@jxsuite/schema 1.9.0 → 2.0.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/README.md +6 -6
- package/defs/function-def.schema.ts +7 -0
- package/package.json +5 -5
- package/schema.json +35 -0
- package/src/locale.ts +24 -0
- package/types.ts +14 -0
package/README.md
CHANGED
|
@@ -44,12 +44,12 @@ const valid = await validateDocument(doc); // validate a Jx document
|
|
|
44
44
|
|
|
45
45
|
## Component schema coverage
|
|
46
46
|
|
|
47
|
-
- **`tagName
|
|
48
|
-
- **Element properties
|
|
49
|
-
- **`style
|
|
50
|
-
- **Event handlers
|
|
51
|
-
- **`state` shapes
|
|
52
|
-
- **Built-in `$prototype` values
|
|
47
|
+
- **`tagName`**: all standard HTML element names from `@webref/elements`
|
|
48
|
+
- **Element properties**: all DOM IDL properties from `@webref/idl`
|
|
49
|
+
- **`style`**: all CSSOM camelCase properties from `@webref/css`
|
|
50
|
+
- **Event handlers**: all `EventHandler` names (`onclick`, `oninput`, …)
|
|
51
|
+
- **`state` shapes**: naked value, typed value, computed, function, external class
|
|
52
|
+
- **Built-in `$prototype` values**: `Request`, `LocalStorage`, `SessionStorage`, `Cookie`, `IndexedDB`, `Array`, `Set`, `Map`, `Blob`, `ReadableStream`, `URLSearchParams`, `FormData`
|
|
53
53
|
|
|
54
54
|
## VSCode / editor integration
|
|
55
55
|
|
|
@@ -9,6 +9,13 @@ export const functionDefSchema = {
|
|
|
9
9
|
description: "Named export in $src module. Defaults to the state key name.",
|
|
10
10
|
type: "string",
|
|
11
11
|
},
|
|
12
|
+
$lazy: {
|
|
13
|
+
description:
|
|
14
|
+
"Load $src on first call instead of importing it up front. The function then returns a " +
|
|
15
|
+
"promise, so it may only be called from a handler or lifecycle hook — never bound as a " +
|
|
16
|
+
"computed value. Use it for code most visitors never reach.",
|
|
17
|
+
type: "boolean",
|
|
18
|
+
},
|
|
12
19
|
$prototype: { const: "Function", type: "string" },
|
|
13
20
|
$src: {
|
|
14
21
|
description: "External module specifier. Mutually exclusive with body.",
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@webref/css": "^8.7.
|
|
4
|
-
"@webref/elements": "^2.
|
|
5
|
-
"@webref/idl": "^3.
|
|
3
|
+
"@webref/css": "^8.7.3",
|
|
4
|
+
"@webref/elements": "^2.8.0",
|
|
5
|
+
"@webref/idl": "^3.83.0",
|
|
6
6
|
"ajv": "^8.20.0",
|
|
7
7
|
"ajv-formats": "^3.0.1"
|
|
8
8
|
},
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"schema": "bun run src/schema.ts",
|
|
53
53
|
"test": "bun test --isolate",
|
|
54
54
|
"test:coverage": "bun test --isolate --coverage",
|
|
55
|
-
"upgrade": "
|
|
55
|
+
"upgrade": "bun update --latest && bun install"
|
|
56
56
|
},
|
|
57
57
|
"type": "module",
|
|
58
|
-
"version": "
|
|
58
|
+
"version": "2.0.0",
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"json-schema-to-ts": "^3.1.1"
|
|
61
61
|
}
|
package/schema.json
CHANGED
|
@@ -211,6 +211,10 @@
|
|
|
211
211
|
"description": "Named export in $src module. Defaults to the state key name.",
|
|
212
212
|
"type": "string"
|
|
213
213
|
},
|
|
214
|
+
"$lazy": {
|
|
215
|
+
"description": "Load $src on first call instead of importing it up front. The function then returns a promise, so it may only be called from a handler or lifecycle hook — never bound as a computed value. Use it for code most visitors never reach.",
|
|
216
|
+
"type": "boolean"
|
|
217
|
+
},
|
|
214
218
|
"$prototype": {
|
|
215
219
|
"const": "Function",
|
|
216
220
|
"type": "string"
|
|
@@ -2565,6 +2569,20 @@
|
|
|
2565
2569
|
}
|
|
2566
2570
|
]
|
|
2567
2571
|
},
|
|
2572
|
+
"onconfigurationchange": {
|
|
2573
|
+
"description": "Event handler for the \"configurationchange\" event.",
|
|
2574
|
+
"oneOf": [
|
|
2575
|
+
{
|
|
2576
|
+
"$ref": "#/$defs/RefObject"
|
|
2577
|
+
},
|
|
2578
|
+
{
|
|
2579
|
+
"$ref": "#/$defs/ExpressionEntry"
|
|
2580
|
+
},
|
|
2581
|
+
{
|
|
2582
|
+
"$ref": "#/$defs/FunctionDef"
|
|
2583
|
+
}
|
|
2584
|
+
]
|
|
2585
|
+
},
|
|
2568
2586
|
"onconnect": {
|
|
2569
2587
|
"description": "Event handler for the \"connect\" event.",
|
|
2570
2588
|
"oneOf": [
|
|
@@ -5421,6 +5439,20 @@
|
|
|
5421
5439
|
}
|
|
5422
5440
|
]
|
|
5423
5441
|
},
|
|
5442
|
+
"onstream": {
|
|
5443
|
+
"description": "Event handler for the \"stream\" event.",
|
|
5444
|
+
"oneOf": [
|
|
5445
|
+
{
|
|
5446
|
+
"$ref": "#/$defs/RefObject"
|
|
5447
|
+
},
|
|
5448
|
+
{
|
|
5449
|
+
"$ref": "#/$defs/ExpressionEntry"
|
|
5450
|
+
},
|
|
5451
|
+
{
|
|
5452
|
+
"$ref": "#/$defs/FunctionDef"
|
|
5453
|
+
}
|
|
5454
|
+
]
|
|
5455
|
+
},
|
|
5424
5456
|
"onsubmit": {
|
|
5425
5457
|
"description": "Event handler for the \"submit\" event.",
|
|
5426
5458
|
"oneOf": [
|
|
@@ -22776,6 +22808,7 @@
|
|
|
22776
22808
|
"body",
|
|
22777
22809
|
"br",
|
|
22778
22810
|
"button",
|
|
22811
|
+
"camera",
|
|
22779
22812
|
"canvas",
|
|
22780
22813
|
"caption",
|
|
22781
22814
|
"circle",
|
|
@@ -22872,6 +22905,7 @@
|
|
|
22872
22905
|
"meter",
|
|
22873
22906
|
"mfrac",
|
|
22874
22907
|
"mi",
|
|
22908
|
+
"microphone",
|
|
22875
22909
|
"mmultiscripts",
|
|
22876
22910
|
"mn",
|
|
22877
22911
|
"mo",
|
|
@@ -22960,6 +22994,7 @@
|
|
|
22960
22994
|
"u",
|
|
22961
22995
|
"ul",
|
|
22962
22996
|
"use",
|
|
22997
|
+
"usermedia",
|
|
22963
22998
|
"var",
|
|
22964
22999
|
"video",
|
|
22965
23000
|
"view",
|
package/src/locale.ts
CHANGED
|
@@ -427,3 +427,27 @@ export function primaryLanguage(tag: unknown): string | null {
|
|
|
427
427
|
const canonical = canonicalizeLocale(tag);
|
|
428
428
|
return canonical === null ? null : (canonical.split("-")[0] ?? null);
|
|
429
429
|
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* The locale a URL belongs to.
|
|
433
|
+
*
|
|
434
|
+
* Matching is on the **first path segment**, compared canonically, so `/fr-CA/about/` resolves for
|
|
435
|
+
* a project that declared `fr-ca`. A path under no declared locale is the default locale — under
|
|
436
|
+
* `prefix-except-default` that is the point, and under `prefix-always` it is a page the author put
|
|
437
|
+
* outside the locale tree, which is theirs to place.
|
|
438
|
+
*
|
|
439
|
+
* @param {string} urlPattern - Site-absolute route pattern, e.g. `/fr/about/`
|
|
440
|
+
* @param {ResolvedI18n | null} i18n
|
|
441
|
+
* @returns {string | null} A canonical tag, or null when the project has no i18n
|
|
442
|
+
*/
|
|
443
|
+
export function localeOfRoute(urlPattern: string, i18n: ResolvedI18n | null): string | null {
|
|
444
|
+
if (i18n === null) {
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
const first = urlPattern.split("/").find(Boolean);
|
|
448
|
+
if (first === undefined) {
|
|
449
|
+
return i18n.defaultLocale;
|
|
450
|
+
}
|
|
451
|
+
const canonical = canonicalizeLocale(first);
|
|
452
|
+
return canonical !== null && i18n.locales.includes(canonical) ? canonical : i18n.defaultLocale;
|
|
453
|
+
}
|
package/types.ts
CHANGED
|
@@ -171,6 +171,13 @@ export interface JxFunctionDef {
|
|
|
171
171
|
$src?: string;
|
|
172
172
|
/** Named export within `$src`; defaults to the state key. */
|
|
173
173
|
$export?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Load `$src` on first call rather than importing it with the module.
|
|
176
|
+
*
|
|
177
|
+
* The function returns a promise once lazy, so it may only be called — never bound as a computed
|
|
178
|
+
* value. Meant for code most visitors never reach.
|
|
179
|
+
*/
|
|
180
|
+
$lazy?: boolean;
|
|
174
181
|
/** Legacy alias for `parameters` (bare names only). */
|
|
175
182
|
arguments?: string[];
|
|
176
183
|
timing?: "compiler" | "server" | "client";
|
|
@@ -648,6 +655,13 @@ export interface ProjectConfig {
|
|
|
648
655
|
deploy?: DeployConfig;
|
|
649
656
|
sitemap?: boolean;
|
|
650
657
|
headers?: HeadersConfig;
|
|
658
|
+
/**
|
|
659
|
+
* Minify emitted browser JavaScript. Defaults to true.
|
|
660
|
+
*
|
|
661
|
+
* Set false to ship readable bundles — debugging a deployed page, or diffing `dist/` where the
|
|
662
|
+
* two bundler backends agree on semantics but not on minified bytes.
|
|
663
|
+
*/
|
|
664
|
+
minify?: boolean;
|
|
651
665
|
[key: string]: unknown;
|
|
652
666
|
};
|
|
653
667
|
images?: ImageConfig;
|