@vnejs/core 0.2.2 → 0.2.4
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/index.js +12 -9
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,16 +24,19 @@ export class VneCore {
|
|
|
24
24
|
VNE_MODULES.forEach(this.addModule);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
init = async (
|
|
28
|
-
const
|
|
29
|
-
const mods = await fetch(`/mods.json?ts=${ts}
|
|
30
|
-
const fetchResult = await Promise.all(mods.map((mod) => fetch(`/media.${mod}.json?ts=${ts}
|
|
27
|
+
init = async () => {
|
|
28
|
+
const ts = Math.round(new Date().getTime() / 1000 / 60 / 60);
|
|
29
|
+
const mods = await fetch(`/mods.json?ts=${ts}`).then(toJSON);
|
|
30
|
+
const fetchResult = await Promise.all(mods.map((mod) => fetch(`/media.${mod}.json?ts=${ts}`).then(toJSON)));
|
|
31
31
|
const media = fetchResult.reduce(mergeFetchResult, {});
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Object.values(this.modules).forEach((module) =>
|
|
32
|
+
const [on, emit, emitOne, emitReal] = [this.observer.subscribe, this.observer.emit, this.observer.emitOne, this.observer.emitReal];
|
|
33
|
+
const moduleArgs = { platform: this.getPlatform() };
|
|
34
|
+
const injectArg = { on, emit, emitOne, emitReal, state: this.state, shared: this.shared, media };
|
|
35
|
+
|
|
36
|
+
Object.values(this.modules).forEach((module) => {
|
|
37
|
+
module?.inject(injectArg);
|
|
38
|
+
module?.subscribe(moduleArgs);
|
|
39
|
+
});
|
|
37
40
|
|
|
38
41
|
window.uninitedModules = [];
|
|
39
42
|
|