@hyperfixi/core 2.10.0 → 2.11.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.
Files changed (43) hide show
  1. package/dist/ast-utils/index.js +109 -8
  2. package/dist/ast-utils/index.mjs +109 -8
  3. package/dist/behaviors/index.js +2 -1
  4. package/dist/behaviors/index.mjs +2 -1
  5. package/dist/chunks/{bridge-CPNAPYAo.js → bridge-De7lnU_9.js} +2 -2
  6. package/dist/chunks/browser-modular-DpHHlmJ0.js +2 -0
  7. package/dist/chunks/{index-BQkkNlzO.js → index-D6-8bcsy.js} +2 -2
  8. package/dist/commands/helpers/dom-mutation.d.ts +3 -2
  9. package/dist/commands/helpers/index.d.ts +1 -1
  10. package/dist/commands/index.js +74 -8
  11. package/dist/commands/index.mjs +74 -8
  12. package/dist/hyperfixi-browser-classic-i18n.js +1 -1
  13. package/dist/hyperfixi-browser-minimal.js +1 -1
  14. package/dist/hyperfixi-browser-standard.js +1 -1
  15. package/dist/hyperfixi-browser.js +1 -1
  16. package/dist/hyperfixi-classic-i18n.js +1 -1
  17. package/dist/hyperfixi-hx-v4.js +1 -1
  18. package/dist/hyperfixi-minimal.js +1 -1
  19. package/dist/hyperfixi-multilingual.js +1 -1
  20. package/dist/hyperfixi-standard.js +1 -1
  21. package/dist/hyperfixi.js +1 -1
  22. package/dist/hyperfixi.mjs +1 -1
  23. package/dist/index.js +224 -33
  24. package/dist/index.min.js +1 -1
  25. package/dist/index.mjs +224 -33
  26. package/dist/lokascript-browser-classic-i18n.js +1 -1
  27. package/dist/lokascript-browser-minimal.js +1 -1
  28. package/dist/lokascript-browser-standard.js +1 -1
  29. package/dist/lokascript-browser.js +1 -1
  30. package/dist/lokascript-multilingual.js +1 -1
  31. package/dist/lsp-metadata.js +2 -2
  32. package/dist/lsp-metadata.mjs +2 -2
  33. package/dist/metadata.d.ts +1 -1
  34. package/dist/metadata.js +13 -11
  35. package/dist/metadata.mjs +13 -11
  36. package/dist/reference/index.js +7 -2
  37. package/dist/reference/index.mjs +7 -2
  38. package/dist/registry/index.js +6 -4
  39. package/dist/registry/index.mjs +6 -4
  40. package/dist/utils/element-check.d.ts +1 -0
  41. package/dist/version.d.ts +2 -0
  42. package/package.json +5 -5
  43. package/dist/chunks/browser-modular-B0lGdcoP.js +0 -2
