@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
@@ -1,2 +1,2 @@
1
- let t=null;async function n(){if(!t)try{t=await import("./browser-modular-B0lGdcoP.js").then(function(t){return t.m})}catch{throw Error("@lokascript/framework is required for LSE support. Install it: npm install @lokascript/framework")}return t}function r(){if(t)return!0;try{return require.resolve("@lokascript/framework"),!0}catch{return!1}}async function a(t,r){return(await n()).parseExplicit(t,r)}async function o(t){return(await n()).isExplicitSyntax(t)}async function i(t){return(await n()).renderExplicit(t)}async function e(t){return(await n()).fromInterchangeNode(t)}async function c(t){return(await n()).toProtocolJSON(t)}async function u(t){return(await n()).fromProtocolJSON(t)}async function s(t){return(await n()).validateProtocolJSON(t)}async function f(t){return(await n()).toEnvelopeJSON(t)}async function l(t){return(await n()).fromEnvelopeJSON(t)}async function w(t){return(await n()).isEnvelope(t)}async function p(t){return(await n()).semanticNodeToRuntimeAST(t)}export{l as fromEnvelopeJSON,e as fromInterchangeNode,u as fromProtocolJSON,w as isEnvelope,o as isExplicitSyntax,r as isLSEAvailable,a as parseExplicit,i as renderExplicit,p as semanticNodeToRuntimeAST,f as toEnvelopeJSON,c as toProtocolJSON,s as validateProtocolJSON};
2
- //# sourceMappingURL=index-BQkkNlzO.js.map
1
+ let t=null;async function n(){if(!t)try{t=await import("./browser-modular-DpHHlmJ0.js").then(function(t){return t.m})}catch{throw Error("@lokascript/framework is required for LSE support. Install it: npm install @lokascript/framework")}return t}function r(){if(t)return!0;try{return require.resolve("@lokascript/framework"),!0}catch{return!1}}async function a(t,r){return(await n()).parseExplicit(t,r)}async function o(t){return(await n()).isExplicitSyntax(t)}async function i(t){return(await n()).renderExplicit(t)}async function e(t){return(await n()).fromInterchangeNode(t)}async function c(t){return(await n()).toProtocolJSON(t)}async function u(t){return(await n()).fromProtocolJSON(t)}async function s(t){return(await n()).validateProtocolJSON(t)}async function f(t){return(await n()).toEnvelopeJSON(t)}async function l(t){return(await n()).fromEnvelopeJSON(t)}async function w(t){return(await n()).isEnvelope(t)}async function p(t){return(await n()).semanticNodeToRuntimeAST(t)}export{l as fromEnvelopeJSON,e as fromInterchangeNode,u as fromProtocolJSON,w as isEnvelope,o as isExplicitSyntax,r as isLSEAvailable,a as parseExplicit,i as renderExplicit,p as semanticNodeToRuntimeAST,f as toEnvelopeJSON,c as toProtocolJSON,s as validateProtocolJSON};
2
+ //# sourceMappingURL=index-D6-8bcsy.js.map
@@ -2,8 +2,9 @@ export type ContentInsertPosition = 'beforebegin' | 'afterbegin' | 'beforeend' |
2
2
  export type SemanticPosition = 'before' | 'prepend' | 'append' | 'after' | 'into';
3
3
  export declare function toInsertPosition(position: SemanticPosition): ContentInsertPosition;
4
4
  export declare function looksLikeHTML(str: string): boolean;
5
- export declare function insertContent(target: HTMLElement, content: string | HTMLElement, position: ContentInsertPosition): void;
6
- export declare function insertContentSemantic(target: HTMLElement, content: string | HTMLElement, position: SemanticPosition): void;
5
+ export declare function insertContent(target: HTMLElement, content: string | Node, position: ContentInsertPosition): void;
6
+ export declare function insertContentSemantic(target: HTMLElement, content: string | Node, position: SemanticPosition): void;
7
+ export declare function insertElementsInOrder(target: HTMLElement, elements: readonly HTMLElement[], position: ContentInsertPosition): void;
7
8
  export declare function removeElement(element: HTMLElement): boolean;
8
9
  export declare function removeElements(elements: HTMLElement[]): number;
9
10
  export declare function swapElements(element1: HTMLElement, element2: HTMLElement): boolean;
