aktion-runtime 0.5.10 → 0.5.11
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 +20 -10
- package/dist/aktion.iife.js +113 -136
- package/dist/aktion.iife.js.map +1 -1
- package/dist/aktion.js +4087 -3959
- package/dist/aktion.js.map +1 -1
- package/dist/aktion.umd.cjs +113 -136
- package/dist/aktion.umd.cjs.map +1 -1
- package/dist/language.js +1938 -1662
- package/dist/language.js.map +1 -1
- package/dist/system_prompt.txt +28 -26
- package/dist/system_prompt_chat.txt +11 -11
- package/dist/testing.js +358 -197
- package/dist/testing.js.map +1 -1
- package/dist/types/library/types.d.ts +50 -0
- package/dist/types/library/utils.d.ts +28 -0
- package/dist/types/library/validate.d.ts +2 -2
- package/dist/types/runtime/evaluator.d.ts +8 -0
- package/dist/types/theme/index.d.ts +3 -0
- package/dist/types/theme/styles.d.ts +1 -1
- package/dist/types/tooling/signature-help.d.ts +35 -0
- package/package.json +1 -1
|
@@ -61,6 +61,56 @@ export declare function findPositionalProp(spec: ComponentSpec): PropSpec | unde
|
|
|
61
61
|
* library never ships a contradictory spec.
|
|
62
62
|
*/
|
|
63
63
|
export declare function assertOnePositionalMax(specs: ReadonlyArray<ComponentSpec>): void;
|
|
64
|
+
/**
|
|
65
|
+
* Minimal shape of one call argument for binding decisions: `objectKeys`
|
|
66
|
+
* is the list of non-spread literal keys when the argument is an object
|
|
67
|
+
* literal, `null` for every other expression kind.
|
|
68
|
+
*/
|
|
69
|
+
export interface CallArgShape {
|
|
70
|
+
objectKeys: ReadonlyArray<string> | null;
|
|
71
|
+
}
|
|
72
|
+
/** True when a prop's declared type can accept a plain-object payload. */
|
|
73
|
+
export declare function propExpectsObject(prop: PropSpec): boolean;
|
|
74
|
+
/** Prop names + aliases (the names a named-props object may use), plus `key`. */
|
|
75
|
+
export declare function knownPropNames(spec: ComponentSpec): Set<string>;
|
|
76
|
+
/**
|
|
77
|
+
* The slot the `n`-th (0-based) positional argument binds to, mirroring the
|
|
78
|
+
* runtime: positional #0 → the `positional: true` slot (or slot 0), every
|
|
79
|
+
* later positional → the next unfilled slot in declaration order. `null`
|
|
80
|
+
* when the call has more positionals than the spec has props.
|
|
81
|
+
*/
|
|
82
|
+
export declare function slotForNthPositional(spec: ComponentSpec, n: number): PropSpec | null;
|
|
83
|
+
/**
|
|
84
|
+
* Decide which argument of a library-component call is the named-props
|
|
85
|
+
* object. Returns the argument index, or `-1` when every argument is
|
|
86
|
+
* positional. The rules, in order:
|
|
87
|
+
*
|
|
88
|
+
* 1. Single object argument, one-prop component → the object is the
|
|
89
|
+
* prop's payload when that prop accepts an object; otherwise it is
|
|
90
|
+
* named props exactly when all keys are known prop names.
|
|
91
|
+
* 2. Single object argument, multi-prop component → named props when all
|
|
92
|
+
* keys are known; a payload for an object-typed positional slot when
|
|
93
|
+
* none are; otherwise assume named props so validation can flag the
|
|
94
|
+
* unknown keys.
|
|
95
|
+
* 3. Multiple arguments — the LAST object literal is the candidate:
|
|
96
|
+
* in trailing position it is the named-props object (the canonical
|
|
97
|
+
* form) unless none of its keys are known and the slot it would fill
|
|
98
|
+
* expects an object; in leading/middle position (legacy
|
|
99
|
+
* `Grid({cols: 12}, [...])`) it is named props only when at least one
|
|
100
|
+
* key is a known prop name.
|
|
101
|
+
*
|
|
102
|
+
* A single object is never split between roles — it is wholly named props
|
|
103
|
+
* or wholly a positional payload.
|
|
104
|
+
*/
|
|
105
|
+
export declare function chooseNamedBagIndex(args: ReadonlyArray<CallArgShape>, spec: ComponentSpec): number;
|
|
106
|
+
/** Build `CallArgShape`s from AST call arguments (parser `Expression`s). */
|
|
107
|
+
export declare function callArgShapes(args: ReadonlyArray<{
|
|
108
|
+
kind: string;
|
|
109
|
+
properties?: ReadonlyArray<{
|
|
110
|
+
spread?: unknown;
|
|
111
|
+
key: string;
|
|
112
|
+
}>;
|
|
113
|
+
}>): CallArgShape[];
|
|
64
114
|
/**
|
|
65
115
|
* Stable, component-local state slot. Returned by
|
|
66
116
|
* `RenderHelpers.useInstanceState`. Keep the reference for the lifetime of
|
|
@@ -6,6 +6,34 @@ export declare function asArray<T>(value: unknown): T[];
|
|
|
6
6
|
export declare function asString(value: unknown, fallback?: string): string;
|
|
7
7
|
export declare function asBoolean(value: unknown, fallback?: boolean): boolean;
|
|
8
8
|
export declare function asNumber(value: unknown, fallback?: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Canonical t-shirt spacing scale shared by every `gap`/`padding`/`margin`/
|
|
11
|
+
* spacing-ish prop. `none` always resolves to `0`. Ordered smallest → largest
|
|
12
|
+
* so the list reads naturally in docs and error messages.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SPACING_TOKENS: readonly ["none", "3xs", "2xs", "xs", "sm", "md", "lg", "xl", "2xl", "3xl"];
|
|
15
|
+
export type SpacingToken = typeof SPACING_TOKENS[number];
|
|
16
|
+
/**
|
|
17
|
+
* Legacy t-shirt spellings still accepted at runtime and in validation but no
|
|
18
|
+
* longer advertised in prop enums: the early single-letter spacing dialect
|
|
19
|
+
* (`s`/`m`/`l`) and the verbose Button sizes (`small`/`normal`/`large`).
|
|
20
|
+
*/
|
|
21
|
+
export declare const LEGACY_SIZE_TOKEN_ALIASES: Record<string, string>;
|
|
22
|
+
/** Map a size token to its canonical spelling (`m` → `md`); other values pass through. */
|
|
23
|
+
export declare function canonicalSizeToken(value: unknown): string;
|
|
24
|
+
/**
|
|
25
|
+
* Normalise a spacing prop value to a canonical {@link SPACING_TOKENS} entry.
|
|
26
|
+
* Legacy aliases canonicalise first; anything outside the scale returns
|
|
27
|
+
* `fallback` so callers can keep their historical defaults.
|
|
28
|
+
*/
|
|
29
|
+
export declare function normalizeSpacingToken(value: unknown, fallback?: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve a spacing token (canonical or legacy) to its CSS value: `none` → `0`,
|
|
32
|
+
* everything else → the matching `var(--rui-spacing-*)`. The stylesheet keeps
|
|
33
|
+
* the historical short variable names for `sm`/`md`/`lg` (`--rui-spacing-s/m/l`)
|
|
34
|
+
* so existing theme overrides keep working. Unknown tokens return "".
|
|
35
|
+
*/
|
|
36
|
+
export declare function spacingCssValue(value: unknown): string;
|
|
9
37
|
/**
|
|
10
38
|
* Breakpoint keys honoured by responsive prop maps (Grid columns, Stack
|
|
11
39
|
* direction, etc.). Ordered from narrow → wide so CSS only needs to chain
|
|
@@ -21,7 +21,7 @@ export declare function validateProgram(source: string, library: ComponentLibrar
|
|
|
21
21
|
*
|
|
22
22
|
* - produces a parser-level migration error at parse time, or
|
|
23
23
|
* - produces a schema-validator error here when library knowledge is
|
|
24
|
-
* required (
|
|
25
|
-
* legacy Theme tokens, …).
|
|
24
|
+
* required (positional arity overflows, unknown props, enum
|
|
25
|
+
* mismatches, built-in-name collisions, legacy Theme tokens, …).
|
|
26
26
|
*/
|
|
27
27
|
export declare function validateProgramSchema(program: Program, library: ComponentLibrary): ParseError[];
|
|
@@ -282,6 +282,14 @@ export interface EvaluationContext {
|
|
|
282
282
|
library?: ComponentLibrary;
|
|
283
283
|
/** Component declarations (`function Foo() { return ... }` — PascalCase). */
|
|
284
284
|
componentDecls: Map<string, ComponentDeclaration>;
|
|
285
|
+
/**
|
|
286
|
+
* Names of user component declarations whose bodies are currently being
|
|
287
|
+
* evaluated (innermost last). Inside its own body, a declaration that
|
|
288
|
+
* shadows a library component resolves back to the BUILT-IN, so the
|
|
289
|
+
* wrapper pattern (`function Button(...) { return Button(...) }`) renders
|
|
290
|
+
* the library Button instead of recursing to the depth limit.
|
|
291
|
+
*/
|
|
292
|
+
activeComponentDecls: string[];
|
|
285
293
|
/** Effect declarations (`effect(() => { ... }, [deps])`), keyed by auto-generated name. */
|
|
286
294
|
effectDecls: Map<string, EffectDeclaration>;
|
|
287
295
|
/**
|
|
@@ -84,6 +84,9 @@ export interface ThemeTokens {
|
|
|
84
84
|
shadowSm: string;
|
|
85
85
|
shadowMd: string;
|
|
86
86
|
shadowLg: string;
|
|
87
|
+
/** Hairline spacing steps below `xs` (optional; default 1px / 2px). */
|
|
88
|
+
spacing3xs?: string;
|
|
89
|
+
spacing2xs?: string;
|
|
87
90
|
spacingXs: string;
|
|
88
91
|
spacingS: string;
|
|
89
92
|
spacingM: string;
|