unpeek 1.6.2 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/ast/index.cjs +2341 -272
  2. package/dist/ast/index.cjs.map +1 -1
  3. package/dist/ast/index.d.cts +69 -1
  4. package/dist/ast/index.d.ts +69 -1
  5. package/dist/ast/index.js +2332 -274
  6. package/dist/ast/index.js.map +1 -1
  7. package/dist/browser.cjs +2326 -277
  8. package/dist/browser.cjs.map +1 -1
  9. package/dist/browser.d.cts +2 -1
  10. package/dist/browser.d.ts +2 -1
  11. package/dist/browser.js +2327 -278
  12. package/dist/browser.js.map +1 -1
  13. package/dist/bundler/unplugin.cjs +2324 -273
  14. package/dist/bundler/unplugin.cjs.map +1 -1
  15. package/dist/bundler/unplugin.js +2326 -275
  16. package/dist/bundler/unplugin.js.map +1 -1
  17. package/dist/cli/index.cjs +2360 -287
  18. package/dist/cli/index.cjs.map +1 -1
  19. package/dist/cli/index.js +2364 -291
  20. package/dist/cli/index.js.map +1 -1
  21. package/dist/cli/protect.cjs +2352 -282
  22. package/dist/cli/protect.cjs.map +1 -1
  23. package/dist/cli/protect.js +2352 -282
  24. package/dist/cli/protect.js.map +1 -1
  25. package/dist/esbuild.cjs +2324 -273
  26. package/dist/esbuild.cjs.map +1 -1
  27. package/dist/esbuild.d.cts +1 -1
  28. package/dist/esbuild.d.ts +1 -1
  29. package/dist/esbuild.js +2326 -275
  30. package/dist/esbuild.js.map +1 -1
  31. package/dist/index.cjs +2438 -363
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +2 -1
  34. package/dist/index.d.ts +2 -1
  35. package/dist/index.js +2437 -362
  36. package/dist/index.js.map +1 -1
  37. package/dist/rollup.cjs +2324 -273
  38. package/dist/rollup.cjs.map +1 -1
  39. package/dist/rollup.d.cts +1 -1
  40. package/dist/rollup.d.ts +1 -1
  41. package/dist/rollup.js +2326 -275
  42. package/dist/rollup.js.map +1 -1
  43. package/dist/runtime/index.cjs +365 -20
  44. package/dist/runtime/index.cjs.map +1 -1
  45. package/dist/runtime/index.d.cts +11 -3
  46. package/dist/runtime/index.d.ts +11 -3
  47. package/dist/runtime/index.js +363 -20
  48. package/dist/runtime/index.js.map +1 -1
  49. package/dist/{types-D-lVfaDU.d.cts → types-CQHprSVk.d.cts} +10 -0
  50. package/dist/{types-D-lVfaDU.d.ts → types-CQHprSVk.d.ts} +10 -0
  51. package/dist/vite.cjs +2324 -273
  52. package/dist/vite.cjs.map +1 -1
  53. package/dist/vite.d.cts +1 -1
  54. package/dist/vite.d.ts +1 -1
  55. package/dist/vite.js +2326 -275
  56. package/dist/vite.js.map +1 -1
  57. package/dist/webpack.cjs +2324 -273
  58. package/dist/webpack.cjs.map +1 -1
  59. package/dist/webpack.d.cts +1 -1
  60. package/dist/webpack.d.ts +1 -1
  61. package/dist/webpack.js +2326 -275
  62. package/dist/webpack.js.map +1 -1
  63. package/package.json +1 -1
@@ -1,9 +1,77 @@
1
1
  import { HotPathReport, TransformOptions, TransformResult } from '../browser.cjs';
2
+ import * as acorn from 'acorn';
2
3
 
4
+ interface HotPathAnalysis {
5
+ report: HotPathReport;
6
+ hotFunctionNodes: WeakSet<acorn.Node>;
7
+ coldFunctionNodes: WeakSet<acorn.Node>;
8
+ hotExemptNodes: WeakSet<acorn.Node>;
9
+ serializedFunctionNodes: WeakSet<acorn.Node>;
10
+ }
11
+ declare function analyzeAstHotPaths(ast: acorn.Program): HotPathAnalysis;
3
12
  declare function detectHotPaths(code: string): HotPathReport;
4
13
 
5
14
  declare function computeFnv1aHash(input: string, seed?: number): number;
