@wix/himalaya-cli 0.1724.0 → 0.1725.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.
Files changed (37) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments-contract.d.ts +6 -4
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/location/src/index.d.ts +5 -3
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/on-device-ai/src/index.d.ts +19 -7
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/sdk-types/src/capabilities.generated.d.ts +1 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/checkout-source.d.ts +3 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/videos.d.ts +31 -1
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/index.d.ts +1 -1
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/audio-record.mjs +1 -1
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calendar.mjs +1 -1
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/calls.mjs +1 -1
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/contacts.mjs +1 -1
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +83 -9
  13. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/location.mjs +1 -1
  14. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/motion.mjs +1 -1
  15. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/on-device-ai.mjs +49 -3
  16. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/photos.mjs +1 -1
  17. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +92 -2
  18. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdk-types.mjs +1 -1
  19. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/tasks.mjs +1 -1
  20. package/dist/browser-plane/assets.json +7 -7
  21. package/dist/browser-plane/preview-deferred/{a6e25c06d2a17ab2b5e34bf2b5965fa3ddd76ce3da32a036e546a60938130d7b.bin → 49dfd582c5a8fb38ceabd1c544343d87fd478063c04f90c4e7a4ed5ee774f1eb.bin} +1 -1
  22. package/dist/browser-plane/sw.js +8 -8
  23. package/dist/browser-plane/t5-frame.html +16 -0
  24. package/dist/browser-plane/t5-worker-frame.html +16 -0
  25. package/dist/cli.mjs +1807 -1466
  26. package/dist/preview-assets.generated.bin +0 -0
  27. package/guides/capabilities.md +2 -2
  28. package/guides/headless-loop.md +2 -1
  29. package/guides/iap-products.md +2 -2
  30. package/guides/iap-screen-adoption.md +1 -1
  31. package/guides/sdk-reference.json +36 -8
  32. package/guides/skill.md +1 -1
  33. package/guides/testing-himi-apps.md +4 -3
  34. package/guides/web-page-sdk-reference.md +1 -1
  35. package/package.json +2 -2
  36. package/templates/branded-lite/dev/index.ts +35 -0
  37. package/templates/branded-lite/tier5-src/himi-branded-lite-video/index.ts +82 -12
