@hyperfixi/types-browser 2.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,180 @@
1
+ /**
2
+ * Type definitions for HyperFixi Semantic browser API
3
+ */
4
+ export type SupportedLanguage = 'en' | 'ja' | 'ar' | 'es' | 'ko' | 'tr' | 'zh' | 'pt' | 'fr' | 'de' | 'id' | 'qu' | 'sw';
5
+ /**
6
+ * HyperFixi semantic parser API exposed on window.HyperFixiSemantic
7
+ */
8
+ export interface LokaScriptSemanticAPI {
9
+ /**
10
+ * Parse hyperscript in any supported language to semantic representation
11
+ *
12
+ * @param code Hyperscript code to parse
13
+ * @param language Two-letter language code (en, ja, ar, es, ko, tr, zh, pt, fr, de, id, qu, sw)
14
+ * @returns Parsed semantic node or null
15
+ */
16
+ parse(code: string, language: SupportedLanguage): SemanticNode | null;
17
+ /**
18
+ * Check if hyperscript can be parsed in a language
19
+ */
20
+ canParse(code: string, language: SupportedLanguage): boolean;
21
+ /**
22
+ * Parse in any supported language (auto-detect)
23
+ */
24
+ parseAny(code: string): SemanticNode | null;
25
+ /**
26
+ * Parse explicit syntax
27
+ */
28
+ parseExplicit(code: string): any | null;
29
+ /**
30
+ * Check if code uses explicit syntax
31
+ */
32
+ isExplicitSyntax(code: string): boolean;
33
+ /**
34
+ * Translate hyperscript between languages
35
+ */
36
+ translate(code: string, fromLanguage: SupportedLanguage, toLanguage: SupportedLanguage): string | null;
37
+ /**
38
+ * Get all translations of hyperscript in supported languages
39
+ */
40
+ getAllTranslations(code: string, fromLanguage: SupportedLanguage): Record<SupportedLanguage, string>;
41
+ /**
42
+ * Round-trip translation validation
43
+ */
44
+ roundTrip(code: string, language: SupportedLanguage): boolean;
45
+ /**
46
+ * Validate translation accuracy
47
+ */
48
+ validateTranslation(original: string, translated: string, fromLang: SupportedLanguage, toLang: SupportedLanguage): boolean;
49
+ /**
50
+ * Render semantic node to hyperscript
51
+ */
52
+ render(node: SemanticNode, language: SupportedLanguage): string;
53
+ /**
54
+ * Render to explicit syntax
55
+ */
56
+ renderExplicit(node: SemanticNode): string;
57
+ /**
58
+ * Convert to explicit syntax
59
+ */
60
+ toExplicit(code: string, language: SupportedLanguage): string | null;
61
+ /**
62
+ * Convert from explicit syntax
63
+ */
64
+ fromExplicit(code: string, language: SupportedLanguage): string | null;
65
+ /**
66
+ * Create semantic analyzer
67
+ */
68
+ createSemanticAnalyzer(options?: any): any;
69
+ /**
70
+ * Check if semantic result should be used
71
+ */
72
+ shouldUseSemanticResult(semanticNode: SemanticNode | null, fallbackNode: any): boolean;
73
+ /**
74
+ * Build AST from semantic node
75
+ */
76
+ buildAST(node: SemanticNode): any;
77
+ /**
78
+ * Tokenize code in a specific language
79
+ */
80
+ tokenize(code: string, language: SupportedLanguage): any[];
81
+ /**
82
+ * Get tokenizer for a language
83
+ */
84
+ getTokenizer(language: SupportedLanguage): any;
85
+ /**
86
+ * Check if language is supported
87
+ */
88
+ isLanguageSupported(language: string): boolean;
89
+ /**
90
+ * Get list of supported language codes
91
+ */
92
+ getSupportedLanguages(): SupportedLanguage[];
93
+ /**
94
+ * Create CSS selector helper
95
+ */
96
+ createSelector(value: string): any;
97
+ /**
98
+ * Create literal value helper
99
+ */
100
+ createLiteral(value: any): any;
101
+ /**
102
+ * Create reference helper
103
+ */
104
+ createReference(name: string): any;
105
+ /**
106
+ * Create property path helper
107
+ */
108
+ createPropertyPath(path: string[]): any;
109
+ /**
110
+ * Create command node helper
111
+ */
112
+ createCommandNode(command: string, options?: any): any;
113
+ /**
114
+ * Create event handler helper
115
+ */
116
+ createEventHandler(event: string, options?: any): any;
117
+ /**
118
+ * Get command mapper
119
+ */
120
+ getCommandMapper(command: string): any;
121
+ /**
122
+ * Register command mapper
123
+ */
124
+ registerCommandMapper(command: string, mapper: any): void;
125
+ /**
126
+ * Package version
127
+ */
128
+ VERSION: string;
129
+ /**
130
+ * Default confidence threshold
131
+ */
132
+ DEFAULT_CONFIDENCE_THRESHOLD: number;
133
+ /**
134
+ * High confidence threshold
135
+ */
136
+ HIGH_CONFIDENCE_THRESHOLD: number;
137
+ /**
138
+ * Language-specific tokenizers
139
+ */
140
+ englishTokenizer: any;
141
+ japaneseTokenizer: any;
142
+ koreanTokenizer: any;
143
+ arabicTokenizer: any;
144
+ spanishTokenizer: any;
145
+ turkishTokenizer: any;
146
+ chineseTokenizer: any;
147
+ portugueseTokenizer: any;
148
+ frenchTokenizer: any;
149
+ germanTokenizer: any;
150
+ indonesianTokenizer: any;
151
+ quechuaTokenizer: any;
152
+ swahiliTokenizer: any;
153
+ /**
154
+ * Semantic analyzer implementation
155
+ */
156
+ SemanticAnalyzerImpl: any;
157
+ /**
158
+ * AST Builder class
159
+ */
160
+ ASTBuilder: any;
161
+ }
162
+ export interface SemanticNode {
163
+ action: string;
164
+ roles: Map<string, SemanticValue>;
165
+ confidence: number;
166
+ errors?: ValidationError[];
167
+ tokens?: any[];
168
+ [key: string]: any;
169
+ }
170
+ export interface SemanticValue {
171
+ value: any;
172
+ type?: string;
173
+ [key: string]: any;
174
+ }
175
+ export interface ValidationError {
176
+ message: string;
177
+ code?: string;
178
+ [key: string]: any;
179
+ }
180
+ //# sourceMappingURL=semantic-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-api.d.ts","sourceRoot":"","sources":["../src/semantic-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,iBAAiB,GACzB,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,CAAC;AAET;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,YAAY,GAAG,IAAI,CAAC;IAEtE;;OAEG;IAC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ScriptSemanticAPI } from './semantic-api';
6
+ import type { LokaScriptI18nAPI } from './i18n-api';
7
+ /**
8
+ * Check if window.hyperfixi is available and properly typed
9
+ */
10
+ export declare function isHyperFixiCoreAvailable(obj?: any): obj is LokaScriptCoreAPI;
11
+ /**
12
+ * Check if window.HyperFixiSemantic is available
13
+ */
14
+ export declare function isHyperFixiSemanticAvailable(obj?: any): obj is LokaScriptSemanticAPI;
15
+ /**
16
+ * Check if window.HyperFixiI18n is available
17
+ */
18
+ export declare function isHyperFixiI18nAvailable(obj?: any): obj is LokaScriptI18nAPI;
19
+ /**
20
+ * Safe access to window.hyperfixi with type checking
21
+ */
22
+ export declare function getHyperFixiCore(): LokaScriptCoreAPI | null;
23
+ /**
24
+ * Safe access to window.LokaScriptSemantic with type checking
25
+ */
26
+ export declare function getHyperFixiSemantic(): LokaScriptSemanticAPI | null;
27
+ /**
28
+ * Safe access to window.LokaScriptI18n with type checking
29
+ */
30
+ export declare function getHyperFixiI18n(): LokaScriptI18nAPI | null;
31
+ //# sourceMappingURL=type-guards.d.ts.map
@@ -0,0 +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,CAO5E;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"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@hyperfixi/types-browser",
3
+ "version": "2.0.0",
4
+ "description": "TypeScript type definitions for LokaScript browser globals",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist/",
15
+ "src/",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc",
20
+ "clean": "rm -rf dist",
21
+ "typecheck": "tsc --noEmit"
22
+ },
23
+ "keywords": [
24
+ "hyperfixi",
25
+ "types",
26
+ "typescript",
27
+ "browser",
28
+ "globals"
29
+ ],
30
+ "author": "LokaScript Contributors",
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "typescript": "^5.8.3"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/codetalcott/hyperfixi.git",
41
+ "directory": "packages/types-browser"
42
+ },
43
+ "bugs": {
44
+ "url": "https://github.com/codetalcott/hyperfixi/issues"
45
+ },
46
+ "homepage": "https://github.com/codetalcott/hyperfixi/tree/main/packages/types-browser#readme"
47
+ }
@@ -0,0 +1,280 @@
1
+ /**
2
+ * Type definitions for @hyperfixi/core browser global (window.hyperfixi)
3
+ */
4
+
5
+ export interface LokaScriptCoreAPI {
6
+ // ==================== API v2 (Recommended) ====================
7
+
8
+ /**
9
+ * Synchronously compile hyperscript code to AST.
10
+ * Use this for English-only code that needs synchronous compilation.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const result = hyperfixi.compileSync('toggle .active');
15
+ * if (result.ok) {
16
+ * console.log('Parser used:', result.meta.parser);
17
+ * await hyperfixi.execute(result.ast, element);
18
+ * }
19
+ * ```
20
+ *
21
+ * @since API v2
22
+ */
23
+ compileSync(source: string, options?: NewCompileOptions): CompileResult;
24
+
25
+ /**
26
+ * Asynchronously compile hyperscript code (handles all 13 languages).
27
+ * Use this for multilingual support or when async compilation is acceptable.
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * // English
32
+ * const result = await hyperfixi.compile('toggle .active');
33
+ *
34
+ * // Japanese
35
+ * const result = await hyperfixi.compile('トグル .active', { language: 'ja' });
36
+ * ```
37
+ *
38
+ * @since API v2
39
+ */
40
+ compile(source: string, options?: NewCompileOptions): Promise<CompileResult>;
41
+
42
+ /**
43
+ * Compile and execute hyperscript in one step.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * // With context
48
+ * const ctx = hyperfixi.createContext(element);
49
+ * await hyperfixi.eval('toggle .active', ctx);
50
+ *
51
+ * // With element directly
52
+ * await hyperfixi.eval('toggle .active', element);
53
+ * ```
54
+ *
55
+ * @since API v2
56
+ */
57
+ eval(source: string, contextOrElement?: ExecutionContext | Element): Promise<any>;
58
+
59
+ /**
60
+ * Validate hyperscript syntax and return detailed errors.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const result = await hyperfixi.validate('toggle .active');
65
+ * if (result.valid) {
66
+ * console.log('Valid syntax');
67
+ * } else {
68
+ * result.errors?.forEach(err => {
69
+ * console.error(`Line ${err.line}: ${err.message}`);
70
+ * });
71
+ * }
72
+ * ```
73
+ *
74
+ * @since API v2
75
+ */
76
+ validate(source: string, options?: NewCompileOptions): Promise<ValidateResult>;
77
+
78
+ /**
79
+ * Create execution context (unified signature with optional parent).
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * // Basic context
84
+ * const ctx = hyperfixi.createContext(element);
85
+ *
86
+ * // Child context
87
+ * const child = hyperfixi.createContext(element, parentContext);
88
+ * ```
89
+ *
90
+ * @since API v2
91
+ */
92
+ createContext(element?: Element | null, parent?: ExecutionContext): ExecutionContext;
93
+
94
+ // ==================== API v1 (Deprecated) ====================
95
+
96
+ /**
97
+ * Execute hyperscript on an element
98
+ */
99
+ execute(source: string, element?: Element, context?: ExecutionOptions): Promise<void>;
100
+
101
+ /**
102
+ * @deprecated Use `eval()` instead
103
+ * Run (compile and execute) hyperscript
104
+ */
105
+ run(source: string, element?: Element): Promise<void>;
106
+
107
+ /**
108
+ * @deprecated Use `eval()` instead
109
+ * Alias for run()
110
+ */
111
+ evaluate(source: string, element?: Element): Promise<void>;
112
+
113
+ /**
114
+ * Parse hyperscript to AST
115
+ */
116
+ parse(source: string): ParseResult;
117
+
118
+ /**
119
+ * Process a DOM node for hyperscript attributes
120
+ */
121
+ processNode(node: Node): void;
122
+
123
+ /**
124
+ * Process entire document for hyperscript
125
+ */
126
+ process(root?: Document | Element): void;
127
+
128
+ /**
129
+ * @deprecated Use `createContext(element, parent)` instead
130
+ * Create child execution context
131
+ */
132
+ createChildContext(parent: ExecutionContext, element?: Element): ExecutionContext;
133
+
134
+ /**
135
+ * @deprecated Use `validate()` instead
136
+ * Validate hyperscript syntax
137
+ */
138
+ isValidHyperscript(source: string): boolean;
139
+
140
+ /**
141
+ * Get HyperFixi version
142
+ */
143
+ version: string;
144
+
145
+ /**
146
+ * Create runtime instance
147
+ */
148
+ createRuntime(options?: RuntimeOptions): Runtime;
149
+ }
150
+
151
+ export interface CompileOptions {
152
+ strict?: boolean;
153
+ includeSource?: boolean;
154
+ }
155
+
156
+ export interface CompilationResult {
157
+ ast: ASTNode;
158
+ errors: ParseError[];
159
+ success: boolean;
160
+ }
161
+
162
+ export interface ParseResult {
163
+ ast: ASTNode;
164
+ tokens: Token[];
165
+ errors: ParseError[];
166
+ }
167
+
168
+ export interface ParseError {
169
+ message: string;
170
+ position: number;
171
+ line: number;
172
+ column: number;
173
+ }
174
+
175
+ export interface Token {
176
+ type: string;
177
+ value: string;
178
+ position: number;
179
+ line: number;
180
+ column: number;
181
+ }
182
+
183
+ export interface ASTNode {
184
+ type: string;
185
+ [key: string]: unknown;
186
+ }
187
+
188
+ export interface ExecutionOptions {
189
+ globals?: Record<string, unknown>;
190
+ locals?: Record<string, unknown>;
191
+ }
192
+
193
+ export interface ExecutionContext {
194
+ me: Element | null;
195
+ you?: Element | null;
196
+ it?: unknown;
197
+ result?: unknown;
198
+ locals: Map<string, unknown>;
199
+ globals: Map<string, unknown>;
200
+ target?: Element | EventTarget | null;
201
+ detail?: unknown;
202
+ }
203
+
204
+ export interface ContextOptions {
205
+ element?: Element;
206
+ globals?: Record<string, unknown>;
207
+ }
208
+
209
+ export interface RuntimeOptions {
210
+ strict?: boolean;
211
+ timeout?: number;
212
+ }
213
+
214
+ export interface Runtime {
215
+ execute(ast: ASTNode, context: ExecutionContext): Promise<void>;
216
+ processCommand(command: ASTNode, context: ExecutionContext): Promise<void>;
217
+ }
218
+
219
+ // ==================== API v2 Types ====================
220
+
221
+ /**
222
+ * Result of compilation (API v2)
223
+ */
224
+ export interface CompileResult {
225
+ /** Whether compilation succeeded */
226
+ ok: boolean;
227
+ /** Compiled AST (only present if ok=true) */
228
+ ast?: ASTNode;
229
+ /** Compilation errors (only present if ok=false) */
230
+ errors?: CompileError[];
231
+ /** Compilation metadata */
232
+ meta: {
233
+ /** Parser used: semantic or traditional */
234
+ parser: 'semantic' | 'traditional';
235
+ /** Confidence score (0-1) if semantic parser was used */
236
+ confidence?: number;
237
+ /** Language code */
238
+ language: string;
239
+ /** Compilation time in milliseconds */
240
+ timeMs: number;
241
+ /** Whether direct path was taken (no fallback) */
242
+ directPath?: boolean;
243
+ };
244
+ }
245
+
246
+ /**
247
+ * Compilation error (API v2)
248
+ */
249
+ export interface CompileError {
250
+ /** Error message */
251
+ message: string;
252
+ /** Line number where error occurred */
253
+ line: number;
254
+ /** Column number where error occurred */
255
+ column: number;
256
+ /** Optional suggestion for fixing the error */
257
+ suggestion?: string;
258
+ }
259
+
260
+ /**
261
+ * Compilation options (API v2)
262
+ */
263
+ export interface NewCompileOptions {
264
+ /** Language code (default: 'en') */
265
+ language?: string;
266
+ /** Minimum confidence for semantic parsing (0-1, default: 0.5) */
267
+ confidenceThreshold?: number;
268
+ /** Force traditional parser, skip semantic analysis */
269
+ traditional?: boolean;
270
+ }
271
+
272
+ /**
273
+ * Validation result (API v2)
274
+ */
275
+ export interface ValidateResult {
276
+ /** Whether code is valid */
277
+ valid: boolean;
278
+ /** Validation errors (only present if valid=false) */
279
+ errors?: CompileError[];
280
+ }