phecda-vue 2.1.3-alpha.2 → 2.1.3-alpha.4
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 +11 -10
- package/dist/index.js +26 -19
- package/dist/index.mjs +25 -19
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Events } from 'phecda-core';
|
|
1
|
+
import { Events, Construct } from 'phecda-core';
|
|
2
2
|
export * from 'phecda-core';
|
|
3
3
|
import * as vue from 'vue';
|
|
4
4
|
import { Ref, App, UnwrapNestedRefs } from 'vue';
|
|
@@ -34,17 +34,18 @@ 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
|
|
42
|
-
declare function useRaw<T extends
|
|
43
|
-
declare function usePatch<T extends
|
|
44
|
-
declare function useR<T extends
|
|
45
|
-
declare function useV<T extends
|
|
41
|
+
declare function useO<T extends Construct>(module: T): UnwrapNestedRefs<InstanceType<T>>;
|
|
42
|
+
declare function useRaw<T extends Construct>(module: T): InstanceType<T>;
|
|
43
|
+
declare function usePatch<T extends Construct>(module: T, Data: DeepPartial<InstanceType<T>>): void;
|
|
44
|
+
declare function useR<T extends Construct>(module: T): UnwrapNestedRefs<InstanceType<T>>;
|
|
45
|
+
declare function useV<T extends Construct>(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
|
|
47
|
+
declare function initialize<M extends Construct>(module: M, deleteOtherProperty?: boolean): InstanceType<M> | void;
|
|
48
|
+
declare function waitUntilInit(...modules: Construct[]): Promise<void>;
|
|
48
49
|
|
|
49
50
|
declare const RE: RegExp;
|
|
50
51
|
declare function createFilter<Data extends Record<string, any>>(initState?: Object, option?: {
|
|
@@ -75,4 +76,4 @@ declare class PV {
|
|
|
75
76
|
off<Key extends keyof Events>(type: Key, handler?: (arg: Events[Key]) => void): void;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
export { PV, PhecdaEmitter, PhecdaInstance, RE, ReplaceInstanceValues, SchemaToObj, createFilter, createPhecda, emitter, getActivePhecda, getReactiveMap, initialize, interval, phecdaSymbol, setActivePhecda, useEvent, useO, usePatch, useR, useRaw, useV };
|
|
79
|
+
export { PV, PhecdaEmitter, PhecdaInstance, RE, ReplaceInstanceValues, SchemaToObj, createFilter, createPhecda, emitter, getActivePhecda, getReactiveMap, initialize, interval, phecdaSymbol, setActivePhecda, useEvent, useO, usePatch, useR, useRaw, useV, waitUntilInit };
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,8 @@ __export(src_exports, {
|
|
|
44
44
|
usePatch: () => usePatch,
|
|
45
45
|
useR: () => useR,
|
|
46
46
|
useRaw: () => useRaw,
|
|
47
|
-
useV: () => useV
|
|
47
|
+
useV: () => useV,
|
|
48
|
+
waitUntilInit: () => waitUntilInit
|
|
48
49
|
});
|
|
49
50
|
module.exports = __toCommonJS(src_exports);
|
|
50
51
|
|
|
@@ -231,28 +232,29 @@ function createSharedReactive(composable) {
|
|
|
231
232
|
__name(createSharedReactive, "createSharedReactive");
|
|
232
233
|
|
|
233
234
|
// src/vue/composable.ts
|
|
234
|
-
function useO(
|
|
235
|
+
function useO(module2) {
|
|
235
236
|
const { useOMap } = getActivePhecda();
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
(
|
|
237
|
+
const tag = (0, import_phecda_core2.getTag)(module2) || module2.name;
|
|
238
|
+
if (!useOMap.has(tag)) {
|
|
239
|
+
const instance = (0, import_vue3.reactive)(new module2());
|
|
240
|
+
useOMap.set(tag, instance);
|
|
241
|
+
instance._promise = (0, import_phecda_core2.registerAsync)(instance);
|
|
240
242
|
}
|
|
241
|
-
return useOMap.get(
|
|
243
|
+
return useOMap.get(tag);
|
|
242
244
|
}
|
|
243
245
|
__name(useO, "useO");
|
|
244
|
-
function useRaw(
|
|
245
|
-
return (0, import_vue3.toRaw)(useO(
|
|
246
|
+
function useRaw(module2) {
|
|
247
|
+
return (0, import_vue3.toRaw)(useO(module2));
|
|
246
248
|
}
|
|
247
249
|
__name(useRaw, "useRaw");
|
|
248
|
-
function usePatch(
|
|
249
|
-
const instance = useO(
|
|
250
|
+
function usePatch(module2, Data) {
|
|
251
|
+
const instance = useO(module2);
|
|
250
252
|
mergeReactiveObjects(instance, Data);
|
|
251
253
|
}
|
|
252
254
|
__name(usePatch, "usePatch");
|
|
253
|
-
function useR(
|
|
255
|
+
function useR(module2) {
|
|
254
256
|
const { useRMap, fnMap } = getActivePhecda();
|
|
255
|
-
const instance = useO(
|
|
257
|
+
const instance = useO(module2);
|
|
256
258
|
if (useRMap.has(instance))
|
|
257
259
|
return useRMap.get(instance);
|
|
258
260
|
const proxy = new Proxy(instance, {
|
|
@@ -278,9 +280,9 @@ function useR(Model) {
|
|
|
278
280
|
return proxy;
|
|
279
281
|
}
|
|
280
282
|
__name(useR, "useR");
|
|
281
|
-
function useV(
|
|
283
|
+
function useV(module2) {
|
|
282
284
|
const { useVMap, fnMap, computedMap } = getActivePhecda();
|
|
283
|
-
const instance = useO(
|
|
285
|
+
const instance = useO(module2);
|
|
284
286
|
if (useVMap.has(instance))
|
|
285
287
|
return useVMap.get(instance);
|
|
286
288
|
computedMap.set(instance, {});
|
|
@@ -320,9 +322,9 @@ function useEvent(eventName, cb) {
|
|
|
320
322
|
return () => emitter.off(eventName, cb);
|
|
321
323
|
}
|
|
322
324
|
__name(useEvent, "useEvent");
|
|
323
|
-
function initialize(
|
|
324
|
-
const instance = useO(
|
|
325
|
-
const newInstance = new
|
|
325
|
+
function initialize(module2, deleteOtherProperty = true) {
|
|
326
|
+
const instance = useO(module2);
|
|
327
|
+
const newInstance = new module2();
|
|
326
328
|
Object.assign(instance, newInstance);
|
|
327
329
|
if (deleteOtherProperty) {
|
|
328
330
|
for (const key in instance) {
|
|
@@ -332,6 +334,10 @@ function initialize(Model, deleteOtherProperty = true) {
|
|
|
332
334
|
}
|
|
333
335
|
}
|
|
334
336
|
__name(initialize, "initialize");
|
|
337
|
+
async function waitUntilInit(...modules) {
|
|
338
|
+
await Promise.all(modules.map((m) => useO(m)._promise));
|
|
339
|
+
}
|
|
340
|
+
__name(waitUntilInit, "waitUntilInit");
|
|
335
341
|
|
|
336
342
|
// src/filter.ts
|
|
337
343
|
var import_vue4 = require("vue");
|
|
@@ -467,5 +473,6 @@ __name(PV, "PV");
|
|
|
467
473
|
usePatch,
|
|
468
474
|
useR,
|
|
469
475
|
useRaw,
|
|
470
|
-
useV
|
|
476
|
+
useV,
|
|
477
|
+
waitUntilInit
|
|
471
478
|
});
|
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,
|
|
121
|
+
import { getHandler, getTag as getTag2, registerAsync } 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
|
-
|
|
192
|
-
|
|
189
|
+
const tag = getTag2(module) || module.name;
|
|
190
|
+
if (!useOMap.has(tag)) {
|
|
191
|
+
const instance = reactive(new module());
|
|
192
|
+
useOMap.set(tag, instance);
|
|
193
|
+
instance._promise = registerAsync(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) {
|
|
@@ -285,6 +286,10 @@ function initialize(Model, deleteOtherProperty = true) {
|
|
|
285
286
|
}
|
|
286
287
|
}
|
|
287
288
|
__name(initialize, "initialize");
|
|
289
|
+
async function waitUntilInit(...modules) {
|
|
290
|
+
await Promise.all(modules.map((m) => useO(m)._promise));
|
|
291
|
+
}
|
|
292
|
+
__name(waitUntilInit, "waitUntilInit");
|
|
288
293
|
|
|
289
294
|
// src/filter.ts
|
|
290
295
|
import { effectScope as effectScope2, ref } from "vue";
|
|
@@ -419,5 +424,6 @@ export {
|
|
|
419
424
|
usePatch,
|
|
420
425
|
useR,
|
|
421
426
|
useRaw,
|
|
422
|
-
useV
|
|
427
|
+
useV,
|
|
428
|
+
waitUntilInit
|
|
423
429
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-vue",
|
|
3
|
-
"version": "2.1.3-alpha.
|
|
3
|
+
"version": "2.1.3-alpha.4",
|
|
4
4
|
"description": "provide store/form/table with phecda function to vue",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"mitt": "^3.0.0",
|
|
16
16
|
"vue": "^3.2.45",
|
|
17
|
-
"phecda-core": "3.0.0-alpha.
|
|
17
|
+
"phecda-core": "3.0.0-alpha.2"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"tsup": "^6.5.0"
|