@wix/himalaya-cli 0.1264.0 → 0.1266.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.
@@ -78,6 +78,14 @@ export interface MediaPlaybackStatus {
78
78
  bufferedMs: number;
79
79
  queue: MediaQueueItem[];
80
80
  error?: string;
81
+ /** Set when `persistPosition` resumed the current item from a natively saved position
82
+ * (no explicit `startPositionMs` was passed). Absent otherwise. */
83
+ resumedFromMs?: number;
84
+ }
85
+ /** Lock-screen / notification skip-by-seconds controls. Either side may be omitted. */
86
+ export interface MediaSkipIntervals {
87
+ forwardSec?: number;
88
+ backwardSec?: number;
81
89
  }
82
90
  export interface MediaDownloadResult {
83
91
  id: string;
@@ -102,7 +110,41 @@ export declare function setQueue(items: MediaQueueItem[], options?: {
102
110
  * RFC 0040's StreamDirective `onEvent`, for the same reason.
103
111
  */
104
112
  onStatus?: string;
113
+ /**
114
+ * Skip-by-seconds on the lock screen / Now Playing (iOS `skipForwardCommand` /
115
+ * `skipBackwardCommand`), the Android media notification + session, and on web the
116
+ * browser Media Session (`seekbackward` / `seekforward`). Unset keeps today's controls
117
+ * (iOS next/previous track; Android rewind 15 s / forward 30 s). Capped at 3600 s.
118
+ */
119
+ skipIntervals?: MediaSkipIntervals;
120
+ /** Rates offered to iOS `changePlaybackRateCommand` and the Android session's speed
121
+ * button (which shows the current rate and cycles through these). Defaults to 0.5x–2x;
122
+ * each is clamped to the capability's 0.5–3 range. Web has no lock-screen speed control. */
123
+ playbackRates?: number[];
124
+ /**
125
+ * Save the position natively per item id (every ~5 s, and on pause/stop; cleared once
126
+ * the item is >95% played), so a process kill mid-episode resumes where it stopped.
127
+ * When set and `startPositionMs` is NOT passed, loading an item resumes from the saved
128
+ * position and `status.resumedFromMs` reports it. An explicit `startPositionMs` wins.
129
+ */
130
+ persistPosition?: boolean;
131
+ /**
132
+ * With `persistPosition`: treat `startPositionMs` as a FALLBACK — the host's own saved
133
+ * position wins when it has one (it is saved natively every few seconds, so it is never
134
+ * older than a worker's last progress row). A host that predates this flag ignores it and
135
+ * starts at `startPositionMs`, as before.
136
+ */
137
+ startPositionIsFallback?: boolean;
105
138
  }): Promise<MediaPlaybackStatus>;
139
+ /** The lock-screen/persistence half of `setQueue`'s options, as wire params. Every key is
140
+ * emitted only when its option is set, so a caller that sets none sends today's payload. */
141
+ export declare function encodeSessionOptions(options: {
142
+ skipIntervals?: MediaSkipIntervals;
143
+ playbackRates?: number[];
144
+ persistPosition?: boolean;
145
+ startPositionIsFallback?: boolean;
146
+ startPositionMs?: number;
147
+ }): Record<string, string>;
106
148
  /**
107
149
  * Subscribe THIS screen's worker to live playback status.
108
150
  *
@@ -865,7 +865,7 @@ function decodeCustomerId(raw) {
865
865
  }
866
866
  function decodePayment(raw, expected) {
867
867
  if (!isObject3(raw) || !hasPaymentIds(raw) || !echoes(raw, expected) || !hasValidOptionals(raw)) return null;
868
- const status = STATUSES[String(raw.status)];
868
+ const status = ownValue(STATUSES, raw.status);
869
869
  return status ? toPayment(raw, status) : null;
870
870
  }
871
871
  function hasPaymentIds(raw) {
@@ -880,7 +880,7 @@ function hasValidOptionals(raw) {
880
880
  function toPayment(raw, status) {
881
881
  const optional = {
882
882
  appProductId: raw.appProductId,
883
- cancelReason: CANCEL_REASONS[String(raw.cancelReason)],
883
+ cancelReason: ownValue(CANCEL_REASONS, raw.cancelReason),
884
884
  purchaseTransactionId: raw.purchaseTransactionId,
885
885
  expiresDate: raw.expiresDate,
886
886
  approvedDate: raw.approvedDate,
@@ -936,6 +936,9 @@ function withoutUndefined(value) {
936
936
  function isOneOf(codes, code) {
937
937
  return codes.includes(code);
938
938
  }
939
+ function ownValue(table, key) {
940
+ return typeof key === "string" && Object.prototype.hasOwnProperty.call(table, key) ? table[key] : void 0;
941
+ }
939
942
  function isObject3(value) {
940
943
  return value !== null && typeof value === "object" && !Array.isArray(value);
941
944
  }
@@ -28,7 +28,8 @@ function decodeStatus(raw) {
28
28
  rate: typeof raw?.rate === "number" ? raw.rate : 1,
29
29
  bufferedMs: typeof raw?.bufferedMs === "number" ? raw.bufferedMs : 0,
30
30
  queue: Array.isArray(raw?.queue) ? raw.queue : [],
31
- error: raw?.error
31
+ error: raw?.error,
32
+ ...typeof raw?.resumedFromMs === "number" ? { resumedFromMs: raw.resumedFromMs } : {}
32
33
  };
33
34
  }
34
35
  function isSessionRef(value) {
@@ -36,15 +37,36 @@ function isSessionRef(value) {
36
37
  }
37
38
  async function setQueue(items, options = {}) {
38
39
  if (!Array.isArray(items)) throw new Error("media-playback.setQueue: items must be an array");
40
+ const persist = options.persistPosition === true;
39
41
  const r = await dispatch("capability.media_playback.setQueue", {
40
42
  items: JSON.stringify(items),
41
43
  startIndex: String(options.startIndex ?? 0),
42
- startPositionMs: String(options.startPositionMs ?? 0),
44
+ // With persistPosition, an ABSENT start position is how the host knows to resume from
45
+ // the saved one — so it is only omitted then. Every other caller sends what it always did.
46
+ ...persist && options.startPositionMs === void 0 ? {} : { startPositionMs: String(options.startPositionMs ?? 0) },
43
47
  autoplay: String(options.autoplay === true),
44
- ...options.onStatus ? { onStatus: options.onStatus } : {}
48
+ ...options.onStatus ? { onStatus: options.onStatus } : {},
49
+ ...encodeSessionOptions(options)
45
50
  });
46
51
  return decodeStatus(r);
47
52
  }
53
+ function positiveSeconds(value) {
54
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.round(value) : void 0;
55
+ }
56
+ function encodeSessionOptions(options) {
57
+ const out = {};
58
+ const forward = positiveSeconds(options.skipIntervals?.forwardSec);
59
+ const backward = positiveSeconds(options.skipIntervals?.backwardSec);
60
+ if (forward !== void 0) out.skipForwardSec = String(forward);
61
+ if (backward !== void 0) out.skipBackwardSec = String(backward);
62
+ const rates = (options.playbackRates ?? []).filter((r) => typeof r === "number" && Number.isFinite(r)).map((r) => Math.min(3, Math.max(0.5, r)));
63
+ if (rates.length) out.playbackRates = [...new Set(rates)].sort((a, b) => a - b).join(",");
64
+ if (options.persistPosition === true) out.persistPosition = "true";
65
+ if (options.persistPosition === true && options.startPositionIsFallback === true && options.startPositionMs !== void 0) {
66
+ out.startPositionFallback = "true";
67
+ }
68
+ return out;
69
+ }
48
70
  async function subscribeStatus(handler) {
49
71
  if (!handler.includes(".")) {
50
72
  throw new Error('media-playback.subscribeStatus: handler must be "<service>.<action>"');
@@ -150,6 +172,7 @@ async function removeDownload(id) {
150
172
  var version = 1;
151
173
  export {
152
174
  download,
175
+ encodeSessionOptions,
153
176
  getCapabilities,
154
177
  getState,
155
178
  next,
package/dist/cli.mjs CHANGED
@@ -144649,23 +144649,23 @@ var init_preview_assets_generated = __esm({
144649
144649
  "../../packages/serve/src/preview-assets.generated.ts"() {
144650
144650
  init_preview_assets_format();
144651
144651
  PREVIEW_ASSET_MANIFEST = [
144652
- { key: "assets/index-Cp9s6iew.js", contentType: "application/javascript; charset=utf-8", offset: 8, length: 1215608, sha256: "d8146f84ef505b37316197ed7df5e1dc03254ac000b05ad1fb7c99af4a0f75b1" },
144653
- { key: "assets/pdf.worker.min-BmVo14Nb.mjs", contentType: "application/octet-stream", offset: 1215616, length: 1317034, sha256: "a33cfe728c584fdba4fcc1fd54bcdc2f9f2f13889ddbb5b2bd1d0f8cbe49b84e" },
144654
- { key: "assets/pdfDocument-DI7C0g9C.js", contentType: "application/javascript; charset=utf-8", offset: 2532650, length: 489166, sha256: "f5e341a8e5dd7dcc319b059321b9fab3d65aa41aa8fec7abbdc5251541d01946" },
144655
- { key: "fonts/Roboto-LICENSE.txt", contentType: "application/octet-stream", offset: 3021816, length: 4610, sha256: "994062dd7af4186a739de55dd9e151c63b6301f8e2cbafc608d35c2e87da0cd2" },
144656
- { key: "fonts/Roboto-Variable.ttf", contentType: "font/ttf", offset: 3026426, length: 488584, sha256: "d7598e12c5dbef095ff8272cfc55da0250bd07fbdecbac8a530b9b277872a134" },
144657
- { key: "fonts/WixMadeforDisplay-Bold.ttf", contentType: "font/ttf", offset: 3515010, length: 90924, sha256: "ec4c7d63772d980d6e147b2df6215fd2737e4b04cebe0cf7e11dc695fb63cdcf" },
144658
- { key: "fonts/WixMadeforDisplay-ExtraBold.ttf", contentType: "font/ttf", offset: 3605934, length: 90984, sha256: "bf4c16a2774edd38a921edf3099469866cd74c094fd596f3fa4e81f54a04dfaa" },
144659
- { key: "fonts/WixMadeforDisplay-Medium.ttf", contentType: "font/ttf", offset: 3696918, length: 90980, sha256: "368faca44fb9f7207e4af784e94750b1ee59c1098b8689e0f4a918926f244fb5" },
144660
- { key: "fonts/WixMadeforDisplay-Regular.ttf", contentType: "font/ttf", offset: 3787898, length: 90872, sha256: "97ed8f1a6772abe26e3d8af5cecfc4b02faa94497d585b0398b5053b739a70c1" },
144661
- { key: "fonts/WixMadeforDisplay-SemiBold.ttf", contentType: "font/ttf", offset: 3878770, length: 90980, sha256: "642feab8a48ddf6c7a89d7c2a7c0edfa0e6e773f671287e460e222703563191e" },
144662
- { key: "fonts/WixMadeforText-Bold.ttf", contentType: "font/ttf", offset: 3969750, length: 108636, sha256: "37c179b4fefb63ea9637322b84583a2df53aa226c150294eea1675c14b1b8e29" },
144663
- { key: "fonts/WixMadeforText-ExtraBold.ttf", contentType: "font/ttf", offset: 4078386, length: 109084, sha256: "62e2fe4718129f36ecdb0ae4de385bd6b81ecc876146447167c6c140fad699a9" },
144664
- { key: "fonts/WixMadeforText-Medium.ttf", contentType: "font/ttf", offset: 4187470, length: 109048, sha256: "4ecf270136af928612c76fe4ebade91d8156975e5ea4c0cf9225501dd1788e02" },
144665
- { key: "fonts/WixMadeforText-Regular.ttf", contentType: "font/ttf", offset: 4296518, length: 107700, sha256: "dee56f09fd3efc127c1ea95557edc74110c1460a46287da36e0af25efd341ef5" },
144666
- { key: "fonts/WixMadeforText-SemiBold.ttf", contentType: "font/ttf", offset: 4404218, length: 88108, sha256: "dced97a77624bc5f8b1ae65850360908297f4588e09feb6f22792d29dc7e765b" },
144667
- { key: "index.html", contentType: "text/html; charset=utf-8", offset: 4492326, length: 4947, sha256: "52f0f78045659e6cfa7d3db671275f28cb8a71f08f7ab96b423d5670f693a2ec" },
144668
- { key: "t5-frame.html", contentType: "text/html; charset=utf-8", offset: 4497273, length: 17344, sha256: "d057298d75e7373e5e2c4d11b7d1bcbea88e03af555ba63d97641c78509c58e4" }
144652
+ { key: "assets/index-yM_Nn9hQ.js", contentType: "application/javascript; charset=utf-8", offset: 8, length: 1220182, sha256: "ee5ff46db75a994f1b2750b447a6730e081af7bdca01187b41e7dc1b714165a6" },
144653
+ { key: "assets/pdf.worker.min-BmVo14Nb.mjs", contentType: "application/octet-stream", offset: 1220190, length: 1317034, sha256: "a33cfe728c584fdba4fcc1fd54bcdc2f9f2f13889ddbb5b2bd1d0f8cbe49b84e" },
144654
+ { key: "assets/pdfDocument-BbvYLMKH.js", contentType: "application/javascript; charset=utf-8", offset: 2537224, length: 489166, sha256: "3fefab4d874562921e86e42e142988aed1107d6aec4800256aea77693534bb95" },
144655
+ { key: "fonts/Roboto-LICENSE.txt", contentType: "application/octet-stream", offset: 3026390, length: 4610, sha256: "994062dd7af4186a739de55dd9e151c63b6301f8e2cbafc608d35c2e87da0cd2" },
144656
+ { key: "fonts/Roboto-Variable.ttf", contentType: "font/ttf", offset: 3031e3, length: 488584, sha256: "d7598e12c5dbef095ff8272cfc55da0250bd07fbdecbac8a530b9b277872a134" },
144657
+ { key: "fonts/WixMadeforDisplay-Bold.ttf", contentType: "font/ttf", offset: 3519584, length: 90924, sha256: "ec4c7d63772d980d6e147b2df6215fd2737e4b04cebe0cf7e11dc695fb63cdcf" },
144658
+ { key: "fonts/WixMadeforDisplay-ExtraBold.ttf", contentType: "font/ttf", offset: 3610508, length: 90984, sha256: "bf4c16a2774edd38a921edf3099469866cd74c094fd596f3fa4e81f54a04dfaa" },
144659
+ { key: "fonts/WixMadeforDisplay-Medium.ttf", contentType: "font/ttf", offset: 3701492, length: 90980, sha256: "368faca44fb9f7207e4af784e94750b1ee59c1098b8689e0f4a918926f244fb5" },
144660
+ { key: "fonts/WixMadeforDisplay-Regular.ttf", contentType: "font/ttf", offset: 3792472, length: 90872, sha256: "97ed8f1a6772abe26e3d8af5cecfc4b02faa94497d585b0398b5053b739a70c1" },
144661
+ { key: "fonts/WixMadeforDisplay-SemiBold.ttf", contentType: "font/ttf", offset: 3883344, length: 90980, sha256: "642feab8a48ddf6c7a89d7c2a7c0edfa0e6e773f671287e460e222703563191e" },
144662
+ { key: "fonts/WixMadeforText-Bold.ttf", contentType: "font/ttf", offset: 3974324, length: 108636, sha256: "37c179b4fefb63ea9637322b84583a2df53aa226c150294eea1675c14b1b8e29" },
144663
+ { key: "fonts/WixMadeforText-ExtraBold.ttf", contentType: "font/ttf", offset: 4082960, length: 109084, sha256: "62e2fe4718129f36ecdb0ae4de385bd6b81ecc876146447167c6c140fad699a9" },
144664
+ { key: "fonts/WixMadeforText-Medium.ttf", contentType: "font/ttf", offset: 4192044, length: 109048, sha256: "4ecf270136af928612c76fe4ebade91d8156975e5ea4c0cf9225501dd1788e02" },
144665
+ { key: "fonts/WixMadeforText-Regular.ttf", contentType: "font/ttf", offset: 4301092, length: 107700, sha256: "dee56f09fd3efc127c1ea95557edc74110c1460a46287da36e0af25efd341ef5" },
144666
+ { key: "fonts/WixMadeforText-SemiBold.ttf", contentType: "font/ttf", offset: 4408792, length: 88108, sha256: "dced97a77624bc5f8b1ae65850360908297f4588e09feb6f22792d29dc7e765b" },
144667
+ { key: "index.html", contentType: "text/html; charset=utf-8", offset: 4496900, length: 4947, sha256: "6e03c482ba368bd0fd94433dd79e80215cc054c8bce58981b87a7a91a2a5c971" },
144668
+ { key: "t5-frame.html", contentType: "text/html; charset=utf-8", offset: 4501847, length: 17344, sha256: "d057298d75e7373e5e2c4d11b7d1bcbea88e03af555ba63d97641c78509c58e4" }
144669
144669
  ];
144670
144670
  }
144671
144671
  });
Binary file
@@ -2630,7 +2630,13 @@
2630
2630
  "name": "MediaPlaybackStatus",
2631
2631
  "kind": "interface",
2632
2632
  "jsdoc": "",
2633
- "decl": "export interface MediaPlaybackStatus {\n state: PlaybackState;\n currentItem?: MediaQueueItem | null;\n currentIndex: number;\n positionMs: number;\n durationMs: number;\n rate: number;\n bufferedMs: number;\n queue: MediaQueueItem[];\n error?: string;\n}"
2633
+ "decl": "export interface MediaPlaybackStatus {\n state: PlaybackState;\n currentItem?: MediaQueueItem | null;\n currentIndex: number;\n positionMs: number;\n durationMs: number;\n rate: number;\n bufferedMs: number;\n queue: MediaQueueItem[];\n error?: string;\n /** Set when `persistPosition` resumed the current item from a natively saved position\n * (no explicit `startPositionMs` was passed). Absent otherwise. */\n resumedFromMs?: number;\n}"
2634
+ },
2635
+ {
2636
+ "name": "MediaSkipIntervals",
2637
+ "kind": "interface",
2638
+ "jsdoc": "/** Lock-screen / notification skip-by-seconds controls. Either side may be omitted. */",
2639
+ "decl": "export interface MediaSkipIntervals {\n forwardSec?: number;\n backwardSec?: number;\n}"
2634
2640
  },
