@wix/himalaya-cli 0.1807.0 → 0.1808.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 (25) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +62 -1
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +124 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +12 -0
  4. package/dist/cli.mjs +14 -1
  5. package/package.json +2 -2
  6. package/templates/brandy/README.md +83 -14
  7. package/templates/brandy/config.ts +42 -34
  8. package/templates/brandy/dev/index.ts +240 -21
  9. package/templates/brandy/dev/member-screens.ts +2302 -0
  10. package/templates/brandy/himalaya.content.json +3 -0
  11. package/templates/brandy/himalaya.template.json +1 -1
  12. package/templates/brandy/provisioning.json +4 -1
  13. package/templates/brandy/provisioning.member.example.json +69 -7
  14. package/templates/brandy/tier5-src/_shared/exclusive-writes.ts +66 -0
  15. package/templates/brandy/tier5-src/_shared/header-badges.ts +113 -0
  16. package/templates/brandy/tier5-src/_shared/himi-store-saved.ts +57 -0
  17. package/templates/brandy/tier5-src/_shared/iap-presentation.ts +207 -0
  18. package/templates/brandy/tier5-src/_shared/restaurant-ordering.ts +201 -0
  19. package/templates/brandy/tier5-src/_shared/source-badges.ts +72 -0
  20. package/templates/brandy/tier5-src/himi-branded-lite-cart/index.ts +703 -0
  21. package/templates/brandy/tier5-src/himi-branded-lite-header-badges/index.ts +70 -0
  22. package/templates/brandy/tier5-src/himi-branded-lite-member-cart/flag.ts +3 -0
  23. package/templates/brandy/tier5-src/himi-branded-lite-member-cart/index.ts +6 -0
  24. package/templates/brandy/tier5-src/perks/index.ts +75 -0
  25. package/templates/brandy/tokens.json +5 -0
@@ -1,5 +1,5 @@
1
1
  import { type IconName } from "./icon-catalog.generated.js";
