unpeek 2.0.0 → 4.0.0

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.
Files changed (120) hide show
  1. package/README.md +57 -21
  2. package/README.tr.md +65 -29
  3. package/dist/adapters/esbuild.cjs +13 -0
  4. package/dist/adapters/esbuild.d.cts +13 -0
  5. package/dist/adapters/esbuild.d.ts +11 -0
  6. package/dist/adapters/esbuild.js +13 -0
  7. package/dist/adapters/next/adapter.cjs +43 -0
  8. package/dist/{next → adapters/next}/adapter.d.cts +4 -4
  9. package/dist/{next → adapters/next}/adapter.d.ts +4 -4
  10. package/dist/adapters/next/adapter.js +43 -0
  11. package/dist/adapters/next/index.cjs +16 -0
  12. package/dist/adapters/next/index.d.cts +53 -0
  13. package/dist/adapters/next/index.d.ts +53 -0
  14. package/dist/adapters/next/index.js +16 -0
  15. package/dist/adapters/rollup.cjs +13 -0
  16. package/dist/adapters/rollup.d.cts +13 -0
  17. package/dist/adapters/rollup.d.ts +11 -0
  18. package/dist/adapters/rollup.js +13 -0
  19. package/dist/adapters/rspack.cjs +13 -0
  20. package/dist/adapters/rspack.d.cts +13 -0
  21. package/dist/adapters/rspack.d.ts +11 -0
  22. package/dist/adapters/rspack.js +13 -0
  23. package/dist/adapters/vite.cjs +13 -0
  24. package/dist/adapters/vite.d.cts +13 -0
  25. package/dist/adapters/vite.d.ts +11 -0
  26. package/dist/adapters/vite.js +13 -0
  27. package/dist/adapters/webpack.cjs +13 -0
  28. package/dist/adapters/webpack.d.cts +13 -0
  29. package/dist/adapters/webpack.d.ts +11 -0
  30. package/dist/adapters/webpack.js +13 -0
  31. package/dist/browser.cjs +8 -5
  32. package/dist/browser.d.cts +44 -3
  33. package/dist/browser.d.ts +44 -3
  34. package/dist/browser.js +10 -7
  35. package/dist/{chunk-5QD6FZPB.js → chunk-2JU3V7HW.js} +75 -43
  36. package/dist/chunk-3LWXEJU6.cjs +1054 -0
  37. package/dist/chunk-4FNZNIBW.js +7391 -0
  38. package/dist/chunk-7HXLHLLQ.cjs +503 -0
  39. package/dist/chunk-ADKRENAP.js +1054 -0
  40. package/dist/chunk-EN6QVR6P.js +89 -0
  41. package/dist/chunk-HHC7BUCK.js +503 -0
  42. package/dist/chunk-KLYFNMKS.cjs +7391 -0
  43. package/dist/chunk-L6BOM5VS.cjs +40 -0
  44. package/dist/{chunk-OOXSZTRV.js → chunk-LA6J3BT3.js} +26 -1
  45. package/dist/chunk-URPPSTHZ.cjs +89 -0
  46. package/dist/chunk-VG4Y26ZN.cjs +429 -0
  47. package/dist/{chunk-GZB7PFLY.js → chunk-W77DAC3H.js} +46 -64
  48. package/dist/chunk-X6EETCO6.cjs +352 -0
  49. package/dist/chunk-YCRMTXOE.js +429 -0
  50. package/dist/{chunk-GAVI2C44.cjs → chunk-ZG7BIAUI.cjs} +80 -48
  51. package/dist/cli/index.js +9861 -32
  52. package/dist/{types-BBSRUEab.d.cts → config-Y6JwVGwX.d.cts} +58 -86
  53. package/dist/{types-BBSRUEab.d.ts → config-Y6JwVGwX.d.ts} +58 -86
  54. package/dist/config.cjs +4 -16
  55. package/dist/config.d.cts +1 -12
  56. package/dist/config.d.ts +1 -12
  57. package/dist/config.js +5 -17
  58. package/dist/index-0O1WSfVP.d.ts +52 -0
  59. package/dist/index-COVHErnx.d.cts +52 -0
  60. package/dist/index.cjs +437 -9
  61. package/dist/index.d.cts +9 -17
  62. package/dist/index.d.ts +9 -17
  63. package/dist/index.js +438 -10
  64. package/dist/plugins/unplugin.cjs +21 -0
  65. package/dist/plugins/unplugin.d.cts +17 -0
  66. package/dist/plugins/unplugin.d.ts +15 -0
  67. package/dist/{bundler → plugins}/unplugin.js +6 -5
  68. package/dist/types-CMtZnV8C.d.ts +112 -0
  69. package/dist/types-D93PuOOl.d.cts +112 -0
  70. package/package.json +48 -52
  71. package/dist/ast/index.cjs +0 -17
  72. package/dist/ast/index.d.cts +0 -18
  73. package/dist/ast/index.d.ts +0 -18
  74. package/dist/ast/index.js +0 -17
  75. package/dist/bundler/unplugin.cjs +0 -20
  76. package/dist/bundler/unplugin.d.cts +0 -16
  77. package/dist/bundler/unplugin.d.ts +0 -14
  78. package/dist/chunk-24K5NDXH.cjs +0 -370
  79. package/dist/chunk-27HR647Q.js +0 -190
  80. package/dist/chunk-4TDLLEEU.cjs +0 -15
  81. package/dist/chunk-5LCMI2TL.js +0 -575
  82. package/dist/chunk-5M6Z7ZFT.cjs +0 -83
  83. package/dist/chunk-6N6S6WTQ.cjs +0 -423
  84. package/dist/chunk-7YVEHJVM.cjs +0 -575
  85. package/dist/chunk-J5CGNZDM.cjs +0 -190
  86. package/dist/chunk-KQWNFKT2.js +0 -423
  87. package/dist/chunk-LXP73HJC.cjs +0 -4532
  88. package/dist/chunk-R6EBIR3T.cjs +0 -14
  89. package/dist/chunk-S4S2WXGC.js +0 -14
  90. package/dist/chunk-UMPUYLLZ.js +0 -4532
  91. package/dist/chunk-X5MKMFMX.js +0 -83
  92. package/dist/cli/index.cjs +0 -324
  93. package/dist/cli/index.d.cts +0 -22
  94. package/dist/cli/index.d.ts +0 -22
  95. package/dist/esbuild.cjs +0 -15
  96. package/dist/esbuild.d.cts +0 -11
  97. package/dist/esbuild.d.ts +0 -11
  98. package/dist/esbuild.js +0 -13
  99. package/dist/next/adapter.cjs +0 -31
  100. package/dist/next/adapter.js +0 -31
  101. package/dist/next/index.cjs +0 -18
  102. package/dist/next/index.d.cts +0 -42
  103. package/dist/next/index.d.ts +0 -42
  104. package/dist/next/index.js +0 -18
  105. package/dist/rollup.cjs +0 -15
  106. package/dist/rollup.d.cts +0 -11
  107. package/dist/rollup.d.ts +0 -11
  108. package/dist/rollup.js +0 -13
  109. package/dist/runtime/index.cjs +0 -17
  110. package/dist/runtime/index.d.cts +0 -36
  111. package/dist/runtime/index.d.ts +0 -36
  112. package/dist/runtime/index.js +0 -17
  113. package/dist/vite.cjs +0 -15
  114. package/dist/vite.d.cts +0 -11
  115. package/dist/vite.d.ts +0 -11
  116. package/dist/vite.js +0 -13
  117. package/dist/webpack.cjs +0 -15
  118. package/dist/webpack.d.cts +0 -11
  119. package/dist/webpack.d.ts +0 -11
  120. package/dist/webpack.js +0 -13
