@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.
- package/README.md +90 -0
- package/dist/core-api.d.ts +217 -0
- package/dist/core-api.d.ts.map +1 -0
- package/dist/i18n-api.d.ts +170 -0
- package/dist/i18n-api.d.ts.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/semantic-api.d.ts +180 -0
- package/dist/semantic-api.d.ts.map +1 -0
- package/dist/type-guards.d.ts +31 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/package.json +47 -0
- package/src/core-api.d.ts +280 -0
- package/src/core-api.ts +261 -0
- package/src/globals.d.ts +85 -0
- package/src/i18n-api.d.ts +57 -0
- package/src/i18n-api.ts +209 -0
- package/src/index.d.ts +28 -0
- package/src/index.ts +62 -0
- package/src/semantic-api.d.ts +74 -0
- package/src/semantic-api.ts +242 -0
- package/src/type-guards.ts +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @lokascript/types-browser
|
|
2
|
+
|
|
3
|
+
TypeScript type definitions for LokaScript browser globals.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev @lokascript/types-browser
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Add to your `tsconfig.json`:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"compilerOptions": {
|
|
18
|
+
"types": ["@lokascript/types-browser"]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Now you get full TypeScript autocomplete for browser globals:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
// Full IDE autocomplete and type safety!
|
|
27
|
+
window.lokascript.execute('toggle .active', document.body);
|
|
28
|
+
window._hyperscript.compile('on click add .highlight');
|
|
29
|
+
|
|
30
|
+
window.LokaScriptSemantic.parse('トグル .active', 'ja');
|
|
31
|
+
window.LokaScriptSemantic.translate('toggle .active', 'en', 'ko');
|
|
32
|
+
|
|
33
|
+
window.LokaScriptI18n.translate('on click toggle .active', 'en', 'ja');
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Provided Types
|
|
37
|
+
|
|
38
|
+
### window.lokascript / window.\_hyperscript
|
|
39
|
+
|
|
40
|
+
Core LokaScript API (from `lokascript-browser.js` or `lokascript-multilingual.js`):
|
|
41
|
+
|
|
42
|
+
- `compile(source, options?)` - Compile hyperscript to AST
|
|
43
|
+
- `execute(source, element?, context?)` - Execute hyperscript
|
|
44
|
+
- `parse(source)` - Parse to AST
|
|
45
|
+
- `processNode(node)` - Process single DOM node
|
|
46
|
+
- `process(root?)` - Process entire document
|
|
47
|
+
- `createContext(element?, options?)` - Create execution context
|
|
48
|
+
- `isValidHyperscript(source)` - Validate syntax
|
|
49
|
+
- `version` - Get version string
|
|
50
|
+
- `createRuntime(options?)` - Create runtime instance
|
|
51
|
+
|
|
52
|
+
### window.LokaScriptSemantic
|
|
53
|
+
|
|
54
|
+
Semantic parsing API (from `lokascript-semantic.browser.global.js`):
|
|
55
|
+
|
|
56
|
+
- `parse(source, language)` - Parse in any of 13 languages
|
|
57
|
+
- `translate(source, fromLang, toLang)` - Translate between languages
|
|
58
|
+
- `getAllTranslations(source, sourceLang)` - Get all translations
|
|
59
|
+
- `createSemanticAnalyzer(options?)` - Create analyzer
|
|
60
|
+
- `supportedLanguages` - Array of supported language codes
|
|
61
|
+
|
|
62
|
+
### window.LokaScriptI18n
|
|
63
|
+
|
|
64
|
+
Grammar transformation API (from `lokascript-i18n.min.js`):
|
|
65
|
+
|
|
66
|
+
- `translate(source, fromLang, toLang)` - Transform with grammar rules
|
|
67
|
+
- `createTransformer(options?)` - Create transformer instance
|
|
68
|
+
- `supportedLocales` - Array of supported locales
|
|
69
|
+
- `getProfile(locale)` - Get language grammar profile
|
|
70
|
+
|
|
71
|
+
## Browser Bundle Loading
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<!-- Load LokaScript browser bundles -->
|
|
75
|
+
<script src="https://cdn.jsdelivr.net/npm/@lokascript/core/dist/lokascript-browser.js"></script>
|
|
76
|
+
<script src="https://cdn.jsdelivr.net/npm/@lokascript/semantic/dist/lokascript-semantic.browser.global.js"></script>
|
|
77
|
+
<script src="https://cdn.jsdelivr.net/npm/@lokascript/i18n/dist/lokascript-i18n.min.js"></script>
|
|
78
|
+
|
|
79
|
+
<!-- Now use with full TypeScript support -->
|
|
80
|
+
<script>
|
|
81
|
+
// TypeScript knows about these globals!
|
|
82
|
+
window.lokascript.execute('toggle .active');
|
|
83
|
+
window.LokaScriptSemantic.parse('トグル .active', 'ja');
|
|
84
|
+
window.LokaScriptI18n.translate('toggle .active', 'en', 'ja');
|
|
85
|
+
</script>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for HyperFixi Core browser API
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* HyperFixi core API exposed on window.hyperfixi
|
|
6
|
+
*/
|
|
7
|
+
export interface LokaScriptCoreAPI {
|
|
8
|
+
/**
|
|
9
|
+
* Synchronously compile hyperscript code to AST (API v2).
|
|
10
|
+
* @since API v2
|
|
11
|
+
*/
|
|
12
|
+
compileSync(code: string, options?: NewCompileOptions): CompileResult;
|
|
13
|
+
/**
|
|
14
|
+
* Asynchronously compile hyperscript code (handles all 13 languages) (API v2).
|
|
15
|
+
* @since API v2
|
|
16
|
+
*/
|
|
17
|
+
compile(code: string, options?: NewCompileOptions): Promise<CompileResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Compile and execute hyperscript in one step (API v2).
|
|
20
|
+
* @since API v2
|
|
21
|
+
*/
|
|
22
|
+
eval(code: string, contextOrElement?: any): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Validate hyperscript syntax and return detailed errors (API v2).
|
|
25
|
+
* @since API v2
|
|
26
|
+
*/
|
|
27
|
+
validate(code: string, options?: NewCompileOptions): Promise<ValidateResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Create execution context with optional parent (unified signature, API v2).
|
|
30
|
+
* @since API v2
|
|
31
|
+
*/
|
|
32
|
+
createContext(element?: Element | null, parent?: any): any;
|
|
33
|
+
/**
|
|
34
|
+
* Evaluate hyperscript string directly
|
|
35
|
+
*/
|
|
36
|
+
evalHyperScript(code: string, element?: Element): any;
|
|
37
|
+
/**
|
|
38
|
+
* Async evaluation of hyperscript
|
|
39
|
+
*/
|
|
40
|
+
evalHyperScriptAsync(code: string, element?: Element): Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Smart evaluation with automatic context detection
|
|
43
|
+
*/
|
|
44
|
+
evalHyperScriptSmart(code: string): Promise<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Compile multilingual hyperscript code
|
|
47
|
+
* @deprecated Use compile() with options.language instead
|
|
48
|
+
*/
|
|
49
|
+
compileMultilingual(code: string, language: string, options?: CompileOptions): CompilationResult;
|
|
50
|
+
/**
|
|
51
|
+
* Execute hyperscript code
|
|
52
|
+
*/
|
|
53
|
+
execute(code: string, element?: Element, options?: ExecuteOptions): Promise<any>;
|
|
54
|
+
/**
|
|
55
|
+
* Run hyperscript code (alias for execute)
|
|
56
|
+
* @deprecated Use eval() instead
|
|
57
|
+
*/
|
|
58
|
+
run(code: string, element?: Element, options?: ExecuteOptions): Promise<any>;
|
|
59
|
+
/**
|
|
60
|
+
* Create child execution context
|
|
61
|
+
* @deprecated Use createContext(element, parent) instead
|
|
62
|
+
*/
|
|
63
|
+
createChildContext(parent: any, element?: Element): any;
|
|
64
|
+
/**
|
|
65
|
+
* Validate hyperscript syntax (returns boolean)
|
|
66
|
+
* @deprecated Use validate() instead (returns detailed result)
|
|
67
|
+
*/
|
|
68
|
+
isValidHyperscript(code: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Create runtime instance
|
|
71
|
+
*/
|
|
72
|
+
createRuntime(options?: RuntimeOptions): any;
|
|
73
|
+
/**
|
|
74
|
+
* Process DOM node
|
|
75
|
+
*/
|
|
76
|
+
processNode(node: Node): void;
|
|
77
|
+
/**
|
|
78
|
+
* Process DOM node (alias)
|
|
79
|
+
*/
|
|
80
|
+
process(node: Node): void;
|
|
81
|
+
/**
|
|
82
|
+
* Tokenize hyperscript code
|
|
83
|
+
*/
|
|
84
|
+
tokenize(code: string): any[];
|
|
85
|
+
/**
|
|
86
|
+
* Low-level parser access
|
|
87
|
+
*/
|
|
88
|
+
Parser: any;
|
|
89
|
+
/**
|
|
90
|
+
* Low-level runtime access
|
|
91
|
+
*/
|
|
92
|
+
Runtime: any;
|
|
93
|
+
/**
|
|
94
|
+
* Attribute processor
|
|
95
|
+
*/
|
|
96
|
+
attributeProcessor: any;
|
|
97
|
+
/**
|
|
98
|
+
* Tailwind extension
|
|
99
|
+
*/
|
|
100
|
+
tailwindExtension: any;
|
|
101
|
+
/**
|
|
102
|
+
* Debug utilities
|
|
103
|
+
*/
|
|
104
|
+
debug: {
|
|
105
|
+
enableDebugLogging(): void;
|
|
106
|
+
disableDebugLogging(): void;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Style batcher utility
|
|
110
|
+
*/
|
|
111
|
+
styleBatcher: any;
|
|
112
|
+
/**
|
|
113
|
+
* Object pool utility
|
|
114
|
+
*/
|
|
115
|
+
ObjectPool: any;
|
|
116
|
+
/**
|
|
117
|
+
* Semantic parsing utilities
|
|
118
|
+
*/
|
|
119
|
+
semantic?: {
|
|
120
|
+
parse(code: string, language: string): any;
|
|
121
|
+
translate(code: string, fromLang: string, toLang: string): string | null;
|
|
122
|
+
buildAST(node: any): any;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Semantic debug utilities
|
|
126
|
+
*/
|
|
127
|
+
semanticDebug?: any;
|
|
128
|
+
/**
|
|
129
|
+
* Version string
|
|
130
|
+
*/
|
|
131
|
+
version: string;
|
|
132
|
+
}
|
|
133
|
+
export interface CompileOptions {
|
|
134
|
+
language?: string;
|
|
135
|
+
strict?: boolean;
|
|
136
|
+
[key: string]: any;
|
|
137
|
+
}
|
|
138
|
+
export interface CompilationResult {
|
|
139
|
+
success: boolean;
|
|
140
|
+
code?: any;
|
|
141
|
+
error?: Error;
|
|
142
|
+
[key: string]: any;
|
|
143
|
+
}
|
|
144
|
+
export interface ExecuteOptions {
|
|
145
|
+
context?: any;
|
|
146
|
+
element?: Element;
|
|
147
|
+
[key: string]: any;
|
|
148
|
+
}
|
|
149
|
+
export interface ContextOptions {
|
|
150
|
+
element?: Element;
|
|
151
|
+
globals?: Record<string, any>;
|
|
152
|
+
[key: string]: any;
|
|
153
|
+
}
|
|
154
|
+
export interface RuntimeOptions {
|
|
155
|
+
[key: string]: any;
|
|
156
|
+
}
|
|
157
|
+
export type EvalHyperScriptFunction = (code: string, element?: Element) => any;
|
|
158
|
+
export type EvalHyperScriptAsyncFunction = (code: string, element?: Element) => Promise<any>;
|
|
159
|
+
export type EvalHyperScriptSmartFunction = (code: string) => Promise<any>;
|
|
160
|
+
/**
|
|
161
|
+
* Compilation result (API v2)
|
|
162
|
+
*/
|
|
163
|
+
export interface CompileResult {
|
|
164
|
+
/** Whether compilation succeeded */
|
|
165
|
+
ok: boolean;
|
|
166
|
+
/** Compiled AST (only present if ok=true) */
|
|
167
|
+
ast?: any;
|
|
168
|
+
/** Compilation errors (only present if ok=false) */
|
|
169
|
+
errors?: CompileError[];
|
|
170
|
+
/** Compilation metadata */
|
|
171
|
+
meta: {
|
|
172
|
+
/** Parser used: semantic or traditional */
|
|
173
|
+
parser: 'semantic' | 'traditional';
|
|
174
|
+
/** Confidence score (0-1) if semantic parser was used */
|
|
175
|
+
confidence?: number;
|
|
176
|
+
/** Language code */
|
|
177
|
+
language: string;
|
|
178
|
+
/** Compilation time in milliseconds */
|
|
179
|
+
timeMs: number;
|
|
180
|
+
/** Whether direct path was taken (no fallback) */
|
|
181
|
+
directPath?: boolean;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Compilation error (API v2)
|
|
186
|
+
*/
|
|
187
|
+
export interface CompileError {
|
|
188
|
+
/** Error message */
|
|
189
|
+
message: string;
|
|
190
|
+
/** Line number where error occurred */
|
|
191
|
+
line: number;
|
|
192
|
+
/** Column number where error occurred */
|
|
193
|
+
column: number;
|
|
194
|
+
/** Optional suggestion for fixing the error */
|
|
195
|
+
suggestion?: string;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Compilation options (API v2)
|
|
199
|
+
*/
|
|
200
|
+
export interface NewCompileOptions {
|
|
201
|
+
/** Language code (default: 'en') */
|
|
202
|
+
language?: string;
|
|
203
|
+
/** Minimum confidence for semantic parsing (0-1, default: 0.5) */
|
|
204
|
+
confidenceThreshold?: number;
|
|
205
|
+
/** Force traditional parser, skip semantic analysis */
|
|
206
|
+
traditional?: boolean;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Validation result (API v2)
|
|
210
|
+
*/
|
|
211
|
+
export interface ValidateResult {
|
|
212
|
+
/** Whether code is valid */
|
|
213
|
+
valid: boolean;
|
|
214
|
+
/** Validation errors (only present if valid=false) */
|
|
215
|
+
errors?: CompileError[];
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=core-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-api.d.ts","sourceRoot":"","sources":["../src/core-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAGhC;;;OAGG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,aAAa,CAAC;IAEtE;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MA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AU,GAAG,aAAa,CAAC;QACnC,yDAAyD;QACzD,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,oBAAoB;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,uCAAuC;QACvC,MAAM,EAAE,MAAM,CAAC;QACf,kDAAkD;QAClD,UAAU,CAAC,EAAE,OAAO,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,uDAAuD;IACvD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,4BAA4B;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,sDAAsD;IACtD,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for HyperFixi i18n/Grammar transformation browser API
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* HyperFixi i18n/Grammar transformation API on window.HyperFixiI18n
|
|
6
|
+
*/
|
|
7
|
+
export interface LokaScriptI18nAPI {
|
|
8
|
+
/**
|
|
9
|
+
* Transform hyperscript statement from one language word order to another
|
|
10
|
+
*
|
|
11
|
+
* @param statement Parsed hyperscript statement
|
|
12
|
+
* @param fromLocale Source language locale (e.g., 'en')
|
|
13
|
+
* @param toLocale Target language locale (e.g., 'ja')
|
|
14
|
+
* @returns Transformed statement or null
|
|
15
|
+
*/
|
|
16
|
+
translate(statement: HyperscriptStatement, fromLocale: string, toLocale: string): HyperscriptStatement | null;
|
|
17
|
+
/**
|
|
18
|
+
* Transform code from English to target locale
|
|
19
|
+
*/
|
|
20
|
+
toLocale(code: string, toLocale: string): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Transform code from any locale to English
|
|
23
|
+
*/
|
|
24
|
+
toEnglish(code: string, fromLocale: string): string | null;
|
|
25
|
+
/**
|
|
26
|
+
* Parse hyperscript statement
|
|
27
|
+
*/
|
|
28
|
+
parseStatement(code: string): HyperscriptStatement | null;
|
|
29
|
+
/**
|
|
30
|
+
* Get supported locales for grammar transformation
|
|
31
|
+
*/
|
|
32
|
+
getSupportedLocales(): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Check if transformation is supported between two locales
|
|
35
|
+
*/
|
|
36
|
+
supportsTransform(fromLocale: string, toLocale: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get language profile information
|
|
39
|
+
*/
|
|
40
|
+
getProfile(locale: string): LanguageProfile | null;
|
|
41
|
+
/**
|
|
42
|
+
* Reorder semantic roles based on language word order
|
|
43
|
+
*/
|
|
44
|
+
reorderRoles(roles: Record<string, any>, fromProfile: LanguageProfile, toProfile: LanguageProfile): Record<string, any>;
|
|
45
|
+
/**
|
|
46
|
+
* Insert grammatical markers
|
|
47
|
+
*/
|
|
48
|
+
insertMarkers(tokens: string[], role: string, profile: LanguageProfile): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Join tokens with language-specific rules
|
|
51
|
+
*/
|
|
52
|
+
joinTokens(tokens: string[], profile: LanguageProfile): string;
|
|
53
|
+
/**
|
|
54
|
+
* Transform statement between locales
|
|
55
|
+
*/
|
|
56
|
+
transformStatement(statement: HyperscriptStatement, fromProfile: LanguageProfile, toProfile: LanguageProfile): HyperscriptStatement;
|
|
57
|
+
/**
|
|
58
|
+
* Check if direct word mapping exists
|
|
59
|
+
*/
|
|
60
|
+
hasDirectMapping(word: string, fromLocale: string, toLocale: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Get direct word mapping
|
|
63
|
+
*/
|
|
64
|
+
getDirectMapping(word: string, fromLocale: string, toLocale: string): string | null;
|
|
65
|
+
/**
|
|
66
|
+
* Translate word directly using mapping
|
|
67
|
+
*/
|
|
68
|
+
translateWordDirect(word: string, fromLocale: string, toLocale: string): string | null;
|
|
69
|
+
/**
|
|
70
|
+
* Get supported language pairs for direct translation
|
|
71
|
+
*/
|
|
72
|
+
getSupportedDirectPairs(): Array<[string, string]>;
|
|
73
|
+
/**
|
|
74
|
+
* Detect browser locale
|
|
75
|
+
*/
|
|
76
|
+
detectBrowserLocale(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Grammar transformer class
|
|
79
|
+
*/
|
|
80
|
+
GrammarTransformer: any;
|
|
81
|
+
/**
|
|
82
|
+
* Locale manager class
|
|
83
|
+
*/
|
|
84
|
+
LocaleManager: any;
|
|
85
|
+
/**
|
|
86
|
+
* Universal patterns for all languages
|
|
87
|
+
*/
|
|
88
|
+
UNIVERSAL_PATTERNS: any;
|
|
89
|
+
/**
|
|
90
|
+
* Language family defaults
|
|
91
|
+
*/
|
|
92
|
+
LANGUAGE_FAMILY_DEFAULTS: any;
|
|
93
|
+
/**
|
|
94
|
+
* All language profiles
|
|
95
|
+
*/
|
|
96
|
+
profiles: Record<string, LanguageProfile>;
|
|
97
|
+
/**
|
|
98
|
+
* Language-specific profiles
|
|
99
|
+
*/
|
|
100
|
+
englishProfile: LanguageProfile;
|
|
101
|
+
japaneseProfile: LanguageProfile;
|
|
102
|
+
koreanProfile: LanguageProfile;
|
|
103
|
+
arabicProfile: LanguageProfile;
|
|
104
|
+
spanishProfile: LanguageProfile;
|
|
105
|
+
turkishProfile: LanguageProfile;
|
|
106
|
+
chineseProfile: LanguageProfile;
|
|
107
|
+
portugueseProfile: LanguageProfile;
|
|
108
|
+
frenchProfile: LanguageProfile;
|
|
109
|
+
germanProfile: LanguageProfile;
|
|
110
|
+
indonesianProfile: LanguageProfile;
|
|
111
|
+
quechuaProfile: LanguageProfile;
|
|
112
|
+
swahiliProfile: LanguageProfile;
|
|
113
|
+
/**
|
|
114
|
+
* Language-specific keyword dictionaries
|
|
115
|
+
*/
|
|
116
|
+
esDictionary: any;
|
|
117
|
+
jaDictionary: any;
|
|
118
|
+
frDictionary: any;
|
|
119
|
+
deDictionary: any;
|
|
120
|
+
arDictionary: any;
|
|
121
|
+
koDictionary: any;
|
|
122
|
+
zhDictionary: any;
|
|
123
|
+
trDictionary: any;
|
|
124
|
+
idDictionary: any;
|
|
125
|
+
quDictionary: any;
|
|
126
|
+
swDictionary: any;
|
|
127
|
+
ptDictionary: any;
|
|
128
|
+
/**
|
|
129
|
+
* Language-specific keywords
|
|
130
|
+
*/
|
|
131
|
+
esKeywords: any;
|
|
132
|
+
jaKeywords: any;
|
|
133
|
+
frKeywords: any;
|
|
134
|
+
deKeywords: any;
|
|
135
|
+
arKeywords: any;
|
|
136
|
+
koKeywords: any;
|
|
137
|
+
zhKeywords: any;
|
|
138
|
+
trKeywords: any;
|
|
139
|
+
idKeywords: any;
|
|
140
|
+
quKeywords: any;
|
|
141
|
+
swKeywords: any;
|
|
142
|
+
ptKeywords: any;
|
|
143
|
+
/**
|
|
144
|
+
* Direct mapping configuration
|
|
145
|
+
*/
|
|
146
|
+
directMappings: any;
|
|
147
|
+
/**
|
|
148
|
+
* Grammar transformation examples
|
|
149
|
+
*/
|
|
150
|
+
grammarExamples: Array<{
|
|
151
|
+
english: string;
|
|
152
|
+
[locale: string]: string;
|
|
153
|
+
}>;
|
|
154
|
+
}
|
|
155
|
+
export interface HyperscriptStatement {
|
|
156
|
+
command: string;
|
|
157
|
+
roles: Record<string, any>;
|
|
158
|
+
modifiers?: string[];
|
|
159
|
+
[key: string]: any;
|
|
160
|
+
}
|
|
161
|
+
export interface LanguageProfile {
|
|
162
|
+
locale: string;
|
|
163
|
+
name: string;
|
|
164
|
+
wordOrder: 'SVO' | 'SOV' | 'VSO' | 'VOS';
|
|
165
|
+
isRTL: boolean;
|
|
166
|
+
family?: string;
|
|
167
|
+
joinTokens?: Record<string, string>;
|
|
168
|
+
[key: string]: any;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=i18n-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n-api.d.ts","sourceRoot":"","sources":["../src/i18n-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,SAAS,CACP,SAAS,EAAE,oBAAoB,EAC/B,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,oBAAoB,GAAG,IAAI,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAExD;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAE3D;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAAC;IAE1D;;OAEG;IACH,mBAAmB,IAAI,MAAM,EAAE,CAAC;IAEhC;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAEjE;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC;IAEnD;;OAEG;IACH,YAAY,CACV,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,WAAW,EAAE,eAAe,EAC5B,SAAS,EAAE,eAAe,GACzB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEvB;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,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C,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IACzC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hyperfixi/types-browser
|
|
3
|
+
* TypeScript type definitions for HyperFixi browser globals
|
|
4
|
+
*
|
|
5
|
+
* This package provides complete type definitions for using HyperFixi
|
|
6
|
+
* packages in the browser via global variables.
|
|
7
|
+
*
|
|
8
|
+
* ## Installation
|
|
9
|
+
*
|
|
10
|
+
* ```bash
|
|
11
|
+
* npm install --save-dev @hyperfixi/types-browser
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* ## Usage
|
|
15
|
+
*
|
|
16
|
+
* Add to your tsconfig.json:
|
|
17
|
+
* ```json
|
|
18
|
+
* {
|
|
19
|
+
* "compilerOptions": {
|
|
20
|
+
* "types": ["@hyperfixi/types-browser"]
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Or use triple-slash directive in your TypeScript files:
|
|
26
|
+
* ```typescript
|
|
27
|
+
* /// <reference types="@hyperfixi/types-browser" />
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ## Examples
|
|
31
|
+
*
|
|
32
|
+
* ### Using window.hyperfixi
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // window.hyperfixi is now fully typed
|
|
35
|
+
* const result = await window.hyperfixi.execute('toggle .active')
|
|
36
|
+
* window.evalHyperScript('toggle .active')
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* ### Using window.HyperFixiSemantic
|
|
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')
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* ### Using Type Guards
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { isHyperFixiCoreAvailable, getHyperFixiCore } from '@hyperfixi/types-browser'
|
|
50
|
+
*
|
|
51
|
+
* const hyperfixi = getHyperFixiCore()
|
|
52
|
+
* if (hyperfixi) {
|
|
53
|
+
* hyperfixi.execute('toggle .active')
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export * from './core-api';
|
|
58
|
+
export * from './semantic-api';
|
|
59
|
+
export * from './i18n-api';
|
|
60
|
+
export * from './type-guards';
|
|
61
|
+
export * from './globals';
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|