@openuji/speculator 0.5.3 → 0.5.4
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/parse/__tests__/html-in-markdown.test.d.ts +2 -0
- package/dist/parse/__tests__/html-in-markdown.test.d.ts.map +1 -0
- package/dist/parse/__tests__/html-in-markdown.test.js +83 -0
- package/dist/parse/__tests__/html-in-markdown.test.js.map +1 -0
- package/dist/parse/__tests__/pipeline.test.js +1 -8
- package/dist/parse/__tests__/pipeline.test.js.map +1 -1
- package/dist/parse/__tests__/shorthands.test.d.ts +5 -0
- package/dist/parse/__tests__/shorthands.test.d.ts.map +1 -0
- package/dist/parse/__tests__/shorthands.test.js +96 -0
- package/dist/parse/__tests__/shorthands.test.js.map +1 -0
- package/dist/parse/assembler.d.ts.map +1 -1
- package/dist/parse/assembler.js +18 -0
- package/dist/parse/assembler.js.map +1 -1
- package/dist/parse/html/InlinesHtmlParser.d.ts.map +1 -1
- package/dist/parse/html/InlinesHtmlParser.js +11 -1
- package/dist/parse/html/InlinesHtmlParser.js.map +1 -1
- package/dist/parse/html/parser.d.ts +1 -12
- package/dist/parse/html/parser.d.ts.map +1 -1
- package/dist/parse/html/parser.js +15 -47
- package/dist/parse/html/parser.js.map +1 -1
- package/dist/parse/index.d.ts +1 -1
- package/dist/parse/index.d.ts.map +1 -1
- package/dist/parse/index.js.map +1 -1
- package/dist/parse/markdown/HtmlBlockMarkdownParser.d.ts +13 -0
- package/dist/parse/markdown/HtmlBlockMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/HtmlBlockMarkdownParser.js +61 -0
- package/dist/parse/markdown/HtmlBlockMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/HtmlInlinesMarkdownParser.d.ts +12 -0
- package/dist/parse/markdown/HtmlInlinesMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/HtmlInlinesMarkdownParser.js +187 -0
- package/dist/parse/markdown/HtmlInlinesMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/HtmlParagraphMarkdownParser.d.ts +15 -0
- package/dist/parse/markdown/HtmlParagraphMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/HtmlParagraphMarkdownParser.js +67 -0
- package/dist/parse/markdown/HtmlParagraphMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/ShorthandsMarkdownParser.d.ts +29 -0
- package/dist/parse/markdown/ShorthandsMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/ShorthandsMarkdownParser.js +200 -0
- package/dist/parse/markdown/ShorthandsMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/parser.d.ts +3 -14
- package/dist/parse/markdown/parser.d.ts.map +1 -1
- package/dist/parse/markdown/parser.js +72 -47
- package/dist/parse/markdown/parser.js.map +1 -1
- package/dist/parse/parsers.d.ts +3 -0
- package/dist/parse/parsers.d.ts.map +1 -1
- package/dist/parse/parsers.js +10 -0
- package/dist/parse/parsers.js.map +1 -1
- package/dist/parse/pipeline.d.ts.map +1 -1
- package/dist/parse/pipeline.js +8 -20
- package/dist/parse/pipeline.js.map +1 -1
- package/dist/parse/registry.d.ts +50 -91
- package/dist/parse/registry.d.ts.map +1 -1
- package/dist/parse/registry.js +39 -58
- package/dist/parse/registry.js.map +1 -1
- package/dist/parse/types.d.ts +1 -23
- package/dist/parse/types.d.ts.map +1 -1
- package/dist/parse/types.js.map +1 -1
- package/dist/parse/utils/hast-utils.d.ts +30 -0
- package/dist/parse/utils/hast-utils.d.ts.map +1 -0
- package/dist/parse/utils/hast-utils.js +94 -0
- package/dist/parse/utils/hast-utils.js.map +1 -0
- package/dist/pipeline/runner.d.ts.map +1 -1
- package/dist/pipeline/runner.js +16 -12
- package/dist/pipeline/runner.js.map +1 -1
- package/dist/postprocess/index.d.ts +1 -1
- package/dist/postprocess/index.d.ts.map +1 -1
- package/dist/postprocess/index.js +3 -3
- package/dist/postprocess/index.js.map +1 -1
- package/dist/postprocess/plugins/citation-resolve.d.ts +8 -0
- package/dist/postprocess/plugins/citation-resolve.d.ts.map +1 -0
- package/dist/postprocess/plugins/citation-resolve.js +33 -0
- package/dist/postprocess/plugins/citation-resolve.js.map +1 -0
- package/dist/preprocess/__tests__/pipeline.test.js +33 -45
- package/dist/preprocess/__tests__/pipeline.test.js.map +1 -1
- package/dist/preprocess/__tests__/resolver.test.js +38 -40
- package/dist/preprocess/__tests__/resolver.test.js.map +1 -1
- package/dist/preprocess/config/__tests__/rules.test.d.ts +2 -0
- package/dist/preprocess/config/__tests__/rules.test.d.ts.map +1 -0
- package/dist/preprocess/config/__tests__/rules.test.js +212 -0
- package/dist/preprocess/config/__tests__/rules.test.js.map +1 -0
- package/dist/preprocess/config/doc-config.js +1 -1
- package/dist/preprocess/config/doc-config.js.map +1 -1
- package/dist/preprocess/config/index.d.ts +3 -4
- package/dist/preprocess/config/index.d.ts.map +1 -1
- package/dist/preprocess/config/index.js +2 -2
- package/dist/preprocess/config/index.js.map +1 -1
- package/dist/preprocess/config/loader.d.ts +12 -48
- package/dist/preprocess/config/loader.d.ts.map +1 -1
- package/dist/preprocess/config/loader.js +23 -13
- package/dist/preprocess/config/loader.js.map +1 -1
- package/dist/preprocess/config/normalize.d.ts +11 -6
- package/dist/preprocess/config/normalize.d.ts.map +1 -1
- package/dist/preprocess/config/normalize.js +58 -8
- package/dist/preprocess/config/normalize.js.map +1 -1
- package/dist/preprocess/config/types.d.ts +57 -22
- package/dist/preprocess/config/types.d.ts.map +1 -1
- package/dist/preprocess/include/index.d.ts +1 -1
- package/dist/preprocess/include/index.d.ts.map +1 -1
- package/dist/preprocess/include/index.js +1 -1
- package/dist/preprocess/include/index.js.map +1 -1
- package/dist/preprocess/include/resolver.d.ts +14 -8
- package/dist/preprocess/include/resolver.d.ts.map +1 -1
- package/dist/preprocess/include/resolver.js +27 -18
- package/dist/preprocess/include/resolver.js.map +1 -1
- package/dist/preprocess/index.d.ts +6 -6
- package/dist/preprocess/index.d.ts.map +1 -1
- package/dist/preprocess/index.js +4 -4
- package/dist/preprocess/index.js.map +1 -1
- package/dist/preprocess/pipeline.d.ts +19 -16
- package/dist/preprocess/pipeline.d.ts.map +1 -1
- package/dist/preprocess/pipeline.js +43 -45
- package/dist/preprocess/pipeline.js.map +1 -1
- package/dist/preprocess/types.d.ts +21 -46
- package/dist/preprocess/types.d.ts.map +1 -1
- package/dist/preprocess/types.js +0 -6
- package/dist/preprocess/types.js.map +1 -1
- package/dist/types/ast.generated.d.ts +21 -2
- package/dist/types/ast.generated.d.ts.map +1 -1
- package/dist/types/ast.generated.js +1 -1
- package/dist/types/ast.generated.js.map +1 -1
- package/package.json +1 -1
- package/schema/spec-ast.schema.json +40 -0
|
@@ -4,37 +4,72 @@
|
|
|
4
4
|
* Types for document-level configuration (config.json).
|
|
5
5
|
* Used to define document IDs, dependencies, and optional respec configuration.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
export type DocumentId = string;
|
|
8
|
+
export type ISODateString = `${number}-${number}-${number}`;
|
|
9
|
+
export type MaturityLevel = 'incubating' | 'draft' | 'prerelease' | 'stable';
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Located in config.json sibling to spec entry files.
|
|
11
|
+
* Raw person entry from ReSpec config
|
|
12
12
|
*/
|
|
13
|
-
export interface
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
deps?: string[];
|
|
21
|
-
/**
|
|
22
|
-
* Optional ReSpec configuration embedded in config.json.
|
|
23
|
-
* If present, this replaces the need for a separate config.respec.json file.
|
|
24
|
-
*/
|
|
25
|
-
respec?: RawRespecConfig;
|
|
13
|
+
export interface RawPersonEntry {
|
|
14
|
+
name: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
company?: string;
|
|
17
|
+
companyURL?: string;
|
|
18
|
+
mailto?: string;
|
|
19
|
+
email?: string;
|
|
26
20
|
}
|
|
27
21
|
/**
|
|
28
|
-
*
|
|
22
|
+
* Raw ReSpec configuration as embedded in config.json
|
|
29
23
|
*/
|
|
24
|
+
export interface RawRespecConfig {
|
|
25
|
+
title?: string;
|
|
26
|
+
shortName?: string;
|
|
27
|
+
subtitle?: string;
|
|
28
|
+
specStatus?: string;
|
|
29
|
+
publishDate?: string;
|
|
30
|
+
modificationDate?: string;
|
|
31
|
+
thisVersion?: string;
|
|
32
|
+
latestVersion?: string;
|
|
33
|
+
prevVersion?: string;
|
|
34
|
+
editors?: RawPersonEntry[];
|
|
35
|
+
authors?: RawPersonEntry[];
|
|
36
|
+
abstract?: string;
|
|
37
|
+
license?: string;
|
|
38
|
+
logos?: Array<{
|
|
39
|
+
src: string;
|
|
40
|
+
alt?: string;
|
|
41
|
+
href?: string;
|
|
42
|
+
url?: string;
|
|
43
|
+
}>;
|
|
44
|
+
noTOC?: boolean;
|
|
45
|
+
maxTocLevel?: number;
|
|
46
|
+
localBiblio?: Record<string, unknown>;
|
|
47
|
+
}
|
|
30
48
|
export interface ResolvedDocumentConfig {
|
|
31
49
|
/** Document ID (from config or auto-generated) */
|
|
32
|
-
id:
|
|
50
|
+
id: DocumentId;
|
|
33
51
|
/** Dependencies (empty array if none) */
|
|
34
|
-
deps:
|
|
52
|
+
deps: DocumentId[];
|
|
53
|
+
/** Document title (core config setting, takes priority over respec.title) */
|
|
54
|
+
title?: string;
|
|
55
|
+
/** Last update date (core config setting, takes priority over respec.modificationDate) */
|
|
56
|
+
lastUpdateDate?: ISODateString;
|
|
57
|
+
/** Maturity level (core config setting, takes priority over mapped respec.specStatus) */
|
|
58
|
+
maturityLevel?: MaturityLevel;
|
|
59
|
+
/** Optional ReSpec configuration embedded in config.json */
|
|
60
|
+
respec?: RawRespecConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Custom user-defined properties.
|
|
63
|
+
* Highest priority - overwrites both root and respec values.
|
|
64
|
+
*/
|
|
65
|
+
custom?: Record<string, unknown>;
|
|
35
66
|
/** Whether the ID was auto-generated */
|
|
36
67
|
autoGenerated: boolean;
|
|
37
|
-
/** Optional respec configuration if present in config.json */
|
|
38
|
-
respec?: RawRespecConfig;
|
|
39
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Raw config as read from config.json:
|
|
71
|
+
* - id and deps are optional
|
|
72
|
+
* - autoGenerated should not be user-provided, so we remove it
|
|
73
|
+
*/
|
|
74
|
+
export type DocumentConfig = Omit<Partial<ResolvedDocumentConfig>, 'autoGenerated'>;
|
|
40
75
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/preprocess/config/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/preprocess/config/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,aAAa,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;AAC5D,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,CAAC;AAE7E;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAE5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAA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MAAM,cAAc,GACxB,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAAE,eAAe,CAAC,CAAC"}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { scanMarkdownIncludes } from '#src/preprocess/include/scan-markdown';
|
|
5
5
|
export { scanHtmlIncludes } from '#src/preprocess/include/scan-html';
|
|
6
|
-
export { resolveIncludes } from '#src/preprocess/include/resolver';
|
|
6
|
+
export { resolveIncludes, IncludeResolveError } from '#src/preprocess/include/resolver';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/preprocess/include/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/preprocess/include/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { scanMarkdownIncludes } from '#src/preprocess/include/scan-markdown';
|
|
5
5
|
export { scanHtmlIncludes } from '#src/preprocess/include/scan-html';
|
|
6
|
-
export { resolveIncludes } from '#src/preprocess/include/resolver';
|
|
6
|
+
export { resolveIncludes, IncludeResolveError } from '#src/preprocess/include/resolver';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/preprocess/include/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/preprocess/include/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -6,22 +6,31 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Key behaviors:
|
|
8
8
|
* - Deterministic order: includes are processed in encounter order
|
|
9
|
-
* - Cycle detection: prevents infinite loops with clear
|
|
9
|
+
* - Cycle detection: prevents infinite loops with clear errors
|
|
10
10
|
* - Content splitting: preserves sourcePos.file for each fragment
|
|
11
11
|
*/
|
|
12
12
|
import type { FileProvider } from '#src/file-provider/types';
|
|
13
|
-
import type { SourceFormat, CompositeSource
|
|
13
|
+
import type { SourceFormat, CompositeSource } from '#src/preprocess/types';
|
|
14
|
+
/**
|
|
15
|
+
* Error thrown when include resolution fails
|
|
16
|
+
*/
|
|
17
|
+
export declare class IncludeResolveError extends Error {
|
|
18
|
+
readonly code: 'include-cycle' | 'include-not-found';
|
|
19
|
+
readonly path: string;
|
|
20
|
+
constructor(message: string, code: 'include-cycle' | 'include-not-found', path: string);
|
|
21
|
+
}
|
|
14
22
|
/**
|
|
15
23
|
* Resolve all includes from an entry file
|
|
16
24
|
*
|
|
17
25
|
* @param entry - Canonical path to entry file
|
|
18
26
|
* @param entryFormat - Format of entry file (inferred if not provided)
|
|
19
27
|
* @param fileProvider - File provider for reading files
|
|
20
|
-
* @returns CompositeSource with resolved includes
|
|
28
|
+
* @returns CompositeSource with resolved includes
|
|
29
|
+
* @throws IncludeResolveError on cycle detection or file not found
|
|
21
30
|
*
|
|
22
31
|
* @example
|
|
23
32
|
* ```typescript
|
|
24
|
-
* const
|
|
33
|
+
* const source = await resolveIncludes(
|
|
25
34
|
* '/spec/format.md',
|
|
26
35
|
* 'markdown',
|
|
27
36
|
* fileProvider
|
|
@@ -33,8 +42,5 @@ import type { SourceFormat, CompositeSource, Diagnostic } from '#src/preprocess/
|
|
|
33
42
|
* }
|
|
34
43
|
* ```
|
|
35
44
|
*/
|
|
36
|
-
export declare function resolveIncludes(entry: string, entryFormat: SourceFormat | undefined, fileProvider: FileProvider): Promise<
|
|
37
|
-
source: CompositeSource;
|
|
38
|
-
diagnostics: Diagnostic[];
|
|
39
|
-
}>;
|
|
45
|
+
export declare function resolveIncludes(entry: string, entryFormat: SourceFormat | undefined, fileProvider: FileProvider): Promise<CompositeSource>;
|
|
40
46
|
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/preprocess/include/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EACR,YAAY,EAKZ,eAAe,
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/preprocess/include/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EACR,YAAY,EAKZ,eAAe,EAClB,MAAM,uBAAuB,CAAC;AAK/B;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;aAGtB,IAAI,EAAE,eAAe,GAAG,mBAAmB;aAC3C,IAAI,EAAE,MAAM;gBAF5B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,eAAe,GAAG,mBAAmB,EAC3C,IAAI,EAAE,MAAM;CAKnC;AA6KD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,eAAe,CACjC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,YAAY,GAAG,SAAS,EACrC,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,eAAe,CAAC,CAmB1B"}
|
|
@@ -6,13 +6,26 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Key behaviors:
|
|
8
8
|
* - Deterministic order: includes are processed in encounter order
|
|
9
|
-
* - Cycle detection: prevents infinite loops with clear
|
|
9
|
+
* - Cycle detection: prevents infinite loops with clear errors
|
|
10
10
|
* - Content splitting: preserves sourcePos.file for each fragment
|
|
11
11
|
*/
|
|
12
12
|
import { isFileNotFoundError } from '#src/file-provider/types';
|
|
13
|
-
import { inferFormat
|
|
13
|
+
import { inferFormat } from '#src/preprocess/types';
|
|
14
14
|
import { scanMarkdownIncludes } from '#src/preprocess/include/scan-markdown';
|
|
15
15
|
import { scanHtmlIncludes } from '#src/preprocess/include/scan-html';
|
|
16
|
+
/**
|
|
17
|
+
* Error thrown when include resolution fails
|
|
18
|
+
*/
|
|
19
|
+
export class IncludeResolveError extends Error {
|
|
20
|
+
code;
|
|
21
|
+
path;
|
|
22
|
+
constructor(message, code, path) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.code = code;
|
|
25
|
+
this.path = path;
|
|
26
|
+
this.name = 'IncludeResolveError';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
16
29
|
/**
|
|
17
30
|
* Count lines up to an offset
|
|
18
31
|
*/
|
|
@@ -37,14 +50,14 @@ function scanIncludes(content, file, format) {
|
|
|
37
50
|
* Split content at include points and recursively resolve
|
|
38
51
|
*
|
|
39
52
|
* Returns SourceUnits in document order (includes expanded in-place)
|
|
53
|
+
* @throws IncludeResolveError on cycle detection or file not found
|
|
40
54
|
*/
|
|
41
55
|
async function resolveFile(file, format, ctx) {
|
|
42
|
-
const { fileProvider, includeGraph,
|
|
56
|
+
const { fileProvider, includeGraph, activePath, visited } = ctx;
|
|
43
57
|
// Cycle detection
|
|
44
58
|
if (activePath.has(file)) {
|
|
45
59
|
const cycle = [...activePath, file];
|
|
46
|
-
|
|
47
|
-
return [];
|
|
60
|
+
throw new IncludeResolveError(`Include cycle detected: ${cycle.join(' → ')}`, 'include-cycle', file);
|
|
48
61
|
}
|
|
49
62
|
// Check if already processed (for diamond includes - A includes B and C, both include D)
|
|
50
63
|
const cached = visited.get(file);
|
|
@@ -64,12 +77,11 @@ async function resolveFile(file, format, ctx) {
|
|
|
64
77
|
}
|
|
65
78
|
catch (error) {
|
|
66
79
|
if (isFileNotFoundError(error)) {
|
|
67
|
-
|
|
80
|
+
throw new IncludeResolveError(`Included file not found: ${file}`, 'include-not-found', file);
|
|
68
81
|
}
|
|
69
82
|
else {
|
|
70
|
-
|
|
83
|
+
throw new IncludeResolveError(`Failed to read included file: ${file} - ${error instanceof Error ? error.message : String(error)}`, 'include-not-found', file);
|
|
71
84
|
}
|
|
72
|
-
return [];
|
|
73
85
|
}
|
|
74
86
|
// Cache for diamond include handling
|
|
75
87
|
visited.set(file, { content, format });
|
|
@@ -147,11 +159,12 @@ async function resolveFile(file, format, ctx) {
|
|
|
147
159
|
* @param entry - Canonical path to entry file
|
|
148
160
|
* @param entryFormat - Format of entry file (inferred if not provided)
|
|
149
161
|
* @param fileProvider - File provider for reading files
|
|
150
|
-
* @returns CompositeSource with resolved includes
|
|
162
|
+
* @returns CompositeSource with resolved includes
|
|
163
|
+
* @throws IncludeResolveError on cycle detection or file not found
|
|
151
164
|
*
|
|
152
165
|
* @example
|
|
153
166
|
* ```typescript
|
|
154
|
-
* const
|
|
167
|
+
* const source = await resolveIncludes(
|
|
155
168
|
* '/spec/format.md',
|
|
156
169
|
* 'markdown',
|
|
157
170
|
* fileProvider
|
|
@@ -169,19 +182,15 @@ export async function resolveIncludes(entry, entryFormat, fileProvider) {
|
|
|
169
182
|
const ctx = {
|
|
170
183
|
fileProvider,
|
|
171
184
|
includeGraph: new Map(),
|
|
172
|
-
diagnostics: [],
|
|
173
185
|
activePath: new Set(),
|
|
174
186
|
visited: new Map(),
|
|
175
187
|
};
|
|
176
188
|
const units = await resolveFile(canonicalEntry, format, ctx);
|
|
177
189
|
return {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
includeGraph: ctx.includeGraph,
|
|
183
|
-
},
|
|
184
|
-
diagnostics: ctx.diagnostics,
|
|
190
|
+
entryFile: canonicalEntry,
|
|
191
|
+
entryFormat: format,
|
|
192
|
+
units,
|
|
193
|
+
includeGraph: ctx.includeGraph,
|
|
185
194
|
};
|
|
186
195
|
}
|
|
187
196
|
//# sourceMappingURL=resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/preprocess/include/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../src/preprocess/include/resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAS/D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAErE;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAGtB;IACA;IAHpB,YACI,OAAe,EACC,IAA2C,EAC3C,IAAY;QAE5B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAuC;QAC3C,SAAI,GAAJ,IA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ce ordered SourceUnits
|
|
7
7
|
* - Preserving source file information for accurate error reporting
|
|
8
8
|
*/
|
|
9
|
-
export { preprocess, validateEntry } from '#src/preprocess/pipeline';
|
|
9
|
+
export { preprocess, validateEntry, PreprocessError } from '#src/preprocess/pipeline';
|
|
10
10
|
export type { PreprocessOptions } from '#src/preprocess/pipeline';
|
|
11
|
-
export type { SourceFormat, IncludeDirective, SourceUnit, IncludeGraph, IncludeEdge, CompositeSource, PersonEntry, SpecConfig, PreprocessedSpec,
|
|
12
|
-
export { inferFormat
|
|
13
|
-
export {
|
|
14
|
-
export type { RawRespecConfig, RawPersonEntry } from '#src/preprocess/config/index';
|
|
15
|
-
export { scanMarkdownIncludes, scanHtmlIncludes, resolveIncludes, } from '#src/preprocess/include/index';
|
|
11
|
+
export type { SourceFormat, IncludeDirective, SourceUnit, IncludeGraph, IncludeEdge, CompositeSource, PersonEntry, SpecConfig, PreprocessedSpec, MaturityLevel, } from '#src/preprocess/types';
|
|
12
|
+
export { inferFormat } from '#src/preprocess/types';
|
|
13
|
+
export { loadConfig, normalizeConfig, createDefaultConfig, ConfigLoadError, } from '#src/preprocess/config/index';
|
|
14
|
+
export type { RawRespecConfig, RawPersonEntry, DocumentConfig, ResolvedDocumentConfig } from '#src/preprocess/config/index';
|
|
15
|
+
export { scanMarkdownIncludes, scanHtmlIncludes, resolveIncludes, IncludeResolveError, } from '#src/preprocess/include/index';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/preprocess/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/preprocess/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtF,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,YAAY,EACR,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,aAAa,GAChB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EACH,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,eAAe,GAClB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAG5H,OAAO,EACH,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACtB,MAAM,+BAA+B,CAAC"}
|
package/dist/preprocess/index.js
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* - Preserving source file information for accurate error reporting
|
|
8
8
|
*/
|
|
9
9
|
// Main orchestrator
|
|
10
|
-
export { preprocess, validateEntry } from '#src/preprocess/pipeline';
|
|
11
|
-
export { inferFormat
|
|
10
|
+
export { preprocess, validateEntry, PreprocessError } from '#src/preprocess/pipeline';
|
|
11
|
+
export { inferFormat } from '#src/preprocess/types';
|
|
12
12
|
// Config submodule (for advanced use)
|
|
13
|
-
export {
|
|
13
|
+
export { loadConfig, normalizeConfig, createDefaultConfig, ConfigLoadError, } from '#src/preprocess/config/index';
|
|
14
14
|
// Include submodule (for advanced use)
|
|
15
|
-
export { scanMarkdownIncludes, scanHtmlIncludes, resolveIncludes, } from '#src/preprocess/include/index';
|
|
15
|
+
export { scanMarkdownIncludes, scanHtmlIncludes, resolveIncludes, IncludeResolveError, } from '#src/preprocess/include/index';
|
|
16
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/preprocess/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/preprocess/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oBAAoB;AACpB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAiBtF,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,sCAAsC;AACtC,OAAO,EACH,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,eAAe,GAClB,MAAM,8BAA8B,CAAC;AAGtC,uCAAuC;AACvC,OAAO,EACH,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACtB,MAAM,+BAA+B,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* This is the main entry point for the preprocess stage.
|
|
6
6
|
*/
|
|
7
7
|
import type { FileProvider } from '#src/file-provider/types';
|
|
8
|
-
import type { SourceFormat,
|
|
8
|
+
import type { SourceFormat, PreprocessedSpec } from '#src/preprocess/types';
|
|
9
9
|
/**
|
|
10
10
|
* Options for preprocessing a specification
|
|
11
11
|
*/
|
|
@@ -19,6 +19,14 @@ export interface PreprocessOptions {
|
|
|
19
19
|
/** File provider for reading files */
|
|
20
20
|
fileProvider: FileProvider;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Error thrown when preprocessing fails
|
|
24
|
+
*/
|
|
25
|
+
export declare class PreprocessError extends Error {
|
|
26
|
+
readonly code: string;
|
|
27
|
+
readonly path?: string | undefined;
|
|
28
|
+
constructor(message: string, code: string, path?: string | undefined);
|
|
29
|
+
}
|
|
22
30
|
/**
|
|
23
31
|
* Preprocess a specification document
|
|
24
32
|
*
|
|
@@ -26,32 +34,27 @@ export interface PreprocessOptions {
|
|
|
26
34
|
* to produce a PreprocessedSpec ready for parsing.
|
|
27
35
|
*
|
|
28
36
|
* @param options - Preprocess options
|
|
29
|
-
* @returns
|
|
37
|
+
* @returns PreprocessedSpec with config and source
|
|
38
|
+
* @throws PreprocessError on failure
|
|
30
39
|
*
|
|
31
40
|
* @example
|
|
32
41
|
* ```typescript
|
|
33
|
-
* const
|
|
42
|
+
* const spec = await preprocess({
|
|
34
43
|
* entry: '/specs/my-spec/format.md',
|
|
35
|
-
* configPath: '/specs/my-spec/config.
|
|
44
|
+
* configPath: '/specs/my-spec/config.json',
|
|
36
45
|
* fileProvider: new NodeFileProvider(),
|
|
37
46
|
* });
|
|
38
47
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* }
|
|
42
|
-
* // result.result contains PreprocessedSpec
|
|
43
|
-
* for (const unit of result.result.source.units) {
|
|
44
|
-
* console.log(`Processing: ${unit.file}`);
|
|
45
|
-
* }
|
|
48
|
+
* // spec contains PreprocessedSpec
|
|
49
|
+
* for (const unit of spec.source.units) {
|
|
50
|
+
* console.log(`Processing: ${unit.file}`);
|
|
46
51
|
* }
|
|
47
52
|
* ```
|
|
48
53
|
*/
|
|
49
|
-
export declare function preprocess(options: PreprocessOptions): Promise<
|
|
54
|
+
export declare function preprocess(options: PreprocessOptions): Promise<PreprocessedSpec>;
|
|
50
55
|
/**
|
|
51
56
|
* Quick check if an entry file exists and is readable
|
|
57
|
+
* @throws PreprocessError if entry file not found
|
|
52
58
|
*/
|
|
53
|
-
export declare function validateEntry(entry: string, fileProvider: FileProvider): Promise<
|
|
54
|
-
valid: boolean;
|
|
55
|
-
diagnostics: Diagnostic[];
|
|
56
|
-
}>;
|
|
59
|
+
export declare function validateEntry(entry: string, fileProvider: FileProvider): Promise<void>;
|
|
57
60
|
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/preprocess/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACR,YAAY,EAEZ,gBAAgB,
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/preprocess/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACR,YAAY,EAEZ,gBAAgB,EACnB,MAAM,uBAAuB,CAAC;AAK/B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IAEd,yEAAyE;IACzE,WAAW,CAAC,EAAE,YAAY,CAAC;IAE3B,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,sCAAsC;IACtC,YAAY,EAAE,YAAY,CAAC;CAC9B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,KAAK;aAGlB,IAAI,EAAE,MAAM;aACZ,IAAI,CAAC,EAAE,MAAM;gBAF7B,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,YAAA;CAKpC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsCtF;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAC/B,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
|
@@ -5,8 +5,21 @@
|
|
|
5
5
|
* This is the main entry point for the preprocess stage.
|
|
6
6
|
*/
|
|
7
7
|
import { inferFormat } from '#src/preprocess/types';
|
|
8
|
-
import {
|
|
9
|
-
import { resolveIncludes } from '#src/preprocess/include/index';
|
|
8
|
+
import { loadConfig, normalizeConfig, createDefaultConfig, ConfigLoadError } from '#src/preprocess/config/index';
|
|
9
|
+
import { resolveIncludes, IncludeResolveError } from '#src/preprocess/include/index';
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when preprocessing fails
|
|
12
|
+
*/
|
|
13
|
+
export class PreprocessError extends Error {
|
|
14
|
+
code;
|
|
15
|
+
path;
|
|
16
|
+
constructor(message, code, path) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.code = code;
|
|
19
|
+
this.path = path;
|
|
20
|
+
this.name = 'PreprocessError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
10
23
|
/**
|
|
11
24
|
* Preprocess a specification document
|
|
12
25
|
*
|
|
@@ -14,87 +27,72 @@ import { resolveIncludes } from '#src/preprocess/include/index';
|
|
|
14
27
|
* to produce a PreprocessedSpec ready for parsing.
|
|
15
28
|
*
|
|
16
29
|
* @param options - Preprocess options
|
|
17
|
-
* @returns
|
|
30
|
+
* @returns PreprocessedSpec with config and source
|
|
31
|
+
* @throws PreprocessError on failure
|
|
18
32
|
*
|
|
19
33
|
* @example
|
|
20
34
|
* ```typescript
|
|
21
|
-
* const
|
|
35
|
+
* const spec = await preprocess({
|
|
22
36
|
* entry: '/specs/my-spec/format.md',
|
|
23
|
-
* configPath: '/specs/my-spec/config.
|
|
37
|
+
* configPath: '/specs/my-spec/config.json',
|
|
24
38
|
* fileProvider: new NodeFileProvider(),
|
|
25
39
|
* });
|
|
26
40
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* }
|
|
30
|
-
* // result.result contains PreprocessedSpec
|
|
31
|
-
* for (const unit of result.result.source.units) {
|
|
32
|
-
* console.log(`Processing: ${unit.file}`);
|
|
33
|
-
* }
|
|
41
|
+
* // spec contains PreprocessedSpec
|
|
42
|
+
* for (const unit of spec.source.units) {
|
|
43
|
+
* console.log(`Processing: ${unit.file}`);
|
|
34
44
|
* }
|
|
35
45
|
* ```
|
|
36
46
|
*/
|
|
37
47
|
export async function preprocess(options) {
|
|
38
48
|
const { entry, entryFormat, configPath, fileProvider } = options;
|
|
39
|
-
const diagnostics = [];
|
|
40
49
|
// Canonicalize entry path
|
|
41
50
|
const canonicalEntry = fileProvider.canonicalize(entry);
|
|
42
51
|
const format = entryFormat ?? inferFormat(canonicalEntry);
|
|
43
52
|
// Load config if provided
|
|
44
53
|
let config;
|
|
45
54
|
if (configPath) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
config = normalizeRespecConfig(configResult.config);
|
|
55
|
+
try {
|
|
56
|
+
const docConfig = await loadConfig(fileProvider, configPath);
|
|
57
|
+
config = normalizeConfig(docConfig);
|
|
50
58
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (error instanceof ConfigLoadError) {
|
|
61
|
+
throw new PreprocessError(error.message, error.code, error.path);
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
54
64
|
}
|
|
55
65
|
}
|
|
56
66
|
else {
|
|
57
67
|
config = createDefaultConfig();
|
|
58
68
|
}
|
|
59
69
|
// Resolve includes
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
+
let source;
|
|
71
|
+
try {
|
|
72
|
+
source = await resolveIncludes(canonicalEntry, format, fileProvider);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof IncludeResolveError) {
|
|
76
|
+
throw new PreprocessError(error.message, error.code, error.path);
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
70
79
|
}
|
|
71
80
|
return {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
source: includeResult.source,
|
|
75
|
-
},
|
|
76
|
-
diagnostics,
|
|
77
|
-
hasErrors,
|
|
81
|
+
config,
|
|
82
|
+
source,
|
|
78
83
|
};
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
81
86
|
* Quick check if an entry file exists and is readable
|
|
87
|
+
* @throws PreprocessError if entry file not found
|
|
82
88
|
*/
|
|
83
89
|
export async function validateEntry(entry, fileProvider) {
|
|
84
|
-
const diagnostics = [];
|
|
85
90
|
const canonicalEntry = fileProvider.canonicalize(entry);
|
|
86
91
|
try {
|
|
87
92
|
await fileProvider.readText(canonicalEntry);
|
|
88
|
-
return { valid: true, diagnostics };
|
|
89
93
|
}
|
|
90
94
|
catch {
|
|
91
|
-
|
|
92
|
-
severity: 'error',
|
|
93
|
-
code: 'include-not-found',
|
|
94
|
-
message: `Entry file not found: ${canonicalEntry}`,
|
|
95
|
-
file: canonicalEntry,
|
|
96
|
-
});
|
|
97
|
-
return { valid: false, diagnostics };
|
|
95
|
+
throw new PreprocessError(`Entry file not found: ${canonicalEntry}`, 'entry-not-found', canonicalEntry);
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
//# sourceMappingURL=pipeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/preprocess/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/preprocess/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACjH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAmBrF;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAGlB;IACA;IAHpB,YACI,OAAe,EACC,IAAY,EACZ,IAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,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