@bagelink/blox 1.15.587 → 1.15.591
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/README.md +48 -22
- package/dist/CmsPageView.vue.d.ts.map +1 -1
- package/dist/{PreviewApp-D208UMZs.js → PreviewApp-BagepqPk.js} +1 -1
- package/dist/{PreviewApp-DNMYw1AS.cjs → PreviewApp-HVipxMQ3.cjs} +1 -1
- package/dist/{PreviewApp.vue_vue_type_style_index_0_lang-Dm0SmjEr.cjs → PreviewApp.vue_vue_type_style_index_0_lang-C6e-tDzD.cjs} +6 -6
- package/dist/{PreviewApp.vue_vue_type_style_index_0_lang-l6QisbG-.js → PreviewApp.vue_vue_type_style_index_0_lang-Dl3bKQTA.js} +1 -1
- package/dist/api/index.d.ts +24 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/{routes-DDiQDksF.js → appRuntime-B6yWkH3M.js} +280 -82
- package/dist/{routes-DOcek9fP.cjs → appRuntime-D1Z3fX-G.cjs} +237 -39
- package/dist/appRuntime.d.ts +26 -0
- package/dist/appRuntime.d.ts.map +1 -0
- package/dist/composables/useLocale.d.ts +10 -3
- package/dist/composables/useLocale.d.ts.map +1 -1
- package/dist/content/routes.d.ts +4 -2
- package/dist/content/routes.d.ts.map +1 -1
- package/dist/content/useContentSeo.d.ts.map +1 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/createBloxApp.d.ts +9 -19
- package/dist/createBloxApp.d.ts.map +1 -1
- package/dist/data/useData.d.ts.map +1 -1
- package/dist/index.cjs +91 -111
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +64 -84
- package/dist/{shard-runner-Bc4gTl71.js → shard-runner-DauYjwvg.js} +2 -2
- package/dist/{shard-runner-ZAwqteYY.cjs → shard-runner-xIPqGX-Q.cjs} +2 -2
- package/dist/ssg/cli.cjs +2 -4
- package/dist/ssg/cli.mjs +2 -4
- package/dist/ssg/client.cjs +0 -73
- package/dist/ssg/client.d.ts +1 -3
- package/dist/ssg/client.d.ts.map +1 -1
- package/dist/ssg/client.mjs +1 -74
- package/dist/ssg/constants.d.ts +0 -4
- package/dist/ssg/constants.d.ts.map +1 -1
- package/dist/ssg/createSSREntry.d.ts.map +1 -1
- package/dist/ssg/index.cjs +26 -47
- package/dist/ssg/index.d.ts +1 -3
- package/dist/ssg/index.d.ts.map +1 -1
- package/dist/ssg/index.mjs +24 -45
- package/dist/ssg/prerender.d.ts +1 -5
- package/dist/ssg/prerender.d.ts.map +1 -1
- package/dist/ssg/render-resolved-page.d.ts +0 -2
- package/dist/ssg/render-resolved-page.d.ts.map +1 -1
- package/dist/{validate-output-DRCseorw.js → validate-output-B56PuxEM.js} +0 -2
- package/dist/{validate-output-DlHgDBoV.cjs → validate-output-CRfMSrpx.cjs} +0 -2
- package/dist/vite-plugin.cjs +3 -64
- package/dist/vite-plugin.d.ts +0 -8
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.mjs +3 -64
- package/package.json +1 -1
- package/dist/ssg/collection-cache.d.ts +0 -53
- package/dist/ssg/collection-cache.d.ts.map +0 -1
- package/dist/ssg/state-cache.d.ts +0 -21
- package/dist/ssg/state-cache.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -28,39 +28,61 @@ Do not import `@bagelink/vue/dist/style.css` or
|
|
|
28
28
|
existing projects. Import the same entries in local development and CI so a
|
|
29
29
|
source alias cannot hide a package-export problem.
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## Production Website Setup
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
34
|
// main.ts
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import { createBlox, ButtonConfig, TextConfig, TitleConfig } from '@bagelink/blox'
|
|
35
|
+
import { createBloxApp } from '@bagelink/blox'
|
|
36
|
+
import { BagelVue } from '@bagelink/vue'
|
|
38
37
|
import '@bagelink/vue/styles/core.css'
|
|
39
38
|
import '@bagelink/blox/style.css'
|
|
40
39
|
|
|
41
40
|
import App from './App.vue'
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
import router from './router'
|
|
42
|
+
|
|
43
|
+
const blocks = import.meta.glob('./components/blocks/*.vue', { eager: true })
|
|
44
|
+
|
|
45
|
+
createBloxApp({
|
|
46
|
+
rootComponent: App,
|
|
47
|
+
router,
|
|
48
|
+
modules: blocks,
|
|
49
|
+
websiteName: 'my-site',
|
|
50
|
+
store: 'my-site',
|
|
51
|
+
locale: 'en',
|
|
52
|
+
supportedLocales: ['en'],
|
|
53
|
+
plugins: [BagelVue],
|
|
54
|
+
navigation: 'document',
|
|
49
55
|
})
|
|
56
|
+
```
|
|
50
57
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
```typescript
|
|
59
|
+
// main.server.ts
|
|
60
|
+
import { createBloxSSREntry } from '@bagelink/blox/ssg'
|
|
61
|
+
import { BagelVue } from '@bagelink/vue'
|
|
62
|
+
import App from './App.vue'
|
|
63
|
+
import { createRouter } from './router'
|
|
64
|
+
|
|
65
|
+
const blocks = import.meta.glob('./components/blocks/*.vue', { eager: true })
|
|
66
|
+
|
|
67
|
+
export const { render, prefetchResolve } = createBloxSSREntry({
|
|
68
|
+
rootComponent: App,
|
|
69
|
+
createRouter,
|
|
70
|
+
modules: blocks,
|
|
71
|
+
websiteName: 'my-site',
|
|
72
|
+
store: 'my-site',
|
|
73
|
+
locale: 'en',
|
|
74
|
+
supportedLocales: ['en'],
|
|
75
|
+
plugins: [BagelVue],
|
|
76
|
+
})
|
|
58
77
|
```
|
|
59
78
|
|
|
60
|
-
|
|
79
|
+
The client hydrates prerendered HTML directly. Components can use normal Vue
|
|
80
|
+
primitives including `Suspense`, `Teleport`, Pinia, and `onServerPrefetch`.
|
|
81
|
+
Use `useData(key, loader)` for data that must be present in static HTML and in
|
|
82
|
+
the hydration payload. Do not install fetch or Axios cache interceptors.
|
|
61
83
|
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
Blox owns the preview route and one named CMS fallback route. Consumer routers
|
|
85
|
+
should declare app-owned routes and redirects only.
|
|
64
86
|
|
|
65
87
|
### With Custom Components
|
|
66
88
|
|
|
@@ -104,7 +126,11 @@ For more examples, see [SETUP_EXAMPLE.md](./SETUP_EXAMPLE.md).
|
|
|
104
126
|
|
|
105
127
|
---
|
|
106
128
|
|
|
107
|
-
##
|
|
129
|
+
## Low-level Setup
|
|
130
|
+
|
|
131
|
+
`createBlox()` remains available for the editor and specialized embedded
|
|
132
|
+
renderers. New production websites should use `createBloxApp()` and
|
|
133
|
+
`createBloxSSREntry()` so client and server assembly cannot drift.
|
|
108
134
|
|
|
109
135
|
### 1. Register Base Components
|
|
110
136
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CmsPageView.vue.d.ts","sourceRoot":"","sources":["../src/CmsPageView.vue"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"CmsPageView.vue.d.ts","sourceRoot":"","sources":["../src/CmsPageView.vue"],"names":[],"mappings":";AAqkBA,wBAMG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const PreviewApp_vue_vue_type_style_index_0_lang = require("./PreviewApp.vue_vue_type_style_index_0_lang-
|
|
3
|
+
const PreviewApp_vue_vue_type_style_index_0_lang = require("./PreviewApp.vue_vue_type_style_index_0_lang-C6e-tDzD.cjs");
|
|
4
4
|
exports.default = PreviewApp_vue_vue_type_style_index_0_lang._sfc_main;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const vue = require("vue");
|
|
3
|
-
const
|
|
3
|
+
const appRuntime = require("./appRuntime-D1Z3fX-G.cjs");
|
|
4
4
|
function sendToEditor(msg) {
|
|
5
5
|
window.parent.postMessage(cloneForPostMessage(msg), "*");
|
|
6
6
|
}
|
|
@@ -45,7 +45,7 @@ const PreviewRenderer = vue.defineComponent({
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
setup(props) {
|
|
48
|
-
const registry = vue.inject(
|
|
48
|
+
const registry = vue.inject(appRuntime.BLOX_REGISTRY_KEY, {});
|
|
49
49
|
const contexts = vue.inject("contexts", { value: {} });
|
|
50
50
|
const localHovered = vue.ref(null);
|
|
51
51
|
function onBlockClick(index) {
|
|
@@ -139,7 +139,7 @@ const PreviewRenderer = vue.defineComponent({
|
|
|
139
139
|
"onMouseleave": onBlockLeave
|
|
140
140
|
},
|
|
141
141
|
[
|
|
142
|
-
vue.h(definition.component,
|
|
142
|
+
vue.h(definition.component, appRuntime.resolveBlockProps(block, definition.schema.defaults, contexts.value)),
|
|
143
143
|
vue.h("div", { style: overlayStyle }),
|
|
144
144
|
(isSelected || isHovered) && vue.h("div", { style: labelStyle }, label)
|
|
145
145
|
]
|
|
@@ -153,8 +153,8 @@ const _hoisted_1 = { class: "blox-preview-root" };
|
|
|
153
153
|
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
154
154
|
__name: "PreviewApp",
|
|
155
155
|
setup(__props) {
|
|
156
|
-
const registry = vue.inject(
|
|
157
|
-
const { setLocale } =
|
|
156
|
+
const registry = vue.inject(appRuntime.BLOX_REGISTRY_KEY, {});
|
|
157
|
+
const { setLocale } = appRuntime.useLocale();
|
|
158
158
|
const blocks = vue.ref([]);
|
|
159
159
|
const contexts = vue.ref({});
|
|
160
160
|
const selectedIndex = vue.ref(null);
|
|
@@ -162,7 +162,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
162
162
|
const globalBlockTypes = vue.ref([]);
|
|
163
163
|
const runtimeLoading = vue.ref(true);
|
|
164
164
|
vue.provide("contexts", contexts);
|
|
165
|
-
vue.provide(
|
|
165
|
+
vue.provide(appRuntime.BLOX_RUNTIME_KEY, {
|
|
166
166
|
isPreview: vue.ref(true),
|
|
167
167
|
loading: runtimeLoading
|
|
168
168
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, inject, ref, h, provide, onMounted, onUnmounted, openBlock, createElementBlock, createVNode, unref, nextTick } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { f as BLOX_REGISTRY_KEY, r as resolveBlockProps, u as useLocale, g as BLOX_RUNTIME_KEY } from "./appRuntime-B6yWkH3M.js";
|
|
3
3
|
function sendToEditor(msg) {
|
|
4
4
|
window.parent.postMessage(cloneForPostMessage(msg), "*");
|
|
5
5
|
}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { CollectionItemsPage, PageResolveRead } from './types';
|
|
2
|
+
import { App, InjectionKey } from 'vue';
|
|
2
3
|
type CollectionResolver = (collection: string, options: ListItemsOptions) => Promise<Array<Record<string, unknown>>>;
|
|
4
|
+
export interface BloxApiOptions {
|
|
5
|
+
websiteName: string;
|
|
6
|
+
store: string;
|
|
7
|
+
origin?: string;
|
|
8
|
+
collectionResolver?: CollectionResolver | null;
|
|
9
|
+
}
|
|
10
|
+
export interface BloxApiClient {
|
|
11
|
+
getWebsiteIdSync: () => string | null;
|
|
12
|
+
getWebsiteId: () => Promise<string>;
|
|
13
|
+
resolvePath: (path: string, locale: string) => Promise<PageResolveRead>;
|
|
14
|
+
listItems: <T = Record<string, unknown>>(collection: string, options?: ListItemsOptions) => Promise<CollectionItemsPage & {
|
|
15
|
+
items: T[];
|
|
16
|
+
}>;
|
|
17
|
+
getItemBySlug: <T = Record<string, unknown>>(collection: string, slug: string, locale?: string) => Promise<T | null>;
|
|
18
|
+
getItemById: <T = Record<string, unknown>>(collection: string, id: string, locale?: string) => Promise<T | null>;
|
|
19
|
+
}
|
|
20
|
+
export declare const BLOX_API_KEY: InjectionKey<BloxApiClient>;
|
|
3
21
|
export declare function configureApi(websiteName: string, store: string): void;
|
|
4
22
|
/**
|
|
5
23
|
* Point blox's datastore client at an absolute API base (SSG/Node, where
|
|
@@ -9,6 +27,9 @@ export declare function configureApi(websiteName: string, store: string): void;
|
|
|
9
27
|
export declare function setApiOrigin(base: string): void;
|
|
10
28
|
/** Use an immutable build-time collection source instead of HTTP during SSR. */
|
|
11
29
|
export declare function setCollectionResolver(resolver: CollectionResolver | null): void;
|
|
30
|
+
export declare function createBloxApi(options: BloxApiOptions): BloxApiClient;
|
|
31
|
+
export declare function provideBloxApi(app: App, options: BloxApiOptions): BloxApiClient;
|
|
32
|
+
export declare function useBloxApi(): BloxApiClient | null;
|
|
12
33
|
/** Synchronously read the resolved website id if already known (SSG-embedded or cached). */
|
|
13
34
|
export declare function getWebsiteIdSync(): string | null;
|
|
14
35
|
export declare function getWebsiteId(): Promise<string>;
|
|
@@ -38,5 +59,8 @@ export declare function getItemBySlug<T = Record<string, unknown>>(collection: s
|
|
|
38
59
|
* Returns null if the item isn't available in that locale (datastore 406/404).
|
|
39
60
|
*/
|
|
40
61
|
export declare function getItemById<T = Record<string, unknown>>(collection: string, id: string, locale?: string): Promise<T | null>;
|
|
62
|
+
export declare function listItemsFromActiveApi<T = Record<string, unknown>>(collection: string, options?: ListItemsOptions): Promise<CollectionItemsPage & {
|
|
63
|
+
items: T[];
|
|
64
|
+
}>;
|
|
41
65
|
export {};
|
|
42
66
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,eAAe,EAAoB,MA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