phecda-vue 2.1.3-alpha.2 → 2.1.3-alpha.3
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 +8 -8
- package/dist/index.js +17 -16
- package/dist/index.mjs +18 -17
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -34,17 +34,17 @@ declare function setActivePhecda(phecda: PhecdaInstance): void;
|
|
|
34
34
|
declare function getActivePhecda(): PhecdaInstance;
|
|
35
35
|
declare function getReactiveMap(symbol: string): Map<string, any> | null;
|
|
36
36
|
|
|
37
|
-
type
|
|
38
|
-
[K in keyof T]?:
|
|
37
|
+
type DeepPartial<T> = {
|
|
38
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
declare function useO<T extends new (...args: any) => any>(
|
|
42
|
-
declare function useRaw<T extends new (...args: any) => any>(
|
|
43
|
-
declare function usePatch<T extends new (...args: any) => any>(
|
|
44
|
-
declare function useR<T extends new (...args: any) => any>(
|
|
45
|
-
declare function useV<T extends new (...args: any) => any>(
|
|
41
|
+
declare function useO<T extends new (...args: any) => any>(module: T): UnwrapNestedRefs<InstanceType<T>>;
|
|
42
|
+
declare function useRaw<T extends new (...args: any) => any>(module: T): InstanceType<T>;
|
|
43
|
+
declare function usePatch<T extends new (...args: any) => any>(module: T, Data: DeepPartial<InstanceType<T>>): void;
|
|
44
|
+
declare function useR<T extends new (...args: any) => any>(module: T): UnwrapNestedRefs<InstanceType<T>>;
|
|
45
|
+
declare function useV<T extends new (...args: any) => any>(module: T): ReplaceInstanceValues<InstanceType<T>>;
|
|
46
46
|
declare function useEvent<Key extends keyof Events>(eventName: Key, cb: Handler<Events[Key]>): () => void;
|
|
47
|
-
declare function initialize<M extends new (...args: any) => any>(
|
|
47
|
+
declare function initialize<M extends new (...args: any) => any>(module: M, deleteOtherProperty?: boolean): InstanceType<M> | void;
|
|
48
48
|
|
|
49
49
|
declare const RE: RegExp;
|
|
50
50
|
declare function createFilter<Data extends Record<string, any>>(initState?: Object, option?: {
|
package/dist/index.js
CHANGED
|
@@ -231,28 +231,29 @@ function createSharedReactive(composable) {
|
|
|
231
231
|
__name(createSharedReactive, "createSharedReactive");
|
|
232
232
|
|
|
233
233
|
// src/vue/composable.ts
|
|
234
|
-
function useO(
|
|
234
|
+
function useO(module2) {
|
|
235
235
|
const { useOMap } = getActivePhecda();
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
const tag = (0, import_phecda_core2.getTag)(module2) || module2.name;
|
|
237
|
+
if (!useOMap.has(tag)) {
|
|
238
|
+
const instance = (0, import_vue3.reactive)(new module2());
|
|
239
|
+
useOMap.set(tag, instance);
|
|
239
240
|
(0, import_phecda_core2.register)(instance);
|
|
240
241
|
}
|
|
241
|
-
return useOMap.get(
|
|
242
|
+
return useOMap.get(tag);
|
|
242
243
|
}
|
|
243
244
|
__name(useO, "useO");
|
|
244
|
-
function useRaw(
|
|
245
|
-
return (0, import_vue3.toRaw)(useO(
|
|
245
|
+
function useRaw(module2) {
|
|
246
|
+
return (0, import_vue3.toRaw)(useO(module2));
|
|
246
247
|
}
|
|
247
248
|
__name(useRaw, "useRaw");
|
|
248
|
-
function usePatch(
|
|
249
|
-
const instance = useO(
|
|
249
|
+
function usePatch(module2, Data) {
|
|
250
|
+
const instance = useO(module2);
|
|
250
251
|
mergeReactiveObjects(instance, Data);
|
|
251
252
|
}
|
|
252
253
|
__name(usePatch, "usePatch");
|
|
253
|
-
function useR(
|
|
254
|
+
function useR(module2) {
|
|
254
255
|
const { useRMap, fnMap } = getActivePhecda();
|
|
255
|
-
const instance = useO(
|
|
256
|
+
const instance = useO(module2);
|
|
256
257
|
if (useRMap.has(instance))
|
|
257
258
|
return useRMap.get(instance);
|
|
258
259
|
const proxy = new Proxy(instance, {
|
|
@@ -278,9 +279,9 @@ function useR(Model) {
|
|
|
278
279
|
return proxy;
|
|
279
280
|
}
|
|
280
281
|
__name(useR, "useR");
|
|
281
|
-
function useV(
|
|
282
|
+
function useV(module2) {
|
|
282
283
|
const { useVMap, fnMap, computedMap } = getActivePhecda();
|
|
283
|
-
const instance = useO(
|
|
284
|
+
const instance = useO(module2);
|
|
284
285
|
if (useVMap.has(instance))
|
|
285
286
|
return useVMap.get(instance);
|
|
286
287
|
computedMap.set(instance, {});
|
|
@@ -320,9 +321,9 @@ function useEvent(eventName, cb) {
|
|
|
320
321
|
return () => emitter.off(eventName, cb);
|
|
321
322
|
}
|
|
322
323
|
__name(useEvent, "useEvent");
|
|
323
|
-
function initialize(
|
|
324
|
-
const instance = useO(
|
|
325
|
-
const newInstance = new
|
|
324
|
+
function initialize(module2, deleteOtherProperty = true) {
|
|
325
|
+
const instance = useO(module2);
|
|
326
|
+
const newInstance = new module2();
|
|
326
327
|
Object.assign(instance, newInstance);
|
|
327
328
|
if (deleteOtherProperty) {
|
|
328
329
|
for (const key in instance) {
|
package/dist/index.mjs
CHANGED
|
@@ -118,7 +118,7 @@ __name(getReactiveMap, "getReactiveMap");
|
|
|
118
118
|
|
|
119
119
|
// src/vue/composable.ts
|
|
120
120
|
import { onBeforeUnmount, reactive, toRaw, toRef } from "vue";
|
|
121
|
-
import { getHandler, register } from "phecda-core";
|
|
121
|
+
import { getHandler, getTag as getTag2, register } from "phecda-core";
|
|
122
122
|
|
|
123
123
|
// src/vue/utils.ts
|
|
124
124
|
import { effectScope, isReactive, isRef, onScopeDispose } from "vue";
|
|
@@ -184,28 +184,29 @@ function createSharedReactive(composable) {
|
|
|
184
184
|
__name(createSharedReactive, "createSharedReactive");
|
|
185
185
|
|
|
186
186
|
// src/vue/composable.ts
|
|
187
|
-
function useO(
|
|
187
|
+
function useO(module) {
|
|
188
188
|
const { useOMap } = getActivePhecda();
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
const tag = getTag2(module) || module.name;
|
|
190
|
+
if (!useOMap.has(tag)) {
|
|
191
|
+
const instance = reactive(new module());
|
|
192
|
+
useOMap.set(tag, instance);
|
|
192
193
|
register(instance);
|
|
193
194
|
}
|
|
194
|
-
return useOMap.get(
|
|
195
|
+
return useOMap.get(tag);
|
|
195
196
|
}
|
|
196
197
|
__name(useO, "useO");
|
|
197
|
-
function useRaw(
|
|
198
|
-
return toRaw(useO(
|
|
198
|
+
function useRaw(module) {
|
|
199
|
+
return toRaw(useO(module));
|
|
199
200
|
}
|
|
200
201
|
__name(useRaw, "useRaw");
|
|
201
|
-
function usePatch(
|
|
202
|
-
const instance = useO(
|
|
202
|
+
function usePatch(module, Data) {
|
|
203
|
+
const instance = useO(module);
|
|
203
204
|
mergeReactiveObjects(instance, Data);
|
|
204
205
|
}
|
|
205
206
|
__name(usePatch, "usePatch");
|
|
206
|
-
function useR(
|
|
207
|
+
function useR(module) {
|
|
207
208
|
const { useRMap, fnMap } = getActivePhecda();
|
|
208
|
-
const instance = useO(
|
|
209
|
+
const instance = useO(module);
|
|
209
210
|
if (useRMap.has(instance))
|
|
210
211
|
return useRMap.get(instance);
|
|
211
212
|
const proxy = new Proxy(instance, {
|
|
@@ -231,9 +232,9 @@ function useR(Model) {
|
|
|
231
232
|
return proxy;
|
|
232
233
|
}
|
|
233
234
|
__name(useR, "useR");
|
|
234
|
-
function useV(
|
|
235
|
+
function useV(module) {
|
|
235
236
|
const { useVMap, fnMap, computedMap } = getActivePhecda();
|
|
236
|
-
const instance = useO(
|
|
237
|
+
const instance = useO(module);
|
|
237
238
|
if (useVMap.has(instance))
|
|
238
239
|
return useVMap.get(instance);
|
|
239
240
|
computedMap.set(instance, {});
|
|
@@ -273,9 +274,9 @@ function useEvent(eventName, cb) {
|
|
|
273
274
|
return () => emitter.off(eventName, cb);
|
|
274
275
|
}
|
|
275
276
|
__name(useEvent, "useEvent");
|
|
276
|
-
function initialize(
|
|
277
|
-
const instance = useO(
|
|
278
|
-
const newInstance = new
|
|
277
|
+
function initialize(module, deleteOtherProperty = true) {
|
|
278
|
+
const instance = useO(module);
|
|
279
|
+
const newInstance = new module();
|
|
279
280
|
Object.assign(instance, newInstance);
|
|
280
281
|
if (deleteOtherProperty) {
|
|
281
282
|
for (const key in instance) {
|