unpeek 4.0.1 → 4.1.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 (62) hide show
  1. package/README.md +17 -9
  2. package/README.tr.md +17 -9
  3. package/dist/adapters/esbuild.cjs +5 -5
  4. package/dist/adapters/esbuild.d.cts +1 -1
  5. package/dist/adapters/esbuild.d.ts +1 -1
  6. package/dist/adapters/esbuild.js +3 -3
  7. package/dist/adapters/next/adapter.cjs +6 -6
  8. package/dist/adapters/next/adapter.d.cts +1 -1
  9. package/dist/adapters/next/adapter.d.ts +1 -1
  10. package/dist/adapters/next/adapter.js +5 -5
  11. package/dist/adapters/next/index.cjs +6 -6
  12. package/dist/adapters/next/index.js +5 -5
  13. package/dist/adapters/rollup.cjs +5 -5
  14. package/dist/adapters/rollup.d.cts +1 -1
  15. package/dist/adapters/rollup.d.ts +1 -1
  16. package/dist/adapters/rollup.js +3 -3
  17. package/dist/adapters/rspack.cjs +5 -5
  18. package/dist/adapters/rspack.d.cts +1 -1
  19. package/dist/adapters/rspack.d.ts +1 -1
  20. package/dist/adapters/rspack.js +3 -3
  21. package/dist/adapters/vite.cjs +5 -5
  22. package/dist/adapters/vite.d.cts +1 -1
  23. package/dist/adapters/vite.d.ts +1 -1
  24. package/dist/adapters/vite.js +3 -3
  25. package/dist/adapters/webpack.cjs +5 -5
  26. package/dist/adapters/webpack.d.cts +1 -1
  27. package/dist/adapters/webpack.d.ts +1 -1
  28. package/dist/adapters/webpack.js +3 -3
  29. package/dist/browser.cjs +2 -2
  30. package/dist/browser.d.cts +4 -4
  31. package/dist/browser.d.ts +4 -4
  32. package/dist/browser.js +1 -1
  33. package/dist/{chunk-TYL32LUK.js → chunk-32GLSJAW.js} +91 -569
  34. package/dist/{chunk-W77DAC3H.js → chunk-6EWFL4LQ.js} +16 -0
  35. package/dist/{chunk-LGTXAAZH.js → chunk-6KLUNEKE.js} +1939 -290
  36. package/dist/{chunk-3GDHYBVH.cjs → chunk-AD6UFBPA.cjs} +96 -574
  37. package/dist/{chunk-X6EETCO6.cjs → chunk-BQ2O6HM5.cjs} +16 -0
  38. package/dist/{chunk-NNAAPDUS.cjs → chunk-FLZ4FSP5.cjs} +8 -8
  39. package/dist/{chunk-4SOS3LRV.js → chunk-HV47WJIR.js} +6 -6
  40. package/dist/{chunk-OTA75YI6.cjs → chunk-Q4DFRMAV.cjs} +53 -36
  41. package/dist/{chunk-XYN5NYSD.js → chunk-STTUFUDC.js} +21 -15
  42. package/dist/{chunk-4G2HCME5.js → chunk-TOUYQ4N5.js} +30 -13
  43. package/dist/{chunk-M46SFJE7.cjs → chunk-VLL4THTG.cjs} +2137 -488
  44. package/dist/{chunk-7ZEVJ4OR.cjs → chunk-WYW5UOBE.cjs} +40 -34
  45. package/dist/cli/index.js +1399 -280
  46. package/dist/{config-Y6JwVGwX.d.cts → config-BFAZrfjQ.d.cts} +2 -0
  47. package/dist/{config-Y6JwVGwX.d.ts → config-BFAZrfjQ.d.ts} +2 -0
  48. package/dist/config.cjs +2 -2
  49. package/dist/config.d.cts +1 -1
  50. package/dist/config.d.ts +1 -1
  51. package/dist/config.js +1 -1
  52. package/dist/{index-COVHErnx.d.cts → index-Bo4S_VVM.d.cts} +1 -1
  53. package/dist/{index-0O1WSfVP.d.ts → index-CKdYVt_L.d.ts} +1 -1
  54. package/dist/index.cjs +21 -21
  55. package/dist/index.d.cts +6 -6
  56. package/dist/index.d.ts +6 -6
  57. package/dist/index.js +8 -8
  58. package/dist/plugins/unplugin.cjs +4 -4
  59. package/dist/plugins/unplugin.js +3 -3
  60. package/dist/{types-CMtZnV8C.d.ts → types-BZqvBhBI.d.ts} +4 -2
  61. package/dist/{types-D93PuOOl.d.cts → types-E4ugA4Oz.d.cts} +4 -2
  62. package/package.json +1 -1
@@ -1,4 +1,4 @@
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; }
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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
2
 
3
3
  var _chunkL6BOM5VScjs = require('./chunk-L6BOM5VS.cjs');
4
4
 
@@ -57,9 +57,858 @@ function invertRivestPoly32(y, a0, a1Odd, a2Even, a3Even) {
57
57
  return x >>> 0;
58
58
  }
59
59
 
