@tanqory/theme-kit 2.0.0-alpha.17 → 2.0.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +4 -1
  2. package/dist/abi/canvas-live.d.ts +7 -2
  3. package/dist/abi/canvas-live.js +8 -3
  4. package/dist/abi/cart.d.ts +5 -4
  5. package/dist/abi/cart.js +14 -5
  6. package/dist/abi/convert.d.ts +18 -2
  7. package/dist/abi/convert.js +56 -4
  8. package/dist/abi/data-api.js +4 -0
  9. package/dist/abi/page-data.d.ts +11 -3
  10. package/dist/abi/page-data.js +71 -3
  11. package/dist/abi/wire.d.ts +8 -0
  12. package/dist/abi/wire.js +32 -2
  13. package/dist/build.d.ts +7 -2
  14. package/dist/build.js +96 -5
  15. package/dist/chunks.d.ts +23 -0
  16. package/dist/chunks.js +41 -0
  17. package/dist/client.d.ts +7 -0
  18. package/dist/client.js +16 -2
  19. package/dist/headless/hooks.js +5 -1
  20. package/dist/headless/index.d.ts +8 -1
  21. package/dist/headless/index.js +11 -1
  22. package/dist/headless/lazy-component.d.ts +72 -0
  23. package/dist/headless/lazy-component.js +225 -0
  24. package/dist/headless/lazy-section.d.ts +38 -0
  25. package/dist/headless/lazy-section.js +97 -0
  26. package/dist/headless/model.d.ts +73 -0
  27. package/dist/headless/model.js +115 -0
  28. package/dist/headless/money.d.ts +1 -9
  29. package/dist/headless/money.js +24 -22
  30. package/dist/headless/page.d.ts +2 -0
  31. package/dist/headless/primitives/storefront.js +2 -1
  32. package/dist/headless/strings.js +8 -0
  33. package/dist/headless/tanqory-money.generated.d.ts +493 -0
  34. package/dist/headless/tanqory-money.generated.js +507 -0
  35. package/dist/headless/theme.d.ts +13 -3
  36. package/dist/headless/theme.js +12 -4
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.js +3 -0
  39. package/dist/runtime/data/StoreProvider.js +10 -3
  40. package/dist/runtime/data/to-ui.d.ts +12 -7
  41. package/dist/runtime/data/to-ui.js +48 -16
  42. package/dist/runtime/kit/cart.d.ts +10 -3
  43. package/dist/runtime/kit/contract/content.d.ts +14 -0
  44. package/dist/runtime/kit/contract/content.js +13 -0
  45. package/dist/runtime/kit/contract/field-types.d.ts +26 -3
  46. package/dist/runtime/kit/contract/field-types.js +11 -1
  47. package/dist/runtime/kit/contract/validate.d.ts +2 -0
  48. package/dist/runtime/kit/contract/validate.js +49 -9
  49. package/dist/runtime/kit/data.d.ts +12 -0
  50. package/dist/runtime/kit/data.js +36 -22
  51. package/dist/runtime/kit/dynamic-source.d.ts +12 -0
  52. package/dist/runtime/kit/dynamic-source.js +17 -0
  53. package/dist/runtime/kit/storefront.d.ts +14 -1
  54. package/dist/runtime/kit/types.d.ts +8 -0
  55. package/dist/runtime/render/SectionRenderer.js +44 -11
  56. package/dist/runtime/render/resolved.d.ts +47 -0
  57. package/dist/runtime/render/resolved.js +80 -0
  58. package/dist/runtime/render/section-actions.d.ts +2 -1
  59. package/dist/runtime/render/section-actions.js +4 -1
  60. package/dist/runtime/render/starter.js +19 -4
  61. package/dist/runtime/seo/head.d.ts +1 -1
  62. package/dist/runtime/shell/PageShell.js +6 -1
  63. package/dist/runtime/shell/RuntimeBridge.d.ts +4 -0
  64. package/dist/runtime/shell/RuntimeBridge.js +37 -6
  65. package/dist/runtime/slots.d.ts +1 -1
  66. package/dist/sdk/font-hooks.d.ts +7 -0
  67. package/dist/sdk/font-hooks.js +21 -0
  68. package/dist/sdk/fonts.d.ts +144 -0
  69. package/dist/sdk/fonts.js +241 -0
  70. package/dist/sdk/index.d.ts +7 -1
  71. package/dist/sdk/index.js +11 -1
  72. package/dist/sdk/motion-hooks.d.ts +23 -0
  73. package/dist/sdk/motion-hooks.js +46 -0
  74. package/dist/sdk/motion.d.ts +78 -0
  75. package/dist/sdk/motion.js +292 -0
  76. package/dist/sdk/runtime-context.d.ts +32 -4
  77. package/dist/sdk/schema.d.ts +47 -4
  78. package/dist/sdk/schema.js +47 -0
  79. package/dist/sdk/store-lookup.d.ts +5 -0
  80. package/dist/sdk/store-lookup.js +19 -0
  81. package/dist/sdk/store.d.ts +15 -0
  82. package/dist/sdk/sx.d.ts +5 -0
  83. package/dist/sdk/sx.js +7 -2
  84. package/dist/sdk/theme.d.ts +21 -0
  85. package/dist/sdk/theme.js +17 -0
  86. package/dist/sdk/types.d.ts +36 -4
  87. package/dist/server.d.ts +5 -4
  88. package/dist/server.js +76 -20
  89. package/dist/vite-chunks.d.ts +10 -0
  90. package/dist/vite-chunks.js +44 -0
  91. package/docs/headless-api.md +33 -3
  92. package/package.json +10 -18
