@orkestrel/guide 0.0.22 → 0.0.24
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/src/core/index.cjs +58 -15
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +32 -15
- package/dist/src/core/index.d.ts +32 -15
- package/dist/src/core/index.js +58 -15
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +58 -15
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +11 -7
- package/dist/src/server/index.d.ts +11 -7
- package/dist/src/server/index.js +58 -15
- package/dist/src/server/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -575,13 +575,17 @@ declare interface SourceInterface {
|
|
|
575
575
|
* block's description paragraph. The first file declaring the name answers for it.
|
|
576
576
|
*
|
|
577
577
|
* @remarks
|
|
578
|
-
* One declaration answers
|
|
579
|
-
* sorted key order and the first one whose located head has a body
|
|
580
|
-
* bases supplies both the members and the bases, so a second file
|
|
581
|
-
* declaring the same name adds nothing; a head with
|
|
582
|
-
* bases does not count as declared, so an empty
|
|
583
|
-
* is skipped and resolution continues to a later
|
|
584
|
-
*
|
|
578
|
+
* One declaration answers under each keyword: the module scope's files are
|
|
579
|
+
* read in sorted key order and the first one whose located head has a body
|
|
580
|
+
* or has bases supplies both the members and the bases, so a second file
|
|
581
|
+
* declaring the same name under that keyword adds nothing; a head with
|
|
582
|
+
* neither a body nor bases does not count as declared, so an empty
|
|
583
|
+
* `export interface X {}` is skipped and resolution continues to a later
|
|
584
|
+
* file. The interface answers for `name`, and the class answers when no
|
|
585
|
+
* interface declares it. Where one file declares `name` as both an
|
|
586
|
+
* interface and a class, which TypeScript merges into one type, both
|
|
587
|
+
* answer: each shape's own members come ahead of inherited ones, the
|
|
588
|
+
* interface's own first. Resolution reads each head's `extends` clause and follows it
|
|
585
589
|
* through this same module scope, keeping the keyword it started from: an
|
|
586
590
|
* `interface` chain resolves through interfaces and a `class` chain through
|
|
587
591
|
* classes, so a class's `implements` clause is outside the walk. A base the
|
|
@@ -575,13 +575,17 @@ declare interface SourceInterface {
|
|
|
575
575
|
* block's description paragraph. The first file declaring the name answers for it.
|
|
576
576
|
*
|
|
577
577
|
* @remarks
|
|
578
|
-
* One declaration answers
|
|
579
|
-
* sorted key order and the first one whose located head has a body
|
|
580
|
-
* bases supplies both the members and the bases, so a second file
|
|
581
|
-
* declaring the same name adds nothing; a head with
|
|
582
|
-
* bases does not count as declared, so an empty
|
|
583
|
-
* is skipped and resolution continues to a later
|
|
584
|
-
*
|
|
578
|
+
* One declaration answers under each keyword: the module scope's files are
|
|
579
|
+
* read in sorted key order and the first one whose located head has a body
|
|
580
|
+
* or has bases supplies both the members and the bases, so a second file
|
|
581
|
+
* declaring the same name under that keyword adds nothing; a head with
|
|
582
|
+
* neither a body nor bases does not count as declared, so an empty
|
|
583
|
+
* `export interface X {}` is skipped and resolution continues to a later
|
|
584
|
+
* file. The interface answers for `name`, and the class answers when no
|
|
585
|
+
* interface declares it. Where one file declares `name` as both an
|
|
586
|
+
* interface and a class, which TypeScript merges into one type, both
|
|
587
|
+
* answer: each shape's own members come ahead of inherited ones, the
|
|
588
|
+
* interface's own first. Resolution reads each head's `extends` clause and follows it
|
|
585
589
|
* through this same module scope, keeping the keyword it started from: an
|
|
586
590
|
* `interface` chain resolves through interfaces and a `class` chain through
|
|
587
591
|
* classes, so a class's `implements` clause is outside the walk. A base the
|
package/dist/src/server/index.js
CHANGED
|
@@ -1287,7 +1287,14 @@ function extractHidden(source) {
|
|
|
1287
1287
|
}
|
|
1288
1288
|
/**
|
|
1289
1289
|
* Joins the declaration head starting at `start` into one space-separated
|
|
1290
|
-
* line, consuming lines until the first that ends with
|
|
1290
|
+
* line, consuming lines until the first that opens a body: one that ends with
|
|
1291
|
+
* `{`, or one that closes an empty body with `{}` or `{ }`.
|
|
1292
|
+
*
|
|
1293
|
+
* @remarks
|
|
1294
|
+
* A line ending with `{}` closes an empty body only when every angle, round,
|
|
1295
|
+
* and square bracket the head opened outside quoted text has closed; inside
|
|
1296
|
+
* one, `{}` is a type or an argument, and an arrow's `=>` closes nothing. A
|
|
1297
|
+
* head that reaches the next column-zero `export` line opens no body.
|
|
1291
1298
|
*
|
|
1292
1299
|
* @param lines - The file's source lines
|
|
1293
1300
|
* @param start - The index of the head's first line
|
|
@@ -1296,6 +1303,7 @@ function extractHidden(source) {
|
|
|
1296
1303
|
* @example
|
|
1297
1304
|
* ```ts
|
|
1298
1305
|
* joinHead(['export class X {'], 0) // { text: 'export class X {', end: 0 }
|
|
1306
|
+
* joinHead(['export interface Y extends X {}'], 0) // { text: 'export interface Y extends X {}', end: 0 }
|
|
1299
1307
|
* ```
|
|
1300
1308
|
*/
|
|
1301
1309
|
function joinHead(lines, start) {
|
|
@@ -1303,8 +1311,15 @@ function joinHead(lines, start) {
|
|
|
1303
1311
|
for (let index = start; index < lines.length; index += 1) {
|
|
1304
1312
|
const line = lines[index];
|
|
1305
1313
|
if (line === void 0) break;
|
|
1306
|
-
|
|
1307
|
-
if (
|
|
1314
|
+
const text = line.trimEnd();
|
|
1315
|
+
if (index > start && text.startsWith("export ")) return void 0;
|
|
1316
|
+
parts.push(index === start ? text : text.trimStart());
|
|
1317
|
+
if (text.endsWith("{")) return {
|
|
1318
|
+
text: parts.join(" "),
|
|
1319
|
+
end: index
|
|
1320
|
+
};
|
|
1321
|
+
const bare = parts.join(" ").replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, "");
|
|
1322
|
+
if ((bare.match(/</g)?.length ?? 0) <= (bare.match(/(?<!=)>/g)?.length ?? 0) && (bare.match(/\(/g)?.length ?? 0) <= (bare.match(/\)/g)?.length ?? 0) && (bare.match(/\[/g)?.length ?? 0) <= (bare.match(/\]/g)?.length ?? 0) && /\{\s*\}$/.test(text)) return {
|
|
1308
1323
|
text: parts.join(" "),
|
|
1309
1324
|
end: index
|
|
1310
1325
|
};
|
|
@@ -1345,12 +1360,14 @@ function escapeRegExp(value) {
|
|
|
1345
1360
|
* optional heritage clause between the identifier and the opening `{`; the identifier is the head's
|
|
1346
1361
|
* own run up to that list or clause, so it enters the key as literal text and no name reaches a
|
|
1347
1362
|
* `RegExp`. Body lines are the raw source between the head and the first projected column-zero `}`,
|
|
1348
|
-
* keeping JSDoc evidence intact
|
|
1363
|
+
* keeping JSDoc evidence intact; a head whose last line closes its own body with `{}` or `{ }`
|
|
1364
|
+
* records an empty body. Every balanced `<...>` span is removed from the head before its
|
|
1349
1365
|
* `extends` clause is read, so a `T extends Base` type parameter is never a base and `Base<T>`
|
|
1350
1366
|
* reads as `Base`; a class's `implements` clause and everything after it is excluded, and a
|
|
1351
1367
|
* qualified base such as `namespace.Base` is returned verbatim. The first head of a key that opens
|
|
1352
1368
|
* a column-zero close answers for that key: a head that opens none records nothing, and a later
|
|
1353
|
-
* head of a key already collected adds nothing
|
|
1369
|
+
* head of a key already collected adds nothing unless the earlier head recorded neither a body
|
|
1370
|
+
* nor bases, which declares nothing as {@link Source} reads it, so the later head replaces it.
|
|
1354
1371
|
*
|
|
1355
1372
|
* @param source - The file's source text to read
|
|
1356
1373
|
* @returns One entry per collected declaration, keyed `${keyword} ${name}`
|
|
@@ -1364,7 +1381,7 @@ function escapeRegExp(value) {
|
|
|
1364
1381
|
function collectDeclarations(source) {
|
|
1365
1382
|
const declarations = /* @__PURE__ */ new Map();
|
|
1366
1383
|
const opener = /^export (?:class|interface) /;
|
|
1367
|
-
const grammar = /^export (class|interface) ([^\s<]+)(?:<.*>)?(?: .*)? \{
|
|
1384
|
+
const grammar = /^export (class|interface) ([^\s<]+)(?:<.*>)?(?: .*)? \{(?:\s*\})?$/;
|
|
1368
1385
|
const lines = extractSourceLines(source);
|
|
1369
1386
|
const projected = lines.map((line) => line.code);
|
|
1370
1387
|
for (let index = 0; index < projected.length; index += 1) {
|
|
@@ -1377,14 +1394,22 @@ function collectDeclarations(source) {
|
|
|
1377
1394
|
const name = declared?.[2];
|
|
1378
1395
|
if (keyword === void 0 || name === void 0) continue;
|
|
1379
1396
|
const key = `${keyword} ${name}`;
|
|
1380
|
-
|
|
1397
|
+
const known = declarations.get(key);
|
|
1398
|
+
if (known !== void 0 && (known.body.length > 0 || known.bases.length > 0)) continue;
|
|
1381
1399
|
let depth = 0;
|
|
1382
1400
|
let flat = "";
|
|
1383
|
-
for (const character of head.text.slice(`export ${key}`.length,
|
|
1401
|
+
for (const character of head.text.slice(`export ${key}`.length, head.text.lastIndexOf("{"))) if (character === "<") depth += 1;
|
|
1384
1402
|
else if (character === ">") depth = Math.max(0, depth - 1);
|
|
1385
1403
|
else if (depth === 0) flat += character;
|
|
1386
1404
|
const clause = flat.replace(/\bimplements\b[\s\S]*$/, "").match(/\bextends\b([\s\S]*)$/)?.[1];
|
|
1387
1405
|
const bases = clause === void 0 ? [] : clause.split(",").map((base) => base.trim()).filter(isNonEmptyString);
|
|
1406
|
+
if (head.text.endsWith("}")) {
|
|
1407
|
+
declarations.set(key, {
|
|
1408
|
+
body: [],
|
|
1409
|
+
bases
|
|
1410
|
+
});
|
|
1411
|
+
continue;
|
|
1412
|
+
}
|
|
1388
1413
|
for (let close = head.end + 1; close < projected.length; close += 1) {
|
|
1389
1414
|
if (projected[close] !== "}") continue;
|
|
1390
1415
|
declarations.set(key, {
|
|
@@ -2937,9 +2962,12 @@ var Guide = class {
|
|
|
2937
2962
|
* remain valid. `methods` resolves a declaration's members through its
|
|
2938
2963
|
* `extends` chain within the same module scope, keeping the keyword it started
|
|
2939
2964
|
* from; a base the scope does not declare contributes nothing. One declaration
|
|
2940
|
-
* answers
|
|
2941
|
-
* supplies its members and its bases, and a second file declaring the
|
|
2942
|
-
* adds nothing.
|
|
2965
|
+
* answers under each keyword: the first file in sorted key order that declares
|
|
2966
|
+
* the head supplies its members and its bases, and a second file declaring the
|
|
2967
|
+
* same name under that keyword adds nothing. The interface answers for a name,
|
|
2968
|
+
* and the class when no interface declares it; one file declaring the name as
|
|
2969
|
+
* both shapes, a TypeScript declaration merge, answers with both, own members
|
|
2970
|
+
* ahead of inherited ones and the interface's own first. Every reading derives once per instance from the immutable
|
|
2943
2971
|
* inventory and is reused — the scope's declaration map on the first `methods`
|
|
2944
2972
|
* or `examples` lookup, then each name's members and each example collection
|
|
2945
2973
|
* under the name asked for — so a reader asking twice reads the files once and
|
|
@@ -2979,6 +3007,7 @@ var Source = class {
|
|
|
2979
3007
|
#surface;
|
|
2980
3008
|
#hidden;
|
|
2981
3009
|
#declarations;
|
|
3010
|
+
#origins = /* @__PURE__ */ new Map();
|
|
2982
3011
|
constructor(options) {
|
|
2983
3012
|
this.#files = options.files;
|
|
2984
3013
|
this.#directories = normalizeDirectories(options.module);
|
|
@@ -3013,10 +3042,18 @@ var Source = class {
|
|
|
3013
3042
|
return examples;
|
|
3014
3043
|
}
|
|
3015
3044
|
#scanMethods(name) {
|
|
3016
|
-
const
|
|
3017
|
-
|
|
3018
|
-
const
|
|
3019
|
-
|
|
3045
|
+
const fromInterface = this.#members("interface", name, /* @__PURE__ */ new Set());
|
|
3046
|
+
const fromClass = this.#members("class", name, /* @__PURE__ */ new Set())?.filter((entry) => entry.name !== "constructor");
|
|
3047
|
+
const origin = this.#origin("interface", name);
|
|
3048
|
+
if (origin === void 0 || origin !== this.#origin("class", name)) return fromInterface ?? fromClass ?? [];
|
|
3049
|
+
const methods = /* @__PURE__ */ new Map();
|
|
3050
|
+
for (const entry of [
|
|
3051
|
+
...extractMemberMethods(this.#locate("interface", name)?.body ?? []),
|
|
3052
|
+
...extractMemberMethods(this.#locate("class", name)?.body ?? []),
|
|
3053
|
+
...fromInterface ?? [],
|
|
3054
|
+
...fromClass ?? []
|
|
3055
|
+
]) if (entry.name !== "constructor" && !methods.has(entry.name)) methods.set(entry.name, entry);
|
|
3056
|
+
return Array.from(methods.values()).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1);
|
|
3020
3057
|
}
|
|
3021
3058
|
#scanExamples() {
|
|
3022
3059
|
const examples = [];
|
|
@@ -3106,6 +3143,9 @@ var Source = class {
|
|
|
3106
3143
|
if (this.#declarations === void 0) this.#declarations = this.#scanDeclarations();
|
|
3107
3144
|
return this.#declarations.get(`${keyword} ${name}`);
|
|
3108
3145
|
}
|
|
3146
|
+
#origin(keyword, name) {
|
|
3147
|
+
return this.#locate(keyword, name) === void 0 ? void 0 : this.#origins.get(`${keyword} ${name}`);
|
|
3148
|
+
}
|
|
3109
3149
|
#scanDeclarations() {
|
|
3110
3150
|
const declarations = /* @__PURE__ */ new Map();
|
|
3111
3151
|
for (const key of selectModuleKeys(this.#files, this.#directories)) {
|
|
@@ -3115,6 +3155,7 @@ var Source = class {
|
|
|
3115
3155
|
if (declarations.has(identity)) continue;
|
|
3116
3156
|
if (declaration.body.length === 0 && declaration.bases.length === 0) continue;
|
|
3117
3157
|
declarations.set(identity, declaration);
|
|
3158
|
+
this.#origins.set(identity, key);
|
|
3118
3159
|
}
|
|
3119
3160
|
}
|
|
3120
3161
|
return declarations;
|
|
@@ -3388,12 +3429,14 @@ var Parity = class Parity {
|
|
|
3388
3429
|
const groups = row.guide.methods();
|
|
3389
3430
|
const documented = groups.map((group) => group.interface);
|
|
3390
3431
|
const declared = new Set(row.source.surface().map((symbol) => symbol.name));
|
|
3432
|
+
const classes = new Set(row.source.surface().filter((symbol) => symbol.keyword === "class").map((symbol) => symbol.name));
|
|
3391
3433
|
for (const group of groups) {
|
|
3392
3434
|
const finding = compareMembership(row.entry.spec, group.interface, group.methods.map((entry) => entry.name), row.source.methods(group.interface).map((entry) => entry.name));
|
|
3393
3435
|
if (finding !== void 0) findings.push(finding);
|
|
3394
3436
|
}
|
|
3395
3437
|
for (const symbol of row.source.surface()) {
|
|
3396
3438
|
if (symbol.keyword !== "interface" && symbol.keyword !== "class") continue;
|
|
3439
|
+
if (symbol.keyword === "interface" && classes.has(symbol.name)) continue;
|
|
3397
3440
|
const members = row.source.methods(symbol.name).map((entry) => entry.name);
|
|
3398
3441
|
if (members.length === 0) continue;
|
|
3399
3442
|
const contract = `${symbol.name}Interface`;
|