@juo/blocks 1.12.0 → 1.13.0-alpha.0
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/{ExtensionRoot-9XfhG8YM.js → ExtensionRoot-peABLAZZ.js} +15 -3
- package/dist/block-B6s9jL7l.js +966 -0
- package/dist/block.d.ts +50 -0
- package/dist/block.d.ts.map +1 -1
- package/dist/block.devtools.test.d.ts +2 -0
- package/dist/block.devtools.test.d.ts.map +1 -0
- package/dist/{bridge-w5KQ-czl.js → bridge-r7Yk8fjY.js} +34 -25
- package/dist/context.d.ts.map +1 -1
- package/dist/context.devtools.test.d.ts +2 -0
- package/dist/context.devtools.test.d.ts.map +1 -0
- package/dist/core.js +1877 -377
- package/dist/devtools/env.d.ts +3 -0
- package/dist/devtools/env.d.ts.map +1 -0
- package/dist/devtools/hook.d.ts +35 -0
- package/dist/devtools/hook.d.ts.map +1 -0
- package/dist/devtools/index.d.ts +4 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools/protocol.d.ts +91 -0
- package/dist/devtools/protocol.d.ts.map +1 -0
- package/dist/devtools.js +44 -0
- package/dist/editor/bridge.d.ts +7 -0
- package/dist/editor/bridge.d.ts.map +1 -1
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/main.d.ts +2 -1
- package/dist/editor/main.d.ts.map +1 -1
- package/dist/editor/messages.d.ts +13 -2
- package/dist/editor/messages.d.ts.map +1 -1
- package/dist/editor/messages.test.d.ts +2 -0
- package/dist/editor/messages.test.d.ts.map +1 -0
- package/dist/editor/overlays.d.ts +14 -0
- package/dist/editor/overlays.d.ts.map +1 -0
- package/dist/editor/overlays.test.d.ts +2 -0
- package/dist/editor/overlays.test.d.ts.map +1 -0
- package/dist/editor.js +64 -45
- package/dist/{juo-workflow-CkyZRq60.js → juo-workflow-DY4rd256.js} +74 -873
- package/dist/main.d.ts +3 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/overlay-wrapper.d.ts +69 -0
- package/dist/overlay-wrapper.d.ts.map +1 -0
- package/dist/overlay-wrapper.test.d.ts +2 -0
- package/dist/overlay-wrapper.test.d.ts.map +1 -0
- package/dist/overlays/OverlayService.d.ts +34 -0
- package/dist/overlays/OverlayService.d.ts.map +1 -0
- package/dist/overlays/OverlayService.test.d.ts +2 -0
- package/dist/overlays/OverlayService.test.d.ts.map +1 -0
- package/dist/preact.js +1 -1
- package/dist/react.js +1 -1
- package/dist/registry.devtools.test.d.ts +2 -0
- package/dist/registry.devtools.test.d.ts.map +1 -0
- package/dist/services/customer/adapter.d.ts +8 -0
- package/dist/services/customer/adapter.d.ts.map +1 -0
- package/dist/services/customer/customerService.d.ts +3 -2
- package/dist/services/customer/customerService.d.ts.map +1 -1
- package/dist/services/customer/index.d.ts +1 -0
- package/dist/services/customer/index.d.ts.map +1 -1
- package/dist/services/customer/types.d.ts +4 -1
- package/dist/services/customer/types.d.ts.map +1 -1
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/login/adapter.d.ts +32 -0
- package/dist/services/login/adapter.d.ts.map +1 -0
- package/dist/services/login/index.d.ts +3 -1
- package/dist/services/login/index.d.ts.map +1 -1
- package/dist/services/login/loginService.d.ts +6 -2
- package/dist/services/login/loginService.d.ts.map +1 -1
- package/dist/services/order/adapter.d.ts +9 -0
- package/dist/services/order/adapter.d.ts.map +1 -0
- package/dist/services/order/index.d.ts +5 -0
- package/dist/services/order/index.d.ts.map +1 -0
- package/dist/services/order/orderService.d.ts +7 -0
- package/dist/services/order/orderService.d.ts.map +1 -0
- package/dist/services/order/types.d.ts +21 -0
- package/dist/services/order/types.d.ts.map +1 -0
- package/dist/services/product/adapter.d.ts +27 -2
- package/dist/services/product/adapter.d.ts.map +1 -1
- package/dist/services/product/adapter.test.d.ts +2 -0
- package/dist/services/product/adapter.test.d.ts.map +1 -0
- package/dist/services/product/index.d.ts +1 -1
- package/dist/services/product/index.d.ts.map +1 -1
- package/dist/services/product/productService.d.ts.map +1 -1
- package/dist/services/product/types.d.ts +68 -0
- package/dist/services/product/types.d.ts.map +1 -1
- package/dist/services/schedules/adapter.d.ts +47 -0
- package/dist/services/schedules/adapter.d.ts.map +1 -0
- package/dist/services/schedules/adapter.test.d.ts +2 -0
- package/dist/services/schedules/adapter.test.d.ts.map +1 -0
- package/dist/services/schedules/index.d.ts +5 -0
- package/dist/services/schedules/index.d.ts.map +1 -0
- package/dist/services/schedules/schedulesService.d.ts +11 -0
- package/dist/services/schedules/schedulesService.d.ts.map +1 -0
- package/dist/services/schedules/schedulesService.test.d.ts +2 -0
- package/dist/services/schedules/schedulesService.test.d.ts.map +1 -0
- package/dist/services/schedules/types.d.ts +101 -0
- package/dist/services/schedules/types.d.ts.map +1 -0
- package/dist/services/settings/index.d.ts +3 -0
- package/dist/services/settings/index.d.ts.map +1 -0
- package/dist/services/settings/settingsService.d.ts +7 -0
- package/dist/services/settings/settingsService.d.ts.map +1 -0
- package/dist/services/settings/settingsService.test.d.ts +2 -0
- package/dist/services/settings/settingsService.test.d.ts.map +1 -0
- package/dist/services/settings/types.d.ts +35 -0
- package/dist/services/settings/types.d.ts.map +1 -0
- package/dist/services/shop/index.d.ts +3 -0
- package/dist/services/shop/index.d.ts.map +1 -0
- package/dist/services/shop/shopService.d.ts +12 -0
- package/dist/services/shop/shopService.d.ts.map +1 -0
- package/dist/services/shop/shopService.test.d.ts +2 -0
- package/dist/services/shop/shopService.test.d.ts.map +1 -0
- package/dist/services/shop/types.d.ts +7 -0
- package/dist/services/shop/types.d.ts.map +1 -0
- package/dist/services/subscription/adapter.d.ts +58 -2
- package/dist/services/subscription/adapter.d.ts.map +1 -1
- package/dist/services/subscription/adapter.test.d.ts +2 -0
- package/dist/services/subscription/adapter.test.d.ts.map +1 -0
- package/dist/services/subscription/index.d.ts +1 -1
- package/dist/services/subscription/index.d.ts.map +1 -1
- package/dist/services/subscription/subscriptionService.d.ts +1 -6
- package/dist/services/subscription/subscriptionService.d.ts.map +1 -1
- package/dist/services/subscription/types.d.ts +216 -9
- package/dist/services/subscription/types.d.ts.map +1 -1
- package/dist/services/subscription/types.test.d.ts +2 -0
- package/dist/services/subscription/types.test.d.ts.map +1 -0
- package/dist/theme-state.d.ts +2 -1
- package/dist/theme-state.d.ts.map +1 -1
- package/dist/theme-state.params.test.d.ts +2 -0
- package/dist/theme-state.params.test.d.ts.map +1 -0
- package/dist/theme-state.translations.test.d.ts +2 -0
- package/dist/theme-state.translations.test.d.ts.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/vue/block.d.ts.map +1 -1
- package/dist/vue.js +25 -4
- package/dist/web-components/ExtensionRoot.d.ts +1 -0
- package/dist/web-components/ExtensionRoot.d.ts.map +1 -1
- package/dist/web-components-editor.js +4 -3
- package/dist/web-components-runtime.js +3 -2
- package/package.json +1 -1
|
@@ -1,829 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
class ContextRequestEvent extends Event {
|
|
8
|
-
constructor(context, callback, subscribe) {
|
|
9
|
-
super("context-request", { bubbles: true, composed: true });
|
|
10
|
-
this.context = context;
|
|
11
|
-
this.callback = callback;
|
|
12
|
-
this.subscribe = subscribe;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
class ContextProvideEvent extends Event {
|
|
16
|
-
constructor(context, value, subscribe) {
|
|
17
|
-
super("context-provide", { bubbles: true, composed: true });
|
|
18
|
-
this.context = context;
|
|
19
|
-
this.value = value;
|
|
20
|
-
this.subscribe = subscribe;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function provideContext(target, context, init) {
|
|
24
|
-
console.log("context:provide", context, target);
|
|
25
|
-
const ev = new ContextProvideEvent(context, init);
|
|
26
|
-
target.dispatchEvent(ev);
|
|
27
|
-
}
|
|
28
|
-
function injectContext(target, context) {
|
|
29
|
-
let value = void 0;
|
|
30
|
-
console.log("context:inject", context, target);
|
|
31
|
-
const ev = new ContextRequestEvent(context, (received) => {
|
|
32
|
-
value = received;
|
|
33
|
-
});
|
|
34
|
-
target.dispatchEvent(ev);
|
|
35
|
-
if (value === void 0) {
|
|
36
|
-
throw new Error(`Context '${context}' not defined`);
|
|
37
|
-
}
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
function subscribeContext(target, context, callback) {
|
|
41
|
-
let unsubscribeFunction = null;
|
|
42
|
-
console.log("context:subscribe", context, target);
|
|
43
|
-
const protocolCallback = (value, unsubscribe) => {
|
|
44
|
-
if (unsubscribe) {
|
|
45
|
-
unsubscribeFunction = unsubscribe;
|
|
46
|
-
}
|
|
47
|
-
callback(value);
|
|
48
|
-
};
|
|
49
|
-
const ev = new ContextRequestEvent(context, protocolCallback, true);
|
|
50
|
-
target.dispatchEvent(ev);
|
|
51
|
-
return () => {
|
|
52
|
-
if (unsubscribeFunction) {
|
|
53
|
-
unsubscribeFunction();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
class ContextRoot extends HTMLElement {
|
|
58
|
-
constructor() {
|
|
59
|
-
super(...arguments);
|
|
60
|
-
__publicField(this, "store", /* @__PURE__ */ new Map());
|
|
61
|
-
__publicField(this, "callbacks", /* @__PURE__ */ new Map());
|
|
62
|
-
}
|
|
63
|
-
connectedCallback() {
|
|
64
|
-
this.addEventListener("context-provide", (ev) => {
|
|
65
|
-
ev.stopPropagation();
|
|
66
|
-
console.log("context-root:provide", ev.context, ev.value);
|
|
67
|
-
this.store.set(ev.context, ev.value);
|
|
68
|
-
const registeredCallbacks = this.callbacks.get(ev.context) ?? [];
|
|
69
|
-
console.log("callbacks", registeredCallbacks);
|
|
70
|
-
registeredCallbacks.forEach((cb) => {
|
|
71
|
-
const unsubscribe = () => {
|
|
72
|
-
const callbacks = this.callbacks.get(ev.context);
|
|
73
|
-
if (callbacks) {
|
|
74
|
-
const cbIndex = callbacks.indexOf(cb);
|
|
75
|
-
if (cbIndex > -1) {
|
|
76
|
-
callbacks.splice(cbIndex, 1);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
console.log("context-root:unsubscribed", ev.context);
|
|
80
|
-
};
|
|
81
|
-
cb(ev.value, unsubscribe);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
this.addEventListener("context-request", (ev) => {
|
|
85
|
-
ev.stopPropagation();
|
|
86
|
-
console.log("context-root:request", ev.context, ev);
|
|
87
|
-
const storedValue = this.store.get(ev.context);
|
|
88
|
-
if (ev.subscribe) {
|
|
89
|
-
let callbacks = this.callbacks.get(ev.context);
|
|
90
|
-
if (!callbacks) {
|
|
91
|
-
callbacks = [];
|
|
92
|
-
this.callbacks.set(ev.context, callbacks);
|
|
93
|
-
}
|
|
94
|
-
const unsubscribe = () => {
|
|
95
|
-
const currentCallbacks = this.callbacks.get(ev.context);
|
|
96
|
-
if (currentCallbacks) {
|
|
97
|
-
const index = currentCallbacks.indexOf(ev.callback);
|
|
98
|
-
if (index > -1) {
|
|
99
|
-
currentCallbacks.splice(index, 1);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
console.log("context-root:unsubscribed", ev.context);
|
|
103
|
-
};
|
|
104
|
-
callbacks.push(ev.callback);
|
|
105
|
-
if (storedValue !== void 0) {
|
|
106
|
-
ev.callback(storedValue, unsubscribe);
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
if (storedValue !== void 0) {
|
|
110
|
-
ev.callback(storedValue);
|
|
111
|
-
} else {
|
|
112
|
-
console.warn("Context not present in store: " + String(ev.context));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
console.log("context-root:ready");
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
var i = Symbol.for("preact-signals");
|
|
120
|
-
function t() {
|
|
121
|
-
if (!(s > 1)) {
|
|
122
|
-
var i2, t2 = false;
|
|
123
|
-
while (void 0 !== h) {
|
|
124
|
-
var r = h;
|
|
125
|
-
h = void 0;
|
|
126
|
-
f++;
|
|
127
|
-
while (void 0 !== r) {
|
|
128
|
-
var o2 = r.o;
|
|
129
|
-
r.o = void 0;
|
|
130
|
-
r.f &= -3;
|
|
131
|
-
if (!(8 & r.f) && c(r)) try {
|
|
132
|
-
r.c();
|
|
133
|
-
} catch (r2) {
|
|
134
|
-
if (!t2) {
|
|
135
|
-
i2 = r2;
|
|
136
|
-
t2 = true;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
r = o2;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
f = 0;
|
|
143
|
-
s--;
|
|
144
|
-
if (t2) throw i2;
|
|
145
|
-
} else s--;
|
|
146
|
-
}
|
|
147
|
-
var o = void 0;
|
|
148
|
-
function n(i2) {
|
|
149
|
-
var t2 = o;
|
|
150
|
-
o = void 0;
|
|
151
|
-
try {
|
|
152
|
-
return i2();
|
|
153
|
-
} finally {
|
|
154
|
-
o = t2;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
var h = void 0, s = 0, f = 0, v = 0;
|
|
158
|
-
function e(i2) {
|
|
159
|
-
if (void 0 !== o) {
|
|
160
|
-
var t2 = i2.n;
|
|
161
|
-
if (void 0 === t2 || t2.t !== o) {
|
|
162
|
-
t2 = { i: 0, S: i2, p: o.s, n: void 0, t: o, e: void 0, x: void 0, r: t2 };
|
|
163
|
-
if (void 0 !== o.s) o.s.n = t2;
|
|
164
|
-
o.s = t2;
|
|
165
|
-
i2.n = t2;
|
|
166
|
-
if (32 & o.f) i2.S(t2);
|
|
167
|
-
return t2;
|
|
168
|
-
} else if (-1 === t2.i) {
|
|
169
|
-
t2.i = 0;
|
|
170
|
-
if (void 0 !== t2.n) {
|
|
171
|
-
t2.n.p = t2.p;
|
|
172
|
-
if (void 0 !== t2.p) t2.p.n = t2.n;
|
|
173
|
-
t2.p = o.s;
|
|
174
|
-
t2.n = void 0;
|
|
175
|
-
o.s.n = t2;
|
|
176
|
-
o.s = t2;
|
|
177
|
-
}
|
|
178
|
-
return t2;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
function u(i2, t2) {
|
|
183
|
-
this.v = i2;
|
|
184
|
-
this.i = 0;
|
|
185
|
-
this.n = void 0;
|
|
186
|
-
this.t = void 0;
|
|
187
|
-
this.W = null == t2 ? void 0 : t2.watched;
|
|
188
|
-
this.Z = null == t2 ? void 0 : t2.unwatched;
|
|
189
|
-
}
|
|
190
|
-
u.prototype.brand = i;
|
|
191
|
-
u.prototype.h = function() {
|
|
192
|
-
return true;
|
|
193
|
-
};
|
|
194
|
-
u.prototype.S = function(i2) {
|
|
195
|
-
var t2 = this, r = this.t;
|
|
196
|
-
if (r !== i2 && void 0 === i2.e) {
|
|
197
|
-
i2.x = r;
|
|
198
|
-
this.t = i2;
|
|
199
|
-
if (void 0 !== r) r.e = i2;
|
|
200
|
-
else n(function() {
|
|
201
|
-
var i3;
|
|
202
|
-
null == (i3 = t2.W) || i3.call(t2);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
u.prototype.U = function(i2) {
|
|
207
|
-
var t2 = this;
|
|
208
|
-
if (void 0 !== this.t) {
|
|
209
|
-
var r = i2.e, o2 = i2.x;
|
|
210
|
-
if (void 0 !== r) {
|
|
211
|
-
r.x = o2;
|
|
212
|
-
i2.e = void 0;
|
|
213
|
-
}
|
|
214
|
-
if (void 0 !== o2) {
|
|
215
|
-
o2.e = r;
|
|
216
|
-
i2.x = void 0;
|
|
217
|
-
}
|
|
218
|
-
if (i2 === this.t) {
|
|
219
|
-
this.t = o2;
|
|
220
|
-
if (void 0 === o2) n(function() {
|
|
221
|
-
var i3;
|
|
222
|
-
null == (i3 = t2.Z) || i3.call(t2);
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
u.prototype.subscribe = function(i2) {
|
|
228
|
-
var t2 = this;
|
|
229
|
-
return E(function() {
|
|
230
|
-
var r = t2.value, n2 = o;
|
|
231
|
-
o = void 0;
|
|
232
|
-
try {
|
|
233
|
-
i2(r);
|
|
234
|
-
} finally {
|
|
235
|
-
o = n2;
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
};
|
|
239
|
-
u.prototype.valueOf = function() {
|
|
240
|
-
return this.value;
|
|
241
|
-
};
|
|
242
|
-
u.prototype.toString = function() {
|
|
243
|
-
return this.value + "";
|
|
244
|
-
};
|
|
245
|
-
u.prototype.toJSON = function() {
|
|
246
|
-
return this.value;
|
|
247
|
-
};
|
|
248
|
-
u.prototype.peek = function() {
|
|
249
|
-
var i2 = o;
|
|
250
|
-
o = void 0;
|
|
251
|
-
try {
|
|
252
|
-
return this.value;
|
|
253
|
-
} finally {
|
|
254
|
-
o = i2;
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
Object.defineProperty(u.prototype, "value", { get: function() {
|
|
258
|
-
var i2 = e(this);
|
|
259
|
-
if (void 0 !== i2) i2.i = this.i;
|
|
260
|
-
return this.v;
|
|
261
|
-
}, set: function(i2) {
|
|
262
|
-
if (i2 !== this.v) {
|
|
263
|
-
if (f > 100) throw new Error("Cycle detected");
|
|
264
|
-
this.v = i2;
|
|
265
|
-
this.i++;
|
|
266
|
-
v++;
|
|
267
|
-
s++;
|
|
268
|
-
try {
|
|
269
|
-
for (var r = this.t; void 0 !== r; r = r.x) r.t.N();
|
|
270
|
-
} finally {
|
|
271
|
-
t();
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
} });
|
|
275
|
-
function d(i2, t2) {
|
|
276
|
-
return new u(i2, t2);
|
|
277
|
-
}
|
|
278
|
-
function c(i2) {
|
|
279
|
-
for (var t2 = i2.s; void 0 !== t2; t2 = t2.n) if (t2.S.i !== t2.i || !t2.S.h() || t2.S.i !== t2.i) return true;
|
|
280
|
-
return false;
|
|
281
|
-
}
|
|
282
|
-
function a(i2) {
|
|
283
|
-
for (var t2 = i2.s; void 0 !== t2; t2 = t2.n) {
|
|
284
|
-
var r = t2.S.n;
|
|
285
|
-
if (void 0 !== r) t2.r = r;
|
|
286
|
-
t2.S.n = t2;
|
|
287
|
-
t2.i = -1;
|
|
288
|
-
if (void 0 === t2.n) {
|
|
289
|
-
i2.s = t2;
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
function l(i2) {
|
|
295
|
-
var t2 = i2.s, r = void 0;
|
|
296
|
-
while (void 0 !== t2) {
|
|
297
|
-
var o2 = t2.p;
|
|
298
|
-
if (-1 === t2.i) {
|
|
299
|
-
t2.S.U(t2);
|
|
300
|
-
if (void 0 !== o2) o2.n = t2.n;
|
|
301
|
-
if (void 0 !== t2.n) t2.n.p = o2;
|
|
302
|
-
} else r = t2;
|
|
303
|
-
t2.S.n = t2.r;
|
|
304
|
-
if (void 0 !== t2.r) t2.r = void 0;
|
|
305
|
-
t2 = o2;
|
|
306
|
-
}
|
|
307
|
-
i2.s = r;
|
|
308
|
-
}
|
|
309
|
-
function y(i2, t2) {
|
|
310
|
-
u.call(this, void 0);
|
|
311
|
-
this.x = i2;
|
|
312
|
-
this.s = void 0;
|
|
313
|
-
this.g = v - 1;
|
|
314
|
-
this.f = 4;
|
|
315
|
-
this.W = null == t2 ? void 0 : t2.watched;
|
|
316
|
-
this.Z = null == t2 ? void 0 : t2.unwatched;
|
|
317
|
-
}
|
|
318
|
-
y.prototype = new u();
|
|
319
|
-
y.prototype.h = function() {
|
|
320
|
-
this.f &= -3;
|
|
321
|
-
if (1 & this.f) return false;
|
|
322
|
-
if (32 == (36 & this.f)) return true;
|
|
323
|
-
this.f &= -5;
|
|
324
|
-
if (this.g === v) return true;
|
|
325
|
-
this.g = v;
|
|
326
|
-
this.f |= 1;
|
|
327
|
-
if (this.i > 0 && !c(this)) {
|
|
328
|
-
this.f &= -2;
|
|
329
|
-
return true;
|
|
330
|
-
}
|
|
331
|
-
var i2 = o;
|
|
332
|
-
try {
|
|
333
|
-
a(this);
|
|
334
|
-
o = this;
|
|
335
|
-
var t2 = this.x();
|
|
336
|
-
if (16 & this.f || this.v !== t2 || 0 === this.i) {
|
|
337
|
-
this.v = t2;
|
|
338
|
-
this.f &= -17;
|
|
339
|
-
this.i++;
|
|
340
|
-
}
|
|
341
|
-
} catch (i3) {
|
|
342
|
-
this.v = i3;
|
|
343
|
-
this.f |= 16;
|
|
344
|
-
this.i++;
|
|
345
|
-
}
|
|
346
|
-
o = i2;
|
|
347
|
-
l(this);
|
|
348
|
-
this.f &= -2;
|
|
349
|
-
return true;
|
|
350
|
-
};
|
|
351
|
-
y.prototype.S = function(i2) {
|
|
352
|
-
if (void 0 === this.t) {
|
|
353
|
-
this.f |= 36;
|
|
354
|
-
for (var t2 = this.s; void 0 !== t2; t2 = t2.n) t2.S.S(t2);
|
|
355
|
-
}
|
|
356
|
-
u.prototype.S.call(this, i2);
|
|
357
|
-
};
|
|
358
|
-
y.prototype.U = function(i2) {
|
|
359
|
-
if (void 0 !== this.t) {
|
|
360
|
-
u.prototype.U.call(this, i2);
|
|
361
|
-
if (void 0 === this.t) {
|
|
362
|
-
this.f &= -33;
|
|
363
|
-
for (var t2 = this.s; void 0 !== t2; t2 = t2.n) t2.S.U(t2);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
y.prototype.N = function() {
|
|
368
|
-
if (!(2 & this.f)) {
|
|
369
|
-
this.f |= 6;
|
|
370
|
-
for (var i2 = this.t; void 0 !== i2; i2 = i2.x) i2.t.N();
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
Object.defineProperty(y.prototype, "value", { get: function() {
|
|
374
|
-
if (1 & this.f) throw new Error("Cycle detected");
|
|
375
|
-
var i2 = e(this);
|
|
376
|
-
this.h();
|
|
377
|
-
if (void 0 !== i2) i2.i = this.i;
|
|
378
|
-
if (16 & this.f) throw this.v;
|
|
379
|
-
return this.v;
|
|
380
|
-
} });
|
|
381
|
-
function w(i2, t2) {
|
|
382
|
-
return new y(i2, t2);
|
|
383
|
-
}
|
|
384
|
-
function _(i2) {
|
|
385
|
-
var r = i2.u;
|
|
386
|
-
i2.u = void 0;
|
|
387
|
-
if ("function" == typeof r) {
|
|
388
|
-
s++;
|
|
389
|
-
var n2 = o;
|
|
390
|
-
o = void 0;
|
|
391
|
-
try {
|
|
392
|
-
r();
|
|
393
|
-
} catch (t2) {
|
|
394
|
-
i2.f &= -2;
|
|
395
|
-
i2.f |= 8;
|
|
396
|
-
b(i2);
|
|
397
|
-
throw t2;
|
|
398
|
-
} finally {
|
|
399
|
-
o = n2;
|
|
400
|
-
t();
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
function b(i2) {
|
|
405
|
-
for (var t2 = i2.s; void 0 !== t2; t2 = t2.n) t2.S.U(t2);
|
|
406
|
-
i2.x = void 0;
|
|
407
|
-
i2.s = void 0;
|
|
408
|
-
_(i2);
|
|
409
|
-
}
|
|
410
|
-
function g(i2) {
|
|
411
|
-
if (o !== this) throw new Error("Out-of-order effect");
|
|
412
|
-
l(this);
|
|
413
|
-
o = i2;
|
|
414
|
-
this.f &= -2;
|
|
415
|
-
if (8 & this.f) b(this);
|
|
416
|
-
t();
|
|
417
|
-
}
|
|
418
|
-
function p(i2) {
|
|
419
|
-
this.x = i2;
|
|
420
|
-
this.u = void 0;
|
|
421
|
-
this.s = void 0;
|
|
422
|
-
this.o = void 0;
|
|
423
|
-
this.f = 32;
|
|
424
|
-
}
|
|
425
|
-
p.prototype.c = function() {
|
|
426
|
-
var i2 = this.S();
|
|
427
|
-
try {
|
|
428
|
-
if (8 & this.f) return;
|
|
429
|
-
if (void 0 === this.x) return;
|
|
430
|
-
var t2 = this.x();
|
|
431
|
-
if ("function" == typeof t2) this.u = t2;
|
|
432
|
-
} finally {
|
|
433
|
-
i2();
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
p.prototype.S = function() {
|
|
437
|
-
if (1 & this.f) throw new Error("Cycle detected");
|
|
438
|
-
this.f |= 1;
|
|
439
|
-
this.f &= -9;
|
|
440
|
-
_(this);
|
|
441
|
-
a(this);
|
|
442
|
-
s++;
|
|
443
|
-
var i2 = o;
|
|
444
|
-
o = this;
|
|
445
|
-
return g.bind(this, i2);
|
|
446
|
-
};
|
|
447
|
-
p.prototype.N = function() {
|
|
448
|
-
if (!(2 & this.f)) {
|
|
449
|
-
this.f |= 2;
|
|
450
|
-
this.o = h;
|
|
451
|
-
h = this;
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
p.prototype.d = function() {
|
|
455
|
-
this.f |= 8;
|
|
456
|
-
if (!(1 & this.f)) b(this);
|
|
457
|
-
};
|
|
458
|
-
p.prototype.dispose = function() {
|
|
459
|
-
this.d();
|
|
460
|
-
};
|
|
461
|
-
function E(i2) {
|
|
462
|
-
var t2 = new p(i2);
|
|
463
|
-
try {
|
|
464
|
-
t2.c();
|
|
465
|
-
} catch (i3) {
|
|
466
|
-
t2.d();
|
|
467
|
-
throw i3;
|
|
468
|
-
}
|
|
469
|
-
var r = t2.d.bind(t2);
|
|
470
|
-
r[Symbol.dispose] = r;
|
|
471
|
-
return r;
|
|
472
|
-
}
|
|
473
|
-
function isEditorPreview() {
|
|
474
|
-
if (typeof window === "undefined") return false;
|
|
475
|
-
return new URLSearchParams(window.location.search).get("editor") === "true";
|
|
476
|
-
}
|
|
477
|
-
function hasRenderedContent(scope) {
|
|
478
|
-
var _a;
|
|
479
|
-
for (const child of scope.children) {
|
|
480
|
-
if (!(child instanceof HTMLElement)) {
|
|
481
|
-
continue;
|
|
482
|
-
}
|
|
483
|
-
const display = (_a = child.ownerDocument.defaultView) == null ? void 0 : _a.getComputedStyle(child).display;
|
|
484
|
-
if (display === "contents") {
|
|
485
|
-
if (hasRenderedContent(child)) {
|
|
486
|
-
return true;
|
|
487
|
-
}
|
|
488
|
-
continue;
|
|
489
|
-
}
|
|
490
|
-
if (child.checkVisibility()) {
|
|
491
|
-
return true;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
function attachEmptyTracking(host, scope) {
|
|
497
|
-
let observer = null;
|
|
498
|
-
let disposed = false;
|
|
499
|
-
queueMicrotask(() => {
|
|
500
|
-
if (disposed) return;
|
|
501
|
-
const observed = scope ?? host.shadowRoot ?? host;
|
|
502
|
-
const sync = () => host.toggleAttribute("data-empty", !hasRenderedContent(observed));
|
|
503
|
-
observer = new MutationObserver(sync);
|
|
504
|
-
observer.observe(observed, { childList: true, subtree: true });
|
|
505
|
-
sync();
|
|
506
|
-
});
|
|
507
|
-
return () => {
|
|
508
|
-
disposed = true;
|
|
509
|
-
observer == null ? void 0 : observer.disconnect();
|
|
510
|
-
observer = null;
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
function serializeBlocks(blocks) {
|
|
514
|
-
return blocks.map((block) => serializeBlock(block));
|
|
515
|
-
}
|
|
516
|
-
function serializeBlock(block) {
|
|
517
|
-
return {
|
|
518
|
-
id: block.id,
|
|
519
|
-
type: block.type,
|
|
520
|
-
props: JSON.parse(JSON.stringify(block.props)),
|
|
521
|
-
slots: Object.fromEntries(
|
|
522
|
-
Object.entries(block.slots ?? {}).map(([key, value]) => [
|
|
523
|
-
key,
|
|
524
|
-
Array.isArray(value) ? value.map(
|
|
525
|
-
(v2) => typeof v2 === "string" ? v2 : serializeBlock(v2)
|
|
526
|
-
) : typeof value === "string" ? value : serializeBlock(value)
|
|
527
|
-
])
|
|
528
|
-
)
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
function createSelectedBlock() {
|
|
532
|
-
const selected = d(null);
|
|
533
|
-
function setSelection(block) {
|
|
534
|
-
selected.value = null;
|
|
535
|
-
selected.value = block;
|
|
536
|
-
}
|
|
537
|
-
function clearSelection(block) {
|
|
538
|
-
var _a;
|
|
539
|
-
if (block == null || ((_a = selected.value) == null ? void 0 : _a.id) === block.id) {
|
|
540
|
-
selected.value = null;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
return { selected, setSelection, clearSelection };
|
|
544
|
-
}
|
|
545
|
-
const SelectedBlockContext = createContext("selectedBlock");
|
|
546
|
-
const blockDefinitions = (() => {
|
|
547
|
-
if (typeof window !== "undefined") {
|
|
548
|
-
window._juoBlocks = window._juoBlocks || /* @__PURE__ */ new Map();
|
|
549
|
-
return window._juoBlocks;
|
|
550
|
-
}
|
|
551
|
-
return /* @__PURE__ */ new Map();
|
|
552
|
-
})();
|
|
553
|
-
class BlockWrapperEvent extends Event {
|
|
554
|
-
constructor(block, callback) {
|
|
555
|
-
super("juo:block-wrapper-render", {
|
|
556
|
-
bubbles: true,
|
|
557
|
-
composed: true,
|
|
558
|
-
cancelable: true
|
|
559
|
-
});
|
|
560
|
-
this.block = block;
|
|
561
|
-
this.callback = callback;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
function withWrapper(fn) {
|
|
565
|
-
let wrapper = null;
|
|
566
|
-
return (block) => {
|
|
567
|
-
var _a;
|
|
568
|
-
let rendered;
|
|
569
|
-
try {
|
|
570
|
-
rendered = fn(block);
|
|
571
|
-
} catch (error) {
|
|
572
|
-
reportBlockError(error, {
|
|
573
|
-
site: "block.withWrapper",
|
|
574
|
-
block: { id: block.id, type: block.type, definition: block.definition },
|
|
575
|
-
keys: {
|
|
576
|
-
props: Object.keys(block.props ?? {}),
|
|
577
|
-
slots: Object.keys(block.slots ?? {})
|
|
578
|
-
}
|
|
579
|
-
});
|
|
580
|
-
rendered = createStubDefinition(block.type).render(block);
|
|
581
|
-
}
|
|
582
|
-
if (wrapper === null) {
|
|
583
|
-
if (isEditorPreview()) {
|
|
584
|
-
wrapper = document.createElement("juo-editor-block-wrapper");
|
|
585
|
-
wrapper.setAttribute("data-block-id", block.id);
|
|
586
|
-
(_a = wrapper.setBlock) == null ? void 0 : _a.call(wrapper, block);
|
|
587
|
-
wrapper.appendChild(rendered);
|
|
588
|
-
} else {
|
|
589
|
-
const evt = new BlockWrapperEvent(block, (evtWrapper) => {
|
|
590
|
-
wrapper = evtWrapper;
|
|
591
|
-
});
|
|
592
|
-
document.dispatchEvent(evt);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
if (!wrapper) {
|
|
596
|
-
return rendered;
|
|
597
|
-
}
|
|
598
|
-
wrapper.replaceChildren(rendered);
|
|
599
|
-
return wrapper;
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
const registerBlockListeners = [];
|
|
603
|
-
function registerBlock(block) {
|
|
604
|
-
blockDefinitions.set(block.name, block);
|
|
605
|
-
stubDefinitionCache.delete(block.name);
|
|
606
|
-
registerBlockListeners.forEach((cb) => cb(block.name, block));
|
|
607
|
-
}
|
|
608
|
-
function onRegisterBlock(cb) {
|
|
609
|
-
registerBlockListeners.push(cb);
|
|
610
|
-
return () => {
|
|
611
|
-
const idx = registerBlockListeners.indexOf(cb);
|
|
612
|
-
if (idx >= 0) registerBlockListeners.splice(idx, 1);
|
|
613
|
-
};
|
|
614
|
-
}
|
|
615
|
-
function defineBlock(name, opts) {
|
|
616
|
-
const definition = {
|
|
617
|
-
name,
|
|
618
|
-
displayName: opts.displayName,
|
|
619
|
-
group: opts.group,
|
|
620
|
-
schema: opts.schema,
|
|
621
|
-
initialValue: opts.initialValue,
|
|
622
|
-
render: opts.renderer,
|
|
623
|
-
presets: opts.presets,
|
|
624
|
-
locales: opts.locales
|
|
625
|
-
};
|
|
626
|
-
return definition;
|
|
627
|
-
}
|
|
628
|
-
function defineBlockRuntime(name, opts) {
|
|
629
|
-
const definition = {
|
|
630
|
-
name,
|
|
631
|
-
displayName: opts.displayName,
|
|
632
|
-
group: opts.group,
|
|
633
|
-
schema: {},
|
|
634
|
-
initialValue() {
|
|
635
|
-
throw new Error("Initial value cannot be called in runtime mode");
|
|
636
|
-
},
|
|
637
|
-
render: opts.renderer
|
|
638
|
-
};
|
|
639
|
-
return definition;
|
|
640
|
-
}
|
|
641
|
-
function getDefinedBlocks() {
|
|
642
|
-
return [...blockDefinitions.values()];
|
|
643
|
-
}
|
|
644
|
-
function createCeRenderer(name) {
|
|
645
|
-
function renderSlots(slots, block) {
|
|
646
|
-
if (!slots) {
|
|
647
|
-
return slots;
|
|
648
|
-
}
|
|
649
|
-
return Object.entries(slots).flatMap(([key, value]) => {
|
|
650
|
-
const values = Array.isArray(value) ? value : [value];
|
|
651
|
-
return values.flatMap((value2) => {
|
|
652
|
-
if (typeof value2 === "string") {
|
|
653
|
-
const el = document.createElement("span");
|
|
654
|
-
if (key !== "default") {
|
|
655
|
-
el.slot = key;
|
|
656
|
-
}
|
|
657
|
-
el.innerText = value2;
|
|
658
|
-
return [el];
|
|
659
|
-
}
|
|
660
|
-
try {
|
|
661
|
-
const el = value2.definition.render({
|
|
662
|
-
...value2,
|
|
663
|
-
props: {
|
|
664
|
-
...value2.props,
|
|
665
|
-
parentProps: block.props
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
if (key !== "default") {
|
|
669
|
-
el.slot = key;
|
|
670
|
-
}
|
|
671
|
-
return [el];
|
|
672
|
-
} catch (error) {
|
|
673
|
-
reportBlockError(error, {
|
|
674
|
-
site: "block.createCeRenderer.renderSlots",
|
|
675
|
-
block: { id: value2.id, type: value2.type, definition: value2.definition },
|
|
676
|
-
extra: {
|
|
677
|
-
parentBlockId: block.id,
|
|
678
|
-
parentBlockType: block.type,
|
|
679
|
-
slotKey: key
|
|
680
|
-
}
|
|
681
|
-
});
|
|
682
|
-
return [];
|
|
683
|
-
}
|
|
684
|
-
});
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
return (block) => {
|
|
688
|
-
const el = document.createElement(name);
|
|
689
|
-
el.setAttribute("data-block-id", block.id);
|
|
690
|
-
el.setAttribute("data-block-type", block.type);
|
|
691
|
-
Object.entries(block.props).forEach(([key, value]) => {
|
|
692
|
-
el[key] = value;
|
|
693
|
-
});
|
|
694
|
-
el.replaceChildren(...renderSlots(block.slots, block));
|
|
695
|
-
attachEmptyTracking(el);
|
|
696
|
-
return el;
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
const stubDefinitionCache = /* @__PURE__ */ new Map();
|
|
700
|
-
function createStubDefinition(name) {
|
|
701
|
-
const cached = stubDefinitionCache.get(name);
|
|
702
|
-
if (cached) return cached;
|
|
703
|
-
const stub = {
|
|
704
|
-
name,
|
|
705
|
-
group: "internal",
|
|
706
|
-
schema: {},
|
|
707
|
-
initialValue: { props: {}, slots: {} },
|
|
708
|
-
__stub: true,
|
|
709
|
-
render() {
|
|
710
|
-
const el = document.createElement("div");
|
|
711
|
-
el.dataset.stubBlock = name;
|
|
712
|
-
if (isEditorPreview()) {
|
|
713
|
-
el.textContent = `Block definition not found: ${name}`;
|
|
714
|
-
} else {
|
|
715
|
-
el.style.display = "none";
|
|
716
|
-
}
|
|
717
|
-
return el;
|
|
718
|
-
}
|
|
719
|
-
};
|
|
720
|
-
stubDefinitionCache.set(name, stub);
|
|
721
|
-
reportBlockWarning(`Block definition '${name}' not found`, {
|
|
722
|
-
site: "block.createStubDefinition",
|
|
723
|
-
block: { id: "(none)", type: name }
|
|
724
|
-
});
|
|
725
|
-
console.warn(
|
|
726
|
-
`[juo/blocks] Block definition '${name}' not found. This block may have been removed or renamed. Rendering a hidden stub.`
|
|
727
|
-
);
|
|
728
|
-
return stub;
|
|
729
|
-
}
|
|
730
|
-
function isStubDefinition(definition) {
|
|
731
|
-
return definition.__stub === true;
|
|
732
|
-
}
|
|
733
|
-
function backfillInstanceDefaults(block) {
|
|
734
|
-
if (Object.keys(block.props ?? {}).length > 0) return false;
|
|
735
|
-
if (Object.keys(block.slots ?? {}).length > 0) return false;
|
|
736
|
-
if (isStubDefinition(block.definition)) return false;
|
|
737
|
-
let defaults;
|
|
738
|
-
try {
|
|
739
|
-
const iv = block.definition.initialValue;
|
|
740
|
-
defaults = (typeof iv === "function" ? iv() : iv) ?? {};
|
|
741
|
-
} catch (error) {
|
|
742
|
-
reportBlockError(error, {
|
|
743
|
-
site: "block.backfillInstanceDefaults",
|
|
744
|
-
block: { id: block.id, type: block.type, definition: block.definition }
|
|
745
|
-
});
|
|
746
|
-
return false;
|
|
747
|
-
}
|
|
748
|
-
const propsDefault = defaults.props ?? {};
|
|
749
|
-
const slotsDefault = defaults.slots ?? {};
|
|
750
|
-
const hasProps = Object.keys(propsDefault).length > 0;
|
|
751
|
-
const hasSlots = Object.keys(slotsDefault).length > 0;
|
|
752
|
-
if (!hasProps && !hasSlots) return false;
|
|
753
|
-
if (hasProps) Object.assign(block.props, propsDefault);
|
|
754
|
-
if (hasSlots) Object.assign(block.slots, slotsDefault);
|
|
755
|
-
return true;
|
|
756
|
-
}
|
|
757
|
-
function getDefinitionByName(name) {
|
|
758
|
-
const definition = blockDefinitions.get(name);
|
|
759
|
-
if (definition != null) {
|
|
760
|
-
return definition;
|
|
761
|
-
}
|
|
762
|
-
return createStubDefinition(name);
|
|
763
|
-
}
|
|
764
|
-
function createBlockInstance(name, opts) {
|
|
765
|
-
const initialValue = (() => {
|
|
766
|
-
const value = getDefinitionByName(name).initialValue ?? {};
|
|
767
|
-
if (typeof value === "function") {
|
|
768
|
-
return value();
|
|
769
|
-
}
|
|
770
|
-
return value;
|
|
771
|
-
})();
|
|
772
|
-
if ((opts == null ? void 0 : opts.props) == null && initialValue == null) {
|
|
773
|
-
const error = new Error(
|
|
774
|
-
`Block '${name}' cannot be created without value in runtime mode`
|
|
775
|
-
);
|
|
776
|
-
reportBlockError(error, {
|
|
777
|
-
site: "block.createBlockInstance",
|
|
778
|
-
block: { id: "(none)", type: name }
|
|
779
|
-
});
|
|
780
|
-
throw error;
|
|
781
|
-
}
|
|
782
|
-
const slots = {
|
|
783
|
-
...initialValue.slots,
|
|
784
|
-
...(opts == null ? void 0 : opts.slots) ?? {}
|
|
785
|
-
};
|
|
786
|
-
const props = {
|
|
787
|
-
...initialValue.props ?? {},
|
|
788
|
-
...(opts == null ? void 0 : opts.props) ?? {}
|
|
789
|
-
};
|
|
790
|
-
return {
|
|
791
|
-
// TODO: This should be unique
|
|
792
|
-
id: (opts == null ? void 0 : opts.id) ?? Math.round(1e3 * Math.random()).toString(10),
|
|
793
|
-
type: name,
|
|
794
|
-
props,
|
|
795
|
-
slots,
|
|
796
|
-
get definition() {
|
|
797
|
-
return getDefinitionByName(name);
|
|
798
|
-
}
|
|
799
|
-
};
|
|
800
|
-
}
|
|
801
|
-
function createBlockInstanceFromObject(input) {
|
|
802
|
-
const { id, type, props, slots } = input;
|
|
803
|
-
return createBlockInstance(type, {
|
|
804
|
-
props,
|
|
805
|
-
slots: Object.fromEntries(
|
|
806
|
-
Object.entries(slots).map(([key, value]) => [
|
|
807
|
-
key,
|
|
808
|
-
(Array.isArray(value) ? value : [value]).map(
|
|
809
|
-
(child) => createBlockInstanceFromObject(child)
|
|
810
|
-
)
|
|
811
|
-
])
|
|
812
|
-
),
|
|
813
|
-
id
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
function createBlockInstanceFromJSON(input) {
|
|
817
|
-
try {
|
|
818
|
-
return createBlockInstanceFromObject(JSON.parse(input));
|
|
819
|
-
} catch (error) {
|
|
820
|
-
reportBlockError(error, {
|
|
821
|
-
site: "block.createBlockInstanceFromJSON",
|
|
822
|
-
extra: { inputLength: input.length }
|
|
823
|
-
});
|
|
824
|
-
throw error;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
4
|
+
import { e as createContext, d, f as createBlockInstanceFromObject, g as createBlockInstance, h as getDefinedBlocks, j as serializeBlocks, o as onRegisterBlock, E, k as w, r as registerBlock, l as defineBlock, s as subscribeContext } from "./block-B6s9jL7l.js";
|
|
5
|
+
import { reportBlockError } from "./observability.js";
|
|
6
|
+
import { c as createEditorBridge, v as createSelectBlockMessage } from "./bridge-r7Yk8fjY.js";
|
|
827
7
|
const DEFAULT_GLOBAL_STYLES = {
|
|
828
8
|
volume: "comfort",
|
|
829
9
|
style: "ghost",
|
|
@@ -906,6 +86,20 @@ function createThemeState(deps) {
|
|
|
906
86
|
function setGlobalStyles(styles) {
|
|
907
87
|
globalStyles.value = styles;
|
|
908
88
|
}
|
|
89
|
+
function setInstanceTranslationOverride(blockId, key, value) {
|
|
90
|
+
const current = catalogs.value;
|
|
91
|
+
if (current == null) return;
|
|
92
|
+
catalogs.value = {
|
|
93
|
+
...current,
|
|
94
|
+
blocks: {
|
|
95
|
+
...current.blocks,
|
|
96
|
+
overrides: {
|
|
97
|
+
...current.blocks.overrides,
|
|
98
|
+
[blockId]: { ...current.blocks.overrides[blockId], [key]: value }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
909
103
|
async function collectBlockDefaults(loc) {
|
|
910
104
|
const nextDefaults = {};
|
|
911
105
|
const nextModes = {};
|
|
@@ -947,12 +141,12 @@ function createThemeState(deps) {
|
|
|
947
141
|
};
|
|
948
142
|
locale.value = nextLocale;
|
|
949
143
|
}
|
|
950
|
-
async function resolve(surface, path) {
|
|
951
|
-
var _a2, _b, _c, _d;
|
|
144
|
+
async function resolve(surface, path, params) {
|
|
145
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h;
|
|
952
146
|
surfaces[surface].blocks.value = [];
|
|
953
147
|
const stored = await deps.resolve(surface, path);
|
|
954
148
|
if (stored != null) {
|
|
955
|
-
|
|
149
|
+
const instances = stored.blocks.flatMap((block) => {
|
|
956
150
|
try {
|
|
957
151
|
return [createBlockInstanceFromObject(block)];
|
|
958
152
|
} catch (error) {
|
|
@@ -967,19 +161,56 @@ function createThemeState(deps) {
|
|
|
967
161
|
return [];
|
|
968
162
|
}
|
|
969
163
|
});
|
|
164
|
+
if (surface === "overlay") {
|
|
165
|
+
for (const instance of instances) {
|
|
166
|
+
if (typeof instance.type !== "string" || !instance.type.startsWith("overlay:")) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
try {
|
|
170
|
+
const canonical = createBlockInstance(instance.type);
|
|
171
|
+
instance.props = {
|
|
172
|
+
...instance.props ?? {},
|
|
173
|
+
layout: (_a2 = canonical.props) == null ? void 0 : _a2.layout,
|
|
174
|
+
canAbort: (_b = canonical.props) == null ? void 0 : _b.canAbort
|
|
175
|
+
};
|
|
176
|
+
} catch (error) {
|
|
177
|
+
reportBlockError(error, {
|
|
178
|
+
site: "theme-state.resolve.overlay-layout",
|
|
179
|
+
extra: { surface, path, blockType: instance.type }
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (params != null) {
|
|
185
|
+
for (const instance of instances) {
|
|
186
|
+
const content = (_c = instance.slots) == null ? void 0 : _c.content;
|
|
187
|
+
const child = Array.isArray(content) ? content[0] : void 0;
|
|
188
|
+
if (child != null) {
|
|
189
|
+
child.props = { ...child.props ?? {}, ...params };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
surfaces[surface].blocks.value = instances;
|
|
970
194
|
return stored;
|
|
971
195
|
}
|
|
972
|
-
const blockToUse = surface === "page" ? (
|
|
196
|
+
const blockToUse = surface === "page" ? (_e = (_d = deps.routerService) == null ? void 0 : _d.getPages().find((p) => p.path === path)) == null ? void 0 : _e.block : (_f = getDefinedBlocks().find((b) => b.name === path)) == null ? void 0 : _f.name;
|
|
973
197
|
if (blockToUse != null) {
|
|
974
198
|
const instance = createBlockInstance(blockToUse);
|
|
199
|
+
if (params != null) {
|
|
200
|
+
const content = (_g = instance.slots) == null ? void 0 : _g.content;
|
|
201
|
+
const child = Array.isArray(content) ? content[0] : void 0;
|
|
202
|
+
if (child != null) {
|
|
203
|
+
child.props = { ...child.props ?? {}, ...params };
|
|
204
|
+
}
|
|
205
|
+
}
|
|
975
206
|
surfaces[surface].blocks.value = [instance];
|
|
976
207
|
const serialized = serializeBlocks([instance]);
|
|
977
|
-
(
|
|
208
|
+
(_h = deps.upsertState) == null ? void 0 : _h.call(deps, surface, path, serialized);
|
|
978
209
|
return { blocks: serialized };
|
|
979
210
|
}
|
|
980
211
|
return { blocks: [] };
|
|
981
212
|
}
|
|
982
|
-
onRegisterBlock(async (
|
|
213
|
+
onRegisterBlock(async (_, block) => {
|
|
983
214
|
if (block.locales == null || catalogs.value == null) return;
|
|
984
215
|
const localeAtLoadStart = locale.value;
|
|
985
216
|
let file = null;
|
|
@@ -1015,6 +246,7 @@ function createThemeState(deps) {
|
|
|
1015
246
|
locales: { locale, catalogs, setLocale },
|
|
1016
247
|
globalStyles,
|
|
1017
248
|
setGlobalStyles,
|
|
249
|
+
setInstanceTranslationOverride,
|
|
1018
250
|
resolve
|
|
1019
251
|
};
|
|
1020
252
|
}
|
|
@@ -1071,7 +303,7 @@ function createTranslationService(locales, options = {}) {
|
|
|
1071
303
|
function getDefaultBlockForAction(actionType, actionConfig, blockId) {
|
|
1072
304
|
const blockName = `action:${actionType}`;
|
|
1073
305
|
const definedBlocks = getDefinedBlocks();
|
|
1074
|
-
const exists = definedBlocks.some((
|
|
306
|
+
const exists = definedBlocks.some((b) => b.name === blockName);
|
|
1075
307
|
if (!exists) {
|
|
1076
308
|
throw new Error(
|
|
1077
309
|
`No default block registered for action type "${actionType}". Expected a block named "${blockName}" to be registered in blocks-extensions.`
|
|
@@ -1081,7 +313,7 @@ function getDefaultBlockForAction(actionType, actionConfig, blockId) {
|
|
|
1081
313
|
}
|
|
1082
314
|
function hasDefaultBlockForAction(actionType) {
|
|
1083
315
|
const blockName = `action:${actionType}`;
|
|
1084
|
-
return getDefinedBlocks().some((
|
|
316
|
+
return getDefinedBlocks().some((b) => b.name === blockName);
|
|
1085
317
|
}
|
|
1086
318
|
const WorkflowServiceContext = createContext("services/workflow");
|
|
1087
319
|
function createWorkflowApiAdapter(sdk) {
|
|
@@ -1215,7 +447,7 @@ function createWorkflowService(deps) {
|
|
|
1215
447
|
outcome: null
|
|
1216
448
|
});
|
|
1217
449
|
if (editor.isEditorMode) {
|
|
1218
|
-
const displayStepId = isInitialResponse && previewStepId && ((_e = data.interactiveSteps) == null ? void 0 : _e.some((
|
|
450
|
+
const displayStepId = isInitialResponse && previewStepId && ((_e = data.interactiveSteps) == null ? void 0 : _e.some((s) => s.stepId === previewStepId)) ? previewStepId : currentStepId;
|
|
1219
451
|
const overlayBlocks = deps.themeState.overlay.blocks.value;
|
|
1220
452
|
const rootBlock = overlayBlocks[0];
|
|
1221
453
|
const stepSlot = displayStepId ? (_f = rootBlock == null ? void 0 : rootBlock.slots) == null ? void 0 : _f[displayStepId] : null;
|
|
@@ -1310,7 +542,7 @@ function createWorkflowService(deps) {
|
|
|
1310
542
|
const presets = {};
|
|
1311
543
|
const baseLabelFor = (step) => {
|
|
1312
544
|
var _a;
|
|
1313
|
-
return ((_a = getDefinedBlocks().find((
|
|
545
|
+
return ((_a = getDefinedBlocks().find((b) => b.name === `action:${step.actionType}`)) == null ? void 0 : _a.displayName) ?? step.stepId;
|
|
1314
546
|
};
|
|
1315
547
|
const totalCounts = /* @__PURE__ */ new Map();
|
|
1316
548
|
for (const step of allSteps) {
|
|
@@ -1622,46 +854,15 @@ if (typeof customElements !== "undefined" && !customElements.get("juo-workflow")
|
|
|
1622
854
|
customElements.define("juo-workflow", JuoWorkflowElement);
|
|
1623
855
|
}
|
|
1624
856
|
export {
|
|
1625
|
-
isEditorPreview as A,
|
|
1626
|
-
BlockWrapperEvent as B,
|
|
1627
|
-
ContextProvideEvent as C,
|
|
1628
857
|
DEFAULT_GLOBAL_STYLES as D,
|
|
1629
|
-
|
|
1630
|
-
isStubDefinition as F,
|
|
1631
|
-
onRegisterBlock as G,
|
|
1632
|
-
provideContext as H,
|
|
1633
|
-
serializeBlocks as I,
|
|
1634
|
-
subscribeContext as J,
|
|
1635
|
-
n as K,
|
|
1636
|
-
withWrapper as L,
|
|
1637
|
-
ContextRoot as M,
|
|
1638
|
-
SelectedBlockContext as S,
|
|
1639
|
-
ThemeStateContext as T,
|
|
858
|
+
TranslationContext as T,
|
|
1640
859
|
WorkflowServiceContext as W,
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
d,
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
createBlockInstanceFromObject as i,
|
|
1650
|
-
createCeRenderer as j,
|
|
1651
|
-
createSelectedBlock as k,
|
|
1652
|
-
createThemeState as l,
|
|
1653
|
-
createTranslationService as m,
|
|
1654
|
-
createWorkflowApiAdapter as n,
|
|
1655
|
-
createWorkflowService as o,
|
|
1656
|
-
defineBlock as p,
|
|
1657
|
-
defineBlockRuntime as q,
|
|
1658
|
-
registerBlock as r,
|
|
1659
|
-
getDefaultBlockForAction as s,
|
|
1660
|
-
getDefinedBlocks as t,
|
|
1661
|
-
u,
|
|
1662
|
-
hasDefaultBlockForAction as v,
|
|
1663
|
-
w,
|
|
1664
|
-
hasRenderedContent as x,
|
|
1665
|
-
indexOverrides as y,
|
|
1666
|
-
injectContext as z
|
|
860
|
+
ThemeStateContext as a,
|
|
861
|
+
createTranslationService as b,
|
|
862
|
+
createThemeState as c,
|
|
863
|
+
createWorkflowApiAdapter as d,
|
|
864
|
+
createWorkflowService as e,
|
|
865
|
+
getDefaultBlockForAction as g,
|
|
866
|
+
hasDefaultBlockForAction as h,
|
|
867
|
+
indexOverrides as i
|
|
1667
868
|
};
|