@hyperfixi/core 2.3.0 → 2.4.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 +8 -11
- package/dist/api/dom-processor.d.ts +8 -4
- package/dist/api/hyperscript-api.d.ts +5 -1
- package/dist/ast-utils/index.js +25320 -94
- package/dist/ast-utils/index.mjs +25320 -94
- package/dist/ast-utils/interchange/types.d.ts +7 -1
- package/dist/behaviors/index.js +54 -100
- package/dist/behaviors/index.mjs +54 -100
- package/dist/bundle-generator/index.js +44 -6
- package/dist/bundle-generator/index.mjs +44 -6
- package/dist/bundle-generator/parser-templates.d.ts +1 -1
- package/dist/bundle-generator/template-capabilities.d.ts +1 -1
- package/dist/chunks/bridge-C4d3blZX.js +2 -0
- package/dist/chunks/browser-modular-BwIRlrTM.js +2 -0
- package/dist/chunks/feature-eventsource-BpZvPy_K.js +2 -0
- package/dist/chunks/{feature-sockets-ClOH7vk7.js → feature-sockets-CrYvjZ4j.js} +2 -2
- package/dist/chunks/feature-webworker-BSYguEIW.js +2 -0
- package/dist/chunks/index-Beno_SBy.js +2 -0
- package/dist/commands/advanced/async.d.ts +6 -2
- package/dist/commands/advanced/js.d.ts +1 -1
- package/dist/commands/animation/start-view-transition.d.ts +24 -0
- package/dist/commands/async/fetch.d.ts +6 -1
- package/dist/commands/control-flow/repeat.d.ts +2 -0
- package/dist/commands/data/clear.d.ts +23 -0
- package/dist/commands/data/set.d.ts +6 -0
- package/dist/commands/dom/close.d.ts +19 -0
- package/dist/commands/dom/empty.d.ts +19 -0
- package/dist/commands/dom/open.d.ts +21 -0
- package/dist/commands/dom/reset.d.ts +19 -0
- package/dist/commands/dom/select.d.ts +19 -0
- package/dist/commands/dom/swap.d.ts +7 -4
- package/dist/commands/events/trigger.d.ts +1 -1
- package/dist/commands/execution/blur.d.ts +19 -0
- package/dist/commands/execution/call.d.ts +1 -2
- package/dist/commands/execution/focus.d.ts +19 -0
- package/dist/commands/helpers/element-resolution.d.ts +2 -2
- package/dist/commands/helpers/event-waiting.d.ts +1 -1
- package/dist/commands/helpers/numeric-target-parser.d.ts +7 -0
- package/dist/commands/index.d.ts +34 -2
- package/dist/commands/index.js +19374 -4848
- package/dist/commands/index.mjs +19342 -4849
- package/dist/commands/navigation/go.d.ts +3 -0
- package/dist/commands/navigation/scroll-to.d.ts +26 -0
- package/dist/commands/utility/beep.d.ts +2 -2
- package/dist/commands/utility/breakpoint.d.ts +19 -0
- package/dist/commands/utility/pick.d.ts +11 -2
- package/dist/compatibility/browser-bundle-modular.d.ts +2 -2
- package/dist/compatibility/browser-bundle-multilingual.d.ts +1 -1
- package/dist/compatibility/browser-bundle-semantic-complete.d.ts +3 -3
- package/dist/compatibility/browser-bundle.d.ts +13 -6
- package/dist/compatibility/browser-modular.d.ts +1 -3
- package/dist/core/expression-evaluator.d.ts +4 -4
- package/dist/core/expression-registry.d.ts +8 -0
- package/dist/expressions/bundles/common-expressions.d.ts +2 -2
- package/dist/expressions/bundles/core-expressions.d.ts +2 -2
- package/dist/expressions/bundles/full-expressions.d.ts +2 -2
- package/dist/expressions/bundles/index.d.ts +3 -3
- package/dist/expressions/collection/index.d.ts +35 -0
- package/dist/expressions/conversion/impl/index.d.ts +1 -1
- package/dist/expressions/index.d.ts +4 -3
- package/dist/expressions/index.js +1117 -1590
- package/dist/expressions/index.mjs +1113 -1586
- package/dist/expressions/logical/index.d.ts +2 -0
- package/dist/expressions/mathematical/index.d.ts +11 -0
- package/dist/expressions/shared/index.d.ts +1 -1
- package/dist/expressions/shared/number-utils.d.ts +1 -0
- package/dist/htmx/htmx-attribute-processor.d.ts +37 -1
- package/dist/htmx/htmx-translator.d.ts +2 -0
- package/dist/htmx/i18n-hooks.d.ts +15 -0
- package/dist/htmx/i18n-orchestrator.d.ts +15 -0
- package/dist/htmx/lang-resolver.d.ts +3 -0
- package/dist/htmx/sse.d.ts +60 -0
- package/dist/htmx/ws.d.ts +59 -0
- package/dist/hyperfixi-browser-classic-i18n.js +2 -0
- package/dist/hyperfixi-browser-minimal.js +1 -0
- package/dist/hyperfixi-browser-standard.js +2 -0
- package/dist/hyperfixi-browser.js +2 -0
- package/dist/hyperfixi-classic-i18n.js +1 -1
- package/dist/hyperfixi-hx-v4.js +1 -0
- package/dist/hyperfixi-hx.js +1 -1
- package/dist/hyperfixi-hybrid-complete.js +1 -1
- package/dist/hyperfixi-hybrid-hx.js +1 -0
- package/dist/hyperfixi-minimal.js +1 -1
- package/dist/hyperfixi-multilingual.js +1 -1
- package/dist/hyperfixi-standard.js +1 -1
- package/dist/hyperfixi.js +1 -1
- package/dist/hyperfixi.mjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +43613 -45063
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +43610 -45064
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/morph-adapter.d.ts +0 -13
- package/dist/lib/swap-executor.d.ts +0 -10
- package/dist/lib/view-transitions.d.ts +1 -30
- package/dist/lokascript-browser-classic-i18n.js +1 -1
- package/dist/lokascript-browser-minimal.js +1 -1
- package/dist/lokascript-browser-standard.js +1 -1
- package/dist/lokascript-browser.js +1 -1
- package/dist/lokascript-hybrid-complete.js +1 -1
- package/dist/lokascript-hybrid-hx.js +1 -1
- package/dist/lokascript-multilingual.js +1 -1
- package/dist/lsp-metadata.d.ts +9 -4
- package/dist/lsp-metadata.js +187 -3
- package/dist/lsp-metadata.mjs +185 -4
- package/dist/metadata.d.ts +1 -1
- package/dist/metadata.js +3 -3
- package/dist/metadata.mjs +3 -3
- package/dist/multilingual/bridge.d.ts +1 -1
- package/dist/multilingual/index.js +79 -22
- package/dist/multilingual/index.mjs +79 -22
- package/dist/parser/command-parsers/animation-commands.d.ts +1 -0
- package/dist/parser/command-parsers/utility-commands.d.ts +1 -0
- package/dist/parser/extensions.d.ts +51 -0
- package/dist/parser/full-parser.js +1224 -899
- package/dist/parser/full-parser.mjs +1224 -899
- package/dist/parser/helpers/ast-helpers.d.ts +1 -0
- package/dist/parser/helpers/parsing-helpers.d.ts +4 -0
- package/dist/parser/hybrid/index.js +7 -0
- package/dist/parser/hybrid/index.mjs +7 -0
- package/dist/parser/hybrid/parser-core.js +7 -0
- package/dist/parser/hybrid/parser-core.mjs +7 -0
- package/dist/parser/hybrid/tokenizer.js +7 -0
- package/dist/parser/hybrid/tokenizer.mjs +7 -0
- package/dist/parser/hybrid-parser.js +7 -0
- package/dist/parser/hybrid-parser.mjs +7 -0
- package/dist/parser/parser-types.d.ts +8 -28
- package/dist/parser/parser.d.ts +3 -7
- package/dist/parser/pratt-parser.d.ts +0 -3
- package/dist/parser/runtime.d.ts +4 -0
- package/dist/parser/semantic-integration.d.ts +17 -0
- package/dist/parser/types.d.ts +7 -1
- package/dist/reference/index.js +91 -0
- package/dist/reference/index.mjs +91 -0
- package/dist/registry/index.js +12866 -5876
- package/dist/registry/index.mjs +12866 -5876
- package/dist/registry/universal-types.d.ts +2 -1
- package/dist/runtime/command-adapter.d.ts +23 -16
- package/dist/runtime/plugin.d.ts +14 -0
- package/dist/runtime/runtime-base.d.ts +32 -7
- package/dist/runtime/runtime-factory.d.ts +3 -3
- package/dist/runtime/runtime.d.ts +2 -2
- package/dist/test-setup.d.ts +1 -0
- package/dist/types/base-types.d.ts +3 -0
- package/dist/types/feature-types.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +26 -20
- package/vocab/htmx/ar.js +60 -0
- package/vocab/htmx/bn.js +49 -0
- package/vocab/htmx/de.js +60 -0
- package/vocab/htmx/en.js +21 -0
- package/vocab/htmx/es.js +60 -0
- package/vocab/htmx/fr.js +59 -0
- package/vocab/htmx/he.js +40 -0
- package/vocab/htmx/hi.js +60 -0
- package/vocab/htmx/id.js +57 -0
- package/vocab/htmx/it.js +58 -0
- package/vocab/htmx/ja.js +60 -0
- package/vocab/htmx/ko.js +60 -0
- package/vocab/htmx/ms.js +35 -0
- package/vocab/htmx/pl.js +60 -0
- package/vocab/htmx/pt.js +60 -0
- package/vocab/htmx/qu.js +60 -0
- package/vocab/htmx/ru.js +60 -0
- package/vocab/htmx/sw.js +59 -0
- package/vocab/htmx/th.js +49 -0
- package/vocab/htmx/tl.js +33 -0
- package/vocab/htmx/tr.js +60 -0
- package/vocab/htmx/uk.js +60 -0
- package/vocab/htmx/vi.js +51 -0
- package/vocab/htmx/zh.js +60 -0
- package/dist/bundles/test-minimal.d.ts +0 -3
- package/dist/bundles/test-standard.d.ts +0 -3
- package/dist/chunks/bridge-BlRqsZT4.js +0 -2
- package/dist/chunks/browser-modular-AbV0Ql4i.js +0 -2
- package/dist/chunks/feature-eventsource-B5F2-H1r.js +0 -2
- package/dist/chunks/feature-webworker-3bAp0ac9.js +0 -2
- package/dist/chunks/index-BDYQHwCF.js +0 -2
- package/dist/compatibility/browser-bundle-minimal.d.ts +0 -8
- package/dist/compatibility/browser-bundle-standard.d.ts +0 -8
- package/dist/compatibility/hyperscript-tests/test-adapter.d.ts +0 -13
- package/dist/core/base-expression-evaluator.d.ts +0 -74
- package/dist/core/binary-expression-evaluator.d.ts +0 -7
- package/dist/core/call-expression-evaluator.d.ts +0 -7
- package/dist/core/configurable-expression-evaluator.d.ts +0 -5
- package/dist/core/lazy-expression-evaluator.d.ts +0 -22
- package/dist/core/parser.d.ts +0 -21
- package/dist/core/selector-evaluator.d.ts +0 -15
- package/dist/core/template-literal-evaluator.d.ts +0 -5
- package/dist/expressions/comparison/index.d.ts +0 -80
- package/dist/expressions/comparison/utils.d.ts +0 -2
- package/dist/expressions/conversion/impl/bridge.d.ts +0 -117
- package/dist/expressions/logical/impl/pattern-matching.d.ts +0 -58
- package/dist/expressions/positional/impl/bridge.d.ts +0 -95
- package/dist/expressions/property/index.d.ts +0 -55
- package/dist/expressions/references/impl/bridge.d.ts +0 -54
- package/dist/extensions/index.d.ts +0 -3
- package/dist/extensions/tailwind.d.ts +0 -22
- package/dist/mod.d.ts +0 -63
- package/dist/parser/expression-parser.d.ts +0 -6
- package/dist/runtime/runtime-experimental.d.ts +0 -18
- package/dist/scripts/code-generator.d.ts +0 -64
- package/dist/scripts/generate-missing-commands.d.ts +0 -4
|
@@ -2,6 +2,75 @@
|
|
|
2
2
|
|
|
3
3
|
var semantic = require('@lokascript/semantic');
|
|
4
4
|
|
|
5
|
+
function checkDebugEnabled() {
|
|
6
|
+
if (typeof localStorage !== 'undefined') {
|
|
7
|
+
try {
|
|
8
|
+
const ls = localStorage;
|
|
9
|
+
const setting = ls.getItem('hyperfixi:debug') || ls.getItem('lokascript:debug');
|
|
10
|
+
if (setting === '*' || setting === 'true')
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (typeof window !== 'undefined' && window.__HYPERFIXI_DEBUG__) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
if (typeof process !== 'undefined' && process.env?.HYPERFIXI_DEBUG === 'true') {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const isDebugEnabled = checkDebugEnabled();
|
|
25
|
+
const DEBUG = {
|
|
26
|
+
commands: isDebugEnabled,
|
|
27
|
+
events: isDebugEnabled,
|
|
28
|
+
parsing: isDebugEnabled,
|
|
29
|
+
expressions: isDebugEnabled,
|
|
30
|
+
styles: isDebugEnabled,
|
|
31
|
+
runtime: isDebugEnabled,
|
|
32
|
+
loops: isDebugEnabled,
|
|
33
|
+
async: isDebugEnabled,
|
|
34
|
+
};
|
|
35
|
+
const debug = {
|
|
36
|
+
command: (...args) => {
|
|
37
|
+
if (DEBUG.commands)
|
|
38
|
+
console.log('🔧', ...args);
|
|
39
|
+
},
|
|
40
|
+
event: (...args) => {
|
|
41
|
+
if (DEBUG.events)
|
|
42
|
+
console.log('🎯', ...args);
|
|
43
|
+
},
|
|
44
|
+
parse: (...args) => {
|
|
45
|
+
if (DEBUG.parsing)
|
|
46
|
+
console.log('📝', ...args);
|
|
47
|
+
},
|
|
48
|
+
expr: (...args) => {
|
|
49
|
+
if (DEBUG.expressions)
|
|
50
|
+
console.log('🔍', ...args);
|
|
51
|
+
},
|
|
52
|
+
expressions: (...args) => {
|
|
53
|
+
if (DEBUG.expressions)
|
|
54
|
+
console.log('🔍', ...args);
|
|
55
|
+
},
|
|
56
|
+
style: (...args) => {
|
|
57
|
+
if (DEBUG.styles)
|
|
58
|
+
console.log('🎨', ...args);
|
|
59
|
+
},
|
|
60
|
+
runtime: (...args) => {
|
|
61
|
+
if (DEBUG.runtime)
|
|
62
|
+
console.log('🚀', ...args);
|
|
63
|
+
},
|
|
64
|
+
loop: (...args) => {
|
|
65
|
+
if (DEBUG.loops)
|
|
66
|
+
console.log('🔁', ...args);
|
|
67
|
+
},
|
|
68
|
+
async: (...args) => {
|
|
69
|
+
if (DEBUG.async)
|
|
70
|
+
console.log('⏳', ...args);
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
5
74
|
let _semanticModule = null;
|
|
6
75
|
async function getSemanticModule() {
|
|
7
76
|
if (!_semanticModule) {
|
|
@@ -11,18 +80,18 @@ async function getSemanticModule() {
|
|
|
11
80
|
}
|
|
12
81
|
class SemanticGrammarBridge {
|
|
13
82
|
constructor(config = {}) {
|
|
14
|
-
this.
|
|
83
|
+
this._initialized = false;
|
|
15
84
|
this.config = {
|
|
16
85
|
confidenceThreshold: config.confidenceThreshold ?? semantic.DEFAULT_CONFIDENCE_THRESHOLD,
|
|
17
86
|
fallbackOnLowConfidence: config.fallbackOnLowConfidence ?? true,
|
|
18
87
|
};
|
|
19
88
|
}
|
|
20
89
|
async initialize() {
|
|
21
|
-
|
|
22
|
-
this.
|
|
90
|
+
await getSemanticModule();
|
|
91
|
+
this._initialized = true;
|
|
23
92
|
}
|
|
24
93
|
isInitialized() {
|
|
25
|
-
return this.
|
|
94
|
+
return this._initialized;
|
|
26
95
|
}
|
|
27
96
|
async transform(input, sourceLang, targetLang) {
|
|
28
97
|
if (!this.isInitialized()) {
|
|
@@ -64,9 +133,8 @@ class SemanticGrammarBridge {
|
|
|
64
133
|
if (!this.isInitialized()) {
|
|
65
134
|
await this.initialize();
|
|
66
135
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const result = this.analyzer.analyze(input, lang);
|
|
136
|
+
const semantic = await getSemanticModule();
|
|
137
|
+
const result = semantic.parseSemantic(input, lang);
|
|
70
138
|
return result.node ?? null;
|
|
71
139
|
}
|
|
72
140
|
async render(node, targetLang) {
|
|
@@ -77,17 +145,15 @@ class SemanticGrammarBridge {
|
|
|
77
145
|
if (!this.isInitialized()) {
|
|
78
146
|
await this.initialize();
|
|
79
147
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const result = this.analyzer.analyze(input, lang);
|
|
148
|
+
const semantic = await getSemanticModule();
|
|
149
|
+
const result = semantic.parseSemantic(input, lang);
|
|
83
150
|
if (result.confidence >= this.config.confidenceThreshold && result.node) {
|
|
84
|
-
const semantic = await getSemanticModule();
|
|
85
151
|
try {
|
|
86
152
|
const buildResult = semantic.buildAST(result.node);
|
|
87
153
|
return buildResult.ast;
|
|
88
154
|
}
|
|
89
155
|
catch (error) {
|
|
90
|
-
|
|
156
|
+
debug.runtime('[SemanticGrammarBridge] AST build failed, using fallback:', error);
|
|
91
157
|
}
|
|
92
158
|
}
|
|
93
159
|
return null;
|
|
@@ -96,17 +162,8 @@ class SemanticGrammarBridge {
|
|
|
96
162
|
if (!this.isInitialized()) {
|
|
97
163
|
await this.initialize();
|
|
98
164
|
}
|
|
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
165
|
const semantic = await getSemanticModule();
|
|
166
|
+
const result = semantic.parseSemantic(input, lang);
|
|
110
167
|
if (result.confidence >= this.config.confidenceThreshold && result.node) {
|
|
111
168
|
try {
|
|
112
169
|
const buildResult = semantic.buildAST(result.node);
|
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
import { DEFAULT_CONFIDENCE_THRESHOLD } from '@lokascript/semantic';
|
|
2
2
|
|
|
3
|
+
function checkDebugEnabled() {
|
|
4
|
+
if (typeof localStorage !== 'undefined') {
|
|
5
|
+
try {
|
|
6
|
+
const ls = localStorage;
|
|
7
|
+
const setting = ls.getItem('hyperfixi:debug') || ls.getItem('lokascript:debug');
|
|
8
|
+
if (setting === '*' || setting === 'true')
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (typeof window !== 'undefined' && window.__HYPERFIXI_DEBUG__) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
if (typeof process !== 'undefined' && process.env?.HYPERFIXI_DEBUG === 'true') {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
const isDebugEnabled = checkDebugEnabled();
|
|
23
|
+
const DEBUG = {
|
|
24
|
+
commands: isDebugEnabled,
|
|
25
|
+
events: isDebugEnabled,
|
|
26
|
+
parsing: isDebugEnabled,
|
|
27
|
+
expressions: isDebugEnabled,
|
|
28
|
+
styles: isDebugEnabled,
|
|
29
|
+
runtime: isDebugEnabled,
|
|
30
|
+
loops: isDebugEnabled,
|
|
31
|
+
async: isDebugEnabled,
|
|
32
|
+
};
|
|
33
|
+
const debug = {
|
|
34
|
+
command: (...args) => {
|
|
35
|
+
if (DEBUG.commands)
|
|
36
|
+
console.log('🔧', ...args);
|
|
37
|
+
},
|
|
38
|
+
event: (...args) => {
|
|
39
|
+
if (DEBUG.events)
|
|
40
|
+
console.log('🎯', ...args);
|
|
41
|
+
},
|
|
42
|
+
parse: (...args) => {
|
|
43
|
+
if (DEBUG.parsing)
|
|
44
|
+
console.log('📝', ...args);
|
|
45
|
+
},
|
|
46
|
+
expr: (...args) => {
|
|
47
|
+
if (DEBUG.expressions)
|
|
48
|
+
console.log('🔍', ...args);
|
|
49
|
+
},
|
|
50
|
+
expressions: (...args) => {
|
|
51
|
+
if (DEBUG.expressions)
|
|
52
|
+
console.log('🔍', ...args);
|
|
53
|
+
},
|
|
54
|
+
style: (...args) => {
|
|
55
|
+
if (DEBUG.styles)
|
|
56
|
+
console.log('🎨', ...args);
|
|
57
|
+
},
|
|
58
|
+
runtime: (...args) => {
|
|
59
|
+
if (DEBUG.runtime)
|
|
60
|
+
console.log('🚀', ...args);
|
|
61
|
+
},
|
|
62
|
+
loop: (...args) => {
|
|
63
|
+
if (DEBUG.loops)
|
|
64
|
+
console.log('🔁', ...args);
|
|
65
|
+
},
|
|
66
|
+
async: (...args) => {
|
|
67
|
+
if (DEBUG.async)
|
|
68
|
+
console.log('⏳', ...args);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
3
72
|
let _semanticModule = null;
|
|
4
73
|
async function getSemanticModule() {
|
|
5
74
|
if (!_semanticModule) {
|
|
@@ -9,18 +78,18 @@ async function getSemanticModule() {
|
|
|
9
78
|
}
|
|
10
79
|
class SemanticGrammarBridge {
|
|
11
80
|
constructor(config = {}) {
|
|
12
|
-
this.
|
|
81
|
+
this._initialized = false;
|
|
13
82
|
this.config = {
|
|
14
83
|
confidenceThreshold: config.confidenceThreshold ?? DEFAULT_CONFIDENCE_THRESHOLD,
|
|
15
84
|
fallbackOnLowConfidence: config.fallbackOnLowConfidence ?? true,
|
|
16
85
|
};
|
|
17
86
|
}
|
|
18
87
|
async initialize() {
|
|
19
|
-
|
|
20
|
-
this.
|
|
88
|
+
await getSemanticModule();
|
|
89
|
+
this._initialized = true;
|
|
21
90
|
}
|
|
22
91
|
isInitialized() {
|
|
23
|
-
return this.
|
|
92
|
+
return this._initialized;
|
|
24
93
|
}
|
|
25
94
|
async transform(input, sourceLang, targetLang) {
|
|
26
95
|
if (!this.isInitialized()) {
|
|
@@ -62,9 +131,8 @@ class SemanticGrammarBridge {
|
|
|
62
131
|
if (!this.isInitialized()) {
|
|
63
132
|
await this.initialize();
|
|
64
133
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const result = this.analyzer.analyze(input, lang);
|
|
134
|
+
const semantic = await getSemanticModule();
|
|
135
|
+
const result = semantic.parseSemantic(input, lang);
|
|
68
136
|
return result.node ?? null;
|
|
69
137
|
}
|
|
70
138
|
async render(node, targetLang) {
|
|
@@ -75,17 +143,15 @@ class SemanticGrammarBridge {
|
|
|
75
143
|
if (!this.isInitialized()) {
|
|
76
144
|
await this.initialize();
|
|
77
145
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const result = this.analyzer.analyze(input, lang);
|
|
146
|
+
const semantic = await getSemanticModule();
|
|
147
|
+
const result = semantic.parseSemantic(input, lang);
|
|
81
148
|
if (result.confidence >= this.config.confidenceThreshold && result.node) {
|
|
82
|
-
const semantic = await getSemanticModule();
|
|
83
149
|
try {
|
|
84
150
|
const buildResult = semantic.buildAST(result.node);
|
|
85
151
|
return buildResult.ast;
|
|
86
152
|
}
|
|
87
153
|
catch (error) {
|
|
88
|
-
|
|
154
|
+
debug.runtime('[SemanticGrammarBridge] AST build failed, using fallback:', error);
|
|
89
155
|
}
|
|
90
156
|
}
|
|
91
157
|
return null;
|
|
@@ -94,17 +160,8 @@ class SemanticGrammarBridge {
|
|
|
94
160
|
if (!this.isInitialized()) {
|
|
95
161
|
await this.initialize();
|
|
96
162
|
}
|
|
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
163
|
const semantic = await getSemanticModule();
|
|
164
|
+
const result = semantic.parseSemantic(input, lang);
|
|
108
165
|
if (result.confidence >= this.config.confidenceThreshold && result.node) {
|
|
109
166
|
try {
|
|
110
167
|
const buildResult = semantic.buildAST(result.node);
|
|
@@ -2,4 +2,5 @@ import type { ParserContext, IdentifierNode } from '../parser-types';
|
|
|
2
2
|
import type { Token } from '../../types/core';
|
|
3
3
|
export declare function parseMeasureCommand(ctx: ParserContext, identifierNode: IdentifierNode): import("../../types/core").CommandNode;
|
|
4
4
|
export declare function parseTransitionCommand(ctx: ParserContext, commandToken: Token): import("../../types/core").CommandNode;
|
|
5
|
+
export declare function parseStartCommand(ctx: ParserContext, identifierNode: IdentifierNode): import('../../types/core').CommandNode;
|
|
5
6
|
//# sourceMappingURL=animation-commands.d.ts.map
|
|
@@ -6,4 +6,5 @@ export declare function parseMultiWordCommand(ctx: ParserContext, commandToken:
|
|
|
6
6
|
export declare function parseFetchCommand(ctx: ParserContext, commandToken: Token): CommandNode;
|
|
7
7
|
export declare function parseJsCommand(ctx: ParserContext, identifierNode: IdentifierNode): CommandNode;
|
|
8
8
|
export declare function parseTellCommand(ctx: ParserContext, identifierNode: IdentifierNode): CommandNode;
|
|
9
|
+
export declare function parsePickCommand(ctx: ParserContext, identifierNode: IdentifierNode): CommandNode;
|
|
9
10
|
//# sourceMappingURL=utility-commands.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { BindingPowerEntry, InfixHandler, PrefixHandler } from './pratt-parser';
|
|
2
|
+
import type { ASTNode, ExecutionContext } from '../types/base-types';
|
|
3
|
+
import type { Token } from '../types/core';
|
|
4
|
+
import type { ParserContext } from './parser-types';
|
|
5
|
+
export type FeatureParseFn = (ctx: ParserContext, token: Token) => ASTNode | null;
|
|
6
|
+
export type NodeEvaluatorFn = (node: ASTNode, context: ExecutionContext) => unknown | Promise<unknown>;
|
|
7
|
+
export type GlobalWriteHook = (name: string, value: unknown, context: ExecutionContext) => void;
|
|
8
|
+
export type GlobalReadHook = (name: string, context: ExecutionContext) => void;
|
|
9
|
+
export type LocalWriteHook = (name: string, value: unknown, context: ExecutionContext) => void;
|
|
10
|
+
export type LocalReadHook = (name: string, context: ExecutionContext) => void;
|
|
11
|
+
export type NodeWriterFn = (node: ASTNode, value: unknown, context: ExecutionContext) => void | Promise<void>;
|
|
12
|
+
export declare function getRegisteredFeature(name: string): FeatureParseFn | undefined;
|
|
13
|
+
export declare function getRegisteredNodeEvaluator(type: string): NodeEvaluatorFn | undefined;
|
|
14
|
+
export declare function getRegisteredNodeWriter(type: string): NodeWriterFn | undefined;
|
|
15
|
+
export declare function getGlobalWriteHooks(): Iterable<GlobalWriteHook>;
|
|
16
|
+
export declare function notifyGlobalRead(name: string, context: ExecutionContext): void;
|
|
17
|
+
export declare function getLocalWriteHooks(): Iterable<LocalWriteHook>;
|
|
18
|
+
export declare function notifyLocalWrite(name: string, value: unknown, context: ExecutionContext): void;
|
|
19
|
+
export declare function notifyLocalRead(name: string, context: ExecutionContext): void;
|
|
20
|
+
export interface ParserExtensionSnapshot {
|
|
21
|
+
commands: string[];
|
|
22
|
+
operators: string[];
|
|
23
|
+
prattEntries: Array<[string, BindingPowerEntry]>;
|
|
24
|
+
features: Array<[string, FeatureParseFn]>;
|
|
25
|
+
nodeEvaluators: Array<[string, NodeEvaluatorFn]>;
|
|
26
|
+
nodeWriters: Array<[string, NodeWriterFn]>;
|
|
27
|
+
globalWriteHooks: GlobalWriteHook[];
|
|
28
|
+
globalReadHooks: GlobalReadHook[];
|
|
29
|
+
localWriteHooks: LocalWriteHook[];
|
|
30
|
+
localReadHooks: LocalReadHook[];
|
|
31
|
+
}
|
|
32
|
+
export declare class ParserExtensionRegistry {
|
|
33
|
+
registerCommand(name: string): void;
|
|
34
|
+
registerCompoundOperator(token: string): void;
|
|
35
|
+
registerInfixOperator(token: string, leftBp: number, rightBp: number, handler: InfixHandler): void;
|
|
36
|
+
registerPrefixOperator(token: string, bp: number, handler: PrefixHandler): void;
|
|
37
|
+
hasCommand(name: string): boolean;
|
|
38
|
+
registerFeature(keyword: string, parseFn: FeatureParseFn): void;
|
|
39
|
+
hasFeature(name: string): boolean;
|
|
40
|
+
registerNodeEvaluator(nodeType: string, fn: NodeEvaluatorFn): void;
|
|
41
|
+
registerNodeWriter(nodeType: string, fn: NodeWriterFn): void;
|
|
42
|
+
registerGlobalWriteHook(hook: GlobalWriteHook): () => void;
|
|
43
|
+
registerGlobalReadHook(hook: GlobalReadHook): () => void;
|
|
44
|
+
registerLocalWriteHook(hook: LocalWriteHook): () => void;
|
|
45
|
+
registerLocalReadHook(hook: LocalReadHook): () => void;
|
|
46
|
+
snapshot(): ParserExtensionSnapshot;
|
|
47
|
+
restore(snapshot: ParserExtensionSnapshot): void;
|
|
48
|
+
}
|
|
49
|
+
export declare function getParserExtensionRegistry(): ParserExtensionRegistry;
|
|
50
|
+
export declare function setGlobal(context: ExecutionContext, name: string, value: unknown): void;
|
|
51
|
+
//# sourceMappingURL=extensions.d.ts.map
|