60
+ // src/core/vlq.ts
61
+ var _crypto = require('crypto'); var _crypto2 = _interopRequireDefault(_crypto);
62
+ var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
63
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
64
+ var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
65
+ var BASE64_MAP = /* @__PURE__ */ new Map();
66
+ for (let i = 0; i < BASE64_CHARS.length; i++) {
67
+ BASE64_MAP.set(BASE64_CHARS[i], i);
68
+ }
69
+ var VLQ_BASE_SHIFT = 5;
70
+ var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
71
+ var VLQ_BASE_MASK = VLQ_BASE - 1;
72
+ var VLQ_CONTINUATION_BIT = VLQ_BASE;
73
+ function encodeVlq(value) {
74
+ let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
75
+ let encoded = "";
76
+ do {
77
+ let digit = vlq & VLQ_BASE_MASK;
78
+ vlq >>>= VLQ_BASE_SHIFT;
79
+ if (vlq > 0) {
80
+ digit |= VLQ_CONTINUATION_BIT;
81
+ }
82
+ encoded += BASE64_CHARS[digit];
83
+ } while (vlq > 0);
84
+ return encoded;
85
+ }
86
+ function decodeVlq(segment, startIndex) {
87
+ let result = 0;
88
+ let shift = 0;
89
+ let index = startIndex;
90
+ while (index < segment.length) {
91
+ const digit = BASE64_MAP.get(segment[index]);
92
+ if (digit === void 0) {
93
+ return null;
94
+ }
95
+ index++;
96
+ const continuation = (digit & VLQ_CONTINUATION_BIT) !== 0;
97
+ result += (digit & VLQ_BASE_MASK) << shift;
98
+ shift += VLQ_BASE_SHIFT;
99
+ if (!continuation) {
100
+ const isNegative = (result & 1) === 1;
101
+ const shifted = result >> 1;
102
+ return {
103
+ value: isNegative ? -shifted : shifted,
104
+ nextIndex: index
105
+ };
106
+ }
107
+ if (shift > 30) {
108
+ return null;
109
+ }
110
+ }
111
+ return null;
112
+ }
113
+ function decodeMappingsString(mappingsStr) {
114
+ const mappings = [];
115
+ let malformedCount = 0;
116
+ if (!mappingsStr) {
117
+ return { mappings, malformedCount };
118
+ }
119
+ let sourceIndex = 0;
120
+ let originalLine = 0;
121
+ let originalColumn = 0;
122
+ let nameIndex = 0;
123
+ const lines = mappingsStr.split(";");
124
+ for (let genLine = 0; genLine < lines.length; genLine++) {
125
+ const lineStr = lines[genLine];
126
+ if (!lineStr) continue;
127
+ let genCol = 0;
128
+ const segments = lineStr.split(",");
129
+ for (const seg of segments) {
130
+ if (!seg) continue;
131
+ const values = [];
132
+ let idx = 0;
133
+ let valid = true;
134
+ while (idx < seg.length) {
135
+ const decoded = decodeVlq(seg, idx);
136
+ if (!decoded) {
137
+ valid = false;
138
+ break;
139
+ }
140
+ values.push(decoded.value);
141
+ idx = decoded.nextIndex;
142
+ }
143
+ if (!valid || values.length !== 1 && values.length !== 4 && values.length !== 5) {
144
+ malformedCount++;
145
+ continue;
146
+ }
147
+ genCol += values[0];
148
+ if (values.length >= 4) {
149
+ sourceIndex += values[1];
150
+ originalLine += values[2];
151
+ originalColumn += values[3];
152
+ const mapping = {
153
+ generatedLine: genLine,
154
+ generatedColumn: genCol,
155
+ sourceIndex,
156
+ originalLine,
157
+ originalColumn
158
+ };
159
+ if (values.length === 5) {
160
+ nameIndex += values[4];
161
+ mapping.nameIndex = nameIndex;
162
+ }
163
+ mappings.push(mapping);
164
+ }
165
+ }
166
+ }
167
+ return { mappings, malformedCount };
168
+ }
169
+ function resolveSourceWithRoot(rawSource, sourceRoot) {
170
+ if (!sourceRoot || !rawSource || rawSource.startsWith(sourceRoot)) {
171
+ return rawSource;
172
+ }
173
+ return `${sourceRoot.replace(/\/$/, "")}/${rawSource.replace(/^\//, "")}`;
174
+ }
175
+ function flattenSourceMapSectionsWithStats(rawMap) {
176
+ if (!Array.isArray(rawMap.sections)) {
177
+ const normalized = {
178
+ version: _nullishCoalesce(rawMap.version, () => ( 3)),
179
+ sources: Array.isArray(rawMap.sources) ? [...rawMap.sources] : [],
180
+ names: Array.isArray(rawMap.names) ? [...rawMap.names] : [],
181
+ mappings: typeof rawMap.mappings === "string" ? rawMap.mappings : ""
182
+ };
183
+ if (rawMap.file !== void 0) normalized.file = rawMap.file;
184
+ if (rawMap.sourceRoot !== void 0) normalized.sourceRoot = rawMap.sourceRoot;
185
+ if (Array.isArray(rawMap.sourcesContent)) {
186
+ normalized.sourcesContent = [...rawMap.sourcesContent];
187
+ }
188
+ const debugId2 = _nullishCoalesce(rawMap.debugId, () => ( rawMap.debug_id));
189
+ if (debugId2) normalized.debugId = debugId2;
190
+ return { map: normalized, malformedCount: 0 };
191
+ }
192
+ const mergedSources = [];
193
+ const mergedSourcesContent = [];
194
+ let hasAnySourcesContent = false;
195
+ const sourceIndexMap = /* @__PURE__ */ new Map();
196
+ const mergedNames = [];
197
+ const nameIndexMap = /* @__PURE__ */ new Map();
198
+ const mergedMappings = [];
199
+ let totalMalformed = 0;
200
+ const internSource = (src, content) => {
201
+ const existing = sourceIndexMap.get(src);
202
+ if (existing !== void 0) {
203
+ if (mergedSourcesContent[existing] === null && content !== void 0 && content !== null) {
204
+ mergedSourcesContent[existing] = content;
205
+ hasAnySourcesContent = true;
206
+ }
207
+ return existing;
208
+ }
209
+ const nextIdx = mergedSources.length;
210
+ mergedSources.push(src);
211
+ if (content !== void 0 && content !== null) {
212
+ hasAnySourcesContent = true;
213
+ }
214
+ mergedSourcesContent.push(_nullishCoalesce(content, () => ( null)));
215
+ sourceIndexMap.set(src, nextIdx);
216
+ return nextIdx;
217
+ };
218
+ const internName = (name) => {
219
+ const existing = nameIndexMap.get(name);
220
+ if (existing !== void 0) return existing;
221
+ const nextIdx = mergedNames.length;
222
+ mergedNames.push(name);
223
+ nameIndexMap.set(name, nextIdx);
224
+ return nextIdx;
225
+ };
226
+ for (const section of rawMap.sections) {
227
+ if (!section || !section.map) continue;
228
+ const offLine = (_nullishCoalesce(_optionalChain([section, 'access', _ => _.offset, 'optionalAccess', _2 => _2.line]), () => ( 0))) | 0;
229
+ const offCol = (_nullishCoalesce(_optionalChain([section, 'access', _3 => _3.offset, 'optionalAccess', _4 => _4.column]), () => ( 0))) | 0;
230
+ const flatSecResult = flattenSourceMapSectionsWithStats(section.map);
231
+ const flatSec = flatSecResult.map;
232
+ totalMalformed += flatSecResult.malformedCount;
233
+ const decoded = decodeMappingsString(flatSec.mappings);
234
+ totalMalformed += decoded.malformedCount;
235
+ const secSources = _nullishCoalesce(flatSec.sources, () => ( []));
236
+ const secContents = _nullishCoalesce(flatSec.sourcesContent, () => ( []));
237
+ const secNames = _nullishCoalesce(flatSec.names, () => ( []));
238
+ const sourceRemap = /* @__PURE__ */ new Map();
239
+ for (let i = 0; i < secSources.length; i++) {
240
+ const fullSource = resolveSourceWithRoot(secSources[i], flatSec.sourceRoot);
241
+ sourceRemap.set(i, internSource(fullSource, secContents[i]));
242
+ }
243
+ const nameRemap = /* @__PURE__ */ new Map();
244
+ for (let i = 0; i < secNames.length; i++) {
245
+ nameRemap.set(i, internName(secNames[i]));
246
+ }
247
+ for (const m of decoded.mappings) {
248
+ const mappedSource = sourceRemap.get(m.sourceIndex);
249
+ if (mappedSource === void 0) continue;
250
+ const shifted = {
251
+ generatedLine: offLine + m.generatedLine,
252
+ generatedColumn: (m.generatedLine === 0 ? offCol : 0) + m.generatedColumn,
253
+ sourceIndex: mappedSource,
254
+ originalLine: m.originalLine,
255
+ originalColumn: m.originalColumn
256
+ };
257
+ if (m.nameIndex !== void 0) {
258
+ const mappedName = nameRemap.get(m.nameIndex);
259
+ if (mappedName !== void 0) {
260
+ shifted.nameIndex = mappedName;
261
+ }
262
+ }
263
+ mergedMappings.push(shifted);
264
+ }
265
+ }
266
+ mergedMappings.sort(
267
+ (a, b) => a.generatedLine !== b.generatedLine ? a.generatedLine - b.generatedLine : a.generatedColumn - b.generatedColumn
268
+ );
269
+ const flat = {
270
+ version: _nullishCoalesce(rawMap.version, () => ( 3)),
271
+ sources: mergedSources,
272
+ names: mergedNames,
273
+ mappings: encodeMappings(mergedMappings)
274
+ };
275
+ if (rawMap.file !== void 0) flat.file = rawMap.file;
276
+ if (rawMap.sourceRoot !== void 0) flat.sourceRoot = rawMap.sourceRoot;
277
+ if (hasAnySourcesContent) flat.sourcesContent = mergedSourcesContent;
278
+ const debugId = _nullishCoalesce(rawMap.debugId, () => ( rawMap.debug_id));
279
+ if (debugId) flat.debugId = debugId;
280
+ return { map: flat, malformedCount: totalMalformed };
281
+ }
282
+ function flattenSourceMapSections(rawMap) {
283
+ return flattenSourceMapSectionsWithStats(rawMap).map;
284
+ }
285
+ function encodeMappings(decoded) {
286
+ if (decoded.length === 0) return "";
287
+ const sorted = [...decoded].sort(
288
+ (a, b) => a.generatedLine !== b.generatedLine ? a.generatedLine - b.generatedLine : a.generatedColumn - b.generatedColumn
289
+ );
290
+ const maxLine = sorted[sorted.length - 1].generatedLine;
291
+ const lineBuckets = Array.from({ length: maxLine + 1 }, () => []);
292
+ let prevSource = 0;
293
+ let prevOrigLine = 0;
294
+ let prevOrigCol = 0;
295
+ let prevName = 0;
296
+ let prevGenLine = -1;
297
+ let prevGenCol = 0;
298
+ for (const m of sorted) {
299
+ if (m.generatedLine !== prevGenLine) {
300
+ prevGenLine = m.generatedLine;
301
+ prevGenCol = 0;
302
+ }
303
+ let seg = encodeVlq(m.generatedColumn - prevGenCol) + encodeVlq(m.sourceIndex - prevSource) + encodeVlq(m.originalLine - prevOrigLine) + encodeVlq(m.originalColumn - prevOrigCol);
304
+ prevGenCol = m.generatedColumn;
305
+ prevSource = m.sourceIndex;
306
+ prevOrigLine = m.originalLine;
307
+ prevOrigCol = m.originalColumn;
308
+ if (m.nameIndex !== void 0) {
309
+ seg += encodeVlq(m.nameIndex - prevName);
310
+ prevName = m.nameIndex;
311
+ }
312
+ lineBuckets[m.generatedLine].push(seg);
313
+ }
314
+ return lineBuckets.map((segs) => segs.join(",")).join(";");
315
+ }
316
+ function ensureSortedMappings(mappings) {
317
+ for (let i = 1; i < mappings.length; i++) {
318
+ const prev = mappings[i - 1];
319
+ const curr = mappings[i];
320
+ if (curr.generatedLine < prev.generatedLine || curr.generatedLine === prev.generatedLine && curr.generatedColumn < prev.generatedColumn) {
321
+ return [...mappings].sort(
322
+ (a, b) => a.generatedLine !== b.generatedLine ? a.generatedLine - b.generatedLine : a.generatedColumn - b.generatedColumn
323
+ );
324
+ }
325
+ }
326
+ return mappings;
327
+ }
328
+ function findMappingAt(mappings, line0, col0) {
329
+ let lo = 0;
330
+ let hi = mappings.length - 1;
331
+ let best;
332
+ while (lo <= hi) {
333
+ const mid = lo + hi >> 1;
334
+ const m = mappings[mid];
335
+ if (m.generatedLine < line0 || m.generatedLine === line0 && m.generatedColumn <= col0) {
336
+ if (m.generatedLine === line0) {
337
+ best = m;
338
+ }
339
+ lo = mid + 1;
340
+ } else {
341
+ hi = mid - 1;
342
+ }
343
+ }
344
+ return best;
345
+ }
346
+ function shiftSourceMapLines(map, lineOffset) {
347
+ if (lineOffset <= 0 || !map.mappings) {
348
+ return map;
349
+ }
350
+ return {
351
+ ...map,
352
+ mappings: `${";".repeat(lineOffset)}${map.mappings}`
353
+ };
354
+ }
355
+ function computeDeterministicDebugId(code, mappings = "") {
356
+ const hash = _crypto2.default.createHash("sha256").update(code, "utf8");
357
+ if (mappings) {
358
+ hash.update("\0", "utf8").update(mappings, "utf8");
359
+ }
360
+ const bytes = hash.digest();
361
+ bytes[6] = bytes[6] & 15 | 64;
362
+ bytes[8] = bytes[8] & 63 | 128;
363
+ const hex = bytes.subarray(0, 16).toString("hex");
364
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20, 32)}`;
365
+ }
366
+ function chainSourceMaps(mapB, mapA) {
367
+ const flatB = flattenSourceMapSections(mapB);
368
+ const flatA = flattenSourceMapSections(mapA);
369
+ const decodedB = ensureSortedMappings(decodeMappingsString(flatB.mappings).mappings);
370
+ const decodedA = ensureSortedMappings(decodeMappingsString(flatA.mappings).mappings);
371
+ const chained = [];
372
+ for (const mB of decodedB) {
373
+ const mA = findMappingAt(decodedA, mB.originalLine, mB.originalColumn);
374
+ if (mA) {
375
+ chained.push({
376
+ generatedLine: mB.generatedLine,
377
+ generatedColumn: mB.generatedColumn,
378
+ sourceIndex: mA.sourceIndex,
379
+ originalLine: mA.originalLine,
380
+ originalColumn: mA.originalColumn,
381
+ nameIndex: mA.nameIndex
382
+ });
383
+ }
384
+ }
385
+ const debugId = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(flatA.debugId, () => ( flatA.debug_id)), () => ( flatB.debugId)), () => ( flatB.debug_id));
386
+ const result = {
387
+ version: 3,
388
+ file: _nullishCoalesce(flatB.file, () => ( flatA.file)),
389
+ sourceRoot: flatA.sourceRoot,
390
+ sources: [...flatA.sources],
391
+ sourcesContent: flatA.sourcesContent ? [...flatA.sourcesContent] : void 0,
392
+ names: [...flatA.names],
393
+ mappings: encodeMappings(chained)
394
+ };
395
+ if (debugId) {
396
+ result.debugId = debugId;
397
+ }
398
+ return result;
399
+ }
400
+ function resolvePosition(map, line1Based, column1Based) {
401
+ const { map: flatMap, malformedCount: flattenMalformed } = flattenSourceMapSectionsWithStats(map);
402
+ const { mappings, malformedCount: decodeMalformed } = decodeMappingsString(flatMap.mappings);
403
+ const malformedCount = flattenMalformed + decodeMalformed;
404
+ const sortedMappings = ensureSortedMappings(mappings);
405
+ const match = findMappingAt(
406
+ sortedMappings,
407
+ Math.max(0, line1Based - 1),
408
+ Math.max(0, column1Based - 1)
409
+ );
410
+ if (!match) {
411
+ return { malformedCount };
412
+ }
413
+ const rawSource = flatMap.sources[match.sourceIndex];
414
+ const source = resolveSourceWithRoot(rawSource, flatMap.sourceRoot);
415
+ return {
416
+ source,
417
+ line: match.originalLine + 1,
418
+ column: match.originalColumn + 1,
419
+ name: match.nameIndex !== void 0 ? flatMap.names[match.nameIndex] : void 0,
420
+ malformedCount
421
+ };
422
+ }
423
+ function safeDecodeURIComponent(input) {
424
+ try {
425
+ return decodeURIComponent(input);
426
+ } catch (e2) {
427
+ return input.replace(/%[0-9A-Fa-f]{2}/g, (seq) => {
428
+ try {
429
+ return decodeURIComponent(seq);
430
+ } catch (e3) {
431
+ return seq;
432
+ }
433
+ });
434
+ }
435
+ }
436
+ function collectMapFiles(mapsDir) {
437
+ if (!_fs2.default.existsSync(mapsDir)) return [];
438
+ const results = [];
439
+ const walk9 = (dir) => {
440
+ let entries;
441
+ try {
442
+ entries = _fs2.default.readdirSync(dir, { withFileTypes: true });
443
+ } catch (e4) {
444
+ return;
445
+ }
446
+ for (const entry of entries) {
447
+ const fullPath = _path2.default.join(dir, entry.name);
448
+ if (entry.isDirectory()) {
449
+ walk9(fullPath);
450
+ } else if (entry.isFile() && entry.name.endsWith(".map")) {
451
+ results.push(fullPath);
452
+ }
453
+ }
454
+ };
455
+ walk9(mapsDir);
456
+ return results;
457
+ }
458
+ function normalizeFileRefCandidates(fileRef) {
459
+ let cleanRef = fileRef.trim();
460
+ try {
461
+ if (/^(?:https?|file):\/\//i.test(cleanRef)) {
462
+ cleanRef = new URL(cleanRef).pathname;
463
+ }
464
+ } catch (e5) {
465
+ }
466
+ cleanRef = cleanRef.split("?")[0].split("#")[0].replace(/\\/g, "/");
467
+ cleanRef = cleanRef.replace(/^\/+([A-Za-z]:\/)/, "$1").replace(/^\/+/, "");
468
+ const decodedRef = safeDecodeURIComponent(cleanRef).replace(/\\/g, "/").replace(/^\/+/, "");
469
+ const variants = /* @__PURE__ */ new Set();
470
+ for (const raw of [decodedRef, cleanRef]) {
471
+ if (!raw) continue;
472
+ variants.add(raw);
473
+ const withoutDrive = raw.replace(/^[A-Za-z]:\//, "");
474
+ variants.add(withoutDrive);
475
+ for (const v of [raw, withoutDrive]) {
476
+ const nextStripped = v.replace(
477
+ /^(?:.*\/)?(?:_next\/static\/chunks\/|_next\/static\/|_next\/|static\/chunks\/|static\/)/,
478
+ ""
479
+ );
480
+ if (nextStripped) variants.add(nextStripped);
481
+ const chunksIdx = v.indexOf("/chunks/");
482
+ if (chunksIdx !== -1) {
483
+ variants.add(v.slice(chunksIdx + "/chunks/".length));
484
+ }
485
+ }
486
+ }
487
+ return Array.from(variants).filter(Boolean);
488
+ }
489
+ function findMatchingMapFile(fileRef, mapsDir, allMaps) {
490
+ const candidates = normalizeFileRefCandidates(fileRef);
491
+ for (const cand of candidates) {
492
+ const exactCandidate = _path2.default.join(mapsDir, `${cand}.map`);
493
+ if (_fs2.default.existsSync(exactCandidate)) {
494
+ return exactCandidate;
495
+ }
496
+ }
497
+ for (const mapPath of allMaps) {
498
+ const relRaw = _path2.default.relative(mapsDir, mapPath).replace(/\\/g, "/");
499
+ const relDecoded = safeDecodeURIComponent(relRaw);
500
+ for (const rel of [relDecoded, relRaw]) {
501
+ const relNoMap = rel.slice(0, -4);
502
+ for (const cand of candidates) {
503
+ if (rel === `${cand}.map` || rel.endsWith(`/${cand}.map`) || cand.endsWith(`/${relNoMap}`) || cand === relNoMap) {
504
+ return mapPath;
505
+ }
506
+ }
507
+ }
508
+ }
509
+ const baseNames = new Set(candidates.map((c) => `${_path2.default.posix.basename(c)}.map`));
510
+ return allMaps.find((m) => {
511
+ const base2 = _path2.default.basename(m);
512
+ return baseNames.has(base2) || baseNames.has(safeDecodeURIComponent(base2));
513
+ });
514
+ }
515
+ var V8_PARENS_FRAME_REGEX = /^\s*at\s+(?:.+?\s+\()(.+):(\d+):(\d+)\)\s*$/;
516
+ var V8_BARE_FRAME_REGEX = /^\s*at\s+(.+?):(\d+):(\d+)\s*$/;
517
+ var FIREFOX_FRAME_REGEX = /^[^@]*@(.+?):(\d+):(\d+)\s*$/;
518
+ var STACK_FRAME_REGEX = /(?:at\s+(?:[^(]+\s+\()?|\@)([^\s()]+?):(\d+):(\d+)\)?/;
519
+ function parseStackFrame(rawLine) {
520
+ const match = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(rawLine.match(V8_PARENS_FRAME_REGEX), () => ( rawLine.match(V8_BARE_FRAME_REGEX))), () => ( rawLine.match(FIREFOX_FRAME_REGEX))), () => ( rawLine.match(STACK_FRAME_REGEX)));
521
+ if (!match) {
522
+ return null;
523
+ }
524
+ return {
525
+ fileRef: match[1],
526
+ lineNum: Number(match[2]),
527
+ colNum: Number(match[3])
528
+ };
529
+ }
530
+ async function symbolicateStackTrace(options) {
531
+ const cwd = _path2.default.resolve(_nullishCoalesce(options.cwd, () => ( process.cwd())));
532
+ const mapsDir = _path2.default.resolve(cwd, _nullishCoalesce(options.mapsDir, () => ( ".unpeek-maps")));
533
+ const allMaps = collectMapFiles(mapsDir);
534
+ const warnings = [];
535
+ const mapCache = /* @__PURE__ */ new Map();
536
+ if (allMaps.length === 0) {
537
+ warnings.push(`No .map files found in "${mapsDir}".`);
538
+ }
539
+ const lines = options.stackTrace.split(/\r?\n/);
540
+ const frames = [];
541
+ const outputLines = [];
542
+ for (const rawLine of lines) {
543
+ const parsedFrame = parseStackFrame(rawLine);
544
+ if (!parsedFrame) {
545
+ frames.push({ raw: rawLine, resolved: false });
546
+ outputLines.push(rawLine);
547
+ continue;
548
+ }
549
+ const { fileRef, lineNum, colNum } = parsedFrame;
550
+ const normalizedFrameFile = safeDecodeURIComponent(fileRef).replace(/\\/g, "/");
551
+ const mapPath = findMatchingMapFile(fileRef, mapsDir, allMaps);
552
+ if (!mapPath) {
553
+ frames.push({
554
+ raw: rawLine,
555
+ file: normalizedFrameFile,
556
+ line: lineNum,
557
+ column: colNum,
558
+ resolved: false
559
+ });
560
+ outputLines.push(rawLine);
561
+ continue;
562
+ }
563
+ let parsedMap = mapCache.get(mapPath);
564
+ if (parsedMap === void 0) {
565
+ try {
566
+ const rawJson = JSON.parse(_fs2.default.readFileSync(mapPath, "utf8"));
567
+ parsedMap = Array.isArray(_optionalChain([rawJson, 'optionalAccess', _5 => _5.sections])) ? flattenSourceMapSections(rawJson) : rawJson;
568
+ } catch (e6) {
569
+ parsedMap = null;
570
+ warnings.push(`Failed to parse source map "${mapPath}".`);
571
+ }
572
+ mapCache.set(mapPath, parsedMap);
573
+ }
574
+ if (!parsedMap || typeof parsedMap.mappings !== "string" || !Array.isArray(parsedMap.sources)) {
575
+ frames.push({
576
+ raw: rawLine,
577
+ file: normalizedFrameFile,
578
+ line: lineNum,
579
+ column: colNum,
580
+ resolved: false
581
+ });
582
+ outputLines.push(rawLine);
583
+ continue;
584
+ }
585
+ const pos = resolvePosition(parsedMap, lineNum, colNum);
586
+ if (pos.malformedCount > 0) {
587
+ warnings.push(`Skipped ${pos.malformedCount} malformed VLQ segment(s) in "${_path2.default.basename(mapPath)}".`);
588
+ }
589
+ if (!pos.source || pos.line === void 0 || pos.column === void 0) {
590
+ frames.push({
591
+ raw: rawLine,
592
+ file: normalizedFrameFile,
593
+ line: lineNum,
594
+ column: colNum,
595
+ resolved: false
596
+ });
597
+ outputLines.push(rawLine);
598
+ continue;
599
+ }
600
+ frames.push({
601
+ raw: rawLine,
602
+ file: normalizedFrameFile,
603
+ line: lineNum,
604
+ column: colNum,
605
+ originalSource: pos.source,
606
+ originalLine: pos.line,
607
+ originalColumn: pos.column,
608
+ originalName: pos.name,
609
+ resolved: true
610
+ });
611
+ const fnPrefix = pos.name ? `${pos.name} ` : "";
612
+ outputLines.push(` at ${fnPrefix}(${pos.source}:${pos.line}:${pos.column})`);
613
+ }
614
+ return {
615
+ stackTrace: outputLines.join("\n"),
616
+ frames,
617
+ warnings: Array.from(new Set(warnings))
618
+ };
619
+ }
620
+
60
621
  // src/ast/hot-path-detector.ts
61
622
  var _acorn = require('acorn'); var acorn = _interopRequireWildcard(_acorn); var acorn4 = _interopRequireWildcard(_acorn); var acorn3 = _interopRequireWildcard(_acorn); var acorn2 = _interopRequireWildcard(_acorn); var acorn5 = _interopRequireWildcard(_acorn); var acorn6 = _interopRequireWildcard(_acorn);
62
623
  var _acornwalk = require('acorn-walk'); var walk = _interopRequireWildcard(_acornwalk); var walk4 = _interopRequireWildcard(_acornwalk); var walk3 = _interopRequireWildcard(_acornwalk); var walk2 = _interopRequireWildcard(_acornwalk); var walk5 = _interopRequireWildcard(_acornwalk); var walk6 = _interopRequireWildcard(_acornwalk); var walk7 = _interopRequireWildcard(_acornwalk); var walk8 = _interopRequireWildcard(_acornwalk);
624
+
625
+ // src/ast/sourcemap-critical.ts
626
+ function contentMightMatchInclude(content, rawPatterns) {
627
+ for (const pat of rawPatterns) {
628
+ if (typeof pat === "string" && pat.length > 0) {
629
+ if (content.includes(pat)) return true;
630
+ try {
631
+ const stripped = pat.replace(/^\^|\$$/g, "");
632
+ if (stripped && new RegExp(stripped).test(content)) return true;
633
+ } catch (e7) {
634
+ }
635
+ } else if (pat instanceof RegExp) {
636
+ try {
637
+ const stripped = pat.source.replace(/^\^|\$$/g, "");
638
+ const flags = pat.flags.replace(/[gy]/g, "");
639
+ if (new RegExp(stripped, flags).test(content)) return true;
640
+ } catch (e8) {
641
+ return true;
642
+ }
643
+ }
644
+ }
645
+ return false;
646
+ }
647
+ function mightContainCriticalMatches(rawMap, options) {
648
+ if (!rawMap || typeof rawMap !== "object") return false;
649
+ if (Array.isArray(rawMap.sections)) {
650
+ return rawMap.sections.some(
651
+ (sec) => _optionalChain([sec, 'optionalAccess', _6 => _6.map]) && mightContainCriticalMatches(sec.map, options)
652
+ );
653
+ }
654
+ if (options.criticalIncludeMatchers.length > 0 && Array.isArray(rawMap.names) && rawMap.names.some(
655
+ (n) => typeof n === "string" && options.criticalIncludeMatchers.some((match) => match(n))
656
+ )) {
657
+ return true;
658
+ }
659
+ if (Array.isArray(rawMap.sourcesContent)) {
660
+ for (const content of rawMap.sourcesContent) {
661
+ if (typeof content !== "string" || content.length === 0) continue;
662
+ if (content.includes(options.criticalAnnotation)) return true;
663
+ if (options.rawIncludePatterns.length > 0 && contentMightMatchInclude(content, options.rawIncludePatterns)) {
664
+ return true;
665
+ }
666
+ }
667
+ }
668
+ return false;
669
+ }
670
+ function decodeMappingsByLine(mappingsStr, maxGenLine) {
671
+ const byLine = /* @__PURE__ */ new Map();
672
+ if (!mappingsStr || maxGenLine < 0) return byLine;
673
+ let sourceIndex = 0;
674
+ let originalLine = 0;
675
+ let originalColumn = 0;
676
+ let nameIndex = 0;
677
+ let genLine = 0;
678
+ let pos = 0;
679
+ const len = mappingsStr.length;
680
+ while (pos <= len && genLine <= maxGenLine) {
681
+ let semi = mappingsStr.indexOf(";", pos);
682
+ if (semi === -1) semi = len;
683
+ if (semi > pos) {
684
+ const lineStr = mappingsStr.slice(pos, semi);
685
+ let genCol = 0;
686
+ const lineSegs = [];
687
+ const segments = lineStr.split(",");
688
+ for (const seg of segments) {
689
+ if (!seg) continue;
690
+ const values = [];
691
+ let idx = 0;
692
+ let valid = true;
693
+ while (idx < seg.length) {
694
+ const decoded = decodeVlq(seg, idx);
695
+ if (!decoded) {
696
+ valid = false;
697
+ break;
698
+ }
699
+ values.push(decoded.value);
700
+ idx = decoded.nextIndex;
701
+ }
702
+ if (!valid || values.length !== 1 && values.length !== 4 && values.length !== 5) {
703
+ continue;
704
+ }
705
+ genCol += values[0];
706
+ if (values.length >= 4) {
707
+ sourceIndex += values[1];
708
+ originalLine += values[2];
709
+ originalColumn += values[3];
710
+ const mapping = {
711
+ generatedLine: genLine,
712
+ generatedColumn: genCol,
713
+ sourceIndex,
714
+ originalLine,
715
+ originalColumn
716
+ };
717
+ if (values.length === 5) {
718
+ nameIndex += values[4];
719
+ mapping.nameIndex = nameIndex;
720
+ }
721
+ lineSegs.push(mapping);
722
+ }
723
+ }
724
+ if (lineSegs.length > 0) {
725
+ for (let i = 1; i < lineSegs.length; i++) {
726
+ if (lineSegs[i].generatedColumn < lineSegs[i - 1].generatedColumn) {
727
+ lineSegs.sort((a, b) => a.generatedColumn - b.generatedColumn);
728
+ break;
729
+ }
730
+ }
731
+ byLine.set(genLine, lineSegs);
732
+ }
733
+ }
734
+ if (semi === len) break;
735
+ pos = semi + 1;
736
+ genLine++;
737
+ }
738
+ return byLine;
739
+ }
740
+ function findNearestSegmentOnLine(lineSegs, genCol, maxForwardCol) {
741
+ if (!lineSegs || lineSegs.length === 0) return void 0;
742
+ let lo = 0;
743
+ let hi = lineSegs.length - 1;
744
+ let best;
745
+ while (lo <= hi) {
746
+ const mid = lo + hi >> 1;
747
+ const m = lineSegs[mid];
748
+ if (m.generatedColumn <= genCol) {
749
+ best = m;
750
+ lo = mid + 1;
751
+ } else {
752
+ hi = mid - 1;
753
+ }
754
+ }
755
+ if (best) return best;
756
+ const first = lineSegs[0];
757
+ if (maxForwardCol === void 0 || first.generatedColumn <= maxForwardCol) {
758
+ return first;
759
+ }
760
+ return void 0;
761
+ }
762
+ function hasCriticalAnnotationNearLine(lines, origLine, annotation) {
763
+ if (origLine < 0 || origLine >= lines.length) return false;
764
+ if (lines[origLine].includes(annotation)) return true;
765
+ const minLine = Math.max(0, origLine - 5);
766
+ let inBlockComment = false;
767
+ for (let l = origLine - 1; l >= minLine; l--) {
768
+ const line = lines[l];
769
+ if (line.includes(annotation)) return true;
770
+ const trimmed = line.trim();
771
+ if (!inBlockComment && trimmed.endsWith("*/") && !trimmed.includes("/*")) {
772
+ inBlockComment = true;
773
+ continue;
774
+ }
775
+ if (inBlockComment) {
776
+ if (trimmed.includes("/*")) {
777
+ inBlockComment = false;
778
+ }
779
+ continue;
780
+ }
781
+ if (trimmed === "" || trimmed.startsWith("//") || trimmed.startsWith("/*") && trimmed.endsWith("*/")) {
782
+ continue;
783
+ }
784
+ break;
785
+ }
786
+ return false;
787
+ }
788
+ var IDENT_CHAR_RE = /[A-Za-z0-9_$]/;
789
+ var DECL_IDENT_RES = [
790
+ /\bfunction\s*\*?\s*([A-Za-z_$][A-Za-z0-9_$]*)/g,
791
+ /\b(?:const|let|var)\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=/g,
792
+ /([A-Za-z_$][A-Za-z0-9_$]*)\s*[:=]\s*(?:async\s+)?(?:function\b|\()/g
793
+ ];
794
+ function hasCriticalNameOnSourceLine(line, origCol, matchers) {
795
+ if (!line || matchers.length === 0) return false;
796
+ if (origCol >= 0 && origCol < line.length) {
797
+ let start = origCol;
798
+ while (start > 0 && IDENT_CHAR_RE.test(line[start - 1])) start--;
799
+ let end = origCol;
800
+ while (end < line.length && IDENT_CHAR_RE.test(line[end])) end++;
801
+ if (end > start) {
802
+ const token = line.slice(start, end);
803
+ if (matchers.some((m) => m(token))) return true;
804
+ }
805
+ }
806
+ for (const re of DECL_IDENT_RES) {
807
+ re.lastIndex = 0;
808
+ let m;
809
+ while ((m = re.exec(line)) !== null) {
810
+ if (m[1] && matchers.some((match) => match(m[1]))) {
811
+ return true;
812
+ }
813
+ }
814
+ }
815
+ return false;
816
+ }
817
+ function resolveSourceMapCriticalNodes(functions, originalSourceMap, options) {
818
+ const matched = /* @__PURE__ */ new Set();
819
+ if (!originalSourceMap || functions.length === 0) {
820
+ return matched;
821
+ }
822
+ if (!mightContainCriticalMatches(originalSourceMap, options)) {
823
+ return matched;
824
+ }
825
+ const flatMap = flattenSourceMapSections(originalSourceMap);
826
+ if (!flatMap.mappings) {
827
+ return matched;
828
+ }
829
+ let maxGenLine = -1;
830
+ for (const fn of functions) {
831
+ const nLine = _optionalChain([fn, 'access', _7 => _7.node, 'access', _8 => _8.loc, 'optionalAccess', _9 => _9.start, 'optionalAccess', _10 => _10.line]);
832
+ if (typeof nLine === "number") {
833
+ maxGenLine = Math.max(maxGenLine, nLine - 1);
834
+ }
835
+ const idLine = _optionalChain([fn, 'access', _11 => _11.idNode, 'optionalAccess', _12 => _12.loc, 'optionalAccess', _13 => _13.start, 'optionalAccess', _14 => _14.line]);
836
+ if (typeof idLine === "number") {
837
+ maxGenLine = Math.max(maxGenLine, idLine - 1);
838
+ }
839
+ }
840
+ if (maxGenLine < 0) {
841
+ return matched;
842
+ }
843
+ const lineMappings = decodeMappingsByLine(flatMap.mappings, maxGenLine);
844
+ if (lineMappings.size === 0) {
845
+ return matched;
846
+ }
847
+ const linesCache = /* @__PURE__ */ new Map();
848
+ const getSourceLines = (sourceIdx) => {
849
+ if (linesCache.has(sourceIdx)) return linesCache.get(sourceIdx);
850
+ const content = _optionalChain([flatMap, 'access', _15 => _15.sourcesContent, 'optionalAccess', _16 => _16[sourceIdx]]);
851
+ if (typeof content !== "string") return void 0;
852
+ const split = content.split(/\r?\n/);
853
+ linesCache.set(sourceIdx, split);
854
+ return split;
855
+ };
856
+ const segmentIsCritical = (seg) => {
857
+ if (seg.nameIndex !== void 0 && options.criticalIncludeMatchers.length > 0) {
858
+ const mappedName = flatMap.names[seg.nameIndex];
859
+ if (typeof mappedName === "string" && options.criticalIncludeMatchers.some((m) => m(mappedName))) {
860
+ return true;
861
+ }
862
+ }
863
+ const lines = getSourceLines(seg.sourceIndex);
864
+ if (!lines) return false;
865
+ if (hasCriticalAnnotationNearLine(
866
+ lines,
867
+ seg.originalLine,
868
+ options.criticalAnnotation
869
+ )) {
870
+ return true;
871
+ }
872
+ if (options.criticalIncludeMatchers.length > 0 && seg.originalLine >= 0 && seg.originalLine < lines.length && hasCriticalNameOnSourceLine(
873
+ lines[seg.originalLine],
874
+ seg.originalColumn,
875
+ options.criticalIncludeMatchers
876
+ )) {
877
+ return true;
878
+ }
879
+ return false;
880
+ };
881
+ for (const fn of functions) {
882
+ const candidates = [];
883
+ const idLoc = _optionalChain([fn, 'access', _17 => _17.idNode, 'optionalAccess', _18 => _18.loc, 'optionalAccess', _19 => _19.start]);
884
+ if (idLoc) {
885
+ const seg = findNearestSegmentOnLine(
886
+ lineMappings.get(idLoc.line - 1),
887
+ idLoc.column
888
+ );
889
+ if (seg) candidates.push(seg);
890
+ }
891
+ const nodeStart = _optionalChain([fn, 'access', _20 => _20.node, 'access', _21 => _21.loc, 'optionalAccess', _22 => _22.start]);
892
+ if (nodeStart) {
893
+ const nodeEnd = _optionalChain([fn, 'access', _23 => _23.node, 'access', _24 => _24.loc, 'optionalAccess', _25 => _25.end]);
894
+ const maxForwardCol = nodeEnd && nodeEnd.line === nodeStart.line ? nodeEnd.column : void 0;
895
+ const seg = findNearestSegmentOnLine(
896
+ lineMappings.get(nodeStart.line - 1),
897
+ nodeStart.column,
898
+ maxForwardCol
899
+ );
900
+ if (seg && !candidates.includes(seg)) {
901
+ candidates.push(seg);
902
+ }
903
+ }
904
+ if (candidates.some(segmentIsCritical)) {
905
+ matched.add(fn.node);
906
+ }
907
+ }
908
+ return matched;
909
+ }
910
+
911
+ // src/ast/hot-path-detector.ts
63
912
  var ARRAY_HOF_METHODS = /* @__PURE__ */ new Set([
64
913
  "map",
65
914
  "filter",
@@ -100,6 +949,16 @@ var DEFAULT_EVENT_HANDLER_REGEX = /^(?:on|handle)(?!Tick|Render|Update|Frame|Ani
100
949
  var CRITICAL_COLD_HANDLER_REGEX = /^(?:onSubmit|handleSubmit|submit[A-Z0-9_]*|validate[A-Z0-9_]*|login|signIn|register|checkout)$/i;
101
950
  var CRITICAL_COLD_CALLEE_REGEX = /^(?:onSubmit|handleSubmit|submit[A-Z0-9_]*|validate[A-Z0-9_]*|login|signIn|register|checkout|createServerReference|fetch)$/i;
102
951
  var DEFAULT_HOOK_REGEX = /^use[A-Z0-9]/;
952
+ var JSX_FACTORY_CALLS = /* @__PURE__ */ new Set([
953
+ "jsx",
954
+ "jsxs",
955
+ "_jsx",
956
+ "_jsxs",
957
+ "jsxDEV",
958
+ "_jsxDEV",
959
+ "createElement",
960
+ "cloneElement"
961
+ ]);
103
962
  var REACT_HOOK_OR_RENDER_CALLS = /* @__PURE__ */ new Set([
104
963
  "useState",
105
964
  "useEffect",
@@ -114,7 +973,10 @@ var REACT_HOOK_OR_RENDER_CALLS = /* @__PURE__ */ new Set([
114
973
  "jsxs",
115
974
  "_jsx",
116
975
  "_jsxs",
117
- "createElement"
976
+ "jsxDEV",
977
+ "_jsxDEV",
978
+ "createElement",
979
+ "cloneElement"
118
980
  ]);
119
981
  var FUNCTION_NODE_TYPES = /* @__PURE__ */ new Set([
120
982
  "FunctionDeclaration",
@@ -122,7 +984,7 @@ var FUNCTION_NODE_TYPES = /* @__PURE__ */ new Set([
122
984
  "ArrowFunctionExpression"
123
985
  ]);
124
986
  function parseJavaScriptAst(code, comments, opts) {
125
- const locations = _optionalChain([opts, 'optionalAccess', _ => _.locations]) !== false;
987
+ const locations = _optionalChain([opts, 'optionalAccess', _26 => _26.locations]) !== false;
126
988
  const collectedComments = _nullishCoalesce(comments, () => ( []));
127
989
  let ast = null;
128
990
  try {
@@ -133,7 +995,7 @@ function parseJavaScriptAst(code, comments, opts) {
133
995
  locations,
134
996
  onComment: collectedComments
135
997
  });
136
- } catch (e) {
998
+ } catch (e9) {
137
999
  collectedComments.length = 0;
138
1000
  try {
139
1001
  ast = acorn.parse(code, {
@@ -143,7 +1005,7 @@ function parseJavaScriptAst(code, comments, opts) {
143
1005
  locations,
144
1006
  onComment: collectedComments
145
1007
  });
146
- } catch (e2) {
1008
+ } catch (e10) {
147
1009
  return null;
148
1010
  }
149
1011
  }
@@ -156,21 +1018,31 @@ function parseJavaScriptAst(code, comments, opts) {
156
1018
  }
157
1019
  return ast;
158
1020
  }
159
- function isHocCall(callNode, hocWrappers) {
160
- if (!callNode || callNode.type !== "CallExpression") return false;
161
- const callee = callNode.callee;
1021
+ function unwrapCallee(callee) {
1022
+ let cur = callee;
1023
+ while (_optionalChain([cur, 'optionalAccess', _27 => _27.type]) === "SequenceExpression" && Array.isArray(cur.expressions) && cur.expressions.length > 0) {
1024
+ cur = cur.expressions[cur.expressions.length - 1];
1025
+ }
1026
+ return cur;
1027
+ }
1028
+ function isHocCall(callNode, hocWrappers, depth = 0) {
1029
+ if (!callNode || callNode.type !== "CallExpression" || depth > 4) return false;
1030
+ const callee = unwrapCallee(callNode.callee);
162
1031
  if (!callee) return false;
163
1032
  const wrappers = _nullishCoalesce(hocWrappers, () => ( DEFAULT_HOC_WRAPPERS));
164
1033
  if (callee.type === "Identifier") {
165
1034
  return wrappers.has(callee.name);
166
1035
  }
167
- if (callee.type === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _2 => _2.property, 'optionalAccess', _3 => _3.type]) === "Identifier") {
1036
+ if (callee.type === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _28 => _28.property, 'optionalAccess', _29 => _29.type]) === "Identifier") {
168
1037
  if (wrappers.has(callee.property.name)) return true;
169
- if (_optionalChain([callee, 'access', _4 => _4.object, 'optionalAccess', _5 => _5.type]) === "Identifier") {
1038
+ if (_optionalChain([callee, 'access', _30 => _30.object, 'optionalAccess', _31 => _31.type]) === "Identifier") {
170
1039
  const full2 = `${callee.object.name}.${callee.property.name}`;
171
1040
  if (wrappers.has(full2)) return true;
172
1041
  }
173
1042
  }
1043
+ if (callee.type === "CallExpression") {
1044
+ return isHocCall(callee, wrappers, depth + 1);
1045
+ }
174
1046
  return false;
175
1047
  }
176
1048
  function getFunctionLabel(node, ancestors, hocWrappers) {
@@ -179,21 +1051,21 @@ function getFunctionLabel(node, ancestors, hocWrappers) {
179
1051
  }
180
1052
  const parent = ancestors[ancestors.length - 2];
181
1053
  if (parent) {
182
- if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _6 => _6.id, 'optionalAccess', _7 => _7.type]) === "Identifier") {
1054
+ if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _32 => _32.id, 'optionalAccess', _33 => _33.type]) === "Identifier") {
183
1055
  return parent.id.name;
184
1056
  }
185
1057
  if (parent.type === "Property") {
186
- if (_optionalChain([parent, 'access', _8 => _8.key, 'optionalAccess', _9 => _9.type]) === "Identifier") {
1058
+ if (_optionalChain([parent, 'access', _34 => _34.key, 'optionalAccess', _35 => _35.type]) === "Identifier") {
187
1059
  return parent.key.name;
188
1060
  }
189
- if (_optionalChain([parent, 'access', _10 => _10.key, 'optionalAccess', _11 => _11.type]) === "Literal" && typeof parent.key.value === "string") {
1061
+ if (_optionalChain([parent, 'access', _36 => _36.key, 'optionalAccess', _37 => _37.type]) === "Literal" && typeof parent.key.value === "string") {
190
1062
  return parent.key.value;
191
1063
  }
192
1064
  }
193
- if (parent.type === "MethodDefinition" && _optionalChain([parent, 'access', _12 => _12.key, 'optionalAccess', _13 => _13.type]) === "Identifier") {
1065
+ if (parent.type === "MethodDefinition" && _optionalChain([parent, 'access', _38 => _38.key, 'optionalAccess', _39 => _39.type]) === "Identifier") {
194
1066
  return parent.key.name;
195
1067
  }
196
- if (parent.type === "AssignmentExpression" && _optionalChain([parent, 'access', _14 => _14.left, 'optionalAccess', _15 => _15.type]) === "Identifier") {
1068
+ if (parent.type === "AssignmentExpression" && _optionalChain([parent, 'access', _40 => _40.left, 'optionalAccess', _41 => _41.type]) === "Identifier") {
197
1069
  return parent.left.name;
198
1070
  }
199
1071
  if (parent.type === "CallExpression") {
@@ -209,10 +1081,10 @@ function getFunctionLabel(node, ancestors, hocWrappers) {
209
1081
  }
210
1082
  if (matchedHoc && idx >= 0) {
211
1083
  const outer = ancestors[idx];
212
- if (outer.type === "VariableDeclarator" && _optionalChain([outer, 'access', _16 => _16.id, 'optionalAccess', _17 => _17.type]) === "Identifier") {
1084
+ if (outer.type === "VariableDeclarator" && _optionalChain([outer, 'access', _42 => _42.id, 'optionalAccess', _43 => _43.type]) === "Identifier") {
213
1085
  return outer.id.name;
214
1086
  }
215
- if (outer.type === "AssignmentExpression" && _optionalChain([outer, 'access', _18 => _18.left, 'optionalAccess', _19 => _19.type]) === "Identifier") {
1087
+ if (outer.type === "AssignmentExpression" && _optionalChain([outer, 'access', _44 => _44.left, 'optionalAccess', _45 => _45.type]) === "Identifier") {
216
1088
  return outer.left.name;
217
1089
  }
218
1090
  }
@@ -220,8 +1092,73 @@ function getFunctionLabel(node, ancestors, hocWrappers) {
220
1092
  }
221
1093
  return `anonymous_${node.start}`;
222
1094
  }
223
- function isPascalCaseComponent(name) {
224
- return /^[A-Z][a-zA-Z0-9]*$/.test(name);
1095
+ function hasUiComponentSignal(node, ancestors, hocWrappers, isHookFn) {
1096
+ if (!node) return false;
1097
+ for (let i = ancestors.length - 2; i >= 0; i--) {
1098
+ const anc = ancestors[i];
1099
+ if (anc.type === "CallExpression") {
1100
+ if (isHocCall(anc, hocWrappers)) {
1101
+ return true;
1102
+ }
1103
+ } else {
1104
+ break;
1105
+ }
1106
+ }
1107
+ if (!node.body) return false;
1108
+ const stack = [node.body];
1109
+ while (stack.length > 0) {
1110
+ const cur = stack.pop();
1111
+ if (!cur || typeof cur !== "object") continue;
1112
+ if (cur.type === "JSXElement" || cur.type === "JSXFragment") {
1113
+ return true;
1114
+ }
1115
+ if (cur.type === "CallExpression") {
1116
+ const callee = unwrapCallee(cur.callee);
1117
+ let calleeName = "";
1118
+ let memberProp = "";
1119
+ let qualifiedCall = "";
1120
+ if (_optionalChain([callee, 'optionalAccess', _46 => _46.type]) === "Identifier") {
1121
+ calleeName = callee.name;
1122
+ qualifiedCall = calleeName;
1123
+ } else if (_optionalChain([callee, 'optionalAccess', _47 => _47.type]) === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _48 => _48.property, 'optionalAccess', _49 => _49.type]) === "Identifier") {
1124
+ memberProp = callee.property.name;
1125
+ if (_optionalChain([callee, 'access', _50 => _50.object, 'optionalAccess', _51 => _51.type]) === "Identifier") {
1126
+ qualifiedCall = `${callee.object.name}.${memberProp}`;
1127
+ }
1128
+ }
1129
+ if (JSX_FACTORY_CALLS.has(calleeName) || JSX_FACTORY_CALLS.has(memberProp) || qualifiedCall === "React.createElement" || qualifiedCall === "React.cloneElement" || REACT_HOOK_OR_RENDER_CALLS.has(calleeName) || REACT_HOOK_OR_RENDER_CALLS.has(memberProp) || isHookFn(calleeName) || isHookFn(memberProp)) {
1130
+ return true;
1131
+ }
1132
+ if (calleeName === "h" && Array.isArray(cur.arguments) && (cur.arguments.length >= 2 || cur.arguments.length === 1 && _optionalChain([cur, 'access', _52 => _52.arguments, 'access', _53 => _53[0], 'optionalAccess', _54 => _54.type]) === "Literal" && typeof cur.arguments[0].value === "string")) {
1133
+ return true;
1134
+ }
1135
+ }
1136
+ for (const key of Object.keys(cur)) {
1137
+ if (key === "loc" || key === "start" || key === "end") continue;
1138
+ const val = cur[key];
1139
+ if (Array.isArray(val)) {
1140
+ for (let i = val.length - 1; i >= 0; i--) {
1141
+ const item = val[i];
1142
+ if (item && typeof item === "object" && typeof item.type === "string" && !FUNCTION_NODE_TYPES.has(item.type)) {
1143
+ stack.push(item);
1144
+ }
1145
+ }
1146
+ } else if (val && typeof val === "object" && typeof val.type === "string" && !FUNCTION_NODE_TYPES.has(val.type)) {
1147
+ stack.push(val);
1148
+ }
1149
+ }
1150
+ }
1151
+ return false;
1152
+ }
1153
+ function isPascalCaseComponent(name, node, ancestors, hocWrappers, isHookFn) {
1154
+ if (!/^[A-Z][a-zA-Z0-9]*$/.test(name)) return false;
1155
+ if (!node || !ancestors) return false;
1156
+ return hasUiComponentSignal(
1157
+ node,
1158
+ ancestors,
1159
+ _nullishCoalesce(hocWrappers, () => ( DEFAULT_HOC_WRAPPERS)),
1160
+ _nullishCoalesce(isHookFn, () => ( ((n) => DEFAULT_HOOK_REGEX.test(n))))
1161
+ );
225
1162
  }
226
1163
  function isEventHandlerName(name, regex = DEFAULT_EVENT_HANDLER_REGEX) {
227
1164
  return regex.test(name);
@@ -264,7 +1201,7 @@ function isZeroArgIifeFactoryFunction(node) {
264
1201
  const retArg = stmts[0].argument;
265
1202
  if (!retArg || retArg.type !== "CallExpression") return false;
266
1203
  const callee = retArg.callee;
267
- return callee && (callee.type === "FunctionExpression" || callee.type === "ArrowFunctionExpression") && _optionalChain([callee, 'access', _20 => _20.body, 'optionalAccess', _21 => _21.type]) === "BlockStatement";
1204
+ return callee && (callee.type === "FunctionExpression" || callee.type === "ArrowFunctionExpression") && _optionalChain([callee, 'access', _55 => _55.body, 'optionalAccess', _56 => _56.type]) === "BlockStatement";
268
1205
  }
269
1206
  function containsLoopOrAnimation(fnNode, animationCalls = ANIMATION_FRAME_CALLS) {
270
1207
  let found = false;
@@ -287,12 +1224,12 @@ function containsLoopOrAnimation(fnNode, animationCalls = ANIMATION_FRAME_CALLS)
287
1224
  CallExpression(callNode) {
288
1225
  let cName = "";
289
1226
  let mProp = "";
290
- if (_optionalChain([callNode, 'access', _22 => _22.callee, 'optionalAccess', _23 => _23.type]) === "Identifier") {
1227
+ if (_optionalChain([callNode, 'access', _57 => _57.callee, 'optionalAccess', _58 => _58.type]) === "Identifier") {
291
1228
  cName = callNode.callee.name;
292
- } else if (_optionalChain([callNode, 'access', _24 => _24.callee, 'optionalAccess', _25 => _25.type]) === "MemberExpression" && !callNode.callee.computed && _optionalChain([callNode, 'access', _26 => _26.callee, 'access', _27 => _27.property, 'optionalAccess', _28 => _28.type]) === "Identifier") {
1229
+ } else if (_optionalChain([callNode, 'access', _59 => _59.callee, 'optionalAccess', _60 => _60.type]) === "MemberExpression" && !callNode.callee.computed && _optionalChain([callNode, 'access', _61 => _61.callee, 'access', _62 => _62.property, 'optionalAccess', _63 => _63.type]) === "Identifier") {
293
1230
  mProp = callNode.callee.property.name;
294
1231
  }
295
- const isTickerAdd = mProp === "add" && (_optionalChain([callNode, 'access', _29 => _29.callee, 'optionalAccess', _30 => _30.object, 'optionalAccess', _31 => _31.name]) === "ticker" || _optionalChain([callNode, 'access', _32 => _32.callee, 'optionalAccess', _33 => _33.object, 'optionalAccess', _34 => _34.property, 'optionalAccess', _35 => _35.name]) === "ticker");
1232
+ const isTickerAdd = mProp === "add" && (_optionalChain([callNode, 'access', _64 => _64.callee, 'optionalAccess', _65 => _65.object, 'optionalAccess', _66 => _66.name]) === "ticker" || _optionalChain([callNode, 'access', _67 => _67.callee, 'optionalAccess', _68 => _68.object, 'optionalAccess', _69 => _69.property, 'optionalAccess', _70 => _70.name]) === "ticker");
296
1233
  if (animationCalls.has(cName) || animationCalls.has(mProp) || isTickerAdd) {
297
1234
  found = true;
298
1235
  }
@@ -300,7 +1237,7 @@ function containsLoopOrAnimation(fnNode, animationCalls = ANIMATION_FRAME_CALLS)
300
1237
  });
301
1238
  return found;
302
1239
  }
303
- function analyzeAstHotPaths(ast, config) {
1240
+ function analyzeAstHotPaths(ast, config, originalSourceMap) {
304
1241
  const hotFunctionNodes = /* @__PURE__ */ new WeakSet();
305
1242
  const coldFunctionNodes = /* @__PURE__ */ new WeakSet();
306
1243
  const hotExemptNodes = /* @__PURE__ */ new WeakSet();
@@ -323,24 +1260,24 @@ function analyzeAstHotPaths(ast, config) {
323
1260
  const pendingHotRefs = [];
324
1261
  const allCallSites = [];
325
1262
  const animationCalls = new Set(ANIMATION_FRAME_CALLS);
326
- if (_optionalChain([config, 'optionalAccess', _36 => _36.hotPath, 'optionalAccess', _37 => _37.customAnimationCalls])) {
1263
+ if (_optionalChain([config, 'optionalAccess', _71 => _71.hotPath, 'optionalAccess', _72 => _72.customAnimationCalls])) {
327
1264
  for (const c of config.hotPath.customAnimationCalls) {
328
1265
  animationCalls.add(c);
329
1266
  }
330
1267
  }
331
1268
  const mergedImportSources = {
332
1269
  ...DEFAULT_IMPORT_SOURCES,
333
- ..._nullishCoalesce(_optionalChain([config, 'optionalAccess', _38 => _38.hotPath, 'optionalAccess', _39 => _39.importSources]), () => ( {}))
1270
+ ..._nullishCoalesce(_optionalChain([config, 'optionalAccess', _73 => _73.hotPath, 'optionalAccess', _74 => _74.importSources]), () => ( {}))
334
1271
  };
335
1272
  if (ast && Array.isArray(ast.body)) {
336
1273
  for (const stmt of ast.body) {
337
- if (stmt.type === "ImportDeclaration" && _optionalChain([stmt, 'access', _40 => _40.source, 'optionalAccess', _41 => _41.value])) {
1274
+ if (stmt.type === "ImportDeclaration" && _optionalChain([stmt, 'access', _75 => _75.source, 'optionalAccess', _76 => _76.value])) {
338
1275
  const sourcePkg = String(stmt.source.value);
339
1276
  const sourceMethods = mergedImportSources[sourcePkg];
340
1277
  for (const spec of stmt.specifiers || []) {
341
1278
  if (spec.type === "ImportSpecifier") {
342
- const importedName = _nullishCoalesce(_optionalChain([spec, 'access', _42 => _42.imported, 'optionalAccess', _43 => _43.name]), () => ( _optionalChain([spec, 'access', _44 => _44.imported, 'optionalAccess', _45 => _45.value])));
343
- const localName = _optionalChain([spec, 'access', _46 => _46.local, 'optionalAccess', _47 => _47.name]);
1279
+ const importedName = _nullishCoalesce(_optionalChain([spec, 'access', _77 => _77.imported, 'optionalAccess', _78 => _78.name]), () => ( _optionalChain([spec, 'access', _79 => _79.imported, 'optionalAccess', _80 => _80.value])));
1280
+ const localName = _optionalChain([spec, 'access', _81 => _81.local, 'optionalAccess', _82 => _82.name]);
344
1281
  if (localName && importedName) {
345
1282
  const isKnownSource = sourceMethods !== void 0;
346
1283
  const isListedMethod = sourceMethods && (sourceMethods.includes(importedName) || sourceMethods.includes("*"));
@@ -355,36 +1292,36 @@ function analyzeAstHotPaths(ast, config) {
355
1292
  }
356
1293
  }
357
1294
  const hocWrappers = new Set(DEFAULT_HOC_WRAPPERS);
358
- if (_optionalChain([config, 'optionalAccess', _48 => _48.hotPath, 'optionalAccess', _49 => _49.hocWrappers])) {
1295
+ if (_optionalChain([config, 'optionalAccess', _83 => _83.hotPath, 'optionalAccess', _84 => _84.hocWrappers])) {
359
1296
  for (const h of config.hotPath.hocWrappers) {
360
1297
  hocWrappers.add(h);
361
1298
  }
362
1299
  }
363
1300
  const arrayHofMethods = new Set(ARRAY_HOF_METHODS);
364
- if (_optionalChain([config, 'optionalAccess', _50 => _50.hotPath, 'optionalAccess', _51 => _51.arrayHofMethods])) {
1301
+ if (_optionalChain([config, 'optionalAccess', _85 => _85.hotPath, 'optionalAccess', _86 => _86.arrayHofMethods])) {
365
1302
  for (const m of config.hotPath.arrayHofMethods) {
366
1303
  arrayHofMethods.add(m);
367
1304
  }
368
1305
  }
369
- const rawEventRegex = _optionalChain([config, 'optionalAccess', _52 => _52.hotPath, 'optionalAccess', _53 => _53.eventHandlerRegex]);
1306
+ const rawEventRegex = _optionalChain([config, 'optionalAccess', _87 => _87.hotPath, 'optionalAccess', _88 => _88.eventHandlerRegex]);
370
1307
  const eventHandlerRegex = typeof rawEventRegex === "string" ? new RegExp(rawEventRegex) : _nullishCoalesce(rawEventRegex, () => ( DEFAULT_EVENT_HANDLER_REGEX));
371
- const rawHookRegex = _optionalChain([config, 'optionalAccess', _54 => _54.hotPath, 'optionalAccess', _55 => _55.hookPattern]);
1308
+ const rawHookRegex = _optionalChain([config, 'optionalAccess', _89 => _89.hotPath, 'optionalAccess', _90 => _90.hookPattern]);
372
1309
  const hookRegex = typeof rawHookRegex === "string" ? new RegExp(rawHookRegex) : _nullishCoalesce(rawHookRegex, () => ( DEFAULT_HOOK_REGEX));
373
- const customHooksSet = new Set(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _56 => _56.hotPath, 'optionalAccess', _57 => _57.customHooks]), () => ( [])));
1310
+ const customHooksSet = new Set(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _91 => _91.hotPath, 'optionalAccess', _92 => _92.customHooks]), () => ( [])));
374
1311
  function isHookName(name) {
375
1312
  if (!name) return false;
376
1313
  return customHooksSet.has(name) || hookRegex.test(name);
377
1314
  }
378
- const excludedComponents = new Set(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _58 => _58.hotPath, 'optionalAccess', _59 => _59.excludeComponents]), () => ( [])));
379
- const maxPipelineCallers = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _60 => _60.hotPath, 'optionalAccess', _61 => _61.maxPipelineCallers]), () => ( 2));
1315
+ const excludedComponents = new Set(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _93 => _93.hotPath, 'optionalAccess', _94 => _94.excludeComponents]), () => ( [])));
1316
+ const maxPipelineCallers = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _95 => _95.hotPath, 'optionalAccess', _96 => _96.maxPipelineCallers]), () => ( 2));
380
1317
  function ensureFnParams(fnNode) {
381
1318
  let paramSet = fnParams.get(fnNode);
382
1319
  if (!paramSet) {
383
1320
  paramSet = /* @__PURE__ */ new Set();
384
1321
  for (const p of fnNode.params || []) {
385
- if (_optionalChain([p, 'optionalAccess', _62 => _62.type]) === "Identifier") {
1322
+ if (_optionalChain([p, 'optionalAccess', _97 => _97.type]) === "Identifier") {
386
1323
  paramSet.add(p.name);
387
- } else if (_optionalChain([p, 'optionalAccess', _63 => _63.type]) === "AssignmentPattern" && _optionalChain([p, 'access', _64 => _64.left, 'optionalAccess', _65 => _65.type]) === "Identifier") {
1324
+ } else if (_optionalChain([p, 'optionalAccess', _98 => _98.type]) === "AssignmentPattern" && _optionalChain([p, 'access', _99 => _99.left, 'optionalAccess', _100 => _100.type]) === "Identifier") {
388
1325
  paramSet.add(p.left.name);
389
1326
  }
390
1327
  }
@@ -426,7 +1363,7 @@ function analyzeAstHotPaths(ast, config) {
426
1363
  if (!anc || typeof anc.start !== "number") break;
427
1364
  if (anc.type === "VariableDeclarator" && anc.init === child) {
428
1365
  anchorStart = Math.min(anchorStart, anc.start);
429
- } else if (anc.type === "VariableDeclaration" && _optionalChain([anc, 'access', _66 => _66.declarations, 'optionalAccess', _67 => _67[0]]) === child) {
1366
+ } else if (anc.type === "VariableDeclaration" && _optionalChain([anc, 'access', _101 => _101.declarations, 'optionalAccess', _102 => _102[0]]) === child) {
430
1367
  anchorStart = Math.min(anchorStart, anc.start);
431
1368
  } else if ((anc.type === "ExportNamedDeclaration" || anc.type === "ExportDefaultDeclaration") && anc.declaration === child) {
432
1369
  anchorStart = Math.min(anchorStart, anc.start);
@@ -442,15 +1379,56 @@ function analyzeAstHotPaths(ast, config) {
442
1379
  }
443
1380
  return anchorStart;
444
1381
  }
1382
+ function getFunctionIdNode(node, ancestors) {
1383
+ if (node.id) return node.id;
1384
+ const parent = ancestors[ancestors.length - 2];
1385
+ if (!parent) return null;
1386
+ if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _103 => _103.id, 'optionalAccess', _104 => _104.type]) === "Identifier") {
1387
+ return parent.id;
1388
+ }
1389
+ if (parent.type === "AssignmentExpression" && _optionalChain([parent, 'access', _105 => _105.left, 'optionalAccess', _106 => _106.type]) === "Identifier") {
1390
+ return parent.left;
1391
+ }
1392
+ if ((parent.type === "Property" || parent.type === "MethodDefinition") && _optionalChain([parent, 'access', _107 => _107.key, 'optionalAccess', _108 => _108.type]) === "Identifier") {
1393
+ return parent.key;
1394
+ }
1395
+ if (parent.type === "CallExpression") {
1396
+ let idx = ancestors.length - 2;
1397
+ let matchedHoc = false;
1398
+ while (idx >= 0 && ancestors[idx].type === "CallExpression") {
1399
+ if (isHocCall(ancestors[idx], hocWrappers)) {
1400
+ matchedHoc = true;
1401
+ idx--;
1402
+ } else {
1403
+ break;
1404
+ }
1405
+ }
1406
+ if (matchedHoc && idx >= 0) {
1407
+ const outer = ancestors[idx];
1408
+ if (outer.type === "VariableDeclarator" && _optionalChain([outer, 'access', _109 => _109.id, 'optionalAccess', _110 => _110.type]) === "Identifier") {
1409
+ return outer.id;
1410
+ }
1411
+ if (outer.type === "AssignmentExpression" && _optionalChain([outer, 'access', _111 => _111.left, 'optionalAccess', _112 => _112.type]) === "Identifier") {
1412
+ return outer.left;
1413
+ }
1414
+ }
1415
+ }
1416
+ return null;
1417
+ }
445
1418
  function registerFunctionNode(node, ancestors) {
446
1419
  const name = getFunctionLabel(node, ancestors, hocWrappers);
447
- allFunctions.push({ node, name, anchorStart: computeFunctionAnchorStart(node, ancestors) });
1420
+ allFunctions.push({
1421
+ node,
1422
+ name,
1423
+ anchorStart: computeFunctionAnchorStart(node, ancestors),
1424
+ idNode: getFunctionIdNode(node, ancestors)
1425
+ });
448
1426
  fnByName.set(name, node);
449
1427
  const paramSet = /* @__PURE__ */ new Set();
450
1428
  for (const p of node.params || []) {
451
- if (_optionalChain([p, 'optionalAccess', _68 => _68.type]) === "Identifier") {
1429
+ if (_optionalChain([p, 'optionalAccess', _113 => _113.type]) === "Identifier") {
452
1430
  paramSet.add(p.name);
453
- } else if (_optionalChain([p, 'optionalAccess', _69 => _69.type]) === "AssignmentPattern" && _optionalChain([p, 'access', _70 => _70.left, 'optionalAccess', _71 => _71.type]) === "Identifier") {
1431
+ } else if (_optionalChain([p, 'optionalAccess', _114 => _114.type]) === "AssignmentPattern" && _optionalChain([p, 'access', _115 => _115.left, 'optionalAccess', _116 => _116.type]) === "Identifier") {
454
1432
  paramSet.add(p.left.name);
455
1433
  }
456
1434
  }
@@ -463,17 +1441,17 @@ function analyzeAstHotPaths(ast, config) {
463
1441
  }
464
1442
  localMap.set(name, node);
465
1443
  const parent = ancestors[ancestors.length - 2];
466
- if (_optionalChain([parent, 'optionalAccess', _72 => _72.type]) === "VariableDeclarator" && _optionalChain([parent, 'access', _73 => _73.id, 'optionalAccess', _74 => _74.type]) === "Identifier") {
1444
+ if (_optionalChain([parent, 'optionalAccess', _117 => _117.type]) === "VariableDeclarator" && _optionalChain([parent, 'access', _118 => _118.id, 'optionalAccess', _119 => _119.type]) === "Identifier") {
467
1445
  fnByName.set(parent.id.name, node);
468
1446
  localMap.set(parent.id.name, node);
469
- } else if (_optionalChain([parent, 'optionalAccess', _75 => _75.type]) === "AssignmentExpression" && _optionalChain([parent, 'access', _76 => _76.left, 'optionalAccess', _77 => _77.type]) === "Identifier") {
1447
+ } else if (_optionalChain([parent, 'optionalAccess', _120 => _120.type]) === "AssignmentExpression" && _optionalChain([parent, 'access', _121 => _121.left, 'optionalAccess', _122 => _122.type]) === "Identifier") {
470
1448
  fnByName.set(parent.left.name, node);
471
1449
  localMap.set(parent.left.name, node);
472
- } else if (_optionalChain([parent, 'optionalAccess', _78 => _78.type]) === "AssignmentExpression" && _optionalChain([parent, 'access', _79 => _79.left, 'optionalAccess', _80 => _80.type]) === "MemberExpression" && !parent.left.computed && _optionalChain([parent, 'access', _81 => _81.left, 'access', _82 => _82.property, 'optionalAccess', _83 => _83.type]) === "Identifier") {
1450
+ } else if (_optionalChain([parent, 'optionalAccess', _123 => _123.type]) === "AssignmentExpression" && _optionalChain([parent, 'access', _124 => _124.left, 'optionalAccess', _125 => _125.type]) === "MemberExpression" && !parent.left.computed && _optionalChain([parent, 'access', _126 => _126.left, 'access', _127 => _127.property, 'optionalAccess', _128 => _128.type]) === "Identifier") {
473
1451
  const propName = parent.left.property.name;
474
1452
  fnByName.set(propName, node);
475
1453
  localMap.set(propName, node);
476
- if (_optionalChain([parent, 'access', _84 => _84.left, 'access', _85 => _85.object, 'optionalAccess', _86 => _86.type]) === "Identifier") {
1454
+ if (_optionalChain([parent, 'access', _129 => _129.left, 'access', _130 => _130.object, 'optionalAccess', _131 => _131.type]) === "Identifier") {
477
1455
  const qual = `${parent.left.object.name}.${propName}`;
478
1456
  fnByName.set(qual, node);
479
1457
  localMap.set(qual, node);
@@ -481,7 +1459,7 @@ function analyzeAstHotPaths(ast, config) {
481
1459
  }
482
1460
  const grandParent = ancestors[ancestors.length - 3];
483
1461
  const greatGrandParent = ancestors[ancestors.length - 4];
484
- if (_optionalChain([parent, 'optionalAccess', _87 => _87.type]) === "Property" && _optionalChain([parent, 'access', _88 => _88.key, 'optionalAccess', _89 => _89.type]) === "Identifier" && _optionalChain([grandParent, 'optionalAccess', _90 => _90.type]) === "ObjectExpression" && _optionalChain([greatGrandParent, 'optionalAccess', _91 => _91.type]) === "VariableDeclarator" && _optionalChain([greatGrandParent, 'access', _92 => _92.id, 'optionalAccess', _93 => _93.type]) === "Identifier") {
1462
+ if (_optionalChain([parent, 'optionalAccess', _132 => _132.type]) === "Property" && _optionalChain([parent, 'access', _133 => _133.key, 'optionalAccess', _134 => _134.type]) === "Identifier" && _optionalChain([grandParent, 'optionalAccess', _135 => _135.type]) === "ObjectExpression" && _optionalChain([greatGrandParent, 'optionalAccess', _136 => _136.type]) === "VariableDeclarator" && _optionalChain([greatGrandParent, 'access', _137 => _137.id, 'optionalAccess', _138 => _138.type]) === "Identifier") {
485
1463
  const qualified = `${greatGrandParent.id.name}.${parent.key.name}`;
486
1464
  fnByName.set(qualified, node);
487
1465
  localMap.set(qualified, node);
@@ -493,7 +1471,8 @@ function analyzeAstHotPaths(ast, config) {
493
1471
  }
494
1472
  }
495
1473
  fnScopeChain.set(node, chain);
496
- if (isPascalCaseComponent(name) && !excludedComponents.has(name)) {
1474
+ if (isPascalCaseComponent(name, node, ancestors, hocWrappers, isHookName) && !excludedComponents.has(name)) {
1475
+ node._unpeekIsComponent = true;
497
1476
  shallowComponentNodes.add(node);
498
1477
  hotFunctionNodes.add(node);
499
1478
  directHotNodes.add(node);
@@ -510,13 +1489,13 @@ function analyzeAstHotPaths(ast, config) {
510
1489
  }
511
1490
  }
512
1491
  function resolveCalleeNode(callerNode, calleeKey) {
513
- const directLocal = _optionalChain([scopeFunctions, 'access', _94 => _94.get, 'call', _95 => _95(callerNode), 'optionalAccess', _96 => _96.get, 'call', _97 => _97(calleeKey)]);
1492
+ const directLocal = _optionalChain([scopeFunctions, 'access', _139 => _139.get, 'call', _140 => _140(callerNode), 'optionalAccess', _141 => _141.get, 'call', _142 => _142(calleeKey)]);
514
1493
  if (directLocal) return directLocal;
515
1494
  const chain = fnScopeChain.get(callerNode);
516
1495
  if (chain) {
517
1496
  for (const scopeNode of chain) {
518
1497
  const localMap = scopeFunctions.get(scopeNode);
519
- const found = _optionalChain([localMap, 'optionalAccess', _98 => _98.get, 'call', _99 => _99(calleeKey)]);
1498
+ const found = _optionalChain([localMap, 'optionalAccess', _143 => _143.get, 'call', _144 => _144(calleeKey)]);
520
1499
  if (found) return found;
521
1500
  }
522
1501
  }
@@ -528,12 +1507,12 @@ function analyzeAstHotPaths(ast, config) {
528
1507
  markSerializedFunction(target);
529
1508
  } else if (target.type === "Identifier") {
530
1509
  pendingSerializedRefs.push({ scopeNode: enclosingScope, name: target.name });
531
- } else if (target.type === "MemberExpression" && !target.computed && _optionalChain([target, 'access', _100 => _100.property, 'optionalAccess', _101 => _101.type]) === "Identifier") {
1510
+ } else if (target.type === "MemberExpression" && !target.computed && _optionalChain([target, 'access', _145 => _145.property, 'optionalAccess', _146 => _146.type]) === "Identifier") {
532
1511
  pendingSerializedRefs.push({
533
1512
  scopeNode: enclosingScope,
534
1513
  name: target.property.name
535
1514
  });
536
- if (_optionalChain([target, 'access', _102 => _102.object, 'optionalAccess', _103 => _103.type]) === "Identifier") {
1515
+ if (_optionalChain([target, 'access', _147 => _147.object, 'optionalAccess', _148 => _148.type]) === "Identifier") {
537
1516
  pendingSerializedRefs.push({
538
1517
  scopeNode: enclosingScope,
539
1518
  name: `${target.object.name}.${target.property.name}`
@@ -552,19 +1531,19 @@ function analyzeAstHotPaths(ast, config) {
552
1531
  registerFunctionNode(node, ancestors);
553
1532
  },
554
1533
  VariableDeclarator(node, _state, ancestors) {
555
- if (_optionalChain([node, 'access', _104 => _104.id, 'optionalAccess', _105 => _105.type]) === "Identifier" && _optionalChain([node, 'access', _106 => _106.init, 'optionalAccess', _107 => _107.type]) === "Identifier") {
1534
+ if (_optionalChain([node, 'access', _149 => _149.id, 'optionalAccess', _150 => _150.type]) === "Identifier" && _optionalChain([node, 'access', _151 => _151.init, 'optionalAccess', _152 => _152.type]) === "Identifier") {
556
1535
  const scopeNode = _nullishCoalesce(findEnclosingFunction(ancestors), () => ( ast));
557
1536
  recordVarAlias(scopeNode, node.id.name, node.init.name);
558
1537
  }
559
1538
  },
560
1539
  AssignmentExpression(node, _state, ancestors) {
561
1540
  const left = node.left;
562
- if (_optionalChain([left, 'optionalAccess', _108 => _108.type]) === "Identifier" && _optionalChain([node, 'access', _109 => _109.right, 'optionalAccess', _110 => _110.type]) === "Identifier") {
1541
+ if (_optionalChain([left, 'optionalAccess', _153 => _153.type]) === "Identifier" && _optionalChain([node, 'access', _154 => _154.right, 'optionalAccess', _155 => _155.type]) === "Identifier") {
563
1542
  const scopeNode = _nullishCoalesce(findEnclosingFunction(ancestors), () => ( ast));
564
1543
  recordVarAlias(scopeNode, left.name, node.right.name);
565
1544
  }
566
- const isBareOnMessage = _optionalChain([left, 'optionalAccess', _111 => _111.type]) === "Identifier" && left.name === "onmessage";
567
- const isSelfOnMessage = _optionalChain([left, 'optionalAccess', _112 => _112.type]) === "MemberExpression" && !left.computed && _optionalChain([left, 'access', _113 => _113.object, 'optionalAccess', _114 => _114.type]) === "Identifier" && left.object.name === "self" && _optionalChain([left, 'access', _115 => _115.property, 'optionalAccess', _116 => _116.type]) === "Identifier" && left.property.name === "onmessage";
1545
+ const isBareOnMessage = _optionalChain([left, 'optionalAccess', _156 => _156.type]) === "Identifier" && left.name === "onmessage";
1546
+ const isSelfOnMessage = _optionalChain([left, 'optionalAccess', _157 => _157.type]) === "MemberExpression" && !left.computed && _optionalChain([left, 'access', _158 => _158.object, 'optionalAccess', _159 => _159.type]) === "Identifier" && left.object.name === "self" && _optionalChain([left, 'access', _160 => _160.property, 'optionalAccess', _161 => _161.type]) === "Identifier" && left.property.name === "onmessage";
568
1547
  if (isBareOnMessage || isSelfOnMessage) {
569
1548
  const enclosingFn = findEnclosingFunction(ancestors);
570
1549
  if (enclosingFn) {
@@ -582,8 +1561,8 @@ function analyzeAstHotPaths(ast, config) {
582
1561
  const props = node.properties || [];
583
1562
  const propMap = /* @__PURE__ */ new Map();
584
1563
  for (const p of props) {
585
- if (_optionalChain([p, 'optionalAccess', _117 => _117.type]) === "Property" && !p.computed) {
586
- const keyName = _optionalChain([p, 'access', _118 => _118.key, 'optionalAccess', _119 => _119.type]) === "Identifier" ? p.key.name : _optionalChain([p, 'access', _120 => _120.key, 'optionalAccess', _121 => _121.type]) === "Literal" ? String(p.key.value) : "";
1564
+ if (_optionalChain([p, 'optionalAccess', _162 => _162.type]) === "Property" && !p.computed) {
1565
+ const keyName = _optionalChain([p, 'access', _163 => _163.key, 'optionalAccess', _164 => _164.type]) === "Identifier" ? p.key.name : _optionalChain([p, 'access', _165 => _165.key, 'optionalAccess', _166 => _166.type]) === "Literal" ? String(p.key.value) : "";
587
1566
  if (keyName) {
588
1567
  propMap.set(keyName, p.value);
589
1568
  }
@@ -597,7 +1576,7 @@ function analyzeAstHotPaths(ast, config) {
597
1576
  if (val) queueSerializedTarget(val, scopeNode);
598
1577
  }
599
1578
  const deps = propMap.get("dependencies");
600
- if (_optionalChain([deps, 'optionalAccess', _122 => _122.type]) === "ArrayExpression") {
1579
+ if (_optionalChain([deps, 'optionalAccess', _167 => _167.type]) === "ArrayExpression") {
601
1580
  for (const el of deps.elements || []) {
602
1581
  if (el) queueSerializedTarget(el, scopeNode);
603
1582
  }
@@ -605,18 +1584,18 @@ function analyzeAstHotPaths(ast, config) {
605
1584
  }
606
1585
  },
607
1586
  CallExpression(node, _state, ancestors) {
608
- const callee = node.callee;
1587
+ const callee = unwrapCallee(node.callee);
609
1588
  let calleeName = "";
610
1589
  let memberProp = "";
611
1590
  let qualifiedCall = "";
612
- if (_optionalChain([callee, 'optionalAccess', _123 => _123.type]) === "Identifier") {
1591
+ if (_optionalChain([callee, 'optionalAccess', _168 => _168.type]) === "Identifier") {
613
1592
  calleeName = callee.name;
614
1593
  qualifiedCall = calleeName;
615
- } else if (_optionalChain([callee, 'optionalAccess', _124 => _124.type]) === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _125 => _125.property, 'optionalAccess', _126 => _126.type]) === "Identifier") {
1594
+ } else if (_optionalChain([callee, 'optionalAccess', _169 => _169.type]) === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _170 => _170.property, 'optionalAccess', _171 => _171.type]) === "Identifier") {
616
1595
  memberProp = callee.property.name;
617
- if (_optionalChain([callee, 'access', _127 => _127.object, 'optionalAccess', _128 => _128.type]) === "Identifier") {
1596
+ if (_optionalChain([callee, 'access', _172 => _172.object, 'optionalAccess', _173 => _173.type]) === "Identifier") {
618
1597
  qualifiedCall = `${callee.object.name}.${memberProp}`;
619
- } else if (_optionalChain([callee, 'access', _129 => _129.object, 'optionalAccess', _130 => _130.type]) === "ThisExpression") {
1598
+ } else if (_optionalChain([callee, 'access', _174 => _174.object, 'optionalAccess', _175 => _175.type]) === "ThisExpression") {
620
1599
  qualifiedCall = memberProp;
621
1600
  }
622
1601
  }
@@ -640,10 +1619,10 @@ function analyzeAstHotPaths(ast, config) {
640
1619
  }
641
1620
  }
642
1621
  }
643
- if (memberProp === "toString" && (!node.arguments || node.arguments.length === 0) && _optionalChain([callee, 'optionalAccess', _131 => _131.type]) === "MemberExpression") {
1622
+ if (memberProp === "toString" && (!node.arguments || node.arguments.length === 0) && _optionalChain([callee, 'optionalAccess', _176 => _176.type]) === "MemberExpression") {
644
1623
  const targetObj = callee.object;
645
1624
  queueSerializedTarget(targetObj, currentScope);
646
- if (_optionalChain([targetObj, 'optionalAccess', _132 => _132.type]) === "Identifier" && enclosingFn) {
1625
+ if (_optionalChain([targetObj, 'optionalAccess', _177 => _177.type]) === "Identifier" && enclosingFn) {
647
1626
  const resolvedName = resolveAliasTarget(enclosingFn, targetObj.name);
648
1627
  if (ensureFnParams(enclosingFn).has(resolvedName)) {
649
1628
  serializerHelperNodes.add(enclosingFn);
@@ -653,10 +1632,10 @@ function analyzeAstHotPaths(ast, config) {
653
1632
  }
654
1633
  }
655
1634
  }
656
- if ((memberProp === "call" || memberProp === "apply") && _optionalChain([callee, 'optionalAccess', _133 => _133.type]) === "MemberExpression" && _optionalChain([callee, 'access', _134 => _134.object, 'optionalAccess', _135 => _135.type]) === "MemberExpression" && _optionalChain([callee, 'access', _136 => _136.object, 'access', _137 => _137.property, 'optionalAccess', _138 => _138.type]) === "Identifier" && callee.object.property.name === "toString" && _optionalChain([node, 'access', _139 => _139.arguments, 'optionalAccess', _140 => _140.length]) > 0) {
1635
+ if ((memberProp === "call" || memberProp === "apply") && _optionalChain([callee, 'optionalAccess', _178 => _178.type]) === "MemberExpression" && _optionalChain([callee, 'access', _179 => _179.object, 'optionalAccess', _180 => _180.type]) === "MemberExpression" && _optionalChain([callee, 'access', _181 => _181.object, 'access', _182 => _182.property, 'optionalAccess', _183 => _183.type]) === "Identifier" && callee.object.property.name === "toString" && _optionalChain([node, 'access', _184 => _184.arguments, 'optionalAccess', _185 => _185.length]) > 0) {
657
1636
  const firstArg = node.arguments[0];
658
1637
  queueSerializedTarget(firstArg, currentScope);
659
- if (_optionalChain([firstArg, 'optionalAccess', _141 => _141.type]) === "Identifier" && enclosingFn) {
1638
+ if (_optionalChain([firstArg, 'optionalAccess', _186 => _186.type]) === "Identifier" && enclosingFn) {
660
1639
  const resolvedName = resolveAliasTarget(enclosingFn, firstArg.name);
661
1640
  if (ensureFnParams(enclosingFn).has(resolvedName)) {
662
1641
  serializerHelperNodes.add(enclosingFn);
@@ -666,12 +1645,12 @@ function analyzeAstHotPaths(ast, config) {
666
1645
  }
667
1646
  }
668
1647
  }
669
- if (calleeName === "importScripts" || memberProp === "importScripts" && _optionalChain([callee, 'optionalAccess', _142 => _142.object, 'optionalAccess', _143 => _143.type]) === "Identifier" && callee.object.name === "self") {
1648
+ if (calleeName === "importScripts" || memberProp === "importScripts" && _optionalChain([callee, 'optionalAccess', _187 => _187.object, 'optionalAccess', _188 => _188.type]) === "Identifier" && callee.object.name === "self") {
670
1649
  if (enclosingFn) markSerializedFunction(enclosingFn);
671
1650
  const outerFn = findOutermostModuleFunction(ancestors);
672
1651
  if (outerFn) markSerializedFunction(outerFn);
673
1652
  }
674
- const isTickerAdd = memberProp === "add" && (_optionalChain([callee, 'optionalAccess', _144 => _144.object, 'optionalAccess', _145 => _145.name]) === "ticker" || _optionalChain([callee, 'optionalAccess', _146 => _146.object, 'optionalAccess', _147 => _147.property, 'optionalAccess', _148 => _148.name]) === "ticker");
1653
+ const isTickerAdd = memberProp === "add" && (_optionalChain([callee, 'optionalAccess', _189 => _189.object, 'optionalAccess', _190 => _190.name]) === "ticker" || _optionalChain([callee, 'optionalAccess', _191 => _191.object, 'optionalAccess', _192 => _192.property, 'optionalAccess', _193 => _193.name]) === "ticker");
675
1654
  if (animationCalls.has(calleeName) || animationCalls.has(memberProp) || isTickerAdd) {
676
1655
  if (enclosingFn) {
677
1656
  trueHotNodes.add(enclosingFn);
@@ -684,7 +1663,7 @@ function analyzeAstHotPaths(ast, config) {
684
1663
  hotFunctionNodes.add(arg);
685
1664
  directHotNodes.add(arg);
686
1665
  hotExemptNodes.add(arg);
687
- } else if (_optionalChain([arg, 'optionalAccess', _149 => _149.type]) === "Identifier") {
1666
+ } else if (_optionalChain([arg, 'optionalAccess', _194 => _194.type]) === "Identifier") {
688
1667
  pendingHotRefs.push({ scopeNode: currentScope, name: arg.name });
689
1668
  allCallSites.push({
690
1669
  scopeNode: currentScope,
@@ -702,7 +1681,7 @@ function analyzeAstHotPaths(ast, config) {
702
1681
  hotFunctionNodes.add(arg);
703
1682
  directHotNodes.add(arg);
704
1683
  hotExemptNodes.add(arg);
705
- } else if (_optionalChain([arg, 'optionalAccess', _150 => _150.type]) === "Identifier") {
1684
+ } else if (_optionalChain([arg, 'optionalAccess', _195 => _195.type]) === "Identifier") {
706
1685
  allCallSites.push({
707
1686
  scopeNode: currentScope,
708
1687
  calleeKey: arg.name,
@@ -720,11 +1699,11 @@ function analyzeAstHotPaths(ast, config) {
720
1699
  }
721
1700
  }
722
1701
  if (calleeName === "useEffect" || memberProp === "useEffect" || calleeName === "useLayoutEffect" || memberProp === "useLayoutEffect") {
723
- const effectArg = _optionalChain([node, 'access', _151 => _151.arguments, 'optionalAccess', _152 => _152[0]]);
1702
+ const effectArg = _optionalChain([node, 'access', _196 => _196.arguments, 'optionalAccess', _197 => _197[0]]);
724
1703
  if (effectArg && FUNCTION_NODE_TYPES.has(effectArg.type)) {
725
1704
  if (!containsLoopOrAnimation(effectArg, animationCalls)) {
726
1705
  coldForcedNodes.add(effectArg);
727
- if (_optionalChain([effectArg, 'access', _153 => _153.body, 'optionalAccess', _154 => _154.type]) === "BlockStatement") {
1706
+ if (_optionalChain([effectArg, 'access', _198 => _198.body, 'optionalAccess', _199 => _199.type]) === "BlockStatement") {
728
1707
  for (const s of effectArg.body.body || []) {
729
1708
  if (s.type === "ReturnStatement" && s.argument && FUNCTION_NODE_TYPES.has(s.argument.type) && !containsLoopOrAnimation(s.argument, animationCalls)) {
730
1709
  coldForcedNodes.add(s.argument);
@@ -736,6 +1715,9 @@ function analyzeAstHotPaths(ast, config) {
736
1715
  }
737
1716
  if (REACT_HOOK_OR_RENDER_CALLS.has(calleeName) || REACT_HOOK_OR_RENDER_CALLS.has(memberProp) || isHookName(calleeName) || isHookName(memberProp)) {
738
1717
  if (enclosingFn) {
1718
+ if (JSX_FACTORY_CALLS.has(calleeName) || JSX_FACTORY_CALLS.has(memberProp) || REACT_HOOK_OR_RENDER_CALLS.has(calleeName) || REACT_HOOK_OR_RENDER_CALLS.has(memberProp)) {
1719
+ enclosingFn._unpeekIsComponent = true;
1720
+ }
739
1721
  shallowComponentNodes.add(enclosingFn);
740
1722
  hotFunctionNodes.add(enclosingFn);
741
1723
  directHotNodes.add(enclosingFn);
@@ -842,7 +1824,7 @@ function analyzeAstHotPaths(ast, config) {
842
1824
  break;
843
1825
  }
844
1826
  if (coldForcedNodes.has(fn.node)) continue;
845
- const isModuleContainer = (_nullishCoalesce(_optionalChain([fnScopeChain, 'access', _155 => _155.get, 'call', _156 => _156(anc), 'optionalAccess', _157 => _157.length]), () => ( 0))) <= 1;
1827
+ const isModuleContainer = (_nullishCoalesce(_optionalChain([fnScopeChain, 'access', _200 => _200.get, 'call', _201 => _201(anc), 'optionalAccess', _202 => _202.length]), () => ( 0))) <= 1;
846
1828
  if (trueHotNodes.has(anc) && !shallowComponentNodes.has(anc) && !isModuleContainer) {
847
1829
  if (!trueHotNodes.has(fn.node)) {
848
1830
  trueHotNodes.add(fn.node);
@@ -904,6 +1886,99 @@ function analyzeAstHotPaths(ast, config) {
904
1886
  }
905
1887
  }
906
1888
  }
1889
+ const criticalAnnotation = typeof _optionalChain([config, 'optionalAccess', _203 => _203.critical, 'optionalAccess', _204 => _204.annotation]) === "string" && config.critical.annotation.length > 0 ? config.critical.annotation : "@unpeek-critical";
1890
+ const astComments = _nullishCoalesce(_nullishCoalesce(_optionalChain([ast, 'optionalAccess', _205 => _205.__unpeekComments]), () => ( _optionalChain([ast, 'optionalAccess', _206 => _206.comments]))), () => ( []));
1891
+ const criticalComments = astComments.filter(
1892
+ (c) => typeof _optionalChain([c, 'optionalAccess', _207 => _207.value]) === "string" && c.value.includes(criticalAnnotation)
1893
+ );
1894
+ const criticalCommentNodes = /* @__PURE__ */ new Set();
1895
+ if (criticalComments.length > 0 && allFunctions.length > 0) {
1896
+ const stmtRanges = [];
1897
+ walk.full(ast, (n) => {
1898
+ if (n && typeof n.start === "number" && typeof n.end === "number" && n.type !== "Program" && n.type !== "BlockStatement" && n.type !== "EmptyStatement" && (n.type.endsWith("Statement") || n.type === "VariableDeclaration" || n.type === "FunctionDeclaration" || n.type === "ClassDeclaration" || n.type === "ImportDeclaration" || n.type === "ExportNamedDeclaration" || n.type === "ExportDefaultDeclaration")) {
1899
+ stmtRanges.push({ start: n.start, end: n.end });
1900
+ }
1901
+ });
1902
+ const sortedFns = [...allFunctions].sort(
1903
+ (a, b) => (_nullishCoalesce(a.node.start, () => ( 0))) - (_nullishCoalesce(b.node.start, () => ( 0)))
1904
+ );
1905
+ for (const c of criticalComments) {
1906
+ const cStart = typeof c.start === "number" ? c.start : 0;
1907
+ const cEnd = typeof c.end === "number" ? c.end : 0;
1908
+ let enclosingFnEntry;
1909
+ for (const fn of sortedFns) {
1910
+ const s = fn.node.start;
1911
+ const e = fn.node.end;
1912
+ if (typeof s === "number" && typeof e === "number" && s <= cStart && cEnd <= e) {
1913
+ enclosingFnEntry = fn;
1914
+ }
1915
+ }
1916
+ const target = sortedFns.find(
1917
+ (fn) => typeof fn.node.start === "number" && fn.node.start >= cEnd
1918
+ );
1919
+ const enclosingEnd = enclosingFnEntry ? enclosingFnEntry.node.end : Infinity;
1920
+ if (target && target.node.end <= enclosingEnd) {
1921
+ const fnStart = target.node.start;
1922
+ const fnEnd = target.node.end;
1923
+ const blockedByStmt = stmtRanges.some(
1924
+ (s) => !(s.start <= fnStart && fnEnd <= s.end) && s.end > cEnd && s.end <= target.anchorStart
1925
+ );
1926
+ if (!blockedByStmt) {
1927
+ criticalCommentNodes.add(target.node);
1928
+ continue;
1929
+ }
1930
+ }
1931
+ if (enclosingFnEntry) {
1932
+ const body = enclosingFnEntry.node.body;
1933
+ if (body && typeof body.start === "number" && cStart >= body.start) {
1934
+ const hasPriorStmtInBody = stmtRanges.some(
1935
+ (s) => s.start >= body.start && s.end <= cStart
1936
+ );
1937
+ if (!hasPriorStmtInBody) {
1938
+ criticalCommentNodes.add(enclosingFnEntry.node);
1939
+ }
1940
+ }
1941
+ }
1942
+ }
1943
+ }
1944
+ const rawCriticalInclude = _optionalChain([config, 'optionalAccess', _208 => _208.critical, 'optionalAccess', _209 => _209.include]);
1945
+ const criticalIncludeList = Array.isArray(rawCriticalInclude) ? rawCriticalInclude : rawCriticalInclude !== void 0 ? [rawCriticalInclude] : [];
1946
+ const criticalIncludeMatchers = [];
1947
+ for (const pat of criticalIncludeList) {
1948
+ if (pat instanceof RegExp) {
1949
+ criticalIncludeMatchers.push((name) => pat.test(name));
1950
+ } else if (typeof pat === "string" && pat.length > 0) {
1951
+ try {
1952
+ const re = new RegExp(pat);
1953
+ criticalIncludeMatchers.push((name) => re.test(name));
1954
+ } catch (e11) {
1955
+ criticalIncludeMatchers.push((name) => name.includes(pat));
1956
+ }
1957
+ }
1958
+ }
1959
+ const sourceMapCriticalNodes = resolveSourceMapCriticalNodes(
1960
+ allFunctions,
1961
+ originalSourceMap,
1962
+ {
1963
+ criticalAnnotation,
1964
+ criticalIncludeMatchers,
1965
+ rawIncludePatterns: criticalIncludeList
1966
+ }
1967
+ );
1968
+ const matchedCriticalNodes = /* @__PURE__ */ new Set();
1969
+ for (const fn of allFunctions) {
1970
+ if (criticalCommentNodes.has(fn.node) || sourceMapCriticalNodes.has(fn.node) || criticalIncludeMatchers.some((match) => match(fn.name))) {
1971
+ matchedCriticalNodes.add(fn.node);
1972
+ if (!trueHotNodes.has(fn.node) && !serializedWorkerNodes.has(fn.node)) {
1973
+ shallowComponentNodes.delete(fn.node);
1974
+ hotFunctionNodes.delete(fn.node);
1975
+ directHotNodes.delete(fn.node);
1976
+ hotExemptNodes.delete(fn.node);
1977
+ delete fn.node._unpeekIsComponent;
1978
+ coldForcedNodes.add(fn.node);
1979
+ }
1980
+ }
1981
+ }
907
1982
  const calleeToCallers = /* @__PURE__ */ new Map();
908
1983
  for (const [callerNode, calleeNames] of callerToCallees.entries()) {
909
1984
  for (const cName of calleeNames) {
@@ -942,56 +2017,10 @@ function analyzeAstHotPaths(ast, config) {
942
2017
  }
943
2018
  }
944
2019
  for (const node of coldForcedNodes) {
2020
+ shallowComponentNodes.delete(node);
945
2021
  hotFunctionNodes.delete(node);
946
2022
  hotExemptNodes.delete(node);
947
2023
  }
948
- const criticalAnnotation = typeof _optionalChain([config, 'optionalAccess', _158 => _158.critical, 'optionalAccess', _159 => _159.annotation]) === "string" && config.critical.annotation.length > 0 ? config.critical.annotation : "@unpeek-critical";
949
- const astComments = _nullishCoalesce(_nullishCoalesce(_optionalChain([ast, 'optionalAccess', _160 => _160.__unpeekComments]), () => ( _optionalChain([ast, 'optionalAccess', _161 => _161.comments]))), () => ( []));
950
- const criticalComments = astComments.filter(
951
- (c) => typeof _optionalChain([c, 'optionalAccess', _162 => _162.value]) === "string" && c.value.includes(criticalAnnotation)
952
- );
953
- const criticalCommentNodes = /* @__PURE__ */ new Set();
954
- if (criticalComments.length > 0 && allFunctions.length > 0) {
955
- const stmtRanges = [];
956
- walk.full(ast, (n) => {
957
- if (n && typeof n.start === "number" && typeof n.end === "number" && n.type !== "Program" && n.type !== "BlockStatement" && (n.type.endsWith("Statement") || n.type === "VariableDeclaration" || n.type === "FunctionDeclaration" || n.type === "ClassDeclaration" || n.type === "ImportDeclaration" || n.type === "ExportNamedDeclaration" || n.type === "ExportDefaultDeclaration")) {
958
- stmtRanges.push({ start: n.start, end: n.end });
959
- }
960
- });
961
- const sortedFns = [...allFunctions].sort(
962
- (a, b) => (_nullishCoalesce(a.node.start, () => ( 0))) - (_nullishCoalesce(b.node.start, () => ( 0)))
963
- );
964
- for (const c of criticalComments) {
965
- const cEnd = typeof c.end === "number" ? c.end : 0;
966
- const target = sortedFns.find(
967
- (fn) => typeof fn.node.start === "number" && fn.node.start >= cEnd
968
- );
969
- if (!target) continue;
970
- const fnStart = target.node.start;
971
- const fnEnd = target.node.end;
972
- const blockedByStmt = stmtRanges.some(
973
- (s) => !(s.start <= fnStart && fnEnd <= s.end) && s.end > cEnd && s.end <= target.anchorStart
974
- );
975
- if (!blockedByStmt) {
976
- criticalCommentNodes.add(target.node);
977
- }
978
- }
979
- }
980
- const rawCriticalInclude = _optionalChain([config, 'optionalAccess', _163 => _163.critical, 'optionalAccess', _164 => _164.include]);
981
- const criticalIncludeList = Array.isArray(rawCriticalInclude) ? rawCriticalInclude : rawCriticalInclude !== void 0 ? [rawCriticalInclude] : [];
982
- const criticalIncludeMatchers = [];
983
- for (const pat of criticalIncludeList) {
984
- if (pat instanceof RegExp) {
985
- criticalIncludeMatchers.push((name) => pat.test(name));
986
- } else if (typeof pat === "string" && pat.length > 0) {
987
- try {
988
- const re = new RegExp(pat);
989
- criticalIncludeMatchers.push((name) => re.test(name));
990
- } catch (e3) {
991
- criticalIncludeMatchers.push((name) => name.includes(pat));
992
- }
993
- }
994
- }
995
2024
  const hotFunctionsSkipped = [];
996
2025
  const coldFunctionsProtected = [];
997
2026
  for (const fn of allFunctions) {
@@ -1000,7 +2029,7 @@ function analyzeAstHotPaths(ast, config) {
1000
2029
  } else {
1001
2030
  coldFunctionNodes.add(fn.node);
1002
2031
  coldFunctionsProtected.push(fn.name);
1003
- if (criticalCommentNodes.has(fn.node) || criticalIncludeMatchers.some((match) => match(fn.name))) {
2032
+ if (matchedCriticalNodes.has(fn.node) && !trueHotNodes.has(fn.node) && !serializedWorkerNodes.has(fn.node)) {
1004
2033
  criticalFunctionNodes.add(fn.node);
1005
2034
  }
1006
2035
  }
@@ -1045,6 +2074,9 @@ function computeNormalizedIntegrityHash(source, seed = 0) {
1045
2074
  );
1046
2075
  }
1047
2076
  var NATIVE_BUILTIN_RE = /^function (\w+)\(\)\s*\{\s*\[native code\]\s*\}$/;
2077
+ var STACK_GETTER_RE = /^function (?:get )?stack\(\)\s*\{\s*\[native code\]\s*\}$/;
2078
+ var STACK_SETTER_RE = /^function (?:set )?stack\(\)\s*\{\s*\[native code\]\s*\}$/;
2079
+ var NATIVE_ANON_OR_STACK_RE = /^function (?:(?:get )?stack)?\(\)\s*\{\s*\[native code\]\s*\}$/;
1048
2080
  function hasTamperedDescriptor(obj, key) {
1049
2081
  try {
1050
2082
  let cur = _nullishCoalesce(obj, () => ( null));
@@ -1056,7 +2088,7 @@ function hasTamperedDescriptor(obj, key) {
1056
2088
  cur = Object.getPrototypeOf(cur);
1057
2089
  }
1058
2090
  return false;
1059
- } catch (e4) {
2091
+ } catch (e12) {
1060
2092
  return true;
1061
2093
  }
1062
2094
  }
@@ -1072,40 +2104,87 @@ function isNativeBuiltinSignature(fn, expectedName, expectedLength, toStr) {
1072
2104
  }
1073
2105
  const match = NATIVE_BUILTIN_RE.exec(direct);
1074
2106
  return !!match && match[1] === expectedName;
1075
- } catch (e5) {
2107
+ } catch (e13) {
1076
2108
  return false;
1077
2109
  }
1078
2110
  }
1079
- function probeThrowsCleanTypeError(fn, thisArg, args) {
1080
- const refLine = (new Error().stack || "").split("\n")[1] || "";
1081
- const refMatch = /^\s*at\s+([^\s(]+)\s*\(/.exec(refLine);
1082
- const callerMarker = refMatch ? `
1083
- at ${refMatch[1]} (` : "";
2111
+ function probeThrowsCleanTypeError(fn, thisArg, args, toStr, stackProtoDesc) {
2112
+ const errCtor = Error;
2113
+ const prevPrepare = errCtor.prepareStackTrace;
2114
+ let ok = false;
2115
+ let restoreFailed = false;
1084
2116
  try {
1085
- Reflect.apply(fn, thisArg, args);
1086
- return false;
1087
- } catch (err) {
1088
- const isTypeError = err instanceof TypeError || err !== null && typeof err === "object" && err.name === "TypeError";
1089
- if (!isTypeError) {
1090
- return false;
1091
- }
1092
- const stack = err !== null && typeof err === "object" && typeof err.stack === "string" ? err.stack : "";
1093
- if (stack && callerMarker && stack.includes(callerMarker)) {
1094
- const head = stack.slice(0, stack.indexOf(callerMarker));
1095
- if (/(?:Object|Proxy)\.apply\b/.test(head) || /\n at (?!.* \(<anonymous>\)$)/m.test(head)) {
2117
+ if (prevPrepare !== void 0) {
2118
+ if (typeof process === "undefined") {
1096
2119
  return false;
1097
2120
  }
1098
- } else if (stack && /(?:Object|Proxy)\.apply\b/.test(stack)) {
2121
+ errCtor.prepareStackTrace = void 0;
2122
+ }
2123
+ const refOwnStackDesc = Object.getOwnPropertyDescriptor(new Error(), "stack");
2124
+ const refLine = (new Error().stack || "").split("\n")[1] || "";
2125
+ const refMatch = /^\s*at\s+([^\s(]+)\s*\(/.exec(refLine);
2126
+ const callerMarker = refMatch ? `
2127
+ at ${refMatch[1]} (` : "";
2128
+ try {
2129
+ Reflect.apply(fn, thisArg, args);
1099
2130
  return false;
2131
+ } catch (err) {
2132
+ if (errCtor.prepareStackTrace !== void 0) {
2133
+ if (typeof process === "undefined") {
2134
+ return false;
2135
+ }
2136
+ errCtor.prepareStackTrace = void 0;
2137
+ }
2138
+ const isTypeError = err instanceof TypeError || err !== null && typeof err === "object" && err.name === "TypeError";
2139
+ if (!isTypeError || err === null || typeof err !== "object") {
2140
+ return false;
2141
+ }
2142
+ const ownDesc = Object.getOwnPropertyDescriptor(err, "stack");
2143
+ if (ownDesc) {
2144
+ if ("value" in ownDesc || typeof ownDesc.get !== "function" || Reflect.has(ownDesc.get, "prototype") || !_optionalChain([refOwnStackDesc, 'optionalAccess', _210 => _210.get]) || ownDesc.get.name !== "" || ownDesc.get.length !== 0) {
2145
+ return false;
2146
+ }
2147
+ const getterSrc = Reflect.apply(toStr, ownDesc.get, []);
2148
+ if (typeof getterSrc !== "string" || !NATIVE_ANON_OR_STACK_RE.test(getterSrc)) {
2149
+ return false;
2150
+ }
2151
+ }
2152
+ const stack = _optionalChain([stackProtoDesc, 'optionalAccess', _211 => _211.get]) ? Reflect.apply(stackProtoDesc.get, err, []) : _optionalChain([ownDesc, 'optionalAccess', _212 => _212.get]) ? Reflect.apply(ownDesc.get, err, []) : err.stack;
2153
+ if (typeof stack !== "string" || stack.length === 0 || !stack.includes("\n at ")) {
2154
+ return false;
2155
+ }
2156
+ if (callerMarker && stack.includes(callerMarker)) {
2157
+ const head = stack.slice(0, stack.indexOf(callerMarker));
2158
+ if (/(?:Object|Proxy)\.apply\b/.test(head) || /\n at (?!.* \(<anonymous>\)$)/m.test(head)) {
2159
+ return false;
2160
+ }
2161
+ } else if (/(?:Object|Proxy)\.apply\b/.test(stack)) {
2162
+ return false;
2163
+ }
2164
+ ok = true;
2165
+ }
2166
+ } catch (e14) {
2167
+ return false;
2168
+ } finally {
2169
+ if (prevPrepare !== void 0) {
2170
+ try {
2171
+ errCtor.prepareStackTrace = prevPrepare;
2172
+ } catch (e15) {
2173
+ restoreFailed = true;
2174
+ }
1100
2175
  }
1101
- return true;
1102
2176
  }
2177
+ return ok && !restoreFailed;
1103
2178
  }
1104
2179
  function isNativeDescriptorIntact() {
1105
2180
  if (typeof Reflect === "undefined" || typeof Reflect.apply !== "function") {
1106
2181
  return false;
1107
2182
  }
1108
- if (hasTamperedDescriptor(Function.prototype, "toString") || hasTamperedDescriptor(Function.prototype, "call") || hasTamperedDescriptor(Reflect, "apply")) {
2183
+ const errCtor = Error;
2184
+ if (hasTamperedDescriptor(Function.prototype, "toString") || hasTamperedDescriptor(Function.prototype, "call") || hasTamperedDescriptor(Reflect, "apply") || hasTamperedDescriptor(Error, "prepareStackTrace")) {
2185
+ return false;
2186
+ }
2187
+ if (typeof process === "undefined" && errCtor.prepareStackTrace !== void 0) {
1109
2188
  return false;
1110
2189
  }
1111
2190
  const toStr = Function.prototype.toString;
@@ -1114,8 +2193,36 @@ function isNativeDescriptorIntact() {
1114
2193
  if (!isNativeBuiltinSignature(reflectApply, "apply", 3, toStr) || !isNativeBuiltinSignature(toStr, "toString", 0, toStr) || !isNativeBuiltinSignature(fnCall, "call", 1, toStr)) {
1115
2194
  return false;
1116
2195
  }
1117
- if (!probeThrowsCleanTypeError(Object.getOwnPropertyDescriptor, null, []) || !probeThrowsCleanTypeError(toStr, { toString() {
1118
- } }, []) || !probeThrowsCleanTypeError(reflectApply, toStr, [null, toStr, []])) {
2196
+ const stackProtoDesc = Object.getOwnPropertyDescriptor(Error.prototype, "stack");
2197
+ if (stackProtoDesc) {
2198
+ if (typeof stackProtoDesc.get !== "function" || Reflect.has(stackProtoDesc.get, "prototype")) {
2199
+ return false;
2200
+ }
2201
+ try {
2202
+ const getSrc = reflectApply(toStr, stackProtoDesc.get, []);
2203
+ if (typeof getSrc !== "string" || !STACK_GETTER_RE.test(getSrc)) {
2204
+ return false;
2205
+ }
2206
+ if (stackProtoDesc.set !== void 0) {
2207
+ if (typeof stackProtoDesc.set !== "function" || Reflect.has(stackProtoDesc.set, "prototype")) {
2208
+ return false;
2209
+ }
2210
+ const setSrc = reflectApply(toStr, stackProtoDesc.set, []);
2211
+ if (typeof setSrc !== "string" || !STACK_SETTER_RE.test(setSrc)) {
2212
+ return false;
2213
+ }
2214
+ }
2215
+ } catch (e16) {
2216
+ return false;
2217
+ }
2218
+ if (hasTamperedDescriptor(Object.getPrototypeOf(Error.prototype), "stack")) {
2219
+ return false;
2220
+ }
2221
+ } else if (hasTamperedDescriptor(Error.prototype, "stack")) {
2222
+ return false;
2223
+ }
2224
+ if (!probeThrowsCleanTypeError(Object.getOwnPropertyDescriptor, null, [], toStr, stackProtoDesc) || !probeThrowsCleanTypeError(toStr, { toString() {
2225
+ } }, [], toStr, stackProtoDesc) || !probeThrowsCleanTypeError(reflectApply, toStr, [null, toStr, []], toStr, stackProtoDesc)) {
1119
2226
  return false;
1120
2227
  }
1121
2228
  try {
@@ -1125,7 +2232,7 @@ function isNativeDescriptorIntact() {
1125
2232
  if (toStr.call(probeFn) !== expectedProbe || fnCall.call(toStr, probeFn) !== expectedProbe) {
1126
2233
  return false;
1127
2234
  }
1128
- } catch (e6) {
2235
+ } catch (e17) {
1129
2236
  return false;
1130
2237
  }
1131
2238
  return true;
@@ -1147,7 +2254,7 @@ function verifyCodeIntegrity(fnOrSource, expectedHash, seed = 0, normalized = fa
1147
2254
  return false;
1148
2255
  }
1149
2256
  raw = Reflect.apply(toStr, fnOrSource, []);
1150
- } catch (e7) {
2257
+ } catch (e18) {
1151
2258
  return false;
1152
2259
  }
1153
2260
  } else {
@@ -1310,24 +2417,24 @@ function getLeadingNode(state, node, parentNode, isRightHand = false) {
1310
2417
  cur = cur.left;
1311
2418
  right = false;
1312
2419
  } else if (cur.type === "ConditionalExpression") {
1313
- const prec = _optionalChain([state, 'optionalAccess', _165 => _165.expressionsPrecedence, 'optionalAccess', _166 => _166[_optionalChain([cur, 'access', _167 => _167.test, 'optionalAccess', _168 => _168.type])]]);
1314
- if (prec === NEEDS_PARENTHESES || prec <= _optionalChain([state, 'optionalAccess', _169 => _169.expressionsPrecedence, 'optionalAccess', _170 => _170.ConditionalExpression])) {
2420
+ const prec = _optionalChain([state, 'optionalAccess', _213 => _213.expressionsPrecedence, 'optionalAccess', _214 => _214[_optionalChain([cur, 'access', _215 => _215.test, 'optionalAccess', _216 => _216.type])]]);
2421
+ if (prec === NEEDS_PARENTHESES || prec <= _optionalChain([state, 'optionalAccess', _217 => _217.expressionsPrecedence, 'optionalAccess', _218 => _218.ConditionalExpression])) {
1315
2422
  return null;
1316
2423
  }
1317
2424
  parent = cur;
1318
2425
  cur = cur.test;
1319
2426
  right = false;
1320
2427
  } else if (cur.type === "MemberExpression") {
1321
- const prec = _optionalChain([state, 'optionalAccess', _171 => _171.expressionsPrecedence, 'optionalAccess', _172 => _172[_optionalChain([cur, 'access', _173 => _173.object, 'optionalAccess', _174 => _174.type])]]);
1322
- if (prec === NEEDS_PARENTHESES || prec < _optionalChain([state, 'optionalAccess', _175 => _175.expressionsPrecedence, 'optionalAccess', _176 => _176.MemberExpression])) {
2428
+ const prec = _optionalChain([state, 'optionalAccess', _219 => _219.expressionsPrecedence, 'optionalAccess', _220 => _220[_optionalChain([cur, 'access', _221 => _221.object, 'optionalAccess', _222 => _222.type])]]);
2429
+ if (prec === NEEDS_PARENTHESES || prec < _optionalChain([state, 'optionalAccess', _223 => _223.expressionsPrecedence, 'optionalAccess', _224 => _224.MemberExpression])) {
1323
2430
  return null;
1324
2431
  }
1325
2432
  parent = cur;
1326
2433
  cur = cur.object;
1327
2434
  right = false;
1328
2435
  } else if (cur.type === "CallExpression") {
1329
- const prec = _optionalChain([state, 'optionalAccess', _177 => _177.expressionsPrecedence, 'optionalAccess', _178 => _178[_optionalChain([cur, 'access', _179 => _179.callee, 'optionalAccess', _180 => _180.type])]]);
1330
- if (prec === NEEDS_PARENTHESES || prec < _optionalChain([state, 'optionalAccess', _181 => _181.expressionsPrecedence, 'optionalAccess', _182 => _182.CallExpression])) {
2436
+ const prec = _optionalChain([state, 'optionalAccess', _225 => _225.expressionsPrecedence, 'optionalAccess', _226 => _226[_optionalChain([cur, 'access', _227 => _227.callee, 'optionalAccess', _228 => _228.type])]]);
2437
+ if (prec === NEEDS_PARENTHESES || prec < _optionalChain([state, 'optionalAccess', _229 => _229.expressionsPrecedence, 'optionalAccess', _230 => _230.CallExpression])) {
1331
2438
  return null;
1332
2439
  }
1333
2440
  parent = cur;
@@ -1338,8 +2445,8 @@ function getLeadingNode(state, node, parentNode, isRightHand = false) {
1338
2445
  cur = cur.expression;
1339
2446
  right = false;
1340
2447
  } else if (cur.type === "TaggedTemplateExpression") {
1341
- const prec = _optionalChain([state, 'optionalAccess', _183 => _183.expressionsPrecedence, 'optionalAccess', _184 => _184[_optionalChain([cur, 'access', _185 => _185.tag, 'optionalAccess', _186 => _186.type])]]);
1342
- if (prec === NEEDS_PARENTHESES || prec < _optionalChain([state, 'optionalAccess', _187 => _187.expressionsPrecedence, 'optionalAccess', _188 => _188.CallExpression])) {
2448
+ const prec = _optionalChain([state, 'optionalAccess', _231 => _231.expressionsPrecedence, 'optionalAccess', _232 => _232[_optionalChain([cur, 'access', _233 => _233.tag, 'optionalAccess', _234 => _234.type])]]);
2449
+ if (prec === NEEDS_PARENTHESES || prec < _optionalChain([state, 'optionalAccess', _235 => _235.expressionsPrecedence, 'optionalAccess', _236 => _236.CallExpression])) {
1343
2450
  return null;
1344
2451
  }
1345
2452
  parent = cur;
@@ -1696,7 +2803,7 @@ var compactGenerator = Object.assign({}, _astring.baseGenerator, {
1696
2803
  },
1697
2804
  ImportExpression(node, state) {
1698
2805
  state.write("import(");
1699
- if (Array.isArray(_optionalChain([node, 'access', _189 => _189.source, 'optionalAccess', _190 => _190.comments])) && node.source.comments.length > 0) {
2806
+ if (Array.isArray(_optionalChain([node, 'access', _237 => _237.source, 'optionalAccess', _238 => _238.comments])) && node.source.comments.length > 0) {
1700
2807
  for (const c of node.source.comments) {
1701
2808
  state.write(c.type === "Block" ? `/*${c.value}*/` : `//${c.value}
1702
2809
  `);
@@ -1711,7 +2818,7 @@ var compactGenerator = Object.assign({}, _astring.baseGenerator, {
1711
2818
  }
1712
2819
  });
1713
2820
  var VLQ_BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1714
- function encodeVlq(value) {
2821
+ function encodeVlq2(value) {
1715
2822
  let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
1716
2823
  let encoded = "";
1717
2824
  do {
@@ -1812,13 +2919,13 @@ function generateCompactJsWithMap(ast, fileName) {
1812
2919
  let prevGenCol = 0;
1813
2920
  const encodedSegs = [];
1814
2921
  for (const seg of segs) {
1815
- let s = encodeVlq(seg.genCol - prevGenCol) + encodeVlq(seg.srcIdx - prevSrcIdx) + encodeVlq(seg.origLine - prevOrigLine) + encodeVlq(seg.origCol - prevOrigCol);
2922
+ let s = encodeVlq2(seg.genCol - prevGenCol) + encodeVlq2(seg.srcIdx - prevSrcIdx) + encodeVlq2(seg.origLine - prevOrigLine) + encodeVlq2(seg.origCol - prevOrigCol);
1816
2923
  prevGenCol = seg.genCol;
1817
2924
  prevSrcIdx = seg.srcIdx;
1818
2925
  prevOrigLine = seg.origLine;
1819
2926
  prevOrigCol = seg.origCol;
1820
2927
  if (seg.nameIdx !== void 0) {
1821
- s += encodeVlq(seg.nameIdx - prevNameIdx);
2928
+ s += encodeVlq2(seg.nameIdx - prevNameIdx);
1822
2929
  prevNameIdx = seg.nameIdx;
1823
2930
  }
1824
2931
  encodedSegs.push(s);
@@ -1851,7 +2958,7 @@ function createDeterrentSnippet(config) {
1851
2958
  const headlessDecl = detectHeadless ? ",n=w.navigator||0" : "";
1852
2959
  const headlessCond = detectHeadless ? "||n.webdriver||/HeadlessChrome/.test(n.userAgent)" : "";
1853
2960
  const k1Mul = (seed | 1) >>> 0;
1854
- return `(function ${fnName}(w){var G=globalThis||w;if(w){var O=Object,P=O.getOwnPropertyDescriptor,RF=G.Reflect,R=RF&&RF.apply,FP=Function.prototype,SP=String.prototype,Q='__unpeek_',y=${symLit},z=y+'_s',U='__unpeek_tampered',K=Q+'seed',T=(o,k)=>{try{for(var r;o;o=O.getPrototypeOf(o))if((r=P(o,k))&&(r.set||!r.writable))return 1;}catch(e){return 1;}},D=k=>T(w,k)|T(G,k),B=(k,v,c,W)=>{W=o=>{try{if(!c||!T(o,k))o[k]=v;}catch(e){}};W(G);W(w);},s=FP.toString${headlessDecl},src='',t=+((G[z]||w[z])?.[0]==2);try{var ps,E=(f,a,b)=>{try{R(f,a,b);t=1;}catch(e){t|=e?.name!='TypeError'||/\\n at (?!.* \\(<anonymous>\\)$)/m.test(e?.stack?.split('\\n at E (')[0]);}},F=(f,n,l)=>typeof f!='function'||'prototype'in f||f.name!=n||f.length!=l||/^function (\\w+)\\(\\)\\s*\\x7b\\s*\\[native code\\]\\s*}$/.exec(R(R,null,[s,f,[]]))?.[1]!=n;E(P,null,[]);E(s,{toString(){}},[]);E(R,s,[null,s,[]]);src=R(s,${fnName},[]);t|=F(R,'apply',3)|F(s,'toString',0)|s.call(T)!==(ps=R(s,T,[]))|FP.call.call(s,T)!==ps|/\\n/.test(src)${headlessCond};}catch(e){t=1;}t|=D(y)|D(z)|D(U)|T(SP,'_u')|T(FP,'toString')|T(FP,'call')|T(RF,'apply');for(var h=2166136261,i=0;i<src.length;)h=Math.imul(h^src.charCodeAt(i++),16777619);var d=h&65535,pd=t?d^((h>>>16^23131)||1):d;B(z,[t+1,h^${seed}^t,h^${k1Mul}^t,1,d^h>>>16],t);B(y,pd,t);if(t){B(y+'_t',!0);B(Q+'delta',pd);try{SP._u=14;}catch(e){}B(K,((w[K]||${seed})^1)>>>0);B(U,!0);try{${consoleSilence}w.dispatchEvent?.(new CustomEvent('unpeek:tamper'));}catch(e){}}}})(typeof window!=='undefined'?window:typeof self<'u'?self:typeof globalThis<'u'?globalThis:0);`;
2961
+ return `(function ${fnName}(w){var G=globalThis||w;if(w){var O=Object,P=O.getOwnPropertyDescriptor,RF=G.Reflect,R=RF&&RF.apply,FP=Function.prototype,SP=String.prototype,ER=Error,EP=ER.prototype,Q='__unpeek_',y=${symLit},z=y+'_s',U='__unpeek_tampered',K=Q+'seed',ST='stack',PS='prepareStackTrace',A='\\n at ',T=(o,k)=>{try{for(var r;o;o=O.getPrototypeOf(o))if((r=P(o,k))&&(r.set||!r.writable))return 1;}catch(e){return 1;}},D=k=>T(w,k)|T(G,k),B=(k,v,c,W)=>{W=o=>{try{if(!c||!T(o,k))o[k]=v;}catch(e){}};W(G);W(w);},s=FP.toString${headlessDecl},src='',t=+((G[z]||w[z])?.[0]==2),sd=P(EP,ST),ep=ER[PS],M=/^function (?:get )?(\\w*)\\(\\)\\s*\\x7b\\s*\\[native code\\]\\s*\\}$/;try{var ps,rf=P(new ER(),ST),Z=()=>{if(ER[PS]!==void 0){if(typeof process>'u')t=1;ER[PS]=void 0;}},F=(f,n,l)=>typeof f!='function'||'prototype'in f||(l>=0&&(f.name!=n||f.length!=l))||M.exec(R(R,null,[s,f,[]]))?.[1]!=n,E=(f,a,b)=>{try{R(f,a,b);t=1;}catch(e){Z();var ed=P(e,ST),st=sd&&sd.get?R(sd.get,e,[]):ed&&ed.get?R(ed.get,e,[]):e[ST];if(ed&&(!rf||F(ed.get,'',0)))t=1;t|=e?.name!='TypeError'||!st||st.indexOf(A)<0||/(?:Object|Proxy)\\.apply\\b|\\n at (?!.* \\(<anonymous>\\)$)/m.test(st.split(A+'E (')[0]);}};Z();try{E(P,null,[]);E(s,{toString(){}},[]);E(R,s,[null,s,[]]);}finally{if(ep!==void 0)ER[PS]=ep;}src=R(s,${fnName},[]);t|=(sd&&F(sd.get,ST,-1))|F(R,'apply',3)|F(s,'toString',0)|s.call(T)!==(ps=R(s,T,[]))|FP.call.call(s,T)!==ps|/\\n/.test(src)${headlessCond};}catch(e){t=1;}t|=D(y)|D(z)|D(U)|T(SP,'_u')|T(FP,'toString')|T(FP,'call')|T(RF,'apply')|T(ER,PS)|(sd?T(O.getPrototypeOf(EP),ST):T(EP,ST));for(var h=2166136261,i=0;i<src.length;)h=Math.imul(h^src.charCodeAt(i++),16777619);var d=h&65535,pd=t?d^((h>>>16^23131)||1):d;B(z,[t+1,h^${seed}^t,h^${k1Mul}^t,1,d^h>>>16],t);B(y,pd,t);if(t){B(y+'_t',!0);B(Q+'delta',pd);try{SP._u=14;}catch(e){}B(K,((w[K]||${seed})^1)>>>0);B(U,!0);try{${consoleSilence}w.dispatchEvent?.(new CustomEvent('unpeek:tamper'));}catch(e){}}}})(typeof window!=='undefined'?window:typeof self<'u'?self:typeof globalThis<'u'?globalThis:0);`;
1855
2962
  }
1856
2963
 
1857
2964
  // src/runtime/index.ts
@@ -1870,13 +2977,15 @@ function generateRuntimeShield(config) {
1870
2977
  const computedHash = computeIntegrityHash(fnDecl, 0);
1871
2978
  const expectedHash = config.expectedIntegrityHash !== void 0 ? config.expectedIntegrityHash >>> 0 : computedHash;
1872
2979
  const expectedDelta = config.expectedDelta !== void 0 ? config.expectedDelta & 65535 : computedHash >>> 0 & 65535;
2980
+ const expectedStateHash = computedHash ^ seed | 0;
1873
2981
  const payload = {
1874
2982
  preambleCode,
1875
2983
  integrityCheckFnName,
1876
2984
  expectedHash,
1877
2985
  windowKeySymbol,
1878
2986
  expectedDelta,
1879
- stateKeySymbol: `${windowKeySymbol}_s`
2987
+ stateKeySymbol: `${windowKeySymbol}_s`,
2988
+ expectedStateHash
1880
2989
  };
1881
2990
  return payload;
1882
2991
  }
@@ -1948,10 +3057,13 @@ function deriveWasmHostParams(seed) {
1948
3057
  const rA1 = computeFnv1aHash("wasm-ra1", seed) | 1;
1949
3058
  const rA2 = computeFnv1aHash("wasm-ra2", seed) & ~1;
1950
3059
  const rA3 = computeFnv1aHash("wasm-ra3", seed) & ~1;
1951
- return { gArr, sOff, rA0, rA1, rA2, rA3 };
3060
+ const gMask = computeFnv1aHash("wasm-gmask", seed) | 1 | 0;
3061
+ const pcMask = computeFnv1aHash("wasm-pcmask", seed) | 1 | 0;
3062
+ return { gArr, sOff, rA0, rA1, rA2, rA3, gMask, pcMask };
1952
3063
  }
1953
3064
  function generateWasmKdfBinary(seed) {
1954
3065
  const { sVal, c1, c2, k0, r1, r2 } = deriveKdfParams(seed);
3066
+ const { gMask, pcMask } = deriveWasmHostParams(seed);
1955
3067
  const memBase = (seed >>> 0 & 127) * 4;
1956
3068
  const r0 = computeFnv1aHash("wasm-r0", seed) | 0;
1957
3069
  const rotAmt = (seed >>> 0) % 27 + 3;
@@ -1965,6 +3077,8 @@ function generateWasmKdfBinary(seed) {
1965
3077
  const w2 = c1 ^ (w0 + w1 | 0) | 0;
1966
3078
  const w3 = c2 - Math.imul(w1 | 1, w2 | 1) | 0;
1967
3079
  const w4 = k0 ^ rotl32(w2, 11) ^ w3 | 0;
3080
+ const w5 = gMask ^ rotl32(w3, 7) ^ w0 | 0;
3081
+ const w6 = pcMask ^ rotl32(w4, 13) ^ w1 | 0;
1968
3082
  const kdfInstructions = [
1969
3083
  65,
1970
3084
  ...encodeSignedLeb128(memA),
@@ -2071,9 +3185,68 @@ function generateWasmKdfBinary(seed) {
2071
3185
  115,
2072
3186
  // i32.xor
2073
3187
  33,
2074
- 9,
2075
- // local.set 9 (c1)
2076
- // Reconstruct k0 -> local 10
3188
+ 9,
3189
+ // local.set 9 (c1)
3190
+ // Reconstruct k0 -> local 10
3191
+ 32,
3192
+ 3,
3193
+ // local.get 3 (ptr)
3194
+ 40,
3195
+ 2,
3196
+ 16,
3197
+ // i32.load align=2 offset=16 (w4)
3198
+ 32,
3199
+ 6,
3200
+ // local.get 6 (w2)
3201
+ 65,
3202
+ 11,
3203
+ // i32.const 11
3204
+ 119,
3205
+ // i32.rotl
3206
+ 115,
3207
+ // i32.xor
3208
+ 32,
3209
+ 7,
3210
+ // local.get 7 (w3)
3211
+ 115,
3212
+ // i32.xor
3213
+ 33,
3214
+ 10,
3215
+ // local.set 10 (k0)
3216
+ // Reconstruct gMask -> local 12
3217
+ 32,
3218
+ 3,
3219
+ // local.get 3 (ptr)
3220
+ 40,
3221
+ 2,
3222
+ 20,
3223
+ // i32.load align=2 offset=20 (w5)
3224
+ 32,
3225
+ 7,
3226
+ // local.get 7 (w3)
3227
+ 65,
3228
+ 7,
3229
+ // i32.const 7
3230
+ 119,
3231
+ // i32.rotl
3232
+ 115,
3233
+ // i32.xor
3234
+ 32,
3235
+ 4,
3236
+ // local.get 4 (w0)
3237
+ 115,
3238
+ // i32.xor
3239
+ 33,
3240
+ 12,
3241
+ // local.set 12 (gMask)
3242
+ // Reconstruct pcMask -> local 13
3243
+ 32,
3244
+ 3,
3245
+ // local.get 3 (ptr)
3246
+ 40,
3247
+ 2,
3248
+ 24,
3249
+ // i32.load align=2 offset=24 (w6)
2077
3250
  32,
2078
3251
  3,
2079
3252
  // local.get 3 (ptr)
@@ -2081,25 +3254,22 @@ function generateWasmKdfBinary(seed) {
2081
3254
  2,
2082
3255
  16,
2083
3256
  // i32.load align=2 offset=16 (w4)
2084
- 32,
2085
- 6,
2086
- // local.get 6 (w2)
2087
3257
  65,
2088
- 11,
2089
- // i32.const 11
3258
+ 13,
3259
+ // i32.const 13
2090
3260
  119,
2091
3261
  // i32.rotl
2092
3262
  115,
2093
3263
  // i32.xor
2094
3264
  32,
2095
- 7,
2096
- // local.get 7 (w3)
3265
+ 5,
3266
+ // local.get 5 (w1)
2097
3267
  115,
2098
3268
  // i32.xor
2099
3269
  33,
2100
- 10,
2101
- // local.set 10 (k0)
2102
- // x = f ^ sVal ^ k0 ^ env.g(0)
3270
+ 13,
3271
+ // local.set 13 (pcMask)
3272
+ // x = f ^ sVal ^ k0 ^ (env.g(0) ^ gMask)
2103
3273
  32,
2104
3274
  0,
2105
3275
  // local.get 0 (fnId)
@@ -2119,6 +3289,11 @@ function generateWasmKdfBinary(seed) {
2119
3289
  16,
2120
3290
  0,
2121
3291
  // call 0 (env.g(0))
3292
+ 32,
3293
+ 12,
3294
+ // local.get 12 (gMask)
3295
+ 115,
3296
+ // i32.xor
2122
3297
  115,
2123
3298
  // i32.xor
2124
3299
  34,
@@ -2152,14 +3327,19 @@ function generateWasmKdfBinary(seed) {
2152
3327
  // i32.const r1
2153
3328
  119,
2154
3329
  // i32.rotl
2155
- // x = env.m(x, shieldHash)
3330
+ // x = env.m(x, shieldHash ^ pcMask)
2156
3331
  32,
2157
3332
  2,
2158
3333
  // local.get 2 (shieldHash)
3334
+ 32,
3335
+ 13,
3336
+ // local.get 13 (pcMask)
3337
+ 115,
3338
+ // i32.xor
2159
3339
  16,
2160
3340
  1,
2161
- // call 1 (env.m(x, shieldHash))
2162
- // x = imul(x ^ h ^ sVal ^ env.g(1), c2)
3341
+ // call 1 (env.m(x, maskedPc))
3342
+ // x = imul(x ^ h ^ sVal ^ (env.g(1) ^ gMask), c2)
2163
3343
  32,
2164
3344
  2,
2165
3345
  // local.get 2 (shieldHash)
@@ -2176,6 +3356,11 @@ function generateWasmKdfBinary(seed) {
2176
3356
  16,
2177
3357
  0,
2178
3358
  // call 0 (env.g(1))
3359
+ 32,
3360
+ 12,
3361
+ // local.get 12 (gMask)
3362
+ 115,
3363
+ // i32.xor
2179
3364
  115,
2180
3365
  // i32.xor
2181
3366
  32,
@@ -2312,6 +3497,11 @@ function generateWasmKdfBinary(seed) {
2312
3497
  16,
2313
3498
  0,
2314
3499
  // call 0 (env.g)
3500
+ 65,
3501
+ ...encodeSignedLeb128(gMask),
3502
+ // i32.const gMask
3503
+ 115,
3504
+ // i32.xor
2315
3505
  106,
2316
3506
  // i32.add
2317
3507
  16,
@@ -2363,7 +3553,7 @@ function generateWasmKdfBinary(seed) {
2363
3553
  11
2364
3554
  // end func
2365
3555
  ];
2366
- const kdfBody = [1, 9, 127, ...kdfInstructions];
3556
+ const kdfBody = [1, 11, 127, ...kdfInstructions];
2367
3557
  const kdfBodyWithLen = [...encodeUnsignedLeb128(kdfBody.length), ...kdfBody];
2368
3558
  const bulkBody = [1, 2, 127, ...bulkMixInstructions];
2369
3559
  const bulkBodyWithLen = [...encodeUnsignedLeb128(bulkBody.length), ...bulkBody];
@@ -2476,7 +3666,9 @@ function generateWasmKdfBinary(seed) {
2476
3666
  ...writeI32LE(w1),
2477
3667
  ...writeI32LE(w2),
2478
3668
  ...writeI32LE(w3),
2479
- ...writeI32LE(w4)
3669
+ ...writeI32LE(w4),
3670
+ ...writeI32LE(w5),
3671
+ ...writeI32LE(w6)
2480
3672
  ];
2481
3673
  const dataPayload = [
2482
3674
  1,
@@ -2509,20 +3701,22 @@ function generateWasmKdfBinary(seed) {
2509
3701
  }
2510
3702
  function fallbackKdf(fnId, callSiteSalt, shieldHash, seed) {
2511
3703
  const { sVal, c1, c2, k0, r1, r2 } = deriveKdfParams(seed);
2512
- const { gArr, sOff, rA0, rA1, rA2, rA3 } = deriveWasmHostParams(seed);
3704
+ const { gArr, sOff, rA0, rA1, rA2, rA3, gMask, pcMask } = deriveWasmHostParams(seed);
3705
+ const envG = (slot) => gArr[slot & 3] ^ gMask | 0;
2513
3706
  const envM = (acc, pc) => {
2514
3707
  const sb0 = Math.imul(167, acc & 255) + sOff & 255;
2515
3708
  const sb1 = Math.imul(167, acc >>> 8 & 255) + sOff & 255;
2516
3709
  const sb = sb0 ^ sb1 << 8;
2517
- const riv = evalRivestPoly32(acc ^ sb ^ pc | 0, rA0, rA1, rA2, rA3) | 0;
3710
+ const unmaskedPc = pc ^ pcMask | 0;
3711
+ const riv = evalRivestPoly32(acc ^ sb ^ unmaskedPc | 0, rA0, rA1, rA2, rA3) | 0;
2518
3712
  return riv ^ gArr[2] | 0;
2519
3713
  };
2520
- let x = fnId ^ sVal ^ k0 ^ gArr[0] | 0;
3714
+ let x = fnId ^ sVal ^ k0 ^ (envG(0) ^ gMask) | 0;
2521
3715
  x = x ^ x >>> 16 | 0;
2522
3716
  x = Math.imul(x, c1);
2523
3717
  x = rotl32(x ^ callSiteSalt | 0, r1);
2524
- x = envM(x, shieldHash | 0);
2525
- x = Math.imul(x ^ shieldHash ^ sVal ^ gArr[1] | 0, c2);
3718
+ x = envM(x, shieldHash ^ pcMask | 0);
3719
+ x = Math.imul(x ^ shieldHash ^ sVal ^ (envG(1) ^ gMask) | 0, c2);
2526
3720
  x = x ^ x >>> 15 | 0;
2527
3721
  x = x + rotl32(callSiteSalt ^ k0 | 0, r2) | 0;
2528
3722
  x = Math.imul(x, c1);
@@ -2532,8 +3726,8 @@ function fallbackKdf(fnId, callSiteSalt, shieldHash, seed) {
2532
3726
  function isWasmVaultAlreadyInjected(ast) {
2533
3727
  if (!ast || !Array.isArray(ast.body)) return false;
2534
3728
  return ast.body.some((stmt) => {
2535
- if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _191 => _191.declarations, 'optionalAccess', _192 => _192.some, 'call', _193 => _193(
2536
- (d) => _optionalChain([d, 'access', _194 => _194.id, 'optionalAccess', _195 => _195.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
3729
+ if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _239 => _239.declarations, 'optionalAccess', _240 => _240.some, 'call', _241 => _241(
3730
+ (d) => _optionalChain([d, 'access', _242 => _242.id, 'optionalAccess', _243 => _243.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
2537
3731
  )])) {
2538
3732
  return true;
2539
3733
  }
@@ -2546,11 +3740,11 @@ function injectWasmVault(ast, seed = 2654435769) {
2546
3740
  const wasmVarName = `_wb${suffix}`;
2547
3741
  if (isWasmVaultAlreadyInjected(ast)) {
2548
3742
  const existing = ast.body.find(
2549
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _196 => _196.declarations, 'optionalAccess', _197 => _197.some, 'call', _198 => _198(
2550
- (d) => _optionalChain([d, 'access', _199 => _199.id, 'optionalAccess', _200 => _200.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
3743
+ (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _244 => _244.declarations, 'optionalAccess', _245 => _245.some, 'call', _246 => _246(
3744
+ (d) => _optionalChain([d, 'access', _247 => _247.id, 'optionalAccess', _248 => _248.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
2551
3745
  )])
2552
3746
  );
2553
- const id = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _201 => _201.declarations, 'access', _202 => _202[0], 'optionalAccess', _203 => _203.id, 'optionalAccess', _204 => _204.name]), () => ( kdfFnName));
3747
+ const id = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _249 => _249.declarations, 'access', _250 => _250[0], 'optionalAccess', _251 => _251.id, 'optionalAccess', _252 => _252.name]), () => ( kdfFnName));
2554
3748
  return {
2555
3749
  kdfFnName: id,
2556
3750
  wasmBytes: generateWasmKdfBinary(seed),
@@ -2561,7 +3755,7 @@ function injectWasmVault(ast, seed = 2654435769) {
2561
3755
  const wasmBytes = generateWasmKdfBinary(seed);
2562
3756
  const byteArrayLiteral = Array.from(wasmBytes).join(",");
2563
3757
  const { sVal, c1, c2, k0, r1, r2 } = deriveKdfParams(seed);
2564
- const { gArr, sOff, rA0, rA1, rA2, rA3 } = deriveWasmHostParams(seed);
3758
+ const { gArr, sOff, rA0, rA1, rA2, rA3, gMask, pcMask } = deriveWasmHostParams(seed);
2565
3759
  const targets = [c1, c2, sVal, k0, r1, r2];
2566
3760
  const rivEncodedTargets = targets.map(
2567
3761
  (t, j) => invertRivestPoly32((t ^ gArr[j & 3]) >>> 0, rA0, rA1, rA2, rA3) | 0
@@ -2586,11 +3780,11 @@ function injectWasmVault(ast, seed = 2654435769) {
2586
3780
  var _tk = ['__','unp','eek_t','ampered'].join('');
2587
3781
  var _eG = function(sl) {
2588
3782
  var tp = (_G && _G[_tk] === !0) ? 0x5a5b : 0;
2589
- return (_g[sl & 3] ^ tp) | 0;
3783
+ return (_g[sl & 3] ^ ${gMask} ^ tp) | 0;
2590
3784
  };
2591
3785
  var _eM = function(acc, pc) {
2592
3786
  var sb = _sb(acc) ^ (_sb(acc >>> 8) << 8);
2593
- return (_evR((acc ^ sb ^ pc) | 0) ^ _g[2]) | 0;
3787
+ return (_evR((acc ^ sb ^ (pc ^ ${pcMask})) | 0) ^ _g[2]) | 0;
2594
3788
  };
2595
3789
  try {
2596
3790
  var ${wasmVarName} = new Uint8Array([${byteArrayLiteral}]);
@@ -2610,13 +3804,13 @@ function injectWasmVault(ast, seed = 2654435769) {
2610
3804
  }
2611
3805
  var _m = Math[_p];
2612
3806
  ${kdfFnName} = function(f, s, h) {
2613
- var _x = (f ^ _k[2] ^ _k[3] ^ _eG(0)) | 0;
3807
+ var _x = (f ^ _k[2] ^ _k[3] ^ (_eG(0) ^ ${gMask})) | 0;
2614
3808
  _x = (_x ^ (_x >>> 16)) | 0;
2615
3809
  _x = _m(_x, _k[0]);
2616
3810
  var _t0 = _x ^ s, _r1 = _k[4];
2617
3811
  _x = (_t0 << _r1) | (_t0 >>> (32 - _r1));
2618
- _x = _eM(_x, h | 0);
2619
- _x = _m(_x ^ h ^ _k[2] ^ _eG(1), _k[1]);
3812
+ _x = _eM(_x, (h ^ ${pcMask}) | 0);
3813
+ _x = _m(_x ^ h ^ _k[2] ^ (_eG(1) ^ ${gMask}), _k[1]);
2620
3814
  _x = (_x ^ (_x >>> 15)) | 0;
2621
3815
  var _u0 = s ^ _k[3], _r2 = _k[5];
2622
3816
  _x = (_x + ((_u0 << _r2) | (_u0 >>> (32 - _r2)))) | 0;
@@ -2633,7 +3827,7 @@ function injectWasmVault(ast, seed = 2654435769) {
2633
3827
  let insertIdx = 0;
2634
3828
  while (insertIdx < ast.body.length) {
2635
3829
  const stmt = ast.body[insertIdx];
2636
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _205 => _205.expression, 'optionalAccess', _206 => _206.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
3830
+ const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _253 => _253.expression, 'optionalAccess', _254 => _254.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
2637
3831
  if (isDirective || stmt.type === "ImportDeclaration") {
2638
3832
  insertIdx++;
2639
3833
  } else {
@@ -2664,7 +3858,7 @@ function isWebpackModuleMap(node) {
2664
3858
  return false;
2665
3859
  }
2666
3860
  return node.properties.some(
2667
- (p) => _optionalChain([p, 'optionalAccess', _207 => _207.type]) === "Property" && (_optionalChain([p, 'access', _208 => _208.value, 'optionalAccess', _209 => _209.type]) === "FunctionExpression" || _optionalChain([p, 'access', _210 => _210.value, 'optionalAccess', _211 => _211.type]) === "ArrowFunctionExpression")
3861
+ (p) => _optionalChain([p, 'optionalAccess', _255 => _255.type]) === "Property" && (_optionalChain([p, 'access', _256 => _256.value, 'optionalAccess', _257 => _257.type]) === "FunctionExpression" || _optionalChain([p, 'access', _258 => _258.value, 'optionalAccess', _259 => _259.type]) === "ArrowFunctionExpression")
2668
3862
  );
2669
3863
  }
2670
3864
  function exemptWebpackPushArg(arg, exemptSubtreeRoots) {
@@ -2684,9 +3878,9 @@ function exemptWebpackPushArg(arg, exemptSubtreeRoots) {
2684
3878
  exemptSubtreeRoots.add(arg);
2685
3879
  }
2686
3880
  function exemptTurbopackPropertyKeys(objNode, exemptSubtreeRoots) {
2687
- if (!Array.isArray(_optionalChain([objNode, 'optionalAccess', _212 => _212.properties]))) return;
3881
+ if (!Array.isArray(_optionalChain([objNode, 'optionalAccess', _260 => _260.properties]))) return;
2688
3882
  for (const prop of objNode.properties) {
2689
- if (_optionalChain([prop, 'optionalAccess', _213 => _213.type]) === "Property" && prop.key && typeof prop.key === "object") {
3883
+ if (_optionalChain([prop, 'optionalAccess', _261 => _261.type]) === "Property" && prop.key && typeof prop.key === "object") {
2690
3884
  exemptSubtreeRoots.add(prop.key);
2691
3885
  }
2692
3886
  }
@@ -2725,11 +3919,11 @@ function isHostMember(node, matcher) {
2725
3919
  if (node.type === "Identifier" && matchesPropName(node.name, matcher)) {
2726
3920
  return true;
2727
3921
  }
2728
- if (node.type === "MemberExpression" && (_optionalChain([node, 'access', _214 => _214.object, 'optionalAccess', _215 => _215.type]) === "Identifier" && GLOBAL_HOSTS.has(node.object.name) || _optionalChain([node, 'access', _216 => _216.object, 'optionalAccess', _217 => _217.type]) === "ThisExpression")) {
2729
- if (!node.computed && _optionalChain([node, 'access', _218 => _218.property, 'optionalAccess', _219 => _219.type]) === "Identifier") {
3922
+ if (node.type === "MemberExpression" && (_optionalChain([node, 'access', _262 => _262.object, 'optionalAccess', _263 => _263.type]) === "Identifier" && GLOBAL_HOSTS.has(node.object.name) || _optionalChain([node, 'access', _264 => _264.object, 'optionalAccess', _265 => _265.type]) === "ThisExpression")) {
3923
+ if (!node.computed && _optionalChain([node, 'access', _266 => _266.property, 'optionalAccess', _267 => _267.type]) === "Identifier") {
2730
3924
  return matchesPropName(node.property.name, matcher);
2731
3925
  }
2732
- if (node.computed && _optionalChain([node, 'access', _220 => _220.property, 'optionalAccess', _221 => _221.type]) === "Literal" && typeof node.property.value === "string") {
3926
+ if (node.computed && _optionalChain([node, 'access', _268 => _268.property, 'optionalAccess', _269 => _269.type]) === "Literal" && typeof node.property.value === "string") {
2733
3927
  return matchesPropName(node.property.value, matcher);
2734
3928
  }
2735
3929
  }
@@ -2765,7 +3959,7 @@ function classifyChunkBoundary(ast) {
2765
3959
  walk2.simple(ast, {
2766
3960
  CallExpression(node) {
2767
3961
  const callee = node.callee;
2768
- const isPushCall = _optionalChain([callee, 'optionalAccess', _222 => _222.type]) === "MemberExpression" && (!callee.computed && _optionalChain([callee, 'access', _223 => _223.property, 'optionalAccess', _224 => _224.type]) === "Identifier" && callee.property.name === "push" || callee.computed && _optionalChain([callee, 'access', _225 => _225.property, 'optionalAccess', _226 => _226.type]) === "Literal" && callee.property.value === "push");
3962
+ const isPushCall = _optionalChain([callee, 'optionalAccess', _270 => _270.type]) === "MemberExpression" && (!callee.computed && _optionalChain([callee, 'access', _271 => _271.property, 'optionalAccess', _272 => _272.type]) === "Identifier" && callee.property.name === "push" || callee.computed && _optionalChain([callee, 'access', _273 => _273.property, 'optionalAccess', _274 => _274.type]) === "Literal" && callee.property.value === "push");
2769
3963
  if (isPushCall) {
2770
3964
  if (unwrapAssignedHostMember(callee.object, "__next_f")) {
2771
3965
  hasRscFlight = true;
@@ -2805,13 +3999,13 @@ function classifyChunkBoundary(ast) {
2805
3999
  if (isHostMember(node.left, "TURBOPACK") || isHostMember(node.left, isWebpackOrRspackChunkName)) {
2806
4000
  hasEntryBootstrap = true;
2807
4001
  exemptSubtreeRoots.add(node);
2808
- } else if (_optionalChain([node, 'access', _227 => _227.left, 'optionalAccess', _228 => _228.type]) === "Identifier" && node.left.name === "__vite__mapDeps") {
4002
+ } else if (_optionalChain([node, 'access', _275 => _275.left, 'optionalAccess', _276 => _276.type]) === "Identifier" && node.left.name === "__vite__mapDeps") {
2809
4003
  hasPreloadManifest = true;
2810
4004
  exemptSubtreeRoots.add(node);
2811
4005
  }
2812
4006
  },
2813
4007
  VariableDeclarator(node) {
2814
- if (_optionalChain([node, 'access', _229 => _229.id, 'optionalAccess', _230 => _230.type]) === "Identifier") {
4008
+ if (_optionalChain([node, 'access', _277 => _277.id, 'optionalAccess', _278 => _278.type]) === "Identifier") {
2815
4009
  if (node.id.name === "__vite__mapDeps") {
2816
4010
  hasPreloadManifest = true;
2817
4011
  exemptSubtreeRoots.add(node);
@@ -2822,7 +4016,7 @@ function classifyChunkBoundary(ast) {
2822
4016
  }
2823
4017
  },
2824
4018
  FunctionDeclaration(node) {
2825
- if (_optionalChain([node, 'access', _231 => _231.id, 'optionalAccess', _232 => _232.type]) === "Identifier" && node.id.name === "__vite__mapDeps") {
4019
+ if (_optionalChain([node, 'access', _279 => _279.id, 'optionalAccess', _280 => _280.type]) === "Identifier" && node.id.name === "__vite__mapDeps") {
2826
4020
  hasPreloadManifest = true;
2827
4021
  exemptSubtreeRoots.add(node);
2828
4022
  }
@@ -2864,7 +4058,7 @@ function attachMagicComments(importExpressions, comments) {
2864
4058
  const magicComments = comments.filter((c) => MAGIC_COMMENT_RE.test(c.value));
2865
4059
  if (magicComments.length === 0) return;
2866
4060
  for (const expr of importExpressions) {
2867
- const src = _optionalChain([expr, 'optionalAccess', _233 => _233.source]);
4061
+ const src = _optionalChain([expr, 'optionalAccess', _281 => _281.source]);
2868
4062
  if (!src || typeof expr.start !== "number" || typeof src.start !== "number") {
2869
4063
  continue;
2870
4064
  }
@@ -2882,6 +4076,7 @@ function computeCallSiteSalt(seed, idx) {
2882
4076
  const [lo, hi] = computeCallSiteSalt64(seed >>> 0, idx >>> 0, seed >>> 0);
2883
4077
  return ((lo ^ hi) & 2147483647 | 1) >>> 0;
2884
4078
  }
4079
+ var NARROWED_ASYNC_BR_DECL = `var _br=(typeof window<'u'&&typeof document<'u'&&window.document===document&&document.nodeType===9&&document.scripts&&document.scripts.length>0&&document.readyState!=='complete')||(typeof self<'u'&&typeof self.importScripts==='function');`;
2885
4080
  function buildRivestDeltaExpr(seed, expectedDelta, varName = "_ed") {
2886
4081
  const s = seed >>> 0;
2887
4082
  const rA0 = computeFnv1aHash(`riv-a0:${s}`, s) | 0;
@@ -2908,7 +4103,7 @@ function createSaltedDecryptorFnAst(seed, pChars, expectedDelta, windowKeySymbol
2908
4103
  } else {
2909
4104
  const edInit = buildRivestDeltaExpr(seed, expectedDelta, "_ed");
2910
4105
  const hasWindowKey = Boolean(windowKeySymbol);
2911
- const brDecl = hasWindowKey ? `var _br=typeof window<"u"||typeof document<"u"||typeof self<"u";` : "";
4106
+ const brDecl = hasWindowKey ? NARROWED_ASYNC_BR_DECL : "";
2912
4107
  const svCheck = hasWindowKey ? `(sv===void 0?!_br:sv!==_ed)` : `(sv!==void 0&&sv!==_ed)`;
2913
4108
  fBody = `var m=[],c=Function.prototype.toString.call(f),_tk=${tkExpr};for(var h=0x811c9dc5,j=0;j<c.length;j++)h=Math.imul(h^c.charCodeAt(j),0x01000193)>>>0;var A="${safeAlpha}",P="${pChars}";${edInit}return function(i,s){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0;` + brDecl + `var sv=G&&G${propAccess}!==void 0?G${propAccess}:w&&w${propAccess}!==void 0?w${propAccess}:void 0;var sr=G&&G${stateAccess}?G${stateAccess}:w&&w${stateAccess}?w${stateAccess}:void 0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||(sr&&sr[0]===2)||((""._u||a._u||0)!==0)||${svCheck};if(!tm&&sv===_ed&&(i in m))return m[i];var d=tm?((_ed^(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1))&65535):_ed;var q=(h^(""._u||a._u||0)^d)>>>0,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 ch=p[j],k=A.indexOf(ch);o+=k<0?ch:A[(A.indexOf(P[(k-(t&65535)%92+92)%92])-(t>>>16)%92+92)%92];}if(!tm&&sv===_ed)m[i]=o;return o;};`;
2914
4109
  }
@@ -2958,8 +4153,8 @@ function encodeSaltedString(str, k) {
2958
4153
  function isAstAlreadySalted(ast) {
2959
4154
  if (!ast || !Array.isArray(ast.body)) return false;
2960
4155
  return ast.body.some((stmt) => {
2961
- if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _234 => _234.declarations, 'optionalAccess', _235 => _235.some, 'call', _236 => _236(
2962
- (d) => _optionalChain([d, 'access', _237 => _237.id, 'optionalAccess', _238 => _238.type]) === "Identifier" && typeof d.id.name === "string" && (d.id.name.startsWith("_uP") || _optionalChain([d, 'access', _239 => _239.init, 'optionalAccess', _240 => _240.type]) === "CallExpression" && _optionalChain([d, 'access', _241 => _241.init, 'access', _242 => _242.callee, 'optionalAccess', _243 => _243.type]) === "FunctionExpression" && _optionalChain([d, 'access', _244 => _244.init, 'access', _245 => _245.callee, 'optionalAccess', _246 => _246.id, 'optionalAccess', _247 => _247.name]) === "f" && _optionalChain([d, 'access', _248 => _248.init, 'access', _249 => _249.arguments, 'optionalAccess', _250 => _250[0], 'optionalAccess', _251 => _251.type]) === "ArrayExpression")
4156
+ if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _282 => _282.declarations, 'optionalAccess', _283 => _283.some, 'call', _284 => _284(
4157
+ (d) => _optionalChain([d, 'access', _285 => _285.id, 'optionalAccess', _286 => _286.type]) === "Identifier" && typeof d.id.name === "string" && (d.id.name.startsWith("_uP") || _optionalChain([d, 'access', _287 => _287.init, 'optionalAccess', _288 => _288.type]) === "CallExpression" && _optionalChain([d, 'access', _289 => _289.init, 'access', _290 => _290.callee, 'optionalAccess', _291 => _291.type]) === "FunctionExpression" && _optionalChain([d, 'access', _292 => _292.init, 'access', _293 => _293.callee, 'optionalAccess', _294 => _294.id, 'optionalAccess', _295 => _295.name]) === "f" && _optionalChain([d, 'access', _296 => _296.init, 'access', _297 => _297.arguments, 'optionalAccess', _298 => _298[0], 'optionalAccess', _299 => _299.type]) === "ArrayExpression")
2963
4158
  )])) {
2964
4159
  return true;
2965
4160
  }
@@ -2994,14 +4189,14 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
2994
4189
  shaderBuffersCount: 0
2995
4190
  };
2996
4191
  }
2997
- const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _252 => _252.vault, 'optionalAccess', _253 => _253.minStringLength]), () => ( minStringLength));
4192
+ const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _300 => _300.vault, 'optionalAccess', _301 => _301.minStringLength]), () => ( minStringLength));
2998
4193
  const activeDirectives = new Set(DIRECTIVE_STRINGS);
2999
- if (_optionalChain([config, 'optionalAccess', _254 => _254.vault, 'optionalAccess', _255 => _255.customDirectives])) {
4194
+ if (_optionalChain([config, 'optionalAccess', _302 => _302.vault, 'optionalAccess', _303 => _303.customDirectives])) {
3000
4195
  for (const dir of config.vault.customDirectives) {
3001
4196
  activeDirectives.add(dir);
3002
4197
  }
3003
4198
  }
3004
- const customReserved = _optionalChain([config, 'optionalAccess', _256 => _256.vault, 'optionalAccess', _257 => _257.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
4199
+ const customReserved = _optionalChain([config, 'optionalAccess', _304 => _304.vault, 'optionalAccess', _305 => _305.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
3005
4200
  const targetsToReplace = [];
3006
4201
  const encryptedPayloads = [];
3007
4202
  const shaderToIndex = /* @__PURE__ */ new Map();
@@ -3122,6 +4317,17 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
3122
4317
  let vaultVarName = "";
3123
4318
  let decryptFnName = "";
3124
4319
  let integrityToken = computeFnv1aHash("empty-salted", seed);
4320
+ const sym = _nullishCoalesce(windowKeySymbol, () => ( deriveWindowKeySymbol(seed)));
4321
+ let expDelta = expectedDelta;
4322
+ if (shieldCoupled && expDelta === void 0) {
4323
+ const shield = generateRuntimeShield({
4324
+ seed,
4325
+ windowKeySymbol: sym,
4326
+ deterrentMode: _nullishCoalesce(deterrentMode, () => ( "passive")),
4327
+ detectHeadless
4328
+ });
4329
+ expDelta = _nullishCoalesce(shield.expectedDelta, () => ( 0));
4330
+ }
3125
4331
  if (targetsToReplace.length > 0) {
3126
4332
  const wasmResult = injectWasmVault(ast, seed);
3127
4333
  const kdfFnName = wasmResult.kdfFnName;
@@ -3130,17 +4336,6 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
3130
4336
  const cacheVarName = `_uCache${suffix}`;
3131
4337
  const dCacheVarName = `_uDc${suffix}`;
3132
4338
  decryptFnName = `_uD${suffix}`;
3133
- const sym = _nullishCoalesce(windowKeySymbol, () => ( deriveWindowKeySymbol(seed)));
3134
- let expDelta = expectedDelta;
3135
- if (shieldCoupled && expDelta === void 0) {
3136
- const shield = generateRuntimeShield({
3137
- seed,
3138
- windowKeySymbol: sym,
3139
- deterrentMode: _nullishCoalesce(deterrentMode, () => ( "passive")),
3140
- detectHeadless
3141
- });
3142
- expDelta = _nullishCoalesce(shield.expectedDelta, () => ( 0));
3143
- }
3144
4339
  const propAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(sym) ? `.${sym}` : `[${JSON.stringify(sym)}]`;
3145
4340
  const stateSym = `${sym}_s`;
3146
4341
  const stateAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(stateSym) ? `.${stateSym}` : `[${JSON.stringify(stateSym)}]`;
@@ -3154,7 +4349,7 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
3154
4349
  } else {
3155
4350
  const edInit = buildRivestDeltaExpr(seed, (_nullishCoalesce(expDelta, () => ( 0))) & 65535, "_ed");
3156
4351
  const hasWindowKey = Boolean(sym);
3157
- const brDecl = hasWindowKey ? `var _br=typeof window<"u"||typeof document<"u"||typeof self<"u";` : "";
4352
+ const brDecl = hasWindowKey ? NARROWED_ASYNC_BR_DECL : "";
3158
4353
  const svCheck = hasWindowKey ? `(sv===void 0?!_br:sv!==_ed)` : `(sv!==void 0&&sv!==_ed)`;
3159
4354
  helperFnSnippet = `function ${decryptFnName}(i,s){var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0,_tk=${tkExpr},_dk=${dkExpr};${edInit}` + brDecl + `var sv=G&&G${propAccess}!==void 0?G${propAccess}:w&&w${propAccess}!==void 0?w${propAccess}:void 0;var sr=G&&G${stateAccess}?G${stateAccess}:w&&w${stateAccess}?w${stateAccess}:void 0;var dv=(G&&G[_dk]!=null?G[_dk]:w&&w[_dk]!=null?w[_dk]:0)|0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||(sr&&sr[0]===2)||((""._u||0)!==0)||(dv!==0)||${svCheck};if(!tm&&sv===_ed&&${cacheVarName}[i]!==void 0)return ${cacheVarName}[i];if(${dCacheVarName}===void 0){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;${dCacheVarName}=((h|0)^_ed)|0;}var effD=tm?((${dCacheVarName}^(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1))|0):${dCacheVarName};var k=${kdfFnName}(i,s,effD);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));}if(!tm&&sv===_ed)${cacheVarName}[i]=o;return o;}`;
3160
4355
  }
@@ -3223,7 +4418,10 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
3223
4418
  const shaderHelperStmt = createShaderVaultAst(
3224
4419
  shaderVarName,
3225
4420
  shaderPayloads,
3226
- seed
4421
+ seed,
4422
+ sym,
4423
+ expDelta,
4424
+ shieldCoupled
3227
4425
  );
3228
4426
  const shaderInsertIdx = findVaultInsertIndex(ast, activeDirectives);
3229
4427
  ast.body.splice(shaderInsertIdx, 0, shaderHelperStmt);
@@ -3296,7 +4494,7 @@ function isReactDomSpecialProp(val, node, parent, customReserved) {
3296
4494
  if (parent.key === node && !parent.computed) {
3297
4495
  return true;
3298
4496
  }
3299
- const keyName = _optionalChain([parent, 'access', _258 => _258.key, 'optionalAccess', _259 => _259.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _260 => _260.key, 'optionalAccess', _261 => _261.type]) === "Literal" ? String(parent.key.value) : "";
4497
+ const keyName = _optionalChain([parent, 'access', _306 => _306.key, 'optionalAccess', _307 => _307.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _308 => _308.key, 'optionalAccess', _309 => _309.type]) === "Literal" ? String(parent.key.value) : "";
3300
4498
  if (keyName && isReservedProp(keyName, customReserved)) {
3301
4499
  return true;
3302
4500
  }
@@ -3359,11 +4557,11 @@ var DEFAULT_SEMANTIC_ANCHOR_RE = /(?:\bapi\/|\bcheckout\b|\badmin\b|\bauth\b|\bt
3359
4557
  function isUiClassName(val, parent) {
3360
4558
  if (parent) {
3361
4559
  if (parent.type === "Property") {
3362
- const k = _optionalChain([parent, 'access', _262 => _262.key, 'optionalAccess', _263 => _263.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _264 => _264.key, 'optionalAccess', _265 => _265.type]) === "Literal" ? String(parent.key.value) : "";
4560
+ const k = _optionalChain([parent, 'access', _310 => _310.key, 'optionalAccess', _311 => _311.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _312 => _312.key, 'optionalAccess', _313 => _313.type]) === "Literal" ? String(parent.key.value) : "";
3363
4561
  if (k === "className" || k === "class" || k === "classList") return true;
3364
4562
  }
3365
4563
  if (parent.type === "JSXAttribute") {
3366
- const name = _optionalChain([parent, 'access', _266 => _266.name, 'optionalAccess', _267 => _267.name]);
4564
+ const name = _optionalChain([parent, 'access', _314 => _314.name, 'optionalAccess', _315 => _315.name]);
3367
4565
  if (name === "className" || name === "class") return true;
3368
4566
  }
3369
4567
  }
@@ -3385,6 +4583,7 @@ function isAdversaryDecoy(val, seed) {
3385
4583
  }
3386
4584
  function isEligibleHotLiteral(val, node, parent, ancestors, minLen, seed = 2654435769, customReserved, activeDirectives = DIRECTIVE_STRINGS, semanticAnchorPatterns, excludeUiClasses = true) {
3387
4585
  if (val.length < minLen || activeDirectives.has(val)) return false;
4586
+ if (isBinaryOrBase64Payload(val)) return false;
3388
4587
  if (isReactDomSpecialProp(val, node, parent, customReserved)) return false;
3389
4588
  if (isTailwindNoise(val)) return false;
3390
4589
  if (isSvgPathString(val, parent)) return false;
@@ -3412,11 +4611,7 @@ function isEligibleHotLiteral(val, node, parent, ancestors, minLen, seed = 26544
3412
4611
  for (let i = ancestors.length - 2; i >= 0; i--) {
3413
4612
  const a = ancestors[i];
3414
4613
  if (a.type === "FunctionDeclaration" || a.type === "FunctionExpression" || a.type === "ArrowFunctionExpression") {
3415
- if (_optionalChain([a, 'access', _268 => _268.id, 'optionalAccess', _269 => _269.name]) && /^[A-Z]/.test(a.id.name)) {
3416
- isInsideRender = true;
3417
- break;
3418
- }
3419
- if (a._unpeekIsComponent) {
4614
+ if (Boolean(a._unpeekIsComponent)) {
3420
4615
  isInsideRender = true;
3421
4616
  break;
3422
4617
  }
@@ -3449,9 +4644,20 @@ function isInsideLoopOrSerialized(ancestors) {
3449
4644
  }
3450
4645
  return false;
3451
4646
  }
4647
+ var BINARY_DATA_URI_RE = /^data:(?:application\/(?:wasm|octet-stream|pdf|zip|gzip|font-[a-z0-9-]+)|image\/|font\/|audio\/|video\/)/i;
4648
+ var PURE_BASE64_RE = /^[A-Za-z0-9+/]+={0,2}$/;
4649
+ function isBinaryOrBase64Payload(val) {
4650
+ if (val.startsWith("AGFzbQE")) return true;
4651
+ if (BINARY_DATA_URI_RE.test(val)) return true;
4652
+ if (val.length >= 4096 && !/\s/.test(val) && PURE_BASE64_RE.test(val)) {
4653
+ return true;
4654
+ }
4655
+ return false;
4656
+ }
3452
4657
  function isShaderPayload(val, node, parent, ancestors, seed, isHotExempt, customReserved) {
4658
+ if (isBinaryOrBase64Payload(val)) return false;
3453
4659
  if (isInsideLoopOrSerialized(ancestors)) return false;
3454
- if (_optionalChain([parent, 'optionalAccess', _270 => _270.type]) === "Property" && parent.key === node && !parent.computed) return false;
4660
+ if (_optionalChain([parent, 'optionalAccess', _316 => _316.type]) === "Property" && parent.key === node && !parent.computed) return false;
3455
4661
  if (isReservedProp(val, customReserved)) return false;
3456
4662
  if (isTailwindNoise(val)) return false;
3457
4663
  if (isSvgPathString(val, parent)) return false;
@@ -3468,7 +4674,7 @@ function findVaultInsertIndex(ast, activeDirectives = DIRECTIVE_STRINGS) {
3468
4674
  let insertIdx = 0;
3469
4675
  while (insertIdx < ast.body.length) {
3470
4676
  const stmt = ast.body[insertIdx];
3471
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _271 => _271.expression, 'optionalAccess', _272 => _272.type]) === "Literal" && typeof stmt.expression.value === "string" && (activeDirectives.has(stmt.expression.value) || /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim())));
4677
+ const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _317 => _317.expression, 'optionalAccess', _318 => _318.type]) === "Literal" && typeof stmt.expression.value === "string" && (activeDirectives.has(stmt.expression.value) || /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim())));
3472
4678
  if (isDirective || stmt.type === "ImportDeclaration") {
3473
4679
  insertIdx++;
3474
4680
  } else {
@@ -3479,6 +4685,7 @@ function findVaultInsertIndex(ast, activeDirectives = DIRECTIVE_STRINGS) {
3479
4685
  }
3480
4686
  function shouldEncryptString(val, minLen, parent, activeDirectives = DIRECTIVE_STRINGS, customReserved) {
3481
4687
  if (val.length < minLen || activeDirectives.has(val)) return false;
4688
+ if (isBinaryOrBase64Payload(val)) return false;
3482
4689
  if (isReservedProp(val, customReserved)) return false;
3483
4690
  if (isSvgPathString(val, parent)) return false;
3484
4691
  if (isTailwindNoise(val)) return false;
@@ -3546,9 +4753,31 @@ function uint8ArrayToBase64(bytes) {
3546
4753
  }
3547
4754
  throw new Error("No base64 encoder available in this environment");
3548
4755
  }
3549
- function createShaderVaultAst(shaderVarName, shaderPayloads, seed) {
4756
+ function createShaderVaultAst(shaderVarName, shaderPayloads, seed, windowKeySymbol, expectedDelta, shieldCoupled = false) {
3550
4757
  const sSeed = seed >>> 0;
3551
- 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);}};})`;
4758
+ let fnCode;
4759
+ let ed = 0;
4760
+ if (!shieldCoupled) {
4761
+ 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);}};})`;
4762
+ } else {
4763
+ const sym = _nullishCoalesce(windowKeySymbol, () => ( deriveWindowKeySymbol(sSeed)));
4764
+ let expDelta = expectedDelta;
4765
+ if (expDelta === void 0) {
4766
+ expDelta = _nullishCoalesce(generateRuntimeShield({
4767
+ seed: sSeed,
4768
+ windowKeySymbol: sym
4769
+ }).expectedDelta, () => ( 0));
4770
+ }
4771
+ ed = expDelta & 65535;
4772
+ const edInit = buildRivestDeltaExpr(sSeed, ed, "_ed");
4773
+ const propAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(sym) ? `.${sym}` : `[${JSON.stringify(sym)}]`;
4774
+ const stateSym = `${sym}_s`;
4775
+ const stateAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(stateSym) ? `.${stateSym}` : `[${JSON.stringify(stateSym)}]`;
4776
+ const flagSym = `${sym}_t`;
4777
+ const flagAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(flagSym) ? `.${flagSym}` : `[${JSON.stringify(flagSym)}]`;
4778
+ const tkExpr = `['__','unp','eek_t','ampered'].join('')`;
4779
+ 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;${edInit}var _tk=${tkExpr},_sc=[],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,S){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 G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof self<"u"?self:this;var w=typeof window<"u"?window:typeof self<"u"?self:0;${NARROWED_ASYNC_BR_DECL}var sv=G&&G${propAccess}!==void 0?G${propAccess}:w&&w${propAccess}!==void 0?w${propAccess}:void 0;var sr=G&&G${stateAccess}?G${stateAccess}:w&&w${stateAccess}?w${stateAccess}:void 0;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||(sr&&sr[0]===2)||((""._u||0)!==0)||(sv===void 0?!_br:sv!==_ed);if(!tm&&sv===_ed&&(i in _sc))return _sc[i];var S=(h^${sSeed}^_ed^(tm?(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1):0))>>>0;var u=b[i];x(u,i,S);try{var o=d?d.decode(u):String.fromCharCode.apply(null,u);if(!tm&&sv===_ed)_sc[i]=o;return o;}finally{x(u,i,S);}};})`;
4780
+ }
3552
4781
  const parsedProgram = acorn4.parse(fnCode, {
3553
4782
  ecmaVersion: "latest",
3554
4783
  sourceType: "script"
@@ -3556,7 +4785,7 @@ function createShaderVaultAst(shaderVarName, shaderPayloads, seed) {
3556
4785
  const firstStmt = parsedProgram.body[0];
3557
4786
  const fnAst = firstStmt.expression;
3558
4787
  const buildH = computeIntegrityHash(generateCompactJs(fnAst), 0);
3559
- const S = (buildH ^ sSeed) >>> 0;
4788
+ const S = (buildH ^ sSeed ^ (shieldCoupled ? ed : 0)) >>> 0;
3560
4789
  const textEncoder = new TextEncoder();
3561
4790
  const b64List = [];
3562
4791
  for (let idx = 0; idx < shaderPayloads.length; idx++) {
@@ -3597,24 +4826,24 @@ function findLowestCommonScope(ast, chains) {
3597
4826
  return _nullishCoalesce(lca[lca.length - 1], () => ( ast));
3598
4827
  }
3599
4828
  function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes, windowKeySymbol, expectedDelta, deterrentMode, config, shieldCoupled = true, detectHeadless = false, exemptSubtreeRoots) {
3600
- const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _273 => _273.vault, 'optionalAccess', _274 => _274.minStringLength]), () => ( minStringLength));
4829
+ const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _319 => _319.vault, 'optionalAccess', _320 => _320.minStringLength]), () => ( minStringLength));
3601
4830
  const activeDirectives = new Set(DIRECTIVE_STRINGS);
