@openuji/speculator 0.1.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 +38 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown/index.d.ts +5 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +70 -0
- package/dist/markdown/index.js.map +1 -0
- package/dist/markdown/plugins/cite.d.ts +3 -0
- package/dist/markdown/plugins/cite.d.ts.map +1 -0
- package/dist/markdown/plugins/cite.js +36 -0
- package/dist/markdown/plugins/cite.js.map +1 -0
- package/dist/markdown/plugins/concept.d.ts +3 -0
- package/dist/markdown/plugins/concept.d.ts.map +1 -0
- package/dist/markdown/plugins/concept.js +30 -0
- package/dist/markdown/plugins/concept.js.map +1 -0
- package/dist/markdown/plugins/idl.d.ts +3 -0
- package/dist/markdown/plugins/idl.d.ts.map +1 -0
- package/dist/markdown/plugins/idl.js +28 -0
- package/dist/markdown/plugins/idl.js.map +1 -0
- package/dist/pipeline/passes/boilerplate.d.ts +3 -0
- package/dist/pipeline/passes/boilerplate.d.ts.map +1 -0
- package/dist/pipeline/passes/boilerplate.js +59 -0
- package/dist/pipeline/passes/boilerplate.js.map +1 -0
- package/dist/pipeline/passes/diagnostics.d.ts +3 -0
- package/dist/pipeline/passes/diagnostics.d.ts.map +1 -0
- package/dist/pipeline/passes/diagnostics.js +43 -0
- package/dist/pipeline/passes/diagnostics.js.map +1 -0
- package/dist/pipeline/passes/idl.d.ts +4 -0
- package/dist/pipeline/passes/idl.d.ts.map +1 -0
- package/dist/pipeline/passes/idl.js +188 -0
- package/dist/pipeline/passes/idl.js.map +1 -0
- package/dist/pipeline/passes/references.d.ts +3 -0
- package/dist/pipeline/passes/references.d.ts.map +1 -0
- package/dist/pipeline/passes/references.js +99 -0
- package/dist/pipeline/passes/references.js.map +1 -0
- package/dist/pipeline/passes/toc.d.ts +3 -0
- package/dist/pipeline/passes/toc.d.ts.map +1 -0
- package/dist/pipeline/passes/toc.js +30 -0
- package/dist/pipeline/passes/toc.js.map +1 -0
- package/dist/pipeline/passes/xref.d.ts +3 -0
- package/dist/pipeline/passes/xref.d.ts.map +1 -0
- package/dist/pipeline/passes/xref.js +132 -0
- package/dist/pipeline/passes/xref.js.map +1 -0
- package/dist/pipeline/postprocess.d.ts +6 -0
- package/dist/pipeline/postprocess.d.ts.map +1 -0
- package/dist/pipeline/postprocess.js +26 -0
- package/dist/pipeline/postprocess.js.map +1 -0
- package/dist/speculator.d.ts +40 -0
- package/dist/speculator.d.ts.map +1 -0
- package/dist/speculator.js +188 -0
- package/dist/speculator.js.map +1 -0
- package/dist/types.d.ts +146 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/file-loader.d.ts +18 -0
- package/dist/utils/file-loader.d.ts.map +1 -0
- package/dist/utils/file-loader.js +100 -0
- package/dist/utils/file-loader.js.map +1 -0
- package/dist/utils/strip-ident.d.ts +2 -0
- package/dist/utils/strip-ident.d.ts.map +1 -0
- package/dist/utils/strip-ident.js +15 -0
- package/dist/utils/strip-ident.js.map +1 -0
- package/package.json +68 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Speculator
|
|
2
|
+
|
|
3
|
+
A TypeScript library for processing ReSpec-like markup and open for intgration in any frontend framework out there
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pnpm install @openui/speculator
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## Package Structure
|
|
14
|
+
|
|
15
|
+
```bash
|
|
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
|
+
```
|
|
37
|
+
|
|
38
|
+
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Speculator } from './speculator';
|
|
2
|
+
export { parseMarkdown, createMarkdownRenderer } from './markdown';
|
|
3
|
+
export { nodeFileLoader, browserFileLoader, createFallbackFileLoader, getDefaultFileLoader } from './utils/file-loader';
|
|
4
|
+
export type { SpeculatorOptions, FileLoader, MarkdownOptions, ProcessingResult, ProcessingStats, DataFormat } from './types';
|
|
5
|
+
export { SpeculatorError } from './types';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,aAAa,EACb,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpeculatorError = exports.getDefaultFileLoader = exports.createFallbackFileLoader = exports.browserFileLoader = exports.nodeFileLoader = exports.createMarkdownRenderer = exports.parseMarkdown = exports.Speculator = void 0;
|
|
4
|
+
// Main exports
|
|
5
|
+
var speculator_1 = require("./speculator");
|
|
6
|
+
Object.defineProperty(exports, "Speculator", { enumerable: true, get: function () { return speculator_1.Speculator; } });
|
|
7
|
+
var markdown_1 = require("./markdown");
|
|
8
|
+
Object.defineProperty(exports, "parseMarkdown", { enumerable: true, get: function () { return markdown_1.parseMarkdown; } });
|
|
9
|
+
Object.defineProperty(exports, "createMarkdownRenderer", { enumerable: true, get: function () { return markdown_1.createMarkdownRenderer; } });
|
|
10
|
+
var file_loader_1 = require("./utils/file-loader");
|
|
11
|
+
Object.defineProperty(exports, "nodeFileLoader", { enumerable: true, get: function () { return file_loader_1.nodeFileLoader; } });
|
|
12
|
+
Object.defineProperty(exports, "browserFileLoader", { enumerable: true, get: function () { return file_loader_1.browserFileLoader; } });
|
|
13
|
+
Object.defineProperty(exports, "createFallbackFileLoader", { enumerable: true, get: function () { return file_loader_1.createFallbackFileLoader; } });
|
|
14
|
+
Object.defineProperty(exports, "getDefaultFileLoader", { enumerable: true, get: function () { return file_loader_1.getDefaultFileLoader; } });
|
|
15
|
+
var types_1 = require("./types");
|
|
16
|
+
Object.defineProperty(exports, "SpeculatorError", { enumerable: true, get: function () { return types_1.SpeculatorError; } });
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,eAAe;AACf,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,uCAGoB;AAFlB,yGAAA,aAAa,OAAA;AACb,kHAAA,sBAAsB,OAAA;AAExB,mDAK6B;AAJ3B,6GAAA,cAAc,OAAA;AACd,gHAAA,iBAAiB,OAAA;AACjB,uHAAA,wBAAwB,OAAA;AACxB,mHAAA,oBAAoB,OAAA;AAatB,iCAA0C;AAAjC,wGAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import MarkdownIt from 'markdown-it';
|
|
2
|
+
import type { MarkdownOptions } from '../types.js';
|
|
3
|
+
export declare function createMarkdownRenderer(options?: MarkdownOptions): MarkdownIt;
|
|
4
|
+
export declare function parseMarkdown(markdown: string, options?: MarkdownOptions, env?: Record<string, any>): string;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/markdown/index.ts"],"names":[],"mappings":"AAAC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAKnD,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,eAAoB,GAAG,UAAU,CA0ChF;AAGF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAQhH"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createMarkdownRenderer = createMarkdownRenderer;
|
|
7
|
+
exports.parseMarkdown = parseMarkdown;
|
|
8
|
+
const markdown_it_1 = __importDefault(require("markdown-it"));
|
|
9
|
+
const concept_js_1 = require("../markdown/plugins/concept.js");
|
|
10
|
+
const idl_js_1 = require("../markdown/plugins/idl.js");
|
|
11
|
+
const cite_js_1 = require("../markdown/plugins/cite.js");
|
|
12
|
+
function createMarkdownRenderer(options = {}) {
|
|
13
|
+
const md = new markdown_it_1.default({
|
|
14
|
+
html: false,
|
|
15
|
+
linkify: options.gfm ?? true,
|
|
16
|
+
breaks: options.breaks ?? true,
|
|
17
|
+
typographer: options.smartypants ?? true,
|
|
18
|
+
xhtmlOut: false,
|
|
19
|
+
});
|
|
20
|
+
const headerIds = options.headerIds ?? true;
|
|
21
|
+
md.renderer.rules.heading_open = (tokens, idx, _opts, env, self) => {
|
|
22
|
+
void env;
|
|
23
|
+
const open = tokens[idx];
|
|
24
|
+
const inline = tokens[idx + 1];
|
|
25
|
+
const close = tokens[idx + 2];
|
|
26
|
+
if (open.tag === 'h1') {
|
|
27
|
+
open.tag = 'h2';
|
|
28
|
+
if (close && close.type === 'heading_close')
|
|
29
|
+
close.tag = 'h2';
|
|
30
|
+
}
|
|
31
|
+
if (headerIds && inline && inline.type === 'inline') {
|
|
32
|
+
const id = slugify(inline.content);
|
|
33
|
+
open.attrSet('id', id);
|
|
34
|
+
}
|
|
35
|
+
return self.renderToken(tokens, idx, _opts);
|
|
36
|
+
};
|
|
37
|
+
md.renderer.rules.fence = (tokens, idx) => {
|
|
38
|
+
const token = tokens[idx];
|
|
39
|
+
const info = (token.info || '').trim();
|
|
40
|
+
const lang = info ? info.split(/\s+/)[0] : '';
|
|
41
|
+
const classAttr = lang ? ` class="${md.utils.escapeHtml(lang)}"` : '';
|
|
42
|
+
const code = md.utils.escapeHtml(token.content);
|
|
43
|
+
return `<pre${classAttr}><code>${code}</code></pre>\n`;
|
|
44
|
+
};
|
|
45
|
+
// Install ReSpec-aligned shorthand plugins
|
|
46
|
+
md.use(concept_js_1.respecConceptPlugin);
|
|
47
|
+
md.use(idl_js_1.respecIdlPlugin);
|
|
48
|
+
md.use(cite_js_1.respecCitePlugin);
|
|
49
|
+
return md;
|
|
50
|
+
}
|
|
51
|
+
// Optional env bag lets callers read things like __citations
|
|
52
|
+
function parseMarkdown(markdown, options = {}, env) {
|
|
53
|
+
try {
|
|
54
|
+
const md = createMarkdownRenderer(options);
|
|
55
|
+
return md.render(markdown, env);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error('Markdown parsing error:', error);
|
|
59
|
+
return `<p class="error">Error parsing markdown: ${error instanceof Error ? error.message : 'Unknown error'}</p>`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function slugify(content) {
|
|
63
|
+
return content
|
|
64
|
+
.toLowerCase()
|
|
65
|
+
.trim()
|
|
66
|
+
.replace(/[^\w\s-]/g, '') // Remove non-word characters except spaces and hyphens
|
|
67
|
+
.replace(/\s+/g, '-') // Replace spaces with hyphens
|
|
68
|
+
.replace(/-+/g, '-'); // Collapse multiple hyphens
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/markdown/index.ts"],"names":[],"mappings":";;;;;AAMC,wDA0CC;AAGF,sCAQC;AA3DA,8DAAqC;AAErC,+DAAqE;AACrE,uDAA6D;AAC7D,yDAA+D;AAE/D,SAAgB,sBAAsB,CAAC,UAA2B,EAAE;IAClE,MAAM,EAAE,GAAG,IAAI,qBAAU,CAAC;QACxB,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,OAAO,CAAC,GAAG,IAAI,IAAI;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI;QAC9B,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI;QACxC,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;IAE5C,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QACjE,KAAK,GAAG,CAAC;QACT,MAAM,IAAI,GAAG,MAAM,CAAC,G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AAE,UAAU,QAuC9C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.respecCitePlugin = respecCitePlugin;
|
|
4
|
+
function respecCitePlugin(md) {
|
|
5
|
+
const NAME = 'respec-cite';
|
|
6
|
+
function tokenize(state, silent) {
|
|
7
|
+
const pos = state.pos;
|
|
8
|
+
const src = state.src;
|
|
9
|
+
// Must start with "[["
|
|
10
|
+
if (src.charCodeAt(pos) !== 0x5B /*[*/ || src.charCodeAt(pos + 1) !== 0x5B /*[*/)
|
|
11
|
+
return false;
|
|
12
|
+
const end = src.indexOf(']]', pos + 2);
|
|
13
|
+
if (end < 0)
|
|
14
|
+
return false;
|
|
15
|
+
if (!silent) {
|
|
16
|
+
const raw = src.slice(pos + 2, end).trim();
|
|
17
|
+
const normative = raw.startsWith('!');
|
|
18
|
+
const id = normative ? raw.slice(1) : raw;
|
|
19
|
+
// record into env
|
|
20
|
+
const env = state.env;
|
|
21
|
+
const col = (env.__citations || (env.__citations = []));
|
|
22
|
+
col.push({ id, normative });
|
|
23
|
+
// Render as a link placeholder
|
|
24
|
+
const open = state.push('link_open', 'a', 1);
|
|
25
|
+
open.attrSet('data-spec', id);
|
|
26
|
+
open.attrSet('data-normative', String(normative));
|
|
27
|
+
const text = state.push('text', '', 0);
|
|
28
|
+
text.content = `[${id}]`;
|
|
29
|
+
state.push('link_close', 'a', -1);
|
|
30
|
+
}
|
|
31
|
+
state.pos = end + 2;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
md.inline.ruler.before('link', NAME, tokenize);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=cite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cite.js","sourceRoot":"","sources":["../../../src/markdown/plugins/cite.ts"],"names":[],"mappings":";;AAKA,4CAuCC;AAvCD,SAAgB,gBAAgB,CAAC,EAAc;IAC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C,CAAC;YAC9B,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;YAElD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACvC,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,GAAG,CAAC;YAEzB,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC;QAED,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concept.d.ts","sourceRoot":"","sources":["../../../src/markdown/plugins/concept.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAI1C,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,UAAU,QAiCjD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.respecConceptPlugin = respecConceptPlugin;
|
|
4
|
+
function respecConceptPlugin(md) {
|
|
5
|
+
const NAME = 'respec-concept';
|
|
6
|
+
function tokenize(state, silent) {
|
|
7
|
+
const pos = state.pos;
|
|
8
|
+
const src = state.src;
|
|
9
|
+
// Must start with "[="
|
|
10
|
+
if (src.charCodeAt(pos) !== 0x5B /*[*/ || src.charCodeAt(pos + 1) !== 0x3D /*=*/)
|
|
11
|
+
return false;
|
|
12
|
+
const end = src.indexOf('=]', pos + 2);
|
|
13
|
+
if (end < 0)
|
|
14
|
+
return false;
|
|
15
|
+
if (!silent) {
|
|
16
|
+
const content = src.slice(pos + 2, end).trim();
|
|
17
|
+
const tokenOpen = state.push('respec_concept_open', 'a', 1);
|
|
18
|
+
tokenOpen.attrSet('data-xref', content);
|
|
19
|
+
const text = state.push('text', '', 0);
|
|
20
|
+
text.content = content;
|
|
21
|
+
state.push('respec_concept_close', 'a', -1);
|
|
22
|
+
}
|
|
23
|
+
state.pos = end + 2;
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
md.inline.ruler.before('link', NAME, tokenize);
|
|
27
|
+
md.renderer.rules.respec_concept_open = (tokens, idx) => `<a data-xref="${md.utils.escapeHtml(tokens[idx].attrGet('data-xref') || '')}">`;
|
|
28
|
+
md.renderer.rules.respec_concept_close = () => `</a>`;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=concept.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concept.js","sourceRoot":"","sources":["../../../src/markdown/plugins/concept.ts"],"names":[],"mappings":";;AAIA,kDAiCC;AAjCD,SAAgB,mBAAmB,CAAC,EAAc;IAChD,MAAM,IAAI,GAAG,gBAAgB,CAAC;IAE9B,SAAS,QAAQ,CAAC,KAAkB,EAAE,MAAe;QACnD,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;QACtB,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;QAEtB,uBAAuB;QACvB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QAE/F,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;QACvC,IAAI,GAAG,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAE1B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,OAAO,GAAG,GAAG,CAAC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2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.respecIdlPlugin = respecIdlPlugin;
|
|
4
|
+
function respecIdlPlugin(md) {
|
|
5
|
+
const NAME = 'respec-idl';
|
|
6
|
+
function tokenize(state, silent) {
|
|
7
|
+
const pos = state.pos;
|
|
8
|
+
const src = state.src;
|
|
9
|
+
// Must start with "{{"
|
|
10
|
+
if (src.charCodeAt(pos) !== 0x7B /*{*/ || src.charCodeAt(pos + 1) !== 0x7B /*{*/)
|
|
11
|
+
return false;
|
|
12
|
+
const end = src.indexOf('}}', pos + 2);
|
|
13
|
+
if (end < 0)
|
|
14
|
+
return false;
|
|
15
|
+
if (!silent) {
|
|
16
|
+
const content = src.slice(pos + 2, end).trim();
|
|
17
|
+
const open = state.push('link_open', 'a', 1);
|
|
18
|
+
open.attrSet('data-idl', content);
|
|
19
|
+
const text = state.push('text', '', 0);
|
|
20
|
+
text.content = content;
|
|
21
|
+
state.push('link_close', 'a', -1);
|
|
22
|
+
}
|
|
23
|
+
state.pos = end + 2;
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
md.inline.ruler.before('emphasis', NAME, tokenize);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=idl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idl.js","sourceRoot":"","sources":["../../../src/markdown/plugins/idl.ts"],"names":[],"mappings":";;AAIA,0CA6BC;AA7BD,SAAgB,eAAe,CAAC,EAAc;IAC5C,MAAM,IAAI,GAAG,YAAY,CAAC;IAE1B,SAAS,QAAQ,CAAC,KAAkB,EAAE,MAAe;QACnD,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;QACtB,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;QAEtB,uBAAuB;QACvB,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,G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
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runBoilerplatePass = runBoilerplatePass;
|
|
4
|
+
function createSection(doc, id, title, content) {
|
|
5
|
+
const sec = doc.createElement('section');
|
|
6
|
+
sec.id = id;
|
|
7
|
+
const h2 = doc.createElement('h2');
|
|
8
|
+
h2.textContent = title;
|
|
9
|
+
sec.appendChild(h2);
|
|
10
|
+
if (content) {
|
|
11
|
+
const p = doc.createElement('p');
|
|
12
|
+
p.textContent = content;
|
|
13
|
+
sec.appendChild(p);
|
|
14
|
+
}
|
|
15
|
+
return sec;
|
|
16
|
+
}
|
|
17
|
+
function runBoilerplatePass(root, options) {
|
|
18
|
+
const bp = options.boilerplate;
|
|
19
|
+
if (!bp)
|
|
20
|
+
return;
|
|
21
|
+
const doc = root.ownerDocument;
|
|
22
|
+
const mountMode = bp.mount || 'end';
|
|
23
|
+
// Determine insertion reference node based on mount option
|
|
24
|
+
let ref = null;
|
|
25
|
+
if (mountMode === 'before-references') {
|
|
26
|
+
ref = root.querySelector('#references');
|
|
27
|
+
}
|
|
28
|
+
else if (mountMode === 'after-toc') {
|
|
29
|
+
const toc = root.querySelector('#toc');
|
|
30
|
+
ref = toc ? toc.nextSibling : null;
|
|
31
|
+
}
|
|
32
|
+
const insert = (section) => {
|
|
33
|
+
if (ref) {
|
|
34
|
+
root.insertBefore(section, ref);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
root.appendChild(section);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const defs = [
|
|
41
|
+
{ key: 'conformance', title: 'Conformance' },
|
|
42
|
+
{ key: 'security', title: 'Security' },
|
|
43
|
+
{ key: 'privacy', title: 'Privacy' },
|
|
44
|
+
];
|
|
45
|
+
for (const { key, title: defaultTitle } of defs) {
|
|
46
|
+
const opt = bp[key];
|
|
47
|
+
if (!opt)
|
|
48
|
+
continue; // not enabled
|
|
49
|
+
const cfg = typeof opt === 'object' ? opt : {};
|
|
50
|
+
const id = cfg.id || key;
|
|
51
|
+
if (root.querySelector(`#${id}`))
|
|
52
|
+
continue; // avoid overwriting existing sections
|
|
53
|
+
const title = cfg.title || defaultTitle;
|
|
54
|
+
const content = cfg.content;
|
|
55
|
+
const sec = createSection(doc, id, title, content);
|
|
56
|
+
insert(sec);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=boilerplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boilerplate.js","sourceRoot":"","sources":["../../../src/pipeline/passes/boilerplate.ts"],"names":[],"mappings":";;AAsBA,gDA2CC;AAzDD,SAAS,aAAa,CAAC,GAAa,EAAE,EAAU,EAAE,KAAa,EAAE,OAAgB;IAC/E,MAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IACzC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,EAAE,GAAG,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACnC,EAAE,CAAC,WAAW,GAAG,KAAK,CAAC;IACvB,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACpB,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC,CAAC,WAAW,GAAG,OAAO,CAAC;QACxB,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,kBAAkB,CAAC,IAAa,EAAE,OAA2B;IAC3E,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAC/B,IAAI,CAAC,EAAE;QAAE,OAAO;IAEhB,MAAM,GAAG,GAAG,IAAI,CAAC,aAAc,CAAC;IAChC,MAAM,SAAS,GAAG,EAAE,CAAC,KAAK,IAAI,KAAK,CAAC;IAEpC,2DAA2D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CAAC;YAAE,SAAS,CAAC,sCAAsC;QAElF,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,YAAY,CAAC;QACxC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAC5B,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,CAAC,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/pipeline/passes/diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAwCxF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runDiagnosticsPass = runDiagnosticsPass;
|
|
4
|
+
function runDiagnosticsPass(root, options) {
|
|
5
|
+
const warnings = [];
|
|
6
|
+
const suppressClass = options?.suppressClass ?? 'no-link-warnings';
|
|
7
|
+
const idsAndLinks = options?.idsAndLinks ?? true;
|
|
8
|
+
if (idsAndLinks) {
|
|
9
|
+
// Duplicate IDs
|
|
10
|
+
const seen = new Map();
|
|
11
|
+
root.querySelectorAll('[id]').forEach(el => {
|
|
12
|
+
const id = el.id;
|
|
13
|
+
if (!id)
|
|
14
|
+
return;
|
|
15
|
+
if (seen.has(id)) {
|
|
16
|
+
if (!el.closest(`.${suppressClass}`)) {
|
|
17
|
+
warnings.push(`Duplicate id: "${id}"`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
seen.set(id, el);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
// Anchors missing href
|
|
25
|
+
const anchors = root.querySelectorAll('a');
|
|
26
|
+
anchors.forEach(a => {
|
|
27
|
+
if (a.closest(`.${suppressClass}`))
|
|
28
|
+
return;
|
|
29
|
+
const hasHref = a.hasAttribute('href') && a.getAttribute('href') !== '';
|
|
30
|
+
const isPlaceholder = a.hasAttribute('data-xref') || a.hasAttribute('data-idl') || a.hasAttribute('data-spec');
|
|
31
|
+
if (!hasHref && isPlaceholder) {
|
|
32
|
+
const label = a.getAttribute('data-xref') ||
|
|
33
|
+
a.getAttribute('data-idl') ||
|
|
34
|
+
a.getAttribute('data-spec') ||
|
|
35
|
+
a.textContent ||
|
|
36
|
+
'';
|
|
37
|
+
warnings.push(`Unresolved link placeholder: "${label.trim()}"`);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return warnings;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../../src/pipeline/passes/diagnostics.ts"],"names":[],"mappings":";;AAEA,gDAwCC;AAxCD,SAAgB,kBAAkB,CAAC,IAAa,EAAE,OAA4B;IAC5E,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,kBAAkB,CAAC;IACnE,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,IAAI,CAAC;IAEjD,IAAI,WAAW,EAAE,CAAC;QAChB,gBAAgB;QAChB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAmB,CAAC;QACxC,IAAI,CAAC,gBAAgB,CAAc,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;YACtD,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,EAAE;gBAAE,OAAO;YAChB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EA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","sourceRoot":"","sources":["../../../src/pipeline/passes/idl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAsJlD,kBAAkB;AAClB,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAM/E"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.runIdlPass = runIdlPass;
|
|
37
|
+
const WebIDL2 = __importStar(require("webidl2"));
|
|
38
|
+
function norm(s) {
|
|
39
|
+
return s.toLowerCase().replace(/\s+/g, ' ').trim();
|
|
40
|
+
}
|
|
41
|
+
function slug(s) {
|
|
42
|
+
return s.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
|
|
43
|
+
}
|
|
44
|
+
function uniqueId(doc, base) {
|
|
45
|
+
let id = base;
|
|
46
|
+
let i = 2;
|
|
47
|
+
while (doc.getElementById(id)) {
|
|
48
|
+
id = `${base}-${i++}`;
|
|
49
|
+
}
|
|
50
|
+
return id;
|
|
51
|
+
}
|
|
52
|
+
function collectTargetsFromAst(ast) {
|
|
53
|
+
const defs = [];
|
|
54
|
+
const addTop = (name) => {
|
|
55
|
+
const key = norm(name);
|
|
56
|
+
defs.push({ id: `idl-${slug(name)}`, key, text: name });
|
|
57
|
+
};
|
|
58
|
+
const addMember = (ifc, mem) => {
|
|
59
|
+
const key = `${norm(ifc)}.${norm(mem)}`;
|
|
60
|
+
defs.push({ id: `idl-${slug(ifc)}-${slug(mem)}`, key, text: `${ifc}.${mem}` });
|
|
61
|
+
};
|
|
62
|
+
for (const d of ast) {
|
|
63
|
+
switch (d.type) {
|
|
64
|
+
case 'interface':
|
|
65
|
+
case 'interface mixin':
|
|
66
|
+
case 'namespace':
|
|
67
|
+
case 'dictionary':
|
|
68
|
+
case 'callback interface':
|
|
69
|
+
case 'callback':
|
|
70
|
+
case 'typedef':
|
|
71
|
+
case 'enum': {
|
|
72
|
+
if (!('name' in d) || !d.name)
|
|
73
|
+
break;
|
|
74
|
+
addTop(d.name);
|
|
75
|
+
// members where applicable
|
|
76
|
+
if ('members' in d && Array.isArray(d.members)) {
|
|
77
|
+
for (const m of d.members) {
|
|
78
|
+
if (m.type === 'attribute' && m.name)
|
|
79
|
+
addMember(d.name, m.name);
|
|
80
|
+
else if (m.type === 'operation' && m.name)
|
|
81
|
+
addMember(d.name, m.name);
|
|
82
|
+
else if (m.type === 'const' && m.name)
|
|
83
|
+
addMember(d.name, m.name);
|
|
84
|
+
else if (m.type === 'field' && m.name)
|
|
85
|
+
addMember(d.name, m.name);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
// 'includes' doesn’t add new top-level names — skip
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { defs };
|
|
94
|
+
}
|
|
95
|
+
/** Insert hidden anchors for each target before the given <pre>. */
|
|
96
|
+
function insertAnchorsBefore(pre, targets) {
|
|
97
|
+
if (!targets.length)
|
|
98
|
+
return;
|
|
99
|
+
const doc = pre.ownerDocument;
|
|
100
|
+
const wrapper = doc.createElement('div');
|
|
101
|
+
wrapper.className = 'idl-anchors';
|
|
102
|
+
wrapper.hidden = true; // JS property for broader envs
|
|
103
|
+
for (const t of targets) {
|
|
104
|
+
const a = doc.createElement('a');
|
|
105
|
+
a.id = uniqueId(doc, t.id);
|
|
106
|
+
a.textContent = t.text;
|
|
107
|
+
wrapper.appendChild(a);
|
|
108
|
+
}
|
|
109
|
+
pre.parentNode?.insertBefore(wrapper, pre);
|
|
110
|
+
}
|
|
111
|
+
/** Try to parse a string of IDL; return targets or throw. */
|
|
112
|
+
function parseIdlToTargets(idl) {
|
|
113
|
+
const ast = WebIDL2.parse(idl);
|
|
114
|
+
return collectTargetsFromAst(ast).defs;
|
|
115
|
+
}
|
|
116
|
+
/** Find candidate <pre> blocks containing IDL. */
|
|
117
|
+
function findIdlBlocks(root) {
|
|
118
|
+
const blocks = [];
|
|
119
|
+
const pres = root.querySelectorAll('pre');
|
|
120
|
+
pres.forEach((pre) => {
|
|
121
|
+
const cls = (pre.getAttribute('class') || '').toLowerCase();
|
|
122
|
+
const looksIdlClass = /\b(idl|language-idl)\b/.test(cls);
|
|
123
|
+
const code = pre.querySelector('code');
|
|
124
|
+
const text = (code ? code.textContent : pre.textContent) || '';
|
|
125
|
+
const maybeIdl = looksIdlClass || /^\s*(interface|dictionary|enum|namespace|callback|typedef)\b/.test(text);
|
|
126
|
+
if (maybeIdl && text.trim())
|
|
127
|
+
blocks.push(pre);
|
|
128
|
+
});
|
|
129
|
+
return blocks;
|
|
130
|
+
}
|
|
131
|
+
/** Build a map of resolvable IDL keys -> href based on parsed blocks. */
|
|
132
|
+
function buildIdlIndex(root, warnings) {
|
|
133
|
+
const map = new Map();
|
|
134
|
+
const blocks = findIdlBlocks(root);
|
|
135
|
+
for (const pre of blocks) {
|
|
136
|
+
const code = pre.querySelector('code');
|
|
137
|
+
const idl = (code ? code.textContent : pre.textContent) || '';
|
|
138
|
+
try {
|
|
139
|
+
const targets = parseIdlToTargets(idl);
|
|
140
|
+
insertAnchorsBefore(pre, targets);
|
|
141
|
+
for (const t of targets) {
|
|
142
|
+
const href = `#${t.id}`;
|
|
143
|
+
if (!map.has(t.key))
|
|
144
|
+
map.set(t.key, href);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
const msg = e && e.message ? e.message : String(e);
|
|
149
|
+
warnings.push(`IDL parse error: ${msg}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return map;
|
|
153
|
+
}
|
|
154
|
+
/** Resolve <a data-idl> anchors using the built index. */
|
|
155
|
+
function resolveIdlLinks(root, index, warnings, suppressClass) {
|
|
156
|
+
const anchors = root.querySelectorAll('a[data-idl]');
|
|
157
|
+
Array.from(anchors).forEach((a) => {
|
|
158
|
+
if (a.closest(`.${suppressClass}`))
|
|
159
|
+
return;
|
|
160
|
+
const raw = a.getAttribute('data-idl') || '';
|
|
161
|
+
const term = raw.trim();
|
|
162
|
+
const hasMember = term.includes('.');
|
|
163
|
+
let key = '';
|
|
164
|
+
if (hasMember) {
|
|
165
|
+
const [iface, member] = term.split('.', 2);
|
|
166
|
+
key = `${norm(iface)}.${norm(member)}`;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
key = norm(term);
|
|
170
|
+
}
|
|
171
|
+
const href = index.get(key);
|
|
172
|
+
if (href) {
|
|
173
|
+
a.setAttribute('href', href);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
warnings.push(`Unresolved IDL link: "${term}"`);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/** Public pass */
|
|
181
|
+
function runIdlPass(root, options) {
|
|
182
|
+
const warnings = [];
|
|
183
|
+
const suppressClass = options.diagnostics?.suppressClass ?? 'no-link-warnings';
|
|
184
|
+
const index = buildIdlIndex(root, warnings);
|
|
185
|
+
resolveIdlLinks(root, index, warnings, suppressClass);
|
|
186
|
+
return warnings;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=idl.js.map
|