@nookuio/vue 1.0.8 → 1.0.9

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.
@@ -9,7 +9,7 @@ var _utils = require("../utils");
9
9
  var _helpers = require("../utils/helpers");
10
10
  function g(e) {
11
11
  if (import.meta.server || !e) return;
12
- const o = (0, _helpers.debounce)(() => {
12
+ const r = (0, _helpers.debounce)(() => {
13
13
  const n = (0, _helpers.getInstanceState)(e);
14
14
  window.__nooku__.emit("instance-data-update", n);
15
15
  }, 500);
@@ -19,28 +19,31 @@ function g(e) {
19
19
  };
20
20
  let t;
21
21
  return e.asyncDep && typeof e.asyncDep.then == "function" ? e.asyncDep.then(n => {
22
- t = (0, _vue.watch)([() => n, () => e.devtoolsRawSetupState], o, {
22
+ t = (0, _vue.watch)([() => n, () => e.devtoolsRawSetupState], r, {
23
23
  deep: !0,
24
24
  immediate: !0
25
25
  });
26
- }) : t = (0, _vue.watch)(() => e.devtoolsRawSetupState, o, {
26
+ }) : t = (0, _vue.watch)(() => e.devtoolsRawSetupState, r, {
27
27
  deep: !0,
28
28
  immediate: !0
29
29
  }), () => t?.();
30
30
  }
31
- function useVueComponent(e, o) {
31
+ function useVueComponent(e, r) {
32
32
  const t = (0, _vue.shallowRef)(),
33
33
  n = (0, _vue.shallowRef)(),
34
- r = (0, _vue.shallowRef)(!1);
34
+ o = (0, _vue.shallowRef)(!1);
35
35
  async function s() {
36
- r.value = !0;
37
- const [i, d] = await (0, _utils.trySafe)(() => (0, _utils.importVueComponentFromPath)(e.value, (0, _vue.toValue)(o)), 5e3);
38
- if (d) {
39
- n.value = d, t.value = null, r.value = !1;
36
+ if (o.value = !0, !e) {
37
+ n.value = new Error("Invalid component path"), t.value = null, o.value = !1;
38
+ return;
39
+ }
40
+ const [i, f] = await (0, _utils.trySafe)(() => (0, _utils.importVueComponentFromPath)(e.value, (0, _vue.toValue)(r)), 5e3);
41
+ if (f) {
42
+ n.value = f, t.value = null, o.value = !1;
40
43
  return;
41
44
  }
42
45
  if (!i) {
43
- n.value = new Error(`Failed to load component from path: ${e}`), t.value = null, r.value = !1;
46
+ n.value = new Error(`Failed to load component from path: ${e}`), t.value = null, o.value = !1;
44
47
  return;
45
48
  }
46
49
  n.value = null, t.value = (0, _vue.defineComponent)({
@@ -49,23 +52,23 @@ function useVueComponent(e, o) {
49
52
  attrs: v,
50
53
  slots: y
51
54
  }) {
52
- const f = (0, _vue.shallowRef)(null);
55
+ const d = (0, _vue.shallowRef)(null);
53
56
  let p;
54
- return (0, _vue.watch)(f, l => {
57
+ return (0, _vue.watch)(d, l => {
55
58
  p?.(), l && (p = g(l.$ || l));
56
59
  }), () => (0, _vue.h)(i, {
57
- ref: f,
60
+ ref: d,
58
61
  ...v,
59
62
  ...c
60
63
  }, y);
61
64
  }
62
- }), r.value = !1;
65
+ }), o.value = !1;
63
66
  }
64
- return (0, _vue.watch)([() => e.value, o], s, {
67
+ return (0, _vue.watch)([() => e.value, r], s, {
65
68
  immediate: !0
66
69
  }), {
67
70
  component: t,
68
71
  error: n,
69
- isLoading: r
72
+ isLoading: o
70
73
  };
71
74
  }
@@ -1,9 +1,9 @@
1
- import { watch as u, shallowRef as a, toValue as _, defineComponent as w, h } from "vue";
1
+ import { watch as u, shallowRef as a, toValue as w, defineComponent as _, h } from "vue";
2
2
  import { trySafe as C, importVueComponentFromPath as R } from "../utils/index.mjs";
3
3
  import { debounce as S, getInstanceState as m } from "../utils/helpers.mjs";
4
4
  function g(e) {
5
5
  if (import.meta.server || !e) return;
6
- const o = S(() => {
6
+ const r = S(() => {
7
7
  const n = m(e);
8
8
  window.__nooku__.emit("instance-data-update", n);
9
9
  }, 500);
@@ -13,42 +13,45 @@ function g(e) {
13
13
  };
14
14
  let t;
15
15
  return e.asyncDep && typeof e.asyncDep.then == "function" ? e.asyncDep.then((n) => {
16
- t = u([() => n, () => e.devtoolsRawSetupState], o, {
16
+ t = u([() => n, () => e.devtoolsRawSetupState], r, {
17
17
  deep: !0,
18
18
  immediate: !0
19
19
  });
20
- }) : t = u(() => e.devtoolsRawSetupState, o, {
20
+ }) : t = u(() => e.devtoolsRawSetupState, r, {
21
21
  deep: !0,
22
22
  immediate: !0
23
23
  }), () => t?.();
24
24
  }
25
- export function useVueComponent(e, o) {
26
- const t = a(), n = a(), r = a(!1);
25
+ export function useVueComponent(e, r) {
26
+ const t = a(), n = a(), o = a(!1);
27
27
  async function s() {
28
- r.value = !0;
29
- const [i, d] = await C(() => R(e.value, _(o)), 5e3);
30
- if (d) {
31
- n.value = d, t.value = null, r.value = !1;
28
+ if (o.value = !0, !e) {
29
+ n.value = new Error("Invalid component path"), t.value = null, o.value = !1;
30
+ return;
31
+ }
32
+ const [i, f] = await C(() => R(e.value, w(r)), 5e3);
33
+ if (f) {
34
+ n.value = f, t.value = null, o.value = !1;
32
35
  return;
33
36
  }
34
37
  if (!i) {
35
- n.value = new Error(`Failed to load component from path: ${e}`), t.value = null, r.value = !1;
38
+ n.value = new Error(`Failed to load component from path: ${e}`), t.value = null, o.value = !1;
36
39
  return;
37
40
  }
38
- n.value = null, t.value = w({
41
+ n.value = null, t.value = _({
39
42
  name: "NookuEditorPreview",
40
43
  setup(c, { attrs: v, slots: y }) {
41
- const f = a(null);
44
+ const d = a(null);
42
45
  let p;
43
- return u(f, (l) => {
46
+ return u(d, (l) => {
44
47
  p?.(), l && (p = g(l.$ || l));
45
- }), () => h(i, { ref: f, ...v, ...c }, y);
48
+ }), () => h(i, { ref: d, ...v, ...c }, y);
46
49
  }
47
- }), r.value = !1;
50
+ }), o.value = !1;
48
51
  }
49
- return u([() => e.value, o], s, { immediate: !0 }), {
52
+ return u([() => e.value, r], s, { immediate: !0 }), {
50
53
  component: t,
51
54
  error: n,
52
- isLoading: r
55
+ isLoading: o
53
56
  };
54
57
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nookuio/vue",
3
3
  "description": "",
4
- "version": "1.0.8",
4
+ "version": "1.0.9",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "exports": {