@valbuild/react 0.126.0 → 0.127.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/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @valbuild/react
2
2
 
3
+ ## 0.127.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#608](https://github.com/valbuild/val/pull/608) [`5b7fe05`](https://github.com/valbuild/val/commit/5b7fe05cec6365f9cd1de9ba31e65ed4a87edb63) Thanks [@freekh](https://github.com/freekh)! - `s.locale()`: one of the project's languages.
8
+
9
+ The languages themselves are declared in the settings module (`locales.available`);
10
+ this says that a value is one of them.
11
+
12
+ ```typescript
13
+ // a field: everything in this entry is in this language
14
+ s.record(s.string(), s.object({ locale: s.locale(), title: s.string() }));
15
+
16
+ // a key: one entry per language
17
+ s.record(s.locale(), s.object({ title: s.string() }));
18
+ ```
19
+
20
+ Every locale in content is checked against the project's list, the way `keyOf`
21
+ and `route` are checked against what they point at. An undeclared language names
22
+ the ones the project has; a project that has declared none is told to declare
23
+ them rather than told the value is wrong.
24
+
25
+ A locale is stored as the tag itself — the value in content is `nb-NO`, and a
26
+ record keyed by `s.locale()` has `nb-NO` as its key. Spelling one differently
27
+ where it is stored (`/no/…` as a URL segment) is a real need and is deliberately
28
+ not in this release: it changes what is accepted as well as what is shown, so it
29
+ is being designed on its own rather than folded in here.
30
+
31
+ A locale is **never stega encoded**: it ends up in `<html lang>`, in `hreflang`
32
+ and in `Intl` constructors, none of which survive invisible characters.
33
+
34
+ `assistant.translation` joins the settings module alongside `context` and `tone`
35
+ — a note per language, keyed by language, so only the target language's rules are
36
+ sent when translating into it.
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [[`7fa8699`](https://github.com/valbuild/val/commit/7fa869974bc895af992a7d5c18b76253636d7d65), [`600308d`](https://github.com/valbuild/val/commit/600308d0174990ad9f5c417147d160273489c65a), [`5b7fe05`](https://github.com/valbuild/val/commit/5b7fe05cec6365f9cd1de9ba31e65ed4a87edb63), [`88262ac`](https://github.com/valbuild/val/commit/88262ac8db068650a664981ef73556457d87741a), [`7072e07`](https://github.com/valbuild/val/commit/7072e07623c953a09ac14388ae22dada0b431ce3), [`29811c3`](https://github.com/valbuild/val/commit/29811c3f8c7e001a950e6f4833af6888e6a4efea), [`9983116`](https://github.com/valbuild/val/commit/99831164c5151aad7ca69de79e1d0d59878be251)]:
41
+ - @valbuild/core@0.127.0
42
+ - @valbuild/shared@0.127.0
43
+ - @valbuild/ui@0.127.0
44
+
3
45
  ## 0.126.0
4
46
 
5
47
  ### Minor Changes
@@ -265,6 +265,12 @@ function stegaEncode(input, opts) {
265
265
  if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isCodeSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
266
266
  return sourceOrSelector;
267
267
  }
268
+ // A locale ends up in `<html lang>`, in `hreflang`, and in `Intl`
269
+ // constructors. None of those survive invisible characters: the attribute
270
+ // carries them into the markup, and `Intl` throws on a tag it cannot parse.
271
+ if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isLocaleSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
272
+ return sourceOrSelector;
273
+ }
268
274
  // An enum value is one of a fixed set of strings, and consumer code
269
275
  // compares against those strings. Weaving stega into it would break every
270
276
  // such comparison, so it is handed back verbatim — as a literal is.
@@ -373,6 +379,9 @@ function isDateTimeSchema(schema) {
373
379
  function isColorSchema(schema) {
374
380
  return (schema === null || schema === void 0 ? void 0 : schema.type) === "color";
375
381
  }
382
+ function isLocaleSchema(schema) {
383
+ return (schema === null || schema === void 0 ? void 0 : schema.type) === "locale";
384
+ }
376
385
  function isCodeSchema(schema) {
377
386
  return (schema === null || schema === void 0 ? void 0 : schema.type) === "code";
378
387
  }
@@ -263,6 +263,12 @@ function stegaEncode(input, opts) {
263
263
  if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isCodeSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
264
264
  return sourceOrSelector;
265
265
  }
266
+ // A locale ends up in `<html lang>`, in `hreflang`, and in `Intl`
267
+ // constructors. None of those survive invisible characters: the attribute
268
+ // carries them into the markup, and `Intl` throws on a tag it cannot parse.
269
+ if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isLocaleSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
270
+ return sourceOrSelector;
271
+ }
266
272
  // An enum value is one of a fixed set of strings, and consumer code
267
273
  // compares against those strings. Weaving stega into it would break every
268
274
  // such comparison, so it is handed back verbatim — as a literal is.
@@ -371,6 +377,9 @@ function isDateTimeSchema(schema) {
371
377
  function isColorSchema(schema) {
372
378
  return (schema === null || schema === void 0 ? void 0 : schema.type) === "color";
373
379
  }
380
+ function isLocaleSchema(schema) {
381
+ return (schema === null || schema === void 0 ? void 0 : schema.type) === "locale";
382
+ }
374
383
  function isCodeSchema(schema) {
375
384
  return (schema === null || schema === void 0 ? void 0 : schema.type) === "code";
376
385
  }
@@ -263,6 +263,12 @@ function stegaEncode(input, opts) {
263
263
  if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isCodeSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
264
264
  return sourceOrSelector;
265
265
  }
266
+ // A locale ends up in `<html lang>`, in `hreflang`, and in `Intl`
267
+ // constructors. None of those survive invisible characters: the attribute
268
+ // carries them into the markup, and `Intl` throws on a tag it cannot parse.
269
+ if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isLocaleSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
270
+ return sourceOrSelector;
271
+ }
266
272
  // An enum value is one of a fixed set of strings, and consumer code
267
273
  // compares against those strings. Weaving stega into it would break every
268
274
  // such comparison, so it is handed back verbatim — as a literal is.
@@ -371,6 +377,9 @@ function isDateTimeSchema(schema) {
371
377
  function isColorSchema(schema) {
372
378
  return (schema === null || schema === void 0 ? void 0 : schema.type) === "color";
373
379
  }
380
+ function isLocaleSchema(schema) {
381
+ return (schema === null || schema === void 0 ? void 0 : schema.type) === "locale";
382
+ }
374
383
  function isCodeSchema(schema) {
375
384
  return (schema === null || schema === void 0 ? void 0 : schema.type) === "code";
376
385
  }
@@ -263,6 +263,12 @@ function stegaEncode(input, opts) {
263
263
  if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isCodeSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
264
264
  return sourceOrSelector;
265
265
  }
266
+ // A locale ends up in `<html lang>`, in `hreflang`, and in `Intl`
267
+ // constructors. None of those survive invisible characters: the attribute
268
+ // carries them into the markup, and `Intl` throws on a tag it cannot parse.
269
+ if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isLocaleSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
270
+ return sourceOrSelector;
271
+ }
266
272
  // An enum value is one of a fixed set of strings, and consumer code
267
273
  // compares against those strings. Weaving stega into it would break every
268
274
  // such comparison, so it is handed back verbatim — as a literal is.
@@ -371,6 +377,9 @@ function isDateTimeSchema(schema) {
371
377
  function isColorSchema(schema) {
372
378
  return (schema === null || schema === void 0 ? void 0 : schema.type) === "color";
373
379
  }
380
+ function isLocaleSchema(schema) {
381
+ return (schema === null || schema === void 0 ? void 0 : schema.type) === "locale";
382
+ }
374
383
  function isCodeSchema(schema) {
375
384
  return (schema === null || schema === void 0 ? void 0 : schema.type) === "code";
376
385
  }
@@ -265,6 +265,12 @@ function stegaEncode(input, opts) {
265
265
  if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isCodeSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
266
266
  return sourceOrSelector;
267
267
  }
268
+ // A locale ends up in `<html lang>`, in `hreflang`, and in `Intl`
269
+ // constructors. None of those survive invisible characters: the attribute
270
+ // carries them into the markup, and `Intl` throws on a tag it cannot parse.
271
+ if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isLocaleSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
272
+ return sourceOrSelector;
273
+ }
268
274
  // An enum value is one of a fixed set of strings, and consumer code
269
275
  // compares against those strings. Weaving stega into it would break every
270
276
  // such comparison, so it is handed back verbatim — as a literal is.
@@ -373,6 +379,9 @@ function isDateTimeSchema(schema) {
373
379
  function isColorSchema(schema) {
374
380
  return (schema === null || schema === void 0 ? void 0 : schema.type) === "color";
375
381
  }
382
+ function isLocaleSchema(schema) {
383
+ return (schema === null || schema === void 0 ? void 0 : schema.type) === "locale";
384
+ }
376
385
  function isCodeSchema(schema) {
377
386
  return (schema === null || schema === void 0 ? void 0 : schema.type) === "code";
378
387
  }
@@ -1,5 +1,5 @@
1
1
  import { c as _arrayLikeToArray, b as _unsupportedIterableToArray } from '../../dist/slicedToArray-9cce0d9f.browser.esm.js';
2
- import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-7ab6ed4f.browser.esm.js';
2
+ import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-57f19ada.browser.esm.js';
3
3
  import React from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
  import '@valbuild/core';
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var slicedToArray = require('../../dist/slicedToArray-e9e8e991.cjs.dev.js');
6
- var raw = require('../../dist/raw-b5ef1ca2.cjs.dev.js');
6
+ var raw = require('../../dist/raw-512e7a0a.cjs.dev.js');
7
7
  var React = require('react');
8
8
  var ReactJSXRuntime = require('react/jsx-runtime');
9
9
  require('@valbuild/core');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var slicedToArray = require('../../dist/slicedToArray-86004d59.cjs.prod.js');
6
- var raw = require('../../dist/raw-791f5023.cjs.prod.js');
6
+ var raw = require('../../dist/raw-fe78b046.cjs.prod.js');
7
7
  var React = require('react');
8
8
  var ReactJSXRuntime = require('react/jsx-runtime');
9
9
  require('@valbuild/core');
@@ -1,5 +1,5 @@
1
1
  import { c as _arrayLikeToArray, b as _unsupportedIterableToArray } from '../../dist/slicedToArray-0c0a3b4a.esm.js';
2
- import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-d83a161a.esm.js';
2
+ import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-7ce61255.esm.js';
3
3
  import React from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
  import '@valbuild/core';
@@ -1,5 +1,5 @@
1
1
  import { c as _arrayLikeToArray, b as _unsupportedIterableToArray } from '../../dist/slicedToArray-7d0170b6.worker.esm.js';
2
- import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-b9cef70c.worker.esm.js';
2
+ import { d as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-eede220f.worker.esm.js';
3
3
  import React from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
  import '@valbuild/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/react",
3
- "version": "0.126.0",
3
+ "version": "0.127.0",
4
4
  "private": false,
5
5
  "description": "Val - React internal helpers",
6
6
  "repository": {
@@ -11,9 +11,9 @@
11
11
  "dependencies": {
12
12
  "@vercel/stega": "^1.1.0",
13
13
  "base64-arraybuffer": "^1.0.2",
14
- "@valbuild/core": "0.126.0",
15
- "@valbuild/shared": "0.126.0",
16
- "@valbuild/ui": "0.126.0"
14
+ "@valbuild/core": "0.127.0",
15
+ "@valbuild/shared": "0.127.0",
16
+ "@valbuild/ui": "0.127.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@testing-library/react": "^16.3.3",
@@ -1,6 +1,6 @@
1
1
  import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-9cce0d9f.browser.esm.js';
2
- import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-7ab6ed4f.browser.esm.js';
3
- export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-7ab6ed4f.browser.esm.js';
2
+ import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-57f19ada.browser.esm.js';
3
+ export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-57f19ada.browser.esm.js';
4
4
  import ReactJSXRuntime__default from 'react/jsx-runtime';
5
5
  import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
6
6
  import React from 'react';
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var slicedToArray = require('../../dist/slicedToArray-e9e8e991.cjs.dev.js');
6
- var raw = require('../../dist/raw-b5ef1ca2.cjs.dev.js');
6
+ var raw = require('../../dist/raw-512e7a0a.cjs.dev.js');
7
7
  var ReactJSXRuntime = require('react/jsx-runtime');
8
8
  var jsxRuntimeDev = require('react/jsx-dev-runtime');
9
9
  var React = require('react');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var slicedToArray = require('../../dist/slicedToArray-86004d59.cjs.prod.js');
6
- var raw = require('../../dist/raw-791f5023.cjs.prod.js');
6
+ var raw = require('../../dist/raw-fe78b046.cjs.prod.js');
7
7
  var ReactJSXRuntime = require('react/jsx-runtime');
8
8
  var jsxRuntimeDev = require('react/jsx-dev-runtime');
9
9
  var React = require('react');
@@ -1,6 +1,6 @@
1
1
  import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-0c0a3b4a.esm.js';
2
- import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-d83a161a.esm.js';
3
- export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-d83a161a.esm.js';
2
+ import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-7ce61255.esm.js';
3
+ export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-7ce61255.esm.js';
4
4
  import ReactJSXRuntime__default from 'react/jsx-runtime';
5
5
  import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
6
6
  import React from 'react';
@@ -1,6 +1,6 @@
1
1
  import { a as _typeof, _ as _slicedToArray } from '../../dist/slicedToArray-7d0170b6.worker.esm.js';
2
- import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-b9cef70c.worker.esm.js';
3
- export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-b9cef70c.worker.esm.js';
2
+ import { s as stegaDecodeStrings, _ as _createForOfIteratorHelper } from '../../dist/raw-eede220f.worker.esm.js';
3
+ export { c as attrs, g as getModuleIds, r as raw, b as stegaClean, s as stegaDecodeStrings, a as stegaEncode } from '../../dist/raw-eede220f.worker.esm.js';
4
4
  import ReactJSXRuntime__default from 'react/jsx-runtime';
5
5
  import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
6
6
  import React from 'react';