@nookuio/vue 1.0.2 → 1.0.4
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/index.d.ts +2 -0
- package/dist/index.js +21 -20
- package/dist/index.mjs +23 -26
- package/dist/runtime/components/ComponentPreview.vue +40 -0
- package/dist/runtime/components/Error.vue +148 -0
- package/dist/runtime/composables/useComponent.d.ts +6 -0
- package/dist/runtime/composables/useComponent.js +33 -0
- package/dist/runtime/composables/useComponent.mjs +23 -0
- package/dist/runtime/composables/useQuery.js +10 -6
- package/dist/runtime/composables/useQuery.mjs +10 -6
- package/dist/runtime/utils/client.d.ts +5 -0
- package/dist/runtime/utils/client.js +61 -0
- package/dist/runtime/utils/client.mjs +56 -0
- package/dist/runtime/utils/helpers.d.ts +1 -1
- package/dist/runtime/utils/helpers.js +22 -22
- package/dist/runtime/utils/helpers.mjs +21 -21
- package/dist/runtime/utils/index.d.ts +4 -5
- package/dist/runtime/utils/index.js +28 -56
- package/dist/runtime/utils/index.mjs +4 -56
- package/dist/runtime/utils/tryCatch.d.ts +17 -12
- package/dist/runtime/utils/tryCatch.js +21 -20
- package/dist/runtime/utils/tryCatch.mjs +18 -12
- package/dist/runtime/utils/vue.d.ts +2 -0
- package/dist/runtime/utils/vue.js +19 -0
- package/dist/runtime/utils/vue.mjs +22 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +25 -0
- package/dist/utils.mjs +2 -0
- package/package.json +6 -1
- package/dist/runtime/components/NotFound.vue +0 -48
- package/dist/runtime/components/Renderer.vue +0 -56
- package/dist/runtime/utils/tailwind.d.ts +0 -1
- package/dist/runtime/utils/tailwind.js +0 -13
- package/dist/runtime/utils/tailwind.mjs +0 -6
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,42 +3,43 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "ComponentPreview", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ComponentPreview.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
|
|
7
13
|
var _vue = require("vue");
|
|
8
|
-
var
|
|
14
|
+
var _ComponentPreview = _interopRequireDefault(require("./runtime/components/ComponentPreview.vue"));
|
|
9
15
|
var _helpers = require("./runtime/utils/helpers");
|
|
10
16
|
var _utils = require("./runtime/utils");
|
|
11
|
-
var _tailwind = require("./runtime/utils/tailwind");
|
|
12
|
-
var _useQuery = require("./runtime/composables/useQuery");
|
|
13
17
|
var _iframe = require("@nookuio/iframe");
|
|
14
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
18
|
-
const
|
|
19
|
-
console.warn(
|
|
19
|
+
function a(t, r, n) {
|
|
20
|
+
const o = typeof t == "string" ? document.querySelector(t) : t;
|
|
21
|
+
if (!o) {
|
|
22
|
+
const u = typeof t == "string" ? `Failed to mount app: mount target selector "${t}" returned null.` : "Failed to mount app to the target element";
|
|
23
|
+
console.warn(u);
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
22
|
-
const
|
|
23
|
-
return (0, _vue.render)(
|
|
26
|
+
const i = (0, _vue.createVNode)(r, n || {});
|
|
27
|
+
return (0, _vue.render)(i, o), i.component;
|
|
24
28
|
}
|
|
25
|
-
const
|
|
26
|
-
install(t,
|
|
27
|
-
process.env.DEV && (window === void 0 || !(0, _helpers.
|
|
29
|
+
const g = {
|
|
30
|
+
install(t, r) {
|
|
31
|
+
process.env.DEV && (window === void 0 || !(0, _helpers.isInsideEditor)() || window.location.pathname === _iframe.EDITOR_PAGE_PATH && (t.mount = function (n) {
|
|
28
32
|
t._component = {
|
|
29
33
|
render() {
|
|
30
34
|
return (0, _vue.h)(_vue.Suspense, {}, {
|
|
31
|
-
default: () => (0, _vue.h)(
|
|
35
|
+
default: () => (0, _vue.h)(_ComponentPreview.default),
|
|
32
36
|
fallback: () => (0, _vue.h)("div", "Loading...")
|
|
33
37
|
});
|
|
34
38
|
}
|
|
35
39
|
};
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
(0, _tailwind.injectTailwind)(o);
|
|
39
|
-
const r = w(e, t._component);
|
|
40
|
-
return (0, _utils.initializeClient)(t), r?.proxy;
|
|
40
|
+
const o = a(n, t._component);
|
|
41
|
+
return (0, _utils.initializeClient)(t), o?.proxy;
|
|
41
42
|
}));
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
|
-
module.exports =
|
|
45
|
+
module.exports = g;
|
package/dist/index.mjs
CHANGED
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
import { createVNode as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { initializeClient as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
console.warn(r);
|
|
1
|
+
import { createVNode as p, h as e, render as d, Suspense as f } from "vue";
|
|
2
|
+
import m from "./runtime/components/ComponentPreview.vue";
|
|
3
|
+
import { isInsideEditor as l } from "./runtime/utils/helpers.mjs";
|
|
4
|
+
import { initializeClient as s } from "./runtime/utils/index.mjs";
|
|
5
|
+
import { EDITOR_PAGE_PATH as c } from "@nookuio/iframe";
|
|
6
|
+
export { m as ComponentPreview };
|
|
7
|
+
function a(t, r, n) {
|
|
8
|
+
const o = typeof t == "string" ? document.querySelector(t) : t;
|
|
9
|
+
if (!o) {
|
|
10
|
+
const u = typeof t == "string" ? `Failed to mount app: mount target selector "${t}" returned null.` : "Failed to mount app to the target element";
|
|
11
|
+
console.warn(u);
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
|
-
const
|
|
16
|
-
return d(
|
|
14
|
+
const i = p(r, n || {});
|
|
15
|
+
return d(i, o), i.component;
|
|
17
16
|
}
|
|
18
|
-
const
|
|
19
|
-
install(t,
|
|
20
|
-
import.meta.env.DEV && (window === void 0 || !
|
|
17
|
+
const g = {
|
|
18
|
+
install(t, r) {
|
|
19
|
+
import.meta.env.DEV && (window === void 0 || !l() || window.location.pathname === c && (t.mount = function(n) {
|
|
21
20
|
t._component = {
|
|
22
21
|
render() {
|
|
23
|
-
return
|
|
24
|
-
|
|
22
|
+
return e(
|
|
23
|
+
f,
|
|
25
24
|
{},
|
|
26
25
|
{
|
|
27
|
-
default: () =>
|
|
28
|
-
fallback: () =>
|
|
26
|
+
default: () => e(m),
|
|
27
|
+
fallback: () => e("div", "Loading...")
|
|
29
28
|
}
|
|
30
29
|
);
|
|
31
30
|
}
|
|
32
31
|
};
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const r = w(e, t._component);
|
|
36
|
-
return a(t), r?.proxy;
|
|
32
|
+
const o = a(n, t._component);
|
|
33
|
+
return s(t), o?.proxy;
|
|
37
34
|
}));
|
|
38
35
|
}
|
|
39
36
|
};
|
|
40
|
-
export default
|
|
37
|
+
export default g;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useQuery } from "../composables/useQuery";
|
|
4
|
+
import { useVueComponent } from "../composables/useComponent";
|
|
5
|
+
import ErrorComponent from "./Error.vue";
|
|
6
|
+
const { query } = useQuery(), props = defineProps({
|
|
7
|
+
path: { type: String, required: !1 },
|
|
8
|
+
name: { type: String, required: !1 },
|
|
9
|
+
props: { type: String, required: !1 }
|
|
10
|
+
}), componentPath = computed(() => props.path || query.value.path || ""), {
|
|
11
|
+
component: componentToRender,
|
|
12
|
+
error,
|
|
13
|
+
isLoading
|
|
14
|
+
} = useVueComponent(componentPath, () => props.name || query.value.name), componentProps = computed(() => {
|
|
15
|
+
if (!props.props && !query.value.props) return {};
|
|
16
|
+
try {
|
|
17
|
+
return new Function(`return ${props.props || query.value.props}`)();
|
|
18
|
+
} catch {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<template>
|
|
25
|
+
<ErrorComponent
|
|
26
|
+
v-if="(error || !componentToRender) && !isLoading"
|
|
27
|
+
:error="error"
|
|
28
|
+
/>
|
|
29
|
+
<component
|
|
30
|
+
v-else-if="componentToRender"
|
|
31
|
+
:is="componentToRender"
|
|
32
|
+
v-bind="componentProps"
|
|
33
|
+
/>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<style>
|
|
37
|
+
body {
|
|
38
|
+
margin: 0 !important;
|
|
39
|
+
}
|
|
40
|
+
</style>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
const props = defineProps({
|
|
3
|
+
error: { type: null, required: !0 }
|
|
4
|
+
});
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<div class="error-page">
|
|
9
|
+
<div class="error-card">
|
|
10
|
+
<div
|
|
11
|
+
class="error-icon"
|
|
12
|
+
aria-hidden="true"
|
|
13
|
+
>
|
|
14
|
+
!
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<h1 class="error-title">
|
|
18
|
+
<span v-if="props.error?.message">Something went wrong</span>
|
|
19
|
+
<span v-else>Component not found</span>
|
|
20
|
+
</h1>
|
|
21
|
+
|
|
22
|
+
<p class="error-message">
|
|
23
|
+
<span v-if="props.error?.message">
|
|
24
|
+
{{ props.error.message }}
|
|
25
|
+
</span>
|
|
26
|
+
<span v-else> The requested component could not be found. </span>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<div
|
|
30
|
+
v-if="props.error?.stack"
|
|
31
|
+
class="error-details"
|
|
32
|
+
>
|
|
33
|
+
<span class="error-details-label">Details</span>
|
|
34
|
+
<pre class="error-details-text"
|
|
35
|
+
>{{ props.error.stack }}
|
|
36
|
+
</pre>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<style scoped>
|
|
43
|
+
.error-page {
|
|
44
|
+
display: flex;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
align-items: center;
|
|
47
|
+
padding: 1.5rem;
|
|
48
|
+
position: fixed;
|
|
49
|
+
inset: 0;
|
|
50
|
+
height: 100vh;
|
|
51
|
+
background-color: #050608;
|
|
52
|
+
color: #f9fafb;
|
|
53
|
+
box-sizing: border-box;
|
|
54
|
+
font-family:
|
|
55
|
+
system-ui,
|
|
56
|
+
-apple-system,
|
|
57
|
+
BlinkMacSystemFont,
|
|
58
|
+
'Segoe UI',
|
|
59
|
+
sans-serif;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.error-card {
|
|
63
|
+
width: 100%;
|
|
64
|
+
max-width: 32rem;
|
|
65
|
+
padding: 1.75rem 1.75rem 1.5rem;
|
|
66
|
+
background-color: #0b0d10;
|
|
67
|
+
border-radius: 0.9rem;
|
|
68
|
+
border: 1px solid #1f2933;
|
|
69
|
+
box-shadow: 0 18px 45px rgba(0, 0, 0, 0.6);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.error-icon {
|
|
73
|
+
width: 2.5rem;
|
|
74
|
+
height: 2.5rem;
|
|
75
|
+
border-radius: 999px;
|
|
76
|
+
border: 1px solid #4b5563;
|
|
77
|
+
color: #f97373;
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
font-weight: 600;
|
|
82
|
+
margin-bottom: 1.25rem;
|
|
83
|
+
font-size: 1.1rem;
|
|
84
|
+
background-color: #111827;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.error-title {
|
|
88
|
+
font-size: 1.5rem;
|
|
89
|
+
line-height: 1.3;
|
|
90
|
+
margin: 0;
|
|
91
|
+
color: #f9fafb;
|
|
92
|
+
letter-spacing: 0.02em;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.error-message {
|
|
96
|
+
margin-top: 0.75rem;
|
|
97
|
+
margin-bottom: 0;
|
|
98
|
+
font-size: 0.95rem;
|
|
99
|
+
line-height: 1.6;
|
|
100
|
+
color: #9ca3af;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.error-details {
|
|
104
|
+
margin-top: 1.25rem;
|
|
105
|
+
padding-top: 1rem;
|
|
106
|
+
border-top: 1px solid #111827;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.error-details-label {
|
|
110
|
+
display: block;
|
|
111
|
+
font-size: 0.75rem;
|
|
112
|
+
text-transform: uppercase;
|
|
113
|
+
letter-spacing: 0.12em;
|
|
114
|
+
color: #6b7280;
|
|
115
|
+
margin-bottom: 0.5rem;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.error-details-text {
|
|
119
|
+
margin: 0;
|
|
120
|
+
padding: 0.75rem 0.85rem;
|
|
121
|
+
background-color: #050608;
|
|
122
|
+
border-radius: 0.5rem;
|
|
123
|
+
font-size: 0.78rem;
|
|
124
|
+
color: #d1d5db;
|
|
125
|
+
overflow-x: auto;
|
|
126
|
+
white-space: pre-wrap;
|
|
127
|
+
word-break: break-word;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/* Responsive adjustments */
|
|
131
|
+
@media (max-width: 600px) {
|
|
132
|
+
.error-card {
|
|
133
|
+
padding: 1.5rem 1.25rem 1.25rem;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.error-title {
|
|
137
|
+
font-size: 1.25rem;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.error-message {
|
|
141
|
+
font-size: 0.9rem;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.error-details-text {
|
|
145
|
+
font-size: 0.75rem;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
</style>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Component, Ref, MaybeRefOrGetter } from 'vue';
|
|
2
|
+
export declare function useVueComponent(path: Ref<string>, name?: MaybeRefOrGetter<string>): {
|
|
3
|
+
component: import("vue").ShallowRef<Component | null | undefined, Component | null | undefined>;
|
|
4
|
+
error: import("vue").ShallowRef<Error | null | undefined, Error | null | undefined>;
|
|
5
|
+
isLoading: import("vue").ShallowRef<boolean, boolean>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useVueComponent = useVueComponent;
|
|
7
|
+
var _vue = require("vue");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
function useVueComponent(r, l) {
|
|
10
|
+
const o = (0, _vue.shallowRef)(),
|
|
11
|
+
t = (0, _vue.shallowRef)(),
|
|
12
|
+
e = (0, _vue.shallowRef)(!1);
|
|
13
|
+
async function f() {
|
|
14
|
+
e.value = !0;
|
|
15
|
+
const [u, a] = await (0, _utils.trySafe)(() => (0, _utils.importVueComponentFromPath)(r.value, (0, _vue.toValue)(l)), 5e3);
|
|
16
|
+
if (a) {
|
|
17
|
+
t.value = a, o.value = null, e.value = !1;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (!u) {
|
|
21
|
+
t.value = new Error(`Failed to load component from path: ${r}`), o.value = null, e.value = !1;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
t.value = null, o.value = u, e.value = !1;
|
|
25
|
+
}
|
|
26
|
+
return (0, _vue.watch)([() => r.value, l], f, {
|
|
27
|
+
immediate: !0
|
|
28
|
+
}), {
|
|
29
|
+
component: o,
|
|
30
|
+
error: t,
|
|
31
|
+
isLoading: e
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { watch as m, shallowRef as n, toValue as i } from "vue";
|
|
2
|
+
import { trySafe as s, importVueComponentFromPath as p } from "../utils/index.mjs";
|
|
3
|
+
export function useVueComponent(r, l) {
|
|
4
|
+
const o = n(), t = n(), e = n(!1);
|
|
5
|
+
async function f() {
|
|
6
|
+
e.value = !0;
|
|
7
|
+
const [u, a] = await s(() => p(r.value, i(l)), 5e3);
|
|
8
|
+
if (a) {
|
|
9
|
+
t.value = a, o.value = null, e.value = !1;
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!u) {
|
|
13
|
+
t.value = new Error(`Failed to load component from path: ${r}`), o.value = null, e.value = !1;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
t.value = null, o.value = u, e.value = !1;
|
|
17
|
+
}
|
|
18
|
+
return m([() => r.value, l], f, { immediate: !0 }), {
|
|
19
|
+
component: o,
|
|
20
|
+
error: t,
|
|
21
|
+
isLoading: e
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -7,16 +7,20 @@ exports.getQuery = getQuery;
|
|
|
7
7
|
exports.useQuery = useQuery;
|
|
8
8
|
var _vue = require("vue");
|
|
9
9
|
function getQuery() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
try {
|
|
11
|
+
const t = new URLSearchParams(window.location.search),
|
|
12
|
+
e = {};
|
|
13
|
+
return t.forEach((n, r) => e[r] = n), e;
|
|
14
|
+
} catch {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
18
|
function useQuery() {
|
|
15
|
-
const
|
|
19
|
+
const t = (0, _vue.ref)(getQuery()),
|
|
16
20
|
e = () => {
|
|
17
|
-
|
|
21
|
+
t.value = getQuery();
|
|
18
22
|
};
|
|
19
23
|
return (0, _vue.onMounted)(() => window.addEventListener("popstate", e)), (0, _vue.onBeforeUnmount)(() => window.removeEventListener("popstate", e)), {
|
|
20
|
-
query:
|
|
24
|
+
query: t
|
|
21
25
|
};
|
|
22
26
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as o, onMounted as a, onBeforeUnmount as s } from "vue";
|
|
2
2
|
export function getQuery() {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
try {
|
|
4
|
+
const t = new URLSearchParams(window.location.search), e = {};
|
|
5
|
+
return t.forEach((n, r) => e[r] = n), e;
|
|
6
|
+
} catch {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
5
9
|
}
|
|
6
10
|
export function useQuery() {
|
|
7
|
-
const
|
|
8
|
-
|
|
11
|
+
const t = o(getQuery()), e = () => {
|
|
12
|
+
t.value = getQuery();
|
|
9
13
|
};
|
|
10
|
-
return
|
|
14
|
+
return a(() => window.addEventListener("popstate", e)), s(() => window.removeEventListener("popstate", e)), { query: t };
|
|
11
15
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.initializeClient = initializeClient;
|
|
7
|
+
var _vue = require("vue");
|
|
8
|
+
var _helpers = require("./helpers");
|
|
9
|
+
var _iframe = require("@nookuio/iframe/iframe");
|
|
10
|
+
var _useQuery = require("../composables/useQuery");
|
|
11
|
+
const d = new Map();
|
|
12
|
+
function initializeClient(t) {
|
|
13
|
+
const i = (0, _useQuery.getQuery)(),
|
|
14
|
+
o = (0, _vue.computed)(() => i.path || ""),
|
|
15
|
+
r = (0, _iframe.createVueIframeClient)({
|
|
16
|
+
getInstanceData(e) {
|
|
17
|
+
const n = d.get(e);
|
|
18
|
+
return n ? (0, _helpers.getInstanceState)(n) : {};
|
|
19
|
+
},
|
|
20
|
+
navigateTo(e) {
|
|
21
|
+
e && e && I(e);
|
|
22
|
+
},
|
|
23
|
+
updateCode(e, n) {}
|
|
24
|
+
}, {
|
|
25
|
+
disableDefaultConsole: !1
|
|
26
|
+
});
|
|
27
|
+
return t.config.errorHandler = e => {
|
|
28
|
+
r.emit("console", "error", [e?.stack]);
|
|
29
|
+
}, t.mixin({
|
|
30
|
+
created() {
|
|
31
|
+
const e = this.$options.__file?.replace(/\\/g, "/") || "";
|
|
32
|
+
if (!e || e.includes("node_modules")) return;
|
|
33
|
+
const n = (0, _vue.computed)(() => o.value === e),
|
|
34
|
+
s = this.$;
|
|
35
|
+
d.set(e, s);
|
|
36
|
+
let a;
|
|
37
|
+
async function f() {
|
|
38
|
+
const c = (0, _helpers.getInstanceState)(s);
|
|
39
|
+
r?.emit("instance-data-update", c);
|
|
40
|
+
}
|
|
41
|
+
const m = (0, _helpers.debounce)(() => f(), 500);
|
|
42
|
+
(0, _vue.watch)(n, c => {
|
|
43
|
+
c ? a = (0, _vue.watch)(() => s.devtoolsRawSetupState, m, {
|
|
44
|
+
deep: !0,
|
|
45
|
+
immediate: !0
|
|
46
|
+
}) : a && (a?.(), a = void 0);
|
|
47
|
+
}, {
|
|
48
|
+
immediate: !0
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
beforeUnmount() {
|
|
52
|
+
const e = this.$options.__file?.replace(/\\/g, "/") || "";
|
|
53
|
+
!e || e.includes("node_modules") || o.value !== e && d.delete(e);
|
|
54
|
+
}
|
|
55
|
+
}), r;
|
|
56
|
+
}
|
|
57
|
+
function I(t, i = {}) {
|
|
58
|
+
return new Promise(o => {
|
|
59
|
+
i.replace ? history.replaceState({}, "", t) : history.pushState({}, "", t), window.dispatchEvent(new Event("popstate")), o();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { computed as u, watch as l } from "vue";
|
|
2
|
+
import { debounce as h, getInstanceState as p } from "./helpers.mjs";
|
|
3
|
+
import { createVueIframeClient as g } from "@nookuio/iframe/iframe";
|
|
4
|
+
import { getQuery as v } from "../composables/useQuery.mjs";
|
|
5
|
+
const d = /* @__PURE__ */ new Map();
|
|
6
|
+
export function initializeClient(t) {
|
|
7
|
+
const i = v(), o = u(() => i.path || ""), r = g(
|
|
8
|
+
{
|
|
9
|
+
getInstanceData(e) {
|
|
10
|
+
const n = d.get(e);
|
|
11
|
+
return n ? p(n) : {};
|
|
12
|
+
},
|
|
13
|
+
navigateTo(e) {
|
|
14
|
+
e && e && I(e);
|
|
15
|
+
},
|
|
16
|
+
updateCode(e, n) {
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{ disableDefaultConsole: !1 }
|
|
20
|
+
);
|
|
21
|
+
return t.config.errorHandler = (e) => {
|
|
22
|
+
r.emit("console", "error", [e?.stack]);
|
|
23
|
+
}, t.mixin({
|
|
24
|
+
created() {
|
|
25
|
+
const e = this.$options.__file?.replace(/\\/g, "/") || "";
|
|
26
|
+
if (!e || e.includes("node_modules")) return;
|
|
27
|
+
const n = u(() => o.value === e), s = this.$;
|
|
28
|
+
d.set(e, s);
|
|
29
|
+
let a;
|
|
30
|
+
async function f() {
|
|
31
|
+
const c = p(s);
|
|
32
|
+
r?.emit("instance-data-update", c);
|
|
33
|
+
}
|
|
34
|
+
const m = h(() => f(), 500);
|
|
35
|
+
l(
|
|
36
|
+
n,
|
|
37
|
+
(c) => {
|
|
38
|
+
c ? a = l(() => s.devtoolsRawSetupState, m, {
|
|
39
|
+
deep: !0,
|
|
40
|
+
immediate: !0
|
|
41
|
+
}) : a && (a?.(), a = void 0);
|
|
42
|
+
},
|
|
43
|
+
{ immediate: !0 }
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
beforeUnmount() {
|
|
47
|
+
const e = this.$options.__file?.replace(/\\/g, "/") || "";
|
|
48
|
+
!e || e.includes("node_modules") || o.value !== e && d.delete(e);
|
|
49
|
+
}
|
|
50
|
+
}), r;
|
|
51
|
+
}
|
|
52
|
+
function I(t, i = {}) {
|
|
53
|
+
return new Promise((o) => {
|
|
54
|
+
i.replace ? history.replaceState({}, "", t) : history.pushState({}, "", t), window.dispatchEvent(new Event("popstate")), o();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ComponentInternalInstance } from 'vue';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function isInsideEditor(): boolean;
|
|
3
3
|
export declare function debounce(cb: Function, delay?: number): (...args: any[]) => void;
|
|
4
4
|
export declare function getInstanceState(instance: ComponentInternalInstance | undefined, onTemplate?: boolean): Record<string, any>;
|
|
@@ -5,34 +5,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.debounce = debounce;
|
|
7
7
|
exports.getInstanceState = getInstanceState;
|
|
8
|
-
exports.
|
|
9
|
-
function
|
|
10
|
-
return window === void 0 ? !1 : !!(window.parent && window.location !== window.parent.location || window.top !== window.self);
|
|
8
|
+
exports.isInsideEditor = isInsideEditor;
|
|
9
|
+
function isInsideEditor() {
|
|
10
|
+
return !import.meta.client || window === void 0 ? !1 : !!(window.parent && window.location !== window.parent.location || window.top !== window.self);
|
|
11
11
|
}
|
|
12
|
-
function debounce(
|
|
13
|
-
let
|
|
12
|
+
function debounce(e, t = 500) {
|
|
13
|
+
let n;
|
|
14
14
|
return (...o) => {
|
|
15
|
-
clearTimeout(
|
|
16
|
-
|
|
15
|
+
clearTimeout(n), n = setTimeout(() => {
|
|
16
|
+
e(...o);
|
|
17
17
|
}, t);
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
const i = "__v_isRef",
|
|
21
|
-
|
|
22
|
-
function s(
|
|
23
|
-
return
|
|
24
|
-
value:
|
|
21
|
+
u = "__v_isReadonly";
|
|
22
|
+
function s(e, t) {
|
|
23
|
+
return e?.[i] ? t ? e.value : {
|
|
24
|
+
value: e.value,
|
|
25
25
|
[i]: "true",
|
|
26
|
-
[
|
|
27
|
-
} :
|
|
26
|
+
[u]: !!e.__v_isReadonly
|
|
27
|
+
} : e;
|
|
28
28
|
}
|
|
29
|
-
function getInstanceState(
|
|
30
|
-
if (!
|
|
31
|
-
const
|
|
32
|
-
return Object.entries(
|
|
33
|
-
|
|
34
|
-
}), Object.entries(
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
}),
|
|
29
|
+
function getInstanceState(e, t) {
|
|
30
|
+
if (!e) return {};
|
|
31
|
+
const n = {};
|
|
32
|
+
return Object.entries(e.props).forEach(([o, r]) => {
|
|
33
|
+
n[o] = r;
|
|
34
|
+
}), Object.entries(e.devtoolsRawSetupState ?? e.setupState).forEach(([o, r]) => {
|
|
35
|
+
const a = s(r, t);
|
|
36
|
+
n[o] = a;
|
|
37
|
+
}), n;
|
|
38
38
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export function
|
|
2
|
-
return window === void 0 ? !1 : !!(window.parent && window.location !== window.parent.location || window.top !== window.self);
|
|
1
|
+
export function isInsideEditor() {
|
|
2
|
+
return !import.meta.client || window === void 0 ? !1 : !!(window.parent && window.location !== window.parent.location || window.top !== window.self);
|
|
3
3
|
}
|
|
4
|
-
export function debounce(
|
|
5
|
-
let
|
|
4
|
+
export function debounce(e, t = 500) {
|
|
5
|
+
let n;
|
|
6
6
|
return (...o) => {
|
|
7
|
-
clearTimeout(
|
|
8
|
-
|
|
7
|
+
clearTimeout(n), n = setTimeout(() => {
|
|
8
|
+
e(...o);
|
|
9
9
|
}, t);
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
const i = "__v_isRef",
|
|
13
|
-
function s(
|
|
14
|
-
return
|
|
15
|
-
value:
|
|
12
|
+
const i = "__v_isRef", u = "__v_isReadonly";
|
|
13
|
+
function s(e, t) {
|
|
14
|
+
return e?.[i] ? t ? e.value : {
|
|
15
|
+
value: e.value,
|
|
16
16
|
[i]: "true",
|
|
17
17
|
// as string
|
|
18
|
-
[
|
|
19
|
-
} :
|
|
18
|
+
[u]: !!e.__v_isReadonly
|
|
19
|
+
} : e;
|
|
20
20
|
}
|
|
21
|
-
export function getInstanceState(
|
|
22
|
-
if (!
|
|
23
|
-
const
|
|
24
|
-
return Object.entries(
|
|
25
|
-
|
|
26
|
-
}), Object.entries(
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
}),
|
|
21
|
+
export function getInstanceState(e, t) {
|
|
22
|
+
if (!e) return {};
|
|
23
|
+
const n = {};
|
|
24
|
+
return Object.entries(e.props).forEach(([o, r]) => {
|
|
25
|
+
n[o] = r;
|
|
26
|
+
}), Object.entries(e.devtoolsRawSetupState ?? e.setupState).forEach(([o, r]) => {
|
|
27
|
+
const a = s(r, t);
|
|
28
|
+
n[o] = a;
|
|
29
|
+
}), n;
|
|
30
30
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export declare function initializeClient(app: App): any;
|
|
1
|
+
export { initializeClient } from './client';
|
|
2
|
+
export { trySafe } from './tryCatch';
|
|
3
|
+
export { importVueComponentFromPath } from './vue';
|
|
4
|
+
export { isInsideEditor } from './helpers';
|
|
@@ -3,59 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
s = this.$;
|
|
35
|
-
d.set(e, s);
|
|
36
|
-
let a;
|
|
37
|
-
async function f() {
|
|
38
|
-
const c = (0, _helpers.getInstanceState)(s);
|
|
39
|
-
r?.emit("instance-data-update", c);
|
|
40
|
-
}
|
|
41
|
-
const m = (0, _helpers.debounce)(() => f(), 500);
|
|
42
|
-
(0, _vue.watch)(n, c => {
|
|
43
|
-
c ? a = (0, _vue.watch)(() => s.devtoolsRawSetupState, m, {
|
|
44
|
-
deep: !0,
|
|
45
|
-
immediate: !0
|
|
46
|
-
}) : a && (a?.(), a = void 0);
|
|
47
|
-
}, {
|
|
48
|
-
immediate: !0
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
beforeUnmount() {
|
|
52
|
-
const e = this.$options.__file?.replace(/\\/g, "/") || "";
|
|
53
|
-
!e || e.includes("node_modules") || o.value !== e && d.delete(e);
|
|
54
|
-
}
|
|
55
|
-
}), r;
|
|
56
|
-
}
|
|
57
|
-
function I(t, i = {}) {
|
|
58
|
-
return new Promise(o => {
|
|
59
|
-
i.replace ? history.replaceState({}, "", t) : history.pushState({}, "", t), window.dispatchEvent(new Event("popstate")), o();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
6
|
+
Object.defineProperty(exports, "importVueComponentFromPath", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _vue.importVueComponentFromPath;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "initializeClient", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _client.initializeClient;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "isInsideEditor", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _helpers.isInsideEditor;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "trySafe", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _tryCatch.trySafe;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _client = require("./client");
|
|
31
|
+
var _tryCatch = require("./tryCatch");
|
|
32
|
+
var _vue = require("./vue");
|
|
33
|
+
var _helpers = require("./helpers");
|
|
@@ -1,56 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const d = /* @__PURE__ */ new Map();
|
|
6
|
-
export function initializeClient(t) {
|
|
7
|
-
const i = v(), o = u(() => i.path || ""), r = g(
|
|
8
|
-
{
|
|
9
|
-
getInstanceData(e) {
|
|
10
|
-
const n = d.get(e);
|
|
11
|
-
return n ? p(n) : {};
|
|
12
|
-
},
|
|
13
|
-
navigateTo(e) {
|
|
14
|
-
e && e && I(e);
|
|
15
|
-
},
|
|
16
|
-
updateCode(e, n) {
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{ disableDefaultConsole: !1 }
|
|
20
|
-
);
|
|
21
|
-
return t.config.errorHandler = (e) => {
|
|
22
|
-
r.emit("console", "error", [e?.stack]);
|
|
23
|
-
}, t.mixin({
|
|
24
|
-
created() {
|
|
25
|
-
const e = this.$options.__file?.replace(/\\/g, "/") || "";
|
|
26
|
-
if (!e || e.includes("node_modules")) return;
|
|
27
|
-
const n = u(() => o.value === e), s = this.$;
|
|
28
|
-
d.set(e, s);
|
|
29
|
-
let a;
|
|
30
|
-
async function f() {
|
|
31
|
-
const c = p(s);
|
|
32
|
-
r?.emit("instance-data-update", c);
|
|
33
|
-
}
|
|
34
|
-
const m = h(() => f(), 500);
|
|
35
|
-
l(
|
|
36
|
-
n,
|
|
37
|
-
(c) => {
|
|
38
|
-
c ? a = l(() => s.devtoolsRawSetupState, m, {
|
|
39
|
-
deep: !0,
|
|
40
|
-
immediate: !0
|
|
41
|
-
}) : a && (a?.(), a = void 0);
|
|
42
|
-
},
|
|
43
|
-
{ immediate: !0 }
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
beforeUnmount() {
|
|
47
|
-
const e = this.$options.__file?.replace(/\\/g, "/") || "";
|
|
48
|
-
!e || e.includes("node_modules") || o.value !== e && d.delete(e);
|
|
49
|
-
}
|
|
50
|
-
}), r;
|
|
51
|
-
}
|
|
52
|
-
function I(t, i = {}) {
|
|
53
|
-
return new Promise((o) => {
|
|
54
|
-
i.replace ? history.replaceState({}, "", t) : history.pushState({}, "", t), window.dispatchEvent(new Event("popstate")), o();
|
|
55
|
-
});
|
|
56
|
-
}
|
|
1
|
+
export { initializeClient } from "./client.mjs";
|
|
2
|
+
export { trySafe } from "./tryCatch.mjs";
|
|
3
|
+
export { importVueComponentFromPath } from "./vue.mjs";
|
|
4
|
+
export { isInsideEditor } from "./helpers.mjs";
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
type
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
type AttemptSuccess<T> = readonly [T, null];
|
|
2
|
+
type AttemptFailure<E> = readonly [null, E];
|
|
3
|
+
type AttemptResult<E, T> = AttemptSuccess<T> | AttemptFailure<E>;
|
|
4
|
+
export declare class TimeoutError extends Error {
|
|
5
|
+
readonly timeoutMs?: number | undefined;
|
|
6
|
+
constructor(timeoutMs?: number | undefined);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Executes `func` and returns either `[result, null]` on success or `[null, error]` on failure.
|
|
10
|
+
* If `timeout` (in milliseconds) is provided and the operation doesn't settle within that time,
|
|
11
|
+
* the returned result will be `[null, TimeoutError]`.
|
|
12
|
+
*
|
|
13
|
+
* Notes:
|
|
14
|
+
* - The function `func` is invoked immediately. If it returns a Promise, we await it.
|
|
15
|
+
* - A timer is cleared as soon as the operation settles to avoid leaks.
|
|
16
|
+
*/
|
|
17
|
+
export declare function trySafe<T = any, E = Error>(func: () => T | Promise<T>, timeout?: number): Promise<AttemptResult<E, T>>;
|
|
13
18
|
export {};
|
|
@@ -3,29 +3,30 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} catch (r) {
|
|
14
|
-
if (e === "throw") throw r;
|
|
15
|
-
return e && e(r), {
|
|
16
|
-
error: r
|
|
17
|
-
};
|
|
6
|
+
exports.TimeoutError = void 0;
|
|
7
|
+
exports.trySafe = trySafe;
|
|
8
|
+
class TimeoutError extends Error {
|
|
9
|
+
constructor(e) {
|
|
10
|
+
super(typeof e == "number" ? `Operation timed out after ${e} ms` : "Operation timed out");
|
|
11
|
+
this.timeoutMs = e;
|
|
12
|
+
this.name = "TimeoutError";
|
|
18
13
|
}
|
|
19
14
|
}
|
|
20
|
-
|
|
15
|
+
exports.TimeoutError = TimeoutError;
|
|
16
|
+
async function trySafe(n, t) {
|
|
17
|
+
let e = null;
|
|
21
18
|
try {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
const r = (async () => n())();
|
|
20
|
+
if (typeof t == "number" && t > 0) {
|
|
21
|
+
const o = new Promise((l, u) => {
|
|
22
|
+
e = setTimeout(() => {
|
|
23
|
+
u(new TimeoutError(t));
|
|
24
|
+
}, t);
|
|
25
|
+
}),
|
|
26
|
+
a = await Promise.race([r, o]);
|
|
27
|
+
return e && (clearTimeout(e), e = null), [a, null];
|
|
28
|
+
} else return [await r, null];
|
|
25
29
|
} catch (r) {
|
|
26
|
-
|
|
27
|
-
return e && e(r), {
|
|
28
|
-
error: r
|
|
29
|
-
};
|
|
30
|
+
return e && (clearTimeout(e), e = null), [null, r];
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
throw r;
|
|
7
|
-
return e && e(r), { error: r };
|
|
1
|
+
export class TimeoutError extends Error {
|
|
2
|
+
constructor(e) {
|
|
3
|
+
super(typeof e == "number" ? `Operation timed out after ${e} ms` : "Operation timed out");
|
|
4
|
+
this.timeoutMs = e;
|
|
5
|
+
this.name = "TimeoutError";
|
|
8
6
|
}
|
|
9
7
|
}
|
|
10
|
-
export function
|
|
8
|
+
export async function trySafe(n, t) {
|
|
9
|
+
let e = null;
|
|
11
10
|
try {
|
|
12
|
-
|
|
11
|
+
const r = (async () => n())();
|
|
12
|
+
if (typeof t == "number" && t > 0) {
|
|
13
|
+
const o = new Promise((l, u) => {
|
|
14
|
+
e = setTimeout(() => {
|
|
15
|
+
u(new TimeoutError(t));
|
|
16
|
+
}, t);
|
|
17
|
+
}), a = await Promise.race([r, o]);
|
|
18
|
+
return e && (clearTimeout(e), e = null), [a, null];
|
|
19
|
+
} else
|
|
20
|
+
return [await r, null];
|
|
13
21
|
} catch (r) {
|
|
14
|
-
|
|
15
|
-
throw r;
|
|
16
|
-
return e && e(r), { error: r };
|
|
22
|
+
return e && (clearTimeout(e), e = null), [null, r];
|
|
17
23
|
}
|
|
18
24
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.importVueComponentFromPath = importVueComponentFromPath;
|
|
7
|
+
async function importVueComponentFromPath(n, e) {
|
|
8
|
+
if (!n) return [void 0, void 0];
|
|
9
|
+
const r = window?.__buildAssetsURL;
|
|
10
|
+
try {
|
|
11
|
+
return r ? await Promise.resolve(`${r(n)}`).then(s => require(s)).then(t => e ? t?.[e] : t.default) : await Promise.resolve(`${"/@fs/" + n}`).then(s => require(s)).then(t => e ? t?.[e] : t.default);
|
|
12
|
+
} catch {
|
|
13
|
+
try {
|
|
14
|
+
return await Promise.resolve(`${n}`).then(s => require(s)).then(t => e ? t?.[e] : t.default);
|
|
15
|
+
} catch (t) {
|
|
16
|
+
throw t;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export async function importVueComponentFromPath(n, e) {
|
|
2
|
+
if (!n) return [void 0, void 0];
|
|
3
|
+
const r = window?.__buildAssetsURL;
|
|
4
|
+
try {
|
|
5
|
+
return r ? await import(
|
|
6
|
+
/* @vite-ignore */
|
|
7
|
+
r(n)
|
|
8
|
+
).then((t) => e ? t?.[e] : t.default) : await import(
|
|
9
|
+
/* @vite-ignore */
|
|
10
|
+
"/@fs/" + n
|
|
11
|
+
).then((t) => e ? t?.[e] : t.default);
|
|
12
|
+
} catch {
|
|
13
|
+
try {
|
|
14
|
+
return await import(
|
|
15
|
+
/* @vite-ignore */
|
|
16
|
+
n
|
|
17
|
+
).then((t) => e ? t?.[e] : t.default);
|
|
18
|
+
} catch (t) {
|
|
19
|
+
throw t;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "importVueComponentFromPath", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _utils.importVueComponentFromPath;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "isInsideEditor", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _utils.isInsideEditor;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "useVueComponent", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _useComponent.useVueComponent;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _utils = require("./runtime/utils");
|
|
25
|
+
var _useComponent = require("./runtime/composables/useComponent");
|
package/dist/utils.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nookuio/vue",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"exports": {
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
"types": "./dist/vite-plugin.d.ts",
|
|
15
15
|
"require": "./dist/vite-plugin.js",
|
|
16
16
|
"import": "./dist/vite-plugin.mjs"
|
|
17
|
+
},
|
|
18
|
+
"./utils": {
|
|
19
|
+
"types": "./dist/utils.d.ts",
|
|
20
|
+
"require": "./dist/utils.js",
|
|
21
|
+
"import": "./dist/utils.mjs"
|
|
17
22
|
}
|
|
18
23
|
},
|
|
19
24
|
"files": [
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="not-found">
|
|
3
|
-
<div class="content">
|
|
4
|
-
<h1>Component Not Found</h1>
|
|
5
|
-
<p>The requested component could not be found.</p>
|
|
6
|
-
</div>
|
|
7
|
-
</div>
|
|
8
|
-
</template>
|
|
9
|
-
|
|
10
|
-
<style scoped>
|
|
11
|
-
.not-found {
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
height: 100vh;
|
|
16
|
-
background-color: #f9f9f9;
|
|
17
|
-
color: #333;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.content {
|
|
21
|
-
text-align: center;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
h1 {
|
|
25
|
-
font-size: 2rem;
|
|
26
|
-
margin: 0;
|
|
27
|
-
color: #0f0f0f;
|
|
28
|
-
font-weight: bold;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
p {
|
|
32
|
-
font-size: 1.25rem;
|
|
33
|
-
margin-top: 0.5rem;
|
|
34
|
-
color: #666;
|
|
35
|
-
}
|
|
36
|
-
/* Responsive adjustments */
|
|
37
|
-
@media (max-width: 600px) {
|
|
38
|
-
h1 {
|
|
39
|
-
font-size: 1.5rem;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
p {
|
|
43
|
-
font-size: 1rem;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
</style>
|
|
48
|
-
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
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
|
-
try {
|
|
8
|
-
return new Function(`return ${query.value.props}`)();
|
|
9
|
-
} catch {
|
|
10
|
-
return {};
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
async function importVueComponent(path) {
|
|
14
|
-
if (!path) return;
|
|
15
|
-
const buildAssetsURL = window?.__buildAssetsURL;
|
|
16
|
-
try {
|
|
17
|
-
return buildAssetsURL ? await import(
|
|
18
|
-
/* @vite-ignore */
|
|
19
|
-
buildAssetsURL(path)
|
|
20
|
-
).then(
|
|
21
|
-
(c) => query.value.name ? c?.[query.value.name] : c.default
|
|
22
|
-
) : await import(
|
|
23
|
-
/* @vite-ignore */
|
|
24
|
-
"/@fs/" + path
|
|
25
|
-
).then(
|
|
26
|
-
(c) => query.value.name ? c?.[query.value.name] : c.default
|
|
27
|
-
);
|
|
28
|
-
} catch {
|
|
29
|
-
try {
|
|
30
|
-
return await import(
|
|
31
|
-
/* @vite-ignore */
|
|
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
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
watch(componentPath, async (path) => componentToRender.value = await importVueComponent(path));
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<template>
|
|
44
|
-
<component
|
|
45
|
-
v-if="componentToRender"
|
|
46
|
-
:is="componentToRender"
|
|
47
|
-
v-bind="componentProps"
|
|
48
|
-
/>
|
|
49
|
-
<ErrorComponent v-else />
|
|
50
|
-
</template>
|
|
51
|
-
|
|
52
|
-
<style>
|
|
53
|
-
body {
|
|
54
|
-
margin: 0;
|
|
55
|
-
}
|
|
56
|
-
</style>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function injectTailwind(tailwindVersion: 3 | 4 | undefined): void;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.injectTailwind = injectTailwind;
|
|
7
|
-
function injectTailwind(e) {
|
|
8
|
-
const n = document.querySelector("#nooku-injected-tailwind-css");
|
|
9
|
-
if (n && e === void 0 && document.removeChild(n), n || e === void 0) return;
|
|
10
|
-
const c = e === 3 ? "https://cdn.tailwindcss.com" : "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4",
|
|
11
|
-
t = document.createElement("script");
|
|
12
|
-
t.id = "nooku-injected-tailwind-css", t.src = c, document.head.appendChild(t);
|
|
13
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export function injectTailwind(e) {
|
|
2
|
-
const n = document.querySelector("#nooku-injected-tailwind-css");
|
|
3
|
-
if (n && e === void 0 && document.removeChild(n), n || e === void 0) return;
|
|
4
|
-
const c = e === 3 ? "https://cdn.tailwindcss.com" : "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4", t = document.createElement("script");
|
|
5
|
-
t.id = "nooku-injected-tailwind-css", t.src = c, document.head.appendChild(t);
|
|
6
|
-
}
|