xmlui 0.9.21 → 0.9.25
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-CFF3bC6o.mjs +818 -0
- package/dist/{index-B3CWFAxa.mjs → index-DtxDGaqF.mjs} +11942 -3291
- package/dist/index.css +1301 -564
- package/dist/language-server-web-worker.mjs +1 -1
- package/dist/language-server.mjs +1 -1
- package/dist/lint-CYAUfk0_.mjs +168 -0
- package/dist/metadata-utils-CCIMqe69.mjs +466 -0
- package/dist/scripts/package.json +252 -0
- package/dist/scripts/src/components/App/AppLayoutContext.js +0 -1
- package/dist/scripts/src/components/App/AppNative.js +21 -9
- package/dist/scripts/src/components/AppHeader/AppHeader.js +1 -1
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +5 -2
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +13 -10
- package/dist/scripts/src/components/Bookmark/BookmarkNative.js +5 -1
- package/dist/scripts/src/components/CodeBlock/CodeBlock.js +31 -0
- package/dist/scripts/src/components/CodeBlock/CodeBlockNative.js +82 -0
- package/dist/scripts/src/components/ComponentProvider.js +5 -0
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +1 -0
- package/dist/scripts/src/components/Form/FormContext.js +5 -4
- package/dist/scripts/src/components/Form/FormNative.js +41 -43
- package/dist/scripts/src/components/Form/formActions.js +1 -1
- package/dist/scripts/src/components/FormItem/FormItem.js +6 -3
- package/dist/scripts/src/components/FormItem/FormItemNative.js +56 -15
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +1 -1
- package/dist/scripts/src/components/Heading/Heading.js +13 -0
- package/dist/scripts/src/components/Heading/HeadingNative.js +1 -1
- package/dist/scripts/src/components/HtmlTags/HtmlTags.js +7 -3
- package/dist/scripts/src/components/Icon/DarkToLightIcon.js +10 -0
- package/dist/scripts/src/components/Icon/LightToDark.js +10 -0
- package/dist/scripts/src/components/IconProvider.js +4 -0
- package/dist/scripts/src/components/Image/ImageNative.js +1 -1
- package/dist/scripts/src/components/Items/ItemsNative.js +8 -6
- package/dist/scripts/src/components/Link/Link.js +5 -5
- package/dist/scripts/src/components/List/ListNative.js +1 -1
- package/dist/scripts/src/components/Markdown/Markdown.js +52 -16
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +34 -73
- package/dist/scripts/src/components/Markdown/highlight-code.js +160 -0
- package/dist/scripts/src/components/Markdown/parse-binding-expr.js +60 -0
- package/dist/scripts/src/components/Markdown/utils.js +282 -0
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +116 -0
- package/dist/scripts/src/components/ModalDialog/Dialog.js +20 -0
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +4 -5
- package/dist/scripts/src/components/NestedApp/NestedApp.js +61 -0
- package/dist/scripts/src/components/NestedApp/NestedAppNative.js +125 -0
- package/dist/scripts/src/components/NestedApp/Tooltip.js +46 -0
- package/dist/scripts/src/components/NumberBox/NumberBox.js +4 -1
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +2 -2
- package/dist/scripts/src/components/Option/Option.js +3 -2
- package/dist/scripts/src/components/Select/Select.js +5 -3
- package/dist/scripts/src/components/Select/SelectNative.js +53 -40
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +1 -1
- package/dist/scripts/src/components/Spinner/Spinner.js +0 -1
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +1 -0
- package/dist/scripts/src/components/Text/Text.js +12 -1
- package/dist/scripts/src/components/Text/TextNative.js +5 -1
- package/dist/scripts/src/components/TextBox/TextBox.js +6 -1
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +2 -2
- package/dist/scripts/src/components/Theme/ThemeNative.js +7 -3
- package/dist/scripts/src/components/ToneChangerButton/ToneChangerButton.js +1 -3
- package/dist/scripts/src/components-core/RestApiProxy.js +10 -7
- package/dist/scripts/src/components-core/TableOfContentsContext.js +1 -1
- package/dist/scripts/src/components-core/appContext/date-functions.js +23 -0
- package/dist/scripts/src/components-core/appContext/math-function.js +27 -0
- package/dist/scripts/src/components-core/appContext/misc-utils.js +13 -0
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +199 -0
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +94 -0
- package/dist/scripts/src/components-core/interception/Backend.js +128 -0
- package/dist/scripts/src/components-core/interception/Errors.js +129 -0
- package/dist/scripts/src/components-core/interception/InMemoryDb.js +41 -0
- package/dist/scripts/src/components-core/interception/IndexedDb.js +207 -0
- package/dist/scripts/src/components-core/interception/ReadonlyCollection.js +145 -0
- package/dist/scripts/src/components-core/interception/abstractions.js +2 -0
- package/dist/scripts/src/components-core/interception/apiInterceptorWorker.js +46 -0
- package/dist/scripts/src/components-core/interception/useApiInterceptorContext.js +9 -0
- package/dist/scripts/src/components-core/rendering/AppContent.js +336 -0
- package/dist/scripts/src/components-core/rendering/AppRoot.js +84 -0
- package/dist/scripts/src/components-core/rendering/AppWrapper.js +49 -0
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +17 -7
- package/dist/scripts/src/components-core/rendering/Container.js +2 -1
- package/dist/scripts/src/components-core/theming/ThemeProvider.js +2 -7
- package/dist/scripts/src/components-core/theming/themes/root.js +1 -0
- package/dist/scripts/src/components-core/utils/date-utils.js +78 -0
- package/dist/scripts/src/components-core/utils/hooks.js +26 -0
- package/dist/scripts/src/components-core/utils/misc.js +1 -1
- package/dist/scripts/src/components-core/utils/request-params.js +70 -0
- package/dist/scripts/src/logging/LoggerContext.js +22 -0
- package/dist/scripts/src/logging/LoggerInitializer.js +14 -0
- package/dist/scripts/src/logging/LoggerService.js +60 -0
- package/dist/scripts/src/parsers/xmlui-parser/transform.js +7 -0
- package/dist/{server-common-DW5h7Q34.mjs → server-common-9TiLMTJj.mjs} +106 -98
- package/dist/style.css +3314 -2823
- package/dist/{lint-EcgF-9Wr.mjs → transform-DC0Gy6qw.mjs} +1246 -540
- package/dist/xmlui-metadata.mjs +2850 -2665
- package/dist/xmlui-metadata.umd.js +2850 -2665
- package/dist/xmlui-parser.d.ts +49 -4
- package/dist/xmlui-parser.mjs +49 -48
- package/dist/xmlui-standalone.umd.js +34674 -31457
- package/dist/xmlui.d.ts +3 -1
- package/dist/xmlui.mjs +10 -10
- package/package.json +3 -1
- package/dist/apiInterceptorWorker-7aKQ2rBj.mjs +0 -8447
- package/dist/parser-CBXS8ft2.mjs +0 -1196
|
@@ -322,3 +322,29 @@ const useRealBackground = (element) => {
|
|
|
322
322
|
return (0, react_1.useMemo)(() => element ? realBackgroundColor(element) : 'transparent', [element, counter]);
|
|
323
323
|
};
|
|
324
324
|
exports.useRealBackground = useRealBackground;
|
|
325
|
+
// export const useIsInViewport = (ref, observerOptions) => {
|
|
326
|
+
// const [entered, setEntered] = useState(false);
|
|
327
|
+
// const observer = useRef(
|
|
328
|
+
// new IntersectionObserver(
|
|
329
|
+
// ([entry]) => setEntered(entry.isIntersecting),
|
|
330
|
+
// observerOptions
|
|
331
|
+
// )
|
|
332
|
+
// );
|
|
333
|
+
//
|
|
334
|
+
// useEffect(() => {
|
|
335
|
+
// const element = ref.current;
|
|
336
|
+
// const ob = observer.current;
|
|
337
|
+
//
|
|
338
|
+
// // stop observing once the element has entered the viewport for the first time.
|
|
339
|
+
// // if (entered) {
|
|
340
|
+
// // ob.disconnect();
|
|
341
|
+
// // return;
|
|
342
|
+
// // }
|
|
343
|
+
//
|
|
344
|
+
// if (element) ob.observe(element);
|
|
345
|
+
//
|
|
346
|
+
// return () => ob.disconnect();
|
|
347
|
+
// }, [entered, ref]);
|
|
348
|
+
//
|
|
349
|
+
// return entered;
|
|
350
|
+
// };
|
|
@@ -126,7 +126,7 @@ const useEvent = (callback) => {
|
|
|
126
126
|
}, [callback]);
|
|
127
127
|
return (0, react_1.useCallback)((...args) => {
|
|
128
128
|
const latestFn = callbackRef.current;
|
|
129
|
-
return latestFn(...args);
|
|
129
|
+
return latestFn === null || latestFn === void 0 ? void 0 : latestFn(...args);
|
|
130
130
|
}, [callbackRef]);
|
|
131
131
|
};
|
|
132
132
|
exports.useEvent = useEvent;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertRequestParamPart = convertRequestParamPart;
|
|
4
|
+
// Testable helper function to convert request parameters
|
|
5
|
+
function convertRequestParamPart(part, paramTypes) {
|
|
6
|
+
if (!paramTypes)
|
|
7
|
+
return part;
|
|
8
|
+
const result = Object.assign({}, part);
|
|
9
|
+
Object.keys(part).forEach((key) => {
|
|
10
|
+
if (!(key in paramTypes))
|
|
11
|
+
return;
|
|
12
|
+
const partValue = part[key];
|
|
13
|
+
const partValueType = typeof partValue;
|
|
14
|
+
switch (paramTypes[key]) {
|
|
15
|
+
// --- Parameter to integer
|
|
16
|
+
case "integer":
|
|
17
|
+
switch (partValueType) {
|
|
18
|
+
case "number":
|
|
19
|
+
result[key] = Math.round(partValue);
|
|
20
|
+
break;
|
|
21
|
+
case "string":
|
|
22
|
+
result[key] = parseInt(partValue, 10);
|
|
23
|
+
break;
|
|
24
|
+
case "boolean":
|
|
25
|
+
result[key] = partValue ? 1 : 0;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
// --- Parameter to float
|
|
30
|
+
case "float":
|
|
31
|
+
case "real":
|
|
32
|
+
case "double":
|
|
33
|
+
switch (partValueType) {
|
|
34
|
+
case "number":
|
|
35
|
+
result[key] = partValue;
|
|
36
|
+
break;
|
|
37
|
+
case "string":
|
|
38
|
+
result[key] = parseFloat(partValue);
|
|
39
|
+
break;
|
|
40
|
+
case "boolean":
|
|
41
|
+
result[key] = partValue ? 1 : 0;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
// --- Parameter to boolean
|
|
46
|
+
case "boolean":
|
|
47
|
+
switch (partValueType) {
|
|
48
|
+
case "string":
|
|
49
|
+
switch (partValue.toLowerCase()) {
|
|
50
|
+
case "true":
|
|
51
|
+
case "yes":
|
|
52
|
+
case "on":
|
|
53
|
+
result[key] = true;
|
|
54
|
+
break;
|
|
55
|
+
case "false":
|
|
56
|
+
case "no":
|
|
57
|
+
case "off":
|
|
58
|
+
result[key] = false;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
case "number":
|
|
63
|
+
result[key] = !!partValue;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLogger = exports.LoggerProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const LogContext = (0, react_1.createContext)(undefined);
|
|
7
|
+
const LoggerProvider = ({ children }) => {
|
|
8
|
+
const [logs, setLogs] = (0, react_1.useState)([]);
|
|
9
|
+
const addLog = (0, react_1.useCallback)((args) => {
|
|
10
|
+
const newEntry = { timestamp: new Date(), args };
|
|
11
|
+
setLogs(prev => [...prev, newEntry]);
|
|
12
|
+
}, []);
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(LogContext.Provider, { value: { logs, addLog }, children: children }));
|
|
14
|
+
};
|
|
15
|
+
exports.LoggerProvider = LoggerProvider;
|
|
16
|
+
const useLogger = () => {
|
|
17
|
+
const context = (0, react_1.useContext)(LogContext);
|
|
18
|
+
if (!context)
|
|
19
|
+
throw new Error('useLogger must be used within LoggerProvider');
|
|
20
|
+
return context;
|
|
21
|
+
};
|
|
22
|
+
exports.useLogger = useLogger;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoggerInitializer = void 0;
|
|
4
|
+
const LoggerContext_1 = require("./LoggerContext");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const LoggerService_1 = require("./LoggerService");
|
|
7
|
+
const LoggerInitializer = () => {
|
|
8
|
+
const { addLog } = (0, LoggerContext_1.useLogger)();
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
LoggerService_1.loggerService.registerCallback(addLog);
|
|
11
|
+
}, [addLog]);
|
|
12
|
+
return null;
|
|
13
|
+
};
|
|
14
|
+
exports.LoggerInitializer = LoggerInitializer;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loggerService = void 0;
|
|
4
|
+
class LoggerService {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.isDev = process.env.NODE_ENV === "development" || !!process.env.VITE_DEV_MODE;
|
|
7
|
+
}
|
|
8
|
+
static getInstance() {
|
|
9
|
+
if (!LoggerService.instance) {
|
|
10
|
+
LoggerService.instance = new LoggerService();
|
|
11
|
+
}
|
|
12
|
+
return LoggerService.instance;
|
|
13
|
+
}
|
|
14
|
+
registerCallback(callback) {
|
|
15
|
+
if (this.isDev) {
|
|
16
|
+
this.callback = callback;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
log(args) {
|
|
20
|
+
if (!this.isDev)
|
|
21
|
+
return;
|
|
22
|
+
console.log("[xmlui.log]", ...args);
|
|
23
|
+
if (this.callback) {
|
|
24
|
+
this.callback(args);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
warn(args) {
|
|
28
|
+
if (!this.isDev)
|
|
29
|
+
return;
|
|
30
|
+
console.warn("[xmlui.warn]", ...args);
|
|
31
|
+
if (this.callback) {
|
|
32
|
+
this.callback(args);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
info(args) {
|
|
36
|
+
if (!this.isDev)
|
|
37
|
+
return;
|
|
38
|
+
console.info("[xmlui.info]", ...args);
|
|
39
|
+
if (this.callback) {
|
|
40
|
+
this.callback(args);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
error(args) {
|
|
44
|
+
if (!this.isDev)
|
|
45
|
+
return;
|
|
46
|
+
console.error("[xmlui.error]", ...args);
|
|
47
|
+
if (this.callback) {
|
|
48
|
+
this.callback(args);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
trace(args) {
|
|
52
|
+
if (!this.isDev)
|
|
53
|
+
return;
|
|
54
|
+
console.trace("[xmlui.trace]", ...args);
|
|
55
|
+
if (this.callback) {
|
|
56
|
+
this.callback(args);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.loggerService = LoggerService.getInstance();
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CORE_NAMESPACE_VALUE = exports.onPrefixRegex = exports.UCRegex = exports.COMPOUND_COMP_ID = void 0;
|
|
4
4
|
exports.nodeToComponentDef = nodeToComponentDef;
|
|
5
|
+
exports.stripOnPrefix = stripOnPrefix;
|
|
5
6
|
const code_behind_collect_1 = require("../scripting/code-behind-collect");
|
|
6
7
|
const syntax_kind_1 = require("./syntax-kind");
|
|
7
8
|
const ParserError_1 = require("./ParserError");
|
|
@@ -1103,3 +1104,9 @@ function getNamespaceResolvedComponentName(node, getText, namespaceStack) {
|
|
|
1103
1104
|
}
|
|
1104
1105
|
return resolvedNamespace + "." + name;
|
|
1105
1106
|
}
|
|
1107
|
+
/**
|
|
1108
|
+
* @param name - The name of the event in camelCase, with "on" prefix.
|
|
1109
|
+
*/
|
|
1110
|
+
function stripOnPrefix(name) {
|
|
1111
|
+
return name[2].toLowerCase() + name.substring(3);
|
|
1112
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MarkupKind as MarkupKind$1, CompletionItemKind as CompletionItemKind$1, TextDocuments as TextDocuments$1, TextDocumentSyncKind, DidChangeConfigurationNotification } from "vscode-languageserver";
|
|
2
2
|
import { TextDocument as TextDocument$1 } from "vscode-languageserver-textdocument";
|
|
3
|
-
import { S as SyntaxKind,
|
|
3
|
+
import { S as SyntaxKind, ap as findTokenAtPos, N as createXmlUiParser } from "./transform-DC0Gy6qw.mjs";
|
|
4
|
+
import { q as addOnPrefix, M as MetadataProvider } from "./metadata-utils-CCIMqe69.mjs";
|
|
4
5
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
5
6
|
function getAugmentedNamespace(n) {
|
|
6
7
|
if (n.__esModule) return n;
|
|
@@ -18695,7 +18696,7 @@ function generateCompNameDescription(componentName, metadata) {
|
|
|
18695
18696
|
if (metadata.props && Object.keys(metadata.props).length > 0) {
|
|
18696
18697
|
sections.push("\n## Properties");
|
|
18697
18698
|
Object.entries(metadata.props).filter(([_, prop]) => !prop.isInternal).forEach(([propName, prop]) => {
|
|
18698
|
-
sections.push(
|
|
18699
|
+
sections.push(generateAttrDescription(propName, prop));
|
|
18699
18700
|
});
|
|
18700
18701
|
}
|
|
18701
18702
|
if (metadata.events && Object.keys(metadata.events).length > 0) {
|
|
@@ -18721,21 +18722,27 @@ ${contextVar.description}`);
|
|
|
18721
18722
|
}
|
|
18722
18723
|
return sections.join("\n\n");
|
|
18723
18724
|
}
|
|
18724
|
-
function
|
|
18725
|
-
let propText =
|
|
18726
|
-
|
|
18727
|
-
|
|
18725
|
+
function generateAttrDescription(attrName, attrMd) {
|
|
18726
|
+
let propText = `\`${attrName}\``;
|
|
18727
|
+
if (attrMd.isRequired) {
|
|
18728
|
+
propText += " (required)";
|
|
18729
|
+
}
|
|
18730
|
+
propText += ": ";
|
|
18731
|
+
if (attrMd.description) {
|
|
18732
|
+
propText += attrMd.description;
|
|
18733
|
+
}
|
|
18734
|
+
if (attrMd.defaultValue !== void 0) {
|
|
18728
18735
|
propText += `
|
|
18729
18736
|
|
|
18730
|
-
Default: \`${
|
|
18737
|
+
Default: \`${attrMd.defaultValue}\``;
|
|
18731
18738
|
}
|
|
18732
|
-
if (
|
|
18733
|
-
const values =
|
|
18739
|
+
if (attrMd.availableValues && attrMd.availableValues.length > 0) {
|
|
18740
|
+
const values = attrMd.availableValues.map(
|
|
18734
18741
|
(v) => typeof v === "object" ? `- \`${v.value}\`: ${v.description}` : `- \`${v}\``
|
|
18735
18742
|
).join("\n");
|
|
18736
18743
|
propText += `
|
|
18737
18744
|
|
|
18738
|
-
Allowed values
|
|
18745
|
+
**Allowed values**:
|
|
18739
18746
|
${values}`;
|
|
18740
18747
|
}
|
|
18741
18748
|
return propText;
|
|
@@ -18798,15 +18805,17 @@ function handleCompletionResolve({
|
|
|
18798
18805
|
var _a2;
|
|
18799
18806
|
const metadataAccessInfo = (_a2 = item == null ? void 0 : item.data) == null ? void 0 : _a2.metadataAccessInfo;
|
|
18800
18807
|
if (metadataAccessInfo) {
|
|
18801
|
-
const { componentName } = metadataAccessInfo;
|
|
18802
|
-
const componentMeta = metaByComp2
|
|
18803
|
-
if (
|
|
18804
|
-
|
|
18805
|
-
|
|
18806
|
-
|
|
18808
|
+
const { componentName, attribute } = metadataAccessInfo;
|
|
18809
|
+
const componentMeta = metaByComp2.getComponent(componentName);
|
|
18810
|
+
if (!componentMeta) {
|
|
18811
|
+
return null;
|
|
18812
|
+
}
|
|
18813
|
+
if (attribute) {
|
|
18814
|
+
const attributeMetadata = componentMeta.getAttrForKind(attribute);
|
|
18815
|
+
item.documentation = markupContent(generateAttrDescription(attribute.name, attributeMetadata));
|
|
18807
18816
|
} else {
|
|
18808
18817
|
item.documentation = markupContent(
|
|
18809
|
-
generateCompNameDescription(componentName, componentMeta)
|
|
18818
|
+
generateCompNameDescription(componentName, componentMeta.getMetadata())
|
|
18810
18819
|
);
|
|
18811
18820
|
}
|
|
18812
18821
|
}
|
|
@@ -18846,12 +18855,12 @@ function handleCompletion({ parseResult: { node }, getText, metaByComp: metaByCo
|
|
|
18846
18855
|
if (completeForProp) {
|
|
18847
18856
|
const tagNameNode = findTagNameNodeInStack(chainAtPos);
|
|
18848
18857
|
const compName = compNameForTagNameNode(tagNameNode, getText);
|
|
18849
|
-
return
|
|
18858
|
+
return completionForNewAttr(compName, metaByComp2);
|
|
18850
18859
|
}
|
|
18851
18860
|
return null;
|
|
18852
18861
|
}
|
|
18853
18862
|
function allComponentNames(md) {
|
|
18854
|
-
return
|
|
18863
|
+
return md.componentNames().map(componentCompletionItem);
|
|
18855
18864
|
}
|
|
18856
18865
|
function matchingTagName(elementNode, metaByComp2, getText) {
|
|
18857
18866
|
const nameNode = elementNode.children.find((c) => c.kind === SyntaxKind.TagNameNode);
|
|
@@ -18875,7 +18884,7 @@ function matchingTagName(elementNode, metaByComp2, getText) {
|
|
|
18875
18884
|
}
|
|
18876
18885
|
name = getText(nameIdent);
|
|
18877
18886
|
const value = nameSpace !== void 0 ? nameSpace + ":" + name : name;
|
|
18878
|
-
return [
|
|
18887
|
+
return [componentCompletionItem(value)];
|
|
18879
18888
|
}
|
|
18880
18889
|
function handleCompletionInsideToken(chainAtPos, position, metaByComp2, getText) {
|
|
18881
18890
|
const parent = chainAtPos.at(-2);
|
|
@@ -18898,81 +18907,75 @@ function handleCompletionInsideToken(chainAtPos, position, metaByComp2, getText)
|
|
|
18898
18907
|
case SyntaxKind.AttributeKeyNode: {
|
|
18899
18908
|
const tagNameNode = findTagNameNodeInStack(chainAtPos);
|
|
18900
18909
|
const compName = compNameForTagNameNode(tagNameNode, getText);
|
|
18901
|
-
return
|
|
18910
|
+
return completionForNewAttr(compName, metaByComp2);
|
|
18902
18911
|
}
|
|
18903
18912
|
}
|
|
18904
18913
|
return null;
|
|
18905
18914
|
}
|
|
18906
|
-
function
|
|
18907
|
-
const metadata = metaByComp2
|
|
18908
|
-
if (!metadata
|
|
18915
|
+
function completionForNewAttr(compName, metaByComp2) {
|
|
18916
|
+
const metadata = metaByComp2.getComponent(compName);
|
|
18917
|
+
if (!metadata) {
|
|
18909
18918
|
return null;
|
|
18910
18919
|
}
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
);
|
|
18920
|
+
const completionItemFromAttr = attributeCompletionItem.bind({}, compName);
|
|
18921
|
+
return metadata.getAllAttributes().map(completionItemFromAttr);
|
|
18914
18922
|
}
|
|
18915
|
-
function
|
|
18923
|
+
function attrKindToCompletionItemKind(attrKind) {
|
|
18924
|
+
switch (attrKind) {
|
|
18925
|
+
case "api":
|
|
18926
|
+
return CompletionItemKind$1.Function;
|
|
18927
|
+
case "event":
|
|
18928
|
+
return CompletionItemKind$1.Event;
|
|
18929
|
+
case "implicit":
|
|
18930
|
+
case "layout":
|
|
18931
|
+
case "prop":
|
|
18932
|
+
return CompletionItemKind$1.Property;
|
|
18933
|
+
}
|
|
18934
|
+
}
|
|
18935
|
+
function attributeCompletionItem(componentName, attribute) {
|
|
18936
|
+
const label = attribute.kind === "event" ? addOnPrefix(attribute.name) : attribute.name;
|
|
18916
18937
|
return {
|
|
18917
|
-
|
|
18918
|
-
|
|
18938
|
+
label,
|
|
18939
|
+
kind: attrKindToCompletionItemKind(attribute.kind),
|
|
18940
|
+
data: {
|
|
18941
|
+
metadataAccessInfo: {
|
|
18942
|
+
componentName,
|
|
18943
|
+
attribute
|
|
18944
|
+
}
|
|
18945
|
+
}
|
|
18919
18946
|
};
|
|
18920
18947
|
}
|
|
18921
|
-
|
|
18922
|
-
|
|
18923
|
-
|
|
18924
|
-
|
|
18925
|
-
|
|
18926
|
-
};
|
|
18927
|
-
return new CompletionItemBuilder(item);
|
|
18928
|
-
}
|
|
18929
|
-
static withProp(propName) {
|
|
18930
|
-
const item = {
|
|
18931
|
-
label: propName,
|
|
18932
|
-
kind: CompletionItemKind$1.Property
|
|
18933
|
-
};
|
|
18934
|
-
return new CompletionItemBuilder(item);
|
|
18935
|
-
}
|
|
18936
|
-
constructor(item) {
|
|
18937
|
-
this.item = item;
|
|
18938
|
-
}
|
|
18939
|
-
componentResolveData() {
|
|
18940
|
-
const data = {
|
|
18941
|
-
metadataAccessInfo: { componentName: this.item.label }
|
|
18942
|
-
};
|
|
18943
|
-
this.item.data = data;
|
|
18944
|
-
return this;
|
|
18945
|
-
}
|
|
18946
|
-
propResolveData(componentName) {
|
|
18947
|
-
const data = {
|
|
18948
|
+
function componentCompletionItem(componentName) {
|
|
18949
|
+
return {
|
|
18950
|
+
label: componentName,
|
|
18951
|
+
kind: CompletionItemKind$1.Constructor,
|
|
18952
|
+
data: {
|
|
18948
18953
|
metadataAccessInfo: {
|
|
18949
|
-
componentName
|
|
18950
|
-
prop: this.item.label
|
|
18954
|
+
componentName
|
|
18951
18955
|
}
|
|
18952
|
-
}
|
|
18953
|
-
|
|
18954
|
-
|
|
18955
|
-
|
|
18956
|
-
|
|
18957
|
-
|
|
18958
|
-
|
|
18956
|
+
}
|
|
18957
|
+
};
|
|
18958
|
+
}
|
|
18959
|
+
function markupContent(content) {
|
|
18960
|
+
return {
|
|
18961
|
+
kind: MarkupKind$1.Markdown,
|
|
18962
|
+
value: content
|
|
18963
|
+
};
|
|
18959
18964
|
}
|
|
18960
|
-
function
|
|
18965
|
+
function handleHoverCore({ node, getText, metaByComp: metaByComp2 }, position) {
|
|
18961
18966
|
const findRes = findTokenAtPos(node, position);
|
|
18962
|
-
console.log("findres: ", findRes);
|
|
18963
18967
|
if (findRes === void 0) {
|
|
18964
18968
|
return null;
|
|
18965
18969
|
}
|
|
18966
18970
|
const { chainAtPos } = findRes;
|
|
18967
18971
|
const atNode = chainAtPos.at(-1);
|
|
18968
18972
|
const parentNode = chainAtPos.at(-2);
|
|
18969
|
-
console.log("hovering: ", atNode, parentNode);
|
|
18970
18973
|
switch (atNode.kind) {
|
|
18971
18974
|
case SyntaxKind.Identifier:
|
|
18972
18975
|
switch (parentNode == null ? void 0 : parentNode.kind) {
|
|
18973
18976
|
case SyntaxKind.TagNameNode: {
|
|
18974
18977
|
return hoverName({
|
|
18975
|
-
|
|
18978
|
+
metaByComp: metaByComp2,
|
|
18976
18979
|
tagNameNode: parentNode,
|
|
18977
18980
|
identNode: atNode,
|
|
18978
18981
|
getText
|
|
@@ -18991,13 +18994,30 @@ function handleHover({ parseResult: { node }, getText, metaByComp: metaByComp2 }
|
|
|
18991
18994
|
}
|
|
18992
18995
|
return null;
|
|
18993
18996
|
}
|
|
18997
|
+
function handleHover(ctx, position) {
|
|
18998
|
+
const hoverRes = handleHoverCore(ctx, position);
|
|
18999
|
+
if (hoverRes === null) {
|
|
19000
|
+
return null;
|
|
19001
|
+
}
|
|
19002
|
+
const { value, range } = hoverRes;
|
|
19003
|
+
return {
|
|
19004
|
+
contents: {
|
|
19005
|
+
kind: MarkupKind$1.Markdown,
|
|
19006
|
+
value
|
|
19007
|
+
},
|
|
19008
|
+
range: {
|
|
19009
|
+
start: ctx.offsetToPosition(range.pos),
|
|
19010
|
+
end: ctx.offsetToPosition(range.end)
|
|
19011
|
+
}
|
|
19012
|
+
};
|
|
19013
|
+
}
|
|
18994
19014
|
function hoverAttr({
|
|
18995
19015
|
metaByComp: metaByComp2,
|
|
18996
19016
|
attrKeyNode,
|
|
18997
19017
|
parentStack,
|
|
18998
19018
|
getText
|
|
18999
19019
|
}) {
|
|
19000
|
-
var _a2, _b
|
|
19020
|
+
var _a2, _b;
|
|
19001
19021
|
if (parentStack.at(-1).kind !== SyntaxKind.AttributeNode) {
|
|
19002
19022
|
return null;
|
|
19003
19023
|
}
|
|
@@ -19013,7 +19033,7 @@ function hoverAttr({
|
|
|
19013
19033
|
return null;
|
|
19014
19034
|
}
|
|
19015
19035
|
const compName = compNameForTagNameNode(tagNameNode, getText);
|
|
19016
|
-
const component = metaByComp2
|
|
19036
|
+
const component = metaByComp2.getComponent(compName);
|
|
19017
19037
|
if (!component) {
|
|
19018
19038
|
return null;
|
|
19019
19039
|
}
|
|
@@ -19022,7 +19042,6 @@ function hoverAttr({
|
|
|
19022
19042
|
if (identIdx === -1) {
|
|
19023
19043
|
return null;
|
|
19024
19044
|
}
|
|
19025
|
-
console.log("here");
|
|
19026
19045
|
const attrIdent = attrKeyChildren[identIdx];
|
|
19027
19046
|
const propIsNamespaceDefinition = ((_a2 = attrKeyChildren[identIdx + 1]) == null ? void 0 : _a2.kind) === SyntaxKind.Colon && ((_b = attrKeyChildren[identIdx + 2]) == null ? void 0 : _b.kind) === SyntaxKind.Identifier && getText(attrIdent) === "xmlns";
|
|
19028
19047
|
if (propIsNamespaceDefinition) {
|
|
@@ -19034,12 +19053,12 @@ function hoverAttr({
|
|
|
19034
19053
|
}
|
|
19035
19054
|
};
|
|
19036
19055
|
}
|
|
19037
|
-
const
|
|
19038
|
-
const
|
|
19039
|
-
if (!
|
|
19056
|
+
const attrName = getText(attrIdent);
|
|
19057
|
+
const attrMd = component.getAttr(attrName);
|
|
19058
|
+
if (!attrMd) {
|
|
19040
19059
|
return null;
|
|
19041
19060
|
}
|
|
19042
|
-
const value =
|
|
19061
|
+
const value = generateAttrDescription(attrName, attrMd);
|
|
19043
19062
|
return {
|
|
19044
19063
|
value,
|
|
19045
19064
|
range: {
|
|
@@ -19049,16 +19068,17 @@ function hoverAttr({
|
|
|
19049
19068
|
};
|
|
19050
19069
|
}
|
|
19051
19070
|
function hoverName({
|
|
19052
|
-
|
|
19071
|
+
metaByComp: metaByComp2,
|
|
19053
19072
|
tagNameNode,
|
|
19054
19073
|
identNode,
|
|
19055
19074
|
getText
|
|
19056
19075
|
}) {
|
|
19076
|
+
var _a2;
|
|
19057
19077
|
const compName = compNameForTagNameNode(tagNameNode, getText);
|
|
19058
19078
|
if (!compName) {
|
|
19059
19079
|
return null;
|
|
19060
19080
|
}
|
|
19061
|
-
const compMetadata =
|
|
19081
|
+
const compMetadata = (_a2 = metaByComp2.getComponent(compName)) == null ? void 0 : _a2.getMetadata();
|
|
19062
19082
|
if (!compMetadata) {
|
|
19063
19083
|
return null;
|
|
19064
19084
|
}
|
|
@@ -19072,6 +19092,7 @@ function hoverName({
|
|
|
19072
19092
|
};
|
|
19073
19093
|
}
|
|
19074
19094
|
const metaByComp = collectedComponentMetadata;
|
|
19095
|
+
const metadataProvider = new MetadataProvider(metaByComp);
|
|
19075
19096
|
function start(connection2) {
|
|
19076
19097
|
const documents = new TextDocuments$1(TextDocument$1);
|
|
19077
19098
|
let hasConfigurationCapability = false;
|
|
@@ -19119,10 +19140,10 @@ function start(connection2) {
|
|
|
19119
19140
|
return [];
|
|
19120
19141
|
}
|
|
19121
19142
|
const parseResult = parseDocument(document);
|
|
19122
|
-
return handleCompletion({ parseResult: parseResult.parseResult, getText: parseResult.getText, metaByComp }, document.offsetAt(position));
|
|
19143
|
+
return handleCompletion({ parseResult: parseResult.parseResult, getText: parseResult.getText, metaByComp: metadataProvider }, document.offsetAt(position));
|
|
19123
19144
|
});
|
|
19124
19145
|
connection2.onCompletionResolve((completionItem) => {
|
|
19125
|
-
return handleCompletionResolve({ metaByComp, item: completionItem });
|
|
19146
|
+
return handleCompletionResolve({ metaByComp: metadataProvider, item: completionItem });
|
|
19126
19147
|
});
|
|
19127
19148
|
connection2.onHover(({ position, textDocument }) => {
|
|
19128
19149
|
connection2.console.log(`Received request hover`);
|
|
@@ -19132,25 +19153,12 @@ function start(connection2) {
|
|
|
19132
19153
|
}
|
|
19133
19154
|
const { parseResult, getText } = parseDocument(document);
|
|
19134
19155
|
const ctx = {
|
|
19135
|
-
parseResult,
|
|
19156
|
+
node: parseResult.node,
|
|
19136
19157
|
getText,
|
|
19137
|
-
metaByComp
|
|
19138
|
-
|
|
19139
|
-
const hoverRes = handleHover(ctx, document.offsetAt(position));
|
|
19140
|
-
if (hoverRes === null) {
|
|
19141
|
-
return null;
|
|
19142
|
-
}
|
|
19143
|
-
const { value, range } = hoverRes;
|
|
19144
|
-
return {
|
|
19145
|
-
contents: {
|
|
19146
|
-
kind: MarkupKind$1.Markdown,
|
|
19147
|
-
value
|
|
19148
|
-
},
|
|
19149
|
-
range: {
|
|
19150
|
-
start: document.positionAt(range.pos),
|
|
19151
|
-
end: document.positionAt(range.end)
|
|
19152
|
-
}
|
|
19158
|
+
metaByComp: metadataProvider,
|
|
19159
|
+
offsetToPosition: document.positionAt
|
|
19153
19160
|
};
|
|
19161
|
+
return handleHover(ctx, document.offsetAt(position));
|
|
19154
19162
|
});
|
|
19155
19163
|
const parsedDocuments = /* @__PURE__ */ new Map();
|
|
19156
19164
|
function parseDocument(document) {
|