aktion-runtime 0.5.4 → 0.5.6
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 +206 -125
- package/dist/aktion.iife.js +106 -460
- package/dist/aktion.iife.js.map +1 -1
- package/dist/aktion.js +13612 -12644
- package/dist/aktion.js.map +1 -1
- package/dist/aktion.umd.cjs +106 -460
- package/dist/aktion.umd.cjs.map +1 -1
- package/dist/devtools.js +1367 -0
- package/dist/devtools.js.map +1 -0
- package/dist/{node/index-8OvnOYPI.js → language.js} +14789 -12298
- package/dist/language.js.map +1 -0
- package/dist/plugin.cjs +2660 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.js +2660 -0
- package/dist/plugin.js.map +1 -0
- package/dist/system_prompt.txt +200 -451
- package/dist/system_prompt_chat.txt +35 -85
- package/dist/testing.js +30190 -0
- package/dist/testing.js.map +1 -0
- package/dist/types/aktion-modules.d.ts +6 -10
- package/dist/types/compiler/index.d.ts +9 -11
- package/dist/types/compiler/linker.d.ts +11 -11
- package/dist/types/compiler/project.d.ts +45 -0
- package/dist/types/compiler/runtime.d.ts +22 -26
- package/dist/types/devtools/hook.d.ts +88 -0
- package/dist/types/devtools/index.d.ts +35 -0
- package/dist/types/devtools/panel.d.ts +109 -0
- package/dist/types/devtools/protocol.d.ts +130 -0
- package/dist/types/devtools/styles.d.ts +7 -0
- package/dist/types/element.d.ts +56 -25
- package/dist/types/index.d.ts +1 -1
- package/dist/types/language/builtins.d.ts +52 -0
- package/dist/types/language/index.d.ts +5 -2
- package/dist/types/language-api.d.ts +12 -8
- package/dist/types/library/components/helpers.d.ts +0 -5
- package/dist/types/library/components/wrappers.d.ts +1 -0
- package/dist/types/parser/types.d.ts +8 -9
- package/dist/types/plugin/index.d.ts +13 -6
- package/dist/types/renderer/renderer.d.ts +28 -0
- package/dist/types/runtime/builtins.d.ts +5 -11
- package/dist/types/runtime/effects.d.ts +16 -18
- package/dist/types/runtime/evaluator.d.ts +46 -5
- package/dist/types/runtime/http.d.ts +41 -1
- package/dist/types/runtime/index.d.ts +2 -1
- package/dist/types/runtime/router.d.ts +28 -2
- package/dist/types/runtime/toast.d.ts +45 -0
- package/dist/types/runtime/util.d.ts +11 -1
- package/dist/types/testing/index.d.ts +201 -0
- package/dist/types/theme/index.d.ts +3 -3
- package/dist/types/theme/styles.d.ts +1 -1
- package/dist/types/tooling/formatter.d.ts +7 -1
- package/dist/types/tooling/index.d.ts +6 -3
- package/dist/types/tooling/language-service.d.ts +10 -5
- package/dist/types/tooling/navigation.d.ts +91 -0
- package/dist/types/tooling/semantic-tokens.d.ts +24 -0
- package/dist/types/tooling/signature-help.d.ts +21 -0
- package/package.json +21 -19
- package/dist/node/compile-BUw0GAvN.cjs +0 -491
- package/dist/node/compile-BUw0GAvN.cjs.map +0 -1
- package/dist/node/compile-DxttTzo8.js +0 -492
- package/dist/node/compile-DxttTzo8.js.map +0 -1
- package/dist/node/compiler.cjs +0 -11
- package/dist/node/compiler.cjs.map +0 -1
- package/dist/node/compiler.js +0 -11
- package/dist/node/compiler.js.map +0 -1
- package/dist/node/index-8OvnOYPI.js.map +0 -1
- package/dist/node/index-DBgA3bHQ.cjs +0 -14069
- package/dist/node/index-DBgA3bHQ.cjs.map +0 -1
- package/dist/node/language.cjs +0 -1244
- package/dist/node/language.cjs.map +0 -1
- package/dist/node/language.js +0 -1244
- package/dist/node/language.js.map +0 -1
- package/dist/node/vite.cjs +0 -65
- package/dist/node/vite.cjs.map +0 -1
- package/dist/node/vite.js +0 -65
- package/dist/node/vite.js.map +0 -1
- package/dist/types/compiler/compile.d.ts +0 -54
- package/dist/types/compiler/emit.d.ts +0 -15
- package/dist/types/compiler/sourcemap.d.ts +0 -40
- package/dist/types/library/components/theme.d.ts +0 -2
- package/dist/types/plugin/vite.d.ts +0 -21
- package/dist/types/tooling/codemod.d.ts +0 -36
|
@@ -34,6 +34,18 @@ export type RouteListener = (detail: RouteChangeDetail) => void;
|
|
|
34
34
|
export interface RouterOptions {
|
|
35
35
|
/** Initial path when no hash is set. Defaults to `/`. */
|
|
36
36
|
defaultPath?: string;
|
|
37
|
+
/**
|
|
38
|
+
* URL strategy. `"hash"` (default) keeps everything after `#/…` and works
|
|
39
|
+
* on any static host. `"history"` uses the HTML5 History API (clean
|
|
40
|
+
* `/about` URLs) and requires the server to fall back to `index.html` for
|
|
41
|
+
* unknown paths.
|
|
42
|
+
*/
|
|
43
|
+
mode?: "hash" | "history";
|
|
44
|
+
/**
|
|
45
|
+
* Optional base path stripped from / prepended to URLs in `"history"` mode
|
|
46
|
+
* (e.g. `"/app"` when the SPA is served under a sub-directory).
|
|
47
|
+
*/
|
|
48
|
+
basePath?: string;
|
|
37
49
|
}
|
|
38
50
|
/**
|
|
39
51
|
* Normalise an arbitrary string into a clean route path.
|
|
@@ -68,15 +80,29 @@ export declare class Router {
|
|
|
68
80
|
private hashListener;
|
|
69
81
|
private listeners;
|
|
70
82
|
private readonly defaultPath;
|
|
71
|
-
|
|
72
|
-
|
|
83
|
+
private mode;
|
|
84
|
+
private basePath;
|
|
85
|
+
/** True while we're updating `window.location` ourselves — used to
|
|
86
|
+
* filter out the resulting `hashchange` / `popstate` echo. */
|
|
73
87
|
private settingHash;
|
|
74
88
|
constructor(options?: RouterOptions);
|
|
89
|
+
/**
|
|
90
|
+
* Re-configure the URL strategy before `start()` is called. The host
|
|
91
|
+
* element uses this to apply the `router-mode` / `router-base` attributes
|
|
92
|
+
* it reads at connect time. No-op once the router is already enabled.
|
|
93
|
+
*/
|
|
94
|
+
configure(options: {
|
|
95
|
+
mode?: "hash" | "history";
|
|
96
|
+
basePath?: string;
|
|
97
|
+
}): void;
|
|
98
|
+
getMode(): "hash" | "history";
|
|
75
99
|
/**
|
|
76
100
|
* Attach the `hashchange` listener and synchronise from the current URL.
|
|
77
101
|
* Safe to call multiple times — it's idempotent.
|
|
78
102
|
*/
|
|
79
103
|
start(): void;
|
|
104
|
+
/** Read the active path from `window.location` per the current mode. */
|
|
105
|
+
private readLocation;
|
|
80
106
|
/**
|
|
81
107
|
* Detach the `hashchange` listener. The current path stays as the last
|
|
82
108
|
* observed value so a follow-up `start()` resumes cleanly.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { EvaluationContext } from './evaluator.js';
|
|
2
|
+
/** A single live toast tracked by the `$toast` manager. */
|
|
3
|
+
export interface ToastItem {
|
|
4
|
+
id: string;
|
|
5
|
+
message: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
/** Visual accent, mapped onto the `Toast` component's `tone`. */
|
|
8
|
+
tone: string;
|
|
9
|
+
/** Auto-dismiss delay in ms; `0` keeps the toast until dismissed. */
|
|
10
|
+
duration: number;
|
|
11
|
+
/** ms-epoch the toast was shown — handy for ordering / debugging. */
|
|
12
|
+
createdAt: number;
|
|
13
|
+
}
|
|
14
|
+
/** Options accepted by `$toast.show(message, options)` and the shortcuts. */
|
|
15
|
+
export interface ToastOptions {
|
|
16
|
+
title?: string;
|
|
17
|
+
tone?: string;
|
|
18
|
+
duration?: number;
|
|
19
|
+
}
|
|
20
|
+
/** Imperative surface exposed as the reserved `$toast` namespace. */
|
|
21
|
+
export interface ToastManager {
|
|
22
|
+
/** Reactive list of live toasts (newest last). Treat as read-only. */
|
|
23
|
+
items: ToastItem[];
|
|
24
|
+
/** Show a toast; returns its id. `message` is coerced to a string. */
|
|
25
|
+
show: (message: unknown, options?: ToastOptions) => string;
|
|
26
|
+
/** `show` with `tone: "success"`. */
|
|
27
|
+
success: (message: unknown, options?: ToastOptions) => string;
|
|
28
|
+
/** `show` with `tone: "danger"`. */
|
|
29
|
+
error: (message: unknown, options?: ToastOptions) => string;
|
|
30
|
+
/** `show` with `tone: "info"`. */
|
|
31
|
+
info: (message: unknown, options?: ToastOptions) => string;
|
|
32
|
+
/** `show` with `tone: "warning"`. */
|
|
33
|
+
warning: (message: unknown, options?: ToastOptions) => string;
|
|
34
|
+
/** Remove a single toast by id (no-op if already gone). */
|
|
35
|
+
dismiss: (id: string) => void;
|
|
36
|
+
/** Remove every toast. */
|
|
37
|
+
clear: () => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build a context-scoped toast manager. Registers a disposer that clears any
|
|
41
|
+
* pending auto-dismiss timers when the context is torn down (replan /
|
|
42
|
+
* disconnect), so a previous program's toasts can never fire against a stale
|
|
43
|
+
* scope.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createToastManager(ctx: EvaluationContext): ToastManager;
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
* text = Util.plural(items.length, "item")
|
|
21
21
|
*
|
|
22
22
|
* Comparators for `filter` / `find` accept the operator strings
|
|
23
|
-
* `"=="`, `"!="`, `">"`, `"<"`, `">="`, `"<="`, `"contains"
|
|
23
|
+
* `"=="`, `"!="`, `">"`, `"<"`, `">="`, `"<="`, `"contains"`,
|
|
24
|
+
* `"startsWith"`, `"endsWith"`. The string operators (`contains` /
|
|
25
|
+
* `startsWith` / `endsWith`) match case-insensitively.
|
|
24
26
|
*/
|
|
25
27
|
export declare const Util: {
|
|
26
28
|
readonly count: (arr: unknown) => number;
|
|
@@ -40,6 +42,14 @@ export declare const Util: {
|
|
|
40
42
|
readonly range: (start: number, end: number, step?: number) => number[];
|
|
41
43
|
readonly repeat: <T>(value: T, n: number) => T[];
|
|
42
44
|
readonly pick: (obj: unknown, keys: unknown) => Record<string, unknown>;
|
|
45
|
+
readonly omit: (obj: unknown, keys: unknown) => Record<string, unknown>;
|
|
46
|
+
readonly chunk: (arr: unknown, size: number) => unknown[][];
|
|
47
|
+
readonly flatten: (arr: unknown, depth?: number) => unknown[];
|
|
48
|
+
readonly zip: (...arrays: unknown[]) => unknown[][];
|
|
49
|
+
readonly partition: (arr: unknown, field?: string, op?: string, value?: unknown) => [unknown[], unknown[]];
|
|
50
|
+
readonly keyBy: (arr: unknown, field?: string) => Record<string, unknown>;
|
|
51
|
+
readonly cloneDeep: <T>(value: T) => T;
|
|
52
|
+
readonly merge: (target: unknown, ...sources: unknown[]) => Record<string, unknown>;
|
|
43
53
|
/**
|
|
44
54
|
* Locale-aware number formatter. Modes: `"number"` (default),
|
|
45
55
|
* `"currency"`, `"percent"`, `"compact"`. Options object:
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { ComponentSpec } from '../library/types.js';
|
|
2
|
+
import { ThemeInput } from '../theme/index.js';
|
|
3
|
+
/** The public surface of the `<aktion-app>` element this library drives. */
|
|
4
|
+
export type AktionApp = HTMLElement & {
|
|
5
|
+
setResponse(text: string): void;
|
|
6
|
+
appendChunk(chunk: string): void;
|
|
7
|
+
serializeState(): Record<string, unknown>;
|
|
8
|
+
hydrateState(snapshot: Record<string, unknown>): void;
|
|
9
|
+
setTheme(theme: ThemeInput): void;
|
|
10
|
+
registerComponents(components: ComponentSpec[], rootName?: string): void;
|
|
11
|
+
navigate(path: string): void;
|
|
12
|
+
clear(): void;
|
|
13
|
+
route: string;
|
|
14
|
+
streaming: boolean;
|
|
15
|
+
showErrors: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** A value the fetch mock may return; normalised into a real `Response`. */
|
|
18
|
+
export type MockResult = Response | string | {
|
|
19
|
+
status?: number;
|
|
20
|
+
json?: unknown;
|
|
21
|
+
body?: BodyInit | null;
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
};
|
|
24
|
+
/** The fetch mock handler — receives the resolved URL and the `fetch` init. */
|
|
25
|
+
export type FetchHandler = (url: string, init: RequestInit & {
|
|
26
|
+
method: string;
|
|
27
|
+
}) => MockResult | Promise<MockResult>;
|
|
28
|
+
/** A request the mock fetch observed, captured for assertions. */
|
|
29
|
+
export interface CapturedRequest {
|
|
30
|
+
url: string;
|
|
31
|
+
method: string;
|
|
32
|
+
headers: Record<string, string>;
|
|
33
|
+
body: unknown;
|
|
34
|
+
}
|
|
35
|
+
export interface RenderOptions {
|
|
36
|
+
/** Theme name (`"dark"`) or a token map applied before the first render. */
|
|
37
|
+
theme?: ThemeInput;
|
|
38
|
+
/** Seed reactive `$state` before the program plans (inject props / spies). */
|
|
39
|
+
state?: Record<string, unknown>;
|
|
40
|
+
/** Host-registered custom components (TypeScript `ComponentSpec`s). */
|
|
41
|
+
components?: ComponentSpec[];
|
|
42
|
+
/** Initial hash route, e.g. `"/orders/42"`. */
|
|
43
|
+
route?: string;
|
|
44
|
+
/** Mock the global `fetch` used by `$http(...)` for the lifetime of the test. */
|
|
45
|
+
fetch?: FetchHandler;
|
|
46
|
+
/**
|
|
47
|
+
* Custom `$emit("name", ...)` event names to capture from the first render.
|
|
48
|
+
* The built-ins (`assistant-message`, `route-change`, `error`) are always
|
|
49
|
+
* captured; custom events need their name listed here (or a `screen.listen`
|
|
50
|
+
* call) BEFORE they fire, since their names aren't known in advance.
|
|
51
|
+
*/
|
|
52
|
+
captureEvents?: string[];
|
|
53
|
+
/** Mount in this element instead of `document.body`. */
|
|
54
|
+
container?: HTMLElement;
|
|
55
|
+
/** Render the in-shadow parse-error banner (off by default). */
|
|
56
|
+
showErrors?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface ComponentRenderOptions extends RenderOptions {
|
|
59
|
+
/** DSL statements injected ABOVE the `$app(expression)` line (helpers, state). */
|
|
60
|
+
setup?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface TextMatchOptions {
|
|
63
|
+
/** Exact normalised-text match (default `true`); `false` => substring. */
|
|
64
|
+
exact?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface WaitForOptions {
|
|
67
|
+
/** Give up after this many ms (default 1000). */
|
|
68
|
+
timeout?: number;
|
|
69
|
+
/** Poll interval in ms (default 20). */
|
|
70
|
+
interval?: number;
|
|
71
|
+
}
|
|
72
|
+
/** A string, regex, or predicate used to match an element's accessible text. */
|
|
73
|
+
export type Matcher = string | RegExp | ((content: string, element: Element) => boolean);
|
|
74
|
+
/**
|
|
75
|
+
* Drain the microtask queue so Aktion's state-flush → render cascade settles.
|
|
76
|
+
* Aktion schedules both state notifications and renders with `queueMicrotask`,
|
|
77
|
+
* so a handful of turns is enough for any synchronous chain (a click that
|
|
78
|
+
* writes state, which re-derives a computed atom, which re-renders).
|
|
79
|
+
*/
|
|
80
|
+
export declare function flush(times?: number): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Run `fn` (which may trigger reactive writes / handlers) and then flush —
|
|
83
|
+
* the Aktion equivalent of React's `act(...)`. Returns whatever `fn` returns.
|
|
84
|
+
*/
|
|
85
|
+
export declare function act<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
86
|
+
/**
|
|
87
|
+
* Poll `fn` until it returns a truthy / non-empty value or `timeout` elapses.
|
|
88
|
+
* Use it (or the `findBy*` queries built on it) to await async work —
|
|
89
|
+
* `$http(...)` resolutions, `setTimeout`, debounced effects.
|
|
90
|
+
*/
|
|
91
|
+
export declare function waitFor<T>(fn: () => T, opts?: WaitForOptions): Promise<T>;
|
|
92
|
+
/** A captured DOM/custom event with its `detail` payload. */
|
|
93
|
+
export interface CapturedEvent {
|
|
94
|
+
type: string;
|
|
95
|
+
detail: unknown;
|
|
96
|
+
event: Event;
|
|
97
|
+
}
|
|
98
|
+
export interface Screen {
|
|
99
|
+
/** The mounted `<aktion-app>` element. */
|
|
100
|
+
readonly container: AktionApp;
|
|
101
|
+
/** The element's shadow root (where the program renders). */
|
|
102
|
+
readonly shadowRoot: ShadowRoot;
|
|
103
|
+
/** Captured fetch requests (empty unless a `fetch` mock was supplied). */
|
|
104
|
+
readonly requests: ReadonlyArray<CapturedRequest>;
|
|
105
|
+
getByText(matcher: Matcher, options?: TextMatchOptions): HTMLElement;
|
|
106
|
+
queryByText(matcher: Matcher, options?: TextMatchOptions): HTMLElement | null;
|
|
107
|
+
getAllByText(matcher: Matcher, options?: TextMatchOptions): HTMLElement[];
|
|
108
|
+
queryAllByText(matcher: Matcher, options?: TextMatchOptions): HTMLElement[];
|
|
109
|
+
findByText(matcher: Matcher, options?: TextMatchOptions, wait?: WaitForOptions): Promise<HTMLElement>;
|
|
110
|
+
findAllByText(matcher: Matcher, options?: TextMatchOptions, wait?: WaitForOptions): Promise<HTMLElement[]>;
|
|
111
|
+
getByRole(role: string, options?: {
|
|
112
|
+
name?: Matcher;
|
|
113
|
+
}): HTMLElement;
|
|
114
|
+
queryByRole(role: string, options?: {
|
|
115
|
+
name?: Matcher;
|
|
116
|
+
}): HTMLElement | null;
|
|
117
|
+
getAllByRole(role: string, options?: {
|
|
118
|
+
name?: Matcher;
|
|
119
|
+
}): HTMLElement[];
|
|
120
|
+
findByRole(role: string, options?: {
|
|
121
|
+
name?: Matcher;
|
|
122
|
+
}, wait?: WaitForOptions): Promise<HTMLElement>;
|
|
123
|
+
getByLabelText(matcher: Matcher, options?: TextMatchOptions): HTMLElement;
|
|
124
|
+
queryByLabelText(matcher: Matcher, options?: TextMatchOptions): HTMLElement | null;
|
|
125
|
+
getByPlaceholderText(matcher: Matcher, options?: TextMatchOptions): HTMLElement;
|
|
126
|
+
queryByPlaceholderText(matcher: Matcher, options?: TextMatchOptions): HTMLElement | null;
|
|
127
|
+
getByTestId(id: string): HTMLElement;
|
|
128
|
+
queryByTestId(id: string): HTMLElement | null;
|
|
129
|
+
readonly user: UserEvent;
|
|
130
|
+
/** Click a button/link/[role=button] found by its text, or click an element. */
|
|
131
|
+
click(target: string | Element): Promise<void>;
|
|
132
|
+
/** Type into a field found by label/placeholder/role, or into an element. */
|
|
133
|
+
type(target: string | Element, text: string): Promise<void>;
|
|
134
|
+
fireEvent(el: Element, type: string, init?: EventInit): Promise<void>;
|
|
135
|
+
readonly state: StateProbe;
|
|
136
|
+
/** Await an atom until `predicate(value)` holds (or it becomes non-null). */
|
|
137
|
+
waitForState(name: string, predicate?: (value: unknown) => boolean, wait?: WaitForOptions): Promise<unknown>;
|
|
138
|
+
readonly events: ReadonlyArray<CapturedEvent>;
|
|
139
|
+
/** Start capturing a custom `$emit(...)` event type (call before the trigger). */
|
|
140
|
+
listen(type: string): void;
|
|
141
|
+
emitted(type?: string): unknown[];
|
|
142
|
+
lastEvent(type: string): unknown;
|
|
143
|
+
waitForEvent(type: string, wait?: WaitForOptions): Promise<unknown>;
|
|
144
|
+
navigate(path: string): Promise<void>;
|
|
145
|
+
readonly route: string;
|
|
146
|
+
rerender(program: string): Promise<void>;
|
|
147
|
+
appendChunk(chunk: string): Promise<void>;
|
|
148
|
+
stream(chunks: string[]): Promise<void>;
|
|
149
|
+
setStreaming(value: boolean): void;
|
|
150
|
+
setTheme(theme: ThemeInput): Promise<void>;
|
|
151
|
+
flush(times?: number): Promise<void>;
|
|
152
|
+
unmount(): void;
|
|
153
|
+
html(): string;
|
|
154
|
+
debug(el?: Element): void;
|
|
155
|
+
}
|
|
156
|
+
export interface UserEvent {
|
|
157
|
+
click(el: Element): Promise<void>;
|
|
158
|
+
type(el: Element, text: string): Promise<void>;
|
|
159
|
+
clear(el: Element): Promise<void>;
|
|
160
|
+
selectOption(select: Element, value: string): Promise<void>;
|
|
161
|
+
check(el: Element): Promise<void>;
|
|
162
|
+
uncheck(el: Element): Promise<void>;
|
|
163
|
+
keyboard(el: Element, key: string): Promise<void>;
|
|
164
|
+
hover(el: Element): Promise<void>;
|
|
165
|
+
unhover(el: Element): Promise<void>;
|
|
166
|
+
submit(form: Element): Promise<void>;
|
|
167
|
+
}
|
|
168
|
+
export interface StateProbe {
|
|
169
|
+
/** Read one atom from the live snapshot (`serializeState()[name]`). */
|
|
170
|
+
get(name: string): unknown;
|
|
171
|
+
/** Whether the atom currently exists. */
|
|
172
|
+
has(name: string): boolean;
|
|
173
|
+
/** The full reactive snapshot — ideal for `toMatchSnapshot()`. */
|
|
174
|
+
snapshot(): Record<string, unknown>;
|
|
175
|
+
/** Simulate a host-side write (`hydrateState`) and re-render. */
|
|
176
|
+
set(name: string, value: unknown): Promise<void>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Mount an Aktion program in a real `<aktion-app>` and return a `Screen`
|
|
180
|
+
* scoped to its shadow root. Renders synchronously enough that the returned
|
|
181
|
+
* screen's `getBy*` queries see the first paint; use `findBy*` / `waitFor`
|
|
182
|
+
* for anything that resolves after an effect, timer, or `$http(...)` request.
|
|
183
|
+
*/
|
|
184
|
+
export declare function render(program: string, options?: RenderOptions): Screen;
|
|
185
|
+
/**
|
|
186
|
+
* Render a single component expression in isolation — sugar over `render`
|
|
187
|
+
* that wraps the expression in `$app(...)` and lets you prepend `setup` DSL
|
|
188
|
+
* (helper functions, seed state). Capture interactions the idiomatic Aktion
|
|
189
|
+
* way (write a `$state` flag or `$emit(...)` inside an inline handler) and
|
|
190
|
+
* assert with `screen.state` / `screen.emitted`.
|
|
191
|
+
*
|
|
192
|
+
* renderComponent(`Button("Save", { onClick: () => $saved = true })`)
|
|
193
|
+
*/
|
|
194
|
+
export declare function renderComponent(expression: string, options?: ComponentRenderOptions): Screen;
|
|
195
|
+
/**
|
|
196
|
+
* Unmount every screen created since the last cleanup and restore any mocked
|
|
197
|
+
* `fetch`. Call from your runner's `afterEach` for isolated tests.
|
|
198
|
+
*/
|
|
199
|
+
export declare function cleanup(): void;
|
|
200
|
+
/** Convenience for building a JSON `MockResult` in a `fetch` handler. */
|
|
201
|
+
export declare function json(data: unknown, status?: number): MockResult;
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
* - "skyline" (deep navy + cyan, crisp & calm)
|
|
12
12
|
*
|
|
13
13
|
* Consumers can also pass a JSON object via the `theme` attribute, call
|
|
14
|
-
* `element.setTheme({...})`, or
|
|
15
|
-
* Aktion program. All three paths flow through `mergeTheme`
|
|
14
|
+
* `element.setTheme({...})`, or write a bare `$theme({...})` statement
|
|
15
|
+
* inside a Aktion program. All three paths flow through `mergeTheme`
|
|
16
16
|
* so partial token maps are layered on top of the `light` defaults.
|
|
17
17
|
*
|
|
18
18
|
* Token taxonomy:
|
|
@@ -168,7 +168,7 @@ export declare function clearTokenOverrides(host: HTMLElement, keys: ReadonlyArr
|
|
|
168
168
|
/**
|
|
169
169
|
* Filter an arbitrary object down to the keys recognised by `ThemeTokens`,
|
|
170
170
|
* stringifying primitive values along the way. Used when an Aktion program
|
|
171
|
-
*
|
|
171
|
+
* applies `$theme({...})` — the evaluator hands us
|
|
172
172
|
* a plain JS object, and we want to ignore anything that isn't a real token
|
|
173
173
|
* (LLM typo guard) before applying it.
|
|
174
174
|
*/
|