3602
- if (_optionalChain([config, 'optionalAccess', _275 => _275.vault, 'optionalAccess', _276 => _276.customDirectives])) {
4831
+ if (_optionalChain([config, 'optionalAccess', _321 => _321.vault, 'optionalAccess', _322 => _322.customDirectives])) {
3603
4832
  for (const dir of config.vault.customDirectives) {
3604
4833
  activeDirectives.add(dir);
3605
4834
  }
3606
4835
  }
3607
- const customReserved = _optionalChain([config, 'optionalAccess', _277 => _277.vault, 'optionalAccess', _278 => _278.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
3608
- const semanticPatterns = _optionalChain([config, 'optionalAccess', _279 => _279.vault, 'optionalAccess', _280 => _280.semanticAnchors, 'optionalAccess', _281 => _281.patterns, 'optionalAccess', _282 => _282.map, 'call', _283 => _283(
4836
+ const customReserved = _optionalChain([config, 'optionalAccess', _323 => _323.vault, 'optionalAccess', _324 => _324.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
4837
+ const semanticPatterns = _optionalChain([config, 'optionalAccess', _325 => _325.vault, 'optionalAccess', _326 => _326.semanticAnchors, 'optionalAccess', _327 => _327.patterns, 'optionalAccess', _328 => _328.map, 'call', _329 => _329(
3609
4838
  (p) => typeof p === "string" ? new RegExp(p) : p
3610
4839
  )]);
3611
- const excludeUi = _optionalChain([config, 'optionalAccess', _284 => _284.vault, 'optionalAccess', _285 => _285.semanticAnchors, 'optionalAccess', _286 => _286.excludeUiClasses]) !== false;
4840
+ const excludeUi = _optionalChain([config, 'optionalAccess', _330 => _330.vault, 'optionalAccess', _331 => _331.semanticAnchors, 'optionalAccess', _332 => _332.excludeUiClasses]) !== false;
3612
4841
  const suffix = (seed >>> 0 & 65535).toString(36);
3613
4842
  const decryptFnName = `_uD${suffix}`;
3614
4843
  const cacheVarName = derivePolymorphicIdent(seed, "vault");
3615
4844
  const shaderVarName = derivePolymorphicIdent(seed, "shader");
3616
4845
  const sym = _nullishCoalesce(windowKeySymbol, () => ( deriveWindowKeySymbol(seed)));
3617
- const browserOnly = _optionalChain([config, 'optionalAccess', _287 => _287.target]) === "browser";
4846
+ const browserOnly = _optionalChain([config, 'optionalAccess', _333 => _333.target]) === "browser";
3618
4847
  let expDelta = shieldCoupled ? expectedDelta : 0;
3619
4848
  if (shieldCoupled && expDelta === void 0) {
3620
4849
  const shield = generateRuntimeShield({
@@ -3626,8 +4855,8 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3626
4855
  expDelta = _nullishCoalesce(shield.expectedDelta, () => ( 0));
3627
4856
  }
3628
4857
  const alreadyVaulted = ast.body.some(
3629
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _288 => _288.declarations, 'optionalAccess', _289 => _289.some, 'call', _290 => _290(
3630
- (d) => _optionalChain([d, 'access', _291 => _291.id, 'optionalAccess', _292 => _292.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', _293 => _293.init, 'optionalAccess', _294 => _294.type]) === "CallExpression" && _optionalChain([d, 'access', _295 => _295.init, 'access', _296 => _296.callee, 'optionalAccess', _297 => _297.type]) === "FunctionExpression" && _optionalChain([d, 'access', _298 => _298.init, 'access', _299 => _299.callee, 'optionalAccess', _300 => _300.id, 'optionalAccess', _301 => _301.name]) === "f" && _optionalChain([d, 'access', _302 => _302.init, 'access', _303 => _303.arguments, 'optionalAccess', _304 => _304[0], 'optionalAccess', _305 => _305.type]) === "ArrayExpression")
4858
+ (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _334 => _334.declarations, 'optionalAccess', _335 => _335.some, 'call', _336 => _336(
4859
+ (d) => _optionalChain([d, 'access', _337 => _337.id, 'optionalAccess', _338 => _338.type]) === "Identifier" && typeof d.id.name === "string" && (d.id.name.startsWith("_uC") || d.id.name.startsWith("_uD") && !d.id.name.startsWith("_uDec") || d.id.name === decryptFnName || d.id.name === cacheVarName || _optionalChain([d, 'access', _339 => _339.init, 'optionalAccess', _340 => _340.type]) === "CallExpression" && _optionalChain([d, 'access', _341 => _341.init, 'access', _342 => _342.callee, 'optionalAccess', _343 => _343.type]) === "FunctionExpression" && _optionalChain([d, 'access', _344 => _344.init, 'access', _345 => _345.callee, 'optionalAccess', _346 => _346.id, 'optionalAccess', _347 => _347.name]) === "f" && _optionalChain([d, 'access', _348 => _348.init, 'access', _349 => _349.arguments, 'optionalAccess', _350 => _350[0], 'optionalAccess', _351 => _351.type]) === "ArrayExpression")
3631
4860
  )])
3632
4861
  );
3633
4862
  if (alreadyVaulted) {
@@ -3805,7 +5034,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3805
5034
  for (let i = 0; i < val.length; i++) {
3806
5035
  encodedStr += String.fromCharCode(val.charCodeAt(i) ^ key);
3807
5036
  }
3808
- if (_optionalChain([parent, 'optionalAccess', _306 => _306.type]) === "Property" && parent.key === node) {
5037
+ if (_optionalChain([parent, 'optionalAccess', _352 => _352.type]) === "Property" && parent.key === node) {
3809
5038
  parent.computed = true;
3810
5039
  }
3811
5040
  node.type = "CallExpression";
@@ -3832,8 +5061,8 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3832
5061
  delete node.expressions;
3833
5062
  }
3834
5063
  let insertIdx = findVaultInsertIndex(ast, activeDirectives);
3835
- const wantFragmented = Boolean(_optionalChain([config, 'optionalAccess', _307 => _307.vault, 'optionalAccess', _308 => _308.fragmented]));
3836
- let fragCount = Math.max(2, Math.min(8, Math.floor(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _309 => _309.vault, 'optionalAccess', _310 => _310.fragmentCount]), () => ( 3)))));
5064
+ const wantFragmented = Boolean(_optionalChain([config, 'optionalAccess', _353 => _353.vault, 'optionalAccess', _354 => _354.fragmented]));
5065
+ let fragCount = Math.max(2, Math.min(8, Math.floor(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _355 => _355.vault, 'optionalAccess', _356 => _356.fragmentCount]), () => ( 3)))));
3837
5066
  while (fragCount > 2 && Math.floor(uniqueStrings.length / fragCount) < 4) {
3838
5067
  fragCount--;
3839
5068
  }
@@ -3848,7 +5077,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3848
5077
  }
3849
5078
  integrityToken = computeFnv1aHash(JSON.stringify(encryptedPayloads), seed);
3850
5079
  for (const { type, node, parent, idx } of targetsToReplace) {
3851
- if (_optionalChain([parent, 'optionalAccess', _311 => _311.type]) === "Property" && parent.key === node) {
5080
+ if (_optionalChain([parent, 'optionalAccess', _357 => _357.type]) === "Property" && parent.key === node) {
3852
5081
  parent.computed = true;
3853
5082
  }
3854
5083
  if (type === "shader") {
@@ -3937,7 +5166,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3937
5166
  });
3938
5167
  }
3939
5168
  for (const { type, node, parent, idx, scopeChain } of targetsToReplace) {
3940
- if (_optionalChain([parent, 'optionalAccess', _312 => _312.type]) === "Property" && parent.key === node) {
5169
+ if (_optionalChain([parent, 'optionalAccess', _358 => _358.type]) === "Property" && parent.key === node) {
3941
5170
  parent.computed = true;
3942
5171
  }
3943
5172
  if (type === "shader") {
@@ -3975,7 +5204,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3975
5204
  ast.body.splice(insertIdx++, 0, helperStmt);
3976
5205
  } else {
3977
5206
  let blockInsertIdx = 0;
3978
- while (blockInsertIdx < lcaScope.body.length && _optionalChain([lcaScope, 'access', _313 => _313.body, 'access', _314 => _314[blockInsertIdx], 'optionalAccess', _315 => _315.type]) === "ExpressionStatement" && Boolean(_optionalChain([lcaScope, 'access', _316 => _316.body, 'access', _317 => _317[blockInsertIdx], 'optionalAccess', _318 => _318.directive]))) {
5207
+ while (blockInsertIdx < lcaScope.body.length && _optionalChain([lcaScope, 'access', _359 => _359.body, 'access', _360 => _360[blockInsertIdx], 'optionalAccess', _361 => _361.type]) === "ExpressionStatement" && Boolean(_optionalChain([lcaScope, 'access', _362 => _362.body, 'access', _363 => _363[blockInsertIdx], 'optionalAccess', _364 => _364.directive]))) {
3979
5208
  blockInsertIdx++;
3980
5209
  }
3981
5210
  lcaScope.body.splice(blockInsertIdx, 0, helperStmt);
@@ -3985,7 +5214,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3985
5214
  }
3986
5215
  if (hotTargetsToReplace.length > 0) {
3987
5216
  const alreadyHasHx = ast.body.some(
3988
- (stmt) => stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _319 => _319.id, 'optionalAccess', _320 => _320.name]) === "_hX"
5217
+ (stmt) => stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _365 => _365.id, 'optionalAccess', _366 => _366.name]) === "_hX"
3989
5218
  );
3990
5219
  if (!alreadyHasHx) {
3991
5220
  const hxAst = acorn4.parse(
@@ -4007,7 +5236,10 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
4007
5236
  const shaderHelperStmt = createShaderVaultAst(
4008
5237
  shaderVarName,
4009
5238
  shaderPayloads,
4010
- seed
5239
+ seed,
5240
+ sym,
5241
+ expDelta,
5242
+ shieldCoupled
4011
5243
  );
4012
5244
  ast.body.splice(insertIdx++, 0, shaderHelperStmt);
4013
5245
  }
@@ -4173,8 +5405,8 @@ function collectPatternTargets(pattern, out, shorthandProp) {
4173
5405
  }
4174
5406
  }
4175
5407
  function isMangleableName(origName, reservedSet = RESERVED_IDENTIFIERS, manglerConfig) {
4176
- const minLength = _nullishCoalesce(_optionalChain([manglerConfig, 'optionalAccess', _321 => _321.minLength]), () => ( 1));
4177
- return origName.length >= minLength && !reservedSet.has(origName) && !JS_KEYWORDS.has(origName) && !origName.startsWith("$") && !origName.startsWith("__") && !origName.startsWith("_u") && !origName.startsWith("_0x") && (!_optionalChain([manglerConfig, 'optionalAccess', _322 => _322.excludePrefixes]) || !manglerConfig.excludePrefixes.some((p) => origName.startsWith(p))) && (!_optionalChain([manglerConfig, 'optionalAccess', _323 => _323.excludePatterns]) || !manglerConfig.excludePatterns.some(
5408
+ const minLength = _nullishCoalesce(_optionalChain([manglerConfig, 'optionalAccess', _367 => _367.minLength]), () => ( 1));
5409
+ return origName.length >= minLength && !reservedSet.has(origName) && !JS_KEYWORDS.has(origName) && !origName.startsWith("$") && !origName.startsWith("__") && !origName.startsWith("_u") && !origName.startsWith("_0x") && (!_optionalChain([manglerConfig, 'optionalAccess', _368 => _368.excludePrefixes]) || !manglerConfig.excludePrefixes.some((p) => origName.startsWith(p))) && (!_optionalChain([manglerConfig, 'optionalAccess', _369 => _369.excludePatterns]) || !manglerConfig.excludePatterns.some(
4178
5410
  (re) => (typeof re === "string" ? new RegExp(re) : re).test(origName)
4179
5411
  ));
4180
5412
  }
@@ -4194,12 +5426,12 @@ function shuffleAlphabet(chars, seed) {
4194
5426
  }
4195
5427
  function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes, config) {
4196
5428
  const activeReserved = new Set(RESERVED_IDENTIFIERS);
4197
- if (_optionalChain([config, 'optionalAccess', _324 => _324.mangler, 'optionalAccess', _325 => _325.reservedIdentifiers])) {
5429
+ if (_optionalChain([config, 'optionalAccess', _370 => _370.mangler, 'optionalAccess', _371 => _371.reservedIdentifiers])) {
4198
5430
  for (const id of config.mangler.reservedIdentifiers) {
4199
5431
  activeReserved.add(id);
4200
5432
  }
4201
5433
  }
4202
- const manglerConfig = _optionalChain([config, 'optionalAccess', _326 => _326.mangler]);
5434
+ const manglerConfig = _optionalChain([config, 'optionalAccess', _372 => _372.mangler]);
4203
5435
  const scopeRecords = /* @__PURE__ */ new Map();
4204
5436
  const barrierOrFreeIds = /* @__PURE__ */ new Set();
4205
5437
  const renamedTargetNodes = /* @__PURE__ */ new WeakSet();
@@ -4321,17 +5553,17 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
4321
5553
  ensureScopeChain(ancestors);
4322
5554
  },
4323
5555
  ImportSpecifier(node) {
4324
- if (_optionalChain([node, 'access', _327 => _327.local, 'optionalAccess', _328 => _328.name])) barrierOrFreeIds.add(node.local.name);
5556
+ if (_optionalChain([node, 'access', _373 => _373.local, 'optionalAccess', _374 => _374.name])) barrierOrFreeIds.add(node.local.name);
4325
5557
  },
4326
5558
  ImportDefaultSpecifier(node) {
4327
- if (_optionalChain([node, 'access', _329 => _329.local, 'optionalAccess', _330 => _330.name])) barrierOrFreeIds.add(node.local.name);
5559
+ if (_optionalChain([node, 'access', _375 => _375.local, 'optionalAccess', _376 => _376.name])) barrierOrFreeIds.add(node.local.name);
4328
5560
  },
4329
5561
  ImportNamespaceSpecifier(node) {
4330
- if (_optionalChain([node, 'access', _331 => _331.local, 'optionalAccess', _332 => _332.name])) barrierOrFreeIds.add(node.local.name);
5562
+ if (_optionalChain([node, 'access', _377 => _377.local, 'optionalAccess', _378 => _378.name])) barrierOrFreeIds.add(node.local.name);
4331
5563
  },
4332
5564
  FunctionDeclaration(node, _state, ancestors) {
4333
5565
  registerFunctionParams(node, ancestors);
4334
- if (_optionalChain([node, 'access', _333 => _333.id, 'optionalAccess', _334 => _334.type]) === "Identifier") {
5566
+ if (_optionalChain([node, 'access', _379 => _379.id, 'optionalAccess', _380 => _380.type]) === "Identifier") {
4335
5567
  const parentAncestors = ancestors.slice(0, -1);
4336
5568
  const lexNode = findEnclosingLexicalNode(parentAncestors);
4337
5569
  const fnNode = _nullishCoalesce(findEnclosingFunctionNode(parentAncestors), () => ( ast));
@@ -4339,15 +5571,15 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
4339
5571
  if (lexNode === fnNode.body || fnNode === ast) {
4340
5572
  registerBarrierName(fnNode, node.id.name);
4341
5573
  }
4342
- if (!_optionalChain([scopeRecords, 'access', _335 => _335.get, 'call', _336 => _336(node), 'optionalAccess', _337 => _337.bindings, 'access', _338 => _338.has, 'call', _339 => _339(node.id.name)])) {
5574
+ if (!_optionalChain([scopeRecords, 'access', _381 => _381.get, 'call', _382 => _382(node), 'optionalAccess', _383 => _383.bindings, 'access', _384 => _384.has, 'call', _385 => _385(node.id.name)])) {
4343
5575
  registerBarrierName(node, node.id.name);
4344
5576
  }
4345
5577
  }
4346
5578
  },
4347
5579
  FunctionExpression(node, _state, ancestors) {
4348
5580
  registerFunctionParams(node, ancestors);
4349
- if (_optionalChain([node, 'access', _340 => _340.id, 'optionalAccess', _341 => _341.type]) === "Identifier") {
4350
- if (!_optionalChain([scopeRecords, 'access', _342 => _342.get, 'call', _343 => _343(node), 'optionalAccess', _344 => _344.bindings, 'access', _345 => _345.has, 'call', _346 => _346(node.id.name)])) {
5581
+ if (_optionalChain([node, 'access', _386 => _386.id, 'optionalAccess', _387 => _387.type]) === "Identifier") {
5582
+ if (!_optionalChain([scopeRecords, 'access', _388 => _388.get, 'call', _389 => _389(node), 'optionalAccess', _390 => _390.bindings, 'access', _391 => _391.has, 'call', _392 => _392(node.id.name)])) {
4351
5583
  registerBarrierName(node, node.id.name);
4352
5584
  }
4353
5585
  }
@@ -4357,7 +5589,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
4357
5589
  },
4358
5590
  ClassDeclaration(node, _state, ancestors) {
4359
5591
  ensureScopeChain(ancestors);
4360
- if (_optionalChain([node, 'access', _347 => _347.id, 'optionalAccess', _348 => _348.type]) === "Identifier") {
5592
+ if (_optionalChain([node, 'access', _393 => _393.id, 'optionalAccess', _394 => _394.type]) === "Identifier") {
4361
5593
  const parentAncestors = ancestors.slice(0, -1);
4362
5594
  const lexNode = findEnclosingLexicalNode(parentAncestors);
4363
5595
  registerBarrierName(lexNode, node.id.name);
@@ -4366,7 +5598,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
4366
5598
  },
4367
5599
  ClassExpression(node, _state, ancestors) {
4368
5600
  ensureScopeChain(ancestors);
4369
- if (_optionalChain([node, 'access', _349 => _349.id, 'optionalAccess', _350 => _350.type]) === "Identifier") {
5601
+ if (_optionalChain([node, 'access', _395 => _395.id, 'optionalAccess', _396 => _396.type]) === "Identifier") {
4370
5602
  registerBarrierName(node, node.id.name);
4371
5603
  }
4372
5604
  },
@@ -4405,7 +5637,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
4405
5637
  if (ancestors[i] === fnScope) break;
4406
5638
  if (ancestors[i].type === "CatchClause") {
4407
5639
  const catchScope = scopeRecords.get(ancestors[i]);
4408
- if (_optionalChain([catchScope, 'optionalAccess', _351 => _351.bindings, 'access', _352 => _352.has, 'call', _353 => _353(origName)])) {
5640
+ if (_optionalChain([catchScope, 'optionalAccess', _397 => _397.bindings, 'access', _398 => _398.has, 'call', _399 => _399(origName)])) {
4409
5641
  registerBarrierName(ancestors[i], origName);
4410
5642
  registerBarrierName(fnScope, origName);
4411
5643
  }
@@ -5068,14 +6300,14 @@ function makeSafeNumericParam(name) {
5068
6300
  function buildLiveVariables4(seed, fnIndex, paramNode, isArrowFn = false, ctxOpts) {
5069
6301
  const candidates = [];
5070
6302
  const seenNames = /* @__PURE__ */ new Set();
5071
- const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _354 => _354.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
6303
+ const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _400 => _400.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
5072
6304
  for (const name of names) {
5073
6305
  if (name && name !== "arguments" && name !== "eval" && !seenNames.has(name)) {
5074
6306
  seenNames.add(name);
5075
6307
  candidates.push(makeSafeNumericParam(name));
5076
6308
  }
5077
6309
  }
5078
- if (_optionalChain([ctxOpts, 'optionalAccess', _355 => _355.aliasIdentA]) && _optionalChain([ctxOpts, 'optionalAccess', _356 => _356.aliasIdentB])) {
6310
+ if (_optionalChain([ctxOpts, 'optionalAccess', _401 => _401.aliasIdentA]) && _optionalChain([ctxOpts, 'optionalAccess', _402 => _402.aliasIdentB])) {
5079
6311
  const slot0 = fnIndex + 0 & 3;
5080
6312
  const slot1 = fnIndex + 1 & 3;
5081
6313
  candidates.push(makeBinary("|", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slot0)), makeLiteral(0)));
@@ -5120,20 +6352,150 @@ function buildLiveVariables4(seed, fnIndex, paramNode, isArrowFn = false, ctxOpt
5120
6352
  return [candidates[0], candidates[1], candidates[2], candidates[3]];
5121
6353
  }
5122
6354
  var QNR_RESIDUE_FAMILIES = [
5123
- { add: 1, mask: 3, target: 3 },
5124
- { add: 3, mask: 7, target: 6 },
5125
- { add: 5, mask: 7, target: 3 },
5126
- { add: 7, mask: 15, target: 13 }
6355
+ // LHS in {1, 2}: > 2 is false; ((v ^ (v >> 1)) & 1) === 1
6356
+ { add: 1, mask: 3, target: 3, outBoundOp: ">", outBoundVal: 2, bitKind: "xor1", expectedBit: 1 },
6357
+ // LHS in {3, 4, 7}: < 3 is false; ((v | (v >> 2)) & 1) === 1
6358
+ { add: 3, mask: 7, target: 6, outBoundOp: "<", outBoundVal: 3, bitKind: "or2", expectedBit: 1 },
6359
+ // LHS in {1, 5, 6}: > 6 is false; ((v ^ (v >> 1)) & 1) === 1
6360
+ { add: 5, mask: 7, target: 3, outBoundOp: ">", outBoundVal: 6, bitKind: "xor1", expectedBit: 1 },
6361
+ // LHS in {0, 7, 8, 11}: > 11 is false; ((v ^ (v >> 1)) & 1) === 0
6362
+ { add: 7, mask: 15, target: 13, outBoundOp: ">", outBoundVal: 11, bitKind: "xor1", expectedBit: 0 }
5127
6363
  ];
6364
+ function makeTypeofGlobalLen() {
6365
+ return {
6366
+ type: "MemberExpression",
6367
+ computed: false,
6368
+ object: makeUnary("typeof", { type: "Identifier", name: "globalThis" }),
6369
+ property: { type: "Identifier", name: "length" }
6370
+ };
6371
+ }
6372
+ function makePropAccess(objExpr, propName) {
6373
+ if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(propName)) {
6374
+ return {
6375
+ type: "MemberExpression",
6376
+ computed: false,
6377
+ object: objExpr,
6378
+ property: { type: "Identifier", name: propName }
6379
+ };
6380
+ }
6381
+ return {
6382
+ type: "MemberExpression",
6383
+ computed: true,
6384
+ object: objExpr,
6385
+ property: makeLiteral(propName)
6386
+ };
6387
+ }
6388
+ function buildQnrBitExpr(qnrValRef, bitKind) {
6389
+ const shiftAmt = bitKind === "xor1" ? 1 : 2;
6390
+ const combOp = bitKind === "xor1" ? "^" : "|";
6391
+ return makeBinary(
6392
+ "&",
6393
+ makeBinary(
6394
+ combOp,
6395
+ cloneNode(qnrValRef),
6396
+ makeBinary(">>", cloneNode(qnrValRef), makeLiteral(shiftAmt))
6397
+ ),
6398
+ makeLiteral(1)
6399
+ );
6400
+ }
5128
6401
  function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArrowFn = false, ctxOpts) {
5129
- const domain = _nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _357 => _357.returnDomain]), () => ( "object"));
6402
+ const domain = _nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _403 => _403.returnDomain]), () => ( "object"));
5130
6403
  const [x1, x2, x3, x4] = buildLiveVariables4(seed, fnIndex, paramNode, isArrowFn, ctxOpts);
5131
6404
  const mba4 = buildMba4Ast(seed, fnIndex, x1, x2, x3, x4);
5132
6405
  const qnrFamilyIdx = ((seed ^ Math.imul(fnIndex + 1, 2654435761)) >>> 0) % QNR_RESIDUE_FAMILIES.length;
5133
6406
  const qnrFamily = QNR_RESIDUE_FAMILIES[qnrFamilyIdx];
6407
+ const slotA = fnIndex + (seed & 3) & 3;
6408
+ const slotB = slotA + 1 + (seed >>> 2 & 1) & 3;
6409
+ const hasAlias = Boolean(_optionalChain([ctxOpts, 'optionalAccess', _404 => _404.aliasIdentA]));
6410
+ const aliasReadIdent = _nullishCoalesce(_nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _405 => _405.aliasIdentB]), () => ( _optionalChain([ctxOpts, 'optionalAccess', _406 => _406.aliasIdentA]))), () => ( ""));
5134
6411
  let qnrLeft;
6412
+ let qnrValForForm0;
5135
6413
  let zRefForDecoy;
5136
- if (_optionalChain([ctxOpts, 'optionalAccess', _358 => _358.scratchVarIdent])) {
6414
+ let aliasInvZero = null;
6415
+ if (_optionalChain([ctxOpts, 'optionalAccess', _407 => _407.mxIdent]) && _optionalChain([ctxOpts, 'optionalAccess', _408 => _408.scratchVarIdent]) && hasAlias) {
6416
+ const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
6417
+ const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _409 => _409.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
6418
+ const uniqueNames = [];
6419
+ for (const n of names) {
6420
+ if (n && n !== "arguments" && n !== "eval" && !uniqueNames.includes(n)) {
6421
+ uniqueNames.push(n);
6422
+ }
6423
+ }
6424
+ const arg0 = uniqueNames.length >= 1 ? makeSafeNumericParam(uniqueNames[0]) : !isArrowFn ? {
6425
+ type: "MemberExpression",
6426
+ computed: false,
6427
+ object: { type: "Identifier", name: "arguments" },
6428
+ property: { type: "Identifier", name: "length" }
6429
+ } : makeTypeofGlobalLen();
6430
+ const arg1 = uniqueNames.length >= 2 ? makeSafeNumericParam(uniqueNames[1]) : uniqueNames.length === 1 && !isArrowFn ? {
6431
+ type: "MemberExpression",
6432
+ computed: false,
6433
+ object: { type: "Identifier", name: "arguments" },
6434
+ property: { type: "Identifier", name: "length" }
6435
+ } : makeTypeofGlobalLen();
6436
+ const a0 = mixSeed32(seed, fnIndex * 13 + 3);
6437
+ const a1 = mixSeed32(seed, fnIndex * 13 + 5) | 1;
6438
+ const a2 = mixSeed32(seed, fnIndex * 13 + 7) & ~1;
6439
+ const a3 = mixSeed32(seed, fnIndex * 13 + 9) & ~1;
6440
+ const maskConst = mixSeed32(seed, fnIndex + 97) | 1;
6441
+ const r0 = mixSeed32(seed, fnIndex * 17 + 1);
6442
+ const r1 = mixSeed32(seed, fnIndex * 17 + 3) | 1;
6443
+ const seqExprs = [
6444
+ {
6445
+ type: "AssignmentExpression",
6446
+ operator: "=",
6447
+ left: cloneNode(scratchId),
6448
+ right: {
6449
+ type: "CallExpression",
6450
+ callee: { type: "Identifier", name: ctxOpts.mxIdent },
6451
+ arguments: [
6452
+ arg0,
6453
+ arg1,
6454
+ makeLiteral(slotA),
6455
+ makeLiteral(slotB),
6456
+ makeInt32Literal(maskConst),
6457
+ makeInt32Literal(a0),
6458
+ makeInt32Literal(a1),
6459
+ makeInt32Literal(a2),
6460
+ makeInt32Literal(a3)
6461
+ ],
6462
+ optional: false
6463
+ }
6464
+ },
6465
+ {
6466
+ type: "AssignmentExpression",
6467
+ operator: "=",
6468
+ left: cloneNode(scratchId),
6469
+ right: makeBinary(
6470
+ "|",
6471
+ makeBinary("+", makeInt32Literal(r0), makeImul(cloneNode(scratchId), makeInt32Literal(r1))),
6472
+ makeLiteral(0)
6473
+ )
6474
+ }
6475
+ ];
6476
+ const qnrCore = makeBinary(
6477
+ "&",
6478
+ makeBinary("+", makeImul(cloneNode(scratchId), cloneNode(scratchId)), makeLiteral(qnrFamily.add)),
6479
+ makeLiteral(qnrFamily.mask)
6480
+ );
6481
+ qnrLeft = {
6482
+ type: "SequenceExpression",
6483
+ expressions: [...seqExprs, qnrCore]
6484
+ };
6485
+ qnrValForForm0 = {
6486
+ type: "SequenceExpression",
6487
+ expressions: [
6488
+ {
6489
+ type: "AssignmentExpression",
6490
+ operator: "=",
6491
+ left: cloneNode(scratchId),
6492
+ right: cloneNode(qnrCore)
6493
+ },
6494
+ buildQnrBitExpr(scratchId, qnrFamily.bitKind)
6495
+ ]
6496
+ };
6497
+ zRefForDecoy = cloneNode(scratchId);
6498
+ } else if (_optionalChain([ctxOpts, 'optionalAccess', _410 => _410.scratchVarIdent])) {
5137
6499
  const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
5138
6500
  const rivestOnScratch = buildRivestPermAst(seed, fnIndex, scratchId);
5139
6501
  const seqExprs = [
@@ -5158,43 +6520,62 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
5158
6520
  right: buildSboxMixAst(ctxOpts.sboxIdent, ctxOpts.scratchVarIdent)
5159
6521
  });
5160
6522
  }
5161
- if (ctxOpts.aliasIdentA) {
5162
- const aliasSlot = fnIndex + (seed & 3) & 3;
5163
- const aliasMem = makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(aliasSlot));
6523
+ if (hasAlias) {
6524
+ const aliasWriteMemA = makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slotA));
6525
+ const maskConst = mixSeed32(seed, fnIndex + 97) | 1;
6526
+ const updateMask = makeBinary(
6527
+ "^",
6528
+ makeBinary("<<", cloneNode(scratchId), makeLiteral(3)),
6529
+ makeInt32Literal(maskConst)
6530
+ );
5164
6531
  seqExprs.push({
5165
6532
  type: "AssignmentExpression",
5166
6533
  operator: "=",
5167
- left: cloneNode(aliasMem),
5168
- right: makeBinary(
5169
- "|",
5170
- makeBinary(
5171
- "^",
5172
- cloneNode(aliasMem),
5173
- makeBinary("&", cloneNode(scratchId), makeLiteral(0))
5174
- ),
5175
- makeLiteral(0)
5176
- )
6534
+ left: cloneNode(aliasWriteMemA),
6535
+ right: makeBinary("|", makeBinary("^", cloneNode(aliasWriteMemA), cloneNode(updateMask)), makeLiteral(0))
5177
6536
  });
6537
+ aliasInvZero = makeBinary(
6538
+ "^",
6539
+ makeBinary("|", makeBinary("^", cloneNode(aliasWriteMemA), cloneNode(updateMask)), makeLiteral(0)),
6540
+ {
6541
+ type: "AssignmentExpression",
6542
+ operator: "=",
6543
+ left: cloneNode(aliasWriteMemA),
6544
+ right: makeBinary("|", makeBinary("^", cloneNode(aliasWriteMemA), cloneNode(updateMask)), makeLiteral(0))
6545
+ }
6546
+ );
5178
6547
  }
5179
- seqExprs.push(
5180
- makeBinary(
5181
- "&",
5182
- makeBinary("+", makeImul(cloneNode(scratchId), cloneNode(scratchId)), makeLiteral(qnrFamily.add)),
5183
- makeLiteral(qnrFamily.mask)
5184
- )
6548
+ const qnrCore = makeBinary(
6549
+ "&",
6550
+ makeBinary("+", makeImul(cloneNode(scratchId), cloneNode(scratchId)), makeLiteral(qnrFamily.add)),
6551
+ makeLiteral(qnrFamily.mask)
5185
6552
  );
5186
6553
  qnrLeft = {
5187
6554
  type: "SequenceExpression",
5188
- expressions: seqExprs
6555
+ expressions: [...seqExprs, qnrCore]
6556
+ };
6557
+ qnrValForForm0 = {
6558
+ type: "SequenceExpression",
6559
+ expressions: [
6560
+ {
6561
+ type: "AssignmentExpression",
6562
+ operator: "=",
6563
+ left: cloneNode(scratchId),
6564
+ right: cloneNode(qnrCore)
6565
+ },
6566
+ buildQnrBitExpr(scratchId, qnrFamily.bitKind)
6567
+ ]
5189
6568
  };
5190
6569
  zRefForDecoy = cloneNode(scratchId);
5191
6570
  } else {
5192
6571
  const zExpr = buildRivestPermAst(seed, fnIndex, mba4);
5193
- qnrLeft = makeBinary(
6572
+ const qnrCore = makeBinary(
5194
6573
  "&",
5195
6574
  makeBinary("+", makeImul(cloneNode(zExpr), cloneNode(zExpr)), makeLiteral(qnrFamily.add)),
5196
6575
  makeLiteral(qnrFamily.mask)
5197
6576
  );
6577
+ qnrLeft = qnrCore;
6578
+ qnrValForForm0 = buildQnrBitExpr(qnrCore, qnrFamily.bitKind);
5198
6579
  zRefForDecoy = zExpr;
5199
6580
  }
5200
6581
  const consequent = createContextualDecoyConsequent(
@@ -5204,14 +6585,94 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
5204
6585
  decoyIdent,
5205
6586
  zRefForDecoy
5206
6587
  );
6588
+ const hasShieldCoupling = Boolean(_optionalChain([ctxOpts, 'optionalAccess', _411 => _411.shieldCoupled]) && _optionalChain([ctxOpts, 'optionalAccess', _412 => _412.windowKeySymbol]));
6589
+ const predForm = fnIndex + (hasShieldCoupling ? 1 : seed >>> 2 & 3) & 3;
6590
+ let testExpr;
6591
+ if (predForm === 0) {
6592
+ let pathACore = qnrValForForm0;
6593
+ if (aliasInvZero) {
6594
+ pathACore = makeBinary("^", aliasInvZero, qnrValForForm0);
6595
+ }
6596
+ if (hasAlias) {
6597
+ pathACore = makeBinary(
6598
+ "^",
6599
+ pathACore,
6600
+ makeBinary("&", makeMemberIndex(aliasReadIdent, makeLiteral(slotB)), makeLiteral(1))
6601
+ );
6602
+ }
6603
+ const pathA = _optionalChain([ctxOpts, 'optionalAccess', _413 => _413.scratchVarIdent]) ? {
6604
+ type: "SequenceExpression",
6605
+ expressions: [...qnrLeft.expressions.slice(0, -1), pathACore]
6606
+ } : pathACore;
6607
+ const pathB = hasAlias ? makeBinary(
6608
+ "^",
6609
+ makeLiteral(qnrFamily.expectedBit),
6610
+ makeBinary("&", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slotB)), makeLiteral(1))
6611
+ ) : makeLiteral(qnrFamily.expectedBit);
6612
+ testExpr = makeBinary("!==", makeBinary("^", pathA, pathB), makeLiteral(0));
6613
+ } else if (predForm === 1) {
6614
+ const qnrLhs = aliasInvZero ? makeBinary("+", qnrLeft, makeBinary("&", aliasInvZero, makeLiteral(1))) : qnrLeft;
6615
+ const qnrFail = makeBinary(qnrFamily.outBoundOp, qnrLhs, makeLiteral(qnrFamily.outBoundVal));
6616
+ const hasGlobal = makeBinary(
6617
+ "<",
6618
+ makeUnary("typeof", { type: "Identifier", name: "globalThis" }),
6619
+ makeLiteral("u")
6620
+ );
6621
+ const tamperCheck = hasShieldCoupling ? {
6622
+ type: "LogicalExpression",
6623
+ operator: "&&",
6624
+ left: hasGlobal,
6625
+ right: {
6626
+ type: "LogicalExpression",
6627
+ operator: "&&",
6628
+ left: makePropAccess({ type: "Identifier", name: "globalThis" }, `${ctxOpts.windowKeySymbol}_s`),
6629
+ right: makeBinary(
6630
+ "===",
6631
+ {
6632
+ type: "MemberExpression",
6633
+ computed: true,
6634
+ object: makePropAccess({ type: "Identifier", name: "globalThis" }, `${ctxOpts.windowKeySymbol}_s`),
6635
+ property: makeLiteral(0)
6636
+ },
6637
+ makeLiteral(2)
6638
+ )
6639
+ }
6640
+ } : {
6641
+ type: "LogicalExpression",
6642
+ operator: "&&",
6643
+ left: hasGlobal,
6644
+ right: makeBinary(
6645
+ "===",
6646
+ makePropAccess({ type: "Identifier", name: "globalThis" }, "__unpeek_tampered"),
6647
+ makeUnary("!", makeLiteral(0))
6648
+ )
6649
+ };
6650
+ testExpr = {
6651
+ type: "LogicalExpression",
6652
+ operator: "||",
6653
+ left: qnrFail,
6654
+ right: tamperCheck
6655
+ };
6656
+ } else if (predForm === 2) {
6657
+ const slotReadB = hasAlias ? makeBinary("&", makeMemberIndex(aliasReadIdent, makeLiteral(slotB)), makeLiteral(7)) : makeBinary("&", makeTypeofGlobalLen(), makeLiteral(7));
6658
+ const slotWriteB = hasAlias ? makeBinary("&", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slotB)), makeLiteral(7)) : makeBinary("&", makeTypeofGlobalLen(), makeLiteral(7));
6659
+ let lhsExpr = makeBinary("+", qnrLeft, slotReadB);
6660
+ if (aliasInvZero) {
6661
+ lhsExpr = makeBinary("+", lhsExpr, makeBinary("&", aliasInvZero, makeLiteral(3)));
6662
+ }
6663
+ const rhsExpr = makeBinary("+", makeLiteral(qnrFamily.outBoundVal), slotWriteB);
6664
+ testExpr = makeBinary(qnrFamily.outBoundOp, lhsExpr, rhsExpr);
6665
+ } else {
6666
+ const tagLhs = hasAlias ? makeBinary("&", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slotB)), makeLiteral(240)) : makeBinary("&", makeBinary("<<", makeTypeofGlobalLen(), makeLiteral(4)), makeLiteral(240));
6667
+ const tagRhsBase = hasAlias ? makeBinary("&", makeMemberIndex(aliasReadIdent, makeLiteral(slotB)), makeLiteral(240)) : makeBinary("&", makeBinary("<<", makeTypeofGlobalLen(), makeLiteral(4)), makeLiteral(240));
6668
+ const tagRhs = aliasInvZero ? makeBinary("^", tagRhsBase, makeBinary("&", aliasInvZero, makeLiteral(15))) : tagRhsBase;
6669
+ const lhsExpr = makeBinary("|", makeBinary("^", qnrLeft, tagLhs), makeLiteral(0));
6670
+ const rhsExpr = makeBinary("|", makeBinary("^", makeLiteral(qnrFamily.target), tagRhs), makeLiteral(0));
6671
+ testExpr = makeBinary("===", lhsExpr, rhsExpr);
6672
+ }
5207
6673
  return {
5208
6674
  type: "IfStatement",
5209
- test: {
5210
- type: "BinaryExpression",
5211
- operator: "===",
5212
- left: qnrLeft,
5213
- right: makeLiteral(qnrFamily.target)
5214
- },
6675
+ test: testExpr,
5215
6676
  consequent,
5216
6677
  alternate: null
5217
6678
  };
@@ -5263,14 +6724,14 @@ function inferFunctionReturnDomain(fnNode) {
5263
6724
  }
5264
6725
  }
5265
6726
  scanStmts(fnNode.body);
5266
- if (!hasReturnArg && _optionalChain([fnNode, 'access', _359 => _359.body, 'optionalAccess', _360 => _360.type]) === "BlockStatement") return "void";
6727
+ if (!hasReturnArg && _optionalChain([fnNode, 'access', _414 => _414.body, 'optionalAccess', _415 => _415.type]) === "BlockStatement") return "void";
5267
6728
  if (seenObject) return "object";
5268
6729
  if (seenBoolean && !seenNumber && !seenString) return "boolean";
5269
6730
  if (seenNumber && !seenBoolean && !seenString) return "number";
5270
6731
  if (seenString && !seenNumber && !seenBoolean) return "string";
5271
6732
  return "object";
5272
6733
  }
