@afterpack/integration-utils 0.1.0-rc.20260925T1347
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +24 -0
- package/dist/index.cjs +4566 -0
- package/dist/index.d.cts +1147 -0
- package/dist/index.d.ts +1147 -0
- package/dist/index.js +4246 -0
- package/package.json +75 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1147 @@
|
|
|
1
|
+
import { ProtectionMap } from "@afterpack/protection-map";
|
|
2
|
+
|
|
3
|
+
//#region src/paths.d.ts
|
|
4
|
+
type ArtifactMode = "single" | "directory" | "framework";
|
|
5
|
+
interface FindUpwardOptions {
|
|
6
|
+
stopAtDir?: (dir: string) => boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function findUpward(startDir: string, fileName: string, options?: FindUpwardOptions): string | null;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/git.d.ts
|
|
11
|
+
interface GitBuildContext {
|
|
12
|
+
commitSha?: string;
|
|
13
|
+
ref?: string;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/registry.d.ts
|
|
17
|
+
type ConfigScope = "program" | "region";
|
|
18
|
+
type ConfigTier = "free" | "pro";
|
|
19
|
+
type ConfigSurface = "engine" | "build" | "cli";
|
|
20
|
+
type ValueShape = "scalar" | "list" | "mixedList" | "structured";
|
|
21
|
+
type ValueType = {
|
|
22
|
+
readonly kind: "boolean";
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: "number";
|
|
25
|
+
readonly min: number;
|
|
26
|
+
readonly integer?: true;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: "unbounded";
|
|
29
|
+
readonly min: number;
|
|
30
|
+
readonly unlimited: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: "string";
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: "enum";
|
|
35
|
+
readonly values: readonly string[];
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "seed";
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: "reserved";
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: "region";
|
|
42
|
+
};
|
|
43
|
+
interface GlobReserved {
|
|
44
|
+
glob: string;
|
|
45
|
+
names: string[];
|
|
46
|
+
}
|
|
47
|
+
interface ConfigKeyDef {
|
|
48
|
+
readonly path: string;
|
|
49
|
+
readonly shape: ValueShape;
|
|
50
|
+
readonly scope: ConfigScope;
|
|
51
|
+
readonly tier: ConfigTier;
|
|
52
|
+
readonly surface: ConfigSurface;
|
|
53
|
+
readonly item: ValueType;
|
|
54
|
+
readonly default: string;
|
|
55
|
+
readonly configFileForm?: string;
|
|
56
|
+
readonly namedValuesOf?: string;
|
|
57
|
+
}
|
|
58
|
+
declare const PRESET_VALUES: readonly ["minify", "light", "medium", "hard", "extreme"];
|
|
59
|
+
declare const TRANSFORM_KIND_VALUES: readonly ["stringEncoding", "controlFlowFlatten", "opaquePredicate", "mixedBooleanArithmetic", "integerBytecode", "crossDependency", "scopeDeepen", "comparisonHardening", "selfIntegrity", "objectConstruction"];
|
|
60
|
+
declare const REFLECTION_ALLOW_VALUES: readonly ["functionToString", "nameIntrospection", "argumentsCallee", "prototypeChain", "decoratorMetadata", "constructorIntrospection", "angular", "nestjs"];
|
|
61
|
+
declare const BUILD_MODE_VALUES: readonly ["production", "development"];
|
|
62
|
+
type BuildMode = (typeof BUILD_MODE_VALUES)[number];
|
|
63
|
+
declare const CONFIG_KEYS: readonly [{
|
|
64
|
+
readonly path: "seed";
|
|
65
|
+
readonly shape: "scalar";
|
|
66
|
+
readonly scope: "program";
|
|
67
|
+
readonly tier: "free";
|
|
68
|
+
readonly surface: "engine";
|
|
69
|
+
readonly item: {
|
|
70
|
+
readonly kind: "seed";
|
|
71
|
+
};
|
|
72
|
+
readonly default: "a new random seed per build";
|
|
73
|
+
}, {
|
|
74
|
+
readonly path: "preset";
|
|
75
|
+
readonly shape: "scalar";
|
|
76
|
+
readonly scope: "region";
|
|
77
|
+
readonly tier: "free";
|
|
78
|
+
readonly surface: "engine";
|
|
79
|
+
readonly item: {
|
|
80
|
+
readonly kind: "enum";
|
|
81
|
+
readonly values: readonly ["minify", "light", "medium", "hard", "extreme"];
|
|
82
|
+
};
|
|
83
|
+
readonly default: "light";
|
|
84
|
+
}, {
|
|
85
|
+
readonly path: "complexity";
|
|
86
|
+
readonly shape: "scalar";
|
|
87
|
+
readonly scope: "region";
|
|
88
|
+
readonly tier: "free";
|
|
89
|
+
readonly surface: "engine";
|
|
90
|
+
readonly item: {
|
|
91
|
+
readonly kind: "number";
|
|
92
|
+
readonly min: 0;
|
|
93
|
+
};
|
|
94
|
+
readonly default: "the preset's value; light is 2";
|
|
95
|
+
readonly namedValuesOf: "preset";
|
|
96
|
+
}, {
|
|
97
|
+
readonly path: "inflation.max";
|
|
98
|
+
readonly shape: "scalar";
|
|
99
|
+
readonly scope: "region";
|
|
100
|
+
readonly tier: "free";
|
|
101
|
+
readonly surface: "engine";
|
|
102
|
+
readonly item: {
|
|
103
|
+
readonly kind: "unbounded";
|
|
104
|
+
readonly min: 0;
|
|
105
|
+
readonly unlimited: "unlimited";
|
|
106
|
+
};
|
|
107
|
+
readonly default: "the preset's output-size ladder: 1.2 / 2 / 2.5 / 4 / 7";
|
|
108
|
+
}, {
|
|
109
|
+
readonly path: "strings.encode";
|
|
110
|
+
readonly shape: "scalar";
|
|
111
|
+
readonly scope: "region";
|
|
112
|
+
readonly tier: "free";
|
|
113
|
+
readonly surface: "engine";
|
|
114
|
+
readonly item: {
|
|
115
|
+
readonly kind: "boolean";
|
|
116
|
+
};
|
|
117
|
+
readonly default: "true at any positive complexity; false at 0";
|
|
118
|
+
}, {
|
|
119
|
+
readonly path: "strings.minLength";
|
|
120
|
+
readonly shape: "scalar";
|
|
121
|
+
readonly scope: "program";
|
|
122
|
+
readonly tier: "free";
|
|
123
|
+
readonly surface: "engine";
|
|
124
|
+
readonly item: {
|
|
125
|
+
readonly kind: "number";
|
|
126
|
+
readonly min: 0;
|
|
127
|
+
readonly integer: true;
|
|
128
|
+
};
|
|
129
|
+
readonly default: "0";
|
|
130
|
+
}, {
|
|
131
|
+
readonly path: "strings.leaks.max";
|
|
132
|
+
readonly shape: "scalar";
|
|
133
|
+
readonly scope: "program";
|
|
134
|
+
readonly tier: "free";
|
|
135
|
+
readonly surface: "engine";
|
|
136
|
+
readonly item: {
|
|
137
|
+
readonly kind: "number";
|
|
138
|
+
readonly min: 0;
|
|
139
|
+
readonly integer: true;
|
|
140
|
+
};
|
|
141
|
+
readonly default: "unset; the count is reported but never fails a build";
|
|
142
|
+
}, {
|
|
143
|
+
readonly path: "strings.preserveLiterals";
|
|
144
|
+
readonly shape: "list";
|
|
145
|
+
readonly scope: "program";
|
|
146
|
+
readonly tier: "free";
|
|
147
|
+
readonly surface: "engine";
|
|
148
|
+
readonly item: {
|
|
149
|
+
readonly kind: "string";
|
|
150
|
+
};
|
|
151
|
+
readonly default: "[]";
|
|
152
|
+
}, {
|
|
153
|
+
readonly path: "paths.include";
|
|
154
|
+
readonly shape: "list";
|
|
155
|
+
readonly scope: "program";
|
|
156
|
+
readonly tier: "free";
|
|
157
|
+
readonly surface: "build";
|
|
158
|
+
readonly item: {
|
|
159
|
+
readonly kind: "string";
|
|
160
|
+
};
|
|
161
|
+
readonly default: "[]";
|
|
162
|
+
}, {
|
|
163
|
+
readonly path: "paths.exclude";
|
|
164
|
+
readonly shape: "list";
|
|
165
|
+
readonly scope: "program";
|
|
166
|
+
readonly tier: "free";
|
|
167
|
+
readonly surface: "engine";
|
|
168
|
+
readonly item: {
|
|
169
|
+
readonly kind: "string";
|
|
170
|
+
};
|
|
171
|
+
readonly default: "[]";
|
|
172
|
+
}, {
|
|
173
|
+
readonly path: "identifiers.rename";
|
|
174
|
+
readonly shape: "scalar";
|
|
175
|
+
readonly scope: "program";
|
|
176
|
+
readonly tier: "free";
|
|
177
|
+
readonly surface: "engine";
|
|
178
|
+
readonly item: {
|
|
179
|
+
readonly kind: "boolean";
|
|
180
|
+
};
|
|
181
|
+
readonly default: "true";
|
|
182
|
+
}, {
|
|
183
|
+
readonly path: "identifiers.globals.rename";
|
|
184
|
+
readonly shape: "scalar";
|
|
185
|
+
readonly scope: "program";
|
|
186
|
+
readonly tier: "free";
|
|
187
|
+
readonly surface: "engine";
|
|
188
|
+
readonly item: {
|
|
189
|
+
readonly kind: "boolean";
|
|
190
|
+
};
|
|
191
|
+
readonly default: "false";
|
|
192
|
+
}, {
|
|
193
|
+
readonly path: "identifiers.reserved";
|
|
194
|
+
readonly shape: "mixedList";
|
|
195
|
+
readonly scope: "program";
|
|
196
|
+
readonly tier: "free";
|
|
197
|
+
readonly surface: "engine";
|
|
198
|
+
readonly item: {
|
|
199
|
+
readonly kind: "reserved";
|
|
200
|
+
};
|
|
201
|
+
readonly default: "[]";
|
|
202
|
+
readonly configFileForm: "{ \"identifiers\": { \"reserved\": [{ \"glob\": \"…\", \"names\": [\"…\"] }] } }";
|
|
203
|
+
}, {
|
|
204
|
+
readonly path: "identifiers.methods.rename";
|
|
205
|
+
readonly shape: "scalar";
|
|
206
|
+
readonly scope: "program";
|
|
207
|
+
readonly tier: "free";
|
|
208
|
+
readonly surface: "engine";
|
|
209
|
+
readonly item: {
|
|
210
|
+
readonly kind: "boolean";
|
|
211
|
+
};
|
|
212
|
+
readonly default: "true";
|
|
213
|
+
}, {
|
|
214
|
+
readonly path: "reflection.allow";
|
|
215
|
+
readonly shape: "list";
|
|
216
|
+
readonly scope: "program";
|
|
217
|
+
readonly tier: "free";
|
|
218
|
+
readonly surface: "engine";
|
|
219
|
+
readonly item: {
|
|
220
|
+
readonly kind: "enum";
|
|
221
|
+
readonly values: readonly ["functionToString", "nameIntrospection", "argumentsCallee", "prototypeChain", "decoratorMetadata", "constructorIntrospection", "angular", "nestjs"];
|
|
222
|
+
};
|
|
223
|
+
readonly default: "[]";
|
|
224
|
+
}, {
|
|
225
|
+
readonly path: "sourceMap.enabled";
|
|
226
|
+
readonly shape: "scalar";
|
|
227
|
+
readonly scope: "program";
|
|
228
|
+
readonly tier: "free";
|
|
229
|
+
readonly surface: "engine";
|
|
230
|
+
readonly item: {
|
|
231
|
+
readonly kind: "boolean";
|
|
232
|
+
};
|
|
233
|
+
readonly default: "true in development when an input map exists; false in production";
|
|
234
|
+
}, {
|
|
235
|
+
readonly path: "sourceMap.sourcesContent";
|
|
236
|
+
readonly shape: "scalar";
|
|
237
|
+
readonly scope: "program";
|
|
238
|
+
readonly tier: "free";
|
|
239
|
+
readonly surface: "engine";
|
|
240
|
+
readonly item: {
|
|
241
|
+
readonly kind: "boolean";
|
|
242
|
+
};
|
|
243
|
+
readonly default: "true in development; false in production";
|
|
244
|
+
}, {
|
|
245
|
+
readonly path: "sourceMap.emitUrl";
|
|
246
|
+
readonly shape: "scalar";
|
|
247
|
+
readonly scope: "program";
|
|
248
|
+
readonly tier: "free";
|
|
249
|
+
readonly surface: "build";
|
|
250
|
+
readonly item: {
|
|
251
|
+
readonly kind: "boolean";
|
|
252
|
+
};
|
|
253
|
+
readonly default: "true in development; false in production";
|
|
254
|
+
}, {
|
|
255
|
+
readonly path: "protectionMap.enabled";
|
|
256
|
+
readonly shape: "scalar";
|
|
257
|
+
readonly scope: "program";
|
|
258
|
+
readonly tier: "free";
|
|
259
|
+
readonly surface: "engine";
|
|
260
|
+
readonly item: {
|
|
261
|
+
readonly kind: "boolean";
|
|
262
|
+
};
|
|
263
|
+
readonly default: "true when the bundler emitted a source map";
|
|
264
|
+
}, {
|
|
265
|
+
readonly path: "protectionMap.detailed";
|
|
266
|
+
readonly shape: "scalar";
|
|
267
|
+
readonly scope: "program";
|
|
268
|
+
readonly tier: "free";
|
|
269
|
+
readonly surface: "engine";
|
|
270
|
+
readonly item: {
|
|
271
|
+
readonly kind: "boolean";
|
|
272
|
+
};
|
|
273
|
+
readonly default: "true";
|
|
274
|
+
}, {
|
|
275
|
+
readonly path: "regions";
|
|
276
|
+
readonly shape: "structured";
|
|
277
|
+
readonly scope: "program";
|
|
278
|
+
readonly tier: "pro";
|
|
279
|
+
readonly surface: "engine";
|
|
280
|
+
readonly item: {
|
|
281
|
+
readonly kind: "region";
|
|
282
|
+
};
|
|
283
|
+
readonly default: "[]";
|
|
284
|
+
readonly configFileForm: "{ \"regions\": [{ \"start\": 0, \"end\": 100, \"complexity\": 40 }] }";
|
|
285
|
+
}, {
|
|
286
|
+
readonly path: "transforms.controlFlowFlatten.enabled";
|
|
287
|
+
readonly shape: "scalar";
|
|
288
|
+
readonly scope: "program";
|
|
289
|
+
readonly tier: "free";
|
|
290
|
+
readonly surface: "engine";
|
|
291
|
+
readonly item: {
|
|
292
|
+
readonly kind: "boolean";
|
|
293
|
+
};
|
|
294
|
+
readonly default: "true";
|
|
295
|
+
}, {
|
|
296
|
+
readonly path: "transforms.opaquePredicate.enabled";
|
|
297
|
+
readonly shape: "scalar";
|
|
298
|
+
readonly scope: "program";
|
|
299
|
+
readonly tier: "free";
|
|
300
|
+
readonly surface: "engine";
|
|
301
|
+
readonly item: {
|
|
302
|
+
readonly kind: "boolean";
|
|
303
|
+
};
|
|
304
|
+
readonly default: "true";
|
|
305
|
+
}, {
|
|
306
|
+
readonly path: "transforms.mixedBooleanArithmetic.enabled";
|
|
307
|
+
readonly shape: "scalar";
|
|
308
|
+
readonly scope: "program";
|
|
309
|
+
readonly tier: "free";
|
|
310
|
+
readonly surface: "engine";
|
|
311
|
+
readonly item: {
|
|
312
|
+
readonly kind: "boolean";
|
|
313
|
+
};
|
|
314
|
+
readonly default: "true";
|
|
315
|
+
}, {
|
|
316
|
+
readonly path: "transforms.integerBytecode.enabled";
|
|
317
|
+
readonly shape: "scalar";
|
|
318
|
+
readonly scope: "program";
|
|
319
|
+
readonly tier: "free";
|
|
320
|
+
readonly surface: "engine";
|
|
321
|
+
readonly item: {
|
|
322
|
+
readonly kind: "boolean";
|
|
323
|
+
};
|
|
324
|
+
readonly default: "true";
|
|
325
|
+
}, {
|
|
326
|
+
readonly path: "transforms.crossDependency.enabled";
|
|
327
|
+
readonly shape: "scalar";
|
|
328
|
+
readonly scope: "program";
|
|
329
|
+
readonly tier: "free";
|
|
330
|
+
readonly surface: "engine";
|
|
331
|
+
readonly item: {
|
|
332
|
+
readonly kind: "boolean";
|
|
333
|
+
};
|
|
334
|
+
readonly default: "true";
|
|
335
|
+
}, {
|
|
336
|
+
readonly path: "transforms.scopeDeepen.enabled";
|
|
337
|
+
readonly shape: "scalar";
|
|
338
|
+
readonly scope: "program";
|
|
339
|
+
readonly tier: "free";
|
|
340
|
+
readonly surface: "engine";
|
|
341
|
+
readonly item: {
|
|
342
|
+
readonly kind: "boolean";
|
|
343
|
+
};
|
|
344
|
+
readonly default: "true";
|
|
345
|
+
}, {
|
|
346
|
+
readonly path: "transforms.objectConstruction.enabled";
|
|
347
|
+
readonly shape: "scalar";
|
|
348
|
+
readonly scope: "program";
|
|
349
|
+
readonly tier: "free";
|
|
350
|
+
readonly surface: "engine";
|
|
351
|
+
readonly item: {
|
|
352
|
+
readonly kind: "boolean";
|
|
353
|
+
};
|
|
354
|
+
readonly default: "true";
|
|
355
|
+
}, {
|
|
356
|
+
readonly path: "transforms.comparisonHardening.enabled";
|
|
357
|
+
readonly shape: "scalar";
|
|
358
|
+
readonly scope: "program";
|
|
359
|
+
readonly tier: "pro";
|
|
360
|
+
readonly surface: "engine";
|
|
361
|
+
readonly item: {
|
|
362
|
+
readonly kind: "boolean";
|
|
363
|
+
};
|
|
364
|
+
readonly default: "false";
|
|
365
|
+
}, {
|
|
366
|
+
readonly path: "transforms.selfIntegrity.enabled";
|
|
367
|
+
readonly shape: "scalar";
|
|
368
|
+
readonly scope: "program";
|
|
369
|
+
readonly tier: "pro";
|
|
370
|
+
readonly surface: "engine";
|
|
371
|
+
readonly item: {
|
|
372
|
+
readonly kind: "boolean";
|
|
373
|
+
};
|
|
374
|
+
readonly default: "false";
|
|
375
|
+
}, {
|
|
376
|
+
readonly path: "build.backup";
|
|
377
|
+
readonly shape: "scalar";
|
|
378
|
+
readonly scope: "program";
|
|
379
|
+
readonly tier: "free";
|
|
380
|
+
readonly surface: "build";
|
|
381
|
+
readonly item: {
|
|
382
|
+
readonly kind: "boolean";
|
|
383
|
+
};
|
|
384
|
+
readonly default: "false for an in-place pass; true standalone";
|
|
385
|
+
}, {
|
|
386
|
+
readonly path: "build.autorun";
|
|
387
|
+
readonly shape: "scalar";
|
|
388
|
+
readonly scope: "program";
|
|
389
|
+
readonly tier: "free";
|
|
390
|
+
readonly surface: "build";
|
|
391
|
+
readonly item: {
|
|
392
|
+
readonly kind: "boolean";
|
|
393
|
+
};
|
|
394
|
+
readonly default: "true";
|
|
395
|
+
}, {
|
|
396
|
+
readonly path: "build.mode";
|
|
397
|
+
readonly shape: "scalar";
|
|
398
|
+
readonly scope: "program";
|
|
399
|
+
readonly tier: "free";
|
|
400
|
+
readonly surface: "build";
|
|
401
|
+
readonly item: {
|
|
402
|
+
readonly kind: "enum";
|
|
403
|
+
readonly values: readonly ["production", "development"];
|
|
404
|
+
};
|
|
405
|
+
readonly default: "detected from the environment";
|
|
406
|
+
}, {
|
|
407
|
+
readonly path: "directives.enabled";
|
|
408
|
+
readonly shape: "scalar";
|
|
409
|
+
readonly scope: "program";
|
|
410
|
+
readonly tier: "free";
|
|
411
|
+
readonly surface: "build";
|
|
412
|
+
readonly item: {
|
|
413
|
+
readonly kind: "boolean";
|
|
414
|
+
};
|
|
415
|
+
readonly default: "true";
|
|
416
|
+
}, {
|
|
417
|
+
readonly path: "diagnostics.level";
|
|
418
|
+
readonly shape: "scalar";
|
|
419
|
+
readonly scope: "program";
|
|
420
|
+
readonly tier: "free";
|
|
421
|
+
readonly surface: "build";
|
|
422
|
+
readonly item: {
|
|
423
|
+
readonly kind: "enum";
|
|
424
|
+
readonly values: readonly ["summary", "all", "none"];
|
|
425
|
+
};
|
|
426
|
+
readonly default: "summary";
|
|
427
|
+
}, {
|
|
428
|
+
readonly path: "diagnostics.format";
|
|
429
|
+
readonly shape: "scalar";
|
|
430
|
+
readonly scope: "program";
|
|
431
|
+
readonly tier: "free";
|
|
432
|
+
readonly surface: "cli";
|
|
433
|
+
readonly item: {
|
|
434
|
+
readonly kind: "enum";
|
|
435
|
+
readonly values: readonly ["text", "json"];
|
|
436
|
+
};
|
|
437
|
+
readonly default: "text";
|
|
438
|
+
}, {
|
|
439
|
+
readonly path: "telemetry.enabled";
|
|
440
|
+
readonly shape: "scalar";
|
|
441
|
+
readonly scope: "program";
|
|
442
|
+
readonly tier: "free";
|
|
443
|
+
readonly surface: "build";
|
|
444
|
+
readonly item: {
|
|
445
|
+
readonly kind: "boolean";
|
|
446
|
+
};
|
|
447
|
+
readonly default: "true";
|
|
448
|
+
}, {
|
|
449
|
+
readonly path: "allowUnobfuscated";
|
|
450
|
+
readonly shape: "scalar";
|
|
451
|
+
readonly scope: "program";
|
|
452
|
+
readonly tier: "free";
|
|
453
|
+
readonly surface: "build";
|
|
454
|
+
readonly item: {
|
|
455
|
+
readonly kind: "boolean";
|
|
456
|
+
};
|
|
457
|
+
readonly default: "false";
|
|
458
|
+
}, {
|
|
459
|
+
readonly path: "key";
|
|
460
|
+
readonly shape: "scalar";
|
|
461
|
+
readonly scope: "program";
|
|
462
|
+
readonly tier: "pro";
|
|
463
|
+
readonly surface: "build";
|
|
464
|
+
readonly item: {
|
|
465
|
+
readonly kind: "string";
|
|
466
|
+
};
|
|
467
|
+
readonly default: "unset; builds run locally with basic protection";
|
|
468
|
+
}];
|
|
469
|
+
type Registry = (typeof CONFIG_KEYS)[number];
|
|
470
|
+
type ItemTs<I> = I extends {
|
|
471
|
+
kind: "boolean";
|
|
472
|
+
} ? boolean : I extends {
|
|
473
|
+
kind: "number";
|
|
474
|
+
} ? number : I extends {
|
|
475
|
+
kind: "unbounded";
|
|
476
|
+
unlimited: infer U;
|
|
477
|
+
} ? number | U : I extends {
|
|
478
|
+
kind: "enum";
|
|
479
|
+
values: readonly (infer V)[];
|
|
480
|
+
} ? V : I extends {
|
|
481
|
+
kind: "seed";
|
|
482
|
+
} ? number | string : I extends {
|
|
483
|
+
kind: "reserved";
|
|
484
|
+
} ? string | GlobReserved : I extends {
|
|
485
|
+
kind: "region";
|
|
486
|
+
} ? RegionConfig : I extends {
|
|
487
|
+
kind: "string";
|
|
488
|
+
} ? string : never;
|
|
489
|
+
type KeyTs<K extends ConfigKeyDef> = K["shape"] extends "scalar" ? ItemTs<K["item"]> : ItemTs<K["item"]>[];
|
|
490
|
+
type Nest<P extends string, V> = P extends `${infer Head}.${infer Rest}` ? { [X in Head]?: Nest<Rest, V> } : { [X in P]?: V };
|
|
491
|
+
type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never;
|
|
492
|
+
type Collapse<T> = T extends readonly unknown[] ? T : T extends object ? { [K in keyof T]: Collapse<T[K]> } | ("enabled" extends keyof T ? boolean : never) : T;
|
|
493
|
+
type NestOf<K> = K extends ConfigKeyDef ? Nest<K["path"], KeyTs<K>> : never;
|
|
494
|
+
type AfterpackConfig = Collapse<UnionToIntersection<NestOf<Registry>>>;
|
|
495
|
+
interface ConfigIssue {
|
|
496
|
+
path: string;
|
|
497
|
+
message: string;
|
|
498
|
+
}
|
|
499
|
+
interface ValidationResult {
|
|
500
|
+
config: AfterpackConfig;
|
|
501
|
+
issues: ConfigIssue[];
|
|
502
|
+
}
|
|
503
|
+
declare function validateConfig(input: unknown, surface: string): ValidationResult;
|
|
504
|
+
declare function mergeConfig(base: AfterpackConfig, override: AfterpackConfig): AfterpackConfig;
|
|
505
|
+
declare function getPath(config: AfterpackConfig, path: string): unknown;
|
|
506
|
+
type ReflectionAllow = (typeof REFLECTION_ALLOW_VALUES)[number];
|
|
507
|
+
interface CoreConfigSubset {
|
|
508
|
+
seed?: number | string;
|
|
509
|
+
preset?: Preset;
|
|
510
|
+
complexity?: number;
|
|
511
|
+
inflation?: {
|
|
512
|
+
max?: number | "unlimited";
|
|
513
|
+
};
|
|
514
|
+
strings?: {
|
|
515
|
+
encode?: boolean;
|
|
516
|
+
minLength?: number;
|
|
517
|
+
leaks?: {
|
|
518
|
+
max?: number;
|
|
519
|
+
};
|
|
520
|
+
preserveLiterals?: string[];
|
|
521
|
+
};
|
|
522
|
+
paths?: {
|
|
523
|
+
exclude?: string[];
|
|
524
|
+
};
|
|
525
|
+
identifiers?: {
|
|
526
|
+
rename?: boolean;
|
|
527
|
+
reserved?: (string | GlobReserved)[];
|
|
528
|
+
globals?: {
|
|
529
|
+
rename?: boolean;
|
|
530
|
+
};
|
|
531
|
+
methods?: {
|
|
532
|
+
rename?: boolean;
|
|
533
|
+
};
|
|
534
|
+
};
|
|
535
|
+
reflection?: {
|
|
536
|
+
allow?: ReflectionAllow[];
|
|
537
|
+
};
|
|
538
|
+
sourceMap?: {
|
|
539
|
+
enabled?: boolean;
|
|
540
|
+
sourcesContent?: boolean;
|
|
541
|
+
};
|
|
542
|
+
protectionMap?: {
|
|
543
|
+
enabled?: boolean;
|
|
544
|
+
detailed?: boolean;
|
|
545
|
+
};
|
|
546
|
+
regions?: RegionConfig[];
|
|
547
|
+
transforms?: Partial<Record<TransformKind, {
|
|
548
|
+
enabled?: boolean;
|
|
549
|
+
}>>;
|
|
550
|
+
}
|
|
551
|
+
declare function toEngineConfig(config: AfterpackConfig): CoreConfigSubset;
|
|
552
|
+
interface PluginOptionsView {
|
|
553
|
+
artifactOptions: AfterpackArtifactOptions;
|
|
554
|
+
seed?: number | string;
|
|
555
|
+
preset?: Preset;
|
|
556
|
+
complexity?: number;
|
|
557
|
+
regions?: RegionConfig[];
|
|
558
|
+
directives: {
|
|
559
|
+
enabled: boolean;
|
|
560
|
+
explicit: boolean;
|
|
561
|
+
};
|
|
562
|
+
build?: {
|
|
563
|
+
autorun?: boolean;
|
|
564
|
+
};
|
|
565
|
+
diagnostics?: {
|
|
566
|
+
level?: "summary" | "all" | "none";
|
|
567
|
+
format?: "text" | "json";
|
|
568
|
+
};
|
|
569
|
+
paths?: {
|
|
570
|
+
include?: string[];
|
|
571
|
+
};
|
|
572
|
+
key?: string;
|
|
573
|
+
}
|
|
574
|
+
declare function toPluginOptions(config: AfterpackConfig): PluginOptionsView;
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region src/policy.d.ts
|
|
577
|
+
interface EnvLike {
|
|
578
|
+
NODE_ENV?: string;
|
|
579
|
+
CI?: string;
|
|
580
|
+
[key: string]: string | undefined;
|
|
581
|
+
}
|
|
582
|
+
interface AfterpackArtifactOptions {
|
|
583
|
+
protectionMap?: {
|
|
584
|
+
enabled?: boolean;
|
|
585
|
+
};
|
|
586
|
+
sourceMap?: {
|
|
587
|
+
enabled?: boolean;
|
|
588
|
+
emitUrl?: boolean;
|
|
589
|
+
};
|
|
590
|
+
build?: {
|
|
591
|
+
backup?: boolean;
|
|
592
|
+
mode?: BuildMode;
|
|
593
|
+
};
|
|
594
|
+
allowUnobfuscated?: boolean;
|
|
595
|
+
telemetry?: {
|
|
596
|
+
enabled?: boolean;
|
|
597
|
+
};
|
|
598
|
+
git?: GitBuildContext | false;
|
|
599
|
+
}
|
|
600
|
+
interface ReportPolicySignals {
|
|
601
|
+
hasBundlerSourcemap?: boolean;
|
|
602
|
+
inPlaceOutput?: boolean;
|
|
603
|
+
}
|
|
604
|
+
interface ReportPolicy {
|
|
605
|
+
isProduction: boolean;
|
|
606
|
+
protectionMap: boolean;
|
|
607
|
+
autoEnableBundlerSourcemap: boolean;
|
|
608
|
+
sourceMap: boolean;
|
|
609
|
+
emitSourceMappingURL: boolean;
|
|
610
|
+
backup: boolean;
|
|
611
|
+
protectionMapInProd: boolean;
|
|
612
|
+
engineSourceMapOverride?: boolean;
|
|
613
|
+
}
|
|
614
|
+
declare function resolveReportPolicy(env?: EnvLike, userOpts?: AfterpackArtifactOptions, signals?: ReportPolicySignals): ReportPolicy;
|
|
615
|
+
type Preset = (typeof PRESET_VALUES)[number];
|
|
616
|
+
type TransformKind = (typeof TRANSFORM_KIND_VALUES)[number];
|
|
617
|
+
interface RegionConfig {
|
|
618
|
+
start: number;
|
|
619
|
+
end: number;
|
|
620
|
+
complexity?: number;
|
|
621
|
+
inflation?: {
|
|
622
|
+
max?: number;
|
|
623
|
+
};
|
|
624
|
+
strings?: {
|
|
625
|
+
encode?: boolean;
|
|
626
|
+
};
|
|
627
|
+
transforms?: {
|
|
628
|
+
only?: TransformKind[];
|
|
629
|
+
deny?: TransformKind[];
|
|
630
|
+
};
|
|
631
|
+
label?: string;
|
|
632
|
+
}
|
|
633
|
+
interface BuildEngineConfigOptions {
|
|
634
|
+
filePath?: string;
|
|
635
|
+
inputSourceMap?: string | null;
|
|
636
|
+
policy: ReportPolicy;
|
|
637
|
+
preset?: Preset;
|
|
638
|
+
complexity?: number;
|
|
639
|
+
seed?: number | string;
|
|
640
|
+
sourcesContent?: boolean;
|
|
641
|
+
regions?: RegionConfig[];
|
|
642
|
+
renameGlobals?: boolean;
|
|
643
|
+
engine?: CoreConfigSubset;
|
|
644
|
+
}
|
|
645
|
+
interface CoreConfig extends CoreConfigSubset {
|
|
646
|
+
seed: number | string;
|
|
647
|
+
preset?: Preset;
|
|
648
|
+
sourceMap: {
|
|
649
|
+
enabled?: boolean;
|
|
650
|
+
sourcesContent: boolean;
|
|
651
|
+
};
|
|
652
|
+
inputSourceMap?: string;
|
|
653
|
+
filePath?: string;
|
|
654
|
+
protectionMap: {
|
|
655
|
+
enabled: boolean;
|
|
656
|
+
detailed?: boolean;
|
|
657
|
+
};
|
|
658
|
+
regions?: RegionConfig[];
|
|
659
|
+
}
|
|
660
|
+
interface BuildContext {
|
|
661
|
+
commitSha?: string;
|
|
662
|
+
ref?: string;
|
|
663
|
+
clientVersion?: string;
|
|
664
|
+
client?: string;
|
|
665
|
+
}
|
|
666
|
+
//#endregion
|
|
667
|
+
//#region src/artifacts.d.ts
|
|
668
|
+
interface Logger {
|
|
669
|
+
warn: (message: string) => void;
|
|
670
|
+
log: (message: string) => void;
|
|
671
|
+
}
|
|
672
|
+
interface WriteArtifactsInput {
|
|
673
|
+
outPath: string;
|
|
674
|
+
code: string;
|
|
675
|
+
sourceMapJson: string | null;
|
|
676
|
+
protectionMapJson: ProtectionMap | null;
|
|
677
|
+
originalSource: string | null;
|
|
678
|
+
policy: ReportPolicy;
|
|
679
|
+
mode?: ArtifactMode;
|
|
680
|
+
afterpackDir?: string;
|
|
681
|
+
logger?: Logger;
|
|
682
|
+
}
|
|
683
|
+
interface WriteArtifactsResult {
|
|
684
|
+
codePath: string;
|
|
685
|
+
mapPath: string | null;
|
|
686
|
+
backupPath: string | null;
|
|
687
|
+
protectionMapPath: string | null;
|
|
688
|
+
wroteSourceMappingURL: boolean;
|
|
689
|
+
}
|
|
690
|
+
declare function writeArtifacts(input: WriteArtifactsInput): WriteArtifactsResult;
|
|
691
|
+
//#endregion
|
|
692
|
+
//#region src/notices.d.ts
|
|
693
|
+
interface CloudNotice {
|
|
694
|
+
severity: string;
|
|
695
|
+
code: string;
|
|
696
|
+
message: string;
|
|
697
|
+
url?: string;
|
|
698
|
+
}
|
|
699
|
+
type NoticeSeverity = "info" | "warning" | "error";
|
|
700
|
+
interface SafeNotice {
|
|
701
|
+
severity: NoticeSeverity;
|
|
702
|
+
code: string;
|
|
703
|
+
message: string;
|
|
704
|
+
url: string | null;
|
|
705
|
+
}
|
|
706
|
+
declare function sanitizeNotices(raw: unknown): SafeNotice[];
|
|
707
|
+
interface NoticeLogger {
|
|
708
|
+
log(message: string): void;
|
|
709
|
+
warn?(message: string): void;
|
|
710
|
+
}
|
|
711
|
+
//#endregion
|
|
712
|
+
//#region src/compat.d.ts
|
|
713
|
+
interface ClientIdentity {
|
|
714
|
+
packageName: string | null;
|
|
715
|
+
packageVersion: string | null;
|
|
716
|
+
coreVersion: string | null;
|
|
717
|
+
}
|
|
718
|
+
declare function resolveClientIdentity(moduleUrl: string | URL): ClientIdentity;
|
|
719
|
+
declare function npxAlternative(identity: ClientIdentity | null | undefined): string | null;
|
|
720
|
+
declare const CLOUD_REFUSAL_SUMMARY = "This version of AfterPack is no longer supported by the AfterPack cloud.";
|
|
721
|
+
declare const CORE_FLOOR_SUMMARY = "@afterpack/core is too old to protect this build \u2014 update @afterpack/core.";
|
|
722
|
+
declare function installedRequiredLine(installed: string | null, minVersion: string | null): string;
|
|
723
|
+
declare function serverAddsInfo(serverMessage: string, shownText: string): boolean;
|
|
724
|
+
declare class CoreVersionError extends Error {
|
|
725
|
+
readonly code = "CORE_VERSION_UNSUPPORTED";
|
|
726
|
+
readonly installed: string;
|
|
727
|
+
readonly minimum: string;
|
|
728
|
+
readonly fix: string;
|
|
729
|
+
constructor(message: string, installed: string, minimum: string, fix: string);
|
|
730
|
+
}
|
|
731
|
+
type CloudErrorKind = "upgradeRequired" | "sunset" | "api";
|
|
732
|
+
declare class CloudApiError extends Error {
|
|
733
|
+
readonly code: string;
|
|
734
|
+
readonly kind: CloudErrorKind;
|
|
735
|
+
readonly apiCode: string | null;
|
|
736
|
+
readonly apiMessage: string;
|
|
737
|
+
readonly details: Record<string, unknown> | null;
|
|
738
|
+
readonly notices: SafeNotice[];
|
|
739
|
+
readonly minVersion: string | null;
|
|
740
|
+
readonly installed: string | null;
|
|
741
|
+
readonly fix: string;
|
|
742
|
+
constructor(input: {
|
|
743
|
+
message: string;
|
|
744
|
+
code: string;
|
|
745
|
+
kind: CloudErrorKind;
|
|
746
|
+
apiCode: string | null;
|
|
747
|
+
apiMessage: string;
|
|
748
|
+
details: Record<string, unknown> | null;
|
|
749
|
+
notices: SafeNotice[];
|
|
750
|
+
minVersion: string | null;
|
|
751
|
+
installed: string | null;
|
|
752
|
+
fix: string;
|
|
753
|
+
cause: unknown;
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
//#endregion
|
|
757
|
+
//#region src/diagnostics.d.ts
|
|
758
|
+
type EngineSeverity = "info" | "error" | "critical";
|
|
759
|
+
interface EngineSpan {
|
|
760
|
+
startByte: number;
|
|
761
|
+
endByte: number;
|
|
762
|
+
}
|
|
763
|
+
type EngineDiagnosticData = {
|
|
764
|
+
kind: string;
|
|
765
|
+
} & Record<string, unknown>;
|
|
766
|
+
interface EngineDiagnostic {
|
|
767
|
+
severity: EngineSeverity;
|
|
768
|
+
message: string;
|
|
769
|
+
code: string;
|
|
770
|
+
span?: EngineSpan | null;
|
|
771
|
+
file?: string | null;
|
|
772
|
+
data?: EngineDiagnosticData | null;
|
|
773
|
+
}
|
|
774
|
+
type DiagnosticsVerbosity = "summary" | "all" | "none";
|
|
775
|
+
interface DiagnosticsSummary {
|
|
776
|
+
total: number;
|
|
777
|
+
info: number;
|
|
778
|
+
error: number;
|
|
779
|
+
critical: number;
|
|
780
|
+
byCode: Record<string, number>;
|
|
781
|
+
}
|
|
782
|
+
declare const DIAG_ALREADY_OBFUSCATED = "DIAG_ALREADY_OBFUSCATED";
|
|
783
|
+
declare class AlreadyObfuscatedError extends Error {
|
|
784
|
+
readonly code = "DIAG_ALREADY_OBFUSCATED";
|
|
785
|
+
readonly files: readonly string[];
|
|
786
|
+
readonly receiptPath: string;
|
|
787
|
+
readonly dir: string;
|
|
788
|
+
constructor(message: string, files: readonly string[], receiptPath: string, dir: string);
|
|
789
|
+
}
|
|
790
|
+
//#endregion
|
|
791
|
+
//#region src/directives.d.ts
|
|
792
|
+
interface CapturedDirective {
|
|
793
|
+
keyword: string;
|
|
794
|
+
form: "line" | "block";
|
|
795
|
+
tier: "free" | "amplifying";
|
|
796
|
+
line: number;
|
|
797
|
+
column: number;
|
|
798
|
+
region: RegionConfig;
|
|
799
|
+
charStart: number;
|
|
800
|
+
charEnd: number;
|
|
801
|
+
}
|
|
802
|
+
interface DirectiveDiagnostic {
|
|
803
|
+
code: string;
|
|
804
|
+
message: string;
|
|
805
|
+
line: number;
|
|
806
|
+
column: number;
|
|
807
|
+
}
|
|
808
|
+
interface DirectiveManifest {
|
|
809
|
+
regions: RegionConfig[];
|
|
810
|
+
directives: CapturedDirective[];
|
|
811
|
+
diagnostics: DirectiveDiagnostic[];
|
|
812
|
+
renameGlobals: boolean;
|
|
813
|
+
}
|
|
814
|
+
declare function scanDirectives(source: string): DirectiveManifest;
|
|
815
|
+
//#endregion
|
|
816
|
+
//#region src/map-color.d.ts
|
|
817
|
+
interface CapturedModule {
|
|
818
|
+
id: string;
|
|
819
|
+
source: string;
|
|
820
|
+
directives: CapturedDirective[];
|
|
821
|
+
renameGlobals?: boolean;
|
|
822
|
+
srcIndex?: number;
|
|
823
|
+
}
|
|
824
|
+
//#endregion
|
|
825
|
+
//#region src/receipt.d.ts
|
|
826
|
+
declare const PROTECTION_RECEIPT_FILE = ".afterpack-protection.json";
|
|
827
|
+
interface ProtectionReceiptFile {
|
|
828
|
+
path: string;
|
|
829
|
+
sha256: string;
|
|
830
|
+
transformed: boolean;
|
|
831
|
+
}
|
|
832
|
+
type EngineSource = "local" | "cloud";
|
|
833
|
+
interface ProtectionReceipt {
|
|
834
|
+
schema: number;
|
|
835
|
+
tool: string;
|
|
836
|
+
engine: EngineSource | null;
|
|
837
|
+
engineVersion: string | null;
|
|
838
|
+
seed: string;
|
|
839
|
+
seedOrigin: string;
|
|
840
|
+
bundler: string;
|
|
841
|
+
buildId: string | null;
|
|
842
|
+
files: ProtectionReceiptFile[];
|
|
843
|
+
}
|
|
844
|
+
declare function sha256Of(path: string): string;
|
|
845
|
+
interface WriteProtectionReceiptInput {
|
|
846
|
+
dir: string;
|
|
847
|
+
tool: string;
|
|
848
|
+
engine: EngineSource | null;
|
|
849
|
+
engineVersion: string | null;
|
|
850
|
+
seed: number | string;
|
|
851
|
+
seedOrigin: string;
|
|
852
|
+
bundler: string;
|
|
853
|
+
buildId: string | null;
|
|
854
|
+
files: string[];
|
|
855
|
+
transformed: readonly string[];
|
|
856
|
+
}
|
|
857
|
+
declare function writeDeferredProtectionReceipt(deferred: WriteProtectionReceiptInput): string | null;
|
|
858
|
+
declare function writeProtectionReceipt(input: WriteProtectionReceiptInput): string;
|
|
859
|
+
interface ProtectionVerification {
|
|
860
|
+
receiptPath: string;
|
|
861
|
+
receipt: ProtectionReceipt | null;
|
|
862
|
+
problems: string[];
|
|
863
|
+
}
|
|
864
|
+
declare const DIAG_RECEIPT_UNREADABLE = "DIAG_RECEIPT_UNREADABLE";
|
|
865
|
+
declare class UnreadableReceiptError extends Error {
|
|
866
|
+
readonly code = "DIAG_RECEIPT_UNREADABLE";
|
|
867
|
+
readonly receiptPath: string;
|
|
868
|
+
readonly schema: number;
|
|
869
|
+
constructor(message: string, receiptPath: string, schema: number);
|
|
870
|
+
}
|
|
871
|
+
declare function verifyProtectionReceipt(dir: string, expectedBuildId?: string | null): ProtectionVerification;
|
|
872
|
+
//#endregion
|
|
873
|
+
//#region src/seed.d.ts
|
|
874
|
+
type SeedOption = number | string | undefined;
|
|
875
|
+
declare const SEED_ENV_VAR = "AFTERPACK_SEED";
|
|
876
|
+
type SeedOrigin = "option" | "git" | "env" | "session" | "fresh";
|
|
877
|
+
//#endregion
|
|
878
|
+
//#region src/summary.d.ts
|
|
879
|
+
type PassSummaryStyle = "cli" | "plugin";
|
|
880
|
+
//#endregion
|
|
881
|
+
//#region src/telemetry.d.ts
|
|
882
|
+
type TelemetrySeverity = "error" | "critical";
|
|
883
|
+
interface TelemetrySpan {
|
|
884
|
+
startByte: number;
|
|
885
|
+
endByte: number;
|
|
886
|
+
}
|
|
887
|
+
type TelemetryDiagnosticData = {
|
|
888
|
+
kind: string;
|
|
889
|
+
} & Record<string, string | number>;
|
|
890
|
+
interface TelemetryDiagnostic {
|
|
891
|
+
code: string;
|
|
892
|
+
severity: TelemetrySeverity;
|
|
893
|
+
span: TelemetrySpan | null;
|
|
894
|
+
data: TelemetryDiagnosticData | null;
|
|
895
|
+
message?: never;
|
|
896
|
+
file?: never;
|
|
897
|
+
}
|
|
898
|
+
interface TelemetryPayload {
|
|
899
|
+
version: number;
|
|
900
|
+
installId: string;
|
|
901
|
+
framework: string;
|
|
902
|
+
frameworkVersion: string | null;
|
|
903
|
+
engineVersion: string | null;
|
|
904
|
+
clientVersion: string | null;
|
|
905
|
+
nodeVersion: string;
|
|
906
|
+
os: string;
|
|
907
|
+
arch: string;
|
|
908
|
+
ci: boolean;
|
|
909
|
+
complexity: string;
|
|
910
|
+
fileCountBucket: string;
|
|
911
|
+
durationBucket: string;
|
|
912
|
+
diagnostics: TelemetryDiagnostic[];
|
|
913
|
+
errorCount: number;
|
|
914
|
+
criticalCount: number;
|
|
915
|
+
droppedCount: number;
|
|
916
|
+
}
|
|
917
|
+
interface TelemetryFacts {
|
|
918
|
+
label: string;
|
|
919
|
+
projectRoot: string;
|
|
920
|
+
diagnostics: readonly EngineDiagnostic[];
|
|
921
|
+
fileCount: number;
|
|
922
|
+
durationMs: number;
|
|
923
|
+
preset?: Preset;
|
|
924
|
+
complexity?: number;
|
|
925
|
+
engineVersion?: string | null;
|
|
926
|
+
clientVersion?: string | null;
|
|
927
|
+
}
|
|
928
|
+
interface TelemetryContext {
|
|
929
|
+
installId: string;
|
|
930
|
+
env?: EnvLike;
|
|
931
|
+
runtime?: {
|
|
932
|
+
node: string;
|
|
933
|
+
platform: string;
|
|
934
|
+
arch: string;
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
type TelemetryReporter = (facts: TelemetryFacts | null) => Promise<void>;
|
|
938
|
+
interface TelemetryReporterDeps {
|
|
939
|
+
env?: EnvLike;
|
|
940
|
+
logger?: NoticeLogger;
|
|
941
|
+
fetchImpl?: typeof fetch;
|
|
942
|
+
now?: () => number;
|
|
943
|
+
stateFile?: string;
|
|
944
|
+
timeoutMs?: number;
|
|
945
|
+
}
|
|
946
|
+
declare function createTelemetryReporter(deps?: TelemetryReporterDeps): TelemetryReporter;
|
|
947
|
+
//#endregion
|
|
948
|
+
//#region src/pass.d.ts
|
|
949
|
+
interface EngineFileInput {
|
|
950
|
+
path: string;
|
|
951
|
+
source: string;
|
|
952
|
+
sourceMap?: string;
|
|
953
|
+
regions?: RegionConfig[];
|
|
954
|
+
}
|
|
955
|
+
interface EngineFileResult {
|
|
956
|
+
path: string;
|
|
957
|
+
code: string;
|
|
958
|
+
sourceMap?: string;
|
|
959
|
+
protectionMap?: ProtectionMap;
|
|
960
|
+
status: "success" | "failure";
|
|
961
|
+
error?: string;
|
|
962
|
+
unobfuscated: boolean;
|
|
963
|
+
diagnostics?: EngineDiagnostic[];
|
|
964
|
+
}
|
|
965
|
+
interface EngineBatchResult {
|
|
966
|
+
files: EngineFileResult[];
|
|
967
|
+
totalFiles: number;
|
|
968
|
+
successCount: number;
|
|
969
|
+
failureCount: number;
|
|
970
|
+
source: "local" | "cloud";
|
|
971
|
+
notices?: CloudNotice[];
|
|
972
|
+
engineVersion?: string;
|
|
973
|
+
}
|
|
974
|
+
interface ObfuscationEngine {
|
|
975
|
+
processBatch(inputs: EngineFileInput[], config: CoreConfig, buildContext?: BuildContext | null): Promise<EngineBatchResult>;
|
|
976
|
+
version?(): Promise<string>;
|
|
977
|
+
}
|
|
978
|
+
interface CombinedProtectionMapTarget {
|
|
979
|
+
buildDir: string;
|
|
980
|
+
afterpackDir?: string;
|
|
981
|
+
fileName?: string;
|
|
982
|
+
}
|
|
983
|
+
interface InMemoryInput {
|
|
984
|
+
source: string;
|
|
985
|
+
sourceMap?: string | null;
|
|
986
|
+
}
|
|
987
|
+
interface InMemoryOutput {
|
|
988
|
+
path: string;
|
|
989
|
+
code: string;
|
|
990
|
+
sourceMap: string | null;
|
|
991
|
+
}
|
|
992
|
+
interface PassMessages {
|
|
993
|
+
autoEnableBundlerSourcemap?: string;
|
|
994
|
+
directivesNeedClientMaps?: string;
|
|
995
|
+
}
|
|
996
|
+
interface PassReceiptIdentity {
|
|
997
|
+
bundler?: string;
|
|
998
|
+
buildId?: string | null;
|
|
999
|
+
}
|
|
1000
|
+
interface ObfuscationPassOptions {
|
|
1001
|
+
files: string[];
|
|
1002
|
+
inputs?: Map<string, InMemoryInput>;
|
|
1003
|
+
emitToCaller?: boolean;
|
|
1004
|
+
engine: ObfuscationEngine;
|
|
1005
|
+
label: string;
|
|
1006
|
+
gitignoreDir: string;
|
|
1007
|
+
combinedProtectionMap: CombinedProtectionMapTarget;
|
|
1008
|
+
artifactOptions?: AfterpackArtifactOptions;
|
|
1009
|
+
hasBundlerSourcemap?: boolean;
|
|
1010
|
+
seed?: SeedOption;
|
|
1011
|
+
buildLeg?: string;
|
|
1012
|
+
preset?: Preset;
|
|
1013
|
+
complexity?: number;
|
|
1014
|
+
regions?: RegionConfig[];
|
|
1015
|
+
engineConfig?: CoreConfigSubset;
|
|
1016
|
+
directivesEnabled?: boolean;
|
|
1017
|
+
postMinify?: boolean;
|
|
1018
|
+
directivesEnabledExplicit?: boolean;
|
|
1019
|
+
capturedByFile?: Map<string, CapturedModule[]>;
|
|
1020
|
+
env?: EnvLike;
|
|
1021
|
+
messages?: PassMessages;
|
|
1022
|
+
receipt?: PassReceiptIdentity;
|
|
1023
|
+
afterWrite?: () => void;
|
|
1024
|
+
diagnostics?: DiagnosticsVerbosity;
|
|
1025
|
+
telemetry?: TelemetryReporter;
|
|
1026
|
+
clientVersion?: string;
|
|
1027
|
+
client?: ClientIdentity | null;
|
|
1028
|
+
logger?: Logger;
|
|
1029
|
+
startedAt?: number;
|
|
1030
|
+
summaryStyle?: PassSummaryStyle;
|
|
1031
|
+
colorGlyph?: (glyph: string) => string;
|
|
1032
|
+
}
|
|
1033
|
+
interface PassTiming {
|
|
1034
|
+
totalMs: number;
|
|
1035
|
+
prepMs: number;
|
|
1036
|
+
engineMs: number;
|
|
1037
|
+
writeMs: number;
|
|
1038
|
+
cloudMs: number | null;
|
|
1039
|
+
engineSource: string | null;
|
|
1040
|
+
callerAnchored: boolean;
|
|
1041
|
+
}
|
|
1042
|
+
interface ObfuscationPassResult {
|
|
1043
|
+
fileCount: number;
|
|
1044
|
+
protectionMapPath: string | null;
|
|
1045
|
+
receiptPath: string | null;
|
|
1046
|
+
deferredReceipt: WriteProtectionReceiptInput | null;
|
|
1047
|
+
policy: ReportPolicy;
|
|
1048
|
+
seed: number | string;
|
|
1049
|
+
seedOrigin: SeedOrigin;
|
|
1050
|
+
timing: PassTiming;
|
|
1051
|
+
diagnostics: DiagnosticsSummary;
|
|
1052
|
+
transformedFiles: string[];
|
|
1053
|
+
outputs?: InMemoryOutput[];
|
|
1054
|
+
}
|
|
1055
|
+
declare function runObfuscationPass(options: ObfuscationPassOptions): Promise<ObfuscationPassResult>;
|
|
1056
|
+
//#endregion
|
|
1057
|
+
//#region src/bundle.d.ts
|
|
1058
|
+
interface BundleEntryLike {
|
|
1059
|
+
type: string;
|
|
1060
|
+
fileName: string;
|
|
1061
|
+
code?: string;
|
|
1062
|
+
source?: string | Uint8Array;
|
|
1063
|
+
map?: {
|
|
1064
|
+
toString(): string;
|
|
1065
|
+
} | null;
|
|
1066
|
+
sourcemapFileName?: string | null;
|
|
1067
|
+
modules?: Record<string, unknown>;
|
|
1068
|
+
}
|
|
1069
|
+
type OutputBundleLike = Record<string, BundleEntryLike>;
|
|
1070
|
+
interface BundleJs {
|
|
1071
|
+
files: string[];
|
|
1072
|
+
inputs: Map<string, InMemoryInput>;
|
|
1073
|
+
entries: Map<string, BundleEntryLike>;
|
|
1074
|
+
}
|
|
1075
|
+
declare function collectBundleJs(bundle: OutputBundleLike, outDir: string): BundleJs;
|
|
1076
|
+
declare function applyBundleOutput(bundle: OutputBundleLike, entry: BundleEntryLike, out: InMemoryOutput, policy: ReportPolicy): void;
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region src/collect.d.ts
|
|
1079
|
+
interface CollectJsOptions {
|
|
1080
|
+
include?: readonly string[];
|
|
1081
|
+
onNestedProject?: (dir: string) => void;
|
|
1082
|
+
}
|
|
1083
|
+
declare function collectJsFiles(target: string, options?: CollectJsOptions): string[];
|
|
1084
|
+
declare function collectSourceMaps(dir: string): string[];
|
|
1085
|
+
//#endregion
|
|
1086
|
+
//#region src/config-file.d.ts
|
|
1087
|
+
declare const CONFIG_FILE_NAME = "afterpack.json";
|
|
1088
|
+
interface LoadedConfigFile {
|
|
1089
|
+
path: string | null;
|
|
1090
|
+
config: AfterpackConfig;
|
|
1091
|
+
issues: ConfigIssue[];
|
|
1092
|
+
}
|
|
1093
|
+
declare function loadConfigFile(startDir: string): LoadedConfigFile;
|
|
1094
|
+
//#endregion
|
|
1095
|
+
//#region src/config-parse.d.ts
|
|
1096
|
+
interface CliParseResult {
|
|
1097
|
+
config: AfterpackConfig;
|
|
1098
|
+
positionals: string[];
|
|
1099
|
+
help: boolean;
|
|
1100
|
+
version: boolean;
|
|
1101
|
+
issues: ConfigIssue[];
|
|
1102
|
+
}
|
|
1103
|
+
declare function parseCliOptions(argv: string[]): CliParseResult;
|
|
1104
|
+
interface EnvParseResult {
|
|
1105
|
+
config: AfterpackConfig;
|
|
1106
|
+
issues: ConfigIssue[];
|
|
1107
|
+
}
|
|
1108
|
+
declare function parseEnvOptions(env: Record<string, string | undefined>): EnvParseResult;
|
|
1109
|
+
//#endregion
|
|
1110
|
+
//#region src/plugin-config.d.ts
|
|
1111
|
+
declare const PLUGIN_LOCAL_KEYS: readonly ["git"];
|
|
1112
|
+
type AfterpackPluginOptions = Omit<AfterpackConfig, "key"> & Pick<AfterpackArtifactOptions, (typeof PLUGIN_LOCAL_KEYS)[number]>;
|
|
1113
|
+
interface NormalizedPluginOptions {
|
|
1114
|
+
config: Record<string, unknown>;
|
|
1115
|
+
issues: ConfigIssue[];
|
|
1116
|
+
}
|
|
1117
|
+
declare function normalizePluginOptions(input: unknown, localKeys: readonly string[], surface: string): NormalizedPluginOptions;
|
|
1118
|
+
interface PluginConfigInput {
|
|
1119
|
+
label: string;
|
|
1120
|
+
options?: unknown;
|
|
1121
|
+
argv?: string[];
|
|
1122
|
+
cwd?: string;
|
|
1123
|
+
env?: Record<string, string | undefined>;
|
|
1124
|
+
localKeys?: readonly string[];
|
|
1125
|
+
unsupported?: Readonly<Record<string, string>>;
|
|
1126
|
+
}
|
|
1127
|
+
interface ResolvedPluginConfig {
|
|
1128
|
+
config: AfterpackConfig;
|
|
1129
|
+
options: PluginOptionsView;
|
|
1130
|
+
engineConfig: CoreConfigSubset;
|
|
1131
|
+
configFile: string | null;
|
|
1132
|
+
positionals: string[];
|
|
1133
|
+
help: boolean;
|
|
1134
|
+
version: boolean;
|
|
1135
|
+
}
|
|
1136
|
+
type PassSettings = Pick<ObfuscationPassOptions, "artifactOptions" | "seed" | "preset" | "complexity" | "regions" | "engineConfig" | "diagnostics" | "directivesEnabled" | "directivesEnabledExplicit">;
|
|
1137
|
+
declare function passSettings(resolved: Pick<ResolvedPluginConfig, "options" | "engineConfig">): PassSettings;
|
|
1138
|
+
declare function applyResolvedKey(config: AfterpackConfig, env?: Record<string, string | undefined>): void;
|
|
1139
|
+
declare function resolvePluginConfig(input: PluginConfigInput): ResolvedPluginConfig;
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region src/source-map.d.ts
|
|
1142
|
+
declare function withSourceMappingURL(code: string, url: string | null): string;
|
|
1143
|
+
declare function extractSourceMappingURL(code: string): string | null;
|
|
1144
|
+
declare function decodeDataUri(url: string): string | null;
|
|
1145
|
+
declare function discoverInputSourceMap(jsPath: string, code?: string): string | null;
|
|
1146
|
+
//#endregion
|
|
1147
|
+
export { type AfterpackArtifactOptions, type AfterpackConfig, type AfterpackPluginOptions, AlreadyObfuscatedError, type ArtifactMode, type BuildContext, type BuildEngineConfigOptions, type BundleEntryLike, type BundleJs, CLOUD_REFUSAL_SUMMARY, CONFIG_FILE_NAME, CONFIG_KEYS, CORE_FLOOR_SUMMARY, type CapturedDirective, type CapturedModule, type CliParseResult, type ClientIdentity, CloudApiError, type CloudErrorKind, type CloudNotice, type CollectJsOptions, type CombinedProtectionMapTarget, type ConfigIssue, type ConfigKeyDef, type ConfigScope, type ConfigSurface, type ConfigTier, type CoreConfig, type CoreConfigSubset, CoreVersionError, DIAG_ALREADY_OBFUSCATED, DIAG_RECEIPT_UNREADABLE, type DiagnosticsSummary, type DiagnosticsVerbosity, type DirectiveDiagnostic, type DirectiveManifest, type EngineBatchResult, type EngineDiagnostic, type EngineDiagnosticData, type EngineFileInput, type EngineFileResult, type EngineSeverity, type EngineSpan, type EnvLike, type EnvParseResult, type GitBuildContext, type GlobReserved, type InMemoryInput, type InMemoryOutput, type LoadedConfigFile, type Logger, type NormalizedPluginOptions, type NoticeLogger, type NoticeSeverity, type ObfuscationEngine, type ObfuscationPassOptions, type ObfuscationPassResult, type OutputBundleLike, PROTECTION_RECEIPT_FILE, type PassMessages, type PassReceiptIdentity, type PassSettings, type PassTiming, type PluginConfigInput, type PluginOptionsView, type Preset, type ProtectionReceipt, type ProtectionReceiptFile, type ProtectionVerification, type RegionConfig, type ReportPolicy, type ReportPolicySignals, type ResolvedPluginConfig, SEED_ENV_VAR, type SafeNotice, type SeedOption, type SeedOrigin, type TelemetryContext, type TelemetryDiagnostic, type TelemetryDiagnosticData, type TelemetryFacts, type TelemetryPayload, type TelemetryReporter, type TelemetryReporterDeps, type TelemetrySeverity, type TelemetrySpan, type TransformKind, UnreadableReceiptError, type ValidationResult, type ValueShape, type ValueType, type WriteArtifactsInput, type WriteArtifactsResult, type WriteProtectionReceiptInput, applyBundleOutput, applyResolvedKey, collectBundleJs, collectJsFiles, collectSourceMaps, createTelemetryReporter, decodeDataUri, discoverInputSourceMap, extractSourceMappingURL, findUpward, getPath, installedRequiredLine, loadConfigFile, mergeConfig, normalizePluginOptions, npxAlternative, parseCliOptions, parseEnvOptions, passSettings, resolveClientIdentity, resolvePluginConfig, resolveReportPolicy, runObfuscationPass, sanitizeNotices, scanDirectives, serverAddsInfo, sha256Of, toEngineConfig, toPluginOptions, validateConfig, verifyProtectionReceipt, withSourceMappingURL, writeArtifacts, writeDeferredProtectionReceipt, writeProtectionReceipt };
|