@orkestrel/guide 0.0.22 → 0.0.23
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 +33 -8
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +15 -5
- package/dist/src/core/index.d.ts +15 -5
- package/dist/src/core/index.js +33 -8
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +33 -8
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.js +33 -8
- package/dist/src/server/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -102,12 +102,14 @@ export declare function buildTable(table: TableNode, row: number, column: number
|
|
|
102
102
|
* optional heritage clause between the identifier and the opening `{`; the identifier is the head's
|
|
103
103
|
* own run up to that list or clause, so it enters the key as literal text and no name reaches a
|
|
104
104
|
* `RegExp`. Body lines are the raw source between the head and the first projected column-zero `}`,
|
|
105
|
-
* keeping JSDoc evidence intact
|
|
105
|
+
* keeping JSDoc evidence intact; a head whose last line closes its own body with `{}` or `{ }`
|
|
106
|
+
* records an empty body. Every balanced `<...>` span is removed from the head before its
|
|
106
107
|
* `extends` clause is read, so a `T extends Base` type parameter is never a base and `Base<T>`
|
|
107
108
|
* reads as `Base`; a class's `implements` clause and everything after it is excluded, and a
|
|
108
109
|
* qualified base such as `namespace.Base` is returned verbatim. The first head of a key that opens
|
|
109
110
|
* a column-zero close answers for that key: a head that opens none records nothing, and a later
|
|
110
|
-
* head of a key already collected adds nothing
|
|
111
|
+
* head of a key already collected adds nothing unless the earlier head recorded neither a body
|
|
112
|
+
* nor bases, which declares nothing as {@link Source} reads it, so the later head replaces it.
|
|
111
113
|
*
|
|
112
114
|
* @param source - The file's source text to read
|
|
113
115
|
* @returns One entry per collected declaration, keyed `${keyword} ${name}`
|
|
@@ -490,7 +492,7 @@ export declare function createSurfaceSymbolContract(): ContractInterface<Surface
|
|
|
490
492
|
* {@link collectDeclarations}).
|
|
491
493
|
*/
|
|
492
494
|
export declare interface Declaration {
|
|
493
|
-
/** Holds the declaration's raw body lines, between the head and the column-zero closing `}
|
|
495
|
+
/** Holds the declaration's raw body lines, between the head and the column-zero closing `}`; empty when the head's last line closes its own body. */
|
|
494
496
|
readonly body: readonly string[];
|
|
495
497
|
/** Lists the base identifiers its head extends, in head order. */
|
|
496
498
|
readonly bases: readonly string[];
|
|
@@ -504,7 +506,7 @@ export declare interface Declaration {
|
|
|
504
506
|
export declare interface DeclarationHead {
|
|
505
507
|
/** Holds the joined, space-separated head text. */
|
|
506
508
|
readonly text: string;
|
|
507
|
-
/** Holds the index (within the source `lines`) of the line
|
|
509
|
+
/** Holds the index (within the source `lines`) of the line that carries the opening `{`. */
|
|
508
510
|
readonly end: number;
|
|
509
511
|
}
|
|
510
512
|
|
|
@@ -1565,7 +1567,14 @@ export declare const isSurfaceSymbol: Guard<SurfaceSymbol>;
|
|
|
1565
1567
|
|
|
1566
1568
|
/**
|
|
1567
1569
|
* Joins the declaration head starting at `start` into one space-separated
|
|
1568
|
-
* line, consuming lines until the first that ends with
|
|
1570
|
+
* line, consuming lines until the first that opens a body: one that ends with
|
|
1571
|
+
* `{`, or one that closes an empty body with `{}` or `{ }`.
|
|
1572
|
+
*
|
|
1573
|
+
* @remarks
|
|
1574
|
+
* A line ending with `{}` closes an empty body only when every angle, round,
|
|
1575
|
+
* and square bracket the head opened outside quoted text has closed; inside
|
|
1576
|
+
* one, `{}` is a type or an argument, and an arrow's `=>` closes nothing. A
|
|
1577
|
+
* head that reaches the next column-zero `export` line opens no body.
|
|
1569
1578
|
*
|
|
1570
1579
|
* @param lines - The file's source lines
|
|
1571
1580
|
* @param start - The index of the head's first line
|
|
@@ -1574,6 +1583,7 @@ export declare const isSurfaceSymbol: Guard<SurfaceSymbol>;
|
|
|
1574
1583
|
* @example
|
|
1575
1584
|
* ```ts
|
|
1576
1585
|
* joinHead(['export class X {'], 0) // { text: 'export class X {', end: 0 }
|
|
1586
|
+
* joinHead(['export interface Y extends X {}'], 0) // { text: 'export interface Y extends X {}', end: 0 }
|
|
1577
1587
|
* ```
|
|
1578
1588
|
*/
|
|
1579
1589
|
export declare function joinHead(lines: readonly string[], start: number): DeclarationHead | undefined;
|
package/dist/src/core/index.d.ts
CHANGED
|
@@ -102,12 +102,14 @@ export declare function buildTable(table: TableNode, row: number, column: number
|
|
|
102
102
|
* optional heritage clause between the identifier and the opening `{`; the identifier is the head's
|
|
103
103
|
* own run up to that list or clause, so it enters the key as literal text and no name reaches a
|
|
104
104
|
* `RegExp`. Body lines are the raw source between the head and the first projected column-zero `}`,
|
|
105
|
-
* keeping JSDoc evidence intact
|
|
105
|
+
* keeping JSDoc evidence intact; a head whose last line closes its own body with `{}` or `{ }`
|
|
106
|
+
* records an empty body. Every balanced `<...>` span is removed from the head before its
|
|
106
107
|
* `extends` clause is read, so a `T extends Base` type parameter is never a base and `Base<T>`
|
|
107
108
|
* reads as `Base`; a class's `implements` clause and everything after it is excluded, and a
|
|
108
109
|
* qualified base such as `namespace.Base` is returned verbatim. The first head of a key that opens
|
|
109
110
|
* a column-zero close answers for that key: a head that opens none records nothing, and a later
|
|
110
|
-
* head of a key already collected adds nothing
|
|
111
|
+
* head of a key already collected adds nothing unless the earlier head recorded neither a body
|
|
112
|
+
* nor bases, which declares nothing as {@link Source} reads it, so the later head replaces it.
|
|
111
113
|
*
|
|
112
114
|
* @param source - The file's source text to read
|
|
113
115
|
* @returns One entry per collected declaration, keyed `${keyword} ${name}`
|
|
@@ -490,7 +492,7 @@ export declare function createSurfaceSymbolContract(): ContractInterface<Surface
|
|
|
490
492
|
* {@link collectDeclarations}).
|
|
491
493
|
*/
|
|
492
494
|
export declare interface Declaration {
|
|
493
|
-
/** Holds the declaration's raw body lines, between the head and the column-zero closing `}
|
|
495
|
+
/** Holds the declaration's raw body lines, between the head and the column-zero closing `}`; empty when the head's last line closes its own body. */
|
|
494
496
|
readonly body: readonly string[];
|
|
495
497
|
/** Lists the base identifiers its head extends, in head order. */
|
|
496
498
|
readonly bases: readonly string[];
|
|
@@ -504,7 +506,7 @@ export declare interface Declaration {
|
|
|
504
506
|
export declare interface DeclarationHead {
|
|
505
507
|
/** Holds the joined, space-separated head text. */
|
|
506
508
|
readonly text: string;
|
|
507
|
-
/** Holds the index (within the source `lines`) of the line
|
|
509
|
+
/** Holds the index (within the source `lines`) of the line that carries the opening `{`. */
|
|
508
510
|
readonly end: number;
|
|
509
511
|
}
|
|
510
512
|
|
|
@@ -1565,7 +1567,14 @@ export declare const isSurfaceSymbol: Guard<SurfaceSymbol>;
|
|
|
1565
1567
|
|
|
1566
1568
|
/**
|
|
1567
1569
|
* Joins the declaration head starting at `start` into one space-separated
|
|
1568
|
-
* line, consuming lines until the first that ends with
|
|
1570
|
+
* line, consuming lines until the first that opens a body: one that ends with
|
|
1571
|
+
* `{`, or one that closes an empty body with `{}` or `{ }`.
|
|
1572
|
+
*
|
|
1573
|
+
* @remarks
|
|
1574
|
+
* A line ending with `{}` closes an empty body only when every angle, round,
|
|
1575
|
+
* and square bracket the head opened outside quoted text has closed; inside
|
|
1576
|
+
* one, `{}` is a type or an argument, and an arrow's `=>` closes nothing. A
|
|
1577
|
+
* head that reaches the next column-zero `export` line opens no body.
|
|
1569
1578
|
*
|
|
1570
1579
|
* @param lines - The file's source lines
|
|
1571
1580
|
* @param start - The index of the head's first line
|
|
@@ -1574,6 +1583,7 @@ export declare const isSurfaceSymbol: Guard<SurfaceSymbol>;
|
|
|
1574
1583
|
* @example
|
|
1575
1584
|
* ```ts
|
|
1576
1585
|
* joinHead(['export class X {'], 0) // { text: 'export class X {', end: 0 }
|
|
1586
|
+
* joinHead(['export interface Y extends X {}'], 0) // { text: 'export interface Y extends X {}', end: 0 }
|
|
1577
1587
|
* ```
|
|
1578
1588
|
*/
|
|
1579
1589
|
export declare function joinHead(lines: readonly string[], start: number): DeclarationHead | undefined;
|
package/dist/src/core/index.js
CHANGED
|
@@ -1245,7 +1245,14 @@ function extractHidden(source) {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
/**
|
|
1247
1247
|
* Joins the declaration head starting at `start` into one space-separated
|
|
1248
|
-
* line, consuming lines until the first that ends with
|
|
1248
|
+
* line, consuming lines until the first that opens a body: one that ends with
|
|
1249
|
+
* `{`, or one that closes an empty body with `{}` or `{ }`.
|
|
1250
|
+
*
|
|
1251
|
+
* @remarks
|
|
1252
|
+
* A line ending with `{}` closes an empty body only when every angle, round,
|
|
1253
|
+
* and square bracket the head opened outside quoted text has closed; inside
|
|
1254
|
+
* one, `{}` is a type or an argument, and an arrow's `=>` closes nothing. A
|
|
1255
|
+
* head that reaches the next column-zero `export` line opens no body.
|
|
1249
1256
|
*
|
|
1250
1257
|
* @param lines - The file's source lines
|
|
1251
1258
|
* @param start - The index of the head's first line
|
|
@@ -1254,6 +1261,7 @@ function extractHidden(source) {
|
|
|
1254
1261
|
* @example
|
|
1255
1262
|
* ```ts
|
|
1256
1263
|
* joinHead(['export class X {'], 0) // { text: 'export class X {', end: 0 }
|
|
1264
|
+
* joinHead(['export interface Y extends X {}'], 0) // { text: 'export interface Y extends X {}', end: 0 }
|
|
1257
1265
|
* ```
|
|
1258
1266
|
*/
|
|
1259
1267
|
function joinHead(lines, start) {
|
|
@@ -1261,8 +1269,15 @@ function joinHead(lines, start) {
|
|
|
1261
1269
|
for (let index = start; index < lines.length; index += 1) {
|
|
1262
1270
|
const line = lines[index];
|
|
1263
1271
|
if (line === void 0) break;
|
|
1264
|
-
|
|
1265
|
-
if (
|
|
1272
|
+
const text = line.trimEnd();
|
|
1273
|
+
if (index > start && text.startsWith("export ")) return void 0;
|
|
1274
|
+
parts.push(index === start ? text : text.trimStart());
|
|
1275
|
+
if (text.endsWith("{")) return {
|
|
1276
|
+
text: parts.join(" "),
|
|
1277
|
+
end: index
|
|
1278
|
+
};
|
|
1279
|
+
const bare = parts.join(" ").replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g, "");
|
|
1280
|
+
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 {
|
|
1266
1281
|
text: parts.join(" "),
|
|
1267
1282
|
end: index
|
|
1268
1283
|
};
|
|
@@ -1303,12 +1318,14 @@ function escapeRegExp(value) {
|
|
|
1303
1318
|
* optional heritage clause between the identifier and the opening `{`; the identifier is the head's
|
|
1304
1319
|
* own run up to that list or clause, so it enters the key as literal text and no name reaches a
|
|
1305
1320
|
* `RegExp`. Body lines are the raw source between the head and the first projected column-zero `}`,
|
|
1306
|
-
* keeping JSDoc evidence intact
|
|
1321
|
+
* keeping JSDoc evidence intact; a head whose last line closes its own body with `{}` or `{ }`
|
|
1322
|
+
* records an empty body. Every balanced `<...>` span is removed from the head before its
|
|
1307
1323
|
* `extends` clause is read, so a `T extends Base` type parameter is never a base and `Base<T>`
|
|
1308
1324
|
* reads as `Base`; a class's `implements` clause and everything after it is excluded, and a
|
|
1309
1325
|
* qualified base such as `namespace.Base` is returned verbatim. The first head of a key that opens
|
|
1310
1326
|
* a column-zero close answers for that key: a head that opens none records nothing, and a later
|
|
1311
|
-
* head of a key already collected adds nothing
|
|
1327
|
+
* head of a key already collected adds nothing unless the earlier head recorded neither a body
|
|
1328
|
+
* nor bases, which declares nothing as {@link Source} reads it, so the later head replaces it.
|
|
1312
1329
|
*
|
|
1313
1330
|
* @param source - The file's source text to read
|
|
1314
1331
|
* @returns One entry per collected declaration, keyed `${keyword} ${name}`
|
|
@@ -1322,7 +1339,7 @@ function escapeRegExp(value) {
|
|
|
1322
1339
|
function collectDeclarations(source) {
|
|
1323
1340
|
const declarations = /* @__PURE__ */ new Map();
|
|
1324
1341
|
const opener = /^export (?:class|interface) /;
|
|
1325
|
-
const grammar = /^export (class|interface) ([^\s<]+)(?:<.*>)?(?: .*)? \{
|
|
1342
|
+
const grammar = /^export (class|interface) ([^\s<]+)(?:<.*>)?(?: .*)? \{(?:\s*\})?$/;
|
|
1326
1343
|
const lines = extractSourceLines(source);
|
|
1327
1344
|
const projected = lines.map((line) => line.code);
|
|
1328
1345
|
for (let index = 0; index < projected.length; index += 1) {
|
|
@@ -1335,14 +1352,22 @@ function collectDeclarations(source) {
|
|
|
1335
1352
|
const name = declared?.[2];
|
|
1336
1353
|
if (keyword === void 0 || name === void 0) continue;
|
|
1337
1354
|
const key = `${keyword} ${name}`;
|
|
1338
|
-
|
|
1355
|
+
const known = declarations.get(key);
|
|
1356
|
+
if (known !== void 0 && (known.body.length > 0 || known.bases.length > 0)) continue;
|
|
1339
1357
|
let depth = 0;
|
|
1340
1358
|
let flat = "";
|
|
1341
|
-
for (const character of head.text.slice(`export ${key}`.length,
|
|
1359
|
+
for (const character of head.text.slice(`export ${key}`.length, head.text.lastIndexOf("{"))) if (character === "<") depth += 1;
|
|
1342
1360
|
else if (character === ">") depth = Math.max(0, depth - 1);
|
|
1343
1361
|
else if (depth === 0) flat += character;
|
|
1344
1362
|
const clause = flat.replace(/\bimplements\b[\s\S]*$/, "").match(/\bextends\b([\s\S]*)$/)?.[1];
|
|
1345
1363
|
const bases = clause === void 0 ? [] : clause.split(",").map((base) => base.trim()).filter(isNonEmptyString);
|
|
1364
|
+
if (head.text.endsWith("}")) {
|
|
1365
|
+
declarations.set(key, {
|
|
1366
|
+
body: [],
|
|
1367
|
+
bases
|
|
1368
|
+
});
|
|
1369
|
+
continue;
|
|
1370
|
+
}
|
|
1346
1371
|
for (let close = head.end + 1; close < projected.length; close += 1) {
|
|
1347
1372
|
if (projected[close] !== "}") continue;
|
|
1348
1373
|
declarations.set(key, {
|