@stonecrop/stonecrop 0.3.11 → 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.
- package/dist/composable.js +17 -19
- package/dist/plugins/index.js +6 -3
- package/dist/registry.js +7 -7
- package/dist/src/composable.d.ts +1 -2
- package/dist/src/composable.d.ts.map +1 -1
- package/dist/src/plugins/index.d.ts.map +1 -1
- package/dist/src/registry.d.ts +6 -6
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/stonecrop.d.ts +7 -8
- package/dist/stonecrop.js +1028 -2827
- package/dist/stonecrop.js.map +1 -1
- package/dist/stonecrop.tsbuildinfo +1 -1
- package/dist/stonecrop.umd.cjs +7 -37
- package/dist/stonecrop.umd.cjs.map +1 -1
- package/package.json +5 -5
- package/src/composable.ts +18 -21
- package/src/plugins/index.ts +7 -3
- package/src/registry.ts +10 -9
- package/dist/router.js +0 -6
- package/dist/src/router.d.ts +0 -3
- package/dist/src/router.d.ts.map +0 -1
- package/src/router.ts +0 -8
package/dist/composable.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject,
|
|
1
|
+
import { inject, onMounted, ref } from 'vue';
|
|
2
2
|
import { Stonecrop } from './stonecrop';
|
|
3
3
|
import { useDataStore } from './stores/data';
|
|
4
4
|
/**
|
|
@@ -9,21 +9,21 @@ import { useDataStore } from './stores/data';
|
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
export function useStonecrop(registry) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
store
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!registry)
|
|
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
|
+
if (!registry || !registry.router)
|
|
27
27
|
return;
|
|
28
28
|
const route = registry.router.currentRoute.value;
|
|
29
29
|
const doctypeSlug = route.params.records?.toString().toLowerCase();
|
|
@@ -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
|
-
|
|
53
|
-
return { stonecrop, isReady };
|
|
51
|
+
return { stonecrop };
|
|
54
52
|
}
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Registry from '../registry';
|
|
2
|
-
import router from '../router';
|
|
3
2
|
import { pinia } from '../stores';
|
|
4
3
|
/**
|
|
5
4
|
* Stonecrop Vue plugin
|
|
@@ -31,9 +30,13 @@ import { pinia } from '../stores';
|
|
|
31
30
|
*/
|
|
32
31
|
const plugin = {
|
|
33
32
|
install: (app, options) => {
|
|
34
|
-
|
|
33
|
+
// check if the router is already installed via another plugin
|
|
34
|
+
const existingRouter = app.config.globalProperties.$router;
|
|
35
|
+
const appRouter = existingRouter || options?.router;
|
|
35
36
|
const registry = new Registry(appRouter, options?.getMeta);
|
|
36
|
-
|
|
37
|
+
if (!existingRouter && appRouter) {
|
|
38
|
+
app.use(appRouter);
|
|
39
|
+
}
|
|
37
40
|
app.use(pinia);
|
|
38
41
|
app.provide('$registry', registry);
|
|
39
42
|
if (options?.components) {
|
package/dist/registry.js
CHANGED
|
@@ -13,16 +13,16 @@ export default class Registry {
|
|
|
13
13
|
* @defaultValue 'Registry'
|
|
14
14
|
*/
|
|
15
15
|
name;
|
|
16
|
-
/**
|
|
17
|
-
* The Vue router instance
|
|
18
|
-
* @see {@link https://router.vuejs.org/}
|
|
19
|
-
*/
|
|
20
|
-
router;
|
|
21
16
|
/**
|
|
22
17
|
* The registry property contains a collection of doctypes
|
|
23
18
|
* @see {@link DoctypeMeta}
|
|
24
19
|
*/
|
|
25
20
|
registry;
|
|
21
|
+
/**
|
|
22
|
+
* The Vue router instance
|
|
23
|
+
* @see {@link https://router.vuejs.org/}
|
|
24
|
+
*/
|
|
25
|
+
router;
|
|
26
26
|
/**
|
|
27
27
|
* The getMeta function fetches doctype metadata from an API
|
|
28
28
|
* @see {@link DoctypeMeta}
|
|
@@ -34,8 +34,8 @@ export default class Registry {
|
|
|
34
34
|
}
|
|
35
35
|
Registry._root = this;
|
|
36
36
|
this.name = 'Registry';
|
|
37
|
-
this.router = router;
|
|
38
37
|
this.registry = {};
|
|
38
|
+
this.router = router;
|
|
39
39
|
this.getMeta = getMeta;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
@@ -48,7 +48,7 @@ export default class Registry {
|
|
|
48
48
|
if (!(doctype.doctype in Object.keys(this.registry))) {
|
|
49
49
|
this.registry[doctype.slug] = doctype;
|
|
50
50
|
}
|
|
51
|
-
if (!this.router.hasRoute(doctype.doctype)
|
|
51
|
+
if (doctype.component && this.router && !this.router.hasRoute(doctype.doctype)) {
|
|
52
52
|
this.router.addRoute({
|
|
53
53
|
path: `/${doctype.slug}`,
|
|
54
54
|
name: doctype.slug,
|
package/dist/src/composable.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composable.d.ts","sourceRoot":"","sources":["../../src/composable.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,MAAM,EAAE,MAAM,KAAK,CAAA;AAMtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,QAAA,MAAM,MAAM,EAAE,MAoBb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/dist/src/registry.d.ts
CHANGED
|
@@ -15,22 +15,22 @@ export default class Registry {
|
|
|
15
15
|
* @defaultValue 'Registry'
|
|
16
16
|
*/
|
|
17
17
|
name: string;
|
|
18
|
-
/**
|
|
19
|
-
* The Vue router instance
|
|
20
|
-
* @see {@link https://router.vuejs.org/}
|
|
21
|
-
*/
|
|
22
|
-
router: Router;
|
|
23
18
|
/**
|
|
24
19
|
* The registry property contains a collection of doctypes
|
|
25
20
|
* @see {@link DoctypeMeta}
|
|
26
21
|
*/
|
|
27
22
|
registry: Record<string, DoctypeMeta>;
|
|
23
|
+
/**
|
|
24
|
+
* The Vue router instance
|
|
25
|
+
* @see {@link https://router.vuejs.org/}
|
|
26
|
+
*/
|
|
27
|
+
router?: Router;
|
|
28
28
|
/**
|
|
29
29
|
* The getMeta function fetches doctype metadata from an API
|
|
30
30
|
* @see {@link DoctypeMeta}
|
|
31
31
|
*/
|
|
32
32
|
getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>;
|
|
33
|
-
constructor(router
|
|
33
|
+
constructor(router?: Router, getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>);
|
|
34
34
|
/**
|
|
35
35
|
* Get doctype metadata
|
|
36
36
|
* @param doctype - The doctype to fetch metadata for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,WAAW,MAAM,WAAW,CAAA;AAEnC;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC5B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAA;IAEtB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,WAAW,MAAM,WAAW,CAAA;AAEnC;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC5B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAA;IAEtB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IAErC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;gBAErD,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAW9F;;;;;OAKG;IACH,UAAU,CAAC,OAAO,EAAE,WAAW;CAa/B"}
|
package/dist/stonecrop.d.ts
CHANGED
|
@@ -211,22 +211,22 @@ export declare class Registry {
|
|
|
211
211
|
* @defaultValue 'Registry'
|
|
212
212
|
*/
|
|
213
213
|
name: string;
|
|
214
|
-
/**
|
|
215
|
-
* The Vue router instance
|
|
216
|
-
* @see {@link https://router.vuejs.org/}
|
|
217
|
-
*/
|
|
218
|
-
router: Router;
|
|
219
214
|
/**
|
|
220
215
|
* The registry property contains a collection of doctypes
|
|
221
216
|
* @see {@link DoctypeMeta}
|
|
222
217
|
*/
|
|
223
218
|
registry: Record<string, DoctypeMeta>;
|
|
219
|
+
/**
|
|
220
|
+
* The Vue router instance
|
|
221
|
+
* @see {@link https://router.vuejs.org/}
|
|
222
|
+
*/
|
|
223
|
+
router?: Router;
|
|
224
224
|
/**
|
|
225
225
|
* The getMeta function fetches doctype metadata from an API
|
|
226
226
|
* @see {@link DoctypeMeta}
|
|
227
227
|
*/
|
|
228
228
|
getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>;
|
|
229
|
-
constructor(router
|
|
229
|
+
constructor(router?: Router, getMeta?: (doctype: string) => DoctypeMeta | Promise<DoctypeMeta>);
|
|
230
230
|
/**
|
|
231
231
|
* Get doctype metadata
|
|
232
232
|
* @param doctype - The doctype to fetch metadata for
|
|
@@ -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
|
/**
|