king-design-analyzer 2.1.7 → 2.2.0
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/components/actions.json +101 -0
- package/components/advancedset.json +127 -0
- package/components/affix.json +7 -0
- package/components/aksk.json +172 -0
- package/components/az.json +15 -2
- package/components/badge.json +7 -0
- package/components/billtypes.json +14 -2
- package/components/breadcrumb.json +7 -0
- package/components/button.json +191 -0
- package/components/buttonlink.json +73 -0
- package/components/card.json +8 -1
- package/components/cardcol.json +142 -0
- package/components/cardcols.json +121 -0
- package/components/cardcontent.json +15 -3
- package/components/cardtabs.json +172 -0
- package/components/carousel.json +7 -0
- package/components/cascader.json +520 -368
- package/components/checkbox.json +51 -4
- package/components/cidrinput.json +140 -0
- package/components/code.json +8 -1
- package/components/collapse.json +7 -0
- package/components/colorpicker.json +217 -0
- package/components/copy.json +7 -0
- package/components/copyhover.json +111 -0
- package/components/copyrow.json +124 -0
- package/components/datepicker.json +656 -524
- package/components/description.json +98 -0
- package/components/dialog.json +522 -455
- package/components/divider.json +8 -1
- package/components/drawer.json +571 -558
- package/components/dropdown.json +464 -384
- package/components/duration.json +125 -0
- package/components/editable.json +66 -0
- package/components/ellipsis.json +34 -1
- package/components/filtertablefieldsdialog.json +128 -0
- package/components/flex.json +151 -0
- package/components/form.json +131 -0
- package/components/formiteminput.json +214 -0
- package/components/formitemspinner.json +213 -0
- package/components/formitemswitch.json +185 -0
- package/components/formitemtableconfigs.json +210 -0
- package/components/grid.json +7 -0
- package/components/header.json +161 -0
- package/components/icon.json +13 -1
- package/components/icontooltip.json +19 -1
- package/components/input.json +188 -4
- package/components/instancelist.json +194 -0
- package/components/instancenum.json +196 -0
- package/components/ipinput.json +117 -0
- package/components/kspstatus.json +205 -0
- package/components/kvcode.json +120 -0
- package/components/layoutcontent.json +15 -3
- package/components/layoutlistcontent.json +148 -0
- package/components/layoutpermissioncontent.json +155 -0
- package/components/layoutstandardlist.json +275 -0
- package/components/layouttabs.json +168 -0
- package/components/lazymount.json +86 -0
- package/components/lazyteleport.json +118 -0
- package/components/menu.json +7 -0
- package/components/pagination.json +12 -0
- package/components/paginationplus.json +30 -3
- package/components/password.json +121 -0
- package/components/popover.json +457 -437
- package/components/projects.json +129 -0
- package/components/protable.json +97 -8
- package/components/queuevisualrange.json +110 -0
- package/components/radio.json +82 -2
- package/components/rate.json +199 -0
- package/components/region.json +14 -2
- package/components/search.json +221 -0
- package/components/searchinput.json +132 -0
- package/components/searchitems.json +215 -0
- package/components/searchselect.json +195 -0
- package/components/select.json +686 -666
- package/components/sidebar.json +198 -0
- package/components/skeleton.json +233 -0
- package/components/spin.json +8 -1
- package/components/split.json +260 -0
- package/components/sshkeys.json +138 -0
- package/components/status.json +60 -3
- package/components/steps.json +7 -0
- package/components/switch.json +8 -1
- package/components/table.json +18 -1
- package/components/tablecolumnid.json +14 -2
- package/components/tabs.json +12 -0
- package/components/timeline.json +213 -0
- package/components/timepicker.json +147 -3
- package/components/timerange.json +262 -0
- package/components/tip.json +7 -0
- package/components/tooltip.json +484 -395
- package/components/tour.json +418 -372
- package/components/transfer.json +27 -3
- package/components/tree.json +6 -4
- package/components/treeselect.json +556 -475
- package/components/upload.json +474 -473
- package/components/vdialog.json +308 -0
- package/components/vdrawer.json +331 -0
- package/components/virtuallist.json +7 -0
- package/dist/ast/index.d.mts +35 -1
- package/dist/ast/index.d.ts +35 -1
- package/dist/ast/index.js +5 -3
- package/dist/ast/index.mjs +3 -1
- package/dist/{chunk-DSWKLUIX.mjs → chunk-3LYQ5XFM.mjs} +1 -1
- package/dist/chunk-BI5TIQID.mjs +330 -0
- package/dist/{chunk-6QS5IGS6.js → chunk-CJGGFVQJ.js} +8 -8
- package/dist/chunk-CR3GC4H3.js +353 -0
- package/dist/{chunk-NZ6TLWMD.mjs → chunk-D2SXGGTX.mjs} +28 -17
- package/dist/{chunk-D3Y6FGWA.js → chunk-EYKZY2F3.js} +29 -18
- package/dist/chunk-JSBRDJBE.js +30 -0
- package/dist/chunk-KF5YBEM5.js +143 -0
- package/dist/chunk-KMIDURUR.mjs +33324 -0
- package/dist/chunk-QC6VTSA3.mjs +117 -0
- package/dist/chunk-SZYVGYKK.js +33350 -0
- package/dist/{chunk-WYSRJVX4.js → chunk-TA3SV4SP.js} +2 -2
- package/dist/chunk-UJCSKKID.mjs +27 -0
- package/dist/{chunk-FVSQ6BU6.mjs → chunk-XGPHQHLR.mjs} +4 -4
- package/dist/docs/index.js +1 -1
- package/dist/docs/index.mjs +1 -1
- package/dist/full/index.js +8 -6
- package/dist/full/index.mjs +6 -4
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -13
- package/dist/index.mjs +7 -5
- package/dist/metadata/index.d.mts +22 -2
- package/dist/metadata/index.d.ts +22 -2
- package/dist/metadata/index.js +27 -17
- package/dist/metadata/index.mjs +27 -16
- package/dist/resolve-BsLBxlBi.d.mts +24 -0
- package/dist/resolve-BsLBxlBi.d.ts +24 -0
- package/dist/runtime/index.js +5 -4
- package/dist/runtime/index.mjs +3 -2
- package/dist/shared/index.d.mts +10 -0
- package/dist/shared/index.d.ts +10 -0
- package/dist/shared/index.js +23 -0
- package/dist/shared/index.mjs +2 -0
- package/dist/static/index.js +6 -5
- package/dist/static/index.mjs +3 -2
- package/docs_for_llm/actions.doc.md +77 -0
- package/docs_for_llm/advancedset.doc.md +89 -0
- package/docs_for_llm/affix.doc.md +15 -7
- package/docs_for_llm/aksk.doc.md +111 -0
- package/docs_for_llm/az.doc.md +17 -11
- package/docs_for_llm/badge.doc.md +6 -5
- package/docs_for_llm/billtypes.doc.md +17 -11
- package/docs_for_llm/breadcrumb.doc.md +6 -3
- package/docs_for_llm/button.doc.md +34 -18
- package/docs_for_llm/buttonlink.doc.md +55 -0
- package/docs_for_llm/card.doc.md +8 -5
- package/docs_for_llm/cardcol.doc.md +78 -0
- package/docs_for_llm/cardcols.doc.md +84 -0
- package/docs_for_llm/cardcontent.doc.md +10 -10
- package/docs_for_llm/cardtabs.doc.md +106 -0
- package/docs_for_llm/carousel.doc.md +8 -7
- package/docs_for_llm/cascader.doc.md +46 -25
- package/docs_for_llm/checkbox.doc.md +25 -13
- package/docs_for_llm/cidrinput.doc.md +83 -0
- package/docs_for_llm/code.doc.md +22 -11
- package/docs_for_llm/collapse.doc.md +9 -6
- package/docs_for_llm/colorpicker.doc.md +104 -0
- package/docs_for_llm/copy.doc.md +15 -13
- package/docs_for_llm/copyhover.doc.md +59 -0
- package/docs_for_llm/copyrow.doc.md +71 -0
- package/docs_for_llm/datepicker.doc.md +51 -39
- package/docs_for_llm/description.doc.md +75 -0
- package/docs_for_llm/descriptions.doc.md +9 -6
- package/docs_for_llm/dialog.doc.md +48 -77
- package/docs_for_llm/divider.doc.md +9 -7
- package/docs_for_llm/drawer.doc.md +43 -84
- package/docs_for_llm/dropdown.doc.md +52 -21
- package/docs_for_llm/duration.doc.md +76 -0
- package/docs_for_llm/editable.doc.md +36 -14
- package/docs_for_llm/ellipsis.doc.md +10 -5
- package/docs_for_llm/filtertablefieldsdialog.doc.md +99 -0
- package/docs_for_llm/flex.doc.md +74 -0
- package/docs_for_llm/form.doc.md +33 -14
- package/docs_for_llm/formiteminput.doc.md +128 -0
- package/docs_for_llm/formitemspinner.doc.md +105 -0
- package/docs_for_llm/formitemswitch.doc.md +113 -0
- package/docs_for_llm/formitemtableconfigs.doc.md +95 -0
- package/docs_for_llm/grid.doc.md +7 -5
- package/docs_for_llm/header.doc.md +85 -0
- package/docs_for_llm/icon.doc.md +12 -8
- package/docs_for_llm/icontooltip.doc.md +121 -0
- package/docs_for_llm/input.doc.md +90 -39
- package/docs_for_llm/instancelist.doc.md +113 -0
- package/docs_for_llm/instancenum.doc.md +95 -0
- package/docs_for_llm/ipinput.doc.md +77 -0
- package/docs_for_llm/kspstatus.doc.md +82 -0
- package/docs_for_llm/kvcode.doc.md +76 -0
- package/docs_for_llm/layoutcontent.doc.md +17 -17
- package/docs_for_llm/layoutlistcontent.doc.md +95 -0
- package/docs_for_llm/layoutpermissioncontent.doc.md +84 -0
- package/docs_for_llm/layoutstandardlist.doc.md +120 -0
- package/docs_for_llm/layouttabs.doc.md +101 -0
- package/docs_for_llm/lazymount.doc.md +73 -0
- package/docs_for_llm/lazyteleport.doc.md +76 -0
- package/docs_for_llm/menu.doc.md +14 -11
- package/docs_for_llm/message.doc.md +48 -10
- package/docs_for_llm/pagination.doc.md +30 -17
- package/docs_for_llm/paginationplus.doc.md +31 -10
- package/docs_for_llm/password.doc.md +86 -0
- package/docs_for_llm/popover.doc.md +24 -55
- package/docs_for_llm/progress.doc.md +13 -10
- package/docs_for_llm/projects.doc.md +91 -0
- package/docs_for_llm/protable.doc.md +89 -15
- package/docs_for_llm/queuevisualrange.doc.md +78 -0
- package/docs_for_llm/radio.doc.md +23 -8
- package/docs_for_llm/rate.doc.md +122 -0
- package/docs_for_llm/region.doc.md +25 -13
- package/docs_for_llm/search.doc.md +120 -0
- package/docs_for_llm/searchinput.doc.md +111 -0
- package/docs_for_llm/searchitems.doc.md +116 -0
- package/docs_for_llm/searchselect.doc.md +126 -0
- package/docs_for_llm/select.doc.md +40 -55
- package/docs_for_llm/sidebar.doc.md +133 -0
- package/docs_for_llm/skeleton.doc.md +117 -0
- package/docs_for_llm/slider.doc.md +31 -21
- package/docs_for_llm/spin.doc.md +8 -5
- package/docs_for_llm/spinner.doc.md +28 -18
- package/docs_for_llm/split.doc.md +157 -0
- package/docs_for_llm/sshkeys.doc.md +88 -0
- package/docs_for_llm/status.doc.md +14 -9
- package/docs_for_llm/steps.doc.md +10 -7
- package/docs_for_llm/switch.doc.md +17 -14
- package/docs_for_llm/table.doc.md +118 -51
- package/docs_for_llm/tablecolumnid.doc.md +36 -16
- package/docs_for_llm/tabs.doc.md +19 -10
- package/docs_for_llm/tag.doc.md +19 -10
- package/docs_for_llm/timeline.doc.md +109 -0
- package/docs_for_llm/timepicker.doc.md +57 -38
- package/docs_for_llm/timerange.doc.md +157 -0
- package/docs_for_llm/tip.doc.md +20 -11
- package/docs_for_llm/tooltip.doc.md +55 -29
- package/docs_for_llm/tour.doc.md +48 -29
- package/docs_for_llm/transfer.doc.md +40 -29
- package/docs_for_llm/tree.doc.md +65 -23
- package/docs_for_llm/treeselect.doc.md +37 -48
- package/docs_for_llm/upload.doc.md +56 -32
- package/docs_for_llm/useCRUD.doc.md +49 -0
- package/docs_for_llm/useCountdown.doc.md +43 -0
- package/docs_for_llm/useDetail.doc.md +48 -0
- package/docs_for_llm/useDialog.doc.md +46 -0
- package/docs_for_llm/useEntity.doc.md +45 -0
- package/docs_for_llm/useEventListener.doc.md +44 -0
- package/docs_for_llm/useFalseUntilTruthy.doc.md +41 -0
- package/docs_for_llm/useGetCopyAuthText.doc.md +35 -0
- package/docs_for_llm/useGetUserPermission.doc.md +43 -0
- package/docs_for_llm/useGroup.doc.md +48 -0
- package/docs_for_llm/useIdEntities.doc.md +48 -0
- package/docs_for_llm/useIdEntity.doc.md +103 -0
- package/docs_for_llm/useInterval.doc.md +43 -0
- package/docs_for_llm/useLayoutStandardList.doc.md +38 -0
- package/docs_for_llm/useMessage.doc.md +46 -0
- package/docs_for_llm/useModifyCache.doc.md +37 -0
- package/docs_for_llm/useOpenDialog.doc.md +41 -0
- package/docs_for_llm/usePagination.doc.md +60 -0
- package/docs_for_llm/usePersist.doc.md +54 -0
- package/docs_for_llm/usePoll.doc.md +41 -0
- package/docs_for_llm/useRoutePlus.doc.md +34 -0
- package/docs_for_llm/useRouterPlus.doc.md +34 -0
- package/docs_for_llm/useSearch.doc.md +68 -0
- package/docs_for_llm/useShell.doc.md +43 -0
- package/docs_for_llm/useSkip.doc.md +41 -0
- package/docs_for_llm/useStorageIdEntity.doc.md +46 -0
- package/docs_for_llm/useStore.doc.md +34 -0
- package/docs_for_llm/useTable.doc.md +57 -0
- package/docs_for_llm/useTableGroup.doc.md +47 -0
- package/docs_for_llm/useTableSort.doc.md +40 -0
- package/docs_for_llm/useToState.doc.md +112 -0
- package/docs_for_llm/useUser.doc.md +38 -0
- package/docs_for_llm/useValidForm.doc.md +41 -0
- package/docs_for_llm/vdialog.doc.md +129 -0
- package/docs_for_llm/vdrawer.doc.md +119 -0
- package/docs_for_llm/virtuallist.doc.md +6 -3
- package/hooks/useCRUD.json +61 -0
- package/hooks/useCountdown.json +49 -0
- package/hooks/useDetail.json +67 -0
- package/hooks/useDialog.json +49 -0
- package/hooks/useEntity.json +61 -0
- package/hooks/useEventListener.json +61 -0
- package/hooks/useFalseUntilTruthy.json +43 -0
- package/hooks/useGetCopyAuthText.json +36 -0
- package/hooks/useGetUserPermission.json +55 -0
- package/hooks/useGroup.json +49 -0
- package/hooks/useIdEntities.json +61 -0
- package/hooks/useInterval.json +55 -0
- package/hooks/useLayoutStandardList.json +36 -0
- package/hooks/useMessage.json +73 -0
- package/hooks/useModifyCache.json +36 -0
- package/hooks/useOpenDialog.json +43 -0
- package/hooks/usePagination.json +49 -0
- package/hooks/usePersist.json +61 -0
- package/hooks/usePoll.json +43 -0
- package/hooks/useRoutePlus.json +36 -0
- package/hooks/useRouterPlus.json +36 -0
- package/hooks/useSearch.json +56 -0
- package/hooks/useShell.json +49 -0
- package/hooks/useSkip.json +43 -0
- package/hooks/useStorageIdEntity.json +67 -0
- package/hooks/useStore.json +36 -0
- package/hooks/useTable.json +49 -0
- package/hooks/useTableGroup.json +43 -0
- package/hooks/useTableSort.json +43 -0
- package/hooks/useUser.json +36 -0
- package/hooks/useValidForm.json +43 -0
- package/package.json +12 -6
- package/dist/chunk-HDV7ETXE.mjs +0 -1055
- package/dist/chunk-HPAUCD5I.js +0 -156
- package/dist/chunk-L4DS3EXI.mjs +0 -133
- package/dist/chunk-YWY3D4J7.js +0 -1082
package/dist/chunk-HPAUCD5I.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var sucrase = require('sucrase');
|
|
4
|
-
var ts = require('typescript');
|
|
5
|
-
|
|
6
|
-
function _interopNamespace(e) {
|
|
7
|
-
if (e && e.__esModule) return e;
|
|
8
|
-
var n = Object.create(null);
|
|
9
|
-
if (e) {
|
|
10
|
-
Object.keys(e).forEach(function (k) {
|
|
11
|
-
if (k !== 'default') {
|
|
12
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return e[k]; }
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
n.default = e;
|
|
21
|
-
return Object.freeze(n);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
var ts__namespace = /*#__PURE__*/_interopNamespace(ts);
|
|
25
|
-
|
|
26
|
-
// src/tools/sfcCompiler.ts
|
|
27
|
-
var ALLOWED_IMPORT_SOURCES = [
|
|
28
|
-
"vue",
|
|
29
|
-
"@vue/",
|
|
30
|
-
"@king-design/vue",
|
|
31
|
-
"@ksyun-internal/versatile"
|
|
32
|
-
];
|
|
33
|
-
function scopeStyles(css, scopeClass) {
|
|
34
|
-
return css.replace(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g, (match, selector, suffix) => {
|
|
35
|
-
if (selector.trim().startsWith("@")) return match;
|
|
36
|
-
const scopedSelector = selector.split(",").map((s) => {
|
|
37
|
-
s = s.trim();
|
|
38
|
-
if (s === "body" || s === "html") return `.${scopeClass}`;
|
|
39
|
-
return `.${scopeClass} ${s}`;
|
|
40
|
-
}).join(", ");
|
|
41
|
-
return `${scopedSelector}${suffix}`;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function transformLocalImportToMock(importClause, source) {
|
|
45
|
-
const namespaceMatch = importClause.match(/^\*\s+as\s+(\w+)$/);
|
|
46
|
-
if (namespaceMatch) {
|
|
47
|
-
return `const ${namespaceMatch[1]} = __mockModule('${source}');`;
|
|
48
|
-
}
|
|
49
|
-
const namedMatch = importClause.match(/^\{([^}]+)\}$/);
|
|
50
|
-
if (namedMatch) {
|
|
51
|
-
return `const { ${namedMatch[1]} } = __mockModule('${source}');`;
|
|
52
|
-
}
|
|
53
|
-
const defaultMatch = importClause.match(/^(\w+)/);
|
|
54
|
-
if (defaultMatch) {
|
|
55
|
-
const defaultName = defaultMatch[1];
|
|
56
|
-
const mixedMatch = importClause.match(/^(\w+)\s*,\s*\{([^}]+)\}$/);
|
|
57
|
-
if (mixedMatch) {
|
|
58
|
-
const namedImports = mixedMatch[2];
|
|
59
|
-
return `const _mock_${defaultName} = __mockModule('${source}'); const ${defaultName} = _mock_${defaultName}.default || _mock_${defaultName}; const { ${namedImports} } = _mock_${defaultName};`;
|
|
60
|
-
}
|
|
61
|
-
return `const ${defaultName} = __mockModule('${source}').default || __mockModule('${source}');`;
|
|
62
|
-
}
|
|
63
|
-
return "";
|
|
64
|
-
}
|
|
65
|
-
function compileSFC(code, scopeId, options) {
|
|
66
|
-
const whitelist = options?.allowedImports ?? ALLOWED_IMPORT_SOURCES;
|
|
67
|
-
const strippedImports = [];
|
|
68
|
-
try {
|
|
69
|
-
const templateMatch = code.match(/<template>([\s\S]*)<\/template>/);
|
|
70
|
-
const scriptMatch = code.match(/<script[\s\S]*?>([\s\S]*)<\/script>/);
|
|
71
|
-
const styleMatch = code.match(/<style[\s\S]*?>([\s\S]*)<\/style>/);
|
|
72
|
-
const template = templateMatch && templateMatch[1] || "";
|
|
73
|
-
const script = scriptMatch && scriptMatch[1] || "";
|
|
74
|
-
const styleRaw = styleMatch && styleMatch[1] || "";
|
|
75
|
-
const style = styleRaw ? scopeStyles(styleRaw, scopeId) : "";
|
|
76
|
-
if (!template && !script) {
|
|
77
|
-
return { template: "", script: "", style: "", bindings: [] };
|
|
78
|
-
}
|
|
79
|
-
let cleanScript = script;
|
|
80
|
-
cleanScript = cleanScript.replace(/import\s+type\s+[\s\S]*?from\s+['"].*?['"];?/g, "");
|
|
81
|
-
cleanScript = cleanScript.replace(
|
|
82
|
-
/import\s+([^;]+?)\s+from\s+['"]([^'"]+)['"];?/g,
|
|
83
|
-
(match, importClause, source) => {
|
|
84
|
-
const isWhitelisted = whitelist.some(
|
|
85
|
-
(w) => source === w || source.startsWith(w + "/")
|
|
86
|
-
);
|
|
87
|
-
if (isWhitelisted) {
|
|
88
|
-
strippedImports.push({ source, reason: "whitelisted" });
|
|
89
|
-
return "";
|
|
90
|
-
}
|
|
91
|
-
if (source.startsWith(".")) {
|
|
92
|
-
strippedImports.push({ source, reason: "relative" });
|
|
93
|
-
return transformLocalImportToMock(importClause.trim(), source);
|
|
94
|
-
}
|
|
95
|
-
strippedImports.push({ source, reason: "unknown" });
|
|
96
|
-
return "";
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
const result = sucrase.transform(cleanScript, {
|
|
100
|
-
transforms: ["typescript"],
|
|
101
|
-
disableESTransforms: true
|
|
102
|
-
});
|
|
103
|
-
if (result && typeof result.code === "string") {
|
|
104
|
-
cleanScript = result.code;
|
|
105
|
-
}
|
|
106
|
-
const varNames = /* @__PURE__ */ new Set();
|
|
107
|
-
try {
|
|
108
|
-
let extractNames2 = function(name) {
|
|
109
|
-
if (ts__namespace.isIdentifier(name)) {
|
|
110
|
-
varNames.add(name.text);
|
|
111
|
-
} else if (ts__namespace.isObjectBindingPattern(name) || ts__namespace.isArrayBindingPattern(name)) {
|
|
112
|
-
name.elements.forEach((element) => {
|
|
113
|
-
if (ts__namespace.isBindingElement(element)) {
|
|
114
|
-
extractNames2(element.name);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}, visit2 = function(node) {
|
|
119
|
-
if (ts__namespace.isVariableStatement(node)) {
|
|
120
|
-
node.declarationList.declarations.forEach((decl) => extractNames2(decl.name));
|
|
121
|
-
} else if (ts__namespace.isFunctionDeclaration(node) && node.name) {
|
|
122
|
-
varNames.add(node.name.text);
|
|
123
|
-
} else if (ts__namespace.isClassDeclaration(node) && node.name) {
|
|
124
|
-
varNames.add(node.name.text);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
var extractNames = extractNames2, visit = visit2;
|
|
128
|
-
const sourceFile = ts__namespace.createSourceFile(
|
|
129
|
-
"temp.ts",
|
|
130
|
-
cleanScript,
|
|
131
|
-
ts__namespace.ScriptTarget.Latest,
|
|
132
|
-
true
|
|
133
|
-
);
|
|
134
|
-
sourceFile.statements.forEach(visit2);
|
|
135
|
-
} catch (e) {
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
template,
|
|
139
|
-
script: cleanScript,
|
|
140
|
-
style,
|
|
141
|
-
bindings: [...varNames],
|
|
142
|
-
strippedImports: strippedImports.length > 0 ? strippedImports : void 0
|
|
143
|
-
};
|
|
144
|
-
} catch (e) {
|
|
145
|
-
return {
|
|
146
|
-
template: "",
|
|
147
|
-
script: "",
|
|
148
|
-
style: "",
|
|
149
|
-
bindings: [],
|
|
150
|
-
error: e.message
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
exports.compileSFC = compileSFC;
|
|
156
|
-
exports.scopeStyles = scopeStyles;
|
package/dist/chunk-L4DS3EXI.mjs
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { transform } from 'sucrase';
|
|
2
|
-
import * as ts from 'typescript';
|
|
3
|
-
|
|
4
|
-
// src/tools/sfcCompiler.ts
|
|
5
|
-
var ALLOWED_IMPORT_SOURCES = [
|
|
6
|
-
"vue",
|
|
7
|
-
"@vue/",
|
|
8
|
-
"@king-design/vue",
|
|
9
|
-
"@ksyun-internal/versatile"
|
|
10
|
-
];
|
|
11
|
-
function scopeStyles(css, scopeClass) {
|
|
12
|
-
return css.replace(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g, (match, selector, suffix) => {
|
|
13
|
-
if (selector.trim().startsWith("@")) return match;
|
|
14
|
-
const scopedSelector = selector.split(",").map((s) => {
|
|
15
|
-
s = s.trim();
|
|
16
|
-
if (s === "body" || s === "html") return `.${scopeClass}`;
|
|
17
|
-
return `.${scopeClass} ${s}`;
|
|
18
|
-
}).join(", ");
|
|
19
|
-
return `${scopedSelector}${suffix}`;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function transformLocalImportToMock(importClause, source) {
|
|
23
|
-
const namespaceMatch = importClause.match(/^\*\s+as\s+(\w+)$/);
|
|
24
|
-
if (namespaceMatch) {
|
|
25
|
-
return `const ${namespaceMatch[1]} = __mockModule('${source}');`;
|
|
26
|
-
}
|
|
27
|
-
const namedMatch = importClause.match(/^\{([^}]+)\}$/);
|
|
28
|
-
if (namedMatch) {
|
|
29
|
-
return `const { ${namedMatch[1]} } = __mockModule('${source}');`;
|
|
30
|
-
}
|
|
31
|
-
const defaultMatch = importClause.match(/^(\w+)/);
|
|
32
|
-
if (defaultMatch) {
|
|
33
|
-
const defaultName = defaultMatch[1];
|
|
34
|
-
const mixedMatch = importClause.match(/^(\w+)\s*,\s*\{([^}]+)\}$/);
|
|
35
|
-
if (mixedMatch) {
|
|
36
|
-
const namedImports = mixedMatch[2];
|
|
37
|
-
return `const _mock_${defaultName} = __mockModule('${source}'); const ${defaultName} = _mock_${defaultName}.default || _mock_${defaultName}; const { ${namedImports} } = _mock_${defaultName};`;
|
|
38
|
-
}
|
|
39
|
-
return `const ${defaultName} = __mockModule('${source}').default || __mockModule('${source}');`;
|
|
40
|
-
}
|
|
41
|
-
return "";
|
|
42
|
-
}
|
|
43
|
-
function compileSFC(code, scopeId, options) {
|
|
44
|
-
const whitelist = options?.allowedImports ?? ALLOWED_IMPORT_SOURCES;
|
|
45
|
-
const strippedImports = [];
|
|
46
|
-
try {
|
|
47
|
-
const templateMatch = code.match(/<template>([\s\S]*)<\/template>/);
|
|
48
|
-
const scriptMatch = code.match(/<script[\s\S]*?>([\s\S]*)<\/script>/);
|
|
49
|
-
const styleMatch = code.match(/<style[\s\S]*?>([\s\S]*)<\/style>/);
|
|
50
|
-
const template = templateMatch && templateMatch[1] || "";
|
|
51
|
-
const script = scriptMatch && scriptMatch[1] || "";
|
|
52
|
-
const styleRaw = styleMatch && styleMatch[1] || "";
|
|
53
|
-
const style = styleRaw ? scopeStyles(styleRaw, scopeId) : "";
|
|
54
|
-
if (!template && !script) {
|
|
55
|
-
return { template: "", script: "", style: "", bindings: [] };
|
|
56
|
-
}
|
|
57
|
-
let cleanScript = script;
|
|
58
|
-
cleanScript = cleanScript.replace(/import\s+type\s+[\s\S]*?from\s+['"].*?['"];?/g, "");
|
|
59
|
-
cleanScript = cleanScript.replace(
|
|
60
|
-
/import\s+([^;]+?)\s+from\s+['"]([^'"]+)['"];?/g,
|
|
61
|
-
(match, importClause, source) => {
|
|
62
|
-
const isWhitelisted = whitelist.some(
|
|
63
|
-
(w) => source === w || source.startsWith(w + "/")
|
|
64
|
-
);
|
|
65
|
-
if (isWhitelisted) {
|
|
66
|
-
strippedImports.push({ source, reason: "whitelisted" });
|
|
67
|
-
return "";
|
|
68
|
-
}
|
|
69
|
-
if (source.startsWith(".")) {
|
|
70
|
-
strippedImports.push({ source, reason: "relative" });
|
|
71
|
-
return transformLocalImportToMock(importClause.trim(), source);
|
|
72
|
-
}
|
|
73
|
-
strippedImports.push({ source, reason: "unknown" });
|
|
74
|
-
return "";
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
const result = transform(cleanScript, {
|
|
78
|
-
transforms: ["typescript"],
|
|
79
|
-
disableESTransforms: true
|
|
80
|
-
});
|
|
81
|
-
if (result && typeof result.code === "string") {
|
|
82
|
-
cleanScript = result.code;
|
|
83
|
-
}
|
|
84
|
-
const varNames = /* @__PURE__ */ new Set();
|
|
85
|
-
try {
|
|
86
|
-
let extractNames2 = function(name) {
|
|
87
|
-
if (ts.isIdentifier(name)) {
|
|
88
|
-
varNames.add(name.text);
|
|
89
|
-
} else if (ts.isObjectBindingPattern(name) || ts.isArrayBindingPattern(name)) {
|
|
90
|
-
name.elements.forEach((element) => {
|
|
91
|
-
if (ts.isBindingElement(element)) {
|
|
92
|
-
extractNames2(element.name);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}, visit2 = function(node) {
|
|
97
|
-
if (ts.isVariableStatement(node)) {
|
|
98
|
-
node.declarationList.declarations.forEach((decl) => extractNames2(decl.name));
|
|
99
|
-
} else if (ts.isFunctionDeclaration(node) && node.name) {
|
|
100
|
-
varNames.add(node.name.text);
|
|
101
|
-
} else if (ts.isClassDeclaration(node) && node.name) {
|
|
102
|
-
varNames.add(node.name.text);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
var extractNames = extractNames2, visit = visit2;
|
|
106
|
-
const sourceFile = ts.createSourceFile(
|
|
107
|
-
"temp.ts",
|
|
108
|
-
cleanScript,
|
|
109
|
-
ts.ScriptTarget.Latest,
|
|
110
|
-
true
|
|
111
|
-
);
|
|
112
|
-
sourceFile.statements.forEach(visit2);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
template,
|
|
117
|
-
script: cleanScript,
|
|
118
|
-
style,
|
|
119
|
-
bindings: [...varNames],
|
|
120
|
-
strippedImports: strippedImports.length > 0 ? strippedImports : void 0
|
|
121
|
-
};
|
|
122
|
-
} catch (e) {
|
|
123
|
-
return {
|
|
124
|
-
template: "",
|
|
125
|
-
script: "",
|
|
126
|
-
style: "",
|
|
127
|
-
bindings: [],
|
|
128
|
-
error: e.message
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export { compileSFC, scopeStyles };
|