@wix/himalaya-cli 0.1525.0 → 0.1527.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/dev-server/src/builder.d.ts +14 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/state/src/connectivity.d.ts +5 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/state/src/index.d.ts +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +22 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/worker-subtree-safe-types.generated.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +7 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +13 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/state.mjs +14 -0
- package/dist/cli.mjs +157 -40
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/designing-himi-screens.md +43 -18
- package/guides/himi-test.md +3 -3
- package/guides/recipe-dynamic-list.md +7 -7
- package/guides/recipe-four-state.md +47 -41
- package/guides/recipe-search.md +1 -1
- package/package.json +2 -2
- package/templates/beauty-salon/dev/index.ts +1943 -646
- package/templates/beauty-salon/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/beauty-salon/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +1 -0
- package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +803 -284
- package/templates/beauty-salon/tier5-src/himi-branded-lite-address/index.ts +3 -1
- package/templates/beauty-salon/tier5-src/himi-branded-lite-addresses/index.ts +3 -1
- package/templates/beauty-salon/tier5-src/himi-branded-lite-agenda/index.ts +9 -1
- package/templates/beauty-salon/tier5-src/himi-branded-lite-cart/index.ts +3 -0
- package/templates/beauty-salon/tier5-src/himi-branded-lite-order/index.ts +3 -1
- package/templates/beauty-salon/tier5-src/himi-branded-lite-place-summary/index.ts +12 -1
- package/templates/beauty-salon/tier5-src/himi-branded-lite-plans/index.ts +13 -1
- package/templates/beauty-salon/tier5-src/himi-branded-lite-wallet/index.ts +3 -1
- package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +10 -4
- package/templates/beauty-salon-owner/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/beauty-salon-owner/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/branded-lite/dev/index.ts +2404 -1020
- package/templates/branded-lite/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/branded-lite/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/branded-lite/tier5-src/business-chat/index.ts +4 -0
- package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +1 -0
- package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +803 -284
- package/templates/branded-lite/tier5-src/himi-branded-lite-address/index.ts +3 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-addresses/index.ts +3 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-agenda/index.ts +9 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-cart/index.ts +3 -0
- package/templates/branded-lite/tier5-src/himi-branded-lite-feed/index.ts +3 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-group/index.ts +3 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-notifications/index.ts +6 -4
- package/templates/branded-lite/tier5-src/himi-branded-lite-notifsettings/index.ts +6 -4
- package/templates/branded-lite/tier5-src/himi-branded-lite-order/index.ts +3 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-place-summary/index.ts +12 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-plans/index.ts +13 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-program/index.ts +3 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-reservations/index.ts +6 -4
- package/templates/branded-lite/tier5-src/himi-branded-lite-reserve/index.ts +3 -1
- package/templates/branded-lite/tier5-src/himi-branded-lite-wallet/index.ts +3 -1
- package/templates/branded-lite/tier5-src/himi-events-detail/index.ts +8 -1
- package/templates/branded-lite/tier5-src/himi-events-rsvp/index.ts +7 -4
- package/templates/branded-lite/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/branded-lite/tier5-src/himi-store-product/index.ts +10 -4
- package/templates/community-club/dev/index.ts +40 -21
- package/templates/community-club/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/community-club/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/community-club/tier5-src/himi-branded-lite-feed/index.ts +3 -1
- package/templates/community-club/tier5-src/himi-branded-lite-group/index.ts +3 -1
- package/templates/community-club/tier5-src/himi-events-detail/index.ts +8 -1
- package/templates/community-club/tier5-src/himi-events-rsvp/index.ts +7 -4
- package/templates/community-club/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/community-club-owner/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/community-club-owner/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/events-meetups/dev/index.ts +36 -19
- package/templates/events-meetups/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/events-meetups/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/events-meetups/tier5-src/himi-branded-lite-feed/index.ts +3 -1
- package/templates/events-meetups/tier5-src/himi-branded-lite-group/index.ts +3 -1
- package/templates/events-meetups/tier5-src/himi-events-detail/index.ts +8 -1
- package/templates/events-meetups/tier5-src/himi-events-rsvp/index.ts +7 -4
- package/templates/events-meetups/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/events-meetups-owner/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/events-meetups-owner/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/gym-fitness/dev/index.ts +1944 -645
- package/templates/gym-fitness/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/gym-fitness/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +1 -0
- package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +803 -284
- package/templates/gym-fitness/tier5-src/himi-branded-lite-address/index.ts +3 -1
- package/templates/gym-fitness/tier5-src/himi-branded-lite-addresses/index.ts +3 -1
- package/templates/gym-fitness/tier5-src/himi-branded-lite-agenda/index.ts +9 -1
- package/templates/gym-fitness/tier5-src/himi-branded-lite-cart/index.ts +3 -0
- package/templates/gym-fitness/tier5-src/himi-branded-lite-order/index.ts +3 -1
- package/templates/gym-fitness/tier5-src/himi-branded-lite-place-summary/index.ts +12 -1
- package/templates/gym-fitness/tier5-src/himi-branded-lite-plans/index.ts +13 -1
- package/templates/gym-fitness/tier5-src/himi-branded-lite-wallet/index.ts +3 -1
- package/templates/gym-fitness/tier5-src/himi-events-detail/index.ts +8 -1
- package/templates/gym-fitness/tier5-src/himi-events-rsvp/index.ts +7 -4
- package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +10 -4
- package/templates/gym-fitness-owner/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/gym-fitness-owner/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/nonprofit-cause/dev/index.ts +47 -29
- package/templates/nonprofit-cause/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/nonprofit-cause/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-feed/index.ts +3 -1
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-group/index.ts +3 -1
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-place-summary/index.ts +12 -1
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-plans/index.ts +13 -1
- package/templates/nonprofit-cause/tier5-src/himi-branded-lite-wallet/index.ts +3 -1
- package/templates/nonprofit-cause/tier5-src/himi-events-detail/index.ts +8 -1
- package/templates/nonprofit-cause/tier5-src/himi-events-rsvp/index.ts +7 -4
- package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/nonprofit-cause-owner/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/owner-lite/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/owner-lite/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/podcast-creator/dev/index.ts +47 -29
- package/templates/podcast-creator/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/podcast-creator/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/podcast-creator/tier5-src/himi-branded-lite-feed/index.ts +3 -1
- package/templates/podcast-creator/tier5-src/himi-branded-lite-place-summary/index.ts +12 -1
- package/templates/podcast-creator/tier5-src/himi-branded-lite-plans/index.ts +13 -1
- package/templates/podcast-creator/tier5-src/himi-branded-lite-wallet/index.ts +3 -1
- package/templates/podcast-creator/tier5-src/himi-events-detail/index.ts +8 -1
- package/templates/podcast-creator/tier5-src/himi-events-rsvp/index.ts +7 -4
- package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/podcast-creator-owner/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/podcast-creator-owner/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/portfolio-creative/dev/index.ts +52 -27
- package/templates/portfolio-creative/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/portfolio-creative/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-address/index.ts +3 -1
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-addresses/index.ts +3 -1
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-cart/index.ts +3 -0
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-order/index.ts +3 -1
- package/templates/portfolio-creative/tier5-src/himi-branded-lite-wallet/index.ts +3 -1
- package/templates/portfolio-creative/tier5-src/himi-events-detail/index.ts +8 -1
- package/templates/portfolio-creative/tier5-src/himi-events-rsvp/index.ts +7 -4
- package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +10 -4
- package/templates/portfolio-creative-owner/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/portfolio-creative-owner/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/restaurant/dev/index.ts +48 -25
- package/templates/restaurant/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/restaurant/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/restaurant/tier5-src/himi-branded-lite-address/index.ts +3 -1
- package/templates/restaurant/tier5-src/himi-branded-lite-addresses/index.ts +3 -1
- package/templates/restaurant/tier5-src/himi-branded-lite-reserve/index.ts +3 -1
- package/templates/restaurant/tier5-src/himi-branded-lite-wallet/index.ts +3 -1
- package/templates/restaurant/tier5-src/himi-events-detail/index.ts +8 -1
- package/templates/restaurant/tier5-src/himi-events-rsvp/index.ts +7 -4
- package/templates/restaurant/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/restaurant-owner/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/restaurant-owner/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/retail-store/dev/index.ts +44 -23
- package/templates/retail-store/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/retail-store/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/retail-store/tier5-src/himi-branded-lite-address/index.ts +3 -1
- package/templates/retail-store/tier5-src/himi-branded-lite-addresses/index.ts +3 -1
- package/templates/retail-store/tier5-src/himi-branded-lite-cart/index.ts +3 -0
- package/templates/retail-store/tier5-src/himi-branded-lite-order/index.ts +3 -1
- package/templates/retail-store/tier5-src/himi-branded-lite-wallet/index.ts +3 -1
- package/templates/retail-store/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/retail-store/tier5-src/himi-store-product/index.ts +10 -4
- package/templates/retail-store-owner/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/retail-store-owner/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/yoga-studio/dev/index.ts +2102 -811
- package/templates/yoga-studio/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/yoga-studio/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +1 -0
- package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +803 -284
- package/templates/yoga-studio/tier5-src/himi-branded-lite-agenda/index.ts +9 -1
- package/templates/yoga-studio/tier5-src/himi-branded-lite-place-summary/index.ts +12 -1
- package/templates/yoga-studio/tier5-src/himi-branded-lite-plans/index.ts +13 -1
- package/templates/yoga-studio/tier5-src/himi-branded-lite-program/index.ts +3 -1
- package/templates/yoga-studio/tier5-src/himi-branded-lite-wallet/index.ts +3 -1
- package/templates/yoga-studio/tier5-src/himi-events-detail/index.ts +8 -1
- package/templates/yoga-studio/tier5-src/himi-events-rsvp/index.ts +7 -4
- package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +69 -10
- package/templates/yoga-studio-owner/tier5-src/_shared/collection-service.ts +5 -1
- package/templates/yoga-studio-owner/tier5-src/_shared/online-actions.ts +76 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { withOnlineWrites, offlineWritesEnabled, offlineWriteMessage } from "../_shared/online-actions.js";
|
|
2
|
+
import { defineService as registerState } from "@himalaya/state";
|
|
1
3
|
// Tier-5 bundle: himi-store — product detail.
|
|
2
4
|
import { withIapPresentation } from "../_shared/iap-presentation.js";
|
|
3
5
|
import { storesAppleSalesEnabled, storesProductOrders, type IapCommerce, type IapPurchaseFields } from "@himalaya/iap-checkout";
|
|
@@ -459,6 +461,7 @@ const NOT_APPLE: IapPurchaseFields = { appleRoute: false, accessReady: false, bu
|
|
|
459
461
|
let productPricing: IapCommerce;
|
|
460
462
|
let checkoutEntered = false;
|
|
461
463
|
const defineService = withIapPresentation<S>({
|
|
464
|
+
register: withOnlineWrites(registerState, ["beginAdd", "addToCart", "buy"], { derive, messageFields: action => action === "buy" ? ["buyNote"] : ["cartHint"] }),
|
|
462
465
|
adapters: SELLS_THROUGH_APPLE ? [storesProductOrders] : [],
|
|
463
466
|
onCreate: commerce => { productPricing = commerce; }, prefix: "product",
|
|
464
467
|
transientKeys: ["price", "optionsIncomplete", "cartHint", "cartHidden", "buyHidden", "buyLabel", "buyDisabled", "buyNote", "purchasedNote", "addedSheetPresented", "shareHint"], contentActions: ["load", "paintCached"], concurrentPublishActions: ["buy"],
|
|
@@ -467,12 +470,14 @@ const defineService = withIapPresentation<S>({
|
|
|
467
470
|
const purchase = applePurchase(state);
|
|
468
471
|
const unavailable = iapPriceCopy("product").purchaseUnavailable;
|
|
469
472
|
const blocked = lastProduct?.productType?.toLowerCase() === "digital" || (!state.optionsUnknown && !allowed(inputId()));
|
|
470
|
-
const cartHint =
|
|
473
|
+
const cartHint = state.cartHint === offlineWriteMessage ? state.cartHint
|
|
474
|
+
: !purchase.appleRoute && blocked ? unavailable : state.cartHint === unavailable ? "" : state.cartHint;
|
|
471
475
|
return {
|
|
472
476
|
...state, price: price(inputId()), ...(purchase.appleRoute ? { wasPrice: "", wasPriceEmpty: false, notOnSale: true } : {}), optionsIncomplete: derive(state).optionsIncomplete || !allowed(inputId()) || lastProduct?.productType?.toLowerCase() === "digital",
|
|
473
477
|
cartHint, noCartHint: !cartHint || state.added, addDisabled: state.addDisabled || blocked,
|
|
474
478
|
cartHidden: purchase.appleRoute,
|
|
475
|
-
buyHidden: !purchase.appleRoute || purchase.accessReady, buyLabel: purchase.buyLabel, buyDisabled: purchase.buyDisabled,
|
|
479
|
+
buyHidden: !purchase.appleRoute || purchase.accessReady, buyLabel: purchase.buyLabel, buyDisabled: purchase.buyDisabled,
|
|
480
|
+
buyNote: state.buyNote === offlineWriteMessage ? state.buyNote : purchase.buyNote,
|
|
476
481
|
purchasedNote: purchase.accessReady ? copyParam("product.purchasedText", "Purchased") : "",
|
|
477
482
|
};
|
|
478
483
|
},
|
|
@@ -848,11 +853,11 @@ const svc = defineService<S, {
|
|
|
848
853
|
const sale = lastProduct ? productSale(lastProduct) : { wasPrice: "" };
|
|
849
854
|
const swatches = s.optionGroups.flatMap(g => g.kind === "color" ? g.choices.map(c => c.colorCode).filter(Boolean) : []).slice(0, 5);
|
|
850
855
|
const line: DbEntity = { id: variantKey ? `line-${id}-${variantKey}` : `line-${id}`, productId: id, name: s.name || "product", title: s.name || "product", subtitle: chosen ? `${chosen} · Qty ${quantity}` : `Qty ${quantity}`, quantity: String(quantity), image: s.image, unitPrice, wasPrice: sale.wasPrice, swatches, total: optimisticLineTotal(unitPrice, quantity), hasImage: !!s.image, noImage: !s.image };
|
|
851
|
-
await cartPut(line);
|
|
856
|
+
if (!offlineWritesEnabled) await cartPut(line);
|
|
852
857
|
try {
|
|
853
858
|
await addToCurrentCart(id, quantity, cartOptions);
|
|
854
859
|
} catch (e) {
|
|
855
|
-
if (isBridgeUnavailable(e)) {
|
|
860
|
+
if (!offlineWritesEnabled && isBridgeUnavailable(e)) {
|
|
856
861
|
// Offline / no bridge: the optimistic cache line already shows; queue the
|
|
857
862
|
// add to replay (WriteQueue, idempotent) when connectivity returns.
|
|
858
863
|
await queueWrite("tier5.himiStoreProduct.addToCart", { id, ...(cartOptions ? { options: JSON.stringify(cartOptions) } : {}) });
|
|
@@ -861,6 +866,7 @@ const svc = defineService<S, {
|
|
|
861
866
|
// Roll the optimistic badge back — nothing was added.
|
|
862
867
|
return derive({ ...s, adding: false, added: false, cartCount: before, cartHint: copyParam("product.cartHintFailed", "Could not add to cart. Try again.") });
|
|
863
868
|
}
|
|
869
|
+
if (offlineWritesEnabled) await cartPut(line);
|
|
864
870
|
// The write LANDED. The badge re-read is outside the write's try on purpose: a failed
|
|
865
871
|
// count must never be mistaken for a failed add. Server count wins; else keep optimistic.
|
|
866
872
|
const count = await cartItemCount().catch(() => 0);
|
|
@@ -2100,8 +2100,10 @@ const SCREENS = runtimeSetting({
|
|
|
2100
2100
|
"actionId": "himi.open",
|
|
2101
2101
|
"params": {
|
|
2102
2102
|
"screenId": "himi_sign_in",
|
|
2103
|
-
"mode": "signin"
|
|
2104
|
-
|
|
2103
|
+
"mode": "signin",
|
|
2104
|
+
"modal": "1"
|
|
2105
|
+
},
|
|
2106
|
+
"presentation": "sheet"
|
|
2105
2107
|
}
|
|
2106
2108
|
}
|
|
2107
2109
|
}
|
|
@@ -2119,8 +2121,10 @@ const SCREENS = runtimeSetting({
|
|
|
2119
2121
|
"actionId": "himi.open",
|
|
2120
2122
|
"params": {
|
|
2121
2123
|
"screenId": "himi_sign_in",
|
|
2122
|
-
"mode": "register"
|
|
2123
|
-
|
|
2124
|
+
"mode": "register",
|
|
2125
|
+
"modal": "1"
|
|
2126
|
+
},
|
|
2127
|
+
"presentation": "sheet"
|
|
2124
2128
|
}
|
|
2125
2129
|
}
|
|
2126
2130
|
}
|
|
@@ -3077,6 +3081,8 @@ const SCREENS = runtimeSetting({
|
|
|
3077
3081
|
"memberAccountLinks": "1",
|
|
3078
3082
|
"restorePurchases": "1",
|
|
3079
3083
|
"signInScreen": "himi_sign_in",
|
|
3084
|
+
"signInPresentation": "sheet",
|
|
3085
|
+
"signInReturnTab": "profile",
|
|
3080
3086
|
"pollIdentity": "1",
|
|
3081
3087
|
"copy": "{\"account.subtitle\":\"RSVPs, groups and saved content in one place.\",\"storeAccount.authBody\":\"Sign in to continue — RSVPs and groups stay with you.\",\"storeAccount.authBodyRegister\":\"Create a member account to continue — RSVPs and groups stay with you.\"}"
|
|
3082
3088
|
}
|
|
@@ -3332,8 +3338,10 @@ const SCREENS = runtimeSetting({
|
|
|
3332
3338
|
"params": {
|
|
3333
3339
|
"screenId": "himi_sign_in",
|
|
3334
3340
|
"mode": "signin",
|
|
3335
|
-
"returnScreenId": "himi_account_settings"
|
|
3336
|
-
|
|
3341
|
+
"returnScreenId": "himi_account_settings",
|
|
3342
|
+
"modal": "1"
|
|
3343
|
+
},
|
|
3344
|
+
"presentation": "sheet"
|
|
3337
3345
|
}
|
|
3338
3346
|
}
|
|
3339
3347
|
},
|
|
@@ -5243,8 +5251,7 @@ const SCREENS = runtimeSetting({
|
|
|
5243
5251
|
"style": "primary",
|
|
5244
5252
|
"fullWidth": true,
|
|
5245
5253
|
"action": {
|
|
5246
|
-
"actionId": "
|
|
5247
|
-
"presentation": "back"
|
|
5254
|
+
"actionId": "tier5.himiStoreAccount.leave"
|
|
5248
5255
|
}
|
|
5249
5256
|
}
|
|
5250
5257
|
}
|
|
@@ -5285,7 +5292,7 @@ const SCREENS = runtimeSetting({
|
|
|
5285
5292
|
"declaredCapabilities": [
|
|
5286
5293
|
"wix_api"
|
|
5287
5294
|
],
|
|
5288
|
-
"minBinaryVersion": "
|
|
5295
|
+
"minBinaryVersion": "1.7.0",
|
|
5289
5296
|
"bundleVersion": "0.0.1"
|
|
5290
5297
|
}
|
|
5291
5298
|
},
|
|
@@ -6152,8 +6159,10 @@ const SCREENS = runtimeSetting({
|
|
|
6152
6159
|
"screenId": "himi_sign_in",
|
|
6153
6160
|
"mode": "signin",
|
|
6154
6161
|
"intent": "profile",
|
|
6155
|
-
"returnScreenId": "himi_view_profile"
|
|
6156
|
-
|
|
6162
|
+
"returnScreenId": "himi_view_profile",
|
|
6163
|
+
"modal": "1"
|
|
6164
|
+
},
|
|
6165
|
+
"presentation": "sheet"
|
|
6157
6166
|
}
|
|
6158
6167
|
}
|
|
6159
6168
|
}
|
|
@@ -6884,8 +6893,10 @@ const SCREENS = runtimeSetting({
|
|
|
6884
6893
|
"screenId": "himi_sign_in",
|
|
6885
6894
|
"mode": "signin",
|
|
6886
6895
|
"intent": "post",
|
|
6887
|
-
"returnScreenId": "himi_feed"
|
|
6888
|
-
|
|
6896
|
+
"returnScreenId": "himi_feed",
|
|
6897
|
+
"modal": "1"
|
|
6898
|
+
},
|
|
6899
|
+
"presentation": "sheet"
|
|
6889
6900
|
}
|
|
6890
6901
|
}
|
|
6891
6902
|
}
|
|
@@ -7502,8 +7513,10 @@ const SCREENS = runtimeSetting({
|
|
|
7502
7513
|
"screenId": "himi_sign_in",
|
|
7503
7514
|
"mode": "signin",
|
|
7504
7515
|
"intent": "post",
|
|
7505
|
-
"returnScreenId": "himi_create_post"
|
|
7506
|
-
|
|
7516
|
+
"returnScreenId": "himi_create_post",
|
|
7517
|
+
"modal": "1"
|
|
7518
|
+
},
|
|
7519
|
+
"presentation": "sheet"
|
|
7507
7520
|
}
|
|
7508
7521
|
}
|
|
7509
7522
|
}
|
|
@@ -17254,8 +17267,10 @@ const SCREENS = runtimeSetting({
|
|
|
17254
17267
|
"action": {
|
|
17255
17268
|
"actionId": "himi.open",
|
|
17256
17269
|
"params": {
|
|
17257
|
-
"screenId": "himi_sign_in"
|
|
17258
|
-
|
|
17270
|
+
"screenId": "himi_sign_in",
|
|
17271
|
+
"modal": "1"
|
|
17272
|
+
},
|
|
17273
|
+
"presentation": "sheet"
|
|
17259
17274
|
}
|
|
17260
17275
|
}
|
|
17261
17276
|
},
|
|
@@ -20851,8 +20866,10 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
|
|
|
20851
20866
|
"params": {
|
|
20852
20867
|
"screenId": "himi_sign_in",
|
|
20853
20868
|
"mode": "signin",
|
|
20854
|
-
"intent": "rsvp"
|
|
20855
|
-
|
|
20869
|
+
"intent": "rsvp",
|
|
20870
|
+
"modal": "1"
|
|
20871
|
+
},
|
|
20872
|
+
"presentation": "sheet"
|
|
20856
20873
|
}
|
|
20857
20874
|
}
|
|
20858
20875
|
},
|
|
@@ -22184,8 +22201,10 @@ const TEMPLATED: { pattern: string; display: string; liveSeed?: LiveSeed; static
|
|
|
22184
22201
|
"intent": "join_group",
|
|
22185
22202
|
"contextName": "$service:himiBrandedGroup.name",
|
|
22186
22203
|
"returnScreenId": "himi_group",
|
|
22187
|
-
"returnId": "$service:himiBrandedGroup.id"
|
|
22188
|
-
|
|
22204
|
+
"returnId": "$service:himiBrandedGroup.id",
|
|
22205
|
+
"modal": "1"
|
|
22206
|
+
},
|
|
22207
|
+
"presentation": "sheet"
|
|
22189
22208
|
}
|
|
22190
22209
|
}
|
|
22191
22210
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withOnlineWrites } from './online-actions.js';
|
|
1
2
|
import { defineService as register, type ServiceDefinition } from '@himalaya/state';
|
|
2
3
|
import { COLLECTIONS, COLLECTION_CHROME_MIN_ITEMS, initialCollection, normalizeCollection, projectCollection, collectionId, collectionActionsLabel, type CollectionRow } from './collection-contract.js';
|
|
3
4
|
import { localPreferences, type PreferenceRuntime } from './local-preferences.js';
|
|
@@ -331,6 +332,8 @@ export function decorateCollection(name: string, def: { state: State; actions?:
|
|
|
331
332
|
* reducer and reads the private controller snapshot, never an SDUI payload. */
|
|
332
333
|
export function defineBackendCollection<S extends object, Row extends object>(name: string, options: {
|
|
333
334
|
register?: typeof register;
|
|
335
|
+
/** Explicit mutation preflight; unrelated collection services keep their current reducers. */
|
|
336
|
+
onlineWrites?: boolean;
|
|
334
337
|
/** Revalidate already opened pages on navigation return; explicit refresh resets. */
|
|
335
338
|
restorePagesOnLoad?: boolean;
|
|
336
339
|
/** The load action's argument (onAppear params beyond `copy`), before the query runs — for a
|
|
@@ -350,7 +353,8 @@ export function defineBackendCollection<S extends object, Row extends object>(na
|
|
|
350
353
|
controller: controller as unknown as BackendCollection['controller'],
|
|
351
354
|
apply: (state, page) => options.apply(state as S, page as unknown as CollectionQueryState<Row>) as State,
|
|
352
355
|
});
|
|
353
|
-
const
|
|
356
|
+
const registerService = options.onlineWrites ? withOnlineWrites(options.register ?? register, ['confirmCancel', 'confirmOperation', 'retryOperation', 'commitWrite'], { messageFields: ['actionMessage'] }) : (options.register ?? register);
|
|
357
|
+
const handle = registerService(name, definition);
|
|
354
358
|
// Registration restored the state a cold boot saved: the page it showed is this run's, before the first load. Only
|
|
355
359
|
// when the service's own rows came back with it: a bundle that keeps them out of the restore (its `notHydrated`)
|
|
356
360
|
// starts its first load as before, never from rows it chose not to restore. Rows that came back empty are the
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { connectivity, defineService as register, type ServiceDefinition } from '@himalaya/state';
|
|
2
|
+
|
|
3
|
+
// Template generation enables this behavior only in the selected two starter families.
|
|
4
|
+
export const offlineWritesEnabled = false;
|
|
5
|
+
|
|
6
|
+
export const offlineWriteMessage = 'You’re offline. Connect to save this change, then submit it again.';
|
|
7
|
+
|
|
8
|
+
/** The guard runs before the reducer: entered values survive and no optimistic
|
|
9
|
+
* changes, success state, or queued writes can occur. It never submits on reconnect. */
|
|
10
|
+
export function offlineWriteState<S extends object>(state: S): S {
|
|
11
|
+
const next: Record<string, unknown> = { ...state, error: offlineWriteMessage, message: offlineWriteMessage };
|
|
12
|
+
for (const key of ['saving', 'isSaving', 'submitting', 'isSubmitting', 'adding', 'added', 'bookingInFlight']) {
|
|
13
|
+
if (key in next) next[key] = false;
|
|
14
|
+
}
|
|
15
|
+
for (const key of ['savedMessage', 'successMessage']) {
|
|
16
|
+
if (key in next) next[key] = '';
|
|
17
|
+
}
|
|
18
|
+
// A saved/favourited item is business state, not a submission-success flag.
|
|
19
|
+
return next as S;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface OfflineWriteOptions<S> {
|
|
23
|
+
derive?: (state: S) => S;
|
|
24
|
+
/** Exempt only non-mutating branches of a registered action. */
|
|
25
|
+
requiresConnectivity?: (action: string, state: S, argument?: unknown) => boolean;
|
|
26
|
+
messageFields?: readonly string[] | ((action: string) => readonly string[]);
|
|
27
|
+
draftFields?: readonly string[] | Readonly<Record<string, string>>;
|
|
28
|
+
secretFields?: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function withOnlineWrites<S extends object>(registerService: typeof register, names: readonly string[], options: OfflineWriteOptions<S> = {}): typeof register {
|
|
32
|
+
if (!offlineWritesEnabled) return registerService;
|
|
33
|
+
return ((name: string, definition: ServiceDefinition<Record<string, unknown>>) => {
|
|
34
|
+
let currentState: (() => Record<string, unknown>) | undefined;
|
|
35
|
+
const handle = registerService(name, {
|
|
36
|
+
...definition,
|
|
37
|
+
notHydrated: [...new Set([...(definition.notHydrated ?? []), ...(options.secretFields ?? [])])],
|
|
38
|
+
actions: Object.fromEntries(Object.entries(definition.actions ?? {}).map(([action, reduce]) => [action,
|
|
39
|
+
(state: Record<string, unknown>, ...args: never[]) => {
|
|
40
|
+
if (!names.includes(action)) return reduce(state, ...args);
|
|
41
|
+
if (options.requiresConnectivity?.(action, state as S, args[0]) === false) return reduce(state, ...args);
|
|
42
|
+
const fields = typeof options.messageFields === 'function' ? options.messageFields(action) : options.messageFields ?? ['message'];
|
|
43
|
+
if (connectivity().online) {
|
|
44
|
+
let cleared = false;
|
|
45
|
+
for (const field of ['error', 'message', ...fields]) {
|
|
46
|
+
if (state[field] === offlineWriteMessage) { state[field] = ''; cleared = true; }
|
|
47
|
+
}
|
|
48
|
+
// Keep the runtime's state object: reducers may mutate it and return undefined.
|
|
49
|
+
const result = reduce(state, ...args);
|
|
50
|
+
if (!cleared) return result;
|
|
51
|
+
// Publish cleared feedback even for a void reducer. An async completion must
|
|
52
|
+
// keep any newer state published by another action while it was awaiting.
|
|
53
|
+
const finish = (next: Record<string, unknown> | undefined) => next === undefined ? currentState?.() ?? state : next;
|
|
54
|
+
return result && typeof (result as Promise<unknown>).then === 'function'
|
|
55
|
+
? Promise.resolve(result).then(finish)
|
|
56
|
+
: finish(result as Record<string, unknown> | undefined);
|
|
57
|
+
}
|
|
58
|
+
const draft = { ...state };
|
|
59
|
+
const argument = args[0] as Record<string, unknown> | undefined;
|
|
60
|
+
const draftFields = options.draftFields ?? [];
|
|
61
|
+
const entries = Array.isArray(draftFields) ? draftFields.map(key => [key, key]) : Object.entries(draftFields);
|
|
62
|
+
for (const [key, source] of entries) {
|
|
63
|
+
if (argument && key in state && typeof argument[source] === typeof state[key]) draft[key] = argument[source];
|
|
64
|
+
}
|
|
65
|
+
for (const key of options.secretFields ?? []) draft[key] = '';
|
|
66
|
+
const feedback = Object.fromEntries(fields.map(key => [key, offlineWriteMessage]));
|
|
67
|
+
let next = { ...offlineWriteState(draft), ...feedback };
|
|
68
|
+
if (options.derive) next = options.derive(next as S) as Record<string, unknown>;
|
|
69
|
+
return { ...next, ...feedback };
|
|
70
|
+
},
|
|
71
|
+
])),
|
|
72
|
+
});
|
|
73
|
+
if (typeof handle.getState === 'function') currentState = () => handle.getState();
|
|
74
|
+
return handle;
|
|
75
|
+
}) as typeof register;
|
|
76
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withOnlineWrites } from "../_shared/online-actions.js";
|
|
1
2
|
// Tier-5 bundle: himi-branded-lite — community activity feed (design §4.5).
|
|
2
3
|
//
|
|
3
4
|
// The feed rides the Wix Groups social feed: a feed item lives in a group
|
|
@@ -9,7 +10,7 @@
|
|
|
9
10
|
// worker's signed-in flags (the himi_group join-button pattern) and the
|
|
10
11
|
// sign-in card routes to himi_account — never a dead tap.
|
|
11
12
|
// Four-state (loading / error / rows / empty) like the sibling branded workers.
|
|
12
|
-
import { defineService } from "@himalaya/state";
|
|
13
|
+
import { defineService as registerService } from "@himalaya/state";
|
|
13
14
|
import {
|
|
14
15
|
createFeedItem,
|
|
15
16
|
listFeedItems,
|
|
@@ -301,6 +302,7 @@ async function loadFeed(state: State): Promise<State> {
|
|
|
301
302
|
}
|
|
302
303
|
}
|
|
303
304
|
|
|
305
|
+
const defineService = withOnlineWrites(registerService, ["post", "react"], { derive, draftFields: { draft: "message" } });
|
|
304
306
|
const svc = defineService<State, {
|
|
305
307
|
load: (state: State, arg?: unknown) => Promise<State>;
|
|
306
308
|
filter: (state: State, arg?: unknown) => State;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withOnlineWrites } from "../_shared/online-actions.js";
|
|
2
|
+
import { defineService as registerService } from "@himalaya/state";
|
|
2
3
|
import { getGroup, joinGroup, leaveGroup, queryMembers as queryGroupMembers, type WixGroup } from "@himalaya/wix-groups";
|
|
3
4
|
import { getMember } from "@himalaya/wix-members";
|
|
4
5
|
import { signedInEmail } from "../_shared/himi-account";
|
|
@@ -159,6 +160,7 @@ const initial: State = {
|
|
|
159
160
|
hideContent: true,
|
|
160
161
|
};
|
|
161
162
|
|
|
163
|
+
const defineService = withOnlineWrites(registerService, ["join","leave"]);
|
|
162
164
|
const svc = defineService<State, {
|
|
163
165
|
load: (state: State, arg?: unknown) => Promise<State>;
|
|
164
166
|
join: (state: State) => Promise<State>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Tier-5 bundle: himi-events — event detail.
|
|
2
2
|
import { formatCurrency } from "../_shared/engine-intl.js";
|
|
3
|
-
import { defineService } from "@himalaya/state";
|
|
3
|
+
import { defineService as registerService } from "@himalaya/state";
|
|
4
|
+
import { withOnlineWrites } from "../_shared/online-actions.js";
|
|
4
5
|
import { createEvent, getPermissionStatus, requestPermission } from "@himalaya/calendar";
|
|
5
6
|
import { open } from "@himalaya/open-url";
|
|
6
7
|
import { share as shareSheet } from "@himalaya/share";
|
|
@@ -431,6 +432,12 @@ async function enrichRegistration(id: string, e: WixEvent): Promise<WixEvent> {
|
|
|
431
432
|
}
|
|
432
433
|
}
|
|
433
434
|
|
|
435
|
+
const defineService = withOnlineWrites(registerService, ["buyApple", "openRegistration"], {
|
|
436
|
+
derive,
|
|
437
|
+
messageFields: ["actionMessage"],
|
|
438
|
+
requiresConnectivity: (action, state) => action !== "openRegistration"
|
|
439
|
+
|| (state.registrationKind === "tickets" && !!state.id && !isHostedWorker()),
|
|
440
|
+
});
|
|
434
441
|
const svc = defineService<S, {
|
|
435
442
|
load: (s: S, arg?: unknown) => Promise<S | undefined>;
|
|
436
443
|
openMap: (s: S) => Promise<S>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { withOnlineWrites, offlineWritesEnabled } from "../_shared/online-actions.js";
|
|
1
2
|
// Tier-5 bundle: himi-events — member RSVP flow.
|
|
2
|
-
import { defineService } from "@himalaya/state";
|
|
3
|
+
import { defineService as registerService } from "@himalaya/state";
|
|
3
4
|
import { dispatch } from "@himalaya/dispatch";
|
|
4
5
|
import { createRsvp, getEvent, type WixEvent } from "@himalaya/wix-events";
|
|
5
6
|
import { displayName, getMyData, type WixMyData } from "@himalaya/wix-users";
|
|
@@ -125,6 +126,7 @@ function contactName(dataLine: string): { first: string; last: string } {
|
|
|
125
126
|
return { first: parts[0], last: parts.slice(1).join(" ") };
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
const defineService = withOnlineWrites(registerService, ["rsvp", "signIn"], { derive, secretFields: ["password"] });
|
|
128
130
|
const svc = defineService<S, {
|
|
129
131
|
load: (s: S, arg?: unknown) => Promise<S>;
|
|
130
132
|
setEmail: (s: S, arg?: unknown) => S;
|
|
@@ -202,16 +204,17 @@ const svc = defineService<S, {
|
|
|
202
204
|
// Optimistic local write — the RSVP row lands in the cache before the Wix POST.
|
|
203
205
|
const rsvpRow = (id: string): DbEntity => ({ id, eventId: s.id, firstName: name.first, lastName: name.last, email: guestEmail, status: "YES", title: s.title });
|
|
204
206
|
const localId = s.id;
|
|
205
|
-
await cachePut(rsvpRow(localId));
|
|
207
|
+
if (!offlineWritesEnabled) await cachePut(rsvpRow(localId));
|
|
206
208
|
try {
|
|
207
209
|
const res = await createRsvp(s.id, name.first, name.last, guestEmail, "YES");
|
|
208
210
|
// Reconcile the optimistic local id with the server-assigned rsvp id.
|
|
209
211
|
const serverId = res.rsvp?.id;
|
|
210
|
-
if (
|
|
212
|
+
if (offlineWritesEnabled) await cachePut(rsvpRow(serverId || localId));
|
|
213
|
+
else if (serverId && serverId !== localId) { await cacheDrop(localId); await cachePut(rsvpRow(serverId)); }
|
|
211
214
|
rememberRsvp(s.id);
|
|
212
215
|
return derive({ ...s, successMessage: copyParam("rsvp.successMessage", "You are going. Added to My Events."), message: "" });
|
|
213
216
|
} catch (e) {
|
|
214
|
-
if (isBridgeUnavailable(e)) {
|
|
217
|
+
if (!offlineWritesEnabled && isBridgeUnavailable(e)) {
|
|
215
218
|
// Offline / no bridge: the optimistic cache row already shows; queue the
|
|
216
219
|
// write to replay (WriteQueue, idempotent) when connectivity returns.
|
|
217
220
|
await queueWrite("tier5.himiEventsRsvp.rsvp", { id: s.id, firstName: name.first, lastName: name.last, email: guestEmail, status: "YES" });
|
|
@@ -26,6 +26,10 @@ interface AuthRouteInput {
|
|
|
26
26
|
returnScreenId?: string;
|
|
27
27
|
returnId?: string;
|
|
28
28
|
returnChannelId?: string;
|
|
29
|
+
/** Standalone sign-in only: "1" when it was opened as a modal (sheet / cover). */
|
|
30
|
+
modal?: string;
|
|
31
|
+
/** Modal only: the tab whose stack the return screen opens on once the modal closes. */
|
|
32
|
+
returnTab?: string;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
// The screen's boot input survives refresh; consuming it must survive too.
|
|
@@ -61,6 +65,12 @@ function authIntentFromArg(arg: unknown, prev: Pick<S, "authIntent" | "authConte
|
|
|
61
65
|
};
|
|
62
66
|
}
|
|
63
67
|
|
|
68
|
+
/** How the standalone form leaves. A modal is closed: on web `back` pops the tab's stack,
|
|
69
|
+
* not the modal. A pushed form goes back. */
|
|
70
|
+
function leaveNav(): "dismiss" | "back" {
|
|
71
|
+
return routeInput().modal === "1" ? "dismiss" : "back";
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
/** Where a successful sign-in returns to, or null. Never Account itself — that would
|
|
65
75
|
* only push a second copy of the screen the member is already on. */
|
|
66
76
|
function resumeTarget(s: Pick<S, "returnScreenId" | "returnId" | "returnChannelId">): { screenId: string; args?: Record<string, string> } | null {
|
|
@@ -78,11 +88,26 @@ function resumeTarget(s: Pick<S, "returnScreenId" | "returnId" | "returnChannelI
|
|
|
78
88
|
* On the standalone sign-in screen the target is pushed, not a `replace`: on iOS and
|
|
79
89
|
* Android `replace` resets the stack to its root, which would drop the screens the
|
|
80
90
|
* visitor came through. Back from the target shows the form again, and the form sends a
|
|
81
|
-
* member back on appear (settle). With no target the form goes back.
|
|
91
|
+
* member back on appear (settle). With no target the form goes back.
|
|
92
|
+
*
|
|
93
|
+
* A modal form closes. A target pushed from here would open inside the modal (iOS, Android)
|
|
94
|
+
* or under it (web), so a modal that names a `returnTab` hands the target to that tab: the
|
|
95
|
+
* host closes the modal, then pushes it on that tab's stack (Account's member rows). A host
|
|
96
|
+
* showing no such tab (a drawer, a narrow Mac window) drops that request whole, modal and
|
|
97
|
+
* all, so the modal is also dismissed directly: it always closes, and the row opens where
|
|
98
|
+
* the tab exists. With no `returnTab` it only closes, and the screen under it loads again —
|
|
99
|
+
* the screen that opened the modal is the return target. */
|
|
82
100
|
function resumeAfterAuth(next: S): S {
|
|
83
101
|
const target = resumeTarget(next);
|
|
84
102
|
if (!next.isMember) return next;
|
|
85
|
-
|
|
103
|
+
const tab = routeInput().modal === "1" ? routeInput().returnTab ?? "" : "";
|
|
104
|
+
if (target && tab && next.standalone) {
|
|
105
|
+
routeInputConsumed = true;
|
|
106
|
+
void dispatch("himi.open", { presentation: "dismiss" });
|
|
107
|
+
const cleared = derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "", returnChannelId: "" });
|
|
108
|
+
return navigate(cleared, target.args ? { tab, screenId: target.screenId, args: target.args } : { tab, screenId: target.screenId });
|
|
109
|
+
}
|
|
110
|
+
if (!target || routeInput().modal === "1") return next.standalone ? navigate(next, { presentation: leaveNav() }) : next;
|
|
86
111
|
routeInputConsumed = true;
|
|
87
112
|
const cleared = derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "", returnChannelId: "" });
|
|
88
113
|
return navigate(cleared, target);
|
|
@@ -96,11 +121,31 @@ function forwardToSignIn(next: S): S {
|
|
|
96
121
|
if (!next.authIntent && !next.returnScreenId) return next;
|
|
97
122
|
routeInputConsumed = true;
|
|
98
123
|
const args: Record<string, string> = { mode: "signin" };
|
|
99
|
-
for (const key of ["authIntent", "authContextName"
|
|
100
|
-
if (next[key]) args[key === "authIntent" ? "intent" :
|
|
124
|
+
for (const key of ["authIntent", "authContextName"] as const) {
|
|
125
|
+
if (next[key]) args[key === "authIntent" ? "intent" : "contextName"] = next[key];
|
|
126
|
+
}
|
|
127
|
+
return openSignIn(derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "", returnChannelId: "" }),
|
|
128
|
+
args, resumeTarget(next));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Account sends a guest to the standalone sign-in screen, with `after`, the member screen to
|
|
132
|
+
* open once signed in. With a `signInPresentation` appear param it opens as that modal, and
|
|
133
|
+
* `after` goes on Account's own tab (`signInReturnTab`) when the modal closes; pushed, the form
|
|
134
|
+
* pushes `after` itself (resumeAfterAuth). */
|
|
135
|
+
function openSignIn(next: S, args: Record<string, string>, after: { screenId: string; args?: Record<string, string> } | null): S {
|
|
136
|
+
const screenId = next.signInScreen || "himi_sign_in";
|
|
137
|
+
const presentation = signInPresentationRequested;
|
|
138
|
+
const back: Record<string, string> = {};
|
|
139
|
+
if (after) {
|
|
140
|
+
back.returnScreenId = after.screenId;
|
|
141
|
+
if (after.args?.id) back.returnId = after.args.id;
|
|
142
|
+
if (after.args?.channelId) back.returnChannelId = after.args.channelId;
|
|
101
143
|
}
|
|
102
|
-
return navigate(
|
|
103
|
-
|
|
144
|
+
if (!presentation) return navigate(next, { screenId, args: { ...args, ...back } });
|
|
145
|
+
const modalArgs: Record<string, string> = { ...args, modal: "1" };
|
|
146
|
+
// With no tab to open it on, a modal has no way to the member screen: it only closes.
|
|
147
|
+
if (after && signInReturnTabRequested) Object.assign(modalArgs, back, { returnTab: signInReturnTabRequested });
|
|
148
|
+
return navigate(next, { screenId, presentation, args: modalArgs });
|
|
104
149
|
}
|
|
105
150
|
|
|
106
151
|
/** After a load: the standalone sign-in screen sends a member back (a stale link, or a
|
|
@@ -128,8 +173,11 @@ function settle(next: S, arg: unknown, latest = true): S {
|
|
|
128
173
|
// The appear refresh returns `_nav`, which every host applies — binaries from before
|
|
129
174
|
// worker nav dispatch included. Only an arg-less load, whose result iOS
|
|
130
175
|
// discards, dispatches.
|
|
131
|
-
if (strField(arg, "standalone") === "1") return navigate(cleared, { presentation:
|
|
132
|
-
|
|
176
|
+
if (strField(arg, "standalone") === "1") return navigate(cleared, { presentation: leaveNav() });
|
|
177
|
+
// Not from a modal: nothing pushed over it comes back to it, and on iOS the closing modal's
|
|
178
|
+
// own screen reloads here once, after it has asked to close — a late dismiss would close
|
|
179
|
+
// whatever modal is open by then.
|
|
180
|
+
if (routeInput().modal !== "1") void dispatch("himi.open", { presentation: leaveNav() });
|
|
133
181
|
return cleared;
|
|
134
182
|
}
|
|
135
183
|
// Account forwards only on an appear refresh: the boot `load()` has no params and its
|
|
@@ -180,6 +228,10 @@ let appliedSeq = 0;
|
|
|
180
228
|
// The appear params belong to the worker session too, like the two flags above: a probe
|
|
181
229
|
// dropped because the visitor typed must not take them with it.
|
|
182
230
|
let signInScreenRequested = "";
|
|
231
|
+
/** Account only: how it opens the standalone sign-in screen ("" = push). */
|
|
232
|
+
let signInPresentationRequested: "" | "sheet" | "full_screen" = "";
|
|
233
|
+
/** Account only: its tab, where a member screen opens after a modal sign-in. */
|
|
234
|
+
let signInReturnTabRequested = "";
|
|
183
235
|
let standaloneRequested = false;
|
|
184
236
|
let pollIdentityRequested = false;
|
|
185
237
|
// Bumped by every mode switch, so a dropped probe never puts back a mode the visitor left.
|
|
@@ -210,6 +262,9 @@ function appearConfig(s: S, arg: unknown): AppearConfig {
|
|
|
210
262
|
passwordDraft = "";
|
|
211
263
|
}
|
|
212
264
|
signInScreenRequested ||= strField(arg, "signInScreen") || s.signInScreen;
|
|
265
|
+
const presentation = strField(arg, "signInPresentation");
|
|
266
|
+
if (presentation === "sheet" || presentation === "full_screen") signInPresentationRequested = presentation;
|
|
267
|
+
signInReturnTabRequested ||= strField(arg, "signInReturnTab");
|
|
213
268
|
// Only the sign-in screen's route carries `mode`, so it marks the form from the boot load on.
|
|
214
269
|
standaloneRequested ||= s.standalone || appearing || (!routeInputConsumed && !!routeInput().mode);
|
|
215
270
|
pollIdentityRequested ||= s.pollIdentity || strField(arg, "pollIdentity") === "1";
|
|
@@ -676,6 +731,7 @@ const svc = defineService<S, {
|
|
|
676
731
|
signOut: (s: S) => Promise<S>;
|
|
677
732
|
sync: (s: S) => Promise<S | undefined>;
|
|
678
733
|
openMember: (s: S, arg?: unknown) => Promise<S>;
|
|
734
|
+
leave: (s: S) => S;
|
|
679
735
|
restorePublish: (s: S) => S;
|
|
680
736
|
iapRestore: (s: S) => Promise<undefined>;
|
|
681
737
|
}>("himiStoreAccount", {
|
|
@@ -756,7 +812,8 @@ const svc = defineService<S, {
|
|
|
756
812
|
return "next" in r ? r.next : undefined;
|
|
757
813
|
},
|
|
758
814
|
// A row to a member-only screen shows to a guest too. A member opens it; a guest signs
|
|
759
|
-
// in first and the sign-in screen
|
|
815
|
+
// in first, and the sign-in screen then opens the row's screen — as a modal, by closing
|
|
816
|
+
// and pushing it on this tab (openSignIn) — so Back returns here either way.
|
|
760
817
|
openMember: async (s, arg): Promise<S> => {
|
|
761
818
|
const screenId = strField(arg, "screenId");
|
|
762
819
|
if (!screenId) return s;
|
|
@@ -764,8 +821,10 @@ const svc = defineService<S, {
|
|
|
764
821
|
// From the state as it is now: a probe may have landed during the identity read.
|
|
765
822
|
const now = svc.getState();
|
|
766
823
|
if (member) return navigate(now, { screenId });
|
|
767
|
-
return
|
|
824
|
+
return openSignIn(now, { mode: "signin" }, { screenId });
|
|
768
825
|
},
|
|
826
|
+
// The standalone form's Continue: leaves the form the way it was opened.
|
|
827
|
+
leave: (s) => navigate(s, { presentation: leaveNav() }),
|
|
769
828
|
// Typing means any focus request was delivered: clear the tokens (safe while mounted, since
|
|
770
829
|
// bumpToken never repeats), so a visit rarely ends — and a pooled form rarely reopens —
|
|
771
830
|
// holding one.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withOnlineWrites } from './online-actions.js';
|
|
1
2
|
import { defineService as register, type ServiceDefinition } from '@himalaya/state';
|
|
2
3
|
import { COLLECTIONS, COLLECTION_CHROME_MIN_ITEMS, initialCollection, normalizeCollection, projectCollection, collectionId, collectionActionsLabel, type CollectionRow } from './collection-contract.js';
|
|
3
4
|
import { localPreferences, type PreferenceRuntime } from './local-preferences.js';
|
|
@@ -331,6 +332,8 @@ export function decorateCollection(name: string, def: { state: State; actions?:
|
|
|
331
332
|
* reducer and reads the private controller snapshot, never an SDUI payload. */
|
|
332
333
|
export function defineBackendCollection<S extends object, Row extends object>(name: string, options: {
|
|
333
334
|
register?: typeof register;
|
|
335
|
+
/** Explicit mutation preflight; unrelated collection services keep their current reducers. */
|
|
336
|
+
onlineWrites?: boolean;
|
|
334
337
|
/** Revalidate already opened pages on navigation return; explicit refresh resets. */
|
|
335
338
|
restorePagesOnLoad?: boolean;
|
|
336
339
|
/** The load action's argument (onAppear params beyond `copy`), before the query runs — for a
|
|
@@ -350,7 +353,8 @@ export function defineBackendCollection<S extends object, Row extends object>(na
|
|
|
350
353
|
controller: controller as unknown as BackendCollection['controller'],
|
|
351
354
|
apply: (state, page) => options.apply(state as S, page as unknown as CollectionQueryState<Row>) as State,
|
|
352
355
|
});
|
|
353
|
-
const
|
|
356
|
+
const registerService = options.onlineWrites ? withOnlineWrites(options.register ?? register, ['confirmCancel', 'confirmOperation', 'retryOperation', 'commitWrite'], { messageFields: ['actionMessage'] }) : (options.register ?? register);
|
|
357
|
+
const handle = registerService(name, definition);
|
|
354
358
|
// Registration restored the state a cold boot saved: the page it showed is this run's, before the first load. Only
|
|
355
359
|
// when the service's own rows came back with it: a bundle that keeps them out of the restore (its `notHydrated`)
|
|
356
360
|
// starts its first load as before, never from rows it chose not to restore. Rows that came back empty are the
|