15
+ interface StringVaultResult {
16
+ encryptedStringsCount: number;
17
+ integrityToken: number;
18
+ shaderBuffersCount?: number;
19
+ }
20
+ declare function applyStringVault(ast: acorn.Program, seed?: number, minStringLength?: number, hotExemptNodes?: WeakSet<acorn.Node>, windowKeySymbol?: string, expectedDelta?: number): StringVaultResult;
21
+
22
+ declare function applyPolymorphicMangler(ast: acorn.Program, seed?: number, serializedFunctionNodes?: WeakSet<acorn.Node>): number;
23
+
24
+ declare function applyColdFlowGuard(ast: acorn.Program, coldFunctionNodes: WeakSet<acorn.Node>, seed?: number, hotExemptNodes?: WeakSet<acorn.Node>): number;
25
+
26
+ type PolymorphicRole = 'vault' | 'shield' | 'decoy' | 'shader' | 'vm' | 'wasm' | 'salted' | 'windowKey' | string;
27
+ /**
28
+ * Deterministically derives a short, collision-free, minify-friendly identifier
29
+ * (_a0, $b1, etc.) for a given seed and role, eliminating fixed _uC and _u$ prefixes.
30
+ */
31
+ declare function derivePolymorphicIdent(seed: number, role: PolymorphicRole): string;
32
+ /**
33
+ * Generates compact, single-line JavaScript using custom astring rules to eliminate
34
+ * redundant whitespace while preserving string literal contents and language semantics.
35
+ */
36
+ declare function generateCompactJs(ast: any): string;
37
+
38
+ interface MicroVmResult {
39
+ virtualizedCount: number;
40
+ vmHelperName: string;
41
+ }
42
+ /**
43
+ * Selective Bytecode Micro-VM virtualization for Layer 2 (--aggressive).
44
+ * Selects qualifying cold functions (not serialized, no JSX, no super/yield/arguments/new.target, 15 <= N <= 80),
45
+ * transforms their bodies into stack-based bytecode calls, and injects the <1.2 KB switch-dispatch interpreter once.
46
+ */
47
+ declare function applyMicroVm(ast: acorn.Program, coldFunctionNodes?: Set<acorn.Node> | WeakSet<acorn.Node>, serializedFunctionNodes?: WeakSet<acorn.Node>, seed?: number): MicroVmResult;
48
+
49
+ interface WasmVaultInjectionResult {
50
+ kdfFnName: string;
51
+ wasmBytes: Uint8Array;
52
+ wasmVarName: string;
53
+ }
54
+ /**
55
+ * Injects the synchronous inline WebAssembly KDF key vault into the AST program.
56
+ * Falls back transparently to Math.imul on strict CSP runtimes.
57
+ */
58
+ declare function injectWasmVault(ast: acorn.Program, seed?: number): WasmVaultInjectionResult;
59
+
60
+ interface SaltedVaultResult {
61
+ encryptedStringsCount: number;
62
+ integrityToken: number;
63
+ vaultVarName: string;
64
+ decryptFnName: string;
65
+ }
66
+ /**
67
+ * Applies idempotent call-site salted lazy string vaulting in Layer 2 (--aggressive).
68
+ * Each eligible string access site receives a deterministic static salt constant and is transformed
69
+ * into a _uD(idx, localSalt) call.
70
+ * Operates with 100% idempotence and order-independence under React 19 Concurrent Mode
71
+ * and StrictMode double-mounting.
72
+ */
73
+ declare function applySaltedStringVault(ast: acorn.Program, seed?: number, minStringLength?: number, hotExemptNodes?: WeakSet<acorn.Node>): SaltedVaultResult;
6
74
 
7
75
  declare function transformJavaScript(code: string, options?: TransformOptions): TransformResult;
8
76
 
9
- export { computeFnv1aHash, detectHotPaths, transformJavaScript };
77
+ export { analyzeAstHotPaths, applyColdFlowGuard, applyMicroVm, applyPolymorphicMangler, applySaltedStringVault, applyStringVault, computeFnv1aHash, derivePolymorphicIdent, detectHotPaths, generateCompactJs, injectWasmVault, transformJavaScript };
@@ -1,9 +1,77 @@
1
1
  import { HotPathReport, TransformOptions, TransformResult } from '../browser.js';
2
+ import * as acorn from 'acorn';
2
3
 
4
+ interface HotPathAnalysis {
5
+ report: HotPathReport;
6
+ hotFunctionNodes: WeakSet<acorn.Node>;
7
+ coldFunctionNodes: WeakSet<acorn.Node>;
8
+ hotExemptNodes: WeakSet<acorn.Node>;
9
+ serializedFunctionNodes: WeakSet<acorn.Node>;
10
+ }
11
+ declare function analyzeAstHotPaths(ast: acorn.Program): HotPathAnalysis;
3
12
  declare function detectHotPaths(code: string): HotPathReport;
