phecda-react 0.0.1-alpha.0 → 0.0.1-alpha.2
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.ts +2 -2
- package/dist/index.js +8 -7
- package/dist/index.mjs +9 -8
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -17,8 +17,8 @@ interface PhecdaInstance {
|
|
|
17
17
|
declare const emitter: PhecdaEmitter;
|
|
18
18
|
declare function setActivePhecda(phecda: PhecdaInstance): void;
|
|
19
19
|
declare function getActivePhecda(): PhecdaInstance;
|
|
20
|
-
declare function useO<T extends new (...args: any) => any>(
|
|
21
|
-
declare function useR<T extends new (...args: any) => any>(
|
|
20
|
+
declare function useO<T extends new (...args: any) => any>(module: T): any;
|
|
21
|
+
declare function useR<T extends new (...args: any) => any>(module: T): [InstanceType<T>, InstanceType<T>];
|
|
22
22
|
declare function createPhecdaContext(): ({ children }: any) => react.FunctionComponentElement<react.ProviderProps<null>>;
|
|
23
23
|
|
|
24
24
|
declare function wrapError(target: any, key: PropertyKey, errorHandler: Function): (...args: any) => any;
|
package/dist/index.js
CHANGED
|
@@ -83,18 +83,19 @@ function getActivePhecda() {
|
|
|
83
83
|
return activePhecda;
|
|
84
84
|
}
|
|
85
85
|
__name(getActivePhecda, "getActivePhecda");
|
|
86
|
-
function useO(
|
|
86
|
+
function useO(module2) {
|
|
87
87
|
const { useOMap } = getActivePhecda();
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
const tag = (0, import_phecda_core.getTag)(module2) || module2.name;
|
|
89
|
+
if (useOMap.has(tag))
|
|
90
|
+
return useOMap.get(tag);
|
|
91
|
+
const instance = new module2();
|
|
92
|
+
useOMap.set(tag, instance);
|
|
92
93
|
return instance;
|
|
93
94
|
}
|
|
94
95
|
__name(useO, "useO");
|
|
95
|
-
function useR(
|
|
96
|
+
function useR(module2) {
|
|
96
97
|
const { useRMap, fnMap } = getActivePhecda();
|
|
97
|
-
const instance = useO(
|
|
98
|
+
const instance = useO(module2);
|
|
98
99
|
if (useRMap.has(instance)) {
|
|
99
100
|
const proxyInstance2 = useRMap.get(instance);
|
|
100
101
|
return [
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/composables.ts
|
|
5
5
|
import { proxy, useSnapshot } from "valtio";
|
|
6
|
-
import { getHandler, getProperty, injectProperty, register } from "phecda-core";
|
|
6
|
+
import { getHandler, getProperty, getTag, injectProperty, register } from "phecda-core";
|
|
7
7
|
import { createContext, createElement, useEffect } from "react";
|
|
8
8
|
import mitt from "mitt";
|
|
9
9
|
|
|
@@ -45,18 +45,19 @@ function getActivePhecda() {
|
|
|
45
45
|
return activePhecda;
|
|
46
46
|
}
|
|
47
47
|
__name(getActivePhecda, "getActivePhecda");
|
|
48
|
-
function useO(
|
|
48
|
+
function useO(module) {
|
|
49
49
|
const { useOMap } = getActivePhecda();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const tag = getTag(module) || module.name;
|
|
51
|
+
if (useOMap.has(tag))
|
|
52
|
+
return useOMap.get(tag);
|
|
53
|
+
const instance = new module();
|
|
54
|
+
useOMap.set(tag, instance);
|
|
54
55
|
return instance;
|
|
55
56
|
}
|
|
56
57
|
__name(useO, "useO");
|
|
57
|
-
function useR(
|
|
58
|
+
function useR(module) {
|
|
58
59
|
const { useRMap, fnMap } = getActivePhecda();
|
|
59
|
-
const instance = useO(
|
|
60
|
+
const instance = useO(module);
|
|
60
61
|
if (useRMap.has(instance)) {
|
|
61
62
|
const proxyInstance2 = useRMap.get(instance);
|
|
62
63
|
return [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-react",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.2",
|
|
4
4
|
"description": "provide store with phecda function to react",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"mitt": "^3.0.0",
|
|
16
16
|
"react": "^18.2.0",
|
|
17
17
|
"valtio": "^1.13.0",
|
|
18
|
-
"phecda-core": "
|
|
18
|
+
"phecda-core": "3.0.0-alpha.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/react": "^18.2.48",
|