@hyperfixi/core 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/LICENSE +21 -0
- package/README.md +218 -0
- package/dist/__test-utils__/context-builders.d.ts +42 -0
- package/dist/__test-utils__/error-testing.d.ts +18 -0
- package/dist/__test-utils__/index.d.ts +6 -0
- package/dist/__test-utils__/mock-types.d.ts +57 -0
- package/dist/__test-utils__/parser-context-mock.d.ts +7 -0
- package/dist/__test-utils__/parser-helpers.d.ts +38 -0
- package/dist/api/dom-processor.d.ts +17 -0
- package/dist/api/hyperscript-api.d.ts +68 -0
- package/dist/api/lokascript-api.d.ts +9 -0
- package/dist/ast-utils/analyzer.d.ts +19 -0
- package/dist/ast-utils/documentation.d.ts +8 -0
- package/dist/ast-utils/generator.d.ts +9 -0
- package/dist/ast-utils/index.d.ts +12 -0
- package/dist/ast-utils/index.js +3366 -0
- package/dist/ast-utils/index.mjs +3320 -0
- package/dist/ast-utils/interchange/from-core.d.ts +8 -0
- package/dist/ast-utils/interchange/index.d.ts +6 -0
- package/dist/ast-utils/interchange/lsp.d.ts +108 -0
- package/dist/ast-utils/interchange/to-core.d.ts +8 -0
- package/dist/ast-utils/interchange/types.d.ts +113 -0
- package/dist/ast-utils/query.d.ts +25 -0
- package/dist/ast-utils/transformer.d.ts +14 -0
- package/dist/ast-utils/types.d.ts +162 -0
- package/dist/ast-utils/visitor.d.ts +40 -0
- package/dist/behaviors/boosted.d.ts +29 -0
- package/dist/behaviors/history-swap.d.ts +24 -0
- package/dist/behaviors/index.d.ts +4 -0
- package/dist/behaviors/index.js +1149 -0
- package/dist/behaviors/index.mjs +1139 -0
- package/dist/bundle-generator/generator.d.ts +4 -0
- package/dist/bundle-generator/index.d.ts +6 -0
- package/dist/bundle-generator/index.js +2294 -0
- package/dist/bundle-generator/index.mjs +2271 -0
- package/dist/bundle-generator/parser-templates.d.ts +6 -0
- package/dist/bundle-generator/template-capabilities.d.ts +10 -0
- package/dist/bundle-generator/templates.d.ts +11 -0
- package/dist/bundle-generator/types.d.ts +34 -0
- package/dist/bundles/test-minimal.d.ts +3 -0
- package/dist/bundles/test-standard.d.ts +3 -0
- package/dist/chunks/bridge-I6ceoWxV.js +2 -0
- package/dist/chunks/browser-modular-Dv6PAV3c.js +2 -0
- package/dist/chunks/feature-eventsource-DWb514fy.js +2 -0
- package/dist/chunks/feature-sockets-3PFuvCVY.js +2 -0
- package/dist/chunks/feature-webworker-DTm_eh-E.js +2 -0
- package/dist/commands/advanced/async.d.ts +28 -0
- package/dist/commands/advanced/js.d.ts +28 -0
- package/dist/commands/animation/measure.d.ts +31 -0
- package/dist/commands/animation/settle.d.ts +26 -0
- package/dist/commands/animation/take.d.ts +28 -0
- package/dist/commands/animation/transition.d.ts +31 -0
- package/dist/commands/async/fetch.d.ts +44 -0
- package/dist/commands/async/wait.d.ts +41 -0
- package/dist/commands/behaviors/install.d.ts +41 -0
- package/dist/commands/content/append.d.ts +27 -0
- package/dist/commands/control-flow/break.d.ts +15 -0
- package/dist/commands/control-flow/continue.d.ts +15 -0
- package/dist/commands/control-flow/exit.d.ts +15 -0
- package/dist/commands/control-flow/halt.d.ts +25 -0
- package/dist/commands/control-flow/if.d.ts +45 -0
- package/dist/commands/control-flow/repeat.d.ts +35 -0
- package/dist/commands/control-flow/return.d.ts +23 -0
- package/dist/commands/control-flow/signal-base.d.ts +25 -0
- package/dist/commands/control-flow/throw.d.ts +22 -0
- package/dist/commands/control-flow/unless.d.ts +3 -0
- package/dist/commands/data/decrement.d.ts +3 -0
- package/dist/commands/data/default.d.ts +31 -0
- package/dist/commands/data/get.d.ts +23 -0
- package/dist/commands/data/increment.d.ts +25 -0
- package/dist/commands/data/set.d.ts +56 -0
- package/dist/commands/decorators/index.d.ts +30 -0
- package/dist/commands/dom/__tests__/add-standalone-helpers.d.ts +11 -0
- package/dist/commands/dom/add.d.ts +31 -0
- package/dist/commands/dom/dom-modification-base.d.ts +48 -0
- package/dist/commands/dom/hide.d.ts +12 -0
- package/dist/commands/dom/make.d.ts +21 -0
- package/dist/commands/dom/process-partials.d.ts +39 -0
- package/dist/commands/dom/put.d.ts +31 -0
- package/dist/commands/dom/remove.d.ts +33 -0
- package/dist/commands/dom/show.d.ts +13 -0
- package/dist/commands/dom/swap.d.ts +38 -0
- package/dist/commands/dom/toggle.d.ts +55 -0
- package/dist/commands/dom/visibility-base.d.ts +20 -0
- package/dist/commands/events/send.d.ts +3 -0
- package/dist/commands/events/trigger.d.ts +36 -0
- package/dist/commands/execution/call.d.ts +24 -0
- package/dist/commands/execution/pseudo-command.d.ts +42 -0
- package/dist/commands/helpers/attribute-manipulation.d.ts +11 -0
- package/dist/commands/helpers/batch-dom-operations.d.ts +12 -0
- package/dist/commands/helpers/class-manipulation.d.ts +11 -0
- package/dist/commands/helpers/condition-helpers.d.ts +4 -0
- package/dist/commands/helpers/dom-mutation.d.ts +15 -0
- package/dist/commands/helpers/duration-parsing.d.ts +8 -0
- package/dist/commands/helpers/element-property-access.d.ts +7 -0
- package/dist/commands/helpers/element-resolution.d.ts +17 -0
- package/dist/commands/helpers/error-helpers.d.ts +17 -0
- package/dist/commands/helpers/event-helpers.d.ts +13 -0
- package/dist/commands/helpers/event-waiting.d.ts +37 -0
- package/dist/commands/helpers/index.d.ts +32 -0
- package/dist/commands/helpers/input-validator.d.ts +23 -0
- package/dist/commands/helpers/loop-executor.d.ts +53 -0
- package/dist/commands/helpers/numeric-target-parser.d.ts +14 -0
- package/dist/commands/helpers/property-target.d.ts +30 -0
- package/dist/commands/helpers/selector-type-detection.d.ts +24 -0
- package/dist/commands/helpers/smart-element.d.ts +16 -0
- package/dist/commands/helpers/style-manipulation.d.ts +16 -0
- package/dist/commands/helpers/temporal-modifiers.d.ts +15 -0
- package/dist/commands/helpers/url-argument-parser.d.ts +10 -0
- package/dist/commands/helpers/url-validation.d.ts +7 -0
- package/dist/commands/helpers/variable-access.d.ts +10 -0
- package/dist/commands/helpers/visibility-target-parser.d.ts +11 -0
- package/dist/commands/index.d.ts +139 -0
- package/dist/commands/index.js +9186 -0
- package/dist/commands/index.mjs +9032 -0
- package/dist/commands/navigation/go.d.ts +35 -0
- package/dist/commands/navigation/push-url.d.ts +35 -0
- package/dist/commands/navigation/replace-url.d.ts +3 -0
- package/dist/commands/templates/render.d.ts +48 -0
- package/dist/commands/utility/beep.d.ts +32 -0
- package/dist/commands/utility/copy.d.ts +29 -0
- package/dist/commands/utility/log.d.ts +24 -0
- package/dist/commands/utility/pick.d.ts +26 -0
- package/dist/commands/utility/tell.d.ts +26 -0
- package/dist/compatibility/browser-bundle-animation-generated.d.ts +16 -0
- package/dist/compatibility/browser-bundle-classic-i18n.d.ts +63 -0
- package/dist/compatibility/browser-bundle-classic.d.ts +17 -0
- package/dist/compatibility/browser-bundle-forms-generated.d.ts +16 -0
- package/dist/compatibility/browser-bundle-hybrid-complete.d.ts +28 -0
- package/dist/compatibility/browser-bundle-hybrid-hx.d.ts +43 -0
- package/dist/compatibility/browser-bundle-lite-plus.d.ts +25 -0
- package/dist/compatibility/browser-bundle-lite.d.ts +23 -0
- package/dist/compatibility/browser-bundle-minimal-generated.d.ts +16 -0
- package/dist/compatibility/browser-bundle-minimal-v2.d.ts +17 -0
- package/dist/compatibility/browser-bundle-minimal.d.ts +8 -0
- package/dist/compatibility/browser-bundle-modular.d.ts +18 -0
- package/dist/compatibility/browser-bundle-multilingual.d.ts +19 -0
- package/dist/compatibility/browser-bundle-semantic-complete.d.ts +24 -0
- package/dist/compatibility/browser-bundle-standard-v2.d.ts +17 -0
- package/dist/compatibility/browser-bundle-standard.d.ts +8 -0
- package/dist/compatibility/browser-bundle-textshelf-minimal.d.ts +16 -0
- package/dist/compatibility/browser-bundle-textshelf-profile.d.ts +18 -0
- package/dist/compatibility/browser-bundle.d.ts +140 -0
- package/dist/compatibility/browser-modular.d.ts +53 -0
- package/dist/compatibility/browser-tests/test-utils.d.ts +21 -0
- package/dist/compatibility/eval-hyperscript.d.ts +15 -0
- package/dist/compatibility/feature-loader.d.ts +8 -0
- package/dist/compatibility/hyperscript-adapter.d.ts +38 -0
- package/dist/compatibility/hyperscript-tests/test-adapter.d.ts +13 -0
- package/dist/core/ast-property-utils.d.ts +2 -0
- package/dist/core/base-expression-evaluator.d.ts +70 -0
- package/dist/core/binary-expression-evaluator.d.ts +7 -0
- package/dist/core/call-expression-evaluator.d.ts +7 -0
- package/dist/core/configurable-expression-evaluator.d.ts +5 -0
- package/dist/core/context.d.ts +15 -0
- package/dist/core/dom.d.ts +15 -0
- package/dist/core/evaluator-types.d.ts +5 -0
- package/dist/core/events.d.ts +48 -0
- package/dist/core/executor.d.ts +34 -0
- package/dist/core/expression-evaluator.d.ts +6 -0
- package/dist/core/lazy-expression-evaluator.d.ts +22 -0
- package/dist/core/parser.d.ts +21 -0
- package/dist/core/selector-evaluator.d.ts +15 -0
- package/dist/core/template-literal-evaluator.d.ts +5 -0
- package/dist/dom/attribute-processor.d.ts +40 -0
- package/dist/dom/minimal-attribute-processor.d.ts +20 -0
- package/dist/experimental/binary-tree/accessor.d.ts +10 -0
- package/dist/experimental/binary-tree/ast-serializer.d.ts +26 -0
- package/dist/experimental/binary-tree/benchmark.d.ts +24 -0
- package/dist/experimental/binary-tree/buffer-context.d.ts +27 -0
- package/dist/experimental/binary-tree/deserializer.d.ts +17 -0
- package/dist/experimental/binary-tree/index.d.ts +22 -0
- package/dist/experimental/binary-tree/serializer.d.ts +4 -0
- package/dist/experimental/binary-tree/types.d.ts +54 -0
- package/dist/expressions/base-expression.d.ts +27 -0
- package/dist/expressions/bundles/common-expressions.d.ts +9 -0
- package/dist/expressions/bundles/core-expressions.d.ts +7 -0
- package/dist/expressions/bundles/full-expressions.d.ts +10 -0
- package/dist/expressions/bundles/index.d.ts +7 -0
- package/dist/expressions/comparison/index.d.ts +80 -0
- package/dist/expressions/comparison/utils.d.ts +2 -0
- package/dist/expressions/conversion/impl/bridge.d.ts +117 -0
- package/dist/expressions/conversion/impl/index.d.ts +59 -0
- package/dist/expressions/conversion/index.d.ts +23 -0
- package/dist/expressions/expression-tiers.d.ts +13 -0
- package/dist/expressions/index.d.ts +11 -0
- package/dist/expressions/index.js +6930 -0
- package/dist/expressions/index.mjs +6912 -0
- package/dist/expressions/logical/impl/index.d.ts +54 -0
- package/dist/expressions/logical/impl/pattern-matching.d.ts +58 -0
- package/dist/expressions/logical/index.d.ts +59 -0
- package/dist/expressions/mathematical/index.d.ts +69 -0
- package/dist/expressions/positional/impl/bridge.d.ts +95 -0
- package/dist/expressions/positional/impl/index.d.ts +73 -0
- package/dist/expressions/positional/index.d.ts +26 -0
- package/dist/expressions/properties/impl/index.d.ts +105 -0
- package/dist/expressions/properties/index.d.ts +26 -0
- package/dist/expressions/property/index.d.ts +55 -0
- package/dist/expressions/property-access-utils.d.ts +23 -0
- package/dist/expressions/references/impl/bridge.d.ts +54 -0
- package/dist/expressions/references/impl/index.d.ts +65 -0
- package/dist/expressions/references/index.d.ts +40 -0
- package/dist/expressions/shared/comparison-utils.d.ts +10 -0
- package/dist/expressions/shared/index.d.ts +9 -0
- package/dist/expressions/shared/number-utils.d.ts +7 -0
- package/dist/expressions/shared/validation-utils.d.ts +13 -0
- package/dist/expressions/special/index.d.ts +104 -0
- package/dist/expressions/type-helpers.d.ts +11 -0
- package/dist/expressions/type-registry.d.ts +57 -0
- package/dist/expressions/validation-helpers.d.ts +15 -0
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/tailwind.d.ts +22 -0
- package/dist/features/behaviors.d.ts +153 -0
- package/dist/features/def.d.ts +135 -0
- package/dist/features/eventsource.d.ts +140 -0
- package/dist/features/init.d.ts +135 -0
- package/dist/features/on.d.ts +131 -0
- package/dist/features/predefined-behaviors/dropdown-behavior.d.ts +20 -0
- package/dist/features/predefined-behaviors/index.d.ts +12 -0
- package/dist/features/predefined-behaviors/modal-behavior.d.ts +18 -0
- package/dist/features/predefined-behaviors/toggle-group-behavior.d.ts +23 -0
- package/dist/features/predefined-behaviors/types.d.ts +14 -0
- package/dist/features/sockets.d.ts +162 -0
- package/dist/features/webworker.d.ts +135 -0
- package/dist/htmx/htmx-attribute-processor.d.ts +84 -0
- package/dist/htmx/htmx-translator.d.ts +19 -0
- package/dist/htmx/index.d.ts +3 -0
- package/dist/hyperfixi-classic-i18n.js +2 -0
- package/dist/hyperfixi-hx.js +1 -0
- package/dist/hyperfixi-hybrid-complete.js +1 -0
- package/dist/hyperfixi-lite-plus.js +1 -0
- package/dist/hyperfixi-lite.js +1 -0
- package/dist/hyperfixi-minimal.js +1 -0
- package/dist/hyperfixi-multilingual.js +2 -0
- package/dist/hyperfixi-standard.js +2 -0
- package/dist/hyperfixi.js +2 -0
- package/dist/hyperfixi.mjs +2 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +65387 -0
- package/dist/index.min.js +2 -0
- package/dist/index.mjs +65343 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/morph-adapter.d.ts +22 -0
- package/dist/lib/swap-executor.d.ts +22 -0
- package/dist/lib/view-transitions.d.ts +33 -0
- package/dist/lokascript-browser-classic-i18n.js +2 -0
- package/dist/lokascript-browser-minimal.js +1 -0
- package/dist/lokascript-browser-standard.js +2 -0
- package/dist/lokascript-browser.js +2 -0
- package/dist/lokascript-hybrid-complete.js +1 -0
- package/dist/lokascript-hybrid-hx.js +1 -0
- package/dist/lokascript-lite-plus.js +1 -0
- package/dist/lokascript-lite.js +1 -0
- package/dist/lokascript-multilingual.js +2 -0
- package/dist/lsp-metadata.d.ts +25 -0
- package/dist/lsp-metadata.js +680 -0
- package/dist/lsp-metadata.mjs +670 -0
- package/dist/metadata.d.ts +213 -0
- package/dist/metadata.js +378 -0
- package/dist/metadata.mjs +368 -0
- package/dist/mod.d.ts +63 -0
- package/dist/multilingual/bridge.d.ts +36 -0
- package/dist/multilingual/index.d.ts +32 -0
- package/dist/multilingual/index.js +285 -0
- package/dist/multilingual/index.mjs +278 -0
- package/dist/parser/__types__/test-helpers.d.ts +25 -0
- package/dist/parser/command-node-builder.d.ts +45 -0
- package/dist/parser/command-parsers/animation-commands.d.ts +5 -0
- package/dist/parser/command-parsers/async-commands.d.ts +5 -0
- package/dist/parser/command-parsers/control-flow-commands.d.ts +7 -0
- package/dist/parser/command-parsers/dom-commands.d.ts +8 -0
- package/dist/parser/command-parsers/event-commands.d.ts +4 -0
- package/dist/parser/command-parsers/utility-commands.d.ts +9 -0
- package/dist/parser/command-parsers/variable-commands.d.ts +12 -0
- package/dist/parser/error-handler.d.ts +34 -0
- package/dist/parser/expression-parser.d.ts +6 -0
- package/dist/parser/full-parser.d.ts +4 -0
- package/dist/parser/full-parser.js +6532 -0
- package/dist/parser/full-parser.mjs +6529 -0
- package/dist/parser/helpers/ast-helpers.d.ts +22 -0
- package/dist/parser/helpers/parsing-helpers.d.ts +19 -0
- package/dist/parser/helpers/token-helpers.d.ts +28 -0
- package/dist/parser/hybrid/aliases.d.ts +7 -0
- package/dist/parser/hybrid/aliases.js +44 -0
- package/dist/parser/hybrid/aliases.mjs +37 -0
- package/dist/parser/hybrid/ast-types.d.ts +97 -0
- package/dist/parser/hybrid/ast-types.js +3 -0
- package/dist/parser/hybrid/ast-types.mjs +2 -0
- package/dist/parser/hybrid/index.d.ts +6 -0
- package/dist/parser/hybrid/index.js +1015 -0
- package/dist/parser/hybrid/index.mjs +1005 -0
- package/dist/parser/hybrid/parser-core.d.ts +57 -0
- package/dist/parser/hybrid/parser-core.js +1001 -0
- package/dist/parser/hybrid/parser-core.mjs +999 -0
- package/dist/parser/hybrid/tokenizer.d.ts +9 -0
- package/dist/parser/hybrid/tokenizer.js +242 -0
- package/dist/parser/hybrid/tokenizer.mjs +239 -0
- package/dist/parser/hybrid-parser.d.ts +10 -0
- package/dist/parser/hybrid-parser.js +1078 -0
- package/dist/parser/hybrid-parser.mjs +1071 -0
- package/dist/parser/parser-constants.d.ts +102 -0
- package/dist/parser/parser-interface.d.ts +11 -0
- package/dist/parser/parser-types.d.ts +175 -0
- package/dist/parser/parser.d.ts +146 -0
- package/dist/parser/regex-parser.d.ts +4 -0
- package/dist/parser/regex-parser.js +412 -0
- package/dist/parser/regex-parser.mjs +409 -0
- package/dist/parser/runtime.d.ts +3 -0
- package/dist/parser/semantic-integration.d.ts +61 -0
- package/dist/parser/token-consumer.d.ts +35 -0
- package/dist/parser/token-predicates.d.ts +77 -0
- package/dist/parser/tokenizer.d.ts +57 -0
- package/dist/parser/types.d.ts +118 -0
- package/dist/performance/expression-cache.d.ts +78 -0
- package/dist/performance/integration.d.ts +40 -0
- package/dist/performance/production-monitor.d.ts +67 -0
- package/dist/reference/index.d.ts +41 -0
- package/dist/reference/index.js +586 -0
- package/dist/reference/index.mjs +577 -0
- package/dist/registry/browser-types.d.ts +20 -0
- package/dist/registry/browser-types.js +81 -0
- package/dist/registry/browser-types.mjs +76 -0
- package/dist/registry/context-provider-registry.d.ts +38 -0
- package/dist/registry/environment.d.ts +19 -0
- package/dist/registry/environment.js +36 -0
- package/dist/registry/environment.mjs +30 -0
- package/dist/registry/event-source-registry.d.ts +54 -0
- package/dist/registry/examples/server-commands.d.ts +6 -0
- package/dist/registry/examples/server-event-source.d.ts +32 -0
- package/dist/registry/index.d.ts +54 -0
- package/dist/registry/index.js +7636 -0
- package/dist/registry/index.mjs +7612 -0
- package/dist/registry/multilingual/examples.d.ts +16 -0
- package/dist/registry/multilingual/index.d.ts +68 -0
- package/dist/registry/runtime-integration.d.ts +30 -0
- package/dist/registry/universal-types.d.ts +34 -0
- package/dist/registry/universal-types.js +91 -0
- package/dist/registry/universal-types.mjs +86 -0
- package/dist/runtime/cleanup-registry.d.ts +47 -0
- package/dist/runtime/command-adapter.d.ts +63 -0
- package/dist/runtime/environment.d.ts +75 -0
- package/dist/runtime/runtime-base.d.ts +78 -0
- package/dist/runtime/runtime-experimental.d.ts +18 -0
- package/dist/runtime/runtime-factory.d.ts +30 -0
- package/dist/runtime/runtime.d.ts +19 -0
- package/dist/runtime/temporal-modifiers.d.ts +37 -0
- package/dist/scripts/code-generator.d.ts +64 -0
- package/dist/scripts/generate-missing-commands.d.ts +4 -0
- package/dist/test-setup.d.ts +45 -0
- package/dist/test-utilities.d.ts +52 -0
- package/dist/tokenizer.d.ts +49 -0
- package/dist/types/base-types.d.ts +336 -0
- package/dist/types/code-fix.d.ts +39 -0
- package/dist/types/command-metadata.d.ts +57 -0
- package/dist/types/command-types.d.ts +272 -0
- package/dist/types/context-types.d.ts +106 -0
- package/dist/types/core-context.d.ts +21 -0
- package/dist/types/core.d.ts +203 -0
- package/dist/types/error-codes.d.ts +207 -0
- package/dist/types/expression-types.d.ts +155 -0
- package/dist/types/feature-types.d.ts +81 -0
- package/dist/types/hooks.d.ts +45 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/result.d.ts +72 -0
- package/dist/types/template-types.d.ts +162 -0
- package/dist/types/type-guards.d.ts +24 -0
- package/dist/types/unified-types.d.ts +99 -0
- package/dist/utils/debug-events.d.ts +41 -0
- package/dist/utils/debug.d.ts +35 -0
- package/dist/utils/dom-utils.d.ts +16 -0
- package/dist/utils/element-check.d.ts +7 -0
- package/dist/utils/keyboard-shortcuts.d.ts +18 -0
- package/dist/utils/performance.d.ts +40 -0
- package/dist/validation/command-pattern-validator.d.ts +53 -0
- package/dist/validation/common-validators.d.ts +24 -0
- package/dist/validation/lightweight-validators.d.ts +113 -0
- package/dist/validation/partial-validation-types.d.ts +50 -0
- package/dist/validation/partial-validator.d.ts +6 -0
- package/dist/validation/partial-warning-formatter.d.ts +6 -0
- package/dist/validation/validate-cli.d.ts +41 -0
- package/package.json +292 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var semantic = require('@lokascript/semantic');
|
|
4
|
+
|
|
5
|
+
let _semanticModule = null;
|
|
6
|
+
async function getSemanticModule() {
|
|
7
|
+
if (!_semanticModule) {
|
|
8
|
+
_semanticModule = await import('@lokascript/semantic');
|
|
9
|
+
}
|
|
10
|
+
return _semanticModule;
|
|
11
|
+
}
|
|
12
|
+
class SemanticGrammarBridge {
|
|
13
|
+
constructor(config = {}) {
|
|
14
|
+
this.analyzer = null;
|
|
15
|
+
this.config = {
|
|
16
|
+
confidenceThreshold: config.confidenceThreshold ?? semantic.DEFAULT_CONFIDENCE_THRESHOLD,
|
|
17
|
+
fallbackOnLowConfidence: config.fallbackOnLowConfidence ?? true,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async initialize() {
|
|
21
|
+
const semantic = await getSemanticModule();
|
|
22
|
+
this.analyzer = semantic.createSemanticAnalyzer();
|
|
23
|
+
}
|
|
24
|
+
isInitialized() {
|
|
25
|
+
return this.analyzer !== null;
|
|
26
|
+
}
|
|
27
|
+
async transform(input, sourceLang, targetLang) {
|
|
28
|
+
if (!this.isInitialized()) {
|
|
29
|
+
await this.initialize();
|
|
30
|
+
}
|
|
31
|
+
if (sourceLang === targetLang) {
|
|
32
|
+
return {
|
|
33
|
+
output: input,
|
|
34
|
+
usedSemantic: false,
|
|
35
|
+
confidence: 1.0,
|
|
36
|
+
sourceLang,
|
|
37
|
+
targetLang,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const semantic = await getSemanticModule();
|
|
41
|
+
try {
|
|
42
|
+
const output = semantic.translate(input, sourceLang, targetLang);
|
|
43
|
+
if (output !== input) {
|
|
44
|
+
return {
|
|
45
|
+
output,
|
|
46
|
+
usedSemantic: true,
|
|
47
|
+
confidence: 0.9,
|
|
48
|
+
sourceLang,
|
|
49
|
+
targetLang,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
output: input,
|
|
57
|
+
usedSemantic: false,
|
|
58
|
+
confidence: 0,
|
|
59
|
+
sourceLang,
|
|
60
|
+
targetLang,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async parse(input, lang) {
|
|
64
|
+
if (!this.isInitialized()) {
|
|
65
|
+
await this.initialize();
|
|
66
|
+
}
|
|
67
|
+
if (!this.analyzer)
|
|
68
|
+
return null;
|
|
69
|
+
const result = this.analyzer.analyze(input, lang);
|
|
70
|
+
return result.node ?? null;
|
|
71
|
+
}
|
|
72
|
+
async render(node, targetLang) {
|
|
73
|
+
const semantic = await getSemanticModule();
|
|
74
|
+
return semantic.render(node, targetLang);
|
|
75
|
+
}
|
|
76
|
+
async parseToAST(input, lang) {
|
|
77
|
+
if (!this.isInitialized()) {
|
|
78
|
+
await this.initialize();
|
|
79
|
+
}
|
|
80
|
+
if (!this.analyzer)
|
|
81
|
+
return null;
|
|
82
|
+
const result = this.analyzer.analyze(input, lang);
|
|
83
|
+
if (result.confidence >= this.config.confidenceThreshold && result.node) {
|
|
84
|
+
const semantic = await getSemanticModule();
|
|
85
|
+
try {
|
|
86
|
+
const buildResult = semantic.buildAST(result.node);
|
|
87
|
+
return buildResult.ast;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.warn('[SemanticGrammarBridge] AST build failed, using fallback:', error);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
async parseToASTWithDetails(input, lang) {
|
|
96
|
+
if (!this.isInitialized()) {
|
|
97
|
+
await this.initialize();
|
|
98
|
+
}
|
|
99
|
+
if (!this.analyzer) {
|
|
100
|
+
return {
|
|
101
|
+
ast: null,
|
|
102
|
+
usedDirectPath: false,
|
|
103
|
+
confidence: 0,
|
|
104
|
+
lang,
|
|
105
|
+
fallbackText: null,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const result = this.analyzer.analyze(input, lang);
|
|
109
|
+
const semantic = await getSemanticModule();
|
|
110
|
+
if (result.confidence >= this.config.confidenceThreshold && result.node) {
|
|
111
|
+
try {
|
|
112
|
+
const buildResult = semantic.buildAST(result.node);
|
|
113
|
+
return {
|
|
114
|
+
ast: buildResult.ast,
|
|
115
|
+
usedDirectPath: true,
|
|
116
|
+
confidence: result.confidence,
|
|
117
|
+
lang,
|
|
118
|
+
fallbackText: null,
|
|
119
|
+
warnings: buildResult.warnings,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (result.node && this.config.fallbackOnLowConfidence) {
|
|
126
|
+
const englishText = semantic.render(result.node, 'en');
|
|
127
|
+
return {
|
|
128
|
+
ast: null,
|
|
129
|
+
usedDirectPath: false,
|
|
130
|
+
confidence: result.confidence,
|
|
131
|
+
lang,
|
|
132
|
+
fallbackText: englishText,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
ast: null,
|
|
137
|
+
usedDirectPath: false,
|
|
138
|
+
confidence: result.confidence,
|
|
139
|
+
lang,
|
|
140
|
+
fallbackText: null,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
async getAllTranslations(input, sourceLang) {
|
|
144
|
+
const semantic = await getSemanticModule();
|
|
145
|
+
const languages = semantic.getSupportedLanguages();
|
|
146
|
+
const results = {};
|
|
147
|
+
for (const lang of languages) {
|
|
148
|
+
results[lang] = await this.transform(input, sourceLang, lang);
|
|
149
|
+
}
|
|
150
|
+
return results;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
let _defaultBridge = null;
|
|
154
|
+
async function getDefaultBridge() {
|
|
155
|
+
if (!_defaultBridge) {
|
|
156
|
+
_defaultBridge = new SemanticGrammarBridge();
|
|
157
|
+
await _defaultBridge.initialize();
|
|
158
|
+
}
|
|
159
|
+
return _defaultBridge;
|
|
160
|
+
}
|
|
161
|
+
async function translate(input, sourceLang, targetLang) {
|
|
162
|
+
const bridge = await getDefaultBridge();
|
|
163
|
+
const result = await bridge.transform(input, sourceLang, targetLang);
|
|
164
|
+
return result.output;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
class MultilingualHyperscript {
|
|
168
|
+
constructor(config = {}) {
|
|
169
|
+
this.initialized = false;
|
|
170
|
+
this.bridge = new SemanticGrammarBridge(config);
|
|
171
|
+
}
|
|
172
|
+
async initialize() {
|
|
173
|
+
if (this.initialized)
|
|
174
|
+
return;
|
|
175
|
+
await this.bridge.initialize();
|
|
176
|
+
this.initialized = true;
|
|
177
|
+
}
|
|
178
|
+
isInitialized() {
|
|
179
|
+
return this.initialized;
|
|
180
|
+
}
|
|
181
|
+
async ensureInitialized() {
|
|
182
|
+
if (!this.initialized) {
|
|
183
|
+
await this.initialize();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async parse(input, lang = 'en') {
|
|
187
|
+
await this.ensureInitialized();
|
|
188
|
+
return this.bridge.parse(input, lang);
|
|
189
|
+
}
|
|
190
|
+
async parseToAST(input, lang = 'en') {
|
|
191
|
+
await this.ensureInitialized();
|
|
192
|
+
return this.bridge.parseToAST(input, lang);
|
|
193
|
+
}
|
|
194
|
+
async parseToASTWithDetails(input, lang = 'en') {
|
|
195
|
+
await this.ensureInitialized();
|
|
196
|
+
return this.bridge.parseToASTWithDetails(input, lang);
|
|
197
|
+
}
|
|
198
|
+
async translate(input, from, to) {
|
|
199
|
+
await this.ensureInitialized();
|
|
200
|
+
const result = await this.bridge.transform(input, from, to);
|
|
201
|
+
return result.output;
|
|
202
|
+
}
|
|
203
|
+
async translateWithDetails(input, from, to) {
|
|
204
|
+
await this.ensureInitialized();
|
|
205
|
+
return this.bridge.transform(input, from, to);
|
|
206
|
+
}
|
|
207
|
+
async render(node, lang) {
|
|
208
|
+
await this.ensureInitialized();
|
|
209
|
+
return this.bridge.render(node, lang);
|
|
210
|
+
}
|
|
211
|
+
async getAllTranslations(input, from) {
|
|
212
|
+
await this.ensureInitialized();
|
|
213
|
+
return this.bridge.getAllTranslations(input, from);
|
|
214
|
+
}
|
|
215
|
+
getSupportedLanguages() {
|
|
216
|
+
return [
|
|
217
|
+
'en',
|
|
218
|
+
'ja',
|
|
219
|
+
'ar',
|
|
220
|
+
'es',
|
|
221
|
+
'ko',
|
|
222
|
+
'zh',
|
|
223
|
+
'tr',
|
|
224
|
+
'pt',
|
|
225
|
+
'fr',
|
|
226
|
+
'de',
|
|
227
|
+
'id',
|
|
228
|
+
'qu',
|
|
229
|
+
'sw',
|
|
230
|
+
];
|
|
231
|
+
}
|
|
232
|
+
isLanguageSupported(lang) {
|
|
233
|
+
return this.getSupportedLanguages().includes(lang);
|
|
234
|
+
}
|
|
235
|
+
getLanguageInfo(lang) {
|
|
236
|
+
return LANGUAGE_INFO[lang];
|
|
237
|
+
}
|
|
238
|
+
getAllLanguageInfo() {
|
|
239
|
+
return { ...LANGUAGE_INFO };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const LANGUAGE_INFO = {
|
|
243
|
+
en: { code: 'en', name: 'English', nativeName: 'English', direction: 'ltr', wordOrder: 'SVO' },
|
|
244
|
+
ja: { code: 'ja', name: 'Japanese', nativeName: '日本語', direction: 'ltr', wordOrder: 'SOV' },
|
|
245
|
+
ar: { code: 'ar', name: 'Arabic', nativeName: 'العربية', direction: 'rtl', wordOrder: 'VSO' },
|
|
246
|
+
es: { code: 'es', name: 'Spanish', nativeName: 'Español', direction: 'ltr', wordOrder: 'SVO' },
|
|
247
|
+
ko: { code: 'ko', name: 'Korean', nativeName: '한국어', direction: 'ltr', wordOrder: 'SOV' },
|
|
248
|
+
zh: { code: 'zh', name: 'Chinese', nativeName: '中文', direction: 'ltr', wordOrder: 'SVO' },
|
|
249
|
+
tr: { code: 'tr', name: 'Turkish', nativeName: 'Türkçe', direction: 'ltr', wordOrder: 'SOV' },
|
|
250
|
+
pt: {
|
|
251
|
+
code: 'pt',
|
|
252
|
+
name: 'Portuguese',
|
|
253
|
+
nativeName: 'Português',
|
|
254
|
+
direction: 'ltr',
|
|
255
|
+
wordOrder: 'SVO',
|
|
256
|
+
},
|
|
257
|
+
fr: { code: 'fr', name: 'French', nativeName: 'Français', direction: 'ltr', wordOrder: 'SVO' },
|
|
258
|
+
de: { code: 'de', name: 'German', nativeName: 'Deutsch', direction: 'ltr', wordOrder: 'SVO' },
|
|
259
|
+
id: {
|
|
260
|
+
code: 'id',
|
|
261
|
+
name: 'Indonesian',
|
|
262
|
+
nativeName: 'Bahasa Indonesia',
|
|
263
|
+
direction: 'ltr',
|
|
264
|
+
wordOrder: 'SVO',
|
|
265
|
+
},
|
|
266
|
+
qu: { code: 'qu', name: 'Quechua', nativeName: 'Runasimi', direction: 'ltr', wordOrder: 'SOV' },
|
|
267
|
+
sw: { code: 'sw', name: 'Swahili', nativeName: 'Kiswahili', direction: 'ltr', wordOrder: 'SVO' },
|
|
268
|
+
};
|
|
269
|
+
let _defaultInstance = null;
|
|
270
|
+
async function getMultilingual() {
|
|
271
|
+
if (!_defaultInstance) {
|
|
272
|
+
_defaultInstance = new MultilingualHyperscript();
|
|
273
|
+
await _defaultInstance.initialize();
|
|
274
|
+
}
|
|
275
|
+
return _defaultInstance;
|
|
276
|
+
}
|
|
277
|
+
const multilingual = new MultilingualHyperscript();
|
|
278
|
+
|
|
279
|
+
exports.MultilingualHyperscript = MultilingualHyperscript;
|
|
280
|
+
exports.SemanticGrammarBridge = SemanticGrammarBridge;
|
|
281
|
+
exports.getDefaultBridge = getDefaultBridge;
|
|
282
|
+
exports.getMultilingual = getMultilingual;
|
|
283
|
+
exports.multilingual = multilingual;
|
|
284
|
+
exports.translate = translate;
|
|
285
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { DEFAULT_CONFIDENCE_THRESHOLD } from '@lokascript/semantic';
|
|
2
|
+
|
|
3
|
+
let _semanticModule = null;
|
|
4
|
+
async function getSemanticModule() {
|
|
5
|
+
if (!_semanticModule) {
|
|
6
|
+
_semanticModule = await import('@lokascript/semantic');
|
|
7
|
+
}
|
|
8
|
+
return _semanticModule;
|
|
9
|
+
}
|
|
10
|
+
class SemanticGrammarBridge {
|
|
11
|
+
constructor(config = {}) {
|
|
12
|
+
this.analyzer = null;
|
|
13
|
+
this.config = {
|
|
14
|
+
confidenceThreshold: config.confidenceThreshold ?? DEFAULT_CONFIDENCE_THRESHOLD,
|
|
15
|
+
fallbackOnLowConfidence: config.fallbackOnLowConfidence ?? true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
async initialize() {
|
|
19
|
+
const semantic = await getSemanticModule();
|
|
20
|
+
this.analyzer = semantic.createSemanticAnalyzer();
|
|
21
|
+
}
|
|
22
|
+
isInitialized() {
|
|
23
|
+
return this.analyzer !== null;
|
|
24
|
+
}
|
|
25
|
+
async transform(input, sourceLang, targetLang) {
|
|
26
|
+
if (!this.isInitialized()) {
|
|
27
|
+
await this.initialize();
|
|
28
|
+
}
|
|
29
|
+
if (sourceLang === targetLang) {
|
|
30
|
+
return {
|
|
31
|
+
output: input,
|
|
32
|
+
usedSemantic: false,
|
|
33
|
+
confidence: 1.0,
|
|
34
|
+
sourceLang,
|
|
35
|
+
targetLang,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const semantic = await getSemanticModule();
|
|
39
|
+
try {
|
|
40
|
+
const output = semantic.translate(input, sourceLang, targetLang);
|
|
41
|
+
if (output !== input) {
|
|
42
|
+
return {
|
|
43
|
+
output,
|
|
44
|
+
usedSemantic: true,
|
|
45
|
+
confidence: 0.9,
|
|
46
|
+
sourceLang,
|
|
47
|
+
targetLang,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
output: input,
|
|
55
|
+
usedSemantic: false,
|
|
56
|
+
confidence: 0,
|
|
57
|
+
sourceLang,
|
|
58
|
+
targetLang,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async parse(input, lang) {
|
|
62
|
+
if (!this.isInitialized()) {
|
|
63
|
+
await this.initialize();
|
|
64
|
+
}
|
|
65
|
+
if (!this.analyzer)
|
|
66
|
+
return null;
|
|
67
|
+
const result = this.analyzer.analyze(input, lang);
|
|
68
|
+
return result.node ?? null;
|
|
69
|
+
}
|
|
70
|
+
async render(node, targetLang) {
|
|
71
|
+
const semantic = await getSemanticModule();
|
|
72
|
+
return semantic.render(node, targetLang);
|
|
73
|
+
}
|
|
74
|
+
async parseToAST(input, lang) {
|
|
75
|
+
if (!this.isInitialized()) {
|
|
76
|
+
await this.initialize();
|
|
77
|
+
}
|
|
78
|
+
if (!this.analyzer)
|
|
79
|
+
return null;
|
|
80
|
+
const result = this.analyzer.analyze(input, lang);
|
|
81
|
+
if (result.confidence >= this.config.confidenceThreshold && result.node) {
|
|
82
|
+
const semantic = await getSemanticModule();
|
|
83
|
+
try {
|
|
84
|
+
const buildResult = semantic.buildAST(result.node);
|
|
85
|
+
return buildResult.ast;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
console.warn('[SemanticGrammarBridge] AST build failed, using fallback:', error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
async parseToASTWithDetails(input, lang) {
|
|
94
|
+
if (!this.isInitialized()) {
|
|
95
|
+
await this.initialize();
|
|
96
|
+
}
|
|
97
|
+
if (!this.analyzer) {
|
|
98
|
+
return {
|
|
99
|
+
ast: null,
|
|
100
|
+
usedDirectPath: false,
|
|
101
|
+
confidence: 0,
|
|
102
|
+
lang,
|
|
103
|
+
fallbackText: null,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const result = this.analyzer.analyze(input, lang);
|
|
107
|
+
const semantic = await getSemanticModule();
|
|
108
|
+
if (result.confidence >= this.config.confidenceThreshold && result.node) {
|
|
109
|
+
try {
|
|
110
|
+
const buildResult = semantic.buildAST(result.node);
|
|
111
|
+
return {
|
|
112
|
+
ast: buildResult.ast,
|
|
113
|
+
usedDirectPath: true,
|
|
114
|
+
confidence: result.confidence,
|
|
115
|
+
lang,
|
|
116
|
+
fallbackText: null,
|
|
117
|
+
warnings: buildResult.warnings,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (result.node && this.config.fallbackOnLowConfidence) {
|
|
124
|
+
const englishText = semantic.render(result.node, 'en');
|
|
125
|
+
return {
|
|
126
|
+
ast: null,
|
|
127
|
+
usedDirectPath: false,
|
|
128
|
+
confidence: result.confidence,
|
|
129
|
+
lang,
|
|
130
|
+
fallbackText: englishText,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
ast: null,
|
|
135
|
+
usedDirectPath: false,
|
|
136
|
+
confidence: result.confidence,
|
|
137
|
+
lang,
|
|
138
|
+
fallbackText: null,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
async getAllTranslations(input, sourceLang) {
|
|
142
|
+
const semantic = await getSemanticModule();
|
|
143
|
+
const languages = semantic.getSupportedLanguages();
|
|
144
|
+
const results = {};
|
|
145
|
+
for (const lang of languages) {
|
|
146
|
+
results[lang] = await this.transform(input, sourceLang, lang);
|
|
147
|
+
}
|
|
148
|
+
return results;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
let _defaultBridge = null;
|
|
152
|
+
async function getDefaultBridge() {
|
|
153
|
+
if (!_defaultBridge) {
|
|
154
|
+
_defaultBridge = new SemanticGrammarBridge();
|
|
155
|
+
await _defaultBridge.initialize();
|
|
156
|
+
}
|
|
157
|
+
return _defaultBridge;
|
|
158
|
+
}
|
|
159
|
+
async function translate(input, sourceLang, targetLang) {
|
|
160
|
+
const bridge = await getDefaultBridge();
|
|
161
|
+
const result = await bridge.transform(input, sourceLang, targetLang);
|
|
162
|
+
return result.output;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
class MultilingualHyperscript {
|
|
166
|
+
constructor(config = {}) {
|
|
167
|
+
this.initialized = false;
|
|
168
|
+
this.bridge = new SemanticGrammarBridge(config);
|
|
169
|
+
}
|
|
170
|
+
async initialize() {
|
|
171
|
+
if (this.initialized)
|
|
172
|
+
return;
|
|
173
|
+
await this.bridge.initialize();
|
|
174
|
+
this.initialized = true;
|
|
175
|
+
}
|
|
176
|
+
isInitialized() {
|
|
177
|
+
return this.initialized;
|
|
178
|
+
}
|
|
179
|
+
async ensureInitialized() {
|
|
180
|
+
if (!this.initialized) {
|
|
181
|
+
await this.initialize();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async parse(input, lang = 'en') {
|
|
185
|
+
await this.ensureInitialized();
|
|
186
|
+
return this.bridge.parse(input, lang);
|
|
187
|
+
}
|
|
188
|
+
async parseToAST(input, lang = 'en') {
|
|
189
|
+
await this.ensureInitialized();
|
|
190
|
+
return this.bridge.parseToAST(input, lang);
|
|
191
|
+
}
|
|
192
|
+
async parseToASTWithDetails(input, lang = 'en') {
|
|
193
|
+
await this.ensureInitialized();
|
|
194
|
+
return this.bridge.parseToASTWithDetails(input, lang);
|
|
195
|
+
}
|
|
196
|
+
async translate(input, from, to) {
|
|
197
|
+
await this.ensureInitialized();
|
|
198
|
+
const result = await this.bridge.transform(input, from, to);
|
|
199
|
+
return result.output;
|
|
200
|
+
}
|
|
201
|
+
async translateWithDetails(input, from, to) {
|
|
202
|
+
await this.ensureInitialized();
|
|
203
|
+
return this.bridge.transform(input, from, to);
|
|
204
|
+
}
|
|
205
|
+
async render(node, lang) {
|
|
206
|
+
await this.ensureInitialized();
|
|
207
|
+
return this.bridge.render(node, lang);
|
|
208
|
+
}
|
|
209
|
+
async getAllTranslations(input, from) {
|
|
210
|
+
await this.ensureInitialized();
|
|
211
|
+
return this.bridge.getAllTranslations(input, from);
|
|
212
|
+
}
|
|
213
|
+
getSupportedLanguages() {
|
|
214
|
+
return [
|
|
215
|
+
'en',
|
|
216
|
+
'ja',
|
|
217
|
+
'ar',
|
|
218
|
+
'es',
|
|
219
|
+
'ko',
|
|
220
|
+
'zh',
|
|
221
|
+
'tr',
|
|
222
|
+
'pt',
|
|
223
|
+
'fr',
|
|
224
|
+
'de',
|
|
225
|
+
'id',
|
|
226
|
+
'qu',
|
|
227
|
+
'sw',
|
|
228
|
+
];
|
|
229
|
+
}
|
|
230
|
+
isLanguageSupported(lang) {
|
|
231
|
+
return this.getSupportedLanguages().includes(lang);
|
|
232
|
+
}
|
|
233
|
+
getLanguageInfo(lang) {
|
|
234
|
+
return LANGUAGE_INFO[lang];
|
|
235
|
+
}
|
|
236
|
+
getAllLanguageInfo() {
|
|
237
|
+
return { ...LANGUAGE_INFO };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const LANGUAGE_INFO = {
|
|
241
|
+
en: { code: 'en', name: 'English', nativeName: 'English', direction: 'ltr', wordOrder: 'SVO' },
|
|
242
|
+
ja: { code: 'ja', name: 'Japanese', nativeName: '日本語', direction: 'ltr', wordOrder: 'SOV' },
|
|
243
|
+
ar: { code: 'ar', name: 'Arabic', nativeName: 'العربية', direction: 'rtl', wordOrder: 'VSO' },
|
|
244
|
+
es: { code: 'es', name: 'Spanish', nativeName: 'Español', direction: 'ltr', wordOrder: 'SVO' },
|
|
245
|
+
ko: { code: 'ko', name: 'Korean', nativeName: '한국어', direction: 'ltr', wordOrder: 'SOV' },
|
|
246
|
+
zh: { code: 'zh', name: 'Chinese', nativeName: '中文', direction: 'ltr', wordOrder: 'SVO' },
|
|
247
|
+
tr: { code: 'tr', name: 'Turkish', nativeName: 'Türkçe', direction: 'ltr', wordOrder: 'SOV' },
|
|
248
|
+
pt: {
|
|
249
|
+
code: 'pt',
|
|
250
|
+
name: 'Portuguese',
|
|
251
|
+
nativeName: 'Português',
|
|
252
|
+
direction: 'ltr',
|
|
253
|
+
wordOrder: 'SVO',
|
|
254
|
+
},
|
|
255
|
+
fr: { code: 'fr', name: 'French', nativeName: 'Français', direction: 'ltr', wordOrder: 'SVO' },
|
|
256
|
+
de: { code: 'de', name: 'German', nativeName: 'Deutsch', direction: 'ltr', wordOrder: 'SVO' },
|
|
257
|
+
id: {
|
|
258
|
+
code: 'id',
|
|
259
|
+
name: 'Indonesian',
|
|
260
|
+
nativeName: 'Bahasa Indonesia',
|
|
261
|
+
direction: 'ltr',
|
|
262
|
+
wordOrder: 'SVO',
|
|
263
|
+
},
|
|
264
|
+
qu: { code: 'qu', name: 'Quechua', nativeName: 'Runasimi', direction: 'ltr', wordOrder: 'SOV' },
|
|
265
|
+
sw: { code: 'sw', name: 'Swahili', nativeName: 'Kiswahili', direction: 'ltr', wordOrder: 'SVO' },
|
|
266
|
+
};
|
|
267
|
+
let _defaultInstance = null;
|
|
268
|
+
async function getMultilingual() {
|
|
269
|
+
if (!_defaultInstance) {
|
|
270
|
+
_defaultInstance = new MultilingualHyperscript();
|
|
271
|
+
await _defaultInstance.initialize();
|
|
272
|
+
}
|
|
273
|
+
return _defaultInstance;
|
|
274
|
+
}
|
|
275
|
+
const multilingual = new MultilingualHyperscript();
|
|
276
|
+
|
|
277
|
+
export { MultilingualHyperscript, SemanticGrammarBridge, getDefaultBridge, getMultilingual, multilingual, translate };
|
|
278
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CommandNode, ASTNode, Token } from '../types';
|
|
2
|
+
import type { ParserContext } from '../parser-types';
|
|
3
|
+
export interface ParsedStatementResult {
|
|
4
|
+
node: CommandNode;
|
|
5
|
+
tokens: Token[];
|
|
6
|
+
context?: ParserContext;
|
|
7
|
+
metadata?: ParsingMetadata;
|
|
8
|
+
}
|
|
9
|
+
export interface ParsingMetadata {
|
|
10
|
+
duration?: number;
|
|
11
|
+
warnings?: string[];
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface ASTNodeAssertable extends CommandNode {
|
|
15
|
+
name: string;
|
|
16
|
+
type: 'Command';
|
|
17
|
+
children?: CommandNode[];
|
|
18
|
+
arguments: ASTNode[];
|
|
19
|
+
target?: ASTNode;
|
|
20
|
+
}
|
|
21
|
+
export declare function isCommandNode(node: unknown): node is CommandNode;
|
|
22
|
+
export declare function assertCommandNode(node: unknown): asserts node is CommandNode;
|
|
23
|
+
export declare function getNodeProperty<T = unknown>(node: unknown, property: string): T | undefined;
|
|
24
|
+
export declare function assertNodeHasProperty<T = unknown>(node: unknown, property: string): asserts node is Record<string, T>;
|
|
25
|
+
//# sourceMappingURL=test-helpers.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Token, CommandNode, ExpressionNode, ASTNode, StatementNode } from '../types/core';
|
|
2
|
+
export declare class CommandNodeBuilder {
|
|
3
|
+
private name;
|
|
4
|
+
private args;
|
|
5
|
+
private body?;
|
|
6
|
+
private implicitTarget?;
|
|
7
|
+
private isBlocking;
|
|
8
|
+
private modifiers?;
|
|
9
|
+
private originalCmd?;
|
|
10
|
+
private startPos?;
|
|
11
|
+
private endPos?;
|
|
12
|
+
private constructor();
|
|
13
|
+
static from(token: Token): CommandNodeBuilder;
|
|
14
|
+
static fromIdentifier(node: {
|
|
15
|
+
name: string;
|
|
16
|
+
start?: number;
|
|
17
|
+
end?: number;
|
|
18
|
+
line?: number;
|
|
19
|
+
column?: number;
|
|
20
|
+
}): CommandNodeBuilder;
|
|
21
|
+
static named(name: string): CommandNodeBuilder;
|
|
22
|
+
withArgs(...args: ASTNode[]): this;
|
|
23
|
+
withBody(body: StatementNode[]): this;
|
|
24
|
+
withImplicitTarget(target: ExpressionNode): this;
|
|
25
|
+
withModifier(key: string, value: ExpressionNode): this;
|
|
26
|
+
withModifiers(modifiers: Record<string, ExpressionNode>): this;
|
|
27
|
+
withName(name: string): this;
|
|
28
|
+
withOriginalCommand(name: string): this;
|
|
29
|
+
blocking(value?: boolean): this;
|
|
30
|
+
startingAt(source: Token | {
|
|
31
|
+
start?: number;
|
|
32
|
+
end?: number;
|
|
33
|
+
line?: number;
|
|
34
|
+
column?: number;
|
|
35
|
+
}): this;
|
|
36
|
+
endingAt(position: {
|
|
37
|
+
start?: number;
|
|
38
|
+
end: number;
|
|
39
|
+
line?: number;
|
|
40
|
+
column?: number;
|
|
41
|
+
}): this;
|
|
42
|
+
build(): CommandNode;
|
|
43
|
+
clone(): CommandNodeBuilder;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=command-node-builder.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ParserContext, IdentifierNode } from '../parser-types';
|
|
2
|
+
import type { Token } from '../../types/core';
|
|
3
|
+
export declare function parseMeasureCommand(ctx: ParserContext, identifierNode: IdentifierNode): import("../../types/core").CommandNode;
|
|
4
|
+
export declare function parseTransitionCommand(ctx: ParserContext, commandToken: Token): import("../../types/core").CommandNode;
|
|
5
|
+
//# sourceMappingURL=animation-commands.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ParserContext } from '../parser-types';
|
|
2
|
+
import type { Token } from '../../types/core';
|
|
3
|
+
export declare function parseWaitCommand(ctx: ParserContext, commandToken: Token): import("../../types/core").CommandNode;
|
|
4
|
+
export declare function parseInstallCommand(ctx: ParserContext, commandToken: Token): import("../../types/core").CommandNode;
|
|
5
|
+
//# sourceMappingURL=async-commands.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ParserContext, IdentifierNode } from '../parser-types';
|
|
2
|
+
import type { CommandNode, Token } from '../../types/core';
|
|
3
|
+
export declare function parseHaltCommand(ctx: ParserContext, identifierNode: IdentifierNode): CommandNode | null;
|
|
4
|
+
export declare function parseRepeatCommand(ctx: ParserContext, commandToken: Token): CommandNode;
|
|
5
|
+
export declare function parseIfCommand(ctx: ParserContext, commandToken: Token): CommandNode;
|
|
6
|
+
export declare function parseForCommand(ctx: ParserContext, commandToken: Token): CommandNode;
|
|
7
|
+
//# sourceMappingURL=control-flow-commands.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ParserContext, IdentifierNode } from '../parser-types';
|
|
2
|
+
import type { Token } from '../../types/core';
|
|
3
|
+
export declare function parseRemoveCommand(ctx: ParserContext, identifierNode: IdentifierNode): import("../../types/core").CommandNode;
|
|
4
|
+
export declare function parseToggleCommand(ctx: ParserContext, identifierNode: IdentifierNode): import("../../types/core").CommandNode;
|
|
5
|
+
export declare function parseAddCommand(ctx: ParserContext, commandToken: Token): import("../../types/core").CommandNode;
|
|
6
|
+
export declare function parsePutCommand(ctx: ParserContext, identifierNode: IdentifierNode): import("../../types/core").CommandNode | null;
|
|
7
|
+
export declare function parseSwapCommand(ctx: ParserContext, identifierNode: IdentifierNode): import("../../types/core").CommandNode;
|
|
8
|
+
//# sourceMappingURL=dom-commands.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ParserContext, IdentifierNode } from '../parser-types';
|
|
2
|
+
import type { CommandNode } from '../../types/core';
|
|
3
|
+
export declare function parseTriggerCommand(ctx: ParserContext, identifierNode: IdentifierNode): CommandNode | null;
|
|
4
|
+
//# sourceMappingURL=event-commands.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ParserContext, IdentifierNode } from '../parser-types';
|
|
2
|
+
import type { Token, CommandNode } from '../../types/core';
|
|
3
|
+
export declare function parseCompoundCommand(ctx: ParserContext, identifierNode: IdentifierNode): CommandNode | null;
|
|
4
|
+
export declare function parseRegularCommand(ctx: ParserContext, identifierNode: IdentifierNode): CommandNode;
|
|
5
|
+
export declare function parseMultiWordCommand(ctx: ParserContext, commandToken: Token, commandName: string): CommandNode | null;
|
|
6
|
+
export declare function parseFetchCommand(ctx: ParserContext, commandToken: Token): CommandNode;
|
|
7
|
+
export declare function parseJsCommand(ctx: ParserContext, identifierNode: IdentifierNode): CommandNode;
|
|
8
|
+
export declare function parseTellCommand(ctx: ParserContext, identifierNode: IdentifierNode): CommandNode;
|
|
9
|
+
//# sourceMappingURL=utility-commands.d.ts.map
|