@hyperfixi/core 2.7.1 → 2.7.2

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.
@@ -1,5 +1,14 @@
1
1
  'use strict';
2
2
 
3
+ function ensureDomGlobals() {
4
+ if (typeof globalThis.Element === 'undefined') {
5
+ globalThis.Element = class {
6
+ };
7
+ }
8
+ return true;
9
+ }
10
+ ensureDomGlobals();
11
+
3
12
  // src/morphlex.ts
4
13
  var SUPPORTS_MOVE_BEFORE = "moveBefore" in Element.prototype;
5
14
  var ELEMENT_NODE_TYPE = 1;
@@ -551,7 +560,7 @@ function longestIncreasingSubsequence(sequence) {
551
560
  //# debugId=3F4BCB911DEC843864756E2164756E21
552
561
 
553
562
  function toMorphlexOptions(options) {
554
- return { preserveChanges: options?.preserveChanges ?? true };
563
+ return { preserveChanges: (options?.preserveChanges ?? true) };
555
564
  }
556
565
  const morphAdapter = {
557
566
  morph(target, content, options) {
@@ -1,3 +1,12 @@
1
+ function ensureDomGlobals() {
2
+ if (typeof globalThis.Element === 'undefined') {
3
+ globalThis.Element = class {
4
+ };
5
+ }
6
+ return true;
7
+ }
8
+ ensureDomGlobals();
9
+
1
10
  // src/morphlex.ts
2
11
  var SUPPORTS_MOVE_BEFORE = "moveBefore" in Element.prototype;
3
12
  var ELEMENT_NODE_TYPE = 1;
@@ -549,7 +558,7 @@ function longestIncreasingSubsequence(sequence) {
549
558
  //# debugId=3F4BCB911DEC843864756E2164756E21
550
559
 
551
560
  function toMorphlexOptions(options) {
552
- return { preserveChanges: options?.preserveChanges ?? true };
561
+ return { preserveChanges: (options?.preserveChanges ?? true) };
553
562
  }
554
563
  const morphAdapter = {
555
564
  morph(target, content, options) {
@@ -1,2 +1,2 @@
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
1
+ import{D as n,d as i}from"./browser-modular-DW4nC6lH.js";import"./feature-sockets-CrYvjZ4j.js";let e=null;async function t(){return e||(e=await import("./browser-modular-DW4nC6lH.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-DuveK8T4.js.map