@valancex/common 0.12.0 → 0.13.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/LICENSE +21 -0
- package/dist/app.d.ts +7 -4
- package/dist/app.js +162 -32
- package/dist/client.js +10 -2
- package/dist/color-scheme.d.ts +12 -0
- package/dist/color-scheme.js +15 -0
- package/dist/desktop.d.ts +22 -0
- package/dist/desktop.js +71 -0
- package/dist/http.d.ts +4 -1
- package/dist/http.js +7 -1
- package/dist/index.d.ts +82 -0
- package/dist/index.js +4 -0
- package/dist/internal.d.ts +6 -0
- package/dist/internal.js +6 -0
- package/dist/navigation.d.ts +6 -0
- package/dist/navigation.js +5 -0
- package/dist/open-system.d.ts +12 -0
- package/dist/open-system.js +31 -0
- package/dist/open.d.ts +23 -0
- package/dist/open.js +47 -0
- package/dist/platform.d.ts +5 -0
- package/dist/platform.js +4 -0
- package/dist/primitives.js +26 -1
- package/dist/scope.d.ts +11 -2
- package/dist/scope.js +10 -1
- package/dist/server.js +2 -1
- package/dist/store-file.d.ts +4 -0
- package/dist/store-file.js +49 -0
- package/dist/store.d.ts +40 -0
- package/dist/store.js +60 -0
- package/dist/targets.d.ts +8 -0
- package/dist/targets.js +22 -0
- package/dist/vocabulary.d.ts +23 -2
- package/dist/vocabulary.js +26 -1
- package/dist/web-app.d.ts +6 -0
- package/dist/web-app.js +20 -0
- package/package.json +8 -3
package/dist/vocabulary.d.ts
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
import type { WebPrimitives } from "@valancex/port-web";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* A target's vocabulary has one of two forms. The web's is a table of PORT Web's realizations, from which the manifest is derived (`tags`). Any other target's is a MESH manifest, as data
|
|
4
|
+
* (`components`): the PORT ships it (the Desktop PORT's `vocabulary.json` and `content.json`), and the build reads it as it is.
|
|
5
|
+
*/
|
|
6
|
+
export interface WebVocabulary {
|
|
3
7
|
/** The target's id (`web`). */
|
|
4
8
|
readonly target: string;
|
|
5
9
|
/** The tags, each with its props and events. */
|
|
6
10
|
readonly tags: WebPrimitives;
|
|
11
|
+
/**
|
|
12
|
+
* The props a template may leave out, by tag. PORT Web's table says how a prop is realized, not whether it is required, so the manifest derived from it makes every prop required but a boolean
|
|
13
|
+
* one; this is the author-facing rule beside it. An absent prop is not in the render tree, and PORT Web realizes an absent prop as no attribute (or the element's own initial value).
|
|
14
|
+
*/
|
|
15
|
+
readonly optional?: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
7
16
|
}
|
|
17
|
+
export interface ManifestVocabulary {
|
|
18
|
+
readonly target: string;
|
|
19
|
+
/** MESH manifest components: each with its props and events. */
|
|
20
|
+
readonly components: Readonly<Record<string, unknown>>;
|
|
21
|
+
}
|
|
22
|
+
export type Vocabulary = WebVocabulary | ManifestVocabulary;
|
|
23
|
+
/** The names a template may write as a primitive in this vocabulary. */
|
|
24
|
+
export declare const namesOf: (vocabulary: Vocabulary) => ReadonlyArray<string>;
|
|
25
|
+
/** A vocabulary that is a MESH manifest (or several: their components are merged, and a name may not be in two). */
|
|
26
|
+
export declare const fromManifests: (target: string, ...manifests: ReadonlyArray<{
|
|
27
|
+
readonly components: Readonly<Record<string, unknown>>;
|
|
28
|
+
}>) => ManifestVocabulary;
|
|
8
29
|
/** The web's vocabulary: HTML elements, with `class`, `theme`, `id` and `aria-*` as styling and accessibility hooks. */
|
|
9
|
-
export declare const webVocabulary:
|
|
30
|
+
export declare const webVocabulary: WebVocabulary;
|
package/dist/vocabulary.js
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
1
|
import { primitives } from "./primitives.js";
|
|
2
|
+
/** The names a template may write as a primitive in this vocabulary. */
|
|
3
|
+
export const namesOf = (vocabulary) => Object.keys("tags" in vocabulary ? vocabulary.tags : vocabulary.components);
|
|
4
|
+
/** A vocabulary that is a MESH manifest (or several: their components are merged, and a name may not be in two). */
|
|
5
|
+
export const fromManifests = (target, ...manifests) => {
|
|
6
|
+
const components = {};
|
|
7
|
+
for (const manifest of manifests) {
|
|
8
|
+
for (const [name, each] of Object.entries(manifest.components)) {
|
|
9
|
+
if (name in components) {
|
|
10
|
+
throw new Error(`the ${target} vocabulary declares "${name}" twice`);
|
|
11
|
+
}
|
|
12
|
+
components[name] = each;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return { target, components };
|
|
16
|
+
};
|
|
2
17
|
/** The web's vocabulary: HTML elements, with `class`, `theme`, `id` and `aria-*` as styling and accessibility hooks. */
|
|
3
|
-
export const webVocabulary = {
|
|
18
|
+
export const webVocabulary = {
|
|
19
|
+
target: "web",
|
|
20
|
+
tags: primitives,
|
|
21
|
+
optional: {
|
|
22
|
+
// styling and accessibility hooks are the web's, and a template for both targets does not write them
|
|
23
|
+
button: ["class", "pressed"],
|
|
24
|
+
checkbox: ["label"],
|
|
25
|
+
textfield: ["label", "placeholder"],
|
|
26
|
+
heading: ["level"],
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Plugin } from "@valancex/valance/web/plugin";
|
|
2
|
+
import type { AppState, Built } from "./app.js";
|
|
3
|
+
import type { DefinedApp } from "./index.js";
|
|
4
|
+
import type { Content } from "./model.js";
|
|
5
|
+
/** The plugin that makes the application a website: its tags, its URL policy, and its document head. */
|
|
6
|
+
export declare const plugin: (content: Content, built: Built, author?: DefinedApp) => Plugin<AppState>;
|
package/dist/web-app.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { titleFor } from "./app.js";
|
|
2
|
+
import { pageAt } from "./scope.js";
|
|
3
|
+
import { primitives } from "./primitives.js";
|
|
4
|
+
import { routes } from "./routes.js";
|
|
5
|
+
/** The plugin that makes the application a website: its tags, its URL policy, and its document head. */
|
|
6
|
+
export const plugin = (content, built, author) => ({
|
|
7
|
+
name: "valance-app",
|
|
8
|
+
primitives,
|
|
9
|
+
routes: routes(content),
|
|
10
|
+
head: (state) => {
|
|
11
|
+
const page = pageAt(content, state.page);
|
|
12
|
+
const shown = page ?? { description: "" };
|
|
13
|
+
const canonical = content.site.url === "" || page === undefined ? [] : [{ rel: "canonical", href: `${content.site.url}${content.site.base}${page.path.replace(/^\//, "")}` }];
|
|
14
|
+
return {
|
|
15
|
+
title: titleFor(content, page, state, author),
|
|
16
|
+
meta: shown.description === "" ? [] : [{ name: "description", content: shown.description }],
|
|
17
|
+
links: [...built.styles.map((href) => ({ rel: "stylesheet", href })), ...canonical],
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valancex/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "The author's side of a VALANCE application (defineApp, component, field) and the runtime the vlx build runs: the browser and server entries. What src/main.ts imports; @valancex/cli builds what it describes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"valance",
|
|
@@ -32,6 +32,10 @@
|
|
|
32
32
|
"types": "./dist/client.d.ts",
|
|
33
33
|
"default": "./dist/client.js"
|
|
34
34
|
},
|
|
35
|
+
"./desktop": {
|
|
36
|
+
"types": "./dist/desktop.d.ts",
|
|
37
|
+
"default": "./dist/desktop.js"
|
|
38
|
+
},
|
|
35
39
|
"./http": {
|
|
36
40
|
"types": "./dist/http.d.ts",
|
|
37
41
|
"default": "./dist/http.js"
|
|
@@ -58,8 +62,9 @@
|
|
|
58
62
|
"dependencies": {
|
|
59
63
|
"@valancex/mesh-runtime": "^0.11.0",
|
|
60
64
|
"@valancex/nexus": "^0.12.0",
|
|
61
|
-
"@valancex/port-web": "^0.
|
|
62
|
-
"@valancex/
|
|
65
|
+
"@valancex/port-web": "^0.6.1",
|
|
66
|
+
"@valancex/router": "^0.13.0",
|
|
67
|
+
"@valancex/valance": "^0.13.0"
|
|
63
68
|
},
|
|
64
69
|
"peerDependencies": {
|
|
65
70
|
"effect": "^3.10.0"
|