phecda-vue 4.0.3 → 4.0.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.mts CHANGED
@@ -7,7 +7,7 @@ declare class VuePhecda extends WebPhecda {
7
7
  vueApp: App;
8
8
  install(app: App): void;
9
9
  }
10
- declare function createPhecda(): VuePhecda;
10
+ declare function createPhecda(models?: Construct[]): VuePhecda;
11
11
 
12
12
  declare const RawSymbol: unique symbol;
13
13
  type Raw<T> = T & {
@@ -21,6 +21,7 @@ type SchemaToObj<S> = {
21
21
  };
22
22
 
23
23
  declare function useRaw<T extends Construct>(model: T): InstanceType<T>;
24
+ declare function getRaw<T extends Construct>(model: T): InstanceType<T>;
24
25
  declare function usePhecda(): VuePhecda;
25
26
  declare function getPhecda(phecda?: VuePhecda): VuePhecda;
26
27
  declare function useEvent<Key extends keyof Events>(eventName: Key, cb: (event: Events[Key]) => void): {
@@ -32,10 +33,10 @@ declare function getR<T extends Construct>(model: T, phecda?: VuePhecda): Unwrap
32
33
  declare function useV<T extends Construct>(model: T): ReplaceInstanceValues<InstanceType<T>>;
33
34
  declare function getV<T extends Construct>(model: T, phecda?: VuePhecda): ReplaceInstanceValues<InstanceType<T>>;
34
35
 
35
- declare function Shallow(isShallow?: boolean): (model: any) => void;
36
+ declare function Shallow(model: any): void;
36
37
  declare function WatchEffect(option?: WatchOptions): (proto: any, key: string) => void;
37
38
 
38
39
  declare function markRaw<T extends object>(value: T): Raw<T>;
39
40
  declare function createSharedReactive<F extends (...args: any) => any>(composable: F): () => ReturnType<F>;
40
41
 
41
- export { type Raw, RawSymbol, type ReplaceInstanceValues, type SchemaToObj, Shallow, VuePhecda, WatchEffect, createPhecda, createSharedReactive, getPhecda, getR, getV, markRaw, phecdaSymbol, useEvent, usePhecda, useR, useRaw, useV };
42
+ export { type Raw, RawSymbol, type ReplaceInstanceValues, type SchemaToObj, Shallow, VuePhecda, WatchEffect, createPhecda, createSharedReactive, getPhecda, getR, getRaw, getV, markRaw, phecdaSymbol, useEvent, usePhecda, useR, useRaw, useV };
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ declare class VuePhecda extends WebPhecda {
7
7
  vueApp: App;
8
8
  install(app: App): void;
9
9
  }
10
- declare function createPhecda(): VuePhecda;
10
+ declare function createPhecda(models?: Construct[]): VuePhecda;
11
11
 
12
12
  declare const RawSymbol: unique symbol;
13
13
  type Raw<T> = T & {
@@ -21,6 +21,7 @@ type SchemaToObj<S> = {
21
21
  };
22
22
 
23
23
  declare function useRaw<T extends Construct>(model: T): InstanceType<T>;
24
+ declare function getRaw<T extends Construct>(model: T): InstanceType<T>;
24
25
  declare function usePhecda(): VuePhecda;
25
26
  declare function getPhecda(phecda?: VuePhecda): VuePhecda;
26
27
  declare function useEvent<Key extends keyof Events>(eventName: Key, cb: (event: Events[Key]) => void): {
@@ -32,10 +33,10 @@ declare function getR<T extends Construct>(model: T, phecda?: VuePhecda): Unwrap
32
33
  declare function useV<T extends Construct>(model: T): ReplaceInstanceValues<InstanceType<T>>;
33
34
  declare function getV<T extends Construct>(model: T, phecda?: VuePhecda): ReplaceInstanceValues<InstanceType<T>>;
34
35
 
35
- declare function Shallow(isShallow?: boolean): (model: any) => void;
36
+ declare function Shallow(model: any): void;
36
37
  declare function WatchEffect(option?: WatchOptions): (proto: any, key: string) => void;
37
38
 
38
39
  declare function markRaw<T extends object>(value: T): Raw<T>;
39
40
  declare function createSharedReactive<F extends (...args: any) => any>(composable: F): () => ReturnType<F>;
40
41
 
41
- export { type Raw, RawSymbol, type ReplaceInstanceValues, type SchemaToObj, Shallow, VuePhecda, WatchEffect, createPhecda, createSharedReactive, getPhecda, getR, getV, markRaw, phecdaSymbol, useEvent, usePhecda, useR, useRaw, useV };
42
+ export { type Raw, RawSymbol, type ReplaceInstanceValues, type SchemaToObj, Shallow, VuePhecda, WatchEffect, createPhecda, createSharedReactive, getPhecda, getR, getRaw, getV, markRaw, phecdaSymbol, useEvent, usePhecda, useR, useRaw, useV };
package/dist/index.js CHANGED
@@ -29,6 +29,7 @@ __export(src_exports, {
29
29
  createSharedReactive: () => createSharedReactive,
30
30
  getPhecda: () => getPhecda,
31
31
  getR: () => getR,
32
+ getRaw: () => getRaw,
32
33
  getV: () => getV,
33
34
  markRaw: () => markRaw,
34
35
  phecdaSymbol: () => phecdaSymbol,
@@ -303,7 +304,7 @@ var VuePhecda = class extends import_phecda_web.WebPhecda {
303
304
  }
304
305
  }
305
306
  };
306
- function createPhecda() {
307
+ function createPhecda(models) {
307
308
  const phecda = new VuePhecda("vue", (instance) => {
308
309
  return (0, import_phecda_web.bindMethod)((0, import_phecda_web.get)(instance, "shallow") ? (0, import_vue.shallowReactive)(instance) : (0, import_vue.reactive)(instance), USE_DEVTOOLS ? (instance2, key) => {
309
310
  const cb = instance2[key].bind(instance2);
@@ -331,6 +332,7 @@ function createPhecda() {
331
332
  };
332
333
  } : void 0);
333
334
  });
335
+ models?.forEach((model) => phecda.init(model));
334
336
  return phecda;
335
337
  }
336
338
  __name(createPhecda, "createPhecda");
@@ -414,6 +416,10 @@ function useRaw(model) {
414
416
  return (0, import_vue3.toRaw)(useR(model));
415
417
  }
416
418
  __name(useRaw, "useRaw");
419
+ function getRaw(model) {
420
+ return (0, import_vue3.toRaw)(getR(model));
421
+ }
422
+ __name(getRaw, "getRaw");
417
423
  function usePhecda() {
418
424
  if (!(0, import_vue3.hasInjectionContext)()) throw new Error("[phecda-vue]: use hook inside component setup function");
419
425
  const activePhecda = (0, import_vue3.inject)(phecdaSymbol);
@@ -512,10 +518,8 @@ __name(getV, "getV");
512
518
  // src/decorator.ts
513
519
  var import_phecda_web3 = require("phecda-web");
514
520
  var import_vue4 = require("vue");
515
- function Shallow(isShallow = true) {
516
- return (model) => {
517
- (0, import_phecda_web3.set)(model.prototype, "shallow", isShallow);
518
- };
521
+ function Shallow(model) {
522
+ (0, import_phecda_web3.set)(model.prototype, "shallow", true);
519
523
  }
520
524
  __name(Shallow, "Shallow");
521
525
  function WatchEffect(option) {
@@ -543,6 +547,7 @@ __name(WatchEffect, "WatchEffect");
543
547
  createSharedReactive,
544
548
  getPhecda,
545
549
  getR,
550
+ getRaw,
546
551
  getV,
547
552
  markRaw,
548
553
  phecdaSymbol,
package/dist/index.mjs CHANGED
@@ -266,7 +266,7 @@ var VuePhecda = class extends WebPhecda {
266
266
  }
267
267
  }
268
268
  };
269
- function createPhecda() {
269
+ function createPhecda(models) {
270
270
  const phecda = new VuePhecda("vue", (instance) => {
271
271
  return bindMethod(get(instance, "shallow") ? shallowReactive(instance) : reactive(instance), USE_DEVTOOLS ? (instance2, key) => {
272
272
  const cb = instance2[key].bind(instance2);
@@ -294,6 +294,7 @@ function createPhecda() {
294
294
  };
295
295
  } : void 0);
296
296
  });
297
+ models?.forEach((model) => phecda.init(model));
297
298
  return phecda;
298
299
  }
299
300
  __name(createPhecda, "createPhecda");
@@ -377,6 +378,10 @@ function useRaw(model) {
377
378
  return toRaw2(useR(model));
378
379
  }
379
380
  __name(useRaw, "useRaw");
381
+ function getRaw(model) {
382
+ return toRaw2(getR(model));
383
+ }
384
+ __name(getRaw, "getRaw");
380
385
  function usePhecda() {
381
386
  if (!hasInjectionContext()) throw new Error("[phecda-vue]: use hook inside component setup function");
382
387
  const activePhecda = inject(phecdaSymbol);
@@ -475,10 +480,8 @@ __name(getV, "getV");
475
480
  // src/decorator.ts
476
481
  import { set, setHandler, setStateKey } from "phecda-web";
477
482
  import { watchEffect } from "vue";
478
- function Shallow(isShallow = true) {
479
- return (model) => {
480
- set(model.prototype, "shallow", isShallow);
481
- };
483
+ function Shallow(model) {
484
+ set(model.prototype, "shallow", true);
482
485
  }
483
486
  __name(Shallow, "Shallow");
484
487
  function WatchEffect(option) {
@@ -505,6 +508,7 @@ export {
505
508
  createSharedReactive,
506
509
  getPhecda,
507
510
  getR,
511
+ getRaw,
508
512
  getV,
509
513
  markRaw,
510
514
  phecdaSymbol,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-vue",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
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": "2.0.3"
21
+ "phecda-web": "2.0.5"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@vue/test-utils": "^2.4.6",