@@ -5522,7 +5522,13 @@ var init_command_schemas = __esm({
5522
5522
  expectedTypes: ["selector"],
5523
5523
  selectorKinds: ["class", "attribute"],
5524
5524
  svoPosition: 1,
5525
- sovPosition: 2
5525
+ sovPosition: 2,
5526
+ // zh: the transformer emits `\u5207\u6362 \u628a .active` (the profile's \u628a patient
5527
+ // marker), but natural zh writes `\u5207\u6362 .active` bare \u2014 the handcrafted
5528
+ // patterns' form. Optional accepts both; without it the generated
5529
+ // pattern REQUIRED \u628a and the slim bundles could not parse the bare
5530
+ // form at all. Same treatment as go's destination.
5531
+ markerOptional: { zh: true }
5526
5532
  },
5527
5533
  {
5528
5534
  role: "destination",
@@ -5860,6 +5866,8 @@ var init_command_schemas = __esm({
5860
5866
  markerOverride: {
5861
5867
  en: "",
5862
5868
  // No marker before destination in English: "set :x to 5"
5869
+ es: "",
5870
+ // "establecer x a 5" - no marker before variable (profile default `en` matched nothing)
5863
5871
  ja: "\u3092",
5864
5872
  // "x \u3092 10 \u306b \u8a2d\u5b9a" - variable gets object marker
5865
5873
  ko: "\uB97C",
@@ -5882,9 +5890,19 @@ var init_command_schemas = __esm({
5882
5890
  // generated hi set patterns carried the swapped markers and matched no
5883
5891
  // corpus, so the whole hi set-family (set-text/inner-html/style/attribute)
5884
5892
  // fell to the bare-event fallback (S6 set-trio).
5885
- hi: "\u0915\u094B"
5893
+ hi: "\u0915\u094B",
5886
5894
  // target (destination) gets \u0915\u094b
5887
- }
5895
+ // zh: the transformer emits the verb-first BA form `\u8bbe\u7f6e \u628a X \u5230 V`
5896
+ // (\u628a before the variable), while natural zh writes `\u8bbe\u7f6e X \u4e3a V`
5897
+ // (unmarked). \u628a as the marker, optional below, accepts both. The
5898
+ // profile default \u5728 matched neither form, so the generated zh set
5899
+ // patterns were dead weight and the slim bundles (schema-generated
5900
+ // patterns only) could not parse set at all.
5901
+ zh: "\u628A"
5902
+ },
5903
+ // Accept the unmarked natural form alongside the transformer's \u628a form
5904
+ // (same treatment as go's destination).
5905
+ markerOptional: { zh: true }
5888
5906
  },
5889
5907
  {
5890
5908
  role: "patient",
@@ -5927,8 +5945,14 @@ var init_command_schemas = __esm({
5927
5945
  // "x \u0995\u09c7 10 \u09a4\u09c7 \u09b8\u09c7\u099f" - destination marker on value
5928
5946
  qu: "man",
5929
5947
  // "x ta 10 man churay" - destination marker on value
5930
- hi: "\u092E\u0947\u0902"
5948
+ hi: "\u092E\u0947\u0902",
5931
5949
  // value (patient) gets \u092e\u0947\u0902 \u2014 see the destination note above
5950
+ // zh: the transformer/corpus form marks the value with \u5230 (`\u8bbe\u7f6e \u628a X
5951
+ // \u5230 V`); natural zh uses \u4e3a (`\u8bbe\u7f6e X \u4e3a V`). \u5230 is the override,
5952
+ // the \u4e3a-family rides along as variants (all merged as alternatives
5953
+ // by schemaMarkerAlternatives). Profile default \u628a was the PATIENT
5954
+ // marker, which never precedes set's value in either form.
5955
+ zh: "\u5230"
5932
5956
  },
5933
5957
  // Turkish dative is allomorphic under vowel harmony: the i18n transformer
5934
5958
  // emits `e` for quoted-string values (`"red" e`) but `-ya` for a value
@@ -5941,7 +5965,11 @@ var init_command_schemas = __esm({
5941
5965
  // not parse as a bare command while `t\u0131klama da @disabled i do\u011fru ya
5942
5966
  // ayarla` did. See STRUCTURAL_ARCS_ROADMAP.md (tr set-attribute).
5943
5967
  markerVariants: {
5944
- tr: ["e", "a", "ye", "ya"]
5968
+ tr: ["e", "a", "ye", "ya"],
5969
+ // Natural zh value markers (`\u8bbe\u7f6e X \u4e3a V`), simplified + traditional +
5970
+ // resultative \u2014 the handcrafted set-zh-full alternatives, kept parseable
5971
+ // alongside the transformer's \u5230 override above.
5972
+ zh: ["\u4E3A", "\u70BA", "\u6210"]
5945
5973
  }
5946
5974
  },
5947
5975
  {
@@ -29375,9 +29403,10 @@ function appendOptionalTailRole(tokens, extraction, commandSchema, languageCode,
29375
29403
  type: "group",
29376
29404
  optional: true,
29377
29405
  tokens: [
29378
- ...(marker ? marker.split(/\s+/) : []).map(
29379
- (word) => ({ type: "literal", value: word })
29380
- ),
29406
+ ...(marker ? marker.split(/\s+/) : []).map((word) => ({
29407
+ type: "literal",
29408
+ value: word
29409
+ })),
29381
29410
  {
29382
29411
  type: "role",
29383
29412
  role,
@@ -29508,6 +29537,70 @@ function generateSOVPatientFirstEventHandlerPattern(commandSchema, profile, keyw
29508
29537
  extraction
29509
29538
  };
29510
29539
  }
29540
+ function generateSOVPatientFirstSourceFrontedEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config) {
29541
+ const sourceSpec = commandSchema.roles.find((r) => r.role === "source");
29542
+ if (!sourceSpec) return null;
29543
+ const { marker: sourceMarker, alternatives: sourceAlts } = resolveRoleMarker(sourceSpec, profile);
29544
+ const patientMarker = profile.roleMarkers.patient;
29545
+ if (!sourceMarker) return null;
29546
+ if (sourceMarker === eventMarker.primary || sourceMarker === patientMarker?.primary) return null;
29547
+ const tokens = [];
29548
+ tokens.push({ type: "role", role: "patient", optional: false });
29549
+ if (patientMarker) {
29550
+ tokens.push(
29551
+ patientMarker.alternatives ? {
29552
+ type: "literal",
29553
+ value: patientMarker.primary,
29554
+ alternatives: patientMarker.alternatives
29555
+ } : { type: "literal", value: patientMarker.primary }
29556
+ );
29557
+ }
29558
+ tokens.push({
29559
+ type: "role",
29560
+ role: "source",
29561
+ optional: false,
29562
+ ...sourceSpec.expectedTypes ? { expectedTypes: sourceSpec.expectedTypes } : {},
29563
+ ...sourceSpec.valueShape !== void 0 ? { valueShape: sourceSpec.valueShape } : {}
29564
+ });
29565
+ for (const word of sourceMarker.split(/\s+/)) {
29566
+ tokens.push(
29567
+ sourceAlts && sourceMarker.split(/\s+/).length === 1 ? { type: "literal", value: word, alternatives: sourceAlts } : { type: "literal", value: word }
29568
+ );
29569
+ }
29570
+ tokens.push({ type: "role", role: "event", optional: false });
29571
+ if (eventMarker.position === "after") {
29572
+ const markerWords = eventMarker.primary.split(/\s+/);
29573
+ if (markerWords.length > 1) {
29574
+ for (const word of markerWords) tokens.push({ type: "literal", value: word });
29575
+ } else {
29576
+ tokens.push(
29577
+ eventMarker.alternatives ? { type: "literal", value: eventMarker.primary, alternatives: eventMarker.alternatives } : { type: "literal", value: eventMarker.primary }
29578
+ );
29579
+ }
29580
+ }
29581
+ tokens.push(
29582
+ keyword.alternatives ? { type: "literal", value: keyword.primary, alternatives: keyword.alternatives } : { type: "literal", value: keyword.primary }
29583
+ );
29584
+ const extraction = {
29585
+ action: { value: commandSchema.action },
29586
+ event: { fromRole: "event" },
29587
+ patient: { fromRole: "patient" },
29588
+ source: { fromRole: "source" }
29589
+ };
29590
+ appendOptionalRecipient(tokens, extraction, commandSchema, profile.code);
29591
+ appendOptionalViewTransition(tokens, extraction, commandSchema, profile.code);
29592
+ return {
29593
+ id: `${commandSchema.action}-event-${profile.code}-sov-source-fronted`,
29594
+ language: profile.code,
29595
+ command: "on",
29596
+ priority: (config.basePriority ?? 100) + 48,
29597
+ template: {
29598
+ format: `{patient} ${patientMarker?.primary || ""} {source} ${sourceMarker} {event} ${eventMarker.primary} ${keyword.primary}`,
29599
+ tokens
29600
+ },
29601
+ extraction
29602
+ };
29603
+ }
29511
29604
  function generateSOVPatientFirstWithDestEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config) {
29512
29605
  const tokens = [];
29513
29606
  tokens.push({ type: "role", role: "patient", optional: false });
@@ -30383,6 +30476,14 @@ function generateEventHandlerPatterns(commandSchema, profile, config = defaultCo
30383
30476
  config
30384
30477
  )
30385
30478
  );
30479
+ const sourceFronted = generateSOVPatientFirstSourceFrontedEventHandlerPattern(
30480
+ commandSchema,
30481
+ profile,
30482
+ keyword,
30483
+ eventMarker,
30484
+ config
30485
+ );
30486
+ if (sourceFronted) patterns.push(sourceFronted);
30386
30487
  const destMarkerCheck = profile.roleMarkers.destination;
30387
30488
  if (destMarkerCheck && destMarkerCheck.primary !== eventMarker.primary) {
30388
30489
  patterns.push(
@@ -5520,7 +5520,13 @@ var init_command_schemas = __esm({
5520
5520
  expectedTypes: ["selector"],
5521
5521
  selectorKinds: ["class", "attribute"],
5522
5522
  svoPosition: 1,
5523
- sovPosition: 2
5523
+ sovPosition: 2,
5524
+ // zh: the transformer emits `\u5207\u6362 \u628a .active` (the profile's \u628a patient
5525
+ // marker), but natural zh writes `\u5207\u6362 .active` bare \u2014 the handcrafted
5526
+ // patterns' form. Optional accepts both; without it the generated
5527
+ // pattern REQUIRED \u628a and the slim bundles could not parse the bare
5528
+ // form at all. Same treatment as go's destination.
5529
+ markerOptional: { zh: true }
5524
5530
  },
5525
5531
  {
5526
5532
  role: "destination",
@@ -5858,6 +5864,8 @@ var init_command_schemas = __esm({
5858
5864
  markerOverride: {
5859
5865
  en: "",
5860
5866
  // No marker before destination in English: "set :x to 5"
5867
+ es: "",
5868
+ // "establecer x a 5" - no marker before variable (profile default `en` matched nothing)
5861
5869
  ja: "\u3092",
5862
5870
  // "x \u3092 10 \u306b \u8a2d\u5b9a" - variable gets object marker
5863
5871
  ko: "\uB97C",
@@ -5880,9 +5888,19 @@ var init_command_schemas = __esm({
5880
5888
  // generated hi set patterns carried the swapped markers and matched no
5881
5889
  // corpus, so the whole hi set-family (set-text/inner-html/style/attribute)
5882
5890
  // fell to the bare-event fallback (S6 set-trio).
5883
- hi: "\u0915\u094B"
5891
+ hi: "\u0915\u094B",
5884
5892
  // target (destination) gets \u0915\u094b
5885
- }
5893
+ // zh: the transformer emits the verb-first BA form `\u8bbe\u7f6e \u628a X \u5230 V`
5894
+ // (\u628a before the variable), while natural zh writes `\u8bbe\u7f6e X \u4e3a V`
5895
+ // (unmarked). \u628a as the marker, optional below, accepts both. The
5896
+ // profile default \u5728 matched neither form, so the generated zh set
5897
+ // patterns were dead weight and the slim bundles (schema-generated
5898
+ // patterns only) could not parse set at all.
5899
+ zh: "\u628A"
5900
+ },
5901
+ // Accept the unmarked natural form alongside the transformer's \u628a form
5902
+ // (same treatment as go's destination).
5903
+ markerOptional: { zh: true }
5886
5904
  },
5887
5905
  {
5888
5906
  role: "patient",
@@ -5925,8 +5943,14 @@ var init_command_schemas = __esm({
5925
5943
  // "x \u0995\u09c7 10 \u09a4\u09c7 \u09b8\u09c7\u099f" - destination marker on value
5926
5944
  qu: "man",
5927
5945
  // "x ta 10 man churay" - destination marker on value
5928
- hi: "\u092E\u0947\u0902"
5946
+ hi: "\u092E\u0947\u0902",
5929
5947
  // value (patient) gets \u092e\u0947\u0902 \u2014 see the destination note above
5948
+ // zh: the transformer/corpus form marks the value with \u5230 (`\u8bbe\u7f6e \u628a X
5949
+ // \u5230 V`); natural zh uses \u4e3a (`\u8bbe\u7f6e X \u4e3a V`). \u5230 is the override,
5950
+ // the \u4e3a-family rides along as variants (all merged as alternatives
5951
+ // by schemaMarkerAlternatives). Profile default \u628a was the PATIENT
5952
+ // marker, which never precedes set's value in either form.
5953
+ zh: "\u5230"
5930
5954
  },
5931
5955
  // Turkish dative is allomorphic under vowel harmony: the i18n transformer
5932
5956
  // emits `e` for quoted-string values (`"red" e`) but `-ya` for a value
@@ -5939,7 +5963,11 @@ var init_command_schemas = __esm({
5939
5963
  // not parse as a bare command while `t\u0131klama da @disabled i do\u011fru ya
5940
5964
  // ayarla` did. See STRUCTURAL_ARCS_ROADMAP.md (tr set-attribute).
5941
5965
  markerVariants: {
5942
- tr: ["e", "a", "ye", "ya"]
5966
+ tr: ["e", "a", "ye", "ya"],
5967
+ // Natural zh value markers (`\u8bbe\u7f6e X \u4e3a V`), simplified + traditional +
5968
+ // resultative \u2014 the handcrafted set-zh-full alternatives, kept parseable
5969
+ // alongside the transformer's \u5230 override above.
5970
+ zh: ["\u4E3A", "\u70BA", "\u6210"]
5943
5971
  }
5944
5972
  },
5945
5973
  {
@@ -29373,9 +29401,10 @@ function appendOptionalTailRole(tokens, extraction, commandSchema, languageCode,
29373
29401
  type: "group",
29374
29402
  optional: true,
29375
29403
  tokens: [
29376
- ...(marker ? marker.split(/\s+/) : []).map(
29377
- (word) => ({ type: "literal", value: word })
29378
- ),
29404
+ ...(marker ? marker.split(/\s+/) : []).map((word) => ({
29405
+ type: "literal",
29406
+ value: word
29407
+ })),
29379
29408
  {
29380
29409
  type: "role",
29381
29410
  role,
@@ -29506,6 +29535,70 @@ function generateSOVPatientFirstEventHandlerPattern(commandSchema, profile, keyw
29506
29535
  extraction
29507
29536
  };
29508
29537
  }
29538
+ function generateSOVPatientFirstSourceFrontedEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config) {
29539
+ const sourceSpec = commandSchema.roles.find((r) => r.role === "source");
29540
+ if (!sourceSpec) return null;
29541
+ const { marker: sourceMarker, alternatives: sourceAlts } = resolveRoleMarker(sourceSpec, profile);
29542
+ const patientMarker = profile.roleMarkers.patient;
29543
+ if (!sourceMarker) return null;
29544
+ if (sourceMarker === eventMarker.primary || sourceMarker === patientMarker?.primary) return null;
29545
+ const tokens = [];
29546
+ tokens.push({ type: "role", role: "patient", optional: false });
29547
+ if (patientMarker) {
29548
+ tokens.push(
29549
+ patientMarker.alternatives ? {
29550
+ type: "literal",
29551
+ value: patientMarker.primary,
29552
+ alternatives: patientMarker.alternatives
29553
+ } : { type: "literal", value: patientMarker.primary }
29554
+ );
29555
+ }
29556
+ tokens.push({
29557
+ type: "role",
29558
+ role: "source",
29559
+ optional: false,
29560
+ ...sourceSpec.expectedTypes ? { expectedTypes: sourceSpec.expectedTypes } : {},
29561
+ ...sourceSpec.valueShape !== void 0 ? { valueShape: sourceSpec.valueShape } : {}
29562
+ });
29563
+ for (const word of sourceMarker.split(/\s+/)) {
29564
+ tokens.push(
29565
+ sourceAlts && sourceMarker.split(/\s+/).length === 1 ? { type: "literal", value: word, alternatives: sourceAlts } : { type: "literal", value: word }
29566
+ );
29567
+ }
29568
+ tokens.push({ type: "role", role: "event", optional: false });
29569
+ if (eventMarker.position === "after") {
29570
+ const markerWords = eventMarker.primary.split(/\s+/);
29571
+ if (markerWords.length > 1) {
29572
+ for (const word of markerWords) tokens.push({ type: "literal", value: word });
29573
+ } else {
29574
+ tokens.push(
29575
+ eventMarker.alternatives ? { type: "literal", value: eventMarker.primary, alternatives: eventMarker.alternatives } : { type: "literal", value: eventMarker.primary }
29576
+ );
29577
+ }
29578
+ }
29579
+ tokens.push(
29580
+ keyword.alternatives ? { type: "literal", value: keyword.primary, alternatives: keyword.alternatives } : { type: "literal", value: keyword.primary }
29581
+ );
29582
+ const extraction = {
29583
+ action: { value: commandSchema.action },
29584
+ event: { fromRole: "event" },
29585
+ patient: { fromRole: "patient" },
29586
+ source: { fromRole: "source" }
29587
+ };
29588
+ appendOptionalRecipient(tokens, extraction, commandSchema, profile.code);
29589
+ appendOptionalViewTransition(tokens, extraction, commandSchema, profile.code);
29590
+ return {
29591
+ id: `${commandSchema.action}-event-${profile.code}-sov-source-fronted`,
29592
+ language: profile.code,
29593
+ command: "on",
29594
+ priority: (config.basePriority ?? 100) + 48,
29595
+ template: {
29596
+ format: `{patient} ${patientMarker?.primary || ""} {source} ${sourceMarker} {event} ${eventMarker.primary} ${keyword.primary}`,
29597
+ tokens
29598
+ },
29599
+ extraction
29600
+ };
29601
+ }
29509
29602
  function generateSOVPatientFirstWithDestEventHandlerPattern(commandSchema, profile, keyword, eventMarker, config) {
29510
29603
  const tokens = [];
29511
29604
  tokens.push({ type: "role", role: "patient", optional: false });
@@ -30381,6 +30474,14 @@ function generateEventHandlerPatterns(commandSchema, profile, config = defaultCo
30381
30474
  config
30382
30475
  )
30383
30476
  );
30477
+ const sourceFronted = generateSOVPatientFirstSourceFrontedEventHandlerPattern(
30478
+ commandSchema,
30479
+ profile,
30480
+ keyword,
30481
+ eventMarker,
30482
+ config
30483
+ );
30484
+ if (sourceFronted) patterns.push(sourceFronted);
30384
30485
  const destMarkerCheck = profile.roleMarkers.destination;
30385
30486
  if (destMarkerCheck && destMarkerCheck.primary !== eventMarker.primary) {
30386
30487
  patterns.push(
@@ -583,8 +583,9 @@ const morphAdapter = {
583
583
  function getStartViewTransition() {
584
584
  if (typeof document === 'undefined')
585
585
  return undefined;
586
- return document
586
+ const fn = document
587
587
  .startViewTransition;
588
+ return typeof fn === 'function' ? fn.bind(document) : undefined;
588
589
  }
589
590
  function isViewTransitionsSupported() {
590
591
  return typeof getStartViewTransition() === 'function';
@@ -581,8 +581,9 @@ const morphAdapter = {
581
581
  function getStartViewTransition() {
582
582
  if (typeof document === 'undefined')
583
583
  return undefined;
584
- return document
584
+ const fn = document
585
585
  .startViewTransition;
586
+ return typeof fn === 'function' ? fn.bind(document) : undefined;
586
587
  }
587
588
  function isViewTransitionsSupported() {
588
589
  return typeof getStartViewTransition() === 'function';
@@ -1,2 +1,2 @@
1
- import{D as n,d as i}from"./browser-modular-B0lGdcoP.js";import"./feature-sockets-CcTxD5sT.js";function e(n){const i=n.diagnostics;return i?.length?i.filter(n=>"unconsumed-input"===n.code).map(n=>n.message):[]}let t=null;async function a(){return t||(t=await import("./browser-modular-B0lGdcoP.js").then(function(n){return n.n})),t}class c{constructor(i={}){this._initialized=!1,this.config={confidenceThreshold:i.confidenceThreshold??n,fallbackOnLowConfidence:i.fallbackOnLowConfidence??!0}}async initialize(){await a(),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 t=await a();try{const a=t.translate(n,i,e);if(a!==n)return{output:a,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 a()).parseSemantic(n,i).node??null}async render(n,i){return(await a()).render(n,i)}async parseToAST(n,i){this.isInitialized()||await this.initialize();const e=await a(),t=e.parseSemantic(n,i);if(t.confidence>=this.config.confidenceThreshold&&t.node)try{return e.buildAST(t.node).ast}catch(n){}return null}async parseToASTWithDetails(n,i){this.isInitialized()||await this.initialize();const t=await a(),c=t.parseSemantic(n,i);if(c.confidence>=this.config.confidenceThreshold&&c.node)try{const n=t.buildAST(c.node);return{ast:n.ast,usedDirectPath:!0,confidence:c.confidence,lang:i,fallbackText:null,warnings:[...n.warnings??[],...e(c.node)]}}catch{}if(c.node&&this.config.fallbackOnLowConfidence){const n=t.render(c.node,"en");return{ast:null,usedDirectPath:!1,confidence:c.confidence,lang:i,fallbackText:n}}return{ast:null,usedDirectPath:!1,confidence:c.confidence,lang:i,fallbackText:null}}async getAllTranslations(n,i){const e=(await a()).getSupportedLanguages(),t={};for(const a of e)t[a]=await this.transform(n,i,a);return t}}export{c as SemanticGrammarBridge};
2
- //# sourceMappingURL=bridge-CPNAPYAo.js.map
1
+ import{D as n,d as i}from"./browser-modular-DpHHlmJ0.js";import"./feature-sockets-CcTxD5sT.js";function e(n){const i=n.diagnostics;return i?.length?i.filter(n=>"unconsumed-input"===n.code).map(n=>n.message):[]}let t=null;async function a(){return t||(t=await import("./browser-modular-DpHHlmJ0.js").then(function(n){return n.n})),t}class c{constructor(i={}){this._initialized=!1,this.config={confidenceThreshold:i.confidenceThreshold??n,fallbackOnLowConfidence:i.fallbackOnLowConfidence??!0}}async initialize(){await a(),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 t=await a();try{const a=t.translate(n,i,e);if(a!==n)return{output:a,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 a()).parseSemantic(n,i).node??null}async render(n,i){return(await a()).render(n,i)}async parseToAST(n,i){this.isInitialized()||await this.initialize();const e=await a(),t=e.parseSemantic(n,i);if(t.confidence>=this.config.confidenceThreshold&&t.node)try{return e.buildAST(t.node).ast}catch(n){}return null}async parseToASTWithDetails(n,i){this.isInitialized()||await this.initialize();const t=await a(),c=t.parseSemantic(n,i);if(c.confidence>=this.config.confidenceThreshold&&c.node)try{const n=t.buildAST(c.node);return{ast:n.ast,usedDirectPath:!0,confidence:c.confidence,lang:i,fallbackText:null,warnings:[...n.warnings??[],...e(c.node)]}}catch{}if(c.node&&this.config.fallbackOnLowConfidence){const n=t.render(c.node,"en");return{ast:null,usedDirectPath:!1,confidence:c.confidence,lang:i,fallbackText:n}}return{ast:null,usedDirectPath:!1,confidence:c.confidence,lang:i,fallbackText:null}}async getAllTranslations(n,i){const e=(await a()).getSupportedLanguages(),t={};for(const a of e)t[a]=await this.transform(n,i,a);return t}}export{c as SemanticGrammarBridge};
2
+ //# sourceMappingURL=bridge-De7lnU_9.js.map