mirror of
https://github.com/bdnugget/php-wasm.git
synced 2026-11-07 09:07:28 +00:00
430 lines
14 KiB
JavaScript
430 lines
14 KiB
JavaScript
(function() {
|
|
'use strict';
|
|
|
|
var globals = typeof global === 'undefined' ? self : global;
|
|
if (typeof globals.require === 'function') return;
|
|
|
|
var modules = {};
|
|
var cache = {};
|
|
var aliases = {};
|
|
var has = {}.hasOwnProperty;
|
|
|
|
var expRe = /^\.\.?(\/|$)/;
|
|
var expand = function(root, name) {
|
|
var results = [], part;
|
|
var parts = (expRe.test(name) ? root + '/' + name : name).split('/');
|
|
for (var i = 0, length = parts.length; i < length; i++) {
|
|
part = parts[i];
|
|
if (part === '..') {
|
|
results.pop();
|
|
} else if (part !== '.' && part !== '') {
|
|
results.push(part);
|
|
}
|
|
}
|
|
return results.join('/');
|
|
};
|
|
|
|
var dirname = function(path) {
|
|
return path.split('/').slice(0, -1).join('/');
|
|
};
|
|
|
|
var localRequire = function(path) {
|
|
return function expanded(name) {
|
|
var absolute = expand(dirname(path), name);
|
|
return globals.require(absolute, path);
|
|
};
|
|
};
|
|
|
|
var initModule = function(name, definition) {
|
|
var hot = hmr && hmr.createHot(name);
|
|
var module = {id: name, exports: {}, hot: hot};
|
|
cache[name] = module;
|
|
definition(module.exports, localRequire(name), module);
|
|
return module.exports;
|
|
};
|
|
|
|
var expandAlias = function(name) {
|
|
var val = aliases[name];
|
|
return (val && name !== val) ? expandAlias(val) : name;
|
|
};
|
|
|
|
var _resolve = function(name, dep) {
|
|
return expandAlias(expand(dirname(name), dep));
|
|
};
|
|
|
|
var require = function(name, loaderPath) {
|
|
if (loaderPath == null) loaderPath = '/';
|
|
var path = expandAlias(name);
|
|
|
|
if (has.call(cache, path)) return cache[path].exports;
|
|
if (has.call(modules, path)) return initModule(path, modules[path]);
|
|
|
|
throw new Error("Cannot find module '" + name + "' from '" + loaderPath + "'");
|
|
};
|
|
|
|
require.alias = function(from, to) {
|
|
aliases[to] = from;
|
|
};
|
|
|
|
var extRe = /\.[^.\/]+$/;
|
|
var indexRe = /\/index(\.[^\/]+)?$/;
|
|
var addExtensions = function(bundle) {
|
|
if (extRe.test(bundle)) {
|
|
var alias = bundle.replace(extRe, '');
|
|
if (!has.call(aliases, alias) || aliases[alias].replace(extRe, '') === alias + '/index') {
|
|
aliases[alias] = bundle;
|
|
}
|
|
}
|
|
|
|
if (indexRe.test(bundle)) {
|
|
var iAlias = bundle.replace(indexRe, '');
|
|
if (!has.call(aliases, iAlias)) {
|
|
aliases[iAlias] = bundle;
|
|
}
|
|
}
|
|
};
|
|
|
|
require.register = require.define = function(bundle, fn) {
|
|
if (bundle && typeof bundle === 'object') {
|
|
for (var key in bundle) {
|
|
if (has.call(bundle, key)) {
|
|
require.register(key, bundle[key]);
|
|
}
|
|
}
|
|
} else {
|
|
modules[bundle] = fn;
|
|
delete cache[bundle];
|
|
addExtensions(bundle);
|
|
}
|
|
};
|
|
|
|
require.list = function() {
|
|
var list = [];
|
|
for (var item in modules) {
|
|
if (has.call(modules, item)) {
|
|
list.push(item);
|
|
}
|
|
}
|
|
return list;
|
|
};
|
|
|
|
var hmr = globals._hmr && new globals._hmr(_resolve, require, modules, cache);
|
|
require._cache = cache;
|
|
require.hmr = hmr && hmr.wrap;
|
|
require.brunch = true;
|
|
globals.require = require;
|
|
})();
|
|
|
|
(function() {
|
|
var global = typeof window === 'undefined' ? this : window;
|
|
var process;
|
|
var __makeRelativeRequire = function(require, mappings, pref) {
|
|
var none = {};
|
|
var tryReq = function(name, pref) {
|
|
var val;
|
|
try {
|
|
val = require(pref + '/node_modules/' + name);
|
|
return val;
|
|
} catch (e) {
|
|
if (e.toString().indexOf('Cannot find module') === -1) {
|
|
throw e;
|
|
}
|
|
|
|
if (pref.indexOf('node_modules') !== -1) {
|
|
var s = pref.split('/');
|
|
var i = s.lastIndexOf('node_modules');
|
|
var newPref = s.slice(0, i).join('/');
|
|
return tryReq(name, newPref);
|
|
}
|
|
}
|
|
return none;
|
|
};
|
|
return function(name) {
|
|
if (name in mappings) name = mappings[name];
|
|
if (!name) return;
|
|
if (name[0] !== '.' && pref) {
|
|
var val = tryReq(name, pref);
|
|
if (val !== none) return val;
|
|
}
|
|
return require(name);
|
|
}
|
|
};
|
|
|
|
require.register("process/browser.js", function(exports, require, module) {
|
|
require = __makeRelativeRequire(require, {}, "process");
|
|
(function() {
|
|
// shim for using process in browser
|
|
var process = module.exports = {};
|
|
|
|
// cached from whatever global is present so that test runners that stub it
|
|
// don't break things. But we need to wrap it in a try catch in case it is
|
|
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
|
// function because try/catches deoptimize in certain engines.
|
|
|
|
var cachedSetTimeout;
|
|
var cachedClearTimeout;
|
|
|
|
function defaultSetTimout() {
|
|
throw new Error('setTimeout has not been defined');
|
|
}
|
|
function defaultClearTimeout () {
|
|
throw new Error('clearTimeout has not been defined');
|
|
}
|
|
(function () {
|
|
try {
|
|
if (typeof setTimeout === 'function') {
|
|
cachedSetTimeout = setTimeout;
|
|
} else {
|
|
cachedSetTimeout = defaultSetTimout;
|
|
}
|
|
} catch (e) {
|
|
cachedSetTimeout = defaultSetTimout;
|
|
}
|
|
try {
|
|
if (typeof clearTimeout === 'function') {
|
|
cachedClearTimeout = clearTimeout;
|
|
} else {
|
|
cachedClearTimeout = defaultClearTimeout;
|
|
}
|
|
} catch (e) {
|
|
cachedClearTimeout = defaultClearTimeout;
|
|
}
|
|
} ())
|
|
function runTimeout(fun) {
|
|
if (cachedSetTimeout === setTimeout) {
|
|
//normal enviroments in sane situations
|
|
return setTimeout(fun, 0);
|
|
}
|
|
// if setTimeout wasn't available but was latter defined
|
|
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
cachedSetTimeout = setTimeout;
|
|
return setTimeout(fun, 0);
|
|
}
|
|
try {
|
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
return cachedSetTimeout(fun, 0);
|
|
} catch(e){
|
|
try {
|
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
return cachedSetTimeout.call(null, fun, 0);
|
|
} catch(e){
|
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
|
return cachedSetTimeout.call(this, fun, 0);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
function runClearTimeout(marker) {
|
|
if (cachedClearTimeout === clearTimeout) {
|
|
//normal enviroments in sane situations
|
|
return clearTimeout(marker);
|
|
}
|
|
// if clearTimeout wasn't available but was latter defined
|
|
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
cachedClearTimeout = clearTimeout;
|
|
return clearTimeout(marker);
|
|
}
|
|
try {
|
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
return cachedClearTimeout(marker);
|
|
} catch (e){
|
|
try {
|
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
return cachedClearTimeout.call(null, marker);
|
|
} catch (e){
|
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
|
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
|
return cachedClearTimeout.call(this, marker);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
var queue = [];
|
|
var draining = false;
|
|
var currentQueue;
|
|
var queueIndex = -1;
|
|
|
|
function cleanUpNextTick() {
|
|
if (!draining || !currentQueue) {
|
|
return;
|
|
}
|
|
draining = false;
|
|
if (currentQueue.length) {
|
|
queue = currentQueue.concat(queue);
|
|
} else {
|
|
queueIndex = -1;
|
|
}
|
|
if (queue.length) {
|
|
drainQueue();
|
|
}
|
|
}
|
|
|
|
function drainQueue() {
|
|
if (draining) {
|
|
return;
|
|
}
|
|
var timeout = runTimeout(cleanUpNextTick);
|
|
draining = true;
|
|
|
|
var len = queue.length;
|
|
while(len) {
|
|
currentQueue = queue;
|
|
queue = [];
|
|
while (++queueIndex < len) {
|
|
if (currentQueue) {
|
|
currentQueue[queueIndex].run();
|
|
}
|
|
}
|
|
queueIndex = -1;
|
|
len = queue.length;
|
|
}
|
|
currentQueue = null;
|
|
draining = false;
|
|
runClearTimeout(timeout);
|
|
}
|
|
|
|
process.nextTick = function (fun) {
|
|
var args = new Array(arguments.length - 1);
|
|
if (arguments.length > 1) {
|
|
for (var i = 1; i < arguments.length; i++) {
|
|
args[i - 1] = arguments[i];
|
|
}
|
|
}
|
|
queue.push(new Item(fun, args));
|
|
if (queue.length === 1 && !draining) {
|
|
runTimeout(drainQueue);
|
|
}
|
|
};
|
|
|
|
// v8 likes predictible objects
|
|
function Item(fun, array) {
|
|
this.fun = fun;
|
|
this.array = array;
|
|
}
|
|
Item.prototype.run = function () {
|
|
this.fun.apply(null, this.array);
|
|
};
|
|
process.title = 'browser';
|
|
process.browser = true;
|
|
process.env = {};
|
|
process.argv = [];
|
|
process.version = ''; // empty string to avoid regexp issues
|
|
process.versions = {};
|
|
|
|
function noop() {}
|
|
|
|
process.on = noop;
|
|
process.addListener = noop;
|
|
process.once = noop;
|
|
process.off = noop;
|
|
process.removeListener = noop;
|
|
process.removeAllListeners = noop;
|
|
process.emit = noop;
|
|
process.prependListener = noop;
|
|
process.prependOnceListener = noop;
|
|
|
|
process.listeners = function (name) { return [] }
|
|
|
|
process.binding = function (name) {
|
|
throw new Error('process.binding is not supported');
|
|
};
|
|
|
|
process.cwd = function () { return '/' };
|
|
process.chdir = function (dir) {
|
|
throw new Error('process.chdir is not supported');
|
|
};
|
|
process.umask = function() { return 0; };
|
|
})();
|
|
});
|
|
require.register("DrupalWorker.js", function(exports, require, module) {
|
|
"use strict";
|
|
|
|
var _browser = require("process/browser");
|
|
|
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
|
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
|
|
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
|
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
|
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
|
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
|
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
|
|
self.addEventListener('install', function (event) {
|
|
console.log('Install');
|
|
self.skipWaiting();
|
|
});
|
|
self.addEventListener('activate', function (event) {
|
|
console.log('Activate');
|
|
event.waitUntil(clients.claim());
|
|
});
|
|
self.addEventListener('fetch', function (event) {
|
|
return event.respondWith(new Promise(function (accept) {
|
|
var url = new URL(event.request.url);
|
|
var pathname = url.pathname.replace(/^\//, '');
|
|
var path = pathname.split('/');
|
|
console.log(path);
|
|
|
|
if (!path[path.length - 1].match(/\.\w+$/) && (path[1] === 'drupal-7.59' || path[2] === 'drupal-7.59')) {
|
|
var getClient = self.clients.matchAll({
|
|
includeUncontrolled: true
|
|
});
|
|
var getPost = event.request.method !== 'POST' ? Promise.resolve() : event.request.formData().then(function (formData) {
|
|
var post = {};
|
|
|
|
var _iterator = _createForOfIteratorHelper(formData.keys()),
|
|
_step;
|
|
|
|
try {
|
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
var key = _step.value;
|
|
post[key] = formData.get(key);
|
|
}
|
|
} catch (err) {
|
|
_iterator.e(err);
|
|
} finally {
|
|
_iterator.f();
|
|
}
|
|
|
|
return post;
|
|
});
|
|
return Promise.all([getClient, getPost]).then(function (_ref) {
|
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
clients = _ref2[0],
|
|
post = _ref2[1];
|
|
|
|
clients.forEach(function (client) {
|
|
client.postMessage({
|
|
method: event.request.method,
|
|
path: '/' + pathname,
|
|
_GET: url.search,
|
|
_POST: post || null
|
|
});
|
|
});
|
|
accept(new Response('Loopback Request...'));
|
|
});
|
|
} else {
|
|
accept(fetch(event.request));
|
|
}
|
|
}));
|
|
});
|
|
self.addEventListener('message', function (event) {});
|
|
self.addEventListener('push', function (event) {
|
|
console.log(event);
|
|
});
|
|
|
|
});
|
|
|
|
require.alias("process/browser.js", "process");process = require('process');require.register("___globals___", function(exports, require, module) {
|
|
|
|
});})();require('___globals___');
|
|
|
|
require('DrupalWorker'); |