phecda-vue 2.0.0 → 2.0.2
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 +5 -5
- package/dist/index.js +15 -19
- package/dist/index.mjs +13 -17
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ interface PhecdaEmitter {
|
|
|
19
19
|
declare const emitter: PhecdaEmitter;
|
|
20
20
|
|
|
21
21
|
declare const phecdaSymbol: unique symbol;
|
|
22
|
+
declare const interval: any;
|
|
22
23
|
declare function createPhecda(symbol?: string): vue.Raw<{
|
|
23
24
|
install(app: App): void;
|
|
24
25
|
}>;
|
|
@@ -45,11 +46,10 @@ declare function useV<T extends new (...args: any) => any>(Model: T): ReplaceIns
|
|
|
45
46
|
declare function useEvent<Key extends keyof Events>(eventName: Key, cb: Handler<Events[Key]>): () => void;
|
|
46
47
|
declare function initialize<M extends new (...args: any) => any>(Model: M): InstanceType<M> | void;
|
|
47
48
|
|
|
48
|
-
declare const
|
|
49
|
-
declare const FN_RE: RegExp;
|
|
49
|
+
declare const RE: RegExp;
|
|
50
50
|
declare function createFilter<Data extends Record<string, any>>(initState?: Object, option?: {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
RE?: RegExp;
|
|
52
|
+
needReturn?: boolean;
|
|
53
53
|
exclude?: string[];
|
|
54
54
|
errorHandler?: (error?: Error, errorPath?: string) => any;
|
|
55
55
|
}): {
|
|
@@ -136,4 +136,4 @@ declare class PV {
|
|
|
136
136
|
off<Key extends keyof Events>(type: Key, handler?: (arg: Events[Key]) => void): void;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
export {
|
|
139
|
+
export { GetDevUIRules, PV, PhecdaEmitter, RE, ReplaceInstanceValues, SchemaToObj, createFilter, createForm, createFormData, createLayer, createModal, createPhecda, createPipe, createTable, emitter, getActivePhecda, getAntDRules, getArcoRules, getElementPlusRules, getNaiveUIRules, getNutUIRules, getReactiveMap, getVantRules, initialize, interval, phecdaSymbol, setActivePhecda, useEvent, useO, usePatch, useR, useRaw, useV };
|
package/dist/index.js
CHANGED
|
@@ -28,10 +28,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
28
28
|
// src/index.ts
|
|
29
29
|
var src_exports = {};
|
|
30
30
|
__export(src_exports, {
|
|
31
|
-
EXPRESS_RE: () => EXPRESS_RE,
|
|
32
|
-
FN_RE: () => FN_RE,
|
|
33
31
|
GetDevUIRules: () => GetDevUIRules,
|
|
34
32
|
PV: () => PV,
|
|
33
|
+
RE: () => RE,
|
|
35
34
|
createFilter: () => createFilter,
|
|
36
35
|
createForm: () => createForm,
|
|
37
36
|
createFormData: () => createFormData,
|
|
@@ -50,6 +49,7 @@ __export(src_exports, {
|
|
|
50
49
|
getReactiveMap: () => getReactiveMap,
|
|
51
50
|
getVantRules: () => getVantRules,
|
|
52
51
|
initialize: () => initialize,
|
|
52
|
+
interval: () => interval,
|
|
53
53
|
phecdaSymbol: () => phecdaSymbol,
|
|
54
54
|
setActivePhecda: () => setActivePhecda,
|
|
55
55
|
useEvent: () => useEvent,
|
|
@@ -69,9 +69,11 @@ var emitter = (0, import_mitt.default)();
|
|
|
69
69
|
var import_vue = require("vue");
|
|
70
70
|
var import_phecda_core = require("phecda-core");
|
|
71
71
|
var phecdaSymbol = Symbol("phecda");
|
|
72
|
+
var interval = {};
|
|
72
73
|
function createPhecda(symbol) {
|
|
73
74
|
const phecda = (0, import_vue.markRaw)({
|
|
74
75
|
install(app) {
|
|
76
|
+
interval.app = app;
|
|
75
77
|
app.provide(phecdaSymbol, phecda);
|
|
76
78
|
app.config.globalProperties.$phecda = phecda;
|
|
77
79
|
if (!window.__PHECDA_VUE__)
|
|
@@ -346,12 +348,10 @@ __name(initialize, "initialize");
|
|
|
346
348
|
|
|
347
349
|
// src/filter.ts
|
|
348
350
|
var import_vue4 = require("vue");
|
|
349
|
-
var
|
|
350
|
-
var FN_RE = /^\[\[(.*)\]\]$/;
|
|
351
|
+
var RE = /{{(.*)}}/;
|
|
351
352
|
function createFilter(initState = {}, option = {}) {
|
|
352
353
|
const resolveOption = Object.assign({
|
|
353
|
-
|
|
354
|
-
fnRE: FN_RE,
|
|
354
|
+
RE,
|
|
355
355
|
exclude: []
|
|
356
356
|
}, option);
|
|
357
357
|
const scope = (0, import_vue4.effectScope)(true);
|
|
@@ -365,11 +365,13 @@ function createFilter(initState = {}, option = {}) {
|
|
|
365
365
|
if (typeof obj[i] === "object" && obj[i])
|
|
366
366
|
traverse(obj[i], errorPath);
|
|
367
367
|
if (typeof obj[i] === "string") {
|
|
368
|
-
if (resolveOption.
|
|
369
|
-
const body = obj[i].
|
|
368
|
+
if (resolveOption.RE.test(obj[i])) {
|
|
369
|
+
const body = obj[i].replace(resolveOption.RE, (_, s) => {
|
|
370
|
+
return s;
|
|
371
|
+
});
|
|
370
372
|
Object.defineProperty(obj, i, {
|
|
371
373
|
get() {
|
|
372
|
-
return new Function(...Object.keys(data.value), "_eh", resolveOption.errorHandler ? `try{return ${body}}catch(e){return _eh(e,"${errorPath}")}` :
|
|
374
|
+
return new Function(...Object.keys(data.value), "_eh", resolveOption.errorHandler ? `try{${resolveOption.needReturn ? "" : "return"} ${body}}catch(e){return _eh(e,"${errorPath}")}` : `${resolveOption.needReturn ? "" : "return"} ${body}`)(...Object.values(data.value), resolveOption.errorHandler);
|
|
373
375
|
},
|
|
374
376
|
set(value) {
|
|
375
377
|
try {
|
|
@@ -382,14 +384,6 @@ function createFilter(initState = {}, option = {}) {
|
|
|
382
384
|
}
|
|
383
385
|
});
|
|
384
386
|
}
|
|
385
|
-
if (resolveOption.fnRE.test(obj[i])) {
|
|
386
|
-
const body = obj[i].match(resolveOption.fnRE)[1];
|
|
387
|
-
Object.defineProperty(obj, i, {
|
|
388
|
-
get() {
|
|
389
|
-
return new Function(...Object.keys(data.value), "_eh", resolveOption.errorHandler ? `try{${body}}catch(e){return _eh(e,"${errorPath}")}` : `${body}`)(...Object.values(data.value), resolveOption.errorHandler);
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
387
|
}
|
|
394
388
|
}
|
|
395
389
|
}
|
|
@@ -737,6 +731,7 @@ var createLayer = /* @__PURE__ */ __name(function(modalWrapper, content_props =
|
|
|
737
731
|
if (!isMounted) {
|
|
738
732
|
const el = document.createElement("div");
|
|
739
733
|
const vnode = (0, import_vue7.h)(wrapper);
|
|
734
|
+
vnode.appContext = interval.app?._context;
|
|
740
735
|
document.body.appendChild(((0, import_vue7.render)(vnode, el), el));
|
|
741
736
|
isMounted = true;
|
|
742
737
|
} else {
|
|
@@ -855,6 +850,7 @@ var createModal = /* @__PURE__ */ __name(function(wrapComp, comp, opts = {}) {
|
|
|
855
850
|
if (!isMounted) {
|
|
856
851
|
const el = document.createElement("div");
|
|
857
852
|
const vnode = (0, import_vue10.h)(wrapper);
|
|
853
|
+
vnode.appContext = interval.app?._context;
|
|
858
854
|
document.body.appendChild(((0, import_vue10.render)(vnode, el), el));
|
|
859
855
|
isMounted = true;
|
|
860
856
|
} else {
|
|
@@ -883,10 +879,9 @@ var PV = class {
|
|
|
883
879
|
__name(PV, "PV");
|
|
884
880
|
// Annotate the CommonJS export names for ESM import in node:
|
|
885
881
|
0 && (module.exports = {
|
|
886
|
-
EXPRESS_RE,
|
|
887
|
-
FN_RE,
|
|
888
882
|
GetDevUIRules,
|
|
889
883
|
PV,
|
|
884
|
+
RE,
|
|
890
885
|
createFilter,
|
|
891
886
|
createForm,
|
|
892
887
|
createFormData,
|
|
@@ -905,6 +900,7 @@ __name(PV, "PV");
|
|
|
905
900
|
getReactiveMap,
|
|
906
901
|
getVantRules,
|
|
907
902
|
initialize,
|
|
903
|
+
interval,
|
|
908
904
|
phecdaSymbol,
|
|
909
905
|
setActivePhecda,
|
|
910
906
|
useEvent,
|
package/dist/index.mjs
CHANGED
|
@@ -9,9 +9,11 @@ var emitter = mitt();
|
|
|
9
9
|
import { markRaw } from "vue";
|
|
10
10
|
import { getProperty, getTag, injectProperty } from "phecda-core";
|
|
11
11
|
var phecdaSymbol = Symbol("phecda");
|
|
12
|
+
var interval = {};
|
|
12
13
|
function createPhecda(symbol) {
|
|
13
14
|
const phecda = markRaw({
|
|
14
15
|
install(app) {
|
|
16
|
+
interval.app = app;
|
|
15
17
|
app.provide(phecdaSymbol, phecda);
|
|
16
18
|
app.config.globalProperties.$phecda = phecda;
|
|
17
19
|
if (!window.__PHECDA_VUE__)
|
|
@@ -286,12 +288,10 @@ __name(initialize, "initialize");
|
|
|
286
288
|
|
|
287
289
|
// src/filter.ts
|
|
288
290
|
import { effectScope as effectScope2, ref } from "vue";
|
|
289
|
-
var
|
|
290
|
-
var FN_RE = /^\[\[(.*)\]\]$/;
|
|
291
|
+
var RE = /{{(.*)}}/;
|
|
291
292
|
function createFilter(initState = {}, option = {}) {
|
|
292
293
|
const resolveOption = Object.assign({
|
|
293
|
-
|
|
294
|
-
fnRE: FN_RE,
|
|
294
|
+
RE,
|
|
295
295
|
exclude: []
|
|
296
296
|
}, option);
|
|
297
297
|
const scope = effectScope2(true);
|
|
@@ -305,11 +305,13 @@ function createFilter(initState = {}, option = {}) {
|
|
|
305
305
|
if (typeof obj[i] === "object" && obj[i])
|
|
306
306
|
traverse(obj[i], errorPath);
|
|
307
307
|
if (typeof obj[i] === "string") {
|
|
308
|
-
if (resolveOption.
|
|
309
|
-
const body = obj[i].
|
|
308
|
+
if (resolveOption.RE.test(obj[i])) {
|
|
309
|
+
const body = obj[i].replace(resolveOption.RE, (_, s) => {
|
|
310
|
+
return s;
|
|
311
|
+
});
|
|
310
312
|
Object.defineProperty(obj, i, {
|
|
311
313
|
get() {
|
|
312
|
-
return new Function(...Object.keys(data.value), "_eh", resolveOption.errorHandler ? `try{return ${body}}catch(e){return _eh(e,"${errorPath}")}` :
|
|
314
|
+
return new Function(...Object.keys(data.value), "_eh", resolveOption.errorHandler ? `try{${resolveOption.needReturn ? "" : "return"} ${body}}catch(e){return _eh(e,"${errorPath}")}` : `${resolveOption.needReturn ? "" : "return"} ${body}`)(...Object.values(data.value), resolveOption.errorHandler);
|
|
313
315
|
},
|
|
314
316
|
set(value) {
|
|
315
317
|
try {
|
|
@@ -322,14 +324,6 @@ function createFilter(initState = {}, option = {}) {
|
|
|
322
324
|
}
|
|
323
325
|
});
|
|
324
326
|
}
|
|
325
|
-
if (resolveOption.fnRE.test(obj[i])) {
|
|
326
|
-
const body = obj[i].match(resolveOption.fnRE)[1];
|
|
327
|
-
Object.defineProperty(obj, i, {
|
|
328
|
-
get() {
|
|
329
|
-
return new Function(...Object.keys(data.value), "_eh", resolveOption.errorHandler ? `try{${body}}catch(e){return _eh(e,"${errorPath}")}` : `${body}`)(...Object.values(data.value), resolveOption.errorHandler);
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
327
|
}
|
|
334
328
|
}
|
|
335
329
|
}
|
|
@@ -677,6 +671,7 @@ var createLayer = /* @__PURE__ */ __name(function(modalWrapper, content_props =
|
|
|
677
671
|
if (!isMounted) {
|
|
678
672
|
const el = document.createElement("div");
|
|
679
673
|
const vnode = h2(wrapper);
|
|
674
|
+
vnode.appContext = interval.app?._context;
|
|
680
675
|
document.body.appendChild((render(vnode, el), el));
|
|
681
676
|
isMounted = true;
|
|
682
677
|
} else {
|
|
@@ -795,6 +790,7 @@ var createModal = /* @__PURE__ */ __name(function(wrapComp, comp, opts = {}) {
|
|
|
795
790
|
if (!isMounted) {
|
|
796
791
|
const el = document.createElement("div");
|
|
797
792
|
const vnode = h5(wrapper);
|
|
793
|
+
vnode.appContext = interval.app?._context;
|
|
798
794
|
document.body.appendChild((render2(vnode, el), el));
|
|
799
795
|
isMounted = true;
|
|
800
796
|
} else {
|
|
@@ -822,10 +818,9 @@ var PV = class {
|
|
|
822
818
|
};
|
|
823
819
|
__name(PV, "PV");
|
|
824
820
|
export {
|
|
825
|
-
EXPRESS_RE,
|
|
826
|
-
FN_RE,
|
|
827
821
|
GetDevUIRules,
|
|
828
822
|
PV,
|
|
823
|
+
RE,
|
|
829
824
|
createFilter,
|
|
830
825
|
createForm,
|
|
831
826
|
createFormData,
|
|
@@ -844,6 +839,7 @@ export {
|
|
|
844
839
|
getReactiveMap,
|
|
845
840
|
getVantRules,
|
|
846
841
|
initialize,
|
|
842
|
+
interval,
|
|
847
843
|
phecdaSymbol,
|
|
848
844
|
setActivePhecda,
|
|
849
845
|
useEvent,
|