4
13
 
5
14
  declare function computeFnv1aHash(input: string, seed?: number): number;
15
+ interface StringVaultResult {
16
+ encryptedStringsCount: number;
17
+ integrityToken: number;
18
+ shaderBuffersCount?: number;
19
+ }
20
+ declare function applyStringVault(ast: acorn.Program, seed?: number, minStringLength?: number, hotExemptNodes?: WeakSet<acorn.Node>, windowKeySymbol?: string, expectedDelta?: number): StringVaultResult;
21
+
22
+ declare function applyPolymorphicMangler(ast: acorn.Program, seed?: number, serializedFunctionNodes?: WeakSet<acorn.Node>): number;
23
+
24
+ declare function applyColdFlowGuard(ast: acorn.Program, coldFunctionNodes: WeakSet<acorn.Node>, seed?: number, hotExemptNodes?: WeakSet<acorn.Node>): number;
25
+
26
+ type PolymorphicRole = 'vault' | 'shield' | 'decoy' | 'shader' | 'vm' | 'wasm' | 'salted' | 'windowKey' | string;
27
+ /**
28
+ * Deterministically derives a short, collision-free, minify-friendly identifier
29
+ * (_a0, $b1, etc.) for a given seed and role, eliminating fixed _uC and _u$ prefixes.
30
+ */
31
+ declare function derivePolymorphicIdent(seed: number, role: PolymorphicRole): string;
32
+ /**
33
+ * Generates compact, single-line JavaScript using custom astring rules to eliminate
34
+ * redundant whitespace while preserving string literal contents and language semantics.
35
+ */
36
+ declare function generateCompactJs(ast: any): string;
37
+
38
+ interface MicroVmResult {
39
+ virtualizedCount: number;
40
+ vmHelperName: string;
41
+ }
42
+ /**
43
+ * Selective Bytecode Micro-VM virtualization for Layer 2 (--aggressive).
44
+ * Selects qualifying cold functions (not serialized, no JSX, no super/yield/arguments/new.target, 15 <= N <= 80),
45
+ * transforms their bodies into stack-based bytecode calls, and injects the <1.2 KB switch-dispatch interpreter once.
46
+ */
47
+ declare function applyMicroVm(ast: acorn.Program, coldFunctionNodes?: Set<acorn.Node> | WeakSet<acorn.Node>, serializedFunctionNodes?: WeakSet<acorn.Node>, seed?: number): MicroVmResult;
48
+
49
+ interface WasmVaultInjectionResult {
50
+ kdfFnName: string;
51
+ wasmBytes: Uint8Array;
52
+ wasmVarName: string;
53
+ }
54
+ /**
55
+ * Injects the synchronous inline WebAssembly KDF key vault into the AST program.
56
+ * Falls back transparently to Math.imul on strict CSP runtimes.
57
+ */
58
+ declare function injectWasmVault(ast: acorn.Program, seed?: number): WasmVaultInjectionResult;
59
+
60
+ interface SaltedVaultResult {
61
+ encryptedStringsCount: number;
62
+ integrityToken: number;
63
+ vaultVarName: string;
64
+ decryptFnName: string;
65
+ }
66
+ /**
67
+ * Applies idempotent call-site salted lazy string vaulting in Layer 2 (--aggressive).
68
+ * Each eligible string access site receives a deterministic static salt constant and is transformed
69
+ * into a _uD(idx, localSalt) call.
70
+ * Operates with 100% idempotence and order-independence under React 19 Concurrent Mode
71
+ * and StrictMode double-mounting.
72
+ */
73
+ declare function applySaltedStringVault(ast: acorn.Program, seed?: number, minStringLength?: number, hotExemptNodes?: WeakSet<acorn.Node>): SaltedVaultResult;
6
74
 
7
75
  declare function transformJavaScript(code: string, options?: TransformOptions): TransformResult;
8
76
 
9
- export { computeFnv1aHash, detectHotPaths, transformJavaScript };
77
+ export { analyzeAstHotPaths, applyColdFlowGuard, applyMicroVm, applyPolymorphicMangler, applySaltedStringVault, applyStringVault, computeFnv1aHash, derivePolymorphicIdent, detectHotPaths, generateCompactJs, injectWasmVault, transformJavaScript };