5273
- function createSboxAndAliasDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scratchVarIdent, seed) {
6734
+ function createSboxAndAliasDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scratchVarIdent, seed, mxIdent) {
5274
6735
  const sboxInit = acorn5.parseExpressionAt(
5275
6736
  `(function(){var a=[],i,s=${seed | 0},j,t;for(i=0;i<256;i++)a[i]=i;for(i=255;i>0;i--){s=(Math.imul(s,1664525)+1013904223)|0;j=(s>>>0)%(i+1);t=a[i];a[i]=a[j];a[j]=t;}return a;})()`,
5276
6737
  0,
@@ -5282,48 +6743,188 @@ function createSboxAndAliasDeclarations(sboxIdent, aliasIdentA, aliasIdentB, scr
5282
6743
  mixSeed32(seed, 107),
5283
6744
  mixSeed32(seed, 109)
5284
6745
  ];
6746
+ const declarations = [
6747
+ {
6748
+ type: "VariableDeclarator",
6749
+ id: { type: "Identifier", name: sboxIdent },
6750
+ init: sboxInit
6751
+ },
6752
+ {
6753
+ type: "VariableDeclarator",
6754
+ id: { type: "Identifier", name: aliasIdentA },
6755
+ init: {
6756
+ type: "ArrayExpression",
6757
+ elements: stateVals.map((v) => makeInt32Literal(v))
6758
+ }
6759
+ },
6760
+ {
6761
+ type: "VariableDeclarator",
6762
+ id: { type: "Identifier", name: aliasIdentB },
6763
+ init: { type: "Identifier", name: aliasIdentA }
6764
+ },
6765
+ {
6766
+ type: "VariableDeclarator",
6767
+ id: { type: "Identifier", name: scratchVarIdent },
6768
+ init: makeLiteral(0)
6769
+ }
6770
+ ];
6771
+ if (mxIdent) {
6772
+ const mbaAst = buildMba4Ast(
6773
+ seed,
6774
+ 0,
6775
+ { type: "Identifier", name: "$u" },
6776
+ { type: "Identifier", name: "$v" },
6777
+ { type: "Identifier", name: "$p" },
6778
+ { type: "Identifier", name: "$q" }
6779
+ );
6780
+ const mxFn = {
6781
+ type: "FunctionExpression",
6782
+ id: null,
6783
+ params: [
6784
+ { type: "Identifier", name: "$a" },
6785
+ { type: "Identifier", name: "$b" },
6786
+ { type: "Identifier", name: "$c" },
6787
+ { type: "Identifier", name: "$d" },
6788
+ { type: "Identifier", name: "$e" },
6789
+ { type: "Identifier", name: "$f" },
6790
+ { type: "Identifier", name: "$g" },
6791
+ { type: "Identifier", name: "$h" },
6792
+ { type: "Identifier", name: "$i" }
6793
+ ],
6794
+ body: {
6795
+ type: "BlockStatement",
6796
+ body: [
6797
+ {
6798
+ type: "VariableDeclaration",
6799
+ kind: "var",
6800
+ declarations: [
6801
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$u" }, init: makeBinary("|", { type: "Identifier", name: "$a" }, makeLiteral(0)) },
6802
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$v" }, init: makeBinary("|", { type: "Identifier", name: "$b" }, makeLiteral(0)) },
6803
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$p" }, init: makeBinary("|", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }), makeLiteral(0)) },
6804
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$q" }, init: makeBinary("|", makeMemberIndex(aliasIdentB, { type: "Identifier", name: "$d" }), makeLiteral(0)) },
6805
+ { type: "VariableDeclarator", id: { type: "Identifier", name: "$z" }, init: mbaAst }
6806
+ ]
6807
+ },
6808
+ {
6809
+ type: "ExpressionStatement",
6810
+ expression: {
6811
+ type: "AssignmentExpression",
6812
+ operator: "=",
6813
+ left: { type: "Identifier", name: "$z" },
6814
+ right: makeBinary(
6815
+ "|",
6816
+ makeBinary(
6817
+ "+",
6818
+ { type: "Identifier", name: "$f" },
6819
+ makeImul(
6820
+ { type: "Identifier", name: "$z" },
6821
+ makeBinary(
6822
+ "+",
6823
+ { type: "Identifier", name: "$g" },
6824
+ makeImul(
6825
+ { type: "Identifier", name: "$z" },
6826
+ makeBinary(
6827
+ "+",
6828
+ { type: "Identifier", name: "$h" },
6829
+ makeImul({ type: "Identifier", name: "$z" }, { type: "Identifier", name: "$i" })
6830
+ )
6831
+ )
6832
+ )
6833
+ )
6834
+ ),
6835
+ makeLiteral(0)
6836
+ )
6837
+ }
6838
+ },
6839
+ {
6840
+ type: "ExpressionStatement",
6841
+ expression: {
6842
+ type: "AssignmentExpression",
6843
+ operator: "=",
6844
+ left: { type: "Identifier", name: "$z" },
6845
+ right: buildSboxMixAst(sboxIdent, "$z")
6846
+ }
6847
+ },
6848
+ {
6849
+ type: "VariableDeclaration",
6850
+ kind: "var",
6851
+ declarations: [
6852
+ {
6853
+ type: "VariableDeclarator",
6854
+ id: { type: "Identifier", name: "$m" },
6855
+ init: makeBinary("^", makeBinary("<<", { type: "Identifier", name: "$z" }, makeLiteral(3)), { type: "Identifier", name: "$e" })
6856
+ }
6857
+ ]
6858
+ },
6859
+ {
6860
+ type: "ExpressionStatement",
6861
+ expression: {
6862
+ type: "AssignmentExpression",
6863
+ operator: "=",
6864
+ left: makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }),
6865
+ right: makeBinary("|", makeBinary("^", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }), { type: "Identifier", name: "$m" }), makeLiteral(0))
6866
+ }
6867
+ },
6868
+ {
6869
+ type: "VariableDeclaration",
6870
+ kind: "var",
6871
+ declarations: [
6872
+ {
6873
+ type: "VariableDeclarator",
6874
+ id: { type: "Identifier", name: "$w" },
6875
+ init: makeBinary(
6876
+ "^",
6877
+ makeBinary("|", makeBinary("^", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }), { type: "Identifier", name: "$m" }), makeLiteral(0)),
6878
+ {
6879
+ type: "AssignmentExpression",
6880
+ operator: "=",
6881
+ left: makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }),
6882
+ right: makeBinary("|", makeBinary("^", makeMemberIndex(aliasIdentA, { type: "Identifier", name: "$c" }), { type: "Identifier", name: "$m" }), makeLiteral(0))
6883
+ }
6884
+ )
6885
+ }
6886
+ ]
6887
+ },
6888
+ {
6889
+ type: "ReturnStatement",
6890
+ argument: {
6891
+ type: "AssignmentExpression",
6892
+ operator: "=",
6893
+ left: { type: "Identifier", name: scratchVarIdent },
6894
+ right: makeBinary("|", makeBinary("^", { type: "Identifier", name: "$z" }, { type: "Identifier", name: "$w" }), makeLiteral(0))
6895
+ }
6896
+ }
6897
+ ]
6898
+ },
6899
+ generator: false,
6900
+ async: false,
6901
+ expression: false
6902
+ };
6903
+ declarations.push({
6904
+ type: "VariableDeclarator",
6905
+ id: { type: "Identifier", name: mxIdent },
6906
+ init: mxFn
6907
+ });
6908
+ }
5285
6909
  return {
5286
6910
  type: "VariableDeclaration",
5287
6911
  kind: "var",
5288
- declarations: [
5289
- {
5290
- type: "VariableDeclarator",
5291
- id: { type: "Identifier", name: sboxIdent },
5292
- init: sboxInit
5293
- },
5294
- {
5295
- type: "VariableDeclarator",
5296
- id: { type: "Identifier", name: aliasIdentA },
5297
- init: {
5298
- type: "ArrayExpression",
5299
- elements: stateVals.map((v) => makeInt32Literal(v))
5300
- }
5301
- },
5302
- {
5303
- type: "VariableDeclarator",
5304
- id: { type: "Identifier", name: aliasIdentB },
5305
- init: { type: "Identifier", name: aliasIdentA }
5306
- },
5307
- {
5308
- type: "VariableDeclarator",
5309
- id: { type: "Identifier", name: scratchVarIdent },
5310
- init: makeLiteral(0)
5311
- }
5312
- ]
6912
+ declarations
5313
6913
  };
