@amboras-dev/storefront-core 2026.11.1 → 2026.11.3
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 +107 -0
- package/README.md +99 -24
- package/bin/amboras-check.mjs +2 -1
- package/bin/checks/check-proxy-matcher.mjs +112 -0
- package/core-manifest.json +36 -1
- package/dist/config/index.d.ts +7 -3
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +33 -19
- package/dist/config/index.js.map +1 -1
- package/dist/entries/client.d.ts +2 -1
- package/dist/entries/client.d.ts.map +1 -1
- package/dist/entries/client.js +1 -1
- package/dist/entries/client.js.map +1 -1
- package/dist/entries/server.d.ts +2 -1
- package/dist/entries/server.d.ts.map +1 -1
- package/dist/entries/server.js +2 -1
- package/dist/entries/server.js.map +1 -1
- package/dist/hooks/use-auth.d.ts +12 -3
- package/dist/hooks/use-auth.d.ts.map +1 -1
- package/dist/hooks/use-auth.js +41 -36
- package/dist/hooks/use-auth.js.map +1 -1
- package/dist/hooks/use-brand.d.ts +8 -0
- package/dist/hooks/use-brand.d.ts.map +1 -1
- package/dist/hooks/use-brand.js +2 -26
- package/dist/hooks/use-brand.js.map +1 -1
- package/dist/hooks/use-cart.d.ts +4 -1
- package/dist/hooks/use-cart.d.ts.map +1 -1
- package/dist/hooks/use-cart.js +33 -38
- package/dist/hooks/use-cart.js.map +1 -1
- package/dist/hooks/use-checkout-settings.d.ts +9 -2
- package/dist/hooks/use-checkout-settings.d.ts.map +1 -1
- package/dist/hooks/use-checkout-settings.js +25 -3
- package/dist/hooks/use-checkout-settings.js.map +1 -1
- package/dist/hooks/use-email-language.d.ts +10 -0
- package/dist/hooks/use-email-language.d.ts.map +1 -0
- package/dist/hooks/use-email-language.js +60 -0
- package/dist/hooks/use-email-language.js.map +1 -0
- package/dist/hooks/use-express-checkout.d.ts +3 -1
- package/dist/hooks/use-express-checkout.d.ts.map +1 -1
- package/dist/hooks/use-express-checkout.js +4 -0
- package/dist/hooks/use-express-checkout.js.map +1 -1
- package/dist/hooks/use-listing-params.d.ts +3 -1
- package/dist/hooks/use-listing-params.d.ts.map +1 -1
- package/dist/hooks/use-listing-params.js +4 -0
- package/dist/hooks/use-listing-params.js.map +1 -1
- package/dist/hooks/use-marketing-opt-in.d.ts +2 -0
- package/dist/hooks/use-marketing-opt-in.d.ts.map +1 -1
- package/dist/hooks/use-marketing-opt-in.js +3 -4
- package/dist/hooks/use-marketing-opt-in.js.map +1 -1
- package/dist/hooks/use-payment-methods-config.d.ts +3 -1
- package/dist/hooks/use-payment-methods-config.d.ts.map +1 -1
- package/dist/hooks/use-payment-methods-config.js +4 -0
- package/dist/hooks/use-payment-methods-config.js.map +1 -1
- package/dist/hooks/use-payment-providers.d.ts +2 -1
- package/dist/hooks/use-payment-providers.d.ts.map +1 -1
- package/dist/hooks/use-payment-providers.js +4 -0
- package/dist/hooks/use-payment-providers.js.map +1 -1
- package/dist/hooks/use-region.d.ts +3 -1
- package/dist/hooks/use-region.d.ts.map +1 -1
- package/dist/hooks/use-region.js +4 -0
- package/dist/hooks/use-region.js.map +1 -1
- package/dist/hooks/use-store-config.d.ts +43 -0
- package/dist/hooks/use-store-config.d.ts.map +1 -0
- package/dist/hooks/use-store-config.js +53 -0
- package/dist/hooks/use-store-config.js.map +1 -0
- package/dist/hooks/use-store-credit.d.ts +5 -1
- package/dist/hooks/use-store-credit.d.ts.map +1 -1
- package/dist/hooks/use-store-credit.js +5 -0
- package/dist/hooks/use-store-credit.js.map +1 -1
- package/dist/hooks/use-stripe-error-copy.d.ts +3 -1
- package/dist/hooks/use-stripe-error-copy.d.ts.map +1 -1
- package/dist/hooks/use-stripe-error-copy.js +4 -0
- package/dist/hooks/use-stripe-error-copy.js.map +1 -1
- package/dist/hooks/use-subscription-cart.d.ts.map +1 -1
- package/dist/hooks/use-subscription-cart.js +2 -19
- package/dist/hooks/use-subscription-cart.js.map +1 -1
- package/dist/hooks/use-subscription-offers.d.ts +5 -2
- package/dist/hooks/use-subscription-offers.d.ts.map +1 -1
- package/dist/hooks/use-subscription-offers.js +17 -6
- package/dist/hooks/use-subscription-offers.js.map +1 -1
- package/dist/lib/auth/sign-in-code.d.ts +30 -0
- package/dist/lib/auth/sign-in-code.d.ts.map +1 -0
- package/dist/lib/auth/sign-in-code.js +70 -0
- package/dist/lib/auth/sign-in-code.js.map +1 -0
- package/dist/lib/brand.d.ts +96 -0
- package/dist/lib/brand.d.ts.map +1 -1
- package/dist/lib/brand.js +49 -1
- package/dist/lib/brand.js.map +1 -1
- package/dist/lib/cart/create-cart.d.ts +6 -0
- package/dist/lib/cart/create-cart.d.ts.map +1 -0
- package/dist/lib/cart/create-cart.js +49 -0
- package/dist/lib/cart/create-cart.js.map +1 -0
- package/dist/lib/locale.d.ts +10 -0
- package/dist/lib/locale.d.ts.map +1 -0
- package/dist/lib/locale.js +59 -0
- package/dist/lib/locale.js.map +1 -0
- package/dist/lib/store-config.d.ts +69 -0
- package/dist/lib/store-config.d.ts.map +1 -0
- package/dist/lib/store-config.js +70 -0
- package/dist/lib/store-config.js.map +1 -0
- package/dist/lib/utils/safe-redirect.d.ts +0 -21
- package/dist/lib/utils/safe-redirect.d.ts.map +1 -1
- package/dist/lib/utils/safe-redirect.js +12 -8
- package/dist/lib/utils/safe-redirect.js.map +1 -1
- package/dist/lib/utils/within.d.ts +3 -0
- package/dist/lib/utils/within.d.ts.map +1 -0
- package/dist/lib/utils/within.js +14 -0
- package/dist/lib/utils/within.js.map +1 -0
- package/dist/next-config/index.d.ts +24 -5
- package/dist/next-config/index.d.ts.map +1 -1
- package/dist/next-config/index.js +258 -35
- package/dist/next-config/index.js.map +1 -1
- package/dist/shell/core-provider.d.ts +4 -1
- package/dist/shell/core-provider.d.ts.map +1 -1
- package/dist/shell/core-provider.js +11 -8
- package/dist/shell/core-provider.js.map +1 -1
- package/dist/shell/overrides.d.ts +30 -0
- package/dist/shell/overrides.d.ts.map +1 -0
- package/dist/shell/overrides.js +11 -0
- package/dist/shell/overrides.js.map +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,113 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 2026.11.3
|
|
6
|
+
|
|
7
|
+
### Breaking
|
|
8
|
+
|
|
9
|
+
- In production, a missing Medusa URL now throws `MissingMedusaUrlError` on the first config read
|
|
10
|
+
instead of falling back to `http://localhost:9000`. Development and tests keep the fallback.
|
|
11
|
+
- `configureCore` returns `void`; in 2026.11.1 and 2026.11.2 it returned the `CoreConfig`. A store
|
|
12
|
+
that uses the return value fails type-check on upgrade: call `getCoreConfig()` instead.
|
|
13
|
+
|
|
14
|
+
### Fixes
|
|
15
|
+
|
|
16
|
+
- Lazy cart: concurrent adds, from one or several `useCart` instances or `useSubscriptionCart`, now
|
|
17
|
+
share one cart instead of each creating one. `lib/cart/create-cart` is the one creator.
|
|
18
|
+
- `safeRedirect` resolves the value as a browser would and refuses every form that leaves the site
|
|
19
|
+
(`/\evil.com`, `/<tab>/evil.com`, `/..//evil.com`, `/%5Cevil.com`), returning the resolved path.
|
|
20
|
+
- `<CoreProvider overrides>` is read once in a ref; the README says it must be stable.
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- `<CoreProvider overrides>`: override the hooks core calls itself (`useCart`, `useRegion`,
|
|
25
|
+
`useAuth`, `useListingParams`, `usePaymentProviders`, `usePaymentMethodsConfig`,
|
|
26
|
+
`useStripeErrorCopy`, `useExpressCheckout`). See the README.
|
|
27
|
+
- `amboras-check proxy-matcher`: fails when `proxy.ts`'s matcher differs from core's `proxyConfig`.
|
|
28
|
+
- Shopper email language (template #207): every new cart (`useCart`, `useSubscriptionCart`) sends
|
|
29
|
+
`locale`, the shopper's pick or the store default from `/store/brand` (one try, 1 s at most, else
|
|
30
|
+
none). `useCart().updateLocale` saves it (keepalive, never cached). New `useEmailLanguage()`
|
|
31
|
+
(`client/use-email-language`) drives the checkout select and its `flush`, and `lib/locale`
|
|
32
|
+
holds the helpers. `useBrand().brand` adds `languages`, `giftCardSendOn`, `emailLanguages` and
|
|
33
|
+
`signInCode`; `lib/brand` adds `brandQuery`, which both share, and `storeLanguages`.
|
|
34
|
+
- Sign in with an email code (template #207): `useAuth()` adds `requestSignInCode`,
|
|
35
|
+
`loginWithCode` and their pending flags; neither is retried. `lib/auth/sign-in-code` maps each
|
|
36
|
+
refusal to its copy and reads a 429's wait.
|
|
37
|
+
- `api/shim-exports.json`: the export names of every `client/*` and `lib/*` module.
|
|
38
|
+
`check:manifest` fails when one is removed or renamed.
|
|
39
|
+
- `lib/utils/within`: the one bounded wait. `FLUSH_BOUND_MS` is exported from
|
|
40
|
+
`client/use-marketing-opt-in`.
|
|
41
|
+
|
|
42
|
+
## 2026.11.2
|
|
43
|
+
|
|
44
|
+
### Release order
|
|
45
|
+
|
|
46
|
+
**The orchestrator's image-hosts endpoint (`GET /api/v1/public/storefront/image-hosts`) must be live
|
|
47
|
+
in production before any production store adopts 2026.11.2.** Until then a production build cannot
|
|
48
|
+
reach it and uses the baked fallback list. In a 1% production sample of product `image` rows on the
|
|
49
|
+
12 most common hosts, about 4% (850 of 20,217) were on merchant hosts that the fallback list does
|
|
50
|
+
not include. Those images would fail in `/_next/image`.
|
|
51
|
+
|
|
52
|
+
### Breaking
|
|
53
|
+
|
|
54
|
+
- **`withAmborasCore`'s `imageHosts` option now replaces the host list.** In 2026.11.1 it was added
|
|
55
|
+
to the platform's wildcard hosts. Now it is the whole list (plus the Medusa host, the local-dev
|
|
56
|
+
hosts off Vercel, and the store's own `images.remotePatterns`). Pass
|
|
57
|
+
`await resolveAmborasImageHosts()`, not only your extra hosts. The `./next-config` entry now has
|
|
58
|
+
an API report (`api/next-config.api.md`) checked by `api:check`.
|
|
59
|
+
- **`medusaImageHost()` is removed** from `./next-config`. Core no longer used it, and no store or
|
|
60
|
+
template imports it. The reader adds the Medusa host itself.
|
|
61
|
+
- **The documented `next.config.mjs` shape changed.** Keep the literal
|
|
62
|
+
`const nextConfig = { … }` and apply core on the export line:
|
|
63
|
+
`export default withAmborasCore(nextConfig, { root: __dirname, imageHosts })`. The shape this
|
|
64
|
+
release first documented, `const nextConfig = withAmborasCore({...})`, matches none of the
|
|
65
|
+
orchestrator's or the Shopify cloner's patterns, so previews lost `allowedDevOrigins` and
|
|
66
|
+
`check_build` lost `NEXT_DIST_DIR`. A test now runs those real patterns, vendored verbatim
|
|
67
|
+
with their source lines, against the README snippet.
|
|
68
|
+
|
|
69
|
+
### Changes
|
|
70
|
+
|
|
71
|
+
- **`withAmborasCore()` allows no wildcard image hosts.** Version 2026.11.1 allowed
|
|
72
|
+
`*.amazonaws.com`, `*.s3.amazonaws.com`, `*.cloudfront.net`, `*.supabase.co` and
|
|
73
|
+
`*.amboras.com`, which reopened the image proxy the platform had just closed. The hosts are now
|
|
74
|
+
data. The new `resolveAmborasImageHosts()` reads them from the platform endpoint
|
|
75
|
+
(`/api/v1/public/storefront/image-hosts?store=…`, 2s timeout). If that fails, it reads
|
|
76
|
+
`AMBORAS_IMAGE_HOSTS`, and then the baked fallback list (`AMBORAS_FALLBACK_IMAGE_HOSTS`,
|
|
77
|
+
the template's 13 hosts). It always adds the store's Medusa host. This is the template's
|
|
78
|
+
`amboras:image-hosts-reader` algorithm. A drift test runs core's copy next to a vendored copy
|
|
79
|
+
of the template's block (source commit in the fixture) and fails on any difference. Any
|
|
80
|
+
hostname containing `*` now throws. `PLATFORM_IMAGE_HOSTS` is a deprecated alias of the
|
|
81
|
+
exact-host fallback list.
|
|
82
|
+
- **Features come from Medusa's `GET /store/config`.** There is a new `useStoreConfig()` hook
|
|
83
|
+
(`client/use-store-config`, query key `['store-config']`) and a new server read,
|
|
84
|
+
`getStoreConfig()` (`/server`, `lib/store-config`, revalidates every 60s). Both return
|
|
85
|
+
`features` (`store_credit`, `gift_card_tender`, `subscriptions`, `cod`), `checkout_settings` and
|
|
86
|
+
`brand`. **Unknown is not off.** Each flag is `true`, `false`, or `null` (unknown), and
|
|
87
|
+
`checkout_settings` and `brand` are `null` when unknown. Everything is unknown while loading, on
|
|
88
|
+
an older Medusa (404), when Medusa cannot read the store (503), and on a network error. In those
|
|
89
|
+
cases `available` is false. A part whose reader failed in Medusa is `null` while the rest is
|
|
90
|
+
known. `isFeatureOff()` is true only for an explicit `false`, and it is the safe gate. Do not
|
|
91
|
+
read `features.x` as a boolean. `isFeatureOn()` is its counterpart. `useStoreConfig()` also
|
|
92
|
+
returns `checkoutSettingsAvailable` and `brandAvailable`, which are true when the route answered
|
|
93
|
+
and that part is known. Several hooks now use this data, and their APIs are unchanged:
|
|
94
|
+
- `useStoreCreditBalance` skips the balance call only when `store_credit` is `false`. When the
|
|
95
|
+
flag is unknown it asks as before.
|
|
96
|
+
- `useSubscriptionOffers` returns an empty page only when `subscriptions` is `false`. When the
|
|
97
|
+
flag is unknown it asks as before.
|
|
98
|
+
- `useCheckoutSettings` reads `checkout_settings` through the same `['store-config']` query
|
|
99
|
+
(`select`), so there is one cache and one 5-minute bound, not two stacked. It falls back to
|
|
100
|
+
`/store/checkout-settings` when that part is unknown.
|
|
101
|
+
|
|
102
|
+
`useBrand` and `getBrand` keep using `/store/brand`, because they need the store name.
|
|
103
|
+
`/store/payment-providers` still decides COD for each region.
|
|
104
|
+
|
|
105
|
+
- **`getBrand()` revalidates every 60s instead of using `no-store`.** The store's root
|
|
106
|
+
`generateMetadata` calls it, so the `no-store` fetch made every route dynamic and cancelled the
|
|
107
|
+
template's `force-dynamic` scoping. With this change, routes without A/B tests can be static.
|
|
108
|
+
For example, a test build rendered the `/checkout` shell as `○` static. It still returns `null`
|
|
109
|
+
on any failure. A logo or colour change can take up to about 2 minutes to reach metadata (Next's
|
|
110
|
+
60s plus Medusa's 60s route cache).
|
|
111
|
+
|
|
5
112
|
## 2026.11.1
|
|
6
113
|
|
|
7
114
|
- **A broken plugin no longer takes the page down.** Each plugin in `PluginSlot` and
|
package/README.md
CHANGED
|
@@ -34,6 +34,9 @@ configureCore({
|
|
|
34
34
|
|
|
35
35
|
Core reads the config lazily, at call time, so module order does not matter.
|
|
36
36
|
|
|
37
|
+
In production, a missing Medusa URL throws `MissingMedusaUrlError` on the first config read.
|
|
38
|
+
Only development and tests fall back to `http://localhost:9000`.
|
|
39
|
+
|
|
37
40
|
### 2. Shims keep every import path
|
|
38
41
|
|
|
39
42
|
Each file core owns stays in the store as a one-line re-export, so existing design files (AI-restyled
|
|
@@ -86,22 +89,81 @@ import { StripePaymentForm } from '@/components/checkout/stripe-payment-form'
|
|
|
86
89
|
Payment plugins add an adapter with `registerPaymentProvider(config)` from
|
|
87
90
|
`@amboras-dev/storefront-core/lib/payment-providers/registry`.
|
|
88
91
|
|
|
92
|
+
### Overriding a hook
|
|
93
|
+
|
|
94
|
+
A local export next to a shim's `export *` only changes the store's own imports. Core's hooks
|
|
95
|
+
import each other directly, so to change a hook core itself calls, pass it to `CoreProvider`:
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
// app/providers.tsx. Module scope: overrides are read once.
|
|
99
|
+
const overrides: CoreHookOverrides = {
|
|
100
|
+
useCart: (base) => {
|
|
101
|
+
const cart = base()
|
|
102
|
+
return { ...cart /* … */ }
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
;<CoreProvider registry={PLUGIN_REGISTRY} overrides={overrides}>
|
|
107
|
+
{children}
|
|
108
|
+
</CoreProvider>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Overridable: `useCart`, `useRegion`, `useAuth`, `useListingParams`, `usePaymentProviders`,
|
|
112
|
+
`usePaymentMethodsConfig`, `useStripeErrorCopy`, `useExpressCheckout`. Every other hook is called
|
|
113
|
+
only by store code, so its shim is already the override. `/lib` functions are not overridable. An
|
|
114
|
+
override is a hook: call `base` on every render or on none. `overrides` is read once, on the first
|
|
115
|
+
render: keep it stable (module scope), since adding or removing one later would change hook order.
|
|
116
|
+
|
|
89
117
|
### 4. Next config and Tailwind
|
|
90
118
|
|
|
91
119
|
```js
|
|
92
120
|
// next.config.mjs
|
|
93
|
-
import {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
121
|
+
import { fileURLToPath } from 'node:url'
|
|
122
|
+
import { dirname } from 'node:path'
|
|
123
|
+
import { resolveAmborasImageHosts, withAmborasCore } from '@amboras-dev/storefront-core/next-config'
|
|
124
|
+
|
|
125
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
126
|
+
const imageHosts = await resolveAmborasImageHosts()
|
|
127
|
+
|
|
128
|
+
/** @type {import('next').NextConfig} */
|
|
129
|
+
const nextConfig = {
|
|
130
|
+
/* store options */
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default withAmborasCore(nextConfig, { root: __dirname, imageHosts })
|
|
100
134
|
```
|
|
101
135
|
|
|
102
|
-
|
|
103
|
-
`
|
|
104
|
-
|
|
136
|
+
**Keep that shape.** The orchestrator (e2b previews, `check_build`) and the Shopify cloner patch
|
|
137
|
+
`next.config.mjs` by regex, and all of them anchor on the literal `const nextConfig = {`. That is
|
|
138
|
+
where `allowedDevOrigins` (previews) and `distDir: process.env.NEXT_DIST_DIR` (`check_build`'s
|
|
139
|
+
isolated build) are injected. Keep the store's options in that literal object and apply core only
|
|
140
|
+
on the export line. `const nextConfig = withAmborasCore({...})` matches none of the patterns, so
|
|
141
|
+
previews and `check_build` silently lose their patches. `withAmborasCore` spreads the object, so
|
|
142
|
+
the injected keys survive. `test/core/next-config-patchers.test.ts` runs the orchestrator's and
|
|
143
|
+
the cloner's real patterns against this snippet. Resolve the hosts with a top-level `await`; never
|
|
144
|
+
export an async function.
|
|
145
|
+
|
|
146
|
+
`withAmborasCore` adds core to `transpilePackages`, pins `turbopack.root`, and builds
|
|
147
|
+
`images.remotePatterns` from exact hosts only. The hosts are platform data, not code.
|
|
148
|
+
`resolveAmborasImageHosts()` reads them once, at config load, from the first source that answers:
|
|
149
|
+
|
|
150
|
+
1. the platform: `GET <platform>/api/v1/public/storefront/image-hosts?store=<NEXT_PUBLIC_STORE_ID>`,
|
|
151
|
+
with a 2s timeout. `<platform>` is `AMBORAS_PLATFORM_API_URL`, else derived from the Medusa host
|
|
152
|
+
(`api[-env].amboras.com` becomes `core[-env].amboras.com`), else `https://core.amboras.com`;
|
|
153
|
+
2. `AMBORAS_IMAGE_HOSTS`: a JSON array or a comma list of exact host names;
|
|
154
|
+
3. the baked fallback `AMBORAS_FALLBACK_IMAGE_HOSTS` (the template's 13 hosts).
|
|
155
|
+
|
|
156
|
+
The exact host of `NEXT_PUBLIC_MEDUSA_BACKEND_URL` is always added, and the local-dev hosts are
|
|
157
|
+
added when not on Vercel. It is the same algorithm as the template's
|
|
158
|
+
`amboras:image-hosts-reader` block. Without `imageHosts`, `withAmborasCore` uses
|
|
159
|
+
`AMBORAS_IMAGE_HOSTS` or the fallback list (it does not call the network). Any hostname containing `*`
|
|
160
|
+
throws, whether it is `**` or `*.cloudfront.net`, because a wildcard makes `/_next/image` an open
|
|
161
|
+
proxy.
|
|
162
|
+
|
|
163
|
+
**Release order:** the orchestrator's image-hosts endpoint must be live in production before any
|
|
164
|
+
production store adopts 2026.11.2. Without it a production build uses the fallback list. In a 1%
|
|
165
|
+
production sample of product images, about 4% were on merchant hosts that the list does not
|
|
166
|
+
include, so they would fail in `/_next/image`.
|
|
105
167
|
|
|
106
168
|
Add `@source "../node_modules/@amboras-dev/storefront-core";` to `app/globals.css` (see
|
|
107
169
|
`presets/tailwind.md`).
|
|
@@ -120,25 +182,37 @@ export const config = {
|
|
|
120
182
|
}
|
|
121
183
|
```
|
|
122
184
|
|
|
123
|
-
|
|
185
|
+
`amboras-check proxy-matcher` fails when the copy differs from the installed core's matcher.
|
|
186
|
+
|
|
187
|
+
### 6. Feature switches: unknown is not off
|
|
188
|
+
|
|
189
|
+
`useStoreConfig()` (client) and `getStoreConfig()` (server) read Medusa's `GET /store/config`. Each
|
|
190
|
+
feature flag is `true`, `false` or `null`, and `null` means unknown. Everything is unknown while
|
|
191
|
+
loading, on an older Medusa, on a 503 and on a network error, and a flag whose reader failed in
|
|
192
|
+
Medusa is `null` too. Gate UI with `isFeatureOff(feature)`, which is true only when Medusa said
|
|
193
|
+
`false`. Never read `features.x` as a boolean, because `null` is falsy and would hide a feature
|
|
194
|
+
nobody turned off. `checkout_settings` and `brand` are `null` when unknown. `useCheckoutSettings`
|
|
195
|
+
then falls back to `/store/checkout-settings`.
|
|
196
|
+
|
|
197
|
+
### 7. Build gates
|
|
124
198
|
|
|
125
199
|
```bash
|
|
126
|
-
npx amboras-check # plugin slots, store quirks, redirect boundaries, consent scroll
|
|
200
|
+
npx amboras-check # plugin slots, store quirks, redirect boundaries, consent scroll, proxy matcher
|
|
127
201
|
npx amboras-check slots # one gate
|
|
128
202
|
```
|
|
129
203
|
|
|
130
204
|
## Entry points
|
|
131
205
|
|
|
132
|
-
| Entry | What
|
|
133
|
-
| -------------------------- |
|
|
134
|
-
| `/client` | `CoreProvider
|
|
135
|
-
| `/client/<hook>` | one hook file, same exports as the template's
|
|
136
|
-
| `/server` | `createPluginSlot`, `PluginSlot`, `getPluginConfigs`, `medusaFetch`, config | no |
|
|
137
|
-
| `/lib/<path>` | logic modules (checkout, cart, payment providers, analytics, consent…)
|
|
138
|
-
| `/edge` | `proxy`, `proxyConfig`
|
|
139
|
-
| `/next-config` | `withAmborasCore`
|
|
140
|
-
| `/config` | `configureCore`, `getCoreConfig`
|
|
141
|
-
| `/types`, `/types/plugins` | shared types, slot types
|
|
206
|
+
| Entry | What | `"use client"` |
|
|
207
|
+
| -------------------------- | --------------------------------------------------------------------------------------------- | -------------- |
|
|
208
|
+
| `/client` | `CoreProvider` (registry, payment UI, hook overrides), `ClientPluginSlot`, config | yes |
|
|
209
|
+
| `/client/<hook>` | one hook file, same exports as the template's | per file |
|
|
210
|
+
| `/server` | `createPluginSlot`, `PluginSlot`, `getPluginConfigs`, `medusaFetch`, `getStoreConfig`, config | no |
|
|
211
|
+
| `/lib/<path>` | logic modules (checkout, cart, payment providers, analytics, consent…) | per file |
|
|
212
|
+
| `/edge` | `proxy`, `proxyConfig` | no |
|
|
213
|
+
| `/next-config` | `withAmborasCore`, `resolveAmborasImageHosts` | no |
|
|
214
|
+
| `/config` | `configureCore`, `getCoreConfig` | no |
|
|
215
|
+
| `/types`, `/types/plugins` | shared types, slot types | no |
|
|
142
216
|
|
|
143
217
|
`dist/` is `tsc` output, file for file: every `"use client"` stays on the file that had it.
|
|
144
218
|
|
|
@@ -146,7 +220,8 @@ npx amboras-check slots # one gate
|
|
|
146
220
|
|
|
147
221
|
CalVer `YYYY.M.N` (`npm run version:next`). Plugins declare
|
|
148
222
|
`peerDependencies['@amboras-dev/storefront-core']: '>=2026.11.0'`. Deprecated names stay exported
|
|
149
|
-
for at least two minors. `api/*.api.md` is the public surface of `/client
|
|
150
|
-
when it changes without the report being updated.
|
|
223
|
+
for at least two minors. `api/*.api.md` is the public surface of `/client`, `/server` and
|
|
224
|
+
`/next-config`; CI fails when it changes without the report being updated. `api/shim-exports.json`
|
|
225
|
+
lists the export names behind `/client/*` and `/lib/*`; CI fails when one is removed or renamed.
|
|
151
226
|
|
|
152
227
|
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development and release.
|
package/bin/amboras-check.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// amboras-check [gate…] [--root <dir>]
|
|
5
5
|
//
|
|
6
|
-
// Gates: slots, quirks, redirect-boundaries, consent-scroll (default: all).
|
|
6
|
+
// Gates: slots, quirks, redirect-boundaries, consent-scroll, proxy-matcher (default: all).
|
|
7
7
|
// The store root defaults to the current directory. Each gate is a separate
|
|
8
8
|
// node process, so a failing gate's exit code and output are its own.
|
|
9
9
|
import { spawnSync } from 'node:child_process'
|
|
@@ -16,6 +16,7 @@ const GATES = {
|
|
|
16
16
|
quirks: 'check-store-quirks.mjs',
|
|
17
17
|
'redirect-boundaries': 'check-redirect-boundaries.mjs',
|
|
18
18
|
'consent-scroll': 'check-consent-scroll.mjs',
|
|
19
|
+
'proxy-matcher': 'check-proxy-matcher.mjs',
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const args = process.argv.slice(2)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Fails when the store's proxy.ts config.matcher differs from the installed core's proxyConfig.matcher.
|
|
3
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
|
|
7
|
+
const ROOT = process.env.AMBORAS_STORE_ROOT ? path.resolve(process.env.AMBORAS_STORE_ROOT) : process.cwd()
|
|
8
|
+
const STORE_FILES = ['proxy.ts', 'proxy.js', 'src/proxy.ts']
|
|
9
|
+
|
|
10
|
+
/** String literals of the `matcher: [ … ]` array after `anchor`, or null. */
|
|
11
|
+
export function extractMatcher(src, anchor = /\bmatcher\s*:\s*\[/) {
|
|
12
|
+
const m = anchor.exec(src)
|
|
13
|
+
if (!m) return null
|
|
14
|
+
const out = []
|
|
15
|
+
let i = m.index + m[0].length
|
|
16
|
+
let depth = 1
|
|
17
|
+
while (i < src.length) {
|
|
18
|
+
const c = src[i]
|
|
19
|
+
const next = src[i + 1]
|
|
20
|
+
if (c === '/' && next === '/') {
|
|
21
|
+
i = src.indexOf('\n', i)
|
|
22
|
+
if (i === -1) return null
|
|
23
|
+
continue
|
|
24
|
+
}
|
|
25
|
+
if (c === '/' && next === '*') {
|
|
26
|
+
i = src.indexOf('*/', i + 2)
|
|
27
|
+
if (i === -1) return null
|
|
28
|
+
i += 2
|
|
29
|
+
continue
|
|
30
|
+
}
|
|
31
|
+
if (c === "'" || c === '"' || c === '`') {
|
|
32
|
+
let j = i + 1
|
|
33
|
+
let value = ''
|
|
34
|
+
while (j < src.length && src[j] !== c) {
|
|
35
|
+
if (src[j] === '\\') {
|
|
36
|
+
value += src[j + 1]
|
|
37
|
+
j += 2
|
|
38
|
+
continue
|
|
39
|
+
}
|
|
40
|
+
if (c === '`' && src[j] === '$' && src[j + 1] === '{') return null
|
|
41
|
+
value += src[j]
|
|
42
|
+
j++
|
|
43
|
+
}
|
|
44
|
+
out.push(value)
|
|
45
|
+
i = j + 1
|
|
46
|
+
continue
|
|
47
|
+
}
|
|
48
|
+
if (c === '[') depth++
|
|
49
|
+
if (c === ']' && --depth === 0) return out
|
|
50
|
+
i++
|
|
51
|
+
}
|
|
52
|
+
return null
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function coreMatcher(src) {
|
|
56
|
+
return extractMatcher(src, /\bproxyConfig\s*=\s*\{\s*matcher\s*:\s*\[/)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function storeMatcher(src) {
|
|
60
|
+
return extractMatcher(src, /\bexport\s+const\s+config\s*(?::[^=]+)?=\s*\{\s*matcher\s*:\s*\[/)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function compare(store, core) {
|
|
64
|
+
const lines = []
|
|
65
|
+
const n = Math.max(store.length, core.length)
|
|
66
|
+
for (let k = 0; k < n; k++) {
|
|
67
|
+
if (store[k] === core[k]) continue
|
|
68
|
+
lines.push(` [${k}] store: ${JSON.stringify(store[k] ?? null)} core: ${JSON.stringify(core[k] ?? null)}`)
|
|
69
|
+
}
|
|
70
|
+
return lines
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function main() {
|
|
74
|
+
const storeFile = STORE_FILES.find((f) => existsSync(path.join(ROOT, f)))
|
|
75
|
+
if (!storeFile) {
|
|
76
|
+
console.error(`[check-proxy-matcher] FAIL: no proxy file (${STORE_FILES.join(', ')}) in ${ROOT}.`)
|
|
77
|
+
process.exit(1)
|
|
78
|
+
}
|
|
79
|
+
const store = storeMatcher(readFileSync(path.join(ROOT, storeFile), 'utf8'))
|
|
80
|
+
if (!store) {
|
|
81
|
+
console.error(
|
|
82
|
+
`[check-proxy-matcher] FAIL: ${storeFile} has no static \`export const config = { matcher: [ … ] }\`.`,
|
|
83
|
+
)
|
|
84
|
+
process.exit(1)
|
|
85
|
+
}
|
|
86
|
+
const CORE_FILE = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'dist', 'edge', 'proxy.js')
|
|
87
|
+
const core = coreMatcher(readFileSync(CORE_FILE, 'utf8'))
|
|
88
|
+
if (!core) {
|
|
89
|
+
console.error(`[check-proxy-matcher] FAIL: could not read proxyConfig.matcher from ${CORE_FILE}.`)
|
|
90
|
+
process.exit(1)
|
|
91
|
+
}
|
|
92
|
+
const diff = compare(store, core)
|
|
93
|
+
if (diff.length) {
|
|
94
|
+
console.error(
|
|
95
|
+
`[check-proxy-matcher] FAIL: ${storeFile}'s matcher differs from core's proxyConfig.matcher.\n` +
|
|
96
|
+
diff.join('\n') +
|
|
97
|
+
"\n Copy core's proxyConfig.matcher (@amboras-dev/storefront-core/edge) into config.matcher verbatim.",
|
|
98
|
+
)
|
|
99
|
+
process.exit(1)
|
|
100
|
+
}
|
|
101
|
+
console.log(`[check-proxy-matcher] OK: ${storeFile} matches core's proxyConfig (${core.length} patterns).`)
|
|
102
|
+
console.log('[check-proxy-matcher] EXIT_OK')
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) {
|
|
106
|
+
try {
|
|
107
|
+
main()
|
|
108
|
+
} catch (err) {
|
|
109
|
+
console.error(`[check-proxy-matcher] FAIL: check crashed — ${err?.message ?? err}`)
|
|
110
|
+
process.exit(1)
|
|
111
|
+
}
|
|
112
|
+
}
|
package/core-manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "Generated by scripts/build-manifest.mjs. Paths are relative to the storefront app root.",
|
|
3
3
|
"package": "@amboras-dev/storefront-core",
|
|
4
|
-
"version": "2026.11.
|
|
4
|
+
"version": "2026.11.3",
|
|
5
5
|
"shims": [
|
|
6
6
|
{
|
|
7
7
|
"path": "hooks/use-auth.ts",
|
|
@@ -53,6 +53,11 @@
|
|
|
53
53
|
"import": "@amboras-dev/storefront-core/client/use-digital-downloads",
|
|
54
54
|
"kind": "reexport"
|
|
55
55
|
},
|
|
56
|
+
{
|
|
57
|
+
"path": "hooks/use-email-language.ts",
|
|
58
|
+
"import": "@amboras-dev/storefront-core/client/use-email-language",
|
|
59
|
+
"kind": "reexport"
|
|
60
|
+
},
|
|
56
61
|
{
|
|
57
62
|
"path": "hooks/use-express-checkout-flow.ts",
|
|
58
63
|
"import": "@amboras-dev/storefront-core/client/use-express-checkout-flow",
|
|
@@ -173,6 +178,11 @@
|
|
|
173
178
|
"import": "@amboras-dev/storefront-core/client/use-shipping-countries",
|
|
174
179
|
"kind": "reexport"
|
|
175
180
|
},
|
|
181
|
+
{
|
|
182
|
+
"path": "hooks/use-store-config.ts",
|
|
183
|
+
"import": "@amboras-dev/storefront-core/client/use-store-config",
|
|
184
|
+
"kind": "reexport"
|
|
185
|
+
},
|
|
176
186
|
{
|
|
177
187
|
"path": "hooks/use-store-credit.ts",
|
|
178
188
|
"import": "@amboras-dev/storefront-core/client/use-store-credit",
|
|
@@ -218,6 +228,11 @@
|
|
|
218
228
|
"import": "@amboras-dev/storefront-core/lib/analytics",
|
|
219
229
|
"kind": "reexport"
|
|
220
230
|
},
|
|
231
|
+
{
|
|
232
|
+
"path": "lib/auth/sign-in-code.ts",
|
|
233
|
+
"import": "@amboras-dev/storefront-core/lib/auth/sign-in-code",
|
|
234
|
+
"kind": "reexport"
|
|
235
|
+
},
|
|
221
236
|
{
|
|
222
237
|
"path": "lib/brand.ts",
|
|
223
238
|
"import": "@amboras-dev/storefront-core/lib/brand",
|
|
@@ -248,6 +263,11 @@
|
|
|
248
263
|
"import": "@amboras-dev/storefront-core/lib/cart/cart-country",
|
|
249
264
|
"kind": "reexport"
|
|
250
265
|
},
|
|
266
|
+
{
|
|
267
|
+
"path": "lib/cart/create-cart.ts",
|
|
268
|
+
"import": "@amboras-dev/storefront-core/lib/cart/create-cart",
|
|
269
|
+
"kind": "reexport"
|
|
270
|
+
},
|
|
251
271
|
{
|
|
252
272
|
"path": "lib/cart/discount-total.ts",
|
|
253
273
|
"import": "@amboras-dev/storefront-core/lib/cart/discount-total",
|
|
@@ -343,6 +363,11 @@
|
|
|
343
363
|
"import": "@amboras-dev/storefront-core/lib/get-policies",
|
|
344
364
|
"kind": "reexport"
|
|
345
365
|
},
|
|
366
|
+
{
|
|
367
|
+
"path": "lib/locale.ts",
|
|
368
|
+
"import": "@amboras-dev/storefront-core/lib/locale",
|
|
369
|
+
"kind": "reexport"
|
|
370
|
+
},
|
|
346
371
|
{
|
|
347
372
|
"path": "lib/logger.ts",
|
|
348
373
|
"import": "@amboras-dev/storefront-core/lib/logger",
|
|
@@ -443,6 +468,11 @@
|
|
|
443
468
|
"import": "@amboras-dev/storefront-core/lib/store-api",
|
|
444
469
|
"kind": "reexport"
|
|
445
470
|
},
|
|
471
|
+
{
|
|
472
|
+
"path": "lib/store-config.ts",
|
|
473
|
+
"import": "@amboras-dev/storefront-core/lib/store-config",
|
|
474
|
+
"kind": "reexport"
|
|
475
|
+
},
|
|
446
476
|
{
|
|
447
477
|
"path": "lib/stripe/appearance.ts",
|
|
448
478
|
"import": "@amboras-dev/storefront-core/lib/stripe/appearance",
|
|
@@ -508,6 +538,11 @@
|
|
|
508
538
|
"import": "@amboras-dev/storefront-core/lib/utils/safe-redirect",
|
|
509
539
|
"kind": "reexport"
|
|
510
540
|
},
|
|
541
|
+
{
|
|
542
|
+
"path": "lib/utils/within.ts",
|
|
543
|
+
"import": "@amboras-dev/storefront-core/lib/utils/within",
|
|
544
|
+
"kind": "reexport"
|
|
545
|
+
},
|
|
511
546
|
{
|
|
512
547
|
"path": "lib/variant-extensions.ts",
|
|
513
548
|
"import": "@amboras-dev/storefront-core/lib/variant-extensions",
|
package/dist/config/index.d.ts
CHANGED
|
@@ -16,13 +16,17 @@ export interface CoreConfig {
|
|
|
16
16
|
debug?: boolean;
|
|
17
17
|
}
|
|
18
18
|
export type CoreConfigInput = Partial<CoreConfig>;
|
|
19
|
+
/** Thrown by config reads in production when no Medusa URL is configured. */
|
|
20
|
+
export declare class MissingMedusaUrlError extends Error {
|
|
21
|
+
constructor();
|
|
22
|
+
}
|
|
19
23
|
/**
|
|
20
24
|
* Sets the store configuration. Call it at module scope of the store's
|
|
21
25
|
* lib/amboras.ts. Calling it again merges: unset values keep what an earlier
|
|
22
|
-
* call (or the env fallback) gave.
|
|
26
|
+
* call (or the env fallback) gave. Never throws; a missing URL throws on first read.
|
|
23
27
|
*/
|
|
24
|
-
export declare function configureCore(input: CoreConfigInput):
|
|
25
|
-
/** The active configuration
|
|
28
|
+
export declare function configureCore(input: CoreConfigInput): void;
|
|
29
|
+
/** The active configuration; throws {@link MissingMedusaUrlError} in production without a Medusa URL. */
|
|
26
30
|
export declare function getCoreConfig(): CoreConfig;
|
|
27
31
|
/** True once the store called configureCore (the version-floor check reads this in dev). */
|
|
28
32
|
export declare function isCoreConfigured(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAA;IACjB,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAA;IACjB,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,yFAAyF;IACzF,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mEAAmE;IACnE,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAIjD,6EAA6E;AAC7E,qBAAa,qBAAsB,SAAQ,KAAK;;CAS/C;AAoDD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAE1D;AAED,yGAAyG;AACzG,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED,4FAA4F;AAC5F,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED,sDAAsD;AACtD,wBAAgB,eAAe,IAAI,IAAI,CAEtC"}
|
package/dist/config/index.js
CHANGED
|
@@ -10,7 +10,16 @@
|
|
|
10
10
|
// so the order in which modules evaluate does not matter. The env fallback
|
|
11
11
|
// keeps an unconfigured server render and the tests working; it is not the
|
|
12
12
|
// contract.
|
|
13
|
-
const
|
|
13
|
+
const DEV_MEDUSA_URL = 'http://localhost:9000';
|
|
14
|
+
/** Thrown by config reads in production when no Medusa URL is configured. */
|
|
15
|
+
export class MissingMedusaUrlError extends Error {
|
|
16
|
+
constructor() {
|
|
17
|
+
super('[storefront-core] No Medusa backend URL is configured. Set NEXT_PUBLIC_MEDUSA_BACKEND_URL ' +
|
|
18
|
+
'for this build and pass it to configureCore({ medusaUrl }) in lib/amboras.ts. ' +
|
|
19
|
+
'Only development falls back to http://localhost:9000.');
|
|
20
|
+
this.name = 'MissingMedusaUrlError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
14
23
|
let configured = null;
|
|
15
24
|
function clean(input) {
|
|
16
25
|
const out = {};
|
|
@@ -36,33 +45,38 @@ function fromEnv() {
|
|
|
36
45
|
googleMapsApiKey: env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY,
|
|
37
46
|
});
|
|
38
47
|
}
|
|
48
|
+
// Literal `process.env.NODE_ENV` so bundlers inline it; `process.env?.NODE_ENV` is not inlined.
|
|
49
|
+
function nodeEnv() {
|
|
50
|
+
try {
|
|
51
|
+
return process.env.NODE_ENV;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
39
57
|
function nodeEnvIsDevelopment() {
|
|
40
|
-
return
|
|
58
|
+
return nodeEnv() === 'development';
|
|
59
|
+
}
|
|
60
|
+
function resolve(input) {
|
|
61
|
+
if (!input.medusaUrl && nodeEnv() === 'production')
|
|
62
|
+
throw new MissingMedusaUrlError();
|
|
63
|
+
return {
|
|
64
|
+
...input,
|
|
65
|
+
medusaUrl: stripSlash(input.medusaUrl ?? DEV_MEDUSA_URL),
|
|
66
|
+
debug: input.debug ?? nodeEnvIsDevelopment(),
|
|
67
|
+
};
|
|
41
68
|
}
|
|
42
69
|
/**
|
|
43
70
|
* Sets the store configuration. Call it at module scope of the store's
|
|
44
71
|
* lib/amboras.ts. Calling it again merges: unset values keep what an earlier
|
|
45
|
-
* call (or the env fallback) gave.
|
|
72
|
+
* call (or the env fallback) gave. Never throws; a missing URL throws on first read.
|
|
46
73
|
*/
|
|
47
74
|
export function configureCore(input) {
|
|
48
|
-
|
|
49
|
-
configured = {
|
|
50
|
-
...merged,
|
|
51
|
-
medusaUrl: stripSlash(merged.medusaUrl ?? DEFAULT_MEDUSA_URL),
|
|
52
|
-
debug: merged.debug ?? nodeEnvIsDevelopment(),
|
|
53
|
-
};
|
|
54
|
-
return configured;
|
|
75
|
+
configured = { ...fromEnv(), ...(configured ?? {}), ...clean(input) };
|
|
55
76
|
}
|
|
56
|
-
/** The active configuration
|
|
77
|
+
/** The active configuration; throws {@link MissingMedusaUrlError} in production without a Medusa URL. */
|
|
57
78
|
export function getCoreConfig() {
|
|
58
|
-
|
|
59
|
-
return configured;
|
|
60
|
-
const env = fromEnv();
|
|
61
|
-
return {
|
|
62
|
-
...env,
|
|
63
|
-
medusaUrl: stripSlash(env.medusaUrl ?? DEFAULT_MEDUSA_URL),
|
|
64
|
-
debug: nodeEnvIsDevelopment(),
|
|
65
|
-
};
|
|
79
|
+
return resolve(configured ?? fromEnv());
|
|
66
80
|
}
|
|
67
81
|
/** True once the store called configureCore (the version-floor check reads this in dev). */
|
|
68
82
|
export function isCoreConfigured() {
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,yEAAyE;AACzE,gFAAgF;AAChF,uEAAuE;AACvE,2EAA2E;AAC3E,wDAAwD;AACxD,EAAE;AACF,+EAA+E;AAC/E,2EAA2E;AAC3E,2EAA2E;AAC3E,YAAY;AAsBZ,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"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"}
|
package/dist/entries/client.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { CoreProvider, type CoreProviderProps } from '../shell/core-provider.js';
|
|
2
2
|
export { ClientPluginSlot, type ClientPluginSlotProps } from '../shell/client-plugin-slot.js';
|
|
3
3
|
export { usePluginRegistry } from '../shell/registry-context.js';
|
|
4
|
+
export { type CoreHookOverrides, type HookOverride, type OverridableHook } from '../shell/overrides.js';
|
|
4
5
|
export { ErrorBoundary } from '../shell/error-boundary.js';
|
|
5
6
|
export { PaymentUiProvider, usePaymentUi, type PaymentUiComponents, type StripePaymentFormProps, type SavedMethodSelectorProps, type SaveMethodConsentProps, type PayPalSmartButtonsProps, } from '../lib/payment-providers/ui.js';
|
|
6
|
-
export { configureCore, getCoreConfig, type CoreConfig, type CoreConfigInput } from '../config/index.js';
|
|
7
|
+
export { configureCore, getCoreConfig, MissingMedusaUrlError, type CoreConfig, type CoreConfigInput, } from '../config/index.js';
|
|
7
8
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/entries/client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAChF,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,gCAAgC,CAAA;AACvC,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/entries/client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAChF,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAChE,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,KAAK,UAAU,EACf,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAA"}
|
package/dist/entries/client.js
CHANGED
|
@@ -6,5 +6,5 @@ export { ClientPluginSlot } from '../shell/client-plugin-slot.js';
|
|
|
6
6
|
export { usePluginRegistry } from '../shell/registry-context.js';
|
|
7
7
|
export { ErrorBoundary } from '../shell/error-boundary.js';
|
|
8
8
|
export { PaymentUiProvider, usePaymentUi, } from '../lib/payment-providers/ui.js';
|
|
9
|
-
export { configureCore, getCoreConfig } from '../config/index.js';
|
|
9
|
+
export { configureCore, getCoreConfig, MissingMedusaUrlError, } from '../config/index.js';
|
|
10
10
|
//# sourceMappingURL=client.js.map
|