@andmarruda/lpb-vue 0.0.0-stage → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Anderson Arruda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,29 @@
1
- # Temporary Holding Version
1
+ # @andmarruda/lpb-vue
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Vue 3 renderer of Laravel Page Builder pages — part of
4
+ [Laravel Page Builder](https://github.com/andmarruda/lpb). Renders the 48
5
+ built-in widgets through [`@andmarruda/lpb-core`](https://www.npmjs.com/package/@andmarruda/lpb-core)
6
+ and your own components for any widget name, with the page's scoped styles
7
+ and interactive behaviours.
8
+
9
+ ```bash
10
+ npm install @andmarruda/lpb-core @andmarruda/lpb-vue vue
11
+ ```
12
+
13
+ ```ts
14
+ import "@andmarruda/lpb-core/styles.css";
15
+ import { createApp, h } from "vue";
16
+ import { readEmbeddedPayload } from "@andmarruda/lpb-core";
17
+ import { LpbPage } from "@andmarruda/lpb-vue";
18
+
19
+ createApp({ render: () => h(LpbPage, { payload: readEmbeddedPayload(), components: { hero: MyHero } }) })
20
+ .mount("#lpb-app");
21
+ ```
22
+
23
+ With Inertia, render `InertiaPage` from the configured page component. For
24
+ external frontends (e.g. Nuxt) use `usePagePayload({ slug })`.
25
+
26
+ Components receive the widget's `config` and `instance`; a component with
27
+ the name of a built-in widget replaces it.
28
+
29
+ MIT © Anderson Arruda
@@ -0,0 +1,97 @@
1
+ import { type Component, type PropType } from 'vue';
2
+ import { type Breakpoints, type Media, type PagePayload, type WidgetRenderer } from '@andmarruda/lpb-core';
3
+ /**
4
+ * Renders a page payload: blocks, built-in widgets (from @andmarruda/lpb-core) and the
5
+ * application's widget components, with the page's scoped CSS. Application
6
+ * components receive `config` and `instance` props.
7
+ */
8
+ export declare const LpbPage: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
9
+ payload: {
10
+ type: PropType<Pick<PagePayload, "blocks"> | null>;
11
+ default: null;
12
+ };
13
+ /** Vue components by widget name: custom widgets or overrides of built-in ones. */
14
+ components: {
15
+ type: PropType<Record<string, Component>>;
16
+ default: () => {};
17
+ };
18
+ renderers: {
19
+ type: PropType<Record<string, WidgetRenderer>>;
20
+ default: undefined;
21
+ };
22
+ resolveMedia: {
23
+ type: PropType<(id: string | number) => Media | null>;
24
+ default: undefined;
25
+ };
26
+ apiBase: {
27
+ type: StringConstructor;
28
+ default: undefined;
29
+ };
30
+ breakpoints: {
31
+ type: PropType<Breakpoints>;
32
+ default: () => Breakpoints;
33
+ };
34
+ /** Skip the interactive behaviours (e.g. inside an editor canvas). */
35
+ static: {
36
+ type: BooleanConstructor;
37
+ default: boolean;
38
+ };
39
+ }>, () => (import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
40
+ [key: string]: any;
41
+ }> | null)[] | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
42
+ payload: {
43
+ type: PropType<Pick<PagePayload, "blocks"> | null>;
44
+ default: null;
45
+ };
46
+ /** Vue components by widget name: custom widgets or overrides of built-in ones. */
47
+ components: {
48
+ type: PropType<Record<string, Component>>;
49
+ default: () => {};
50
+ };
51
+ renderers: {
52
+ type: PropType<Record<string, WidgetRenderer>>;
53
+ default: undefined;
54
+ };
55
+ resolveMedia: {
56
+ type: PropType<(id: string | number) => Media | null>;
57
+ default: undefined;
58
+ };
59
+ apiBase: {
60
+ type: StringConstructor;
61
+ default: undefined;
62
+ };
63
+ breakpoints: {
64
+ type: PropType<Breakpoints>;
65
+ default: () => Breakpoints;
66
+ };
67
+ /** Skip the interactive behaviours (e.g. inside an editor canvas). */
68
+ static: {
69
+ type: BooleanConstructor;
70
+ default: boolean;
71
+ };
72
+ }>> & Readonly<{}>, {
73
+ payload: Pick<PagePayload, "blocks"> | null;
74
+ components: Record<string, Component>;
75
+ renderers: Record<string, WidgetRenderer>;
76
+ resolveMedia: (id: string | number) => Media | null;
77
+ apiBase: string;
78
+ breakpoints: Breakpoints;
79
+ static: boolean;
80
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
81
+ /**
82
+ * Page component for the Inertia flow: Lpb::inertia() renders the
83
+ * configured component (default "Lpb/Page") with the payload as `page`.
84
+ */
85
+ export declare const InertiaPage: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
86
+ page: {
87
+ type: PropType<PagePayload>;
88
+ required: true;
89
+ };
90
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
91
+ [key: string]: any;
92
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
93
+ page: {
94
+ type: PropType<PagePayload>;
95
+ required: true;
96
+ };
97
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,58 @@
1
+ import { computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
2
+ import { DEFAULT_BREAKPOINTS, enhance, renderBlocks, treeCss } from '@andmarruda/lpb-core';
3
+ import { renderChildren } from './vnode.js';
4
+ /**
5
+ * Renders a page payload: blocks, built-in widgets (from @andmarruda/lpb-core) and the
6
+ * application's widget components, with the page's scoped CSS. Application
7
+ * components receive `config` and `instance` props.
8
+ */
9
+ export const LpbPage = defineComponent({
10
+ name: 'LpbPage',
11
+ props: {
12
+ payload: { type: Object, default: null },
13
+ /** Vue components by widget name: custom widgets or overrides of built-in ones. */
14
+ components: { type: Object, default: () => ({}) },
15
+ renderers: { type: Object, default: undefined },
16
+ resolveMedia: { type: Function, default: undefined },
17
+ apiBase: { type: String, default: undefined },
18
+ breakpoints: { type: Object, default: () => DEFAULT_BREAKPOINTS },
19
+ /** Skip the interactive behaviours (e.g. inside an editor canvas). */
20
+ static: { type: Boolean, default: false },
21
+ },
22
+ setup(props, { slots }) {
23
+ const root = ref(null);
24
+ const nodes = computed(() => renderBlocks(props.payload?.blocks ?? [], { components: Object.keys(props.components), renderers: props.renderers, resolveMedia: props.resolveMedia, apiBase: props.apiBase }));
25
+ const css = computed(() => treeCss(props.payload?.blocks ?? [], props.breakpoints));
26
+ let cleanup = () => { };
27
+ const run = () => { cleanup(); cleanup = props.static ? () => { } : enhance(root.value); };
28
+ onMounted(run);
29
+ watch(nodes, () => nextTick(run));
30
+ onBeforeUnmount(() => cleanup());
31
+ return () => {
32
+ if (!props.payload)
33
+ return slots.fallback?.() ?? null;
34
+ return [
35
+ // innerHTML: text children of <style> would be entity-escaped by the SSR
36
+ // renderer; treeCss cannot contain markup
37
+ css.value ? h('style', { 'data-lpb-styles': '', innerHTML: css.value }) : null,
38
+ h('div', { ref: root, class: 'lpb-page' }, renderChildren(nodes.value, (slot, key) => {
39
+ const component = props.components[slot.instance.widget];
40
+ return component ? h('div', { key, class: slot.className, 'data-lpb-widget': slot.instance.widget }, [h(component, { config: slot.instance.config, instance: slot.instance })]) : null;
41
+ })),
42
+ ];
43
+ };
44
+ },
45
+ });
46
+ /**
47
+ * Page component for the Inertia flow: Lpb::inertia() renders the
48
+ * configured component (default "Lpb/Page") with the payload as `page`.
49
+ */
50
+ export const InertiaPage = defineComponent({
51
+ name: 'LpbInertiaPage',
52
+ inheritAttrs: false,
53
+ props: { page: { type: Object, required: true } },
54
+ setup(props, { attrs }) {
55
+ return () => h(LpbPage, { ...attrs, payload: props.page });
56
+ },
57
+ });
58
+ //# sourceMappingURL=LpbPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LpbPage.js","sourceRoot":"","sources":["../src/LpbPage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAiC,MAAM,KAAK,CAAC;AACpI,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAuE,MAAM,sBAAsB,CAAC;AAChK,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC;IACrC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE;QACL,OAAO,EAAE,EAAE,IAAI,EAAE,MAAsD,EAAE,OAAO,EAAE,IAAI,EAAE;QACxF,mFAAmF;QACnF,UAAU,EAAE,EAAE,IAAI,EAAE,MAA6C,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE;QACxF,SAAS,EAAE,EAAE,IAAI,EAAE,MAAkD,EAAE,OAAO,EAAE,SAAS,EAAE;QAC3F,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B,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAA+B,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IAC1E,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,113 @@
1
+ import { type Ref } from 'vue';
2
+ import { LpbClient, type PagePayload } from '@andmarruda/lpb-core';
3
+ export type PageStatus = 'loading' | 'ready' | 'not-found' | 'error';
4
+ /**
5
+ * The payload embedded by @lpbPayload (view flow), or fetched from the
6
+ * delivery API by slug (external frontends).
7
+ */
8
+ export declare function usePagePayload(source: {
9
+ slug: Ref<string> | string;
10
+ client?: LpbClient;
11
+ } | {
12
+ embedded: true;
13
+ }): {
14
+ payload: Ref<{
15
+ format_version: 1;
16
+ page: {
17
+ id: string;
18
+ slug: string;
19
+ title: string;
20
+ seo: {
21
+ title?: string | undefined;
22
+ description?: string | undefined;
23
+ og_title?: string | undefined;
24
+ og_description?: string | undefined;
25
+ og_image?: string | undefined;
26
+ canonical?: string | undefined;
27
+ robots?: string | undefined;
28
+ } | null;
29
+ metatags: {
30
+ name?: string | undefined;
31
+ property?: string | undefined;
32
+ content: string;
33
+ }[];
34
+ };
35
+ template: {
36
+ id: string;
37
+ slug: string;
38
+ } | null;
39
+ revision_id: string | null;
40
+ design_version: number | null;
41
+ blocks: {
42
+ id: string;
43
+ type: import("@andmarruda/lpb-core").BlockType;
44
+ styles: {
45
+ breakpoint: string | null;
46
+ state: "hover" | "focus" | "active" | null;
47
+ props: Record<string, import("@andmarruda/lpb-core").CssValue>;
48
+ }[];
49
+ widgets: {
50
+ id: string;
51
+ widget: string;
52
+ schema_version: number;
53
+ config: Record<string, unknown>;
54
+ styles: {
55
+ breakpoint: string | null;
56
+ state: "hover" | "focus" | "active" | null;
57
+ props: Record<string, import("@andmarruda/lpb-core").CssValue>;
58
+ }[];
59
+ }[];
60
+ children: /*elided*/ any[];
61
+ }[];
62
+ } | null, PagePayload | {
63
+ format_version: 1;
64
+ page: {
65
+ id: string;
66
+ slug: string;
67
+ title: string;
68
+ seo: {
69
+ title?: string | undefined;
70
+ description?: string | undefined;
71
+ og_title?: string | undefined;
72
+ og_description?: string | undefined;
73
+ og_image?: string | undefined;
74
+ canonical?: string | undefined;
75
+ robots?: string | undefined;
76
+ } | null;
77
+ metatags: {
78
+ name?: string | undefined;
79
+ property?: string | undefined;
80
+ content: string;
81
+ }[];
82
+ };
83
+ template: {
84
+ id: string;
85
+ slug: string;
86
+ } | null;
87
+ revision_id: string | null;
88
+ design_version: number | null;
89
+ blocks: {
90
+ id: string;
91
+ type: import("@andmarruda/lpb-core").BlockType;
92
+ styles: {
93
+ breakpoint: string | null;
94
+ state: "hover" | "focus" | "active" | null;
95
+ props: Record<string, import("@andmarruda/lpb-core").CssValue>;
96
+ }[];
97
+ widgets: {
98
+ id: string;
99
+ widget: string;
100
+ schema_version: number;
101
+ config: Record<string, unknown>;
102
+ styles: {
103
+ breakpoint: string | null;
104
+ state: "hover" | "focus" | "active" | null;
105
+ props: Record<string, import("@andmarruda/lpb-core").CssValue>;
106
+ }[];
107
+ }[];
108
+ children: /*elided*/ any[];
109
+ }[];
110
+ } | null>;
111
+ status: Ref<PageStatus, PageStatus>;
112
+ error: Ref<unknown, unknown>;
113
+ };
@@ -0,0 +1,30 @@
1
+ import { ref, watchEffect } from 'vue';
2
+ import { LpbClient, readEmbeddedPayload } from '@andmarruda/lpb-core';
3
+ /**
4
+ * The payload embedded by @lpbPayload (view flow), or fetched from the
5
+ * delivery API by slug (external frontends).
6
+ */
7
+ export function usePagePayload(source) {
8
+ const payload = ref(null);
9
+ const status = ref('loading');
10
+ const error = ref(null);
11
+ if ('embedded' in source) {
12
+ payload.value = readEmbeddedPayload();
13
+ status.value = payload.value ? 'ready' : 'not-found';
14
+ return { payload, status, error };
15
+ }
16
+ const client = source.client ?? new LpbClient();
17
+ watchEffect((onCleanup) => {
18
+ let active = true;
19
+ onCleanup(() => { active = false; });
20
+ const slug = typeof source.slug === 'string' ? source.slug : source.slug.value;
21
+ status.value = 'loading';
22
+ client.page(slug)
23
+ .then((result) => { if (!active)
24
+ return; payload.value = result; status.value = result ? 'ready' : 'not-found'; })
25
+ .catch((e) => { if (!active)
26
+ return; error.value = e; status.value = 'error'; });
27
+ });
28
+ return { payload, status, error };
29
+ }
30
+ //# sourceMappingURL=composables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composables.js","sourceRoot":"","sources":["../src/composables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,WAAW,EAAY,MAAM,KAAK,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;AAIxF;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAA+E;IAC5G,MAAM,OAAO,GAAG,GAAG,CAAqB,IAAI,CAAC,CAAC;IAC9C,MAAM,MAAM,GAAG,GAAG,CAAa,SAAS,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,GAAG,CAAU,IAAI,CAAC,CAAC;IAEjC,IAAI,UAAU,IAAI,MAAM,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,GAAG,mBAAmB,EAAE,CAAC;QACtC,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC;QACrD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACpC,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;IAChD,WAAW,CAAC,CAAC,SAAS,EAAE,EAAE;QACxB,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,MAAM,IAAI,GAAG,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QAC/E,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;aACd,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM;YAAE,OAAO,CAAC,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;aACjH,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM;YAAE,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { LpbPage, InertiaPage } from './LpbPage.js';
2
+ export { renderVNode, renderChildren, type SlotRenderer } from './vnode.js';
3
+ export { usePagePayload, type PageStatus } from './composables.js';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { LpbPage, InertiaPage } from './LpbPage.js';
2
+ export { renderVNode, renderChildren } from './vnode.js';
3
+ export { usePagePayload } from './composables.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAqB,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAmB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type VNode as VueNode, type VNodeArrayChildren } from 'vue';
2
+ import type { SlotNode, VNode } from '@andmarruda/lpb-core';
3
+ export type SlotRenderer = (slot: SlotNode, key: string) => VueNode | null;
4
+ /** Renders core virtual nodes as Vue vnodes. */
5
+ export declare function renderVNode(node: VNode, slot?: SlotRenderer, key?: string): VueNode | string | null;
6
+ export declare function renderChildren(nodes: VNode[], slot?: SlotRenderer, key?: string): VNodeArrayChildren;
package/dist/vnode.js ADDED
@@ -0,0 +1,25 @@
1
+ import { h } from 'vue';
2
+ function props(attrs, key) {
3
+ const out = { key };
4
+ for (const [name, value] of Object.entries(attrs)) {
5
+ if (value === null || value === undefined || value === false)
6
+ continue;
7
+ out[name] = value === true ? '' : value;
8
+ }
9
+ return out;
10
+ }
11
+ /** Renders core virtual nodes as Vue vnodes. */
12
+ export function renderVNode(node, slot, key = '0') {
13
+ if (node.kind === 'text')
14
+ return node.text;
15
+ if (node.kind === 'slot')
16
+ return slot ? slot(node, key) : null;
17
+ const elementProps = props(node.attrs, key);
18
+ if (node.html !== undefined)
19
+ return h(node.tag, { ...elementProps, innerHTML: node.html });
20
+ return h(node.tag, elementProps, renderChildren(node.children, slot, key));
21
+ }
22
+ export function renderChildren(nodes, slot, key = '0') {
23
+ return nodes.map((child, i) => renderVNode(child, slot, `${key}.${i}`));
24
+ }
25
+ //# sourceMappingURL=vnode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vnode.js","sourceRoot":"","sources":["../src/vnode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAkD,MAAM,KAAK,CAAC;AAKxE,SAAS,KAAK,CAAC,KAAgC,EAAE,GAAW;IAC1D,MAAM,GAAG,GAA4B,E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AAC,KAAK,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@andmarruda/lpb-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "Vue 3 renderer of Laravel Page Builder pages",
5
+ "keywords": [
6
+ "laravel",
7
+ "page-builder",
8
+ "lpb",
9
+ "cms",
10
+ "vue",
11
+ "inertia"
12
+ ],
13
+ "license": "MIT",
14
+ "author": "Anderson Arruda",
15
+ "homepage": "https://github.com/andmarruda/lpb-frontend/tree/main/packages/vue#readme",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/andmarruda/lpb-frontend.git",
19
+ "directory": "packages/vue"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/andmarruda/lpb-frontend/issues"
23
+ },
24
+ "type": "module",
25
+ "main": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "scripts": {
37
+ "build": "tsc -p tsconfig.build.json",
38
+ "typecheck": "tsc -p tsconfig.json --noEmit",
39
+ "test": "vitest run"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "engines": {
45
+ "node": ">=18"
46
+ },
47
+ "dependencies": {
48
+ "@andmarruda/lpb-core": "0.0.1"
49
+ },
50
+ "peerDependencies": {
51
+ "vue": "^3.4"
52
+ },
53
+ "devDependencies": {
54
+ "@andmarruda/lpb-conformance": "0.0.1",
55
+ "vue": "^3.5.0"
56
+ }
57
+ }