unpeek 4.0.0 → 4.0.1

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 (34) hide show
  1. package/README.md +7 -6
  2. package/README.tr.md +6 -5
  3. package/dist/adapters/esbuild.cjs +5 -5
  4. package/dist/adapters/esbuild.js +3 -3
  5. package/dist/adapters/next/adapter.cjs +5 -5
  6. package/dist/adapters/next/adapter.js +4 -4
  7. package/dist/adapters/next/index.cjs +5 -5
  8. package/dist/adapters/next/index.js +4 -4
  9. package/dist/adapters/rollup.cjs +5 -5
  10. package/dist/adapters/rollup.js +3 -3
  11. package/dist/adapters/rspack.cjs +5 -5
  12. package/dist/adapters/rspack.js +3 -3
  13. package/dist/adapters/vite.cjs +5 -5
  14. package/dist/adapters/vite.js +3 -3
  15. package/dist/adapters/webpack.cjs +5 -5
  16. package/dist/adapters/webpack.js +3 -3
  17. package/dist/browser.cjs +2 -2
  18. package/dist/browser.js +1 -1
  19. package/dist/{chunk-3LWXEJU6.cjs → chunk-3GDHYBVH.cjs} +56 -18
  20. package/dist/{chunk-YCRMTXOE.js → chunk-4G2HCME5.js} +2 -2
  21. package/dist/{chunk-2JU3V7HW.js → chunk-4SOS3LRV.js} +50 -9
  22. package/dist/{chunk-7HXLHLLQ.cjs → chunk-7ZEVJ4OR.cjs} +121 -29
  23. package/dist/{chunk-4FNZNIBW.js → chunk-LGTXAAZH.js} +686 -344
  24. package/dist/{chunk-KLYFNMKS.cjs → chunk-M46SFJE7.cjs} +813 -471
  25. package/dist/{chunk-ZG7BIAUI.cjs → chunk-NNAAPDUS.cjs} +58 -17
  26. package/dist/{chunk-VG4Y26ZN.cjs → chunk-OTA75YI6.cjs} +14 -14
  27. package/dist/{chunk-ADKRENAP.js → chunk-TYL32LUK.js} +46 -8
  28. package/dist/{chunk-HHC7BUCK.js → chunk-XYN5NYSD.js} +95 -3
  29. package/dist/cli/index.js +921 -372
  30. package/dist/index.cjs +184 -45
  31. package/dist/index.js +170 -31
  32. package/dist/plugins/unplugin.cjs +4 -4
  33. package/dist/plugins/unplugin.js +3 -3
  34. package/package.json +1 -1
@@ -97,6 +97,8 @@ var DEFAULT_HOC_WRAPPERS = /* @__PURE__ */ new Set([
97
97
  "connect"
98
98
  ]);
99
99
  var DEFAULT_EVENT_HANDLER_REGEX = /^(?:on|handle)(?!Tick|Render|Update|Frame|Animate|Physics)[A-Z]/;
100
+ var CRITICAL_COLD_HANDLER_REGEX = /^(?:onSubmit|handleSubmit|submit[A-Z0-9_]*|validate[A-Z0-9_]*|login|signIn|register|checkout)$/i;
101
+ var CRITICAL_COLD_CALLEE_REGEX = /^(?:onSubmit|handleSubmit|submit[A-Z0-9_]*|validate[A-Z0-9_]*|login|signIn|register|checkout|createServerReference|fetch)$/i;
100
102
  var DEFAULT_HOOK_REGEX = /^use[A-Z0-9]/;
101
103
  var REACT_HOOK_OR_RENDER_CALLS = /* @__PURE__ */ new Set([
102
104
  "useState",
@@ -882,6 +884,26 @@ function analyzeAstHotPaths(ast, config) {
882
884
  }
883
885
  }
884
886
  }
887
+ for (const fn of allFunctions) {
888
+ if (!serializedWorkerNodes.has(fn.node) && !trueHotNodes.has(fn.node) && !shallowComponentNodes.has(fn.node) && !containsLoopOrAnimation(fn.node, animationCalls)) {
889
+ let isCriticalHandler = CRITICAL_COLD_HANDLER_REGEX.test(fn.name);
890
+ if (!isCriticalHandler) {
891
+ const callees = callerToCallees.get(fn.node);
892
+ if (callees) {
893
+ for (const cName of callees) {
894
+ const bare = cName.includes(".") ? cName.split(".").pop() : cName;
895
+ if (CRITICAL_COLD_CALLEE_REGEX.test(bare)) {
896
+ isCriticalHandler = true;
897
+ break;
898
+ }
899
+ }
900
+ }
901
+ }
902
+ if (isCriticalHandler) {
903
+ coldForcedNodes.add(fn.node);
904
+ }
905
+ }
906
+ }
885
907
  const calleeToCallers = /* @__PURE__ */ new Map();
886
908
  for (const [callerNode, calleeNames] of callerToCallees.entries()) {
887
909
  for (const cName of calleeNames) {
@@ -923,9 +945,10 @@ function analyzeAstHotPaths(ast, config) {
923
945
  hotFunctionNodes.delete(node);
924
946
  hotExemptNodes.delete(node);
925
947
  }
926
- const astComments = _nullishCoalesce(_nullishCoalesce(_optionalChain([ast, 'optionalAccess', _158 => _158.__unpeekComments]), () => ( _optionalChain([ast, 'optionalAccess', _159 => _159.comments]))), () => ( []));
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]))), () => ( []));
927
950
  const criticalComments = astComments.filter(
928
- (c) => typeof _optionalChain([c, 'optionalAccess', _160 => _160.value]) === "string" && c.value.includes("@unpeek-critical")
951
+ (c) => typeof _optionalChain([c, 'optionalAccess', _162 => _162.value]) === "string" && c.value.includes(criticalAnnotation)
929
952
  );
930
953
  const criticalCommentNodes = /* @__PURE__ */ new Set();
931
954
  if (criticalComments.length > 0 && allFunctions.length > 0) {
@@ -954,7 +977,7 @@ function analyzeAstHotPaths(ast, config) {
954
977
  }
955
978
  }
956
979
  }
957
- const rawCriticalInclude = _optionalChain([config, 'optionalAccess', _161 => _161.critical, 'optionalAccess', _162 => _162.include]);
980
+ const rawCriticalInclude = _optionalChain([config, 'optionalAccess', _163 => _163.critical, 'optionalAccess', _164 => _164.include]);
958
981
  const criticalIncludeList = Array.isArray(rawCriticalInclude) ? rawCriticalInclude : rawCriticalInclude !== void 0 ? [rawCriticalInclude] : [];
959
982
  const criticalIncludeMatchers = [];
960
983
  for (const pat of criticalIncludeList) {
@@ -1021,30 +1044,89 @@ function computeNormalizedIntegrityHash(source, seed = 0) {
1021
1044
  (FNV_OFFSET_BASIS ^ seed >>> 0) >>> 0
1022
1045
  );
1023
1046
  }
