@juo/blocks 1.0.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-CZyBNJZY.js +159 -0
- package/dist/block-VhmfGB3N.js +51 -0
- package/dist/block.d.ts +96 -0
- package/dist/block.d.ts.map +1 -0
- package/dist/bridge-DQsM97cH.js +490 -0
- package/dist/context.d.ts +76 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.test.d.ts +2 -0
- package/dist/context.test.d.ts.map +1 -0
- package/dist/core.js +1163 -0
- package/dist/editor/bridge.d.ts +75 -0
- package/dist/editor/bridge.d.ts.map +1 -0
- package/dist/editor/bridge.test.d.ts +2 -0
- package/dist/editor/bridge.test.d.ts.map +1 -0
- package/dist/editor/components.d.ts +31 -0
- package/dist/editor/components.d.ts.map +1 -0
- package/dist/editor/handler.d.ts +10 -0
- package/dist/editor/handler.d.ts.map +1 -0
- package/dist/editor/main.d.ts +17 -0
- package/dist/editor/main.d.ts.map +1 -0
- package/dist/editor/messages.d.ts +233 -0
- package/dist/editor/messages.d.ts.map +1 -0
- package/dist/editor.js +711 -0
- package/dist/flows/MockWorkflowApiAdapter.d.ts +13 -0
- package/dist/flows/MockWorkflowApiAdapter.d.ts.map +1 -0
- package/dist/flows/WorkflowService.d.ts +175 -0
- package/dist/flows/WorkflowService.d.ts.map +1 -0
- package/dist/flows/__tests__/WorkflowService.test.d.ts +2 -0
- package/dist/flows/__tests__/WorkflowService.test.d.ts.map +1 -0
- package/dist/flows/__tests__/defaults.test.d.ts +2 -0
- package/dist/flows/__tests__/defaults.test.d.ts.map +1 -0
- package/dist/flows/__tests__/juo-workflow.test.d.ts +2 -0
- package/dist/flows/__tests__/juo-workflow.test.d.ts.map +1 -0
- package/dist/flows/__tests__/overlay-behavior.test.d.ts +2 -0
- package/dist/flows/__tests__/overlay-behavior.test.d.ts.map +1 -0
- package/dist/flows/__tests__/theme-state-surfaces.test.d.ts +2 -0
- package/dist/flows/__tests__/theme-state-surfaces.test.d.ts.map +1 -0
- package/dist/flows/defaults.d.ts +15 -0
- package/dist/flows/defaults.d.ts.map +1 -0
- package/dist/flows/index.d.ts +4 -0
- package/dist/flows/index.d.ts.map +1 -0
- package/dist/flows/juo-workflow.d.ts +48 -0
- package/dist/flows/juo-workflow.d.ts.map +1 -0
- package/dist/juo-workflow-RSrOuKUH.js +591 -0
- package/dist/main.d.ts +11 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/preact/block.d.ts +21 -0
- package/dist/preact/block.d.ts.map +1 -0
- package/dist/preact/block.test.d.ts +2 -0
- package/dist/preact/block.test.d.ts.map +1 -0
- package/dist/preact/bridge.d.ts +11 -0
- package/dist/preact/bridge.d.ts.map +1 -0
- package/dist/preact/context.d.ts +31 -0
- package/dist/preact/context.d.ts.map +1 -0
- package/dist/preact/main.d.ts +11 -0
- package/dist/preact/main.d.ts.map +1 -0
- package/dist/preact/signals.d.ts +23 -0
- package/dist/preact/signals.d.ts.map +1 -0
- package/dist/preact.js +230 -0
- package/dist/react/block.d.ts +21 -0
- package/dist/react/block.d.ts.map +1 -0
- package/dist/react/block.test.d.ts +2 -0
- package/dist/react/block.test.d.ts.map +1 -0
- package/dist/react/bridge.d.ts +11 -0
- package/dist/react/bridge.d.ts.map +1 -0
- package/dist/react/context.d.ts +28 -0
- package/dist/react/context.d.ts.map +1 -0
- package/dist/react/main.d.ts +11 -0
- package/dist/react/main.d.ts.map +1 -0
- package/dist/react/signals.d.ts +23 -0
- package/dist/react/signals.d.ts.map +1 -0
- package/dist/react.js +205 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/login/index.d.ts +23 -0
- package/dist/services/login/index.d.ts.map +1 -0
- package/dist/services/login/loginService.d.ts +82 -0
- package/dist/services/login/loginService.d.ts.map +1 -0
- package/dist/services/product/adapter.d.ts +20 -0
- package/dist/services/product/adapter.d.ts.map +1 -0
- package/dist/services/product/index.d.ts +5 -0
- package/dist/services/product/index.d.ts.map +1 -0
- package/dist/services/product/productService.d.ts +12 -0
- package/dist/services/product/productService.d.ts.map +1 -0
- package/dist/services/product/types.d.ts +32 -0
- package/dist/services/product/types.d.ts.map +1 -0
- package/dist/services/subscription/adapter.d.ts +49 -0
- package/dist/services/subscription/adapter.d.ts.map +1 -0
- package/dist/services/subscription/index.d.ts +5 -0
- package/dist/services/subscription/index.d.ts.map +1 -0
- package/dist/services/subscription/list.d.ts +22 -0
- package/dist/services/subscription/list.d.ts.map +1 -0
- package/dist/services/subscription/store.d.ts +30 -0
- package/dist/services/subscription/store.d.ts.map +1 -0
- package/dist/services/subscription/subscriptionService.d.ts +12 -0
- package/dist/services/subscription/subscriptionService.d.ts.map +1 -0
- package/dist/services/subscription/types.d.ts +76 -0
- package/dist/services/subscription/types.d.ts.map +1 -0
- package/dist/shared/block.d.ts +17 -0
- package/dist/shared/block.d.ts.map +1 -0
- package/dist/shared/context.d.ts +16 -0
- package/dist/shared/context.d.ts.map +1 -0
- package/dist/shared/signals.d.ts +17 -0
- package/dist/shared/signals.d.ts.map +1 -0
- package/dist/state.d.ts +81 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/theme-state-BZplRS92.js +886 -0
- package/dist/theme-state.d.ts +85 -0
- package/dist/theme-state.d.ts.map +1 -0
- package/dist/theme-state.locales.test.d.ts +2 -0
- package/dist/theme-state.locales.test.d.ts.map +1 -0
- package/dist/translation.d.ts +14 -0
- package/dist/translation.d.ts.map +1 -0
- package/dist/translation.test.d.ts +2 -0
- package/dist/translation.test.d.ts.map +1 -0
- package/dist/utils/index.d.ts +32 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/login.d.ts +11 -0
- package/dist/utils/login.d.ts.map +1 -0
- package/dist/utils/uuid.d.ts +2 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/vue/block.d.ts +7 -0
- package/dist/vue/block.d.ts.map +1 -0
- package/dist/vue/bridge.d.ts +11 -0
- package/dist/vue/bridge.d.ts.map +1 -0
- package/dist/vue/context.d.ts +24 -0
- package/dist/vue/context.d.ts.map +1 -0
- package/dist/vue/main.d.ts +6 -0
- package/dist/vue/main.d.ts.map +1 -0
- package/dist/vue/signals.d.ts +5 -0
- package/dist/vue/signals.d.ts.map +1 -0
- package/dist/vue/target.d.ts +2 -0
- package/dist/vue/target.d.ts.map +1 -0
- package/dist/vue/transform.d.ts +2 -0
- package/dist/vue/transform.d.ts.map +1 -0
- package/dist/vue.js +254 -0
- package/dist/web-components/Block.d.ts +17 -0
- package/dist/web-components/Block.d.ts.map +1 -0
- package/dist/web-components/Block.test.d.ts +2 -0
- package/dist/web-components/Block.test.d.ts.map +1 -0
- package/dist/web-components/ExtensionRoot.d.ts +29 -0
- package/dist/web-components/ExtensionRoot.d.ts.map +1 -0
- package/dist/web-components/editor/InlineText.d.ts +29 -0
- package/dist/web-components/editor/InlineText.d.ts.map +1 -0
- package/dist/web-components/editor/main.d.ts +2 -0
- package/dist/web-components/editor/main.d.ts.map +1 -0
- package/dist/web-components/runtime/InlineText.d.ts +6 -0
- package/dist/web-components/runtime/InlineText.d.ts.map +1 -0
- package/dist/web-components/runtime/main.d.ts +2 -0
- package/dist/web-components/runtime/main.d.ts.map +1 -0
- package/dist/web-components-editor.js +183 -0
- package/dist/web-components-runtime.js +55 -0
- package/package.json +62 -0
|
@@ -0,0 +1,886 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
const createContext = (key) => key;
|
|
5
|
+
class ContextRequestEvent extends Event {
|
|
6
|
+
constructor(context, callback, subscribe) {
|
|
7
|
+
super("context-request", { bubbles: true, composed: true });
|
|
8
|
+
this.context = context;
|
|
9
|
+
this.callback = callback;
|
|
10
|
+
this.subscribe = subscribe;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
class ContextProvideEvent extends Event {
|
|
14
|
+
constructor(context, value, subscribe) {
|
|
15
|
+
super("context-provide", { bubbles: true, composed: true });
|
|
16
|
+
this.context = context;
|
|
17
|
+
this.value = value;
|
|
18
|
+
this.subscribe = subscribe;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function provideContext(target, context, init) {
|
|
22
|
+
console.log("context:provide", context, target);
|
|
23
|
+
const ev = new ContextProvideEvent(context, init);
|
|
24
|
+
target.dispatchEvent(ev);
|
|
25
|
+
}
|
|
26
|
+
function injectContext(target, context) {
|
|
27
|
+
let value = void 0;
|
|
28
|
+
console.log("context:inject", context, target);
|
|
29
|
+
const ev = new ContextRequestEvent(context, (received) => {
|
|
30
|
+
value = received;
|
|
31
|
+
});
|
|
32
|
+
target.dispatchEvent(ev);
|
|
33
|
+
if (value === void 0) {
|
|
34
|
+
throw new Error(`Context '${context}' not defined`);
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
function subscribeContext(target, context, callback) {
|
|
39
|
+
let unsubscribeFunction = null;
|
|
40
|
+
console.log("context:subscribe", context, target);
|
|
41
|
+
const protocolCallback = (value, unsubscribe) => {
|
|
42
|
+
if (unsubscribe) {
|
|
43
|
+
unsubscribeFunction = unsubscribe;
|
|
44
|
+
}
|
|
45
|
+
callback(value);
|
|
46
|
+
};
|
|
47
|
+
const ev = new ContextRequestEvent(context, protocolCallback, true);
|
|
48
|
+
target.dispatchEvent(ev);
|
|
49
|
+
return () => {
|
|
50
|
+
if (unsubscribeFunction) {
|
|
51
|
+
unsubscribeFunction();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
class ContextRoot extends HTMLElement {
|
|
56
|
+
constructor() {
|
|
57
|
+
super(...arguments);
|
|
58
|
+
__publicField(this, "store", /* @__PURE__ */ new Map());
|
|
59
|
+
__publicField(this, "callbacks", /* @__PURE__ */ new Map());
|
|
60
|
+
}
|
|
61
|
+
connectedCallback() {
|
|
62
|
+
this.addEventListener("context-provide", (ev) => {
|
|
63
|
+
ev.stopPropagation();
|
|
64
|
+
console.log("context-root:provide", ev.context, ev.value);
|
|
65
|
+
this.store.set(ev.context, ev.value);
|
|
66
|
+
const registeredCallbacks = this.callbacks.get(ev.context) ?? [];
|
|
67
|
+
console.log("callbacks", registeredCallbacks);
|
|
68
|
+
registeredCallbacks.forEach((cb) => {
|
|
69
|
+
const unsubscribe = () => {
|
|
70
|
+
const callbacks = this.callbacks.get(ev.context);
|
|
71
|
+
if (callbacks) {
|
|
72
|
+
const cbIndex = callbacks.indexOf(cb);
|
|
73
|
+
if (cbIndex > -1) {
|
|
74
|
+
callbacks.splice(cbIndex, 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
console.log("context-root:unsubscribed", ev.context);
|
|
78
|
+
};
|
|
79
|
+
cb(ev.value, unsubscribe);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
this.addEventListener("context-request", (ev) => {
|
|
83
|
+
ev.stopPropagation();
|
|
84
|
+
console.log("context-root:request", ev.context, ev);
|
|
85
|
+
const storedValue = this.store.get(ev.context);
|
|
86
|
+
if (ev.subscribe) {
|
|
87
|
+
let callbacks = this.callbacks.get(ev.context);
|
|
88
|
+
if (!callbacks) {
|
|
89
|
+
callbacks = [];
|
|
90
|
+
this.callbacks.set(ev.context, callbacks);
|
|
91
|
+
}
|
|
92
|
+
const unsubscribe = () => {
|
|
93
|
+
const currentCallbacks = this.callbacks.get(ev.context);
|
|
94
|
+
if (currentCallbacks) {
|
|
95
|
+
const index = currentCallbacks.indexOf(ev.callback);
|
|
96
|
+
if (index > -1) {
|
|
97
|
+
currentCallbacks.splice(index, 1);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
console.log("context-root:unsubscribed", ev.context);
|
|
101
|
+
};
|
|
102
|
+
callbacks.push(ev.callback);
|
|
103
|
+
if (storedValue !== void 0) {
|
|
104
|
+
ev.callback(storedValue, unsubscribe);
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
if (storedValue !== void 0) {
|
|
108
|
+
ev.callback(storedValue);
|
|
109
|
+
} else {
|
|
110
|
+
console.warn("Context not present in store: " + String(ev.context));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
console.log("context-root:ready");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
var i = Symbol.for("preact-signals");
|
|
118
|
+
function t() {
|
|
119
|
+
if (!(s > 1)) {
|
|
120
|
+
var i2, t2 = false;
|
|
121
|
+
while (void 0 !== h) {
|
|
122
|
+
var r = h;
|
|
123
|
+
h = void 0;
|
|
124
|
+
f++;
|
|
125
|
+
while (void 0 !== r) {
|
|
126
|
+
var o2 = r.o;
|
|
127
|
+
r.o = void 0;
|
|
128
|
+
r.f &= -3;
|
|
129
|
+
if (!(8 & r.f) && c(r)) try {
|
|
130
|
+
r.c();
|
|
131
|
+
} catch (r2) {
|
|
132
|
+
if (!t2) {
|
|
133
|
+
i2 = r2;
|
|
134
|
+
t2 = true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
r = o2;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
f = 0;
|
|
141
|
+
s--;
|
|
142
|
+
if (t2) throw i2;
|
|
143
|
+
} else s--;
|
|
144
|
+
}
|
|
145
|
+
var o = void 0;
|
|
146
|
+
function n(i2) {
|
|
147
|
+
var t2 = o;
|
|
148
|
+
o = void 0;
|
|
149
|
+
try {
|
|
150
|
+
return i2();
|
|
151
|
+
} finally {
|
|
152
|
+
o = t2;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
var h = void 0, s = 0, f = 0, v = 0;
|
|
156
|
+
function e(i2) {
|
|
157
|
+
if (void 0 !== o) {
|
|
158
|
+
var t2 = i2.n;
|
|
159
|
+
if (void 0 === t2 || t2.t !== o) {
|
|
160
|
+
t2 = { i: 0, S: i2, p: o.s, n: void 0, t: o, e: void 0, x: void 0, r: t2 };
|
|
161
|
+
if (void 0 !== o.s) o.s.n = t2;
|
|
162
|
+
o.s = t2;
|
|
163
|
+
i2.n = t2;
|
|
164
|
+
if (32 & o.f) i2.S(t2);
|
|
165
|
+
return t2;
|
|
166
|
+
} else if (-1 === t2.i) {
|
|
167
|
+
t2.i = 0;
|
|
168
|
+
if (void 0 !== t2.n) {
|
|
169
|
+
t2.n.p = t2.p;
|
|
170
|
+
if (void 0 !== t2.p) t2.p.n = t2.n;
|
|
171
|
+
t2.p = o.s;
|
|
172
|
+
t2.n = void 0;
|
|
173
|
+
o.s.n = t2;
|
|
174
|
+
o.s = t2;
|
|
175
|
+
}
|
|
176
|
+
return t2;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function u(i2, t2) {
|
|
181
|
+
this.v = i2;
|
|
182
|
+
this.i = 0;
|
|
183
|
+
this.n = void 0;
|
|
184
|
+
this.t = void 0;
|
|
185
|
+
this.W = null == t2 ? void 0 : t2.watched;
|
|
186
|
+
this.Z = null == t2 ? void 0 : t2.unwatched;
|
|
187
|
+
}
|
|
188
|
+
u.prototype.brand = i;
|
|
189
|
+
u.prototype.h = function() {
|
|
190
|
+
return true;
|
|
191
|
+
};
|
|
192
|
+
u.prototype.S = function(i2) {
|
|
193
|
+
var t2 = this, r = this.t;
|
|
194
|
+
if (r !== i2 && void 0 === i2.e) {
|
|
195
|
+
i2.x = r;
|
|
196
|
+
this.t = i2;
|
|
197
|
+
if (void 0 !== r) r.e = i2;
|
|
198
|
+
else n(function() {
|
|
199
|
+
var i3;
|
|
200
|
+
null == (i3 = t2.W) || i3.call(t2);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
u.prototype.U = function(i2) {
|
|
205
|
+
var t2 = this;
|
|
206
|
+
if (void 0 !== this.t) {
|
|
207
|
+
var r = i2.e, o2 = i2.x;
|
|
208
|
+
if (void 0 !== r) {
|
|
209
|
+
r.x = o2;
|
|
210
|
+
i2.e = void 0;
|
|
211
|
+
}
|
|
212
|
+
if (void 0 !== o2) {
|
|
213
|
+
o2.e = r;
|
|
214
|
+
i2.x = void 0;
|
|
215
|
+
}
|
|
216
|
+
if (i2 === this.t) {
|
|
217
|
+
this.t = o2;
|
|
218
|
+
if (void 0 === o2) n(function() {
|
|
219
|
+
var i3;
|
|
220
|
+
null == (i3 = t2.Z) || i3.call(t2);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
u.prototype.subscribe = function(i2) {
|
|
226
|
+
var t2 = this;
|
|
227
|
+
return E(function() {
|
|
228
|
+
var r = t2.value, n2 = o;
|
|
229
|
+
o = void 0;
|
|
230
|
+
try {
|
|
231
|
+
i2(r);
|
|
232
|
+
} finally {
|
|
233
|
+
o = n2;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
u.prototype.valueOf = function() {
|
|
238
|
+
return this.value;
|
|
239
|
+
};
|
|
240
|
+
u.prototype.toString = function() {
|
|
241
|
+
return this.value + "";
|
|
242
|
+
};
|
|
243
|
+
u.prototype.toJSON = function() {
|
|
244
|
+
return this.value;
|
|
245
|
+
};
|
|
246
|
+
u.prototype.peek = function() {
|
|
247
|
+
var i2 = o;
|
|
248
|
+
o = void 0;
|
|
249
|
+
try {
|
|
250
|
+
return this.value;
|
|
251
|
+
} finally {
|
|
252
|
+
o = i2;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
Object.defineProperty(u.prototype, "value", { get: function() {
|
|
256
|
+
var i2 = e(this);
|
|
257
|
+
if (void 0 !== i2) i2.i = this.i;
|
|
258
|
+
return this.v;
|
|
259
|
+
}, set: function(i2) {
|
|
260
|
+
if (i2 !== this.v) {
|
|
261
|
+
if (f > 100) throw new Error("Cycle detected");
|
|
262
|
+
this.v = i2;
|
|
263
|
+
this.i++;
|
|
264
|
+
v++;
|
|
265
|
+
s++;
|
|
266
|
+
try {
|
|
267
|
+
for (var r = this.t; void 0 !== r; r = r.x) r.t.N();
|
|
268
|
+
} finally {
|
|
269
|
+
t();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
} });
|
|
273
|
+
function d(i2, t2) {
|
|
274
|
+
return new u(i2, t2);
|
|
275
|
+
}
|
|
276
|
+
function c(i2) {
|
|
277
|
+
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;
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
function a(i2) {
|
|
281
|
+
for (var t2 = i2.s; void 0 !== t2; t2 = t2.n) {
|
|
282
|
+
var r = t2.S.n;
|
|
283
|
+
if (void 0 !== r) t2.r = r;
|
|
284
|
+
t2.S.n = t2;
|
|
285
|
+
t2.i = -1;
|
|
286
|
+
if (void 0 === t2.n) {
|
|
287
|
+
i2.s = t2;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function l(i2) {
|
|
293
|
+
var t2 = i2.s, r = void 0;
|
|
294
|
+
while (void 0 !== t2) {
|
|
295
|
+
var o2 = t2.p;
|
|
296
|
+
if (-1 === t2.i) {
|
|
297
|
+
t2.S.U(t2);
|
|
298
|
+
if (void 0 !== o2) o2.n = t2.n;
|
|
299
|
+
if (void 0 !== t2.n) t2.n.p = o2;
|
|
300
|
+
} else r = t2;
|
|
301
|
+
t2.S.n = t2.r;
|
|
302
|
+
if (void 0 !== t2.r) t2.r = void 0;
|
|
303
|
+
t2 = o2;
|
|
304
|
+
}
|
|
305
|
+
i2.s = r;
|
|
306
|
+
}
|
|
307
|
+
function y(i2, t2) {
|
|
308
|
+
u.call(this, void 0);
|
|
309
|
+
this.x = i2;
|
|
310
|
+
this.s = void 0;
|
|
311
|
+
this.g = v - 1;
|
|
312
|
+
this.f = 4;
|
|
313
|
+
this.W = null == t2 ? void 0 : t2.watched;
|
|
314
|
+
this.Z = null == t2 ? void 0 : t2.unwatched;
|
|
315
|
+
}
|
|
316
|
+
y.prototype = new u();
|
|
317
|
+
y.prototype.h = function() {
|
|
318
|
+
this.f &= -3;
|
|
319
|
+
if (1 & this.f) return false;
|
|
320
|
+
if (32 == (36 & this.f)) return true;
|
|
321
|
+
this.f &= -5;
|
|
322
|
+
if (this.g === v) return true;
|
|
323
|
+
this.g = v;
|
|
324
|
+
this.f |= 1;
|
|
325
|
+
if (this.i > 0 && !c(this)) {
|
|
326
|
+
this.f &= -2;
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
var i2 = o;
|
|
330
|
+
try {
|
|
331
|
+
a(this);
|
|
332
|
+
o = this;
|
|
333
|
+
var t2 = this.x();
|
|
334
|
+
if (16 & this.f || this.v !== t2 || 0 === this.i) {
|
|
335
|
+
this.v = t2;
|
|
336
|
+
this.f &= -17;
|
|
337
|
+
this.i++;
|
|
338
|
+
}
|
|
339
|
+
} catch (i3) {
|
|
340
|
+
this.v = i3;
|
|
341
|
+
this.f |= 16;
|
|
342
|
+
this.i++;
|
|
343
|
+
}
|
|
344
|
+
o = i2;
|
|
345
|
+
l(this);
|
|
346
|
+
this.f &= -2;
|
|
347
|
+
return true;
|
|
348
|
+
};
|
|
349
|
+
y.prototype.S = function(i2) {
|
|
350
|
+
if (void 0 === this.t) {
|
|
351
|
+
this.f |= 36;
|
|
352
|
+
for (var t2 = this.s; void 0 !== t2; t2 = t2.n) t2.S.S(t2);
|
|
353
|
+
}
|
|
354
|
+
u.prototype.S.call(this, i2);
|
|
355
|
+
};
|
|
356
|
+
y.prototype.U = function(i2) {
|
|
357
|
+
if (void 0 !== this.t) {
|
|
358
|
+
u.prototype.U.call(this, i2);
|
|
359
|
+
if (void 0 === this.t) {
|
|
360
|
+
this.f &= -33;
|
|
361
|
+
for (var t2 = this.s; void 0 !== t2; t2 = t2.n) t2.S.U(t2);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
y.prototype.N = function() {
|
|
366
|
+
if (!(2 & this.f)) {
|
|
367
|
+
this.f |= 6;
|
|
368
|
+
for (var i2 = this.t; void 0 !== i2; i2 = i2.x) i2.t.N();
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
Object.defineProperty(y.prototype, "value", { get: function() {
|
|
372
|
+
if (1 & this.f) throw new Error("Cycle detected");
|
|
373
|
+
var i2 = e(this);
|
|
374
|
+
this.h();
|
|
375
|
+
if (void 0 !== i2) i2.i = this.i;
|
|
376
|
+
if (16 & this.f) throw this.v;
|
|
377
|
+
return this.v;
|
|
378
|
+
} });
|
|
379
|
+
function w(i2, t2) {
|
|
380
|
+
return new y(i2, t2);
|
|
381
|
+
}
|
|
382
|
+
function _(i2) {
|
|
383
|
+
var r = i2.u;
|
|
384
|
+
i2.u = void 0;
|
|
385
|
+
if ("function" == typeof r) {
|
|
386
|
+
s++;
|
|
387
|
+
var n2 = o;
|
|
388
|
+
o = void 0;
|
|
389
|
+
try {
|
|
390
|
+
r();
|
|
391
|
+
} catch (t2) {
|
|
392
|
+
i2.f &= -2;
|
|
393
|
+
i2.f |= 8;
|
|
394
|
+
b(i2);
|
|
395
|
+
throw t2;
|
|
396
|
+
} finally {
|
|
397
|
+
o = n2;
|
|
398
|
+
t();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function b(i2) {
|
|
403
|
+
for (var t2 = i2.s; void 0 !== t2; t2 = t2.n) t2.S.U(t2);
|
|
404
|
+
i2.x = void 0;
|
|
405
|
+
i2.s = void 0;
|
|
406
|
+
_(i2);
|
|
407
|
+
}
|
|
408
|
+
function g(i2) {
|
|
409
|
+
if (o !== this) throw new Error("Out-of-order effect");
|
|
410
|
+
l(this);
|
|
411
|
+
o = i2;
|
|
412
|
+
this.f &= -2;
|
|
413
|
+
if (8 & this.f) b(this);
|
|
414
|
+
t();
|
|
415
|
+
}
|
|
416
|
+
function p(i2) {
|
|
417
|
+
this.x = i2;
|
|
418
|
+
this.u = void 0;
|
|
419
|
+
this.s = void 0;
|
|
420
|
+
this.o = void 0;
|
|
421
|
+
this.f = 32;
|
|
422
|
+
}
|
|
423
|
+
p.prototype.c = function() {
|
|
424
|
+
var i2 = this.S();
|
|
425
|
+
try {
|
|
426
|
+
if (8 & this.f) return;
|
|
427
|
+
if (void 0 === this.x) return;
|
|
428
|
+
var t2 = this.x();
|
|
429
|
+
if ("function" == typeof t2) this.u = t2;
|
|
430
|
+
} finally {
|
|
431
|
+
i2();
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
p.prototype.S = function() {
|
|
435
|
+
if (1 & this.f) throw new Error("Cycle detected");
|
|
436
|
+
this.f |= 1;
|
|
437
|
+
this.f &= -9;
|
|
438
|
+
_(this);
|
|
439
|
+
a(this);
|
|
440
|
+
s++;
|
|
441
|
+
var i2 = o;
|
|
442
|
+
o = this;
|
|
443
|
+
return g.bind(this, i2);
|
|
444
|
+
};
|
|
445
|
+
p.prototype.N = function() {
|
|
446
|
+
if (!(2 & this.f)) {
|
|
447
|
+
this.f |= 2;
|
|
448
|
+
this.o = h;
|
|
449
|
+
h = this;
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
p.prototype.d = function() {
|
|
453
|
+
this.f |= 8;
|
|
454
|
+
if (!(1 & this.f)) b(this);
|
|
455
|
+
};
|
|
456
|
+
p.prototype.dispose = function() {
|
|
457
|
+
this.d();
|
|
458
|
+
};
|
|
459
|
+
function E(i2) {
|
|
460
|
+
var t2 = new p(i2);
|
|
461
|
+
try {
|
|
462
|
+
t2.c();
|
|
463
|
+
} catch (i3) {
|
|
464
|
+
t2.d();
|
|
465
|
+
throw i3;
|
|
466
|
+
}
|
|
467
|
+
var r = t2.d.bind(t2);
|
|
468
|
+
r[Symbol.dispose] = r;
|
|
469
|
+
return r;
|
|
470
|
+
}
|
|
471
|
+
function serializeBlocks(blocks) {
|
|
472
|
+
return blocks.map((block) => serializeBlock(block));
|
|
473
|
+
}
|
|
474
|
+
function serializeBlock(block) {
|
|
475
|
+
return {
|
|
476
|
+
id: block.id,
|
|
477
|
+
type: block.type,
|
|
478
|
+
props: JSON.parse(JSON.stringify(block.props)),
|
|
479
|
+
slots: Object.fromEntries(
|
|
480
|
+
Object.entries(block.slots ?? {}).map(([key, value]) => [
|
|
481
|
+
key,
|
|
482
|
+
Array.isArray(value) ? value.map(
|
|
483
|
+
(v2) => typeof v2 === "string" ? v2 : serializeBlock(v2)
|
|
484
|
+
) : typeof value === "string" ? value : serializeBlock(value)
|
|
485
|
+
])
|
|
486
|
+
)
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
function createSelectedBlock() {
|
|
490
|
+
const selected = d(null);
|
|
491
|
+
function setSelection(block) {
|
|
492
|
+
selected.value = null;
|
|
493
|
+
selected.value = block;
|
|
494
|
+
}
|
|
495
|
+
function clearSelection(block) {
|
|
496
|
+
var _a;
|
|
497
|
+
if (block == null || ((_a = selected.value) == null ? void 0 : _a.id) === block.id) {
|
|
498
|
+
selected.value = null;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return { selected, setSelection, clearSelection };
|
|
502
|
+
}
|
|
503
|
+
const SelectedBlockContext = createContext("selectedBlock");
|
|
504
|
+
const blockDefinitions = (() => {
|
|
505
|
+
if (typeof window !== "undefined") {
|
|
506
|
+
window._juoBlocks = window._juoBlocks || /* @__PURE__ */ new Map();
|
|
507
|
+
return window._juoBlocks;
|
|
508
|
+
}
|
|
509
|
+
return /* @__PURE__ */ new Map();
|
|
510
|
+
})();
|
|
511
|
+
class BlockWrapperEvent extends Event {
|
|
512
|
+
constructor(block, callback) {
|
|
513
|
+
super("juo:block-wrapper-render", {
|
|
514
|
+
bubbles: true,
|
|
515
|
+
composed: true,
|
|
516
|
+
cancelable: true
|
|
517
|
+
});
|
|
518
|
+
this.block = block;
|
|
519
|
+
this.callback = callback;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function isInEditorIframe() {
|
|
523
|
+
if (typeof window === "undefined") return false;
|
|
524
|
+
const params = new URLSearchParams(window.location.search);
|
|
525
|
+
return params.get("editor") === "true";
|
|
526
|
+
}
|
|
527
|
+
function withWrapper(fn) {
|
|
528
|
+
let wrapper = null;
|
|
529
|
+
return (block) => {
|
|
530
|
+
var _a;
|
|
531
|
+
let rendered = fn(block);
|
|
532
|
+
if (wrapper === null) {
|
|
533
|
+
if (isInEditorIframe()) {
|
|
534
|
+
wrapper = document.createElement("juo-editor-block-wrapper");
|
|
535
|
+
wrapper.setAttribute("data-block-id", block.id);
|
|
536
|
+
(_a = wrapper.setBlock) == null ? void 0 : _a.call(wrapper, block);
|
|
537
|
+
wrapper.appendChild(rendered);
|
|
538
|
+
} else {
|
|
539
|
+
const evt = new BlockWrapperEvent(block, (evtWrapper) => {
|
|
540
|
+
wrapper = evtWrapper;
|
|
541
|
+
});
|
|
542
|
+
document.dispatchEvent(evt);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
if (!wrapper) {
|
|
546
|
+
return rendered;
|
|
547
|
+
}
|
|
548
|
+
wrapper.replaceChildren(rendered);
|
|
549
|
+
return wrapper;
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
const registerBlockListeners = [];
|
|
553
|
+
function registerBlock(block) {
|
|
554
|
+
blockDefinitions.set(block.name, block);
|
|
555
|
+
registerBlockListeners.forEach((cb) => cb(block.name, block));
|
|
556
|
+
}
|
|
557
|
+
function onRegisterBlock(cb) {
|
|
558
|
+
registerBlockListeners.push(cb);
|
|
559
|
+
}
|
|
560
|
+
function defineBlock(name, opts) {
|
|
561
|
+
const definition = {
|
|
562
|
+
name,
|
|
563
|
+
group: opts.group,
|
|
564
|
+
schema: opts.schema,
|
|
565
|
+
initialValue: opts.initialValue,
|
|
566
|
+
render: opts.renderer,
|
|
567
|
+
presets: opts.presets,
|
|
568
|
+
locales: opts.locales
|
|
569
|
+
};
|
|
570
|
+
return definition;
|
|
571
|
+
}
|
|
572
|
+
function defineBlockRuntime(name, opts) {
|
|
573
|
+
const definition = {
|
|
574
|
+
name,
|
|
575
|
+
group: opts.group,
|
|
576
|
+
schema: {},
|
|
577
|
+
initialValue() {
|
|
578
|
+
throw new Error("Initial value cannot be called in runtime mode");
|
|
579
|
+
},
|
|
580
|
+
render: opts.renderer
|
|
581
|
+
};
|
|
582
|
+
return definition;
|
|
583
|
+
}
|
|
584
|
+
function getDefinedBlocks() {
|
|
585
|
+
return [...blockDefinitions.values()];
|
|
586
|
+
}
|
|
587
|
+
function createCeRenderer(name) {
|
|
588
|
+
function renderSlots(slots, block) {
|
|
589
|
+
if (!slots) {
|
|
590
|
+
return slots;
|
|
591
|
+
}
|
|
592
|
+
return Object.entries(slots).flatMap(([key, value]) => {
|
|
593
|
+
const values = Array.isArray(value) ? value : [value];
|
|
594
|
+
return values.map((value2) => {
|
|
595
|
+
if (typeof value2 === "string") {
|
|
596
|
+
const el2 = document.createElement("span");
|
|
597
|
+
if (key !== "default") {
|
|
598
|
+
el2.slot = key;
|
|
599
|
+
}
|
|
600
|
+
el2.innerText = value2;
|
|
601
|
+
return el2;
|
|
602
|
+
}
|
|
603
|
+
const el = value2.definition.render({
|
|
604
|
+
...value2,
|
|
605
|
+
props: {
|
|
606
|
+
...value2.props,
|
|
607
|
+
parentProps: block.props
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
if (key !== "default") {
|
|
611
|
+
el.slot = key;
|
|
612
|
+
}
|
|
613
|
+
return el;
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
return (block) => {
|
|
618
|
+
const wrapper = document.createElement("div");
|
|
619
|
+
wrapper.setAttribute("data-block-id", block.id);
|
|
620
|
+
wrapper.setAttribute("data-block-type", block.type);
|
|
621
|
+
const el = document.createElement(name);
|
|
622
|
+
el.setAttribute("data-block-id", block.id);
|
|
623
|
+
el.setAttribute("data-block-type", block.type);
|
|
624
|
+
Object.entries(block.props).forEach(([key, value]) => {
|
|
625
|
+
el[key] = value;
|
|
626
|
+
});
|
|
627
|
+
el.replaceChildren(...renderSlots(block.slots, block));
|
|
628
|
+
wrapper.append(el);
|
|
629
|
+
return wrapper;
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function getDefinitionByName(name) {
|
|
633
|
+
const definition = blockDefinitions.get(name);
|
|
634
|
+
if (definition == null) {
|
|
635
|
+
throw new Error(`Definition for block '${name} does not exists`);
|
|
636
|
+
}
|
|
637
|
+
return definition;
|
|
638
|
+
}
|
|
639
|
+
function createBlockInstance(name, opts) {
|
|
640
|
+
const initialValue = (() => {
|
|
641
|
+
const value = getDefinitionByName(name).initialValue ?? {};
|
|
642
|
+
if (typeof value === "function") {
|
|
643
|
+
return value();
|
|
644
|
+
}
|
|
645
|
+
return value;
|
|
646
|
+
})();
|
|
647
|
+
if ((opts == null ? void 0 : opts.props) == null && initialValue == null) {
|
|
648
|
+
throw new Error(
|
|
649
|
+
`Block '${name} cannot be created without value in runtime mode`
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
const slots = {
|
|
653
|
+
...initialValue.slots,
|
|
654
|
+
...(opts == null ? void 0 : opts.slots) ?? {}
|
|
655
|
+
};
|
|
656
|
+
const props = {
|
|
657
|
+
...initialValue.props ?? {},
|
|
658
|
+
...(opts == null ? void 0 : opts.props) ?? {}
|
|
659
|
+
};
|
|
660
|
+
return {
|
|
661
|
+
// TODO: This should be unique
|
|
662
|
+
id: (opts == null ? void 0 : opts.id) ?? Math.round(1e3 * Math.random()).toString(10),
|
|
663
|
+
type: name,
|
|
664
|
+
props,
|
|
665
|
+
slots,
|
|
666
|
+
get definition() {
|
|
667
|
+
return getDefinitionByName(name);
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
function createBlockInstanceFromObject(input) {
|
|
672
|
+
const { id, type, props, slots } = input;
|
|
673
|
+
return createBlockInstance(type, {
|
|
674
|
+
props,
|
|
675
|
+
slots: Object.fromEntries(
|
|
676
|
+
Object.entries(slots).map(([key, value]) => [
|
|
677
|
+
key,
|
|
678
|
+
(Array.isArray(value) ? value : [value]).map(
|
|
679
|
+
(child) => createBlockInstanceFromObject(child)
|
|
680
|
+
)
|
|
681
|
+
])
|
|
682
|
+
),
|
|
683
|
+
id
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
function createBlockInstanceFromJSON(input) {
|
|
687
|
+
return createBlockInstanceFromObject(JSON.parse(input));
|
|
688
|
+
}
|
|
689
|
+
const DEFAULT_GLOBAL_STYLES = {
|
|
690
|
+
volume: "comfort",
|
|
691
|
+
style: "ghost",
|
|
692
|
+
corners: "round",
|
|
693
|
+
buttonCorners: "round",
|
|
694
|
+
thumbnailCorners: "circle",
|
|
695
|
+
theme: "preset",
|
|
696
|
+
themeType: "neutral",
|
|
697
|
+
colors: {
|
|
698
|
+
accent: "#000000",
|
|
699
|
+
secondary: "#000000",
|
|
700
|
+
tint: "#111111",
|
|
701
|
+
callout: "#F5F5F5",
|
|
702
|
+
success: "#287a25",
|
|
703
|
+
error: "#a93c3c",
|
|
704
|
+
information: "#0075a3",
|
|
705
|
+
warning: "#8a5e00",
|
|
706
|
+
background: "#FFFFFF"
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
const ThemeStateContext = createContext("theme-state");
|
|
710
|
+
function normalizeLocale(locale) {
|
|
711
|
+
return locale.trim().toLowerCase().split("-")[0] || "en";
|
|
712
|
+
}
|
|
713
|
+
function toStringRecord(input) {
|
|
714
|
+
if (input == null) return {};
|
|
715
|
+
return Object.fromEntries(
|
|
716
|
+
Object.entries(input).filter(([, value]) => typeof value === "string")
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
function parseBlockLocaleFile(file) {
|
|
720
|
+
if (file == null) {
|
|
721
|
+
return { defaults: {}, modes: {} };
|
|
722
|
+
}
|
|
723
|
+
const entries = Object.entries(file).filter(
|
|
724
|
+
([key, value]) => key !== "overrides" && typeof value === "string"
|
|
725
|
+
);
|
|
726
|
+
const topLevel = Object.fromEntries(entries);
|
|
727
|
+
const overrides = toStringRecord(file.overrides);
|
|
728
|
+
return {
|
|
729
|
+
defaults: { ...topLevel, ...overrides },
|
|
730
|
+
modes: {
|
|
731
|
+
...Object.fromEntries(
|
|
732
|
+
Object.keys(topLevel).map((key) => [key, "default"])
|
|
733
|
+
),
|
|
734
|
+
...Object.fromEntries(
|
|
735
|
+
Object.keys(overrides).map((key) => [key, "override"])
|
|
736
|
+
)
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
function indexOverrides(overrides) {
|
|
741
|
+
const indexed = {
|
|
742
|
+
theme: {},
|
|
743
|
+
blocks: {}
|
|
744
|
+
};
|
|
745
|
+
for (const item of overrides) {
|
|
746
|
+
if (item.scope.kind === "theme") {
|
|
747
|
+
indexed.theme[item.key] = item.value;
|
|
748
|
+
continue;
|
|
749
|
+
}
|
|
750
|
+
if (indexed.blocks[item.scope.blockId] == null) {
|
|
751
|
+
indexed.blocks[item.scope.blockId] = {};
|
|
752
|
+
}
|
|
753
|
+
indexed.blocks[item.scope.blockId][item.key] = item.value;
|
|
754
|
+
}
|
|
755
|
+
return indexed;
|
|
756
|
+
}
|
|
757
|
+
function createThemeState(deps) {
|
|
758
|
+
const surfaces = {
|
|
759
|
+
page: { blocks: d([]) },
|
|
760
|
+
overlay: { blocks: d([]) }
|
|
761
|
+
};
|
|
762
|
+
const locale = d("en");
|
|
763
|
+
const catalogs = d(null);
|
|
764
|
+
const globalStyles = d(
|
|
765
|
+
deps.initialGlobalStyles ?? DEFAULT_GLOBAL_STYLES
|
|
766
|
+
);
|
|
767
|
+
function setGlobalStyles(styles) {
|
|
768
|
+
globalStyles.value = styles;
|
|
769
|
+
}
|
|
770
|
+
async function collectBlockDefaults(loc) {
|
|
771
|
+
const nextDefaults = {};
|
|
772
|
+
const nextModes = {};
|
|
773
|
+
for (const block of getDefinedBlocks()) {
|
|
774
|
+
if (block.locales == null) continue;
|
|
775
|
+
let file = null;
|
|
776
|
+
try {
|
|
777
|
+
file = await block.locales.load(loc);
|
|
778
|
+
} catch {
|
|
779
|
+
file = null;
|
|
780
|
+
}
|
|
781
|
+
const parsed = parseBlockLocaleFile(file);
|
|
782
|
+
nextDefaults[block.name] = parsed.defaults;
|
|
783
|
+
nextModes[block.name] = parsed.modes;
|
|
784
|
+
}
|
|
785
|
+
return { defaults: nextDefaults, modes: nextModes };
|
|
786
|
+
}
|
|
787
|
+
async function setLocale(nextLocaleRaw) {
|
|
788
|
+
var _a;
|
|
789
|
+
const nextLocale = normalizeLocale(nextLocaleRaw);
|
|
790
|
+
const [blockData, loadedOverrides] = await Promise.all([
|
|
791
|
+
collectBlockDefaults(nextLocale),
|
|
792
|
+
((_a = deps.translations) == null ? void 0 : _a.resolveTranslations(nextLocale).catch(() => [])) ?? Promise.resolve([])
|
|
793
|
+
]);
|
|
794
|
+
const overrides = loadedOverrides.filter(
|
|
795
|
+
(item) => normalizeLocale(item.locale) === nextLocale
|
|
796
|
+
);
|
|
797
|
+
const indexed = indexOverrides(overrides);
|
|
798
|
+
catalogs.value = {
|
|
799
|
+
theme: {
|
|
800
|
+
defaults: {},
|
|
801
|
+
overrides: indexed.theme
|
|
802
|
+
},
|
|
803
|
+
blocks: {
|
|
804
|
+
defaults: blockData.defaults,
|
|
805
|
+
modes: blockData.modes,
|
|
806
|
+
overrides: indexed.blocks
|
|
807
|
+
}
|
|
808
|
+
};
|
|
809
|
+
locale.value = nextLocale;
|
|
810
|
+
}
|
|
811
|
+
async function resolve(surface, id, defaultBlock) {
|
|
812
|
+
surfaces[surface].blocks.value = [];
|
|
813
|
+
const result = await deps.resolve(surface, id, defaultBlock);
|
|
814
|
+
surfaces[surface].blocks.value = [
|
|
815
|
+
...result.blocks.map((block) => createBlockInstanceFromObject(block))
|
|
816
|
+
];
|
|
817
|
+
return result;
|
|
818
|
+
}
|
|
819
|
+
onRegisterBlock(async (_2, block) => {
|
|
820
|
+
if (block.locales == null || catalogs.value == null) return;
|
|
821
|
+
const localeAtLoadStart = locale.value;
|
|
822
|
+
let file = null;
|
|
823
|
+
try {
|
|
824
|
+
file = await block.locales.load(localeAtLoadStart);
|
|
825
|
+
} catch {
|
|
826
|
+
file = null;
|
|
827
|
+
}
|
|
828
|
+
if (catalogs.value == null || locale.value !== localeAtLoadStart) return;
|
|
829
|
+
const parsed = parseBlockLocaleFile(file);
|
|
830
|
+
const current = catalogs.value;
|
|
831
|
+
catalogs.value = {
|
|
832
|
+
...current,
|
|
833
|
+
blocks: {
|
|
834
|
+
...current.blocks,
|
|
835
|
+
defaults: {
|
|
836
|
+
...current.blocks.defaults,
|
|
837
|
+
[block.name]: parsed.defaults
|
|
838
|
+
},
|
|
839
|
+
modes: {
|
|
840
|
+
...current.blocks.modes,
|
|
841
|
+
[block.name]: parsed.modes
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
});
|
|
846
|
+
return {
|
|
847
|
+
page: surfaces.page,
|
|
848
|
+
overlay: surfaces.overlay,
|
|
849
|
+
locales: { locale, catalogs, setLocale },
|
|
850
|
+
globalStyles,
|
|
851
|
+
setGlobalStyles,
|
|
852
|
+
resolve
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
export {
|
|
856
|
+
BlockWrapperEvent as B,
|
|
857
|
+
ContextRequestEvent as C,
|
|
858
|
+
DEFAULT_GLOBAL_STYLES as D,
|
|
859
|
+
E,
|
|
860
|
+
SelectedBlockContext as S,
|
|
861
|
+
ThemeStateContext as T,
|
|
862
|
+
createBlockInstance as a,
|
|
863
|
+
createBlockInstanceFromJSON as b,
|
|
864
|
+
createContext as c,
|
|
865
|
+
d,
|
|
866
|
+
createBlockInstanceFromObject as e,
|
|
867
|
+
createCeRenderer as f,
|
|
868
|
+
defineBlock as g,
|
|
869
|
+
defineBlockRuntime as h,
|
|
870
|
+
getDefinedBlocks as i,
|
|
871
|
+
withWrapper as j,
|
|
872
|
+
createSelectedBlock as k,
|
|
873
|
+
createThemeState as l,
|
|
874
|
+
indexOverrides as m,
|
|
875
|
+
ContextProvideEvent as n,
|
|
876
|
+
onRegisterBlock as o,
|
|
877
|
+
injectContext as p,
|
|
878
|
+
provideContext as q,
|
|
879
|
+
registerBlock as r,
|
|
880
|
+
serializeBlocks as s,
|
|
881
|
+
subscribeContext as t,
|
|
882
|
+
u,
|
|
883
|
+
n as v,
|
|
884
|
+
w,
|
|
885
|
+
ContextRoot as x
|
|
886
|
+
};
|