@juo/blocks 1.13.0-alpha.1 → 1.13.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-peABLAZZ.js → ExtensionRoot-2xTGTu3K.js} +3 -15
- package/dist/block.d.ts +0 -50
- package/dist/block.d.ts.map +1 -1
- package/dist/{bridge-r7Yk8fjY.js → bridge-w5KQ-czl.js} +25 -34
- package/dist/context.d.ts.map +1 -1
- package/dist/core.js +344 -1892
- package/dist/editor/bridge.d.ts +0 -7
- package/dist/editor/bridge.d.ts.map +1 -1
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/main.d.ts +1 -2
- package/dist/editor/main.d.ts.map +1 -1
- package/dist/editor/messages.d.ts +2 -13
- package/dist/editor/messages.d.ts.map +1 -1
- package/dist/editor.js +45 -64
- package/dist/flows/WorkflowService.d.ts +2 -0
- package/dist/flows/WorkflowService.d.ts.map +1 -1
- package/dist/{juo-workflow-DY4rd256.js → juo-workflow-BlG9CcAG.js} +887 -78
- package/dist/main.d.ts +1 -3
- package/dist/main.d.ts.map +1 -1
- package/dist/preact.js +1 -1
- package/dist/react.js +1 -1
- package/dist/services/customer/customerService.d.ts +2 -3
- package/dist/services/customer/customerService.d.ts.map +1 -1
- package/dist/services/customer/index.d.ts +0 -1
- package/dist/services/customer/index.d.ts.map +1 -1
- package/dist/services/customer/types.d.ts +1 -4
- package/dist/services/customer/types.d.ts.map +1 -1
- package/dist/services/index.d.ts +0 -3
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/login/index.d.ts +1 -3
- package/dist/services/login/index.d.ts.map +1 -1
- package/dist/services/login/loginService.d.ts +2 -6
- package/dist/services/login/loginService.d.ts.map +1 -1
- package/dist/services/orders/adapter.d.ts +0 -2
- package/dist/services/orders/adapter.d.ts.map +1 -1
- package/dist/services/orders/index.d.ts +1 -1
- package/dist/services/orders/index.d.ts.map +1 -1
- package/dist/services/product/adapter.d.ts +2 -27
- package/dist/services/product/adapter.d.ts.map +1 -1
- 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 +0 -68
- package/dist/services/product/types.d.ts.map +1 -1
- package/dist/services/subscription/adapter.d.ts +2 -58
- package/dist/services/subscription/adapter.d.ts.map +1 -1
- 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 +6 -1
- package/dist/services/subscription/subscriptionService.d.ts.map +1 -1
- package/dist/services/subscription/types.d.ts +9 -212
- package/dist/services/subscription/types.d.ts.map +1 -1
- package/dist/theme-state.d.ts +1 -2
- package/dist/theme-state.d.ts.map +1 -1
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/vue/block.d.ts.map +1 -1
- package/dist/vue.js +4 -25
- package/dist/web-components/ExtensionRoot.d.ts +0 -1
- package/dist/web-components/ExtensionRoot.d.ts.map +1 -1
- package/dist/web-components-editor.js +3 -4
- package/dist/web-components-runtime.js +2 -3
- package/package.json +1 -1
- package/dist/block-B6s9jL7l.js +0 -966
- package/dist/block.devtools.test.d.ts +0 -2
- package/dist/block.devtools.test.d.ts.map +0 -1
- package/dist/context.devtools.test.d.ts +0 -2
- package/dist/context.devtools.test.d.ts.map +0 -1
- package/dist/devtools/env.d.ts +0 -3
- package/dist/devtools/env.d.ts.map +0 -1
- package/dist/devtools/hook.d.ts +0 -35
- package/dist/devtools/hook.d.ts.map +0 -1
- package/dist/devtools/index.d.ts +0 -4
- package/dist/devtools/index.d.ts.map +0 -1
- package/dist/devtools/protocol.d.ts +0 -91
- package/dist/devtools/protocol.d.ts.map +0 -1
- package/dist/devtools.js +0 -44
- package/dist/editor/messages.test.d.ts +0 -2
- package/dist/editor/messages.test.d.ts.map +0 -1
- package/dist/editor/overlays.d.ts +0 -14
- package/dist/editor/overlays.d.ts.map +0 -1
- package/dist/editor/overlays.test.d.ts +0 -2
- package/dist/editor/overlays.test.d.ts.map +0 -1
- package/dist/overlay-wrapper.d.ts +0 -69
- package/dist/overlay-wrapper.d.ts.map +0 -1
- package/dist/overlay-wrapper.test.d.ts +0 -2
- package/dist/overlay-wrapper.test.d.ts.map +0 -1
- package/dist/overlays/OverlayService.d.ts +0 -34
- package/dist/overlays/OverlayService.d.ts.map +0 -1
- package/dist/overlays/OverlayService.test.d.ts +0 -2
- package/dist/overlays/OverlayService.test.d.ts.map +0 -1
- package/dist/registry.devtools.test.d.ts +0 -2
- package/dist/registry.devtools.test.d.ts.map +0 -1
- package/dist/services/customer/adapter.d.ts +0 -8
- package/dist/services/customer/adapter.d.ts.map +0 -1
- package/dist/services/login/adapter.d.ts +0 -32
- package/dist/services/login/adapter.d.ts.map +0 -1
- package/dist/services/order/adapter.d.ts +0 -9
- package/dist/services/order/adapter.d.ts.map +0 -1
- package/dist/services/order/index.d.ts +0 -5
- package/dist/services/order/index.d.ts.map +0 -1
- package/dist/services/order/orderService.d.ts +0 -7
- package/dist/services/order/orderService.d.ts.map +0 -1
- package/dist/services/order/types.d.ts +0 -21
- package/dist/services/order/types.d.ts.map +0 -1
- package/dist/services/product/adapter.test.d.ts +0 -2
- package/dist/services/product/adapter.test.d.ts.map +0 -1
- package/dist/services/schedules/adapter.d.ts +0 -47
- package/dist/services/schedules/adapter.d.ts.map +0 -1
- package/dist/services/schedules/adapter.test.d.ts +0 -2
- package/dist/services/schedules/adapter.test.d.ts.map +0 -1
- package/dist/services/schedules/index.d.ts +0 -5
- package/dist/services/schedules/index.d.ts.map +0 -1
- package/dist/services/schedules/schedulesService.d.ts +0 -11
- package/dist/services/schedules/schedulesService.d.ts.map +0 -1
- package/dist/services/schedules/schedulesService.test.d.ts +0 -2
- package/dist/services/schedules/schedulesService.test.d.ts.map +0 -1
- package/dist/services/schedules/types.d.ts +0 -101
- package/dist/services/schedules/types.d.ts.map +0 -1
- package/dist/services/settings/index.d.ts +0 -3
- package/dist/services/settings/index.d.ts.map +0 -1
- package/dist/services/settings/settingsService.d.ts +0 -7
- package/dist/services/settings/settingsService.d.ts.map +0 -1
- package/dist/services/settings/settingsService.test.d.ts +0 -2
- package/dist/services/settings/settingsService.test.d.ts.map +0 -1
- package/dist/services/settings/types.d.ts +0 -35
- package/dist/services/settings/types.d.ts.map +0 -1
- package/dist/services/shop/index.d.ts +0 -3
- package/dist/services/shop/index.d.ts.map +0 -1
- package/dist/services/shop/shopService.d.ts +0 -12
- package/dist/services/shop/shopService.d.ts.map +0 -1
- package/dist/services/shop/shopService.test.d.ts +0 -2
- package/dist/services/shop/shopService.test.d.ts.map +0 -1
- package/dist/services/shop/types.d.ts +0 -7
- package/dist/services/shop/types.d.ts.map +0 -1
- package/dist/services/subscription/adapter.test.d.ts +0 -2
- package/dist/services/subscription/adapter.test.d.ts.map +0 -1
- package/dist/services/subscription/types.test.d.ts +0 -2
- package/dist/services/subscription/types.test.d.ts.map +0 -1
- package/dist/theme-state.params.test.d.ts +0 -2
- package/dist/theme-state.params.test.d.ts.map +0 -1
- package/dist/theme-state.translations.test.d.ts +0 -2
- package/dist/theme-state.translations.test.d.ts.map +0 -1
|
@@ -1,9 +1,829 @@
|
|
|
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
|
-
|
|
4
|
+
import { reportBlockError, reportBlockWarning } from "./observability.js";
|
|
5
|
+
import { a as createEditorBridge, e as createSelectBlockMessage } from "./bridge-w5KQ-czl.js";
|
|
6
|
+
const createContext = (key) => key;
|
|
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
|
+
}
|
|
7
827
|
const DEFAULT_GLOBAL_STYLES = {
|
|
8
828
|
volume: "comfort",
|
|
9
829
|
style: "ghost",
|
|
@@ -86,20 +906,6 @@ function createThemeState(deps) {
|
|
|
86
906
|
function setGlobalStyles(styles) {
|
|
87
907
|
globalStyles.value = styles;
|
|
88
908
|
}
|
|
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
|
-
}
|
|
103
909
|
async function collectBlockDefaults(loc) {
|
|
104
910
|
const nextDefaults = {};
|
|
105
911
|
const nextModes = {};
|
|
@@ -141,12 +947,12 @@ function createThemeState(deps) {
|
|
|
141
947
|
};
|
|
142
948
|
locale.value = nextLocale;
|
|
143
949
|
}
|
|
144
|
-
async function resolve(surface, path
|
|
145
|
-
var _a2, _b, _c, _d
|
|
950
|
+
async function resolve(surface, path) {
|
|
951
|
+
var _a2, _b, _c, _d;
|
|
146
952
|
surfaces[surface].blocks.value = [];
|
|
147
953
|
const stored = await deps.resolve(surface, path);
|
|
148
954
|
if (stored != null) {
|
|
149
|
-
|
|
955
|
+
surfaces[surface].blocks.value = stored.blocks.flatMap((block) => {
|
|
150
956
|
try {
|
|
151
957
|
return [createBlockInstanceFromObject(block)];
|
|
152
958
|
} catch (error) {
|
|
@@ -161,56 +967,19 @@ function createThemeState(deps) {
|
|
|
161
967
|
return [];
|
|
162
968
|
}
|
|
163
969
|
});
|
|
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;
|
|
194
970
|
return stored;
|
|
195
971
|
}
|
|
196
|
-
const blockToUse = surface === "page" ? (
|
|
972
|
+
const blockToUse = surface === "page" ? (_b = (_a2 = deps.routerService) == null ? void 0 : _a2.getPages().find((p2) => p2.path === path)) == null ? void 0 : _b.block : (_c = getDefinedBlocks().find((b2) => b2.name === path)) == null ? void 0 : _c.name;
|
|
197
973
|
if (blockToUse != null) {
|
|
198
974
|
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
|
-
}
|
|
206
975
|
surfaces[surface].blocks.value = [instance];
|
|
207
976
|
const serialized = serializeBlocks([instance]);
|
|
208
|
-
(
|
|
977
|
+
(_d = deps.upsertState) == null ? void 0 : _d.call(deps, surface, path, serialized);
|
|
209
978
|
return { blocks: serialized };
|
|
210
979
|
}
|
|
211
980
|
return { blocks: [] };
|
|
212
981
|
}
|
|
213
|
-
onRegisterBlock(async (
|
|
982
|
+
onRegisterBlock(async (_2, block) => {
|
|
214
983
|
if (block.locales == null || catalogs.value == null) return;
|
|
215
984
|
const localeAtLoadStart = locale.value;
|
|
216
985
|
let file = null;
|
|
@@ -246,7 +1015,6 @@ function createThemeState(deps) {
|
|
|
246
1015
|
locales: { locale, catalogs, setLocale },
|
|
247
1016
|
globalStyles,
|
|
248
1017
|
setGlobalStyles,
|
|
249
|
-
setInstanceTranslationOverride,
|
|
250
1018
|
resolve
|
|
251
1019
|
};
|
|
252
1020
|
}
|
|
@@ -303,7 +1071,7 @@ function createTranslationService(locales, options = {}) {
|
|
|
303
1071
|
function getDefaultBlockForAction(actionType, actionConfig, blockId) {
|
|
304
1072
|
const blockName = `action:${actionType}`;
|
|
305
1073
|
const definedBlocks = getDefinedBlocks();
|
|
306
|
-
const exists = definedBlocks.some((
|
|
1074
|
+
const exists = definedBlocks.some((b2) => b2.name === blockName);
|
|
307
1075
|
if (!exists) {
|
|
308
1076
|
throw new Error(
|
|
309
1077
|
`No default block registered for action type "${actionType}". Expected a block named "${blockName}" to be registered in blocks-extensions.`
|
|
@@ -313,9 +1081,13 @@ function getDefaultBlockForAction(actionType, actionConfig, blockId) {
|
|
|
313
1081
|
}
|
|
314
1082
|
function hasDefaultBlockForAction(actionType) {
|
|
315
1083
|
const blockName = `action:${actionType}`;
|
|
316
|
-
return getDefinedBlocks().some((
|
|
1084
|
+
return getDefinedBlocks().some((b2) => b2.name === blockName);
|
|
317
1085
|
}
|
|
318
1086
|
const WorkflowServiceContext = createContext("services/workflow");
|
|
1087
|
+
const RUN_SCOPED_RESET = {
|
|
1088
|
+
firstPollReason: null,
|
|
1089
|
+
feedbackCollected: false
|
|
1090
|
+
};
|
|
319
1091
|
function createWorkflowApiAdapter(sdk) {
|
|
320
1092
|
return {
|
|
321
1093
|
async start(flowType, context, workflowId, dryRun) {
|
|
@@ -379,7 +1151,7 @@ function createWorkflowService(deps) {
|
|
|
379
1151
|
outcome: null,
|
|
380
1152
|
completionData: null,
|
|
381
1153
|
dryRun: null,
|
|
382
|
-
|
|
1154
|
+
...RUN_SCOPED_RESET
|
|
383
1155
|
});
|
|
384
1156
|
const _backendInteractionId = d(null);
|
|
385
1157
|
const _registeredRootBlocks = /* @__PURE__ */ new Set();
|
|
@@ -447,7 +1219,7 @@ function createWorkflowService(deps) {
|
|
|
447
1219
|
outcome: null
|
|
448
1220
|
});
|
|
449
1221
|
if (editor.isEditorMode) {
|
|
450
|
-
const displayStepId = isInitialResponse && previewStepId && ((_e = data.interactiveSteps) == null ? void 0 : _e.some((
|
|
1222
|
+
const displayStepId = isInitialResponse && previewStepId && ((_e = data.interactiveSteps) == null ? void 0 : _e.some((s2) => s2.stepId === previewStepId)) ? previewStepId : currentStepId;
|
|
451
1223
|
const overlayBlocks = deps.themeState.overlay.blocks.value;
|
|
452
1224
|
const rootBlock = overlayBlocks[0];
|
|
453
1225
|
const stepSlot = displayStepId ? (_f = rootBlock == null ? void 0 : rootBlock.slots) == null ? void 0 : _f[displayStepId] : null;
|
|
@@ -490,7 +1262,7 @@ function createWorkflowService(deps) {
|
|
|
490
1262
|
invalidatedResources: [],
|
|
491
1263
|
outcome: null,
|
|
492
1264
|
completionData: null,
|
|
493
|
-
|
|
1265
|
+
...RUN_SCOPED_RESET
|
|
494
1266
|
});
|
|
495
1267
|
}
|
|
496
1268
|
}
|
|
@@ -542,7 +1314,7 @@ function createWorkflowService(deps) {
|
|
|
542
1314
|
const presets = {};
|
|
543
1315
|
const baseLabelFor = (step) => {
|
|
544
1316
|
var _a;
|
|
545
|
-
return ((_a = getDefinedBlocks().find((
|
|
1317
|
+
return ((_a = getDefinedBlocks().find((b2) => b2.name === `action:${step.actionType}`)) == null ? void 0 : _a.displayName) ?? step.stepId;
|
|
546
1318
|
};
|
|
547
1319
|
const totalCounts = /* @__PURE__ */ new Map();
|
|
548
1320
|
for (const step of allSteps) {
|
|
@@ -643,7 +1415,7 @@ function createWorkflowService(deps) {
|
|
|
643
1415
|
flowParams: context,
|
|
644
1416
|
flowType,
|
|
645
1417
|
dryRun: isDryRun,
|
|
646
|
-
|
|
1418
|
+
...RUN_SCOPED_RESET
|
|
647
1419
|
});
|
|
648
1420
|
try {
|
|
649
1421
|
const data = await api.start(
|
|
@@ -696,6 +1468,12 @@ function createWorkflowService(deps) {
|
|
|
696
1468
|
updateState({ firstPollReason: reason });
|
|
697
1469
|
}
|
|
698
1470
|
}
|
|
1471
|
+
if (!_state.value.feedbackCollected && currentInteraction2.actionType === "collect_feedback" && responseType === "submitted") {
|
|
1472
|
+
const feedback = responseData == null ? void 0 : responseData.feedback;
|
|
1473
|
+
if (typeof feedback === "string" && feedback.trim().length > 0) {
|
|
1474
|
+
updateState({ feedbackCollected: true });
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
699
1477
|
handleFlowResponse(data);
|
|
700
1478
|
} catch (error) {
|
|
701
1479
|
handleError(error);
|
|
@@ -748,7 +1526,7 @@ function createWorkflowService(deps) {
|
|
|
748
1526
|
invalidatedResources: [],
|
|
749
1527
|
outcome: null,
|
|
750
1528
|
completionData: null,
|
|
751
|
-
|
|
1529
|
+
...RUN_SCOPED_RESET
|
|
752
1530
|
});
|
|
753
1531
|
},
|
|
754
1532
|
async refresh() {
|
|
@@ -854,15 +1632,46 @@ if (typeof customElements !== "undefined" && !customElements.get("juo-workflow")
|
|
|
854
1632
|
customElements.define("juo-workflow", JuoWorkflowElement);
|
|
855
1633
|
}
|
|
856
1634
|
export {
|
|
1635
|
+
isEditorPreview as A,
|
|
1636
|
+
BlockWrapperEvent as B,
|
|
1637
|
+
ContextProvideEvent as C,
|
|
857
1638
|
DEFAULT_GLOBAL_STYLES as D,
|
|
858
|
-
|
|
1639
|
+
E,
|
|
1640
|
+
isStubDefinition as F,
|
|
1641
|
+
onRegisterBlock as G,
|
|
1642
|
+
provideContext as H,
|
|
1643
|
+
serializeBlocks as I,
|
|
1644
|
+
subscribeContext as J,
|
|
1645
|
+
n as K,
|
|
1646
|
+
withWrapper as L,
|
|
1647
|
+
ContextRoot as M,
|
|
1648
|
+
SelectedBlockContext as S,
|
|
1649
|
+
ThemeStateContext as T,
|
|
859
1650
|
WorkflowServiceContext as W,
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1651
|
+
ContextRequestEvent as a,
|
|
1652
|
+
TranslationContext as b,
|
|
1653
|
+
createContext as c,
|
|
1654
|
+
d,
|
|
1655
|
+
attachEmptyTracking as e,
|
|
1656
|
+
backfillInstanceDefaults as f,
|
|
1657
|
+
createBlockInstance as g,
|
|
1658
|
+
createBlockInstanceFromJSON as h,
|
|
1659
|
+
createBlockInstanceFromObject as i,
|
|
1660
|
+
createCeRenderer as j,
|
|
1661
|
+
createSelectedBlock as k,
|
|
1662
|
+
createThemeState as l,
|
|
1663
|
+
createTranslationService as m,
|
|
1664
|
+
createWorkflowApiAdapter as n,
|
|
1665
|
+
createWorkflowService as o,
|
|
1666
|
+
defineBlock as p,
|
|
1667
|
+
defineBlockRuntime as q,
|
|
1668
|
+
registerBlock as r,
|
|
1669
|
+
getDefaultBlockForAction as s,
|
|
1670
|
+
getDefinedBlocks as t,
|
|
1671
|
+
u,
|
|
1672
|
+
hasDefaultBlockForAction as v,
|
|
1673
|
+
w,
|
|
1674
|
+
hasRenderedContent as x,
|
|
1675
|
+
indexOverrides as y,
|
|
1676
|
+
injectContext as z
|
|
868
1677
|
};
|