@hyperfixi/types-browser 3.3.0 → 4.0.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.
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Global type augmentation for HyperFixi and LokaScript browser APIs
3
+ *
4
+ * This file augments the Window and globalThis interfaces to include
5
+ * HyperFixi and LokaScript global variables, providing IDE autocomplete and type safety.
6
+ */
7
+ import type { HyperfixiAPI } from './core-api';
8
+ import type { LokaScriptSemanticAPI } from './semantic-api';
9
+ import type { LokaScriptI18nAPI } from './i18n-api';
10
+ declare global {
11
+ /**
12
+ * Window interface augmentation
13
+ */
14
+ interface Window {
15
+ /**
16
+ * The hyperscript engine (`@hyperfixi/engine`'s public object).
17
+ *
18
+ * Loaded from: hyperfixi-hs.js (or hyperfixi.js, the same file under `@hyperfixi/core`'s name)
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * window.hyperfixi.evaluate('add .highlight to me', { me: document.body })
23
+ * window.hyperfixi.parse('on click toggle .active').errors // []
24
+ * ```
25
+ */
26
+ hyperfixi: HyperfixiAPI;
27
+ /**
28
+ * The same object as `window.hyperfixi`, under upstream `_hyperscript`'s name — set by
29
+ * hyperfixi-hs.js, and by upstream `_hyperscript` itself.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * window._hyperscript.processNode(document.body)
34
+ * ```
35
+ */
36
+ _hyperscript: HyperfixiAPI;
37
+ /**
38
+ * LokaScript Semantic - Multilingual semantic parsing (24 languages)
39
+ *
40
+ * Loaded from: lokascript-semantic.browser.global.js
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * const result = window.LokaScriptSemantic.parse('トグル .active', 'ja')
45
+ * const korean = window.LokaScriptSemantic.translate('toggle .active', 'en', 'ko')
46
+ * ```
47
+ */
48
+ LokaScriptSemantic: LokaScriptSemanticAPI;
49
+ /**
50
+ * LokaScript I18n - per-language vocabulary and word-order profiles (24 languages).
51
+ * Translation is `window.LokaScriptSemantic.translate`.
52
+ *
53
+ * Loaded from: lokascript-i18n.min.js
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * window.LokaScriptI18n.getProfile('ja')?.wordOrder // 'SOV'
58
+ * ```
59
+ */
60
+ LokaScriptI18n: LokaScriptI18nAPI;
61
+ }
62
+ /**
63
+ * globalThis interface augmentation (same as Window for browser contexts)
64
+ */
65
+ var hyperfixi: HyperfixiAPI;
66
+ var _hyperscript: HyperfixiAPI;
67
+ var LokaScriptSemantic: LokaScriptSemanticAPI;
68
+ var LokaScriptI18n: LokaScriptI18nAPI;
69
+ }
70
+ export {};
71
+ //# sourceMappingURL=globals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,CAAC,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,MAAM;QACd;;;;;;;;;;WAUG;QACH,SAAS,EAAE,YAAY,CAAC;QAExB;;;;;;;;WAQG;QACH,YAAY,EAAE,YAAY,CAAC;QAE3B;;;;;;;;;;WAUG;QACH,kBAAkB,EAAE,qBAAqB,CAAC;QAE1C;;;;;;;;;;WAUG;QACH,cAAc,EAAE,iBAAiB,CAAC;KACnC;IAED;;OAEG;IACH,IAAI,SAAS,EAAE,YAAY,CAAC;IAC5B,IAAI,YAAY,EAAE,YAAY,CAAC;IAC/B,IAAI,kBAAkB,EAAE,qBAAqB,CAAC;IAC9C,IAAI,cAAc,EAAE,iBAAiB,CAAC;CACvC;AAGD,OAAO,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -31,26 +31,26 @@
31
31
  *
32
32
  * ### Using window.hyperfixi
