@hyperfixi/core 2.2.1 → 2.3.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.
Files changed (43) hide show
  1. package/README.md +8 -11
  2. package/dist/bundle-generator/index.js +25 -4
  3. package/dist/bundle-generator/index.mjs +25 -4
  4. package/dist/chunks/{bridge-BELRwj7r.js → bridge-Clbh_xAj.js} +2 -2
  5. package/dist/chunks/browser-modular-DIOxQqhV.js +2 -0
  6. package/dist/chunks/{index-lsDi6izr.js → index-DcxoRUBe.js} +2 -2
  7. package/dist/commands/index.js +36 -6
  8. package/dist/commands/index.mjs +36 -6
  9. package/dist/core/base-expression-evaluator.d.ts +4 -0
  10. package/dist/expressions/index.js +10 -0
  11. package/dist/expressions/index.mjs +10 -0
  12. package/dist/hyperfixi-classic-i18n.js +1 -1
  13. package/dist/hyperfixi-hx.js +1 -1
  14. package/dist/hyperfixi-hybrid-complete.js +1 -1
  15. package/dist/hyperfixi-minimal.js +1 -1
  16. package/dist/hyperfixi-multilingual.js +1 -1
  17. package/dist/hyperfixi-standard.js +1 -1
  18. package/dist/hyperfixi.js +1 -1
  19. package/dist/hyperfixi.mjs +1 -1
  20. package/dist/index.js +175 -79
  21. package/dist/index.min.js +1 -1
  22. package/dist/index.mjs +175 -79
  23. package/dist/lokascript-browser-classic-i18n.js +1 -1
  24. package/dist/lokascript-browser-minimal.js +1 -1
  25. package/dist/lokascript-browser-standard.js +1 -1
  26. package/dist/lokascript-browser.js +1 -1
  27. package/dist/lokascript-hybrid-complete.js +1 -1
  28. package/dist/lokascript-hybrid-hx.js +1 -1
  29. package/dist/lokascript-multilingual.js +1 -1
  30. package/dist/parser/full-parser.js +119 -70
  31. package/dist/parser/full-parser.mjs +119 -70
  32. package/dist/parser/hybrid/index.js +7 -0
  33. package/dist/parser/hybrid/index.mjs +7 -0
  34. package/dist/parser/hybrid/parser-core.js +7 -0
  35. package/dist/parser/hybrid/parser-core.mjs +7 -0
  36. package/dist/parser/hybrid/tokenizer.js +7 -0
  37. package/dist/parser/hybrid/tokenizer.mjs +7 -0
  38. package/dist/parser/hybrid-parser.js +7 -0
  39. package/dist/parser/hybrid-parser.mjs +7 -0
  40. package/dist/registry/index.js +10 -0
  41. package/dist/registry/index.mjs +10 -0
  42. package/package.json +1 -1
  43. package/dist/chunks/browser-modular-B7Bb-ABs.js +0 -2
package/README.md CHANGED
@@ -1,12 +1,10 @@
1
1
  # @lokascript/core
2
2
 
3
- 🚀 **Complete hyperscript implementation with 100% \_hyperscript compatibility**
4
-
5
- An experimental hyperscript engine that provides fast parsing, command execution, and comprehensive error handling for web applications. Built with TypeScript-first design and full compatibility with the official \_hyperscript library.
3
+ An experimental hyperscript engine that provides fast parsing, command execution, and comprehensive error handling for web applications. Built with TypeScript-first design.
6
4
 
7
5
  ## Features
8
6
 
9
- - 🎯 **100% \_hyperscript Compatible** - Full compatibility with official \_hyperscript library
7
+ - 🎯 **\_hyperscript Compatible** - Tested via gallery examples, bundle compatibility matrix, and command/expression browser tests
10
8
  - 🚀 **High Performance** - Optimized tokenizer and parser for large expressions
11
9
  - 🔧 **TypeScript First** - Complete type safety with comprehensive type definitions
12
10
  - 🧪 **Thoroughly Tested** - 2800+ tests with 98.5%+ reliability
@@ -170,7 +168,7 @@ For complete API documentation, see [API.md](./docs/API.md).
170
168
  - **Async Operations**: `wait 500ms`, `fetch "/api/data"`
171
169
  - **Events**: `send customEvent to me`
172
170
 
173
- ### Expressions (100% \_hyperscript Compatible)
171
+ ### Expressions
174
172
 
175
173
  - **Arithmetic**: `5 + 3 * 2`, `value / 2`, `x mod 3`
176
174
  - **Logical**: `true and false`, `value > 10`, `x contains y`
@@ -204,14 +202,13 @@ npx playwright test --grep "Command Tests"
204
202
  npx playwright test --grep "Expression Tests"
