@zappie/foundations 0.19.0 → 0.21.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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @zappie/foundations
2
2
 
3
+ ## 0.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bc9580f: `@zappie/sdk/server` holds the server side every site repeats. `pageCacheRules({ menu })` returns the page cache rules and headers for the pages you name. `siteWorker` is the whole site Worker: the closed page, an early redirect, the edge page cache and the error page. `robotsResponse` and `sitemapResponse` answer robots and the sitemap, `allMenus` reads each branch's menu for it, `storeRedirect` reads the merchant's own redirects, `originFetch` names the shopper's origin on each API call, and `legacyRedirects({ business })` moves the classic storefront's addresses onto your site.
8
+
9
+ `@zappie/foundations/site/server` holds what needs React Router: `siteContext`, `createServerClient`, `siteEnv`, `siteMode`, `isPreview`, `requestOrigin`, `documentHandler` (the whole of `entry.server.tsx`) and `closedPageData`. `@zappie/foundations/site` has `PageViews`, `useAtTable`, `IN_VENUE_HANDLE`, `pageTitle` and `isClosedPage`. `@zappie/foundations/site/customer` has `CustomerGate` and `useCheckoutReturn`.
10
+
11
+ The starter's cache rules, server client, `entry.server.tsx`, Worker, robots, sitemap, customer gate, checkout return and page views use them, and its copies are gone.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [bc9580f]
16
+ - @zappie/sdk@0.20.0
17
+
18
+ ## 0.20.0
19
+
20
+ ### Minor Changes
21
+
22
+ - 4102e33: `@zappie/foundations/hours` puts a branch's hours into words, in the branch's own time zone, then the store's, then Africa/Lagos. `openStatus` and `useOpenStatus` say whether it is open, closing soon or when it opens next. `opensLabel` and `nextOpening` read the API's next opening and fall back to the hours. `closedForOrders` and `takesOrdersAhead` say whether it takes an order now or for later. `openingHours` groups a week from Sunday, Monday or today, and `branchHours` gives a branch card its status, today's hours and its week. Every label takes your clock style, weekday names and words. `useNow` is the shopper's clock once the page is in the browser.
23
+
24
+ The starter's Our branches page shows each branch's status, whether it takes orders while closed and its week from today.
25
+
3
26
  ## 0.19.0
4
27
 
5
28
  ### Minor Changes
package/README.md CHANGED
@@ -31,20 +31,24 @@ Want ready-made, styled components instead? Copy them into your project from the
31
31
 
32
32
  ## Entry points
33
33
 
34
- | Import | For |
35
- | ----------------------------------- | ----------------------------------------------------------------------- |
36
- | `@zappie/foundations` | Every part |
37
- | `@zappie/foundations/next` | Keeping overlays in step with Back and Forward in a Next.js app |
38
- | `@zappie/foundations/branch-switch` | Choosing a branch in a React Router site without waiting for the server |
39
- | `@zappie/foundations/branch-finder` | Opening the site's branch picker or locator from any control |
40
- | `@zappie/foundations/branch-list` | Nearest-first branch lists and what each branch sells |
41
- | `@zappie/foundations/checkout` | Checkout behaviour for a bag or a cart page, with no markup |
42
- | `@zappie/foundations/loyalty` | The rewards sheet's parts, the bag's rewards row and the claim toast |
43
- | `@zappie/foundations/order` | A customer's order details page, as parts or one default layout |
44
- | `@zappie/foundations/item-sheet` | A product sheet over the current page in a React Router site |
45
- | `@zappie/foundations/bag` | The bag over the page, its address and the "added" notice |
46
- | `@zappie/foundations/bag/server` | The `/cart` and `/checkout` redirects that open the bag |
47
- | `@zappie/foundations/rich-text` | Sanitising and parsing merchant rich text before you render it |
34
+ | Import | For |
35
+ | ----------------------------------- | ---------------------------------------------------------------------------------------- |
36
+ | `@zappie/foundations` | Every part |
37
+ | `@zappie/foundations/next` | Keeping overlays in step with Back and Forward in a Next.js app |
38
+ | `@zappie/foundations/branch-switch` | Choosing a branch in a React Router site without waiting for the server |
39
+ | `@zappie/foundations/branch-finder` | Opening the site's branch picker or locator from any control |
40
+ | `@zappie/foundations/branch-list` | Nearest-first branch lists and what each branch sells |
41
+ | `@zappie/foundations/hours` | Open now, opening labels, closed for orders and a week of hours |
42
+ | `@zappie/foundations/checkout` | Checkout behaviour for a bag or a cart page, with no markup |
43
+ | `@zappie/foundations/loyalty` | The rewards sheet's parts, the bag's rewards row and the claim toast |
44
+ | `@zappie/foundations/order` | A customer's order details page, as parts or one default layout |
45
+ | `@zappie/foundations/item-sheet` | A product sheet over the current page in a React Router site |
46
+ | `@zappie/foundations/bag` | The bag over the page, its address and the "added" notice |
47
+ | `@zappie/foundations/bag/server` | The `/cart` and `/checkout` redirects that open the bag |
48
+ | `@zappie/foundations/site` | Page views, the table page check, page titles and the closed page's data type |
49
+ | `@zappie/foundations/site/customer` | The signed-in pages' gate and the checkout return page's state |
50
+ | `@zappie/foundations/site/server` | A React Router site's load context, server client, document handler and closed page data |
51
+ | `@zappie/foundations/rich-text` | Sanitising and parsing merchant rich text before you render it |
48
52
 
49
53
  ## Docs
50
54
 
@@ -650,6 +654,71 @@ const offers = useBranchOffers(store.branches, { active: open });
650
654
  - `menusLabel(names)` joins the names with " · ", and reads "Breakfast only"
651
655
  for one.
652
656
 
657
+ ## Hours
658
+
659
+ `@zappie/foundations/hours` puts a branch's hours into words: open now and
660
+ closing soon, when it opens next, whether it takes orders, a week of hours and
661
+ a branch card's hours. It reads each branch in its own time zone, then the
662
+ store's (`storeTimezone`), then Africa/Lagos. It loads only on the pages that
663
+ use it.
664
+
665
+ ```tsx
666
+ import {
667
+ closedForOrders,
668
+ opensLabel,
669
+ useBranchHours,
670
+ useOpenStatus,
671
+ } from "@zappie/foundations/hours";
672
+
673
+ const status = useOpenStatus(branch, { storeTimezone: store.timezone });
674
+ // undefined on the server, then { isOpen, closingSoon, closedForOrders, label: "Open until 10 pm", ... }
675
+ const hours = useBranchHours(branch, { storeTimezone: store.timezone });
676
+ {
677
+ hours?.week.map((row) => (
678
+ <div key={row.dayLabel} aria-current={row.today && "date"}>
679
+ <dt>{row.dayLabel}</dt>
680
+ <dd>{row.hoursLabel}</dd>
681
+ </div>
682
+ ));
683
+ }
684
+ opensLabel(branch, { clock: { hour12: false } }); // "Opens tomorrow at 7:00"
685
+ closedForOrders(branch); // closed, and not taking orders for later
686
+ ```
687
+
688
+ - `openStatus(branch, options)` works out the state at `now` from the weekly
689
+ hours, special hours, overnight hours and `closedUntil`. Its label reads
690
+ "Open until 10 pm", "Closes at 10 pm" within `closingSoonMinutes` (30 by
691
+ default), "Opens at 8 am", "Opens tomorrow at 8 am", "Opens Mon at 8 am" or
692
+ "Closed". `closedForOrders` is true when it is closed and takes no orders
693
+ ahead.
694
+ - `opensLabel(branch, options)` and `nextOpening(branch, options)` give when a
695
+ closed branch opens next. `from: "api"`, the default, reads `isOpen`,
696
+ `closedUntil` and `nextChangeAt`, and falls back to the hours when no
697
+ opening is still ahead; `from: "hours"` reads only the hours. Today and
698
+ tomorrow are the branch's local dates.
699
+ - Every label takes `clock` (`hour12`, `padHour`, `minutes`, `period`,
700
+ `space`, `roundLastMinute`), `weekday` (`short` or `long`) and `phrases`,
701
+ whose `{time}` and `{weekday}` fill in: `{ today: "Opens today {time}" }`.
702
+ `formatClock(time, clock)` formats one wall-clock time.
703
+ - `closedForOrders(branch, { lastOrderMinutes? })` is the API's closed and no
704
+ orders ahead. With `lastOrderMinutes`, an open branch that closes within
705
+ them takes no order either, unless it takes orders ahead.
706
+ `takesOrdersAhead(branch, menu, menuIds)` says whether a bag can be timed
707
+ for later, by the branch or a pre-order menu.
708
+ - `openingHours(times, options)` groups a week into runs of days that share
709
+ their hours, from `start` (`sunday`, `monday` or `today`). `closed` names
710
+ the closed days, `everyDay` collapses a week of the same hours, `allDay`
711
+ names midnight to midnight, `today` marks its row, and `dayNames`, `range`
712
+ and `through` set the words.
713
+ - `branchHours(branch, options)` is a branch card's hours: its `status`,
714
+ `today`'s hours with special hours, and its `week` from today.
715
+ - `useNow()` is the time once the page is idle in the browser, then each
716
+ minute and on focus; undefined on the server. `useOpenStatus` and
717
+ `useBranchHours` run on it, so the server's HTML never disagrees with the
718
+ first render.
719
+
720
+ `src/hours/ADOPTING.md` maps each site's own copies onto these.
721
+
653
722
  ## Item form focus
654
723
 
655
724
  When an add fails validation, `ItemForm.Root` focuses the first invalid group
@@ -772,3 +841,54 @@ is the themed dot. Like `BranchMap`, it renders nothing without a key, loads
772
841
  Maps after mount, calls `onLoadError(error)` on a failure and shows “Map location
773
842
  unavailable” when either point has no valid coordinates. It fits again when the
774
843
  points, the route or its size change.
