@stonecrop/stonecrop 0.4.0 → 0.4.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.
@@ -1,4 +1,4 @@
1
- import { inject, onBeforeMount, ref } from 'vue';
1
+ import { inject, onMounted, ref } from 'vue';
2
2
  import { Stonecrop } from './stonecrop';
3
3
  import { useDataStore } from './stores/data';
4
4
  /**
@@ -9,20 +9,20 @@ import { useDataStore } from './stores/data';
9
9
  * @public
10
10
  */
11
11
  export function useStonecrop(registry) {
12
- if (!registry) {
13
- registry = inject('$registry');
14
- }
15
- let store;
16
- try {
17
- store = useDataStore();
18
- }
19
- catch (e) {
20
- throw new Error('Please enable the Stonecrop plugin before using the Stonecrop composable');
21
- }
22
- // @ts-expect-error TODO: handle empty registry passed to Stonecrop
23
- const stonecrop = ref(new Stonecrop(registry, store));
24
- const isReady = ref(false);
25
- onBeforeMount(async () => {
12
+ const stonecrop = ref();
13
+ onMounted(async () => {
14
+ if (!registry) {
15
+ registry = inject('$registry');
16
+ }
17
+ let store;
18
+ try {
19
+ store = useDataStore();
20
+ }
21
+ catch (e) {
22
+ throw new Error('Please enable the Stonecrop plugin before using the Stonecrop composable');
23
+ }
24
+ // @ts-expect-error TODO: handle empty registry passed to Stonecrop
25
+ stonecrop.value = new Stonecrop(registry, store);
26
26
  if (!registry || !registry.router)
27
27
  return;
28
28
  const route = registry.router.currentRoute.value;
@@ -47,8 +47,6 @@ export function useStonecrop(registry) {
47
47
  }
48
48
  stonecrop.value.runAction(doctype, 'LOAD', recordId ? [recordId] : undefined);
49
49
  }
50
- isReady.value = true;
51
50
  });
52
- // @ts-expect-error TODO: fix the type mismatch
53
- return { stonecrop, isReady };
51
+ return { stonecrop };
54
52
  }
@@ -6,8 +6,7 @@ import { Stonecrop } from './stonecrop';
6
6
  * @public
7
7
  */
8
8
  export type StonecropReturn = {
9
- stonecrop: Ref<Stonecrop>;
10
- isReady: Ref<boolean>;
9
+ stonecrop: Ref<Stonecrop | undefined>;
11
10
  };
12
11
  /**
13
12
  * Stonecrop composable
@@ -1 +1 @@
1
- {"version":3,"file":"composable.d.ts","sourceRoot":"","sources":["../../src/composable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,GAAG,EAAO,MAAM,KAAK,CAAA;AAErD,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;IACzB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACrB,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,eAAe,CAkDjE"}
1
+ {"version":3,"file":"composable.d.ts","sourceRoot":"","sources":["../../src/composable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,GAAG,EAAO,MAAM,KAAK,CAAA;AAEjD,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC7B,SAAS,EAAE,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,CAAA;CACrC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,eAAe,CAgDjE"}
@@ -467,8 +467,7 @@ declare class Stonecrop_2 {
467
467
  * @public
468
468
  */
469
469
  export declare type StonecropReturn = {
470
- stonecrop: Ref<Stonecrop_2>;
471
- isReady: Ref<boolean>;
470
+ stonecrop: Ref<Stonecrop_2 | undefined>;
472
471
  };
473
472
 
474
473
  /**