xmlui 0.7.34 → 0.8.1
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/_commonjsHelpers-BkfeUUK-.mjs +28 -0
- package/dist/{apiInterceptorWorker-DHDoRL37.mjs → apiInterceptorWorker-CJUgtSE2.mjs} +1 -1
- package/dist/index-B09mlAcY.mjs +28210 -0
- package/dist/index.css +1 -1
- package/dist/language-server.d.ts +24 -0
- package/dist/language-server.mjs +14331 -0
- package/dist/lint-BN6SMVda.mjs +4902 -0
- package/dist/parser-Bko8vvFS.mjs +746 -0
- package/dist/scripts/src/components/Accordion/Accordion.js +10 -10
- package/dist/scripts/src/components/App/App.js +3 -3
- package/dist/scripts/src/components/AppHeader/AppHeader.js +3 -3
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +14 -14
- package/dist/scripts/src/components/Avatar/Avatar.js +4 -4
- package/dist/scripts/src/components/Badge/Badge.js +5 -5
- package/dist/scripts/src/components/Button/Button.js +64 -64
- package/dist/scripts/src/components/Card/Card.js +3 -3
- package/dist/scripts/src/components/Carousel/Carousel.js +14 -14
- package/dist/scripts/src/components/Checkbox/Checkbox.js +14 -14
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +1 -1
- package/dist/scripts/src/components/DatePicker/DatePicker.js +8 -8
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.js +8 -8
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +3 -3
- package/dist/scripts/src/components/Footer/Footer.js +5 -5
- package/dist/scripts/src/components/Form/Form.js +16 -16
- package/dist/scripts/src/components/FormItem/FormItem.js +2 -2
- package/dist/scripts/src/components/Heading/Heading.js +1 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +11 -11
- package/dist/scripts/src/components/Link/Link.js +6 -6
- package/dist/scripts/src/components/List/ListNative.js +53 -39
- package/dist/scripts/src/components/Markdown/Markdown.js +3 -3
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +2 -2
- package/dist/scripts/src/components/NavGroup/NavGroup.js +2 -2
- package/dist/scripts/src/components/NavLink/NavLink.js +3 -3
- package/dist/scripts/src/components/NavPanel/NavPanel.js +2 -2
- package/dist/scripts/src/components/NoResult/NoResult.js +1 -1
- package/dist/scripts/src/components/OffCanvas/OffCanvas.js +1 -1
- package/dist/scripts/src/components/ProgressBar/ProgressBar.js +2 -2
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +16 -16
- package/dist/scripts/src/components/Select/Select.js +16 -16
- package/dist/scripts/src/components/Slider/Slider.js +11 -11
- package/dist/scripts/src/components/Spinner/Spinner.js +2 -2
- package/dist/scripts/src/components/Splitter/Splitter.js +1 -1
- package/dist/scripts/src/components/StickyBox/StickyBox.js +1 -1
- package/dist/scripts/src/components/Switch/Switch.js +18 -18
- package/dist/scripts/src/components/Table/Table.js +17 -17
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +7 -7
- package/dist/scripts/src/components/Tabs/Tabs.js +12 -12
- package/dist/scripts/src/components/Text/Text.js +23 -23
- package/dist/scripts/src/components/TextBox/TextBox.js +11 -11
- package/dist/scripts/src/components-core/theming/themes/base-utils.js +0 -16
- package/dist/scripts/src/components-core/theming/themes/root.js +73 -86
- package/dist/scripts/src/components-core/theming/themes/solid.js +1 -1
- package/dist/scripts/src/components-core/theming/themes/xmlui.js +3 -3
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +152 -152
- package/dist/scripts/src/parsers/scripting/Parser.js +2 -2
- package/dist/style.css +1 -1
- package/dist/xmlui-metadata.mjs +7916 -7916
- package/dist/xmlui-metadata.umd.js +11 -11
- package/dist/xmlui-parser.mjs +53 -52
- package/dist/xmlui-standalone.umd.js +146 -146
- package/dist/xmlui.d.ts +3 -3
- package/dist/xmlui.mjs +1 -1
- package/package.json +11 -5
- package/dist/index-B90aqc2f.mjs +0 -28217
- package/dist/lint-D3rXRbP1.mjs +0 -5645
- package/dist/scripts/bin/language-server.js +0 -11
- package/dist/scripts/src/components-core/abstractions/standalone.js +0 -2
- package/dist/scripts/src/components-core/interception/abstractions.js +0 -2
- package/dist/scripts/src/language-server/metadata.js +0 -8206
- package/dist/scripts/src/language-server/server.js +0 -135
- package/dist/scripts/src/language-server/services/completion.js +0 -100
- package/dist/scripts/src/language-server/services/hover.js +0 -170
- package/dist/scripts/src/language-server/services/syntax-node-utilities.js +0 -22
- package/dist/scripts/src/parsers/xmlui-parser/index.js +0 -29
- package/dist/scripts/src/parsers/xmlui-parser/lint.js +0 -177
- package/dist/scripts/src/parsers/xmlui-parser/xmlui-serializer.js +0 -582
- package/dist/scripts/src/parsers/xmlui-parser/xmlui-tree.js +0 -2
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const node_1 = require("vscode-languageserver/node");
|
|
13
|
-
const completion_1 = require("./services/completion");
|
|
14
|
-
const hover_1 = require("./services/hover");
|
|
15
|
-
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
16
|
-
const parser_1 = require("../parsers/xmlui-parser/parser");
|
|
17
|
-
// Create a connection for the server, using Node's IPC as a transport.
|
|
18
|
-
// Also include all preview / proposed LSP features.
|
|
19
|
-
const connection = (0, node_1.createConnection)(node_1.ProposedFeatures.all);
|
|
20
|
-
// Create a simple text document manager.
|
|
21
|
-
const documents = new node_1.TextDocuments(vscode_languageserver_textdocument_1.TextDocument);
|
|
22
|
-
let hasConfigurationCapability = false;
|
|
23
|
-
let hasWorkspaceFolderCapability = false;
|
|
24
|
-
let hasDiagnosticRelatedInformationCapability = false;
|
|
25
|
-
connection.onInitialize((params) => {
|
|
26
|
-
connection.console.log("initing!");
|
|
27
|
-
const capabilities = params.capabilities;
|
|
28
|
-
// Does the client support the `workspace/configuration` request?
|
|
29
|
-
// If not, we fall back using global settings.
|
|
30
|
-
hasConfigurationCapability = !!(capabilities.workspace && !!capabilities.workspace.configuration);
|
|
31
|
-
hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders);
|
|
32
|
-
hasDiagnosticRelatedInformationCapability = !!(capabilities.textDocument &&
|
|
33
|
-
capabilities.textDocument.publishDiagnostics &&
|
|
34
|
-
capabilities.textDocument.publishDiagnostics.relatedInformation);
|
|
35
|
-
const result = {
|
|
36
|
-
capabilities: {
|
|
37
|
-
textDocumentSync: node_1.TextDocumentSyncKind.Incremental,
|
|
38
|
-
// Tell the client that this server supports code completion.
|
|
39
|
-
completionProvider: {
|
|
40
|
-
resolveProvider: false,
|
|
41
|
-
triggerCharacters: ["<", "/"],
|
|
42
|
-
},
|
|
43
|
-
hoverProvider: true,
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
if (hasWorkspaceFolderCapability) {
|
|
47
|
-
result.capabilities.workspace = {
|
|
48
|
-
workspaceFolders: {
|
|
49
|
-
supported: true
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
});
|
|
55
|
-
connection.onInitialized(() => {
|
|
56
|
-
if (hasConfigurationCapability) {
|
|
57
|
-
// Register for all configuration changes.
|
|
58
|
-
connection.client.register(node_1.DidChangeConfigurationNotification.type, undefined);
|
|
59
|
-
}
|
|
60
|
-
if (hasWorkspaceFolderCapability) {
|
|
61
|
-
connection.workspace.onDidChangeWorkspaceFolders(_event => {
|
|
62
|
-
connection.console.log('Workspace folder change event received.');
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
connection.onCompletion((_a) => __awaiter(void 0, [_a], void 0, function* ({ position, textDocument }) {
|
|
67
|
-
connection.console.log(`Received request completion`);
|
|
68
|
-
const document = documents.get(textDocument.uri);
|
|
69
|
-
if (!document) {
|
|
70
|
-
return [];
|
|
71
|
-
}
|
|
72
|
-
const parseResult = getParseResult(document);
|
|
73
|
-
return (0, completion_1.handleCompletion)(parseResult.parseResult, document.offsetAt(position), parseResult.getText);
|
|
74
|
-
}));
|
|
75
|
-
connection.onHover(({ position, textDocument }) => {
|
|
76
|
-
connection.console.log(`Received request hover`);
|
|
77
|
-
const document = documents.get(textDocument.uri);
|
|
78
|
-
if (!document) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
const parseResult = getParseResult(document);
|
|
82
|
-
const hoverRes = (0, hover_1.handleHover)(parseResult, document.offsetAt(position));
|
|
83
|
-
if (hoverRes === null) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
const { value, range } = hoverRes;
|
|
87
|
-
return {
|
|
88
|
-
contents: {
|
|
89
|
-
kind: node_1.MarkupKind.Markdown,
|
|
90
|
-
value,
|
|
91
|
-
},
|
|
92
|
-
range: {
|
|
93
|
-
start: document.positionAt(range.pos),
|
|
94
|
-
end: document.positionAt(range.end),
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
const parseResults = new Map();
|
|
99
|
-
function getParseResult(document) {
|
|
100
|
-
const parseForDoc = parseResults.get(document.uri);
|
|
101
|
-
if (parseForDoc !== undefined) {
|
|
102
|
-
if (parseForDoc.version === document.version) {
|
|
103
|
-
return {
|
|
104
|
-
parseResult: parseForDoc.parseResult,
|
|
105
|
-
getText: parseForDoc.getText,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const parser = (0, parser_1.createXmlUiParser)(document.getText());
|
|
110
|
-
const parseResult = parser.parse();
|
|
111
|
-
parseResults.set(document.uri, {
|
|
112
|
-
parseResult,
|
|
113
|
-
version: document.version,
|
|
114
|
-
getText: parser.getText,
|
|
115
|
-
});
|
|
116
|
-
return { parseResult, getText: parser.getText };
|
|
117
|
-
}
|
|
118
|
-
// This handler resolves additional information for the item selected in
|
|
119
|
-
// the completion list.
|
|
120
|
-
connection.onCompletionResolve((item) => {
|
|
121
|
-
if (item.data === 1) {
|
|
122
|
-
item.detail = 'TypeScript details';
|
|
123
|
-
item.documentation = 'TypeScript documentation';
|
|
124
|
-
}
|
|
125
|
-
else if (item.data === 2) {
|
|
126
|
-
item.detail = 'JavaScript details';
|
|
127
|
-
item.documentation = 'JavaScript documentation';
|
|
128
|
-
}
|
|
129
|
-
return item;
|
|
130
|
-
});
|
|
131
|
-
// Make the text document manager listen on the connection
|
|
132
|
-
// for open, change and close text document events
|
|
133
|
-
documents.listen(connection);
|
|
134
|
-
// Listen on the connection
|
|
135
|
-
connection.listen();
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.handleCompletion = handleCompletion;
|
|
7
|
-
const utils_1 = require("../../parsers/xmlui-parser/utils");
|
|
8
|
-
const syntax_kind_1 = require("../../parsers/xmlui-parser/syntax-kind");
|
|
9
|
-
const metadata_1 = __importDefault(require("../metadata"));
|
|
10
|
-
const syntax_node_utilities_1 = require("./syntax-node-utilities");
|
|
11
|
-
function handleCompletion({ node }, position, getText) {
|
|
12
|
-
const findRes = (0, utils_1.findTokenAtPos)(node, position);
|
|
13
|
-
if (!findRes) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const { chainAtPos, chainBeforePos, sharedParents } = findRes;
|
|
17
|
-
if (findRes.chainBeforePos === undefined) {
|
|
18
|
-
return handleCompletionInsideToken(chainAtPos, position, getText);
|
|
19
|
-
}
|
|
20
|
-
const nodeBefore = chainBeforePos.at(-1);
|
|
21
|
-
switch (nodeBefore.kind) {
|
|
22
|
-
case syntax_kind_1.SyntaxKind.OpenNodeStart:
|
|
23
|
-
return allComponentNames();
|
|
24
|
-
case syntax_kind_1.SyntaxKind.CloseNodeStart:
|
|
25
|
-
return matchingTagName(findRes, getText);
|
|
26
|
-
}
|
|
27
|
-
const completeForProp = chainBeforePos.some(n => n.kind === syntax_kind_1.SyntaxKind.AttributeKeyNode ||
|
|
28
|
-
n.kind === syntax_kind_1.SyntaxKind.TagNameNode ||
|
|
29
|
-
n.kind === syntax_kind_1.SyntaxKind.AttributeNode);
|
|
30
|
-
if (completeForProp) {
|
|
31
|
-
const tagNameNode = (0, syntax_node_utilities_1.findTagNameNodeInStack)(chainAtPos);
|
|
32
|
-
const compName = (0, syntax_node_utilities_1.compNameForTagNameNode)(tagNameNode, getText);
|
|
33
|
-
return completionForNewProps(compName);
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
function allComponentNames() {
|
|
38
|
-
return Object.keys(metadata_1.default).map(name => ({ label: name }));
|
|
39
|
-
}
|
|
40
|
-
function matchingTagName({ chainAtPos, chainBeforePos, sharedParents }, getText) {
|
|
41
|
-
let parentBefore;
|
|
42
|
-
if (chainBeforePos.length > 1) {
|
|
43
|
-
parentBefore = chainBeforePos[chainBeforePos.length - 2];
|
|
44
|
-
}
|
|
45
|
-
else if (sharedParents > 0) {
|
|
46
|
-
parentBefore = chainAtPos[sharedParents - 1];
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return allComponentNames();
|
|
50
|
-
}
|
|
51
|
-
if (parentBefore.kind === syntax_kind_1.SyntaxKind.ElementNode) {
|
|
52
|
-
const nameNode = parentBefore.children.find((c) => c.kind === syntax_kind_1.SyntaxKind.TagNameNode);
|
|
53
|
-
if (nameNode === undefined) {
|
|
54
|
-
return allComponentNames();
|
|
55
|
-
}
|
|
56
|
-
const colonIdx = nameNode.children.findIndex((c) => c.kind === syntax_kind_1.SyntaxKind.Colon);
|
|
57
|
-
let nameSpace = undefined;
|
|
58
|
-
let nameIdentSearchSpace = nameNode.children;
|
|
59
|
-
let name = undefined;
|
|
60
|
-
if (colonIdx !== -1) {
|
|
61
|
-
nameIdentSearchSpace = nameNode.children.slice(colonIdx + 1);
|
|
62
|
-
const nameSpaceIdx = nameNode.children.findIndex((c) => c.kind === syntax_kind_1.SyntaxKind.Identifier);
|
|
63
|
-
if (nameSpaceIdx < colonIdx) {
|
|
64
|
-
nameSpace = getText(nameNode.children[nameSpaceIdx]);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const nameIdent = nameIdentSearchSpace.find((c) => c.kind === syntax_kind_1.SyntaxKind.Identifier);
|
|
68
|
-
if (nameIdent === undefined) {
|
|
69
|
-
return allComponentNames();
|
|
70
|
-
}
|
|
71
|
-
name = getText(nameIdent);
|
|
72
|
-
const value = nameSpace !== undefined ? nameSpace + ":" + name : name;
|
|
73
|
-
return [{ label: value }];
|
|
74
|
-
}
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
function handleCompletionInsideToken(chainAtPos, position, getText) {
|
|
78
|
-
const parent = chainAtPos.at(-2);
|
|
79
|
-
if (!parent) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
switch (parent.kind) {
|
|
83
|
-
case syntax_kind_1.SyntaxKind.TagNameNode: {
|
|
84
|
-
return allComponentNames();
|
|
85
|
-
}
|
|
86
|
-
case syntax_kind_1.SyntaxKind.AttributeKeyNode: {
|
|
87
|
-
const tagNameNode = (0, syntax_node_utilities_1.findTagNameNodeInStack)(chainAtPos);
|
|
88
|
-
const compName = (0, syntax_node_utilities_1.compNameForTagNameNode)(tagNameNode, getText);
|
|
89
|
-
return completionForNewProps(compName);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
function completionForNewProps(compName) {
|
|
95
|
-
const metadata = metadata_1.default[compName];
|
|
96
|
-
if (!metadata || !metadata.props) {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
return Object.keys(metadata.props).map(propName => ({ label: propName }));
|
|
100
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.handleHover = handleHover;
|
|
7
|
-
const utils_1 = require("../../parsers/xmlui-parser/utils");
|
|
8
|
-
const syntax_kind_1 = require("../../parsers/xmlui-parser/syntax-kind");
|
|
9
|
-
const metadata_1 = __importDefault(require("../metadata"));
|
|
10
|
-
const syntax_node_utilities_1 = require("./syntax-node-utilities");
|
|
11
|
-
/**
|
|
12
|
-
* @returns The hover content string
|
|
13
|
-
*/
|
|
14
|
-
function handleHover({ parseResult: { node }, getText }, position) {
|
|
15
|
-
const findRes = (0, utils_1.findTokenAtPos)(node, position);
|
|
16
|
-
console.log("findres: ", findRes);
|
|
17
|
-
if (findRes === undefined) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
const { chainAtPos } = findRes;
|
|
21
|
-
const atNode = chainAtPos.at(-1);
|
|
22
|
-
const parentNode = chainAtPos.at(-2);
|
|
23
|
-
console.log("hovering: ", atNode, parentNode);
|
|
24
|
-
switch (atNode.kind) {
|
|
25
|
-
case syntax_kind_1.SyntaxKind.Identifier:
|
|
26
|
-
switch (parentNode === null || parentNode === void 0 ? void 0 : parentNode.kind) {
|
|
27
|
-
case syntax_kind_1.SyntaxKind.TagNameNode: {
|
|
28
|
-
return hoverName(parentNode, atNode, getText);
|
|
29
|
-
}
|
|
30
|
-
case syntax_kind_1.SyntaxKind.AttributeKeyNode: {
|
|
31
|
-
return hoverAttr(parentNode, chainAtPos.slice(0, -2), getText);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
function hoverAttr(attrKeyNode, parentStack, getText) {
|
|
39
|
-
var _a, _b, _c;
|
|
40
|
-
if (parentStack.at(-1).kind !== syntax_kind_1.SyntaxKind.AttributeNode) {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
if (parentStack.at(-2).kind !== syntax_kind_1.SyntaxKind.AttributeListNode) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
// console.log(parentStack.map(n => toDbgString(n, getText)));
|
|
47
|
-
const tag = parentStack.at(-3);
|
|
48
|
-
if ((tag === null || tag === void 0 ? void 0 : tag.kind) !== syntax_kind_1.SyntaxKind.ElementNode) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
const tagNameNode = (0, syntax_node_utilities_1.findTagNameNodeInStack)(parentStack);
|
|
52
|
-
if (!tagNameNode) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
const compName = (0, syntax_node_utilities_1.compNameForTagNameNode)(tagNameNode, getText);
|
|
56
|
-
const component = metadata_1.default[compName];
|
|
57
|
-
if (!component) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
const attrKeyChildren = attrKeyNode.children;
|
|
61
|
-
const identIdx = attrKeyChildren.findIndex(c => c.kind === syntax_kind_1.SyntaxKind.Identifier);
|
|
62
|
-
if (identIdx === -1) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
console.log("here");
|
|
66
|
-
const attrIdent = attrKeyChildren[identIdx];
|
|
67
|
-
const propIsNamespaceDefinition = ((_a = attrKeyChildren[identIdx + 1]) === null || _a === void 0 ? void 0 : _a.kind) === syntax_kind_1.SyntaxKind.Colon && ((_b = attrKeyChildren[identIdx + 2]) === null || _b === void 0 ? void 0 : _b.kind) === syntax_kind_1.SyntaxKind.Identifier && getText(attrIdent) === "xmlns";
|
|
68
|
-
if (propIsNamespaceDefinition) {
|
|
69
|
-
return {
|
|
70
|
-
value: `Defines a namespace. TODO Further Documentation needed.`,
|
|
71
|
-
range: {
|
|
72
|
-
pos: attrKeyNode.pos,
|
|
73
|
-
end: attrKeyNode.end
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
const propName = getText(attrIdent);
|
|
78
|
-
const propMetadata = (_c = component.props) === null || _c === void 0 ? void 0 : _c[propName];
|
|
79
|
-
if (!propMetadata) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
const value = generatePropDescription(propName, propMetadata);
|
|
83
|
-
return {
|
|
84
|
-
value,
|
|
85
|
-
range: {
|
|
86
|
-
pos: attrKeyNode.pos,
|
|
87
|
-
end: attrKeyNode.end
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function hoverName(tagNameNode, identNode, getText) {
|
|
92
|
-
const compName = (0, syntax_node_utilities_1.compNameForTagNameNode)(tagNameNode, getText);
|
|
93
|
-
if (!compName) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
const compMetadata = metadata_1.default[compName];
|
|
97
|
-
if (!compMetadata) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
const value = generateCompNameDescription(compName, compMetadata);
|
|
101
|
-
return {
|
|
102
|
-
value,
|
|
103
|
-
range: {
|
|
104
|
-
pos: identNode.pos,
|
|
105
|
-
end: identNode.end
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function generateCompNameDescription(componentName, metadata) {
|
|
110
|
-
const sections = [];
|
|
111
|
-
// Add title and description
|
|
112
|
-
sections.push(`# ${componentName}`);
|
|
113
|
-
if (metadata.description) {
|
|
114
|
-
sections.push(metadata.description);
|
|
115
|
-
}
|
|
116
|
-
// Add status if not stable
|
|
117
|
-
if (metadata.status && metadata.status !== 'stable') {
|
|
118
|
-
sections.push(`**Status:** ${metadata.status}`);
|
|
119
|
-
}
|
|
120
|
-
// Add Properties section if there are props
|
|
121
|
-
if (metadata.props && Object.keys(metadata.props).length > 0) {
|
|
122
|
-
sections.push('\n## Properties');
|
|
123
|
-
Object.entries(metadata.props)
|
|
124
|
-
.filter(([_, prop]) => !prop.isInternal)
|
|
125
|
-
.forEach(([propName, prop]) => {
|
|
126
|
-
sections.push(generatePropDescription(propName, prop));
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
// Add Events section if there are events
|
|
130
|
-
if (metadata.events && Object.keys(metadata.events).length > 0) {
|
|
131
|
-
sections.push('\n## Events');
|
|
132
|
-
Object.entries(metadata.events)
|
|
133
|
-
.filter(([_, event]) => !event.isInternal)
|
|
134
|
-
.forEach(([eventName, event]) => {
|
|
135
|
-
sections.push(`### \`${eventName}\`\n${event.description}`);
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
// Add APIs section if there are APIs
|
|
139
|
-
if (metadata.apis && Object.keys(metadata.apis).length > 0) {
|
|
140
|
-
sections.push('\n## APIs');
|
|
141
|
-
Object.entries(metadata.apis)
|
|
142
|
-
.filter(([_, api]) => !api.isInternal)
|
|
143
|
-
.forEach(([apiName, api]) => {
|
|
144
|
-
sections.push(`### \`${apiName}\`\n${api.description}`);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
// Add Context Variables section if there are any
|
|
148
|
-
if (metadata.contextVars && Object.keys(metadata.contextVars).length > 0) {
|
|
149
|
-
sections.push('\n## Context Variables');
|
|
150
|
-
Object.entries(metadata.contextVars)
|
|
151
|
-
.filter(([_, contextVar]) => !contextVar.isInternal)
|
|
152
|
-
.forEach(([varName, contextVar]) => {
|
|
153
|
-
sections.push(`### \`${varName}\`\n${contextVar.description}`);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
return sections.join('\n\n');
|
|
157
|
-
}
|
|
158
|
-
function generatePropDescription(propName, prop) {
|
|
159
|
-
let propText = `### \`${propName}\`\n${prop.description}`;
|
|
160
|
-
if (prop.defaultValue !== undefined) {
|
|
161
|
-
propText += `\n\nDefault: \`${prop.defaultValue}\``;
|
|
162
|
-
}
|
|
163
|
-
if (prop.availableValues) {
|
|
164
|
-
const values = prop.availableValues.map(v => typeof v === 'object' ?
|
|
165
|
-
`- \`${v.value}\`: ${v.description}` :
|
|
166
|
-
`- \`${v}\``).join('\n');
|
|
167
|
-
propText += `\n\nAllowed values:\n${values}`;
|
|
168
|
-
}
|
|
169
|
-
return propText;
|
|
170
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findTagNameNodeInStack = findTagNameNodeInStack;
|
|
4
|
-
exports.compNameForTagNameNode = compNameForTagNameNode;
|
|
5
|
-
const xmlui_parser_1 = require("../../parsers/xmlui-parser");
|
|
6
|
-
function findTagNameNodeInStack(nodeStack) {
|
|
7
|
-
const elementNode = nodeStack.findLast(n => n.kind === xmlui_parser_1.SyntaxKind.ElementNode);
|
|
8
|
-
if (!elementNode) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
const tagNameNode = elementNode.children.find(n => n.kind === xmlui_parser_1.SyntaxKind.TagNameNode);
|
|
12
|
-
return tagNameNode;
|
|
13
|
-
}
|
|
14
|
-
function compNameForTagNameNode(tagNameNode, getText) {
|
|
15
|
-
const colonIdx = tagNameNode.children.findIndex((n) => n.kind === xmlui_parser_1.SyntaxKind.Colon);
|
|
16
|
-
const hasNs = colonIdx === -1 ? false : tagNameNode.children.slice(0, colonIdx).findIndex((n) => n.kind === xmlui_parser_1.SyntaxKind.Identifier) !== -1;
|
|
17
|
-
if (hasNs) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
const nameNode = tagNameNode.children.findLast(c => c.kind === xmlui_parser_1.SyntaxKind.Identifier);
|
|
21
|
-
return getText(nameNode);
|
|
22
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./CharacterCodes"), exports);
|
|
18
|
-
__exportStar(require("./diagnostics"), exports);
|
|
19
|
-
__exportStar(require("./fileExtensions"), exports);
|
|
20
|
-
__exportStar(require("./lint"), exports);
|
|
21
|
-
__exportStar(require("./parser"), exports);
|
|
22
|
-
__exportStar(require("./ParserError"), exports);
|
|
23
|
-
__exportStar(require("./scanner"), exports);
|
|
24
|
-
__exportStar(require("./syntax-kind"), exports);
|
|
25
|
-
__exportStar(require("./syntax-node"), exports);
|
|
26
|
-
__exportStar(require("./transform"), exports);
|
|
27
|
-
__exportStar(require("./utils"), exports);
|
|
28
|
-
__exportStar(require("./xmlui-serializer"), exports);
|
|
29
|
-
__exportStar(require("./xmlui-tree"), exports);
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LintDiagKind = exports.LintSeverity = void 0;
|
|
4
|
-
exports.getLintSeverity = getLintSeverity;
|
|
5
|
-
exports.lintApp = lintApp;
|
|
6
|
-
exports.printComponentLints = printComponentLints;
|
|
7
|
-
exports.lintErrorsComponent = lintErrorsComponent;
|
|
8
|
-
exports.lint = lint;
|
|
9
|
-
const descriptorHelper_1 = require("../../components-core/descriptorHelper");
|
|
10
|
-
const abstractions_1 = require("../../components/abstractions");
|
|
11
|
-
const transform_1 = require("./transform");
|
|
12
|
-
var LintSeverity;
|
|
13
|
-
(function (LintSeverity) {
|
|
14
|
-
LintSeverity[LintSeverity["Skip"] = 0] = "Skip";
|
|
15
|
-
LintSeverity[LintSeverity["Warning"] = 1] = "Warning";
|
|
16
|
-
LintSeverity[LintSeverity["Error"] = 2] = "Error";
|
|
17
|
-
})(LintSeverity || (exports.LintSeverity = LintSeverity = {}));
|
|
18
|
-
;
|
|
19
|
-
var LintDiagKind;
|
|
20
|
-
(function (LintDiagKind) {
|
|
21
|
-
LintDiagKind[LintDiagKind["UnrecognisedProp"] = 0] = "UnrecognisedProp";
|
|
22
|
-
})(LintDiagKind || (exports.LintDiagKind = LintDiagKind = {}));
|
|
23
|
-
;
|
|
24
|
-
function getLintSeverity(lintSeverityOption) {
|
|
25
|
-
if (!lintSeverityOption) {
|
|
26
|
-
return LintSeverity.Warning;
|
|
27
|
-
}
|
|
28
|
-
let lintSeverity = LintSeverity.Warning;
|
|
29
|
-
switch (lintSeverityOption.toLowerCase()) {
|
|
30
|
-
case "warning":
|
|
31
|
-
return LintSeverity.Warning;
|
|
32
|
-
break;
|
|
33
|
-
case "error":
|
|
34
|
-
return LintSeverity.Error;
|
|
35
|
-
break;
|
|
36
|
-
case "skip":
|
|
37
|
-
return LintSeverity.Skip;
|
|
38
|
-
break;
|
|
39
|
-
default:
|
|
40
|
-
console.warn(`Invalid lint severity option '${lintSeverityOption}'. Must be one of: 'warning', 'error', 'skip'. Defaulting to 'warning'.`);
|
|
41
|
-
return LintSeverity.Warning;
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function lintApp({ appDef, metadataByComponent, }) {
|
|
46
|
-
var _a;
|
|
47
|
-
const entryPointLints = {
|
|
48
|
-
componentName: "Main",
|
|
49
|
-
lints: lint({
|
|
50
|
-
component: appDef.entryPoint,
|
|
51
|
-
metadataByComponent: metadataByComponent,
|
|
52
|
-
})
|
|
53
|
-
};
|
|
54
|
-
const compoundCompLints = ((_a = appDef.components) !== null && _a !== void 0 ? _a : [])
|
|
55
|
-
.map((c) => {
|
|
56
|
-
const lints = lint({
|
|
57
|
-
component: c,
|
|
58
|
-
metadataByComponent: metadataByComponent,
|
|
59
|
-
});
|
|
60
|
-
return { lints, componentName: c.name };
|
|
61
|
-
});
|
|
62
|
-
return [entryPointLints, ...compoundCompLints].filter((diags) => diags.lints.length > 0);
|
|
63
|
-
}
|
|
64
|
-
function printComponentLints(lintDiags) {
|
|
65
|
-
console.group(`Validation on '${lintDiags.componentName}':`);
|
|
66
|
-
lintDiags.lints.forEach(({ message }) => {
|
|
67
|
-
console.warn(message);
|
|
68
|
-
});
|
|
69
|
-
console.groupEnd();
|
|
70
|
-
}
|
|
71
|
-
function lintErrorsComponent(lints) {
|
|
72
|
-
function makeComponent() {
|
|
73
|
-
const errList = lints
|
|
74
|
-
.map((lint, idx) => {
|
|
75
|
-
return {
|
|
76
|
-
type: "VStack",
|
|
77
|
-
props: { gap: "0px" },
|
|
78
|
-
children: [
|
|
79
|
-
{
|
|
80
|
-
type: "VStack",
|
|
81
|
-
props: { "backgroundColor": 'lightgrey', padding: "10px" },
|
|
82
|
-
children: [
|
|
83
|
-
{
|
|
84
|
-
type: "H2",
|
|
85
|
-
props: {
|
|
86
|
-
value: `#${idx + 1}: In component '${lint.componentName}':`,
|
|
87
|
-
color: "$color-info",
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
type: "VStack",
|
|
92
|
-
children: lint.lints.map(({ message }, msgIdx) => {
|
|
93
|
-
return {
|
|
94
|
-
type: "Text",
|
|
95
|
-
props: { value: `${idx + 1}.${msgIdx + 1}: ${message}`, fontWeight: "bold" },
|
|
96
|
-
};
|
|
97
|
-
}),
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
const comp = {
|
|
105
|
-
type: "VStack",
|
|
106
|
-
props: { padding: "$padding-normal", gap: 0 },
|
|
107
|
-
children: [
|
|
108
|
-
{
|
|
109
|
-
type: "H1",
|
|
110
|
-
props: {
|
|
111
|
-
value: `Errors found while checking Xmlui markup`,
|
|
112
|
-
padding: "$padding-normal",
|
|
113
|
-
backgroundColor: "$color-error",
|
|
114
|
-
color: "white",
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
type: "VStack",
|
|
119
|
-
props: {
|
|
120
|
-
gap: "$gap-tight",
|
|
121
|
-
padding: "$padding-normal",
|
|
122
|
-
},
|
|
123
|
-
children: errList,
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
};
|
|
127
|
-
return comp;
|
|
128
|
-
}
|
|
129
|
-
return makeComponent();
|
|
130
|
-
}
|
|
131
|
-
function lint({ component, metadataByComponent, }) {
|
|
132
|
-
if ("component" in component) {
|
|
133
|
-
return lintHelp(component.component, metadataByComponent, []);
|
|
134
|
-
}
|
|
135
|
-
return lintHelp(component, metadataByComponent, []);
|
|
136
|
-
}
|
|
137
|
-
function lintHelp(component, metadataByComponent, acc) {
|
|
138
|
-
const componentType = component.type.startsWith(transform_1.CORE_NAMESPACE_VALUE) ? component.type.slice(transform_1.CORE_NAMESPACE_VALUE.length + 1) : component.type;
|
|
139
|
-
const metadataForCurrentComponent = metadataByComponent[componentType];
|
|
140
|
-
const skipPropLints = !component.props || !metadataForCurrentComponent || !metadataForCurrentComponent.props || metadataForCurrentComponent.allowArbitraryProps;
|
|
141
|
-
if (!skipPropLints) {
|
|
142
|
-
lintProps(component, metadataForCurrentComponent, acc);
|
|
143
|
-
}
|
|
144
|
-
if (!component.children) {
|
|
145
|
-
return acc;
|
|
146
|
-
}
|
|
147
|
-
for (const child of component.children) {
|
|
148
|
-
lintHelp(child, metadataByComponent, acc);
|
|
149
|
-
}
|
|
150
|
-
return acc;
|
|
151
|
-
}
|
|
152
|
-
const implicitPropNames = descriptorHelper_1.layoutOptionKeys;
|
|
153
|
-
function lintProps(component, metadataForCurrentComponent, diags) {
|
|
154
|
-
const propNames = Object.keys(component.props);
|
|
155
|
-
const unrecognisedProps = propNames.filter((name) => !implicitProp(name) && !(name in metadataForCurrentComponent.props));
|
|
156
|
-
for (const prop of unrecognisedProps) {
|
|
157
|
-
diags.push(toUnrecognisedPropDiag(component, prop));
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function toUnrecognisedPropDiag(component, prop) {
|
|
161
|
-
return {
|
|
162
|
-
message: `Unrecognised property '${prop}' on component '${component.type}'.`,
|
|
163
|
-
kind: LintDiagKind.UnrecognisedProp,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
function implicitProp(name) {
|
|
167
|
-
for (const size of abstractions_1.viewportSizeMd) {
|
|
168
|
-
const suffix = "-" + (size.value);
|
|
169
|
-
if (name.endsWith(suffix)) {
|
|
170
|
-
const nameWithoutSize = name.slice(0, -suffix.length);
|
|
171
|
-
if (implicitPropNames.includes(nameWithoutSize)) {
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return implicitPropNames.includes(name);
|
|
177
|
-
}
|