2635
2641
  {
2636
2642
  "name": "MediaDownloadResult",
@@ -2642,7 +2648,13 @@
2642
2648
  "name": "setQueue",
2643
2649
  "kind": "function",
2644
2650
  "jsdoc": "",
2645
- "decl": "export async function setQueue(\n items: MediaQueueItem[],\n options: {\n startIndex?: number;\n startPositionMs?: number;\n autoplay?: boolean;\n /**\n * PUSH channel for live playback state — `\"<service>.<action>\"` (e.g.\n * `\"podcast.mediaStatus\"`). The host invokes that reducer with a\n * `MediaPlaybackStatus` whenever the real player's state, rate or position\n * changes materially (throttled natively).\n *\n * Why it exists: a worker has NO TIMERS, so it cannot poll `status()`. Without\n * a push the UI reads playback state once at screen open and then drifts — the\n * play/pause icon and progress bar stop matching the audio. Same shape as\n * RFC 0040's StreamDirective `onEvent`, for the same reason.\n */\n onStatus?: string;\n } = {},\n): Promise<MediaPlaybackStatus>;"
2651
+ "decl": "export async function setQueue(\n items: MediaQueueItem[],\n options: {\n startIndex?: number;\n startPositionMs?: number;\n autoplay?: boolean;\n /**\n * PUSH channel for live playback state — `\"<service>.<action>\"` (e.g.\n * `\"podcast.mediaStatus\"`). The host invokes that reducer with a\n * `MediaPlaybackStatus` whenever the real player's state, rate or position\n * changes materially (throttled natively).\n *\n * Why it exists: a worker has NO TIMERS, so it cannot poll `status()`. Without\n * a push the UI reads playback state once at screen open and then drifts — the\n * play/pause icon and progress bar stop matching the audio. Same shape as\n * RFC 0040's StreamDirective `onEvent`, for the same reason.\n */\n onStatus?: string;\n /**\n * Skip-by-seconds on the lock screen / Now Playing (iOS `skipForwardCommand` /\n * `skipBackwardCommand`), the Android media notification + session, and on web the\n * browser Media Session (`seekbackward` / `seekforward`). Unset keeps today's controls\n * (iOS next/previous track; Android rewind 15 s / forward 30 s). Capped at 3600 s.\n */\n skipIntervals?: MediaSkipIntervals;\n /** Rates offered to iOS `changePlaybackRateCommand` and the Android session's speed\n * button (which shows the current rate and cycles through these). Defaults to 0.5x–2x;\n * each is clamped to the capability's 0.5–3 range. Web has no lock-screen speed control. */\n playbackRates?: number[];\n /**\n * Save the position natively per item id (every ~5 s, and on pause/stop; cleared once\n/* … */"
2652
+ },
2653
+ {
2654
+ "name": "encodeSessionOptions",
2655
+ "kind": "function",
2656
+ "jsdoc": "/** The lock-screen/persistence half of `setQueue`'s options, as wire params. Every key is\n * emitted only when its option is set, so a caller that sets none sends today's payload. */",
2657
+ "decl": "export function encodeSessionOptions(options: {\n skipIntervals?: MediaSkipIntervals;\n playbackRates?: number[];\n persistPosition?: boolean;\n startPositionIsFallback?: boolean;\n startPositionMs?: number;\n}): Record<string, string>;"
2646
2658
  },
2647
2659
  {
2648
2660
  "name": "subscribeStatus",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1264.0",
3
+ "version": "0.1266.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": [
@@ -67,5 +67,5 @@
67
67
  "artifactId": "himalaya-cli"
68
68
  }
69
69
  },
70
- "falconPackageHash": "6164348fcd868a9238f69f22f42590f2e10be6a07feee5a842ea7f31"
70
+ "falconPackageHash": "11911671b0473dec25fb472b1dd3581d09af89ddd184c648d4f56095"
71
71
  }