@@ -0,0 +1,507 @@
1
+ // @ts-nocheck
2
+ // GENERATED from packages/money/index.js by tools/money/vendor.mjs. Do not edit: change the package and run the tool.
3
+ /**
4
+ * @tanqory/money: the one currency table and the one money arithmetic of the platform (docs/STANDARDS.md API-6).
5
+ *
6
+ * - Digits per currency are ISO 4217's minor units, from the maintenance agency's list one (SIX, published
7
+ * 2026-09-17, ISO_4217 below). Nothing else decides how many digits an amount has: not Intl (CLDR's display digits
8
+ * differ for IQD, LBP, RSD, AFN, ...), not a provider's list.
9
+ * - A payment provider that counts some currency in another exponent (Stripe sends ISK as two decimals "00") is a
10
+ * documented entry of PROVIDER_UNITS here, with its source, and is only used at that provider's boundary.
11
+ * - Amounts are decimal strings ("12.34", "1200", "1.250") or integer minor units at a provider boundary. The
12
+ * arithmetic here is exact (BigInt scaled integers), never a JS number: a JSON number is an IEEE 754 binary64
13
+ * (RFC 8259 §6), and 0.1 + 0.2 is not 0.3 in it.
14
+ * - Rounding is half up (away from zero at the half, as Prisma.Decimal ROUND_HALF_UP and DATABASE_STANDARD 3.5's
15
+ * roundMoney) unless the caller names another mode.
16
+ *
17
+ * Zero dependencies; runs on Node, Workers, browsers and Next. The api keeps Prisma.Decimal for its own arithmetic
18
+ * (API-6 allows a decimal type) and takes its digits and provider units from here.
19
+ */
20
+ /** Where the table comes from. Re-check against list one when SIX publishes a new one (amendments are rare). */
21
+ const ISO_4217 = Object.freeze({
22
+ source: 'https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list-one.xml',
23
+ published: '2026-09-17',
24
+ read: '2026-11-19',
25
+ });
26
+ const DIGITS_0 = ['BIF', 'CLP', 'DJF', 'GNF', 'ISK', 'JPY', 'KMF', 'KRW', 'PYG', 'RWF', 'UGX', 'UYI', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'];
27
+ const DIGITS_3 = ['BHD', 'IQD', 'JOD', 'KWD', 'LYD', 'OMR', 'TND'];
28
+ const DIGITS_4 = ['CLF', 'UYW'];
29
+ const DIGITS_2 = [
30
+ 'AED', 'AFN', 'ALL', 'AMD', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD', 'BDT', 'BMD', 'BND', 'BOB', 'BOV', 'BRL',
31
+ 'BSD', 'BTN', 'BWP', 'BYN', 'BZD', 'CAD', 'CDF', 'CHE', 'CHF', 'CHW', 'CNY', 'COP', 'COU', 'CRC', 'CUP', 'CVE', 'CZK',
32
+ 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GTQ', 'GYD', 'HKD',
33
+ 'HNL', 'HTG', 'HUF', 'IDR', 'ILS', 'INR', 'IRR', 'JMD', 'KES', 'KGS', 'KHR', 'KPW', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR',
34
+ 'LRD', 'LSL', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRU', 'MUR', 'MVR', 'MWK', 'MXN', 'MXV', 'MYR', 'MZN',
35
+ 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'QAR', 'RON', 'RSD', 'RUB', 'SAR',
36
+ 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLE', 'SOS', 'SRD', 'SSP', 'STN', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMT',
37
+ 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'USD', 'USN', 'UYU', 'UZS', 'VED', 'VES', 'WST', 'XAD', 'XCD', 'XCG', 'YER',
38
+ 'ZAR', 'ZMW', 'ZWG',
39
+ ];
40
+ /** List one's codes with no minor unit ("N.A."): funds, metals, the test and "no currency" codes. Not prices. */
41
+ const NO_MINOR_UNIT = Object.freeze(['XAG', 'XAU', 'XBA', 'XBB', 'XBC', 'XBD', 'XDR', 'XPD', 'XPT', 'XSU', 'XTS', 'XUA', 'XXX']);
42
+ /** Every ISO 4217 currency with a minor unit, and its digits. */
43
+ const CURRENCY_DIGITS = Object.freeze(Object.fromEntries([
44
+ ...DIGITS_0.map((c) => [c, 0]),
45
+ ...DIGITS_2.map((c) => [c, 2]),
46
+ ...DIGITS_3.map((c) => [c, 3]),
47
+ ...DIGITS_4.map((c) => [c, 4]),
48
+ ]));
49
+ const normal = (code) => String(code == null ? '' : code).trim().toUpperCase();
50
+ /** The currency's ISO 4217 minor unit: JPY 0, USD 2, KWD 3, CLF 4. An unknown code, or one with none, is 2. */
51
+ function currencyDigits(code) {
52
+ const d = CURRENCY_DIGITS[normal(code)];
53
+ return d === undefined ? 2 : d;
54
+ }
55
+ /** True for a list-one code that is a currency with a minor unit (a price can be in it). */
56
+ function isCurrencyCode(code) {
57
+ return CURRENCY_DIGITS[normal(code)] !== undefined;
58
+ }
59
+ /**
60
+ * Display only: the currencies a price is shown in whole units although ISO 4217 gives them 2 digits. The amount keeps
61
+ * its ISO digits everywhere it is computed, stored, charged or sent; only formatting for a reader drops the fraction.
62
+ * Source: CLDR common/supplemental/supplementalData.xml <currencyData> (unicode-org/cldr main, read 2026-11-19):
63
+ * HUF digits="0", IDR digits="0", TWD cashDigits="0" (TWD digits="2"). The list is these three on purpose: the other
64
+ * currencies CLDR shows with fewer digits than ISO (IQD 0, LBP 0, ...) are shown in ISO's digits, so a shopper sees the
65
+ * amount they are charged.
66
+ */
67
+ const DISPLAY_WHOLE_UNITS = Object.freeze(['HUF', 'IDR', 'TWD']);
68
+ /** The fraction digits a price is shown with: 0 for DISPLAY_WHOLE_UNITS, else currencyDigits (JPY 0, USD 2, KWD 3). */
69
+ function displayDigits(code) {
70
+ return DISPLAY_WHOLE_UNITS.includes(normal(code)) ? 0 : currencyDigits(code);
71
+ }
72
+ /**
73
+ * The amount as a reader sees it, exact: rounded half up to displayDigits ("1234.5" JPY "1235", KWD "1234.500", IDR
74
+ * "1235"); grouping and the symbol are the formatter's. Throws InvalidAmountError when the amount is not a decimal.
75
+ */
76
+ function displayAmount(amount, code) {
77
+ return toFixedDigits(amount, displayDigits(code));
78
+ }
79
+ /**
80
+ * How a provider counts a currency where it differs from ISO 4217. `exponent`: the power of ten of its integer unit
81
+ * (the amount it is sent is amount x 10^exponent). `precision`: the digits an amount may have for it (rounded to these
82
+ * first). A currency absent from a provider's entry takes the entry's '*' when it has one (the provider's stated
83
+ * default), else ISO's: exponent = precision = currencyDigits.
84
+ *
85
+ * Each entry names its source. "existing adapter" entries were in an adapter before 2026-11-19 with the citation its
86
+ * file gave; they moved here unchanged (API-6: no second table in an adapter).
87
+ */
88
+ const u = (exponent, precision) => Object.freeze({ exponent, precision });
89
+ const whole = (codes, unit) => Object.fromEntries(codes.map((c) => [c, unit]));
90
+ /** https://docs.stripe.com/currencies, "Zero-decimal currencies" (read 2026-11-19). */
91
+ const STRIPE_ZERO_DECIMAL = ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'];
92
+ const STRIPE_THREE_DECIMAL = ['BHD', 'JOD', 'KWD', 'OMR', 'TND'];
93
+ const PROVIDER_UNITS = Object.freeze({
94
+ // https://docs.stripe.com/currencies (read 2026-11-19): "Currencies are two-decimal currencies unless otherwise
95
+ // specified" ('*'), the zero-decimal list above, and the special cases: ISK and UGX "require you to represent it as
96
+ // a two-decimal value, where the decimal amount is always 00". UGX is also on the zero-decimal list; Stripe's API
97
+ // settled it (test mode, 2026-11-19): amount 2000 ugx is "20.00 USh", and 2050 is refused, "charged amounts must be
98
+ // evenly divisible by 100"; the same for ISK. MGA 5000 is accepted as 5000 MGA. HUF and TWD differ only for payouts
99
+ // (stripe_payout). Three-decimal currencies are charged in thousandths ending in 0: the rule the api followed before
100
+ // 2026-11-19; the page read on 2026-11-19 has no three-decimal section and the Dev (US) account does not take KWD or
101
+ // BHD, so it is not re-proven (open, lane SD report).
102
+ stripe: Object.freeze({
103
+ '*': u(2, 2),
104
+ ...whole(STRIPE_ZERO_DECIMAL, u(0, 0)),
105
+ ...whole(STRIPE_THREE_DECIMAL, u(3, 2)),
106
+ ISK: u(2, 0),
107
+ UGX: u(2, 0),
108
+ }),
109
+ // https://docs.stripe.com/currencies, "Special cases": HUF and TWD are zero-decimal "for payouts", sent as integers
110
+ // "evenly divisible by 100". The rest as for charges.
111
+ stripe_payout: Object.freeze({
112
+ '*': u(2, 2),
113
+ ...whole(STRIPE_ZERO_DECIMAL, u(0, 0)),
114
+ ...whole(STRIPE_THREE_DECIMAL, u(3, 2)),
115
+ ISK: u(2, 0),
116
+ UGX: u(2, 0),
117
+ HUF: u(2, 0),
118
+ TWD: u(2, 0),
119
+ }),
120
+ // existing adapter (providers/payments/paypal/adapter.ts, before 2026-11-19): HUF, JPY and TWD take no decimals,
121
+ // every other currency two.
122
+ paypal: Object.freeze({ '*': u(2, 2), HUF: u(0, 0), JPY: u(0, 0), TWD: u(0, 0) }),
123
+ // existing adapter (providers/payments/omise/adapter.ts, before 2026-11-19): JPY has none, every other currency two.
124
+ omise: Object.freeze({ '*': u(2, 2), JPY: u(0, 0) }),
125
+ // existing adapters, each header's source: ABA PayWay KHR whole riel; Barion HUF whole forint; Checkout.com CLP in
126
+ // cents; NewebPay and TapPay TWD whole dollars; NICEPAY IDR whole rupiah; VNPAY VND x 100. Checkout.com and VNPAY
127
+ // took two-decimal amounts for these before 2026-11-19 (digits override 2), so precision stays 2. Every other
128
+ // currency: ISO 4217.
129
+ aba_payway: Object.freeze({ KHR: u(0, 0) }),
130
+ barion: Object.freeze({ HUF: u(0, 0) }),
131
+ checkout_com: Object.freeze({ CLP: u(2, 2) }),
132
+ newebpay: Object.freeze({ TWD: u(0, 0) }),
133
+ tappay: Object.freeze({ TWD: u(0, 0) }),
134
+ nicepay: Object.freeze({ IDR: u(0, 0) }),
135
+ vnpay: Object.freeze({ VND: u(2, 2) }),
136
+ // https://docs.midtrans.com/reference/json-objects (read 2026-11-19): transaction_details.gross_amount is an Integer,
137
+ // "Amount to be charged", IDR only: whole rupiah.
138
+ midtrans: Object.freeze({ IDR: u(0, 0) }),
139
+ // https://tripay.co.id/developer (Request Transaksi Closed Payment, read 2026-11-20): `amount` is an int, whole rupiah
140
+ // (the example 1000000 for Rp 1.000.000; the order_items prices the same).
141
+ tripay: Object.freeze({ IDR: u(0, 0) }),
142
+ // https://docs.globalgetnet.com/en/products/online-payments/web-checkout/swagger (Web Checkout API 1.7.0, read
143
+ // 2026-11-20): "Amounts are integers where the last two digits represent the cents (for example, `9990` represents BRL
144
+ // 99.90). For currencies without cents, fill the last two digits with zeros." CLP (no minor unit in ISO 4217) is whole
145
+ // pesos times 100; every other currency ISO's two digits.
146
+ getnet: Object.freeze({ CLP: u(2, 0) }),
147
+ });
148
+ for (const [name, table] of Object.entries(PROVIDER_UNITS)) {
149
+ for (const [code, unit] of Object.entries(table)) {
150
+ if (!(unit.exponent >= unit.precision))
151
+ throw new Error(`@tanqory/money: PROVIDER_UNITS.${name}.${code}: exponent below precision`);
152
+ }
153
+ }
154
+ /**
155
+ * The currencies a provider prices in, where its docs publish a closed list and its adapter refuses any other currency
156
+ * before a request (API-6: the list lives here beside PROVIDER_UNITS, never as a table in an adapter). Each entry names
157
+ * its source; the order is the docs' (an adapter's refusal lists them in it). Units stay ISO 4217's unless
158
+ * PROVIDER_UNITS says otherwise.
159
+ */
160
+ const PROVIDER_CURRENCIES = Object.freeze({
161
+ // https://pay-docs.crypto.com/#api-reference-resources, Pricing Currencies (the list its adapter carried before
162
+ // 2026-11-20): the fiat currencies a payment is priced in, 0.01 the smallest unit except CLP, JPY and KRW (1), as ISO.
163
+ crypto_com_pay: Object.freeze([
164
+ 'USD', 'EUR', 'AUD', 'CAD', 'GBP', 'BGN', 'BRL', 'CHF', 'CLP', 'CNY', 'COP', 'DKK', 'HKD', 'IDR', 'INR', 'JPY', 'KRW',
165
+ 'MDL', 'MOP', 'MXN', 'MYR', 'NOK', 'PHP', 'RON', 'RUB', 'SAR', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'UAH', 'ZAR',
166
+ ]),
167
+ // https://developer.fastspring.com/reference/createsession, PriceMap (the list its adapter carried before 2026-11-20):
168
+ // the currencies a custom price may be in.
169
+ fastspring: Object.freeze([
170
+ 'AED', 'ARS', 'AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'COP', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR',
171
+ 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PEN', 'PHP', 'PLN', 'RUB', 'SAR', 'SEK', 'SGD', 'THB', 'TRY', 'TWD',
172
+ 'USD', 'VND', 'ZAR',
173
+ ]),
174
+ // https://developer.paddle.com/concepts/sell/supported-currencies (the list its adapter carried before 2026-11-20):
175
+ // the currencies a transaction may be in.
176
+ paddle: Object.freeze([
177
+ 'USD', 'GBP', 'EUR', 'ARS', 'AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'COP', 'CZK', 'DKK', 'HKD', 'HUF', 'ILS',
178
+ 'INR', 'JPY', 'KRW', 'MXN', 'NOK', 'NZD', 'PEN', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'UAH', 'VND', 'ZAR',
179
+ ]),
180
+ // https://developers.upayments.com/reference/multi-currency (the list its adapter carried before 2026-11-20): what
181
+ // UInterfaceV2 takes (other than KWD once UPayments enables multi-currency for the account), each at its ISO 4217
182
+ // digits (KWD, BHD, OMR and JOD three).
183
+ upayments: Object.freeze(['KWD', 'SAR', 'USD', 'BHD', 'EUR', 'OMR', 'QAR', 'AED', 'INR', 'GBP', 'JOD']),
184
+ });
185
+ for (const [name, list] of Object.entries(PROVIDER_CURRENCIES)) {
186
+ for (const code of list) {
187
+ // A three-letter code, not necessarily on today's list one: a provider may still list a withdrawn code (BGN left
188
+ // list one when Bulgaria took the euro), which then counts with currencyDigits' default.
189
+ if (!/^[A-Z]{3}$/.test(code))
190
+ throw new Error(`@tanqory/money: PROVIDER_CURRENCIES.${name}: ${code} is not a currency code`);
191
+ }
192
+ }
193
+ /** The currencies a provider of PROVIDER_CURRENCIES prices in, in its docs' order. */
194
+ function providerCurrencies(provider) {
195
+ const list = PROVIDER_CURRENCIES[provider];
196
+ if (!list)
197
+ throw new Error(`@tanqory/money: no provider "${provider}" in PROVIDER_CURRENCIES`);
198
+ return list;
199
+ }
200
+ /** True when the provider prices in the currency (case- and space-insensitive). */
201
+ function providerTakes(provider, code) {
202
+ return providerCurrencies(provider).includes(normal(code));
203
+ }
204
+ /** The units a provider counts a currency in (ISO's when the provider has no entry for it). */
205
+ function providerUnits(provider, code) {
206
+ const c = normal(code);
207
+ if (provider) {
208
+ const table = PROVIDER_UNITS[provider];
209
+ if (!table)
210
+ throw new Error(`@tanqory/money: no provider "${provider}" in PROVIDER_UNITS`);
211
+ if (table[c])
212
+ return table[c];
213
+ if (table['*'])
214
+ return table['*'];
215
+ }
216
+ const d = currencyDigits(c);
217
+ return { exponent: d, precision: d };
218
+ }
219
+ // ─── exact decimals ──────────────────────────────────────────────────────────────────────────────────────────────────
220
+ const DECIMAL = /^([+-])?(\d+)?(?:\.(\d*))?(?:[eE]([+-]?\d+))?$/;
221
+ /** The largest exponent an amount's text may carry (1e40 is far past any money). */
222
+ const MAX_EXPONENT = 40;
223
+ class InvalidAmountError extends Error {
224
+ constructor(value) {
225
+ super(`@tanqory/money: not a decimal amount: ${String(value).slice(0, 40)}`);
226
+ this.name = 'InvalidAmountError';
227
+ }
228
+ }
229
+ class InexactAmountError extends Error {
230
+ constructor(amount, currency) {
231
+ super(`amount ${amount} ${currency} has no exact value in the provider's unit`);
232
+ this.name = 'InexactAmountError';
233
+ }
234
+ }
235
+ /**
236
+ * A decimal as { n: BigInt, s: scale } (value = n / 10^s). Takes a decimal string, a finite number (read through its
237
+ * shortest round-trip text, so 0.1 is "0.1"), a BigInt, or a decimal object (Prisma.Decimal / decimal.js: toFixed()).
238
+ */
239
+ function parse(value) {
240
+ let text;
241
+ if (typeof value === 'bigint')
242
+ return { n: value, s: 0 };
243
+ if (typeof value === 'number') {
244
+ if (!Number.isFinite(value))
245
+ throw new InvalidAmountError(value);
246
+ text = String(value);
247
+ }
248
+ else if (typeof value === 'string') {
249
+ text = value.trim();
250
+ }
251
+ else if (value && typeof value.toFixed === 'function' && typeof value.isFinite === 'function') {
252
+ if (!value.isFinite())
253
+ throw new InvalidAmountError(value);
254
+ text = value.toFixed();
255
+ }
256
+ else {
257
+ throw new InvalidAmountError(value);
258
+ }
259
+ // A text longer than any amount, or an exponent past MAX_EXPONENT, is refused before any BigInt is built: 10n ** 3e8n
260
+ // would block the process (a provider's answer reaches here).
261
+ if (text.length > 100)
262
+ throw new InvalidAmountError(value);
263
+ const m = DECIMAL.exec(text);
264
+ if (!m || (m[2] === undefined && (m[3] === undefined || m[3] === '')))
265
+ throw new InvalidAmountError(value);
266
+ if (m[4] && Math.abs(Number(m[4])) > MAX_EXPONENT)
267
+ throw new InvalidAmountError(value);
268
+ const frac = m[3] || '';
269
+ let n = BigInt((m[2] || '0') + frac);
270
+ let s = frac.length - (m[4] ? Number(m[4]) : 0);
271
+ if (s < 0) {
272
+ n *= 10n ** BigInt(-s);
273
+ s = 0;
274
+ }
275
+ if (m[1] === '-')
276
+ n = -n;
277
+ return { n, s };
278
+ }
279
+ const pow10 = (k) => 10n ** BigInt(k);
280
+ const abs = (x) => (x < 0n ? -x : x);
281
+ /** n / 10^s at scale t (t >= s): exact. */
282
+ function rescale(d, t) {
283
+ return d.n * pow10(t - d.s);
284
+ }
285
+ const MODES = ['half_up', 'half_even', 'half_down', 'up', 'down', 'ceil', 'floor'];
286
+ const ROUNDING_MODES = Object.freeze(MODES.slice());
287
+ /** BigInt division q = n / m rounded by `mode` (m > 0). */
288
+ function divRound(n, m, mode) {
289
+ const q = n / m; // truncated toward zero
290
+ const r = n - q * m;
291
+ if (r === 0n)
292
+ return q;
293
+ const neg = n < 0n;
294
+ const away = neg ? q - 1n : q + 1n;
295
+ const twice = abs(r) * 2n;
296
+ switch (mode) {
297
+ case 'down': return q;
298
+ case 'up': return away;
299
+ case 'floor': return neg ? away : q;
300
+ case 'ceil': return neg ? q : away;
301
+ case 'half_up': return twice >= m ? away : q;
302
+ case 'half_down': return twice > m ? away : q;
303
+ case 'half_even': return twice > m || (twice === m && (abs(q) % 2n === 1n)) ? away : q;
304
+ default: throw new Error(`@tanqory/money: rounding mode must be one of ${MODES.join(', ')}`);
305
+ }
306
+ }
307
+ /** The value rounded to `digits` decimals (mode default half_up), as BigInt units of 10^-digits. */
308
+ function unitsAt(value, digits, mode = 'half_up') {
309
+ if (!MODES.includes(mode))
310
+ throw new Error(`@tanqory/money: rounding mode must be one of ${MODES.join(', ')}`);
311
+ const d = parse(value);
312
+ if (d.s <= digits)
313
+ return d.n * pow10(digits - d.s);
314
+ return divRound(d.n, pow10(d.s - digits), mode);
315
+ }
316
+ /** BigInt units of 10^-digits as a decimal string with exactly `digits` decimals ("-0.05", "1200", "1.250"). */
317
+ function unitsText(units, digits) {
318
+ const neg = units < 0n;
319
+ const s = abs(units).toString().padStart(digits + 1, '0');
320
+ const out = digits ? `${s.slice(0, -digits)}.${s.slice(-digits)}` : s;
321
+ return neg && units !== 0n ? `-${out}` : out;
322
+ }
323
+ /** The value as a decimal string with exactly `digits` decimals, rounded by `mode` (half_up). */
324
+ function toFixedDigits(value, digits, mode = 'half_up') {
325
+ if (!Number.isInteger(digits) || digits < 0 || digits > 18)
326
+ throw new RangeError('@tanqory/money: digits must be 0-18');
327
+ return unitsText(unitsAt(value, digits, mode), digits);
328
+ }
329
+ /** The amount rounded to its currency's ISO 4217 digits: "12.35" (USD), "1235" (JPY), "1.235" (KWD). */
330
+ function roundMoney(amount, currency, mode = 'half_up') {
331
+ return toFixedDigits(amount, currencyDigits(currency), mode);
332
+ }
333
+ /** The exact value as the shortest decimal string ("1.5", "-0.25", "3"). */
334
+ function decimalText(value) {
335
+ const d = parse(value);
336
+ let { n, s } = d;
337
+ while (s > 0 && n % 10n === 0n) {
338
+ n /= 10n;
339
+ s -= 1;
340
+ }
341
+ return unitsText(n, s);
342
+ }
343
+ /** a + b, exact. */
344
+ function add(a, b) {
345
+ const x = parse(a), y = parse(b);
346
+ const t = Math.max(x.s, y.s);
347
+ return decimalText(unitsText(rescale(x, t) + rescale(y, t), t));
348
+ }
349
+ /** a - b, exact. */
350
+ function sub(a, b) {
351
+ const x = parse(a), y = parse(b);
352
+ const t = Math.max(x.s, y.s);
353
+ return decimalText(unitsText(rescale(x, t) - rescale(y, t), t));
354
+ }
355
+ /** a x b, exact (a quantity, a rate or a ratio as b). */
356
+ function mul(a, b) {
357
+ const x = parse(a), y = parse(b);
358
+ return decimalText(unitsText(x.n * y.n, x.s + y.s));
359
+ }
360
+ /** The sum of a list, exact ("0" for none). */
361
+ function sum(values) {
362
+ let acc = '0';
363
+ for (const v of values)
364
+ acc = add(acc, v);
365
+ return acc;
366
+ }
367
+ /** -1, 0 or 1 as a is below, equal to or above b. */
368
+ function compare(a, b) {
369
+ const x = parse(a), y = parse(b);
370
+ const t = Math.max(x.s, y.s);
371
+ const l = rescale(x, t), r = rescale(y, t);
372
+ return l < r ? -1 : l > r ? 1 : 0;
373
+ }
374
+ function isZero(a) {
375
+ return parse(a).n === 0n;
376
+ }
377
+ function negate(a) {
378
+ return decimalText(unitsText(-parse(a).n, parse(a).s));
379
+ }
380
+ /** a / b rounded to `digits` decimals by `mode` (half_up). b must not be 0. */
381
+ function div(a, b, digits, mode = 'half_up') {
382
+ const x = parse(a), y = parse(b);
383
+ if (y.n === 0n)
384
+ throw new RangeError('@tanqory/money: division by zero');
385
+ // a/b = (x.n / 10^x.s) / (y.n / 10^y.s); scaled to 10^digits.
386
+ let num = x.n * pow10(digits + y.s);
387
+ let den = y.n * pow10(x.s);
388
+ if (den < 0n) {
389
+ num = -num;
390
+ den = -den;
391
+ }
392
+ return unitsText(divRound(num, den, mode), digits);
393
+ }
394
+ /** `pct` percent of the amount, rounded to the currency's digits by `mode` (half_up): percentOf("19.99", "7", "USD") = "1.40". */
395
+ function percentOf(amount, pct, currency, mode = 'half_up') {
396
+ return div(mul(amount, pct), '100', currencyDigits(currency), mode);
397
+ }
398
+ /**
399
+ * The amount split in proportion to `weights` (decimal strings or numbers >= 0), each part in the currency's digits,
400
+ * the parts summing exactly to the amount rounded to the currency (largest remainder; ties go to the earlier part).
401
+ */
402
+ function allocate(amount, weights, currency) {
403
+ const d = currencyDigits(currency);
404
+ const total = unitsAt(amount, d);
405
+ const ws = weights.map((w) => parse(w));
406
+ if (!ws.length)
407
+ return [];
408
+ if (ws.some((w) => w.n < 0n))
409
+ throw new RangeError('@tanqory/money: weights must be >= 0');
410
+ const t = Math.max(...ws.map((w) => w.s));
411
+ const wi = ws.map((w) => rescale(w, t));
412
+ const wsum = wi.reduce((a, b) => a + b, 0n);
413
+ if (wsum === 0n)
414
+ throw new RangeError('@tanqory/money: weights must not all be 0');
415
+ const sign = total < 0n ? -1n : 1n;
416
+ const T = abs(total);
417
+ const parts = wi.map((w) => (T * w) / wsum);
418
+ const rems = wi.map((w, i) => ({ i, r: T * w - parts[i] * wsum }));
419
+ let left = T - parts.reduce((a, b) => a + b, 0n);
420
+ rems.sort((a, b) => (a.r === b.r ? a.i - b.i : a.r > b.r ? -1 : 1));
421
+ for (let k = 0; left > 0n; k++, left--)
422
+ parts[rems[k % rems.length].i] += 1n;
423
+ return parts.map((p) => unitsText(sign * p, d));
424
+ }
425
+ // ─── provider boundary ───────────────────────────────────────────────────────────────────────────────────────────────
426
+ /**
427
+ * The amount as the integer a provider is sent: rounded to the currency's precision for that provider (half up),
428
+ * times 10^exponent. ISO's digits when `opts.provider` is absent. Throws InexactAmountError when the result is not a
429
+ * safe integer, or when `opts.exact` and the amount had more digits than the precision (never charge a near amount).
430
+ */
431
+ function toMinorUnits(amount, currency, opts = {}) {
432
+ const u = providerUnits(opts.provider, currency);
433
+ const d = parse(amount);
434
+ if (opts.exact && d.s > u.precision && d.n % pow10(d.s - u.precision) !== 0n)
435
+ throw new InexactAmountError(String(amount), normal(currency));
436
+ const units = unitsAt(amount, u.precision, opts.mode || 'half_up');
437
+ const minor = units * pow10(u.exponent - u.precision);
438
+ if (abs(minor) > BigInt(Number.MAX_SAFE_INTEGER))
439
+ throw new InexactAmountError(String(amount), normal(currency));
440
+ return Number(minor);
441
+ }
442
+ /**
443
+ * A provider's integer amount back to a decimal string in the currency's ISO digits ("10.50", "1050", "1.050").
444
+ * Not an integer: InvalidAmountError. More digits than ISO has (a provider's sub-unit): kept exact, not rounded.
445
+ */
446
+ function fromMinorUnits(minor, currency, opts = {}) {
447
+ const raw = typeof minor === 'string' ? minor.trim() : minor;
448
+ if (typeof raw === 'number' && !Number.isSafeInteger(raw))
449
+ throw new InvalidAmountError(minor);
450
+ if (typeof raw === 'string' && !/^[+-]?\d{1,30}$/.test(raw))
451
+ throw new InvalidAmountError(minor);
452
+ if (typeof raw !== 'number' && typeof raw !== 'string' && typeof raw !== 'bigint')
453
+ throw new InvalidAmountError(minor);
454
+ const u = providerUnits(opts.provider, currency);
455
+ const n = BigInt(raw);
456
+ const iso = currencyDigits(currency);
457
+ const exact = { n, s: u.exponent };
458
+ // In the ISO digits when that loses nothing, else every digit the provider sent.
459
+ const atIso = iso >= u.exponent ? n * pow10(iso - u.exponent) : n % pow10(u.exponent - iso) === 0n ? n / pow10(u.exponent - iso) : null;
460
+ return atIso === null ? unitsText(exact.n, exact.s) : unitsText(atIso, iso);
461
+ }
462
+ /**
463
+ * The local currency of each country (ISO 3166-1 alpha-2 → ISO 4217), for every CountryCode value of the Admin API but
464
+ * ZZ ("unknown region", no currency). Used by the markets domain (a market's currency follows its countries;
465
+ * MarketRegionCountry.currency when a market sells in local currencies), by store creation and by platform billing.
466
+ * Not stated by any standard: a country whose own currency is not a CurrencyCode value (CU, KP, ZW) uses USD.
467
+ */
468
+ const COUNTRY_CURRENCY = Object.freeze({
469
+ AF: 'AFN', AX: 'EUR', AL: 'ALL', DZ: 'DZD', AD: 'EUR', AO: 'AOA', AI: 'XCD', AG: 'XCD', AR: 'ARS', AM: 'AMD', AW: 'AWG',
470
+ AC: 'SHP', AU: 'AUD', AT: 'EUR', AZ: 'AZN', BS: 'BSD', BH: 'BHD', BD: 'BDT', BB: 'BBD', BY: 'BYN', BE: 'EUR', BZ: 'BZD',
471
+ BJ: 'XOF', BM: 'BMD', BT: 'BTN', BO: 'BOB', BA: 'BAM', BW: 'BWP', BV: 'NOK', BR: 'BRL', IO: 'USD', BN: 'BND', BG: 'EUR',
472
+ BF: 'XOF', BI: 'BIF', KH: 'KHR', CA: 'CAD', CV: 'CVE', BQ: 'USD', KY: 'KYD', CF: 'XAF', TD: 'XAF', CL: 'CLP', CN: 'CNY',
473
+ CX: 'AUD', CC: 'AUD', CO: 'COP', KM: 'KMF', CG: 'XAF', CD: 'CDF', CK: 'NZD', CR: 'CRC', HR: 'EUR', CU: 'USD', CW: 'XCG',
474
+ CY: 'EUR', CZ: 'CZK', CI: 'XOF', DK: 'DKK', DJ: 'DJF', DM: 'XCD', DO: 'DOP', EC: 'USD', EG: 'EGP', SV: 'USD', GQ: 'XAF',
475
+ ER: 'ERN', EE: 'EUR', SZ: 'SZL', ET: 'ETB', FK: 'FKP', FO: 'DKK', FJ: 'FJD', FI: 'EUR', FR: 'EUR', GF: 'EUR', PF: 'XPF',
476
+ TF: 'EUR', GA: 'XAF', GM: 'GMD', GE: 'GEL', DE: 'EUR', GH: 'GHS', GI: 'GIP', GR: 'EUR', GL: 'DKK', GD: 'XCD', GP: 'EUR',
477
+ GT: 'GTQ', GG: 'GBP', GN: 'GNF', GW: 'XOF', GY: 'GYD', HT: 'HTG', HM: 'AUD', VA: 'EUR', HN: 'HNL', HK: 'HKD', HU: 'HUF',
478
+ IS: 'ISK', IN: 'INR', ID: 'IDR', IR: 'IRR', IQ: 'IQD', IE: 'EUR', IM: 'GBP', IL: 'ILS', IT: 'EUR', JM: 'JMD', JP: 'JPY',
479
+ JE: 'GBP', JO: 'JOD', KZ: 'KZT', KE: 'KES', KI: 'AUD', KP: 'USD', XK: 'EUR', KW: 'KWD', KG: 'KGS', LA: 'LAK', LV: 'EUR',
480
+ LB: 'LBP', LS: 'LSL', LR: 'LRD', LY: 'LYD', LI: 'CHF', LT: 'EUR', LU: 'EUR', MO: 'MOP', MG: 'MGA', MW: 'MWK', MY: 'MYR',
481
+ MV: 'MVR', ML: 'XOF', MT: 'EUR', MQ: 'EUR', MR: 'MRU', MU: 'MUR', YT: 'EUR', MX: 'MXN', MD: 'MDL', MC: 'EUR', MN: 'MNT',
482
+ ME: 'EUR', MS: 'XCD', MA: 'MAD', MZ: 'MZN', MM: 'MMK', NA: 'NAD', NR: 'AUD', NP: 'NPR', NL: 'EUR', AN: 'ANG', NC: 'XPF',
483
+ NZ: 'NZD', NI: 'NIO', NE: 'XOF', NG: 'NGN', NU: 'NZD', NF: 'AUD', MK: 'MKD', NO: 'NOK', OM: 'OMR', PK: 'PKR', PS: 'ILS',
484
+ PA: 'PAB', PG: 'PGK', PY: 'PYG', PE: 'PEN', PH: 'PHP', PN: 'NZD', PL: 'PLN', PT: 'EUR', QA: 'QAR', CM: 'XAF', RE: 'EUR',
485
+ RO: 'RON', RU: 'RUB', RW: 'RWF', BL: 'EUR', SH: 'SHP', KN: 'XCD', LC: 'XCD', MF: 'EUR', PM: 'EUR', WS: 'WST', SM: 'EUR',
486
+ ST: 'STN', SA: 'SAR', SN: 'XOF', RS: 'RSD', SC: 'SCR', SL: 'SLL', SG: 'SGD', SX: 'XCG', SK: 'EUR', SI: 'EUR', SB: 'SBD',
487
+ SO: 'SOS', ZA: 'ZAR', GS: 'GBP', KR: 'KRW', SS: 'SSP', ES: 'EUR', LK: 'LKR', VC: 'XCD', SD: 'SDG', SR: 'SRD', SJ: 'NOK',
488
+ SE: 'SEK', CH: 'CHF', SY: 'SYP', TW: 'TWD', TJ: 'TJS', TZ: 'TZS', TH: 'THB', TL: 'USD', TG: 'XOF', TK: 'NZD', TO: 'TOP',
489
+ TT: 'TTD', TA: 'GBP', TN: 'TND', TR: 'TRY', TM: 'TMT', TC: 'USD', TV: 'AUD', UG: 'UGX', UA: 'UAH', AE: 'AED', GB: 'GBP',
490
+ US: 'USD', UM: 'USD', UY: 'UYU', UZ: 'UZS', VU: 'VUV', VE: 'VES', VN: 'VND', VG: 'USD', WF: 'XPF', EH: 'MAD', YE: 'YER',
491
+ ZM: 'ZMW', ZW: 'USD',
492
+ });
493
+ /** The local currency of a country code (upper case), or null for an unknown code or ZZ. */
494
+ function countryCurrency(code) {
495
+ return (code && COUNTRY_CURRENCY[String(code).trim().toUpperCase()]) || null;
496
+ }
497
+ /** The distinct local currencies of a list of countries, in first-seen order; unknown codes are skipped. */
498
+ function countryCurrencies(codes) {
499
+ const out = [];
500
+ for (const c of codes || []) {
501
+ const cur = countryCurrency(c);
502
+ if (cur && !out.includes(cur))
503
+ out.push(cur);
504
+ }
505
+ return out;
506
+ }
507
+ export { COUNTRY_CURRENCY, countryCurrency, countryCurrencies, ISO_4217, CURRENCY_DIGITS, NO_MINOR_UNIT, DISPLAY_WHOLE_UNITS, displayDigits, displayAmount, PROVIDER_UNITS, PROVIDER_CURRENCIES, ROUNDING_MODES, InvalidAmountError, InexactAmountError, currencyDigits, isCurrencyCode, providerUnits, providerCurrencies, providerTakes, toFixedDigits, roundMoney, decimalText, add, sub, mul, div, sum, compare, isZero, negate, percentOf, allocate, toMinorUnits, fromMinorUnits, };
@@ -18,10 +18,16 @@ import type { ComponentType, ReactNode } from 'react';
18
18
  import { type Fields, type HandlesOf, type Schema, type SettingsOf } from '../sdk/schema.js';
19
19
  import type { SectionZone, ThemeDefinition, ThemeSection } from '../sdk/theme.js';
20
20
  import type { AiRole } from './ai.js';
21
+ import { APP_BLOCKS } from '../runtime/kit/contract/content.js';
21
22
  /** A section's or block's settings as its component receives them. */
22
23
  export type SettingsFor<F extends Fields> = SettingsOf<Schema<F>> & HandlesOf<Schema<F>>;
23
- /** One block of a section, in the merchant's order. */
24
+ /**
25
+ * One block of a section, in the merchant's order. A block of an installed app (`app:<app>/<block>`, where the section
26
+ * lists `'@app'`) keeps its saved settings: render it with `<AppBlock block={b} />` (theme-abi §7.2).
27
+ */
24
28
  export interface BlockInstance {
29
+ /** The node id the merchant's content gave it (the placeholder's `data-tq-node`); absent on an id-less block. */
30
+ id?: string;
25
31
  type: string;
26
32
  settings: Record<string, unknown>;
27
33
  }
@@ -61,8 +67,12 @@ export interface SectionDefinition<F extends Fields> {
61
67
  /** Where the page places it: the header zone, the page body (default), the footer zone. */
62
68
  zone?: SectionZone;
63
69
  settings: F;
64
- /** The blocks this section accepts. */
65
- blocks?: readonly BlockSchema[];
70
+ /**
71
+ * The blocks this section accepts. `'@app'` (`APP_BLOCKS`) accepts the blocks of the store's installed apps: render
72
+ * each with `<AppBlock>`. Every theme lists it on its product section and on a general section (theme-abi §7.2
73
+ * AppBlocks-1); a header or footer may list it too.
74
+ */
75
+ blocks?: readonly (BlockSchema | typeof APP_BLOCKS)[];
66
76
  /** "Add section" starting points; `presets[0]` is what the editor previews. */
67
77
  presets?: readonly SectionPresetDef[];
68
78
  /** Route kinds the section needs (`product`, `collection`, `cart`, …): offered only on those templates. */
@@ -1,6 +1,8 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { defineSchema, resolveSettings } from '../sdk/schema.js';
3
3
  import { kitStrings } from './strings.js';
4
+ import { APP_BLOCKS } from '../runtime/kit/contract/content.js';
5
+ import { isAppBlock } from '../sdk/app-block.js';
4
6
  /** Declare a block: its persisted type, its settings, and the sections it may be placed in. */
5
7
  export function defineBlock(def) {
6
8
  return defineSchema({ kind: 'block', name: def.type, family: 'theme', title: def.title, ...(def.description ? { description: def.description } : {}), ...(def.parents ? { parents: def.parents } : {}), ...(def.requires ? { requiresContext: def.requires } : {}) }, def.settings);
@@ -11,8 +13,10 @@ const merged = (schema, raw) => {
11
13
  };
12
14
  /** Declare a section of a headless theme. */
13
15
  export function defineSection(def) {
14
- const blocks = def.blocks ?? [];
15
- const schema = defineSchema({ kind: 'section', name: def.type, family: 'theme', ...(blocks.length ? { blocks: blocks.map((b) => b.name) } : {}), title: def.title, ...(def.description ? { description: def.description } : {}) }, def.settings);
16
+ const blocks = (def.blocks ?? []).filter((b) => typeof b !== 'string');
17
+ const appBlocks = (def.blocks ?? []).includes(APP_BLOCKS);
18
+ const names = [...blocks.map((b) => b.name), ...(appBlocks ? [APP_BLOCKS] : [])];
19
+ const schema = defineSchema({ kind: 'section', name: def.type, family: 'theme', ...(names.length ? { blocks: names } : {}), title: def.title, ...(def.description ? { description: def.description } : {}) }, def.settings);
16
20
  return {
17
21
  id: def.type,
18
22
  schema,
@@ -28,9 +32,13 @@ export function defineSection(def) {
28
32
  headless: true,
29
33
  data: (node) => ({
30
34
  settings: merged(schema, node.settings),
31
- blocks: (node.blocks ?? []).map((b) => {
35
+ blocks: (node.blocks ?? []).flatMap((b) => {
36
+ const id = typeof b.id === 'string' && b.id ? { id: b.id } : {};
37
+ // an app block only where the section lists '@app' (the platform drops it elsewhere before render, §7.2)
38
+ if (isAppBlock(b))
39
+ return appBlocks ? [{ ...id, type: b.type, settings: { ...(b.settings ?? {}) } }] : [];
32
40
  const bs = blocks.find((x) => x.name === b.type || x.legacyNames?.includes(b.type));
33
- return { type: bs?.name ?? b.type, settings: bs ? merged(bs, b.settings) : { ...(b.settings ?? {}) } };
41
+ return [{ ...id, type: bs?.name ?? b.type, settings: bs ? merged(bs, b.settings) : { ...(b.settings ?? {}) } }];
34
42
  }),
35
43
  }),
36
44
  };
package/dist/index.d.ts CHANGED
@@ -16,5 +16,6 @@
16
16
  * `@tanqory/theme-kit/client` (`hydrate`). Nothing here fetches or knows how the platform works.
17
17
  */
18
18
  export * from './sdk/index.js';
19
+ export { currencyDigits, displayAmount, displayDigits, div, mul, roundMoney, sub, toFixedDigits } from './headless/tanqory-money.generated.js';
19
20
  export type { ThemeBundle } from './runtime/slots.js';
20
21
  export type { ContentNode } from './runtime/kit/types.js';
package/dist/index.js CHANGED
@@ -16,3 +16,6 @@
16
16
  * `@tanqory/theme-kit/client` (`hydrate`). Nothing here fetches or knows how the platform works.
17
17
  */
18
18
  export * from './sdk/index.js';
19
+ // The platform's one currency table and exact money maths (@tanqory/money, a generated copy; docs/STANDARDS.md API-6),
20
+ // for a theme's own price maths and formats: one copy in the bundle, not one per theme file.
21
+ export { currencyDigits, displayAmount, displayDigits, div, mul, roundMoney, sub, toFixedDigits } from './headless/tanqory-money.generated.js';
@@ -172,10 +172,14 @@ export function StoreProvider({ location, locale, settings, labels: merchant, ch
172
172
  data.consent
173
173
  .get()
174
174
  .then((r) => {
175
- // The merchant's banner settings decide where it shows (map.consentBannerShows); absent = as before.
176
- const required = r.bannerRequired && map.consentBannerShows(r, data.shop?.consentBanner);
175
+ // The merchant's banner settings decide where it shows (map.consentBannerShows); absent = as before. Board 35
176
+ // #42 (2026-11-24): where it shows, it stays enabled after the shopper chose, so "Cookie preferences" remains
177
+ // and the choice can be changed (before, `bannerRequired` turned false with the choice and the link went away).
178
+ const shows = map.consentBannerShows(r, data.shop?.consentBanner);
179
+ const choice = r.known ? { analytics: r.analytics === true, marketing: r.marketing === true, preferences: r.functional === true } : undefined;
180
+ const optOut = r.regionRequiresOptOut === true;
177
181
  if (alive)
178
- setConsentState({ enabled: required, answered: r.known || !required });
182
+ setConsentState({ enabled: shows, answered: r.known || !shows, ...(choice ? { choice } : {}), optOut });
179
183
  })
180
184
  .catch(() => {
181
185
  /* no readout ⇒ no banner; the platform's default applies */
@@ -310,6 +314,8 @@ export function StoreProvider({ location, locale, settings, labels: merchant, ch
310
314
  }),
311
315
  consentEnabled: consent.enabled,
312
316
  consentAnswered: consent.answered,
317
+ ...(consent.choice ? { consentChoice: consent.choice } : {}),
318
+ ...(consent.optOut ? { consentOptOut: true } : {}),
313
319
  brandColor: str(settings.colorPrimary),
314
320
  collections: lookup(collection),
315
321
  currentCollection,
@@ -328,6 +334,7 @@ export function StoreProvider({ location, locale, settings, labels: merchant, ch
328
334
  reviews: currentReviews,
329
335
  ugcFeed: null,
330
336
  currentCart: map.toCart(cart),
337
+ cartStatus: cart.ready ? 'ready' : cart.loadError && !cart.loadRetrying ? 'failed' : 'loading',
331
338
  checkoutUrl: cart.checkoutUrl ?? '/checkout',
332
339
  cartLink: route.template === 'cart' ? search.get('cart_link') : null,
333
340
  searchQuery: query,