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.
- checksums.yaml +4 -4
- data/_includes/head/index.html +3 -1
- data/assets/js/partytown/debug/partytown-atomics.js +572 -0
- data/assets/js/partytown/debug/partytown-media.js +374 -0
- data/assets/js/partytown/debug/partytown-sandbox-sw.js +559 -0
- data/assets/js/partytown/debug/partytown-sw.js +59 -0
- data/assets/js/partytown/debug/partytown-ww-atomics.js +1876 -0
- data/assets/js/partytown/debug/partytown-ww-sw.js +1868 -0
- data/assets/js/partytown/debug/partytown.js +75 -0
- data/assets/js/partytown/partytown-atomics.js +2 -0
- data/assets/js/partytown/partytown-media.js +2 -0
- data/assets/js/partytown/partytown-sw.js +2 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c32fe7c7df7eab2bd3ccab7687ae364c2bbe42e65e8a4eb7db57dd359400d754
|
4
|
+
data.tar.gz: 5e1d744f67e74c8921b3473363f7c625dee9a7a300dfa3831a5f198e5015d20e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cddf58ece85fc0652a78184f00a1adb28e05237bfe7f522f4b4e2e92912ece04c96ba2da1510bfe55a89ab59ceddb8e453c061ae13960054c5791a0fd1cbe70d
|
7
|
+
data.tar.gz: 0ef41d135468f44432fd8ae1e9255200ebd607cacc9f80b028c1ea45c936813b0e6a974a5cbf4dd543b31fc8069b7af59f8d135aea048d3d4a8510d201164fd7
|
data/_includes/head/index.html
CHANGED
@@ -340,7 +340,9 @@
|
|
340
340
|
l ||
|
341
341
|
((l = 1),
|
342
342
|
"/" ==
|
343
|
-
(a =
|
343
|
+
(a =
|
344
|
+
(o.lib || "/assets/js/partytown/") +
|
345
|
+
(o.debug ? "debug/" : ""))[0] &&
|
344
346
|
((s = e.querySelectorAll('script[type="text/partytown"]')),
|
345
347
|
i != t
|
346
348
|
? i.dispatchEvent(new CustomEvent("pt1", { detail: t }))
|
@@ -0,0 +1,572 @@
|
|
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 readMainInterfaces = () => {
|
427
|
+
const elms = Object.getOwnPropertyNames(mainWindow).map((interfaceName => ((doc, interfaceName, r, tag) => {
|
428
|
+
r = interfaceName.match(/^(HTML|SVG)(.+)Element$/);
|
429
|
+
if (r) {
|
430
|
+
tag = r[2];
|
431
|
+
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);
|
432
|
+
}
|
433
|
+
})(docImpl, interfaceName))).filter((elm => elm)).map((elm => [ elm ]));
|
434
|
+
return readImplementations(elms, []);
|
435
|
+
};
|
436
|
+
const cstrs = new Set([ "Object" ]);
|
437
|
+
const readImplementations = (impls, interfaces) => {
|
438
|
+
const cstrImpls = impls.filter((implData => implData[0])).map((implData => {
|
439
|
+
const impl = implData[0];
|
440
|
+
const interfaceType = implData[1];
|
441
|
+
const cstrName = getConstructorName(impl);
|
442
|
+
const CstrPrototype = mainWindow[cstrName].prototype;
|
443
|
+
return [ cstrName, CstrPrototype, impl, interfaceType ];
|
444
|
+
}));
|
445
|
+
cstrImpls.map((([cstrName, CstrPrototype, impl, intefaceType]) => readOwnImplementation(cstrs, interfaces, cstrName, CstrPrototype, impl, intefaceType)));
|
446
|
+
return interfaces;
|
447
|
+
};
|
448
|
+
const readImplementation = (cstrName, impl, memberName) => {
|
449
|
+
let interfaceMembers = [];
|
450
|
+
let interfaceInfo = [ cstrName, "Object", interfaceMembers ];
|
451
|
+
for (memberName in impl) {
|
452
|
+
readImplementationMember(interfaceMembers, impl, memberName);
|
453
|
+
}
|
454
|
+
return interfaceInfo;
|
455
|
+
};
|
456
|
+
const readOwnImplementation = (cstrs, interfaces, cstrName, CstrPrototype, impl, interfaceType) => {
|
457
|
+
if (!cstrs.has(cstrName)) {
|
458
|
+
cstrs.add(cstrName);
|
459
|
+
const SuperCstr = Object.getPrototypeOf(CstrPrototype);
|
460
|
+
const superCstrName = getConstructorName(SuperCstr);
|
461
|
+
const interfaceMembers = [];
|
462
|
+
const propDescriptors = Object.getOwnPropertyDescriptors(CstrPrototype);
|
463
|
+
readOwnImplementation(cstrs, interfaces, superCstrName, SuperCstr, impl, interfaceType);
|
464
|
+
for (const memberName in propDescriptors) {
|
465
|
+
readImplementationMember(interfaceMembers, impl, memberName);
|
466
|
+
}
|
467
|
+
interfaces.push([ cstrName, superCstrName, interfaceMembers, interfaceType, getNodeName(impl) ]);
|
468
|
+
}
|
469
|
+
};
|
470
|
+
const readImplementationMember = (interfaceMembers, implementation, memberName, value, memberType, cstrName) => {
|
471
|
+
try {
|
472
|
+
if (isValidMemberName(memberName) && isNaN(memberName[0]) && "all" !== memberName) {
|
473
|
+
value = implementation[memberName];
|
474
|
+
memberType = typeof value;
|
475
|
+
if ("function" === memberType) {
|
476
|
+
(String(value).includes("[native") || Object.getPrototypeOf(implementation)[memberName]) && interfaceMembers.push([ memberName, 5 ]);
|
477
|
+
} else if ("object" === memberType && null != value) {
|
478
|
+
cstrName = getConstructorName(value);
|
479
|
+
"Object" !== cstrName && self[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]);
|
480
|
+
} else {
|
481
|
+
"symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]));
|
482
|
+
}
|
483
|
+
}
|
484
|
+
} catch (e) {
|
485
|
+
console.warn(e);
|
486
|
+
}
|
487
|
+
};
|
488
|
+
const readStorage = storageName => {
|
489
|
+
let items = [];
|
490
|
+
let i = 0;
|
491
|
+
let l = len(mainWindow[storageName]);
|
492
|
+
let key;
|
493
|
+
for (;i < l; i++) {
|
494
|
+
key = mainWindow[storageName].key(i);
|
495
|
+
items.push([ key, mainWindow[storageName].getItem(key) ]);
|
496
|
+
}
|
497
|
+
return items;
|
498
|
+
};
|
499
|
+
const getGlobalConstructor = (mainWindow, cstrName) => void 0 !== mainWindow[cstrName] ? new mainWindow[cstrName](noop) : 0;
|
500
|
+
const addGlobalConstructorUsingPrototype = ($interfaces$, mainWindow, cstrName) => {
|
501
|
+
void 0 !== mainWindow[cstrName] && $interfaces$.push([ cstrName, "Object", Object.keys(mainWindow[cstrName].prototype).map((propName => [ propName, 6 ])), 12 ]);
|
502
|
+
};
|
503
|
+
let worker;
|
504
|
+
(async receiveMessage => {
|
505
|
+
const sharedDataBuffer = new SharedArrayBuffer(1073741824);
|
506
|
+
const sharedData = new Int32Array(sharedDataBuffer);
|
507
|
+
return (worker, msg) => {
|
508
|
+
const msgType = msg[0];
|
509
|
+
const accessReq = msg[1];
|
510
|
+
if (0 === msgType) {
|
511
|
+
const initData = (() => {
|
512
|
+
const elm = docImpl.createElement("i");
|
513
|
+
const textNode = docImpl.createTextNode("");
|
514
|
+
const comment = docImpl.createComment("");
|
515
|
+
const frag = docImpl.createDocumentFragment();
|
516
|
+
const shadowRoot = docImpl.createElement("p").attachShadow({
|
517
|
+
mode: "open"
|
518
|
+
});
|
519
|
+
const intersectionObserver = getGlobalConstructor(mainWindow, "IntersectionObserver");
|
520
|
+
const mutationObserver = getGlobalConstructor(mainWindow, "MutationObserver");
|
521
|
+
const resizeObserver = getGlobalConstructor(mainWindow, "ResizeObserver");
|
522
|
+
const perf = mainWindow.performance;
|
523
|
+
const screen = mainWindow.screen;
|
524
|
+
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 ] ];
|
525
|
+
const initialInterfaces = [ readImplementation("Window", mainWindow), readImplementation("Node", textNode) ];
|
526
|
+
const $config$ = JSON.stringify(config, ((k, v) => {
|
527
|
+
if ("function" == typeof v) {
|
528
|
+
v = String(v);
|
529
|
+
v.startsWith(k + "(") && (v = "function " + v);
|
530
|
+
}
|
531
|
+
return v;
|
532
|
+
}));
|
533
|
+
const initWebWorkerData = {
|
534
|
+
$config$: $config$,
|
535
|
+
$interfaces$: readImplementations(impls, initialInterfaces),
|
536
|
+
$libPath$: new URL(libPath, mainWindow.location) + "",
|
537
|
+
$origin$: origin,
|
538
|
+
$localStorage$: readStorage("localStorage"),
|
539
|
+
$sessionStorage$: readStorage("sessionStorage")
|
540
|
+
};
|
541
|
+
addGlobalConstructorUsingPrototype(initWebWorkerData.$interfaces$, mainWindow, "IntersectionObserverEntry");
|
542
|
+
return initWebWorkerData;
|
543
|
+
})();
|
544
|
+
initData.$sharedDataBuffer$ = sharedDataBuffer;
|
545
|
+
worker.postMessage([ 1, initData ]);
|
546
|
+
} else {
|
547
|
+
2 === msg[0] ? worker.postMessage([ 3, readMainInterfaces() ]) : 11 === msgType ? receiveMessage(accessReq, (accessRsp => {
|
548
|
+
const stringifiedData = JSON.stringify(accessRsp);
|
549
|
+
const stringifiedDataLength = stringifiedData.length;
|
550
|
+
for (let i = 0; i < stringifiedDataLength; i++) {
|
551
|
+
sharedData[i + 1] = stringifiedData.charCodeAt(i);
|
552
|
+
}
|
553
|
+
sharedData[0] = stringifiedDataLength;
|
554
|
+
Atomics.notify(sharedData, 0);
|
555
|
+
})) : onMessageFromWebWorker(worker, msg);
|
556
|
+
}
|
557
|
+
};
|
558
|
+
})(((accessReq, responseCallback) => mainAccessHandler(worker, accessReq).then(responseCallback))).then((onMessageHandler => {
|
559
|
+
if (onMessageHandler) {
|
560
|
+
worker = new Worker(libPath + "partytown-ww-atomics.js?v=0.7.5", {
|
561
|
+
name: "Partytown 🎉"
|
562
|
+
});
|
563
|
+
worker.onmessage = ev => {
|
564
|
+
const msg = ev.data;
|
565
|
+
12 === msg[0] ? mainAccessHandler(worker, msg[1]) : onMessageHandler(worker, msg);
|
566
|
+
};
|
567
|
+
logMain("Created Partytown web worker (0.7.5)");
|
568
|
+
worker.onerror = ev => console.error("Web Worker Error", ev);
|
569
|
+
mainWindow.addEventListener("pt1", (ev => registerWindow(worker, getAndSetInstanceId(ev.detail.frameElement), ev.detail)));
|
570
|
+
}
|
571
|
+
}));
|
572
|
+
})(window);
|