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