@graview/guest 0.1.9 → 0.1.12
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 +353 -3
- package/client.js +2 -0
- package/dist/channel.d.ts +11 -3
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js +5 -1
- package/dist/channel.js.map +1 -1
- package/dist/cli.d.ts +16 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +75 -0
- package/dist/cli.js.map +1 -0
- package/dist/client-script.d.ts +3 -0
- package/dist/client-script.d.ts.map +1 -0
- package/dist/client-script.js +21 -0
- package/dist/client-script.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.generated.d.ts +4 -0
- package/dist/client.generated.d.ts.map +1 -0
- package/dist/client.generated.js +9 -0
- package/dist/client.generated.js.map +1 -0
- package/dist/client.js +12 -0
- package/dist/client.js.map +1 -0
- package/dist/headless/describe.d.ts +19 -0
- package/dist/headless/describe.d.ts.map +1 -0
- package/dist/headless/describe.js +255 -0
- package/dist/headless/describe.js.map +1 -0
- package/dist/headless/draw.d.ts +17 -0
- package/dist/headless/draw.d.ts.map +1 -0
- package/dist/headless/draw.js +25 -0
- package/dist/headless/draw.js.map +1 -0
- package/dist/headless/index.d.ts +99 -0
- package/dist/headless/index.d.ts.map +1 -0
- package/dist/headless/index.js +143 -0
- package/dist/headless/index.js.map +1 -0
- package/dist/headless/judge.d.ts +16 -0
- package/dist/headless/judge.d.ts.map +1 -0
- package/dist/headless/judge.js +52 -0
- package/dist/headless/judge.js.map +1 -0
- package/dist/headless/node.d.ts +8 -0
- package/dist/headless/node.d.ts.map +1 -0
- package/dist/headless/node.js +80 -0
- package/dist/headless/node.js.map +1 -0
- package/dist/headless/protocol.d.ts +75 -0
- package/dist/headless/protocol.d.ts.map +1 -0
- package/dist/headless/protocol.js +14 -0
- package/dist/headless/protocol.js.map +1 -0
- package/dist/headless/runtime.d.ts +2 -0
- package/dist/headless/runtime.d.ts.map +1 -0
- package/dist/headless/runtime.generated.d.ts +2 -0
- package/dist/headless/runtime.generated.d.ts.map +1 -0
- package/dist/headless/runtime.generated.js +8 -0
- package/dist/headless/runtime.generated.js.map +1 -0
- package/dist/headless/runtime.js +171 -0
- package/dist/headless/runtime.js.map +1 -0
- package/dist/headless/tree.d.ts +54 -0
- package/dist/headless/tree.d.ts.map +1 -0
- package/dist/headless/tree.js +128 -0
- package/dist/headless/tree.js.map +1 -0
- package/dist/host/css.d.ts +118 -0
- package/dist/host/css.d.ts.map +1 -0
- package/dist/host/css.js +963 -0
- package/dist/host/css.js.map +1 -0
- package/dist/host/draw-budget.d.ts +10 -0
- package/dist/host/draw-budget.d.ts.map +1 -0
- package/dist/host/draw-budget.js +29 -0
- package/dist/host/draw-budget.js.map +1 -0
- package/dist/host/frame.d.ts +19 -1
- package/dist/host/frame.d.ts.map +1 -1
- package/dist/host/frame.js +21 -2
- package/dist/host/frame.js.map +1 -1
- package/dist/host/index.d.ts +4 -3
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +7 -1
- package/dist/host/index.js.map +1 -1
- package/dist/host/kit.d.ts +6 -2
- package/dist/host/kit.d.ts.map +1 -1
- package/dist/host/kit.js +12 -5
- package/dist/host/kit.js.map +1 -1
- package/dist/host/links.d.ts +24 -0
- package/dist/host/links.d.ts.map +1 -0
- package/dist/host/links.js +35 -0
- package/dist/host/links.js.map +1 -0
- package/dist/host/manifest.d.ts +50 -0
- package/dist/host/manifest.d.ts.map +1 -0
- package/dist/host/manifest.js +103 -0
- package/dist/host/manifest.js.map +1 -0
- package/dist/host/open-draw.d.ts +44 -0
- package/dist/host/open-draw.d.ts.map +1 -0
- package/dist/host/open-draw.js +108 -0
- package/dist/host/open-draw.js.map +1 -0
- package/dist/host/open-judge.d.ts +53 -0
- package/dist/host/open-judge.d.ts.map +1 -0
- package/dist/host/open-judge.js +95 -0
- package/dist/host/open-judge.js.map +1 -0
- package/dist/host/open-render.d.ts +32 -0
- package/dist/host/open-render.d.ts.map +1 -0
- package/dist/host/open-render.js +262 -0
- package/dist/host/open-render.js.map +1 -0
- package/dist/host/press.d.ts +15 -0
- package/dist/host/press.d.ts.map +1 -0
- package/dist/host/press.js +156 -0
- package/dist/host/press.js.map +1 -0
- package/dist/host/react.d.ts +15 -2
- package/dist/host/react.d.ts.map +1 -1
- package/dist/host/react.js +13 -5
- package/dist/host/react.js.map +1 -1
- package/dist/host/session.d.ts +94 -1
- package/dist/host/session.d.ts.map +1 -1
- package/dist/host/session.js +103 -14
- package/dist/host/session.js.map +1 -1
- package/dist/host/theme.d.ts +14 -0
- package/dist/host/theme.d.ts.map +1 -0
- package/dist/host/theme.js +51 -0
- package/dist/host/theme.js.map +1 -0
- package/dist/host/view-runtime.generated.d.ts +2 -0
- package/dist/host/view-runtime.generated.d.ts.map +1 -0
- package/dist/host/view-runtime.generated.js +7 -0
- package/dist/host/view-runtime.generated.js.map +1 -0
- package/dist/host/view-source.d.ts +10 -0
- package/dist/host/view-source.d.ts.map +1 -0
- package/dist/host/view-source.js +44 -0
- package/dist/host/view-source.js.map +1 -0
- package/dist/host/view.d.ts +138 -0
- package/dist/host/view.d.ts.map +1 -0
- package/dist/host/view.js +381 -0
- package/dist/host/view.js.map +1 -0
- package/dist/host/views.d.ts +10 -0
- package/dist/host/views.d.ts.map +1 -0
- package/dist/host/views.js +15 -0
- package/dist/host/views.js.map +1 -0
- package/dist/host/worker-react.d.ts +57 -0
- package/dist/host/worker-react.d.ts.map +1 -0
- package/dist/host/worker-react.js +129 -0
- package/dist/host/worker-react.js.map +1 -0
- package/dist/host/worker-start.d.ts +66 -0
- package/dist/host/worker-start.d.ts.map +1 -0
- package/dist/host/worker-start.js +188 -0
- package/dist/host/worker-start.js.map +1 -0
- package/dist/host/worker.d.ts +28 -19
- package/dist/host/worker.d.ts.map +1 -1
- package/dist/host/worker.js +60 -119
- package/dist/host/worker.js.map +1 -1
- package/dist/host/writes.d.ts +49 -0
- package/dist/host/writes.d.ts.map +1 -0
- package/dist/host/writes.js +76 -0
- package/dist/host/writes.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/open-kit.d.ts +148 -0
- package/dist/open-kit.d.ts.map +1 -0
- package/dist/open-kit.js +321 -0
- package/dist/open-kit.js.map +1 -0
- package/dist/protocol.d.ts +109 -3
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +13 -0
- package/dist/protocol.js.map +1 -1
- package/dist/worker/harden.d.ts +13 -2
- package/dist/worker/harden.d.ts.map +1 -1
- package/dist/worker/harden.js +10 -4
- package/dist/worker/harden.js.map +1 -1
- package/dist/worker/natives.d.ts +1 -0
- package/dist/worker/natives.d.ts.map +1 -1
- package/dist/worker/natives.js +4 -0
- package/dist/worker/natives.js.map +1 -1
- package/dist/worker/view-global.d.ts +70 -0
- package/dist/worker/view-global.d.ts.map +1 -0
- package/dist/worker/view-global.js +264 -0
- package/dist/worker/view-global.js.map +1 -0
- package/dist/worker/view.d.ts +14 -0
- package/dist/worker/view.d.ts.map +1 -0
- package/dist/worker/view.js +64 -0
- package/dist/worker/view.js.map +1 -0
- package/package.json +30 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AnySchema, Store } from "@graview/core";
|
|
2
|
+
import type { GuestRefusal } from "../protocol.js";
|
|
3
|
+
import { type ManifestAct, type WorkerViewManifest } from "./manifest.js";
|
|
4
|
+
/** Whether every member of the app sees every record: no sight is declared, or every kind is seen by everybody, whole. */
|
|
5
|
+
export declare function sightIsTotal<S extends AnySchema>(store: Store<S>): boolean;
|
|
6
|
+
/** A field the host read, at the moment of a press. */
|
|
7
|
+
export interface PressedField {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly value: string | number | boolean;
|
|
10
|
+
/** The viewer typed it: the last change was theirs, and the view has not set it since. */
|
|
11
|
+
readonly typed: boolean;
|
|
12
|
+
/** It holds nothing, and nobody has touched it. */
|
|
13
|
+
readonly empty: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* It is a pick — a radio, a select — whose value is the view's own words:
|
|
16
|
+
* the viewer chose it, but did not write it. Taken only as a value the
|
|
17
|
+
* app itself declares for the argument, or a record the view was shown.
|
|
18
|
+
*/
|
|
19
|
+
readonly chosen?: true;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The values the app's own declaration allows an argument — an enum's
|
|
23
|
+
* options or a literal's values, through `optional()`, `default()` and the
|
|
24
|
+
* like — or undefined when it declares no such list.
|
|
25
|
+
*/
|
|
26
|
+
export declare function declaredValues(schema: unknown): readonly unknown[] | undefined;
|
|
27
|
+
/** A press the host saw on an element bound to an act. */
|
|
28
|
+
export interface Press {
|
|
29
|
+
/** What the view called the act (`data-act`). */
|
|
30
|
+
readonly as: string;
|
|
31
|
+
/** The record the element is bound to (`data-record`), if any. */
|
|
32
|
+
readonly record?: string;
|
|
33
|
+
/** The fields in the press's scope, read by the host. */
|
|
34
|
+
readonly fields: readonly PressedField[];
|
|
35
|
+
}
|
|
36
|
+
export type Judged = {
|
|
37
|
+
readonly ok: true;
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly args: Record<string, unknown>;
|
|
40
|
+
} | {
|
|
41
|
+
readonly ok: false;
|
|
42
|
+
readonly reason: GuestRefusal;
|
|
43
|
+
readonly message: string;
|
|
44
|
+
};
|
|
45
|
+
export declare const refuse: (reason: GuestRefusal, message: string) => Judged;
|
|
46
|
+
export declare function entryFor(manifest: WorkerViewManifest, asked: string): ManifestAct | undefined;
|
|
47
|
+
/** An act the view asked for from its own code (`graview.act`). */
|
|
48
|
+
export declare function judgeCodeAct<S extends AnySchema>(store: Store<S>, manifest: WorkerViewManifest, name: string, args: Readonly<Record<string, unknown>>): Judged;
|
|
49
|
+
//# sourceMappingURL=writes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writes.d.ts","sourceRoot":"","sources":["../../src/host/writes.ts"],"names":[],"mappings":"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AK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5L,eAAO,MAAM,MAAM,GAAI,QAAQ,YAAY,EAAE,SAAS,MAAM,KAAG,MAA0C,CAAC;AAE1G,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAE7F;AAED,mEAAmE;AACnE,wBAAgB,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAK9J"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { manifestActs } from "./manifest.js";
|
|
2
|
+
/*
|
|
3
|
+
* WRITES THAT CANNOT LEAK (FR-92).
|
|
4
|
+
*
|
|
5
|
+
* A view runs for every member with that member's sight, and its author is
|
|
6
|
+
* not the member: a chat that read a record somebody else wrote may follow
|
|
7
|
+
* what was hidden in it. The danger is a view reading what this viewer may
|
|
8
|
+
* see and writing it where somebody else may see it. So:
|
|
9
|
+
*
|
|
10
|
+
* An act must be named in the view's manifest, or it is refused.
|
|
11
|
+
*
|
|
12
|
+
* Where the app's sight is total — every member sees every record — there
|
|
13
|
+
* is nothing to leak, and an act the view asks for from its own code
|
|
14
|
+
* applies with the arguments it gives (`sightIsTotal`).
|
|
15
|
+
*
|
|
16
|
+
* Otherwise an act applies only from a press the HOST saw — a trusted
|
|
17
|
+
* click on an element the view drew with `data-act` — in that press's own
|
|
18
|
+
* handler, and its arguments come only from
|
|
19
|
+
* · the record the element is bound to (`data-record`, on it or the
|
|
20
|
+
* nearest element around it), one the view was shown;
|
|
21
|
+
* · the manifest's constants for the act; and
|
|
22
|
+
* · the values of fields the host itself read, each one the viewer
|
|
23
|
+
* typed: the last change to it a trusted `input` or `change` event,
|
|
24
|
+
* and nothing the view drew changing it since.
|
|
25
|
+
* A field whose value the view set — its `value` attribute, a later
|
|
26
|
+
* update, a textarea's text, an option's `selected` — is FILLED BY THE
|
|
27
|
+
* VIEW, and a press that would carry it is refused. A view's code cannot
|
|
28
|
+
* type: what it dispatches lands in its own worker's DOM, never the
|
|
29
|
+
* host's, and every event it could cause there is untrusted.
|
|
30
|
+
*
|
|
31
|
+
* Either way the act is applied as the viewer, `via: "view:<name>"`, under
|
|
32
|
+
* the view's allowance, and undoable like any other.
|
|
33
|
+
*
|
|
34
|
+
* Pure: no DOM. The host's region reads the press and the fields
|
|
35
|
+
* (press.ts, fetched with the region's drawing), and judges them there.
|
|
36
|
+
*/
|
|
37
|
+
/** Whether every member of the app sees every record: no sight is declared, or every kind is seen by everybody, whole. */
|
|
38
|
+
export function sightIsTotal(store) {
|
|
39
|
+
const sees = store.policy?.sees ?? [];
|
|
40
|
+
if (sees.length === 0)
|
|
41
|
+
return true;
|
|
42
|
+
return store.schema.kinds.every((kind) => sees.some((sight) => sight.roles === "*" && !sight.own && sight.kinds.includes(kind)));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The values the app's own declaration allows an argument — an enum's
|
|
46
|
+
* options or a literal's values, through `optional()`, `default()` and the
|
|
47
|
+
* like — or undefined when it declares no such list.
|
|
48
|
+
*/
|
|
49
|
+
export function declaredValues(schema) {
|
|
50
|
+
let at = schema;
|
|
51
|
+
for (let depth = 0; depth < 8 && at?._zod?.def; depth += 1) {
|
|
52
|
+
const def = at._zod.def;
|
|
53
|
+
if (def["type"] === "enum")
|
|
54
|
+
return Object.values(def["entries"]);
|
|
55
|
+
if (def["type"] === "literal")
|
|
56
|
+
return def["values"];
|
|
57
|
+
if (!("innerType" in def))
|
|
58
|
+
return undefined;
|
|
59
|
+
at = def["innerType"];
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
export const refuse = (reason, message) => ({ ok: false, reason, message });
|
|
64
|
+
export function entryFor(manifest, asked) {
|
|
65
|
+
return manifestActs(manifest).find((one) => (one.as ?? one.act) === asked) ?? manifestActs(manifest).find((one) => one.act === asked && one.as === undefined);
|
|
66
|
+
}
|
|
67
|
+
/** An act the view asked for from its own code (`graview.act`). */
|
|
68
|
+
export function judgeCodeAct(store, manifest, name, args) {
|
|
69
|
+
const entry = entryFor(manifest, name);
|
|
70
|
+
if (!entry)
|
|
71
|
+
return refuse("undeclared", `This view may not ask for “${name}”: its manifest does not name it.`);
|
|
72
|
+
if (!sightIsTotal(store))
|
|
73
|
+
return refuse("press-only", "In this app some members may not see some records, so a view's act applies only when you press it.");
|
|
74
|
+
return { ok: true, name: entry.act, args: { ...args, ...(entry.constants ?? {}) } };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=writes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writes.js","sourceRoot":"","sources":["../../src/host/writes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAA6C,MAAM,eAAe,CAAC;AAExF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,0HAA0H;AAC1H,MAAM,UAAU,YAAY,CAAsB,KAAe;IAC/D,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;IACtC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,OAAQ,KAAK,CAAC,MAAM,CAAC,KAA2B,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CA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;AAED,mEAAmE;AACnE,MAAM,UAAU,YAAY,CAAsB,KAAe,EAAE,QAA4B,EAAE,IAAY,EAAE,IAAuC;IACpJ,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,KAAK;QAAE,OAAO,MAAM,CAAC,YAAY,EAAE,8BAA8B,IAAI,mCAAmC,CAAC,CAAC;IAC/G,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,YAAY,EAAE,oGAAoG,CAAC,CAAC;IAC5J,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;AACtF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { connectGuest } from "./guest.js";
|
|
2
2
|
export type { ConnectGuestOptions, Guest } from "./guest.js";
|
|
3
3
|
export { GUEST_PROTOCOL, GUEST_SANDBOX, OPAQUE_ORIGIN, isGuestReady, isHostHello } from "./protocol.js";
|
|
4
|
-
export type { GuestAct, GuestAnswer, GuestEdge, GuestEvent, GuestNode, GuestProps, GuestReady, GuestRefusal, GuestRequest, HostHello, HostMessage, } from "./protocol.js";
|
|
4
|
+
export type { GuestAct, GuestAnswer, GuestEdge, GuestDomEvent, GuestEvent, GuestNode, GuestPlace, GuestPressed, GuestProps, GuestTheme, GuestReady, GuestRefusal, GuestRequest, HostHello, HostMessage, } from "./protocol.js";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxG,YAAY,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,WAAW,GACZ,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxG,YAAY,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,EACb,UAAU,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,WAAW,GACZ,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE OPEN KIT (FR-90): what a worker view may draw, declared once.
|
|
3
|
+
*
|
|
4
|
+
* Graview Cloud's ADR 0007 put it in one line: safety comes from what a
|
|
5
|
+
* view can REACH, not from what it can DRAW. So the kit is broad — most of
|
|
6
|
+
* HTML's sectioning, text, lists, tables, disclosure and form controls,
|
|
7
|
+
* images, SVG's shapes, paths, text and gradients, and CSS for layout,
|
|
8
|
+
* colour, type, transitions, keyframes and media queries — and what is left
|
|
9
|
+
* out is exactly what could fetch, escape the region, or speak for the app:
|
|
10
|
+
*
|
|
11
|
+
* fetch `<script>`, `<iframe>`, `<object>`, `<embed>`, `<link>`, `<meta>`,
|
|
12
|
+
* `<base>`, `<style>` outside the view's own stylesheet, media and
|
|
13
|
+
* canvas, SVG `<image>`, `<feImage>`, `<foreignObject>`, SVG `<a>`,
|
|
14
|
+
* SMIL (which can rewrite an `href`), every `src`/`href`/`srcset`
|
|
15
|
+
* but an image's `data:` or same-origin `blob:` source and an SVG
|
|
16
|
+
* reference to `#id` in the view's own drawing, and in CSS every
|
|
17
|
+
* `url()` but `url(#id)` on a paint, `@import`, `@font-face`,
|
|
18
|
+
* `@namespace`, and every function not on `CSS_FUNCTIONS`
|
|
19
|
+
* (`image-set()`, `cross-fade()`, `element()`, `paint()`,
|
|
20
|
+
* `attr()`, `expression()`, …).
|
|
21
|
+
* escape `position: fixed` and `sticky`, `:host` and `::slotted`, the
|
|
22
|
+
* top layer (`popover`, `<dialog>`), `autofocus`, `accesskey`,
|
|
23
|
+
* and `<form>`, whose submission is a navigation.
|
|
24
|
+
* speak `role="alert"`, the landmark roles the app's own chrome uses
|
|
25
|
+
* and the elements that carry them (`<nav>`, `<header>`,
|
|
26
|
+
* `<footer>`, `<aside>`, `<search>` are drawn as `<div>`, `<output>`
|
|
27
|
+
* as `<span>`, and a `<section>` is never named),
|
|
28
|
+
* `aria-live="assertive"`, and password and file inputs.
|
|
29
|
+
*
|
|
30
|
+
* The host draws from this declaration (host/open-render.ts, with
|
|
31
|
+
* host/css.ts for every stylesheet, style attribute and SVG paint), and the
|
|
32
|
+
* worker's runtime reads the same tables to tell an author at once what the
|
|
33
|
+
* host will not draw (worker/view.ts). Adding an element or an attribute
|
|
34
|
+
* here makes it drawable on both sides; nothing else changes.
|
|
35
|
+
*
|
|
36
|
+
* This module has no imports: a view's runtime carries it and nothing of
|
|
37
|
+
* the framework.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* What an attribute's value may be:
|
|
41
|
+
*
|
|
42
|
+
* text any string, as text (a title, a label, an id)
|
|
43
|
+
* number a finite number
|
|
44
|
+
* boolean present or absent
|
|
45
|
+
* oneOf one of a closed list, compared without case
|
|
46
|
+
* css a CSS value for the property of the attribute's own name (an
|
|
47
|
+
* SVG presentation attribute: `fill`, `stroke`, …), sanitised
|
|
48
|
+
* as a stylesheet's value is
|
|
49
|
+
* geometry SVG geometry and transforms (`d`, `points`, `viewBox`,
|
|
50
|
+
* `transform`): numbers, letters, commas and brackets, never `url`
|
|
51
|
+
* image an image's source: a `data:image/…` URL, or a `blob:` URL of
|
|
52
|
+
* the host page's own origin
|
|
53
|
+
* fragment a reference to an element of the view's own drawing: `#id`
|
|
54
|
+
* style a declaration list, sanitised as a stylesheet's declarations
|
|
55
|
+
*/
|
|
56
|
+
export type OpenAttribute = "text" | "number" | "boolean" | "css" | "geometry" | "image" | "fragment" | "style" | {
|
|
57
|
+
readonly oneOf: readonly string[];
|
|
58
|
+
};
|
|
59
|
+
export interface OpenElement {
|
|
60
|
+
/** The attributes this element takes beyond its namespace's global ones, by canonical name. */
|
|
61
|
+
readonly attributes?: Readonly<Record<string, OpenAttribute>>;
|
|
62
|
+
/** It holds nothing (`img`, `input`, `br`). */
|
|
63
|
+
readonly empty?: true;
|
|
64
|
+
}
|
|
65
|
+
/** Attributes every HTML element takes. `aria-*` and `data-*` are read by pattern (`isAriaAttribute`, `isDataAttribute`). */
|
|
66
|
+
export declare const HTML_GLOBAL_ATTRIBUTES: Readonly<Record<string, OpenAttribute>>;
|
|
67
|
+
/** The HTML elements a view may draw, by name. */
|
|
68
|
+
export declare const HTML_ELEMENTS: Readonly<Record<string, OpenElement>>;
|
|
69
|
+
/** Attributes every SVG element takes. */
|
|
70
|
+
export declare const SVG_GLOBAL_ATTRIBUTES: Readonly<Record<string, OpenAttribute>>;
|
|
71
|
+
/** The SVG elements a view may draw, by canonical (camel-cased) name. */
|
|
72
|
+
export declare const SVG_ELEMENTS: Readonly<Record<string, OpenElement>>;
|
|
73
|
+
/**
|
|
74
|
+
* What is refused, and why, for an author and for the tests: none of these
|
|
75
|
+
* is in the tables above, and a test holds them out. Not the allowlist —
|
|
76
|
+
* anything not above is refused — but the names a reader looks for.
|
|
77
|
+
*/
|
|
78
|
+
export declare const NEVER_DRAWN: {
|
|
79
|
+
readonly html: readonly ["script", "iframe", "frame", "frameset", "object", "embed", "applet", "portal", "link", "meta", "base", "style", "form", "template", "slot", "noscript", "audio", "video", "source", "track", "picture", "canvas", "dialog", "datalist", "main", "html", "head", "body", "title"];
|
|
80
|
+
readonly svg: readonly ["image", "feImage", "filter", "foreignObject", "a", "script", "style", "animate", "animateMotion", "animateTransform", "set", "discard", "view", "switch", "cursor", "font-face"];
|
|
81
|
+
readonly attributes: readonly ["src (outside img)", "href", "xlink:href (outside a #fragment)", "srcset", "sizes", "action", "formaction", "ping", "poster", "background", "on*", "popover", "popovertarget", "autofocus", "accesskey", "contenteditable", "is", "nonce", "autocomplete", "form", "list"];
|
|
82
|
+
};
|
|
83
|
+
/** Roles that would make a view speak as the app's own chrome or notices. */
|
|
84
|
+
export declare const REFUSED_ROLES: readonly ["alert", "alertdialog", "dialog", "banner", "main", "navigation", "contentinfo", "complementary", "search", "form", "region", "application", "status", "log", "marquee", "timer"];
|
|
85
|
+
/**
|
|
86
|
+
* Elements whose own role is a landmark or a notice's, drawn as an element
|
|
87
|
+
* with none: what they hold is drawn, but they speak as the app's chrome
|
|
88
|
+
* (`<nav>` is a navigation landmark, `<header>` a banner, `<output>` a
|
|
89
|
+
* status) to assistive technology. Setting a role on them cannot cover it:
|
|
90
|
+
* `role="none"` on a focusable or named element is ignored, and the
|
|
91
|
+
* landmark comes back. A view's stylesheet reaches them by class, not by
|
|
92
|
+
* these names.
|
|
93
|
+
*/
|
|
94
|
+
export declare const HTML_DRAWN_AS: Readonly<Record<string, string>>;
|
|
95
|
+
/** Attributes that would name an element: a named `<section>` is a region landmark, so a section is never named. */
|
|
96
|
+
export declare const UNNAMED_ELEMENTS: Readonly<Record<string, readonly string[]>>;
|
|
97
|
+
/** `aria-*`, by pattern. */
|
|
98
|
+
export declare function isAriaAttribute(name: string): boolean;
|
|
99
|
+
/** `data-*`, by pattern. */
|
|
100
|
+
export declare function isDataAttribute(name: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* THE CSS A VIEW MAY WRITE: an allowlist of properties, so a property a
|
|
103
|
+
* browser ships tomorrow that takes an image is refused until somebody adds
|
|
104
|
+
* it here, rather than drawn until somebody notices.
|
|
105
|
+
*/
|
|
106
|
+
export declare const CSS_PROPERTIES: readonly string[];
|
|
107
|
+
/**
|
|
108
|
+
* The CSS functions a value may call. Every one makes a value of its own
|
|
109
|
+
* arguments; none names a resource. `url()` is not here: it is read apart,
|
|
110
|
+
* and kept only as `url(#id)` on a property in `CSS_FRAGMENT_PROPERTIES`.
|
|
111
|
+
*/
|
|
112
|
+
export declare const CSS_FUNCTIONS: readonly string[];
|
|
113
|
+
/**
|
|
114
|
+
* Where `url(#id)` stays: the paints and references an SVG drawing makes
|
|
115
|
+
* to its own gradients, clip paths, masks and markers. A fragment of the
|
|
116
|
+
* view's own drawing is resolved in the view's own tree and fetches
|
|
117
|
+
* nothing; anything else in a `url()` is refused wherever it is written.
|
|
118
|
+
*/
|
|
119
|
+
export declare const CSS_FRAGMENT_PROPERTIES: readonly string[];
|
|
120
|
+
/** The at-rules a stylesheet may hold. `@import`, `@font-face`, `@namespace`, `@property`, `@layer` and the rest are refused. */
|
|
121
|
+
export declare const CSS_AT_RULES: readonly string[];
|
|
122
|
+
/**
|
|
123
|
+
* The values a property may take when it may take only some: `position`
|
|
124
|
+
* stays in the region (no `fixed`, no `sticky`), and so does `var()` — a
|
|
125
|
+
* property held to a list is held to a keyword, so a custom property
|
|
126
|
+
* cannot carry `fixed` into it.
|
|
127
|
+
*/
|
|
128
|
+
export declare const CSS_KEYWORD_PROPERTIES: Readonly<Record<string, readonly string[]>>;
|
|
129
|
+
/** Selectors a view's stylesheet may not write: each reaches past the view's own tree. */
|
|
130
|
+
export declare const CSS_REFUSED_SELECTORS: readonly string[];
|
|
131
|
+
/** The largest stylesheet, in characters, a view may give. */
|
|
132
|
+
export declare const OPEN_MAX_STYLESHEET = 64000;
|
|
133
|
+
/** The longest attribute value, in characters; geometry (`d`, `points`) may be longer. */
|
|
134
|
+
export declare const OPEN_MAX_ATTRIBUTE = 4000;
|
|
135
|
+
export declare const OPEN_MAX_GEOMETRY = 100000;
|
|
136
|
+
/** The largest image a view may hold, as its `data:` URL's length. */
|
|
137
|
+
export declare const OPEN_MAX_IMAGE = 512000;
|
|
138
|
+
/** The longest text a node may hold, in characters; longer is cut. */
|
|
139
|
+
export declare const OPEN_MAX_TEXT = 10000;
|
|
140
|
+
export declare const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
141
|
+
export declare const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
142
|
+
export declare function svgElementName(name: string): string | undefined;
|
|
143
|
+
/** The canonical name of an attribute an element takes, from any casing (`viewbox` → `viewBox`), with what it may hold; or undefined. */
|
|
144
|
+
export declare function openAttribute(namespace: "html" | "svg", element: string, name: string): {
|
|
145
|
+
readonly name: string;
|
|
146
|
+
readonly kind: OpenAttribute;
|
|
147
|
+
} | undefined;
|
|
148
|
+
//# sourceMappingURL=open-kit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-kit.d.ts","sourceRoot":"","sources":["../src/open-kit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAExJ,MAAM,WAAW,WAAW;IAC1B,+FAA+F;IAC/F,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MA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