vome-core 0.1.11 → 0.1.13

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.
Files changed (38) hide show
  1. package/dist/admin/config/plugin-dev.js +1 -1
  2. package/dist/admin/crud/config.js +1 -1
  3. package/dist/admin/crud/confirm.js +1 -1
  4. package/dist/admin/crud/dict.js +1 -1
  5. package/dist/admin/crud/index.js +1 -1
  6. package/dist/admin/crud/key.js +1 -1
  7. package/dist/admin/crud/mitt.js +1 -1
  8. package/dist/admin/crud/plugins.js +1 -1
  9. package/dist/admin/crud/span.js +1 -1
  10. package/dist/admin/crud/style.js +1 -1
  11. package/dist/admin/crud/validate.js +1 -1
  12. package/dist/admin/directives/perm.js +1 -1
  13. package/dist/admin/hooks/useUpload.js +1 -1
  14. package/dist/admin/lib/browser.js +1 -1
  15. package/dist/admin/lib/cn.js +1 -1
  16. package/dist/admin/lib/dialog-float.js +1 -1
  17. package/dist/admin/lib/export-excel.js +1 -1
  18. package/dist/admin/lib/import-excel.js +1 -1
  19. package/dist/admin/lib/json.js +1 -1
  20. package/dist/admin/lib/menu.js +1 -1
  21. package/dist/admin/lib/tree.js +1 -1
  22. package/dist/admin/lib/upload.js +1 -1
  23. package/dist/admin/lib/video-frame.js +1 -1
  24. package/dist/client/vite-admin.d.ts +19 -0
  25. package/dist/client/vite-admin.js +42 -0
  26. package/dist/client/vite-auto-import.d.ts +1 -0
  27. package/dist/client/vite-auto-import.js +103 -0
  28. package/dist/client/vite-micro-proxy.d.ts +17 -0
  29. package/dist/client/vite-micro-proxy.js +39 -0
  30. package/dist/client/vite-resolve.d.ts +8 -0
  31. package/dist/client/vite-resolve.js +124 -0
  32. package/dist/index.js +1 -1
  33. package/dist/server/index.js +1 -1
  34. package/dist/shared/excel.js +1 -1
  35. package/dist/shared/index.js +1 -1
  36. package/dist/shared/locale-json.js +1 -1
  37. package/dist/shared/tree.js +1 -1
  38. package/package.json +28 -2
