langsys-js-react 0.6.7 → 0.7.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.
package/dist/index.js CHANGED
@@ -1,17 +1,65 @@
1
1
  'use strict';
2
2
 
3
3
  var langsysJsTypescript = require('langsys-js-typescript');
4
- var react = require('react');
4
+ var React = require('react');
5
+ var pure = require('langsys-js-typescript/pure');
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n.default = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
5
26
 
6
27
  // src/index.ts
7
- function useSignal(signal) {
8
- return react.useSyncExternalStore(signal.subscribe, signal.get, signal.get);
28
+ var SeedScope = React.createContext(null);
29
+ var noSubscription = () => () => {
30
+ };
31
+ function useServerSnapshotWindow() {
32
+ return React.useSyncExternalStore(
33
+ noSubscription,
34
+ () => false,
35
+ () => true
36
+ );
9
37
  }
38
+ function useSeedScopeRunner() {
39
+ const scope = React.useContext(SeedScope);
40
+ const inWindow = useServerSnapshotWindow();
41
+ return scope && inWindow ? (fn) => scope.run(fn) : (fn) => fn();
42
+ }
43
+ function LangsysProvider({ seed, children }) {
44
+ const [scope] = React.useState(() => seed ? langsysJsTypescript.scopeFromSeed(seed) : null);
45
+ React.useInsertionEffect(() => {
46
+ if (seed) langsysJsTypescript.LangsysApp.seedCatalog(seed.catalog, seed.locale, seed);
47
+ }, []);
48
+ return React.createElement(SeedScope.Provider, { value: scope }, children);
49
+ }
50
+ var LangsysApp2 = langsysJsTypescript.LangsysApp;
10
51
  function createLocaleStore(initial = "en-US") {
11
52
  return langsysJsTypescript.createSignal(initial);
12
53
  }
54
+
55
+ // src/adapters.ts
56
+ function useSignal(signal) {
57
+ const scope = React.useContext(SeedScope);
58
+ return React.useSyncExternalStore(signal.subscribe, signal.get, scope ? () => scope.run(signal.get) : signal.get);
59
+ }
13
60
  function useT() {
14
- return useSignal(langsysJsTypescript.tSignal);
61
+ const scope = React.useContext(SeedScope);
62
+ return React.useSyncExternalStore(langsysJsTypescript.tSignal.subscribe, langsysJsTypescript.tSignal.get, scope ? () => scope.t : langsysJsTypescript.tSignal.get);
15
63
  }
16
64
  function useCurrentLocale() {
17
65
  return useSignal(langsysJsTypescript.currentlyLoadedLocale);
@@ -20,131 +68,452 @@ function useTranslations() {
20
68
  return useSignal(langsysJsTypescript.sTranslations);
21
69
  }
22
70
  function useLocaleStore(initial = "en-US") {
23
- const [store] = react.useState(() => createLocaleStore(initial));
71
+ const [store] = React.useState(() => createLocaleStore(initial));
24
72
  const locale = useSignal(store);
25
73
  return [locale, store.set, store];
26
74
  }
75
+ var writeEnabledServerSnapshot = () => void 0;
76
+ function useWriteEnabled() {
77
+ return React.useSyncExternalStore(langsysJsTypescript.writeEnabled.subscribe, langsysJsTypescript.writeEnabled.get, writeEnabledServerSnapshot);
78
+ }
79
+ function useNotifyNavigation(location) {
80
+ React.useEffect(() => {
81
+ langsysJsTypescript.notifyNavigation();
82
+ }, [location]);
83
+ }
84
+ function useRenderServerMessage() {
85
+ const t = useT();
86
+ const inSeedScope = useSeedScopeRunner();
87
+ return React.useMemo(
88
+ () => (entry, category) => inSeedScope(() => langsysJsTypescript.renderServerMessage(entry, category)),
89
+ // eslint-disable-next-line react-hooks/exhaustive-deps
90
+ [t]
91
+ );
92
+ }
93
+ function DontTranslate({ tag = "span", className, children }) {
94
+ return React.createElement(
95
+ tag,
96
+ { translate: "no", "data-ls-dont-translate": "", className },
97
+ children
98
+ );
99
+ }
100
+
101
+ // src/block-nodes.ts
102
+ var PORTAL = /* @__PURE__ */ Symbol.for("react.portal");
103
+ var PROP_TO_ATTR = { className: "class", htmlFor: "for" };
104
+ function attrValue(value) {
105
+ if (typeof value === "function" || typeof value === "object" || value === void 0 || value === false) return void 0;
106
+ return value === true ? "" : String(value);
107
+ }
108
+ function attrsOf(props) {
109
+ const out = {};
110
+ for (const [name, value] of Object.entries(props)) {
111
+ if (name === "children" || name === "key" || name === "ref") continue;
112
+ const attr = attrValue(value);
113
+ if (attr !== void 0) out[PROP_TO_ATTR[name] ?? name] = attr;
114
+ }
115
+ return Object.keys(out).length ? out : void 0;
116
+ }
117
+ var CONTEXT = /* @__PURE__ */ Symbol.for("react.context");
118
+ var read = React__namespace.use;
119
+ function isContext(node) {
120
+ return typeof node === "object" && node !== null && node.$$typeof === CONTEXT;
121
+ }
122
+ function isUsable(node) {
123
+ if (typeof node !== "object" || node === null) return false;
124
+ return typeof node.then === "function" || node.$$typeof === CONTEXT;
125
+ }
126
+ function isParamValue(value) {
127
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean" || isDate(value);
128
+ }
129
+ function isDate(value) {
130
+ return Object.prototype.toString.call(value) === "[object Date]";
131
+ }
132
+ var oneShotItems = /* @__PURE__ */ new WeakMap();
133
+ function itemsOf(list) {
134
+ if (list[Symbol.iterator]() !== list) return Array.from(list);
135
+ let items = oneShotItems.get(list);
136
+ if (!items) oneShotItems.set(list, items = Array.from(list));
137
+ return items;
138
+ }
139
+ function isIterable(node) {
140
+ return typeof node === "object" && node !== null && !React.isValidElement(node) && typeof node[Symbol.iterator] === "function";
141
+ }
142
+ function isPortal(node) {
143
+ return typeof node === "object" && node !== null && node.$$typeof === PORTAL;
144
+ }
145
+ function toBlockNodes(children) {
146
+ const elements = [];
147
+ const portals = [];
148
+ const nested = [];
149
+ let failure;
150
+ function mapLevel(level, parent) {
151
+ const out = [];
152
+ const visit = (node) => {
153
+ if (failure || node === null || node === void 0 || typeof node === "boolean") return;
154
+ if (typeof node === "string" || typeof node === "number" || typeof node === "bigint") {
155
+ out.push({ text: String(node) });
156
+ return;
157
+ }
158
+ if (Array.isArray(node)) return node.forEach(visit);
159
+ if (isPortal(node)) {
160
+ if (parent === null) portals.push(node);
161
+ else nested[parent].push(node);
162
+ return;
163
+ }
164
+ if (!React.isValidElement(node)) {
165
+ failure = `an unsupported child (${typeof node})`;
166
+ return;
167
+ }
168
+ const props = node.props;
169
+ if (node.type === DontTranslate) return visit(DontTranslate(props));
170
+ if (typeof node.type !== "string") {
171
+ failure = "a component, provider, lazy or Suspense child, whose DOM is unknown until React renders it";
172
+ return;
173
+ }
174
+ if (props.dangerouslySetInnerHTML) {
175
+ failure = "dangerouslySetInnerHTML, an HTML string rather than a tree";
176
+ return;
177
+ }
178
+ const index = elements.push(node) - 1;
179
+ nested[index] = [];
180
+ const kids = mapLevel(props.children, index);
181
+ const attrs = attrsOf(props);
182
+ out.push({ tag: node.type, ...attrs ? { attrs } : {}, ...kids.length ? { children: kids } : {} });
183
+ };
184
+ React.Children.toArray(withoutFragments(level)).forEach(visit);
185
+ return out;
186
+ }
187
+ const nodes = mapLevel(children, null);
188
+ return failure ? { ok: false, reason: failure } : { ok: true, nodes, elements, portals, nested };
189
+ }
190
+ var ATTR_TO_PROP = { class: "className", for: "htmlFor" };
191
+ var literally = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
192
+ function propFor(attr, props) {
193
+ const same = new RegExp(`^${literally(attr)}$`, "i");
194
+ return ATTR_TO_PROP[attr] ?? Object.keys(props).find((name) => same.test(name)) ?? attr;
195
+ }
196
+ function toReactNodes(nodes, elements, nested = []) {
197
+ return nodes.flatMap((node) => {
198
+ if ("text" in node) return [node.text];
199
+ if ("comment" in node) return [];
200
+ const original = elements[node.source];
201
+ const originalProps = original.props;
202
+ const changed = {};
203
+ for (const [attr, value] of Object.entries(node.attrs)) {
204
+ if (value === true) continue;
205
+ const prop = propFor(attr, originalProps);
206
+ if ((attrValue(originalProps[prop]) ?? "") !== value) changed[prop] = value;
207
+ }
208
+ const kids = [...toReactNodes(node.children, elements, nested), ...nested[node.source] ?? []];
209
+ return [kids.length ? React.cloneElement(original, changed, ...kids) : React.cloneElement(original, { ...changed, children: void 0 })];
210
+ });
211
+ }
212
+ function hasRuntimeValues(children, skipExcluded = false) {
213
+ let run = [];
214
+ const flush = () => {
215
+ const hit = run.filter((p) => String(p).trim() !== "").length > 1;
216
+ run = [];
217
+ return hit;
218
+ };
219
+ for (const c of [...inRun(children), null]) {
220
+ if (typeof c === "string" || typeof c === "number" || typeof c === "bigint") {
221
+ run.push(c);
222
+ continue;
223
+ }
224
+ if (flush()) return true;
225
+ if (!React.isValidElement(c)) continue;
226
+ const node = c.type === DontTranslate ? DontTranslate(c.props) : c;
227
+ if (typeof node.type !== "string") continue;
228
+ const props = node.props;
229
+ if (skipExcluded && opaqueInPhrase(node.type, props)) continue;
230
+ if (hasRuntimeValues(props.children, skipExcluded)) return true;
231
+ }
232
+ return false;
233
+ }
234
+ function withoutFragments(node) {
235
+ if (read && isContext(node)) return withoutFragments(read(node));
236
+ if (Array.isArray(node)) return node.map(withoutFragments);
237
+ if (isIterable(node)) return Array.from(node, withoutFragments);
238
+ if (React.isValidElement(node) && node.type === React.Fragment) return [withoutFragments(node.props.children)];
239
+ return node;
240
+ }
241
+ function inRun(level) {
242
+ return React.Children.toArray(withoutFragments(level));
243
+ }
244
+ function opaqueInPhrase(tag, props) {
245
+ return pure.NON_TRANSLATABLE_ELEMENTS.includes(tag) || langsysJsTypescript.isTranslationExcluded(attributeReader(tag, attrsOf(props)));
246
+ }
247
+ function attributeReader(tagName, attrs) {
248
+ const valueOf = (name) => Object.entries(attrs ?? {}).find(([key]) => key === name)?.[1];
249
+ return { tagName, getAttribute: (name) => valueOf(name) ?? null, hasAttribute: (name) => valueOf(name) !== void 0 };
250
+ }
251
+ function withNodeParams(children, given) {
252
+ const nodes = {};
253
+ const rest = {};
254
+ const props = /* @__PURE__ */ Object.create(null);
255
+ for (const [name, param] of Object.entries(given)) {
256
+ const value = read && isUsable(param) ? read(param) : param;
257
+ if (value === null || value === void 0) rest[name] = "";
258
+ else if (typeof value === "bigint") rest[name] = String(value);
259
+ else if (isParamValue(value)) rest[name] = value;
260
+ else {
261
+ nodes[name] = isIterable(value) && !Array.isArray(value) ? itemsOf(value) : value;
262
+ props[`%${name}%`] = props[`{${name}}`] = value;
263
+ }
264
+ }
265
+ const names = Object.keys(nodes);
266
+ if (!names.length) return { children, params: rest };
267
+ const alternatives = names.map(literally).join("|");
268
+ const split = new RegExp(`%(${alternatives})%|(%[A-Za-z_][A-Za-z0-9_]*%)|\\{(${alternatives})\\}`);
269
+ const inText = /* @__PURE__ */ new Set();
270
+ const ownProps = (element) => {
271
+ let out;
272
+ for (const [prop, value] of Object.entries(element)) {
273
+ if (prop === "children" || typeof value !== "string") continue;
274
+ if (value in props) (out ??= {})[prop] = props[value];
275
+ else {
276
+ for (const match of value.matchAll(new RegExp(split.source, "g"))) {
277
+ const name = match[1] ?? match[3];
278
+ if (name !== void 0) inText.add(name);
279
+ }
280
+ }
281
+ }
282
+ return out;
283
+ };
284
+ const visit = (node) => {
285
+ if (typeof node === "string") {
286
+ const parts = node.split(new RegExp(split.source, "g"));
287
+ const out = [];
288
+ let text = "";
289
+ for (let i = 0; i < parts.length; i += 4) {
290
+ text += parts[i] + (parts[i + 2] ?? "");
291
+ const name = parts[i + 1] ?? parts[i + 3];
292
+ if (name === void 0) continue;
293
+ if (text) out.push(text);
294
+ text = "";
295
+ out.push(React.createElement(React.Fragment, { key: i + 1 }, nodes[name]));
296
+ }
297
+ if (out.length === 0) return node;
298
+ if (text) out.push(text);
299
+ return out;
300
+ }
301
+ if (Array.isArray(node)) {
302
+ const kids2 = node.map(visit);
303
+ return kids2.some((kid, i) => kid !== node[i]) ? kids2 : node;
304
+ }
305
+ if (!React.isValidElement(node)) return node;
306
+ if (typeof node.type !== "string" && node.type !== React.Fragment && node.type !== DontTranslate) return node;
307
+ const attrs = typeof node.type === "string" ? ownProps(node.props) : void 0;
308
+ const own = node.props.children;
309
+ if (own === void 0) return attrs ? React.cloneElement(node, attrs) : node;
310
+ const kids = Array.isArray(own) ? own.map(visit) : [visit(own)];
311
+ const same = Array.isArray(own) ? kids.every((kid, i) => kid === own[i]) : kids[0] === own;
312
+ return same && !attrs ? node : React.cloneElement(node, attrs, ...kids);
313
+ };
314
+ const rendered = visit(children);
315
+ for (const name of inText) rest[name] = String(props[`%${name}%`]);
316
+ return { children: rendered, params: rest };
317
+ }
318
+ var BlockCategory = React.createContext(void 0);
319
+ function useUnitCategory(named, namedPrevious) {
320
+ const block = React.useContext(BlockCategory);
321
+ const outerCategory = block?.category;
322
+ const outerPrevious = block?.previousCategory;
323
+ return React.useMemo(() => {
324
+ if (named !== void 0 || !block) return { category: named ?? "", previousCategory: namedPrevious };
325
+ return { category: block.category, previousCategory: namedPrevious ?? block.previousCategory };
326
+ }, [named, namedPrevious, block !== void 0, outerCategory, outerPrevious]);
327
+ }
328
+
329
+ // src/components/Translate.tsx
27
330
  function Translate({
28
- category = "",
331
+ category: named,
332
+ previousCategory: namedPrevious,
29
333
  custom_id = "",
30
334
  label = "",
31
- params,
335
+ params: given,
32
336
  tag = "translate",
33
337
  className,
34
- children
338
+ children: content,
339
+ "data-ls-unnamed": unmarked
35
340
  }) {
36
- const hostRef = react.useRef(null);
37
- const instanceRef = react.useRef(void 0);
38
- react.useEffect(() => {
341
+ const unit = useUnitCategory(named, namedPrevious);
342
+ const { category, previousCategory } = unit;
343
+ const { children, params } = given ? withNodeParams(content, given) : { children: content, params: given };
344
+ const t = useT();
345
+ const hostRef = React.useRef(null);
346
+ const instanceRef = React.useRef(void 0);
347
+ const mapped = toBlockNodes(children);
348
+ const unnamedValues = unmarked !== void 0 || hasRuntimeValues(children);
349
+ const options = {
350
+ category,
351
+ ...previousCategory === void 0 || previousCategory === null ? {} : { previousCategory },
352
+ params,
353
+ label,
354
+ ...custom_id ? { id: custom_id } : {},
355
+ ...unnamedValues ? { register: false } : {}
356
+ };
357
+ const inSeedScope = useSeedScopeRunner();
358
+ const rendered = mapped.ok ? inSeedScope(() => langsysJsTypescript.renderBlock(mapped.nodes, options)) : null;
359
+ const scope = langsysJsTypescript.currentRequestScope();
360
+ const register = (host) => {
361
+ if (!mapped.ok || !rendered || rendered.shape === "empty") return;
362
+ if (unnamedValues) warnUnnamed(unmarked !== void 0);
363
+ void langsysJsTypescript.registerBlock(mapped.nodes, { ...options, host });
364
+ };
365
+ if (scope) {
366
+ register();
367
+ if (!mapped.ok) langsysJsTypescript.warnUnrenderedBlock(mapped.reason);
368
+ }
369
+ const blockKey = rendered ? `${category}\0${custom_id}\0${rendered.customId}` : null;
370
+ React.useEffect(() => {
371
+ register(hostRef.current ?? void 0);
372
+ }, [t, blockKey, tag]);
373
+ React.useEffect(() => {
39
374
  const host = hostRef.current;
40
- if (!host) return;
41
- const instance = new langsysJsTypescript.Translate(host, { category, custom_id, label, params });
375
+ if (mapped.ok || !host) return;
376
+ if (unnamedValues) warnUnnamed(unmarked !== void 0);
377
+ const instance = new langsysJsTypescript.Translate(host, {
378
+ category,
379
+ ...previousCategory === void 0 || previousCategory === null ? {} : { previousCategory },
380
+ custom_id,
381
+ label,
382
+ params,
383
+ ...unnamedValues ? { register: false } : {}
384
+ });
42
385
  instanceRef.current = instance;
43
386
  return () => {
44
387
  instance.destroy();
45
388
  instanceRef.current = void 0;
46
389
  };
47
- }, [category, custom_id, label]);
48
- react.useEffect(() => {
390
+ }, [mapped.ok, category, previousCategory, custom_id, label, tag]);
391
+ React.useEffect(() => {
49
392
  instanceRef.current?.setParams(params);
50
393
  });
51
- return react.createElement(tag, { ref: hostRef, className }, children);
394
+ if (mapped.ok && rendered) {
395
+ return React.createElement(
396
+ tag,
397
+ { ref: hostRef, className, ...rendered.hostAttrs },
398
+ ...toReactNodes(rendered.nodes, mapped.elements, mapped.nested),
399
+ ...mapped.portals
400
+ );
401
+ }
402
+ return React.createElement(
403
+ tag,
404
+ { ref: hostRef, className, ...custom_id ? { [langsysJsTypescript.CONTENT_BLOCK_MARKER_ATTR]: custom_id } : {} },
405
+ React.createElement(
406
+ BlockCategory.Provider,
407
+ { value: unit },
408
+ ...children !== content && Array.isArray(children) ? children : [children]
409
+ )
410
+ );
52
411
  }
53
- function Phrase({ category = "", params = {}, tag = "span", className, children }) {
54
- const hostRef = react.useRef(null);
55
- const instanceRef = react.useRef(void 0);
56
- react.useEffect(() => {
57
- const host = hostRef.current;
58
- if (!host) return;
59
- const instance = new langsysJsTypescript.Phrase(host, { category, params });
412
+ function warnUnnamed(unmarked) {
413
+ langsysJsTypescript.warnUnregistered(
414
+ unmarked ? "a value the build transform left as written: inside MathML or SVG, <script> or <style>, or an element that holds text only" : "a value the build transform did not name: it is not enabled (langsys-js-react/vite, /babel or /next), or the value is a conditional, which it leaves as written"
415
+ );
416
+ }
417
+ function Phrase({
418
+ category: named,
419
+ previousCategory: namedPrevious,
420
+ params: given = {},
421
+ tag = "span",
422
+ className,
423
+ children: content,
424
+ "data-ls-unnamed": unmarked
425
+ }) {
426
+ const inherited = useUnitCategory(named, namedPrevious);
427
+ const { category, previousCategory } = inherited;
428
+ const { children, params } = withNodeParams(content, given ?? {});
429
+ const t = useT();
430
+ const hostRef = React.useRef(null);
431
+ const instanceRef = React.useRef(void 0);
432
+ const mapped = toBlockNodes(children);
433
+ const unit = mapped.ok ? [{ tag, attrs: { [langsysJsTypescript.PHRASE_MARKER_ATTR]: "" }, children: mapped.nodes }] : null;
434
+ const unnamedValues = unmarked !== void 0 || hasRuntimeValues(children, true);
435
+ const moved = previousCategory === void 0 || previousCategory === null ? {} : { previousCategory };
436
+ const options = { category, ...moved, params, ...unnamedValues ? { register: false } : {} };
437
+ const inSeedScope = useSeedScopeRunner();
438
+ const rendered = unit ? inSeedScope(() => langsysJsTypescript.renderBlock(unit, options)) : null;
439
+ const scope = langsysJsTypescript.currentRequestScope();
440
+ const register = (host2) => {
441
+ if (!unit) return;
442
+ if (unnamedValues) warnUnnamed2(unmarked !== void 0);
443
+ void langsysJsTypescript.registerBlock(unit, { ...options, host: host2 });
444
+ };
445
+ if (scope) {
446
+ register();
447
+ if (!mapped.ok) langsysJsTypescript.warnUnrenderedBlock(mapped.reason);
448
+ }
449
+ React.useEffect(() => {
450
+ register(hostRef.current ?? void 0);
451
+ }, [t, category, rendered ? JSON.stringify(unit) : null]);
452
+ React.useEffect(() => {
453
+ const host2 = hostRef.current;
454
+ if (mapped.ok || !host2) return;
455
+ if (unnamedValues) warnUnnamed2(unmarked !== void 0);
456
+ const instance = new langsysJsTypescript.Phrase(host2, {
457
+ category,
458
+ ...moved,
459
+ params,
460
+ ...unnamedValues ? { register: false } : {}
461
+ });
60
462
  instanceRef.current = instance;
61
463
  return () => {
62
464
  instance.destroy();
63
465
  instanceRef.current = void 0;
64
466
  };
65
- }, [category]);
66
- react.useEffect(() => {
467
+ }, [mapped.ok, category, previousCategory, tag]);
468
+ React.useEffect(() => {
67
469
  instanceRef.current?.setParams(params);
68
470
  });
69
- return react.createElement(tag, { ref: hostRef, className, [langsysJsTypescript.PHRASE_MARKER_ATTR]: "" }, children);
70
- }
71
- function DontTranslate({ tag = "span", className, children }) {
72
- return react.createElement(
471
+ const host = rendered?.nodes[0];
472
+ if (mapped.ok && host && "tag" in host) {
473
+ const { class: _class, ...hostAttrs } = host.attrs;
474
+ return React.createElement(
475
+ tag,
476
+ { ref: hostRef, className, ...hostAttrs },
477
+ ...toReactNodes(host.children, [React.createElement(tag), ...mapped.elements], [[], ...mapped.nested]),
478
+ ...mapped.portals
479
+ );
480
+ }
481
+ return React.createElement(
73
482
  tag,
74
- { translate: "no", "data-ls-dont-translate": "", className },
75
- children
483
+ { ref: hostRef, className, [langsysJsTypescript.PHRASE_MARKER_ATTR]: "" },
484
+ React.createElement(
485
+ BlockCategory.Provider,
486
+ { value: inherited },
487
+ ...children !== content && Array.isArray(children) ? children : [children]
488
+ )
489
+ );
490
+ }
491
+ function warnUnnamed2(unmarked) {
492
+ langsysJsTypescript.warnUnregistered(
493
+ unmarked ? "a value the build transform left as written in a phrase whose values are all marked: in a translated <svg>, or an element that holds text only" : "a value the build transform did not name: it is not enabled (langsys-js-react/vite, /babel or /next), or the value is a conditional, which it leaves as written"
76
494
  );
77
495
  }
78
496
 
79
- // src/index.ts
80
- var LangsysAppReact = class {
81
- /** Initialize Langsys. Pass a `Signal<string>` (from `createLocaleStore`) as `UserLocaleStore`. */
82
- init(config) {
83
- return langsysJsTypescript.LangsysApp.init(config);
84
- }
85
- get Translations() {
86
- return langsysJsTypescript.LangsysApp.Translations;
87
- }
88
- get translationsLoadingPromise() {
89
- return langsysJsTypescript.LangsysApp.translationsLoadingPromise;
90
- }
91
- /** Current translation function. Reads fresh state on every call (not reactive on its own — use `useT()` in components). */
92
- get t() {
93
- return langsysJsTypescript.LangsysApp.t;
94
- }
95
- get debug() {
96
- return langsysJsTypescript.LangsysApp.debug;
97
- }
98
- refresh() {
99
- return langsysJsTypescript.LangsysApp.refresh();
100
- }
101
- getCountries(inLocale) {
102
- return langsysJsTypescript.LangsysApp.getCountries(inLocale);
103
- }
104
- getCountryName(forCountryCode, inLocale) {
105
- return langsysJsTypescript.LangsysApp.getCountryName(forCountryCode, inLocale);
106
- }
107
- getCurrencies(inLocale) {
108
- return langsysJsTypescript.LangsysApp.getCurrencies(inLocale);
109
- }
110
- getCurrencyName(forCurrencyCode, inLocale) {
111
- return langsysJsTypescript.LangsysApp.getCurrencyName(forCurrencyCode, inLocale);
112
- }
113
- getDialCodes(inLocale) {
114
- return langsysJsTypescript.LangsysApp.getDialCodes(inLocale);
115
- }
116
- getLocales(inLocale) {
117
- return langsysJsTypescript.LangsysApp.getLocales(inLocale);
118
- }
119
- getLocalesFlat(inLocale) {
120
- return langsysJsTypescript.LangsysApp.getLocalesFlat(inLocale);
121
- }
122
- getLocalesData(inLocale, forceRefresh) {
123
- return langsysJsTypescript.LangsysApp.getLocalesData(inLocale, forceRefresh);
124
- }
125
- getLocalesFormat(format = "", inLocale) {
126
- return langsysJsTypescript.LangsysApp.getLocalesFormat(format, inLocale);
127
- }
128
- getLocaleName(forLocale, shortName, inLocale) {
129
- return langsysJsTypescript.LangsysApp.getLocaleName(forLocale, shortName, inLocale);
130
- }
131
- getLocaleNameWithLookup(forLocale, shortName, inLocale) {
132
- return langsysJsTypescript.LangsysApp.getLocaleNameWithLookup(forLocale, shortName, inLocale);
133
- }
134
- /** @deprecated use `getLocaleNameWithLookup` or `getLocaleName` */
135
- getLanguageName(forLocale, shortName, inLocale) {
136
- return langsysJsTypescript.LangsysApp.getLanguageName(forLocale, shortName, inLocale);
137
- }
138
- detectPreferredLocale(acceptLanguageHeader, supportedLocales) {
139
- return langsysJsTypescript.LangsysApp.detectPreferredLocale(acceptLanguageHeader, supportedLocales);
140
- }
141
- };
142
- var LangsysApp = new LangsysAppReact();
143
-
497
+ Object.defineProperty(exports, "DEFAULT_SERVER_MESSAGE_CATEGORY", {
498
+ enumerable: true,
499
+ get: function () { return langsysJsTypescript.DEFAULT_SERVER_MESSAGE_CATEGORY; }
500
+ });
144
501
  Object.defineProperty(exports, "LangsysAppAPI", {
145
502
  enumerable: true,
146
503
  get: function () { return langsysJsTypescript.LangsysAppAPI; }
147
504
  });
505
+ Object.defineProperty(exports, "LangsysConfigurationError", {
506
+ enumerable: true,
507
+ get: function () { return langsysJsTypescript.LangsysConfigurationError; }
508
+ });
509
+ Object.defineProperty(exports, "LegacyFormatError", {
510
+ enumerable: true,
511
+ get: function () { return langsysJsTypescript.LegacyFormatError; }
512
+ });
513
+ Object.defineProperty(exports, "SnapshotError", {
514
+ enumerable: true,
515
+ get: function () { return langsysJsTypescript.SnapshotError; }
516
+ });
148
517
  Object.defineProperty(exports, "canonicalizeLocale", {
149
518
  enumerable: true,
150
519
  get: function () { return langsysJsTypescript.canonicalizeLocale; }
@@ -157,23 +526,59 @@ Object.defineProperty(exports, "currentlyLoadedLocale", {
157
526
  enumerable: true,
158
527
  get: function () { return langsysJsTypescript.currentlyLoadedLocale; }
159
528
  });
529
+ Object.defineProperty(exports, "inCategory", {
530
+ enumerable: true,
531
+ get: function () { return langsysJsTypescript.inCategory; }
532
+ });
533
+ Object.defineProperty(exports, "interpolate", {
534
+ enumerable: true,
535
+ get: function () { return langsysJsTypescript.interpolate; }
536
+ });
537
+ Object.defineProperty(exports, "isCategoryRef", {
538
+ enumerable: true,
539
+ get: function () { return langsysJsTypescript.isCategoryRef; }
540
+ });
541
+ Object.defineProperty(exports, "localeHeaders", {
542
+ enumerable: true,
543
+ get: function () { return langsysJsTypescript.localeHeaders; }
544
+ });
545
+ Object.defineProperty(exports, "notifyNavigation", {
546
+ enumerable: true,
547
+ get: function () { return langsysJsTypescript.notifyNavigation; }
548
+ });
549
+ Object.defineProperty(exports, "renderServerMessage", {
550
+ enumerable: true,
551
+ get: function () { return langsysJsTypescript.renderServerMessage; }
552
+ });
553
+ Object.defineProperty(exports, "resolveServerMessages", {
554
+ enumerable: true,
555
+ get: function () { return langsysJsTypescript.resolveServerMessages; }
556
+ });
160
557
  Object.defineProperty(exports, "sTranslations", {
161
558
  enumerable: true,
162
559
  get: function () { return langsysJsTypescript.sTranslations; }
163
560
  });
561
+ Object.defineProperty(exports, "setWriteGrant", {
562
+ enumerable: true,
563
+ get: function () { return langsysJsTypescript.setWriteGrant; }
564
+ });
164
565
  Object.defineProperty(exports, "t", {
165
566
  enumerable: true,
166
567
  get: function () { return langsysJsTypescript.tSignal; }
167
568
  });
168
569
  exports.DontTranslate = DontTranslate;
169
- exports.LangsysApp = LangsysApp;
570
+ exports.LangsysApp = LangsysApp2;
571
+ exports.LangsysProvider = LangsysProvider;
170
572
  exports.Phrase = Phrase;
171
573
  exports.Translate = Translate;
172
574
  exports.createLocaleStore = createLocaleStore;
173
575
  exports.useCurrentLocale = useCurrentLocale;
174
576
  exports.useLocaleStore = useLocaleStore;
577
+ exports.useNotifyNavigation = useNotifyNavigation;
578
+ exports.useRenderServerMessage = useRenderServerMessage;
175
579
  exports.useSignal = useSignal;
176
580
  exports.useT = useT;
177
581
  exports.useTranslations = useTranslations;
582
+ exports.useWriteEnabled = useWriteEnabled;
178
583
  //# sourceMappingURL=index.js.map
179
584
  //# sourceMappingURL=index.js.map