@hyperfixi/core 2.9.4 → 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 (102) hide show
  1. package/dist/ast-utils/index.js +400 -89
  2. package/dist/ast-utils/index.mjs +400 -89
  3. package/dist/behaviors/index.js +2 -1
  4. package/dist/behaviors/index.mjs +2 -1
  5. package/dist/chunks/{bridge-DhmZ3Khh.js → bridge-De7lnU_9.js} +2 -2
  6. package/dist/chunks/browser-modular-DpHHlmJ0.js +2 -0
  7. package/dist/chunks/{index-DKrx4rv2.js → index-D6-8bcsy.js} +2 -2
  8. package/dist/commands/advanced/async.d.ts +0 -8
  9. package/dist/commands/advanced/js.d.ts +0 -8
  10. package/dist/commands/animation/measure.d.ts +0 -8
  11. package/dist/commands/animation/settle.d.ts +0 -8
  12. package/dist/commands/animation/start-view-transition.d.ts +0 -8
  13. package/dist/commands/animation/take.d.ts +0 -8
  14. package/dist/commands/animation/transition.d.ts +0 -8
  15. package/dist/commands/async/fetch.d.ts +0 -8
  16. package/dist/commands/async/wait.d.ts +0 -8
  17. package/dist/commands/behaviors/install.d.ts +0 -8
  18. package/dist/commands/content/append.d.ts +0 -8
  19. package/dist/commands/content/prepend.d.ts +0 -8
  20. package/dist/commands/control-flow/break.d.ts +0 -8
  21. package/dist/commands/control-flow/continue.d.ts +0 -8
  22. package/dist/commands/control-flow/exit.d.ts +0 -8
  23. package/dist/commands/control-flow/halt.d.ts +0 -8
  24. package/dist/commands/control-flow/if.d.ts +0 -8
  25. package/dist/commands/control-flow/repeat.d.ts +0 -8
  26. package/dist/commands/control-flow/return.d.ts +0 -8
  27. package/dist/commands/control-flow/throw.d.ts +0 -8
  28. package/dist/commands/data/clear.d.ts +0 -8
  29. package/dist/commands/data/default.d.ts +0 -8
  30. package/dist/commands/data/get.d.ts +0 -8
  31. package/dist/commands/data/increment.d.ts +0 -8
  32. package/dist/commands/data/set.d.ts +0 -8
  33. package/dist/commands/decorators/index.d.ts +2 -8
  34. package/dist/commands/dom/add.d.ts +0 -8
  35. package/dist/commands/dom/close.d.ts +0 -8
  36. package/dist/commands/dom/empty.d.ts +0 -8
  37. package/dist/commands/dom/hide.d.ts +0 -8
  38. package/dist/commands/dom/make.d.ts +0 -8
  39. package/dist/commands/dom/open.d.ts +0 -8
  40. package/dist/commands/dom/process-partials.d.ts +0 -8
  41. package/dist/commands/dom/put.d.ts +0 -8
  42. package/dist/commands/dom/remove.d.ts +0 -8
  43. package/dist/commands/dom/reset.d.ts +0 -8
  44. package/dist/commands/dom/select.d.ts +0 -8
  45. package/dist/commands/dom/show.d.ts +0 -8
  46. package/dist/commands/dom/swap.d.ts +2 -18
  47. package/dist/commands/dom/toggle.d.ts +0 -8
  48. package/dist/commands/events/trigger.d.ts +0 -8
  49. package/dist/commands/execution/blur.d.ts +0 -8
  50. package/dist/commands/execution/call.d.ts +0 -8
  51. package/dist/commands/execution/focus.d.ts +0 -8
  52. package/dist/commands/execution/pseudo-command.d.ts +0 -8
  53. package/dist/commands/helpers/dom-mutation.d.ts +3 -2
  54. package/dist/commands/helpers/index.d.ts +1 -1
  55. package/dist/commands/index.js +156 -31
  56. package/dist/commands/index.mjs +156 -31
  57. package/dist/commands/navigation/go.d.ts +0 -8
  58. package/dist/commands/navigation/push-url.d.ts +0 -8
  59. package/dist/commands/navigation/scroll-to.d.ts +0 -8
  60. package/dist/commands/templates/render.d.ts +0 -8
  61. package/dist/commands/utility/beep.d.ts +0 -8
  62. package/dist/commands/utility/breakpoint.d.ts +0 -8
  63. package/dist/commands/utility/copy.d.ts +0 -8
  64. package/dist/commands/utility/log.d.ts +0 -8
  65. package/dist/commands/utility/pick.d.ts +0 -8
  66. package/dist/commands/utility/tell.d.ts +0 -8
  67. package/dist/hyperfixi-browser-classic-i18n.js +1 -1
  68. package/dist/hyperfixi-browser-minimal.js +1 -1
  69. package/dist/hyperfixi-browser-standard.js +1 -1
  70. package/dist/hyperfixi-browser.js +1 -1
  71. package/dist/hyperfixi-classic-i18n.js +1 -1
  72. package/dist/hyperfixi-hx-v4.js +1 -1
  73. package/dist/hyperfixi-minimal.js +1 -1
  74. package/dist/hyperfixi-multilingual.js +1 -1
  75. package/dist/hyperfixi-standard.js +1 -1
  76. package/dist/hyperfixi.js +1 -1
  77. package/dist/hyperfixi.mjs +1 -1
  78. package/dist/index.js +660 -171
  79. package/dist/index.min.js +1 -1
  80. package/dist/index.mjs +660 -171
  81. package/dist/lokascript-browser-classic-i18n.js +1 -1
  82. package/dist/lokascript-browser-minimal.js +1 -1
  83. package/dist/lokascript-browser-standard.js +1 -1
  84. package/dist/lokascript-browser.js +1 -1
  85. package/dist/lokascript-multilingual.js +1 -1
  86. package/dist/lsp-metadata.js +2 -2
  87. package/dist/lsp-metadata.mjs +2 -2
  88. package/dist/metadata.d.ts +1 -1
  89. package/dist/metadata.js +13 -11
  90. package/dist/metadata.mjs +13 -11
  91. package/dist/parser/command-parsers/dom-commands.d.ts +1 -0
  92. package/dist/parser/full-parser.js +47 -1
  93. package/dist/parser/full-parser.mjs +47 -1
  94. package/dist/reference/index.js +13 -7
  95. package/dist/reference/index.mjs +13 -7
  96. package/dist/registry/index.js +56 -10
  97. package/dist/registry/index.mjs +56 -10
  98. package/dist/runtime/command-adapter.d.ts +8 -8
  99. package/dist/utils/element-check.d.ts +1 -0
  100. package/dist/version.d.ts +2 -0
  101. package/package.json +5 -5
  102. package/dist/chunks/browser-modular-BllAMlht.js +0 -2
