This commit is contained in:
nurmuhammet committed 2026-05-08 20:49:37 +05:00
commit bb5d03bf86
2758 files changed
+1485998

No files matched your search

@@ -0,0 +1,572 @@
/* Partytown 0.8.1 - MIT builder.io */
(window => {
const isPromise = v => "object" == typeof v && v && v.then;
const noop = () => {};
const len = obj => obj.length;
const getConstructorName = obj => {
var _a, _b, _c;
try {
const constructorName = null === (_a = null == obj ? void 0 : obj.constructor) || void 0 === _a ? void 0 : _a.name;
if (constructorName) {
return constructorName;
}
} catch (e) {}
try {
const zoneJsConstructorName = null === (_c = null === (_b = null == obj ? void 0 : obj.__zone_symbol__originalInstance) || void 0 === _b ? void 0 : _b.constructor) || void 0 === _c ? void 0 : _c.name;
if (zoneJsConstructorName) {
return zoneJsConstructorName;
}
} catch (e) {}
return "";
};
const startsWith = (str, val) => str.startsWith(val);
const isValidMemberName = memberName => !(startsWith(memberName, "webkit") || startsWith(memberName, "toJSON") || startsWith(memberName, "constructor") || startsWith(memberName, "toString") || startsWith(memberName, "_"));
const getNodeName = node => 11 === node.nodeType && node.host ? "#s" : node.nodeName;
const randomId = () => Math.round(Math.random() * Number.MAX_SAFE_INTEGER).toString(36);
const defineConstructorName = (Cstr, value) => ((obj, memberName, descriptor) => Object.defineProperty(obj, memberName, {
...descriptor,
configurable: true
}))(Cstr, "name", {
value: value
});
const htmlConstructorTags = {
Anchor: "a",
DList: "dl",
Image: "img",
OList: "ol",
Paragraph: "p",
Quote: "q",
TableCaption: "caption",
TableCell: "td",
TableCol: "colgroup",
TableRow: "tr",
TableSection: "tbody",
UList: "ul"
};
const svgConstructorTags = {
Graphics: "g",
SVG: "svg"
};
const InstanceIdKey = Symbol();
const CreatedKey = Symbol();
const instances = new Map;
const mainRefs = new Map;
const winCtxs = {};
const windowIds = new WeakMap;
const getAndSetInstanceId = (instance, instanceId) => {
if (instance) {
if (instanceId = windowIds.get(instance)) {
return instanceId;
}
(instanceId = instance[InstanceIdKey]) || setInstanceId(instance, instanceId = randomId());
return instanceId;
}
};
const getInstance = (winId, instanceId, win, doc, docId) => {
if ((win = winCtxs[winId]) && win.$window$) {
if (winId === instanceId) {
return win.$window$;
}
doc = win.$window$.document;
docId = instanceId.split(".").pop();
if ("d" === docId) {
return doc;
}
if ("e" === docId) {
return doc.documentElement;
}
if ("h" === docId) {
return doc.head;
}
if ("b" === docId) {
return doc.body;
}
}
return instances.get(instanceId);
};
const setInstanceId = (instance, instanceId, now) => {
if (instance) {
instances.set(instanceId, instance);
instance[InstanceIdKey] = instanceId;
instance[CreatedKey] = now = Date.now();
if (now > lastCleanup + 5e3) {
instances.forEach(((storedInstance, instanceId) => {
storedInstance[CreatedKey] < lastCleanup && storedInstance.nodeType && !storedInstance.isConnected && instances.delete(instanceId);
}));
lastCleanup = now;
}
}
};
let lastCleanup = 0;
const mainWindow = window.parent;
const docImpl = document.implementation.createHTMLDocument();
const config = mainWindow.partytown || {};
const libPath = (config.lib || "/~partytown/") + "debug/";
const logMain = msg => {
console.debug.apply(console, [ "%cMain 🌎", "background: #717171; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;", msg ]);
};
const winIds = [];
const normalizedWinId = winId => {
winIds.includes(winId) || winIds.push(winId);
return winIds.indexOf(winId) + 1;
};
const defineCustomElement = (winId, worker, ceData) => {
const Cstr = defineConstructorName(class extends winCtxs[winId].$window$.HTMLElement {}, ceData[0]);
const ceCallbackMethods = "connectedCallback,disconnectedCallback,attributeChangedCallback,adoptedCallback".split(",");
ceCallbackMethods.map((callbackMethodName => Cstr.prototype[callbackMethodName] = function(...args) {
worker.postMessage([ 15, winId, getAndSetInstanceId(this), callbackMethodName, args ]);
}));
Cstr.observedAttributes = ceData[1];
return Cstr;
};
const serializeForWorker = ($winId$, value, added, type, cstrName, prevInstanceId) => void 0 !== value && (type = typeof value) ? "string" === type || "number" === type || "boolean" === type || null == value ? [ 0, value ] : "function" === type ? [ 6 ] : (added = added || new Set) && Array.isArray(value) ? added.has(value) ? [ 1, [] ] : added.add(value) && [ 1, value.map((v => serializeForWorker($winId$, v, added))) ] : "object" === type ? serializedValueIsError(value) ? [ 14, {
name: value.name,
message: value.message,
stack: value.stack
} ] : "" === (cstrName = getConstructorName(value)) ? [ 2, {} ] : "Window" === cstrName ? [ 3, [ $winId$, $winId$ ] ] : "HTMLCollection" === cstrName || "NodeList" === cstrName ? [ 7, Array.from(value).map((v => serializeForWorker($winId$, v, added)[1])) ] : cstrName.endsWith("Event") ? [ 5, serializeObjectForWorker($winId$, value, added) ] : "CSSRuleList" === cstrName ? [ 12, Array.from(value).map(serializeCssRuleForWorker) ] : startsWith(cstrName, "CSS") && cstrName.endsWith("Rule") ? [ 11, serializeCssRuleForWorker(value) ] : "CSSStyleDeclaration" === cstrName ? [ 13, serializeObjectForWorker($winId$, value, added) ] : "Attr" === cstrName ? [ 10, [ value.name, value.value ] ] : value.nodeType ? [ 3, [ $winId$, getAndSetInstanceId(value), getNodeName(value), prevInstanceId ] ] : [ 2, serializeObjectForWorker($winId$, value, added, true, true) ] : void 0 : value;
const serializeObjectForWorker = (winId, obj, added, includeFunctions, includeEmptyStrings, serializedObj, propName, propValue) => {
serializedObj = {};
if (!added.has(obj)) {
added.add(obj);
for (propName in obj) {
if (isValidMemberName(propName)) {
propValue = "path" === propName && getConstructorName(obj).endsWith("Event") ? obj.composedPath() : obj[propName];
(includeFunctions || "function" != typeof propValue) && (includeEmptyStrings || "" !== propValue) && (serializedObj[propName] = serializeForWorker(winId, propValue, added));
}
}
}
return serializedObj;
};
const serializeCssRuleForWorker = cssRule => {
let obj = {};
let key;
for (key in cssRule) {
validCssRuleProps.includes(key) && (obj[key] = String(cssRule[key]));
}
return obj;
};
const serializedValueIsError = value => value instanceof window.top.Error;
const deserializeFromWorker = (worker, serializedTransfer, serializedType, serializedValue) => {
if (serializedTransfer) {
serializedType = serializedTransfer[0];
serializedValue = serializedTransfer[1];
return 0 === serializedType ? serializedValue : 4 === serializedType ? deserializeRefFromWorker(worker, serializedValue) : 1 === serializedType ? serializedValue.map((v => deserializeFromWorker(worker, v))) : 3 === serializedType ? getInstance(serializedValue[0], serializedValue[1]) : 5 === serializedType ? constructEvent(deserializeObjectFromWorker(worker, serializedValue)) : 2 === serializedType ? deserializeObjectFromWorker(worker, serializedValue) : 8 === serializedType ? serializedValue : 9 === serializedType ? new window[serializedTransfer[2]](serializedValue) : void 0;
}
};
const deserializeRefFromWorker = (worker, {$winId$: $winId$, $instanceId$: $instanceId$, $refId$: $refId$}, ref) => {
ref = mainRefs.get($refId$);
if (!ref) {
ref = function(...args) {
worker.postMessage([ 9, {
$winId$: $winId$,
$instanceId$: $instanceId$,
$refId$: $refId$,
$thisArg$: serializeForWorker($winId$, this),
$args$: serializeForWorker($winId$, args)
} ]);
};
mainRefs.set($refId$, ref);
}
return ref;
};
const constructEvent = eventProps => new ("detail" in eventProps ? CustomEvent : Event)(eventProps.type, eventProps);
const deserializeObjectFromWorker = (worker, serializedValue, obj, key) => {
obj = {};
for (key in serializedValue) {
obj[key] = deserializeFromWorker(worker, serializedValue[key]);
}
return obj;
};
const validCssRuleProps = "cssText,selectorText,href,media,namespaceURI,prefix,name,conditionText".split(",");
const mainAccessHandler = async (worker, accessReq) => {
let accessRsp = {
$msgId$: accessReq.$msgId$
};
let totalTasks = len(accessReq.$tasks$);
let i = 0;
let task;
let winId;
let applyPath;
let instance;
let rtnValue;
let isLast;
for (;i < totalTasks; i++) {
try {
isLast = i === totalTasks - 1;
task = accessReq.$tasks$[i];
winId = task.$winId$;
applyPath = task.$applyPath$;
!winCtxs[winId] && winId.startsWith("f_") && await new Promise((resolve => {
let check = 0;
let callback = () => {
winCtxs[winId] || check++ > 1e3 ? resolve() : requestAnimationFrame(callback);
};
callback();
}));
if (1 === applyPath[0] && applyPath[1] in winCtxs[winId].$window$) {
setInstanceId(new winCtxs[winId].$window$[applyPath[1]](...deserializeFromWorker(worker, applyPath[2])), task.$instanceId$);
} else {
instance = getInstance(winId, task.$instanceId$);
if (instance) {
rtnValue = applyToInstance(worker, winId, instance, applyPath, isLast, task.$groupedGetters$);
task.$assignInstanceId$ && ("string" == typeof task.$assignInstanceId$ ? setInstanceId(rtnValue, task.$assignInstanceId$) : winCtxs[task.$assignInstanceId$.$winId$] = {
$winId$: task.$assignInstanceId$.$winId$,
$window$: {
document: rtnValue
}
});
if (isPromise(rtnValue)) {
rtnValue = await rtnValue;
isLast && (accessRsp.$isPromise$ = true);
}
isLast && (accessRsp.$rtnValue$ = serializeForWorker(winId, rtnValue, void 0, void 0, void 0, task.$instanceId$));
} else {
accessRsp.$error$ = `Error finding instance "${task.$instanceId$}" on window ${normalizedWinId(winId)}`;
console.error(accessRsp.$error$, task);
}
}
} catch (e) {
isLast ? accessRsp.$error$ = String(e.stack || e) : console.error(e);
}
}
return accessRsp;
};
const applyToInstance = (worker, winId, instance, applyPath, isLast, groupedGetters) => {
let i = 0;
let l = len(applyPath);
let next;
let current;
let previous;
let args;
let groupedRtnValues;
for (;i < l; i++) {
current = applyPath[i];
next = applyPath[i + 1];
previous = applyPath[i - 1];
try {
if (!Array.isArray(next)) {
if ("string" == typeof current || "number" == typeof current) {
if (i + 1 === l && groupedGetters) {
groupedRtnValues = {};
groupedGetters.map((propName => groupedRtnValues[propName] = instance[propName]));
return groupedRtnValues;
}
instance = instance[current];
} else {
if (0 === next) {
instance[previous] = deserializeFromWorker(worker, current);
return;
}
if ("function" == typeof instance[previous]) {
args = deserializeFromWorker(worker, current);
"define" === previous && "CustomElementRegistry" === getConstructorName(instance) && (args[1] = defineCustomElement(winId, worker, args[1]));
"insertRule" === previous && args[1] > len(instance.cssRules) && (args[1] = len(instance.cssRules));
instance = instance[previous].apply(instance, args);
if ("play" === previous) {
return Promise.resolve();
}
}
}
}
} catch (err) {
if (isLast) {
throw err;
}
console.debug("Non-blocking setter error:", err);
}
}
return instance;
};
const readNextScript = (worker, winCtx) => {
let $winId$ = winCtx.$winId$;
let win = winCtx.$window$;
let doc = win.document;
let scriptSelector = 'script[type="text/partytown"]:not([data-ptid]):not([data-pterror])';
let scriptElm;
let $instanceId$;
let scriptData;
if (doc && doc.body) {
scriptElm = doc.querySelector('script[type="text/partytown"]:not([data-ptid]):not([data-pterror]):not([async]):not([defer])');
scriptElm || (scriptElm = doc.querySelector(scriptSelector));
if (scriptElm) {
scriptElm.dataset.ptid = $instanceId$ = getAndSetInstanceId(scriptElm, $winId$);
scriptData = {
$winId$: $winId$,
$instanceId$: $instanceId$
};
if (scriptElm.src) {
scriptData.$url$ = scriptElm.src;
scriptData.$orgUrl$ = scriptElm.dataset.ptsrc || scriptElm.src;
} else {
scriptData.$content$ = scriptElm.innerHTML;
}
worker.postMessage([ 7, scriptData ]);
} else {
if (!winCtx.$isInitialized$) {
winCtx.$isInitialized$ = 1;
((worker, $winId$, win) => {
let queuedForwardCalls = win._ptf;
let forwards = (win.partytown || {}).forward || [];
let i;
let mainForwardFn;
let forwardCall = ($forward$, args) => worker.postMessage([ 10, {
$winId$: $winId$,
$forward$: $forward$,
$args$: serializeForWorker($winId$, Array.from(args))
} ]);
win._ptf = void 0;
forwards.map((forwardProps => {
mainForwardFn = win;
forwardProps.split(".").map(((_, i, arr) => {
mainForwardFn = mainForwardFn[arr[i]] = i + 1 < len(arr) ? mainForwardFn[arr[i]] || ("push" === arr[i + 1] ? [] : {}) : (...args) => forwardCall(arr, args);
}));
}));
if (queuedForwardCalls) {
for (i = 0; i < len(queuedForwardCalls); i += 2) {
forwardCall(queuedForwardCalls[i], queuedForwardCalls[i + 1]);
}
}
})(worker, $winId$, win);
doc.dispatchEvent(new CustomEvent("pt0"));
{
const winType = win === win.top ? "top" : "iframe";
logMain(`Executed ${winType} window ${normalizedWinId($winId$)} environment scripts in ${(performance.now() - winCtx.$startTime$).toFixed(1)}ms`);
}
}
worker.postMessage([ 8, $winId$ ]);
}
} else {
requestAnimationFrame((() => readNextScript(worker, winCtx)));
}
};
const registerWindow = (worker, $winId$, $window$) => {
if (!windowIds.has($window$)) {
windowIds.set($window$, $winId$);
const doc = $window$.document;
const history = $window$.history;
const $parentWinId$ = windowIds.get($window$.parent);
let initialised = false;
const onInitialisedQueue = [];
const onInitialised = callback => {
initialised ? callback() : onInitialisedQueue.push(callback);
};
const sendInitEnvData = () => {
worker.postMessage([ 5, {
$winId$: $winId$,
$parentWinId$: $parentWinId$,
$url$: doc.baseURI,
$visibilityState$: doc.visibilityState
} ]);
setTimeout((() => {
initialised = true;
onInitialisedQueue.forEach((callback => {
callback();
}));
}));
};
const pushState = history.pushState.bind(history);
const replaceState = history.replaceState.bind(history);
const onLocationChange = (type, state, newUrl, oldUrl) => () => {
setTimeout((() => {
worker.postMessage([ 13, {
$winId$: $winId$,
type: type,
state: state,
url: doc.baseURI,
newUrl: newUrl,
oldUrl: oldUrl
} ]);
}));
};
history.pushState = (state, _, newUrl) => {
pushState(state, _, newUrl);
onInitialised(onLocationChange(0, state, null == newUrl ? void 0 : newUrl.toString()));
};
history.replaceState = (state, _, newUrl) => {
replaceState(state, _, newUrl);
onInitialised(onLocationChange(1, state, null == newUrl ? void 0 : newUrl.toString()));
};
$window$.addEventListener("popstate", (event => {
onInitialised(onLocationChange(2, event.state));
}));
$window$.addEventListener("hashchange", (event => {
onInitialised(onLocationChange(3, {}, event.newURL, event.oldURL));
}));
$window$.addEventListener("ptupdate", (() => {
readNextScript(worker, winCtxs[$winId$]);
}));
doc.addEventListener("visibilitychange", (() => worker.postMessage([ 14, $winId$, doc.visibilityState ])));
winCtxs[$winId$] = {
$winId$: $winId$,
$window$: $window$
};
winCtxs[$winId$].$startTime$ = performance.now();
{
const winType = $winId$ === $parentWinId$ ? "top" : "iframe";
logMain(`Registered ${winType} window ${normalizedWinId($winId$)}`);
}
"complete" === doc.readyState ? sendInitEnvData() : $window$.addEventListener("load", sendInitEnvData);
}
};
const onMessageFromWebWorker = (worker, msg, winCtx) => {
if (4 === msg[0]) {
registerWindow(worker, randomId(), mainWindow);
} else {
winCtx = winCtxs[msg[1]];
winCtx && (7 === msg[0] ? requestAnimationFrame((() => readNextScript(worker, winCtx))) : 6 === msg[0] && ((worker, winCtx, instanceId, errorMsg, scriptElm) => {
scriptElm = winCtx.$window$.document.querySelector(`[data-ptid="${instanceId}"]`);
if (scriptElm) {
errorMsg ? scriptElm.dataset.pterror = errorMsg : scriptElm.type += "-x";
delete scriptElm.dataset.ptid;
}
readNextScript(worker, winCtx);
})(worker, winCtx, msg[2], msg[3]));
}
};
const readMainInterfaces = () => {
const elms = Object.getOwnPropertyNames(mainWindow).map((interfaceName => ((doc, interfaceName, r, tag) => {
r = interfaceName.match(/^(HTML|SVG)(.+)Element$/);
if (r) {
tag = r[2];
return "S" == interfaceName[0] ? doc.createElementNS("http://www.w3.org/2000/svg", svgConstructorTags[tag] || tag.slice(0, 2).toLowerCase() + tag.slice(2)) : doc.createElement(htmlConstructorTags[tag] || tag);
}
})(docImpl, interfaceName))).filter((elm => elm)).map((elm => [ elm ]));
return readImplementations(elms, []);
};
const readImplementations = (impls, interfaces) => {
const cstrs = new Set([ "Object" ]);
const cstrImpls = impls.filter((implData => implData[0])).map((implData => {
const impl = implData[0];
const interfaceType = implData[1];
const cstrName = getConstructorName(impl);
const CstrPrototype = mainWindow[cstrName].prototype;
return [ cstrName, CstrPrototype, impl, interfaceType ];
}));
cstrImpls.map((([cstrName, CstrPrototype, impl, intefaceType]) => readOwnImplementation(cstrs, interfaces, cstrName, CstrPrototype, impl, intefaceType)));
return interfaces;
};
const readImplementation = (cstrName, impl, memberName) => {
let interfaceMembers = [];
let interfaceInfo = [ cstrName, "Object", interfaceMembers ];
for (memberName in impl) {
readImplementationMember(interfaceMembers, impl, memberName);
}
return interfaceInfo;
};
const readOwnImplementation = (cstrs, interfaces, cstrName, CstrPrototype, impl, interfaceType) => {
if (!cstrs.has(cstrName)) {
cstrs.add(cstrName);
const SuperCstr = Object.getPrototypeOf(CstrPrototype);
const superCstrName = getConstructorName(SuperCstr);
const interfaceMembers = [];
const propDescriptors = Object.getOwnPropertyDescriptors(CstrPrototype);
readOwnImplementation(cstrs, interfaces, superCstrName, SuperCstr, impl, interfaceType);
for (const memberName in propDescriptors) {
readImplementationMember(interfaceMembers, impl, memberName);
}
interfaces.push([ cstrName, superCstrName, interfaceMembers, interfaceType, getNodeName(impl) ]);
}
};
const readImplementationMember = (interfaceMembers, implementation, memberName, value, memberType, cstrName) => {
try {
if (isValidMemberName(memberName) && isNaN(memberName[0]) && "all" !== memberName) {
value = implementation[memberName];
memberType = typeof value;
if ("function" === memberType) {
(String(value).includes("[native") || Object.getPrototypeOf(implementation)[memberName]) && interfaceMembers.push([ memberName, 5 ]);
} else if ("object" === memberType && null != value) {
cstrName = getConstructorName(value);
"Object" !== cstrName && "Function" !== cstrName && self[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]);
} else {
"symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]));
}
}
} catch (e) {
console.warn(e);
}
};
const readStorage = storageName => {
let items = [];
let i = 0;
let l = len(mainWindow[storageName]);
let key;
for (;i < l; i++) {
key = mainWindow[storageName].key(i);
items.push([ key, mainWindow[storageName].getItem(key) ]);
}
return items;
};
const getGlobalConstructor = (mainWindow, cstrName) => void 0 !== mainWindow[cstrName] ? new mainWindow[cstrName](noop) : 0;
const addGlobalConstructorUsingPrototype = ($interfaces$, mainWindow, cstrName) => {
void 0 !== mainWindow[cstrName] && $interfaces$.push([ cstrName, "Object", Object.keys(mainWindow[cstrName].prototype).map((propName => [ propName, 6 ])), 12 ]);
};
let worker;
(async receiveMessage => {
const sharedDataBuffer = new SharedArrayBuffer(1073741824);
const sharedData = new Int32Array(sharedDataBuffer);
return (worker, msg) => {
const msgType = msg[0];
const accessReq = msg[1];
if (0 === msgType) {
const initData = (() => {
const elm = docImpl.createElement("i");
const textNode = docImpl.createTextNode("");
const comment = docImpl.createComment("");
const frag = docImpl.createDocumentFragment();
const shadowRoot = docImpl.createElement("p").attachShadow({
mode: "open"
});
const intersectionObserver = getGlobalConstructor(mainWindow, "IntersectionObserver");
const mutationObserver = getGlobalConstructor(mainWindow, "MutationObserver");
const resizeObserver = getGlobalConstructor(mainWindow, "ResizeObserver");
const perf = mainWindow.performance;
const screen = mainWindow.screen;
const impls = [ [ mainWindow.history ], [ perf ], [ perf.navigation ], [ perf.timing ], [ screen ], [ screen.orientation ], [ mainWindow.visualViewport ], [ intersectionObserver, 12 ], [ mutationObserver, 12 ], [ resizeObserver, 12 ], [ textNode ], [ comment ], [ frag ], [ shadowRoot ], [ elm ], [ elm.attributes ], [ elm.classList ], [ elm.dataset ], [ elm.style ], [ docImpl ], [ docImpl.doctype ] ];
const initialInterfaces = [ readImplementation("Window", mainWindow), readImplementation("Node", textNode) ];
const $config$ = JSON.stringify(config, ((k, v) => {
if ("function" == typeof v) {
v = String(v);
v.startsWith(k + "(") && (v = "function " + v);
}
return v;
}));
const initWebWorkerData = {
$config$: $config$,
$interfaces$: readImplementations(impls, initialInterfaces),
$libPath$: new URL(libPath, mainWindow.location) + "",
$origin$: origin,
$localStorage$: readStorage("localStorage"),
$sessionStorage$: readStorage("sessionStorage")
};
addGlobalConstructorUsingPrototype(initWebWorkerData.$interfaces$, mainWindow, "IntersectionObserverEntry");
return initWebWorkerData;
})();
initData.$sharedDataBuffer$ = sharedDataBuffer;
worker.postMessage([ 1, initData ]);
} else {
2 === msg[0] ? worker.postMessage([ 3, readMainInterfaces() ]) : 11 === msgType ? receiveMessage(accessReq, (accessRsp => {
const stringifiedData = JSON.stringify(accessRsp);
const stringifiedDataLength = stringifiedData.length;
for (let i = 0; i < stringifiedDataLength; i++) {
sharedData[i + 1] = stringifiedData.charCodeAt(i);
}
sharedData[0] = stringifiedDataLength;
Atomics.notify(sharedData, 0);
})) : onMessageFromWebWorker(worker, msg);
}
};
})(((accessReq, responseCallback) => mainAccessHandler(worker, accessReq).then(responseCallback))).then((onMessageHandler => {
if (onMessageHandler) {
worker = new Worker(libPath + "partytown-ww-atomics.js?v=0.8.1", {
name: "Partytown 🎉"
});
worker.onmessage = ev => {
const msg = ev.data;
12 === msg[0] ? mainAccessHandler(worker, msg[1]) : onMessageHandler(worker, msg);
};
logMain("Created Partytown web worker (0.8.1)");
worker.onerror = ev => console.error("Web Worker Error", ev);
mainWindow.addEventListener("pt1", (ev => registerWindow(worker, getAndSetInstanceId(ev.detail.frameElement), ev.detail)));
}
}));
})(window);
+374
View File
@@ -0,0 +1,374 @@
/* Partytown 0.8.1 - MIT builder.io */
(self => {
const [getter, setter, callMethod, constructGlobal, definePrototypePropertyDescriptor, randomId, WinIdKey, InstanceIdKey, ApplyPathKey] = self.$bridgeToMedia$;
delete self.$bridgeToMedia$;
const ContextKey = Symbol();
const MediaSourceKey = Symbol();
const ReadyStateKey = Symbol();
const SourceBuffersKey = Symbol();
const SourceBufferTasksKey = Symbol();
const TimeRangesKey = Symbol();
const EMPTY_ARRAY = [];
const defineCstr = (win, cstrName, Cstr) => win[cstrName] = defineCstrName(cstrName, Cstr);
const defineCstrName = (cstrName, Cstr) => Object.defineProperty(Cstr, "name", {
value: cstrName
});
const initCanvas = (WorkerBase, win) => {
const HTMLCanvasDescriptorMap = {
getContext: {
value(contextType, contextAttributes) {
this[ContextKey] || (this[ContextKey] = (contextType.includes("webgl") ? createContextWebGL : createContext2D)(this, contextType, contextAttributes));
return this[ContextKey];
}
}
};
const WorkerCanvasGradient = defineCstr(win, "CanvasGradient", class extends WorkerBase {
addColorStop(...args) {
callMethod(this, [ "addColorStop" ], args, 2);
}
});
const WorkerCanvasPattern = defineCstr(win, "CanvasPattern", class extends WorkerBase {
setTransform(...args) {
callMethod(this, [ "setTransform" ], args, 2);
}
});
const createContext2D = (canvasInstance, contextType, contextAttributes) => {
const winId = canvasInstance[WinIdKey];
const ctxInstanceId = randomId();
const ctxInstance = {
[WinIdKey]: winId,
[InstanceIdKey]: ctxInstanceId,
[ApplyPathKey]: []
};
const ctx = callMethod(canvasInstance, [ "getContext" ], [ contextType, contextAttributes ], 1, ctxInstanceId);
const ctx2dGetterMethods = "getContextAttributes,getImageData,getLineDash,getTransform,isPointInPath,isPointInStroke,measureText".split(",");
const CanvasRenderingContext2D = {
get: (target, propName) => "string" == typeof propName && propName in ctx ? "function" == typeof ctx[propName] ? (...args) => {
if (propName.startsWith("create")) {
const instanceId = randomId();
callMethod(ctxInstance, [ propName ], args, 2, instanceId);
if ("createImageData" === propName || "createPattern" === propName) {
(api => {
console.warn(`${api} not implemented`);
})(`${propName}()`);
return {
setTransform: () => {}
};
}
return new WorkerCanvasGradient(winId, instanceId);
}
const methodCallType = ctx2dGetterMethods.includes(propName) ? 1 : 2;
return callMethod(ctxInstance, [ propName ], args, methodCallType);
} : ctx[propName] : target[propName],
set(target, propName, value) {
if ("string" == typeof propName && propName in ctx) {
ctx[propName] !== value && "function" != typeof value && setter(ctxInstance, [ propName ], value);
ctx[propName] = value;
} else {
target[propName] = value;
}
return true;
}
};
return new Proxy(ctx, CanvasRenderingContext2D);
};
const createContextWebGL = (canvasInstance, contextType, contextAttributes) => {
const winId = canvasInstance[WinIdKey];
const ctxInstanceId = randomId();
const ctxInstance = {
[WinIdKey]: winId,
[InstanceIdKey]: ctxInstanceId,
[ApplyPathKey]: []
};
const ctx = callMethod(canvasInstance, [ "getContext" ], [ contextType, contextAttributes ], 1, ctxInstanceId);
const WebGLRenderingContextHandler = {
get: (target, propName) => "string" == typeof propName ? "function" != typeof ctx[propName] ? ctx[propName] : (...args) => callMethod(ctxInstance, [ propName ], args, getWebGlMethodCallType(propName)) : target[propName],
set(target, propName, value) {
if ("string" == typeof propName && propName in ctx) {
ctx[propName] !== value && "function" != typeof value && setter(ctxInstance, [ propName ], value);
ctx[propName] = value;
} else {
target[propName] = value;
}
return true;
}
};
return new Proxy(ctx, WebGLRenderingContextHandler);
};
const ctxWebGLGetterMethods = "checkFramebufferStatus,makeXRCompatible".split(",");
const getWebGlMethodCallType = methodName => methodName.startsWith("create") || methodName.startsWith("get") || methodName.startsWith("is") || ctxWebGLGetterMethods.includes(methodName) ? 1 : 2;
defineCstr(win, "CanvasGradient", WorkerCanvasGradient);
defineCstr(win, "CanvasPattern", WorkerCanvasPattern);
definePrototypePropertyDescriptor(win.HTMLCanvasElement, HTMLCanvasDescriptorMap);
};
const initMedia = (WorkerBase, WorkerEventTargetProxy, env, win) => {
var _a, _b;
win.Audio = defineCstrName("HTMLAudioElement", class {
constructor(src) {
const audio = env.$createNode$("audio", randomId());
audio.src = src;
return audio;
}
});
const WorkerAudioTrack = class extends WorkerBase {
get enabled() {
return getter(this, [ "enabled" ]);
}
set enabled(value) {
setter(this, [ "enabled" ], value);
}
get id() {
return getter(this, [ "id" ]);
}
get kind() {
return getter(this, [ "kind" ]);
}
get label() {
return getter(this, [ "label" ]);
}
get language() {
return getter(this, [ "language" ]);
}
get sourceBuffer() {
return new WorkerSourceBuffer(this);
}
};
const WorkerAudioTrackList = class {
constructor(mediaElm) {
const winId = mediaElm[WinIdKey];
const instanceId = mediaElm[InstanceIdKey];
const instance = {
addEventListener(...args) {
callMethod(mediaElm, [ "audioTracks", "addEventListener" ], args, 3);
},
getTrackById: (...args) => callMethod(mediaElm, [ "audioTracks", "getTrackById" ], args),
get length() {
return getter(mediaElm, [ "audioTracks", "length" ]);
},
removeEventListener(...args) {
callMethod(mediaElm, [ "audioTracks", "removeEventListener" ], args, 3);
}
};
return new Proxy(instance, {
get: (target, propName) => "number" == typeof propName ? new WorkerAudioTrack(winId, instanceId, [ "audioTracks", propName ]) : target[propName]
});
}
};
const WorkerSourceBufferList = defineCstr(win, "SourceBufferList", class extends Array {
constructor(mediaSource) {
super();
this[MediaSourceKey] = mediaSource;
}
addEventListener(...args) {
callMethod(this[MediaSourceKey], [ "sourceBuffers", "addEventListener" ], args, 3);
}
removeEventListener(...args) {
callMethod(this[MediaSourceKey], [ "sourceBuffers", "removeEventListener" ], args, 3);
}
});
const WorkerSourceBuffer = defineCstr(win, "SourceBuffer", (_b = class extends WorkerEventTargetProxy {
constructor(mediaSource) {
super(mediaSource[WinIdKey], mediaSource[InstanceIdKey], [ "sourceBuffers" ]);
this[_a] = [];
this[MediaSourceKey] = mediaSource;
}
abort() {
const sbIndex = getSourceBufferIndex(this);
callMethod(this, [ sbIndex, "appendWindowStart" ], EMPTY_ARRAY, 1);
}
addEventListener(...args) {
const sbIndex = getSourceBufferIndex(this);
callMethod(this, [ sbIndex, "addEventListener" ], args, 3);
}
appendBuffer(buf) {
this[SourceBufferTasksKey].push([ "appendBuffer", [ buf ], buf ]);
drainSourceBufferQueue(this);
}
get appendWindowStart() {
const sbIndex = getSourceBufferIndex(this);
return getter(this, [ sbIndex, "appendWindowStart" ]);
}
set appendWindowStart(value) {
const sbIndex = getSourceBufferIndex(this);
setter(this, [ sbIndex, "appendWindowStart" ], value);
}
get appendWindowEnd() {
const sbIndex = getSourceBufferIndex(this);
return getter(this, [ sbIndex, "appendWindowEnd" ]);
}
set appendWindowEnd(value) {
const sbIndex = getSourceBufferIndex(this);
setter(this, [ sbIndex, "appendWindowEnd" ], value);
}
get buffered() {
const mediaSource = this[MediaSourceKey];
const sbIndex = getSourceBufferIndex(this);
const timeRanges = new WorkerTimeRanges(mediaSource[WinIdKey], mediaSource[InstanceIdKey], [ "sourceBuffers", sbIndex, "buffered" ]);
return timeRanges;
}
changeType(mimeType) {
const sbIndex = getSourceBufferIndex(this);
callMethod(this, [ sbIndex, "changeType" ], [ mimeType ], 2);
}
get mode() {
const sbIndex = getSourceBufferIndex(this);
return getter(this, [ sbIndex, "mode" ]);
}
set mode(value) {
const sbIndex = getSourceBufferIndex(this);
setter(this, [ sbIndex, "mode" ], value);
}
remove(start, end) {
this[SourceBufferTasksKey].push([ "remove", [ start, end ] ]);
drainSourceBufferQueue(this);
}
removeEventListener(...args) {
const sbIndex = getSourceBufferIndex(this);
callMethod(this, [ sbIndex, "removeEventListener" ], args, 3);
}
get timestampOffset() {
const sbIndex = getSourceBufferIndex(this);
return getter(this, [ sbIndex, "timestampOffset" ]);
}
set timestampOffset(value) {
const sbIndex = getSourceBufferIndex(this);
setter(this, [ sbIndex, "timestampOffset" ], value);
}
get updating() {
const sbIndex = getSourceBufferIndex(this);
return getter(this, [ sbIndex, "updating" ]);
}
}, _a = SourceBufferTasksKey, _b));
const WorkerTimeRanges = defineCstr(win, "TimeRanges", class extends WorkerBase {
start(...args) {
return callMethod(this, [ "start" ], args);
}
end(...args) {
return callMethod(this, [ "end" ], args);
}
get length() {
return getter(this, [ "length" ]);
}
});
const getSourceBufferIndex = sourceBuffer => {
if (sourceBuffer) {
const mediaSource = sourceBuffer[MediaSourceKey];
const sourceBufferList = mediaSource[SourceBuffersKey];
return sourceBufferList.indexOf(sourceBuffer);
}
return -1;
};
const drainSourceBufferQueue = sourceBuffer => {
if (sourceBuffer[SourceBufferTasksKey].length) {
if (!sourceBuffer.updating) {
const task = sourceBuffer[SourceBufferTasksKey].shift();
if (task) {
const sbIndex = getSourceBufferIndex(sourceBuffer);
callMethod(sourceBuffer, [ sbIndex, task[0] ], task[1], 3, void 0, task[2]);
}
}
setTimeout((() => drainSourceBufferQueue(sourceBuffer)), 50);
}
};
const HTMLMediaDescriptorMap = {
buffered: {
get() {
if (!this[TimeRangesKey]) {
this[TimeRangesKey] = new WorkerTimeRanges(this[WinIdKey], this[InstanceIdKey], [ "buffered" ]);
setTimeout((() => {
this[TimeRangesKey] = void 0;
}), 5e3);
}
return this[TimeRangesKey];
}
},
readyState: {
get() {
if (4 === this[ReadyStateKey]) {
return 4;
}
if ("number" != typeof this[ReadyStateKey]) {
this[ReadyStateKey] = getter(this, [ "readyState" ]);
setTimeout((() => {
this[ReadyStateKey] = void 0;
}), 1e3);
}
return this[ReadyStateKey];
}
}
};
defineCstr(win, "MediaSource", class extends WorkerEventTargetProxy {
constructor() {
super(env.$winId$);
this[SourceBuffersKey] = new WorkerSourceBufferList(this);
constructGlobal(this, "MediaSource", EMPTY_ARRAY);
}
get activeSourceBuffers() {
return [];
}
addSourceBuffer(mimeType) {
const sourceBuffer = new WorkerSourceBuffer(this);
this[SourceBuffersKey].push(sourceBuffer);
callMethod(this, [ "addSourceBuffer" ], [ mimeType ]);
return sourceBuffer;
}
clearLiveSeekableRange() {
callMethod(this, [ "clearLiveSeekableRange" ], EMPTY_ARRAY, 2);
}
get duration() {
return getter(this, [ "duration" ]);
}
set duration(value) {
setter(this, [ "duration" ], value);
}
endOfStream(endOfStreamError) {
callMethod(this, [ "endOfStream" ], [ endOfStreamError ], 3);
}
get readyState() {
return getter(this, [ "readyState" ]);
}
removeSourceBuffer(sourceBuffer) {
const index = getSourceBufferIndex(sourceBuffer);
if (index > -1) {
this[SourceBuffersKey].splice(index, 1);
callMethod(this, [ "removeSourceBuffer" ], [ index ], 1);
}
}
setLiveSeekableRange(start, end) {
callMethod(this, [ "setLiveSeekableRange" ], [ start, end ], 2);
}
get sourceBuffers() {
return this[SourceBuffersKey];
}
static isTypeSupported(mimeType) {
if (!isStaticTypeSupported.has(mimeType)) {
const isSupported = callMethod(win, [ "MediaSource", "isTypeSupported" ], [ mimeType ]);
isStaticTypeSupported.set(mimeType, isSupported);
}
return isStaticTypeSupported.get(mimeType);
}
});
const winURL = win.URL = defineCstrName("URL", class extends URL {});
const hasAudioTracks = "audioTracks" in win.HTMLMediaElement.prototype;
if (hasAudioTracks) {
defineCstr(win, "AudioTrackList", WorkerAudioTrackList);
defineCstr(win, "AudioTrack", WorkerAudioTrack);
HTMLMediaDescriptorMap.audioTracks = {
get() {
return new WorkerAudioTrackList(this);
}
};
}
definePrototypePropertyDescriptor(win.HTMLMediaElement, HTMLMediaDescriptorMap);
winURL.createObjectURL = obj => callMethod(win, [ "URL", "createObjectURL" ], [ obj ]);
winURL.revokeObjectURL = obj => callMethod(win, [ "URL", "revokeObjectURL" ], [ obj ]);
};
const isStaticTypeSupported = new Map;
self.$bridgeFromMedia$ = (WorkerBase, WorkerEventTargetProxy, env, win, windowMediaConstructors) => {
windowMediaConstructors.map((mediaCstrName => {
delete win[mediaCstrName];
}));
initCanvas(WorkerBase, win);
initMedia(WorkerBase, WorkerEventTargetProxy, env, win);
};
})(self);
@@ -0,0 +1,559 @@
/* Partytown 0.8.1 - MIT builder.io */
(window => {
const isPromise = v => "object" == typeof v && v && v.then;
const noop = () => {};
const len = obj => obj.length;
const getConstructorName = obj => {
var _a, _b, _c;
try {
const constructorName = null === (_a = null == obj ? void 0 : obj.constructor) || void 0 === _a ? void 0 : _a.name;
if (constructorName) {
return constructorName;
}
} catch (e) {}
try {
const zoneJsConstructorName = null === (_c = null === (_b = null == obj ? void 0 : obj.__zone_symbol__originalInstance) || void 0 === _b ? void 0 : _b.constructor) || void 0 === _c ? void 0 : _c.name;
if (zoneJsConstructorName) {
return zoneJsConstructorName;
}
} catch (e) {}
return "";
};
const startsWith = (str, val) => str.startsWith(val);
const isValidMemberName = memberName => !(startsWith(memberName, "webkit") || startsWith(memberName, "toJSON") || startsWith(memberName, "constructor") || startsWith(memberName, "toString") || startsWith(memberName, "_"));
const getNodeName = node => 11 === node.nodeType && node.host ? "#s" : node.nodeName;
const randomId = () => Math.round(Math.random() * Number.MAX_SAFE_INTEGER).toString(36);
const defineConstructorName = (Cstr, value) => ((obj, memberName, descriptor) => Object.defineProperty(obj, memberName, {
...descriptor,
configurable: true
}))(Cstr, "name", {
value: value
});
const htmlConstructorTags = {
Anchor: "a",
DList: "dl",
Image: "img",
OList: "ol",
Paragraph: "p",
Quote: "q",
TableCaption: "caption",
TableCell: "td",
TableCol: "colgroup",
TableRow: "tr",
TableSection: "tbody",
UList: "ul"
};
const svgConstructorTags = {
Graphics: "g",
SVG: "svg"
};
const InstanceIdKey = Symbol();
const CreatedKey = Symbol();
const instances = new Map;
const mainRefs = new Map;
const winCtxs = {};
const windowIds = new WeakMap;
const getAndSetInstanceId = (instance, instanceId) => {
if (instance) {
if (instanceId = windowIds.get(instance)) {
return instanceId;
}
(instanceId = instance[InstanceIdKey]) || setInstanceId(instance, instanceId = randomId());
return instanceId;
}
};
const getInstance = (winId, instanceId, win, doc, docId) => {
if ((win = winCtxs[winId]) && win.$window$) {
if (winId === instanceId) {
return win.$window$;
}
doc = win.$window$.document;
docId = instanceId.split(".").pop();
if ("d" === docId) {
return doc;
}
if ("e" === docId) {
return doc.documentElement;
}
if ("h" === docId) {
return doc.head;
}
if ("b" === docId) {
return doc.body;
}
}
return instances.get(instanceId);
};
const setInstanceId = (instance, instanceId, now) => {
if (instance) {
instances.set(instanceId, instance);
instance[InstanceIdKey] = instanceId;
instance[CreatedKey] = now = Date.now();
if (now > lastCleanup + 5e3) {
instances.forEach(((storedInstance, instanceId) => {
storedInstance[CreatedKey] < lastCleanup && storedInstance.nodeType && !storedInstance.isConnected && instances.delete(instanceId);
}));
lastCleanup = now;
}
}
};
let lastCleanup = 0;
const mainWindow = window.parent;
const docImpl = document.implementation.createHTMLDocument();
const config = mainWindow.partytown || {};
const libPath = (config.lib || "/~partytown/") + "debug/";
const logMain = msg => {
console.debug.apply(console, [ "%cMain 🌎", "background: #717171; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;", msg ]);
};
const winIds = [];
const normalizedWinId = winId => {
winIds.includes(winId) || winIds.push(winId);
return winIds.indexOf(winId) + 1;
};
const defineCustomElement = (winId, worker, ceData) => {
const Cstr = defineConstructorName(class extends winCtxs[winId].$window$.HTMLElement {}, ceData[0]);
const ceCallbackMethods = "connectedCallback,disconnectedCallback,attributeChangedCallback,adoptedCallback".split(",");
ceCallbackMethods.map((callbackMethodName => Cstr.prototype[callbackMethodName] = function(...args) {
worker.postMessage([ 15, winId, getAndSetInstanceId(this), callbackMethodName, args ]);
}));
Cstr.observedAttributes = ceData[1];
return Cstr;
};
const serializeForWorker = ($winId$, value, added, type, cstrName, prevInstanceId) => void 0 !== value && (type = typeof value) ? "string" === type || "number" === type || "boolean" === type || null == value ? [ 0, value ] : "function" === type ? [ 6 ] : (added = added || new Set) && Array.isArray(value) ? added.has(value) ? [ 1, [] ] : added.add(value) && [ 1, value.map((v => serializeForWorker($winId$, v, added))) ] : "object" === type ? serializedValueIsError(value) ? [ 14, {
name: value.name,
message: value.message,
stack: value.stack
} ] : "" === (cstrName = getConstructorName(value)) ? [ 2, {} ] : "Window" === cstrName ? [ 3, [ $winId$, $winId$ ] ] : "HTMLCollection" === cstrName || "NodeList" === cstrName ? [ 7, Array.from(value).map((v => serializeForWorker($winId$, v, added)[1])) ] : cstrName.endsWith("Event") ? [ 5, serializeObjectForWorker($winId$, value, added) ] : "CSSRuleList" === cstrName ? [ 12, Array.from(value).map(serializeCssRuleForWorker) ] : startsWith(cstrName, "CSS") && cstrName.endsWith("Rule") ? [ 11, serializeCssRuleForWorker(value) ] : "CSSStyleDeclaration" === cstrName ? [ 13, serializeObjectForWorker($winId$, value, added) ] : "Attr" === cstrName ? [ 10, [ value.name, value.value ] ] : value.nodeType ? [ 3, [ $winId$, getAndSetInstanceId(value), getNodeName(value), prevInstanceId ] ] : [ 2, serializeObjectForWorker($winId$, value, added, true, true) ] : void 0 : value;
const serializeObjectForWorker = (winId, obj, added, includeFunctions, includeEmptyStrings, serializedObj, propName, propValue) => {
serializedObj = {};
if (!added.has(obj)) {
added.add(obj);
for (propName in obj) {
if (isValidMemberName(propName)) {
propValue = "path" === propName && getConstructorName(obj).endsWith("Event") ? obj.composedPath() : obj[propName];
(includeFunctions || "function" != typeof propValue) && (includeEmptyStrings || "" !== propValue) && (serializedObj[propName] = serializeForWorker(winId, propValue, added));
}
}
}
return serializedObj;
};
const serializeCssRuleForWorker = cssRule => {
let obj = {};
let key;
for (key in cssRule) {
validCssRuleProps.includes(key) && (obj[key] = String(cssRule[key]));
}
return obj;
};
const serializedValueIsError = value => value instanceof window.top.Error;
const deserializeFromWorker = (worker, serializedTransfer, serializedType, serializedValue) => {
if (serializedTransfer) {
serializedType = serializedTransfer[0];
serializedValue = serializedTransfer[1];
return 0 === serializedType ? serializedValue : 4 === serializedType ? deserializeRefFromWorker(worker, serializedValue) : 1 === serializedType ? serializedValue.map((v => deserializeFromWorker(worker, v))) : 3 === serializedType ? getInstance(serializedValue[0], serializedValue[1]) : 5 === serializedType ? constructEvent(deserializeObjectFromWorker(worker, serializedValue)) : 2 === serializedType ? deserializeObjectFromWorker(worker, serializedValue) : 8 === serializedType ? serializedValue : 9 === serializedType ? new window[serializedTransfer[2]](serializedValue) : void 0;
}
};
const deserializeRefFromWorker = (worker, {$winId$: $winId$, $instanceId$: $instanceId$, $refId$: $refId$}, ref) => {
ref = mainRefs.get($refId$);
if (!ref) {
ref = function(...args) {
worker.postMessage([ 9, {
$winId$: $winId$,
$instanceId$: $instanceId$,
$refId$: $refId$,
$thisArg$: serializeForWorker($winId$, this),
$args$: serializeForWorker($winId$, args)
} ]);
};
mainRefs.set($refId$, ref);
}
return ref;
};
const constructEvent = eventProps => new ("detail" in eventProps ? CustomEvent : Event)(eventProps.type, eventProps);
const deserializeObjectFromWorker = (worker, serializedValue, obj, key) => {
obj = {};
for (key in serializedValue) {
obj[key] = deserializeFromWorker(worker, serializedValue[key]);
}
return obj;
};
const validCssRuleProps = "cssText,selectorText,href,media,namespaceURI,prefix,name,conditionText".split(",");
const mainAccessHandler = async (worker, accessReq) => {
let accessRsp = {
$msgId$: accessReq.$msgId$
};
let totalTasks = len(accessReq.$tasks$);
let i = 0;
let task;
let winId;
let applyPath;
let instance;
let rtnValue;
let isLast;
for (;i < totalTasks; i++) {
try {
isLast = i === totalTasks - 1;
task = accessReq.$tasks$[i];
winId = task.$winId$;
applyPath = task.$applyPath$;
!winCtxs[winId] && winId.startsWith("f_") && await new Promise((resolve => {
let check = 0;
let callback = () => {
winCtxs[winId] || check++ > 1e3 ? resolve() : requestAnimationFrame(callback);
};
callback();
}));
if (1 === applyPath[0] && applyPath[1] in winCtxs[winId].$window$) {
setInstanceId(new winCtxs[winId].$window$[applyPath[1]](...deserializeFromWorker(worker, applyPath[2])), task.$instanceId$);
} else {
instance = getInstance(winId, task.$instanceId$);
if (instance) {
rtnValue = applyToInstance(worker, winId, instance, applyPath, isLast, task.$groupedGetters$);
task.$assignInstanceId$ && ("string" == typeof task.$assignInstanceId$ ? setInstanceId(rtnValue, task.$assignInstanceId$) : winCtxs[task.$assignInstanceId$.$winId$] = {
$winId$: task.$assignInstanceId$.$winId$,
$window$: {
document: rtnValue
}
});
if (isPromise(rtnValue)) {
rtnValue = await rtnValue;
isLast && (accessRsp.$isPromise$ = true);
}
isLast && (accessRsp.$rtnValue$ = serializeForWorker(winId, rtnValue, void 0, void 0, void 0, task.$instanceId$));
} else {
accessRsp.$error$ = `Error finding instance "${task.$instanceId$}" on window ${normalizedWinId(winId)}`;
console.error(accessRsp.$error$, task);
}
}
} catch (e) {
isLast ? accessRsp.$error$ = String(e.stack || e) : console.error(e);
}
}
return accessRsp;
};
const applyToInstance = (worker, winId, instance, applyPath, isLast, groupedGetters) => {
let i = 0;
let l = len(applyPath);
let next;
let current;
let previous;
let args;
let groupedRtnValues;
for (;i < l; i++) {
current = applyPath[i];
next = applyPath[i + 1];
previous = applyPath[i - 1];
try {
if (!Array.isArray(next)) {
if ("string" == typeof current || "number" == typeof current) {
if (i + 1 === l && groupedGetters) {
groupedRtnValues = {};
groupedGetters.map((propName => groupedRtnValues[propName] = instance[propName]));
return groupedRtnValues;
}
instance = instance[current];
} else {
if (0 === next) {
instance[previous] = deserializeFromWorker(worker, current);
return;
}
if ("function" == typeof instance[previous]) {
args = deserializeFromWorker(worker, current);
"define" === previous && "CustomElementRegistry" === getConstructorName(instance) && (args[1] = defineCustomElement(winId, worker, args[1]));
"insertRule" === previous && args[1] > len(instance.cssRules) && (args[1] = len(instance.cssRules));
instance = instance[previous].apply(instance, args);
if ("play" === previous) {
return Promise.resolve();
}
}
}
}
} catch (err) {
if (isLast) {
throw err;
}
console.debug("Non-blocking setter error:", err);
}
}
return instance;
};
const readNextScript = (worker, winCtx) => {
let $winId$ = winCtx.$winId$;
let win = winCtx.$window$;
let doc = win.document;
let scriptSelector = 'script[type="text/partytown"]:not([data-ptid]):not([data-pterror])';
let scriptElm;
let $instanceId$;
let scriptData;
if (doc && doc.body) {
scriptElm = doc.querySelector('script[type="text/partytown"]:not([data-ptid]):not([data-pterror]):not([async]):not([defer])');
scriptElm || (scriptElm = doc.querySelector(scriptSelector));
if (scriptElm) {
scriptElm.dataset.ptid = $instanceId$ = getAndSetInstanceId(scriptElm, $winId$);
scriptData = {
$winId$: $winId$,
$instanceId$: $instanceId$
};
if (scriptElm.src) {
scriptData.$url$ = scriptElm.src;
scriptData.$orgUrl$ = scriptElm.dataset.ptsrc || scriptElm.src;
} else {
scriptData.$content$ = scriptElm.innerHTML;
}
worker.postMessage([ 7, scriptData ]);
} else {
if (!winCtx.$isInitialized$) {
winCtx.$isInitialized$ = 1;
((worker, $winId$, win) => {
let queuedForwardCalls = win._ptf;
let forwards = (win.partytown || {}).forward || [];
let i;
let mainForwardFn;
let forwardCall = ($forward$, args) => worker.postMessage([ 10, {
$winId$: $winId$,
$forward$: $forward$,
$args$: serializeForWorker($winId$, Array.from(args))
} ]);
win._ptf = void 0;
forwards.map((forwardProps => {
mainForwardFn = win;
forwardProps.split(".").map(((_, i, arr) => {
mainForwardFn = mainForwardFn[arr[i]] = i + 1 < len(arr) ? mainForwardFn[arr[i]] || ("push" === arr[i + 1] ? [] : {}) : (...args) => forwardCall(arr, args);
}));
}));
if (queuedForwardCalls) {
for (i = 0; i < len(queuedForwardCalls); i += 2) {
forwardCall(queuedForwardCalls[i], queuedForwardCalls[i + 1]);
}
}
})(worker, $winId$, win);
doc.dispatchEvent(new CustomEvent("pt0"));
{
const winType = win === win.top ? "top" : "iframe";
logMain(`Executed ${winType} window ${normalizedWinId($winId$)} environment scripts in ${(performance.now() - winCtx.$startTime$).toFixed(1)}ms`);
}
}
worker.postMessage([ 8, $winId$ ]);
}
} else {
requestAnimationFrame((() => readNextScript(worker, winCtx)));
}
};
const registerWindow = (worker, $winId$, $window$) => {
if (!windowIds.has($window$)) {
windowIds.set($window$, $winId$);
const doc = $window$.document;
const history = $window$.history;
const $parentWinId$ = windowIds.get($window$.parent);
let initialised = false;
const onInitialisedQueue = [];
const onInitialised = callback => {
initialised ? callback() : onInitialisedQueue.push(callback);
};
const sendInitEnvData = () => {
worker.postMessage([ 5, {
$winId$: $winId$,
$parentWinId$: $parentWinId$,
$url$: doc.baseURI,
$visibilityState$: doc.visibilityState
} ]);
setTimeout((() => {
initialised = true;
onInitialisedQueue.forEach((callback => {
callback();
}));
}));
};
const pushState = history.pushState.bind(history);
const replaceState = history.replaceState.bind(history);
const onLocationChange = (type, state, newUrl, oldUrl) => () => {
setTimeout((() => {
worker.postMessage([ 13, {
$winId$: $winId$,
type: type,
state: state,
url: doc.baseURI,
newUrl: newUrl,
oldUrl: oldUrl
} ]);
}));
};
history.pushState = (state, _, newUrl) => {
pushState(state, _, newUrl);
onInitialised(onLocationChange(0, state, null == newUrl ? void 0 : newUrl.toString()));
};
history.replaceState = (state, _, newUrl) => {
replaceState(state, _, newUrl);
onInitialised(onLocationChange(1, state, null == newUrl ? void 0 : newUrl.toString()));
};
$window$.addEventListener("popstate", (event => {
onInitialised(onLocationChange(2, event.state));
}));
$window$.addEventListener("hashchange", (event => {
onInitialised(onLocationChange(3, {}, event.newURL, event.oldURL));
}));
$window$.addEventListener("ptupdate", (() => {
readNextScript(worker, winCtxs[$winId$]);
}));
doc.addEventListener("visibilitychange", (() => worker.postMessage([ 14, $winId$, doc.visibilityState ])));
winCtxs[$winId$] = {
$winId$: $winId$,
$window$: $window$
};
winCtxs[$winId$].$startTime$ = performance.now();
{
const winType = $winId$ === $parentWinId$ ? "top" : "iframe";
logMain(`Registered ${winType} window ${normalizedWinId($winId$)}`);
}
"complete" === doc.readyState ? sendInitEnvData() : $window$.addEventListener("load", sendInitEnvData);
}
};
const onMessageFromWebWorker = (worker, msg, winCtx) => {
if (4 === msg[0]) {
registerWindow(worker, randomId(), mainWindow);
} else {
winCtx = winCtxs[msg[1]];
winCtx && (7 === msg[0] ? requestAnimationFrame((() => readNextScript(worker, winCtx))) : 6 === msg[0] && ((worker, winCtx, instanceId, errorMsg, scriptElm) => {
scriptElm = winCtx.$window$.document.querySelector(`[data-ptid="${instanceId}"]`);
if (scriptElm) {
errorMsg ? scriptElm.dataset.pterror = errorMsg : scriptElm.type += "-x";
delete scriptElm.dataset.ptid;
}
readNextScript(worker, winCtx);
})(worker, winCtx, msg[2], msg[3]));
}
};
const readMainPlatform = () => {
const elm = docImpl.createElement("i");
const textNode = docImpl.createTextNode("");
const comment = docImpl.createComment("");
const frag = docImpl.createDocumentFragment();
const shadowRoot = docImpl.createElement("p").attachShadow({
mode: "open"
});
const intersectionObserver = getGlobalConstructor(mainWindow, "IntersectionObserver");
const mutationObserver = getGlobalConstructor(mainWindow, "MutationObserver");
const resizeObserver = getGlobalConstructor(mainWindow, "ResizeObserver");
const perf = mainWindow.performance;
const screen = mainWindow.screen;
const impls = [ [ mainWindow.history ], [ perf ], [ perf.navigation ], [ perf.timing ], [ screen ], [ screen.orientation ], [ mainWindow.visualViewport ], [ intersectionObserver, 12 ], [ mutationObserver, 12 ], [ resizeObserver, 12 ], [ textNode ], [ comment ], [ frag ], [ shadowRoot ], [ elm ], [ elm.attributes ], [ elm.classList ], [ elm.dataset ], [ elm.style ], [ docImpl ], [ docImpl.doctype ] ];
const initialInterfaces = [ readImplementation("Window", mainWindow), readImplementation("Node", textNode) ];
const $config$ = JSON.stringify(config, ((k, v) => {
if ("function" == typeof v) {
v = String(v);
v.startsWith(k + "(") && (v = "function " + v);
}
return v;
}));
const initWebWorkerData = {
$config$: $config$,
$interfaces$: readImplementations(impls, initialInterfaces),
$libPath$: new URL(libPath, mainWindow.location) + "",
$origin$: origin,
$localStorage$: readStorage("localStorage"),
$sessionStorage$: readStorage("sessionStorage")
};
addGlobalConstructorUsingPrototype(initWebWorkerData.$interfaces$, mainWindow, "IntersectionObserverEntry");
return initWebWorkerData;
};
const readMainInterfaces = () => {
const elms = Object.getOwnPropertyNames(mainWindow).map((interfaceName => ((doc, interfaceName, r, tag) => {
r = interfaceName.match(/^(HTML|SVG)(.+)Element$/);
if (r) {
tag = r[2];
return "S" == interfaceName[0] ? doc.createElementNS("http://www.w3.org/2000/svg", svgConstructorTags[tag] || tag.slice(0, 2).toLowerCase() + tag.slice(2)) : doc.createElement(htmlConstructorTags[tag] || tag);
}
})(docImpl, interfaceName))).filter((elm => elm)).map((elm => [ elm ]));
return readImplementations(elms, []);
};
const readImplementations = (impls, interfaces) => {
const cstrs = new Set([ "Object" ]);
const cstrImpls = impls.filter((implData => implData[0])).map((implData => {
const impl = implData[0];
const interfaceType = implData[1];
const cstrName = getConstructorName(impl);
const CstrPrototype = mainWindow[cstrName].prototype;
return [ cstrName, CstrPrototype, impl, interfaceType ];
}));
cstrImpls.map((([cstrName, CstrPrototype, impl, intefaceType]) => readOwnImplementation(cstrs, interfaces, cstrName, CstrPrototype, impl, intefaceType)));
return interfaces;
};
const readImplementation = (cstrName, impl, memberName) => {
let interfaceMembers = [];
let interfaceInfo = [ cstrName, "Object", interfaceMembers ];
for (memberName in impl) {
readImplementationMember(interfaceMembers, impl, memberName);
}
return interfaceInfo;
};
const readOwnImplementation = (cstrs, interfaces, cstrName, CstrPrototype, impl, interfaceType) => {
if (!cstrs.has(cstrName)) {
cstrs.add(cstrName);
const SuperCstr = Object.getPrototypeOf(CstrPrototype);
const superCstrName = getConstructorName(SuperCstr);
const interfaceMembers = [];
const propDescriptors = Object.getOwnPropertyDescriptors(CstrPrototype);
readOwnImplementation(cstrs, interfaces, superCstrName, SuperCstr, impl, interfaceType);
for (const memberName in propDescriptors) {
readImplementationMember(interfaceMembers, impl, memberName);
}
interfaces.push([ cstrName, superCstrName, interfaceMembers, interfaceType, getNodeName(impl) ]);
}
};
const readImplementationMember = (interfaceMembers, implementation, memberName, value, memberType, cstrName) => {
try {
if (isValidMemberName(memberName) && isNaN(memberName[0]) && "all" !== memberName) {
value = implementation[memberName];
memberType = typeof value;
if ("function" === memberType) {
(String(value).includes("[native") || Object.getPrototypeOf(implementation)[memberName]) && interfaceMembers.push([ memberName, 5 ]);
} else if ("object" === memberType && null != value) {
cstrName = getConstructorName(value);
"Object" !== cstrName && "Function" !== cstrName && self[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]);
} else {
"symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]));
}
}
} catch (e) {
console.warn(e);
}
};
const readStorage = storageName => {
let items = [];
let i = 0;
let l = len(mainWindow[storageName]);
let key;
for (;i < l; i++) {
key = mainWindow[storageName].key(i);
items.push([ key, mainWindow[storageName].getItem(key) ]);
}
return items;
};
const getGlobalConstructor = (mainWindow, cstrName) => void 0 !== mainWindow[cstrName] ? new mainWindow[cstrName](noop) : 0;
const addGlobalConstructorUsingPrototype = ($interfaces$, mainWindow, cstrName) => {
void 0 !== mainWindow[cstrName] && $interfaces$.push([ cstrName, "Object", Object.keys(mainWindow[cstrName].prototype).map((propName => [ propName, 6 ])), 12 ]);
};
let worker;
(receiveMessage => {
const swContainer = window.navigator.serviceWorker;
return swContainer.getRegistration().then((swRegistration => {
swContainer.addEventListener("message", (ev => receiveMessage(ev.data, (accessRsp => swRegistration.active && swRegistration.active.postMessage(accessRsp)))));
return (worker, msg) => {
0 === msg[0] ? worker.postMessage([ 1, readMainPlatform() ]) : 2 === msg[0] ? worker.postMessage([ 3, readMainInterfaces() ]) : onMessageFromWebWorker(worker, msg);
};
}));
})(((accessReq, responseCallback) => mainAccessHandler(worker, accessReq).then(responseCallback))).then((onMessageHandler => {
if (onMessageHandler) {
worker = new Worker(libPath + "partytown-ww-sw.js?v=0.8.1", {
name: "Partytown 🎉"
});
worker.onmessage = ev => {
const msg = ev.data;
12 === msg[0] ? mainAccessHandler(worker, msg[1]) : onMessageHandler(worker, msg);
};
logMain("Created Partytown web worker (0.8.1)");
worker.onerror = ev => console.error("Web Worker Error", ev);
mainWindow.addEventListener("pt1", (ev => registerWindow(worker, getAndSetInstanceId(ev.detail.frameElement), ev.detail)));
}
}));
})(window);
+59
View File
@@ -0,0 +1,59 @@
/* Partytown 0.8.1 - MIT builder.io */
const resolves = new Map;
const swMessageError = (accessReq, $error$) => ({
$msgId$: accessReq.$msgId$,
$error$: $error$
});
const httpRequestFromWebWorker = req => new Promise((async resolve => {
const accessReq = await req.clone().json();
const responseData = await (accessReq => new Promise((async resolve => {
const clients = await self.clients.matchAll();
const client = [ ...clients ].sort(((a, b) => a.url > b.url ? -1 : a.url < b.url ? 1 : 0))[0];
if (client) {
const timeout = 12e4;
const msgResolve = [ resolve, setTimeout((() => {
resolves.delete(accessReq.$msgId$);
resolve(swMessageError(accessReq, "Timeout"));
}), timeout) ];
resolves.set(accessReq.$msgId$, msgResolve);
client.postMessage(accessReq);
} else {
resolve(swMessageError(accessReq, "NoParty"));
}
})))(accessReq);
resolve(response(JSON.stringify(responseData), "application/json"));
}));
const response = (body, contentType) => new Response(body, {
headers: {
"content-type": contentType || "text/html",
"Cache-Control": "no-store"
}
});
self.oninstall = () => self.skipWaiting();
self.onactivate = () => self.clients.claim();
self.onmessage = ev => {
const accessRsp = ev.data;
const r = resolves.get(accessRsp.$msgId$);
if (r) {
resolves.delete(accessRsp.$msgId$);
clearTimeout(r[1]);
r[0](accessRsp);
}
};
self.onfetch = ev => {
const req = ev.request;
const url = new URL(req.url);
const pathname = url.pathname;
if (pathname.endsWith("sw.html")) {
ev.respondWith(response('<!DOCTYPE html><html><head><meta charset="utf-8"><script src="./partytown-sandbox-sw.js?v=0.8.1"><\/script></head></html>'));
} else {
pathname.endsWith("proxytown") && ev.respondWith(httpRequestFromWebWorker(req));
}
};
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+80
View File
@@ -0,0 +1,80 @@
/* Partytown 0.8.1 - MIT builder.io */
!function(win, doc, nav, top, useAtomics, config, libPath, timeout, scripts, sandbox, mainForwardFn, isReady) {
function ready() {
if (!isReady) {
isReady = 1;
libPath = (config.lib || "/~partytown/") + (false !== config.debug ? "debug/" : "");
if ("/" == libPath[0]) {
scripts = doc.querySelectorAll('script[type="text/partytown"]');
if (top != win) {
top.dispatchEvent(new CustomEvent("pt1", {
detail: win
}));
} else {
timeout = setTimeout(fallback, 1e4);
doc.addEventListener("pt0", clearFallback);
useAtomics ? loadSandbox(1) : nav.serviceWorker ? nav.serviceWorker.register(libPath + (config.swPath || "partytown-sw.js"), {
scope: libPath
}).then((function(swRegistration) {
if (swRegistration.active) {
loadSandbox();
} else if (swRegistration.installing) {
swRegistration.installing.addEventListener("statechange", (function(ev) {
"activated" == ev.target.state && loadSandbox();
}));
} else {
console.warn(swRegistration);
}
}), console.error) : fallback();
}
} else {
console.warn('Partytown config.lib url must start with "/"');
}
}
}
function loadSandbox(isAtomics) {
sandbox = doc.createElement(isAtomics ? "script" : "iframe");
if (!isAtomics) {
sandbox.style.display = "block";
sandbox.style.width = "0";
sandbox.style.height = "0";
sandbox.style.border = "0";
sandbox.style.visibility = "hidden";
sandbox.setAttribute("aria-hidden", !0);
}
sandbox.src = libPath + "partytown-" + (isAtomics ? "atomics.js?v=0.8.1" : "sandbox-sw.html?" + Date.now());
doc.querySelector(config.sandboxParent || "body").appendChild(sandbox);
}
function fallback(i, script) {
console.warn("Partytown script fallback");
clearFallback();
top == win && (config.forward || []).map((function(forwardProps) {
delete win[forwardProps.split(".")[0]];
}));
for (i = 0; i < scripts.length; i++) {
script = doc.createElement("script");
script.innerHTML = scripts[i].innerHTML;
script.nonce = config.nonce;
doc.head.appendChild(script);
}
sandbox && sandbox.parentNode.removeChild(sandbox);
}
function clearFallback() {
clearTimeout(timeout);
}
config = win.partytown || {};
top == win && (config.forward || []).map((function(forwardProps) {
mainForwardFn = win;
forwardProps.split(".").map((function(_, i, forwardPropsArr) {
mainForwardFn = mainForwardFn[forwardPropsArr[i]] = i + 1 < forwardPropsArr.length ? "push" == forwardPropsArr[i + 1] ? [] : mainForwardFn[forwardPropsArr[i]] || {} : function() {
(win._ptf = win._ptf || []).push(forwardPropsArr, arguments);
};
}));
}));
if ("complete" == doc.readyState) {
ready();
} else {
win.addEventListener("DOMContentLoaded", ready);
win.addEventListener("load", ready);
}
}(window, document, navigator, top, window.crossOriginIsolated);
+2
View File
@@ -0,0 +1,2 @@
/* Partytown 0.8.1 - MIT builder.io */
(e=>{const t=()=>{},r=e=>e.length,n=e=>{var t,r,n;try{const r=null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name;if(r)return r}catch(e){}try{const t=null===(n=null===(r=null==e?void 0:e.__zone_symbol__originalInstance)||void 0===r?void 0:r.constructor)||void 0===n?void 0:n.name;if(t)return t}catch(e){}return""},i=(e,t)=>e.startsWith(t),s=e=>!(i(e,"webkit")||i(e,"toJSON")||i(e,"constructor")||i(e,"toString")||i(e,"_")),o=e=>11===e.nodeType&&e.host?"#s":e.nodeName,a=()=>Math.round(Math.random()*Number.MAX_SAFE_INTEGER).toString(36),l={Anchor:"a",DList:"dl",Image:"img",OList:"ol",Paragraph:"p",Quote:"q",TableCaption:"caption",TableCell:"td",TableCol:"colgroup",TableRow:"tr",TableSection:"tbody",UList:"ul"},c={Graphics:"g",SVG:"svg"},u=Symbol(),d=Symbol(),h=new Map,p=new Map,m={},g=new WeakMap,f=(e,t)=>{if(e)return(t=g.get(e))||(t=e[u])||v(e,t=a()),t},y=(e,t,r,n,i)=>{if((r=m[e])&&r.U){if(e===t)return r.U;if(n=r.U.document,"d"===(i=t.split(".").pop()))return n;if("e"===i)return n.documentElement;if("h"===i)return n.head;if("b"===i)return n.body}return h.get(t)},v=(e,t,r)=>{e&&(h.set(t,e),e[u]=t,e[d]=r=Date.now(),r>w+5e3&&(h.forEach(((e,t)=>{e[d]<w&&e.nodeType&&!e.isConnected&&h.delete(t)})),w=r))};let w=0;const $=e.parent,S=document.implementation.createHTMLDocument(),b=$.partytown||{},E=(b.lib||"/~partytown/")+"",T=(e,t,r)=>{const n=((e,t)=>{return r=e,n={value:t},Object.defineProperty(r,"name",{...n,configurable:!0});var r,n})(class extends m[e].U.HTMLElement{},r[0]);return"connectedCallback,disconnectedCallback,attributeChangedCallback,adoptedCallback".split(",").map((r=>n.prototype[r]=function(...n){t.postMessage([15,e,f(this),r,n])})),n.observedAttributes=r[1],n},I=(e,t,r,s,a,l)=>void 0!==t&&(s=typeof t)?"string"===s||"number"===s||"boolean"===s||null==t?[0,t]:"function"===s?[6]:(r=r||new Set)&&Array.isArray(t)?r.has(t)?[1,[]]:r.add(t)&&[1,t.map((t=>I(e,t,r)))]:"object"===s?N(t)?[14,{name:t.name,message:t.message,stack:t.stack}]:""===(a=n(t))?[2,{}]:"Window"===a?[3,[e,e]]:"HTMLCollection"===a||"NodeList"===a?[7,Array.from(t).map((t=>I(e,t,r)[1]))]:a.endsWith("Event")?[5,M(e,t,r)]:"CSSRuleList"===a?[12,Array.from(t).map(x)]:i(a,"CSS")&&a.endsWith("Rule")?[11,x(t)]:"CSSStyleDeclaration"===a?[13,M(e,t,r)]:"Attr"===a?[10,[t.name,t.value]]:t.nodeType?[3,[e,f(t),o(t),l]]:[2,M(e,t,r,!0,!0)]:void 0:t,M=(e,t,r,i,o,a,l,c)=>{if(a={},!r.has(t))for(l in r.add(t),t)s(l)&&(c="path"===l&&n(t).endsWith("Event")?t.composedPath():t[l],(i||"function"!=typeof c)&&(o||""!==c)&&(a[l]=I(e,c,r)));return a},x=e=>{let t,r={};for(t in e)W.includes(t)&&(r[t]=String(e[t]));return r},N=t=>t instanceof e.top.Error,L=(t,r,n,i)=>r?(n=r[0],i=r[1],0===n?i:4===n?C(t,i):1===n?i.map((e=>L(t,e))):3===n?y(i[0],i[1]):5===n?R(A(t,i)):2===n?A(t,i):8===n?i:9===n?new e[r[2]](i):void 0):void 0,C=(e,{V:t,w:r,L:n},i)=>((i=p.get(n))||(i=function(...i){e.postMessage([9,{V:t,w:r,L:n,R:I(t,this),b:I(t,i)}])},p.set(n,i)),i),R=e=>new("detail"in e?CustomEvent:Event)(e.type,e),A=(e,t,r,n)=>{for(n in r={},t)r[n]=L(e,t[n]);return r},W="cssText,selectorText,href,media,namespaceURI,prefix,name,conditionText".split(","),U=async(e,t)=>{let n,i,s,o,a,l,c={F:t.F},u=r(t.Q),d=0;for(;d<u;d++)try{l=d===u-1,n=t.Q[d],i=n.V,s=n.a,!m[i]&&i.startsWith("f_")&&await new Promise((e=>{let t=0,r=()=>{m[i]||t++>1e3?e():requestAnimationFrame(r)};r()})),1===s[0]&&s[1]in m[i].U?v(new m[i].U[s[1]](...L(e,s[2])),n.w):(o=y(i,n.w),o?(a=P(e,i,o,s,l,n.r),n.d&&("string"==typeof n.d?v(a,n.d):m[n.d.V]={V:n.d.V,U:{document:a}}),"object"==typeof(h=a)&&h&&h.then&&(a=await a,l&&(c.z=!0)),l&&(c.M=I(i,a,void 0,void 0,void 0,n.w))):c.p=n.w+" not found")}catch(e){l?c.p=String(e.stack||e):console.error(e)}var h;return c},P=(e,t,i,s,o,a)=>{let l,c,u,d,h,p=0,m=r(s);for(;p<m;p++){c=s[p],l=s[p+1],u=s[p-1];try{if(!Array.isArray(l))if("string"==typeof c||"number"==typeof c){if(p+1===m&&a)return h={},a.map((e=>h[e]=i[e])),h;i=i[c]}else{if(0===l)return void(i[u]=L(e,c));if("function"==typeof i[u]&&(d=L(e,c),"define"===u&&"CustomElementRegistry"===n(i)&&(d[1]=T(t,e,d[1])),"insertRule"===u&&d[1]>r(i.cssRules)&&(d[1]=r(i.cssRules)),i=i[u].apply(i,d),"play"===u))return Promise.resolve()}}catch(e){if(o)throw e;console.debug(e)}}return i},j=(e,t)=>{let n,i,s,o=t.V,a=t.U,l=a.document;l&&l.body?(n=l.querySelector('script[type="text/partytown"]:not([data-ptid]):not([data-pterror]):not([async]):not([defer])'),n||(n=l.querySelector('script[type="text/partytown"]:not([data-ptid]):not([data-pterror])')),n?(n.dataset.ptid=i=f(n,o),s={V:o,w:i},n.src?(s.S=n.src,s.H=n.dataset.ptsrc||n.src):s.j=n.innerHTML,e.postMessage([7,s])):(t.x||(t.x=1,((e,t,n)=>{let i,s,o=n._ptf,a=(n.partytown||{}).forward||[],l=(r,n)=>e.postMessage([10,{V:t,q:r,b:I(t,Array.from(n))}]);if(n._ptf=void 0,a.map((e=>{s=n,e.split(".").map(((e,t,n)=>{s=s[n[t]]=t+1<r(n)?s[n[t]]||("push"===n[t+1]?[]:{}):(...e)=>l(n,e)}))})),o)for(i=0;i<r(o);i+=2)l(o[i],o[i+1])})(e,o,a),l.dispatchEvent(new CustomEvent("pt0"))),e.postMessage([8,o]))):requestAnimationFraLine truncated
+2
View File
@@ -0,0 +1,2 @@
/* Partytown 0.8.1 - MIT builder.io */
(e=>{const[t,s,n,r,i,a,o,d,u]=e.g;delete e.g;const c=Symbol(),h=Symbol(),f=Symbol(),p=Symbol(),g=Symbol(),l=Symbol(),m=[],v=(e,t,s)=>e[t]=S(t,s),S=(e,t)=>Object.defineProperty(t,"name",{value:e}),b=(e,t)=>{const r={getContext:{value(e,t){return this[c]||(this[c]=(e.includes("webgl")?g:p)(this,e,t)),this[c]}}},h=v(t,"CanvasGradient",class extends e{addColorStop(...e){n(this,["addColorStop"],e,2)}}),f=v(t,"CanvasPattern",class extends e{setTransform(...e){n(this,["setTransform"],e,2)}}),p=(e,t,r)=>{const i=e[o],c=a(),f={[o]:i,[d]:c,[u]:[]},p=n(e,["getContext"],[t,r],1,c),g="getContextAttributes,getImageData,getLineDash,getTransform,isPointInPath,isPointInStroke,measureText".split(","),l={get:(e,t)=>"string"==typeof t&&t in p?"function"==typeof p[t]?(...e)=>{if(t.startsWith("create")){const r=a();return n(f,[t],e,2,r),"createImageData"===t||"createPattern"===t?(s=`${t}()`,console.warn(`${s} not implemented`),{setTransform:()=>{}}):new h(i,r)}var s;const r=g.includes(t)?1:2;return n(f,[t],e,r)}:p[t]:e[t],set:(e,t,n)=>("string"==typeof t&&t in p?(p[t]!==n&&"function"!=typeof n&&s(f,[t],n),p[t]=n):e[t]=n,!0)};return new Proxy(p,l)},g=(e,t,r)=>{const i=e[o],c=a(),h={[o]:i,[d]:c,[u]:[]},f=n(e,["getContext"],[t,r],1,c),p={get:(e,t)=>"string"==typeof t?"function"!=typeof f[t]?f[t]:(...e)=>n(h,[t],e,m(t)):e[t],set:(e,t,n)=>("string"==typeof t&&t in f?(f[t]!==n&&"function"!=typeof n&&s(h,[t],n),f[t]=n):e[t]=n,!0)};return new Proxy(f,p)},l="checkFramebufferStatus,makeXRCompatible".split(","),m=e=>e.startsWith("create")||e.startsWith("get")||e.startsWith("is")||l.includes(e)?1:2;v(t,"CanvasGradient",h),v(t,"CanvasPattern",f),i(t.HTMLCanvasElement,r)},y=(e,u,c,b)=>{var y,T;b.Audio=S("HTMLAudioElement",class{constructor(e){const t=c.k("audio",a());return t.src=e,t}});const w=class extends e{get enabled(){return t(this,["enabled"])}set enabled(e){s(this,["enabled"],e)}get id(){return t(this,["id"])}get kind(){return t(this,["kind"])}get label(){return t(this,["label"])}get language(){return t(this,["language"])}get sourceBuffer(){return new x(this)}},E=class{constructor(e){const s="audioTracks",r=e[o],i=e[d];return new Proxy({addEventListener(...t){n(e,[s,"addEventListener"],t,3)},getTrackById:(...t)=>n(e,[s,"getTrackById"],t),get length(){return t(e,[s,"length"])},removeEventListener(...t){n(e,[s,"removeEventListener"],t,3)}},{get:(e,t)=>"number"==typeof t?new w(r,i,[s,t]):e[t]})}},k=v(b,"SourceBufferList",class extends Array{constructor(e){super(),this[h]=e}addEventListener(...e){n(this[h],["sourceBuffers","addEventListener"],e,3)}removeEventListener(...e){n(this[h],["sourceBuffers","removeEventListener"],e,3)}}),x=v(b,"SourceBuffer",(T=class extends u{constructor(e){super(e[o],e[d],["sourceBuffers"]),this[y]=[],this[h]=e}abort(){const e=R(this);n(this,[e,"appendWindowStart"],m,1)}addEventListener(...e){const t=R(this);n(this,[t,"addEventListener"],e,3)}appendBuffer(e){this[g].push(["appendBuffer",[e],e]),M(this)}get appendWindowStart(){const e=R(this);return t(this,[e,"appendWindowStart"])}set appendWindowStart(e){const t=R(this);s(this,[t,"appendWindowStart"],e)}get appendWindowEnd(){const e=R(this);return t(this,[e,"appendWindowEnd"])}set appendWindowEnd(e){const t=R(this);s(this,[t,"appendWindowEnd"],e)}get buffered(){const e=this[h],t=R(this);return new B(e[o],e[d],["sourceBuffers",t,"buffered"])}changeType(e){const t=R(this);n(this,[t,"changeType"],[e],2)}get mode(){const e=R(this);return t(this,[e,"mode"])}set mode(e){const t=R(this);s(this,[t,"mode"],e)}remove(e,t){this[g].push(["remove",[e,t]]),M(this)}removeEventListener(...e){const t=R(this);n(this,[t,"removeEventListener"],e,3)}get timestampOffset(){const e=R(this);return t(this,[e,"timestampOffset"])}set timestampOffset(e){const t=R(this);s(this,[t,"timestampOffset"],e)}get updating(){const e=R(this);return t(this,[e,"updating"])}},y=g,T)),B=v(b,"TimeRanges",class extends e{start(...e){return n(this,["start"],e)}end(...e){return n(this,["end"],e)}get length(){return t(this,["length"])}}),R=e=>e?e[h][p].indexOf(e):-1,M=e=>{if(e[g].length){if(!e.updating){const t=e[g].shift();if(t){const s=R(e);n(e,[s,t[0]],t[1],3,void 0,t[2])}}setTimeout((()=>M(e)),50)}},W={buffered:{get(){return this[l]||(this[l]=new B(this[o],this[d],["buffered"]),setTimeout((()=>{this[l]=void 0}),5e3)),this[l]}},readyState:{get(){return 4===this[f]?4:("number"!=typeof this[f]&&(this[f]=t(this,["readyState"]),setTimeout((()=>{this[f]=void 0}),1e3)),this[f])}}};v(b,"MediaSource",class extends u{constructor(){super(c.V),this[p]=new k(this),r(this,"MediaSource",m)}get activeSourceBuffers(){return[]}addSourceBuffer(e){const t=new x(this);return this[p].push(t),n(this,["addSourceBuffer"],[e]),t}clearLiveSeekableRange(){n(this,["clearLiveSeekableRange"],m,2)}get duration(){return t(this,["duration"])}set duration(e){s(this,["duration"],e)}endOfStream(e){n(this,["endOfStream"],[e],3)}get readyState(){return t(this,["readyState"])}removeSourceBuffer(e){const t=R(e);t>-1&&(this[p].splice(t,1),n(thisLine truncated
+2
View File
@@ -0,0 +1,2 @@
/* Partytown 0.8.1 - MIT builder.io */
const e=new Map,t=(e,t)=>({F:e.F,p:t}),r=(e,t)=>new Response(e,{headers:{"content-type":t||"text/html","Cache-Control":"no-store"}});self.oninstall=()=>self.skipWaiting(),self.onactivate=()=>self.clients.claim(),self.onmessage=t=>{const r=t.data,n=e.get(r.F);n&&(e.delete(r.F),clearTimeout(n[1]),n[0](r))},self.onfetch=n=>{const i=n.request,s=new URL(i.url).pathname;s.endsWith("sw.html")?n.respondWith(r('<!DOCTYPE html><html><head><meta charset="utf-8"><script type="module">/* Partytown 0.8.1 - MIT builder.io */\n(e=>{const t=()=>{},r=e=>e.length,n=e=>{var t,r,n;try{const r=null===(t=null==e?void 0:e.constructor)||void 0===t?void 0:t.name;if(r)return r}catch(e){}try{const t=null===(n=null===(r=null==e?void 0:e.__zone_symbol__originalInstance)||void 0===r?void 0:r.constructor)||void 0===n?void 0:n.name;if(t)return t}catch(e){}return""},i=(e,t)=>e.startsWith(t),s=e=>!(i(e,"webkit")||i(e,"toJSON")||i(e,"constructor")||i(e,"toString")||i(e,"_")),o=e=>11===e.nodeType&&e.host?"#s":e.nodeName,a=()=>Math.round(Math.random()*Number.MAX_SAFE_INTEGER).toString(36),l={Anchor:"a",DList:"dl",Image:"img",OList:"ol",Paragraph:"p",Quote:"q",TableCaption:"caption",TableCell:"td",TableCol:"colgroup",TableRow:"tr",TableSection:"tbody",UList:"ul"},c={Graphics:"g",SVG:"svg"},u=Symbol(),d=Symbol(),h=new Map,p=new Map,m={},g=new WeakMap,f=(e,t)=>{if(e)return(t=g.get(e))||(t=e[u])||v(e,t=a()),t},y=(e,t,r,n,i)=>{if((r=m[e])&&r.U){if(e===t)return r.U;if(n=r.U.document,"d"===(i=t.split(".").pop()))return n;if("e"===i)return n.documentElement;if("h"===i)return n.head;if("b"===i)return n.body}return h.get(t)},v=(e,t,r)=>{e&&(h.set(t,e),e[u]=t,e[d]=r=Date.now(),r>w+5e3&&(h.forEach(((e,t)=>{e[d]<w&&e.nodeType&&!e.isConnected&&h.delete(t)})),w=r))};let w=0;const $=e.parent,S=document.implementation.createHTMLDocument(),b=$.partytown||{},E=(b.lib||"/~partytown/")+"",T=(e,t,r)=>{const n=((e,t)=>{return r=e,n={value:t},Object.defineProperty(r,"name",{...n,configurable:!0});var r,n})(class extends m[e].U.HTMLElement{},r[0]);return"connectedCallback,disconnectedCallback,attributeChangedCallback,adoptedCallback".split(",").map((r=>n.prototype[r]=function(...n){t.postMessage([15,e,f(this),r,n])})),n.observedAttributes=r[1],n},I=(e,t,r,s,a,l)=>void 0!==t&&(s=typeof t)?"string"===s||"number"===s||"boolean"===s||null==t?[0,t]:"function"===s?[6]:(r=r||new Set)&&Array.isArray(t)?r.has(t)?[1,[]]:r.add(t)&&[1,t.map((t=>I(e,t,r)))]:"object"===s?N(t)?[14,{name:t.name,message:t.message,stack:t.stack}]:""===(a=n(t))?[2,{}]:"Window"===a?[3,[e,e]]:"HTMLCollection"===a||"NodeList"===a?[7,Array.from(t).map((t=>I(e,t,r)[1]))]:a.endsWith("Event")?[5,M(e,t,r)]:"CSSRuleList"===a?[12,Array.from(t).map(x)]:i(a,"CSS")&&a.endsWith("Rule")?[11,x(t)]:"CSSStyleDeclaration"===a?[13,M(e,t,r)]:"Attr"===a?[10,[t.name,t.value]]:t.nodeType?[3,[e,f(t),o(t),l]]:[2,M(e,t,r,!0,!0)]:void 0:t,M=(e,t,r,i,o,a,l,c)=>{if(a={},!r.has(t))for(l in r.add(t),t)s(l)&&(c="path"===l&&n(t).endsWith("Event")?t.composedPath():t[l],(i||"function"!=typeof c)&&(o||""!==c)&&(a[l]=I(e,c,r)));return a},x=e=>{let t,r={};for(t in e)A.includes(t)&&(r[t]=String(e[t]));return r},N=t=>t instanceof e.top.Error,L=(t,r,n,i)=>r?(n=r[0],i=r[1],0===n?i:4===n?C(t,i):1===n?i.map((e=>L(t,e))):3===n?y(i[0],i[1]):5===n?R(W(t,i)):2===n?W(t,i):8===n?i:9===n?new e[r[2]](i):void 0):void 0,C=(e,{V:t,w:r,L:n},i)=>((i=p.get(n))||(i=function(...i){e.postMessage([9,{V:t,w:r,L:n,R:I(t,this),b:I(t,i)}])},p.set(n,i)),i),R=e=>new("detail"in e?CustomEvent:Event)(e.type,e),W=(e,t,r,n)=>{for(n in r={},t)r[n]=L(e,t[n]);return r},A="cssText,selectorText,href,media,namespaceURI,prefix,name,conditionText".split(","),U=async(e,t)=>{let n,i,s,o,a,l,c={F:t.F},u=r(t.Q),d=0;for(;d<u;d++)try{l=d===u-1,n=t.Q[d],i=n.V,s=n.a,!m[i]&&i.startsWith("f_")&&await new Promise((e=>{let t=0,r=()=>{m[i]||t++>1e3?e():requestAnimationFrame(r)};r()})),1===s[0]&&s[1]in m[i].U?v(new m[i].U[s[1]](...L(e,s[2])),n.w):(o=y(i,n.w),o?(a=P(e,i,o,s,l,n.r),n.d&&("string"==typeof n.d?v(a,n.d):m[n.d.V]={V:n.d.V,U:{document:a}}),"object"==typeof(h=a)&&h&&h.then&&(a=await a,l&&(c.z=!0)),l&&(c.M=I(i,a,void 0,void 0,void 0,n.w))):c.p=n.w+" not found")}catch(e){l?c.p=String(e.stack||e):console.error(e)}var h;return c},P=(e,t,i,s,o,a)=>{let l,c,u,d,h,p=0,m=r(s);for(;p<m;p++){c=s[p],l=s[p+1],u=s[p-1];try{if(!Array.isArray(l))if("string"==typeof c||"number"==typeof c){if(p+1===m&&a)return h={},a.map((e=>h[e]=i[e])),h;i=i[c]}else{if(0===l)return void(i[u]=L(e,c));if("function"==typeof i[u]&&(d=L(e,c),"define"===u&&"CustomElementRegistry"===n(i)&&(d[1]=T(t,e,d[1])),"insertRule"===u&&d[1]>r(i.cssRules)&&(d[1]=r(i.cssRules)),i=i[u].apply(i,d),"play"===u))return Promise.resolve()}}catch(e){if(o)throw e;console.debug(e)}}return i},j=(e,t)=>{let n,i,s,o=t.V,a=t.U,l=a.document;l&&l.body?(n=l.querySelector(\'script[type="text/partytown"]:not([data-ptid]):not([data-pterror]):not([async]):not([defer])\'),n||(n=l.querySelector(\'script[type="text/partytown"]:not([data-ptid]):not([data-pterror])\Line truncated
+2
View File
@@ -0,0 +1,2 @@
/* Partytown 0.8.1 - MIT builder.io */
!function(t,e,n,i,o,r,a,s,d,c,l,p){function u(){p||(p=1,"/"==(a=(r.lib||"/~partytown/")+(r.debug?"debug/":""))[0]&&(d=e.querySelectorAll('script[type="text/partytown"]'),i!=t?i.dispatchEvent(new CustomEvent("pt1",{detail:t})):(s=setTimeout(f,1e4),e.addEventListener("pt0",w),o?h(1):n.serviceWorker?n.serviceWorker.register(a+(r.swPath||"partytown-sw.js"),{scope:a}).then((function(t){t.active?h():t.installing&&t.installing.addEventListener("statechange",(function(t){"activated"==t.target.state&&h()}))}),console.error):f())))}function h(t){c=e.createElement(t?"script":"iframe"),t||(c.style.display="block",c.style.width="0",c.style.height="0",c.style.border="0",c.style.visibility="hidden",c.setAttribute("aria-hidden",!0)),c.src=a+"partytown-"+(t?"atomics.js?v=0.8.1":"sandbox-sw.html?"+Date.now()),e.querySelector(r.sandboxParent||"body").appendChild(c)}function f(n,o){for(w(),i==t&&(r.forward||[]).map((function(e){delete t[e.split(".")[0]]})),n=0;n<d.length;n++)(o=e.createElement("script")).innerHTML=d[n].innerHTML,o.nonce=r.nonce,e.head.appendChild(o);c&&c.parentNode.removeChild(c)}function w(){clearTimeout(s)}r=t.partytown||{},i==t&&(r.forward||[]).map((function(e){l=t,e.split(".").map((function(e,n,i){l=l[i[n]]=n+1<i.length?"push"==i[n+1]?[]:l[i[n]]||{}:function(){(t._ptf=t._ptf||[]).push(i,arguments)}}))})),"complete"==e.readyState?u():(t.addEventListener("DOMContentLoaded",u),t.addEventListener("load",u))}(window,document,navigator,top,window.crossOriginIsolated);