phecda-react 0.1.0-alpha.10 → 0.1.0-alpha.11

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.js CHANGED
@@ -35,14 +35,14 @@ var import_valtio = require("valtio");
35
35
  var import_react = require("react");
36
36
  var import_phecda_web = require("phecda-web");
37
37
  function useO(module2) {
38
- const { state, _o: oMap } = (0, import_phecda_web.getActiveInstance)();
38
+ const { state, origin } = (0, import_phecda_web.getActiveInstance)();
39
39
  if (module2.prototype.__ISOLATE__) {
40
40
  const instance2 = new module2();
41
41
  return instance2;
42
42
  }
43
43
  const tag = (0, import_phecda_web.getTag)(module2);
44
44
  if (tag in state) {
45
- if (oMap.get(state[tag]) !== module2)
45
+ if (origin.get(state[tag]) !== module2)
46
46
  console.warn(`Synonym module: Module taged "${String(tag)}" has been loaded before, so won't load Module "${module2.name}"`);
47
47
  return state[tag];
48
48
  }
@@ -52,10 +52,10 @@ function useO(module2) {
52
52
  }
53
53
  __name(useO, "useO");
54
54
  function useR(module2) {
55
- const { _r: rmap, _f: fmap } = (0, import_phecda_web.getActiveInstance)();
55
+ const { cache: cacheMap } = (0, import_phecda_web.getActiveInstance)();
56
56
  const instance = useO(module2);
57
- if (rmap.has(instance)) {
58
- const proxyInstance2 = rmap.get(instance);
57
+ if (cacheMap.has(instance)) {
58
+ const proxyInstance2 = cacheMap.get(instance);
59
59
  return [
60
60
  (0, import_valtio.useSnapshot)(proxyInstance2),
61
61
  proxyInstance2
@@ -66,13 +66,13 @@ function useR(module2) {
66
66
  if (key === "_promise")
67
67
  return target[key];
68
68
  if (typeof target[key] === "function") {
69
- if (fmap.has(target[key]))
70
- return fmap.get(target[key]);
69
+ if (cacheMap.has(target[key]))
70
+ return cacheMap.get(target[key]);
71
71
  const errorHandler = (0, import_phecda_web.getHandler)(target, key).find((item) => item.error)?.error;
72
72
  if (!errorHandler)
73
73
  return target[key].bind(target);
74
74
  const wrapper = (0, import_phecda_web.wrapError)(target, key, errorHandler);
75
- fmap.set(target[key], wrapper);
75
+ cacheMap.set(target[key], wrapper);
76
76
  return wrapper;
77
77
  }
78
78
  return target[key];
@@ -83,7 +83,7 @@ function useR(module2) {
83
83
  }
84
84
  }));
85
85
  instance._promise = (0, import_phecda_web.invokeHandler)("init", proxyInstance);
86
- rmap.set(instance, proxyInstance);
86
+ cacheMap.set(instance, proxyInstance);
87
87
  return [
88
88
  (0, import_valtio.useSnapshot)(proxyInstance),
89
89
  proxyInstance
package/dist/index.mjs CHANGED
@@ -6,14 +6,14 @@ import { proxy, useSnapshot } from "valtio";
6
6
  import { useEffect } from "react";
7
7
  import { getActiveInstance, getHandler, getTag, invokeHandler, resetActiveInstance, wrapError } from "phecda-web";
8
8
  function useO(module) {
9
- const { state, _o: oMap } = getActiveInstance();
9
+ const { state, origin } = getActiveInstance();
10
10
  if (module.prototype.__ISOLATE__) {
11
11
  const instance2 = new module();
12
12
  return instance2;
13
13
  }
14
14
  const tag = getTag(module);
15
15
  if (tag in state) {
16
- if (oMap.get(state[tag]) !== module)
16
+ if (origin.get(state[tag]) !== module)
17
17
  console.warn(`Synonym module: Module taged "${String(tag)}" has been loaded before, so won't load Module "${module.name}"`);
18
18
  return state[tag];
19
19
  }
@@ -23,10 +23,10 @@ function useO(module) {
23
23
  }
24
24
  __name(useO, "useO");
25
25
  function useR(module) {
26
- const { _r: rmap, _f: fmap } = getActiveInstance();
26
+ const { cache: cacheMap } = getActiveInstance();
27
27
  const instance = useO(module);
28
- if (rmap.has(instance)) {
29
- const proxyInstance2 = rmap.get(instance);
28
+ if (cacheMap.has(instance)) {
29
+ const proxyInstance2 = cacheMap.get(instance);
30
30
  return [
31
31
  useSnapshot(proxyInstance2),
32
32
  proxyInstance2
@@ -37,13 +37,13 @@ function useR(module) {
37
37
  if (key === "_promise")
38
38
  return target[key];
39
39
  if (typeof target[key] === "function") {
40
- if (fmap.has(target[key]))
41
- return fmap.get(target[key]);
40
+ if (cacheMap.has(target[key]))
41
+ return cacheMap.get(target[key]);
42
42
  const errorHandler = getHandler(target, key).find((item) => item.error)?.error;
43
43
  if (!errorHandler)
44
44
  return target[key].bind(target);
45
45
  const wrapper = wrapError(target, key, errorHandler);
46
- fmap.set(target[key], wrapper);
46
+ cacheMap.set(target[key], wrapper);
47
47
  return wrapper;
48
48
  }
49
49
  return target[key];
@@ -54,7 +54,7 @@ function useR(module) {
54
54
  }
55
55
  }));
56
56
  instance._promise = invokeHandler("init", proxyInstance);
57
- rmap.set(instance, proxyInstance);
57
+ cacheMap.set(instance, proxyInstance);
58
58
  return [
59
59
  useSnapshot(proxyInstance),
60
60
  proxyInstance
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-react",
3
- "version": "0.1.0-alpha.10",
3
+ "version": "0.1.0-alpha.11",
4
4
  "description": "provide phecda function to react by valtio",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "react": "^18.2.0",
16
16
  "valtio": "^1.13.0",
17
- "phecda-web": "1.0.1-alpha.6"
17
+ "phecda-web": "1.0.1-alpha.7"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/react": "^18.2.48",