From 950a71c2308eb438967b30a72403f7df5a04596c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 28 Jan 2023 21:39:10 +0000 Subject: chore: autopublish 2023-01-28T21:39:10Z --- public/~partytown/debug/partytown-ww-sw.js | 251 ++++++++++++++++++++++++----- 1 file changed, 209 insertions(+), 42 deletions(-) (limited to 'public/~partytown/debug/partytown-ww-sw.js') diff --git a/public/~partytown/debug/partytown-ww-sw.js b/public/~partytown/debug/partytown-ww-sw.js index f7f0fab..e18e9b8 100644 --- a/public/~partytown/debug/partytown-ww-sw.js +++ b/public/~partytown/debug/partytown-ww-sw.js @@ -1,4 +1,4 @@ -/* Partytown 0.5.4 - MIT builder.io */ +/* Partytown 0.7.5 - MIT builder.io */ (self => { const WinIdKey = Symbol(); const InstanceIdKey = Symbol(); @@ -54,6 +54,7 @@ }; const EMPTY_ARRAY = []; const randomId = () => Math.round(Math.random() * Number.MAX_SAFE_INTEGER).toString(36); + const SCRIPT_TYPE = "text/partytown"; const defineProperty = (obj, memberName, descriptor) => Object.defineProperty(obj, memberName, { ...descriptor, configurable: true @@ -162,7 +163,7 @@ return deserializeRefFromMain(applyPath, serializedValue); } if (6 === serializedType) { - return noop; + return winId && applyPath.length > 0 ? (...args) => callMethod(environments[winId].$window$, applyPath, args, 1) : noop; } if (3 === serializedType) { return getOrCreateSerializedInstance(serializedValue); @@ -176,6 +177,9 @@ if (1 === serializedType) { return serializedValue.map((v => deserializeFromMain(winId, instanceId, applyPath, v))); } + if (14 === serializedType) { + return new CustomError(serializedValue); + } obj = {}; for (key in serializedValue) { obj[key] = deserializeFromMain(winId, instanceId, [ ...applyPath, key ], serializedValue[key]); @@ -213,7 +217,15 @@ }, $refId$); return webWorkerRefsByRefId[$refId$]; }; - const NodeList = class { + class CustomError extends Error { + constructor(errorObject) { + super(errorObject.message); + this.name = errorObject.name; + this.message = errorObject.message; + this.stack = errorObject.stack; + } + } + class NodeList { constructor(nodes) { (this._ = nodes).map(((node, index) => this[index] = node)); } @@ -238,7 +250,7 @@ [Symbol.iterator]() { return this._[Symbol.iterator](); } - }; + } const Attr = class { constructor(serializedAttr) { this.name = serializedAttr[0]; @@ -288,7 +300,6 @@ const getTargetProp = (target, applyPath) => { let n = ""; if (target) { - target[InstanceIdKey]; const cstrName = getConstructorName(target); if ("Window" === cstrName) { n = ""; @@ -520,7 +531,9 @@ name: applyPath.join("."), continue: HookContinue, nodeName: instance[InstanceDataKey], - constructor: getConstructorName(instance) + constructor: getConstructorName(instance), + instance: instance, + window: environments[instance[WinIdKey]].$window$ }); const addStorageApi = (win, storageName, storages, isSameOrigin, env) => { let getItems = items => { @@ -558,7 +571,18 @@ return getItems().length; } }; - win[storageName] = storage; + win[storageName] = new Proxy(storage, { + get: (target, key) => Reflect.has(target, key) ? Reflect.get(target, key) : target.getItem(key), + set(target, key, value) { + target.setItem(key, value); + return true; + }, + has: (target, key) => !!Reflect.has(target, key) || "string" == typeof key && null !== target.getItem(key), + deleteProperty(target, key) { + target.removeItem(key); + return true; + } + }); }; const STORAGE_KEY = 0; const STORAGE_VALUE = 1; @@ -673,7 +697,7 @@ }; const run = (env, scriptContent, scriptUrl) => { env.$runWindowLoadEvent$ = 1; - scriptContent = `with(this){${(webWorkerCtx.$config$.globalFns || []).filter((globalFnName => /[a-zA-Z_$][0-9a-zA-Z_$]*/.test(globalFnName))).map((g => `(typeof ${g}=='function'&&(window.${g}=${g}))`)).join(";") + scriptContent.replace(/\bthis\b/g, "(thi$(this)?window:this)").replace(/\/\/# so/g, "//Xso")}\n;function thi$(t){return t===this}}` + (scriptUrl ? "\n//# sourceURL=" + scriptUrl : ""); + scriptContent = `with(this){${scriptContent.replace(/\bthis\b/g, "(thi$(this)?window:this)").replace(/\/\/# so/g, "//Xso")}\n;function thi$(t){return t===this}};${(webWorkerCtx.$config$.globalFns || []).filter((globalFnName => /[a-zA-Z_$][0-9a-zA-Z_$]*/.test(globalFnName))).map((g => `(typeof ${g}=='function'&&(this.${g}=${g}))`)).join(";")};` + (scriptUrl ? "\n//# sourceURL=" + scriptUrl : ""); env.$isSameOrigin$ || (scriptContent = scriptContent.replace(/.postMessage\(/g, `.postMessage('${env.$winId$}',`)); new Function(scriptContent).call(env.$window$); env.$runWindowLoadEvent$ = 0; @@ -684,7 +708,7 @@ type: type }))))); }; - const resolveToUrl = (env, url, noUserHook, baseLocation, resolvedUrl, configResolvedUrl) => { + const resolveToUrl = (env, url, type, baseLocation, resolvedUrl, configResolvedUrl) => { baseLocation = env.$location$; while (!baseLocation.host) { env = environments[env.$parentWinId$]; @@ -694,29 +718,32 @@ } } resolvedUrl = new URL(url || "", baseLocation); - if (!noUserHook && webWorkerCtx.$config$.resolveUrl) { - configResolvedUrl = webWorkerCtx.$config$.resolveUrl(resolvedUrl, baseLocation); + if (type && webWorkerCtx.$config$.resolveUrl) { + configResolvedUrl = webWorkerCtx.$config$.resolveUrl(resolvedUrl, baseLocation, type); if (configResolvedUrl) { return configResolvedUrl; } } return resolvedUrl; }; - const resolveUrl = (env, url, noUserHook) => resolveToUrl(env, url, noUserHook) + ""; - const getPartytownScript = () => `