@@ -0,0 +1,124 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { createRequire } from "node:module";
4
+ function resolveFile(base) {
5
+ const candidates = [
6
+ base,
7
+ `${base}.js`,
8
+ `${base}.ts`,
9
+ `${base}.vue`,
10
+ `${base}.css`,
11
+ `${base}.json`,
12
+ path.join(base, "index.js"),
13
+ path.join(base, "index.ts"),
14
+ path.join(base, "index.vue")
15
+ ];
16
+ for (const c of candidates) {
17
+ if (fs.existsSync(c) && fs.statSync(c).isFile())
18
+ return c;
19
+ }
20
+ return null;
21
+ }
22
+ function stripQuery(id) {
23
+ return id.split("?")[0].split("#")[0];
24
+ }
25
+ export function vomePeerDepsPlugin(appRoot) {
26
+ const require = createRequire(path.join(appRoot, "package.json"));
27
+ const nm = path.join(appRoot, "node_modules");
28
+ const pinned = {
29
+ clsx: path.join(nm, "clsx/dist/clsx.mjs"),
30
+ "tailwind-merge": path.join(nm, "tailwind-merge/dist/bundle-mjs.mjs"),
31
+ dompurify: path.join(nm, "dompurify/dist/purify.es.mjs"),
32
+ marked: path.join(nm, "marked/lib/marked.esm.js"),
33
+ "vue-sonner": path.join(nm, "vue-sonner/lib/index.js")
34
+ };
35
+ function resolvePeerPkg(pkg) {
36
+ const file = pinned[pkg];
37
+ if (file && fs.existsSync(file))
38
+ return file;
39
+ try {
40
+ return require.resolve(pkg);
41
+ } catch {
42
+ return;
43
+ }
44
+ }
45
+ function isCoreImporter(importer) {
46
+ if (!importer)
47
+ return false;
48
+ const norm = importer.replace(/\\/g, "/");
49
+ return norm.includes("/node_modules/vome-core/") || norm.includes("/vome-core/dist/");
50
+ }
51
+ return {
52
+ name: "vome-peer-deps",
53
+ enforce: "pre",
54
+ resolveId(source, importer) {
55
+ const normalized = source.replace(/^\0/, "");
56
+ if (normalized.startsWith("__vite-optional-peer-dep:")) {
57
+ const pkg = normalized.slice("__vite-optional-peer-dep:".length).replace(/:vome-core$/, "");
58
+ return resolvePeerPkg(pkg);
59
+ }
60
+ if (isCoreImporter(importer) && pinned[source]) {
61
+ return resolvePeerPkg(source);
62
+ }
63
+ return;
64
+ }
65
+ };
66
+ }
67
+ export function vomeResolvePlugin(root, hostSrc) {
68
+ const coreAdmin = path.resolve(root, "node_modules/vome-core/dist/admin");
69
+ const serviceEntry = path.resolve(coreAdmin, "service/index.js");
70
+ function resolveServiceId(id, importer) {
71
+ const clean = stripQuery(id).replace(/^@core\//, "vome-core/").replace(/^vome-core\//, "vome-core/");
72
+ if (clean === "vome-core/admin/service" || clean === "vome-core/admin/service/index" || clean === "vome-core/admin/service/index.js" || clean === "@core/admin/service" || clean === "@core/admin/service/index") {
73
+ return serviceEntry;
74
+ }
75
+ const norm = path.normalize(clean);
76
+ if (norm === path.normalize(serviceEntry))
77
+ return serviceEntry;
78
+ if (importer) {
79
+ const impDir = path.dirname(stripQuery(importer));
80
+ if (/vome-core[/\\]dist[/\\]admin/.test(impDir)) {
81
+ const abs = path.normalize(path.resolve(impDir, clean));
82
+ if (abs === path.normalize(serviceEntry) || abs === path.normalize(path.join(coreAdmin, "service")) || abs === path.normalize(path.join(coreAdmin, "service/index")) || abs === path.normalize(path.join(coreAdmin, "service/index.js"))) {
83
+ return serviceEntry;
84
+ }
85
+ }
86
+ }
87
+ return;
88
+ }
89
+ return {
90
+ name: "vome-resolve",
91
+ enforce: "pre",
92
+ resolveId(id, importer) {
93
+ const serviceId = resolveServiceId(id, importer);
94
+ if (serviceId)
95
+ return serviceId;
96
+ if (id === "#vome-host" || id.startsWith("#vome-host/")) {
97
+ const sub = id === "#vome-host" ? "" : id.slice("#vome-host/".length);
98
+ return resolveFile(path.resolve(hostSrc, sub)) ?? undefined;
99
+ }
100
+ let adminId = id;
101
+ if (adminId.startsWith("@core/admin")) {
102
+ adminId = adminId.replace(/^@core\//, "vome-core/");
103
+ }
104
+ if (adminId === "vome-core/admin" || adminId.startsWith("vome-core/admin/")) {
105
+ const sub = adminId === "vome-core/admin" ? "" : adminId.slice("vome-core/admin/".length);
106
+ return resolveFile(path.resolve(coreAdmin, sub)) ?? undefined;
107
+ }
108
+ }
109
+ };
110
+ }
111
+ export function vomeHostEsbuildPlugin(hostSrc) {
112
+ return {
113
+ name: "vome-host-esbuild",
114
+ setup(build) {
115
+ build.onResolve({ filter: /^#vome-host(\/|$)/ }, (args) => {
116
+ const sub = args.path === "#vome-host" ? "" : args.path.slice("#vome-host/".length);
117
+ const resolved = resolveFile(path.resolve(hostSrc, sub));
118
+ if (!resolved)
119
+ return;
120
+ return { path: resolved };
121
+ });
122
+ }
123
+ };
124
+ }