@agentshouse/mdmodel 0.1.0-c46ca56158c79 → 0.1.0-c4f4d37bc9d6a
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/API.md +7 -7
- package/README.md +1 -1
- package/dist/blocks.d.ts.map +1 -1
- package/dist/blocks.js +29 -7
- package/dist/condition.d.ts +0 -1
- package/dist/condition.d.ts.map +1 -1
- package/dist/condition.js +0 -1
- package/dist/definition.d.ts +1 -0
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +11 -16
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +15 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +80 -37
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -1
- package/dist/pattern.d.ts +10 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +355 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +4 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +35 -11
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +27 -1
- package/package.json +2 -2
package/API.md
CHANGED
|
@@ -76,10 +76,10 @@ to their siblings and the variants of `anyOf`, `oneOf`, `then`, `else` and `depe
|
|
|
76
76
|
variant's own keys `conditional`; a path without one `type`, `null` aside, has none. A malformed
|
|
77
77
|
schema is refused whole, naming its `rule`, the keyword or the model's own, and the JSON Pointer
|
|
78
78
|
`location` it concerns, such as `/plan/properties/status/enum`, or `line <n>` outside the YAML
|
|
79
|
-
subset. `pointerFacts(definition, pointer)` reads the facts a frontmatter pointer reaches,
|
|
80
|
-
|
|
81
|
-
`pointerSegments` and `escapePointer` split and write a pointer,
|
|
82
|
-
segment, and `ATTACHMENT` is the `reference` that admits any path.
|
|
79
|
+
subset. `pointerFacts(definition, pointer)` reads the facts a frontmatter pointer reaches, `itemFacts`
|
|
80
|
+
and `memberFacts` take one step and `crossedFacts` reads a list's item facts; `JSON_POINTER` matches the
|
|
81
|
+
JSON Pointer grammar, `''` included, `pointerSegments` and `escapePointer` split and write a pointer,
|
|
82
|
+
`ARRAY_INDEX` matches an index segment, and `ATTACHMENT` is the `reference` that admits any path.
|
|
83
83
|
|
|
84
84
|
`validate(library, context?, model?)` takes the resulting text Library and one `ValidationContext`
|
|
85
85
|
of `binaryTargets: readonly string[]`, none when omitted. Library keys and binary targets share one
|
|
@@ -122,9 +122,9 @@ merged or fenced heading is refused as `overlapping-section` naming that section
|
|
|
122
122
|
does not reformat the rest of the file: an inline value is replaced where it stands, and a value
|
|
123
123
|
written after the key's line, an empty one or a block mapping or list, is written after the key's
|
|
124
124
|
colon in its place. A field holds a `FrontmatterValue`: null, a string, a boolean, a finite number,
|
|
125
|
-
a list without holes or a plain object of them,
|
|
126
|
-
test
|
|
127
|
-
two by value, whatever their key order, as `apply`
|
|
125
|
+
a list without holes or a plain object of them, no cycle, at most 63 deep. `frontmatterValue(value)`
|
|
126
|
+
is that test; `apply` refuses any other value and `parse` a frontmatter past 64 deep as
|
|
127
|
+
`frontmatter-fence`. `equalValue` compares two by value, whatever their key order, as `apply` does.
|
|
128
128
|
|
|
129
129
|
`Document.preamble` is a readonly string holding the exact source after frontmatter and before the
|
|
130
130
|
first section heading the section parser recognizes, `''` when empty, whitespace, newlines, a
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ deterministic application of one structured change to a Document, plus a
|
|
|
5
5
|
conformance fixture corpus.
|
|
6
6
|
|
|
7
7
|
It runs in the browser and in Node, makes no network call, and reads no
|
|
8
|
-
filesystem on its own. It ships one ESM artifact that Node 24.
|
|
8
|
+
filesystem on its own. It ships one ESM artifact that Node 24.22.1 and later
|
|
9
9
|
loads through `import` or `require`.
|
|
10
10
|
|
|
11
11
|
## Install
|
package/dist/blocks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAoDF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,EAAE,CA4BrF;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAe/E"}
|
package/dist/blocks.js
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
import { fenceSpans, spanCursor } from './links.js';
|
|
2
|
-
const
|
|
2
|
+
const HEADING_OPEN = /^(#{1,6})(?!#)([ \t]+)/;
|
|
3
|
+
const LINE_BREAK = /[\n\r\u2028\u2029]/;
|
|
4
|
+
function blank(character) {
|
|
5
|
+
return character === ' ' || character === '\t';
|
|
6
|
+
}
|
|
7
|
+
function heading(text) {
|
|
8
|
+
const open = HEADING_OPEN.exec(text);
|
|
9
|
+
if (open === null || LINE_BREAK.test(text))
|
|
10
|
+
return null;
|
|
11
|
+
const level = open[1].length;
|
|
12
|
+
const rest = text.slice(open[0].length);
|
|
13
|
+
if (rest === '')
|
|
14
|
+
return open[2].length > 1 ? { level, name: '' } : null;
|
|
15
|
+
let end = rest.length;
|
|
16
|
+
while (blank(rest[end - 1]))
|
|
17
|
+
end -= 1;
|
|
18
|
+
let hashes = end;
|
|
19
|
+
while (rest[hashes - 1] === '#')
|
|
20
|
+
hashes -= 1;
|
|
21
|
+
let spaced = hashes;
|
|
22
|
+
while (blank(rest[spaced - 1]))
|
|
23
|
+
spaced -= 1;
|
|
24
|
+
const closed = hashes < end && spaced < hashes && spaced > 0;
|
|
25
|
+
return { level, name: rest.slice(0, closed ? spaced : end).trim() };
|
|
26
|
+
}
|
|
3
27
|
function lineAt(content, from, to) {
|
|
4
28
|
const nl = content.indexOf('\n', from);
|
|
5
29
|
const end = nl === -1 || nl >= to ? to : nl;
|
|
@@ -30,13 +54,11 @@ export function headingLines(content, from, to) {
|
|
|
30
54
|
fenced ??= spanCursor(fenceSpans(content.slice(from, to)));
|
|
31
55
|
if (fenced(i - from) === undefined) {
|
|
32
56
|
const { text } = lineAt(content, i, to);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const name = match?.[2];
|
|
36
|
-
if (hashes !== undefined && name !== undefined) {
|
|
57
|
+
const read = heading(text);
|
|
58
|
+
if (read !== null) {
|
|
37
59
|
found.push({
|
|
38
|
-
level:
|
|
39
|
-
name: name
|
|
60
|
+
level: read.level,
|
|
61
|
+
name: read.name,
|
|
40
62
|
start: i,
|
|
41
63
|
textEnd: i + text.length,
|
|
42
64
|
next,
|
package/dist/condition.d.ts
CHANGED
|
@@ -121,7 +121,6 @@ export type ItemFacts = {
|
|
|
121
121
|
readonly delivery: string;
|
|
122
122
|
readonly source: string | null;
|
|
123
123
|
readonly address: string | null;
|
|
124
|
-
readonly has_attachment: boolean;
|
|
125
124
|
readonly container: string | null;
|
|
126
125
|
readonly author: string | null;
|
|
127
126
|
readonly headers: Readonly<Record<string, string>>;
|
package/dist/condition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../src/condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,UAAU,EAEf,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvD,eAAO,MAAM,mBAAmB,YAC9B,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,CACA,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,GAC1C;IAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,aAAa,EAAE,CAAA;CAAE,GAC1C;IAAE,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAA;CAAE,GAC/B,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,CACzB;IAAE,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,EAAE,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,GAC1C;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAA;CAA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iBAAiB,EAAE,CAExE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAEtD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAIrD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAgC1D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAahE;AA+GD,wBAAgB,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAahF;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,GAAG,KAAK,CAEzE;AAkFD,wBAAgB,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAiBjF;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAM5E"}
|
package/dist/condition.js
CHANGED
|
@@ -304,7 +304,6 @@ const ACTOR_TESTS = [
|
|
|
304
304
|
const ITEM_TESTS = [
|
|
305
305
|
envelope('/delivery', 'enum', (item) => item.delivery),
|
|
306
306
|
envelope('/source', 'enum', (item) => item.source),
|
|
307
|
-
envelope('/has_attachment', 'boolean', (item) => item.has_attachment),
|
|
308
307
|
envelope('/container', 'string', (item) => item.container),
|
|
309
308
|
envelope('/author', 'string', (item) => item.author),
|
|
310
309
|
{
|
package/dist/definition.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export declare const JSON_TYPES: readonly JsonType[];
|
|
|
60
60
|
export declare const BUILT_IN_TYPE = "any";
|
|
61
61
|
export declare const ATTACHMENT = "attachment";
|
|
62
62
|
export declare const ARRAY_INDEX: RegExp;
|
|
63
|
+
export declare const JSON_POINTER: RegExp;
|
|
63
64
|
export declare function escapePointer(key: string): string;
|
|
64
65
|
export declare function pointerSegments(pointer: string): string[];
|
|
65
66
|
export declare function refTarget(reference: string, defs: Readonly<Record<string, unknown>>): {
|
package/dist/definition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjG,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;CAClC,CAAC;AAE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D,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,UAAU,CAE7F;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAElF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAKlF;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,CAK5D;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAItF;AAqBD,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAc9F;AAuQD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,aAAwB,GACjC,aAAa,GAAG,OAAO,CAsCzB"}
|
package/dist/definition.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
2
|
+
import { linearPattern } from './pattern.js';
|
|
2
3
|
import { equalValue, isRecord, jsValue, parseYamlMapping, YamlError } from './yaml.js';
|
|
3
4
|
export const JSON_TYPES = [
|
|
4
5
|
'string',
|
|
@@ -27,8 +28,10 @@ const FIELD_RULES = ['change_roles', 'initial_roles', 'transitions'];
|
|
|
27
28
|
const PROVIDED_KEYWORDS = ['create_roles', 'delete_roles'];
|
|
28
29
|
const NO_TYPES = Object.freeze({ types: Object.freeze({}) });
|
|
29
30
|
const DEFS_REFERENCE = '#/$defs/';
|
|
31
|
+
const UNBOUNDED_FORMAT = 'url';
|
|
30
32
|
const UNRESOLVED = /[\u0000-\u001f\u007f%[\]\\^{|}]|\s$/u;
|
|
31
33
|
export const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
|
|
34
|
+
export const JSON_POINTER = /^(?:\/(?:[^~/]|~[01])*)*$/u;
|
|
32
35
|
const HOUSE_KEYS = {
|
|
33
36
|
[TYPE_FIELD]: { prose: false },
|
|
34
37
|
[SITE_FIELD]: { prose: false },
|
|
@@ -47,12 +50,12 @@ export function pointerSegments(pointer) {
|
|
|
47
50
|
return pointer.split('/').slice(1).map(unescapePointer);
|
|
48
51
|
}
|
|
49
52
|
export function refTarget(reference, defs) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (segments.some((segment) => escapePointer(unescapePointer(segment)) !== segment))
|
|
53
|
+
const pointer = reference.slice('#'.length);
|
|
54
|
+
if (!reference.startsWith(DEFS_REFERENCE) ||
|
|
55
|
+
UNRESOLVED.test(reference) ||
|
|
56
|
+
!JSON_POINTER.test(pointer))
|
|
55
57
|
return undefined;
|
|
58
|
+
const [, name = '', ...rest] = pointerSegments(pointer);
|
|
56
59
|
if (!Object.hasOwn(defs, name))
|
|
57
60
|
return undefined;
|
|
58
61
|
let node = defs[name];
|
|
@@ -83,15 +86,7 @@ export function refTarget(reference, defs) {
|
|
|
83
86
|
return { name, node };
|
|
84
87
|
}
|
|
85
88
|
function compiles(pattern) {
|
|
86
|
-
|
|
87
|
-
return false;
|
|
88
|
-
try {
|
|
89
|
-
new RegExp(pattern, 'u');
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
89
|
+
return typeof pattern === 'string' && linearPattern(pattern) !== null;
|
|
95
90
|
}
|
|
96
91
|
function finite(value) {
|
|
97
92
|
return typeof value === 'number' && Number.isFinite(value);
|
|
@@ -201,7 +196,7 @@ const KEYWORDS = {
|
|
|
201
196
|
uniqueItems: FLAG,
|
|
202
197
|
required: strings,
|
|
203
198
|
dependentRequired: (value) => isRecord(value) && Object.values(value).every(strings),
|
|
204
|
-
format:
|
|
199
|
+
format: (value) => typeof value === 'string' && value !== UNBOUNDED_FORMAT,
|
|
205
200
|
contentEncoding: TEXT,
|
|
206
201
|
contentMediaType: TEXT,
|
|
207
202
|
title: TEXT,
|
|
@@ -449,7 +444,7 @@ export function itemFacts(facts, index) {
|
|
|
449
444
|
export function memberFacts(facts, key) {
|
|
450
445
|
if (facts.properties !== undefined && Object.hasOwn(facts.properties, key))
|
|
451
446
|
return facts.properties[key];
|
|
452
|
-
const pattern = facts.patterns?.find((one) =>
|
|
447
|
+
const pattern = facts.patterns?.find((one) => linearPattern(one.pattern).test(key));
|
|
453
448
|
return pattern === undefined ? facts.additional : pattern.facts;
|
|
454
449
|
}
|
|
455
450
|
export function crossedFacts(facts) {
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAcpB,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAcL,KAAK,OAAO,EAEb,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChF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C,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAEpD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAE9D"}
|
package/dist/document.js
CHANGED
|
@@ -5,29 +5,31 @@ import { references } from './references.js';
|
|
|
5
5
|
import { headingSpans, sectionsRecord } from './sections.js';
|
|
6
6
|
import { refusal } from './refuse.js';
|
|
7
7
|
import { bodyStartAfterYaml, bodyStartOf, equalValue, extractFrontmatter, frontmatterValue, jsValue, lineEnding, mapEntry, parseYamlMapping, serializeJs, serializeKey, YamlError, } from './yaml.js';
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
const HELD = Symbol('held');
|
|
9
|
+
function heldOf(document) {
|
|
10
|
+
return document[HELD];
|
|
11
|
+
}
|
|
10
12
|
export function inventoryOf(document) {
|
|
11
|
-
const held =
|
|
12
|
-
if (held !== undefined)
|
|
13
|
-
return held;
|
|
13
|
+
const held = heldOf(document);
|
|
14
|
+
if (held?.inventory !== undefined)
|
|
15
|
+
return held.inventory;
|
|
14
16
|
const inventory = linkInventory(document.content.slice(bodyStartOf(document.content)));
|
|
15
|
-
|
|
17
|
+
if (held !== undefined)
|
|
18
|
+
held.inventory = inventory;
|
|
16
19
|
return inventory;
|
|
17
20
|
}
|
|
18
21
|
function refuse(file, rule, location) {
|
|
19
22
|
return location === undefined ? refusal(file, rule) : refusal(file, rule, { location });
|
|
20
23
|
}
|
|
21
24
|
function freezeDocument(content, type, fields, preamble, sections, internal) {
|
|
22
|
-
const
|
|
25
|
+
const held = { internal, inventory: undefined };
|
|
26
|
+
return Object.freeze(Object.defineProperty({
|
|
23
27
|
content,
|
|
24
28
|
type,
|
|
25
29
|
fields: Object.freeze(fields),
|
|
26
30
|
preamble,
|
|
27
31
|
sections: Object.freeze(sections),
|
|
28
|
-
});
|
|
29
|
-
internals.set(document, internal);
|
|
30
|
-
return document;
|
|
32
|
+
}, HELD, { value: held }));
|
|
31
33
|
}
|
|
32
34
|
function declaredType(fields) {
|
|
33
35
|
const value = fields.type;
|
|
@@ -222,9 +224,9 @@ export function bodyLinks(body, file) {
|
|
|
222
224
|
return linksIn(hrefOccurrences(body), file);
|
|
223
225
|
}
|
|
224
226
|
function internalOf(document) {
|
|
225
|
-
const held =
|
|
227
|
+
const held = heldOf(document);
|
|
226
228
|
if (held !== undefined)
|
|
227
|
-
return held;
|
|
229
|
+
return held.internal;
|
|
228
230
|
const read = opened(document.content, '');
|
|
229
231
|
if (!read.ok)
|
|
230
232
|
return read.refusal;
|
|
@@ -461,5 +463,5 @@ export function serialize(document) {
|
|
|
461
463
|
return document.content;
|
|
462
464
|
}
|
|
463
465
|
export function frontmatter(document) {
|
|
464
|
-
return
|
|
466
|
+
return heldOf(document)?.internal.root ?? null;
|
|
465
467
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { RoomTarget } from './paths.js';
|
|
|
10
10
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
11
11
|
export { project } from './project.js';
|
|
12
12
|
export { references } from './references.js';
|
|
13
|
-
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
13
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
14
14
|
export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, SectionSpec, Shape, Transition, ValueFacts, } from './definition.js';
|
|
15
15
|
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, RoomReference, Span, Validation, ValidationContext, ValidationStep, VerifiedModel, } from './types.js';
|
|
16
16
|
export { assess, bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verdicts, verify, } from './validate.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,KAAK,EACL,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,UAAU,EACV,SAAS,EACT,QAAQ,EACR,aAAa,EACb,cAAc,EACd,OAAO,EACP,OAAO,EACP,UAAU,EACV,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,KAAK,EACL,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,KAAK,EACL,SAAS,EACT,KAAK,EACL,KAAK,EACL,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,UAAU,EACV,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC9E,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,aAAa,EACb,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,KAAK,EACL,UAAU,EACV,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,MAAM,EACN,aAAa,EACb,aAAa,EACb,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,KAAK,EACL,YA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EACZ,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,KAAK,EACL,UAAU,EACV,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,MAAM,EACN,aAAa,EACb,aAAa,EACb,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export { relative, retarget, roomPath, roomTarget, target } from './paths.js';
|
|
|
7
7
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
8
8
|
export { project } from './project.js';
|
|
9
9
|
export { references } from './references.js';
|
|
10
|
-
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
10
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
11
11
|
export { assess, bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verdicts, verify, } from './validate.js';
|
|
12
12
|
export { VERSION } from './version.js';
|
|
13
13
|
export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
|
package/dist/links.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAgiBA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5D;AAyLD,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,GAC5C,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAOvC;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;CAC7C,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAe/E;AA+CD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAmEzD;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,cAAc,EAAE,CAIhF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,cAAc,EAAE,CAEvE"}
|
package/dist/links.js
CHANGED
|
@@ -17,17 +17,28 @@ const HTML_TAG_LINE = /^(?:<[A-Za-z][A-Za-z0-9-]*(?:[ \t\v\f]+[A-Za-z_:][A-Za-z0
|
|
|
17
17
|
const ORDERED = /^(\d{1,9})[.)]/;
|
|
18
18
|
const LABEL_LENGTH = 999;
|
|
19
19
|
const PUNCTUATION = /^[!-/:-@[-`{-~]$/;
|
|
20
|
-
const
|
|
20
|
+
const INLINE_TAG = new RegExp([
|
|
21
21
|
'<[A-Za-z][A-Za-z0-9-]*(?:[ \\t\\n\\v\\f\\r]+[A-Za-z_:][A-Za-z0-9_.:-]*(?:[ \\t\\n\\v\\f\\r]*=[ \\t\\n\\v\\f\\r]*(?:[^ \\t\\n\\v\\f\\r"\'=<>`]+|\'[^\']*\'|"[^"]*"))?)*[ \\t\\n\\v\\f\\r]*\\/?>',
|
|
22
22
|
'<\\/[A-Za-z][A-Za-z0-9-]*[ \\t\\n\\v\\f\\r]*>',
|
|
23
23
|
'<!--(?!-?>)(?:-?[^-])*-->',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'<!\\[CDATA\\[[\\s\\S]*?\\]\\]>',
|
|
24
|
+
].join('|'), 'y');
|
|
25
|
+
const AUTOLINK = new RegExp([
|
|
27
26
|
'<[A-Za-z][A-Za-z0-9+.-]{1,31}:[^\\x00-\\x20<>]*>',
|
|
28
27
|
"<[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*>",
|
|
29
28
|
].join('|'), 'y');
|
|
30
|
-
const
|
|
29
|
+
const DECLARATION = /<![A-Z]+[ \t\n\v\f\r]/y;
|
|
30
|
+
const INSTRUCTION = '<?';
|
|
31
|
+
const CDATA = '<![CDATA[';
|
|
32
|
+
const BACKSLASH = 0x5c;
|
|
33
|
+
const BACKTICK = 0x60;
|
|
34
|
+
const LINE_FEED = 0x0a;
|
|
35
|
+
const CARRIAGE_RETURN = 0x0d;
|
|
36
|
+
const LESS_THAN = 0x3c;
|
|
37
|
+
const OPEN_BRACKET = 0x5b;
|
|
38
|
+
const CLOSE_BRACKET = 0x5d;
|
|
39
|
+
const EXCLAMATION = 0x21;
|
|
40
|
+
const OPEN_PAREN = 0x28;
|
|
41
|
+
const DELIMITER_ROW = /^\|?[ \t]*:?-+:?(?:[ \t]*\|[ \t]*:?-+:?)*(?:[ \t]*\|)?[ \t]*$/;
|
|
31
42
|
const GAP = /^[ \t\v\f]+/;
|
|
32
43
|
function endOfLine(text, from) {
|
|
33
44
|
const nl = text.indexOf('\n', from);
|
|
@@ -164,10 +175,10 @@ function skipInlineCode(text, index, joins, unclosed) {
|
|
|
164
175
|
const runs = new Map();
|
|
165
176
|
let i = index + ticks;
|
|
166
177
|
while (i < text.length) {
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
178
|
+
const code = text.charCodeAt(i);
|
|
179
|
+
if (code === BACKTICK) {
|
|
169
180
|
let run = 0;
|
|
170
|
-
while (text
|
|
181
|
+
while (text.charCodeAt(i + run) === BACKTICK)
|
|
171
182
|
run += 1;
|
|
172
183
|
if (run === ticks)
|
|
173
184
|
return i + run;
|
|
@@ -175,9 +186,9 @@ function skipInlineCode(text, index, joins, unclosed) {
|
|
|
175
186
|
i += run;
|
|
176
187
|
continue;
|
|
177
188
|
}
|
|
178
|
-
if (
|
|
189
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
179
190
|
break;
|
|
180
|
-
if (
|
|
191
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
181
192
|
break;
|
|
182
193
|
i += 1;
|
|
183
194
|
}
|
|
@@ -200,21 +211,21 @@ function skipInlineSpace(text, start, joins) {
|
|
|
200
211
|
return afterIndent(text, readLine(text, i + 1, endOfLine(text, i + 1)));
|
|
201
212
|
}
|
|
202
213
|
function closeEnd(text, start, open, joins) {
|
|
203
|
-
const close = open === '(' ? ')' : open;
|
|
214
|
+
const close = (open === '(' ? ')' : open).charCodeAt(0);
|
|
204
215
|
let i = start;
|
|
205
216
|
while (i < text.length) {
|
|
206
|
-
const
|
|
217
|
+
const code = text.charCodeAt(i);
|
|
207
218
|
if (escapes(text, i)) {
|
|
208
219
|
i += 2;
|
|
209
220
|
continue;
|
|
210
221
|
}
|
|
211
|
-
if (
|
|
222
|
+
if (code === close)
|
|
212
223
|
return i + 1;
|
|
213
|
-
if (open === '(' &&
|
|
224
|
+
if (open === '(' && code === OPEN_PAREN)
|
|
214
225
|
return null;
|
|
215
|
-
if (
|
|
226
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
216
227
|
return null;
|
|
217
|
-
if (
|
|
228
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
218
229
|
return null;
|
|
219
230
|
i += 1;
|
|
220
231
|
}
|
|
@@ -511,23 +522,23 @@ function structure(text) {
|
|
|
511
522
|
return { joins, raw };
|
|
512
523
|
}
|
|
513
524
|
export function escapes(text, index) {
|
|
514
|
-
return text
|
|
525
|
+
return text.charCodeAt(index) === BACKSLASH && PUNCTUATION.test(text[index + 1] ?? '');
|
|
515
526
|
}
|
|
516
527
|
function referenceEnd(text, start, joins) {
|
|
517
528
|
let i = start;
|
|
518
529
|
while (i < text.length) {
|
|
519
|
-
const
|
|
530
|
+
const code = text.charCodeAt(i);
|
|
520
531
|
if (escapes(text, i)) {
|
|
521
532
|
i += 2;
|
|
522
533
|
continue;
|
|
523
534
|
}
|
|
524
|
-
if (
|
|
535
|
+
if (code === CLOSE_BRACKET)
|
|
525
536
|
return i + 1;
|
|
526
|
-
if (
|
|
537
|
+
if (code === OPEN_BRACKET)
|
|
527
538
|
return -1;
|
|
528
|
-
if (
|
|
539
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
529
540
|
return -1;
|
|
530
|
-
if (
|
|
541
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
531
542
|
return -1;
|
|
532
543
|
i += 1;
|
|
533
544
|
}
|
|
@@ -702,14 +713,45 @@ export function fenceSpans(text) {
|
|
|
702
713
|
function paragraphEnd(text, from, joins) {
|
|
703
714
|
let i = from;
|
|
704
715
|
while (i < text.length) {
|
|
705
|
-
|
|
716
|
+
const code = text.charCodeAt(i);
|
|
717
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
706
718
|
return i;
|
|
707
|
-
if (
|
|
719
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
708
720
|
return i;
|
|
709
721
|
i += 1;
|
|
710
722
|
}
|
|
711
723
|
return i;
|
|
712
724
|
}
|
|
725
|
+
function closerAt(text, closer, from, closers) {
|
|
726
|
+
const held = closers.get(closer);
|
|
727
|
+
if (held !== undefined && from >= held[0] && (held[1] === -1 || from <= held[1]))
|
|
728
|
+
return held[1];
|
|
729
|
+
const at = text.indexOf(closer, from);
|
|
730
|
+
closers.set(closer, [from, at]);
|
|
731
|
+
return at;
|
|
732
|
+
}
|
|
733
|
+
function closedAfter(text, closer, from, closers) {
|
|
734
|
+
const at = closerAt(text, closer, from, closers);
|
|
735
|
+
return at === -1 ? -1 : at + closer.length;
|
|
736
|
+
}
|
|
737
|
+
function stuck(pattern, text, at) {
|
|
738
|
+
pattern.lastIndex = at;
|
|
739
|
+
return pattern.test(text) ? pattern.lastIndex : -1;
|
|
740
|
+
}
|
|
741
|
+
function markupEnd(text, at, closers) {
|
|
742
|
+
if (text.startsWith(INSTRUCTION, at))
|
|
743
|
+
return closedAfter(text, '?>', at + INSTRUCTION.length, closers);
|
|
744
|
+
if (text.startsWith(CDATA, at))
|
|
745
|
+
return closedAfter(text, ']]>', at + CDATA.length, closers);
|
|
746
|
+
const declared = stuck(DECLARATION, text, at);
|
|
747
|
+
if (declared !== -1)
|
|
748
|
+
return closedAfter(text, '>', declared, closers);
|
|
749
|
+
return stuck(INLINE_TAG, text, at);
|
|
750
|
+
}
|
|
751
|
+
function inlineRawEnd(text, at, closers) {
|
|
752
|
+
const end = markupEnd(text, at, closers);
|
|
753
|
+
return end === -1 ? stuck(AUTOLINK, text, at) : end;
|
|
754
|
+
}
|
|
713
755
|
export function linkInventory(body) {
|
|
714
756
|
const { raw, definitions, blocks, joins } = scanBlocks(body);
|
|
715
757
|
const rawEnd = spanCursor(raw);
|
|
@@ -717,7 +759,7 @@ export function linkInventory(body) {
|
|
|
717
759
|
const uses = [];
|
|
718
760
|
const openers = [];
|
|
719
761
|
const unclosed = { stop: 0, runs: new Map() };
|
|
720
|
-
let paragraph = { start: 0, end: -1, text: '' };
|
|
762
|
+
let paragraph = { start: 0, end: -1, text: '', closers: new Map() };
|
|
721
763
|
let i = 0;
|
|
722
764
|
while (i < body.length) {
|
|
723
765
|
const skipEnd = rawEnd(i) ?? blockEnd(i);
|
|
@@ -726,39 +768,40 @@ export function linkInventory(body) {
|
|
|
726
768
|
i = skipEnd;
|
|
727
769
|
continue;
|
|
728
770
|
}
|
|
729
|
-
const
|
|
771
|
+
const code = body.charCodeAt(i);
|
|
730
772
|
if (escapes(body, i)) {
|
|
731
773
|
i += 2;
|
|
732
774
|
continue;
|
|
733
775
|
}
|
|
734
|
-
if (
|
|
776
|
+
if (code === BACKTICK) {
|
|
735
777
|
i = skipInlineCode(body, i, joins, unclosed);
|
|
736
778
|
continue;
|
|
737
779
|
}
|
|
738
|
-
if (
|
|
780
|
+
if (code === LESS_THAN) {
|
|
739
781
|
if (i >= paragraph.end) {
|
|
740
782
|
const end = paragraphEnd(body, i, joins);
|
|
741
|
-
paragraph = { start: i, end, text: body.slice(i, end) };
|
|
783
|
+
paragraph = { start: i, end, text: body.slice(i, end), closers: new Map() };
|
|
742
784
|
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
i += raw[0].length;
|
|
785
|
+
const raw = inlineRawEnd(paragraph.text, i - paragraph.start, paragraph.closers);
|
|
786
|
+
if (raw !== -1) {
|
|
787
|
+
i = paragraph.start + raw;
|
|
747
788
|
continue;
|
|
748
789
|
}
|
|
749
790
|
}
|
|
750
|
-
if ((
|
|
791
|
+
if ((code === LINE_FEED && !joins.has(i)) ||
|
|
792
|
+
(code === CARRIAGE_RETURN && body.charCodeAt(i + 1) !== LINE_FEED))
|
|
751
793
|
openers.length = 0;
|
|
752
|
-
if (
|
|
794
|
+
if (code === OPEN_BRACKET ||
|
|
795
|
+
(code === EXCLAMATION && body.charCodeAt(i + 1) === OPEN_BRACKET)) {
|
|
753
796
|
const previous = openers.at(-1);
|
|
754
797
|
if (previous !== undefined)
|
|
755
798
|
previous.bracketAfter = true;
|
|
756
|
-
const image =
|
|
799
|
+
const image = code === EXCLAMATION;
|
|
757
800
|
openers.push({ at: image ? i + 1 : i, start: i, image, active: true, bracketAfter: false });
|
|
758
801
|
i += image ? 2 : 1;
|
|
759
802
|
continue;
|
|
760
803
|
}
|
|
761
|
-
if (
|
|
804
|
+
if (code === CLOSE_BRACKET) {
|
|
762
805
|
const opener = openers.pop();
|
|
763
806
|
const use = opener?.active ? closeLink(body, opener, i, definitions, joins) : null;
|
|
764
807
|
if (opener === undefined || use === null) {
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;AAwDD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW3D;AAgBD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAY5E,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAEV;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAAC,GAC/B;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAatB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAG1D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGpD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMvE"}
|
package/dist/paths.js
CHANGED
|
@@ -61,7 +61,10 @@ function located(href) {
|
|
|
61
61
|
const written = href.trim();
|
|
62
62
|
const { base, suffix } = unescaped(written);
|
|
63
63
|
const url = base.replace(/[\t\n\r]/g, '').replace(/^[\u0000-\u0020]+/, '');
|
|
64
|
-
return {
|
|
64
|
+
return {
|
|
65
|
+
base: suffix === written.length ? url.replace(/(?<![\u0000-\u0020])[\u0000-\u0020]+$/, '') : url,
|
|
66
|
+
suffix,
|
|
67
|
+
};
|
|
65
68
|
}
|
|
66
69
|
const ENCODED = /(?:%[0-9a-fA-F]{2})+/g;
|
|
67
70
|
function decodedRun(run) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const PATTERN_STATES = 1000;
|
|
2
|
+
export declare class PatternTooCostly extends Error {
|
|
3
|
+
}
|
|
4
|
+
export type Pattern = {
|
|
5
|
+
readonly test: (text: string) => boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function linearPattern(source: string): Pattern | null;
|
|
8
|
+
export declare function withLinearRegExp<T>(run: () => T): T;
|
|
9
|
+
export declare function openPatternBudget(): () => void;
|
|
10
|
+
//# sourceMappingURL=pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../src/pattern.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,OAAQ,CAAC;AAMpC,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAQ9C,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,CAAC;AAiUnE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAM5D;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAkBnD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,IAAI,CAM9C"}
|
package/dist/pattern.js
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
const NativeRegExp = RegExp;
|
|
2
|
+
export const PATTERN_STATES = 1_000;
|
|
3
|
+
const VISIT_BUDGET = 100_000_000;
|
|
4
|
+
const HELD_PATTERNS = 512;
|
|
5
|
+
export class PatternTooCostly extends Error {
|
|
6
|
+
}
|
|
7
|
+
let scope = null;
|
|
8
|
+
const ASCII = 128;
|
|
9
|
+
class Unsupported extends Error {
|
|
10
|
+
}
|
|
11
|
+
const ATOM = 0;
|
|
12
|
+
const SPLIT = 1;
|
|
13
|
+
const ASSERT = 2;
|
|
14
|
+
const MATCH = 3;
|
|
15
|
+
class Atom {
|
|
16
|
+
literal;
|
|
17
|
+
ascii = new Int8Array(ASCII);
|
|
18
|
+
matcher;
|
|
19
|
+
constructor(source, literal) {
|
|
20
|
+
this.literal = literal;
|
|
21
|
+
this.matcher = new NativeRegExp(`^(?:${source})$`, 'u');
|
|
22
|
+
}
|
|
23
|
+
holds(point) {
|
|
24
|
+
if (this.literal !== null)
|
|
25
|
+
return point === this.literal;
|
|
26
|
+
if (point >= ASCII)
|
|
27
|
+
return this.matcher.test(String.fromCodePoint(point));
|
|
28
|
+
const known = this.ascii[point];
|
|
29
|
+
if (known !== 0)
|
|
30
|
+
return known > 0;
|
|
31
|
+
const held = this.matcher.test(String.fromCharCode(point));
|
|
32
|
+
this.ascii[point] = held ? 1 : -1;
|
|
33
|
+
return held;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class Reader {
|
|
37
|
+
source;
|
|
38
|
+
at = 0;
|
|
39
|
+
constructor(source) {
|
|
40
|
+
this.source = source;
|
|
41
|
+
}
|
|
42
|
+
peek(offset = 0) {
|
|
43
|
+
return this.source[this.at + offset];
|
|
44
|
+
}
|
|
45
|
+
starts(text) {
|
|
46
|
+
return this.source.startsWith(text, this.at);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function digits(reader) {
|
|
50
|
+
const from = reader.at;
|
|
51
|
+
while (/[0-9]/.test(reader.peek() ?? ''))
|
|
52
|
+
reader.at += 1;
|
|
53
|
+
return reader.at === from ? null : Number(reader.source.slice(from, reader.at));
|
|
54
|
+
}
|
|
55
|
+
function escapeEnd(source, at) {
|
|
56
|
+
const next = source[at + 1];
|
|
57
|
+
if (next === 'c')
|
|
58
|
+
return at + 3;
|
|
59
|
+
if (next === 'x')
|
|
60
|
+
return at + 4;
|
|
61
|
+
if ((next === 'u' && source[at + 2] === '{') || next === 'p' || next === 'P')
|
|
62
|
+
return source.indexOf('}', at + 2) + 1;
|
|
63
|
+
if (next !== 'u')
|
|
64
|
+
return at + 2;
|
|
65
|
+
const end = at + 6;
|
|
66
|
+
const lead = Number.parseInt(source.slice(at + 2, end), 16);
|
|
67
|
+
const trail = /^\\u([0-9a-fA-F]{4})$/.exec(source.slice(end, end + 6))?.[1];
|
|
68
|
+
const paired = lead >= 0xd800 &&
|
|
69
|
+
lead <= 0xdbff &&
|
|
70
|
+
trail !== undefined &&
|
|
71
|
+
Number.parseInt(trail, 16) >= 0xdc00 &&
|
|
72
|
+
Number.parseInt(trail, 16) <= 0xdfff;
|
|
73
|
+
return paired ? end + 6 : end;
|
|
74
|
+
}
|
|
75
|
+
function classEnd(source, at) {
|
|
76
|
+
let i = at + 1;
|
|
77
|
+
while (source[i] !== ']')
|
|
78
|
+
i += source[i] === '\\' ? 2 : 1;
|
|
79
|
+
return i + 1;
|
|
80
|
+
}
|
|
81
|
+
function escaped(reader) {
|
|
82
|
+
const next = reader.peek(1);
|
|
83
|
+
if (next === 'b' || next === 'B') {
|
|
84
|
+
reader.at += 2;
|
|
85
|
+
return { kind: 'assert', assertion: next === 'b' ? 'boundary' : 'inside' };
|
|
86
|
+
}
|
|
87
|
+
if (/[1-9k]/.test(next))
|
|
88
|
+
throw new Unsupported();
|
|
89
|
+
const end = escapeEnd(reader.source, reader.at);
|
|
90
|
+
const source = reader.source.slice(reader.at, end);
|
|
91
|
+
reader.at = end;
|
|
92
|
+
return { kind: 'atom', source, literal: false };
|
|
93
|
+
}
|
|
94
|
+
function group(reader) {
|
|
95
|
+
reader.at += 1;
|
|
96
|
+
if (reader.starts('?:'))
|
|
97
|
+
reader.at += 2;
|
|
98
|
+
else if (reader.starts('?<') && !reader.starts('?<=') && !reader.starts('?<!'))
|
|
99
|
+
reader.at = reader.source.indexOf('>', reader.at) + 1;
|
|
100
|
+
else if (reader.peek() === '?')
|
|
101
|
+
throw new Unsupported();
|
|
102
|
+
const alternatives = disjunction(reader);
|
|
103
|
+
reader.at += 1;
|
|
104
|
+
return { kind: 'group', alternatives };
|
|
105
|
+
}
|
|
106
|
+
function atom(reader) {
|
|
107
|
+
const character = reader.peek();
|
|
108
|
+
if (character === '^' || character === '$') {
|
|
109
|
+
reader.at += 1;
|
|
110
|
+
return { kind: 'assert', assertion: character === '^' ? 'start' : 'end' };
|
|
111
|
+
}
|
|
112
|
+
if (character === '\\')
|
|
113
|
+
return escaped(reader);
|
|
114
|
+
if (character === '(')
|
|
115
|
+
return group(reader);
|
|
116
|
+
if (character === '[' || character === '.') {
|
|
117
|
+
const end = character === '[' ? classEnd(reader.source, reader.at) : reader.at + 1;
|
|
118
|
+
const source = reader.source.slice(reader.at, end);
|
|
119
|
+
reader.at = end;
|
|
120
|
+
return { kind: 'atom', source, literal: false };
|
|
121
|
+
}
|
|
122
|
+
const source = String.fromCodePoint(reader.source.codePointAt(reader.at));
|
|
123
|
+
reader.at += source.length;
|
|
124
|
+
return { kind: 'atom', source, literal: true };
|
|
125
|
+
}
|
|
126
|
+
function quantified(reader, node) {
|
|
127
|
+
const sign = reader.peek();
|
|
128
|
+
let least = 1;
|
|
129
|
+
let most = 1;
|
|
130
|
+
if (sign === '*' || sign === '+' || sign === '?') {
|
|
131
|
+
reader.at += 1;
|
|
132
|
+
least = sign === '+' ? 1 : 0;
|
|
133
|
+
most = sign === '?' ? 1 : Infinity;
|
|
134
|
+
}
|
|
135
|
+
else if (sign === '{') {
|
|
136
|
+
reader.at += 1;
|
|
137
|
+
least = digits(reader);
|
|
138
|
+
most = least;
|
|
139
|
+
if (reader.peek() === ',') {
|
|
140
|
+
reader.at += 1;
|
|
141
|
+
most = digits(reader) ?? Infinity;
|
|
142
|
+
}
|
|
143
|
+
reader.at += 1;
|
|
144
|
+
}
|
|
145
|
+
else
|
|
146
|
+
return { node, least, most };
|
|
147
|
+
if (reader.peek() === '?')
|
|
148
|
+
reader.at += 1;
|
|
149
|
+
if (least > PATTERN_STATES || (Number.isFinite(most) && most > PATTERN_STATES))
|
|
150
|
+
throw new Unsupported();
|
|
151
|
+
return { node, least, most };
|
|
152
|
+
}
|
|
153
|
+
function disjunction(reader) {
|
|
154
|
+
const alternatives = [[]];
|
|
155
|
+
while (reader.at < reader.source.length && reader.peek() !== ')') {
|
|
156
|
+
if (reader.peek() === '|') {
|
|
157
|
+
reader.at += 1;
|
|
158
|
+
alternatives.push([]);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
alternatives.at(-1).push(quantified(reader, atom(reader)));
|
|
162
|
+
}
|
|
163
|
+
return alternatives;
|
|
164
|
+
}
|
|
165
|
+
class Machine {
|
|
166
|
+
kinds = [];
|
|
167
|
+
outs = [];
|
|
168
|
+
alternates = [];
|
|
169
|
+
atoms = [];
|
|
170
|
+
assertions = [];
|
|
171
|
+
atomed = new Map();
|
|
172
|
+
state(kind, out, alternate = -1) {
|
|
173
|
+
if (this.kinds.length >= PATTERN_STATES)
|
|
174
|
+
throw new Unsupported();
|
|
175
|
+
this.kinds.push(kind);
|
|
176
|
+
this.outs.push(out);
|
|
177
|
+
this.alternates.push(alternate);
|
|
178
|
+
return this.kinds.length - 1;
|
|
179
|
+
}
|
|
180
|
+
atom(source, literal) {
|
|
181
|
+
const known = this.atomed.get(source);
|
|
182
|
+
if (known !== undefined)
|
|
183
|
+
return known;
|
|
184
|
+
this.atoms.push(new Atom(source, literal ? source.codePointAt(0) : null));
|
|
185
|
+
this.atomed.set(source, this.atoms.length - 1);
|
|
186
|
+
return this.atoms.length - 1;
|
|
187
|
+
}
|
|
188
|
+
node(node, next) {
|
|
189
|
+
if (node.kind === 'atom')
|
|
190
|
+
return this.state(ATOM, next, this.atom(node.source, node.literal));
|
|
191
|
+
if (node.kind === 'assert') {
|
|
192
|
+
this.assertions.push(node.assertion);
|
|
193
|
+
return this.state(ASSERT, next, this.assertions.length - 1);
|
|
194
|
+
}
|
|
195
|
+
return this.alternatives(node.alternatives, next);
|
|
196
|
+
}
|
|
197
|
+
alternatives(alternatives, next) {
|
|
198
|
+
let entry = this.sequence(alternatives.at(-1), next);
|
|
199
|
+
for (let index = alternatives.length - 2; index >= 0; index -= 1)
|
|
200
|
+
entry = this.state(SPLIT, this.sequence(alternatives[index], next), entry);
|
|
201
|
+
return entry;
|
|
202
|
+
}
|
|
203
|
+
sequence(terms, next) {
|
|
204
|
+
let entry = next;
|
|
205
|
+
for (let index = terms.length - 1; index >= 0; index -= 1)
|
|
206
|
+
entry = this.term(terms[index], entry);
|
|
207
|
+
return entry;
|
|
208
|
+
}
|
|
209
|
+
term({ node, least, most }, next) {
|
|
210
|
+
if (least === 1 && most === 1)
|
|
211
|
+
return this.node(node, next);
|
|
212
|
+
let entry = next;
|
|
213
|
+
if (most === Infinity) {
|
|
214
|
+
const loop = this.state(SPLIT, -1, next);
|
|
215
|
+
const body = this.node(node, loop);
|
|
216
|
+
if (body === loop)
|
|
217
|
+
return next;
|
|
218
|
+
this.outs[loop] = body;
|
|
219
|
+
entry = loop;
|
|
220
|
+
}
|
|
221
|
+
else
|
|
222
|
+
for (let copy = least; copy < most; copy += 1) {
|
|
223
|
+
const body = this.node(node, entry);
|
|
224
|
+
if (body === entry)
|
|
225
|
+
return next;
|
|
226
|
+
entry = this.state(SPLIT, body, entry);
|
|
227
|
+
}
|
|
228
|
+
for (let copy = 0; copy < least; copy += 1) {
|
|
229
|
+
const body = this.node(node, entry);
|
|
230
|
+
if (body === entry)
|
|
231
|
+
return next;
|
|
232
|
+
entry = body;
|
|
233
|
+
}
|
|
234
|
+
return entry;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function word(point) {
|
|
238
|
+
return ((point >= 0x30 && point <= 0x39) ||
|
|
239
|
+
(point >= 0x41 && point <= 0x5a) ||
|
|
240
|
+
(point >= 0x61 && point <= 0x7a) ||
|
|
241
|
+
point === 0x5f);
|
|
242
|
+
}
|
|
243
|
+
function holds(assertion, at, point, across) {
|
|
244
|
+
if (assertion === 'start')
|
|
245
|
+
return at === 0;
|
|
246
|
+
if (assertion === 'end')
|
|
247
|
+
return point === -1;
|
|
248
|
+
return assertion === 'boundary' ? across : !across;
|
|
249
|
+
}
|
|
250
|
+
class Linear {
|
|
251
|
+
machine;
|
|
252
|
+
start;
|
|
253
|
+
marks;
|
|
254
|
+
generation = 0;
|
|
255
|
+
constructor(machine, start) {
|
|
256
|
+
this.machine = machine;
|
|
257
|
+
this.start = start;
|
|
258
|
+
this.marks = new Float64Array(machine.kinds.length);
|
|
259
|
+
}
|
|
260
|
+
test(text) {
|
|
261
|
+
const { kinds, outs, alternates, atoms, assertions } = this.machine;
|
|
262
|
+
const marks = this.marks;
|
|
263
|
+
const budget = scope ?? { left: VISIT_BUDGET };
|
|
264
|
+
let seeds = [];
|
|
265
|
+
let previous = -1;
|
|
266
|
+
for (let at = 0;;) {
|
|
267
|
+
const point = at < text.length ? text.codePointAt(at) : -1;
|
|
268
|
+
const across = word(previous) !== word(point);
|
|
269
|
+
const generation = (this.generation += 1);
|
|
270
|
+
const active = [];
|
|
271
|
+
seeds.push(this.start);
|
|
272
|
+
while (seeds.length > 0) {
|
|
273
|
+
const state = seeds.pop();
|
|
274
|
+
if (marks[state] === generation)
|
|
275
|
+
continue;
|
|
276
|
+
marks[state] = generation;
|
|
277
|
+
if ((budget.left -= 1) < 0)
|
|
278
|
+
throw new PatternTooCostly();
|
|
279
|
+
const kind = kinds[state];
|
|
280
|
+
if (kind === MATCH)
|
|
281
|
+
return true;
|
|
282
|
+
if (kind === ATOM)
|
|
283
|
+
active.push(state);
|
|
284
|
+
else if (kind === SPLIT)
|
|
285
|
+
seeds.push(alternates[state], outs[state]);
|
|
286
|
+
else if (holds(assertions[alternates[state]], at, point, across))
|
|
287
|
+
seeds.push(outs[state]);
|
|
288
|
+
}
|
|
289
|
+
if (point === -1)
|
|
290
|
+
return false;
|
|
291
|
+
for (const state of active)
|
|
292
|
+
if (atoms[alternates[state]].holds(point))
|
|
293
|
+
seeds.push(outs[state]);
|
|
294
|
+
previous = point;
|
|
295
|
+
at += point > 0xffff ? 2 : 1;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function compiled(source) {
|
|
300
|
+
try {
|
|
301
|
+
new NativeRegExp(source, 'u');
|
|
302
|
+
}
|
|
303
|
+
catch {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
const alternatives = disjunction(new Reader(source));
|
|
308
|
+
const machine = new Machine();
|
|
309
|
+
const start = machine.alternatives(alternatives, machine.state(MATCH, -1));
|
|
310
|
+
return new Linear(machine, start);
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
if (error instanceof Unsupported)
|
|
314
|
+
return null;
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const held = new Map();
|
|
319
|
+
export function linearPattern(source) {
|
|
320
|
+
if (held.has(source))
|
|
321
|
+
return held.get(source);
|
|
322
|
+
const made = compiled(source);
|
|
323
|
+
if (held.size >= HELD_PATTERNS)
|
|
324
|
+
held.delete(held.keys().next().value);
|
|
325
|
+
held.set(source, made);
|
|
326
|
+
return made;
|
|
327
|
+
}
|
|
328
|
+
export function withLinearRegExp(run) {
|
|
329
|
+
const native = globalThis.RegExp;
|
|
330
|
+
function LinearRegExp(source) {
|
|
331
|
+
new NativeRegExp(source, 'u');
|
|
332
|
+
return {
|
|
333
|
+
test(text) {
|
|
334
|
+
const pattern = linearPattern(source);
|
|
335
|
+
if (pattern === null)
|
|
336
|
+
throw new SyntaxError(`the pattern ${source} is not linear`);
|
|
337
|
+
return pattern.test(text);
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
globalThis.RegExp = LinearRegExp;
|
|
342
|
+
try {
|
|
343
|
+
return run();
|
|
344
|
+
}
|
|
345
|
+
finally {
|
|
346
|
+
globalThis.RegExp = native;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
export function openPatternBudget() {
|
|
350
|
+
const outer = scope;
|
|
351
|
+
scope = outer ?? { left: VISIT_BUDGET };
|
|
352
|
+
return () => {
|
|
353
|
+
scope = outer;
|
|
354
|
+
};
|
|
355
|
+
}
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAU5E,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AA2KjF,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,aAAa,GAAG,SAAS,CAI3B;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMvF"}
|
package/dist/schema.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Validator } from '@cfworker/json-schema';
|
|
2
2
|
import { escapePointer, refTarget } from './definition.js';
|
|
3
3
|
import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
4
|
+
import { withLinearRegExp } from './pattern.js';
|
|
4
5
|
import { interpretPlain, isRecord } from './yaml.js';
|
|
5
6
|
const STANDING_MAPS = ['properties', 'patternProperties'];
|
|
6
7
|
const STANDING = [
|
|
@@ -150,7 +151,8 @@ function refusalOf(errors) {
|
|
|
150
151
|
return { rule: 'schema', location: '' };
|
|
151
152
|
}
|
|
152
153
|
export function frontmatterRefusal(definition, fields) {
|
|
153
|
-
const
|
|
154
|
+
const { frontmatter } = compiledOf(definition);
|
|
155
|
+
const result = withLinearRegExp(() => frontmatter.validate(fields));
|
|
154
156
|
return result.valid ? undefined : refusalOf(result.errors);
|
|
155
157
|
}
|
|
156
158
|
export function fitsItem(definition, section, text) {
|
|
@@ -159,5 +161,5 @@ export function fitsItem(definition, section, text) {
|
|
|
159
161
|
if (spec?.kind !== 'list' || validator === undefined)
|
|
160
162
|
return false;
|
|
161
163
|
const typed = spec.items.type === 'string' ? text : interpretPlain(text);
|
|
162
|
-
return validator.validate(typed).valid;
|
|
164
|
+
return withLinearRegExp(() => validator.validate(typed).valid);
|
|
163
165
|
}
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AASzF,OAAO,KAAK,EAEV,aAAa,EAEb,OAAO,EACP,iBAAiB,EACjB,OAAO,EACP,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACd,MAAM,YAAY,CAAC;AA8CpB,wBAAgB,QAAQ,CACtB,SAAS,EAAE,OAAO,EAClB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC5C,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAChC,OAAO,CAET;AA8BD,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,iBAAiB,CAQlF;AAoED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAM,GAC/C,aAAa,CA0Bf;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,GACrB,SAAS,OAAO,EAAE,CAiBpB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAO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AAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,SAAS,CAAC,cAAc,EAAE,UAAU,EAAE,IAAI,CAAC,CAsB7C;AAED,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,UAAU,CAKZ"}
|
package/dist/validate.js
CHANGED
|
@@ -5,6 +5,7 @@ import { classifyHref, roomTarget } from './paths.js';
|
|
|
5
5
|
import { references } from './references.js';
|
|
6
6
|
import { refusal } from './refuse.js';
|
|
7
7
|
import { fitsItem, frontmatterRefusal } from './schema.js';
|
|
8
|
+
import { openPatternBudget, PatternTooCostly } from './pattern.js';
|
|
8
9
|
import { headingSpans, listItems } from './sections.js';
|
|
9
10
|
import { bodyAfterFrontmatter, bodyStartOf } from './yaml.js';
|
|
10
11
|
function refuse(file, rule, extra) {
|
|
@@ -232,6 +233,23 @@ export function assess(file, content, binary, model = { types: {} }, context = {
|
|
|
232
233
|
return { ...typed, targets: [], fields: [], linked: true, sections: [] };
|
|
233
234
|
}
|
|
234
235
|
const definition = definitionOf(document, model);
|
|
236
|
+
try {
|
|
237
|
+
return structured(file, content, typed, document, definition, context);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
if (!(error instanceof PatternTooCostly))
|
|
241
|
+
throw error;
|
|
242
|
+
return {
|
|
243
|
+
...typed,
|
|
244
|
+
targets: [],
|
|
245
|
+
structured: refuse(file, 'pattern', { location: '' }),
|
|
246
|
+
fields: [],
|
|
247
|
+
linked: true,
|
|
248
|
+
sections: [],
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function structured(file, content, typed, document, definition, context) {
|
|
235
253
|
const read = structure(file, content, document, definition);
|
|
236
254
|
if ('refusal' in read || definition === undefined) {
|
|
237
255
|
return {
|
|
@@ -318,19 +336,25 @@ export function* validating(library, context = { binaryTargets: [] }, model = {
|
|
|
318
336
|
const binary = (path) => binaryTargets.has(path);
|
|
319
337
|
const types = new Map();
|
|
320
338
|
const assessments = [];
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
339
|
+
const closeBudget = openPatternBudget();
|
|
340
|
+
try {
|
|
341
|
+
for (const [file, content] of library) {
|
|
342
|
+
const assessment = assess(file, content, binary(file), model, context);
|
|
343
|
+
if (assessment.type !== undefined)
|
|
344
|
+
types.set(file, assessment.type);
|
|
345
|
+
assessments.push(assessment);
|
|
346
|
+
yield { path: file, resolved: 0 };
|
|
347
|
+
}
|
|
348
|
+
const judged = verdicts();
|
|
349
|
+
for (const assessment of assessments) {
|
|
350
|
+
const resolved = judged.add(assessment, (path) => types.get(path), binary);
|
|
351
|
+
yield { path: assessment.file, resolved };
|
|
352
|
+
}
|
|
353
|
+
return judged.verdict();
|
|
327
354
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const resolved = judged.add(assessment, (path) => types.get(path), binary);
|
|
331
|
-
yield { path: assessment.file, resolved };
|
|
355
|
+
finally {
|
|
356
|
+
closeBudget();
|
|
332
357
|
}
|
|
333
|
-
return judged.verdict();
|
|
334
358
|
}
|
|
335
359
|
export function validate(library, context = { binaryTargets: [] }, model = { types: {} }) {
|
|
336
360
|
const steps = validating(new Map(Object.entries(library)), context, model);
|
package/dist/yaml.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAnC,YAAqB,MAAM,EAAE,MAAM,EAGlC;CACF;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EA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Error extends Error {
|
|
|
6
6
|
this.name = 'YamlError';
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
const YAML_DEPTH_MAX = 64;
|
|
10
|
+
function nested(c, parse) {
|
|
11
|
+
if (c.depth >= YAML_DEPTH_MAX)
|
|
12
|
+
throw new YamlError(c.i);
|
|
13
|
+
c.depth += 1;
|
|
14
|
+
try {
|
|
15
|
+
return parse();
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
c.depth -= 1;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
9
21
|
function peek(c) {
|
|
10
22
|
return c.i < c.end ? c.text[c.i] : '';
|
|
11
23
|
}
|
|
@@ -202,6 +214,9 @@ function parseFlowValue(c) {
|
|
|
202
214
|
return parseScalar(c, true);
|
|
203
215
|
}
|
|
204
216
|
function parseFlowMap(c) {
|
|
217
|
+
return nested(c, () => flowMap(c));
|
|
218
|
+
}
|
|
219
|
+
function flowMap(c) {
|
|
205
220
|
const start = c.i;
|
|
206
221
|
if (peek(c) !== '{')
|
|
207
222
|
throw new YamlError(c.i);
|
|
@@ -240,6 +255,9 @@ function parseFlowMap(c) {
|
|
|
240
255
|
throw new YamlError(c.i);
|
|
241
256
|
}
|
|
242
257
|
function parseFlowSeq(c) {
|
|
258
|
+
return nested(c, () => flowSeq(c));
|
|
259
|
+
}
|
|
260
|
+
function flowSeq(c) {
|
|
243
261
|
const start = c.i;
|
|
244
262
|
if (peek(c) !== '[')
|
|
245
263
|
throw new YamlError(c.i);
|
|
@@ -336,6 +354,9 @@ function parseSeqItem(c, indent) {
|
|
|
336
354
|
return parseValue(c, indent);
|
|
337
355
|
}
|
|
338
356
|
function parseBlockSeq(c, indent) {
|
|
357
|
+
return nested(c, () => blockSeq(c, indent));
|
|
358
|
+
}
|
|
359
|
+
function blockSeq(c, indent) {
|
|
339
360
|
const start = c.i;
|
|
340
361
|
const items = [];
|
|
341
362
|
let end = start;
|
|
@@ -355,6 +376,9 @@ function parseBlockSeq(c, indent) {
|
|
|
355
376
|
return { kind: 'seq', items, start, end };
|
|
356
377
|
}
|
|
357
378
|
function parseBlockMap(c, indent, inline = false) {
|
|
379
|
+
return nested(c, () => blockMap(c, indent, inline));
|
|
380
|
+
}
|
|
381
|
+
function blockMap(c, indent, inline) {
|
|
358
382
|
const start = c.i;
|
|
359
383
|
const entries = [];
|
|
360
384
|
const seen = new Set();
|
|
@@ -387,7 +411,7 @@ function parseBlockMap(c, indent, inline = false) {
|
|
|
387
411
|
return { kind: 'map', entries, start, end };
|
|
388
412
|
}
|
|
389
413
|
export function parseYamlMapping(text, start, end) {
|
|
390
|
-
const c = { text, i: start, end };
|
|
414
|
+
const c = { text, i: start, end, depth: 0 };
|
|
391
415
|
skipBlankAndComments(c);
|
|
392
416
|
if (c.i >= end)
|
|
393
417
|
return { kind: 'map', entries: [], start, end };
|
|
@@ -445,6 +469,8 @@ function heldWithin(value, within) {
|
|
|
445
469
|
return Number.isFinite(value);
|
|
446
470
|
if (typeof value !== 'object' || within.includes(value))
|
|
447
471
|
return false;
|
|
472
|
+
if (within.length + 1 >= YAML_DEPTH_MAX)
|
|
473
|
+
return false;
|
|
448
474
|
const path = [...within, value];
|
|
449
475
|
const held = (item) => heldWithin(item, path);
|
|
450
476
|
if (Array.isArray(value))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdmodel",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-c4f4d37bc9d6a",
|
|
4
4
|
"description": "MD Type language, parser, validator, structured change application, Markdown syntax profile, and conformance fixtures",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": ">=24.
|
|
12
|
+
"node": ">=24.22.1"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|