@@ -19,7 +19,7 @@ export { validateTargetArray, isValidTargetArray, validateStringArray, isValidSt
19
19
  export type { ValidationResult as InputValidationResult } from './input-validator';
20
20
  export { detectSmartElementType, resolveSmartElementTargets, toggleDialog, toggleDetails, toggleSelect, toggleSmartElement, isSmartElement, isDialogElement, isDetailsElement, isSelectElement, isSummaryElement, } from './smart-element';
21
21
  export type { SmartElementType, DialogMode } from './smart-element';
22
- export { toInsertPosition, looksLikeHTML, insertContent, insertContentSemantic, removeElement, removeElements, swapElements, cloneElement, createElementFromHTML, setInnerHTML, setTextContent, clearElement, } from './dom-mutation';
22
+ export { toInsertPosition, looksLikeHTML, insertContent, insertContentSemantic, insertElementsInOrder, removeElement, removeElements, swapElements, cloneElement, createElementFromHTML, setInnerHTML, setTextContent, clearElement, } from './dom-mutation';
23
23
  export type { ContentInsertPosition, SemanticPosition } from './dom-mutation';
24
24
  export { batchApply, batchApplyItems, batchAddClasses, batchRemoveClasses, batchToggleClasses, batchSetAttribute, batchRemoveAttribute, batchToggleAttribute, toggleAttribute, batchSetStyles, batchRemoveStyles, } from './batch-dom-operations';
25
25
  export { waitForEvent, waitForTime, waitForTransitionEnd, waitForAnimationComplete, waitForFirst, createGuardedFinisher, createOnceGuard, createCleanupManager, } from './event-waiting';
@@ -86,6 +86,12 @@ function isHTMLElement$2(value) {
86
86
  typeof value.tagName === 'string' &&
87
87
  'classList' in value);
88
88
  }
