@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
Binary file
@@ -314,10 +314,10 @@ binary carries neither the code nor the store-review footprint of a framework it
314
314
  | iap | `iap` (and `wix_cashier` on iOS) |
315
315
  | live_activity | `live_activity` |
316
316
  | location | `location`, `location_background` |
317
- | location_background (iOS) | `location_background` |
317
+ | location_background | `location_background` |
318
318
  | media | `media_playback`, `video_playback` (in-app video: no iOS background audio, no Android media foreground service) |
319
319
  | motion | `motion` |
320
- | on_device_ai (iOS) | `on_device_ai` |
320
+ | on_device_ai | `on_device_ai` |
321
321
  | push | `push` |
322
322
  | speech (iOS) | `speech` |
323
323
  | tasks (iOS) | `tasks` |
@@ -159,7 +159,8 @@ changed (the text, the component, the token, "logic changed" for a worker-only e
159
159
  in its `{"watch":"rebuilt"}` line. Check the map before handover: an unreached screen or a broken
160
160
  link is a gap to close or to name. `himi test` writes one PNG per
161
161
  screen to `.himi/shots/` on every run, so take the new screens from there instead of rendering each
162
- one again; a bare `--png` on `himi render` writes `.himi/shots/<id>.png`. `himi progress` copies each image into `.himi/history/`
162
+ one again; a bare `--png` on `himi render` writes that run's own `.himi/renders/<id>/<hash>.png` (the `pngFile` it
163
+ prints, so renders you run in parallel never swap pictures) and refreshes `.himi/shots/<id>.png` as the newest one. `himi progress` copies each image into `.himi/history/`
163
164
  as it was when you journaled it, so a later render cannot change what the record says the owner saw;
164
165
  `--step` takes the journey step's number or name, and `--notify` also raises a desktop
165
166
  notification for an owner who stepped away. Nothing here is sent anywhere, and `.himi/` and a
@@ -557,8 +557,8 @@ In order:
557
557
  4. **One mapping per Wix item → Apple product, through Catalog `listProducts` / `createProduct`.** Online Programs map by program id, Wix Stores
558
558
  digital products by product id, one-time unlimited Pricing Plans by plan id, and Wix videos by
559
559
  video id (the ids the purchase flow looks up), all only as non-consumables. A mapped video gets
