@ja-platform/parser-core 0.0.0-dev-20261021213526 → 0.0.0-dev-20261027003550
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 +50 -0
- package/dist/@types/AttributeParseEvent.d.ts +5 -14
- package/dist/@types/ParseEvent.d.ts +11 -0
- package/dist/@types/attributes/Attribute.d.ts +9 -5
- package/dist/@types/attributes/ContentTextAttribute.d.ts +4 -6
- package/dist/@types/attributes/TextAttribute.d.ts +2 -2
- package/dist/@types/index.d.ts +9 -1
- package/dist/@types/input/AttributeInput.d.ts +28 -0
- package/dist/@types/input/AttributeParseContext.d.ts +21 -0
- package/dist/@types/input/NodeInput.d.ts +35 -0
- package/dist/@types/nodes/ContentNode.d.ts +5 -5
- package/dist/@types/nodes/EitherNode.d.ts +32 -0
- package/dist/@types/nodes/Node.d.ts +19 -20
- package/dist/@types/nodes/NodeAlternatives.d.ts +7 -4
- package/dist/@types/nodes/RecordNode.d.ts +16 -0
- package/dist/@types/parsed/ParsedArrayNode.d.ts +6 -1
- package/dist/@types/parsed/ParsedAttribute.d.ts +5 -8
- package/dist/@types/parsed/ParsedDiagnostic.d.ts +7 -3
- package/dist/@types/parsed/ParsedEitherNode.d.ts +9 -0
- package/dist/@types/parsed/ParsedNode.d.ts +5 -7
- package/dist/@types/parsed/ParsedRecordNode.d.ts +6 -0
- package/dist/@types/source/SourceReference.d.ts +9 -0
- package/dist/AttributeParseEvent.js.map +1 -1
- package/dist/{XMLParseEvent.js → ParseEvent.js} +1 -1
- package/dist/ParseEvent.js.map +1 -0
- package/dist/attributes/Attribute.js +33 -55
- package/dist/attributes/Attribute.js.map +1 -1
- package/dist/attributes/ContentTextAttribute.js +9 -24
- package/dist/attributes/ContentTextAttribute.js.map +1 -1
- package/dist/attributes/NumberAttribute.js +1 -1
- package/dist/attributes/NumberAttribute.js.map +1 -1
- package/dist/attributes/TextAttribute.js +11 -9
- package/dist/attributes/TextAttribute.js.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/input/AttributeInput.js +14 -0
- package/dist/input/AttributeInput.js.map +1 -0
- package/dist/input/AttributeParseContext.js +3 -0
- package/dist/input/AttributeParseContext.js.map +1 -0
- package/dist/input/NodeInput.js +14 -0
- package/dist/input/NodeInput.js.map +1 -0
- package/dist/nodes/ContentNode.js +13 -11
- package/dist/nodes/ContentNode.js.map +1 -1
- package/dist/nodes/EitherNode.js +95 -0
- package/dist/nodes/EitherNode.js.map +1 -0
- package/dist/nodes/Node.js +44 -37
- package/dist/nodes/Node.js.map +1 -1
- package/dist/nodes/NodeAlternatives.js +28 -21
- package/dist/nodes/NodeAlternatives.js.map +1 -1
- package/dist/nodes/RecordNode.js +36 -0
- package/dist/nodes/RecordNode.js.map +1 -0
- package/dist/parsed/ParsedArrayNode.js +9 -5
- package/dist/parsed/ParsedArrayNode.js.map +1 -1
- package/dist/parsed/ParsedAttribute.js +8 -6
- package/dist/parsed/ParsedAttribute.js.map +1 -1
- package/dist/parsed/ParsedDiagnostic.js +4 -2
- package/dist/parsed/ParsedDiagnostic.js.map +1 -1
- package/dist/parsed/ParsedEitherNode.js +16 -0
- package/dist/parsed/ParsedEitherNode.js.map +1 -0
- package/dist/parsed/ParsedNode.js +15 -12
- package/dist/parsed/ParsedNode.js.map +1 -1
- package/dist/parsed/ParsedRecordNode.js +14 -0
- package/dist/parsed/ParsedRecordNode.js.map +1 -0
- package/dist/source/SourceReference.js +3 -0
- package/dist/source/SourceReference.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -6
- package/dist/@types/XMLParseEvent.d.ts +0 -37
- package/dist/XMLParseEvent.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParsedArrayNode.js","sourceRoot":"","sources":["../../src/parsed/ParsedArrayNode.ts"],"names":[],"mappings":";;;AAAA,iEAAoF;AAEpF,0DAAoD;
|
|
1
|
+
{"version":3,"file":"Par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AAE,MAAM,EAAE,IAAI,EAAoB;;QACnD,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACzE,IAAI,MAAM,EAAE,CAAC;YACX,MAAA,IAAI,CAAC,SAAS,EAAc,0CAAE,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;IACnC,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;IACtC,CAAC;IAED,GAAG,CAAI,EAAqC;QAC1C,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { ParsedNodeValues, ParsedNodeValuesLike } from '../values/ParsedNodeValues';\nimport { ParsedExpressionValue } from './ParsedNodeTypes';\nimport { TreeNode } from '@journeyapps/common-tree';\n\nimport type { SourceReference } from '../source/SourceReference';\nimport { Node } from '../nodes/Node';\nimport { AbstractValueProvider } from '../values/AbstractValueProvider';\nimport { ParsedDiagnostic, ParsedDiagnosticStore } from './ParsedDiagnostic';\nimport { ParsedNode } from './ParsedNode';\n\nexport interface ParsedArrayNodeOptions {\n definition: Node<any>;\n key: string;\n inputPresent?: boolean;\n source?: SourceReference;\n}\n\nexport type ParsedArrayNodeChild = ParsedNode<any, any> | ParsedArrayNode<any>;\n\nexport class ParsedArrayNode<Child extends ParsedArrayNodeChild = ParsedNode<any, any>> extends TreeNode {\n public readonly definition: Node<any>;\n readonly inputPresent?: boolean;\n readonly source?: SourceReference;\n private readonly diagnostics = new ParsedDiagnosticStore();\n\n constructor(options: ParsedArrayNodeOptions) {\n super(options.key);\n this.definition = options.definition;\n this.inputPresent = options.inputPresent;\n this.source = options.source;\n }\n\n nodes(): Child[] {\n return this.getNodes<Child>();\n }\n\n /**\n * Resolve repeated children in order, preserving nested arrays.\n */\n valueTree(): ParsedNodeValuesLike<ParsedExpressionValue<Child>[]> {\n return new ParsedNodeValues(\n this.nodes().map((child) => child.valueTree()),\n (values) =>\n [\n ...(values.length === 0 && !this.inputPresent ? (this.definition.defaultValue ?? []) : values)\n ] as ParsedExpressionValue<Child>[]\n );\n }\n\n at(index: number): Child | undefined {\n return this.nodes()[index];\n }\n\n setValueProviders(providers: readonly AbstractValueProvider[]): this {\n this.nodes().forEach((child) => child.setValueProviders(providers));\n return this;\n }\n\n pushError({ message, source, type }: ParsedDiagnostic): ParsedDiagnostic {\n const diagnostic = this.diagnostics.pushError({ message, source, type });\n if (source) {\n this.getParent<ParsedNode>()?.reportDiagnostic({ source, message, type });\n }\n return diagnostic;\n }\n\n errors(): ParsedDiagnostic[] {\n return this.diagnostics.errors();\n }\n\n hasErrors(): boolean {\n return this.diagnostics.hasErrors();\n }\n\n map<T>(cb: (node: Child, index: number) => T): T[] {\n return this.nodes().map(cb);\n }\n}\n"]}
|
|
@@ -5,13 +5,13 @@ const common_tree_1 = require("@journeyapps/common-tree");
|
|
|
5
5
|
const ParsedDiagnostic_1 = require("./ParsedDiagnostic");
|
|
6
6
|
class ParsedAttribute extends common_tree_1.TreeEntity {
|
|
7
7
|
constructor(options) {
|
|
8
|
+
var _a;
|
|
8
9
|
super(options.definition.options.key);
|
|
9
10
|
this.diagnostics = new ParsedDiagnostic_1.ParsedDiagnosticStore();
|
|
10
11
|
this.definition = options.definition;
|
|
11
|
-
this.
|
|
12
|
-
this.reportError = options.
|
|
12
|
+
this.input = options.input;
|
|
13
|
+
this.reportError = (_a = options.reportError) !== null && _a !== void 0 ? _a : (() => undefined);
|
|
13
14
|
this.expressionValue = options.expression;
|
|
14
|
-
this.parseContext = options.parseContext;
|
|
15
15
|
}
|
|
16
16
|
get name() {
|
|
17
17
|
return this.definition.options.name;
|
|
@@ -22,9 +22,11 @@ class ParsedAttribute extends common_tree_1.TreeEntity {
|
|
|
22
22
|
setExpression(value) {
|
|
23
23
|
this.expressionValue = value;
|
|
24
24
|
}
|
|
25
|
-
pushError(
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
pushError(_a) {
|
|
26
|
+
var _b;
|
|
27
|
+
var { message, type, source = (_b = this.input) === null || _b === void 0 ? void 0 : _b.source } = _a;
|
|
28
|
+
const diagnostic = this.diagnostics.pushError({ message, type, source });
|
|
29
|
+
this.reportError(diagnostic);
|
|
28
30
|
return diagnostic;
|
|
29
31
|
}
|
|
30
32
|
errors() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParsedAttribute.js","sourceRoot":"","sources":["../../src/parsed/ParsedAttribute.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ParsedAttribute.js","sourceRoot":"","sources":["../../src/parsed/ParsedAttribute.ts"],"names":[],"mappings":";;;AACA,0DAAsD;AAEtD,yDAA6E;AAU7E,qBAAyF,SAAQ,wBAAU;IAOzG,YAAY,OAAuD;;QACjE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAJvB,gBAAW,GAAG,IAAI,wCAAqB,EAAE,CAAC;QAKzD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,WAAW,SAAG,OAAO,CAAC,WAAW,mCAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5D,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC;IACtC,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,aAAa,CAAC,KAAiB;QAC7B,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,EAAgE;;YAAhE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAA,IAAI,CAAC,KAAK,0CAAE,MAAM,EAAE;QACtD,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC7B,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;IACnC,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;IACtC,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,EAAc,CAAC,CAAC;IACvF,CAAC;CACF","sourcesContent":["import type { AttributeInput } from '../input/AttributeInput';\nimport { TreeEntity } from '@journeyapps/common-tree';\nimport { Attribute } from '../attributes/Attribute';\nimport { ParsedDiagnosticStore, ParsedDiagnostic } from './ParsedDiagnostic';\nimport { ParsedNode } from './ParsedNode';\n\nexport interface ParsedAttributeOptions<Expression = any, Definition extends Attribute = Attribute> {\n definition: Definition;\n input?: AttributeInput;\n reportError?: (diagnostic: ParsedDiagnostic) => void;\n expression: Expression;\n}\n\nexport class ParsedAttribute<Expression = any, Definition extends Attribute = Attribute> extends TreeEntity {\n public readonly definition: Definition;\n private expressionValue: Expression;\n public readonly input?: AttributeInput;\n private readonly diagnostics = new ParsedDiagnosticStore();\n private readonly reportError: (diagnostic: ParsedDiagnostic) => void;\n\n constructor(options: ParsedAttributeOptions<Expression, Definition>) {\n super(options.definition.options.key);\n this.definition = options.definition;\n this.input = options.input;\n this.reportError = options.reportError ?? (() => undefined);\n this.expressionValue = options.expression;\n }\n\n get name(): string {\n return this.definition.options.name;\n }\n\n expression(): Expression {\n return this.expressionValue;\n }\n\n setExpression(value: Expression) {\n this.expressionValue = value;\n }\n\n pushError({ message, type, source = this.input?.source }: ParsedDiagnostic): ParsedDiagnostic {\n const diagnostic = this.diagnostics.pushError({ message, type, source });\n this.reportError(diagnostic);\n return diagnostic;\n }\n\n errors(): ParsedDiagnostic[] {\n return this.diagnostics.errors();\n }\n\n hasErrors(): boolean {\n return this.diagnostics.hasErrors();\n }\n\n stringify() {\n return this.definition.stringify(this.expressionValue, this.getParent<ParsedNode>());\n }\n}\n"]}
|
|
@@ -5,8 +5,10 @@ class ParsedDiagnosticStore {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
this.diagnostics = [];
|
|
7
7
|
}
|
|
8
|
-
pushError({ message,
|
|
9
|
-
const diagnostic = {
|
|
8
|
+
pushError({ message, type, source }) {
|
|
9
|
+
const diagnostic = { message, type };
|
|
10
|
+
if (source)
|
|
11
|
+
diagnostic.source = source;
|
|
10
12
|
this.diagnostics.push(diagnostic);
|
|
11
13
|
return diagnostic;
|
|
12
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParsedDiagnostic.js","sourceRoot":"","sources":["../../src/parsed/ParsedDiagnostic.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ParsedDiagnostic.js","sourceRoot":"","sources":["../../src/parsed/ParsedDiagnostic.ts"],"names":[],"mappings":";;;AAaA;IAAA;QACmB,gBAAW,GAAuB,EAAE,CAAC;IAgBxD,CAAC;IAdC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAoB;QACnD,MAAM,UAAU,GAAqB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACvD,IAAI,MAAM;YAAE,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;QACvC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,MAAM;QACJ,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,CAAC;CACF","sourcesContent":["import type { SourceReference } from '../source/SourceReference';\nimport type { ExpressionDiagnostic } from '@ja-platform/parser-expressions';\n\nexport interface ParsedDiagnostic {\n message: string;\n type?: 'error' | 'warning';\n source?: SourceReference;\n}\n\nexport interface ParsedValidationDiagnostic extends ParsedDiagnostic {\n token?: ExpressionDiagnostic['token'];\n}\n\nexport class ParsedDiagnosticStore {\n private readonly diagnostics: ParsedDiagnostic[] = [];\n\n pushError({ message, type, source }: ParsedDiagnostic): ParsedDiagnostic {\n const diagnostic: ParsedDiagnostic = { message, type };\n if (source) diagnostic.source = source;\n this.diagnostics.push(diagnostic);\n return diagnostic;\n }\n\n errors(): ParsedDiagnostic[] {\n return [...this.diagnostics];\n }\n\n hasErrors(): boolean {\n return this.diagnostics.length > 0;\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParsedEitherNode = void 0;
|
|
4
|
+
const ParsedNode_1 = require("./ParsedNode");
|
|
5
|
+
const ParsedNodeValues_1 = require("../values/ParsedNodeValues");
|
|
6
|
+
/** Preserve the selected branch's value without adding an object to the output. */
|
|
7
|
+
class ParsedEitherNode extends ParsedNode_1.ParsedNode {
|
|
8
|
+
valueTree() {
|
|
9
|
+
const selected = this.child('value');
|
|
10
|
+
if (!selected)
|
|
11
|
+
return new ParsedNodeValues_1.ParsedNodeValues([], () => undefined);
|
|
12
|
+
return selected.valueTree();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ParsedEitherNode = ParsedEitherNode;
|
|
16
|
+
//# sourceMappingURL=ParsedEitherNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParsedEitherNode.js","sourceRoot":"","sources":["../../src/parsed/ParsedEitherNode.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAE1C,iEAAyF;AAEzF,mFAAmF;AACnF,sBAAqC,SAAQ,uBAAsD;IACjG,SAAS;QACP,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,mCAAgB,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAChE,OAAO,QAAQ,CAAC,SAAS,EAAiC,CAAC;IAC7D,CAAC;CACF","sourcesContent":["import { ParsedNode } from './ParsedNode';\nimport type { ParsedChild } from './ParsedNodeTypes';\nimport { ParsedNodeValues, type ParsedNodeValuesLike } from '../values/ParsedNodeValues';\n\n/** Preserve the selected branch's value without adding an object to the output. */\nexport class ParsedEitherNode<Value> extends ParsedNode<{ value?: ParsedChild }, Value | undefined> {\n valueTree(): ParsedNodeValuesLike<Value | undefined> {\n const selected = this.child('value');\n if (!selected) return new ParsedNodeValues([], () => undefined);\n return selected.valueTree() as ParsedNodeValuesLike<Value>;\n }\n}\n"]}
|
|
@@ -16,12 +16,9 @@ class ParsedNode extends common_tree_1.TreeNode {
|
|
|
16
16
|
this.childrenByKey = new Map();
|
|
17
17
|
this.diagnostics = new ParsedDiagnostic_1.ParsedDiagnosticStore();
|
|
18
18
|
this.definition = definition;
|
|
19
|
-
this.
|
|
20
|
-
this.parseParentNode = options.
|
|
21
|
-
this.reportError = options.
|
|
22
|
-
if (options.valueProviders) {
|
|
23
|
-
this.valueProviders = Object.freeze([...options.valueProviders]);
|
|
24
|
-
}
|
|
19
|
+
this.input = options.input;
|
|
20
|
+
this.parseParentNode = options.parentNode;
|
|
21
|
+
this.reportError = options.report;
|
|
25
22
|
}
|
|
26
23
|
get type() {
|
|
27
24
|
var _a, _b;
|
|
@@ -61,6 +58,9 @@ class ParsedNode extends common_tree_1.TreeNode {
|
|
|
61
58
|
const attributes = this.collectAttributeValues(this.attributes().map((attribute) => attribute.getKey()));
|
|
62
59
|
const sources = [...attributes];
|
|
63
60
|
for (const [key, child] of this.childrenByKey) {
|
|
61
|
+
if (child instanceof ParsedArrayNode_1.ParsedArrayNode && child.inputPresent === false && child.definition.defaultValue == null) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
64
|
sources.push([key, child.valueTree()]);
|
|
65
65
|
}
|
|
66
66
|
return new ParsedNodeValues_1.ParsedNodeValues(sources.map(([, source]) => source), (currentValues) => Object.fromEntries([
|
|
@@ -114,24 +114,27 @@ class ParsedNode extends common_tree_1.TreeNode {
|
|
|
114
114
|
* Diagnostics are returned without changing parse errors or reading values.
|
|
115
115
|
*/
|
|
116
116
|
validate({ scope }) {
|
|
117
|
+
var _a;
|
|
117
118
|
const diagnostics = [];
|
|
118
|
-
const
|
|
119
|
+
const source = (_a = this.input) === null || _a === void 0 ? void 0 : _a.source;
|
|
119
120
|
const context = {
|
|
120
121
|
scope,
|
|
121
122
|
report(diagnostic) {
|
|
122
123
|
var _a;
|
|
123
|
-
diagnostics.push(diagnostic.token ? diagnostic : Object.assign(Object.assign({}, diagnostic), {
|
|
124
|
+
diagnostics.push(diagnostic.token ? diagnostic : Object.assign(Object.assign({}, diagnostic), { source: (_a = diagnostic.source) !== null && _a !== void 0 ? _a : source }));
|
|
124
125
|
}
|
|
125
126
|
};
|
|
126
127
|
this.iterateListeners((listener) => { var _a; return (_a = listener.preValidation) === null || _a === void 0 ? void 0 : _a.call(listener, { node: this, context }); });
|
|
127
128
|
diagnostics.push(...this.attributes().flatMap((attribute) => { var _a; var _b; return (_b = (_a = attribute
|
|
128
|
-
.expression()) === null || _a === void 0 ? void 0 : _a.validate(scope).map((diagnostic) => (Object.assign(Object.assign({}, diagnostic), {
|
|
129
|
+
.expression()) === null || _a === void 0 ? void 0 : _a.validate(scope).map((diagnostic) => { var _a; var _b; return (Object.assign(Object.assign({}, diagnostic), { source: (_b = (_a = attribute.input) === null || _a === void 0 ? void 0 : _a.source) !== null && _b !== void 0 ? _b : source })); })) !== null && _b !== void 0 ? _b : []; }), ...this.nodes().flatMap((child) => child.validate({ scope })));
|
|
129
130
|
this.iterateListeners((listener) => { var _a; return (_a = listener.postValidation) === null || _a === void 0 ? void 0 : _a.call(listener, { node: this, context }); });
|
|
130
131
|
return diagnostics;
|
|
131
132
|
}
|
|
132
|
-
pushError(
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
pushError(_a) {
|
|
134
|
+
var _b;
|
|
135
|
+
var { message, source = (_b = this.input) === null || _b === void 0 ? void 0 : _b.source, type } = _a;
|
|
136
|
+
const diagnostic = this.diagnostics.pushError({ message, source, type });
|
|
137
|
+
this.reportError({ source, message, type });
|
|
135
138
|
return diagnostic;
|
|
136
139
|
}
|
|
137
140
|
reportDiagnostic(diagnostic) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParsedNode.js","sourceRoot":"","sources":["../../src/parsed/ParsedNode.ts"],"names":[],"mappings":";;;AAAA,iEAAoF;AACpF,0DAAsE;AAKtE,uDAAoD;AAEpD,yDAAyG;AAkBzG,uDAAoD;AAwCpD,gBAAiG,SAAQ,sBAExG;IAYC,YAAY,OAA0B;;QACpC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACtC,KAAK,OAAC,OAAO,CAAC,GAAG,mCAAI,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAb9B,iBAAY,GAAG,IAAI,GAAG,EAAqC,CAAC;QACrE,oBAAe,GAAiC,IAAI,GAAG,EAAE,CAAC;QAC1D,kBAAa,GAA6B,IAAI,GAAG,EAAE,CAAC;QAM3C,gBAAW,GAAG,IAAI,wCAAqB,EAAE,CAAC;QAMzD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7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IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAEO,cAAc,CAAC,KAAkB;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/C,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { ParsedNodeValues, ParsedNodeValuesLike } from '../values/ParsedNodeValues';\nimport { TreeNode, TreeNodeListener } from '@journeyapps/common-tree';\nimport { XMLParseEvent } from '../XMLParseEvent';\n\nimport { XMLElement } from '@journeyapps/domparser/lib';\nimport { Node } from '../nodes/Node';\nimport { ParsedArrayNode } from './ParsedArrayNode';\nimport { ParsedAttribute } from './ParsedAttribute';\nimport { ParsedDiagnostic, ParsedDiagnosticStore, ParsedValidationDiagnostic } from './ParsedDiagnostic';\nimport type { ValidationContext } from '@ja-platform/parser-expressions';\nimport {\n ParsedChild,\n ParsedChildNamesMarker,\n ParsedNodeAttribute,\n ParsedNodeAttributeShape,\n ParsedNodeAttributeName,\n ParsedNodeChild,\n ParsedNodeExpressionKey,\n ParsedNodeKnownChildKey,\n ParsedNodeValue,\n ParsedNodeValueRequest,\n ParsedNodeValueRequestKey,\n ParsedNodeRequiredAttributeName,\n ParsedNodeShape,\n ParsedNodeUntypedExpressionKey\n} from './ParsedNodeTypes';\nimport { ParsedValue } from '../values/ParsedValue';\nimport { AbstractValueProvider } from '../values/AbstractValueProvider';\n\nexport interface ParsedNodeOptions {\n definition: Node<any>;\n event: XMLParseEvent<ParsedNode>;\n key?: string;\n valueProviders?: readonly AbstractValueProvider[];\n}\n\nexport interface ParsedNodeValidationContext {\n scope: ValidationContext;\n}\n\nexport interface NodeValidationEvent<Shape extends ParsedNodeShape = ParsedNodeShape, Value = ParsedNodeValue<Shape>> {\n node: ParsedNode<Shape, Value>;\n context: NodeValidationContext;\n}\n\nexport interface NodeValidationContext {\n readonly scope: ValidationContext;\n report(diagnostic: ParsedValidationDiagnostic): void;\n}\n\nexport interface ParsedNodeListener<\n Shape extends ParsedNodeShape = ParsedNodeShape,\n Value = ParsedNodeValue<Shape>\n> extends TreeNodeListener {\n /**\n * Report diagnostics and introduce child scopes before validating expressions and descendants.\n * Hooks run in registration order during explicit validation, independently of parsing.\n */\n preValidation?(event: NodeValidationEvent<Shape, Value>): void;\n\n /**\n * Validate this node after its expressions and descendants using the resulting context.\n */\n postValidation?(event: NodeValidationEvent<Shape, Value>): void;\n}\n\nexport class ParsedNode<T extends ParsedNodeShape = ParsedNodeShape, Value = ParsedNodeValue<T>> extends TreeNode<\n ParsedNodeListener<any, any>\n> {\n private readonly parsedValues = new Map<ParsedAttribute, ParsedValue<any>>();\n private attributesByKey: Map<string, ParsedAttribute> = new Map();\n private childrenByKey: Map<string, ParsedChild> = new Map();\n private valueProviders?: readonly AbstractValueProvider[];\n public readonly definition: Node<any>;\n public readonly sourceElement: XMLElement;\n public readonly parseParentNode?: ParsedNode;\n private parsedContent: any;\n private readonly diagnostics = new ParsedDiagnosticStore();\n private readonly reportError: (diagnostic: ParsedDiagnostic) => void;\n\n constructor(options: ParsedNodeOptions) {\n const definition = options.definition;\n super(options.key ?? definition.options.key);\n this.definition = definition;\n this.sourceElement = options.event.element;\n this.parseParentNode = options.event.parentNode;\n this.reportError = options.event.helper.pushError;\n if (options.valueProviders) {\n this.valueProviders = Object.freeze([...options.valueProviders]);\n }\n }\n\n get type(): string {\n return this.attribute('type')?.expression()?.value() ?? this.definition.options.name;\n }\n\n registerListener(listener: Partial<ParsedNodeListener<T, Value>>): () => void {\n return super.registerListener(listener);\n }\n\n get children(): ParsedNode[] {\n return this.nodes();\n }\n\n getRoot(): ParsedNode {\n const parent = this.getParent<ParsedNode>() ?? this.parseParentNode;\n return parent?.getRoot() ?? this;\n }\n\n get parsedValueProviders(): readonly AbstractValueProvider[] | undefined {\n return this.valueProviders;\n }\n\n setValueProviders(providers: readonly AbstractValueProvider[]): this {\n this.parsedValues.clear();\n this.valueProviders = Object.freeze([...providers]);\n this.childEntries().forEach((child) => child.setValueProviders(providers));\n return this;\n }\n\n value<const Keys extends readonly ParsedNodeValueRequestKey<T, Value>[]>(\n attributes: Keys\n ): ParsedNodeValuesLike<ParsedNodeValueRequest<T, Value, Keys>>;\n value<RequestedValue = any>(\n attributes: readonly ParsedNodeUntypedExpressionKey<T>[]\n ): ParsedNodeValuesLike<RequestedValue>;\n value(attributeKeys: readonly string[]): ParsedNodeValuesLike<any> {\n const attributes = this.collectAttributeValues(attributeKeys);\n return new ParsedNodeValues(\n attributes.map(([, source]) => source),\n (currentValues) =>\n Object.fromEntries(\n attributes.flatMap(([key], index) =>\n currentValues[index] === undefined ? [] : [[key, currentValues[index]]]\n )\n )\n );\n }\n\n /**\n * Resolve this node's attributes and descendants through their value providers.\n * Include declared defaults for absent children without creating parsed nodes.\n */\n valueTree(): ParsedNodeValuesLike<Value> {\n const defaults = this.definition.nodes.flatMap(({ options, defaultValue }) =>\n !this.childrenByKey.has(options.key) && defaultValue !== undefined ? [[options.key, defaultValue]] : []\n );\n const attributes = this.collectAttributeValues(this.attributes().map((attribute) => attribute.getKey()));\n const sources: Array<readonly [string, ParsedNodeValuesLike<unknown>]> = [...attributes];\n for (const [key, child] of this.childrenByKey) {\n sources.push([key, child.valueTree()]);\n }\n return new ParsedNodeValues<Value>(\n sources.map(([, source]) => source),\n (currentValues) =>\n Object.fromEntries([\n ...defaults,\n ...sources.flatMap(([key], index) =>\n index < attributes.length && currentValues[index] === undefined ? [] : [[key, currentValues[index]]]\n )\n ]) as Value\n );\n }\n\n /**\n * Collect retained attribute sources for a value container to own and release.\n */\n protected collectAttributeValues(attributeKeys: readonly string[]): Array<readonly [string, ParsedValue<unknown>]> {\n if (!this.valueProviders) {\n throw new Error(`No value providers have been configured for parsed node '${this.getKey()}'`);\n }\n const attributes = attributeKeys.map((key) => {\n const attribute = this.attribute(key);\n if (!attribute) {\n throw new Error(`Unknown parsed attribute '${key}' on node '${this.getKey()}'`);\n }\n return attribute;\n });\n const sources: Array<readonly [string, ParsedValue<unknown>]> = [];\n for (const attribute of attributes) {\n sources.push([attribute.getKey(), this.getParsedValue(attribute).retain()]);\n }\n return sources;\n }\n\n attribute<Key extends Extract<ParsedNodeRequiredAttributeName<T>, ParsedNodeExpressionKey<T>>>(\n key: Key\n ): ParsedNodeAttribute<T, Key>;\n attribute<Key extends Exclude<ParsedNodeExpressionKey<T>, ParsedNodeRequiredAttributeName<T>>>(\n key: Key\n ): ParsedNodeAttribute<T, Key> | undefined;\n attribute<Attribute extends ParsedAttribute = ParsedAttribute>(key: string): Attribute | undefined;\n attribute(key: string): ParsedAttribute | undefined {\n return this.attributesByKey.get(key);\n }\n\n attrExpression<Key extends ParsedNodeExpressionKey<T>>(key: Key): ParsedNodeAttributeShape<T>[Key] | undefined;\n attrExpression<Value = any>(key: ParsedNodeUntypedExpressionKey<T>): Value | undefined;\n attrExpression(key: string): any {\n return this.attributesByKey.get(key)?.expression();\n }\n\n attributes(): ParsedAttribute[];\n attributes<const Names extends readonly ParsedNodeAttributeName<T>[]>(names: Names): ParsedAttribute[];\n attributes(names?: readonly string[]): ParsedAttribute[] {\n const attributes = Array.from(this.attributesByKey.values());\n if (!names || names.length === 0) {\n return attributes;\n }\n\n return attributes.filter((attribute) => names.includes(attribute.name));\n }\n\n content() {\n return this.parsedContent;\n }\n\n setContent(content: any): this {\n this.parsedContent = content;\n return this;\n }\n\n /**\n * Validate attribute expressions and descendants against the supplied scope.\n * Diagnostics are returned without changing parse errors or reading values.\n */\n validate({ scope }: ParsedNodeValidationContext): ParsedValidationDiagnostic[] {\n const diagnostics: ParsedValidationDiagnostic[] = [];\n const element = this.sourceElement;\n const context: NodeValidationContext = {\n scope,\n report(diagnostic) {\n diagnostics.push(diagnostic.token ? diagnostic : { ...diagnostic, element: diagnostic.element ?? element });\n }\n };\n this.iterateListeners((listener) => listener.preValidation?.({ node: this, context }));\n diagnostics.push(\n ...this.attributes().flatMap(\n (attribute) =>\n attribute\n .expression()\n ?.validate(scope)\n .map((diagnostic) => ({ ...diagnostic, element })) ?? []\n ),\n ...this.nodes().flatMap((child) => child.validate({ scope }))\n );\n this.iterateListeners((listener) => listener.postValidation?.({ node: this, context }));\n return diagnostics;\n }\n\n pushError({ message, element = this.sourceElement, type }: ParsedDiagnostic): ParsedDiagnostic {\n const diagnostic = this.diagnostics.pushError({ message, element, type });\n this.reportError({ element, message, type });\n return diagnostic;\n }\n\n reportDiagnostic(diagnostic: ParsedDiagnostic) {\n this.reportError(diagnostic);\n }\n\n errors(options: { deep?: boolean } = {}): ParsedDiagnostic[] {\n if (!options.deep) {\n return this.diagnostics.errors();\n }\n\n return [\n ...this.diagnostics.errors(),\n ...this.attributes().flatMap((attribute) => attribute.errors()),\n ...this.childEntries().flatMap((child) => {\n if (child instanceof ParsedArrayNode) {\n return [...child.errors(), ...child.nodes().flatMap((node) => node.errors({ deep: true }))];\n }\n return child.errors({ deep: true });\n })\n ];\n }\n\n hasErrors(options: { deep?: boolean } = {}): boolean {\n return this.errors(options).length > 0;\n }\n\n child(key: string): ParsedChild | undefined {\n return this.childrenByKey.get(key);\n }\n\n setChild(key: string, child: ParsedChild): this {\n const existing = this.childrenByKey.get(key);\n if (existing && existing !== child) {\n existing.delete();\n }\n\n this.childrenByKey.set(key, child);\n\n this.addParsedChild(child);\n\n if (this.valueProviders) {\n child.setValueProviders(this.valueProviders);\n }\n\n return this;\n }\n\n removeChild(key: string): this {\n const child = this.childrenByKey.get(key);\n this.childrenByKey.delete(key);\n child?.delete();\n return this;\n }\n\n setAttribute(attribute: ParsedAttribute): this {\n const previous = this.attributesByKey.get(attribute.definition.options.key);\n this.parsedValues.delete(previous);\n this.attributesByKey.set(attribute.definition.options.key, attribute);\n this.addParsedAttribute(attribute);\n return this;\n }\n\n node<Key extends ParsedNodeKnownChildKey<T>>(key: Key): ParsedNodeChild<T, Key> | undefined;\n node<Child extends ParsedChild = ParsedChild>(\n key: T extends ParsedChildNamesMarker<any> ? never : string\n ): Child | undefined;\n node(key: string): ParsedChild | undefined {\n return this.child(key);\n }\n\n childEntries(): ParsedChild[] {\n return Array.from(this.childrenByKey.values());\n }\n\n nodes(): ParsedNode[] {\n return this.childEntries().flatMap((child) => {\n if (child instanceof ParsedArrayNode) {\n return this.flattenParsedArray(child);\n }\n return [child];\n });\n }\n\n private flattenParsedArray(arrayNode: ParsedArrayNode): ParsedNode[] {\n return arrayNode.nodes().flatMap((child) => {\n if (child instanceof ParsedArrayNode) {\n return this.flattenParsedArray(child);\n }\n return [child];\n });\n }\n\n private getParsedValue(attribute: ParsedAttribute): ParsedValue<any> {\n let value = this.parsedValues.get(attribute);\n if (!value) {\n value = new ParsedValue(attribute, this.valueProviders);\n this.parsedValues.set(attribute, value);\n const deregister = value.registerListener({\n disposed: () => {\n deregister();\n if (this.parsedValues.get(attribute) === value) {\n this.parsedValues.delete(attribute);\n }\n }\n });\n }\n return value;\n }\n\n private addParsedAttribute(attribute: ParsedAttribute) {\n const existing = this.getChild(attribute.getKey());\n if (existing) {\n existing.delete();\n }\n this.addChild(attribute);\n }\n\n private addParsedChild(child: ParsedChild) {\n const existing = this.getChild(child.getKey());\n if (existing) {\n existing.delete();\n }\n this.addChild(child);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ParsedNode.js","sourceRoot":"","sources":["../../src/parsed/ParsedNode.ts"],"names":[],"mappings":";;;AAAA,iEAAoF;AACpF,0DAAsE;AAKtE,uDAAoD;AAEpD,yDAAyG;AAkBzG,uDAAoD;AAsCpD,gBAAiG,SAAQ,sBAExG;IAYC,YAAY,OAA0B;;QACpC,MAAM,UAA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E,KAAK,CAAC,CAAC;YACxC,MAAM,UAAU,GAAG,KAAK,CAAC,gBAAgB,CAAC;gBACxC,QAAQ,EAAE,GAAG,EAAE;oBACb,UAAU,EAAE,CAAC;oBACb,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,KAAK,EAAE,CAAC;wBAC/C,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;oBACtC,CAAC;gBACH,CAAC;aACF,CAAC,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,kBAAkB,CAAC,SAA0B;QACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;QACnD,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAEO,cAAc,CAAC,KAAkB;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/C,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { ParsedNodeValues, ParsedNodeValuesLike } from '../values/ParsedNodeValues';\nimport { TreeNode, TreeNodeListener } from '@journeyapps/common-tree';\nimport { ParseEvent } from '../ParseEvent';\n\nimport type { NodeInput } from '../input/NodeInput';\nimport { Node } from '../nodes/Node';\nimport { ParsedArrayNode } from './ParsedArrayNode';\nimport { ParsedAttribute } from './ParsedAttribute';\nimport { ParsedDiagnostic, ParsedDiagnosticStore, ParsedValidationDiagnostic } from './ParsedDiagnostic';\nimport type { ValidationContext } from '@ja-platform/parser-expressions';\nimport {\n ParsedChild,\n ParsedChildNamesMarker,\n ParsedNodeAttribute,\n ParsedNodeAttributeShape,\n ParsedNodeAttributeName,\n ParsedNodeChild,\n ParsedNodeExpressionKey,\n ParsedNodeKnownChildKey,\n ParsedNodeValue,\n ParsedNodeValueRequest,\n ParsedNodeValueRequestKey,\n ParsedNodeRequiredAttributeName,\n ParsedNodeShape,\n ParsedNodeUntypedExpressionKey\n} from './ParsedNodeTypes';\nimport { ParsedValue } from '../values/ParsedValue';\nimport { AbstractValueProvider } from '../values/AbstractValueProvider';\n\nexport interface ParsedNodeOptions extends ParseEvent {\n definition: Node<any>;\n key?: string;\n}\n\nexport interface ParsedNodeValidationContext {\n scope: ValidationContext;\n}\n\nexport interface NodeValidationEvent<Shape extends ParsedNodeShape = ParsedNodeShape, Value = ParsedNodeValue<Shape>> {\n node: ParsedNode<Shape, Value>;\n context: NodeValidationContext;\n}\n\nexport interface NodeValidationContext {\n readonly scope: ValidationContext;\n report(diagnostic: ParsedValidationDiagnostic): void;\n}\n\nexport interface ParsedNodeListener<\n Shape extends ParsedNodeShape = ParsedNodeShape,\n Value = ParsedNodeValue<Shape>\n> extends TreeNodeListener {\n /**\n * Report diagnostics and introduce child scopes before validating expressions and descendants.\n * Hooks run in registration order during explicit validation, independently of parsing.\n */\n preValidation?(event: NodeValidationEvent<Shape, Value>): void;\n\n /**\n * Validate this node after its expressions and descendants using the resulting context.\n */\n postValidation?(event: NodeValidationEvent<Shape, Value>): void;\n}\n\nexport class ParsedNode<T extends ParsedNodeShape = ParsedNodeShape, Value = ParsedNodeValue<T>> extends TreeNode<\n ParsedNodeListener<any, any>\n> {\n private readonly parsedValues = new Map<ParsedAttribute, ParsedValue<any>>();\n private attributesByKey: Map<string, ParsedAttribute> = new Map();\n private childrenByKey: Map<string, ParsedChild> = new Map();\n private valueProviders?: readonly AbstractValueProvider[];\n public readonly definition: Node<any>;\n public readonly input?: NodeInput;\n public readonly parseParentNode?: ParsedNode;\n private parsedContent: any;\n private readonly diagnostics = new ParsedDiagnosticStore();\n private readonly reportError: (diagnostic: ParsedDiagnostic) => void;\n\n constructor(options: ParsedNodeOptions) {\n const definition = options.definition;\n super(options.key ?? definition.options.key);\n this.definition = definition;\n this.input = options.input;\n this.parseParentNode = options.parentNode;\n this.reportError = options.report;\n }\n\n get type(): string {\n return this.attribute('type')?.expression()?.value() ?? this.definition.options.name;\n }\n\n registerListener(listener: Partial<ParsedNodeListener<T, Value>>): () => void {\n return super.registerListener(listener);\n }\n\n get children(): ParsedNode[] {\n return this.nodes();\n }\n\n getRoot(): ParsedNode {\n const parent = this.getParent<ParsedNode>() ?? this.parseParentNode;\n return parent?.getRoot() ?? this;\n }\n\n get parsedValueProviders(): readonly AbstractValueProvider[] | undefined {\n return this.valueProviders;\n }\n\n setValueProviders(providers: readonly AbstractValueProvider[]): this {\n this.parsedValues.clear();\n this.valueProviders = Object.freeze([...providers]);\n this.childEntries().forEach((child) => child.setValueProviders(providers));\n return this;\n }\n\n value<const Keys extends readonly ParsedNodeValueRequestKey<T, Value>[]>(\n attributes: Keys\n ): ParsedNodeValuesLike<ParsedNodeValueRequest<T, Value, Keys>>;\n value<RequestedValue = any>(\n attributes: readonly ParsedNodeUntypedExpressionKey<T>[]\n ): ParsedNodeValuesLike<RequestedValue>;\n value(attributeKeys: readonly string[]): ParsedNodeValuesLike<any> {\n const attributes = this.collectAttributeValues(attributeKeys);\n return new ParsedNodeValues(\n attributes.map(([, source]) => source),\n (currentValues) =>\n Object.fromEntries(\n attributes.flatMap(([key], index) =>\n currentValues[index] === undefined ? [] : [[key, currentValues[index]]]\n )\n )\n );\n }\n\n /**\n * Resolve this node's attributes and descendants through their value providers.\n * Include declared defaults for absent children without creating parsed nodes.\n */\n valueTree(): ParsedNodeValuesLike<Value> {\n const defaults = this.definition.nodes.flatMap(({ options, defaultValue }) =>\n !this.childrenByKey.has(options.key) && defaultValue !== undefined ? [[options.key, defaultValue]] : []\n );\n const attributes = this.collectAttributeValues(this.attributes().map((attribute) => attribute.getKey()));\n const sources: Array<readonly [string, ParsedNodeValuesLike<unknown>]> = [...attributes];\n for (const [key, child] of this.childrenByKey) {\n if (child instanceof ParsedArrayNode && child.inputPresent === false && child.definition.defaultValue == null) {\n continue;\n }\n sources.push([key, child.valueTree()]);\n }\n return new ParsedNodeValues<Value>(\n sources.map(([, source]) => source),\n (currentValues) =>\n Object.fromEntries([\n ...defaults,\n ...sources.flatMap(([key], index) =>\n index < attributes.length && currentValues[index] === undefined ? [] : [[key, currentValues[index]]]\n )\n ]) as Value\n );\n }\n\n /**\n * Collect retained attribute sources for a value container to own and release.\n */\n protected collectAttributeValues(attributeKeys: readonly string[]): Array<readonly [string, ParsedValue<unknown>]> {\n if (!this.valueProviders) {\n throw new Error(`No value providers have been configured for parsed node '${this.getKey()}'`);\n }\n const attributes = attributeKeys.map((key) => {\n const attribute = this.attribute(key);\n if (!attribute) {\n throw new Error(`Unknown parsed attribute '${key}' on node '${this.getKey()}'`);\n }\n return attribute;\n });\n const sources: Array<readonly [string, ParsedValue<unknown>]> = [];\n for (const attribute of attributes) {\n sources.push([attribute.getKey(), this.getParsedValue(attribute).retain()]);\n }\n return sources;\n }\n\n attribute<Key extends Extract<ParsedNodeRequiredAttributeName<T>, ParsedNodeExpressionKey<T>>>(\n key: Key\n ): ParsedNodeAttribute<T, Key>;\n attribute<Key extends Exclude<ParsedNodeExpressionKey<T>, ParsedNodeRequiredAttributeName<T>>>(\n key: Key\n ): ParsedNodeAttribute<T, Key> | undefined;\n attribute<Attribute extends ParsedAttribute = ParsedAttribute>(key: string): Attribute | undefined;\n attribute(key: string): ParsedAttribute | undefined {\n return this.attributesByKey.get(key);\n }\n\n attrExpression<Key extends ParsedNodeExpressionKey<T>>(key: Key): ParsedNodeAttributeShape<T>[Key] | undefined;\n attrExpression<Value = any>(key: ParsedNodeUntypedExpressionKey<T>): Value | undefined;\n attrExpression(key: string): any {\n return this.attributesByKey.get(key)?.expression();\n }\n\n attributes(): ParsedAttribute[];\n attributes<const Names extends readonly ParsedNodeAttributeName<T>[]>(names: Names): ParsedAttribute[];\n attributes(names?: readonly string[]): ParsedAttribute[] {\n const attributes = Array.from(this.attributesByKey.values());\n if (!names || names.length === 0) {\n return attributes;\n }\n\n return attributes.filter((attribute) => names.includes(attribute.name));\n }\n\n content() {\n return this.parsedContent;\n }\n\n setContent(content: any): this {\n this.parsedContent = content;\n return this;\n }\n\n /**\n * Validate attribute expressions and descendants against the supplied scope.\n * Diagnostics are returned without changing parse errors or reading values.\n */\n validate({ scope }: ParsedNodeValidationContext): ParsedValidationDiagnostic[] {\n const diagnostics: ParsedValidationDiagnostic[] = [];\n const source = this.input?.source;\n const context: NodeValidationContext = {\n scope,\n report(diagnostic) {\n diagnostics.push(diagnostic.token ? diagnostic : { ...diagnostic, source: diagnostic.source ?? source });\n }\n };\n this.iterateListeners((listener) => listener.preValidation?.({ node: this, context }));\n diagnostics.push(\n ...this.attributes().flatMap(\n (attribute) =>\n attribute\n .expression()\n ?.validate(scope)\n .map((diagnostic) => ({ ...diagnostic, source: attribute.input?.source ?? source })) ?? []\n ),\n ...this.nodes().flatMap((child) => child.validate({ scope }))\n );\n this.iterateListeners((listener) => listener.postValidation?.({ node: this, context }));\n return diagnostics;\n }\n\n pushError({ message, source = this.input?.source, type }: ParsedDiagnostic): ParsedDiagnostic {\n const diagnostic = this.diagnostics.pushError({ message, source, type });\n this.reportError({ source, message, type });\n return diagnostic;\n }\n\n reportDiagnostic(diagnostic: ParsedDiagnostic) {\n this.reportError(diagnostic);\n }\n\n errors(options: { deep?: boolean } = {}): ParsedDiagnostic[] {\n if (!options.deep) {\n return this.diagnostics.errors();\n }\n\n return [\n ...this.diagnostics.errors(),\n ...this.attributes().flatMap((attribute) => attribute.errors()),\n ...this.childEntries().flatMap((child) => {\n if (child instanceof ParsedArrayNode) {\n return [...child.errors(), ...child.nodes().flatMap((node) => node.errors({ deep: true }))];\n }\n return child.errors({ deep: true });\n })\n ];\n }\n\n hasErrors(options: { deep?: boolean } = {}): boolean {\n return this.errors(options).length > 0;\n }\n\n child(key: string): ParsedChild | undefined {\n return this.childrenByKey.get(key);\n }\n\n setChild(key: string, child: ParsedChild): this {\n const existing = this.childrenByKey.get(key);\n if (existing && existing !== child) {\n existing.delete();\n }\n\n this.childrenByKey.set(key, child);\n\n this.addParsedChild(child);\n\n if (this.valueProviders) {\n child.setValueProviders(this.valueProviders);\n }\n\n return this;\n }\n\n removeChild(key: string): this {\n const child = this.childrenByKey.get(key);\n this.childrenByKey.delete(key);\n child?.delete();\n return this;\n }\n\n setAttribute(attribute: ParsedAttribute): this {\n const previous = this.attributesByKey.get(attribute.definition.options.key);\n this.parsedValues.delete(previous);\n this.attributesByKey.set(attribute.definition.options.key, attribute);\n this.addParsedAttribute(attribute);\n return this;\n }\n\n node<Key extends ParsedNodeKnownChildKey<T>>(key: Key): ParsedNodeChild<T, Key> | undefined;\n node<Child extends ParsedChild = ParsedChild>(\n key: T extends ParsedChildNamesMarker<any> ? never : string\n ): Child | undefined;\n node(key: string): ParsedChild | undefined {\n return this.child(key);\n }\n\n childEntries(): ParsedChild[] {\n return Array.from(this.childrenByKey.values());\n }\n\n nodes(): ParsedNode[] {\n return this.childEntries().flatMap((child) => {\n if (child instanceof ParsedArrayNode) {\n return this.flattenParsedArray(child);\n }\n return [child];\n });\n }\n\n private flattenParsedArray(arrayNode: ParsedArrayNode): ParsedNode[] {\n return arrayNode.nodes().flatMap((child) => {\n if (child instanceof ParsedArrayNode) {\n return this.flattenParsedArray(child);\n }\n return [child];\n });\n }\n\n private getParsedValue(attribute: ParsedAttribute): ParsedValue<any> {\n let value = this.parsedValues.get(attribute);\n if (!value) {\n value = new ParsedValue(attribute, this.valueProviders);\n this.parsedValues.set(attribute, value);\n const deregister = value.registerListener({\n disposed: () => {\n deregister();\n if (this.parsedValues.get(attribute) === value) {\n this.parsedValues.delete(attribute);\n }\n }\n });\n }\n return value;\n }\n\n private addParsedAttribute(attribute: ParsedAttribute) {\n const existing = this.getChild(attribute.getKey());\n if (existing) {\n existing.delete();\n }\n this.addChild(attribute);\n }\n\n private addParsedChild(child: ParsedChild) {\n const existing = this.getChild(child.getKey());\n if (existing) {\n existing.delete();\n }\n this.addChild(child);\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParsedRecordNode = void 0;
|
|
4
|
+
const ParsedNode_1 = require("./ParsedNode");
|
|
5
|
+
const ParsedNodeValues_1 = require("../values/ParsedNodeValues");
|
|
6
|
+
/** Only document keys become entries; the entry definition does not imply a default key. */
|
|
7
|
+
class ParsedRecordNode extends ParsedNode_1.ParsedNode {
|
|
8
|
+
valueTree() {
|
|
9
|
+
const entries = this.nodes();
|
|
10
|
+
return new ParsedNodeValues_1.ParsedNodeValues(entries.map((entry) => entry.valueTree()), (values) => Object.fromEntries(entries.map((entry, index) => [entry.getKey(), values[index]])));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ParsedRecordNode = ParsedRecordNode;
|
|
14
|
+
//# sourceMappingURL=ParsedRecordNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParsedRecordNode.js","sourceRoot":"","sources":["../../src/parsed/ParsedRecordNode.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAC1C,iEAAyF;AAEzF,4FAA4F;AAC5F,sBAAyE,SAAQ,uBAGhF;IACC,SAAS;QACP,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC7B,OAAO,IAAI,mCAAgB,CACzB,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,EACzC,CAAC,MAAM,EAAE,EAAE,CACT,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAA0B,CAC9G,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { ParsedNode } from './ParsedNode';\nimport { ParsedNodeValues, type ParsedNodeValuesLike } from '../values/ParsedNodeValues';\n\n/** Only document keys become entries; the entry definition does not imply a default key. */\nexport class ParsedRecordNode<Entry extends ParsedNode<any, any>, Value> extends ParsedNode<\n Record<string, Entry>,\n Record<string, Value>\n> {\n valueTree(): ParsedNodeValuesLike<Record<string, Value>> {\n const entries = this.nodes();\n return new ParsedNodeValues(\n entries.map((entry) => entry.valueTree()),\n (values) =>\n Object.fromEntries(entries.map((entry, index) => [entry.getKey(), values[index]])) as Record<string, Value>\n );\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceReference.js","sourceRoot":"","sources":["../../src/source/SourceReference.ts"],"names":[],"mappings":"","sourcesContent":["/** Offsets use UTF-16 code units; end is exclusive. */\nexport interface SourceRange {\n readonly start: number;\n readonly end: number;\n}\n\n/** Format adapters can extend this with their original syntax objects. */\nexport interface SourceReference {\n readonly range: SourceRange;\n}\n"]}
|