1024
- function isNativeDescriptorIntact() {
1025
- if (typeof Reflect === "undefined" || typeof Reflect.apply !== "function") {
1047
+ var NATIVE_BUILTIN_RE = /^function (\w+)\(\)\s*\{\s*\[native code\]\s*\}$/;
1048
+ function hasTamperedDescriptor(obj, key) {
1049
+ try {
1050
+ let cur = _nullishCoalesce(obj, () => ( null));
1051
+ while (cur) {
1052
+ const desc = Object.getOwnPropertyDescriptor(cur, key);
1053
+ if (desc && (desc.set || !desc.writable)) {
1054
+ return true;
1055
+ }
1056
+ cur = Object.getPrototypeOf(cur);
1057
+ }
1058
+ return false;
1059
+ } catch (e4) {
1060
+ return true;
1061
+ }
1062
+ }
1063
+ function isNativeBuiltinSignature(fn, expectedName, expectedLength, toStr) {
1064
+ if (typeof fn !== "function" || Reflect.has(fn, "prototype") || fn.name !== expectedName || fn.length !== expectedLength) {
1065
+ return false;
1066
+ }
1067
+ try {
1068
+ const direct = Reflect.apply(toStr, fn, []);
1069
+ const nested = Reflect.apply(Reflect.apply, null, [toStr, fn, []]);
1070
+ if (typeof direct !== "string" || direct !== nested) {
1071
+ return false;
1072
+ }
1073
+ const match = NATIVE_BUILTIN_RE.exec(direct);
1074
+ return !!match && match[1] === expectedName;
1075
+ } catch (e5) {
1026
1076
  return false;
1027
1077
  }
1078
+ }
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]} (` : "";
1028
1084
  try {
1029
- Reflect.apply(Object.getOwnPropertyDescriptor, null, []);
1085
+ Reflect.apply(fn, thisArg, args);
1030
1086
  return false;
1031
1087
  } catch (err) {
1032
- if (!(err instanceof TypeError)) {
1088
+ const isTypeError = err instanceof TypeError || err !== null && typeof err === "object" && err.name === "TypeError";
1089
+ if (!isTypeError) {
1033
1090
  return false;
1034
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)) {
1096
+ return false;
1097
+ }
1098
+ } else if (stack && /(?:Object|Proxy)\.apply\b/.test(stack)) {
1099
+ return false;
1100
+ }
1101
+ return true;
1102
+ }
1103
+ }
1104
+ function isNativeDescriptorIntact() {
1105
+ if (typeof Reflect === "undefined" || typeof Reflect.apply !== "function") {
1106
+ return false;
1107
+ }
1108
+ if (hasTamperedDescriptor(Function.prototype, "toString") || hasTamperedDescriptor(Function.prototype, "call") || hasTamperedDescriptor(Reflect, "apply")) {
1109
+ return false;
1035
1110
  }
1036
1111
  const toStr = Function.prototype.toString;
1037
- if (typeof toStr !== "function" || Reflect.has(toStr, "prototype") || toStr.name !== "toString" || toStr.length !== 0) {
1112
+ const reflectApply = Reflect.apply;
1113
+ const fnCall = Function.prototype.call;
1114
+ if (!isNativeBuiltinSignature(reflectApply, "apply", 3, toStr) || !isNativeBuiltinSignature(toStr, "toString", 0, toStr) || !isNativeBuiltinSignature(fnCall, "call", 1, toStr)) {
1038
1115
  return false;
1039
1116
  }
1040
- try {
1041
- Reflect.apply(toStr, { toString() {
1042
- } }, []);
1117
+ if (!probeThrowsCleanTypeError(Object.getOwnPropertyDescriptor, null, []) || !probeThrowsCleanTypeError(toStr, { toString() {
1118
+ } }, []) || !probeThrowsCleanTypeError(reflectApply, toStr, [null, toStr, []])) {
1043
1119
  return false;
1044
- } catch (err) {
1045
- if (!(err instanceof TypeError)) {
1120
+ }
1121
+ try {
1122
+ const probeFn = function() {
1123
+ };
1124
+ const expectedProbe = reflectApply(toStr, probeFn, []);
1125
+ if (toStr.call(probeFn) !== expectedProbe || fnCall.call(toStr, probeFn) !== expectedProbe) {
1046
1126
  return false;
1047
1127
  }
1128
+ } catch (e6) {
1129
+ return false;
1048
1130
  }
1049
1131
  return true;
1050
1132
  }
@@ -1060,11 +1142,12 @@ function verifyCodeIntegrity(fnOrSource, expectedHash, seed = 0, normalized = fa
1060
1142
  try {
1061
1143
  const toStr = Function.prototype.toString;
1062
1144
  const selfStr = Reflect.apply(toStr, toStr, []);
1063
- if (typeof selfStr !== "string" || selfStr.indexOf("[native code]") < 0) {
1145
+ const match = typeof selfStr === "string" ? NATIVE_BUILTIN_RE.exec(selfStr) : null;
1146
+ if (!match || match[1] !== "toString") {
1064
1147
  return false;
1065
1148
  }
1066
1149
  raw = Reflect.apply(toStr, fnOrSource, []);
1067
- } catch (e4) {
1150
+ } catch (e7) {
1068
1151
  return false;
1069
1152
  }
1070
1153
  } else {
@@ -1112,24 +1195,25 @@ var DISALLOWED_IDENTS = /* @__PURE__ */ new Set([
1112
1195
  function derivePolymorphicIdent(seed, role) {
1113
1196
  let h = (2166136261 ^ seed >>> 0) >>> 0;
1114
1197
  for (let i = 0; i < role.length; i++) {
1115
- h ^= role.charCodeAt(i);
1198
+ h = (h ^ role.charCodeAt(i)) >>> 0;
1116
1199
  h = Math.imul(h, 16777619) >>> 0;
1117
1200
  }
1118
- h ^= h >>> 16;
1201
+ h = (h ^ h >>> 16) >>> 0;
1119
1202
  h = Math.imul(h, 2246822507) >>> 0;
1120
- h ^= h >>> 13;
1203
+ h = (h ^ h >>> 13) >>> 0;
1121
1204
  h = Math.imul(h, 3266489909) >>> 0;
1122
- h ^= h >>> 16;
1205
+ h = (h ^ h >>> 16) >>> 0;
1123
1206
  for (let attempt = 0; attempt < 32; attempt++) {
1124
- const c0 = IDENT_START_CHARS[h % IDENT_START_CHARS.length];
1125
- const c1 = IDENT_CONT_CHARS[(h >>> 6) % IDENT_CONT_CHARS.length];
1126
- const c2 = IDENT_CONT_CHARS[(h >>> 12) % IDENT_CONT_CHARS.length];
1127
- const c3 = IDENT_CONT_CHARS[(h >>> 18) % IDENT_CONT_CHARS.length];
1207
+ const u = h >>> 0;
1208
+ const c0 = IDENT_START_CHARS[u % IDENT_START_CHARS.length];
1209
+ const c1 = IDENT_CONT_CHARS[(u >>> 6) % IDENT_CONT_CHARS.length];
1210
+ const c2 = IDENT_CONT_CHARS[(u >>> 12) % IDENT_CONT_CHARS.length];
1211
+ const c3 = IDENT_CONT_CHARS[(u >>> 18) % IDENT_CONT_CHARS.length];
1128
1212
  const ident = `${c0}${c1}${c2}${c3}`;
1129
1213
  if (!DISALLOWED_IDENTS.has(ident) && !ident.startsWith("__") && !ident.startsWith("_u") && !ident.startsWith("_0")) {
1130
1214
  return ident;
1131
1215
  }
1132
- h = Math.imul(h ^ 2654435769 + attempt, 2246822507) >>> 0;
1216
+ h = Math.imul(u ^ 2654435769 + attempt, 2246822507) >>> 0;
1133
1217
  }
1134
1218
  return `_${(h >>> 0).toString(36).slice(0, 3).padStart(3, "0")}`;
1135
1219
  }
@@ -1226,24 +1310,24 @@ function getLeadingNode(state, node, parentNode, isRightHand = false) {
1226
1310
  cur = cur.left;
1227
1311
  right = false;
1228
1312
  } else if (cur.type === "ConditionalExpression") {
1229
- const prec = _optionalChain([state, 'optionalAccess', _163 => _163.expressionsPrecedence, 'optionalAccess', _164 => _164[_optionalChain([cur, 'access', _165 => _165.test, 'optionalAccess', _166 => _166.type])]]);
1230
- if (prec === NEEDS_PARENTHESES || prec <= _optionalChain([state, 'optionalAccess', _167 => _167.expressionsPrecedence, 'optionalAccess', _168 => _168.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])) {
1231
1315
  return null;
1232
1316
  }
1233
1317
  parent = cur;
1234
1318
  cur = cur.test;
1235
1319
  right = false;
1236
1320
  } else if (cur.type === "MemberExpression") {
1237
- const prec = _optionalChain([state, 'optionalAccess', _169 => _169.expressionsPrecedence, 'optionalAccess', _170 => _170[_optionalChain([cur, 'access', _171 => _171.object, 'optionalAccess', _172 => _172.type])]]);
1238
- if (prec === NEEDS_PARENTHESES || prec < _optionalChain([state, 'optionalAccess', _173 => _173.expressionsPrecedence, 'optionalAccess', _174 => _174.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])) {
1239
1323
  return null;
1240
1324
  }
1241
1325
  parent = cur;
1242
1326
  cur = cur.object;
1243
1327
  right = false;
1244
1328
  } else if (cur.type === "CallExpression") {
1245
- const prec = _optionalChain([state, 'optionalAccess', _175 => _175.expressionsPrecedence, 'optionalAccess', _176 => _176[_optionalChain([cur, 'access', _177 => _177.callee, 'optionalAccess', _178 => _178.type])]]);
1246
- if (prec === NEEDS_PARENTHESES || prec < _optionalChain([state, 'optionalAccess', _179 => _179.expressionsPrecedence, 'optionalAccess', _180 => _180.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])) {
1247
1331
  return null;
1248
1332
  }
1249
1333
  parent = cur;
@@ -1254,8 +1338,8 @@ function getLeadingNode(state, node, parentNode, isRightHand = false) {
1254
1338
  cur = cur.expression;
1255
1339
  right = false;
1256
1340
  } else if (cur.type === "TaggedTemplateExpression") {
1257
- const prec = _optionalChain([state, 'optionalAccess', _181 => _181.expressionsPrecedence, 'optionalAccess', _182 => _182[_optionalChain([cur, 'access', _183 => _183.tag, 'optionalAccess', _184 => _184.type])]]);
1258
- if (prec === NEEDS_PARENTHESES || prec < _optionalChain([state, 'optionalAccess', _185 => _185.expressionsPrecedence, 'optionalAccess', _186 => _186.CallExpression])) {
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])) {
1259
1343
  return null;
1260
1344
  }
1261
1345
  parent = cur;
@@ -1612,7 +1696,7 @@ var compactGenerator = Object.assign({}, _astring.baseGenerator, {
1612
1696
  },
1613
1697
  ImportExpression(node, state) {
1614
1698
  state.write("import(");
1615
- if (Array.isArray(_optionalChain([node, 'access', _187 => _187.source, 'optionalAccess', _188 => _188.comments])) && node.source.comments.length > 0) {
1699
+ if (Array.isArray(_optionalChain([node, 'access', _189 => _189.source, 'optionalAccess', _190 => _190.comments])) && node.source.comments.length > 0) {
1616
1700
  for (const c of node.source.comments) {
1617
1701
  state.write(c.type === "Block" ? `/*${c.value}*/` : `//${c.value}
1618
1702
  `);
@@ -1762,13 +1846,12 @@ function createDeterrentSnippet(config) {
1762
1846
  const detectHeadless = _nullishCoalesce(config.detectHeadless, () => ( false));
1763
1847
  const fnName = deriveIntegrityFnName(seed);
1764
1848
  const sym = _nullishCoalesce(config.windowKeySymbol, () => ( deriveWindowKeySymbol(seed)));
1765
- const consoleSilence = deterrentMode === "gradual" ? "for(var k in console)console[k]=function(){return 0;};" : "";
1849
+ const consoleSilence = deterrentMode === "gradual" ? "for(var k in console)console[k]=()=>0;" : "";
1766
1850
  const symLit = JSON.stringify(sym);
1767
- const stateLit = JSON.stringify(`${sym}_s`);
1768
1851
  const headlessDecl = detectHeadless ? ",n=w.navigator||0" : "";
1769
1852
  const headlessCond = detectHeadless ? "||n.webdriver||/HeadlessChrome/.test(n.userAgent)" : "";
1770
1853
  const k1Mul = (seed | 1) >>> 0;
1771
- return `(function ${fnName}(w){var G=typeof globalThis<'u'?globalThis:w;if(w){var O=Object,P=O.getOwnPropertyDescriptor,GP=O.getPrototypeOf,R=typeof Reflect<'u'&&Reflect.apply,SP=String.prototype,Q='__unpeek_',y=${symLit},z=${stateLit},U='__unpeek_tampered',T=function(o,k){try{while(o){var r=P&&P(o,k);if(r&&(r.set||!r.writable))return 1;o=GP?GP(o):0;}}catch(e){return 1;}},B=function(k,v,c){try{if(!c||!T(G,k))G[k]=v;}catch(e){}try{if(!c||!T(w,k))w[k]=v;}catch(e){}},s=Function.prototype.toString${headlessDecl},src='',t=0;if((G[z]||w[z]||0)[0]==2)t=1;try{if(typeof R!='function')t=1;else{var E=function(f,a,b){try{R(f,a,b);t=1;}catch(e){t|=!e||(!(e instanceof TypeError)&&e.name!='TypeError');}};E(P,null,[]);E(s,{toString(){}},[]);src=R(s,${fnName},[]);if(typeof s!='function'||'prototype'in s||s.name!='toString'||s.length!=0||R(s,s,[]).indexOf('[native code]')<0||/\\n/.test(src)${headlessCond})t=1;}}catch(e){t=1;}for(var j in K=[y,z,U])if(T(w,K[j])||T(G,K[j]))t=1;if(T(SP,'_u'))t=1;for(var h=0x811c9dc5,i=0;i<src.length;i++)h=Math.imul(h^src.charCodeAt(i),0x01000193)>>>0;var d=h&65535,k0=(h^${seed})>>>0,k1=(h^${k1Mul})>>>0,nc=(d^(h>>>16))>>>0;B(z,[t?2:1,k0^t,k1^t,1,nc],t);if(t){var pd=(d^((h>>>16^0x5a5b)||1))&65535;B(y,pd,1);B(y+'_t',!0);B(Q+'delta',pd);try{SP._u=14;}catch(e){}B(Q+'seed',((w.__unpeek_seed||${seed})^1)>>>0);B(U,!0);try{${consoleSilence}w.dispatchEvent&&w.dispatchEvent(new CustomEvent('unpeek:tamper'));}catch(e){}}else B(y,d);}})(typeof window!=='undefined'?window:typeof self<'u'?self:typeof globalThis<'u'?globalThis: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);`;
1772
1855
  }
1773
1856
 
1774
1857
  // src/runtime/index.ts
@@ -2449,8 +2532,8 @@ function fallbackKdf(fnId, callSiteSalt, shieldHash, seed) {
2449
2532
  function isWasmVaultAlreadyInjected(ast) {
2450
2533
  if (!ast || !Array.isArray(ast.body)) return false;
2451
2534
  return ast.body.some((stmt) => {
2452
- if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _189 => _189.declarations, 'optionalAccess', _190 => _190.some, 'call', _191 => _191(
2453
- (d) => _optionalChain([d, 'access', _192 => _192.id, 'optionalAccess', _193 => _193.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
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")
2454
2537
  )])) {
2455
2538
  return true;
2456
2539
  }
@@ -2463,11 +2546,11 @@ function injectWasmVault(ast, seed = 2654435769) {
2463
2546
  const wasmVarName = `_wb${suffix}`;
2464
2547
  if (isWasmVaultAlreadyInjected(ast)) {
2465
2548
  const existing = ast.body.find(
2466
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _194 => _194.declarations, 'optionalAccess', _195 => _195.some, 'call', _196 => _196(
2467
- (d) => _optionalChain([d, 'access', _197 => _197.id, 'optionalAccess', _198 => _198.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_wKdf")
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")
2468
2551
  )])
2469
2552
  );
2470
- const id = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _199 => _199.declarations, 'access', _200 => _200[0], 'optionalAccess', _201 => _201.id, 'optionalAccess', _202 => _202.name]), () => ( kdfFnName));
2553
+ const id = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _201 => _201.declarations, 'access', _202 => _202[0], 'optionalAccess', _203 => _203.id, 'optionalAccess', _204 => _204.name]), () => ( kdfFnName));
2471
2554
  return {
2472
2555
  kdfFnName: id,
2473
2556
  wasmBytes: generateWasmKdfBinary(seed),
@@ -2550,7 +2633,7 @@ function injectWasmVault(ast, seed = 2654435769) {
2550
2633
  let insertIdx = 0;
2551
2634
  while (insertIdx < ast.body.length) {
2552
2635
  const stmt = ast.body[insertIdx];
2553
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _203 => _203.expression, 'optionalAccess', _204 => _204.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
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()));
2554
2637
  if (isDirective || stmt.type === "ImportDeclaration") {
2555
2638
  insertIdx++;
2556
2639
  } else {
@@ -2581,7 +2664,7 @@ function isWebpackModuleMap(node) {
2581
2664
  return false;
2582
2665
  }
2583
2666
  return node.properties.some(
2584
- (p) => _optionalChain([p, 'optionalAccess', _205 => _205.type]) === "Property" && (_optionalChain([p, 'access', _206 => _206.value, 'optionalAccess', _207 => _207.type]) === "FunctionExpression" || _optionalChain([p, 'access', _208 => _208.value, 'optionalAccess', _209 => _209.type]) === "ArrowFunctionExpression")
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")
2585
2668
  );
2586
2669
  }
2587
2670
  function exemptWebpackPushArg(arg, exemptSubtreeRoots) {
@@ -2600,16 +2683,53 @@ function exemptWebpackPushArg(arg, exemptSubtreeRoots) {
2600
2683
  }
2601
2684
  exemptSubtreeRoots.add(arg);
2602
2685
  }
2686
+ function exemptTurbopackPropertyKeys(objNode, exemptSubtreeRoots) {
2687
+ if (!Array.isArray(_optionalChain([objNode, 'optionalAccess', _212 => _212.properties]))) return;
2688
+ for (const prop of objNode.properties) {
2689
+ if (_optionalChain([prop, 'optionalAccess', _213 => _213.type]) === "Property" && prop.key && typeof prop.key === "object") {
2690
+ exemptSubtreeRoots.add(prop.key);
2691
+ }
2692
+ }
2693
+ }
2694
+ function exemptTurbopackPushArg(arg, exemptSubtreeRoots) {
2695
+ if (!arg || typeof arg !== "object") return;
2696
+ if (arg.type === "ArrayExpression" && Array.isArray(arg.elements)) {
2697
+ for (let i = 0; i < arg.elements.length; i++) {
2698
+ const el = arg.elements[i];
2699
+ if (!el || typeof el !== "object") continue;
2700
+ if (i === 0) {
2701
+ exemptSubtreeRoots.add(el);
2702
+ continue;
2703
+ }
2704
+ if (el.type === "Literal") {
2705
+ exemptSubtreeRoots.add(el);
2706
+ } else if (el.type === "ObjectExpression") {
2707
+ exemptTurbopackPropertyKeys(el, exemptSubtreeRoots);
2708
+ } else if (el.type === "FunctionExpression" || el.type === "ArrowFunctionExpression") {
2709
+ continue;
2710
+ }
2711
+ }
2712
+ return;
2713
+ }
2714
+ if (arg.type === "ObjectExpression") {
2715
+ exemptTurbopackPropertyKeys(arg, exemptSubtreeRoots);
2716
+ return;
2717
+ }
2718
+ if (arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression") {
2719
+ return;
2720
+ }
2721
+ exemptSubtreeRoots.add(arg);
2722
+ }
2603
2723
  function isHostMember(node, matcher) {
2604
2724
  if (!node) return false;
2605
2725
  if (node.type === "Identifier" && matchesPropName(node.name, matcher)) {
2606
2726
  return true;
2607
2727
  }
2608
- if (node.type === "MemberExpression" && (_optionalChain([node, 'access', _210 => _210.object, 'optionalAccess', _211 => _211.type]) === "Identifier" && GLOBAL_HOSTS.has(node.object.name) || _optionalChain([node, 'access', _212 => _212.object, 'optionalAccess', _213 => _213.type]) === "ThisExpression")) {
2609
- if (!node.computed && _optionalChain([node, 'access', _214 => _214.property, 'optionalAccess', _215 => _215.type]) === "Identifier") {
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") {
2610
2730
  return matchesPropName(node.property.name, matcher);
2611
2731
  }
2612
- if (node.computed && _optionalChain([node, 'access', _216 => _216.property, 'optionalAccess', _217 => _217.type]) === "Literal" && typeof node.property.value === "string") {
2732
+ if (node.computed && _optionalChain([node, 'access', _220 => _220.property, 'optionalAccess', _221 => _221.type]) === "Literal" && typeof node.property.value === "string") {
2613
2733
  return matchesPropName(node.property.value, matcher);
2614
2734
  }
2615
2735
  }
@@ -2645,7 +2765,7 @@ function classifyChunkBoundary(ast) {
2645
2765
  walk2.simple(ast, {
2646
2766
  CallExpression(node) {
2647
2767
  const callee = node.callee;
2648
- const isPushCall = _optionalChain([callee, 'optionalAccess', _218 => _218.type]) === "MemberExpression" && (!callee.computed && _optionalChain([callee, 'access', _219 => _219.property, 'optionalAccess', _220 => _220.type]) === "Identifier" && callee.property.name === "push" || callee.computed && _optionalChain([callee, 'access', _221 => _221.property, 'optionalAccess', _222 => _222.type]) === "Literal" && callee.property.value === "push");
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");
2649
2769
  if (isPushCall) {
2650
2770
  if (unwrapAssignedHostMember(callee.object, "__next_f")) {
2651
2771
  hasRscFlight = true;
@@ -2658,12 +2778,13 @@ function classifyChunkBoundary(ast) {
2658
2778
  }
2659
2779
  } else if (unwrapAssignedHostMember(callee.object, "TURBOPACK")) {
2660
2780
  hasEntryBootstrap = true;
2661
- exemptSubtreeRoots.add(node);
2781
+ exemptSubtreeRoots.add(callee);
2782
+ if (callee.object && typeof callee.object === "object") {
2783
+ exemptSubtreeRoots.add(callee.object);
2784
+ }
2662
2785
  if (Array.isArray(node.arguments)) {
2663
2786
  for (const arg of node.arguments) {
2664
- if (arg && typeof arg === "object") {
2665
- exemptSubtreeRoots.add(arg);
2666
- }
2787
+ exemptTurbopackPushArg(arg, exemptSubtreeRoots);
2667
2788
  }
2668
2789
  }
2669
2790
  } else if (unwrapAssignedHostMember(callee.object, isWebpackOrRspackChunkName)) {
@@ -2684,13 +2805,13 @@ function classifyChunkBoundary(ast) {
2684
2805
  if (isHostMember(node.left, "TURBOPACK") || isHostMember(node.left, isWebpackOrRspackChunkName)) {
2685
2806
  hasEntryBootstrap = true;
2686
2807
  exemptSubtreeRoots.add(node);
2687
- } else if (_optionalChain([node, 'access', _223 => _223.left, 'optionalAccess', _224 => _224.type]) === "Identifier" && node.left.name === "__vite__mapDeps") {
2808
+ } else if (_optionalChain([node, 'access', _227 => _227.left, 'optionalAccess', _228 => _228.type]) === "Identifier" && node.left.name === "__vite__mapDeps") {
2688
2809
  hasPreloadManifest = true;
2689
2810
  exemptSubtreeRoots.add(node);
2690
2811
  }
2691
2812
  },
2692
2813
  VariableDeclarator(node) {
2693
- if (_optionalChain([node, 'access', _225 => _225.id, 'optionalAccess', _226 => _226.type]) === "Identifier") {
2814
+ if (_optionalChain([node, 'access', _229 => _229.id, 'optionalAccess', _230 => _230.type]) === "Identifier") {
2694
2815
  if (node.id.name === "__vite__mapDeps") {
2695
2816
  hasPreloadManifest = true;
2696
2817
  exemptSubtreeRoots.add(node);
@@ -2701,7 +2822,7 @@ function classifyChunkBoundary(ast) {
2701
2822
  }
2702
2823
  },
2703
2824
  FunctionDeclaration(node) {
2704
- if (_optionalChain([node, 'access', _227 => _227.id, 'optionalAccess', _228 => _228.type]) === "Identifier" && node.id.name === "__vite__mapDeps") {
2825
+ if (_optionalChain([node, 'access', _231 => _231.id, 'optionalAccess', _232 => _232.type]) === "Identifier" && node.id.name === "__vite__mapDeps") {
2705
2826
  hasPreloadManifest = true;
2706
2827
  exemptSubtreeRoots.add(node);
2707
2828
  }
@@ -2743,7 +2864,7 @@ function attachMagicComments(importExpressions, comments) {
2743
2864
  const magicComments = comments.filter((c) => MAGIC_COMMENT_RE.test(c.value));
2744
2865
  if (magicComments.length === 0) return;
2745
2866
  for (const expr of importExpressions) {
2746
- const src = _optionalChain([expr, 'optionalAccess', _229 => _229.source]);
2867
+ const src = _optionalChain([expr, 'optionalAccess', _233 => _233.source]);
2747
2868
  if (!src || typeof expr.start !== "number" || typeof src.start !== "number") {
2748
2869
  continue;
2749
2870
  }
@@ -2786,7 +2907,10 @@ function createSaltedDecryptorFnAst(seed, pChars, expectedDelta, windowKeySymbol
2786
2907
  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}";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;var tm=(G&&(G[_tk]===!0||G${flagAccess}===!0))||(w&&(w[_tk]===!0||w${flagAccess}===!0))||((""._u||a._u||0)!==0);if(!tm&&(i in m))return m[i];var d=tm?(((Math.imul(i+1,0x9e3779b1)^0x5a5b)&65535)|1):0;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)m[i]=o;return o;};`;
2787
2908
  } else {
2788
2909
  const edInit = buildRivestDeltaExpr(seed, expectedDelta, "_ed");
2789
- 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;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)||(sv!==void 0&&sv!==_ed);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;};`;
2910
+ const hasWindowKey = Boolean(windowKeySymbol);
2911
+ const brDecl = hasWindowKey ? `var _br=typeof window<"u"||typeof document<"u"||typeof self<"u";` : "";
2912
+ const svCheck = hasWindowKey ? `(sv===void 0?!_br:sv!==_ed)` : `(sv!==void 0&&sv!==_ed)`;
2913
+ 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;};`;
2790
2914
  }
2791
2915
  return acorn3.parse(`(function f(a){${fBody}})`, {
2792
2916
  ecmaVersion: "latest",
@@ -2834,8 +2958,8 @@ function encodeSaltedString(str, k) {
2834
2958
  function isAstAlreadySalted(ast) {
2835
2959
  if (!ast || !Array.isArray(ast.body)) return false;
2836
2960
  return ast.body.some((stmt) => {
2837
- if (stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _230 => _230.declarations, 'optionalAccess', _231 => _231.some, 'call', _232 => _232(
2838
- (d) => _optionalChain([d, 'access', _233 => _233.id, 'optionalAccess', _234 => _234.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uP")
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")
2839
2963
  )])) {
2840
2964
  return true;
2841
2965
  }
@@ -2866,167 +2990,253 @@ function applySaltedStringVault(ast, seed = 2654435769, minStringLength = 4, hot
2866
2990
  encryptedStringsCount: 0,
2867
2991
  integrityToken: computeFnv1aHash("already-salted", seed),
2868
2992
  vaultVarName: "",
2869
- decryptFnName: ""
2993
+ decryptFnName: "",
2994
+ shaderBuffersCount: 0
2870
2995
  };
2871
2996
  }
2872
- const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _235 => _235.vault, 'optionalAccess', _236 => _236.minStringLength]), () => ( minStringLength));
2997
+ const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _252 => _252.vault, 'optionalAccess', _253 => _253.minStringLength]), () => ( minStringLength));
2873
2998
  const activeDirectives = new Set(DIRECTIVE_STRINGS);
