@openuji/speculator 0.3.2 → 0.4.0
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/README.md +111 -50
- package/dist/file-provider/__tests__/compliance.test.d.ts +5 -0
- package/dist/file-provider/__tests__/compliance.test.d.ts.map +1 -0
- package/dist/file-provider/__tests__/compliance.test.js +52 -0
- package/dist/file-provider/__tests__/compliance.test.js.map +1 -0
- package/dist/file-provider/index.d.ts +8 -0
- package/dist/file-provider/index.d.ts.map +1 -0
- package/dist/file-provider/index.js +10 -0
- package/dist/file-provider/index.js.map +1 -0
- package/dist/file-provider/memory.d.ts +46 -0
- package/dist/file-provider/memory.d.ts.map +1 -0
- package/dist/file-provider/memory.js +99 -0
- package/dist/file-provider/memory.js.map +1 -0
- package/dist/file-provider/node.d.ts +32 -0
- package/dist/file-provider/node.d.ts.map +1 -0
- package/dist/file-provider/node.js +65 -0
- package/dist/file-provider/node.js.map +1 -0
- package/dist/file-provider/types.d.ts +69 -0
- package/dist/file-provider/types.d.ts.map +1 -0
- package/dist/file-provider/types.js +47 -0
- package/dist/file-provider/types.js.map +1 -0
- package/dist/file-provider/web.d.ts +32 -0
- package/dist/file-provider/web.d.ts.map +1 -0
- package/dist/file-provider/web.js +77 -0
- package/dist/file-provider/web.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/parse/AsideHtmlParser.d.ts +12 -0
- package/dist/parse/AsideHtmlParser.d.ts.map +1 -0
- package/dist/parse/AsideHtmlParser.js +74 -0
- package/dist/parse/AsideHtmlParser.js.map +1 -0
- package/dist/parse/BlockquoteHtmlParser.d.ts +11 -0
- package/dist/parse/BlockquoteHtmlParser.d.ts.map +1 -0
- package/dist/parse/BlockquoteHtmlParser.js +28 -0
- package/dist/parse/BlockquoteHtmlParser.js.map +1 -0
- package/dist/parse/BlockquoteMarkdownParser.d.ts +11 -0
- package/dist/parse/BlockquoteMarkdownParser.d.ts.map +1 -0
- package/dist/parse/BlockquoteMarkdownParser.js +26 -0
- package/dist/parse/BlockquoteMarkdownParser.js.map +1 -0
- package/dist/parse/CodeHtmlParser.d.ts +11 -0
- package/dist/parse/CodeHtmlParser.d.ts.map +1 -0
- package/dist/parse/CodeHtmlParser.js +38 -0
- package/dist/parse/CodeHtmlParser.js.map +1 -0
- package/dist/parse/CodeMarkdownParser.d.ts +11 -0
- package/dist/parse/CodeMarkdownParser.d.ts.map +1 -0
- package/dist/parse/CodeMarkdownParser.js +29 -0
- package/dist/parse/CodeMarkdownParser.js.map +1 -0
- package/dist/parse/DfnHtmlParser.d.ts +12 -0
- package/dist/parse/DfnHtmlParser.d.ts.map +1 -0
- package/dist/parse/DfnHtmlParser.js +53 -0
- package/dist/parse/DfnHtmlParser.js.map +1 -0
- package/dist/parse/HeadingsHtmlParser.d.ts +11 -0
- package/dist/parse/HeadingsHtmlParser.d.ts.map +1 -0
- package/dist/parse/HeadingsHtmlParser.js +30 -0
- package/dist/parse/HeadingsHtmlParser.js.map +1 -0
- package/dist/parse/HeadingsMarkdownParser.d.ts +11 -0
- package/dist/parse/HeadingsMarkdownParser.d.ts.map +1 -0
- package/dist/parse/HeadingsMarkdownParser.js +26 -0
- package/dist/parse/HeadingsMarkdownParser.js.map +1 -0
- package/dist/parse/InlinesHtmlParser.d.ts +12 -0
- package/dist/parse/InlinesHtmlParser.d.ts.map +1 -0
- package/dist/parse/InlinesHtmlParser.js +150 -0
- package/dist/parse/InlinesHtmlParser.js.map +1 -0
- package/dist/parse/InlinesMarkdownParser.d.ts +11 -0
- package/dist/parse/InlinesMarkdownParser.d.ts.map +1 -0
- package/dist/parse/InlinesMarkdownParser.js +91 -0
- package/dist/parse/InlinesMarkdownParser.js.map +1 -0
- package/dist/parse/ListsHtmlParser.d.ts +11 -0
- package/dist/parse/ListsHtmlParser.d.ts.map +1 -0
- package/dist/parse/ListsHtmlParser.js +71 -0
- package/dist/parse/ListsHtmlParser.js.map +1 -0
- package/dist/parse/ListsMarkdownParser.d.ts +11 -0
- package/dist/parse/ListsMarkdownParser.d.ts.map +1 -0
- package/dist/parse/ListsMarkdownParser.js +46 -0
- package/dist/parse/ListsMarkdownParser.js.map +1 -0
- package/dist/parse/MiscHtmlParser.d.ts +12 -0
- package/dist/parse/MiscHtmlParser.d.ts.map +1 -0
- package/dist/parse/MiscHtmlParser.js +85 -0
- package/dist/parse/MiscHtmlParser.js.map +1 -0
- package/dist/parse/MiscMarkdownParser.d.ts +11 -0
- package/dist/parse/MiscMarkdownParser.d.ts.map +1 -0
- package/dist/parse/MiscMarkdownParser.js +38 -0
- package/dist/parse/MiscMarkdownParser.js.map +1 -0
- package/dist/parse/ParagraphsHtmlParser.d.ts +11 -0
- package/dist/parse/ParagraphsHtmlParser.d.ts.map +1 -0
- package/dist/parse/ParagraphsHtmlParser.js +30 -0
- package/dist/parse/ParagraphsHtmlParser.js.map +1 -0
- package/dist/parse/ParagraphsMarkdownParser.d.ts +11 -0
- package/dist/parse/ParagraphsMarkdownParser.d.ts.map +1 -0
- package/dist/parse/ParagraphsMarkdownParser.js +25 -0
- package/dist/parse/ParagraphsMarkdownParser.js.map +1 -0
- package/dist/parse/SectionsHtmlParser.d.ts +12 -0
- package/dist/parse/SectionsHtmlParser.d.ts.map +1 -0
- package/dist/parse/SectionsHtmlParser.js +58 -0
- package/dist/parse/SectionsHtmlParser.js.map +1 -0
- package/dist/parse/TablesHtmlParser.d.ts +11 -0
- package/dist/parse/TablesHtmlParser.d.ts.map +1 -0
- package/dist/parse/TablesHtmlParser.js +81 -0
- package/dist/parse/TablesHtmlParser.js.map +1 -0
- package/dist/parse/TablesMarkdownParser.d.ts +11 -0
- package/dist/parse/TablesMarkdownParser.d.ts.map +1 -0
- package/dist/parse/TablesMarkdownParser.js +56 -0
- package/dist/parse/TablesMarkdownParser.js.map +1 -0
- package/dist/parse/XrefHtmlParser.d.ts +12 -0
- package/dist/parse/XrefHtmlParser.d.ts.map +1 -0
- package/dist/parse/XrefHtmlParser.js +124 -0
- package/dist/parse/XrefHtmlParser.js.map +1 -0
- package/dist/parse/__tests__/assembler.test.d.ts +5 -0
- package/dist/parse/__tests__/assembler.test.d.ts.map +1 -0
- package/dist/parse/__tests__/assembler.test.js +135 -0
- package/dist/parse/__tests__/assembler.test.js.map +1 -0
- package/dist/parse/__tests__/html.test.d.ts +5 -0
- package/dist/parse/__tests__/html.test.d.ts.map +1 -0
- package/dist/parse/__tests__/html.test.js +149 -0
- package/dist/parse/__tests__/html.test.js.map +1 -0
- package/dist/parse/__tests__/markdown.test.d.ts +5 -0
- package/dist/parse/__tests__/markdown.test.d.ts.map +1 -0
- package/dist/parse/__tests__/markdown.test.js +133 -0
- package/dist/parse/__tests__/markdown.test.js.map +1 -0
- package/dist/parse/__tests__/pipeline.test.d.ts +5 -0
- package/dist/parse/__tests__/pipeline.test.d.ts.map +1 -0
- package/dist/parse/__tests__/pipeline.test.js +215 -0
- package/dist/parse/__tests__/pipeline.test.js.map +1 -0
- package/dist/parse/__tests__/respec.test.d.ts +7 -0
- package/dist/parse/__tests__/respec.test.d.ts.map +1 -0
- package/dist/parse/__tests__/respec.test.js +151 -0
- package/dist/parse/__tests__/respec.test.js.map +1 -0
- package/dist/parse/assembler.d.ts +20 -0
- package/dist/parse/assembler.d.ts.map +1 -0
- package/dist/parse/assembler.js +175 -0
- package/dist/parse/assembler.js.map +1 -0
- package/dist/parse/html/AsideHtmlParser.d.ts +12 -0
- package/dist/parse/html/AsideHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/AsideHtmlParser.js +74 -0
- package/dist/parse/html/AsideHtmlParser.js.map +1 -0
- package/dist/parse/html/BlockquoteHtmlParser.d.ts +11 -0
- package/dist/parse/html/BlockquoteHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/BlockquoteHtmlParser.js +28 -0
- package/dist/parse/html/BlockquoteHtmlParser.js.map +1 -0
- package/dist/parse/html/CodeHtmlParser.d.ts +11 -0
- package/dist/parse/html/CodeHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/CodeHtmlParser.js +38 -0
- package/dist/parse/html/CodeHtmlParser.js.map +1 -0
- package/dist/parse/html/DfnHtmlParser.d.ts +12 -0
- package/dist/parse/html/DfnHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/DfnHtmlParser.js +53 -0
- package/dist/parse/html/DfnHtmlParser.js.map +1 -0
- package/dist/parse/html/HeadingsHtmlParser.d.ts +11 -0
- package/dist/parse/html/HeadingsHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/HeadingsHtmlParser.js +30 -0
- package/dist/parse/html/HeadingsHtmlParser.js.map +1 -0
- package/dist/parse/html/InlinesHtmlParser.d.ts +12 -0
- package/dist/parse/html/InlinesHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/InlinesHtmlParser.js +150 -0
- package/dist/parse/html/InlinesHtmlParser.js.map +1 -0
- package/dist/parse/html/ListsHtmlParser.d.ts +11 -0
- package/dist/parse/html/ListsHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/ListsHtmlParser.js +71 -0
- package/dist/parse/html/ListsHtmlParser.js.map +1 -0
- package/dist/parse/html/MiscHtmlParser.d.ts +12 -0
- package/dist/parse/html/MiscHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/MiscHtmlParser.js +85 -0
- package/dist/parse/html/MiscHtmlParser.js.map +1 -0
- package/dist/parse/html/ParagraphsHtmlParser.d.ts +11 -0
- package/dist/parse/html/ParagraphsHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/ParagraphsHtmlParser.js +30 -0
- package/dist/parse/html/ParagraphsHtmlParser.js.map +1 -0
- package/dist/parse/html/SectionsHtmlParser.d.ts +12 -0
- package/dist/parse/html/SectionsHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/SectionsHtmlParser.js +58 -0
- package/dist/parse/html/SectionsHtmlParser.js.map +1 -0
- package/dist/parse/html/TablesHtmlParser.d.ts +11 -0
- package/dist/parse/html/TablesHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/TablesHtmlParser.js +81 -0
- package/dist/parse/html/TablesHtmlParser.js.map +1 -0
- package/dist/parse/html/XrefHtmlParser.d.ts +12 -0
- package/dist/parse/html/XrefHtmlParser.d.ts.map +1 -0
- package/dist/parse/html/XrefHtmlParser.js +125 -0
- package/dist/parse/html/XrefHtmlParser.js.map +1 -0
- package/dist/parse/html/handlers/blockquote.d.ts +9 -0
- package/dist/parse/html/handlers/blockquote.d.ts.map +1 -0
- package/dist/parse/html/handlers/blockquote.js +21 -0
- package/dist/parse/html/handlers/blockquote.js.map +1 -0
- package/dist/parse/html/handlers/code.d.ts +9 -0
- package/dist/parse/html/handlers/code.d.ts.map +1 -0
- package/dist/parse/html/handlers/code.js +31 -0
- package/dist/parse/html/handlers/code.js.map +1 -0
- package/dist/parse/html/handlers/containers.d.ts +16 -0
- package/dist/parse/html/handlers/containers.d.ts.map +1 -0
- package/dist/parse/html/handlers/containers.js +25 -0
- package/dist/parse/html/handlers/containers.js.map +1 -0
- package/dist/parse/html/handlers/heading.d.ts +9 -0
- package/dist/parse/html/handlers/heading.d.ts.map +1 -0
- package/dist/parse/html/handlers/heading.js +26 -0
- package/dist/parse/html/handlers/heading.js.map +1 -0
- package/dist/parse/html/handlers/index.d.ts +23 -0
- package/dist/parse/html/handlers/index.d.ts.map +1 -0
- package/dist/parse/html/handlers/index.js +47 -0
- package/dist/parse/html/handlers/index.js.map +1 -0
- package/dist/parse/html/handlers/inline.d.ts +35 -0
- package/dist/parse/html/handlers/inline.d.ts.map +1 -0
- package/dist/parse/html/handlers/inline.js +119 -0
- package/dist/parse/html/handlers/inline.js.map +1 -0
- package/dist/parse/html/handlers/list.d.ts +9 -0
- package/dist/parse/html/handlers/list.d.ts.map +1 -0
- package/dist/parse/html/handlers/list.js +63 -0
- package/dist/parse/html/handlers/list.js.map +1 -0
- package/dist/parse/html/handlers/paragraph.d.ts +9 -0
- package/dist/parse/html/handlers/paragraph.d.ts.map +1 -0
- package/dist/parse/html/handlers/paragraph.js +20 -0
- package/dist/parse/html/handlers/paragraph.js.map +1 -0
- package/dist/parse/html/handlers/section.d.ts +9 -0
- package/dist/parse/html/handlers/section.d.ts.map +1 -0
- package/dist/parse/html/handlers/section.js +53 -0
- package/dist/parse/html/handlers/section.js.map +1 -0
- package/dist/parse/html/index.d.ts +5 -0
- package/dist/parse/html/index.d.ts.map +1 -0
- package/dist/parse/html/index.js +12 -0
- package/dist/parse/html/index.js.map +1 -0
- package/dist/parse/html/parser.d.ts +51 -0
- package/dist/parse/html/parser.d.ts.map +1 -0
- package/dist/parse/html/parser.js +228 -0
- package/dist/parse/html/parser.js.map +1 -0
- package/dist/parse/index.d.ts +16 -0
- package/dist/parse/index.d.ts.map +1 -0
- package/dist/parse/index.js +19 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/parse/markdown/BlockquoteMarkdownParser.d.ts +11 -0
- package/dist/parse/markdown/BlockquoteMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/BlockquoteMarkdownParser.js +26 -0
- package/dist/parse/markdown/BlockquoteMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/CodeMarkdownParser.d.ts +11 -0
- package/dist/parse/markdown/CodeMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/CodeMarkdownParser.js +29 -0
- package/dist/parse/markdown/CodeMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/HeadingsMarkdownParser.d.ts +11 -0
- package/dist/parse/markdown/HeadingsMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/HeadingsMarkdownParser.js +26 -0
- package/dist/parse/markdown/HeadingsMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/InlinesMarkdownParser.d.ts +11 -0
- package/dist/parse/markdown/InlinesMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/InlinesMarkdownParser.js +91 -0
- package/dist/parse/markdown/InlinesMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/ListsMarkdownParser.d.ts +11 -0
- package/dist/parse/markdown/ListsMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/ListsMarkdownParser.js +46 -0
- package/dist/parse/markdown/ListsMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/MiscMarkdownParser.d.ts +11 -0
- package/dist/parse/markdown/MiscMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/MiscMarkdownParser.js +38 -0
- package/dist/parse/markdown/MiscMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/ParagraphsMarkdownParser.d.ts +11 -0
- package/dist/parse/markdown/ParagraphsMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/ParagraphsMarkdownParser.js +25 -0
- package/dist/parse/markdown/ParagraphsMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/TablesMarkdownParser.d.ts +11 -0
- package/dist/parse/markdown/TablesMarkdownParser.d.ts.map +1 -0
- package/dist/parse/markdown/TablesMarkdownParser.js +56 -0
- package/dist/parse/markdown/TablesMarkdownParser.js.map +1 -0
- package/dist/parse/markdown/handlers/blockquote.d.ts +9 -0
- package/dist/parse/markdown/handlers/blockquote.d.ts.map +1 -0
- package/dist/parse/markdown/handlers/blockquote.js +22 -0
- package/dist/parse/markdown/handlers/blockquote.js.map +1 -0
- package/dist/parse/markdown/handlers/code.d.ts +9 -0
- package/dist/parse/markdown/handlers/code.d.ts.map +1 -0
- package/dist/parse/markdown/handlers/code.js +25 -0
- package/dist/parse/markdown/handlers/code.js.map +1 -0
- package/dist/parse/markdown/handlers/heading.d.ts +9 -0
- package/dist/parse/markdown/handlers/heading.d.ts.map +1 -0
- package/dist/parse/markdown/handlers/heading.js +22 -0
- package/dist/parse/markdown/handlers/heading.js.map +1 -0
- package/dist/parse/markdown/handlers/index.d.ts +23 -0
- package/dist/parse/markdown/handlers/index.d.ts.map +1 -0
- package/dist/parse/markdown/handlers/index.js +47 -0
- package/dist/parse/markdown/handlers/index.js.map +1 -0
- package/dist/parse/markdown/handlers/inline.d.ts +35 -0
- package/dist/parse/markdown/handlers/inline.d.ts.map +1 -0
- package/dist/parse/markdown/handlers/inline.js +126 -0
- package/dist/parse/markdown/handlers/inline.js.map +1 -0
- package/dist/parse/markdown/handlers/list.d.ts +9 -0
- package/dist/parse/markdown/handlers/list.d.ts.map +1 -0
- package/dist/parse/markdown/handlers/list.js +42 -0
- package/dist/parse/markdown/handlers/list.js.map +1 -0
- package/dist/parse/markdown/handlers/misc.d.ts +15 -0
- package/dist/parse/markdown/handlers/misc.d.ts.map +1 -0
- package/dist/parse/markdown/handlers/misc.js +38 -0
- package/dist/parse/markdown/handlers/misc.js.map +1 -0
- package/dist/parse/markdown/handlers/paragraph.d.ts +9 -0
- package/dist/parse/markdown/handlers/paragraph.d.ts.map +1 -0
- package/dist/parse/markdown/handlers/paragraph.js +21 -0
- package/dist/parse/markdown/handlers/paragraph.js.map +1 -0
- package/dist/parse/markdown/handlers/table.d.ts +9 -0
- package/dist/parse/markdown/handlers/table.d.ts.map +1 -0
- package/dist/parse/markdown/handlers/table.js +52 -0
- package/dist/parse/markdown/handlers/table.js.map +1 -0
- package/dist/parse/markdown/index.d.ts +5 -0
- package/dist/parse/markdown/index.d.ts.map +1 -0
- package/dist/parse/markdown/index.js +12 -0
- package/dist/parse/markdown/index.js.map +1 -0
- package/dist/parse/markdown/parser.d.ts +51 -0
- package/dist/parse/markdown/parser.d.ts.map +1 -0
- package/dist/parse/markdown/parser.js +134 -0
- package/dist/parse/markdown/parser.js.map +1 -0
- package/dist/parse/normalize.d.ts +51 -0
- package/dist/parse/normalize.d.ts.map +1 -0
- package/dist/parse/normalize.js +78 -0
- package/dist/parse/normalize.js.map +1 -0
- package/dist/parse/parsers.d.ts +37 -0
- package/dist/parse/parsers.d.ts.map +1 -0
- package/dist/parse/parsers.js +86 -0
- package/dist/parse/parsers.js.map +1 -0
- package/dist/parse/pipeline.d.ts +41 -0
- package/dist/parse/pipeline.d.ts.map +1 -0
- package/dist/parse/pipeline.js +120 -0
- package/dist/parse/pipeline.js.map +1 -0
- package/dist/parse/registry.d.ts +156 -0
- package/dist/parse/registry.d.ts.map +1 -0
- package/dist/parse/registry.js +104 -0
- package/dist/parse/registry.js.map +1 -0
- package/dist/parse/types.d.ts +67 -0
- package/dist/parse/types.d.ts.map +1 -0
- package/dist/parse/types.js +19 -0
- package/dist/parse/types.js.map +1 -0
- package/dist/pipeline/__tests__/pipeline.test.d.ts +5 -0
- package/dist/pipeline/__tests__/pipeline.test.d.ts.map +1 -0
- package/dist/pipeline/__tests__/pipeline.test.js +69 -0
- package/dist/pipeline/__tests__/pipeline.test.js.map +1 -0
- package/dist/pipeline/__tests__/single-as-workspace.test.d.ts +2 -0
- package/dist/pipeline/__tests__/single-as-workspace.test.d.ts.map +1 -0
- package/dist/pipeline/__tests__/single-as-workspace.test.js +19 -0
- package/dist/pipeline/__tests__/single-as-workspace.test.js.map +1 -0
- package/dist/pipeline/__tests__/workspace-rules.test.d.ts +11 -0
- package/dist/pipeline/__tests__/workspace-rules.test.d.ts.map +1 -0
- package/dist/pipeline/__tests__/workspace-rules.test.js +54 -0
- package/dist/pipeline/__tests__/workspace-rules.test.js.map +1 -0
- package/dist/pipeline/__tests__/workspace.test.d.ts +2 -0
- package/dist/pipeline/__tests__/workspace.test.d.ts.map +1 -0
- package/dist/pipeline/__tests__/workspace.test.js +61 -0
- package/dist/pipeline/__tests__/workspace.test.js.map +1 -0
- package/dist/pipeline/index.d.ts +34 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +45 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/runner.d.ts +38 -0
- package/dist/pipeline/runner.d.ts.map +1 -0
- package/dist/pipeline/runner.js +128 -0
- package/dist/pipeline/runner.js.map +1 -0
- package/dist/pipeline/types.d.ts +106 -0
- package/dist/pipeline/types.d.ts.map +1 -0
- package/dist/pipeline/types.js +9 -0
- package/dist/pipeline/types.js.map +1 -0
- package/dist/pipeline/workspace-index.d.ts +11 -0
- package/dist/pipeline/workspace-index.d.ts.map +1 -0
- package/dist/pipeline/workspace-index.js +57 -0
- package/dist/pipeline/workspace-index.js.map +1 -0
- package/dist/plugins/__tests__/citation-transform.test.d.ts +7 -0
- package/dist/plugins/__tests__/citation-transform.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/citation-transform.test.js +89 -0
- package/dist/plugins/__tests__/citation-transform.test.js.map +1 -0
- package/dist/plugins/__tests__/dfn-parsing.test.d.ts +2 -0
- package/dist/plugins/__tests__/dfn-parsing.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/dfn-parsing.test.js +65 -0
- package/dist/plugins/__tests__/dfn-parsing.test.js.map +1 -0
- package/dist/plugins/__tests__/dfn-resolve.test.d.ts +5 -0
- package/dist/plugins/__tests__/dfn-resolve.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/dfn-resolve.test.js +152 -0
- package/dist/plugins/__tests__/dfn-resolve.test.js.map +1 -0
- package/dist/plugins/__tests__/xref-parsing.test.d.ts +2 -0
- package/dist/plugins/__tests__/xref-parsing.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/xref-parsing.test.js +66 -0
- package/dist/plugins/__tests__/xref-parsing.test.js.map +1 -0
- package/dist/plugins/aside.d.ts +12 -0
- package/dist/plugins/aside.d.ts.map +1 -0
- package/dist/plugins/aside.js +78 -0
- package/dist/plugins/aside.js.map +1 -0
- package/dist/plugins/blockquote.d.ts +11 -0
- package/dist/plugins/blockquote.d.ts.map +1 -0
- package/dist/plugins/blockquote.js +47 -0
- package/dist/plugins/blockquote.js.map +1 -0
- package/dist/plugins/citation-transform.d.ts +19 -0
- package/dist/plugins/citation-transform.d.ts.map +1 -0
- package/dist/plugins/citation-transform.js +176 -0
- package/dist/plugins/citation-transform.js.map +1 -0
- package/dist/plugins/citation.d.ts +21 -0
- package/dist/plugins/citation.d.ts.map +1 -0
- package/dist/plugins/citation.js +131 -0
- package/dist/plugins/citation.js.map +1 -0
- package/dist/plugins/code.d.ts +11 -0
- package/dist/plugins/code.d.ts.map +1 -0
- package/dist/plugins/code.js +60 -0
- package/dist/plugins/code.js.map +1 -0
- package/dist/plugins/core-html.d.ts +27 -0
- package/dist/plugins/core-html.d.ts.map +1 -0
- package/dist/plugins/core-html.js +53 -0
- package/dist/plugins/core-html.js.map +1 -0
- package/dist/plugins/core-markdown.d.ts +26 -0
- package/dist/plugins/core-markdown.d.ts.map +1 -0
- package/dist/plugins/core-markdown.js +55 -0
- package/dist/plugins/core-markdown.js.map +1 -0
- package/dist/plugins/data-cite.d.ts +12 -0
- package/dist/plugins/data-cite.d.ts.map +1 -0
- package/dist/plugins/data-cite.js +50 -0
- package/dist/plugins/data-cite.js.map +1 -0
- package/dist/plugins/dfn-resolve.d.ts +15 -0
- package/dist/plugins/dfn-resolve.d.ts.map +1 -0
- package/dist/plugins/dfn-resolve.js +257 -0
- package/dist/plugins/dfn-resolve.js.map +1 -0
- package/dist/plugins/dfn.d.ts +12 -0
- package/dist/plugins/dfn.d.ts.map +1 -0
- package/dist/plugins/dfn.js +57 -0
- package/dist/plugins/dfn.js.map +1 -0
- package/dist/plugins/directives.d.ts +8 -0
- package/dist/plugins/directives.d.ts.map +1 -0
- package/dist/plugins/directives.js +34 -0
- package/dist/plugins/directives.js.map +1 -0
- package/dist/plugins/heading.d.ts +11 -0
- package/dist/plugins/heading.d.ts.map +1 -0
- package/dist/plugins/heading.js +49 -0
- package/dist/plugins/heading.js.map +1 -0
- package/dist/plugins/index.d.ts +12 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +26 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/inline.d.ts +12 -0
- package/dist/plugins/inline.d.ts.map +1 -0
- package/dist/plugins/inline.js +234 -0
- package/dist/plugins/inline.js.map +1 -0
- package/dist/plugins/list.d.ts +11 -0
- package/dist/plugins/list.d.ts.map +1 -0
- package/dist/plugins/list.js +110 -0
- package/dist/plugins/list.js.map +1 -0
- package/dist/plugins/misc.d.ts +12 -0
- package/dist/plugins/misc.d.ts.map +1 -0
- package/dist/plugins/misc.js +116 -0
- package/dist/plugins/misc.js.map +1 -0
- package/dist/plugins/paragraph.d.ts +11 -0
- package/dist/plugins/paragraph.d.ts.map +1 -0
- package/dist/plugins/paragraph.js +48 -0
- package/dist/plugins/paragraph.js.map +1 -0
- package/dist/plugins/section.d.ts +12 -0
- package/dist/plugins/section.d.ts.map +1 -0
- package/dist/plugins/section.js +62 -0
- package/dist/plugins/section.js.map +1 -0
- package/dist/plugins/table.d.ts +11 -0
- package/dist/plugins/table.d.ts.map +1 -0
- package/dist/plugins/table.js +130 -0
- package/dist/plugins/table.js.map +1 -0
- package/dist/plugins/xref.d.ts +12 -0
- package/dist/plugins/xref.d.ts.map +1 -0
- package/dist/plugins/xref.js +92 -0
- package/dist/plugins/xref.js.map +1 -0
- package/dist/postprocess/__tests__/citation-transform.test.d.ts +7 -0
- package/dist/postprocess/__tests__/citation-transform.test.d.ts.map +1 -0
- package/dist/postprocess/__tests__/citation-transform.test.js +89 -0
- package/dist/postprocess/__tests__/citation-transform.test.js.map +1 -0
- package/dist/postprocess/__tests__/dfn-resolve.test.d.ts +5 -0
- package/dist/postprocess/__tests__/dfn-resolve.test.d.ts.map +1 -0
- package/dist/postprocess/__tests__/dfn-resolve.test.js +160 -0
- package/dist/postprocess/__tests__/dfn-resolve.test.js.map +1 -0
- package/dist/postprocess/__tests__/section-id.test.d.ts +5 -0
- package/dist/postprocess/__tests__/section-id.test.d.ts.map +1 -0
- package/dist/postprocess/__tests__/section-id.test.js +222 -0
- package/dist/postprocess/__tests__/section-id.test.js.map +1 -0
- package/dist/postprocess/citation-transform.d.ts +19 -0
- package/dist/postprocess/citation-transform.d.ts.map +1 -0
- package/dist/postprocess/citation-transform.js +176 -0
- package/dist/postprocess/citation-transform.js.map +1 -0
- package/dist/postprocess/dfn-index.d.ts +16 -0
- package/dist/postprocess/dfn-index.d.ts.map +1 -0
- package/dist/postprocess/dfn-index.js +72 -0
- package/dist/postprocess/dfn-index.js.map +1 -0
- package/dist/postprocess/dfn-resolve.d.ts +15 -0
- package/dist/postprocess/dfn-resolve.d.ts.map +1 -0
- package/dist/postprocess/dfn-resolve.js +257 -0
- package/dist/postprocess/dfn-resolve.js.map +1 -0
- package/dist/postprocess/index.d.ts +15 -0
- package/dist/postprocess/index.d.ts.map +1 -0
- package/dist/postprocess/index.js +36 -0
- package/dist/postprocess/index.js.map +1 -0
- package/dist/postprocess/plugins/citation-transform.d.ts +19 -0
- package/dist/postprocess/plugins/citation-transform.d.ts.map +1 -0
- package/dist/postprocess/plugins/citation-transform.js +179 -0
- package/dist/postprocess/plugins/citation-transform.js.map +1 -0
- package/dist/postprocess/plugins/dfn-index.d.ts +16 -0
- package/dist/postprocess/plugins/dfn-index.d.ts.map +1 -0
- package/dist/postprocess/plugins/dfn-index.js +76 -0
- package/dist/postprocess/plugins/dfn-index.js.map +1 -0
- package/dist/postprocess/plugins/reference-resolve.d.ts +19 -0
- package/dist/postprocess/plugins/reference-resolve.d.ts.map +1 -0
- package/dist/postprocess/plugins/reference-resolve.js +103 -0
- package/dist/postprocess/plugins/reference-resolve.js.map +1 -0
- package/dist/postprocess/plugins/section-id.d.ts +16 -0
- package/dist/postprocess/plugins/section-id.d.ts.map +1 -0
- package/dist/postprocess/plugins/section-id.js +116 -0
- package/dist/postprocess/plugins/section-id.js.map +1 -0
- package/dist/postprocess/plugins/walk-ast.d.ts +38 -0
- package/dist/postprocess/plugins/walk-ast.d.ts.map +1 -0
- package/dist/postprocess/plugins/walk-ast.js +92 -0
- package/dist/postprocess/plugins/walk-ast.js.map +1 -0
- package/dist/postprocess/reference-resolve.d.ts +19 -0
- package/dist/postprocess/reference-resolve.d.ts.map +1 -0
- package/dist/postprocess/reference-resolve.js +105 -0
- package/dist/postprocess/reference-resolve.js.map +1 -0
- package/dist/postprocess/walk-ast.d.ts +38 -0
- package/dist/postprocess/walk-ast.d.ts.map +1 -0
- package/dist/postprocess/walk-ast.js +94 -0
- package/dist/postprocess/walk-ast.js.map +1 -0
- package/dist/preprocess/__tests__/pipeline.test.d.ts +5 -0
- package/dist/preprocess/__tests__/pipeline.test.d.ts.map +1 -0
- package/dist/preprocess/__tests__/pipeline.test.js +188 -0
- package/dist/preprocess/__tests__/pipeline.test.js.map +1 -0
- package/dist/preprocess/__tests__/resolver.test.d.ts +5 -0
- package/dist/preprocess/__tests__/resolver.test.d.ts.map +1 -0
- package/dist/preprocess/__tests__/resolver.test.js +165 -0
- package/dist/preprocess/__tests__/resolver.test.js.map +1 -0
- package/dist/preprocess/__tests__/scan-html.test.d.ts +5 -0
- package/dist/preprocess/__tests__/scan-html.test.d.ts.map +1 -0
- package/dist/preprocess/__tests__/scan-html.test.js +99 -0
- package/dist/preprocess/__tests__/scan-html.test.js.map +1 -0
- package/dist/preprocess/__tests__/scan-markdown.test.d.ts +5 -0
- package/dist/preprocess/__tests__/scan-markdown.test.d.ts.map +1 -0
- package/dist/preprocess/__tests__/scan-markdown.test.js +92 -0
- package/dist/preprocess/__tests__/scan-markdown.test.js.map +1 -0
- package/dist/preprocess/config/doc-config.d.ts +30 -0
- package/dist/preprocess/config/doc-config.d.ts.map +1 -0
- package/dist/preprocess/config/doc-config.js +85 -0
- package/dist/preprocess/config/doc-config.js.map +1 -0
- package/dist/preprocess/config/index.d.ts +9 -0
- package/dist/preprocess/config/index.d.ts.map +1 -0
- package/dist/preprocess/config/index.js +7 -0
- package/dist/preprocess/config/index.js.map +1 -0
- package/dist/preprocess/config/loader.d.ts +61 -0
- package/dist/preprocess/config/loader.d.ts.map +1 -0
- package/dist/preprocess/config/loader.js +40 -0
- package/dist/preprocess/config/loader.js.map +1 -0
- package/dist/preprocess/config/normalize.d.ts +19 -0
- package/dist/preprocess/config/normalize.d.ts.map +1 -0
- package/dist/preprocess/config/normalize.js +106 -0
- package/dist/preprocess/config/normalize.js.map +1 -0
- package/dist/preprocess/config/types.d.ts +40 -0
- package/dist/preprocess/config/types.d.ts.map +1 -0
- package/dist/preprocess/config/types.js +8 -0
- package/dist/preprocess/config/types.js.map +1 -0
- package/dist/preprocess/include/index.d.ts +7 -0
- package/dist/preprocess/include/index.d.ts.map +1 -0
- package/dist/preprocess/include/index.js +7 -0
- package/dist/preprocess/include/index.js.map +1 -0
- package/dist/preprocess/include/resolver.d.ts +40 -0
- package/dist/preprocess/include/resolver.d.ts.map +1 -0
- package/dist/preprocess/include/resolver.js +187 -0
- package/dist/preprocess/include/resolver.js.map +1 -0
- package/dist/preprocess/include/scan-html.d.ts +31 -0
- package/dist/preprocess/include/scan-html.d.ts.map +1 -0
- package/dist/preprocess/include/scan-html.js +100 -0
- package/dist/preprocess/include/scan-html.js.map +1 -0
- package/dist/preprocess/include/scan-markdown.d.ts +31 -0
- package/dist/preprocess/include/scan-markdown.d.ts.map +1 -0
- package/dist/preprocess/include/scan-markdown.js +83 -0
- package/dist/preprocess/include/scan-markdown.js.map +1 -0
- package/dist/preprocess/index.d.ts +16 -0
- package/dist/preprocess/index.d.ts.map +1 -0
- package/dist/preprocess/index.js +16 -0
- package/dist/preprocess/index.js.map +1 -0
- package/dist/preprocess/pipeline.d.ts +57 -0
- package/dist/preprocess/pipeline.d.ts.map +1 -0
- package/dist/preprocess/pipeline.js +100 -0
- package/dist/preprocess/pipeline.js.map +1 -0
- package/dist/preprocess/types.d.ts +197 -0
- package/dist/preprocess/types.d.ts.map +1 -0
- package/dist/preprocess/types.js +22 -0
- package/dist/preprocess/types.js.map +1 -0
- package/dist/types/ast.generated.d.ts +517 -0
- package/dist/types/ast.generated.d.ts.map +1 -0
- package/dist/types/ast.generated.js +66 -0
- package/dist/types/ast.generated.js.map +1 -0
- package/dist/validation/validate.d.ts +86 -0
- package/dist/validation/validate.d.ts.map +1 -0
- package/dist/validation/validate.js +162 -0
- package/dist/validation/validate.js.map +1 -0
- package/dist/workspace/__tests__/sort.test.d.ts +2 -0
- package/dist/workspace/__tests__/sort.test.d.ts.map +1 -0
- package/dist/workspace/__tests__/sort.test.js +122 -0
- package/dist/workspace/__tests__/sort.test.js.map +1 -0
- package/dist/workspace/index.d.ts +8 -0
- package/dist/workspace/index.d.ts.map +1 -0
- package/dist/workspace/index.js +7 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/sort.d.ts +49 -0
- package/dist/workspace/sort.d.ts.map +1 -0
- package/dist/workspace/sort.js +114 -0
- package/dist/workspace/sort.js.map +1 -0
- package/package.json +46 -81
- package/schema/spec-ast.schema.json +1440 -0
- package/bin/speculator.mjs +0 -76
- package/dist/browser.cjs +0 -1693
- package/dist/browser.d.cts +0 -416
- package/dist/browser.d.ts +0 -416
- package/dist/browser.js +0 -36
- package/dist/chunk-KC3NVWHK.js +0 -28
- package/dist/chunk-ONLMOJIJ.js +0 -1649
- package/dist/cli/export-assertions.cjs +0 -1713
- package/dist/cli/export-assertions.d.cts +0 -25
- package/dist/cli/export-assertions.d.ts +0 -25
- package/dist/cli/export-assertions.js +0 -107
- package/dist/node.cjs +0 -1715
- package/dist/node.d.cts +0 -17
- package/dist/node.d.ts +0 -17
- package/dist/node.js +0 -40
package/README.md
CHANGED
|
@@ -1,73 +1,134 @@
|
|
|
1
1
|
# Speculator
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
AST-first specification parser and indexer with schema-central architecture.
|
|
4
4
|
|
|
5
|
+
Speculator transforms specification documents (Markdown or HTML) into structured AST and semantic indexes. It does **not** render output - that responsibility belongs to separate tools. Speculator provides optional JSON serialization of the AST and indexes for consumption by renderers, linters, or other processors.
|
|
5
6
|
|
|
6
|
-
##
|
|
7
|
+
## Schema Architecture
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
pnpm install -D @openui/speculator linkdom
|
|
10
|
-
```
|
|
9
|
+
The AST JSON Schema (`schema/spec-ast.schema.json`) is the single source of truth. All pipeline outputs validate against it.
|
|
11
10
|
|
|
11
|
+
### Core Node Types
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
| Type | Description |
|
|
14
|
+
|------|-------------|
|
|
15
|
+
| `Document` | Root container with metadata, sections, and indexes |
|
|
16
|
+
| `Section` | Grouping with optional heading, supports nesting |
|
|
17
|
+
| `Block` | Block-level: paragraph, heading, codeBlock, example, blockquote, list, table, thematicBreak, html |
|
|
18
|
+
| `Inline` | Inline: text, emphasis, strong, inlineCode, link, image, definition, reference, requirement, issue |
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
speculator/
|
|
17
|
-
├── src/
|
|
18
|
-
│ ├── index.ts
|
|
19
|
-
│ ├── renderer.ts
|
|
20
|
-
│ ├── types.ts
|
|
21
|
-
│ └── utils/
|
|
22
|
-
│ ├── markdown.ts
|
|
23
|
-
│ └── file-loader.ts
|
|
24
|
-
├── tests/
|
|
25
|
-
│ ├── renderer.test.ts
|
|
26
|
-
│ └── fixtures/
|
|
27
|
-
│ ├── intro.md
|
|
28
|
-
│ ├── smooth-scroller.md
|
|
29
|
-
│ └── ujse.webidl
|
|
30
|
-
├── dist/
|
|
31
|
-
├── package.json
|
|
32
|
-
├── tsconfig.json
|
|
33
|
-
├── jest.config.js
|
|
34
|
-
├── .npmignore
|
|
35
|
-
└── README.md
|
|
36
|
-
```
|
|
20
|
+
### Index Markers (Inline)
|
|
37
21
|
|
|
38
|
-
|
|
22
|
+
Indexes are extracted from inline markers during the post-parse `index` phase:
|
|
39
23
|
|
|
40
|
-
|
|
41
|
-
|
|
24
|
+
| Marker Type | Description | Extracted To |
|
|
25
|
+
|-------------|-------------|--------------|
|
|
26
|
+
| `definition` | Term definition (dfn) | `indexes.definitions[]` |
|
|
27
|
+
| `reference` | Cross-reference | `indexes.references[]` |
|
|
28
|
+
| `requirement` | RFC 2119 keyword | `indexes.requirements[]` |
|
|
29
|
+
| `issue` | Open issue/TODO | `indexes.issues[]` |
|
|
30
|
+
| `example` (block) | Code example | `indexes.examples[]` |
|
|
42
31
|
|
|
43
|
-
|
|
44
|
-
import { parseMarkdown } from '@openui/speculator';
|
|
45
|
-
import anchor from 'markdown-it-anchor';
|
|
32
|
+
### Semantic vs Computed Boundaries
|
|
46
33
|
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
| Category | In AST | Computed | Notes |
|
|
35
|
+
|----------|--------|----------|-------|
|
|
36
|
+
| Semantic nodes | ✓ | ✗ | Core AST structure |
|
|
37
|
+
| Indexes | ✓ | ✗ | Extracted, not computed |
|
|
38
|
+
| `computed.toc` | ✓ optional | ✓ | Marked `x-computed: true` |
|
|
39
|
+
| `computed.headingNumbers` | ✓ optional | ✓ | Marked `x-computed: true` |
|
|
40
|
+
| `computed.wordCount` | ✓ optional | ✓ | Marked `x-computed: true` |
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
**Key Distinction:**
|
|
43
|
+
- **Semantic AST**: Node structure + indexes. Always valid. Use `SemanticDocument` type.
|
|
44
|
+
- **Full AST**: Semantic + computed fields. Use `FullDocument` type.
|
|
52
45
|
|
|
53
|
-
##
|
|
46
|
+
## TypeScript Types
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
`mermaid` option when parsing Markdown:
|
|
48
|
+
Generate types from schema:
|
|
57
49
|
|
|
58
|
-
```
|
|
59
|
-
|
|
50
|
+
```bash
|
|
51
|
+
npm run generate:types
|
|
52
|
+
```
|
|
60
53
|
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
This generates `src/types/ast.generated.ts` with:
|
|
55
|
+
- All node types
|
|
56
|
+
- `SemanticDocument` - AST without computed fields
|
|
57
|
+
- `FullDocument` - AST with computed fields
|
|
58
|
+
- Type guards: `isDocument()`, `isSection()`, `isBlock()`, `isInline()`, etc.
|
|
59
|
+
|
|
60
|
+
## Runtime Validation
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { validateAST, assertValidAST, ASTValidator } from './src/validation/validate';
|
|
64
|
+
|
|
65
|
+
// Quick validation
|
|
66
|
+
const result = validateAST(ast, 'semantic'); // or 'full'
|
|
67
|
+
if (!result.valid) {
|
|
68
|
+
console.error(result.errors);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Assertion-style (throws on failure)
|
|
72
|
+
assertValidAST(ast, 'semantic');
|
|
73
|
+
|
|
74
|
+
// Per-stage validation
|
|
75
|
+
const validator = new ASTValidator();
|
|
76
|
+
validator.validateAtStage(ast, 'parse'); // semantic mode
|
|
77
|
+
validator.validateAtStage(ast, 'transform'); // semantic mode
|
|
78
|
+
validator.validateAtStage(ast, 'resolve'); // semantic mode
|
|
79
|
+
validator.validateAtStage(ast, 'index'); // semantic mode
|
|
80
|
+
validator.validateAtStage(ast, 'compute'); // full mode
|
|
63
81
|
```
|
|
64
82
|
|
|
65
|
-
|
|
83
|
+
## Development
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Install dependencies
|
|
87
|
+
npm install
|
|
88
|
+
|
|
89
|
+
# Validate schema syntax
|
|
90
|
+
npm run validate:schema
|
|
91
|
+
|
|
92
|
+
# Generate TypeScript types
|
|
93
|
+
npm run generate:types
|
|
94
|
+
|
|
95
|
+
# Build
|
|
96
|
+
npm run build
|
|
66
97
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
mermaid: { theme: 'forest' },
|
|
70
|
-
});
|
|
98
|
+
# Test
|
|
99
|
+
npm run test
|
|
71
100
|
```
|
|
72
101
|
|
|
102
|
+
## Pipeline Phases
|
|
73
103
|
|
|
104
|
+
```
|
|
105
|
+
loadConfig → loadEntry → preprocessIncludes → parse → transform → resolve → index → (compute?)
|
|
106
|
+
↓
|
|
107
|
+
Extract indexes from
|
|
108
|
+
inline markers
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The pipeline produces:
|
|
112
|
+
- **AST**: Structured document tree with semantic nodes
|
|
113
|
+
- **Indexes**: Extracted definitions, references, requirements, issues, examples
|
|
114
|
+
- **JSON Output**: Optional serialization of AST and indexes for external tools
|
|
115
|
+
|
|
116
|
+
## Source Position Tracking
|
|
117
|
+
|
|
118
|
+
Every node can have a `sourcePos` with:
|
|
119
|
+
- `file` - Canonical file path (preserves include origins)
|
|
120
|
+
- `line`, `column` - 1-indexed position
|
|
121
|
+
- `offset` - 0-indexed byte offset
|
|
122
|
+
- `endLine`, `endColumn`, `endOffset` - End position (optional)
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
interface SourcePos {
|
|
126
|
+
file: string;
|
|
127
|
+
line: number; // 1-indexed
|
|
128
|
+
column: number; // 1-indexed
|
|
129
|
+
offset?: number; // 0-indexed
|
|
130
|
+
endLine?: number;
|
|
131
|
+
endColumn?: number;
|
|
132
|
+
endOffset?: number;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compliance.test.d.ts","sourceRoot":"","sources":["../../../src/file-provider/__tests__/compliance.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for FileProvider compliance across implementations
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect } from 'vitest';
|
|
5
|
+
import { MemoryFileProvider, NodeFileProvider, FileNotFoundError } from '#src/file-provider/index';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
// Helper to test common compliance requirements
|
|
8
|
+
function runComplianceTests(name, provider) {
|
|
9
|
+
describe(`${name} Compliance`, () => {
|
|
10
|
+
it('canonicalizes paths deterministically', () => {
|
|
11
|
+
// Different inputs should map to same canonical path
|
|
12
|
+
const p1 = provider.canonicalize('/foo/bar/../baz.md');
|
|
13
|
+
const p2 = provider.canonicalize('/foo/baz.md');
|
|
14
|
+
expect(p1).toBe(p2);
|
|
15
|
+
});
|
|
16
|
+
it('resolves relative paths correctly', () => {
|
|
17
|
+
const from = provider.canonicalize('/docs/spec/index.md');
|
|
18
|
+
const resolved = provider.resolve(from, '../images/logo.png');
|
|
19
|
+
const expected = provider.canonicalize('/docs/images/logo.png');
|
|
20
|
+
expect(resolved).toBe(expected);
|
|
21
|
+
});
|
|
22
|
+
it('resolves sibling paths correctly', () => {
|
|
23
|
+
const from = provider.canonicalize('/docs/intro.md');
|
|
24
|
+
const resolved = provider.resolve(from, './setup.md');
|
|
25
|
+
const expected = provider.canonicalize('/docs/setup.md');
|
|
26
|
+
expect(resolved).toBe(expected);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
describe('MemoryFileProvider', () => {
|
|
31
|
+
const provider = new MemoryFileProvider({
|
|
32
|
+
'/foo/bar.md': 'content'
|
|
33
|
+
});
|
|
34
|
+
runComplianceTests('MemoryFileProvider', provider);
|
|
35
|
+
it('reads existing files', async () => {
|
|
36
|
+
const content = await provider.readText('/foo/bar.md');
|
|
37
|
+
expect(content).toBe('content');
|
|
38
|
+
});
|
|
39
|
+
it('throws FileNotFoundError for missing files', async () => {
|
|
40
|
+
await expect(provider.readText('/missing.md'))
|
|
41
|
+
.rejects.toThrow(FileNotFoundError);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe('NodeFileProvider', () => {
|
|
45
|
+
const provider = new NodeFileProvider();
|
|
46
|
+
runComplianceTests('NodeFileProvider', provider);
|
|
47
|
+
it('canonicalizes to absolute paths', () => {
|
|
48
|
+
const p = provider.canonicalize('foo.md');
|
|
49
|
+
expect(path.isAbsolute(p)).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=compliance.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compliance.test.js","sourceRoot":"","sources":["../../../src/file-provider/__tests__/compliance.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FileProvider exports
|
|
3
|
+
*/
|
|
4
|
+
export { FileProvider, FileNotFoundError, FileReadError, isFileNotFoundError, isFileReadError } from '#src/file-provider/types';
|
|
5
|
+
export { MemoryFileProvider } from '#src/file-provider/memory';
|
|
6
|
+
export { NodeFileProvider } from '#src/file-provider/node';
|
|
7
|
+
export { WebFileProvider } from '#src/file-provider/web';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/file-provider/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACH,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,eAAe,EAClB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FileProvider exports
|
|
3
|
+
*/
|
|
4
|
+
// Types and interface
|
|
5
|
+
export { FileNotFoundError, FileReadError, isFileNotFoundError, isFileReadError } from '#src/file-provider/types';
|
|
6
|
+
// Implementations
|
|
7
|
+
export { MemoryFileProvider } from '#src/file-provider/memory';
|
|
8
|
+
export { NodeFileProvider } from '#src/file-provider/node';
|
|
9
|
+
export { WebFileProvider } from '#src/file-provider/web';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/file-provider/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,sBAAsB;AACtB,OAAO,EAEH,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,eAAe,EAClB,MAAM,0BAA0B,CAAC;AAElC,kBAAkB;AAClB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemoryFileProvider - In-memory file provider for testing
|
|
3
|
+
*
|
|
4
|
+
* Uses a simple Map to store files. Paths are normalized to forward slashes.
|
|
5
|
+
* Useful for unit tests and documentation examples.
|
|
6
|
+
*/
|
|
7
|
+
import { FileProvider } from '#src/file-provider/types';
|
|
8
|
+
/**
|
|
9
|
+
* In-memory file provider
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const provider = new MemoryFileProvider({
|
|
14
|
+
* '/spec/index.md': '# Main\n:::include ./intro.md :::',
|
|
15
|
+
* '/spec/intro.md': '## Introduction\nContent here...'
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* const content = await provider.readText('/spec/index.md');
|
|
19
|
+
* const resolved = provider.resolve('/spec/index.md', './intro.md');
|
|
20
|
+
* // resolved === '/spec/intro.md'
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class MemoryFileProvider implements FileProvider {
|
|
24
|
+
private files;
|
|
25
|
+
constructor(files?: Record<string, string>);
|
|
26
|
+
/**
|
|
27
|
+
* Add or update a file in memory
|
|
28
|
+
*/
|
|
29
|
+
setFile(path: string, content: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Remove a file from memory
|
|
32
|
+
*/
|
|
33
|
+
deleteFile(path: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Check if a file exists
|
|
36
|
+
*/
|
|
37
|
+
hasFile(path: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Get all file paths
|
|
40
|
+
*/
|
|
41
|
+
listFiles(): string[];
|
|
42
|
+
readText(path: string): Promise<string>;
|
|
43
|
+
resolve(fromFile: string, relativePath: string): string;
|
|
44
|
+
canonicalize(path: string): string;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/file-provider/memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACH,YAAY,EAEf,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IACnD,OAAO,CAAC,KAAK,CAAsB;gBAEvB,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAO9C;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5C;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,SAAS,IAAI,MAAM,EAAE;IAIf,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAW7C,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAevD,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CA0BrC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MemoryFileProvider - In-memory file provider for testing
|
|
3
|
+
*
|
|
4
|
+
* Uses a simple Map to store files. Paths are normalized to forward slashes.
|
|
5
|
+
* Useful for unit tests and documentation examples.
|
|
6
|
+
*/
|
|
7
|
+
import { FileNotFoundError } from '#src/file-provider/types';
|
|
8
|
+
/**
|
|
9
|
+
* In-memory file provider
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const provider = new MemoryFileProvider({
|
|
14
|
+
* '/spec/index.md': '# Main\n:::include ./intro.md :::',
|
|
15
|
+
* '/spec/intro.md': '## Introduction\nContent here...'
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* const content = await provider.readText('/spec/index.md');
|
|
19
|
+
* const resolved = provider.resolve('/spec/index.md', './intro.md');
|
|
20
|
+
* // resolved === '/spec/intro.md'
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class MemoryFileProvider {
|
|
24
|
+
files;
|
|
25
|
+
constructor(files = {}) {
|
|
26
|
+
this.files = new Map();
|
|
27
|
+
for (const [path, content] of Object.entries(files)) {
|
|
28
|
+
this.files.set(this.canonicalize(path), content);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Add or update a file in memory
|
|
33
|
+
*/
|
|
34
|
+
setFile(path, content) {
|
|
35
|
+
this.files.set(this.canonicalize(path), content);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Remove a file from memory
|
|
39
|
+
*/
|
|
40
|
+
deleteFile(path) {
|
|
41
|
+
return this.files.delete(this.canonicalize(path));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if a file exists
|
|
45
|
+
*/
|
|
46
|
+
hasFile(path) {
|
|
47
|
+
return this.files.has(this.canonicalize(path));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get all file paths
|
|
51
|
+
*/
|
|
52
|
+
listFiles() {
|
|
53
|
+
return Array.from(this.files.keys());
|
|
54
|
+
}
|
|
55
|
+
async readText(path) {
|
|
56
|
+
const canonical = this.canonicalize(path);
|
|
57
|
+
const content = this.files.get(canonical);
|
|
58
|
+
if (content === undefined) {
|
|
59
|
+
throw new FileNotFoundError(canonical);
|
|
60
|
+
}
|
|
61
|
+
return content;
|
|
62
|
+
}
|
|
63
|
+
resolve(fromFile, relativePath) {
|
|
64
|
+
// Get directory of source file
|
|
65
|
+
const fromCanonical = this.canonicalize(fromFile);
|
|
66
|
+
const lastSlash = fromCanonical.lastIndexOf('/');
|
|
67
|
+
const fromDir = lastSlash > 0 ? fromCanonical.slice(0, lastSlash) : '/';
|
|
68
|
+
// Handle absolute paths
|
|
69
|
+
if (relativePath.startsWith('/')) {
|
|
70
|
+
return this.canonicalize(relativePath);
|
|
71
|
+
}
|
|
72
|
+
// Combine and canonicalize
|
|
73
|
+
return this.canonicalize(`${fromDir}/${relativePath}`);
|
|
74
|
+
}
|
|
75
|
+
canonicalize(path) {
|
|
76
|
+
// Normalize to forward slashes
|
|
77
|
+
let normalized = path.replace(/\\/g, '/');
|
|
78
|
+
// Ensure absolute path
|
|
79
|
+
if (!normalized.startsWith('/')) {
|
|
80
|
+
normalized = '/' + normalized;
|
|
81
|
+
}
|
|
82
|
+
// Split and resolve . and ..
|
|
83
|
+
const parts = normalized.split('/');
|
|
84
|
+
const resolved = [];
|
|
85
|
+
for (const part of parts) {
|
|
86
|
+
if (part === '' || part === '.') {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (part === '..') {
|
|
90
|
+
resolved.pop();
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
resolved.push(part);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return '/' + resolved.join('/');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/file-provider/memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEH,iBAAiB,EACpB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,kBAAkB;IACnB,KAAK,CAAsB;IAEnC,YAAY,QAAgC,EAAE;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;IACL,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,IAAY,EAAE,OAAe;QACjC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAAY;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,IAAY;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,SAAS;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE1C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,YAAoB;QAC1C,+BAA+B;QAC/B,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAExE,wBAAwB;QACxB,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC;QAED,2BAA2B;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,YAAY,CAAC,IAAY;QACrB,+BAA+B;QAC/B,IAAI,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE1C,uBAAuB;QACvB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,UAAU,GAAG,GAAG,GAAG,UAAU,CAAC;QAClC,CAAC;QAED,6BAA6B;QAC7B,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;gBAC9B,SAAS;YACb,CAAC;YACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAChB,QAAQ,CAAC,GAAG,EAAE,CAAC;YACnB,CAAC;iBAAM,CAAC;gBACJ,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;QACL,CAAC;QAED,OAAO,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;CACJ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NodeFileProvider - Node.js file system provider
|
|
3
|
+
*
|
|
4
|
+
* Uses Node.js fs module for file operations.
|
|
5
|
+
* Paths are canonicalized using path.resolve and path.normalize.
|
|
6
|
+
*/
|
|
7
|
+
import { FileProvider } from '#src/file-provider/types';
|
|
8
|
+
/**
|
|
9
|
+
* Node.js file provider
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const provider = new NodeFileProvider();
|
|
14
|
+
*
|
|
15
|
+
* const content = await provider.readText('/project/spec/index.md');
|
|
16
|
+
* const resolved = provider.resolve('/project/spec/index.md', './intro.md');
|
|
17
|
+
* // resolved === '/project/spec/intro.md'
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class NodeFileProvider implements FileProvider {
|
|
21
|
+
private basePath;
|
|
22
|
+
/**
|
|
23
|
+
* Create a Node.js file provider
|
|
24
|
+
*
|
|
25
|
+
* @param basePath - Optional base path for relative paths (defaults to cwd)
|
|
26
|
+
*/
|
|
27
|
+
constructor(basePath?: string);
|
|
28
|
+
readText(filePath: string): Promise<string>;
|
|
29
|
+
resolve(fromFile: string, relativePath: string): string;
|
|
30
|
+
canonicalize(filePath: string): string;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/file-provider/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACH,YAAY,EAGf,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACjD,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;;OAIG;gBACS,QAAQ,CAAC,EAAE,MAAM;IAIvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAejD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAavD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CASzC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NodeFileProvider - Node.js file system provider
|
|
3
|
+
*
|
|
4
|
+
* Uses Node.js fs module for file operations.
|
|
5
|
+
* Paths are canonicalized using path.resolve and path.normalize.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from 'fs/promises';
|
|
8
|
+
import * as path from 'path';
|
|
9
|
+
import { FileNotFoundError, FileReadError } from '#src/file-provider/types';
|
|
10
|
+
/**
|
|
11
|
+
* Node.js file provider
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const provider = new NodeFileProvider();
|
|
16
|
+
*
|
|
17
|
+
* const content = await provider.readText('/project/spec/index.md');
|
|
18
|
+
* const resolved = provider.resolve('/project/spec/index.md', './intro.md');
|
|
19
|
+
* // resolved === '/project/spec/intro.md'
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export class NodeFileProvider {
|
|
23
|
+
basePath;
|
|
24
|
+
/**
|
|
25
|
+
* Create a Node.js file provider
|
|
26
|
+
*
|
|
27
|
+
* @param basePath - Optional base path for relative paths (defaults to cwd)
|
|
28
|
+
*/
|
|
29
|
+
constructor(basePath) {
|
|
30
|
+
this.basePath = basePath ?? process.cwd();
|
|
31
|
+
}
|
|
32
|
+
async readText(filePath) {
|
|
33
|
+
const canonical = this.canonicalize(filePath);
|
|
34
|
+
try {
|
|
35
|
+
return await fs.readFile(canonical, 'utf-8');
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof Error && 'code' in error) {
|
|
39
|
+
if (error.code === 'ENOENT') {
|
|
40
|
+
throw new FileNotFoundError(canonical);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
throw new FileReadError(canonical, error instanceof Error ? error : undefined);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
resolve(fromFile, relativePath) {
|
|
47
|
+
const fromCanonical = this.canonicalize(fromFile);
|
|
48
|
+
const fromDir = path.dirname(fromCanonical);
|
|
49
|
+
// Handle absolute paths
|
|
50
|
+
if (path.isAbsolute(relativePath)) {
|
|
51
|
+
return this.canonicalize(relativePath);
|
|
52
|
+
}
|
|
53
|
+
// Resolve relative to source file's directory
|
|
54
|
+
return this.canonicalize(path.join(fromDir, relativePath));
|
|
55
|
+
}
|
|
56
|
+
canonicalize(filePath) {
|
|
57
|
+
// Make absolute if relative
|
|
58
|
+
const absolutePath = path.isAbsolute(filePath)
|
|
59
|
+
? filePath
|
|
60
|
+
: path.join(this.basePath, filePath);
|
|
61
|
+
// Normalize (resolves . and ..)
|
|
62
|
+
return path.normalize(absolutePath);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/file-provider/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAEH,iBAAiB,EACjB,aAAa,EAChB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,gBAAgB;IACjB,QAAQ,CAAS;IAEzB;;;;OAIG;IACH,YAAY,QAAiB;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAgB;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,CAAC;YACD,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;gBAC5C,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACrD,MAAM,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC;gBAC3C,CAAC;YACL,CAAC;YACD,MAAM,IAAI,aAAa,CAAC,SAAS,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACnF,CAAC;IACL,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,YAAoB;QAC1C,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAE5C,wBAAwB;QACxB,IAAI,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC;QAED,8CAA8C;QAC9C,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,YAAY,CAAC,QAAgB;QACzB,4BAA4B;QAC5B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YAC1C,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAEzC,gCAAgC;QAChC,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;CACJ"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FileProvider - Isomorphic file access abstraction
|
|
3
|
+
*
|
|
4
|
+
* Provides a minimal interface for reading files and resolving paths
|
|
5
|
+
* across different environments (Node.js, Web, Memory).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when a file cannot be found
|
|
9
|
+
*/
|
|
10
|
+
export declare class FileNotFoundError extends Error {
|
|
11
|
+
readonly path: string;
|
|
12
|
+
readonly code = "FILE_NOT_FOUND";
|
|
13
|
+
constructor(path: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Error thrown when a file cannot be read
|
|
17
|
+
*/
|
|
18
|
+
export declare class FileReadError extends Error {
|
|
19
|
+
readonly path: string;
|
|
20
|
+
readonly cause?: Error | undefined;
|
|
21
|
+
readonly code = "FILE_READ_ERROR";
|
|
22
|
+
constructor(path: string, cause?: Error | undefined);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Minimal isomorphic file provider interface
|
|
26
|
+
*
|
|
27
|
+
* All paths are expected to be canonical after canonicalize() is called.
|
|
28
|
+
* Implementations must ensure deterministic behavior for the same inputs.
|
|
29
|
+
*/
|
|
30
|
+
export interface FileProvider {
|
|
31
|
+
/**
|
|
32
|
+
* Read file contents as UTF-8 text
|
|
33
|
+
*
|
|
34
|
+
* @param path - Canonical file path
|
|
35
|
+
* @returns File contents as string
|
|
36
|
+
* @throws FileNotFoundError if file doesn't exist
|
|
37
|
+
* @throws FileReadError if file cannot be read
|
|
38
|
+
*/
|
|
39
|
+
readText(path: string): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a relative path from a source file's location
|
|
42
|
+
*
|
|
43
|
+
* @param fromFile - Canonical path of the file containing the reference
|
|
44
|
+
* @param relativePath - Relative path to resolve (e.g., "./foo.md", "../bar.md")
|
|
45
|
+
* @returns Canonical resolved path
|
|
46
|
+
*/
|
|
47
|
+
resolve(fromFile: string, relativePath: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Convert a path to its canonical form
|
|
50
|
+
*
|
|
51
|
+
* Canonical paths are:
|
|
52
|
+
* - Absolute (no relative segments)
|
|
53
|
+
* - Normalized (no . or .. segments)
|
|
54
|
+
* - Consistent across platform (forward slashes for web/memory)
|
|
55
|
+
*
|
|
56
|
+
* @param path - Path to canonicalize
|
|
57
|
+
* @returns Canonical path
|
|
58
|
+
*/
|
|
59
|
+
canonicalize(path: string): string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Type guard for FileNotFoundError
|
|
63
|
+
*/
|
|
64
|
+
export declare function isFileNotFoundError(error: unknown): error is FileNotFoundError;
|
|
65
|
+
/**
|
|
66
|
+
* Type guard for FileReadError
|
|
67
|
+
*/
|
|
68
|
+
export declare function isFileReadError(error: unknown): error is FileReadError;
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/file-provider/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;aAGZ,IAAI,EAAE,MAAM;IAFxC,QAAQ,CAAC,IAAI,oBAAoB;gBAEL,IAAI,EAAE,MAAM;CAI3C;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;aAIhB,IAAI,EAAE,MAAM;aACZ,KAAK,CAAC,EAAE,KAAK;IAJjC,QAAQ,CAAC,IAAI,qBAAqB;gBAGd,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,KAAK,YAAA;CAKpC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IACzB;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExC;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;IAExD;;;;;;;;;;OAUG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACtC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAG9E;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAGtE"}
|