@spyglassmc/mcfunction 0.2.4 → 0.2.5

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.
@@ -1,3 +1,5 @@
1
1
  import * as core from '@spyglassmc/core';
2
+ import type { CommandMacroNode } from '../node/index.js';
2
3
  export declare function register(meta: core.MetaRegistry): void;
4
+ export declare const macro: core.Colorizer<CommandMacroNode>;
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,10 @@
1
1
  import * as core from '@spyglassmc/core';
2
2
  export function register(meta) {
3
+ meta.registerColorizer('mcfunction:command_macro', macro);
3
4
  meta.registerColorizer('mcfunction:command_child/literal', core.colorizer.literal);
4
5
  meta.registerColorizer('mcfunction:command_child/trailing', core.colorizer.error);
5
6
  }
7
+ export const macro = (node, ctx) => {
8
+ return [core.ColorToken.create(node, 'string')];
9
+ };
6
10
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,5 @@
1
1
  import * as core from '@spyglassmc/core';
2
+ import { CommandMacroNode } from '../node/index.js';
2
3
  import { CommandNode } from '../node/index.js';
3
4
  import { categorizeTreeChildren, CommandTreeRegistry, redirect, resolveParentTreeNode, } from '../tree/index.js';
4
5
  /**
@@ -9,7 +10,7 @@ export function entry(commandTreeName, getMockNodes) {
9
10
  return (node, ctx) => {
10
11
  const tree = CommandTreeRegistry.instance.get(commandTreeName);
11
12
  const childNode = core.AstNode.findChild(node, ctx.offset, true);
12
- if (core.CommentNode.is(childNode)) {
13
+ if (core.CommentNode.is(childNode) || CommandMacroNode.is(childNode)) {
13
14
  return [];
14
15
  }
15
16
  else {
@@ -7,6 +7,12 @@ export declare namespace CommandNode {
7
7
  function is(node: core.AstNode): node is CommandNode;
8
8
  function mock(range: core.RangeLike): CommandNode;
9
9
  }
10
+ export interface CommandMacroNode extends core.AstNode {
11
+ type: 'mcfunction:command_macro';
12
+ }
13
+ export declare namespace CommandMacroNode {
14
+ function is<T extends core.DeepReadonly<core.AstNode> | undefined>(obj: T): obj is core.InheritReadonly<CommandMacroNode, T>;
15
+ }
10
16
  export interface CommandChildNode extends core.AstNode {
11
17
  type: 'mcfunction:command_child';
12
18
  /**
@@ -15,6 +15,14 @@ export var CommandNode;
15
15
  }
16
16
  CommandNode.mock = mock;
17
17
  })(CommandNode || (CommandNode = {}));
18
+ export var CommandMacroNode;
19
+ (function (CommandMacroNode) {
20
+ function is(obj) {
21
+ return obj?.type ===
22
+ 'mcfunction:command_macro';
23
+ }
24
+ CommandMacroNode.is = is;
25
+ })(CommandMacroNode || (CommandMacroNode = {}));
18
26
  export var CommandChildNode;
19
27
  (function (CommandChildNode) {
20
28
  function is(node) {
@@ -1,6 +1,6 @@
1
1
  import type * as core from '@spyglassmc/core';
2
- import type { CommandNode } from './command.js';
3
- export interface McfunctionNode extends core.SequenceNode<CommandNode | core.CommentNode> {
2
+ import type { CommandMacroNode, CommandNode } from './command.js';
3
+ export interface McfunctionNode extends core.SequenceNode<CommandNode | CommandMacroNode | core.CommentNode> {
4
4
  type: 'mcfunction:entry';
5
5
  }
6
6
  export declare namespace McfunctionNode {
@@ -16,6 +16,14 @@ export function entry(commandTreeName, argument) {
16
16
  if (src.peek() === '#') {
17
17
  result = comment(src, ctx);
18
18
  }
19
+ else if (src.peek() === '$') {
20
+ const start = src.cursor;
21
+ src.skipLine();
22
+ result = {
23
+ type: 'mcfunction:command_macro',
24
+ range: core.Range.create(start, src),
25
+ };
26
+ }
19
27
  else {
20
28
  result = command(CommandTreeRegistry.instance.get(commandTreeName), argument)(src, ctx);
21
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spyglassmc/mcfunction",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -25,7 +25,7 @@
25
25
  "url": "https://github.com/SpyglassMC/Spyglass/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@spyglassmc/core": "0.4.2",
29
- "@spyglassmc/locales": "0.3.2"
28
+ "@spyglassmc/core": "0.4.3",
29
+ "@spyglassmc/locales": "0.3.3"
30
30
  }
31
31
  }