@builder.io/partytown
Advanced tools
Comparing version 0.0.20 to 0.0.21
@@ -6,4 +6,4 @@ { | ||
"types": "index.d.ts", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"private": true | ||
} |
@@ -1,2 +0,2 @@ | ||
/* Partytown 0.0.20 - MIT builder.io */ | ||
/* Partytown 0.0.21 - MIT builder.io */ | ||
const isPromise = v => "object" == typeof v && v && v.then; | ||
@@ -65,6 +65,7 @@ | ||
const getInstance = (winId, instanceId, instanceItem) => { | ||
const win = winCtxs[winId].$window$; | ||
const doc = win.document; | ||
return 0 === instanceId ? win : 1 === instanceId ? doc : 2 === instanceId ? doc.documentElement : 3 === instanceId ? doc.head : 4 === instanceId ? doc.body : instances.get(instanceId); | ||
const getInstance = (winId, instanceId, winCtx, win, doc) => { | ||
if ((winCtx = winCtxs[winId]) && (win = winCtx.$window$)) { | ||
doc = win.document; | ||
return 0 === instanceId ? win : 1 === instanceId ? doc : 2 === instanceId ? doc.documentElement : 3 === instanceId ? doc.head : 4 === instanceId ? doc.body : instances.get(instanceId); | ||
} | ||
}; | ||
@@ -194,2 +195,46 @@ | ||
const mainAccessHandler = async (worker, accessReq) => { | ||
const accessRsp = { | ||
$msgId$: accessReq.$msgId$ | ||
}; | ||
const totalTasks = len(accessReq.$tasks$); | ||
for (let i = 0; i < totalTasks; i++) { | ||
try { | ||
let task = accessReq.$tasks$[i]; | ||
let winId = task.$winId$; | ||
let instanceId = task.$instanceId$; | ||
let applyPath = task.$applyPath$; | ||
let instance; | ||
let rtnValue; | ||
winCtxs[winId] || await new Promise((resolve => { | ||
let i = 0; | ||
let callback = () => { | ||
winCtxs[winId] || i++ > 999 ? resolve() : setTimeout(callback, 9); | ||
}; | ||
callback(); | ||
})); | ||
if (1 === applyPath[0] && applyPath[1] in winCtxs[winId].$window$) { | ||
const constructedInstance = new winCtxs[winId].$window$[applyPath[1]](...deserializeFromWorker(worker, applyPath[2])); | ||
setInstanceId(constructedInstance, instanceId); | ||
} else { | ||
instance = getInstance(winId, instanceId); | ||
if (instance) { | ||
rtnValue = applyToInstance(worker, instance, applyPath, task.$groupedGetters$); | ||
task.$assignInstanceId$ && setInstanceId(rtnValue, task.$assignInstanceId$); | ||
if (isPromise(rtnValue)) { | ||
rtnValue = await rtnValue; | ||
accessRsp.$isPromise$ = !0; | ||
} | ||
accessRsp.$rtnValue$ = serializeForWorker(winId, rtnValue); | ||
} else { | ||
accessRsp.$error$ = instanceId + " not found"; | ||
} | ||
} | ||
} catch (e) { | ||
i === totalTasks - 1 ? accessRsp.$error$ = String(e.stack || e) : console.error(e); | ||
} | ||
} | ||
return accessRsp; | ||
}; | ||
const applyToInstance = (worker, instance, applyPath, groupedGetters) => { | ||
@@ -238,13 +283,25 @@ let i = 0; | ||
const doc = $window$.document; | ||
const $url$ = doc.baseURI; | ||
const history = $window$.history; | ||
const envData = { | ||
$winId$: $winId$, | ||
$parentWinId$: windowIds.get($window$.parent), | ||
$url$: $url$ | ||
$url$: doc.baseURI | ||
}; | ||
const sendInitEnvData = () => worker.postMessage([ 3, envData ]); | ||
const pushState = history.pushState.bind(history); | ||
const replaceState = history.replaceState.bind(history); | ||
const onLocationChange = () => setTimeout((() => worker.postMessage([ 11, $winId$, doc.baseURI ]))); | ||
history.pushState = (data, _, url) => { | ||
pushState(data, _, url); | ||
onLocationChange(); | ||
}; | ||
history.replaceState = (data, _, url) => { | ||
replaceState(data, _, url); | ||
onLocationChange(); | ||
}; | ||
$window$.addEventListener("popstate", onLocationChange); | ||
$window$.addEventListener("hashchange", onLocationChange); | ||
winCtxs[$winId$] = { | ||
$winId$: $winId$, | ||
$window$: $window$, | ||
$url$: $url$ | ||
$window$: $window$ | ||
}; | ||
@@ -340,3 +397,3 @@ winCtxs[$winId$].$startTime$ = performance.now(); | ||
try { | ||
isValidMemberName(memberName) && isNaN(memberName[0]) && ("function" === (memberType = typeof (value = implementation[memberName])) ? String(value).includes("[native") && interfaceMembers.push([ memberName, 5 ]) : "object" === memberType && null != value ? "Object" !== (cstrName = getConstructorName(value)) && window[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]) : "symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]))); | ||
isValidMemberName(memberName) && isNaN(memberName[0]) && ("function" === (memberType = typeof (value = implementation[memberName])) ? (String(value).includes("[native") || Object.getPrototypeOf(implementation)[memberName]) && interfaceMembers.push([ memberName, 5 ]) : "object" === memberType && null != value ? "Object" !== (cstrName = getConstructorName(value)) && window[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]) : "symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]))); | ||
} catch (e) { | ||
@@ -430,45 +487,3 @@ console.warn(e); | ||
const mainWindow = sandboxWindow.parent; | ||
const onMessageHandler = await createMessengerAtomics(0, ((accessReq, responseCallback) => (async (worker, accessReq) => { | ||
const accessRsp = { | ||
$msgId$: accessReq.$msgId$ | ||
}; | ||
const totalTasks = len(accessReq.$tasks$); | ||
for (let i = 0; i < totalTasks; i++) { | ||
try { | ||
let task = accessReq.$tasks$[i]; | ||
let winId = task.$winId$; | ||
let instanceId = task.$instanceId$; | ||
let applyPath = task.$applyPath$; | ||
let instance; | ||
let rtnValue; | ||
winCtxs[winId] || await new Promise((resolve => { | ||
let i = 0; | ||
let callback = () => { | ||
winCtxs[winId] || i++ > 999 ? resolve() : setTimeout(callback, 9); | ||
}; | ||
callback(); | ||
})); | ||
if (1 === applyPath[0] && applyPath[1] in winCtxs[winId].$window$) { | ||
const constructedInstance = new winCtxs[winId].$window$[applyPath[1]](...deserializeFromWorker(worker, applyPath[2])); | ||
setInstanceId(constructedInstance, instanceId); | ||
} else { | ||
instance = getInstance(winId, instanceId); | ||
if (instance) { | ||
rtnValue = applyToInstance(worker, instance, applyPath, task.$groupedGetters$); | ||
task.$assignInstanceId$ && setInstanceId(rtnValue, task.$assignInstanceId$); | ||
if (isPromise(rtnValue)) { | ||
rtnValue = await rtnValue; | ||
accessRsp.$isPromise$ = !0; | ||
} | ||
accessRsp.$rtnValue$ = serializeForWorker(winId, rtnValue); | ||
} else { | ||
accessRsp.$error$ = instanceId + " not found"; | ||
} | ||
} | ||
} catch (e) { | ||
i === totalTasks - 1 ? accessRsp.$error$ = String(e.stack || e) : console.error(e); | ||
} | ||
} | ||
return accessRsp; | ||
})(worker, accessReq).then(responseCallback))); | ||
const onMessageHandler = await createMessengerAtomics(0, ((accessReq, responseCallback) => mainAccessHandler(worker, accessReq).then(responseCallback))); | ||
if (onMessageHandler) { | ||
@@ -478,3 +493,6 @@ worker = new Worker("./partytown-ww-atomics.js", { | ||
}); | ||
worker.onmessage = ev => onMessageHandler(worker, mainWindow, ev.data); | ||
worker.onmessage = ev => { | ||
const msg = ev.data; | ||
10 === msg[0] ? mainAccessHandler(worker, msg[1]) : onMessageHandler(worker, mainWindow, msg); | ||
}; | ||
logMain("Created web worker"); | ||
@@ -481,0 +499,0 @@ worker.onerror = ev => console.error("Web Worker Error", ev); |
@@ -1,2 +0,2 @@ | ||
/* Partytown 0.0.20 - MIT builder.io */ | ||
/* Partytown 0.0.21 - MIT builder.io */ | ||
(window => { | ||
@@ -50,6 +50,7 @@ const isPromise = v => "object" == typeof v && v && v.then; | ||
}; | ||
const getInstance = (winId, instanceId, instanceItem) => { | ||
const win = winCtxs[winId].$window$; | ||
const doc = win.document; | ||
return 0 === instanceId ? win : 1 === instanceId ? doc : 2 === instanceId ? doc.documentElement : 3 === instanceId ? doc.head : 4 === instanceId ? doc.body : instances.get(instanceId); | ||
const getInstance = (winId, instanceId, winCtx, win, doc) => { | ||
if ((winCtx = winCtxs[winId]) && (win = winCtx.$window$)) { | ||
doc = win.document; | ||
return 0 === instanceId ? win : 1 === instanceId ? doc : 2 === instanceId ? doc.documentElement : 3 === instanceId ? doc.head : 4 === instanceId ? doc.body : instances.get(instanceId); | ||
} | ||
}; | ||
@@ -168,2 +169,45 @@ const setInstanceId = (instance, instanceId) => { | ||
const validCssRuleProps = "cssText,selectorText,href,media,namespaceURI,prefix,name,conditionText".split(","); | ||
const mainAccessHandler = async (worker, accessReq) => { | ||
const accessRsp = { | ||
$msgId$: accessReq.$msgId$ | ||
}; | ||
const totalTasks = len(accessReq.$tasks$); | ||
for (let i = 0; i < totalTasks; i++) { | ||
try { | ||
let task = accessReq.$tasks$[i]; | ||
let winId = task.$winId$; | ||
let instanceId = task.$instanceId$; | ||
let applyPath = task.$applyPath$; | ||
let instance; | ||
let rtnValue; | ||
winCtxs[winId] || await new Promise((resolve => { | ||
let i = 0; | ||
let callback = () => { | ||
winCtxs[winId] || i++ > 999 ? resolve() : setTimeout(callback, 9); | ||
}; | ||
callback(); | ||
})); | ||
if (1 === applyPath[0] && applyPath[1] in winCtxs[winId].$window$) { | ||
const constructedInstance = new winCtxs[winId].$window$[applyPath[1]](...deserializeFromWorker(worker, applyPath[2])); | ||
setInstanceId(constructedInstance, instanceId); | ||
} else { | ||
instance = getInstance(winId, instanceId); | ||
if (instance) { | ||
rtnValue = applyToInstance(worker, instance, applyPath, task.$groupedGetters$); | ||
task.$assignInstanceId$ && setInstanceId(rtnValue, task.$assignInstanceId$); | ||
if (isPromise(rtnValue)) { | ||
rtnValue = await rtnValue; | ||
accessRsp.$isPromise$ = !0; | ||
} | ||
accessRsp.$rtnValue$ = serializeForWorker(winId, rtnValue); | ||
} else { | ||
accessRsp.$error$ = instanceId + " not found"; | ||
} | ||
} | ||
} catch (e) { | ||
i === totalTasks - 1 ? accessRsp.$error$ = String(e.stack || e) : console.error(e); | ||
} | ||
} | ||
return accessRsp; | ||
}; | ||
const applyToInstance = (worker, instance, applyPath, groupedGetters) => { | ||
@@ -211,13 +255,25 @@ let i = 0; | ||
const doc = $window$.document; | ||
const $url$ = doc.baseURI; | ||
const history = $window$.history; | ||
const envData = { | ||
$winId$: $winId$, | ||
$parentWinId$: windowIds.get($window$.parent), | ||
$url$: $url$ | ||
$url$: doc.baseURI | ||
}; | ||
const sendInitEnvData = () => worker.postMessage([ 3, envData ]); | ||
const pushState = history.pushState.bind(history); | ||
const replaceState = history.replaceState.bind(history); | ||
const onLocationChange = () => setTimeout((() => worker.postMessage([ 11, $winId$, doc.baseURI ]))); | ||
history.pushState = (data, _, url) => { | ||
pushState(data, _, url); | ||
onLocationChange(); | ||
}; | ||
history.replaceState = (data, _, url) => { | ||
replaceState(data, _, url); | ||
onLocationChange(); | ||
}; | ||
$window$.addEventListener("popstate", onLocationChange); | ||
$window$.addEventListener("hashchange", onLocationChange); | ||
winCtxs[$winId$] = { | ||
$winId$: $winId$, | ||
$window$: $window$, | ||
$url$: $url$ | ||
$window$: $window$ | ||
}; | ||
@@ -344,3 +400,3 @@ winCtxs[$winId$].$startTime$ = performance.now(); | ||
try { | ||
isValidMemberName(memberName) && isNaN(memberName[0]) && ("function" === (memberType = typeof (value = implementation[memberName])) ? String(value).includes("[native") && interfaceMembers.push([ memberName, 5 ]) : "object" === memberType && null != value ? "Object" !== (cstrName = getConstructorName(value)) && window[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]) : "symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]))); | ||
isValidMemberName(memberName) && isNaN(memberName[0]) && ("function" === (memberType = typeof (value = implementation[memberName])) ? (String(value).includes("[native") || Object.getPrototypeOf(implementation)[memberName]) && interfaceMembers.push([ memberName, 5 ]) : "object" === memberType && null != value ? "Object" !== (cstrName = getConstructorName(value)) && window[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]) : "symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]))); | ||
} catch (e) { | ||
@@ -377,45 +433,3 @@ console.warn(e); | ||
} : null; | ||
})(sandboxWindow, ((accessReq, responseCallback) => (async (worker, accessReq) => { | ||
const accessRsp = { | ||
$msgId$: accessReq.$msgId$ | ||
}; | ||
const totalTasks = len(accessReq.$tasks$); | ||
for (let i = 0; i < totalTasks; i++) { | ||
try { | ||
let task = accessReq.$tasks$[i]; | ||
let winId = task.$winId$; | ||
let instanceId = task.$instanceId$; | ||
let applyPath = task.$applyPath$; | ||
let instance; | ||
let rtnValue; | ||
winCtxs[winId] || await new Promise((resolve => { | ||
let i = 0; | ||
let callback = () => { | ||
winCtxs[winId] || i++ > 999 ? resolve() : setTimeout(callback, 9); | ||
}; | ||
callback(); | ||
})); | ||
if (1 === applyPath[0] && applyPath[1] in winCtxs[winId].$window$) { | ||
const constructedInstance = new winCtxs[winId].$window$[applyPath[1]](...deserializeFromWorker(worker, applyPath[2])); | ||
setInstanceId(constructedInstance, instanceId); | ||
} else { | ||
instance = getInstance(winId, instanceId); | ||
if (instance) { | ||
rtnValue = applyToInstance(worker, instance, applyPath, task.$groupedGetters$); | ||
task.$assignInstanceId$ && setInstanceId(rtnValue, task.$assignInstanceId$); | ||
if (isPromise(rtnValue)) { | ||
rtnValue = await rtnValue; | ||
accessRsp.$isPromise$ = !0; | ||
} | ||
accessRsp.$rtnValue$ = serializeForWorker(winId, rtnValue); | ||
} else { | ||
accessRsp.$error$ = instanceId + " not found"; | ||
} | ||
} | ||
} catch (e) { | ||
i === totalTasks - 1 ? accessRsp.$error$ = String(e.stack || e) : console.error(e); | ||
} | ||
} | ||
return accessRsp; | ||
})(worker, accessReq).then(responseCallback))); | ||
})(sandboxWindow, ((accessReq, responseCallback) => mainAccessHandler(worker, accessReq).then(responseCallback))); | ||
if (onMessageHandler) { | ||
@@ -425,3 +439,6 @@ worker = new Worker("./partytown-ww-sw.js", { | ||
}); | ||
worker.onmessage = ev => onMessageHandler(worker, mainWindow, ev.data); | ||
worker.onmessage = ev => { | ||
const msg = ev.data; | ||
10 === msg[0] ? mainAccessHandler(worker, msg[1]) : onMessageHandler(worker, mainWindow, msg); | ||
}; | ||
logMain("Created web worker"); | ||
@@ -428,0 +445,0 @@ worker.onerror = ev => console.error("Web Worker Error", ev); |
@@ -1,2 +0,2 @@ | ||
/* Partytown 0.0.20 - MIT builder.io */ | ||
/* Partytown 0.0.21 - MIT builder.io */ | ||
const resolves = new Map; | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
/* Partytown 0.0.20 - MIT builder.io */ | ||
/* Partytown 0.0.21 - MIT builder.io */ | ||
(self => { | ||
@@ -188,2 +188,3 @@ const WinIdKey = Symbol(); | ||
const taskQueue = []; | ||
let asyncMsgTimer = 0; | ||
const queue = (instance, $applyPath$, isSetter, $assignInstanceId$, $groupedGetters$) => { | ||
@@ -199,7 +200,8 @@ const $instanceId$ = instance[InstanceIdKey]; | ||
if (!isSetter) { | ||
return sync(); | ||
return sendToMain(!0); | ||
} | ||
setTimeout(sync, 40); | ||
asyncMsgTimer = setTimeout(sendToMain, 30); | ||
}; | ||
const sync = () => { | ||
const sendToMain = isBlocking => { | ||
clearTimeout(asyncMsgTimer); | ||
if (len(taskQueue)) { | ||
@@ -213,25 +215,28 @@ webWorkerCtx.$config$.logMainAccess && logWorker(`Main access, tasks sent: ${taskQueue.length}`); | ||
taskQueue.length = 0; | ||
const accessRsp = ((webWorkerCtx, accessReq) => { | ||
const sharedDataBuffer = webWorkerCtx.$sharedDataBuffer$; | ||
const sharedData = new Int32Array(sharedDataBuffer); | ||
Atomics.store(sharedData, 0, 0); | ||
webWorkerCtx.$postMessage$([ 9, accessReq ]); | ||
Atomics.wait(sharedData, 0, 0); | ||
let dataLength = Atomics.load(sharedData, 0); | ||
0 === dataLength && console.error("Atomics failed", sharedDataBuffer); | ||
let accessRespStr = ""; | ||
for (let i = 0; i < dataLength; i++) { | ||
accessRespStr += String.fromCharCode(sharedData[i + 1]); | ||
if (isBlocking) { | ||
const accessRsp = ((webWorkerCtx, accessReq) => { | ||
const sharedDataBuffer = webWorkerCtx.$sharedDataBuffer$; | ||
const sharedData = new Int32Array(sharedDataBuffer); | ||
Atomics.store(sharedData, 0, 0); | ||
webWorkerCtx.$postMessage$([ 9, accessReq ]); | ||
Atomics.wait(sharedData, 0, 0); | ||
let dataLength = Atomics.load(sharedData, 0); | ||
0 === dataLength && console.error("Atomics failed", sharedDataBuffer); | ||
let accessRespStr = ""; | ||
for (let i = 0; i < dataLength; i++) { | ||
accessRespStr += String.fromCharCode(sharedData[i + 1]); | ||
} | ||
return JSON.parse(accessRespStr); | ||
})(webWorkerCtx, accessReq); | ||
const isPromise = accessRsp.$isPromise$; | ||
const rtnValue = deserializeFromMain(endTask.$instanceId$, endTask.$applyPath$, accessRsp.$rtnValue$); | ||
if (accessRsp.$error$) { | ||
if (isPromise) { | ||
return Promise.reject(accessRsp.$error$); | ||
} | ||
throw new Error(accessRsp.$error$); | ||
} | ||
return JSON.parse(accessRespStr); | ||
})(webWorkerCtx, accessReq); | ||
const isPromise = accessRsp.$isPromise$; | ||
const rtnValue = deserializeFromMain(endTask.$instanceId$, endTask.$applyPath$, accessRsp.$rtnValue$); | ||
if (accessRsp.$error$) { | ||
if (isPromise) { | ||
return Promise.reject(accessRsp.$error$); | ||
} | ||
throw new Error(accessRsp.$error$); | ||
return isPromise ? Promise.resolve(rtnValue) : rtnValue; | ||
} | ||
return isPromise ? Promise.resolve(rtnValue) : rtnValue; | ||
webWorkerCtx.$postMessage$([ 10, accessReq ]); | ||
} | ||
@@ -599,2 +604,3 @@ }; | ||
const winId = iframe[InstanceIdKey]; | ||
setter(iframe, [ "dataset", "ptwindow" ], winId); | ||
const callback = () => { | ||
@@ -612,3 +618,3 @@ if (environments[winId] && environments[winId].$isInitialized$) { | ||
}))); | ||
console.error("Timeout"); | ||
console.error(`Iframe timeout: ${winId}`); | ||
} else { | ||
@@ -621,3 +627,3 @@ setTimeout(callback, 9); | ||
if (isScript) { | ||
sync(); | ||
sendToMain(!0); | ||
webWorkerCtx.$postMessage$([ 6, winId ]); | ||
@@ -1313,2 +1319,4 @@ } | ||
} | ||
} else { | ||
11 === msgType && (environments[msg[1]].$location$.href = msg[2]); | ||
} | ||
@@ -1315,0 +1323,0 @@ } else if (1 === msgType) { |
@@ -1,2 +0,2 @@ | ||
/* Partytown 0.0.20 - MIT builder.io */ | ||
/* Partytown 0.0.21 - MIT builder.io */ | ||
(self => { | ||
@@ -188,2 +188,3 @@ const WinIdKey = Symbol(); | ||
const taskQueue = []; | ||
let asyncMsgTimer = 0; | ||
const queue = (instance, $applyPath$, isSetter, $assignInstanceId$, $groupedGetters$) => { | ||
@@ -199,7 +200,8 @@ const $instanceId$ = instance[InstanceIdKey]; | ||
if (!isSetter) { | ||
return sync(); | ||
return sendToMain(!0); | ||
} | ||
setTimeout(sync, 40); | ||
asyncMsgTimer = setTimeout(sendToMain, 30); | ||
}; | ||
const sync = () => { | ||
const sendToMain = isBlocking => { | ||
clearTimeout(asyncMsgTimer); | ||
if (len(taskQueue)) { | ||
@@ -213,18 +215,21 @@ webWorkerCtx.$config$.logMainAccess && logWorker(`Main access, tasks sent: ${taskQueue.length}`); | ||
taskQueue.length = 0; | ||
const accessRsp = ((webWorkerCtx, accessReq) => { | ||
const xhr = new XMLHttpRequest; | ||
const url = webWorkerCtx.$libPath$ + "proxytown"; | ||
xhr.open("POST", url, !1); | ||
xhr.send(JSON.stringify(accessReq)); | ||
return JSON.parse(xhr.responseText); | ||
})(webWorkerCtx, accessReq); | ||
const isPromise = accessRsp.$isPromise$; | ||
const rtnValue = deserializeFromMain(endTask.$instanceId$, endTask.$applyPath$, accessRsp.$rtnValue$); | ||
if (accessRsp.$error$) { | ||
if (isPromise) { | ||
return Promise.reject(accessRsp.$error$); | ||
if (isBlocking) { | ||
const accessRsp = ((webWorkerCtx, accessReq) => { | ||
const xhr = new XMLHttpRequest; | ||
const url = webWorkerCtx.$libPath$ + "proxytown"; | ||
xhr.open("POST", url, !1); | ||
xhr.send(JSON.stringify(accessReq)); | ||
return JSON.parse(xhr.responseText); | ||
})(webWorkerCtx, accessReq); | ||
const isPromise = accessRsp.$isPromise$; | ||
const rtnValue = deserializeFromMain(endTask.$instanceId$, endTask.$applyPath$, accessRsp.$rtnValue$); | ||
if (accessRsp.$error$) { | ||
if (isPromise) { | ||
return Promise.reject(accessRsp.$error$); | ||
} | ||
throw new Error(accessRsp.$error$); | ||
} | ||
throw new Error(accessRsp.$error$); | ||
return isPromise ? Promise.resolve(rtnValue) : rtnValue; | ||
} | ||
return isPromise ? Promise.resolve(rtnValue) : rtnValue; | ||
webWorkerCtx.$postMessage$([ 10, accessReq ]); | ||
} | ||
@@ -592,2 +597,3 @@ }; | ||
const winId = iframe[InstanceIdKey]; | ||
setter(iframe, [ "dataset", "ptwindow" ], winId); | ||
const callback = () => { | ||
@@ -605,3 +611,3 @@ if (environments[winId] && environments[winId].$isInitialized$) { | ||
}))); | ||
console.error("Timeout"); | ||
console.error(`Iframe timeout: ${winId}`); | ||
} else { | ||
@@ -614,3 +620,3 @@ setTimeout(callback, 9); | ||
if (isScript) { | ||
sync(); | ||
sendToMain(!0); | ||
webWorkerCtx.$postMessage$([ 6, winId ]); | ||
@@ -1306,2 +1312,4 @@ } | ||
} | ||
} else { | ||
11 === msgType && (environments[msg[1]].$location$.href = msg[2]); | ||
} | ||
@@ -1308,0 +1316,0 @@ } else if (1 === msgType) { |
@@ -1,2 +0,2 @@ | ||
/* Partytown 0.0.20 - MIT builder.io */ | ||
/* Partytown 0.0.21 - MIT builder.io */ | ||
!function(win, doc, nav, libPath, sandbox, scripts, timeout) { | ||
@@ -3,0 +3,0 @@ function loadSandbox(msgType) { |
@@ -1,2 +0,2 @@ | ||
/* Partytown 0.0.20 - MIT builder.io */ | ||
const e=new Map,t=(e,t)=>({C:e.C,l:t}),r=(e,t,r)=>{const n={"content-type":r||"text/html","Cache-Control":"no-store"};return t&&(n["Cross-Origin-Embedder-Policy"]="require-corp"),new Response(e,{headers:n})};self.oninstall=()=>self.skipWaiting(),self.onactivate=()=>self.clients.claim(),self.onmessage=t=>{const r=t.data,n=e.get(r.C);n&&(e.delete(r.C),clearTimeout(n[1]),n[0](r))},self.onfetch=n=>{const s=n.request,o=new URL(s.url).pathname;o.endsWith("partytown-sandbox-sw.html")?n.respondWith(r('<!DOCTYPE html><html><head><meta charset="utf-8"><script type="module">/* Partytown 0.0.20 - MIT builder.io */\n(e=>{const t=()=>!0,r=e=>e.length,n=e=>{try{return e.constructor.name}catch(e){}return""},s=(e,t)=>e.startsWith(t),o=e=>!(s(e,"webkit")||s(e,"toJSON")||s(e,"constructor")||s(e,"toString")||s(e,"_")),i=()=>Math.round(9999999999*Math.random()+4),a=new WeakMap,c=new Map,l=new Map,u={},h=new WeakMap,d=(e,t,r)=>e?e===e.window?0:"#document"===(r=e.nodeName)?1:"HTML"===r?2:"HEAD"===r?3:"BODY"===r?4:("number"!=typeof(t=a.get(e))&&m(e,t=i()),t):-1,p=(e,t,r)=>{const n=u[e].M,s=n.document;return 0===t?n:1===t?s:2===t?s.documentElement:3===t?s.head:4===t?s.body:c.get(t)},m=(e,t)=>{e&&(c.set(t,e),a.set(e,t),g++,g>99999&&(c.forEach(((e,t)=>{e.nodeType&&!e.isConnected&&c.delete(t)})),g=0))};let g=0;const f=(e,t,r,o,i)=>{if(void 0!==t){if("string"==(o=typeof t)||"number"===o||"boolean"===o||null==t)return[9,t];if("function"===o)return[5];if(r=r||new Set,Array.isArray(t))return r.has(t)?[0,[]]:(r.add(t),[0,t.map((t=>f(e,t,r)))]);if("object"===o)return""===(i=n(t))?[8,{}]:"Window"===i?[6,{P:e,t:0}]:"HTMLCollection"===i||"NodeList"===i?[7,Array.from(t).map((t=>f(e,t,r)[1]))]:"Event"===i?[4,y(e,t,r)]:"CSSRuleList"===i?[3,Array.from(t).map($)]:s(i,"CSS")&&i.endsWith("Rule")?[2,$(t)]:"CSSStyleDeclaration"===i?[8,y(e,t,r)]:"Attr"===i?[1,[t.name,t.value]]:t.nodeType?[6,{P:e,t:d(t),D:t.nodeName}]:[8,y(e,t,r,!0,!0)]}},y=(e,t,r,n,s,i,a,c)=>{if(i={},!r.has(t))for(a in r.add(t),t)o(a)&&(c=t[a],(n||"function"!=typeof c)&&(s||""!==c)&&(i[a]=f(e,c,r)));return i},$=e=>{let t,r={};for(t in e)T.includes(t)&&(r[t]=e[t]);return r},w=(e,t,r,n)=>{if(t){if(r=t[0],n=t[1],9===r)return n;if(10===r)return v(e,n);if(0===r)return n.map((t=>w(e,t)));if(6===r)return p(n.P,n.t);if(4===r)return b(E(e,n));if(8===r)return E(e,n)}},v=(e,{P:t,t:r,G:n})=>{let s=l.get(n);return s||(s=function(...s){const o={t:r,G:n,K:f(t,this),b:f(t,s)};e.postMessage([7,o])},l.set(n,s)),s},b=e=>new("detail"in e?CustomEvent:Event)(e.type,e),E=(e,t,r,n)=>{for(n in r={},t)r[n]=w(e,t[n]);return r},T="cssText,selectorText,href,media,namespaceURI,prefix,name,conditionText".split(","),M=(e,t,n,s)=>{let o,i,a,c,l=0,u=r(n);for(;l<u;l++){i=n[l],o=n[l+1],a=n[l-1];try{if(!Array.isArray(o))if("string"==typeof i||"number"==typeof i){if(l+1===u&&s){const e={};return s.map((r=>e[r]=t[r])),e}t=t[i]}else{if(0===o)return void(t[a]=w(e,i));"function"==typeof t[a]&&(c=w(e,i),"insertRule"===a&&c[1]>r(t.cssRules)&&(c[1]=r(t.cssRules)),t=t[a].apply(t,c))}}catch(e){console.warn(e)}}return t},S=(e,t,r)=>{if(!h.has(r)){h.set(r,t);const n=r.document,s=n.baseURI,o={P:t,E:h.get(r.parent),L:s},i=()=>e.postMessage([3,o]);u[t]={P:t,M:r,L:s},"complete"===n.readyState?i():r.addEventListener("load",i)}},N=(e,t)=>{let n,s,o=t.P,i=t.M,a=i.document,c=a.querySelector(\'script[type="text/partytown"]:not([data-ptid]):not([data-pterror]):not([async]):not([defer])\');c||(c=a.querySelector(\'script[type="text/partytown"]:not([data-ptid]):not([data-pterror])\')),c?(c.dataset.ptid=n=d(c,o),s={P:o,t:n},c.src?s.L=c.src:s.f=c.innerHTML,e.postMessage([6,s])):t.v||(t.v=1,((e,t,n)=>{let s=n._ptf,o=n._ptf=[],i=0;if(o.push=(r,n)=>e.postMessage([8,{P:t,t:0,m:r,b:f(t,Array.from(n))}]),s)for(;i<r(s);i+=2)o.push(s[i],s[i+1])})(e,o,i),a.dispatchEvent(new CustomEvent("pt0")),e.postMessage([4,o]))},L=e=>{const r=e.document.implementation.createHTMLDocument(),n=r.createTextNode(""),s=r.createComment(""),o=r.createDocumentFragment(),i=r.createElement("i"),a=r.createElementNS("http://www.w3.org/2000/svg","svg"),c=r.createElement("canvas").getContext("2d"),l=new MutationObserver(t),u=new ResizeObserver(t),h=Object.getOwnPropertyNames(e).filter((e=>/^HTML.+Element$/.test(e))).map((e=>{const t=A(e);return[r.createElement(t)]})),d=[[e.localStorage],[e.history],[e.screen],[e.screen.orientation],[l,12],[u,12],[n],[s],[o],[i],[i.attributes],[i.classList],[i.dataset],[i.style],[a],[r],[r.doctype],[c],...h].filter((e=>e[0])).map((t=>{const r=t[0],n=t[1],s=r.constructor.name;return[s,e[s].prototype,r,n]})),p=[I("Window",e),I("Node",n)],m=e.partytown||{},g=(m.lib||"/~partytown/")+"",f={e:JSON.stringify(m,((e,t)=>("function"==typeof t&&(t=String(t)).startsWith(e+"(")&&(t="function "+t),t))),z:new URL(g,e.location)+"",s:p};return d.map((([e,t,r,n])=>O(p,e,t,r,n))),f},I=(e,t)=>{const r=[],n=[e,"Object",r];for(const e in t)x(r,t,e);return n},O=(e,t,r,n,s)=>{if("Object"!==t&&!e.some((e=>e[0]===t))){const o=Object.getPrototypeOf(r),i=o.constructor.name,a=[];O(e,i,o,n,s),Object.keys(Object.getOwnPropertyDescriptors(r)).map((e=>x(a,n,e))),e.push([t,i,a,s,n.nodeName])}},x=(t,r,s,i,a,c)=>{try{o(s)&&isNaN(s[0])&&("function"==(a=typeof(i=r[s]))?String(i).includes("[native")&&t.push([s,5]):"object"===a&&null!=i?"Object"!==(c=n(i))&&e[c]&&t.push([s,i.nodeType||c]):"symbol"!==a&&(s.toUpperCase()===s?t.push([s,6,i]):t.push([s,6])))}catch(e){console.warn(e)}},C={Anchor:"A",DList:"DL",Image:"IMG",OList:"OL",Paragraph:"P",TableCaption:"CAPTION",TableCell:"TD",TableCol:"COLGROUP",TableRow:"TR",TableSection:"TBODY",UList:"UL"},A=e=>(e=e.substr(4).replace("Element",""),C[e]||e);(async e=>{let t;const n=e.parent,s=await(async(e,n)=>{const s=e.navigator.serviceWorker,o=await s.getRegistration();return s.addEventListener("message",(e=>{return n=e.data,s=e=>o.active&&o.active.postMessage(e),(async(e,t)=>{const n={C:t.C},s=r(t.J);for(let r=0;r<s;r++)try{let s,i,a=t.J[r],c=a.P,l=a.t,h=a.a;if(u[c]||await new Promise((e=>{let t=0,r=()=>{u[c]||t++>999?e():setTimeout(r,9)};r()})),1===h[0]&&h[1]in u[c].M){const t=new u[c].M[h[1]](...w(e,h[2]));m(t,l)}else s=p(c,l),s?(i=M(e,s,h,a.o),a.c&&m(i,a.c),"object"==typeof(o=i)&&o&&o.then&&(i=await i,n.w=!0),n.H=f(c,i)):n.l=l+" not found"}catch(e){r===s-1?n.l=String(e.stack||e):console.error(e)}var o;return n})(t,n).then(s);var n,s})),o?(e,t,r)=>{0===r[0]?e.postMessage([1,L(t)]):((e,t,r)=>{const n=r[0];if(2===n)S(e,i(),t);else{const t=r[1],s=u[t];s&&(6===n?N(e,s):5===n&&((e,t,r,n,s)=>{(s=t.M.document.querySelector(`[data-ptid="${r}"]`))&&(n?s.dataset.pterror=n:s.type+="-x"),N(e,t)})(e,s,r[2],r[3]))}})(e,t,r)}:null})(e);s&&(t=new Worker(URL.createObjectURL(new Blob([\'/* Partytown 0.0.20 - MIT builder.io */\\n(e=>{const t=Symbol(),r=Symbol(),n=Symbol(),s=Symbol(),i=Symbol(),o=Symbol(),a=new Map,c={},l=new WeakMap,u={},h={},$={},d={},p=new Map,g=new Map,m="getClientRects,getBoundingClientRect".split(","),f="innerHeight,innerWidth,outerHeight,outerWidth,clientHeight,clientWidth,clientTop,clientLeft,scrollHeight,scrollWidth,scrollTop,scrollLeft,offsetHeight,offsetWidth,offsetTop,offsetLeft".split(","),w="childElementCount,children,firstElementChild,lastElementChild,nextElementSibling,previousElementSibling",y=()=>!0,v=e=>e.length,I=(e,t)=>Object.defineProperty(e,"name",{value:t}),E=[],b=()=>Math.round(9999999999*Math.random()+4),S="text/partytown",T=(e,t,r)=>Object.defineProperty(e,t,{...r,configurable:!0}),N=(e,t,r)=>T(e.prototype,t,r),M=(e,t)=>Object.defineProperties(e.prototype,t),x=(e,t,r)=>N(e,t,{value:r,writable:!0}),L=[],C=(e,n,s,o,a)=>{const c=e[r];if(L.push({P:e[t],t:c,a:[...e[i],...n],c:o,o:a}),!s)return R();setTimeout(R,40)},R=()=>{if(v(L)){const e=L[v(L)-1],t={C:b(),J:L.slice()};L.length=0;const r=((e,t)=>{const r=new XMLHttpRequest,n=e.z+"proxytown";return r.open("POST",n,!1),r.send(JSON.stringify(t)),JSON.parse(r.responseText)})($,t),n=r.w,s=se(e.t,e.a,r.H);if(r.l){if(n)return Promise.reject(r.l);throw new Error(r.l)}return n?Promise.resolve(s):s}},W=(e,t,r)=>C(e,t,!1,void 0,r),H=(e,t,r)=>{const n=[...t,ne(e,r),0];C(e,n,!0)},O=(e,t,r,n)=>{const s=t[v(t)-1],i=P.includes(s),o=[...t,ne(e,r)],a=C(e,o,i,n);return i||m.includes(s)||p.clear(),a},P="addEventListener,removeEventListener,createElement,createTextNode,insertBefore,insertRule,deleteRule,setAttribute,setItem,removeItem,classList.add,classList.remove,classList.toggle".split(","),A=(e,t,r,n)=>{let s=a.get(t);return s||(s=j(e,t,r,n),a.set(t,s)),s},j=(t,r,n,s)=>new(u[n]?u[n]:n.includes("-")?u.UNKNOWN:e.HTMLElement)(t,r,[],n,s),D=(e,t)=>t in e[o],k=(e,t)=>e[o][t],B=(e,t,r)=>e[o][t]=r,U=(e,t,r,n)=>{let s="";try{e.g=t,F(e,r)}catch(e){console.error(r,e),s=String(e.stack||e)+""}return e.g=-1,s},F=(e,t)=>{new Function(`with(this){${t}}`).apply(e.M)},_=(e,t,r)=>{(r=k(e,t))&&setTimeout((()=>r.map((e=>e({type:t})))),undefined)},J=(e,t,r)=>{for(r=e.A;!r.host&&(r=(e=d[e.E]).A,e.P!==e.E););const n=new URL(t||"",r);if($.e.resolveUrl){const e=$.e.resolveUrl(n,r);if(e)return e}return n},z=(e,t)=>J(e,t)+"",q=e=>J(Z(e),k(e,4)),G=()=>`<script src=${JSON.stringify($.z+"partytown.js")} async defer><\\\\/script>`,V=e=>class{constructor(){this.s="",this.l=[],this.e=[]}get src(){return this.s}set src(t){fetch(z(e,t),{mode:"no-cors",keepalive:!0}).then((e=>{e.ok||0===e.status?this.l.map((e=>e({type:"load"}))):this.e.map((e=>e({type:"error"})))}),(()=>this.e.forEach((e=>e({type:"error"})))))}addEventListener(e,t){"load"===e&&this.l.push(t),"error"===e&&this.e.push(t)}get onload(){return this.l[0]}set onload(e){this.l=[e]}get onerror(){return this.e[0]}set onerror(e){this.e=[e]}};class X extends URL{assign(){}reload(){}replace(){}}class Y{constructor(e,a,c,l,u){this[t]=e,this[r]=a,this[i]=c||[],this[n]=l,this[o]={},u&&(this[s]=u)}}class K extends Y{constructor(e,t,r,n){return super(e,t,r,n),new Proxy(this,{get:(e,t)=>W(e,[t]),set:(e,t,r)=>(H(e,[t],r),!0)})}}class Window extends Y{constructor(t,r,n){super(t,0);for(const t in e)if(!(t in this)&&"onmessage"!==t){const r=e[t];if(null!=r){const n="function"==typeof r&&!r.toString().startsWith("class");this[t]=n?r.bind(e):r}}Object.getOwnPropertyNames(e).map((t=>{t in this||(this[t]=e[t])}));for(const e in h)this[e]=I(class{constructor(...r){const n=new(0,h[e])(t,b()),s=ne(n,r);return C(n,[1,e,s]),n}},e);const s=new Proxy(this,{has:()=>!0});return d[t]={P:t,E:r,M:s,j:j(t,1,"#document"),k:j(t,2,"HTML"),p:j(t,3,"HEAD"),d:j(t,4,"BODY"),A:new X(n)},this.requestAnimationFrame=e=>setTimeout((()=>e(performance.now())),9),this.cancelAnimationFrame=e=>clearTimeout(e),T(this.performance,"timing",{get:()=>{const e=W(this,["performance","timing"]);return e?{...e,toJSON:()=>e}:void 0}}),s}get Audio(){return e=Z(this),class{constructor(t){const r=e.j.createElement("audio");return r.src=t,r}};var e}get body(){return Z(this).d}get document(){return Z(this).j}get documentElement(){return Z(this).k}fetch(e,t){return e="string"==typeof e||e instanceof URL?String(e):e.url,fetch(z(Z(this),e),t)}get frameElement(){const e=Z(this),t=e.E,r=e.P;return r===t?null:A(t,r,"IFRAME")}get globalThis(){return this}get head(){return Z(this).p}get location(){return Z(this).A}set location(e){Z(this).A.href=e+""}get Image(){return V(Z(this))}get name(){const e=this[t];return name+e}get navigator(){return(t=>{const r=e.navigator;return r.sendBeacon=(e,r)=>{try{return fetch(z(t,e),{method:"POST",body:r,mode:"no-cors",keepalive:!0}),!0}catch(e){return console.error(e),!1}},r})(Z(this))}get origin(){return Z(this).A.origin}get parent(){return d[Z(this).E].M}get self(){return this}get top(){for(const e in d)if(d[e].P===d[e].E)return d[e].M}get window(){return this}}const Q=({P:e,E:t,L:r})=>{d[e]?d[e].A.href=r:new Window(e,t,r),$.F([6,e])},Z=e=>d[e[t]];class Node extends Y{appendChild(e){return this.insertBefore(e,null)}get href(){}set href(e){}insertBefore(e,s){const i=e[t]=this[t],o=e[r],a=e[n],c="SCRIPT"===a,l="IFRAME"===a;if(c){const t=k(e,3);if(t){const r=U(Z(e),o,t),n=r?"pterror":"ptid",s=r||o;H(e,["type"],S+"-x"),H(e,["dataset",n],s),H(e,["innerHTML"],t)}}return O(this,["insertBefore"],[e,s]),l&&(e=>{let t=0;const n=e[r],s=()=>{if(d[n]&&d[n].v){let t=k(e,1)?"error":"load",r=k(e,t);r&&r.map((e=>e({type:t})))}else if(t++>2e3){let t=k(e,"error");t&&t.map((e=>e({type:"error"}))),console.error("Timeout")}else setTimeout(s,9)};s()})(e),c&&(R(),$.F([6,i])),e}get nodeName(){return this[n]}get nodeType(){return 3}get ownerDocument(){return Z(this).j}}class ee{constructor(e){this.name=e[0],this.value=e[1]}get nodeName(){return this.name}get nodeType(){return 2}}class NodeList{constructor(e){(this._=e).map(((e,t)=>this[t]=e))}entries(){return this._.entries()}forEach(e,t){this._.map(e,t)}item(e){return this[e]}keys(){return this._.keys()}get length(){return v(this._)}values(){return this._.values()}[Symbol.iterator](){return this._[Symbol.iterator]()}}const te=(e,n,s,i)=>{if(void 0!==s){let u=typeof s;if("string"===u||"boolean"===u||"number"===u||null==s)return[9,s];if("function"===u)return[10,{P:e,t:n,G:(o=s,(a=l.get(o))||(l.set(o,a=b()),c[a]=o),a)}];if(i=i||new Set,Array.isArray(s))return i.has(s)?[0,[]]:[0,s.map((t=>te(e,n,t,i)))];if("object"===u)return"number"==typeof s[r]?[6,{P:s[t],t:s[r]}]:s instanceof Event?[4,re(e,n,s,!1,i)]:[8,re(e,n,s,!0,i)]}var o,a},re=(e,t,r,n,s,i,o,a)=>{if(i={},!s.has(r))for(o in s.add(r),r)a=r[o],(n||"function"!=typeof a)&&(i[o]=te(e,t,a,s));return i},ne=(e,n)=>e?te(e[t],e[r],n):[9,n],se=(e,t,r,n,s)=>{if(r){if(n=r[0],s=r[1],9===n||2===n||3===n)return s;if(10===n)return ce(t,s);if(6===n)return oe(s);if(7===n)return new NodeList(s.map(oe));if(1===n)return new ee(s);if(0===n)return s.map((r=>se(e,t,r)));if(4===n)return i=ie(e,t,s),new Proxy(new Event(i.type,i),{get:(e,t)=>t in i?i[t]:e[String(t)]});if(8===n)return ie(e,t,s)}var i},ie=(e,t,r,n,s)=>{for(s in n={},r)n[s]=se(e,[...t,s],r[s]);return n},oe=({P:e,t:t,D:r})=>ae(e,t)||A(e,t,r),ae=(e,t)=>{const r=d[e];return 0===t?r.M:1===t?r.j:2===t?r.k:3===t?r.p:4===t?r.d:void 0},ce=(e,{P:t,t:r,D:n,G:s})=>(c[s]||l.set(c[s]=function(...s){const i=A(t,r,n);return O(i,e,s)},s),c[s]),le={sheet:{get(){return new ue(this)}}};class ue{constructor(e){this.ownerNode=e}get cssRules(){const e=this.ownerNode;return new Proxy({},{get(t,r){const n=String(r);return"item"===n?t=>$e(e,t):"length"===n?he(e).length:isNaN(n)?t[r]:$e(e,n)}})}insertRule(e,t){const r=he(this.ownerNode);return(t=void 0===t?0:t)>=0&&t<=r.length&&(O(this.ownerNode,["sheet","insertRule"],[e,t]),r.splice(t,0,0)),t}deleteRule(e){O(this.ownerNode,["sheet","deleteRule"],[e]),he(this.ownerNode).splice(e,1)}}const he=e=>{let t=k(e,2);return t||(t=W(e,["sheet","cssRules"]),B(e,2,t)),t},$e=(e,t)=>{let r=he(e);return 0===r[t]&&(r[t]=W(e,["sheet","cssRules",parseInt(t,10)])),r[t]},de={body:{get(){return Z(this).d}},createElement:{value(e){e=e.toUpperCase();const r=this[t],n=b(),s=A(r,n,e);return O(this,["createElement"],[e],n),"IFRAME"===e?(Q({P:n,E:r,L:"about:blank"}),H(s,["srcdoc"],G())):"SCRIPT"===e&&H(s,["type"],S),s}},createElementNS:{value(e,r){r=r.toLowerCase();const n=this[t],s=b(),i=A(n,s,r,e);return O(this,["createElementNS"],[e,r],s),i}},createTextNode:{value(e){const r=this[t],n=b(),s=A(r,n,"#text");return O(this,["createTextNode"],[e],n),s}},createEvent:{value:e=>new Event(e)},currentScript:{get(){const e=this[t],r=Z(this).g;return r>0?A(e,r,"SCRIPT"):null}},defaultView:{get(){return Z(this).M}},documentElement:{get(){return Z(this).k}},getElementsByTagName:{value(e){return"BODY"===(e=e.toUpperCase())?[Z(this).d]:"HEAD"===e?[Z(this).p]:O(this,["getElementsByTagName"],[e])}},head:{get(){return Z(this).p}},implementation:{value:{hasFeature:y}},location:{get(){return Z(this).A},set(e){Z(this).A.href=e+""}},nodeType:{value:9},parentNode:{value:null},parentElement:{value:null},readyState:{value:"complete"}},pe={parentElement:{get(){return this.parentNode}},parentNode:{get(){return Z(this).k}}},ge={parentElement:{value:null},parentNode:{get(){return Z(this).j}}},me={localName:{get(){return this[n].toLowerCase()}},namespaceURI:{get(){return this[s]||"http://www.w3.org/1999/xhtml"}},nodeType:{value:1},tagName:{get(){return this[n]}}},fe={hash:{get(){return q(this).hash}},host:{get(){return q(this).host}},hostname:{get(){return q(this).hostname}},href:{get(){return q(this).href},set(e){B(this,4,e+=""),H(this,["href"],e)}},origin:{get(){return q(this).origin}},pathname:{get(){return q(this).pathname}},port:{get(){return q(this).port}},protocol:{get(){return q(this).protocol}},search:{get(){return q(this).search}}},we={getContext:{value(...n){const s=["getContext",ne(this,n)];return new e.CanvasRenderingContext2D(this[t],this[r],s)}}},ye={addEventListener:{value(...e){const t=e[0],r=k(this,t)||[];r.push(e[1]),B(this,t,r)}},async:{get:y,set:y},defer:{get:y,set:y},onload:{get(){let e=k(this,"load");return e&&e[0]||null},set(e){B(this,"load",e?[e]:null)}},onerror:{get(){let e=k(this,"error");return e&&e[0]||null},set(e){B(this,"error",e?[e]:null)}}},ve={contentDocument:{get(){return this.contentWindow.document}},contentWindow:{get(){const e=this[r];return d[e].M}},src:{get(){return k(this,4)||""},set(e){let t,r=new XMLHttpRequest;e=z(Z(this),e),B(this,1,void 0),B(this,4,e),r.open("GET",e,!1),r.send(),t=r.status,t>199&&t<300?H(this,["srcdoc"],((e,t)=>`<base href="${e}">`+t.replace(/<script>/g,\\\'<script type="text/partytown">\\\').replace(/<script /g,\\\'<script type="text/partytown" \\\').replace(/text\\\\/javascript/g,S)+G())(e,r.responseText)):B(this,1,t)}},...ye},Ie={get(){return k(this,3)||""},set(e){B(this,3,e)}},Ee={innerHTML:Ie,innerText:Ie,src:{get(){return k(this,4)||""},set(e){e=z(Z(this),e),B(this,4,e),H(this,["src"],e)}},getAttribute:{value(e){return"src"===e?this.src:O(this,["getAttribute"],[e])}},setAttribute:{value(e,t){"src"===e?this.src=t:O(this,["setAttribute"],[e,t])}},textContent:Ie,type:{get(){return W(this,["type"])},set(e){"text/javascript"!==e&&H(this,["type"],e)}},...ye},be=([s,o,a,c,l])=>{const $=Se[s]?K:"Object"===o||"EventTarget"===o?Y:e[o],d=e[s]=I(e[s]||class extends ${},s);12===c&&(h[s]=d),l&&(u[l]=d),a.map((([s,o,a])=>{s in d.prototype||s in $.prototype||("string"==typeof o?N(d,s,{get(){if(!D(this,s)){const a=this[t],c=this[r],l=[...this[i],s],u=this[n],h=e[o];B(this,s,new h(a,c,l,u))}return k(this,s)},set(e){B(this,s,e)}}):5===o?x(d,s,(function(...e){return O(this,[s],e)})):o>0&&(void 0!==a?x(d,s,a):N(d,s,{get(){return W(this,[s])},set(e){return H(this,[s],e)}})))}))},Se={CSSStyleDeclaration:1,DOMStringMap:1,NamedNodeMap:1},Te=(e,t)=>x(e,"nodeType",t),Ne=(e,t)=>t.split(",").map((t=>N(e,t,{get(){let e=Me(this,t),r=g.get(e);return r||(r=W(this,[t]),g.set(e,r)),r}}))),Me=(e,n)=>e[t]+"."+e[r]+"."+n,xe=(e,t)=>t.split(",").map((t=>N(e,t,{get(){return D(this,t)||B(this,t,W(this,[t])),k(this,t)},set(e){B(this,t,e)}}))),Le=(e,t)=>Object.keys(t).map((r=>x(e,r,t[r]))),Ce=e=>f.map((t=>N(e,t,{get(){const e=p.get(Me(this,t));if("number"==typeof e)return e;const r=W(this,[t],f);return Object.entries(r).map((([e,t])=>{p.set(Me(this,e),t)})),r[t]}}))),Re=e=>m.map((t=>{e.prototype[t]=function(){let e=Me(this,t),r=p.get(e);return r||(r=O(this,[t],E),p.set(e,r)),r}})),We=[],He=t=>{const r=t.data,n=r[0];$.v?6===n?(async t=>{let r,n,s=t.P,i=t.t,o=A(s,i,"SCRIPT"),a=t.f,c=t.L,l="",u=d[s];if(c)try{n=J(u,c),c=n+"",B(o,4,c),r=await e.fetch(c),r.ok?(a=await r.text(),u.g=i,F(u,a),_(o,"load")):(console.error(r.status,"url:",c),l=r.statusText,_(o,"error"))}catch(e){console.error("url:",c,e),l=String(e.stack||e)+"",_(o,"error")}else a&&(l=U(u,i,a));u.g=-1,$.F([5,s,i,l])})(r[1]):7===n?(({t:e,G:t,K:r,b:n})=>{if(c[t])try{const s=se(e,[],r),i=se(e,[],n);c[t].apply(s,i)}catch(e){console.error(e)}})(r[1]):8===n?(({P:t,t:r,m:n,b:s})=>{try{const i=d[t].M,o=n[0]in i?i:n[0]in e?e:{},a=se(r,[],s),c=o[n[0]];Array.isArray(c)?c.push(...a):"function"==typeof c&&c.apply(o,a)}catch(e){console.error(e)}})(r[1]):3===n?Q(r[1]):4===n&&(d[r[1]].v=1):1===n?((t=>{Object.assign($,t);const r=$.e=JSON.parse($.e);r.resolveUrl&&Object.assign(r,{resolveUrl:new Function("return "+r.resolveUrl)()}),$.n=(r.forward||E).map((e=>e[0])),$.F=postMessage.bind(e),e.postMessage=e.importScripts=void 0,e.Node=Node,e.Window=Window,e.CSSStyleSheet=ue,$.s.map(be),(()=>{const t=e.Document,r=e.DocumentFragment,n=e.Element;"atob,btoa,crypto,indexedDB,performance,setTimeout,setInterval,clearTimeout,clearInterval".split(",").map((e=>delete Window.prototype[e])),M(n,me),M(t,de),M(e.HTMLAnchorElement,fe),M(e.HTMLCanvasElement,we),M(e.HTMLIFrameElement,ve),M(e.HTMLScriptElement,Ee),M(e.HTMLStyleElement,le),M(e.HTMLHeadElement,pe),M(e.HTMLBodyElement,pe),M(e.HTMLHtmlElement,ge),Le(ue,{type:"text/css"}),Te(e.Comment,8),Te(e.DocumentType,10),Te(r,11),Ne(Node,"childNodes,firstChild,isConnected,lastChild,nextSibling,parentElement,parentNode,previousSibling"),Ne(n,w),Ne(r,w),Ce(n),Ce(Window),Re(n),xe(t,"compatMode,referrer")})(),$.v=1})(r[1]),$.F([2]),We.slice().forEach(He),We.length=0):We.push(t)};e.onmessage=He,postMessage([0])})(self);\\n\'],{type:"text/javascript"})),{name:"Partytown 🎉"}),t.onmessage=e=>s(t,n,e.data),n.addEventListener("pt1",(e=>{const r=e.detail,n=d(r.frameElement);S(t,n,r)})))})(e)})(window);\n<\/script></head></html>',false)):o.endsWith("proxytown")&&n.respondWith(((n,s)=>new Promise((async o=>{const i=await n.clone().json(),a=await(r=>new Promise((async n=>{const s=[...await self.clients.matchAll()].sort(((e,t)=>e.url>t.url?-1:e.url<t.url?1:0))[0];if(s){const o=[n,setTimeout((()=>{e.delete(r.C),n(t(r,"Timeout"))}),1e4)];e.set(r.C,o),s.postMessage(r)}else n(t(r,"No Party"))})))(i);o(r(JSON.stringify(a),s,"application/json"))})))(s,false))}; | ||
/* Partytown 0.0.21 - MIT builder.io */ | ||
const e=new Map,t=(e,t)=>({C:e.C,l:t}),r=(e,t,r)=>{const n={"content-type":r||"text/html","Cache-Control":"no-store"};return t&&(n["Cross-Origin-Embedder-Policy"]="require-corp"),new Response(e,{headers:n})};self.oninstall=()=>self.skipWaiting(),self.onactivate=()=>self.clients.claim(),self.onmessage=t=>{const r=t.data,n=e.get(r.C);n&&(e.delete(r.C),clearTimeout(n[1]),n[0](r))},self.onfetch=n=>{const s=n.request,o=new URL(s.url).pathname;o.endsWith("partytown-sandbox-sw.html")?n.respondWith(r('<!DOCTYPE html><html><head><meta charset="utf-8"><script type="module">/* Partytown 0.0.21 - MIT builder.io */\n(e=>{const t=()=>!0,r=e=>e.length,n=e=>{try{return e.constructor.name}catch(e){}return""},s=(e,t)=>e.startsWith(t),o=e=>!(s(e,"webkit")||s(e,"toJSON")||s(e,"constructor")||s(e,"toString")||s(e,"_")),i=()=>Math.round(9999999999*Math.random()+4),a=new WeakMap,c=new Map,l=new Map,u={},h=new WeakMap,d=(e,t,r)=>e?e===e.window?0:"#document"===(r=e.nodeName)?1:"HTML"===r?2:"HEAD"===r?3:"BODY"===r?4:("number"!=typeof(t=a.get(e))&&m(e,t=i()),t):-1,p=(e,t,r,n,s)=>{if((r=u[e])&&(n=r.M))return s=n.document,0===t?n:1===t?s:2===t?s.documentElement:3===t?s.head:4===t?s.body:c.get(t)},m=(e,t)=>{e&&(c.set(t,e),a.set(e,t),g++,g>99999&&(c.forEach(((e,t)=>{e.nodeType&&!e.isConnected&&c.delete(t)})),g=0))};let g=0;const f=(e,t,r,o,i)=>{if(void 0!==t){if("string"==(o=typeof t)||"number"===o||"boolean"===o||null==t)return[9,t];if("function"===o)return[5];if(r=r||new Set,Array.isArray(t))return r.has(t)?[0,[]]:(r.add(t),[0,t.map((t=>f(e,t,r)))]);if("object"===o)return""===(i=n(t))?[8,{}]:"Window"===i?[6,{P:e,t:0}]:"HTMLCollection"===i||"NodeList"===i?[7,Array.from(t).map((t=>f(e,t,r)[1]))]:"Event"===i?[4,y(e,t,r)]:"CSSRuleList"===i?[3,Array.from(t).map($)]:s(i,"CSS")&&i.endsWith("Rule")?[2,$(t)]:"CSSStyleDeclaration"===i?[8,y(e,t,r)]:"Attr"===i?[1,[t.name,t.value]]:t.nodeType?[6,{P:e,t:d(t),D:t.nodeName}]:[8,y(e,t,r,!0,!0)]}},y=(e,t,r,n,s,i,a,c)=>{if(i={},!r.has(t))for(a in r.add(t),t)o(a)&&(c=t[a],(n||"function"!=typeof c)&&(s||""!==c)&&(i[a]=f(e,c,r)));return i},$=e=>{let t,r={};for(t in e)T.includes(t)&&(r[t]=e[t]);return r},w=(e,t,r,n)=>{if(t){if(r=t[0],n=t[1],9===r)return n;if(10===r)return v(e,n);if(0===r)return n.map((t=>w(e,t)));if(6===r)return p(n.P,n.t);if(4===r)return b(E(e,n));if(8===r)return E(e,n)}},v=(e,{P:t,t:r,G:n})=>{let s=l.get(n);return s||(s=function(...s){const o={t:r,G:n,K:f(t,this),b:f(t,s)};e.postMessage([7,o])},l.set(n,s)),s},b=e=>new("detail"in e?CustomEvent:Event)(e.type,e),E=(e,t,r,n)=>{for(n in r={},t)r[n]=w(e,t[n]);return r},T="cssText,selectorText,href,media,namespaceURI,prefix,name,conditionText".split(","),S=async(e,t)=>{const n={C:t.C},s=r(t.J);for(let r=0;r<s;r++)try{let s,i,a=t.J[r],c=a.P,l=a.t,h=a.a;if(u[c]||await new Promise((e=>{let t=0,r=()=>{u[c]||t++>999?e():setTimeout(r,9)};r()})),1===h[0]&&h[1]in u[c].M){const t=new u[c].M[h[1]](...w(e,h[2]));m(t,l)}else s=p(c,l),s?(i=M(e,s,h,a.o),a.c&&m(i,a.c),"object"==typeof(o=i)&&o&&o.then&&(i=await i,n.w=!0),n.H=f(c,i)):n.l=l+" not found"}catch(e){r===s-1?n.l=String(e.stack||e):console.error(e)}var o;return n},M=(e,t,n,s)=>{let o,i,a,c,l=0,u=r(n);for(;l<u;l++){i=n[l],o=n[l+1],a=n[l-1];try{if(!Array.isArray(o))if("string"==typeof i||"number"==typeof i){if(l+1===u&&s){const e={};return s.map((r=>e[r]=t[r])),e}t=t[i]}else{if(0===o)return void(t[a]=w(e,i));"function"==typeof t[a]&&(c=w(e,i),"insertRule"===a&&c[1]>r(t.cssRules)&&(c[1]=r(t.cssRules)),t=t[a].apply(t,c))}}catch(e){console.warn(e)}}return t},N=(e,t,r)=>{if(!h.has(r)){h.set(r,t);const n=r.document,s=r.history,o={P:t,E:h.get(r.parent),L:n.baseURI},i=()=>e.postMessage([3,o]),a=s.pushState.bind(s),c=s.replaceState.bind(s),l=()=>setTimeout((()=>e.postMessage([11,t,n.baseURI])));s.pushState=(e,t,r)=>{a(e,t,r),l()},s.replaceState=(e,t,r)=>{c(e,t,r),l()},r.addEventListener("popstate",l),r.addEventListener("hashchange",l),u[t]={P:t,M:r},"complete"===n.readyState?i():r.addEventListener("load",i)}},L=(e,t)=>{let n,s,o=t.P,i=t.M,a=i.document,c=a.querySelector(\'script[type="text/partytown"]:not([data-ptid]):not([data-pterror]):not([async]):not([defer])\');c||(c=a.querySelector(\'script[type="text/partytown"]:not([data-ptid]):not([data-pterror])\')),c?(c.dataset.ptid=n=d(c,o),s={P:o,t:n},c.src?s.L=c.src:s.f=c.innerHTML,e.postMessage([6,s])):t.v||(t.v=1,((e,t,n)=>{let s=n._ptf,o=n._ptf=[],i=0;if(o.push=(r,n)=>e.postMessage([8,{P:t,t:0,m:r,b:f(t,Array.from(n))}]),s)for(;i<r(s);i+=2)o.push(s[i],s[i+1])})(e,o,i),a.dispatchEvent(new CustomEvent("pt0")),e.postMessage([4,o]))},O=e=>{const r=e.document.implementation.createHTMLDocument(),n=r.createTextNode(""),s=r.createComment(""),o=r.createDocumentFragment(),i=r.createElement("i"),a=r.createElementNS("http://www.w3.org/2000/svg","svg"),c=r.createElement("canvas").getContext("2d"),l=new MutationObserver(t),u=new ResizeObserver(t),h=Object.getOwnPropertyNames(e).filter((e=>/^HTML.+Element$/.test(e))).map((e=>{const t=C(e);return[r.createElement(t)]})),d=[[e.localStorage],[e.history],[e.screen],[e.screen.orientation],[l,12],[u,12],[n],[s],[o],[i],[i.attributes],[i.classList],[i.dataset],[i.style],[a],[r],[r.doctype],[c],...h].filter((e=>e[0])).map((t=>{const r=t[0],n=t[1],s=r.constructor.name;return[s,e[s].prototype,r,n]})),p=[I("Window",e),I("Node",n)],m=e.partytown||{},g=(m.lib||"/~partytown/")+"",f={e:JSON.stringify(m,((e,t)=>("function"==typeof t&&(t=String(t)).startsWith(e+"(")&&(t="function "+t),t))),z:new URL(g,e.location)+"",s:p};return d.map((([e,t,r,n])=>P(p,e,t,r,n))),f},I=(e,t)=>{const r=[],n=[e,"Object",r];for(const e in t)x(r,t,e);return n},P=(e,t,r,n,s)=>{if("Object"!==t&&!e.some((e=>e[0]===t))){const o=Object.getPrototypeOf(r),i=o.constructor.name,a=[];P(e,i,o,n,s),Object.keys(Object.getOwnPropertyDescriptors(r)).map((e=>x(a,n,e))),e.push([t,i,a,s,n.nodeName])}},x=(t,r,s,i,a,c)=>{try{o(s)&&isNaN(s[0])&&("function"==(a=typeof(i=r[s]))?(String(i).includes("[native")||Object.getPrototypeOf(r)[s])&&t.push([s,5]):"object"===a&&null!=i?"Object"!==(c=n(i))&&e[c]&&t.push([s,i.nodeType||c]):"symbol"!==a&&(s.toUpperCase()===s?t.push([s,6,i]):t.push([s,6])))}catch(e){console.warn(e)}},R={Anchor:"A",DList:"DL",Image:"IMG",OList:"OL",Paragraph:"P",TableCaption:"CAPTION",TableCell:"TD",TableCol:"COLGROUP",TableRow:"TR",TableSection:"TBODY",UList:"UL"},C=e=>(e=e.substr(4).replace("Element",""),R[e]||e);(async e=>{let t;const r=e.parent,n=await(async(e,r)=>{const n=e.navigator.serviceWorker,s=await n.getRegistration();return n.addEventListener("message",(e=>{return r=e.data,n=e=>s.active&&s.active.postMessage(e),S(t,r).then(n);var r,n})),s?(e,t,r)=>{0===r[0]?e.postMessage([1,O(t)]):((e,t,r)=>{const n=r[0];if(2===n)N(e,i(),t);else{const t=r[1],s=u[t];s&&(6===n?L(e,s):5===n&&((e,t,r,n,s)=>{(s=t.M.document.querySelector(`[data-ptid="${r}"]`))&&(n?s.dataset.pterror=n:s.type+="-x"),L(e,t)})(e,s,r[2],r[3]))}})(e,t,r)}:null})(e);n&&(t=new Worker(URL.createObjectURL(new Blob([\'/* Partytown 0.0.21 - MIT builder.io */\\n(e=>{const t=Symbol(),r=Symbol(),n=Symbol(),s=Symbol(),i=Symbol(),o=Symbol(),a=new Map,c={},l=new WeakMap,u={},h={},$={},d={},p=new Map,g=new Map,m="getClientRects,getBoundingClientRect".split(","),f="innerHeight,innerWidth,outerHeight,outerWidth,clientHeight,clientWidth,clientTop,clientLeft,scrollHeight,scrollWidth,scrollTop,scrollLeft,offsetHeight,offsetWidth,offsetTop,offsetLeft".split(","),w="childElementCount,children,firstElementChild,lastElementChild,nextElementSibling,previousElementSibling",y=()=>!0,v=e=>e.length,I=(e,t)=>Object.defineProperty(e,"name",{value:t}),E=[],b=()=>Math.round(9999999999*Math.random()+4),S="text/partytown",T=(e,t,r)=>Object.defineProperty(e,t,{...r,configurable:!0}),N=(e,t,r)=>T(e.prototype,t,r),M=(e,t)=>Object.defineProperties(e.prototype,t),x=(e,t,r)=>N(e,t,{value:r,writable:!0}),L=[];let C=0;const R=(e,n,s,o,a)=>{const c=e[r];if(L.push({P:e[t],t:c,a:[...e[i],...n],c:o,o:a}),!s)return W(!0);C=setTimeout(W,30)},W=e=>{if(clearTimeout(C),v(L)){const t=L[v(L)-1],r={C:b(),J:L.slice()};if(L.length=0,e){const e=((e,t)=>{const r=new XMLHttpRequest,n=e.z+"proxytown";return r.open("POST",n,!1),r.send(JSON.stringify(t)),JSON.parse(r.responseText)})($,r),n=e.w,s=ie(t.t,t.a,e.H);if(e.l){if(n)return Promise.reject(e.l);throw new Error(e.l)}return n?Promise.resolve(s):s}$.F([10,r])}},H=(e,t,r)=>R(e,t,!1,void 0,r),O=(e,t,r)=>{const n=[...t,se(e,r),0];R(e,n,!0)},P=(e,t,r,n)=>{const s=t[v(t)-1],i=A.includes(s),o=[...t,se(e,r)],a=R(e,o,i,n);return i||m.includes(s)||p.clear(),a},A="addEventListener,removeEventListener,createElement,createTextNode,insertBefore,insertRule,deleteRule,setAttribute,setItem,removeItem,classList.add,classList.remove,classList.toggle".split(","),j=(e,t,r,n)=>{let s=a.get(t);return s||(s=D(e,t,r,n),a.set(t,s)),s},D=(t,r,n,s)=>new(u[n]?u[n]:n.includes("-")?u.UNKNOWN:e.HTMLElement)(t,r,[],n,s),k=(e,t)=>t in e[o],B=(e,t)=>e[o][t],U=(e,t,r)=>e[o][t]=r,F=(e,t,r,n)=>{let s="";try{e.g=t,_(e,r)}catch(e){console.error(r,e),s=String(e.stack||e)+""}return e.g=-1,s},_=(e,t)=>{new Function(`with(this){${t}}`).apply(e.M)},J=(e,t,r)=>{(r=B(e,t))&&setTimeout((()=>r.map((e=>e({type:t})))),undefined)},z=(e,t,r)=>{for(r=e.A;!r.host&&(r=(e=d[e.E]).A,e.P!==e.E););const n=new URL(t||"",r);if($.e.resolveUrl){const e=$.e.resolveUrl(n,r);if(e)return e}return n},q=(e,t)=>z(e,t)+"",G=e=>z(ee(e),B(e,4)),V=()=>`<script src=${JSON.stringify($.z+"partytown.js")} async defer><\\\\/script>`,X=e=>class{constructor(){this.s="",this.l=[],this.e=[]}get src(){return this.s}set src(t){fetch(q(e,t),{mode:"no-cors",keepalive:!0}).then((e=>{e.ok||0===e.status?this.l.map((e=>e({type:"load"}))):this.e.map((e=>e({type:"error"})))}),(()=>this.e.forEach((e=>e({type:"error"})))))}addEventListener(e,t){"load"===e&&this.l.push(t),"error"===e&&this.e.push(t)}get onload(){return this.l[0]}set onload(e){this.l=[e]}get onerror(){return this.e[0]}set onerror(e){this.e=[e]}};class Y extends URL{assign(){}reload(){}replace(){}}class K{constructor(e,a,c,l,u){this[t]=e,this[r]=a,this[i]=c||[],this[n]=l,this[o]={},u&&(this[s]=u)}}class Q extends K{constructor(e,t,r,n){return super(e,t,r,n),new Proxy(this,{get:(e,t)=>H(e,[t]),set:(e,t,r)=>(O(e,[t],r),!0)})}}class Window extends K{constructor(t,r,n){super(t,0);for(const t in e)if(!(t in this)&&"onmessage"!==t){const r=e[t];if(null!=r){const n="function"==typeof r&&!r.toString().startsWith("class");this[t]=n?r.bind(e):r}}Object.getOwnPropertyNames(e).map((t=>{t in this||(this[t]=e[t])}));for(const e in h)this[e]=I(class{constructor(...r){const n=new(0,h[e])(t,b()),s=se(n,r);return R(n,[1,e,s]),n}},e);const s=new Proxy(this,{has:()=>!0});return d[t]={P:t,E:r,M:s,j:D(t,1,"#document"),k:D(t,2,"HTML"),p:D(t,3,"HEAD"),d:D(t,4,"BODY"),A:new Y(n)},this.requestAnimationFrame=e=>setTimeout((()=>e(performance.now())),9),this.cancelAnimationFrame=e=>clearTimeout(e),T(this.performance,"timing",{get:()=>{const e=H(this,["performance","timing"]);return e?{...e,toJSON:()=>e}:void 0}}),s}get Audio(){return e=ee(this),class{constructor(t){const r=e.j.createElement("audio");return r.src=t,r}};var e}get body(){return ee(this).d}get document(){return ee(this).j}get documentElement(){return ee(this).k}fetch(e,t){return e="string"==typeof e||e instanceof URL?String(e):e.url,fetch(q(ee(this),e),t)}get frameElement(){const e=ee(this),t=e.E,r=e.P;return r===t?null:j(t,r,"IFRAME")}get globalThis(){return this}get head(){return ee(this).p}get location(){return ee(this).A}set location(e){ee(this).A.href=e+""}get Image(){return X(ee(this))}get name(){const e=this[t];return name+e}get navigator(){return(t=>{const r=e.navigator;return r.sendBeacon=(e,r)=>{try{return fetch(q(t,e),{method:"POST",body:r,mode:"no-cors",keepalive:!0}),!0}catch(e){return console.error(e),!1}},r})(ee(this))}get origin(){return ee(this).A.origin}get parent(){return d[ee(this).E].M}get self(){return this}get top(){for(const e in d)if(d[e].P===d[e].E)return d[e].M}get window(){return this}}const Z=({P:e,E:t,L:r})=>{d[e]?d[e].A.href=r:new Window(e,t,r),$.F([6,e])},ee=e=>d[e[t]];class Node extends K{appendChild(e){return this.insertBefore(e,null)}get href(){}set href(e){}insertBefore(e,s){const i=e[t]=this[t],o=e[r],a=e[n],c="SCRIPT"===a,l="IFRAME"===a;if(c){const t=B(e,3);if(t){const r=F(ee(e),o,t),n=r?"pterror":"ptid",s=r||o;O(e,["type"],S+"-x"),O(e,["dataset",n],s),O(e,["innerHTML"],t)}}return P(this,["insertBefore"],[e,s]),l&&(e=>{let t=0;const n=e[r],s=()=>{if(d[n]&&d[n].v){let t=B(e,1)?"error":"load",r=B(e,t);r&&r.map((e=>e({type:t})))}else if(t++>2e3){let t=B(e,"error");t&&t.map((e=>e({type:"error"}))),console.error("Timeout")}else setTimeout(s,9)};s()})(e),c&&(W(!0),$.F([6,i])),e}get nodeName(){return this[n]}get nodeType(){return 3}get ownerDocument(){return ee(this).j}}class te{constructor(e){this.name=e[0],this.value=e[1]}get nodeName(){return this.name}get nodeType(){return 2}}class NodeList{constructor(e){(this._=e).map(((e,t)=>this[t]=e))}entries(){return this._.entries()}forEach(e,t){this._.map(e,t)}item(e){return this[e]}keys(){return this._.keys()}get length(){return v(this._)}values(){return this._.values()}[Symbol.iterator](){return this._[Symbol.iterator]()}}const re=(e,n,s,i)=>{if(void 0!==s){let u=typeof s;if("string"===u||"boolean"===u||"number"===u||null==s)return[9,s];if("function"===u)return[10,{P:e,t:n,G:(o=s,(a=l.get(o))||(l.set(o,a=b()),c[a]=o),a)}];if(i=i||new Set,Array.isArray(s))return i.has(s)?[0,[]]:[0,s.map((t=>re(e,n,t,i)))];if("object"===u)return"number"==typeof s[r]?[6,{P:s[t],t:s[r]}]:s instanceof Event?[4,ne(e,n,s,!1,i)]:[8,ne(e,n,s,!0,i)]}var o,a},ne=(e,t,r,n,s,i,o,a)=>{if(i={},!s.has(r))for(o in s.add(r),r)a=r[o],(n||"function"!=typeof a)&&(i[o]=re(e,t,a,s));return i},se=(e,n)=>e?re(e[t],e[r],n):[9,n],ie=(e,t,r,n,s)=>{if(r){if(n=r[0],s=r[1],9===n||2===n||3===n)return s;if(10===n)return le(t,s);if(6===n)return ae(s);if(7===n)return new NodeList(s.map(ae));if(1===n)return new te(s);if(0===n)return s.map((r=>ie(e,t,r)));if(4===n)return i=oe(e,t,s),new Proxy(new Event(i.type,i),{get:(e,t)=>t in i?i[t]:e[String(t)]});if(8===n)return oe(e,t,s)}var i},oe=(e,t,r,n,s)=>{for(s in n={},r)n[s]=ie(e,[...t,s],r[s]);return n},ae=({P:e,t:t,D:r})=>ce(e,t)||j(e,t,r),ce=(e,t)=>{const r=d[e];return 0===t?r.M:1===t?r.j:2===t?r.k:3===t?r.p:4===t?r.d:void 0},le=(e,{P:t,t:r,D:n,G:s})=>(c[s]||l.set(c[s]=function(...s){const i=j(t,r,n);return P(i,e,s)},s),c[s]),ue={sheet:{get(){return new he(this)}}};class he{constructor(e){this.ownerNode=e}get cssRules(){const e=this.ownerNode;return new Proxy({},{get(t,r){const n=String(r);return"item"===n?t=>de(e,t):"length"===n?$e(e).length:isNaN(n)?t[r]:de(e,n)}})}insertRule(e,t){const r=$e(this.ownerNode);return(t=void 0===t?0:t)>=0&&t<=r.length&&(P(this.ownerNode,["sheet","insertRule"],[e,t]),r.splice(t,0,0)),t}deleteRule(e){P(this.ownerNode,["sheet","deleteRule"],[e]),$e(this.ownerNode).splice(e,1)}}const $e=e=>{let t=B(e,2);return t||(t=H(e,["sheet","cssRules"]),U(e,2,t)),t},de=(e,t)=>{let r=$e(e);return 0===r[t]&&(r[t]=H(e,["sheet","cssRules",parseInt(t,10)])),r[t]},pe={body:{get(){return ee(this).d}},createElement:{value(e){e=e.toUpperCase();const r=this[t],n=b(),s=j(r,n,e);return P(this,["createElement"],[e],n),"IFRAME"===e?(Z({P:n,E:r,L:"about:blank"}),O(s,["srcdoc"],V())):"SCRIPT"===e&&O(s,["type"],S),s}},createElementNS:{value(e,r){r=r.toLowerCase();const n=this[t],s=b(),i=j(n,s,r,e);return P(this,["createElementNS"],[e,r],s),i}},createTextNode:{value(e){const r=this[t],n=b(),s=j(r,n,"#text");return P(this,["createTextNode"],[e],n),s}},createEvent:{value:e=>new Event(e)},currentScript:{get(){const e=this[t],r=ee(this).g;return r>0?j(e,r,"SCRIPT"):null}},defaultView:{get(){return ee(this).M}},documentElement:{get(){return ee(this).k}},getElementsByTagName:{value(e){return"BODY"===(e=e.toUpperCase())?[ee(this).d]:"HEAD"===e?[ee(this).p]:P(this,["getElementsByTagName"],[e])}},head:{get(){return ee(this).p}},implementation:{value:{hasFeature:y}},location:{get(){return ee(this).A},set(e){ee(this).A.href=e+""}},nodeType:{value:9},parentNode:{value:null},parentElement:{value:null},readyState:{value:"complete"}},ge={parentElement:{get(){return this.parentNode}},parentNode:{get(){return ee(this).k}}},me={parentElement:{value:null},parentNode:{get(){return ee(this).j}}},fe={localName:{get(){return this[n].toLowerCase()}},namespaceURI:{get(){return this[s]||"http://www.w3.org/1999/xhtml"}},nodeType:{value:1},tagName:{get(){return this[n]}}},we={hash:{get(){return G(this).hash}},host:{get(){return G(this).host}},hostname:{get(){return G(this).hostname}},href:{get(){return G(this).href},set(e){U(this,4,e+=""),O(this,["href"],e)}},origin:{get(){return G(this).origin}},pathname:{get(){return G(this).pathname}},port:{get(){return G(this).port}},protocol:{get(){return G(this).protocol}},search:{get(){return G(this).search}}},ye={getContext:{value(...n){const s=["getContext",se(this,n)];return new e.CanvasRenderingContext2D(this[t],this[r],s)}}},ve={addEventListener:{value(...e){const t=e[0],r=B(this,t)||[];r.push(e[1]),U(this,t,r)}},async:{get:y,set:y},defer:{get:y,set:y},onload:{get(){let e=B(this,"load");return e&&e[0]||null},set(e){U(this,"load",e?[e]:null)}},onerror:{get(){let e=B(this,"error");return e&&e[0]||null},set(e){U(this,"error",e?[e]:null)}}},Ie={contentDocument:{get(){return this.contentWindow.document}},contentWindow:{get(){const e=this[r];return d[e].M}},src:{get(){return B(this,4)||""},set(e){let t,r=new XMLHttpRequest;e=q(ee(this),e),U(this,1,void 0),U(this,4,e),r.open("GET",e,!1),r.send(),t=r.status,t>199&&t<300?O(this,["srcdoc"],((e,t)=>`<base href="${e}">`+t.replace(/<script>/g,\\\'<script type="text/partytown">\\\').replace(/<script /g,\\\'<script type="text/partytown" \\\').replace(/text\\\\/javascript/g,S)+V())(e,r.responseText)):U(this,1,t)}},...ve},Ee={get(){return B(this,3)||""},set(e){U(this,3,e)}},be={innerHTML:Ee,innerText:Ee,src:{get(){return B(this,4)||""},set(e){e=q(ee(this),e),U(this,4,e),O(this,["src"],e)}},getAttribute:{value(e){return"src"===e?this.src:P(this,["getAttribute"],[e])}},setAttribute:{value(e,t){"src"===e?this.src=t:P(this,["setAttribute"],[e,t])}},textContent:Ee,type:{get(){return H(this,["type"])},set(e){"text/javascript"!==e&&O(this,["type"],e)}},...ve},Se=([s,o,a,c,l])=>{const $=Te[s]?Q:"Object"===o||"EventTarget"===o?K:e[o],d=e[s]=I(e[s]||class extends ${},s);12===c&&(h[s]=d),l&&(u[l]=d),a.map((([s,o,a])=>{s in d.prototype||s in $.prototype||("string"==typeof o?N(d,s,{get(){if(!k(this,s)){const a=this[t],c=this[r],l=[...this[i],s],u=this[n],h=e[o];U(this,s,new h(a,c,l,u))}return B(this,s)},set(e){U(this,s,e)}}):5===o?x(d,s,(function(...e){return P(this,[s],e)})):o>0&&(void 0!==a?x(d,s,a):N(d,s,{get(){return H(this,[s])},set(e){return O(this,[s],e)}})))}))},Te={CSSStyleDeclaration:1,DOMStringMap:1,NamedNodeMap:1},Ne=(e,t)=>x(e,"nodeType",t),Me=(e,t)=>t.split(",").map((t=>N(e,t,{get(){let e=xe(this,t),r=g.get(e);return r||(r=H(this,[t]),g.set(e,r)),r}}))),xe=(e,n)=>e[t]+"."+e[r]+"."+n,Le=(e,t)=>t.split(",").map((t=>N(e,t,{get(){return k(this,t)||U(this,t,H(this,[t])),B(this,t)},set(e){U(this,t,e)}}))),Ce=(e,t)=>Object.keys(t).map((r=>x(e,r,t[r]))),Re=e=>f.map((t=>N(e,t,{get(){const e=p.get(xe(this,t));if("number"==typeof e)return e;const r=H(this,[t],f);return Object.entries(r).map((([e,t])=>{p.set(xe(this,e),t)})),r[t]}}))),We=e=>m.map((t=>{e.prototype[t]=function(){let e=xe(this,t),r=p.get(e);return r||(r=P(this,[t],E),p.set(e,r)),r}})),He=[],Oe=t=>{const r=t.data,n=r[0];$.v?6===n?(async t=>{let r,n,s=t.P,i=t.t,o=j(s,i,"SCRIPT"),a=t.f,c=t.L,l="",u=d[s];if(c)try{n=z(u,c),c=n+"",U(o,4,c),r=await e.fetch(c),r.ok?(a=await r.text(),u.g=i,_(u,a),J(o,"load")):(console.error(r.status,"url:",c),l=r.statusText,J(o,"error"))}catch(e){console.error("url:",c,e),l=String(e.stack||e)+"",J(o,"error")}else a&&(l=F(u,i,a));u.g=-1,$.F([5,s,i,l])})(r[1]):7===n?(({t:e,G:t,K:r,b:n})=>{if(c[t])try{const s=ie(e,[],r),i=ie(e,[],n);c[t].apply(s,i)}catch(e){console.error(e)}})(r[1]):8===n?(({P:t,t:r,m:n,b:s})=>{try{const i=d[t].M,o=n[0]in i?i:n[0]in e?e:{},a=ie(r,[],s),c=o[n[0]];Array.isArray(c)?c.push(...a):"function"==typeof c&&c.apply(o,a)}catch(e){console.error(e)}})(r[1]):3===n?Z(r[1]):4===n?d[r[1]].v=1:11===n&&(d[r[1]].A.href=r[2]):1===n?((t=>{Object.assign($,t);const r=$.e=JSON.parse($.e);r.resolveUrl&&Object.assign(r,{resolveUrl:new Function("return "+r.resolveUrl)()}),$.n=(r.forward||E).map((e=>e[0])),$.F=postMessage.bind(e),e.postMessage=e.importScripts=void 0,e.Node=Node,e.Window=Window,e.CSSStyleSheet=he,$.s.map(Se),(()=>{const t=e.Document,r=e.DocumentFragment,n=e.Element;"atob,btoa,crypto,indexedDB,performance,setTimeout,setInterval,clearTimeout,clearInterval".split(",").map((e=>delete Window.prototype[e])),M(n,fe),M(t,pe),M(e.HTMLAnchorElement,we),M(e.HTMLCanvasElement,ye),M(e.HTMLIFrameElement,Ie),M(e.HTMLScriptElement,be),M(e.HTMLStyleElement,ue),M(e.HTMLHeadElement,ge),M(e.HTMLBodyElement,ge),M(e.HTMLHtmlElement,me),Ce(he,{type:"text/css"}),Ne(e.Comment,8),Ne(e.DocumentType,10),Ne(r,11),Me(Node,"childNodes,firstChild,isConnected,lastChild,nextSibling,parentElement,parentNode,previousSibling"),Me(n,w),Me(r,w),Re(n),Re(Window),We(n),Le(t,"compatMode,referrer")})(),$.v=1})(r[1]),$.F([2]),He.slice().forEach(Oe),He.length=0):He.push(t)};e.onmessage=Oe,postMessage([0])})(self);\\n\'],{type:"text/javascript"})),{name:"Partytown 🎉"}),t.onmessage=e=>{const s=e.data;10===s[0]?S(t,s[1]):n(t,r,s)},r.addEventListener("pt1",(e=>{const r=e.detail,n=d(r.frameElement);N(t,n,r)})))})(e)})(window);\n<\/script></head></html>',false)):o.endsWith("proxytown")&&n.respondWith(((n,s)=>new Promise((async o=>{const i=await n.clone().json(),a=await(r=>new Promise((async n=>{const s=[...await self.clients.matchAll()].sort(((e,t)=>e.url>t.url?-1:e.url<t.url?1:0))[0];if(s){const o=[n,setTimeout((()=>{e.delete(r.C),n(t(r,"Timeout"))}),1e4)];e.set(r.C,o),s.postMessage(r)}else n(t(r,"No Party"))})))(i);o(r(JSON.stringify(a),s,"application/json"))})))(s,false))}; |
@@ -1,2 +0,2 @@ | ||
/* Partytown 0.0.20 - MIT builder.io */ | ||
/* Partytown 0.0.21 - MIT builder.io */ | ||
!function(t,e,n,i,o,r,a){function s(t){o||((o=e.createElement("iframe")).dataset.partytown="sandbox",o.setAttribute("style","display:block;width:0;height:0;border:0;visibility:hidden"),o.setAttribute("aria-hidden","true"),o.src=i+"partytown-sandbox-"+t+".html?"+Date.now(),e.body.appendChild(o))}function d(t,n){for(clearTimeout(a),o=1,t=0;t<r.length;t++)(n=e.createElement("script")).innerHTML=r[t].innerHTML,e.body.appendChild(n)}function c(){if(i=(t.partytown||{}).lib||"/~partytown/",r=e.querySelectorAll('script[type="text/partytown"]'),top!==t)top.dispatchEvent(new CustomEvent("pt1",{detail:t}));else if(r.length){if(a=setTimeout(d,1e4),e.addEventListener("pt0",(function(){clearTimeout(a)})),t.crossOriginIsolated)s("atomics");else if("serviceWorker"in n){const e=t.crossOriginIsolated?"?isolated":"";n.serviceWorker.register(i+"partytown-sw.js"+e,{scope:i}).then((function(t){t.active?s("sw"):t.installing?t.installing.addEventListener("statechange",(function(t){"activated"===t.target.state&&s("sw")})):console.warn(t)}),(function(t){console.error(t)}))}else d()}}"complete"===e.readyState?c():window.addEventListener("load",c)}(window,document,navigator); |
{ | ||
"name": "@builder.io/partytown", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "Relocate resource intensive third-party scripts off of the main thread and into a web worker.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,4 +6,4 @@ { | ||
"types": "index.d.ts", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"private": true | ||
} |
@@ -6,4 +6,4 @@ { | ||
"types": "index.d.ts", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"private": true | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
262529
4506
5
253018