@juo/blocks 1.16.0 → 2.0.0-alpha.2
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 → ExtensionRoot-DRpD5EcC.js} +24 -6
- package/dist/block-BjJztStr.js +993 -0
- package/dist/{block-dVP4Rqgz.js → block-DnhzyZ1H.js} +29 -3
- package/dist/block.d.ts +56 -0
- package/dist/block.d.ts.map +1 -1
- package/dist/{bridge-xiKEzCGR.js → bridge-Mz0CqG6E.js} +39 -30
- package/dist/core.js +359 -226
- package/dist/css-runtime-B7tZrBIp.js +749 -0
- package/dist/devtools/hook.d.ts +0 -5
- package/dist/devtools/hook.d.ts.map +1 -1
- package/dist/devtools/index.d.ts +0 -1
- package/dist/devtools/index.d.ts.map +1 -1
- package/dist/devtools/protocol.d.ts +15 -1
- package/dist/devtools/protocol.d.ts.map +1 -1
- package/dist/devtools.js +42 -9
- package/dist/editor/bridge.d.ts +7 -0
- package/dist/editor/bridge.d.ts.map +1 -1
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/main.d.ts +2 -1
- package/dist/editor/main.d.ts.map +1 -1
- package/dist/editor/messages.d.ts +13 -2
- package/dist/editor/messages.d.ts.map +1 -1
- package/dist/editor/overlays.d.ts +14 -0
- package/dist/editor/overlays.d.ts.map +1 -0
- package/dist/editor/overlays.test.d.ts +2 -0
- package/dist/editor/overlays.test.d.ts.map +1 -0
- package/dist/editor.js +52 -33
- package/dist/{gridstack-adapter-CDWbSpbt.js → gridstack-adapter-BGKGC-eO.js} +2 -2
- package/dist/main.d.ts +3 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/{morph-n4LMxOYo.js → morph-CT5hc5Qp.js} +1 -1
- package/dist/overlay-wrapper.d.ts +69 -0
- package/dist/overlay-wrapper.d.ts.map +1 -0
- package/dist/overlay-wrapper.test.d.ts +2 -0
- package/dist/overlay-wrapper.test.d.ts.map +1 -0
- package/dist/overlays/OverlayService.d.ts +34 -0
- package/dist/overlays/OverlayService.d.ts.map +1 -0
- package/dist/overlays/OverlayService.test.d.ts +2 -0
- package/dist/overlays/OverlayService.test.d.ts.map +1 -0
- package/dist/preact/block.d.ts.map +1 -1
- package/dist/preact/context.d.ts.map +1 -1
- package/dist/preact/context.test.d.ts +2 -0
- package/dist/preact/context.test.d.ts.map +1 -0
- package/dist/preact/signals.d.ts +19 -0
- package/dist/preact/signals.d.ts.map +1 -1
- package/dist/preact/useContextSubscription.test.d.ts +2 -0
- package/dist/preact/useContextSubscription.test.d.ts.map +1 -0
- package/dist/preact.js +33 -7
- package/dist/{project-gridstack-CM783oKI.js → project-gridstack-PxN_DIfP.js} +1 -1
- package/dist/react/block.d.ts.map +1 -1
- package/dist/react/context.d.ts.map +1 -1
- package/dist/react/context.test.d.ts +2 -0
- package/dist/react/context.test.d.ts.map +1 -0
- package/dist/react/signals.d.ts +19 -0
- package/dist/react/signals.d.ts.map +1 -1
- package/dist/react/useContextSubscription.test.d.ts +2 -0
- package/dist/react/useContextSubscription.test.d.ts.map +1 -0
- package/dist/react.js +40 -8
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/order/adapter.d.ts +7 -6
- package/dist/services/order/adapter.d.ts.map +1 -1
- package/dist/services/order/index.d.ts +2 -3
- package/dist/services/order/index.d.ts.map +1 -1
- package/dist/services/order/orderService.d.ts +2 -3
- package/dist/services/order/orderService.d.ts.map +1 -1
- package/dist/services/order/orderService.test.d.ts +2 -0
- package/dist/services/order/orderService.test.d.ts.map +1 -0
- package/dist/services/order/types.d.ts +53 -14
- package/dist/services/order/types.d.ts.map +1 -1
- package/dist/services/subscription/adapter.d.ts.map +1 -1
- package/dist/services/subscription/types.d.ts +20 -0
- package/dist/services/subscription/types.d.ts.map +1 -1
- package/dist/shared/context.d.ts +10 -3
- package/dist/shared/context.d.ts.map +1 -1
- package/dist/shared/touchSignals.d.ts +17 -0
- package/dist/shared/touchSignals.d.ts.map +1 -0
- package/dist/shared/touchSignals.test.d.ts +2 -0
- package/dist/shared/touchSignals.test.d.ts.map +1 -0
- package/dist/theme-state.d.ts +2 -1
- package/dist/theme-state.d.ts.map +1 -1
- package/dist/theme-state.params.test.d.ts +2 -0
- package/dist/theme-state.params.test.d.ts.map +1 -0
- package/dist/theme-state.translations.test.d.ts +2 -0
- package/dist/theme-state.translations.test.d.ts.map +1 -0
- package/dist/vue/block.d.ts.map +1 -1
- package/dist/vue.js +16 -13
- package/dist/web-components/ExtensionRoot.d.ts +1 -0
- package/dist/web-components/ExtensionRoot.d.ts.map +1 -1
- package/dist/web-components-editor.js +6 -5
- package/dist/web-components-runtime.js +3 -2
- package/package.json +1 -1
- package/dist/css-runtime-ClH0MEYr.js +0 -1570
- package/dist/devtools/instrumentation.d.ts +0 -47
- package/dist/devtools/instrumentation.d.ts.map +0 -1
- package/dist/index-JSv6UH_o.js +0 -169
- package/dist/services/orders/adapter.d.ts +0 -10
- package/dist/services/orders/adapter.d.ts.map +0 -1
- package/dist/services/orders/index.d.ts +0 -4
- package/dist/services/orders/index.d.ts.map +0 -1
- package/dist/services/orders/ordersService.d.ts +0 -6
- package/dist/services/orders/ordersService.d.ts.map +0 -1
- package/dist/services/orders/ordersService.test.d.ts +0 -2
- package/dist/services/orders/ordersService.test.d.ts.map +0 -1
- package/dist/services/orders/types.d.ts +0 -60
- package/dist/services/orders/types.d.ts.map +0 -1
package/dist/core.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
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 { e as createContext, f as d, m as w, n as defineBlock, h as createBlockInstance, j as getDefinedBlocks, p as registerBlock, E, u, s as subscribeContext } from "./block-BjJztStr.js";
|
|
5
|
+
import { B, q, t, S, v, _, x, c, y, g, z, A, D, F, G, i, H, b, I, o, J, k, K, l, L, w as w2 } from "./block-BjJztStr.js";
|
|
6
|
+
import { G as GRID_V1_ENGINE_ID, d as clampRect, e as applyFillExpansion, f as compactItems, g as findFreeRect, D as DEFAULT_GRID } from "./css-runtime-B7tZrBIp.js";
|
|
7
|
+
import { h, i as i2, L as L2, P, a, T, b as b2, j, k as k2, l as l2, m, n, o as o2, p, q as q2, s, t as t2, u as u2, v as v2, c as c2, w as w3, r } from "./css-runtime-B7tZrBIp.js";
|
|
6
8
|
import { reportBlockWarning, reportBlockError } from "./observability.js";
|
|
7
|
-
import { a as createEditorBridge,
|
|
8
|
-
import { p } from "./project-gridstack-
|
|
9
|
+
import { a as createEditorBridge, E as createSelectBlockMessage } from "./bridge-Mz0CqG6E.js";
|
|
10
|
+
import { p as p2 } from "./project-gridstack-PxN_DIfP.js";
|
|
9
11
|
import { clearLayoutModeAdapter, getLayoutModeAdapter, registerLayoutModeAdapter } from "./layout-mode-adapter-BBd4JRQd.js";
|
|
10
12
|
function createState() {
|
|
11
13
|
const discountCode = d(null);
|
|
@@ -75,6 +77,111 @@ function createState() {
|
|
|
75
77
|
};
|
|
76
78
|
}
|
|
77
79
|
const StateContext = createContext("state");
|
|
80
|
+
const OVERLAY_WRAPPER_SCHEMA = {
|
|
81
|
+
type: "object",
|
|
82
|
+
properties: {
|
|
83
|
+
props: {
|
|
84
|
+
type: "object",
|
|
85
|
+
properties: {
|
|
86
|
+
layout: {
|
|
87
|
+
type: "string",
|
|
88
|
+
enum: ["modal", "sidebar"]
|
|
89
|
+
},
|
|
90
|
+
canAbort: {
|
|
91
|
+
type: "boolean"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
required: ["layout"],
|
|
95
|
+
additionalProperties: false
|
|
96
|
+
},
|
|
97
|
+
slots: {
|
|
98
|
+
type: "object",
|
|
99
|
+
properties: {
|
|
100
|
+
content: {}
|
|
101
|
+
},
|
|
102
|
+
additionalProperties: false
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
required: ["props", "slots"],
|
|
106
|
+
additionalProperties: false
|
|
107
|
+
};
|
|
108
|
+
function defineOverlayWrapper(opts) {
|
|
109
|
+
const layout = opts.layout ?? "sidebar";
|
|
110
|
+
const canAbort = opts.canAbort ?? true;
|
|
111
|
+
return defineBlock(opts.name, {
|
|
112
|
+
displayName: opts.title,
|
|
113
|
+
group: "internal",
|
|
114
|
+
schema: OVERLAY_WRAPPER_SCHEMA,
|
|
115
|
+
initialValue: () => ({
|
|
116
|
+
props: { layout, canAbort },
|
|
117
|
+
slots: {
|
|
118
|
+
content: [createBlockInstance(opts.content)]
|
|
119
|
+
}
|
|
120
|
+
}),
|
|
121
|
+
renderer: () => null
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const OVERLAY_PREFIX$1 = "overlay:";
|
|
125
|
+
function callInitialValue(block) {
|
|
126
|
+
if (typeof block.initialValue !== "function") return block.initialValue;
|
|
127
|
+
try {
|
|
128
|
+
return block.initialValue();
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.warn(
|
|
131
|
+
`[overlays] initialValue() threw for "${block.name}"; its content block will not be hidden from the palette.`,
|
|
132
|
+
error
|
|
133
|
+
);
|
|
134
|
+
return void 0;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function buildOverlayRegistry(blocks) {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
const registry = {};
|
|
140
|
+
for (const block of blocks) {
|
|
141
|
+
if (!block.name.startsWith(OVERLAY_PREFIX$1)) continue;
|
|
142
|
+
const id = block.name.slice(OVERLAY_PREFIX$1.length);
|
|
143
|
+
const initial = callInitialValue(block);
|
|
144
|
+
const first = (_b = (_a = initial == null ? void 0 : initial.slots) == null ? void 0 : _a.content) == null ? void 0 : _b[0];
|
|
145
|
+
const contentBlock = typeof (first == null ? void 0 : first.type) === "string" ? first.type : "";
|
|
146
|
+
registry[id] = {
|
|
147
|
+
block: block.name,
|
|
148
|
+
title: block.displayName ?? id,
|
|
149
|
+
contentBlock
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return registry;
|
|
153
|
+
}
|
|
154
|
+
const OVERLAY_PREFIX = "overlay:";
|
|
155
|
+
const OverlayServiceContext = createContext("services/overlay");
|
|
156
|
+
function createOverlayService(themeState, options = {}) {
|
|
157
|
+
const getBlocks = options.getBlocks ?? getDefinedBlocks;
|
|
158
|
+
const current = w(() => {
|
|
159
|
+
const root = themeState.overlay.blocks.value[0];
|
|
160
|
+
const type = root == null ? void 0 : root.type;
|
|
161
|
+
if (typeof type !== "string" || !type.startsWith(OVERLAY_PREFIX)) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
const props = root.props ?? {};
|
|
165
|
+
return {
|
|
166
|
+
name: type,
|
|
167
|
+
// Defaults mirror defineOverlayWrapper's seeding in overlay-wrapper.ts — keep in sync.
|
|
168
|
+
layout: props.layout ?? "sidebar",
|
|
169
|
+
canAbort: Boolean(props.canAbort ?? true)
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
return {
|
|
173
|
+
getEditableOverlays() {
|
|
174
|
+
return buildOverlayRegistry(getBlocks());
|
|
175
|
+
},
|
|
176
|
+
open(name, params) {
|
|
177
|
+
void themeState.resolve("overlay", name, params);
|
|
178
|
+
},
|
|
179
|
+
close() {
|
|
180
|
+
themeState.overlay.blocks.value = [];
|
|
181
|
+
},
|
|
182
|
+
current
|
|
183
|
+
};
|
|
184
|
+
}
|
|
78
185
|
function isLocalhostOrigin(origin) {
|
|
79
186
|
try {
|
|
80
187
|
const url = new URL(origin);
|
|
@@ -190,8 +297,8 @@ function createApiCustomerAdapter(fetcher) {
|
|
|
190
297
|
_tag: "Success",
|
|
191
298
|
data: { id: data.id, name, email: data.email }
|
|
192
299
|
};
|
|
193
|
-
} catch (
|
|
194
|
-
return { _tag: "Failure", error:
|
|
300
|
+
} catch (e) {
|
|
301
|
+
return { _tag: "Failure", error: e };
|
|
195
302
|
}
|
|
196
303
|
}
|
|
197
304
|
};
|
|
@@ -209,7 +316,7 @@ const PARAMS = {
|
|
|
209
316
|
function uuid() {
|
|
210
317
|
return ("10000000-1000-4000-8000" + -1e11).replace(
|
|
211
318
|
/[018]/g,
|
|
212
|
-
(
|
|
319
|
+
(c3) => (c3 ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c3 / 4).toString(16)
|
|
213
320
|
);
|
|
214
321
|
}
|
|
215
322
|
function createMockLoginAdapter(opts = {}) {
|
|
@@ -280,8 +387,8 @@ function createApiLoginAdapter(fetcher, opts) {
|
|
|
280
387
|
lang
|
|
281
388
|
);
|
|
282
389
|
return { _tag: "Success", data: void 0 };
|
|
283
|
-
} catch (
|
|
284
|
-
return { _tag: "Failure", error:
|
|
390
|
+
} catch (e) {
|
|
391
|
+
return { _tag: "Failure", error: e };
|
|
285
392
|
}
|
|
286
393
|
},
|
|
287
394
|
async authenticate(params) {
|
|
@@ -315,8 +422,8 @@ function createApiLoginAdapter(fetcher, opts) {
|
|
|
315
422
|
throw new Error(`Unexpected response: ${res.statusText}`);
|
|
316
423
|
}
|
|
317
424
|
return { _tag: "Success", data: await res.json() };
|
|
318
|
-
} catch (
|
|
319
|
-
return { _tag: "Failure", error:
|
|
425
|
+
} catch (e) {
|
|
426
|
+
return { _tag: "Failure", error: e };
|
|
320
427
|
}
|
|
321
428
|
},
|
|
322
429
|
getAuthorizeUrl({ connection, state, shop }) {
|
|
@@ -575,7 +682,7 @@ function createLoginService(init) {
|
|
|
575
682
|
return service;
|
|
576
683
|
}
|
|
577
684
|
const LoginServiceContext = createContext("services/login");
|
|
578
|
-
function
|
|
685
|
+
function createMockOrderAdapter() {
|
|
579
686
|
const mockOrders = [
|
|
580
687
|
{
|
|
581
688
|
id: "10001",
|
|
@@ -659,7 +766,7 @@ function mapOrder(order) {
|
|
|
659
766
|
customAttributes: order.customAttributes
|
|
660
767
|
};
|
|
661
768
|
}
|
|
662
|
-
function
|
|
769
|
+
function createApiOrderAdapter(fetcher) {
|
|
663
770
|
return {
|
|
664
771
|
async getOrders(params) {
|
|
665
772
|
const query = new URLSearchParams();
|
|
@@ -685,7 +792,7 @@ function createApiOrdersAdapter(fetcher) {
|
|
|
685
792
|
}
|
|
686
793
|
};
|
|
687
794
|
}
|
|
688
|
-
function
|
|
795
|
+
function createOrderService(adapter) {
|
|
689
796
|
return {
|
|
690
797
|
async getOrders(params) {
|
|
691
798
|
try {
|
|
@@ -697,7 +804,7 @@ function createOrdersService(adapter) {
|
|
|
697
804
|
}
|
|
698
805
|
};
|
|
699
806
|
}
|
|
700
|
-
const
|
|
807
|
+
const OrderServiceContext = createContext("services/order");
|
|
701
808
|
function createMockProductAdapter() {
|
|
702
809
|
const products = [
|
|
703
810
|
{
|
|
@@ -888,9 +995,9 @@ function createMockProductAdapter() {
|
|
|
888
995
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
889
996
|
return products.filter((product) => ids.includes(product.id)).map(toAvailableProduct);
|
|
890
997
|
},
|
|
891
|
-
async getAvailableProducts({ q }) {
|
|
998
|
+
async getAvailableProducts({ q: q3 }) {
|
|
892
999
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
893
|
-
const queryLower =
|
|
1000
|
+
const queryLower = q3 == null ? void 0 : q3.toLowerCase();
|
|
894
1001
|
return products.filter(
|
|
895
1002
|
(product) => !queryLower || product.title.toLowerCase().includes(queryLower) || product.variants.some(
|
|
896
1003
|
(variant) => variant.title.toLowerCase().includes(queryLower)
|
|
@@ -964,7 +1071,7 @@ function mapProduct(product, currencyCode) {
|
|
|
964
1071
|
featuredImage: product.image == null ? null : { url: product.image.url, altText: product.image.altText ?? void 0 },
|
|
965
1072
|
hasOnlyDefaultVariant: product.variants.length <= 1,
|
|
966
1073
|
variants: {
|
|
967
|
-
items: product.variants.map((
|
|
1074
|
+
items: product.variants.map((v3) => mapVariant(v3, currencyCode)),
|
|
968
1075
|
pageInfo: {
|
|
969
1076
|
hasNextPage: false,
|
|
970
1077
|
hasPrevPage: false,
|
|
@@ -1019,7 +1126,7 @@ function createApiProductAdapter(fetcher, opts = { currencyCode: "USD" }) {
|
|
|
1019
1126
|
}
|
|
1020
1127
|
const body = await fetchProducts(params);
|
|
1021
1128
|
return {
|
|
1022
|
-
items: body.data.map((
|
|
1129
|
+
items: body.data.map((p3) => mapProduct(p3, currencyCode)),
|
|
1023
1130
|
pageInfo: {
|
|
1024
1131
|
hasNextPage: body.hasNextPage,
|
|
1025
1132
|
hasPrevPage: body.hasPrevPage,
|
|
@@ -1045,10 +1152,10 @@ function createApiProductAdapter(fetcher, opts = { currencyCode: "USD" }) {
|
|
|
1045
1152
|
const res = await fetcher(`/customer/products/by-ids?${params.toString()}`);
|
|
1046
1153
|
if (!res.ok) return [];
|
|
1047
1154
|
const data = await res.json();
|
|
1048
|
-
return (data ?? []).map((
|
|
1049
|
-
id:
|
|
1050
|
-
title:
|
|
1051
|
-
featuredImage:
|
|
1155
|
+
return (data ?? []).map((p3) => ({
|
|
1156
|
+
id: p3.id,
|
|
1157
|
+
title: p3.title ?? "",
|
|
1158
|
+
featuredImage: p3.featuredImage ? { url: p3.featuredImage.url, altText: p3.featuredImage.altText } : null,
|
|
1052
1159
|
hasOnlyDefaultVariant: true,
|
|
1053
1160
|
collections: []
|
|
1054
1161
|
}));
|
|
@@ -1060,30 +1167,30 @@ function createApiProductAdapter(fetcher, opts = { currencyCode: "USD" }) {
|
|
|
1060
1167
|
const res = await fetcher(`/customer/products/variants?${params.toString()}`);
|
|
1061
1168
|
if (!res.ok) return [];
|
|
1062
1169
|
const data = await res.json();
|
|
1063
|
-
return (data ?? []).map((
|
|
1170
|
+
return (data ?? []).map((p3) => {
|
|
1064
1171
|
var _a;
|
|
1065
1172
|
return {
|
|
1066
|
-
id:
|
|
1067
|
-
title:
|
|
1068
|
-
description:
|
|
1069
|
-
featuredImage:
|
|
1070
|
-
hasOnlyDefaultVariant:
|
|
1071
|
-
variants: (
|
|
1072
|
-
id:
|
|
1073
|
-
availableForSale:
|
|
1074
|
-
title:
|
|
1075
|
-
currentPrice:
|
|
1076
|
-
basePrice:
|
|
1077
|
-
image:
|
|
1078
|
-
recurring:
|
|
1173
|
+
id: p3.id,
|
|
1174
|
+
title: p3.title,
|
|
1175
|
+
description: p3.description ?? "",
|
|
1176
|
+
featuredImage: p3.featuredImage,
|
|
1177
|
+
hasOnlyDefaultVariant: p3.hasOnlyDefaultVariant ?? (((_a = p3.variants) == null ? void 0 : _a.length) ?? 0) <= 1,
|
|
1178
|
+
variants: (p3.variants ?? []).map((v3) => ({
|
|
1179
|
+
id: v3.id,
|
|
1180
|
+
availableForSale: v3.availableForSale,
|
|
1181
|
+
title: v3.title,
|
|
1182
|
+
currentPrice: v3.currentPrice,
|
|
1183
|
+
basePrice: v3.basePrice,
|
|
1184
|
+
image: v3.image,
|
|
1185
|
+
recurring: v3.recurring
|
|
1079
1186
|
}))
|
|
1080
1187
|
};
|
|
1081
1188
|
});
|
|
1082
1189
|
},
|
|
1083
|
-
async getAvailableProducts({ subscriptionId, lineId, q, mode, action, pagination }) {
|
|
1190
|
+
async getAvailableProducts({ subscriptionId, lineId, q: q3, mode, action, pagination }) {
|
|
1084
1191
|
const params = new URLSearchParams();
|
|
1085
1192
|
params.set("action", action);
|
|
1086
|
-
if (
|
|
1193
|
+
if (q3) params.set("q", q3);
|
|
1087
1194
|
if (mode) params.set("mode", mode);
|
|
1088
1195
|
if (pagination && "after" in pagination) params.set("after", pagination.after);
|
|
1089
1196
|
if (pagination && "before" in pagination) params.set("before", pagination.before);
|
|
@@ -1092,22 +1199,22 @@ function createApiProductAdapter(fetcher, opts = { currencyCode: "USD" }) {
|
|
|
1092
1199
|
);
|
|
1093
1200
|
if (!res.ok) return [];
|
|
1094
1201
|
const data = await res.json();
|
|
1095
|
-
return (data ?? []).map((
|
|
1202
|
+
return (data ?? []).map((p3) => {
|
|
1096
1203
|
var _a;
|
|
1097
1204
|
return {
|
|
1098
|
-
id:
|
|
1099
|
-
title:
|
|
1100
|
-
description:
|
|
1101
|
-
featuredImage:
|
|
1102
|
-
hasOnlyDefaultVariant:
|
|
1103
|
-
variants: (
|
|
1104
|
-
id:
|
|
1105
|
-
availableForSale:
|
|
1106
|
-
title:
|
|
1107
|
-
currentPrice:
|
|
1108
|
-
basePrice:
|
|
1109
|
-
image:
|
|
1110
|
-
recurring:
|
|
1205
|
+
id: p3.id,
|
|
1206
|
+
title: p3.title,
|
|
1207
|
+
description: p3.description ?? "",
|
|
1208
|
+
featuredImage: p3.featuredImage,
|
|
1209
|
+
hasOnlyDefaultVariant: p3.hasOnlyDefaultVariant ?? (((_a = p3.variants) == null ? void 0 : _a.length) ?? 0) <= 1,
|
|
1210
|
+
variants: (p3.variants ?? []).map((v3) => ({
|
|
1211
|
+
id: v3.id,
|
|
1212
|
+
availableForSale: v3.availableForSale,
|
|
1213
|
+
title: v3.title,
|
|
1214
|
+
currentPrice: v3.currentPrice,
|
|
1215
|
+
basePrice: v3.basePrice,
|
|
1216
|
+
image: v3.image,
|
|
1217
|
+
recurring: v3.recurring
|
|
1111
1218
|
}))
|
|
1112
1219
|
};
|
|
1113
1220
|
});
|
|
@@ -1152,7 +1259,7 @@ function routeNameTableFromPages(pages) {
|
|
|
1152
1259
|
function createRouterService(options) {
|
|
1153
1260
|
const { pages, pushImplementation } = options;
|
|
1154
1261
|
const routeNameToPagePath = routeNameTableFromPages(pages);
|
|
1155
|
-
const pathSet = new Set(pages.map((
|
|
1262
|
+
const pathSet = new Set(pages.map((p3) => p3.path));
|
|
1156
1263
|
const navigationSubscribers = [];
|
|
1157
1264
|
function notifySubscribers(logicalPath) {
|
|
1158
1265
|
for (const cb of navigationSubscribers) cb({ path: logicalPath });
|
|
@@ -1420,7 +1527,7 @@ function createMockSubscriptionAdapter(options = {}) {
|
|
|
1420
1527
|
data: subscription ? {
|
|
1421
1528
|
...subscription,
|
|
1422
1529
|
items: subscription.items.map((item) => ({ ...item })),
|
|
1423
|
-
discounts: subscription.discounts.map((
|
|
1530
|
+
discounts: subscription.discounts.map((d2) => ({ ...d2 }))
|
|
1424
1531
|
} : null
|
|
1425
1532
|
};
|
|
1426
1533
|
},
|
|
@@ -1468,7 +1575,7 @@ function createMockSubscriptionAdapter(options = {}) {
|
|
|
1468
1575
|
}
|
|
1469
1576
|
const currencyCode = ((_a = subscription.items[0]) == null ? void 0 : _a.price.currencyCode) ?? "USD";
|
|
1470
1577
|
const product = await ((_b = options.productAdapter) == null ? void 0 : _b.getByVariantId(item.variantId)) ?? await ((_c = options.productAdapter) == null ? void 0 : _c.getById(item.variantId)) ?? null;
|
|
1471
|
-
const variant = (product == null ? void 0 : product.variants.items.find((
|
|
1578
|
+
const variant = (product == null ? void 0 : product.variants.items.find((v3) => v3.id === item.variantId)) ?? (product == null ? void 0 : product.variants.items[0]);
|
|
1472
1579
|
const linePrice = ((_e = (_d = variant == null ? void 0 : variant.purchaseOptions) == null ? void 0 : _d[0]) == null ? void 0 : _e.price) ?? (variant == null ? void 0 : variant.price);
|
|
1473
1580
|
subscription.items.push({
|
|
1474
1581
|
id: `item_${Date.now()}_${subscription.items.length}`,
|
|
@@ -1481,8 +1588,10 @@ function createMockSubscriptionAdapter(options = {}) {
|
|
|
1481
1588
|
...variant && product && !product.hasOnlyDefaultVariant ? { variantTitle: variant.title } : {},
|
|
1482
1589
|
...(variant == null ? void 0 : variant.image) ? { variantImage: variant.image } : {},
|
|
1483
1590
|
variantAvailableForSale: true,
|
|
1484
|
-
|
|
1485
|
-
|
|
1591
|
+
// An explicit per-line billingPolicy wins; otherwise inherit the plan's.
|
|
1592
|
+
billingPolicy: item.billingPolicy ?? ((_f = subscription.items[0]) == null ? void 0 : _f.billingPolicy) ?? subscription.billingPolicy ?? null,
|
|
1593
|
+
deliveryPolicy: ((_g = subscription.items[0]) == null ? void 0 : _g.deliveryPolicy) ?? subscription.deliveryPolicy ?? null,
|
|
1594
|
+
...item.recurringCycleLimit != null ? { recurringCycleLimit: item.recurringCycleLimit } : {}
|
|
1486
1595
|
});
|
|
1487
1596
|
subscription.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1488
1597
|
return { _tag: "Success", data: void 0 };
|
|
@@ -1493,7 +1602,7 @@ function createMockSubscriptionAdapter(options = {}) {
|
|
|
1493
1602
|
if (!subscription) {
|
|
1494
1603
|
return { _tag: "Failure", error: "Subscription not found" };
|
|
1495
1604
|
}
|
|
1496
|
-
subscription.items = subscription.items.filter((
|
|
1605
|
+
subscription.items = subscription.items.filter((i3) => i3.id !== itemId);
|
|
1497
1606
|
subscription.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1498
1607
|
return { _tag: "Success", data: void 0 };
|
|
1499
1608
|
},
|
|
@@ -1503,7 +1612,7 @@ function createMockSubscriptionAdapter(options = {}) {
|
|
|
1503
1612
|
if (!subscription) {
|
|
1504
1613
|
return { _tag: "Failure", error: "Subscription not found" };
|
|
1505
1614
|
}
|
|
1506
|
-
const item = subscription.items.find((
|
|
1615
|
+
const item = subscription.items.find((i3) => i3.id === lineId);
|
|
1507
1616
|
if (!item) {
|
|
1508
1617
|
return { _tag: "Failure", error: "Line item not found" };
|
|
1509
1618
|
}
|
|
@@ -1519,7 +1628,7 @@ function createMockSubscriptionAdapter(options = {}) {
|
|
|
1519
1628
|
if (!subscription) {
|
|
1520
1629
|
return { _tag: "Failure", error: "Subscription not found" };
|
|
1521
1630
|
}
|
|
1522
|
-
const item = subscription.items.find((
|
|
1631
|
+
const item = subscription.items.find((i3) => i3.id === lineId);
|
|
1523
1632
|
if (!item) {
|
|
1524
1633
|
return { _tag: "Failure", error: "Line item not found" };
|
|
1525
1634
|
}
|
|
@@ -1709,7 +1818,7 @@ function createMockSubscriptionAdapter(options = {}) {
|
|
|
1709
1818
|
data: {
|
|
1710
1819
|
...subscription,
|
|
1711
1820
|
items: subscription.items.map((item) => ({ ...item })),
|
|
1712
|
-
discounts: subscription.discounts.map((
|
|
1821
|
+
discounts: subscription.discounts.map((d2) => ({ ...d2 }))
|
|
1713
1822
|
}
|
|
1714
1823
|
};
|
|
1715
1824
|
},
|
|
@@ -1781,14 +1890,14 @@ function mapSubscription(raw) {
|
|
|
1781
1890
|
),
|
|
1782
1891
|
discounts: (raw.discounts ?? []).map(
|
|
1783
1892
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1784
|
-
(
|
|
1893
|
+
(d2) => {
|
|
1785
1894
|
var _a2, _b2, _c;
|
|
1786
1895
|
return {
|
|
1787
|
-
id:
|
|
1788
|
-
type: ((_a2 =
|
|
1789
|
-
value: ((_b2 =
|
|
1790
|
-
code:
|
|
1791
|
-
description:
|
|
1896
|
+
id: d2.id,
|
|
1897
|
+
type: ((_a2 = d2.value) == null ? void 0 : _a2.type) === "fixed-amount" || d2.type === "fixed_amount" ? "fixed_amount" : "percentage",
|
|
1898
|
+
value: ((_b2 = d2.value) == null ? void 0 : _b2.amount) ?? ((_c = d2.value) == null ? void 0 : _c.percentage) ?? d2.value ?? 0,
|
|
1899
|
+
code: d2.title ?? d2.code ?? "",
|
|
1900
|
+
description: d2.description ?? ""
|
|
1792
1901
|
};
|
|
1793
1902
|
}
|
|
1794
1903
|
),
|
|
@@ -1822,8 +1931,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1822
1931
|
try {
|
|
1823
1932
|
const params = new URLSearchParams();
|
|
1824
1933
|
if ((_a = options == null ? void 0 : options.filters) == null ? void 0 : _a.length) {
|
|
1825
|
-
const groups = options.filters.filter((f) => Object.keys(f).length > 0).map((f) => Object.entries(f).filter(([,
|
|
1826
|
-
(entries) => "(" + entries.map(([
|
|
1934
|
+
const groups = options.filters.filter((f) => Object.keys(f).length > 0).map((f) => Object.entries(f).filter(([, v3]) => Boolean(v3))).filter((entries) => entries.length > 0).map(
|
|
1935
|
+
(entries) => "(" + entries.map(([k3, v3]) => `${k3}:'${v3}'`).join(" AND ") + ")"
|
|
1827
1936
|
);
|
|
1828
1937
|
if (groups.length) params.set("query", groups.join(" OR "));
|
|
1829
1938
|
}
|
|
@@ -1853,8 +1962,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1853
1962
|
}
|
|
1854
1963
|
}
|
|
1855
1964
|
};
|
|
1856
|
-
} catch (
|
|
1857
|
-
return { _tag: "Failure", error:
|
|
1965
|
+
} catch (e) {
|
|
1966
|
+
return { _tag: "Failure", error: e };
|
|
1858
1967
|
}
|
|
1859
1968
|
},
|
|
1860
1969
|
async getById(id) {
|
|
@@ -1866,24 +1975,41 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1866
1975
|
const body = await res.json();
|
|
1867
1976
|
const raw = body.data[0];
|
|
1868
1977
|
return { _tag: "Success", data: raw ? mapSubscription(raw) : null };
|
|
1869
|
-
} catch (
|
|
1870
|
-
return { _tag: "Failure", error:
|
|
1978
|
+
} catch (e) {
|
|
1979
|
+
return { _tag: "Failure", error: e };
|
|
1871
1980
|
}
|
|
1872
1981
|
},
|
|
1982
|
+
// Uses the legacy POST /customer/subscriptions/{id}/lines rather than
|
|
1983
|
+
// POST /customer/v1/subscriptions/{id}/items: only the legacy endpoint
|
|
1984
|
+
// accepts a per-line `billingPolicy`. It answers 204 with no body.
|
|
1985
|
+
// Behavioural differences vs the v1 route, both intentional here:
|
|
1986
|
+
// - it rejects membership subscriptions with 403 (v1 does not),
|
|
1987
|
+
// - it skips the availableForSale check (v1 enforces it), so callers are
|
|
1988
|
+
// responsible for only offering purchasable variants — which the
|
|
1989
|
+
// product picker already does.
|
|
1873
1990
|
async addItem({ subscriptionId, item }) {
|
|
1874
1991
|
try {
|
|
1992
|
+
const body = {
|
|
1993
|
+
productVariantId: item.variantId,
|
|
1994
|
+
quantity: item.quantity,
|
|
1995
|
+
// `!= null` on purpose: null means "inherit"/"no limit", and the
|
|
1996
|
+
// endpoint rejects an explicit null on either field.
|
|
1997
|
+
...item.billingPolicy != null ? { billingPolicy: item.billingPolicy } : {},
|
|
1998
|
+
...item.recurringCycleLimit != null ? { renewalLimit: item.recurringCycleLimit } : {},
|
|
1999
|
+
...item.shippingMethodHandle != null ? { shippingMethodHandle: item.shippingMethodHandle } : {}
|
|
2000
|
+
};
|
|
1875
2001
|
const res = await fetcher(
|
|
1876
|
-
`/customer/
|
|
2002
|
+
`/customer/subscriptions/${subscriptionId}/lines`,
|
|
1877
2003
|
{
|
|
1878
2004
|
method: "POST",
|
|
1879
2005
|
headers: { "Content-Type": "application/json" },
|
|
1880
|
-
body: JSON.stringify(
|
|
2006
|
+
body: JSON.stringify(body)
|
|
1881
2007
|
}
|
|
1882
2008
|
);
|
|
1883
2009
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
1884
2010
|
return { _tag: "Success", data: void 0 };
|
|
1885
|
-
} catch (
|
|
1886
|
-
return { _tag: "Failure", error:
|
|
2011
|
+
} catch (e) {
|
|
2012
|
+
return { _tag: "Failure", error: e };
|
|
1887
2013
|
}
|
|
1888
2014
|
},
|
|
1889
2015
|
async removeItem({ subscriptionId, itemId }) {
|
|
@@ -1894,8 +2020,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1894
2020
|
);
|
|
1895
2021
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
1896
2022
|
return { _tag: "Success", data: void 0 };
|
|
1897
|
-
} catch (
|
|
1898
|
-
return { _tag: "Failure", error:
|
|
2023
|
+
} catch (e) {
|
|
2024
|
+
return { _tag: "Failure", error: e };
|
|
1899
2025
|
}
|
|
1900
2026
|
},
|
|
1901
2027
|
async updateItem({ subscriptionId, lineId, update }) {
|
|
@@ -1916,8 +2042,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1916
2042
|
);
|
|
1917
2043
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
1918
2044
|
return { _tag: "Success", data: void 0 };
|
|
1919
|
-
} catch (
|
|
1920
|
-
return { _tag: "Failure", error:
|
|
2045
|
+
} catch (e) {
|
|
2046
|
+
return { _tag: "Failure", error: e };
|
|
1921
2047
|
}
|
|
1922
2048
|
},
|
|
1923
2049
|
async updateItemAttributes({ subscriptionId, lineId, customAttributes }) {
|
|
@@ -1932,8 +2058,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1932
2058
|
);
|
|
1933
2059
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
1934
2060
|
return { _tag: "Success", data: void 0 };
|
|
1935
|
-
} catch (
|
|
1936
|
-
return { _tag: "Failure", error:
|
|
2061
|
+
} catch (e) {
|
|
2062
|
+
return { _tag: "Failure", error: e };
|
|
1937
2063
|
}
|
|
1938
2064
|
},
|
|
1939
2065
|
async updateAttributes({ subscriptionId, customAttributes }) {
|
|
@@ -1948,8 +2074,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1948
2074
|
);
|
|
1949
2075
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
1950
2076
|
return { _tag: "Success", data: void 0 };
|
|
1951
|
-
} catch (
|
|
1952
|
-
return { _tag: "Failure", error:
|
|
2077
|
+
} catch (e) {
|
|
2078
|
+
return { _tag: "Failure", error: e };
|
|
1953
2079
|
}
|
|
1954
2080
|
},
|
|
1955
2081
|
async skipLineItem({ subscriptionId, lineId, nextBillingDate }) {
|
|
@@ -1964,8 +2090,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1964
2090
|
);
|
|
1965
2091
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
1966
2092
|
return { _tag: "Success", data: void 0 };
|
|
1967
|
-
} catch (
|
|
1968
|
-
return { _tag: "Failure", error:
|
|
2093
|
+
} catch (e) {
|
|
2094
|
+
return { _tag: "Failure", error: e };
|
|
1969
2095
|
}
|
|
1970
2096
|
},
|
|
1971
2097
|
async updateBoxItems({ subscriptionId, parentId, items, shippingMethodHandle }) {
|
|
@@ -1980,8 +2106,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
1980
2106
|
);
|
|
1981
2107
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
1982
2108
|
return { _tag: "Success", data: void 0 };
|
|
1983
|
-
} catch (
|
|
1984
|
-
return { _tag: "Failure", error:
|
|
2109
|
+
} catch (e) {
|
|
2110
|
+
return { _tag: "Failure", error: e };
|
|
1985
2111
|
}
|
|
1986
2112
|
},
|
|
1987
2113
|
async addDiscount({ subscriptionId, code }) {
|
|
@@ -2007,10 +2133,10 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2007
2133
|
return { _tag: "Failure", error: { kind: "UNKNOWN", message: `HTTP ${res.status}` } };
|
|
2008
2134
|
}
|
|
2009
2135
|
return { _tag: "Success", data: void 0 };
|
|
2010
|
-
} catch (
|
|
2136
|
+
} catch (e) {
|
|
2011
2137
|
return {
|
|
2012
2138
|
_tag: "Failure",
|
|
2013
|
-
error: { kind: "NETWORK", message:
|
|
2139
|
+
error: { kind: "NETWORK", message: e instanceof Error ? e.message : void 0 }
|
|
2014
2140
|
};
|
|
2015
2141
|
}
|
|
2016
2142
|
},
|
|
@@ -2032,10 +2158,10 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2032
2158
|
return { _tag: "Failure", error: { kind: "UNKNOWN", message: `HTTP ${res.status}` } };
|
|
2033
2159
|
}
|
|
2034
2160
|
return { _tag: "Success", data: void 0 };
|
|
2035
|
-
} catch (
|
|
2161
|
+
} catch (e) {
|
|
2036
2162
|
return {
|
|
2037
2163
|
_tag: "Failure",
|
|
2038
|
-
error: { kind: "NETWORK", message:
|
|
2164
|
+
error: { kind: "NETWORK", message: e instanceof Error ? e.message : void 0 }
|
|
2039
2165
|
};
|
|
2040
2166
|
}
|
|
2041
2167
|
},
|
|
@@ -2053,8 +2179,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2053
2179
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2054
2180
|
const data = await res.json();
|
|
2055
2181
|
return { _tag: "Success", data: mapSubscription(data) };
|
|
2056
|
-
} catch (
|
|
2057
|
-
return { _tag: "Failure", error:
|
|
2182
|
+
} catch (e) {
|
|
2183
|
+
return { _tag: "Failure", error: e };
|
|
2058
2184
|
}
|
|
2059
2185
|
},
|
|
2060
2186
|
// PATCH /customer/v1/subscriptions/{id} with the full customer-visible set.
|
|
@@ -2071,8 +2197,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2071
2197
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2072
2198
|
const data = await res.json();
|
|
2073
2199
|
return { _tag: "Success", data: mapSubscription(data) };
|
|
2074
|
-
} catch (
|
|
2075
|
-
return { _tag: "Failure", error:
|
|
2200
|
+
} catch (e) {
|
|
2201
|
+
return { _tag: "Failure", error: e };
|
|
2076
2202
|
}
|
|
2077
2203
|
},
|
|
2078
2204
|
async resume({ subscriptionId }) {
|
|
@@ -2084,8 +2210,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2084
2210
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2085
2211
|
const data = await res.json();
|
|
2086
2212
|
return { _tag: "Success", data: mapSubscription(data) };
|
|
2087
|
-
} catch (
|
|
2088
|
-
return { _tag: "Failure", error:
|
|
2213
|
+
} catch (e) {
|
|
2214
|
+
return { _tag: "Failure", error: e };
|
|
2089
2215
|
}
|
|
2090
2216
|
},
|
|
2091
2217
|
async pause({ subscriptionId }) {
|
|
@@ -2097,8 +2223,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2097
2223
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2098
2224
|
const data = await res.json();
|
|
2099
2225
|
return { _tag: "Success", data: mapSubscription(data) };
|
|
2100
|
-
} catch (
|
|
2101
|
-
return { _tag: "Failure", error:
|
|
2226
|
+
} catch (e) {
|
|
2227
|
+
return { _tag: "Failure", error: e };
|
|
2102
2228
|
}
|
|
2103
2229
|
},
|
|
2104
2230
|
async reactivate({ subscriptionId }) {
|
|
@@ -2110,8 +2236,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2110
2236
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2111
2237
|
const data = await res.json();
|
|
2112
2238
|
return { _tag: "Success", data: mapSubscription(data) };
|
|
2113
|
-
} catch (
|
|
2114
|
-
return { _tag: "Failure", error:
|
|
2239
|
+
} catch (e) {
|
|
2240
|
+
return { _tag: "Failure", error: e };
|
|
2115
2241
|
}
|
|
2116
2242
|
},
|
|
2117
2243
|
async cancel({ subscriptionId, reason }) {
|
|
@@ -2127,8 +2253,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2127
2253
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2128
2254
|
const data = await res.json();
|
|
2129
2255
|
return { _tag: "Success", data: mapSubscription(data) };
|
|
2130
|
-
} catch (
|
|
2131
|
-
return { _tag: "Failure", error:
|
|
2256
|
+
} catch (e) {
|
|
2257
|
+
return { _tag: "Failure", error: e };
|
|
2132
2258
|
}
|
|
2133
2259
|
},
|
|
2134
2260
|
// Legacy endpoint — no /customer/v1/subscriptions/{id}/plans exists yet.
|
|
@@ -2140,8 +2266,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2140
2266
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2141
2267
|
const data = await res.json();
|
|
2142
2268
|
return { _tag: "Success", data };
|
|
2143
|
-
} catch (
|
|
2144
|
-
return { _tag: "Failure", error:
|
|
2269
|
+
} catch (e) {
|
|
2270
|
+
return { _tag: "Failure", error: e };
|
|
2145
2271
|
}
|
|
2146
2272
|
},
|
|
2147
2273
|
// Legacy endpoint — no /customer/v1 equivalent exists yet.
|
|
@@ -2153,8 +2279,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2153
2279
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2154
2280
|
const data = await res.json();
|
|
2155
2281
|
return { _tag: "Success", data: (data == null ? void 0 : data.id) ?? null };
|
|
2156
|
-
} catch (
|
|
2157
|
-
return { _tag: "Failure", error:
|
|
2282
|
+
} catch (e) {
|
|
2283
|
+
return { _tag: "Failure", error: e };
|
|
2158
2284
|
}
|
|
2159
2285
|
},
|
|
2160
2286
|
// Legacy endpoint — no /customer/v1/subscriptions/{id}/upsells exists yet.
|
|
@@ -2165,24 +2291,24 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2165
2291
|
);
|
|
2166
2292
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2167
2293
|
const data = await res.json();
|
|
2168
|
-
const products = data.map((
|
|
2294
|
+
const products = data.map((p3) => {
|
|
2169
2295
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2170
2296
|
return {
|
|
2171
|
-
id:
|
|
2172
|
-
variantId: ((_b = (_a =
|
|
2173
|
-
title:
|
|
2174
|
-
imageUrl: ((_c =
|
|
2297
|
+
id: p3.id,
|
|
2298
|
+
variantId: ((_b = (_a = p3.variants) == null ? void 0 : _a[0]) == null ? void 0 : _b.id) ?? "",
|
|
2299
|
+
title: p3.title ?? "",
|
|
2300
|
+
imageUrl: ((_c = p3.featuredImage) == null ? void 0 : _c.url) ?? void 0,
|
|
2175
2301
|
price: {
|
|
2176
|
-
amount: String(((_f = (_e = (_d =
|
|
2177
|
-
currencyCode: ((_i = (_h = (_g =
|
|
2302
|
+
amount: String(((_f = (_e = (_d = p3.variants) == null ? void 0 : _d[0]) == null ? void 0 : _e.currentPrice) == null ? void 0 : _f.amount) ?? 0),
|
|
2303
|
+
currencyCode: ((_i = (_h = (_g = p3.variants) == null ? void 0 : _g[0]) == null ? void 0 : _h.currentPrice) == null ? void 0 : _i.currencyCode) ?? ""
|
|
2178
2304
|
},
|
|
2179
2305
|
// recurring comes from the upsell rule on variants[0]; present in PreparedProductSchema
|
|
2180
|
-
recurring: (_k = (_j =
|
|
2306
|
+
recurring: (_k = (_j = p3.variants) == null ? void 0 : _j[0]) == null ? void 0 : _k.recurring
|
|
2181
2307
|
};
|
|
2182
2308
|
});
|
|
2183
2309
|
return { _tag: "Success", data: products };
|
|
2184
|
-
} catch (
|
|
2185
|
-
return { _tag: "Failure", error:
|
|
2310
|
+
} catch (e) {
|
|
2311
|
+
return { _tag: "Failure", error: e };
|
|
2186
2312
|
}
|
|
2187
2313
|
},
|
|
2188
2314
|
// Legacy endpoint — no /customer/v1/subscriptions/{id}/upsells POST exists yet.
|
|
@@ -2202,8 +2328,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2202
2328
|
);
|
|
2203
2329
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2204
2330
|
return { _tag: "Success", data: void 0 };
|
|
2205
|
-
} catch (
|
|
2206
|
-
return { _tag: "Failure", error:
|
|
2331
|
+
} catch (e) {
|
|
2332
|
+
return { _tag: "Failure", error: e };
|
|
2207
2333
|
}
|
|
2208
2334
|
},
|
|
2209
2335
|
// Legacy endpoint — no /customer/v1 equivalent exists yet.
|
|
@@ -2219,8 +2345,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2219
2345
|
_tag: "Success",
|
|
2220
2346
|
data: { id: data.id, createdAt: data.createdAt }
|
|
2221
2347
|
};
|
|
2222
|
-
} catch (
|
|
2223
|
-
return { _tag: "Failure", error:
|
|
2348
|
+
} catch (e) {
|
|
2349
|
+
return { _tag: "Failure", error: e };
|
|
2224
2350
|
}
|
|
2225
2351
|
},
|
|
2226
2352
|
// Legacy endpoints, split by stage (see SubscriptionService.renewNow docs):
|
|
@@ -2240,8 +2366,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2240
2366
|
result: (body == null ? void 0 : body.result) ?? "success"
|
|
2241
2367
|
}
|
|
2242
2368
|
};
|
|
2243
|
-
} catch (
|
|
2244
|
-
return { _tag: "Failure", error:
|
|
2369
|
+
} catch (e) {
|
|
2370
|
+
return { _tag: "Failure", error: e };
|
|
2245
2371
|
}
|
|
2246
2372
|
},
|
|
2247
2373
|
// Legacy endpoint — POST /plan returns 204; re-fetch to return the updated subscription.
|
|
@@ -2263,8 +2389,8 @@ function createApiSubscriptionAdapter(fetcher) {
|
|
|
2263
2389
|
_tag: "Failure",
|
|
2264
2390
|
error: "Subscription not found after frequency change"
|
|
2265
2391
|
};
|
|
2266
|
-
} catch (
|
|
2267
|
-
return { _tag: "Failure", error:
|
|
2392
|
+
} catch (e) {
|
|
2393
|
+
return { _tag: "Failure", error: e };
|
|
2268
2394
|
}
|
|
2269
2395
|
}
|
|
2270
2396
|
};
|
|
@@ -2325,13 +2451,13 @@ function mapScheduleOrder(order) {
|
|
|
2325
2451
|
};
|
|
2326
2452
|
}),
|
|
2327
2453
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2328
|
-
discounts: (order.discounts ?? []).map((
|
|
2454
|
+
discounts: (order.discounts ?? []).map((d2) => {
|
|
2329
2455
|
var _a, _b, _c;
|
|
2330
2456
|
return {
|
|
2331
|
-
id:
|
|
2332
|
-
title:
|
|
2333
|
-
type: ((_a =
|
|
2334
|
-
value: ((_b =
|
|
2457
|
+
id: d2.id,
|
|
2458
|
+
title: d2.title ?? void 0,
|
|
2459
|
+
type: ((_a = d2.value) == null ? void 0 : _a.type) === "fixed-amount" ? "fixed_amount" : "percentage",
|
|
2460
|
+
value: ((_b = d2.value) == null ? void 0 : _b.amount) ?? ((_c = d2.value) == null ? void 0 : _c.percentage) ?? 0
|
|
2335
2461
|
};
|
|
2336
2462
|
})
|
|
2337
2463
|
};
|
|
@@ -2370,26 +2496,26 @@ function buildSkipItemMatcher(params) {
|
|
|
2370
2496
|
const DELIVERY_PRICE = 5;
|
|
2371
2497
|
const DELIVERY_OFFSET_DAYS = 2;
|
|
2372
2498
|
function toPrice(amount) {
|
|
2373
|
-
const
|
|
2374
|
-
return Number.isFinite(
|
|
2499
|
+
const n2 = Number.parseFloat(amount ?? "0");
|
|
2500
|
+
return Number.isFinite(n2) ? n2 : 0;
|
|
2375
2501
|
}
|
|
2376
2502
|
function addInterval(date, interval, units) {
|
|
2377
|
-
const
|
|
2503
|
+
const d2 = new Date(date);
|
|
2378
2504
|
switch (interval) {
|
|
2379
2505
|
case "DAY":
|
|
2380
|
-
|
|
2506
|
+
d2.setDate(d2.getDate() + units);
|
|
2381
2507
|
break;
|
|
2382
2508
|
case "WEEK":
|
|
2383
|
-
|
|
2509
|
+
d2.setDate(d2.getDate() + units * 7);
|
|
2384
2510
|
break;
|
|
2385
2511
|
case "YEAR":
|
|
2386
|
-
|
|
2512
|
+
d2.setFullYear(d2.getFullYear() + units);
|
|
2387
2513
|
break;
|
|
2388
2514
|
default:
|
|
2389
|
-
|
|
2515
|
+
d2.setMonth(d2.getMonth() + units);
|
|
2390
2516
|
break;
|
|
2391
2517
|
}
|
|
2392
|
-
return
|
|
2518
|
+
return d2;
|
|
2393
2519
|
}
|
|
2394
2520
|
function mapItem(sub, item, cycle) {
|
|
2395
2521
|
var _a, _b;
|
|
@@ -2447,11 +2573,11 @@ function projectUpcomingOrders(sub, count) {
|
|
|
2447
2573
|
deliveryDate: deliveryDate.toISOString(),
|
|
2448
2574
|
status: "scheduled",
|
|
2449
2575
|
items,
|
|
2450
|
-
discounts: sub.discounts.map((
|
|
2451
|
-
id:
|
|
2452
|
-
title:
|
|
2453
|
-
type:
|
|
2454
|
-
value:
|
|
2576
|
+
discounts: sub.discounts.map((d2) => ({
|
|
2577
|
+
id: d2.id,
|
|
2578
|
+
title: d2.code,
|
|
2579
|
+
type: d2.type,
|
|
2580
|
+
value: d2.value
|
|
2455
2581
|
}))
|
|
2456
2582
|
});
|
|
2457
2583
|
}
|
|
@@ -2479,7 +2605,7 @@ function applyAdjustments(orders, stored) {
|
|
|
2479
2605
|
);
|
|
2480
2606
|
const subtotal = items.reduce((sum, it) => sum + it.totalPrice, 0);
|
|
2481
2607
|
next = { ...next, items, subtotal };
|
|
2482
|
-
if (items.length > 0 && items.every((
|
|
2608
|
+
if (items.length > 0 && items.every((i3) => i3.skipped)) {
|
|
2483
2609
|
next = { ...next, skipped: true, status: "skipped", deliveryPrice: 0 };
|
|
2484
2610
|
}
|
|
2485
2611
|
}
|
|
@@ -2514,11 +2640,11 @@ function createMockSchedulesAdapter(subscriptions = createMockSubscriptionAdapte
|
|
|
2514
2640
|
const iso = toIsoOrNull(opts.date);
|
|
2515
2641
|
const target = iso == null ? void 0 : iso.split("T")[0];
|
|
2516
2642
|
const match = target ? orders.find(
|
|
2517
|
-
(
|
|
2643
|
+
(o3) => o3.deliveryDate.split("T")[0] === target || o3.date.split("T")[0] === target
|
|
2518
2644
|
) : void 0;
|
|
2519
2645
|
return match ? match.cycleIndex : null;
|
|
2520
2646
|
}
|
|
2521
|
-
const firstScheduled = orders.find((
|
|
2647
|
+
const firstScheduled = orders.find((o3) => o3.status === "scheduled");
|
|
2522
2648
|
return (firstScheduled == null ? void 0 : firstScheduled.cycleIndex) ?? null;
|
|
2523
2649
|
}
|
|
2524
2650
|
async function recordAdjustment(subscriptionId, opts, buildAction, matcherOverride) {
|
|
@@ -2551,25 +2677,25 @@ function createMockSchedulesAdapter(subscriptions = createMockSubscriptionAdapte
|
|
|
2551
2677
|
const subs = await subscriptionsToProject(subscriptionId);
|
|
2552
2678
|
const skipCount = new Set(
|
|
2553
2679
|
stored.filter(
|
|
2554
|
-
(
|
|
2555
|
-
).map((
|
|
2680
|
+
(s2) => s2.adjustment.action.type === "SKIP_ORDER" || s2.adjustment.action.type === "SKIP_ITEM"
|
|
2681
|
+
).map((s2) => `${s2.subscriptionId}:${s2.cycle}`)
|
|
2556
2682
|
).size;
|
|
2557
2683
|
const depth = excludeSkipped ? count + skipCount : count;
|
|
2558
2684
|
const orders = subs.flatMap(
|
|
2559
2685
|
(sub) => applyAdjustments(projectUpcomingOrders(sub, depth), stored)
|
|
2560
|
-
).filter((
|
|
2561
|
-
(
|
|
2686
|
+
).filter((o3) => excludeSkipped ? !o3.skipped : true).map(
|
|
2687
|
+
(o3) => (
|
|
2562
2688
|
// Mirror backend removeSkippedItems: the billable view also strips
|
|
2563
2689
|
// skipped lines from surviving (partially-skipped) orders. No
|
|
2564
2690
|
// recompute needed — skipped lines already carry totalPrice 0 (R4).
|
|
2565
|
-
excludeSkipped &&
|
|
2691
|
+
excludeSkipped && o3.items.some((i3) => i3.skipped) ? { ...o3, items: o3.items.filter((i3) => !i3.skipped) } : o3
|
|
2566
2692
|
)
|
|
2567
|
-
).sort((
|
|
2693
|
+
).sort((a2, b3) => a2.date.localeCompare(b3.date));
|
|
2568
2694
|
return { _tag: "Success", data: orders.slice(0, count) };
|
|
2569
2695
|
},
|
|
2570
2696
|
async getAdjustments() {
|
|
2571
2697
|
await new Promise((r2) => setTimeout(r2, 200));
|
|
2572
|
-
return { _tag: "Success", data: stored.map((
|
|
2698
|
+
return { _tag: "Success", data: stored.map((s2) => s2.adjustment) };
|
|
2573
2699
|
},
|
|
2574
2700
|
async skipOrder({ subscriptionId, cycle, date }) {
|
|
2575
2701
|
await new Promise((r2) => setTimeout(r2, 300));
|
|
@@ -2642,7 +2768,7 @@ function createMockSchedulesAdapter(subscriptions = createMockSubscriptionAdapte
|
|
|
2642
2768
|
},
|
|
2643
2769
|
async removeAdjustment({ adjustmentId }) {
|
|
2644
2770
|
await new Promise((r2) => setTimeout(r2, 200));
|
|
2645
|
-
stored = stored.filter((
|
|
2771
|
+
stored = stored.filter((s2) => s2.adjustment.id !== adjustmentId);
|
|
2646
2772
|
return { _tag: "Success", data: void 0 };
|
|
2647
2773
|
}
|
|
2648
2774
|
};
|
|
@@ -2657,8 +2783,8 @@ function createApiSchedulesAdapter(fetcher) {
|
|
|
2657
2783
|
});
|
|
2658
2784
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2659
2785
|
return { _tag: "Success", data: void 0 };
|
|
2660
|
-
} catch (
|
|
2661
|
-
return { _tag: "Failure", error:
|
|
2786
|
+
} catch (e) {
|
|
2787
|
+
return { _tag: "Failure", error: e };
|
|
2662
2788
|
}
|
|
2663
2789
|
}
|
|
2664
2790
|
return {
|
|
@@ -2671,8 +2797,8 @@ function createApiSchedulesAdapter(fetcher) {
|
|
|
2671
2797
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2672
2798
|
const data = await res.json();
|
|
2673
2799
|
return { _tag: "Success", data: (data.orders ?? []).map(mapScheduleOrder) };
|
|
2674
|
-
} catch (
|
|
2675
|
-
return { _tag: "Failure", error:
|
|
2800
|
+
} catch (e) {
|
|
2801
|
+
return { _tag: "Failure", error: e };
|
|
2676
2802
|
}
|
|
2677
2803
|
},
|
|
2678
2804
|
async getAdjustments() {
|
|
@@ -2688,10 +2814,10 @@ function createApiSchedulesAdapter(fetcher) {
|
|
|
2688
2814
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2689
2815
|
const body = await res.json();
|
|
2690
2816
|
all.push(
|
|
2691
|
-
...body.data.map((
|
|
2692
|
-
id:
|
|
2693
|
-
matcher:
|
|
2694
|
-
action:
|
|
2817
|
+
...body.data.map((a2) => ({
|
|
2818
|
+
id: a2.id,
|
|
2819
|
+
matcher: a2.matcher,
|
|
2820
|
+
action: a2.action
|
|
2695
2821
|
}))
|
|
2696
2822
|
);
|
|
2697
2823
|
if (!body.hasNextPage) return { _tag: "Success", data: all };
|
|
@@ -2707,8 +2833,8 @@ function createApiSchedulesAdapter(fetcher) {
|
|
|
2707
2833
|
_tag: "Failure",
|
|
2708
2834
|
error: "Adjustments pagination exceeded 50 pages"
|
|
2709
2835
|
};
|
|
2710
|
-
} catch (
|
|
2711
|
-
return { _tag: "Failure", error:
|
|
2836
|
+
} catch (e) {
|
|
2837
|
+
return { _tag: "Failure", error: e };
|
|
2712
2838
|
}
|
|
2713
2839
|
},
|
|
2714
2840
|
async skipOrder({ cycle, date }) {
|
|
@@ -2784,16 +2910,16 @@ function createApiSchedulesAdapter(fetcher) {
|
|
|
2784
2910
|
);
|
|
2785
2911
|
if (!res.ok) return { _tag: "Failure", error: `HTTP ${res.status}` };
|
|
2786
2912
|
return { _tag: "Success", data: void 0 };
|
|
2787
|
-
} catch (
|
|
2788
|
-
return { _tag: "Failure", error:
|
|
2913
|
+
} catch (e) {
|
|
2914
|
+
return { _tag: "Failure", error: e };
|
|
2789
2915
|
}
|
|
2790
2916
|
}
|
|
2791
2917
|
};
|
|
2792
2918
|
}
|
|
2793
2919
|
const SchedulesServiceContext = createContext("services/schedules");
|
|
2794
|
-
function isSameCalendarDay(
|
|
2795
|
-
const da = new Date(
|
|
2796
|
-
const db = new Date(
|
|
2920
|
+
function isSameCalendarDay(a2, b3) {
|
|
2921
|
+
const da = new Date(a2);
|
|
2922
|
+
const db = new Date(b3);
|
|
2797
2923
|
if (Number.isNaN(da.getTime()) || Number.isNaN(db.getTime())) return false;
|
|
2798
2924
|
return da.toISOString().slice(0, 10) === db.toISOString().slice(0, 10);
|
|
2799
2925
|
}
|
|
@@ -2873,26 +2999,26 @@ function createSchedulesService(adapter, opts) {
|
|
|
2873
2999
|
const adjustments = await adapter.getAdjustments();
|
|
2874
3000
|
if (adjustments._tag === "Failure") return adjustments;
|
|
2875
3001
|
const covering = adjustments.data.filter(
|
|
2876
|
-
(
|
|
3002
|
+
(a2) => a2.action.type === "SKIP_ITEM" && a2.action.input.lineIds.includes(lineId) && matcherAffects(a2.matcher, { cycle, date })
|
|
2877
3003
|
);
|
|
2878
3004
|
if (covering.length === 0) {
|
|
2879
3005
|
return { _tag: "Failure", error: "No skip found for this item" };
|
|
2880
3006
|
}
|
|
2881
|
-
if (covering.some((
|
|
3007
|
+
if (covering.some((a2) => a2.action.input.lineIds.length > 1)) {
|
|
2882
3008
|
return {
|
|
2883
3009
|
_tag: "Failure",
|
|
2884
3010
|
error: "This item was skipped together with other items and can't be unskipped individually"
|
|
2885
3011
|
};
|
|
2886
3012
|
}
|
|
2887
|
-
if (covering.some((
|
|
3013
|
+
if (covering.some((a2) => !matcherExactlyTargets(a2.matcher, { cycle, date }))) {
|
|
2888
3014
|
return {
|
|
2889
3015
|
_tag: "Failure",
|
|
2890
3016
|
error: "This skip also affects another order and can't be removed from here"
|
|
2891
3017
|
};
|
|
2892
3018
|
}
|
|
2893
3019
|
let deleted = 0;
|
|
2894
|
-
for (const
|
|
2895
|
-
const result = await adapter.removeAdjustment({ adjustmentId:
|
|
3020
|
+
for (const a2 of covering) {
|
|
3021
|
+
const result = await adapter.removeAdjustment({ adjustmentId: a2.id });
|
|
2896
3022
|
if (result._tag === "Failure") {
|
|
2897
3023
|
if (deleted > 0) await notifyChanged(subscriptionId);
|
|
2898
3024
|
return result;
|
|
@@ -3127,7 +3253,7 @@ function createSubscriptionService(adapter) {
|
|
|
3127
3253
|
function getDefaultBlockForAction(actionType, actionConfig, blockId) {
|
|
3128
3254
|
const blockName = `action:${actionType}`;
|
|
3129
3255
|
const definedBlocks = getDefinedBlocks();
|
|
3130
|
-
const exists = definedBlocks.some((
|
|
3256
|
+
const exists = definedBlocks.some((b3) => b3.name === blockName);
|
|
3131
3257
|
if (!exists) {
|
|
3132
3258
|
throw new Error(
|
|
3133
3259
|
`No default block registered for action type "${actionType}". Expected a block named "${blockName}" to be registered in blocks-extensions.`
|
|
@@ -3137,7 +3263,7 @@ function getDefaultBlockForAction(actionType, actionConfig, blockId) {
|
|
|
3137
3263
|
}
|
|
3138
3264
|
function hasDefaultBlockForAction(actionType) {
|
|
3139
3265
|
const blockName = `action:${actionType}`;
|
|
3140
|
-
return getDefinedBlocks().some((
|
|
3266
|
+
return getDefinedBlocks().some((b3) => b3.name === blockName);
|
|
3141
3267
|
}
|
|
3142
3268
|
const WorkflowServiceContext = createContext("services/workflow");
|
|
3143
3269
|
const RUN_SCOPED_RESET = {
|
|
@@ -3275,7 +3401,7 @@ function createWorkflowService(deps) {
|
|
|
3275
3401
|
outcome: null
|
|
3276
3402
|
});
|
|
3277
3403
|
if (editor.isEditorMode) {
|
|
3278
|
-
const displayStepId = isInitialResponse && previewStepId && ((_e = data.interactiveSteps) == null ? void 0 : _e.some((
|
|
3404
|
+
const displayStepId = isInitialResponse && previewStepId && ((_e = data.interactiveSteps) == null ? void 0 : _e.some((s2) => s2.stepId === previewStepId)) ? previewStepId : currentStepId;
|
|
3279
3405
|
const overlayBlocks = deps.themeState.overlay.blocks.value;
|
|
3280
3406
|
const rootBlock = overlayBlocks[0];
|
|
3281
3407
|
const stepSlot = displayStepId ? (_f = rootBlock == null ? void 0 : rootBlock.slots) == null ? void 0 : _f[displayStepId] : null;
|
|
@@ -3370,7 +3496,7 @@ function createWorkflowService(deps) {
|
|
|
3370
3496
|
const presets = {};
|
|
3371
3497
|
const baseLabelFor = (step) => {
|
|
3372
3498
|
var _a;
|
|
3373
|
-
return ((_a = getDefinedBlocks().find((
|
|
3499
|
+
return ((_a = getDefinedBlocks().find((b3) => b3.name === `action:${step.actionType}`)) == null ? void 0 : _a.displayName) ?? step.stepId;
|
|
3374
3500
|
};
|
|
3375
3501
|
const totalCounts = /* @__PURE__ */ new Map();
|
|
3376
3502
|
for (const step of allSteps) {
|
|
@@ -3965,9 +4091,9 @@ const gridV1Engine = {
|
|
|
3965
4091
|
case "resize": {
|
|
3966
4092
|
const current = layout.items[cmd.blockId];
|
|
3967
4093
|
if (current) {
|
|
3968
|
-
const
|
|
3969
|
-
const
|
|
3970
|
-
layout.items[cmd.blockId] = { ...current, w:
|
|
4094
|
+
const w4 = Math.max(1, Math.min(cmd.size.w, ctx2.cols - current.c));
|
|
4095
|
+
const h2 = Math.max(1, cmd.size.h);
|
|
4096
|
+
layout.items[cmd.blockId] = { ...current, w: w4, h: h2 };
|
|
3971
4097
|
}
|
|
3972
4098
|
break;
|
|
3973
4099
|
}
|
|
@@ -4034,7 +4160,7 @@ function insertRectRelative(doc, args) {
|
|
|
4034
4160
|
if (!layout) continue;
|
|
4035
4161
|
const target = layout.items[args.targetId];
|
|
4036
4162
|
if (!target) continue;
|
|
4037
|
-
const cols = ((_a = doc.breakpoints.find((
|
|
4163
|
+
const cols = ((_a = doc.breakpoints.find((b3) => b3.id === breakpointId)) == null ? void 0 : _a.cols) ?? ((_b = layout.grid) == null ? void 0 : _b.cols) ?? DEFAULT_GRID.cols;
|
|
4038
4164
|
const insertRow = args.position === "before" ? target.r : target.r + target.h;
|
|
4039
4165
|
for (const [id, rect] of Object.entries(layout.items)) {
|
|
4040
4166
|
if (id === args.blockId) continue;
|
|
@@ -4085,18 +4211,19 @@ export {
|
|
|
4085
4211
|
AuthenticationError,
|
|
4086
4212
|
AuthenticationErrorReason,
|
|
4087
4213
|
B as BlockWrapperEvent,
|
|
4088
|
-
|
|
4089
|
-
|
|
4214
|
+
q as ContextProvideEvent,
|
|
4215
|
+
t as ContextRequestEvent,
|
|
4090
4216
|
CustomerServiceContext,
|
|
4091
|
-
|
|
4092
|
-
|
|
4217
|
+
h as DEFAULT_BREAKPOINTS,
|
|
4218
|
+
i2 as DEFAULT_GLOBAL_STYLES,
|
|
4093
4219
|
DEFAULT_GRID,
|
|
4094
4220
|
DEFAULT_NEW_BLOCK_HEIGHT,
|
|
4095
4221
|
DISCOUNT_REJECTION_REASONS,
|
|
4096
4222
|
GRID_V1_ENGINE_ID,
|
|
4097
|
-
|
|
4223
|
+
L2 as LAYOUT_SCOPE_ATTR,
|
|
4098
4224
|
LoginServiceContext,
|
|
4099
|
-
|
|
4225
|
+
OrderServiceContext,
|
|
4226
|
+
OverlayServiceContext,
|
|
4100
4227
|
P as PAGE_ROOT_SLOT,
|
|
4101
4228
|
ProductServiceContext,
|
|
4102
4229
|
RouterServiceContext,
|
|
@@ -4107,99 +4234,105 @@ export {
|
|
|
4107
4234
|
u as Signal,
|
|
4108
4235
|
StateContext,
|
|
4109
4236
|
SubscriptionServiceContext,
|
|
4110
|
-
|
|
4237
|
+
a as ThemeStateContext,
|
|
4111
4238
|
T as TranslationContext,
|
|
4112
4239
|
WorkflowServiceContext,
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4240
|
+
v as __recordDevtoolsInstance,
|
|
4241
|
+
_ as __recordDevtoolsPropSetter,
|
|
4242
|
+
x as attachEmptyTracking,
|
|
4243
|
+
c as backfillInstanceDefaults,
|
|
4244
|
+
b2 as buildGridLayout,
|
|
4245
|
+
j as buildLayoutCss,
|
|
4117
4246
|
canvasMode,
|
|
4118
4247
|
clampRect,
|
|
4119
|
-
|
|
4248
|
+
k2 as classifyRowDividers,
|
|
4120
4249
|
clearAllSurfaceContexts,
|
|
4121
4250
|
clearLayoutModeAdapter,
|
|
4122
4251
|
compactItems,
|
|
4123
|
-
|
|
4252
|
+
l2 as compactLayoutDocument,
|
|
4124
4253
|
w as computed,
|
|
4125
4254
|
createApiCustomerAdapter,
|
|
4126
4255
|
createApiLoginAdapter,
|
|
4127
|
-
|
|
4256
|
+
createApiOrderAdapter,
|
|
4128
4257
|
createApiProductAdapter,
|
|
4129
4258
|
createApiSchedulesAdapter,
|
|
4130
4259
|
createApiSubscriptionAdapter,
|
|
4131
4260
|
createBlockInstance,
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4261
|
+
y as createBlockInstanceFromJSON,
|
|
4262
|
+
g as createBlockInstanceFromObject,
|
|
4263
|
+
z as createCeRenderer,
|
|
4135
4264
|
createContext,
|
|
4136
4265
|
createCustomerService,
|
|
4137
|
-
|
|
4266
|
+
m as createDefaultLayoutDocument,
|
|
4138
4267
|
createLoginService,
|
|
4139
4268
|
createMockCustomerAdapter,
|
|
4140
4269
|
createMockLoginAdapter,
|
|
4141
|
-
|
|
4270
|
+
createMockOrderAdapter,
|
|
4142
4271
|
createMockProductAdapter,
|
|
4143
4272
|
createMockRouterService,
|
|
4144
4273
|
createMockSchedulesAdapter,
|
|
4145
4274
|
createMockSubscriptionAdapter,
|
|
4146
4275
|
createMockWorkflowApiAdapter,
|
|
4147
|
-
|
|
4276
|
+
createOrderService,
|
|
4277
|
+
createOverlayService,
|
|
4148
4278
|
createProductService,
|
|
4149
4279
|
createRouterService,
|
|
4150
4280
|
createSchedulesService,
|
|
4151
|
-
|
|
4281
|
+
A as createSelectedBlock,
|
|
4152
4282
|
createSettingsService,
|
|
4153
4283
|
createShopService,
|
|
4154
4284
|
createState,
|
|
4155
4285
|
createSubscriptionService,
|
|
4156
|
-
|
|
4157
|
-
|
|
4286
|
+
n as createThemeState,
|
|
4287
|
+
o2 as createTranslationService,
|
|
4158
4288
|
createWorkflowApiAdapter,
|
|
4159
4289
|
createWorkflowService,
|
|
4160
4290
|
defineBlock,
|
|
4161
|
-
|
|
4162
|
-
|
|
4291
|
+
D as defineBlockRuntime,
|
|
4292
|
+
defineOverlayWrapper,
|
|
4293
|
+
p as deriveLayout,
|
|
4163
4294
|
E as effect,
|
|
4164
4295
|
emitLayoutCommand,
|
|
4165
4296
|
emitLayoutSetRects,
|
|
4166
|
-
|
|
4297
|
+
q2 as expandFillLayoutDocument,
|
|
4167
4298
|
findFreeRect,
|
|
4168
4299
|
getActiveSurfaceContext,
|
|
4169
4300
|
getDefaultBlockForAction,
|
|
4170
4301
|
getDefinedBlocks,
|
|
4302
|
+
F as getDevtoolsBlockState,
|
|
4171
4303
|
getLayoutModeAdapter,
|
|
4172
4304
|
gridV1Engine,
|
|
4173
4305
|
hasDefaultBlockForAction,
|
|
4174
|
-
|
|
4175
|
-
|
|
4306
|
+
G as hasRenderedContent,
|
|
4307
|
+
s as indexOverrides,
|
|
4176
4308
|
i as injectContext,
|
|
4177
4309
|
insertRectRelative,
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4310
|
+
H as isEditorPreview,
|
|
4311
|
+
b as isStubDefinition,
|
|
4312
|
+
t2 as layoutScopeSelector,
|
|
4313
|
+
I as layoutSystemEnabled,
|
|
4182
4314
|
loadBlockRegistry,
|
|
4183
4315
|
loginService,
|
|
4184
4316
|
o as onRegisterBlock,
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4317
|
+
u2 as projectToCss,
|
|
4318
|
+
p2 as projectToGridStack,
|
|
4319
|
+
J as provideContext,
|
|
4320
|
+
v2 as readingOrder,
|
|
4321
|
+
c2 as reconcileLayout,
|
|
4322
|
+
w3 as rectsOverlap,
|
|
4191
4323
|
registerBlock,
|
|
4192
4324
|
registerLayoutModeAdapter,
|
|
4193
4325
|
resetBreakpoint,
|
|
4194
4326
|
r as resolveLayout,
|
|
4195
|
-
|
|
4327
|
+
k as serializeBlocks,
|
|
4196
4328
|
setActiveSurfaceContext,
|
|
4329
|
+
K as setDevtoolsBlockProp,
|
|
4197
4330
|
setLayoutCommandDispatcher,
|
|
4198
4331
|
setLayoutCommandEmitter,
|
|
4199
|
-
|
|
4332
|
+
l as setLayoutSystemEnabled,
|
|
4200
4333
|
d as signal,
|
|
4201
4334
|
subscribeContext,
|
|
4202
|
-
|
|
4335
|
+
L as untracked,
|
|
4203
4336
|
waitForDevBlocksUrl,
|
|
4204
4337
|
w2 as withWrapper
|
|
4205
4338
|
};
|