@nookuio/vue 1.0.0 → 1.0.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,43 +1,43 @@
1
1
  <script setup>
2
- import { computed as o, watch as s, shallowRef as i } from "vue";
3
- import { useQuery as m } from "../composables/useQuery";
4
- import "./NotFound.vue";
5
- const { query: e } = m(), a = o(() => e.value.path || ""), p = i(await u(a.value)), d = o(() => {
6
- if (!e.value.props) return {};
2
+ import { computed, watch, shallowRef } from "vue";
3
+ import { useQuery } from "../composables/useQuery";
4
+ import ErrorComponent from "./NotFound.vue";
5
+ const { query } = useQuery(), componentPath = computed(() => query.value.path || ""), componentToRender = shallowRef(await importVueComponent(componentPath.value)), componentProps = computed(() => {
6
+ if (!query.value.props) return {};
7
7
  try {
8
- return new Function(`return ${e.value.props}`)();
8
+ return new Function(`return ${query.value.props}`)();
9
9
  } catch {
10
10
  return {};
11
11
  }
12
12
  });
13
- async function u(n) {
14
- if (!n) return;
15
- const r = window?.__buildAssetsURL;
13
+ async function importVueComponent(path) {
14
+ if (!path) return;
15
+ const buildAssetsURL = window?.__buildAssetsURL;
16
16
  try {
17
- return r ? await import(
17
+ return buildAssetsURL ? await import(
18
18
  /* @vite-ignore */
19
- r(n)
19
+ buildAssetsURL(path)
20
20
  ).then(
21
- (t) => e.value.name ? t?.[e.value.name] : t.default
21
+ (c) => query.value.name ? c?.[query.value.name] : c.default
22
22
  ) : await import(
23
23
  /* @vite-ignore */
24
- "/@fs/" + n
24
+ "/@fs/" + path
25
25
  ).then(
26
- (t) => e.value.name ? t?.[e.value.name] : t.default
26
+ (c) => query.value.name ? c?.[query.value.name] : c.default
27
27
  );
28
28
  } catch {
29
29
  try {
30
30
  return await import(
31
31
  /* @vite-ignore */
32
- n
33
- ).then((t) => e.value.name ? t?.[e.value.name] : t.default);
34
- } catch (t) {
35
- console.log("Error importing component:", t);
32
+ path
33
+ ).then((c) => query.value.name ? c?.[query.value.name] : c.default);
34
+ } catch (err) {
35
+ console.log("Error importing component:", err);
36
36
  return;
37
37
  }
38
38
  }
39
39
  }
40
- s(a, async (n) => p.value = await u(n));
40
+ watch(componentPath, async (path) => componentToRender.value = await importVueComponent(path));
41
41
  </script>
42
42
 
43
43
  <template>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nookuio/vue",
3
3
  "description": "",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "exports": {