@wix/himalaya-cli 0.1853.0 → 0.1855.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +1010 -681
- package/guides/iap-products.md +4 -0
- package/guides/one-app-section-mappings.md +1 -1
- package/guides/one-app-to-himi-app.md +10 -7
- package/guides/push-cli-onboarding.md +20 -0
- package/package.json +2 -2
- package/templates/branded-lite/tier5-src/_shared/announcement-section.ts +6 -14
- package/templates/branded-lite/tier5-src/_shared/draft-content.ts +66 -0
- package/templates/branded-lite/tier5-src/_shared/galleries-section.ts +52 -23
package/guides/iap-products.md
CHANGED
|
@@ -35,6 +35,10 @@ These key and profile prerequisites apply to direct Apple mode. There is **no am
|
|
|
35
35
|
|
|
36
36
|
## Set up the owner's Apple keys
|
|
37
37
|
|
|
38
|
+
These are IAP setup steps (`asc-key` through `saveAscKey`, `purchases-app`, `iap-key`); the table of
|
|
39
|
+
every setup step is in [push-provisioning-contract.md](push-provisioning-contract.md#setup-steps), and
|
|
40
|
+
`himi setup check` shows them under `iapSetup` without a manifest.
|
|
41
|
+
|
|
38
42
|
Use `himi store apple-keys setup` to upload either key independently of push setup
|
|
39
43
|
and local signing profiles. The **App Store Connect API key** is stored in Branded
|
|
40
44
|
BuildSecrets for Catalog. The separate **In-App Purchase key** is stored on the
|
|
@@ -221,7 +221,7 @@ carousel placement remain separate gaps; the mappings above stay Partial.
|
|
|
221
221
|
| --- | --- | --- | --- | --- | --- |
|
|
222
222
|
| `platform_general_contact_section` | `wix.platform.general.contact_section` | [Core Text/Button/Map composition](https://github.com/wix-private/himalaya/blob/97f1542f2f7d6e8cb7a902b912c87dcaa37e5a67/core/dev-server/src/builder.ts "audience-lint-ok: optional pinned upstream evidence, not a local authoring dependency") | Inline composition | Composition | Compose the supplied business contact/address/description and source visibility/get-in-touch settings. Wire phone/email/URL/chat actions to existing target capabilities; the Structure alone may need business contact values supplied alongside it. |
|
|
223
223
|
| `platform_general_upcoming_section` | `wix.platform.general.upcoming_section` | [My Bookings data](https://github.com/wix-private/himalaya/blob/97f1542f2f7d6e8cb7a902b912c87dcaa37e5a67/core/dev-server/tier5-bundles-src/himi-booking-bookings/index.ts "audience-lint-ok: optional pinned upstream evidence, not a local authoring dependency") + [existing home modules](https://github.com/wix-private/himalaya/blob/97f1542f2f7d6e8cb7a902b912c87dcaa37e5a67/core/dev-server/src/home-modules-screen.ts "audience-lint-ok: optional pinned upstream evidence, not a local authoring dependency") | Existing base; adaptation needed | Partial | Reuse real member upcoming-booking logic and compose the source strip/limit. Preserve visitor/access behavior and the original agenda CTA; this does not resolve the separate Bookings agenda gap. |
|
|
224
|
-
| `platform_general_announcement_section` | `wix.platform.general.announcement_section` | `announcement-section` shared module + `announcement-card` recipe, mapped by `himi one-app generate` | Inline section; the content is read at runtime, never baked at migration time | Module | The latest announcement (title, rich body, creator, date) through the one read-only call the native app makes: `GET https://manage.wix.com/_api/mobile-apps-announcements/v1/announcements/latest?includeReaderData=false`, authorized with the app's own signed instance (Member when signed in, else Visitor). `includeReaderData` stays false (true needs the One App manage permission and answers 403); `AddCurrentMemberAsReader` is a write and is never called. Known server behaviour, shared with the native app: a site with no announcement gets its default welcome text saved once by this read, so do not call it during migration collection or validation. The section has no settings. The announcement `content` is a DraftJS raw state for announcements written in the app (shown
|
|
224
|
+
| `platform_general_announcement_section` | `wix.platform.general.announcement_section` | `announcement-section` shared module + `announcement-card` recipe, mapped by `himi one-app generate` | Inline section; the content is read at runtime, never baked at migration time | Module | The latest announcement (title, rich body, creator, date) through the one read-only call the native app makes: `GET https://manage.wix.com/_api/mobile-apps-announcements/v1/announcements/latest?includeReaderData=false`, authorized with the app's own signed instance (Member when signed in, else Visitor). `includeReaderData` stays false (true needs the One App manage permission and answers 403); `AddCurrentMemberAsReader` is a write and is never called. Known server behaviour, shared with the native app: a site with no announcement gets its default welcome text saved once by this read, so do not call it during migration collection or validation. The section has no settings. The announcement `content` is a DraftJS raw state for announcements written in the app or a Ricos document (shown rich). A DraftJS state with pictures (an atomic block pointing at a `wix-draft-plugin-image` entity, shape read from a live site) is shown rich too, its pictures in order with the text and sized from the Wix media name; a DraftJS state without pictures is shown as plain text, and other entities (video, file, gallery) are left out. Native hosts send the consumer credential to exactly this GET path only (the `isSupportedConsumerEndpoint` family in `WixApiCapability`, Android and Swift), so a phone shows the section from the first Player/app native release that carries that entry; the local web preview (`himi run`) needs nothing. |
|
|
225
225
|
| `platform_general_members_section` | `membersArea.MembersAboutWidget` | [Member data](https://github.com/wix-private/himalaya/blob/97f1542f2f7d6e8cb7a902b912c87dcaa37e5a67/core/dev-server/tier5-bundles-src/wix-spaces-members/index.ts "audience-lint-ok: optional pinned upstream evidence, not a local authoring dependency") + [existing member avatars/home composition](https://github.com/wix-private/himalaya/blob/97f1542f2f7d6e8cb7a902b912c87dcaa37e5a67/core/dev-server/src/home-modules-screen.ts "audience-lint-ok: optional pinned upstream evidence, not a local authoring dependency") | Inline composition | Composition | Reuse member rows/avatar presentation and the member-directory destination. Preserve source strip/title/count/privacy settings rather than copying seeded dashboard members. |
|
|
226
226
|
| `platform_elements_divider_section` | `wix.platform.elements.divider_section` | [Core Divider / layout modifiers](https://github.com/wix-private/himalaya/blob/97f1542f2f7d6e8cb7a902b912c87dcaa37e5a67/core/dev-server/src/builder.ts "audience-lint-ok: optional pinned upstream evidence, not a local authoring dependency") | Inline primitive | Primitive | Translate orientation/style/spacing from instance settings where supported and retain section margins. |
|
|
227
227
|
| `platform_elements_image_section` | `wix.platform.elements.image_section` | [Core Image](https://github.com/wix-private/himalaya/blob/97f1542f2f7d6e8cb7a902b912c87dcaa37e5a67/core/dev-server/src/builder.ts "audience-lint-ok: optional pinned upstream evidence, not a local authoring dependency") | Inline primitive | Primitive | Translate media URL, aspect/crop ratio, fill/fit, corner radius, alt text and configured click action; preserve sizing and accessibility. |
|
|
@@ -225,7 +225,7 @@ source's title (only when the source shows it) and a **See All** button to the s
|
|
|
225
225
|
| `platform_general_upcoming_section` | `himi_agenda` | nothing: the source strip is the Bookings member widget (the business's next 3 bookable sessions with the member's booked status; the Events module does not feed it), whatever its `interval` says |
|
|
226
226
|
| `vod_list_section` | `himi_videos` | nothing: the screen is the channel list |
|
|
227
227
|
| `bookings_agenda_section` | `himi_agenda` | nothing: the screen is the calendar of the site's class and course sessions |
|
|
228
|
-
| `proGallery_gallery_list_section` | `himi_galleries` | nothing: the section has no settings. Beside other sections it shows the site's first 10 galleries as full-width cards (a card opens `himi_gallery`), with View All to this screen, and reports that gap |
|
|
228
|
+
| `proGallery_gallery_list_section` | `himi_galleries` | nothing: the section has no settings. Beside other sections it shows the site's first 10 galleries as full-width cards (a card opens `himi_gallery`), with View All to this screen, and reports that gap. Like the source, which reads the One App's own galleries service as a member and never shows hidden or empty galleries, the section lists them for a signed-in member only: a visitor sees the "no galleries" state, and so does a member where that service cannot be read (the web bridge refuses its host: the public Pro Gallery list has no hidden flag, so it is never used as a stand-in) |
|
|
229
229
|
| `shared_gallery_list_section` | `himi_galleries` | nothing. Never shown inline: it is the members' Shared Gallery, a different data source from the site's Pro Gallery. It keeps its title and a See All link that opens the site's galleries, not the members' shared ones, and reports that gap |
|
|
230
230
|
|
|
231
231
|
A screen that cannot follow a setting would show more or other content than the source, so `generate` reports one **gap** per
|
|
@@ -826,12 +826,15 @@ Apply these interpretation rules:
|
|
|
826
826
|
badges (the bar then holds only the avatar). The avatar replaces the hamburger on every tab root, and the scaffold's
|
|
827
827
|
Profile screen then lists the side menu's pages under "Pages" (the scaffold ships that group hidden, as it cannot know the
|
|
828
828
|
app's top bar; the same command shows it by setting the load parameter `showPages: "1"` on `himi_account`, reported as
|
|
829
|
-
`profilePages`: `set`, or `unchanged` on a rerun).
|
|
830
|
-
`app: { newApp: true }` in `config.ts
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
829
|
+
`profilePages`: `set`, or `unchanged` on a rerun). A One App migration is always a new Himalaya app (it has shipped no older binary), so
|
|
830
|
+
the command declares `app: { newApp: true }` in `config.ts` itself when the file says nothing about it, in the same
|
|
831
|
+
write as the avatar (reported as `newApp: "declared"`; a rerun finds it and reports nothing). That is the same edit
|
|
832
|
+
`access --new-app` makes, so the page locks of a source that locks a page and the avatar compose in either order and the
|
|
833
|
+
declaration appears once. An app that has shipped older binaries must keep its hamburger: pass `--not-new-app`, or set
|
|
834
|
+
`app: { newApp: false }` in `config.ts` (the command never overwrites an author's `false`, nor an `app` that is not an
|
|
835
|
+
object literal). It then writes no avatar and says so (`avatar: "skipped_not_new_app"` and an `avatarNote` that names
|
|
836
|
+
the reason). Order: `header-badges` (it declares the app new and writes the avatar), then `access --new-app` when the
|
|
837
|
+
source locks a page; either order gives the same result. The avatar needs the full nav worker
|
|
835
838
|
(`himi-branded-lite-nav`, or `himi-branded-lite-access-nav` after `access`); a config that names the badges-only worker is
|
|
836
839
|
reported as `config_needs_manual_merge`.
|
|
837
840
|
|
|
@@ -127,6 +127,26 @@ built without Sign in with Apple hides Google on iOS too.
|
|
|
127
127
|
social login.
|
|
128
128
|
Its `iap` section runs `himi store iap check` when you pass
|
|
129
129
|
`--iap-manifest <file> --catalog-route <path>`, and is `not_checked` without them.
|
|
130
|
+
Its `steps` section lists every server setup step and its `iapSetup` section every IAP setup step,
|
|
131
|
+
with no manifest needed. `steps` fails only on a step that needs attention, and `--only push` or
|
|
132
|
+
`--only signin` lists only that area's steps (`app-identity` is in both, `android-signin` is
|
|
133
|
+
sign-in's). `iapSetup` fails on a missing key or app and stays unverified while the payment provider
|
|
134
|
+
cannot be read. It checks the site and bundle ID of `--iap-manifest` when you pass one, else the
|
|
135
|
+
content package's (or `--app`, `--site` and `--bundle-id`):
|
|
136
|
+
|
|
137
|
+
| Step | Runs in | What it does | Needs | Stages it checkpoints | Run by |
|
|
138
|
+
|---|---|---|---|---|---|
|
|
139
|
+
| `app-identity` | server | Finds or creates the site's Branded record and writes the iOS bundle ID and Android package onto it (and makes a bundle or package move). Branded turns these into the site's IAM Apple and Google sign-in connections. | `bundleId`, `androidApplicationId`, `displayName` | `read_branded_record`, `create_branded_record`, `configure_branded_record`, `migrate_branded_record` | push setup; Apple sign-in (`purpose: "apple_sign_in"`) |
|
|
140
|
+
| `apns` | server | Saves the APNs key in the site's build secrets. Repeats every run. | APNs key | `write_build_secrets` | push setup (iOS) |
|
|
141
|
+
| `apple-signing` | server | Saves the App Store Connect key (in the same write as APNs) and asks Apple for certificates and profiles with `CreateAppStoreSecrets`, **once**: never again after it completes. | App Store Connect key | `create_app_store_secrets` | push setup (iOS, with that key) |
|
|
142
|
+
| `firebase` | server | Asks Branded to create the Firebase app and FCM credential (`SavePushNotificationsCredentials`; `forceCreate` only after an Android package move). | Android package | `save_push_credentials` | push setup (Android) |
|
|
143
|
+
| `android-signin` | server | Saves the Play signing SHA-1 and forces the Firebase step until Google lists the Android OAuth client. | SHA-1 | `write_certificate_fingerprint`, `sync_android_client` | `POST /v1/admin/push/android-signin`; push setup after a package move |
|
|
144
|
+
| `ping-readback` | server | Reads Ping and decides whether push is `ready`. | none | `read_back_ping` | push setup |
|
|
145
|
+
| `saveAscKey` | server helper | Saves the App Store Connect key by itself and reads it back. | App Store Connect key | none | `POST /v1/admin/store/asc-key` (`himi store apple-keys setup`) |
|
|
146
|
+
| `purchases-app` | CLI | Finds or registers the bundle's purchases app on the site. | site, bundle ID | none | `himi store apple-keys setup`, `himi store iap connect` |
|
|
147
|
+
| `iap-key` | CLI | Stores the In-App Purchase key on the purchases app: `apple-keys setup` replaces a stored one, `iap connect` keeps it. | In-App Purchase key | none | `himi store apple-keys setup`, `himi store iap connect` |
|
|
148
|
+
| `payment-provider` | CLI | Connects the appleIAP payment provider through Serve's wix-iap route. Nothing can read its state, so a check reports it `unverified`. | purchases app | none | `himi store iap connect` |
|
|
149
|
+
|
|
130
150
|
`--only push,signin,iap` limits the report. Each section's `ok` is `true`, `false` or `null`
|
|
131
151
|
(unverified, listed under `unverified`); the top-level `ok` is false when any section is false.
|
|
132
152
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1855.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": [
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"artifactId": "himalaya-cli"
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
|
-
"falconPackageHash": "
|
|
85
|
+
"falconPackageHash": "17c5a9085e9906a6ec0f17805468d73dd5d39288c05be2330f3bce80"
|
|
86
86
|
}
|
|
@@ -14,6 +14,7 @@ import { defineService } from "@himalaya/state";
|
|
|
14
14
|
import { richBody } from "./rich-body.js";
|
|
15
15
|
import { formatDateMedium } from "./engine-intl.js";
|
|
16
16
|
import { openRichLink } from "./rich-content-link.js";
|
|
17
|
+
import { draftPlainText, draftToRicos } from "./draft-content.js";
|
|
17
18
|
|
|
18
19
|
/** The one call: the latest announcement, without the reader data. */
|
|
19
20
|
export const LATEST_ANNOUNCEMENT_URL = "https://manage.wix.com/_api/mobile-apps-announcements/v1/announcements/latest?includeReaderData=false";
|
|
@@ -44,17 +45,6 @@ export interface AnnouncementState {
|
|
|
44
45
|
|
|
45
46
|
const text = (value: unknown): string => (typeof value === "string" ? value.trim() : "");
|
|
46
47
|
|
|
47
|
-
/** The plain text of a DraftJS raw state (`{ blocks: [{ text }], entityMap }`), which is what the service's `content` really is for
|
|
48
|
-
* announcements written in the app (observed on a live site, 2026-11-11), or undefined when `content` is not one. Only the blocks' own
|
|
49
|
-
* text is read: the entity map (links, images) is never followed. */
|
|
50
|
-
function draftPlainText(content: unknown): string | undefined {
|
|
51
|
-
let doc = content;
|
|
52
|
-
if (typeof doc === "string") { try { doc = JSON.parse(doc); } catch { return undefined; } }
|
|
53
|
-
const blocks = (doc as { blocks?: unknown } | null | undefined)?.blocks;
|
|
54
|
-
if (!Array.isArray(blocks)) return undefined;
|
|
55
|
-
return blocks.map((block) => text((block as { text?: unknown } | null)?.text)).filter(Boolean).join("\n\n");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
48
|
function derive(status: AnnouncementState["status"], fields: { title?: string; bodyJson?: string; body?: string; created?: string; creator?: string; creatorImage?: string } = {}): AnnouncementState {
|
|
59
49
|
const title = fields.title ?? "", bodyJson = fields.bodyJson ?? "", body = fields.body ?? "", created = fields.created ?? "";
|
|
60
50
|
const creator = fields.creator ?? "", creatorImage = fields.creatorImage ?? "";
|
|
@@ -76,9 +66,11 @@ function derive(status: AnnouncementState["status"], fields: { title?: string; b
|
|
|
76
66
|
export function announcementState(response: unknown): AnnouncementState {
|
|
77
67
|
const announcement = (response as LatestAnnouncementResponse | undefined)?.announcement;
|
|
78
68
|
if (!announcement || typeof announcement !== "object") return derive("ready");
|
|
79
|
-
// A DraftJS body
|
|
80
|
-
|
|
81
|
-
const
|
|
69
|
+
// A DraftJS body with pictures becomes a Ricos document (text and images in order), so the rich viewer draws them; one without shows as
|
|
70
|
+
// its plain text. A Ricos body keeps its rich document.
|
|
71
|
+
const draftDoc = draftToRicos(announcement.content);
|
|
72
|
+
const draft = draftDoc ? undefined : draftPlainText(announcement.content);
|
|
73
|
+
const rich = draftDoc ? richBody(draftDoc) : draft !== undefined ? { bodyJson: "", bodyText: draft } : richBody(announcement.content);
|
|
82
74
|
const when = typeof announcement.createdDate === "string" ? new Date(announcement.createdDate) : undefined;
|
|
83
75
|
const image = text(announcement.creatorMemberProfileData?.imageUrl);
|
|
84
76
|
return derive("ready", {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// A DraftJS raw state (`{ blocks, entityMap }`), which is what Wix's in-app editors (the One App announcement composer) save as `content`,
|
|
2
|
+
// read as plain text or, when it carries pictures, as a Ricos document the RichContent viewer already draws.
|
|
3
|
+
// A picture is an ATOMIC block (`type: "atomic"`, one placeholder character) whose `entityRanges[0].key` names an IMAGE entry in `entityMap`
|
|
4
|
+
// (`wix-draft-plugin-image`: `data.src` is `{ file_name, width, height }` for Wix media, `data.metadata.alt` its alt text). Only the blocks'
|
|
5
|
+
// own text and those images are read; every other entity (link, divider, video, ...) is ignored, as it always was.
|
|
6
|
+
// The entity's media reference stays as it came and goes through the shared Ricos encoder (`richBody`), which sizes Wix media and drops any
|
|
7
|
+
// reference that is not https, so nothing here fetches or trusts a URL.
|
|
8
|
+
import type { RicosDocument, RicosNode } from "@himalaya/wix-rich-content";
|
|
9
|
+
|
|
10
|
+
type Obj = Record<string, unknown>;
|
|
11
|
+
const isObj = (v: unknown): v is Obj => !!v && typeof v === "object" && !Array.isArray(v);
|
|
12
|
+
const text = (value: unknown): string => (typeof value === "string" ? value.trim() : "");
|
|
13
|
+
const size = (value: unknown): number | undefined => (typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined);
|
|
14
|
+
|
|
15
|
+
/** The DraftJS raw state inside `content` (an object, or its JSON string), or undefined when `content` is not one. */
|
|
16
|
+
function draftState(content: unknown): { blocks: unknown[]; entityMap: Obj } | undefined {
|
|
17
|
+
let doc = content;
|
|
18
|
+
if (typeof doc === "string") { try { doc = JSON.parse(doc); } catch { return undefined; } }
|
|
19
|
+
if (!isObj(doc) || !Array.isArray(doc.blocks)) return undefined;
|
|
20
|
+
return { blocks: doc.blocks, entityMap: isObj(doc.entityMap) ? doc.entityMap : {} };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The plain text of a DraftJS raw state: blank blocks dropped, the rest one paragraph each. Undefined when `content` is not a DraftJS state. */
|
|
24
|
+
export function draftPlainText(content: unknown): string | undefined {
|
|
25
|
+
const state = draftState(content);
|
|
26
|
+
if (!state) return undefined;
|
|
27
|
+
return state.blocks.map((block) => text(isObj(block) ? block.text : undefined)).filter(Boolean).join("\n\n");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** One image entity as a Ricos IMAGE node, or undefined when it names no picture. `data.src` is a Wix media object (`file_name`, or `url`/`id`),
|
|
31
|
+
* or a bare string; `data.url` is read too. A media reference that is not https or Wix media is dropped later, by the encoder. */
|
|
32
|
+
function imageNode(entity: unknown, id: string): RicosNode | undefined {
|
|
33
|
+
if (!isObj(entity) || !/image/i.test(text(entity.type))) return undefined;
|
|
34
|
+
const data = isObj(entity.data) ? entity.data : {};
|
|
35
|
+
const src = isObj(data.src) ? data.src : {};
|
|
36
|
+
const ref = text(typeof data.src === "string" ? data.src : src.url) || text(src.file_name) || text(src.fileName) || text(src.id) || text(data.url);
|
|
37
|
+
if (!ref) return undefined;
|
|
38
|
+
const meta = isObj(data.metadata) ? data.metadata : {};
|
|
39
|
+
const image: Obj = { src: { url: ref } };
|
|
40
|
+
const width = size(src.width), height = size(src.height);
|
|
41
|
+
if (width && height) { image.width = width; image.height = height; }
|
|
42
|
+
const alt = text(meta.alt) || text(meta.caption);
|
|
43
|
+
return { type: "IMAGE", id, imageData: { image, ...(alt ? { altText: alt } : {}) } };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** A Ricos document of the state's text blocks and images, in order, or undefined when `content` is not a DraftJS state or has no image
|
|
47
|
+
* (a text-only announcement stays plain text, which draws exactly as before). */
|
|
48
|
+
export function draftToRicos(content: unknown): RicosDocument | undefined {
|
|
49
|
+
const state = draftState(content);
|
|
50
|
+
if (!state) return undefined;
|
|
51
|
+
const nodes: RicosNode[] = [];
|
|
52
|
+
let images = 0;
|
|
53
|
+
state.blocks.forEach((block, index) => {
|
|
54
|
+
if (!isObj(block)) return;
|
|
55
|
+
const id = `d${index}`;
|
|
56
|
+
if (block.type === "atomic") {
|
|
57
|
+
const range = Array.isArray(block.entityRanges) ? block.entityRanges.find(isObj) : undefined;
|
|
58
|
+
const node = range ? imageNode(state.entityMap[String(range.key)], id) : undefined;
|
|
59
|
+
if (node) { nodes.push(node); images += 1; }
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const line = text(block.text);
|
|
63
|
+
if (line) nodes.push({ type: "PARAGRAPH", id, nodes: [{ type: "TEXT", id: `${id}t`, textData: { text: line, decorations: [] } }], paragraphData: {} });
|
|
64
|
+
});
|
|
65
|
+
return images > 0 ? { nodes } : undefined;
|
|
66
|
+
}
|
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
// limit -> how many galleries (the source section's `maxGalleries`); `noMore` is false when the site has more,
|
|
3
3
|
// which is when the section's See All button (to the galleries screen) shows.
|
|
4
4
|
// showName -> whether a card shows the gallery's name (the source section's `isShowName`); the accessibility label always has it.
|
|
5
|
-
// The
|
|
5
|
+
// The source reads the One App's own galleries service with the MEMBER's signed instance, never hidden galleries (`withHidden=false`), and
|
|
6
|
+
// drops empty ones; a visitor has no member instance, so the source shows them its "no galleries" state, and so does a failed read. This section
|
|
7
|
+
// does the same, and never falls back to the public Pro Gallery list (`/progallery/v2/galleries`), which has no hidden flag:
|
|
8
|
+
// - a signed-out visitor gets the empty state, without a read;
|
|
9
|
+
// - a member reads that service (`photography-one-app-viewer/galleries`), which a native host reaches;
|
|
10
|
+
// - where it cannot be read (the published web bridge refuses that host) the member gets the empty state too: a hidden gallery must never show.
|
|
6
11
|
// A page worker registers it under a service name; the descriptor binds `$service:<serviceName>.*` (recipes galleries-carousel / galleries-list).
|
|
7
12
|
import { defineService } from "@himalaya/state";
|
|
8
13
|
import { wixMediaUrl } from "@himalaya/wix-media";
|
|
9
14
|
import { copyParam, stashCopy, copyTemplate } from "./himi-copy.js";
|
|
15
|
+
import { memberAccess } from "./member-access.js";
|
|
10
16
|
|
|
11
17
|
export interface GalleriesSectionOptions {
|
|
12
18
|
/** How many galleries to show. */
|
|
@@ -37,7 +43,8 @@ export interface GalleriesSectionState {
|
|
|
37
43
|
noMore: boolean;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
/** The One App's own list: what the source section reads (its `API_BASE_URL` + `/galleries`), as a member, without hidden galleries. */
|
|
47
|
+
const ONE_APP_GALLERIES_URL = "https://www.wix.com/_api/photography-one-app-viewer/galleries";
|
|
41
48
|
const DEFAULT_LIMIT = 10;
|
|
42
49
|
/** The API's page maximum, and the most galleries a section shows (the template's galleries screen caps at 30 too). */
|
|
43
50
|
const PAGE_SIZE = 10, MAX_GALLERIES = 30;
|
|
@@ -45,15 +52,15 @@ const PAGE_SIZE = 10, MAX_GALLERIES = 30;
|
|
|
45
52
|
const CARD_IMAGE = { width: 720, height: 540, quality: 85 };
|
|
46
53
|
|
|
47
54
|
type WixApi = { call: (method: string, path: string) => Promise<unknown> };
|
|
48
|
-
interface
|
|
55
|
+
interface RawItem { mediaUrl?: unknown; dataType?: unknown; videoMetadata?: { posters?: Array<{ url?: unknown }> } }
|
|
56
|
+
/** A gallery of the One App's list. */
|
|
57
|
+
interface RawGallery { id?: unknown; name?: unknown; items?: RawItem[]; totalItemsCount?: unknown; isHidden?: unknown }
|
|
49
58
|
|
|
50
|
-
/** A
|
|
59
|
+
/** A gallery's cover: the first item's picture (a video gives its poster). */
|
|
51
60
|
function coverOf(gallery: RawGallery): string {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const media = info as { url?: unknown; id?: unknown };
|
|
56
|
-
return wixMediaUrl(media.url, CARD_IMAGE) || wixMediaUrl(media.id, CARD_IMAGE);
|
|
61
|
+
const item = Array.isArray(gallery.items) ? gallery.items[0] : undefined;
|
|
62
|
+
const poster = item?.dataType === "Video" ? item.videoMetadata?.posters?.find((p) => typeof p?.url === "string" && p.url)?.url : undefined;
|
|
63
|
+
return wixMediaUrl(poster ?? item?.mediaUrl, CARD_IMAGE);
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
function rowOf(gallery: RawGallery, index: number, showName: boolean): GalleryRow {
|
|
@@ -67,21 +74,37 @@ function rowOf(gallery: RawGallery, index: number, showName: boolean): GalleryRo
|
|
|
67
74
|
};
|
|
68
75
|
}
|
|
69
76
|
|
|
70
|
-
/**
|
|
77
|
+
/** A gallery the section may show: the source drops hidden and empty galleries. An unknown count is not "empty". */
|
|
78
|
+
function visible(gallery: RawGallery): boolean {
|
|
79
|
+
const count = gallery.totalItemsCount;
|
|
80
|
+
return typeof gallery.id === "string" && !!gallery.id && gallery.isHidden !== true && !(typeof count === "number" && count <= 0);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The most galleries one read looks through while it fills the section: the source's own cap on a list. */
|
|
84
|
+
const MAX_SCANNED = 200;
|
|
85
|
+
|
|
86
|
+
/** One page of the One App's list, as the source section reads it (`withHidden=false`). A native transport may hand the body over bare or wrapped as
|
|
87
|
+
* `{ data }`. The service drops hidden galleries after it pages, so only its `totalGalleriesCount` says where the list ends: a body without one is not read. */
|
|
88
|
+
async function readPage(api: WixApi, offset: number): Promise<{ galleries: RawGallery[]; total: number }> {
|
|
89
|
+
const res = await api.call("GET", `${ONE_APP_GALLERIES_URL}?itemsPerGallery=1&offset=${offset}&limit=${PAGE_SIZE}&withHidden=false&useNew=true`);
|
|
90
|
+
const body = (res as { data?: unknown } | null)?.data ?? res;
|
|
91
|
+
const { galleries, totalGalleriesCount } = (body ?? {}) as { galleries?: unknown; totalGalleriesCount?: unknown };
|
|
92
|
+
if (!Array.isArray(galleries) || typeof totalGalleriesCount !== "number") throw new Error("Malformed One App galleries response");
|
|
93
|
+
return { galleries, total: totalGalleriesCount };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The first `limit` visible galleries, page by page, and whether there are more. A page can hold fewer than `PAGE_SIZE` visible galleries, so paging goes by the offset and the total. */
|
|
71
97
|
async function readGalleries(api: WixApi, limit: number): Promise<{ galleries: RawGallery[]; more: boolean }> {
|
|
72
98
|
const galleries: RawGallery[] = [];
|
|
73
|
-
let total
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
total = res?.totalGalleries;
|
|
81
|
-
if (page.length < size) break;
|
|
99
|
+
let offset = 0, total = Infinity;
|
|
100
|
+
// One more than the section shows, so "more" is known without a second read.
|
|
101
|
+
while (galleries.length <= limit && offset < total && offset < MAX_SCANNED) {
|
|
102
|
+
const page = await readPage(api, offset);
|
|
103
|
+
galleries.push(...page.galleries.filter(visible));
|
|
104
|
+
total = page.total;
|
|
105
|
+
offset += PAGE_SIZE;
|
|
82
106
|
}
|
|
83
|
-
|
|
84
|
-
return { galleries, more: typeof total === "number" ? total > galleries.length : galleries.length >= limit };
|
|
107
|
+
return { galleries: galleries.slice(0, limit), more: galleries.length > limit || (offset < total && offset >= MAX_SCANNED) };
|
|
85
108
|
}
|
|
86
109
|
|
|
87
110
|
export function registerGalleriesSection(serviceName: string, options: GalleriesSectionOptions = {}) {
|
|
@@ -100,10 +123,16 @@ export function registerGalleriesSection(serviceName: string, options: Galleries
|
|
|
100
123
|
load: async (_state, arg) => {
|
|
101
124
|
stashCopy(arg);
|
|
102
125
|
try {
|
|
126
|
+
// The source reads as the member: a visitor has no instance for it and sees its "no galleries" state.
|
|
127
|
+
if (!(await memberAccess()).signedIn) return view("ready", [], false);
|
|
103
128
|
const api = (globalThis as { himalaya?: { wixApi?: WixApi } }).himalaya?.wixApi;
|
|
104
129
|
if (!api) throw new Error("Wix bridge unavailable");
|
|
105
|
-
const { galleries, more } = await readGalleries(api, limit)
|
|
106
|
-
|
|
130
|
+
const { galleries, more } = await readGalleries(api, limit).catch((oneAppError) => {
|
|
131
|
+
// As in the source, a list that cannot be read is its "no galleries" state (and it is never replaced by the public list: that one cannot tell a hidden gallery).
|
|
132
|
+
console.warn("galleries_section: the One App galleries service could not be read", oneAppError);
|
|
133
|
+
return { galleries: [] as RawGallery[], more: false };
|
|
134
|
+
});
|
|
135
|
+
const rows = galleries.slice(0, limit).map((gallery, index) => rowOf(gallery, index, showName));
|
|
107
136
|
return view("ready", rows, more);
|
|
108
137
|
} catch (error) {
|
|
109
138
|
console.warn("galleries_section: the galleries could not be read", error);
|