@wix/himalaya-cli 0.1660.0 → 0.1662.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/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +17 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/audio-record/src/index.d.ts +4 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +26 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/apple-iap-contract.d.ts +12 -3
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/order-refs.d.ts +8 -4
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-v1/src/index.d.ts +26 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +89 -43
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +89 -43
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +8 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members.mjs +4 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{fcafca348b6b973cfc2eadc938ddec3c515c641874cbca1667a43b22e1bf7a39.bin → 5fe817d61d13666ee8e6951d96a873f768ef305462735f6030cce105f1c21488.bin} +1 -1
- package/dist/browser-plane/sw.js +8 -8
- package/dist/cli.mjs +929 -694
- package/dist/preview-assets.generated.bin +0 -0
- package/fixtures/wix-canned.json +1 -0
- package/guides/component-reference.json +13 -4
- package/guides/component-reference.md +26 -6
- package/guides/himi-json-output.md +9 -1
- package/guides/index.json +1 -1
- package/guides/qa-builds.md +7 -4
- package/guides/sdk-reference.json +28 -5
- package/package.json +2 -2
- package/templates/beauty-salon/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/beauty-salon-owner/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/branded-lite/dev/index.ts +791 -169
- package/templates/branded-lite/l10n/en.json +46 -13
- package/templates/branded-lite/l10n/he.json +59 -7
- package/templates/branded-lite/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/branded-lite/tier5-src/wix-spaces-member-detail/index.ts +367 -63
- package/templates/community-club/l10n/he.json +2 -2
- package/templates/community-club/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/community-club-owner/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/conference/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/events-meetups/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/events-meetups-owner/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/gym-fitness/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/gym-fitness-owner/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/nonprofit-cause/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/nonprofit-cause-owner/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/owner-lite/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/podcast-creator/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/podcast-creator-owner/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/portfolio-creative/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/portfolio-creative-owner/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/restaurant/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/restaurant-owner/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/retail-store/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/retail-store-owner/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/salon-spa/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/wholesale-store/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/yoga-studio/tier5-src/_shared/engine-intl.ts +8 -0
- package/templates/yoga-studio-owner/tier5-src/_shared/engine-intl.ts +8 -0
|
@@ -1604,6 +1604,23 @@ export declare function voiceNote(props: {
|
|
|
1604
1604
|
id?: string;
|
|
1605
1605
|
modifiers?: Component["modifiers"];
|
|
1606
1606
|
}): Component;
|
|
1607
|
+
/** #4670 — a live microphone waveform: the ACTIVE `audio_record` recording's level as
|
|
1608
|
+
* scrolling bars, fed natively by the renderer (no worker message per sample). Flat,
|
|
1609
|
+
* low-contrast baseline while nothing records or `activePath` is falsy. Decorative unless
|
|
1610
|
+
* `modifiers.accessibilityLabel` is set. */
|
|
1611
|
+
export declare function liveWaveform(props?: {
|
|
1612
|
+
/** "audio_record" (default; the only source). */
|
|
1613
|
+
source?: string;
|
|
1614
|
+
/** visible bars (default 32, clamped 8..128) */
|
|
1615
|
+
bars?: number;
|
|
1616
|
+
color?: string;
|
|
1617
|
+
height?: number;
|
|
1618
|
+
/** `$service:` boolean binding — draw live while truthy. */
|
|
1619
|
+
activePath?: string;
|
|
1620
|
+
}, opts?: {
|
|
1621
|
+
id?: string;
|
|
1622
|
+
modifiers?: Component["modifiers"];
|
|
1623
|
+
}): Component;
|
|
1607
1624
|
/** Motion grammar (Batch 4) — a Lottie/Rive vector animation. `source` is an
|
|
1608
1625
|
* https URL to the animation JSON or the inline JSON string (ships OTA). Plays
|
|
1609
1626
|
* via lottie-ios / lottie-compose / lottie-web; reduced motion → static last
|
|
@@ -55,7 +55,10 @@ export declare function pause(): Promise<{
|
|
|
55
55
|
export declare function resume(): Promise<{
|
|
56
56
|
resumed: boolean;
|
|
57
57
|
}>;
|
|
58
|
-
/** Subscribe the worker to native-pushed live meter readings
|
|
58
|
+
/** Subscribe the worker to native-pushed live meter readings, delivered at most 10 times a
|
|
59
|
+
* second while a `start()` recording runs (iOS, macOS and Android; web answers a snapshot).
|
|
60
|
+
* For an on-screen meter, prefer the `LiveWaveform` component: the renderer reads the level
|
|
61
|
+
* itself, so the worker does not re-render the screen on every reading. */
|
|
59
62
|
export declare function subscribeLevel(handler: string): Promise<void>;
|
|
60
63
|
/** Stop and discard the in-progress recording. */
|
|
61
64
|
export declare function cancel(): Promise<{
|
package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts
CHANGED
|
@@ -2018,6 +2018,28 @@ export interface VoiceNoteProps {
|
|
|
2018
2018
|
/** resample target (default 48, clamped 8..128). */
|
|
2019
2019
|
barCount?: number;
|
|
2020
2020
|
}
|
|
2021
|
+
/**
|
|
2022
|
+
* A live microphone waveform — the ACTIVE `audio_record` recording's level,
|
|
2023
|
+
* drawn as bars that scroll in from the trailing edge.
|
|
2024
|
+
*
|
|
2025
|
+
* Renderer-fed: every arm subscribes to the host's level stream on appear, samples it
|
|
2026
|
+
* at display rate (<= 60 Hz) and never messages the worker. Levels are on the same
|
|
2027
|
+
* 0..1 dBFS curve as `VoiceNote.waveform`. Flat, low-contrast baseline while no
|
|
2028
|
+
* recording is active or `activePath` resolves falsy. Decorative: hidden from
|
|
2029
|
+
* assistive tech unless `modifiers.accessibilityLabel` is set.
|
|
2030
|
+
*/
|
|
2031
|
+
export interface LiveWaveformProps {
|
|
2032
|
+
/** "audio_record" (default; the only source). Any other value draws the flat baseline. */
|
|
2033
|
+
source?: string;
|
|
2034
|
+
/** Visible bar count. Default 32, clamped 8..128. */
|
|
2035
|
+
bars?: number;
|
|
2036
|
+
/** Bar colour token. Default "accentPrimary". */
|
|
2037
|
+
color?: TokenName;
|
|
2038
|
+
/** Height in pt/dp. Default 32. */
|
|
2039
|
+
height?: number;
|
|
2040
|
+
/** `$service:` binding → boolean. Live while truthy, baseline otherwise. Empty ⇒ live whenever a recording is active. */
|
|
2041
|
+
activePath?: string;
|
|
2042
|
+
}
|
|
2021
2043
|
export interface MarqueeProps {
|
|
2022
2044
|
text?: string;
|
|
2023
2045
|
durationMs?: number;
|
|
@@ -2847,6 +2869,10 @@ export type CoreComponentBody = {
|
|
|
2847
2869
|
package: "himalaya";
|
|
2848
2870
|
type: "VoiceNote";
|
|
2849
2871
|
props: VoiceNoteProps;
|
|
2872
|
+
} | {
|
|
2873
|
+
package: "himalaya";
|
|
2874
|
+
type: "LiveWaveform";
|
|
2875
|
+
props: LiveWaveformProps;
|
|
2850
2876
|
} | {
|
|
2851
2877
|
package: "himalaya";
|
|
2852
2878
|
type: "Marquee";
|
|
@@ -140,8 +140,8 @@ export interface IapVerticalOrderAdapter extends IapAdapterBase {
|
|
|
140
140
|
/** Opens, or reuses the vertical's own open, order for the signed-in member. */
|
|
141
141
|
/** Repeatable adapters call beforeCreate immediately before their first inventory write,
|
|
142
142
|
* after read-only checks, and abort without writing if it returns false. They call afterCreate
|
|
143
|
-
* with the ids of each inventory write as soon as it answers
|
|
144
|
-
openOrder(item: IapOrderItem, bridge: SessionBoundBridge, beforeCreate?: (guard: OpeningGuard) => boolean, afterCreate?: (guard: OpeningGuard) =>
|
|
143
|
+
* with the ids of each inventory write as soon as it answers; on false they answer `unavailable`. */
|
|
144
|
+
openOrder(item: IapOrderItem, bridge: SessionBoundBridge, beforeCreate?: (guard: OpeningGuard) => boolean, afterCreate?: (guard: OpeningGuard) => boolean): Promise<OrderAttempt>;
|
|
145
145
|
/** Settles an earlier attempt's guard before a new sale of the same item. `settled`: the attempt
|
|
146
146
|
* that wrote it has had time to finish, so what it created may be undone; before then it may be
|
|
147
147
|
* another screen's sale still in flight. `claim` must answer true immediately before anything
|
|
@@ -168,7 +168,7 @@ export interface IapItemPaymentAdapter extends IapAdapterBase {
|
|
|
168
168
|
/** The catalog item to order, for an item `eligibility` accepted. A vertical that must read or
|
|
169
169
|
* make something first (a plan's pricing variant, the member's booking) does it here, through
|
|
170
170
|
* the session-bound bridge, before anything is ordered. */
|
|
171
|
-
itemPayment(item: IapOrderItem, bridge: SessionBoundBridge, beforeCreate?: (guard: OpeningGuard) => boolean, afterCreate?: (guard: OpeningGuard) =>
|
|
171
|
+
itemPayment(item: IapOrderItem, bridge: SessionBoundBridge, beforeCreate?: (guard: OpeningGuard) => boolean, afterCreate?: (guard: OpeningGuard) => boolean): ItemPayment | ItemPaymentRefusal | Promise<ItemPayment | ItemPaymentRefusal>;
|
|
172
172
|
openOrder?: never;
|
|
173
173
|
reopenOrder?: never;
|
|
174
174
|
/** Each sale is its own attempt (a ticket, a booking): the item carries an `attemptId`. */
|
|
@@ -213,13 +213,22 @@ export interface OrderRef {
|
|
|
213
213
|
appAccountToken?: string;
|
|
214
214
|
/** For `openingOrder`: when anything its write created has been released by Wix. */
|
|
215
215
|
releaseAt?: number;
|
|
216
|
+
/** For `openingOrder`: the attempt that owns the guard. Ownership is checked by it, never by
|
|
217
|
+
* `updatedAt`, which two workers can write in the same millisecond. Absent on guards stored before it. */
|
|
218
|
+
guardToken?: string;
|
|
216
219
|
updatedAt: number;
|
|
217
220
|
}
|
|
221
|
+
/** `replaced`: the key no longer holds the expected guard, so nothing was written. */
|
|
222
|
+
export type GuardWrite = "written" | "replaced" | "unavailable";
|
|
218
223
|
export interface OrderRefPartition {
|
|
219
224
|
refs(): readonly OrderRef[];
|
|
220
225
|
/** False when the write could not be verified as durable; the caller must not proceed. */
|
|
221
226
|
put(ref: OrderRef): boolean;
|
|
222
227
|
remove(key: string): boolean;
|
|
228
|
+
/** Writes `next` only while the key still holds `expected`'s creation guard (the same token). */
|
|
229
|
+
replaceGuard(expected: OrderRef, next: OrderRef): GuardWrite;
|
|
230
|
+
/** Removes the key only while it still holds `expected`'s creation guard. */
|
|
231
|
+
removeGuard(expected: OrderRef): GuardWrite;
|
|
223
232
|
}
|
|
224
233
|
export interface OrderRefStore {
|
|
225
234
|
/** Null when this partition cannot be stored durably: no storage bridge, unreadable or
|
|
@@ -13,17 +13,21 @@ export declare const ITEM_START_HOLD_MS = 3600000;
|
|
|
13
13
|
/** Drops every hold older than its stage's hold time, whatever its key (an item, or a `payment:`
|
|
14
14
|
* with no local order), so holds never accumulate and lock the member out. A held proof still
|
|
15
15
|
* unfinished renews its hold on every retry, so only one Apple no longer delivers expires. A
|
|
16
|
-
* creation guard goes at its own `releaseAt
|
|
16
|
+
* creation guard goes at its own `releaseAt`, and only while it is still the guard that expired,
|
|
17
|
+
* never a fresh one another worker stored under the key since. Returns the keys it removed. */
|
|
17
18
|
export declare function pruneExpiredHolds(partition: OrderRefPartition, now: number): string[];
|
|
18
19
|
/** How long (5 minutes) a creation guard may belong to a sale still running in another screen's
|
|
19
20
|
* worker, which shares these references but not that sale's coordinator: longer than any one
|
|
20
21
|
* openOrder takes. Until then nothing it may have created is undone. A literal, as above. */
|
|
21
22
|
export declare const OPENING_SETTLE_MS = 300000;
|
|
22
23
|
/** Asks the guard's adapter to settle it. Before undoing anything the adapter claims the guard
|
|
23
|
-
* (
|
|
24
|
-
* is dropped only while it is still the stored guard: a slow answer never removes what
|
|
25
|
-
* worker wrote under the key since. A guard changed meanwhile is judged again as it now is. */
|
|
24
|
+
* (gives it a new token), so the sale that wrote it, should it still be running, is no longer
|
|
25
|
+
* charged. It is dropped only while it is still the stored guard: a slow answer never removes what
|
|
26
|
+
* another worker wrote under the key since. A guard changed meanwhile is judged again as it now is. */
|
|
26
27
|
export declare function settleOpening(partition: OrderRefPartition, adapter: IapOrderAdapter, guard: OrderRef, item: IapOrderItem | undefined, bridge: SessionBoundBridge, now: number): Promise<OpeningResolution | "storageUnavailable">;
|
|
28
|
+
export declare function isStoredGuard(partition: OrderRefPartition, guard: OrderRef): boolean;
|
|
29
|
+
/** Unique per creation attempt, across the workers sharing these references. */
|
|
30
|
+
export declare function newGuardToken(): string;
|
|
27
31
|
/** References one member keeps at once. When full, the oldest reference from before Apple's sheet
|
|
28
32
|
* is evicted; a partition full of handed-over payments refuses new sales instead. */
|
|
29
33
|
export declare const MAX_ORDER_REFS = 16;
|
|
@@ -231,6 +231,32 @@ export declare function getFollowCounts(memberId: string, options?: WixCallOptio
|
|
|
231
231
|
* /members/v3/followers/my/connections. Returns false on any miss. May 403 →
|
|
232
232
|
* caller should default to false. */
|
|
233
233
|
export declare function isFollowingMember(targetId: string): Promise<boolean>;
|
|
234
|
+
export interface WixMemberAbout {
|
|
235
|
+
id?: string;
|
|
236
|
+
memberId?: string;
|
|
237
|
+
/** Ricos document of the "About" section. */
|
|
238
|
+
content?: Record<string, unknown>;
|
|
239
|
+
}
|
|
240
|
+
export interface WixQueryMemberAboutsResponse {
|
|
241
|
+
memberAbouts?: WixMemberAbout[];
|
|
242
|
+
}
|
|
243
|
+
/** The "About" sections that match a query — POST /members/v2/abouts/query. Filter by
|
|
244
|
+
* `{ memberId }`. A member with no About yields an empty list; the by-id GET answers 404 instead,
|
|
245
|
+
* so callers should query rather than get.
|
|
246
|
+
*
|
|
247
|
+
* @scope visitor — observed live: an anonymous visitor token (the Branded Lite site's OAuth client) got 200 for eight public members.
|
|
248
|
+
* None of them had an About section, so the shape of a non-empty answer is the documented one, not an observed one. The API lock
|
|
249
|
+
* (`codegen/wix/auto/lock.json`) lists the APP identity only. A refused read must hide the About section and nothing else; it never
|
|
250
|
+
* means "this member has no About". */
|
|
251
|
+
export declare function queryMemberAbouts(req?: {
|
|
252
|
+
query?: {
|
|
253
|
+
filter?: Record<string, unknown>;
|
|
254
|
+
cursorPaging?: {
|
|
255
|
+
limit?: number;
|
|
256
|
+
cursor?: string;
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
}, options?: WixCallOptions): Promise<WixQueryMemberAboutsResponse>;
|
|
234
260
|
/** When a member last opened the app, as the One App computes it: `unit` is "min", "hour" or "day", and `ts`
|
|
235
261
|
* (epoch milliseconds, as a string) is there for a day count the One App prints as a date. */
|
|
236
262
|
export interface WixMemberLastOpenApp {
|
|
@@ -8683,6 +8683,7 @@ var COLOR_TOKEN_PROPS = {
|
|
|
8683
8683
|
Gauge: ["tint", "rings[].tint"],
|
|
8684
8684
|
Rating: ["color"],
|
|
8685
8685
|
VoiceNote: ["tint"],
|
|
8686
|
+
LiveWaveform: ["color"],
|
|
8686
8687
|
Marquee: ["color"],
|
|
8687
8688
|
Fab: ["tint"]
|
|
8688
8689
|
};
|
|
@@ -9850,6 +9851,8 @@ var CORE_COMPONENTS = /* @__PURE__ */ new Set([
|
|
|
9850
9851
|
"himalaya.MediaField",
|
|
9851
9852
|
// Recorded-audio bubble — messenger design G4
|
|
9852
9853
|
"himalaya.VoiceNote",
|
|
9854
|
+
// Live microphone waveform — #4670
|
|
9855
|
+
"himalaya.LiveWaveform",
|
|
9853
9856
|
"himalaya.Marquee",
|
|
9854
9857
|
"himalaya.CollapsingHeader",
|
|
9855
9858
|
"himalaya.AvatarStrip",
|
|
@@ -1818,7 +1818,8 @@ var NEEDS_SUPPORT_HOLD_MS = 6048e5;
|
|
|
1818
1818
|
var ITEM_START_HOLD_MS = 36e5;
|
|
1819
1819
|
function pruneExpiredHolds(partition, now) {
|
|
1820
1820
|
const expired = partition.refs().filter((ref) => now - ref.updatedAt >= (HOLD_MS[ref.stage] ?? Infinity) || released(ref, now));
|
|
1821
|
-
|
|
1821
|
+
const removed = (ref) => ref.stage === "openingOrder" ? partition.removeGuard(ref) === "written" : partition.remove(ref.key);
|
|
1822
|
+
return expired.filter(removed).map((ref) => ref.key);
|
|
1822
1823
|
}
|
|
1823
1824
|
var OPENING_SETTLE_MS = 3e5;
|
|
1824
1825
|
async function settleOpening(partition, adapter, guard, item, bridge, now) {
|
|
@@ -1826,23 +1827,36 @@ async function settleOpening(partition, adapter, guard, item, bridge, now) {
|
|
|
1826
1827
|
if (!resolve) return "held";
|
|
1827
1828
|
let current = guard;
|
|
1828
1829
|
const claim = () => {
|
|
1829
|
-
const next = { ...current, updatedAt: now };
|
|
1830
|
-
if (
|
|
1830
|
+
const next = { ...current, guardToken: newGuardToken(), updatedAt: now };
|
|
1831
|
+
if (partition.replaceGuard(current, next) !== "written") return false;
|
|
1831
1832
|
current = next;
|
|
1832
1833
|
return true;
|
|
1833
1834
|
};
|
|
1834
1835
|
const resolution = await resolve(guard, item, bridge, { settled: now - guard.updatedAt >= OPENING_SETTLE_MS, claim });
|
|
1835
|
-
if (
|
|
1836
|
-
|
|
1837
|
-
|
|
1836
|
+
if (resolution === "released") {
|
|
1837
|
+
const removed = partition.removeGuard(current);
|
|
1838
|
+
if (removed !== "replaced") return removed === "written" ? "released" : "storageUnavailable";
|
|
1839
|
+
} else if (isStoredGuard(partition, current)) {
|
|
1840
|
+
return resolution;
|
|
1838
1841
|
}
|
|
1839
1842
|
const stored = partition.refs().find((ref) => ref.key === guard.key);
|
|
1840
1843
|
if (!stored) return "released";
|
|
1841
1844
|
return stored.stage === "openingOrder" ? resolve(stored, item, bridge, { settled: false, claim: () => false }) : "held";
|
|
1842
1845
|
}
|
|
1843
1846
|
function isStoredGuard(partition, guard) {
|
|
1844
|
-
|
|
1845
|
-
|
|
1847
|
+
return holdsGuard(partition.refs(), guard);
|
|
1848
|
+
}
|
|
1849
|
+
function holdsGuard(refs, expected) {
|
|
1850
|
+
const stored = refs.find((ref) => ref.key === expected.key);
|
|
1851
|
+
if (stored?.stage !== "openingOrder") return false;
|
|
1852
|
+
return expected.guardToken === void 0 ? stored.guardToken === void 0 && stored.updatedAt === expected.updatedAt : stored.guardToken === expected.guardToken;
|
|
1853
|
+
}
|
|
1854
|
+
var guardTokens = 0;
|
|
1855
|
+
function newGuardToken() {
|
|
1856
|
+
const crypto = globalThis.crypto;
|
|
1857
|
+
if (typeof crypto?.randomUUID === "function") return crypto.randomUUID();
|
|
1858
|
+
const random = () => Math.random().toString(36).slice(2, 12);
|
|
1859
|
+
return `${Date.now().toString(36)}-${(guardTokens++).toString(36)}-${random()}${random()}`;
|
|
1846
1860
|
}
|
|
1847
1861
|
var MAX_ORDER_REFS = 16;
|
|
1848
1862
|
function createWorkerOrderRefStore(storage) {
|
|
@@ -1854,19 +1868,34 @@ function createWorkerOrderRefStore(storage) {
|
|
|
1854
1868
|
return {
|
|
1855
1869
|
refs: () => readRefs(kv(), location) ?? [],
|
|
1856
1870
|
put: (ref) => writeWith(location, key, (refs) => upsert(refs, ref)),
|
|
1857
|
-
remove: (refKey) => writeWith(location, key, (refs) => refs.filter((stored) => stored.key !== refKey))
|
|
1871
|
+
remove: (refKey) => writeWith(location, key, (refs) => refs.filter((stored) => stored.key !== refKey)),
|
|
1872
|
+
replaceGuard: (expected, next) => guardedWrite(location, key, expected, (refs) => upsert(refs, next)),
|
|
1873
|
+
removeGuard: (expected) => guardedWrite(location, key, expected, (refs) => refs.filter((stored) => stored.key !== expected.key))
|
|
1858
1874
|
};
|
|
1859
1875
|
}
|
|
1876
|
+
function guardedWrite(location, key, expected, change) {
|
|
1877
|
+
let replaced = false;
|
|
1878
|
+
const written = writeWith(location, key, (refs) => {
|
|
1879
|
+
replaced = !holdsGuard(refs, expected);
|
|
1880
|
+
return replaced ? null : change(refs);
|
|
1881
|
+
});
|
|
1882
|
+
return written ? "written" : replaced ? "replaced" : "unavailable";
|
|
1883
|
+
}
|
|
1860
1884
|
function writeWith(location, key, change) {
|
|
1861
1885
|
const store = kv();
|
|
1862
1886
|
if (!store) return false;
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1887
|
+
for (let attempt3 = 0; attempt3 < WRITE_ATTEMPTS; attempt3++) {
|
|
1888
|
+
const raw = safely(() => store.getItem(location));
|
|
1889
|
+
const current = parseRefs(raw);
|
|
1890
|
+
const next = current && change(current);
|
|
1891
|
+
if (!next) return false;
|
|
1892
|
+
if (next.length > 0 && !updateIndex(store, key, true)) return false;
|
|
1893
|
+
if (safely(() => store.getItem(location)) !== raw) continue;
|
|
1894
|
+
if (!writeVerified(store, location, serialize({ v: VERSION, refs: next }))) return false;
|
|
1895
|
+
if (next.length === 0) updateIndex(store, key, false);
|
|
1896
|
+
return true;
|
|
1897
|
+
}
|
|
1898
|
+
return false;
|
|
1870
1899
|
}
|
|
1871
1900
|
function hasRefs(app) {
|
|
1872
1901
|
if (!isUUID3(app.purchasesAppId) || !isUUID3(app.siteId)) return null;
|
|
@@ -1891,7 +1920,10 @@ function updateIndex(store, key, holdsRefs) {
|
|
|
1891
1920
|
return next.length === members.length && next.every((m, i) => m === members[i]) || writeVerified(store, location, serialize({ v: VERSION, members: next }));
|
|
1892
1921
|
}
|
|
1893
1922
|
function readRefs(store, location) {
|
|
1894
|
-
|
|
1923
|
+
return store ? parseRefs(safely(() => store.getItem(location))) : null;
|
|
1924
|
+
}
|
|
1925
|
+
function parseRefs(raw) {
|
|
1926
|
+
const parsed = parseVersioned(raw);
|
|
1895
1927
|
if (parsed === "empty") return [];
|
|
1896
1928
|
if (!parsed || !Array.isArray(parsed.refs) || !parsed.refs.every(isOrderRef)) return null;
|
|
1897
1929
|
return parsed.refs;
|
|
@@ -1903,8 +1935,9 @@ function readIndex(store, location) {
|
|
|
1903
1935
|
return parsed.members;
|
|
1904
1936
|
}
|
|
1905
1937
|
function readVersioned(store, location) {
|
|
1906
|
-
|
|
1907
|
-
|
|
1938
|
+
return store ? parseVersioned(safely(() => store.getItem(location))) : null;
|
|
1939
|
+
}
|
|
1940
|
+
function parseVersioned(raw) {
|
|
1908
1941
|
if (raw === void 0) return null;
|
|
1909
1942
|
if (raw === null || raw === "") return "empty";
|
|
1910
1943
|
const parsed = safely(() => JSON.parse(raw));
|
|
@@ -1921,7 +1954,7 @@ function isOrderRef(value) {
|
|
|
1921
1954
|
if (!isObject6(value) || typeof value.key !== "string" || !STAGES.has(value.stage)) return false;
|
|
1922
1955
|
if (typeof value.updatedAt !== "number") return false;
|
|
1923
1956
|
if (value.releaseAt !== void 0 && typeof value.releaseAt !== "number") return false;
|
|
1924
|
-
const optional = ["kind", "cashierOrderId", "wixTransactionId", "paymentId", "storeProductId", "appProductId", "appleTransactionId", "appAccountToken"];
|
|
1957
|
+
const optional = ["kind", "cashierOrderId", "wixTransactionId", "paymentId", "storeProductId", "appProductId", "appleTransactionId", "appAccountToken", "guardToken"];
|
|
1925
1958
|
if (!optional.every((field) => value[field] === void 0 || typeof value[field] === "string")) return false;
|
|
1926
1959
|
return value.verticalRef === void 0 || isStringMap(value.verticalRef);
|
|
1927
1960
|
}
|
|
@@ -1977,6 +2010,7 @@ function isUUID3(value) {
|
|
|
1977
2010
|
return typeof value === "string" && /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(value);
|
|
1978
2011
|
}
|
|
1979
2012
|
var VERSION = 1;
|
|
2013
|
+
var WRITE_ATTEMPTS = 3;
|
|
1980
2014
|
var PREFIX = "himi.iap.wix-checkout.v1";
|
|
1981
2015
|
var STAGES = /* @__PURE__ */ new Set(["startingItem", "openingOrder", "ordered", "charged", "started", "submitted", "fulfilled", "held", "needsSupport"]);
|
|
1982
2016
|
var HOLD_MS = { held: NEEDS_SUPPORT_HOLD_MS, needsSupport: NEEDS_SUPPORT_HOLD_MS, startingItem: ITEM_START_HOLD_MS };
|
|
@@ -2075,15 +2109,16 @@ function createWixOrderBackend(deps) {
|
|
|
2075
2109
|
const { state, beforeCreate, afterCreate } = creationGuards(sale, void 0);
|
|
2076
2110
|
const prepared = await adapter.itemPayment(sale.item, sale.bridge, beforeCreate, afterCreate);
|
|
2077
2111
|
if (state.prevented) return contextResult(catalogRef, state.prevented);
|
|
2112
|
+
if (state.orphan) return contextResult(catalogRef, await releaseOrphan(sale, state.orphan));
|
|
2078
2113
|
if (!sale.bridge.isCurrent()) return contextResult(catalogRef, STALE2);
|
|
2079
2114
|
if ("status" in prepared) return contextResult(catalogRef, preparationStop(sale, prepared, state.guarded));
|
|
2080
|
-
if (state.guarded
|
|
2115
|
+
if (state.guarded && !isStoredGuard(sale.partition, state.guarded)) return contextResult(catalogRef, retry("unavailable"));
|
|
2081
2116
|
const stillBlocked = state.guarded === void 0 ? saleBlocked(sale) : null;
|
|
2082
2117
|
if (stillBlocked) return contextResult(catalogRef, stillBlocked);
|
|
2083
|
-
return startItemFor(sale, prepared, country);
|
|
2118
|
+
return startItemFor(sale, prepared, country, state.guarded);
|
|
2084
2119
|
}
|
|
2085
2120
|
function preparationStop(sale, refusal, guarded) {
|
|
2086
|
-
if (refusal.noOrderCreated && guarded
|
|
2121
|
+
if (refusal.noOrderCreated && guarded && sale.partition.removeGuard(guarded) === "unavailable") {
|
|
2087
2122
|
return stopWith("rejected", "storageUnavailable");
|
|
2088
2123
|
}
|
|
2089
2124
|
if (refusal.status === "refused") return stopWith("rejected", refusal.reason);
|
|
@@ -2159,19 +2194,21 @@ function createWixOrderBackend(deps) {
|
|
|
2159
2194
|
state.prevented = blocked;
|
|
2160
2195
|
return false;
|
|
2161
2196
|
}
|
|
2162
|
-
const opening = persist(sale, { ...guard, key: sale.catalogRef, kind: sale.adapter.kind, stage: "openingOrder", updatedAt: now() });
|
|
2197
|
+
const opening = persist(sale, { ...guard, key: sale.catalogRef, kind: sale.adapter.kind, stage: "openingOrder", guardToken: newGuardToken(), updatedAt: now() });
|
|
2163
2198
|
if (isStop(opening)) {
|
|
2164
2199
|
state.prevented = opening;
|
|
2165
2200
|
return false;
|
|
2166
2201
|
}
|
|
2167
|
-
state.guarded = opening
|
|
2202
|
+
state.guarded = opening;
|
|
2168
2203
|
return true;
|
|
2169
2204
|
};
|
|
2170
2205
|
const afterCreate = (guard) => {
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
const
|
|
2174
|
-
if (
|
|
2206
|
+
if (!state.guarded || !sale.bridge.isCurrent()) return true;
|
|
2207
|
+
const recorded = { ...state.guarded, ...guard, verticalRef: { ...state.guarded.verticalRef, ...guard.verticalRef }, updatedAt: now() };
|
|
2208
|
+
const written = sale.partition.replaceGuard(state.guarded, recorded);
|
|
2209
|
+
if (written === "written") state.guarded = recorded;
|
|
2210
|
+
if (written === "replaced") state.orphan = recorded;
|
|
2211
|
+
return written !== "replaced";
|
|
2175
2212
|
};
|
|
2176
2213
|
return { state, beforeCreate, afterCreate };
|
|
2177
2214
|
}
|
|
@@ -2180,28 +2217,24 @@ function createWixOrderBackend(deps) {
|
|
|
2180
2217
|
const { state, beforeCreate, afterCreate } = creationGuards(sale, existing);
|
|
2181
2218
|
const attempt3 = existing?.cashierOrderId && existing.verticalRef ? await reopenOrOpen(sale, { cashierOrderId: existing.cashierOrderId, verticalRef: existing.verticalRef }) : await sale.adapter.openOrder(sale.item, sale.bridge, beforeCreate, afterCreate);
|
|
2182
2219
|
if (state.prevented) return state.prevented;
|
|
2183
|
-
if (state.
|
|
2220
|
+
if (state.orphan) return releaseOrphan(sale, state.orphan);
|
|
2184
2221
|
const ref = recordOrder(sale, existing, attempt3, state.guarded);
|
|
2185
2222
|
return isStop(ref) ? ref : { ref, placed: isPlaced(attempt3) };
|
|
2186
2223
|
}
|
|
2187
|
-
function stillGuarded(sale, guarded) {
|
|
2188
|
-
const stored = refAt(sale.partition, sale.catalogRef);
|
|
2189
|
-
return stored?.stage === "openingOrder" && stored.updatedAt === guarded;
|
|
2190
|
-
}
|
|
2191
2224
|
async function reopenOrOpen(sale, order) {
|
|
2192
2225
|
const reopened = await sale.adapter.reopenOrder(order, sale.bridge);
|
|
2193
2226
|
const closed = reopened.status === "refused" && reopened.reason === "orderClosed";
|
|
2194
2227
|
return closed && !sale.adapter.repeatable ? sale.adapter.openOrder(sale.item, sale.bridge) : reopened;
|
|
2195
2228
|
}
|
|
2196
2229
|
function recordOrder(sale, existing, attempt3, guarded) {
|
|
2197
|
-
if (attempt3.noOrderCreated && guarded
|
|
2230
|
+
if (attempt3.noOrderCreated && guarded && sale.partition.removeGuard(guarded) === "unavailable") {
|
|
2198
2231
|
return stopWith("rejected", "storageUnavailable");
|
|
2199
2232
|
}
|
|
2200
2233
|
if (attempt3.status === "granted") return alreadyOwned(sale);
|
|
2201
2234
|
if (attempt3.status === "refused") return stopWith("rejected", attempt3.reason);
|
|
2202
2235
|
if (attempt3.status !== "open") return attempt3.status === "sessionChanged" ? STALE2 : retry("unavailable");
|
|
2203
2236
|
const kept = existing && existing.cashierOrderId === attempt3.cashierOrderId ? existing : { key: sale.catalogRef, updatedAt: 0 };
|
|
2204
|
-
|
|
2237
|
+
const ordered = {
|
|
2205
2238
|
...kept,
|
|
2206
2239
|
key: sale.catalogRef,
|
|
2207
2240
|
stage: "ordered",
|
|
@@ -2209,7 +2242,18 @@ function createWixOrderBackend(deps) {
|
|
|
2209
2242
|
verticalRef: attempt3.verticalRef,
|
|
2210
2243
|
cashierOrderId: attempt3.cashierOrderId,
|
|
2211
2244
|
updatedAt: now()
|
|
2212
|
-
}
|
|
2245
|
+
};
|
|
2246
|
+
return guarded ? persistGuarded(sale, guarded, ordered) : persist(sale, ordered);
|
|
2247
|
+
}
|
|
2248
|
+
async function releaseOrphan(sale, made) {
|
|
2249
|
+
const released2 = await sale.adapter.resolveOpening?.(made, sale.item, sale.bridge, { settled: true, claim: () => true });
|
|
2250
|
+
return released2 === "sessionChanged" || !sale.bridge.isCurrent() ? STALE2 : retry("unavailable");
|
|
2251
|
+
}
|
|
2252
|
+
function persistGuarded(sale, guarded, ref) {
|
|
2253
|
+
if (!sale.bridge.isCurrent()) return STALE2;
|
|
2254
|
+
const written = sale.partition.replaceGuard(guarded, ref);
|
|
2255
|
+
if (written === "replaced") return retry("unavailable");
|
|
2256
|
+
return written === "written" ? ref : stopWith("rejected", "storageUnavailable");
|
|
2213
2257
|
}
|
|
2214
2258
|
async function chargeFor(sale, ref, options) {
|
|
2215
2259
|
const charge = await (options.placed ? chargePlacedOrder : ensureAppleIapCharge)(sale.bridge, deps.cashier, ref.cashierOrderId ?? "");
|
|
@@ -2265,10 +2309,10 @@ function createWixOrderBackend(deps) {
|
|
|
2265
2309
|
if (isStop(recorded)) return contextResult(sale.catalogRef, recorded);
|
|
2266
2310
|
return { status: "ok", context: { productId: started.storeProductId, appAccountToken: started.appAccountToken, scopeKey: sale.member.scopeKey } };
|
|
2267
2311
|
}
|
|
2268
|
-
async function startItemFor(sale, itemPayment4, country) {
|
|
2312
|
+
async function startItemFor(sale, itemPayment4, country, owned) {
|
|
2269
2313
|
const made = refAt(sale.partition, sale.catalogRef);
|
|
2270
2314
|
const guarded = made?.stage === "openingOrder" ? { verticalRef: made.verticalRef, releaseAt: made.releaseAt } : {};
|
|
2271
|
-
const
|
|
2315
|
+
const next = {
|
|
2272
2316
|
key: sale.catalogRef,
|
|
2273
2317
|
stage: "startingItem",
|
|
2274
2318
|
kind: sale.adapter.kind,
|
|
@@ -2276,7 +2320,8 @@ function createWixOrderBackend(deps) {
|
|
|
2276
2320
|
...guarded.verticalRef ? { verticalRef: guarded.verticalRef } : {},
|
|
2277
2321
|
...guarded.releaseAt !== void 0 ? { releaseAt: guarded.releaseAt } : {},
|
|
2278
2322
|
updatedAt: now()
|
|
2279
|
-
}
|
|
2323
|
+
};
|
|
2324
|
+
const attempt3 = owned ? persistGuarded(sale, owned, next) : persist(sale, next);
|
|
2280
2325
|
if (isStop(attempt3)) return contextResult(sale.catalogRef, attempt3);
|
|
2281
2326
|
const started = await deps.wixIap.startItemPayment({ item: itemPayment4.catalogItem, ...country ? { storeCountryCode: country } : {} });
|
|
2282
2327
|
if (started.status === "outcomeUnknown") return contextResult(sale.catalogRef, sale.bridge.isCurrent() ? OUTCOME_UNKNOWN : STALE2);
|
|
@@ -2325,6 +2370,7 @@ function createWixOrderBackend(deps) {
|
|
|
2325
2370
|
key: attempt3.key,
|
|
2326
2371
|
kind: adapter.kind,
|
|
2327
2372
|
stage: "openingOrder",
|
|
2373
|
+
guardToken: newGuardToken(),
|
|
2328
2374
|
verticalRef: attempt3.verticalRef,
|
|
2329
2375
|
...attempt3.releaseAt !== void 0 ? { releaseAt: attempt3.releaseAt } : {},
|
|
2330
2376
|
updatedAt: now() - OPENING_SETTLE_MS
|
|
@@ -3694,7 +3740,7 @@ async function bookingPayment(item, bridge, beforeCreate, afterCreate) {
|
|
|
3694
3740
|
if (isRefusal(created)) return creationRefused(created);
|
|
3695
3741
|
const bookingId = bodyObject(created, "booking")?.id;
|
|
3696
3742
|
if (!isNonEmpty3(bookingId)) return ORDER_REFUSED;
|
|
3697
|
-
afterCreate?.({ verticalRef: { bookingId } });
|
|
3743
|
+
if (afterCreate?.({ verticalRef: { bookingId } }) === false) return { status: "unavailable" };
|
|
3698
3744
|
const serviceId = item.reference.id;
|
|
3699
3745
|
return {
|
|
3700
3746
|
catalogItem: { catalogItemId: serviceId, catalogAppId: WIX_BOOKINGS_APP, options: { bookingId } },
|
|
@@ -3850,7 +3896,7 @@ async function openBooking(item, bridge, beforeCreate, afterCreate) {
|
|
|
3850
3896
|
if (isRefusal(created)) return creationRefused2(created);
|
|
3851
3897
|
const bookingId = bodyObject(created, "booking")?.id;
|
|
3852
3898
|
if (!isNonEmpty3(bookingId)) return ORDER_REFUSED;
|
|
3853
|
-
afterCreate?.({ verticalRef: { bookingId } });
|
|
3899
|
+
if (afterCreate?.({ verticalRef: { bookingId } }) === false) return { status: "unavailable" };
|
|
3854
3900
|
return bookingCheckout(item, bookingId, bridge);
|
|
3855
3901
|
}
|
|
3856
3902
|
function slotGuard2(slot) {
|
|
@@ -3943,7 +3989,7 @@ async function reserveTicket(item, bridge, now, afterCreate) {
|
|
|
3943
3989
|
if (isRefusal(held)) return creationRefused2(held);
|
|
3944
3990
|
const reservation = held.body;
|
|
3945
3991
|
if (!isObject7(reservation) || !isNonEmpty3(reservation.id) || !future(reservation.expires, now)) return ORDER_CLOSED;
|
|
3946
|
-
afterCreate?.({ verticalRef: { reservationId: reservation.id }, releaseAt: Date.parse(reservation.expires) + RELEASE_MARGIN_MS2 });
|
|
3992
|
+
if (afterCreate?.({ verticalRef: { reservationId: reservation.id }, releaseAt: Date.parse(reservation.expires) + RELEASE_MARGIN_MS2 }) === false) return { status: "unavailable" };
|
|
3947
3993
|
if (!heldAsSelected(reservation, item)) return CHANGED2;
|
|
3948
3994
|
const placed = await bridge.call("POST", "/events/v1/checkout", { eventId: selected.eventId, reservationId: reservation.id, buyer: selected.buyer, ...selected.guests ? { guests: selected.guests } : {}, ...selected.buyerSubmission ? { buyerSubmission: selected.buyerSubmission } : {}, ...selected.guestSubmissions ? { guestSubmissions: selected.guestSubmissions } : {}, options: { silent: false, payInPerson: false, ignoreFormValidation: false, markAsPaid: false } });
|
|
3949
3995
|
if (isRefusal(placed)) return attemptRefused(placed);
|