phecda-vue 5.1.2 → 5.2.0-alpha.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 +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +17 -7
- package/dist/index.mjs +16 -7
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -17,20 +17,21 @@ type ReplaceInstanceValues<I> = {
|
|
|
17
17
|
[P in keyof I]: I[P] extends (...args: any[]) => any ? I[P] : I[P] extends Raw<infer O> ? O : Ref<I[P]>;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
declare function useRaw<
|
|
21
|
-
declare function getRaw<
|
|
20
|
+
declare function useRaw<Model extends Construct>(model: Model): InstanceType<Model>;
|
|
21
|
+
declare function getRaw<Model extends Construct>(model: Model): InstanceType<Model>;
|
|
22
22
|
declare function usePhecda(): VuePhecda;
|
|
23
23
|
declare function getPhecda(phecda?: VuePhecda): VuePhecda;
|
|
24
24
|
declare function useEvent<Key extends keyof Events>(eventName: Key, cb: (event: Events[Key]) => void): {
|
|
25
25
|
emit: (arg: Events[Key]) => void;
|
|
26
26
|
cancel: () => void;
|
|
27
27
|
};
|
|
28
|
-
declare function useR<
|
|
29
|
-
declare function getR<
|
|
30
|
-
declare function useV<
|
|
31
|
-
declare function getV<
|
|
28
|
+
declare function useR<Model extends Construct>(model: Model): UnwrapNestedRefs<InstanceType<Model>>;
|
|
29
|
+
declare function getR<Model extends Construct>(model: Model, phecda?: VuePhecda): UnwrapNestedRefs<InstanceType<Model>>;
|
|
30
|
+
declare function useV<Model extends Construct>(model: Model): ReplaceInstanceValues<InstanceType<Model>>;
|
|
31
|
+
declare function getV<Model extends Construct>(model: Model, phecda?: VuePhecda): ReplaceInstanceValues<InstanceType<Model>>;
|
|
32
32
|
|
|
33
33
|
declare function Shallow(model: any): void;
|
|
34
|
+
declare function KeepAlive(isKeepAlive?: boolean): (model: any) => void;
|
|
34
35
|
declare function WatchEffect(option?: WatchOptions): (proto: any, key: string) => void;
|
|
35
36
|
|
|
36
37
|
declare function markRaw<T extends object>(value: T): Raw<T>;
|
|
@@ -40,4 +41,4 @@ declare function hasI(model: Construct): boolean;
|
|
|
40
41
|
declare function useIR<T extends Construct>(model: T, forceProvide?: boolean): UnwrapNestedRefs<InstanceType<T>>;
|
|
41
42
|
declare function useIV<T extends Construct>(model: T, forceProvide?: boolean): ReplaceInstanceValues<InstanceType<T>>;
|
|
42
43
|
|
|
43
|
-
export { type Raw, RawSymbol, type ReplaceInstanceValues, Shallow, VuePhecda, WatchEffect, createPhecda, createSharedReactive, getPhecda, getR, getRaw, getV, hasI, markRaw, phecdaSymbol, useEvent, useIR, useIV, usePhecda, useR, useRaw, useV };
|
|
44
|
+
export { KeepAlive, type Raw, RawSymbol, type ReplaceInstanceValues, Shallow, VuePhecda, WatchEffect, createPhecda, createSharedReactive, getPhecda, getR, getRaw, getV, hasI, markRaw, phecdaSymbol, useEvent, useIR, useIV, usePhecda, useR, useRaw, useV };
|
package/dist/index.d.ts
CHANGED
|
@@ -17,20 +17,21 @@ type ReplaceInstanceValues<I> = {
|
|
|
17
17
|
[P in keyof I]: I[P] extends (...args: any[]) => any ? I[P] : I[P] extends Raw<infer O> ? O : Ref<I[P]>;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
declare function useRaw<
|
|
21
|
-
declare function getRaw<
|
|
20
|
+
declare function useRaw<Model extends Construct>(model: Model): InstanceType<Model>;
|
|
21
|
+
declare function getRaw<Model extends Construct>(model: Model): InstanceType<Model>;
|
|
22
22
|
declare function usePhecda(): VuePhecda;
|
|
23
23
|
declare function getPhecda(phecda?: VuePhecda): VuePhecda;
|
|
24
24
|
declare function useEvent<Key extends keyof Events>(eventName: Key, cb: (event: Events[Key]) => void): {
|
|
25
25
|
emit: (arg: Events[Key]) => void;
|
|
26
26
|
cancel: () => void;
|
|
27
27
|
};
|
|
28
|
-
declare function useR<
|
|
29
|
-
declare function getR<
|
|
30
|
-
declare function useV<
|
|
31
|
-
declare function getV<
|
|
28
|
+
declare function useR<Model extends Construct>(model: Model): UnwrapNestedRefs<InstanceType<Model>>;
|
|
29
|
+
declare function getR<Model extends Construct>(model: Model, phecda?: VuePhecda): UnwrapNestedRefs<InstanceType<Model>>;
|
|
30
|
+
declare function useV<Model extends Construct>(model: Model): ReplaceInstanceValues<InstanceType<Model>>;
|
|
31
|
+
declare function getV<Model extends Construct>(model: Model, phecda?: VuePhecda): ReplaceInstanceValues<InstanceType<Model>>;
|
|
32
32
|
|
|
33
33
|
declare function Shallow(model: any): void;
|
|
34
|
+
declare function KeepAlive(isKeepAlive?: boolean): (model: any) => void;
|
|
34
35
|
declare function WatchEffect(option?: WatchOptions): (proto: any, key: string) => void;
|
|
35
36
|
|
|
36
37
|
declare function markRaw<T extends object>(value: T): Raw<T>;
|
|
@@ -40,4 +41,4 @@ declare function hasI(model: Construct): boolean;
|
|
|
40
41
|
declare function useIR<T extends Construct>(model: T, forceProvide?: boolean): UnwrapNestedRefs<InstanceType<T>>;
|
|
41
42
|
declare function useIV<T extends Construct>(model: T, forceProvide?: boolean): ReplaceInstanceValues<InstanceType<T>>;
|
|
42
43
|
|
|
43
|
-
export { type Raw, RawSymbol, type ReplaceInstanceValues, Shallow, VuePhecda, WatchEffect, createPhecda, createSharedReactive, getPhecda, getR, getRaw, getV, hasI, markRaw, phecdaSymbol, useEvent, useIR, useIV, usePhecda, useR, useRaw, useV };
|
|
44
|
+
export { KeepAlive, type Raw, RawSymbol, type ReplaceInstanceValues, Shallow, VuePhecda, WatchEffect, createPhecda, createSharedReactive, getPhecda, getR, getRaw, getV, hasI, markRaw, phecdaSymbol, useEvent, useIR, useIV, usePhecda, useR, useRaw, useV };
|
package/dist/index.js
CHANGED
|
@@ -20,8 +20,9 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
22
|
// src/index.ts
|
|
23
|
-
var
|
|
24
|
-
__export(
|
|
23
|
+
var index_exports = {};
|
|
24
|
+
__export(index_exports, {
|
|
25
|
+
KeepAlive: () => KeepAlive,
|
|
25
26
|
Shallow: () => Shallow,
|
|
26
27
|
VuePhecda: () => VuePhecda,
|
|
27
28
|
WatchEffect: () => WatchEffect,
|
|
@@ -42,8 +43,8 @@ __export(src_exports, {
|
|
|
42
43
|
useRaw: () => useRaw,
|
|
43
44
|
useV: () => useV
|
|
44
45
|
});
|
|
45
|
-
module.exports = __toCommonJS(
|
|
46
|
-
__reExport(
|
|
46
|
+
module.exports = __toCommonJS(index_exports);
|
|
47
|
+
__reExport(index_exports, require("phecda-web"), module.exports);
|
|
47
48
|
|
|
48
49
|
// src/core.ts
|
|
49
50
|
var import_vue = require("vue");
|
|
@@ -451,7 +452,7 @@ function getPhecda(phecda) {
|
|
|
451
452
|
}
|
|
452
453
|
__name(getPhecda, "getPhecda");
|
|
453
454
|
function useEvent(eventName, cb) {
|
|
454
|
-
(0, import_vue3.
|
|
455
|
+
(0, import_vue3.onUnmounted)(() => {
|
|
455
456
|
import_phecda_web2.emitter.off(eventName, cb);
|
|
456
457
|
});
|
|
457
458
|
import_phecda_web2.emitter.on(eventName, cb);
|
|
@@ -462,8 +463,10 @@ function useEvent(eventName, cb) {
|
|
|
462
463
|
}
|
|
463
464
|
__name(useEvent, "useEvent");
|
|
464
465
|
function useR(model) {
|
|
466
|
+
const phecda = usePhecda();
|
|
467
|
+
if (phecda.has(model) && (0, import_phecda_web2.get)(model.prototype, "keepAlive") === false) (0, import_vue3.onUnmounted)(() => phecda.unmount(model));
|
|
465
468
|
setMetaToComponent(model);
|
|
466
|
-
return
|
|
469
|
+
return phecda.init(model);
|
|
467
470
|
}
|
|
468
471
|
__name(useR, "useR");
|
|
469
472
|
function getR(model, phecda) {
|
|
@@ -472,7 +475,9 @@ function getR(model, phecda) {
|
|
|
472
475
|
__name(getR, "getR");
|
|
473
476
|
function useV(model) {
|
|
474
477
|
setMetaToComponent(model);
|
|
475
|
-
const
|
|
478
|
+
const phecda = usePhecda();
|
|
479
|
+
if (phecda.has(model) && (0, import_phecda_web2.get)(model.prototype, "keepAlive") === false) (0, import_vue3.onUnmounted)(() => phecda.unmount(model));
|
|
480
|
+
const instance = phecda.init(model);
|
|
476
481
|
if (cacheMap.has(instance)) return cacheMap.get(instance);
|
|
477
482
|
const cache = {};
|
|
478
483
|
const proxy = new Proxy(instance, {
|
|
@@ -525,6 +530,10 @@ function Shallow(model) {
|
|
|
525
530
|
(0, import_phecda_web3.set)(model.prototype, "shallow", true);
|
|
526
531
|
}
|
|
527
532
|
__name(Shallow, "Shallow");
|
|
533
|
+
function KeepAlive(isKeepAlive = true) {
|
|
534
|
+
return (model) => (0, import_phecda_web3.set)(model.prototype, "keepAlive", isKeepAlive);
|
|
535
|
+
}
|
|
536
|
+
__name(KeepAlive, "KeepAlive");
|
|
528
537
|
function WatchEffect(option) {
|
|
529
538
|
return (proto, key) => {
|
|
530
539
|
let stopHandler;
|
|
@@ -601,6 +610,7 @@ function useIV(model, forceProvide = false) {
|
|
|
601
610
|
__name(useIV, "useIV");
|
|
602
611
|
// Annotate the CommonJS export names for ESM import in node:
|
|
603
612
|
0 && (module.exports = {
|
|
613
|
+
KeepAlive,
|
|
604
614
|
Shallow,
|
|
605
615
|
VuePhecda,
|
|
606
616
|
WatchEffect,
|
package/dist/index.mjs
CHANGED
|
@@ -339,8 +339,8 @@ function getAllGetters(obj) {
|
|
|
339
339
|
__name(getAllGetters, "getAllGetters");
|
|
340
340
|
|
|
341
341
|
// src/composable.ts
|
|
342
|
-
import { bindMethod as bindMethod2, emitter, getDefaultPhecda, getTag as getTag2 } from "phecda-web";
|
|
343
|
-
import { getCurrentInstance, hasInjectionContext, inject,
|
|
342
|
+
import { bindMethod as bindMethod2, emitter, get as get2, getDefaultPhecda, getTag as getTag2 } from "phecda-web";
|
|
343
|
+
import { getCurrentInstance, hasInjectionContext, inject, onUnmounted, toRaw as toRaw2, toRef } from "vue";
|
|
344
344
|
|
|
345
345
|
// src/utils.ts
|
|
346
346
|
import { effectScope, onScopeDispose, markRaw as raw } from "vue";
|
|
@@ -410,7 +410,7 @@ function getPhecda(phecda) {
|
|
|
410
410
|
}
|
|
411
411
|
__name(getPhecda, "getPhecda");
|
|
412
412
|
function useEvent(eventName, cb) {
|
|
413
|
-
|
|
413
|
+
onUnmounted(() => {
|
|
414
414
|
emitter.off(eventName, cb);
|
|
415
415
|
});
|
|
416
416
|
emitter.on(eventName, cb);
|
|
@@ -421,8 +421,10 @@ function useEvent(eventName, cb) {
|
|
|
421
421
|
}
|
|
422
422
|
__name(useEvent, "useEvent");
|
|
423
423
|
function useR(model) {
|
|
424
|
+
const phecda = usePhecda();
|
|
425
|
+
if (phecda.has(model) && get2(model.prototype, "keepAlive") === false) onUnmounted(() => phecda.unmount(model));
|
|
424
426
|
setMetaToComponent(model);
|
|
425
|
-
return
|
|
427
|
+
return phecda.init(model);
|
|
426
428
|
}
|
|
427
429
|
__name(useR, "useR");
|
|
428
430
|
function getR(model, phecda) {
|
|
@@ -431,7 +433,9 @@ function getR(model, phecda) {
|
|
|
431
433
|
__name(getR, "getR");
|
|
432
434
|
function useV(model) {
|
|
433
435
|
setMetaToComponent(model);
|
|
434
|
-
const
|
|
436
|
+
const phecda = usePhecda();
|
|
437
|
+
if (phecda.has(model) && get2(model.prototype, "keepAlive") === false) onUnmounted(() => phecda.unmount(model));
|
|
438
|
+
const instance = phecda.init(model);
|
|
435
439
|
if (cacheMap.has(instance)) return cacheMap.get(instance);
|
|
436
440
|
const cache = {};
|
|
437
441
|
const proxy = new Proxy(instance, {
|
|
@@ -484,6 +488,10 @@ function Shallow(model) {
|
|
|
484
488
|
set(model.prototype, "shallow", true);
|
|
485
489
|
}
|
|
486
490
|
__name(Shallow, "Shallow");
|
|
491
|
+
function KeepAlive(isKeepAlive = true) {
|
|
492
|
+
return (model) => set(model.prototype, "keepAlive", isKeepAlive);
|
|
493
|
+
}
|
|
494
|
+
__name(KeepAlive, "KeepAlive");
|
|
487
495
|
function WatchEffect(option) {
|
|
488
496
|
return (proto, key) => {
|
|
489
497
|
let stopHandler;
|
|
@@ -502,7 +510,7 @@ __name(WatchEffect, "WatchEffect");
|
|
|
502
510
|
|
|
503
511
|
// src/lib.ts
|
|
504
512
|
import { bindMethod as bindMethod3, getParamtypes, getTag as getTag3, invokeInit, invokeUnmount } from "phecda-web";
|
|
505
|
-
import { getCurrentInstance as getCurrentInstance2, inject as inject2, onBeforeUnmount
|
|
513
|
+
import { getCurrentInstance as getCurrentInstance2, inject as inject2, onBeforeUnmount, provide, reactive as reactive2, toRef as toRef2 } from "vue";
|
|
506
514
|
function hasI(model) {
|
|
507
515
|
const tag = getTag3(model);
|
|
508
516
|
const injectKey = `phecda-vue:lib ${tag.toString()}`;
|
|
@@ -527,7 +535,7 @@ function useIR(model, forceProvide = false) {
|
|
|
527
535
|
invokeInit(existModule);
|
|
528
536
|
provide(injectKey, existModule);
|
|
529
537
|
modelMap.set(model, existModule);
|
|
530
|
-
|
|
538
|
+
onBeforeUnmount(() => invokeUnmount(existModule));
|
|
531
539
|
return existModule;
|
|
532
540
|
} else {
|
|
533
541
|
return existModule;
|
|
@@ -559,6 +567,7 @@ function useIV(model, forceProvide = false) {
|
|
|
559
567
|
}
|
|
560
568
|
__name(useIV, "useIV");
|
|
561
569
|
export {
|
|
570
|
+
KeepAlive,
|
|
562
571
|
Shallow,
|
|
563
572
|
VuePhecda,
|
|
564
573
|
WatchEffect,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-vue",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.0-alpha.1",
|
|
4
4
|
"description": "provide phecda function to vue",
|
|
5
5
|
"author": "fgsreally",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@vue/devtools-api": "^6.6.3",
|
|
20
20
|
"vue": "^3.2.45",
|
|
21
|
-
"phecda-web": "3.0.1"
|
|
21
|
+
"phecda-web": "3.0.2-alpha.1"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@vue/test-utils": "^2.4.6",
|