prosebook 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/README.md +345 -29
  2. package/dist/bun.d.ts +34 -0
  3. package/dist/bun.d.ts.map +1 -0
  4. package/dist/bun.js +98 -0
  5. package/dist/bun.js.map +1 -0
  6. package/dist/bundle-CpUIWb9j.d.ts +6 -0
  7. package/dist/bundle-CpUIWb9j.d.ts.map +1 -0
  8. package/dist/bundle-DboItAre.js +111 -0
  9. package/dist/bundle-DboItAre.js.map +1 -0
  10. package/dist/cli.js +51 -56
  11. package/dist/cli.js.map +1 -1
  12. package/dist/compile-ClK9htKr.d.ts +16 -0
  13. package/dist/compile-ClK9htKr.d.ts.map +1 -0
  14. package/dist/{config-_4HfnJQu.d.ts → config-CzaJJQ60.d.ts} +75 -2
  15. package/dist/config-CzaJJQ60.d.ts.map +1 -0
  16. package/dist/{config-D--RITk2.js → config-nWZf9QmF.js} +42 -212
  17. package/dist/config-nWZf9QmF.js.map +1 -0
  18. package/dist/config.d.ts +2 -2
  19. package/dist/config.js +1 -1
  20. package/dist/{copy-DXnzXsJa.d.ts → copy-B3V_QRkT.d.ts} +20 -7
  21. package/dist/copy-B3V_QRkT.d.ts.map +1 -0
  22. package/dist/copy-Bo_FIoLy.js +154 -0
  23. package/dist/copy-Bo_FIoLy.js.map +1 -0
  24. package/dist/endpoints-BgG_5Vpm.js +96 -0
  25. package/dist/endpoints-BgG_5Vpm.js.map +1 -0
  26. package/dist/generate-BW3N8EGb.js +5488 -0
  27. package/dist/generate-BW3N8EGb.js.map +1 -0
  28. package/dist/helpers-BWGcD0kS.js +96 -0
  29. package/dist/helpers-BWGcD0kS.js.map +1 -0
  30. package/dist/icu-Dej0mNsF.js +218 -0
  31. package/dist/icu-Dej0mNsF.js.map +1 -0
  32. package/dist/index.d.ts +12 -2
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +4 -188
  35. package/dist/inspector.d.ts +4 -1
  36. package/dist/inspector.d.ts.map +1 -1
  37. package/dist/inspector.js +7 -2
  38. package/dist/inspector.js.map +1 -1
  39. package/dist/locale-DpQA1pqH.js +70 -0
  40. package/dist/locale-DpQA1pqH.js.map +1 -0
  41. package/dist/next-loader.d.ts +11 -0
  42. package/dist/next-loader.d.ts.map +1 -0
  43. package/dist/next-loader.js +17 -0
  44. package/dist/next-loader.js.map +1 -0
  45. package/dist/next.d.ts +30 -0
  46. package/dist/next.d.ts.map +1 -0
  47. package/dist/next.js +160 -0
  48. package/dist/next.js.map +1 -0
  49. package/dist/react/index.d.ts +3 -3
  50. package/dist/react/index.d.ts.map +1 -1
  51. package/dist/react/index.js.map +1 -1
  52. package/dist/react/server.d.ts +20 -0
  53. package/dist/react/server.d.ts.map +1 -0
  54. package/dist/react/server.js +34 -0
  55. package/dist/react/server.js.map +1 -0
  56. package/dist/{sarif-CI8HOokm.js → sarif-B5nrMqrT.js} +103 -87
  57. package/dist/sarif-B5nrMqrT.js.map +1 -0
  58. package/dist/scan-Bx0_yDSi.js +387 -0
  59. package/dist/scan-Bx0_yDSi.js.map +1 -0
  60. package/dist/tools.d.ts +83 -90
  61. package/dist/tools.d.ts.map +1 -1
  62. package/dist/tools.js +5 -4
  63. package/dist/vite.d.ts +3 -2
  64. package/dist/vite.d.ts.map +1 -1
  65. package/dist/vite.js +29 -109
  66. package/dist/vite.js.map +1 -1
  67. package/package.json +37 -4
  68. package/src/bun.ts +132 -0
  69. package/src/cli.ts +60 -58
  70. package/src/index.ts +1 -1
  71. package/src/inspector.ts +8 -3
  72. package/src/next-loader.ts +16 -0
  73. package/src/next.ts +188 -0
  74. package/src/react/index.tsx +6 -6
  75. package/src/react/server.ts +37 -0
  76. package/src/runtime/copy.ts +22 -3
  77. package/src/runtime/helpers.ts +54 -18
  78. package/src/runtime/locale.ts +19 -0
  79. package/src/runtime/types.ts +21 -6
  80. package/src/tools/bundle.ts +131 -0
  81. package/src/tools/catalog.ts +2 -2
  82. package/src/tools/compile.ts +60 -23
  83. package/src/tools/config.ts +57 -0
  84. package/src/tools/endpoints.ts +121 -0
  85. package/src/tools/entry.ts +77 -0
  86. package/src/tools/generate.ts +2 -0
  87. package/src/tools/icu.ts +63 -7
  88. package/src/tools/index.ts +6 -3
  89. package/src/tools/lock.ts +7 -0
  90. package/src/tools/mf1.ts +21 -7
  91. package/src/tools/mf2.ts +249 -57
  92. package/src/tools/migrate.ts +3 -2
  93. package/src/tools/native/android.ts +201 -0
  94. package/src/tools/native/apple.ts +139 -0
  95. package/src/tools/native/emit.ts +87 -0
  96. package/src/tools/native/index.ts +48 -0
  97. package/src/tools/native/kotlin.ts +269 -0
  98. package/src/tools/native/model.ts +292 -0
  99. package/src/tools/native/number.ts +210 -0
  100. package/src/tools/native/plurals.ts +103 -0
  101. package/src/tools/native/printf.ts +95 -0
  102. package/src/tools/native/rust.ts +367 -0
  103. package/src/tools/native/swift.ts +326 -0
  104. package/src/tools/syntax.ts +3 -3
  105. package/src/tools/todo.ts +118 -0
  106. package/src/vite.ts +28 -114
  107. package/dist/config-D--RITk2.js.map +0 -1
  108. package/dist/config-_4HfnJQu.d.ts.map +0 -1
  109. package/dist/copy-DXnzXsJa.d.ts.map +0 -1
  110. package/dist/helpers-BPuPGjQP.js +0 -61
  111. package/dist/helpers-BPuPGjQP.js.map +0 -1
  112. package/dist/index.js.map +0 -1
  113. package/dist/sarif-CI8HOokm.js.map +0 -1
  114. package/dist/scan-Ch2BfIUD.js +0 -2561
  115. package/dist/scan-Ch2BfIUD.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-B3V_QRkT.d.ts","names":[],"sources":["../src/runtime/types.ts","../src/runtime/copy.ts"],"mappings":";;;;;;;;UASiB;EACf;EACA;;;KAIU;GAAmB,cAAc;;;;;;;;;;;;;;;UAgB5B;KAEL,qBAAqB;EAAmB,gBAAgB,UAAU;IAAkB,IAAI;KACxF,mBAAmB;EAAmB,cAAc;IAAqB;;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G,YAAY;;EAE3B,SAAS;;EAET;KAAU,cAAc;;;EAExB,aAAa,aAAa,QAAQ;;;;;EAKlC,WAAW,OAAO,OAAO,aAAa,QAAQ;;;UAI/B,KAAK,UAAU,gBAAgB,eAAe;;WAEpD,QAAQ;WACR,kBAAkB;WAClB,QAAQ;;WAER;cAAkB,cAAc;;;WAEhC,OAAO;;EAEhB,EAAE,gBAAgB,YAAY,YAAY,KAAK,MAAM,MAAM,UAAU,EAAE;;EAEvE,KAAK,UAAU,QAAQ,IAAI,aAAa,YAAY,KAAK,MAAM,QAAQ,UAAU,EAAE,IAAI,KAAK,OAAO;EACnG,IAAI,YAAY,cAAc,aAAa;;EAE3C,UAAU,YAAY,MAAM,wCAAwC;;WAE3D;;EAET,UAAU,YAAY;;EAEtB,OAAO,YAAY,wBAAwB,UAAU,KAAK;;EAE1D,KAAK,YAAY,OAAO,eAAe,UAAU,KAAK;;EAEtD,KAAK,YAAY,OAAO,kBAAkB,UAAU,KAAK;;EAEzD,SAAS,YAAY,eAAe,MAAM,KAAK,wBAAwB,UAAU,KAAK;;;iBAaxE,WAAW,UAAU,eAAe,kBAAkB,SAAS,QAAQ,GAAG,IAAI,UAAS,YAAY,KAAU,KAAK,GAAG"}
