phecda-vue 5.1.0 → 5.1.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.js +9 -2
- package/dist/index.mjs +11 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -552,16 +552,23 @@ function hasI(model) {
|
|
|
552
552
|
__name(hasI, "hasI");
|
|
553
553
|
function useIR(model, forceProvide = false) {
|
|
554
554
|
const tag = (0, import_phecda_web4.getTag)(model);
|
|
555
|
+
const instance = (0, import_vue5.getCurrentInstance)();
|
|
556
|
+
if (!instance["phecda-vue"]) instance["phecda-vue"] = /* @__PURE__ */ new WeakMap();
|
|
557
|
+
const modelMap = instance["phecda-vue"];
|
|
555
558
|
const injectKey = `phecda-vue:lib ${tag.toString()}`;
|
|
556
|
-
let existModule = (0, import_vue5.inject)(injectKey);
|
|
559
|
+
let existModule = modelMap.get(model) || (0, import_vue5.inject)(injectKey);
|
|
557
560
|
if (!existModule || forceProvide) {
|
|
558
561
|
const data = {
|
|
559
562
|
// keep class name
|
|
560
563
|
[model.name]: class extends model {
|
|
561
564
|
}
|
|
562
565
|
};
|
|
563
|
-
|
|
566
|
+
const paramtypes = (0, import_phecda_web4.getParamtypes)(model) || [];
|
|
567
|
+
existModule = (0, import_phecda_web4.bindMethod)((0, import_vue5.reactive)(new data[model.name](...paramtypes.map((param) => useIR(param)))));
|
|
568
|
+
(0, import_phecda_web4.invokeInit)(existModule);
|
|
564
569
|
(0, import_vue5.provide)(injectKey, existModule);
|
|
570
|
+
modelMap.set(model, existModule);
|
|
571
|
+
(0, import_vue5.onBeforeUnmount)(() => (0, import_phecda_web4.invokeUnmount)(existModule));
|
|
565
572
|
return existModule;
|
|
566
573
|
} else {
|
|
567
574
|
return existModule;
|
package/dist/index.mjs
CHANGED
|
@@ -501,8 +501,8 @@ function WatchEffect(option) {
|
|
|
501
501
|
__name(WatchEffect, "WatchEffect");
|
|
502
502
|
|
|
503
503
|
// src/lib.ts
|
|
504
|
-
import { bindMethod as bindMethod3, getTag as getTag3 } from "phecda-web";
|
|
505
|
-
import { inject as inject2, provide, reactive as reactive2, toRef as toRef2 } from "vue";
|
|
504
|
+
import { bindMethod as bindMethod3, getParamtypes, getTag as getTag3, invokeInit, invokeUnmount } from "phecda-web";
|
|
505
|
+
import { getCurrentInstance as getCurrentInstance2, inject as inject2, onBeforeUnmount as onBeforeUnmount2, provide, reactive as reactive2, toRef as toRef2 } from "vue";
|
|
506
506
|
function hasI(model) {
|
|
507
507
|
const tag = getTag3(model);
|
|
508
508
|
const injectKey = `phecda-vue:lib ${tag.toString()}`;
|
|
@@ -511,16 +511,23 @@ function hasI(model) {
|
|
|
511
511
|
__name(hasI, "hasI");
|
|
512
512
|
function useIR(model, forceProvide = false) {
|
|
513
513
|
const tag = getTag3(model);
|
|
514
|
+
const instance = getCurrentInstance2();
|
|
515
|
+
if (!instance["phecda-vue"]) instance["phecda-vue"] = /* @__PURE__ */ new WeakMap();
|
|
516
|
+
const modelMap = instance["phecda-vue"];
|
|
514
517
|
const injectKey = `phecda-vue:lib ${tag.toString()}`;
|
|
515
|
-
let existModule = inject2(injectKey);
|
|
518
|
+
let existModule = modelMap.get(model) || inject2(injectKey);
|
|
516
519
|
if (!existModule || forceProvide) {
|
|
517
520
|
const data = {
|
|
518
521
|
// keep class name
|
|
519
522
|
[model.name]: class extends model {
|
|
520
523
|
}
|
|
521
524
|
};
|
|
522
|
-
|
|
525
|
+
const paramtypes = getParamtypes(model) || [];
|
|
526
|
+
existModule = bindMethod3(reactive2(new data[model.name](...paramtypes.map((param) => useIR(param)))));
|
|
527
|
+
invokeInit(existModule);
|
|
523
528
|
provide(injectKey, existModule);
|
|
529
|
+
modelMap.set(model, existModule);
|
|
530
|
+
onBeforeUnmount2(() => invokeUnmount(existModule));
|
|
524
531
|
return existModule;
|
|
525
532
|
} else {
|
|
526
533
|
return existModule;
|