844
+
845
+ ## Site plumbing
846
+
847
+ Every React Router site runs the same plumbing around its own pages. These parts hold it, so a site keeps only its
848
+ choices and its markup. The framework-free pieces (the page cache rules, the Worker, robots, the sitemap and the old
849
+ address redirects) are in `@zappie/sdk/server`.
850
+
851
+ `@zappie/foundations/site/server` runs on the server only:
852
+
853
+ - `siteContext(env, ctx)` is the load context for React Router's request handler. `envContext` and `edgeContext`
854
+ read it back.
855
+ - `createServerClient({ store, branch })` returns the site's `serverClient(context, request)`: one Zappie client per
856
+ request, `{ client, env, origin }`. It reads the store and its menus through the Worker's edge cache, except for a
857
+ draft, a review or `ZAPPIE_EDGE_CACHE=off`. `siteEnv`, `siteMode`, `isPreview` and `requestOrigin` are there for
858
+ your own loaders.
859
+ - `documentHandler({ config, cache, isBot })` is the whole of `app/entry.server.tsx`: a CSP nonce, Zappie's security
860
+ headers, and cache headers from your `pageCacheRules`. Pass `page` when your root's data isn't the usual
861
+ `{ mode, menu, store }`.
862
+ - `closedPageData(store, closed)` is what your closed page shows, formatted on the server. `branches`, `hours` and
863
+ `title` change the order, the hours and the title.
864
+
865
+ `@zappie/foundations/site` runs on both sides:
866
+
867
+ - `<PageViews storeName enabled />` counts a visit for each page, and skips the bag's `?bag=open` address.
868
+ - `useAtTable()` is true on a route whose `handle` is `IN_VENUE_HANDLE`.
869
+ - `pageTitle(store, page)` titles a page in the store's own pattern.
870
+ - `isClosedPage(data)` tells the closed page's data from the shop's.
871
+
872
+ `@zappie/foundations/site/customer` is for the customer's pages:
873
+
874
+ - `<CustomerGate returnTo>` signs a shopper in once, then renders your page with the customer client. Pass
875
+ `checking` and `signedOut` for your own markup.
876
+ - `useCheckoutReturn()` waits for the payment on `/checkout/return`, then clears the cart and opens the order. It
877
+ returns `{ state, title, body }`, and you draw the page.
878
+
879
+ ```tsx
880
+ // app/entry.server.tsx
881
+ export default documentHandler({
882
+ config: siteConfig,
883
+ cache: pageCache,
884
+ isBot: isbot,
885
+ });
886
+
887
+ // app/server.ts
888
+ export const serverClient = createServerClient({ store: "my-shop" });
889
+
890
+ // app/routes/orders.tsx
891
+ <CustomerGate returnTo="/orders" className="status-page">
892
+ {(customer) => <Orders customer={customer} />}
893
+ </CustomerGate>;
894
+ ```
@@ -0,0 +1,237 @@
1
+ import { OpeningTime, Branch, Menu } from '@zappie/sdk';
2
+
3
+ /** A day of the week, Sunday 0 to Saturday 6, as `OpeningTime.day` counts it. */
4
+ type Weekday = OpeningTime["day"];
5
+ /** The time zone for a branch and a store that name none. */
6
+ declare const DEFAULT_TIMEZONE = "Africa/Lagos";
7
+ /**
8
+ * The time zone a branch's hours are kept in: its own, then the store's, then Africa/Lagos.
9
+ *
10
+ * @param storeTimezone - The store's time zone, for a branch that names none.
11
+ */
12
+ declare function branchTimezone(branch: Pick<Branch, "timezone">, storeTimezone?: string): string;
13
+ /** The weekday it is at `now` in `timezone`. */
14
+ declare function todayIn(timezone: string, now?: Date): Weekday;
15
+ /**
16
+ * How a time reads. The default is a 12-hour clock in lower case with a space, minutes only when they aren't
17
+ * zero: "9 am", "7:30 pm".
18
+ */
19
+ type ClockStyle = {
20
+ /** A 12-hour clock with am and pm. Defaults to true. A 24-hour clock always shows its minutes: "7:00", "19:30". */
21
+ hour12?: boolean | undefined;
22
+ /** Pad the hour to two digits: "09:00 AM". Defaults to false. */
23
+ padHour?: boolean | undefined;
24
+ /** `auto` drops zero minutes ("9 am"), `always` keeps them ("9:00 am"). Defaults to `auto`. */
25
+ minutes?: "auto" | "always" | undefined;
26
+ /** `lower` reads "am", `upper` reads "AM". Defaults to `lower`. */
27
+ period?: "lower" | "upper" | undefined;
28
+ /** A space between the time and am or pm. Defaults to true. */
29
+ space?: boolean | undefined;
30
+ /** Read a minute to the hour as the hour, so the API's 16:59 close reads "5 pm". Defaults to false. */
31
+ roundLastMinute?: boolean | undefined;
32
+ };
33
+ /**
34
+ * Format an HH:mm or HH:mm:ss wall-clock time. Returns invalid input unchanged.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * formatClock("19:30"); // "7:30 pm"
39
+ * formatClock("09:00", { padHour: true, minutes: "always", period: "upper", space: false }); // "09:00AM"
40
+ * formatClock("07:00", { hour12: false }); // "7:00"
41
+ * ```
42
+ */
43
+ declare function formatClock(time: string, { hour12, padHour, minutes, period, space, roundLastMinute, }?: ClockStyle): string;
44
+ /** When a closed branch opens next, in its own time zone. */
45
+ type NextOpening = {
46
+ at: Date;
47
+ /** Whether that is today or tomorrow in the branch's time zone, or a later day. */
48
+ day: "today" | "tomorrow" | "later";
49
+ weekday: Weekday;
50
+ /** The local wall-clock time, HH:mm. */
51
+ time: string;
52
+ };
53
+ /** The instant to measure from and the store's time zone, for a branch that names none. */
54
+ type HoursOptions = {
55
+ /** Defaults to the current time. */
56
+ now?: Date | undefined;
57
+ /** The store's time zone, for a branch that names none. The branch's own always wins. */
58
+ storeTimezone?: string | undefined;
59
+ };
60
+ /**
61
+ * When a closed branch opens next, or undefined while it is open or when nothing is ahead.
62
+ *
63
+ * `api` (the default) reads the API's answer: open is `branch.isOpen`, and the opening is `closedUntil`, then
64
+ * `nextChangeAt`. It falls back to the hours when the API sends no opening still ahead. `hours` works both out from
65
+ * the weekly hours, special hours and `closedUntil` at `now`, so it keeps up with the clock after the store was read.
66
+ */
67
+ declare function nextOpening(branch: Branch, { from, now, storeTimezone, }?: HoursOptions & {
68
+ from?: "api" | "hours" | undefined;
69
+ }): NextOpening | undefined;
70
+ /**
71
+ * The words around an opening. `{time}` is the formatted time and `{weekday}` the day's name.
72
+ * The defaults read "Opens at 7 am", "Opens tomorrow at 7 am" and "Opens Thu at 7 am".
73
+ */
74
+ type OpeningPhrases = {
75
+ today: string;
76
+ tomorrow: string;
77
+ later: string;
78
+ };
79
+ /** How an opening or a status reads. */
80
+ type LabelOptions = {
81
+ clock?: ClockStyle | undefined;
82
+ /** `short` reads "Thu", `long` reads "Thursday". Defaults to `short`. */
83
+ weekday?: "short" | "long" | undefined;
84
+ phrases?: Partial<OpeningPhrases> | undefined;
85
+ };
86
+ /** Put an opening into words, as `opensLabel` does. */
87
+ declare function describeOpening(next: NextOpening, { clock, weekday, phrases }?: LabelOptions): string;
88
+ /**
89
+ * When a closed branch opens next, in words and in its own time zone: "Opens at 7 am", "Opens tomorrow at 7 am",
90
+ * "Opens Thu at 7 am". Undefined while it is open or when nothing is ahead.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * opensLabel(branch, { clock: { hour12: false } }); // "Opens tomorrow at 7:00"
95
+ * opensLabel(branch, { from: "hours", weekday: "long", phrases: { today: "Opens today {time}" } });
96
+ * ```
97
+ */
98
+ declare function opensLabel(branch: Branch, options?: HoursOptions & LabelOptions & {
99
+ from?: "api" | "hours" | undefined;
100
+ }): string | undefined;
101
+ /**
102
+ * Whether the branch takes no order at all now: closed, and not taking orders for later either.
103
+ *
104
+ * With `lastOrderMinutes`, an open branch that closes within that many minutes takes no order either, unless it takes
105
+ * orders for later. Open is the API's `branch.isOpen`, and the closing comes from its hours at `now`.
106
+ */
107
+ declare function closedForOrders(branch: Branch, { lastOrderMinutes, now, storeTimezone, }?: HoursOptions & {
108
+ lastOrderMinutes?: number | undefined;
109
+ }): boolean;
110
+ /**
111
+ * Whether a bag can be timed for later: the branch takes orders ahead, or the bag holds an item from a pre-order
112
+ * menu, which is scheduled on that menu's own terms even at a branch that takes no orders ahead. Either way the
113
+ * branch must take scheduled orders.
114
+ *
115
+ * @param menuIds - The source menus of the bag's lines.
116
+ */
117
+ declare function takesOrdersAhead(branch: Branch, menu: Menu | undefined, menuIds: readonly string[]): boolean;
118
+ /**
119
+ * The words of a status. `{time}` is the closing time in `open` and `closingSoon`.
120
+ * The defaults read "Open until 10 pm", "Closes at 10 pm" and "Closed".
121
+ */
122
+ type StatusPhrases = OpeningPhrases & {
123
+ open: string;
124
+ closingSoon: string;
125
+ closed: string;
126
+ };
127
+ /** A branch's state at an instant, worked out from its hours in its own time zone. */
128
+ type HoursStatus = {
129
+ isOpen: boolean;
130
+ /** Whether the branch takes orders for later, so a closed branch can still take one. */
131
+ canOrderAhead: boolean;
132
+ /** Closed now and not taking orders for later. */
133
+ closedForOrders: boolean;
134
+ /** Open, and closing within `closingSoonMinutes`. */
135
+ closingSoon: boolean;
136
+ label: string;
137
+ /** When it opens next, while it is closed. */
138
+ next?: NextOpening;
139
+ /** The next opening or closing found in the hours, for a timer. */
140
+ nextChange?: Date;
141
+ timezone: string;
142
+ };
143
+ /** Options for `openStatus`. */
144
+ type OpenStatusOptions = HoursOptions & Omit<LabelOptions, "phrases"> & {
145
+ phrases?: Partial<StatusPhrases> | undefined;
146
+ /** How near the closing time counts as closing soon. Defaults to 30 minutes. */
147
+ closingSoonMinutes?: number | undefined;
148
+ };
149
+ /**
150
+ * Whether a branch is open at `now` and its next change in words, from its weekly hours, special hours, overnight
151
+ * hours and `closedUntil`, in the branch's own time zone.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * openStatus(branch, { now, storeTimezone: store.timezone });
156
+ * // { isOpen: true, closingSoon: false, label: "Open until 10 pm", ... }
157
+ * ```
158
+ */
159
+ declare function openStatus(branch: Branch, { now, storeTimezone, closingSoonMinutes, phrases, ...label }?: OpenStatusOptions): HoursStatus;
160
+ /** One row of a week's hours: a run of days that share their hours. */
161
+ type HoursRow = {
162
+ days: Weekday[];
163
+ dayLabel: string;
164
+ hoursLabel: string;
165
+ /** Set on a run of closed days, when `closed` names them. */
166
+ closed?: true;
167
+ /** Set on the row that holds `today`. */
168
+ today?: true;
169
+ };
170
+ /** How a week's hours are grouped and read. */
171
+ type OpeningHoursOptions = {
172
+ /** The first day: `sunday`, `monday` or `today`. Defaults to `sunday`. `today` needs `today`. */
173
+ start?: "sunday" | "monday" | "today" | undefined;
174
+ /** Today's weekday, from `todayIn`, to start the week on or to mark its row. */
175
+ today?: Weekday | undefined;
176
+ /** Name the closed days with this label ("Closed") instead of leaving them out. */
177
+ closed?: string | undefined;
178
+ /** One row with this label ("Every day") when all seven days share their hours. */
179
+ everyDay?: string | undefined;
180
+ /** Read hours from midnight to 23:5x with this label ("Open all day"). */
181
+ allDay?: string | undefined;
182
+ clock?: ClockStyle | undefined;
183
+ /** Seven day names from Sunday. Defaults to the full English names. */
184
+ dayNames?: readonly string[] | undefined;
185
+ /** Between an opening and a closing time. Defaults to " – ". */
186
+ range?: string | undefined;
187
+ /** Between the first and last day of a run. Defaults to " – ". */
188
+ through?: string | undefined;
189
+ /** Between two sets of hours on one day. Defaults to ", ". */
190
+ separator?: string | undefined;
191
+ };
192
+ /**
193
+ * A week's opening hours grouped into runs of consecutive days that share their hours, from Sunday, Monday or
194
+ * today. Closed days are left out unless `closed` names them, and a week with no open day has no rows.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * openingHours(branch.openingTimes, { start: "monday", closed: "Closed", everyDay: "Every day" });
199
+ * // [{ days: [1, 2, 3, 4, 5], dayLabel: "Monday – Friday", hoursLabel: "8 am – 10 pm" },
200
+ * // { days: [6, 0], dayLabel: "Saturday – Sunday", hoursLabel: "Closed", closed: true }]
201
+ * ```
202
+ */
203
+ declare function openingHours(times: readonly OpeningTime[], options?: OpeningHoursOptions): HoursRow[];
204
+ /** A branch's hours for a list of branches: its status, today's hours and its week from today. */
205
+ type BranchHours = {
206
+ status: HoursStatus;
207
+ /** Today's hours in the branch's time zone, with today's special hours. Empty on a closed day. */
208
+ today: string;
209
+ week: HoursRow[];
210
+ };
211
+ /** Options for `branchHours`: `hours` reads today's hours and the week, the rest read the status. */
212
+ type BranchHoursOptions = OpenStatusOptions & {
213
+ hours?: Omit<OpeningHoursOptions, "today"> | undefined;
214
+ };
215
+ /**
216
+ * Everything a branch card shows about hours, in the branch's own time zone: whether it is open at `now` and its next
217
+ * change, today's hours (special hours included), and the week starting today with today's row marked.
218
+ */
219
+ declare function branchHours(branch: Branch, { hours, ...options }?: BranchHoursOptions): BranchHours;
220
+ /**
221
+ * The time now, once the page is in the browser and idle, then each `every` milliseconds and on window focus.
222
+ * Undefined while the server renders and until then, so hours are worked out on the shopper's clock and the server's
223
+ * HTML never disagrees with the first render.
224
+ *
225
+ * @param every - How often to refresh. Defaults to a minute.
226
+ */
227
+ declare function useNow(every?: number): Date | undefined;
228
+ /**
229
+ * `openStatus` on the shopper's clock (`useNow`): undefined while the server renders and until the page is idle,
230
+ * then refreshed each minute and on window focus.
231
+ */
232
+ declare function useOpenStatus(branch: Branch | undefined, options?: Omit<OpenStatusOptions, "now">): HoursStatus | undefined;
233
+ /** `branchHours` on the shopper's clock (`useNow`), undefined until the page is idle in the browser. */
234
+ declare function useBranchHours(branch: Branch, options?: Omit<BranchHoursOptions, "now">): BranchHours | undefined;
235
+
236
+ export { DEFAULT_TIMEZONE, branchHours, branchTimezone, closedForOrders, describeOpening, formatClock, nextOpening, openStatus, openingHours, opensLabel, takesOrdersAhead, todayIn, useBranchHours, useNow, useOpenStatus };
237
+ export type { BranchHours, BranchHoursOptions, ClockStyle, HoursOptions, HoursRow, HoursStatus, LabelOptions, NextOpening, OpenStatusOptions, OpeningHoursOptions, OpeningPhrases, StatusPhrases, Weekday };
@@ -0,0 +1,2 @@
1
+ import{useEffect,useState}from"react";import{canOrderAhead,dateOffset,getOpenStatus,localParts,parseWallClock}from"../status/hours.js";var DEFAULT_TIMEZONE="Africa/Lagos";var LONG_DAYS=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];var SHORT_DAYS=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var MINUTE=6e4;function branchTimezone(branch,storeTimezone){return branch.timezone??storeTimezone??DEFAULT_TIMEZONE}function todayIn(timezone,now=new Date){return new Date(`${localParts(now,timezone).date}T00:00:00Z`).getUTCDay()}function formatClock(time,{hour12=true,padHour=false,minutes="auto",period="lower",space=true,roundLastMinute=false}={}){const clock=parseWallClock(time);if(!clock){return time}let total=clock.hour24*60+clock.minute;if(roundLastMinute&&clock.minute===59){total=(total+1)%1440}const hour24=Math.floor(total/60);const minute=String(total%60).padStart(2,"0");const hour=String(hour12?hour24%12||12:hour24).padStart(padHour?2:1,"0");if(!hour12){return`${hour}:${minute}`}const half=hour24>=12?"PM":"AM";return`${hour}${minutes==="always"||minute!=="00"?`:${minute}`:""}${space?" ":""}${period==="upper"?half:half.toLowerCase()}`}var pad=value=>String(value).padStart(2,"0");function opening(at,timezone,now){const local=localParts(at,timezone);const today=localParts(now,timezone).date;return{at,day:local.date===today?"today":local.date===dateOffset(today,1)?"tomorrow":"later",weekday:new Date(`${local.date}T00:00:00Z`).getUTCDay(),time:`${pad(local.hour)}:${pad(local.minute)}`}}function nextOpening(branch,{from="api",now=new Date,storeTimezone}={}){const timezone=branchTimezone(branch,storeTimezone);if(from==="api"){if(branch.isOpen){return void 0}const value=branch.closedUntil??branch.nextChangeAt;const at=value?new Date(value):void 0;if(at&&at.getTime()>now.getTime()){return opening(at,timezone,now)}}const state=getOpenStatus(branch,timezone,now);return state.isOpen||!state.nextChange?void 0:opening(state.nextChange,timezone,now)}var OPENING={today:"Opens at {time}",tomorrow:"Opens tomorrow at {time}",later:"Opens {weekday} at {time}"};function describeOpening(next,{clock,weekday="short",phrases}={}){return{...OPENING,...phrases}[next.day].replace("{time}",formatClock(next.time,clock)).replace("{weekday}",(weekday==="long"?LONG_DAYS:SHORT_DAYS)[next.weekday])}function opensLabel(branch,options={}){const next=nextOpening(branch,options);return next&&describeOpening(next,options)}function closedForOrders(branch,{lastOrderMinutes,now=new Date,storeTimezone}={}){const ahead=canOrderAhead(branch);if(!branch.isOpen||ahead||!lastOrderMinutes){return!branch.isOpen&&!ahead}const state=getOpenStatus(branch,branchTimezone(branch,storeTimezone),now);return Boolean(state.isOpen&&state.nextChange&&state.nextChange.getTime()-now.getTime()<=lastOrderMinutes*MINUTE)}function takesOrdersAhead(branch,menu,menuIds){const preorder=menuIds.some(id=>menu?.menus?.find(section=>section.id===id)?.schedule?.preorder);return branch.fulfilment.scheduling&&(preorder||canOrderAhead(branch))}var STATUS={...OPENING,open:"Open until {time}",closingSoon:"Closes at {time}",closed:"Closed"};function openStatus(branch,{now=new Date,storeTimezone,closingSoonMinutes=30,phrases,...label}={}){const timezone=branchTimezone(branch,storeTimezone);const state=getOpenStatus(branch,timezone,now);const words={...STATUS,...phrases};const closingSoon=Boolean(state.isOpen&&state.nextChange&&state.nextChange.getTime()-now.getTime()<=closingSoonMinutes*MINUTE);const next=!state.isOpen&&state.nextChange?opening(state.nextChange,timezone,now):void 0;return{isOpen:state.isOpen,canOrderAhead:state.canOrderAhead,closedForOrders:!state.isOpen&&!state.canOrderAhead,closingSoon,label:state.isOpen?(closingSoon?words.closingSoon:words.open).replace("{time}",state.nextChange?formatClock(opening(state.nextChange,timezone,now).time,label.clock):""):next?describeOpening(next,{...label,phrases:words}):words.closed,...next?{next}:{},...state.nextChange?{nextChange:state.nextChange}:{},timezone}}function dayHours(times,day,{allDay,clock,range=" \u2013 ",separator=", "}){return times.filter(time=>!time.disabled&&time.day===day).sort((a,b)=>a.opens.localeCompare(b.opens)).map(time=>allDay!==void 0&&time.opens.startsWith("00:00")&&/^23:5\d/.test(time.closes)?allDay:`${formatClock(time.opens,clock)}${range}${formatClock(time.closes,clock)}`).join(separator)}function openingHours(times,options={}){const{start="sunday",today,closed,everyDay,dayNames=LONG_DAYS,through=" \u2013 "}=options;const first=start==="monday"?1:start==="today"?today??0:0;const week=Array.from({length:7},(_,index)=>(first+index)%7);const hours=week.map(day=>dayHours(times,day,options));if(!hours.some(Boolean)){return[]}const mark=days=>today!==void 0&&days.includes(today)?{today:true}:{};if(everyDay!==void 0&&hours.every(value=>value===hours[0])){return[{days:week,dayLabel:everyDay,hoursLabel:hours[0],...mark(week)}]}const runs=[];week.forEach((day,index)=>{const value=hours[index]||closed;if(value===void 0){return}const run=runs.at(-1);if(run&&run.last===index-1&&run.hours===value){run.days.push(day);run.last=index}else{runs.push({days:[day],hours:value,last:index})}});return runs.map(({days,hours:value})=>({days,dayLabel:days.length===1?dayNames[days[0]]:`${dayNames[days[0]]}${through}${dayNames[days.at(-1)]}`,hoursLabel:value,...value===closed&&!dayHours(times,days[0],options)?{closed:true}:{},...mark(days)}))}function branchHours(branch,{hours={},...options}={}){const status=openStatus(branch,options);const now=options.now??new Date;const day=todayIn(status.timezone,now);const date=localParts(now,status.timezone).date;const special=branch.specialHours?.find(entry=>entry.date===date);const clock=hours.clock??options.clock;const style={...hours,clock};return{status,today:special?special.closed||!special.opens||!special.closes?"":dayHours([{day,opens:special.opens,closes:special.closes}],day,style):dayHours(branch.openingTimes,day,style),week:openingHours(branch.openingTimes,{start:"today",...style,today:day})}}function useNow(every=MINUTE){const[now,setNow]=useState();useEffect(()=>{const tick=()=>setNow(new Date);const idle=typeof requestIdleCallback==="function"?requestIdleCallback(tick,{timeout:1500}):void 0;const soon=idle===void 0?setTimeout(tick,0):void 0;const timer=setInterval(tick,every);window.addEventListener("focus",tick);return()=>{if(idle!==void 0){cancelIdleCallback(idle)}clearTimeout(soon);clearInterval(timer);window.removeEventListener("focus",tick)}},[every]);return now}function useOpenStatus(branch,options={}){const now=useNow();return branch&&now?openStatus(branch,{...options,now}):void 0}function useBranchHours(branch,options={}){const now=useNow();return now?branchHours(branch,{...options,now}):void 0}export{DEFAULT_TIMEZONE,branchHours,branchTimezone,closedForOrders,describeOpening,formatClock,nextOpening,openStatus,openingHours,opensLabel,takesOrdersAhead,todayIn,useBranchHours,useNow,useOpenStatus};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/hours/index.ts"],
4
+ "mappings": "AACA,OAAS,UAAW,aAAgB,QACpC,OACE,cACA,WACA,cACA,WACA,mBACK,qBAMA,IAAM,iBAAmB,eAEhC,IAAM,UAAY,CAChB,SACA,SACA,UACA,YACA,WACA,SACA,UACF,EACA,IAAM,WAAa,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,KAAK,EACnE,IAAM,OAAS,IA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,KACF,EACF,SAAS,OAAO,aAAc,IAAK,KAAK,EAC5C,KAAM,aAAa,OAAO,aAAc,CACtC,MAAO,QACP,GAAG,MACH,MAAO,GACT,CAAC,CACH,CACF,CASO,SAAS,OAAO,MAAQ,OAA0B,CACvD,KAAM,CAAC,IAAK,MAAM,EAAI,SAAe,EACrC,UAAU,IAAM,CACd,MAAM,KAAO,IAAM,OAAO,IAAI,IAAM,EACpC,MAAM,KACJ,OAAO,sBAAwB,WAC3B,oBAAoB,KAAM,CAAE,QAAS,IAAK,CAAC,EAC3C,OACN,MAAM,KAAO,OAAS,OAAY,WAAW,KAAM,CAAC,EAAI,OACxD,MAAM,MAAQ,YAAY,KAAM,KAAK,EACrC,OAAO,iBAAiB,QAAS,IAAI,EACrC,MAAO,IAAM,CACX,GAAI,OAAS,OAAW,CACtB,mBAAmB,IAAI,CACzB,CACA,aAAa,IAAI,EACjB,cAAc,KAAK,EACnB,OAAO,oBAAoB,QAAS,IAAI,CAC1C,CACF,EAAG,CAAC,KAAK,CAAC,EACV,OAAO,GACT,CAMO,SAAS,cACd,OACA,QAA0C,CAAC,EAClB,CACzB,MAAM,IAAM,OAAO,EACnB,OAAO,QAAU,IAAM,WAAW,OAAQ,CAAE,GAAG,QAAS,GAAI,CAAC,EAAI,MACnE,CAGO,SAAS,eACd,OACA,QAA2C,CAAC,EACnB,CACzB,MAAM,IAAM,OAAO,EACnB,OAAO,IAAM,YAAY,OAAQ,CAAE,GAAG,QAAS,GAAI,CAAC,EAAI,MAC1D",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ "use client";import{useMatches}from"react-router";var IN_VENUE_HANDLE=Object.freeze({inVenue:true});function useAtTable(){return useMatches().some(match=>match.handle?.inVenue===true)}export{IN_VENUE_HANDLE,useAtTable};
2
+ //# sourceMappingURL=at-table.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/site/at-table.ts"],
4
+ "mappings": "aACA,OAAS,eAAkB,eAMpB,IAAM,gBAA8C,OAAO,OAAO,CACvE,QAAS,IACX,CAAC,EAMM,SAAS,YAAsB,CACpC,OAAO,WAAW,EAAE,KACjB,OACE,MAAM,QAA8C,UAAY,IACrE,CACF",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ var isClosedPage=data=>typeof data==="object"&&data!==null&&"closed"in data;export{isClosedPage};
2
+ //# sourceMappingURL=closed.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/site/closed.ts"],
4
+ "mappings": "AAuBO,IAAM,aAAgB,MAC3B,OAAO,OAAS,UAAY,OAAS,MAAQ,WAAY",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ "use client";import{createCheckout}from"@zappie/sdk/checkout";import{useCart}from"@zappie/sdk/react";import{useEffect,useMemo,useRef,useState}from"react";import{useNavigate,useSearchParams}from"react-router";var CHECKOUT_RETURN_WORDS=Object.freeze({waiting:{title:"Confirming your payment",body:"This takes a few seconds."},ended:{title:"That payment ended",body:"Nothing was charged. Your cart is unchanged."},missing:{title:"Nothing to confirm",body:"This page opens after a payment."},unknown:{title:"We could not confirm it here",body:"If you paid, the order is in your orders."}});function useCheckoutReturn({words,orderHref=id=>`/orders/${encodeURIComponent(id)}`}={}){const[query]=useSearchParams();const sessionId=query.get("session")??"";const[state,setState]=useState(sessionId?"waiting":"missing");const checkout=useMemo(()=>createCheckout(),[]);const cart=useCart();const navigate=useNavigate();const href=useRef(orderHref);href.current=orderHref;useEffect(()=>{if(!sessionId){return}const abort=new AbortController;void checkout.awaitCompletion(sessionId,{signal:abort.signal}).then(session=>{if(session.status==="completed"){cart.actions.clear();navigate(href.current(session.order_id),{replace:true})}else{setState("ended")}},()=>{if(!abort.signal.aborted){setState("unknown")}});return()=>abort.abort()},[cart.actions,checkout,navigate,sessionId]);return{state,...{...CHECKOUT_RETURN_WORDS,...words}[state]}}export{CHECKOUT_RETURN_WORDS,useCheckoutReturn};
2
+ //# sourceMappingURL=checkout-return.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/site/customer/checkout-return.ts"],
4
+ "mappings": "aACA,OAAS,mBAAsB,uBAC/B,OAAS,YAAe,oBACxB,OAAS,UAAW,QAAS,OAAQ,aAAgB,QACrD,OAAS,YAAa,oBAAuB,eAYtC,IAAM,sBACX,OAAO,OAAO,CACZ,QAAS,CACP,MAAO,0BACP,KAAM,2BACR,EACA,MAAO,CACL,MAAO,qBACP,KAAM,8CACR,EACA,QAAS,CACP,MAAO,qBACP,KAAM,kCACR,EACA,QAAS,CACP,MAAO,+BACP,KAAM,2CACR,CACF,CAAC,EA0BI,SAAS,kBAAkB,CAChC,MACA,UAAa,IAAO,WAAW,mBAAmB,EAAE,CAAC,EACvD,EAA2B,CAAC,EAI1B,CACA,KAAM,CAAC,KAAK,EAAI,gBAAgB,EAChC,MAAM,UAAY,MAAM,IAAI,SAAS,GAAK,GAC1C,KAAM,CAAC,MAAO,QAAQ,EAAI,SACxB,UAAY,UAAY,SAC1B,EACA,MAAM,SAAW,QAAQ,IAAM,eAAe,EAAG,CAAC,CAAC,EACnD,MAAM,KAAO,QAAQ,EACrB,MAAM,SAAW,YAAY,EAC7B,MAAM,KAAO,OAAO,SAAS,EAC7B,KAAK,QAAU,UACf,UAAU,IAAM,CACd,GAAI,CAAC,UAAW,CACd,MACF,CACA,MAAM,MAAQ,IAAI,gBAClB,KAAK,SAAS,gBAAgB,UAAW,CAAE,OAAQ,MAAM,MAAO,CAAC,EAAE,KAChE,SAAY,CACX,GAAI,QAAQ,SAAW,YAAa,CAClC,KAAK,QAAQ,MAAM,EACnB,SAAS,KAAK,QAAQ,QAAQ,QAAQ,EAAG,CAAE,QAAS,IAAK,CAAC,CAC5D,KAAO,CACL,SAAS,OAAO,CAClB,CACF,EACA,IAAM,CACJ,GAAI,CAAC,MAAM,OAAO,QAAS,CACzB,SAAS,SAAS,CACpB,CACF,CACF,EACA,MAAO,IAAM,MAAM,MAAM,CAC3B,EAAG,CAAC,KAAK,QAAS,SAAU,SAAU,SAAS,CAAC,EAChD,MAAO,CAAE,MAAO,GAAG,CAAE,GAAG,sBAAuB,GAAG,KAAM,EAAE,KAAK,CAAE,CACnE",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ "use client";import{createCustomer}from"@zappie/sdk/customer";import{CustomerProvider,useAuth}from"@zappie/sdk/customer/react";import{useEffect,useMemo,useState}from"react";import{signInOnce}from"../../checkout/sign-in.js";import{jsx,jsxs}from"react/jsx-runtime";function Gate({returnTo,children,checking,signedOut,className}){const auth=useAuth();const[failed,setFailed]=useState(false);useEffect(()=>{if(auth.state==="anonymous"){setFailed(!signInOnce(returnTo))}},[auth.state,returnTo]);if(failed){const again=()=>setFailed(!signInOnce(returnTo));return signedOut?signedOut(again):jsxs("div",{className,role:"alert",children:[jsx("p",{children:"You're not signed in yet."}),jsx("button",{type:"button",onClick:again,children:"Sign in again"})]})}if(auth.state!=="authenticated"||!auth.customer){return checking??jsx("p",{className,role:"status",children:"Checking your account\u2026"})}return children}function CustomerGate({children,...props}){const client=useMemo(()=>createCustomer(),[]);return jsx(CustomerProvider,{client,children:jsx(Gate,{...props,children:children(client)})})}export{CustomerGate};
2
+ //# sourceMappingURL=gate.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/site/customer/gate.tsx"],
4
+ "mappings": "aACA,OAAS,mBAA2C,uBACpD,OAAS,iBAAkB,YAAe,6BAC1C,OAAS,UAAW,QAAS,aAAgC,QAC7D,OAAS,eAAkB,4BAsCrB,OACE,IADF,6BAnBN,SAAS,KAAK,CACZ,SACA,SACA,SACA,UACA,SACF,EAAkE,CAChE,MAAM,KAAO,QAAQ,EACrB,KAAM,CAAC,OAAQ,SAAS,EAAI,SAAS,KAAK,EAC1C,UAAU,IAAM,CACd,GAAI,KAAK,QAAU,YAAa,CAC9B,UAAU,CAAC,WAAW,QAAQ,CAAC,CACjC,CACF,EAAG,CAAC,KAAK,MAAO,QAAQ,CAAC,EACzB,GAAI,OAAQ,CACV,MAAM,MAAQ,IAAM,UAAU,CAAC,WAAW,QAAQ,CAAC,EACnD,OAAO,UACL,UAAU,KAAK,EAEf,KAAC,OAAI,UAAsB,KAAK,QAC9B,cAAC,KAAE,qCAA8B,EACjC,IAAC,UAAO,KAAK,SAAS,QAAS,MAAO,yBAEtC,GACF,CAEJ,CACA,GAAI,KAAK,QAAU,iBAAmB,CAAC,KAAK,SAAU,CACpD,OACE,UACE,IAAC,KAAE,UAAsB,KAAK,SAAS,uCAEvC,CAGN,CACA,OAAO,QACT,CAYO,SAAS,aAAa,CAAE,SAAU,GAAG,KAAM,EAAsB,CACtE,MAAM,OAAS,QAAQ,IAAM,eAAe,EAAG,CAAC,CAAC,EACjD,OACE,IAAC,kBAAiB,OAChB,aAAC,MAAM,GAAG,MAAQ,kBAAS,MAAM,EAAE,EACrC,CAEJ",
5
+ "names": []
6
+ }
@@ -0,0 +1,72 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { CustomerClient } from '@zappie/sdk/customer';
4
+
5
+ /** Where a return from Zappie's hosted checkout stands. */
6
+ type CheckoutReturnState = "waiting" | "ended" | "missing" | "unknown";
7
+ /** A state's heading and the sentence under it. */
8
+ type CheckoutReturnWords = Record<CheckoutReturnState, {
9
+ title: string;
10
+ body: string;
11
+ }>;
12
+ /** The default words for each state. */
13
+ declare const CHECKOUT_RETURN_WORDS: Readonly<CheckoutReturnWords>;
14
+ /** Options for {@link useCheckoutReturn}. */
15
+ type CheckoutReturnOptions = {
16
+ /** Your own words for any state. */
17
+ words?: Partial<CheckoutReturnWords>;
18
+ /** The order's page. Defaults to `/orders/<id>`. */
19
+ orderHref?: (orderId: string) => string;
20
+ };
21
+ /**
22
+ * The `/checkout/return` page's state, for Zappie's hosted checkout to come back to with `?session=`. It waits for
23
+ * the payment, then clears the cart and replaces the page with the order's. A payment that ended without one is
24
+ * `ended`, a page opened without a session is `missing`, and a session it could not confirm is `unknown`. You draw
25
+ * the page.
26
+ *
27
+ * @example
28
+ * const { state, title, body } = useCheckoutReturn();
29
+ * return (
30
+ * <main aria-live="polite">
31
+ * <h1>{title}</h1>
32
+ * <p>{body}</p>
33
+ * {state !== "waiting" && <Link to={state === "unknown" ? "/orders" : "/"}>Continue</Link>}
34
+ * </main>
35
+ * );
36
+ */
37
+ declare function useCheckoutReturn({ words, orderHref, }?: CheckoutReturnOptions): {
38
+ state: CheckoutReturnState;
39
+ title: string;
40
+ body: string;
41
+ };
42
+
43
+ /** Props for {@link CustomerGate}. */
44
+ type CustomerGateProps = {
45
+ /** The page to come back to after signing in, such as `/orders`. */
46
+ returnTo: string;
47
+ /** The page, given the signed-in customer's client. Renders only once the customer is signed in. */
48
+ children: (client: CustomerClient) => ReactNode;
49
+ /** What shows while the account is checked. Defaults to "Checking your account…" in a status paragraph. */
50
+ checking?: ReactNode;
51
+ /**
52
+ * What shows when a sign-in came back without a session the site can use, given the function that signs in again.
53
+ * Defaults to "You're not signed in yet." and a "Sign in again" button in an alert.
54
+ */
55
+ signedOut?: (signInAgain: () => void) => ReactNode;
56
+ /** The class of the default `checking` and `signedOut` elements. */
57
+ className?: string;
58
+ };
59
+ /**
60
+ * A page for a signed-in customer only, such as their orders or account. It provides a customer client and sends a
61
+ * shopper who isn't signed in to sign in, once: when that sign-in comes back without a session, it says so and
62
+ * offers to sign in again instead of looping.
63
+ *
64
+ * @example
65
+ * <CustomerGate returnTo="/orders" className="status-page">
66
+ * {(client) => <Orders client={client} />}
67
+ * </CustomerGate>
68
+ */
69
+ declare function CustomerGate({ children, ...props }: CustomerGateProps): react.JSX.Element;
70
+
71
+ export { CHECKOUT_RETURN_WORDS, CustomerGate, useCheckoutReturn };
72
+ export type { CheckoutReturnOptions, CheckoutReturnState, CheckoutReturnWords, CustomerGateProps };
@@ -0,0 +1,2 @@
1
+ "use client";import{CHECKOUT_RETURN_WORDS,useCheckoutReturn}from"./checkout-return.js";import{CustomerGate}from"./gate.js";export{CHECKOUT_RETURN_WORDS,CustomerGate,useCheckoutReturn};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/site/customer/index.ts"],
4
+ "mappings": "aACA,OACE,sBACA,sBAIK,uBACP,OAAS,iBAA4C",
5
+ "names": []
6
+ }
@@ -0,0 +1,35 @@
1
+ export { C as ClosedPageData, i as isClosedPage, p as pageTitle } from '../title-CgphFqNB.js';
2
+ import '@zappie/sdk';
3
+
4
+ /**
5
+ * The route `handle` for a table page (`/pay-point/:id`, `/dine-in/…`): export it from the route that renders the
6
+ * SDK's `InVenuePage`, so {@link useAtTable} knows the page is at a table.
7
+ */
8
+ declare const IN_VENUE_HANDLE: {
9
+ readonly inVenue: true;
10
+ };
11
+ /**
12
+ * True on a table page, a route whose `handle` has `inVenue: true`. There the SDK's order panel is the table's bag,
13
+ * so the shell hides its own bag button and bag.
14
+ */
15
+ declare function useAtTable(): boolean;
16
+
17
+ /** Props for {@link PageViews}. */
18
+ type PageViewsProps = {
19
+ /** The store's name, which the visit records. */
20
+ storeName: string;
21
+ /**
22
+ * Whether this page counts visits. Pass `mode === "site"`: a draft or review runs where no hosting layer answers
23
+ * `/_zappie/view`.
24
+ */
25
+ enabled: boolean;
26
+ };
27
+ /**
28
+ * Counts a visit for each page the shopper opens, through `countPage` from `@zappie/sdk/visits`. An address with
29
+ * `?bag=open`, where `/cart` and `/checkout` land, is not counted: the bag takes the parameter off at once, and the
30
+ * address it leaves counts. Render it once, in the root. It renders nothing.
31
+ */
32
+ declare function PageViews({ storeName, enabled }: PageViewsProps): null;
33
+
34
+ export { IN_VENUE_HANDLE, PageViews, useAtTable };
35
+ export type { PageViewsProps };
@@ -0,0 +1,2 @@
1
+ "use client";import{IN_VENUE_HANDLE,useAtTable}from"./at-table.js";import{isClosedPage}from"./closed.js";import{PageViews}from"./page-views.js";import{pageTitle}from"./title.js";export{IN_VENUE_HANDLE,PageViews,isClosedPage,pageTitle,useAtTable};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/site/index.ts"],
4
+ "mappings": "aACA,OAAS,gBAAiB,eAAkB,gBAC5C,OAAS,iBAAyC,cAClD,OAAS,cAAsC,kBAC/C,OAAS,cAAiB",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ "use client";import{countPage}from"@zappie/sdk/visits";import{useEffect}from"react";import{useLocation}from"react-router";import{hasBagParam}from"../bag/index.js";function PageViews({storeName,enabled}){const location=useLocation();useEffect(()=>{if(hasBagParam(location.search)){return}countPage({path:location.pathname,search:location.search,title:document.title,referrer:document.referrer,storeName,enabled})},[enabled,location.pathname,location.search,storeName]);return null}export{PageViews};
2
+ //# sourceMappingURL=page-views.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/site/page-views.tsx"],
4
+ "mappings": "aACA,OAAS,cAAiB,qBAC1B,OAAS,cAAiB,QAC1B,OAAS,gBAAmB,eAC5B,OAAS,gBAAmB,kBAkBrB,SAAS,UAAU,CAAE,UAAW,OAAQ,EAAyB,CACtE,MAAM,SAAW,YAAY,EAC7B,UAAU,IAAM,CACd,GAAI,YAAY,SAAS,MAAM,EAAG,CAChC,MACF,CACA,UAAU,CACR,KAAM,SAAS,SACf,OAAQ,SAAS,OACjB,MAAO,SAAS,MAChB,SAAU,SAAS,SACnB,UACA,OACF,CAAC,CACH,EAAG,CAAC,QAAS,SAAS,SAAU,SAAS,OAAQ,SAAS,CAAC,EAC3D,OAAO,IACT",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ import{formatPhone}from"@zappie/sdk/display";import{siteClosedCopy}from"@zappie/sdk/site-closed";import{contactLinks}from"../../status/contact.js";import{formatOpeningHours}from"../../status/hours.js";import{pageTitle}from"../title.js";function closedPageData(store,closed,{copy,title=pageTitle,branches=all=>all,hours=branch=>formatOpeningHours(branch.openingTimes).map(group=>({days:group.dayLabel,hours:group.hoursLabel}))}={}){const words=siteClosedCopy(closed,copy);return{closed:words,title:title(store,words.title),store:{name:store.name,...store.brand.logoUrl?{logoUrl:store.brand.logoUrl}:{},...store.templateSettings?{templateSettings:store.templateSettings}:{}},branches:branches(store.branches).map(branch=>({id:branch.id,name:branch.name,...branch.address?{address:branch.address}:{},contact:contactLinks(branch).map(link=>({href:link.href,label:link.type==="phone"&&branch.phone?formatPhone(branch.phone,branch.country?{country:branch.country}:{}):link.label})),hours:hours(branch)}))}}export{closedPageData};
2
+ //# sourceMappingURL=closed.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/site/server/closed.ts"],
4
+ "mappings": "AACA,OAAS,gBAAmB,sBAC5B,OAAS,mBAAuC,0BAChD,OAAS,iBAAoB,0BAC7B,OAAS,uBAA0B,wBAEnC,OAAS,cAAiB,cA4BnB,SAAS,eACd,MACA,OACA,CACE,KACA,MAAQ,UACR,SAAY,KAAQ,IACpB,MAAS,QACP,mBAAmB,OAAO,YAAY,EAAE,IAAK,QAAW,CACtD,KAAM,MAAM,SACZ,MAAO,MAAM,UACf,EAAE,CACN,EAAuB,CAAC,EACR,CAChB,MAAM,MAAQ,eAAe,OAAQ,IAAI,EACzC,MAAO,CACL,OAAQ,MACR,MAAO,MAAM,MAAO,MAAM,KAAK,EAC/B,MAAO,CACL,KAAM,MAAM,KACZ,GAAI,MAAM,MAAM,QAAU,CAAE,QAAS,MAAM,MAAM,OAAQ,EAAI,CAAC,EAC9D,GAAI,MAAM,iBACN,CAAE,iBAAkB,MAAM,gBAAiB,EAC3C,CAAC,CACP,EACA,SAAU,SAAS,MAAM,QAAQ,EAAE,IAAK,SAAY,CAClD,GAAI,OAAO,GACX,KAAM,OAAO,KACb,GAAI,OAAO,QAAU,CAAE,QAAS,OAAO,OAAQ,EAAI,CAAC,EACpD,QAAS,aAAa,MAAM,EAAE,IAAK,OAAU,CAC3C,KAAM,KAAK,KACX,MACE,KAAK,OAAS,SAAW,OAAO,MAC5B,YACE,OAAO,MACP,OAAO,QAAU,CAAE,QAAS,OAAO,OAAQ,EAAI,CAAC,CAClD,EACA,KAAK,KACb,EAAE,EACF,MAAO,MAAM,MAAM,CACrB,EAAE,CACJ,CACF",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ import{createZappie}from"@zappie/sdk";import{cachedApiFetch,originFetch}from"@zappie/sdk/server";import{createContext,RouterContextProvider}from"react-router";var envContext=createContext({});var edgeContext=createContext(void 0);function siteContext(env,ctx){const context=new RouterContextProvider;context.set(envContext,env);context.set(edgeContext,ctx);return context}var read=(context,key)=>{const get=context?.get;try{return typeof get==="function"?get.call(context,key):void 0}catch{return void 0}};function siteEnv(context,request){const provided=read(context,envContext)??{};const cloudflare=context?.cloudflare?.env??{};const processEnv=globalThis.process?.env??{};const value={...processEnv,...cloudflare,...provided};const baseUrl=value.ZAPPIE_API?.replace(/\/+$/,"");const key=value.ZAPPIE_KEY||request.headers.get("x-zappie-key")||void 0;if(!baseUrl||!key){throw new Error("The site has no ZAPPIE_API or ZAPPIE_KEY binding.")}return{...value,ZAPPIE_API:baseUrl,ZAPPIE_KEY:key,ZAPPIE_DRAFT:value.ZAPPIE_DRAFT??request.headers.get("x-zappie-draft")??"",ZAPPIE_REVIEW:value.ZAPPIE_REVIEW??request.headers.get("x-zappie-review")??""}}function isPreview(env){return env.ZAPPIE_DRAFT==="1"||env.ZAPPIE_REVIEW==="1"}function siteMode(env,{dev=false}={}){if(env.ZAPPIE_REVIEW==="1"){return"review"}return env.ZAPPIE_DRAFT==="1"||dev?"draft":"site"}function requestOrigin(request){const forwardedHost=request.headers.get("x-forwarded-host");if(!forwardedHost){return new URL(request.url).origin}return`${request.headers.get("x-forwarded-proto")??"https"}://${forwardedHost}`}function createServerClient(options={}){const made=new WeakMap;const make=(context,request)=>{const env=siteEnv(context,request);const store=env.ZAPPIE_STORE??options.store;if(!store){throw new Error("The site has no ZAPPIE_STORE binding.")}const branch=env.ZAPPIE_BRANCH??options.branch;const origin=requestOrigin(request);const cached=!isPreview(env)&&env.ZAPPIE_EDGE_CACHE!=="off";const ctx=read(context,edgeContext);const plain=originFetch(origin);return{client:createZappie({store,key:env.ZAPPIE_KEY,...branch?{branch}:{},baseUrl:env.ZAPPIE_API,customerBase:`${origin}/_zappie/api`,fetch:cached?cachedApiFetch({...ctx?{ctx}:{},fetch:plain}):plain,telemetry:false}),env:{...env,ZAPPIE_STORE:store,...branch?{ZAPPIE_BRANCH:branch}:{}},origin}};return(context,request)=>{if(typeof context!=="object"||context===null){return make(context,request)}const existing=made.get(context);if(existing){return existing}const shared=make(context,request);made.set(context,shared);return shared}}export{createServerClient,edgeContext,envContext,isPreview,requestOrigin,siteContext,siteEnv,siteMode};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/site/server/context.ts"],
4
+ "mappings": "AAAA,OAAS,iBAAiC,cAC1C,OACE,eACA,gBAEK,qBACP,OAAS,cAAe,0BAA6B,eA0B9C,IAAM,WAAa,cAAuB,CAAC,CAAC,EAE5C,IAAM,YAAc,cAAuC,MAAS,EAQpE,SAAS,YACd,IACA,IACuB,CACvB,MAAM,QAAU,IAAI,sBACpB,QAAQ,IAAI,WAAY,GAAG,EAC3B,QAAQ,IAAI,YAAa,GAAG,EAC5B,OAAO,OACT,CAEA,IAAM,KAAO,CAAI,QAAkB,MAAgC,CACjE,MAAM,IAAO,SAA6D,IAC1E,GAAI,CACF,OAAO,OAAO,MAAQ,WACjB,IAAI,KAAK,QAAS,GAAG,EACtB,MACN,MAAQ,CACN,OAAO,MACT,CACF,EASO,SAAS,QACd,QACA,QACsB,CACtB,MAAM,SAAW,KAAU,QAAS,UAAU,GAAK,CAAC,EACpD,MAAM,WACH,SAAwD,YAAY,KACrE,CAAC,EACH,MAAM,WACH,WAAsD,SAAS,KAAO,CAAC,EAC1E,MAAM,MA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,MAC5D,MAAM,IAAM,KAAkB,QAAS,WAAW,EAClD,MAAM,MAAQ,YAAY,MAAM,EAChC,MAAO,CACL,OAAQ,aAAa,CACnB,MACA,IAAK,IAAI,WACT,GAAI,OAAS,CAAE,MAAO,EAAI,CAAC,EAC3B,QAAS,IAAI,WACb,aAAc,GAAG,MAAM,eACvB,MAAO,OACH,eAAe,CAAE,GAAI,IAAM,CAAE,GAAI,EAAI,CAAC,EAAI,MAAO,KAAM,CAAC,EACxD,MACJ,UAAW,KACb,CAAC,EACD,IAAK,CACH,GAAG,IACH,aAAc,MACd,GAAI,OAAS,CAAE,cAAe,MAAO,EAAI,CAAC,CAC5C,EACA,MACF,CACF,EACA,MAAO,CAAC,QAAS,UAAY,CAC3B,GAAI,OAAO,UAAY,UAAY,UAAY,KAAM,CACnD,OAAO,KAAK,QAAS,OAAO,CAC9B,CACA,MAAM,SAAW,KAAK,IAAI,OAAO,EACjC,GAAI,SAAU,CACZ,OAAO,QACT,CACA,MAAM,OAAS,KAAK,QAAS,OAAO,EACpC,KAAK,IAAI,QAAS,MAAM,EACxB,OAAO,MACT,CACF",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ import{createSecurityNonce,deferredDataFailed,securityHeaders,sharedCacheControl,snapshotHash}from"@zappie/sdk/server";import{renderToReadableStream}from"react-dom/server.edge";import{ServerRouter}from"react-router";import{isClosedPage}from"../closed.js";import{envContext}from"./context.js";import{jsx}from"react/jsx-runtime";function defaultPage(root){if(isClosedPage(root)){return{closed:true}}if(typeof root!=="object"||root===null){return{closed:false}}const shop=root;return{closed:false,...shop.mode?{mode:shop.mode}:{},...shop.menu?.version?{menuVersion:shop.menu.version}:{},...shop.store?{store:shop.store}:{}}}function documentHandler({config,cache,isBot,page=defaultPage}){return async function handleRequest(request,status,headers,routerContext,loadContext){const nonce=createSecurityNonce();let shell=false;let failed=false;const body=await renderToReadableStream(jsx(ServerRouter,{context:routerContext,url:request.url,nonce}),{nonce,onError(error){status=500;failed=true;if(shell){console.error(error)}}});shell=true;const{loaderData,errors}=routerContext.staticHandlerContext;const shop=page(loaderData.root);const pathname=new URL(request.url).pathname;const preview=shop.closed||shop.mode!=="site";const own=headers.get("cache-control");const shareable=own?sharedCacheControl(own):cache.documentCacheRule({pathname,status,preview})!=="private";if(shop.closed||shareable||isBot(request.headers.get("user-agent")??"")||routerContext.isSpaMode){await body.allReady}const apiUrl=loadContext.get(envContext).ZAPPIE_API;const responseHeaders=securityHeaders({nonce,config,...apiUrl?{apiUrl}:{},headers,hosted:["x-zappie-site","x-zappie-review","x-zappie-draft","x-zappie-key"].some(name=>request.headers.has(name))});responseHeaders.set("content-type","text/html; charset=utf-8");const setsCookie=responseHeaders.has("set-cookie");const errored=failed||Boolean(errors)||shareable&&await deferredDataFailed(loaderData);if(!own||setsCookie||shareable&&errored){const values=cache.documentCacheHeaders({pathname,status,preview,setsCookie,failed:errored,...shop.menuVersion&&shop.store?{menuVersion:shop.menuVersion,storeVersion:await snapshotHash(shop.store)}:{},deployId:routerContext.manifest.version});for(const[name,value]of Object.entries(values)){responseHeaders.set(name,value)}}return new Response(body,{status,headers:responseHeaders})}}export{documentHandler};
2
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/site/server/document.tsx"],
4
+ "mappings": "AACA,OACE,oBACA,mBACA,gBACA,mBACA,iBAEK,qBACP,OAAS,2BAA8B,wBACvC,OACE,iBAGK,eACP,OAAS,iBAAoB,eAC7B,OAAS,eAAkB,eAiFrB,mCApDN,SAAS,YAAY,KAA6B,CAChD,GAAI,aAAa,IAAI,EAAG,CACtB,MAAO,CAAE,OAAQ,IAAK,CACxB,CACA,GAAI,OAAO,OAAS,UAAY,OAAS,KAAM,CAC7C,MAAO,CAAE,OAAQ,KAAM,CACzB,CACA,MAAM,KAAO,KAKb,MAAO,CACL,OAAQ,MACR,GAAI,KAAK,KAAO,CAAE,KAAM,KAAK,IAAK,EAAI,CAAC,E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a,gBAAgB,IAAI,YAAY,EACnD,MAAM,QACJ,QACA,QAAQ,MAAM,GACb,WAAc,MAAM,mBAAmB,UAAU,EACpD,GAAI,CAAC,KAAO,YAAe,WAAa,QAAU,CAChD,MAAM,OAAS,MAAM,qBAAqB,CACxC,SACA,OACA,QACA,WACA,OAAQ,QACR,GAAI,KAAK,aAAe,KAAK,MACzB,CACE,YAAa,KAAK,YAClB,aAAc,MAAM,aAAa,KAAK,KAAK,CAC7C,EACA,CAAC,EACL,SAAU,cAAc,SAAS,OACnC,CAAC,EACD,SAAW,CAAC,KAAM,KAAK,IAAK,OAAO,QAAQ,MAAM,EAAG,CAClD,gBAAgB,IAAI,KAAM,KAAK,CACjC,CACF,CACA,OAAO,IAAI,SAAS,KAAM,CAAE,OAAQ,QAAS,eAAgB,CAAC,CAChE,CACF",
5
+ "names": []
6
+ }
@@ -0,0 +1,163 @@
1
+ import { C as ClosedPageData } from '../../title-CgphFqNB.js';
2
+ export { i as isClosedPage, p as pageTitle } from '../../title-CgphFqNB.js';
3
+ import { Store, Zappie } from '@zappie/sdk';
4
+ import { siteClosedCopy, SiteClosed } from '@zappie/sdk/site-closed';
5
+ import * as react_router from 'react-router';
6
+ import { RouterContextProvider, EntryContext } from 'react-router';
7
+ import { EdgeContext, PageCacheRules } from '@zappie/sdk/server';
8
+ import { ZappieSiteConfig } from '@zappie/sdk/config';
9
+
10
+ type Branch = Store["branches"][number];
11
+ /** Options for {@link closedPageData}. */
12
+ type ClosedPageOptions = {
13
+ /** The page's words when the merchant set no message. */
14
+ copy?: Parameters<typeof siteClosedCopy>[1];
15
+ /** The page's title. Defaults to the words' title in the store's own title pattern. */
16
+ title?: (store: Store, page: string) => string;
17
+ /** The branches in the order the page lists them. Defaults to the store's order. */
18
+ branches?: (branches: Branch[]) => Branch[];
19
+ /** A branch's week of hours. Defaults to `formatOpeningHours`' groups. */
20
+ hours?: (branch: Branch) => {
21
+ days: string;
22
+ hours: string;
23
+ }[];
24
+ };
25
+ /**
26
+ * What the closed page shows, from the store alone: never the menu or the shop's redirects. The words, phone numbers
27
+ * and hours are formatted on the server, so the browser's code carries none of it. Return it from the root loader
28
+ * when `siteClosed(request)` says the storefront is off.
29
+ *
30
+ * @example
31
+ * const closed = siteClosed(request);
32
+ * if (closed) {
33
+ * const { client } = serverClient(context, request);
34
+ * return closedPageData(await client.store.get(), closed);
35
+ * }
36
+ */
37
+ declare function closedPageData(store: Store, closed: SiteClosed, { copy, title, branches, hours, }?: ClosedPageOptions): ClosedPageData;
38
+
39
+ /** The Worker's variables a site reads. Zappie hosting sets them; a self-hosted site sets them on its Worker. */
40
+ type SiteEnv = {
41
+ ZAPPIE_API?: string;
42
+ ZAPPIE_KEY?: string;
43
+ ZAPPIE_STORE?: string;
44
+ ZAPPIE_BRANCH?: string;
45
+ ZAPPIE_DRAFT?: string;
46
+ ZAPPIE_REVIEW?: string;
47
+ ZAPPIE_IMAGES?: string;
48
+ /** `off` renders every page and reads the API afresh, as an end-to-end test's own Worker does. */
49
+ ZAPPIE_EDGE_CACHE?: string;
50
+ };
51
+ /** {@link SiteEnv} with the API, the key and the preview flags resolved. */
52
+ type ResolvedSiteEnv<Env extends SiteEnv = SiteEnv> = Env & {
53
+ ZAPPIE_API: string;
54
+ ZAPPIE_KEY: string;
55
+ /** `1` for a draft: the Worker's variable, else the request's `x-zappie-draft`, else empty. */
56
+ ZAPPIE_DRAFT: string;
57
+ /** `1` for a review: the Worker's variable, else the request's `x-zappie-review`, else empty. */
58
+ ZAPPIE_REVIEW: string;
59
+ };
60
+ /** The Worker's variables, in the load context {@link siteContext} makes. */
61
+ declare const envContext: react_router.RouterContext<SiteEnv>;
62
+ /** The Worker's execution context, for cache refreshes that finish after the response. */
63
+ declare const edgeContext: react_router.RouterContext<EdgeContext | undefined>;
64
+ /**
65
+ * The load context for React Router's request handler, holding the Worker's variables and its execution context.
66
+ *
67
+ * @example
68
+ * siteWorker({ render: (request, env, ctx) => handle(request, siteContext(env, ctx)), … });
69
+ */
70
+ declare function siteContext(env: SiteEnv, ctx?: EdgeContext): RouterContextProvider;
71
+ /**
72
+ * The site's variables for a request: the process's, then Cloudflare's `context.cloudflare.env`, then the load
73
+ * context's, the last one winning. The key falls back to the request's `x-zappie-key`, which the Studio preview sends,
74
+ * and the draft and review flags to the request's headers.
75
+ *
76
+ * @throws When there is no `ZAPPIE_API` or `ZAPPIE_KEY`.
77
+ */
78
+ declare function siteEnv<Env extends SiteEnv = SiteEnv>(context: unknown, request: Request): ResolvedSiteEnv<Env>;
79
+ /** Whether the request is a draft or a review, which is never shared or counted. */
80
+ declare function isPreview(env: Pick<ResolvedSiteEnv, "ZAPPIE_DRAFT" | "ZAPPIE_REVIEW">): boolean;
81
+ /**
82
+ * Whether the request is the live site, a draft or a review. Pass `dev: import.meta.env.DEV` so a dev server runs as
83
+ * a draft, which the editor can follow and restyle and whose visits go uncounted.
84
+ */
85
+ declare function siteMode(env: Pick<ResolvedSiteEnv, "ZAPPIE_DRAFT" | "ZAPPIE_REVIEW">, { dev }?: {
86
+ dev?: boolean;
87
+ }): "site" | "draft" | "review";
88
+ /** The origin the shopper opened: the proxy's `x-forwarded-host` when there is one, else the request's own. */
89
+ declare function requestOrigin(request: Request): string;
90
+ /** Options for {@link createServerClient}. */
91
+ type ServerClientOptions = {
92
+ /** The store's slug when the Worker has no `ZAPPIE_STORE`. */
93
+ store?: string;
94
+ /** The branch when the Worker has no `ZAPPIE_BRANCH`. Without either, the client names no branch. */
95
+ branch?: string;
96
+ };
97
+ /** What a server client function returns: the client, the resolved variables and the shopper's origin. */
98
+ type ServerClient<Env extends SiteEnv = SiteEnv> = {
99
+ client: Zappie;
100
+ /** The resolved variables, with `ZAPPIE_STORE` and `ZAPPIE_BRANCH` taking the fallbacks. */
101
+ env: ResolvedSiteEnv<Env> & {
102
+ ZAPPIE_STORE: string;
103
+ };
104
+ origin: string;
105
+ };
106
+ /**
107
+ * The site's `serverClient(context, request)` for loaders: a Zappie client for the request, made once per load
108
+ * context. The live site reads the store and its menus through the Worker's edge cache, for as long as the API's own
109
+ * `Cache-Control` allows; a draft, a review and `ZAPPIE_EDGE_CACHE=off` read afresh, so each saved change shows. Each
110
+ * API call names the shopper's origin, and the customer API goes through the site host's `/_zappie/api`, which adds
111
+ * the signed-in shopper.
112
+ *
113
+ * @example
114
+ * export const serverClient = createServerClient({ store: "my-shop" });
115
+ * // in a loader
116
+ * const { client, env, origin } = serverClient(context, request);
117
+ */
118
+ declare function createServerClient<Env extends SiteEnv = SiteEnv>(options?: ServerClientOptions): (context: unknown, request: Request) => ServerClient<Env>;
119
+
120
+ /** What the document handler reads from the root route's loader data. */
121
+ type DocumentPage = {
122
+ /** The closed page, which is never shared and renders in full. */
123
+ closed: boolean;
124
+ /** The shop's mode. Anything but `site`, or none, is a preview, which is never shared. */
125
+ mode?: "site" | "draft" | "review";
126
+ /** The menu version the page rendered, for the ETag. */
127
+ menuVersion?: string;
128
+ /** The store details the page rendered, hashed into the ETag. */
129
+ store?: unknown;
130
+ };
131
+ /** Options for {@link documentHandler}. */
132
+ type DocumentHandlerOptions = {
133
+ /** The site's `zappie.config.ts`, for the security headers. */
134
+ config: ZappieSiteConfig;
135
+ /** The site's page cache rules, from `pageCacheRules`. */
136
+ cache: Pick<PageCacheRules, "documentCacheRule" | "documentCacheHeaders">;
137
+ /** Whether a user agent is a crawler, which gets the page in full. Pass `isbot` from the `isbot` package. */
138
+ isBot: (userAgent: string) => boolean;
139
+ /**
140
+ * Reads the root's loader data. By default, data `isClosedPage` accepts is the closed page, and otherwise its
141
+ * `mode`, `menu.version` and `store` are read.
142
+ */
143
+ page?: (root: unknown) => DocumentPage;
144
+ };
145
+ /**
146
+ * The site's `app/entry.server.tsx` default export. It streams the page with a CSP nonce and Zappie's security
147
+ * headers, and sets the cache headers from the site's rules:
148
+ *
149
+ * - a page a shared cache may keep, the closed page, a crawler's page and SPA mode render in full before the headers
150
+ * go out, so an error after the shell can still make the page private;
151
+ * - a page that errored, sets a cookie, is a preview or whose deferred data failed is private;
152
+ * - a route that exports its own `headers()` keeps its `Cache-Control`, unless the response sets a cookie or the
153
+ * page errored;
154
+ * - a shared menu page gets a weak ETag of its menu version, its store details and the deploy.
155
+ *
156
+ * @example
157
+ * // app/entry.server.tsx
158
+ * export default documentHandler({ config: siteConfig, cache: pageCache, isBot: isbot });
159
+ */
160
+ declare function documentHandler({ config, cache, isBot, page, }: DocumentHandlerOptions): (request: Request, status: number, headers: Headers, routerContext: EntryContext, loadContext: RouterContextProvider) => Promise<Response>;
161
+
162
+ export { ClosedPageData, closedPageData, createServerClient, documentHandler, edgeContext, envContext, isPreview, requestOrigin, siteContext, siteEnv, siteMode };
163
+ export type { ClosedPageOptions, DocumentHandlerOptions, DocumentPage, ResolvedSiteEnv, ServerClient, ServerClientOptions, SiteEnv };
@@ -0,0 +1,2 @@
1
+ import{isClosedPage}from"../closed.js";import{pageTitle}from"../title.js";import{closedPageData}from"./closed.js";import{createServerClient,edgeContext,envContext,isPreview,requestOrigin,siteContext,siteEnv,siteMode}from"./context.js";import{documentHandler}from"./document.js";export{closedPageData,createServerClient,documentHandler,edgeContext,envContext,isClosedPage,isPreview,pageTitle,requestOrigin,siteContext,siteEnv,siteMode};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/site/server/index.ts"],
4
+ "mappings": "AAAA,OAAS,iBAAyC,eAClD,OAAS,cAAiB,cAC1B,OAAS,mBAA8C,cACvD,OACE,mBACA,YACA,WACA,UACA,cACA,YACA,QACA,aAKK,eACP,OACE,oBAGK",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ function pageTitle(store,page){if(!page){return store.name}return(store.seo?.titlePattern||"{page} \xB7 {store}").replaceAll("{page}",page).replaceAll("{store}",store.name).trim()}export{pageTitle};
2
+ //# sourceMappingURL=title.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/site/title.ts"],
4
+ "mappings": "AASO,SAAS,UACd,MACA,KACQ,CACR,GAAI,CAAC,KAAM,CACT,OAAO,MAAM,IACf,CACA,OAAQ,MAAM,KAAK,cAAgB,uBAChC,WAAW,SAAU,IAAI,EACzB,WAAW,UAAW,MAAM,IAAI,EAChC,KAAK,CACV",
5
+ "names": []
6
+ }
@@ -0,0 +1,44 @@
1
+ import { Store } from '@zappie/sdk';
2
+
3
+ /** What a closed page shows: the words, the page's title, the store's name and logo, and how to reach each branch. */
4
+ type ClosedPageData = {
5
+ closed: {
6
+ title: string;
7
+ message: string;
8
+ };
9
+ /** The page's title, in the store's own title pattern. */
10
+ title: string;
11
+ /** The store's name and logo, and its template settings, which carry the merchant's colours and logo style. */
12
+ store: {
13
+ name: string;
14
+ logoUrl?: string;
15
+ templateSettings?: Store["templateSettings"];
16
+ };
17
+ branches: {
18
+ id: string;
19
+ name: string;
20
+ address?: string;
21
+ contact: {
22
+ label: string;
23
+ href: string;
24
+ }[];
25
+ hours: {
26
+ days: string;
27
+ hours: string;
28
+ }[];
29
+ }[];
30
+ };
31
+ /** Whether the root's loader data is the closed page's, from `closedPageData`, rather than the shop's. */
32
+ declare const isClosedPage: (data: unknown) => data is ClosedPageData;
33
+
34
+ /**
35
+ * A page's title in the store's own title pattern (`seo.titlePattern`, such as `{page} | {store}`), or
36
+ * `{page} · {store}` when it has none. Without a page it is the store's name.
37
+ *
38
+ * @param store - The store, with its name and search settings.
39
+ * @param page - The page's own name, such as "About".
40
+ */
41
+ declare function pageTitle(store: Pick<Store, "name" | "seo">, page?: string): string;
42
+
43
+ export { isClosedPage as i, pageTitle as p };
44
+ export type { ClosedPageData as C };
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- var PACKAGE_VERSION=true?"0.19.0":"0.0.0-development";export{PACKAGE_VERSION};
1
+ var PACKAGE_VERSION=true?"0.21.0":"0.0.0-development";export{PACKAGE_VERSION};
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zappie/foundations",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "UI-less React primitives for Zappie storefronts: behaviour, state and accessibility without styles.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -25,6 +25,10 @@
25
25
  "types": "./dist/branch-list/index.d.ts",
