phecda-web 2.0.8 → 3.0.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/dist/index.d.mts CHANGED
@@ -16,7 +16,6 @@ type DeepPartial<T> = {
16
16
  declare const emitter: PhecdaEmitter;
17
17
  declare function defaultWebInject(): void;
18
18
 
19
- declare function wait(...instances: InstanceType<Construct>[]): Promise<any[]>;
20
19
  declare function getParamtypes(Model: Construct): any;
21
20
  declare const phecdaNamespace: Map<string, WebPhecda>;
22
21
  declare function setDefaultPhecda(namespace: string, phecda: WebPhecda): void;
@@ -89,4 +88,4 @@ declare class WebBase extends Base {
89
88
  emitter: PhecdaEmitter;
90
89
  }
91
90
 
92
- export { type DeepPartial, type PhecdaEmitter, WebBase, WebPhecda, bindMethod, defaultWebInject, delDefaultPhecda, emitter, getDefaultPhecda, getParamtypes, phecdaNamespace, setDefaultPhecda, wait };
91
+ export { type DeepPartial, type PhecdaEmitter, WebBase, WebPhecda, bindMethod, defaultWebInject, delDefaultPhecda, emitter, getDefaultPhecda, getParamtypes, phecdaNamespace, setDefaultPhecda };
package/dist/index.d.ts CHANGED
@@ -16,7 +16,6 @@ type DeepPartial<T> = {
16
16
  declare const emitter: PhecdaEmitter;
17
17
  declare function defaultWebInject(): void;
18
18
 
19
- declare function wait(...instances: InstanceType<Construct>[]): Promise<any[]>;
20
19
  declare function getParamtypes(Model: Construct): any;
21
20
  declare const phecdaNamespace: Map<string, WebPhecda>;
22
21
  declare function setDefaultPhecda(namespace: string, phecda: WebPhecda): void;
@@ -89,4 +88,4 @@ declare class WebBase extends Base {
89
88
  emitter: PhecdaEmitter;
90
89
  }
91
90
 
92
- export { type DeepPartial, type PhecdaEmitter, WebBase, WebPhecda, bindMethod, defaultWebInject, delDefaultPhecda, emitter, getDefaultPhecda, getParamtypes, phecdaNamespace, setDefaultPhecda, wait };
91
+ export { type DeepPartial, type PhecdaEmitter, WebBase, WebPhecda, bindMethod, defaultWebInject, delDefaultPhecda, emitter, getDefaultPhecda, getParamtypes, phecdaNamespace, setDefaultPhecda };
package/dist/index.js CHANGED
@@ -42,8 +42,7 @@ __export(src_exports, {
42
42
  getDefaultPhecda: () => getDefaultPhecda,
43
43
  getParamtypes: () => getParamtypes,
44
44
  phecdaNamespace: () => phecdaNamespace,
45
- setDefaultPhecda: () => setDefaultPhecda,
46
- wait: () => wait
45
+ setDefaultPhecda: () => setDefaultPhecda
47
46
  });
48
47
  module.exports = __toCommonJS(src_exports);
49
48
  __reExport(src_exports, require("phecda-core"), module.exports);
@@ -54,8 +53,8 @@ var import_mitt = __toESM(require("mitt"));
54
53
  var emitter = (0, import_mitt.default)();
55
54
  function defaultWebInject() {
56
55
  if (!(0, import_phecda_core.getInject)("watcher")) {
57
- (0, import_phecda_core.setInject)("watcher", ({ eventName, instance, key, options }) => {
58
- const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
56
+ (0, import_phecda_core.setInject)("watcher", ({ eventName, instance, property, options }) => {
57
+ const fn = typeof instance[property] === "function" ? instance[property].bind(instance) : (v) => instance[property] = v;
59
58
  if (options?.once) {
60
59
  const handler = /* @__PURE__ */ __name(() => {
61
60
  fn();
@@ -69,22 +68,22 @@ function defaultWebInject() {
69
68
  });
70
69
  }
71
70
  if (!(0, import_phecda_core.getInject)("storage")) {
72
- (0, import_phecda_core.setInject)("storage", ({ tag, key, instance, toJSON, toString }) => {
73
- tag = `phecda:${key ? `${tag}-${key}` : tag}`;
71
+ (0, import_phecda_core.setInject)("storage", ({ tag, property, instance, toJSON, toString }) => {
72
+ tag = `phecda:${property ? `${tag}-${property}` : tag}`;
74
73
  const initstr = localStorage.getItem(tag);
75
74
  if (initstr) {
76
75
  const data = toJSON(initstr);
77
- if (key) {
78
- instance[key] = data;
76
+ if (property) {
77
+ instance[property] = data;
79
78
  } else {
80
79
  for (const i in data) {
81
80
  if (i) instance[i] = data[i];
82
81
  }
83
82
  }
84
83
  }
85
- localStorage.setItem(tag, toString(key ? instance[key] : instance));
84
+ localStorage.setItem(tag, toString(property ? instance[property] : instance));
86
85
  globalThis.addEventListener("beforeunload", () => {
87
- localStorage.setItem(tag, toString(key ? instance[key] : instance));
86
+ localStorage.setItem(tag, toString(property ? instance[property] : instance));
88
87
  });
89
88
  });
90
89
  }
@@ -117,10 +116,6 @@ function deepMerge(target, patchToApply) {
117
116
  __name(deepMerge, "deepMerge");
118
117
 
119
118
  // src/core.ts
120
- function wait(...instances) {
121
- return Promise.all(instances.map((i) => i.__PROMISE_SYMBOL__));
122
- }
123
- __name(wait, "wait");
124
119
  function getParamtypes(Model) {
125
120
  return Reflect.getMetadata("design:paramtypes", Model);
126
121
  }
@@ -184,7 +179,7 @@ var WebPhecda = class {
184
179
  then(onfulfilled, onrejected) {
185
180
  const then = this.then;
186
181
  this.then = void 0;
187
- wait(...Object.values(this.state)).then(() => onfulfilled?.(this), onrejected).then(() => {
182
+ (0, import_phecda_core2.wait)(...Object.values(this.state)).then(() => onfulfilled?.(this), onrejected).then(() => {
188
183
  this.then = then;
189
184
  });
190
185
  return this;
@@ -212,7 +207,7 @@ var WebPhecda = class {
212
207
  this.emit("Initialize", {
213
208
  tag
214
209
  });
215
- (0, import_phecda_core2.invokeHandler)("init", instance2);
210
+ (0, import_phecda_core2.invokeInit)(instance2);
216
211
  }
217
212
  return instance2;
218
213
  }, "initModel");
@@ -284,7 +279,7 @@ var WebPhecda = class {
284
279
  tag
285
280
  });
286
281
  const { state } = this;
287
- await (0, import_phecda_core2.invokeHandler)("unmount", this.get(tag));
282
+ await (0, import_phecda_core2.invokeUnmount)(this.get(tag));
288
283
  delete state[tag];
289
284
  }
290
285
  async unmountAll() {
@@ -345,6 +340,5 @@ var import_ts_mixer = require("ts-mixer");
345
340
  getParamtypes,
346
341
  phecdaNamespace,
347
342
  setDefaultPhecda,
348
- wait,
349
343
  ...require("phecda-core")
350
344
  });
package/dist/index.mjs CHANGED
@@ -10,8 +10,8 @@ import mitt from "mitt";
10
10
  var emitter = mitt();
11
11
  function defaultWebInject() {
12
12
  if (!getInject("watcher")) {
13
- setInject("watcher", ({ eventName, instance, key, options }) => {
14
- const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
13
+ setInject("watcher", ({ eventName, instance, property, options }) => {
14
+ const fn = typeof instance[property] === "function" ? instance[property].bind(instance) : (v) => instance[property] = v;
15
15
  if (options?.once) {
16
16
  const handler = /* @__PURE__ */ __name(() => {
17
17
  fn();
@@ -25,22 +25,22 @@ function defaultWebInject() {
25
25
  });
26
26
  }
27
27
  if (!getInject("storage")) {
28
- setInject("storage", ({ tag, key, instance, toJSON, toString }) => {
29
- tag = `phecda:${key ? `${tag}-${key}` : tag}`;
28
+ setInject("storage", ({ tag, property, instance, toJSON, toString }) => {
29
+ tag = `phecda:${property ? `${tag}-${property}` : tag}`;
30
30
  const initstr = localStorage.getItem(tag);
31
31
  if (initstr) {
32
32
  const data = toJSON(initstr);
33
- if (key) {
34
- instance[key] = data;
33
+ if (property) {
34
+ instance[property] = data;
35
35
  } else {
36
36
  for (const i in data) {
37
37
  if (i) instance[i] = data[i];
38
38
  }
39
39
  }
40
40
  }
41
- localStorage.setItem(tag, toString(key ? instance[key] : instance));
41
+ localStorage.setItem(tag, toString(property ? instance[property] : instance));
42
42
  globalThis.addEventListener("beforeunload", () => {
43
- localStorage.setItem(tag, toString(key ? instance[key] : instance));
43
+ localStorage.setItem(tag, toString(property ? instance[property] : instance));
44
44
  });
45
45
  });
46
46
  }
@@ -48,7 +48,7 @@ function defaultWebInject() {
48
48
  __name(defaultWebInject, "defaultWebInject");
49
49
 
50
50
  // src/core.ts
51
- import { get, getTag, invokeHandler } from "phecda-core";
51
+ import { get, getTag, invokeInit, invokeUnmount, wait } from "phecda-core";
52
52
  import "reflect-metadata";
53
53
  import mitt2 from "mitt";
54
54
 
@@ -73,10 +73,6 @@ function deepMerge(target, patchToApply) {
73
73
  __name(deepMerge, "deepMerge");
74
74
 
75
75
  // src/core.ts
76
- function wait(...instances) {
77
- return Promise.all(instances.map((i) => i.__PROMISE_SYMBOL__));
78
- }
79
- __name(wait, "wait");
80
76
  function getParamtypes(Model) {
81
77
  return Reflect.getMetadata("design:paramtypes", Model);
82
78
  }
@@ -168,7 +164,7 @@ var WebPhecda = class {
168
164
  this.emit("Initialize", {
169
165
  tag
170
166
  });
171
- invokeHandler("init", instance2);
167
+ invokeInit(instance2);
172
168
  }
173
169
  return instance2;
174
170
  }, "initModel");
@@ -240,7 +236,7 @@ var WebPhecda = class {
240
236
  tag
241
237
  });
242
238
  const { state } = this;
243
- await invokeHandler("unmount", this.get(tag));
239
+ await invokeUnmount(this.get(tag));
244
240
  delete state[tag];
245
241
  }
246
242
  async unmountAll() {
@@ -299,6 +295,5 @@ export {
299
295
  getDefaultPhecda,
300
296
  getParamtypes,
301
297
  phecdaNamespace,
302
- setDefaultPhecda,
303
- wait
298
+ setDefaultPhecda
304
299
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-web",
3
- "version": "2.0.8",
3
+ "version": "3.0.1",
4
4
  "description": "using proxy, provide phecda function to web app",
5
5
  "author": "fgsreally",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "mitt": "^3.0.0",
20
20
  "reflect-metadata": "^0.1.13",
21
21
  "ts-mixer": "^6.0.4",
22
- "phecda-core": "3.1.1"
22
+ "phecda-core": "4.0.1"
23
23
  },
24
24
  "devDependencies": {
25
25
  "tsup": "^8.1.0"