xmlui 0.7.19 → 0.7.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{apiInterceptorWorker-C3bvewX6.mjs → apiInterceptorWorker-LRHkKnha.mjs} +1 -1
- package/dist/{grammar.tmLanguage-69iP6c5d.mjs → grammar.tmLanguage-DNepe_jP.mjs} +1 -1
- package/dist/index-5NLXyjX0.mjs +31055 -0
- package/dist/index.css +1 -1
- package/dist/scripts/bin/build-lib.js +1 -1
- package/dist/scripts/bin/index.js +2 -2
- package/dist/scripts/bin/start.js +23 -6
- package/dist/scripts/bin/viteConfig.js +1 -0
- package/dist/scripts/package.json +2 -1
- package/dist/scripts/src/abstractions/ExtensionDefs.js +2 -0
- package/dist/scripts/src/components/Carousel/CarouselItemNative.js +7 -4
- package/dist/scripts/src/components/Carousel/CarouselNative.js +6 -6
- package/dist/scripts/src/components/ComponentProvider.js +171 -148
- package/dist/scripts/src/components/FormItem/FormItemNative.js +1 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +33 -0
- package/dist/scripts/src/components/RawHtml/RawHtml.js +39 -0
- package/dist/scripts/src/components/RawHtml/RawHtmlNative.js +13 -0
- package/dist/scripts/src/components/Theme/ThemeNative.js +1 -1
- package/dist/scripts/src/components-core/LoaderComponent.js +1 -1
- package/dist/scripts/src/components-core/RestApiProxy.js +1 -1
- package/dist/scripts/src/components-core/StandaloneApp.js +19 -19
- package/dist/scripts/src/components-core/{StandaloneComponentManager.js → StandaloneExtensionManager.js} +6 -13
- package/dist/scripts/src/components-core/action/APICall.js +1 -1
- package/dist/scripts/src/components-core/loader/PageableLoader.js +4 -4
- package/dist/scripts/src/components-core/{AppRoot.js → rendering/AppContent.js} +60 -145
- package/dist/scripts/src/components-core/rendering/AppRoot.js +55 -0
- package/dist/scripts/src/components-core/rendering/AppWrapper.js +44 -0
- package/dist/scripts/src/components-core/{ComponentBed.js → rendering/ComponentAdapter.js} +8 -8
- package/dist/scripts/src/components-core/rendering/ComponentWrapper.js +147 -0
- package/dist/scripts/src/components-core/rendering/Container.js +576 -0
- package/dist/scripts/src/components-core/rendering/ContainerWrapper.js +82 -0
- package/dist/scripts/src/components-core/{ErrorBoundary.js → rendering/ErrorBoundary.js} +9 -3
- package/dist/scripts/src/components-core/rendering/StateContainer.js +331 -0
- package/dist/scripts/src/components-core/{container → rendering}/buildProxy.js +11 -7
- package/dist/scripts/src/components-core/{container → rendering}/collectFnVarDeps.js +2 -2
- package/dist/scripts/src/components-core/{container → rendering}/reducer.js +3 -0
- package/dist/scripts/src/components-core/rendering/renderChild.js +81 -0
- package/dist/scripts/src/index.js +3 -6
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +193 -164
- package/dist/scripts/src/syntax/grammar.tmLanguage.json +1 -1
- package/dist/style.css +1 -1
- package/dist/xmlui-metadata.mjs +4216 -4232
- package/dist/xmlui-metadata.umd.js +16 -16
- package/dist/xmlui-standalone.umd.js +262 -290
- package/dist/xmlui.d.ts +36 -61
- package/dist/xmlui.mjs +1 -1
- package/package.json +2 -1
- package/dist/index-BwlAHBcX.mjs +0 -76810
- package/dist/scripts/src/components/BarChart/BarChart.js +0 -49
- package/dist/scripts/src/components/BarChart/BarChartNative.js +0 -176
- package/dist/scripts/src/components/Map/Map.js +0 -75
- package/dist/scripts/src/components/Map/world_countries.json +0 -45307
- package/dist/scripts/src/components/PieChart/PieChart.js +0 -45
- package/dist/scripts/src/components/PieChart/PieChartNative.js +0 -165
- package/dist/scripts/src/components/chart-color-schemes.js +0 -43
- package/dist/scripts/src/components-core/container/Container.js +0 -1186
- package/dist/scripts/src/components-core/container/ContainerComponentDef.js +0 -15
- /package/dist/scripts/src/components-core/{InvalidComponent.js → rendering/InvalidComponent.js} +0 -0
- /package/dist/scripts/src/components-core/{UnknownComponent.js → rendering/UnknownComponent.js} +0 -0
- /package/dist/scripts/src/components-core/{container → rendering}/valueExtractor.js +0 -0
|
@@ -18,139 +18,52 @@ const APP_NS_KEY = "app-ns";
|
|
|
18
18
|
const APP_NS_VALUE = "#app-ns";
|
|
19
19
|
const CORE_NS_KEY = "core-ns";
|
|
20
20
|
const CORE_NS_VALUE = "#xmlui-core-ns";
|
|
21
|
+
var HelperNode;
|
|
22
|
+
(function (HelperNode) {
|
|
23
|
+
HelperNode[HelperNode["property"] = 0] = "property";
|
|
24
|
+
HelperNode[HelperNode["event"] = 1] = "event";
|
|
25
|
+
HelperNode[HelperNode["var"] = 2] = "var";
|
|
26
|
+
HelperNode[HelperNode["loaders"] = 3] = "loaders";
|
|
27
|
+
HelperNode[HelperNode["uses"] = 4] = "uses";
|
|
28
|
+
HelperNode[HelperNode["method"] = 5] = "method";
|
|
29
|
+
HelperNode[HelperNode["item"] = 6] = "item";
|
|
30
|
+
HelperNode[HelperNode["field"] = 7] = "field";
|
|
31
|
+
})(HelperNode || (HelperNode = {}));
|
|
21
32
|
function nodeToComponentDef(node, originalGetText, fileId, moduleResolver = () => "") {
|
|
22
33
|
const getText = (node) => {
|
|
23
34
|
var _a;
|
|
24
35
|
return (_a = node.text) !== null && _a !== void 0 ? _a : originalGetText(node);
|
|
25
36
|
};
|
|
26
|
-
|
|
27
|
-
if (node.children.length !== 2) {
|
|
28
|
-
reportError("T001");
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
// --- Ensure it's a component
|
|
32
|
-
const element = node.children[0];
|
|
33
|
-
if (element.kind !== syntax_kind_1.SyntaxKind.ElementNode) {
|
|
34
|
-
reportError("T001");
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
+
const element = getTopLvlElement(node, getText);
|
|
37
38
|
const preppedElement = prepNode(element);
|
|
38
|
-
const name = getComponentName(element);
|
|
39
|
-
if (!exports.UCRegex.test(name)) {
|
|
40
|
-
reportError("T002");
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
39
|
const usesStack = [];
|
|
44
40
|
const namespaceStack = [];
|
|
45
|
-
return
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
reportError("T002");
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
const name = getNamespaceResolvedComponentName(node);
|
|
52
|
-
const attrs = getAttributes(node).map(segmentAttr);
|
|
53
|
-
let component;
|
|
41
|
+
return transformTopLvlElement(usesStack, preppedElement);
|
|
42
|
+
function transformTopLvlElement(usesStack, node) {
|
|
43
|
+
const name = getNamespaceResolvedComponentName(node, getText, namespaceStack);
|
|
54
44
|
if (name === exports.COMPOUND_COMP_ID) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
if (!exports.UCRegex.test(compoundName.value)) {
|
|
62
|
-
reportError("T004");
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
// --- Get "method" attributes
|
|
66
|
-
let api;
|
|
67
|
-
const apiAttrs = attrs.filter((attr) => attr.startSegment === "method");
|
|
68
|
-
if (apiAttrs.length > 0) {
|
|
69
|
-
api = {};
|
|
70
|
-
apiAttrs.forEach((attr) => {
|
|
71
|
-
api[attr.name] = attr.value;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// --- Get "var" attributes
|
|
75
|
-
let vars;
|
|
76
|
-
const varsAttrs = attrs.filter((attr) => attr.startSegment === "var");
|
|
77
|
-
if (varsAttrs.length > 0) {
|
|
78
|
-
vars = {};
|
|
79
|
-
varsAttrs.forEach((attr) => {
|
|
80
|
-
vars[attr.name] = attr.value;
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
const children = getChildNodes(node);
|
|
84
|
-
// --- Check for nested component
|
|
85
|
-
const nestedCompound = children.find((child) => child.kind === syntax_kind_1.SyntaxKind.ElementNode && getComponentName(child) === exports.COMPOUND_COMP_ID);
|
|
86
|
-
if (nestedCompound) {
|
|
87
|
-
reportError("T006");
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
// --- Get the single component definition
|
|
91
|
-
const nestedComponents = children.filter((child) => child.kind === syntax_kind_1.SyntaxKind.ElementNode && exports.UCRegex.test(getComponentName(child)));
|
|
92
|
-
if (nestedComponents.length === 0) {
|
|
93
|
-
nestedComponents.push(createTextNodeElement(""));
|
|
94
|
-
}
|
|
95
|
-
const childrenToCollect = [];
|
|
96
|
-
const nestedVars = [];
|
|
97
|
-
for (let child of children) {
|
|
98
|
-
if (child.kind === syntax_kind_1.SyntaxKind.ElementNode) {
|
|
99
|
-
const childName = getComponentName(child);
|
|
100
|
-
if (childName === "var") {
|
|
101
|
-
nestedVars.push(child);
|
|
102
|
-
}
|
|
103
|
-
else if (!exports.UCRegex.test(childName)) {
|
|
104
|
-
childrenToCollect.push(child);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// --- Should we wrap with a Fragment?
|
|
109
|
-
let element;
|
|
110
|
-
if (nestedComponents.length > 1 || nestedVars.length > 0) {
|
|
111
|
-
element = wrapWithFragment([...nestedVars, ...nestedComponents]);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
element = nestedComponents[0];
|
|
115
|
-
}
|
|
116
|
-
namespaceStack.push(new Map());
|
|
117
|
-
// --- Get collect namespace attributes
|
|
118
|
-
const nsAttrs = attrs
|
|
119
|
-
.filter((attr) => attr.namespace === "xmlns")
|
|
120
|
-
.forEach((attr) => {
|
|
121
|
-
addToNamespaces(namespaceStack, element, attr.unsegmentedName, attr.value);
|
|
122
|
-
});
|
|
123
|
-
let nestedComponent = transformSingleElement(usesStack, element);
|
|
124
|
-
namespaceStack.pop();
|
|
125
|
-
component = {
|
|
126
|
-
name: compoundName.value,
|
|
127
|
-
component: nestedComponent,
|
|
128
|
-
debug: {
|
|
129
|
-
source: {
|
|
130
|
-
start: node.start,
|
|
131
|
-
end: node.end,
|
|
132
|
-
fileId,
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
if (api) {
|
|
137
|
-
component.api = api;
|
|
138
|
-
}
|
|
139
|
-
if (vars) {
|
|
140
|
-
nestedComponent.vars = Object.assign(Object.assign({}, nestedComponent.vars), vars);
|
|
141
|
-
}
|
|
142
|
-
nestedComponent.debug = {
|
|
45
|
+
return collectCompoundComponent(node);
|
|
46
|
+
}
|
|
47
|
+
let component = {
|
|
48
|
+
type: name,
|
|
49
|
+
debug: {
|
|
143
50
|
source: {
|
|
144
|
-
start:
|
|
145
|
-
end:
|
|
51
|
+
start: node.start,
|
|
52
|
+
end: node.end,
|
|
146
53
|
fileId,
|
|
147
54
|
},
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
// --- Done
|
|
58
|
+
collectTraits(usesStack, component, node);
|
|
59
|
+
return component;
|
|
60
|
+
}
|
|
61
|
+
function transformInnerElement(usesStack, node) {
|
|
62
|
+
const name = getNamespaceResolvedComponentName(node, getText, namespaceStack);
|
|
63
|
+
if (name === exports.COMPOUND_COMP_ID) {
|
|
64
|
+
reportError("T006");
|
|
152
65
|
}
|
|
153
|
-
component = {
|
|
66
|
+
let component = {
|
|
154
67
|
type: name,
|
|
155
68
|
debug: {
|
|
156
69
|
source: {
|
|
@@ -164,6 +77,98 @@ function nodeToComponentDef(node, originalGetText, fileId, moduleResolver = () =
|
|
|
164
77
|
collectTraits(usesStack, component, node);
|
|
165
78
|
return component;
|
|
166
79
|
}
|
|
80
|
+
function collectCompoundComponent(node) {
|
|
81
|
+
const attrs = getAttributes(node).map(segmentAttr);
|
|
82
|
+
// --- Validate component name
|
|
83
|
+
const compoundName = attrs.find((attr) => attr.name === "name");
|
|
84
|
+
if (!compoundName) {
|
|
85
|
+
reportError("T003");
|
|
86
|
+
}
|
|
87
|
+
if (!exports.UCRegex.test(compoundName.value)) {
|
|
88
|
+
reportError("T004");
|
|
89
|
+
}
|
|
90
|
+
// --- Get "method" attributes
|
|
91
|
+
let api;
|
|
92
|
+
const apiAttrs = attrs.filter((attr) => attr.startSegment === "method");
|
|
93
|
+
if (apiAttrs.length > 0) {
|
|
94
|
+
api = {};
|
|
95
|
+
apiAttrs.forEach((attr) => {
|
|
96
|
+
api[attr.name] = attr.value;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
// --- Get "var" attributes
|
|
100
|
+
let vars;
|
|
101
|
+
const varsAttrs = attrs.filter((attr) => attr.startSegment === "var");
|
|
102
|
+
if (varsAttrs.length > 0) {
|
|
103
|
+
vars = {};
|
|
104
|
+
varsAttrs.forEach((attr) => {
|
|
105
|
+
vars[attr.name] = attr.value;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const children = getChildNodes(node);
|
|
109
|
+
// --- Get the single component definition
|
|
110
|
+
const nestedComponents = children.filter((child) => child.kind === syntax_kind_1.SyntaxKind.ElementNode && !(getComponentName(child, getText) in HelperNode));
|
|
111
|
+
if (nestedComponents.length === 0) {
|
|
112
|
+
nestedComponents.push(createTextNodeElement(""));
|
|
113
|
+
}
|
|
114
|
+
const nonVarHelperNodes = [];
|
|
115
|
+
const nestedVars = [];
|
|
116
|
+
for (let child of children) {
|
|
117
|
+
if (child.kind === syntax_kind_1.SyntaxKind.ElementNode) {
|
|
118
|
+
const childName = getComponentName(child, getText);
|
|
119
|
+
if (childName === "var") {
|
|
120
|
+
nestedVars.push(child);
|
|
121
|
+
}
|
|
122
|
+
else if (childName in HelperNode) {
|
|
123
|
+
nonVarHelperNodes.push(child);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// --- Should we wrap with a Fragment?
|
|
128
|
+
let element;
|
|
129
|
+
if (nestedComponents.length > 1 || nestedVars.length > 0) {
|
|
130
|
+
element = wrapWithFragment([...nestedVars, ...nestedComponents]);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
element = nestedComponents[0];
|
|
134
|
+
}
|
|
135
|
+
namespaceStack.push(new Map());
|
|
136
|
+
// --- Get collect namespace attributes
|
|
137
|
+
const nsAttrs = attrs
|
|
138
|
+
.filter((attr) => attr.namespace === "xmlns")
|
|
139
|
+
.forEach((attr) => {
|
|
140
|
+
addToNamespaces(namespaceStack, element, attr.unsegmentedName, attr.value);
|
|
141
|
+
});
|
|
142
|
+
let nestedComponent = transformInnerElement(usesStack, element);
|
|
143
|
+
namespaceStack.pop();
|
|
144
|
+
const component = {
|
|
145
|
+
name: compoundName.value,
|
|
146
|
+
component: nestedComponent,
|
|
147
|
+
debug: {
|
|
148
|
+
source: {
|
|
149
|
+
start: node.start,
|
|
150
|
+
end: node.end,
|
|
151
|
+
fileId,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
if (api) {
|
|
156
|
+
component.api = api;
|
|
157
|
+
}
|
|
158
|
+
if (vars) {
|
|
159
|
+
nestedComponent.vars = Object.assign(Object.assign({}, nestedComponent.vars), vars);
|
|
160
|
+
}
|
|
161
|
+
nestedComponent.debug = {
|
|
162
|
+
source: {
|
|
163
|
+
start: element.start,
|
|
164
|
+
end: element.end,
|
|
165
|
+
fileId,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
const nodeClone = withNewChildNodes(node, nonVarHelperNodes);
|
|
169
|
+
collectTraits(usesStack, component, nodeClone);
|
|
170
|
+
return component;
|
|
171
|
+
}
|
|
167
172
|
/**
|
|
168
173
|
* Collects component traits from attributes and child elements
|
|
169
174
|
* @param comp Component definition
|
|
@@ -201,17 +206,18 @@ function nodeToComponentDef(node, originalGetText, fileId, moduleResolver = () =
|
|
|
201
206
|
comp.children = mergeValue(comp.children, getText(child));
|
|
202
207
|
return;
|
|
203
208
|
}
|
|
204
|
-
const childName = getComponentName(child);
|
|
205
|
-
if (isCompound && child.kind === syntax_kind_1.SyntaxKind.ElementNode &&
|
|
209
|
+
const childName = getComponentName(child, getText);
|
|
210
|
+
if (isCompound && child.kind === syntax_kind_1.SyntaxKind.ElementNode && !(childName in HelperNode)) {
|
|
206
211
|
// --- This is the single nested component definition of a compound component,
|
|
207
212
|
// --- it is already processed
|
|
208
213
|
return;
|
|
209
214
|
}
|
|
210
215
|
// --- Element name starts with an uppercase letter
|
|
211
|
-
if (
|
|
216
|
+
if (!(childName in HelperNode) && !isCompound) {
|
|
217
|
+
// if (UCRegex.test(childName) && !isCompound) {
|
|
212
218
|
// --- This must be a child component
|
|
213
|
-
// maybe here or in the
|
|
214
|
-
const childComponent =
|
|
219
|
+
// maybe here or in the transformInnerElement function, after the compound comp check
|
|
220
|
+
const childComponent = transformInnerElement(usesStack, child);
|
|
215
221
|
if (childComponent) {
|
|
216
222
|
if (!comp.children) {
|
|
217
223
|
comp.children = [childComponent];
|
|
@@ -376,7 +382,7 @@ function nodeToComponentDef(node, originalGetText, fileId, moduleResolver = () =
|
|
|
376
382
|
}
|
|
377
383
|
if (child.kind !== syntax_kind_1.SyntaxKind.ElementNode)
|
|
378
384
|
return;
|
|
379
|
-
const childName = getComponentName(child);
|
|
385
|
+
const childName = getComponentName(child, getText);
|
|
380
386
|
// --- The only element names we accept are "field" or "item"
|
|
381
387
|
if (childName !== "field" && childName !== "item") {
|
|
382
388
|
reportError("T016");
|
|
@@ -420,11 +426,11 @@ function nodeToComponentDef(node, originalGetText, fileId, moduleResolver = () =
|
|
|
420
426
|
return result;
|
|
421
427
|
}
|
|
422
428
|
function collectValue(usesStack, element, allowName = true) {
|
|
423
|
-
const elementName = getComponentName(element);
|
|
429
|
+
const elementName = getComponentName(element, getText);
|
|
424
430
|
// --- Accept only "name", "value"
|
|
425
431
|
const childNodes = getChildNodes(element);
|
|
426
|
-
const nestedComponents = childNodes.filter((c) => c.kind === syntax_kind_1.SyntaxKind.ElementNode && exports.UCRegex.test(getComponentName(c)));
|
|
427
|
-
const nestedElements = childNodes.filter((c) => c.kind === syntax_kind_1.SyntaxKind.ElementNode && !exports.UCRegex.test(getComponentName(c)));
|
|
432
|
+
const nestedComponents = childNodes.filter((c) => c.kind === syntax_kind_1.SyntaxKind.ElementNode && exports.UCRegex.test(getComponentName(c, getText)));
|
|
433
|
+
const nestedElements = childNodes.filter((c) => c.kind === syntax_kind_1.SyntaxKind.ElementNode && !exports.UCRegex.test(getComponentName(c, getText)));
|
|
428
434
|
const attributes = getAttributes(element).map(segmentAttr);
|
|
429
435
|
const attrProps = attributes.filter((attr) => propAttrs.indexOf(attr.name) >= 0);
|
|
430
436
|
if (attributes.length > attrProps.length) {
|
|
@@ -459,7 +465,7 @@ function nodeToComponentDef(node, originalGetText, fileId, moduleResolver = () =
|
|
|
459
465
|
return null;
|
|
460
466
|
}
|
|
461
467
|
// --- We expect a component definition here!
|
|
462
|
-
const nestedComps = nestedComponents.map((nc) =>
|
|
468
|
+
const nestedComps = nestedComponents.map((nc) => transformInnerElement(usesStack, nc));
|
|
463
469
|
return {
|
|
464
470
|
name,
|
|
465
471
|
value: nestedComps.length === 1 ? nestedComps[0] : nestedComps,
|
|
@@ -501,7 +507,7 @@ function nodeToComponentDef(node, originalGetText, fileId, moduleResolver = () =
|
|
|
501
507
|
// todo: is this needed?
|
|
502
508
|
// --- Just for the sake of being sure...
|
|
503
509
|
// if (loader.type !== "Element") return;
|
|
504
|
-
const loaderDef =
|
|
510
|
+
const loaderDef = transformInnerElement(usesStack, loader);
|
|
505
511
|
// --- Get the uid value
|
|
506
512
|
if (!loaderDef.uid) {
|
|
507
513
|
reportError("T013");
|
|
@@ -565,33 +571,6 @@ function nodeToComponentDef(node, originalGetText, fileId, moduleResolver = () =
|
|
|
565
571
|
// --- Extract the value
|
|
566
572
|
(_a = comp.uses) !== null && _a !== void 0 ? _a : (comp.uses = valueAttr.value.split(",").map((v) => v.trim()));
|
|
567
573
|
}
|
|
568
|
-
function getComponentName(node) {
|
|
569
|
-
const nameTokens = node.children.find((c) => c.kind === syntax_kind_1.SyntaxKind.TagNameNode).children;
|
|
570
|
-
const name = getText(nameTokens.at(-1));
|
|
571
|
-
return name;
|
|
572
|
-
}
|
|
573
|
-
function getNamespaceResolvedComponentName(node) {
|
|
574
|
-
const nameTokens = node.children.find((c) => c.kind === syntax_kind_1.SyntaxKind.TagNameNode).children;
|
|
575
|
-
const name = getText(nameTokens.at(-1));
|
|
576
|
-
if (nameTokens.length === 1) {
|
|
577
|
-
return name;
|
|
578
|
-
}
|
|
579
|
-
const namespace = getText(nameTokens[0]);
|
|
580
|
-
if (namespaceStack.length === 0) {
|
|
581
|
-
reportError("T026");
|
|
582
|
-
}
|
|
583
|
-
let resolvedNamespace = undefined;
|
|
584
|
-
for (let i = namespaceStack.length - 1; i >= 0; --i) {
|
|
585
|
-
resolvedNamespace = namespaceStack[i].get(namespace);
|
|
586
|
-
if (resolvedNamespace !== undefined) {
|
|
587
|
-
break;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
if (resolvedNamespace === undefined) {
|
|
591
|
-
reportError("T027", namespace);
|
|
592
|
-
}
|
|
593
|
-
return resolvedNamespace + "." + name;
|
|
594
|
-
}
|
|
595
574
|
function segmentAttr(attr) {
|
|
596
575
|
let key = attr.children[0];
|
|
597
576
|
const hasNamespace = key.children.length === 3;
|
|
@@ -631,9 +610,10 @@ function nodeToComponentDef(node, originalGetText, fileId, moduleResolver = () =
|
|
|
631
610
|
}
|
|
632
611
|
}
|
|
633
612
|
function prepNode(node) {
|
|
613
|
+
var _a;
|
|
634
614
|
const childNodes = getChildNodes(node);
|
|
635
|
-
const tagName = getComponentName(node);
|
|
636
|
-
const hasComponentName =
|
|
615
|
+
const tagName = getComponentName(node, getText);
|
|
616
|
+
const hasComponentName = !(tagName in HelperNode);
|
|
637
617
|
const shouldUseTextNodeElement = hasComponentName || tagName === "property";
|
|
638
618
|
const shouldCollapseWhitespace = tagName !== "event" && tagName !== "method";
|
|
639
619
|
const attrs = getAttributes(node);
|
|
@@ -681,10 +661,20 @@ function nodeToComponentDef(node, originalGetText, fileId, moduleResolver = () =
|
|
|
681
661
|
}
|
|
682
662
|
childNodes[i] = newChild;
|
|
683
663
|
}
|
|
684
|
-
const helperNodes =
|
|
685
|
-
const otherNodes =
|
|
686
|
-
|
|
687
|
-
const
|
|
664
|
+
const helperNodes = [];
|
|
665
|
+
const otherNodes = [];
|
|
666
|
+
let hasComponentChild = false;
|
|
667
|
+
for (const child of childNodes) {
|
|
668
|
+
if (child.kind === syntax_kind_1.SyntaxKind.ElementNode) {
|
|
669
|
+
let compName = (_a = getComponentName(child, getText)) !== null && _a !== void 0 ? _a : undefined;
|
|
670
|
+
if (compName in HelperNode) {
|
|
671
|
+
helperNodes.push(child);
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
hasComponentChild = true;
|
|
675
|
+
}
|
|
676
|
+
otherNodes.push(child);
|
|
677
|
+
}
|
|
688
678
|
if (hasScriptChild && hasComponentChild) {
|
|
689
679
|
const fragment = wrapWithFragment(otherNodes);
|
|
690
680
|
helperNodes.push(fragment);
|
|
@@ -1060,3 +1050,42 @@ function addToNamespaces(namespaceStack, comp, nsKey, value) {
|
|
|
1060
1050
|
(_a = comp.namespaces) !== null && _a !== void 0 ? _a : (comp.namespaces = {});
|
|
1061
1051
|
comp.namespaces[nsKey] = nsValue;
|
|
1062
1052
|
}
|
|
1053
|
+
function getTopLvlElement(node, getText) {
|
|
1054
|
+
// --- Check that the nodes contains exactly only a single component root element before the EoF token
|
|
1055
|
+
if (node.children.length !== 2) {
|
|
1056
|
+
reportError("T001");
|
|
1057
|
+
}
|
|
1058
|
+
// --- Ensure it's a component
|
|
1059
|
+
const element = node.children[0];
|
|
1060
|
+
if (element.kind !== syntax_kind_1.SyntaxKind.ElementNode) {
|
|
1061
|
+
reportError("T001");
|
|
1062
|
+
}
|
|
1063
|
+
return element;
|
|
1064
|
+
}
|
|
1065
|
+
function getComponentName(node, getText) {
|
|
1066
|
+
const nameTokens = node.children.find((c) => c.kind === syntax_kind_1.SyntaxKind.TagNameNode).children;
|
|
1067
|
+
const name = getText(nameTokens.at(-1));
|
|
1068
|
+
return name;
|
|
1069
|
+
}
|
|
1070
|
+
function getNamespaceResolvedComponentName(node, getText, namespaceStack) {
|
|
1071
|
+
const nameTokens = node.children.find((c) => c.kind === syntax_kind_1.SyntaxKind.TagNameNode).children;
|
|
1072
|
+
const name = getText(nameTokens.at(-1));
|
|
1073
|
+
if (nameTokens.length === 1) {
|
|
1074
|
+
return name;
|
|
1075
|
+
}
|
|
1076
|
+
const namespace = getText(nameTokens[0]);
|
|
1077
|
+
if (namespaceStack.length === 0) {
|
|
1078
|
+
reportError("T026");
|
|
1079
|
+
}
|
|
1080
|
+
let resolvedNamespace = undefined;
|
|
1081
|
+
for (let i = namespaceStack.length - 1; i >= 0; --i) {
|
|
1082
|
+
resolvedNamespace = namespaceStack[i].get(namespace);
|
|
1083
|
+
if (resolvedNamespace !== undefined) {
|
|
1084
|
+
break;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
if (resolvedNamespace === undefined) {
|
|
1088
|
+
reportError("T027", namespace);
|
|
1089
|
+
}
|
|
1090
|
+
return resolvedNamespace + "." + name;
|
|
1091
|
+
}
|
|
@@ -244,7 +244,7 @@
|
|
|
244
244
|
"patterns": [{ "include": "#attribute" }, { "include": "#comments" }]
|
|
245
245
|
},
|
|
246
246
|
"componentTag": {
|
|
247
|
-
"begin": "(
|
|
247
|
+
"begin": "(</?)((?:[a-zA-Z_][\\w\\.\\-]*?:)?)([a-zA-Z][\\w\\.\\-]*)",
|
|
248
248
|
"beginCaptures": {
|
|
249
249
|
"1": { "name": "punctuation.definition.tag.xmlui" },
|
|
250
250
|
"2": { "name": "keyword.operator.namespace.xmlui" },
|