560
- its App Store price on the Videos screens; buying it is not available yet (prices only,
561
- [checkout](iap-wix-checkout.md#wix-video-prices-only)). A plan is mapped only when the site reads it
560
+ its App Store price on the Videos screens; buying it stays off until its live gates pass (device order,
561
+ [checkout](iap-wix-checkout.md#wix-video-the-device-opens-videos-order)). A plan is mapped only when the site reads it
562
562
  as one-time unlimited (one payment, valid until cancelled); a recurring, time-limited or archived
563
563
  plan is skipped. When the site's plans cannot be read, each plan is `failed` (`request_failed`,
564
564
  `unverified` in the dry-run diff) and not mapped. Other verticals, price tiers and consumable items
@@ -21,7 +21,7 @@ and generated templates. Historical receipts retain their recorded amounts.
21
21
  | `himi-branded-lite-cart` | Full catalog app/item/options reference and quantity; line `total` | Refreshes the current cart and routes before payment; only verified physical regular carts keep checkout; Apple, mixed, multiple-digital, unknown and unverified digital carts are blocked |
22
22
  | `himi-store-cart` | Full catalog reference; line `total` | Consistent shared prices and suppressed Wix subtotal when routes are unsettled or Apple; remains read-only |
23
23
  | `himi-branded-lite-order` | Original catalog app/item/options and quantity | Preserves references; checks current routing and catalog facts before re-adding physical items; never reprices the paid receipt |
24
- | `himi-branded-lite-videos`, `himi-branded-lite-video` (Videos, channel and Video screens) | Wix video ID (`wixVideo`); carousel and row `priceLine`, Video `priceText` / `priceNote` / `purchaseNote` | Shared pricing for videos with a one-time Sale price, in channels that require no subscription or plan. Prices only: no Buy; `wixVideoOrders` refuses while `VIDEOS_APPLE_SALES_ENABLED` is off. Home's video rail stays unpriced |
24
+ | `himi-branded-lite-videos`, `himi-branded-lite-video` (Videos, channel and Video screens) | Wix video ID (`wixVideo`); carousel and row `priceLine`, Video `priceText` / `priceNote` / `purchaseNote` | Shared pricing for videos with a one-time Sale price, in channels that require no subscription or plan. The Video screen's Buy (`buyHidden` / `buyLabel` / `buyDisabled` / `buyNote`) sells through `wixVideoOrders`, the device's own Video order, only while `VIDEOS_APPLE_SALES_ENABLED` is on; it is off, so no Buy shows. Home's video rail stays unpriced |
25
25
  | `video-courses-preview` / Atlas | `storeProductId`, plus course-specific member access mirror | Deferred: deployment and usable course access are unverified. Existing native digital-checkout guard remains; Atlas courses are Stores products, not Wix Video, so `wixVideoOrders` does not apply |
26
26
  | `wix-spaces-product-detail`, `wix-spaces-shop`, `wix-spaces-saved`, `wix-spaces-cart` | Legacy worker sources | Retired `fixtures/wix-spaces-clone/dev` descriptors still reference these workers; no active app or generated template consumer. Legacy pricing/checkout is not migrated or certified for managed Apple IAP |
27
27
  | `hip-shop-product`, `hip-shop-home`, `hip-shop-explore`, `hip-shop-saved`, `hip-shop-cart` | Legacy worker sources | Retired `fixtures/hip-shop/dev` descriptors reference these workers; no active app or generated template consumer. Legacy pricing/checkout is not migrated or certified for managed Apple IAP |
@@ -2807,7 +2807,7 @@
2807
2807
  {
2808
2808
  "name": "VIDEOS_APPLE_SALES_ENABLED",
2809
2809
  "kind": "const",
2810
- "jsdoc": "/**\n * Whether Wix Video videos sell through the App Store. OFF: prices only. A video with a one-time Sale\n * price above zero is mapped under its video id as a one-time unlock (`wixVideoItem`), and screens show\n * its App Store price, but no purchase path exists yet: Wix Video has no public order API, and the\n * Videos order adapter refuses every sale until this is on.\n */",
2810
+ "jsdoc": "/**\n * Whether Wix Video videos sell through the App Store. OFF until the Wix Video purchase is proven live\n * (gates G1–G4). A video with a one-time Sale price above zero is mapped under\n * its video id as a one-time unlock (`wixVideoItem`), and screens show its App Store price. ON, the Video\n * screen offers Buy: the device opens Video's own SALE order on its GraphQL gateway (`wixVideoOrders`),\n * and the shared checkout charges it with appleIAP and pays it through StartPayment. OFF, the adapter\n * refuses every sale and the screen composes no checkout.\n */",
2811
2811
  "decl": "export const VIDEOS_APPLE_SALES_ENABLED = false;",
2812
2812
  "verificationChecked": true
2813
2813
  },
@@ -3343,7 +3343,7 @@
3343
3343
  "name": "\"./checkout-source.js\"",
3344
3344
  "kind": "reexport",
3345
3345
  "jsdoc": "",
3346
- "decl": "export { storesAppleSalesEnabled } from \"./checkout-source.js\";",
3346
+ "decl": "export { storesAppleSalesEnabled, videosAppleSalesEnabled } from \"./checkout-source.js\";",
3347
3347
  "verificationChecked": true
3348
3348
  },
3349
3349
  {
@@ -3423,6 +3423,13 @@
3423
3423
  "decl": "export function storesAppleSalesEnabled(): boolean;",
3424
3424
  "verificationChecked": true
3425
3425
  },
3426
+ {
3427
+ "name": "videosAppleSalesEnabled",
3428
+ "kind": "function",
3429
+ "jsdoc": "/** Whether a Wix Video sells through the App Store: the device opens Video's SALE order and the\n * shared checkout pays it (`VIDEOS_APPLE_SALES_ENABLED` in @himalaya/iap, off until its live gates pass). */",
3430
+ "decl": "export function videosAppleSalesEnabled(): boolean;",
3431
+ "verificationChecked": true
3432
+ },
3426
3433
  {
3427
3434
  "name": "WixBridge",
3428
3435
  "kind": "interface",
@@ -4246,7 +4253,7 @@
4246
4253
  "name": "RegionMonitoringSupport",
4247
4254
  "kind": "interface",
4248
4255
  "jsdoc": "",
4249
- "decl": "export interface RegionMonitoringSupport {\n /** False on Android and web. Check it BEFORE relying on a terminated-app trigger. */\n available: boolean;\n /** How many regions the OS will monitor for this app. iOS: 20, process-wide. */\n maxRegions: number;\n /** Radii below this are unreliable on consumer GPS and are clamped up to it. */\n minRadiusM: number;\n /** The largest radius this device will monitor; a larger region is never entered. */\n maxRadiusM: number;\n}",
4256
+ "decl": "export interface RegionMonitoringSupport {\n /** False on the web, and wherever the module is not linked. Check it BEFORE relying on a\n * terminated-app trigger. */\n available: boolean;\n /** How many regions the OS will monitor for this app. iOS: 20, Android: 100, process-wide. */\n maxRegions: number;\n /** Radii below this are unreliable on consumer GPS and are clamped up to it. */\n minRadiusM: number;\n /** The largest radius this device will monitor; a larger region is never entered. */\n maxRadiusM: number;\n}",
4250
4257
  "verificationChecked": true
4251
4258
  },
4252
4259
  {
@@ -4260,7 +4267,7 @@
4260
4267
  "name": "MonitoredRegionResult",
4261
4268
  "kind": "interface",
4262
4269
  "jsdoc": "/** The outcome of registering a region. `radiusM` is what the OS ACTUALLY monitors — a\n * requested radius below `minRadiusM` or above the device maximum is clamped, and an app\n * drawing the circle should draw the one it got. */",
4263
- "decl": "export interface MonitoredRegionResult {\n ok: boolean;\n id?: string;\n radiusM?: number;\n /** Why it was refused: no Always grant, the region cap, or an unusable coordinate. */\n reason?: string;\n}",
4270
+ "decl": "export interface MonitoredRegionResult {\n ok: boolean;\n id?: string;\n radiusM?: number;\n /** Why it was refused: no Always grant (on Android, also only approximate location granted —\n * geofencing needs precise), the region cap, or an unusable coordinate. */\n reason?: string;\n}",
4264
4271
  "verificationChecked": true
4265
4272
  },
4266
4273
  {
@@ -4784,8 +4791,8 @@
4784
4791
  {
4785
4792
  "name": "OnDeviceEngine",
4786
4793
  "kind": "type",
4787
- "jsdoc": "/** The on-device engine backing generation, when one is available. */",
4788
- "decl": "export type OnDeviceEngine = \"foundation_models\" | \"gemini_nano\" | \"prompt_api\";",
4794
+ "jsdoc": "/** The on-device engine backing generation, when one is available. `chrome_built_in` is Chrome's\n * task model (Summarizer / Rewriter / Proofreader), which only the writing tasks report. */",
4795
+ "decl": "export type OnDeviceEngine = \"foundation_models\" | \"gemini_nano\" | \"prompt_api\" | \"chrome_built_in\";",
4789
4796
  "verificationChecked": true
4790
4797
  },
4791
4798
  {
@@ -4841,16 +4848,37 @@
4841
4848
  "name": "SummarizeOptions",
4842
4849
  "kind": "interface",
4843
4850
  "jsdoc": "",
4844
- "decl": "export interface SummarizeOptions {\n /** Extra instruction, e.g. \"in one sentence\" or \"as 3 bullet points\". */\n instruction?: string;\n /** Complexity of the summarization. Defaults to MEDIUM. */\n taskComplexity?: TaskComplexity;\n}",
4851
+ "decl": "export interface SummarizeOptions {\n /** \"paragraph\" (default) or \"bullets\". */\n format?: \"paragraph\" | \"bullets\";\n /** \"short\", \"medium\" (default) or \"long\". */\n length?: \"short\" | \"medium\" | \"long\";\n /** Extra free-form instruction, e.g. \"in one sentence\". When set, the summary is generated\n * through `generateText` with that instruction instead of the platform's summarizer. */\n instruction?: string;\n /** Complexity hint for the `instruction` path. Defaults to MEDIUM. */\n taskComplexity?: TaskComplexity;\n}",
4852
+ "verificationChecked": true
4853
+ },
4854
+ {
4855
+ "name": "RewriteStyle",
4856
+ "kind": "type",
4857
+ "jsdoc": "/** How `rewrite` should change the text. */",
4858
+ "decl": "export type RewriteStyle = \"rephrase\" | \"shorter\" | \"elaborate\" | \"friendly\" | \"professional\" | \"emojify\";",
4845
4859
  "verificationChecked": true
4846
4860
  },
4847
4861
  {
4848
4862
  "name": "summarize",
4849
4863
  "kind": "function",
4850
- "jsdoc": "/**\n * Summarize a block of text on device. Thin sugar over `generateText` with a fixed\n * `{ summary: string }` schema; returns the extracted summary in `text` (or the raw failure\n * result — check `.success`).\n */",
4864
+ "jsdoc": "/**\n * Summarize a block of text on device — the on-device model with summarization instructions (Apple\n * Foundation Models, Gemini Nano), or Chrome's Summarizer on the web. Returns plain text in `text`;\n * check `.success`.\n */",
4851
4865
  "decl": "export async function summarize(text: string, opts: SummarizeOptions = {}): Promise<GenerateTextResult>;",
4852
4866
  "verificationChecked": true
4853
4867
  },
4868
+ {
4869
+ "name": "rewrite",
4870
+ "kind": "function",
4871
+ "jsdoc": "/** Rewrite text on device in a given style (shorter, friendlier, more professional…). */",
4872
+ "decl": "export async function rewrite(text: string, style: RewriteStyle = \"rephrase\"): Promise<GenerateTextResult>;",
4873
+ "verificationChecked": true
4874
+ },
4875
+ {
4876
+ "name": "proofread",
4877
+ "kind": "function",
4878
+ "jsdoc": "/** Fix spelling and grammar on device; `text` is the corrected text. */",
4879
+ "decl": "export async function proofread(text: string): Promise<GenerateTextResult>;",
4880
+ "verificationChecked": true
4881
+ },
4854
4882
  {
4855
4883
  "name": "version",
4856
4884
  "kind": "const",
package/guides/skill.md CHANGED
@@ -210,7 +210,7 @@ If a gate is not implied (no credentials, no draft instruction, no site URL for
210
210
  1. **The board opens at init.** `himi init` creates the build board (`.himi/studio/index.html`) and its `next[]` starts with this session's first steps: run them now, in order: the first picture and its postcard, the consent preflight, then the live preview — for every template. The preflight costs nothing on an app that makes no startup request: if no worker or config can make a Wix or external request at boot, go straight on. When the installed `init` prints no `board`, run `himi studio --no-open` once in the app folder.
211
211
  2. **The first picture comes from init.** A current `himi init` renders the home screen itself — offline, it never calls Wix, so it needs no preflight; when the app has recorded data (`dev/net-mocks.json`, which `himi test --record` writes, or cms seed rows) the automatic pictures load it, and otherwise they are captioned as an offline preview, not as an error — and journals it as the STARTING POINT — the template before any of your changes, never "your app" — so the board holds a picture from the start; your first home render after you change the source is journaled as "First look at your app". It does so only for a template bundled with the CLI: one fetched with `--remote` is its publisher's code, and a render runs it on this machine, so read its `dev/`, `config.ts` and `tier5-src/` first. On an older CLI, or when its `firstLook` says `skipped`, make it yourself right after init: `himi render <homeScreenId> --png --device iphone`. The CLI journals that first look itself.
212
212
  3. **Then the live preview: init started it; if it isn't running (`--remote`, CI), start it.** A current `himi init` starts `himi run --watch` itself (its `watch` field names the url, the board and `.himi/watch.log`; it stops after 30 minutes with no save) — do not start a second one. When its `watch` says `skipped`, only once the consent preflight (journey step 4) clears the app to boot locally, run `himi run --watch --content <dir> &` and leave it up until the handover: it repaints on every save and serves the board at `<url>/__himi/studio/`. Do not wait to be reminded: a `reminder` from `himi render` or `himi test` (the last key of their output) that says to start it means none is running — run it then; one that names a url means it is running.
213
- 4. **A postcard with a picture at every journey step:** `himi progress "<what changed>" --step <n> --image .himi/shots/<screenId>.png`. Leave out `--image` and a current CLI attaches the current home shot for you — or, when that shot shows loading placeholders, an empty or an error state, the newest home picture of the current code that shows content; with none it attaches nothing, and `imageNote` says why. `himi test` and `himi push --draft` journal their own results too (a repeat draft says what changed since the last one), and a home render after ten silent minutes journals "Still building" — your postcards still say what changed and why it matters.
213
+ 4. **A postcard with a picture at every journey step:** `himi progress "<what changed>" --step <n> --image <png>`, with the `pngFile` your `himi render --png` printed (that run's own copy under `.himi/renders/`; `.himi/shots/<screenId>.png` is only the newest render, which a parallel render can replace). Leave out `--image` and a current CLI attaches the current home shot for you — or, when that shot shows loading placeholders, an empty or an error state, the newest home picture of the current code that shows content; with none it attaches nothing, and `imageNote` says why. `himi test` and `himi push --draft` journal their own results too (a repeat draft says what changed since the last one), and a home render after ten silent minutes journals "Still building" — your postcards still say what changed and why it matters.
214
214
  5. **At the handover, the picture and the making-of:** journal `himi progress "<what the owner can review>" --step review` — it carries the current home picture even when the draft's card showed it, and rebuilds and names `.himi/making-of.html` (`makingOf`) — then hand the owner that file beside the preview link (every current `himi push --draft` also writes it, as `reel`; on an older CLI run `himi studio reel`). Name the file in your final report.
215
215
 
216
216
  ## Technical handoff
@@ -38,7 +38,7 @@ answers three questions:
38
38
  > ```bash
39
39
  > himi validate --content . --strict
40
40
  > himi test --content . --json
41
- > himi render home --content . --png # bare --png: .himi/shots/home.png
41
+ > himi render home --content . --png # bare --png: pngFile (.himi/renders/home/<hash>.png) + .himi/shots/home.png
42
42
  > himi render home --content . --scheme dark --png .himi/shots/home-dark.png
43
43
  > himi ux record --content . --platform ios --status unavailable --reason "no simulator off-repo"
44
44
  > himi ux record --content . --platform android --status unavailable --reason "no emulator off-repo"
@@ -270,8 +270,9 @@ Absence is said, never silent: without the browser the report carries
270
270
  the install command `himi render --png` prints. Web fidelity, honestly named: these are the web
271
271
  renderer's pixels; native truth still comes from a device (`himi push` a preview).
272
272
 
273
- Hygiene: a **full** run owns `.himi/shots/` and clears it first, so a deleted screen
274
- leaves no stale artifact; a **targeted** run (`himi test <screenId>`) only adds its own
273
+ Hygiene: a **full** run owns `.himi/shots/`: after writing its PNGs it removes the ones of
274
+ screens it did not shoot, so a deleted screen leaves no stale artifact (it never deletes the
275
+ directory, so a `himi render` running at the same time keeps its picture); a **targeted** run (`himi test <screenId>`) only adds its own
275
276
  PNGs, and `--no-shots` leaves whatever the last shots run wrote — delete the dir if that
276
277
  matters. `--offline` strips every data layer for the crawl AND the shots alike, so the
277
278
  PNGs and the report always describe the same run.
@@ -39,7 +39,7 @@ the SDK sources, so it matches the shipped SDKs.
39
39
  - [`media_playback`](https://apps.wix.com/_api/himi-serve/authoring/resource/web-sdk%2Fmedia_playback?format=md) — Background-capable media playback and offline downloads. 21 methods · returns FileHandles.
40
40
  - [`motion`](https://apps.wix.com/_api/himi-serve/authoring/resource/web-sdk%2Fmotion?format=md) — Device's motion sensors. 7 methods.
41
41
  - [`network`](https://apps.wix.com/_api/himi-serve/authoring/resource/web-sdk%2Fnetwork?format=md) — Network capability. 1 method.
42
- - [`on_device_ai`](https://apps.wix.com/_api/himi-serve/authoring/resource/web-sdk%2Fon_device_ai?format=md) — ON-DEVICE text generation. 4 methods.
42
+ - [`on_device_ai`](https://apps.wix.com/_api/himi-serve/authoring/resource/web-sdk%2Fon_device_ai?format=md) — ON-DEVICE text generation. 6 methods.
43
43
  - [`open_url`](https://apps.wix.com/_api/himi-serve/authoring/resource/web-sdk%2Fopen_url?format=md) — Opening links + external apps. 2 methods.
44
44
  - [`pdf`](https://apps.wix.com/_api/himi-serve/authoring/resource/web-sdk%2Fpdf?format=md) — Viewing PDF documents. 2 methods.
45
45
  - [`photos`](https://apps.wix.com/_api/himi-serve/authoring/resource/web-sdk%2Fphotos?format=md) — Photo library (picker-first). 4 methods · returns FileHandles.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1724.0",
3
+ "version": "0.1725.0",
4
4
  "type": "module",
5
5
  "description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
6
6
  "keywords": [
@@ -81,5 +81,5 @@
81
81
  "artifactId": "himalaya-cli"
82
82
  }
83
83
  },
84
- "falconPackageHash": "aad0bbdce1ff36542b6167a0e6087ed91f11189e9990ddcce4a37333"
84
+ "falconPackageHash": "8dd7508f5def814e44efed68e6124c0623fb9f7dfd2bb1bf95cd0aec"
85
85
  }
@@ -81352,6 +81352,41 @@ const SCREENS = runtimeSetting({
81352
81352
  }
81353
81353
  }
81354
81354
  },
81355
+ {
81356
+ "id": "himi_video.buy",
81357
+ "body": {
81358
+ "package": "himalaya",
81359
+ "type": "Button",
81360
+ "props": {
81361
+ "title": "$service:himiBrandedVideo.buyLabel",
81362
+ "style": "primary",
81363
+ "fullWidth": true,
81364
+ "disabledPath": "$service:himiBrandedVideo.buyDisabled",
81365
+ "action": {
81366
+ "actionId": "tier5.himiBrandedVideo.buy"
81367
+ }
81368
+ }
81369
+ },
81370
+ "modifiers": {
81371
+ "hiddenPath": "$service:himiBrandedVideo.buyHidden"
81372
+ }
81373
+ },
81374
+ {
81375
+ "id": "himi_video.buy_note",
81376
+ "body": {
81377
+ "package": "himalaya",
81378
+ "type": "Text",
81379
+ "props": {
81380
+ "text": "$service:himiBrandedVideo.buyNote",
81381
+ "style": "footnote",
81382
+ "color": "textSecondary",
81383
+ "collapseWhenEmpty": true
81384
+ }
81385
+ },
81386
+ "modifiers": {
81387
+ "hiddenPath": "$service:himiBrandedVideo.buyHidden"
81388
+ }
81389
+ },
81355
81390
  {
81356
81391
  "id": "himi_video.price_retry",
81357
81392
  "body": {
@@ -1,11 +1,12 @@
1
1
  // App Store prices come from the shared IAP catalog layer (@himalaya/iap): a video with a one-time Sale
2
- // price, in a channel that does not require a subscription, is priced as `wixVideo` under its id. Prices
3
- // only: buying a video stays off (VIDEOS_APPLE_SALES_ENABLED), so the screen says so instead of a Buy.
2
+ // price, in a channel that does not require a subscription, is priced as `wixVideo` under its id. Buying
3
+ // goes through the shared checkout (`wixVideoOrders`) and only once VIDEOS_APPLE_SALES_ENABLED is on;
4
+ // until then the checkout is not composed at all and the screen says buying is not available yet.
4
5
  import { descriptionBody } from "../_shared/rich-body.js";
5
6
  import { defineService } from "@himalaya/state";
6
7
  import { iapPriceFields, wixVideoItem, type IapCatalogItem } from "@himalaya/iap";
7
- import { createIapCommerce } from "@himalaya/iap-checkout";
8
- import { iapPriceCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
8
+ import { createIapCommerce, videosAppleSalesEnabled, wixVideoOrders, type IapPurchaseFields } from "@himalaya/iap-checkout";
9
+ import { iapPriceCopy, iapPurchaseCopy, resetUnhydratedKeysOnOlderRuntime } from "../_shared/iap-worker.js";
9
10
  import { LOADING, loaded, loadFailed, needsSignIn, type LoadFlags } from "../_shared/branded-load-state.js";
10
11
  import { copyParam, stashCopy } from "../_shared/himi-copy.js";
11
12
  import {
@@ -21,6 +22,8 @@ interface S extends LoadFlags {
21
22
  playbackState: "loading" | "ready" | "processing" | "denied" | "unavailable" | "error";
22
23
  /** This run's App Store price of the video, its loading/unavailable label, or "". */
23
24
  priceText: string; priceNote: string; purchaseNote: string; hidePriceRetry: boolean;
25
+ /** The shared checkout's Buy (`commerce.purchaseFields`): shown only on the App Store route. */
26
+ buyHidden: boolean; buyLabel: string; buyDisabled: boolean; buyNote: string;
24
27
  }
25
28
  const COPY = { prefix: "video", empty: "No videos in this channel yet.", error: "Videos couldn't be loaded.", signIn: "Sign in to watch videos.", sample: () => [] };
26
29
  function input(key: string): string {
@@ -29,17 +32,28 @@ function input(key: string): string {
29
32
  }
30
33
  let generation = 0;
31
34
  const initial: S = { ...LOADING, id: "", channelId: "", title: "", description: "", videos: [], items: [], hidePlayer: true, hideNotFound: true, noEntity: false, hideRefresh: false, emptyText: "", message: "", playbackState: "loading",
32
- priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true };
35
+ priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true, buyHidden: true, buyLabel: "", buyDisabled: true, buyNote: "" };
33
36
 
34
37
  // ── App Store prices ─────
35
38
  // One writer: `load` keeps what it read in `shown` and the priced items here; every repaint goes
36
39
  // through the synchronous `publish`, which reads the latest content and prices together.
37
- const commerce = createIapCommerce({ onChange: () => { void svc.publish(); } });
40
+ /** Read once: the checkout is composed for the whole visit or not at all. */
41
+ const SELLS_THROUGH_APPLE = videosAppleSalesEnabled();
42
+ const commerce = createIapCommerce({ adapters: SELLS_THROUGH_APPLE ? [wixVideoOrders] : [], onChange: () => { void svc.publish(); } });
38
43
  const pricing = commerce.pricing;
39
44
  let shown: S = { ...initial };
40
45
  /** The item the detail prices: a locked video sold once. Rows carry their own. */
41
46
  let detailItem: IapCatalogItem | undefined;
42
47
  let rowItems: Array<IapCatalogItem | undefined> = [];
48
+ let commerceStarted = false;
49
+ /** The bought video `load` re-reads so the player replaces Buy. Only a read that failed, or that Video
50
+ * still denied while its grant catches up, runs again: after ACCESS_RELOAD_RETRY_MS, on the next repaint,
51
+ * at most ACCESS_RELOAD_ATTEMPTS times. Any other answer (the player, processing, unavailable) is final. */
52
+ let accessReload = { id: "", at: 0, attempts: 0, settled: false };
53
+ const ACCESS_RELOAD_RETRY_MS = 10_000;
54
+ const ACCESS_RELOAD_ATTEMPTS = 5;
55
+ const NOT_APPLE: IapPurchaseFields = { appleRoute: false, accessReady: false, buyLabel: "", buyDisabled: true, buyBusy: false, buyNote: "" };
56
+ const NO_BUY = { buyHidden: true, buyLabel: "", buyDisabled: true, buyNote: "" };
43
57
 
44
58
  async function priceContent(): Promise<void> {
45
59
  const items = [...(detailItem ? [detailItem] : []), ...rowItems.flatMap((item) => item ?? [])];
@@ -47,29 +61,83 @@ async function priceContent(): Promise<void> {
47
61
  void svc.publish();
48
62
  }
49
63
 
64
+ /** Every projection re-arms the checkout's poll, so it steps between cadences on any screen. */
50
65
  function priced(state: S): S {
66
+ // A read after access that did not play the video leaves no priced item, so the retry is checked here.
67
+ if (accessReload.id && !accessReload.settled && accessReload.id === state.id) reloadOnceForAccess(state.id);
68
+ return { ...projected(state), ...withPoll() } as S;
69
+ }
70
+
71
+ function projected(state: S): S {
51
72
  const copy = iapPriceCopy("video");
52
73
  const videos = state.videos.map((row, i) => ({ ...row, priceLine: rowItems[i] ? iapPriceFields(pricing.view(rowItems[i]!.reference), copy).priceText : "" }));
53
- if (!detailItem) return { ...state, videos, priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true };
74
+ if (!detailItem) return { ...state, videos, priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true, ...NO_BUY };
54
75
  const view = pricing.view(detailItem.reference);
55
- if (view.route === "disabled") return { ...state, videos, priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true };
76
+ if (view.route === "disabled") return { ...state, videos, priceText: "", priceNote: "", purchaseNote: "", hidePriceRetry: true, ...NO_BUY };
56
77
  const fields = iapPriceFields(view, copy);
57
- return { ...state, videos, priceText: fields.priceText, priceNote: fields.priceNote, purchaseNote: fields.actionNote,
78
+ const purchase = SELLS_THROUGH_APPLE ? commerce.purchaseFields(detailItem.reference, iapPurchaseCopy("video")) : NOT_APPLE;
79
+ if (purchase.accessReady) reloadOnceForAccess(state.id);
80
+ // No access for this video now (another member, or a new sale): its next grant reloads again.
81
+ else if (accessReload.id === state.id) accessReload = { id: "", at: 0, attempts: 0, settled: false };
82
+ return { ...state, videos, priceText: fields.priceText, priceNote: fields.priceNote,
83
+ // On the App Store route Buy and its own note replace "not available yet".
84
+ purchaseNote: purchase.appleRoute ? "" : fields.actionNote,
58
85
  // An incomplete host scope (a failed app-identity read) reads as non-retryable; Retry re-reads it.
59
- hidePriceRetry: fields.hidePriceRetry && commerce.scopeComplete() };
86
+ hidePriceRetry: fields.hidePriceRetry && commerce.scopeComplete(),
87
+ buyHidden: !purchase.appleRoute || purchase.accessReady, buyLabel: purchase.buyLabel, buyDisabled: purchase.buyDisabled, buyNote: purchase.buyNote };
88
+ }
89
+
90
+ /** A purchase being tracked polls faster; the directive is re-armed only when its interval changes. */
91
+ function withPoll(): { _poll?: unknown } {
92
+ const poll = SELLS_THROUGH_APPLE ? commerce.pollDirective("himiBrandedVideo.iapPoll") : undefined;
93
+ return poll ? { _poll: poll } : {};
94
+ }
95
+
96
+ /** Video says the member's purchase is ACTIVE: read the video again so the player replaces Buy. */
97
+ function reloadOnceForAccess(id: string): void {
98
+ if (!id) return;
99
+ const now = Date.now();
100
+ const same = accessReload.id === id;
101
+ if (same && (accessReload.settled || now - accessReload.at < ACCESS_RELOAD_RETRY_MS)) return;
102
+ const attempts = same ? accessReload.attempts + 1 : 1;
103
+ accessReload = { id, at: now, attempts, settled: attempts >= ACCESS_RELOAD_ATTEMPTS };
104
+ void svc.load();
105
+ }
106
+
107
+ /** First entry recovers held purchases; every later load (a return to the screen) reconciles. */
108
+ async function resumeCommerce(): Promise<void> {
109
+ if (!SELLS_THROUGH_APPLE) return;
110
+ const first = !commerceStarted;
111
+ commerceStarted = true;
112
+ await (first ? commerce.start() : commerce.reconcile());
113
+ void svc.publish();
114
+ }
115
+
116
+ /** The App Store sale of the locked video on screen, only through the shared checkout. */
117
+ async function buy(): Promise<undefined> {
118
+ const item = detailItem;
119
+ if (!SELLS_THROUGH_APPLE || !item) return undefined;
120
+ await commerce.buy({ reference: item.reference });
121
+ void svc.publish();
122
+ return undefined;
60
123
  }
61
124
  function unavailable(s: S, kind: S["playbackState"], message: string): S {
62
125
  return { ...s, ...loaded("videos", [], { ...COPY, empty: "" }), items: [], hidePlayer: true, hideNotFound: kind !== "unavailable", noEntity: kind === "unavailable", hideRefresh: kind === "unavailable", emptyText: "", message, playbackState: kind };
63
126
  }
64
- type Actions = { reset: (s: S) => S; publish: (s: S) => S; refreshPrice: (s: S) => Promise<undefined>; start: (s: S) => S; load: (s: S, arg?: unknown) => Promise<undefined> };
127
+ type Actions = {
128
+ reset: (s: S) => S; publish: (s: S) => S; refreshPrice: (s: S) => Promise<undefined>; start: (s: S) => S; load: (s: S, arg?: unknown) => Promise<undefined>;
129
+ buy: (s: S) => Promise<undefined>; iapPoll: (s: S) => Promise<undefined>;
130
+ };
65
131
  const svc = defineService<S, Actions>("himiBrandedVideo", {
66
132
  state: initial,
67
133
  notHydrated: Object.keys(initial) as (keyof S & string)[],
68
134
  actions: {
69
135
  reset: () => { shown = { ...initial }; detailItem = undefined; rowItems = []; return { ...initial }; },
70
136
  publish: () => priced(shown),
71
- start: () => ({ ...priced(shown), _poll: pricing.pollDirective("himiBrandedVideo.refreshPrice") } as S),
137
+ start: () => (SELLS_THROUGH_APPLE ? priced(shown) : { ...priced(shown), _poll: pricing.pollDirective("himiBrandedVideo.refreshPrice") } as S),
72
138
  refreshPrice: async () => { await priceContent(); return undefined; },
139
+ buy,
140
+ iapPoll: async () => { await commerce.poll(); void svc.publish(); return undefined; },
73
141
  load: async (_s, arg) => {
74
142
  stashCopy(arg);
75
143
  const request = ++generation;
@@ -130,11 +198,13 @@ const svc = defineService<S, Actions>("himiBrandedVideo", {
130
198
  { ...next, ...loadFailed("videos", error, COPY), playbackState: "error", items: [], hidePlayer: true };
131
199
  }
132
200
  if (request !== generation) return undefined;
201
+ if (accessReload.id === next.id && next.playbackState !== "error" && next.playbackState !== "denied") accessReload.settled = true;
133
202
  shown = next;
134
203
  detailItem = nextDetail;
135
204
  rowItems = nextRows;
136
205
  void svc.publish();
137
206
  void priceContent();
207
+ void resumeCommerce();
138
208
  return undefined;
139
209
  },
140
210
  },