@vnejs/core 0.2.4 → 0.2.6

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 (3) hide show
  1. package/index.d.ts +0 -7
  2. package/index.js +4 -21
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -5,12 +5,5 @@ declare module "@vnejs/core" {
5
5
  init: (options: any) => Promise<void>;
6
6
  reset: () => Promise<void>;
7
7
  addModule: (m: Module) => void;
8
-
9
- getPlatform: () => string;
10
- getSubPlatform: () => string;
11
-
12
- isMobile: () => Boolean;
13
- isDesktop: () => Boolean;
14
- isWeb: () => Boolean;
15
8
  }
16
9
  }
package/index.js CHANGED
@@ -26,16 +26,15 @@ export class VneCore {
26
26
 
27
27
  init = async () => {
28
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)));
29
+ const mods = await fetch(`${VNE.CONST.SYSTEM.HOST}/mods.json?ts=${ts}`).then(toJSON);
30
+ const fetchResult = await Promise.all(mods.map((mod) => fetch(`${VNE.CONST.SYSTEM.HOST}/media.${mod}.json?ts=${ts}`).then(toJSON)));
31
31
  const media = fetchResult.reduce(mergeFetchResult, {});
32
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
33
  const injectArg = { on, emit, emitOne, emitReal, state: this.state, shared: this.shared, media };
35
34
 
36
35
  Object.values(this.modules).forEach((module) => {
37
36
  module?.inject(injectArg);
38
- module?.subscribe(moduleArgs);
37
+ module?.subscribe();
39
38
  });
40
39
 
41
40
  window.uninitedModules = [];
@@ -47,7 +46,7 @@ export class VneCore {
47
46
  window.uninitedModules.push(module.name);
48
47
  console.log("init module", module.name, "start");
49
48
  module.isReady = false;
50
- if (module.init) await module.init(moduleArgs);
49
+ if (module.init) await module.init();
51
50
  module.isReady = true;
52
51
  console.log("init module", module.name, "finish");
53
52
  window.uninitedModules = window.uninitedModules.filter((k) => k !== module.name);
@@ -68,20 +67,4 @@ export class VneCore {
68
67
 
69
68
  this.modules[module.name] = module;
70
69
  };
71
-
72
- getPlatform = () => {
73
- if (this.isMobile()) return VNE.CONST.PLATFORMS.MOBILE;
74
- if (this.isDesktop()) return VNE.CONST.PLATFORMS.ELECTRON;
75
- return VNE.CONST.PLATFORMS.WEB;
76
- };
77
-
78
- getSubPlatform = () => {
79
- if (this.isMobile()) return VNE.CONST.PLATFORMS.ANDROID;
80
- if (this.isDesktop()) return VNE.CONST.PLATFORMS.WINDOWS;
81
- return VNE.CONST.PLATFORMS.WEB;
82
- };
83
-
84
- isMobile = () => Boolean(Capacitor.isNativePlatform());
85
- isDesktop = () => navigator.userAgent.includes("Electron");
86
- isWeb = () => !this.isMobile() && !this.isDesktop();
87
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/core",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",