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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParseError } from '../parser/types.js';
|
|
1
|
+
import { ParseError, Program } from '../parser/types.js';
|
|
2
2
|
export interface FormatResult {
|
|
3
3
|
/** Canonical source. Equal to the input when parse errors occur. */
|
|
4
4
|
formatted: string;
|
|
@@ -6,3 +6,9 @@ export interface FormatResult {
|
|
|
6
6
|
errors: ParseError[];
|
|
7
7
|
}
|
|
8
8
|
export declare function formatProgram(source: string): FormatResult;
|
|
9
|
+
/**
|
|
10
|
+
* Re-emit a parsed `Program` as canonical Aktion source. Exported so the
|
|
11
|
+
* module linker can serialise a merged (multi-file → single) program back to
|
|
12
|
+
* text for `mountCompiled`'s round-trip fields (reconnect re-parse, snapshots).
|
|
13
|
+
*/
|
|
14
|
+
export declare function printProgram(program: Program): string;
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
*
|
|
12
12
|
* - `formatProgram(source)` — canonical pretty-printer.
|
|
13
13
|
* - `applyDelta(source, ops)` — structured edit protocol (§14).
|
|
14
|
-
* - `migrateV1(source)` — best-effort v1 → 0.5 codemod (Appendix A).
|
|
15
14
|
* - `inspectAST(source)` — Committed + Drafting AST snapshot.
|
|
16
15
|
* - `getDiagnostics(source, library)` — language-service diagnostics.
|
|
17
16
|
* - `getCompletions(source, position, library)` — completions.
|
|
@@ -21,9 +20,13 @@ export { formatProgram } from './formatter.js';
|
|
|
21
20
|
export type { FormatResult } from './formatter.js';
|
|
22
21
|
export { applyDelta } from './delta.js';
|
|
23
22
|
export type { DeltaOp, DeltaResult } from './delta.js';
|
|
24
|
-
export { migrateV1 } from './codemod.js';
|
|
25
|
-
export type { MigrateV1Result } from './codemod.js';
|
|
26
23
|
export { inspectAST, inspectProgram } from './inspector.js';
|
|
27
24
|
export type { InspectorBinding, InspectorView } from './inspector.js';
|
|
28
25
|
export { getDiagnostics, getCompletions, getHoverInfo, } from './language-service.js';
|
|
29
26
|
export type { Position, Diagnostic, CompletionItem, HoverInfo, } from './language-service.js';
|
|
27
|
+
export { getDefinition, getDefinitionTarget, findDeclaration, getReferences, getDocumentHighlights, getDocumentSymbols, getRenameEdits, } from './navigation.js';
|
|
28
|
+
export type { Range, TextEdit, RenameResult, DocumentSymbol, SymbolKind, DefinitionTarget, } from './navigation.js';
|
|
29
|
+
export { getSemanticTokens, semanticTokenTypes, semanticTokenModifiers, } from './semantic-tokens.js';
|
|
30
|
+
export type { SemanticToken, SemanticTokenType, SemanticTokenModifier, } from './semantic-tokens.js';
|
|
31
|
+
export { getSignatureHelp, } from './signature-help.js';
|
|
32
|
+
export type { SignatureHelp, SignatureInfo, ParameterInfo, } from './signature-help.js';
|
|
@@ -43,11 +43,16 @@ export declare function getDiagnostics(source: string, library: ComponentLibrary
|
|
|
43
43
|
* intentionally simple — the prompt + the closed schema (§16) make
|
|
44
44
|
* deep static analysis unnecessary:
|
|
45
45
|
*
|
|
46
|
-
* -
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
46
|
+
* - After `$` → the reactive-atom hint + the `$`-builtin catalog.
|
|
47
|
+
* - Inside a component call's trailing `{ … }` props object → that
|
|
48
|
+
* component's prop names, FOLLOWED BY the general list (so you can
|
|
49
|
+
* still reference components / atoms / actions in prop values).
|
|
50
|
+
* - Everywhere else (top of line, inside a `[ … ]` children array, a
|
|
51
|
+
* `( … )` argument list) → the general list: author-declared symbols,
|
|
52
|
+
* keywords, and the full component library. Components are ALWAYS
|
|
53
|
+
* offered here — a children array like `Column([ Sidebar() ])` is the
|
|
54
|
+
* most common authoring position, so suppressing components there
|
|
55
|
+
* (the old behaviour) broke the headline autocomplete.
|
|
51
56
|
*/
|
|
52
57
|
export declare function getCompletions(source: string, position: Position, library: ComponentLibrary): CompletionItem[];
|
|
53
58
|
/**
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Position } from './language-service.js';
|
|
2
|
+
export interface Range {
|
|
3
|
+
/** 1-indexed inclusive start. */
|
|
4
|
+
start: Position;
|
|
5
|
+
/** 1-indexed exclusive end (column points one past the last character). */
|
|
6
|
+
end: Position;
|
|
7
|
+
}
|
|
8
|
+
export interface TextEdit {
|
|
9
|
+
range: Range;
|
|
10
|
+
newText: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RenameResult {
|
|
13
|
+
edits: TextEdit[];
|
|
14
|
+
/** Set when the rename is rejected (the symbol cannot be renamed safely). */
|
|
15
|
+
error?: string;
|
|
16
|
+
}
|
|
17
|
+
export type SymbolKind = "component" | "action" | "hook" | "state" | "import";
|
|
18
|
+
/**
|
|
19
|
+
* Resolved go-to-definition target. Cross-file navigation lives in the host
|
|
20
|
+
* (it must read the imported file), so the service classifies the cursor:
|
|
21
|
+
*
|
|
22
|
+
* - `local` → a declaration in THIS file (`range` is set).
|
|
23
|
+
* - `import-binding` → an imported name; the host resolves `moduleSource`
|
|
24
|
+
* to a file and looks up `imported` there.
|
|
25
|
+
* - `module` → the module specifier string itself (open the file).
|
|
26
|
+
*/
|
|
27
|
+
export interface DefinitionTarget {
|
|
28
|
+
kind: "local" | "import-binding" | "module";
|
|
29
|
+
/** Set for `kind: "local"` — the declaration range in this file. */
|
|
30
|
+
range?: Range;
|
|
31
|
+
/** Set for `kind: "import-binding"` — the name as exported by the module. */
|
|
32
|
+
imported?: string;
|
|
33
|
+
/** Set for `kind: "import-binding"` — whether the binding is a `$state` atom. */
|
|
34
|
+
isState?: boolean;
|
|
35
|
+
/** Set for `import-binding` + `module` — the raw module specifier. */
|
|
36
|
+
moduleSource?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface DocumentSymbol {
|
|
39
|
+
/** Display name — includes the `$` sigil for state atoms / hooks. */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Human-readable category, e.g. `"component"`. */
|
|
42
|
+
detail: string;
|
|
43
|
+
kind: SymbolKind;
|
|
44
|
+
/** Span used for the outline row (here: the name token). */
|
|
45
|
+
range: Range;
|
|
46
|
+
/** Span the editor reveals/selects when the row is picked (the name). */
|
|
47
|
+
selectionRange: Range;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Location of the declaration for the symbol under `position`, or `null` when
|
|
51
|
+
* the cursor is not over a navigable, file-scoped symbol.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getDefinition(source: string, position: Position): Range | null;
|
|
54
|
+
/**
|
|
55
|
+
* Classify the go-to-definition target under `position`. Unlike
|
|
56
|
+
* `getDefinition` (which only ever resolves within the current file), this
|
|
57
|
+
* also recognises imported bindings and the module specifier string so a host
|
|
58
|
+
* can perform cross-file navigation. Returns `null` when there is nothing to
|
|
59
|
+
* jump to.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getDefinitionTarget(source: string, position: Position): DefinitionTarget | null;
|
|
62
|
+
/**
|
|
63
|
+
* Find the declaration of a top-level `name` in `source` (used by a host to
|
|
64
|
+
* land on an imported symbol's definition in another file). `isState`
|
|
65
|
+
* disambiguates the `$`-namespace from the identifier namespace.
|
|
66
|
+
*/
|
|
67
|
+
export declare function findDeclaration(source: string, name: string, isState: boolean): Range | null;
|
|
68
|
+
/**
|
|
69
|
+
* Every occurrence of the symbol under `position`. For a known file-scoped
|
|
70
|
+
* declaration this is precise; for an unrecognised identifier it falls back to
|
|
71
|
+
* same-name, same-kind tokens (handy as document highlights).
|
|
72
|
+
*/
|
|
73
|
+
export declare function getReferences(source: string, position: Position, options?: {
|
|
74
|
+
includeDeclaration?: boolean;
|
|
75
|
+
}): Range[];
|
|
76
|
+
/**
|
|
77
|
+
* Highlight all occurrences of the symbol under `position` (the editor paints
|
|
78
|
+
* these when the cursor rests on a name). Always includes the declaration.
|
|
79
|
+
*/
|
|
80
|
+
export declare function getDocumentHighlights(source: string, position: Position): Range[];
|
|
81
|
+
/**
|
|
82
|
+
* Rename a file-scoped symbol. Returns the edits to apply, or an `error`
|
|
83
|
+
* explaining why the rename was rejected (unknown symbol, invalid new name).
|
|
84
|
+
* `newName` may be supplied with or without the leading `$`.
|
|
85
|
+
*/
|
|
86
|
+
export declare function getRenameEdits(source: string, position: Position, newName: string): RenameResult;
|
|
87
|
+
/**
|
|
88
|
+
* The document outline: every top-level declaration (atoms, components,
|
|
89
|
+
* actions, hooks) and `import` binding, in source order.
|
|
90
|
+
*/
|
|
91
|
+
export declare function getDocumentSymbols(source: string): DocumentSymbol[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComponentLibrary } from '../library/types.js';
|
|
2
|
+
/** Token type legend (the host registers these in the same order). */
|
|
3
|
+
export declare const semanticTokenTypes: readonly ["namespace", "class", "function", "variable", "property", "keyword", "number"];
|
|
4
|
+
export type SemanticTokenType = (typeof semanticTokenTypes)[number];
|
|
5
|
+
/** Token modifier legend (a token may carry several). */
|
|
6
|
+
export declare const semanticTokenModifiers: readonly ["declaration", "defaultLibrary"];
|
|
7
|
+
export type SemanticTokenModifier = (typeof semanticTokenModifiers)[number];
|
|
8
|
+
export interface SemanticToken {
|
|
9
|
+
/** 1-indexed line. */
|
|
10
|
+
line: number;
|
|
11
|
+
/** 1-indexed column (start). */
|
|
12
|
+
column: number;
|
|
13
|
+
/** Character length of the token (includes `$` for state identifiers). */
|
|
14
|
+
length: number;
|
|
15
|
+
tokenType: SemanticTokenType;
|
|
16
|
+
tokenModifiers: SemanticTokenModifier[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Classify every meaningful token in `source`. Unknown lowercase identifiers
|
|
20
|
+
* (locals, params, bare globals) are intentionally left untagged so the
|
|
21
|
+
* TextMate layer keeps colouring them — semantic tokens only fire where we can
|
|
22
|
+
* say something the regex grammar cannot.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSemanticTokens(source: string, library?: ComponentLibrary): SemanticToken[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ComponentLibrary } from '../library/types.js';
|
|
2
|
+
import { Position } from './language-service.js';
|
|
3
|
+
export interface ParameterInfo {
|
|
4
|
+
label: string;
|
|
5
|
+
documentation?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SignatureInfo {
|
|
8
|
+
label: string;
|
|
9
|
+
documentation?: string;
|
|
10
|
+
parameters: ParameterInfo[];
|
|
11
|
+
}
|
|
12
|
+
export interface SignatureHelp {
|
|
13
|
+
signatures: SignatureInfo[];
|
|
14
|
+
activeSignature: number;
|
|
15
|
+
activeParameter: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Signature help for the call enclosing `position`, or `null` when the cursor
|
|
19
|
+
* is not inside a recognised call.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getSignatureHelp(source: string, position: Position, library?: ComponentLibrary): SignatureHelp | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aktion-runtime",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Aktion is a single web component that turns a compact, streaming-first DSL into a rich, interactive UI inside its shadow DOM. Works in React, Vue, Angular, Svelte, plain HTML — or no framework at all.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -12,20 +12,22 @@
|
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
13
|
"require": "./dist/index.cjs"
|
|
14
14
|
},
|
|
15
|
-
"./
|
|
16
|
-
"types": "./dist/types/
|
|
17
|
-
"import": "./dist/
|
|
18
|
-
"require": "./dist/node/vite.cjs"
|
|
15
|
+
"./test": {
|
|
16
|
+
"types": "./dist/types/testing/index.d.ts",
|
|
17
|
+
"import": "./dist/testing.js"
|
|
19
18
|
},
|
|
20
|
-
"./
|
|
21
|
-
"types": "./dist/types/
|
|
22
|
-
"import": "./dist/
|
|
23
|
-
"require": "./dist/node/compiler.cjs"
|
|
19
|
+
"./devtools": {
|
|
20
|
+
"types": "./dist/types/devtools/index.d.ts",
|
|
21
|
+
"import": "./dist/devtools.js"
|
|
24
22
|
},
|
|
25
23
|
"./language": {
|
|
26
24
|
"types": "./dist/types/language-api.d.ts",
|
|
27
|
-
"import": "./dist/
|
|
28
|
-
|
|
25
|
+
"import": "./dist/language.js"
|
|
26
|
+
},
|
|
27
|
+
"./vite": {
|
|
28
|
+
"types": "./dist/types/plugin/index.d.ts",
|
|
29
|
+
"import": "./dist/plugin.js",
|
|
30
|
+
"require": "./dist/plugin.cjs"
|
|
29
31
|
},
|
|
30
32
|
"./aktion-modules": {
|
|
31
33
|
"types": "./dist/types/aktion-modules.d.ts"
|
|
@@ -42,9 +44,12 @@
|
|
|
42
44
|
},
|
|
43
45
|
"scripts": {
|
|
44
46
|
"dev": "npm run build && vite",
|
|
45
|
-
"build": "tsc -p tsconfig.build.json && vite build && vite build
|
|
47
|
+
"build": "tsc -p tsconfig.build.json && vite build && vite build --config vite.testing.config.ts && vite build --config vite.devtools.config.ts && vite build --config vite.language.config.ts && vite build --config vite.plugin.config.ts && node scripts/emit-prompt.mjs && node scripts/emit-entry.mjs",
|
|
46
48
|
"build:lib": "vite build",
|
|
47
|
-
"build:
|
|
49
|
+
"build:test": "vite build --config vite.testing.config.ts",
|
|
50
|
+
"build:devtools": "vite build --config vite.devtools.config.ts",
|
|
51
|
+
"build:language": "vite build --config vite.language.config.ts",
|
|
52
|
+
"build:plugin": "vite build --config vite.plugin.config.ts",
|
|
48
53
|
"build:prompt": "node scripts/emit-prompt.mjs",
|
|
49
54
|
"build:entry": "node scripts/emit-entry.mjs",
|
|
50
55
|
"build:docs": "node scripts/build-docs.mjs",
|
|
@@ -53,9 +58,6 @@
|
|
|
53
58
|
"test:watch": "vitest",
|
|
54
59
|
"prepublishOnly": "npm run build"
|
|
55
60
|
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"magic-string": "^0.30.0"
|
|
58
|
-
},
|
|
59
61
|
"peerDependencies": {
|
|
60
62
|
"vite": "^5.0.0 || ^6.0.0"
|
|
61
63
|
},
|
|
@@ -66,12 +68,12 @@
|
|
|
66
68
|
},
|
|
67
69
|
"devDependencies": {
|
|
68
70
|
"@types/node": "^20.19.41",
|
|
69
|
-
"@vitest/web-worker": "^2.1.4",
|
|
70
|
-
"happy-dom": "^15.7.4",
|
|
71
71
|
"typescript": "^5.6.3",
|
|
72
72
|
"vite": "^5.4.10",
|
|
73
73
|
"vite-plugin-dts": "^4.3.0",
|
|
74
|
-
"vitest": "^2.1.4"
|
|
74
|
+
"vitest": "^2.1.4",
|
|
75
|
+
"@vitest/web-worker": "^2.1.4",
|
|
76
|
+
"happy-dom": "^15.7.4"
|
|
75
77
|
},
|
|
76
78
|
"keywords": [
|
|
77
79
|
"llm",
|