@vc-shell/framework 1.0.253 → 1.0.255
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/CHANGELOG.md +18 -0
- package/core/plugins/modularity/index.ts +2 -0
- package/core/plugins/modularity/loader.ts +95 -0
- package/dist/core/plugins/modularity/index.d.ts +1 -0
- package/dist/core/plugins/modularity/index.d.ts.map +1 -1
- package/dist/core/plugins/modularity/loader.d.ts +9 -0
- package/dist/core/plugins/modularity/loader.d.ts.map +1 -0
- package/dist/framework.js +14111 -13851
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/components/organisms/vc-app/vc-app.vue.d.ts.map +1 -1
- package/package.json +4 -4
- package/ui/components/organisms/vc-app/vc-app.vue +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## [1.0.255](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.254...v1.0.255) (2024-07-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **core:** useDynamicModules fix ([b38d966](https://github.com/VirtoCommerce/vc-shell/commit/b38d9668b410d7bbb0d798f2218f2b6051416cc9))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [1.0.254](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.253...v1.0.254) (2024-07-12)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* dynamic module loader ([4d15575](https://github.com/VirtoCommerce/vc-shell/commit/4d15575bb5448e16b4034782bafc7097189742f1))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
1
19
|
## [1.0.253](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.252...v1.0.253) (2024-07-12)
|
|
2
20
|
|
|
3
21
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { App, Plugin } from "vue";
|
|
2
|
+
import { Router } from "vue-router";
|
|
3
|
+
|
|
4
|
+
interface ModuleManifest {
|
|
5
|
+
file: string;
|
|
6
|
+
name: string;
|
|
7
|
+
src: string;
|
|
8
|
+
isEntry: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface CssManifest {
|
|
12
|
+
file: string;
|
|
13
|
+
src: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface Manifest {
|
|
17
|
+
[key: string]: ModuleManifest | CssManifest;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface Apps {
|
|
21
|
+
[x: string]: {
|
|
22
|
+
modules: { id: string; url: string }[];
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function loadCSS(url: string) {
|
|
27
|
+
return new Promise<void>((resolve, reject) => {
|
|
28
|
+
const link = document.createElement("link");
|
|
29
|
+
link.rel = "stylesheet";
|
|
30
|
+
link.href = url;
|
|
31
|
+
link.onload = () => resolve();
|
|
32
|
+
link.onerror = () => reject(new Error(`Failed to load CSS: ${url}`));
|
|
33
|
+
document.head.appendChild(link);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function useDynamicModules(app: App, { router, appName }: { router: Router; appName: string }) {
|
|
38
|
+
async function load() {
|
|
39
|
+
try {
|
|
40
|
+
const appsUrl = "/Modules/$(VirtoCommerce.MarketplaceVendor)/Content/apps.json";
|
|
41
|
+
const modules: Apps[] = await fetch(appsUrl).then((res) => res.json());
|
|
42
|
+
|
|
43
|
+
for (const module of modules) {
|
|
44
|
+
const appModules = module[appName].modules;
|
|
45
|
+
|
|
46
|
+
if (!appModules.length) {
|
|
47
|
+
throw new Error("Modules not found");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
for (const module of appModules) {
|
|
51
|
+
const moduleUrl = module.url.replace(/^([^/])/, "/$1").replace(/([^/])$/, "$1/");
|
|
52
|
+
const manifestResponse = await fetch(moduleUrl + "manifest.json");
|
|
53
|
+
|
|
54
|
+
if (!manifestResponse.ok) {
|
|
55
|
+
throw new Error(`Failed to load manifest: ${manifestResponse.statusText}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const manifest: Manifest = await manifestResponse.json();
|
|
59
|
+
|
|
60
|
+
// Find entry point
|
|
61
|
+
const entry = Object.values(manifest).find((file) => (file as ModuleManifest).isEntry);
|
|
62
|
+
|
|
63
|
+
if (!entry) {
|
|
64
|
+
throw new Error("Entry file not found");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
await Promise.all(
|
|
68
|
+
Object.values(manifest)
|
|
69
|
+
.filter((file) => file.file.endsWith(".css"))
|
|
70
|
+
.map((file) => loadCSS(moduleUrl + `${file.file}`)),
|
|
71
|
+
).catch((error) => {
|
|
72
|
+
console.error("Failed to load styles", error);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await import(/* @vite-ignore */ moduleUrl + entry.file).catch((error) => {
|
|
76
|
+
console.error("Failed to load module", error);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
Object.values(window.VcShellDynamicModules).forEach((mod) => {
|
|
80
|
+
app.use((mod as Record<"default", Plugin>)?.default, { router });
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
app.config.globalProperties.$dynamicModules = window.VcShellDynamicModules;
|
|
84
|
+
app.provide("$dynamicModules", app.config.globalProperties.$dynamicModules);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error("Failed to load modules", error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
load,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../core/plugins/modularity/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAK,MAAM,KAAK,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAc,MAAM,qDAAqD,CAAC;AAK3G,eAAO,MAAM,YAAY;;aAAuE,OAAO;iBACxF,GAAG,GAAG,IAAI;CAavB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;iBAOX,GAAG,YAAY;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;CA2GxD,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../core/plugins/modularity/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAK,MAAM,KAAK,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAc,MAAM,qDAAqD,CAAC;AAK3G,eAAO,MAAM,YAAY;;aAAuE,OAAO;iBACxF,GAAG,GAAG,IAAI;CAavB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;;iBAOX,GAAG,YAAY;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;CA2GxD,CAAC;AAEF,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../../core/plugins/modularity/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAU,MAAM,KAAK,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAmCpC,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;;EA0DnG"}
|