@juo/blocks 1.13.0 → 1.15.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-C3lVJEBl.js +385 -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-xiKEzCGR.js} +146 -32
- 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 +786 -37
- package/dist/{juo-workflow-BlG9CcAG.js → css-runtime-ClH0MEYr.js} +511 -618
- package/dist/devtools/env.d.ts +3 -0
- package/dist/devtools/env.d.ts.map +1 -0
- package/dist/devtools/hook.d.ts +40 -0
- package/dist/devtools/hook.d.ts.map +1 -0
- package/dist/devtools/index.d.ts +5 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools/instrumentation.d.ts +47 -0
- package/dist/devtools/instrumentation.d.ts.map +1 -0
- package/dist/devtools/protocol.d.ts +77 -0
- package/dist/devtools/protocol.d.ts.map +1 -0
- package/dist/devtools.js +11 -0
- package/dist/editor/bridge.d.ts +8 -0
- package/dist/editor/bridge.d.ts.map +1 -1
- package/dist/editor/canvas-mode-signal.d.ts +22 -0
- package/dist/editor/canvas-mode-signal.d.ts.map +1 -0
- package/dist/editor/canvas-mode.d.ts +15 -0
- package/dist/editor/canvas-mode.d.ts.map +1 -0
- package/dist/editor/canvas-mode.test.d.ts +2 -0
- package/dist/editor/canvas-mode.test.d.ts.map +1 -0
- package/dist/editor/components.d.ts +113 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/components.test.d.ts.map +1 -1
- package/dist/editor/handler.d.ts.map +1 -1
- package/dist/editor/handler.test.d.ts +2 -0
- package/dist/editor/handler.test.d.ts.map +1 -0
- package/dist/editor/layout-command-emitter.d.ts +37 -0
- package/dist/editor/layout-command-emitter.d.ts.map +1 -0
- package/dist/editor/layout-command-emitter.test.d.ts +2 -0
- package/dist/editor/layout-command-emitter.test.d.ts.map +1 -0
- package/dist/editor/layout-system-signal.d.ts +21 -0
- package/dist/editor/layout-system-signal.d.ts.map +1 -0
- package/dist/editor/main.d.ts +1 -0
- package/dist/editor/main.d.ts.map +1 -1
- package/dist/editor/messages.d.ts +96 -3
- 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/surface-context.d.ts +7 -0
- package/dist/editor/surface-context.d.ts.map +1 -0
- package/dist/editor/surface-context.test.d.ts +2 -0
- package/dist/editor/surface-context.test.d.ts.map +1 -0
- package/dist/editor/wrapper-shared.d.ts +31 -0
- package/dist/editor/wrapper-shared.d.ts.map +1 -0
- package/dist/editor.js +882 -57
- package/dist/gridstack-adapter-CDWbSpbt.js +5489 -0
- package/dist/index-JSv6UH_o.js +169 -0
- package/dist/layout/css-runtime.d.ts +41 -0
- package/dist/layout/css-runtime.d.ts.map +1 -0
- package/dist/layout/css-runtime.test.d.ts +2 -0
- package/dist/layout/css-runtime.test.d.ts.map +1 -0
- package/dist/layout/derive.d.ts +4 -0
- package/dist/layout/derive.d.ts.map +1 -0
- package/dist/layout/derive.test.d.ts +2 -0
- package/dist/layout/derive.test.d.ts.map +1 -0
- package/dist/layout/dividers.d.ts +34 -0
- package/dist/layout/dividers.d.ts.map +1 -0
- package/dist/layout/dividers.test.d.ts +2 -0
- package/dist/layout/dividers.test.d.ts.map +1 -0
- package/dist/layout/engine.d.ts +3 -0
- package/dist/layout/engine.d.ts.map +1 -0
- package/dist/layout/engine.test.d.ts +2 -0
- package/dist/layout/engine.test.d.ts.map +1 -0
- package/dist/layout/grid-utils.d.ts +57 -0
- package/dist/layout/grid-utils.d.ts.map +1 -0
- package/dist/layout/grid-utils.test.d.ts +2 -0
- package/dist/layout/grid-utils.test.d.ts.map +1 -0
- package/dist/layout/index.d.ts +13 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.test.d.ts +2 -0
- package/dist/layout/index.test.d.ts.map +1 -0
- package/dist/layout/insert.d.ts +34 -0
- package/dist/layout/insert.d.ts.map +1 -0
- package/dist/layout/insert.test.d.ts +2 -0
- package/dist/layout/insert.test.d.ts.map +1 -0
- package/dist/layout/override.d.ts +10 -0
- package/dist/layout/override.d.ts.map +1 -0
- package/dist/layout/override.test.d.ts +2 -0
- package/dist/layout/override.test.d.ts.map +1 -0
- package/dist/layout/project-css.d.ts +6 -0
- package/dist/layout/project-css.d.ts.map +1 -0
- package/dist/layout/project-css.test.d.ts +2 -0
- package/dist/layout/project-css.test.d.ts.map +1 -0
- package/dist/layout/project-gridstack.d.ts +50 -0
- package/dist/layout/project-gridstack.d.ts.map +1 -0
- package/dist/layout/project-gridstack.test.d.ts +2 -0
- package/dist/layout/project-gridstack.test.d.ts.map +1 -0
- package/dist/layout/reconcile.d.ts +23 -0
- package/dist/layout/reconcile.d.ts.map +1 -0
- package/dist/layout/reconcile.test.d.ts +2 -0
- package/dist/layout/reconcile.test.d.ts.map +1 -0
- package/dist/layout/types.d.ts +118 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/layout-mode-adapter-BBd4JRQd.js +21 -0
- package/dist/main.d.ts +7 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/morph-n4LMxOYo.js +182 -0
- package/dist/preact/block.d.ts.map +1 -1
- package/dist/preact.js +14 -10
- package/dist/project-gridstack-CM783oKI.js +52 -0
- package/dist/react/block.d.ts.map +1 -1
- package/dist/react.js +13 -9
- package/dist/registry.devtools.test.d.ts +2 -0
- package/dist/registry.devtools.test.d.ts.map +1 -0
- package/dist/theme-state.d.ts +16 -0
- package/dist/theme-state.d.ts.map +1 -1
- package/dist/theme-state.layout.test.d.ts +2 -0
- package/dist/theme-state.layout.test.d.ts.map +1 -0
- package/dist/theme-state.test.d.ts +2 -0
- package/dist/theme-state.test.d.ts.map +1 -0
- package/dist/vue/block.d.ts.map +1 -1
- package/dist/vue.js +22 -4
- package/dist/web-components/ExtensionRoot.d.ts +50 -2
- package/dist/web-components/ExtensionRoot.d.ts.map +1 -1
- package/dist/web-components/editor/ExtensionRoot.d.ts +11 -0
- package/dist/web-components/editor/ExtensionRoot.d.ts.map +1 -0
- package/dist/web-components/editor/ExtensionRoot.test.d.ts +2 -0
- package/dist/web-components/editor/ExtensionRoot.test.d.ts.map +1 -0
- package/dist/web-components/editor/InlineText.d.ts +1 -0
- package/dist/web-components/editor/InlineText.d.ts.map +1 -1
- package/dist/web-components/editor/editor-layout-controller.d.ts +28 -0
- package/dist/web-components/editor/editor-layout-controller.d.ts.map +1 -0
- package/dist/web-components/editor/gridstack-adapter.d.ts +3 -0
- package/dist/web-components/editor/gridstack-adapter.d.ts.map +1 -0
- package/dist/web-components/editor/gridstack-adapter.test.d.ts +2 -0
- package/dist/web-components/editor/gridstack-adapter.test.d.ts.map +1 -0
- package/dist/web-components/editor/morph.d.ts +32 -0
- package/dist/web-components/editor/morph.d.ts.map +1 -0
- package/dist/web-components/editor/morph.test.d.ts +2 -0
- package/dist/web-components/editor/morph.test.d.ts.map +1 -0
- package/dist/web-components/layout/layout-controller.d.ts +55 -0
- package/dist/web-components/layout/layout-controller.d.ts.map +1 -0
- package/dist/web-components/layout/view-layout-controller.d.ts +17 -0
- package/dist/web-components/layout/view-layout-controller.d.ts.map +1 -0
- package/dist/web-components/layout/view-layout-controller.test.d.ts +2 -0
- package/dist/web-components/layout/view-layout-controller.test.d.ts.map +1 -0
- package/dist/web-components/layout-grid.d.ts +47 -0
- package/dist/web-components/layout-grid.d.ts.map +1 -0
- package/dist/web-components/layout-grid.test.d.ts +2 -0
- package/dist/web-components/layout-grid.test.d.ts.map +1 -0
- package/dist/web-components/layout-mode-adapter.d.ts +57 -0
- package/dist/web-components/layout-mode-adapter.d.ts.map +1 -0
- package/dist/web-components/layout-mode-adapter.test.d.ts +2 -0
- package/dist/web-components/layout-mode-adapter.test.d.ts.map +1 -0
- package/dist/web-components-editor.js +130 -17
- package/dist/web-components-runtime.js +4 -3
- package/package.json +7 -2
- package/dist/ExtensionRoot-2xTGTu3K.js +0 -219
package/dist/core.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
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 { B,
|
|
4
|
+
import { f as createContext, g as d, h as w, j as registerBlock, E, u, k as getDefinedBlocks, l as createBlockInstance, m as defineBlock, s as subscribeContext, G as GRID_V1_ENGINE_ID, n as clampRect, p as applyFillExpansion, q as compactItems, t as findFreeRect, D as DEFAULT_GRID } from "./css-runtime-ClH0MEYr.js";
|
|
5
|
+
import { B, v, x, y, z, L, P, S, c, T, A, d as d2, b, F, H, I, J, K, N, O, Q, R, U, V, W, X, Y, Z, i, _, a, $, a0, o, a1, a2, a3, e, a4, r, a5, a6, a7, w as w2 } from "./css-runtime-ClH0MEYr.js";
|
|
6
6
|
import { reportBlockWarning, reportBlockError } from "./observability.js";
|
|
7
|
+
import { a as createEditorBridge, D as createSelectBlockMessage } from "./bridge-xiKEzCGR.js";
|
|
8
|
+
import { p } from "./project-gridstack-CM783oKI.js";
|
|
9
|
+
import { clearLayoutModeAdapter, getLayoutModeAdapter, registerLayoutModeAdapter } from "./layout-mode-adapter-BBd4JRQd.js";
|
|
7
10
|
function createState() {
|
|
8
11
|
const discountCode = d(null);
|
|
9
12
|
const products = d([]);
|
|
@@ -132,7 +135,7 @@ async function loadBlockRegistry(options = {}) {
|
|
|
132
135
|
if ("registerBlocks" in module && typeof module.registerBlocks === "function") {
|
|
133
136
|
module.registerBlocks();
|
|
134
137
|
} else {
|
|
135
|
-
Object.entries(module).forEach(([
|
|
138
|
+
Object.entries(module).forEach(([_2, item]) => {
|
|
136
139
|
if (typeof item === "object" && item != null) {
|
|
137
140
|
registerBlock(item);
|
|
138
141
|
}
|
|
@@ -176,7 +179,7 @@ const PARAMS = {
|
|
|
176
179
|
function uuid() {
|
|
177
180
|
return ("10000000-1000-4000-8000" + -1e11).replace(
|
|
178
181
|
/[018]/g,
|
|
179
|
-
(
|
|
182
|
+
(c2) => (c2 ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c2 / 4).toString(16)
|
|
180
183
|
);
|
|
181
184
|
}
|
|
182
185
|
var AuthenticationErrorReason = /* @__PURE__ */ ((AuthenticationErrorReason2) => {
|
|
@@ -1221,6 +1224,487 @@ const DISCOUNT_REJECTION_REASONS = [
|
|
|
1221
1224
|
"INVALID_COMBINATION",
|
|
1222
1225
|
"QUANTITY_REQUIREMENT_NOT_MET"
|
|
1223
1226
|
];
|
|
1227
|
+
function getDefaultBlockForAction(actionType, actionConfig, blockId) {
|
|
1228
|
+
const blockName = `action:${actionType}`;
|
|
1229
|
+
const definedBlocks = getDefinedBlocks();
|
|
1230
|
+
const exists = definedBlocks.some((b2) => b2.name === blockName);
|
|
1231
|
+
if (!exists) {
|
|
1232
|
+
throw new Error(
|
|
1233
|
+
`No default block registered for action type "${actionType}". Expected a block named "${blockName}" to be registered in blocks-extensions.`
|
|
1234
|
+
);
|
|
1235
|
+
}
|
|
1236
|
+
return createBlockInstance(blockName, { props: actionConfig, id: blockId });
|
|
1237
|
+
}
|
|
1238
|
+
function hasDefaultBlockForAction(actionType) {
|
|
1239
|
+
const blockName = `action:${actionType}`;
|
|
1240
|
+
return getDefinedBlocks().some((b2) => b2.name === blockName);
|
|
1241
|
+
}
|
|
1242
|
+
const WorkflowServiceContext = createContext("services/workflow");
|
|
1243
|
+
const RUN_SCOPED_RESET = {
|
|
1244
|
+
firstPollReason: null,
|
|
1245
|
+
feedbackCollected: false
|
|
1246
|
+
};
|
|
1247
|
+
function createWorkflowApiAdapter(sdk) {
|
|
1248
|
+
return {
|
|
1249
|
+
async start(flowType, context, workflowId, dryRun) {
|
|
1250
|
+
const { data } = await sdk.post("/customer/v1/workflows/start", {
|
|
1251
|
+
flowType,
|
|
1252
|
+
context,
|
|
1253
|
+
...workflowId ? { workflowId } : {},
|
|
1254
|
+
...dryRun ? { dryRun: true } : {}
|
|
1255
|
+
});
|
|
1256
|
+
return data;
|
|
1257
|
+
},
|
|
1258
|
+
async respond(runId, interactionId, responseType, responseData, expectedRunVersion, eventId) {
|
|
1259
|
+
const { data } = await sdk.post(
|
|
1260
|
+
"/customer/v1/workflows/{runId}/respond",
|
|
1261
|
+
{
|
|
1262
|
+
runId,
|
|
1263
|
+
interactionId,
|
|
1264
|
+
responseType,
|
|
1265
|
+
responseData,
|
|
1266
|
+
expectedRunVersion,
|
|
1267
|
+
eventId
|
|
1268
|
+
}
|
|
1269
|
+
);
|
|
1270
|
+
return data;
|
|
1271
|
+
},
|
|
1272
|
+
async getState(runId) {
|
|
1273
|
+
const { data } = await sdk.get("/customer/v1/workflows/{runId}", {
|
|
1274
|
+
runId
|
|
1275
|
+
});
|
|
1276
|
+
return data;
|
|
1277
|
+
},
|
|
1278
|
+
async cancel(runId) {
|
|
1279
|
+
const { data } = await sdk.post("/customer/v1/workflows/{runId}/cancel", {
|
|
1280
|
+
runId
|
|
1281
|
+
});
|
|
1282
|
+
return data;
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
function createWorkflowService(deps) {
|
|
1287
|
+
const { api } = deps;
|
|
1288
|
+
const editor = createEditorBridge();
|
|
1289
|
+
const urlParams = typeof window !== "undefined" ? new URLSearchParams(window.location.search) : null;
|
|
1290
|
+
const previewWorkflowTrigger = (urlParams == null ? void 0 : urlParams.get("trigger")) ?? null;
|
|
1291
|
+
const previewStepId = (urlParams == null ? void 0 : urlParams.get("step-id")) ?? null;
|
|
1292
|
+
const previewWorkflowId = (urlParams == null ? void 0 : urlParams.get("workflow-id")) ?? null;
|
|
1293
|
+
const isEditorMode = editor.isEditorMode || previewWorkflowTrigger !== null;
|
|
1294
|
+
const _state = d({
|
|
1295
|
+
status: "idle",
|
|
1296
|
+
flowType: null,
|
|
1297
|
+
workflowId: null,
|
|
1298
|
+
workflowVersion: null,
|
|
1299
|
+
runId: null,
|
|
1300
|
+
runVersion: null,
|
|
1301
|
+
currentStepId: null,
|
|
1302
|
+
currentInteraction: null,
|
|
1303
|
+
error: null,
|
|
1304
|
+
result: null,
|
|
1305
|
+
flowParams: null,
|
|
1306
|
+
invalidatedResources: [],
|
|
1307
|
+
outcome: null,
|
|
1308
|
+
completionData: null,
|
|
1309
|
+
dryRun: null,
|
|
1310
|
+
...RUN_SCOPED_RESET
|
|
1311
|
+
});
|
|
1312
|
+
const _backendInteractionId = d(null);
|
|
1313
|
+
const _registeredRootBlocks = /* @__PURE__ */ new Set();
|
|
1314
|
+
const isActive = w(() => _state.value.status === "active");
|
|
1315
|
+
const isLoading = w(() => _state.value.status === "loading");
|
|
1316
|
+
const isCompleted = w(() => _state.value.status === "completed");
|
|
1317
|
+
const hasError = w(() => _state.value.status === "error");
|
|
1318
|
+
const currentInteraction = w(() => _state.value.currentInteraction);
|
|
1319
|
+
const canRespond = w(() => {
|
|
1320
|
+
const interaction = _state.value.currentInteraction;
|
|
1321
|
+
const backendId = _backendInteractionId.value;
|
|
1322
|
+
if (!interaction || !backendId) return false;
|
|
1323
|
+
return interaction.interactionId === backendId;
|
|
1324
|
+
});
|
|
1325
|
+
const currentStepInfo = w(() => {
|
|
1326
|
+
const interaction = _state.value.currentInteraction;
|
|
1327
|
+
if (!interaction) return null;
|
|
1328
|
+
const actionConfig = deps.shopCurrencyCode ? { ...interaction.actionConfig, currency: deps.shopCurrencyCode } : interaction.actionConfig;
|
|
1329
|
+
return {
|
|
1330
|
+
interactionId: interaction.interactionId,
|
|
1331
|
+
stepId: interaction.stepId,
|
|
1332
|
+
actionType: interaction.actionType,
|
|
1333
|
+
actionConfig,
|
|
1334
|
+
availableResponses: interaction.availableResponses
|
|
1335
|
+
};
|
|
1336
|
+
});
|
|
1337
|
+
function updateState(updates) {
|
|
1338
|
+
_state.value = { ..._state.value, ...updates };
|
|
1339
|
+
}
|
|
1340
|
+
function hashString(value) {
|
|
1341
|
+
let hash = 2166136261;
|
|
1342
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
1343
|
+
hash ^= value.charCodeAt(index);
|
|
1344
|
+
hash = Math.imul(hash, 16777619);
|
|
1345
|
+
}
|
|
1346
|
+
return (hash >>> 0).toString(36);
|
|
1347
|
+
}
|
|
1348
|
+
function shortenId(value, slugLength = 6) {
|
|
1349
|
+
const compact = value.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
1350
|
+
const slug = (compact || "id").slice(0, slugLength);
|
|
1351
|
+
return `${slug}-${hashString(value)}`;
|
|
1352
|
+
}
|
|
1353
|
+
function createStableStepBlockId(workflowId, stepId) {
|
|
1354
|
+
return `wf-${shortenId(workflowId)}-${shortenId(stepId)}`;
|
|
1355
|
+
}
|
|
1356
|
+
function handleFlowResponse(data) {
|
|
1357
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1358
|
+
const mergedInvalidated = [
|
|
1359
|
+
..._state.value.invalidatedResources,
|
|
1360
|
+
...data.invalidatedResources ?? []
|
|
1361
|
+
];
|
|
1362
|
+
if (data.status === "waiting_interaction") {
|
|
1363
|
+
const currentStepId = ((_a = data.pendingInteraction) == null ? void 0 : _a.stepId) ?? (isEditorMode ? (_c = (_b = data.interactiveSteps) == null ? void 0 : _b[0]) == null ? void 0 : _c.stepId : null);
|
|
1364
|
+
_backendInteractionId.value = ((_d = data.pendingInteraction) == null ? void 0 : _d.interactionId) ?? null;
|
|
1365
|
+
const isInitialResponse = _state.value.runId == null;
|
|
1366
|
+
updateState({
|
|
1367
|
+
status: "active",
|
|
1368
|
+
workflowId: data.workflowId,
|
|
1369
|
+
workflowVersion: data.workflowVersion,
|
|
1370
|
+
runId: data.runId,
|
|
1371
|
+
runVersion: data.runVersion,
|
|
1372
|
+
currentStepId,
|
|
1373
|
+
currentInteraction: data.pendingInteraction,
|
|
1374
|
+
invalidatedResources: mergedInvalidated,
|
|
1375
|
+
outcome: null
|
|
1376
|
+
});
|
|
1377
|
+
if (editor.isEditorMode) {
|
|
1378
|
+
const displayStepId = isInitialResponse && previewStepId && ((_e = data.interactiveSteps) == null ? void 0 : _e.some((s) => s.stepId === previewStepId)) ? previewStepId : currentStepId;
|
|
1379
|
+
const overlayBlocks = deps.themeState.overlay.blocks.value;
|
|
1380
|
+
const rootBlock = overlayBlocks[0];
|
|
1381
|
+
const stepSlot = displayStepId ? (_f = rootBlock == null ? void 0 : rootBlock.slots) == null ? void 0 : _f[displayStepId] : null;
|
|
1382
|
+
const stepBlock = Array.isArray(stepSlot) ? stepSlot[0] : null;
|
|
1383
|
+
const blockId = stepBlock && typeof stepBlock === "object" && "id" in stepBlock ? stepBlock.id : null;
|
|
1384
|
+
if (blockId) {
|
|
1385
|
+
editor.sendMessage(
|
|
1386
|
+
createSelectBlockMessage({ blockId }, blockId)
|
|
1387
|
+
);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
} else if (data.status === "completed") {
|
|
1391
|
+
_backendInteractionId.value = null;
|
|
1392
|
+
updateState({
|
|
1393
|
+
status: "completed",
|
|
1394
|
+
currentStepId: null,
|
|
1395
|
+
currentInteraction: null,
|
|
1396
|
+
runVersion: data.runVersion,
|
|
1397
|
+
result: data.result || null,
|
|
1398
|
+
invalidatedResources: mergedInvalidated,
|
|
1399
|
+
outcome: data.outcome || null,
|
|
1400
|
+
completionData: data.completionData || null
|
|
1401
|
+
});
|
|
1402
|
+
} else if (data.status === "failed") {
|
|
1403
|
+
_backendInteractionId.value = null;
|
|
1404
|
+
handleError(new Error(((_g = data.error) == null ? void 0 : _g.message) || "Flow failed"));
|
|
1405
|
+
} else if (data.status === "cancelled") {
|
|
1406
|
+
_backendInteractionId.value = null;
|
|
1407
|
+
updateState({
|
|
1408
|
+
status: "idle",
|
|
1409
|
+
flowType: null,
|
|
1410
|
+
workflowId: null,
|
|
1411
|
+
workflowVersion: null,
|
|
1412
|
+
runId: null,
|
|
1413
|
+
runVersion: null,
|
|
1414
|
+
currentStepId: null,
|
|
1415
|
+
currentInteraction: null,
|
|
1416
|
+
error: null,
|
|
1417
|
+
result: null,
|
|
1418
|
+
invalidatedResources: [],
|
|
1419
|
+
outcome: null,
|
|
1420
|
+
completionData: null,
|
|
1421
|
+
...RUN_SCOPED_RESET
|
|
1422
|
+
});
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
function handleError(error) {
|
|
1426
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
1427
|
+
updateState({
|
|
1428
|
+
status: "error",
|
|
1429
|
+
error: message
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
function maybeApplyPreviewStep(flowType, data) {
|
|
1433
|
+
var _a;
|
|
1434
|
+
if (!previewWorkflowTrigger) return;
|
|
1435
|
+
if (flowType !== previewWorkflowTrigger) return;
|
|
1436
|
+
if (data.status !== "waiting_interaction") return;
|
|
1437
|
+
const step = (_a = data.interactiveSteps) == null ? void 0 : _a.find(
|
|
1438
|
+
(interactiveStep) => interactiveStep.stepId === previewStepId
|
|
1439
|
+
);
|
|
1440
|
+
if (!step) return;
|
|
1441
|
+
updateState({
|
|
1442
|
+
currentStepId: step.stepId,
|
|
1443
|
+
currentInteraction: {
|
|
1444
|
+
interactionId: `preview-${data.runId}-${step.stepId}`,
|
|
1445
|
+
stepId: step.stepId,
|
|
1446
|
+
actionType: step.actionType,
|
|
1447
|
+
actionBehavior: "input",
|
|
1448
|
+
actionConfig: step.actionConfig,
|
|
1449
|
+
availableResponses: step.availableResponses,
|
|
1450
|
+
presentedAt: /* @__PURE__ */ new Date()
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
function initWorkflowRootBlock(data) {
|
|
1455
|
+
if (_registeredRootBlocks.has(data.workflowId)) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
const allSteps = data.interactiveSteps ?? (data.pendingInteraction ? [
|
|
1459
|
+
{
|
|
1460
|
+
stepId: data.pendingInteraction.stepId,
|
|
1461
|
+
actionType: data.pendingInteraction.actionType,
|
|
1462
|
+
actionConfig: data.pendingInteraction.actionConfig,
|
|
1463
|
+
availableResponses: data.pendingInteraction.availableResponses
|
|
1464
|
+
}
|
|
1465
|
+
] : []);
|
|
1466
|
+
const slotProperties = {};
|
|
1467
|
+
for (const step of allSteps) {
|
|
1468
|
+
slotProperties[step.stepId] = {};
|
|
1469
|
+
}
|
|
1470
|
+
const presets = {};
|
|
1471
|
+
const baseLabelFor = (step) => {
|
|
1472
|
+
var _a;
|
|
1473
|
+
return ((_a = getDefinedBlocks().find((b2) => b2.name === `action:${step.actionType}`)) == null ? void 0 : _a.displayName) ?? step.stepId;
|
|
1474
|
+
};
|
|
1475
|
+
const totalCounts = /* @__PURE__ */ new Map();
|
|
1476
|
+
for (const step of allSteps) {
|
|
1477
|
+
const baseLabel = baseLabelFor(step);
|
|
1478
|
+
totalCounts.set(baseLabel, (totalCounts.get(baseLabel) ?? 0) + 1);
|
|
1479
|
+
}
|
|
1480
|
+
const seenCounts = /* @__PURE__ */ new Map();
|
|
1481
|
+
for (const step of allSteps) {
|
|
1482
|
+
const baseLabel = baseLabelFor(step);
|
|
1483
|
+
const occurrence = (seenCounts.get(baseLabel) ?? 0) + 1;
|
|
1484
|
+
seenCounts.set(baseLabel, occurrence);
|
|
1485
|
+
const isDuplicated = (totalCounts.get(baseLabel) ?? 0) > 1;
|
|
1486
|
+
const label = isDuplicated ? `${baseLabel} (${occurrence})` : baseLabel;
|
|
1487
|
+
presets[step.stepId] = {
|
|
1488
|
+
label,
|
|
1489
|
+
description: step.actionType,
|
|
1490
|
+
state: step.stepId,
|
|
1491
|
+
// @ts-expect-error Untyped
|
|
1492
|
+
context: step
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1495
|
+
registerBlock(
|
|
1496
|
+
defineBlock(`workflow:${data.workflowId}`, {
|
|
1497
|
+
group: "workflow",
|
|
1498
|
+
schema: {
|
|
1499
|
+
type: "object",
|
|
1500
|
+
properties: {
|
|
1501
|
+
props: { type: "object" },
|
|
1502
|
+
slots: {
|
|
1503
|
+
type: "object",
|
|
1504
|
+
properties: slotProperties
|
|
1505
|
+
}
|
|
1506
|
+
},
|
|
1507
|
+
required: ["props", "slots"],
|
|
1508
|
+
additionalProperties: true
|
|
1509
|
+
},
|
|
1510
|
+
initialValue: () => ({
|
|
1511
|
+
props: {},
|
|
1512
|
+
slots: Object.fromEntries(
|
|
1513
|
+
allSteps.map((step) => [
|
|
1514
|
+
step.stepId,
|
|
1515
|
+
[
|
|
1516
|
+
getDefaultBlockForAction(
|
|
1517
|
+
step.actionType,
|
|
1518
|
+
step.actionConfig,
|
|
1519
|
+
createStableStepBlockId(data.workflowId, step.stepId)
|
|
1520
|
+
)
|
|
1521
|
+
]
|
|
1522
|
+
])
|
|
1523
|
+
)
|
|
1524
|
+
}),
|
|
1525
|
+
presets,
|
|
1526
|
+
renderer() {
|
|
1527
|
+
return null;
|
|
1528
|
+
}
|
|
1529
|
+
})
|
|
1530
|
+
);
|
|
1531
|
+
_registeredRootBlocks.add(data.workflowId);
|
|
1532
|
+
}
|
|
1533
|
+
async function initWorkflowState(data) {
|
|
1534
|
+
const { blocks } = await deps.themeState.resolve(
|
|
1535
|
+
"overlay",
|
|
1536
|
+
`workflow:${data.workflowId}`
|
|
1537
|
+
);
|
|
1538
|
+
if (blocks.length === 0) return;
|
|
1539
|
+
editor.onBlockPresetChange(blocks[0].id, (preset) => {
|
|
1540
|
+
if (!preset) {
|
|
1541
|
+
return;
|
|
1542
|
+
}
|
|
1543
|
+
updateState({
|
|
1544
|
+
// @ts-expect-error Untyped
|
|
1545
|
+
currentStepId: preset.state,
|
|
1546
|
+
// @ts-expect-error Untyped
|
|
1547
|
+
currentInteraction: { ...preset == null ? void 0 : preset.context }
|
|
1548
|
+
});
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
const service = {
|
|
1552
|
+
// State signals (readonly)
|
|
1553
|
+
state: _state,
|
|
1554
|
+
/** True when the portal is running inside the Blocks Editor (editorMode dep
|
|
1555
|
+
* or ?trigger=... URL param). Consumers use this to suppress auto-start. */
|
|
1556
|
+
isPreviewMode: isEditorMode,
|
|
1557
|
+
// Computed signals
|
|
1558
|
+
isActive,
|
|
1559
|
+
isLoading,
|
|
1560
|
+
isCompleted,
|
|
1561
|
+
hasError,
|
|
1562
|
+
canRespond,
|
|
1563
|
+
currentInteraction,
|
|
1564
|
+
currentStepInfo,
|
|
1565
|
+
// Methods
|
|
1566
|
+
async startFlow(flowType, context, workflowId) {
|
|
1567
|
+
const isDryRun = isEditorMode;
|
|
1568
|
+
updateState({
|
|
1569
|
+
status: "loading",
|
|
1570
|
+
error: null,
|
|
1571
|
+
flowParams: context,
|
|
1572
|
+
flowType,
|
|
1573
|
+
dryRun: isDryRun,
|
|
1574
|
+
...RUN_SCOPED_RESET
|
|
1575
|
+
});
|
|
1576
|
+
try {
|
|
1577
|
+
const data = await api.start(
|
|
1578
|
+
flowType,
|
|
1579
|
+
context,
|
|
1580
|
+
workflowId,
|
|
1581
|
+
isDryRun || void 0
|
|
1582
|
+
);
|
|
1583
|
+
if (data.status === "no_workflow") {
|
|
1584
|
+
service.reset();
|
|
1585
|
+
return;
|
|
1586
|
+
}
|
|
1587
|
+
if (data.status === "completed_silently") {
|
|
1588
|
+
updateState({
|
|
1589
|
+
status: "completed",
|
|
1590
|
+
currentStepId: null,
|
|
1591
|
+
currentInteraction: null,
|
|
1592
|
+
result: null,
|
|
1593
|
+
invalidatedResources: data.invalidatedResources ?? [],
|
|
1594
|
+
outcome: data.outcome || null,
|
|
1595
|
+
completionData: data.completionData || null
|
|
1596
|
+
});
|
|
1597
|
+
return;
|
|
1598
|
+
}
|
|
1599
|
+
initWorkflowRootBlock(data);
|
|
1600
|
+
await initWorkflowState(data);
|
|
1601
|
+
handleFlowResponse(data);
|
|
1602
|
+
maybeApplyPreviewStep(flowType, data);
|
|
1603
|
+
} catch (error) {
|
|
1604
|
+
handleError(error);
|
|
1605
|
+
}
|
|
1606
|
+
},
|
|
1607
|
+
async respond(responseType, responseData) {
|
|
1608
|
+
const { runId, runVersion, currentInteraction: currentInteraction2 } = _state.value;
|
|
1609
|
+
if (!runId || !currentInteraction2) {
|
|
1610
|
+
throw new Error("No active interaction to respond to");
|
|
1611
|
+
}
|
|
1612
|
+
updateState({ status: "loading" });
|
|
1613
|
+
try {
|
|
1614
|
+
const data = await api.respond(
|
|
1615
|
+
runId,
|
|
1616
|
+
currentInteraction2.interactionId,
|
|
1617
|
+
responseType,
|
|
1618
|
+
responseData,
|
|
1619
|
+
runVersion ?? void 0
|
|
1620
|
+
);
|
|
1621
|
+
if (_state.value.firstPollReason == null && currentInteraction2.actionType === "poll") {
|
|
1622
|
+
const reason = responseData == null ? void 0 : responseData.reason;
|
|
1623
|
+
if (typeof reason === "string" && reason.length > 0) {
|
|
1624
|
+
updateState({ firstPollReason: reason });
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
if (!_state.value.feedbackCollected && currentInteraction2.actionType === "collect_feedback" && responseType === "submitted") {
|
|
1628
|
+
const feedback = responseData == null ? void 0 : responseData.feedback;
|
|
1629
|
+
if (typeof feedback === "string" && feedback.trim().length > 0) {
|
|
1630
|
+
updateState({ feedbackCollected: true });
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
handleFlowResponse(data);
|
|
1634
|
+
} catch (error) {
|
|
1635
|
+
handleError(error);
|
|
1636
|
+
}
|
|
1637
|
+
},
|
|
1638
|
+
async cancel() {
|
|
1639
|
+
const { runId, status } = _state.value;
|
|
1640
|
+
const isTerminal = status === "completed" || status === "error";
|
|
1641
|
+
if (runId && !isTerminal) {
|
|
1642
|
+
try {
|
|
1643
|
+
const data = await api.cancel(runId);
|
|
1644
|
+
if (data.outcome) {
|
|
1645
|
+
updateState({
|
|
1646
|
+
status: "completed",
|
|
1647
|
+
flowType: null,
|
|
1648
|
+
workflowId: null,
|
|
1649
|
+
workflowVersion: null,
|
|
1650
|
+
runId: null,
|
|
1651
|
+
runVersion: null,
|
|
1652
|
+
currentStepId: null,
|
|
1653
|
+
currentInteraction: null,
|
|
1654
|
+
error: null,
|
|
1655
|
+
result: null,
|
|
1656
|
+
flowParams: null,
|
|
1657
|
+
invalidatedResources: data.invalidatedResources ?? [],
|
|
1658
|
+
outcome: data.outcome || null,
|
|
1659
|
+
dryRun: null
|
|
1660
|
+
});
|
|
1661
|
+
return;
|
|
1662
|
+
}
|
|
1663
|
+
} catch {
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
service.reset();
|
|
1667
|
+
},
|
|
1668
|
+
reset() {
|
|
1669
|
+
_backendInteractionId.value = null;
|
|
1670
|
+
updateState({
|
|
1671
|
+
status: "idle",
|
|
1672
|
+
flowType: null,
|
|
1673
|
+
workflowId: null,
|
|
1674
|
+
workflowVersion: null,
|
|
1675
|
+
runId: null,
|
|
1676
|
+
runVersion: null,
|
|
1677
|
+
currentStepId: null,
|
|
1678
|
+
currentInteraction: null,
|
|
1679
|
+
error: null,
|
|
1680
|
+
result: null,
|
|
1681
|
+
flowParams: null,
|
|
1682
|
+
invalidatedResources: [],
|
|
1683
|
+
outcome: null,
|
|
1684
|
+
completionData: null,
|
|
1685
|
+
...RUN_SCOPED_RESET
|
|
1686
|
+
});
|
|
1687
|
+
},
|
|
1688
|
+
async refresh() {
|
|
1689
|
+
const { runId } = _state.value;
|
|
1690
|
+
if (!runId) return;
|
|
1691
|
+
try {
|
|
1692
|
+
const data = await api.getState(runId);
|
|
1693
|
+
handleFlowResponse(data);
|
|
1694
|
+
} catch (error) {
|
|
1695
|
+
handleError(error);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
};
|
|
1699
|
+
if (previewWorkflowTrigger) {
|
|
1700
|
+
void service.startFlow(
|
|
1701
|
+
previewWorkflowTrigger,
|
|
1702
|
+
{},
|
|
1703
|
+
previewWorkflowId ?? void 0
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
return service;
|
|
1707
|
+
}
|
|
1224
1708
|
const MOCK_FLOWS = {
|
|
1225
1709
|
cancellation: [
|
|
1226
1710
|
{
|
|
@@ -1471,35 +1955,277 @@ function createMockWorkflowApiAdapter() {
|
|
|
1471
1955
|
}
|
|
1472
1956
|
};
|
|
1473
1957
|
}
|
|
1958
|
+
class JuoWorkflowElement extends HTMLElement {
|
|
1959
|
+
constructor() {
|
|
1960
|
+
super(...arguments);
|
|
1961
|
+
__publicField(this, "workflowService", null);
|
|
1962
|
+
__publicField(this, "unsubscribeContext", null);
|
|
1963
|
+
__publicField(this, "unsubscribeEffect", null);
|
|
1964
|
+
/** Tracks which step is currently mounted to avoid unnecessary DOM teardown. */
|
|
1965
|
+
__publicField(this, "renderedStepId", null);
|
|
1966
|
+
/**
|
|
1967
|
+
* Optional function to wrap rendered content (step blocks).
|
|
1968
|
+
* Must be set before workflow becomes active for correct behavior.
|
|
1969
|
+
*/
|
|
1970
|
+
__publicField(this, "blockWrapper", null);
|
|
1971
|
+
}
|
|
1972
|
+
connectedCallback() {
|
|
1973
|
+
this.style.display = "contents";
|
|
1974
|
+
this.unsubscribeContext = subscribeContext(
|
|
1975
|
+
this,
|
|
1976
|
+
WorkflowServiceContext,
|
|
1977
|
+
(service) => {
|
|
1978
|
+
this.workflowService = service;
|
|
1979
|
+
this.setupSubscription();
|
|
1980
|
+
}
|
|
1981
|
+
);
|
|
1982
|
+
}
|
|
1983
|
+
disconnectedCallback() {
|
|
1984
|
+
var _a, _b;
|
|
1985
|
+
(_a = this.unsubscribeContext) == null ? void 0 : _a.call(this);
|
|
1986
|
+
(_b = this.unsubscribeEffect) == null ? void 0 : _b.call(this);
|
|
1987
|
+
this.unsubscribeContext = null;
|
|
1988
|
+
this.unsubscribeEffect = null;
|
|
1989
|
+
this.renderedStepId = null;
|
|
1990
|
+
}
|
|
1991
|
+
setupSubscription() {
|
|
1992
|
+
var _a;
|
|
1993
|
+
if (!this.workflowService) return;
|
|
1994
|
+
(_a = this.unsubscribeEffect) == null ? void 0 : _a.call(this);
|
|
1995
|
+
this.unsubscribeEffect = E(() => {
|
|
1996
|
+
var _a2, _b;
|
|
1997
|
+
const status = ((_a2 = this.workflowService) == null ? void 0 : _a2.state.value.status) ?? "idle";
|
|
1998
|
+
const stepInfo = (_b = this.workflowService) == null ? void 0 : _b.currentStepInfo.value;
|
|
1999
|
+
const stepId = (stepInfo == null ? void 0 : stepInfo.stepId) ?? null;
|
|
2000
|
+
queueMicrotask(() => {
|
|
2001
|
+
if (this.isConnected) {
|
|
2002
|
+
this.render(status, stepId);
|
|
2003
|
+
}
|
|
2004
|
+
});
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
render(status, stepId) {
|
|
2008
|
+
var _a;
|
|
2009
|
+
if ((status === "active" || status === "loading") && stepId) {
|
|
2010
|
+
if (this.renderedStepId !== stepId) {
|
|
2011
|
+
this.innerHTML = "";
|
|
2012
|
+
this.renderedStepId = stepId;
|
|
2013
|
+
const extensionRoot = document.createElement(
|
|
2014
|
+
"juo-extension-root"
|
|
2015
|
+
);
|
|
2016
|
+
extensionRoot.setAttribute("surface", "overlay");
|
|
2017
|
+
extensionRoot.setAttribute("name", stepId);
|
|
2018
|
+
extensionRoot.blockWrapper = this.blockWrapper;
|
|
2019
|
+
this.appendChild(extensionRoot);
|
|
2020
|
+
}
|
|
2021
|
+
return;
|
|
2022
|
+
}
|
|
2023
|
+
this.innerHTML = "";
|
|
2024
|
+
this.renderedStepId = null;
|
|
2025
|
+
if (status === "error") {
|
|
2026
|
+
const error = ((_a = this.workflowService) == null ? void 0 : _a.state.value.error) ?? "Unknown error";
|
|
2027
|
+
this.dispatchEvent(
|
|
2028
|
+
new CustomEvent("juo-workflow-error", {
|
|
2029
|
+
bubbles: true,
|
|
2030
|
+
composed: true,
|
|
2031
|
+
detail: { error }
|
|
2032
|
+
})
|
|
2033
|
+
);
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
if (typeof customElements !== "undefined" && !customElements.get("juo-workflow")) {
|
|
2038
|
+
customElements.define("juo-workflow", JuoWorkflowElement);
|
|
2039
|
+
}
|
|
2040
|
+
const gridV1Engine = {
|
|
2041
|
+
id: GRID_V1_ENGINE_ID,
|
|
2042
|
+
applyCommand(doc, cmd, ctx2) {
|
|
2043
|
+
const next = structuredClone(doc);
|
|
2044
|
+
const existing = next.layouts[ctx2.breakpoint];
|
|
2045
|
+
const layout = existing ?? {
|
|
2046
|
+
grid: { cols: ctx2.cols, gap: ctx2.gap, rowUnit: ctx2.rowUnit },
|
|
2047
|
+
items: {}
|
|
2048
|
+
};
|
|
2049
|
+
layout.grid = { cols: ctx2.cols, gap: ctx2.gap, rowUnit: ctx2.rowUnit };
|
|
2050
|
+
switch (cmd.kind) {
|
|
2051
|
+
case "add": {
|
|
2052
|
+
layout.items[cmd.blockId] = cmd.rect ? clampRect(cmd.rect, ctx2.cols) : findFreeRect(layout.items, { w: ctx2.cols, h: 1 }, ctx2.cols);
|
|
2053
|
+
break;
|
|
2054
|
+
}
|
|
2055
|
+
case "move": {
|
|
2056
|
+
const current = layout.items[cmd.blockId];
|
|
2057
|
+
if (current) {
|
|
2058
|
+
layout.items[cmd.blockId] = clampRect(
|
|
2059
|
+
{ ...current, c: cmd.to.c, r: cmd.to.r },
|
|
2060
|
+
ctx2.cols
|
|
2061
|
+
);
|
|
2062
|
+
}
|
|
2063
|
+
break;
|
|
2064
|
+
}
|
|
2065
|
+
case "resize": {
|
|
2066
|
+
const current = layout.items[cmd.blockId];
|
|
2067
|
+
if (current) {
|
|
2068
|
+
const w3 = Math.max(1, Math.min(cmd.size.w, ctx2.cols - current.c));
|
|
2069
|
+
const h = Math.max(1, cmd.size.h);
|
|
2070
|
+
layout.items[cmd.blockId] = { ...current, w: w3, h };
|
|
2071
|
+
}
|
|
2072
|
+
break;
|
|
2073
|
+
}
|
|
2074
|
+
case "remove": {
|
|
2075
|
+
delete layout.items[cmd.blockId];
|
|
2076
|
+
layout.items = compactItems(layout.items, ctx2.cols);
|
|
2077
|
+
break;
|
|
2078
|
+
}
|
|
2079
|
+
case "setRects": {
|
|
2080
|
+
for (const [blockId, rect] of Object.entries(cmd.rects)) {
|
|
2081
|
+
const prev = layout.items[blockId];
|
|
2082
|
+
const clamped = clampRect(rect, ctx2.cols);
|
|
2083
|
+
clamped.fill = (prev == null ? void 0 : prev.fill) === true && rect.w === prev.w;
|
|
2084
|
+
if (!clamped.fill) delete clamped.fill;
|
|
2085
|
+
layout.items[blockId] = clamped;
|
|
2086
|
+
}
|
|
2087
|
+
break;
|
|
2088
|
+
}
|
|
2089
|
+
case "fillWidth": {
|
|
2090
|
+
const current = layout.items[cmd.blockId];
|
|
2091
|
+
if (current) {
|
|
2092
|
+
const nextFill = current.fill !== true;
|
|
2093
|
+
layout.items[cmd.blockId] = nextFill ? { ...current, fill: true } : (() => {
|
|
2094
|
+
const { fill, ...rest } = current;
|
|
2095
|
+
return rest;
|
|
2096
|
+
})();
|
|
2097
|
+
}
|
|
2098
|
+
break;
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
layout.items = applyFillExpansion(layout.items, ctx2.cols);
|
|
2102
|
+
next.layouts[ctx2.breakpoint] = layout;
|
|
2103
|
+
return next;
|
|
2104
|
+
},
|
|
2105
|
+
reflow(doc, ctx2) {
|
|
2106
|
+
const next = structuredClone(doc);
|
|
2107
|
+
const layout = next.layouts[ctx2.breakpoint];
|
|
2108
|
+
if (layout) {
|
|
2109
|
+
layout.grid = { cols: ctx2.cols, gap: ctx2.gap, rowUnit: ctx2.rowUnit };
|
|
2110
|
+
for (const id of Object.keys(layout.items)) {
|
|
2111
|
+
layout.items[id] = clampRect(layout.items[id], ctx2.cols);
|
|
2112
|
+
}
|
|
2113
|
+
layout.items = applyFillExpansion(layout.items, ctx2.cols);
|
|
2114
|
+
}
|
|
2115
|
+
return next;
|
|
2116
|
+
}
|
|
2117
|
+
};
|
|
2118
|
+
function resetBreakpoint(doc, breakpointId) {
|
|
2119
|
+
var _a;
|
|
2120
|
+
const baseId = (_a = doc.breakpoints[0]) == null ? void 0 : _a.id;
|
|
2121
|
+
if (breakpointId === baseId) return doc;
|
|
2122
|
+
if (!doc.layouts[breakpointId]) return doc;
|
|
2123
|
+
const next = structuredClone(doc);
|
|
2124
|
+
delete next.layouts[breakpointId];
|
|
2125
|
+
return next;
|
|
2126
|
+
}
|
|
2127
|
+
const DEFAULT_NEW_BLOCK_HEIGHT = 4;
|
|
2128
|
+
function insertRectRelative(doc, args) {
|
|
2129
|
+
var _a, _b;
|
|
2130
|
+
const next = structuredClone(doc);
|
|
2131
|
+
const newHeight = DEFAULT_NEW_BLOCK_HEIGHT;
|
|
2132
|
+
let changed = false;
|
|
2133
|
+
for (const [breakpointId, layout] of Object.entries(next.layouts)) {
|
|
2134
|
+
if (!layout) continue;
|
|
2135
|
+
const target = layout.items[args.targetId];
|
|
2136
|
+
if (!target) continue;
|
|
2137
|
+
const cols = ((_a = doc.breakpoints.find((b2) => b2.id === breakpointId)) == null ? void 0 : _a.cols) ?? ((_b = layout.grid) == null ? void 0 : _b.cols) ?? DEFAULT_GRID.cols;
|
|
2138
|
+
const insertRow = args.position === "before" ? target.r : target.r + target.h;
|
|
2139
|
+
for (const [id, rect] of Object.entries(layout.items)) {
|
|
2140
|
+
if (id === args.blockId) continue;
|
|
2141
|
+
if (rect.r >= insertRow) {
|
|
2142
|
+
layout.items[id] = { ...rect, r: rect.r + newHeight };
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
layout.items[args.blockId] = clampRect(
|
|
2146
|
+
{ c: target.c, r: insertRow, w: target.w, h: newHeight },
|
|
2147
|
+
cols
|
|
2148
|
+
);
|
|
2149
|
+
changed = true;
|
|
2150
|
+
}
|
|
2151
|
+
return changed ? next : doc;
|
|
2152
|
+
}
|
|
2153
|
+
const canvasMode = d(false);
|
|
2154
|
+
const ctx = {};
|
|
2155
|
+
function setActiveSurfaceContext(surface, id) {
|
|
2156
|
+
if (id == null) {
|
|
2157
|
+
delete ctx[surface];
|
|
2158
|
+
return;
|
|
2159
|
+
}
|
|
2160
|
+
ctx[surface] = { id };
|
|
2161
|
+
}
|
|
2162
|
+
function getActiveSurfaceContext(surface) {
|
|
2163
|
+
return ctx[surface] ?? null;
|
|
2164
|
+
}
|
|
2165
|
+
function clearAllSurfaceContexts() {
|
|
2166
|
+
for (const key of Object.keys(ctx)) {
|
|
2167
|
+
delete ctx[key];
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
let currentEmitter = null;
|
|
2171
|
+
function setLayoutCommandEmitter(emitter) {
|
|
2172
|
+
currentEmitter = emitter;
|
|
2173
|
+
}
|
|
2174
|
+
function emitLayoutSetRects(event) {
|
|
2175
|
+
currentEmitter == null ? void 0 : currentEmitter(event);
|
|
2176
|
+
}
|
|
2177
|
+
let currentDispatcher = null;
|
|
2178
|
+
function setLayoutCommandDispatcher(dispatcher) {
|
|
2179
|
+
currentDispatcher = dispatcher;
|
|
2180
|
+
}
|
|
2181
|
+
function emitLayoutCommand(event) {
|
|
2182
|
+
currentDispatcher == null ? void 0 : currentDispatcher(event);
|
|
2183
|
+
}
|
|
1474
2184
|
export {
|
|
1475
2185
|
AuthenticationError,
|
|
1476
2186
|
AuthenticationErrorReason,
|
|
1477
2187
|
B as BlockWrapperEvent,
|
|
1478
|
-
|
|
1479
|
-
|
|
2188
|
+
v as ContextProvideEvent,
|
|
2189
|
+
x as ContextRequestEvent,
|
|
1480
2190
|
CustomerServiceContext,
|
|
1481
|
-
|
|
2191
|
+
y as DEFAULT_BREAKPOINTS,
|
|
2192
|
+
z as DEFAULT_GLOBAL_STYLES,
|
|
2193
|
+
DEFAULT_GRID,
|
|
2194
|
+
DEFAULT_NEW_BLOCK_HEIGHT,
|
|
1482
2195
|
DISCOUNT_REJECTION_REASONS,
|
|
2196
|
+
GRID_V1_ENGINE_ID,
|
|
2197
|
+
L as LAYOUT_SCOPE_ATTR,
|
|
1483
2198
|
LoginServiceContext,
|
|
1484
2199
|
OrdersServiceContext,
|
|
2200
|
+
P as PAGE_ROOT_SLOT,
|
|
1485
2201
|
ProductServiceContext,
|
|
1486
2202
|
RouterServiceContext,
|
|
1487
2203
|
S as SelectedBlockContext,
|
|
1488
2204
|
u as Signal,
|
|
1489
2205
|
StateContext,
|
|
1490
2206
|
SubscriptionServiceContext,
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
2207
|
+
c as ThemeStateContext,
|
|
2208
|
+
T as TranslationContext,
|
|
2209
|
+
WorkflowServiceContext,
|
|
2210
|
+
A as attachEmptyTracking,
|
|
2211
|
+
d2 as backfillInstanceDefaults,
|
|
2212
|
+
b as buildGridLayout,
|
|
2213
|
+
F as buildLayoutCss,
|
|
2214
|
+
canvasMode,
|
|
2215
|
+
clampRect,
|
|
2216
|
+
H as classifyRowDividers,
|
|
2217
|
+
clearAllSurfaceContexts,
|
|
2218
|
+
clearLayoutModeAdapter,
|
|
2219
|
+
compactItems,
|
|
2220
|
+
I as compactLayoutDocument,
|
|
1496
2221
|
w as computed,
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
2222
|
+
createBlockInstance,
|
|
2223
|
+
J as createBlockInstanceFromJSON,
|
|
2224
|
+
K as createBlockInstanceFromObject,
|
|
2225
|
+
N as createCeRenderer,
|
|
1501
2226
|
createContext,
|
|
1502
2227
|
createCustomerService,
|
|
2228
|
+
O as createDefaultLayoutDocument,
|
|
1503
2229
|
createMockOrdersAdapter,
|
|
1504
2230
|
createMockProductAdapter,
|
|
1505
2231
|
createMockRouterService,
|
|
@@ -1508,33 +2234,56 @@ export {
|
|
|
1508
2234
|
createOrdersService,
|
|
1509
2235
|
createProductService,
|
|
1510
2236
|
createRouterService,
|
|
1511
|
-
|
|
2237
|
+
Q as createSelectedBlock,
|
|
1512
2238
|
createState,
|
|
1513
2239
|
createSubscriptionService,
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
2240
|
+
R as createThemeState,
|
|
2241
|
+
U as createTranslationService,
|
|
2242
|
+
createWorkflowApiAdapter,
|
|
2243
|
+
createWorkflowService,
|
|
2244
|
+
defineBlock,
|
|
2245
|
+
V as defineBlockRuntime,
|
|
2246
|
+
W as deriveLayout,
|
|
1520
2247
|
E as effect,
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
2248
|
+
emitLayoutCommand,
|
|
2249
|
+
emitLayoutSetRects,
|
|
2250
|
+
X as expandFillLayoutDocument,
|
|
2251
|
+
findFreeRect,
|
|
2252
|
+
getActiveSurfaceContext,
|
|
2253
|
+
getDefaultBlockForAction,
|
|
2254
|
+
getDefinedBlocks,
|
|
2255
|
+
getLayoutModeAdapter,
|
|
2256
|
+
gridV1Engine,
|
|
2257
|
+
hasDefaultBlockForAction,
|
|
2258
|
+
Y as hasRenderedContent,
|
|
2259
|
+
Z as indexOverrides,
|
|
2260
|
+
i as injectContext,
|
|
2261
|
+
insertRectRelative,
|
|
2262
|
+
_ as isEditorPreview,
|
|
2263
|
+
a as isStubDefinition,
|
|
2264
|
+
$ as layoutScopeSelector,
|
|
2265
|
+
a0 as layoutSystemEnabled,
|
|
1529
2266
|
loadBlockRegistry,
|
|
1530
2267
|
loginService,
|
|
1531
|
-
|
|
1532
|
-
|
|
2268
|
+
o as onRegisterBlock,
|
|
2269
|
+
a1 as projectToCss,
|
|
2270
|
+
p as projectToGridStack,
|
|
2271
|
+
a2 as provideContext,
|
|
2272
|
+
a3 as readingOrder,
|
|
2273
|
+
e as reconcileLayout,
|
|
2274
|
+
a4 as rectsOverlap,
|
|
1533
2275
|
registerBlock,
|
|
1534
|
-
|
|
2276
|
+
registerLayoutModeAdapter,
|
|
2277
|
+
resetBreakpoint,
|
|
2278
|
+
r as resolveLayout,
|
|
2279
|
+
a5 as serializeBlocks,
|
|
2280
|
+
setActiveSurfaceContext,
|
|
2281
|
+
setLayoutCommandDispatcher,
|
|
2282
|
+
setLayoutCommandEmitter,
|
|
2283
|
+
a6 as setLayoutSystemEnabled,
|
|
1535
2284
|
d as signal,
|
|
1536
|
-
|
|
1537
|
-
|
|
2285
|
+
subscribeContext,
|
|
2286
|
+
a7 as untracked,
|
|
1538
2287
|
waitForDevBlocksUrl,
|
|
1539
|
-
|
|
2288
|
+
w2 as withWrapper
|
|
1540
2289
|
};
|