205
203
  ```
206
204
 
207
- The compatibility tests measure:
205
+ Compatibility is validated via Playwright browser tests:
208
206
 
209
- - **Expression compatibility**: **100%** (15/15 tests passing)
210
- - **Command compatibility**: **100%** (2/2 core tests passing)
211
- - **HTML Integration**: **100%** (3/3 integration tests passing)
212
- - **Overall compatibility**: **~95%** across all hyperscript features ✅
207
+ - **Gallery examples** real hyperscript patterns load and execute without errors
208
+ - **Bundle compatibility matrix** each bundle size correctly supports its documented features
209
+ - **Command/expression tests** individual commands and expressions verified in browser context
213
210
 
214
- View detailed test results at `http://localhost:9323` after running browser tests.
211
+ Run `cd packages/core && npx playwright test` for the full browser test suite.
215
212
 
216
213
  ## License
217
214
 
@@ -811,10 +811,31 @@ function evaluatePositional(node: ASTNode, ctx: Context): Element | null {
811
811
  switch (node.position) {
812
812
  case 'first': return elements[0] || null;
813
813
  case 'last': return elements[elements.length - 1] || null;
814
- case 'next': return ctx.me.nextElementSibling;
815
- case 'previous': return ctx.me.previousElementSibling;
816
- case 'closest': return target.value ? ctx.me.closest(target.value) : null;
817
- case 'parent': return ctx.me.parentElement;
814
+ case 'next': {
815
+ if (selector) {
816
+ let el = ctx.me.nextElementSibling;
817
+ while (el) { if (el.matches(selector)) return el; el = el.nextElementSibling; }
818
+ return null;
819
+ }
820
+ return ctx.me.nextElementSibling;
821
+ }
822
+ case 'previous': {
823
+ if (selector) {
824
+ let el = ctx.me.previousElementSibling;
825
+ while (el) { if (el.matches(selector)) return el; el = el.previousElementSibling; }
826
+ return null;
827
+ }
828
+ return ctx.me.previousElementSibling;
829
+ }
830
+ case 'closest': return selector ? ctx.me.closest(selector) : null;
831
+ case 'parent': {
832
+ if (selector) {
833
+ let el = ctx.me.parentElement;
834
+ while (el) { if (el.matches(selector)) return el; el = el.parentElement; }
835
+ return null;
836
+ }
837
+ return ctx.me.parentElement;
838
+ }
818
839
  default: return elements[0] || null;
819
840
  }
820
841
  }
@@ -809,10 +809,31 @@ function evaluatePositional(node: ASTNode, ctx: Context): Element | null {
809
809
  switch (node.position) {
810
810
  case 'first': return elements[0] || null;
811
811
  case 'last': return elements[elements.length - 1] || null;
812
- case 'next': return ctx.me.nextElementSibling;
813
- case 'previous': return ctx.me.previousElementSibling;
814
- case 'closest': return target.value ? ctx.me.closest(target.value) : null;
815
- case 'parent': return ctx.me.parentElement;
812
+ case 'next': {
813
+ if (selector) {
814
+ let el = ctx.me.nextElementSibling;
815
+ while (el) { if (el.matches(selector)) return el; el = el.nextElementSibling; }
816
+ return null;
817
+ }
818
+ return ctx.me.nextElementSibling;
819
+ }
820
+ case 'previous': {
821
+ if (selector) {
822
+ let el = ctx.me.previousElementSibling;
823
+ while (el) { if (el.matches(selector)) return el; el = el.previousElementSibling; }
824
+ return null;
825
+ }
826
+ return ctx.me.previousElementSibling;
827
+ }
828
+ case 'closest': return selector ? ctx.me.closest(selector) : null;
829
+ case 'parent': {
830
+ if (selector) {
831
+ let el = ctx.me.parentElement;
832
+ while (el) { if (el.matches(selector)) return el; el = el.parentElement; }
833
+ return null;
834
+ }
835
+ return ctx.me.parentElement;
836
+ }
816
837
  default: return elements[0] || null;
817
838
  }
818
839
  }