2
- import type { Component, DrawerItem, LinkableScreen, NavTabItem, ScreenDescriptor, SiteNavConfig, TopBarConfig, WebViewConfig } from "./schema.js";
2
+ import type { Component, DrawerItem, LinkableScreen, NavTabItem, ScreenDescriptor, SiteNavConfig, TopBarAction, TopBarConfig, WebViewConfig } from "./schema.js";
3
3
  /** Which hosting platform the site runs on. Selects origin allow-lists and the binary-shipped
4
4
  * page adapter:
5
5
  * - `"wix"` — a Wix site: its custom domain's `www.` twin is allowed, the Wix chrome hiders (ads,
@@ -495,6 +495,67 @@ export interface SiteShellLinkOptions {
495
495
  nativeCart?: boolean;
496
496
  }
497
497
  export declare function siteShellLinks(site: SiteShellConfig, options?: SiteShellLinkOptions): (descriptor: ScreenDescriptor) => ScreenDescriptor;
498
+ /** The member screens a site shell with a `wix` binding may place as native pages (or a placed one may be a top-bar
499
+ * `{ screen }` target): the activity feed, the inbox, My Orders and My Subscriptions. The cart is
500
+ * {@link SITE_MEMBER_CART_SCREENS}; the Account hub is `himi_account`. */
501
+ export declare const SITE_MEMBER_PAGE_SCREENS: readonly ["himi_notifications", "himi_inbox", "himi_orders", "himi_my_subscriptions"];
502
+ /** The native member cart (and its checkout, the cart worker's own pay rail), for SIGNED-IN MEMBERS only. */
503
+ export declare const SITE_MEMBER_CART_SCREENS: readonly ["himi_cart"];
504
+ /** Every screen only a member binding serves: the pages above, the cart, the Account hub and the screens they open. */
505
+ export declare const SITE_MEMBER_ONLY_SCREENS: readonly string[];
506
+ /** Member pages an outside link must never open (Branded Lite's visibility): a member's own orders. */
507
+ export declare const SITE_PRIVATE_MEMBER_PAGES: readonly string[];
508
+ /** Does this contract place the native member cart? A native page places it (a top-bar `{ screen }` icon may only
509
+ * name a screen a native page places). Only a shell with a `wix` binding may ({@link assertSiteMemberPages}). */
510
+ export declare function siteServesMemberCart(site: Pick<SiteShellConfig, "nativePages">, hasWix: boolean): boolean;
511
+ /** The badges-only app-level worker's paths (service `brandedLiteNav`, the `himi-branded-lite-header-badges` worker a
512
+ * shell serving the member cart names as `navigation.navLogicBundle`): the signed-in member's cart count (eCom's
513
+ * current cart, the same cart the website shows that member), and which of the two cart icons shows. */
514
+ export declare const SITE_MEMBER_CART_BADGE_PATH = "$service:brandedLiteNav.memberCartBadge";
515
+ export declare const SITE_MEMBER_CART_HIDDEN_PATH = "$service:brandedLiteNav.memberCartHidden";
516
+ export declare const SITE_VISITOR_CART_HIDDEN_PATH = "$service:brandedLiteNav.visitorCartHidden";
517
+ /** The site's own cart page, if the contract declares one (id `cart`, or path `/cart` / `/cart-page`; any
518
+ * placement, `overflow` included): a visitor's cart icon opens it. */
519
+ export declare function siteCartPage(site: Pick<SiteShellConfig, "pages">): SitePage | undefined;
520
+ /**
521
+ * The member cart's top-bar icons, applied to a built action list — the app's `topBarDefault` AND every site page's
522
+ * own bar, which replaces the default rather than merging with it. Each contract icon that targets `himi_cart` (a
523
+ * push, or a tab switch when the cart is a tab: matched by the contract icon's id, not its tap) gets the member count.
524
+ * With a site cart page it also gets a visitor twin `<id>_site` that opens that page, and each of the two shows for
525
+ * one session state only. Both hide FAIL-CLOSED (`hiddenUntilResolved`): neither shows until the nav worker answers,
526
+ * so the two are never on screen together, and a failed worker shows neither. The visitor twin carries no count: the
527
+ * website's own count reaches only the page's screen worker, not this app-level one. Every binding resolves against
528
+ * the nav worker by action id, on every surface.
529
+ *
530
+ * `visitorTwin: false` adds no twin (a member screen's own bar has few slots, and an icon that overflows loses its
531
+ * `hiddenPath`). `onCartPage: true` adds no twin either (it would reopen the page it is on). A list already decorated
532
+ * gets no second twin.
533
+ */
534
+ export declare function siteCartActions<A extends Pick<TopBarAction, "id">>(site: SiteShellConfig, actions: readonly A[], opts?: {
535
+ visitorTwin?: boolean;
536
+ onCartPage?: boolean;
537
+ }): Array<A | TopBarAction>;
538
+ /**
539
+ * A site page's descriptor with the member cart's icons ({@link siteCartActions}) on its own top bar. A site page's
540
+ * bar replaces `topBarDefault`, so without this its cart icon would carry no count. The site's cart page itself gets a
541
+ * bar of its own when it has none: the app-wide one carries the visitor twin, which there would reopen the page it is
542
+ * on. Unchanged when no contract icon targets the cart, or the descriptor has no bar and is not the cart page.
543
+ * `opts.nativeScreens` is the shell's own list ({@link SiteTopBarOptions}). Call it only when the shell serves the
544
+ * member cart ({@link siteServesMemberCart}).
545
+ */
546
+ export declare function withSiteCartTopBar<T>(site: SiteShellConfig, descriptor: T, opts?: SiteTopBarOptions): T;
547
+ /**
548
+ * The member-page placement rules of a site shell's contract, with the fix in each message. `where` prefixes every
549
+ * message with the field's location (`"provisioning.site"`, say).
550
+ *
551
+ * - A member's private page (`himi_orders`) never sets `public` or `requiresAuth`: an outside link never opens it.
552
+ * - A screen another member screen opens (a thread, an order, the sign-in form) cannot be placed on its own.
553
+ * - Without a `wix` binding no native page or top-bar icon may name a member screen; the cart is refused with its own
554
+ * reason (a visitor keeps the website's cart).
555
+ * - With one, a placed cart must set `requiresAuth`, and no authored icon may take the `<id>_site` id of a cart
556
+ * icon's visitor twin ({@link siteCartActions}).
557
+ */
558
+ export declare function assertSiteMemberPages(site: SiteShellConfig, hasWix: boolean, where?: string): void;
498
559
  /**
499
560
  * Where a tapped Wix member notification opens in a site shell: on the customer's own site. Wix Ping
500
561
  * delivers Wix MOBILE links (`wix:/my-account/<msid>/stores/orders/<id>`, `https://m-<msid>.branded.wix.app/…`),
@@ -16229,6 +16229,118 @@ function siteShellLinks(site, options = {}) {
16229
16229
  return copy;
16230
16230
  };
16231
16231
  }
16232
+ var SITE_MEMBER_PAGE_SCREENS = ["himi_notifications", "himi_inbox", "himi_orders", "himi_my_subscriptions"];
16233
+ var SITE_MEMBER_CART_SCREENS = ["himi_cart"];
16234
+ var SITE_MEMBER_ONLY_SCREENS = [
16235
+ "himi_account",
16236
+ ...SITE_MEMBER_CART_SCREENS,
16237
+ "himi_delete_account",
16238
+ "himi_sign_in",
16239
+ "himi_chat_thread",
16240
+ "himi_order",
16241
+ "himi_subscription",
16242
+ ...SITE_MEMBER_PAGE_SCREENS
16243
+ ];
16244
+ var SITE_PRIVATE_MEMBER_PAGES = ["himi_orders"];
16245
+ var isMemberCartScreen = (screenId) => screenId !== void 0 && SITE_MEMBER_CART_SCREENS.includes(screenId);
16246
+ function siteServesMemberCart(site, hasWix) {
16247
+ return hasWix && (site.nativePages ?? []).some((page) => isMemberCartScreen(page.screenId));
16248
+ }
16249
+ var SITE_MEMBER_CART_BADGE_PATH = "$service:brandedLiteNav.memberCartBadge";
16250
+ var SITE_MEMBER_CART_HIDDEN_PATH = "$service:brandedLiteNav.memberCartHidden";
16251
+ var SITE_VISITOR_CART_HIDDEN_PATH = "$service:brandedLiteNav.visitorCartHidden";
16252
+ function siteCartPage(site) {
16253
+ return site.pages.find((page) => page.id === "cart" || /^\/cart(-page)?\/?$/.test(page.path));
16254
+ }
16255
+ function siteCartActions(site, actions, opts = {}) {
16256
+ const cartIds = new Set((site.topBar?.actions ?? []).filter((action) => isMemberCartScreen(action.target.screen)).map((action) => action.id));
16257
+ if (cartIds.size === 0) return [...actions];
16258
+ const page = opts.visitorTwin === false ? void 0 : siteCartPage(site);
16259
+ const omitTwin = opts.onCartPage === true || actions.some((a) => a.id.endsWith("_site") && cartIds.has(a.id.slice(0, -5)));
16260
+ const visitorTap = page && !omitTwin ? siteTopBarDefault({ ...site, topBar: { actions: [{ id: "cart_site", icon: "cart", label: "Cart", target: { page: page.id } }] } })?.actions?.[0] : void 0;
16261
+ return actions.flatMap((action) => {
16262
+ if (!cartIds.has(action.id)) return [action];
16263
+ const member = {
16264
+ ...action,
16265
+ badge: { kind: "count", valuePath: SITE_MEMBER_CART_BADGE_PATH },
16266
+ ...page ? { hiddenPath: SITE_MEMBER_CART_HIDDEN_PATH, hiddenUntilResolved: true } : {}
16267
+ };
16268
+ if (!visitorTap) return [member];
16269
+ const label2 = action.accessibilityLabel;
16270
+ return [member, { ...visitorTap, id: `${action.id}_site`, ...label2 ? { accessibilityLabel: label2 } : {}, hiddenPath: SITE_VISITOR_CART_HIDDEN_PATH, hiddenUntilResolved: true }];
16271
+ });
16272
+ }
16273
+ function withSiteCartTopBar(site, descriptor, opts) {
16274
+ const d = descriptor;
16275
+ if (!d || !(site.topBar?.actions ?? []).some((action) => isMemberCartScreen(action.target.screen))) return descriptor;
16276
+ const page = siteCartPage(site);
16277
+ const cartPageScreenId = page ? siteScreenId(page) : void 0;
16278
+ const onCartPage = cartPageScreenId !== void 0 && d.screenId === cartPageScreenId;
16279
+ const actions = d.topBar?.actions ?? (onCartPage ? siteTopBarDefault(site, opts)?.actions?.filter((a) => a.onTap?.params?.screenId !== cartPageScreenId) : void 0);
16280
+ if (!actions) return descriptor;
16281
+ return { ...d, topBar: { ...d.topBar ?? {}, actions: siteCartActions(site, actions, { onCartPage }) } };
16282
+ }
16283
+ function assertSiteMemberPages(site, hasWix, where = "site") {
16284
+ const pages = site.nativePages ?? [];
16285
+ const icons = site.topBar?.actions ?? [];
16286
+ const exposed = pages.find((page) => SITE_PRIVATE_MEMBER_PAGES.includes(page.screenId) && (page.public === true || page.requiresAuth === true));
16287
+ if (exposed) {
16288
+ throw new Error(
16289
+ `${where}.nativePages id "${exposed.id}": ${exposed.screenId} is a member's private page \u2014 an outside link never opens it, so it cannot set public or requiresAuth. Remove the flag.`
16290
+ );
16291
+ }
16292
+ const placeable = /* @__PURE__ */ new Set(["himi_account", "himi_delete_account", ...SITE_MEMBER_PAGE_SCREENS, ...SITE_MEMBER_CART_SCREENS]);
16293
+ const child = pages.find((page) => SITE_MEMBER_ONLY_SCREENS.includes(page.screenId) && !placeable.has(page.screenId));
16294
+ if (child) {
16295
+ throw new Error(
16296
+ `${where}.nativePages id "${child.id}": ${child.screenId} opens from another member screen and cannot be placed. Place one of: himi_account, ${[...SITE_MEMBER_PAGE_SCREENS, ...SITE_MEMBER_CART_SCREENS].join(", ")}.`
16297
+ );
16298
+ }
16299
+ const iconScreen = (action) => action.target.screen;
16300
+ if (hasWix) {
16301
+ const ids = new Set(icons.map((action) => action.id));
16302
+ const clash = siteCartPage(site) && icons.find((action) => isMemberCartScreen(iconScreen(action)) && ids.has(`${action.id}_site`));
16303
+ if (clash) {
16304
+ throw new Error(
16305
+ `${where}.topBar.actions id "${clash.id}_site" is reserved for the website-cart twin of the cart icon "${clash.id}" \u2014 rename that icon.`
16306
+ );
16307
+ }
16308
+ const twins = siteCartPage(site) ? icons.filter((action) => isMemberCartScreen(iconScreen(action))).length : 0;
16309
+ if (icons.length + twins > SITE_TOP_BAR_MAX_ACTIONS) {
16310
+ throw new Error(
16311
+ `${where}.topBar.actions has ${icons.length} icons, and the site's cart page adds a website-cart twin to each cart icon (${twins}): ${icons.length + twins} would not fit, at most ${SITE_TOP_BAR_MAX_ACTIONS} fit beside the title. Remove an icon, or drop the cart page from site.pages.`
16312
+ );
16313
+ }
16314
+ const open = pages.find((page) => isMemberCartScreen(page.screenId) && page.requiresAuth !== true);
16315
+ if (open) {
16316
+ throw new Error(
16317
+ `${where}.nativePages id "${open.id}" places the native cart (${open.screenId}) without requiresAuth: true. The native cart is the website's cart only for a signed-in member, so a link to it must sign in first. Set requiresAuth: true.`
16318
+ );
16319
+ }
16320
+ return;
16321
+ }
16322
+ const cart = [
16323
+ ...pages.filter((page) => isMemberCartScreen(page.screenId)).map((page) => `nativePages id "${page.id}"`),
16324
+ ...icons.filter((action) => isMemberCartScreen(iconScreen(action))).map((action) => `topBar.actions id "${action.id}"`)
16325
+ ];
16326
+ if (cart.length > 0) {
16327
+ throw new Error(
16328
+ `${where} ${cart.join(", ")} names the native cart (himi_cart), but this contract has no wix member binding. The native cart is for signed-in members only: a member's cart is the website's own, while a visitor's native cart would be a second, separate cart (Wix documents no way to share it). Visitors keep the website's cart: point the icon at the site's cart page ({ page }), or add a wix binding (clientId + redirectUri).`
16329
+ );
16330
+ }
16331
+ const named = [
16332
+ ...pages.map((page) => ({ at: `nativePages id "${page.id}"`, screenId: page.screenId })),
16333
+ ...icons.flatMap((action) => {
16334
+ const screen = iconScreen(action);
16335
+ return screen ? [{ at: `topBar.actions id "${action.id}"`, screenId: screen }] : [];
16336
+ })
16337
+ ].filter((entry) => SITE_MEMBER_ONLY_SCREENS.includes(entry.screenId));
16338
+ if (named.length > 0) {
16339
+ throw new Error(
16340
+ `${where} ${named.map((entry) => `${entry.at} (${entry.screenId})`).join(", ")} names a member screen, but this contract has no wix member binding: a visitor-only app does not serve it. Add a wix binding (clientId + redirectUri), or remove those entries.`
16341
+ );
16342
+ }
16343
+ }
16232
16344
  var SITE_MEMBER_PAGE_FOR = {
16233
16345
  "store.order": "orders",
16234
16346
  "bookings.session": "bookings"
@@ -16657,6 +16769,11 @@ export {
16657
16769
  SITE_BUILTIN_NATIVE_SCREENS,
16658
16770
  SITE_KINDS,
16659
16771
  SITE_LAYOUTS,
16772
+ SITE_MEMBER_CART_BADGE_PATH,
16773
+ SITE_MEMBER_CART_HIDDEN_PATH,
16774
+ SITE_MEMBER_CART_SCREENS,
16775
+ SITE_MEMBER_ONLY_SCREENS,
16776
+ SITE_MEMBER_PAGE_SCREENS,
16660
16777
  SITE_MENU_DEFAULT_ICON,
16661
16778
  SITE_MENU_DRAWER_ID_PREFIX,
16662
16779
  SITE_MENU_HREF_MAX,
@@ -16676,12 +16793,14 @@ export {
16676
16793
  SITE_PAGE_NODE_ID,
16677
16794
  SITE_PAGE_SCREEN_ID,
16678
16795
  SITE_PAGE_TITLES,
16796
+ SITE_PRIVATE_MEMBER_PAGES,
16679
16797
  SITE_PRIVATE_NATIVE_SCREENS,
16680
16798
  SITE_SCREEN_FORMS,
16681
16799
  SITE_SCREEN_PREFIX,
16682
16800
  SITE_SCREEN_TRAILING_SLOTS,
16683
16801
  SITE_SHELL_MAX_TABS,
16684
16802
  SITE_TOP_BAR_MAX_ACTIONS,
16803
+ SITE_VISITOR_CART_HIDDEN_PATH,
16685
16804
  SITE_WEB_SDK_GENERATED_PREFIX,
16686
16805
  SITE_WEB_SDK_HEALTH_BUNDLE,
16687
16806
  SIZE_CLASS_BREAKPOINTS,
@@ -16710,6 +16829,7 @@ export {
16710
16829
  appLogicBundleConflict,
16711
16830
  appLogicBundleRef,
16712
16831
  appServicesAllowed,
16832
+ assertSiteMemberPages,
16713
16833
  assertSiteNativePagesAuth,
16714
16834
  assertSiteNativePagesBuilt,
16715
16835
  assertSiteShellConfig,
@@ -16818,6 +16938,8 @@ export {
16818
16938
  shipsLocale,
16819
16939
  shouldRevealError,
16820
16940
  siteAllowedOrigins,
16941
+ siteCartActions,
16942
+ siteCartPage,
16821
16943
  siteHost,
16822
16944
  siteLinkableScreens,
16823
16945
  siteMemberPushRoutes,
@@ -16835,6 +16957,7 @@ export {
16835
16957
  sitePageUrl,
16836
16958
  siteScreenId,
16837
16959
  siteScreens,
16960
+ siteServesMemberCart,
16838
16961
  siteShellLinks,
16839
16962
  siteSidebar,
16840
16963
  siteTopBarDefault,
@@ -16868,6 +16991,7 @@ export {
16868
16991
  webViewOriginAllowed,
16869
16992
  webViewSiteTrustAppFindings,
16870
16993
  widgetSnapshotSchema,
16994
+ withSiteCartTopBar,
16871
16995
  withSiteNativeScreenTopBar,
16872
16996
  withSiteNativeScreenTopBarBuilder,
16873
16997
  withSiteTopBarActions,
@@ -8907,6 +8907,18 @@ function sitePageNode(site, page, opts) {
8907
8907
  return primarySiteWebView(url, enforceSiteKind(site, { ...siteWebViewPreset(site), ...adapter, ...page.webView ?? {} }), opts?.id ?? SITE_PAGE_NODE_ID, page.title, [], page.bridge);
8908
8908
  }
8909
8909
  var ICONS = new Set(ICON_NAMES);
8910
+ var SITE_MEMBER_PAGE_SCREENS = ["himi_notifications", "himi_inbox", "himi_orders", "himi_my_subscriptions"];
8911
+ var SITE_MEMBER_CART_SCREENS = ["himi_cart"];
8912
+ var SITE_MEMBER_ONLY_SCREENS = [
8913
+ "himi_account",
8914
+ ...SITE_MEMBER_CART_SCREENS,
8915
+ "himi_delete_account",
8916
+ "himi_sign_in",
8917
+ "himi_chat_thread",
8918
+ "himi_order",
8919
+ "himi_subscription",
8920
+ ...SITE_MEMBER_PAGE_SCREENS
8921
+ ];
8910
8922
 
8911
8923
  // ../../core/ts/src/rich-content-limits.generated.ts
8912
8924
  var RICH_CONTENT_LIMITS = Object.freeze({ maxBytes: 262144, maxNodes: 5e3, maxDepth: 16 });
package/dist/cli.mjs CHANGED
@@ -8416,7 +8416,7 @@ function assertExternalUrl(site, value2, where) {
8416
8416
  throw new Error(`${where}: target url ${JSON.stringify(value2)} is on the site itself \u2014 declare it as a page (placement "overflow" for no row) and target { page }`);
8417
8417
  }
8418
8418
  }
8419
- var WIX_FREE_SITE_HOST_SUFFIXES, SITE_KINDS, SITE_LAYOUTS, SITE_PAGE_TITLES, SITE_TOP_BAR_MAX_ACTIONS, SITE_BUILTIN_NATIVE_SCREENS, SITE_PRIVATE_NATIVE_SCREENS, SITE_SHELL_MAX_TABS, SITE_SCREEN_PREFIX, SITE_PAGE_SCREEN_ID, BASE44_ORIGINS, PAGE_ID, SITE_PAGE_NODE_ID, SITE_SCREEN_FORMS, SITE_NODE_SCREEN_RENDERER, PLACEMENTS, ICONS;
8419
+ var WIX_FREE_SITE_HOST_SUFFIXES, SITE_KINDS, SITE_LAYOUTS, SITE_PAGE_TITLES, SITE_TOP_BAR_MAX_ACTIONS, SITE_BUILTIN_NATIVE_SCREENS, SITE_PRIVATE_NATIVE_SCREENS, SITE_SHELL_MAX_TABS, SITE_SCREEN_PREFIX, SITE_PAGE_SCREEN_ID, BASE44_ORIGINS, PAGE_ID, SITE_PAGE_NODE_ID, SITE_SCREEN_FORMS, SITE_NODE_SCREEN_RENDERER, PLACEMENTS, ICONS, SITE_MEMBER_PAGE_SCREENS, SITE_MEMBER_CART_SCREENS, SITE_MEMBER_ONLY_SCREENS;
8420
8420
  var init_site_shell = __esm({
8421
8421
  "../../core/ts/src/site-shell.ts"() {
8422
8422
  init_define_HHP_CATALOG();
@@ -8443,6 +8443,18 @@ var init_site_shell = __esm({
8443
8443
  SITE_NODE_SCREEN_RENDERER = "sdui_layout";
8444
8444
  PLACEMENTS = ["tab", "drawer", "overflow"];
8445
8445
  ICONS = new Set(ICON_NAMES);
8446
+ SITE_MEMBER_PAGE_SCREENS = ["himi_notifications", "himi_inbox", "himi_orders", "himi_my_subscriptions"];
8447
+ SITE_MEMBER_CART_SCREENS = ["himi_cart"];
8448
+ SITE_MEMBER_ONLY_SCREENS = [
8449
+ "himi_account",
8450
+ ...SITE_MEMBER_CART_SCREENS,
8451
+ "himi_delete_account",
8452
+ "himi_sign_in",
8453
+ "himi_chat_thread",
8454
+ "himi_order",
8455
+ "himi_subscription",
8456
+ ...SITE_MEMBER_PAGE_SCREENS
8457
+ ];
8446
8458
  }
8447
8459
  });
8448
8460
 
@@ -42314,6 +42326,7 @@ function shouldRevealError(args) {
42314
42326
  var EMAIL_RE, URL_HOST_RE, INTEGER_RE, NUMBER_RE, AUTHORED_PATTERN_LIMIT, authoredPatterns;
42315
42327
  var init_validation = __esm({
42316
42328
  "../../core/ts/src/validation.ts"() {
42329
+ "use strict";
42317
42330
  init_define_HHP_CATALOG();
42318
42331
  EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
42319
42332
  URL_HOST_RE = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:[0-9]+)?$/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1807.0",
3
+ "version": "0.1808.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": "20e30f08c9db97668a334ba87ccf974c5961140b97c864ff2a3f35a5"
85
+ "falconPackageHash": "7e486167dde2258c4a3d4198efbf0e07bea6d0d928d7befacfa1560d"
86
86
  }
@@ -1,8 +1,9 @@
1
1
  # __HIMI_APP_NAME__ — your website as an app
2
2
 
3
- A **site shell**: your live website (on Wix, on Base44, or any other https site), framed as a native app. Every tab and drawer row is one of
4
- your site's own pages, shown in a WebView under native navigation chrome and splash in your brand
5
- colours. The `site.layout` setting selects `auto`, `tabs`, `drawer`, `sidebar`, or `single`; `auto`
3
+ A **site shell**: your live website (on Wix, on Base44, or any other https site), framed as a native app. Your
4
+ site's own pages fill the tabs and drawer, each shown in a WebView under native navigation chrome and splash
5
+ in your brand colours, beside native screens of your own: a sample **Perks** tab ships ready to copy, and a
6
+ Wix member login adds native Account, Notifications and Cart screens. The `site.layout` setting selects `auto`, `tabs`, `drawer`, `sidebar`, or `single`; `auto`
6
7
  removes the tab bar for a one-tab site and keeps its pages reachable through the drawer. The
7
8
  site's own header, footer and Wix ads are hidden (on a Wix site). It is the fastest way to ship an existing
8
9
  website as an app, and each tab can later be replaced by a native screen.
@@ -33,11 +34,18 @@ The whole app is the `site` block in `provisioning.json`:
33
34
  { "id": "blog", "title": "Blog", "path": "/blog", "icon": "newspaper" },
34
35
  { "id": "contact", "title": "Contact", "path": "/contact", "icon": "mail", "placement": "drawer" }
35
36
  ],
36
- "chrome": { "hideSiteHeader": true, "hideSiteMenu": true, "hideSiteFooter": true, "hideWixAds": true }
37
+ "chrome": { "hideSiteHeader": true, "hideSiteMenu": true, "hideSiteFooter": true, "hideWixAds": true },
38
+ "nativePages": [
39
+ { "id": "perks", "screenId": "perks", "title": "Perks", "icon": "gift" }
40
+ ]
37
41
  }
38
42
  }
39
43
  ```
40
44
 
45
+ The `nativePages` entry is a sample native tab, Perks, beside your site's pages: see
46
+ [Your own native screens: the Perks sample](#your-own-native-screens-the-perks-sample). Keep it, change it,
47
+ or delete the entry to ship only your site's pages.
48
+
41
49
  The placeholder origin above is not a real site. Until you replace it, the app loads its pages from
42
50
  `WIX_SITE_URL` when that is set (the published template preview uses it to show a demo site), and
43
51
  once you set your own origin `WIX_SITE_URL` is ignored. Replace it by deriving the block from your
@@ -114,14 +122,15 @@ Optional parts of the `site` block add or trim native chrome, with no code:
114
122
  { "id": "insta", "icon": "photo", "label": "Instagram", "target": { "url": "https://instagram.com/yourshop" } }
115
123
  ] },
116
124
  "nativePages": [
117
- { "id": "rewards", "screenId": "rewards", "title": "Rewards", "icon": "star", "placement": "tab", "after": "home" }
125
+ { "id": "perks", "screenId": "perks", "title": "Perks", "icon": "gift", "placement": "tab", "after": "home" }
118
126
  ]
119
127
  ```
120
128
 
121
129
  - **`topBar.actions`** puts up to three icons at the trailing end of every screen's top bar. `label` is
122
130
  what a screen reader says. A `target` is one of `page` (one of your site's pages, `overflow` ones
123
- included, such as a cart page), `screen` (a native page's screen, or `himi_notification_settings`), or
124
- `url` (a page off your site, which opens in the browser after an "Open in browser?" prompt).
131
+ included, such as a cart page), `screen` (a native page's screen, or `himi_notification_settings`; with a
132
+ Wix member login also `himi_account`), or `url` (a page off your site, which opens in the browser after an
133
+ "Open in browser?" prompt).
125
134
  - **`nativePages`** adds your own Tier-5 screens as a `tab`, a `drawer` row or `overflow` (no row, but
126
135
  linkable). They sit among your site's pages after the page named in `after`, or after all of them
127
136
  when `after` is not set. Tabs count toward the four-tab limit. Add each screen to `dev/index.ts`
@@ -136,6 +145,31 @@ Optional parts of the `site` block add or trim native chrome, with no code:
136
145
  row already names it, and shows it on `overflow` pages and pages opened from a link. Set
137
146
  `"showTitle": true` or `false` on a page to override the rule for that page.
138
147
 
148
+ ## Your own native screens: the Perks sample
149
+
150
+ A fresh app has one native screen of its own beside your site's pages: the **Perks** tab. It works
151
+ without any Wix binding, and it is the pattern to copy for a screen of yours. It is three pieces:
152
+
153
+ - **The worker**, `tier5-src/perks/index.ts`: a `defineService("perks", …)` that holds a short list of
154
+ perks in its state and handles one action, `toggle`, which claims a perk or undoes the claim. Every field
155
+ the screen shows is a flat string the worker shapes, and its `derive()` recomputes the derived ones (each
156
+ row's status, the summary line) in every action.
157
+ - **The descriptor**, `PERKS` in `dev/index.ts`: a title, the bound summary
158
+ (`$service:perks.summary`), and a `Grid` that draws one card per perk (`itemsPath:
159
+ "$service:perks.perks"`, each card reading `$item.title`, `$item.detail` and `$item.status`). A tap on
160
+ a card sends `tier5.perks.toggle` with that perk's id. Its `logicBundle` names the worker.
161
+ - **The placement**, `site.nativePages` in `provisioning.json`, which makes `perks` a tab.
162
+
163
+ ```bash
164
+ himi build && himi validate --strict # compiles tier5-src/perks/, checks every $service:perks.* binding
165
+ himi render perks # the Perks tab, with the worker's first state
166
+ himi test # taps every perk card against the real worker
167
+ ```
168
+
169
+ To make your own, copy the pair (a descriptor in `dev/index.ts`, added to `screens.exact`, and a worker
170
+ in `tier5-src/<name>/`), then place it. To remove the sample, delete its `nativePages` entry, `perks`
171
+ from `dev/index.ts` and `tier5-src/perks/`. `himi docs tier-5-add-a-screen` covers workers in depth.
172
+
139
173
  ## Member login and member pages
140
174
 
141
175
  A `wix` block in `provisioning.json` adds a native member login to a Wix site. Members sign in on the
@@ -149,11 +183,46 @@ app's Account screen, and the app signs them in on your website's pages too.
149
183
  the redirect. Add `"siteId": "<msid>"` to register members for push notifications. With the binding the
150
184
  app also serves the member pages in `dev/member-screens.ts`, which a native page may place (and a
151
185
  `{ screen }` icon open, once placed): `himi_notifications` (activity), `himi_inbox`, `himi_orders` and `himi_my_subscriptions`, plus the
152
- Account hub `himi_account`, which links to all of them. `provisioning.member.example.json` shows a good
153
- start: Account and Notifications drawer rows and a bell that opens Notifications. A tap in these screens
154
- into one this app does not have (a shop, plans, a business chat, a cart) opens the matching page of your
155
- site instead, or is removed. Without a `wix` block, `himi validate` refuses any member page. Cart and
156
- checkout are not native pages yet.
186
+ Account hub `himi_account`, which links to all of them, and the member cart `himi_cart` (below). A tap in
187
+ these screens into one this app does not have (a shop, plans, a business chat) opens the matching page of
188
+ your site instead, or is removed. Without a `wix` block, `himi validate` refuses any member page and the cart.
189
+
190
+ `provisioning.member.example.json` is a good start. Copy it over `provisioning.json` and fill in your
191
+ client:
192
+
193
+ - **Drawer rows** for Account (`himi_account`), Notifications (`himi_notifications`) and the Cart.
194
+ - **Top-bar icons**: the cart, and a person icon that opens the Account hub. Two fit beside a screen's own
195
+ actions; a third would move into the More menu, so Notifications stays a drawer row.
196
+ On the Account screen itself the person icon is left out, as every icon is on the screen it opens.
197
+
198
+ ### The member cart
199
+
200
+ `himi_cart` is a native cart and checkout for **signed-in members only**. A member's native cart is the
201
+ same cart your website shows them (the app carries their session into your pages), so what they add on a
202
+ page shows in the native cart and the other way round. A visitor's native cart would be a second, separate
203
+ cart, so a visitor keeps your website's own cart:
204
+
205
+ ```json
206
+ "nativePages": [
207
+ { "id": "cart", "screenId": "himi_cart", "title": "Cart", "icon": "cart", "placement": "drawer", "requiresAuth": true }
208
+ ],
209
+ "topBar": { "actions": [
210
+ { "id": "cart", "icon": "cart", "label": "Cart", "target": { "screen": "himi_cart" } }
211
+ ] }
212
+ ```
213
+
214
+ - **`requiresAuth: true` is required.** A link to the cart from outside the app signs the user in first;
215
+ `himi validate` refuses a cart page without it. Signed out, the cart screen shows a sign-in prompt.
216
+ - **The cart icon shows the member's item count**, kept current by an app-level worker
217
+ (`tier5-src/himi-branded-lite-header-badges/`, `navigation.navLogicBundle` in `config.ts`) at launch, on
218
+ sign-in and sign-out, and when the app returns to the foreground.
219
+ - **Visitors get a twin icon** when your site has its own cart page in `pages` (id `cart`, or path
220
+ `/cart` or `/cart-page`; an `overflow` page is enough): signed out, the cart icon opens that page
221
+ instead, and signed in, the native cart. Only one of the two shows at a time. Without such a page there
222
+ is one icon, which opens the native cart's sign-in prompt for a visitor. The icon id `<cart icon id>_site`
223
+ is taken by that twin.
224
+ - Every website page's own top bar carries the same icons, and an order's Reorder fills the native cart.
225
+ - The app adds the `wix_cashier` capability for the checkout.
157
226
 
158
227
  ## Wrap any website (not on Wix)
159
228
 
@@ -193,8 +262,8 @@ hide the menu, and `hideSelectors` hides what you list (see
193
262
  beside it, or `"menuSource": "runtime"`, is refused.
194
263
 
195
264
  **App Store review.** Apple's guideline 4.2 rejects an app that is only a website in a wrapper. The
196
- native tabs and drawer, and the Notifications screen every site shell has, are what this app adds;
197
- plan for more native value before you submit.
265
+ native tabs and drawer, the Notifications screen every site shell has, and your own native screens
266
+ (the Perks sample shows how) are what this app adds; plan for more native value before you submit.
198
267
 
199
268
  ## Let your pages call the phone
200
269
 
@@ -7,14 +7,18 @@
7
7
  // which derives it from your site's own menu. Inspect the live values any time with
8
8
  // `himi context`; see `himi docs app-config`.
9
9
  import {
10
+ SITE_MEMBER_PAGE_SCREENS,
11
+ assertSiteMemberPages,
10
12
  assertSiteNativePagesAuth,
11
13
  assertSiteShellConfig,
12
14
  defineApp,
15
+ siteCartActions,
13
16
  siteLinkableScreens,
14
17
  siteNav,
15
18
  siteNavKind,
16
19
  siteSidebar,
17
20
  siteNavConfig,
21
+ siteServesMemberCart,
18
22
  siteTopBarDefault,
19
23
  siteWebSdkCompanion,
20
24
  siteWixPingPush,
@@ -48,7 +52,7 @@ function withPreviewOrigin(provisioned: SiteShellConfig): SiteShellConfig {
48
52
  * { "id": "insta", "icon": "photo", "label": "Instagram", "target": { "url": "https://instagram.com/yourshop" } }
49
53
  * ] },
50
54
  * "nativePages": [
51
- * { "id": "rewards", "screenId": "rewards", "title": "Rewards", "icon": "star", "placement": "tab", "after": "home" }
55
+ * { "id": "perks", "screenId": "perks", "title": "Perks", "icon": "gift" }
52
56
  * ]
53
57
  *
54
58
  * `topBar.actions` — up to three trailing icons on every screen. A target opens a site page (`page`,
@@ -57,7 +61,8 @@ function withPreviewOrigin(provisioned: SiteShellConfig): SiteShellConfig {
57
61
  * prompt (`url`).
58
62
  * `nativePages` — your own Tier-5 screens as tabs, drawer rows or `overflow` (linkable only), mixed with
59
63
  * the site's pages (`after` names the page it follows; absent ⇒ after them all). The screen itself is
60
- * yours: add it to dev/index.ts. Tabs count toward the four-tab limit together with the site's. A
64
+ * yours: add it to dev/index.ts. ./provisioning.json ships one, the sample Perks tab (`perks`, its worker in
65
+ * tier5-src/perks/). Tabs count toward the four-tab limit together with the site's. A
61
66
  * native page is linkable from outside the app (`<scheme>://screen/<screenId>`) only with "public": true.
62
67
  * `pageTitle` — "auto" (default: no title on a page a tab, sidebar or drawer row opens; a title on
63
68
  * overflow and link-opened pages), "always" or "never"; a page's `showTitle` overrides it. */
@@ -170,36 +175,18 @@ export const wix: WixBinding | undefined = rawWix == null || Object.values(rawWi
170
175
  })();
171
176
  if (wix && base44) throw new Error("provisioning.json: bind either wix or base44, not both");
172
177
  /** The member pages a native page or top-bar icon may name, with a `wix` binding only. */
173
- export const MEMBER_PAGE_SCREENS = ["himi_notifications", "himi_inbox", "himi_orders", "himi_my_subscriptions"];
174
- /** Every screen only a member binding serves: the pages, the Account hub and the screens they open. */
175
- const MEMBER_ONLY_SCREENS = ["himi_account", "himi_delete_account", "himi_sign_in", "himi_chat_thread", "himi_subscription", "himi_order", ...MEMBER_PAGE_SCREENS];
176
- for (const page of site.nativePages ?? []) {
177
- const child = MEMBER_ONLY_SCREENS.includes(page.screenId) && page.screenId !== "himi_account" && !MEMBER_PAGE_SCREENS.includes(page.screenId);
178
- if (child) {
179
- throw new Error(`provisioning.json: native page "${page.id}": ${page.screenId} opens from another member screen and cannot be placed. Place one of: himi_account, ${MEMBER_PAGE_SCREENS.join(", ")}`);
180
- }
181
- }
182
- // A member's own orders are never opened by an outside link, even when a native page places them.
183
- for (const page of site.nativePages ?? []) {
184
- if (page.screenId === "himi_orders" && (page.public === true || page.requiresAuth === true)) {
185
- throw new Error(`provisioning.json: native page "${page.id}": himi_orders is a member's private page — an outside link never opens it, so it cannot set public or requiresAuth. Remove the flag.`);
186
- }
187
- }
188
- if (!wix) {
189
- const named = [
190
- ...(site.nativePages ?? []).map((page) => ({ where: `native page "${page.id}"`, screenId: page.screenId })),
191
- ...(site.topBar?.actions ?? []).flatMap((action) =>
192
- "screen" in action.target && action.target.screen ? [{ where: `top-bar icon "${action.id}"`, screenId: action.target.screen }] : []),
193
- ].filter((entry) => MEMBER_ONLY_SCREENS.includes(entry.screenId));
194
- if (named.length > 0) {
195
- throw new Error(
196
- `provisioning.json: ${named.map((entry) => `${entry.where} (${entry.screenId})`).join(", ")} names a member screen, but there is no wix ` +
197
- "member binding, so this visitor-only app does not serve it. Add a wix binding (clientId + redirectUri), or remove those entries.",
198
- );
199
- }
200
- }
178
+ export const MEMBER_PAGE_SCREENS: readonly string[] = SITE_MEMBER_PAGE_SCREENS;
179
+ // The member-page rules every site shell shares (`assertSiteMemberPages` in @himalaya/core): a member page or the
180
+ // cart needs a `wix` binding, a screen another member screen opens cannot be placed, a member's own orders never
181
+ // open from an outside link, and a placed cart signs in first (`requiresAuth: true`).
182
+ assertSiteMemberPages(site, Boolean(wix), "provisioning.json: site");
183
+ /** The native member cart (`himi_cart` placed as a native page, beside a `wix` binding): a cart for SIGNED-IN
184
+ * members, which is the website's own cart for them. A visitor keeps the website's cart page. See the README. */
185
+ export const servesCart = siteServesMemberCart(site, Boolean(wix));
201
186
  /** What the member pages' workers declare beyond push and wix_api. */
202
187
  const MEMBER_CAPABILITIES = ["wix_api", "open_url", "wix_platform", "local_database", "app_info", "iap", "live_activity"];
188
+ /** What the member cart's worker declares beyond those: the wallet fast path of its pay rail. */
189
+ const MEMBER_CART_CAPABILITIES = ["wix_cashier"];
203
190
 
204
191
  /** What the app's `base44` setting carries: the app id, and its server when the binding names one. */
205
192
  const base44Config = base44 === undefined ? undefined
@@ -233,8 +220,12 @@ for (const page of [...site.pages, ...(site.nativePages ?? [])]) {
233
220
  /** The native screens this app serves itself, which a top-bar `{ screen }` target may name beside your
234
221
  * native pages: Notifications, and a Base44 site's Account. */
235
222
  const builtInScreens = ["himi_notification_settings", ...(base44 ? [BASE44_ACCOUNT_SCREEN_ID] : []), ...(wix ? ["himi_account"] : [])];
236
- /** `site.topBar` as the app-wide top bar (every screen without one of its own). */
237
- export const topBarDefault = siteTopBarDefault(site, { nativeScreens: builtInScreens });
223
+ /** `site.topBar` as the app-wide top bar (every screen without one of its own), exactly as written. */
224
+ export const siteTopBar = siteTopBarDefault(site, { nativeScreens: builtInScreens });
225
+ /** The served top bar: with the member cart, its icon carries the member's cart count, and when your site has a
226
+ * cart page (id `cart`, or path `/cart`), a twin icon opens that page for a visitor; each shows for one session
227
+ * state only (`siteCartActions`). dev/index.ts puts the same icons on each website page's own bar. */
228
+ export const topBarDefault = siteTopBar && servesCart ? { ...siteTopBar, actions: siteCartActions(site, siteTopBar.actions ?? []) } : siteTopBar;
238
229
  // A native page's `requiresAuth` needs a sign-in that gates deep links. This app has none (a Wix site is
239
230
  // visitor-only, and a Base44 sign-in does not gate links yet), so it refuses the flag rather than open
240
231
  // the screen signed out.
@@ -269,8 +260,9 @@ export default defineApp({
269
260
  // `push` lets the app ask for notification permission and show the Notifications screen.
270
261
  // `base44` (a Base44 site only) lets the Account screen sign members in to your Base44 app.
271
262
  // Then whatever `webSdk` lets your pages call, with its permission wording.
272
- // `wix_api` and the rest (a `wix` member binding only) back the member pages' workers.
273
- capabilities: [...new Set(["push", ...(base44 ? ["base44"] : []), ...(wix ? MEMBER_CAPABILITIES : []), ...pageCapabilities])],
263
+ // `wix_api` and the rest (a `wix` member binding only) back the member pages' workers, and `wix_cashier`
264
+ // the member cart's checkout.
265
+ capabilities: [...new Set(["push", ...(base44 ? ["base44"] : []), ...(wix ? MEMBER_CAPABILITIES : []), ...(servesCart ? MEMBER_CART_CAPABILITIES : []), ...pageCapabilities])],
274
266
  permissionCopy: webSdk?.permissionCopy,
275
267
  // The Base44 app the native sign-in and the website pages' session talk to (none for a Wix site).
276
268
  base44: base44Config,
@@ -336,6 +328,22 @@ export default defineApp({
336
328
  drawer: { items: [...nav.drawer, ...nativeRows] },
337
329
  // The rail (tablet, or `layout: "sidebar"`) replaces the drawer, so it lists the same rows.
338
330
  sidebar: { items: [...siteSidebar(site), ...nativeRows] },
331
+ // With the member cart: the app-level worker behind its icons (the member's cart count, and which of the two
332
+ // cart icons shows). It refreshes at launch, on sign-in and sign-out, and when the app returns to the
333
+ // foreground. `himi build` builds it from tier5-src/ and fills in `integrity`. Kept last: a spread hides the
334
+ // keys after it from `himi`'s config editor.
335
+ ...(servesCart
336
+ ? {
337
+ navLogicBundle: {
338
+ url: "/v1/bundles/himi-branded-lite-header-badges",
339
+ integrity: "",
340
+ contentType: "application/javascript+ts-bundle",
341
+ declaredCapabilities: ["wix_api"],
342
+ minBinaryVersion: "0.1.0",
343
+ bundleVersion: "0.0.1",
344
+ },
345
+ }
346
+ : {}),
339
347
  },
340
348
  entities: {},
341
349
  });