parse-tmx 1.17.0 → 1.19.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 +201 -201
- package/README.md +106 -106
- package/dist/index.d.ts +45 -45
- package/dist/index.js +20 -20
- package/package.json +3 -7
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 [](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
|
-
...
|
|
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 [](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
|
+
...
|
|
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
|
@@ -2,15 +2,15 @@ interface TMXEditorSettingsParsed extends Record<string, unknown> {
|
|
|
2
2
|
}
|
|
3
3
|
|
|
4
4
|
interface TMXFlipsParsed {
|
|
5
|
+
D: boolean;
|
|
5
6
|
H: boolean;
|
|
6
7
|
V: boolean;
|
|
7
|
-
D: boolean;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
interface TMXImageShared {
|
|
11
11
|
height: number;
|
|
12
|
-
width: number;
|
|
13
12
|
source: string;
|
|
13
|
+
width: number;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
interface TMXImageParsed extends TMXImageShared {
|
|
@@ -26,47 +26,47 @@ declare enum Shape {
|
|
|
26
26
|
type TMXPropertiesParsed = Record<string, unknown>[];
|
|
27
27
|
|
|
28
28
|
interface TMXObjectShared {
|
|
29
|
+
gid: number;
|
|
30
|
+
height: number;
|
|
29
31
|
id: number;
|
|
30
32
|
type: string;
|
|
31
|
-
|
|
33
|
+
width: number;
|
|
32
34
|
x: number;
|
|
33
35
|
y: number;
|
|
34
|
-
width: number;
|
|
35
|
-
height: number;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
interface TMXObjectParsed extends TMXObjectShared {
|
|
39
|
+
flips?: TMXFlipsParsed;
|
|
39
40
|
name: string;
|
|
40
|
-
value: string;
|
|
41
|
-
shape: Shape;
|
|
42
41
|
points?: [number, number][];
|
|
43
|
-
text?: string;
|
|
44
|
-
flips?: TMXFlipsParsed;
|
|
45
42
|
properties?: TMXPropertiesParsed;
|
|
43
|
+
shape: Shape;
|
|
44
|
+
text?: string;
|
|
45
|
+
value: string;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
interface TMXLayerShared {
|
|
49
|
-
id: number;
|
|
50
|
-
name: string;
|
|
51
|
-
type: string;
|
|
52
|
-
width: number;
|
|
53
49
|
height: number;
|
|
54
|
-
|
|
55
|
-
y?: number;
|
|
50
|
+
id: number;
|
|
56
51
|
locked?: number;
|
|
57
|
-
|
|
58
|
-
visible?: number;
|
|
59
|
-
tintcolor?: string;
|
|
52
|
+
name: string;
|
|
60
53
|
offsetx?: number;
|
|
61
54
|
offsety?: number;
|
|
55
|
+
opacity?: number;
|
|
62
56
|
parallaxx?: number;
|
|
63
57
|
parallaxy?: number;
|
|
58
|
+
tintcolor?: string;
|
|
59
|
+
type: string;
|
|
60
|
+
visible?: number;
|
|
61
|
+
width: number;
|
|
62
|
+
x?: number;
|
|
63
|
+
y?: number;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
interface TMXLayerParsed extends TMXLayerShared {
|
|
67
67
|
data?: number[];
|
|
68
|
-
image?: TMXImageParsed;
|
|
69
68
|
flips?: TMXFlipsParsed[];
|
|
69
|
+
image?: TMXImageParsed;
|
|
70
70
|
objects?: TMXObjectParsed[];
|
|
71
71
|
properties?: TMXPropertiesParsed;
|
|
72
72
|
}
|
|
@@ -83,19 +83,19 @@ interface TMXGroupLayerParsed extends TMXGroupLayerShared {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
interface TMXTileShared {
|
|
86
|
-
id: number;
|
|
87
86
|
gid?: number;
|
|
87
|
+
id: number;
|
|
88
88
|
probability?: number;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
interface TMXTileParsed extends TMXTileShared {
|
|
92
|
-
id: number;
|
|
93
|
-
type: string;
|
|
94
92
|
animation?: {
|
|
95
93
|
frames: number[];
|
|
96
94
|
};
|
|
95
|
+
id: number;
|
|
97
96
|
objects?: TMXObjectParsed[];
|
|
98
97
|
properties?: TMXPropertiesParsed;
|
|
98
|
+
type: string;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
interface TMXBaseTilesetShared {
|
|
@@ -104,14 +104,14 @@ interface TMXBaseTilesetShared {
|
|
|
104
104
|
|
|
105
105
|
interface TMXEmbeddedTilesetShared extends TMXBaseTilesetShared {
|
|
106
106
|
columns: number;
|
|
107
|
+
imageheight: number;
|
|
108
|
+
imagewidth: number;
|
|
109
|
+
margin?: number;
|
|
107
110
|
name: string;
|
|
108
111
|
spacing?: number;
|
|
109
|
-
margin?: number;
|
|
110
112
|
tilecount: number;
|
|
111
|
-
tilewidth: number;
|
|
112
113
|
tileheight: number;
|
|
113
|
-
|
|
114
|
-
imageheight: number;
|
|
114
|
+
tilewidth: number;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
interface TMXEmbeddedTilesetParsed extends TMXEmbeddedTilesetShared {
|
|
@@ -129,24 +129,24 @@ interface TMXExternalTilesetParsed extends TMXExternalTilesetShared {
|
|
|
129
129
|
type TMXTilesetParsed = TMXEmbeddedTilesetParsed | TMXExternalTilesetParsed;
|
|
130
130
|
|
|
131
131
|
declare class TMXMapShared {
|
|
132
|
-
version: number;
|
|
133
|
-
tiledversion: string;
|
|
134
|
-
orientation: string;
|
|
135
|
-
renderorder: string;
|
|
136
|
-
width: number;
|
|
137
132
|
height: number;
|
|
138
|
-
tilewidth: number;
|
|
139
|
-
tileheight: number;
|
|
140
133
|
infinite: number;
|
|
141
134
|
nextlayerid: number;
|
|
142
135
|
nextobjectid: number;
|
|
136
|
+
orientation: string;
|
|
137
|
+
renderorder: string;
|
|
138
|
+
tiledversion: string;
|
|
139
|
+
tileheight: number;
|
|
140
|
+
tilewidth: number;
|
|
141
|
+
version: number;
|
|
142
|
+
width: number;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
declare class TMXMapParsed extends TMXMapShared {
|
|
146
146
|
editorsettings: TMXEditorSettingsParsed;
|
|
147
|
-
|
|
148
|
-
layers: (TMXLayerParsed | TMXGroupLayerParsed)[];
|
|
147
|
+
layers: (TMXGroupLayerParsed | TMXLayerParsed)[];
|
|
149
148
|
properties: TMXPropertiesParsed;
|
|
149
|
+
tilesets: TMXTilesetParsed[];
|
|
150
150
|
constructor(init?: Partial<TMXMapParsed>);
|
|
151
151
|
}
|
|
152
152
|
|
|
@@ -177,13 +177,13 @@ declare const isExternalTileset: (tileset: TMXEmbeddedTilesetShared | TMXExterna
|
|
|
177
177
|
interface BaseTMXNode<T> extends Record<string, unknown> {
|
|
178
178
|
$: T;
|
|
179
179
|
}
|
|
180
|
-
type TMXNode<T, TChildNode extends BaseTMXNode<unknown> | undefined = undefined> =
|
|
180
|
+
type TMXNode<T, TChildNode extends BaseTMXNode<unknown> | undefined = undefined> = {
|
|
181
181
|
$$: TChildNode extends undefined ? undefined : TChildNode[];
|
|
182
|
-
}
|
|
182
|
+
} & BaseTMXNode<T>;
|
|
183
183
|
|
|
184
184
|
interface TMXDataNode extends TMXNode<{
|
|
185
|
-
encoding: Encoding;
|
|
186
185
|
compression?: Compression | null;
|
|
186
|
+
encoding: Encoding;
|
|
187
187
|
}> {
|
|
188
188
|
_: string;
|
|
189
189
|
}
|
|
@@ -205,10 +205,10 @@ interface TMXObjectNode extends TMXNode<TMXObjectShared, TMXDataNode | TMXProper
|
|
|
205
205
|
polygon?: TMXNode<{
|
|
206
206
|
points: string;
|
|
207
207
|
}>[];
|
|
208
|
-
text?: TMXDataNode[];
|
|
209
208
|
properties?: {
|
|
210
209
|
property: TMXPropertyNode[];
|
|
211
210
|
}[];
|
|
211
|
+
text?: TMXDataNode[];
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
interface TMXTileNode extends TMXNode<TMXTileShared, TMXPropertiesNode> {
|
|
@@ -223,12 +223,12 @@ interface TMXEmbeddedTilesetNode extends TMXNode<TMXEmbeddedTilesetShared, TMXIm
|
|
|
223
223
|
tile?: TMXTileNode[];
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
declare const isTMXEmbeddedTilesetNode: (node:
|
|
226
|
+
declare const isTMXEmbeddedTilesetNode: (node: TMXDataNode | TMXEmbeddedTilesetNode) => node is TMXEmbeddedTilesetNode;
|
|
227
227
|
|
|
228
228
|
declare const parseFlips: (gid: number) => TMXFlipsParsed;
|
|
229
229
|
|
|
230
|
-
interface TMXLayerNode extends TMXNode<TMXLayerShared,
|
|
231
|
-
data?:
|
|
230
|
+
interface TMXLayerNode extends TMXNode<TMXLayerShared, TMXDataNode | TMXEmbeddedTilesetNode | TMXPropertiesNode> {
|
|
231
|
+
data?: TMXDataNode[] | TMXEmbeddedTilesetNode[];
|
|
232
232
|
image?: TMXImageNode[];
|
|
233
233
|
object?: TMXObjectNode[];
|
|
234
234
|
properties?: {
|
|
@@ -246,7 +246,7 @@ declare const parseGroup: (node: TMXGroupLayerNode, expectedCount: number, trans
|
|
|
246
246
|
|
|
247
247
|
declare const parseLayer: (node: TMXLayerNode) => TMXLayerParsed;
|
|
248
248
|
|
|
249
|
-
declare const parseNode: <TNode extends TMXLayerNode | TMXGroupLayerNode, TParsedNode = TNode extends TMXLayerNode ? TMXLayerParsed : TMXGroupLayerParsed>(node:
|
|
249
|
+
declare const parseNode: <TNode extends TMXLayerNode | TMXGroupLayerNode, TParsedNode = TNode extends TMXLayerNode ? TMXLayerParsed : TMXGroupLayerParsed>(node: TMXGroupLayerNode | TMXLayerNode, expectedCount: number, translateFlips: boolean) => Promise<TParsedNode> | TParsedNode;
|
|
250
250
|
|
|
251
251
|
declare const parseObject: (node: TMXObjectNode) => TMXObjectParsed;
|
|
252
252
|
|
|
@@ -272,8 +272,8 @@ declare const parseTileset: (node: TMXTilesetNode) => TMXTilesetParsed;
|
|
|
272
272
|
declare const unpackTileBytes: (buffer: Buffer, expectedCount: number) => number[];
|
|
273
273
|
|
|
274
274
|
interface TMXExportShared {
|
|
275
|
-
target: string;
|
|
276
275
|
format: string;
|
|
276
|
+
target: string;
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
interface TMXExportNode extends TMXNode<TMXExportShared> {
|
|
@@ -282,7 +282,7 @@ interface TMXExportNode extends TMXNode<TMXExportShared> {
|
|
|
282
282
|
interface TMXEditorSettingsNode extends TMXNode<Record<string, never>, TMXExportNode> {
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
interface TMXMapNode extends TMXNode<TMXMapShared, TMXEditorSettingsNode |
|
|
285
|
+
interface TMXMapNode extends TMXNode<TMXMapShared, TMXEditorSettingsNode | TMXGroupLayerNode | TMXPropertiesNode | TMXTilesetNode> {
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
interface TMX {
|
package/dist/index.js
CHANGED
|
@@ -17,24 +17,24 @@ var TMXNodeType;
|
|
|
17
17
|
})(TMXNodeType || (TMXNodeType = {}));
|
|
18
18
|
|
|
19
19
|
class TMXMapShared {
|
|
20
|
-
version = 0;
|
|
21
|
-
tiledversion = "";
|
|
22
|
-
orientation = "";
|
|
23
|
-
renderorder = "";
|
|
24
|
-
width = 0;
|
|
25
20
|
height = 0;
|
|
26
|
-
tilewidth = 0;
|
|
27
|
-
tileheight = 0;
|
|
28
21
|
infinite = 0;
|
|
29
22
|
nextlayerid = 0;
|
|
30
23
|
nextobjectid = 0;
|
|
24
|
+
orientation = "";
|
|
25
|
+
renderorder = "";
|
|
26
|
+
tiledversion = "";
|
|
27
|
+
tileheight = 0;
|
|
28
|
+
tilewidth = 0;
|
|
29
|
+
version = 0;
|
|
30
|
+
width = 0;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
class TMXMapParsed extends TMXMapShared {
|
|
34
34
|
editorsettings = {};
|
|
35
|
-
tilesets = [];
|
|
36
35
|
layers = [];
|
|
37
36
|
properties = [];
|
|
37
|
+
tilesets = [];
|
|
38
38
|
constructor(init) {
|
|
39
39
|
super();
|
|
40
40
|
Object.assign(this, init);
|
|
@@ -58,9 +58,9 @@ var Flipped;
|
|
|
58
58
|
})(Flipped || (Flipped = {}));
|
|
59
59
|
|
|
60
60
|
const parseFlips = (gid) => ({
|
|
61
|
+
D: Boolean(gid & Flipped.Diagonally),
|
|
61
62
|
H: Boolean(gid & Flipped.Horizontally),
|
|
62
63
|
V: Boolean(gid & Flipped.Vertically),
|
|
63
|
-
D: Boolean(gid & Flipped.Diagonally),
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
var Shape;
|
|
@@ -84,7 +84,7 @@ const parseObjectShape = (node) => {
|
|
|
84
84
|
|
|
85
85
|
const parseProperties = (properties) => properties
|
|
86
86
|
? properties.map(({ property }) => {
|
|
87
|
-
const {
|
|
87
|
+
const { _, $ } = property[0];
|
|
88
88
|
const { name, value } = $;
|
|
89
89
|
return { name, value: value ?? _ };
|
|
90
90
|
})
|
|
@@ -93,7 +93,7 @@ const parseProperties = (properties) => properties
|
|
|
93
93
|
const parseTileId = (gid) => (gid &= ~Object.values(Flipped).reduce((acc, curr) => acc | curr, 0));
|
|
94
94
|
|
|
95
95
|
const parseObject = (node) => {
|
|
96
|
-
const { $, polygon,
|
|
96
|
+
const { $, polygon, properties, text } = node;
|
|
97
97
|
const object = structuredClone($);
|
|
98
98
|
object.shape = parseObjectShape(node);
|
|
99
99
|
if (properties)
|
|
@@ -166,8 +166,8 @@ const parseTileLayer = async (node, expectedCount, translateFlips) => {
|
|
|
166
166
|
layer.data = nodeData.tile?.map(({ $ }) => $.gid ?? 0) ?? [];
|
|
167
167
|
else {
|
|
168
168
|
// Csv, Base64
|
|
169
|
-
const {
|
|
170
|
-
const {
|
|
169
|
+
const { _, $ } = nodeData;
|
|
170
|
+
const { compression, encoding } = $;
|
|
171
171
|
const layerData = _.trim();
|
|
172
172
|
switch (encoding) {
|
|
173
173
|
case Encoding.Csv:
|
|
@@ -218,11 +218,11 @@ const parseNode = (node, expectedCount, translateFlips) => {
|
|
|
218
218
|
switch (tmxNodeType) {
|
|
219
219
|
case TMXNodeType.Group:
|
|
220
220
|
return parseGroup(node, expectedCount, translateFlips);
|
|
221
|
-
case TMXNodeType.Layer:
|
|
222
|
-
return parseTileLayer(node, expectedCount, translateFlips);
|
|
223
221
|
case TMXNodeType.ImageLayer:
|
|
224
222
|
case TMXNodeType.Objectgroup:
|
|
225
223
|
return parseLayer(node);
|
|
224
|
+
case TMXNodeType.Layer:
|
|
225
|
+
return parseTileLayer(node, expectedCount, translateFlips);
|
|
226
226
|
default:
|
|
227
227
|
throw new InvalidOperationError(Operation.Read, parseNode.name, tmxNodeType);
|
|
228
228
|
}
|
|
@@ -273,6 +273,11 @@ const parseTmx = async (xmlString, translateFlips = false) => {
|
|
|
273
273
|
break;
|
|
274
274
|
map.editorsettings = { ...node.$$.map((n) => ({ [n["#name"]]: n.$ })) };
|
|
275
275
|
break;
|
|
276
|
+
case TMXNodeType.Export:
|
|
277
|
+
case TMXNodeType.Image:
|
|
278
|
+
case TMXNodeType.Object:
|
|
279
|
+
case TMXNodeType.Property:
|
|
280
|
+
break;
|
|
276
281
|
case TMXNodeType.Group:
|
|
277
282
|
case TMXNodeType.ImageLayer:
|
|
278
283
|
case TMXNodeType.Layer:
|
|
@@ -292,11 +297,6 @@ const parseTmx = async (xmlString, translateFlips = false) => {
|
|
|
292
297
|
case TMXNodeType.Tileset:
|
|
293
298
|
map.tilesets.push(parseTileset(node));
|
|
294
299
|
break;
|
|
295
|
-
case TMXNodeType.Export:
|
|
296
|
-
case TMXNodeType.Image:
|
|
297
|
-
case TMXNodeType.Object:
|
|
298
|
-
case TMXNodeType.Property:
|
|
299
|
-
break;
|
|
300
300
|
default:
|
|
301
301
|
exhaustiveGuard(tmxNodeType);
|
|
302
302
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "parse-tmx",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "A parser for tmx",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,12 +29,8 @@
|
|
|
29
29
|
"typecheck": "tsc --noEmit",
|
|
30
30
|
"export:gen": "ctix build --config ../configuration/.ctirc-ts"
|
|
31
31
|
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"@esposter/shared": "1.17.0"
|
|
34
|
-
},
|
|
35
32
|
"devDependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@types/node": "^22.1.0"
|
|
33
|
+
"@types/node": "^22.5.4"
|
|
38
34
|
},
|
|
39
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "2fe8f2a49cceb82218872b21e3b45014022b2b95"
|
|
40
36
|
}
|