@wix/himalaya-cli 0.1806.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.
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +62 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +124 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +12 -0
- package/dist/cli.mjs +13 -1
- package/package.json +2 -2
- package/templates/brandy/README.md +83 -14
- package/templates/brandy/config.ts +42 -34
- package/templates/brandy/dev/index.ts +240 -21
- package/templates/brandy/dev/member-screens.ts +2302 -0
- package/templates/brandy/himalaya.content.json +3 -0
- package/templates/brandy/himalaya.template.json +1 -1
- package/templates/brandy/provisioning.json +4 -1
- package/templates/brandy/provisioning.member.example.json +69 -7
- package/templates/brandy/tier5-src/_shared/exclusive-writes.ts +66 -0
- package/templates/brandy/tier5-src/_shared/header-badges.ts +113 -0
- package/templates/brandy/tier5-src/_shared/himi-store-saved.ts +57 -0
- package/templates/brandy/tier5-src/_shared/iap-presentation.ts +207 -0
- package/templates/brandy/tier5-src/_shared/restaurant-ordering.ts +201 -0
- package/templates/brandy/tier5-src/_shared/source-badges.ts +72 -0
- package/templates/brandy/tier5-src/himi-branded-lite-cart/index.ts +703 -0
- package/templates/brandy/tier5-src/himi-branded-lite-header-badges/index.ts +70 -0
- package/templates/brandy/tier5-src/himi-branded-lite-member-cart/flag.ts +3 -0
- package/templates/brandy/tier5-src/himi-branded-lite-member-cart/index.ts +6 -0
- package/templates/brandy/tier5-src/perks/index.ts +75 -0
- package/templates/brandy/tokens.json +5 -0
|
@@ -1,13 +1,30 @@
|
|
|
1
|
-
// Your app's screens.
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
|
|
1
|
+
// Your app's screens. Most are pages of your website — WebView screens built from the `site` block
|
|
2
|
+
// of ../provisioning.json — so change those by changing that block, never this file. When
|
|
3
|
+
// provisioning.json enables page capabilities (`webSdk`), every page gets the worker that answers
|
|
4
|
+
// them (`withSiteWebSdk`). Beside them sit the app's native screens (Notifications, the member
|
|
5
|
+
// screens of a Wix login) and your own: the sample Perks screen below shows how to add one.
|
|
6
|
+
import {
|
|
7
|
+
assertSiteNativePagesBuilt,
|
|
8
|
+
siteCartActions,
|
|
9
|
+
siteScreens,
|
|
10
|
+
siteShellLinks,
|
|
11
|
+
withSiteCartTopBar,
|
|
12
|
+
withSiteNativeScreenTopBar,
|
|
13
|
+
withSiteTopBarActions,
|
|
14
|
+
withSiteWebSdk,
|
|
15
|
+
} from "@himalaya/core";
|
|
16
|
+
import config, { base44, BASE44_ACCOUNT_SCREEN_ID, servesCart, site, siteTopBar, webSdk, wix } from "../config.js";
|
|
17
|
+
import { MEMBER_CART_SCREENS, MEMBER_CART_SEED, MEMBER_SCREENS, MEMBER_SEED, ORDER_SCREEN } from "./member-screens.js";
|
|
8
18
|
|
|
9
19
|
// With a Wix member login (`wix`), a member signed in natively is signed in on the website pages too.
|
|
10
|
-
const
|
|
20
|
+
const SHELL_SITE = wix ? { ...site, sessionBridge: true } : site;
|
|
21
|
+
type Descriptor = ReturnType<typeof siteScreens>[string];
|
|
22
|
+
/** The app's own native screens a top-bar `{ screen }` icon may open (config.ts `builtInScreens`). */
|
|
23
|
+
const NATIVE_SCREENS = ["himi_notification_settings", ...(base44 ? [BASE44_ACCOUNT_SCREEN_ID] : []), ...(wix ? ["himi_account"] : [])];
|
|
24
|
+
/** With the member cart (config.ts `servesCart`), a website page's own top bar — which replaces the app-wide one —
|
|
25
|
+
* carries the same cart icons: the member's count, and the visitor twin that opens your site's cart page. */
|
|
26
|
+
const withCartIcons = (screen: Descriptor): Descriptor => (servesCart ? withSiteCartTopBar(SHELL_SITE, screen, { nativeScreens: NATIVE_SCREENS }) : screen);
|
|
27
|
+
const SCREENS: Record<string, Descriptor> = Object.fromEntries(Object.entries(siteScreens(SHELL_SITE)).map(([id, screen]) => [id, withCartIcons(screen)]));
|
|
11
28
|
|
|
12
29
|
// The native Notifications screen (a drawer row): whether this app may notify, and the one action
|
|
13
30
|
// that changes it — Turn on (the system prompt when it can still show, otherwise the device
|
|
@@ -942,16 +959,202 @@ function base44Account(deleteFunction: string | undefined): unknown {
|
|
|
942
959
|
}
|
|
943
960
|
const ACCOUNT = base44 ? { [BASE44_ACCOUNT_SCREEN_ID]: base44Account(base44.deleteAccountFunction) } : {};
|
|
944
961
|
|
|
962
|
+
// A SAMPLE of your own native screen: the Perks tab ../provisioning.json places with `site.nativePages`
|
|
963
|
+
// ({ "id": "perks", "screenId": "perks", ... }). Its descriptor is plain JSON, its state lives in the worker
|
|
964
|
+
// in ../tier5-src/perks/index.ts (service `perks`), and the two meet in `$service:perks.<field>` bindings:
|
|
965
|
+
// - `summary` is a line of text the worker derives;
|
|
966
|
+
// - the Grid draws one Card per row of `perks` (`itemsPath`), each reading `$item.<field>`;
|
|
967
|
+
// - a tap on a row sends `tier5.perks.toggle` with that row's id, the worker's one action.
|
|
968
|
+
// The `logicBundle` names the worker; `himi build` compiles tier5-src/perks/ and fills in its URL and integrity.
|
|
969
|
+
// Copy this pair (a literal here + a worker) for each screen of your own, add it to `exact` below, and place it
|
|
970
|
+
// in provisioning.json. Delete it (here, the worker, and its native page) when you no longer want it.
|
|
971
|
+
const PERKS = {
|
|
972
|
+
"screenId": "perks",
|
|
973
|
+
"renderer": "sdui_intent",
|
|
974
|
+
"title": "",
|
|
975
|
+
"schemaVersion": 1,
|
|
976
|
+
"cacheControl": {
|
|
977
|
+
"maxAge": 0,
|
|
978
|
+
"staleWhileRevalidate": 0
|
|
979
|
+
},
|
|
980
|
+
"payload": {
|
|
981
|
+
"id": "perks.root",
|
|
982
|
+
"body": {
|
|
983
|
+
"package": "himalaya",
|
|
984
|
+
"type": "VStack",
|
|
985
|
+
"props": {
|
|
986
|
+
"spacing": 12,
|
|
987
|
+
"alignment": "leading",
|
|
988
|
+
"children": [
|
|
989
|
+
{
|
|
990
|
+
"id": "perks.title",
|
|
991
|
+
"body": {
|
|
992
|
+
"package": "himalaya",
|
|
993
|
+
"type": "Text",
|
|
994
|
+
"props": {
|
|
995
|
+
"text": "Perks",
|
|
996
|
+
"style": "title1"
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
"id": "perks.summary",
|
|
1002
|
+
"body": {
|
|
1003
|
+
"package": "himalaya",
|
|
1004
|
+
"type": "Text",
|
|
1005
|
+
"props": {
|
|
1006
|
+
"text": "$service:perks.summary",
|
|
1007
|
+
"style": "body",
|
|
1008
|
+
"color": "textSecondary",
|
|
1009
|
+
"collapseWhenEmpty": true
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
"id": "perks.list",
|
|
1015
|
+
"body": {
|
|
1016
|
+
"package": "himalaya",
|
|
1017
|
+
"type": "Grid",
|
|
1018
|
+
"props": {
|
|
1019
|
+
"columns": 1,
|
|
1020
|
+
"spacing": 10,
|
|
1021
|
+
"itemsPath": "$service:perks.perks",
|
|
1022
|
+
"items": [
|
|
1023
|
+
{
|
|
1024
|
+
"id": "perks.row_$item.id",
|
|
1025
|
+
"body": {
|
|
1026
|
+
"package": "himalaya",
|
|
1027
|
+
"type": "Card",
|
|
1028
|
+
"props": {
|
|
1029
|
+
"children": [
|
|
1030
|
+
{
|
|
1031
|
+
"id": "perks.row_h_$item.id",
|
|
1032
|
+
"body": {
|
|
1033
|
+
"package": "himalaya",
|
|
1034
|
+
"type": "HStack",
|
|
1035
|
+
"props": {
|
|
1036
|
+
"spacing": 12,
|
|
1037
|
+
"children": [
|
|
1038
|
+
{
|
|
1039
|
+
"id": "",
|
|
1040
|
+
"body": {
|
|
1041
|
+
"package": "himalaya",
|
|
1042
|
+
"type": "Icon",
|
|
1043
|
+
"props": {
|
|
1044
|
+
"name": "gift",
|
|
1045
|
+
"size": 24,
|
|
1046
|
+
"tint": "accentPrimary"
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
"modifiers": {
|
|
1050
|
+
"accessibilityRole": "decorative"
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
"id": "perks.row_text_$item.id",
|
|
1055
|
+
"body": {
|
|
1056
|
+
"package": "himalaya",
|
|
1057
|
+
"type": "VStack",
|
|
1058
|
+
"props": {
|
|
1059
|
+
"spacing": 2,
|
|
1060
|
+
"alignment": "leading",
|
|
1061
|
+
"children": [
|
|
1062
|
+
{
|
|
1063
|
+
"id": "perks.row_title_$item.id",
|
|
1064
|
+
"body": {
|
|
1065
|
+
"package": "himalaya",
|
|
1066
|
+
"type": "Text",
|
|
1067
|
+
"props": {
|
|
1068
|
+
"text": "$item.title",
|
|
1069
|
+
"style": "bodyEmphasis"
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
"id": "perks.row_detail_$item.id",
|
|
1075
|
+
"body": {
|
|
1076
|
+
"package": "himalaya",
|
|
1077
|
+
"type": "Text",
|
|
1078
|
+
"props": {
|
|
1079
|
+
"text": "$item.detail",
|
|
1080
|
+
"style": "footnote",
|
|
1081
|
+
"color": "textSecondary"
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
{
|
|
1086
|
+
"id": "perks.row_status_$item.id",
|
|
1087
|
+
"body": {
|
|
1088
|
+
"package": "himalaya",
|
|
1089
|
+
"type": "Text",
|
|
1090
|
+
"props": {
|
|
1091
|
+
"text": "$item.status",
|
|
1092
|
+
"style": "caption",
|
|
1093
|
+
"color": "accentPrimary"
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
]
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
]
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
]
|
|
1106
|
+
}
|
|
1107
|
+
},
|
|
1108
|
+
"modifiers": {
|
|
1109
|
+
"onTap": {
|
|
1110
|
+
"actionId": "tier5.perks.toggle",
|
|
1111
|
+
"params": {
|
|
1112
|
+
"id": "$item.id"
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
]
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
]
|
|
1122
|
+
}
|
|
1123
|
+
},
|
|
1124
|
+
"modifiers": {
|
|
1125
|
+
"background": {
|
|
1126
|
+
"token": "surfacePrimary"
|
|
1127
|
+
},
|
|
1128
|
+
"padding": {
|
|
1129
|
+
"leading": 16,
|
|
1130
|
+
"trailing": 16,
|
|
1131
|
+
"top": 18,
|
|
1132
|
+
"bottom": 28
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
},
|
|
1136
|
+
"logicBundle": {
|
|
1137
|
+
"url": "http://localhost:8190/v1/bundles/perks?integrity=",
|
|
1138
|
+
"integrity": "",
|
|
1139
|
+
"contentType": "application/javascript+ts-bundle",
|
|
1140
|
+
"declaredCapabilities": [],
|
|
1141
|
+
"minBinaryVersion": "0.2.0",
|
|
1142
|
+
"bundleVersion": "0.0.1"
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
|
|
945
1146
|
// A Wix member login (`wix` in ../provisioning.json) adds the member screens in ./member-screens.ts: the
|
|
946
1147
|
// Account hub, the activity feed, the inbox, My orders and My subscriptions, and what they open. A tap in
|
|
947
1148
|
// them into a screen this app does not have (the shop, the plans, the business chat, the cart) opens the
|
|
948
|
-
// matching page of your website instead, or is removed (`siteShellLinks`).
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
// A member screen with a bar of its own also carries your top-bar icons (`site.topBar`).
|
|
952
|
-
|
|
1149
|
+
// matching page of your website instead, or is removed (`siteShellLinks`). With the member cart (`himi_cart` placed
|
|
1150
|
+
// as a native page, members only), the cart taps and an order's Reorder stay, and the cart screen is served too.
|
|
1151
|
+
const rewrite = siteShellLinks(site, { nativeCart: servesCart });
|
|
1152
|
+
// A member screen with a bar of its own also carries your top-bar icons (`site.topBar`). Its bar has room for few
|
|
1153
|
+
// icons, so the cart icon there gets the member count but no visitor twin; signed out it opens the cart's sign-in.
|
|
1154
|
+
const memberBar = siteTopBar && servesCart ? { ...siteTopBar, actions: siteCartActions(site, siteTopBar.actions ?? [], { visitorTwin: false }) } : siteTopBar;
|
|
1155
|
+
const toSite = (screen: Descriptor): Descriptor => withSiteTopBarActions(rewrite(screen), memberBar);
|
|
953
1156
|
const MEMBER: Record<string, Descriptor> = wix
|
|
954
|
-
? Object.fromEntries(Object.entries(MEMBER_SCREENS).map(([id, screen]) => [id, toSite(screen as Descriptor)]))
|
|
1157
|
+
? Object.fromEntries(Object.entries({ ...MEMBER_SCREENS, ...(servesCart ? MEMBER_CART_SCREENS : {}) }).map(([id, screen]) => [id, toSite(screen as Descriptor)]))
|
|
955
1158
|
: {};
|
|
956
1159
|
const ORDER = wix ? toSite(ORDER_SCREEN as Descriptor) : undefined;
|
|
957
1160
|
|
|
@@ -968,17 +1171,28 @@ const exact: Record<string, (ctx: Parameters<typeof withSiteWebSdk>[1]) => unkno
|
|
|
968
1171
|
...Object.fromEntries(Object.entries(ACCOUNT).map(([id, screen]) => [id, () => JSON.parse(JSON.stringify(screen))])),
|
|
969
1172
|
...Object.fromEntries(Object.entries(MEMBER).map(([id, screen]) => [id, () => JSON.parse(JSON.stringify(screen))])),
|
|
970
1173
|
// Your own native screens go here, keyed by screen id, and `site.nativePages` in
|
|
971
|
-
// ../provisioning.json places them as tabs, drawer rows or overflow screens
|
|
972
|
-
|
|
973
|
-
// with its worker in tier5-src/ (`himi docs tier-5-add-a-screen`).
|
|
1174
|
+
// ../provisioning.json places them as tabs, drawer rows or overflow screens. The sample (PERKS above):
|
|
1175
|
+
perks: () => JSON.parse(JSON.stringify(PERKS)),
|
|
1176
|
+
// …each with its worker in tier5-src/ (`himi docs tier-5-add-a-screen`).
|
|
974
1177
|
};
|
|
975
1178
|
// A native page only PLACES a screen, so it must be one built above — or its row would open nothing.
|
|
976
1179
|
assertSiteNativePagesBuilt(site, Object.keys(exact));
|
|
977
1180
|
// A top-bar icon that opens one of your native screens is left out of that screen's own bar (on the
|
|
978
1181
|
// screen itself it would open a second copy), the way a website page's bar leaves out its own icon.
|
|
1182
|
+
// That bar is built from your raw icons, so with the member cart its cart icon gets the same count and
|
|
1183
|
+
// visitor twin as the app-wide bar. A screen that draws a bar of its own keeps it as built.
|
|
1184
|
+
const place = (screen: Descriptor | null): Descriptor | null => {
|
|
1185
|
+
if (!screen || screen.topBar !== undefined) return screen;
|
|
1186
|
+
const placed = withSiteNativeScreenTopBar(site, screen, { nativeScreens: NATIVE_SCREENS });
|
|
1187
|
+
return placed === screen ? screen : withCartIcons(placed);
|
|
1188
|
+
};
|
|
979
1189
|
for (const [screenId, build] of Object.entries(exact)) {
|
|
980
1190
|
// A builder may return its screen directly or as a promise; the wrapper awaits it first.
|
|
981
|
-
if (
|
|
1191
|
+
if (screenId.startsWith("site_")) continue;
|
|
1192
|
+
exact[screenId] = (ctx) => {
|
|
1193
|
+
const built = build(ctx) as Descriptor | null | Promise<Descriptor | null>;
|
|
1194
|
+
return built && typeof (built as Promise<unknown>).then === "function" ? (built as Promise<Descriptor | null>).then(place) : place(built as Descriptor | null);
|
|
1195
|
+
};
|
|
982
1196
|
}
|
|
983
1197
|
|
|
984
1198
|
export default {
|
|
@@ -1008,9 +1222,14 @@ export default {
|
|
|
1008
1222
|
seed: {
|
|
1009
1223
|
screens: {
|
|
1010
1224
|
...SCREENS,
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1225
|
+
...Object.fromEntries(Object.entries({
|
|
1226
|
+
himi_notification_settings: NOTIFICATIONS_SEED,
|
|
1227
|
+
// The sample screen, as served: its worker boots once the app has fetched it.
|
|
1228
|
+
perks: PERKS,
|
|
1229
|
+
...ACCOUNT,
|
|
1230
|
+
...(wix ? Object.fromEntries(Object.entries({ ...MEMBER_SEED, ...(servesCart ? MEMBER_CART_SEED : {}) }).map(([id, screen]) => [id, toSite(screen as Descriptor)])) : {}),
|
|
1231
|
+
// The same top-bar rule as the live screens, so a cold offline start shows the same bars.
|
|
1232
|
+
}).map(([id, screen]) => [id, place(screen as Descriptor)])),
|
|
1014
1233
|
},
|
|
1015
1234
|
data: {},
|
|
1016
1235
|
},
|