@@ -1,4532 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
-
4
-
5
-
6
-
7
-
8
- var _chunk6N6S6WTQcjs = require('./chunk-6N6S6WTQ.cjs');
9
-
10
-
11
- var _chunkR6EBIR3Tcjs = require('./chunk-R6EBIR3T.cjs');
12
-
13
- // src/ast/hot-path-detector.ts
14
- var _acorn = require('acorn'); var acorn = _interopRequireWildcard(_acorn); var acorn4 = _interopRequireWildcard(_acorn); var acorn3 = _interopRequireWildcard(_acorn); var acorn2 = _interopRequireWildcard(_acorn); var acorn5 = _interopRequireWildcard(_acorn);
15
- var _acornwalk = require('acorn-walk'); var walk = _interopRequireWildcard(_acornwalk); var walk3 = _interopRequireWildcard(_acornwalk); var walk2 = _interopRequireWildcard(_acornwalk); var walk4 = _interopRequireWildcard(_acornwalk); var walk5 = _interopRequireWildcard(_acornwalk); var walk6 = _interopRequireWildcard(_acornwalk);
16
- var ARRAY_HOF_METHODS = /* @__PURE__ */ new Set([
17
- "map",
18
- "filter",
19
- "reduce",
20
- "forEach",
21
- "flatMap",
22
- "find",
23
- "findIndex",
24
- "some",
25
- "every"
26
- ]);
27
- var ANIMATION_FRAME_CALLS = /* @__PURE__ */ new Set([
28
- "requestAnimationFrame",
29
- "cancelAnimationFrame",
30
- "useFrame",
31
- "useLenis",
32
- "setAnimationLoop",
33
- "onBeforeRender",
34
- "updateMatrixWorld",
35
- "raf"
36
- ]);
37
- var DEFAULT_IMPORT_SOURCES = {
38
- "@react-three/fiber": ["useFrame"],
39
- lenis: ["useLenis", "raf"],
40
- "lenis/react": ["useLenis"],
41
- three: ["onBeforeRender", "updateMatrixWorld", "useFrame"],
42
- gsap: ["ticker"]
43
- };
44
- var DEFAULT_HOC_WRAPPERS = /* @__PURE__ */ new Set([
45
- "memo",
46
- "forwardRef",
47
- "React.memo",
48
- "React.forwardRef",
49
- "observer",
50
- "connect"
51
- ]);
52
- var DEFAULT_EVENT_HANDLER_REGEX = /^(?:on|handle)(?!Tick|Render|Update|Frame|Animate|Physics)[A-Z]/;
53
- var DEFAULT_HOOK_REGEX = /^use[A-Z0-9]/;
54
- var REACT_HOOK_OR_RENDER_CALLS = /* @__PURE__ */ new Set([
55
- "useState",
56
- "useEffect",
57
- "useMemo",
58
- "useCallback",
59
- "useRef",
60
- "useLayoutEffect",
61
- "useActionState",
62
- "useFormStatus",
63
- "useOptimistic",
64
- "jsx",
65
- "jsxs",
66
- "_jsx",
67
- "_jsxs",
68
- "createElement"
69
- ]);
70
- var FUNCTION_NODE_TYPES = /* @__PURE__ */ new Set([
71
- "FunctionDeclaration",
72
- "FunctionExpression",
73
- "ArrowFunctionExpression"
74
- ]);
75
- function parseJavaScriptAst(code) {
76
- try {
77
- return acorn.parse(code, {
78
- ecmaVersion: "latest",
79
- sourceType: "module",
80
- allowReturnOutsideFunction: true
81
- });
82
- } catch (e) {
83
- try {
84
- return acorn.parse(code, {
85
- ecmaVersion: "latest",
86
- sourceType: "script",
87
- allowReturnOutsideFunction: true
88
- });
89
- } catch (e2) {
90
- return null;
91
- }
92
- }
93
- }
94
- function isHocCall(callNode, hocWrappers) {
95
- if (!callNode || callNode.type !== "CallExpression") return false;
96
- const callee = callNode.callee;
97
- if (!callee) return false;
98
- const wrappers = _nullishCoalesce(hocWrappers, () => ( DEFAULT_HOC_WRAPPERS));
99
- if (callee.type === "Identifier") {
100
- return wrappers.has(callee.name);
101
- }
102
- if (callee.type === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _ => _.property, 'optionalAccess', _2 => _2.type]) === "Identifier") {
103
- if (wrappers.has(callee.property.name)) return true;
104
- if (_optionalChain([callee, 'access', _3 => _3.object, 'optionalAccess', _4 => _4.type]) === "Identifier") {
105
- const full2 = `${callee.object.name}.${callee.property.name}`;
106
- if (wrappers.has(full2)) return true;
107
- }
108
- }
109
- return false;
110
- }
111
- function getFunctionLabel(node, ancestors, hocWrappers) {
112
- if (node.id && typeof node.id.name === "string") {
113
- return node.id.name;
114
- }
115
- const parent = ancestors[ancestors.length - 2];
116
- if (parent) {
117
- if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _5 => _5.id, 'optionalAccess', _6 => _6.type]) === "Identifier") {
118
- return parent.id.name;
119
- }
120
- if (parent.type === "Property") {
121
- if (_optionalChain([parent, 'access', _7 => _7.key, 'optionalAccess', _8 => _8.type]) === "Identifier") {
122
- return parent.key.name;
123
- }
124
- if (_optionalChain([parent, 'access', _9 => _9.key, 'optionalAccess', _10 => _10.type]) === "Literal" && typeof parent.key.value === "string") {
125
- return parent.key.value;
126
- }
127
- }
128
- if (parent.type === "MethodDefinition" && _optionalChain([parent, 'access', _11 => _11.key, 'optionalAccess', _12 => _12.type]) === "Identifier") {
129
- return parent.key.name;
130
- }
131
- if (parent.type === "AssignmentExpression" && _optionalChain([parent, 'access', _13 => _13.left, 'optionalAccess', _14 => _14.type]) === "Identifier") {
132
- return parent.left.name;
133
- }
134
- if (parent.type === "CallExpression") {
135
- let idx = ancestors.length - 2;
136
- let matchedHoc = false;
137
- while (idx >= 0 && ancestors[idx].type === "CallExpression") {
138
- if (isHocCall(ancestors[idx], hocWrappers)) {
139
- matchedHoc = true;
140
- idx--;
141
- } else {
142
- break;
143
- }
144
- }
145
- if (matchedHoc && idx >= 0) {
146
- const outer = ancestors[idx];
147
- if (outer.type === "VariableDeclarator" && _optionalChain([outer, 'access', _15 => _15.id, 'optionalAccess', _16 => _16.type]) === "Identifier") {
148
- return outer.id.name;
149
- }
150
- if (outer.type === "AssignmentExpression" && _optionalChain([outer, 'access', _17 => _17.left, 'optionalAccess', _18 => _18.type]) === "Identifier") {
151
- return outer.left.name;
152
- }
153
- }
154
- }
155
- }
156
- return `anonymous_${node.start}`;
157
- }
158
- function isPascalCaseComponent(name) {
159
- return /^[A-Z][a-zA-Z0-9]*$/.test(name);
160
- }
161
- function isEventHandlerName(name, regex = DEFAULT_EVENT_HANDLER_REGEX) {
162
- return regex.test(name);
163
- }
164
- function findEnclosingScopeNode(ancestors, selfNode) {
165
- for (let i = ancestors.length - 1; i >= 0; i--) {
166
- const anc = ancestors[i];
167
- if (anc !== selfNode && (FUNCTION_NODE_TYPES.has(anc.type) || anc.type === "Program")) {
168
- return anc;
169
- }
170
- }
171
- return ancestors[0];
172
- }
173
- function findEnclosingFunction(ancestors, selfNode) {
174
- for (let i = ancestors.length - 1; i >= 0; i--) {
175
- if (ancestors[i] !== selfNode && FUNCTION_NODE_TYPES.has(ancestors[i].type)) {
176
- return ancestors[i];
177
- }
178
- }
179
- return null;
180
- }
181
- function findOutermostModuleFunction(ancestors) {
182
- const fnList = [];
183
- for (let i = 0; i < ancestors.length; i++) {
184
- if (FUNCTION_NODE_TYPES.has(ancestors[i].type)) {
185
- fnList.push(ancestors[i]);
186
- }
187
- }
188
- if (fnList.length === 0) return null;
189
- if (fnList.length === 1) return fnList[0];
190
- return fnList[1];
191
- }
192
- function isZeroArgIifeFactoryFunction(node) {
193
- if (!node || node.params && node.params.length > 0) return false;
194
- if (!node.body || node.body.type !== "BlockStatement") return false;
195
- const stmts = (node.body.body || []).filter(
196
- (s) => !(s.type === "ExpressionStatement" && s.directive)
197
- );
198
- if (stmts.length !== 1 || stmts[0].type !== "ReturnStatement") return false;
199
- const retArg = stmts[0].argument;
200
- if (!retArg || retArg.type !== "CallExpression") return false;
201
- const callee = retArg.callee;
202
- return callee && (callee.type === "FunctionExpression" || callee.type === "ArrowFunctionExpression") && _optionalChain([callee, 'access', _19 => _19.body, 'optionalAccess', _20 => _20.type]) === "BlockStatement";
203
- }
204
- function containsLoopOrAnimation(fnNode, animationCalls = ANIMATION_FRAME_CALLS) {
205
- let found = false;
206
- walk.simple(fnNode, {
207
- ForStatement() {
208
- found = true;
209
- },
210
- ForInStatement() {
211
- found = true;
212
- },
213
- ForOfStatement() {
214
- found = true;
215
- },
216
- WhileStatement() {
217
- found = true;
218
- },
219
- DoWhileStatement() {
220
- found = true;
221
- },
222
- CallExpression(callNode) {
223
- let cName = "";
224
- let mProp = "";
225
- if (_optionalChain([callNode, 'access', _21 => _21.callee, 'optionalAccess', _22 => _22.type]) === "Identifier") {
226
- cName = callNode.callee.name;
227
- } else if (_optionalChain([callNode, 'access', _23 => _23.callee, 'optionalAccess', _24 => _24.type]) === "MemberExpression" && !callNode.callee.computed && _optionalChain([callNode, 'access', _25 => _25.callee, 'access', _26 => _26.property, 'optionalAccess', _27 => _27.type]) === "Identifier") {
228
- mProp = callNode.callee.property.name;
229
- }
230
- const isTickerAdd = mProp === "add" && (_optionalChain([callNode, 'access', _28 => _28.callee, 'optionalAccess', _29 => _29.object, 'optionalAccess', _30 => _30.name]) === "ticker" || _optionalChain([callNode, 'access', _31 => _31.callee, 'optionalAccess', _32 => _32.object, 'optionalAccess', _33 => _33.property, 'optionalAccess', _34 => _34.name]) === "ticker");
231
- if (animationCalls.has(cName) || animationCalls.has(mProp) || isTickerAdd) {
232
- found = true;
233
- }
234
- }
235
- });
236
- return found;
237
- }
238
- function analyzeAstHotPaths(ast, config) {
239
- const hotFunctionNodes = /* @__PURE__ */ new WeakSet();
240
- const coldFunctionNodes = /* @__PURE__ */ new WeakSet();
241
- const hotExemptNodes = /* @__PURE__ */ new WeakSet();
242
- const serializedFunctionNodes = /* @__PURE__ */ new WeakSet();
243
- const serializedWorkerNodes = /* @__PURE__ */ new Set();
244
- const trueHotNodes = /* @__PURE__ */ new Set();
245
- const shallowComponentNodes = /* @__PURE__ */ new Set();
246
- const coldForcedNodes = /* @__PURE__ */ new Set();
247
- const directHotNodes = /* @__PURE__ */ new Set();
248
- const serializerHelperNodes = /* @__PURE__ */ new Set();
249
- const allFunctions = [];
250
- const fnByName = /* @__PURE__ */ new Map();
251
- const scopeFunctions = /* @__PURE__ */ new Map();
252
- const fnScopeChain = /* @__PURE__ */ new Map();
253
- const fnParams = /* @__PURE__ */ new Map();
254
- const fnVarAliases = /* @__PURE__ */ new Map();
255
- const callerToCallees = /* @__PURE__ */ new Map();
256
- const pendingSerializedRefs = [];
257
- const pendingHotRefs = [];
258
- const allCallSites = [];
259
- const animationCalls = new Set(ANIMATION_FRAME_CALLS);
260
- if (_optionalChain([config, 'optionalAccess', _35 => _35.hotPath, 'optionalAccess', _36 => _36.customAnimationCalls])) {
261
- for (const c of config.hotPath.customAnimationCalls) {
262
- animationCalls.add(c);
263
- }
264
- }
265
- const mergedImportSources = {
266
- ...DEFAULT_IMPORT_SOURCES,
267
- ..._nullishCoalesce(_optionalChain([config, 'optionalAccess', _37 => _37.hotPath, 'optionalAccess', _38 => _38.importSources]), () => ( {}))
268
- };
269
- if (ast && Array.isArray(ast.body)) {
270
- for (const stmt of ast.body) {
271
- if (stmt.type === "ImportDeclaration" && _optionalChain([stmt, 'access', _39 => _39.source, 'optionalAccess', _40 => _40.value])) {
272
- const sourcePkg = String(stmt.source.value);
273
- const sourceMethods = mergedImportSources[sourcePkg];
274
- for (const spec of stmt.specifiers || []) {
275
- if (spec.type === "ImportSpecifier") {
276
- const importedName = _nullishCoalesce(_optionalChain([spec, 'access', _41 => _41.imported, 'optionalAccess', _42 => _42.name]), () => ( _optionalChain([spec, 'access', _43 => _43.imported, 'optionalAccess', _44 => _44.value])));
277
- const localName = _optionalChain([spec, 'access', _45 => _45.local, 'optionalAccess', _46 => _46.name]);
278
- if (localName && importedName) {
279
- const isKnownSource = sourceMethods !== void 0;
280
- const isListedMethod = sourceMethods && (sourceMethods.includes(importedName) || sourceMethods.includes("*"));
281
- const isKnownAnimCall = ANIMATION_FRAME_CALLS.has(importedName);
282
- if (isKnownSource && isListedMethod || isKnownAnimCall) {
283
- animationCalls.add(localName);
284
- }
285
- }
286
- }
287
- }
288
- }
289
- }
290
- }
291
- const hocWrappers = new Set(DEFAULT_HOC_WRAPPERS);
292
- if (_optionalChain([config, 'optionalAccess', _47 => _47.hotPath, 'optionalAccess', _48 => _48.hocWrappers])) {
293
- for (const h of config.hotPath.hocWrappers) {
294
- hocWrappers.add(h);
295
- }
296
- }
297
- const arrayHofMethods = new Set(ARRAY_HOF_METHODS);
298
- if (_optionalChain([config, 'optionalAccess', _49 => _49.hotPath, 'optionalAccess', _50 => _50.arrayHofMethods])) {
299
- for (const m of config.hotPath.arrayHofMethods) {
300
- arrayHofMethods.add(m);
301
- }
302
- }
303
- const eventHandlerRegex = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _51 => _51.hotPath, 'optionalAccess', _52 => _52.eventHandlerRegex]), () => ( DEFAULT_EVENT_HANDLER_REGEX));
304
- const hookRegex = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _53 => _53.hotPath, 'optionalAccess', _54 => _54.hookPattern]), () => ( DEFAULT_HOOK_REGEX));
305
- const customHooksSet = new Set(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _55 => _55.hotPath, 'optionalAccess', _56 => _56.customHooks]), () => ( [])));
306
- function isHookName(name) {
307
- if (!name) return false;
308
- return customHooksSet.has(name) || hookRegex.test(name);
309
- }
310
- const excludedComponents = new Set(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _57 => _57.hotPath, 'optionalAccess', _58 => _58.excludeComponents]), () => ( [])));
311
- const maxPipelineCallers = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _59 => _59.hotPath, 'optionalAccess', _60 => _60.maxPipelineCallers]), () => ( 2));
312
- function ensureFnParams(fnNode) {
313
- let paramSet = fnParams.get(fnNode);
314
- if (!paramSet) {
315
- paramSet = /* @__PURE__ */ new Set();
316
- for (const p of fnNode.params || []) {
317
- if (_optionalChain([p, 'optionalAccess', _61 => _61.type]) === "Identifier") {
318
- paramSet.add(p.name);
319
- } else if (_optionalChain([p, 'optionalAccess', _62 => _62.type]) === "AssignmentPattern" && _optionalChain([p, 'access', _63 => _63.left, 'optionalAccess', _64 => _64.type]) === "Identifier") {
320
- paramSet.add(p.left.name);
321
- }
322
- }
323
- fnParams.set(fnNode, paramSet);
324
- }
325
- return paramSet;
326
- }
327
- function recordVarAlias(scopeNode, varName, rhsName) {
328
- let map = fnVarAliases.get(scopeNode);
329
- if (!map) {
330
- map = /* @__PURE__ */ new Map();
331
- fnVarAliases.set(scopeNode, map);
332
- }
333
- map.set(varName, rhsName);
334
- }
335
- function resolveAliasTarget(scopeNode, identName) {
336
- const map = fnVarAliases.get(scopeNode);
337
- let cur = identName;
338
- const seen = /* @__PURE__ */ new Set();
339
- while (map && map.has(cur) && !seen.has(cur)) {
340
- seen.add(cur);
341
- cur = map.get(cur);
342
- }
343
- return cur;
344
- }
345
- function markSerializedFunction(node) {
346
- node._unpeekSerialized = true;
347
- serializedWorkerNodes.add(node);
348
- serializedFunctionNodes.add(node);
349
- hotFunctionNodes.add(node);
350
- directHotNodes.add(node);
351
- hotExemptNodes.add(node);
352
- }
353
- function registerFunctionNode(node, ancestors) {
354
- const name = getFunctionLabel(node, ancestors, hocWrappers);
355
- allFunctions.push({ node, name });
356
- fnByName.set(name, node);
357
- const paramSet = /* @__PURE__ */ new Set();
358
- for (const p of node.params || []) {
359
- if (_optionalChain([p, 'optionalAccess', _65 => _65.type]) === "Identifier") {
360
- paramSet.add(p.name);
361
- } else if (_optionalChain([p, 'optionalAccess', _66 => _66.type]) === "AssignmentPattern" && _optionalChain([p, 'access', _67 => _67.left, 'optionalAccess', _68 => _68.type]) === "Identifier") {
362
- paramSet.add(p.left.name);
363
- }
364
- }
365
- fnParams.set(node, paramSet);
366
- const enclosingScope = findEnclosingScopeNode(ancestors, node);
367
- let localMap = scopeFunctions.get(enclosingScope);
368
- if (!localMap) {
369
- localMap = /* @__PURE__ */ new Map();
370
- scopeFunctions.set(enclosingScope, localMap);
371
- }
372
- localMap.set(name, node);
373
- const parent = ancestors[ancestors.length - 2];
374
- if (_optionalChain([parent, 'optionalAccess', _69 => _69.type]) === "VariableDeclarator" && _optionalChain([parent, 'access', _70 => _70.id, 'optionalAccess', _71 => _71.type]) === "Identifier") {
375
- fnByName.set(parent.id.name, node);
376
- localMap.set(parent.id.name, node);
377
- } else if (_optionalChain([parent, 'optionalAccess', _72 => _72.type]) === "AssignmentExpression" && _optionalChain([parent, 'access', _73 => _73.left, 'optionalAccess', _74 => _74.type]) === "Identifier") {
378
- fnByName.set(parent.left.name, node);
379
- localMap.set(parent.left.name, node);
380
- } else if (_optionalChain([parent, 'optionalAccess', _75 => _75.type]) === "AssignmentExpression" && _optionalChain([parent, 'access', _76 => _76.left, 'optionalAccess', _77 => _77.type]) === "MemberExpression" && !parent.left.computed && _optionalChain([parent, 'access', _78 => _78.left, 'access', _79 => _79.property, 'optionalAccess', _80 => _80.type]) === "Identifier") {
381
- const propName = parent.left.property.name;
382
- fnByName.set(propName, node);
383
- localMap.set(propName, node);
384
- if (_optionalChain([parent, 'access', _81 => _81.left, 'access', _82 => _82.object, 'optionalAccess', _83 => _83.type]) === "Identifier") {
385
- const qual = `${parent.left.object.name}.${propName}`;
386
- fnByName.set(qual, node);
387
- localMap.set(qual, node);
388
- }
389
- }
390
- const grandParent = ancestors[ancestors.length - 3];
391
- const greatGrandParent = ancestors[ancestors.length - 4];
392
- if (_optionalChain([parent, 'optionalAccess', _84 => _84.type]) === "Property" && _optionalChain([parent, 'access', _85 => _85.key, 'optionalAccess', _86 => _86.type]) === "Identifier" && _optionalChain([grandParent, 'optionalAccess', _87 => _87.type]) === "ObjectExpression" && _optionalChain([greatGrandParent, 'optionalAccess', _88 => _88.type]) === "VariableDeclarator" && _optionalChain([greatGrandParent, 'access', _89 => _89.id, 'optionalAccess', _90 => _90.type]) === "Identifier") {
393
- const qualified = `${greatGrandParent.id.name}.${parent.key.name}`;
394
- fnByName.set(qualified, node);
395
- localMap.set(qualified, node);
396
- }
397
- const chain = [];
398
- for (let i = ancestors.length - 1; i >= 0; i--) {
399
- if (ancestors[i] !== node && (FUNCTION_NODE_TYPES.has(ancestors[i].type) || ancestors[i].type === "Program")) {
400
- chain.push(ancestors[i]);
401
- }
402
- }
403
- fnScopeChain.set(node, chain);
404
- if (isPascalCaseComponent(name) && !excludedComponents.has(name)) {
405
- shallowComponentNodes.add(node);
406
- hotFunctionNodes.add(node);
407
- directHotNodes.add(node);
408
- hotExemptNodes.add(node);
409
- }
410
- if (isHookName(name)) {
411
- shallowComponentNodes.add(node);
412
- hotFunctionNodes.add(node);
413
- directHotNodes.add(node);
414
- hotExemptNodes.add(node);
415
- }
416
- if (isZeroArgIifeFactoryFunction(node)) {
417
- markSerializedFunction(node);
418
- }
419
- }
420
- function resolveCalleeNode(callerNode, calleeKey) {
421
- const directLocal = _optionalChain([scopeFunctions, 'access', _91 => _91.get, 'call', _92 => _92(callerNode), 'optionalAccess', _93 => _93.get, 'call', _94 => _94(calleeKey)]);
422
- if (directLocal) return directLocal;
423
- const chain = fnScopeChain.get(callerNode);
424
- if (chain) {
425
- for (const scopeNode of chain) {
426
- const localMap = scopeFunctions.get(scopeNode);
427
- const found = _optionalChain([localMap, 'optionalAccess', _95 => _95.get, 'call', _96 => _96(calleeKey)]);
428
- if (found) return found;
429
- }
430
- }
431
- return fnByName.get(calleeKey);
432
- }
433
- function queueSerializedTarget(target, enclosingScope) {
434
- if (!target) return;
435
- if (FUNCTION_NODE_TYPES.has(target.type)) {
436
- markSerializedFunction(target);
437
- } else if (target.type === "Identifier") {
438
- pendingSerializedRefs.push({ scopeNode: enclosingScope, name: target.name });
439
- } else if (target.type === "MemberExpression" && !target.computed && _optionalChain([target, 'access', _97 => _97.property, 'optionalAccess', _98 => _98.type]) === "Identifier") {
440
- pendingSerializedRefs.push({
441
- scopeNode: enclosingScope,
442
- name: target.property.name
443
- });
444
- if (_optionalChain([target, 'access', _99 => _99.object, 'optionalAccess', _100 => _100.type]) === "Identifier") {
445
- pendingSerializedRefs.push({
446
- scopeNode: enclosingScope,
447
- name: `${target.object.name}.${target.property.name}`
448
- });
449
- }
450
- }
451
- }
452
- walk.ancestor(ast, {
453
- FunctionDeclaration(node, _state, ancestors) {
454
- registerFunctionNode(node, ancestors);
455
- },
456
- FunctionExpression(node, _state, ancestors) {
457
- registerFunctionNode(node, ancestors);
458
- },
459
- ArrowFunctionExpression(node, _state, ancestors) {
460
- registerFunctionNode(node, ancestors);
461
- },
462
- VariableDeclarator(node, _state, ancestors) {
463
- if (_optionalChain([node, 'access', _101 => _101.id, 'optionalAccess', _102 => _102.type]) === "Identifier" && _optionalChain([node, 'access', _103 => _103.init, 'optionalAccess', _104 => _104.type]) === "Identifier") {
464
- const scopeNode = _nullishCoalesce(findEnclosingFunction(ancestors), () => ( ast));
465
- recordVarAlias(scopeNode, node.id.name, node.init.name);
466
- }
467
- },
468
- AssignmentExpression(node, _state, ancestors) {
469
- const left = node.left;
470
- if (_optionalChain([left, 'optionalAccess', _105 => _105.type]) === "Identifier" && _optionalChain([node, 'access', _106 => _106.right, 'optionalAccess', _107 => _107.type]) === "Identifier") {
471
- const scopeNode = _nullishCoalesce(findEnclosingFunction(ancestors), () => ( ast));
472
- recordVarAlias(scopeNode, left.name, node.right.name);
473
- }
474
- const isBareOnMessage = _optionalChain([left, 'optionalAccess', _108 => _108.type]) === "Identifier" && left.name === "onmessage";
475
- const isSelfOnMessage = _optionalChain([left, 'optionalAccess', _109 => _109.type]) === "MemberExpression" && !left.computed && _optionalChain([left, 'access', _110 => _110.object, 'optionalAccess', _111 => _111.type]) === "Identifier" && left.object.name === "self" && _optionalChain([left, 'access', _112 => _112.property, 'optionalAccess', _113 => _113.type]) === "Identifier" && left.property.name === "onmessage";
476
- if (isBareOnMessage || isSelfOnMessage) {
477
- const enclosingFn = findEnclosingFunction(ancestors);
478
- if (enclosingFn) {
479
- markSerializedFunction(enclosingFn);
480
- }
481
- const outerFn = findOutermostModuleFunction(ancestors);
482
- if (outerFn) {
483
- markSerializedFunction(outerFn);
484
- }
485
- const scopeNode = _nullishCoalesce(enclosingFn, () => ( ast));
486
- queueSerializedTarget(node.right, scopeNode);
487
- }
488
- },
489
- ObjectExpression(node, _state, ancestors) {
490
- const props = node.properties || [];
491
- const propMap = /* @__PURE__ */ new Map();
492
- for (const p of props) {
493
- if (_optionalChain([p, 'optionalAccess', _114 => _114.type]) === "Property" && !p.computed) {
494
- const keyName = _optionalChain([p, 'access', _115 => _115.key, 'optionalAccess', _116 => _116.type]) === "Identifier" ? p.key.name : _optionalChain([p, 'access', _117 => _117.key, 'optionalAccess', _118 => _118.type]) === "Literal" ? String(p.key.value) : "";
495
- if (keyName) {
496
- propMap.set(keyName, p.value);
497
- }
498
- }
499
- }
500
- const hasWorkerDescriptorShape = propMap.has("init") && propMap.has("dependencies") || propMap.has("isWorkerModule") || propMap.has("getTransferables") && (propMap.has("init") || propMap.has("dependencies"));
501
- if (hasWorkerDescriptorShape) {
502
- const scopeNode = _nullishCoalesce(findEnclosingFunction(ancestors), () => ( ast));
503
- for (const key of ["init", "getTransferables", "worker"]) {
504
- const val = propMap.get(key);
505
- if (val) queueSerializedTarget(val, scopeNode);
506
- }
507
- const deps = propMap.get("dependencies");
508
- if (_optionalChain([deps, 'optionalAccess', _119 => _119.type]) === "ArrayExpression") {
509
- for (const el of deps.elements || []) {
510
- if (el) queueSerializedTarget(el, scopeNode);
511
- }
512
- }
513
- }
514
- },
515
- CallExpression(node, _state, ancestors) {
516
- const callee = node.callee;
517
- let calleeName = "";
518
- let memberProp = "";
519
- let qualifiedCall = "";
520
- if (_optionalChain([callee, 'optionalAccess', _120 => _120.type]) === "Identifier") {
521
- calleeName = callee.name;
522
- qualifiedCall = calleeName;
523
- } else if (_optionalChain([callee, 'optionalAccess', _121 => _121.type]) === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _122 => _122.property, 'optionalAccess', _123 => _123.type]) === "Identifier") {
524
- memberProp = callee.property.name;
525
- if (_optionalChain([callee, 'access', _124 => _124.object, 'optionalAccess', _125 => _125.type]) === "Identifier") {
526
- qualifiedCall = `${callee.object.name}.${memberProp}`;
527
- } else if (_optionalChain([callee, 'access', _126 => _126.object, 'optionalAccess', _127 => _127.type]) === "ThisExpression") {
528
- qualifiedCall = memberProp;
529
- }
530
- }
531
- const enclosingFn = findEnclosingFunction(ancestors);
532
- const currentScope = _nullishCoalesce(enclosingFn, () => ( ast));
533
- if (qualifiedCall || memberProp) {
534
- allCallSites.push({
535
- scopeNode: currentScope,
536
- calleeKey: qualifiedCall || memberProp,
537
- args: node.arguments || []
538
- });
539
- if (enclosingFn) {
540
- let set = callerToCallees.get(enclosingFn);
541
- if (!set) {
542
- set = /* @__PURE__ */ new Set();
543
- callerToCallees.set(enclosingFn, set);
544
- }
545
- if (qualifiedCall) set.add(qualifiedCall);
546
- if (memberProp && !arrayHofMethods.has(memberProp)) {
547
- set.add(memberProp);
548
- }
549
- }
550
- }
551
- if (memberProp === "toString" && (!node.arguments || node.arguments.length === 0) && _optionalChain([callee, 'optionalAccess', _128 => _128.type]) === "MemberExpression") {
552
- const targetObj = callee.object;
553
- queueSerializedTarget(targetObj, currentScope);
554
- if (_optionalChain([targetObj, 'optionalAccess', _129 => _129.type]) === "Identifier" && enclosingFn) {
555
- const resolvedName = resolveAliasTarget(enclosingFn, targetObj.name);
556
- if (ensureFnParams(enclosingFn).has(resolvedName)) {
557
- serializerHelperNodes.add(enclosingFn);
558
- }
559
- if (resolvedName !== targetObj.name) {
560
- queueSerializedTarget({ type: "Identifier", name: resolvedName }, currentScope);
561
- }
562
- }
563
- }
564
- if ((memberProp === "call" || memberProp === "apply") && _optionalChain([callee, 'optionalAccess', _130 => _130.type]) === "MemberExpression" && _optionalChain([callee, 'access', _131 => _131.object, 'optionalAccess', _132 => _132.type]) === "MemberExpression" && _optionalChain([callee, 'access', _133 => _133.object, 'access', _134 => _134.property, 'optionalAccess', _135 => _135.type]) === "Identifier" && callee.object.property.name === "toString" && _optionalChain([node, 'access', _136 => _136.arguments, 'optionalAccess', _137 => _137.length]) > 0) {
565
- const firstArg = node.arguments[0];
566
- queueSerializedTarget(firstArg, currentScope);
567
- if (_optionalChain([firstArg, 'optionalAccess', _138 => _138.type]) === "Identifier" && enclosingFn) {
568
- const resolvedName = resolveAliasTarget(enclosingFn, firstArg.name);
569
- if (ensureFnParams(enclosingFn).has(resolvedName)) {
570
- serializerHelperNodes.add(enclosingFn);
571
- }
572
- if (resolvedName !== firstArg.name) {
573
- queueSerializedTarget({ type: "Identifier", name: resolvedName }, currentScope);
574
- }
575
- }
576
- }
577
- if (calleeName === "importScripts" || memberProp === "importScripts" && _optionalChain([callee, 'optionalAccess', _139 => _139.object, 'optionalAccess', _140 => _140.type]) === "Identifier" && callee.object.name === "self") {
578
- if (enclosingFn) markSerializedFunction(enclosingFn);
579
- const outerFn = findOutermostModuleFunction(ancestors);
580
- if (outerFn) markSerializedFunction(outerFn);
581
- }
582
- const isTickerAdd = memberProp === "add" && (_optionalChain([callee, 'optionalAccess', _141 => _141.object, 'optionalAccess', _142 => _142.name]) === "ticker" || _optionalChain([callee, 'optionalAccess', _143 => _143.object, 'optionalAccess', _144 => _144.property, 'optionalAccess', _145 => _145.name]) === "ticker");
583
- if (animationCalls.has(calleeName) || animationCalls.has(memberProp) || isTickerAdd) {
584
- if (enclosingFn) {
585
- trueHotNodes.add(enclosingFn);
586
- hotFunctionNodes.add(enclosingFn);
587
- directHotNodes.add(enclosingFn);
588
- }
589
- for (const arg of node.arguments || []) {
590
- if (FUNCTION_NODE_TYPES.has(arg.type)) {
591
- trueHotNodes.add(arg);
592
- hotFunctionNodes.add(arg);
593
- directHotNodes.add(arg);
594
- hotExemptNodes.add(arg);
595
- } else if (_optionalChain([arg, 'optionalAccess', _146 => _146.type]) === "Identifier") {
596
- pendingHotRefs.push({ scopeNode: currentScope, name: arg.name });
597
- allCallSites.push({
598
- scopeNode: currentScope,
599
- calleeKey: arg.name,
600
- args: [arg]
601
- });
602
- }
603
- }
604
- }
605
- if (arrayHofMethods.has(memberProp)) {
606
- if (enclosingFn !== null) {
607
- for (const arg of node.arguments || []) {
608
- if (FUNCTION_NODE_TYPES.has(arg.type)) {
609
- trueHotNodes.add(arg);
610
- hotFunctionNodes.add(arg);
611
- directHotNodes.add(arg);
612
- hotExemptNodes.add(arg);
613
- } else if (_optionalChain([arg, 'optionalAccess', _147 => _147.type]) === "Identifier") {
614
- allCallSites.push({
615
- scopeNode: currentScope,
616
- calleeKey: arg.name,
617
- args: [arg]
618
- });
619
- }
620
- }
621
- } else {
622
- for (const arg of node.arguments || []) {
623
- const isAnonymousFunction = arg.type === "FunctionExpression" && !arg.id || arg.type === "ArrowFunctionExpression";
624
- if (isAnonymousFunction) {
625
- coldForcedNodes.add(arg);
626
- }
627
- }
628
- }
629
- }
630
- if (calleeName === "useEffect" || memberProp === "useEffect" || calleeName === "useLayoutEffect" || memberProp === "useLayoutEffect") {
631
- const effectArg = _optionalChain([node, 'access', _148 => _148.arguments, 'optionalAccess', _149 => _149[0]]);
632
- if (effectArg && FUNCTION_NODE_TYPES.has(effectArg.type)) {
633
- if (!containsLoopOrAnimation(effectArg, animationCalls)) {
634
- coldForcedNodes.add(effectArg);
635
- if (_optionalChain([effectArg, 'access', _150 => _150.body, 'optionalAccess', _151 => _151.type]) === "BlockStatement") {
636
- for (const s of effectArg.body.body || []) {
637
- if (s.type === "ReturnStatement" && s.argument && FUNCTION_NODE_TYPES.has(s.argument.type) && !containsLoopOrAnimation(s.argument, animationCalls)) {
638
- coldForcedNodes.add(s.argument);
639
- }
640
- }
641
- }
642
- }
643
- }
644
- }
645
- if (REACT_HOOK_OR_RENDER_CALLS.has(calleeName) || REACT_HOOK_OR_RENDER_CALLS.has(memberProp) || isHookName(calleeName) || isHookName(memberProp)) {
646
- if (enclosingFn) {
647
- shallowComponentNodes.add(enclosingFn);
648
- hotFunctionNodes.add(enclosingFn);
649
- directHotNodes.add(enclosingFn);
650
- hotExemptNodes.add(enclosingFn);
651
- }
652
- }
653
- },
654
- ForStatement(node, _state, ancestors) {
655
- hotExemptNodes.add(node);
656
- const enc = findEnclosingFunction(ancestors);
657
- if (enc) {
658
- trueHotNodes.add(enc);
659
- hotFunctionNodes.add(enc);
660
- directHotNodes.add(enc);
661
- }
662
- },
663
- ForInStatement(node, _state, ancestors) {
664
- hotExemptNodes.add(node);
665
- const enc = findEnclosingFunction(ancestors);
666
- if (enc) {
667
- trueHotNodes.add(enc);
668
- hotFunctionNodes.add(enc);
669
- directHotNodes.add(enc);
670
- }
671
- },
672
- ForOfStatement(node, _state, ancestors) {
673
- hotExemptNodes.add(node);
674
- const enc = findEnclosingFunction(ancestors);
675
- if (enc) {
676
- trueHotNodes.add(enc);
677
- hotFunctionNodes.add(enc);
678
- directHotNodes.add(enc);
679
- }
680
- },
681
- WhileStatement(node, _state, ancestors) {
682
- hotExemptNodes.add(node);
683
- const enc = findEnclosingFunction(ancestors);
684
- if (enc) {
685
- trueHotNodes.add(enc);
686
- hotFunctionNodes.add(enc);
687
- directHotNodes.add(enc);
688
- }
689
- },
690
- DoWhileStatement(node, _state, ancestors) {
691
- hotExemptNodes.add(node);
692
- const enc = findEnclosingFunction(ancestors);
693
- if (enc) {
694
- trueHotNodes.add(enc);
695
- hotFunctionNodes.add(enc);
696
- directHotNodes.add(enc);
697
- }
698
- }
699
- });
700
- for (const callSite of allCallSites) {
701
- const resolvedCallee = resolveCalleeNode(callSite.scopeNode, callSite.calleeKey);
702
- if (resolvedCallee && serializerHelperNodes.has(resolvedCallee)) {
703
- for (const arg of callSite.args) {
704
- queueSerializedTarget(arg, callSite.scopeNode);
705
- }
706
- }
707
- }
708
- for (const ref of pendingSerializedRefs) {
709
- const targetNode = resolveCalleeNode(ref.scopeNode, ref.name);
710
- if (targetNode) {
711
- markSerializedFunction(targetNode);
712
- }
713
- }
714
- for (const ref of pendingHotRefs) {
715
- const targetNode = resolveCalleeNode(ref.scopeNode, ref.name);
716
- if (targetNode) {
717
- trueHotNodes.add(targetNode);
718
- hotFunctionNodes.add(targetNode);
719
- directHotNodes.add(targetNode);
720
- hotExemptNodes.add(targetNode);
721
- }
722
- }
723
- for (const fn of allFunctions) {
724
- if (!trueHotNodes.has(fn.node) && !containsLoopOrAnimation(fn.node, animationCalls)) {
725
- if (!shallowComponentNodes.has(fn.node)) {
726
- if (fn.node.async === true || isEventHandlerName(fn.name, eventHandlerRegex)) {
727
- coldForcedNodes.add(fn.node);
728
- }
729
- }
730
- }
731
- }
732
- let forwardChanged = true;
733
- while (forwardChanged) {
734
- forwardChanged = false;
735
- for (const fn of allFunctions) {
736
- if (coldForcedNodes.has(fn.node)) continue;
737
- const chain = fnScopeChain.get(fn.node);
738
- if (!chain) continue;
739
- for (const anc of chain) {
740
- if (anc === fn.node) continue;
741
- if (serializedWorkerNodes.has(anc)) {
742
- if (!serializedWorkerNodes.has(fn.node)) {
743
- fn.node._unpeekSerialized = true;
744
- serializedWorkerNodes.add(fn.node);
745
- serializedFunctionNodes.add(fn.node);
746
- hotFunctionNodes.add(fn.node);
747
- hotExemptNodes.add(fn.node);
748
- forwardChanged = true;
749
- }
750
- break;
751
- }
752
- const isModuleContainer = (_nullishCoalesce(_optionalChain([fnScopeChain, 'access', _152 => _152.get, 'call', _153 => _153(anc), 'optionalAccess', _154 => _154.length]), () => ( 0))) <= 1;
753
- if (trueHotNodes.has(anc) && !shallowComponentNodes.has(anc) && !isModuleContainer) {
754
- if (!trueHotNodes.has(fn.node)) {
755
- trueHotNodes.add(fn.node);
756
- hotFunctionNodes.add(fn.node);
757
- hotExemptNodes.add(fn.node);
758
- forwardChanged = true;
759
- }
760
- break;
761
- }
762
- }
763
- }
764
- for (const callerNode of Array.from(serializedWorkerNodes)) {
765
- const calleeNames = callerToCallees.get(callerNode);
766
- if (!calleeNames) continue;
767
- for (const cName of calleeNames) {
768
- const targetNode = resolveCalleeNode(callerNode, cName);
769
- if (targetNode && !serializedWorkerNodes.has(targetNode) && !coldForcedNodes.has(targetNode)) {
770
- targetNode._unpeekSerialized = true;
771
- serializedWorkerNodes.add(targetNode);
772
- serializedFunctionNodes.add(targetNode);
773
- hotFunctionNodes.add(targetNode);
774
- hotExemptNodes.add(targetNode);
775
- forwardChanged = true;
776
- }
777
- }
778
- }
779
- for (const callerNode of Array.from(trueHotNodes)) {
780
- const calleeNames = callerToCallees.get(callerNode);
781
- if (!calleeNames) continue;
782
- for (const cName of calleeNames) {
783
- const targetNode = resolveCalleeNode(callerNode, cName);
784
- if (targetNode && !trueHotNodes.has(targetNode) && !coldForcedNodes.has(targetNode)) {
785
- trueHotNodes.add(targetNode);
786
- hotFunctionNodes.add(targetNode);
787
- hotExemptNodes.add(targetNode);
788
- forwardChanged = true;
789
- }
790
- }
791
- }
792
- }
793
- const calleeToCallers = /* @__PURE__ */ new Map();
794
- for (const [callerNode, calleeNames] of callerToCallees.entries()) {
795
- for (const cName of calleeNames) {
796
- const targetNode = resolveCalleeNode(callerNode, cName);
797
- if (targetNode) {
798
- let set = calleeToCallers.get(targetNode);
799
- if (!set) {
800
- set = /* @__PURE__ */ new Set();
801
- calleeToCallers.set(targetNode, set);
802
- }
803
- set.add(callerNode);
804
- }
805
- }
806
- }
807
- let changed = true;
808
- while (changed) {
809
- changed = false;
810
- for (const [callerNode, calleeNames] of callerToCallees.entries()) {
811
- if (hotFunctionNodes.has(callerNode) || shallowComponentNodes.has(callerNode) || coldForcedNodes.has(callerNode)) {
812
- continue;
813
- }
814
- for (const cName of calleeNames) {
815
- const targetNode = resolveCalleeNode(callerNode, cName);
816
- if (targetNode && trueHotNodes.has(targetNode)) {
817
- const callers = calleeToCallers.get(targetNode);
818
- const isDedicatedPipeline = callers && callers.size <= maxPipelineCallers;
819
- if (isDedicatedPipeline) {
820
- trueHotNodes.add(callerNode);
821
- hotFunctionNodes.add(callerNode);
822
- hotExemptNodes.add(callerNode);
823
- changed = true;
824
- break;
825
- }
826
- }
827
- }
828
- }
829
- }
830
- for (const node of coldForcedNodes) {
831
- hotFunctionNodes.delete(node);
832
- hotExemptNodes.delete(node);
833
- }
834
- const hotFunctionsSkipped = [];
835
- const coldFunctionsProtected = [];
836
- for (const fn of allFunctions) {
837
- if (hotFunctionNodes.has(fn.node)) {
838
- hotFunctionsSkipped.push(fn.name);
839
- } else {
840
- coldFunctionNodes.add(fn.node);
841
- coldFunctionsProtected.push(fn.name);
842
- }
843
- }
844
- return {
845
- report: {
846
- totalFunctions: allFunctions.length,
847
- hotFunctionsSkipped,
848
- coldFunctionsProtected
849
- },
850
- hotFunctionNodes,
851
- coldFunctionNodes,
852
- hotExemptNodes,
853
- serializedFunctionNodes
854
- };
855
- }
856
- function detectHotPaths(code, config) {
857
- const ast = parseJavaScriptAst(code);
858
- if (!ast) {
859
- return {
860
- totalFunctions: 0,
861
- hotFunctionsSkipped: [],
862
- coldFunctionsProtected: []
863
- };
864
- }
865
- return analyzeAstHotPaths(ast, config).report;
866
- }
867
-
868
- // src/ast/string-vault.ts
869
-
870
-
871
-
872
- // src/ast/salted-vault.ts
873
-
874
-
875
-
876
- // src/ast/wasm-vault.ts
877
-
878
- function encodeSignedLeb128(value) {
879
- const bytes = [];
880
- let val = value | 0;
881
- let more = true;
882
- while (more) {
883
- let byte = val & 127;
884
- val >>= 7;
885
- if (val === 0 && (byte & 64) === 0 || val === -1 && (byte & 64) !== 0) {
886
- more = false;
887
- } else {
888
- byte |= 128;
889
- }
890
- bytes.push(byte);
891
- }
892
- return bytes;
893
- }
894
- function encodeUnsignedLeb128(value) {
895
- const bytes = [];
896
- let val = value >>> 0;
897
- do {
898
- let byte = val & 127;
899
- val >>>= 7;
900
- if (val !== 0) {
901
- byte |= 128;
902
- }
903
- bytes.push(byte);
904
- } while (val !== 0);
905
- return bytes;
906
- }
907
- function rotl32(value, bits) {
908
- return value << bits | value >>> 32 - bits | 0;
909
- }
910
- function writeI32LE(value) {
911
- const v = value | 0;
912
- return [v & 255, v >>> 8 & 255, v >>> 16 & 255, v >>> 24 & 255];
913
- }
914
- function deriveKdfParams(seed) {
915
- const sVal = seed | 0;
916
- const c1 = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "wasm-c1", seed) ^ 2246822507 | 1;
917
- const c2 = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "wasm-c2", seed) ^ 3266489909 | 1;
918
- const k0 = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "wasm-k0", seed) | 0;
919
- const r1 = (seed >>> 0) % 19 + 7;
920
- const r2 = (seed >>> 5) % 17 + 5;
921
- return { sVal, c1, c2, k0, r1, r2 };
922
- }
923
- function generateWasmKdfBinary(seed) {
924
- const { sVal, c1, c2, k0, r1, r2 } = deriveKdfParams(seed);
925
- const memBase = (seed >>> 0 & 127) * 4;
926
- const r0 = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "wasm-r0", seed) | 0;
927
- const rotAmt = (seed >>> 0) % 27 + 3;
928
- const kMul = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "wasm-kmul", seed) | 1;
929
- const kA = kMul >>> 16 & 65535;
930
- const kB = kMul & 65535;
931
- const memMask = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "wasm-mem", seed) & 1023 | 1;
932
- const memA = memBase ^ memMask;
933
- const w0 = r0;
934
- const w1 = sVal ^ rotl32(r0, rotAmt) ^ Math.imul(r0 | 1, kMul) | 0;
935
- const w2 = c1 ^ (w0 + w1 | 0) | 0;
936
- const w3 = c2 - Math.imul(w1 | 1, w2 | 1) | 0;
937
- const w4 = k0 ^ rotl32(w2, 11) ^ w3 | 0;
938
- const instructions = [
939
- 65,
940
- ...encodeSignedLeb128(memA),
941
- // i32.const memA
942
- 65,
943
- ...encodeSignedLeb128(memMask),
944
- // i32.const memMask
945
- 115,
946
- // i32.xor
947
- 34,
948
- 3,
949
- // local.tee 3 (ptr)
950
- 40,
951
- 2,
952
- 0,
953
- // i32.load align=2 offset=0
954
- 33,
955
- 4,
956
- // local.set 4 (w0)
957
- 32,
958
- 3,
959
- // local.get 3
960
- 40,
961
- 2,
962
- 4,
963
- // i32.load align=2 offset=4
964
- 33,
965
- 5,
966
- // local.set 5 (w1)
967
- 32,
968
- 3,
969
- // local.get 3
970
- 40,
971
- 2,
972
- 8,
973
- // i32.load align=2 offset=8
974
- 33,
975
- 6,
976
- // local.set 6 (w2)
977
- 32,
978
- 3,
979
- // local.get 3
980
- 40,
981
- 2,
982
- 12,
983
- // i32.load align=2 offset=12
984
- 33,
985
- 7,
986
- // local.set 7 (w3)
987
- // Reconstruct sVal -> local 8
988
- 32,
989
- 5,
990
- // local.get 5 (w1)
991
- 32,
992
- 4,
993
- // local.get 4 (w0)
994
- 65,
995
- ...encodeSignedLeb128(rotAmt),
996
- // i32.const rotAmt
997
- 119,
998
- // i32.rotl
999
- 115,
1000
- // i32.xor
1001
- 32,
1002
- 4,
1003
- // local.get 4 (w0)
1004
- 65,
1005
- 1,
1006
- // i32.const 1
1007
- 114,
1008
- // i32.or
1009
- 65,
1010
- ...encodeSignedLeb128(kA),
1011
- // i32.const kA
1012
- 65,
1013
- 16,
1014
- // i32.const 16
1015
- 116,
1016
- // i32.shl
1017
- 65,
1018
- ...encodeSignedLeb128(kB),
1019
- // i32.const kB
1020
- 114,
1021
- // i32.or
1022
- 108,
1023
- // i32.mul
1024
- 115,
1025
- // i32.xor
1026
- 33,
1027
- 8,
1028
- // local.set 8 (sVal)
1029
- // Reconstruct c1 -> local 9
1030
- 32,
1031
- 6,
1032
- // local.get 6 (w2)
1033
- 32,
1034
- 4,
1035
- // local.get 4 (w0)
1036
- 32,
1037
- 5,
1038
- // local.get 5 (w1)
1039
- 106,
1040
- // i32.add
1041
- 115,
1042
- // i32.xor
1043
- 33,
1044
- 9,
1045
- // local.set 9 (c1)
1046
- // Reconstruct k0 -> local 10
1047
- 32,
1048
- 3,
1049
- // local.get 3 (ptr)
1050
- 40,
1051
- 2,
1052
- 16,
1053
- // i32.load align=2 offset=16 (w4)
1054
- 32,
1055
- 6,
1056
- // local.get 6 (w2)
1057
- 65,
1058
- 11,
1059
- // i32.const 11
1060
- 119,
1061
- // i32.rotl
1062
- 115,
1063
- // i32.xor
1064
- 32,
1065
- 7,
1066
- // local.get 7 (w3)
1067
- 115,
1068
- // i32.xor
1069
- 33,
1070
- 10,
1071
- // local.set 10 (k0)
1072
- // x = f ^ sVal ^ k0
1073
- 32,
1074
- 0,
1075
- // local.get 0 (fnId)
1076
- 32,
1077
- 8,
1078
- // local.get 8 (sVal)
1079
- 115,
1080
- // i32.xor
1081
- 32,
1082
- 10,
1083
- // local.get 10 (k0)
1084
- 115,
1085
- // i32.xor
1086
- 34,
1087
- 11,
1088
- // local.tee 11 (x)
1089
- // x ^= x >>> 16
1090
- 32,
1091
- 11,
1092
- // local.get 11
1093
- 65,
1094
- 16,
1095
- // i32.const 16
1096
- 118,
1097
- // i32.shr_u
1098
- 115,
1099
- // i32.xor
1100
- // x = imul(x, c1)
1101
- 32,
1102
- 9,
1103
- // local.get 9 (c1)
1104
- 108,
1105
- // i32.mul
1106
- // x = rotl(x ^ s, r1)
1107
- 32,
1108
- 1,
1109
- // local.get 1 (callSiteSalt)
1110
- 115,
1111
- // i32.xor
1112
- 65,
1113
- ...encodeSignedLeb128(r1),
1114
- // i32.const r1
1115
- 119,
1116
- // i32.rotl
1117
- // x = imul(x ^ h ^ sVal, c2)
1118
- 32,
1119
- 2,
1120
- // local.get 2 (shieldHash)
1121
- 115,
1122
- // i32.xor
1123
- 32,
1124
- 8,
1125
- // local.get 8 (sVal)
1126
- 115,
1127
- // i32.xor
1128
- 32,
1129
- 7,
1130
- // local.get 7 (w3)
1131
- 32,
1132
- 5,
1133
- // local.get 5 (w1)
1134
- 65,
1135
- 1,
1136
- // i32.const 1
1137
- 114,
1138
- // i32.or
1139
- 32,
1140
- 6,
1141
- // local.get 6 (w2)
1142
- 65,
1143
- 1,
1144
- // i32.const 1
1145
- 114,
1146
- // i32.or
1147
- 108,
1148
- // i32.mul
1149
- 106,
1150
- // i32.add (c2)
1151
- 108,
1152
- // i32.mul
1153
- 34,
1154
- 11,
1155
- // local.tee 11 (x)
1156
- // x ^= x >>> 15
1157
- 32,
1158
- 11,
1159
- // local.get 11
1160
- 65,
1161
- 15,
1162
- // i32.const 15
1163
- 118,
1164
- // i32.shr_u
1165
- 115,
1166
- // i32.xor
1167
- // x = (x + rotl(s ^ k0, r2))
1168
- 32,
1169
- 1,
1170
- // local.get 1 (callSiteSalt)
1171
- 32,
1172
- 10,
1173
- // local.get 10 (k0)
1174
- 115,
1175
- // i32.xor
1176
- 65,
1177
- ...encodeSignedLeb128(r2),
1178
- // i32.const r2
1179
- 119,
1180
- // i32.rotl
1181
- 106,
1182
- // i32.add
1183
- // x = imul(x, c1)
1184
- 32,
1185
- 9,
1186
- // local.get 9 (c1)
1187
- 108,
1188
- // i32.mul
1189
- 34,
1190
- 11,
1191
- // local.tee 11 (x)
1192
- // x ^= x >>> 16
1193
- 32,
1194
- 11,
1195
- // local.get 11
1196
- 65,
1197
- 16,
1198
- // i32.const 16
1199
- 118,
1200
- // i32.shr_u
1201
- 115,
1202
- // i32.xor
1203
- 11
1204
- // end
1205
- ];
1206
- const funcBody = [1, 9, 127, ...instructions];
1207
- const funcBodyWithLen = [...encodeUnsignedLeb128(funcBody.length), ...funcBody];
1208
- const codeSectionPayload = [1, ...funcBodyWithLen];
1209
- const codeSection = [
1210
- 10,
1211
- ...encodeUnsignedLeb128(codeSectionPayload.length),
1212
- ...codeSectionPayload
1213
- ];
1214
- const typePayload = [
1215
- 1,
1216
- // 1 type
1217
- 96,
1218
- // func
1219
- 3,
1220
- 127,
1221
- 127,
1222
- 127,
1223
- // 3 params of type i32
1224
- 1,
1225
- 127
1226
- // 1 result of type i32
1227
- ];
1228
- const typeSection = [
1229
- 1,
1230
- ...encodeUnsignedLeb128(typePayload.length),
1231
- ...typePayload
1232
- ];
1233
- const funcPayload = [
1234
- 1,
1235
- // 1 function
1236
- 0
1237
- // type index 0
1238
- ];
1239
- const funcSection = [
1240
- 3,
1241
- ...encodeUnsignedLeb128(funcPayload.length),
1242
- ...funcPayload
1243
- ];
1244
- const memSection = [5, 3, 1, 0, 1];
1245
- const exportName = [3, 107, 100, 102];
1246
- const exportPayload = [
1247
- 1,
1248
- // 1 export
1249
- ...exportName,
1250
- 0,
1251
- // function export
1252
- 0
1253
- // function index 0
1254
- ];
1255
- const exportSection = [
1256
- 7,
1257
- ...encodeUnsignedLeb128(exportPayload.length),
1258
- ...exportPayload
1259
- ];
1260
- const dataWords = [
1261
- ...writeI32LE(w0),
1262
- ...writeI32LE(w1),
1263
- ...writeI32LE(w2),
1264
- ...writeI32LE(w3),
1265
- ...writeI32LE(w4)
1266
- ];
1267
- const dataPayload = [
1268
- 1,
1269
- // 1 active segment
1270
- 0,
1271
- // memory index 0
1272
- 65,
1273
- ...encodeSignedLeb128(memBase),
1274
- 11,
1275
- // i32.const memBase; end
1276
- ...encodeUnsignedLeb128(dataWords.length),
1277
- ...dataWords
1278
- ];
1279
- const dataSection = [
1280
- 11,
1281
- ...encodeUnsignedLeb128(dataPayload.length),
1282
- ...dataPayload
1283
- ];
1284
- const header = [0, 97, 115, 109, 1, 0, 0, 0];
1285
- return new Uint8Array([
1286
- ...header,
1287
- ...typeSection,
1288
- ...funcSection,
1289
- ...memSection,
1290
- ...exportSection,
1291
- ...codeSection,
1292
- ...dataSection
1293
- ]);
1294
- }
1295
- function fallbackKdf(fnId, callSiteSalt, shieldHash, seed) {
1296
- const { sVal, c1, c2, k0, r1, r2 } = deriveKdfParams(seed);
1297
- let x = fnId ^ sVal ^ k0 | 0;
1298
- x = x ^ x >>> 16 | 0;
1299
- x = Math.imul(x, c1);
1300
- x = rotl32(x ^ callSiteSalt | 0, r1);
1301
- x = Math.imul(x ^ shieldHash ^ sVal | 0, c2);
1302
- x = x ^ x >>> 15 | 0;
1303
- x = x + rotl32(callSiteSalt ^ k0 | 0, r2) | 0;
1304
- x = Math.imul(x, c1);
1305
- x = x ^ x >>> 16 | 0;
1306
- return x | 0;
1307
- }
1308
- function isWasmVaultAlreadyInjected(ast) {
1309
- if (!ast || !Array.isArray(ast.body)) return false;
1310
- return ast.body.some((stmt) => {
1311
- if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _155 => _155.declarations, 'optionalAccess', _156 => _156.some, 'call', _157 => _157(
1312
- (d) => _optionalChain([d, 'access', _158 => _158.id, 'optionalAccess', _159 => _159.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
1313
- )])) {
1314
- return true;
1315
- }
1316
- return false;
1317
- });
1318
- }
1319
- function injectWasmVault(ast, seed = 2654435769) {
1320
- const suffix = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, `wasm:${seed}`, seed).toString(36);
1321
- const kdfFnName = `_wKdf${suffix}`;
1322
- const wasmVarName = `_wb${suffix}`;
1323
- if (isWasmVaultAlreadyInjected(ast)) {
1324
- const existing = ast.body.find(
1325
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _160 => _160.declarations, 'optionalAccess', _161 => _161.some, 'call', _162 => _162(
1326
- (d) => _optionalChain([d, 'access', _163 => _163.id, 'optionalAccess', _164 => _164.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
1327
- )])
1328
- );
1329
- const id = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _165 => _165.declarations, 'access', _166 => _166[0], 'optionalAccess', _167 => _167.id, 'optionalAccess', _168 => _168.name]), () => ( kdfFnName));
1330
- return {
1331
- kdfFnName: id,
1332
- wasmBytes: generateWasmKdfBinary(seed),
1333
- wasmVarName
1334
- };
1335
- }
1336
- const wasmBytes = generateWasmKdfBinary(seed);
1337
- const byteArrayLiteral = Array.from(wasmBytes).join(",");
1338
- const { sVal, c1, c2, k0, r1, r2 } = deriveKdfParams(seed);
1339
- const targets = [c1, c2, sVal, k0, r1, r2];
1340
- const aArr = [];
1341
- const bArr = [];
1342
- const mArr = [];
1343
- for (let i = 0; i < targets.length; i++) {
1344
- const aVal = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, `mba-a:${i}`, seed) | 0;
1345
- const mVal = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, `mba-m:${i}`, seed) | 0;
1346
- const bVal = (targets[i] ^ mVal) - aVal | 0;
1347
- aArr.push(aVal);
1348
- bArr.push(bVal);
1349
- mArr.push(mVal);
1350
- }
1351
- const strKey = seed & 127 ^ 61 | 0;
1352
- const mChars = [105 ^ strKey, 109 ^ strKey, 117 ^ strKey, 108 ^ strKey].join(",");
1353
- const helperSnippet = `var ${kdfFnName};
1354
- try {
1355
- var ${wasmVarName} = new Uint8Array([${byteArrayLiteral}]);
1356
- var _wm${suffix} = new WebAssembly.Module(${wasmVarName});
1357
- var _wi${suffix} = new WebAssembly.Instance(_wm${suffix});
1358
- ${kdfFnName} = _wi${suffix}.exports.kdf;
1359
- } catch (e) {
1360
- ${kdfFnName} = (function() {
1361
- var _z = +!String;
1362
- var _a = [${aArr.join(",")}];
1363
- var _b = [${bArr.join(",")}];
1364
- var _m0 = [${mArr.join(",")}];
1365
- var _k = [];
1366
- for (var _j = 0; _j < ${targets.length}; _j++) {
1367
- var _u = _a[_j] | _z, _v = _b[_j];
1368
- var _t = ((_u | _v) + (_u & _v)) | 0;
1369
- _k[_j] = ((_t + _m0[_j]) - ((_t & _m0[_j]) << 1)) | 0;
1370
- }
1371
- var _p = '';
1372
- var _c = [${mChars}];
1373
- for (var _i = 0; _i < _c.length; _i++) {
1374
- _p += String.fromCharCode(_c[_i] ^ ${strKey});
1375
- }
1376
- var _m = Math[_p];
1377
- return function(f, s, h) {
1378
- var _x = (f ^ _k[2] ^ _k[3]) | 0;
1379
- _x = (_x ^ (_x >>> 16)) | 0;
1380
- _x = _m(_x, _k[0]);
1381
- var _t0 = _x ^ s, _r1 = _k[4];
1382
- _x = (_t0 << _r1) | (_t0 >>> (32 - _r1));
1383
- _x = _m(_x ^ h ^ _k[2], _k[1]);
1384
- _x = (_x ^ (_x >>> 15)) | 0;
1385
- var _u0 = s ^ _k[3], _r2 = _k[5];
1386
- _x = (_x + ((_u0 << _r2) | (_u0 >>> (32 - _r2)))) | 0;
1387
- _x = _m(_x, _k[0]);
1388
- return (_x ^ (_x >>> 16)) | 0;
1389
- };
1390
- })();
1391
- }`;
1392
- const parsedHelper = acorn2.parse(helperSnippet, {
1393
- ecmaVersion: "latest",
1394
- sourceType: "script"
1395
- });
1396
- let insertIdx = 0;
1397
- while (insertIdx < ast.body.length) {
1398
- const stmt = ast.body[insertIdx];
1399
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _169 => _169.expression, 'optionalAccess', _170 => _170.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
1400
- if (isDirective || stmt.type === "ImportDeclaration") {
1401
- insertIdx++;
1402
- } else {
1403
- break;
1404
- }
1405
- }
1406
- ast.body.splice(insertIdx, 0, ...parsedHelper.body);
1407
- return {
1408
- kdfFnName,
1409
- wasmBytes,
1410
- wasmVarName
1411
- };
1412
- }
1413
-
1414
- // src/ast/salted-vault.ts
1415
- function computeCallSiteSalt(seed, idx) {
1416
- return ((Math.imul((seed ^ idx) >>> 0, 2654435761) ^ Math.imul(idx + 1 >>> 0, 73244475)) & 31) >>> 0;
1417
- }
1418
- function createSaltedDecryptorFnAst(seed, pChars, expectedDelta, windowKeySymbol, safeAlpha = SAFE_ALPHA, shieldCoupled = true, browserOnly = false) {
1419
- const propAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(windowKeySymbol) ? `.${windowKeySymbol}` : `[${JSON.stringify(windowKeySymbol)}]`;
1420
- let fBody;
1421
- if (!shieldCoupled) {
1422
- fBody = `var m=[],c=Function.prototype.toString.call(f);for(var h=0x811c9dc5,j=0;j<c.length;j++)h=Math.imul(h^c.charCodeAt(j),0x01000193)>>>0;var q=(h^(""._u||a._u||0))>>>0,A="${safeAlpha}",P="${pChars}";return function(i,s){if(i in m)return m[i];var p=a[i],o="";if(p)for(var t=q^s^Math.imul(i+1,0x01000193),j=0;j<p.length;j++){t=Math.imul(t^j+1,0x01000193)^0x811c9dc5;var c=p[j],k=A.indexOf(c);o+=k<0?c:A[(A.indexOf(P[(k-(t&65535)%92+92)%92])-(t>>>16)%92+92)%92];}return m[i]=o;};`;
1423
- } else if (browserOnly) {
1424
- fBody = `var m=[],c=Function.prototype.toString.call(f);for(var h=0x811c9dc5,j=0;j<c.length;j++)h=Math.imul(h^c.charCodeAt(j),0x01000193)>>>0;var q,A="${safeAlpha}",P="${pChars}";return function(i,s){if(q===void 0){var w=typeof window<"u"?window:typeof self<"u"?self:0,G=typeof globalThis<"u"?globalThis:w||this,d=G&&G${propAccess}!=null?G${propAccess}:w&&w${propAccess}!=null?w${propAccess}:w?-1:0;q=(h^(""._u||a._u||0)^d)>>>0;}if(i in m)return m[i];var p=a[i],o="";if(p)for(var t=q^s^Math.imul(i+1,0x01000193),j=0;j<p.length;j++){t=Math.imul(t^j+1,0x01000193)^0x811c9dc5;var c=p[j],k=A.indexOf(c);o+=k<0?c:A[(A.indexOf(P[(k-(t&65535)%92+92)%92])-(t>>>16)%92+92)%92];}return m[i]=o;};`;
1425
- } else {
1426
- const maskA = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "delta-a", seed) & 65535 | 1;
1427
- const maskB = (expectedDelta & 65535 ^ maskA) & 65535;
1428
- fBody = `var m=[],c=Function.prototype.toString.call(f);for(var h=0x811c9dc5,j=0;j<c.length;j++)h=Math.imul(h^c.charCodeAt(j),0x01000193)>>>0;var q,A="${safeAlpha}",P="${pChars}";return function(i,s){if(q===void 0){var w=typeof window<"u"?window:typeof self<"u"?self:0,G=typeof globalThis<"u"?globalThis:w||this,d=G&&G${propAccess}!=null?G${propAccess}:w&&w${propAccess}!=null?w${propAccess}:w?-1:(${maskA}^${maskB});q=(h^(""._u||a._u||0)^d)>>>0;}if(i in m)return m[i];var p=a[i],o="";if(p)for(var t=q^s^Math.imul(i+1,0x01000193),j=0;j<p.length;j++){t=Math.imul(t^j+1,0x01000193)^0x811c9dc5;var c=p[j],k=A.indexOf(c);o+=k<0?c:A[(A.indexOf(P[(k-(t&65535)%92+92)%92])-(t>>>16)%92+92)%92];}return m[i]=o;};`;
1429
- }
1430
- return acorn3.parse(`(function f(a){${fBody}})`, {
1431
- ecmaVersion: "latest",
1432
- sourceType: "script"
1433
- }).body[0].expression;
1434
- }
1435
- function createSaltedVaultHelperAst(decryptFnName, encryptedPayloads, fnAst) {
1436
- return {
1437
- type: "VariableDeclaration",
1438
- kind: "var",
1439
- declarations: [
1440
- {
1441
- type: "VariableDeclarator",
1442
- id: { type: "Identifier", name: decryptFnName },
1443
- init: {
1444
- type: "CallExpression",
1445
- callee: fnAst,
1446
- arguments: [
1447
- {
1448
- type: "ArrayExpression",
1449
- elements: encryptedPayloads.map((str) => ({
1450
- type: "Literal",
1451
- value: str,
1452
- raw: JSON.stringify(str)
1453
- }))
1454
- }
1455
- ],
1456
- optional: false
1457
- }
1458
- }
1459
- ]
1460
- };
1461
- }
1462
- function encodeSaltedString(str, k) {
1463
- let out = "";
1464
- let rk = k | 0;
1465
- for (let j = 0; j < str.length; j++) {
1466
- rk = Math.imul(rk ^ j + 1, 73244475) + 2654435769 | 0;
1467
- const code = str.charCodeAt(j);
1468
- const mask = rk >>> 16 & 127 | 1;
1469
- out += String.fromCharCode(code ^ mask);
1470
- }
1471
- return out;
1472
- }
1473
- function isAstAlreadySalted(ast) {
1474
- if (!ast || !Array.isArray(ast.body)) return false;
1475
- return ast.body.some((stmt) => {
1476
- if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _171 => _171.declarations, 'optionalAccess', _172 => _172.some, 'call', _173 => _173(
1477
- (d) => _optionalChain([d, 'access', _174 => _174.id, 'optionalAccess', _175 => _175.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uP")
1478
- )])) {
1479
- return true;
1480
- }
1481
- return false;
1482
- });
1483
- }
1484
- function replaceNodeInParent(parent, oldNode, newNode) {
1485
- if (!parent) return false;
1486
- for (const key of Object.keys(parent)) {
1487
- const val = parent[key];
1488
- if (val === oldNode) {
1489
- parent[key] = newNode;
1490
- return true;
1491
- }
1492
- if (Array.isArray(val)) {
1493
- const idx = val.indexOf(oldNode);
1494
- if (idx !== -1) {
1495
- val[idx] = newNode;
1496
- return true;
1497
- }
1498
- }
1499
- }
1500
- return false;
1501
- }
1502
- function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes, config, windowKeySymbol, expectedDelta, deterrentMode, shieldCoupled = true, detectHeadless = false) {
1503
- if (isAstAlreadySalted(ast)) {
1504
- return {
1505
- encryptedStringsCount: 0,
1506
- integrityToken: _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "already-salted", seed),
1507
- vaultVarName: "",
1508
- decryptFnName: ""
1509
- };
1510
- }
1511
- const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _176 => _176.vault, 'optionalAccess', _177 => _177.minStringLength]), () => ( minStringLength));
1512
- const activeDirectives = new Set(DIRECTIVE_STRINGS);
1513
- if (_optionalChain([config, 'optionalAccess', _178 => _178.vault, 'optionalAccess', _179 => _179.customDirectives])) {
1514
- for (const dir of config.vault.customDirectives) {
1515
- activeDirectives.add(dir);
1516
- }
1517
- }
1518
- const customReserved = _optionalChain([config, 'optionalAccess', _180 => _180.vault, 'optionalAccess', _181 => _181.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
1519
- const targetsToReplace = [];
1520
- const encryptedPayloads = [];
1521
- walk2.ancestor(ast, {
1522
- Literal(node, ancestors) {
1523
- if (typeof node.value !== "string") return;
1524
- if (node.value.length < minLen) return;
1525
- if (activeDirectives.has(node.value)) return;
1526
- const parent = ancestors[ancestors.length - 2];
1527
- if (!parent) return;
1528
- if (parent.type === "ExpressionStatement" && (Boolean(parent.directive) || activeDirectives.has(node.value))) {
1529
- return;
1530
- }
1531
- for (let i = ancestors.length - 2; i >= 0; i--) {
1532
- if (ancestors[i].type === "ExpressionStatement" && Boolean(ancestors[i].directive)) {
1533
- return;
1534
- }
1535
- }
1536
- if ((parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") && parent.source === node) {
1537
- return;
1538
- }
1539
- if (parent.type === "Property" && parent.key === node && !parent.computed) {
1540
- return;
1541
- }
1542
- if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
1543
- return;
1544
- }
1545
- if (hotExemptNodes) {
1546
- for (let i = ancestors.length - 1; i >= 0; i--) {
1547
- if (hotExemptNodes.has(ancestors[i])) {
1548
- return;
1549
- }
1550
- }
1551
- }
1552
- if (isReservedProp(node.value, customReserved)) return;
1553
- if (isTailwindNoise(node.value)) return;
1554
- if (isSvgPathString(node.value, parent)) return;
1555
- const callSiteIdx = targetsToReplace.length;
1556
- const localSalt = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, `salt:${seed}:${callSiteIdx}`, seed) & 2147483647 | 1;
1557
- targetsToReplace.push({
1558
- node,
1559
- parent,
1560
- callSiteIdx,
1561
- localSalt,
1562
- rawString: node.value
1563
- });
1564
- }
1565
- });
1566
- if (targetsToReplace.length === 0) {
1567
- return {
1568
- encryptedStringsCount: 0,
1569
- integrityToken: _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "empty-salted", seed),
1570
- vaultVarName: "",
1571
- decryptFnName: ""
1572
- };
1573
- }
1574
- const wasmResult = injectWasmVault(ast, seed);
1575
- const kdfFnName = wasmResult.kdfFnName;
1576
- const suffix = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, `salted:${seed}`, seed).toString(36);
1577
- const vaultVarName = `_uP${suffix}`;
1578
- const cacheVarName = `_uCache${suffix}`;
1579
- const dCacheVarName = `_uDc${suffix}`;
1580
- const decryptFnName = `_uD${suffix}`;
1581
- const sym = _nullishCoalesce(windowKeySymbol, () => ( _chunk6N6S6WTQcjs.deriveWindowKeySymbol.call(void 0, seed)));
1582
- const browserOnly = _optionalChain([config, 'optionalAccess', _182 => _182.target]) === "browser";
1583
- let expDelta = expectedDelta;
1584
- if (shieldCoupled && expDelta === void 0) {
1585
- const shield = _chunk6N6S6WTQcjs.generateRuntimeShield.call(void 0, {
1586
- seed,
1587
- windowKeySymbol: sym,
1588
- deterrentMode: _nullishCoalesce(deterrentMode, () => ( "passive")),
1589
- detectHeadless
1590
- });
1591
- expDelta = _nullishCoalesce(shield.expectedDelta, () => ( 0));
1592
- }
1593
- const propAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(sym) ? `.${sym}` : `[${JSON.stringify(sym)}]`;
1594
- let shieldDeltaExpr;
1595
- if (!shieldCoupled) {
1596
- shieldDeltaExpr = `var dv=(G&&G.__unpeek_delta!=null?G.__unpeek_delta:0)|0;${dCacheVarName}=((h|0)^dv)|0;`;
1597
- } else {
1598
- const fallbackExpr = browserOnly ? "0" : `(${_chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "salted-a", seed) & 65535 | 1}^${((_nullishCoalesce(expDelta, () => ( 0))) & 65535 ^ (_chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "salted-a", seed) & 65535 | 1)) & 65535})`;
1599
- shieldDeltaExpr = `var w=typeof window<"u"?window:typeof self<"u"?self:0;var sv=G&&G${propAccess}!=null?G${propAccess}:w&&w${propAccess}!=null?w${propAccess}:w?-1:${fallbackExpr};var dv=(G&&G.__unpeek_delta!=null?G.__unpeek_delta:w&&w.__unpeek_delta!=null?w.__unpeek_delta:0)|0;${dCacheVarName}=((h|0)^(sv|0)^dv)|0;`;
1600
- }
1601
- const helperFnSnippet = `function ${decryptFnName}(i,s){if(${cacheVarName}[i]!==void 0)return ${cacheVarName}[i];if(${dCacheVarName}===void 0){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var c=Function.prototype.toString.call(${decryptFnName}),h=0x811c9dc5;for(var l=0;l<c.length;l++)h=Math.imul(h^c.charCodeAt(l),0x01000193)>>>0;${shieldDeltaExpr}}var k=${kdfFnName}(i,s,${dCacheVarName});var p=${vaultVarName}[i],o="",rk=k|0;for(var j=0;j<p.length;j++){rk=(Math.imul(rk^(j+1),0x45d9f3b)+0x9e3779b9)|0;o+=String.fromCharCode(p.charCodeAt(j)^(((rk>>>16)&127)|1));}return (${cacheVarName}[i]=o);}`;
1602
- const parsedFn = acorn3.parse(helperFnSnippet, {
1603
- ecmaVersion: "latest",
1604
- sourceType: "script"
1605
- });
1606
- const fnDeclAst = parsedFn.body[0];
1607
- const selfHash = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, _chunk6N6S6WTQcjs.generateCompactJs.call(void 0, fnDeclAst)) | 0;
1608
- const buildD = shieldCoupled ? selfHash ^ (_nullishCoalesce(expDelta, () => ( 0))) & 65535 | 0 : selfHash | 0;
1609
- for (const target of targetsToReplace) {
1610
- const k = fallbackKdf(target.callSiteIdx, target.localSalt, buildD, seed);
1611
- encryptedPayloads.push(encodeSaltedString(target.rawString, k));
1612
- const callExpr = {
1613
- type: "CallExpression",
1614
- callee: {
1615
- type: "Identifier",
1616
- name: decryptFnName
1617
- },
1618
- arguments: [
1619
- {
1620
- type: "Literal",
1621
- value: target.callSiteIdx,
1622
- raw: String(target.callSiteIdx)
1623
- },
1624
- {
1625
- type: "Literal",
1626
- value: target.localSalt,
1627
- raw: String(target.localSalt)
1628
- }
1629
- ],
1630
- optional: false
1631
- };
1632
- replaceNodeInParent(target.parent, target.node, callExpr);
1633
- }
1634
- const serializedTable = JSON.stringify(encryptedPayloads);
1635
- const integrityToken = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, serializedTable, seed);
1636
- const varsSnippet = `var ${vaultVarName}=${serializedTable};var ${cacheVarName}=[];var ${dCacheVarName};`;
1637
- const parsedVars = acorn3.parse(varsSnippet, {
1638
- ecmaVersion: "latest",
1639
- sourceType: "script"
1640
- });
1641
- let insertIdx = 0;
1642
- while (insertIdx < ast.body.length) {
1643
- const stmt = ast.body[insertIdx];
1644
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _183 => _183.expression, 'optionalAccess', _184 => _184.type]) === "Literal" && typeof stmt.expression.value === "string" && (activeDirectives.has(stmt.expression.value) || /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim())));
1645
- if (isDirective || stmt.type === "ImportDeclaration") {
1646
- insertIdx++;
1647
- } else {
1648
- break;
1649
- }
1650
- }
1651
- ast.body.splice(insertIdx, 0, ...parsedVars.body, fnDeclAst);
1652
- return {
1653
- encryptedStringsCount: targetsToReplace.length,
1654
- integrityToken,
1655
- vaultVarName,
1656
- decryptFnName
1657
- };
1658
- }
1659
-
1660
- // src/ast/string-vault.ts
1661
- var SAFE_ALPHA = " !#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~";
1662
- var DIRECTIVE_STRINGS = /* @__PURE__ */ new Set([
1663
- "use strict",
1664
- "use client",
1665
- "use server",
1666
- "use asm",
1667
- "use cache",
1668
- "use worklet",
1669
- "use worker",
1670
- "use memo"
1671
- ]);
1672
- var STANDARD_PROP_KEYS = /* @__PURE__ */ new Set([
1673
- "id",
1674
- "type",
1675
- "key",
1676
- "ref",
1677
- "className",
1678
- "style",
1679
- "name",
1680
- "value",
1681
- "children",
1682
- "src",
1683
- "href",
1684
- "alt",
1685
- "role",
1686
- "tabIndex",
1687
- "class",
1688
- "part",
1689
- "slot",
1690
- "is",
1691
- "innerHTML",
1692
- "disabled",
1693
- "title"
1694
- ]);
1695
- var STANDARD_PROP_PREFIX_RE = /^(?:data-|aria-|on[A-Z]|v-|bind:)/;
1696
- function isReservedProp(propName, customReserved) {
1697
- if (STANDARD_PROP_KEYS.has(propName)) return true;
1698
- if (customReserved && customReserved.has(propName)) return true;
1699
- if (STANDARD_PROP_PREFIX_RE.test(propName)) return true;
1700
- return false;
1701
- }
1702
- var LOOP_NODE_TYPES = /* @__PURE__ */ new Set([
1703
- "ForStatement",
1704
- "ForInStatement",
1705
- "ForOfStatement",
1706
- "WhileStatement",
1707
- "DoWhileStatement"
1708
- ]);
1709
- function isReactDomSpecialProp(val, node, parent, customReserved) {
1710
- if (isReservedProp(val, customReserved)) return true;
1711
- if (!parent) return false;
1712
- if (parent.type === "Property") {
1713
- if (parent.key === node && !parent.computed) {
1714
- return true;
1715
- }
1716
- const keyName = _optionalChain([parent, 'access', _185 => _185.key, 'optionalAccess', _186 => _186.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _187 => _187.key, 'optionalAccess', _188 => _188.type]) === "Literal" ? String(parent.key.value) : "";
1717
- if (keyName && isReservedProp(keyName, customReserved)) {
1718
- return true;
1719
- }
1720
- }
1721
- return false;
1722
- }
1723
- var TAILWIND_TOKEN_RE = /^(?:flex|grid|block|inline|hidden|relative|absolute|fixed|w-|h-|min-|max-|p[xytrbl]?-|m[xytrbl]?-|space-[xy]-|text-|font-|bg-|border|rounded|shadow|ring|outline|transition|duration|opacity|cursor|pointer-events|select-|items-|justify-|gap-|overflow-|z-|inset-|top-|left-|right-|bottom-|hover:|focus:|focus-visible:|disabled:|dark:|data-\[|aria-|\[&_)/;
1724
- var TAILWIND_VARIANT_PREFIX_RE = /^(?:[a-zA-Z0-9_@-]+:)+/;
1725
- function stripTailwindVariants(token) {
1726
- return token.replace(TAILWIND_VARIANT_PREFIX_RE, "");
1727
- }
1728
- function isTailwindNoise(val) {
1729
- const trimmed = val.trim();
1730
- if (!trimmed) return false;
1731
- const isMatch = (t) => {
1732
- const stripped = stripTailwindVariants(t);
1733
- return TAILWIND_TOKEN_RE.test(stripped) || stripped.startsWith("btn") || stripped.startsWith("p-") || stripped.startsWith("m-");
1734
- };
1735
- if (trimmed.includes(" ")) {
1736
- const tokens = trimmed.split(/\s+/);
1737
- let twHits = 0;
1738
- for (const t of tokens) {
1739
- if (isMatch(t)) {
1740
- twHits++;
1741
- }
1742
- }
1743
- if (twHits / tokens.length >= 0.5) return true;
1744
- } else {
1745
- if (isMatch(trimmed)) return true;
1746
- }
1747
- return false;
1748
- }
1749
- function isParentSvgPathProperty(parent) {
1750
- if (!parent) return false;
1751
- if (parent.type === "Property" && "key" in parent && parent.key) {
1752
- const key = parent.key;
1753
- const keyName = key.type === "Identifier" ? key.name : key.type === "Literal" ? String(key.value) : "";
1754
- if (keyName === "d" || keyName === "path") return true;
1755
- }
1756
- if (parent.type === "JSXAttribute" && "name" in parent && parent.name) {
1757
- const attrName = parent.name.name;
1758
- if (attrName === "d" || attrName === "path") return true;
1759
- }
1760
- return false;
1761
- }
1762
- function isSvgPathString(val, parent) {
1763
- if (typeof val !== "string" || val.length < 4) return false;
1764
- const trimmed = val.trim();
1765
- if (!/^[Mm]\s*[-+]?(?:\d*\.\d+|\d+)/.test(trimmed)) {
1766
- return false;
1767
- }
1768
- if (parent && isParentSvgPathProperty(parent)) {
1769
- return true;
1770
- }
1771
- return /[zZ]$/.test(trimmed) || /[Mm]\s*[-+]?\d.*[a-df-zA-DF-Z]\s*[-+]?\d/.test(trimmed) || /^[Mm]\s*[-+]?\d+(?:\.\d+)?[\s,]+-?\d+(?:\.\d+)?(?:\s+[a-zA-Z][-+]?\d+.*)?$/.test(
1772
- trimmed
1773
- );
1774
- }
1775
- var DEFAULT_SEMANTIC_ANCHOR_RE = /(?:\bapi\/|\bcheckout\b|\badmin\b|\bauth\b|\btoken\b|\bcredential\b|\bsecret\b|\bpassword\b|\bbearer\b)/i;
1776
- function isUiClassName(val, parent) {
1777
- if (parent) {
1778
- if (parent.type === "Property") {
1779
- const k = _optionalChain([parent, 'access', _189 => _189.key, 'optionalAccess', _190 => _190.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _191 => _191.key, 'optionalAccess', _192 => _192.type]) === "Literal" ? String(parent.key.value) : "";
1780
- if (k === "className" || k === "class" || k === "classList") return true;
1781
- }
1782
- if (parent.type === "JSXAttribute") {
1783
- const name = _optionalChain([parent, 'access', _193 => _193.name, 'optionalAccess', _194 => _194.name]);
1784
- if (name === "className" || name === "class") return true;
1785
- }
1786
- }
1787
- if (isTailwindNoise(val)) return true;
1788
- if (/^[a-z0-9_-]+(?:\s+[a-z0-9_-]+)+$/i.test(val.trim())) {
1789
- return true;
1790
- }
1791
- return false;
1792
- }
1793
- function isAdversaryDecoy(val, seed) {
1794
- if (val.startsWith("/api/v2/auth/") || val === "superadmin_token" || val === "elevate" || val === "_verifyMasterToken" || val === "mock_jwt_bypass_signature" || val === "debug_supervisor_override" || val.startsWith("_decoy_") || val.startsWith("_auth_bypass_")) {
1795
- return true;
1796
- }
1797
- const s = (seed >>> 0 & 65535).toString(36);
1798
- if (val.includes(s) && (val.includes("auth") || val.includes("token") || val.includes("decoy") || val.includes("elevate"))) {
1799
- return true;
1800
- }
1801
- return false;
1802
- }
1803
- function isEligibleHotLiteral(val, node, parent, ancestors, minLen, seed = 2654435769, customReserved, activeDirectives = DIRECTIVE_STRINGS, semanticAnchorPatterns, excludeUiClasses = true) {
1804
- if (val.length < minLen || activeDirectives.has(val)) return false;
1805
- if (isReactDomSpecialProp(val, node, parent, customReserved)) return false;
1806
- if (isTailwindNoise(val)) return false;
1807
- if (isSvgPathString(val, parent)) return false;
1808
- for (let i = ancestors.length - 2; i >= 0; i--) {
1809
- if (LOOP_NODE_TYPES.has(ancestors[i].type)) {
1810
- return false;
1811
- }
1812
- }
1813
- for (let i = ancestors.length - 2; i >= 0; i--) {
1814
- if (ancestors[i]._unpeekSerialized) {
1815
- return false;
1816
- }
1817
- }
1818
- if (val.startsWith("HOT_")) return false;
1819
- let isSemanticAnchor = false;
1820
- if (semanticAnchorPatterns && semanticAnchorPatterns.length > 0) {
1821
- isSemanticAnchor = semanticAnchorPatterns.some((re) => re.test(val));
1822
- } else {
1823
- isSemanticAnchor = DEFAULT_SEMANTIC_ANCHOR_RE.test(val);
1824
- }
1825
- if (isSemanticAnchor && excludeUiClasses && isUiClassName(val, parent)) {
1826
- isSemanticAnchor = false;
1827
- }
1828
- let isInsideRender = false;
1829
- for (let i = ancestors.length - 2; i >= 0; i--) {
1830
- const a = ancestors[i];
1831
- if (a.type === "FunctionDeclaration" || a.type === "FunctionExpression" || a.type === "ArrowFunctionExpression") {
1832
- if (_optionalChain([a, 'access', _195 => _195.id, 'optionalAccess', _196 => _196.name]) && /^[A-Z]/.test(a.id.name)) {
1833
- isInsideRender = true;
1834
- break;
1835
- }
1836
- if (a._unpeekIsComponent) {
1837
- isInsideRender = true;
1838
- break;
1839
- }
1840
- }
1841
- }
1842
- if (!isSemanticAnchor && !isInsideRender) return false;
1843
- if (isAdversaryDecoy(val, seed)) {
1844
- return false;
1845
- }
1846
- if (parent) {
1847
- if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") {
1848
- if (parent.source === node) return false;
1849
- }
1850
- if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
1851
- return false;
1852
- }
1853
- if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
1854
- return false;
1855
- }
1856
- }
1857
- return true;
1858
- }
1859
- var SHADER_SIG_RE = /@group|@binding|@vertex|@fragment|@compute|vec4f|gl_Position|uniform/;
1860
- function shouldEncryptString(val, minLen, parent, activeDirectives = DIRECTIVE_STRINGS, customReserved) {
1861
- if (val.length < minLen || activeDirectives.has(val)) return false;
1862
- if (isReservedProp(val, customReserved)) return false;
1863
- if (isSvgPathString(val, parent)) return false;
1864
- if (isTailwindNoise(val)) return false;
1865
- return true;
1866
- }
1867
- function createPermutationTable(seed) {
1868
- let s = (seed || 305419896) >>> 0;
1869
- function xorshift() {
1870
- s ^= s << 13;
1871
- s ^= s >>> 17;
1872
- s ^= s << 5;
1873
- return s >>> 0;
1874
- }
1875
- const indices = [];
1876
- for (let i = 0; i < 92; i++) indices.push(i);
1877
- for (let i = 91; i > 0; i--) {
1878
- const j = xorshift() % (i + 1);
1879
- const tmp = indices[i];
1880
- indices[i] = indices[j];
1881
- indices[j] = tmp;
1882
- }
1883
- const B = new Array(92);
1884
- for (let i = 0; i < 46; i++) {
1885
- const a = indices[2 * i];
1886
- const b = indices[2 * i + 1];
1887
- B[a] = b;
1888
- B[b] = a;
1889
- }
1890
- let P_CHARS = "";
1891
- for (let i = 0; i < 92; i++) {
1892
- P_CHARS += SAFE_ALPHA[B[i]];
1893
- }
1894
- return P_CHARS;
1895
- }
1896
- function encodeStringWithSeed(str, P_CHARS, expectedKey, salt = 0, idx = 0) {
1897
- let out = "";
1898
- let st = (expectedKey >>> 0 ^ salt >>> 0 ^ Math.imul(idx + 1, 16777619)) >>> 0;
1899
- for (let j = 0; j < str.length; j++) {
1900
- st = Math.imul(st ^ j + 1, 16777619) ^ 2166136261 | 0;
1901
- const r1 = (st >>> 16) % 92;
1902
- const r2 = (st & 65535) % 92;
1903
- const c = str.charAt(j);
1904
- const k = SAFE_ALPHA.indexOf(c);
1905
- if (k < 0) {
1906
- out += c;
1907
- } else {
1908
- const y = (k + r1) % 92;
1909
- const z = SAFE_ALPHA.indexOf(P_CHARS.charAt(y));
1910
- out += SAFE_ALPHA.charAt((z + r2) % 92);
1911
- }
1912
- }
1913
- return out;
1914
- }
1915
- function uint8ArrayToBase64(bytes) {
1916
- if (typeof btoa === "function") {
1917
- let binary = "";
1918
- const CHUNK_SIZE = 32768;
1919
- for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
1920
- binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK_SIZE));
1921
- }
1922
- return btoa(binary);
1923
- }
1924
- if (typeof Buffer !== "undefined") {
1925
- return Buffer.from(bytes).toString("base64");
1926
- }
1927
- throw new Error("No base64 encoder available in this environment");
1928
- }
1929
- function createShaderVaultAst(shaderVarName, shaderPayloads, seed) {
1930
- const sSeed = seed >>> 0;
1931
- const fnCode = `(function f(B){var c=Function.prototype.toString.call(f),h=0x811c9dc5;for(var i=0;i<c.length;i++)h=Math.imul(h^c.charCodeAt(i),0x01000193)>>>0;var S=h^${sSeed},b=B.map(function(s){var n=typeof atob=="function"?atob(s):typeof Buffer<"u"?Buffer.from(s,"base64").toString("binary"):"",u=new Uint8Array(n.length);for(var i=0;i<n.length;i++)u[i]=n.charCodeAt(i);return u;}),d=typeof TextDecoder<"u"?new TextDecoder():null;function x(u,i){for(var r=(S^Math.imul(i+1,0x9e3779b1))|0,j=0;j<u.length;j++){r=(Math.imul(r^(j+1),0x45d9f3b)+0x85ebca6b)|0;u[j]^=(r>>>16)&255;}}return function(i){var u=b[i];x(u,i);try{return d?d.decode(u):String.fromCharCode.apply(null,u);}finally{x(u,i);}};})`;
1932
- const parsedProgram = acorn4.parse(fnCode, {
1933
- ecmaVersion: "latest",
1934
- sourceType: "script"
1935
- });
1936
- const firstStmt = parsedProgram.body[0];
1937
- const fnAst = firstStmt.expression;
1938
- const buildH = _chunk6N6S6WTQcjs.computeIntegrityHash.call(void 0, _chunk6N6S6WTQcjs.generateCompactJs.call(void 0, fnAst), 0);
1939
- const S = (buildH ^ sSeed) >>> 0;
1940
- const textEncoder = new TextEncoder();
1941
- const b64List = [];
1942
- for (let idx = 0; idx < shaderPayloads.length; idx++) {
1943
- const str = shaderPayloads[idx];
1944
- const bytes = textEncoder.encode(str);
1945
- let r = S ^ Math.imul(idx + 1, 2654435761) | 0;
1946
- for (let j = 0; j < bytes.length; j++) {
1947
- r = Math.imul(r ^ j + 1, 73244475) + 2246822507 | 0;
1948
- bytes[j] ^= r >>> 16 & 255;
1949
- }
1950
- b64List.push(uint8ArrayToBase64(bytes));
1951
- }
1952
- return createSaltedVaultHelperAst(shaderVarName, b64List, fnAst);
1953
- }
1954
- function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes, windowKeySymbol, expectedDelta, deterrentMode, config, shieldCoupled = true, detectHeadless = false) {
1955
- const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _197 => _197.vault, 'optionalAccess', _198 => _198.minStringLength]), () => ( minStringLength));
1956
- const activeDirectives = new Set(DIRECTIVE_STRINGS);
1957
- if (_optionalChain([config, 'optionalAccess', _199 => _199.vault, 'optionalAccess', _200 => _200.customDirectives])) {
1958
- for (const dir of config.vault.customDirectives) {
1959
- activeDirectives.add(dir);
1960
- }
1961
- }
1962
- const customReserved = _optionalChain([config, 'optionalAccess', _201 => _201.vault, 'optionalAccess', _202 => _202.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
1963
- const semanticPatterns = _optionalChain([config, 'optionalAccess', _203 => _203.vault, 'optionalAccess', _204 => _204.semanticAnchors, 'optionalAccess', _205 => _205.patterns]);
1964
- const excludeUi = _optionalChain([config, 'optionalAccess', _206 => _206.vault, 'optionalAccess', _207 => _207.semanticAnchors, 'optionalAccess', _208 => _208.excludeUiClasses]) !== false;
1965
- const suffix = (seed >>> 0 & 65535).toString(36);
1966
- const decryptFnName = `_uD${suffix}`;
1967
- const cacheVarName = _chunk6N6S6WTQcjs.derivePolymorphicIdent.call(void 0, seed, "vault");
1968
- const shaderVarName = _chunk6N6S6WTQcjs.derivePolymorphicIdent.call(void 0, seed, "shader");
1969
- const sym = _nullishCoalesce(windowKeySymbol, () => ( _chunk6N6S6WTQcjs.deriveWindowKeySymbol.call(void 0, seed)));
1970
- const browserOnly = _optionalChain([config, 'optionalAccess', _209 => _209.target]) === "browser";
1971
- let expDelta = shieldCoupled ? expectedDelta : 0;
1972
- if (shieldCoupled && expDelta === void 0) {
1973
- const shield = _chunk6N6S6WTQcjs.generateRuntimeShield.call(void 0, {
1974
- seed,
1975
- windowKeySymbol: sym,
1976
- deterrentMode: _nullishCoalesce(deterrentMode, () => ( "passive")),
1977
- detectHeadless
1978
- });
1979
- expDelta = _nullishCoalesce(shield.expectedDelta, () => ( 0));
1980
- }
1981
- const alreadyVaulted = ast.body.some(
1982
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _210 => _210.declarations, 'optionalAccess', _211 => _211.some, 'call', _212 => _212(
1983
- (d) => _optionalChain([d, 'access', _213 => _213.id, 'optionalAccess', _214 => _214.type]) === "Identifier" && typeof d.id.name === "string" && (d.id.name.startsWith("_uC") || d.id.name.startsWith("_uD") || d.id.name === decryptFnName || d.id.name === cacheVarName || _optionalChain([d, 'access', _215 => _215.init, 'optionalAccess', _216 => _216.type]) === "CallExpression" && _optionalChain([d, 'access', _217 => _217.init, 'access', _218 => _218.callee, 'optionalAccess', _219 => _219.type]) === "FunctionExpression" && _optionalChain([d, 'access', _220 => _220.init, 'access', _221 => _221.callee, 'optionalAccess', _222 => _222.id, 'optionalAccess', _223 => _223.name]) === "f" && _optionalChain([d, 'access', _224 => _224.init, 'access', _225 => _225.arguments, 'optionalAccess', _226 => _226[0], 'optionalAccess', _227 => _227.type]) === "ArrayExpression")
1984
- )])
1985
- );
1986
- if (alreadyVaulted) {
1987
- return {
1988
- encryptedStringsCount: 0,
1989
- integrityToken: _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "already-vaulted", seed),
1990
- shaderBuffersCount: 0
1991
- };
1992
- }
1993
- const P_CHARS = createPermutationTable(seed);
1994
- const fnAst = createSaltedDecryptorFnAst(
1995
- seed,
1996
- P_CHARS,
1997
- _nullishCoalesce(expDelta, () => ( 0)),
1998
- sym,
1999
- SAFE_ALPHA,
2000
- shieldCoupled,
2001
- browserOnly
2002
- );
2003
- const compactFnStr = _chunk6N6S6WTQcjs.generateCompactJs.call(void 0, fnAst);
2004
- const buildH = _chunk6N6S6WTQcjs.computeIntegrityHash.call(void 0, compactFnStr, 0);
2005
- const expectedKey = (buildH ^ 0 ^ (shieldCoupled ? (_nullishCoalesce(expDelta, () => ( 0))) & 65535 : 0)) >>> 0;
2006
- const stringToIndex = /* @__PURE__ */ new Map();
2007
- const encryptedPayloads = [];
2008
- const shaderToIndex = /* @__PURE__ */ new Map();
2009
- const shaderPayloads = [];
2010
- const targetsToReplace = [];
2011
- const hotTargetsToReplace = [];
2012
- const customWalkBase = {
2013
- ...walk3.base,
2014
- Property(node, st, c) {
2015
- c(node.key, st);
2016
- if (node.value) c(node.value, st);
2017
- }
2018
- };
2019
- walk3.ancestor(
2020
- ast,
2021
- {
2022
- Literal(node, _state, ancestors) {
2023
- if (typeof node.value !== "string") return;
2024
- const val = node.value;
2025
- if (activeDirectives.has(val)) return;
2026
- let isHotExempt = false;
2027
- if (hotExemptNodes) {
2028
- for (let i = ancestors.length - 2; i >= 0; i--) {
2029
- if (hotExemptNodes.has(ancestors[i])) {
2030
- isHotExempt = true;
2031
- break;
2032
- }
2033
- }
2034
- }
2035
- const parent = ancestors[ancestors.length - 2];
2036
- if (!parent) return;
2037
- if (parent.type === "ExpressionStatement" && (Boolean(parent.directive) || activeDirectives.has(val))) {
2038
- return;
2039
- }
2040
- for (let i = ancestors.length - 2; i >= 0; i--) {
2041
- if (ancestors[i].type === "ExpressionStatement" && Boolean(ancestors[i].directive)) {
2042
- return;
2043
- }
2044
- }
2045
- if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") {
2046
- if (parent.source === node) return;
2047
- }
2048
- if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
2049
- return;
2050
- }
2051
- if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
2052
- return;
2053
- }
2054
- if (isHotExempt) {
2055
- if (isEligibleHotLiteral(
2056
- val,
2057
- node,
2058
- parent,
2059
- ancestors,
2060
- minLen,
2061
- seed,
2062
- customReserved,
2063
- activeDirectives,
2064
- semanticPatterns,
2065
- excludeUi
2066
- )) {
2067
- hotTargetsToReplace.push({
2068
- node,
2069
- parent,
2070
- val,
2071
- idx: hotTargetsToReplace.length
2072
- });
2073
- }
2074
- return;
2075
- }
2076
- if (parent.type === "Property" && parent.key === node && !parent.computed) {
2077
- if (isReservedProp(val, customReserved)) {
2078
- return;
2079
- }
2080
- }
2081
- if (isReservedProp(val, customReserved)) return;
2082
- if (isTailwindNoise(val)) return;
2083
- if (isSvgPathString(val, parent)) return;
2084
- const isShader = val.length >= 256 || SHADER_SIG_RE.test(val);
2085
- if (isShader) {
2086
- let idx = shaderToIndex.get(val);
2087
- if (idx === void 0) {
2088
- idx = shaderPayloads.length;
2089
- shaderToIndex.set(val, idx);
2090
- shaderPayloads.push(val);
2091
- }
2092
- targetsToReplace.push({ type: "shader", node, parent, idx });
2093
- } else {
2094
- if (!shouldEncryptString(val, minLen, parent, activeDirectives, customReserved)) return;
2095
- let idx = stringToIndex.get(val);
2096
- if (idx === void 0) {
2097
- idx = encryptedPayloads.length;
2098
- stringToIndex.set(val, idx);
2099
- const salt = computeCallSiteSalt(seed, idx);
2100
- encryptedPayloads.push(
2101
- encodeStringWithSeed(val, P_CHARS, expectedKey, salt, idx)
2102
- );
2103
- }
2104
- targetsToReplace.push({ type: "string", node, parent, idx });
2105
- }
2106
- },
2107
- TemplateLiteral(node, _state, ancestors) {
2108
- if (!node.quasis || node.quasis.length !== 1) return;
2109
- if (node.expressions && node.expressions.length !== 0) return;
2110
- const val = _nullishCoalesce(node.quasis[0].value.cooked, () => ( node.quasis[0].value.raw));
2111
- if (typeof val !== "string" || activeDirectives.has(val)) return;
2112
- let isHotExempt = false;
2113
- if (hotExemptNodes) {
2114
- for (let i = ancestors.length - 2; i >= 0; i--) {
2115
- if (hotExemptNodes.has(ancestors[i])) {
2116
- isHotExempt = true;
2117
- break;
2118
- }
2119
- }
2120
- }
2121
- const parent = ancestors[ancestors.length - 2];
2122
- if (!parent) return;
2123
- if (parent.type === "ExpressionStatement" && (Boolean(parent.directive) || activeDirectives.has(val))) {
2124
- return;
2125
- }
2126
- for (let i = ancestors.length - 2; i >= 0; i--) {
2127
- if (ancestors[i].type === "ExpressionStatement" && Boolean(ancestors[i].directive)) {
2128
- return;
2129
- }
2130
- }
2131
- if (isHotExempt) {
2132
- if (isEligibleHotLiteral(
2133
- val,
2134
- node,
2135
- parent,
2136
- ancestors,
2137
- minLen,
2138
- seed,
2139
- customReserved,
2140
- activeDirectives,
2141
- semanticPatterns,
2142
- excludeUi
2143
- )) {
2144
- hotTargetsToReplace.push({
2145
- node,
2146
- parent,
2147
- val,
2148
- idx: hotTargetsToReplace.length
2149
- });
2150
- }
2151
- return;
2152
- }
2153
- if (isReservedProp(val, customReserved)) return;
2154
- if (isTailwindNoise(val)) return;
2155
- if (isSvgPathString(val, parent)) return;
2156
- const isShader = val.length >= 256 || SHADER_SIG_RE.test(val);
2157
- if (isShader) {
2158
- let idx = shaderToIndex.get(val);
2159
- if (idx === void 0) {
2160
- idx = shaderPayloads.length;
2161
- shaderToIndex.set(val, idx);
2162
- shaderPayloads.push(val);
2163
- }
2164
- targetsToReplace.push({ type: "shader", node, parent, idx });
2165
- } else {
2166
- if (!shouldEncryptString(val, minLen, parent, activeDirectives, customReserved)) return;
2167
- let idx = stringToIndex.get(val);
2168
- if (idx === void 0) {
2169
- idx = encryptedPayloads.length;
2170
- stringToIndex.set(val, idx);
2171
- const salt = computeCallSiteSalt(seed, idx);
2172
- encryptedPayloads.push(
2173
- encodeStringWithSeed(val, P_CHARS, expectedKey, salt, idx)
2174
- );
2175
- }
2176
- targetsToReplace.push({ type: "string", node, parent, idx });
2177
- }
2178
- }
2179
- },
2180
- customWalkBase
2181
- );
2182
- if (targetsToReplace.length === 0 && hotTargetsToReplace.length === 0) {
2183
- return {
2184
- encryptedStringsCount: 0,
2185
- integrityToken: _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "empty", seed),
2186
- shaderBuffersCount: 0
2187
- };
2188
- }
2189
- for (const { node, parent, val, idx } of hotTargetsToReplace) {
2190
- const key = idx % 3 + 1;
2191
- let encodedStr = "";
2192
- for (let i = 0; i < val.length; i++) {
2193
- encodedStr += String.fromCharCode(val.charCodeAt(i) ^ key);
2194
- }
2195
- if (_optionalChain([parent, 'optionalAccess', _228 => _228.type]) === "Property" && parent.key === node) {
2196
- parent.computed = true;
2197
- }
2198
- node.type = "CallExpression";
2199
- node.callee = {
2200
- type: "Identifier",
2201
- name: "_hX"
2202
- };
2203
- node.arguments = [
2204
- {
2205
- type: "Literal",
2206
- value: encodedStr,
2207
- raw: JSON.stringify(encodedStr)
2208
- },
2209
- {
2210
- type: "Literal",
2211
- value: key,
2212
- raw: String(key)
2213
- }
2214
- ];
2215
- node.optional = false;
2216
- delete node.value;
2217
- delete node.raw;
2218
- delete node.quasis;
2219
- delete node.expressions;
2220
- }
2221
- const serializedTable = JSON.stringify(encryptedPayloads);
2222
- const integrityToken = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, serializedTable, seed);
2223
- for (const { type, node, parent, idx } of targetsToReplace) {
2224
- if (_optionalChain([parent, 'optionalAccess', _229 => _229.type]) === "Property" && parent.key === node) {
2225
- parent.computed = true;
2226
- }
2227
- if (type === "shader") {
2228
- node.type = "CallExpression";
2229
- node.callee = {
2230
- type: "Identifier",
2231
- name: shaderVarName
2232
- };
2233
- node.arguments = [
2234
- {
2235
- type: "Literal",
2236
- value: idx,
2237
- raw: String(idx)
2238
- }
2239
- ];
2240
- node.optional = false;
2241
- delete node.value;
2242
- delete node.raw;
2243
- delete node.quasis;
2244
- delete node.expressions;
2245
- } else {
2246
- const salt = computeCallSiteSalt(seed, idx);
2247
- node.type = "CallExpression";
2248
- node.callee = {
2249
- type: "Identifier",
2250
- name: decryptFnName
2251
- };
2252
- node.arguments = [
2253
- {
2254
- type: "Literal",
2255
- value: idx,
2256
- raw: String(idx)
2257
- },
2258
- {
2259
- type: "Literal",
2260
- value: salt,
2261
- raw: String(salt)
2262
- }
2263
- ];
2264
- node.optional = false;
2265
- delete node.value;
2266
- delete node.raw;
2267
- delete node.quasis;
2268
- delete node.expressions;
2269
- }
2270
- }
2271
- let insertIdx = 0;
2272
- while (insertIdx < ast.body.length) {
2273
- const stmt = ast.body[insertIdx];
2274
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _230 => _230.expression, 'optionalAccess', _231 => _231.type]) === "Literal" && typeof stmt.expression.value === "string" && (activeDirectives.has(stmt.expression.value) || /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim())));
2275
- if (isDirective || stmt.type === "ImportDeclaration") {
2276
- insertIdx++;
2277
- } else {
2278
- break;
2279
- }
2280
- }
2281
- if (hotTargetsToReplace.length > 0) {
2282
- const alreadyHasHx = ast.body.some(
2283
- (stmt) => stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _232 => _232.id, 'optionalAccess', _233 => _233.name]) === "_hX"
2284
- );
2285
- if (!alreadyHasHx) {
2286
- const hxAst = acorn4.parse(
2287
- 'function _hX(s,k){var o="";for(var i=0;i<s.length;i++)o+=String.fromCharCode(s.charCodeAt(i)^k);return o;}',
2288
- { ecmaVersion: "latest", sourceType: "script" }
2289
- );
2290
- ast.body.splice(insertIdx++, 0, hxAst.body[0]);
2291
- }
2292
- }
2293
- if (encryptedPayloads.length > 0) {
2294
- const vaultHelperStmt = createSaltedVaultHelperAst(
2295
- decryptFnName,
2296
- encryptedPayloads,
2297
- fnAst
2298
- );
2299
- ast.body.splice(insertIdx++, 0, vaultHelperStmt);
2300
- }
2301
- if (shaderPayloads.length > 0) {
2302
- const shaderHelperStmt = createShaderVaultAst(
2303
- shaderVarName,
2304
- shaderPayloads,
2305
- seed
2306
- );
2307
- ast.body.splice(insertIdx++, 0, shaderHelperStmt);
2308
- }
2309
- return {
2310
- encryptedStringsCount: encryptedPayloads.length + hotTargetsToReplace.length,
2311
- integrityToken,
2312
- shaderBuffersCount: shaderPayloads.length
2313
- };
2314
- }
2315
-
2316
- // src/ast/polymorphic-mangler.ts
2317
-
2318
- var RESERVED_IDENTIFIERS = /* @__PURE__ */ new Set([
2319
- "arguments",
2320
- "undefined",
2321
- "NaN",
2322
- "Infinity",
2323
- "window",
2324
- "document",
2325
- "globalThis",
2326
- "self",
2327
- "console",
2328
- "Math",
2329
- "JSON",
2330
- "Object",
2331
- "Array",
2332
- "String",
2333
- "Number",
2334
- "Boolean",
2335
- "Symbol",
2336
- "BigInt",
2337
- "Promise",
2338
- "Map",
2339
- "Set",
2340
- "WeakMap",
2341
- "WeakSet",
2342
- "Error",
2343
- "TypeError",
2344
- "RangeError",
2345
- "SyntaxError",
2346
- "RegExp",
2347
- "Date",
2348
- "Reflect",
2349
- "Proxy",
2350
- "Intl",
2351
- "eval",
2352
- "process",
2353
- "Buffer",
2354
- "require",
2355
- "module",
2356
- "exports",
2357
- "React",
2358
- "navigator",
2359
- "crypto",
2360
- "location",
2361
- "history",
2362
- "indexedDB",
2363
- "fetch",
2364
- "WebSocket",
2365
- "Worker",
2366
- "AudioContext",
2367
- "performance"
2368
- ]);
2369
- var JS_KEYWORDS = /* @__PURE__ */ new Set([
2370
- "as",
2371
- "await",
2372
- "break",
2373
- "case",
2374
- "catch",
2375
- "class",
2376
- "const",
2377
- "continue",
2378
- "debugger",
2379
- "default",
2380
- "delete",
2381
- "do",
2382
- "else",
2383
- "enum",
2384
- "export",
2385
- "extends",
2386
- "false",
2387
- "finally",
2388
- "for",
2389
- "function",
2390
- "if",
2391
- "implements",
2392
- "import",
2393
- "in",
2394
- "instanceof",
2395
- "interface",
2396
- "let",
2397
- "new",
2398
- "null",
2399
- "of",
2400
- "package",
2401
- "private",
2402
- "protected",
2403
- "public",
2404
- "return",
2405
- "static",
2406
- "super",
2407
- "switch",
2408
- "this",
2409
- "throw",
2410
- "true",
2411
- "try",
2412
- "typeof",
2413
- "var",
2414
- "void",
2415
- "while",
2416
- "with",
2417
- "yield"
2418
- ]);
2419
- var FUNCTION_TYPES = /* @__PURE__ */ new Set([
2420
- "FunctionDeclaration",
2421
- "FunctionExpression",
2422
- "ArrowFunctionExpression"
2423
- ]);
2424
- var LEXICAL_SCOPE_TYPES = /* @__PURE__ */ new Set([
2425
- "Program",
2426
- "FunctionDeclaration",
2427
- "FunctionExpression",
2428
- "ArrowFunctionExpression",
2429
- "BlockStatement",
2430
- "ForStatement",
2431
- "ForInStatement",
2432
- "ForOfStatement",
2433
- "SwitchStatement",
2434
- "CatchClause",
2435
- "ClassDeclaration",
2436
- "ClassExpression"
2437
- ]);
2438
- function collectPatternTargets(pattern, out, shorthandProp) {
2439
- if (!pattern) return;
2440
- switch (pattern.type) {
2441
- case "Identifier":
2442
- out.push({ idNode: pattern, shorthandProp });
2443
- break;
2444
- case "AssignmentPattern":
2445
- collectPatternTargets(pattern.left, out, shorthandProp);
2446
- break;
2447
- case "RestElement":
2448
- collectPatternTargets(pattern.argument, out);
2449
- break;
2450
- case "ArrayPattern":
2451
- for (const el of pattern.elements || []) {
2452
- if (el) collectPatternTargets(el, out);
2453
- }
2454
- break;
2455
- case "ObjectPattern":
2456
- for (const prop of pattern.properties || []) {
2457
- if (prop.type === "Property") {
2458
- collectPatternTargets(
2459
- prop.value,
2460
- out,
2461
- prop.shorthand ? prop : void 0
2462
- );
2463
- } else if (prop.type === "RestElement") {
2464
- collectPatternTargets(prop.argument, out);
2465
- }
2466
- }
2467
- break;
2468
- }
2469
- }
2470
- function isMangleableName(origName, reservedSet = RESERVED_IDENTIFIERS, manglerConfig) {
2471
- const minLength = _nullishCoalesce(_optionalChain([manglerConfig, 'optionalAccess', _234 => _234.minLength]), () => ( 3));
2472
- return origName.length >= minLength && !reservedSet.has(origName) && !JS_KEYWORDS.has(origName) && !origName.startsWith("$") && !origName.startsWith("__") && !origName.startsWith("_u") && !origName.startsWith("_0x") && (!_optionalChain([manglerConfig, 'optionalAccess', _235 => _235.excludePrefixes]) || !manglerConfig.excludePrefixes.some((p) => origName.startsWith(p))) && (!_optionalChain([manglerConfig, 'optionalAccess', _236 => _236.excludePatterns]) || !manglerConfig.excludePatterns.some((re) => re.test(origName)));
2473
- }
2474
- function shuffleAlphabet(chars, seed) {
2475
- const arr = chars.split("");
2476
- let s = (seed || 324478056) >>> 0;
2477
- for (let i = arr.length - 1; i > 0; i--) {
2478
- s ^= s << 13;
2479
- s ^= s >>> 17;
2480
- s ^= s << 5;
2481
- const j = (s >>> 0) % (i + 1);
2482
- const tmp = arr[i];
2483
- arr[i] = arr[j];
2484
- arr[j] = tmp;
2485
- }
2486
- return arr;
2487
- }
2488
- function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes, config) {
2489
- const activeReserved = new Set(RESERVED_IDENTIFIERS);
2490
- if (_optionalChain([config, 'optionalAccess', _237 => _237.mangler, 'optionalAccess', _238 => _238.reservedIdentifiers])) {
2491
- for (const id of config.mangler.reservedIdentifiers) {
2492
- activeReserved.add(id);
2493
- }
2494
- }
2495
- const manglerConfig = _optionalChain([config, 'optionalAccess', _239 => _239.mangler]);
2496
- const scopeRecords = /* @__PURE__ */ new Map();
2497
- const barrierOrFreeIds = /* @__PURE__ */ new Set();
2498
- const renamedTargetNodes = /* @__PURE__ */ new WeakSet();
2499
- let counter = 0;
2500
- function ensureScopeChain(ancestors) {
2501
- let prevScope = null;
2502
- for (let i = 0; i < ancestors.length; i++) {
2503
- const node = ancestors[i];
2504
- if (!LEXICAL_SCOPE_TYPES.has(node.type)) continue;
2505
- let record = scopeRecords.get(node);
2506
- if (!record) {
2507
- const isFn = FUNCTION_TYPES.has(node.type);
2508
- const depth = prevScope ? prevScope.depth + (isFn ? 1 : 0) : 0;
2509
- record = {
2510
- node,
2511
- parent: prevScope,
2512
- children: [],
2513
- depth: Math.max(1, depth),
2514
- bindings: /* @__PURE__ */ new Map(),
2515
- usedNames: /* @__PURE__ */ new Set()
2516
- };
2517
- scopeRecords.set(node, record);
2518
- if (prevScope) {
2519
- prevScope.children.push(record);
2520
- }
2521
- }
2522
- prevScope = record;
2523
- }
2524
- return prevScope;
2525
- }
2526
- function findEnclosingFunctionNode(ancestors) {
2527
- for (let i = ancestors.length - 1; i >= 0; i--) {
2528
- if (FUNCTION_TYPES.has(ancestors[i].type)) {
2529
- return ancestors[i];
2530
- }
2531
- }
2532
- return null;
2533
- }
2534
- function findEnclosingLexicalNode(ancestors) {
2535
- for (let i = ancestors.length - 1; i >= 0; i--) {
2536
- if (LEXICAL_SCOPE_TYPES.has(ancestors[i].type)) {
2537
- return ancestors[i];
2538
- }
2539
- }
2540
- return ancestors[0];
2541
- }
2542
- function registerBindingTarget(scopeNode, target, shouldMangle, fnScope) {
2543
- const scope = scopeRecords.get(scopeNode);
2544
- if (!scope) return;
2545
- const origName = target.idNode.name;
2546
- let canMangle = shouldMangle && isMangleableName(origName, activeReserved, manglerConfig);
2547
- if (canMangle && fnScope) {
2548
- if (serializedFunctionNodes && serializedFunctionNodes.has(fnScope)) {
2549
- canMangle = false;
2550
- }
2551
- }
2552
- renamedTargetNodes.add(target.idNode);
2553
- let entry = scope.bindings.get(origName);
2554
- if (!entry) {
2555
- entry = {
2556
- origName,
2557
- shouldMangle: canMangle,
2558
- targets: [target],
2559
- mangledName: origName
2560
- };
2561
- scope.bindings.set(origName, entry);
2562
- } else {
2563
- if (!canMangle) {
2564
- entry.shouldMangle = false;
2565
- }
2566
- entry.targets.push(target);
2567
- }
2568
- if (!entry.shouldMangle) {
2569
- barrierOrFreeIds.add(origName);
2570
- }
2571
- }
2572
- function registerBarrierName(scopeNode, origName) {
2573
- barrierOrFreeIds.add(origName);
2574
- const scope = scopeRecords.get(scopeNode);
2575
- if (!scope) return;
2576
- let entry = scope.bindings.get(origName);
2577
- if (!entry) {
2578
- entry = {
2579
- origName,
2580
- shouldMangle: false,
2581
- targets: [],
2582
- mangledName: origName
2583
- };
2584
- scope.bindings.set(origName, entry);
2585
- } else {
2586
- entry.shouldMangle = false;
2587
- }
2588
- }
2589
- function registerFunctionParams(fnNode, ancestors) {
2590
- ensureScopeChain(ancestors);
2591
- for (const param of fnNode.params || []) {
2592
- const targets = [];
2593
- collectPatternTargets(param, targets);
2594
- for (const target of targets) {
2595
- registerBindingTarget(fnNode, target, true, fnNode);
2596
- }
2597
- }
2598
- }
2599
- ensureScopeChain([ast]);
2600
- walk4.ancestor(ast, {
2601
- BlockStatement(_node, _state, ancestors) {
2602
- ensureScopeChain(ancestors);
2603
- },
2604
- ForStatement(_node, _state, ancestors) {
2605
- ensureScopeChain(ancestors);
2606
- },
2607
- ForInStatement(_node, _state, ancestors) {
2608
- ensureScopeChain(ancestors);
2609
- },
2610
- ForOfStatement(_node, _state, ancestors) {
2611
- ensureScopeChain(ancestors);
2612
- },
2613
- SwitchStatement(_node, _state, ancestors) {
2614
- ensureScopeChain(ancestors);
2615
- },
2616
- ImportSpecifier(node) {
2617
- if (_optionalChain([node, 'access', _240 => _240.local, 'optionalAccess', _241 => _241.name])) barrierOrFreeIds.add(node.local.name);
2618
- },
2619
- ImportDefaultSpecifier(node) {
2620
- if (_optionalChain([node, 'access', _242 => _242.local, 'optionalAccess', _243 => _243.name])) barrierOrFreeIds.add(node.local.name);
2621
- },
2622
- ImportNamespaceSpecifier(node) {
2623
- if (_optionalChain([node, 'access', _244 => _244.local, 'optionalAccess', _245 => _245.name])) barrierOrFreeIds.add(node.local.name);
2624
- },
2625
- FunctionDeclaration(node, _state, ancestors) {
2626
- registerFunctionParams(node, ancestors);
2627
- if (_optionalChain([node, 'access', _246 => _246.id, 'optionalAccess', _247 => _247.type]) === "Identifier") {
2628
- const parentAncestors = ancestors.slice(0, -1);
2629
- const lexNode = findEnclosingLexicalNode(parentAncestors);
2630
- const fnNode = _nullishCoalesce(findEnclosingFunctionNode(parentAncestors), () => ( ast));
2631
- registerBarrierName(lexNode, node.id.name);
2632
- if (lexNode === fnNode.body || fnNode === ast) {
2633
- registerBarrierName(fnNode, node.id.name);
2634
- }
2635
- if (!_optionalChain([scopeRecords, 'access', _248 => _248.get, 'call', _249 => _249(node), 'optionalAccess', _250 => _250.bindings, 'access', _251 => _251.has, 'call', _252 => _252(node.id.name)])) {
2636
- registerBarrierName(node, node.id.name);
2637
- }
2638
- }
2639
- },
2640
- FunctionExpression(node, _state, ancestors) {
2641
- registerFunctionParams(node, ancestors);
2642
- if (_optionalChain([node, 'access', _253 => _253.id, 'optionalAccess', _254 => _254.type]) === "Identifier") {
2643
- if (!_optionalChain([scopeRecords, 'access', _255 => _255.get, 'call', _256 => _256(node), 'optionalAccess', _257 => _257.bindings, 'access', _258 => _258.has, 'call', _259 => _259(node.id.name)])) {
2644
- registerBarrierName(node, node.id.name);
2645
- }
2646
- }
2647
- },
2648
- ArrowFunctionExpression(node, _state, ancestors) {
2649
- registerFunctionParams(node, ancestors);
2650
- },
2651
- ClassDeclaration(node, _state, ancestors) {
2652
- ensureScopeChain(ancestors);
2653
- if (_optionalChain([node, 'access', _260 => _260.id, 'optionalAccess', _261 => _261.type]) === "Identifier") {
2654
- const parentAncestors = ancestors.slice(0, -1);
2655
- const lexNode = findEnclosingLexicalNode(parentAncestors);
2656
- registerBarrierName(lexNode, node.id.name);
2657
- registerBarrierName(node, node.id.name);
2658
- }
2659
- },
2660
- ClassExpression(node, _state, ancestors) {
2661
- ensureScopeChain(ancestors);
2662
- if (_optionalChain([node, 'access', _262 => _262.id, 'optionalAccess', _263 => _263.type]) === "Identifier") {
2663
- registerBarrierName(node, node.id.name);
2664
- }
2665
- },
2666
- CatchClause(node, _state, ancestors) {
2667
- ensureScopeChain(ancestors);
2668
- if (node.param) {
2669
- const fnScope = findEnclosingFunctionNode(ancestors);
2670
- const targets = [];
2671
- collectPatternTargets(node.param, targets);
2672
- for (const target of targets) {
2673
- registerBindingTarget(node, target, true, fnScope);
2674
- }
2675
- }
2676
- },
2677
- VariableDeclaration(node, _state, ancestors) {
2678
- ensureScopeChain(ancestors);
2679
- const fnScope = findEnclosingFunctionNode(ancestors);
2680
- if (!fnScope) {
2681
- for (const decl of node.declarations || []) {
2682
- const targets = [];
2683
- collectPatternTargets(decl.id, targets);
2684
- for (const target of targets) {
2685
- registerBarrierName(ast, target.idNode.name);
2686
- }
2687
- }
2688
- return;
2689
- }
2690
- const targetScopeNode = node.kind === "var" ? fnScope : findEnclosingLexicalNode(ancestors);
2691
- for (const decl of node.declarations || []) {
2692
- const targets = [];
2693
- collectPatternTargets(decl.id, targets);
2694
- for (const target of targets) {
2695
- const origName = target.idNode.name;
2696
- if (node.kind === "var") {
2697
- for (let i = ancestors.length - 1; i >= 0; i--) {
2698
- if (ancestors[i] === fnScope) break;
2699
- if (ancestors[i].type === "CatchClause") {
2700
- const catchScope = scopeRecords.get(ancestors[i]);
2701
- if (_optionalChain([catchScope, 'optionalAccess', _264 => _264.bindings, 'access', _265 => _265.has, 'call', _266 => _266(origName)])) {
2702
- registerBarrierName(ancestors[i], origName);
2703
- registerBarrierName(fnScope, origName);
2704
- }
2705
- }
2706
- }
2707
- }
2708
- registerBindingTarget(targetScopeNode, target, true, fnScope);
2709
- }
2710
- }
2711
- }
2712
- });
2713
- function resolveBinding(name, ancestors) {
2714
- for (let i = ancestors.length - 1; i >= 0; i--) {
2715
- const scope = scopeRecords.get(ancestors[i]);
2716
- if (scope && scope.bindings.has(name)) {
2717
- return scope.bindings.get(name);
2718
- }
2719
- }
2720
- return null;
2721
- }
2722
- function isNonVarIdentifierPosition(node, parent) {
2723
- if (!parent) return true;
2724
- if ((parent.type === "FunctionDeclaration" || parent.type === "FunctionExpression" || parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.id === node) {
2725
- return true;
2726
- }
2727
- if (parent.type === "MemberExpression" && parent.property === node && !parent.computed) {
2728
- return true;
2729
- }
2730
- if ((parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
2731
- return true;
2732
- }
2733
- if (parent.type === "LabeledStatement" || parent.type === "BreakStatement" || parent.type === "ContinueStatement" || parent.type === "ImportSpecifier" || parent.type === "ImportDefaultSpecifier" || parent.type === "ImportNamespaceSpecifier" || parent.type === "ExportSpecifier" || parent.type === "MetaProperty") {
2734
- return true;
2735
- }
2736
- return false;
2737
- }
2738
- walk4.ancestor(ast, {
2739
- Identifier(node, _state, ancestors) {
2740
- if (renamedTargetNodes.has(node)) return;
2741
- const parent = ancestors[ancestors.length - 2];
2742
- if (isNonVarIdentifierPosition(node, parent)) return;
2743
- const entry = resolveBinding(node.name, ancestors);
2744
- if (!entry || !entry.shouldMangle) {
2745
- barrierOrFreeIds.add(node.name);
2746
- }
2747
- }
2748
- });
2749
- function isNameUsedInScopeOrAncestors(candidate, scope) {
2750
- if (JS_KEYWORDS.has(candidate) || activeReserved.has(candidate) || barrierOrFreeIds.has(candidate)) {
2751
- return true;
2752
- }
2753
- let curr = scope;
2754
- while (curr) {
2755
- if (curr.usedNames.has(candidate)) {
2756
- return true;
2757
- }
2758
- curr = curr.parent;
2759
- }
2760
- return false;
2761
- }
2762
- const p1 = shuffleAlphabet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", seed);
2763
- const p2a = shuffleAlphabet(
2764
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
2765
- (seed ^ 1367130551) >>> 0
2766
- );
2767
- const p2b = shuffleAlphabet(
2768
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_",
2769
- (seed ^ 2654435769) >>> 0
2770
- );
2771
- function candidateAtSlot(slot) {
2772
- if (slot < p1.length) {
2773
- return p1[slot];
2774
- }
2775
- const rem = slot - p1.length;
2776
- const twoCharSpace = p2a.length * p2b.length;
2777
- if (rem < twoCharSpace) {
2778
- return `${p2a[rem % p2a.length]}${p2b[Math.floor(rem / p2a.length)]}`;
2779
- }
2780
- const rem3 = rem - twoCharSpace;
2781
- return `${p2a[rem3 % p2a.length]}${p2b[Math.floor(rem3 / p2a.length) % p2b.length]}${p2b[Math.floor(rem3 / twoCharSpace) % p2b.length]}`;
2782
- }
2783
- function makeScopedMangledName(scope, origName) {
2784
- let slot = 0;
2785
- while (true) {
2786
- const candidate = candidateAtSlot(slot);
2787
- slot++;
2788
- if (candidate === origName) continue;
2789
- if (!isNameUsedInScopeOrAncestors(candidate, scope)) {
2790
- return candidate;
2791
- }
2792
- }
2793
- }
2794
- function assignScopeNamesTopDown(scope) {
2795
- for (const entry of scope.bindings.values()) {
2796
- if (!entry.shouldMangle) {
2797
- entry.mangledName = entry.origName;
2798
- scope.usedNames.add(entry.origName);
2799
- continue;
2800
- }
2801
- const mangled = makeScopedMangledName(scope, entry.origName);
2802
- counter++;
2803
- entry.mangledName = mangled;
2804
- scope.usedNames.add(mangled);
2805
- for (const target of entry.targets) {
2806
- if (target.shorthandProp && target.shorthandProp.shorthand) {
2807
- target.shorthandProp.shorthand = false;
2808
- target.shorthandProp.key = {
2809
- type: "Identifier",
2810
- name: entry.origName
2811
- };
2812
- }
2813
- target.idNode.name = mangled;
2814
- }
2815
- }
2816
- for (const child of scope.children) {
2817
- assignScopeNamesTopDown(child);
2818
- }
2819
- }
2820
- const rootScope = scopeRecords.get(ast);
2821
- if (rootScope) {
2822
- assignScopeNamesTopDown(rootScope);
2823
- }
2824
- if (counter === 0) return 0;
2825
- function renamePatternTargetsInScope(pattern, ancestors) {
2826
- const targets = [];
2827
- collectPatternTargets(pattern, targets);
2828
- for (const target of targets) {
2829
- if (renamedTargetNodes.has(target.idNode)) continue;
2830
- const origName = target.idNode.name;
2831
- const entry = resolveBinding(origName, ancestors);
2832
- if (entry && entry.shouldMangle && entry.mangledName !== origName) {
2833
- if (target.shorthandProp && target.shorthandProp.shorthand) {
2834
- target.shorthandProp.shorthand = false;
2835
- target.shorthandProp.key = {
2836
- type: "Identifier",
2837
- name: origName
2838
- };
2839
- }
2840
- target.idNode.name = entry.mangledName;
2841
- renamedTargetNodes.add(target.idNode);
2842
- }
2843
- }
2844
- }
2845
- walk4.ancestor(ast, {
2846
- AssignmentExpression(node, _state, ancestors) {
2847
- renamePatternTargetsInScope(node.left, ancestors);
2848
- },
2849
- ForInStatement(node, _state, ancestors) {
2850
- if (node.left && node.left.type !== "VariableDeclaration") {
2851
- renamePatternTargetsInScope(node.left, ancestors);
2852
- }
2853
- },
2854
- ForOfStatement(node, _state, ancestors) {
2855
- if (node.left && node.left.type !== "VariableDeclaration") {
2856
- renamePatternTargetsInScope(node.left, ancestors);
2857
- }
2858
- },
2859
- Identifier(node, _state, ancestors) {
2860
- if (renamedTargetNodes.has(node)) return;
2861
- const parent = ancestors[ancestors.length - 2];
2862
- if (isNonVarIdentifierPosition(node, parent)) return;
2863
- const entry = resolveBinding(node.name, ancestors);
2864
- if (entry && entry.shouldMangle && entry.mangledName !== node.name) {
2865
- if (parent.type === "Property" && parent.shorthand && parent.value === node) {
2866
- parent.shorthand = false;
2867
- parent.key = { type: "Identifier", name: node.name };
2868
- }
2869
- node.name = entry.mangledName;
2870
- }
2871
- }
2872
- });
2873
- return counter;
2874
- }
2875
-
2876
- // src/ast/cold-flow-guard.ts
2877
-
2878
- function createDecoyObjectExpression(model) {
2879
- const m = Math.abs(model) % 3;
2880
- if (m === 0) {
2881
- return {
2882
- type: "ObjectExpression",
2883
- properties: [
2884
- {
2885
- type: "Property",
2886
- key: { type: "Identifier", name: "endpoint" },
2887
- value: {
2888
- type: "Literal",
2889
- value: "/api/v2/auth/admin-bypass",
2890
- raw: '"/api/v2/auth/admin-bypass"'
2891
- },
2892
- kind: "init",
2893
- computed: false,
2894
- method: false,
2895
- shorthand: false
2896
- },
2897
- {
2898
- type: "Property",
2899
- key: { type: "Identifier", name: "superadmin_token" },
2900
- value: { type: "Literal", value: 1, raw: "1" },
2901
- kind: "init",
2902
- computed: false,
2903
- method: false,
2904
- shorthand: false
2905
- },
2906
- {
2907
- type: "Property",
2908
- key: { type: "Identifier", name: "elevate" },
2909
- value: { type: "Literal", value: 1, raw: "1" },
2910
- kind: "init",
2911
- computed: false,
2912
- method: false,
2913
- shorthand: false
2914
- }
2915
- ]
2916
- };
2917
- }
2918
- if (m === 1) {
2919
- return {
2920
- type: "ObjectExpression",
2921
- properties: [
2922
- {
2923
- type: "Property",
2924
- key: { type: "Identifier", name: "endpoint" },
2925
- value: {
2926
- type: "Literal",
2927
- value: "/api/v2/auth/verify-master",
2928
- raw: '"/api/v2/auth/verify-master"'
2929
- },
2930
- kind: "init",
2931
- computed: false,
2932
- method: false,
2933
- shorthand: false
2934
- },
2935
- {
2936
- type: "Property",
2937
- key: { type: "Identifier", name: "_verifyMasterToken" },
2938
- value: { type: "Literal", value: true, raw: "true" },
2939
- kind: "init",
2940
- computed: false,
2941
- method: false,
2942
- shorthand: false
2943
- },
2944
- {
2945
- type: "Property",
2946
- key: { type: "Identifier", name: "_bypassToken" },
2947
- value: {
2948
- type: "Literal",
2949
- value: "mock_jwt_bypass_signature",
2950
- raw: '"mock_jwt_bypass_signature"'
2951
- },
2952
- kind: "init",
2953
- computed: false,
2954
- method: false,
2955
- shorthand: false
2956
- },
2957
- {
2958
- type: "Property",
2959
- key: { type: "Identifier", name: "authorized" },
2960
- value: { type: "Literal", value: true, raw: "true" },
2961
- kind: "init",
2962
- computed: false,
2963
- method: false,
2964
- shorthand: false
2965
- }
2966
- ]
2967
- };
2968
- }
2969
- return {
2970
- type: "ObjectExpression",
2971
- properties: [
2972
- {
2973
- type: "Property",
2974
- key: { type: "Identifier", name: "endpoint" },
2975
- value: {
2976
- type: "Literal",
2977
- value: "/api/v2/auth/debug-telemetry",
2978
- raw: '"/api/v2/auth/debug-telemetry"'
2979
- },
2980
- kind: "init",
2981
- computed: false,
2982
- method: false,
2983
- shorthand: false
2984
- },
2985
- {
2986
- type: "Property",
2987
- key: { type: "Identifier", name: "debug_supervisor_override" },
2988
- value: { type: "Literal", value: true, raw: "true" },
2989
- kind: "init",
2990
- computed: false,
2991
- method: false,
2992
- shorthand: false
2993
- },
2994
- {
2995
- type: "Property",
2996
- key: { type: "Identifier", name: "_bypassToken" },
2997
- value: {
2998
- type: "Literal",
2999
- value: "superadmin_token",
3000
- raw: '"superadmin_token"'
3001
- },
3002
- kind: "init",
3003
- computed: false,
3004
- method: false,
3005
- shorthand: false
3006
- },
3007
- {
3008
- type: "Property",
3009
- key: { type: "Identifier", name: "mfa_bypassed" },
3010
- value: { type: "Literal", value: true, raw: "true" },
3011
- kind: "init",
3012
- computed: false,
3013
- method: false,
3014
- shorthand: false
3015
- }
3016
- ]
3017
- };
3018
- }
3019
- function createDecoyConsequent(fnIndex) {
3020
- return {
3021
- type: "BlockStatement",
3022
- body: [
3023
- {
3024
- type: "ReturnStatement",
3025
- argument: createDecoyObjectExpression(fnIndex)
3026
- }
3027
- ]
3028
- };
3029
- }
3030
- function createSharedDecoyConsequent(decoyIdent, fnIndex) {
3031
- const model = Math.abs(fnIndex) % 3;
3032
- return {
3033
- type: "BlockStatement",
3034
- body: [
3035
- {
3036
- type: "ReturnStatement",
3037
- argument: {
3038
- type: "CallExpression",
3039
- callee: {
3040
- type: "MemberExpression",
3041
- computed: true,
3042
- object: { type: "Identifier", name: decoyIdent },
3043
- property: {
3044
- type: "Literal",
3045
- value: model,
3046
- raw: String(model)
3047
- }
3048
- },
3049
- arguments: []
3050
- }
3051
- }
3052
- ]
3053
- };
3054
- }
3055
- function createSharedDecoyDeclaration(decoyIdent = "_d", maxModels = 3) {
3056
- const count = Math.max(1, Math.min(3, maxModels));
3057
- const indices = [];
3058
- for (let i = 0; i < count; i++) indices.push(i);
3059
- return {
3060
- type: "VariableDeclaration",
3061
- kind: "var",
3062
- declarations: [
3063
- {
3064
- type: "VariableDeclarator",
3065
- id: { type: "Identifier", name: decoyIdent },
3066
- init: {
3067
- type: "ArrayExpression",
3068
- elements: indices.map((m) => ({
3069
- type: "ArrowFunctionExpression",
3070
- id: null,
3071
- params: [],
3072
- body: createDecoyObjectExpression(m),
3073
- generator: false,
3074
- async: false,
3075
- expression: true
3076
- }))
3077
- }
3078
- }
3079
- ]
3080
- };
3081
- }
3082
- function cloneNode(node) {
3083
- return JSON.parse(JSON.stringify(node));
3084
- }
3085
- function makeImul(left, right) {
3086
- return {
3087
- type: "CallExpression",
3088
- callee: {
3089
- type: "MemberExpression",
3090
- computed: false,
3091
- object: { type: "Identifier", name: "Math" },
3092
- property: { type: "Identifier", name: "imul" }
3093
- },
3094
- arguments: [left, right]
3095
- };
3096
- }
3097
- function makeBinary(operator, left, right) {
3098
- return {
3099
- type: "BinaryExpression",
3100
- operator,
3101
- left,
3102
- right
3103
- };
3104
- }
3105
- function makeUnary(operator, argument) {
3106
- return {
3107
- type: "UnaryExpression",
3108
- operator,
3109
- prefix: true,
3110
- argument
3111
- };
3112
- }
3113
- function makeLiteral(value) {
3114
- return {
3115
- type: "Literal",
3116
- value,
3117
- raw: String(value)
3118
- };
3119
- }
3120
- function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArrowFn = false) {
3121
- const family = Math.abs((seed + fnIndex) % 5);
3122
- const c1 = (seed >>> 1) + Math.imul(family + 1, 22912827) & 32767;
3123
- const c2 = (c1 ^ 173477) & 32767;
3124
- const target = (seed ^ Math.imul(family + 1, 2654435761)) & 65535 | 1;
3125
- let paramName = null;
3126
- if (typeof paramNode === "string") {
3127
- paramName = paramNode;
3128
- } else if (_optionalChain([paramNode, 'optionalAccess', _267 => _267.type]) === "Identifier") {
3129
- paramName = paramNode.name;
3130
- } else if (_optionalChain([paramNode, 'optionalAccess', _268 => _268.type]) === "AssignmentPattern" && _optionalChain([paramNode, 'access', _269 => _269.left, 'optionalAccess', _270 => _270.type]) === "Identifier") {
3131
- paramName = paramNode.left.name;
3132
- } else if (_optionalChain([paramNode, 'optionalAccess', _271 => _271.type]) === "RestElement" && _optionalChain([paramNode, 'access', _272 => _272.argument, 'optionalAccess', _273 => _273.type]) === "Identifier") {
3133
- paramName = paramNode.argument.name;
3134
- }
3135
- let vBitNode;
3136
- let vIntNode;
3137
- if (paramName && paramName !== "arguments" && paramName !== "eval") {
3138
- vBitNode = { type: "Identifier", name: paramName };
3139
- vIntNode = makeBinary("|", { type: "Identifier", name: paramName }, makeLiteral(0));
3140
- } else if (!isArrowFn) {
3141
- vBitNode = {
3142
- type: "MemberExpression",
3143
- computed: false,
3144
- object: { type: "Identifier", name: "arguments" },
3145
- property: { type: "Identifier", name: "length" }
3146
- };
3147
- vIntNode = cloneNode(vBitNode);
3148
- } else {
3149
- vBitNode = {
3150
- type: "MemberExpression",
3151
- computed: false,
3152
- object: makeUnary("typeof", { type: "Identifier", name: "globalThis" }),
3153
- property: { type: "Identifier", name: "length" }
3154
- };
3155
- vIntNode = cloneNode(vBitNode);
3156
- }
3157
- const kLit = makeLiteral(c2);
3158
- let mbaExpr;
3159
- if (family === 0) {
3160
- const term1 = makeImul(cloneNode(vIntNode), cloneNode(kLit));
3161
- const vAndK = makeBinary("&", cloneNode(vBitNode), cloneNode(kLit));
3162
- const vOrK = makeBinary("|", cloneNode(vBitNode), cloneNode(kLit));
3163
- const notK = makeUnary("~", cloneNode(kLit));
3164
- const notV = makeUnary("~", cloneNode(vBitNode));
3165
- const vAndNotK = makeBinary("&", cloneNode(vBitNode), notK);
3166
- const notVAndK = makeBinary("&", notV, cloneNode(kLit));
3167
- const term2 = makeImul(vAndK, vOrK);
3168
- const term3 = makeImul(vAndNotK, notVAndK);
3169
- const sumTerms = makeBinary("+", term2, term3);
3170
- mbaExpr = makeBinary("|", makeBinary("-", term1, sumTerms), makeLiteral(0));
3171
- } else if (family === 1) {
3172
- const vXorK1 = makeBinary("^", cloneNode(vBitNode), cloneNode(kLit));
3173
- const vXorK2 = makeBinary("^", cloneNode(vBitNode), cloneNode(kLit));
3174
- const term1 = makeImul(vXorK1, vXorK2);
3175
- const vSubK1 = makeBinary("-", cloneNode(vIntNode), cloneNode(kLit));
3176
- const vSubK2 = makeBinary("-", cloneNode(vIntNode), cloneNode(kLit));
3177
- const term2 = makeImul(vSubK1, vSubK2);
3178
- const notK = makeUnary("~", cloneNode(kLit));
3179
- const notV = makeUnary("~", cloneNode(vBitNode));
3180
- const vAndNotK = makeBinary("&", cloneNode(vBitNode), notK);
3181
- const notVAndK = makeBinary("&", notV, cloneNode(kLit));
3182
- const term3 = makeImul(vAndNotK, notVAndK);
3183
- const shiftTerm = makeBinary("<<", term3, makeLiteral(2));
3184
- const sumTerms = makeBinary("+", term2, shiftTerm);
3185
- mbaExpr = makeBinary("|", makeBinary("-", term1, sumTerms), makeLiteral(0));
3186
- } else if (family === 2) {
3187
- const vAddK1 = makeBinary("+", cloneNode(vIntNode), cloneNode(kLit));
3188
- const vAddK2 = makeBinary("+", cloneNode(vIntNode), cloneNode(kLit));
3189
- const term1 = makeImul(vAddK1, vAddK2);
3190
- const vAndK = makeBinary("&", cloneNode(vBitNode), cloneNode(kLit));
3191
- const vOrK = makeBinary("|", cloneNode(vBitNode), cloneNode(kLit));
3192
- const term2 = makeImul(vAndK, vOrK);
3193
- const shiftTerm = makeBinary("<<", term2, makeLiteral(2));
3194
- const vXorK1 = makeBinary("^", cloneNode(vBitNode), cloneNode(kLit));
3195
- const vXorK2 = makeBinary("^", cloneNode(vBitNode), cloneNode(kLit));
3196
- const term3 = makeImul(vXorK1, vXorK2);
3197
- const sumTerms = makeBinary("+", shiftTerm, term3);
3198
- mbaExpr = makeBinary("|", makeBinary("-", term1, sumTerms), makeLiteral(0));
3199
- } else if (family === 3) {
3200
- const vOrK1 = makeBinary("|", cloneNode(vBitNode), cloneNode(kLit));
3201
- const vOrK2 = makeBinary("|", cloneNode(vBitNode), cloneNode(kLit));
3202
- const term1 = makeImul(vOrK1, vOrK2);
3203
- const vAndK1 = makeBinary("&", cloneNode(vBitNode), cloneNode(kLit));
3204
- const vAndK2 = makeBinary("&", cloneNode(vBitNode), cloneNode(kLit));
3205
- const term2 = makeImul(vAndK1, vAndK2);
3206
- const vXorK = makeBinary("^", cloneNode(vBitNode), cloneNode(kLit));
3207
- const vAddK = makeBinary("+", cloneNode(vIntNode), cloneNode(kLit));
3208
- const term3 = makeImul(vXorK, vAddK);
3209
- const sumTerms = makeBinary("+", term2, term3);
3210
- mbaExpr = makeBinary("|", makeBinary("-", term1, sumTerms), makeLiteral(0));
3211
- } else {
3212
- const vk = makeBinary("^", cloneNode(vBitNode), cloneNode(kLit));
3213
- const vkSq = makeImul(vk, cloneNode(vk));
3214
- const sevenVkSqSub1 = makeBinary("-", makeImul(makeLiteral(7), vkSq), makeLiteral(1));
3215
- const vSq = makeImul(cloneNode(vBitNode), cloneNode(vBitNode));
3216
- const quadDiff = makeBinary("^", makeBinary("&", makeBinary("^", sevenVkSqSub1, vSq), makeLiteral(2)), makeLiteral(2));
3217
- const parityTerm = makeBinary("&", makeBinary("+", makeImul(cloneNode(vBitNode), cloneNode(vBitNode)), cloneNode(vIntNode)), makeLiteral(1));
3218
- mbaExpr = makeBinary("|", quadDiff, parityTerm);
3219
- }
3220
- const decoyIdx = Math.abs(fnIndex) % 3;
3221
- const consequent = decoyIdent ? createSharedDecoyConsequent(decoyIdent, decoyIdx) : createDecoyConsequent(decoyIdx);
3222
- return {
3223
- type: "IfStatement",
3224
- test: {
3225
- type: "BinaryExpression",
3226
- operator: "===",
3227
- left: mbaExpr,
3228
- right: { type: "Literal", value: target, raw: String(target) }
3229
- },
3230
- consequent,
3231
- alternate: null
3232
- };
3233
- }
3234
- var MAX_COLD_GUARDS_PER_CHUNK = 12;
3235
- function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExemptNodes) {
3236
- const decoyIdent = "_d";
3237
- if (Array.isArray(ast.body)) {
3238
- const alreadyGuarded = ast.body.some(
3239
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _274 => _274.declarations, 'optionalAccess', _275 => _275.some, 'call', _276 => _276(
3240
- (d) => _optionalChain([d, 'access', _277 => _277.id, 'optionalAccess', _278 => _278.type]) === "Identifier" && d.id.name === decoyIdent
3241
- )])
3242
- );
3243
- if (alreadyGuarded) return 0;
3244
- }
3245
- let guardedCount = 0;
3246
- function maybeInjectGuard(node) {
3247
- if (guardedCount >= MAX_COLD_GUARDS_PER_CHUNK) return;
3248
- if (!coldFunctionNodes.has(node)) return;
3249
- if (!node.body || node.body.type !== "BlockStatement") return;
3250
- const firstParam = _optionalChain([node, 'access', _279 => _279.params, 'optionalAccess', _280 => _280[0]]);
3251
- const isArrow = node.type === "ArrowFunctionExpression";
3252
- const guardStmt = createSotaMbaPredicate(
3253
- seed,
3254
- guardedCount,
3255
- firstParam,
3256
- decoyIdent,
3257
- isArrow
3258
- );
3259
- guardedCount++;
3260
- if (hotExemptNodes) {
3261
- hotExemptNodes.add(guardStmt);
3262
- hotExemptNodes.add(guardStmt.consequent);
3263
- }
3264
- let insertIdx = 0;
3265
- while (insertIdx < node.body.body.length && node.body.body[insertIdx].type === "ExpressionStatement" && node.body.body[insertIdx].directive) {
3266
- insertIdx++;
3267
- }
3268
- node.body.body.splice(insertIdx, 0, guardStmt);
3269
- }
3270
- walk5.simple(ast, {
3271
- FunctionDeclaration: maybeInjectGuard,
3272
- FunctionExpression: maybeInjectGuard,
3273
- ArrowFunctionExpression: maybeInjectGuard
3274
- });
3275
- if (guardedCount > 0 && Array.isArray(ast.body)) {
3276
- const sharedDecoyDecl = createSharedDecoyDeclaration(decoyIdent, guardedCount);
3277
- if (hotExemptNodes) {
3278
- hotExemptNodes.add(sharedDecoyDecl);
3279
- for (const decl of sharedDecoyDecl.declarations || []) {
3280
- if (_optionalChain([decl, 'access', _281 => _281.init, 'optionalAccess', _282 => _282.type]) === "ArrayExpression" && decl.init.elements) {
3281
- for (const el of decl.init.elements) {
3282
- if (el) hotExemptNodes.add(el);
3283
- }
3284
- }
3285
- }
3286
- }
3287
- let insertIdx = 0;
3288
- while (insertIdx < ast.body.length && ast.body[insertIdx].type === "ExpressionStatement" && ast.body[insertIdx].directive) {
3289
- insertIdx++;
3290
- }
3291
- ast.body.splice(insertIdx, 0, sharedDecoyDecl);
3292
- }
3293
- return guardedCount;
3294
- }
3295
-
3296
- // src/ast/micro-vm.ts
3297
-
3298
-
3299
- var OP_LDC = 0;
3300
- var OP_LDV = 1;
3301
- var OP_STV = 2;
3302
- var OP_LDG = 3;
3303
- var OP_GETP = 4;
3304
- var OP_SETP = 5;
3305
- var OP_CALL = 6;
3306
- var OP_MCALL = 7;
3307
- var OP_ADD = 8;
3308
- var OP_SUB = 9;
3309
- var OP_MUL = 10;
3310
- var OP_XOR = 11;
3311
- var OP_AND = 12;
3312
- var OP_OR = 13;
3313
- var OP_SEQ = 14;
3314
- var OP_LT = 15;
3315
- var OP_NOT = 16;
3316
- var OP_JMP = 17;
3317
- var OP_JZ = 18;
3318
- var OP_RET = 19;
3319
- var OP_THROW = 20;
3320
- var OP_AWAIT = 21;
3321
- var OP_OBJ = 22;
3322
- var OP_ARR = 23;
3323
- var OP_LDU = 24;
3324
- var OP_STU = 25;
3325
- var OPCODE_COUNT = 26;
3326
- function shuffleRange(n, seed) {
3327
- const arr = [];
3328
- for (let i = 0; i < n; i++) arr.push(i);
3329
- let s = (seed || 324478056) >>> 0;
3330
- function rand() {
3331
- s ^= s << 13;
3332
- s ^= s >>> 17;
3333
- s ^= s << 5;
3334
- return (s >>> 0) / 4294967296;
3335
- }
3336
- for (let i = arr.length - 1; i > 0; i--) {
3337
- const j = Math.floor(rand() * (i + 1));
3338
- const tmp = arr[i];
3339
- arr[i] = arr[j];
3340
- arr[j] = tmp;
3341
- }
3342
- return arr;
3343
- }
3344
- function deriveVmKey(seed) {
3345
- return _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "vm-key", seed) | 0;
3346
- }
3347
- function encryptBytecodeStream(plainBytecode, fnSalt, vmKey, stateSlots) {
3348
- const len = plainBytecode.length;
3349
- const enc = new Array(len);
3350
- const stateBefore = new Array(len + 1);
3351
- const stAtSlot = /* @__PURE__ */ new Map();
3352
- let st = vmKey ^ fnSalt | 0;
3353
- for (let p = 0; p < len; p++) {
3354
- stateBefore[p] = st;
3355
- if (stateSlots && stateSlots.has(p)) {
3356
- stAtSlot.set(p, st);
3357
- enc[p] = 0;
3358
- } else {
3359
- st = Math.imul(st ^ p + 1, 73244475) + 2654435769 | 0;
3360
- const raw = plainBytecode[p] ^ st >>> 16 & 65535;
3361
- enc[p] = raw;
3362
- st = st ^ Math.imul(raw + 1, 2246822507) | 0;
3363
- }
3364
- }
3365
- stateBefore[len] = st;
3366
- if (stateSlots) {
3367
- for (const slot of stateSlots) {
3368
- const targetPc = plainBytecode[slot - 1];
3369
- const sBefore = _nullishCoalesce(stAtSlot.get(slot), () => ( 0));
3370
- enc[slot] = stateBefore[targetPc] ^ sBefore | 0;
3371
- }
3372
- }
3373
- return enc;
3374
- }
3375
- function generateOpcodeMap(seed, count = OPCODE_COUNT) {
3376
- const pool = [];
3377
- for (let i = 0; i < 256; i++) pool.push(i);
3378
- let s = (seed ^ 2779096485) >>> 0;
3379
- function rand() {
3380
- s ^= s << 13;
3381
- s ^= s >>> 17;
3382
- s ^= s << 5;
3383
- return (s >>> 0) / 4294967296;
3384
- }
3385
- for (let i = pool.length - 1; i > 0; i--) {
3386
- const j = Math.floor(rand() * (i + 1));
3387
- const tmp = pool[i];
3388
- pool[i] = pool[j];
3389
- pool[j] = tmp;
3390
- }
3391
- return pool.slice(0, count);
3392
- }
3393
- function createInterpreterSource(vmHelperName, opMap, seed = 2654435769, windowKeySymbol, expectedDelta) {
3394
- const opCount = opMap.length;
3395
- const slotMap = shuffleRange(opCount, (seed ^ 1367130551) >>> 0);
3396
- const pairOrder = shuffleRange(opCount, (seed ^ 1013904242) >>> 0);
3397
- const opMask = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "vm-opmask", seed) & 255 | 1;
3398
- const slotMask = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "vm-slotmask", seed) & 127 | 32;
3399
- const vmKey = deriveVmKey(seed);
3400
- const pairs = [];
3401
- for (const op of pairOrder) {
3402
- pairs.push(opMap[op] ^ opMask, slotMap[op] ^ slotMask);
3403
- }
3404
- const handlerMap = {
3405
- [OP_LDC]: "function($f){$f.q[$f.r++]=$f.k[$rd($f)];}",
3406
- [OP_LDV]: "function($f){$f.q[$f.r++]=$f.s[$rd($f)];}",
3407
- [OP_STV]: "function($f){$f.s[$rd($f)]=$f.q[--$f.r];}",
3408
- [OP_LDG]: "function($f){$f.q[$f.r++]=$G[$f.k[$rd($f)]];}",
3409
- [OP_GETP]: "function($f){var $b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=$a[$b];}",
3410
- [OP_SETP]: "function($f){var $v=$f.q[--$f.r],$b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=($a[$b]=$v);}",
3411
- [OP_CALL]: "function($f){var $n=$rd($f),$g=[];for(var $i=$n-1;$i>=0;$i--)$g[$i]=$f.q[--$f.r];var $fn=$f.q[--$f.r];$f.q[$f.r++]=$fn.apply(void 0,$g);}",
3412
- [OP_MCALL]: "function($f){var $n=$rd($f),$g=[];for(var $i=$n-1;$i>=0;$i--)$g[$i]=$f.q[--$f.r];var $b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=$a[$b].apply($a,$g);}",
3413
- [OP_ADD]: "function($f){var $b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=$a+$b;}",
3414
- [OP_SUB]: "function($f){var $b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=$a-$b;}",
3415
- [OP_MUL]: "function($f){var $b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=$a*$b;}",
3416
- [OP_XOR]: "function($f){var $b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=$a^$b;}",
3417
- [OP_AND]: "function($f){var $b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=$a&$b;}",
3418
- [OP_OR]: "function($f){var $b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=$a|$b;}",
3419
- [OP_SEQ]: "function($f){var $b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=$a===$b;}",
3420
- [OP_LT]: "function($f){var $b=$f.q[--$f.r],$a=$f.q[--$f.r];$f.q[$f.r++]=$a<$b;}",
3421
- [OP_NOT]: "function($f){$f.q[$f.r-1]=!$f.q[$f.r-1];}",
3422
- [OP_JMP]: "function($f){var $j=$rd($f),$ts=$f.c[$f.p++]^$f.st;$f.p=$j;$f.st=$ts;}",
3423
- [OP_JZ]: "function($f){var $j=$rd($f),$ts=$f.c[$f.p++]^$f.st;if(!$f.q[--$f.r]){$f.p=$j;$f.st=$ts;}}",
3424
- [OP_RET]: "function($f){$f.d=1;$f.v=$f.q[--$f.r];}",
3425
- [OP_THROW]: "function($f){throw $f.q[--$f.r];}",
3426
- [OP_AWAIT]: "function($f){var $v=$f.q[--$f.r];$f.d=2;$f.v=Promise.resolve($v).then(function($w){$f.d=0;$f.q[$f.r++]=$w;return $x($f);});}",
3427
- [OP_OBJ]: "function($f){var $n=$rd($f),$o={},$e=[];for(var $i=0;$i<$n;$i++){var $v=$f.q[--$f.r],$k0=$f.q[--$f.r];$e.push([$k0,$v]);}for(var $i=$e.length-1;$i>=0;$i--){$o[$e[$i][0]]=$e[$i][1];}$f.q[$f.r++]=$o;}",
3428
- [OP_ARR]: "function($f){var $n=$rd($f),$a=[];for(var $i=$n-1;$i>=0;$i--)$a[$i]=$f.q[--$f.r];$f.q[$f.r++]=$a;}",
3429
- [OP_LDU]: "function($f){$f.q[$f.r++]=$f.u[$rd($f)][0]();}",
3430
- [OP_STU]: "function($f){$f.u[$rd($f)][1]($f.q[--$f.r]);}"
3431
- };
3432
- const handlers = new Array(opCount);
3433
- for (let op = 0; op < opCount; op++) {
3434
- handlers[slotMap[op]] = handlerMap[op];
3435
- }
3436
- const hasSym = Boolean(windowKeySymbol && expectedDelta !== void 0);
3437
- const symPropAccess = hasSym ? /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(windowKeySymbol) ? `.${windowKeySymbol}` : `[${JSON.stringify(windowKeySymbol)}]` : "";
3438
- const dDecl = hasSym ? `var $d=$G${symPropAccess}!=null?$G${symPropAccess}:($W?-1:(($h^$D)&0xffff));` : "";
3439
- const okExpr = hasSym ? `(($h&255)^$A^($d&255))&255` : `(($h&255)^$A)&255`;
3440
- const skExpr = hasSym ? `((($h>>>8)&255)^$B^(($d>>>8)&255))&255` : `((($h>>>8)&255)^$B)&255`;
3441
- const vkExpr = hasSym ? `($h^$C^Math.imul($d|0,0x9e3779b1))|0` : `($h^$C)|0`;
3442
- const paramsList = hasSym ? "$P,$A,$B,$C,$D" : "$P,$A,$B,$C";
3443
- const factoryRaw = `(function $I(${paramsList}){var $G=typeof globalThis<"u"?globalThis:(typeof window<"u"?window:this);${hasSym ? 'var $W=typeof window<"u"||typeof self<"u";' : ""}var $ts=Function.prototype.toString,$s=$ts.call($I);for(var $h=0x811c9dc5,$i=0;$i<$s.length;$i++)$h=Math.imul($h^$s.charCodeAt($i),0x01000193)>>>0;try{$ts.call(0);$h^=1;}catch($e){}var $M,$ok,$sk,$vk,$in=0;function $init(){$in=1;${dDecl}$ok=${okExpr};$sk=${skExpr};$vk=${vkExpr};$M=[];for(var $j=0;$j<$P.length;$j+=2)$M[$P[$j]]=$P[$j+1];}function $rd($f){var $p=$f.p++;var $x0=$f.st=(Math.imul($f.st^($p+1),0x45d9f3b)+0x9e3779b9)|0;var $w=$f.c[$p],$v=$w^(($x0>>>16)&0xffff);$f.st=($f.st^Math.imul($w+1,0x85ebca6b))|0;return $v;}var $H;function $x($f){while($f.p<$f.c.length){var $o=$rd($f),$m=$M[$o^$ok];if($m!==void 0){var $h0=$H[$m^$sk];if($h0)$h0($f);}if($f.d)return $f.v;}}$H=[${handlers.join(
3444
- ","
3445
- )}];return function($c,$k,$s0,$t,$a,$u){if(!$in)$init();return $x({c:$c,k:$k,s:$s0,t:$t,u:$u||[],q:[],r:0,p:0,st:($vk^$a)|0,d:0,v:void 0});};})`;
3446
- const parsedFactory = acorn5.parse(factoryRaw, {
3447
- ecmaVersion: "latest",
3448
- sourceType: "script"
3449
- });
3450
- const factoryExpr = parsedFactory.body[0].expression;
3451
- const compactFactory = _chunk6N6S6WTQcjs.generateCompactJs.call(void 0, factoryExpr);
3452
- const buildH = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, compactFactory);
3453
- const expD = hasSym ? expectedDelta & 65535 : 0;
3454
- const argA = (opMask ^ buildH & 255 ^ expD & 255) & 255;
3455
- const argB = (slotMask ^ buildH >>> 8 & 255 ^ expD >>> 8 & 255) & 255;
3456
- const argC = vmKey ^ buildH ^ (hasSym ? Math.imul(expD | 0, 2654435761) : 0) | 0;
3457
- const argD = hasSym ? (buildH ^ expD) & 65535 : 0;
3458
- return `var ${vmHelperName}=(${compactFactory})([${pairs.join(",")}],${argA},${argB},${argC}${hasSym ? `,${argD}` : ""});`;
3459
- }
3460
- function countAstNodes(node) {
3461
- let count = 0;
3462
- walk6.full(node, () => {
3463
- count++;
3464
- });
3465
- return count;
3466
- }
3467
- function hasForbiddenConstructs(fnNode) {
3468
- let forbidden = false;
3469
- walk6.full(fnNode, (node) => {
3470
- if (forbidden) return;
3471
- const type = node.type;
3472
- if (type === "JSXElement" || type === "JSXFragment" || type === "Super" || type === "YieldExpression" || type === "WithStatement") {
3473
- forbidden = true;
3474
- return;
3475
- }
3476
- if (type === "Identifier" && (node.name === "arguments" || node.name === "eval")) {
3477
- forbidden = true;
3478
- return;
3479
- }
3480
- if (type === "MetaProperty") {
3481
- forbidden = true;
3482
- return;
3483
- }
3484
- });
3485
- return forbidden;
3486
- }
3487
- var FUNCTION_NODE_TYPES2 = /* @__PURE__ */ new Set([
3488
- "FunctionDeclaration",
3489
- "FunctionExpression",
3490
- "ArrowFunctionExpression"
3491
- ]);
3492
- var LEXICAL_SCOPE_TYPES2 = /* @__PURE__ */ new Set([
3493
- "Program",
3494
- "FunctionDeclaration",
3495
- "FunctionExpression",
3496
- "ArrowFunctionExpression",
3497
- "BlockStatement",
3498
- "ForStatement",
3499
- "ForInStatement",
3500
- "ForOfStatement",
3501
- "SwitchStatement",
3502
- "CatchClause",
3503
- "ClassDeclaration",
3504
- "ClassExpression"
3505
- ]);
3506
- function collectPatternNames(pattern, out) {
3507
- if (!pattern) return;
3508
- switch (pattern.type) {
3509
- case "Identifier":
3510
- out.add(pattern.name);
3511
- break;
3512
- case "AssignmentPattern":
3513
- collectPatternNames(pattern.left, out);
3514
- break;
3515
- case "RestElement":
3516
- collectPatternNames(pattern.argument, out);
3517
- break;
3518
- case "ArrayPattern":
3519
- for (const el of pattern.elements || []) {
3520
- if (el) collectPatternNames(el, out);
3521
- }
3522
- break;
3523
- case "ObjectPattern":
3524
- for (const prop of pattern.properties || []) {
3525
- if (prop.type === "Property") {
3526
- collectPatternNames(prop.value, out);
3527
- } else if (prop.type === "RestElement") {
3528
- collectPatternNames(prop.argument, out);
3529
- }
3530
- }
3531
- break;
3532
- }
3533
- }
3534
- function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
3535
- const bytecode = [];
3536
- const consts = [];
3537
- const stateSlots = /* @__PURE__ */ new Set();
3538
- const fnScope = /* @__PURE__ */ new Map();
3539
- const scopeStack = [fnScope];
3540
- const upvalues = [];
3541
- const upvalueMap = /* @__PURE__ */ new Map();
3542
- let localCount = 0;
3543
- for (const param of fnNode.params) {
3544
- if (param.type !== "Identifier") return null;
3545
- if (fnScope.has(param.name)) return null;
3546
- fnScope.set(param.name, localCount++);
3547
- }
3548
- let invalidDecl = false;
3549
- function scanVarDecls(node, isTopBody) {
3550
- if (!node || invalidDecl) return;
3551
- if (Array.isArray(node)) {
3552
- for (const item of node) scanVarDecls(item, isTopBody);
3553
- return;
3554
- }
3555
- if (typeof node !== "object" || !node.type) return;
3556
- if (FUNCTION_NODE_TYPES2.has(node.type)) return;
3557
- if (node.type === "VariableDeclaration") {
3558
- const isVar = node.kind === "var";
3559
- if (isVar || isTopBody) {
3560
- for (const decl of node.declarations || []) {
3561
- if (_optionalChain([decl, 'access', _283 => _283.id, 'optionalAccess', _284 => _284.type]) !== "Identifier") {
3562
- invalidDecl = true;
3563
- return;
3564
- }
3565
- if (!fnScope.has(decl.id.name)) {
3566
- fnScope.set(decl.id.name, localCount++);
3567
- }
3568
- }
3569
- }
3570
- return;
3571
- }
3572
- if (node.type === "BlockStatement") {
3573
- for (const s of node.body || []) {
3574
- scanVarDecls(s, false);
3575
- }
3576
- return;
3577
- }
3578
- if (node.type === "IfStatement") {
3579
- scanVarDecls(node.consequent, false);
3580
- if (node.alternate) scanVarDecls(node.alternate, false);
3581
- }
3582
- }
3583
- if (fnNode.body.type === "BlockStatement") {
3584
- for (const stmt of fnNode.body.body || []) {
3585
- scanVarDecls(stmt, true);
3586
- if (invalidDecl) return null;
3587
- }
3588
- }
3589
- function resolveLocal(name) {
3590
- for (let i = scopeStack.length - 1; i >= 0; i--) {
3591
- const slot = scopeStack[i].get(name);
3592
- if (slot !== void 0) return slot;
3593
- }
3594
- return void 0;
3595
- }
3596
- function getOrCreateUpvalue(name, isWritten) {
3597
- let idx = upvalueMap.get(name);
3598
- if (idx === void 0) {
3599
- idx = upvalues.length;
3600
- upvalueMap.set(name, idx);
3601
- upvalues.push({ name, isWritten });
3602
- } else if (isWritten) {
3603
- upvalues[idx].isWritten = true;
3604
- }
3605
- return idx;
3606
- }
3607
- function emitLoadVar(name) {
3608
- const localSlot = resolveLocal(name);
3609
- if (localSlot !== void 0) {
3610
- emit(OP_LDV, localSlot);
3611
- return;
3612
- }
3613
- if (enclosingBindings && enclosingBindings.has(name)) {
3614
- emit(OP_LDU, getOrCreateUpvalue(name, false));
3615
- return;
3616
- }
3617
- const idx = addConst(name);
3618
- emit(OP_LDG, idx);
3619
- }
3620
- function canWriteVar(name) {
3621
- if (resolveLocal(name) !== void 0) return true;
3622
- return Boolean(enclosingBindings && enclosingBindings.has(name));
3623
- }
3624
- function emitStoreVar(name) {
3625
- const localSlot = resolveLocal(name);
3626
- if (localSlot !== void 0) {
3627
- emit(OP_STV, localSlot);
3628
- return true;
3629
- }
3630
- if (enclosingBindings && enclosingBindings.has(name)) {
3631
- emit(OP_STU, getOrCreateUpvalue(name, true));
3632
- return true;
3633
- }
3634
- return false;
3635
- }
3636
- function addConst(val) {
3637
- for (let i = 0; i < consts.length; i++) {
3638
- if (Object.is(consts[i], val)) return i;
3639
- }
3640
- const idx = consts.length;
3641
- consts.push(val);
3642
- return idx;
3643
- }
3644
- function emit(op, ...args) {
3645
- bytecode.push(opMap[op]);
3646
- for (const a of args) bytecode.push(a);
3647
- }
3648
- function compileExpr(node, inValuePos = true) {
3649
- if (!node) return false;
3650
- switch (node.type) {
3651
- case "Literal": {
3652
- if (node.regex || typeof node.value === "bigint") return false;
3653
- const idx = addConst(node.value);
3654
- emit(OP_LDC, idx);
3655
- return true;
3656
- }
3657
- case "Identifier": {
3658
- if (node.name === "undefined") {
3659
- const localSlot = resolveLocal("undefined");
3660
- if (localSlot !== void 0) {
3661
- emit(OP_LDV, localSlot);
3662
- } else if (enclosingBindings && enclosingBindings.has("undefined")) {
3663
- emit(OP_LDU, getOrCreateUpvalue("undefined", false));
3664
- } else {
3665
- const idx = addConst(void 0);
3666
- emit(OP_LDC, idx);
3667
- }
3668
- return true;
3669
- }
3670
- emitLoadVar(node.name);
3671
- return true;
3672
- }
3673
- case "BinaryExpression": {
3674
- if (node.operator === ">") {
3675
- if (!compileExpr(node.right, true)) return false;
3676
- if (!compileExpr(node.left, true)) return false;
3677
- emit(OP_LT);
3678
- return true;
3679
- }
3680
- if (node.operator === "<=") {
3681
- if (!compileExpr(node.right, true)) return false;
3682
- if (!compileExpr(node.left, true)) return false;
3683
- emit(OP_LT);
3684
- emit(OP_NOT);
3685
- return true;
3686
- }
3687
- if (node.operator === ">=") {
3688
- if (!compileExpr(node.left, true)) return false;
3689
- if (!compileExpr(node.right, true)) return false;
3690
- emit(OP_LT);
3691
- emit(OP_NOT);
3692
- return true;
3693
- }
3694
- if (!compileExpr(node.left, true)) return false;
3695
- if (!compileExpr(node.right, true)) return false;
3696
- switch (node.operator) {
3697
- case "+":
3698
- emit(OP_ADD);
3699
- break;
3700
- case "-":
3701
- emit(OP_SUB);
3702
- break;
3703
- case "*":
3704
- emit(OP_MUL);
3705
- break;
3706
- case "^":
3707
- emit(OP_XOR);
3708
- break;
3709
- case "&":
3710
- emit(OP_AND);
3711
- break;
3712
- case "|":
3713
- emit(OP_OR);
3714
- break;
3715
- case "==":
3716
- case "===":
3717
- emit(OP_SEQ);
3718
- break;
3719
- case "!=":
3720
- case "!==":
3721
- emit(OP_SEQ);
3722
- emit(OP_NOT);
3723
- break;
3724
- case "<":
3725
- emit(OP_LT);
3726
- break;
3727
- default:
3728
- return false;
3729
- }
3730
- return true;
3731
- }
3732
- case "UnaryExpression": {
3733
- if (node.operator === "void") {
3734
- if (_optionalChain([node, 'access', _285 => _285.argument, 'optionalAccess', _286 => _286.type]) !== "Literal" || node.argument.regex) return false;
3735
- const undefIdx2 = addConst(void 0);
3736
- emit(OP_LDC, undefIdx2);
3737
- return true;
3738
- }
3739
- if (!compileExpr(node.argument, true)) return false;
3740
- switch (node.operator) {
3741
- case "!":
3742
- emit(OP_NOT);
3743
- break;
3744
- case "-": {
3745
- const neg1Idx = addConst(-1);
3746
- emit(OP_LDC, neg1Idx);
3747
- emit(OP_MUL);
3748
- break;
3749
- }
3750
- case "+": {
3751
- const zeroIdx = addConst(0);
3752
- emit(OP_LDC, zeroIdx);
3753
- emit(OP_ADD);
3754
- break;
3755
- }
3756
- case "~": {
3757
- const neg1Idx = addConst(-1);
3758
- emit(OP_LDC, neg1Idx);
3759
- emit(OP_XOR);
3760
- break;
3761
- }
3762
- default:
3763
- return false;
3764
- }
3765
- return true;
3766
- }
3767
- case "MemberExpression": {
3768
- if (node.optional) return false;
3769
- if (!compileExpr(node.object, true)) return false;
3770
- if (node.computed) {
3771
- if (!compileExpr(node.property, true)) return false;
3772
- } else {
3773
- if (_optionalChain([node, 'access', _287 => _287.property, 'optionalAccess', _288 => _288.type]) !== "Identifier") return false;
3774
- const idx = addConst(node.property.name);
3775
- emit(OP_LDC, idx);
3776
- }
3777
- emit(OP_GETP);
3778
- return true;
3779
- }
3780
- case "CallExpression": {
3781
- if (node.optional) return false;
3782
- if (node.callee.type === "MemberExpression") {
3783
- if (node.callee.optional) return false;
3784
- if (!compileExpr(node.callee.object, true)) return false;
3785
- if (node.callee.computed) {
3786
- if (!compileExpr(node.callee.property, true)) return false;
3787
- } else {
3788
- if (_optionalChain([node, 'access', _289 => _289.callee, 'access', _290 => _290.property, 'optionalAccess', _291 => _291.type]) !== "Identifier") return false;
3789
- const idx = addConst(node.callee.property.name);
3790
- emit(OP_LDC, idx);
3791
- }
3792
- for (const arg of node.arguments) {
3793
- if (!compileExpr(arg, true)) return false;
3794
- }
3795
- emit(OP_MCALL, node.arguments.length);
3796
- } else {
3797
- if (!compileExpr(node.callee, true)) return false;
3798
- for (const arg of node.arguments) {
3799
- if (!compileExpr(arg, true)) return false;
3800
- }
3801
- emit(OP_CALL, node.arguments.length);
3802
- }
3803
- return true;
3804
- }
3805
- case "AssignmentExpression": {
3806
- if (node.left.type === "Identifier") {
3807
- const name = node.left.name;
3808
- if (!canWriteVar(name)) return false;
3809
- if (node.operator === "=") {
3810
- if (!compileExpr(node.right, true)) return false;
3811
- } else {
3812
- let binOp = null;
3813
- switch (node.operator) {
3814
- case "+=":
3815
- binOp = OP_ADD;
3816
- break;
3817
- case "-=":
3818
- binOp = OP_SUB;
3819
- break;
3820
- case "*=":
3821
- binOp = OP_MUL;
3822
- break;
3823
- case "^=":
3824
- binOp = OP_XOR;
3825
- break;
3826
- case "&=":
3827
- binOp = OP_AND;
3828
- break;
3829
- case "|=":
3830
- binOp = OP_OR;
3831
- break;
3832
- default:
3833
- return false;
3834
- }
3835
- emitLoadVar(name);
3836
- if (!compileExpr(node.right, true)) return false;
3837
- emit(binOp);
3838
- }
3839
- if (!emitStoreVar(name)) return false;
3840
- if (inValuePos) {
3841
- emitLoadVar(name);
3842
- }
3843
- return true;
3844
- }
3845
- if (node.left.type === "MemberExpression") {
3846
- if (node.operator !== "=" || node.left.optional) return false;
3847
- if (!compileExpr(node.left.object, true)) return false;
3848
- if (node.left.computed) {
3849
- if (!compileExpr(node.left.property, true)) return false;
3850
- } else {
3851
- if (_optionalChain([node, 'access', _292 => _292.left, 'access', _293 => _293.property, 'optionalAccess', _294 => _294.type]) !== "Identifier") return false;
3852
- const idx = addConst(node.left.property.name);
3853
- emit(OP_LDC, idx);
3854
- }
3855
- if (!compileExpr(node.right, true)) return false;
3856
- emit(OP_SETP);
3857
- return true;
3858
- }
3859
- return false;
3860
- }
3861
- case "UpdateExpression": {
3862
- if (_optionalChain([node, 'access', _295 => _295.argument, 'optionalAccess', _296 => _296.type]) !== "Identifier") return false;
3863
- const name = node.argument.name;
3864
- if (!canWriteVar(name)) return false;
3865
- const oneIdx = addConst(1);
3866
- const stepOp = node.operator === "++" ? OP_ADD : OP_SUB;
3867
- if (node.prefix) {
3868
- emitLoadVar(name);
3869
- emit(OP_LDC, oneIdx);
3870
- emit(OP_MUL);
3871
- emit(OP_LDC, oneIdx);
3872
- emit(stepOp);
3873
- if (!emitStoreVar(name)) return false;
3874
- if (inValuePos) {
3875
- emitLoadVar(name);
3876
- }
3877
- } else {
3878
- if (inValuePos) {
3879
- emitLoadVar(name);
3880
- emit(OP_LDC, oneIdx);
3881
- emit(OP_MUL);
3882
- }
3883
- emitLoadVar(name);
3884
- emit(OP_LDC, oneIdx);
3885
- emit(OP_MUL);
3886
- emit(OP_LDC, oneIdx);
3887
- emit(stepOp);
3888
- if (!emitStoreVar(name)) return false;
3889
- }
3890
- return true;
3891
- }
3892
- case "ObjectExpression": {
3893
- for (const prop of node.properties) {
3894
- if (prop.type !== "Property" || prop.kind !== "init") return false;
3895
- if (prop.computed) {
3896
- if (!compileExpr(prop.key, true)) return false;
3897
- } else {
3898
- const keyName = _nullishCoalesce(_optionalChain([prop, 'access', _297 => _297.key, 'optionalAccess', _298 => _298.name]), () => ( _optionalChain([prop, 'access', _299 => _299.key, 'optionalAccess', _300 => _300.value])));
3899
- if (keyName === void 0) return false;
3900
- const idx = addConst(keyName);
3901
- emit(OP_LDC, idx);
3902
- }
3903
- if (!compileExpr(prop.value, true)) return false;
3904
- }
3905
- emit(OP_OBJ, node.properties.length);
3906
- return true;
3907
- }
3908
- case "ArrayExpression": {
3909
- for (const elem of node.elements) {
3910
- if (!elem || !compileExpr(elem, true)) return false;
3911
- }
3912
- emit(OP_ARR, node.elements.length);
3913
- return true;
3914
- }
3915
- case "AwaitExpression": {
3916
- if (!compileExpr(node.argument, true)) return false;
3917
- emit(OP_AWAIT);
3918
- return true;
3919
- }
3920
- default:
3921
- return false;
3922
- }
3923
- }
3924
- function compileStmt(stmt, isFnBody = false) {
3925
- if (!stmt) return false;
3926
- switch (stmt.type) {
3927
- case "ReturnStatement": {
3928
- if (stmt.argument) {
3929
- if (!compileExpr(stmt.argument, true)) return false;
3930
- } else {
3931
- const idx = addConst(void 0);
3932
- emit(OP_LDC, idx);
3933
- }
3934
- emit(OP_RET);
3935
- return true;
3936
- }
3937
- case "ExpressionStatement": {
3938
- if (!compileExpr(stmt.expression, false)) return false;
3939
- return true;
3940
- }
3941
- case "VariableDeclaration": {
3942
- for (const decl of stmt.declarations) {
3943
- if (_optionalChain([decl, 'access', _301 => _301.id, 'optionalAccess', _302 => _302.type]) !== "Identifier") return false;
3944
- const slot = resolveLocal(decl.id.name);
3945
- if (slot === void 0) return false;
3946
- if (decl.init) {
3947
- if (!compileExpr(decl.init, true)) return false;
3948
- emit(OP_STV, slot);
3949
- }
3950
- }
3951
- return true;
3952
- }
3953
- case "IfStatement": {
3954
- if (!compileExpr(stmt.test, true)) return false;
3955
- const jzPos = bytecode.length;
3956
- emit(OP_JZ, 0, 0);
3957
- stateSlots.add(jzPos + 2);
3958
- if (!compileStmt(stmt.consequent, false)) return false;
3959
- if (stmt.alternate) {
3960
- const jmpPos = bytecode.length;
3961
- emit(OP_JMP, 0, 0);
3962
- stateSlots.add(jmpPos + 2);
3963
- bytecode[jzPos + 1] = bytecode.length;
3964
- if (!compileStmt(stmt.alternate, false)) return false;
3965
- bytecode[jmpPos + 1] = bytecode.length;
3966
- } else {
3967
- bytecode[jzPos + 1] = bytecode.length;
3968
- }
3969
- return true;
3970
- }
3971
- case "BlockStatement": {
3972
- let pushedBlock = false;
3973
- if (!isFnBody) {
3974
- const blockScope = /* @__PURE__ */ new Map();
3975
- for (const s of stmt.body || []) {
3976
- if (s.type === "VariableDeclaration" && s.kind !== "var") {
3977
- for (const decl of s.declarations || []) {
3978
- if (_optionalChain([decl, 'access', _303 => _303.id, 'optionalAccess', _304 => _304.type]) !== "Identifier") return false;
3979
- if (!blockScope.has(decl.id.name)) {
3980
- blockScope.set(decl.id.name, localCount++);
3981
- }
3982
- }
3983
- }
3984
- }
3985
- if (blockScope.size > 0) {
3986
- scopeStack.push(blockScope);
3987
- pushedBlock = true;
3988
- }
3989
- }
3990
- for (const s of stmt.body) {
3991
- if (!compileStmt(s, false)) {
3992
- if (pushedBlock) scopeStack.pop();
3993
- return false;
3994
- }
3995
- }
3996
- if (pushedBlock) scopeStack.pop();
3997
- return true;
3998
- }
3999
- default:
4000
- return false;
4001
- }
4002
- }
4003
- if (fnNode.body.type === "BlockStatement") {
4004
- if (!compileStmt(fnNode.body, true)) return null;
4005
- } else {
4006
- if (!compileExpr(fnNode.body, true)) return null;
4007
- emit(OP_RET);
4008
- }
4009
- const undefIdx = addConst(void 0);
4010
- emit(OP_LDC, undefIdx);
4011
- emit(OP_RET);
4012
- return { bytecode, consts, localCount, stateSlots, upvalues };
4013
- }
4014
- function findInjectedVmHelperName(ast) {
4015
- if (!ast || !Array.isArray(ast.body)) return null;
4016
- for (const stmt of ast.body) {
4017
- if (stmt.type === "FunctionDeclaration" && typeof _optionalChain([stmt, 'access', _305 => _305.id, 'optionalAccess', _306 => _306.name]) === "string" && stmt.id.name.startsWith("_uVm")) {
4018
- return stmt.id.name;
4019
- }
4020
- if (stmt.type === "VariableDeclaration" && Array.isArray(stmt.declarations)) {
4021
- for (const d of stmt.declarations) {
4022
- if (_optionalChain([d, 'access', _307 => _307.id, 'optionalAccess', _308 => _308.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uVm")) {
4023
- return d.id.name;
4024
- }
4025
- }
4026
- }
4027
- }
4028
- return null;
4029
- }
4030
- function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 2654435769, windowKeySymbol, expectedDelta) {
4031
- const suffix = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, `micro-vm:${seed}`, seed).toString(36);
4032
- const vmHelperName = `_uVm${suffix}`;
4033
- const existingName = findInjectedVmHelperName(ast);
4034
- if (existingName) {
4035
- return {
4036
- virtualizedCount: 0,
4037
- vmHelperName: existingName
4038
- };
4039
- }
4040
- const opMap = generateOpcodeMap(seed, OPCODE_COUNT);
4041
- const vmKey = deriveVmKey(seed);
4042
- const scopeBindings = /* @__PURE__ */ new Map();
4043
- function addScopeBinding(scopeNode, name) {
4044
- if (!scopeNode || !name) return;
4045
- let set = scopeBindings.get(scopeNode);
4046
- if (!set) {
4047
- set = /* @__PURE__ */ new Set();
4048
- scopeBindings.set(scopeNode, set);
4049
- }
4050
- set.add(name);
4051
- }
4052
- function findNearestFunctionOrProgram(ancestors) {
4053
- for (let i = ancestors.length - 1; i >= 0; i--) {
4054
- if (FUNCTION_NODE_TYPES2.has(ancestors[i].type) || ancestors[i].type === "Program") {
4055
- return ancestors[i];
4056
- }
4057
- }
4058
- return ast;
4059
- }
4060
- function findNearestLexicalScope(ancestors) {
4061
- for (let i = ancestors.length - 1; i >= 0; i--) {
4062
- if (LEXICAL_SCOPE_TYPES2.has(ancestors[i].type)) {
4063
- return ancestors[i];
4064
- }
4065
- }
4066
- return ast;
4067
- }
4068
- const candidates = [];
4069
- walk6.ancestor(ast, {
4070
- ImportDeclaration(node) {
4071
- for (const spec of node.specifiers || []) {
4072
- if (_optionalChain([spec, 'access', _309 => _309.local, 'optionalAccess', _310 => _310.type]) === "Identifier") {
4073
- addScopeBinding(ast, spec.local.name);
4074
- }
4075
- }
4076
- },
4077
- VariableDeclaration(node, _state, ancestors) {
4078
- const targetScope = node.kind === "var" ? findNearestFunctionOrProgram(ancestors) : findNearestLexicalScope(ancestors);
4079
- const names = /* @__PURE__ */ new Set();
4080
- for (const decl of node.declarations || []) {
4081
- collectPatternNames(decl.id, names);
4082
- }
4083
- for (const name of names) {
4084
- addScopeBinding(targetScope, name);
4085
- }
4086
- },
4087
- FunctionDeclaration(node, _state, ancestors) {
4088
- const parentAncestors = ancestors.slice(0, -1);
4089
- if (_optionalChain([node, 'access', _311 => _311.id, 'optionalAccess', _312 => _312.type]) === "Identifier") {
4090
- addScopeBinding(findNearestLexicalScope(parentAncestors), node.id.name);
4091
- addScopeBinding(findNearestFunctionOrProgram(parentAncestors), node.id.name);
4092
- }
4093
- const paramNames = /* @__PURE__ */ new Set();
4094
- for (const p of node.params || []) {
4095
- collectPatternNames(p, paramNames);
4096
- }
4097
- for (const name of paramNames) {
4098
- addScopeBinding(node, name);
4099
- }
4100
- candidates.push({ fn: node, ancestors: ancestors.slice() });
4101
- },
4102
- FunctionExpression(node, _state, ancestors) {
4103
- if (_optionalChain([node, 'access', _313 => _313.id, 'optionalAccess', _314 => _314.type]) === "Identifier") {
4104
- addScopeBinding(node, node.id.name);
4105
- }
4106
- const paramNames = /* @__PURE__ */ new Set();
4107
- for (const p of node.params || []) {
4108
- collectPatternNames(p, paramNames);
4109
- }
4110
- for (const name of paramNames) {
4111
- addScopeBinding(node, name);
4112
- }
4113
- candidates.push({ fn: node, ancestors: ancestors.slice() });
4114
- },
4115
- ArrowFunctionExpression(node, _state, ancestors) {
4116
- const paramNames = /* @__PURE__ */ new Set();
4117
- for (const p of node.params || []) {
4118
- collectPatternNames(p, paramNames);
4119
- }
4120
- for (const name of paramNames) {
4121
- addScopeBinding(node, name);
4122
- }
4123
- candidates.push({ fn: node, ancestors: ancestors.slice() });
4124
- },
4125
- ClassDeclaration(node, _state, ancestors) {
4126
- if (_optionalChain([node, 'access', _315 => _315.id, 'optionalAccess', _316 => _316.type]) === "Identifier") {
4127
- addScopeBinding(findNearestLexicalScope(ancestors.slice(0, -1)), node.id.name);
4128
- addScopeBinding(node, node.id.name);
4129
- }
4130
- },
4131
- ClassExpression(node) {
4132
- if (_optionalChain([node, 'access', _317 => _317.id, 'optionalAccess', _318 => _318.type]) === "Identifier") {
4133
- addScopeBinding(node, node.id.name);
4134
- }
4135
- },
4136
- CatchClause(node) {
4137
- if (node.param) {
4138
- const names = /* @__PURE__ */ new Set();
4139
- collectPatternNames(node.param, names);
4140
- for (const name of names) {
4141
- addScopeBinding(node, name);
4142
- }
4143
- }
4144
- }
4145
- });
4146
- let virtualizedCount = 0;
4147
- for (const { fn, ancestors } of candidates) {
4148
- if (virtualizedCount >= 5) break;
4149
- if (coldFunctionNodes && !coldFunctionNodes.has(fn)) {
4150
- continue;
4151
- }
4152
- if (serializedFunctionNodes && serializedFunctionNodes.has(fn)) {
4153
- continue;
4154
- }
4155
- if (fn.generator) {
4156
- continue;
4157
- }
4158
- const parentNode = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
4159
- if (_optionalChain([parentNode, 'optionalAccess', _319 => _319.type]) === "MethodDefinition" && parentNode.kind === "constructor") {
4160
- continue;
4161
- }
4162
- if (ancestors.some((a) => a.type === "WithStatement")) {
4163
- continue;
4164
- }
4165
- if (hasForbiddenConstructs(fn)) {
4166
- continue;
4167
- }
4168
- const nodeCount = countAstNodes(fn);
4169
- if (nodeCount < 15 || nodeCount > 80) {
4170
- continue;
4171
- }
4172
- const enclosingBindings = /* @__PURE__ */ new Set();
4173
- for (let i = 0; i < ancestors.length - 1; i++) {
4174
- const bound = scopeBindings.get(ancestors[i]);
4175
- if (bound) {
4176
- for (const name of bound) {
4177
- enclosingBindings.add(name);
4178
- }
4179
- }
4180
- }
4181
- if (fn.type === "FunctionExpression" && _optionalChain([fn, 'access', _320 => _320.id, 'optionalAccess', _321 => _321.type]) === "Identifier") {
4182
- enclosingBindings.add(fn.id.name);
4183
- }
4184
- const compiled = compileFunctionToBytecode(fn, opMap, enclosingBindings);
4185
- if (!compiled) {
4186
- continue;
4187
- }
4188
- const fnSalt = _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, `vm-fn:${virtualizedCount}`, seed) >>> 0;
4189
- const encBytecode = encryptBytecodeStream(
4190
- compiled.bytecode,
4191
- fnSalt,
4192
- vmKey,
4193
- compiled.stateSlots
4194
- );
4195
- const paramArgs = fn.params.map((p) => ({
4196
- type: "Identifier",
4197
- name: p.name
4198
- }));
4199
- const constElements = compiled.consts.map((c) => {
4200
- if (c === void 0) {
4201
- return {
4202
- type: "UnaryExpression",
4203
- operator: "void",
4204
- prefix: true,
4205
- argument: { type: "Literal", value: 0, raw: "0" }
4206
- };
4207
- }
4208
- return {
4209
- type: "Literal",
4210
- value: c,
4211
- raw: JSON.stringify(c)
4212
- };
4213
- });
4214
- const callArgs = [
4215
- {
4216
- type: "ArrayExpression",
4217
- elements: encBytecode.map((b) => ({
4218
- type: "Literal",
4219
- value: b >>> 0,
4220
- raw: String(b >>> 0)
4221
- }))
4222
- },
4223
- {
4224
- type: "ArrayExpression",
4225
- elements: constElements
4226
- },
4227
- {
4228
- type: "ArrayExpression",
4229
- elements: paramArgs
4230
- },
4231
- {
4232
- type: "ThisExpression"
4233
- },
4234
- {
4235
- type: "Literal",
4236
- value: fnSalt,
4237
- raw: String(fnSalt)
4238
- }
4239
- ];
4240
- if (compiled.upvalues && compiled.upvalues.length > 0) {
4241
- const usedParamNames = new Set(enclosingBindings);
4242
- const upvalueElements = compiled.upvalues.map((uv, uIdx) => {
4243
- const getterFn = {
4244
- type: "ArrowFunctionExpression",
4245
- id: null,
4246
- params: [],
4247
- body: { type: "Identifier", name: uv.name },
4248
- generator: false,
4249
- async: false,
4250
- expression: true
4251
- };
4252
- if (!uv.isWritten) {
4253
- return {
4254
- type: "ArrayExpression",
4255
- elements: [getterFn]
4256
- };
4257
- }
4258
- let paramName = `_uv${uIdx}`;
4259
- let suffixIdx = 0;
4260
- while (usedParamNames.has(paramName) || paramName === uv.name) {
4261
- paramName = `_uv${uIdx}_${suffixIdx++}`;
4262
- }
4263
- usedParamNames.add(paramName);
4264
- const setterFn = {
4265
- type: "ArrowFunctionExpression",
4266
- id: null,
4267
- params: [{ type: "Identifier", name: paramName }],
4268
- body: {
4269
- type: "AssignmentExpression",
4270
- operator: "=",
4271
- left: { type: "Identifier", name: uv.name },
4272
- right: { type: "Identifier", name: paramName }
4273
- },
4274
- generator: false,
4275
- async: false,
4276
- expression: true
4277
- };
4278
- return {
4279
- type: "ArrayExpression",
4280
- elements: [getterFn, setterFn]
4281
- };
4282
- });
4283
- callArgs.push({
4284
- type: "ArrayExpression",
4285
- elements: upvalueElements
4286
- });
4287
- }
4288
- const callExpr = {
4289
- type: "CallExpression",
4290
- callee: {
4291
- type: "Identifier",
4292
- name: vmHelperName
4293
- },
4294
- arguments: callArgs,
4295
- optional: false
4296
- };
4297
- if (fn.body.type === "BlockStatement") {
4298
- fn.body.body = [
4299
- {
4300
- type: "ReturnStatement",
4301
- argument: callExpr
4302
- }
4303
- ];
4304
- } else {
4305
- fn.body = callExpr;
4306
- }
4307
- virtualizedCount++;
4308
- }
4309
- if (virtualizedCount > 0) {
4310
- const interpreterSource = createInterpreterSource(
4311
- vmHelperName,
4312
- opMap,
4313
- seed,
4314
- windowKeySymbol,
4315
- expectedDelta
4316
- );
4317
- const parsedHelper = acorn5.parse(interpreterSource, {
4318
- ecmaVersion: "latest",
4319
- sourceType: "script"
4320
- });
4321
- let insertIdx = 0;
4322
- while (insertIdx < ast.body.length) {
4323
- const stmt = ast.body[insertIdx];
4324
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _322 => _322.expression, 'optionalAccess', _323 => _323.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
4325
- if (isDirective || stmt.type === "ImportDeclaration") {
4326
- insertIdx++;
4327
- } else {
4328
- break;
4329
- }
4330
- }
4331
- ast.body.splice(insertIdx, 0, ...parsedHelper.body);
4332
- }
4333
- return {
4334
- virtualizedCount,
4335
- vmHelperName
4336
- };
4337
- }
4338
-
4339
- // src/ast/index.ts
4340
- function isAstAlreadyProtected(ast) {
4341
- if (!ast || !Array.isArray(ast.body)) return false;
4342
- return ast.body.some((stmt) => {
4343
- if (stmt.type === "VariableDeclaration" && Array.isArray(stmt.declarations)) {
4344
- for (const d of stmt.declarations) {
4345
- const name = _optionalChain([d, 'access', _324 => _324.id, 'optionalAccess', _325 => _325.type]) === "Identifier" ? d.id.name : void 0;
4346
- if (typeof name === "string") {
4347
- if (name === "_d" || name.startsWith("_uC") || name.startsWith("_uD") || name.startsWith("_uS") || name.startsWith("_uVm") || name.startsWith("_wKdf") || name.startsWith("_m") || name.startsWith("_w") || name.startsWith("_k") || name.startsWith("_a") && _optionalChain([d, 'access', _326 => _326.init, 'optionalAccess', _327 => _327.type]) === "CallExpression" && _optionalChain([d, 'access', _328 => _328.init, 'access', _329 => _329.callee, 'optionalAccess', _330 => _330.type]) === "FunctionExpression" && _optionalChain([d, 'access', _331 => _331.init, 'access', _332 => _332.callee, 'optionalAccess', _333 => _333.id, 'optionalAccess', _334 => _334.name]) === "f") {
4348
- return true;
4349
- }
4350
- }
4351
- }
4352
- }
4353
- if (stmt.type === "ExpressionStatement" && _optionalChain([stmt, 'access', _335 => _335.expression, 'optionalAccess', _336 => _336.type]) === "CallExpression") {
4354
- const callee = stmt.expression.callee;
4355
- if (_optionalChain([callee, 'optionalAccess', _337 => _337.type]) === "FunctionExpression") {
4356
- const name = _optionalChain([callee, 'access', _338 => _338.id, 'optionalAccess', _339 => _339.name]);
4357
- if (typeof name === "string" && (name.startsWith("_u$") || name.startsWith("_$") || name.startsWith("_s") || name.startsWith("$b"))) {
4358
- return true;
4359
- }
4360
- }
4361
- }
4362
- return false;
4363
- });
4364
- }
4365
- function transformJavaScript(code, options = {}) {
4366
- const internalOptions = options;
4367
- const seed = _nullishCoalesce(internalOptions.seed, () => ( 2654435769));
4368
- const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([options, 'access', _340 => _340.config, 'optionalAccess', _341 => _341.vault, 'optionalAccess', _342 => _342.minStringLength]))), () => ( 4));
4369
- const isAggressive = _nullishCoalesce(options.aggressive, () => ( false));
4370
- if (!code || !code.trim()) {
4371
- const emptyResult = {
4372
- code,
4373
- encryptedStringsCount: 0,
4374
- mangledSymbolsCount: 0,
4375
- hotPathReport: {
4376
- totalFunctions: 0,
4377
- hotFunctionsSkipped: [],
4378
- coldFunctionsProtected: []
4379
- },
4380
- integrityToken: _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, "", seed),
4381
- virtualizedFunctionsCount: 0,
4382
- shaderBuffersCount: 0
4383
- };
4384
- return emptyResult;
4385
- }
4386
- const ast = parseJavaScriptAst(code);
4387
- if (!ast) {
4388
- if (options.strict) {
4389
- const targetLabel = options.filename ? ` "${options.filename}"` : "";
4390
- throw new (0, _chunkR6EBIR3Tcjs.UnpeekError)(
4391
- "ERR_PARSE_FAILED",
4392
- `Failed to parse JavaScript${targetLabel}.`
4393
- );
4394
- }
4395
- const unparsedResult = {
4396
- code,
4397
- encryptedStringsCount: 0,
4398
- mangledSymbolsCount: 0,
4399
- hotPathReport: {
4400
- totalFunctions: 0,
4401
- hotFunctionsSkipped: [],
4402
- coldFunctionsProtected: []
4403
- },
4404
- integrityToken: _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, code, seed),
4405
- virtualizedFunctionsCount: 0,
4406
- shaderBuffersCount: 0
4407
- };
4408
- return unparsedResult;
4409
- }
4410
- if (isAstAlreadyProtected(ast)) {
4411
- const protectedResult = {
4412
- code,
4413
- encryptedStringsCount: 0,
4414
- mangledSymbolsCount: 0,
4415
- hotPathReport: {
4416
- totalFunctions: 0,
4417
- hotFunctionsSkipped: [],
4418
- coldFunctionsProtected: []
4419
- },
4420
- integrityToken: _chunk6N6S6WTQcjs.computeFnv1aHash.call(void 0, code, seed),
4421
- virtualizedFunctionsCount: 0,
4422
- shaderBuffersCount: 0
4423
- };
4424
- return protectedResult;
4425
- }
4426
- const {
4427
- report: hotPathReport,
4428
- coldFunctionNodes,
4429
- hotFunctionNodes,
4430
- hotExemptNodes,
4431
- serializedFunctionNodes
4432
- } = analyzeAstHotPaths(ast, options.config);
4433
- const shieldCoupled = _nullishCoalesce(internalOptions.shieldCoupled, () => ( Boolean(internalOptions.injectRuntimeShield)));
4434
- const deterrentMode = _nullishCoalesce(_nullishCoalesce(internalOptions.deterrentMode, () => ( _optionalChain([internalOptions, 'access', _343 => _343.config, 'optionalAccess', _344 => _344.shield, 'optionalAccess', _345 => _345.deterrentMode]))), () => ( "passive"));
4435
- const detectHeadless = _nullishCoalesce(_nullishCoalesce(internalOptions.detectHeadless, () => ( _optionalChain([internalOptions, 'access', _346 => _346.config, 'optionalAccess', _347 => _347.shield, 'optionalAccess', _348 => _348.detectHeadless]))), () => ( false));
4436
- const sym = shieldCoupled ? _nullishCoalesce(internalOptions.windowKeySymbol, () => ( _chunk6N6S6WTQcjs.deriveWindowKeySymbol.call(void 0, seed))) : void 0;
4437
- let shieldDelta = shieldCoupled ? internalOptions.expectedDelta : void 0;
4438
- if (shieldCoupled && shieldDelta === void 0) {
4439
- const shieldInfo = _chunk6N6S6WTQcjs.generateRuntimeShield.call(void 0, {
4440
- seed,
4441
- windowKeySymbol: sym,
4442
- deterrentMode,
4443
- detectHeadless
4444
- });
4445
- shieldDelta = _nullishCoalesce(shieldInfo.expectedDelta, () => ( 0));
4446
- }
4447
- let virtualizedFunctionsCount = 0;
4448
- if (isAggressive) {
4449
- const vmRes = applyMicroVm(
4450
- ast,
4451
- coldFunctionNodes,
4452
- serializedFunctionNodes,
4453
- seed,
4454
- sym,
4455
- shieldDelta
4456
- );
4457
- virtualizedFunctionsCount = vmRes.virtualizedCount;
4458
- }
4459
- applyColdFlowGuard(ast, coldFunctionNodes, seed, hotExemptNodes);
4460
- const mangledSymbolsCount = applyPolymorphicMangler(
4461
- ast,
4462
- seed,
4463
- serializedFunctionNodes,
4464
- options.config
4465
- );
4466
- let encryptedStringsCount = 0;
4467
- let integrityToken = 0;
4468
- let shaderBuffersCount = 0;
4469
- if (isAggressive) {
4470
- const saltedRes = applySaltedStringVault(
4471
- ast,
4472
- seed,
4473
- minStringLength,
4474
- hotExemptNodes,
4475
- options.config,
4476
- sym,
4477
- shieldDelta,
4478
- deterrentMode,
4479
- shieldCoupled,
4480
- detectHeadless
4481
- );
4482
- encryptedStringsCount = saltedRes.encryptedStringsCount;
4483
- integrityToken = saltedRes.integrityToken;
4484
- } else {
4485
- const vaultRes = applyStringVault(
4486
- ast,
4487
- seed,
4488
- minStringLength,
4489
- hotExemptNodes,
4490
- sym,
4491
- shieldDelta,
4492
- deterrentMode,
4493
- options.config,
4494
- shieldCoupled,
4495
- detectHeadless
4496
- );
4497
- encryptedStringsCount = vaultRes.encryptedStringsCount;
4498
- integrityToken = vaultRes.integrityToken;
4499
- shaderBuffersCount = _nullishCoalesce(vaultRes.shaderBuffersCount, () => ( 0));
4500
- }
4501
- const outputCode = _chunk6N6S6WTQcjs.generateCompactJs.call(void 0, ast);
4502
- let finalCode = outputCode;
4503
- if (internalOptions.injectRuntimeShield && !internalOptions.skipShieldPreamble) {
4504
- const shield = _chunk6N6S6WTQcjs.generateRuntimeShield.call(void 0, {
4505
- seed,
4506
- windowKeySymbol: sym,
4507
- expectedDelta: shieldDelta,
4508
- deterrentMode,
4509
- detectHeadless,
4510
- expectedIntegrityHash: integrityToken
4511
- });
4512
- if (shield.preambleCode) {
4513
- finalCode = `${shield.preambleCode}
4514
- ${finalCode}`;
4515
- }
4516
- }
4517
- const finalResult = {
4518
- code: finalCode,
4519
- encryptedStringsCount,
4520
- mangledSymbolsCount,
4521
- hotPathReport,
4522
- integrityToken,
4523
- virtualizedFunctionsCount,
4524
- shaderBuffersCount
4525
- };
4526
- return finalResult;
4527
- }
4528
-
4529
-
4530
-
4531
-
4532
- exports.detectHotPaths = detectHotPaths; exports.transformJavaScript = transformJavaScript;