33
33
  * ```typescript
34
- * // window.hyperfixi is now fully typed
35
- * const result = await window.hyperfixi.execute('toggle .active')
36
- * window.evalHyperScript('toggle .active')
34
+ * // window.hyperfixi (and window._hyperscript, the same object) is fully typed
35
+ * window.hyperfixi.evaluate('toggle .active on me', { me: button })
36
+ * window.hyperfixi.parse('on click toggle .active').errors // []
37
37
  * ```
38
38
  *
39
- * ### Using window.HyperFixiSemantic
39
+ * ### Using window.LokaScriptSemantic
40
40
  * ```typescript
41
- * if (window.HyperFixiSemantic) {
42
- * const node = window.HyperFixiSemantic.parse('toggle .active', 'en')
43
- * const japanese = window.HyperFixiSemantic.translate('toggle .active', 'en', 'ja')
41
+ * if (window.LokaScriptSemantic) {
42
+ * const node = window.LokaScriptSemantic.parse('toggle .active', 'en')
43
+ * const japanese = window.LokaScriptSemantic.translate('toggle .active', 'en', 'ja')
44
44
  * }
45
45
  * ```
46
46
  *
47
47
  * ### Using Type Guards
48
48
  * ```typescript
49
- * import { isHyperFixiCoreAvailable, getHyperFixiCore } from '@hyperfixi/types-browser'
49
+ * import { getHyperFixiCore } from '@hyperfixi/types-browser'
50
50
  *
51
51
  * const hyperfixi = getHyperFixiCore()
52
52
  * if (hyperfixi) {
53
- * hyperfixi.execute('toggle .active')
53
+ * hyperfixi.evaluate('toggle .active on me', { me: button })
54
54
  * }
55
55
  * ```
56
56
  */
@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * Type guards for browser globals
3
3
  */
4
- import type { LokaScriptCoreAPI } from './core-api';
4
+ import type { HyperfixiAPI } from './core-api';
5
5
  import type { LokaScriptSemanticAPI } from './semantic-api';
6
6
  import type { LokaScriptI18nAPI } from './i18n-api';
7
7
  /**
8
- * Check if window.hyperfixi is available and properly typed
8
+ * Check that a value is the hyperscript host (`window.hyperfixi` / `window._hyperscript`):
9
+ * callable, with `evaluate` and `processNode`.
9
10
  */
10
- export declare function isHyperFixiCoreAvailable(obj?: any): obj is LokaScriptCoreAPI;
11
+ export declare function isHyperFixiCoreAvailable(obj?: any): obj is HyperfixiAPI;
11
12
  /**
12
13
  * Check if window.HyperFixiSemantic is available
13
14
  */
@@ -19,7 +20,7 @@ export declare function isHyperFixiI18nAvailable(obj?: any): obj is LokaScriptI1
19
20
  /**
20
21
  * Safe access to window.hyperfixi with type checking
21
22
  */
22
- export declare function getHyperFixiCore(): LokaScriptCoreAPI | null;
23
+ export declare function getHyperFixiCore(): HyperfixiAPI | null;
23
24
  /**
24
25
  * Safe access to window.LokaScriptSemantic with type checking
25
26
  */
