carrick 0.3.150 → 0.3.151
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/dist/global-install.d.ts +2 -2
- package/dist/global-install.js +1 -1
- package/dist/global-install.js.map +1 -1
- package/dist/hook/reuse.d.ts +1 -0
- package/dist/hook/reuse.js +10 -1
- package/dist/hook/reuse.js.map +1 -1
- package/dist/hook/session-start.js +15 -13
- package/dist/hook/session-start.js.map +1 -1
- package/dist/hook/stop-wait.js +5 -1
- package/dist/hook/stop-wait.js.map +1 -1
- package/dist/hook/upgrade.d.ts +11 -0
- package/dist/hook/upgrade.js +81 -0
- package/dist/hook/upgrade.js.map +1 -0
- package/dist/hook/worktree.d.ts +4 -0
- package/dist/hook/worktree.js +9 -0
- package/dist/hook/worktree.js.map +1 -1
- package/dist/init/repo-copies.d.ts +2 -0
- package/dist/init/repo-copies.js +1 -1
- package/dist/init/repo-copies.js.map +1 -1
- package/dist/init/self-update.d.ts +2 -2
- package/dist/init/self-update.js +56 -12
- package/dist/init/self-update.js.map +1 -1
- package/dist/self-upgrade.d.ts +1 -0
- package/dist/self-upgrade.js +10 -0
- package/dist/self-upgrade.js.map +1 -0
- package/dist/upgrade.d.ts +26 -0
- package/dist/upgrade.js +86 -0
- package/dist/upgrade.js.map +1 -0
- package/package.json +6 -6
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/sidecar/dist/src/capture/anchors.d.ts +7 -0
- package/sidecar/dist/src/capture/anchors.js +13 -4
- package/sidecar/dist/src/capture/check-classify.js +4 -2
- package/sidecar/dist/src/capture/check.js +8 -4
- package/sidecar/dist/src/capture/deep-walk.d.ts +14 -8
- package/sidecar/dist/src/capture/deep-walk.js +26 -9
- package/sidecar/dist/src/capture/index.js +4 -2
- package/sidecar/dist/src/capture/self-check.d.ts +7 -0
- package/sidecar/dist/src/capture/self-check.js +19 -1
- package/sidecar/dist/src/capture/service-config.d.ts +5 -4
- package/sidecar/dist/src/capture/service-config.js +15 -12
- package/sidecar/dist/src/library-claims.js +81 -17
- package/sidecar/dist/src/position-rows.js +25 -3
- package/sidecar/dist/src/types.d.ts +8 -1
- package/sidecar/dist/src/validators.d.ts +104 -0
- package/sidecar/dist/src/validators.js +3 -1
|
@@ -110,8 +110,26 @@ export const SELF_CHECK_OPTIONS = sidecarCompilerOptions({
|
|
|
110
110
|
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
111
111
|
types: [],
|
|
112
112
|
});
|
|
113
|
+
/** The host of a self-check program, with outside declarations resolving from their source. */
|
|
114
|
+
function selfCheckHost(args) {
|
|
115
|
+
const outside = args.outsideSources;
|
|
116
|
+
if (!outside || Object.keys(outside).length === 0)
|
|
117
|
+
return args.compilerHost?.(SELF_CHECK_OPTIONS);
|
|
118
|
+
const host = args.compilerHost?.(SELF_CHECK_OPTIONS) ?? ts.createCompilerHost(SELF_CHECK_OPTIONS);
|
|
119
|
+
const fallback = host.resolveModuleNames?.bind(host);
|
|
120
|
+
host.resolveModuleNames = (names, containingFile, reused, redirected, options, containingSourceFile) => names.map((name, index) => {
|
|
121
|
+
const resolved = fallback
|
|
122
|
+
? fallback([name], containingFile, reused?.slice(index, index + 1), redirected, options, containingSourceFile)[0]
|
|
123
|
+
: ts.resolveModuleName(name, containingFile, options, host).resolvedModule;
|
|
124
|
+
const source = outside[path.resolve(containingFile)];
|
|
125
|
+
if (resolved || !source || name.startsWith('.') || path.isAbsolute(name))
|
|
126
|
+
return resolved;
|
|
127
|
+
return ts.resolveModuleName(name, source, options, host).resolvedModule;
|
|
128
|
+
});
|
|
129
|
+
return host;
|
|
130
|
+
}
|
|
113
131
|
function runSelfCheck(args, treeFiles, repaired) {
|
|
114
|
-
const program = ts.createProgram(treeFiles, SELF_CHECK_OPTIONS, args
|
|
132
|
+
const program = ts.createProgram(treeFiles, SELF_CHECK_OPTIONS, selfCheckHost(args));
|
|
115
133
|
const checker = program.getTypeChecker();
|
|
116
134
|
const diagnostics = ts.getPreEmitDiagnostics(program);
|
|
117
135
|
// A surface holds EVERY alias, and every alias's closure starts there, so
|
|
@@ -33,8 +33,9 @@ export declare function realPath(p: string): string;
|
|
|
33
33
|
* The config each file of one service is typed under (carrick#1604,
|
|
34
34
|
* carrick#3497 ruling R-N1): the one the TypeScript language service picks.
|
|
35
35
|
* From the file's directory up to the service root, inclusive, each directory's
|
|
36
|
-
* `tsconfig.json`,
|
|
37
|
-
* project it references, lists the file; the first that does
|
|
36
|
+
* `tsconfig.json`, then the `jsconfig.json` beside it, is asked whether its
|
|
37
|
+
* program, or a project it references, lists the file; the first that does
|
|
38
|
+
* types it (a
|
|
38
39
|
* solution config hands the file to the reference that lists it). A config
|
|
39
40
|
* that lists the file nowhere is passed over. The climb stops after a
|
|
40
41
|
* directory named `node_modules`, as tsserver's does. A file no config inside
|
|
@@ -50,7 +51,7 @@ export declare class GoverningConfigs {
|
|
|
50
51
|
private readonly serviceConfig;
|
|
51
52
|
private readonly report;
|
|
52
53
|
private readonly root;
|
|
53
|
-
/** Directory -> the
|
|
54
|
+
/** Directory -> the configs in it, in order, for every directory a climb visited. */
|
|
54
55
|
private readonly dirConfigs;
|
|
55
56
|
/** Config -> its projects; undefined for one that cannot be read. */
|
|
56
57
|
private readonly graphs;
|
|
@@ -62,7 +63,7 @@ export declare class GoverningConfigs {
|
|
|
62
63
|
constructor(serviceRoot: string, serviceConfig: string | undefined, report?: (diagnostic: string) => void);
|
|
63
64
|
/** Absolute path of the config that types `file`, or undefined for none. */
|
|
64
65
|
configFor(file: string): string | undefined;
|
|
65
|
-
private
|
|
66
|
+
private configsIn;
|
|
66
67
|
/** The project reached from `config` that lists `file`, absolute. */
|
|
67
68
|
private listingOwner;
|
|
68
69
|
}
|
|
@@ -76,8 +76,9 @@ const FILE_CONFIG_NAMES = ['tsconfig.json', 'jsconfig.json'];
|
|
|
76
76
|
* The config each file of one service is typed under (carrick#1604,
|
|
77
77
|
* carrick#3497 ruling R-N1): the one the TypeScript language service picks.
|
|
78
78
|
* From the file's directory up to the service root, inclusive, each directory's
|
|
79
|
-
* `tsconfig.json`,
|
|
80
|
-
* project it references, lists the file; the first that does
|
|
79
|
+
* `tsconfig.json`, then the `jsconfig.json` beside it, is asked whether its
|
|
80
|
+
* program, or a project it references, lists the file; the first that does
|
|
81
|
+
* types it (a
|
|
81
82
|
* solution config hands the file to the reference that lists it). A config
|
|
82
83
|
* that lists the file nowhere is passed over. The climb stops after a
|
|
83
84
|
* directory named `node_modules`, as tsserver's does. A file no config inside
|
|
@@ -93,7 +94,7 @@ export class GoverningConfigs {
|
|
|
93
94
|
serviceConfig;
|
|
94
95
|
report;
|
|
95
96
|
root;
|
|
96
|
-
/** Directory -> the
|
|
97
|
+
/** Directory -> the configs in it, in order, for every directory a climb visited. */
|
|
97
98
|
dirConfigs = new Map();
|
|
98
99
|
/** Config -> its projects; undefined for one that cannot be read. */
|
|
99
100
|
graphs = new Map();
|
|
@@ -115,10 +116,11 @@ export class GoverningConfigs {
|
|
|
115
116
|
const from = path.relative(this.root, dir);
|
|
116
117
|
if (from.startsWith('..') || path.isAbsolute(from))
|
|
117
118
|
break;
|
|
118
|
-
const config
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
for (const config of this.configsIn(dir)) {
|
|
120
|
+
const owner = this.listingOwner(config, absolute);
|
|
121
|
+
if (owner !== undefined)
|
|
122
|
+
return owner;
|
|
123
|
+
}
|
|
122
124
|
// tsserver looks in a `node_modules` directory itself, then stops.
|
|
123
125
|
if (dir === this.root || path.basename(dir) === 'node_modules')
|
|
124
126
|
break;
|
|
@@ -128,12 +130,13 @@ export class GoverningConfigs {
|
|
|
128
130
|
return undefined;
|
|
129
131
|
return this.listingOwner(this.serviceConfig, absolute) ?? this.serviceConfig;
|
|
130
132
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
configsIn(dir) {
|
|
134
|
+
let configs = this.dirConfigs.get(dir);
|
|
135
|
+
if (configs === undefined) {
|
|
136
|
+
configs = FILE_CONFIG_NAMES.map((n) => path.join(dir, n)).filter((c) => fs.existsSync(c));
|
|
137
|
+
this.dirConfigs.set(dir, configs);
|
|
135
138
|
}
|
|
136
|
-
return
|
|
139
|
+
return configs;
|
|
137
140
|
}
|
|
138
141
|
/** The project reached from `config` that lists `file`, absolute. */
|
|
139
142
|
listingOwner(config, file) {
|
|
@@ -727,7 +727,10 @@ export class LibraryClaimsVerifier {
|
|
|
727
727
|
const builtAtDefaults = built === undefined ? undefined : atDefaults(check, built);
|
|
728
728
|
// An adapter's `runs` is read against the request's collections only
|
|
729
729
|
// when today's reading refuses it (#2474 R6a): `judgeMake` asks.
|
|
730
|
-
const collectionsOf = check.claim.kind === 'make' && check.claim.runs !== undefined
|
|
730
|
+
const collectionsOf = (check.claim.kind === 'make' && check.claim.runs !== undefined) ||
|
|
731
|
+
(check.claim.kind === 'scope' && check.claim.merges !== undefined)
|
|
732
|
+
? collections
|
|
733
|
+
: undefined;
|
|
731
734
|
const holding = [];
|
|
732
735
|
const declarations = [];
|
|
733
736
|
const members = [];
|
|
@@ -2118,7 +2121,7 @@ class DeclarationReader {
|
|
|
2118
2121
|
case 'make':
|
|
2119
2122
|
return this.judgeMake(receiver, claim, built, collections);
|
|
2120
2123
|
case 'scope':
|
|
2121
|
-
return this.judgeScope(receiver, claim, built);
|
|
2124
|
+
return this.judgeScope(receiver, claim, built, collections);
|
|
2122
2125
|
case 'op':
|
|
2123
2126
|
return { outcome: this.judgeOp(receiver, claim, rules) };
|
|
2124
2127
|
case 'reserved':
|
|
@@ -2230,19 +2233,33 @@ class DeclarationReader {
|
|
|
2230
2233
|
* beside `runs`, `yields` or `mounts` (`claim_invalid`). With `collects`
|
|
2231
2234
|
* the member takes an object of procedures there (`collectsOutcome`), and
|
|
2232
2235
|
* its return, the collection, is read as a plain scope's is.
|
|
2236
|
+
*
|
|
2237
|
+
* Merged collections (amendment 9): `merges` is a third way to carry the
|
|
2238
|
+
* scope, alone and as `{ arg, each: true }`. The member's parameter at
|
|
2239
|
+
* `arg`, read through a rest (`parameterAt`), takes what a verified
|
|
2240
|
+
* `collects` scope of the request returns (`collectionSlotOutcome`), and
|
|
2241
|
+
* the return is read as a plain scope's is.
|
|
2233
2242
|
*/
|
|
2234
|
-
judgeScope(receiver, claim, built) {
|
|
2243
|
+
judgeScope(receiver, claim, built, collections) {
|
|
2235
2244
|
if (claim.form === 'decorate')
|
|
2236
2245
|
return { outcome: this.decorateScopeOutcome(receiver, claim) };
|
|
2237
2246
|
if ((claim.runs === undefined) !== (claim.yields === undefined))
|
|
2238
2247
|
return { outcome: unchecked('claim_invalid') };
|
|
2239
2248
|
if (claim.mounts !== undefined && claim.runs !== undefined)
|
|
2240
2249
|
return { outcome: unchecked('claim_invalid') };
|
|
2241
|
-
|
|
2250
|
+
const carried = [claim.name, claim.collects, claim.merges].filter(part => part !== undefined).length;
|
|
2251
|
+
if (carried !== 1)
|
|
2242
2252
|
return { outcome: unchecked('claim_invalid') };
|
|
2243
|
-
if (claim.collects !== undefined
|
|
2253
|
+
if ((claim.collects !== undefined || claim.merges !== undefined) &&
|
|
2254
|
+
(claim.runs !== undefined || claim.mounts !== undefined)) {
|
|
2244
2255
|
return { outcome: unchecked('claim_invalid') };
|
|
2245
2256
|
}
|
|
2257
|
+
const merges = claim.merges;
|
|
2258
|
+
if (merges !== undefined &&
|
|
2259
|
+
(merges.each !== true || merges.key !== undefined || merges.at !== undefined)) {
|
|
2260
|
+
return { outcome: unchecked('claim_invalid') };
|
|
2261
|
+
}
|
|
2262
|
+
const collected = merges === undefined ? undefined : collections?.();
|
|
2246
2263
|
const binds = claim.runs !== undefined || claim.mounts !== undefined;
|
|
2247
2264
|
const layout = this.layout({ name: claim.name, runs: claim.runs, mounts: claim.mounts });
|
|
2248
2265
|
if ('failure' in layout)
|
|
@@ -2250,6 +2267,8 @@ class DeclarationReader {
|
|
|
2250
2267
|
const callee = this.ownCallee(receiver, claim.path ?? [], claim.member, 'call');
|
|
2251
2268
|
if ('failure' in callee)
|
|
2252
2269
|
return { outcome: callee.failure };
|
|
2270
|
+
if (merges !== undefined && collected === undefined)
|
|
2271
|
+
return { outcome: failed('merges_unbound') };
|
|
2253
2272
|
const labels = claim.key_labels ?? {};
|
|
2254
2273
|
const holding = [];
|
|
2255
2274
|
let best;
|
|
@@ -2270,6 +2289,12 @@ class DeclarationReader {
|
|
|
2270
2289
|
if (collected)
|
|
2271
2290
|
result = { rank: 5, outcome: collected };
|
|
2272
2291
|
}
|
|
2292
|
+
if (result.rank === Infinity && merges !== undefined && collected !== undefined) {
|
|
2293
|
+
const merged = this.mergesNotRest(signature, merges.arg) ??
|
|
2294
|
+
this.collectionSlotOutcome(signature, this.mergedSlotAt(signature, merges.arg), collected, 'merges');
|
|
2295
|
+
if (merged)
|
|
2296
|
+
result = { rank: 5, outcome: merged };
|
|
2297
|
+
}
|
|
2273
2298
|
if (result.rank === Infinity && !binds && this.returnSaysNothing(this.returnOf(signature, built))) {
|
|
2274
2299
|
result = { rank: 6, outcome: unchecked('scope_unresolved') };
|
|
2275
2300
|
}
|
|
@@ -2348,22 +2373,57 @@ class DeclarationReader {
|
|
|
2348
2373
|
}
|
|
2349
2374
|
/**
|
|
2350
2375
|
* An adapter's `runs` slot (#2474 R6a) takes one of `collections`, the
|
|
2351
|
-
* types the request's verified `collects` scopes return
|
|
2352
|
-
* instance is (`fitsErased`, then assignability). A slot typed `any`,
|
|
2353
|
-
* `unknown`, `{}` or by an unconstrained type parameter says nothing
|
|
2354
|
-
* (`runs_untyped`). Undefined when it holds.
|
|
2376
|
+
* types the request's verified `collects` scopes return.
|
|
2355
2377
|
*/
|
|
2356
2378
|
runsCollectionOutcome(signature, declared, collections) {
|
|
2379
|
+
return this.collectionSlotOutcome(signature, declared, collections, 'runs');
|
|
2380
|
+
}
|
|
2381
|
+
/** A merge's slot at `index` must be a rest parameter (or an element of one): a plain parameter fails `merges_not_rest`. */
|
|
2382
|
+
mergesNotRest(signature, index) {
|
|
2383
|
+
const restIndex = this.restIndexOf(signature);
|
|
2384
|
+
const plain = restIndex === -1 || index < restIndex;
|
|
2385
|
+
return plain && index < signature.getParameters().length ? failed('merges_not_rest') : undefined;
|
|
2386
|
+
}
|
|
2387
|
+
/**
|
|
2388
|
+
* What a merge's rest slot takes at `index` (amendment 9): the element
|
|
2389
|
+
* `parameterAt` reads, and when that is itself a type parameter spread into
|
|
2390
|
+
* the rest (`...routers: [...R]` with `R extends Router[]`), its
|
|
2391
|
+
* constraint's element. Only that spread is unwrapped: a parameter that
|
|
2392
|
+
* takes an array of routers (`routers: Router[]`, `...lists: Router[][]`)
|
|
2393
|
+
* is a merge over an array, which amendment 9 leaves out.
|
|
2394
|
+
*/
|
|
2395
|
+
mergedSlotAt(signature, index) {
|
|
2396
|
+
const slot = this.parameterAt(signature, index, true);
|
|
2397
|
+
if (slot === undefined || slot === VARIADIC)
|
|
2398
|
+
return slot;
|
|
2399
|
+
const restIndex = this.restIndexOf(signature);
|
|
2400
|
+
if (restIndex === -1 || index < restIndex || !(slot.flags & ts.TypeFlags.TypeParameter))
|
|
2401
|
+
return slot;
|
|
2402
|
+
const through = this.throughConstraint(slot);
|
|
2403
|
+
if (through !== VARIADIC && this.checker.isArrayType(through)) {
|
|
2404
|
+
return this.checker.getTypeArguments(through)[0];
|
|
2405
|
+
}
|
|
2406
|
+
return slot;
|
|
2407
|
+
}
|
|
2408
|
+
/**
|
|
2409
|
+
* A slot that takes one of `collections`, read as a mounted instance is
|
|
2410
|
+
* (`fitsErased`, then assignability): an adapter's `runs` slot and a merge's
|
|
2411
|
+
* rest slot (amendment 9). A slot typed `any`, `unknown`, `{}` or by an
|
|
2412
|
+
* unconstrained type parameter says nothing (`<reason>_untyped`); one that
|
|
2413
|
+
* takes none of them fails (`<reason>_not_collection`). Undefined when it
|
|
2414
|
+
* holds.
|
|
2415
|
+
*/
|
|
2416
|
+
collectionSlotOutcome(signature, declared, collections, reason) {
|
|
2357
2417
|
if (declared === undefined)
|
|
2358
2418
|
return failed('param_missing');
|
|
2359
2419
|
const slot = this.throughConstraint(declared);
|
|
2360
2420
|
if (slot === VARIADIC)
|
|
2361
|
-
return unchecked(
|
|
2421
|
+
return unchecked(`${reason}_untyped`);
|
|
2362
2422
|
const parts = this.parts(slot);
|
|
2363
2423
|
if (parts.length === 0)
|
|
2364
|
-
return failed(
|
|
2424
|
+
return failed(`${reason}_not_collection`);
|
|
2365
2425
|
if (parts.some(part => this.isOpenTop(part) || this.isUnconstrained(part) || this.isEmptyObject(part))) {
|
|
2366
|
-
return unchecked(
|
|
2426
|
+
return unchecked(`${reason}_untyped`);
|
|
2367
2427
|
}
|
|
2368
2428
|
const own = signature.typeParameters ?? [];
|
|
2369
2429
|
for (const collection of collections) {
|
|
@@ -2373,7 +2433,7 @@ class DeclarationReader {
|
|
|
2373
2433
|
if (erased === undefined && this.checker.isTypeAssignableTo(collection, slot))
|
|
2374
2434
|
return undefined;
|
|
2375
2435
|
}
|
|
2376
|
-
return failed(
|
|
2436
|
+
return failed(`${reason}_not_collection`);
|
|
2377
2437
|
}
|
|
2378
2438
|
/**
|
|
2379
2439
|
* `receiver` fits `slot` with the signature's own type parameters
|
|
@@ -2864,6 +2924,7 @@ class DeclarationReader {
|
|
|
2864
2924
|
decorateScopeOutcome(receiver, claim) {
|
|
2865
2925
|
if (claim.name === undefined ||
|
|
2866
2926
|
claim.collects !== undefined ||
|
|
2927
|
+
claim.merges !== undefined ||
|
|
2867
2928
|
claim.runs !== undefined ||
|
|
2868
2929
|
claim.yields !== undefined ||
|
|
2869
2930
|
claim.mounts !== undefined) {
|
|
@@ -5600,6 +5661,12 @@ class DeclarationReader {
|
|
|
5600
5661
|
parts(type) {
|
|
5601
5662
|
return (type.isUnion() ? type.types : [type]).filter(part => !isNullish(part));
|
|
5602
5663
|
}
|
|
5664
|
+
/** The index of the signature's rest parameter, or -1 when it has none. */
|
|
5665
|
+
restIndexOf(signature) {
|
|
5666
|
+
const parameters = signature.getParameters();
|
|
5667
|
+
const declaration = parameters[parameters.length - 1]?.valueDeclaration;
|
|
5668
|
+
return declaration && ts.isParameter(declaration) && declaration.dotDotDotToken ? parameters.length - 1 : -1;
|
|
5669
|
+
}
|
|
5603
5670
|
/**
|
|
5604
5671
|
* What the signature has at parameter `index`, reading through a rest
|
|
5605
5672
|
* parameter; `undefined` when it has none there. A rest typed by a type
|
|
@@ -5609,10 +5676,7 @@ class DeclarationReader {
|
|
|
5609
5676
|
parameterAt(signature, index, readConstraint = false) {
|
|
5610
5677
|
const parameters = signature.getParameters();
|
|
5611
5678
|
const last = parameters[parameters.length - 1];
|
|
5612
|
-
const
|
|
5613
|
-
const restIndex = declaration && ts.isParameter(declaration) && declaration.dotDotDotToken
|
|
5614
|
-
? parameters.length - 1
|
|
5615
|
-
: -1;
|
|
5679
|
+
const restIndex = this.restIndexOf(signature);
|
|
5616
5680
|
if (restIndex === -1 || index < restIndex) {
|
|
5617
5681
|
return index < parameters.length ? this.checker.getTypeOfSymbol(parameters[index]) : undefined;
|
|
5618
5682
|
}
|
|
@@ -876,11 +876,29 @@ export class PositionWalker {
|
|
|
876
876
|
exportName = key ? key.text : declaration.name.text;
|
|
877
877
|
initializer = declaration.parent.parent.initializer;
|
|
878
878
|
}
|
|
879
|
+
let castSpecifier;
|
|
880
|
+
while (initializer &&
|
|
881
|
+
(ts.isParenthesizedExpression(initializer) ||
|
|
882
|
+
ts.isAsExpression(initializer) ||
|
|
883
|
+
ts.isSatisfiesExpression(initializer) ||
|
|
884
|
+
ts.isTypeAssertionExpression(initializer) ||
|
|
885
|
+
ts.isNonNullExpression(initializer))) {
|
|
886
|
+
const type = ts.isNonNullExpression(initializer) || ts.isParenthesizedExpression(initializer) ? undefined : initializer.type;
|
|
887
|
+
if (castSpecifier === undefined && type && ts.isImportTypeNode(type) && type.isTypeOf) {
|
|
888
|
+
const arg = type.argument;
|
|
889
|
+
if (ts.isLiteralTypeNode(arg) && ts.isStringLiteral(arg.literal))
|
|
890
|
+
castSpecifier = arg.literal.text;
|
|
891
|
+
}
|
|
892
|
+
initializer = initializer.expression;
|
|
893
|
+
}
|
|
879
894
|
const specifier = initializer ? this.requireSpecifier(initializer) : undefined;
|
|
880
895
|
if (specifier === undefined)
|
|
881
896
|
return undefined;
|
|
882
897
|
const from = declaration.getSourceFile();
|
|
883
|
-
|
|
898
|
+
const binding = exportName === undefined ? { specifier, from } : { specifier, from, exportName };
|
|
899
|
+
if (castSpecifier !== undefined)
|
|
900
|
+
binding.castSpecifier = castSpecifier;
|
|
901
|
+
return binding;
|
|
884
902
|
}
|
|
885
903
|
/** `"m"` of a call `require("m")` to the global `require`, else `undefined`. */
|
|
886
904
|
requireSpecifier(expression) {
|
|
@@ -896,8 +914,12 @@ export class PositionWalker {
|
|
|
896
914
|
return own ? undefined : argument.text;
|
|
897
915
|
}
|
|
898
916
|
exportOfRequired(binding) {
|
|
899
|
-
const
|
|
900
|
-
|
|
917
|
+
const sourceOf = (specifier) => {
|
|
918
|
+
const resolved = ts.resolveModuleName(specifier, binding.from.fileName, this.program.getCompilerOptions(), this.resolutionHost(), undefined, undefined, ts.ModuleKind.CommonJS).resolvedModule;
|
|
919
|
+
return resolved ? this.program.getSourceFile(resolved.resolvedFileName) : undefined;
|
|
920
|
+
};
|
|
921
|
+
// The require that runs wins; the cast is read only when it names no file.
|
|
922
|
+
const target = sourceOf(binding.specifier) ?? (binding.castSpecifier !== undefined ? sourceOf(binding.castSpecifier) : undefined);
|
|
901
923
|
if (!target)
|
|
902
924
|
return undefined;
|
|
903
925
|
if (binding.exportName === undefined)
|
|
@@ -697,7 +697,7 @@ export type LibraryClaim = {
|
|
|
697
697
|
member: string;
|
|
698
698
|
/** Amendment 7: absent is `call`; `decorate` is a class decorator whose name prefixes its methods' ops. */
|
|
699
699
|
form?: 'call' | 'decorate';
|
|
700
|
-
/** Exactly one of `name` and `
|
|
700
|
+
/** Exactly one of `name`, `collects` and `merges` (#2474 R6a). */
|
|
701
701
|
name?: NameSlot;
|
|
702
702
|
path?: string[];
|
|
703
703
|
on?: ClaimOn;
|
|
@@ -716,6 +716,13 @@ export type LibraryClaim = {
|
|
|
716
716
|
mounts?: ClaimSlot;
|
|
717
717
|
/** Procedure routers (#2474 R6a): the member collects procedures by key and returns the collection. */
|
|
718
718
|
collects?: Collects;
|
|
719
|
+
/**
|
|
720
|
+
* Merged collections (amendment 9 on carrick#2434): the member takes
|
|
721
|
+
* the collections a verified `collects` member returns at `arg` and at
|
|
722
|
+
* every argument after it (`each: true`), and returns one collection
|
|
723
|
+
* serving all their procedures at the same level.
|
|
724
|
+
*/
|
|
725
|
+
merges?: ClaimSlot;
|
|
719
726
|
} | {
|
|
720
727
|
kind: 'op';
|
|
721
728
|
op: LibraryOp;
|
|
@@ -1963,6 +1963,22 @@ export declare const VerifyLibraryClaimsRequestSchema: z.ZodObject<{
|
|
|
1963
1963
|
arg: number;
|
|
1964
1964
|
key?: string | undefined;
|
|
1965
1965
|
}>>;
|
|
1966
|
+
merges: z.ZodOptional<z.ZodObject<{
|
|
1967
|
+
arg: z.ZodNumber;
|
|
1968
|
+
key: z.ZodOptional<z.ZodString>;
|
|
1969
|
+
at: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1970
|
+
each: z.ZodOptional<z.ZodBoolean>;
|
|
1971
|
+
}, "strict", z.ZodTypeAny, {
|
|
1972
|
+
arg: number;
|
|
1973
|
+
at?: string[] | undefined;
|
|
1974
|
+
key?: string | undefined;
|
|
1975
|
+
each?: boolean | undefined;
|
|
1976
|
+
}, {
|
|
1977
|
+
arg: number;
|
|
1978
|
+
at?: string[] | undefined;
|
|
1979
|
+
key?: string | undefined;
|
|
1980
|
+
each?: boolean | undefined;
|
|
1981
|
+
}>>;
|
|
1966
1982
|
}, "strict", z.ZodTypeAny, {
|
|
1967
1983
|
kind: "scope";
|
|
1968
1984
|
member: string;
|
|
@@ -2001,6 +2017,12 @@ export declare const VerifyLibraryClaimsRequestSchema: z.ZodObject<{
|
|
|
2001
2017
|
key?: string | undefined;
|
|
2002
2018
|
each?: boolean | undefined;
|
|
2003
2019
|
} | undefined;
|
|
2020
|
+
merges?: {
|
|
2021
|
+
arg: number;
|
|
2022
|
+
at?: string[] | undefined;
|
|
2023
|
+
key?: string | undefined;
|
|
2024
|
+
each?: boolean | undefined;
|
|
2025
|
+
} | undefined;
|
|
2004
2026
|
picker?: string | undefined;
|
|
2005
2027
|
collects?: {
|
|
2006
2028
|
join: string;
|
|
@@ -2045,6 +2067,12 @@ export declare const VerifyLibraryClaimsRequestSchema: z.ZodObject<{
|
|
|
2045
2067
|
key?: string | undefined;
|
|
2046
2068
|
each?: boolean | undefined;
|
|
2047
2069
|
} | undefined;
|
|
2070
|
+
merges?: {
|
|
2071
|
+
arg: number;
|
|
2072
|
+
at?: string[] | undefined;
|
|
2073
|
+
key?: string | undefined;
|
|
2074
|
+
each?: boolean | undefined;
|
|
2075
|
+
} | undefined;
|
|
2048
2076
|
picker?: string | undefined;
|
|
2049
2077
|
collects?: {
|
|
2050
2078
|
join: string;
|
|
@@ -2814,6 +2842,12 @@ export declare const VerifyLibraryClaimsRequestSchema: z.ZodObject<{
|
|
|
2814
2842
|
key?: string | undefined;
|
|
2815
2843
|
each?: boolean | undefined;
|
|
2816
2844
|
} | undefined;
|
|
2845
|
+
merges?: {
|
|
2846
|
+
arg: number;
|
|
2847
|
+
at?: string[] | undefined;
|
|
2848
|
+
key?: string | undefined;
|
|
2849
|
+
each?: boolean | undefined;
|
|
2850
|
+
} | undefined;
|
|
2817
2851
|
picker?: string | undefined;
|
|
2818
2852
|
collects?: {
|
|
2819
2853
|
join: string;
|
|
@@ -3059,6 +3093,12 @@ export declare const VerifyLibraryClaimsRequestSchema: z.ZodObject<{
|
|
|
3059
3093
|
key?: string | undefined;
|
|
3060
3094
|
each?: boolean | undefined;
|
|
3061
3095
|
} | undefined;
|
|
3096
|
+
merges?: {
|
|
3097
|
+
arg: number;
|
|
3098
|
+
at?: string[] | undefined;
|
|
3099
|
+
key?: string | undefined;
|
|
3100
|
+
each?: boolean | undefined;
|
|
3101
|
+
} | undefined;
|
|
3062
3102
|
picker?: string | undefined;
|
|
3063
3103
|
collects?: {
|
|
3064
3104
|
join: string;
|
|
@@ -3310,6 +3350,12 @@ export declare const VerifyLibraryClaimsRequestSchema: z.ZodObject<{
|
|
|
3310
3350
|
key?: string | undefined;
|
|
3311
3351
|
each?: boolean | undefined;
|
|
3312
3352
|
} | undefined;
|
|
3353
|
+
merges?: {
|
|
3354
|
+
arg: number;
|
|
3355
|
+
at?: string[] | undefined;
|
|
3356
|
+
key?: string | undefined;
|
|
3357
|
+
each?: boolean | undefined;
|
|
3358
|
+
} | undefined;
|
|
3313
3359
|
picker?: string | undefined;
|
|
3314
3360
|
collects?: {
|
|
3315
3361
|
join: string;
|
|
@@ -3562,6 +3608,12 @@ export declare const VerifyLibraryClaimsRequestSchema: z.ZodObject<{
|
|
|
3562
3608
|
key?: string | undefined;
|
|
3563
3609
|
each?: boolean | undefined;
|
|
3564
3610
|
} | undefined;
|
|
3611
|
+
merges?: {
|
|
3612
|
+
arg: number;
|
|
3613
|
+
at?: string[] | undefined;
|
|
3614
|
+
key?: string | undefined;
|
|
3615
|
+
each?: boolean | undefined;
|
|
3616
|
+
} | undefined;
|
|
3565
3617
|
picker?: string | undefined;
|
|
3566
3618
|
collects?: {
|
|
3567
3619
|
join: string;
|
|
@@ -5322,6 +5374,22 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
5322
5374
|
arg: number;
|
|
5323
5375
|
key?: string | undefined;
|
|
5324
5376
|
}>>;
|
|
5377
|
+
merges: z.ZodOptional<z.ZodObject<{
|
|
5378
|
+
arg: z.ZodNumber;
|
|
5379
|
+
key: z.ZodOptional<z.ZodString>;
|
|
5380
|
+
at: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
5381
|
+
each: z.ZodOptional<z.ZodBoolean>;
|
|
5382
|
+
}, "strict", z.ZodTypeAny, {
|
|
5383
|
+
arg: number;
|
|
5384
|
+
at?: string[] | undefined;
|
|
5385
|
+
key?: string | undefined;
|
|
5386
|
+
each?: boolean | undefined;
|
|
5387
|
+
}, {
|
|
5388
|
+
arg: number;
|
|
5389
|
+
at?: string[] | undefined;
|
|
5390
|
+
key?: string | undefined;
|
|
5391
|
+
each?: boolean | undefined;
|
|
5392
|
+
}>>;
|
|
5325
5393
|
}, "strict", z.ZodTypeAny, {
|
|
5326
5394
|
kind: "scope";
|
|
5327
5395
|
member: string;
|
|
@@ -5360,6 +5428,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
5360
5428
|
key?: string | undefined;
|
|
5361
5429
|
each?: boolean | undefined;
|
|
5362
5430
|
} | undefined;
|
|
5431
|
+
merges?: {
|
|
5432
|
+
arg: number;
|
|
5433
|
+
at?: string[] | undefined;
|
|
5434
|
+
key?: string | undefined;
|
|
5435
|
+
each?: boolean | undefined;
|
|
5436
|
+
} | undefined;
|
|
5363
5437
|
picker?: string | undefined;
|
|
5364
5438
|
collects?: {
|
|
5365
5439
|
join: string;
|
|
@@ -5404,6 +5478,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
5404
5478
|
key?: string | undefined;
|
|
5405
5479
|
each?: boolean | undefined;
|
|
5406
5480
|
} | undefined;
|
|
5481
|
+
merges?: {
|
|
5482
|
+
arg: number;
|
|
5483
|
+
at?: string[] | undefined;
|
|
5484
|
+
key?: string | undefined;
|
|
5485
|
+
each?: boolean | undefined;
|
|
5486
|
+
} | undefined;
|
|
5407
5487
|
picker?: string | undefined;
|
|
5408
5488
|
collects?: {
|
|
5409
5489
|
join: string;
|
|
@@ -6173,6 +6253,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
6173
6253
|
key?: string | undefined;
|
|
6174
6254
|
each?: boolean | undefined;
|
|
6175
6255
|
} | undefined;
|
|
6256
|
+
merges?: {
|
|
6257
|
+
arg: number;
|
|
6258
|
+
at?: string[] | undefined;
|
|
6259
|
+
key?: string | undefined;
|
|
6260
|
+
each?: boolean | undefined;
|
|
6261
|
+
} | undefined;
|
|
6176
6262
|
picker?: string | undefined;
|
|
6177
6263
|
collects?: {
|
|
6178
6264
|
join: string;
|
|
@@ -6418,6 +6504,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
6418
6504
|
key?: string | undefined;
|
|
6419
6505
|
each?: boolean | undefined;
|
|
6420
6506
|
} | undefined;
|
|
6507
|
+
merges?: {
|
|
6508
|
+
arg: number;
|
|
6509
|
+
at?: string[] | undefined;
|
|
6510
|
+
key?: string | undefined;
|
|
6511
|
+
each?: boolean | undefined;
|
|
6512
|
+
} | undefined;
|
|
6421
6513
|
picker?: string | undefined;
|
|
6422
6514
|
collects?: {
|
|
6423
6515
|
join: string;
|
|
@@ -6669,6 +6761,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
6669
6761
|
key?: string | undefined;
|
|
6670
6762
|
each?: boolean | undefined;
|
|
6671
6763
|
} | undefined;
|
|
6764
|
+
merges?: {
|
|
6765
|
+
arg: number;
|
|
6766
|
+
at?: string[] | undefined;
|
|
6767
|
+
key?: string | undefined;
|
|
6768
|
+
each?: boolean | undefined;
|
|
6769
|
+
} | undefined;
|
|
6672
6770
|
picker?: string | undefined;
|
|
6673
6771
|
collects?: {
|
|
6674
6772
|
join: string;
|
|
@@ -6921,6 +7019,12 @@ export declare const SidecarRequestSchema: z.ZodDiscriminatedUnion<"action", [z.
|
|
|
6921
7019
|
key?: string | undefined;
|
|
6922
7020
|
each?: boolean | undefined;
|
|
6923
7021
|
} | undefined;
|
|
7022
|
+
merges?: {
|
|
7023
|
+
arg: number;
|
|
7024
|
+
at?: string[] | undefined;
|
|
7025
|
+
key?: string | undefined;
|
|
7026
|
+
each?: boolean | undefined;
|
|
7027
|
+
} | undefined;
|
|
6924
7028
|
picker?: string | undefined;
|
|
6925
7029
|
collects?: {
|
|
6926
7030
|
join: string;
|
|
@@ -542,7 +542,7 @@ const LibraryClaimSchema = z.discriminatedUnion('kind', [
|
|
|
542
542
|
kind: z.literal('scope'),
|
|
543
543
|
member: z.string().min(1),
|
|
544
544
|
form: z.enum(['call', 'decorate']).optional(),
|
|
545
|
-
// Exactly one of `name` and `
|
|
545
|
+
// Exactly one of `name`, `collects` and `merges`: the verifier's verdict (#2474 R6a).
|
|
546
546
|
name: NameSlotSchema.optional(),
|
|
547
547
|
path: MemberPathSchema.optional(),
|
|
548
548
|
on: ClaimOnSchema.optional(),
|
|
@@ -554,6 +554,8 @@ const LibraryClaimSchema = z.discriminatedUnion('kind', [
|
|
|
554
554
|
yields: YieldsSchema.optional(),
|
|
555
555
|
mounts: ClaimSlotSchema.optional(),
|
|
556
556
|
collects: CollectsSchema.optional(),
|
|
557
|
+
// Amendment 9: a rest slot of collections; the verifier's verdict pairs it.
|
|
558
|
+
merges: ClaimSlotSchema.optional(),
|
|
557
559
|
})
|
|
558
560
|
.strict(),
|
|
559
561
|
z
|