5314
6914
  }
5315
6915
  var MAX_COLD_GUARDS_PER_CHUNK = 12;
5316
- function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExemptNodes) {
5317
- const decoyIdent = "_d";
6916
+ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExemptNodes, windowKeySymbol, expectedDelta, shieldCoupled = false) {
5318
6917
  const sfx = (seed >>> 0).toString(36).slice(0, 4);
6918
+ const decoyIdent = `_uDec${sfx}`;
5319
6919
  const sboxIdent = `_uSb${sfx}`;
5320
6920
  const aliasIdentA = `_uAl${sfx}`;
5321
6921
  const aliasIdentB = `_uAm${sfx}`;
5322
6922
  const scratchVarIdent = `_uZt${sfx}`;
6923
+ const mxIdent = `_uMx${sfx}`;
5323
6924
  if (Array.isArray(ast.body)) {
5324
6925
  const alreadyGuarded = ast.body.some(
5325
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _361 => _361.declarations, 'optionalAccess', _362 => _362.some, 'call', _363 => _363(
5326
- (d) => _optionalChain([d, 'access', _364 => _364.id, 'optionalAccess', _365 => _365.type]) === "Identifier" && (d.id.name === decoyIdent || d.id.name === sboxIdent)
6926
+ (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _416 => _416.declarations, 'optionalAccess', _417 => _417.some, 'call', _418 => _418(
6927
+ (d) => _optionalChain([d, 'access', _419 => _419.id, 'optionalAccess', _420 => _420.type]) === "Identifier" && (d.id.name === decoyIdent || d.id.name === sboxIdent || d.id.name === mxIdent)
5327
6928
  )])
5328
6929
  );
5329
6930
  if (alreadyGuarded) return 0;
@@ -5332,14 +6933,14 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
5332
6933
  function maybeInjectGuard(node) {
5333
6934
  if (guardedCount >= MAX_COLD_GUARDS_PER_CHUNK) return;
5334
6935
  if (!coldFunctionNodes.has(node)) return;
5335
- if (_optionalChain([hotExemptNodes, 'optionalAccess', _366 => _366.has, 'call', _367 => _367(node)]) || node._unpeekSerialized) return;
6936
+ if (_optionalChain([hotExemptNodes, 'optionalAccess', _421 => _421.has, 'call', _422 => _422(node)]) || node._unpeekSerialized) return;
5336
6937
  if (node._unpeekVirtualized === true) return;
5337
6938
  if (!node.body || node.body.type !== "BlockStatement") return;
5338
6939
  const paramNames = [];
5339
6940
  for (const p of node.params || []) {
5340
6941
  extractParamNames(p, paramNames);
5341
6942
  }
5342
- const firstParam = _optionalChain([node, 'access', _368 => _368.params, 'optionalAccess', _369 => _369[0]]);
6943
+ const firstParam = _optionalChain([node, 'access', _423 => _423.params, 'optionalAccess', _424 => _424[0]]);
5343
6944
  const isArrow = node.type === "ArrowFunctionExpression";
5344
6945
  const returnDomain = inferFunctionReturnDomain(node);
5345
6946
  const guardStmt = createSotaMbaPredicate(
@@ -5354,7 +6955,11 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
5354
6955
  aliasIdentA,
5355
6956
  aliasIdentB,
5356
6957
  scratchVarIdent,
5357
- returnDomain
6958
+ mxIdent,
6959
+ returnDomain,
6960
+ windowKeySymbol,
6961
+ expectedDelta,
6962
+ shieldCoupled
5358
6963
  }
5359
6964
  );
5360
6965
  guardedCount++;
@@ -5384,13 +6989,19 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
5384
6989
  aliasIdentA,
5385
6990
  aliasIdentB,
5386
6991
  scratchVarIdent,
5387
- seed
6992
+ seed,
6993
+ mxIdent
5388
6994
  );
5389
6995
  if (hotExemptNodes) {
5390
6996
  hotExemptNodes.add(sharedDecoyDecl);
5391
6997
  hotExemptNodes.add(sboxAliasDecl);
6998
+ for (const decl of sboxAliasDecl.declarations || []) {
6999
+ if (_optionalChain([decl, 'access', _425 => _425.init, 'optionalAccess', _426 => _426.type]) === "FunctionExpression") {
7000
+ hotExemptNodes.add(decl.init);
7001
+ }
7002
+ }
5392
7003
  for (const decl of sharedDecoyDecl.declarations || []) {
5393
- if (_optionalChain([decl, 'access', _370 => _370.init, 'optionalAccess', _371 => _371.type]) === "ArrayExpression" && decl.init.elements) {
7004
+ if (_optionalChain([decl, 'access', _427 => _427.init, 'optionalAccess', _428 => _428.type]) === "ArrayExpression" && decl.init.elements) {
5394
7005
  for (const el of decl.init.elements) {
5395
7006
  if (el) hotExemptNodes.add(el);
5396
7007
  }
@@ -5400,7 +7011,7 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
5400
7011
  let insertIdx = 0;
5401
7012
  while (insertIdx < ast.body.length) {
5402
7013
  const stmt = ast.body[insertIdx];
5403
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _372 => _372.expression, 'optionalAccess', _373 => _373.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
7014
+ const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _429 => _429.expression, 'optionalAccess', _430 => _430.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
5404
7015
  if (isDirective || stmt.type === "ImportDeclaration") {
5405
7016
  insertIdx++;
5406
7017
  } else {
@@ -5487,7 +7098,7 @@ function mixOpSeed(seed, salt) {
5487
7098
  h ^= h >>> 13;
5488
7099
  return h | 0;
5489
7100
  }
5490
- function encryptBytecodeStream(plainBytecode, fnSalt, vmKey, stateSlots, accSlots) {
7101
+ function encryptBytecodeStream(plainBytecode, fnSalt, vmKey, stateSlots, accSlots, jumpTargets) {
5491
7102
  const len = plainBytecode.length;
5492
7103
  const enc = new Array(len);
5493
7104
  const stateBefore = new Array(len + 1);
@@ -5518,14 +7129,14 @@ function encryptBytecodeStream(plainBytecode, fnSalt, vmKey, stateSlots, accSlot
5518
7129
  accBefore[len] = ac;
5519
7130
  if (stateSlots) {
5520
7131
  for (const slot of stateSlots) {
5521
- const targetPc = plainBytecode[slot - 1];
7132
+ const targetPc = _nullishCoalesce(_optionalChain([jumpTargets, 'optionalAccess', _431 => _431.get, 'call', _432 => _432(slot - 1)]), () => ( plainBytecode[slot - 1]));
5522
7133
  const sBefore = _nullishCoalesce(stAtSlot.get(slot), () => ( 0));
5523
7134
  enc[slot] = stateBefore[targetPc] ^ sBefore | 0;
5524
7135
  }
5525
7136
  }
5526
7137
  if (accSlots) {
5527
7138
  for (const slot of accSlots) {
5528
- const targetPc = plainBytecode[slot - 2];
7139
+ const targetPc = _nullishCoalesce(_optionalChain([jumpTargets, 'optionalAccess', _433 => _433.get, 'call', _434 => _434(slot - 2)]), () => ( plainBytecode[slot - 2]));
5529
7140
  const aBefore = _nullishCoalesce(acAtSlot.get(slot), () => ( 0));
5530
7141
  enc[slot] = accBefore[targetPc] ^ aBefore | 0;
5531
7142
  }
@@ -5550,43 +7161,39 @@ function generateOpcodeMap(seed, count = OPCODE_COUNT) {
5550
7161
  }
5551
7162
  return pool.slice(0, count);
5552
7163
  }
5553
- function computeHandlerDelta(op) {
5554
- const delta = (op + 1) * 7 & 31;
5555
- return delta === 0 ? 7 : delta;
7164
+ function computeHandlerBias(seed, op) {
7165
+ const mixed = Math.abs(mixOpSeed(seed, op * 19 + 7)) % 31;
7166
+ return mixed + 1;
5556
7167
  }
5557
- function makeHandlerMbaOffsetExpr(seed, op, deltaOp) {
7168
+ function makeHandlerMbaOffsetExpr(seed, op, bias) {
5558
7169
  const variant = Math.abs(mixOpSeed(seed, op * 11 + 3)) % 4;
5559
7170
  const c1 = mixOpSeed(seed, op * 11 + 5);
5560
7171
  const c2 = mixOpSeed(seed, op * 11 + 7);
5561
7172
  if (variant === 0) {
5562
- const cSum = c1 + c2 - deltaOp | 0;
7173
+ const cSum = c1 + c2 - bias | 0;
5563
7174
  return `(((((($f.ac|${c1})+($f.ac&${c1}))|0)|((($f.p^${c2})+(($f.p&${c2})<<1))|0))+((((($f.ac|${c1})+($f.ac&${c1}))|0)&((($f.p^${c2})+(($f.p&${c2})<<1))|0))))-(((((($f.ac^$f.p)+(($f.ac&$f.p)<<1))|0)|${cSum})+((((($f.ac^$f.p)+(($f.ac&$f.p)<<1))|0)&${cSum})))|0))|0`;
5564
7175
  }
5565
7176
  if (variant === 1) {
5566
- const cSum = c1 + c2 + deltaOp | 0;
7177
+ const cSum = c1 + c2 + bias | 0;
5567
7178
  return `((((($f.ac|$f.p)<<1)-($f.ac^$f.p))+${cSum})-((($f.ac^${c1})+(($f.ac&${c1})<<1))+(($f.p|${c2})+($f.p&${c2}))))|0`;
5568
7179
  }
5569
7180
  if (variant === 2) {
5570
- const cFold2 = 1 + deltaOp - c1 - c2 | 0;
7181
+ const cFold2 = 1 + bias - c1 - c2 | 0;
5571
7182
  return `(((~$f.ac|${c1})+(~$f.ac&${c1}))+(($f.ac|$f.p)-(~$f.ac&$f.p))+(($f.p&${c2})+(~$f.p&${c2}))+${cFold2})|0`;
5572
7183
  }
5573
- const cFold = c1 - deltaOp | 0;
7184
+ const cFold = c1 - bias | 0;
5574
7185
  return `((((($f.ac|$f.p)-(~$f.ac&$f.p))|${c1})+((($f.ac|$f.p)-(~$f.ac&$f.p))&${c1}))-(((($f.ac&${c2})+($f.ac&~${c2}))^${cFold})+(((($f.ac&${c2})+($f.ac&~${c2}))&${cFold})<<1)))|0`;
5575
7186
  }
5576
7187
  function wrapHandlerWithMba(seed, op, coreBody, isTerminal = false) {
5577
- const deltaOp = computeHandlerDelta(op);
5578
- const zExpr = makeHandlerMbaOffsetExpr(seed, op, deltaOp);
7188
+ const bias = computeHandlerBias(seed, op);
7189
+ const zExpr = makeHandlerMbaOffsetExpr(seed, op, bias);
5579
7190
  const shape = Math.abs(mixOpSeed(seed, op * 17 + 1)) % 3;
5580
7191
  const zVar = shape === 0 ? "$z0" : shape === 1 ? "$m0" : "$k0";
5581
7192
  const tail = isTerminal ? "return void 0;" : shape === 0 ? "return $step($f);" : shape === 1 ? "var $nx=$step($f);return $nx;" : "return $f.d?void 0:$step($f);";
5582
- const balancedOffset = `(${zVar}-${deltaOp})`;
5583
- const adjustedBody = coreBody.replace(/\$Z/g, balancedOffset);
5584
- if (coreBody.includes("$Z")) {
5585
- return `function($f){var ${zVar}=${zExpr};${adjustedBody}${tail}}`;
5586
- }
5587
- return `function($f){var ${zVar}=${zExpr};$f.r=($f.r+${balancedOffset})|0;${adjustedBody}${tail}}`;
7193
+ const adjustedBody = coreBody.replace(/\$Z/g, zVar).replace(/\$B/g, String(bias));
7194
+ return `function($f){var ${zVar}=${zExpr};${adjustedBody}${tail}}`;
5588
7195
  }
5589
- function createInterpreterSource(vmHelperName, opMap, seed = 2654435769, windowKeySymbol, expectedDelta) {
7196
+ function createInterpreterSource(vmHelperName, opMap, seed = 2654435769, windowKeySymbol, expectedDelta, expectedStateHash) {
5590
7197
  const opCount = opMap.length;
5591
7198
  const slotMap = shuffleRange(opCount, (seed ^ 1367130551) >>> 0);
5592
7199
  const pairOrder = shuffleRange(opCount, (seed ^ 1013904242) >>> 0);
@@ -5601,52 +7208,52 @@ function createInterpreterSource(vmHelperName, opMap, seed = 2654435769, windowK
5601
7208
  const andImpl = Math.abs(mixOpSeed(seed, OP_AND)) % 2 === 0 ? "~(~$a|~$b)" : "$a&$b";
5602
7209
  const orImpl = Math.abs(mixOpSeed(seed, OP_OR)) % 2 === 0 ? "(($a^$b)+($a&$b))|0" : "$a|$b";
5603
7210
  const coreHandlers = {
5604
- [OP_LDC]: { body: "$f.q[($f.r++)+$Z]=$f.k[$rd($f)];" },
5605
- [OP_LDV]: { body: "$f.q[($f.r++)+$Z]=$f.s[$rd($f)];" },
5606
- [OP_STV]: { body: "$f.s[$rd($f)]=$f.q[(--$f.r)+$Z];" },
5607
- [OP_LDG]: { body: "$f.q[($f.r++)+$Z]=$G[$f.k[$rd($f)]];" },
5608
- [OP_GETP]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a[$b];" },
5609
- [OP_SETP]: { body: "var $v=$f.q[--$f.r],$b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=($a[$b]=$v);" },
5610
- [OP_CALL]: { body: "var $n=$rd($f)+$Z,$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);" },
5611
- [OP_MCALL]: { body: "var $n=$rd($f)+$Z,$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);" },
5612
- [OP_ADD]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a+$b;" },
5613
- [OP_SUB]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a-$b;" },
5614
- [OP_MUL]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a*$b;" },
5615
- [OP_XOR]: { body: `var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=${xorImpl};` },
5616
- [OP_AND]: { body: `var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=${andImpl};` },
5617
- [OP_OR]: { body: `var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=${orImpl};` },
5618
- [OP_SEQ]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a===$b;" },
5619
- [OP_LT]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a<$b;" },
5620
- [OP_NOT]: { body: "$f.q[($f.r-1)+$Z]=!$f.q[$f.r-1];" },
5621
- [OP_JMP]: { body: "var $j=$rd($f)+$Z,$ts=$f.c[$f.p++]^$f.st,$ta=$f.c[$f.p++]^$f.ac;$f.p=$j;$f.st=$ts;$f.ac=$ta;" },
5622
- [OP_JZ]: { body: "var $j=$rd($f)+$Z,$ts=$f.c[$f.p++]^$f.st,$ta=$f.c[$f.p++]^$f.ac;if(!$f.q[--$f.r]){$f.p=$j;$f.st=$ts;$f.ac=$ta;}" },
5623
- [OP_RET]: { body: "$f.d=1;$f.v=$f.q[(--$f.r)+$Z];", terminal: true },
5624
- [OP_THROW]: { body: "throw $f.q[(--$f.r)+$Z];" },
7211
+ [OP_LDC]: { body: "$f.q[$f.r++]=$f.k[($rd($f)-$Z)&0xffff];" },
7212
+ [OP_LDV]: { body: "$f.q[$f.r++]=$f.s[($rd($f)-$Z)&0xffff];" },
7213
+ [OP_STV]: { body: "$f.s[($rd($f)-$Z)&0xffff]=$f.q[--$f.r];" },
7214
+ [OP_LDG]: { body: "$f.q[$f.r++]=$G[$f.k[($rd($f)-$Z)&0xffff]];" },
7215
+ [OP_GETP]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a[$b];$f.r=($f.r-$B)|0;" },
7216
+ [OP_SETP]: { body: "$f.r=($f.r+$Z)|0;var $v=$f.q[($f.r-=1)-$B],$b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=($a[$b]=$v);$f.r=($f.r-$B)|0;" },
7217
+ [OP_CALL]: { body: "var $n=($rd($f)-$Z)&0xffff,$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);" },
7218
+ [OP_MCALL]: { body: "var $n=($rd($f)-$Z)&0xffff,$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);" },
7219
+ [OP_ADD]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a+$b;$f.r=($f.r-$B)|0;" },
7220
+ [OP_SUB]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a-$b;$f.r=($f.r-$B)|0;" },
7221
+ [OP_MUL]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a*$b;$f.r=($f.r-$B)|0;" },
7222
+ [OP_XOR]: { body: `$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=${xorImpl};$f.r=($f.r-$B)|0;` },
7223
+ [OP_AND]: { body: `$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=${andImpl};$f.r=($f.r-$B)|0;` },
7224
+ [OP_OR]: { body: `$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=${orImpl};$f.r=($f.r-$B)|0;` },
7225
+ [OP_SEQ]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a===$b;$f.r=($f.r-$B)|0;" },
7226
+ [OP_LT]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a<$b;$f.r=($f.r-$B)|0;" },
7227
+ [OP_NOT]: { body: "$f.r=($f.r+$Z)|0;$f.q[$f.r-(1+$B)]=!$f.q[$f.r-(1+$B)];$f.r=($f.r-$B)|0;" },
7228
+ [OP_JMP]: { body: "var $j=($rd($f)-$Z)&0xffff,$ts=$f.c[$f.p++]^$f.st,$ta=$f.c[$f.p++]^$f.ac;$f.p=$j;$f.st=$ts;$f.ac=$ta;" },
7229
+ [OP_JZ]: { body: "var $j=($rd($f)-$Z)&0xffff,$ts=$f.c[$f.p++]^$f.st,$ta=$f.c[$f.p++]^$f.ac;if(!$f.q[--$f.r]){$f.p=$j;$f.st=$ts;$f.ac=$ta;}" },
7230
+ [OP_RET]: { body: "$f.r=($f.r+$Z)|0;$f.d=1;$f.v=$f.q[($f.r-=1)-$B];$f.r=($f.r-$B)|0;", terminal: true },
7231
+ [OP_THROW]: { body: "$f.r=($f.r+$Z)|0;var $tv=$f.q[($f.r-=1)-$B];$f.r=($f.r-$B)|0;throw $tv;" },
5625
7232
  [OP_AWAIT]: {
5626
- body: "var $v=$f.q[(--$f.r)+$Z];$f.d=2;$f.v=Promise.resolve($v).then(function($w){$f.d=0;$f.q[$f.r++]=$w;return $x($f);},function($e){if($f.e.length>0){var $ex=$f.e.pop();$f.d=0;$f.r=$ex.r;$f.q[$f.r++]=$e;$f.p=$ex.p;$f.st=$ex.s;$f.ac=$ex.a;return $x($f);}throw $e;});",
7233
+ body: "$f.r=($f.r+$Z)|0;var $v=$f.q[($f.r-=1)-$B];$f.r=($f.r-$B)|0;$f.d=2;$f.v=Promise.resolve($v).then(function($w){$f.d=0;$f.q[$f.r++]=$w;return $x($f);},function($e){if($f.e.length>0){var $ex=$f.e.pop();$f.d=0;$f.r=$ex.r;$f.q[$f.r++]=$e;$f.p=$ex.p;$f.st=$ex.s;$f.ac=$ex.a;return $x($f);}throw $e;});",
5627
7234
  terminal: true
5628
7235
  },
5629
- [OP_OBJ]: { body: "var $n=$rd($f)+$Z,$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;" },
5630
- [OP_ARR]: { body: "var $n=$rd($f)+$Z,$a=[];for(var $i=$n-1;$i>=0;$i--)$a[$i]=$f.q[--$f.r];$f.q[$f.r++]=$a;" },
5631
- [OP_LDU]: { body: "$f.q[($f.r++)+$Z]=$f.u[$rd($f)][0]();" },
5632
- [OP_STU]: { body: "$f.u[$rd($f)][1]($f.q[(--$f.r)+$Z]);" },
5633
- [OP_DIV]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a/$b;" },
5634
- [OP_MOD]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a%$b;" },
5635
- [OP_SHL]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a<<$b;" },
5636
- [OP_SHR]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a>>$b;" },
5637
- [OP_USHR]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a>>>$b;" },
5638
- [OP_POW]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a**$b;" },
5639
- [OP_EQ]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a==$b;" },
5640
- [OP_TYPEOF]: { body: "$f.q[($f.r-1)+$Z]=typeof $f.q[$f.r-1];" },
5641
- [OP_IN]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a in $b;" },
5642
- [OP_INSTOF]: { body: "var $b=$f.q[--$f.r],$a=$f.q[(--$f.r)+$Z];$f.q[$f.r++]=$a instanceof $b;" },
5643
- [OP_NEW]: { body: "var $n=$rd($f)+$Z,$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++]=new $fn(...$g);" },
5644
- [OP_THIS]: { body: "$f.q[($f.r++)+$Z]=$f.t;" },
5645
- [OP_POP]: { body: "--$f.r;$f.r+=$Z;" },
5646
- [OP_TRY]: { body: "var $cp=$rd($f)+$Z,$cs=$f.c[$f.p++]^$f.st,$ca=$f.c[$f.p++]^$f.ac;$f.e.push({p:$cp,r:$f.r,s:$cs,a:$ca});" },
5647
- [OP_ENDTRY]: { body: "$f.e.pop();$f.r+=$Z;" },
5648
- [OP_NULLISH]: { body: "var $v=$f.q[($f.r-1)+$Z];$f.q[$f.r-1]=($v===null||$v===void 0);" },
5649
- [OP_DUP]: { body: "var $top=$f.q[($f.r-1)+$Z];$f.q[$f.r++]=$top;" }
7236
+ [OP_OBJ]: { body: "var $n=($rd($f)-$Z)&0xffff,$o={},$e=[];for(var $i=0;$i<$n;$i++){var $v=$f.q[--$f.r],$ky=$f.q[--$f.r];$e.push([$ky,$v]);}for(var $i=$e.length-1;$i>=0;$i--){$o[$e[$i][0]]=$e[$i][1];}$f.q[$f.r++]=$o;" },
7237
+ [OP_ARR]: { body: "var $n=($rd($f)-$Z)&0xffff,$a=[];for(var $i=$n-1;$i>=0;$i--)$a[$i]=$f.q[--$f.r];$f.q[$f.r++]=$a;" },
7238
+ [OP_LDU]: { body: "$f.q[$f.r++]=$f.u[($rd($f)-$Z)&0xffff][0]();" },
7239
+ [OP_STU]: { body: "$f.u[($rd($f)-$Z)&0xffff][1]($f.q[--$f.r]);" },
7240
+ [OP_DIV]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a/$b;$f.r=($f.r-$B)|0;" },
7241
+ [OP_MOD]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a%$b;$f.r=($f.r-$B)|0;" },
7242
+ [OP_SHL]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a<<$b;$f.r=($f.r-$B)|0;" },
7243
+ [OP_SHR]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a>>$b;$f.r=($f.r-$B)|0;" },
7244
+ [OP_USHR]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a>>>$b;$f.r=($f.r-$B)|0;" },
7245
+ [OP_POW]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a**$b;$f.r=($f.r-$B)|0;" },
7246
+ [OP_EQ]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a==$b;$f.r=($f.r-$B)|0;" },
7247
+ [OP_TYPEOF]: { body: "$f.r=($f.r+$Z)|0;$f.q[$f.r-(1+$B)]=typeof $f.q[$f.r-(1+$B)];$f.r=($f.r-$B)|0;" },
7248
+ [OP_IN]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a in $b;$f.r=($f.r-$B)|0;" },
7249
+ [OP_INSTOF]: { body: "$f.r=($f.r+$Z)|0;var $b=$f.q[($f.r-=1)-$B],$a=$f.q[($f.r-=1)-$B];$f.q[($f.r++)-$B]=$a instanceof $b;$f.r=($f.r-$B)|0;" },
7250
+ [OP_NEW]: { body: "var $n=($rd($f)-$Z)&0xffff,$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++]=new $fn(...$g);" },
7251
+ [OP_THIS]: { body: "$f.r=($f.r+$Z)|0;$f.q[($f.r++)-$B]=$f.t;$f.r=($f.r-$B)|0;" },
7252
+ [OP_POP]: { body: "$f.r=($f.r+$Z)|0;$f.r=($f.r-(1+$B))|0;" },
7253
+ [OP_TRY]: { body: "var $cp=($rd($f)-$Z)&0xffff,$cs=$f.c[$f.p++]^$f.st,$ca=$f.c[$f.p++]^$f.ac;$f.e.push({p:$cp,r:$f.r,s:$cs,a:$ca});" },
7254
+ [OP_ENDTRY]: { body: "$f.r=($f.r+$Z)|0;$f.e.pop();$f.r=($f.r-$B)|0;" },
7255
+ [OP_NULLISH]: { body: "$f.r=($f.r+$Z)|0;var $v=$f.q[$f.r-(1+$B)];$f.q[$f.r-(1+$B)]=($v===null||$v===void 0);$f.r=($f.r-$B)|0;" },
7256
+ [OP_DUP]: { body: "$f.r=($f.r+$Z)|0;var $top=$f.q[$f.r-(1+$B)];$f.q[($f.r++)-$B]=$top;$f.r=($f.r-$B)|0;" }
5650
7257
  };
5651
7258
  const handlers = new Array(opCount);
5652
7259
  for (let op = 0; op < opCount; op++) {
@@ -5655,17 +7262,25 @@ function createInterpreterSource(vmHelperName, opMap, seed = 2654435769, windowK
5655
7262
  }
5656
7263
  const hasSym = Boolean(windowKeySymbol);
5657
7264
  const hasExpDelta = Boolean(hasSym && expectedDelta !== void 0);
7265
+ const hasExpHash = Boolean(hasSym && expectedStateHash !== void 0);
7266
+ const hasDigest = hasExpDelta || hasExpHash;
5658
7267
  const symPropAccess = hasSym ? /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(windowKeySymbol) ? `.${windowKeySymbol}` : `[${JSON.stringify(windowKeySymbol)}]` : "";
5659
7268
  const symTamperPropAccess = hasSym ? /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(`${windowKeySymbol}_t`) ? `.${windowKeySymbol}_t` : `[${JSON.stringify(`${windowKeySymbol}_t`)}]` : "";
5660
7269
  const symStatePropAccess = hasSym ? /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(`${windowKeySymbol}_s`) ? `.${windowKeySymbol}_s` : `[${JSON.stringify(`${windowKeySymbol}_s`)}]` : "";
5661
7270
  const expD = hasExpDelta ? expectedDelta & 65535 : 0;
7271
+ const expH = hasExpHash ? expectedStateHash | 0 : 0;
5662
7272
  const seed32 = seed | 0;
5663
7273
  const seedU32 = seed >>> 0;
5664
- const scopeKey = hasSym ? computeFnv1aHash(`${windowKeySymbol}:${hasExpDelta ? expD : ""}`, seed) >>> 0 : 0;
5665
- const expDigest = hasExpDelta ? Math.imul(expD ^ seed32 | 0, 2654435761) ^ (expD << 16 | seed32 >>> 16) ^ 2246822507 | 0 : 0;
7274
+ const scopeKey = hasSym ? computeFnv1aHash(
7275
+ `${windowKeySymbol}:${hasExpDelta ? expD : ""}${hasExpHash ? `:${expH}` : ""}`,
7276
+ seed
7277
+ ) >>> 0 : 0;
7278
+ const expDigest = hasExpDelta ? hasExpHash ? Math.imul(expD ^ expH ^ seed32 | 0, 2654435761) ^ (expD << 16 | seed32 >>> 16) ^ (expH >>> 13 | expH << 19) ^ 2246822507 | 0 : Math.imul(expD ^ seed32 | 0, 2654435761) ^ (expD << 16 | seed32 >>> 16) ^ 2246822507 | 0 : hasExpHash ? Math.imul(expH ^ seed32 | 0, 2654435761) ^ (expH >>> 13 | expH << 19) ^ 2246822507 | 0 : 0;
5666
7279
  const selfPrettyCheck = "$pp||/\\n/.test(Function.prototype.toString.call($vm))";
5667
- const tamperCheckExpr = hasSym ? `var $bad=${selfPrettyCheck}||($G&&($G[$tk]===!0||$G${symTamperPropAccess}===!0||($G${symStatePropAccess}&&$G${symStatePropAccess}[0]===2))),$sv=$G?$G${symPropAccess}:void 0;if(!$bad){if($sv===void 0){if(typeof window>"u"&&typeof document>"u"&&typeof self>"u")$bad=!0;}else if(Array.isArray($sv)){if($sv[0]===2)$bad=!0;}${hasExpDelta ? `else if($sv!==($sv|0)){$bad=!0;}else{var $sh=(Math.imul(($sv^$S)|0,0x9e3779b1)^(($sv<<16)|($S>>>16))^0x85ebca6b)|0;if($sh!==$D)$bad=!0;}` : ""}}` : `var $bad=${selfPrettyCheck}||($G&&$G[$tk]===!0);`;
5668
- const paramsList = hasExpDelta ? "$P,$A,$B,$C,$S,$D" : "$P,$A,$B,$C,$S";
7280
+ const asyncEnvGuard = "var $br=(typeof window<'u'&&typeof document<'u'&&window.document===document&&document.nodeType===9&&document.scripts&&document.scripts.length>0&&document.readyState!==['co','mp','le','te'].join(''))||(typeof self<'u'&&typeof self.importScripts===['fu','nct','ion'].join(''));";
7281
+ const svPresentBranch = hasExpHash ? hasExpDelta ? "else if(!Array.isArray($sr)||$sr[0]!==1||$sv!==($sv|0)){$bad=!0;}else{var $s1=$sr[1]|0,$sh=(Math.imul(($sv^$s1^$S)|0,0x9e3779b1)^(($sv<<16)|($S>>>16))^(($s1>>>13)|($s1<<19))^0x85ebca6b)|0;if($sh!==$D)$bad=!0;}" : "else if(!Array.isArray($sr)||$sr[0]!==1){$bad=!0;}else{var $s1=$sr[1]|0,$sh=(Math.imul(($s1^$S)|0,0x9e3779b1)^(($s1>>>13)|($s1<<19))^0x85ebca6b)|0;if($sh!==$D)$bad=!0;}" : `else if(Array.isArray($sv)){if($sv[0]===2)$bad=!0;}${hasExpDelta ? "else if($sv!==($sv|0)){$bad=!0;}else{var $sh=(Math.imul(($sv^$S)|0,0x9e3779b1)^(($sv<<16)|($S>>>16))^0x85ebca6b)|0;if($sh!==$D)$bad=!0;}" : ""}`;
7282
+ const tamperCheckExpr = hasSym ? `var $sr=$G?$G${symStatePropAccess}:void 0,$bad=${selfPrettyCheck}||($G&&($G[$tk]===!0||$G${symTamperPropAccess}===!0||($sr&&$sr[0]===2))),$sv=$G?$G${symPropAccess}:void 0;if(!$bad){${asyncEnvGuard}if($sv===void 0){if(!$br)$bad=!0;}${svPresentBranch}}` : `var $bad=${selfPrettyCheck}||($G&&$G[$tk]===!0);`;
7283
+ const paramsList = hasDigest ? "$P,$A,$B,$C,$S,$D" : "$P,$A,$B,$C,$S";
5669
7284
  const factoryRaw = `(function $I(${paramsList}){var $G=typeof globalThis<"u"?globalThis:(typeof window<"u"?window:(typeof self<"u"?self:this));var $pp=/\\n/.test(Function.prototype.toString.call($I));var $rk=['__','unp','eek','_vm'].join('');var $rg=0,$rs=0;try{$rg=$G?($G[$rk]||($G[$rk]={})) : 0;$rs=$rg?($rg[${scopeKey}]||($rg[${scopeKey}]={})) : 0;if(!$pp&&$rs&&$rs[${seedU32}])return $rs[${seedU32}];}catch($e){}var $tk=['__','unp','eek','_ta','mpe','red'].join('');var $M=[],$ok=$A&255,$sk=$B&255,$vk=$C|0;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)+(($f.ac|0x9e3779b9)+($f.ac&0x9e3779b9)))|0;var $w=$f.c[$p],$v=$w^(($x0>>>16)&0xffff);$f.st=($f.st^Math.imul($w+1,0x85ebca6b))|0;$f.ac=(Math.imul($f.ac^$v,0x27d4eb2d)^(($f.st>>>13)|($f.st<<19)))|0;return $v;}var $H=[${handlers.join(
5670
7285
  ","
5671
7286
  )}];function $step($f){if($f.d||$f.p>=$f.c.length)return void 0;var $o=$rd($f),$m=$M[$o^$ok];return $m!==void 0?$H[$m^$sk]:void 0;}function $x($f){var $fn=$step($f);while($fn!==void 0){try{$fn=$fn($f);}catch($err){if($f.e.length>0){var $ex=$f.e.pop();$f.r=$ex.r;$f.q[$f.r++]=$err;$f.p=$ex.p;$f.st=$ex.s;$f.ac=$ex.a;$fn=$step($f);}else{throw $err;}}}return $f.v;}var $vm=function($c,$k,$s0,$t,$a,$u){${tamperCheckExpr}var $flt=$bad?(Math.imul($vk^$a,0x45d9f3b)|1):0;return $x({c:$c,k:$k,s:$s0,t:$t,u:$u||[],q:[],r:0,p:0,st:($vk^$a^$flt)|0,ac:($vk^($a<<5)^0x517cc1b7^$flt)|0,e:[],d:0,v:void 0});};try{if(!$pp&&$rs)$rs[${seedU32}]=$vm;}catch($e){}return $vm;})`;
@@ -5677,7 +7292,7 @@ function createInterpreterSource(vmHelperName, opMap, seed = 2654435769, windowK
5677
7292
  const argA = opMask & 255;
5678
7293
  const argB = slotMask & 255;
5679
7294
  const argC = vmKey | 0;
5680
- return `var ${vmHelperName}=(${compactFactory})([${pairs.join(",")}],${argA},${argB},${argC},${seed32}${hasExpDelta ? `,${expDigest}` : ""});`;
7295
+ return `var ${vmHelperName}=(${compactFactory})([${pairs.join(",")}],${argA},${argB},${argC},${seed32}${hasDigest ? `,${expDigest}` : ""});`;
5681
7296
  }
5682
7297
  function walkWithParent(node, parent, visitor) {
5683
7298
  if (!node || typeof node !== "object") return;
@@ -5811,7 +7426,7 @@ function prepareLoweredFunction(fnNode, enclosingBindings) {
5811
7426
  loweredParams.push({ type: "Identifier", name: param.name });
5812
7427
  continue;
5813
7428
  }
5814
- if (param.type === "RestElement" && _optionalChain([param, 'access', _374 => _374.argument, 'optionalAccess', _375 => _375.type]) === "Identifier") {
7429
+ if (param.type === "RestElement" && _optionalChain([param, 'access', _435 => _435.argument, 'optionalAccess', _436 => _436.type]) === "Identifier") {
5815
7430
  wrapperParams.push(param);
5816
7431
  paramPassExprs.push({ type: "Identifier", name: param.argument.name });
5817
7432
  loweredParams.push({ type: "Identifier", name: param.argument.name });
@@ -5870,7 +7485,7 @@ function prepareLoweredFunction(fnNode, enclosingBindings) {
5870
7485
  return null;
5871
7486
  }
5872
7487
  clone.params = loweredParams;
5873
- if (_optionalChain([clone, 'access', _376 => _376.body, 'optionalAccess', _377 => _377.type]) !== "BlockStatement") {
7488
+ if (_optionalChain([clone, 'access', _437 => _437.body, 'optionalAccess', _438 => _438.type]) !== "BlockStatement") {
5874
7489
  clone.body = {
5875
7490
  type: "BlockStatement",
5876
7491
  body: [
@@ -5914,11 +7529,13 @@ function definitelyTerminates(stmt) {
5914
7529
  return false;
5915
7530
  }
5916
7531
  }
5917
- function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
7532
+ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings, seed = 2654435769) {
5918
7533
  const bytecode = [];
5919
7534
  const consts = [];
5920
7535
  const stateSlots = /* @__PURE__ */ new Set();
5921
7536
  const accSlots = /* @__PURE__ */ new Set();
7537
+ const jumpTargets = /* @__PURE__ */ new Map();
7538
+ const jumpOps = /* @__PURE__ */ new Map();
5922
7539
  const fnScope = /* @__PURE__ */ new Map();
5923
7540
  const scopeStack = [fnScope];
5924
7541
  const upvalues = [];
@@ -5976,7 +7593,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
5976
7593
  }
5977
7594
  if (node.type === "TryStatement") {
5978
7595
  scanVarDecls(node.block, false);
5979
- if (_optionalChain([node, 'access', _378 => _378.handler, 'optionalAccess', _379 => _379.body])) scanVarDecls(node.handler.body, false);
7596
+ if (_optionalChain([node, 'access', _439 => _439.handler, 'optionalAccess', _440 => _440.body])) scanVarDecls(node.handler.body, false);
5980
7597
  if (node.finalizer) scanVarDecls(node.finalizer, false);
5981
7598
  return;
5982
7599
  }
@@ -6047,17 +7664,24 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6047
7664
  }
6048
7665
  function emit(op, ...args) {
6049
7666
  bytecode.push(opMap[op]);
6050
- for (const a of args) bytecode.push(a);
7667
+ if (args.length === 1) {
7668
+ bytecode.push(args[0] + computeHandlerBias(seed, op) & 65535);
7669
+ } else {
7670
+ for (const a of args) bytecode.push(a);
7671
+ }
6051
7672
  }
6052
7673
  function emitJumpPlaceholder(op) {
6053
7674
  const pos = bytecode.length;
6054
7675
  emit(op, 0, 0, 0);
7676
+ jumpOps.set(pos, op);
6055
7677
  stateSlots.add(pos + 2);
6056
7678
  accSlots.add(pos + 3);
6057
7679
  return pos;
6058
7680
  }
6059
7681
  function patchJump(pos, targetPc) {
6060
- bytecode[pos + 1] = targetPc;
7682
+ const op = _nullishCoalesce(jumpOps.get(pos), () => ( OP_JMP));
7683
+ jumpTargets.set(pos + 1, targetPc);
7684
+ bytecode[pos + 1] = targetPc + computeHandlerBias(seed, op) & 65535;
6061
7685
  }
6062
7686
  function compilePatternAssignFromSlot(pattern, sourceSlot) {
6063
7687
  if (!pattern) return false;
@@ -6094,7 +7718,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6094
7718
  if (prop.computed) {
6095
7719
  if (!compileExpr(prop.key, true)) return false;
6096
7720
  } else {
6097
- const keyName = _optionalChain([prop, 'access', _380 => _380.key, 'optionalAccess', _381 => _381.type]) === "Identifier" ? prop.key.name : _optionalChain([prop, 'access', _382 => _382.key, 'optionalAccess', _383 => _383.type]) === "Literal" ? String(prop.key.value) : void 0;
7721
+ const keyName = _optionalChain([prop, 'access', _441 => _441.key, 'optionalAccess', _442 => _442.type]) === "Identifier" ? prop.key.name : _optionalChain([prop, 'access', _443 => _443.key, 'optionalAccess', _444 => _444.type]) === "Literal" ? String(prop.key.value) : void 0;
6098
7722
  if (keyName === void 0) return false;
6099
7723
  emit(OP_LDC, addConst(keyName));
6100
7724
  }
@@ -6233,11 +7857,11 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6233
7857
  case "TemplateLiteral": {
6234
7858
  const quasis = node.quasis || [];
6235
7859
  const exprs = node.expressions || [];
6236
- emit(OP_LDC, addConst(_nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _384 => _384[0], 'optionalAccess', _385 => _385.value, 'optionalAccess', _386 => _386.cooked]), () => ( _optionalChain([quasis, 'access', _387 => _387[0], 'optionalAccess', _388 => _388.value, 'optionalAccess', _389 => _389.raw]))), () => ( ""))));
7860
+ emit(OP_LDC, addConst(_nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _445 => _445[0], 'optionalAccess', _446 => _446.value, 'optionalAccess', _447 => _447.cooked]), () => ( _optionalChain([quasis, 'access', _448 => _448[0], 'optionalAccess', _449 => _449.value, 'optionalAccess', _450 => _450.raw]))), () => ( ""))));
6237
7861
  for (let i = 0; i < exprs.length; i++) {
6238
7862
  if (!compileExpr(exprs[i], true)) return false;
6239
7863
  emit(OP_ADD);
6240
- const qStr = _nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _390 => _390[i + 1], 'optionalAccess', _391 => _391.value, 'optionalAccess', _392 => _392.cooked]), () => ( _optionalChain([quasis, 'access', _393 => _393[i + 1], 'optionalAccess', _394 => _394.value, 'optionalAccess', _395 => _395.raw]))), () => ( ""));
7864
+ const qStr = _nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _451 => _451[i + 1], 'optionalAccess', _452 => _452.value, 'optionalAccess', _453 => _453.cooked]), () => ( _optionalChain([quasis, 'access', _454 => _454[i + 1], 'optionalAccess', _455 => _455.value, 'optionalAccess', _456 => _456.raw]))), () => ( ""));
6241
7865
  if (qStr.length > 0) {
6242
7866
  emit(OP_LDC, addConst(qStr));
6243
7867
  emit(OP_ADD);
@@ -6323,7 +7947,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6323
7947
  if (inValuePos) emit(OP_LDC, addConst(void 0));
6324
7948
  return true;
6325
7949
  }
6326
- if (node.operator === "typeof" && _optionalChain([node, 'access', _396 => _396.argument, 'optionalAccess', _397 => _397.type]) === "Identifier") {
7950
+ if (node.operator === "typeof" && _optionalChain([node, 'access', _457 => _457.argument, 'optionalAccess', _458 => _458.type]) === "Identifier") {
6327
7951
  const name = node.argument.name;
6328
7952
  if (name === "undefined" && resolveLocal("undefined") === void 0) {
6329
7953
  emit(OP_LDC, addConst(void 0));
@@ -6370,7 +7994,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6370
7994
  if (node.computed) {
6371
7995
  if (!compileExpr(node.property, true)) return false;
6372
7996
  } else {
6373
- if (_optionalChain([node, 'access', _398 => _398.property, 'optionalAccess', _399 => _399.type]) !== "Identifier") return false;
7997
+ if (_optionalChain([node, 'access', _459 => _459.property, 'optionalAccess', _460 => _460.type]) !== "Identifier") return false;
6374
7998
  emit(OP_LDC, addConst(node.property.name));
6375
7999
  }
6376
8000
  emit(OP_GETP);
@@ -6380,7 +8004,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6380
8004
  case "CallExpression": {
6381
8005
  if (node.optional) return false;
6382
8006
  for (const arg of node.arguments || []) {
6383
- if (_optionalChain([arg, 'optionalAccess', _400 => _400.type]) === "SpreadElement") return false;
8007
+ if (_optionalChain([arg, 'optionalAccess', _461 => _461.type]) === "SpreadElement") return false;
6384
8008
  }
6385
8009
  if (node.callee.type === "MemberExpression") {
6386
8010
  if (node.callee.optional) return false;
@@ -6388,7 +8012,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6388
8012
  if (node.callee.computed) {
6389
8013
  if (!compileExpr(node.callee.property, true)) return false;
6390
8014
  } else {
6391
- if (_optionalChain([node, 'access', _401 => _401.callee, 'access', _402 => _402.property, 'optionalAccess', _403 => _403.type]) !== "Identifier") return false;
8015
+ if (_optionalChain([node, 'access', _462 => _462.callee, 'access', _463 => _463.property, 'optionalAccess', _464 => _464.type]) !== "Identifier") return false;
6392
8016
  emit(OP_LDC, addConst(node.callee.property.name));
6393
8017
  }
6394
8018
  for (const arg of node.arguments) {
@@ -6407,7 +8031,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6407
8031
  }
6408
8032
  case "NewExpression": {
6409
8033
  for (const arg of node.arguments || []) {
6410
- if (_optionalChain([arg, 'optionalAccess', _404 => _404.type]) === "SpreadElement") return false;
8034
+ if (_optionalChain([arg, 'optionalAccess', _465 => _465.type]) === "SpreadElement") return false;
6411
8035
  }
6412
8036
  if (!compileExpr(node.callee, true)) return false;
6413
8037
  for (const arg of node.arguments || []) {
@@ -6450,7 +8074,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6450
8074
  if (node.left.computed) {
6451
8075
  if (!compileExpr(node.left.property, true)) return false;
6452
8076
  } else {
6453
- if (_optionalChain([node, 'access', _405 => _405.left, 'access', _406 => _406.property, 'optionalAccess', _407 => _407.type]) !== "Identifier") return false;
8077
+ if (_optionalChain([node, 'access', _466 => _466.left, 'access', _467 => _467.property, 'optionalAccess', _468 => _468.type]) !== "Identifier") return false;
6454
8078
  emit(OP_LDC, addConst(node.left.property.name));
6455
8079
  }
6456
8080
  if (!compileExpr(node.right, true)) return false;
@@ -6466,7 +8090,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6466
8090
  if (node.left.computed) {
6467
8091
  if (!compileExpr(node.left.property, true)) return false;
6468
8092
  } else {
6469
- if (_optionalChain([node, 'access', _408 => _408.left, 'access', _409 => _409.property, 'optionalAccess', _410 => _410.type]) !== "Identifier") return false;
8093
+ if (_optionalChain([node, 'access', _469 => _469.left, 'access', _470 => _470.property, 'optionalAccess', _471 => _471.type]) !== "Identifier") return false;
6470
8094
  emit(OP_LDC, addConst(node.left.property.name));
6471
8095
  }
6472
8096
  emit(OP_STV, keySlot);
@@ -6486,7 +8110,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6486
8110
  case "UpdateExpression": {
6487
8111
  const oneIdx = addConst(1);
6488
8112
  const stepOp = node.operator === "++" ? OP_ADD : OP_SUB;
6489
- if (_optionalChain([node, 'access', _411 => _411.argument, 'optionalAccess', _412 => _412.type]) === "Identifier") {
8113
+ if (_optionalChain([node, 'access', _472 => _472.argument, 'optionalAccess', _473 => _473.type]) === "Identifier") {
6490
8114
  const name = node.argument.name;
6491
8115
  if (!canWriteVar(name)) return false;
6492
8116
  if (node.prefix) {
@@ -6512,7 +8136,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6512
8136
  }
6513
8137
  return true;
6514
8138
  }
6515
- if (_optionalChain([node, 'access', _413 => _413.argument, 'optionalAccess', _414 => _414.type]) === "MemberExpression" && !node.argument.optional) {
8139
+ if (_optionalChain([node, 'access', _474 => _474.argument, 'optionalAccess', _475 => _475.type]) === "MemberExpression" && !node.argument.optional) {
6516
8140
  const objSlot = allocTempSlot();
6517
8141
  const keySlot = allocTempSlot();
6518
8142
  const oldSlot = allocTempSlot();
@@ -6521,7 +8145,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6521
8145
  if (node.argument.computed) {
6522
8146
  if (!compileExpr(node.argument.property, true)) return false;
6523
8147
  } else {
6524
- if (_optionalChain([node, 'access', _415 => _415.argument, 'access', _416 => _416.property, 'optionalAccess', _417 => _417.type]) !== "Identifier") return false;
8148
+ if (_optionalChain([node, 'access', _476 => _476.argument, 'access', _477 => _477.property, 'optionalAccess', _478 => _478.type]) !== "Identifier") return false;
6525
8149
  emit(OP_LDC, addConst(node.argument.property.name));
6526
8150
  }
6527
8151
  emit(OP_STV, keySlot);
@@ -6553,7 +8177,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6553
8177
  if (prop.computed) {
6554
8178
  if (!compileExpr(prop.key, true)) return false;
6555
8179
  } else {
6556
- const keyName = _nullishCoalesce(_optionalChain([prop, 'access', _418 => _418.key, 'optionalAccess', _419 => _419.name]), () => ( _optionalChain([prop, 'access', _420 => _420.key, 'optionalAccess', _421 => _421.value])));
8180
+ const keyName = _nullishCoalesce(_optionalChain([prop, 'access', _479 => _479.key, 'optionalAccess', _480 => _480.name]), () => ( _optionalChain([prop, 'access', _481 => _481.key, 'optionalAccess', _482 => _482.value])));
6557
8181
  if (keyName === void 0) return false;
6558
8182
  emit(OP_LDC, addConst(keyName));
6559
8183
  }
@@ -6605,14 +8229,14 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6605
8229
  }
6606
8230
  case "VariableDeclaration": {
6607
8231
  for (const decl of stmt.declarations) {
6608
- if (_optionalChain([decl, 'access', _422 => _422.id, 'optionalAccess', _423 => _423.type]) === "Identifier") {
8232
+ if (_optionalChain([decl, 'access', _483 => _483.id, 'optionalAccess', _484 => _484.type]) === "Identifier") {
6609
8233
  const slot = resolveLocal(decl.id.name);
6610
8234
  if (slot === void 0) return false;
6611
8235
  if (decl.init) {
6612
8236
  if (!compileExpr(decl.init, true)) return false;
6613
8237
  emit(OP_STV, slot);
6614
8238
  }
6615
- } else if (_optionalChain([decl, 'access', _424 => _424.id, 'optionalAccess', _425 => _425.type]) === "ObjectPattern" || _optionalChain([decl, 'access', _426 => _426.id, 'optionalAccess', _427 => _427.type]) === "ArrayPattern") {
8239
+ } else if (_optionalChain([decl, 'access', _485 => _485.id, 'optionalAccess', _486 => _486.type]) === "ObjectPattern" || _optionalChain([decl, 'access', _487 => _487.id, 'optionalAccess', _488 => _488.type]) === "ArrayPattern") {
6616
8240
  if (!decl.init) return false;
6617
8241
  const srcSlot = allocTempSlot();
6618
8242
  if (!compileExpr(decl.init, true)) return false;
@@ -6708,7 +8332,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6708
8332
  }
6709
8333
  case "ForStatement": {
6710
8334
  let pushedForScope = false;
6711
- if (_optionalChain([stmt, 'access', _428 => _428.init, 'optionalAccess', _429 => _429.type]) === "VariableDeclaration" && stmt.init.kind !== "var") {
8335
+ if (_optionalChain([stmt, 'access', _489 => _489.init, 'optionalAccess', _490 => _490.type]) === "VariableDeclaration" && stmt.init.kind !== "var") {
6712
8336
  const forScope = /* @__PURE__ */ new Map();
6713
8337
  const names = /* @__PURE__ */ new Set();
6714
8338
  for (const decl of stmt.init.declarations || []) {
@@ -6776,7 +8400,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6776
8400
  case "BreakStatement":
6777
8401
  case "ContinueStatement": {
6778
8402
  const isBreak = stmt.type === "BreakStatement";
6779
- const labelName = _optionalChain([stmt, 'access', _430 => _430.label, 'optionalAccess', _431 => _431.name]);
8403
+ const labelName = _optionalChain([stmt, 'access', _491 => _491.label, 'optionalAccess', _492 => _492.name]);
6780
8404
  let target;
6781
8405
  for (let i = loopStack.length - 1; i >= 0; i--) {
6782
8406
  if (!labelName || loopStack[i].label === labelName) {
@@ -6795,7 +8419,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6795
8419
  return true;
6796
8420
  }
6797
8421
  case "LabeledStatement": {
6798
- return compileStmt(stmt.body, false, _optionalChain([stmt, 'access', _432 => _432.label, 'optionalAccess', _433 => _433.name]));
8422
+ return compileStmt(stmt.body, false, _optionalChain([stmt, 'access', _493 => _493.label, 'optionalAccess', _494 => _494.name]));
6799
8423
  }
6800
8424
  case "TryStatement": {
6801
8425
  if (stmt.finalizer) {
@@ -6920,17 +8544,17 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6920
8544
  emit(OP_LDC, addConst(void 0));
6921
8545
  emit(OP_RET);
6922
8546
  }
6923
- return { bytecode, consts, localCount, stateSlots, accSlots, upvalues };
8547
+ return { bytecode, consts, localCount, stateSlots, accSlots, jumpTargets, upvalues };
6924
8548
  }
6925
8549
  function findInjectedVmHelperName(ast) {
6926
8550
  if (!ast || !Array.isArray(ast.body)) return null;
6927
8551
  for (const stmt of ast.body) {
6928
- if (stmt.type === "FunctionDeclaration" && typeof _optionalChain([stmt, 'access', _434 => _434.id, 'optionalAccess', _435 => _435.name]) === "string" && stmt.id.name.startsWith("_uVm")) {
8552
+ if (stmt.type === "FunctionDeclaration" && typeof _optionalChain([stmt, 'access', _495 => _495.id, 'optionalAccess', _496 => _496.name]) === "string" && stmt.id.name.startsWith("_uVm")) {
6929
8553
  return stmt.id.name;
6930
8554
  }
6931
8555
  if (stmt.type === "VariableDeclaration" && Array.isArray(stmt.declarations)) {
6932
8556
  for (const d of stmt.declarations) {
6933
- if (_optionalChain([d, 'access', _436 => _436.id, 'optionalAccess', _437 => _437.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uVm")) {
8557
+ if (_optionalChain([d, 'access', _497 => _497.id, 'optionalAccess', _498 => _498.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uVm")) {
6934
8558
  return d.id.name;
6935
8559
  }
6936
8560
  }
@@ -6941,26 +8565,26 @@ function findInjectedVmHelperName(ast) {
6941
8565
  var PRIORITY_HANDLER_NAME_RE = /^(?:onSubmit|handleSubmit|submit[A-Za-z0-9_]*|validate[A-Za-z0-9_]*|login(?:[A-Z0-9_].*)?|signIn(?:[A-Z0-9_].*)?|register(?:[A-Z0-9_].*)?|checkout(?:[A-Z0-9_].*)?)$/i;
6942
8566
  var PRIORITY_CALL_NAME_RE = /^(?:onSubmit|handleSubmit|submit[A-Za-z0-9_]*|validate[A-Za-z0-9_]*|login(?:[A-Z0-9_].*)?|signIn(?:[A-Z0-9_].*)?|register(?:[A-Z0-9_].*)?|checkout(?:[A-Z0-9_].*)?|createServerReference|fetch)$/i;
6943
8567
  function getVmCandidateName(fn, ancestors) {
6944
- if (_optionalChain([fn, 'access', _438 => _438.id, 'optionalAccess', _439 => _439.type]) === "Identifier" && typeof fn.id.name === "string") {
8568
+ if (_optionalChain([fn, 'access', _499 => _499.id, 'optionalAccess', _500 => _500.type]) === "Identifier" && typeof fn.id.name === "string") {
6945
8569
  return fn.id.name;
6946
8570
  }
6947
8571
  const parent = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
6948
8572
  if (!parent) return "";
6949
- if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _440 => _440.id, 'optionalAccess', _441 => _441.type]) === "Identifier") {
8573
+ if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _501 => _501.id, 'optionalAccess', _502 => _502.type]) === "Identifier") {
6950
8574
  return parent.id.name;
6951
8575
  }
6952
8576
  if (parent.type === "Property") {
6953
- if (_optionalChain([parent, 'access', _442 => _442.key, 'optionalAccess', _443 => _443.type]) === "Identifier") return parent.key.name;
6954
- if (_optionalChain([parent, 'access', _444 => _444.key, 'optionalAccess', _445 => _445.type]) === "Literal" && typeof parent.key.value === "string") {
8577
+ if (_optionalChain([parent, 'access', _503 => _503.key, 'optionalAccess', _504 => _504.type]) === "Identifier") return parent.key.name;
8578
+ if (_optionalChain([parent, 'access', _505 => _505.key, 'optionalAccess', _506 => _506.type]) === "Literal" && typeof parent.key.value === "string") {
6955
8579
  return parent.key.value;
6956
8580
  }
6957
8581
  }
6958
- if (parent.type === "MethodDefinition" && _optionalChain([parent, 'access', _446 => _446.key, 'optionalAccess', _447 => _447.type]) === "Identifier") {
8582
+ if (parent.type === "MethodDefinition" && _optionalChain([parent, 'access', _507 => _507.key, 'optionalAccess', _508 => _508.type]) === "Identifier") {
6959
8583
  return parent.key.name;
6960
8584
  }
6961
8585
  if (parent.type === "AssignmentExpression") {
6962
- if (_optionalChain([parent, 'access', _448 => _448.left, 'optionalAccess', _449 => _449.type]) === "Identifier") return parent.left.name;
6963
- if (_optionalChain([parent, 'access', _450 => _450.left, 'optionalAccess', _451 => _451.type]) === "MemberExpression" && !parent.left.computed && _optionalChain([parent, 'access', _452 => _452.left, 'access', _453 => _453.property, 'optionalAccess', _454 => _454.type]) === "Identifier") {
8586
+ if (_optionalChain([parent, 'access', _509 => _509.left, 'optionalAccess', _510 => _510.type]) === "Identifier") return parent.left.name;
8587
+ if (_optionalChain([parent, 'access', _511 => _511.left, 'optionalAccess', _512 => _512.type]) === "MemberExpression" && !parent.left.computed && _optionalChain([parent, 'access', _513 => _513.left, 'access', _514 => _514.property, 'optionalAccess', _515 => _515.type]) === "Identifier") {
6964
8588
  return parent.left.property.name;
6965
8589
  }
6966
8590
  }
@@ -6973,11 +8597,11 @@ function bodyHasPrioritySignal(fnNode) {
6973
8597
  if (n !== fnNode && FUNCTION_NODE_TYPES2.has(n.type)) return false;
6974
8598
  if (n.type === "CallExpression") {
6975
8599
  const callee = n.callee;
6976
- if (_optionalChain([callee, 'optionalAccess', _455 => _455.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.name)) {
8600
+ if (_optionalChain([callee, 'optionalAccess', _516 => _516.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.name)) {
6977
8601
  matched = true;
6978
8602
  return false;
6979
8603
  }
6980
- if (_optionalChain([callee, 'optionalAccess', _456 => _456.type]) === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _457 => _457.property, 'optionalAccess', _458 => _458.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.property.name)) {
8604
+ if (_optionalChain([callee, 'optionalAccess', _517 => _517.type]) === "MemberExpression" && !callee.computed && _optionalChain([callee, 'access', _518 => _518.property, 'optionalAccess', _519 => _519.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.property.name)) {
6981
8605
  matched = true;
6982
8606
  return false;
6983
8607
  }
@@ -6997,14 +8621,14 @@ function bodyHasPrioritySignal(fnNode) {
6997
8621
  }
6998
8622
  function scoreVmCandidate(fn, ancestors, criticalSet) {
6999
8623
  let score = 0;
7000
- if (_optionalChain([criticalSet, 'optionalAccess', _459 => _459.has, 'call', _460 => _460(fn)])) {
8624
+ if (_optionalChain([criticalSet, 'optionalAccess', _520 => _520.has, 'call', _521 => _521(fn)])) {
7001
8625
  score += 1e3;
7002
8626
  }
7003
8627
  const candName = getVmCandidateName(fn, ancestors);
7004
8628
  if (candName && PRIORITY_HANDLER_NAME_RE.test(candName) || bodyHasPrioritySignal(fn)) {
7005
8629
  score += 500;
7006
8630
  }
7007
- if (_optionalChain([fn, 'access', _461 => _461.body, 'optionalAccess', _462 => _462.type]) === "BlockStatement" && Array.isArray(fn.body.body)) {
8631
+ if (_optionalChain([fn, 'access', _522 => _522.body, 'optionalAccess', _523 => _523.type]) === "BlockStatement" && Array.isArray(fn.body.body)) {
7008
8632
  const stmtCount = fn.body.body.length;
7009
8633
  if (stmtCount >= 2) {
7010
8634
  score += Math.min(200, 10 + (stmtCount - 2) * 15);
@@ -7022,8 +8646,8 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
7022
8646
  vmHelperName: existingName
7023
8647
  };
7024
8648
  }
7025
- const maxFunctions = _nullishCoalesce(_optionalChain([extraOpts, 'optionalAccess', _463 => _463.maxFunctionsPerChunk]), () => ( 12));
7026
- const criticalSet = _optionalChain([extraOpts, 'optionalAccess', _464 => _464.criticalFunctionNodes]);
8649
+ const maxFunctions = _nullishCoalesce(_optionalChain([extraOpts, 'optionalAccess', _524 => _524.maxFunctionsPerChunk]), () => ( 12));
8650
+ const criticalSet = _optionalChain([extraOpts, 'optionalAccess', _525 => _525.criticalFunctionNodes]);
7027
8651
  const opMap = generateOpcodeMap(seed, OPCODE_COUNT);
7028
8652
  const vmKey = deriveVmKey(seed);
7029
8653
  const scopeBindings = /* @__PURE__ */ new Map();
@@ -7056,7 +8680,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
7056
8680
  walk7.ancestor(ast, {
7057
8681
  ImportDeclaration(node) {
7058
8682
  for (const spec of node.specifiers || []) {
7059
- if (_optionalChain([spec, 'access', _465 => _465.local, 'optionalAccess', _466 => _466.type]) === "Identifier") {
8683
+ if (_optionalChain([spec, 'access', _526 => _526.local, 'optionalAccess', _527 => _527.type]) === "Identifier") {
7060
8684
  addScopeBinding(ast, spec.local.name);
7061
8685
  }
7062
8686
  }
@@ -7073,7 +8697,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
7073
8697
  },
7074
8698
  FunctionDeclaration(node, _state, ancestors) {
7075
8699
  const parentAncestors = ancestors.slice(0, -1);
7076
- if (_optionalChain([node, 'access', _467 => _467.id, 'optionalAccess', _468 => _468.type]) === "Identifier") {
8700
+ if (_optionalChain([node, 'access', _528 => _528.id, 'optionalAccess', _529 => _529.type]) === "Identifier") {
7077
8701
  addScopeBinding(findNearestLexicalScope(parentAncestors), node.id.name);
7078
8702
  addScopeBinding(findNearestFunctionOrProgram(parentAncestors), node.id.name);
7079
8703
  }
@@ -7087,7 +8711,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
7087
8711
  rawCandidates.push({ fn: node, ancestors: ancestors.slice() });
7088
8712
  },
7089
8713
  FunctionExpression(node, _state, ancestors) {
7090
- if (_optionalChain([node, 'access', _469 => _469.id, 'optionalAccess', _470 => _470.type]) === "Identifier") {
8714
+ if (_optionalChain([node, 'access', _530 => _530.id, 'optionalAccess', _531 => _531.type]) === "Identifier") {
7091
8715
  addScopeBinding(node, node.id.name);
7092
8716
  }
7093
8717
  const paramNames = /* @__PURE__ */ new Set();
@@ -7110,13 +8734,13 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
7110
8734
  rawCandidates.push({ fn: node, ancestors: ancestors.slice() });
7111
8735
  },
7112
8736
  ClassDeclaration(node, _state, ancestors) {
7113
- if (_optionalChain([node, 'access', _471 => _471.id, 'optionalAccess', _472 => _472.type]) === "Identifier") {
8737
+ if (_optionalChain([node, 'access', _532 => _532.id, 'optionalAccess', _533 => _533.type]) === "Identifier") {
7114
8738
  addScopeBinding(findNearestLexicalScope(ancestors.slice(0, -1)), node.id.name);
7115
8739
  addScopeBinding(node, node.id.name);
7116
8740
  }
7117
8741
  },
7118
8742
  ClassExpression(node) {
7119
- if (_optionalChain([node, 'access', _473 => _473.id, 'optionalAccess', _474 => _474.type]) === "Identifier") {
8743
+ if (_optionalChain([node, 'access', _534 => _534.id, 'optionalAccess', _535 => _535.type]) === "Identifier") {
7120
8744
  addScopeBinding(node, node.id.name);
7121
8745
  }
7122
8746
  },
@@ -7148,7 +8772,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
7148
8772
  continue;
7149
8773
  }
7150
8774
  const parentNode = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
7151
- if (_optionalChain([parentNode, 'optionalAccess', _475 => _475.type]) === "MethodDefinition" && parentNode.kind === "constructor") {
8775
+ if (_optionalChain([parentNode, 'optionalAccess', _536 => _536.type]) === "MethodDefinition" && parentNode.kind === "constructor") {
7152
8776
  continue;
7153
8777
  }
7154
8778
  if (ancestors.some((a) => a.type === "WithStatement")) {
@@ -7170,14 +8794,14 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
7170
8794
  }
7171
8795
  }
7172
8796
  }
7173
- if (fn.type === "FunctionExpression" && _optionalChain([fn, 'access', _476 => _476.id, 'optionalAccess', _477 => _477.type]) === "Identifier") {
8797
+ if (fn.type === "FunctionExpression" && _optionalChain([fn, 'access', _537 => _537.id, 'optionalAccess', _538 => _538.type]) === "Identifier") {
7174
8798
  enclosingBindings.add(fn.id.name);
7175
8799
  }
7176
8800
  const lowered = prepareLoweredFunction(fn, enclosingBindings);
7177
8801
  if (!lowered) {
7178
8802
  continue;
7179
8803
  }
7180
- const compiled = compileFunctionToBytecode(lowered.loweredFn, opMap, enclosingBindings);
8804
+ const compiled = compileFunctionToBytecode(lowered.loweredFn, opMap, enclosingBindings, seed);
7181
8805
  if (!compiled) {
7182
8806
  continue;
7183
8807
  }
@@ -7187,7 +8811,8 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
7187
8811
  fnSalt,
7188
8812
  vmKey,
7189
8813
  compiled.stateSlots,
7190
- compiled.accSlots
8814
+ compiled.accSlots,
8815
+ compiled.jumpTargets
7191
8816
  );
7192
8817
  const constElements = compiled.consts.map((c) => {
7193
8818
  if (c === void 0) {
@@ -7307,7 +8932,8 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
7307
8932
  opMap,
7308
8933
  seed,
7309
8934
  windowKeySymbol,
7310
- expectedDelta
8935
+ expectedDelta,
8936
+ _optionalChain([extraOpts, 'optionalAccess', _539 => _539.expectedStateHash])
7311
8937
  );
7312
8938
  const parsedHelper = acorn6.parse(interpreterSource, {
7313
8939
  ecmaVersion: "latest",
@@ -7316,7 +8942,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
7316
8942
  let insertIdx = 0;
7317
8943
  while (insertIdx < ast.body.length) {
7318
8944
  const stmt = ast.body[insertIdx];
7319
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _478 => _478.expression, 'optionalAccess', _479 => _479.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
8945
+ const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _540 => _540.expression, 'optionalAccess', _541 => _541.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
7320
8946
  if (isDirective || stmt.type === "ImportDeclaration") {
7321
8947
  insertIdx++;
7322
8948
  } else {
@@ -7403,7 +9029,7 @@ function scrubResidualPaths(ast, options = {}, hotExemptNodes, exemptSubtreeRoot
7403
9029
  Literal(node, _state, ancestors) {
7404
9030
  if (node.regex || typeof node.value !== "string") return;
7405
9031
  const val = node.value;
7406
- if (_optionalChain([exemptSet, 'optionalAccess', _480 => _480.has, 'call', _481 => _481(val)])) return;
9032
+ if (_optionalChain([exemptSet, 'optionalAccess', _542 => _542.has, 'call', _543 => _543(val)])) return;
7407
9033
  const parent = ancestors[ancestors.length - 2];
7408
9034
  if (!parent) return;
7409
9035
  if ((parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") && parent.source === node) {
@@ -7428,12 +9054,12 @@ function scrubResidualPaths(ast, options = {}, hotExemptNodes, exemptSubtreeRoot
7428
9054
  return;
7429
9055
  }
7430
9056
  const parent = ancestors[ancestors.length - 2];
7431
- if (_optionalChain([parent, 'optionalAccess', _482 => _482.type]) === "ImportExpression" && parent.source === node) {
9057
+ if (_optionalChain([parent, 'optionalAccess', _544 => _544.type]) === "ImportExpression" && parent.source === node) {
7432
9058
  return;
7433
9059
  }
7434
9060
  for (const quasi of node.quasis) {
7435
- const val = _nullishCoalesce(_optionalChain([quasi, 'optionalAccess', _483 => _483.value, 'optionalAccess', _484 => _484.cooked]), () => ( _optionalChain([quasi, 'optionalAccess', _485 => _485.value, 'optionalAccess', _486 => _486.raw])));
7436
- if (typeof val !== "string" || _optionalChain([exemptSet, 'optionalAccess', _487 => _487.has, 'call', _488 => _488(val)])) continue;
9061
+ const val = _nullishCoalesce(_optionalChain([quasi, 'optionalAccess', _545 => _545.value, 'optionalAccess', _546 => _546.cooked]), () => ( _optionalChain([quasi, 'optionalAccess', _547 => _547.value, 'optionalAccess', _548 => _548.raw])));
9062
+ if (typeof val !== "string" || _optionalChain([exemptSet, 'optionalAccess', _549 => _549.has, 'call', _550 => _550(val)])) continue;
7437
9063
  const scrubbed = scrubStringValue(val, options.rootDir);
7438
9064
  if (scrubbed !== val) {
7439
9065
  quasi.value.cooked = scrubbed;
@@ -7473,25 +9099,25 @@ function isAstAlreadyProtected(ast) {
7473
9099
  return ast.body.some((stmt) => {
7474
9100
  if (stmt.type === "VariableDeclaration" && Array.isArray(stmt.declarations)) {
7475
9101
  for (const d of stmt.declarations) {
7476
- const name = _optionalChain([d, 'access', _489 => _489.id, 'optionalAccess', _490 => _490.type]) === "Identifier" ? d.id.name : void 0;
9102
+ const name = _optionalChain([d, 'access', _551 => _551.id, 'optionalAccess', _552 => _552.type]) === "Identifier" ? d.id.name : void 0;
7477
9103
  if (typeof name === "string") {
7478
- if (name === "_d" || name.startsWith("_uC") || name.startsWith("_uD") || name.startsWith("_uS") || name.startsWith("_uVm") || name.startsWith("_wKdf") || name.startsWith("_uP") || name.startsWith("_uCache") || name.startsWith("_uDc") || name.startsWith("_m") || name.startsWith("_w") || name.startsWith("_k") || _optionalChain([d, 'access', _491 => _491.init, 'optionalAccess', _492 => _492.type]) === "CallExpression" && _optionalChain([d, 'access', _493 => _493.init, 'access', _494 => _494.callee, 'optionalAccess', _495 => _495.type]) === "FunctionExpression" && _optionalChain([d, 'access', _496 => _496.init, 'access', _497 => _497.callee, 'optionalAccess', _498 => _498.id, 'optionalAccess', _499 => _499.name]) === "f" && _optionalChain([d, 'access', _500 => _500.init, 'access', _501 => _501.arguments, 'optionalAccess', _502 => _502[0], 'optionalAccess', _503 => _503.type]) === "ArrayExpression" || _optionalChain([d, 'access', _504 => _504.init, 'optionalAccess', _505 => _505.type]) === "CallExpression" && _optionalChain([d, 'access', _506 => _506.init, 'access', _507 => _507.callee, 'optionalAccess', _508 => _508.type]) === "MemberExpression" && _optionalChain([d, 'access', _509 => _509.init, 'access', _510 => _510.callee, 'access', _511 => _511.object, 'optionalAccess', _512 => _512.type]) === "Identifier" && d.init.callee.object.name === "Symbol" && _optionalChain([d, 'access', _513 => _513.init, 'access', _514 => _514.callee, 'access', _515 => _515.property, 'optionalAccess', _516 => _516.type]) === "Identifier" && d.init.callee.property.name === "for" && typeof _optionalChain([d, 'access', _517 => _517.init, 'access', _518 => _518.arguments, 'optionalAccess', _519 => _519[0], 'optionalAccess', _520 => _520.value]) === "string" && d.init.arguments[0].value.startsWith("__upk_v4_")) {
9104
+ if (name.startsWith("_uC") || name.startsWith("_uD") || name.startsWith("_uS") || name.startsWith("_uSb") || name.startsWith("_uDec") || name.startsWith("_uAl") || name.startsWith("_uAm") || name.startsWith("_uZt") || name.startsWith("_uVm") || name.startsWith("_wKdf") || name.startsWith("_uP") || name.startsWith("_uCache") || name.startsWith("_uDc") || _optionalChain([d, 'access', _553 => _553.init, 'optionalAccess', _554 => _554.type]) === "CallExpression" && _optionalChain([d, 'access', _555 => _555.init, 'access', _556 => _556.callee, 'optionalAccess', _557 => _557.type]) === "FunctionExpression" && _optionalChain([d, 'access', _558 => _558.init, 'access', _559 => _559.callee, 'optionalAccess', _560 => _560.id, 'optionalAccess', _561 => _561.name]) === "f" && _optionalChain([d, 'access', _562 => _562.init, 'access', _563 => _563.arguments, 'optionalAccess', _564 => _564[0], 'optionalAccess', _565 => _565.type]) === "ArrayExpression" || _optionalChain([d, 'access', _566 => _566.init, 'optionalAccess', _567 => _567.type]) === "CallExpression" && _optionalChain([d, 'access', _568 => _568.init, 'access', _569 => _569.callee, 'optionalAccess', _570 => _570.type]) === "MemberExpression" && _optionalChain([d, 'access', _571 => _571.init, 'access', _572 => _572.callee, 'access', _573 => _573.object, 'optionalAccess', _574 => _574.type]) === "Identifier" && d.init.callee.object.name === "Symbol" && _optionalChain([d, 'access', _575 => _575.init, 'access', _576 => _576.callee, 'access', _577 => _577.property, 'optionalAccess', _578 => _578.type]) === "Identifier" && d.init.callee.property.name === "for" && typeof _optionalChain([d, 'access', _579 => _579.init, 'access', _580 => _580.arguments, 'optionalAccess', _581 => _581[0], 'optionalAccess', _582 => _582.value]) === "string" && d.init.arguments[0].value.startsWith("__upk_v4_")) {
7479
9105
  return true;
7480
9106
  }
7481
9107
  }
7482
9108
  }
7483
9109
  }
7484
- if (stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _521 => _521.id, 'optionalAccess', _522 => _522.type]) === "Identifier") {
9110
+ if (stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _583 => _583.id, 'optionalAccess', _584 => _584.type]) === "Identifier") {
7485
9111
  const fnName = stmt.id.name;
7486
- if (typeof fnName === "string" && (fnName.startsWith("_uD") || fnName.startsWith("_uVm") || fnName.startsWith("_wKdf") || fnName.startsWith("_hX"))) {
9112
+ if (typeof fnName === "string" && (fnName.startsWith("_uD") || fnName.startsWith("_uVm") || fnName.startsWith("_wKdf") || fnName === "_hX")) {
7487
9113
  return true;
7488
9114
  }
7489
9115
  }
7490
- if (stmt.type === "ExpressionStatement" && _optionalChain([stmt, 'access', _523 => _523.expression, 'optionalAccess', _524 => _524.type]) === "CallExpression") {
9116
+ if (stmt.type === "ExpressionStatement" && _optionalChain([stmt, 'access', _585 => _585.expression, 'optionalAccess', _586 => _586.type]) === "CallExpression") {
7491
9117
  const callee = stmt.expression.callee;
7492
- if (_optionalChain([callee, 'optionalAccess', _525 => _525.type]) === "FunctionExpression") {
7493
- const name = _optionalChain([callee, 'access', _526 => _526.id, 'optionalAccess', _527 => _527.name]);
7494
- if (typeof name === "string" && (name.startsWith("_u$") || name.startsWith("_$") || name.startsWith("_s") || name.startsWith("$b") || containsUnpeekShieldMarker(callee.body))) {
9118
+ if (_optionalChain([callee, 'optionalAccess', _587 => _587.type]) === "FunctionExpression") {
9119
+ const name = _optionalChain([callee, 'access', _588 => _588.id, 'optionalAccess', _589 => _589.name]);
9120
+ if (typeof name === "string" && name.startsWith("_u$") || containsUnpeekShieldMarker(callee.body)) {
7495
9121
  return true;
7496
9122
  }
7497
9123
  }
@@ -7502,7 +9128,7 @@ function isAstAlreadyProtected(ast) {
7502
9128
  function transformJavaScript(code, options = {}) {
7503
9129
  const internalOptions = options;
7504
9130
  const seed = _nullishCoalesce(internalOptions.seed, () => ( 2654435769));
7505
- const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([options, 'access', _528 => _528.config, 'optionalAccess', _529 => _529.vault, 'optionalAccess', _530 => _530.minStringLength]))), () => ( 4));
9131
+ const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([options, 'access', _590 => _590.config, 'optionalAccess', _591 => _591.vault, 'optionalAccess', _592 => _592.minStringLength]))), () => ( 4));
7506
9132
  const isAggressive = _nullishCoalesce(options.aggressive, () => ( false));
7507
9133
  if (!code || !code.trim()) {
7508
9134
  const emptyResult = {
@@ -7567,8 +9193,9 @@ function transformJavaScript(code, options = {}) {
7567
9193
  const boundary = classifyChunkBoundary(ast);
7568
9194
  attachMagicComments(boundary.importExpressions, comments);
7569
9195
  const effectiveConfig = options.critical ? { ..._nullishCoalesce(options.config, () => ( {})), critical: options.critical } : options.config;
7570
- const effectiveProfile = _nullishCoalesce(options.profile, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _531 => _531.profile])));
7571
- const hotRes = analyzeAstHotPaths(ast, effectiveConfig);
9196
+ const effectiveProfile = _nullishCoalesce(options.profile, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _593 => _593.profile])));
9197
+ const originalSourceMap = internalOptions.originalSourceMap;
9198
+ const hotRes = analyzeAstHotPaths(ast, effectiveConfig, originalSourceMap);
7572
9199
  const {
7573
9200
  report: hotPathReport,
7574
9201
  coldFunctionNodes,
@@ -7577,7 +9204,7 @@ function transformJavaScript(code, options = {}) {
7577
9204
  serializedFunctionNodes
7578
9205
  } = hotRes;
7579
9206
  const criticalFunctionNodes = hotRes.criticalFunctionNodes;
7580
- if (options.scrubPaths || _optionalChain([effectiveConfig, 'optionalAccess', _532 => _532.scrubPaths])) {
9207
+ if (options.scrubPaths || _optionalChain([effectiveConfig, 'optionalAccess', _594 => _594.scrubPaths])) {
7581
9208
  scrubResidualPaths(
7582
9209
  ast,
7583
9210
  {
@@ -7589,24 +9216,31 @@ function transformJavaScript(code, options = {}) {
7589
9216
  );
7590
9217
  }
7591
9218
  const shieldCoupled = _nullishCoalesce(internalOptions.shieldCoupled, () => ( Boolean(internalOptions.injectRuntimeShield)));
7592
- const deterrentMode = _nullishCoalesce(_nullishCoalesce(internalOptions.deterrentMode, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _533 => _533.shield, 'optionalAccess', _534 => _534.deterrentMode]))), () => ( "passive"));
7593
- const detectHeadless = _nullishCoalesce(_nullishCoalesce(internalOptions.detectHeadless, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _535 => _535.shield, 'optionalAccess', _536 => _536.detectHeadless]))), () => ( false));
9219
+ const deterrentMode = _nullishCoalesce(_nullishCoalesce(internalOptions.deterrentMode, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _595 => _595.shield, 'optionalAccess', _596 => _596.deterrentMode]))), () => ( "passive"));
9220
+ const detectHeadless = _nullishCoalesce(_nullishCoalesce(internalOptions.detectHeadless, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _597 => _597.shield, 'optionalAccess', _598 => _598.detectHeadless]))), () => ( false));
7594
9221
  const sym = shieldCoupled ? _nullishCoalesce(internalOptions.windowKeySymbol, () => ( deriveWindowKeySymbol(seed))) : void 0;
7595
9222
  let shieldDelta = shieldCoupled ? internalOptions.expectedDelta : void 0;
7596
- if (shieldCoupled && shieldDelta === void 0) {
9223
+ let expectedStateHash = shieldCoupled ? internalOptions.expectedStateHash : void 0;
9224
+ if (shieldCoupled && (shieldDelta === void 0 || expectedStateHash === void 0)) {
7597
9225
  const shieldInfo = generateRuntimeShield({
7598
9226
  seed,
7599
9227
  windowKeySymbol: sym,
7600
9228
  deterrentMode,
7601
9229
  detectHeadless
7602
9230
  });
7603
- shieldDelta = _nullishCoalesce(shieldInfo.expectedDelta, () => ( 0));
9231
+ if (shieldDelta === void 0) {
9232
+ shieldDelta = _nullishCoalesce(shieldInfo.expectedDelta, () => ( 0));
9233
+ }
9234
+ if (expectedStateHash === void 0) {
9235
+ expectedStateHash = shieldInfo.expectedStateHash;
9236
+ }
7604
9237
  }
7605
9238
  let virtualizedFunctionsCount = 0;
7606
9239
  if (isAggressive) {
7607
- const extraVmOpts = criticalFunctionNodes || _optionalChain([effectiveConfig, 'optionalAccess', _537 => _537.critical, 'optionalAccess', _538 => _538.maxFunctionsPerChunk]) !== void 0 ? {
9240
+ const extraVmOpts = criticalFunctionNodes || _optionalChain([effectiveConfig, 'optionalAccess', _599 => _599.critical, 'optionalAccess', _600 => _600.maxFunctionsPerChunk]) !== void 0 || expectedStateHash !== void 0 ? {
7608
9241
  ...criticalFunctionNodes ? { criticalFunctionNodes } : {},
7609
- ..._optionalChain([effectiveConfig, 'optionalAccess', _539 => _539.critical, 'optionalAccess', _540 => _540.maxFunctionsPerChunk]) !== void 0 ? { maxFunctionsPerChunk: effectiveConfig.critical.maxFunctionsPerChunk } : {}
9242
+ ..._optionalChain([effectiveConfig, 'optionalAccess', _601 => _601.critical, 'optionalAccess', _602 => _602.maxFunctionsPerChunk]) !== void 0 ? { maxFunctionsPerChunk: effectiveConfig.critical.maxFunctionsPerChunk } : {},
9243
+ ...expectedStateHash !== void 0 ? { expectedStateHash } : {}
7610
9244
  } : void 0;
7611
9245
  const vmRes = extraVmOpts ? applyMicroVm(
7612
9246
  ast,
@@ -7626,8 +9260,16 @@ function transformJavaScript(code, options = {}) {
7626
9260
  );
7627
9261
  virtualizedFunctionsCount = vmRes.virtualizedCount;
7628
9262
  }
7629
- if (effectiveProfile !== "minimal" && _optionalChain([effectiveConfig, 'optionalAccess', _541 => _541.coldFlow]) !== false) {
7630
- applyColdFlowGuard(ast, coldFunctionNodes, seed, hotExemptNodes);
9263
+ if (effectiveProfile !== "minimal" && _optionalChain([effectiveConfig, 'optionalAccess', _603 => _603.coldFlow]) !== false) {
9264
+ applyColdFlowGuard(
9265
+ ast,
9266
+ coldFunctionNodes,
9267
+ seed,
9268
+ hotExemptNodes,
9269
+ sym,
9270
+ shieldDelta,
9271
+ shieldCoupled
9272
+ );
7631
9273
  }
7632
9274
  const mangledSymbolsCount = applyPolymorphicMangler(
7633
9275
  ast,
@@ -7730,4 +9372,11 @@ ${finalCode}`;
7730
9372
 
7731
9373
 
7732
9374
 
7733
- exports.computeFnv1aHash = computeFnv1aHash; exports.detectHotPaths = detectHotPaths; exports.computeIntegrityHash = computeIntegrityHash; exports.verifyCodeIntegrity = verifyCodeIntegrity; exports.deriveWindowKeySymbol = deriveWindowKeySymbol; exports.createDeterrentSnippet = createDeterrentSnippet; exports.generateRuntimeShield = generateRuntimeShield; exports.transformJavaScript = transformJavaScript;
9375
+
9376
+
9377
+
9378
+
9379
+
9380
+
9381
+
9382
+ exports.computeFnv1aHash = computeFnv1aHash; exports.flattenSourceMapSections = flattenSourceMapSections; exports.shiftSourceMapLines = shiftSourceMapLines; exports.computeDeterministicDebugId = computeDeterministicDebugId; exports.chainSourceMaps = chainSourceMaps; exports.resolvePosition = resolvePosition; exports.safeDecodeURIComponent = safeDecodeURIComponent; exports.symbolicateStackTrace = symbolicateStackTrace; exports.detectHotPaths = detectHotPaths; exports.computeIntegrityHash = computeIntegrityHash; exports.verifyCodeIntegrity = verifyCodeIntegrity; exports.deriveWindowKeySymbol = deriveWindowKeySymbol; exports.createDeterrentSnippet = createDeterrentSnippet; exports.generateRuntimeShield = generateRuntimeShield; exports.transformJavaScript = transformJavaScript;