@nookuio/vue 1.0.1 → 1.0.3

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.
Files changed (35) hide show
  1. package/README.md +56 -40
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +21 -18
  4. package/dist/index.mjs +23 -24
  5. package/dist/runtime/components/ComponentPreview.vue +40 -0
  6. package/dist/runtime/components/Error.vue +148 -0
  7. package/dist/runtime/composables/useComponent.d.ts +6 -0
  8. package/dist/runtime/composables/useComponent.js +33 -0
  9. package/dist/runtime/composables/useComponent.mjs +23 -0
  10. package/dist/runtime/composables/useQuery.js +10 -6
  11. package/dist/runtime/composables/useQuery.mjs +10 -6
  12. package/dist/runtime/utils/client.d.ts +5 -0
  13. package/dist/runtime/utils/client.js +61 -0
  14. package/dist/runtime/utils/client.mjs +56 -0
  15. package/dist/runtime/utils/helpers.d.ts +1 -1
  16. package/dist/runtime/utils/helpers.js +6 -6
  17. package/dist/runtime/utils/helpers.mjs +5 -5
  18. package/dist/runtime/utils/index.d.ts +4 -5
  19. package/dist/runtime/utils/index.js +28 -56
  20. package/dist/runtime/utils/index.mjs +4 -56
  21. package/dist/runtime/utils/tryCatch.d.ts +17 -12
  22. package/dist/runtime/utils/tryCatch.js +21 -20
  23. package/dist/runtime/utils/tryCatch.mjs +18 -12
  24. package/dist/runtime/utils/vue.d.ts +2 -0
  25. package/dist/runtime/utils/vue.js +19 -0
  26. package/dist/runtime/utils/vue.mjs +22 -0
  27. package/dist/utils.d.ts +2 -0
  28. package/dist/utils.js +25 -0
  29. package/dist/utils.mjs +2 -0
  30. package/package.json +7 -2
  31. package/dist/runtime/components/NotFound.vue +0 -48
  32. package/dist/runtime/components/Renderer.vue +0 -56
  33. package/dist/runtime/utils/tailwind.d.ts +0 -1
  34. package/dist/runtime/utils/tailwind.js +0 -13
  35. package/dist/runtime/utils/tailwind.mjs +0 -6
package/README.md CHANGED
@@ -1,57 +1,73 @@
1
- # nooku Nuxt Module
1
+ # @nookuio/vue
2
2
 
3
- [![npm version][npm-version-src]][npm-version-href]
4
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
- [![License][license-src]][license-href]
3
+ Lightweight Vue plugin + Vite plugin to connect your Vue 3 application to the Nooku editor.
6
4
 
