@hyperfixi/core 3.3.0 → 4.0.1
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 +57 -179
- package/dist/ast-utils/index.cjs +74 -806
- package/dist/ast-utils/index.d.ts +1 -1
- package/dist/ast-utils/index.mjs +74 -805
- package/dist/ast-utils/interchange/engine-positions.d.ts +3 -0
- package/dist/ast-utils/interchange/index.d.ts +1 -2
- package/dist/hyperfixi.js +19 -2
- package/dist/index.d.ts +2 -22
- package/dist/index.mjs +3 -29128
- package/dist/lsp-metadata.cjs +77 -73
- package/dist/lsp-metadata.d.ts +4 -4
- package/dist/lsp-metadata.mjs +77 -73
- package/dist/metadata.cjs +34 -266
- package/dist/metadata.d.ts +31 -26
- package/dist/metadata.mjs +34 -266
- package/dist/multilingual/index.cjs +16 -382
- package/dist/multilingual/index.d.ts +4 -32
- package/dist/multilingual/index.mjs +15 -377
- package/dist/reference/index.cjs +67 -216
- package/dist/reference/index.d.ts +0 -3
- package/dist/reference/index.mjs +68 -216
- package/dist/version.d.ts +1 -1
- package/package.json +13 -179
- package/dist/__test-utils__/context-builders.d.ts +0 -42
- package/dist/__test-utils__/error-testing.d.ts +0 -18
- package/dist/__test-utils__/index.d.ts +0 -6
- package/dist/__test-utils__/mock-types.d.ts +0 -57
- package/dist/__test-utils__/parser-context-mock.d.ts +0 -7
- package/dist/__test-utils__/parser-helpers.d.ts +0 -38
- package/dist/api/hyperscript-api.d.ts +0 -90
- package/dist/api/lokascript-api.d.ts +0 -9
- package/dist/ast/command-slots.d.ts +0 -140
- package/dist/ast/guards.d.ts +0 -15
- package/dist/ast/legacy.d.ts +0 -15
- package/dist/ast/nodes.d.ts +0 -243
- package/dist/ast-utils/interchange/from-core.d.ts +0 -12
- package/dist/ast-utils/interchange/to-core.d.ts +0 -8
- package/dist/behaviors/boosted.d.ts +0 -29
- package/dist/behaviors/history-swap.d.ts +0 -24
- package/dist/behaviors/index.cjs +0 -1155
- package/dist/behaviors/index.d.ts +0 -4
- package/dist/behaviors/index.mjs +0 -1145
- package/dist/bundle-generator/executor-core.d.ts +0 -4
- package/dist/bundle-generator/generator.d.ts +0 -4
- package/dist/bundle-generator/index.cjs +0 -2804
- package/dist/bundle-generator/index.d.ts +0 -6
- package/dist/bundle-generator/index.mjs +0 -2779
- package/dist/bundle-generator/parser-templates.d.ts +0 -6
- package/dist/bundle-generator/template-capabilities.d.ts +0 -12
- package/dist/bundle-generator/templates.d.ts +0 -12
- package/dist/bundle-generator/types.d.ts +0 -34
- package/dist/chunks/bridge-CI9SOl8u.js +0 -2
- package/dist/chunks/browser-modular-7CpI5VF2.js +0 -2
- package/dist/chunks/index-BwXDEK0m.js +0 -2
- package/dist/chunks/index-DQi2o8Lk.js +0 -2
- package/dist/chunks/index-uCOQ8Qn0.js +0 -2
- package/dist/commands/advanced/js.d.ts +0 -40
- package/dist/commands/animation/measure.d.ts +0 -43
- package/dist/commands/animation/settle.d.ts +0 -38
- package/dist/commands/animation/start-view-transition.d.ts +0 -38
- package/dist/commands/animation/take.d.ts +0 -41
- package/dist/commands/animation/transition.d.ts +0 -49
- package/dist/commands/async/fetch.d.ts +0 -61
- package/dist/commands/async/wait.d.ts +0 -51
- package/dist/commands/behaviors/install.d.ts +0 -40
- package/dist/commands/content/append.d.ts +0 -26
- package/dist/commands/content/insertion-base.d.ts +0 -60
- package/dist/commands/content/prepend.d.ts +0 -26
- package/dist/commands/control-flow/break.d.ts +0 -29
- package/dist/commands/control-flow/continue.d.ts +0 -29
- package/dist/commands/control-flow/exit.d.ts +0 -29
- package/dist/commands/control-flow/halt.d.ts +0 -39
- package/dist/commands/control-flow/if.d.ts +0 -58
- package/dist/commands/control-flow/repeat.d.ts +0 -50
- package/dist/commands/control-flow/return.d.ts +0 -33
- package/dist/commands/control-flow/signal-base.d.ts +0 -18
- package/dist/commands/control-flow/throw.d.ts +0 -34
- package/dist/commands/control-flow/unless.d.ts +0 -3
- package/dist/commands/data/clear.d.ts +0 -37
- package/dist/commands/data/decrement.d.ts +0 -3
- package/dist/commands/data/default.d.ts +0 -60
- package/dist/commands/data/get.d.ts +0 -35
- package/dist/commands/data/increment.d.ts +0 -42
- package/dist/commands/data/set.d.ts +0 -76
- package/dist/commands/decorators/index.d.ts +0 -14
- package/dist/commands/dom/add.d.ts +0 -44
- package/dist/commands/dom/close.d.ts +0 -32
- package/dist/commands/dom/dom-modification-base.d.ts +0 -48
- package/dist/commands/dom/empty.d.ts +0 -32
- package/dist/commands/dom/hide.d.ts +0 -28
- package/dist/commands/dom/make.d.ts +0 -34
- package/dist/commands/dom/open.d.ts +0 -34
- package/dist/commands/dom/process-partials.d.ts +0 -51
- package/dist/commands/dom/put.d.ts +0 -42
- package/dist/commands/dom/remove.d.ts +0 -46
- package/dist/commands/dom/reset.d.ts +0 -32
- package/dist/commands/dom/select.d.ts +0 -32
- package/dist/commands/dom/show.d.ts +0 -29
- package/dist/commands/dom/swap.d.ts +0 -65
- package/dist/commands/dom/toggle.d.ts +0 -69
- package/dist/commands/dom/visibility-base.d.ts +0 -22
- package/dist/commands/events/send.d.ts +0 -3
- package/dist/commands/events/trigger.d.ts +0 -49
- package/dist/commands/execution/blur.d.ts +0 -32
- package/dist/commands/execution/call.d.ts +0 -35
- package/dist/commands/execution/focus.d.ts +0 -32
- package/dist/commands/execution/pseudo-command.d.ts +0 -41
- package/dist/commands/helpers/attribute-manipulation.d.ts +0 -11
- package/dist/commands/helpers/attribute-target.d.ts +0 -9
- package/dist/commands/helpers/batch-dom-operations.d.ts +0 -12
- package/dist/commands/helpers/body-ops.d.ts +0 -10
- package/dist/commands/helpers/class-manipulation.d.ts +0 -11
- package/dist/commands/helpers/condition-helpers.d.ts +0 -4
- package/dist/commands/helpers/dom-mutation.d.ts +0 -16
- package/dist/commands/helpers/duration-parsing.d.ts +0 -8
- package/dist/commands/helpers/element-property-access.d.ts +0 -7
- package/dist/commands/helpers/element-resolution.d.ts +0 -16
- package/dist/commands/helpers/error-helpers.d.ts +0 -17
- package/dist/commands/helpers/event-helpers.d.ts +0 -13
- package/dist/commands/helpers/event-waiting.d.ts +0 -37
- package/dist/commands/helpers/index.d.ts +0 -32
- package/dist/commands/helpers/input-validator.d.ts +0 -23
- package/dist/commands/helpers/loop-executor.d.ts +0 -56
- package/dist/commands/helpers/numeric-target-parser.d.ts +0 -21
- package/dist/commands/helpers/property-target.d.ts +0 -20
- package/dist/commands/helpers/selector-type-detection.d.ts +0 -24
- package/dist/commands/helpers/slots.d.ts +0 -5
- package/dist/commands/helpers/smart-element.d.ts +0 -16
- package/dist/commands/helpers/style-manipulation.d.ts +0 -16
- package/dist/commands/helpers/target-elements.d.ts +0 -5
- package/dist/commands/helpers/temporal-modifiers.d.ts +0 -15
- package/dist/commands/helpers/url-argument-parser.d.ts +0 -13
- package/dist/commands/helpers/url-validation.d.ts +0 -7
- package/dist/commands/helpers/variable-access.d.ts +0 -13
- package/dist/commands/helpers/visibility-target-parser.d.ts +0 -15
- package/dist/commands/helpers/write-target.d.ts +0 -42
- package/dist/commands/index.cjs +0 -24168
- package/dist/commands/index.d.ts +0 -171
- package/dist/commands/index.mjs +0 -23981
- package/dist/commands/manifest.d.ts +0 -17
- package/dist/commands/navigation/go.d.ts +0 -58
- package/dist/commands/navigation/push-url.d.ts +0 -48
- package/dist/commands/navigation/replace-url.d.ts +0 -3
- package/dist/commands/navigation/scroll-to.d.ts +0 -43
- package/dist/commands/templates/render.d.ts +0 -47
- package/dist/commands/utility/beep.d.ts +0 -41
- package/dist/commands/utility/breakpoint.d.ts +0 -32
- package/dist/commands/utility/copy.d.ts +0 -41
- package/dist/commands/utility/log.d.ts +0 -36
- package/dist/commands/utility/pick.d.ts +0 -47
- package/dist/commands/utility/tell.d.ts +0 -39
- package/dist/compatibility/browser-bundle-classic.d.ts +0 -17
- package/dist/compatibility/browser-bundle-hybrid-complete.d.ts +0 -22
- package/dist/compatibility/browser-bundle-hybrid-hx.d.ts +0 -43
- package/dist/compatibility/browser-bundle-lite.d.ts +0 -15
- package/dist/compatibility/browser-bundle-modular.d.ts +0 -18
- package/dist/compatibility/browser-bundle-multilingual.d.ts +0 -19
- package/dist/compatibility/browser-bundle-semantic-complete.d.ts +0 -24
- package/dist/compatibility/browser-bundle-textshelf-minimal.d.ts +0 -16
- package/dist/compatibility/browser-bundle-textshelf-profile.d.ts +0 -18
- package/dist/compatibility/browser-modular.d.ts +0 -42
- package/dist/compatibility/browser-tests/helpers/semantic-page.d.ts +0 -3
- package/dist/compatibility/browser-tests/test-utils.d.ts +0 -21
- package/dist/compatibility/bundle-shell.d.ts +0 -13
- package/dist/compatibility/bundle-sources.d.ts +0 -4
- package/dist/compatibility/eval-hyperscript.d.ts +0 -16
- package/dist/compatibility/hyperscript-adapter.d.ts +0 -38
- package/dist/core/ast-property-utils.d.ts +0 -2
- package/dist/core/context.d.ts +0 -19
- package/dist/core/dom.d.ts +0 -15
- package/dist/core/evaluator-types.d.ts +0 -5
- package/dist/core/events.d.ts +0 -48
- package/dist/core/executor.d.ts +0 -34
- package/dist/core/expression-evaluator.d.ts +0 -6
- package/dist/core/expression-registry.d.ts +0 -8
- package/dist/core/scope-hooks.d.ts +0 -24
- package/dist/debug/debug-controller.d.ts +0 -62
- package/dist/debug/index.d.ts +0 -5
- package/dist/dom/attribute-processor.d.ts +0 -75
- package/dist/dom/detect-language.d.ts +0 -3
- package/dist/dom/minimal-attribute-processor.d.ts +0 -20
- package/dist/expressions/base-expression.d.ts +0 -27
- package/dist/expressions/bundles/common-expressions.d.ts +0 -10
- package/dist/expressions/bundles/core-expressions.d.ts +0 -8
- package/dist/expressions/bundles/full-expressions.d.ts +0 -11
- package/dist/expressions/bundles/index.d.ts +0 -7
- package/dist/expressions/collection/index.d.ts +0 -10
- package/dist/expressions/conversion/index.d.ts +0 -31
- package/dist/expressions/expression-tiers.d.ts +0 -13
- package/dist/expressions/index.cjs +0 -4331
- package/dist/expressions/index.d.ts +0 -13
- package/dist/expressions/index.mjs +0 -4312
- package/dist/expressions/logical/index.d.ts +0 -61
- package/dist/expressions/mathematical/index.d.ts +0 -80
- package/dist/expressions/positional/index.d.ts +0 -31
- package/dist/expressions/properties/index.d.ts +0 -27
- package/dist/expressions/property-access-utils.d.ts +0 -23
- package/dist/expressions/references/index.d.ts +0 -39
- package/dist/expressions/shared/comparison-utils.d.ts +0 -10
- package/dist/expressions/shared/index.d.ts +0 -10
- package/dist/expressions/shared/number-utils.d.ts +0 -8
- package/dist/expressions/shared/tracking.d.ts +0 -20
- package/dist/expressions/shared/validation-utils.d.ts +0 -13
- package/dist/expressions/special/index.d.ts +0 -78
- package/dist/expressions/type-helpers.d.ts +0 -11
- package/dist/expressions/type-registry.d.ts +0 -57
- package/dist/expressions/validation-helpers.d.ts +0 -15
- package/dist/htmx/hcon.d.ts +0 -9
- package/dist/htmx/htmx-attribute-processor.d.ts +0 -120
- package/dist/htmx/htmx-translator.d.ts +0 -22
- package/dist/htmx/i18n-hooks.d.ts +0 -18
- package/dist/htmx/i18n-orchestrator.d.ts +0 -16
- package/dist/htmx/index.d.ts +0 -3
- package/dist/htmx/lang-resolver.d.ts +0 -3
- package/dist/htmx/sse.d.ts +0 -60
- package/dist/htmx/ws.d.ts +0 -59
- package/dist/hyperfixi-browser-classic-i18n.js +0 -2
- package/dist/hyperfixi-browser.js +0 -2
- package/dist/hyperfixi-classic-i18n.js +0 -2
- package/dist/hyperfixi-hx-v4.js +0 -1
- package/dist/hyperfixi-hx.js +0 -1
- package/dist/hyperfixi-hybrid-complete.js +0 -1
- package/dist/hyperfixi-hybrid-hx.js +0 -1
- package/dist/hyperfixi-multilingual.js +0 -2
- package/dist/hyperfixi.mjs +0 -2
- package/dist/i18n/error-catalog.d.ts +0 -12
- package/dist/index.cjs +0 -29159
- package/dist/index.min.js +0 -2
- package/dist/lib/dom-globals-shim.d.ts +0 -2
- package/dist/lib/index.d.ts +0 -4
- package/dist/lib/morph-adapter.d.ts +0 -9
- package/dist/lib/swap-executor.d.ts +0 -12
- package/dist/lib/view-transitions.d.ts +0 -7
- package/dist/lokascript-browser-classic-i18n.js +0 -2
- package/dist/lokascript-browser.js +0 -2
- package/dist/lokascript-hybrid-complete.js +0 -1
- package/dist/lokascript-hybrid-hx.js +0 -1
- package/dist/lokascript-multilingual.js +0 -2
- package/dist/lse/index.cjs +0 -84
- package/dist/lse/index.d.ts +0 -15
- package/dist/lse/index.mjs +0 -71
- package/dist/multilingual/bridge.d.ts +0 -38
- package/dist/multilingual/schema-roles.d.ts +0 -3
- package/dist/parser/__types__/test-helpers.d.ts +0 -25
- package/dist/parser/command-grammar.d.ts +0 -14
- package/dist/parser/command-node-builder.d.ts +0 -46
- package/dist/parser/command-parsers/animation-commands.d.ts +0 -6
- package/dist/parser/command-parsers/async-commands.d.ts +0 -5
- package/dist/parser/command-parsers/control-flow-commands.d.ts +0 -7
- package/dist/parser/command-parsers/declared-commands.d.ts +0 -6
- package/dist/parser/command-parsers/dom-commands.d.ts +0 -11
- package/dist/parser/command-parsers/event-commands.d.ts +0 -4
- package/dist/parser/command-parsers/navigation-commands.d.ts +0 -6
- package/dist/parser/command-parsers/utility-commands.d.ts +0 -14
- package/dist/parser/command-parsers/variable-commands.d.ts +0 -12
- package/dist/parser/error-handler.d.ts +0 -34
- package/dist/parser/extensions.d.ts +0 -43
- package/dist/parser/full-parser.cjs +0 -7943
- package/dist/parser/full-parser.d.ts +0 -4
- package/dist/parser/full-parser.mjs +0 -7940
- package/dist/parser/helpers/ast-helpers.d.ts +0 -24
- package/dist/parser/helpers/parsing-helpers.d.ts +0 -19
- package/dist/parser/helpers/token-helpers.d.ts +0 -28
- package/dist/parser/hybrid/aliases.cjs +0 -44
- package/dist/parser/hybrid/aliases.d.ts +0 -7
- package/dist/parser/hybrid/aliases.mjs +0 -37
- package/dist/parser/hybrid/ast-types.cjs +0 -3
- package/dist/parser/hybrid/ast-types.d.ts +0 -97
- package/dist/parser/hybrid/ast-types.mjs +0 -2
- package/dist/parser/hybrid/index.cjs +0 -1185
- package/dist/parser/hybrid/index.d.ts +0 -6
- package/dist/parser/hybrid/index.mjs +0 -1175
- package/dist/parser/hybrid/parser-core.cjs +0 -1171
- package/dist/parser/hybrid/parser-core.d.ts +0 -69
- package/dist/parser/hybrid/parser-core.mjs +0 -1169
- package/dist/parser/hybrid/tokenizer.cjs +0 -255
- package/dist/parser/hybrid/tokenizer.d.ts +0 -9
- package/dist/parser/hybrid/tokenizer.mjs +0 -252
- package/dist/parser/hybrid-parser.cjs +0 -1249
- package/dist/parser/hybrid-parser.d.ts +0 -10
- package/dist/parser/hybrid-parser.mjs +0 -1242
- package/dist/parser/parser-constants.d.ts +0 -100
- package/dist/parser/parser-interface.d.ts +0 -12
- package/dist/parser/parser-types.d.ts +0 -164
- package/dist/parser/parser.d.ts +0 -165
- package/dist/parser/pratt-parser.d.ts +0 -41
- package/dist/parser/regex-parser.cjs +0 -422
- package/dist/parser/regex-parser.d.ts +0 -4
- package/dist/parser/regex-parser.mjs +0 -419
- package/dist/parser/runtime.d.ts +0 -14
- package/dist/parser/semantic-integration.d.ts +0 -17
- package/dist/parser/token-consumer.d.ts +0 -34
- package/dist/parser/token-predicates.d.ts +0 -77
- package/dist/parser/tokenizer.d.ts +0 -28
- package/dist/parser/types.d.ts +0 -105
- package/dist/performance/expression-cache.d.ts +0 -78
- package/dist/performance/integration.d.ts +0 -40
- package/dist/performance/production-monitor.d.ts +0 -67
- package/dist/registry/browser-types.cjs +0 -81
- package/dist/registry/browser-types.d.ts +0 -20
- package/dist/registry/browser-types.mjs +0 -76
- package/dist/registry/environment.cjs +0 -36
- package/dist/registry/environment.d.ts +0 -19
- package/dist/registry/environment.mjs +0 -30
- package/dist/registry/event-source-registry.d.ts +0 -54
- package/dist/registry/examples/server-commands.d.ts +0 -6
- package/dist/registry/examples/server-event-source.d.ts +0 -32
- package/dist/registry/index.cjs +0 -14055
- package/dist/registry/index.d.ts +0 -39
- package/dist/registry/index.mjs +0 -14039
- package/dist/registry/runtime-integration.d.ts +0 -23
- package/dist/registry/universal-types.cjs +0 -91
- package/dist/registry/universal-types.d.ts +0 -35
- package/dist/registry/universal-types.mjs +0 -86
- package/dist/runtime/cleanup-registry.d.ts +0 -47
- package/dist/runtime/command-adapter.d.ts +0 -69
- package/dist/runtime/environment.d.ts +0 -75
- package/dist/runtime/plugin.d.ts +0 -14
- package/dist/runtime/runtime-base.d.ts +0 -100
- package/dist/runtime/runtime-factory.d.ts +0 -29
- package/dist/runtime/runtime.d.ts +0 -20
- package/dist/runtime/temporal-modifiers.d.ts +0 -37
- package/dist/test-setup.d.ts +0 -28
- package/dist/test-utilities.d.ts +0 -39
- package/dist/types/base-types.d.ts +0 -231
- package/dist/types/code-fix.d.ts +0 -39
- package/dist/types/command-metadata.d.ts +0 -57
- package/dist/types/command-types.d.ts +0 -262
- package/dist/types/context-types.d.ts +0 -106
- package/dist/types/core-context.d.ts +0 -22
- package/dist/types/core.d.ts +0 -143
- package/dist/types/error-codes.d.ts +0 -207
- package/dist/types/expression-types.d.ts +0 -155
- package/dist/types/hooks.d.ts +0 -45
- package/dist/types/index.d.ts +0 -32
- package/dist/types/program.d.ts +0 -8
- package/dist/types/result.d.ts +0 -73
- package/dist/types/template-types.d.ts +0 -162
- package/dist/types/type-guards.d.ts +0 -24
- package/dist/types/unified-types.d.ts +0 -91
- package/dist/utils/beep.d.ts +0 -8
- package/dist/utils/debug-events.d.ts +0 -41
- package/dist/utils/debug.d.ts +0 -35
- package/dist/utils/dom-utils.d.ts +0 -16
- package/dist/utils/element-check.d.ts +0 -8
- package/dist/utils/keyboard-shortcuts.d.ts +0 -18
- package/dist/utils/performance.d.ts +0 -40
- package/dist/validation/command-pattern-validator.d.ts +0 -53
- package/dist/validation/common-validators.d.ts +0 -24
- package/dist/validation/lightweight-validators.d.ts +0 -113
- package/dist/validation/partial-validation-types.d.ts +0 -50
- package/dist/validation/partial-validator.d.ts +0 -6
- package/dist/validation/partial-warning-formatter.d.ts +0 -6
- package/dist/validation/validate-cli.d.ts +0 -41
- package/vocab/htmx/ar.js +0 -62
- package/vocab/htmx/bn.js +0 -65
- package/vocab/htmx/de.js +0 -83
- package/vocab/htmx/en.js +0 -24
- package/vocab/htmx/es.js +0 -79
- package/vocab/htmx/fr.js +0 -79
- package/vocab/htmx/he.js +0 -61
- package/vocab/htmx/hi.js +0 -81
- package/vocab/htmx/id.js +0 -76
- package/vocab/htmx/it.js +0 -79
- package/vocab/htmx/ja.js +0 -85
- package/vocab/htmx/ko.js +0 -81
- package/vocab/htmx/ms.js +0 -58
- package/vocab/htmx/pl.js +0 -80
- package/vocab/htmx/pt.js +0 -81
- package/vocab/htmx/qu.js +0 -83
- package/vocab/htmx/ru.js +0 -82
- package/vocab/htmx/sw.js +0 -79
- package/vocab/htmx/th.js +0 -67
- package/vocab/htmx/tl.js +0 -56
- package/vocab/htmx/tr.js +0 -86
- package/vocab/htmx/uk.js +0 -82
- package/vocab/htmx/vi.js +0 -59
- package/vocab/htmx/zh.js +0 -79
|
@@ -1,394 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function checkDebugEnabled() {
|
|
9
|
-
if (typeof localStorage !== 'undefined') {
|
|
10
|
-
try {
|
|
11
|
-
const ls = localStorage;
|
|
12
|
-
const setting = ls.getItem('hyperfixi:debug') || ls.getItem('lokascript:debug');
|
|
13
|
-
if (setting === '*' || setting === 'true')
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (typeof window !== 'undefined' && window.__HYPERFIXI_DEBUG__) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
if (typeof process !== 'undefined' && process.env?.HYPERFIXI_DEBUG === 'true') {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
3
|
+
let semanticModule = null;
|
|
4
|
+
async function semantic() {
|
|
5
|
+
semanticModule ?? (semanticModule = await import('@lokascript/semantic'));
|
|
6
|
+
return semanticModule;
|
|
26
7
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
commands: isDebugEnabled,
|
|
30
|
-
events: isDebugEnabled,
|
|
31
|
-
parsing: isDebugEnabled,
|
|
32
|
-
expressions: isDebugEnabled,
|
|
33
|
-
styles: isDebugEnabled,
|
|
34
|
-
runtime: isDebugEnabled,
|
|
35
|
-
loops: isDebugEnabled,
|
|
36
|
-
async: isDebugEnabled,
|
|
37
|
-
};
|
|
38
|
-
const debug = {
|
|
39
|
-
command: (...args) => {
|
|
40
|
-
if (DEBUG.commands)
|
|
41
|
-
console.log('\ud83d\udd27', ...args);
|
|
42
|
-
},
|
|
43
|
-
event: (...args) => {
|
|
44
|
-
if (DEBUG.events)
|
|
45
|
-
console.log('\ud83c\udfaf', ...args);
|
|
46
|
-
},
|
|
47
|
-
parse: (...args) => {
|
|
48
|
-
if (DEBUG.parsing)
|
|
49
|
-
console.log('\ud83d\udcdd', ...args);
|
|
50
|
-
},
|
|
51
|
-
expr: (...args) => {
|
|
52
|
-
if (DEBUG.expressions)
|
|
53
|
-
console.log('\ud83d\udd0d', ...args);
|
|
54
|
-
},
|
|
55
|
-
expressions: (...args) => {
|
|
56
|
-
if (DEBUG.expressions)
|
|
57
|
-
console.log('\ud83d\udd0d', ...args);
|
|
58
|
-
},
|
|
59
|
-
style: (...args) => {
|
|
60
|
-
if (DEBUG.styles)
|
|
61
|
-
console.log('\ud83c\udfa8', ...args);
|
|
62
|
-
},
|
|
63
|
-
runtime: (...args) => {
|
|
64
|
-
if (DEBUG.runtime)
|
|
65
|
-
console.log('\ud83d\ude80', ...args);
|
|
66
|
-
},
|
|
67
|
-
loop: (...args) => {
|
|
68
|
-
if (DEBUG.loops)
|
|
69
|
-
console.log('\ud83d\udd01', ...args);
|
|
70
|
-
},
|
|
71
|
-
async: (...args) => {
|
|
72
|
-
if (DEBUG.async)
|
|
73
|
-
console.log('\u23f3', ...args);
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
function unconsumedInputWarnings(node) {
|
|
78
|
-
const diagnostics = node
|
|
79
|
-
.diagnostics;
|
|
80
|
-
if (!diagnostics?.length)
|
|
81
|
-
return [];
|
|
82
|
-
return diagnostics.filter(d => d.code === 'unconsumed-input').map(d => d.message);
|
|
83
|
-
}
|
|
84
|
-
let _semanticModule = null;
|
|
85
|
-
async function getSemanticModule() {
|
|
86
|
-
if (!_semanticModule) {
|
|
87
|
-
_semanticModule = await import('@lokascript/semantic');
|
|
88
|
-
}
|
|
89
|
-
return _semanticModule;
|
|
8
|
+
async function parse(input, lang = 'en') {
|
|
9
|
+
return (await semantic()).parseSemantic(input, lang).node ?? null;
|
|
90
10
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this._initialized = false;
|
|
94
|
-
this.config = {
|
|
95
|
-
confidenceThreshold: config.confidenceThreshold ?? DEFAULT_CONFIDENCE_THRESHOLD,
|
|
96
|
-
fallbackOnLowConfidence: config.fallbackOnLowConfidence ?? true,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
async initialize() {
|
|
100
|
-
await getSemanticModule();
|
|
101
|
-
this._initialized = true;
|
|
102
|
-
}
|
|
103
|
-
isInitialized() {
|
|
104
|
-
return this._initialized;
|
|
105
|
-
}
|
|
106
|
-
async transform(input, sourceLang, targetLang) {
|
|
107
|
-
if (!this.isInitialized()) {
|
|
108
|
-
await this.initialize();
|
|
109
|
-
}
|
|
110
|
-
if (sourceLang === targetLang) {
|
|
111
|
-
return {
|
|
112
|
-
output: input,
|
|
113
|
-
usedSemantic: false,
|
|
114
|
-
confidence: 1.0,
|
|
115
|
-
sourceLang,
|
|
116
|
-
targetLang,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
const semantic = await getSemanticModule();
|
|
120
|
-
try {
|
|
121
|
-
const output = semantic.translate(input, sourceLang, targetLang);
|
|
122
|
-
if (output !== input) {
|
|
123
|
-
return {
|
|
124
|
-
output,
|
|
125
|
-
usedSemantic: true,
|
|
126
|
-
confidence: 0.9,
|
|
127
|
-
sourceLang,
|
|
128
|
-
targetLang,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
catch {
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
output: input,
|
|
136
|
-
usedSemantic: false,
|
|
137
|
-
confidence: 0,
|
|
138
|
-
sourceLang,
|
|
139
|
-
targetLang,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
async parse(input, lang) {
|
|
143
|
-
if (!this.isInitialized()) {
|
|
144
|
-
await this.initialize();
|
|
145
|
-
}
|
|
146
|
-
const semantic = await getSemanticModule();
|
|
147
|
-
const result = semantic.parseSemantic(input, lang);
|
|
148
|
-
return result.node ?? null;
|
|
149
|
-
}
|
|
150
|
-
async render(node, targetLang) {
|
|
151
|
-
const semantic = await getSemanticModule();
|
|
152
|
-
return semantic.render(node, targetLang);
|
|
153
|
-
}
|
|
154
|
-
async parseToAST(input, lang) {
|
|
155
|
-
if (!this.isInitialized()) {
|
|
156
|
-
await this.initialize();
|
|
157
|
-
}
|
|
158
|
-
const semantic = await getSemanticModule();
|
|
159
|
-
const result = semantic.parseSemantic(input, lang);
|
|
160
|
-
if (result.confidence >= this.config.confidenceThreshold && result.node) {
|
|
161
|
-
try {
|
|
162
|
-
const buildResult = semantic.buildAST(result.node);
|
|
163
|
-
return buildResult.ast;
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
debug.runtime('[SemanticGrammarBridge] AST build failed, using fallback:', error);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
async parseToASTWithDetails(input, lang) {
|
|
172
|
-
if (!this.isInitialized()) {
|
|
173
|
-
await this.initialize();
|
|
174
|
-
}
|
|
175
|
-
const semantic = await getSemanticModule();
|
|
176
|
-
const result = semantic.parseSemantic(input, lang);
|
|
177
|
-
if (result.confidence >= this.config.confidenceThreshold && result.node) {
|
|
178
|
-
try {
|
|
179
|
-
const buildResult = semantic.buildAST(result.node);
|
|
180
|
-
return {
|
|
181
|
-
ast: buildResult.ast,
|
|
182
|
-
usedDirectPath: true,
|
|
183
|
-
confidence: result.confidence,
|
|
184
|
-
lang,
|
|
185
|
-
fallbackText: null,
|
|
186
|
-
warnings: [...(buildResult.warnings ?? []), ...unconsumedInputWarnings(result.node)],
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
catch {
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
if (result.node && this.config.fallbackOnLowConfidence) {
|
|
193
|
-
const englishText = semantic.render(result.node, 'en');
|
|
194
|
-
return {
|
|
195
|
-
ast: null,
|
|
196
|
-
usedDirectPath: false,
|
|
197
|
-
confidence: result.confidence,
|
|
198
|
-
lang,
|
|
199
|
-
fallbackText: englishText,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
return {
|
|
203
|
-
ast: null,
|
|
204
|
-
usedDirectPath: false,
|
|
205
|
-
confidence: result.confidence,
|
|
206
|
-
lang,
|
|
207
|
-
fallbackText: null,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
async getAllTranslations(input, sourceLang) {
|
|
211
|
-
const semantic = await getSemanticModule();
|
|
212
|
-
const languages = semantic.getSupportedLanguages();
|
|
213
|
-
const results = {};
|
|
214
|
-
for (const lang of languages) {
|
|
215
|
-
results[lang] = await this.transform(input, sourceLang, lang);
|
|
216
|
-
}
|
|
217
|
-
return results;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
let _defaultBridge = null;
|
|
221
|
-
async function getDefaultBridge() {
|
|
222
|
-
if (!_defaultBridge) {
|
|
223
|
-
_defaultBridge = new SemanticGrammarBridge();
|
|
224
|
-
await _defaultBridge.initialize();
|
|
225
|
-
}
|
|
226
|
-
return _defaultBridge;
|
|
11
|
+
async function render(node, lang) {
|
|
12
|
+
return (await semantic()).render(node, lang);
|
|
227
13
|
}
|
|
228
14
|
async function translate(input, sourceLang, targetLang) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const INTERCHANGE_ADAPTER = {
|
|
235
|
-
getIdentifierName(node) {
|
|
236
|
-
if (node.type !== 'identifier')
|
|
237
|
-
return undefined;
|
|
238
|
-
const ident = node;
|
|
239
|
-
if (typeof ident.name === 'string' && ident.name !== '')
|
|
240
|
-
return ident.name;
|
|
241
|
-
if (typeof ident.value === 'string')
|
|
242
|
-
return ident.value;
|
|
243
|
-
return undefined;
|
|
244
|
-
},
|
|
245
|
-
convertValue(node) {
|
|
246
|
-
return node;
|
|
247
|
-
},
|
|
248
|
-
createLiteralValue(text) {
|
|
249
|
-
return { type: 'literal', value: text };
|
|
250
|
-
},
|
|
251
|
-
};
|
|
252
|
-
const schemaRoleInferrer = (name, args, modifiers, target) => {
|
|
253
|
-
const schema = semantic.getSchema(name);
|
|
254
|
-
if (!schema)
|
|
255
|
-
return null;
|
|
256
|
-
const inferred = intent.inferRolesFromSchema(schema, args, modifiers, target, INTERCHANGE_ADAPTER);
|
|
257
|
-
const declared = schema.ast
|
|
258
|
-
?.modifiers;
|
|
259
|
-
if (declared && modifiers) {
|
|
260
|
-
for (const [key, role] of Object.entries(declared)) {
|
|
261
|
-
const value = modifiers[key];
|
|
262
|
-
const isNode = !!value && typeof value === 'object' && 'type' in value;
|
|
263
|
-
if (isNode && inferred[role] === undefined) {
|
|
264
|
-
inferred[role] = value;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return Object.keys(inferred).length > 0
|
|
269
|
-
? inferred
|
|
270
|
-
: null;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
class MultilingualHyperscript {
|
|
274
|
-
constructor(config = {}) {
|
|
275
|
-
this.initialized = false;
|
|
276
|
-
this.bridge = new SemanticGrammarBridge(config);
|
|
277
|
-
}
|
|
278
|
-
async initialize() {
|
|
279
|
-
if (this.initialized)
|
|
280
|
-
return;
|
|
281
|
-
await this.bridge.initialize();
|
|
282
|
-
this.initialized = true;
|
|
283
|
-
}
|
|
284
|
-
isInitialized() {
|
|
285
|
-
return this.initialized;
|
|
286
|
-
}
|
|
287
|
-
async ensureInitialized() {
|
|
288
|
-
if (!this.initialized) {
|
|
289
|
-
await this.initialize();
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
async parse(input, lang = 'en') {
|
|
293
|
-
await this.ensureInitialized();
|
|
294
|
-
return this.bridge.parse(input, lang);
|
|
295
|
-
}
|
|
296
|
-
async parseToAST(input, lang = 'en') {
|
|
297
|
-
await this.ensureInitialized();
|
|
298
|
-
return this.bridge.parseToAST(input, lang);
|
|
299
|
-
}
|
|
300
|
-
async parseToASTWithDetails(input, lang = 'en') {
|
|
301
|
-
await this.ensureInitialized();
|
|
302
|
-
return this.bridge.parseToASTWithDetails(input, lang);
|
|
15
|
+
if (sourceLang === targetLang)
|
|
16
|
+
return input;
|
|
17
|
+
try {
|
|
18
|
+
return (await semantic()).translate(input, sourceLang, targetLang);
|
|
303
19
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
const result = await this.bridge.transform(input, from, to);
|
|
307
|
-
return result.output;
|
|
308
|
-
}
|
|
309
|
-
async translateWithDetails(input, from, to) {
|
|
310
|
-
await this.ensureInitialized();
|
|
311
|
-
return this.bridge.transform(input, from, to);
|
|
312
|
-
}
|
|
313
|
-
async render(node, lang) {
|
|
314
|
-
await this.ensureInitialized();
|
|
315
|
-
return this.bridge.render(node, lang);
|
|
316
|
-
}
|
|
317
|
-
async getAllTranslations(input, from) {
|
|
318
|
-
await this.ensureInitialized();
|
|
319
|
-
const all = await this.bridge.getAllTranslations(input, from);
|
|
320
|
-
const supported = new Set(this.getSupportedLanguages());
|
|
321
|
-
return Object.fromEntries(Object.entries(all).filter(([lang]) => supported.has(lang)));
|
|
322
|
-
}
|
|
323
|
-
getSupportedLanguages() {
|
|
324
|
-
return [
|
|
325
|
-
'en',
|
|
326
|
-
'ja',
|
|
327
|
-
'ar',
|
|
328
|
-
'es',
|
|
329
|
-
'ko',
|
|
330
|
-
'zh',
|
|
331
|
-
'tr',
|
|
332
|
-
'pt',
|
|
333
|
-
'fr',
|
|
334
|
-
'de',
|
|
335
|
-
'id',
|
|
336
|
-
'qu',
|
|
337
|
-
'sw',
|
|
338
|
-
];
|
|
339
|
-
}
|
|
340
|
-
isLanguageSupported(lang) {
|
|
341
|
-
return this.getSupportedLanguages().includes(lang);
|
|
342
|
-
}
|
|
343
|
-
getLanguageInfo(lang) {
|
|
344
|
-
return LANGUAGE_INFO[lang];
|
|
345
|
-
}
|
|
346
|
-
getAllLanguageInfo() {
|
|
347
|
-
return { ...LANGUAGE_INFO };
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
const LANGUAGE_INFO = {
|
|
351
|
-
en: { code: 'en', name: 'English', nativeName: 'English', direction: 'ltr', wordOrder: 'SVO' },
|
|
352
|
-
ja: { code: 'ja', name: 'Japanese', nativeName: '\u65e5\u672c\u8a9e', direction: 'ltr', wordOrder: 'SOV' },
|
|
353
|
-
ar: { code: 'ar', name: 'Arabic', nativeName: '\u0627\u0644\u0639\u0631\u0628\u064a\u0629', direction: 'rtl', wordOrder: 'VSO' },
|
|
354
|
-
es: { code: 'es', name: 'Spanish', nativeName: 'Espa\u00f1ol', direction: 'ltr', wordOrder: 'SVO' },
|
|
355
|
-
ko: { code: 'ko', name: 'Korean', nativeName: '\ud55c\uad6d\uc5b4', direction: 'ltr', wordOrder: 'SOV' },
|
|
356
|
-
zh: { code: 'zh', name: 'Chinese', nativeName: '\u4e2d\u6587', direction: 'ltr', wordOrder: 'SVO' },
|
|
357
|
-
tr: { code: 'tr', name: 'Turkish', nativeName: 'T\u00fcrk\u00e7e', direction: 'ltr', wordOrder: 'SOV' },
|
|
358
|
-
pt: {
|
|
359
|
-
code: 'pt',
|
|
360
|
-
name: 'Portuguese',
|
|
361
|
-
nativeName: 'Portugu\u00eas',
|
|
362
|
-
direction: 'ltr',
|
|
363
|
-
wordOrder: 'SVO',
|
|
364
|
-
},
|
|
365
|
-
fr: { code: 'fr', name: 'French', nativeName: 'Fran\u00e7ais', direction: 'ltr', wordOrder: 'SVO' },
|
|
366
|
-
de: { code: 'de', name: 'German', nativeName: 'Deutsch', direction: 'ltr', wordOrder: 'SVO' },
|
|
367
|
-
id: {
|
|
368
|
-
code: 'id',
|
|
369
|
-
name: 'Indonesian',
|
|
370
|
-
nativeName: 'Bahasa Indonesia',
|
|
371
|
-
direction: 'ltr',
|
|
372
|
-
wordOrder: 'SVO',
|
|
373
|
-
},
|
|
374
|
-
qu: { code: 'qu', name: 'Quechua', nativeName: 'Runasimi', direction: 'ltr', wordOrder: 'SOV' },
|
|
375
|
-
sw: { code: 'sw', name: 'Swahili', nativeName: 'Kiswahili', direction: 'ltr', wordOrder: 'SVO' },
|
|
376
|
-
};
|
|
377
|
-
let _defaultInstance = null;
|
|
378
|
-
async function getMultilingual() {
|
|
379
|
-
if (!_defaultInstance) {
|
|
380
|
-
_defaultInstance = new MultilingualHyperscript();
|
|
381
|
-
await _defaultInstance.initialize();
|
|
20
|
+
catch {
|
|
21
|
+
return input;
|
|
382
22
|
}
|
|
383
|
-
return _defaultInstance;
|
|
384
23
|
}
|
|
385
|
-
const multilingual = new MultilingualHyperscript();
|
|
386
24
|
|
|
387
|
-
exports.
|
|
388
|
-
exports.
|
|
389
|
-
exports.getDefaultBridge = getDefaultBridge;
|
|
390
|
-
exports.getMultilingual = getMultilingual;
|
|
391
|
-
exports.multilingual = multilingual;
|
|
392
|
-
exports.schemaRoleInferrer = schemaRoleInferrer;
|
|
25
|
+
exports.parse = parse;
|
|
26
|
+
exports.render = render;
|
|
393
27
|
exports.translate = translate;
|
|
394
28
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,33 +1,5 @@
|
|
|
1
|
-
import type { SemanticNode
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export declare class MultilingualHyperscript {
|
|
6
|
-
private bridge;
|
|
7
|
-
private initialized;
|
|
8
|
-
constructor(config?: BridgeConfig);
|
|
9
|
-
initialize(): Promise<void>;
|
|
10
|
-
isInitialized(): boolean;
|
|
11
|
-
private ensureInitialized;
|
|
12
|
-
parse(input: string, lang?: string): Promise<SemanticNode | null>;
|
|
13
|
-
parseToAST(input: string, lang?: string): Promise<ASTNode | null>;
|
|
14
|
-
parseToASTWithDetails(input: string, lang?: string): Promise<ParseToASTResult>;
|
|
15
|
-
translate(input: string, from: string, to: string): Promise<string>;
|
|
16
|
-
translateWithDetails(input: string, from: string, to: string): Promise<BridgeResult>;
|
|
17
|
-
render(node: SemanticNode, lang: string): Promise<string>;
|
|
18
|
-
getAllTranslations(input: string, from: string): Promise<Record<string, BridgeResult>>;
|
|
19
|
-
getSupportedLanguages(): string[];
|
|
20
|
-
isLanguageSupported(lang: string): boolean;
|
|
21
|
-
getLanguageInfo(lang: string): LanguageInfo | undefined;
|
|
22
|
-
getAllLanguageInfo(): Record<string, LanguageInfo>;
|
|
23
|
-
}
|
|
24
|
-
export interface LanguageInfo {
|
|
25
|
-
code: string;
|
|
26
|
-
name: string;
|
|
27
|
-
nativeName: string;
|
|
28
|
-
direction: 'ltr' | 'rtl';
|
|
29
|
-
wordOrder: 'SVO' | 'SOV' | 'VSO' | 'VOS';
|
|
30
|
-
}
|
|
31
|
-
export declare function getMultilingual(): Promise<MultilingualHyperscript>;
|
|
32
|
-
export declare const multilingual: MultilingualHyperscript;
|
|
1
|
+
import type { SemanticNode } from '@lokascript/semantic';
|
|
2
|
+
export declare function parse(input: string, lang?: string): Promise<SemanticNode | null>;
|
|
3
|
+
export declare function render(node: SemanticNode, lang: string): Promise<string>;
|
|
4
|
+
export declare function translate(input: string, sourceLang: string, targetLang: string): Promise<string>;
|
|
33
5
|
//# sourceMappingURL=index.d.ts.map
|