@exponential-at/ui 0.0.0-stage → 0.1.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 +201 -0
- package/NOTICE +54 -0
- package/README.md +360 -2
- package/catalog/a11y.json +668 -0
- package/catalog/basic-map.json +104 -0
- package/catalog/code.json +58 -0
- package/catalog/core.catalog.json +4752 -0
- package/catalog/core.schema.json +22667 -0
- package/catalog/host.json +64 -0
- package/catalog/layout.json +20 -0
- package/catalog/limits.json +9 -0
- package/catalog/locale.json +48 -0
- package/catalog/macros.json +3417 -0
- package/catalog/recipes.json +61 -0
- package/catalog/strings.json +72 -0
- package/catalog/style.json +128 -0
- package/catalog/theme.schema.json +42543 -0
- package/catalog/tokens.json +47 -0
- package/conformance/README.md +217 -0
- package/conformance/baseline.ts +101 -0
- package/conformance/browser-page.ts +146 -0
- package/conformance/browser-suites.ts +683 -0
- package/conformance/compare.ts +201 -0
- package/conformance/dom.ts +96 -0
- package/conformance/dump.ts +163 -0
- package/conformance/fonts.json +154 -0
- package/conformance/manifest.json +224 -0
- package/conformance/parity-compare.ts +191 -0
- package/conformance/parity-report.schema.json +73 -0
- package/conformance/parity.ts +412 -0
- package/conformance/pixel.ts +177 -0
- package/conformance/primitives-page.ts +49 -0
- package/conformance/report.schema.json +66 -0
- package/conformance/run.ts +118 -0
- package/dist/chunks/index-98npjvsd.js +3940 -0
- package/dist/chunks/index-98npjvsd.js.map +27 -0
- package/dist/chunks/index-gwkt14w3.js +7314 -0
- package/dist/chunks/index-gwkt14w3.js.map +10 -0
- package/dist/chunks/index-njt7yzzm.js +134 -0
- package/dist/chunks/index-njt7yzzm.js.map +9 -0
- package/dist/chunks/index-we7va6v6.js +7984 -0
- package/dist/chunks/index-we7va6v6.js.map +15 -0
- package/dist/chunks/index-xrm6f7wc.js +2563 -0
- package/dist/chunks/index-xrm6f7wc.js.map +10 -0
- package/dist/conformance.js +182749 -0
- package/dist/conformance.js.map +10 -0
- package/dist/entries/prompt.js +251 -0
- package/dist/entries/prompt.js.map +11 -0
- package/dist/entries/schema.js +1725 -0
- package/dist/entries/schema.js.map +11 -0
- package/dist/host/index.js +122 -0
- package/dist/host/index.js.map +9 -0
- package/dist/index.js +3213 -0
- package/dist/index.js.map +27 -0
- package/dist/types/src/a11y.d.ts +21 -0
- package/dist/types/src/animation.d.ts +76 -0
- package/dist/types/src/basic-map.d.ts +38 -0
- package/dist/types/src/builder.d.ts +50 -0
- package/dist/types/src/catalog.d.ts +54 -0
- package/dist/types/src/catalog.described.d.ts +33 -0
- package/dist/types/src/catalog.generated.d.ts +829 -0
- package/dist/types/src/chart.d.ts +46 -0
- package/dist/types/src/code.d.ts +44 -0
- package/dist/types/src/color.d.ts +20 -0
- package/dist/types/src/conformance.d.ts +39 -0
- package/dist/types/src/connector/app.d.ts +14 -0
- package/dist/types/src/connector/connector.d.ts +77 -0
- package/dist/types/src/connector/index.d.ts +4 -0
- package/dist/types/src/css.d.ts +29 -0
- package/dist/types/src/define.d.ts +66 -0
- package/dist/types/src/direction.d.ts +16 -0
- package/dist/types/src/dynamic.d.ts +159 -0
- package/dist/types/src/entries/prompt.d.ts +11 -0
- package/dist/types/src/entries/schema.d.ts +8 -0
- package/dist/types/src/expr.d.ts +71 -0
- package/dist/types/src/extension.d.ts +4 -0
- package/dist/types/src/format.d.ts +112 -0
- package/dist/types/src/geometry.d.ts +40 -0
- package/dist/types/src/host/contract.d.ts +188 -0
- package/dist/types/src/host/decoders.d.ts +61 -0
- package/dist/types/src/host/index.d.ts +11 -0
- package/dist/types/src/host/package.d.ts +58 -0
- package/dist/types/src/host/policy.d.ts +105 -0
- package/dist/types/src/host/router.d.ts +34 -0
- package/dist/types/src/host/runtime.d.ts +205 -0
- package/dist/types/src/host/sources.d.ts +15 -0
- package/dist/types/src/host/transports.d.ts +109 -0
- package/dist/types/src/index.d.ts +63 -0
- package/dist/types/src/layout.d.ts +20 -0
- package/dist/types/src/limits.d.ts +21 -0
- package/dist/types/src/list.d.ts +133 -0
- package/dist/types/src/locale.d.ts +22 -0
- package/dist/types/src/macros.d.ts +29 -0
- package/dist/types/src/overlay.d.ts +27 -0
- package/dist/types/src/prompt.d.ts +44 -0
- package/dist/types/src/recipes.d.ts +17 -0
- package/dist/types/src/reducer.d.ts +41 -0
- package/dist/types/src/resizable.d.ts +38 -0
- package/dist/types/src/schema.d.ts +7 -0
- package/dist/types/src/strings.d.ts +13 -0
- package/dist/types/src/style.d.ts +201 -0
- package/dist/types/src/test-preload.d.ts +1 -0
- package/dist/types/src/text-shimmer.d.ts +24 -0
- package/dist/types/src/theme-types.d.ts +162 -0
- package/dist/types/src/theme.d.ts +73 -0
- package/dist/types/src/themes.d.ts +22 -0
- package/dist/types/src/tree-guides.d.ts +17 -0
- package/dist/types/src/types.d.ts +314 -0
- package/dist/types/src/validate.d.ts +31 -0
- package/dist/types/src/web/base-css.d.ts +1 -0
- package/dist/types/src/web/box-css.d.ts +55 -0
- package/dist/types/src/web/coerce.d.ts +32 -0
- package/dist/types/src/web/data.d.ts +105 -0
- package/dist/types/src/web/dates.d.ts +12 -0
- package/dist/types/src/web/form.d.ts +44 -0
- package/dist/types/src/web/host-types.d.ts +119 -0
- package/dist/types/src/web/index.d.ts +28 -0
- package/dist/types/src/web/inputs.d.ts +55 -0
- package/dist/types/src/web/list.d.ts +13 -0
- package/dist/types/src/web/listbox.d.ts +14 -0
- package/dist/types/src/web/markdown.d.ts +96 -0
- package/dist/types/src/web/media.d.ts +62 -0
- package/dist/types/src/web/parts.d.ts +4 -0
- package/dist/types/src/web/primitives/alert-dialog.d.ts +10 -0
- package/dist/types/src/web/primitives/alert.d.ts +9 -0
- package/dist/types/src/web/primitives/avatar-color.d.ts +2 -0
- package/dist/types/src/web/primitives/avatar.d.ts +13 -0
- package/dist/types/src/web/primitives/badge.d.ts +10 -0
- package/dist/types/src/web/primitives/breadcrumb.d.ts +10 -0
- package/dist/types/src/web/primitives/button.d.ts +6 -0
- package/dist/types/src/web/primitives/calendar.d.ts +43 -0
- package/dist/types/src/web/primitives/card.d.ts +9 -0
- package/dist/types/src/web/primitives/checkbox.d.ts +5 -0
- package/dist/types/src/web/primitives/choice-tiles.d.ts +32 -0
- package/dist/types/src/web/primitives/cn.d.ts +3 -0
- package/dist/types/src/web/primitives/code-block.d.ts +24 -0
- package/dist/types/src/web/primitives/command.d.ts +134 -0
- package/dist/types/src/web/primitives/context-ring.d.ts +24 -0
- package/dist/types/src/web/primitives/dialog-arms.d.ts +6 -0
- package/dist/types/src/web/primitives/dialog.d.ts +24 -0
- package/dist/types/src/web/primitives/disclosure-header.d.ts +5 -0
- package/dist/types/src/web/primitives/dock.d.ts +42 -0
- package/dist/types/src/web/primitives/dropdown-menu.d.ts +14 -0
- package/dist/types/src/web/primitives/empty-state.d.ts +15 -0
- package/dist/types/src/web/primitives/glass-card.d.ts +4 -0
- package/dist/types/src/web/primitives/hover-card.d.ts +7 -0
- package/dist/types/src/web/primitives/icon-disc.d.ts +12 -0
- package/dist/types/src/web/primitives/index.d.ts +48 -0
- package/dist/types/src/web/primitives/input.d.ts +5 -0
- package/dist/types/src/web/primitives/kbd.d.ts +4 -0
- package/dist/types/src/web/primitives/label.d.ts +3 -0
- package/dist/types/src/web/primitives/menu-surface.d.ts +17 -0
- package/dist/types/src/web/primitives/meter.d.ts +21 -0
- package/dist/types/src/web/primitives/popover.d.ts +3 -0
- package/dist/types/src/web/primitives/progress-ring.d.ts +5 -0
- package/dist/types/src/web/primitives/progress.d.ts +8 -0
- package/dist/types/src/web/primitives/scroll-area.d.ts +49 -0
- package/dist/types/src/web/primitives/segmented-control.d.ts +5 -0
- package/dist/types/src/web/primitives/select.d.ts +47 -0
- package/dist/types/src/web/primitives/separator.d.ts +3 -0
- package/dist/types/src/web/primitives/sheet-chrome.d.ts +4 -0
- package/dist/types/src/web/primitives/sheet.d.ts +20 -0
- package/dist/types/src/web/primitives/skeleton.d.ts +3 -0
- package/dist/types/src/web/primitives/spinner.d.ts +3 -0
- package/dist/types/src/web/primitives/switch.d.ts +4 -0
- package/dist/types/src/web/primitives/table.d.ts +11 -0
- package/dist/types/src/web/primitives/tabs.d.ts +13 -0
- package/dist/types/src/web/primitives/textarea.d.ts +3 -0
- package/dist/types/src/web/primitives/toast.d.ts +163 -0
- package/dist/types/src/web/primitives/tooltip.d.ts +3 -0
- package/dist/types/src/web/primitives/truncate.d.ts +7 -0
- package/dist/types/src/web/primitives/typeahead-portal.d.ts +12 -0
- package/dist/types/src/web/share.d.ts +6 -0
- package/dist/types/src/web/table.d.ts +20 -0
- package/dist/types/src/web/theme-css.d.ts +69 -0
- package/dist/types/src/web/urls.d.ts +21 -0
- package/dist/web/index.js +2303 -0
- package/dist/web/index.js.map +26 -0
- package/dist/web/primitives/index.js +1450 -0
- package/dist/web/primitives/index.js.map +57 -0
- package/docs/components.generated.json +6238 -0
- package/docs/round-1-contract.md +679 -0
- package/docs/round-2-contract.md +476 -0
- package/docs/round-3-contract.md +174 -0
- package/docs/themes.generated.json +3503 -0
- package/fixtures/animations.json +2890 -0
- package/fixtures/bench-list.json +58 -0
- package/fixtures/bind-time.json +30664 -0
- package/fixtures/catalog-basic-map.json +1692 -0
- package/fixtures/catalog-components.json +9323 -0
- package/fixtures/catalog-extension.json +620 -0
- package/fixtures/catalog-macros.json +36370 -0
- package/fixtures/code-tokens.json +1993 -0
- package/fixtures/conformance-baseline.json +55544 -0
- package/fixtures/conformance-cases.json +49 -0
- package/fixtures/conformance-known.json +2123 -0
- package/fixtures/control-geometry.json +4200 -0
- package/fixtures/dashboard.data.json +74 -0
- package/fixtures/dashboard.json +752 -0
- package/fixtures/demo-surface.json +47 -0
- package/fixtures/format.json +870 -0
- package/fixtures/host-policy.json +1067 -0
- package/fixtures/host-router.json +1152 -0
- package/fixtures/host-transport.json +590 -0
- package/fixtures/interactions-round1.json +773 -0
- package/fixtures/kitchen-sink.expanded.json +10844 -0
- package/fixtures/kitchen-sink.json +3049 -0
- package/fixtures/layout-geometry-round1.json +7278 -0
- package/fixtures/layout-geometry.json +2072 -0
- package/fixtures/overlay-geometry.json +272 -0
- package/fixtures/primitive-specimens.json +58 -0
- package/fixtures/prompt-budget.json +33 -0
- package/fixtures/resizable.json +714 -0
- package/fixtures/round4-contract.json +2985 -0
- package/fixtures/specimens.json +9832 -0
- package/fixtures/style-conditions.json +336 -0
- package/fixtures/template-items.json +2215 -0
- package/fixtures/text-direction.json +309 -0
- package/fixtures/text-shimmer.json +96 -0
- package/fixtures/theme-extends.json +573 -0
- package/fixtures/theme-invalid.json +1296 -0
- package/fixtures/theme-recipes.json +58600 -0
- package/fixtures/theme-resolved.json +23949 -0
- package/fixtures/toast-stack.json +215 -0
- package/fixtures/tree-guides.json +224 -0
- package/fixtures/virtual-list.json +733 -0
- package/generated/ExponentialUICatalog.generated.kt +67 -0
- package/generated/ExponentialUICatalog.generated.swift +67 -0
- package/generated/ExponentialUIThemes.generated.kt +23 -0
- package/generated/ExponentialUIThemes.generated.swift +23 -0
- package/generated/catalog.descriptions.generated.rs +6 -0
- package/generated/catalog.generated.rs +80 -0
- package/generated/catalog.themes.generated.rs +34 -0
- package/generated/core.descriptions.json +2505 -0
- package/generated/core.runtime.json +3609 -0
- package/package.json +87 -4
- package/themes/exponential.recipes.json +49 -0
- package/themes/exponential.theme.json +755 -0
- package/themes/neutral.theme.json +5676 -0
- package/themes/orange.theme.json +43 -0
- package/themes/playful.theme.json +219 -0
- package/vendor/a2ui/LICENSE.txt +203 -0
- package/vendor/a2ui/README.md +27 -0
- package/vendor/a2ui/v0_9/basic_catalog.json +1387 -0
- package/vendor/a2ui/v0_9/basic_catalog_rules.txt +5 -0
- package/vendor/a2ui/v0_9/client_capabilities.json +97 -0
- package/vendor/a2ui/v0_9/client_to_server.json +104 -0
- package/vendor/a2ui/v0_9/common_types.json +315 -0
- package/vendor/a2ui/v0_9/server_to_client.json +132 -0
- package/vendor/json-render/LICENSE.txt +201 -0
- package/vendor/json-render/README.md +13 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export type PluralCategory = `zero` | `one` | `two` | `few` | `many` | `other`;
|
|
2
|
+
export type DateStyle = `short` | `medium` | `long` | `full`;
|
|
3
|
+
export type RelativeUnit = `second` | `minute` | `hour` | `day` | `week` | `month` | `year`;
|
|
4
|
+
export interface NumberOptions {
|
|
5
|
+
/** Fixed fraction digits (min = max); absent = 0..3 for numbers, the
|
|
6
|
+
* currency's minor digits for currencies, 0 for percents. */
|
|
7
|
+
decimals?: number;
|
|
8
|
+
/** Locale grouping separators (default true). */
|
|
9
|
+
grouping?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface DateOptions {
|
|
12
|
+
/** A Unicode TR35 pattern (`MMM d, yyyy`, `HH:mm`); wins over `style`. */
|
|
13
|
+
format?: string;
|
|
14
|
+
/** A locale preset (default `medium`: `Oct 14, 2026`). */
|
|
15
|
+
style?: DateStyle;
|
|
16
|
+
/** Append the short time (`2:30 PM`) to a preset. */
|
|
17
|
+
time?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** What a host supplies per surface (SurfaceSettings.locale + timeZone). */
|
|
20
|
+
export interface Formatter {
|
|
21
|
+
readonly locale: string;
|
|
22
|
+
number(value: number, options?: NumberOptions): string;
|
|
23
|
+
currency(value: number, currency: string, options?: NumberOptions): string;
|
|
24
|
+
/** `value` is a ratio: 0.256 → `26%`. */
|
|
25
|
+
percent(value: number, options?: {
|
|
26
|
+
decimals?: number;
|
|
27
|
+
}): string;
|
|
28
|
+
/** `value` = `yyyy-mm-dd` (a calendar day, no zone), an ISO date-time (an
|
|
29
|
+
* instant; no offset = UTC) or epoch milliseconds; unreadable = ``. */
|
|
30
|
+
date(value: unknown, options?: DateOptions): string;
|
|
31
|
+
/** `value` as for `date`, against `now` (epoch ms). */
|
|
32
|
+
relativeTime(value: unknown, now: number): string;
|
|
33
|
+
plural(value: number): PluralCategory;
|
|
34
|
+
}
|
|
35
|
+
/** What a `string`/`markdown` prop shows for a bound value: strings as they
|
|
36
|
+
* are, finite numbers as ECMAScript `Number.prototype.toString` (shortest
|
|
37
|
+
* round trip, `-0` → `0`, exponent form below 1e-6 and from 1e21), booleans
|
|
38
|
+
* `true`/`false`; null, undefined, non-finite numbers, objects and arrays
|
|
39
|
+
* show nothing (``). No locale formatting (use formatNumber for that). */
|
|
40
|
+
export declare function displayString(value: unknown): string;
|
|
41
|
+
/** The minor digits of a currency (ISO 4217; 2 when not listed). */
|
|
42
|
+
export declare function currencyDigits(code: string): number;
|
|
43
|
+
/** The instant a date value names: `yyyy-mm-dd` = that calendar day (UTC
|
|
44
|
+
* midnight, `dateOnly`), an ISO date-time (no offset = UTC), epoch ms. */
|
|
45
|
+
export declare function parseDateValue(value: unknown): {
|
|
46
|
+
ms: number;
|
|
47
|
+
dateOnly: boolean;
|
|
48
|
+
} | null;
|
|
49
|
+
interface DateFields {
|
|
50
|
+
year: number;
|
|
51
|
+
month: number;
|
|
52
|
+
day: number;
|
|
53
|
+
weekday: number;
|
|
54
|
+
hour: number;
|
|
55
|
+
minute: number;
|
|
56
|
+
second: number;
|
|
57
|
+
}
|
|
58
|
+
interface DateNames {
|
|
59
|
+
months: readonly string[];
|
|
60
|
+
monthsShort: readonly string[];
|
|
61
|
+
weekdays: readonly string[];
|
|
62
|
+
weekdaysShort: readonly string[];
|
|
63
|
+
dayPeriods: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
/** A TR35 pattern over fields: `y yy yyyy M MM MMM MMMM d dd E EEE EEEE h hh
|
|
66
|
+
* H HH m mm s ss a`, `'quoted'` literals (`''` = an apostrophe); any other
|
|
67
|
+
* letter run is copied as written. Digits are ASCII. */
|
|
68
|
+
export declare function formatPattern(pattern: string, f: DateFields, names: DateNames): string;
|
|
69
|
+
/** The en-US preset patterns (`style`), the time a preset appends and the
|
|
70
|
+
* joiner per style (locale.json `englishFallback`). */
|
|
71
|
+
export declare const ENGLISH_DATE_PATTERNS: Readonly<Record<DateStyle, string>>;
|
|
72
|
+
export declare const ENGLISH_TIME_PATTERN: string;
|
|
73
|
+
export declare const ENGLISH_DATE_TIME_JOIN: Readonly<Record<DateStyle, string>>;
|
|
74
|
+
/** The surface zone as the English fallback sees it: the UTC offset in
|
|
75
|
+
* minutes (east positive) in force at an instant (epoch ms). A host
|
|
76
|
+
* without an IANA database passes its platform's local offset; the
|
|
77
|
+
* fixtures pin a fixed one (`offsetMinutes`). */
|
|
78
|
+
export type ZoneOffset = (utcMs: number) => number;
|
|
79
|
+
/** A fixed offset (minutes east of UTC); `fixedOffset(0)` = UTC. */
|
|
80
|
+
export declare const fixedOffset: (minutes: number) => ZoneOffset;
|
|
81
|
+
/** An IANA zone's offset through Intl (TS hosts; the Rust core takes its
|
|
82
|
+
* host's offset instead). */
|
|
83
|
+
export declare function intlZoneOffset(timeZone: string): ZoneOffset;
|
|
84
|
+
/** The unit a delta (value − now, ms) is shown in, and its count (truncated
|
|
85
|
+
* toward zero): under a minute seconds, under an hour minutes, under a day
|
|
86
|
+
* hours, under 7 days days, under 30 days weeks, under 365 days months (of
|
|
87
|
+
* 30 days), else years (of 365 days). */
|
|
88
|
+
export declare function relativeTimeUnit(deltaMs: number): {
|
|
89
|
+
value: number;
|
|
90
|
+
unit: RelativeUnit;
|
|
91
|
+
};
|
|
92
|
+
/** The Formatter a renderer uses without a platform ICU (the Rust core's
|
|
93
|
+
* default): Intl en-US, decided by data (catalog/locale.json
|
|
94
|
+
* `englishFallback`). Instants show in the surface zone `zone` (default
|
|
95
|
+
* UTC); a `yyyy-mm-dd` value is a calendar day and never shifts. */
|
|
96
|
+
export declare function englishFormatter(zone?: ZoneOffset): Formatter;
|
|
97
|
+
/** A Formatter on the platform's Intl in `locale` (BCP 47) and `timeZone`
|
|
98
|
+
* (IANA; default UTC, as the fixtures pin it). Patterns use the locale's
|
|
99
|
+
* month/weekday/day-period NAMES with ASCII digits. */
|
|
100
|
+
export declare function intlFormatter(locale: string, timeZone?: string): Formatter;
|
|
101
|
+
/** The bind-time format functions (A2UI basic `formatNumber`,
|
|
102
|
+
* `formatCurrency`, `formatDate`, `pluralize` + the core `formatPercent`,
|
|
103
|
+
* `formatRelativeTime`), all through ONE Formatter. */
|
|
104
|
+
export declare const FORMAT_FUNCTION_NAMES: readonly ["formatNumber", "formatCurrency", "formatPercent", "formatDate", "formatRelativeTime", "pluralize"];
|
|
105
|
+
/** The format functions over a Formatter; `now` = the clock
|
|
106
|
+
* `formatRelativeTime` reads when its call has no `now` (a renderer
|
|
107
|
+
* re-binds such a node at least once a minute). A value that is not a
|
|
108
|
+
* number, a numeric string (`NUMERIC`) or a date formats to ``. */
|
|
109
|
+
export declare function formatFunctions(formatter: Formatter, now?: () => number): Record<(typeof FORMAT_FUNCTION_NAMES)[number], (args: Record<string, unknown>) => unknown>;
|
|
110
|
+
/** The fallback's format functions (the reference bind table's). */
|
|
111
|
+
export declare const ENGLISH_FORMAT_FUNCTIONS: Record<"formatNumber" | "formatCurrency" | "formatDate" | "pluralize" | "formatPercent" | "formatRelativeTime", (args: Record<string, unknown>) => unknown>;
|
|
112
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ResolvedTheme } from "./theme-types.js";
|
|
2
|
+
/** The part whose recipe sizes each control. */
|
|
3
|
+
export declare const CONTROL_PARTS: Record<string, string>;
|
|
4
|
+
export declare const GEOMETRY_KEYS: readonly ["width", "height", "minWidth", "minHeight", "paddingHorizontal", "paddingVertical", "padding", "gap", "borderWidth", "borderRadius"];
|
|
5
|
+
export type GeometryKey = (typeof GEOMETRY_KEYS)[number];
|
|
6
|
+
export type ControlGeometry = Partial<Record<GeometryKey, number>>;
|
|
7
|
+
/** The numeric box of a control for a theme (mode-independent: lengths do
|
|
8
|
+
* not change with the mode). */
|
|
9
|
+
export declare function controlGeometry(theme: ResolvedTheme, component: string, props?: Record<string, unknown>, states?: readonly string[]): ControlGeometry;
|
|
10
|
+
/** What a painter reports after measuring the control it drew. */
|
|
11
|
+
export interface MeasuredBox {
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
paddingHorizontal?: number;
|
|
15
|
+
paddingVertical?: number;
|
|
16
|
+
borderWidth?: number;
|
|
17
|
+
borderRadius?: number;
|
|
18
|
+
}
|
|
19
|
+
/** A host's replacement painter for one native kind (the VAPP-91 extension
|
|
20
|
+
* API): it may draw anything, but `measure` must return the theme's box. */
|
|
21
|
+
export interface PainterOverride {
|
|
22
|
+
component: string;
|
|
23
|
+
measure(theme: ResolvedTheme, props: Record<string, unknown>, states?: readonly string[]): MeasuredBox;
|
|
24
|
+
}
|
|
25
|
+
export interface GeometryIssue {
|
|
26
|
+
key: string;
|
|
27
|
+
expected: number;
|
|
28
|
+
actual: number | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** Every geometry key the theme fixes that the measured box misses or
|
|
31
|
+
* changes (a key the theme leaves open is the painter's). */
|
|
32
|
+
export declare function checkGeometry(expected: ControlGeometry, measured: MeasuredBox, tolerance?: number): GeometryIssue[];
|
|
33
|
+
/** Run an override through every case the fixture holds for its kind. */
|
|
34
|
+
export declare function verifyPainterGeometry(override: PainterOverride, theme: ResolvedTheme, cases: readonly {
|
|
35
|
+
props: Record<string, unknown>;
|
|
36
|
+
states?: readonly string[];
|
|
37
|
+
}[]): {
|
|
38
|
+
name: string;
|
|
39
|
+
issues: GeometryIssue[];
|
|
40
|
+
}[];
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { FlatComponent } from "../types.js";
|
|
2
|
+
export declare const HOST_CONTRACT: {
|
|
3
|
+
$comment: string;
|
|
4
|
+
version: number;
|
|
5
|
+
a2uiVersion: string;
|
|
6
|
+
messages: {
|
|
7
|
+
$comment: string;
|
|
8
|
+
a2ui: string[];
|
|
9
|
+
extensions: string[];
|
|
10
|
+
};
|
|
11
|
+
ops: {
|
|
12
|
+
$comment: string;
|
|
13
|
+
kinds: string[];
|
|
14
|
+
};
|
|
15
|
+
clientMessages: {
|
|
16
|
+
$comment: string;
|
|
17
|
+
errorCodes: string[];
|
|
18
|
+
};
|
|
19
|
+
functions: {
|
|
20
|
+
$comment: string;
|
|
21
|
+
decisions: string[];
|
|
22
|
+
defaultPolicy: {
|
|
23
|
+
allow: never[];
|
|
24
|
+
ask: never[];
|
|
25
|
+
deny: never[];
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
urls: {
|
|
30
|
+
$comment: string;
|
|
31
|
+
defaultSchemes: string[];
|
|
32
|
+
privateHosts: string[];
|
|
33
|
+
reasons: string[];
|
|
34
|
+
};
|
|
35
|
+
media: {
|
|
36
|
+
$comment: string;
|
|
37
|
+
ruleKeys: string[];
|
|
38
|
+
optionKeys: string[];
|
|
39
|
+
defaultSchemes: string[];
|
|
40
|
+
limits: {
|
|
41
|
+
maxBytes: number;
|
|
42
|
+
timeoutMs: number;
|
|
43
|
+
maxPixels: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
sources: {
|
|
47
|
+
$comment: string;
|
|
48
|
+
pattern: string;
|
|
49
|
+
};
|
|
50
|
+
transport: {
|
|
51
|
+
$comment: string;
|
|
52
|
+
mcpMimeTypes: string[];
|
|
53
|
+
mcpActionTool: string;
|
|
54
|
+
sseEvents: string[];
|
|
55
|
+
};
|
|
56
|
+
negotiation: {
|
|
57
|
+
$comment: string;
|
|
58
|
+
};
|
|
59
|
+
package: {
|
|
60
|
+
$comment: string;
|
|
61
|
+
required: string[];
|
|
62
|
+
};
|
|
63
|
+
paint: {
|
|
64
|
+
$comment: string;
|
|
65
|
+
hook: string;
|
|
66
|
+
errorCode: string;
|
|
67
|
+
};
|
|
68
|
+
surface: {
|
|
69
|
+
$comment: string;
|
|
70
|
+
settings: string[];
|
|
71
|
+
formatter: string[];
|
|
72
|
+
commands: string[];
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export declare const HOST_CONTRACT_VERSION: number;
|
|
76
|
+
export declare const A2UI_MESSAGE_KINDS: readonly string[];
|
|
77
|
+
export declare const EXTENSION_MESSAGE_KINDS: readonly string[];
|
|
78
|
+
export declare const MESSAGE_KINDS: readonly string[];
|
|
79
|
+
export declare const HOST_ERROR_CODES: readonly string[];
|
|
80
|
+
export declare const DEFAULT_URL_SCHEMES: readonly string[];
|
|
81
|
+
/** The media loader's schemes when the host lists none (no `file`). */
|
|
82
|
+
export declare const DEFAULT_MEDIA_SCHEMES: readonly string[];
|
|
83
|
+
/** What every image loader enforces (`media.limits`). */
|
|
84
|
+
export declare const MEDIA_LIMITS: {
|
|
85
|
+
readonly maxBytes: number;
|
|
86
|
+
readonly timeoutMs: number;
|
|
87
|
+
readonly maxPixels: number;
|
|
88
|
+
};
|
|
89
|
+
/** The renderer → host hook a failed painter calls (`paint.hook`) and the
|
|
90
|
+
* A2UI error code the host forwards it with (`paint.errorCode`). */
|
|
91
|
+
export declare const PAINT_ERROR_HOOK: string;
|
|
92
|
+
export declare const RENDER_FAILED: "RENDER_FAILED";
|
|
93
|
+
export declare const MCP_MIME_TYPES: readonly string[];
|
|
94
|
+
export declare const MCP_ACTION_TOOL: string;
|
|
95
|
+
export declare const SSE_EVENTS: readonly string[];
|
|
96
|
+
/** Round 2: what a host hands each surface (`surface`): the SurfaceSettings
|
|
97
|
+
* keys, the Formatter's methods, the commands a live surface takes. */
|
|
98
|
+
export declare const SURFACE_SETTING_KEYS: readonly string[];
|
|
99
|
+
export declare const FORMATTER_METHODS: readonly string[];
|
|
100
|
+
export declare const SURFACE_COMMANDS: readonly string[];
|
|
101
|
+
export type HostErrorCode = `VALIDATION_FAILED` | `INVALID_MESSAGE` | `UNSUPPORTED_CATALOG` | `SURFACE_NOT_FOUND` | `TEMPLATE_NOT_FOUND` | `FUNCTION_NOT_FOUND` | `FUNCTION_DENIED` | `SOURCE_DENIED` | `RENDER_FAILED`;
|
|
102
|
+
/** A server → client message: the four A2UI v0.9 kinds plus the two
|
|
103
|
+
* Exponential UI extensions. */
|
|
104
|
+
export interface ServerMessage {
|
|
105
|
+
version?: string;
|
|
106
|
+
createSurface?: {
|
|
107
|
+
surfaceId: string;
|
|
108
|
+
catalogId: string;
|
|
109
|
+
theme?: unknown;
|
|
110
|
+
sendDataModel?: boolean;
|
|
111
|
+
};
|
|
112
|
+
updateComponents?: {
|
|
113
|
+
surfaceId: string;
|
|
114
|
+
components: FlatComponent[];
|
|
115
|
+
};
|
|
116
|
+
updateDataModel?: {
|
|
117
|
+
surfaceId: string;
|
|
118
|
+
path?: string;
|
|
119
|
+
value?: unknown;
|
|
120
|
+
};
|
|
121
|
+
deleteSurface?: {
|
|
122
|
+
surfaceId: string;
|
|
123
|
+
};
|
|
124
|
+
applyTemplate?: {
|
|
125
|
+
surfaceId: string;
|
|
126
|
+
templateId: string;
|
|
127
|
+
packageId?: string;
|
|
128
|
+
data?: unknown;
|
|
129
|
+
};
|
|
130
|
+
bindDataModel?: {
|
|
131
|
+
surfaceId: string;
|
|
132
|
+
path: string;
|
|
133
|
+
source: string;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export interface ClientAction {
|
|
137
|
+
name: string;
|
|
138
|
+
surfaceId: string;
|
|
139
|
+
sourceComponentId: string;
|
|
140
|
+
timestamp: string;
|
|
141
|
+
context: Record<string, unknown>;
|
|
142
|
+
payload?: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
export interface ClientError {
|
|
145
|
+
code: HostErrorCode | (string & {});
|
|
146
|
+
surfaceId: string;
|
|
147
|
+
message: string;
|
|
148
|
+
path?: string;
|
|
149
|
+
}
|
|
150
|
+
/** A client → server message (A2UI v0.9 client_to_server). */
|
|
151
|
+
export type ClientMessage = {
|
|
152
|
+
version: string;
|
|
153
|
+
action: ClientAction;
|
|
154
|
+
} | {
|
|
155
|
+
version: string;
|
|
156
|
+
error: ClientError;
|
|
157
|
+
};
|
|
158
|
+
/** What the router turns a message into; the platform host performs the
|
|
159
|
+
* ops in order (`catalog/host.json` `ops`). */
|
|
160
|
+
export type HostOp = {
|
|
161
|
+
op: `create`;
|
|
162
|
+
surfaceId: string;
|
|
163
|
+
catalogId: string;
|
|
164
|
+
theme?: unknown;
|
|
165
|
+
sendDataModel?: boolean;
|
|
166
|
+
} | {
|
|
167
|
+
op: `components`;
|
|
168
|
+
surfaceId: string;
|
|
169
|
+
components: FlatComponent[];
|
|
170
|
+
} | {
|
|
171
|
+
op: `data`;
|
|
172
|
+
surfaceId: string;
|
|
173
|
+
path: string;
|
|
174
|
+
value?: unknown;
|
|
175
|
+
} | {
|
|
176
|
+
op: `bind`;
|
|
177
|
+
surfaceId: string;
|
|
178
|
+
path: string;
|
|
179
|
+
source: string;
|
|
180
|
+
} | {
|
|
181
|
+
op: `delete`;
|
|
182
|
+
surfaceId: string;
|
|
183
|
+
} | {
|
|
184
|
+
op: `send`;
|
|
185
|
+
message: ClientMessage;
|
|
186
|
+
};
|
|
187
|
+
export declare function errorMessage(code: HostErrorCode, surfaceId: string, message: string, path?: string): ClientMessage;
|
|
188
|
+
export declare function actionMessage(action: ClientAction): ClientMessage;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ClientMessage } from "./contract.js";
|
|
2
|
+
export interface DecodeIssue {
|
|
3
|
+
/** 1-based line (JSONL) or event (SSE) number. */
|
|
4
|
+
at: number;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Decoded {
|
|
8
|
+
messages: unknown[];
|
|
9
|
+
issues: DecodeIssue[];
|
|
10
|
+
}
|
|
11
|
+
/** One message per line. `push` takes any chunking (a line may span
|
|
12
|
+
* chunks), `end` flushes a last line without a newline. A line past
|
|
13
|
+
* `maxMessageBytes` is an issue (`line N: message larger than … bytes`),
|
|
14
|
+
* never buffered. */
|
|
15
|
+
export declare class JsonlDecoder {
|
|
16
|
+
private lines;
|
|
17
|
+
private line;
|
|
18
|
+
push(chunk: string): Decoded;
|
|
19
|
+
end(): Decoded;
|
|
20
|
+
}
|
|
21
|
+
/** A whole JSONL document (or one JSON value / a JSON array of messages). */
|
|
22
|
+
export declare function decodeJsonl(text: string): Decoded;
|
|
23
|
+
/** Server-Sent Events: `data:` lines join with `\n` per event, a blank line
|
|
24
|
+
* dispatches, `:` comments and other fields are ignored (`retry:` is
|
|
25
|
+
* kept as `retryMs`), an `event:` name
|
|
26
|
+
* outside SSE_EVENTS drops the event. An event's data is one message or
|
|
27
|
+
* JSONL. */
|
|
28
|
+
export declare class SseDecoder {
|
|
29
|
+
/** The last `retry:` field (ms): the server resumes the stream after it
|
|
30
|
+
* ends (a transport reconnects on a clean end only then). */
|
|
31
|
+
retryMs?: number;
|
|
32
|
+
private lines;
|
|
33
|
+
private data;
|
|
34
|
+
/** The event's data bytes so far (past `maxMessageBytes` it is dropped
|
|
35
|
+
* and dispatches as an issue). */
|
|
36
|
+
private dataBytes;
|
|
37
|
+
private oversized;
|
|
38
|
+
private event;
|
|
39
|
+
private count;
|
|
40
|
+
push(chunk: string): Decoded;
|
|
41
|
+
end(): Decoded;
|
|
42
|
+
/** The event is past `maxMessageBytes`: forget its data (it dispatches
|
|
43
|
+
* as an issue). */
|
|
44
|
+
private dropData;
|
|
45
|
+
private line;
|
|
46
|
+
private dispatch;
|
|
47
|
+
}
|
|
48
|
+
/** The A2UI-over-MCP carrier: the messages inside an MCP tool result
|
|
49
|
+
* (`content[]` resources with an A2UI mime type, or
|
|
50
|
+
* `structuredContent.a2ui`). */
|
|
51
|
+
export declare function messagesFromMcpResult(result: unknown): Decoded;
|
|
52
|
+
/** A client message as the MCP tools/call that carries it back. */
|
|
53
|
+
export declare function mcpActionCall(message: ClientMessage, tool?: string): {
|
|
54
|
+
method: `tools/call`;
|
|
55
|
+
params: {
|
|
56
|
+
name: string;
|
|
57
|
+
arguments: {
|
|
58
|
+
message: ClientMessage;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./contract.js";
|
|
2
|
+
export * from "./policy.js";
|
|
3
|
+
export * from "./sources.js";
|
|
4
|
+
export * from "./decoders.js";
|
|
5
|
+
export * from "./package.js";
|
|
6
|
+
export { HostRouter, normalizePath } from "./router.js";
|
|
7
|
+
export type { HostRouterOptions, SurfaceInfo } from "./router.js";
|
|
8
|
+
export { ExponentialHost, PackageError, SurfaceStore, resolveSurfaceTheme } from "./runtime.js";
|
|
9
|
+
export type { Transport, TransportStatus, HostOptions, HostPolicy, HostFunction, FunctionCallInfo, FunctionOutcome, HostIssue } from "./runtime.js";
|
|
10
|
+
export { MemoryTransport, JsonlStreamTransport, SseTransport, WebSocketTransport, McpTransport } from "./transports.js";
|
|
11
|
+
export type { HttpTransportOptions, McpTransportOptions } from "./transports.js";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { FlatComponent } from "../types.js";
|
|
2
|
+
import type { ServerMessage } from "./contract.js";
|
|
3
|
+
/** The core, the core lite, the A2UI basic catalog, then every registered
|
|
4
|
+
* extension id in order, de-duplicated. */
|
|
5
|
+
export declare function supportedCatalogIds(extensionIds?: readonly string[]): string[];
|
|
6
|
+
/** A2UI's `a2uiClientCapabilities`. */
|
|
7
|
+
export declare function clientCapabilities(extensionIds?: readonly string[]): {
|
|
8
|
+
"v0.9": {
|
|
9
|
+
supportedCatalogIds: string[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export interface TemplateBinding {
|
|
13
|
+
path: string;
|
|
14
|
+
source: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AppTemplate {
|
|
17
|
+
components: FlatComponent[];
|
|
18
|
+
data?: unknown;
|
|
19
|
+
bindings?: TemplateBinding[];
|
|
20
|
+
}
|
|
21
|
+
export interface AppPackage {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
version: string;
|
|
25
|
+
catalogId: string;
|
|
26
|
+
templates: Record<string, AppTemplate>;
|
|
27
|
+
/** Function patterns the package's surfaces may call (allowlist). */
|
|
28
|
+
functions?: string[];
|
|
29
|
+
/** VAPP-107: the binding sources the package's surfaces may follow
|
|
30
|
+
* (`exp:devices`, or a prefix `exp:*`); unset = any registered scheme.
|
|
31
|
+
* Set, a template binding or a later `bindDataModel` outside it is
|
|
32
|
+
* refused (`sourceAllowed`). */
|
|
33
|
+
sources?: string[];
|
|
34
|
+
/** A built-in theme id or a theme JSON. */
|
|
35
|
+
theme?: unknown;
|
|
36
|
+
icon?: {
|
|
37
|
+
glyph?: string;
|
|
38
|
+
color?: string;
|
|
39
|
+
};
|
|
40
|
+
description?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface PackageIssue {
|
|
43
|
+
path: string;
|
|
44
|
+
message: string;
|
|
45
|
+
}
|
|
46
|
+
/** Every problem with a package, each with a JSON pointer into it. */
|
|
47
|
+
export declare function validatePackage(pkg: unknown, catalogIds?: readonly string[]): PackageIssue[];
|
|
48
|
+
/** VAPP-107: may a package whose `sources` list is `allowed` follow this
|
|
49
|
+
* source URI? Unset = yes; else the URI's `scheme:name` (scheme
|
|
50
|
+
* lower-cased, the query dropped) must match a listed source exactly or a
|
|
51
|
+
* `prefix*` pattern. */
|
|
52
|
+
export declare function sourceAllowed(allowed: readonly string[] | undefined, source: string): boolean;
|
|
53
|
+
/** A template as the messages that create it: createSurface, the
|
|
54
|
+
* components, the merged initial data, one bindDataModel per binding. */
|
|
55
|
+
export declare function templateMessages(pkg: AppPackage, templateId: string, surfaceId: string, data?: unknown): ServerMessage[] | null;
|
|
56
|
+
/** The template's data under the caller's (objects merge one level deep in
|
|
57
|
+
* key order; anything else: the caller's wins). */
|
|
58
|
+
export declare function mergeData(base: unknown, over: unknown): unknown;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/** The catalog's built-in client functions: the basic 14 + round 1's 15
|
|
2
|
+
* core ones (`functions.names`). */
|
|
3
|
+
export declare const BUILTIN_FUNCTIONS: readonly string[];
|
|
4
|
+
export type FunctionDecision = `allow` | `ask` | `deny` | `not_found`;
|
|
5
|
+
export interface FunctionPolicy {
|
|
6
|
+
allow?: readonly string[];
|
|
7
|
+
ask?: readonly string[];
|
|
8
|
+
deny?: readonly string[];
|
|
9
|
+
/** For a registered name no list matches; default `allow`. */
|
|
10
|
+
default?: `allow` | `ask` | `deny`;
|
|
11
|
+
}
|
|
12
|
+
/** `harness.*` matches `harness.toast`; anything else is exact. */
|
|
13
|
+
export declare function matchesPattern(pattern: string, name: string): boolean;
|
|
14
|
+
/** The gate: built-ins always run; an unregistered name is `not_found`;
|
|
15
|
+
* then deny wins, then allow, then ask, then the policy's default. */
|
|
16
|
+
export declare function decideFunction(policy: FunctionPolicy | undefined, name: string, registered: boolean): FunctionDecision;
|
|
17
|
+
/** Two policies stacked (a package's allowlist under the host's own): the
|
|
18
|
+
* stricter decision wins. */
|
|
19
|
+
export declare function combineDecisions(a: FunctionDecision, b: FunctionDecision): FunctionDecision;
|
|
20
|
+
/** A declarative package's `functions` list as a policy: listed = allow,
|
|
21
|
+
* anything else = deny. */
|
|
22
|
+
export declare function packagePolicy(functions: readonly string[] | undefined): FunctionPolicy;
|
|
23
|
+
export interface UrlPolicy {
|
|
24
|
+
/** The schemes allowed; default `DEFAULT_URL_SCHEMES` (https, http,
|
|
25
|
+
* mailto, tel). `["https"]` = https only. */
|
|
26
|
+
schemes?: readonly string[];
|
|
27
|
+
/** http(s) hosts allowed: exact or `*.example.com`; unset = any. */
|
|
28
|
+
hosts?: readonly string[];
|
|
29
|
+
/** VAPP-107: private, loopback and link-local hosts (`isPrivateHost`)
|
|
30
|
+
* are DENIED for http(s) unless listed here: exact, `*.suffix`, or `*`
|
|
31
|
+
* for every private address. A `hosts` allowlist does not opt one in. */
|
|
32
|
+
allowPrivate?: readonly string[];
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface UrlDecision {
|
|
36
|
+
allowed: boolean;
|
|
37
|
+
/** The absolute url when it parses. */
|
|
38
|
+
url?: string;
|
|
39
|
+
reason?: `invalid` | `scheme` | `host` | `private`;
|
|
40
|
+
}
|
|
41
|
+
/** VAPP-107: is a parsed, lower-cased hostname one the URL and media policy
|
|
42
|
+
* deny by default (`catalog/host.json` urls.privateHosts)? `localhost`
|
|
43
|
+
* and `*.localhost`, `*.local` (mDNS), the IPv4 blocks 0/8, 10/8, 127/8,
|
|
44
|
+
* 169.254/16, 172.16/12, 192.168/16, and IPv6 `::`, `::1`, fe80::/10,
|
|
45
|
+
* fc00::/7 plus an IPv4-mapped address of a private IPv4. LITERALS only:
|
|
46
|
+
* the policy never resolves names (a public name that resolves privately
|
|
47
|
+
* is the host network's job). */
|
|
48
|
+
export declare function isPrivateHost(hostname: string): boolean;
|
|
49
|
+
/** The decision for a url: it must parse (relative against `baseUrl`), use
|
|
50
|
+
* one of `schemes`, and for http(s) match `hosts` when set and not be a
|
|
51
|
+
* private host unless `allowPrivate` covers it. */
|
|
52
|
+
export declare function decideUrl(policy: UrlPolicy | undefined, url: string): UrlDecision;
|
|
53
|
+
export interface MediaRule {
|
|
54
|
+
prefix: string;
|
|
55
|
+
headers: Record<string, string>;
|
|
56
|
+
}
|
|
57
|
+
export interface MediaOptions {
|
|
58
|
+
baseUrl?: string;
|
|
59
|
+
rules?: readonly MediaRule[];
|
|
60
|
+
/** The schemes a src may use; default `DEFAULT_MEDIA_SCHEMES` (https,
|
|
61
|
+
* http, data). `file` only when listed. */
|
|
62
|
+
schemes?: readonly string[];
|
|
63
|
+
/** http(s) hosts media may load from: exact or `*.example.com`; unset = any. */
|
|
64
|
+
hosts?: readonly string[];
|
|
65
|
+
/** VAPP-107: the private hosts media may load from (`UrlPolicy.allowPrivate`). */
|
|
66
|
+
allowPrivate?: readonly string[];
|
|
67
|
+
}
|
|
68
|
+
export interface MediaRequest {
|
|
69
|
+
url: string;
|
|
70
|
+
headers: Record<string, string>;
|
|
71
|
+
}
|
|
72
|
+
/** The image / media loader's request: the absolute url plus the headers of
|
|
73
|
+
* every rule whose prefix it starts with (later rules win per header).
|
|
74
|
+
* Null when the url does not resolve or the media policy (schemes, hosts)
|
|
75
|
+
* denies it: nothing loads. */
|
|
76
|
+
export declare function mediaRequest(url: string, options?: MediaOptions): MediaRequest | null;
|
|
77
|
+
/** The href a renderer may navigate to (Link, markdown links, FileUpload
|
|
78
|
+
* file urls), or undefined when the URL policy denies it. */
|
|
79
|
+
export declare function safeHref(policy: UrlPolicy | undefined, url: unknown): string | undefined;
|
|
80
|
+
export declare function sortKeys<T>(record: Record<string, T>): Record<string, T>;
|
|
81
|
+
/** Width × height from an image's header (PNG, JPEG, GIF, WebP, BMP) or an
|
|
82
|
+
* SVG's root `width`/`height`/`viewBox` without decoding it: what a loader
|
|
83
|
+
* checks against `MEDIA_LIMITS.maxPixels` BEFORE decoding (the Rust core's
|
|
84
|
+
* `image_dimensions`). Null = not a header this reads (truncated bytes,
|
|
85
|
+
* another format). VAPP-103 rfix: an SVG has a size (`svgDimensions`). */
|
|
86
|
+
export declare function imageDimensions(bytes: Uint8Array): [number, number] | null;
|
|
87
|
+
/** The size an SVG rasterizes at: its root's `width`/`height` (px, or
|
|
88
|
+
* pt/pc/in/cm/mm/em/ex at 96 dpi and a 16 px em; `%` = unset); a missing
|
|
89
|
+
* one follows the `viewBox` aspect, both missing = the `viewBox` size, no
|
|
90
|
+
* `viewBox` = 100. Null = no `<svg` root tag (the Rust core's `svg_dimensions`). */
|
|
91
|
+
export declare function svgDimensions(bytes: Uint8Array): [number, number] | null;
|
|
92
|
+
/** The frames an image decodes into: a GIF's image descriptors, an APNG's
|
|
93
|
+
* `acTL` count, an animated WebP's `ANMF` chunks; 1 otherwise (the Rust
|
|
94
|
+
* core's `image_frames`). */
|
|
95
|
+
export declare function imageFrames(bytes: Uint8Array): number;
|
|
96
|
+
/** VAPP-103 rfix: the pixel cap on a whole image before it decodes (the
|
|
97
|
+
* Rust core's `media_image_within_limits`): a raster (PNG, JPEG, GIF, WebP,
|
|
98
|
+
* BMP) or SVG whose size cannot be read is refused, and width × height ×
|
|
99
|
+
* `imageFrames` must fit `maxPixels`. Null = within the limits, else the
|
|
100
|
+
* reason; bytes of no known image format pass (the decoder refuses them).
|
|
101
|
+
* `limits` defaults to `MEDIA_LIMITS` (a host may pass its own). */
|
|
102
|
+
export declare function mediaImageWithinLimits(bytes: Uint8Array, limits?: {
|
|
103
|
+
maxBytes: number;
|
|
104
|
+
maxPixels: number;
|
|
105
|
+
}): string | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { HostOp } from "./contract.js";
|
|
2
|
+
import type { PackageIssue, AppPackage } from "./package.js";
|
|
3
|
+
export interface HostRouterOptions {
|
|
4
|
+
/** Extension catalog ids the host registered (negotiation). */
|
|
5
|
+
extensionIds?: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
export interface SurfaceInfo {
|
|
8
|
+
surfaceId: string;
|
|
9
|
+
catalogId: string;
|
|
10
|
+
/** The package whose template created it (its function policy). */
|
|
11
|
+
packageId?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class HostRouter {
|
|
14
|
+
private extensionIds;
|
|
15
|
+
private surfaces;
|
|
16
|
+
private packages;
|
|
17
|
+
constructor(options?: HostRouterOptions);
|
|
18
|
+
get supportedCatalogIds(): string[];
|
|
19
|
+
registerExtension(id: string): void;
|
|
20
|
+
/** Install a declarative package: its templates become `applyTemplate`
|
|
21
|
+
* targets. Returns the validation issues (installed only when none). */
|
|
22
|
+
installPackage(pkg: AppPackage): PackageIssue[];
|
|
23
|
+
package(id: string): AppPackage | undefined;
|
|
24
|
+
surface(id: string): SurfaceInfo | undefined;
|
|
25
|
+
surfaceIds(): string[];
|
|
26
|
+
/** One server message → the ops to perform, in order. Never throws. */
|
|
27
|
+
route(message: unknown): HostOp[];
|
|
28
|
+
private findPackage;
|
|
29
|
+
private invalid;
|
|
30
|
+
private missing;
|
|
31
|
+
}
|
|
32
|
+
/** A2UI: an omitted path or `/` is the whole data model (`""` in JSON
|
|
33
|
+
* pointer terms, which every surface's setPointer takes). */
|
|
34
|
+
export declare function normalizePath(path: string | undefined): string;
|