@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
@@ -1,2 +1,2 @@
1
- let n=null;async function t(){if(!n)try{n=await import("./browser-modular-B7Bb-ABs.js").then(function(n){return n.n})}catch{throw Error("@lokascript/framework is required for LSE support. Install it: npm install @lokascript/framework")}return n}function r(){if(n)return!0;try{return require.resolve("@lokascript/framework"),!0}catch{return!1}}async function a(n,r){return(await t()).parseExplicit(n,r)}async function o(n){return(await t()).isExplicitSyntax(n)}async function i(n){return(await t()).renderExplicit(n)}async function e(n){return(await t()).fromInterchangeNode(n)}async function c(n){return(await t()).toProtocolJSON(n)}async function u(n){return(await t()).fromProtocolJSON(n)}async function s(n){return(await t()).validateProtocolJSON(n)}async function f(n){return(await t()).toEnvelopeJSON(n)}async function l(n){return(await t()).fromEnvelopeJSON(n)}async function w(n){return(await t()).isEnvelope(n)}async function p(n){return(await t()).semanticNodeToRuntimeAST(n)}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-lsDi6izr.js.map
1
+ let n=null;async function t(){if(!n)try{n=await import("./browser-modular-DIOxQqhV.js").then(function(n){return n.n})}catch{throw Error("@lokascript/framework is required for LSE support. Install it: npm install @lokascript/framework")}return n}function r(){if(n)return!0;try{return require.resolve("@lokascript/framework"),!0}catch{return!1}}async function a(n,r){return(await t()).parseExplicit(n,r)}async function o(n){return(await t()).isExplicitSyntax(n)}async function i(n){return(await t()).renderExplicit(n)}async function e(n){return(await t()).fromInterchangeNode(n)}async function c(n){return(await t()).toProtocolJSON(n)}async function u(n){return(await t()).fromProtocolJSON(n)}async function s(n){return(await t()).validateProtocolJSON(n)}async function f(n){return(await t()).toEnvelopeJSON(n)}async function l(n){return(await t()).fromEnvelopeJSON(n)}async function w(n){return(await t()).isEnvelope(n)}async function p(n){return(await t()).semanticNodeToRuntimeAST(n)}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-DcxoRUBe.js.map
@@ -2390,11 +2390,30 @@ let PutCommand = (() => {
2390
2390
  const obj = targetArg.object, prop = targetArg.property;
2391
2391
  if (obj?.type === 'selector')
2392
2392
  targetSelector = obj.value;
2393
- else if (obj?.type === 'identifier')
2394
- targetSelector = obj.name;
2393
+ else if (obj?.type === 'identifier') {
2394
+ const objName = obj.name;
2395
+ if (objName === 'my' || objName === 'me' || objName === 'I') {
2396
+ if (context.me && prop?.name) {
2397
+ return {
2398
+ value,
2399
+ targets: [context.me],
2400
+ position: 'replace',
2401
+ memberPath: prop.name,
2402
+ };
2403
+ }
2404
+ }
2405
+ else if (objName === 'its' || objName === 'it') {
2406
+ const ev = await evaluator.evaluate(targetArg, context);
2407
+ if (typeof ev === 'string')
2408
+ targetSelector = ev;
2409
+ }
2410
+ else {
2411
+ targetSelector = objName;
2412
+ }
2413
+ }
2395
2414
  if (targetSelector && prop?.name)
2396
2415
  memberPath = prop.name;
2397
- else {
2416
+ else if (!targetSelector && !memberPath) {
2398
2417
  const ev = await evaluator.evaluate(targetArg, context);
2399
2418
  if (typeof ev === 'string')
2400
2419
  targetSelector = ev;
@@ -5331,7 +5350,11 @@ let SetCommand = (() => {
5331
5350
  return { type: 'property', element: firstValue[0], property: 'textContent', value };
5332
5351
  }
5333
5352
  if (typeof firstValue !== 'string') {
5334
- throw new Error('set command target must be a string or object literal');
5353
+ const isMember = firstArg?.type === 'memberExpression' || firstArg?.type === 'propertyAccess';
5354
+ const hint = isMember
5355
+ ? ` (a property chain evaluated to ${firstValue === null ? 'null' : typeof firstValue} — check that all intermediate objects exist)`
5356
+ : '';
5357
+ throw new Error(`set command target must be a string or object literal${hint}`);
5335
5358
  }
5336
5359
  const value = await this.extractValue(raw, evaluator, context);
5337
5360
  return { type: 'variable', name: firstValue, value };
@@ -8711,12 +8734,19 @@ class InstallCommand {
8711
8734
  const behaviorRegistry = context.locals.get('_behaviors');
8712
8735
  if (behaviorRegistry && typeof behaviorRegistry === 'object') {
8713
8736
  const registry = behaviorRegistry;
8714
- return registry.has(behaviorName);
8737
+ if (registry.has(behaviorName))
8738
+ return true;
8739
+ if (registry.resolve && registry.resolve(behaviorName))
8740
+ return true;
8715
8741
  }
8716
8742
  if (typeof globalThis !== 'undefined') {
8717
8743
  const hyperscriptGlobal = globalThis._hyperscript;
8718
8744
  if (hyperscriptGlobal?.behaviors) {
8719
- return hyperscriptGlobal.behaviors.has(behaviorName);
8745
+ if (hyperscriptGlobal.behaviors.has(behaviorName))
8746
+ return true;
8747
+ if (hyperscriptGlobal.behaviors.resolve &&
8748
+ hyperscriptGlobal.behaviors.resolve(behaviorName))
8749
+ return true;
8720
8750
  }
8721
8751
  }
8722
8752
  return false;
@@ -2388,11 +2388,30 @@ let PutCommand = (() => {
2388
2388
  const obj = targetArg.object, prop = targetArg.property;
2389
2389
  if (obj?.type === 'selector')
2390
2390
  targetSelector = obj.value;
2391
- else if (obj?.type === 'identifier')
2392
- targetSelector = obj.name;
2391
+ else if (obj?.type === 'identifier') {
2392
+ const objName = obj.name;
2393
+ if (objName === 'my' || objName === 'me' || objName === 'I') {
2394
+ if (context.me && prop?.name) {
2395
+ return {
2396
+ value,
2397
+ targets: [context.me],
2398
+ position: 'replace',
2399
+ memberPath: prop.name,
2400
+ };
2401
+ }
2402
+ }
2403
+ else if (objName === 'its' || objName === 'it') {
2404
+ const ev = await evaluator.evaluate(targetArg, context);
2405
+ if (typeof ev === 'string')
2406
+ targetSelector = ev;
2407
+ }
2408
+ else {
2409
+ targetSelector = objName;
2410
+ }
2411
+ }
2393
2412
  if (targetSelector && prop?.name)
2394
2413
  memberPath = prop.name;
2395
- else {
2414
+ else if (!targetSelector && !memberPath) {
2396
2415
  const ev = await evaluator.evaluate(targetArg, context);
2397
2416
  if (typeof ev === 'string')
2398
2417
  targetSelector = ev;
@@ -5329,7 +5348,11 @@ let SetCommand = (() => {
5329
5348
  return { type: 'property', element: firstValue[0], property: 'textContent', value };
5330
5349
  }
5331
5350
  if (typeof firstValue !== 'string') {
5332
- throw new Error('set command target must be a string or object literal');
5351
+ const isMember = firstArg?.type === 'memberExpression' || firstArg?.type === 'propertyAccess';
5352
+ const hint = isMember
5353
+ ? ` (a property chain evaluated to ${firstValue === null ? 'null' : typeof firstValue} — check that all intermediate objects exist)`
5354
+ : '';
5355
+ throw new Error(`set command target must be a string or object literal${hint}`);
5333
5356
  }
5334
5357
  const value = await this.extractValue(raw, evaluator, context);
5335
5358
  return { type: 'variable', name: firstValue, value };
@@ -8709,12 +8732,19 @@ class InstallCommand {
8709
8732
  const behaviorRegistry = context.locals.get('_behaviors');
8710
8733
  if (behaviorRegistry && typeof behaviorRegistry === 'object') {
8711
8734
  const registry = behaviorRegistry;
8712
- return registry.has(behaviorName);
8735
+ if (registry.has(behaviorName))
8736
+ return true;
8737
+ if (registry.resolve && registry.resolve(behaviorName))
8738
+ return true;
8713
8739
  }
8714
8740
  if (typeof globalThis !== 'undefined') {
8715
8741
  const hyperscriptGlobal = globalThis._hyperscript;
8716
8742
  if (hyperscriptGlobal?.behaviors) {
8717
- return hyperscriptGlobal.behaviors.has(behaviorName);
8743
+ if (hyperscriptGlobal.behaviors.has(behaviorName))
8744
+ return true;
8745
+ if (hyperscriptGlobal.behaviors.resolve &&
8746
+ hyperscriptGlobal.behaviors.resolve(behaviorName))
8747
+ return true;
8718
8748
  }
8719
8749
  }
8720
8750
  return false;
@@ -36,6 +36,10 @@ export declare class BaseExpressionEvaluator {
36
36
  protected evaluateAttributeAccess(node: {
37
37
  attributeName: string;
38
38
  }, context: ExecutionContext): string | boolean | null;
39
+ protected evaluateAsExpression(node: {
40
+ expression: any;
41
+ targetType: string;
42
+ }, context: ExecutionContext): Promise<unknown>;
39
43
  getAvailableExpressions(): string[];
40
44
  protected evaluateDollarExpression(node: {
41
45
  expression: any;
@@ -1380,6 +1380,8 @@ class BaseExpressionEvaluator {
1380
1380
  return this.evaluateIdSelector(node, context);
1381
1381
  case 'attributeAccess':
1382
1382
  return this.evaluateAttributeAccess(node, context);
1383
+ case 'asExpression':
1384
+ return this.evaluateAsExpression(node, context);
1383
1385
  default:
1384
1386
  throw new Error(`Unsupported AST node type for evaluation: ${node.type}`);
1385
1387
  }
@@ -1665,6 +1667,14 @@ class BaseExpressionEvaluator {
1665
1667
  }
1666
1668
  return `@${node.attributeName}`;
1667
1669
  }
1670
+ async evaluateAsExpression(node, context) {
1671
+ const value = await this.evaluate(node.expression, context);
1672
+ const asExpr = this.expressionRegistry.get('as');
1673
+ if (asExpr) {
1674
+ return asExpr.evaluate(context, value, node.targetType);
1675
+ }
1676
+ throw new Error(`Conversion type 'as' not registered`);
1677
+ }
1668
1678
  getAvailableExpressions() {
1669
1679
  return Array.from(this.expressionRegistry.keys());
1670
1680
  }
@@ -1378,6 +1378,8 @@ class BaseExpressionEvaluator {
1378
1378
  return this.evaluateIdSelector(node, context);
1379
1379
  case 'attributeAccess':
1380
1380
  return this.evaluateAttributeAccess(node, context);
1381
+ case 'asExpression':
1382
+ return this.evaluateAsExpression(node, context);
1381
1383
  default:
1382
1384
  throw new Error(`Unsupported AST node type for evaluation: ${node.type}`);
1383
1385
  }
@@ -1663,6 +1665,14 @@ class BaseExpressionEvaluator {
1663
1665
  }
1664
1666
  return `@${node.attributeName}`;
1665
1667
  }
1668
+ async evaluateAsExpression(node, context) {
1669
+ const value = await this.evaluate(node.expression, context);
1670
+ const asExpr = this.expressionRegistry.get('as');
1671
+ if (asExpr) {
1672
+ return asExpr.evaluate(context, value, node.targetType);
1673
+ }
1674
+ throw new Error(`Conversion type 'as' not registered`);
1675
+ }
1666
1676
  getAvailableExpressions() {
1667
1677
  return Array.from(this.expressionRegistry.keys());
1668
1678
  }