appscms-tools-theme 3.1.8 → 3.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,559 @@
1
+ /* Partytown 0.7.5 - MIT builder.io */
2
+ (window => {
3
+ const isPromise = v => "object" == typeof v && v && v.then;
4
+ const noop = () => {};
5
+ const len = obj => obj.length;
6
+ const getConstructorName = obj => {
7
+ var _a, _b, _c;
8
+ try {
9
+ const constructorName = null === (_a = null == obj ? void 0 : obj.constructor) || void 0 === _a ? void 0 : _a.name;
10
+ if (constructorName) {
11
+ return constructorName;
12
+ }
13
+ } catch (e) {}
14
+ try {
15
+ 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;
16
+ if (zoneJsConstructorName) {
17
+ return zoneJsConstructorName;
18
+ }
19
+ } catch (e) {}
20
+ return "";
21
+ };
22
+ const startsWith = (str, val) => str.startsWith(val);
23
+ const isValidMemberName = memberName => !(startsWith(memberName, "webkit") || startsWith(memberName, "toJSON") || startsWith(memberName, "constructor") || startsWith(memberName, "toString") || startsWith(memberName, "_"));
24
+ const getNodeName = node => 11 === node.nodeType && node.host ? "#s" : node.nodeName;
25
+ const randomId = () => Math.round(Math.random() * Number.MAX_SAFE_INTEGER).toString(36);
26
+ const defineConstructorName = (Cstr, value) => ((obj, memberName, descriptor) => Object.defineProperty(obj, memberName, {
27
+ ...descriptor,
28
+ configurable: true
29
+ }))(Cstr, "name", {
30
+ value: value
31
+ });
32
+ const htmlConstructorTags = {
33
+ Anchor: "a",
34
+ DList: "dl",
35
+ Image: "img",
36
+ OList: "ol",
37
+ Paragraph: "p",
38
+ Quote: "q",
39
+ TableCaption: "caption",
40
+ TableCell: "td",
41
+ TableCol: "colgroup",
42
+ TableRow: "tr",
43
+ TableSection: "tbody",
44
+ UList: "ul"
45
+ };
46
+ const svgConstructorTags = {
47
+ Graphics: "g",
48
+ SVG: "svg"
49
+ };
50
+ const InstanceIdKey = Symbol();
51
+ const CreatedKey = Symbol();
52
+ const instances = new Map;
53
+ const mainRefs = new Map;
54
+ const winCtxs = {};
55
+ const windowIds = new WeakMap;
56
+ const getAndSetInstanceId = (instance, instanceId) => {
57
+ if (instance) {
58
+ if (instanceId = windowIds.get(instance)) {
59
+ return instanceId;
60
+ }
61
+ (instanceId = instance[InstanceIdKey]) || setInstanceId(instance, instanceId = randomId());
62
+ return instanceId;
63
+ }
64
+ };
65
+ const getInstance = (winId, instanceId, win, doc, docId) => {
66
+ if ((win = winCtxs[winId]) && win.$window$) {
67
+ if (winId === instanceId) {
68
+ return win.$window$;
69
+ }
70
+ doc = win.$window$.document;
71
+ docId = instanceId.split(".").pop();
72
+ if ("d" === docId) {
73
+ return doc;
74
+ }
75
+ if ("e" === docId) {
76
+ return doc.documentElement;
77
+ }
78
+ if ("h" === docId) {
79
+ return doc.head;
80
+ }
81
+ if ("b" === docId) {
82
+ return doc.body;
83
+ }
84
+ }
85
+ return instances.get(instanceId);
86
+ };
87
+ const setInstanceId = (instance, instanceId, now) => {
88
+ if (instance) {
89
+ instances.set(instanceId, instance);
90
+ instance[InstanceIdKey] = instanceId;
91
+ instance[CreatedKey] = now = Date.now();
92
+ if (now > lastCleanup + 5e3) {
93
+ instances.forEach(((storedInstance, instanceId) => {
94
+ storedInstance[CreatedKey] < lastCleanup && storedInstance.nodeType && !storedInstance.isConnected && instances.delete(instanceId);
95
+ }));
96
+ lastCleanup = now;
97
+ }
98
+ }
99
+ };
100
+ let lastCleanup = 0;
101
+ const mainWindow = window.parent;
102
+ const docImpl = document.implementation.createHTMLDocument();
103
+ const config = mainWindow.partytown || {};
104
+ const libPath = (config.lib || "/~partytown/") + "debug/";
105
+ const logMain = msg => {
106
+ console.debug.apply(console, [ "%cMain 🌎", "background: #717171; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;", msg ]);
107
+ };
108
+ const winIds = [];
109
+ const normalizedWinId = winId => {
110
+ winIds.includes(winId) || winIds.push(winId);
111
+ return winIds.indexOf(winId) + 1;
112
+ };
113
+ const defineCustomElement = (winId, worker, ceData) => {
114
+ const Cstr = defineConstructorName(class extends winCtxs[winId].$window$.HTMLElement {}, ceData[0]);
115
+ const ceCallbackMethods = "connectedCallback,disconnectedCallback,attributeChangedCallback,adoptedCallback".split(",");
116
+ ceCallbackMethods.map((callbackMethodName => Cstr.prototype[callbackMethodName] = function(...args) {
117
+ worker.postMessage([ 15, winId, getAndSetInstanceId(this), callbackMethodName, args ]);
118
+ }));
119
+ Cstr.observedAttributes = ceData[1];
120
+ return Cstr;
121
+ };
122
+ const serializeForWorker = ($winId$, value, added, type, cstrName) => 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, {
123
+ name: value.name,
124
+ message: value.message,
125
+ stack: value.stack
126
+ } ] : "" === (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) ] ] : [ 2, serializeObjectForWorker($winId$, value, added, true, true) ] : void 0 : value;
127
+ const serializeObjectForWorker = (winId, obj, added, includeFunctions, includeEmptyStrings, serializedObj, propName, propValue) => {
128
+ serializedObj = {};
129
+ if (!added.has(obj)) {
130
+ added.add(obj);
131
+ for (propName in obj) {
132
+ if (isValidMemberName(propName)) {
133
+ propValue = "path" === propName && getConstructorName(obj).endsWith("Event") ? obj.composedPath() : obj[propName];
134
+ (includeFunctions || "function" != typeof propValue) && (includeEmptyStrings || "" !== propValue) && (serializedObj[propName] = serializeForWorker(winId, propValue, added));
135
+ }
136
+ }
137
+ }
138
+ return serializedObj;
139
+ };
140
+ const serializeCssRuleForWorker = cssRule => {
141
+ let obj = {};
142
+ let key;
143
+ for (key in cssRule) {
144
+ validCssRuleProps.includes(key) && (obj[key] = String(cssRule[key]));
145
+ }
146
+ return obj;
147
+ };
148
+ const serializedValueIsError = value => value instanceof window.top.Error;
149
+ const deserializeFromWorker = (worker, serializedTransfer, serializedType, serializedValue) => {
150
+ if (serializedTransfer) {
151
+ serializedType = serializedTransfer[0];
152
+ serializedValue = serializedTransfer[1];
153
+ 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;
154
+ }
155
+ };
156
+ const deserializeRefFromWorker = (worker, {$winId$: $winId$, $instanceId$: $instanceId$, $refId$: $refId$}, ref) => {
157
+ ref = mainRefs.get($refId$);
158
+ if (!ref) {
159
+ ref = function(...args) {
160
+ worker.postMessage([ 9, {
161
+ $winId$: $winId$,
162
+ $instanceId$: $instanceId$,
163
+ $refId$: $refId$,
164
+ $thisArg$: serializeForWorker($winId$, this),
165
+ $args$: serializeForWorker($winId$, args)
166
+ } ]);
167
+ };
168
+ mainRefs.set($refId$, ref);
169
+ }
170
+ return ref;
171
+ };
172
+ const constructEvent = eventProps => new ("detail" in eventProps ? CustomEvent : Event)(eventProps.type, eventProps);
173
+ const deserializeObjectFromWorker = (worker, serializedValue, obj, key) => {
174
+ obj = {};
175
+ for (key in serializedValue) {
176
+ obj[key] = deserializeFromWorker(worker, serializedValue[key]);
177
+ }
178
+ return obj;
179
+ };
180
+ const validCssRuleProps = "cssText,selectorText,href,media,namespaceURI,prefix,name,conditionText".split(",");
181
+ const mainAccessHandler = async (worker, accessReq) => {
182
+ let accessRsp = {
183
+ $msgId$: accessReq.$msgId$
184
+ };
185
+ let totalTasks = len(accessReq.$tasks$);
186
+ let i = 0;
187
+ let task;
188
+ let winId;
189
+ let applyPath;
190
+ let instance;
191
+ let rtnValue;
192
+ let isLast;
193
+ for (;i < totalTasks; i++) {
194
+ try {
195
+ isLast = i === totalTasks - 1;
196
+ task = accessReq.$tasks$[i];
197
+ winId = task.$winId$;
198
+ applyPath = task.$applyPath$;
199
+ !winCtxs[winId] && winId.startsWith("f_") && await new Promise((resolve => {
200
+ let check = 0;
201
+ let callback = () => {
202
+ winCtxs[winId] || check++ > 1e3 ? resolve() : requestAnimationFrame(callback);
203
+ };
204
+ callback();
205
+ }));
206
+ if (1 === applyPath[0] && applyPath[1] in winCtxs[winId].$window$) {
207
+ setInstanceId(new winCtxs[winId].$window$[applyPath[1]](...deserializeFromWorker(worker, applyPath[2])), task.$instanceId$);
208
+ } else {
209
+ instance = getInstance(winId, task.$instanceId$);
210
+ if (instance) {
211
+ rtnValue = applyToInstance(worker, winId, instance, applyPath, isLast, task.$groupedGetters$);
212
+ task.$assignInstanceId$ && ("string" == typeof task.$assignInstanceId$ ? setInstanceId(rtnValue, task.$assignInstanceId$) : winCtxs[task.$assignInstanceId$.$winId$] = {
213
+ $winId$: task.$assignInstanceId$.$winId$,
214
+ $window$: {
215
+ document: rtnValue
216
+ }
217
+ });
218
+ if (isPromise(rtnValue)) {
219
+ rtnValue = await rtnValue;
220
+ isLast && (accessRsp.$isPromise$ = true);
221
+ }
222
+ isLast && (accessRsp.$rtnValue$ = serializeForWorker(winId, rtnValue));
223
+ } else {
224
+ accessRsp.$error$ = `Error finding instance "${task.$instanceId$}" on window ${normalizedWinId(winId)}`;
225
+ console.error(accessRsp.$error$, task);
226
+ }
227
+ }
228
+ } catch (e) {
229
+ isLast ? accessRsp.$error$ = String(e.stack || e) : console.error(e);
230
+ }
231
+ }
232
+ return accessRsp;
233
+ };
234
+ const applyToInstance = (worker, winId, instance, applyPath, isLast, groupedGetters) => {
235
+ let i = 0;
236
+ let l = len(applyPath);
237
+ let next;
238
+ let current;
239
+ let previous;
240
+ let args;
241
+ let groupedRtnValues;
242
+ for (;i < l; i++) {
243
+ current = applyPath[i];
244
+ next = applyPath[i + 1];
245
+ previous = applyPath[i - 1];
246
+ try {
247
+ if (!Array.isArray(next)) {
248
+ if ("string" == typeof current || "number" == typeof current) {
249
+ if (i + 1 === l && groupedGetters) {
250
+ groupedRtnValues = {};
251
+ groupedGetters.map((propName => groupedRtnValues[propName] = instance[propName]));
252
+ return groupedRtnValues;
253
+ }
254
+ instance = instance[current];
255
+ } else {
256
+ if (0 === next) {
257
+ instance[previous] = deserializeFromWorker(worker, current);
258
+ return;
259
+ }
260
+ if ("function" == typeof instance[previous]) {
261
+ args = deserializeFromWorker(worker, current);
262
+ "define" === previous && "CustomElementRegistry" === getConstructorName(instance) && (args[1] = defineCustomElement(winId, worker, args[1]));
263
+ "insertRule" === previous && args[1] > len(instance.cssRules) && (args[1] = len(instance.cssRules));
264
+ instance = instance[previous].apply(instance, args);
265
+ if ("play" === previous) {
266
+ return Promise.resolve();
267
+ }
268
+ }
269
+ }
270
+ }
271
+ } catch (err) {
272
+ if (isLast) {
273
+ throw err;
274
+ }
275
+ console.debug("Non-blocking setter error:", err);
276
+ }
277
+ }
278
+ return instance;
279
+ };
280
+ const readNextScript = (worker, winCtx) => {
281
+ let $winId$ = winCtx.$winId$;
282
+ let win = winCtx.$window$;
283
+ let doc = win.document;
284
+ let scriptSelector = 'script[type="text/partytown"]:not([data-ptid]):not([data-pterror])';
285
+ let scriptElm;
286
+ let $instanceId$;
287
+ let scriptData;
288
+ if (doc && doc.body) {
289
+ scriptElm = doc.querySelector('script[type="text/partytown"]:not([data-ptid]):not([data-pterror]):not([async]):not([defer])');
290
+ scriptElm || (scriptElm = doc.querySelector(scriptSelector));
291
+ if (scriptElm) {
292
+ scriptElm.dataset.ptid = $instanceId$ = getAndSetInstanceId(scriptElm, $winId$);
293
+ scriptData = {
294
+ $winId$: $winId$,
295
+ $instanceId$: $instanceId$
296
+ };
297
+ if (scriptElm.src) {
298
+ scriptData.$url$ = scriptElm.src;
299
+ scriptData.$orgUrl$ = scriptElm.dataset.ptsrc || scriptElm.src;
300
+ } else {
301
+ scriptData.$content$ = scriptElm.innerHTML;
302
+ }
303
+ worker.postMessage([ 7, scriptData ]);
304
+ } else {
305
+ if (!winCtx.$isInitialized$) {
306
+ winCtx.$isInitialized$ = 1;
307
+ ((worker, $winId$, win) => {
308
+ let queuedForwardCalls = win._ptf;
309
+ let forwards = (win.partytown || {}).forward || [];
310
+ let i;
311
+ let mainForwardFn;
312
+ let forwardCall = ($forward$, args) => worker.postMessage([ 10, {
313
+ $winId$: $winId$,
314
+ $forward$: $forward$,
315
+ $args$: serializeForWorker($winId$, Array.from(args))
316
+ } ]);
317
+ win._ptf = void 0;
318
+ forwards.map((forwardProps => {
319
+ mainForwardFn = win;
320
+ forwardProps.split(".").map(((_, i, arr) => {
321
+ mainForwardFn = mainForwardFn[arr[i]] = i + 1 < len(arr) ? mainForwardFn[arr[i]] || ("push" === arr[i + 1] ? [] : {}) : (...args) => forwardCall(arr, args);
322
+ }));
323
+ }));
324
+ if (queuedForwardCalls) {
325
+ for (i = 0; i < len(queuedForwardCalls); i += 2) {
326
+ forwardCall(queuedForwardCalls[i], queuedForwardCalls[i + 1]);
327
+ }
328
+ }
329
+ })(worker, $winId$, win);
330
+ doc.dispatchEvent(new CustomEvent("pt0"));
331
+ {
332
+ const winType = win === win.top ? "top" : "iframe";
333
+ logMain(`Executed ${winType} window ${normalizedWinId($winId$)} environment scripts in ${(performance.now() - winCtx.$startTime$).toFixed(1)}ms`);
334
+ }
335
+ }
336
+ worker.postMessage([ 8, $winId$ ]);
337
+ }
338
+ } else {
339
+ requestAnimationFrame((() => readNextScript(worker, winCtx)));
340
+ }
341
+ };
342
+ const registerWindow = (worker, $winId$, $window$) => {
343
+ if (!windowIds.has($window$)) {
344
+ windowIds.set($window$, $winId$);
345
+ const doc = $window$.document;
346
+ const history = $window$.history;
347
+ const $parentWinId$ = windowIds.get($window$.parent);
348
+ let initialised = false;
349
+ const onInitialisedQueue = [];
350
+ const onInitialised = callback => {
351
+ initialised ? callback() : onInitialisedQueue.push(callback);
352
+ };
353
+ const sendInitEnvData = () => {
354
+ worker.postMessage([ 5, {
355
+ $winId$: $winId$,
356
+ $parentWinId$: $parentWinId$,
357
+ $url$: doc.baseURI,
358
+ $visibilityState$: doc.visibilityState
359
+ } ]);
360
+ setTimeout((() => {
361
+ initialised = true;
362
+ onInitialisedQueue.forEach((callback => {
363
+ callback();
364
+ }));
365
+ }));
366
+ };
367
+ const pushState = history.pushState.bind(history);
368
+ const replaceState = history.replaceState.bind(history);
369
+ const onLocationChange = (type, state, newUrl, oldUrl) => () => {
370
+ setTimeout((() => {
371
+ worker.postMessage([ 13, {
372
+ $winId$: $winId$,
373
+ type: type,
374
+ state: state,
375
+ url: doc.baseURI,
376
+ newUrl: newUrl,
377
+ oldUrl: oldUrl
378
+ } ]);
379
+ }));
380
+ };
381
+ history.pushState = (state, _, newUrl) => {
382
+ pushState(state, _, newUrl);
383
+ onInitialised(onLocationChange(0, state, null == newUrl ? void 0 : newUrl.toString()));
384
+ };
385
+ history.replaceState = (state, _, newUrl) => {
386
+ replaceState(state, _, newUrl);
387
+ onInitialised(onLocationChange(1, state, null == newUrl ? void 0 : newUrl.toString()));
388
+ };
389
+ $window$.addEventListener("popstate", (event => {
390
+ onInitialised(onLocationChange(2, event.state));
391
+ }));
392
+ $window$.addEventListener("hashchange", (event => {
393
+ onInitialised(onLocationChange(3, {}, event.newURL, event.oldURL));
394
+ }));
395
+ $window$.addEventListener("ptupdate", (() => {
396
+ readNextScript(worker, winCtxs[$winId$]);
397
+ }));
398
+ doc.addEventListener("visibilitychange", (() => worker.postMessage([ 14, $winId$, doc.visibilityState ])));
399
+ winCtxs[$winId$] = {
400
+ $winId$: $winId$,
401
+ $window$: $window$
402
+ };
403
+ winCtxs[$winId$].$startTime$ = performance.now();
404
+ {
405
+ const winType = $winId$ === $parentWinId$ ? "top" : "iframe";
406
+ logMain(`Registered ${winType} window ${normalizedWinId($winId$)}`);
407
+ }
408
+ "complete" === doc.readyState ? sendInitEnvData() : $window$.addEventListener("load", sendInitEnvData);
409
+ }
410
+ };
411
+ const onMessageFromWebWorker = (worker, msg, winCtx) => {
412
+ if (4 === msg[0]) {
413
+ registerWindow(worker, randomId(), mainWindow);
414
+ } else {
415
+ winCtx = winCtxs[msg[1]];
416
+ winCtx && (7 === msg[0] ? requestAnimationFrame((() => readNextScript(worker, winCtx))) : 6 === msg[0] && ((worker, winCtx, instanceId, errorMsg, scriptElm) => {
417
+ scriptElm = winCtx.$window$.document.querySelector(`[data-ptid="${instanceId}"]`);
418
+ if (scriptElm) {
419
+ errorMsg ? scriptElm.dataset.pterror = errorMsg : scriptElm.type += "-x";
420
+ delete scriptElm.dataset.ptid;
421
+ }
422
+ readNextScript(worker, winCtx);
423
+ })(worker, winCtx, msg[2], msg[3]));
424
+ }
425
+ };
426
+ const readMainPlatform = () => {
427
+ const elm = docImpl.createElement("i");
428
+ const textNode = docImpl.createTextNode("");
429
+ const comment = docImpl.createComment("");
430
+ const frag = docImpl.createDocumentFragment();
431
+ const shadowRoot = docImpl.createElement("p").attachShadow({
432
+ mode: "open"
433
+ });
434
+ const intersectionObserver = getGlobalConstructor(mainWindow, "IntersectionObserver");
435
+ const mutationObserver = getGlobalConstructor(mainWindow, "MutationObserver");
436
+ const resizeObserver = getGlobalConstructor(mainWindow, "ResizeObserver");
437
+ const perf = mainWindow.performance;
438
+ const screen = mainWindow.screen;
439
+ 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 ] ];
440
+ const initialInterfaces = [ readImplementation("Window", mainWindow), readImplementation("Node", textNode) ];
441
+ const $config$ = JSON.stringify(config, ((k, v) => {
442
+ if ("function" == typeof v) {
443
+ v = String(v);
444
+ v.startsWith(k + "(") && (v = "function " + v);
445
+ }
446
+ return v;
447
+ }));
448
+ const initWebWorkerData = {
449
+ $config$: $config$,
450
+ $interfaces$: readImplementations(impls, initialInterfaces),
451
+ $libPath$: new URL(libPath, mainWindow.location) + "",
452
+ $origin$: origin,
453
+ $localStorage$: readStorage("localStorage"),
454
+ $sessionStorage$: readStorage("sessionStorage")
455
+ };
456
+ addGlobalConstructorUsingPrototype(initWebWorkerData.$interfaces$, mainWindow, "IntersectionObserverEntry");
457
+ return initWebWorkerData;
458
+ };
459
+ const readMainInterfaces = () => {
460
+ const elms = Object.getOwnPropertyNames(mainWindow).map((interfaceName => ((doc, interfaceName, r, tag) => {
461
+ r = interfaceName.match(/^(HTML|SVG)(.+)Element$/);
462
+ if (r) {
463
+ tag = r[2];
464
+ 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);
465
+ }
466
+ })(docImpl, interfaceName))).filter((elm => elm)).map((elm => [ elm ]));
467
+ return readImplementations(elms, []);
468
+ };
469
+ const cstrs = new Set([ "Object" ]);
470
+ const readImplementations = (impls, interfaces) => {
471
+ const cstrImpls = impls.filter((implData => implData[0])).map((implData => {
472
+ const impl = implData[0];
473
+ const interfaceType = implData[1];
474
+ const cstrName = getConstructorName(impl);
475
+ const CstrPrototype = mainWindow[cstrName].prototype;
476
+ return [ cstrName, CstrPrototype, impl, interfaceType ];
477
+ }));
478
+ cstrImpls.map((([cstrName, CstrPrototype, impl, intefaceType]) => readOwnImplementation(cstrs, interfaces, cstrName, CstrPrototype, impl, intefaceType)));
479
+ return interfaces;
480
+ };
481
+ const readImplementation = (cstrName, impl, memberName) => {
482
+ let interfaceMembers = [];
483
+ let interfaceInfo = [ cstrName, "Object", interfaceMembers ];
484
+ for (memberName in impl) {
485
+ readImplementationMember(interfaceMembers, impl, memberName);
486
+ }
487
+ return interfaceInfo;
488
+ };
489
+ const readOwnImplementation = (cstrs, interfaces, cstrName, CstrPrototype, impl, interfaceType) => {
490
+ if (!cstrs.has(cstrName)) {
491
+ cstrs.add(cstrName);
492
+ const SuperCstr = Object.getPrototypeOf(CstrPrototype);
493
+ const superCstrName = getConstructorName(SuperCstr);
494
+ const interfaceMembers = [];
495
+ const propDescriptors = Object.getOwnPropertyDescriptors(CstrPrototype);
496
+ readOwnImplementation(cstrs, interfaces, superCstrName, SuperCstr, impl, interfaceType);
497
+ for (const memberName in propDescriptors) {
498
+ readImplementationMember(interfaceMembers, impl, memberName);
499
+ }
500
+ interfaces.push([ cstrName, superCstrName, interfaceMembers, interfaceType, getNodeName(impl) ]);
501
+ }
502
+ };
503
+ const readImplementationMember = (interfaceMembers, implementation, memberName, value, memberType, cstrName) => {
504
+ try {
505
+ if (isValidMemberName(memberName) && isNaN(memberName[0]) && "all" !== memberName) {
506
+ value = implementation[memberName];
507
+ memberType = typeof value;
508
+ if ("function" === memberType) {
509
+ (String(value).includes("[native") || Object.getPrototypeOf(implementation)[memberName]) && interfaceMembers.push([ memberName, 5 ]);
510
+ } else if ("object" === memberType && null != value) {
511
+ cstrName = getConstructorName(value);
512
+ "Object" !== cstrName && self[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]);
513
+ } else {
514
+ "symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]));
515
+ }
516
+ }
517
+ } catch (e) {
518
+ console.warn(e);
519
+ }
520
+ };
521
+ const readStorage = storageName => {
522
+ let items = [];
523
+ let i = 0;
524
+ let l = len(mainWindow[storageName]);
525
+ let key;
526
+ for (;i < l; i++) {
527
+ key = mainWindow[storageName].key(i);
528
+ items.push([ key, mainWindow[storageName].getItem(key) ]);
529
+ }
530
+ return items;
531
+ };
532
+ const getGlobalConstructor = (mainWindow, cstrName) => void 0 !== mainWindow[cstrName] ? new mainWindow[cstrName](noop) : 0;
533
+ const addGlobalConstructorUsingPrototype = ($interfaces$, mainWindow, cstrName) => {
534
+ void 0 !== mainWindow[cstrName] && $interfaces$.push([ cstrName, "Object", Object.keys(mainWindow[cstrName].prototype).map((propName => [ propName, 6 ])), 12 ]);
535
+ };
536
+ let worker;
537
+ (receiveMessage => {
538
+ const swContainer = window.navigator.serviceWorker;
539
+ return swContainer.getRegistration().then((swRegistration => {
540
+ swContainer.addEventListener("message", (ev => receiveMessage(ev.data, (accessRsp => swRegistration.active && swRegistration.active.postMessage(accessRsp)))));
541
+ return (worker, msg) => {
542
+ 0 === msg[0] ? worker.postMessage([ 1, readMainPlatform() ]) : 2 === msg[0] ? worker.postMessage([ 3, readMainInterfaces() ]) : onMessageFromWebWorker(worker, msg);
543
+ };
544
+ }));
545
+ })(((accessReq, responseCallback) => mainAccessHandler(worker, accessReq).then(responseCallback))).then((onMessageHandler => {
546
+ if (onMessageHandler) {
547
+ worker = new Worker(libPath + "partytown-ww-sw.js?v=0.7.5", {
548
+ name: "Partytown 🎉"
549
+ });
550
+ worker.onmessage = ev => {
551
+ const msg = ev.data;
552
+ 12 === msg[0] ? mainAccessHandler(worker, msg[1]) : onMessageHandler(worker, msg);
553
+ };
554
+ logMain("Created Partytown web worker (0.7.5)");
555
+ worker.onerror = ev => console.error("Web Worker Error", ev);
556
+ mainWindow.addEventListener("pt1", (ev => registerWindow(worker, getAndSetInstanceId(ev.detail.frameElement), ev.detail)));
557
+ }
558
+ }));
559
+ })(window);
@@ -0,0 +1,59 @@
1
+ /* Partytown 0.7.5 - MIT builder.io */
2
+ const resolves = new Map;
3
+
4
+ const swMessageError = (accessReq, $error$) => ({
5
+ $msgId$: accessReq.$msgId$,
6
+ $error$: $error$
7
+ });
8
+
9
+ const httpRequestFromWebWorker = req => new Promise((async resolve => {
10
+ const accessReq = await req.clone().json();
11
+ const responseData = await (accessReq => new Promise((async resolve => {
12
+ const clients = await self.clients.matchAll();
13
+ const client = [ ...clients ].sort(((a, b) => a.url > b.url ? -1 : a.url < b.url ? 1 : 0))[0];
14
+ if (client) {
15
+ const timeout = 12e4;
16
+ const msgResolve = [ resolve, setTimeout((() => {
17
+ resolves.delete(accessReq.$msgId$);
18
+ resolve(swMessageError(accessReq, "Timeout"));
19
+ }), timeout) ];
20
+ resolves.set(accessReq.$msgId$, msgResolve);
21
+ client.postMessage(accessReq);
22
+ } else {
23
+ resolve(swMessageError(accessReq, "NoParty"));
24
+ }
25
+ })))(accessReq);
26
+ resolve(response(JSON.stringify(responseData), "application/json"));
27
+ }));
28
+
29
+ const response = (body, contentType) => new Response(body, {
30
+ headers: {
31
+ "content-type": contentType || "text/html",
32
+ "Cache-Control": "no-store"
33
+ }
34
+ });
35
+
36
+ self.oninstall = () => self.skipWaiting();
37
+
38
+ self.onactivate = () => self.clients.claim();
39
+
40
+ self.onmessage = ev => {
41
+ const accessRsp = ev.data;
42
+ const r = resolves.get(accessRsp.$msgId$);
43
+ if (r) {
44
+ resolves.delete(accessRsp.$msgId$);
45
+ clearTimeout(r[1]);
46
+ r[0](accessRsp);
47
+ }
48
+ };
49
+
50
+ self.onfetch = ev => {
51
+ const req = ev.request;
52
+ const url = new URL(req.url);
53
+ const pathname = url.pathname;
54
+ if (pathname.endsWith("sw.html")) {
55
+ ev.respondWith(response('<!DOCTYPE html><html><head><meta charset="utf-8"><script src="./partytown-sandbox-sw.js?v=0.7.5"><\/script></head></html>'));
56
+ } else {
57
+ pathname.endsWith("proxytown") && ev.respondWith(httpRequestFromWebWorker(req));
58
+ }
59
+ };