7
- [Nuxt](https://nuxt.com/) module for [nooku](https://nooku.io) ⚡️
5
+ This package provides:
6
+ - A Vue 3 plugin that wires up the client-side runtime pieces used by Nooku.
7
+ - A Vite plugin to enable the inspector integration during local development.
8
8
 
9
- This Nuxt module enables connection and interaction between your nuxt app and nooku.
9
+ Prerequisites
10
+ - Vue 3 project (Vue 3.x)
10
11
 
11
- - [ Learn more about nooku](https://nooku.io)
12
+ ---
12
13
 
13
- ## Quick Setup
14
-
15
- 1. Install: Add `@nooku/nuxt` to your project
14
+ ## 1) Install
16
15
 
16
+ Using npm:
17
17
  ```bash
18
- # Using npm
19
- npm install -D @nooku/nuxt
18
+ npm install -D @nookuio/vue
19
+ ```
20
20
 
21
- # Using pnpm
22
- pnpm add -D @nooku/nuxt
21
+ Using pnpm:
22
+ ```bash
23
+ pnpm add -D @nookuio/vue
23
24
  ```
24
25
 
25
- 2. Configure: Add `@nooku/nuxt` to your Nuxt Integrations array `nuxt.config.{js,ts}`
26
-
27
- ```js
28
- //nuxt.config.js (or) nuxt.config.ts
29
-
30
- export default defineNuxtConfig({
31
- modules: [
32
- '@nooku/nuxt',
33
- //...
34
- ],
35
- nooku: {
36
- enabled: true // default true
37
- },
38
- //...
39
- })
26
+ ---
27
+
28
+ ## 2) Register the Vue plugin (runtime)
29
+
30
+ The package's default export is a Vue plugin. Register the plugin with `app.use(...)` in your app's entry file (e.g. `main.js` / `main.ts`).
31
+
32
+ Example main.ts:
33
+
34
+ ```main.ts
35
+ import './assets/main.css';
36
+
37
+ import { createApp } from 'vue';
38
+ import App from './App.vue';
39
+ import router from './router';
40
+ import nookuPlugin from '@nookuio/vue';
41
+
42
+ const app = createApp(App);
43
+
44
+ app.use(router);
45
+ if (import.meta.env.DEV) app.use(nookuPlugin);
46
+ app.mount('#app');
40
47
  ```
41
48
 
42
- Now, open your Nuxt project in nooku. ✨
49
+ ---
50
+
51
+ ## 3) Add the Vite plugin
43
52
 
44
- ## License
53
+ This package also exposes a Vite plugin (exported from `@nookuio/vue/vite-plugin`). Add it to your `vite.config.ts` file.
45
54
 
46
- [MIT License](./LICENSE)
55
+ Example `vite.config.ts`:
47
56
 
48
- Copyright (c) nooku
57
+ ```vite.config.ts
58
+ import { fileURLToPath, URL } from 'node:url';
49
59
 
50
- <!-- Badges -->
60
+ import { defineConfig } from 'vite';
61
+ import vue from '@vitejs/plugin-vue';
62
+ import { nookuViteInspectorPlugin } from '@nookuio/vue/vite-plugin';
51
63
 
52
- [npm-version-src]: https://img.shields.io/npm/v/@nooku/nuxt/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
53
- [npm-version-href]: https://npmjs.com/package/@nooku/nuxt
54
- [npm-downloads-src]: https://img.shields.io/npm/dm/@nooku/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D
55
- [npm-downloads-href]: https://npmjs.com/package/@nooku/nuxt
56
- [license-src]: https://img.shields.io/npm/l/@nooku/nuxt.svg?style=flat&colorA=18181B&colorB=28CF8D
57
- [license-href]: https://npmjs.com/package/@nooku/nuxt
64
+ // https://vite.dev/config/
65
+ export default defineConfig({
66
+ plugins: [vue(), nookuViteInspectorPlugin(),],
67
+ resolve: {
68
+ alias: {
69
+ '@': fileURLToPath(new URL('./src', import.meta.url))
70
+ }
71
+ }
72
+ });
73
+ ```
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import { type Plugin } from 'vue';
2
+ import ComponentPreview from './runtime/components/ComponentPreview.vue';
3
+ export { ComponentPreview };
2
4
  declare const plugin: Plugin;
3
5
  export default plugin;
package/dist/index.js CHANGED
@@ -3,40 +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 _Renderer = _interopRequireDefault(require("./runtime/components/Renderer.vue"));
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 w(n, i, e) {
16
- const o = typeof n == "string" ? document.querySelector(n) : n;
19
+ function a(t, r, n) {
20
+ const o = typeof t == "string" ? document.querySelector(t) : t;
17
21
  if (!o) {
18
- const u = typeof n == "string" ? `Failed to mount app: mount target selector "${n}" returned null.` : "Failed to mount app to the target element";
22
+ const u = typeof t == "string" ? `Failed to mount app: mount target selector "${t}" returned null.` : "Failed to mount app to the target element";
19
23
  console.warn(u);
20
24
  return;
21
25
  }
22
- const t = (0, _vue.createVNode)(i, e || {});
23
- return (0, _vue.render)(t, o), t.component;
26
+ const i = (0, _vue.createVNode)(r, n || {});
27
+ return (0, _vue.render)(i, o), i.component;
24
28
  }
25
- const y = {
26
- install(n, i) {
27
- window === void 0 || !(0, _helpers.isInsideNookuEditor)() || window.location.pathname === _iframe.EDITOR_PAGE_PATH && (n.mount = function (e) {
28
- n._component = {
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) {
32
+ t._component = {
29
33
  render() {
30
34
  return (0, _vue.h)(_vue.Suspense, {}, {
31
- default: () => (0, _vue.h)(_Renderer.default),
35
+ default: () => (0, _vue.h)(_ComponentPreview.default),
32
36
  fallback: () => (0, _vue.h)("div", "Loading...")
33
37
  });
34
38
  }
35
39
  };
36
- const o = (0, _useQuery.getQuery)(),
37
- t = o.injectTailwind === "true" && (o.tailwindVersion === "3" || o.tailwindVersion === "4") ? Number(o.tailwindVersion) : void 0;
38
- return (0, _tailwind.injectTailwind)(t), (0, _utils.initializeClient)(n), w(e, n._component)?.proxy;
39
- });
40
+ const o = a(n, t._component);
41
+ return (0, _utils.initializeClient)(t), o?.proxy;
42
+ }));
40
43
  }
41
44
  };
42
- module.exports = y;
45
+ module.exports = g;
package/dist/index.mjs CHANGED
@@ -1,38 +1,37 @@
1
- import { createVNode as d, h as r, render as m, Suspense as s } from "vue";
2
- import l from "./runtime/components/Renderer.vue";
3
- import { isInsideNookuEditor as p } from "./runtime/utils/helpers.mjs";
4
- import { initializeClient as a } from "./runtime/utils/index.mjs";
5
- import { injectTailwind as c } from "./runtime/utils/tailwind.mjs";
6
- import { getQuery as f } from "./runtime/composables/useQuery.mjs";
7
- import { EDITOR_PAGE_PATH as g } from "@nookuio/iframe";
8
- function w(n, i, e) {
9
- const o = typeof n == "string" ? document.querySelector(n) : n;
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;
10
9
  if (!o) {
11
- const u = typeof n == "string" ? `Failed to mount app: mount target selector "${n}" returned null.` : "Failed to mount app to the target element";
10
+ const u = typeof t == "string" ? `Failed to mount app: mount target selector "${t}" returned null.` : "Failed to mount app to the target element";
12
11
  console.warn(u);
13
12
  return;
14
13
  }
15
- const t = d(i, e || {});
16
- return m(t, o), t.component;
14
+ const i = p(r, n || {});
15
+ return d(i, o), i.component;
17
16
  }
18
- const y = {
19
- install(n, i) {
20
- window === void 0 || !p() || window.location.pathname === g && (n.mount = function(e) {
21
- n._component = {
17
+ const g = {
18
+ install(t, r) {
19
+ import.meta.env.DEV && (window === void 0 || !l() || window.location.pathname === c && (t.mount = function(n) {
20
+ t._component = {
22
21
  render() {
23
- return r(
24
- s,
22
+ return e(
23
+ f,
25
24
  {},
26
25
  {
27
- default: () => r(l),
28
- fallback: () => r("div", "Loading...")
26
+ default: () => e(m),
27
+ fallback: () => e("div", "Loading...")
29
28
  }
30
29
  );
31
30
  }
32
31
  };
33
- const o = f(), t = o.injectTailwind === "true" && (o.tailwindVersion === "3" || o.tailwindVersion === "4") ? Number(o.tailwindVersion) : void 0;
34
- return c(t), a(n), w(e, n._component)?.proxy;
35
- });
32
+ const o = a(n, t._component);
33
+ return s(t), o?.proxy;
34
+ }));
36
35
  }
37
36
  };
38
- export default y;
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
- const n = new URLSearchParams(window.location.search),
11
- e = {};
12
- return n.forEach((o, t) => e[t] = o), e;
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 n = (0, _vue.ref)(getQuery()),
19
+ const t = (0, _vue.ref)(getQuery()),
16
20
  e = () => {
17
- n.value = getQuery();
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: n
24
+ query: t
21
25
  };
22
26
  }
@@ -1,11 +1,15 @@
1
- import { ref as r, onMounted as s, onBeforeUnmount as a } from "vue";
1
+ import { ref as o, onMounted as a, onBeforeUnmount as s } from "vue";
2
2
  export function getQuery() {
3
- const n = new URLSearchParams(window.location.search), e = {};
4
- return n.forEach((o, t) => e[t] = o), e;
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 n = r(getQuery()), e = () => {
8
- n.value = getQuery();
11
+ const t = o(getQuery()), e = () => {
12
+ t.value = getQuery();
9
13
  };
10
- return s(() => window.addEventListener("popstate", e)), a(() => window.removeEventListener("popstate", e)), { query: n };
14
+ return a(() => window.addEventListener("popstate", e)), s(() => window.removeEventListener("popstate", e)), { query: t };
11
15
  }
@@ -0,0 +1,5 @@
1
+ import type { App } from 'vue';
2
+ /**
3
+ * Initialize the communication between the editor and the iframe
4
+ */
5
+ export declare function initializeClient(app: App): any;
@@ -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 isInsideNookuEditor(): boolean;
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,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.debounce = debounce;
7
7
  exports.getInstanceState = getInstanceState;
8
- exports.isInsideNookuEditor = isInsideNookuEditor;
9
- function isInsideNookuEditor() {
8
+ exports.isInsideEditor = isInsideEditor;
9
+ function isInsideEditor() {
10
10
  return window === void 0 ? !1 : !!(window.parent && window.location !== window.parent.location || window.top !== window.self);
11
11
  }
12
12
  function debounce(n, t = 500) {
@@ -18,12 +18,12 @@ function debounce(n, t = 500) {
18
18
  };
19
19
  }
20
20
  const i = "__v_isRef",
21
- a = "__v_isReadonly";
21
+ u = "__v_isReadonly";
22
22
  function s(n, t) {
23
23
  return n?.[i] ? t ? n.value : {
24
24
  value: n.value,
25
25
  [i]: "true",
26
- [a]: !!n.__v_isReadonly
26
+ [u]: !!n.__v_isReadonly
27
27
  } : n;
28
28
  }
29
29
  function getInstanceState(n, t) {
@@ -32,7 +32,7 @@ function getInstanceState(n, t) {
32
32
  return Object.entries(n.props).forEach(([o, r]) => {
33
33
  e[o] = r;
34
34
  }), Object.entries(n.devtoolsRawSetupState ?? n.setupState).forEach(([o, r]) => {
35
- const u = s(r, t);
36
- e[o] = u;
35
+ const a = s(r, t);
36
+ e[o] = a;
37
37
  }), e;
38
38
  }
@@ -1,4 +1,4 @@
1
- export function isInsideNookuEditor() {
1
+ export function isInsideEditor() {
2
2
  return window === void 0 ? !1 : !!(window.parent && window.location !== window.parent.location || window.top !== window.self);
3
3
  }
4
4
  export function debounce(n, t = 500) {
@@ -9,13 +9,13 @@ export function debounce(n, t = 500) {
9
9
  }, t);
10
10
  };
11
11
  }
12
- const i = "__v_isRef", a = "__v_isReadonly";
12
+ const i = "__v_isRef", u = "__v_isReadonly";
13
13
  function s(n, t) {
14
14
  return n?.[i] ? t ? n.value : {
15
15
  value: n.value,
16
16
  [i]: "true",
17
17
  // as string
18
- [a]: !!n.__v_isReadonly
18
+ [u]: !!n.__v_isReadonly
19
19
  } : n;
20
20
  }
21
21
  export function getInstanceState(n, t) {
@@ -24,7 +24,7 @@ export function getInstanceState(n, t) {
24
24
  return Object.entries(n.props).forEach(([o, r]) => {
25
25
  e[o] = r;
26
26
  }), Object.entries(n.devtoolsRawSetupState ?? n.setupState).forEach(([o, r]) => {
27
- const u = s(r, t);
28
- e[o] = u;
27
+ const a = s(r, t);
28
+ e[o] = a;
29
29
  }), e;
30
30
  }
@@ -1,5 +1,4 @@
1
- import type { App } from 'vue';
2
- /**
3
- * Initialize the communication between the editor and the iframe
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.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
- }
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
- 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
+ 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 MaybePromise<T> = T | Promise<T>;
2
- type Success<T> = {
3
- data: T;
4
- error?: never;
5
- };
6
- type Failure<E> = {
7
- data?: never;
8
- error: E;
9
- };
10
- type Result<T, E = Error> = Success<T> | Failure<E>;
11
- export declare function tryCatch<T, E = Error>(func: (() => MaybePromise<T>) | Promise<T>, handler?: ((error: E) => void) | 'throw'): Promise<Result<T, E>>;
12
- export declare function tryCatchSync<T, E = Error>(func: () => T, handler?: ((error: E) => void) | 'throw'): Result<T, E>;
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.tryCatch = tryCatch;
7
- exports.tryCatchSync = tryCatchSync;
8
- async function tryCatch(t, e) {
9
- try {
10
- return {
11
- data: await (t instanceof Promise ? t : Promise.resolve().then(t))
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
- function tryCatchSync(t, e) {
15
+ exports.TimeoutError = TimeoutError;
16
+ async function trySafe(n, t) {
17
+ let e = null;
21
18
  try {
22
- return {
23
- data: t()
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
- if (e === "throw") throw r;
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 async function tryCatch(t, e) {
2
- try {
3
- return { data: await (t instanceof Promise ? t : Promise.resolve().then(t)) };
4
- } catch (r) {
5
- if (e === "throw")
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 tryCatchSync(t, e) {
8
+ export async function trySafe(n, t) {
9
+ let e = null;
11
10
  try {
12
- return { data: t() };
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
- if (e === "throw")
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,2 @@
1
+ import type { Component } from 'vue';
2
+ export declare function importVueComponentFromPath(path: string, name?: string): Promise<Component | undefined>;
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ export { isInsideEditor, importVueComponentFromPath } from './runtime/utils';
2
+ export { useVueComponent } from './runtime/composables/useComponent';
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
@@ -0,0 +1,2 @@
1
+ export { isInsideEditor, importVueComponentFromPath } from "./runtime/utils/index.mjs";
2
+ export { useVueComponent } from "./runtime/composables/useComponent.mjs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nookuio/vue",
3
3
  "description": "",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
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": [
@@ -21,7 +26,7 @@
21
26
  ],
22
27
  "dependencies": {
23
28
  "@nookuio/iframe": "latest",
24
- "@nookuio/inspector-plugin": "latest"
29
+ "@nookuio/inspector-plugin": "1.0.3"
25
30
  },
26
31
  "devDependencies": {
27
32
  "changelogen": "^0.6.2",
@@ -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
- }