2874
- if (_optionalChain([config, 'optionalAccess', _237 => _237.vault, 'optionalAccess', _238 => _238.customDirectives])) {
2999
+ if (_optionalChain([config, 'optionalAccess', _254 => _254.vault, 'optionalAccess', _255 => _255.customDirectives])) {
2875
3000
  for (const dir of config.vault.customDirectives) {
2876
3001
  activeDirectives.add(dir);
2877
3002
  }
2878
3003
  }
2879
- const customReserved = _optionalChain([config, 'optionalAccess', _239 => _239.vault, 'optionalAccess', _240 => _240.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
3004
+ const customReserved = _optionalChain([config, 'optionalAccess', _256 => _256.vault, 'optionalAccess', _257 => _257.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
2880
3005
  const targetsToReplace = [];
2881
3006
  const encryptedPayloads = [];
3007
+ const shaderToIndex = /* @__PURE__ */ new Map();
3008
+ const shaderPayloads = [];
3009
+ const shaderTargets = [];
3010
+ function processSaltedCandidate(val, node, parent, ancestors) {
3011
+ if (isNodeInExemptSubtree(ancestors, exemptSubtreeRoots)) {
3012
+ return;
3013
+ }
3014
+ if (parent.type === "ExpressionStatement" && (Boolean(parent.directive) || activeDirectives.has(val))) {
3015
+ return;
3016
+ }
3017
+ for (let i = ancestors.length - 2; i >= 0; i--) {
3018
+ if (ancestors[i].type === "ExpressionStatement" && Boolean(ancestors[i].directive)) {
3019
+ return;
3020
+ }
3021
+ }
3022
+ let isHotExempt = false;
3023
+ if (hotExemptNodes) {
3024
+ for (let i = ancestors.length - 2; i >= 0; i--) {
3025
+ if (hotExemptNodes.has(ancestors[i])) {
3026
+ isHotExempt = true;
3027
+ break;
3028
+ }
3029
+ }
3030
+ }
3031
+ if (isShaderPayload(
3032
+ val,
3033
+ node,
3034
+ parent,
3035
+ ancestors,
3036
+ seed,
3037
+ isHotExempt,
3038
+ customReserved
3039
+ )) {
3040
+ let idx = shaderToIndex.get(val);
3041
+ if (idx === void 0) {
3042
+ idx = shaderPayloads.length;
3043
+ shaderToIndex.set(val, idx);
3044
+ shaderPayloads.push(val);
3045
+ }
3046
+ shaderTargets.push({ node, parent, idx });
3047
+ return;
3048
+ }
3049
+ if (isHotExempt) {
3050
+ return;
3051
+ }
3052
+ if (!shouldEncryptString(
3053
+ val,
3054
+ minLen,
3055
+ parent,
3056
+ activeDirectives,
3057
+ customReserved
3058
+ )) {
3059
+ return;
3060
+ }
3061
+ const callSiteIdx = targetsToReplace.length;
3062
+ const [saltLo, saltHi] = computeCallSiteSalt64(
3063
+ seed >>> 0,
3064
+ callSiteIdx >>> 0,
3065
+ seed >>> 0
3066
+ );
3067
+ const localSalt = ((saltLo ^ saltHi) & 2147483647 | 1) >>> 0;
3068
+ targetsToReplace.push({
3069
+ node,
3070
+ parent,
3071
+ callSiteIdx,
3072
+ localSalt,
3073
+ rawString: val
3074
+ });
3075
+ }
2882
3076
  walk3.ancestor(ast, {
2883
3077
  Literal(node, ancestors) {
2884
3078
  if (typeof node.value !== "string") return;
2885
- if (node.value.length < minLen) return;
2886
- if (activeDirectives.has(node.value)) return;
3079
+ const val = node.value;
3080
+ if (activeDirectives.has(val)) return;
2887
3081
  const parent = ancestors[ancestors.length - 2];
2888
3082
  if (!parent) return;
2889
- if (isNodeInExemptSubtree(ancestors, exemptSubtreeRoots)) {
3083
+ if ((parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") && parent.source === node) {
2890
3084
  return;
2891
3085
  }
2892
- if (parent.type === "ExpressionStatement" && (Boolean(parent.directive) || activeDirectives.has(node.value))) {
3086
+ if (parent.type === "Property" && parent.key === node && !parent.computed) {
2893
3087
  return;
2894
3088
  }
2895
- for (let i = ancestors.length - 2; i >= 0; i--) {
2896
- if (ancestors[i].type === "ExpressionStatement" && Boolean(ancestors[i].directive)) {
2897
- return;
2898
- }
2899
- }
2900
- if ((parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") && parent.source === node) {
3089
+ if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
2901
3090
  return;
2902
3091
  }
2903
- if (parent.type === "Property" && parent.key === node && !parent.computed) {
3092
+ if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
2904
3093
  return;
2905
3094
  }
2906
- if ((parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") && parent.key === node && !parent.computed) {
3095
+ processSaltedCandidate(val, node, parent, ancestors);
3096
+ },
3097
+ TemplateLiteral(node, ancestors) {
3098
+ if (!node.quasis || node.quasis.length !== 1) return;
3099
+ if (node.expressions && node.expressions.length !== 0) return;
3100
+ const val = _nullishCoalesce(node.quasis[0].value.cooked, () => ( node.quasis[0].value.raw));
3101
+ if (typeof val !== "string" || activeDirectives.has(val)) return;
3102
+ const parent = ancestors[ancestors.length - 2];
3103
+ if (!parent) return;
3104
+ if (parent.type === "TaggedTemplateExpression" && parent.quasi === node) {
2907
3105
  return;
2908
3106
  }
2909
- if (hotExemptNodes) {
2910
- for (let i = ancestors.length - 1; i >= 0; i--) {
2911
- if (hotExemptNodes.has(ancestors[i])) {
2912
- return;
2913
- }
2914
- }
3107
+ if (parent.type === "ImportExpression" && parent.source === node) {
3108
+ return;
2915
3109
  }
2916
- if (isReservedProp(node.value, customReserved)) return;
2917
- if (isTailwindNoise(node.value)) return;
2918
- if (isSvgPathString(node.value, parent)) return;
2919
- const callSiteIdx = targetsToReplace.length;
2920
- const [saltLo, saltHi] = computeCallSiteSalt64(
2921
- seed >>> 0,
2922
- callSiteIdx >>> 0,
2923
- seed >>> 0
2924
- );
2925
- const localSalt = ((saltLo ^ saltHi) & 2147483647 | 1) >>> 0;
2926
- targetsToReplace.push({
2927
- node,
2928
- parent,
2929
- callSiteIdx,
2930
- localSalt,
2931
- rawString: node.value
2932
- });
3110
+ processSaltedCandidate(val, node, parent, ancestors);
2933
3111
  }
2934
3112
  });
2935
- if (targetsToReplace.length === 0) {
3113
+ if (targetsToReplace.length === 0 && shaderTargets.length === 0) {
2936
3114
  return {
2937
3115
  encryptedStringsCount: 0,
2938
3116
  integrityToken: computeFnv1aHash("empty-salted", seed),
2939
3117
  vaultVarName: "",
2940
- decryptFnName: ""
3118
+ decryptFnName: "",
3119
+ shaderBuffersCount: 0
2941
3120
  };
2942
3121
  }
2943
- const wasmResult = injectWasmVault(ast, seed);
2944
- const kdfFnName = wasmResult.kdfFnName;
2945
- const suffix = computeFnv1aHash(`salted:${seed}`, seed).toString(36);
2946
- const vaultVarName = `_uP${suffix}`;
2947
- const cacheVarName = `_uCache${suffix}`;
2948
- const dCacheVarName = `_uDc${suffix}`;
2949
- const decryptFnName = `_uD${suffix}`;
2950
- const sym = _nullishCoalesce(windowKeySymbol, () => ( deriveWindowKeySymbol(seed)));
2951
- let expDelta = expectedDelta;
2952
- if (shieldCoupled && expDelta === void 0) {
2953
- const shield = generateRuntimeShield({
2954
- seed,
2955
- windowKeySymbol: sym,
2956
- deterrentMode: _nullishCoalesce(deterrentMode, () => ( "passive")),
2957
- detectHeadless
3122
+ let vaultVarName = "";
3123
+ let decryptFnName = "";
3124
+ let integrityToken = computeFnv1aHash("empty-salted", seed);
3125
+ if (targetsToReplace.length > 0) {
3126
+ const wasmResult = injectWasmVault(ast, seed);
3127
+ const kdfFnName = wasmResult.kdfFnName;
3128
+ const suffix = computeFnv1aHash(`salted:${seed}`, seed).toString(36);
3129
+ vaultVarName = `_uP${suffix}`;
3130
+ const cacheVarName = `_uCache${suffix}`;
3131
+ const dCacheVarName = `_uDc${suffix}`;
3132
+ 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
+ const propAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(sym) ? `.${sym}` : `[${JSON.stringify(sym)}]`;
3145
+ const stateSym = `${sym}_s`;
3146
+ const stateAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(stateSym) ? `.${stateSym}` : `[${JSON.stringify(stateSym)}]`;
3147
+ const flagSym = `${sym}_t`;
3148
+ const flagAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(flagSym) ? `.${flagSym}` : `[${JSON.stringify(flagSym)}]`;
3149
+ const tkExpr = `['__','unp','eek_t','ampered'].join('')`;
3150
+ const dkExpr = `['__','unp','eek_d','elta'].join('')`;
3151
+ let helperFnSnippet;
3152
+ if (!shieldCoupled) {
3153
+ 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};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))||((""._u||0)!==0)||(dv!==0);if(!tm&&${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;}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)${cacheVarName}[i]=o;return o;}`;
3154
+ } else {
3155
+ const edInit = buildRivestDeltaExpr(seed, (_nullishCoalesce(expDelta, () => ( 0))) & 65535, "_ed");
3156
+ const hasWindowKey = Boolean(sym);
3157
+ const brDecl = hasWindowKey ? `var _br=typeof window<"u"||typeof document<"u"||typeof self<"u";` : "";
3158
+ const svCheck = hasWindowKey ? `(sv===void 0?!_br:sv!==_ed)` : `(sv!==void 0&&sv!==_ed)`;
3159
+ 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
+ }
3161
+ const parsedFn = acorn3.parse(helperFnSnippet, {
3162
+ ecmaVersion: "latest",
3163
+ sourceType: "script"
2958
3164
  });
2959
- expDelta = _nullishCoalesce(shield.expectedDelta, () => ( 0));
2960
- }
2961
- const propAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(sym) ? `.${sym}` : `[${JSON.stringify(sym)}]`;
2962
- const stateSym = `${sym}_s`;
2963
- const stateAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(stateSym) ? `.${stateSym}` : `[${JSON.stringify(stateSym)}]`;
2964
- const flagSym = `${sym}_t`;
2965
- const flagAccess = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(flagSym) ? `.${flagSym}` : `[${JSON.stringify(flagSym)}]`;
2966
- const tkExpr = `['__','unp','eek_t','ampered'].join('')`;
2967
- const dkExpr = `['__','unp','eek_d','elta'].join('')`;
2968
- let helperFnSnippet;
2969
- if (!shieldCoupled) {
2970
- 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};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))||((""._u||0)!==0)||(dv!==0);if(!tm&&${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;}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)${cacheVarName}[i]=o;return o;}`;
2971
- } else {
2972
- const edInit = buildRivestDeltaExpr(seed, (_nullishCoalesce(expDelta, () => ( 0))) & 65535, "_ed");
2973
- 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}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)||(sv!==void 0&&sv!==_ed);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;}`;
2974
- }
2975
- const parsedFn = acorn3.parse(helperFnSnippet, {
2976
- ecmaVersion: "latest",
2977
- sourceType: "script"
2978
- });
2979
- const fnDeclAst = parsedFn.body[0];
2980
- const selfHash = computeFnv1aHash(generateCompactJs(fnDeclAst)) | 0;
2981
- const buildD = shieldCoupled ? selfHash ^ (_nullishCoalesce(expDelta, () => ( 0))) & 65535 | 0 : selfHash | 0;
2982
- for (const target of targetsToReplace) {
2983
- const k = fallbackKdf(target.callSiteIdx, target.localSalt, buildD, seed);
2984
- encryptedPayloads.push(encodeSaltedString(target.rawString, k));
2985
- const callExpr = {
2986
- type: "CallExpression",
2987
- callee: {
2988
- type: "Identifier",
2989
- name: decryptFnName
2990
- },
2991
- arguments: [
2992
- {
2993
- type: "Literal",
2994
- value: target.callSiteIdx,
2995
- raw: String(target.callSiteIdx)
3165
+ const fnDeclAst = parsedFn.body[0];
3166
+ const selfHash = computeFnv1aHash(generateCompactJs(fnDeclAst)) | 0;
3167
+ const buildD = shieldCoupled ? selfHash ^ (_nullishCoalesce(expDelta, () => ( 0))) & 65535 | 0 : selfHash | 0;
3168
+ for (const target of targetsToReplace) {
3169
+ const k = fallbackKdf(target.callSiteIdx, target.localSalt, buildD, seed);
3170
+ encryptedPayloads.push(encodeSaltedString(target.rawString, k));
3171
+ const callExpr = {
3172
+ type: "CallExpression",
3173
+ callee: {
3174
+ type: "Identifier",
3175
+ name: decryptFnName
2996
3176
  },
2997
- {
2998
- type: "Literal",
2999
- value: target.localSalt,
3000
- raw: String(target.localSalt)
3001
- }
3002
- ],
3003
- optional: false
3004
- };
3005
- replaceNodeInParent(target.parent, target.node, callExpr);
3177
+ arguments: [
3178
+ {
3179
+ type: "Literal",
3180
+ value: target.callSiteIdx,
3181
+ raw: String(target.callSiteIdx)
3182
+ },
3183
+ {
3184
+ type: "Literal",
3185
+ value: target.localSalt,
3186
+ raw: String(target.localSalt)
3187
+ }
3188
+ ],
3189
+ optional: false
3190
+ };
3191
+ replaceNodeInParent(target.parent, target.node, callExpr);
3192
+ }
3193
+ const serializedTable = JSON.stringify(encryptedPayloads);
3194
+ integrityToken = computeFnv1aHash(serializedTable, seed);
3195
+ const varsSnippet = `var ${vaultVarName}=${serializedTable};var ${cacheVarName}=[];var ${dCacheVarName};`;
3196
+ const parsedVars = acorn3.parse(varsSnippet, {
3197
+ ecmaVersion: "latest",
3198
+ sourceType: "script"
3199
+ });
3200
+ const insertIdx = findVaultInsertIndex(ast, activeDirectives);
3201
+ ast.body.splice(insertIdx, 0, ...parsedVars.body, fnDeclAst);
3006
3202
  }
3007
- const serializedTable = JSON.stringify(encryptedPayloads);
3008
- const integrityToken = computeFnv1aHash(serializedTable, seed);
3009
- const varsSnippet = `var ${vaultVarName}=${serializedTable};var ${cacheVarName}=[];var ${dCacheVarName};`;
3010
- const parsedVars = acorn3.parse(varsSnippet, {
3011
- ecmaVersion: "latest",
3012
- sourceType: "script"
3013
- });
3014
- let insertIdx = 0;
3015
- while (insertIdx < ast.body.length) {
3016
- const stmt = ast.body[insertIdx];
3017
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _241 => _241.expression, 'optionalAccess', _242 => _242.type]) === "Literal" && typeof stmt.expression.value === "string" && (activeDirectives.has(stmt.expression.value) || /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim())));
3018
- if (isDirective || stmt.type === "ImportDeclaration") {
3019
- insertIdx++;
3020
- } else {
3021
- break;
3203
+ if (shaderPayloads.length > 0) {
3204
+ const shaderVarName = derivePolymorphicIdent(seed, "shader");
3205
+ for (const target of shaderTargets) {
3206
+ const callExpr = {
3207
+ type: "CallExpression",
3208
+ callee: {
3209
+ type: "Identifier",
3210
+ name: shaderVarName
3211
+ },
3212
+ arguments: [
3213
+ {
3214
+ type: "Literal",
3215
+ value: target.idx,
3216
+ raw: String(target.idx)
3217
+ }
3218
+ ],
3219
+ optional: false
3220
+ };
3221
+ replaceNodeInParent(target.parent, target.node, callExpr);
3222
+ }
3223
+ const shaderHelperStmt = createShaderVaultAst(
3224
+ shaderVarName,
3225
+ shaderPayloads,
3226
+ seed
3227
+ );
3228
+ const shaderInsertIdx = findVaultInsertIndex(ast, activeDirectives);
3229
+ ast.body.splice(shaderInsertIdx, 0, shaderHelperStmt);
3230
+ if (targetsToReplace.length === 0) {
3231
+ integrityToken = computeFnv1aHash(JSON.stringify(shaderPayloads), seed);
3022
3232
  }
3023
3233
  }
3024
- ast.body.splice(insertIdx, 0, ...parsedVars.body, fnDeclAst);
3025
3234
  return {
3026
3235
  encryptedStringsCount: targetsToReplace.length,
3027
3236
  integrityToken,
3028
3237
  vaultVarName,
3029
- decryptFnName
3238
+ decryptFnName,
3239
+ shaderBuffersCount: shaderPayloads.length
3030
3240
  };
3031
3241
  }
3032
3242
 
@@ -3086,7 +3296,7 @@ function isReactDomSpecialProp(val, node, parent, customReserved) {
3086
3296
  if (parent.key === node && !parent.computed) {
3087
3297
  return true;
3088
3298
  }
3089
- const keyName = _optionalChain([parent, 'access', _243 => _243.key, 'optionalAccess', _244 => _244.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _245 => _245.key, 'optionalAccess', _246 => _246.type]) === "Literal" ? String(parent.key.value) : "";
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) : "";
3090
3300
  if (keyName && isReservedProp(keyName, customReserved)) {
3091
3301
  return true;
3092
3302
  }
@@ -3149,11 +3359,11 @@ var DEFAULT_SEMANTIC_ANCHOR_RE = /(?:\bapi\/|\bcheckout\b|\badmin\b|\bauth\b|\bt
3149
3359
  function isUiClassName(val, parent) {
3150
3360
  if (parent) {
3151
3361
  if (parent.type === "Property") {
3152
- const k = _optionalChain([parent, 'access', _247 => _247.key, 'optionalAccess', _248 => _248.type]) === "Identifier" ? parent.key.name : _optionalChain([parent, 'access', _249 => _249.key, 'optionalAccess', _250 => _250.type]) === "Literal" ? String(parent.key.value) : "";
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) : "";
3153
3363
  if (k === "className" || k === "class" || k === "classList") return true;
3154
3364
  }
3155
3365
  if (parent.type === "JSXAttribute") {
3156
- const name = _optionalChain([parent, 'access', _251 => _251.name, 'optionalAccess', _252 => _252.name]);
3366
+ const name = _optionalChain([parent, 'access', _266 => _266.name, 'optionalAccess', _267 => _267.name]);
3157
3367
  if (name === "className" || name === "class") return true;
3158
3368
  }
3159
3369
  }
@@ -3202,7 +3412,7 @@ function isEligibleHotLiteral(val, node, parent, ancestors, minLen, seed = 26544
3202
3412
  for (let i = ancestors.length - 2; i >= 0; i--) {
3203
3413
  const a = ancestors[i];
3204
3414
  if (a.type === "FunctionDeclaration" || a.type === "FunctionExpression" || a.type === "ArrowFunctionExpression") {
3205
- if (_optionalChain([a, 'access', _253 => _253.id, 'optionalAccess', _254 => _254.name]) && /^[A-Z]/.test(a.id.name)) {
3415
+ if (_optionalChain([a, 'access', _268 => _268.id, 'optionalAccess', _269 => _269.name]) && /^[A-Z]/.test(a.id.name)) {
3206
3416
  isInsideRender = true;
3207
3417
  break;
3208
3418
  }
@@ -3229,7 +3439,44 @@ function isEligibleHotLiteral(val, node, parent, ancestors, minLen, seed = 26544
3229
3439
  }
3230
3440
  return true;
3231
3441
  }
3232
- var SHADER_SIG_RE = /@group|@binding|@vertex|@fragment|@compute|vec4f|gl_Position|uniform/;
3442
+ var SHADER_SIG_RE = /@group|@binding|@vertex|@fragment|@compute|@builtin|@location|@workgroup_size|\bstruct\s+[A-Za-z_]\w*\s*\{|\b[iub]?vec[234][fhiu]?\b|\bmat[234](?:x[234])?[fhi]?\b|\buniform\b|\bvar<(?:uniform|storage)|\bgl_(?:Position|FragColor|FragCoord|VertexID|InstanceID)\b|\bfn\s+main\b|\bvoid\s+main\s*\(|\bprecision\s+(?:lowp|mediump|highp)\s+float\b/;
3443
+ function isInsideLoopOrSerialized(ancestors) {
3444
+ for (let i = ancestors.length - 2; i >= 0; i--) {
3445
+ const anc = ancestors[i];
3446
+ if (LOOP_NODE_TYPES.has(anc.type) || Boolean(anc._unpeekSerialized)) {
3447
+ return true;
3448
+ }
3449
+ }
3450
+ return false;
3451
+ }
3452
+ function isShaderPayload(val, node, parent, ancestors, seed, isHotExempt, customReserved) {
3453
+ if (isInsideLoopOrSerialized(ancestors)) return false;
3454
+ if (_optionalChain([parent, 'optionalAccess', _270 => _270.type]) === "Property" && parent.key === node && !parent.computed) return false;
3455
+ if (isReservedProp(val, customReserved)) return false;
3456
+ if (isTailwindNoise(val)) return false;
3457
+ if (isSvgPathString(val, parent)) return false;
3458
+ if (isAdversaryDecoy(val, seed)) return false;
3459
+ if (val.startsWith("HOT_")) return false;
3460
+ const matchesSig = SHADER_SIG_RE.test(val);
3461
+ if (!matchesSig) {
3462
+ if (val.length < 256) return false;
3463
+ if (isHotExempt && isUiClassName(val, parent)) return false;
3464
+ }
3465
+ return true;
3466
+ }
3467
+ function findVaultInsertIndex(ast, activeDirectives = DIRECTIVE_STRINGS) {
3468
+ let insertIdx = 0;
3469
+ while (insertIdx < ast.body.length) {
3470
+ 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())));
3472
+ if (isDirective || stmt.type === "ImportDeclaration") {
3473
+ insertIdx++;
3474
+ } else {
3475
+ break;
3476
+ }
3477
+ }
3478
+ return insertIdx;
3479
+ }
3233
3480
  function shouldEncryptString(val, minLen, parent, activeDirectives = DIRECTIVE_STRINGS, customReserved) {
3234
3481
  if (val.length < minLen || activeDirectives.has(val)) return false;
3235
3482
  if (isReservedProp(val, customReserved)) return false;
@@ -3350,24 +3597,24 @@ function findLowestCommonScope(ast, chains) {
3350
3597
  return _nullishCoalesce(lca[lca.length - 1], () => ( ast));
3351
3598
  }
3352
3599
  function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExemptNodes, windowKeySymbol, expectedDelta, deterrentMode, config, shieldCoupled = true, detectHeadless = false, exemptSubtreeRoots) {
3353
- const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _255 => _255.vault, 'optionalAccess', _256 => _256.minStringLength]), () => ( minStringLength));
3600
+ const minLen = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _273 => _273.vault, 'optionalAccess', _274 => _274.minStringLength]), () => ( minStringLength));
3354
3601
  const activeDirectives = new Set(DIRECTIVE_STRINGS);
3355
- if (_optionalChain([config, 'optionalAccess', _257 => _257.vault, 'optionalAccess', _258 => _258.customDirectives])) {
3602
+ if (_optionalChain([config, 'optionalAccess', _275 => _275.vault, 'optionalAccess', _276 => _276.customDirectives])) {
3356
3603
  for (const dir of config.vault.customDirectives) {
3357
3604
  activeDirectives.add(dir);
3358
3605
  }
3359
3606
  }
3360
- const customReserved = _optionalChain([config, 'optionalAccess', _259 => _259.vault, 'optionalAccess', _260 => _260.reservedProps]) ? new Set(config.vault.reservedProps) : void 0;
3361
- const semanticPatterns = _optionalChain([config, 'optionalAccess', _261 => _261.vault, 'optionalAccess', _262 => _262.semanticAnchors, 'optionalAccess', _263 => _263.patterns, 'optionalAccess', _264 => _264.map, 'call', _265 => _265(
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(
3362
3609
  (p) => typeof p === "string" ? new RegExp(p) : p
3363
3610
  )]);
3364
- const excludeUi = _optionalChain([config, 'optionalAccess', _266 => _266.vault, 'optionalAccess', _267 => _267.semanticAnchors, 'optionalAccess', _268 => _268.excludeUiClasses]) !== false;
3611
+ const excludeUi = _optionalChain([config, 'optionalAccess', _284 => _284.vault, 'optionalAccess', _285 => _285.semanticAnchors, 'optionalAccess', _286 => _286.excludeUiClasses]) !== false;
3365
3612
  const suffix = (seed >>> 0 & 65535).toString(36);
3366
3613
  const decryptFnName = `_uD${suffix}`;
3367
3614
  const cacheVarName = derivePolymorphicIdent(seed, "vault");
3368
3615
  const shaderVarName = derivePolymorphicIdent(seed, "shader");
3369
3616
  const sym = _nullishCoalesce(windowKeySymbol, () => ( deriveWindowKeySymbol(seed)));
3370
- const browserOnly = _optionalChain([config, 'optionalAccess', _269 => _269.target]) === "browser";
3617
+ const browserOnly = _optionalChain([config, 'optionalAccess', _287 => _287.target]) === "browser";
3371
3618
  let expDelta = shieldCoupled ? expectedDelta : 0;
3372
3619
  if (shieldCoupled && expDelta === void 0) {
3373
3620
  const shield = generateRuntimeShield({
@@ -3379,8 +3626,8 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3379
3626
  expDelta = _nullishCoalesce(shield.expectedDelta, () => ( 0));
3380
3627
  }
3381
3628
  const alreadyVaulted = ast.body.some(
3382
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _270 => _270.declarations, 'optionalAccess', _271 => _271.some, 'call', _272 => _272(
3383
- (d) => _optionalChain([d, 'access', _273 => _273.id, 'optionalAccess', _274 => _274.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', _275 => _275.init, 'optionalAccess', _276 => _276.type]) === "CallExpression" && _optionalChain([d, 'access', _277 => _277.init, 'access', _278 => _278.callee, 'optionalAccess', _279 => _279.type]) === "FunctionExpression" && _optionalChain([d, 'access', _280 => _280.init, 'access', _281 => _281.callee, 'optionalAccess', _282 => _282.id, 'optionalAccess', _283 => _283.name]) === "f" && _optionalChain([d, 'access', _284 => _284.init, 'access', _285 => _285.arguments, 'optionalAccess', _286 => _286[0], 'optionalAccess', _287 => _287.type]) === "ArrayExpression")
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")
3384
3631
  )])
3385
3632
  );
3386
3633
  if (alreadyVaulted) {
@@ -3417,6 +3664,96 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3417
3664
  if (node.value) c(node.value, st);
3418
3665
  }
3419
3666
  };
3667
+ function processVaultCandidate(val, node, parent, ancestors) {
3668
+ if (isNodeInExemptSubtree(ancestors, exemptSubtreeRoots)) {
3669
+ return;
3670
+ }
3671
+ if (parent.type === "ExpressionStatement" && (Boolean(parent.directive) || activeDirectives.has(val))) {
3672
+ return;
3673
+ }
3674
+ for (let i = ancestors.length - 2; i >= 0; i--) {
3675
+ if (ancestors[i].type === "ExpressionStatement" && Boolean(ancestors[i].directive)) {
3676
+ return;
3677
+ }
3678
+ }
3679
+ let isHotExempt = false;
3680
+ if (hotExemptNodes) {
3681
+ for (let i = ancestors.length - 2; i >= 0; i--) {
3682
+ if (hotExemptNodes.has(ancestors[i])) {
3683
+ isHotExempt = true;
3684
+ break;
3685
+ }
3686
+ }
3687
+ }
3688
+ if (isShaderPayload(
3689
+ val,
3690
+ node,
3691
+ parent,
3692
+ ancestors,
3693
+ seed,
3694
+ isHotExempt,
3695
+ customReserved
3696
+ )) {
3697
+ let idx2 = shaderToIndex.get(val);
3698
+ if (idx2 === void 0) {
3699
+ idx2 = shaderPayloads.length;
3700
+ shaderToIndex.set(val, idx2);
3701
+ shaderPayloads.push(val);
3702
+ }
3703
+ targetsToReplace.push({
3704
+ type: "shader",
3705
+ node,
3706
+ parent,
3707
+ idx: idx2,
3708
+ scopeChain: extractScopeChain(ast, ancestors)
3709
+ });
3710
+ return;
3711
+ }
3712
+ if (isHotExempt) {
3713
+ if (isEligibleHotLiteral(
3714
+ val,
3715
+ node,
3716
+ parent,
3717
+ ancestors,
3718
+ minLen,
3719
+ seed,
3720
+ customReserved,
3721
+ activeDirectives,
3722
+ semanticPatterns,
3723
+ excludeUi
3724
+ )) {
3725
+ hotTargetsToReplace.push({
3726
+ node,
3727
+ parent,
3728
+ val,
3729
+ idx: hotTargetsToReplace.length
3730
+ });
3731
+ }
3732
+ return;
3733
+ }
3734
+ if (!shouldEncryptString(
3735
+ val,
3736
+ minLen,
3737
+ parent,
3738
+ activeDirectives,
3739
+ customReserved
3740
+ )) {
3741
+ return;
3742
+ }
3743
+ let idx = stringToIndex.get(val);
3744
+ if (idx === void 0) {
3745
+ idx = uniqueStrings.length;
3746
+ stringToIndex.set(val, idx);
3747
+ uniqueStrings.push(val);
3748
+ }
3749
+ targetsToReplace.push({
3750
+ type: "string",
3751
+ node,
3752
+ parent,
3753
+ idx,
3754
+ scopeChain: extractScopeChain(ast, ancestors)
3755
+ });
3756
+ }
3420
3757
  walk4.ancestor(
3421
3758
  ast,
3422
3759
  {
@@ -3424,28 +3761,8 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3424
3761
  if (typeof node.value !== "string") return;
3425
3762
  const val = node.value;
3426
3763
  if (activeDirectives.has(val)) return;
3427
- let isHotExempt = false;
3428
- if (hotExemptNodes) {
3429
- for (let i = ancestors.length - 2; i >= 0; i--) {
3430
- if (hotExemptNodes.has(ancestors[i])) {
3431
- isHotExempt = true;
3432
- break;
3433
- }
3434
- }
3435
- }
3436
3764
  const parent = ancestors[ancestors.length - 2];
3437
3765
  if (!parent) return;
3438
- if (isNodeInExemptSubtree(ancestors, exemptSubtreeRoots)) {
3439
- return;
3440
- }
3441
- if (parent.type === "ExpressionStatement" && (Boolean(parent.directive) || activeDirectives.has(val))) {
3442
- return;
3443
- }
3444
- for (let i = ancestors.length - 2; i >= 0; i--) {
3445
- if (ancestors[i].type === "ExpressionStatement" && Boolean(ancestors[i].directive)) {
3446
- return;
3447
- }
3448
- }
3449
3766
  if (parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") {
3450
3767
  if (parent.source === node) return;
3451
3768
  }
@@ -3455,154 +3772,22 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3455
3772
  if (parent.type === "ImportAttribute" || parent.type === "ImportSpecifier" || parent.type === "ExportSpecifier") {
3456
3773
  return;
3457
3774
  }
3458
- if (isHotExempt) {
3459
- if (isEligibleHotLiteral(
3460
- val,
3461
- node,
3462
- parent,
3463
- ancestors,
3464
- minLen,
3465
- seed,
3466
- customReserved,
3467
- activeDirectives,
3468
- semanticPatterns,
3469
- excludeUi
3470
- )) {
3471
- hotTargetsToReplace.push({
3472
- node,
3473
- parent,
3474
- val,
3475
- idx: hotTargetsToReplace.length
3476
- });
3477
- }
3478
- return;
3479
- }
3480
- if (parent.type === "Property" && parent.key === node && !parent.computed) {
3481
- if (isReservedProp(val, customReserved)) {
3482
- return;
3483
- }
3484
- }
3485
- if (isReservedProp(val, customReserved)) return;
3486
- if (isTailwindNoise(val)) return;
3487
- if (isSvgPathString(val, parent)) return;
3488
- const isShader = val.length >= 256 || SHADER_SIG_RE.test(val);
3489
- if (isShader) {
3490
- let idx = shaderToIndex.get(val);
3491
- if (idx === void 0) {
3492
- idx = shaderPayloads.length;
3493
- shaderToIndex.set(val, idx);
3494
- shaderPayloads.push(val);
3495
- }
3496
- targetsToReplace.push({
3497
- type: "shader",
3498
- node,
3499
- parent,
3500
- idx,
3501
- scopeChain: extractScopeChain(ast, ancestors)
3502
- });
3503
- } else {
3504
- if (!shouldEncryptString(val, minLen, parent, activeDirectives, customReserved)) return;
3505
- let idx = stringToIndex.get(val);
3506
- if (idx === void 0) {
3507
- idx = uniqueStrings.length;
3508
- stringToIndex.set(val, idx);
3509
- uniqueStrings.push(val);
3510
- }
3511
- targetsToReplace.push({
3512
- type: "string",
3513
- node,
3514
- parent,
3515
- idx,
3516
- scopeChain: extractScopeChain(ast, ancestors)
3517
- });
3518
- }
3775
+ processVaultCandidate(val, node, parent, ancestors);
3519
3776
  },
3520
3777
  TemplateLiteral(node, _state, ancestors) {
3521
3778
  if (!node.quasis || node.quasis.length !== 1) return;
3522
3779
  if (node.expressions && node.expressions.length !== 0) return;
3523
3780
  const val = _nullishCoalesce(node.quasis[0].value.cooked, () => ( node.quasis[0].value.raw));
3524
3781
  if (typeof val !== "string" || activeDirectives.has(val)) return;
3525
- if (isNodeInExemptSubtree(ancestors, exemptSubtreeRoots)) {
3526
- return;
3527
- }
3528
- let isHotExempt = false;
3529
- if (hotExemptNodes) {
3530
- for (let i = ancestors.length - 2; i >= 0; i--) {
3531
- if (hotExemptNodes.has(ancestors[i])) {
3532
- isHotExempt = true;
3533
- break;
3534
- }
3535
- }
3536
- }
3537
3782
  const parent = ancestors[ancestors.length - 2];
3538
3783
  if (!parent) return;
3539
- if (isNodeInExemptSubtree(ancestors, exemptSubtreeRoots)) {
3540
- return;
3541
- }
3542
- if (parent.type === "ExpressionStatement" && (Boolean(parent.directive) || activeDirectives.has(val))) {
3784
+ if (parent.type === "TaggedTemplateExpression" && parent.quasi === node) {
3543
3785
  return;
3544
3786
  }
3545
- for (let i = ancestors.length - 2; i >= 0; i--) {
3546
- if (ancestors[i].type === "ExpressionStatement" && Boolean(ancestors[i].directive)) {
3547
- return;
3548
- }
3549
- }
3550
- if (isHotExempt) {
3551
- if (isEligibleHotLiteral(
3552
- val,
3553
- node,
3554
- parent,
3555
- ancestors,
3556
- minLen,
3557
- seed,
3558
- customReserved,
3559
- activeDirectives,
3560
- semanticPatterns,
3561
- excludeUi
3562
- )) {
3563
- hotTargetsToReplace.push({
3564
- node,
3565
- parent,
3566
- val,
3567
- idx: hotTargetsToReplace.length
3568
- });
3569
- }
3787
+ if (parent.type === "ImportExpression" && parent.source === node) {
3570
3788
  return;
3571
3789
  }
3572
- if (isReservedProp(val, customReserved)) return;
3573
- if (isTailwindNoise(val)) return;
3574
- if (isSvgPathString(val, parent)) return;
3575
- const isShader = val.length >= 256 || SHADER_SIG_RE.test(val);
3576
- if (isShader) {
3577
- let idx = shaderToIndex.get(val);
3578
- if (idx === void 0) {
3579
- idx = shaderPayloads.length;
3580
- shaderToIndex.set(val, idx);
3581
- shaderPayloads.push(val);
3582
- }
3583
- targetsToReplace.push({
3584
- type: "shader",
3585
- node,
3586
- parent,
3587
- idx,
3588
- scopeChain: extractScopeChain(ast, ancestors)
3589
- });
3590
- } else {
3591
- if (!shouldEncryptString(val, minLen, parent, activeDirectives, customReserved)) return;
3592
- let idx = stringToIndex.get(val);
3593
- if (idx === void 0) {
3594
- idx = uniqueStrings.length;
3595
- stringToIndex.set(val, idx);
3596
- uniqueStrings.push(val);
3597
- }
3598
- targetsToReplace.push({
3599
- type: "string",
3600
- node,
3601
- parent,
3602
- idx,
3603
- scopeChain: extractScopeChain(ast, ancestors)
3604
- });
3605
- }
3790
+ processVaultCandidate(val, node, parent, ancestors);
3606
3791
  }
3607
3792
  },
3608
3793
  customWalkBase
@@ -3620,7 +3805,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3620
3805
  for (let i = 0; i < val.length; i++) {
3621
3806
  encodedStr += String.fromCharCode(val.charCodeAt(i) ^ key);
3622
3807
  }
3623
- if (_optionalChain([parent, 'optionalAccess', _288 => _288.type]) === "Property" && parent.key === node) {
3808
+ if (_optionalChain([parent, 'optionalAccess', _306 => _306.type]) === "Property" && parent.key === node) {
3624
3809
  parent.computed = true;
3625
3810
  }
3626
3811
  node.type = "CallExpression";
@@ -3646,18 +3831,9 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3646
3831
  delete node.quasis;
3647
3832
  delete node.expressions;
3648
3833
  }
3649
- let insertIdx = 0;
3650
- while (insertIdx < ast.body.length) {
3651
- const stmt = ast.body[insertIdx];
3652
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _289 => _289.expression, 'optionalAccess', _290 => _290.type]) === "Literal" && typeof stmt.expression.value === "string" && (activeDirectives.has(stmt.expression.value) || /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim())));
3653
- if (isDirective || stmt.type === "ImportDeclaration") {
3654
- insertIdx++;
3655
- } else {
3656
- break;
3657
- }
3658
- }
3659
- const wantFragmented = Boolean(_optionalChain([config, 'optionalAccess', _291 => _291.vault, 'optionalAccess', _292 => _292.fragmented]));
3660
- let fragCount = Math.max(2, Math.min(8, Math.floor(_nullishCoalesce(_optionalChain([config, 'optionalAccess', _293 => _293.vault, 'optionalAccess', _294 => _294.fragmentCount]), () => ( 3)))));
3834
+ 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)))));
3661
3837
  while (fragCount > 2 && Math.floor(uniqueStrings.length / fragCount) < 4) {
3662
3838
  fragCount--;
3663
3839
  }
@@ -3672,7 +3848,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3672
3848
  }
3673
3849
  integrityToken = computeFnv1aHash(JSON.stringify(encryptedPayloads), seed);
3674
3850
  for (const { type, node, parent, idx } of targetsToReplace) {
3675
- if (_optionalChain([parent, 'optionalAccess', _295 => _295.type]) === "Property" && parent.key === node) {
3851
+ if (_optionalChain([parent, 'optionalAccess', _311 => _311.type]) === "Property" && parent.key === node) {
3676
3852
  parent.computed = true;
3677
3853
  }
3678
3854
  if (type === "shader") {
@@ -3761,7 +3937,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3761
3937
  });
3762
3938
  }
3763
3939
  for (const { type, node, parent, idx, scopeChain } of targetsToReplace) {
3764
- if (_optionalChain([parent, 'optionalAccess', _296 => _296.type]) === "Property" && parent.key === node) {
3940
+ if (_optionalChain([parent, 'optionalAccess', _312 => _312.type]) === "Property" && parent.key === node) {
3765
3941
  parent.computed = true;
3766
3942
  }
3767
3943
  if (type === "shader") {
@@ -3799,7 +3975,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3799
3975
  ast.body.splice(insertIdx++, 0, helperStmt);
3800
3976
  } else {
3801
3977
  let blockInsertIdx = 0;
3802
- while (blockInsertIdx < lcaScope.body.length && _optionalChain([lcaScope, 'access', _297 => _297.body, 'access', _298 => _298[blockInsertIdx], 'optionalAccess', _299 => _299.type]) === "ExpressionStatement" && Boolean(_optionalChain([lcaScope, 'access', _300 => _300.body, 'access', _301 => _301[blockInsertIdx], 'optionalAccess', _302 => _302.directive]))) {
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]))) {
3803
3979
  blockInsertIdx++;
3804
3980
  }
3805
3981
  lcaScope.body.splice(blockInsertIdx, 0, helperStmt);
@@ -3809,7 +3985,7 @@ function applyStringVault(ast, seed = 2654435769, minStringLength = 4, hotExempt
3809
3985
  }
3810
3986
  if (hotTargetsToReplace.length > 0) {
3811
3987
  const alreadyHasHx = ast.body.some(
3812
- (stmt) => stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _303 => _303.id, 'optionalAccess', _304 => _304.name]) === "_hX"
3988
+ (stmt) => stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _319 => _319.id, 'optionalAccess', _320 => _320.name]) === "_hX"
3813
3989
  );
3814
3990
  if (!alreadyHasHx) {
3815
3991
  const hxAst = acorn4.parse(
@@ -3997,8 +4173,8 @@ function collectPatternTargets(pattern, out, shorthandProp) {
3997
4173
  }
3998
4174
  }
3999
4175
  function isMangleableName(origName, reservedSet = RESERVED_IDENTIFIERS, manglerConfig) {
4000
- const minLength = _nullishCoalesce(_optionalChain([manglerConfig, 'optionalAccess', _305 => _305.minLength]), () => ( 1));
4001
- return origName.length >= minLength && !reservedSet.has(origName) && !JS_KEYWORDS.has(origName) && !origName.startsWith("$") && !origName.startsWith("__") && !origName.startsWith("_u") && !origName.startsWith("_0x") && (!_optionalChain([manglerConfig, 'optionalAccess', _306 => _306.excludePrefixes]) || !manglerConfig.excludePrefixes.some((p) => origName.startsWith(p))) && (!_optionalChain([manglerConfig, 'optionalAccess', _307 => _307.excludePatterns]) || !manglerConfig.excludePatterns.some(
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(
4002
4178
  (re) => (typeof re === "string" ? new RegExp(re) : re).test(origName)
4003
4179
  ));
4004
4180
  }
@@ -4018,12 +4194,12 @@ function shuffleAlphabet(chars, seed) {
4018
4194
  }
4019
4195
  function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes, config) {
4020
4196
  const activeReserved = new Set(RESERVED_IDENTIFIERS);
4021
- if (_optionalChain([config, 'optionalAccess', _308 => _308.mangler, 'optionalAccess', _309 => _309.reservedIdentifiers])) {
4197
+ if (_optionalChain([config, 'optionalAccess', _324 => _324.mangler, 'optionalAccess', _325 => _325.reservedIdentifiers])) {
4022
4198
  for (const id of config.mangler.reservedIdentifiers) {
4023
4199
  activeReserved.add(id);
4024
4200
  }
4025
4201
  }
4026
- const manglerConfig = _optionalChain([config, 'optionalAccess', _310 => _310.mangler]);
4202
+ const manglerConfig = _optionalChain([config, 'optionalAccess', _326 => _326.mangler]);
4027
4203
  const scopeRecords = /* @__PURE__ */ new Map();
4028
4204
  const barrierOrFreeIds = /* @__PURE__ */ new Set();
4029
4205
  const renamedTargetNodes = /* @__PURE__ */ new WeakSet();
@@ -4145,17 +4321,17 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
4145
4321
  ensureScopeChain(ancestors);
4146
4322
  },
4147
4323
  ImportSpecifier(node) {
4148
- if (_optionalChain([node, 'access', _311 => _311.local, 'optionalAccess', _312 => _312.name])) barrierOrFreeIds.add(node.local.name);
4324
+ if (_optionalChain([node, 'access', _327 => _327.local, 'optionalAccess', _328 => _328.name])) barrierOrFreeIds.add(node.local.name);
4149
4325
  },
4150
4326
  ImportDefaultSpecifier(node) {
4151
- if (_optionalChain([node, 'access', _313 => _313.local, 'optionalAccess', _314 => _314.name])) barrierOrFreeIds.add(node.local.name);
4327
+ if (_optionalChain([node, 'access', _329 => _329.local, 'optionalAccess', _330 => _330.name])) barrierOrFreeIds.add(node.local.name);
4152
4328
  },
4153
4329
  ImportNamespaceSpecifier(node) {
4154
- if (_optionalChain([node, 'access', _315 => _315.local, 'optionalAccess', _316 => _316.name])) barrierOrFreeIds.add(node.local.name);
4330
+ if (_optionalChain([node, 'access', _331 => _331.local, 'optionalAccess', _332 => _332.name])) barrierOrFreeIds.add(node.local.name);
4155
4331
  },
4156
4332
  FunctionDeclaration(node, _state, ancestors) {
4157
4333
  registerFunctionParams(node, ancestors);
4158
- if (_optionalChain([node, 'access', _317 => _317.id, 'optionalAccess', _318 => _318.type]) === "Identifier") {
4334
+ if (_optionalChain([node, 'access', _333 => _333.id, 'optionalAccess', _334 => _334.type]) === "Identifier") {
4159
4335
  const parentAncestors = ancestors.slice(0, -1);
4160
4336
  const lexNode = findEnclosingLexicalNode(parentAncestors);
4161
4337
  const fnNode = _nullishCoalesce(findEnclosingFunctionNode(parentAncestors), () => ( ast));
@@ -4163,15 +4339,15 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
4163
4339
  if (lexNode === fnNode.body || fnNode === ast) {
4164
4340
  registerBarrierName(fnNode, node.id.name);
4165
4341
  }
4166
- if (!_optionalChain([scopeRecords, 'access', _319 => _319.get, 'call', _320 => _320(node), 'optionalAccess', _321 => _321.bindings, 'access', _322 => _322.has, 'call', _323 => _323(node.id.name)])) {
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)])) {
4167
4343
  registerBarrierName(node, node.id.name);
4168
4344
  }
4169
4345
  }
4170
4346
  },
4171
4347
  FunctionExpression(node, _state, ancestors) {
4172
4348
  registerFunctionParams(node, ancestors);
4173
- if (_optionalChain([node, 'access', _324 => _324.id, 'optionalAccess', _325 => _325.type]) === "Identifier") {
4174
- if (!_optionalChain([scopeRecords, 'access', _326 => _326.get, 'call', _327 => _327(node), 'optionalAccess', _328 => _328.bindings, 'access', _329 => _329.has, 'call', _330 => _330(node.id.name)])) {
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)])) {
4175
4351
  registerBarrierName(node, node.id.name);
4176
4352
  }
4177
4353
  }
@@ -4181,7 +4357,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
4181
4357
  },
4182
4358
  ClassDeclaration(node, _state, ancestors) {
4183
4359
  ensureScopeChain(ancestors);
4184
- if (_optionalChain([node, 'access', _331 => _331.id, 'optionalAccess', _332 => _332.type]) === "Identifier") {
4360
+ if (_optionalChain([node, 'access', _347 => _347.id, 'optionalAccess', _348 => _348.type]) === "Identifier") {
4185
4361
  const parentAncestors = ancestors.slice(0, -1);
4186
4362
  const lexNode = findEnclosingLexicalNode(parentAncestors);
4187
4363
  registerBarrierName(lexNode, node.id.name);
@@ -4190,7 +4366,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
4190
4366
  },
4191
4367
  ClassExpression(node, _state, ancestors) {
4192
4368
  ensureScopeChain(ancestors);
4193
- if (_optionalChain([node, 'access', _333 => _333.id, 'optionalAccess', _334 => _334.type]) === "Identifier") {
4369
+ if (_optionalChain([node, 'access', _349 => _349.id, 'optionalAccess', _350 => _350.type]) === "Identifier") {
4194
4370
  registerBarrierName(node, node.id.name);
4195
4371
  }
4196
4372
  },
@@ -4229,7 +4405,7 @@ function applyPolymorphicMangler(ast, seed = 2654435769, serializedFunctionNodes
4229
4405
  if (ancestors[i] === fnScope) break;
4230
4406
  if (ancestors[i].type === "CatchClause") {
4231
4407
  const catchScope = scopeRecords.get(ancestors[i]);
4232
- if (_optionalChain([catchScope, 'optionalAccess', _335 => _335.bindings, 'access', _336 => _336.has, 'call', _337 => _337(origName)])) {
4408
+ if (_optionalChain([catchScope, 'optionalAccess', _351 => _351.bindings, 'access', _352 => _352.has, 'call', _353 => _353(origName)])) {
4233
4409
  registerBarrierName(ancestors[i], origName);
4234
4410
  registerBarrierName(fnScope, origName);
4235
4411
  }
@@ -4876,17 +5052,30 @@ function extractParamNames(paramNode, out = []) {
4876
5052
  }
4877
5053
  return out;
4878
5054
  }
5055
+ function makeSafeNumericParam(name) {
5056
+ return {
5057
+ type: "ConditionalExpression",
5058
+ test: {
5059
+ type: "BinaryExpression",
5060
+ operator: "===",
5061
+ left: makeUnary("typeof", { type: "Identifier", name }),
5062
+ right: makeLiteral("number")
5063
+ },
5064
+ consequent: makeBinary("|", { type: "Identifier", name }, makeLiteral(0)),
5065
+ alternate: makeLiteral(0)
5066
+ };
5067
+ }
4879
5068
  function buildLiveVariables4(seed, fnIndex, paramNode, isArrowFn = false, ctxOpts) {
4880
5069
  const candidates = [];
4881
5070
  const seenNames = /* @__PURE__ */ new Set();
4882
- const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _338 => _338.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
5071
+ const names = [..._nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _354 => _354.liveVars]), () => ( [])), ...extractParamNames(paramNode)];
4883
5072
  for (const name of names) {
4884
5073
  if (name && name !== "arguments" && name !== "eval" && !seenNames.has(name)) {
4885
5074
  seenNames.add(name);
4886
- candidates.push(makeBinary("|", { type: "Identifier", name }, makeLiteral(0)));
5075
+ candidates.push(makeSafeNumericParam(name));
4887
5076
  }
4888
5077
  }
4889
- if (_optionalChain([ctxOpts, 'optionalAccess', _339 => _339.aliasIdentA]) && _optionalChain([ctxOpts, 'optionalAccess', _340 => _340.aliasIdentB])) {
5078
+ if (_optionalChain([ctxOpts, 'optionalAccess', _355 => _355.aliasIdentA]) && _optionalChain([ctxOpts, 'optionalAccess', _356 => _356.aliasIdentB])) {
4890
5079
  const slot0 = fnIndex + 0 & 3;
4891
5080
  const slot1 = fnIndex + 1 & 3;
4892
5081
  candidates.push(makeBinary("|", makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(slot0)), makeLiteral(0)));
@@ -4930,13 +5119,21 @@ function buildLiveVariables4(seed, fnIndex, paramNode, isArrowFn = false, ctxOpt
4930
5119
  }
4931
5120
  return [candidates[0], candidates[1], candidates[2], candidates[3]];
4932
5121
  }
5122
+ 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 }
5127
+ ];
4933
5128
  function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArrowFn = false, ctxOpts) {
4934
- const domain = _nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _341 => _341.returnDomain]), () => ( "object"));
5129
+ const domain = _nullishCoalesce(_optionalChain([ctxOpts, 'optionalAccess', _357 => _357.returnDomain]), () => ( "object"));
4935
5130
  const [x1, x2, x3, x4] = buildLiveVariables4(seed, fnIndex, paramNode, isArrowFn, ctxOpts);
4936
5131
  const mba4 = buildMba4Ast(seed, fnIndex, x1, x2, x3, x4);
5132
+ const qnrFamilyIdx = ((seed ^ Math.imul(fnIndex + 1, 2654435761)) >>> 0) % QNR_RESIDUE_FAMILIES.length;
5133
+ const qnrFamily = QNR_RESIDUE_FAMILIES[qnrFamilyIdx];
4937
5134
  let qnrLeft;
4938
5135
  let zRefForDecoy;
4939
- if (_optionalChain([ctxOpts, 'optionalAccess', _342 => _342.scratchVarIdent])) {
5136
+ if (_optionalChain([ctxOpts, 'optionalAccess', _358 => _358.scratchVarIdent])) {
4940
5137
  const scratchId = { type: "Identifier", name: ctxOpts.scratchVarIdent };
4941
5138
  const rivestOnScratch = buildRivestPermAst(seed, fnIndex, scratchId);
4942
5139
  const seqExprs = [
@@ -4961,11 +5158,29 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
4961
5158
  right: buildSboxMixAst(ctxOpts.sboxIdent, ctxOpts.scratchVarIdent)
4962
5159
  });
4963
5160
  }
5161
+ if (ctxOpts.aliasIdentA) {
5162
+ const aliasSlot = fnIndex + (seed & 3) & 3;
5163
+ const aliasMem = makeMemberIndex(ctxOpts.aliasIdentA, makeLiteral(aliasSlot));
5164
+ seqExprs.push({
5165
+ type: "AssignmentExpression",
5166
+ 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
+ )
5177
+ });
5178
+ }
4964
5179
  seqExprs.push(
4965
5180
  makeBinary(
4966
5181
  "&",
4967
- makeBinary("+", makeImul(cloneNode(scratchId), cloneNode(scratchId)), makeLiteral(1)),
4968
- makeLiteral(3)
5182
+ makeBinary("+", makeImul(cloneNode(scratchId), cloneNode(scratchId)), makeLiteral(qnrFamily.add)),
5183
+ makeLiteral(qnrFamily.mask)
4969
5184
  )
4970
5185
  );
4971
5186
  qnrLeft = {
@@ -4977,8 +5192,8 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
4977
5192
  const zExpr = buildRivestPermAst(seed, fnIndex, mba4);
4978
5193
  qnrLeft = makeBinary(
4979
5194
  "&",
4980
- makeBinary("+", makeImul(cloneNode(zExpr), cloneNode(zExpr)), makeLiteral(1)),
4981
- makeLiteral(3)
5195
+ makeBinary("+", makeImul(cloneNode(zExpr), cloneNode(zExpr)), makeLiteral(qnrFamily.add)),
5196
+ makeLiteral(qnrFamily.mask)
4982
5197
  );
4983
5198
  zRefForDecoy = zExpr;
4984
5199
  }
@@ -4995,7 +5210,7 @@ function createSotaMbaPredicate(seed, fnIndex = 0, paramNode, decoyIdent, isArro
4995
5210
  type: "BinaryExpression",
4996
5211
  operator: "===",
4997
5212
  left: qnrLeft,
4998
- right: makeLiteral(3)
5213
+ right: makeLiteral(qnrFamily.target)
4999
5214
  },
5000
5215
  consequent,
5001
5216
  alternate: null
@@ -5048,7 +5263,7 @@ function inferFunctionReturnDomain(fnNode) {
5048
5263
  }
5049
5264
  }
5050
5265
  scanStmts(fnNode.body);
5051
- if (!hasReturnArg && _optionalChain([fnNode, 'access', _343 => _343.body, 'optionalAccess', _344 => _344.type]) === "BlockStatement") return "void";
5266
+ if (!hasReturnArg && _optionalChain([fnNode, 'access', _359 => _359.body, 'optionalAccess', _360 => _360.type]) === "BlockStatement") return "void";
5052
5267
  if (seenObject) return "object";
5053
5268
  if (seenBoolean && !seenNumber && !seenString) return "boolean";
5054
5269
  if (seenNumber && !seenBoolean && !seenString) return "number";
@@ -5107,8 +5322,8 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
5107
5322
  const scratchVarIdent = `_uZt${sfx}`;
5108
5323
  if (Array.isArray(ast.body)) {
5109
5324
  const alreadyGuarded = ast.body.some(
5110
- (stmt) => stmt.type === "VariableDeclaration" && _optionalChain([stmt, 'access', _345 => _345.declarations, 'optionalAccess', _346 => _346.some, 'call', _347 => _347(
5111
- (d) => _optionalChain([d, 'access', _348 => _348.id, 'optionalAccess', _349 => _349.type]) === "Identifier" && (d.id.name === decoyIdent || d.id.name === sboxIdent)
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)
5112
5327
  )])
5113
5328
  );
5114
5329
  if (alreadyGuarded) return 0;
@@ -5117,13 +5332,14 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
5117
5332
  function maybeInjectGuard(node) {
5118
5333
  if (guardedCount >= MAX_COLD_GUARDS_PER_CHUNK) return;
5119
5334
  if (!coldFunctionNodes.has(node)) return;
5120
- if (_optionalChain([hotExemptNodes, 'optionalAccess', _350 => _350.has, 'call', _351 => _351(node)]) || node._unpeekSerialized) return;
5335
+ if (_optionalChain([hotExemptNodes, 'optionalAccess', _366 => _366.has, 'call', _367 => _367(node)]) || node._unpeekSerialized) return;
5336
+ if (node._unpeekVirtualized === true) return;
5121
5337
  if (!node.body || node.body.type !== "BlockStatement") return;
5122
5338
  const paramNames = [];
5123
5339
  for (const p of node.params || []) {
5124
5340
  extractParamNames(p, paramNames);
5125
5341
  }
5126
- const firstParam = _optionalChain([node, 'access', _352 => _352.params, 'optionalAccess', _353 => _353[0]]);
5342
+ const firstParam = _optionalChain([node, 'access', _368 => _368.params, 'optionalAccess', _369 => _369[0]]);
5127
5343
  const isArrow = node.type === "ArrowFunctionExpression";
5128
5344
  const returnDomain = inferFunctionReturnDomain(node);
5129
5345
  const guardStmt = createSotaMbaPredicate(
@@ -5174,7 +5390,7 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
5174
5390
  hotExemptNodes.add(sharedDecoyDecl);
5175
5391
  hotExemptNodes.add(sboxAliasDecl);
5176
5392
  for (const decl of sharedDecoyDecl.declarations || []) {
5177
- if (_optionalChain([decl, 'access', _354 => _354.init, 'optionalAccess', _355 => _355.type]) === "ArrayExpression" && decl.init.elements) {
5393
+ if (_optionalChain([decl, 'access', _370 => _370.init, 'optionalAccess', _371 => _371.type]) === "ArrayExpression" && decl.init.elements) {
5178
5394
  for (const el of decl.init.elements) {
5179
5395
  if (el) hotExemptNodes.add(el);
5180
5396
  }
@@ -5184,7 +5400,7 @@ function applyColdFlowGuard(ast, coldFunctionNodes, seed = 2654435769, hotExempt
5184
5400
  let insertIdx = 0;
5185
5401
  while (insertIdx < ast.body.length) {
5186
5402
  const stmt = ast.body[insertIdx];
5187
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _356 => _356.expression, 'optionalAccess', _357 => _357.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
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()));
5188
5404
  if (isDirective || stmt.type === "ImportDeclaration") {
5189
5405
  insertIdx++;
5190
5406
  } else {
@@ -5334,34 +5550,41 @@ function generateOpcodeMap(seed, count = OPCODE_COUNT) {
5334
5550
  }
5335
5551
  return pool.slice(0, count);
5336
5552
  }
5337
- function makeHandlerMbaZeroExpr(seed, op) {
5553
+ function computeHandlerDelta(op) {
5554
+ const delta = (op + 1) * 7 & 31;
5555
+ return delta === 0 ? 7 : delta;
5556
+ }
5557
+ function makeHandlerMbaOffsetExpr(seed, op, deltaOp) {
5338
5558
  const variant = Math.abs(mixOpSeed(seed, op * 11 + 3)) % 4;
5339
5559
  const c1 = mixOpSeed(seed, op * 11 + 5);
5340
5560
  const c2 = mixOpSeed(seed, op * 11 + 7);
5341
5561
  if (variant === 0) {
5342
- const cSum = c1 + c2 | 0;
5562
+ const cSum = c1 + c2 - deltaOp | 0;
5343
5563
  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`;
5344
5564
  }
5345
5565
  if (variant === 1) {
5346
- const cSum = c1 + c2 | 0;
5566
+ const cSum = c1 + c2 + deltaOp | 0;
5347
5567
  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`;
5348
5568
  }
5349
5569
  if (variant === 2) {
5350
- const cFold = 1 - c1 - c2 | 0;
5351
- return `(((~$f.ac|${c1})+(~$f.ac&${c1}))+(($f.ac|${c2})+($f.ac&${c2}))+${cFold})|0`;
5570
+ const cFold2 = 1 + deltaOp - c1 - c2 | 0;
5571
+ return `(((~$f.ac|${c1})+(~$f.ac&${c1}))+(($f.ac|$f.p)-(~$f.ac&$f.p))+(($f.p&${c2})+(~$f.p&${c2}))+${cFold2})|0`;
5352
5572
  }
5353
- return `((($f.ac|$f.p)-(~$f.ac&$f.p))^((($f.ac&${c1})+($f.ac&~${c1}))))|0`;
5573
+ const cFold = c1 - deltaOp | 0;
5574
+ 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`;
5354
5575
  }
5355
5576
  function wrapHandlerWithMba(seed, op, coreBody, isTerminal = false) {
5356
- const zExpr = makeHandlerMbaZeroExpr(seed, op);
5577
+ const deltaOp = computeHandlerDelta(op);
5578
+ const zExpr = makeHandlerMbaOffsetExpr(seed, op, deltaOp);
5357
5579
  const shape = Math.abs(mixOpSeed(seed, op * 17 + 1)) % 3;
5358
5580
  const zVar = shape === 0 ? "$z0" : shape === 1 ? "$m0" : "$k0";
5359
5581
  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);";
5360
- const adjustedBody = coreBody.replace(/\$Z/g, zVar);
5582
+ const balancedOffset = `(${zVar}-${deltaOp})`;
5583
+ const adjustedBody = coreBody.replace(/\$Z/g, balancedOffset);
5361
5584
  if (coreBody.includes("$Z")) {
5362
5585
  return `function($f){var ${zVar}=${zExpr};${adjustedBody}${tail}}`;
5363
5586
  }
5364
- return `function($f){var ${zVar}=${zExpr};$f.r=($f.r+${zVar})|0;${adjustedBody}${tail}}`;
5587
+ return `function($f){var ${zVar}=${zExpr};$f.r=($f.r+${balancedOffset})|0;${adjustedBody}${tail}}`;
5365
5588
  }
5366
5589
  function createInterpreterSource(vmHelperName, opMap, seed = 2654435769, windowKeySymbol, expectedDelta) {
5367
5590
  const opCount = opMap.length;
@@ -5430,17 +5653,22 @@ function createInterpreterSource(vmHelperName, opMap, seed = 2654435769, windowK
5430
5653
  const spec = coreHandlers[op];
5431
5654
  handlers[slotMap[op]] = wrapHandlerWithMba(seed, op, spec.body, Boolean(spec.terminal));
5432
5655
  }
5433
- const hasSym = Boolean(windowKeySymbol && expectedDelta !== void 0);
5656
+ const hasSym = Boolean(windowKeySymbol);
5657
+ const hasExpDelta = Boolean(hasSym && expectedDelta !== void 0);
5434
5658
  const symPropAccess = hasSym ? /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(windowKeySymbol) ? `.${windowKeySymbol}` : `[${JSON.stringify(windowKeySymbol)}]` : "";
5435
5659
  const symTamperPropAccess = hasSym ? /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(`${windowKeySymbol}_t`) ? `.${windowKeySymbol}_t` : `[${JSON.stringify(`${windowKeySymbol}_t`)}]` : "";
5436
- const expD = hasSym ? expectedDelta & 65535 : 0;
5660
+ const symStatePropAccess = hasSym ? /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(`${windowKeySymbol}_s`) ? `.${windowKeySymbol}_s` : `[${JSON.stringify(`${windowKeySymbol}_s`)}]` : "";
5661
+ const expD = hasExpDelta ? expectedDelta & 65535 : 0;
5437
5662
  const seed32 = seed | 0;
5438
- const expDigest = hasSym ? Math.imul(expD ^ seed32 | 0, 2654435761) ^ (expD << 16 | seed32 >>> 16) ^ 2246822507 | 0 : 0;
5439
- const tamperCheckExpr = hasSym ? `var $bad=$G[$tk]===!0||$G${symTamperPropAccess}===!0,$sv=$G${symPropAccess};if(!$bad&&$sv!==void 0){if(Array.isArray($sv)){if($sv[0]===2)$bad=true;}else{var $sh=(Math.imul(($sv^$S)|0,0x9e3779b1)^(($sv<<16)|($S>>>16))^0x85ebca6b)|0;if($sh!==$D)$bad=true;}}` : `var $bad=$G[$tk]===!0;`;
5440
- const paramsList = hasSym ? "$P,$A,$B,$C,$S,$D" : "$P,$A,$B,$C,$S";
5441
- const factoryRaw = `(function $I(${paramsList}){var $G=typeof globalThis<"u"?globalThis:(typeof window<"u"?window:this);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(
5663
+ 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;
5666
+ 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";
5669
+ 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(
5442
5670
  ","
5443
- )}];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;}return 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});};})`;
5671
+ )}];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;})`;
5444
5672
  const parsedFactory = acorn6.parse(factoryRaw, {
5445
5673
  ecmaVersion: "latest",
5446
5674
  sourceType: "script"
@@ -5449,7 +5677,7 @@ function createInterpreterSource(vmHelperName, opMap, seed = 2654435769, windowK
5449
5677
  const argA = opMask & 255;
5450
5678
  const argB = slotMask & 255;
5451
5679
  const argC = vmKey | 0;
5452
- return `var ${vmHelperName}=(${compactFactory})([${pairs.join(",")}],${argA},${argB},${argC},${seed32}${hasSym ? `,${expDigest}` : ""});`;
5680
+ return `var ${vmHelperName}=(${compactFactory})([${pairs.join(",")}],${argA},${argB},${argC},${seed32}${hasExpDelta ? `,${expDigest}` : ""});`;
5453
5681
  }
5454
5682
  function walkWithParent(node, parent, visitor) {
5455
5683
  if (!node || typeof node !== "object") return;
@@ -5583,7 +5811,7 @@ function prepareLoweredFunction(fnNode, enclosingBindings) {
5583
5811
  loweredParams.push({ type: "Identifier", name: param.name });
5584
5812
  continue;
5585
5813
  }
5586
- if (param.type === "RestElement" && _optionalChain([param, 'access', _358 => _358.argument, 'optionalAccess', _359 => _359.type]) === "Identifier") {
5814
+ if (param.type === "RestElement" && _optionalChain([param, 'access', _374 => _374.argument, 'optionalAccess', _375 => _375.type]) === "Identifier") {
5587
5815
  wrapperParams.push(param);
5588
5816
  paramPassExprs.push({ type: "Identifier", name: param.argument.name });
5589
5817
  loweredParams.push({ type: "Identifier", name: param.argument.name });
@@ -5642,7 +5870,7 @@ function prepareLoweredFunction(fnNode, enclosingBindings) {
5642
5870
  return null;
5643
5871
  }
5644
5872
  clone.params = loweredParams;
5645
- if (_optionalChain([clone, 'access', _360 => _360.body, 'optionalAccess', _361 => _361.type]) !== "BlockStatement") {
5873
+ if (_optionalChain([clone, 'access', _376 => _376.body, 'optionalAccess', _377 => _377.type]) !== "BlockStatement") {
5646
5874
  clone.body = {
5647
5875
  type: "BlockStatement",
5648
5876
  body: [
@@ -5659,6 +5887,33 @@ function prepareLoweredFunction(fnNode, enclosingBindings) {
5659
5887
  }
5660
5888
  return { loweredFn: clone, wrapperParams, paramPassExprs };
5661
5889
  }
5890
+ function definitelyTerminates(stmt) {
5891
+ if (!stmt) return false;
5892
+ switch (stmt.type) {
5893
+ case "ReturnStatement":
5894
+ case "ThrowStatement":
5895
+ return true;
5896
+ case "BlockStatement": {
5897
+ const stmts = stmt.body || [];
5898
+ for (const s of stmts) {
5899
+ if (definitelyTerminates(s)) return true;
5900
+ }
5901
+ return false;
5902
+ }
5903
+ case "IfStatement":
5904
+ return Boolean(
5905
+ stmt.alternate && definitelyTerminates(stmt.consequent) && definitelyTerminates(stmt.alternate)
5906
+ );
5907
+ case "TryStatement": {
5908
+ if (stmt.finalizer && definitelyTerminates(stmt.finalizer)) return true;
5909
+ if (!definitelyTerminates(stmt.block)) return false;
5910
+ if (stmt.handler && !definitelyTerminates(stmt.handler.body)) return false;
5911
+ return true;
5912
+ }
5913
+ default:
5914
+ return false;
5915
+ }
5916
+ }
5662
5917
  function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
5663
5918
  const bytecode = [];
5664
5919
  const consts = [];
@@ -5721,7 +5976,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
5721
5976
  }
5722
5977
  if (node.type === "TryStatement") {
5723
5978
  scanVarDecls(node.block, false);
5724
- if (_optionalChain([node, 'access', _362 => _362.handler, 'optionalAccess', _363 => _363.body])) scanVarDecls(node.handler.body, false);
5979
+ if (_optionalChain([node, 'access', _378 => _378.handler, 'optionalAccess', _379 => _379.body])) scanVarDecls(node.handler.body, false);
5725
5980
  if (node.finalizer) scanVarDecls(node.finalizer, false);
5726
5981
  return;
5727
5982
  }
@@ -5839,7 +6094,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
5839
6094
  if (prop.computed) {
5840
6095
  if (!compileExpr(prop.key, true)) return false;
5841
6096
  } else {
5842
- const keyName = _optionalChain([prop, 'access', _364 => _364.key, 'optionalAccess', _365 => _365.type]) === "Identifier" ? prop.key.name : _optionalChain([prop, 'access', _366 => _366.key, 'optionalAccess', _367 => _367.type]) === "Literal" ? String(prop.key.value) : void 0;
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;
5843
6098
  if (keyName === void 0) return false;
5844
6099
  emit(OP_LDC, addConst(keyName));
5845
6100
  }
@@ -5978,11 +6233,11 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
5978
6233
  case "TemplateLiteral": {
5979
6234
  const quasis = node.quasis || [];
5980
6235
  const exprs = node.expressions || [];
5981
- emit(OP_LDC, addConst(_nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _368 => _368[0], 'optionalAccess', _369 => _369.value, 'optionalAccess', _370 => _370.cooked]), () => ( _optionalChain([quasis, 'access', _371 => _371[0], 'optionalAccess', _372 => _372.value, 'optionalAccess', _373 => _373.raw]))), () => ( ""))));
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]))), () => ( ""))));
5982
6237
  for (let i = 0; i < exprs.length; i++) {
5983
6238
  if (!compileExpr(exprs[i], true)) return false;
5984
6239
  emit(OP_ADD);
5985
- const qStr = _nullishCoalesce(_nullishCoalesce(_optionalChain([quasis, 'access', _374 => _374[i + 1], 'optionalAccess', _375 => _375.value, 'optionalAccess', _376 => _376.cooked]), () => ( _optionalChain([quasis, 'access', _377 => _377[i + 1], 'optionalAccess', _378 => _378.value, 'optionalAccess', _379 => _379.raw]))), () => ( ""));
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]))), () => ( ""));
5986
6241
  if (qStr.length > 0) {
5987
6242
  emit(OP_LDC, addConst(qStr));
5988
6243
  emit(OP_ADD);
@@ -6068,7 +6323,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6068
6323
  if (inValuePos) emit(OP_LDC, addConst(void 0));
6069
6324
  return true;
6070
6325
  }
6071
- if (node.operator === "typeof" && _optionalChain([node, 'access', _380 => _380.argument, 'optionalAccess', _381 => _381.type]) === "Identifier") {
6326
+ if (node.operator === "typeof" && _optionalChain([node, 'access', _396 => _396.argument, 'optionalAccess', _397 => _397.type]) === "Identifier") {
6072
6327
  const name = node.argument.name;
6073
6328
  if (name === "undefined" && resolveLocal("undefined") === void 0) {
6074
6329
  emit(OP_LDC, addConst(void 0));
@@ -6115,7 +6370,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6115
6370
  if (node.computed) {
6116
6371
  if (!compileExpr(node.property, true)) return false;
6117
6372
  } else {
6118
- if (_optionalChain([node, 'access', _382 => _382.property, 'optionalAccess', _383 => _383.type]) !== "Identifier") return false;
6373
+ if (_optionalChain([node, 'access', _398 => _398.property, 'optionalAccess', _399 => _399.type]) !== "Identifier") return false;
6119
6374
  emit(OP_LDC, addConst(node.property.name));
6120
6375
  }
6121
6376
  emit(OP_GETP);
@@ -6125,7 +6380,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6125
6380
  case "CallExpression": {
6126
6381
  if (node.optional) return false;
6127
6382
  for (const arg of node.arguments || []) {
6128
- if (_optionalChain([arg, 'optionalAccess', _384 => _384.type]) === "SpreadElement") return false;
6383
+ if (_optionalChain([arg, 'optionalAccess', _400 => _400.type]) === "SpreadElement") return false;
6129
6384
  }
6130
6385
  if (node.callee.type === "MemberExpression") {
6131
6386
  if (node.callee.optional) return false;
@@ -6133,7 +6388,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6133
6388
  if (node.callee.computed) {
6134
6389
  if (!compileExpr(node.callee.property, true)) return false;
6135
6390
  } else {
6136
- if (_optionalChain([node, 'access', _385 => _385.callee, 'access', _386 => _386.property, 'optionalAccess', _387 => _387.type]) !== "Identifier") return false;
6391
+ if (_optionalChain([node, 'access', _401 => _401.callee, 'access', _402 => _402.property, 'optionalAccess', _403 => _403.type]) !== "Identifier") return false;
6137
6392
  emit(OP_LDC, addConst(node.callee.property.name));
6138
6393
  }
6139
6394
  for (const arg of node.arguments) {
@@ -6152,7 +6407,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6152
6407
  }
6153
6408
  case "NewExpression": {
6154
6409
  for (const arg of node.arguments || []) {
6155
- if (_optionalChain([arg, 'optionalAccess', _388 => _388.type]) === "SpreadElement") return false;
6410
+ if (_optionalChain([arg, 'optionalAccess', _404 => _404.type]) === "SpreadElement") return false;
6156
6411
  }
6157
6412
  if (!compileExpr(node.callee, true)) return false;
6158
6413
  for (const arg of node.arguments || []) {
@@ -6195,7 +6450,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6195
6450
  if (node.left.computed) {
6196
6451
  if (!compileExpr(node.left.property, true)) return false;
6197
6452
  } else {
6198
- if (_optionalChain([node, 'access', _389 => _389.left, 'access', _390 => _390.property, 'optionalAccess', _391 => _391.type]) !== "Identifier") return false;
6453
+ if (_optionalChain([node, 'access', _405 => _405.left, 'access', _406 => _406.property, 'optionalAccess', _407 => _407.type]) !== "Identifier") return false;
6199
6454
  emit(OP_LDC, addConst(node.left.property.name));
6200
6455
  }
6201
6456
  if (!compileExpr(node.right, true)) return false;
@@ -6211,7 +6466,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6211
6466
  if (node.left.computed) {
6212
6467
  if (!compileExpr(node.left.property, true)) return false;
6213
6468
  } else {
6214
- if (_optionalChain([node, 'access', _392 => _392.left, 'access', _393 => _393.property, 'optionalAccess', _394 => _394.type]) !== "Identifier") return false;
6469
+ if (_optionalChain([node, 'access', _408 => _408.left, 'access', _409 => _409.property, 'optionalAccess', _410 => _410.type]) !== "Identifier") return false;
6215
6470
  emit(OP_LDC, addConst(node.left.property.name));
6216
6471
  }
6217
6472
  emit(OP_STV, keySlot);
@@ -6231,7 +6486,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6231
6486
  case "UpdateExpression": {
6232
6487
  const oneIdx = addConst(1);
6233
6488
  const stepOp = node.operator === "++" ? OP_ADD : OP_SUB;
6234
- if (_optionalChain([node, 'access', _395 => _395.argument, 'optionalAccess', _396 => _396.type]) === "Identifier") {
6489
+ if (_optionalChain([node, 'access', _411 => _411.argument, 'optionalAccess', _412 => _412.type]) === "Identifier") {
6235
6490
  const name = node.argument.name;
6236
6491
  if (!canWriteVar(name)) return false;
6237
6492
  if (node.prefix) {
@@ -6257,7 +6512,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6257
6512
  }
6258
6513
  return true;
6259
6514
  }
6260
- if (_optionalChain([node, 'access', _397 => _397.argument, 'optionalAccess', _398 => _398.type]) === "MemberExpression" && !node.argument.optional) {
6515
+ if (_optionalChain([node, 'access', _413 => _413.argument, 'optionalAccess', _414 => _414.type]) === "MemberExpression" && !node.argument.optional) {
6261
6516
  const objSlot = allocTempSlot();
6262
6517
  const keySlot = allocTempSlot();
6263
6518
  const oldSlot = allocTempSlot();
@@ -6266,7 +6521,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6266
6521
  if (node.argument.computed) {
6267
6522
  if (!compileExpr(node.argument.property, true)) return false;
6268
6523
  } else {
6269
- if (_optionalChain([node, 'access', _399 => _399.argument, 'access', _400 => _400.property, 'optionalAccess', _401 => _401.type]) !== "Identifier") return false;
6524
+ if (_optionalChain([node, 'access', _415 => _415.argument, 'access', _416 => _416.property, 'optionalAccess', _417 => _417.type]) !== "Identifier") return false;
6270
6525
  emit(OP_LDC, addConst(node.argument.property.name));
6271
6526
  }
6272
6527
  emit(OP_STV, keySlot);
@@ -6298,7 +6553,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6298
6553
  if (prop.computed) {
6299
6554
  if (!compileExpr(prop.key, true)) return false;
6300
6555
  } else {
6301
- const keyName = _nullishCoalesce(_optionalChain([prop, 'access', _402 => _402.key, 'optionalAccess', _403 => _403.name]), () => ( _optionalChain([prop, 'access', _404 => _404.key, 'optionalAccess', _405 => _405.value])));
6556
+ const keyName = _nullishCoalesce(_optionalChain([prop, 'access', _418 => _418.key, 'optionalAccess', _419 => _419.name]), () => ( _optionalChain([prop, 'access', _420 => _420.key, 'optionalAccess', _421 => _421.value])));
6302
6557
  if (keyName === void 0) return false;
6303
6558
  emit(OP_LDC, addConst(keyName));
6304
6559
  }
@@ -6350,14 +6605,14 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6350
6605
  }
6351
6606
  case "VariableDeclaration": {
6352
6607
  for (const decl of stmt.declarations) {
6353
- if (_optionalChain([decl, 'access', _406 => _406.id, 'optionalAccess', _407 => _407.type]) === "Identifier") {
6608
+ if (_optionalChain([decl, 'access', _422 => _422.id, 'optionalAccess', _423 => _423.type]) === "Identifier") {
6354
6609
  const slot = resolveLocal(decl.id.name);
6355
6610
  if (slot === void 0) return false;
6356
6611
  if (decl.init) {
6357
6612
  if (!compileExpr(decl.init, true)) return false;
6358
6613
  emit(OP_STV, slot);
6359
6614
  }
6360
- } else if (_optionalChain([decl, 'access', _408 => _408.id, 'optionalAccess', _409 => _409.type]) === "ObjectPattern" || _optionalChain([decl, 'access', _410 => _410.id, 'optionalAccess', _411 => _411.type]) === "ArrayPattern") {
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") {
6361
6616
  if (!decl.init) return false;
6362
6617
  const srcSlot = allocTempSlot();
6363
6618
  if (!compileExpr(decl.init, true)) return false;
@@ -6374,10 +6629,15 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6374
6629
  const jzPos = emitJumpPlaceholder(OP_JZ);
6375
6630
  if (!compileStmt(stmt.consequent, false)) return false;
6376
6631
  if (stmt.alternate) {
6377
- const jmpPos = emitJumpPlaceholder(OP_JMP);
6632
+ let jmpPos = -1;
6633
+ if (!definitelyTerminates(stmt.consequent)) {
6634
+ jmpPos = emitJumpPlaceholder(OP_JMP);
6635
+ }
6378
6636
  patchJump(jzPos, bytecode.length);
6379
6637
  if (!compileStmt(stmt.alternate, false)) return false;
6380
- patchJump(jmpPos, bytecode.length);
6638
+ if (jmpPos !== -1) {
6639
+ patchJump(jmpPos, bytecode.length);
6640
+ }
6381
6641
  } else {
6382
6642
  patchJump(jzPos, bytecode.length);
6383
6643
  }
@@ -6448,7 +6708,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6448
6708
  }
6449
6709
  case "ForStatement": {
6450
6710
  let pushedForScope = false;
6451
- if (_optionalChain([stmt, 'access', _412 => _412.init, 'optionalAccess', _413 => _413.type]) === "VariableDeclaration" && stmt.init.kind !== "var") {
6711
+ if (_optionalChain([stmt, 'access', _428 => _428.init, 'optionalAccess', _429 => _429.type]) === "VariableDeclaration" && stmt.init.kind !== "var") {
6452
6712
  const forScope = /* @__PURE__ */ new Map();
6453
6713
  const names = /* @__PURE__ */ new Set();
6454
6714
  for (const decl of stmt.init.declarations || []) {
@@ -6516,7 +6776,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6516
6776
  case "BreakStatement":
6517
6777
  case "ContinueStatement": {
6518
6778
  const isBreak = stmt.type === "BreakStatement";
6519
- const labelName = _optionalChain([stmt, 'access', _414 => _414.label, 'optionalAccess', _415 => _415.name]);
6779
+ const labelName = _optionalChain([stmt, 'access', _430 => _430.label, 'optionalAccess', _431 => _431.name]);
6520
6780
  let target;
6521
6781
  for (let i = loopStack.length - 1; i >= 0; i--) {
6522
6782
  if (!labelName || loopStack[i].label === labelName) {
@@ -6535,7 +6795,7 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6535
6795
  return true;
6536
6796
  }
6537
6797
  case "LabeledStatement": {
6538
- return compileStmt(stmt.body, false, _optionalChain([stmt, 'access', _416 => _416.label, 'optionalAccess', _417 => _417.name]));
6798
+ return compileStmt(stmt.body, false, _optionalChain([stmt, 'access', _432 => _432.label, 'optionalAccess', _433 => _433.name]));
6539
6799
  }
6540
6800
  case "TryStatement": {
6541
6801
  if (stmt.finalizer) {
@@ -6647,25 +6907,30 @@ function compileFunctionToBytecode(fnNode, opMap, enclosingBindings) {
6647
6907
  return false;
6648
6908
  }
6649
6909
  }
6910
+ let endsWithTermination = false;
6650
6911
  if (fnNode.body.type === "BlockStatement") {
6651
6912
  if (!compileStmt(fnNode.body, true)) return null;
6913
+ endsWithTermination = definitelyTerminates(fnNode.body);
6652
6914
  } else {
6653
6915
  if (!compileExpr(fnNode.body, true)) return null;
6654
6916
  emit(OP_RET);
6917
+ endsWithTermination = true;
6918
+ }
6919
+ if (!endsWithTermination) {
6920
+ emit(OP_LDC, addConst(void 0));
6921
+ emit(OP_RET);
6655
6922
  }
6656
- emit(OP_LDC, addConst(void 0));
6657
- emit(OP_RET);
6658
6923
  return { bytecode, consts, localCount, stateSlots, accSlots, upvalues };
6659
6924
  }
6660
6925
  function findInjectedVmHelperName(ast) {
6661
6926
  if (!ast || !Array.isArray(ast.body)) return null;
6662
6927
  for (const stmt of ast.body) {
6663
- if (stmt.type === "FunctionDeclaration" && typeof _optionalChain([stmt, 'access', _418 => _418.id, 'optionalAccess', _419 => _419.name]) === "string" && stmt.id.name.startsWith("_uVm")) {
6928
+ if (stmt.type === "FunctionDeclaration" && typeof _optionalChain([stmt, 'access', _434 => _434.id, 'optionalAccess', _435 => _435.name]) === "string" && stmt.id.name.startsWith("_uVm")) {
6664
6929
  return stmt.id.name;
6665
6930
  }
6666
6931
  if (stmt.type === "VariableDeclaration" && Array.isArray(stmt.declarations)) {
6667
6932
  for (const d of stmt.declarations) {
6668
- if (_optionalChain([d, 'access', _420 => _420.id, 'optionalAccess', _421 => _421.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uVm")) {
6933
+ if (_optionalChain([d, 'access', _436 => _436.id, 'optionalAccess', _437 => _437.type]) === "Identifier" && typeof d.id.name === "string" && d.id.name.startsWith("_uVm")) {
6669
6934
  return d.id.name;
6670
6935
  }
6671
6936
  }
@@ -6673,6 +6938,80 @@ function findInjectedVmHelperName(ast) {
6673
6938
  }
6674
6939
  return null;
6675
6940
  }
6941
+ 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
+ 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
+ function getVmCandidateName(fn, ancestors) {
6944
+ if (_optionalChain([fn, 'access', _438 => _438.id, 'optionalAccess', _439 => _439.type]) === "Identifier" && typeof fn.id.name === "string") {
6945
+ return fn.id.name;
6946
+ }
6947
+ const parent = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
6948
+ if (!parent) return "";
6949
+ if (parent.type === "VariableDeclarator" && _optionalChain([parent, 'access', _440 => _440.id, 'optionalAccess', _441 => _441.type]) === "Identifier") {
6950
+ return parent.id.name;
6951
+ }
6952
+ 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") {
6955
+ return parent.key.value;
6956
+ }
6957
+ }
6958
+ if (parent.type === "MethodDefinition" && _optionalChain([parent, 'access', _446 => _446.key, 'optionalAccess', _447 => _447.type]) === "Identifier") {
6959
+ return parent.key.name;
6960
+ }
6961
+ 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") {
6964
+ return parent.left.property.name;
6965
+ }
6966
+ }
6967
+ return "";
6968
+ }
6969
+ function bodyHasPrioritySignal(fnNode) {
6970
+ let matched = false;
6971
+ walkWithParent(fnNode.body, fnNode, (n, parent) => {
6972
+ if (matched) return false;
6973
+ if (n !== fnNode && FUNCTION_NODE_TYPES2.has(n.type)) return false;
6974
+ if (n.type === "CallExpression") {
6975
+ const callee = n.callee;
6976
+ if (_optionalChain([callee, 'optionalAccess', _455 => _455.type]) === "Identifier" && PRIORITY_CALL_NAME_RE.test(callee.name)) {
6977
+ matched = true;
6978
+ return false;
6979
+ }
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)) {
6981
+ matched = true;
6982
+ return false;
6983
+ }
6984
+ }
6985
+ if (n.type === "Identifier" && PRIORITY_CALL_NAME_RE.test(n.name)) {
6986
+ if (parent && parent.type === "MemberExpression" && !parent.computed && parent.property === n) {
6987
+ return;
6988
+ }
6989
+ if (parent && parent.type === "Property" && !parent.computed && parent.key === n && !parent.shorthand) {
6990
+ return;
6991
+ }
6992
+ matched = true;
6993
+ return false;
6994
+ }
6995
+ });
6996
+ return matched;
6997
+ }
6998
+ function scoreVmCandidate(fn, ancestors, criticalSet) {
6999
+ let score = 0;
7000
+ if (_optionalChain([criticalSet, 'optionalAccess', _459 => _459.has, 'call', _460 => _460(fn)])) {
7001
+ score += 1e3;
7002
+ }
7003
+ const candName = getVmCandidateName(fn, ancestors);
7004
+ if (candName && PRIORITY_HANDLER_NAME_RE.test(candName) || bodyHasPrioritySignal(fn)) {
7005
+ score += 500;
7006
+ }
7007
+ if (_optionalChain([fn, 'access', _461 => _461.body, 'optionalAccess', _462 => _462.type]) === "BlockStatement" && Array.isArray(fn.body.body)) {
7008
+ const stmtCount = fn.body.body.length;
7009
+ if (stmtCount >= 2) {
7010
+ score += Math.min(200, 10 + (stmtCount - 2) * 15);
7011
+ }
7012
+ }
7013
+ return score;
7014
+ }
6676
7015
  function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 2654435769, windowKeySymbol, expectedDelta, extraOpts) {
6677
7016
  const suffix = computeFnv1aHash(`micro-vm:${seed}`, seed).toString(36);
6678
7017
  const vmHelperName = `_uVm${suffix}`;
@@ -6683,8 +7022,8 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
6683
7022
  vmHelperName: existingName
6684
7023
  };
6685
7024
  }
6686
- const maxFunctions = _nullishCoalesce(_optionalChain([extraOpts, 'optionalAccess', _422 => _422.maxFunctionsPerChunk]), () => ( 12));
6687
- const criticalSet = _optionalChain([extraOpts, 'optionalAccess', _423 => _423.criticalFunctionNodes]);
7025
+ const maxFunctions = _nullishCoalesce(_optionalChain([extraOpts, 'optionalAccess', _463 => _463.maxFunctionsPerChunk]), () => ( 12));
7026
+ const criticalSet = _optionalChain([extraOpts, 'optionalAccess', _464 => _464.criticalFunctionNodes]);
6688
7027
  const opMap = generateOpcodeMap(seed, OPCODE_COUNT);
6689
7028
  const vmKey = deriveVmKey(seed);
6690
7029
  const scopeBindings = /* @__PURE__ */ new Map();
@@ -6717,7 +7056,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
6717
7056
  walk7.ancestor(ast, {
6718
7057
  ImportDeclaration(node) {
6719
7058
  for (const spec of node.specifiers || []) {
6720
- if (_optionalChain([spec, 'access', _424 => _424.local, 'optionalAccess', _425 => _425.type]) === "Identifier") {
7059
+ if (_optionalChain([spec, 'access', _465 => _465.local, 'optionalAccess', _466 => _466.type]) === "Identifier") {
6721
7060
  addScopeBinding(ast, spec.local.name);
6722
7061
  }
6723
7062
  }
@@ -6734,7 +7073,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
6734
7073
  },
6735
7074
  FunctionDeclaration(node, _state, ancestors) {
6736
7075
  const parentAncestors = ancestors.slice(0, -1);
6737
- if (_optionalChain([node, 'access', _426 => _426.id, 'optionalAccess', _427 => _427.type]) === "Identifier") {
7076
+ if (_optionalChain([node, 'access', _467 => _467.id, 'optionalAccess', _468 => _468.type]) === "Identifier") {
6738
7077
  addScopeBinding(findNearestLexicalScope(parentAncestors), node.id.name);
6739
7078
  addScopeBinding(findNearestFunctionOrProgram(parentAncestors), node.id.name);
6740
7079
  }
@@ -6748,7 +7087,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
6748
7087
  rawCandidates.push({ fn: node, ancestors: ancestors.slice() });
6749
7088
  },
6750
7089
  FunctionExpression(node, _state, ancestors) {
6751
- if (_optionalChain([node, 'access', _428 => _428.id, 'optionalAccess', _429 => _429.type]) === "Identifier") {
7090
+ if (_optionalChain([node, 'access', _469 => _469.id, 'optionalAccess', _470 => _470.type]) === "Identifier") {
6752
7091
  addScopeBinding(node, node.id.name);
6753
7092
  }
6754
7093
  const paramNames = /* @__PURE__ */ new Set();
@@ -6771,13 +7110,13 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
6771
7110
  rawCandidates.push({ fn: node, ancestors: ancestors.slice() });
6772
7111
  },
6773
7112
  ClassDeclaration(node, _state, ancestors) {
6774
- if (_optionalChain([node, 'access', _430 => _430.id, 'optionalAccess', _431 => _431.type]) === "Identifier") {
7113
+ if (_optionalChain([node, 'access', _471 => _471.id, 'optionalAccess', _472 => _472.type]) === "Identifier") {
6775
7114
  addScopeBinding(findNearestLexicalScope(ancestors.slice(0, -1)), node.id.name);
6776
7115
  addScopeBinding(node, node.id.name);
6777
7116
  }
6778
7117
  },
6779
7118
  ClassExpression(node) {
6780
- if (_optionalChain([node, 'access', _432 => _432.id, 'optionalAccess', _433 => _433.type]) === "Identifier") {
7119
+ if (_optionalChain([node, 'access', _473 => _473.id, 'optionalAccess', _474 => _474.type]) === "Identifier") {
6781
7120
  addScopeBinding(node, node.id.name);
6782
7121
  }
6783
7122
  },
@@ -6791,10 +7130,11 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
6791
7130
  }
6792
7131
  }
6793
7132
  });
6794
- const candidates = criticalSet ? [
6795
- ...rawCandidates.filter((c) => criticalSet.has(c.fn)),
6796
- ...rawCandidates.filter((c) => !criticalSet.has(c.fn))
6797
- ] : rawCandidates;
7133
+ const candidates = rawCandidates.map((c, idx) => ({
7134
+ ...c,
7135
+ score: scoreVmCandidate(c.fn, c.ancestors, criticalSet),
7136
+ idx
7137
+ })).sort((a, b) => b.score !== a.score ? b.score - a.score : a.idx - b.idx);
6798
7138
  let virtualizedCount = 0;
6799
7139
  for (const { fn, ancestors } of candidates) {
6800
7140
  if (virtualizedCount >= maxFunctions) break;
@@ -6808,7 +7148,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
6808
7148
  continue;
6809
7149
  }
6810
7150
  const parentNode = ancestors.length >= 2 ? ancestors[ancestors.length - 2] : null;
6811
- if (_optionalChain([parentNode, 'optionalAccess', _434 => _434.type]) === "MethodDefinition" && parentNode.kind === "constructor") {
7151
+ if (_optionalChain([parentNode, 'optionalAccess', _475 => _475.type]) === "MethodDefinition" && parentNode.kind === "constructor") {
6812
7152
  continue;
6813
7153
  }
6814
7154
  if (ancestors.some((a) => a.type === "WithStatement")) {
@@ -6830,7 +7170,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
6830
7170
  }
6831
7171
  }
6832
7172
  }
6833
- if (fn.type === "FunctionExpression" && _optionalChain([fn, 'access', _435 => _435.id, 'optionalAccess', _436 => _436.type]) === "Identifier") {
7173
+ if (fn.type === "FunctionExpression" && _optionalChain([fn, 'access', _476 => _476.id, 'optionalAccess', _477 => _477.type]) === "Identifier") {
6834
7174
  enclosingBindings.add(fn.id.name);
6835
7175
  }
6836
7176
  const lowered = prepareLoweredFunction(fn, enclosingBindings);
@@ -6958,6 +7298,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
6958
7298
  } else {
6959
7299
  fn.body = callExpr;
6960
7300
  }
7301
+ fn._unpeekVirtualized = true;
6961
7302
  virtualizedCount++;
6962
7303
  }
6963
7304
  if (virtualizedCount > 0) {
@@ -6975,7 +7316,7 @@ function applyMicroVm(ast, coldFunctionNodes, serializedFunctionNodes, seed = 26
6975
7316
  let insertIdx = 0;
6976
7317
  while (insertIdx < ast.body.length) {
6977
7318
  const stmt = ast.body[insertIdx];
6978
- const isDirective = stmt.type === "ExpressionStatement" && (Boolean(stmt.directive) || _optionalChain([stmt, 'access', _437 => _437.expression, 'optionalAccess', _438 => _438.type]) === "Literal" && typeof stmt.expression.value === "string" && /^(?:use\s+[a-zA-Z0-9_-]+)/.test(stmt.expression.value.trim()));
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()));
6979
7320
  if (isDirective || stmt.type === "ImportDeclaration") {
6980
7321
  insertIdx++;
6981
7322
  } else {
@@ -7062,7 +7403,7 @@ function scrubResidualPaths(ast, options = {}, hotExemptNodes, exemptSubtreeRoot
7062
7403
  Literal(node, _state, ancestors) {
7063
7404
  if (node.regex || typeof node.value !== "string") return;
7064
7405
  const val = node.value;
7065
- if (_optionalChain([exemptSet, 'optionalAccess', _439 => _439.has, 'call', _440 => _440(val)])) return;
7406
+ if (_optionalChain([exemptSet, 'optionalAccess', _480 => _480.has, 'call', _481 => _481(val)])) return;
7066
7407
  const parent = ancestors[ancestors.length - 2];
7067
7408
  if (!parent) return;
7068
7409
  if ((parent.type === "ImportDeclaration" || parent.type === "ExportNamedDeclaration" || parent.type === "ExportAllDeclaration" || parent.type === "ImportExpression") && parent.source === node) {
@@ -7087,12 +7428,12 @@ function scrubResidualPaths(ast, options = {}, hotExemptNodes, exemptSubtreeRoot
7087
7428
  return;
7088
7429
  }
7089
7430
  const parent = ancestors[ancestors.length - 2];
7090
- if (_optionalChain([parent, 'optionalAccess', _441 => _441.type]) === "ImportExpression" && parent.source === node) {
7431
+ if (_optionalChain([parent, 'optionalAccess', _482 => _482.type]) === "ImportExpression" && parent.source === node) {
7091
7432
  return;
7092
7433
  }
7093
7434
  for (const quasi of node.quasis) {
7094
- const val = _nullishCoalesce(_optionalChain([quasi, 'optionalAccess', _442 => _442.value, 'optionalAccess', _443 => _443.cooked]), () => ( _optionalChain([quasi, 'optionalAccess', _444 => _444.value, 'optionalAccess', _445 => _445.raw])));
7095
- if (typeof val !== "string" || _optionalChain([exemptSet, 'optionalAccess', _446 => _446.has, 'call', _447 => _447(val)])) continue;
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;
7096
7437
  const scrubbed = scrubStringValue(val, options.rootDir);
7097
7438
  if (scrubbed !== val) {
7098
7439
  quasi.value.cooked = scrubbed;
@@ -7132,24 +7473,24 @@ function isAstAlreadyProtected(ast) {
7132
7473
  return ast.body.some((stmt) => {
7133
7474
  if (stmt.type === "VariableDeclaration" && Array.isArray(stmt.declarations)) {
7134
7475
  for (const d of stmt.declarations) {
7135
- const name = _optionalChain([d, 'access', _448 => _448.id, 'optionalAccess', _449 => _449.type]) === "Identifier" ? d.id.name : void 0;
7476
+ const name = _optionalChain([d, 'access', _489 => _489.id, 'optionalAccess', _490 => _490.type]) === "Identifier" ? d.id.name : void 0;
7136
7477
  if (typeof name === "string") {
7137
- 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', _450 => _450.init, 'optionalAccess', _451 => _451.type]) === "CallExpression" && _optionalChain([d, 'access', _452 => _452.init, 'access', _453 => _453.callee, 'optionalAccess', _454 => _454.type]) === "FunctionExpression" && _optionalChain([d, 'access', _455 => _455.init, 'access', _456 => _456.callee, 'optionalAccess', _457 => _457.id, 'optionalAccess', _458 => _458.name]) === "f" && _optionalChain([d, 'access', _459 => _459.init, 'access', _460 => _460.arguments, 'optionalAccess', _461 => _461[0], 'optionalAccess', _462 => _462.type]) === "ArrayExpression" || _optionalChain([d, 'access', _463 => _463.init, 'optionalAccess', _464 => _464.type]) === "CallExpression" && _optionalChain([d, 'access', _465 => _465.init, 'access', _466 => _466.callee, 'optionalAccess', _467 => _467.type]) === "MemberExpression" && _optionalChain([d, 'access', _468 => _468.init, 'access', _469 => _469.callee, 'access', _470 => _470.object, 'optionalAccess', _471 => _471.type]) === "Identifier" && d.init.callee.object.name === "Symbol" && _optionalChain([d, 'access', _472 => _472.init, 'access', _473 => _473.callee, 'access', _474 => _474.property, 'optionalAccess', _475 => _475.type]) === "Identifier" && d.init.callee.property.name === "for" && typeof _optionalChain([d, 'access', _476 => _476.init, 'access', _477 => _477.arguments, 'optionalAccess', _478 => _478[0], 'optionalAccess', _479 => _479.value]) === "string" && d.init.arguments[0].value.startsWith("__upk_v4_")) {
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_")) {
7138
7479
  return true;
7139
7480
  }
7140
7481
  }
7141
7482
  }
7142
7483
  }
7143
- if (stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _480 => _480.id, 'optionalAccess', _481 => _481.type]) === "Identifier") {
7484
+ if (stmt.type === "FunctionDeclaration" && _optionalChain([stmt, 'access', _521 => _521.id, 'optionalAccess', _522 => _522.type]) === "Identifier") {
7144
7485
  const fnName = stmt.id.name;
7145
7486
  if (typeof fnName === "string" && (fnName.startsWith("_uD") || fnName.startsWith("_uVm") || fnName.startsWith("_wKdf") || fnName.startsWith("_hX"))) {
7146
7487
  return true;
7147
7488
  }
7148
7489
  }
7149
- if (stmt.type === "ExpressionStatement" && _optionalChain([stmt, 'access', _482 => _482.expression, 'optionalAccess', _483 => _483.type]) === "CallExpression") {
7490
+ if (stmt.type === "ExpressionStatement" && _optionalChain([stmt, 'access', _523 => _523.expression, 'optionalAccess', _524 => _524.type]) === "CallExpression") {
7150
7491
  const callee = stmt.expression.callee;
7151
- if (_optionalChain([callee, 'optionalAccess', _484 => _484.type]) === "FunctionExpression") {
7152
- const name = _optionalChain([callee, 'access', _485 => _485.id, 'optionalAccess', _486 => _486.name]);
7492
+ if (_optionalChain([callee, 'optionalAccess', _525 => _525.type]) === "FunctionExpression") {
7493
+ const name = _optionalChain([callee, 'access', _526 => _526.id, 'optionalAccess', _527 => _527.name]);
7153
7494
  if (typeof name === "string" && (name.startsWith("_u$") || name.startsWith("_$") || name.startsWith("_s") || name.startsWith("$b") || containsUnpeekShieldMarker(callee.body))) {
7154
7495
  return true;
7155
7496
  }
@@ -7161,7 +7502,7 @@ function isAstAlreadyProtected(ast) {
7161
7502
  function transformJavaScript(code, options = {}) {
7162
7503
  const internalOptions = options;
7163
7504
  const seed = _nullishCoalesce(internalOptions.seed, () => ( 2654435769));
7164
- const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([options, 'access', _487 => _487.config, 'optionalAccess', _488 => _488.vault, 'optionalAccess', _489 => _489.minStringLength]))), () => ( 4));
7505
+ const minStringLength = _nullishCoalesce(_nullishCoalesce(options.minStringLength, () => ( _optionalChain([options, 'access', _528 => _528.config, 'optionalAccess', _529 => _529.vault, 'optionalAccess', _530 => _530.minStringLength]))), () => ( 4));
7165
7506
  const isAggressive = _nullishCoalesce(options.aggressive, () => ( false));
7166
7507
  if (!code || !code.trim()) {
7167
7508
  const emptyResult = {
@@ -7226,7 +7567,7 @@ function transformJavaScript(code, options = {}) {
7226
7567
  const boundary = classifyChunkBoundary(ast);
7227
7568
  attachMagicComments(boundary.importExpressions, comments);
7228
7569
  const effectiveConfig = options.critical ? { ..._nullishCoalesce(options.config, () => ( {})), critical: options.critical } : options.config;
7229
- const effectiveProfile = _nullishCoalesce(options.profile, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _490 => _490.profile])));
7570
+ const effectiveProfile = _nullishCoalesce(options.profile, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _531 => _531.profile])));
7230
7571
  const hotRes = analyzeAstHotPaths(ast, effectiveConfig);
7231
7572
  const {
7232
7573
  report: hotPathReport,
@@ -7236,7 +7577,7 @@ function transformJavaScript(code, options = {}) {
7236
7577
  serializedFunctionNodes
7237
7578
  } = hotRes;
7238
7579
  const criticalFunctionNodes = hotRes.criticalFunctionNodes;
7239
- if (options.scrubPaths || _optionalChain([effectiveConfig, 'optionalAccess', _491 => _491.scrubPaths])) {
7580
+ if (options.scrubPaths || _optionalChain([effectiveConfig, 'optionalAccess', _532 => _532.scrubPaths])) {
7240
7581
  scrubResidualPaths(
7241
7582
  ast,
7242
7583
  {
@@ -7248,8 +7589,8 @@ function transformJavaScript(code, options = {}) {
7248
7589
  );
7249
7590
  }
7250
7591
  const shieldCoupled = _nullishCoalesce(internalOptions.shieldCoupled, () => ( Boolean(internalOptions.injectRuntimeShield)));
7251
- const deterrentMode = _nullishCoalesce(_nullishCoalesce(internalOptions.deterrentMode, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _492 => _492.shield, 'optionalAccess', _493 => _493.deterrentMode]))), () => ( "passive"));
7252
- const detectHeadless = _nullishCoalesce(_nullishCoalesce(internalOptions.detectHeadless, () => ( _optionalChain([effectiveConfig, 'optionalAccess', _494 => _494.shield, 'optionalAccess', _495 => _495.detectHeadless]))), () => ( false));
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));
7253
7594
  const sym = shieldCoupled ? _nullishCoalesce(internalOptions.windowKeySymbol, () => ( deriveWindowKeySymbol(seed))) : void 0;
7254
7595
  let shieldDelta = shieldCoupled ? internalOptions.expectedDelta : void 0;
7255
7596
  if (shieldCoupled && shieldDelta === void 0) {
@@ -7263,9 +7604,9 @@ function transformJavaScript(code, options = {}) {
7263
7604
  }
7264
7605
  let virtualizedFunctionsCount = 0;
7265
7606
  if (isAggressive) {
7266
- const extraVmOpts = criticalFunctionNodes || _optionalChain([effectiveConfig, 'optionalAccess', _496 => _496.critical, 'optionalAccess', _497 => _497.maxFunctionsPerChunk]) !== void 0 ? {
7607
+ const extraVmOpts = criticalFunctionNodes || _optionalChain([effectiveConfig, 'optionalAccess', _537 => _537.critical, 'optionalAccess', _538 => _538.maxFunctionsPerChunk]) !== void 0 ? {
7267
7608
  ...criticalFunctionNodes ? { criticalFunctionNodes } : {},
7268
- ..._optionalChain([effectiveConfig, 'optionalAccess', _498 => _498.critical, 'optionalAccess', _499 => _499.maxFunctionsPerChunk]) !== void 0 ? { maxFunctionsPerChunk: effectiveConfig.critical.maxFunctionsPerChunk } : {}
7609
+ ..._optionalChain([effectiveConfig, 'optionalAccess', _539 => _539.critical, 'optionalAccess', _540 => _540.maxFunctionsPerChunk]) !== void 0 ? { maxFunctionsPerChunk: effectiveConfig.critical.maxFunctionsPerChunk } : {}
7269
7610
  } : void 0;
7270
7611
  const vmRes = extraVmOpts ? applyMicroVm(
7271
7612
  ast,
@@ -7285,7 +7626,7 @@ function transformJavaScript(code, options = {}) {
7285
7626
  );
7286
7627
  virtualizedFunctionsCount = vmRes.virtualizedCount;
7287
7628
  }
7288
- if (effectiveProfile !== "minimal" && _optionalChain([effectiveConfig, 'optionalAccess', _500 => _500.coldFlow]) !== false) {
7629
+ if (effectiveProfile !== "minimal" && _optionalChain([effectiveConfig, 'optionalAccess', _541 => _541.coldFlow]) !== false) {
7289
7630
  applyColdFlowGuard(ast, coldFunctionNodes, seed, hotExemptNodes);
7290
7631
  }
7291
7632
  const mangledSymbolsCount = applyPolymorphicMangler(
@@ -7313,6 +7654,7 @@ function transformJavaScript(code, options = {}) {
7313
7654
  );
7314
7655
  encryptedStringsCount = saltedRes.encryptedStringsCount;
7315
7656
  integrityToken = saltedRes.integrityToken;
7657
+ shaderBuffersCount = _nullishCoalesce(saltedRes.shaderBuffersCount, () => ( 0));
7316
7658
  } else {
7317
7659
  const vaultRes = applyStringVault(
7318
7660
  ast,