@spyglassmc/nbt 0.1.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.
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isExpandableCompound = exports.getSpecialStringParser = exports.getEntityFromItem = exports.getBlocksFromItem = void 0;
4
+ const BlockItems = {
5
+ // Coral fans.
6
+ 'minecraft:brain_coral_fan': [
7
+ 'minecraft:brain_coral_fan',
8
+ 'minecraft:brain_coral_wall_fan',
9
+ ],
10
+ 'minecraft:bubble_coral_fan': [
11
+ 'minecraft:bubble_coral_fan',
12
+ 'minecraft:bubble_coral_wall_fan',
13
+ ],
14
+ 'minecraft:fire_coral_fan': [
15
+ 'minecraft:fire_coral_fan',
16
+ 'minecraft:fire_coral_wall_fan',
17
+ ],
18
+ 'minecraft:horn_coral_fan': [
19
+ 'minecraft:horn_coral_fan',
20
+ 'minecraft:horn_coral_wall_fan',
21
+ ],
22
+ 'minecraft:tube_coral_fan': [
23
+ 'minecraft:tube_coral_fan',
24
+ 'minecraft:tube_coral_wall_fan',
25
+ ],
26
+ // Heads and skulls.
27
+ 'minecraft:creeper_head': [
28
+ 'minecraft:creeper_head',
29
+ 'minecraft:creeper_wall_head',
30
+ ],
31
+ 'minecraft:dragon_head': [
32
+ 'minecraft:dragon_head',
33
+ 'minecraft:dragon_wall_head',
34
+ ],
35
+ 'minecraft:player_head': [
36
+ 'minecraft:player_head',
37
+ 'minecraft:player_wall_head',
38
+ ],
39
+ 'minecraft:skeleton_skull': [
40
+ 'minecraft:skeleton_skull',
41
+ 'minecraft:skeleton_wall_skull',
42
+ ],
43
+ 'minecraft:wither_skeleton_skull': [
44
+ 'minecraft:wither_skeleton_skull',
45
+ 'minecraft:wither_skeleton_wall_skull',
46
+ ],
47
+ // Dead coral fans.
48
+ 'minecraft:dead_brain_coral_fan': [
49
+ 'minecraft:dead_brain_coral_fan',
50
+ 'minecraft:dead_brain_coral_wall_fan',
51
+ ],
52
+ 'minecraft:dead_bubble_coral_fan': [
53
+ 'minecraft:dead_bubble_coral_fan',
54
+ 'minecraft:dead_bubble_coral_wall_fan',
55
+ ],
56
+ 'minecraft:dead_fire_coral_fan': [
57
+ 'minecraft:dead_fire_coral_fan',
58
+ 'minecraft:dead_fire_coral_wall_fan',
59
+ ],
60
+ 'minecraft:dead_horn_coral_fan': [
61
+ 'minecraft:dead_horn_coral_fan',
62
+ 'minecraft:dead_horn_coral_wall_fan',
63
+ ],
64
+ 'minecraft:dead_tube_coral_fan': [
65
+ 'minecraft:dead_tube_coral_fan',
66
+ 'minecraft:dead_tube_coral_wall_fan',
67
+ ],
68
+ // Torches.
69
+ 'minecraft:torch': [
70
+ 'minecraft:torch',
71
+ 'minecraft:wall_torch',
72
+ ],
73
+ 'minecraft:soul_torch': [
74
+ 'minecraft:soul_torch',
75
+ 'minecraft:soul_wall_torch',
76
+ ],
77
+ 'minecraft:redstone_torch': [
78
+ 'minecraft:redstone_torch',
79
+ 'minecraft:redstone_wall_torch',
80
+ ],
81
+ 'minecraft:beetroot_seeds': [
82
+ 'minecraft:beetroots',
83
+ ],
84
+ 'minecraft:carrot': [
85
+ 'minecraft:carrots',
86
+ ],
87
+ 'minecraft:cocoa_beans': [
88
+ 'minecraft:cocoa',
89
+ ],
90
+ 'minecraft:glow_berries': [
91
+ 'minecraft:cave_vines',
92
+ ],
93
+ 'minecraft:melon_seeds': [
94
+ 'minecraft:melon_stem',
95
+ ],
96
+ 'minecraft:potato': [
97
+ 'minecraft:potatoes',
98
+ ],
99
+ 'minecraft:pumpkin_seeds': [
100
+ 'minecraft:pumpkin_stem',
101
+ ],
102
+ 'minecraft:redstone': [
103
+ 'minecraft:redstone_wire',
104
+ ],
105
+ 'minecraft:string': [
106
+ 'minecraft:tripwire',
107
+ ],
108
+ 'minecraft:sweat_berries': [
109
+ 'minecraft:sweat_berry_bush',
110
+ ],
111
+ 'minecraft:wheat_seeds': [
112
+ 'minecraft:wheat',
113
+ ],
114
+ };
115
+ function getBlocksFromItem(item) {
116
+ return BlockItems[item];
117
+ }
118
+ exports.getBlocksFromItem = getBlocksFromItem;
119
+ function getEntityFromItem(item) {
120
+ if (item === 'minecraft:armor_stand') {
121
+ return item;
122
+ }
123
+ const result = item.match(/^minecraft:([a-z0-9_]+)_spawn_egg$/);
124
+ if (result) {
125
+ return `minecraft:${result[1]}`;
126
+ }
127
+ return undefined;
128
+ }
129
+ exports.getEntityFromItem = getEntityFromItem;
130
+ const SpecialStrings = {
131
+ '::minecraft::block::banner::Banner.CustomName': 'mcfunction:component',
132
+ '::minecraft::block::brewingstand::BrewingStand.CustomName': 'mcfunction:component',
133
+ '::minecraft::block::commandblock::CommandBlock.Command': 'mcfunction:command',
134
+ '::minecraft::block::commandblock::CommandBlock.CustomName': 'mcfunction:component',
135
+ '::minecraft::block::container::ContainerBase.CustomName': 'mcfunction:component',
136
+ '::minecraft::block::enchantingtable::EnchantingTable.CustomName': 'mcfunction:component',
137
+ '::minecraft::block::furnace::Furnace.CustomName': 'mcfunction:component',
138
+ '::minecraft::block::hopper::Hopper.CustomName': 'mcfunction:component',
139
+ '::minecraft::block::sign::Sign.Text1': 'mcfunction:component',
140
+ '::minecraft::block::sign::Sign.Text2': 'mcfunction:component',
141
+ '::minecraft::block::sign::Sign.Text3': 'mcfunction:component',
142
+ '::minecraft::block::sign::Sign.Text4': 'mcfunction:component',
143
+ // TODO
144
+ // '::minecraft::entity::effectcloud::EffectCloud.Particle': 'mcfunction:particle',
145
+ '::minecraft::entity::minecart::CommandMinecart.Command': 'mcfunction:command',
146
+ '::minecraft::entity::mob::LivingEntity.Team': 'mcfunction:team',
147
+ '::minecraft::entity::EntityBase.Tags[]': 'mcfunction:tag',
148
+ '::minecraft::item::blockitem::BlockItem.CanPlaceOn[]': 'mcfunction:block_predicate',
149
+ '::minecraft::item::book::WrittenBook.pages[]': 'mcfunction:component',
150
+ '::minecraft::item::ItemBase.CanDestroy[]': 'mcfunction:block_predicate',
151
+ };
152
+ function getSpecialStringParser(nbtdocPath) {
153
+ return SpecialStrings[nbtdocPath];
154
+ }
155
+ exports.getSpecialStringParser = getSpecialStringParser;
156
+ const ExpandableCompounds = [
157
+ '::minecraft::item::ItemBase',
158
+ '::minecraft::entity::marker::Any',
159
+ ];
160
+ /**
161
+ * @param nbtdocPath Path of the nbtdoc compound definition.
162
+ */
163
+ function isExpandableCompound(nbtdocPath) {
164
+ return ExpandableCompounds.includes(nbtdocPath);
165
+ }
166
+ exports.isExpandableCompound = isExpandableCompound;
167
+ //# sourceMappingURL=nbtdocUtil.js.map
@@ -0,0 +1,3 @@
1
+ import type { MetaRegistry } from '@spyglassmc/core';
2
+ export declare function register(meta: MetaRegistry): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.register = void 0;
23
+ const core = __importStar(require("@spyglassmc/core"));
24
+ function register(meta) {
25
+ meta.registerColorizer('nbt:byte', core.colorizer.number);
26
+ meta.registerColorizer('nbt:short', core.colorizer.number);
27
+ meta.registerColorizer('nbt:int', core.colorizer.number);
28
+ meta.registerColorizer('nbt:long', core.colorizer.number);
29
+ meta.registerColorizer('nbt:float', core.colorizer.number);
30
+ meta.registerColorizer('nbt:double', core.colorizer.number);
31
+ }
32
+ exports.register = register;
33
+ //# sourceMappingURL=index.js.map
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type * as core from '@spyglassmc/core';
2
+ export * as checker from './checker';
3
+ export * as colorizer from './colorizer';
4
+ export * from './node';
5
+ export * as parser from './parser';
6
+ export declare const initialize: core.ProjectInitializer;
7
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.initialize = exports.parser = exports.colorizer = exports.checker = void 0;
26
+ const colorizer = __importStar(require("./colorizer"));
27
+ const parser = __importStar(require("./parser"));
28
+ exports.checker = __importStar(require("./checker"));
29
+ exports.colorizer = __importStar(require("./colorizer"));
30
+ __exportStar(require("./node"), exports);
31
+ exports.parser = __importStar(require("./parser"));
32
+ /* istanbul ignore next */
33
+ const initialize = ({ meta }) => {
34
+ meta.registerLanguage('nbt', {
35
+ extensions: ['.snbt'],
36
+ parser: parser.entry,
37
+ });
38
+ meta.registerParser('nbt:entry', parser.entry);
39
+ meta.registerParser('nbt:compound', parser.compound);
40
+ meta.registerParser('nbt:path', parser.path);
41
+ colorizer.register(meta);
42
+ };
43
+ exports.initialize = initialize;
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,113 @@
1
+ import * as core from '@spyglassmc/core';
2
+ import type * as nbtdoc from '@spyglassmc/nbtdoc';
3
+ export declare type NbtNode = NbtPrimitiveNode | NbtCompoundNode | NbtCollectionNode;
4
+ export declare namespace NbtNode {
5
+ function is(node: core.AstNode | undefined): node is NbtNode;
6
+ }
7
+ export declare type NbtPrimitiveNode = NbtNumberNode | core.StringNode;
8
+ export declare namespace NbtPrimitiveNode {
9
+ function is(node: core.AstNode | undefined): node is NbtPrimitiveNode;
10
+ }
11
+ export declare type NbtNumberNode = NbtIntegerAlikeNode | NbtFloatAlikeNode;
12
+ export declare namespace NbtNumberNode {
13
+ function is(node: core.AstNode | undefined): node is NbtNumberNode;
14
+ }
15
+ export declare type NbtIntegerAlikeNode = NbtByteNode | NbtShortNode | NbtIntNode | NbtLongNode;
16
+ export declare namespace NbtIntegerAlikeNode {
17
+ function is(node: core.AstNode | undefined): node is NbtIntegerAlikeNode;
18
+ }
19
+ export interface NbtByteNode extends core.IntegerBaseNode {
20
+ readonly type: 'nbt:byte';
21
+ }
22
+ export declare namespace NbtByteNode {
23
+ function is(node: core.AstNode | undefined): node is NbtByteNode;
24
+ }
25
+ export interface NbtShortNode extends core.IntegerBaseNode {
26
+ readonly type: 'nbt:short';
27
+ }
28
+ export declare namespace NbtShortNode {
29
+ function is(node: core.AstNode | undefined): node is NbtShortNode;
30
+ }
31
+ export interface NbtIntNode extends core.IntegerBaseNode {
32
+ readonly type: 'nbt:int';
33
+ }
34
+ export declare namespace NbtIntNode {
35
+ function is(node: core.AstNode | undefined): node is NbtIntNode;
36
+ }
37
+ export interface NbtLongNode extends core.LongBaseNode {
38
+ readonly type: 'nbt:long';
39
+ }
40
+ export declare namespace NbtLongNode {
41
+ function is(node: core.AstNode | undefined): node is NbtLongNode;
42
+ }
43
+ export declare type NbtFloatAlikeNode = NbtFloatNode | NbtDoubleNode;
44
+ export declare namespace NbtFloatAlikeNode {
45
+ function is(node: core.AstNode | undefined): node is NbtFloatAlikeNode;
46
+ }
47
+ export interface NbtFloatNode extends core.FloatBaseNode {
48
+ readonly type: 'nbt:float';
49
+ }
50
+ export declare namespace NbtFloatNode {
51
+ function is(node: core.AstNode | undefined): node is NbtFloatNode;
52
+ }
53
+ export interface NbtDoubleNode extends core.FloatBaseNode {
54
+ readonly type: 'nbt:double';
55
+ }
56
+ export declare namespace NbtDoubleNode {
57
+ function is(node: core.AstNode | undefined): node is NbtDoubleNode;
58
+ }
59
+ export interface NbtCompoundNode extends core.RecordBaseNode<core.StringNode, NbtNode> {
60
+ readonly type: 'nbt:compound';
61
+ }
62
+ export declare namespace NbtCompoundNode {
63
+ function is(node: core.AstNode | undefined): node is NbtCompoundNode;
64
+ }
65
+ export declare type NbtCollectionNode = NbtListNode | NbtPrimitiveArrayNode;
66
+ export declare namespace NbtCollectionNode {
67
+ function is(node: core.AstNode | undefined): node is NbtCollectionNode;
68
+ }
69
+ export interface NbtListNode extends core.ListNode<NbtNode> {
70
+ readonly type: 'nbt:list';
71
+ readonly valueType?: NbtNode['type'];
72
+ }
73
+ export declare namespace NbtListNode {
74
+ function is(node: core.AstNode | undefined): node is NbtListNode;
75
+ }
76
+ export declare type NbtPrimitiveArrayNode = NbtByteArrayNode | NbtIntArrayNode | NbtLongArrayNode;
77
+ export declare namespace NbtPrimitiveArrayNode {
78
+ function is(node: core.AstNode | undefined): node is NbtPrimitiveArrayNode;
79
+ }
80
+ export interface NbtByteArrayNode extends core.ListNode<NbtByteNode> {
81
+ readonly type: 'nbt:byte_array';
82
+ }
83
+ export declare namespace NbtByteArrayNode {
84
+ function is(node: core.AstNode | undefined): node is NbtByteArrayNode;
85
+ }
86
+ export interface NbtIntArrayNode extends core.ListNode<NbtIntNode> {
87
+ readonly type: 'nbt:int_array';
88
+ }
89
+ export declare namespace NbtIntArrayNode {
90
+ function is(node: core.AstNode | undefined): node is NbtIntArrayNode;
91
+ }
92
+ export interface NbtLongArrayNode extends core.ListNode<NbtLongNode> {
93
+ readonly type: 'nbt:long_array';
94
+ }
95
+ export declare namespace NbtLongArrayNode {
96
+ function is(node: core.AstNode | undefined): node is NbtLongArrayNode;
97
+ }
98
+ export interface NbtPathNode extends core.AstNode {
99
+ type: 'nbt:path';
100
+ children: (core.StringNode | NbtCompoundNode | NbtPathIndexNode)[];
101
+ targetType?: nbtdoc.NbtdocType | undefined;
102
+ }
103
+ export declare namespace NbtPathNode {
104
+ function is(node: core.AstNode | undefined): node is NbtPathNode;
105
+ }
106
+ export interface NbtPathIndexNode extends core.AstNode {
107
+ type: 'nbt:path/index';
108
+ children: [core.IntegerNode] | [NbtCompoundNode] | undefined;
109
+ }
110
+ export declare namespace NbtPathIndexNode {
111
+ function is(node: core.AstNode | undefined): node is NbtPathIndexNode;
112
+ }
113
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.NbtPathIndexNode = exports.NbtPathNode = exports.NbtLongArrayNode = exports.NbtIntArrayNode = exports.NbtByteArrayNode = exports.NbtPrimitiveArrayNode = exports.NbtListNode = exports.NbtCollectionNode = exports.NbtCompoundNode = exports.NbtDoubleNode = exports.NbtFloatNode = exports.NbtFloatAlikeNode = exports.NbtLongNode = exports.NbtIntNode = exports.NbtShortNode = exports.NbtByteNode = exports.NbtIntegerAlikeNode = exports.NbtNumberNode = exports.NbtPrimitiveNode = exports.NbtNode = void 0;
23
+ const core = __importStar(require("@spyglassmc/core"));
24
+ var NbtNode;
25
+ (function (NbtNode) {
26
+ /* istanbul ignore next */
27
+ function is(node) {
28
+ return NbtPrimitiveNode.is(node) || NbtCompoundNode.is(node) || NbtCollectionNode.is(node);
29
+ }
30
+ NbtNode.is = is;
31
+ })(NbtNode = exports.NbtNode || (exports.NbtNode = {}));
32
+ var NbtPrimitiveNode;
33
+ (function (NbtPrimitiveNode) {
34
+ /* istanbul ignore next */
35
+ function is(node) {
36
+ return NbtNumberNode.is(node) || core.StringNode.is(node);
37
+ }
38
+ NbtPrimitiveNode.is = is;
39
+ })(NbtPrimitiveNode = exports.NbtPrimitiveNode || (exports.NbtPrimitiveNode = {}));
40
+ var NbtNumberNode;
41
+ (function (NbtNumberNode) {
42
+ /* istanbul ignore next */
43
+ function is(node) {
44
+ return NbtIntegerAlikeNode.is(node) || NbtFloatAlikeNode.is(node);
45
+ }
46
+ NbtNumberNode.is = is;
47
+ })(NbtNumberNode = exports.NbtNumberNode || (exports.NbtNumberNode = {}));
48
+ var NbtIntegerAlikeNode;
49
+ (function (NbtIntegerAlikeNode) {
50
+ /* istanbul ignore next */
51
+ function is(node) {
52
+ return NbtByteNode.is(node) || NbtShortNode.is(node) || NbtIntNode.is(node) || NbtLongNode.is(node);
53
+ }
54
+ NbtIntegerAlikeNode.is = is;
55
+ })(NbtIntegerAlikeNode = exports.NbtIntegerAlikeNode || (exports.NbtIntegerAlikeNode = {}));
56
+ var NbtByteNode;
57
+ (function (NbtByteNode) {
58
+ /* istanbul ignore next */
59
+ function is(node) {
60
+ return node?.type === 'nbt:byte';
61
+ }
62
+ NbtByteNode.is = is;
63
+ })(NbtByteNode = exports.NbtByteNode || (exports.NbtByteNode = {}));
64
+ var NbtShortNode;
65
+ (function (NbtShortNode) {
66
+ /* istanbul ignore next */
67
+ function is(node) {
68
+ return node?.type === 'nbt:short';
69
+ }
70
+ NbtShortNode.is = is;
71
+ })(NbtShortNode = exports.NbtShortNode || (exports.NbtShortNode = {}));
72
+ var NbtIntNode;
73
+ (function (NbtIntNode) {
74
+ /* istanbul ignore next */
75
+ function is(node) {
76
+ return node?.type === 'nbt:int';
77
+ }
78
+ NbtIntNode.is = is;
79
+ })(NbtIntNode = exports.NbtIntNode || (exports.NbtIntNode = {}));
80
+ var NbtLongNode;
81
+ (function (NbtLongNode) {
82
+ /* istanbul ignore next */
83
+ function is(node) {
84
+ return node?.type === 'nbt:long';
85
+ }
86
+ NbtLongNode.is = is;
87
+ })(NbtLongNode = exports.NbtLongNode || (exports.NbtLongNode = {}));
88
+ var NbtFloatAlikeNode;
89
+ (function (NbtFloatAlikeNode) {
90
+ /* istanbul ignore next */
91
+ function is(node) {
92
+ return NbtFloatNode.is(node) || NbtDoubleNode.is(node);
93
+ }
94
+ NbtFloatAlikeNode.is = is;
95
+ })(NbtFloatAlikeNode = exports.NbtFloatAlikeNode || (exports.NbtFloatAlikeNode = {}));
96
+ var NbtFloatNode;
97
+ (function (NbtFloatNode) {
98
+ /* istanbul ignore next */
99
+ function is(node) {
100
+ return node?.type === 'nbt:float';
101
+ }
102
+ NbtFloatNode.is = is;
103
+ })(NbtFloatNode = exports.NbtFloatNode || (exports.NbtFloatNode = {}));
104
+ var NbtDoubleNode;
105
+ (function (NbtDoubleNode) {
106
+ /* istanbul ignore next */
107
+ function is(node) {
108
+ return node?.type === 'nbt:double';
109
+ }
110
+ NbtDoubleNode.is = is;
111
+ })(NbtDoubleNode = exports.NbtDoubleNode || (exports.NbtDoubleNode = {}));
112
+ var NbtCompoundNode;
113
+ (function (NbtCompoundNode) {
114
+ /* istanbul ignore next */
115
+ function is(node) {
116
+ return node?.type === 'nbt:compound';
117
+ }
118
+ NbtCompoundNode.is = is;
119
+ })(NbtCompoundNode = exports.NbtCompoundNode || (exports.NbtCompoundNode = {}));
120
+ var NbtCollectionNode;
121
+ (function (NbtCollectionNode) {
122
+ /* istanbul ignore next */
123
+ function is(node) {
124
+ return NbtListNode.is(node) || NbtPrimitiveArrayNode.is(node);
125
+ }
126
+ NbtCollectionNode.is = is;
127
+ })(NbtCollectionNode = exports.NbtCollectionNode || (exports.NbtCollectionNode = {}));
128
+ var NbtListNode;
129
+ (function (NbtListNode) {
130
+ /* istanbul ignore next */
131
+ function is(node) {
132
+ return node?.type === 'nbt:list';
133
+ }
134
+ NbtListNode.is = is;
135
+ })(NbtListNode = exports.NbtListNode || (exports.NbtListNode = {}));
136
+ var NbtPrimitiveArrayNode;
137
+ (function (NbtPrimitiveArrayNode) {
138
+ /* istanbul ignore next */
139
+ function is(node) {
140
+ return NbtByteArrayNode.is(node) || NbtIntArrayNode.is(node) || NbtLongArrayNode.is(node);
141
+ }
142
+ NbtPrimitiveArrayNode.is = is;
143
+ })(NbtPrimitiveArrayNode = exports.NbtPrimitiveArrayNode || (exports.NbtPrimitiveArrayNode = {}));
144
+ var NbtByteArrayNode;
145
+ (function (NbtByteArrayNode) {
146
+ /* istanbul ignore next */
147
+ function is(node) {
148
+ return node?.type === 'nbt:byte_array';
149
+ }
150
+ NbtByteArrayNode.is = is;
151
+ })(NbtByteArrayNode = exports.NbtByteArrayNode || (exports.NbtByteArrayNode = {}));
152
+ var NbtIntArrayNode;
153
+ (function (NbtIntArrayNode) {
154
+ /* istanbul ignore next */
155
+ function is(node) {
156
+ return node?.type === 'nbt:int_array';
157
+ }
158
+ NbtIntArrayNode.is = is;
159
+ })(NbtIntArrayNode = exports.NbtIntArrayNode || (exports.NbtIntArrayNode = {}));
160
+ var NbtLongArrayNode;
161
+ (function (NbtLongArrayNode) {
162
+ /* istanbul ignore next */
163
+ function is(node) {
164
+ return node?.type === 'nbt:long_array';
165
+ }
166
+ NbtLongArrayNode.is = is;
167
+ })(NbtLongArrayNode = exports.NbtLongArrayNode || (exports.NbtLongArrayNode = {}));
168
+ var NbtPathNode;
169
+ (function (NbtPathNode) {
170
+ /* istanbul ignore next */
171
+ function is(node) {
172
+ return node?.type === 'nbt:path';
173
+ }
174
+ NbtPathNode.is = is;
175
+ })(NbtPathNode = exports.NbtPathNode || (exports.NbtPathNode = {}));
176
+ var NbtPathIndexNode;
177
+ (function (NbtPathIndexNode) {
178
+ /* istanbul ignore next */
179
+ function is(node) {
180
+ return node?.type === 'nbt:path/index';
181
+ }
182
+ NbtPathIndexNode.is = is;
183
+ })(NbtPathIndexNode = exports.NbtPathIndexNode || (exports.NbtPathIndexNode = {}));
184
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ import * as core from '@spyglassmc/core';
2
+ import type { NbtByteArrayNode, NbtIntArrayNode, NbtListNode, NbtLongArrayNode } from '../node';
3
+ export declare const list: core.Parser<NbtListNode>;
4
+ export declare const byteArray: core.Parser<NbtByteArrayNode>;
5
+ export declare const intArray: core.Parser<NbtIntArrayNode>;
6
+ export declare const longArray: core.Parser<NbtLongArrayNode>;
7
+ //# sourceMappingURL=collection.d.ts.map
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.longArray = exports.intArray = exports.byteArray = exports.list = void 0;
23
+ const core = __importStar(require("@spyglassmc/core"));
24
+ const locales_1 = require("@spyglassmc/locales");
25
+ const util_1 = require("../util");
26
+ const entry_1 = require("./entry");
27
+ const primitive_1 = require("./primitive");
28
+ const list = (src, ctx) => {
29
+ const parser = core.list({ start: '[', value: entry_1.entry, sep: ',', trailingSep: false, end: ']' });
30
+ const ans = parser(src, ctx);
31
+ ans.type = 'nbt:list';
32
+ ans.valueType = ans.children[0]?.value?.type;
33
+ // Check if every element is of the same type.
34
+ if (ans.valueType) {
35
+ for (const { value } of ans.children) {
36
+ if (value && value.type !== ans.valueType) {
37
+ ctx.err.report((0, locales_1.localize)('expected-got', (0, util_1.localizeTag)(ans.valueType), (0, util_1.localizeTag)(value.type)), value);
38
+ }
39
+ }
40
+ }
41
+ return ans;
42
+ };
43
+ exports.list = list;
44
+ const byteArray = (src, ctx) => {
45
+ const parser = core.list({ start: '[B;', value: primitive_1.primitive, sep: ',', trailingSep: false, end: ']' });
46
+ const ans = parser(src, ctx);
47
+ ans.type = 'nbt:byte_array';
48
+ // Check if every element is of the required type.
49
+ for (const { value } of ans.children) {
50
+ if (value && value.type !== 'nbt:byte') {
51
+ ctx.err.report((0, locales_1.localize)('expected-got', (0, locales_1.localize)('nbt.node.byte'), (0, util_1.localizeTag)(value.type)), value);
52
+ }
53
+ }
54
+ return ans;
55
+ };
56
+ exports.byteArray = byteArray;
57
+ const intArray = (src, ctx) => {
58
+ const parser = core.list({ start: '[I;', value: primitive_1.primitive, sep: ',', trailingSep: false, end: ']' });
59
+ const ans = parser(src, ctx);
60
+ ans.type = 'nbt:int_array';
61
+ // Check if every element is of the required type.
62
+ for (const { value } of ans.children) {
63
+ if (value && value.type !== 'nbt:int') {
64
+ ctx.err.report((0, locales_1.localize)('expected-got', (0, locales_1.localize)('nbt.node.int'), (0, util_1.localizeTag)(value.type)), value);
65
+ }
66
+ }
67
+ return ans;
68
+ };
69
+ exports.intArray = intArray;
70
+ const longArray = (src, ctx) => {
71
+ const parser = core.list({ start: '[L;', value: primitive_1.primitive, sep: ',', trailingSep: false, end: ']' });
72
+ const ans = parser(src, ctx);
73
+ ans.type = 'nbt:long_array';
74
+ // Check if every element is of the required type.
75
+ for (const { value } of ans.children) {
76
+ if (value && value.type !== 'nbt:long') {
77
+ ctx.err.report((0, locales_1.localize)('expected-got', (0, locales_1.localize)('nbt.node.long'), (0, util_1.localizeTag)(value.type)), value);
78
+ }
79
+ }
80
+ return ans;
81
+ };
82
+ exports.longArray = longArray;
83
+ //# sourceMappingURL=collection.js.map
@@ -0,0 +1,4 @@
1
+ import * as core from '@spyglassmc/core';
2
+ import type { NbtCompoundNode } from '../node';
3
+ export declare const compound: core.InfallibleParser<NbtCompoundNode>;
4
+ //# sourceMappingURL=compound.d.ts.map