26
26
  "import": "./dist/branch-list/index.js"
27
27
  },
28
+ "./hours": {
29
+ "types": "./dist/hours/index.d.ts",
30
+ "import": "./dist/hours/index.js"
31
+ },
28
32
  "./schedule": {
29
33
  "types": "./dist/schedule/index.d.ts",
30
34
  "import": "./dist/schedule/index.js"
@@ -53,6 +57,18 @@
53
57
  "types": "./dist/bag/server.d.ts",
54
58
  "import": "./dist/bag/server.js"
55
59
  },
60
+ "./site": {
61
+ "types": "./dist/site/index.d.ts",
62
+ "import": "./dist/site/index.js"
63
+ },
64
+ "./site/customer": {
65
+ "types": "./dist/site/customer/index.d.ts",
66
+ "import": "./dist/site/customer/index.js"
67
+ },
68
+ "./site/server": {
69
+ "types": "./dist/site/server/index.d.ts",
70
+ "import": "./dist/site/server/index.js"
71
+ },
56
72
  "./phone": {
57
73
  "types": "./dist/phone/index.d.ts",
58
74
  "import": "./dist/phone/index.js"
@@ -85,7 +101,7 @@
85
101
  "peerDependencies": {
86
102
  "react": "^18.2.0 || ^19.0.0",
87
103
  "react-dom": "^18.2.0 || ^19.0.0",
88
- "@zappie/sdk": "^0.19.0",
104
+ "@zappie/sdk": "^0.20.0",
89
105
  "react-router": "^8.4.0"
90
106
  },
91
107
  "peerDependenciesMeta": {
@@ -102,7 +118,7 @@
102
118
  "@types/google.maps": "^3.66.7",
103
119
  "esbuild": "^0.28.2",
104
120
  "react-router": "8.5.0",
105
- "@zappie/sdk": "0.19.0"
121
+ "@zappie/sdk": "0.20.0"
106
122
  },
107
123
  "license": "MIT",
108
124
  "homepage": "https://github.com/zappie/storefront-packages#readme",