@azx-pbc/axiom-web 0.0.0-stage → 0.0.1

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 (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +161 -2
  3. package/dist/address.d.ts +32 -0
  4. package/dist/address.d.ts.map +1 -0
  5. package/dist/address.js +146 -0
  6. package/dist/address.js.map +1 -0
  7. package/dist/capture/MediaCapture.d.ts +45 -0
  8. package/dist/capture/MediaCapture.d.ts.map +1 -0
  9. package/dist/capture/MediaCapture.js +669 -0
  10. package/dist/capture/MediaCapture.js.map +1 -0
  11. package/dist/capture/SignatureCapture.d.ts +31 -0
  12. package/dist/capture/SignatureCapture.d.ts.map +1 -0
  13. package/dist/capture/SignatureCapture.js +329 -0
  14. package/dist/capture/SignatureCapture.js.map +1 -0
  15. package/dist/capture/copy.d.ts +101 -0
  16. package/dist/capture/copy.d.ts.map +1 -0
  17. package/dist/capture/copy.js +1369 -0
  18. package/dist/capture/copy.js.map +1 -0
  19. package/dist/capture/index.d.ts +19 -0
  20. package/dist/capture/index.d.ts.map +1 -0
  21. package/dist/capture/index.js +14 -0
  22. package/dist/capture/index.js.map +1 -0
  23. package/dist/capture/media-kind.d.ts +16 -0
  24. package/dist/capture/media-kind.d.ts.map +1 -0
  25. package/dist/capture/media-kind.js +64 -0
  26. package/dist/capture/media-kind.js.map +1 -0
  27. package/dist/capture/permissions.d.ts +109 -0
  28. package/dist/capture/permissions.d.ts.map +1 -0
  29. package/dist/capture/permissions.js +172 -0
  30. package/dist/capture/permissions.js.map +1 -0
  31. package/dist/capture/refusal.d.ts +13 -0
  32. package/dist/capture/refusal.d.ts.map +1 -0
  33. package/dist/capture/refusal.js +16 -0
  34. package/dist/capture/refusal.js.map +1 -0
  35. package/dist/controls.d.ts +64 -0
  36. package/dist/controls.d.ts.map +1 -0
  37. package/dist/controls.js +2524 -0
  38. package/dist/controls.js.map +1 -0
  39. package/dist/coordinate.d.ts +38 -0
  40. package/dist/coordinate.d.ts.map +1 -0
  41. package/dist/coordinate.js +220 -0
  42. package/dist/coordinate.js.map +1 -0
  43. package/dist/copy.d.ts +313 -0
  44. package/dist/copy.d.ts.map +1 -0
  45. package/dist/copy.js +2602 -0
  46. package/dist/copy.js.map +1 -0
  47. package/dist/countries.d.ts +14 -0
  48. package/dist/countries.d.ts.map +1 -0
  49. package/dist/countries.js +264 -0
  50. package/dist/countries.js.map +1 -0
  51. package/dist/format/calendar-locale.d.ts +19 -0
  52. package/dist/format/calendar-locale.d.ts.map +1 -0
  53. package/dist/format/calendar-locale.js +38 -0
  54. package/dist/format/calendar-locale.js.map +1 -0
  55. package/dist/format/country-names.d.ts +21 -0
  56. package/dist/format/country-names.d.ts.map +1 -0
  57. package/dist/format/country-names.js +2277 -0
  58. package/dist/format/country-names.js.map +1 -0
  59. package/dist/format/date.d.ts +58 -0
  60. package/dist/format/date.d.ts.map +1 -0
  61. package/dist/format/date.js +155 -0
  62. package/dist/format/date.js.map +1 -0
  63. package/dist/format/digits.d.ts +23 -0
  64. package/dist/format/digits.d.ts.map +1 -0
  65. package/dist/format/digits.js +46 -0
  66. package/dist/format/digits.js.map +1 -0
  67. package/dist/format/index.d.ts +28 -0
  68. package/dist/format/index.d.ts.map +1 -0
  69. package/dist/format/index.js +24 -0
  70. package/dist/format/index.js.map +1 -0
  71. package/dist/format/invariant.d.ts +8 -0
  72. package/dist/format/invariant.d.ts.map +1 -0
  73. package/dist/format/invariant.js +10 -0
  74. package/dist/format/invariant.js.map +1 -0
  75. package/dist/format/locale.d.ts +33 -0
  76. package/dist/format/locale.d.ts.map +1 -0
  77. package/dist/format/locale.js +39 -0
  78. package/dist/format/locale.js.map +1 -0
  79. package/dist/format/media-type.d.ts +8 -0
  80. package/dist/format/media-type.d.ts.map +1 -0
  81. package/dist/format/media-type.js +302 -0
  82. package/dist/format/media-type.js.map +1 -0
  83. package/dist/format/money.d.ts +52 -0
  84. package/dist/format/money.d.ts.map +1 -0
  85. package/dist/format/money.js +36 -0
  86. package/dist/format/money.js.map +1 -0
  87. package/dist/format/number.d.ts +28 -0
  88. package/dist/format/number.d.ts.map +1 -0
  89. package/dist/format/number.js +91 -0
  90. package/dist/format/number.js.map +1 -0
  91. package/dist/host.d.ts +122 -0
  92. package/dist/host.d.ts.map +1 -0
  93. package/dist/host.js +20 -0
  94. package/dist/host.js.map +1 -0
  95. package/dist/index.d.ts +57 -0
  96. package/dist/index.d.ts.map +1 -0
  97. package/dist/index.js +49 -0
  98. package/dist/index.js.map +1 -0
  99. package/dist/media.d.ts +42 -0
  100. package/dist/media.d.ts.map +1 -0
  101. package/dist/media.js +151 -0
  102. package/dist/media.js.map +1 -0
  103. package/dist/pickers/DatePicker.d.ts +35 -0
  104. package/dist/pickers/DatePicker.d.ts.map +1 -0
  105. package/dist/pickers/DatePicker.js +212 -0
  106. package/dist/pickers/DatePicker.js.map +1 -0
  107. package/dist/pickers/TimeSegments.d.ts +27 -0
  108. package/dist/pickers/TimeSegments.d.ts.map +1 -0
  109. package/dist/pickers/TimeSegments.js +82 -0
  110. package/dist/pickers/TimeSegments.js.map +1 -0
  111. package/dist/pickers/day-picker-locale.d.ts +15 -0
  112. package/dist/pickers/day-picker-locale.d.ts.map +1 -0
  113. package/dist/pickers/day-picker-locale.js +46 -0
  114. package/dist/pickers/day-picker-locale.js.map +1 -0
  115. package/dist/render/dom.d.ts +100 -0
  116. package/dist/render/dom.d.ts.map +1 -0
  117. package/dist/render/dom.js +882 -0
  118. package/dist/render/dom.js.map +1 -0
  119. package/dist/render/layout.d.ts +45 -0
  120. package/dist/render/layout.d.ts.map +1 -0
  121. package/dist/render/layout.js +8 -0
  122. package/dist/render/layout.js.map +1 -0
  123. package/dist/schedule/SchedulePicker.d.ts +46 -0
  124. package/dist/schedule/SchedulePicker.d.ts.map +1 -0
  125. package/dist/schedule/SchedulePicker.js +160 -0
  126. package/dist/schedule/SchedulePicker.js.map +1 -0
  127. package/dist/schedule/timeslot.d.ts +52 -0
  128. package/dist/schedule/timeslot.d.ts.map +1 -0
  129. package/dist/schedule/timeslot.js +265 -0
  130. package/dist/schedule/timeslot.js.map +1 -0
  131. package/dist/styles.css +2151 -0
  132. package/dist/theme/index.d.ts +12 -0
  133. package/dist/theme/index.d.ts.map +1 -0
  134. package/dist/theme/index.js +11 -0
  135. package/dist/theme/index.js.map +1 -0
  136. package/dist/theme/presets.d.ts +93 -0
  137. package/dist/theme/presets.d.ts.map +1 -0
  138. package/dist/theme/presets.js +200 -0
  139. package/dist/theme/presets.js.map +1 -0
  140. package/dist/tokens.css +234 -0
  141. package/dist/wizard-checkpoints.d.ts +18 -0
  142. package/dist/wizard-checkpoints.d.ts.map +1 -0
  143. package/dist/wizard-checkpoints.js +56 -0
  144. package/dist/wizard-checkpoints.js.map +1 -0
  145. package/package.json +76 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digits.js","sourceRoot":"","sources":["../../src/format/digits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,cAAc,CAAU,CAAC;AAKnE,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAgB,SAAS,CAAC;AAE3D,sEAAsE;AACtE,MAAM,mBAAmB,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC3D,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;CACT,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC;AAC1F,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,MAAmB;IAC9D,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC;QACf,KAAK,cAAc;YACjB,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACpC;YACE,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC","sourcesContent":["import { assertNever } from '@azx-pbc/axiom-runtime';\n\n/**\n * How a locale writes its numerals.\n *\n * The policy is a parameter rather than a fact of the language: Western digits are the default\n * for every locale, Arabic included, because the chrome and the record must not disagree about\n * what a digit is. A host that wants Arabic-Indic numerals asks for them explicitly.\n */\nexport const DIGIT_POLICIES = ['western', 'arabic-indic'] as const;\n\n/** The numeral set one formatter writes. */\nexport type DigitPolicy = (typeof DIGIT_POLICIES)[number];\n\n/** Western digits are the default for every locale, including Arabic. */\nexport const DEFAULT_DIGIT_POLICY: DigitPolicy = 'western';\n\n/** U+0660..U+0669, indexed by the Western digit each one replaces. */\nconst ARABIC_INDIC_DIGITS: readonly string[] = Object.freeze([\n '\\u0660',\n '\\u0661',\n '\\u0662',\n '\\u0663',\n '\\u0664',\n '\\u0665',\n '\\u0666',\n '\\u0667',\n '\\u0668',\n '\\u0669',\n]);\n\n/**\n * The Arabic-Indic spelling of every Western digit in `value`.\n *\n * The mapping is one code point for one code point: separators, signs, letters and spaces are\n * untouched, so a formatted number keeps the locale's punctuation while its numerals change. An\n * Arabic-Indic digit already present is left alone, which makes the function idempotent.\n */\nexport function toArabicIndicDigits(value: string): string {\n return value.replace(/[0-9]/gu, (digit) => ARABIC_INDIC_DIGITS[Number(digit)] ?? digit);\n}\n\n/** The numerals one policy writes, applied to text whose digits are Western. */\nexport function presentDigits(value: string, policy: DigitPolicy): string {\n switch (policy) {\n case 'western':\n return value;\n case 'arabic-indic':\n return toArabicIndicDigits(value);\n default:\n return assertNever(policy);\n }\n}\n"]}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The chrome's locale mechanics, as one door.
3
+ *
4
+ * The tables are vendored so the same bytes render on Node, in a browser and on Hermes: no host
5
+ * locale database and no locale-sensitive formatting API is consulted. A tag that is not one of
6
+ * the nine languages reads English, the same fallback the copy catalogue takes.
7
+ *
8
+ * The amount formatters return digits in the locale's marks and, for money, the currency code
9
+ * beside them. They deliberately stop there: the mark a currency uses and the side of the amount
10
+ * it sits on belong to the copy layer's sentence (`FormCopy.display`), which is the one place a
11
+ * value and its wording are placed together. A host that needs that placement asks `formCopy`,
12
+ * not this door.
13
+ *
14
+ * The input brands are the boundary's. `isDecimalString`, `isCivilDateString`,
15
+ * `isCanonicalMoneyText` and `isCurrencyCode` answer once, and every formatter takes the brand
16
+ * so a plain string cannot reach a table that assumes canonical text.
17
+ */
18
+ export { LOCALES, resolveLocale } from './locale.js';
19
+ export type { Locale, ResolvedLocale } from './locale.js';
20
+ export { CALENDAR_LOCALES, calendarLocale } from './calendar-locale.js';
21
+ export { DEFAULT_DIGIT_POLICY, DIGIT_POLICIES, toArabicIndicDigits } from './digits.js';
22
+ export type { DigitPolicy } from './digits.js';
23
+ export { formatDecimal, isDecimalString } from './number.js';
24
+ export { formatMoney, isCanonicalMoneyText, isCurrencyCode } from './money.js';
25
+ export type { CanonicalMoneyText, CurrencyCode, MoneyDisplay } from './money.js';
26
+ export { formatCivilDate, formatInstant, isCivilDateString, isInstantString } from './date.js';
27
+ export type { CivilDateString, InstantString } from './date.js';
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/format/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACxF,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC/E,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEjF,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/F,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The chrome's locale mechanics, as one door.
3
+ *
4
+ * The tables are vendored so the same bytes render on Node, in a browser and on Hermes: no host
5
+ * locale database and no locale-sensitive formatting API is consulted. A tag that is not one of
6
+ * the nine languages reads English, the same fallback the copy catalogue takes.
7
+ *
8
+ * The amount formatters return digits in the locale's marks and, for money, the currency code
9
+ * beside them. They deliberately stop there: the mark a currency uses and the side of the amount
10
+ * it sits on belong to the copy layer's sentence (`FormCopy.display`), which is the one place a
11
+ * value and its wording are placed together. A host that needs that placement asks `formCopy`,
12
+ * not this door.
13
+ *
14
+ * The input brands are the boundary's. `isDecimalString`, `isCivilDateString`,
15
+ * `isCanonicalMoneyText` and `isCurrencyCode` answer once, and every formatter takes the brand
16
+ * so a plain string cannot reach a table that assumes canonical text.
17
+ */
18
+ export { LOCALES, resolveLocale } from './locale.js';
19
+ export { CALENDAR_LOCALES, calendarLocale } from './calendar-locale.js';
20
+ export { DEFAULT_DIGIT_POLICY, DIGIT_POLICIES, toArabicIndicDigits } from './digits.js';
21
+ export { formatDecimal, isDecimalString } from './number.js';
22
+ export { formatMoney, isCanonicalMoneyText, isCurrencyCode } from './money.js';
23
+ export { formatCivilDate, formatInstant, isCivilDateString, isInstantString } from './date.js';
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/format/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGxF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG/E,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC","sourcesContent":["/**\n * The chrome's locale mechanics, as one door.\n *\n * The tables are vendored so the same bytes render on Node, in a browser and on Hermes: no host\n * locale database and no locale-sensitive formatting API is consulted. A tag that is not one of\n * the nine languages reads English, the same fallback the copy catalogue takes.\n *\n * The amount formatters return digits in the locale's marks and, for money, the currency code\n * beside them. They deliberately stop there: the mark a currency uses and the side of the amount\n * it sits on belong to the copy layer's sentence (`FormCopy.display`), which is the one place a\n * value and its wording are placed together. A host that needs that placement asks `formCopy`,\n * not this door.\n *\n * The input brands are the boundary's. `isDecimalString`, `isCivilDateString`,\n * `isCanonicalMoneyText` and `isCurrencyCode` answer once, and every formatter takes the brand\n * so a plain string cannot reach a table that assumes canonical text.\n */\nexport { LOCALES, resolveLocale } from './locale.js';\nexport type { Locale, ResolvedLocale } from './locale.js';\n\nexport { CALENDAR_LOCALES, calendarLocale } from './calendar-locale.js';\n\nexport { DEFAULT_DIGIT_POLICY, DIGIT_POLICIES, toArabicIndicDigits } from './digits.js';\nexport type { DigitPolicy } from './digits.js';\n\nexport { formatDecimal, isDecimalString } from './number.js';\n\nexport { formatMoney, isCanonicalMoneyText, isCurrencyCode } from './money.js';\nexport type { CanonicalMoneyText, CurrencyCode, MoneyDisplay } from './money.js';\n\nexport { formatCivilDate, formatInstant, isCivilDateString, isInstantString } from './date.js';\nexport type { CivilDateString, InstantString } from './date.js';\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The terminator for an exhaustive switch.
3
+ *
4
+ * A union that grows a variant reaches this arm as a type error before it can reach a renderer
5
+ * that would silently fall through. The throw is a programmer error, never an expected input.
6
+ */
7
+ export declare function assertNever(value: never): never;
8
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../src/format/invariant.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAE/C"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The terminator for an exhaustive switch.
3
+ *
4
+ * A union that grows a variant reaches this arm as a type error before it can reach a renderer
5
+ * that would silently fall through. The throw is a programmer error, never an expected input.
6
+ */
7
+ export function assertNever(value) {
8
+ throw new Error(`unreachable variant: ${String(value)}`);
9
+ }
10
+ //# sourceMappingURL=invariant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariant.js","sourceRoot":"","sources":["../../src/format/invariant.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,MAAM,IAAI,KAAK,CAAC,wBAAwB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/**\n * The terminator for an exhaustive switch.\n *\n * A union that grows a variant reaches this arm as a type error before it can reach a renderer\n * that would silently fall through. The throw is a programmer error, never an expected input.\n */\nexport function assertNever(value: never): never {\n throw new Error(`unreachable variant: ${String(value)}`);\n}\n"]}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The nine locales the chrome's mechanics are written for.
3
+ *
4
+ * The order here is the order the tables state, and this list is their only authority: adding a
5
+ * language makes every `Record<Locale, ...>` in this module fail to compile until it has a number
6
+ * table, a date pattern and a calendar locale. No host locale database is consulted; an unknown
7
+ * tag reads English, the same fallback the copy catalogue already takes.
8
+ */
9
+ export declare const LOCALES: readonly ['en', 'es', 'fr', 'de', 'ru', 'it', 'zh', 'ar', 'pt'];
10
+ /** One of the languages this module can present. */
11
+ export type Locale = (typeof LOCALES)[number];
12
+ /** A host tag and the language and script it names. */
13
+ export interface ResolvedLocale {
14
+ /** The shipped language the tag reads. An unknown language reads `en`. */
15
+ readonly language: Locale;
16
+ /**
17
+ * The four-letter script subtag in its canonical title case, when the tag states one.
18
+ *
19
+ * `zh-Hant` keeps `Hans` apart from `zh-Hans`, so a caller can tell a traditional tag from a
20
+ * simplified one even though the shipped Chinese calendar table promises only Hans.
21
+ */
22
+ readonly script?: string;
23
+ }
24
+ /**
25
+ * The language and optional script a host tag resolves to.
26
+ *
27
+ * `pt-BR`, `pt_PT` and `PT` all read `pt`; `zh-Hant` reads `zh` with `script: 'Hant'`. The
28
+ * function is total: a missing value, a number, a null or a language this module does not carry
29
+ * all read English with no script. It never guesses a region from a language, because the tables
30
+ * hold one order per language and a region would be a second, undocumented mechanic.
31
+ */
32
+ export declare function resolveLocale(tag: unknown): ResolvedLocale;
33
+ //# sourceMappingURL=locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/format/locale.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,YAAI,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAEvF,oDAAoD;AACpD,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9C,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAiBD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAQ1D"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The nine locales the chrome's mechanics are written for.
3
+ *
4
+ * The order here is the order the tables state, and this list is their only authority: adding a
5
+ * language makes every `Record<Locale, ...>` in this module fail to compile until it has a number
6
+ * table, a date pattern and a calendar locale. No host locale database is consulted; an unknown
7
+ * tag reads English, the same fallback the copy catalogue already takes.
8
+ */
9
+ export const LOCALES = ['en', 'es', 'fr', 'de', 'ru', 'it', 'zh', 'ar', 'pt'];
10
+ const DEFAULT_LOCALE = 'en';
11
+ /**
12
+ * The language subtag a host tag names.
13
+ *
14
+ * The map is derived from `LOCALES`, so the resolver cannot carry a language the tables do not
15
+ * and cannot lose one they do.
16
+ */
17
+ const BY_LANGUAGE = new Map(LOCALES.map((locale) => [locale, locale]));
18
+ /** A BCP 47 script subtag: four letters, no digits. */
19
+ const SCRIPT_PATTERN = /^[a-z]{4}$/u;
20
+ /**
21
+ * The language and optional script a host tag resolves to.
22
+ *
23
+ * `pt-BR`, `pt_PT` and `PT` all read `pt`; `zh-Hant` reads `zh` with `script: 'Hant'`. The
24
+ * function is total: a missing value, a number, a null or a language this module does not carry
25
+ * all read English with no script. It never guesses a region from a language, because the tables
26
+ * hold one order per language and a region would be a second, undocumented mechanic.
27
+ */
28
+ export function resolveLocale(tag) {
29
+ const segments = typeof tag === 'string' ? tag.trim().toLowerCase().split(/[-_]/u).filter(isNonEmpty) : [];
30
+ const language = BY_LANGUAGE.get(segments[0] ?? '') ?? DEFAULT_LOCALE;
31
+ const script = segments.slice(1).find((segment) => SCRIPT_PATTERN.test(segment));
32
+ return script === undefined
33
+ ? { language }
34
+ : { language, script: script.charAt(0).toUpperCase() + script.slice(1) };
35
+ }
36
+ function isNonEmpty(segment) {
37
+ return segment !== '';
38
+ }
39
+ //# sourceMappingURL=locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.js","sourceRoot":"","sources":["../../src/format/locale.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAkBvF,MAAM,cAAc,GAAW,IAAI,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,WAAW,GAAgC,IAAI,GAAG,CACtD,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC,CACnD,CAAC;AAEF,uDAAuD;AACvD,MAAM,cAAc,GAAG,aAAa,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,MAAM,QAAQ,GACZ,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5F,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,cAAc,CAAC;IACtE,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACjF,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,EAAE,QAAQ,EAAE;QACd,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7E,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO,OAAO,KAAK,EAAE,CAAC;AACxB,CAAC","sourcesContent":["/**\n * The nine locales the chrome's mechanics are written for.\n *\n * The order here is the order the tables state, and this list is their only authority: adding a\n * language makes every `Record<Locale, ...>` in this module fail to compile until it has a number\n * table, a date pattern and a calendar locale. No host locale database is consulted; an unknown\n * tag reads English, the same fallback the copy catalogue already takes.\n */\nexport const LOCALES = ['en', 'es', 'fr', 'de', 'ru', 'it', 'zh', 'ar', 'pt'] as const;\n\n/** One of the languages this module can present. */\nexport type Locale = (typeof LOCALES)[number];\n\n/** A host tag and the language and script it names. */\nexport interface ResolvedLocale {\n /** The shipped language the tag reads. An unknown language reads `en`. */\n readonly language: Locale;\n /**\n * The four-letter script subtag in its canonical title case, when the tag states one.\n *\n * `zh-Hant` keeps `Hans` apart from `zh-Hans`, so a caller can tell a traditional tag from a\n * simplified one even though the shipped Chinese calendar table promises only Hans.\n */\n readonly script?: string;\n}\n\nconst DEFAULT_LOCALE: Locale = 'en';\n\n/**\n * The language subtag a host tag names.\n *\n * The map is derived from `LOCALES`, so the resolver cannot carry a language the tables do not\n * and cannot lose one they do.\n */\nconst BY_LANGUAGE: ReadonlyMap<string, Locale> = new Map<string, Locale>(\n LOCALES.map((locale) => [locale, locale] as const),\n);\n\n/** A BCP 47 script subtag: four letters, no digits. */\nconst SCRIPT_PATTERN = /^[a-z]{4}$/u;\n\n/**\n * The language and optional script a host tag resolves to.\n *\n * `pt-BR`, `pt_PT` and `PT` all read `pt`; `zh-Hant` reads `zh` with `script: 'Hant'`. The\n * function is total: a missing value, a number, a null or a language this module does not carry\n * all read English with no script. It never guesses a region from a language, because the tables\n * hold one order per language and a region would be a second, undocumented mechanic.\n */\nexport function resolveLocale(tag: unknown): ResolvedLocale {\n const segments =\n typeof tag === 'string' ? tag.trim().toLowerCase().split(/[-_]/u).filter(isNonEmpty) : [];\n const language = BY_LANGUAGE.get(segments[0] ?? '') ?? DEFAULT_LOCALE;\n const script = segments.slice(1).find((segment) => SCRIPT_PATTERN.test(segment));\n return script === undefined\n ? { language }\n : { language, script: script.charAt(0).toUpperCase() + script.slice(1) };\n}\n\nfunction isNonEmpty(segment: string): boolean {\n return segment !== '';\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { CountryLocale } from './country-names.js';
2
+ /** A singular noun phrase for a media type, never its wire spelling. */
3
+ export declare function mediaTypeNameIn(locale: CountryLocale, mediaType: string): string;
4
+ /** A plural noun phrase for a media type, for the list a field accepts. */
5
+ export declare function mediaTypePluralIn(locale: CountryLocale, mediaType: string): string;
6
+ /** The conjunction a locale joins two admitted media types with. */
7
+ export declare function mediaTypeSeparatorIn(locale: CountryLocale): string;
8
+ //# sourceMappingURL=media-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-type.d.ts","sourceRoot":"","sources":["../../src/format/media-type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAkRxD,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAehF;AAgBD,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAOlF;AAED,oEAAoE;AACpE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAqBlE"}
@@ -0,0 +1,302 @@
1
+ import { MEDIA_EXTENSION_TYPES } from '@azx-pbc/axiom-runtime';
2
+ /** The media types the shipped host names, keyed by their wire spelling. */
3
+ const MEDIA_TYPES = {
4
+ 'image/jpeg': { name: 'JPEG', noun: 'image' },
5
+ 'image/png': { name: 'PNG', noun: 'image' },
6
+ 'image/gif': { name: 'GIF', noun: 'image' },
7
+ 'image/webp': { name: 'WebP', noun: 'image' },
8
+ 'image/heic': { name: 'HEIC', noun: 'image' },
9
+ 'image/heif': { name: 'HEIF', noun: 'image' },
10
+ 'image/svg+xml': { name: 'SVG', noun: 'image' },
11
+ 'image/bmp': { name: 'BMP', noun: 'image' },
12
+ 'image/tiff': { name: 'TIFF', noun: 'image' },
13
+ 'image/avif': { name: 'AVIF', noun: 'image' },
14
+ 'audio/mpeg': { name: 'MP3', noun: 'audio' },
15
+ 'audio/mp4': { name: 'M4A', noun: 'audio' },
16
+ 'audio/ogg': { name: 'Ogg', noun: 'audio' },
17
+ 'audio/wav': { name: 'WAV', noun: 'audio' },
18
+ 'audio/x-wav': { name: 'WAV', noun: 'audio' },
19
+ 'audio/webm': { name: 'WebM', noun: 'audio' },
20
+ 'audio/flac': { name: 'FLAC', noun: 'audio' },
21
+ 'video/mp4': { name: 'MP4', noun: 'video' },
22
+ 'video/webm': { name: 'WebM', noun: 'video' },
23
+ 'video/quicktime': { name: 'QuickTime', noun: 'video' },
24
+ 'video/ogg': { name: 'Ogg', noun: 'video' },
25
+ 'application/pdf': { name: 'PDF', noun: 'file' },
26
+ 'application/zip': { name: 'ZIP', noun: 'file' },
27
+ 'application/json': { name: 'JSON', noun: 'file' },
28
+ 'text/plain': { name: 'plain-text', noun: 'file' },
29
+ 'text/csv': { name: 'CSV', noun: 'file' },
30
+ 'application/msword': { name: 'Word', noun: 'file' },
31
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': {
32
+ name: 'Word',
33
+ noun: 'file',
34
+ },
35
+ 'application/vnd.ms-excel': { name: 'Excel', noun: 'file' },
36
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': {
37
+ name: 'Excel',
38
+ noun: 'file',
39
+ },
40
+ 'application/octet-stream': { name: 'binary', noun: 'file' },
41
+ };
42
+ /**
43
+ * The classifier noun each locale pairs with a short type name.
44
+ *
45
+ * English puts the article and the noun after the acronym (`a JPEG image`); French, Spanish,
46
+ * Portuguese, German and Italian do the same with their own article and gender; Russian, Arabic
47
+ * and Chinese put the noun first and carry no article, which is why the phrase, not a template,
48
+ * is the unit here.
49
+ */
50
+ const NOUNS = {
51
+ en: {
52
+ image: 'image',
53
+ imagePlural: 'images',
54
+ audio: 'audio file',
55
+ audioPlural: 'audio files',
56
+ video: 'video',
57
+ videoPlural: 'videos',
58
+ file: 'file',
59
+ filePlural: 'files',
60
+ },
61
+ es: {
62
+ image: 'imagen',
63
+ imagePlural: 'imágenes',
64
+ audio: 'archivo de audio',
65
+ audioPlural: 'archivos de audio',
66
+ video: 'vídeo',
67
+ videoPlural: 'vídeos',
68
+ file: 'archivo',
69
+ filePlural: 'archivos',
70
+ },
71
+ pt: {
72
+ image: 'imagem',
73
+ imagePlural: 'imagens',
74
+ audio: 'ficheiro de áudio',
75
+ audioPlural: 'ficheiros de áudio',
76
+ video: 'vídeo',
77
+ videoPlural: 'vídeos',
78
+ file: 'ficheiro',
79
+ filePlural: 'ficheiros',
80
+ },
81
+ fr: {
82
+ image: 'image',
83
+ imagePlural: 'images',
84
+ audio: 'fichier audio',
85
+ audioPlural: 'fichiers audio',
86
+ video: 'vidéo',
87
+ videoPlural: 'vidéos',
88
+ file: 'fichier',
89
+ filePlural: 'fichiers',
90
+ },
91
+ ar: {
92
+ image: 'صورة',
93
+ imagePlural: 'صور',
94
+ audio: 'ملف صوتي',
95
+ audioPlural: 'ملفات صوتية',
96
+ video: 'فيديو',
97
+ videoPlural: 'مقاطع فيديو',
98
+ file: 'ملف',
99
+ filePlural: 'ملفات',
100
+ },
101
+ de: {
102
+ image: 'Bild',
103
+ imagePlural: 'Bilder',
104
+ audio: 'Audiodatei',
105
+ audioPlural: 'Audiodateien',
106
+ video: 'Video',
107
+ videoPlural: 'Videos',
108
+ file: 'Datei',
109
+ filePlural: 'Dateien',
110
+ },
111
+ it: {
112
+ image: 'immagine',
113
+ imagePlural: 'immagini',
114
+ audio: 'file audio',
115
+ audioPlural: 'file audio',
116
+ video: 'video',
117
+ videoPlural: 'video',
118
+ file: 'file',
119
+ filePlural: 'file',
120
+ },
121
+ ru: {
122
+ image: 'изображение',
123
+ imagePlural: 'изображения',
124
+ audio: 'аудиофайл',
125
+ audioPlural: 'аудиофайлы',
126
+ video: 'видео',
127
+ videoPlural: 'видеофайлы',
128
+ file: 'файл',
129
+ filePlural: 'файлы',
130
+ },
131
+ zh: {
132
+ image: '图片',
133
+ imagePlural: '图片',
134
+ audio: '音频文件',
135
+ audioPlural: '音频文件',
136
+ video: '视频',
137
+ videoPlural: '视频',
138
+ file: '文件',
139
+ filePlural: '文件',
140
+ },
141
+ };
142
+ /** The phrase a type this table does not carry is called, singular and plural. */
143
+ const UNKNOWN = {
144
+ en: {
145
+ one: 'a type this field does not take',
146
+ many: 'other file types',
147
+ },
148
+ es: {
149
+ one: 'un tipo que este campo no admite',
150
+ many: 'otros tipos de archivo',
151
+ },
152
+ pt: {
153
+ one: 'um tipo que este campo não aceita',
154
+ many: 'outros tipos de ficheiro',
155
+ },
156
+ fr: {
157
+ one: "un type que ce champ n'accepte pas",
158
+ many: "d'autres types de fichier",
159
+ },
160
+ ar: {
161
+ one: 'نوع لا يقبله هذا الحقل',
162
+ many: 'أنواع ملفات أخرى',
163
+ },
164
+ de: {
165
+ one: 'ein Typ, den dieses Feld nicht annimmt',
166
+ many: 'andere Dateitypen',
167
+ },
168
+ it: {
169
+ one: 'un tipo che questo campo non accetta',
170
+ many: 'altri tipi di file',
171
+ },
172
+ ru: {
173
+ one: 'тип, который это поле не принимает',
174
+ many: 'другие типы файлов',
175
+ },
176
+ zh: {
177
+ one: '此字段不接受的文件类型',
178
+ many: '其他文件类型',
179
+ },
180
+ };
181
+ /**
182
+ * The grammatical gender each locale gives a classifier noun.
183
+ *
184
+ * The article follows the noun, not the acronym: Spanish says `una imagen` and `un archivo`, and
185
+ * German says `ein Bild` and `eine Audiodatei`. English is the one locale whose article follows
186
+ * the type name instead (`a JPEG image`, `an MP3 audio file`), which is why the name is a
187
+ * parameter.
188
+ */
189
+ const GENDER = {
190
+ en: { image: 'n', audio: 'n', video: 'n', file: 'n' },
191
+ es: { image: 'f', audio: 'm', video: 'm', file: 'm' },
192
+ pt: { image: 'f', audio: 'm', video: 'm', file: 'm' },
193
+ fr: { image: 'f', audio: 'm', video: 'f', file: 'm' },
194
+ ar: { image: 'f', audio: 'm', video: 'm', file: 'm' },
195
+ de: { image: 'n', audio: 'f', video: 'n', file: 'f' },
196
+ it: { image: 'f', audio: 'm', video: 'm', file: 'm' },
197
+ ru: { image: 'n', audio: 'm', video: 'n', file: 'm' },
198
+ zh: { image: 'n', audio: 'n', video: 'n', file: 'n' },
199
+ };
200
+ /** The indefinite article a locale puts before a named type. */
201
+ function articleOf(locale, noun, name) {
202
+ switch (locale) {
203
+ case 'en':
204
+ return /^[aeiou]/iu.test(name) ? 'an' : 'a';
205
+ case 'es':
206
+ return GENDER.es[noun] === 'f' ? 'una' : 'un';
207
+ case 'pt':
208
+ return GENDER.pt[noun] === 'f' ? 'uma' : 'um';
209
+ case 'fr':
210
+ return GENDER.fr[noun] === 'f' ? 'une' : 'un';
211
+ case 'de':
212
+ return GENDER.de[noun] === 'f' ? 'eine' : 'ein';
213
+ case 'it':
214
+ return GENDER.it[noun] === 'f' ? 'una' : 'un';
215
+ case 'ar':
216
+ case 'ru':
217
+ case 'zh':
218
+ return '';
219
+ }
220
+ }
221
+ /** Whether a locale writes the type name before the classifier noun rather than after it. */
222
+ function nameFirst(locale) {
223
+ return locale === 'en' || locale === 'zh';
224
+ }
225
+ /** The media type an `accept` entry denotes, resolving an extension through the closed table. */
226
+ function mediaTypeOf(entry) {
227
+ const lower = entry.toLowerCase();
228
+ return lower.startsWith('.') ? (MEDIA_EXTENSION_TYPES.get(lower) ?? '') : lower;
229
+ }
230
+ /** The type name and noun one entry denotes, or `undefined` when the table does not carry it. */
231
+ function namedType(entry) {
232
+ const type = mediaTypeOf(entry);
233
+ return type === '' ? undefined : MEDIA_TYPES[type];
234
+ }
235
+ /** A singular noun phrase for a media type, never its wire spelling. */
236
+ export function mediaTypeNameIn(locale, mediaType) {
237
+ const named = namedType(mediaType);
238
+ if (named === undefined)
239
+ return UNKNOWN[locale].one;
240
+ const noun = NOUNS[locale][named.noun];
241
+ const article = articleOf(locale, named.noun, named.name);
242
+ if (nameFirst(locale)) {
243
+ return article === '' ? `${named.name} ${noun}` : `${article} ${named.name} ${noun}`;
244
+ }
245
+ // German compounds the type and the noun: `ein JPEG-Bild`, `eine ZIP-Datei`.
246
+ if (locale === 'de')
247
+ return `${article} ${named.name}-${noun}`;
248
+ // Italian elides the feminine article before a vowel: `un'immagine`, not `una immagine`.
249
+ if (locale === 'it' && article === 'una' && /^[aeiou]/iu.test(noun)) {
250
+ return `un'${noun} ${named.name}`;
251
+ }
252
+ return article === '' ? `${noun} ${named.name}` : `${article} ${noun} ${named.name}`;
253
+ }
254
+ /** The plural classifier a locale gives one noun kind. */
255
+ function pluralOf(locale, noun) {
256
+ switch (noun) {
257
+ case 'image':
258
+ return NOUNS[locale].imagePlural;
259
+ case 'audio':
260
+ return NOUNS[locale].audioPlural;
261
+ case 'video':
262
+ return NOUNS[locale].videoPlural;
263
+ case 'file':
264
+ return NOUNS[locale].filePlural;
265
+ }
266
+ }
267
+ /** A plural noun phrase for a media type, for the list a field accepts. */
268
+ export function mediaTypePluralIn(locale, mediaType) {
269
+ const named = namedType(mediaType);
270
+ if (named === undefined)
271
+ return UNKNOWN[locale].many;
272
+ const noun = pluralOf(locale, named.noun);
273
+ if (nameFirst(locale))
274
+ return `${named.name} ${noun}`;
275
+ if (locale === 'de')
276
+ return `${named.name}-${noun}`;
277
+ return `${noun} ${named.name}`;
278
+ }
279
+ /** The conjunction a locale joins two admitted media types with. */
280
+ export function mediaTypeSeparatorIn(locale) {
281
+ switch (locale) {
282
+ case 'en':
283
+ return ' or ';
284
+ case 'es':
285
+ return ' o ';
286
+ case 'pt':
287
+ return ' ou ';
288
+ case 'fr':
289
+ return ' ou ';
290
+ case 'ar':
291
+ return ' أو ';
292
+ case 'de':
293
+ return ' oder ';
294
+ case 'it':
295
+ return ' o ';
296
+ case 'ru':
297
+ return ' или ';
298
+ case 'zh':
299
+ return '或';
300
+ }
301
+ }
302
+ //# sourceMappingURL=media-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-type.js","sourceRoot":"","sources":["../../src/format/media-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAsB/D,4EAA4E;AAC5E,MAAM,WAAW,GAA4C;IAC3D,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7C,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE;IAC3C,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE;IAC3C,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7C,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7C,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7C,eAAe,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE;IAC/C,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE;IAC3C,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7C,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;IAC7C,YAAY,EAAE,E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,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;IACrD,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,SAAS,CAAC,MAAM,CAAC;QAAE,OAAO,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;IACtD,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;IACpD,OAAO,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;AACjC,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,oBAAoB,CAAC,MAAqB;IACxD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,IAAI;YACP,OAAO,MAAM,CAAC;QAChB,KAAK,IAAI;YACP,OAAO,KAAK,CAAC;QACf,KAAK,IAAI;YACP,OAAO,MAAM,CAAC;QAChB,KAAK,IAAI;YACP,OAAO,MAAM,CAAC;QAChB,KAAK,IAAI;YACP,OAAO,MAAM,CAAC;QAChB,KAAK,IAAI;YACP,OAAO,QAAQ,CAAC;QAClB,KAAK,IAAI;YACP,OAAO,KAAK,CAAC;QACf,KAAK,IAAI;YACP,OAAO,OAAO,CAAC;QACjB,KAAK,IAAI;YACP,OAAO,GAAG,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import { MEDIA_EXTENSION_TYPES } from '@azx-pbc/axiom-runtime';\nimport type { CountryLocale } from './country-names.js';\n\n/**\n * What a media type is called in a sentence.\n *\n * A declaration states `image/jpeg` and a file reports `application/zip`, and neither is a word a\n * reader recognises. This module is the one place the wire spelling becomes a noun phrase, so a\n * constraint sentence and a capture refusal name the same type the same way. The table is closed:\n * a type it does not carry is not spelled as its MIME string, because a machine key in a sentence\n * is the defect this module exists to remove.\n */\n\n/** The noun a media type is a kind of. */\ntype MediaNoun = 'image' | 'audio' | 'video' | 'file';\n\ninterface MediaTypeName {\n /** The short name a person reads, or the words for the subtype when it has no short one. */\n readonly name: string;\n readonly noun: MediaNoun;\n}\n\n/** The media types the shipped host names, keyed by their wire spelling. */\nconst MEDIA_TYPES: Readonly<Record<string, MediaTypeName>> = {\n 'image/jpeg': { name: 'JPEG', noun: 'image' },\n 'image/png': { name: 'PNG', noun: 'image' },\n 'image/gif': { name: 'GIF', noun: 'image' },\n 'image/webp': { name: 'WebP', noun: 'image' },\n 'image/heic': { name: 'HEIC', noun: 'image' },\n 'image/heif': { name: 'HEIF', noun: 'image' },\n 'image/svg+xml': { name: 'SVG', noun: 'image' },\n 'image/bmp': { name: 'BMP', noun: 'image' },\n 'image/tiff': { name: 'TIFF', noun: 'image' },\n 'image/avif': { name: 'AVIF', noun: 'image' },\n 'audio/mpeg': { name: 'MP3', noun: 'audio' },\n 'audio/mp4': { name: 'M4A', noun: 'audio' },\n 'audio/ogg': { name: 'Ogg', noun: 'audio' },\n 'audio/wav': { name: 'WAV', noun: 'audio' },\n 'audio/x-wav': { name: 'WAV', noun: 'audio' },\n 'audio/webm': { name: 'WebM', noun: 'audio' },\n 'audio/flac': { name: 'FLAC', noun: 'audio' },\n 'video/mp4': { name: 'MP4', noun: 'video' },\n 'video/webm': { name: 'WebM', noun: 'video' },\n 'video/quicktime': { name: 'QuickTime', noun: 'video' },\n 'video/ogg': { name: 'Ogg', noun: 'video' },\n 'application/pdf': { name: 'PDF', noun: 'file' },\n 'application/zip': { name: 'ZIP', noun: 'file' },\n 'application/json': { name: 'JSON', noun: 'file' },\n 'text/plain': { name: 'plain-text', noun: 'file' },\n 'text/csv': { name: 'CSV', noun: 'file' },\n 'application/msword': { name: 'Word', noun: 'file' },\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': {\n name: 'Word',\n noun: 'file',\n },\n 'application/vnd.ms-excel': { name: 'Excel', noun: 'file' },\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': {\n name: 'Excel',\n noun: 'file',\n },\n 'application/octet-stream': { name: 'binary', noun: 'file' },\n};\n\n/** The noun phrases one locale gives a type, singular and plural. */\ninterface NounWords {\n readonly image: string;\n readonly imagePlural: string;\n readonly audio: string;\n readonly audioPlural: string;\n readonly video: string;\n readonly videoPlural: string;\n readonly file: string;\n readonly filePlural: string;\n}\n\n/**\n * The classifier noun each locale pairs with a short type name.\n *\n * English puts the article and the noun after the acronym (`a JPEG image`); French, Spanish,\n * Portuguese, German and Italian do the same with their own article and gender; Russian, Arabic\n * and Chinese put the noun first and carry no article, which is why the phrase, not a template,\n * is the unit here.\n */\nconst NOUNS: Readonly<Record<CountryLocale, NounWords>> = {\n en: {\n image: 'image',\n imagePlural: 'images',\n audio: 'audio file',\n audioPlural: 'audio files',\n video: 'video',\n videoPlural: 'videos',\n file: 'file',\n filePlural: 'files',\n },\n es: {\n image: 'imagen',\n imagePlural: 'imágenes',\n audio: 'archivo de audio',\n audioPlural: 'archivos de audio',\n video: 'vídeo',\n videoPlural: 'vídeos',\n file: 'archivo',\n filePlural: 'archivos',\n },\n pt: {\n image: 'imagem',\n imagePlural: 'imagens',\n audio: 'ficheiro de áudio',\n audioPlural: 'ficheiros de áudio',\n video: 'vídeo',\n videoPlural: 'vídeos',\n file: 'ficheiro',\n filePlural: 'ficheiros',\n },\n fr: {\n image: 'image',\n imagePlural: 'images',\n audio: 'fichier audio',\n audioPlural: 'fichiers audio',\n video: 'vidéo',\n videoPlural: 'vidéos',\n file: 'fichier',\n filePlural: 'fichiers',\n },\n ar: {\n image: 'صورة',\n imagePlural: 'صور',\n audio: 'ملف صوتي',\n audioPlural: 'ملفات صوتية',\n video: 'فيديو',\n videoPlural: 'مقاطع فيديو',\n file: 'ملف',\n filePlural: 'ملفات',\n },\n de: {\n image: 'Bild',\n imagePlural: 'Bilder',\n audio: 'Audiodatei',\n audioPlural: 'Audiodateien',\n video: 'Video',\n videoPlural: 'Videos',\n file: 'Datei',\n filePlural: 'Dateien',\n },\n it: {\n image: 'immagine',\n imagePlural: 'immagini',\n audio: 'file audio',\n audioPlural: 'file audio',\n video: 'video',\n videoPlural: 'video',\n file: 'file',\n filePlural: 'file',\n },\n ru: {\n image: 'изображение',\n imagePlural: 'изображения',\n audio: 'аудиофайл',\n audioPlural: 'аудиофайлы',\n video: 'видео',\n videoPlural: 'видеофайлы',\n file: 'файл',\n filePlural: 'файлы',\n },\n zh: {\n image: '图片',\n imagePlural: '图片',\n audio: '音频文件',\n audioPlural: '音频文件',\n video: '视频',\n videoPlural: '视频',\n file: '文件',\n filePlural: '文件',\n },\n};\n\n/** The phrase a type this table does not carry is called, singular and plural. */\nconst UNKNOWN: Readonly<Record<CountryLocale, { readonly one: string; readonly many: string }>> = {\n en: {\n one: 'a type this field does not take',\n many: 'other file types',\n },\n es: {\n one: 'un tipo que este campo no admite',\n many: 'otros tipos de archivo',\n },\n pt: {\n one: 'um tipo que este campo não aceita',\n many: 'outros tipos de ficheiro',\n },\n fr: {\n one: \"un type que ce champ n'accepte pas\",\n many: \"d'autres types de fichier\",\n },\n ar: {\n one: 'نوع لا يقبله هذا الحقل',\n many: 'أنواع ملفات أخرى',\n },\n de: {\n one: 'ein Typ, den dieses Feld nicht annimmt',\n many: 'andere Dateitypen',\n },\n it: {\n one: 'un tipo che questo campo non accetta',\n many: 'altri tipi di file',\n },\n ru: {\n one: 'тип, который это поле не принимает',\n many: 'другие типы файлов',\n },\n zh: {\n one: '此字段不接受的文件类型',\n many: '其他文件类型',\n },\n};\n\n/**\n * The grammatical gender each locale gives a classifier noun.\n *\n * The article follows the noun, not the acronym: Spanish says `una imagen` and `un archivo`, and\n * German says `ein Bild` and `eine Audiodatei`. English is the one locale whose article follows\n * the type name instead (`a JPEG image`, `an MP3 audio file`), which is why the name is a\n * parameter.\n */\nconst GENDER: Readonly<Record<CountryLocale, Readonly<Record<MediaNoun, 'f' | 'm' | 'n'>>>> = {\n en: { image: 'n', audio: 'n', video: 'n', file: 'n' },\n es: { image: 'f', audio: 'm', video: 'm', file: 'm' },\n pt: { image: 'f', audio: 'm', video: 'm', file: 'm' },\n fr: { image: 'f', audio: 'm', video: 'f', file: 'm' },\n ar: { image: 'f', audio: 'm', video: 'm', file: 'm' },\n de: { image: 'n', audio: 'f', video: 'n', file: 'f' },\n it: { image: 'f', audio: 'm', video: 'm', file: 'm' },\n ru: { image: 'n', audio: 'm', video: 'n', file: 'm' },\n zh: { image: 'n', audio: 'n', video: 'n', file: 'n' },\n};\n\n/** The indefinite article a locale puts before a named type. */\nfunction articleOf(locale: CountryLocale, noun: MediaNoun, name: string): string {\n switch (locale) {\n case 'en':\n return /^[aeiou]/iu.test(name) ? 'an' : 'a';\n case 'es':\n return GENDER.es[noun] === 'f' ? 'una' : 'un';\n case 'pt':\n return GENDER.pt[noun] === 'f' ? 'uma' : 'um';\n case 'fr':\n return GENDER.fr[noun] === 'f' ? 'une' : 'un';\n case 'de':\n return GENDER.de[noun] === 'f' ? 'eine' : 'ein';\n case 'it':\n return GENDER.it[noun] === 'f' ? 'una' : 'un';\n case 'ar':\n case 'ru':\n case 'zh':\n return '';\n }\n}\n\n/** Whether a locale writes the type name before the classifier noun rather than after it. */\nfunction nameFirst(locale: CountryLocale): boolean {\n return locale === 'en' || locale === 'zh';\n}\n\n/** The media type an `accept` entry denotes, resolving an extension through the closed table. */\nfunction mediaTypeOf(entry: string): string {\n const lower = entry.toLowerCase();\n return lower.startsWith('.') ? (MEDIA_EXTENSION_TYPES.get(lower) ?? '') : lower;\n}\n\n/** The type name and noun one entry denotes, or `undefined` when the table does not carry it. */\nfunction namedType(entry: string): MediaTypeName | undefined {\n const type = mediaTypeOf(entry);\n return type === '' ? undefined : MEDIA_TYPES[type];\n}\n\n/** A singular noun phrase for a media type, never its wire spelling. */\nexport function mediaTypeNameIn(locale: CountryLocale, mediaType: string): string {\n const named = namedType(mediaType);\n if (named === undefined) return UNKNOWN[locale].one;\n const noun = NOUNS[locale][named.noun];\n const article = articleOf(locale, named.noun, named.name);\n if (nameFirst(locale)) {\n return article === '' ? `${named.name} ${noun}` : `${article} ${named.name} ${noun}`;\n }\n // German compounds the type and the noun: `ein JPEG-Bild`, `eine ZIP-Datei`.\n if (locale === 'de') return `${article} ${named.name}-${noun}`;\n // Italian elides the feminine article before a vowel: `un'immagine`, not `una immagine`.\n if (locale === 'it' && article === 'una' && /^[aeiou]/iu.test(noun)) {\n return `un'${noun} ${named.name}`;\n }\n return article === '' ? `${noun} ${named.name}` : `${article} ${noun} ${named.name}`;\n}\n\n/** The plural classifier a locale gives one noun kind. */\nfunction pluralOf(locale: CountryLocale, noun: MediaNoun): string {\n switch (noun) {\n case 'image':\n return NOUNS[locale].imagePlural;\n case 'audio':\n return NOUNS[locale].audioPlural;\n case 'video':\n return NOUNS[locale].videoPlural;\n case 'file':\n return NOUNS[locale].filePlural;\n }\n}\n\n/** A plural noun phrase for a media type, for the list a field accepts. */\nexport function mediaTypePluralIn(locale: CountryLocale, mediaType: string): string {\n const named = namedType(mediaType);\n if (named === undefined) return UNKNOWN[locale].many;\n const noun = pluralOf(locale, named.noun);\n if (nameFirst(locale)) return `${named.name} ${noun}`;\n if (locale === 'de') return `${named.name}-${noun}`;\n return `${noun} ${named.name}`;\n}\n\n/** The conjunction a locale joins two admitted media types with. */\nexport function mediaTypeSeparatorIn(locale: CountryLocale): string {\n switch (locale) {\n case 'en':\n return ' or ';\n case 'es':\n return ' o ';\n case 'pt':\n return ' ou ';\n case 'fr':\n return ' ou ';\n case 'ar':\n return ' أو ';\n case 'de':\n return ' oder ';\n case 'it':\n return ' o ';\n case 'ru':\n return ' или ';\n case 'zh':\n return '或';\n }\n}\n"]}
@@ -0,0 +1,52 @@
1
+ import type { DigitPolicy } from './digits.js';
2
+ import type { Locale } from './locale.js';
3
+ declare const canonicalMoneyTextBrand: unique symbol;
4
+ /**
5
+ * Money text at a declared scale: the `.`-separated amount the existing buffer prints, such as
6
+ * `1200.00` or `-0.50`.
7
+ *
8
+ * It is deliberately not canonical decimal text: a scale of two legitimately keeps two trailing
9
+ * zeros, and the amount is still exact because the declaration, not the spelling, states the
10
+ * scale.
11
+ */
12
+ export type CanonicalMoneyText = string & {
13
+ readonly [canonicalMoneyTextBrand]: 'CanonicalMoneyText';
14
+ };
15
+ /**
16
+ * True when `value` is the `.`-separated money text a declared scale produces.
17
+ *
18
+ * The wire allows a scale of `0..6`, so one to six fraction digits is the bound. Negative zero
19
+ * is refused for the same reason the wire refuses `-0`: two spellings of zero would be two
20
+ * amounts to a reader and one amount to the record.
21
+ */
22
+ export declare function isCanonicalMoneyText(value: unknown): value is CanonicalMoneyText;
23
+ declare const currencyCodeBrand: unique symbol;
24
+ /** An ISO 4217-shaped currency code: three upper-case ASCII letters. */
25
+ export type CurrencyCode = string & {
26
+ readonly [currencyCodeBrand]: 'CurrencyCode';
27
+ };
28
+ /** True when `value` is three upper-case ASCII letters. */
29
+ export declare function isCurrencyCode(value: unknown): value is CurrencyCode;
30
+ /**
31
+ * One amount as the chrome prints it, with the currency it is denominated in.
32
+ *
33
+ * `amount` carries the locale's grouping and decimal marks and no currency mark at all. The copy
34
+ * layer owns placement, so this function cannot invent a symbol before or after the digits; it
35
+ * returns the currency code beside the amount so the layer that writes the sentence has both.
36
+ */
37
+ export interface MoneyDisplay {
38
+ readonly amount: string;
39
+ readonly currency: CurrencyCode;
40
+ }
41
+ /**
42
+ * The money display for one amount, locale and currency.
43
+ *
44
+ * The digits, sign and scale are the caller's canonical text unchanged; only the integer part is
45
+ * grouped and only the two marks are localised. CLDR's `minimumGroupingDigits` applies: Spanish
46
+ * prints a four-digit amount as `1234,00` and a five-digit one as `12.345,00`, while German
47
+ * prints `1.234,00` at four. The currency is passed through, not printed, because placement
48
+ * belongs to the copy layer.
49
+ */
50
+ export declare function formatMoney(amount: CanonicalMoneyText, locale: Locale, currency: CurrencyCode, policy?: DigitPolicy): MoneyDisplay;
51
+ export {};
52
+ //# sourceMappingURL=money.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../src/format/money.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,MAAM,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG;IACxC,QAAQ,CAAC,CAAC,uBAAuB,CAAC,EAAE,oBAAoB,CAAC;CAC1D,CAAC;AAIF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAGhF;AAED,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAC;AAE/C,wEAAwE;AACxE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,iBAAiB,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC;AAErF,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,YAAY,EACtB,MAAM,GAAE,WAAkC,GACzC,YAAY,CAKd"}