@hyperfixi/core 2.6.0 → 2.7.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/dist/api/hyperscript-api.d.ts +6 -0
- package/dist/ast-utils/index.js +8 -8
- package/dist/ast-utils/index.mjs +8 -8
- package/dist/bundle-generator/index.js +12 -4
- package/dist/bundle-generator/index.mjs +12 -4
- package/dist/chunks/{bridge-fFLEvCQs.js → bridge-lZbOVRDD.js} +2 -2
- package/dist/chunks/browser-modular-DegkWQ8d.js +2 -0
- package/dist/chunks/{index-BRgVy8nY.js → index-i_j9Z-1e.js} +2 -2
- package/dist/commands/data/set.d.ts +1 -0
- package/dist/commands/index.js +156 -47
- package/dist/commands/index.mjs +156 -47
- package/dist/core/context.d.ts +4 -0
- package/dist/dom/attribute-processor.d.ts +1 -0
- package/dist/hyperfixi-browser-classic-i18n.js +1 -1
- package/dist/hyperfixi-browser-minimal.js +1 -1
- package/dist/hyperfixi-browser-standard.js +1 -1
- package/dist/hyperfixi-browser.js +1 -1
- package/dist/hyperfixi-classic-i18n.js +1 -1
- package/dist/hyperfixi-hx-v4.js +1 -1
- package/dist/hyperfixi-hx.js +1 -1
- package/dist/hyperfixi-hybrid-complete.js +1 -1
- package/dist/hyperfixi-hybrid-hx.js +1 -1
- package/dist/hyperfixi-lite-plus.js +1 -1
- package/dist/hyperfixi-lite.js +1 -1
- 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 +1 -1
- package/dist/index.js +694 -459
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +691 -460
- 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-lite-plus.js +1 -1
- package/dist/lokascript-lite.js +1 -1
- package/dist/lokascript-multilingual.js +1 -1
- package/dist/parser/full-parser.js +70 -35
- package/dist/parser/full-parser.mjs +70 -35
- package/dist/parser/parser-types.d.ts +1 -1
- package/dist/parser/parser.d.ts +2 -0
- package/dist/parser/regex-parser.js +23 -14
- package/dist/parser/regex-parser.mjs +23 -14
- package/dist/registry/index.js +178 -45
- package/dist/registry/index.mjs +178 -45
- package/dist/types/core-context.d.ts +1 -0
- package/package.json +6 -6
- package/dist/chunks/browser-modular-BK3IOo93.js +0 -2
- package/dist/compatibility/browser-bundle.d.ts +0 -164
|
@@ -17,6 +17,12 @@ export interface HyperscriptConfig {
|
|
|
17
17
|
confidenceThreshold: number;
|
|
18
18
|
logAll: boolean;
|
|
19
19
|
conversions: ConversionConfig;
|
|
20
|
+
onCompileError: ((info: {
|
|
21
|
+
source: 'attribute' | 'script';
|
|
22
|
+
code: string;
|
|
23
|
+
errors: CompileError[];
|
|
24
|
+
element: Element | null;
|
|
25
|
+
}) => void) | null;
|
|
20
26
|
}
|
|
21
27
|
export declare const config: HyperscriptConfig;
|
|
22
28
|
export interface CompileError {
|
package/dist/ast-utils/index.js
CHANGED
|
@@ -4056,14 +4056,6 @@ var DEFAULT_OPERATORS$1 = [
|
|
|
4056
4056
|
"~"
|
|
4057
4057
|
];
|
|
4058
4058
|
|
|
4059
|
-
// src/core/tokenization/char-classifiers.ts
|
|
4060
|
-
function createUnicodeRangeClassifier(ranges) {
|
|
4061
|
-
return (char) => {
|
|
4062
|
-
const code = char.charCodeAt(0);
|
|
4063
|
-
return ranges.some(([start, end]) => code >= start && code <= end);
|
|
4064
|
-
};
|
|
4065
|
-
}
|
|
4066
|
-
|
|
4067
4059
|
// src/core/tokenization/base-tokenizer.ts
|
|
4068
4060
|
new Set(DEFAULT_OPERATORS$1);
|
|
4069
4061
|
var MARKER_CONCEPT_NORMALIZEDS = /* @__PURE__ */ new Set([
|
|
@@ -4788,6 +4780,14 @@ _BaseTokenizer.STANDARD_TIME_UNITS = [
|
|
|
4788
4780
|
];
|
|
4789
4781
|
var BaseTokenizer = _BaseTokenizer;
|
|
4790
4782
|
|
|
4783
|
+
// src/core/tokenization/char-classifiers.ts
|
|
4784
|
+
function createUnicodeRangeClassifier(ranges) {
|
|
4785
|
+
return (char) => {
|
|
4786
|
+
const code = char.charCodeAt(0);
|
|
4787
|
+
return ranges.some(([start, end]) => code >= start && code <= end);
|
|
4788
|
+
};
|
|
4789
|
+
}
|
|
4790
|
+
|
|
4791
4791
|
// src/core/tokenization/morphology/types.ts
|
|
4792
4792
|
function noChange(word) {
|
|
4793
4793
|
return { stem: word, confidence: 1 };
|
package/dist/ast-utils/index.mjs
CHANGED
|
@@ -4054,14 +4054,6 @@ var DEFAULT_OPERATORS$1 = [
|
|
|
4054
4054
|
"~"
|
|
4055
4055
|
];
|
|
4056
4056
|
|
|
4057
|
-
// src/core/tokenization/char-classifiers.ts
|
|
4058
|
-
function createUnicodeRangeClassifier(ranges) {
|
|
4059
|
-
return (char) => {
|
|
4060
|
-
const code = char.charCodeAt(0);
|
|
4061
|
-
return ranges.some(([start, end]) => code >= start && code <= end);
|
|
4062
|
-
};
|
|
4063
|
-
}
|
|
4064
|
-
|
|
4065
4057
|
// src/core/tokenization/base-tokenizer.ts
|
|
4066
4058
|
new Set(DEFAULT_OPERATORS$1);
|
|
4067
4059
|
var MARKER_CONCEPT_NORMALIZEDS = /* @__PURE__ */ new Set([
|
|
@@ -4786,6 +4778,14 @@ _BaseTokenizer.STANDARD_TIME_UNITS = [
|
|
|
4786
4778
|
];
|
|
4787
4779
|
var BaseTokenizer = _BaseTokenizer;
|
|
4788
4780
|
|
|
4781
|
+
// src/core/tokenization/char-classifiers.ts
|
|
4782
|
+
function createUnicodeRangeClassifier(ranges) {
|
|
4783
|
+
return (char) => {
|
|
4784
|
+
const code = char.charCodeAt(0);
|
|
4785
|
+
return ranges.some(([start, end]) => code >= start && code <= end);
|
|
4786
|
+
};
|
|
4787
|
+
}
|
|
4788
|
+
|
|
4789
4789
|
// src/core/tokenization/morphology/types.ts
|
|
4790
4790
|
function noChange(word) {
|
|
4791
4791
|
return { stem: word, confidence: 1 };
|
|
@@ -63,7 +63,7 @@ const COMMAND_IMPLEMENTATIONS_TS = {
|
|
|
63
63
|
|
|
64
64
|
if (target.type === 'variable') {
|
|
65
65
|
const varName = target.name.slice(1);
|
|
66
|
-
const map = target.scope === 'local' ? ctx.
|
|
66
|
+
const map = target.scope === 'local' ? elemScope(ctx.me) : globalVars;
|
|
67
67
|
map.set(varName, value);
|
|
68
68
|
ctx.it = value;
|
|
69
69
|
return value;
|
|
@@ -262,7 +262,7 @@ const COMMAND_IMPLEMENTATIONS_TS = {
|
|
|
262
262
|
|
|
263
263
|
if (target.type === 'variable') {
|
|
264
264
|
const varName = target.name.slice(1);
|
|
265
|
-
const map = target.scope === 'local' ? ctx.
|
|
265
|
+
const map = target.scope === 'local' ? elemScope(ctx.me) : globalVars;
|
|
266
266
|
const current = map.get(varName) || 0;
|
|
267
267
|
const newVal = current + amount;
|
|
268
268
|
map.set(varName, newVal);
|
|
@@ -286,7 +286,7 @@ const COMMAND_IMPLEMENTATIONS_TS = {
|
|
|
286
286
|
|
|
287
287
|
if (target.type === 'variable') {
|
|
288
288
|
const varName = target.name.slice(1);
|
|
289
|
-
const map = target.scope === 'local' ? ctx.
|
|
289
|
+
const map = target.scope === 'local' ? elemScope(ctx.me) : globalVars;
|
|
290
290
|
const current = map.get(varName) || 0;
|
|
291
291
|
const newVal = current - amount;
|
|
292
292
|
map.set(varName, newVal);
|
|
@@ -683,6 +683,14 @@ interface Context {
|
|
|
683
683
|
}
|
|
684
684
|
|
|
685
685
|
const globalVars = new Map<string, any>();
|
|
686
|
+
// Per-element store for \`:name\` variables (scope 'local' from the mini-parser).
|
|
687
|
+
// Persists per-element across event firings, isolated per element.
|
|
688
|
+
const elementVars = new WeakMap<Element, Map<string, any>>();
|
|
689
|
+
function elemScope(el: Element): Map<string, any> {
|
|
690
|
+
let m = elementVars.get(el);
|
|
691
|
+
if (!m) { m = new Map<string, any>(); elementVars.set(el, m); }
|
|
692
|
+
return m;
|
|
693
|
+
}
|
|
686
694
|
${hasBlocks ? `const MAX_LOOP_ITERATIONS = ${maxLoopIterations};` : ''}
|
|
687
695
|
|
|
688
696
|
async function evaluate(node: ASTNode, ctx: Context): Promise<any> {
|
|
@@ -702,7 +710,7 @@ async function evaluate(node: ASTNode, ctx: Context): Promise<any> {
|
|
|
702
710
|
return node.value;
|
|
703
711
|
|
|
704
712
|
case 'variable':
|
|
705
|
-
if (node.scope === 'local') return ctx.
|
|
713
|
+
if (node.scope === 'local') return elemScope(ctx.me).get(node.name.slice(1));
|
|
706
714
|
const gName = node.name.slice(1);
|
|
707
715
|
if (globalVars.has(gName)) return globalVars.get(gName);
|
|
708
716
|
return (window as any)[node.name];
|
|
@@ -61,7 +61,7 @@ const COMMAND_IMPLEMENTATIONS_TS = {
|
|
|
61
61
|
|
|
62
62
|
if (target.type === 'variable') {
|
|
63
63
|
const varName = target.name.slice(1);
|
|
64
|
-
const map = target.scope === 'local' ? ctx.
|
|
64
|
+
const map = target.scope === 'local' ? elemScope(ctx.me) : globalVars;
|
|
65
65
|
map.set(varName, value);
|
|
66
66
|
ctx.it = value;
|
|
67
67
|
return value;
|
|
@@ -260,7 +260,7 @@ const COMMAND_IMPLEMENTATIONS_TS = {
|
|
|
260
260
|
|
|
261
261
|
if (target.type === 'variable') {
|
|
262
262
|
const varName = target.name.slice(1);
|
|
263
|
-
const map = target.scope === 'local' ? ctx.
|
|
263
|
+
const map = target.scope === 'local' ? elemScope(ctx.me) : globalVars;
|
|
264
264
|
const current = map.get(varName) || 0;
|
|
265
265
|
const newVal = current + amount;
|
|
266
266
|
map.set(varName, newVal);
|
|
@@ -284,7 +284,7 @@ const COMMAND_IMPLEMENTATIONS_TS = {
|
|
|
284
284
|
|
|
285
285
|
if (target.type === 'variable') {
|
|
286
286
|
const varName = target.name.slice(1);
|
|
287
|
-
const map = target.scope === 'local' ? ctx.
|
|
287
|
+
const map = target.scope === 'local' ? elemScope(ctx.me) : globalVars;
|
|
288
288
|
const current = map.get(varName) || 0;
|
|
289
289
|
const newVal = current - amount;
|
|
290
290
|
map.set(varName, newVal);
|
|
@@ -681,6 +681,14 @@ interface Context {
|
|
|
681
681
|
}
|
|
682
682
|
|
|
683
683
|
const globalVars = new Map<string, any>();
|
|
684
|
+
// Per-element store for \`:name\` variables (scope 'local' from the mini-parser).
|
|
685
|
+
// Persists per-element across event firings, isolated per element.
|
|
686
|
+
const elementVars = new WeakMap<Element, Map<string, any>>();
|
|
687
|
+
function elemScope(el: Element): Map<string, any> {
|
|
688
|
+
let m = elementVars.get(el);
|
|
689
|
+
if (!m) { m = new Map<string, any>(); elementVars.set(el, m); }
|
|
690
|
+
return m;
|
|
691
|
+
}
|
|
684
692
|
${hasBlocks ? `const MAX_LOOP_ITERATIONS = ${maxLoopIterations};` : ''}
|
|
685
693
|
|
|
686
694
|
async function evaluate(node: ASTNode, ctx: Context): Promise<any> {
|
|
@@ -700,7 +708,7 @@ async function evaluate(node: ASTNode, ctx: Context): Promise<any> {
|
|
|
700
708
|
return node.value;
|
|
701
709
|
|
|
702
710
|
case 'variable':
|
|
703
|
-
if (node.scope === 'local') return ctx.
|
|
711
|
+
if (node.scope === 'local') return elemScope(ctx.me).get(node.name.slice(1));
|
|
704
712
|
const gName = node.name.slice(1);
|
|
705
713
|
if (globalVars.has(gName)) return globalVars.get(gName);
|
|
706
714
|
return (window as any)[node.name];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{D as n,d as i}from"./browser-modular-
|
|
2
|
-
//# sourceMappingURL=bridge-
|
|
1
|
+
import{D as n,d as i}from"./browser-modular-DegkWQ8d.js";import"./feature-sockets-CrYvjZ4j.js";let e=null;async function t(){return e||(e=await import("./browser-modular-DegkWQ8d.js").then(function(n){return n.n})),e}class a{constructor(i={}){this._initialized=!1,this.config={confidenceThreshold:i.confidenceThreshold??n,fallbackOnLowConfidence:i.fallbackOnLowConfidence??!0}}async initialize(){await t(),this._initialized=!0}isInitialized(){return this._initialized}async transform(n,i,e){if(this.isInitialized()||await this.initialize(),i===e)return{output:n,usedSemantic:!1,confidence:1,sourceLang:i,targetLang:e};const a=await t();try{const t=a.translate(n,i,e);if(t!==n)return{output:t,usedSemantic:!0,confidence:.9,sourceLang:i,targetLang:e}}catch{}return{output:n,usedSemantic:!1,confidence:0,sourceLang:i,targetLang:e}}async parse(n,i){this.isInitialized()||await this.initialize();return(await t()).parseSemantic(n,i).node??null}async render(n,i){return(await t()).render(n,i)}async parseToAST(n,i){this.isInitialized()||await this.initialize();const e=await t(),a=e.parseSemantic(n,i);if(a.confidence>=this.config.confidenceThreshold&&a.node)try{return e.buildAST(a.node).ast}catch(n){}return null}async parseToASTWithDetails(n,i){this.isInitialized()||await this.initialize();const e=await t(),a=e.parseSemantic(n,i);if(a.confidence>=this.config.confidenceThreshold&&a.node)try{const n=e.buildAST(a.node);return{ast:n.ast,usedDirectPath:!0,confidence:a.confidence,lang:i,fallbackText:null,warnings:n.warnings}}catch{}if(a.node&&this.config.fallbackOnLowConfidence){const n=e.render(a.node,"en");return{ast:null,usedDirectPath:!1,confidence:a.confidence,lang:i,fallbackText:n}}return{ast:null,usedDirectPath:!1,confidence:a.confidence,lang:i,fallbackText:null}}async getAllTranslations(n,i){const e=(await t()).getSupportedLanguages(),a={};for(const t of e)a[t]=await this.transform(n,i,t);return a}}export{a as SemanticGrammarBridge};
|
|
2
|
+
//# sourceMappingURL=bridge-lZbOVRDD.js.map
|