@@ -0,0 +1,154 @@
1
+ import { n as flatten, t as createHelpers } from "./helpers-BWGcD0kS.js";
2
+ import { n as chainOf, r as negotiate } from "./locale-DpQA1pqH.js";
3
+ // src/runtime/copy.ts
4
+ /** Ties a generated catalog to its message shapes. Called by generated code. */
5
+ function defineCatalog(catalog) {
6
+ return catalog;
7
+ }
8
+ /** A message as the text it puts on screen: rendered again with its tags left as their text. */
9
+ function textOf(message, values, h) {
10
+ if (typeof message === "string") return message;
11
+ const plain = Object.fromEntries(Object.entries(values).filter(([, v]) => typeof v !== "function"));
12
+ return flatten(message(plain, h)).join("");
13
+ }
14
+ /** A catalog reader with a current locale. Create one per app, or one per request on a server. */
15
+ function createCopy(catalog, options = {}) {
16
+ const loaded = /* @__PURE__ */ new Map();
17
+ const pending = /* @__PURE__ */ new Map();
18
+ const listeners = /* @__PURE__ */ new Set();
19
+ const defaultTags = options.tags ?? {};
20
+ const formatters = /* @__PURE__ */ new Map();
21
+ let reading;
22
+ const helpers = (l) => createHelpers(l, (error) => {
23
+ if (reading === void 0) return;
24
+ if (options.onError) options.onError(error, reading, l);
25
+ else console.error(`prosebook: ${reading} in ${l}: ${error.message}`);
26
+ });
27
+ for (const [locale, messages] of Object.entries(catalog.messages)) loaded.set(locale, {
28
+ messages,
29
+ h: helpers(locale)
30
+ });
31
+ let locale = catalog.source;
32
+ let chain = layers(chainOf(locale, catalog.locales, catalog.source));
33
+ let latest = 0;
34
+ let version = 0;
35
+ function changed() {
36
+ version++;
37
+ for (const listener of listeners) listener();
38
+ }
39
+ globalThis.__PROSEBOOK_HOT__?.add((l, messages) => {
40
+ const layer = loaded.get(l);
41
+ if (layer === void 0) return;
42
+ layer.messages = messages;
43
+ changed();
44
+ });
45
+ function layers(locales) {
46
+ return locales.flatMap((l) => loaded.get(l) ?? []);
47
+ }
48
+ function load(l) {
49
+ const done = loaded.get(l);
50
+ if (done) return Promise.resolve(done);
51
+ let p = pending.get(l);
52
+ if (p === void 0) {
53
+ const loader = catalog.loaders[l];
54
+ if (loader === void 0) return Promise.reject(/* @__PURE__ */ new Error(`prosebook: no messages for locale "${l}"`));
55
+ p = loader().then((mod) => {
56
+ const layer = {
57
+ messages: mod.default,
58
+ h: helpers(l)
59
+ };
60
+ loaded.set(l, layer);
61
+ pending.delete(l);
62
+ return layer;
63
+ });
64
+ p.catch(() => pending.delete(l));
65
+ pending.set(l, p);
66
+ }
67
+ return p;
68
+ }
69
+ async function setLocale(next) {
70
+ const target = negotiate(next, catalog.locales, catalog.source);
71
+ const ticket = ++latest;
72
+ const locales = chainOf(target, catalog.locales, catalog.source);
73
+ await Promise.all(locales.map(load));
74
+ if (ticket !== latest || target === locale) return;
75
+ locale = target;
76
+ chain = layers(locales);
77
+ formatters.clear();
78
+ changed();
79
+ }
80
+ function find(key) {
81
+ for (const layer of chain) {
82
+ const message = layer.messages[key];
83
+ if (message !== void 0) return [message, layer.h];
84
+ }
85
+ }
86
+ function render(key, values) {
87
+ const found = find(key);
88
+ if (found === void 0) return options.onMissing ? options.onMissing(key, locale) : key;
89
+ const [message, h] = found;
90
+ reading = key;
91
+ let out;
92
+ try {
93
+ out = typeof message === "string" ? message : message(values, h);
94
+ } finally {
95
+ reading = void 0;
96
+ }
97
+ const read = globalThis.__PROSEBOOK_READ__;
98
+ if (read !== void 0) read(key, typeof out === "string" ? out : textOf(message, values, h), h.locale);
99
+ return out;
100
+ }
101
+ function formatter(kind, options, make) {
102
+ const id = `${kind}${JSON.stringify(options ?? {})}`;
103
+ let made = formatters.get(id);
104
+ if (made === void 0) formatters.set(id, made = make());
105
+ return made;
106
+ }
107
+ const ready = options.locale === void 0 ? Promise.resolve() : setLocale(options.locale);
108
+ return {
109
+ get locale() {
110
+ return locale;
111
+ },
112
+ get version() {
113
+ return version;
114
+ },
115
+ locales: catalog.locales,
116
+ source: catalog.source,
117
+ tags: defaultTags,
118
+ ready,
119
+ t(key, ...args) {
120
+ const out = render(key, args[0] ?? {});
121
+ return typeof out === "string" ? out : flatten(out).join("");
122
+ },
123
+ rich(key, ...values) {
124
+ const out = render(key, {
125
+ ...defaultTags,
126
+ ...values[0]
127
+ });
128
+ return flatten(out);
129
+ },
130
+ has(key) {
131
+ return find(key) !== void 0;
132
+ },
133
+ setLocale,
134
+ subscribe(listener) {
135
+ listeners.add(listener);
136
+ return () => listeners.delete(listener);
137
+ },
138
+ number(value, opts) {
139
+ return formatter("n", opts, () => new Intl.NumberFormat(locale, opts)).format(value);
140
+ },
141
+ date(value, opts) {
142
+ return formatter("d", opts, () => new Intl.DateTimeFormat(locale, opts)).format(value);
143
+ },
144
+ list(items, opts) {
145
+ return formatter("l", opts, () => new Intl.ListFormat(locale, opts)).format(items);
146
+ },
147
+ relative(value, unit, opts) {
148
+ return formatter("r", opts, () => new Intl.RelativeTimeFormat(locale, opts)).format(value, unit);
149
+ }
150
+ };
151
+ }
152
+ export { defineCatalog as n, createCopy as t };
153
+
154
+ //# sourceMappingURL=copy-Bo_FIoLy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-Bo_FIoLy.js","names":[],"sources":["../src/runtime/copy.ts"],"sourcesContent":["import { createHelpers, flatten } from './helpers.ts';\nimport { chainOf, negotiate } from './locale.ts';\nimport type {\n AnyTagFn,\n ArgsParam,\n Chunks,\n Compiled,\n CompiledMessages,\n Helpers,\n DevHooks,\n MessageShapes,\n RichKey,\n RichParam,\n Values,\n} from './types.ts';\n\ntype Loader = () => Promise<{ default: CompiledMessages }>;\n\n/** A generated catalog: which locales exist, which ship in the bundle and how to fetch the rest. */\nexport interface Catalog<M extends MessageShapes = MessageShapes, L extends string = string> {\n /** The locale the catalog is written in, which every other falls back to. */\n readonly source: L;\n readonly locales: readonly L[];\n /** Locales whose messages ship in the bundle. Always holds the source. */\n readonly messages: { readonly [locale in L]?: CompiledMessages };\n /** Locales fetched when first asked for. */\n readonly loaders: { readonly [locale in L]?: Loader };\n /** Type-only: carries the message shapes from the generated module to `createCopy`. */\n readonly '~messages'?: M;\n}\n\n/** Ties a generated catalog to its message shapes. Called by generated code. */\nexport function defineCatalog<M extends MessageShapes, L extends string = string>(\n catalog: Omit<Catalog<M, L>, '~messages'>,\n): Catalog<M, L> {\n return catalog;\n}\n\nexport interface CopyOptions<L extends string> {\n /** The locale to start in, or the locales a reader prefers, most preferred first. Defaults to the source. */\n locale?: L | (string & {}) | readonly string[];\n /** Tag renderers every rich read gets unless it supplies its own, such as `b` or `link`. */\n tags?: { [tag: string]: AnyTagFn };\n /** What a key the catalog lacks reads as. Defaults to the key itself. */\n onMissing?: (key: string, locale: L) => string;\n /**\n * Told of a placeholder that had no value, or one `Intl` refused (`currency: 'euro'`): the message\n * still renders, showing `{name}` there. Defaults to `console.error`.\n */\n onError?: (error: Error, key: string, locale: L) => void;\n}\n\n/** Its methods don't use `this`, so they can be passed around and destructured: `const { t } = copy`. */\nexport interface Copy<M extends MessageShapes = MessageShapes, L extends string = string> {\n /** The locale messages are coming back in. */\n readonly locale: L;\n readonly locales: readonly L[];\n readonly source: L;\n /** The tag renderers rich reads fall back to, from `CopyOptions.tags`. */\n readonly tags: { readonly [tag: string]: AnyTagFn };\n /** Settles once the starting locale's messages are loaded. */\n readonly ready: Promise<void>;\n /** A message as plain text. Tags render as the text they wrap. */\n t<K extends keyof M & string>(this: void, key: K, ...args: ArgsParam<M[K]>): string;\n /** A message with elements inside it: each tag's function turns what it wraps into a node. */\n rich<K extends RichKey<M>, N = unknown>(this: void, key: K, ...values: RichParam<M[K], N>): Chunks<N>;\n has(this: void, key: string): key is keyof M & string;\n /** Switches locale once its messages (and its fallbacks') are loaded. */\n setLocale(this: void, next: L | (string & {}) | readonly string[]): Promise<void>;\n /** Counts changes to what messages read as: each locale switch, and each catalog edit in dev. */\n readonly version: number;\n /** Called after each locale switch, and in dev after each catalog edit. Returns the unsubscribe. */\n subscribe(this: void, listener: () => void): () => void;\n /** Formats a number in the current locale. */\n number(this: void, value: number | bigint, options?: Intl.NumberFormatOptions): string;\n /** Formats a date in the current locale. */\n date(this: void, value: Date | number, options?: Intl.DateTimeFormatOptions): string;\n /** Joins items as a list in the current locale: `a, b and c`. */\n list(this: void, items: Iterable<string>, options?: Intl.ListFormatOptions): string;\n /** `in 3 days`, `2 hours ago`, in the current locale. */\n relative(this: void, value: number, unit: Intl.RelativeTimeFormatUnit, options?: Intl.RelativeTimeFormatOptions): string;\n}\n\ntype Layer = { messages: CompiledMessages; h: Helpers };\n\n/** A message as the text it puts on screen: rendered again with its tags left as their text. */\nfunction textOf(message: Compiled, values: Values, h: Helpers): string {\n if (typeof message === 'string') return message;\n const plain = Object.fromEntries(Object.entries(values).filter(([, v]) => typeof v !== 'function'));\n return flatten(message(plain, h)).join('');\n}\n\n/** A catalog reader with a current locale. Create one per app, or one per request on a server. */\nexport function createCopy<M extends MessageShapes, L extends string>(catalog: Catalog<M, L>, options: CopyOptions<L> = {}): Copy<M, L> {\n const loaded = new Map<L, Layer>();\n const pending = new Map<L, Promise<Layer>>();\n const listeners = new Set<() => void>();\n const defaultTags = options.tags ?? {};\n const formatters = new Map<string, Intl.NumberFormat | Intl.DateTimeFormat | Intl.ListFormat | Intl.RelativeTimeFormat>();\n // The key being rendered, which a helper's report names; none while the inspector renders it again.\n let reading: string | undefined;\n const helpers = (l: L) =>\n createHelpers(l, (error) => {\n if (reading === undefined) return;\n if (options.onError) options.onError(error, reading, l);\n else console.error(`prosebook: ${reading} in ${l}: ${error.message}`);\n });\n\n for (const [locale, messages] of Object.entries(catalog.messages) as [L, CompiledMessages][])\n loaded.set(locale, { messages, h: helpers(locale) });\n\n let locale = catalog.source;\n let chain: Layer[] = layers(chainOf(locale, catalog.locales, catalog.source));\n let latest = 0;\n let version = 0;\n\n function changed() {\n version++;\n for (const listener of listeners) listener();\n }\n\n // A layer's messages are swapped in place, so the chain that holds it reads the new ones.\n (globalThis as DevHooks).__PROSEBOOK_HOT__?.add((l, messages) => {\n const layer = loaded.get(l as L);\n if (layer === undefined) return;\n layer.messages = messages;\n changed();\n });\n\n function layers(locales: L[]): Layer[] {\n return locales.flatMap((l) => loaded.get(l) ?? []);\n }\n\n function load(l: L): Promise<Layer> {\n const done = loaded.get(l);\n if (done) return Promise.resolve(done);\n let p = pending.get(l);\n if (p === undefined) {\n // oxlint-disable-next-line typescript/no-unsafe-enum-assignment -- `L` is a string union, not an enum; the rule misreads the mapped type\n const loader = catalog.loaders[l];\n if (loader === undefined) return Promise.reject(new Error(`prosebook: no messages for locale \"${l}\"`));\n p = loader().then((mod) => {\n const layer = { messages: mod.default, h: helpers(l) };\n loaded.set(l, layer);\n pending.delete(l);\n return layer;\n });\n p.catch(() => pending.delete(l));\n pending.set(l, p);\n }\n return p;\n }\n\n async function setLocale(next: L | (string & {}) | readonly string[]): Promise<void> {\n const target = negotiate(next, catalog.locales, catalog.source);\n const ticket = ++latest;\n const locales = chainOf(target, catalog.locales, catalog.source);\n await Promise.all(locales.map(load));\n // A slower load must not undo a later switch.\n if (ticket !== latest || target === locale) return;\n locale = target;\n chain = layers(locales);\n formatters.clear();\n changed();\n }\n\n function find(key: string): [Compiled, Helpers] | undefined {\n for (const layer of chain) {\n const message = layer.messages[key];\n if (message !== undefined) return [message, layer.h];\n }\n return undefined;\n }\n\n function render(key: string, values: Values): unknown {\n const found = find(key);\n if (found === undefined) return options.onMissing ? options.onMissing(key, locale) : key;\n const [message, h] = found;\n reading = key;\n let out: unknown;\n try {\n out = typeof message === 'string' ? message : message(values, h);\n } finally {\n reading = undefined;\n }\n const read = (globalThis as DevHooks).__PROSEBOOK_READ__;\n if (read !== undefined) read(key, typeof out === 'string' ? out : textOf(message, values, h), h.locale);\n return out;\n }\n\n function formatter<F>(kind: string, options: object | undefined, make: () => F): F {\n const id = `${kind}${JSON.stringify(options ?? {})}`;\n let made = formatters.get(id) as F | undefined;\n if (made === undefined) formatters.set(id, (made = make()) as never);\n return made;\n }\n\n const ready = options.locale === undefined ? Promise.resolve() : setLocale(options.locale);\n\n return {\n get locale() {\n return locale;\n },\n get version() {\n return version;\n },\n locales: catalog.locales,\n source: catalog.source,\n tags: defaultTags,\n ready,\n t(key, ...args) {\n const out = render(key, (args[0] as Values | undefined) ?? {});\n return typeof out === 'string' ? out : flatten(out).join('');\n },\n rich(key, ...values) {\n const out = render(key, { ...defaultTags, ...(values[0] as Values | undefined) });\n return flatten(out) as Chunks<never>;\n },\n has(key): key is keyof M & string {\n return find(key) !== undefined;\n },\n setLocale,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n number(value, opts) {\n return formatter('n', opts, () => new Intl.NumberFormat(locale, opts)).format(value);\n },\n date(value, opts) {\n return formatter('d', opts, () => new Intl.DateTimeFormat(locale, opts)).format(value);\n },\n list(items, opts) {\n return formatter('l', opts, () => new Intl.ListFormat(locale, opts)).format(items);\n },\n relative(value, unit, opts) {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GAAG,MAAM,KAAA;EACvB;EACA;EACA,UAAU,UAAU;GAClB,UAAU,IAAI,QAAQ;GACtB,aAAa,UAAU,OAAO,QAAQ;EACxC;EACA,OAAO,OAAO,MAAM;GAClB,OAAO,UAAU,KAAK,YAAY,IAAI,KAAK,aAAa,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK;EACrF;EACA,KAAK,OAAO,MAAM;GAChB,OAAO,UAAU,KAAK,YAAY,IAAI,KAAK,eAAe,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK;EACvF;EACA,KAAK,OAAO,MAAM;GAChB,OAAO,UAAU,KAAK,YAAY,IAAI,KAAK,WAAW,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK;EACnF;EACA,SAAS,OAAO,MAAM,MAAM;GAC1B,OAAO,UAAU,KAAK,YAAY,IAAI,KAAK,mBAAmB,QAAQ,IAAI,CAAC,CAAC,CAAC,OAAO,OAAO,IAAI;EACjG;CACF;AACF"}
@@ -0,0 +1,96 @@
1
+ import { C as entryLocation, T as loadCatalog, b as readEntry, v as editEntry, x as CatalogError } from "./generate-BW3N8EGb.js";
2
+ // src/tools/endpoints.ts
3
+ /** Answers the inspector's requests, and nothing for any other path. */
4
+ function inspectorEndpoints(config, { base = "/", open }) {
5
+ return async (req) => {
6
+ const url = new URL(req.url);
7
+ if (url.pathname === `${base}__prosebook/open`) return openEntry(await config, url, open);
8
+ if (url.pathname === `${base}__prosebook/entry`) return entry(await config, req, url);
9
+ };
10
+ }
11
+ /**
12
+ * `?key=cart.items&locale=de`: the translation's entry, or the catalog's with `catalog` or when the
13
+ * locale has none. Read from disk, so a key added since the page loaded is found.
14
+ */
15
+ async function openEntry(config, url, open) {
16
+ const key = url.searchParams.get("key") ?? "";
17
+ let message;
18
+ try {
19
+ message = loadCatalog(config).messages.find((m) => m.key === key);
20
+ } catch (e) {
21
+ return failed(e);
22
+ }
23
+ if (message === void 0) return new Response(`no entry for "${key}" in the catalog: has it been renamed since the page loaded?`, { status: 404 });
24
+ const locale = url.searchParams.has("catalog") ? void 0 : url.searchParams.get("locale") ?? void 0;
25
+ return open(entryLocation(config, message, locale));
26
+ }
27
+ /**
28
+ * The inspector's dialog: GET `?key=…` reads an entry in every locale, POST `{ key, edit, write }`
29
+ * applies an edit (`entry.ts`). A POST writes files, so only the page itself may send one: same origin,
30
+ * and JSON, which a form on another site can't send without asking first.
31
+ */
32
+ async function entry(config, req, url) {
33
+ if (req.method === "GET") try {
34
+ return Response.json(readEntry(config, url.searchParams.get("key") ?? ""));
35
+ } catch (e) {
36
+ return failed(e);
37
+ }
38
+ const origin = req.headers.get("origin");
39
+ const sameOrigin = origin === null || new URL(origin).host === url.host;
40
+ if (req.method !== "POST" || !sameOrigin || req.headers.get("content-type")?.startsWith("application/json") !== true) return Response.json({ problems: [{
41
+ severity: "error",
42
+ message: "edits come from the page, as JSON"
43
+ }] }, { status: 403 });
44
+ try {
45
+ const { key, edit, write } = await req.json();
46
+ const result = editEntry(config, key, edit, write === true);
47
+ return Response.json(result, { status: result.problems.length > 0 ? 422 : 200 });
48
+ } catch (e) {
49
+ return failed(e);
50
+ }
51
+ }
52
+ /** A redirect within the page's origin, to a launcher the dev server answers itself. */
53
+ const redirect = (path) => new Response(null, {
54
+ status: 307,
55
+ headers: { Location: path }
56
+ });
57
+ function failed(e) {
58
+ return Response.json({ problems: e instanceof CatalogError ? e.problems : [{
59
+ severity: "error",
60
+ message: e instanceof Error ? e.message : String(e)
61
+ }] }, { status: e instanceof CatalogError ? 409 : 400 });
62
+ }
63
+ /**
64
+ * The endpoints as Node middleware, for Vite's server and Next's. The request's host is the one the
65
+ * page was served from: a proxy's `x-forwarded-host`, as Next's rewrite sets, before its own.
66
+ */
67
+ function nodeMiddleware(handle) {
68
+ return (req, res, next) => {
69
+ if (req.url?.includes("/__prosebook/") !== true) return next();
70
+ const forwarded = req.headers["x-forwarded-host"];
71
+ const host = (Array.isArray(forwarded) ? forwarded[0] : forwarded) ?? req.headers.host ?? "localhost";
72
+ const headers = new Headers();
73
+ for (const [name, value] of Object.entries(req.headers)) for (const v of Array.isArray(value) ? value : value === void 0 ? [] : [value]) headers.append(name, v);
74
+ const chunks = [];
75
+ req.on("data", (chunk) => chunks.push(chunk));
76
+ req.on("end", () => {
77
+ const body = req.method === "GET" || req.method === "HEAD" ? void 0 : Buffer.concat(chunks);
78
+ handle(new Request(`http://${host}${req.url}`, {
79
+ method: req.method,
80
+ headers,
81
+ body
82
+ })).then(async (response) => {
83
+ if (response === void 0) return next();
84
+ res.statusCode = response.status;
85
+ response.headers.forEach((value, name) => res.setHeader(name, value));
86
+ res.end(Buffer.from(await response.arrayBuffer()));
87
+ }).catch((e) => {
88
+ res.statusCode = 500;
89
+ res.end(e instanceof Error ? e.message : String(e));
90
+ });
91
+ });
92
+ };
93
+ }
94
+ export { nodeMiddleware as n, redirect as r, inspectorEndpoints as t };
95
+
96
+ //# sourceMappingURL=endpoints-BgG_5Vpm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoints-BgG_5Vpm.js","names":[],"sources":["../src/tools/endpoints.ts"],"sourcesContent":["/**\n * The dev server's half of the inspector (`inspector.ts`, `inspector-dialog.ts`): `__prosebook/open`,\n * which opens an entry in the editor, and `__prosebook/entry`, which reads and edits one. Written over\n * `Request` and `Response`, so each integration mounts them its own way: Vite as middleware, Bun as\n * `Bun.serve` routes, Next behind a rewrite to a server of their own. Each opens the editor its dev\n * server already launches.\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http';\n\nimport { CatalogError, entryLocation, loadCatalog, type EntryLocation } from './catalog.ts';\nimport type { ResolvedConfig } from './config.ts';\nimport { editEntry, readEntry, type EntryEdit } from './entry.ts';\n\nexport interface EndpointOptions {\n /** The path the endpoints sit under, ending in `/`: `/` by default. */\n base?: string;\n /** Opens an entry in the editor: a redirect to the dev server's own launcher, or a reply once it has. */\n open: (at: EntryLocation) => Response | Promise<Response>;\n}\n\n/** Answers the inspector's requests, and nothing for any other path. */\nexport function inspectorEndpoints(\n config: ResolvedConfig | Promise<ResolvedConfig>,\n { base = '/', open }: EndpointOptions,\n): (req: Request) => Promise<Response | undefined> {\n return async (req) => {\n const url = new URL(req.url);\n if (url.pathname === `${base}__prosebook/open`) return openEntry(await config, url, open);\n if (url.pathname === `${base}__prosebook/entry`) return entry(await config, req, url);\n return undefined;\n };\n}\n\n/**\n * `?key=cart.items&locale=de`: the translation's entry, or the catalog's with `catalog` or when the\n * locale has none. Read from disk, so a key added since the page loaded is found.\n */\nasync function openEntry(config: ResolvedConfig, url: URL, open: EndpointOptions['open']): Promise<Response> {\n const key = url.searchParams.get('key') ?? '';\n let message;\n try {\n message = loadCatalog(config).messages.find((m) => m.key === key);\n } catch (e) {\n return failed(e);\n }\n if (message === undefined)\n return new Response(`no entry for \"${key}\" in the catalog: has it been renamed since the page loaded?`, { status: 404 });\n const locale = url.searchParams.has('catalog') ? undefined : (url.searchParams.get('locale') ?? undefined);\n return open(entryLocation(config, message, locale));\n}\n\n/**\n * The inspector's dialog: GET `?key=…` reads an entry in every locale, POST `{ key, edit, write }`\n * applies an edit (`entry.ts`). A POST writes files, so only the page itself may send one: same origin,\n * and JSON, which a form on another site can't send without asking first.\n */\nasync function entry(config: ResolvedConfig, req: Request, url: URL): Promise<Response> {\n if (req.method === 'GET') {\n try {\n return Response.json(readEntry(config, url.searchParams.get('key') ?? ''));\n } catch (e) {\n return failed(e);\n }\n }\n const origin = req.headers.get('origin');\n const sameOrigin = origin === null || new URL(origin).host === url.host;\n if (req.method !== 'POST' || !sameOrigin || req.headers.get('content-type')?.startsWith('application/json') !== true)\n return Response.json({ problems: [{ severity: 'error', message: 'edits come from the page, as JSON' }] }, { status: 403 });\n try {\n const { key, edit, write } = (await req.json()) as { key: string; edit: EntryEdit; write?: boolean };\n const result = editEntry(config, key, edit, write === true);\n return Response.json(result, { status: result.problems.length > 0 ? 422 : 200 });\n } catch (e) {\n return failed(e);\n }\n}\n\n/** A redirect within the page's origin, to a launcher the dev server answers itself. */\nexport const redirect = (path: string) => new Response(null, { status: 307, headers: { Location: path } });\n\nfunction failed(e: unknown): Response {\n return Response.json(\n { problems: e instanceof CatalogError ? e.problems : [{ severity: 'error', message: e instanceof Error ? e.message : String(e) }] },\n { status: e instanceof CatalogError ? 409 : 400 },\n );\n}\n\n/**\n * The endpoints as Node middleware, for Vite's server and Next's. The request's host is the one the\n * page was served from: a proxy's `x-forwarded-host`, as Next's rewrite sets, before its own.\n */\nexport function nodeMiddleware(\n handle: (req: Request) => Promise<Response | undefined>,\n): (req: IncomingMessage, res: ServerResponse, next: () => void) => void {\n return (req, res, next) => {\n // Before reading the body, which a request for anything else leaves to whoever answers it.\n if (req.url?.includes('/__prosebook/') !== true) return next();\n const forwarded = req.headers['x-forwarded-host'];\n const host = (Array.isArray(forwarded) ? forwarded[0] : forwarded) ?? req.headers.host ?? 'localhost';\n const headers = new Headers();\n for (const [name, value] of Object.entries(req.headers))\n for (const v of Array.isArray(value) ? value : value === undefined ? [] : [value]) headers.append(name, v);\n\n const chunks: Buffer[] = [];\n req.on('data', (chunk: Buffer) => chunks.push(chunk));\n req.on('end', () => {\n const body = req.method === 'GET' || req.method === 'HEAD' ? undefined : Buffer.concat(chunks);\n handle(new Request(`http://${host}${req.url}`, { method: req.method, headers, body }))\n .then(async (response) => {\n if (response === undefined) return next();\n res.statusCode = response.status;\n response.headers.forEach((value, name) => res.setHeader(name, value));\n res.end(Buffer.from(await response.arrayBuffer()));\n })\n .catch((e: unknown) => {\n res.statusCode = 500;\n res.end(e instanceof Error ? e.message : String(e));\n });\n });\n };\n}\n"],"mappings":";;;AAqBA,SAAgB,mBACd,QACA,EAAE,OAAO,KAAK,QACmC;CACjD,OAAO,OAAO,QAAQ;EACpB,MAAM,MAAM,IAAI,IAAI,IAAI,GAAG;EAC3B,IAAI,IAAI,aAAa,GAAG,KAAK,mBAAmB,OAAO,UAAU,MAAM,QAAQ,KAAK,IAAI;EACxF,IAAI,IAAI,aAAa,GAAG,KAAK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