@eldrajs/sdk 0.2.8 → 0.2.9
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 +6 -0
- package/README.md +21 -0
- package/THIRD-PARTY-NOTICES.md +18 -0
- package/dist/format/date.d.ts +4 -0
- package/dist/format/date.js +12214 -0
- package/dist/format/display-names.d.ts +4 -0
- package/dist/format/display-names.js +4905 -0
- package/dist/format/list.d.ts +4 -0
- package/dist/format/list.js +902 -0
- package/dist/format/relative-time.d.ts +4 -0
- package/dist/format/relative-time.js +1546 -0
- package/dist/format.d.ts +12 -0
- package/dist/format.js +72 -0
- package/dist/locale-DOZdbAbY.js +4011 -0
- package/dist/number-D3Vt6TOL.js +9585 -0
- package/package.json +32 -3
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,12 @@ platform repository.
|
|
|
9
9
|
|
|
10
10
|
## Unreleased
|
|
11
11
|
|
|
12
|
+
- **Icelandic formatting that prints the same on every runtime: `@eldrajs/sdk/format`.**
|
|
13
|
+
`numberFormat`, `formatPrice` and `comparator`/`compareIcelandic`, plus `./format/date`,
|
|
14
|
+
`./format/list`, `./format/relative-time` and `./format/display-names`. Icelandic and English come
|
|
15
|
+
from the package's own CLDR 48.2 data, so Chrome and Cloudflare Workers, which lack it, print what
|
|
16
|
+
Node and Safari do; every other locale goes to the runtime's `Intl`. Dates are UTC. No new
|
|
17
|
+
runtime dependency: the formatjs code is bundled.
|
|
12
18
|
- **A request that answered `429` or `503` is retried instead of failing.** The gateway rate-limits a
|
|
13
19
|
client by requests per minute, which a static build of a real catalogue meets routinely. The
|
|
14
20
|
default `fetch` transport now repeats an **idempotent** request (`GET`/`HEAD`/`OPTIONS` — never a
|
package/README.md
CHANGED
|
@@ -61,6 +61,27 @@ const image = responsiveImage(product.thumbnail, {
|
|
|
61
61
|
parts on their own. Anything that is not an Eldra media asset comes back unchanged. The variants,
|
|
62
62
|
choosing `sizes`, and avoiding layout shift are in [docs/images.md](../../docs/images.md).
|
|
63
63
|
|
|
64
|
+
## Icelandic formatting
|
|
65
|
+
|
|
66
|
+
Chrome, Edge and Cloudflare Workers ship without Icelandic locale data, and `Intl` then prints
|
|
67
|
+
English without an error (`ISK 1,234,567` for `1.234.567 kr.`), which also breaks hydration. The
|
|
68
|
+
`./format` entries print Icelandic and English the same on every runtime:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { comparator, formatPrice, numberFormat } from '@eldrajs/sdk/format';
|
|
72
|
+
import { dateTimeFormat } from '@eldrajs/sdk/format/date';
|
|
73
|
+
|
|
74
|
+
formatPrice(12900, 'ISK', 'is-IS'); // "12.900 kr."
|
|
75
|
+
formatPrice(12900, 'ISK', 'en-US'); // "ISK 12,900"
|
|
76
|
+
dateTimeFormat('is-IS', { dateStyle: 'long' }).format(date); // "12. október 2026"
|
|
77
|
+
towns.sort(comparator('is-IS')); // Akureyri, Ísafjörður, Þórshöfn, Ölfus
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Each takes the options of the `Intl` constructor it is named after and returns an object with the
|
|
81
|
+
same methods. `./format/list`, `./format/relative-time` and `./format/display-names` cover the rest.
|
|
82
|
+
Import only the entries you use; each carries its own data. The rules and what it costs are in
|
|
83
|
+
[docs/icelandic-formatting.md](../../docs/icelandic-formatting.md).
|
|
84
|
+
|
|
64
85
|
## What is in the client
|
|
65
86
|
|
|
66
87
|
| Group | Methods |
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The `./format` entries bundle code from [formatjs](https://github.com/formatjs/formatjs) (`@formatjs/intl-numberformat`, `-datetimeformat`, `-listformat`, `-relativetimeformat`, `-displaynames`, `@formatjs/bigdecimal`, `@formatjs/intl-localematcher`, `@formatjs/fast-memoize`) and locale data derived from the Unicode CLDR. formatjs is distributed under this licence:
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2023 FormatJS
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The locale data is derived from the Unicode Common Locale Data Repository, under the
|
|
18
|
+
[Unicode License v3](https://www.unicode.org/license.txt).
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/format/date.d.ts
|
|
2
|
+
/** `new Intl.DateTimeFormat(locale, options)` with the same text everywhere; the time zone defaults to UTC, Iceland's. */
|
|
3
|
+
export declare function dateTimeFormat(locale: string, options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
4
|
+
//#endregion
|