@bagelink/blox 1.15.47 → 1.15.51
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/{PreviewApp-CCxTa86_.js → PreviewApp-BrpFk5Ud.js} +1 -1
- package/dist/{PreviewApp-C5hzLdHt.cjs → PreviewApp-C6NyDvt7.cjs} +1 -1
- package/dist/PreviewApp.vue.d.ts.map +1 -1
- package/dist/{PreviewApp.vue_vue_type_style_index_0_lang-Bv4eRrVz.js → PreviewApp.vue_vue_type_style_index_0_lang-weDpp7Uy.js} +71 -25
- package/dist/{PreviewApp.vue_vue_type_style_index_0_lang-Da4Pi_Lc.cjs → PreviewApp.vue_vue_type_style_index_0_lang-y8aUlctU.cjs} +71 -25
- package/dist/PreviewRenderer.d.ts +11 -0
- package/dist/PreviewRenderer.d.ts.map +1 -1
- package/dist/bridge.d.ts +31 -0
- package/dist/bridge.d.ts.map +1 -1
- package/dist/composables/useGlobalBlock.d.ts +31 -0
- package/dist/composables/useGlobalBlock.d.ts.map +1 -0
- package/dist/{core-Do0ELzJT.js → core-CIFcs9Cn.js} +6 -6
- package/dist/{core-CR2evIjK.cjs → core-ZJ2VPvQb.cjs} +1 -1
- package/dist/index.cjs +35 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +41 -8
- package/dist/ssg/index.cjs +1 -1
- package/dist/ssg/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -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-y8aUlctU.cjs");
|
|
4
4
|
exports.default = PreviewApp_vue_vue_type_style_index_0_lang._sfc_main;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewApp.vue.d.ts","sourceRoot":"","sources":["../src/PreviewApp.vue"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PreviewApp.vue.d.ts","sourceRoot":"","sources":["../src/PreviewApp.vue"],"names":[],"mappings":";AA6RA,wBAMG"}
|
|
@@ -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 { B as BLOX_REGISTRY_KEY, u as useLocale } from "./core-CIFcs9Cn.js";
|
|
3
3
|
function sendToEditor(msg) {
|
|
4
4
|
window.parent.postMessage(msg, "*");
|
|
5
5
|
}
|
|
@@ -21,6 +21,11 @@ const PreviewRenderer = defineComponent({
|
|
|
21
21
|
hoveredIndex: {
|
|
22
22
|
type: Number,
|
|
23
23
|
default: null
|
|
24
|
+
},
|
|
25
|
+
/** Block types that are global/shared (nav, footer, …) — highlighted distinctly. */
|
|
26
|
+
globalBlockTypes: {
|
|
27
|
+
type: Array,
|
|
28
|
+
default: () => []
|
|
24
29
|
}
|
|
25
30
|
},
|
|
26
31
|
setup(props) {
|
|
@@ -29,6 +34,15 @@ const PreviewRenderer = defineComponent({
|
|
|
29
34
|
function onBlockClick(index) {
|
|
30
35
|
sendToEditor({ type: "BLOX_BLOCK_CLICK", index });
|
|
31
36
|
}
|
|
37
|
+
function onBlockContextMenu(index, event) {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
sendToEditor({
|
|
40
|
+
type: "BLOX_BLOCK_CONTEXTMENU",
|
|
41
|
+
index,
|
|
42
|
+
x: event.clientX,
|
|
43
|
+
y: event.clientY
|
|
44
|
+
});
|
|
45
|
+
}
|
|
32
46
|
function onBlockEnter(index) {
|
|
33
47
|
localHovered.value = index;
|
|
34
48
|
sendToEditor({ type: "BLOX_BLOCK_HOVER", index });
|
|
@@ -37,29 +51,24 @@ const PreviewRenderer = defineComponent({
|
|
|
37
51
|
localHovered.value = null;
|
|
38
52
|
sendToEditor({ type: "BLOX_BLOCK_HOVER", index: null });
|
|
39
53
|
}
|
|
54
|
+
const REGULAR = { solid: "#6366f1", rgb: "99, 102, 241" };
|
|
55
|
+
const GLOBAL = { solid: "#f59e0b", rgb: "245, 158, 11" };
|
|
40
56
|
const wrapperStyle = { position: "relative", cursor: "pointer" };
|
|
41
|
-
const
|
|
57
|
+
const overlayBaseFor = (rgb) => ({
|
|
42
58
|
position: "absolute",
|
|
43
59
|
inset: "0",
|
|
44
|
-
zIndex: "
|
|
60
|
+
zIndex: "2147483646",
|
|
45
61
|
pointerEvents: "auto",
|
|
46
|
-
transition: "box-shadow 0.12s, background 0.12s"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
const overlaySelected = {
|
|
54
|
-
...overlayBase,
|
|
55
|
-
boxShadow: "inset 0 0 0 3px #6366f1",
|
|
56
|
-
background: "rgba(99, 102, 241, 0.06)"
|
|
57
|
-
};
|
|
58
|
-
const labelBase = {
|
|
62
|
+
transition: "box-shadow 0.12s, background 0.12s",
|
|
63
|
+
boxShadow: "none",
|
|
64
|
+
background: "transparent",
|
|
65
|
+
"--blox-rgb": rgb
|
|
66
|
+
});
|
|
67
|
+
const labelBaseFor = (palette) => ({
|
|
59
68
|
position: "absolute",
|
|
60
69
|
top: "0",
|
|
61
70
|
left: "0",
|
|
62
|
-
zIndex: "
|
|
71
|
+
zIndex: "2147483647",
|
|
63
72
|
padding: "2px 8px",
|
|
64
73
|
fontSize: "11px",
|
|
65
74
|
fontFamily: "system-ui, sans-serif",
|
|
@@ -69,11 +78,10 @@ const PreviewRenderer = defineComponent({
|
|
|
69
78
|
textTransform: "uppercase",
|
|
70
79
|
pointerEvents: "none",
|
|
71
80
|
whiteSpace: "nowrap",
|
|
72
|
-
color:
|
|
73
|
-
background:
|
|
81
|
+
color: palette.solid,
|
|
82
|
+
background: `rgba(${palette.rgb}, 0.12)`,
|
|
74
83
|
borderBottomRightRadius: "4px"
|
|
75
|
-
};
|
|
76
|
-
const labelSelected = { ...labelBase, color: "#fff", background: "#6366f1" };
|
|
84
|
+
});
|
|
77
85
|
return () => h(
|
|
78
86
|
"div",
|
|
79
87
|
{ class: "blox-preview-canvas" },
|
|
@@ -83,7 +91,18 @@ const PreviewRenderer = defineComponent({
|
|
|
83
91
|
const isSelected = props.selectedIndex === i;
|
|
84
92
|
const isHovered = (props.hoveredIndex === i || localHovered.value === i) && !isSelected;
|
|
85
93
|
const { label } = definition.schema;
|
|
86
|
-
const
|
|
94
|
+
const isGlobal = props.globalBlockTypes.includes(block.type);
|
|
95
|
+
const palette = isGlobal ? GLOBAL : REGULAR;
|
|
96
|
+
const overlayStyle = { ...overlayBaseFor(palette.rgb) };
|
|
97
|
+
if (isSelected) {
|
|
98
|
+
overlayStyle.boxShadow = `inset 0 0 0 3px ${palette.solid}`;
|
|
99
|
+
overlayStyle.background = `rgba(${palette.rgb}, 0.06)`;
|
|
100
|
+
} else if (isHovered) {
|
|
101
|
+
overlayStyle.boxShadow = `inset 0 0 0 2px rgba(${palette.rgb}, 0.5)`;
|
|
102
|
+
overlayStyle.background = `rgba(${palette.rgb}, 0.04)`;
|
|
103
|
+
}
|
|
104
|
+
const labelBase = labelBaseFor(palette);
|
|
105
|
+
const labelStyle = isSelected ? { ...labelBase, color: "#fff", background: palette.solid } : labelBase;
|
|
87
106
|
return [
|
|
88
107
|
h(
|
|
89
108
|
"div",
|
|
@@ -94,6 +113,9 @@ const PreviewRenderer = defineComponent({
|
|
|
94
113
|
"onClick": () => {
|
|
95
114
|
onBlockClick(i);
|
|
96
115
|
},
|
|
116
|
+
"onContextmenu": (e) => {
|
|
117
|
+
onBlockContextMenu(i, e);
|
|
118
|
+
},
|
|
97
119
|
"onMouseenter": () => {
|
|
98
120
|
onBlockEnter(i);
|
|
99
121
|
},
|
|
@@ -102,7 +124,7 @@ const PreviewRenderer = defineComponent({
|
|
|
102
124
|
[
|
|
103
125
|
h(definition.component, { ...definition.schema.defaults, ...block.props }),
|
|
104
126
|
h("div", { style: overlayStyle }),
|
|
105
|
-
(isSelected || isHovered) && h("div", { style:
|
|
127
|
+
(isSelected || isHovered) && h("div", { style: labelStyle }, label)
|
|
106
128
|
]
|
|
107
129
|
)
|
|
108
130
|
];
|
|
@@ -120,6 +142,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
120
142
|
const contexts = ref({});
|
|
121
143
|
const selectedIndex = ref(null);
|
|
122
144
|
const hoveredIndex = ref(null);
|
|
145
|
+
const globalBlockTypes = ref([]);
|
|
123
146
|
provide("contexts", contexts);
|
|
124
147
|
let heightObserver = null;
|
|
125
148
|
function onMessage(event) {
|
|
@@ -149,13 +172,32 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
149
172
|
case "BLOX_HOVER_BLOCK":
|
|
150
173
|
hoveredIndex.value = msg.index;
|
|
151
174
|
break;
|
|
175
|
+
case "BLOX_SET_GLOBAL_BLOCKS":
|
|
176
|
+
globalBlockTypes.value = msg.types ?? [];
|
|
177
|
+
break;
|
|
152
178
|
case "BLOX_SCROLL_TOP":
|
|
153
179
|
window.scrollTo(0, 0);
|
|
154
180
|
break;
|
|
155
181
|
}
|
|
156
182
|
}
|
|
183
|
+
function blockNavigation(event) {
|
|
184
|
+
const target = event.target;
|
|
185
|
+
const anchor = target == null ? void 0 : target.closest("a");
|
|
186
|
+
if (anchor && (anchor.getAttribute("href") || anchor.hasAttribute("target"))) {
|
|
187
|
+
event.preventDefault();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function blockSubmit(event) {
|
|
191
|
+
event.preventDefault();
|
|
192
|
+
}
|
|
193
|
+
function blockUnload(event) {
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
}
|
|
157
196
|
onMounted(() => {
|
|
158
197
|
window.addEventListener("message", onMessage);
|
|
198
|
+
document.addEventListener("click", blockNavigation, true);
|
|
199
|
+
document.addEventListener("submit", blockSubmit, true);
|
|
200
|
+
window.addEventListener("beforeunload", blockUnload);
|
|
159
201
|
heightObserver = new ResizeObserver(() => {
|
|
160
202
|
sendToEditor({ type: "BLOX_HEIGHT", height: document.body.scrollHeight });
|
|
161
203
|
});
|
|
@@ -167,6 +209,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
167
209
|
});
|
|
168
210
|
onUnmounted(() => {
|
|
169
211
|
window.removeEventListener("message", onMessage);
|
|
212
|
+
document.removeEventListener("click", blockNavigation, true);
|
|
213
|
+
document.removeEventListener("submit", blockSubmit, true);
|
|
214
|
+
window.removeEventListener("beforeunload", blockUnload);
|
|
170
215
|
heightObserver == null ? void 0 : heightObserver.disconnect();
|
|
171
216
|
});
|
|
172
217
|
return (_ctx, _cache) => {
|
|
@@ -174,8 +219,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
174
219
|
createVNode(unref(PreviewRenderer), {
|
|
175
220
|
blocks: blocks.value,
|
|
176
221
|
"selected-index": selectedIndex.value,
|
|
177
|
-
"hovered-index": hoveredIndex.value
|
|
178
|
-
|
|
222
|
+
"hovered-index": hoveredIndex.value,
|
|
223
|
+
"global-block-types": globalBlockTypes.value
|
|
224
|
+
}, null, 8, ["blocks", "selected-index", "hovered-index", "global-block-types"])
|
|
179
225
|
]);
|
|
180
226
|
};
|
|
181
227
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const vue = require("vue");
|
|
3
|
-
const core = require("./core-
|
|
3
|
+
const core = require("./core-ZJ2VPvQb.cjs");
|
|
4
4
|
function sendToEditor(msg) {
|
|
5
5
|
window.parent.postMessage(msg, "*");
|
|
6
6
|
}
|
|
@@ -22,6 +22,11 @@ const PreviewRenderer = vue.defineComponent({
|
|
|
22
22
|
hoveredIndex: {
|
|
23
23
|
type: Number,
|
|
24
24
|
default: null
|
|
25
|
+
},
|
|
26
|
+
/** Block types that are global/shared (nav, footer, …) — highlighted distinctly. */
|
|
27
|
+
globalBlockTypes: {
|
|
28
|
+
type: Array,
|
|
29
|
+
default: () => []
|
|
25
30
|
}
|
|
26
31
|
},
|
|
27
32
|
setup(props) {
|
|
@@ -30,6 +35,15 @@ const PreviewRenderer = vue.defineComponent({
|
|
|
30
35
|
function onBlockClick(index) {
|
|
31
36
|
sendToEditor({ type: "BLOX_BLOCK_CLICK", index });
|
|
32
37
|
}
|
|
38
|
+
function onBlockContextMenu(index, event) {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
sendToEditor({
|
|
41
|
+
type: "BLOX_BLOCK_CONTEXTMENU",
|
|
42
|
+
index,
|
|
43
|
+
x: event.clientX,
|
|
44
|
+
y: event.clientY
|
|
45
|
+
});
|
|
46
|
+
}
|
|
33
47
|
function onBlockEnter(index) {
|
|
34
48
|
localHovered.value = index;
|
|
35
49
|
sendToEditor({ type: "BLOX_BLOCK_HOVER", index });
|
|
@@ -38,29 +52,24 @@ const PreviewRenderer = vue.defineComponent({
|
|
|
38
52
|
localHovered.value = null;
|
|
39
53
|
sendToEditor({ type: "BLOX_BLOCK_HOVER", index: null });
|
|
40
54
|
}
|
|
55
|
+
const REGULAR = { solid: "#6366f1", rgb: "99, 102, 241" };
|
|
56
|
+
const GLOBAL = { solid: "#f59e0b", rgb: "245, 158, 11" };
|
|
41
57
|
const wrapperStyle = { position: "relative", cursor: "pointer" };
|
|
42
|
-
const
|
|
58
|
+
const overlayBaseFor = (rgb) => ({
|
|
43
59
|
position: "absolute",
|
|
44
60
|
inset: "0",
|
|
45
|
-
zIndex: "
|
|
61
|
+
zIndex: "2147483646",
|
|
46
62
|
pointerEvents: "auto",
|
|
47
|
-
transition: "box-shadow 0.12s, background 0.12s"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
const overlaySelected = {
|
|
55
|
-
...overlayBase,
|
|
56
|
-
boxShadow: "inset 0 0 0 3px #6366f1",
|
|
57
|
-
background: "rgba(99, 102, 241, 0.06)"
|
|
58
|
-
};
|
|
59
|
-
const labelBase = {
|
|
63
|
+
transition: "box-shadow 0.12s, background 0.12s",
|
|
64
|
+
boxShadow: "none",
|
|
65
|
+
background: "transparent",
|
|
66
|
+
"--blox-rgb": rgb
|
|
67
|
+
});
|
|
68
|
+
const labelBaseFor = (palette) => ({
|
|
60
69
|
position: "absolute",
|
|
61
70
|
top: "0",
|
|
62
71
|
left: "0",
|
|
63
|
-
zIndex: "
|
|
72
|
+
zIndex: "2147483647",
|
|
64
73
|
padding: "2px 8px",
|
|
65
74
|
fontSize: "11px",
|
|
66
75
|
fontFamily: "system-ui, sans-serif",
|
|
@@ -70,11 +79,10 @@ const PreviewRenderer = vue.defineComponent({
|
|
|
70
79
|
textTransform: "uppercase",
|
|
71
80
|
pointerEvents: "none",
|
|
72
81
|
whiteSpace: "nowrap",
|
|
73
|
-
color:
|
|
74
|
-
background:
|
|
82
|
+
color: palette.solid,
|
|
83
|
+
background: `rgba(${palette.rgb}, 0.12)`,
|
|
75
84
|
borderBottomRightRadius: "4px"
|
|
76
|
-
};
|
|
77
|
-
const labelSelected = { ...labelBase, color: "#fff", background: "#6366f1" };
|
|
85
|
+
});
|
|
78
86
|
return () => vue.h(
|
|
79
87
|
"div",
|
|
80
88
|
{ class: "blox-preview-canvas" },
|
|
@@ -84,7 +92,18 @@ const PreviewRenderer = vue.defineComponent({
|
|
|
84
92
|
const isSelected = props.selectedIndex === i;
|
|
85
93
|
const isHovered = (props.hoveredIndex === i || localHovered.value === i) && !isSelected;
|
|
86
94
|
const { label } = definition.schema;
|
|
87
|
-
const
|
|
95
|
+
const isGlobal = props.globalBlockTypes.includes(block.type);
|
|
96
|
+
const palette = isGlobal ? GLOBAL : REGULAR;
|
|
97
|
+
const overlayStyle = { ...overlayBaseFor(palette.rgb) };
|
|
98
|
+
if (isSelected) {
|
|
99
|
+
overlayStyle.boxShadow = `inset 0 0 0 3px ${palette.solid}`;
|
|
100
|
+
overlayStyle.background = `rgba(${palette.rgb}, 0.06)`;
|
|
101
|
+
} else if (isHovered) {
|
|
102
|
+
overlayStyle.boxShadow = `inset 0 0 0 2px rgba(${palette.rgb}, 0.5)`;
|
|
103
|
+
overlayStyle.background = `rgba(${palette.rgb}, 0.04)`;
|
|
104
|
+
}
|
|
105
|
+
const labelBase = labelBaseFor(palette);
|
|
106
|
+
const labelStyle = isSelected ? { ...labelBase, color: "#fff", background: palette.solid } : labelBase;
|
|
88
107
|
return [
|
|
89
108
|
vue.h(
|
|
90
109
|
"div",
|
|
@@ -95,6 +114,9 @@ const PreviewRenderer = vue.defineComponent({
|
|
|
95
114
|
"onClick": () => {
|
|
96
115
|
onBlockClick(i);
|
|
97
116
|
},
|
|
117
|
+
"onContextmenu": (e) => {
|
|
118
|
+
onBlockContextMenu(i, e);
|
|
119
|
+
},
|
|
98
120
|
"onMouseenter": () => {
|
|
99
121
|
onBlockEnter(i);
|
|
100
122
|
},
|
|
@@ -103,7 +125,7 @@ const PreviewRenderer = vue.defineComponent({
|
|
|
103
125
|
[
|
|
104
126
|
vue.h(definition.component, { ...definition.schema.defaults, ...block.props }),
|
|
105
127
|
vue.h("div", { style: overlayStyle }),
|
|
106
|
-
(isSelected || isHovered) && vue.h("div", { style:
|
|
128
|
+
(isSelected || isHovered) && vue.h("div", { style: labelStyle }, label)
|
|
107
129
|
]
|
|
108
130
|
)
|
|
109
131
|
];
|
|
@@ -121,6 +143,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
121
143
|
const contexts = vue.ref({});
|
|
122
144
|
const selectedIndex = vue.ref(null);
|
|
123
145
|
const hoveredIndex = vue.ref(null);
|
|
146
|
+
const globalBlockTypes = vue.ref([]);
|
|
124
147
|
vue.provide("contexts", contexts);
|
|
125
148
|
let heightObserver = null;
|
|
126
149
|
function onMessage(event) {
|
|
@@ -150,13 +173,32 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
150
173
|
case "BLOX_HOVER_BLOCK":
|
|
151
174
|
hoveredIndex.value = msg.index;
|
|
152
175
|
break;
|
|
176
|
+
case "BLOX_SET_GLOBAL_BLOCKS":
|
|
177
|
+
globalBlockTypes.value = msg.types ?? [];
|
|
178
|
+
break;
|
|
153
179
|
case "BLOX_SCROLL_TOP":
|
|
154
180
|
window.scrollTo(0, 0);
|
|
155
181
|
break;
|
|
156
182
|
}
|
|
157
183
|
}
|
|
184
|
+
function blockNavigation(event) {
|
|
185
|
+
const target = event.target;
|
|
186
|
+
const anchor = target == null ? void 0 : target.closest("a");
|
|
187
|
+
if (anchor && (anchor.getAttribute("href") || anchor.hasAttribute("target"))) {
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function blockSubmit(event) {
|
|
192
|
+
event.preventDefault();
|
|
193
|
+
}
|
|
194
|
+
function blockUnload(event) {
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
}
|
|
158
197
|
vue.onMounted(() => {
|
|
159
198
|
window.addEventListener("message", onMessage);
|
|
199
|
+
document.addEventListener("click", blockNavigation, true);
|
|
200
|
+
document.addEventListener("submit", blockSubmit, true);
|
|
201
|
+
window.addEventListener("beforeunload", blockUnload);
|
|
160
202
|
heightObserver = new ResizeObserver(() => {
|
|
161
203
|
sendToEditor({ type: "BLOX_HEIGHT", height: document.body.scrollHeight });
|
|
162
204
|
});
|
|
@@ -168,6 +210,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
168
210
|
});
|
|
169
211
|
vue.onUnmounted(() => {
|
|
170
212
|
window.removeEventListener("message", onMessage);
|
|
213
|
+
document.removeEventListener("click", blockNavigation, true);
|
|
214
|
+
document.removeEventListener("submit", blockSubmit, true);
|
|
215
|
+
window.removeEventListener("beforeunload", blockUnload);
|
|
171
216
|
heightObserver == null ? void 0 : heightObserver.disconnect();
|
|
172
217
|
});
|
|
173
218
|
return (_ctx, _cache) => {
|
|
@@ -175,8 +220,9 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
175
220
|
vue.createVNode(vue.unref(PreviewRenderer), {
|
|
176
221
|
blocks: blocks.value,
|
|
177
222
|
"selected-index": selectedIndex.value,
|
|
178
|
-
"hovered-index": hoveredIndex.value
|
|
179
|
-
|
|
223
|
+
"hovered-index": hoveredIndex.value,
|
|
224
|
+
"global-block-types": globalBlockTypes.value
|
|
225
|
+
}, null, 8, ["blocks", "selected-index", "hovered-index", "global-block-types"])
|
|
180
226
|
]);
|
|
181
227
|
};
|
|
182
228
|
}
|
|
@@ -13,6 +13,11 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
13
13
|
type: PropType<number | null>;
|
|
14
14
|
default: null;
|
|
15
15
|
};
|
|
16
|
+
/** Block types that are global/shared (nav, footer, …) — highlighted distinctly. */
|
|
17
|
+
globalBlockTypes: {
|
|
18
|
+
type: PropType<string[]>;
|
|
19
|
+
default: () => string[];
|
|
20
|
+
};
|
|
16
21
|
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
17
22
|
[key: string]: any;
|
|
18
23
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
@@ -28,10 +33,16 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
28
33
|
type: PropType<number | null>;
|
|
29
34
|
default: null;
|
|
30
35
|
};
|
|
36
|
+
/** Block types that are global/shared (nav, footer, …) — highlighted distinctly. */
|
|
37
|
+
globalBlockTypes: {
|
|
38
|
+
type: PropType<string[]>;
|
|
39
|
+
default: () => string[];
|
|
40
|
+
};
|
|
31
41
|
}>> & Readonly<{}>, {
|
|
32
42
|
blocks: Block[];
|
|
33
43
|
selectedIndex: number | null;
|
|
34
44
|
hoveredIndex: number | null;
|
|
45
|
+
globalBlockTypes: string[];
|
|
35
46
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
36
47
|
export default _default;
|
|
37
48
|
//# sourceMappingURL=PreviewRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreviewRenderer.d.ts","sourceRoot":"","sources":["../src/PreviewRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;;;cAatB,QAAQ,CAAC,KAAK,EAAE,CAAC;uBACnB,KAAK,EAAE;;;cAGJ,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;cAIvB,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"PreviewRenderer.d.ts","sourceRoot":"","sources":["../src/PreviewRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;;;cAatB,QAAQ,CAAC,KAAK,EAAE,CAAC;uBACnB,KAAK,EAAE;;;cAGJ,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;cAIvB,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;IAGxC,oFAAoF;;cAEpE,QAAQ,CAAC,MAAM,EAAE,CAAC;uBACpB,MAAM,EAAE;;;;;;cAdN,QAAQ,CAAC,KAAK,EAAE,CAAC;uBACnB,KAAK,EAAE;;;cAGJ,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;;cAIvB,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;;;IAGxC,oFAAoF;;cAEpE,QAAQ,CAAC,MAAM,EAAE,CAAC;uBACpB,MAAM,EAAE;;;;;;;;AAlBxB,wBA8HE"}
|
package/dist/bridge.d.ts
CHANGED
|
@@ -28,6 +28,25 @@ export type EditorMessage = {
|
|
|
28
28
|
index: number | null;
|
|
29
29
|
} | {
|
|
30
30
|
type: 'BLOX_SCROLL_TOP';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Tells the preview which block types are global/shared (e.g. nav, footer).
|
|
34
|
+
* The preview renders their selection/hover overlay in a distinct color so
|
|
35
|
+
* it's clear editing them affects every page.
|
|
36
|
+
*/
|
|
37
|
+
| {
|
|
38
|
+
type: 'BLOX_SET_GLOBAL_BLOCKS';
|
|
39
|
+
types: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Tells the preview that a global/shared block's content changed (e.g. the
|
|
43
|
+
* editor saved the nav or footer singleton). Global block components should
|
|
44
|
+
* re-fetch their shared content. `block` optionally narrows the refresh to a
|
|
45
|
+
* single block type; when omitted, all global blocks should refresh.
|
|
46
|
+
*/
|
|
47
|
+
| {
|
|
48
|
+
type: 'BLOX_REFRESH_GLOBAL';
|
|
49
|
+
block?: string;
|
|
31
50
|
};
|
|
32
51
|
export type PreviewMessage = {
|
|
33
52
|
type: 'BLOX_READY';
|
|
@@ -38,6 +57,18 @@ export type PreviewMessage = {
|
|
|
38
57
|
} | {
|
|
39
58
|
type: 'BLOX_BLOCK_HOVER';
|
|
40
59
|
index: number | null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Right-click on a block in the preview. `x`/`y` are the pointer position
|
|
63
|
+
* relative to the iframe viewport; the editor maps them to its own
|
|
64
|
+
* coordinate space (accounting for the iframe offset + zoom) to open a
|
|
65
|
+
* context menu.
|
|
66
|
+
*/
|
|
67
|
+
| {
|
|
68
|
+
type: 'BLOX_BLOCK_CONTEXTMENU';
|
|
69
|
+
index: number;
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
41
72
|
} | {
|
|
42
73
|
type: 'BLOX_HEIGHT';
|
|
43
74
|
height: number;
|
package/dist/bridge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","s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K,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AACpD;;;;;GAKG;GACD;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GACvE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAM3C,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAEtD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI,CAEjF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Loader for a global/shared block's content.
|
|
4
|
+
*
|
|
5
|
+
* Receives nothing and returns the saved props object (or `null` when nothing
|
|
6
|
+
* is saved yet). Usually backed by a datastore singleton.
|
|
7
|
+
*/
|
|
8
|
+
export type GlobalBlockLoader<T> = () => Promise<T | null>;
|
|
9
|
+
export interface UseGlobalBlockResult<T> {
|
|
10
|
+
/** The loaded shared content, or `null` until the first successful load. */
|
|
11
|
+
data: Ref<T | null>;
|
|
12
|
+
/** True while a (re)load is in flight. */
|
|
13
|
+
loading: Ref<boolean>;
|
|
14
|
+
/** Manually trigger a reload. */
|
|
15
|
+
refresh: () => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Load and reactively track a global/shared block's content (e.g. site nav or
|
|
19
|
+
* footer, stored as a datastore singleton and shared across every page).
|
|
20
|
+
*
|
|
21
|
+
* The content is loaded once on mount. Additionally, when rendered inside the
|
|
22
|
+
* page-designer preview iframe, it listens for the `BLOX_REFRESH_GLOBAL` editor
|
|
23
|
+
* message and re-fetches — so saving the block in the editor updates the live
|
|
24
|
+
* preview instantly, without a page reload.
|
|
25
|
+
*
|
|
26
|
+
* @param blockType The block's type (e.g. `'TopnavBlox'`). Used to match
|
|
27
|
+
* targeted refresh messages.
|
|
28
|
+
* @param loader Async function that fetches the saved shared content.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useGlobalBlock<T extends Record<string, unknown>>(blockType: string, loader: GlobalBlockLoader<T>): UseGlobalBlockResult<T>;
|
|
31
|
+
//# sourceMappingURL=useGlobalBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGlobalBlock.d.ts","sourceRoot":"","sources":["../../src/composables/useGlobalBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAI9B;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;AAE1D,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACtC,4EAA4E;IAC5E,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;IACnB,0CAA0C;IAC1C,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,iCAAiC;IACjC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC1B,oBAAoB,CAAC,CAAC,CAAC,CAqCzB"}
|
|
@@ -403,7 +403,7 @@ class BloxInstance {
|
|
|
403
403
|
}
|
|
404
404
|
router.addRoute({
|
|
405
405
|
path: "/_blox_preview",
|
|
406
|
-
component: () => import("./PreviewApp-
|
|
406
|
+
component: () => import("./PreviewApp-BrpFk5Ud.js"),
|
|
407
407
|
beforeEnter: () => window.parent !== window ? true : "/"
|
|
408
408
|
});
|
|
409
409
|
router.addRoute({ path: "/:pathMatch(.*)*", component: _sfc_main$1 });
|
|
@@ -452,14 +452,14 @@ function createBlox(options) {
|
|
|
452
452
|
return instance;
|
|
453
453
|
}
|
|
454
454
|
export {
|
|
455
|
-
|
|
455
|
+
BLOX_REGISTRY_KEY as B,
|
|
456
456
|
PageRenderer as P,
|
|
457
457
|
_sfc_main$1 as _,
|
|
458
|
-
|
|
459
|
-
|
|
458
|
+
BLOX_LOCALE_STRATEGY_KEY as a,
|
|
459
|
+
BLOX_CONFIG_KEY as b,
|
|
460
460
|
createBlox as c,
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
BloxInstance as d,
|
|
462
|
+
configureApi as e,
|
|
463
463
|
listItems as l,
|
|
464
464
|
resolvePath as r,
|
|
465
465
|
useLocale as u
|
|
@@ -404,7 +404,7 @@ class BloxInstance {
|
|
|
404
404
|
}
|
|
405
405
|
router.addRoute({
|
|
406
406
|
path: "/_blox_preview",
|
|
407
|
-
component: () => Promise.resolve().then(() => require("./PreviewApp-
|
|
407
|
+
component: () => Promise.resolve().then(() => require("./PreviewApp-C6NyDvt7.cjs")),
|
|
408
408
|
beforeEnter: () => window.parent !== window ? true : "/"
|
|
409
409
|
});
|
|
410
410
|
router.addRoute({ path: "/:pathMatch(.*)*", component: _sfc_main$1 });
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const core = require("./core-
|
|
4
|
-
const PreviewApp_vue_vue_type_style_index_0_lang = require("./PreviewApp.vue_vue_type_style_index_0_lang-
|
|
3
|
+
const core = require("./core-ZJ2VPvQb.cjs");
|
|
4
|
+
const PreviewApp_vue_vue_type_style_index_0_lang = require("./PreviewApp.vue_vue_type_style_index_0_lang-y8aUlctU.cjs");
|
|
5
5
|
const vue = require("vue");
|
|
6
6
|
const vueRouter = require("vue-router");
|
|
7
7
|
const pinia = require("pinia");
|
|
8
8
|
const ssg_client = require("./ssg/client.cjs");
|
|
9
|
+
function useGlobalBlock(blockType, loader) {
|
|
10
|
+
const data = vue.ref(null);
|
|
11
|
+
const loading = vue.ref(false);
|
|
12
|
+
async function refresh() {
|
|
13
|
+
loading.value = true;
|
|
14
|
+
try {
|
|
15
|
+
const loaded = await loader();
|
|
16
|
+
if (loaded) data.value = loaded;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.warn(`[useGlobalBlock] failed to load "${blockType}", using defaults`, e);
|
|
19
|
+
} finally {
|
|
20
|
+
loading.value = false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function onEditorMessage(event) {
|
|
24
|
+
const msg = event.data;
|
|
25
|
+
if ((msg == null ? void 0 : msg.type) !== "BLOX_REFRESH_GLOBAL") return;
|
|
26
|
+
if (!msg.block || msg.block === blockType) void refresh();
|
|
27
|
+
}
|
|
28
|
+
vue.onMounted(() => {
|
|
29
|
+
void refresh();
|
|
30
|
+
if (typeof window !== "undefined") {
|
|
31
|
+
window.addEventListener("message", onEditorMessage);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
vue.onUnmounted(() => {
|
|
35
|
+
if (typeof window !== "undefined") {
|
|
36
|
+
window.removeEventListener("message", onEditorMessage);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return { data, loading, refresh };
|
|
40
|
+
}
|
|
9
41
|
function useLocaleNav() {
|
|
10
42
|
const strategy = vue.inject(core.BLOX_LOCALE_STRATEGY_KEY, null);
|
|
11
43
|
const router = vueRouter.useRouter();
|
|
@@ -117,5 +149,6 @@ exports.sendToEditor = PreviewApp_vue_vue_type_style_index_0_lang.sendToEditor;
|
|
|
117
149
|
exports.sendToPreview = PreviewApp_vue_vue_type_style_index_0_lang.sendToPreview;
|
|
118
150
|
exports.createBloxApp = createBloxApp;
|
|
119
151
|
exports.defineBlock = defineBlock;
|
|
152
|
+
exports.useGlobalBlock = useGlobalBlock;
|
|
120
153
|
exports.useLocaleNav = useLocaleNav;
|
|
121
154
|
exports.usePageContext = usePageContext;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export type { BindingWarning, Block, BloxPageApiAdapter, CollectionItem, Collect
|
|
|
4
4
|
export { sendToEditor, sendToPreview } from './bridge';
|
|
5
5
|
export type { BlockSchemaInfo, EditorMessage, PreviewMessage } from './bridge';
|
|
6
6
|
export { default as CmsPageView } from './CmsPageView.vue';
|
|
7
|
+
export { useGlobalBlock } from './composables/useGlobalBlock';
|
|
8
|
+
export type { GlobalBlockLoader, UseGlobalBlockResult } from './composables/useGlobalBlock';
|
|
7
9
|
export { useLocale } from './composables/useLocale';
|
|
8
10
|
export type { Locale } from './composables/useLocale';
|
|
9
11
|
export { useLocaleNav } from './composables/useLocaleNav';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,YAAY,EACX,cAAc,EACd,KAAK,EAEL,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,cAAc,EACd,QAAQ,EACR,eAAe,EACf,cAAc,EACd,WAAW,GACX,MAAM,aAAa,CAAA;AAIpB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACtD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAI9E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,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AAM,mBAAmB,CAAA;AAK9D,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAI5E,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAErE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { _ as _2, P as P2, s, a
|
|
4
|
-
import { inject, computed, createApp, markRaw } from "vue";
|
|
1
|
+
import { a as BLOX_LOCALE_STRATEGY_KEY, u as useLocale, c as createBlox } from "./core-CIFcs9Cn.js";
|
|
2
|
+
import { b, d, _, P, e, l, r } from "./core-CIFcs9Cn.js";
|
|
3
|
+
import { _ as _2, P as P2, s, a } from "./PreviewApp.vue_vue_type_style_index_0_lang-weDpp7Uy.js";
|
|
4
|
+
import { ref, onMounted, onUnmounted, inject, computed, createApp, markRaw } from "vue";
|
|
5
5
|
import { useRouter } from "vue-router";
|
|
6
6
|
import { createPinia } from "pinia";
|
|
7
7
|
import { installBloxStateCache, installCollectionCache } from "./ssg/client.mjs";
|
|
8
|
+
function useGlobalBlock(blockType, loader) {
|
|
9
|
+
const data = ref(null);
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
async function refresh() {
|
|
12
|
+
loading.value = true;
|
|
13
|
+
try {
|
|
14
|
+
const loaded = await loader();
|
|
15
|
+
if (loaded) data.value = loaded;
|
|
16
|
+
} catch (e2) {
|
|
17
|
+
console.warn(`[useGlobalBlock] failed to load "${blockType}", using defaults`, e2);
|
|
18
|
+
} finally {
|
|
19
|
+
loading.value = false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function onEditorMessage(event) {
|
|
23
|
+
const msg = event.data;
|
|
24
|
+
if ((msg == null ? void 0 : msg.type) !== "BLOX_REFRESH_GLOBAL") return;
|
|
25
|
+
if (!msg.block || msg.block === blockType) void refresh();
|
|
26
|
+
}
|
|
27
|
+
onMounted(() => {
|
|
28
|
+
void refresh();
|
|
29
|
+
if (typeof window !== "undefined") {
|
|
30
|
+
window.addEventListener("message", onEditorMessage);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
onUnmounted(() => {
|
|
34
|
+
if (typeof window !== "undefined") {
|
|
35
|
+
window.removeEventListener("message", onEditorMessage);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return { data, loading, refresh };
|
|
39
|
+
}
|
|
8
40
|
function useLocaleNav() {
|
|
9
41
|
const strategy = inject(BLOX_LOCALE_STRATEGY_KEY, null);
|
|
10
42
|
const router = useRouter();
|
|
@@ -101,21 +133,22 @@ function defineBlock(meta) {
|
|
|
101
133
|
return meta;
|
|
102
134
|
}
|
|
103
135
|
export {
|
|
104
|
-
|
|
136
|
+
b as BLOX_CONFIG_KEY,
|
|
105
137
|
BLOX_LOCALE_STRATEGY_KEY,
|
|
106
|
-
|
|
138
|
+
d as BloxInstance,
|
|
107
139
|
_ as CmsPageView,
|
|
108
140
|
P as PageRenderer,
|
|
109
141
|
_2 as PreviewApp,
|
|
110
142
|
P2 as PreviewRenderer,
|
|
111
|
-
|
|
143
|
+
e as configureApi,
|
|
112
144
|
createBlox,
|
|
113
145
|
createBloxApp,
|
|
114
146
|
defineBlock,
|
|
115
147
|
l as listItems,
|
|
116
148
|
r as resolvePath,
|
|
117
149
|
s as sendToEditor,
|
|
118
|
-
|
|
150
|
+
a as sendToPreview,
|
|
151
|
+
useGlobalBlock,
|
|
119
152
|
useLocale,
|
|
120
153
|
useLocaleNav,
|
|
121
154
|
usePageContext
|
package/dist/ssg/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ const prerender = require("../prerender-DH6Arhpk.cjs");
|
|
|
26
26
|
const ssg_client = require("./client.cjs");
|
|
27
27
|
const pinia = require("pinia");
|
|
28
28
|
const vue = require("vue");
|
|
29
|
-
const core = require("../core-
|
|
29
|
+
const core = require("../core-ZJ2VPvQb.cjs");
|
|
30
30
|
async function renderBloxSsgPage(options) {
|
|
31
31
|
const {
|
|
32
32
|
url,
|
package/dist/ssg/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { BLOX_STATE_WINDOW_KEY, BLOX_COLLECTIONS_WINDOW_KEY, BLOX_WEBSITE_ID_WIN
|
|
|
4
4
|
import { getCollectionCache, getEmbeddedWebsiteId, installBloxStateCache, installCollectionCache } from "./client.mjs";
|
|
5
5
|
import { createPinia } from "pinia";
|
|
6
6
|
import { createSSRApp, markRaw } from "vue";
|
|
7
|
-
import { c as createBlox } from "../core-
|
|
7
|
+
import { c as createBlox } from "../core-CIFcs9Cn.js";
|
|
8
8
|
async function renderBloxSsgPage(options) {
|
|
9
9
|
const {
|
|
10
10
|
url,
|
package/package.json
CHANGED