parse-tmx 1.7.1 → 1.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.
package/LICENSE CHANGED
@@ -1,201 +1,201 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2024 Jimmy Chen
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2024 Jimmy Chen
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,106 +1,106 @@
1
- # parse-tmx [![NPM Version](https://img.shields.io/npm/v/parse-tmx.svg?style=flat)](https://www.npmjs.org/package/parse-tmx)
2
-
3
- Inspired by [tmx-map-parser](https://github.com/praghus/tmx-map-parser).
4
- A parser for [Tiled Map Editor](http://www.mapeditor.org/) \*.tmx files.
5
-
6
- ## Installation
7
-
8
- ```sh
9
- pnpm i parse-tmx
10
- ```
11
-
12
- ## Usage
13
-
14
- The basic implementation:
15
-
16
- ```ts
17
- import { parseTmx } from "parse-tmx";
18
- // The *.tmx file can be loaded as a string or URL encoded data.
19
- // for Webpack use 'url-loader' plugin, for Rollup it can be '@rollup/plugin-url'
20
- import tmxFile from "map.tmx";
21
-
22
- // Translates the tile flips in the layer data (default: false)
23
- const translateFlips = true;
24
-
25
- const loadMap = async () => {
26
- const data = await parseTmx(tmxFile, translateFlips);
27
- console.log(data);
28
- };
29
- ```
30
-
31
- ### Important
32
-
33
- Parser only supports embedded tilesets. At the moment, external tilesets are not supported!
34
-
35
- ## Example data
36
-
37
- [TMX Map Format documentation](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/)
38
-
39
- ```js
40
- {
41
- tiledversion: "1.8.0",
42
- tilewidth: 16,
43
- tileheight: 16,
44
- version: 1.8,
45
- width: 512,
46
- height: 128,
47
- infinite: 0,
48
- nextlayerid: 5,
49
- nextobjectid: 165,
50
- orientation: "orthogonal",
51
- renderorder: "right-down",
52
- properties: {
53
- property1: 'value',
54
- property2: 0.5
55
- },
56
- layers: [{
57
- id: 1,
58
- name: "layer name",
59
- type: "layer",
60
- visible: 1,
61
- data: [0, 1, 1, 10, 10, 10, 1, 1, 0, 0, 0, 0, …],
62
- // When the translateFlips parameter is enabled
63
- flips: [
64
- {H: false, V: false, D: false},
65
- {H: true, V: false, D: true},
66
- {H: false, V: false, D: false},
67
- {…}
68
- ],
69
- width: 512,
70
- height: 128,
71
- opacity: 0.77,
72
- properties: {
73
- property1: 'value',
74
- property2: false
75
- }
76
- }, {
77
- id: 2,
78
- name: "objects",
79
- type: "objectgroup",
80
- visible: 1,
81
- objects: [{…}, {…}, {…}],
82
- properties: {
83
- property1: 'value',
84
- property2: false
85
- }
86
- }, {
87
- …
88
- }],
89
- tilesets: [{
90
- columns: 32,
91
- firstgid: 1,
92
- image: {source: "tiles.png", width: 512, height: 512},
93
- name: "tiles",
94
- tilecount: 1024,
95
- tilewidth: 16,
96
- tileheight: 16,
97
- tiles: [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
98
- }, {
99
- …
100
- }]
101
- }
102
- ```
103
-
104
- ## License
105
-
106
- [Apache-2.0 licensed](../../LICENSE).
1
+ # parse-tmx [![NPM Version](https://img.shields.io/npm/v/parse-tmx.svg?style=flat)](https://www.npmjs.org/package/parse-tmx)
2
+
3
+ Inspired by [tmx-map-parser](https://github.com/praghus/tmx-map-parser).
4
+ A parser for [Tiled Map Editor](http://www.mapeditor.org/) \*.tmx files.
5
+
6
+ ## Installation
7
+
8
+ ```sh
9
+ pnpm i parse-tmx
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ The basic implementation:
15
+
16
+ ```ts
17
+ import { parseTmx } from "parse-tmx";
18
+ // The *.tmx file can be loaded as a string or URL encoded data.
19
+ // for Webpack use 'url-loader' plugin, for Rollup it can be '@rollup/plugin-url'
20
+ import tmxFile from "map.tmx";
21
+
22
+ // Translates the tile flips in the layer data (default: false)
23
+ const translateFlips = true;
24
+
25
+ const loadMap = async () => {
26
+ const data = await parseTmx(tmxFile, translateFlips);
27
+ console.log(data);
28
+ };
29
+ ```
30
+
31
+ ### Important
32
+
33
+ Parser only supports embedded tilesets. At the moment, external tilesets are not supported!
34
+
35
+ ## Example data
36
+
37
+ [TMX Map Format documentation](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/)
38
+
39
+ ```js
40
+ {
41
+ tiledversion: "1.8.0",
42
+ tilewidth: 16,
43
+ tileheight: 16,
44
+ version: 1.8,
45
+ width: 512,
46
+ height: 128,
47
+ infinite: 0,
48
+ nextlayerid: 5,
49
+ nextobjectid: 165,
50
+ orientation: "orthogonal",
51
+ renderorder: "right-down",
52
+ properties: {
53
+ property1: 'value',
54
+ property2: 0.5
55
+ },
56
+ layers: [{
57
+ id: 1,
58
+ name: "layer name",
59
+ type: "layer",
60
+ visible: 1,
61
+ data: [0, 1, 1, 10, 10, 10, 1, 1, 0, 0, 0, 0, …],
62
+ // When the translateFlips parameter is enabled
63
+ flips: [
64
+ {H: false, V: false, D: false},
65
+ {H: true, V: false, D: true},
66
+ {H: false, V: false, D: false},
67
+ {…}
68
+ ],
69
+ width: 512,
70
+ height: 128,
71
+ opacity: 0.77,
72
+ properties: {
73
+ property1: 'value',
74
+ property2: false
75
+ }
76
+ }, {
77
+ id: 2,
78
+ name: "objects",
79
+ type: "objectgroup",
80
+ visible: 1,
81
+ objects: [{…}, {…}, {…}],
82
+ properties: {
83
+ property1: 'value',
84
+ property2: false
85
+ }
86
+ }, {
87
+ …
88
+ }],
89
+ tilesets: [{
90
+ columns: 32,
91
+ firstgid: 1,
92
+ image: {source: "tiles.png", width: 512, height: 512},
93
+ name: "tiles",
94
+ tilecount: 1024,
95
+ tilewidth: 16,
96
+ tileheight: 16,
97
+ tiles: [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
98
+ }, {
99
+ …
100
+ }]
101
+ }
102
+ ```
103
+
104
+ ## License
105
+
106
+ [Apache-2.0 licensed](../../LICENSE).
package/dist/index.d.ts CHANGED
@@ -1,194 +1,307 @@
1
- // Generated by dts-bundle-generator v9.5.1
2
-
3
- export interface TMXEditorSettingsParsed extends Record<string, unknown> {
1
+ interface TMXEditorSettingsParsed extends Record<string, unknown> {
4
2
  }
5
- export interface TMXFlipsParsed {
6
- H: boolean;
7
- V: boolean;
8
- D: boolean;
3
+
4
+ interface TMXFlipsParsed {
5
+ H: boolean;
6
+ V: boolean;
7
+ D: boolean;
9
8
  }
10
- export interface TMXImageShared {
11
- height: number;
12
- width: number;
13
- source: string;
9
+
10
+ interface TMXImageShared {
11
+ height: number;
12
+ width: number;
13
+ source: string;
14
14
  }
15
- export interface TMXImageParsed extends TMXImageShared {
15
+
16
+ interface TMXImageParsed extends TMXImageShared {
16
17
  }
18
+
17
19
  declare enum Shape {
18
- Ellipse = "ellipse",
19
- Point = "point",
20
- Polygon = "polygon",
21
- Rectangle = "rectangle"
22
- }
23
- export type TMXPropertiesParsed = Record<string, unknown>[];
24
- export interface TMXObjectShared {
25
- id: number;
26
- type: string;
27
- gid: number;
28
- x: number;
29
- y: number;
30
- width: number;
31
- height: number;
32
- }
33
- export interface TMXObjectParsed extends TMXObjectShared {
34
- name: string;
35
- value: string;
36
- shape: Shape;
37
- points?: [
38
- number,
39
- number
40
- ][];
41
- text?: string;
42
- flips?: TMXFlipsParsed;
43
- properties?: TMXPropertiesParsed;
44
- }
45
- export interface TMXLayerShared {
46
- id: number;
47
- name: string;
48
- type: string;
49
- width: number;
50
- height: number;
51
- x?: number;
52
- y?: number;
53
- locked?: number;
54
- opacity?: number;
55
- visible?: number;
56
- tintcolor?: string;
57
- offsetx?: number;
58
- offsety?: number;
59
- parallaxx?: number;
60
- parallaxy?: number;
61
- }
62
- export interface TMXLayerParsed extends TMXLayerShared {
63
- data?: number[];
64
- image?: TMXImageParsed;
65
- flips?: TMXFlipsParsed[];
66
- objects?: TMXObjectParsed[];
67
- properties?: TMXPropertiesParsed;
68
- }
69
- export interface TMXGroupLayerShared {
70
- id: number;
71
- name: string;
72
- type: string;
73
- }
74
- export interface TMXGroupLayerParsed extends TMXGroupLayerShared {
75
- layers: TMXLayerParsed[];
76
- properties?: TMXPropertiesParsed;
77
- }
78
- export interface TMXTileShared {
79
- id: number;
80
- gid?: number;
81
- probability?: number;
82
- }
83
- export interface TMXTileParsed extends TMXTileShared {
84
- id: number;
85
- type: string;
86
- animation?: {
87
- frames: number[];
88
- };
89
- objects?: TMXObjectParsed[];
90
- properties?: TMXPropertiesParsed;
91
- }
92
- export interface TMXBaseTilesetShared {
93
- firstgid: number;
94
- }
95
- export interface TMXEmbeddedTilesetShared extends TMXBaseTilesetShared {
96
- columns: number;
97
- name: string;
98
- spacing?: number;
99
- margin?: number;
100
- tilecount: number;
101
- tilewidth: number;
102
- tileheight: number;
103
- imagewidth: number;
104
- imageheight: number;
105
- }
106
- export interface TMXEmbeddedTilesetParsed extends TMXEmbeddedTilesetShared {
107
- image: TMXImageParsed;
108
- tiles: TMXTileParsed[];
109
- }
110
- export interface TMXExternalTilesetShared extends TMXBaseTilesetShared {
111
- source: string;
112
- }
113
- export interface TMXExternalTilesetParsed extends TMXExternalTilesetShared {
114
- }
115
- export type TMXTilesetParsed = TMXEmbeddedTilesetParsed | TMXExternalTilesetParsed;
116
- declare class TMXMapShared {
117
- version: number;
118
- tiledversion: string;
119
- orientation: string;
120
- renderorder: string;
121
- width: number;
122
- height: number;
123
- tilewidth: number;
124
- tileheight: number;
125
- infinite: number;
126
- nextlayerid: number;
127
- nextobjectid: number;
20
+ Ellipse = "ellipse",
21
+ Point = "point",
22
+ Polygon = "polygon",
23
+ Rectangle = "rectangle"
128
24
  }
129
- declare class TMXMapParsed extends TMXMapShared {
130
- editorsettings: TMXEditorSettingsParsed;
131
- tilesets: TMXTilesetParsed[];
132
- layers: (TMXLayerParsed | TMXGroupLayerParsed)[];
133
- properties: TMXPropertiesParsed;
134
- constructor(init?: Partial<TMXMapParsed>);
25
+
26
+ type TMXPropertiesParsed = Record<string, unknown>[];
27
+
28
+ interface TMXObjectShared {
29
+ id: number;
30
+ type: string;
31
+ gid: number;
32
+ x: number;
33
+ y: number;
34
+ width: number;
35
+ height: number;
135
36
  }
136
- export interface TMXParsed {
137
- map: TMXMapParsed;
37
+
38
+ interface TMXObjectParsed extends TMXObjectShared {
39
+ name: string;
40
+ value: string;
41
+ shape: Shape;
42
+ points?: [number, number][];
43
+ text?: string;
44
+ flips?: TMXFlipsParsed;
45
+ properties?: TMXPropertiesParsed;
138
46
  }
139
- export interface BaseTMXNode<T> extends Record<string, unknown> {
140
- $: T;
47
+
48
+ interface TMXLayerShared {
49
+ id: number;
50
+ name: string;
51
+ type: string;
52
+ width: number;
53
+ height: number;
54
+ x?: number;
55
+ y?: number;
56
+ locked?: number;
57
+ opacity?: number;
58
+ visible?: number;
59
+ tintcolor?: string;
60
+ offsetx?: number;
61
+ offsety?: number;
62
+ parallaxx?: number;
63
+ parallaxy?: number;
141
64
  }
142
- export type TMXNode<T, TChildNode extends BaseTMXNode<unknown> | undefined = undefined> = BaseTMXNode<T> & {
143
- $$: TChildNode extends undefined ? undefined : TChildNode[];
144
- };
145
- export interface TMXImageNode extends TMXNode<TMXImageShared> {
65
+
66
+ interface TMXLayerParsed extends TMXLayerShared {
67
+ data?: number[];
68
+ image?: TMXImageParsed;
69
+ flips?: TMXFlipsParsed[];
70
+ objects?: TMXObjectParsed[];
71
+ properties?: TMXPropertiesParsed;
72
+ }
73
+
74
+ interface TMXGroupLayerShared {
75
+ id: number;
76
+ name: string;
77
+ type: string;
78
+ }
79
+
80
+ interface TMXGroupLayerParsed extends TMXGroupLayerShared {
81
+ layers: TMXLayerParsed[];
82
+ properties?: TMXPropertiesParsed;
83
+ }
84
+
85
+ interface TMXTileShared {
86
+ id: number;
87
+ gid?: number;
88
+ probability?: number;
89
+ }
90
+
91
+ interface TMXTileParsed extends TMXTileShared {
92
+ id: number;
93
+ type: string;
94
+ animation?: {
95
+ frames: number[];
96
+ };
97
+ objects?: TMXObjectParsed[];
98
+ properties?: TMXPropertiesParsed;
99
+ }
100
+
101
+ interface TMXBaseTilesetShared {
102
+ firstgid: number;
146
103
  }
104
+
105
+ interface TMXEmbeddedTilesetShared extends TMXBaseTilesetShared {
106
+ columns: number;
107
+ name: string;
108
+ spacing?: number;
109
+ margin?: number;
110
+ tilecount: number;
111
+ tilewidth: number;
112
+ tileheight: number;
113
+ imagewidth: number;
114
+ imageheight: number;
115
+ }
116
+
117
+ interface TMXEmbeddedTilesetParsed extends TMXEmbeddedTilesetShared {
118
+ image: TMXImageParsed;
119
+ tiles: TMXTileParsed[];
120
+ }
121
+
122
+ interface TMXExternalTilesetShared extends TMXBaseTilesetShared {
123
+ source: string;
124
+ }
125
+
126
+ interface TMXExternalTilesetParsed extends TMXExternalTilesetShared {
127
+ }
128
+
129
+ type TMXTilesetParsed = TMXEmbeddedTilesetParsed | TMXExternalTilesetParsed;
130
+
131
+ declare class TMXMapShared {
132
+ version: number;
133
+ tiledversion: string;
134
+ orientation: string;
135
+ renderorder: string;
136
+ width: number;
137
+ height: number;
138
+ tilewidth: number;
139
+ tileheight: number;
140
+ infinite: number;
141
+ nextlayerid: number;
142
+ nextobjectid: number;
143
+ }
144
+
145
+ declare class TMXMapParsed extends TMXMapShared {
146
+ editorsettings: TMXEditorSettingsParsed;
147
+ tilesets: TMXTilesetParsed[];
148
+ layers: (TMXLayerParsed | TMXGroupLayerParsed)[];
149
+ properties: TMXPropertiesParsed;
150
+ constructor(init?: Partial<TMXMapParsed>);
151
+ }
152
+
153
+ interface TMXParsed {
154
+ map: TMXMapParsed;
155
+ }
156
+
157
+ declare const parseTmx: (xmlString: string, translateFlips?: boolean) => Promise<TMXParsed>;
158
+
147
159
  declare enum Compression {
148
- Gzip = "gzip",
149
- Zlib = "zlib"
160
+ Gzip = "gzip",
161
+ Zlib = "zlib"
150
162
  }
163
+
151
164
  declare enum Encoding {
152
- Base64 = "base64",
153
- Csv = "csv"
165
+ Base64 = "base64",
166
+ Csv = "csv"
167
+ }
168
+
169
+ declare enum Flipped {
170
+ Diagonally = 536870912,
171
+ Horizontally = 2147483648,
172
+ Vertically = 1073741824
154
173
  }
155
- export interface TMXDataNode extends TMXNode<{
156
- encoding: Encoding;
157
- compression?: Compression | null;
174
+
175
+ declare const isExternalTileset: (tileset: TMXEmbeddedTilesetShared | TMXExternalTilesetShared) => tileset is TMXExternalTilesetShared;
176
+
177
+ declare const parseFlips: (gid: number) => TMXFlipsParsed;
178
+
179
+ interface BaseTMXNode<T> extends Record<string, unknown> {
180
+ $: T;
181
+ }
182
+ type TMXNode<T, TChildNode extends BaseTMXNode<unknown> | undefined = undefined> = BaseTMXNode<T> & {
183
+ $$: TChildNode extends undefined ? undefined : TChildNode[];
184
+ };
185
+
186
+ interface TMXDataNode extends TMXNode<{
187
+ encoding: Encoding;
188
+ compression?: Compression | null;
158
189
  }> {
159
- _: string;
190
+ _: string;
160
191
  }
161
- export interface TMXPropertyNode extends TMXNode<{
162
- name: string;
163
- value?: string;
192
+
193
+ interface TMXImageNode extends TMXNode<TMXImageShared> {
194
+ }
195
+
196
+ interface TMXPropertyNode extends TMXNode<{
197
+ name: string;
198
+ value?: string;
164
199
  }> {
165
- _: string;
200
+ _: string;
201
+ }
202
+
203
+ interface TMXPropertiesNode extends TMXNode<Record<string, never>, TMXPropertyNode> {
204
+ }
205
+
206
+ interface TMXObjectNode extends TMXNode<TMXObjectShared, TMXDataNode | TMXPropertiesNode> {
207
+ polygon?: TMXNode<{
208
+ points: string;
209
+ }>[];
210
+ text?: TMXDataNode[];
211
+ properties?: {
212
+ property: TMXPropertyNode[];
213
+ }[];
214
+ }
215
+
216
+ interface TMXTileNode extends TMXNode<TMXTileShared, TMXPropertiesNode> {
217
+ animation?: Record<string, TMXNode<number>[]>[];
218
+ objectgroup?: Record<string, TMXObjectNode[]>[];
219
+ properties?: {
220
+ property: TMXPropertyNode[];
221
+ }[];
222
+ }
223
+
224
+ interface TMXEmbeddedTilesetNode extends TMXNode<TMXEmbeddedTilesetShared, TMXImageNode | TMXTileNode> {
225
+ tile?: TMXTileNode[];
226
+ }
227
+
228
+ interface TMXLayerNode extends TMXNode<TMXLayerShared, TMXEmbeddedTilesetNode | TMXDataNode | TMXPropertiesNode> {
229
+ data?: TMXEmbeddedTilesetNode[] | TMXDataNode[];
230
+ image?: TMXImageNode[];
231
+ object?: TMXObjectNode[];
232
+ properties?: {
233
+ property: TMXPropertyNode[];
234
+ }[];
235
+ }
236
+
237
+ interface TMXGroupLayerNode extends TMXNode<TMXGroupLayerShared, TMXLayerNode> {
238
+ properties?: {
239
+ property: TMXPropertyNode[];
240
+ }[];
241
+ }
242
+
243
+ declare const parseGroup: (node: TMXGroupLayerNode, expectedCount: number, translateFlips: boolean) => Promise<TMXGroupLayerParsed>;
244
+
245
+ declare const parseLayer: (node: TMXLayerNode) => TMXLayerParsed;
246
+
247
+ declare const parseNode: <TNode extends TMXLayerNode | TMXGroupLayerNode, TParsedNode = TNode extends TMXLayerNode ? TMXLayerParsed : TMXGroupLayerParsed>(node: TMXLayerNode | TMXGroupLayerNode, expectedCount: number, translateFlips: boolean) => Promise<TParsedNode> | TParsedNode;
248
+
249
+ declare const parseObject: (node: TMXObjectNode) => TMXObjectParsed;
250
+
251
+ declare const parseObjectShape: (node: TMXObjectNode) => Shape;
252
+
253
+ declare const parseProperties: (properties?: {
254
+ property: TMXPropertyNode[];
255
+ }[]) => TMXPropertiesParsed | undefined;
256
+
257
+ declare const parseTile: (node: TMXTileNode) => TMXTileParsed;
258
+
259
+ declare const parseTileId: (gid: number) => number;
260
+
261
+ declare const parseTileLayer: (node: TMXLayerNode, expectedCount: number, translateFlips: boolean) => Promise<TMXLayerParsed>;
262
+
263
+ interface TMXExternalTilesetNode extends TMXNode<TMXExternalTilesetShared> {
264
+ }
265
+
266
+ type TMXTilesetNode = TMXEmbeddedTilesetNode | TMXExternalTilesetNode;
267
+
268
+ declare const parseTileset: (node: TMXTilesetNode) => TMXTilesetParsed;
269
+
270
+ declare const unpackTileBytes: (buffer: Buffer, expectedCount: number) => number[];
271
+
272
+ interface TMXExportShared {
273
+ target: string;
274
+ format: string;
166
275
  }
167
- export interface TMXPropertiesNode extends TMXNode<Record<string, never>, TMXPropertyNode> {
276
+
277
+ interface TMXExportNode extends TMXNode<TMXExportShared> {
168
278
  }
169
- export interface TMXObjectNode extends TMXNode<TMXObjectShared, TMXDataNode | TMXPropertiesNode> {
170
- polygon?: TMXNode<{
171
- points: string;
172
- }>[];
173
- text?: TMXDataNode[];
174
- properties?: {
175
- property: TMXPropertyNode[];
176
- }[];
279
+
280
+ interface TMXEditorSettingsNode extends TMXNode<Record<string, never>, TMXExportNode> {
177
281
  }
178
- export interface TMXTileNode extends TMXNode<TMXTileShared, TMXPropertiesNode> {
179
- animation?: Record<string, TMXNode<number>[]>[];
180
- objectgroup?: Record<string, TMXObjectNode[]>[];
181
- properties?: {
182
- property: TMXPropertyNode[];
183
- }[];
282
+
283
+ interface TMXMapNode extends TMXNode<TMXMapShared, TMXEditorSettingsNode | TMXTilesetNode | TMXGroupLayerNode | TMXPropertiesNode> {
184
284
  }
185
- export interface TMXEmbeddedTilesetNode extends TMXNode<TMXEmbeddedTilesetShared, TMXImageNode | TMXTileNode> {
186
- tile?: TMXTileNode[];
285
+
286
+ interface TMX {
287
+ map: TMXMapNode;
187
288
  }
188
- export interface TMXExternalTilesetNode extends TMXNode<TMXExternalTilesetShared> {
289
+
290
+ declare enum TMXNodeType {
291
+ EditorSettings = "editorsettings",
292
+ Export = "export",
293
+ Group = "group",
294
+ Image = "image",
295
+ ImageLayer = "imagelayer",
296
+ Layer = "layer",
297
+ Object = "object",
298
+ Objectgroup = "objectgroup",
299
+ Properties = "properties",
300
+ Property = "property",
301
+ Tileset = "tileset"
302
+ }
303
+
304
+ interface TMXExportParsed extends TMXExportShared {
189
305
  }
190
- export type TMXTilesetNode = TMXEmbeddedTilesetNode | TMXExternalTilesetNode;
191
- export declare const parseTileset: (node: TMXTilesetNode) => TMXTilesetParsed;
192
- export declare const parseTmx: (xmlString: string, translateFlips?: boolean) => Promise<TMXParsed>;
193
306
 
194
- export {};
307
+ export { Compression, Encoding, Flipped, Shape, type TMX, type TMXBaseTilesetShared, type TMXDataNode, type TMXEditorSettingsNode, type TMXEditorSettingsParsed, type TMXEmbeddedTilesetNode, type TMXEmbeddedTilesetParsed, type TMXEmbeddedTilesetShared, type TMXExportNode, type TMXExportParsed, type TMXExportShared, type TMXExternalTilesetNode, type TMXExternalTilesetParsed, type TMXExternalTilesetShared, type TMXFlipsParsed, type TMXGroupLayerNode, type TMXGroupLayerParsed, type TMXGroupLayerShared, type TMXImageNode, type TMXImageParsed, type TMXImageShared, type TMXLayerNode, type TMXLayerParsed, type TMXLayerShared, type TMXMapNode, TMXMapParsed, TMXMapShared, type TMXNode, TMXNodeType, type TMXObjectNode, type TMXObjectParsed, type TMXObjectShared, type TMXParsed, type TMXPropertiesNode, type TMXPropertiesParsed, type TMXPropertyNode, type TMXTileNode, type TMXTileParsed, type TMXTileShared, type TMXTilesetNode, type TMXTilesetParsed, isExternalTileset, parseFlips, parseGroup, parseLayer, parseNode, parseObject, parseObjectShape, parseProperties, parseTile, parseTileId, parseTileLayer, parseTileset, parseTmx, unpackTileBytes };
package/dist/index.js CHANGED
@@ -303,4 +303,4 @@ const parseTmx = async (xmlString, translateFlips = false) => {
303
303
  return { map };
304
304
  };
305
305
 
306
- export { parseTileset, parseTmx };
306
+ export { Compression, Encoding, Flipped, Shape, TMXMapParsed, TMXMapShared, TMXNodeType, isExternalTileset, parseFlips, parseGroup, parseLayer, parseNode, parseObject, parseObjectShape, parseProperties, parseTile, parseTileId, parseTileLayer, parseTileset, parseTmx, unpackTileBytes };
package/package.json CHANGED
@@ -1,10 +1,8 @@
1
1
  {
2
2
  "name": "parse-tmx",
3
- "version": "1.7.1",
3
+ "version": "1.9.0",
4
4
  "description": "A parser for tmx",
5
5
  "type": "module",
6
- "homepage": "https://github.com/Esposter/Esposter#readme",
7
- "license": "Apache-2.0",
8
6
  "main": "dist/index.js",
9
7
  "types": "dist/index.d.ts",
10
8
  "files": [
@@ -15,6 +13,8 @@
15
13
  "tmx",
16
14
  "parser"
17
15
  ],
16
+ "homepage": "https://github.com/Esposter/Esposter#readme",
17
+ "license": "Apache-2.0",
18
18
  "repository": {
19
19
  "type": "git",
20
20
  "url": "git+https://github.com/Esposter/Esposter.git"
@@ -23,22 +23,18 @@
23
23
  "url": "https://github.com/Esposter/Esposter/issues"
24
24
  },
25
25
  "scripts": {
26
- "build": "rollup --config rollup.config.ts --configPlugin typescript && pnpm run types:gen",
26
+ "build": "pnpm run export:gen && rollup --config rollup.config.js",
27
27
  "lint": "eslint .",
28
28
  "lint:fix": "eslint --fix .",
29
29
  "typecheck": "tsc --noEmit",
30
- "types:gen": "dts-bundle-generator -o dist/index.d.ts src/index.ts"
30
+ "export:gen": "ctix build --config ../configuration/.ctirc"
31
31
  },
32
32
  "dependencies": {
33
- "@esposter/shared": "1.7.1"
33
+ "@esposter/shared": "1.9.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@rollup/plugin-typescript": "^11.1.6",
37
- "@types/node": "^20.12.12",
38
- "dts-bundle-generator": "^9.5.1",
39
- "eslint": "^9.3.0",
40
- "rollup": "^4.17.2",
41
- "typescript": "^5.4.5"
36
+ "@esposter/configuration": "1.9.0",
37
+ "@types/node": "^20.12.12"
42
38
  },
43
- "gitHead": "af7e26ffe150e019dfc1d789a94bd0264ffd4358"
39
+ "gitHead": "59b5a81397421bd4d521b861791efe33fdf9b544"
44
40
  }