@@ -41,10 +41,12 @@ export interface AppleSaleRule {
41
41
  * id (eCom's `catalogItemId`). One-time unlocks only, whatever the backend also accepts. */
42
42
  export declare const STORES_PRODUCT_SALE_RULE: AppleSaleRule;
43
43
  /**
44
- * Whether Wix Video videos sell through the App Store. OFF: prices only. A video with a one-time Sale
45
- * price above zero is mapped under its video id as a one-time unlock (`wixVideoItem`), and screens show
46
- * its App Store price, but no purchase path exists yet: Wix Video has no public order API, and the
47
- * Videos order adapter refuses every sale until this is on.
44
+ * Whether Wix Video videos sell through the App Store. OFF until the Wix Video purchase is proven live
45
+ * (gates G1–G4). A video with a one-time Sale price above zero is mapped under
46
+ * its video id as a one-time unlock (`wixVideoItem`), and screens show its App Store price. ON, the Video
47
+ * screen offers Buy: the device opens Video's own SALE order on its GraphQL gateway (`wixVideoOrders`),
48
+ * and the shared checkout charges it with appleIAP and pays it through StartPayment. OFF, the adapter
49
+ * refuses every sale and the screen composes no checkout.
48
50
  */
49
51
  export declare const VIDEOS_APPLE_SALES_ENABLED = false;
50
52
  /**
@@ -187,9 +187,10 @@ export declare function watchGeofences(fences: Geofence[], onEvent: (event: Geof
187
187
  }): GeofenceWatcher;
188
188
  export declare const version = 4;
189
189
  export interface RegionMonitoringSupport {
190
- /** False on Android and web. Check it BEFORE relying on a terminated-app trigger. */
190
+ /** False on the web, and wherever the module is not linked. Check it BEFORE relying on a
191
+ * terminated-app trigger. */
191
192
  available: boolean;
192
- /** How many regions the OS will monitor for this app. iOS: 20, process-wide. */
193
+ /** How many regions the OS will monitor for this app. iOS: 20, Android: 100, process-wide. */
193
194
  maxRegions: number;
194
195
  /** Radii below this are unreliable on consumer GPS and are clamped up to it. */
195
196
  minRadiusM: number;
@@ -205,7 +206,8 @@ export interface MonitoredRegionResult {
205
206
  ok: boolean;
206
207
  id?: string;
207
208
  radiusM?: number;
208
- /** Why it was refused: no Always grant, the region cap, or an unusable coordinate. */
209
+ /** Why it was refused: no Always grant (on Android, also only approximate location granted —
210
+ * geofencing needs precise), the region cap, or an unusable coordinate. */
209
211
  reason?: string;
210
212
  }
211
213
  /**
@@ -1,7 +1,8 @@
1
1
  import type { Availability } from "@wix/himalaya/sdk-types";
2
2
  export type { Availability } from "@wix/himalaya/sdk-types";
3
- /** The on-device engine backing generation, when one is available. */
4
- export type OnDeviceEngine = "foundation_models" | "gemini_nano" | "prompt_api";
3
+ /** The on-device engine backing generation, when one is available. `chrome_built_in` is Chrome's
4
+ * task model (Summarizer / Rewriter / Proofreader), which only the writing tasks report. */
5
+ export type OnDeviceEngine = "foundation_models" | "gemini_nano" | "prompt_api" | "chrome_built_in";
5
6
  export interface OnDeviceAvailability {
6
7
  /** Honest support level for text generation on THIS device/host (spec R8). */
7
8
  textGeneration: Availability;
@@ -57,15 +58,26 @@ export declare function generateText(input: GenerateTextInput): Promise<Generate
57
58
  */
58
59
  export declare function generateJson<T = Record<string, unknown>>(input: GenerateTextInput): Promise<T | null>;
59
60
  export interface SummarizeOptions {
60
- /** Extra instruction, e.g. "in one sentence" or "as 3 bullet points". */
61
+ /** "paragraph" (default) or "bullets". */
62
+ format?: "paragraph" | "bullets";
63
+ /** "short", "medium" (default) or "long". */
64
+ length?: "short" | "medium" | "long";
65
+ /** Extra free-form instruction, e.g. "in one sentence". When set, the summary is generated
66
+ * through `generateText` with that instruction instead of the platform's summarizer. */
61
67
  instruction?: string;
62
- /** Complexity of the summarization. Defaults to MEDIUM. */
68
+ /** Complexity hint for the `instruction` path. Defaults to MEDIUM. */
63
69
  taskComplexity?: TaskComplexity;
64
70
  }
71
+ /** How `rewrite` should change the text. */
72
+ export type RewriteStyle = "rephrase" | "shorter" | "elaborate" | "friendly" | "professional" | "emojify";
65
73
  /**
66
- * Summarize a block of text on device. Thin sugar over `generateText` with a fixed
67
- * `{ summary: string }` schema; returns the extracted summary in `text` (or the raw failure
68
- * result — check `.success`).
74
+ * Summarize a block of text on device — the on-device model with summarization instructions (Apple
75
+ * Foundation Models, Gemini Nano), or Chrome's Summarizer on the web. Returns plain text in `text`;
76
+ * check `.success`.
69
77
  */
70
78
  export declare function summarize(text: string, opts?: SummarizeOptions): Promise<GenerateTextResult>;
79
+ /** Rewrite text on device in a given style (shorter, friendlier, more professional…). */
80
+ export declare function rewrite(text: string, style?: RewriteStyle): Promise<GenerateTextResult>;
81
+ /** Fix spelling and grammar on device; `text` is the corrected text. */
82
+ export declare function proofread(text: string): Promise<GenerateTextResult>;
71
83
  export declare const version = 1;
@@ -25,7 +25,7 @@ export declare const CAPABILITY_REGISTRY: {
25
25
  readonly media_playback: readonly ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"];
26
26
  readonly motion: readonly ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"];
27
27
  readonly network: readonly ["status", "subscribe"];
28
- readonly on_device_ai: readonly ["availability", "generateText"];
28
+ readonly on_device_ai: readonly ["availability", "generateText", "proofreadText", "rewriteText", "summarizeText"];
29
29
  readonly open_url: readonly ["canOpen", "open"];
30
30
  readonly pdf: readonly ["isAvailable", "open"];
31
31
  readonly photos: readonly ["getSavePermissionStatus", "pick", "saveToLibrary"];
@@ -6,3 +6,6 @@ export declare function appleIapCheckoutEnabled(): boolean;
6
6
  /** @deprecated Always true: Wix Stores items always sell through the App Store (wix-iap StartItemPayment).
7
7
  * Kept because screens generated from earlier `himi init` templates still call it. */
8
8
  export declare function storesAppleSalesEnabled(): boolean;
9
+ /** Whether a Wix Video sells through the App Store: the device opens Video's SALE order and the
10
+ * shared checkout pays it (`VIDEOS_APPLE_SALES_ENABLED` in @himalaya/iap, off until its live gates pass). */
11
+ export declare function videosAppleSalesEnabled(): boolean;
@@ -1,5 +1,35 @@
1
- import type { IapOrderAdapter } from "../apple-iap-contract.js";
1
+ import type { BridgeRefusal, IapOrderAdapter, SessionBoundBridge } from "../apple-iap-contract.js";
2
+ /** What opening a SALE order answered. `pending` and `active` are Video's own refusals of a second
3
+ * order (wix-vod-backend `purchase-order.ts`); `other` is any refusal it gave a reason for. */
4
+ export type VideoOrderAnswer = {
5
+ status: "ok";
6
+ orderId: string;
7
+ } | {
8
+ status: "refused";
9
+ reason: "pending" | "active" | "other";
10
+ } | BridgeRefusal;
11
+ /** The member's SALE purchase of a video: its status and the order it was opened with, or null when
12
+ * Video knows none. */
13
+ export type VideoPurchaseAnswer = {
14
+ status: "ok";
15
+ purchase: {
16
+ status: string;
17
+ orderId: string | null;
18
+ } | null;
19
+ } | BridgeRefusal;
20
+ /** Video's order and purchase reads, bound to the captured member session. */
21
+ export interface WixVideoPort {
22
+ openSaleOrder(videoId: string): Promise<VideoOrderAnswer>;
23
+ /** Video keys a purchase by the video, not by the order (wix-vod-gql-schema `purchase.graphql`). */
24
+ salePurchase(videoId: string): Promise<VideoPurchaseAnswer>;
25
+ }
26
+ export type WixVideoPortOf = (bridge: SessionBoundBridge) => WixVideoPort;
27
+ /** Video's GraphQL gateway over the session-bound bridge, which refuses to send and drops the answer
28
+ * once the member's session is no longer current. The native transport attaches the credential. */
29
+ export declare const graphqlVideoPort: WixVideoPortOf;
30
+ /** Internal factory for hermetic tests. Screens receive the built-in bound to the shipped switch. */
2
31
  export declare function videoOrdersWith(options: {
3
32
  enabled: boolean;
33
+ port?: WixVideoPortOf;
4
34
  }): IapOrderAdapter;
5
35
  export declare const wixVideoOrders: IapOrderAdapter;
@@ -3,6 +3,6 @@ export { iapPurchaseFields } from "./purchase-fields.js";
3
3
  export { createAppleIapCheckout } from "./apple-iap.js";
4
4
  export { onlineProgramOrders, pricingPlanOrders, storesProductOrders, bookingOrders, eventTicketOrders, wixVideoOrders, classifyCart } from "./iap-verticals/index.js";
5
5
  export { createWorkerOrderRefStore } from "./order-refs.js";
6
- export { storesAppleSalesEnabled } from "./checkout-source.js";
6
+ export { storesAppleSalesEnabled, videosAppleSalesEnabled } from "./checkout-source.js";
7
7
  export type { AccessRead, AppleIapCheckout, AppleIapCheckoutDependencies, AppleIapCheckoutPhase, AppleIapCheckoutState, BridgeOutcome, BridgeRefusal, CashierRoute, IapAdapterBase, IapEligibility, IapItemPaymentAdapter, IapOrderAdapter, IapOrderItem, IapVerticalOrderAdapter, OrderAttempt, OrderFailureCode, OrderPartitionKey, OrderRef, OrderRefPartition, OrderRefStage, OrderRefStore, PaymentAccess, PaymentProgress, SessionBoundBridge, VerticalRef, WixBridge, } from "./apple-iap-contract.js";
8
8
  export type { AppleIapCheckoutRoutes, IapCommerce, IapCommerceOptions, IapPurchaseCopy, IapPurchaseFields, IapPurchaseGap, IapPurchaseReadiness, IapRestoreResult, } from "./commerce-contract.js";
@@ -40,7 +40,7 @@ var CAPABILITY_REGISTRY = {
40
40
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
41
41
  "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
42
42
  "network": ["status", "subscribe"],
43
- "on_device_ai": ["availability", "generateText"],
43
+ "on_device_ai": ["availability", "generateText", "proofreadText", "rewriteText", "summarizeText"],
44
44
  "open_url": ["canOpen", "open"],
45
45
  "pdf": ["isAvailable", "open"],
46
46
  "photos": ["getSavePermissionStatus", "pick", "saveToLibrary"],
@@ -40,7 +40,7 @@ var CAPABILITY_REGISTRY = {
40
40
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
41
41
  "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
42
42
  "network": ["status", "subscribe"],
43
- "on_device_ai": ["availability", "generateText"],
43
+ "on_device_ai": ["availability", "generateText", "proofreadText", "rewriteText", "summarizeText"],
44
44
  "open_url": ["canOpen", "open"],
45
45
  "pdf": ["isAvailable", "open"],
46
46
  "photos": ["getSavePermissionStatus", "pick", "saveToLibrary"],
@@ -40,7 +40,7 @@ var CAPABILITY_REGISTRY = {
40
40
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
41
41
  "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
42
42
  "network": ["status", "subscribe"],
43
- "on_device_ai": ["availability", "generateText"],
43
+ "on_device_ai": ["availability", "generateText", "proofreadText", "rewriteText", "summarizeText"],
44
44
  "open_url": ["canOpen", "open"],
45
45
  "pdf": ["isAvailable", "open"],
46
46
  "photos": ["getSavePermissionStatus", "pick", "saveToLibrary"],
@@ -40,7 +40,7 @@ var CAPABILITY_REGISTRY = {
40
40
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
41
41
  "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
42
42
  "network": ["status", "subscribe"],
43
- "on_device_ai": ["availability", "generateText"],
43
+ "on_device_ai": ["availability", "generateText", "proofreadText", "rewriteText", "summarizeText"],
44
44
  "open_url": ["canOpen", "open"],
45
45
  "pdf": ["isAvailable", "open"],
46
46
  "photos": ["getSavePermissionStatus", "pick", "saveToLibrary"],
@@ -1659,6 +1659,9 @@ function appleIapCheckoutEnabled() {
1659
1659
  function storesAppleSalesEnabled() {
1660
1660
  return true;
1661
1661
  }
1662
+ function videosAppleSalesEnabled() {
1663
+ return VIDEOS_APPLE_SALES_ENABLED;
1664
+ }
1662
1665
 
1663
1666
  // ../../stdlib/flows/iap-checkout/src/cashier-charges.ts
1664
1667
  async function ensureAppleIapCharge(bridge, route, orderId) {
@@ -2210,7 +2213,7 @@ function createWixOrderBackend(deps) {
2210
2213
  case "approved":
2211
2214
  return alreadyPaid(sale, ref);
2212
2215
  case "closed":
2213
- return options.reordered ? stopWith("rejected", "orderClosed") : reorder(sale);
2216
+ return options.reordered ? stopWith("rejected", "orderClosed") : reorder(sale, ref.cashierOrderId);
2214
2217
  case "inOtherPayment":
2215
2218
  return stopWith("rejected", "orderRefused");
2216
2219
  case "refused":
@@ -2224,10 +2227,11 @@ function createWixOrderBackend(deps) {
2224
2227
  return retry("unavailable");
2225
2228
  }
2226
2229
  }
2227
- async function reorder(sale) {
2230
+ async function reorder(sale, closedOrderId) {
2228
2231
  if (sale.adapter.repeatable) return stopWith("rejected", "orderClosed");
2229
2232
  if (!forget(sale, sale.catalogRef)) return stopWith("rejected", "storageUnavailable");
2230
2233
  const attempt3 = await sale.adapter.openOrder(sale.item, sale.bridge);
2234
+ if (attempt3.status === "open" && attempt3.cashierOrderId === closedOrderId) return stopWith("rejected", "needsSupport");
2231
2235
  const recorded = recordOrder(sale, void 0, attempt3);
2232
2236
  return isStop(recorded) ? recorded : chargeFor(sale, recorded, { reordered: true, placed: isPlaced(attempt3) });
2233
2237
  }
@@ -3343,6 +3347,7 @@ function isNonEmpty3(value) {
3343
3347
  var UNSUPPORTED = { eligible: false, reason: "unsupportedItem" };
3344
3348
  var ORDER_REFUSED = { status: "refused", reason: "orderRefused" };
3345
3349
  var ORDER_CLOSED = { status: "refused", reason: "orderClosed" };
3350
+ var GRANTED = { status: "granted" };
3346
3351
  async function ecomOrderAccess(orderId, bridge) {
3347
3352
  if (!isNonEmpty3(orderId)) return "unavailable";
3348
3353
  const answer = await bridge.call("GET", `/ecom/v1/orders/${encodeURIComponent(orderId)}`);
@@ -3620,17 +3625,85 @@ function readAccess2(verticalRef, bridge) {
3620
3625
  // ../../stdlib/flows/iap-checkout/src/iap-verticals/videos.ts
3621
3626
  var KIND4 = "wixVideo";
3622
3627
  var NOT_ENABLED = { status: "refused", reason: "notEnabled" };
3623
- var NO_ORDER_STEP = { status: "refused", reason: "notConfigured" };
3628
+ var VIDEO_GRAPHQL_URL = "https://manage.wix.com/_api/vod/public/graphql";
3629
+ var graphqlVideoPort = (bridge) => ({
3630
+ async openSaleOrder(videoId) {
3631
+ const answer = await bridge.call("POST", VIDEO_GRAPHQL_URL, { query: CREATE_ORDER, variables: { videoId } });
3632
+ if (isRefusal(answer)) return answer;
3633
+ const created = dataAt(answer.body, ["purchase", "order", "create"]);
3634
+ if (!created) return { status: "unavailable" };
3635
+ const orderId = isObject7(created.entity) ? created.entity.id : void 0;
3636
+ if (created.status === "SUCCESS" && isNonEmpty3(orderId)) return { status: "ok", orderId };
3637
+ const message = typeof created.message === "string" ? created.message : "";
3638
+ return { status: "refused", reason: message === PENDING_MESSAGE ? "pending" : message === ACTIVE_MESSAGE ? "active" : "other" };
3639
+ },
3640
+ async salePurchase(videoId) {
3641
+ const answer = await bridge.call("POST", VIDEO_GRAPHQL_URL, { query: SALE_PURCHASE, variables: { videoId } });
3642
+ if (isRefusal(answer)) return answer;
3643
+ const data = isObject7(answer.body) && isObject7(answer.body.data) ? answer.body.data : null;
3644
+ if (!data || !("purchase" in data)) return { status: "unavailable" };
3645
+ const found = isObject7(data.purchase) ? data.purchase : null;
3646
+ if (!found) return { status: "ok", purchase: null };
3647
+ if (!isNonEmpty3(found.status)) return { status: "unavailable" };
3648
+ return { status: "ok", purchase: { status: found.status, orderId: isNonEmpty3(found.orderId) ? found.orderId : null } };
3649
+ }
3650
+ });
3624
3651
  function videoOrdersWith(options) {
3625
- return {
3652
+ const portOf = options.port ?? graphqlVideoPort;
3653
+ const adapter = {
3626
3654
  kind: KIND4,
3627
3655
  eligibility: (item) => options.enabled ? singleUnitOf(KIND4, item) : { eligible: false, reason: "notEnabled" },
3628
- openOrder: async () => options.enabled ? NO_ORDER_STEP : NOT_ENABLED,
3629
- reopenOrder: async () => ORDER_CLOSED,
3630
- readAccess: async () => "unavailable"
3656
+ openOrder: async (item, bridge) => options.enabled ? openOrder(item, portOf(bridge)) : NOT_ENABLED,
3657
+ reopenOrder: async (order, bridge) => options.enabled ? reopenOrder(order.verticalRef, portOf(bridge)) : ORDER_CLOSED,
3658
+ readAccess: async (verticalRef, bridge) => options.enabled ? readAccess3(verticalRef, portOf(bridge)) : "unavailable"
3631
3659
  };
3632
- }
3633
- var wixVideoOrders = /* @__PURE__ */ videoOrdersWith({ enabled: VIDEOS_APPLE_SALES_ENABLED });
3660
+ return adapter;
3661
+ }
3662
+ async function openOrder(item, port) {
3663
+ const videoId = item.reference.id;
3664
+ const answer = await port.openSaleOrder(videoId);
3665
+ if (answer.status === "ok") return { status: "open", cashierOrderId: answer.orderId, verticalRef: { videoId, orderId: answer.orderId } };
3666
+ if (answer.status !== "refused") return attemptRefused(answer);
3667
+ if (answer.reason === "active") return GRANTED;
3668
+ return answer.reason === "pending" ? { status: "refused", reason: "paymentInProgress" } : ORDER_REFUSED;
3669
+ }
3670
+ async function reopenOrder(verticalRef, port) {
3671
+ const { videoId, orderId } = verticalRef;
3672
+ if (!isNonEmpty3(videoId) || !isNonEmpty3(orderId)) return ORDER_CLOSED;
3673
+ const answer = await port.salePurchase(videoId);
3674
+ if (answer.status !== "ok") return attemptRefused(answer);
3675
+ const purchase = answer.purchase;
3676
+ if (purchase?.status === "ACTIVE") return GRANTED;
3677
+ if (purchase && purchase.orderId === orderId && UNPAID.has(purchase.status)) return { status: "open", cashierOrderId: orderId, verticalRef: { videoId, orderId } };
3678
+ return ORDER_CLOSED;
3679
+ }
3680
+ async function readAccess3(verticalRef, port) {
3681
+ const { videoId, orderId } = verticalRef;
3682
+ if (!isNonEmpty3(videoId) || !isNonEmpty3(orderId)) return "unavailable";
3683
+ const answer = await port.salePurchase(videoId);
3684
+ if (answer.status !== "ok") return accessRefused(answer);
3685
+ const purchase = answer.purchase;
3686
+ if (purchase?.status === "ACTIVE") return "granted";
3687
+ if (!purchase || purchase.orderId !== orderId) return "unavailable";
3688
+ if (UNPAID.has(purchase.status)) return "pending";
3689
+ return ENDED.has(purchase.status) ? "none" : "unavailable";
3690
+ }
3691
+ function dataAt(body, path) {
3692
+ let node = isObject7(body) && isObject7(body.data) ? body.data : body;
3693
+ for (const key of path) node = isObject7(node) ? node[key] : void 0;
3694
+ return isObject7(node) ? node : null;
3695
+ }
3696
+ var ENDED = /* @__PURE__ */ new Set(["DECLINED", "EXPIRED", "CANCELED", "REFUNDED", "FAILED"]);
3697
+ var UNPAID = /* @__PURE__ */ new Set(["INITIALIZED", "PENDING"]);
3698
+ var PENDING_MESSAGE = "Pending payment for the purchase";
3699
+ var ACTIVE_MESSAGE = "Active purchase already existed";
3700
+ var CREATE_ORDER = `mutation HimiVideoSaleOrder($videoId: ID!) {
3701
+ purchase { order { create(input: {id: $videoId, type: SALE}) { status message entity { id } } } }
3702
+ }`;
3703
+ var SALE_PURCHASE = `query HimiVideoSalePurchase($videoId: ID!) {
3704
+ purchase(filter: {id: $videoId, type: SALE}) { status orderId }
3705
+ }`;
3706
+ var wixVideoOrders = /* @__PURE__ */ videoOrdersWith({ enabled: videosAppleSalesEnabled() });
3634
3707
 
3635
3708
  // ../../stdlib/flows/iap-checkout/src/iap-verticals/index.ts
3636
3709
  var onlineProgramOrders = onlineProgramItemPayments;
@@ -3649,6 +3722,7 @@ export {
3649
3722
  pricingPlanOrders,
3650
3723
  storesAppleSalesEnabled,
3651
3724
  storesProductOrders,
3725
+ videosAppleSalesEnabled,
3652
3726
  wixVideoOrders
3653
3727
  };
3654
3728
  //# sourceMappingURL=iap-checkout.mjs.map
@@ -40,7 +40,7 @@ var CAPABILITY_REGISTRY = {
40
40
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
41
41
  "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
42
42
  "network": ["status", "subscribe"],
43
- "on_device_ai": ["availability", "generateText"],
43
+ "on_device_ai": ["availability", "generateText", "proofreadText", "rewriteText", "summarizeText"],
44
44
  "open_url": ["canOpen", "open"],
45
45
  "pdf": ["isAvailable", "open"],
46
46
  "photos": ["getSavePermissionStatus", "pick", "saveToLibrary"],
@@ -40,7 +40,7 @@ var CAPABILITY_REGISTRY = {
40
40
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
41
41
  "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
42
42
  "network": ["status", "subscribe"],
43
- "on_device_ai": ["availability", "generateText"],
43
+ "on_device_ai": ["availability", "generateText", "proofreadText", "rewriteText", "summarizeText"],
44
44
  "open_url": ["canOpen", "open"],
45
45
  "pdf": ["isAvailable", "open"],
46
46
  "photos": ["getSavePermissionStatus", "pick", "saveToLibrary"],
@@ -50,10 +50,54 @@ async function generateJson(input) {
50
50
  return null;
51
51
  }
52
52
  }
53
+ function taskResult(r) {
54
+ return {
55
+ success: !!r?.success,
56
+ text: r?.text,
57
+ status: typeof r?.status === "number" ? r.status : r?.success ? 200 : 0,
58
+ error: r?.error,
59
+ engine: r?.engine
60
+ };
61
+ }
62
+ var UNKNOWN_ACTION = /unknown[_ ]?(action|handler)|ActionError\.unknown|^unknown\(|no handler/i;
63
+ async function runTask(pending, fallback) {
64
+ try {
65
+ return taskResult(await pending());
66
+ } catch (e) {
67
+ if (UNKNOWN_ACTION.test(String(e?.message ?? e))) return fallback();
68
+ throw e;
69
+ }
70
+ }
71
+ function viaGenerateText(systemPrompt, text) {
72
+ return generateText({ systemPrompt: `${systemPrompt} Reply with the result only.`, userPrompt: text, responseSchema: {} });
73
+ }
74
+ var REWRITE_HOW = {
75
+ rephrase: "Rephrase the user's text with the same meaning and length.",
76
+ shorter: "Make the user's text shorter while keeping its meaning.",
77
+ elaborate: "Expand the user's text with more detail while keeping its meaning.",
78
+ friendly: "Make the user's text warmer and more casual.",
79
+ professional: "Make the user's text more formal and professional.",
80
+ emojify: "Add fitting emoji to the user's text without changing its words."
81
+ };
82
+ var TEXT_REQUIRED = Object.freeze({ success: false, status: 0, error: "text is required" });
53
83
  async function summarize(text, opts = {}) {
54
- const instruction = opts.instruction ? ` ${opts.instruction}.` : "";
84
+ if (!text?.trim()) return TEXT_REQUIRED;
85
+ if (opts.instruction) return summarizeWithInstruction(text, opts.instruction, opts.taskComplexity ?? "MEDIUM");
86
+ const format = opts.format ?? "paragraph";
87
+ const length = opts.length ?? "medium";
88
+ return runTask(() => dispatch("capability.on_device_ai.summarizeText", { text, format, length }), () => summarizeWithInstruction(text, `${length === "short" ? "In one or two sentences" : length === "long" ? "In detail" : "Briefly"}${format === "bullets" ? ", as a bulleted list" : ""}`, "MEDIUM"));
89
+ }
90
+ async function rewrite(text, style = "rephrase") {
91
+ if (!text?.trim()) return TEXT_REQUIRED;
92
+ return runTask(() => dispatch("capability.on_device_ai.rewriteText", { text, style }), () => viaGenerateText(REWRITE_HOW[style] ?? REWRITE_HOW.rephrase, text));
93
+ }
94
+ async function proofread(text) {
95
+ if (!text?.trim()) return TEXT_REQUIRED;
96
+ return runTask(() => dispatch("capability.on_device_ai.proofreadText", { text }), () => viaGenerateText("Correct the spelling, grammar and punctuation of the user's text without changing its meaning or style.", text));
97
+ }
98
+ async function summarizeWithInstruction(text, instruction, taskComplexity) {
55
99
  const res = await generateText({
56
- systemPrompt: `You are a concise summarizer. Summarize the user's text faithfully.${instruction} Respond ONLY with JSON matching the schema.`,
100
+ systemPrompt: `You are a concise summarizer. Summarize the user's text faithfully. ${instruction}. Respond ONLY with JSON matching the schema.`,
57
101
  userPrompt: text,
58
102
  responseSchema: {
59
103
  type: "object",
@@ -61,7 +105,7 @@ async function summarize(text, opts = {}) {
61
105
  required: ["summary"],
62
106
  additionalProperties: false
63
107
  },
64
- taskComplexity: opts.taskComplexity ?? "MEDIUM"
108
+ taskComplexity
65
109
  });
66
110
  if (!res.success || !res.text) return res;
67
111
  try {
@@ -76,6 +120,8 @@ export {
76
120
  availability,
77
121
  generateJson,
78
122
  generateText,
123
+ proofread,
124
+ rewrite,
79
125
  summarize,
80
126
  version
81
127
  };
@@ -40,7 +40,7 @@ var CAPABILITY_REGISTRY = {
40
40
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
41
41
  "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
42
42
  "network": ["status", "subscribe"],
43
- "on_device_ai": ["availability", "generateText"],
43
+ "on_device_ai": ["availability", "generateText", "proofreadText", "rewriteText", "summarizeText"],
44
44
  "open_url": ["canOpen", "open"],
45
45
  "pdf": ["isAvailable", "open"],
46
46
  "photos": ["getSavePermissionStatus", "pick", "saveToLibrary"],
@@ -3243,6 +3243,9 @@ var HIMALAYA_SERVE_CHECKOUT_ROUTES = {
3243
3243
  function appleIapCheckoutRoutes() {
3244
3244
  return HIMALAYA_SERVE_CHECKOUT_ROUTES;
3245
3245
  }
3246
+ function videosAppleSalesEnabled() {
3247
+ return VIDEOS_APPLE_SALES_ENABLED;
3248
+ }
3246
3249
 
3247
3250
  // ../../stdlib/flows/iap-checkout/src/cashier-charges.ts
3248
3251
  async function ensureAppleIapCharge(bridge, route, orderId) {
@@ -3794,7 +3797,7 @@ function createWixOrderBackend(deps) {
3794
3797
  case "approved":
3795
3798
  return alreadyPaid(sale, ref);
3796
3799
  case "closed":
3797
- return options.reordered ? stopWith("rejected", "orderClosed") : reorder(sale);
3800
+ return options.reordered ? stopWith("rejected", "orderClosed") : reorder(sale, ref.cashierOrderId);
3798
3801
  case "inOtherPayment":
3799
3802
  return stopWith("rejected", "orderRefused");
3800
3803
  case "refused":
@@ -3808,10 +3811,11 @@ function createWixOrderBackend(deps) {
3808
3811
  return retry("unavailable");
3809
3812
  }
3810
3813
  }
3811
- async function reorder(sale) {
3814
+ async function reorder(sale, closedOrderId) {
3812
3815
  if (sale.adapter.repeatable) return stopWith("rejected", "orderClosed");
3813
3816
  if (!forget(sale, sale.catalogRef)) return stopWith("rejected", "storageUnavailable");
3814
3817
  const attempt4 = await sale.adapter.openOrder(sale.item, sale.bridge);
3818
+ if (attempt4.status === "open" && attempt4.cashierOrderId === closedOrderId) return stopWith("rejected", "needsSupport");
3815
3819
  const recorded = recordOrder(sale, void 0, attempt4);
3816
3820
  return isStop(recorded) ? recorded : chargeFor(sale, recorded, { reordered: true, placed: isPlaced(attempt4) });
3817
3821
  }
@@ -4920,6 +4924,9 @@ function isNonEmpty3(value) {
4920
4924
  return typeof value === "string" && value.length > 0;
4921
4925
  }
4922
4926
  var UNSUPPORTED = { eligible: false, reason: "unsupportedItem" };
4927
+ var ORDER_REFUSED = { status: "refused", reason: "orderRefused" };
4928
+ var ORDER_CLOSED = { status: "refused", reason: "orderClosed" };
4929
+ var GRANTED = { status: "granted" };
4923
4930
 
4924
4931
  // ../../stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans.ts
4925
4932
  var KIND = "pricingPlan";
@@ -4962,6 +4969,89 @@ async function planAccess(planId, bridge) {
4962
4969
  }
4963
4970
  }
4964
4971
 
4972
+ // ../../stdlib/flows/iap-checkout/src/iap-verticals/videos.ts
4973
+ var KIND2 = "wixVideo";
4974
+ var NOT_ENABLED = { status: "refused", reason: "notEnabled" };
4975
+ var VIDEO_GRAPHQL_URL = "https://manage.wix.com/_api/vod/public/graphql";
4976
+ var graphqlVideoPort = (bridge) => ({
4977
+ async openSaleOrder(videoId) {
4978
+ const answer = await bridge.call("POST", VIDEO_GRAPHQL_URL, { query: CREATE_ORDER, variables: { videoId } });
4979
+ if (isRefusal(answer)) return answer;
4980
+ const created = dataAt(answer.body, ["purchase", "order", "create"]);
4981
+ if (!created) return { status: "unavailable" };
4982
+ const orderId = isObject7(created.entity) ? created.entity.id : void 0;
4983
+ if (created.status === "SUCCESS" && isNonEmpty3(orderId)) return { status: "ok", orderId };
4984
+ const message = typeof created.message === "string" ? created.message : "";
4985
+ return { status: "refused", reason: message === PENDING_MESSAGE ? "pending" : message === ACTIVE_MESSAGE ? "active" : "other" };
4986
+ },
4987
+ async salePurchase(videoId) {
4988
+ const answer = await bridge.call("POST", VIDEO_GRAPHQL_URL, { query: SALE_PURCHASE, variables: { videoId } });
4989
+ if (isRefusal(answer)) return answer;
4990
+ const data = isObject7(answer.body) && isObject7(answer.body.data) ? answer.body.data : null;
4991
+ if (!data || !("purchase" in data)) return { status: "unavailable" };
4992
+ const found = isObject7(data.purchase) ? data.purchase : null;
4993
+ if (!found) return { status: "ok", purchase: null };
4994
+ if (!isNonEmpty3(found.status)) return { status: "unavailable" };
4995
+ return { status: "ok", purchase: { status: found.status, orderId: isNonEmpty3(found.orderId) ? found.orderId : null } };
4996
+ }
4997
+ });
4998
+ function videoOrdersWith(options) {
4999
+ const portOf = options.port ?? graphqlVideoPort;
5000
+ const adapter = {
5001
+ kind: KIND2,
5002
+ eligibility: (item) => options.enabled ? singleUnitOf(KIND2, item) : { eligible: false, reason: "notEnabled" },
5003
+ openOrder: async (item, bridge) => options.enabled ? openOrder(item, portOf(bridge)) : NOT_ENABLED,
5004
+ reopenOrder: async (order, bridge) => options.enabled ? reopenOrder(order.verticalRef, portOf(bridge)) : ORDER_CLOSED,
5005
+ readAccess: async (verticalRef, bridge) => options.enabled ? readAccess(verticalRef, portOf(bridge)) : "unavailable"
5006
+ };
5007
+ return adapter;
5008
+ }
5009
+ async function openOrder(item, port) {
5010
+ const videoId = item.reference.id;
5011
+ const answer = await port.openSaleOrder(videoId);
5012
+ if (answer.status === "ok") return { status: "open", cashierOrderId: answer.orderId, verticalRef: { videoId, orderId: answer.orderId } };
5013
+ if (answer.status !== "refused") return attemptRefused(answer);
5014
+ if (answer.reason === "active") return GRANTED;
5015
+ return answer.reason === "pending" ? { status: "refused", reason: "paymentInProgress" } : ORDER_REFUSED;
5016
+ }
5017
+ async function reopenOrder(verticalRef, port) {
5018
+ const { videoId, orderId } = verticalRef;
5019
+ if (!isNonEmpty3(videoId) || !isNonEmpty3(orderId)) return ORDER_CLOSED;
5020
+ const answer = await port.salePurchase(videoId);
5021
+ if (answer.status !== "ok") return attemptRefused(answer);
5022
+ const purchase = answer.purchase;
5023
+ if (purchase?.status === "ACTIVE") return GRANTED;
5024
+ if (purchase && purchase.orderId === orderId && UNPAID.has(purchase.status)) return { status: "open", cashierOrderId: orderId, verticalRef: { videoId, orderId } };
5025
+ return ORDER_CLOSED;
5026
+ }
5027
+ async function readAccess(verticalRef, port) {
5028
+ const { videoId, orderId } = verticalRef;
5029
+ if (!isNonEmpty3(videoId) || !isNonEmpty3(orderId)) return "unavailable";
5030
+ const answer = await port.salePurchase(videoId);
5031
+ if (answer.status !== "ok") return accessRefused(answer);
5032
+ const purchase = answer.purchase;
5033
+ if (purchase?.status === "ACTIVE") return "granted";
5034
+ if (!purchase || purchase.orderId !== orderId) return "unavailable";
5035
+ if (UNPAID.has(purchase.status)) return "pending";
5036
+ return ENDED.has(purchase.status) ? "none" : "unavailable";
5037
+ }
5038
+ function dataAt(body, path) {
5039
+ let node3 = isObject7(body) && isObject7(body.data) ? body.data : body;
5040
+ for (const key of path) node3 = isObject7(node3) ? node3[key] : void 0;
5041
+ return isObject7(node3) ? node3 : null;
5042
+ }
5043
+ var ENDED = /* @__PURE__ */ new Set(["DECLINED", "EXPIRED", "CANCELED", "REFUNDED", "FAILED"]);
5044
+ var UNPAID = /* @__PURE__ */ new Set(["INITIALIZED", "PENDING"]);
5045
+ var PENDING_MESSAGE = "Pending payment for the purchase";
5046
+ var ACTIVE_MESSAGE = "Active purchase already existed";
5047
+ var CREATE_ORDER = `mutation HimiVideoSaleOrder($videoId: ID!) {
5048
+ purchase { order { create(input: {id: $videoId, type: SALE}) { status message entity { id } } } }
5049
+ }`;
5050
+ var SALE_PURCHASE = `query HimiVideoSalePurchase($videoId: ID!) {
5051
+ purchase(filter: {id: $videoId, type: SALE}) { status orderId }
5052
+ }`;
5053
+ var wixVideoOrders = /* @__PURE__ */ videoOrdersWith({ enabled: videosAppleSalesEnabled() });
5054
+
4965
5055
  // ../../stdlib/flows/iap-checkout/src/iap-verticals/index.ts
4966
5056
  var pricingPlanOrders = pricingPlanItemPayments;
4967
5057
 
@@ -25,7 +25,7 @@ var CAPABILITY_REGISTRY = {
25
25
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
26
26
  "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
27
27
  "network": ["status", "subscribe"],
28
- "on_device_ai": ["availability", "generateText"],
28
+ "on_device_ai": ["availability", "generateText", "proofreadText", "rewriteText", "summarizeText"],
29
29
  "open_url": ["canOpen", "open"],
30
30
  "pdf": ["isAvailable", "open"],
31
31
  "photos": ["getSavePermissionStatus", "pick", "saveToLibrary"],
@@ -40,7 +40,7 @@ var CAPABILITY_REGISTRY = {
40
40
  "media_playback": ["download", "getCapabilities", "getState", "next", "pause", "pictureInPicture", "play", "presentFullscreen", "previous", "release", "removeDownload", "seek", "seekTo", "setMuted", "setQueue", "setRate", "skip", "status", "stop", "subscribeStatus", "unsubscribeStatus"],
41
41
  "motion": ["availability", "getAltitude", "getHeading", "getPermissionStatus", "getStepCount", "openStepHistorySetup", "requestPermission", "watchNext", "watchStart", "watchStop"],
42
42
  "network": ["status", "subscribe"],
43
- "on_device_ai": ["availability", "generateText"],
43
+ "on_device_ai": ["availability", "generateText", "proofreadText", "rewriteText", "summarizeText"],
44
44
  "open_url": ["canOpen", "open"],
45
45
  "pdf": ["isAvailable", "open"],
46
46
  "photos": ["getSavePermissionStatus", "pick", "saveToLibrary"],