@hyperfixi/core 2.7.2 → 2.9.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 (65) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/api/hyperscript-api.d.ts +1 -0
  3. package/dist/ast-utils/index.js +2227 -263
  4. package/dist/ast-utils/index.mjs +2227 -263
  5. package/dist/bundle-generator/index.d.ts +1 -1
  6. package/dist/bundle-generator/index.js +77 -68
  7. package/dist/bundle-generator/index.mjs +76 -69
  8. package/dist/bundle-generator/template-capabilities.d.ts +2 -0
  9. package/dist/chunks/bridge-D9JLmPkk.js +2 -0
  10. package/dist/chunks/browser-modular-CPiVQXM0.js +2 -0
  11. package/dist/chunks/{index-D2WUNSCR.js → index-6DUg7Qjm.js} +2 -2
  12. package/dist/commands/index.js +117 -5
  13. package/dist/commands/index.mjs +117 -5
  14. package/dist/compatibility/browser-modular.d.ts +2 -2
  15. package/dist/expressions/index.d.ts +1 -1
  16. package/dist/htmx/hcon.d.ts +9 -0
  17. package/dist/htmx/htmx-translator.d.ts +1 -0
  18. package/dist/hyperfixi-browser-classic-i18n.js +1 -1
  19. package/dist/hyperfixi-browser-minimal.js +1 -1
  20. package/dist/hyperfixi-browser-standard.js +1 -1
  21. package/dist/hyperfixi-browser.js +1 -1
  22. package/dist/hyperfixi-classic-i18n.js +1 -1
  23. package/dist/hyperfixi-hx-v4.js +1 -1
  24. package/dist/hyperfixi-hx.js +1 -1
  25. package/dist/hyperfixi-hybrid-complete.js +1 -1
  26. package/dist/hyperfixi-hybrid-hx.js +1 -1
  27. package/dist/hyperfixi-minimal.js +1 -1
  28. package/dist/hyperfixi-multilingual.js +1 -1
  29. package/dist/hyperfixi-standard.js +1 -1
  30. package/dist/hyperfixi.js +1 -1
  31. package/dist/hyperfixi.mjs +1 -1
  32. package/dist/index.js +5187 -727
  33. package/dist/index.min.js +1 -1
  34. package/dist/index.mjs +5187 -727
  35. package/dist/lokascript-browser-classic-i18n.js +1 -1
  36. package/dist/lokascript-browser-minimal.js +1 -1
  37. package/dist/lokascript-browser-standard.js +1 -1
  38. package/dist/lokascript-browser.js +1 -1
  39. package/dist/lokascript-hybrid-complete.js +1 -1
  40. package/dist/lokascript-hybrid-hx.js +1 -1
  41. package/dist/lokascript-multilingual.js +1 -1
  42. package/dist/lse/index.d.ts +7 -7
  43. package/dist/metadata.d.ts +1 -1
  44. package/dist/metadata.js +31 -14
  45. package/dist/metadata.mjs +31 -14
  46. package/dist/multilingual/index.js +8 -1
  47. package/dist/multilingual/index.mjs +8 -1
  48. package/dist/parser/command-parsers/animation-commands.d.ts +2 -2
  49. package/dist/parser/command-parsers/async-commands.d.ts +2 -2
  50. package/dist/parser/command-parsers/dom-commands.d.ts +5 -5
  51. package/dist/parser/command-parsers/navigation-commands.d.ts +4 -0
  52. package/dist/parser/command-parsers/utility-commands.d.ts +2 -1
  53. package/dist/parser/command-parsers/variable-commands.d.ts +2 -2
  54. package/dist/parser/full-parser.js +117 -5
  55. package/dist/parser/full-parser.mjs +117 -5
  56. package/dist/parser/semantic-integration.d.ts +1 -0
  57. package/dist/performance/integration.d.ts +1 -1
  58. package/dist/registry/index.js +117 -5
  59. package/dist/registry/index.mjs +117 -5
  60. package/package.json +14 -20
  61. package/dist/chunks/bridge-DuveK8T4.js +0 -2
  62. package/dist/chunks/browser-modular-DW4nC6lH.js +0 -2
  63. package/dist/compatibility/browser-bundle-animation-generated.d.ts +0 -16
  64. package/dist/compatibility/browser-bundle-forms-generated.d.ts +0 -16
  65. package/dist/compatibility/browser-bundle-minimal-generated.d.ts +0 -16