@@ -5510,6 +5510,40 @@ function parseTakeCommand(ctx, identifierNode) {
5510
5510
  .endingAt(ctx.getPosition())
5511
5511
  .build();
5512
5512
  }
5513
+ function consumeViewTransitionTail(ctx, args) {
5514
+ if (!ctx.check('using')) {
5515
+ return false;
5516
+ }
5517
+ ctx.advance();
5518
+ if (!ctx.match('view')) {
5519
+ throw new Error("expected 'view transition' after 'using'");
5520
+ }
5521
+ if (!ctx.match('transition')) {
5522
+ throw new Error("expected 'transition' after 'using view'");
5523
+ }
5524
+ args.push(ctx.createIdentifier('using'));
5525
+ args.push(ctx.createIdentifier('view'));
5526
+ args.push(ctx.createIdentifier('transition'));
5527
+ return true;
5528
+ }
5529
+ function parseProcessCommand(ctx, identifierNode) {
5530
+ if (!ctx.check('partials')) {
5531
+ return null;
5532
+ }
5533
+ const args = [];
5534
+ consumeKeywordToArgs(ctx, 'partials', args);
5535
+ if (consumeKeywordToArgs(ctx, KEYWORDS.IN, args)) {
5536
+ const contentArg = parseOneArgument(ctx, ['using']);
5537
+ if (contentArg) {
5538
+ args.push(contentArg);
5539
+ }
5540
+ }
5541
+ consumeViewTransitionTail(ctx, args);
5542
+ return CommandNodeBuilder.fromIdentifier(identifierNode)
5543
+ .withArgs(...args)
5544
+ .endingAt(ctx.getPosition())
5545
+ .build();
5546
+ }
5513
5547
  function parseAddCommand(ctx, commandToken) {
5514
5548
  const args = [];
5515
5549
  if (ctx.match('{')) {
@@ -5631,6 +5665,7 @@ function parseSwapCommand(ctx, identifierNode) {
5631
5665
  args.push(contentExpr);
5632
5666
  }
5633
5667
  }
5668
+ consumeViewTransitionTail(ctx, args);
5634
5669
  return CommandNodeBuilder.fromIdentifier(identifierNode)
5635
5670
  .withArgs(...args)
5636
5671
  .endingAt(ctx.getPosition())
@@ -6144,6 +6179,9 @@ function parseCompoundCommand(ctx, identifierNode) {
6144
6179
  case 'swap':
6145
6180
  case 'morph':
6146
6181
  return parseSwapCommand(ctx, identifierNode);
6182
+ case 'process':
6183
+ return (parseProcessCommand(ctx, identifierNode) ??
6184
+ parseRegularCommand(ctx, identifierNode));
6147
6185
  default:
6148
6186
  return parseRegularCommand(ctx, identifierNode);
6149
6187
  }
@@ -6475,6 +6513,9 @@ function parseTellCommand(ctx, identifierNode) {
6475
6513
  if (!target) {
6476
6514
  throw new Error('tell command requires a target expression');
6477
6515
  }
6516
+ if (ctx.check(KEYWORDS.TO)) {
6517
+ ctx.advance();
6518
+ }
6478
6519
  const commands = [];
6479
6520
  while (!ctx.isAtEnd()) {
6480
6521
  if (ctx.checkIsCommand()) {
@@ -6494,7 +6535,11 @@ function parseTellCommand(ctx, identifierNode) {
6494
6535
  if (ctx.match(KEYWORDS.AND) || ctx.match(KEYWORDS.THEN)) {
6495
6536
  continue;
6496
6537
  }
6497
- if (ctx.check(KEYWORDS.ELSE) || ctx.check(KEYWORDS.END)) {
6538
+ if (ctx.check(KEYWORDS.ELSE)) {
6539
+ break;
6540
+ }
6541
+ if (ctx.check(KEYWORDS.END)) {
6542
+ ctx.advance();
6498
6543
  break;
6499
6544
  }
6500
6545
  if (ctx.checkIsCommand()) {
@@ -8832,6 +8877,7 @@ class Parser {
8832
8877
  'js',
8833
8878
  'tell',
8834
8879
  'fetch',
8880
+ 'process',
8835
8881
  ];
8836
8882
  if (this.semanticAdapter && !skipSemanticParsing.includes(commandName.toLowerCase())) {
8837
8883
  const remainingInput = this.getRemainingInput();
@@ -9859,6 +9905,12 @@ function evaluateLiteral(node) {
9859
9905
  }
9860
9906
  async function evaluateIdentifier(node, context) {
9861
9907
  const name = node.name;
9908
+ if (name.startsWith('$')) {
9909
+ notifyGlobalRead(name.slice(1), context);
9910
+ }
9911
+ else if (node.scope === 'global') {
9912
+ notifyGlobalRead(name, context);
9913
+ }
9862
9914
  if (name === 'me' || name === 'my' || name === 'I') {
9863
9915
  return getExpr(context, 'me').evaluate(context);
9864
9916
  }
@@ -9878,7 +9930,6 @@ async function evaluateIdentifier(node, context) {
9878
9930
  return getExpr(context, 'document').evaluate(context);
9879
9931
  }
9880
9932
  if (node.scope === 'global' && context.globals?.has(name)) {
9881
- notifyGlobalRead(name, context);
9882
9933
  return context.globals.get(name);
9883
9934
  }
9884
9935
  if (node.scope === 'element') {
@@ -9889,12 +9940,9 @@ async function evaluateIdentifier(node, context) {
9889
9940
  return context.locals.get(name);
9890
9941
  }
9891
9942
  if (context.globals && context.globals.has(name)) {
9892
- if (name.startsWith('$'))
9893
- notifyGlobalRead(name.slice(1), context);
9894
9943
  return context.globals.get(name);
9895
9944
  }
9896
9945
  if (name.startsWith('$') && context.globals && context.globals.has(name.slice(1))) {
9897
- notifyGlobalRead(name.slice(1), context);
9898
9946
  return context.globals.get(name.slice(1));
9899
9947
  }
9900
9948
  if (context[name] !== undefined) {
@@ -10868,7 +10916,7 @@ class CommandAdapterV2 {
10868
10916
  return {
10869
10917
  description: this.impl.metadata?.description || '',
10870
10918
  examples: this.impl.metadata?.examples || [],
10871
- syntax: Array.isArray(syntax) ? syntax.join(' | ') : syntax || '',
10919
+ syntax: typeof syntax === 'string' ? syntax : syntax ? syntax.join(' | ') : '',
10872
10920
  };
10873
10921
  }
10874
10922
  async execute(context, ...args) {
@@ -10944,10 +10992,8 @@ class CommandAdapterV2 {
10944
10992
  }
10945
10993
  }
10946
10994
  validate(input) {
10947
- if (this.impl.validate) {
10948
- return this.impl.validate(input);
10949
- }
10950
- return { isValid: true, errors: [], suggestions: [] };
10995
+ const isValid = this.impl.validate ? this.impl.validate(input) : true;
10996
+ return { isValid, errors: [], suggestions: [] };
10951
10997
  }
10952
10998
  }
10953
10999
  class CommandRegistryV2 {
@@ -7,15 +7,15 @@ export interface RuntimeCommand {
7
7
  validate?(input: unknown): ValidationResult<unknown>;
8
8
  metadata?: {
9
9
  description: string;
10
- examples: string[];
10
+ examples: readonly string[];
11
11
  syntax: string;
12
12
  };
13
13
  }
14
14
  export interface CommandMetadata {
15
15
  description?: string;
16
- examples?: string[];
17
- syntax?: string | string[];
18
- aliases?: string[];
16
+ examples?: readonly string[];
17
+ syntax?: string | readonly string[];
18
+ aliases?: readonly string[];
19
19
  [extra: string]: unknown;
20
20
  }
21
21
  export interface CommandRawInput {
@@ -28,8 +28,8 @@ export interface CommandWithParseInput {
28
28
  parseInput?(raw: CommandRawInput, evaluator: {
29
29
  evaluate(node: ASTNode, context: ExecutionContext): Promise<unknown>;
30
30
  }, context: ExecutionContext): Promise<unknown>;
31
- execute(input: unknown, context: TypedExecutionContext): Promise<unknown>;
32
- validate?(input: unknown): ValidationResult<unknown>;
31
+ execute(input: unknown, context: TypedExecutionContext): unknown;
32
+ validate?(input: unknown): boolean;
33
33
  metadata?: CommandMetadata;
34
34
  }
35
35
  export declare class ContextBridge {
@@ -45,7 +45,7 @@ export declare class CommandAdapterV2 implements RuntimeCommand {
45
45
  get name(): string;
46
46
  get metadata(): {
47
47
  description: string;
48
- examples: string[];
48
+ examples: readonly string[];
49
49
  syntax: string;
50
50
  };
51
51
  execute(context: ExecutionContext, ...args: unknown[]): Promise<unknown>;
@@ -58,7 +58,7 @@ export declare class CommandRegistryV2 {
58
58
  constructor(_legacySharedEvaluator?: unknown, hookRegistry?: HookRegistry);
59
59
  setHookRegistry(registry: HookRegistry): void;
60
60
  getHookRegistry(): HookRegistry | undefined;
61
- register(impl: any): void;
61
+ register(impl: CommandWithParseInput): void;
62
62
  getAdapter(name: string): CommandAdapterV2 | undefined;
63
63
  has(name: string): boolean;
64
64
  getCommandNames(): string[];
@@ -1,6 +1,7 @@
1
1
  export declare function isHTMLElement(value: unknown): value is HTMLElement;
2
2
  export declare function isNode(value: unknown): value is Node;
3
3
  export declare function isElement(value: unknown): value is Element;
4
+ export declare function isInsertableNode(value: unknown): value is Node;
4
5
  export declare function isEventTarget(value: unknown): value is EventTarget;
5
6
  export declare function isNodeList(value: unknown): value is NodeList;
6
7
  export declare function isDocumentFragment(value: unknown): value is DocumentFragment;
@@ -0,0 +1,2 @@
1
+ export declare const VERSION = "2.10.0";
2
+ //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperfixi/core",
3
- "version": "2.9.4",
3
+ "version": "2.11.0",
4
4
  "description": "Multilingual, tree-shakeable hyperscript",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -284,14 +284,14 @@
284
284
  "access": "public"
285
285
  },
286
286
  "dependencies": {
287
- "@lokascript/intent": "^2.9.4",
288
- "@lokascript/semantic": "^2.9.4",
287
+ "@lokascript/intent": "^2.11.0",
288
+ "@lokascript/semantic": "^2.11.0",
289
289
  "morphlex": "^1.4.0",
290
290
  "tslib": "^2.8.1"
291
291
  },
292
292
  "peerDependencies": {
293
- "@hyperfixi/patterns-reference": "^2.9.4",
294
- "@lokascript/framework": "^2.9.4"
293
+ "@hyperfixi/patterns-reference": "^2.11.0",
294
+ "@lokascript/framework": "^2.11.0"
295
295
  },
296
296
  "peerDependenciesMeta": {
297
297
  "@hyperfixi/patterns-reference": {