@@ -1,2 +1,2 @@
1
- import{D as n}from"./browser-modular-B7Bb-ABs.js";import"./feature-sockets-ClOH7vk7.js";let e=null;async function t(){return e||(e=await import("./browser-modular-B7Bb-ABs.js").then(function(n){return n.o})),e}class a{constructor(e={}){this.analyzer=null,this.config={confidenceThreshold:e.confidenceThreshold??n,fallbackOnLowConfidence:e.fallbackOnLowConfidence??!0}}async initialize(){const n=await t();this.analyzer=n.createSemanticAnalyzer()}isInitialized(){return null!==this.analyzer}async transform(n,e,a){if(this.isInitialized()||await this.initialize(),e===a)return{output:n,usedSemantic:!1,confidence:1,sourceLang:e,targetLang:a};const i=await t();try{const t=i.translate(n,e,a);if(t!==n)return{output:t,usedSemantic:!0,confidence:.9,sourceLang:e,targetLang:a}}catch{}return{output:n,usedSemantic:!1,confidence:0,sourceLang:e,targetLang:a}}async parse(n,e){if(this.isInitialized()||await this.initialize(),!this.analyzer)return null;return this.analyzer.analyze(n,e).node??null}async render(n,e){return(await t()).render(n,e)}async parseToAST(n,e){if(this.isInitialized()||await this.initialize(),!this.analyzer)return null;const a=this.analyzer.analyze(n,e);if(a.confidence>=this.config.confidenceThreshold&&a.node){const n=await t();try{return n.buildAST(a.node).ast}catch(n){}}return null}async parseToASTWithDetails(n,e){if(this.isInitialized()||await this.initialize(),!this.analyzer)return{ast:null,usedDirectPath:!1,confidence:0,lang:e,fallbackText:null};const a=this.analyzer.analyze(n,e),i=await t();if(a.confidence>=this.config.confidenceThreshold&&a.node)try{const n=i.buildAST(a.node);return{ast:n.ast,usedDirectPath:!0,confidence:a.confidence,lang:e,fallbackText:null,warnings:n.warnings}}catch{}if(a.node&&this.config.fallbackOnLowConfidence){const n=i.render(a.node,"en");return{ast:null,usedDirectPath:!1,confidence:a.confidence,lang:e,fallbackText:n}}return{ast:null,usedDirectPath:!1,confidence:a.confidence,lang:e,fallbackText:null}}async getAllTranslations(n,e){const a=(await t()).getSupportedLanguages(),i={};for(const t of a)i[t]=await this.transform(n,e,t);return i}}export{a as SemanticGrammarBridge};
2
- //# sourceMappingURL=bridge-BELRwj7r.js.map
1
+ import{D as n}from"./browser-modular-DIOxQqhV.js";import"./feature-sockets-ClOH7vk7.js";let e=null;async function t(){return e||(e=await import("./browser-modular-DIOxQqhV.js").then(function(n){return n.o})),e}class a{constructor(e={}){this.analyzer=null,this.config={confidenceThreshold:e.confidenceThreshold??n,fallbackOnLowConfidence:e.fallbackOnLowConfidence??!0}}async initialize(){const n=await t();this.analyzer=n.createSemanticAnalyzer()}isInitialized(){return null!==this.analyzer}async transform(n,e,a){if(this.isInitialized()||await this.initialize(),e===a)return{output:n,usedSemantic:!1,confidence:1,sourceLang:e,targetLang:a};const i=await t();try{const t=i.translate(n,e,a);if(t!==n)return{output:t,usedSemantic:!0,confidence:.9,sourceLang:e,targetLang:a}}catch{}return{output:n,usedSemantic:!1,confidence:0,sourceLang:e,targetLang:a}}async parse(n,e){if(this.isInitialized()||await this.initialize(),!this.analyzer)return null;return this.analyzer.analyze(n,e).node??null}async render(n,e){return(await t()).render(n,e)}async parseToAST(n,e){if(this.isInitialized()||await this.initialize(),!this.analyzer)return null;const a=this.analyzer.analyze(n,e);if(a.confidence>=this.config.confidenceThreshold&&a.node){const n=await t();try{return n.buildAST(a.node).ast}catch(n){}}return null}async parseToASTWithDetails(n,e){if(this.isInitialized()||await this.initialize(),!this.analyzer)return{ast:null,usedDirectPath:!1,confidence:0,lang:e,fallbackText:null};const a=this.analyzer.analyze(n,e),i=await t();if(a.confidence>=this.config.confidenceThreshold&&a.node)try{const n=i.buildAST(a.node);return{ast:n.ast,usedDirectPath:!0,confidence:a.confidence,lang:e,fallbackText:null,warnings:n.warnings}}catch{}if(a.node&&this.config.fallbackOnLowConfidence){const n=i.render(a.node,"en");return{ast:null,usedDirectPath:!1,confidence:a.confidence,lang:e,fallbackText:n}}return{ast:null,usedDirectPath:!1,confidence:a.confidence,lang:e,fallbackText:null}}async getAllTranslations(n,e){const a=(await t()).getSupportedLanguages(),i={};for(const t of a)i[t]=await this.transform(n,e,t);return i}}export{a as SemanticGrammarBridge};
2
+ //# sourceMappingURL=bridge-Clbh_xAj.js.map