@faststore/core 2.2.41 → 2.2.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -0
- package/.next/build-manifest.json +126 -0
- package/.next/cache/.tsbuildinfo +1 -0
- package/.next/cache/config.json +7 -0
- package/.next/cache/eslint/.cache_1gneedd +1 -0
- package/.next/cache/next-server.js.nft.json +1 -0
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/export-marker.json +1 -0
- package/.next/images-manifest.json +1 -0
- package/.next/next-server.js.nft.json +1 -0
- package/.next/package.json +1 -0
- package/.next/prerender-manifest.json +1 -0
- package/.next/react-loadable-manifest.json +47 -0
- package/.next/required-server-files.json +1 -0
- package/.next/routes-manifest.json +1 -0
- package/.next/server/chunks/117.js +430 -0
- package/.next/server/chunks/177.js +125 -0
- package/.next/server/chunks/183.js +122 -0
- package/.next/server/chunks/184.js +61 -0
- package/.next/server/chunks/289.js +240 -0
- package/.next/server/chunks/312.js +678 -0
- package/.next/server/chunks/350.js +200 -0
- package/.next/server/chunks/386.js +200 -0
- package/.next/server/chunks/390.js +550 -0
- package/.next/server/chunks/398.js +611 -0
- package/.next/server/chunks/52.js +4007 -0
- package/.next/server/chunks/53.js +61 -0
- package/.next/server/chunks/574.js +145 -0
- package/.next/server/chunks/576.js +122 -0
- package/.next/server/chunks/585.js +640 -0
- package/.next/server/chunks/676.js +32 -0
- package/.next/server/chunks/693.js +58 -0
- package/.next/server/chunks/732.js +1881 -0
- package/.next/server/chunks/74.js +4066 -0
- package/.next/server/chunks/779.js +58 -0
- package/.next/server/chunks/817.js +4007 -0
- package/.next/server/chunks/825.js +4074 -0
- package/.next/server/chunks/854.js +72 -0
- package/.next/server/chunks/859.js +959 -0
- package/.next/server/chunks/863.js +111 -0
- package/.next/server/chunks/979.js +1305 -0
- package/.next/server/chunks/98.js +163 -0
- package/.next/server/chunks/988.js +211 -0
- package/.next/server/chunks/font-manifest.json +1 -0
- package/.next/server/font-manifest.json +1 -0
- package/.next/server/middleware-build-manifest.js +1 -0
- package/.next/server/middleware-manifest.json +6 -0
- package/.next/server/middleware-react-loadable-manifest.js +1 -0
- package/.next/server/pages/404.js +391 -0
- package/.next/server/pages/404.js.nft.json +1 -0
- package/.next/server/pages/500.js +395 -0
- package/.next/server/pages/500.js.nft.json +1 -0
- package/.next/server/pages/[...slug].js +1084 -0
- package/.next/server/pages/[...slug].js.nft.json +1 -0
- package/.next/server/pages/[slug]/p.js +2273 -0
- package/.next/server/pages/[slug]/p.js.nft.json +1 -0
- package/.next/server/pages/_app.js +301 -0
- package/.next/server/pages/_app.js.nft.json +1 -0
- package/.next/server/pages/_document.js +363 -0
- package/.next/server/pages/_document.js.nft.json +1 -0
- package/.next/server/pages/_error.js +164 -0
- package/.next/server/pages/_error.js.nft.json +1 -0
- package/.next/server/pages/account.js +370 -0
- package/.next/server/pages/account.js.nft.json +1 -0
- package/.next/server/pages/api/graphql.js +464 -0
- package/.next/server/pages/api/graphql.js.nft.json +1 -0
- package/.next/server/pages/api/health/live.js +31 -0
- package/.next/server/pages/api/health/live.js.nft.json +1 -0
- package/.next/server/pages/api/health/ready.js +31 -0
- package/.next/server/pages/api/health/ready.js.nft.json +1 -0
- package/.next/server/pages/api/preview.js +137 -0
- package/.next/server/pages/api/preview.js.nft.json +1 -0
- package/.next/server/pages/checkout.js +370 -0
- package/.next/server/pages/checkout.js.nft.json +1 -0
- package/.next/server/pages/en-US/404.html +81 -0
- package/.next/server/pages/en-US/404.json +1 -0
- package/.next/server/pages/en-US/500.html +81 -0
- package/.next/server/pages/en-US/500.json +1 -0
- package/.next/server/pages/en-US/account.html +81 -0
- package/.next/server/pages/en-US/account.json +1 -0
- package/.next/server/pages/en-US/checkout.html +81 -0
- package/.next/server/pages/en-US/checkout.json +1 -0
- package/.next/server/pages/en-US/login.html +81 -0
- package/.next/server/pages/en-US/login.json +1 -0
- package/.next/server/pages/en-US/s.html +81 -0
- package/.next/server/pages/en-US/s.json +1 -0
- package/.next/server/pages/en-US.html +90 -0
- package/.next/server/pages/en-US.json +1 -0
- package/.next/server/pages/index.js +439 -0
- package/.next/server/pages/index.js.nft.json +1 -0
- package/.next/server/pages/login.js +382 -0
- package/.next/server/pages/login.js.nft.json +1 -0
- package/.next/server/pages/s.js +554 -0
- package/.next/server/pages/s.js.nft.json +1 -0
- package/.next/server/pages-manifest.json +18 -0
- package/.next/server/webpack-api-runtime.js +229 -0
- package/.next/server/webpack-runtime.js +229 -0
- package/.next/static/A0luZO19pCRpHHJjixWd9/_buildManifest.js +1 -0
- package/.next/static/A0luZO19pCRpHHJjixWd9/_ssgManifest.js +1 -0
- package/.next/static/chunks/223-cb77217cce52d45c.js +1 -0
- package/.next/static/chunks/251.1c79f06f2a2814b1.js +1 -0
- package/.next/static/chunks/386.d01e0db26c523f0f.js +1 -0
- package/.next/static/chunks/400-d4daabcd57b2ea80.js +1 -0
- package/.next/static/chunks/469-7259b855711d4ad3.js +1 -0
- package/.next/static/chunks/574.70612be06fd1365f.js +1 -0
- package/.next/static/chunks/585.4c5d40fc6a72a611.js +1 -0
- package/.next/static/chunks/651.7142f31ce1e052b3.js +1 -0
- package/.next/static/chunks/741.52f7fb873418346f.js +1 -0
- package/.next/static/chunks/783-fbcb7a3216c40744.js +1 -0
- package/.next/static/chunks/800.ee4f8b9622001e8c.js +1 -0
- package/.next/static/chunks/98.40c7e17d9de4eb8f.js +1 -0
- package/.next/static/chunks/988.afda042dd9ba11d1.js +1 -0
- package/.next/static/chunks/framework-dfd14d7ce6600b03.js +1 -0
- package/.next/static/chunks/main-e4e873ee741162eb.js +1 -0
- package/.next/static/chunks/pages/404-2240f0b22db2d370.js +1 -0
- package/.next/static/chunks/pages/500-c0580e3299329874.js +1 -0
- package/.next/static/chunks/pages/[...slug]-3eed3497c887fae5.js +1 -0
- package/.next/static/chunks/pages/[slug]/p-e1df08570f34a0d8.js +1 -0
- package/.next/static/chunks/pages/_app-30b9666307e4b3b1.js +1 -0
- package/.next/static/chunks/pages/_error-319451dea77827a6.js +1 -0
- package/.next/static/chunks/pages/account-b35bcbef719765f3.js +1 -0
- package/.next/static/chunks/pages/checkout-55bd56ade4408cbe.js +1 -0
- package/.next/static/chunks/pages/index-2506749e45c335bf.js +1 -0
- package/.next/static/chunks/pages/login-3f94bff1503b4fdc.js +1 -0
- package/.next/static/chunks/pages/s-2374cff2e39ed624.js +1 -0
- package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +1 -0
- package/.next/static/chunks/webpack-4ccaf6613cbd7224.js +1 -0
- package/.next/static/css/29868543c76bc6fd.css +1 -0
- package/.next/static/css/527e334fa69cf40a.css +1 -0
- package/.next/static/css/5d1f64b61ea581f4.css +1 -0
- package/.next/static/css/6a7fdc5a21fbead5.css +1 -0
- package/.next/static/css/723835bce380750d.css +1 -0
- package/.next/static/css/a2eefb25a4608343.css +1 -0
- package/.next/static/css/cb7d1fcea42fab9c.css +1 -0
- package/.next/static/css/d7bbfbd552f407e9.css +1 -0
- package/.next/static/css/df588bb98c0b0ca6.css +1 -0
- package/.next/static/css/dfbdb0f27fd64782.css +1 -0
- package/.next/static/css/e84fc497732ea596.css +1 -0
- package/.next/trace +78 -0
- package/.turbo/turbo-build.log +13 -1
- package/.turbo/turbo-test.log +8 -5
- package/package.json +3 -3
- package/public/~partytown/debug/partytown-atomics.js +556 -0
- package/public/~partytown/debug/partytown-media.js +374 -0
- package/public/~partytown/debug/partytown-sandbox-sw.js +543 -0
- package/public/~partytown/debug/partytown-sw.js +59 -0
- package/public/~partytown/debug/partytown-ww-atomics.js +1789 -0
- package/public/~partytown/debug/partytown-ww-sw.js +1781 -0
- package/public/~partytown/debug/partytown.js +72 -0
- package/public/~partytown/partytown-atomics.js +2 -0
- package/public/~partytown/partytown-media.js +2 -0
- package/public/~partytown/partytown-sw.js +2 -0
- package/public/~partytown/partytown.js +2 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
$ yarn partytown & yarn generate && next build
|
|
2
|
-
$ partytown copylib ./public/~partytown
|
|
3
2
|
$ faststore generate-graphql -c
|
|
3
|
+
$ partytown copylib ./public/~partytown
|
|
4
4
|
Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
|
|
5
5
|
success - GraphQL schema, types, and optimizations successfully generated 🎉
|
|
6
6
|
warn - You have enabled experimental feature (scrollRestoration) in next.config.js.
|
|
@@ -12,10 +12,22 @@ This information is used to shape Next.js' roadmap and prioritize features.
|
|
|
12
12
|
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
|
|
13
13
|
https://nextjs.org/telemetry
|
|
14
14
|
|
|
15
|
+
Browserslist: caniuse-lite is outdated. Please run:
|
|
16
|
+
npx browserslist@latest --update-db
|
|
17
|
+
Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
|
|
15
18
|
info - Linting and checking validity of types...
|
|
19
|
+
Browserslist: caniuse-lite is outdated. Please run:
|
|
20
|
+
npx browserslist@latest --update-db
|
|
21
|
+
Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
|
|
16
22
|
info - Creating an optimized production build...
|
|
17
23
|
info - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
|
|
24
|
+
Browserslist: caniuse-lite is outdated. Please run:
|
|
25
|
+
npx browserslist@latest --update-db
|
|
26
|
+
Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
|
|
18
27
|
info - Using external babel configuration from /home/runner/work/faststore/faststore/packages/core/.babelrc
|
|
28
|
+
Browserslist: caniuse-lite is outdated. Please run:
|
|
29
|
+
npx update-browserslist-db@latest
|
|
30
|
+
Why you should do it regularly: https://github.com/browserslist/update-db#readme
|
|
19
31
|
info - Compiled successfully
|
|
20
32
|
info - Collecting page data...
|
|
21
33
|
info - Generating static pages (0/7)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
$ tsdx test
|
|
2
2
|
ts-jest[versions] (WARN) Version 29.1.0 of jest installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=25.0.0 <26.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
|
|
3
3
|
ts-jest[versions] (WARN) Version 4.9.4 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=3.4.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
|
|
4
|
-
|
|
4
|
+
Browserslist: caniuse-lite is outdated. Please run:
|
|
5
|
+
npx update-browserslist-db@latest
|
|
6
|
+
Why you should do it regularly: https://github.com/browserslist/update-db#readme
|
|
7
|
+
PASS test/server/index.test.ts (6.153s)
|
|
5
8
|
FastStore GraphQL Layer
|
|
6
9
|
@faststore/api
|
|
7
10
|
✓ should return a valid GraphQL schema (5ms)
|
|
8
11
|
✓ should return a valid GraphQL schema contain all expected types (4ms)
|
|
9
12
|
✓ should return a valid GraphQL schema contain all expected queries (1ms)
|
|
10
|
-
✓ should return a valid GraphQL schema contain all expected mutations
|
|
13
|
+
✓ should return a valid GraphQL schema contain all expected mutations
|
|
11
14
|
VTEX API Extension
|
|
12
15
|
✓ getTypeDefsFromFolder function should return an Array (6ms)
|
|
13
16
|
Third Party API Extension
|
|
@@ -15,11 +18,11 @@ PASS test/server/index.test.ts (6.082s)
|
|
|
15
18
|
Final Schema after merging
|
|
16
19
|
✓ should return a valid merged GraphQL schema (27ms)
|
|
17
20
|
Envelop
|
|
18
|
-
✓ should exist with its plugins (
|
|
19
|
-
✓ should handle options and execute (
|
|
21
|
+
✓ should exist with its plugins (29ms)
|
|
22
|
+
✓ should handle options and execute (344ms)
|
|
20
23
|
|
|
21
24
|
Test Suites: 1 passed, 1 total
|
|
22
25
|
Tests: 9 passed, 9 total
|
|
23
26
|
Snapshots: 0 total
|
|
24
|
-
Time: 6.
|
|
27
|
+
Time: 6.581s
|
|
25
28
|
Ran all test suites.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.42",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "vtex/faststore",
|
|
6
6
|
"browserslist": "supports es6-module and not dead",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@envelop/graphql-jit": "^1.1.1",
|
|
38
38
|
"@envelop/parser-cache": "^2.2.0",
|
|
39
39
|
"@envelop/validation-cache": "^2.2.0",
|
|
40
|
-
"@faststore/api": "^2.2.
|
|
40
|
+
"@faststore/api": "^2.2.42",
|
|
41
41
|
"@faststore/components": "^2.2.38",
|
|
42
42
|
"@faststore/graphql-utils": "^2.2.38",
|
|
43
43
|
"@faststore/sdk": "^2.2.38",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"msw": {
|
|
120
120
|
"workerDirectory": "public"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "42551deeabb190aa2f4efa0e0803fec593a997af"
|
|
123
123
|
}
|
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
/* Partytown 0.6.4 - 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 = 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 registerWindow = (worker, $winId$, $window$) => {
|
|
281
|
+
if (!windowIds.has($window$)) {
|
|
282
|
+
windowIds.set($window$, $winId$);
|
|
283
|
+
const doc = $window$.document;
|
|
284
|
+
const history = $window$.history;
|
|
285
|
+
const $parentWinId$ = windowIds.get($window$.parent);
|
|
286
|
+
const sendInitEnvData = () => worker.postMessage([ 5, {
|
|
287
|
+
$winId$: $winId$,
|
|
288
|
+
$parentWinId$: $parentWinId$,
|
|
289
|
+
$url$: doc.baseURI,
|
|
290
|
+
$visibilityState$: doc.visibilityState
|
|
291
|
+
} ]);
|
|
292
|
+
const pushState = history.pushState.bind(history);
|
|
293
|
+
const replaceState = history.replaceState.bind(history);
|
|
294
|
+
const onLocationChange = (type, state, newUrl, oldUrl) => {
|
|
295
|
+
setTimeout((() => {
|
|
296
|
+
worker.postMessage([ 13, {
|
|
297
|
+
$winId$: $winId$,
|
|
298
|
+
type: type,
|
|
299
|
+
state: state,
|
|
300
|
+
url: doc.baseURI,
|
|
301
|
+
newUrl: newUrl,
|
|
302
|
+
oldUrl: oldUrl
|
|
303
|
+
} ]);
|
|
304
|
+
}));
|
|
305
|
+
};
|
|
306
|
+
history.pushState = (state, _, newUrl) => {
|
|
307
|
+
pushState(state, _, newUrl);
|
|
308
|
+
onLocationChange(0, state, null == newUrl ? void 0 : newUrl.toString());
|
|
309
|
+
};
|
|
310
|
+
history.replaceState = (state, _, newUrl) => {
|
|
311
|
+
replaceState(state, _, newUrl);
|
|
312
|
+
onLocationChange(1, state, null == newUrl ? void 0 : newUrl.toString());
|
|
313
|
+
};
|
|
314
|
+
$window$.addEventListener("popstate", (event => {
|
|
315
|
+
onLocationChange(2, event.state);
|
|
316
|
+
}));
|
|
317
|
+
$window$.addEventListener("hashchange", (event => {
|
|
318
|
+
onLocationChange(3, {}, event.newURL, event.oldURL);
|
|
319
|
+
}));
|
|
320
|
+
doc.addEventListener("visibilitychange", (() => worker.postMessage([ 14, $winId$, doc.visibilityState ])));
|
|
321
|
+
winCtxs[$winId$] = {
|
|
322
|
+
$winId$: $winId$,
|
|
323
|
+
$window$: $window$
|
|
324
|
+
};
|
|
325
|
+
winCtxs[$winId$].$startTime$ = performance.now();
|
|
326
|
+
{
|
|
327
|
+
const winType = $winId$ === $parentWinId$ ? "top" : "iframe";
|
|
328
|
+
logMain(`Registered ${winType} window ${normalizedWinId($winId$)}`);
|
|
329
|
+
}
|
|
330
|
+
"complete" === doc.readyState ? sendInitEnvData() : $window$.addEventListener("load", sendInitEnvData);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
const readNextScript = (worker, winCtx) => {
|
|
334
|
+
let $winId$ = winCtx.$winId$;
|
|
335
|
+
let win = winCtx.$window$;
|
|
336
|
+
let doc = win.document;
|
|
337
|
+
let scriptSelector = 'script[type="text/partytown"]:not([data-ptid]):not([data-pterror])';
|
|
338
|
+
let scriptElm;
|
|
339
|
+
let $instanceId$;
|
|
340
|
+
let scriptData;
|
|
341
|
+
if (doc && doc.body) {
|
|
342
|
+
scriptElm = doc.querySelector('script[type="text/partytown"]:not([data-ptid]):not([data-pterror]):not([async]):not([defer])');
|
|
343
|
+
scriptElm || (scriptElm = doc.querySelector(scriptSelector));
|
|
344
|
+
if (scriptElm) {
|
|
345
|
+
scriptElm.dataset.ptid = $instanceId$ = getAndSetInstanceId(scriptElm, $winId$);
|
|
346
|
+
scriptData = {
|
|
347
|
+
$winId$: $winId$,
|
|
348
|
+
$instanceId$: $instanceId$
|
|
349
|
+
};
|
|
350
|
+
if (scriptElm.src) {
|
|
351
|
+
scriptData.$url$ = scriptElm.src;
|
|
352
|
+
scriptData.$orgUrl$ = scriptElm.dataset.ptsrc || scriptElm.src;
|
|
353
|
+
} else {
|
|
354
|
+
scriptData.$content$ = scriptElm.innerHTML;
|
|
355
|
+
}
|
|
356
|
+
worker.postMessage([ 7, scriptData ]);
|
|
357
|
+
} else {
|
|
358
|
+
if (!winCtx.$isInitialized$) {
|
|
359
|
+
winCtx.$isInitialized$ = 1;
|
|
360
|
+
((worker, $winId$, win) => {
|
|
361
|
+
let queuedForwardCalls = win._ptf;
|
|
362
|
+
let forwards = (win.partytown || {}).forward || [];
|
|
363
|
+
let i;
|
|
364
|
+
let mainForwardFn;
|
|
365
|
+
let forwardCall = ($forward$, args) => worker.postMessage([ 10, {
|
|
366
|
+
$winId$: $winId$,
|
|
367
|
+
$forward$: $forward$,
|
|
368
|
+
$args$: serializeForWorker($winId$, Array.from(args))
|
|
369
|
+
} ]);
|
|
370
|
+
win._ptf = void 0;
|
|
371
|
+
forwards.map((forwardProps => {
|
|
372
|
+
mainForwardFn = win;
|
|
373
|
+
forwardProps.split(".").map(((_, i, arr) => {
|
|
374
|
+
mainForwardFn = mainForwardFn[arr[i]] = i + 1 < len(arr) ? mainForwardFn[arr[i]] || ("push" === arr[i + 1] ? [] : {}) : (...args) => forwardCall(arr, args);
|
|
375
|
+
}));
|
|
376
|
+
}));
|
|
377
|
+
if (queuedForwardCalls) {
|
|
378
|
+
for (i = 0; i < len(queuedForwardCalls); i += 2) {
|
|
379
|
+
forwardCall(queuedForwardCalls[i], queuedForwardCalls[i + 1]);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
})(worker, $winId$, win);
|
|
383
|
+
doc.dispatchEvent(new CustomEvent("pt0"));
|
|
384
|
+
{
|
|
385
|
+
const winType = win === win.top ? "top" : "iframe";
|
|
386
|
+
logMain(`Executed ${winType} window ${normalizedWinId($winId$)} environment scripts in ${(performance.now() - winCtx.$startTime$).toFixed(1)}ms`);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
worker.postMessage([ 8, $winId$ ]);
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
392
|
+
requestAnimationFrame((() => readNextScript(worker, winCtx)));
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
const onMessageFromWebWorker = (worker, msg, winCtx) => {
|
|
396
|
+
if (4 === msg[0]) {
|
|
397
|
+
registerWindow(worker, randomId(), mainWindow);
|
|
398
|
+
} else {
|
|
399
|
+
winCtx = winCtxs[msg[1]];
|
|
400
|
+
winCtx && (7 === msg[0] ? requestAnimationFrame((() => readNextScript(worker, winCtx))) : 6 === msg[0] && ((worker, winCtx, instanceId, errorMsg, scriptElm) => {
|
|
401
|
+
scriptElm = winCtx.$window$.document.querySelector(`[data-ptid="${instanceId}"]`);
|
|
402
|
+
if (scriptElm) {
|
|
403
|
+
errorMsg ? scriptElm.dataset.pterror = errorMsg : scriptElm.type += "-x";
|
|
404
|
+
delete scriptElm.dataset.ptid;
|
|
405
|
+
}
|
|
406
|
+
readNextScript(worker, winCtx);
|
|
407
|
+
})(worker, winCtx, msg[2], msg[3]));
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
const readMainInterfaces = () => {
|
|
411
|
+
const elms = Object.getOwnPropertyNames(mainWindow).map((interfaceName => ((doc, interfaceName, r, tag) => {
|
|
412
|
+
r = interfaceName.match(/^(HTML|SVG)(.+)Element$/);
|
|
413
|
+
if (r) {
|
|
414
|
+
tag = r[2];
|
|
415
|
+
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);
|
|
416
|
+
}
|
|
417
|
+
})(docImpl, interfaceName))).filter((elm => elm)).map((elm => [ elm ]));
|
|
418
|
+
return readImplementations(elms, []);
|
|
419
|
+
};
|
|
420
|
+
const cstrs = new Set([ "Object" ]);
|
|
421
|
+
const readImplementations = (impls, interfaces) => {
|
|
422
|
+
const cstrImpls = impls.filter((implData => implData[0])).map((implData => {
|
|
423
|
+
const impl = implData[0];
|
|
424
|
+
const interfaceType = implData[1];
|
|
425
|
+
const cstrName = getConstructorName(impl);
|
|
426
|
+
const CstrPrototype = mainWindow[cstrName].prototype;
|
|
427
|
+
return [ cstrName, CstrPrototype, impl, interfaceType ];
|
|
428
|
+
}));
|
|
429
|
+
cstrImpls.map((([cstrName, CstrPrototype, impl, intefaceType]) => readOwnImplementation(cstrs, interfaces, cstrName, CstrPrototype, impl, intefaceType)));
|
|
430
|
+
return interfaces;
|
|
431
|
+
};
|
|
432
|
+
const readImplementation = (cstrName, impl, memberName) => {
|
|
433
|
+
let interfaceMembers = [];
|
|
434
|
+
let interfaceInfo = [ cstrName, "Object", interfaceMembers ];
|
|
435
|
+
for (memberName in impl) {
|
|
436
|
+
readImplementationMember(interfaceMembers, impl, memberName);
|
|
437
|
+
}
|
|
438
|
+
return interfaceInfo;
|
|
439
|
+
};
|
|
440
|
+
const readOwnImplementation = (cstrs, interfaces, cstrName, CstrPrototype, impl, interfaceType) => {
|
|
441
|
+
if (!cstrs.has(cstrName)) {
|
|
442
|
+
cstrs.add(cstrName);
|
|
443
|
+
const SuperCstr = Object.getPrototypeOf(CstrPrototype);
|
|
444
|
+
const superCstrName = getConstructorName(SuperCstr);
|
|
445
|
+
const interfaceMembers = [];
|
|
446
|
+
const propDescriptors = Object.getOwnPropertyDescriptors(CstrPrototype);
|
|
447
|
+
readOwnImplementation(cstrs, interfaces, superCstrName, SuperCstr, impl, interfaceType);
|
|
448
|
+
for (const memberName in propDescriptors) {
|
|
449
|
+
readImplementationMember(interfaceMembers, impl, memberName);
|
|
450
|
+
}
|
|
451
|
+
interfaces.push([ cstrName, superCstrName, interfaceMembers, interfaceType, getNodeName(impl) ]);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
const readImplementationMember = (interfaceMembers, implementation, memberName, value, memberType, cstrName) => {
|
|
455
|
+
try {
|
|
456
|
+
if (isValidMemberName(memberName) && isNaN(memberName[0]) && "all" !== memberName) {
|
|
457
|
+
value = implementation[memberName];
|
|
458
|
+
memberType = typeof value;
|
|
459
|
+
if ("function" === memberType) {
|
|
460
|
+
(String(value).includes("[native") || Object.getPrototypeOf(implementation)[memberName]) && interfaceMembers.push([ memberName, 5 ]);
|
|
461
|
+
} else if ("object" === memberType && null != value) {
|
|
462
|
+
cstrName = getConstructorName(value);
|
|
463
|
+
"Object" !== cstrName && self[cstrName] && interfaceMembers.push([ memberName, value.nodeType || cstrName ]);
|
|
464
|
+
} else {
|
|
465
|
+
"symbol" !== memberType && (memberName.toUpperCase() === memberName ? interfaceMembers.push([ memberName, 6, value ]) : interfaceMembers.push([ memberName, 6 ]));
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
} catch (e) {
|
|
469
|
+
console.warn(e);
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
const readStorage = storageName => {
|
|
473
|
+
let items = [];
|
|
474
|
+
let i = 0;
|
|
475
|
+
let l = len(mainWindow[storageName]);
|
|
476
|
+
let key;
|
|
477
|
+
for (;i < l; i++) {
|
|
478
|
+
key = mainWindow[storageName].key(i);
|
|
479
|
+
items.push([ key, mainWindow[storageName].getItem(key) ]);
|
|
480
|
+
}
|
|
481
|
+
return items;
|
|
482
|
+
};
|
|
483
|
+
const getGlobalConstructor = (mainWindow, cstrName) => void 0 !== mainWindow[cstrName] ? new mainWindow[cstrName](noop) : 0;
|
|
484
|
+
const addGlobalConstructorUsingPrototype = ($interfaces$, mainWindow, cstrName) => {
|
|
485
|
+
void 0 !== mainWindow[cstrName] && $interfaces$.push([ cstrName, "Object", Object.keys(mainWindow[cstrName].prototype).map((propName => [ propName, 6 ])), 12 ]);
|
|
486
|
+
};
|
|
487
|
+
let worker;
|
|
488
|
+
(async receiveMessage => {
|
|
489
|
+
const sharedDataBuffer = new SharedArrayBuffer(1073741824);
|
|
490
|
+
const sharedData = new Int32Array(sharedDataBuffer);
|
|
491
|
+
return (worker, msg) => {
|
|
492
|
+
const msgType = msg[0];
|
|
493
|
+
const accessReq = msg[1];
|
|
494
|
+
if (0 === msgType) {
|
|
495
|
+
const initData = (() => {
|
|
496
|
+
const elm = docImpl.createElement("i");
|
|
497
|
+
const textNode = docImpl.createTextNode("");
|
|
498
|
+
const comment = docImpl.createComment("");
|
|
499
|
+
const frag = docImpl.createDocumentFragment();
|
|
500
|
+
const shadowRoot = docImpl.createElement("p").attachShadow({
|
|
501
|
+
mode: "open"
|
|
502
|
+
});
|
|
503
|
+
const intersectionObserver = getGlobalConstructor(mainWindow, "IntersectionObserver");
|
|
504
|
+
const mutationObserver = getGlobalConstructor(mainWindow, "MutationObserver");
|
|
505
|
+
const resizeObserver = getGlobalConstructor(mainWindow, "ResizeObserver");
|
|
506
|
+
const perf = mainWindow.performance;
|
|
507
|
+
const screen = mainWindow.screen;
|
|
508
|
+
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 ] ];
|
|
509
|
+
const initialInterfaces = [ readImplementation("Window", mainWindow), readImplementation("Node", textNode) ];
|
|
510
|
+
const $config$ = JSON.stringify(config, ((k, v) => {
|
|
511
|
+
if ("function" == typeof v) {
|
|
512
|
+
v = String(v);
|
|
513
|
+
v.startsWith(k + "(") && (v = "function " + v);
|
|
514
|
+
}
|
|
515
|
+
return v;
|
|
516
|
+
}));
|
|
517
|
+
const initWebWorkerData = {
|
|
518
|
+
$config$: $config$,
|
|
519
|
+
$interfaces$: readImplementations(impls, initialInterfaces),
|
|
520
|
+
$libPath$: new URL(libPath, mainWindow.location) + "",
|
|
521
|
+
$origin$: origin,
|
|
522
|
+
$localStorage$: readStorage("localStorage"),
|
|
523
|
+
$sessionStorage$: readStorage("sessionStorage")
|
|
524
|
+
};
|
|
525
|
+
addGlobalConstructorUsingPrototype(initWebWorkerData.$interfaces$, mainWindow, "IntersectionObserverEntry");
|
|
526
|
+
return initWebWorkerData;
|
|
527
|
+
})();
|
|
528
|
+
initData.$sharedDataBuffer$ = sharedDataBuffer;
|
|
529
|
+
worker.postMessage([ 1, initData ]);
|
|
530
|
+
} else {
|
|
531
|
+
2 === msg[0] ? worker.postMessage([ 3, readMainInterfaces() ]) : 11 === msgType ? receiveMessage(accessReq, (accessRsp => {
|
|
532
|
+
const stringifiedData = JSON.stringify(accessRsp);
|
|
533
|
+
const stringifiedDataLength = stringifiedData.length;
|
|
534
|
+
for (let i = 0; i < stringifiedDataLength; i++) {
|
|
535
|
+
sharedData[i + 1] = stringifiedData.charCodeAt(i);
|
|
536
|
+
}
|
|
537
|
+
sharedData[0] = stringifiedDataLength;
|
|
538
|
+
Atomics.notify(sharedData, 0);
|
|
539
|
+
})) : onMessageFromWebWorker(worker, msg);
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
})(((accessReq, responseCallback) => mainAccessHandler(worker, accessReq).then(responseCallback))).then((onMessageHandler => {
|
|
543
|
+
if (onMessageHandler) {
|
|
544
|
+
worker = new Worker(libPath + "partytown-ww-atomics.js?v=0.6.4", {
|
|
545
|
+
name: "Partytown 🎉"
|
|
546
|
+
});
|
|
547
|
+
worker.onmessage = ev => {
|
|
548
|
+
const msg = ev.data;
|
|
549
|
+
12 === msg[0] ? mainAccessHandler(worker, msg[1]) : onMessageHandler(worker, msg);
|
|
550
|
+
};
|
|
551
|
+
logMain("Created Partytown web worker (0.6.4)");
|
|
552
|
+
worker.onerror = ev => console.error("Web Worker Error", ev);
|
|
553
|
+
mainWindow.addEventListener("pt1", (ev => registerWindow(worker, getAndSetInstanceId(ev.detail.frameElement), ev.detail)));
|
|
554
|
+
}
|
|
555
|
+
}));
|
|
556
|
+
})(window);
|