89
+ function isInsertableNode(value) {
90
+ if (value === null || typeof value !== 'object')
91
+ return false;
92
+ const nodeType = value.nodeType;
93
+ return nodeType === 1 || nodeType === 3 || nodeType === 11;
94
+ }
89
95
  function isNodeList(value) {
90
96
  return (value !== null &&
91
97
  typeof value === 'object' &&
@@ -1067,7 +1073,7 @@ function insertContent(target, content, position) {
1067
1073
  insertReplace(target, content);
1068
1074
  return;
1069
1075
  }
1070
- if (isHTMLElement$2(content)) {
1076
+ if (isInsertableNode(content)) {
1071
1077
  insertElement(target, content, position);
1072
1078
  }
1073
1079
  else {
@@ -1078,7 +1084,7 @@ function insertContentSemantic(target, content, position) {
1078
1084
  insertContent(target, content, toInsertPosition(position));
1079
1085
  }
1080
1086
  function insertReplace(target, content) {
1081
- if (isHTMLElement$2(content)) {
1087
+ if (isInsertableNode(content)) {
1082
1088
  target.innerHTML = '';
1083
1089
  target.appendChild(content);
1084
1090
  }
@@ -1125,6 +1131,53 @@ function insertText(target, content, position) {
1125
1131
  target.insertAdjacentText(domPosition, content);
1126
1132
  }
1127
1133
  }
1134
+ function moveOrInsert(parent, element, ref) {
1135
+ const p = parent;
1136
+ if (typeof p.moveBefore === 'function' && element.isConnected && parent.isConnected) {
1137
+ try {
1138
+ p.moveBefore(element, ref);
1139
+ return;
1140
+ }
1141
+ catch {
1142
+ }
1143
+ }
1144
+ parent.insertBefore(element, ref);
1145
+ }
1146
+ function insertElementsInOrder(target, elements, position) {
1147
+ switch (position) {
1148
+ case 'beforeend':
1149
+ for (const el of elements)
1150
+ moveOrInsert(target, el, null);
1151
+ break;
1152
+ case 'afterbegin':
1153
+ for (let i = elements.length - 1; i >= 0; i--) {
1154
+ moveOrInsert(target, elements[i], target.firstChild);
1155
+ }
1156
+ break;
1157
+ case 'beforebegin': {
1158
+ const parent = target.parentElement;
1159
+ if (!parent)
1160
+ return;
1161
+ for (const el of elements)
1162
+ moveOrInsert(parent, el, target);
1163
+ break;
1164
+ }
1165
+ case 'afterend': {
1166
+ const parent = target.parentElement;
1167
+ if (!parent)
1168
+ return;
1169
+ for (let i = elements.length - 1; i >= 0; i--) {
1170
+ moveOrInsert(parent, elements[i], target.nextSibling);
1171
+ }
1172
+ break;
1173
+ }
1174
+ case 'replace':
1175
+ target.innerHTML = '';
1176
+ for (const el of elements)
1177
+ moveOrInsert(target, el, null);
1178
+ break;
1179
+ }
1180
+ }
1128
1181
  function removeElement(element) {
1129
1182
  if (element.parentNode) {
1130
1183
  element.remove();
@@ -2747,7 +2800,12 @@ let PutCommand = (() => {
2747
2800
  else {
2748
2801
  for (const t of targets) {
2749
2802
  const content = this.parseValue(value);
2750
- insertContentSemantic(t, content, position);
2803
+ if (Array.isArray(content)) {
2804
+ insertElementsInOrder(t, content, toInsertPosition(position));
2805
+ }
2806
+ else {
2807
+ insertContentSemantic(t, content, position);
2808
+ }
2751
2809
  }
2752
2810
  }
2753
2811
  return targets;
@@ -2779,6 +2837,11 @@ let PutCommand = (() => {
2779
2837
  parseValue(v) {
2780
2838
  if (isHTMLElement$2(v))
2781
2839
  return v;
2840
+ if (Array.isArray(v) && v.length > 0 && v.every(isHTMLElement$2)) {
2841
+ return v;
2842
+ }
2843
+ if (isInsertableNode(v))
2844
+ return v;
2782
2845
  return v == null ? '' : String(v);
2783
2846
  }
2784
2847
  looksLikeCss(s) {
@@ -12145,6 +12208,12 @@ function evaluateLiteral(node) {
12145
12208
  }
12146
12209
  async function evaluateIdentifier(node, context) {
12147
12210
  const name = node.name;
12211
+ if (name.startsWith('$')) {
12212
+ notifyGlobalRead(name.slice(1), context);
12213
+ }
12214
+ else if (node.scope === 'global') {
12215
+ notifyGlobalRead(name, context);
12216
+ }
12148
12217
  if (name === 'me' || name === 'my' || name === 'I') {
12149
12218
  return getExpr(context, 'me').evaluate(context);
12150
12219
  }
@@ -12164,7 +12233,6 @@ async function evaluateIdentifier(node, context) {
12164
12233
  return getExpr(context, 'document').evaluate(context);
12165
12234
  }
12166
12235
  if (node.scope === 'global' && context.globals?.has(name)) {
12167
- notifyGlobalRead(name, context);
12168
12236
  return context.globals.get(name);
12169
12237
  }
12170
12238
  if (node.scope === 'element') {
@@ -12175,12 +12243,9 @@ async function evaluateIdentifier(node, context) {
12175
12243
  return context.locals.get(name);
12176
12244
  }
12177
12245
  if (context.globals && context.globals.has(name)) {
12178
- if (name.startsWith('$'))
12179
- notifyGlobalRead(name.slice(1), context);
12180
12246
  return context.globals.get(name);
12181
12247
  }
12182
12248
  if (name.startsWith('$') && context.globals && context.globals.has(name.slice(1))) {
12183
- notifyGlobalRead(name.slice(1), context);
12184
12249
  return context.globals.get(name.slice(1));
12185
12250
  }
12186
12251
  if (context[name] !== undefined) {
@@ -14118,8 +14183,9 @@ const morphAdapter = {
14118
14183
  function getStartViewTransition() {
14119
14184
  if (typeof document === 'undefined')
14120
14185
  return undefined;
14121
- return document
14186
+ const fn = document
14122
14187
  .startViewTransition;
14188
+ return typeof fn === 'function' ? fn.bind(document) : undefined;
14123
14189
  }
14124
14190
  function isViewTransitionsSupported() {
14125
14191
  return typeof getStartViewTransition() === 'function';
@@ -84,6 +84,12 @@ function isHTMLElement$2(value) {
84
84
  typeof value.tagName === 'string' &&
85
85
  'classList' in value);
86
86
  }
87
+ function isInsertableNode(value) {
88
+ if (value === null || typeof value !== 'object')
89
+ return false;
90
+ const nodeType = value.nodeType;
91
+ return nodeType === 1 || nodeType === 3 || nodeType === 11;
92
+ }
87
93
  function isNodeList(value) {
88
94
  return (value !== null &&
89
95
  typeof value === 'object' &&
@@ -1065,7 +1071,7 @@ function insertContent(target, content, position) {
1065
1071
  insertReplace(target, content);
1066
1072
  return;
1067
1073
  }
1068
- if (isHTMLElement$2(content)) {
1074
+ if (isInsertableNode(content)) {
1069
1075
  insertElement(target, content, position);
1070
1076
  }
1071
1077
  else {
@@ -1076,7 +1082,7 @@ function insertContentSemantic(target, content, position) {
1076
1082
  insertContent(target, content, toInsertPosition(position));
1077
1083
  }
1078
1084
  function insertReplace(target, content) {
1079
- if (isHTMLElement$2(content)) {
1085
+ if (isInsertableNode(content)) {
1080
1086
  target.innerHTML = '';
1081
1087
  target.appendChild(content);
1082
1088
  }
@@ -1123,6 +1129,53 @@ function insertText(target, content, position) {
1123
1129
  target.insertAdjacentText(domPosition, content);
1124
1130
  }
1125
1131
  }
1132
+ function moveOrInsert(parent, element, ref) {
1133
+ const p = parent;
1134
+ if (typeof p.moveBefore === 'function' && element.isConnected && parent.isConnected) {
1135
+ try {
1136
+ p.moveBefore(element, ref);
1137
+ return;
1138
+ }
1139
+ catch {
1140
+ }
1141
+ }
1142
+ parent.insertBefore(element, ref);
1143
+ }
1144
+ function insertElementsInOrder(target, elements, position) {
1145
+ switch (position) {
1146
+ case 'beforeend':
1147
+ for (const el of elements)
1148
+ moveOrInsert(target, el, null);
1149
+ break;
1150
+ case 'afterbegin':
1151
+ for (let i = elements.length - 1; i >= 0; i--) {
1152
+ moveOrInsert(target, elements[i], target.firstChild);
1153
+ }
1154
+ break;
1155
+ case 'beforebegin': {
1156
+ const parent = target.parentElement;
1157
+ if (!parent)
1158
+ return;
1159
+ for (const el of elements)
1160
+ moveOrInsert(parent, el, target);
1161
+ break;
1162
+ }
1163
+ case 'afterend': {
1164
+ const parent = target.parentElement;
1165
+ if (!parent)
1166
+ return;
1167
+ for (let i = elements.length - 1; i >= 0; i--) {
1168
+ moveOrInsert(parent, elements[i], target.nextSibling);
1169
+ }
1170
+ break;
1171
+ }
1172
+ case 'replace':
1173
+ target.innerHTML = '';
1174
+ for (const el of elements)
1175
+ moveOrInsert(target, el, null);
1176
+ break;
1177
+ }
1178
+ }
1126
1179
  function removeElement(element) {
1127
1180
  if (element.parentNode) {
1128
1181
  element.remove();
@@ -2745,7 +2798,12 @@ let PutCommand = (() => {
2745
2798
  else {
2746
2799
  for (const t of targets) {
2747
2800
  const content = this.parseValue(value);
2748
- insertContentSemantic(t, content, position);
2801
+ if (Array.isArray(content)) {
2802
+ insertElementsInOrder(t, content, toInsertPosition(position));
2803
+ }
2804
+ else {
2805
+ insertContentSemantic(t, content, position);
2806
+ }
2749
2807
  }
2750
2808
  }
2751
2809
  return targets;
@@ -2777,6 +2835,11 @@ let PutCommand = (() => {
2777
2835
  parseValue(v) {
2778
2836
  if (isHTMLElement$2(v))
2779
2837
  return v;
2838
+ if (Array.isArray(v) && v.length > 0 && v.every(isHTMLElement$2)) {
2839
+ return v;
2840
+ }
2841
+ if (isInsertableNode(v))
2842
+ return v;
2780
2843
  return v == null ? '' : String(v);
2781
2844
  }
2782
2845
  looksLikeCss(s) {
@@ -12143,6 +12206,12 @@ function evaluateLiteral(node) {
12143
12206
  }
12144
12207
  async function evaluateIdentifier(node, context) {
12145
12208
  const name = node.name;
12209
+ if (name.startsWith('$')) {
12210
+ notifyGlobalRead(name.slice(1), context);
12211
+ }
12212
+ else if (node.scope === 'global') {
12213
+ notifyGlobalRead(name, context);
12214
+ }
12146
12215
  if (name === 'me' || name === 'my' || name === 'I') {
12147
12216
  return getExpr(context, 'me').evaluate(context);
12148
12217
  }
@@ -12162,7 +12231,6 @@ async function evaluateIdentifier(node, context) {
12162
12231
  return getExpr(context, 'document').evaluate(context);
12163
12232
  }
12164
12233
  if (node.scope === 'global' && context.globals?.has(name)) {
12165
- notifyGlobalRead(name, context);
12166
12234
  return context.globals.get(name);
12167
12235
  }
12168
12236
  if (node.scope === 'element') {
@@ -12173,12 +12241,9 @@ async function evaluateIdentifier(node, context) {
12173
12241
  return context.locals.get(name);
12174
12242
  }
12175
12243
  if (context.globals && context.globals.has(name)) {
12176
- if (name.startsWith('$'))
12177
- notifyGlobalRead(name.slice(1), context);
12178
12244
  return context.globals.get(name);
12179
12245
  }
12180
12246
  if (name.startsWith('$') && context.globals && context.globals.has(name.slice(1))) {
12181
- notifyGlobalRead(name.slice(1), context);
12182
12247
  return context.globals.get(name.slice(1));
12183
12248
  }
12184
12249
  if (context[name] !== undefined) {
@@ -14116,8 +14181,9 @@ const morphAdapter = {
14116
14181
  function getStartViewTransition() {
14117
14182
  if (typeof document === 'undefined')
14118
14183
  return undefined;
14119
- return document
14184
+ const fn = document
14120
14185
  .startViewTransition;
14186
+ return typeof fn === 'function' ? fn.bind(document) : undefined;
14121
14187
  }
14122
14188
  function isViewTransitionsSupported() {
14123
14189
  return typeof getStartViewTransition() === 'function';