@@ -1 +1 @@
1
- {"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../src/type-guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,IAAI,iBAAiB,CAO5E;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,IAAI,qBAAqB,CAOpF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,IAAI,iBAAiB,CAU5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,GAAG,IAAI,CAK3D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,qBAAqB,GAAG,IAAI,CAKnE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,GAAG,IAAI,CAK3D"}
1
+ {"version":3,"file":"type-guards.d.ts","sourceRoot":"","sources":["../src/type-guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,IAAI,YAAY,CAMvE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,IAAI,qBAAqB,CAOpF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,IAAI,iBAAiB,CAU5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,YAAY,GAAG,IAAI,CAKtD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,qBAAqB,GAAG,IAAI,CAKnE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,iBAAiB,GAAG,IAAI,CAK3D"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hyperfixi/types-browser",
3
- "version": "3.3.0",
4
- "description": "TypeScript type definitions for LokaScript browser globals",
3
+ "version": "4.0.0",
4
+ "description": "TypeScript definitions for the hyperfixi browser globals: window.hyperfixi / window._hyperscript (the engine), LokaScriptSemantic, LokaScriptI18n",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -18,7 +18,7 @@
18
18
  "scripts": {
19
19
  "build": "tsc",
20
20
  "clean": "rm -rf dist",
21
- "typecheck": "tsc --noEmit"
21
+ "typecheck": "tsc --noEmit -p tsconfig.check.json"
22
22
  },
23
23
  "keywords": [
24
24
  "hyperfixi",
@@ -30,6 +30,7 @@
30
30
  "author": "LokaScript Contributors",
31
31
  "license": "MIT",
32
32
  "devDependencies": {
33
+ "@hyperfixi/engine": "^4.0.0",
33
34
  "typescript": "^5.8.3"
34
35
  },
35
36
  "publishConfig": {
package/src/core-api.ts CHANGED
@@ -1,256 +1,150 @@
1
1
  /**
2
- * Type definitions for HyperFixi Core browser API
2
+ * Type definitions for the hyperscript host on `window.hyperfixi` and `window._hyperscript`.
3
+ *
4
+ * Both globals are one object: `@hyperfixi/engine`'s public API, which the engine's
5
+ * `hyperfixi-hs.js` installs, and which `@hyperfixi/core` ships as `hyperfixi.js` (the same
6
+ * file, since Phase C3 of the engine cutover). It is shaped like upstream `_hyperscript`'s
7
+ * public object, so upstream plugins can use it, plus one hook upstream lacks
8
+ * (`addSourceTransform`). `test/engine-api.check.ts` checks the engine's own `api` against
9
+ * this interface, so the two cannot drift apart.
10
+ *
11
+ * (Until then `hyperfixi.js` was core's own bundle, and `window.hyperfixi` had core's API:
12
+ * `compile`, `compileSync`, `execute`, `createContext`, `evalHyperScript`, … — none of which
13
+ * the engine has. Those types are gone; see `HyperfixiAPI` for what replaced each.)
3
14
  */
4
15
 
5
- /**
6
- * HyperFixi core API exposed on window.hyperfixi
7
- */
8
- export interface LokaScriptCoreAPI {
9
- // ==================== API v2 (Recommended) ====================
10
-
11
- /**
12
- * Synchronously compile hyperscript code to AST (API v2).
13
- * @since API v2
14
- */
15
- compileSync(code: string, options?: NewCompileOptions): CompileResult;
16
-
17
- /**
18
- * Asynchronously compile hyperscript code (handles all 13 languages) (API v2).
19
- * @since API v2
20
- */
21
- compile(code: string, options?: NewCompileOptions): Promise<CompileResult>;
22
-
23
- /**
24
- * Compile and execute hyperscript in one step (API v2).
25
- * @since API v2
26
- */
27
- eval(code: string, contextOrElement?: any): Promise<any>;
28
-
29
- /**
30
- * Validate hyperscript syntax and return detailed errors (API v2).
31
- * @since API v2
32
- */
33
- validate(code: string, options?: NewCompileOptions): Promise<ValidateResult>;
34
-
35
- /**
36
- * Create execution context with optional parent (unified signature, API v2).
37
- * @since API v2
38
- */
39
- createContext(element?: Element | null, parent?: any): any;
40
-
41
- // ==================== API v1 (Deprecated) ====================
42
-
43
- /**
44
- * Evaluate hyperscript string directly
45
- */
46
- evalHyperScript(code: string, element?: Element): any;
47
-
48
- /**
49
- * Async evaluation of hyperscript
50
- */
51
- evalHyperScriptAsync(code: string, element?: Element): Promise<any>;
52
-
53
- /**
54
- * Smart evaluation with automatic context detection
55
- */
56
- evalHyperScriptSmart(code: string): Promise<any>;
57
-
58
- /**
59
- * Compile multilingual hyperscript code
60
- * @deprecated Use compile() with options.language instead
61
- */
62
- compileMultilingual(code: string, language: string, options?: CompileOptions): CompilationResult;
63
-
64
- /**
65
- * Execute hyperscript code
66
- */
67
- execute(code: string, element?: Element, options?: ExecuteOptions): Promise<any>;
68
-
69
- /**
70
- * Run hyperscript code (alias for execute)
71
- * @deprecated Use eval() instead
72
- */
73
- run(code: string, element?: Element, options?: ExecuteOptions): Promise<any>;
74
-
75
- /**
76
- * Create child execution context
77
- * @deprecated Use createContext(element, parent) instead
78
- */
79
- createChildContext(parent: any, element?: Element): any;
80
-
81
- /**
82
- * Validate hyperscript syntax (returns boolean)
83
- * @deprecated Use validate() instead (returns detailed result)
84
- */
85
- isValidHyperscript(code: string): boolean;
86
-
87
- /**
88
- * Create runtime instance
89
- */
90
- createRuntime(options?: RuntimeOptions): any;
91
-
92
- /**
93
- * Process DOM node
94
- */
95
- processNode(node: Node): void;
96
-
97
- /**
98
- * Process DOM node (alias)
99
- */
100
- process(node: Node): void;
101
-
102
- /**
103
- * Tokenize hyperscript code
104
- */
105
- tokenize(code: string): any[];
106
-
107
- /**
108
- * Low-level parser access
109
- */
110
- Parser: any;
111
-
112
- /**
113
- * Low-level runtime access
114
- */
115
- Runtime: any;
16
+ /** The context `evaluate` runs its source in. Every field is optional. */
17
+ export interface HyperscriptContext {
18
+ /** What `me` / `my` / `I` refer to (default: `document.body`). */
19
+ me?: unknown;
20
+ you?: unknown;
21
+ /** `it` / `result`. */
22
+ result?: unknown;
23
+ event?: unknown;
24
+ target?: unknown;
25
+ detail?: unknown;
26
+ sender?: unknown;
27
+ body?: unknown;
28
+ /** Local variables, by name. */
29
+ locals?: Record<string, unknown>;
30
+ }
116
31
 
117
- /**
118
- * Attribute processor
119
- */
120
- attributeProcessor: any;
32
+ /** The token a parse error points at. */
33
+ export interface HyperscriptToken {
34
+ type: string;
35
+ value: string;
36
+ /** Offsets into the source. */
37
+ start: number;
38
+ end: number;
39
+ /** 1-based line, 0-based column. */
40
+ line: number;
41
+ column: number;
42
+ }
121
43
 
122
- /**
123
- * Debug utilities
124
- */
125
- debug: {
126
- enableDebugLogging(): void;
127
- disableDebugLogging(): void;
128
- };
44
+ /** A grammar error, as `parse` reports it and as the `hyperscript:parse-error` event carries it. */
45
+ export interface HyperscriptParseError {
46
+ message: string;
47
+ token: HyperscriptToken;
48
+ source: string;
49
+ /** The words the parser would have accepted, when it knows. */
50
+ expected?: string[];
51
+ /** What the author wrote, when a source transform rewrote the script before it was parsed. */
52
+ written?: string;
53
+ }
129
54
 
130
- /**
131
- * Style batcher utility
132
- */
133
- styleBatcher: any;
55
+ /** `parse`'s result: the parsed node in upstream's shape, with its `errors` (empty when it parsed). */
56
+ export interface HyperscriptParseResult {
57
+ errors: HyperscriptParseError[];
58
+ }
134
59
 
135
- /**
136
- * Object pool utility
137
- */
138
- ObjectPool: any;
60
+ /** A root `processNode` initialises: hooks receive it before and after. */
61
+ export type HyperscriptProcessRoot = Element | Document | DocumentFragment;
139
62
 
140
- /**
141
- * Semantic parsing utilities
142
- */
143
- semantic?: {
144
- parse(code: string, language: string): any;
145
- translate(code: string, fromLang: string, toLang: string): string | null;
146
- buildAST(node: any): any;
63
+ /**
64
+ * A plugin's rewrite of a script, applied as the script is read; the element keeps the text its
65
+ * author wrote. Return nothing to leave the script as it is.
66
+ */
67
+ export type HyperscriptSourceTransform = (
68
+ source: string,
69
+ element: Element
70
+ ) => string | null | undefined;
71
+
72
+ /** `config`: upstream's settings, and the table `as <Name>` conversions read. */
73
+ export interface HyperscriptConfig {
74
+ /** Attributes that hold a script (default `'_, script, data-script'`). */
75
+ attributes: string;
76
+ defaultTransition: string;
77
+ disableSelector: string;
78
+ /** The strategy `hide` / `show` / `toggle` use when none is named (`display` if unset). */
79
+ defaultHideShowStrategy?: string;
80
+ /** Extra strategies, by name. */
81
+ hideShowStrategies: Record<
82
+ string,
83
+ (op: 'hide' | 'show' | 'toggle', elt: HTMLElement, arg?: string) => void
84
+ >;
85
+ /** `fetch` throws when the response status matches one of these. */
86
+ fetchThrowsOn: RegExp[];
87
+ /** `as <Name>` conversions, by name; `dynamicResolvers` handle names with arguments. */
88
+ conversions: Record<string, (value: unknown) => unknown> & {
89
+ dynamicResolvers: ((name: string, value: unknown) => unknown)[];
147
90
  };
91
+ }
148
92
 
149
- /**
150
- * Semantic debug utilities
151
- */
152
- semanticDebug?: any;
93
+ /**
94
+ * `window.hyperfixi` / `window._hyperscript`. Callable: `hyperfixi(source, context?)` is
95
+ * `hyperfixi.evaluate(source, context?)`.
96
+ *
97
+ * Replacing core 3.x's API: `compileSync(code)` → `parse(code).errors`;
98
+ * `eval(code, element)` / `execute(code, element)` → `evaluate(code, { me: element })`;
99
+ * `processNode(node)` is unchanged; `compile(code, { language })` → load
100
+ * `@lokascript/hyperscript-adapter` beside a semantic bundle, which translates each script as
101
+ * the engine reads it.
102
+ */
103
+ export interface HyperfixiAPI {
104
+ (source: string, context?: HyperscriptContext): unknown;
153
105
 
154
106
  /**
155
- * Version string
107
+ * Run source: commands, features (installed on `document.body`) or one expression.
108
+ * Synchronous unless the source itself waits on something; then it returns a promise.
109
+ * A parse error throws.
156
110
  */
157
- version: string;
158
- }
111
+ evaluate(source: string, context?: HyperscriptContext): unknown;
159
112
 
160
- export interface CompileOptions {
161
- language?: string;
162
- strict?: boolean;
163
- [key: string]: any;
164
- }
113
+ /** Parse without running. A grammar error is reported in `errors`; a tokenizer error throws. */
114
+ parse(source: string): HyperscriptParseResult;
165
115
 
166
- export interface CompilationResult {
167
- success: boolean;
168
- code?: any;
169
- error?: Error;
170
- [key: string]: any;
171
- }
116
+ /** Initialise every scripted element under a node; elements already initialised are skipped. */
117
+ process(node: unknown): void;
172
118
 
173
- export interface ExecuteOptions {
174
- context?: any;
175
- element?: Element;
176
- [key: string]: any;
177
- }
119
+ /** Upstream's older name for `process`. */
120
+ processNode(node: unknown): void;
178
121
 
179
- export interface ContextOptions {
180
- element?: Element;
181
- globals?: Record<string, any>;
182
- [key: string]: any;
183
- }
122
+ /** Remove everything an element's script installed: listeners, observers, timers, state. */
123
+ cleanup(element: Element): void;
184
124
 
185
- export interface RuntimeOptions {
186
- [key: string]: any;
187
- }
125
+ config: HyperscriptConfig;
188
126
 
189
- export type EvalHyperScriptFunction = (code: string, element?: Element) => any;
127
+ /** `use(plugin)`: the plugin receives this object (upstream's plugin API). */
128
+ use(plugin: (hyperscript: unknown) => void): void;
190
129
 
191
- export type EvalHyperScriptAsyncFunction = (code: string, element?: Element) => Promise<any>;
130
+ addBeforeProcessHook(hook: (root: HyperscriptProcessRoot) => void): void;
192
131
 
193
- export type EvalHyperScriptSmartFunction = (code: string) => Promise<any>;
132
+ addAfterProcessHook(hook: (root: HyperscriptProcessRoot) => void): void;
194
133
 
195
- // ==================== API v2 Types ====================
134
+ /** Not in upstream: rewrite a script as it is read, leaving the attribute as written. */
135
+ addSourceTransform(transform: HyperscriptSourceTransform): void;
196
136
 
197
- /**
198
- * Compilation result (API v2)
199
- */
200
- export interface CompileResult {
201
- /** Whether compilation succeeded */
202
- ok: boolean;
203
- /** Compiled AST (only present if ok=true) */
204
- ast?: any;
205
- /** Compilation errors (only present if ok=false) */
206
- errors?: CompileError[];
207
- /** Compilation metadata */
208
- meta: {
209
- /** Parser used: semantic or traditional */
210
- parser: 'semantic' | 'traditional';
211
- /** Confidence score (0-1) if semantic parser was used */
212
- confidence?: number;
213
- /** Language code */
214
- language: string;
215
- /** Compilation time in milliseconds */
216
- timeMs: number;
217
- /** Whether direct path was taken (no fallback) */
218
- directPath?: boolean;
137
+ /** The part of upstream's `internals` that pages and tests reach for. */
138
+ internals: {
139
+ runtime: {
140
+ cleanup(element: Element): void;
141
+ processNode(node: unknown): void;
142
+ };
219
143
  };
220
- }
221
144
 
222
- /**
223
- * Compilation error (API v2)
224
- */
225
- export interface CompileError {
226
- /** Error message */
227
- message: string;
228
- /** Line number where error occurred */
229
- line: number;
230
- /** Column number where error occurred */
231
- column: number;
232
- /** Optional suggestion for fixing the error */
233
- suggestion?: string;
234
- }
235
-
236
- /**
237
- * Compilation options (API v2)
238
- */
239
- export interface NewCompileOptions {
240
- /** Language code (default: 'en') */
241
- language?: string;
242
- /** Minimum confidence for semantic parsing (0-1, default: 0.5) */
243
- confidenceThreshold?: number;
244
- /** Force traditional parser, skip semantic analysis */
245
- traditional?: boolean;
145
+ /** The engine's package version (`'dev'` when built from source without one). */
146
+ version: string;
246
147
  }
247
148
 
248
- /**
249
- * Validation result (API v2)
250
- */
251
- export interface ValidateResult {
252
- /** Whether code is valid */
253
- valid: boolean;
254
- /** Validation errors (only present if valid=false) */
255
- errors?: CompileError[];
256
- }
149
+ /** @deprecated The 3.x name; `window.hyperfixi` is a {@link HyperfixiAPI} since 4.0. */
150
+ export type LokaScriptCoreAPI = HyperfixiAPI;
@@ -5,7 +5,7 @@
5
5
  * HyperFixi and LokaScript global variables, providing IDE autocomplete and type safety.
6
6
  */
7
7
 
8
- import type { LokaScriptCoreAPI } from './core-api';
8
+ import type { HyperfixiAPI } from './core-api';
9
9
  import type { LokaScriptSemanticAPI } from './semantic-api';
10
10
  import type { LokaScriptI18nAPI } from './i18n-api';
11
11
 
@@ -15,34 +15,28 @@ declare global {
15
15
  */
16
16
  interface Window {
17
17
  /**
18
- * HyperFixi - Modern hyperscript engine with fixi/htmx integration
18
+ * The hyperscript engine (`@hyperfixi/engine`'s public object).
19
19
  *
20
- * Loaded from: hyperfixi.js or hyperfixi-hx.js
20
+ * Loaded from: hyperfixi-hs.js (or hyperfixi.js, the same file under `@hyperfixi/core`'s name)
21
21
  *
22
22
  * @example
23
23
  * ```typescript
24
- * window.hyperfixi.execute('toggle .active', document.body)
25
- * window.hyperfixi.compile('on click add .highlight')
24
+ * window.hyperfixi.evaluate('add .highlight to me', { me: document.body })
25
+ * window.hyperfixi.parse('on click toggle .active').errors // []
26
26
  * ```
27
27
  */
28
- hyperfixi: LokaScriptCoreAPI;
28
+ hyperfixi: HyperfixiAPI;
29
29
 
30
30
  /**
31
- * @deprecated Use `hyperfixi` instead. Will be removed in v3.0.0.
32
- *
33
- * Loaded from: hyperfixi.js (backward-compat alias)
34
- */
35
- lokascript: LokaScriptCoreAPI;
36
-
37
- /**
38
- * Compatibility alias for official _hyperscript API compatibility
31
+ * The same object as `window.hyperfixi`, under upstream `_hyperscript`'s name — set by
32
+ * hyperfixi-hs.js, and by upstream `_hyperscript` itself.
39
33
  *
40
34
  * @example
41
35
  * ```typescript
42
- * window._hyperscript.compile('on click toggle .active')
36
+ * window._hyperscript.processNode(document.body)
43
37
  * ```
44
38
  */
45
- _hyperscript: LokaScriptCoreAPI;
39
+ _hyperscript: HyperfixiAPI;
46
40
 
47
41
  /**
48
42
  * LokaScript Semantic - Multilingual semantic parsing (24 languages)
@@ -58,14 +52,14 @@ declare global {
58
52
  LokaScriptSemantic: LokaScriptSemanticAPI;
59
53
 
60
54
  /**
61
- * LokaScript I18n - Grammar transformation for natural language word order
55
+ * LokaScript I18n - per-language vocabulary and word-order profiles (24 languages).
56
+ * Translation is `window.LokaScriptSemantic.translate`.
62
57
  *
63
58
  * Loaded from: lokascript-i18n.min.js
64
59
  *
65
60
  * @example
66
61
  * ```typescript
67
- * const japanese = window.LokaScriptI18n.translate('on click toggle .active', 'en', 'ja')
68
- * // Result: 'クリック で .active を 切り替え' (SOV word order)
62
+ * window.LokaScriptI18n.getProfile('ja')?.wordOrder // 'SOV'
69
63
  * ```
70
64
  */
71
65
  LokaScriptI18n: LokaScriptI18nAPI;
@@ -74,9 +68,8 @@ declare global {
74
68
  /**
75
69
  * globalThis interface augmentation (same as Window for browser contexts)
76
70
  */
77
- var hyperfixi: LokaScriptCoreAPI;
78
- var lokascript: LokaScriptCoreAPI;
79
- var _hyperscript: LokaScriptCoreAPI;
71
+ var hyperfixi: HyperfixiAPI;
72
+ var _hyperscript: HyperfixiAPI;
80
73
  var LokaScriptSemantic: LokaScriptSemanticAPI;
81
74
  var LokaScriptI18n: LokaScriptI18nAPI;
82
75
  }
package/src/i18n-api.ts CHANGED
@@ -11,7 +11,7 @@ export interface LokaScriptI18nAPI {
11
11
  // The global keeps its DICTIONARIES, keyword providers, locale manager,
12
12
  // direct mappings and grammar PROFILES — everything that was not the
13
13
  // transformer. Translation is `@lokascript/semantic`'s job; in the browser
14
- // that is `hyperfixi.translate` from the multilingual bundle.
14
+ // that is `LokaScriptSemantic.translate` (every semantic browser bundle has it).
15
15
 
16
16
  /**
17
17
  * Get supported locales for grammar transformation