@lokascript/semantic 1.2.0 → 1.2.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/dist/core.d.ts +1246 -0
- package/dist/core.js +3073 -0
- package/dist/core.js.map +1 -0
- package/package.json +5 -1
- package/src/core.ts +155 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lokascript/semantic",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Semantic multilingual parser for hyperscript (23 languages)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"import": "./dist/index.js",
|
|
14
14
|
"require": "./dist/index.cjs"
|
|
15
15
|
},
|
|
16
|
+
"./core": {
|
|
17
|
+
"types": "./dist/core.d.ts",
|
|
18
|
+
"import": "./dist/core.js"
|
|
19
|
+
},
|
|
16
20
|
"./browser": {
|
|
17
21
|
"types": "./dist/index.d.ts",
|
|
18
22
|
"default": "./dist/browser.global.js"
|
package/src/core.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Entry Point (No Language Data)
|
|
3
|
+
*
|
|
4
|
+
* A minimal ESM entry point that exports core semantic analysis infrastructure
|
|
5
|
+
* without importing any language modules. Languages must be imported separately
|
|
6
|
+
* as side-effect imports that self-register with the registry.
|
|
7
|
+
*
|
|
8
|
+
* This enables tree-shaking for Vite/Rollup projects that only need specific
|
|
9
|
+
* languages rather than the full 25-language bundle.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Import core infrastructure
|
|
14
|
+
* import { createSemanticAnalyzer, buildAST, isLanguageSupported } from '@lokascript/semantic/core';
|
|
15
|
+
*
|
|
16
|
+
* // Import only the languages you need (self-registering side effects)
|
|
17
|
+
* import '@lokascript/semantic/languages/en';
|
|
18
|
+
* import '@lokascript/semantic/languages/es';
|
|
19
|
+
*
|
|
20
|
+
* // Now use the analyzer
|
|
21
|
+
* const analyzer = createSemanticAnalyzer();
|
|
22
|
+
* const result = analyzer.analyze('toggle .active', 'en');
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// Core Parser Bridge (SemanticAnalyzer)
|
|
28
|
+
// =============================================================================
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
// Types
|
|
32
|
+
type SemanticAnalysisResult,
|
|
33
|
+
type SemanticAnalyzer,
|
|
34
|
+
type SemanticAnalyzerOptions,
|
|
35
|
+
// Implementation
|
|
36
|
+
SemanticAnalyzerImpl,
|
|
37
|
+
createSemanticAnalyzer,
|
|
38
|
+
// Thresholds
|
|
39
|
+
DEFAULT_CONFIDENCE_THRESHOLD,
|
|
40
|
+
HIGH_CONFIDENCE_THRESHOLD,
|
|
41
|
+
// Helpers
|
|
42
|
+
shouldUseSemanticResult,
|
|
43
|
+
rolesToCommandArgs,
|
|
44
|
+
// Cache types
|
|
45
|
+
type SemanticCacheConfig,
|
|
46
|
+
type CacheStats,
|
|
47
|
+
} from './core-bridge';
|
|
48
|
+
|
|
49
|
+
// =============================================================================
|
|
50
|
+
// AST Builder
|
|
51
|
+
// =============================================================================
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
// Main builder
|
|
55
|
+
ASTBuilder,
|
|
56
|
+
buildAST,
|
|
57
|
+
// Value converters
|
|
58
|
+
convertValue,
|
|
59
|
+
convertLiteral,
|
|
60
|
+
convertSelector,
|
|
61
|
+
convertReference,
|
|
62
|
+
convertPropertyPath,
|
|
63
|
+
convertExpression,
|
|
64
|
+
// Command mappers
|
|
65
|
+
getCommandMapper,
|
|
66
|
+
registerCommandMapper,
|
|
67
|
+
getRegisteredMappers,
|
|
68
|
+
// Types
|
|
69
|
+
type ASTNode,
|
|
70
|
+
type CommandNode,
|
|
71
|
+
type EventHandlerNode,
|
|
72
|
+
type ConditionalNode,
|
|
73
|
+
type CommandSequenceNode,
|
|
74
|
+
type BlockNode,
|
|
75
|
+
type ASTBuilderOptions,
|
|
76
|
+
type CommandMapper,
|
|
77
|
+
type CommandMapperResult,
|
|
78
|
+
type BuildASTResult,
|
|
79
|
+
} from './ast-builder';
|
|
80
|
+
|
|
81
|
+
// =============================================================================
|
|
82
|
+
// Registry (Language Management)
|
|
83
|
+
// =============================================================================
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
// Query functions
|
|
87
|
+
isLanguageSupported,
|
|
88
|
+
isLanguageRegistered,
|
|
89
|
+
getRegisteredLanguages,
|
|
90
|
+
getTokenizer,
|
|
91
|
+
tryGetProfile,
|
|
92
|
+
getProfile,
|
|
93
|
+
getPatternsForLanguage,
|
|
94
|
+
getPatternsForLanguageAndCommand,
|
|
95
|
+
// Registration functions (used by self-registering language modules)
|
|
96
|
+
registerLanguage,
|
|
97
|
+
registerPatterns,
|
|
98
|
+
setPatternGenerator,
|
|
99
|
+
// Profile utilities
|
|
100
|
+
mergeProfiles,
|
|
101
|
+
} from './registry';
|
|
102
|
+
|
|
103
|
+
// Re-export profile types from registry
|
|
104
|
+
export type {
|
|
105
|
+
LanguageProfile,
|
|
106
|
+
WordOrder,
|
|
107
|
+
MarkingStrategy,
|
|
108
|
+
RoleMarker,
|
|
109
|
+
VerbConfig,
|
|
110
|
+
PossessiveConfig,
|
|
111
|
+
KeywordTranslation,
|
|
112
|
+
TokenizationConfig,
|
|
113
|
+
} from './registry';
|
|
114
|
+
|
|
115
|
+
// =============================================================================
|
|
116
|
+
// Core Types
|
|
117
|
+
// =============================================================================
|
|
118
|
+
|
|
119
|
+
export type {
|
|
120
|
+
// Semantic types
|
|
121
|
+
ActionType,
|
|
122
|
+
SemanticRole,
|
|
123
|
+
SemanticValue,
|
|
124
|
+
SemanticNode,
|
|
125
|
+
CommandSemanticNode,
|
|
126
|
+
EventHandlerSemanticNode,
|
|
127
|
+
ConditionalSemanticNode,
|
|
128
|
+
CompoundSemanticNode,
|
|
129
|
+
LoopSemanticNode,
|
|
130
|
+
SemanticMetadata,
|
|
131
|
+
// Pattern types
|
|
132
|
+
LanguagePattern,
|
|
133
|
+
PatternMatchResult,
|
|
134
|
+
// Token types
|
|
135
|
+
LanguageToken,
|
|
136
|
+
TokenKind,
|
|
137
|
+
TokenStream,
|
|
138
|
+
LanguageTokenizer,
|
|
139
|
+
} from './types';
|
|
140
|
+
|
|
141
|
+
// Type helpers
|
|
142
|
+
export {
|
|
143
|
+
createSelector,
|
|
144
|
+
createLiteral,
|
|
145
|
+
createReference,
|
|
146
|
+
createPropertyPath,
|
|
147
|
+
createCommandNode,
|
|
148
|
+
createEventHandler,
|
|
149
|
+
} from './types';
|
|
150
|
+
|
|
151
|
+
// =============================================================================
|
|
152
|
+
// Cache
|
|
153
|
+
// =============================================================================
|
|
154
|
+
|
|
155
|
+
export { SemanticCache, semanticCache, createSemanticCache, withCache } from './cache';
|