king-design-analyzer 2.1.9 → 2.2.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/components/actions.json +109 -0
- package/components/advancedset.json +128 -0
- package/components/affix.json +8 -0
- package/components/aksk.json +172 -0
- package/components/anchor.json +220 -0
- package/components/anchorlink.json +111 -0
- package/components/az.json +15 -2
- package/components/badge.json +8 -0
- package/components/billtypes.json +14 -2
- package/components/breadcrumb.json +9 -1
- package/components/button.json +192 -0
- package/components/buttonlink.json +74 -0
- package/components/card.json +14 -4
- package/components/cardcol.json +142 -0
- package/components/cardcols.json +121 -0
- package/components/cardcontent.json +20 -3
- package/components/cardtabs.json +172 -0
- package/components/carousel.json +7 -0
- package/components/cascader.json +576 -368
- package/components/checkbox.json +51 -4
- package/components/cidrinput.json +140 -0
- package/components/code.json +8 -1
- package/components/collapse.json +335 -341
- package/components/colorpicker.json +217 -0
- package/components/configprovider.json +96 -0
- package/components/copy.json +7 -0
- package/components/copyhover.json +111 -0
- package/components/copyrow.json +125 -0
- package/components/datepicker.json +656 -524
- package/components/description.json +98 -0
- package/components/descriptions.json +10 -3
- package/components/diagram.json +295 -0
- package/components/dialog.json +526 -455
- package/components/divider.json +9 -1
- package/components/drawer.json +603 -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 +152 -0
- package/components/form.json +143 -3
- 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 +165 -0
- package/components/icon.json +13 -1
- package/components/icontooltip.json +19 -1
- package/components/input.json +196 -8
- 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 +24 -3
- package/components/layoutlistcontent.json +157 -0
- package/components/layoutpermissioncontent.json +156 -0
- package/components/layoutstandardlist.json +276 -0
- package/components/layouttabs.json +168 -0
- package/components/lazymount.json +87 -0
- package/components/lazyteleport.json +119 -0
- package/components/menu.json +11 -3
- package/components/notification.json +351 -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 +99 -8
- package/components/queuevisualrange.json +110 -0
- package/components/radio.json +82 -2
- package/components/rate.json +200 -0
- package/components/region.json +14 -2
- package/components/scrollselect.json +140 -0
- 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 +749 -666
- package/components/sidebar.json +198 -0
- package/components/skeleton.json +234 -0
- package/components/slider.json +12 -2
- package/components/spin.json +10 -2
- package/components/spinner.json +419 -429
- package/components/split.json +263 -0
- package/components/sshkeys.json +138 -0
- package/components/status.json +60 -3
- package/components/steps.json +7 -0
- package/components/switch.json +12 -3
- package/components/table.json +24 -2
- package/components/tablecolumnid.json +14 -2
- package/components/tabs.json +14 -2
- package/components/tag.json +8 -5
- package/components/timeline.json +215 -0
- package/components/timepicker.json +147 -3
- package/components/timerange.json +262 -0
- package/components/tip.json +27 -0
- package/components/tooltip.json +492 -395
- package/components/tour.json +418 -372
- package/components/transfer.json +79 -8
- package/components/tree.json +28 -5
- package/components/treeselect.json +612 -475
- package/components/upload.json +474 -473
- package/components/vdialog.json +309 -0
- package/components/vdrawer.json +335 -0
- package/components/virtuallist.json +7 -0
- package/dist/ast/index.d.mts +65 -2
- package/dist/ast/index.d.ts +65 -2
- package/dist/ast/index.js +4 -3
- package/dist/ast/index.mjs +2 -1
- package/dist/chunk-4OTQAQ6J.mjs +341 -0
- package/dist/{chunk-F26GUCGG.js → chunk-4WXOYU2N.js} +32 -9
- package/dist/chunk-6HOIRUQB.mjs +409 -0
- package/dist/chunk-DHLWNT53.js +364 -0
- package/dist/{chunk-H2ET6MMM.mjs → chunk-IPJJMPOO.mjs} +155 -66
- package/dist/{chunk-WYSRJVX4.js → chunk-JJ6AB4ZH.js} +2 -2
- package/dist/{chunk-2W6OCG2S.js → chunk-JNRGUR3O.js} +155 -67
- package/dist/chunk-KF5YBEM5.js +143 -0
- package/dist/{chunk-OJOHB64C.mjs → chunk-LRTDTFFQ.mjs} +28 -5
- package/dist/{chunk-DSWKLUIX.mjs → chunk-NZL6T22V.mjs} +1 -1
- package/dist/chunk-QC6VTSA3.mjs +117 -0
- package/dist/chunk-V5N65MRP.js +411 -0
- package/dist/full/index.d.mts +2 -0
- package/dist/full/index.d.ts +2 -0
- package/dist/full/index.js +7 -6
- package/dist/full/index.mjs +5 -4
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +14 -13
- package/dist/index.mjs +6 -5
- package/dist/metadata/index.d.mts +38 -3
- package/dist/metadata/index.d.ts +38 -3
- package/dist/metadata/index.js +26 -16
- package/dist/metadata/index.mjs +26 -15
- package/dist/resolve-BsLBxlBi.d.mts +24 -0
- package/dist/resolve-BsLBxlBi.d.ts +24 -0
- package/dist/runtime/index.d.mts +2 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +4 -4
- package/dist/runtime/index.mjs +2 -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 +5 -5
- package/dist/static/index.mjs +2 -2
- package/docs_for_llm/actions.doc.md +87 -0
- package/docs_for_llm/advancedset.doc.md +98 -0
- package/docs_for_llm/affix.doc.md +20 -7
- package/docs_for_llm/aksk.doc.md +111 -0
- package/docs_for_llm/anchor.doc.md +155 -0
- package/docs_for_llm/anchorlink.doc.md +75 -0
- package/docs_for_llm/az.doc.md +17 -11
- package/docs_for_llm/badge.doc.md +11 -5
- package/docs_for_llm/billtypes.doc.md +17 -11
- package/docs_for_llm/breadcrumb.doc.md +80 -4
- package/docs_for_llm/button.doc.md +91 -18
- package/docs_for_llm/buttonlink.doc.md +64 -0
- package/docs_for_llm/card.doc.md +58 -8
- 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 +31 -10
- package/docs_for_llm/cardtabs.doc.md +106 -0
- package/docs_for_llm/carousel.doc.md +79 -7
- package/docs_for_llm/cascader.doc.md +106 -23
- 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 +147 -14
- package/docs_for_llm/colorpicker.doc.md +104 -0
- package/docs_for_llm/configprovider.doc.md +77 -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 +80 -0
- package/docs_for_llm/datepicker.doc.md +66 -35
- package/docs_for_llm/description.doc.md +75 -0
- package/docs_for_llm/descriptions.doc.md +122 -10
- package/docs_for_llm/diagram.doc.md +343 -0
- package/docs_for_llm/dialog.doc.md +97 -77
- package/docs_for_llm/divider.doc.md +14 -7
- package/docs_for_llm/drawer.doc.md +114 -69
- package/docs_for_llm/dropdown.doc.md +290 -22
- 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 +83 -0
- package/docs_for_llm/form.doc.md +196 -18
- 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 +78 -5
- package/docs_for_llm/header.doc.md +114 -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 +199 -41
- 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 +54 -17
- package/docs_for_llm/layoutlistcontent.doc.md +168 -0
- package/docs_for_llm/layoutpermissioncontent.doc.md +93 -0
- package/docs_for_llm/layoutstandardlist.doc.md +129 -0
- package/docs_for_llm/layouttabs.doc.md +101 -0
- package/docs_for_llm/lazymount.doc.md +82 -0
- package/docs_for_llm/lazyteleport.doc.md +85 -0
- package/docs_for_llm/menu.doc.md +139 -14
- package/docs_for_llm/message.doc.md +93 -10
- package/docs_for_llm/notification.doc.md +214 -0
- 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 +98 -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 +127 -0
- package/docs_for_llm/region.doc.md +25 -13
- package/docs_for_llm/scrollselect.doc.md +90 -0
- 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 +208 -49
- package/docs_for_llm/sidebar.doc.md +133 -0
- package/docs_for_llm/skeleton.doc.md +152 -0
- package/docs_for_llm/slider.doc.md +42 -22
- package/docs_for_llm/spin.doc.md +18 -6
- package/docs_for_llm/spinner.doc.md +28 -18
- package/docs_for_llm/split.doc.md +170 -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 +81 -7
- package/docs_for_llm/switch.doc.md +32 -16
- package/docs_for_llm/table.doc.md +317 -55
- package/docs_for_llm/tablecolumnid.doc.md +36 -16
- package/docs_for_llm/tabs.doc.md +117 -12
- package/docs_for_llm/tag.doc.md +167 -15
- package/docs_for_llm/timeline.doc.md +187 -0
- package/docs_for_llm/timepicker.doc.md +74 -36
- package/docs_for_llm/timerange.doc.md +157 -0
- package/docs_for_llm/tip.doc.md +50 -11
- package/docs_for_llm/tooltip.doc.md +99 -27
- package/docs_for_llm/tour.doc.md +125 -28
- package/docs_for_llm/transfer.doc.md +99 -33
- package/docs_for_llm/tree.doc.md +129 -24
- package/docs_for_llm/treeselect.doc.md +101 -44
- package/docs_for_llm/upload.doc.md +63 -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 +154 -0
- package/docs_for_llm/vdrawer.doc.md +148 -0
- package/docs_for_llm/virtuallist.doc.md +157 -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 +14 -8
- package/dist/chunk-D3Y6FGWA.js +0 -153
- package/dist/chunk-HPAUCD5I.js +0 -156
- package/dist/chunk-L4DS3EXI.mjs +0 -133
- package/dist/chunk-NZ6TLWMD.mjs +0 -151
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import { compileSFC } from './chunk-4OTQAQ6J.mjs';
|
|
2
|
+
|
|
3
|
+
// src/runtime/index.ts
|
|
4
|
+
var scopeIdCounter = 0;
|
|
5
|
+
var ENVIRONMENT_SENSITIVE_IDENTIFIERS = [
|
|
6
|
+
"window",
|
|
7
|
+
"document",
|
|
8
|
+
"location",
|
|
9
|
+
"navigator"
|
|
10
|
+
];
|
|
11
|
+
var ENVIRONMENT_SENSITIVE_CALLS = [
|
|
12
|
+
"getCurrentInstance",
|
|
13
|
+
"useRouter",
|
|
14
|
+
"useRoute",
|
|
15
|
+
"onBeforeRouteLeave",
|
|
16
|
+
"onBeforeRouteUpdate"
|
|
17
|
+
];
|
|
18
|
+
function createMockProxy(path) {
|
|
19
|
+
const target = function mockTarget() {
|
|
20
|
+
};
|
|
21
|
+
return new Proxy(target, {
|
|
22
|
+
get: (_target, prop, receiver) => {
|
|
23
|
+
const existing = Reflect.get(target, prop, receiver);
|
|
24
|
+
if (existing !== void 0) return existing;
|
|
25
|
+
if (prop === Symbol.toPrimitive) return () => 0;
|
|
26
|
+
if (prop === "then") return void 0;
|
|
27
|
+
if (prop === "toString") return () => `[MockProxy ${path}]`;
|
|
28
|
+
if (prop === "valueOf") return () => 0;
|
|
29
|
+
if (prop === "__path") return path;
|
|
30
|
+
return createMockProxy(`${path}.${String(prop)}`);
|
|
31
|
+
},
|
|
32
|
+
apply: () => createMockProxy(`${path}()`),
|
|
33
|
+
construct: () => createMockProxy(`new ${path}()`),
|
|
34
|
+
has: (_target, prop) => Reflect.has(target, prop),
|
|
35
|
+
set: (_target, prop, value, receiver) => Reflect.set(target, prop, value, receiver)
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function createWhitelistedModule(source, context) {
|
|
39
|
+
if (source === "vue" || source.startsWith("@vue/")) {
|
|
40
|
+
return context;
|
|
41
|
+
}
|
|
42
|
+
if (source === "vue-router") {
|
|
43
|
+
return context.__mockVueRouter;
|
|
44
|
+
}
|
|
45
|
+
return new Proxy({}, {
|
|
46
|
+
get: (_target, prop) => {
|
|
47
|
+
if (prop === "default") return createMockProxy(source);
|
|
48
|
+
if (typeof prop === "string" && prop in context) {
|
|
49
|
+
return context[prop];
|
|
50
|
+
}
|
|
51
|
+
return createMockProxy(`${source}.${String(prop)}`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function createMockElement(path) {
|
|
56
|
+
const element = createMockProxy(path);
|
|
57
|
+
element.style = {};
|
|
58
|
+
element.classList = {
|
|
59
|
+
add: () => {
|
|
60
|
+
},
|
|
61
|
+
remove: () => {
|
|
62
|
+
},
|
|
63
|
+
contains: () => false
|
|
64
|
+
};
|
|
65
|
+
element.dataset = {};
|
|
66
|
+
element.getBoundingClientRect = () => ({
|
|
67
|
+
x: 0,
|
|
68
|
+
y: 0,
|
|
69
|
+
top: 0,
|
|
70
|
+
left: 0,
|
|
71
|
+
right: 0,
|
|
72
|
+
bottom: 0,
|
|
73
|
+
width: 0,
|
|
74
|
+
height: 0
|
|
75
|
+
});
|
|
76
|
+
return element;
|
|
77
|
+
}
|
|
78
|
+
var MOCK_LOCATION = {
|
|
79
|
+
href: "https://mock.local/",
|
|
80
|
+
pathname: "/",
|
|
81
|
+
search: "",
|
|
82
|
+
hash: "",
|
|
83
|
+
origin: "https://mock.local",
|
|
84
|
+
host: "mock.local",
|
|
85
|
+
hostname: "mock.local",
|
|
86
|
+
port: "",
|
|
87
|
+
protocol: "https:",
|
|
88
|
+
assign: () => {
|
|
89
|
+
},
|
|
90
|
+
replace: () => {
|
|
91
|
+
},
|
|
92
|
+
reload: () => {
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var MOCK_NAVIGATOR = {
|
|
96
|
+
userAgent: "king-design-analyzer-runtime-mock",
|
|
97
|
+
language: "zh-CN",
|
|
98
|
+
languages: ["zh-CN"],
|
|
99
|
+
clipboard: {
|
|
100
|
+
writeText: async () => {
|
|
101
|
+
},
|
|
102
|
+
readText: async () => ""
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var MOCK_DOCUMENT = {
|
|
106
|
+
body: createMockElement("document.body"),
|
|
107
|
+
head: createMockElement("document.head"),
|
|
108
|
+
documentElement: createMockElement("document.documentElement"),
|
|
109
|
+
createElement: (_tag) => createMockElement("document.createElement()"),
|
|
110
|
+
createTextNode: (_text) => createMockElement("document.createTextNode()"),
|
|
111
|
+
getElementById: (_id) => createMockElement("document.getElementById()"),
|
|
112
|
+
querySelector: (_selector) => createMockElement("document.querySelector()"),
|
|
113
|
+
querySelectorAll: () => [],
|
|
114
|
+
addEventListener: () => {
|
|
115
|
+
},
|
|
116
|
+
removeEventListener: () => {
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var MOCK_WINDOW = {
|
|
120
|
+
document: MOCK_DOCUMENT,
|
|
121
|
+
navigator: MOCK_NAVIGATOR,
|
|
122
|
+
location: MOCK_LOCATION,
|
|
123
|
+
innerWidth: 1440,
|
|
124
|
+
innerHeight: 900,
|
|
125
|
+
addEventListener: () => {
|
|
126
|
+
},
|
|
127
|
+
removeEventListener: () => {
|
|
128
|
+
},
|
|
129
|
+
matchMedia: () => ({
|
|
130
|
+
matches: false,
|
|
131
|
+
media: "",
|
|
132
|
+
onchange: null,
|
|
133
|
+
addListener: () => {
|
|
134
|
+
},
|
|
135
|
+
removeListener: () => {
|
|
136
|
+
},
|
|
137
|
+
addEventListener: () => {
|
|
138
|
+
},
|
|
139
|
+
removeEventListener: () => {
|
|
140
|
+
},
|
|
141
|
+
dispatchEvent: () => false
|
|
142
|
+
}),
|
|
143
|
+
requestAnimationFrame: (cb) => {
|
|
144
|
+
cb(0);
|
|
145
|
+
return 0;
|
|
146
|
+
},
|
|
147
|
+
cancelAnimationFrame: () => {
|
|
148
|
+
},
|
|
149
|
+
setTimeout,
|
|
150
|
+
clearTimeout,
|
|
151
|
+
setInterval,
|
|
152
|
+
clearInterval,
|
|
153
|
+
open: () => createMockProxy("window.open()")
|
|
154
|
+
};
|
|
155
|
+
var MOCK_ROUTE = {
|
|
156
|
+
path: "/",
|
|
157
|
+
name: void 0,
|
|
158
|
+
fullPath: "/",
|
|
159
|
+
params: {},
|
|
160
|
+
query: {},
|
|
161
|
+
hash: "",
|
|
162
|
+
meta: {},
|
|
163
|
+
matched: []
|
|
164
|
+
};
|
|
165
|
+
var MOCK_ROUTER = {
|
|
166
|
+
currentRoute: { value: MOCK_ROUTE },
|
|
167
|
+
push: async () => void 0,
|
|
168
|
+
replace: async () => void 0,
|
|
169
|
+
back: () => {
|
|
170
|
+
},
|
|
171
|
+
go: () => {
|
|
172
|
+
},
|
|
173
|
+
forward: () => {
|
|
174
|
+
},
|
|
175
|
+
beforeEach: () => () => {
|
|
176
|
+
},
|
|
177
|
+
afterEach: () => () => {
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
function detectEnvironmentSensitivity(code, strippedImports = []) {
|
|
181
|
+
const warnings = [];
|
|
182
|
+
let status = "passed";
|
|
183
|
+
for (const identifier of ENVIRONMENT_SENSITIVE_IDENTIFIERS) {
|
|
184
|
+
if (new RegExp(`\\b${identifier}\\b`).test(code)) {
|
|
185
|
+
warnings.push(`\u68C0\u6D4B\u5230\u6D4F\u89C8\u5668\u73AF\u5883\u5BF9\u8C61 ${identifier}\uFF0C\u8FD0\u884C\u65F6\u7ED3\u679C\u4F9D\u8D56\u5BBF\u4E3B\u73AF\u5883 mock\u3002`);
|
|
186
|
+
status = "env_dependent";
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (const callee of ENVIRONMENT_SENSITIVE_CALLS) {
|
|
190
|
+
if (new RegExp(`\\b${callee}\\s*\\(`).test(code)) {
|
|
191
|
+
warnings.push(`\u68C0\u6D4B\u5230\u73AF\u5883\u654F\u611F\u8C03\u7528 ${callee}()\uFF0C\u8FD0\u884C\u65F6\u7ED3\u679C\u4F9D\u8D56 mock\u3002`);
|
|
192
|
+
status = "env_dependent";
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const skippedImports = strippedImports.filter(
|
|
196
|
+
(item) => item.reason === "unknown" && !item.source.startsWith(".")
|
|
197
|
+
);
|
|
198
|
+
if (skippedImports.length > 0) {
|
|
199
|
+
status = "runtime_skipped";
|
|
200
|
+
warnings.push(
|
|
201
|
+
`\u68C0\u6D4B\u5230\u7B2C\u4E09\u65B9\u5BFC\u5165 ${skippedImports.map((item) => item.source).join(", ")}\uFF0C\u5DF2\u4F7F\u7528\u6A21\u5757 mock\uFF0C\u8FD0\u884C\u65F6\u7ED3\u679C\u4EC5\u4F9B\u53C2\u8003\u3002`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
return { status, warnings };
|
|
205
|
+
}
|
|
206
|
+
function isEnvironmentRelatedRuntimeError(message) {
|
|
207
|
+
return /(window|document|location|navigator|getCurrentInstance|useRouter|useRoute|route|router)/i.test(message);
|
|
208
|
+
}
|
|
209
|
+
var MOCK_VUE_CONTEXT = {
|
|
210
|
+
// Reactivity
|
|
211
|
+
ref: (v) => ({ value: v }),
|
|
212
|
+
reactive: (v) => v,
|
|
213
|
+
computed: (fn) => ({ value: typeof fn === "function" ? fn() : fn }),
|
|
214
|
+
readonly: (v) => v,
|
|
215
|
+
shallowRef: (v) => ({ value: v }),
|
|
216
|
+
shallowReactive: (v) => v,
|
|
217
|
+
toRef: () => ({ value: void 0 }),
|
|
218
|
+
toRefs: (obj) => Object.fromEntries(
|
|
219
|
+
Object.keys(obj || {}).map((k) => [k, { value: obj[k] }])
|
|
220
|
+
),
|
|
221
|
+
toRaw: (v) => v,
|
|
222
|
+
markRaw: (v) => v,
|
|
223
|
+
isRef: () => false,
|
|
224
|
+
isReactive: () => false,
|
|
225
|
+
isReadonly: () => false,
|
|
226
|
+
isProxy: () => false,
|
|
227
|
+
triggerRef: () => {
|
|
228
|
+
},
|
|
229
|
+
customRef: (factory) => factory(() => {
|
|
230
|
+
}, () => {
|
|
231
|
+
}),
|
|
232
|
+
// Lifecycle
|
|
233
|
+
onMounted: () => {
|
|
234
|
+
},
|
|
235
|
+
onUnmounted: () => {
|
|
236
|
+
},
|
|
237
|
+
onBeforeMount: () => {
|
|
238
|
+
},
|
|
239
|
+
onBeforeUnmount: () => {
|
|
240
|
+
},
|
|
241
|
+
onUpdated: () => {
|
|
242
|
+
},
|
|
243
|
+
onBeforeUpdate: () => {
|
|
244
|
+
},
|
|
245
|
+
onActivated: () => {
|
|
246
|
+
},
|
|
247
|
+
onDeactivated: () => {
|
|
248
|
+
},
|
|
249
|
+
onErrorCaptured: () => {
|
|
250
|
+
},
|
|
251
|
+
// Watchers
|
|
252
|
+
watch: () => () => {
|
|
253
|
+
},
|
|
254
|
+
watchEffect: () => () => {
|
|
255
|
+
},
|
|
256
|
+
watchPostEffect: () => () => {
|
|
257
|
+
},
|
|
258
|
+
watchSyncEffect: () => () => {
|
|
259
|
+
},
|
|
260
|
+
// Composition API
|
|
261
|
+
defineProps: () => ({}),
|
|
262
|
+
defineEmits: () => () => {
|
|
263
|
+
},
|
|
264
|
+
defineExpose: () => {
|
|
265
|
+
},
|
|
266
|
+
defineOptions: () => {
|
|
267
|
+
},
|
|
268
|
+
defineSlots: () => ({}),
|
|
269
|
+
defineModel: () => ({ value: void 0 }),
|
|
270
|
+
withDefaults: (_props, defaults) => defaults,
|
|
271
|
+
useSlots: () => ({}),
|
|
272
|
+
useAttrs: () => ({}),
|
|
273
|
+
// Dependency Injection
|
|
274
|
+
inject: () => void 0,
|
|
275
|
+
provide: () => {
|
|
276
|
+
},
|
|
277
|
+
// Utilities
|
|
278
|
+
nextTick: () => Promise.resolve(),
|
|
279
|
+
getCurrentInstance: () => ({
|
|
280
|
+
proxy: createMockProxy("instance.proxy"),
|
|
281
|
+
appContext: createMockProxy("instance.appContext"),
|
|
282
|
+
emit: () => {
|
|
283
|
+
},
|
|
284
|
+
attrs: {},
|
|
285
|
+
slots: {}
|
|
286
|
+
}),
|
|
287
|
+
h: () => ({}),
|
|
288
|
+
createVNode: () => ({}),
|
|
289
|
+
resolveComponent: () => ({}),
|
|
290
|
+
// Browser-ish globals
|
|
291
|
+
window: MOCK_WINDOW,
|
|
292
|
+
document: MOCK_DOCUMENT,
|
|
293
|
+
location: MOCK_LOCATION,
|
|
294
|
+
navigator: MOCK_NAVIGATOR,
|
|
295
|
+
self: MOCK_WINDOW,
|
|
296
|
+
globalThis: MOCK_WINDOW,
|
|
297
|
+
// vue-router
|
|
298
|
+
useRouter: () => MOCK_ROUTER,
|
|
299
|
+
useRoute: () => MOCK_ROUTE,
|
|
300
|
+
onBeforeRouteLeave: () => {
|
|
301
|
+
},
|
|
302
|
+
onBeforeRouteUpdate: () => {
|
|
303
|
+
},
|
|
304
|
+
RouterLink: createMockProxy("vue-router.RouterLink"),
|
|
305
|
+
RouterView: createMockProxy("vue-router.RouterView"),
|
|
306
|
+
__mockVueRouter: {
|
|
307
|
+
useRouter: () => MOCK_ROUTER,
|
|
308
|
+
useRoute: () => MOCK_ROUTE,
|
|
309
|
+
onBeforeRouteLeave: () => {
|
|
310
|
+
},
|
|
311
|
+
onBeforeRouteUpdate: () => {
|
|
312
|
+
},
|
|
313
|
+
RouterLink: createMockProxy("vue-router.RouterLink"),
|
|
314
|
+
RouterView: createMockProxy("vue-router.RouterView"),
|
|
315
|
+
createRouter: () => createMockProxy("vue-router.createRouter()"),
|
|
316
|
+
createWebHistory: () => createMockProxy("vue-router.createWebHistory()"),
|
|
317
|
+
createWebHashHistory: () => createMockProxy("vue-router.createWebHashHistory()")
|
|
318
|
+
},
|
|
319
|
+
// =========================================================================
|
|
320
|
+
// @ksyun-internal/versatile Hooks
|
|
321
|
+
// =========================================================================
|
|
322
|
+
useToState: (_props, _key, _emit, defaultValue) => ({ value: defaultValue ?? void 0 }),
|
|
323
|
+
useIdEntity: () => ({ value: void 0 }),
|
|
324
|
+
// =========================================================================
|
|
325
|
+
// Module Mocking
|
|
326
|
+
// =========================================================================
|
|
327
|
+
__mockModule: (modulePath) => createMockProxy(modulePath),
|
|
328
|
+
__getWhitelistedModule: (source) => createWhitelistedModule(source, MOCK_VUE_CONTEXT)
|
|
329
|
+
};
|
|
330
|
+
function validateRuntimePrecheck(code) {
|
|
331
|
+
const scopeId = `runtime-${Date.now()}-${++scopeIdCounter}`;
|
|
332
|
+
const { script, bindings, strippedImports, error } = compileSFC(code, scopeId);
|
|
333
|
+
if (error) {
|
|
334
|
+
return {
|
|
335
|
+
name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
|
|
336
|
+
passed: false,
|
|
337
|
+
status: "failed",
|
|
338
|
+
errors: [error]
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
const sensitivity = detectEnvironmentSensitivity(code, strippedImports);
|
|
342
|
+
try {
|
|
343
|
+
const funcBody = `
|
|
344
|
+
"use strict";
|
|
345
|
+
${script}
|
|
346
|
+
return { ${bindings.join(", ")} };
|
|
347
|
+
`;
|
|
348
|
+
const keys = Object.keys(MOCK_VUE_CONTEXT);
|
|
349
|
+
const values = Object.values(MOCK_VUE_CONTEXT);
|
|
350
|
+
const runner = new Function(...keys, funcBody);
|
|
351
|
+
const result = runner(...values);
|
|
352
|
+
const missingBindings = bindings.filter((binding) => !(binding in result));
|
|
353
|
+
if (missingBindings.length > 0) {
|
|
354
|
+
return {
|
|
355
|
+
name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
|
|
356
|
+
passed: false,
|
|
357
|
+
status: "failed",
|
|
358
|
+
errors: missingBindings.map((b) => `\u53D8\u91CF ${b} \u672A\u6B63\u786E\u5BFC\u51FA`),
|
|
359
|
+
warnings: sensitivity.warnings.length > 0 ? sensitivity.warnings : void 0
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
return {
|
|
363
|
+
name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
|
|
364
|
+
passed: true,
|
|
365
|
+
status: sensitivity.status,
|
|
366
|
+
errors: [],
|
|
367
|
+
warnings: sensitivity.warnings.length > 0 ? sensitivity.warnings : void 0
|
|
368
|
+
};
|
|
369
|
+
} catch (e) {
|
|
370
|
+
const errorMessage = e.message || String(e);
|
|
371
|
+
const errorLocation = e.stack?.split("\n")[1]?.trim() || "";
|
|
372
|
+
if (sensitivity.status === "runtime_skipped") {
|
|
373
|
+
return {
|
|
374
|
+
name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
|
|
375
|
+
passed: true,
|
|
376
|
+
status: "runtime_skipped",
|
|
377
|
+
errors: [],
|
|
378
|
+
warnings: [
|
|
379
|
+
...sensitivity.warnings,
|
|
380
|
+
`\u8FD0\u884C\u65F6\u6267\u884C\u5DF2\u8DF3\u8FC7\u4E25\u683C\u5224\u5B9A: ${errorMessage}`
|
|
381
|
+
]
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
if (sensitivity.status === "env_dependent" && isEnvironmentRelatedRuntimeError(errorMessage)) {
|
|
385
|
+
return {
|
|
386
|
+
name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
|
|
387
|
+
passed: true,
|
|
388
|
+
status: "env_dependent",
|
|
389
|
+
errors: [],
|
|
390
|
+
warnings: [
|
|
391
|
+
...sensitivity.warnings,
|
|
392
|
+
`\u8FD0\u884C\u65F6\u6267\u884C\u53D7\u5BBF\u4E3B\u73AF\u5883\u5F71\u54CD: ${errorMessage}`
|
|
393
|
+
]
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
name: "\u8FD0\u884C\u65F6\u9884\u68C0\u67E5",
|
|
398
|
+
passed: false,
|
|
399
|
+
status: "failed",
|
|
400
|
+
errors: [
|
|
401
|
+
`JavaScript \u6267\u884C\u9519\u8BEF: ${errorMessage}`,
|
|
402
|
+
...errorLocation ? [`\u4F4D\u7F6E: ${errorLocation}`] : []
|
|
403
|
+
],
|
|
404
|
+
warnings: sensitivity.warnings.length > 0 ? sensitivity.warnings : void 0
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
export { validateRuntimePrecheck };
|