@@ -1,2 +1,2 @@
1
- let t=null;async function n(){if(!t)try{t=await import("./browser-modular-DW4nC6lH.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-D2WUNSCR.js.map
1
+ let t=null;async function n(){if(!t)try{t=await import("./browser-modular-CPiVQXM0.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-6DUg7Qjm.js.map
@@ -2902,6 +2902,7 @@ const COMPOUND_COMMANDS = new Set([
2902
2902
  'halt',
2903
2903
  'measure',
2904
2904
  'js',
2905
+ 'go',
2905
2906
  'tell',
2906
2907
  'pick',
2907
2908
  'start',
@@ -7298,9 +7299,6 @@ class SemanticIntegrationAdapter {
7298
7299
  case 'responseType':
7299
7300
  modifiers['as'] = exprNode;
7300
7301
  break;
7301
- case 'method':
7302
- modifiers['method'] = exprNode;
7303
- break;
7304
7302
  case 'style':
7305
7303
  modifiers['with'] = exprNode;
7306
7304
  break;
@@ -9446,6 +9444,117 @@ function parseIncrementDecrementCommand(ctx, commandToken) {
9446
9444
  .build();
9447
9445
  }
9448
9446
 
9447
+ const GO_KEYWORDS = new Set([
9448
+ 'to',
9449
+ 'the',
9450
+ 'url',
9451
+ 'of',
9452
+ 'in',
9453
+ 'new',
9454
+ 'window',
9455
+ 'top',
9456
+ 'middle',
9457
+ 'bottom',
9458
+ 'left',
9459
+ 'center',
9460
+ 'right',
9461
+ 'smoothly',
9462
+ 'instantly',
9463
+ 'back',
9464
+ 'forward',
9465
+ ]);
9466
+ const GO_URL_STOP = new Set([
9467
+ 'in',
9468
+ 'then',
9469
+ 'and',
9470
+ 'else',
9471
+ 'end',
9472
+ 'otherwise',
9473
+ 'when',
9474
+ 'where',
9475
+ 'catch',
9476
+ 'finally',
9477
+ ]);
9478
+ function isGoURLTerminator(ctx) {
9479
+ return ctx.isAtEnd() || GO_URL_STOP.has(ctx.peek().value);
9480
+ }
9481
+ function stringNode(value, tok) {
9482
+ return {
9483
+ type: 'string',
9484
+ value,
9485
+ start: tok.start,
9486
+ end: tok.end,
9487
+ line: tok.line,
9488
+ column: tok.column,
9489
+ };
9490
+ }
9491
+ function isNakedURLStart(ctx) {
9492
+ const tok = ctx.peek();
9493
+ if (tok.value === '/')
9494
+ return true;
9495
+ if (ctx.checkIdentifierLike()) {
9496
+ const next = ctx.peekAt(1);
9497
+ return !!next && next.value === ':' && next.start === tok.end;
9498
+ }
9499
+ return false;
9500
+ }
9501
+ function parseGoCommand(ctx, identifierNode) {
9502
+ const args = [];
9503
+ while (!isCommandBoundary(ctx, ['when', 'where', 'catch', 'finally'])) {
9504
+ const tok = ctx.peek();
9505
+ const canonical = ctx.resolveKeyword(tok.value).toLowerCase();
9506
+ if (GO_KEYWORDS.has(canonical)) {
9507
+ ctx.advance();
9508
+ args.push(stringNode(canonical, tok));
9509
+ continue;
9510
+ }
9511
+ if (isNakedURLStart(ctx)) {
9512
+ const url = parseBareURLPath(ctx, isGoURLTerminator);
9513
+ if (url) {
9514
+ args.push(url);
9515
+ continue;
9516
+ }
9517
+ ctx.advance();
9518
+ args.push(stringNode(tok.value, tok));
9519
+ continue;
9520
+ }
9521
+ if (tok.value === '+' || tok.value === '-') {
9522
+ ctx.advance();
9523
+ args.push(stringNode(tok.value, tok));
9524
+ continue;
9525
+ }
9526
+ if (tok.kind === 'number') {
9527
+ ctx.advance();
9528
+ const next = ctx.peek();
9529
+ if (!ctx.isAtEnd() && next.value === 'px' && next.start === tok.end) {
9530
+ const px = ctx.advance();
9531
+ args.push(stringNode(`${tok.value}px`, { ...tok, end: px.end }));
9532
+ }
9533
+ else {
9534
+ args.push({
9535
+ type: 'literal',
9536
+ value: Number(tok.value),
9537
+ raw: tok.value,
9538
+ start: tok.start,
9539
+ end: tok.end,
9540
+ line: tok.line,
9541
+ column: tok.column,
9542
+ });
9543
+ }
9544
+ continue;
9545
+ }
9546
+ const before = ctx.current;
9547
+ args.push(ctx.parsePrimary());
9548
+ if (ctx.current === before) {
9549
+ break;
9550
+ }
9551
+ }
9552
+ return CommandNodeBuilder.fromIdentifier(identifierNode)
9553
+ .withArgs(...args)
9554
+ .endingAt(ctx.getPosition())
9555
+ .build();
9556
+ }
9557
+
9449
9558
  function parseCompoundCommand(ctx, identifierNode) {
9450
9559
  const commandName = identifierNode.name.toLowerCase();
9451
9560
  switch (commandName) {
@@ -9466,6 +9575,8 @@ function parseCompoundCommand(ctx, identifierNode) {
9466
9575
  return parseMeasureCommand(ctx, identifierNode);
9467
9576
  case 'js':
9468
9577
  return parseJsCommand(ctx, identifierNode);
9578
+ case 'go':
9579
+ return parseGoCommand(ctx, identifierNode);
9469
9580
  case 'tell':
9470
9581
  return parseTellCommand(ctx, identifierNode);
9471
9582
  case 'pick':
@@ -9545,10 +9656,10 @@ function isFetchURLTerminator(ctx) {
9545
9656
  return (['as', 'with', '{', 'then', 'end', 'else', 'otherwise', ')'].includes(val) ||
9546
9657
  isCommandBoundary(ctx));
9547
9658
  }
9548
- function parseBareURLPath(ctx) {
9659
+ function parseBareURLPath(ctx, isTerminator = isFetchURLTerminator) {
9549
9660
  const startPos = ctx.savePosition();
9550
9661
  let path = '';
9551
- while (!ctx.isAtEnd() && !isFetchURLTerminator(ctx)) {
9662
+ while (!ctx.isAtEnd() && !isTerminator(ctx)) {
9552
9663
  path += ctx.advance().value;
9553
9664
  }
9554
9665
  if (!path || path === '/') {
@@ -12078,6 +12189,7 @@ class Parser {
12078
12189
  'closest',
12079
12190
  'js',
12080
12191
  'tell',
12192
+ 'fetch',
12081
12193
  ];
12082
12194
  if (this.semanticAdapter && !skipSemanticParsing.includes(commandName.toLowerCase())) {
12083
12195
  const remainingInput = this.getRemainingInput();
@@ -2900,6 +2900,7 @@ const COMPOUND_COMMANDS = new Set([
2900
2900
  'halt',
2901
2901
  'measure',
2902
2902
  'js',
2903
+ 'go',
2903
2904
  'tell',
2904
2905
  'pick',
2905
2906
  'start',
@@ -7296,9 +7297,6 @@ class SemanticIntegrationAdapter {
7296
7297
  case 'responseType':
7297
7298
  modifiers['as'] = exprNode;
7298
7299
  break;
7299
- case 'method':
7300
- modifiers['method'] = exprNode;
7301
- break;
7302
7300
  case 'style':
7303
7301
  modifiers['with'] = exprNode;
7304
7302
  break;
@@ -9444,6 +9442,117 @@ function parseIncrementDecrementCommand(ctx, commandToken) {
9444
9442
  .build();
9445
9443
  }
9446
9444
 
9445
+ const GO_KEYWORDS = new Set([
9446
+ 'to',
9447
+ 'the',
9448
+ 'url',
9449
+ 'of',
9450
+ 'in',
9451
+ 'new',
9452
+ 'window',
9453
+ 'top',
9454
+ 'middle',
9455
+ 'bottom',
9456
+ 'left',
9457
+ 'center',
9458
+ 'right',
9459
+ 'smoothly',
9460
+ 'instantly',
9461
+ 'back',
9462
+ 'forward',
9463
+ ]);
9464
+ const GO_URL_STOP = new Set([
9465
+ 'in',
9466
+ 'then',
9467
+ 'and',
9468
+ 'else',
9469
+ 'end',
9470
+ 'otherwise',
9471
+ 'when',
9472
+ 'where',
9473
+ 'catch',
9474
+ 'finally',
9475
+ ]);
9476
+ function isGoURLTerminator(ctx) {
9477
+ return ctx.isAtEnd() || GO_URL_STOP.has(ctx.peek().value);
9478
+ }
9479
+ function stringNode(value, tok) {
9480
+ return {
9481
+ type: 'string',
9482
+ value,
9483
+ start: tok.start,
9484
+ end: tok.end,
9485
+ line: tok.line,
9486
+ column: tok.column,
9487
+ };
9488
+ }
9489
+ function isNakedURLStart(ctx) {
9490
+ const tok = ctx.peek();
9491
+ if (tok.value === '/')
9492
+ return true;
9493
+ if (ctx.checkIdentifierLike()) {
9494
+ const next = ctx.peekAt(1);
9495
+ return !!next && next.value === ':' && next.start === tok.end;
9496
+ }
9497
+ return false;
9498
+ }
9499
+ function parseGoCommand(ctx, identifierNode) {
9500
+ const args = [];
9501
+ while (!isCommandBoundary(ctx, ['when', 'where', 'catch', 'finally'])) {
9502
+ const tok = ctx.peek();
9503
+ const canonical = ctx.resolveKeyword(tok.value).toLowerCase();
9504
+ if (GO_KEYWORDS.has(canonical)) {
9505
+ ctx.advance();
9506
+ args.push(stringNode(canonical, tok));
9507
+ continue;
9508
+ }
9509
+ if (isNakedURLStart(ctx)) {
9510
+ const url = parseBareURLPath(ctx, isGoURLTerminator);
9511
+ if (url) {
9512
+ args.push(url);
9513
+ continue;
9514
+ }
9515
+ ctx.advance();
9516
+ args.push(stringNode(tok.value, tok));
9517
+ continue;
9518
+ }
9519
+ if (tok.value === '+' || tok.value === '-') {
9520
+ ctx.advance();
9521
+ args.push(stringNode(tok.value, tok));
9522
+ continue;
9523
+ }
9524
+ if (tok.kind === 'number') {
9525
+ ctx.advance();
9526
+ const next = ctx.peek();
9527
+ if (!ctx.isAtEnd() && next.value === 'px' && next.start === tok.end) {
9528
+ const px = ctx.advance();
9529
+ args.push(stringNode(`${tok.value}px`, { ...tok, end: px.end }));
9530
+ }
9531
+ else {
9532
+ args.push({
9533
+ type: 'literal',
9534
+ value: Number(tok.value),
9535
+ raw: tok.value,
9536
+ start: tok.start,
9537
+ end: tok.end,
9538
+ line: tok.line,
9539
+ column: tok.column,
9540
+ });
9541
+ }
9542
+ continue;
9543
+ }
9544
+ const before = ctx.current;
9545
+ args.push(ctx.parsePrimary());
9546
+ if (ctx.current === before) {
9547
+ break;
9548
+ }
9549
+ }
9550
+ return CommandNodeBuilder.fromIdentifier(identifierNode)
9551
+ .withArgs(...args)
9552
+ .endingAt(ctx.getPosition())
9553
+ .build();
9554
+ }
9555
+
9447
9556
  function parseCompoundCommand(ctx, identifierNode) {
9448
9557
  const commandName = identifierNode.name.toLowerCase();
9449
9558
  switch (commandName) {
@@ -9464,6 +9573,8 @@ function parseCompoundCommand(ctx, identifierNode) {
9464
9573
  return parseMeasureCommand(ctx, identifierNode);
9465
9574
  case 'js':
9466
9575
  return parseJsCommand(ctx, identifierNode);
9576
+ case 'go':
9577
+ return parseGoCommand(ctx, identifierNode);
9467
9578
  case 'tell':
9468
9579
  return parseTellCommand(ctx, identifierNode);
9469
9580
  case 'pick':
@@ -9543,10 +9654,10 @@ function isFetchURLTerminator(ctx) {
9543
9654
  return (['as', 'with', '{', 'then', 'end', 'else', 'otherwise', ')'].includes(val) ||
9544
9655
  isCommandBoundary(ctx));
9545
9656
  }
9546
- function parseBareURLPath(ctx) {
9657
+ function parseBareURLPath(ctx, isTerminator = isFetchURLTerminator) {
9547
9658
  const startPos = ctx.savePosition();
9548
9659
  let path = '';
9549
- while (!ctx.isAtEnd() && !isFetchURLTerminator(ctx)) {
9660
+ while (!ctx.isAtEnd() && !isTerminator(ctx)) {
9550
9661
  path += ctx.advance().value;
9551
9662
  }
9552
9663
  if (!path || path === '/') {
@@ -12076,6 +12187,7 @@ class Parser {
12076
12187
  'closest',
12077
12188
  'js',
12078
12189
  'tell',
12190
+ 'fetch',
12079
12191
  ];
12080
12192
  if (this.semanticAdapter && !skipSemanticParsing.includes(commandName.toLowerCase())) {
12081
12193
  const remainingInput = this.getRemainingInput();
@@ -12,11 +12,11 @@ declare const hyperfixi: {
12
12
  evalHyperScriptAsync: typeof evalHyperScriptAsync;
13
13
  evalHyperScriptSmart: typeof evalHyperScriptSmart;
14
14
  evaluate: typeof evalHyperScript;
15
- compile: (code: string) => import("../api/hyperscript-api").CompileResult;
15
+ compile: (code: string) => import("..").CompileResult;
16
16
  execute: (ast: import("..").ASTNode, context?: import("..").ExecutionContext) => Promise<unknown>;
17
17
  run: (code: string, context?: any) => Promise<unknown>;
18
18
  createContext: (element?: HTMLElement | null, parent?: import("..").ExecutionContext) => import("..").ExecutionContext;
19
- createRuntime: (options?: import("../runtime/runtime").RuntimeOptions) => Runtime;
19
+ createRuntime: (options?: import("..").RuntimeOptions) => Runtime;
20
20
  Parser: typeof Parser;
21
21
  Runtime: typeof Runtime;
22
22
  tokenize: typeof tokenize;
@@ -5,7 +5,7 @@ export { conversionExpressions as conversion } from './bundles/common-expression
5
5
  export { positionalExpressions as positional } from './bundles/common-expressions';
6
6
  export { propertiesExpressions as properties } from './bundles/full-expressions';
7
7
  export { createCoreRegistry, createCommonRegistry, createFullRegistry } from './bundles';
8
- export declare function createFullExpressionRegistry(): import("../core/expression-registry").ExpressionRegistry;
8
+ export declare function createFullExpressionRegistry(): import(".").ExpressionRegistry;
9
9
  export { createExpressionRegistry } from '../core/expression-registry';
10
10
  export type { ExpressionRegistry } from '../core/expression-registry';
11
11
  export * from './bundles';
@@ -0,0 +1,9 @@
1
+ export type HconPrimitive = string | number | boolean | null;
2
+ export type HconValue = HconPrimitive | HconValue[] | {
3
+ [key: string]: HconValue;
4
+ };
5
+ export type HconObject = Record<string, HconValue>;
6
+ export declare function parse(input: string): HconObject;
7
+ export declare function split(input: string): string[];
8
+ export declare function merge(source: HconObject | string, target: HconObject): HconObject;
9
+ //# sourceMappingURL=hcon.d.ts.map
@@ -13,6 +13,7 @@ export interface HtmxConfig {
13
13
  onHandlers?: Record<string, string>;
14
14
  hxLive?: string;
15
15
  }
16
+ export declare function resetUnsupportedModifierWarnings(): void;
16
17
  export declare function resolveHxTarget(target: string): string;
17
18
  export declare function translateToHyperscript(config: HtmxConfig, element: Element): string;
18
19
  export declare function hasHtmxAttributes(element: Element): boolean;