phecda-vue 1.2.4 → 1.2.6
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 +18 -17
- package/dist/index.js +45 -23
- package/dist/index.mjs +45 -23
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { PhecdaEvents } from 'phecda-core';
|
|
2
|
+
export * from 'phecda-core';
|
|
3
3
|
import * as vue from 'vue';
|
|
4
4
|
import { Ref, App, UnwrapNestedRefs, Component, DefineComponent, VNode } from 'vue';
|
|
5
|
-
|
|
5
|
+
import { Handler } from 'mitt';
|
|
6
6
|
|
|
7
7
|
type ReadonlyValue<T> = {
|
|
8
8
|
readonly [K in keyof T]: K extends 'value' ? T[K] : ReadonlyValue<T[K]>;
|
|
@@ -16,28 +16,21 @@ type ReplaceInstanceValues<I> = {
|
|
|
16
16
|
type SchemaToObj<S> = {
|
|
17
17
|
[P in keyof S]: S[P] extends object ? SchemaToObj<S[P]> : (S[P] extends string ? any : S[P]);
|
|
18
18
|
};
|
|
19
|
-
interface
|
|
20
|
-
|
|
19
|
+
interface PhecdaEmitter {
|
|
20
|
+
on<N extends keyof PhecdaEvents>(eventName: N, cb: (args: PhecdaEvents[N]) => void): void;
|
|
21
|
+
off<N extends keyof PhecdaEvents>(eventName: N, cb?: (args: PhecdaEvents[N]) => void): void;
|
|
22
|
+
emit<N extends keyof PhecdaEvents>(eventName: N, param: PhecdaEvents[N]): void;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
declare const emitter:
|
|
24
|
-
declare const invokeAction: {
|
|
25
|
-
<Key extends keyof PhecdaEvents>(type: Key, event: PhecdaEvents[Key]): void;
|
|
26
|
-
<Key_1 extends keyof PhecdaEvents>(type: undefined extends PhecdaEvents[Key_1] ? Key_1 : never): void;
|
|
27
|
-
};
|
|
25
|
+
declare const emitter: PhecdaEmitter;
|
|
28
26
|
|
|
29
27
|
declare const phecdaSymbol: unique symbol;
|
|
30
28
|
declare function createPhecda(symbol?: string): vue.Raw<{
|
|
31
29
|
install(app: App): void;
|
|
32
|
-
useVMap: WeakMap<object, any>;
|
|
33
|
-
useOMap: WeakMap<object, any>;
|
|
34
|
-
useRMap: WeakMap<object, any>;
|
|
35
|
-
fnMap: WeakMap<object, any>;
|
|
36
|
-
computedMap: WeakMap<object, any>;
|
|
37
30
|
}>;
|
|
38
31
|
interface PhecdaInstance {
|
|
39
32
|
useVMap: WeakMap<any, any>;
|
|
40
|
-
useOMap:
|
|
33
|
+
useOMap: Map<any, any>;
|
|
41
34
|
useRMap: WeakMap<any, any>;
|
|
42
35
|
fnMap: WeakMap<any, any>;
|
|
43
36
|
computedMap: WeakMap<any, any>;
|
|
@@ -125,4 +118,12 @@ interface PipeRet {
|
|
|
125
118
|
get: Record<string, () => VNode>;
|
|
126
119
|
}
|
|
127
120
|
|
|
128
|
-
|
|
121
|
+
declare class PV {
|
|
122
|
+
constructor();
|
|
123
|
+
get tag(): any;
|
|
124
|
+
on<Key extends keyof PhecdaEvents>(type: Key, handler: (arg: PhecdaEvents[Key]) => void): void;
|
|
125
|
+
emit<Key extends keyof PhecdaEvents>(type: Key, param: PhecdaEvents[Key]): void;
|
|
126
|
+
off<Key extends keyof PhecdaEvents>(type: Key, handler?: (arg: PhecdaEvents[Key]) => void): void;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { EXPRESS_RE, FN_RE, GetDevUIRules, PV, PhecdaEmitter, PublicOnly, ReplaceInstanceValues, SchemaToObj, clearStorage, createFilter, createForm, createFormData, createModal, createPhecda, createPipe, createTable, deleteStorage, emitter, getActivePhecda, getAntDRules, getElementPlusRules, getNaiveUIRules, getNutUIRules, getReactiveMap, getVantRules, initalize, phecdaSymbol, setActivePhecda, useEvent, useO, usePatch, useR, useV };
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __export(src_exports, {
|
|
|
31
31
|
EXPRESS_RE: () => EXPRESS_RE,
|
|
32
32
|
FN_RE: () => FN_RE,
|
|
33
33
|
GetDevUIRules: () => GetDevUIRules,
|
|
34
|
+
PV: () => PV,
|
|
34
35
|
clearStorage: () => clearStorage,
|
|
35
36
|
createFilter: () => createFilter,
|
|
36
37
|
createForm: () => createForm,
|
|
@@ -49,7 +50,6 @@ __export(src_exports, {
|
|
|
49
50
|
getReactiveMap: () => getReactiveMap,
|
|
50
51
|
getVantRules: () => getVantRules,
|
|
51
52
|
initalize: () => initalize,
|
|
52
|
-
invokeAction: () => invokeAction,
|
|
53
53
|
phecdaSymbol: () => phecdaSymbol,
|
|
54
54
|
setActivePhecda: () => setActivePhecda,
|
|
55
55
|
useEvent: () => useEvent,
|
|
@@ -63,7 +63,6 @@ module.exports = __toCommonJS(src_exports);
|
|
|
63
63
|
// src/emitter.ts
|
|
64
64
|
var import_mitt = __toESM(require("mitt"));
|
|
65
65
|
var emitter = (0, import_mitt.default)();
|
|
66
|
-
var invokeAction = emitter.emit.bind(emitter);
|
|
67
66
|
|
|
68
67
|
// src/vue/phecda.ts
|
|
69
68
|
var import_vue = require("vue");
|
|
@@ -81,7 +80,8 @@ function createPhecda(symbol) {
|
|
|
81
80
|
instance: phecda,
|
|
82
81
|
snapshot: () => {
|
|
83
82
|
const ret = [];
|
|
84
|
-
|
|
83
|
+
const { useOMap } = getActivePhecda();
|
|
84
|
+
for (const [key, value] of useOMap)
|
|
85
85
|
ret.push({
|
|
86
86
|
key: (0, import_phecda_core.getTag)(key) || key.name,
|
|
87
87
|
value
|
|
@@ -90,35 +90,43 @@ function createPhecda(symbol) {
|
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
(0, import_phecda_core.injectProperty)("watcher", ({ eventName, instance, key }) => {
|
|
93
|
+
let eventRecord = [];
|
|
94
|
+
(0, import_phecda_core.injectProperty)("watcher", ({ eventName, instance, key, options }) => {
|
|
95
95
|
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
if (options?.once) {
|
|
97
|
+
const handler = /* @__PURE__ */ __name((...args) => {
|
|
98
|
+
fn(...args);
|
|
99
|
+
emitter.off(eventName, handler);
|
|
100
|
+
}, "handler");
|
|
101
|
+
emitter.on(eventName, handler);
|
|
102
|
+
eventRecord.push([
|
|
103
|
+
eventName,
|
|
104
|
+
handler
|
|
105
|
+
]);
|
|
106
|
+
} else {
|
|
107
|
+
eventRecord.push([
|
|
108
|
+
eventName,
|
|
109
|
+
fn
|
|
110
|
+
]);
|
|
111
|
+
emitter.on(eventName, fn);
|
|
112
|
+
}
|
|
101
113
|
});
|
|
102
114
|
const originUnmount = app.unmount.bind(app);
|
|
103
115
|
app.unmount = () => {
|
|
104
116
|
eventRecord.forEach(([eventName, handler]) => emitter.off(eventName, handler));
|
|
117
|
+
eventRecord = [];
|
|
105
118
|
if (symbol)
|
|
106
119
|
delete window.__PHECDA_VUE__[symbol];
|
|
107
120
|
originUnmount();
|
|
108
121
|
};
|
|
109
|
-
}
|
|
110
|
-
useVMap: /* @__PURE__ */ new WeakMap(),
|
|
111
|
-
useOMap: new (symbol ? Map : WeakMap)(),
|
|
112
|
-
useRMap: /* @__PURE__ */ new WeakMap(),
|
|
113
|
-
fnMap: /* @__PURE__ */ new WeakMap(),
|
|
114
|
-
computedMap: /* @__PURE__ */ new WeakMap()
|
|
122
|
+
}
|
|
115
123
|
});
|
|
116
124
|
return phecda;
|
|
117
125
|
}
|
|
118
126
|
__name(createPhecda, "createPhecda");
|
|
119
127
|
var activePhecda = {
|
|
120
128
|
useVMap: /* @__PURE__ */ new WeakMap(),
|
|
121
|
-
useOMap: /* @__PURE__ */ new
|
|
129
|
+
useOMap: /* @__PURE__ */ new Map(),
|
|
122
130
|
useRMap: /* @__PURE__ */ new WeakMap(),
|
|
123
131
|
fnMap: /* @__PURE__ */ new WeakMap(),
|
|
124
132
|
computedMap: /* @__PURE__ */ new WeakMap()
|
|
@@ -211,11 +219,6 @@ __name(createSharedReactive, "createSharedReactive");
|
|
|
211
219
|
|
|
212
220
|
// src/vue/composable.ts
|
|
213
221
|
function useO(Model) {
|
|
214
|
-
if ((0, import_vue3.getCurrentInstance)()) {
|
|
215
|
-
const cur = (0, import_vue3.inject)(phecdaSymbol, null);
|
|
216
|
-
if (cur)
|
|
217
|
-
setActivePhecda(cur);
|
|
218
|
-
}
|
|
219
222
|
const { useOMap } = getActivePhecda();
|
|
220
223
|
if (!useOMap.has(Model)) {
|
|
221
224
|
const instance = (0, import_vue3.reactive)(new Model());
|
|
@@ -730,11 +733,31 @@ function createPipe(comp, props, to = "default", slot) {
|
|
|
730
733
|
};
|
|
731
734
|
}
|
|
732
735
|
__name(createPipe, "createPipe");
|
|
736
|
+
|
|
737
|
+
// src/wrapper.ts
|
|
738
|
+
var PV = class {
|
|
739
|
+
constructor() {
|
|
740
|
+
}
|
|
741
|
+
get tag() {
|
|
742
|
+
return this._namespace.__TAG__;
|
|
743
|
+
}
|
|
744
|
+
on(type, handler) {
|
|
745
|
+
emitter.on(type, handler);
|
|
746
|
+
}
|
|
747
|
+
emit(type, param) {
|
|
748
|
+
emitter.emit(type, param);
|
|
749
|
+
}
|
|
750
|
+
off(type, handler) {
|
|
751
|
+
emitter.off(type, handler);
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
__name(PV, "PV");
|
|
733
755
|
// Annotate the CommonJS export names for ESM import in node:
|
|
734
756
|
0 && (module.exports = {
|
|
735
757
|
EXPRESS_RE,
|
|
736
758
|
FN_RE,
|
|
737
759
|
GetDevUIRules,
|
|
760
|
+
PV,
|
|
738
761
|
clearStorage,
|
|
739
762
|
createFilter,
|
|
740
763
|
createForm,
|
|
@@ -753,7 +776,6 @@ __name(createPipe, "createPipe");
|
|
|
753
776
|
getReactiveMap,
|
|
754
777
|
getVantRules,
|
|
755
778
|
initalize,
|
|
756
|
-
invokeAction,
|
|
757
779
|
phecdaSymbol,
|
|
758
780
|
setActivePhecda,
|
|
759
781
|
useEvent,
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,6 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
4
4
|
// src/emitter.ts
|
|
5
5
|
import mitt from "mitt";
|
|
6
6
|
var emitter = mitt();
|
|
7
|
-
var invokeAction = emitter.emit.bind(emitter);
|
|
8
7
|
|
|
9
8
|
// src/vue/phecda.ts
|
|
10
9
|
import { markRaw } from "vue";
|
|
@@ -22,7 +21,8 @@ function createPhecda(symbol) {
|
|
|
22
21
|
instance: phecda,
|
|
23
22
|
snapshot: () => {
|
|
24
23
|
const ret = [];
|
|
25
|
-
|
|
24
|
+
const { useOMap } = getActivePhecda();
|
|
25
|
+
for (const [key, value] of useOMap)
|
|
26
26
|
ret.push({
|
|
27
27
|
key: getTag(key) || key.name,
|
|
28
28
|
value
|
|
@@ -31,35 +31,43 @@ function createPhecda(symbol) {
|
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
injectProperty("watcher", ({ eventName, instance, key }) => {
|
|
34
|
+
let eventRecord = [];
|
|
35
|
+
injectProperty("watcher", ({ eventName, instance, key, options }) => {
|
|
36
36
|
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
if (options?.once) {
|
|
38
|
+
const handler = /* @__PURE__ */ __name((...args) => {
|
|
39
|
+
fn(...args);
|
|
40
|
+
emitter.off(eventName, handler);
|
|
41
|
+
}, "handler");
|
|
42
|
+
emitter.on(eventName, handler);
|
|
43
|
+
eventRecord.push([
|
|
44
|
+
eventName,
|
|
45
|
+
handler
|
|
46
|
+
]);
|
|
47
|
+
} else {
|
|
48
|
+
eventRecord.push([
|
|
49
|
+
eventName,
|
|
50
|
+
fn
|
|
51
|
+
]);
|
|
52
|
+
emitter.on(eventName, fn);
|
|
53
|
+
}
|
|
42
54
|
});
|
|
43
55
|
const originUnmount = app.unmount.bind(app);
|
|
44
56
|
app.unmount = () => {
|
|
45
57
|
eventRecord.forEach(([eventName, handler]) => emitter.off(eventName, handler));
|
|
58
|
+
eventRecord = [];
|
|
46
59
|
if (symbol)
|
|
47
60
|
delete window.__PHECDA_VUE__[symbol];
|
|
48
61
|
originUnmount();
|
|
49
62
|
};
|
|
50
|
-
}
|
|
51
|
-
useVMap: /* @__PURE__ */ new WeakMap(),
|
|
52
|
-
useOMap: new (symbol ? Map : WeakMap)(),
|
|
53
|
-
useRMap: /* @__PURE__ */ new WeakMap(),
|
|
54
|
-
fnMap: /* @__PURE__ */ new WeakMap(),
|
|
55
|
-
computedMap: /* @__PURE__ */ new WeakMap()
|
|
63
|
+
}
|
|
56
64
|
});
|
|
57
65
|
return phecda;
|
|
58
66
|
}
|
|
59
67
|
__name(createPhecda, "createPhecda");
|
|
60
68
|
var activePhecda = {
|
|
61
69
|
useVMap: /* @__PURE__ */ new WeakMap(),
|
|
62
|
-
useOMap: /* @__PURE__ */ new
|
|
70
|
+
useOMap: /* @__PURE__ */ new Map(),
|
|
63
71
|
useRMap: /* @__PURE__ */ new WeakMap(),
|
|
64
72
|
fnMap: /* @__PURE__ */ new WeakMap(),
|
|
65
73
|
computedMap: /* @__PURE__ */ new WeakMap()
|
|
@@ -84,7 +92,7 @@ function getReactiveMap(symbol) {
|
|
|
84
92
|
__name(getReactiveMap, "getReactiveMap");
|
|
85
93
|
|
|
86
94
|
// src/vue/composable.ts
|
|
87
|
-
import { computed,
|
|
95
|
+
import { computed, onBeforeUnmount, reactive } from "vue";
|
|
88
96
|
import { getHandler, register } from "phecda-core";
|
|
89
97
|
|
|
90
98
|
// src/vue/utils.ts
|
|
@@ -152,11 +160,6 @@ __name(createSharedReactive, "createSharedReactive");
|
|
|
152
160
|
|
|
153
161
|
// src/vue/composable.ts
|
|
154
162
|
function useO(Model) {
|
|
155
|
-
if (getCurrentInstance()) {
|
|
156
|
-
const cur = inject(phecdaSymbol, null);
|
|
157
|
-
if (cur)
|
|
158
|
-
setActivePhecda(cur);
|
|
159
|
-
}
|
|
160
163
|
const { useOMap } = getActivePhecda();
|
|
161
164
|
if (!useOMap.has(Model)) {
|
|
162
165
|
const instance = reactive(new Model());
|
|
@@ -671,10 +674,30 @@ function createPipe(comp, props, to = "default", slot) {
|
|
|
671
674
|
};
|
|
672
675
|
}
|
|
673
676
|
__name(createPipe, "createPipe");
|
|
677
|
+
|
|
678
|
+
// src/wrapper.ts
|
|
679
|
+
var PV = class {
|
|
680
|
+
constructor() {
|
|
681
|
+
}
|
|
682
|
+
get tag() {
|
|
683
|
+
return this._namespace.__TAG__;
|
|
684
|
+
}
|
|
685
|
+
on(type, handler) {
|
|
686
|
+
emitter.on(type, handler);
|
|
687
|
+
}
|
|
688
|
+
emit(type, param) {
|
|
689
|
+
emitter.emit(type, param);
|
|
690
|
+
}
|
|
691
|
+
off(type, handler) {
|
|
692
|
+
emitter.off(type, handler);
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
__name(PV, "PV");
|
|
674
696
|
export {
|
|
675
697
|
EXPRESS_RE,
|
|
676
698
|
FN_RE,
|
|
677
699
|
GetDevUIRules,
|
|
700
|
+
PV,
|
|
678
701
|
clearStorage,
|
|
679
702
|
createFilter,
|
|
680
703
|
createForm,
|
|
@@ -693,7 +716,6 @@ export {
|
|
|
693
716
|
getReactiveMap,
|
|
694
717
|
getVantRules,
|
|
695
718
|
initalize,
|
|
696
|
-
invokeAction,
|
|
697
719
|
phecdaSymbol,
|
|
698
720
|
setActivePhecda,
|
|
699
721
|
useEvent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-vue",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "",
|
|
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": "1.1.
|
|
17
|
+
"phecda-core": "1.1.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"tsup": "^6.5.0"
|