@hyperfixi/types-browser
v2.3.0
Published
TypeScript type definitions for LokaScript browser globals
Maintainers
Readme
@lokascript/types-browser
TypeScript type definitions for LokaScript browser globals.
Installation
npm install --save-dev @lokascript/types-browserUsage
Add to your tsconfig.json:
{
"compilerOptions": {
"types": ["@lokascript/types-browser"]
}
}Now you get full TypeScript autocomplete for browser globals:
// Full IDE autocomplete and type safety!
window.lokascript.execute('toggle .active', document.body);
window._hyperscript.compile('on click add .highlight');
window.LokaScriptSemantic.parse('トグル .active', 'ja');
window.LokaScriptSemantic.translate('toggle .active', 'en', 'ko');
window.LokaScriptI18n.translate('on click toggle .active', 'en', 'ja');Provided Types
window.lokascript / window._hyperscript
Core LokaScript API (from lokascript-browser.js or lokascript-multilingual.js):
compile(source, options?)- Compile hyperscript to ASTexecute(source, element?, context?)- Execute hyperscriptparse(source)- Parse to ASTprocessNode(node)- Process single DOM nodeprocess(root?)- Process entire documentcreateContext(element?, options?)- Create execution contextisValidHyperscript(source)- Validate syntaxversion- Get version stringcreateRuntime(options?)- Create runtime instance
window.LokaScriptSemantic
Semantic parsing API (from lokascript-semantic.browser.global.js):
parse(source, language)- Parse in any of 13 languagestranslate(source, fromLang, toLang)- Translate between languagesgetAllTranslations(source, sourceLang)- Get all translationscreateSemanticAnalyzer(options?)- Create analyzersupportedLanguages- Array of supported language codes
window.LokaScriptI18n
Grammar transformation API (from lokascript-i18n.min.js):
translate(source, fromLang, toLang)- Transform with grammar rulescreateTransformer(options?)- Create transformer instancesupportedLocales- Array of supported localesgetProfile(locale)- Get language grammar profile
Browser Bundle Loading
<!-- Load LokaScript browser bundles -->
<script src="https://cdn.jsdelivr.net/npm/@lokascript/core/dist/lokascript-browser.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@lokascript/semantic/dist/lokascript-semantic.browser.global.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@lokascript/i18n/dist/lokascript-i18n.min.js"></script>
<!-- Now use with full TypeScript support -->
<script>
// TypeScript knows about these globals!
window.lokascript.execute('toggle .active');
window.LokaScriptSemantic.parse('トグル .active', 'ja');
window.LokaScriptI18n.translate('toggle .active', 'en', 'ja');
</script>License
MIT
