@stonecrop/stonecrop 0.3.10 → 0.4.0
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 +1 -1
- package/dist/plugins/index.js +6 -3
- package/dist/registry.js +7 -7
- 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 +6 -6
- package/dist/stonecrop.js +1023 -2822
- 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 +4 -4
- package/src/composable.ts +1 -1
- 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
|
@@ -23,7 +23,7 @@ export function useStonecrop(registry) {
|
|
|
23
23
|
const stonecrop = ref(new Stonecrop(registry, store));
|
|
24
24
|
const isReady = ref(false);
|
|
25
25
|
onBeforeMount(async () => {
|
|
26
|
-
if (!registry)
|
|
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();
|
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,
|
|
@@ -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
|