phecda-vue 1.2.4 → 1.2.5
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 +17 -11
- package/dist/index.js +41 -10
- package/dist/index.mjs +40 -9
- 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,15 +16,13 @@ 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<{
|
|
@@ -125,4 +123,12 @@ interface PipeRet {
|
|
|
125
123
|
get: Record<string, () => VNode>;
|
|
126
124
|
}
|
|
127
125
|
|
|
128
|
-
|
|
126
|
+
declare class PV {
|
|
127
|
+
constructor();
|
|
128
|
+
get tag(): any;
|
|
129
|
+
on<Key extends keyof PhecdaEvents>(type: Key, handler: (arg: PhecdaEvents[Key]) => void): void;
|
|
130
|
+
emit<Key extends keyof PhecdaEvents>(type: Key, param: PhecdaEvents[Key]): void;
|
|
131
|
+
off<Key extends keyof PhecdaEvents>(type: Key, handler?: (arg: PhecdaEvents[Key]) => void): void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
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");
|
|
@@ -90,18 +89,31 @@ function createPhecda(symbol) {
|
|
|
90
89
|
}
|
|
91
90
|
};
|
|
92
91
|
}
|
|
93
|
-
|
|
94
|
-
(0, import_phecda_core.injectProperty)("watcher", ({ eventName, instance, key }) => {
|
|
92
|
+
let eventRecord = [];
|
|
93
|
+
(0, import_phecda_core.injectProperty)("watcher", ({ eventName, instance, key, options }) => {
|
|
95
94
|
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
if (options?.once) {
|
|
96
|
+
const handler = /* @__PURE__ */ __name((...args) => {
|
|
97
|
+
fn(...args);
|
|
98
|
+
emitter.off(eventName, handler);
|
|
99
|
+
}, "handler");
|
|
100
|
+
emitter.on(eventName, handler);
|
|
101
|
+
eventRecord.push([
|
|
102
|
+
eventName,
|
|
103
|
+
handler
|
|
104
|
+
]);
|
|
105
|
+
} else {
|
|
106
|
+
eventRecord.push([
|
|
107
|
+
eventName,
|
|
108
|
+
fn
|
|
109
|
+
]);
|
|
110
|
+
emitter.on(eventName, fn);
|
|
111
|
+
}
|
|
101
112
|
});
|
|
102
113
|
const originUnmount = app.unmount.bind(app);
|
|
103
114
|
app.unmount = () => {
|
|
104
115
|
eventRecord.forEach(([eventName, handler]) => emitter.off(eventName, handler));
|
|
116
|
+
eventRecord = [];
|
|
105
117
|
if (symbol)
|
|
106
118
|
delete window.__PHECDA_VUE__[symbol];
|
|
107
119
|
originUnmount();
|
|
@@ -730,11 +742,31 @@ function createPipe(comp, props, to = "default", slot) {
|
|
|
730
742
|
};
|
|
731
743
|
}
|
|
732
744
|
__name(createPipe, "createPipe");
|
|
745
|
+
|
|
746
|
+
// src/wrapper.ts
|
|
747
|
+
var PV = class {
|
|
748
|
+
constructor() {
|
|
749
|
+
}
|
|
750
|
+
get tag() {
|
|
751
|
+
return this._namespace.__TAG__;
|
|
752
|
+
}
|
|
753
|
+
on(type, handler) {
|
|
754
|
+
emitter.on(type, handler);
|
|
755
|
+
}
|
|
756
|
+
emit(type, param) {
|
|
757
|
+
emitter.emit(type, param);
|
|
758
|
+
}
|
|
759
|
+
off(type, handler) {
|
|
760
|
+
emitter.off(type, handler);
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
__name(PV, "PV");
|
|
733
764
|
// Annotate the CommonJS export names for ESM import in node:
|
|
734
765
|
0 && (module.exports = {
|
|
735
766
|
EXPRESS_RE,
|
|
736
767
|
FN_RE,
|
|
737
768
|
GetDevUIRules,
|
|
769
|
+
PV,
|
|
738
770
|
clearStorage,
|
|
739
771
|
createFilter,
|
|
740
772
|
createForm,
|
|
@@ -753,7 +785,6 @@ __name(createPipe, "createPipe");
|
|
|
753
785
|
getReactiveMap,
|
|
754
786
|
getVantRules,
|
|
755
787
|
initalize,
|
|
756
|
-
invokeAction,
|
|
757
788
|
phecdaSymbol,
|
|
758
789
|
setActivePhecda,
|
|
759
790
|
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";
|
|
@@ -31,18 +30,31 @@ function createPhecda(symbol) {
|
|
|
31
30
|
}
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
injectProperty("watcher", ({ eventName, instance, key }) => {
|
|
33
|
+
let eventRecord = [];
|
|
34
|
+
injectProperty("watcher", ({ eventName, instance, key, options }) => {
|
|
36
35
|
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
if (options?.once) {
|
|
37
|
+
const handler = /* @__PURE__ */ __name((...args) => {
|
|
38
|
+
fn(...args);
|
|
39
|
+
emitter.off(eventName, handler);
|
|
40
|
+
}, "handler");
|
|
41
|
+
emitter.on(eventName, handler);
|
|
42
|
+
eventRecord.push([
|
|
43
|
+
eventName,
|
|
44
|
+
handler
|
|
45
|
+
]);
|
|
46
|
+
} else {
|
|
47
|
+
eventRecord.push([
|
|
48
|
+
eventName,
|
|
49
|
+
fn
|
|
50
|
+
]);
|
|
51
|
+
emitter.on(eventName, fn);
|
|
52
|
+
}
|
|
42
53
|
});
|
|
43
54
|
const originUnmount = app.unmount.bind(app);
|
|
44
55
|
app.unmount = () => {
|
|
45
56
|
eventRecord.forEach(([eventName, handler]) => emitter.off(eventName, handler));
|
|
57
|
+
eventRecord = [];
|
|
46
58
|
if (symbol)
|
|
47
59
|
delete window.__PHECDA_VUE__[symbol];
|
|
48
60
|
originUnmount();
|
|
@@ -671,10 +683,30 @@ function createPipe(comp, props, to = "default", slot) {
|
|
|
671
683
|
};
|
|
672
684
|
}
|
|
673
685
|
__name(createPipe, "createPipe");
|
|
686
|
+
|
|
687
|
+
// src/wrapper.ts
|
|
688
|
+
var PV = class {
|
|
689
|
+
constructor() {
|
|
690
|
+
}
|
|
691
|
+
get tag() {
|
|
692
|
+
return this._namespace.__TAG__;
|
|
693
|
+
}
|
|
694
|
+
on(type, handler) {
|
|
695
|
+
emitter.on(type, handler);
|
|
696
|
+
}
|
|
697
|
+
emit(type, param) {
|
|
698
|
+
emitter.emit(type, param);
|
|
699
|
+
}
|
|
700
|
+
off(type, handler) {
|
|
701
|
+
emitter.off(type, handler);
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
__name(PV, "PV");
|
|
674
705
|
export {
|
|
675
706
|
EXPRESS_RE,
|
|
676
707
|
FN_RE,
|
|
677
708
|
GetDevUIRules,
|
|
709
|
+
PV,
|
|
678
710
|
clearStorage,
|
|
679
711
|
createFilter,
|
|
680
712
|
createForm,
|
|
@@ -693,7 +725,6 @@ export {
|
|
|
693
725
|
getReactiveMap,
|
|
694
726
|
getVantRules,
|
|
695
727
|
initalize,
|
|
696
|
-
invokeAction,
|
|
697
728
|
phecdaSymbol,
|
|
698
729
|
setActivePhecda,
|
|
699
730
|
useEvent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-vue",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
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"
|