@margoengine/tilemap 0.0.0-stage → 1.0.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/dist/hex.js ADDED
@@ -0,0 +1,101 @@
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./layout-CLx3KdGC.js";
2
+ //#region src/hex.ts
3
+ var s = (e) => {
4
+ if (e.orientation !== "hexagonal" && e.orientation !== "staggered") throw RangeError(`hex cells need a hexagonal or staggered map, got "${e.orientation ?? "orthogonal"}".`);
5
+ return {
6
+ y: (e.staggerAxis ?? "y") === "y",
7
+ odd: (e.staggerIndex ?? "odd") === "odd"
8
+ };
9
+ };
10
+ function c(e, t, n) {
11
+ let { y: r, odd: i } = s(e);
12
+ if (r) {
13
+ let e = t - (i ? (n - (n & 1)) / 2 : (n + (n & 1)) / 2);
14
+ return [
15
+ e,
16
+ n,
17
+ -e - n
18
+ ];
19
+ }
20
+ let a = n - (i ? (t - (t & 1)) / 2 : (t + (t & 1)) / 2);
21
+ return [
22
+ t,
23
+ a,
24
+ -t - a
25
+ ];
26
+ }
27
+ function l(e, [t, n]) {
28
+ let { y: r, odd: i } = s(e);
29
+ return r ? [t + (i ? (n - (n & 1)) / 2 : (n + (n & 1)) / 2), n] : [t, n + (i ? (t - (t & 1)) / 2 : (t + (t & 1)) / 2)];
30
+ }
31
+ function u(e, t, n) {
32
+ let [r, i, a] = c(e, t[0], t[1]), [o, s, l] = c(e, n[0], n[1]);
33
+ return Math.max(Math.abs(r - o), Math.abs(i - s), Math.abs(a - l));
34
+ }
35
+ function d(e, t, n) {
36
+ let r = Math.round(e), i = Math.round(t), a = Math.round(n), o = Math.abs(r - e), s = Math.abs(i - t), c = Math.abs(a - n);
37
+ return o > s && o > c ? r = -i - a : s > c ? i = -r - a : a = -r - i, [
38
+ r + 0,
39
+ i + 0,
40
+ a + 0
41
+ ];
42
+ }
43
+ function f(e, t, n) {
44
+ let r = u(e, t, n), [i, a, o] = c(e, t[0], t[1]), [s, f, p] = c(e, n[0], n[1]), m = [];
45
+ for (let t = 0; t <= r; t++) {
46
+ let n = r ? t / r : 0;
47
+ m.push(l(e, d(i + (s - i) * n + 1e-6, a + (f - a) * n + 1e-6, o + (p - o) * n - 2e-6)));
48
+ }
49
+ return m;
50
+ }
51
+ function p(e, t, n, r) {
52
+ if (!Number.isInteger(r) || r < 0) throw RangeError(`radius must be a whole number of 0 or more, got ${r}.`);
53
+ if (!r) return [[t, n]];
54
+ let [i, a, o] = c(e, t, n), s = [
55
+ [
56
+ 1,
57
+ -1,
58
+ 0
59
+ ],
60
+ [
61
+ 1,
62
+ 0,
63
+ -1
64
+ ],
65
+ [
66
+ 0,
67
+ 1,
68
+ -1
69
+ ],
70
+ [
71
+ -1,
72
+ 1,
73
+ 0
74
+ ],
75
+ [
76
+ -1,
77
+ 0,
78
+ 1
79
+ ],
80
+ [
81
+ 0,
82
+ -1,
83
+ 1
84
+ ]
85
+ ], u = [], d = [
86
+ i + s[4][0] * r,
87
+ a + s[4][1] * r,
88
+ o + s[4][2] * r
89
+ ];
90
+ for (let t of s) for (let n = 0; n < r; n++) u.push(l(e, d)), d = [
91
+ d[0] + t[0],
92
+ d[1] + t[1],
93
+ d[2] + t[2]
94
+ ];
95
+ return u;
96
+ }
97
+ function m(e, t, n) {
98
+ return i(e, t[0], t[1]).some(([e, t]) => e === n[0] && t === n[1]);
99
+ }
100
+ //#endregion
101
+ export { o as cellBox, n as cellCenter, i as cellNeighbors, t as cellPolygon, c as cellToCube, l as cubeToCell, m as hexAdjacent, u as hexDistance, f as hexLine, p as hexRing, e as mapPixelSize, r as paintOrder, a as pixelToCell, d as roundCube };
package/dist/hpa.d.ts ADDED
@@ -0,0 +1,87 @@
1
+ import type { CostGrid, GridPath, PathOptions } from './path.js';
2
+ /** Settings of {@link PathHierarchy}. */
3
+ export interface HierarchyOptions {
4
+ /** Corner steps, as `findPath` takes them. Default `'no-corners'`. */
5
+ diagonal?: PathOptions['diagonal'];
6
+ /** Stops one `findPath` call after this many expanded cells and nodes. Default 1,000,000. */
7
+ maxCells?: number;
8
+ /** Cells along a cluster's side, a whole number of 2 or more. Default 16. */
9
+ cluster?: number;
10
+ /**
11
+ * How many steps any border crossing may lie from a transition, a whole number of 0 or more. 0 makes every crossing a
12
+ * transition, for exact costs and the largest graph; higher values make a smaller graph. Default 3.
13
+ */
14
+ detour?: number;
15
+ }
16
+ /**
17
+ * Long paths over a large grid for the price of short ones: build once, then {@link PathHierarchy.findPath} searches a
18
+ * graph of cluster borders and fills in only the clusters the path crosses. Change `grid.cost`, tell
19
+ * {@link PathHierarchy.update} which cells changed, and only the clusters around them are rebuilt.
20
+ */
21
+ export declare class PathHierarchy {
22
+ /** The grid searched; change its costs in place, then call {@link update}. */
23
+ readonly grid: CostGrid;
24
+ readonly cluster: number;
25
+ readonly detour: number;
26
+ private readonly diagonal;
27
+ private readonly square;
28
+ private readonly max;
29
+ private readonly across;
30
+ private readonly down;
31
+ private low;
32
+ private readonly clusters;
33
+ /** The transitions between two clusters, under `first * count + second`. */
34
+ private readonly borders;
35
+ /** Each node's transitions, both ways. */
36
+ private readonly links;
37
+ private readonly dirty;
38
+ private readonly dist;
39
+ private readonly came;
40
+ private readonly seen;
41
+ private readonly done;
42
+ private stamp;
43
+ private expanded;
44
+ constructor(grid: CostGrid, options?: HierarchyOptions);
45
+ /** The nodes of the abstract graph, as cells, for drawing and for judging the size `cluster` and `detour` give. */
46
+ get nodes(): [number, number][];
47
+ /**
48
+ * Tells the hierarchy which cells' costs changed since the last call; the clusters around them are rebuilt before the
49
+ * next query. Every changed cell must be listed.
50
+ */
51
+ update(cells: Iterable<readonly [number, number]>): this;
52
+ /**
53
+ * A path from `start` to `goal`, or null when there is no way (or `maxCells` ran out). It finds a way whenever one
54
+ * exists. Its cost is the cheapest one with a `detour` of 0, and otherwise above it by at most
55
+ * `(2 * detour + 1) * L * highest` for each cluster border a cheapest path crosses, where `highest` is the dearest open
56
+ * cell and `L` is sqrt(2) with corner steps and 1 without them (and on hexagonal and staggered maps). `smooth`
57
+ * (default true) searches the path again in short stretches and keeps what is cheaper.
58
+ */
59
+ findPath(start: readonly [number, number], goal: readonly [number, number], { smooth }?: {
60
+ smooth?: boolean;
61
+ }): GridPath | null;
62
+ private clusterOf;
63
+ private inside;
64
+ /** The cost of the step from `a` to its neighbour `b`. */
65
+ private price;
66
+ /**
67
+ * Searches from `from` over the cells `allowed` accepts: to `target` by A*, or everywhere (-1). With `reverse` each
68
+ * distance is the cost of walking from the cell to `from`. True when the target was reached (or there is none).
69
+ */
70
+ private explore;
71
+ /** The distances the last search found to those of `cells` it reached. */
72
+ private reached;
73
+ /** The last search's way to `cell`, from its start. */
74
+ private trace;
75
+ /**
76
+ * Searches stretches of the path again, each a cluster side long and overlapping the next by half, inside the stretch's
77
+ * bounds widened by half a cluster, and takes the new way where it is cheaper.
78
+ */
79
+ private shorten;
80
+ /** Chooses the transitions of the borders of every dirty cluster again, then the ways inside the clusters they end in. */
81
+ private rebuild;
82
+ /**
83
+ * The transitions from cluster `a` to cluster `b`: enough of the steps between them that every such step is within
84
+ * `detour` hops of one. A hop moves each end by at most one step inside its own cluster.
85
+ */
86
+ private transitions;
87
+ }
package/dist/hpa.js ADDED
@@ -0,0 +1,239 @@
1
+ import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./grid-search-B0VbYKpe.js";
2
+ //#region src/hpa.ts
3
+ var s = class {
4
+ constructor(e, t = {}) {
5
+ this.low = Infinity, this.borders = /* @__PURE__ */ new Map(), this.links = /* @__PURE__ */ new Map(), this.dirty = /* @__PURE__ */ new Set(), this.stamp = 0, this.expanded = 0;
6
+ let { diagonal: n, max: a, square: o } = i(e, t), s = t.cluster ?? 16, c = t.detour ?? 3;
7
+ if (!Number.isInteger(s) || s < 2) throw RangeError(`cluster must be a whole number of 2 or more, got ${s}.`);
8
+ if (!Number.isInteger(c) || c < 0) throw RangeError(`detour must be a whole number of 0 or more, got ${c}.`);
9
+ this.grid = e, this.diagonal = n, this.square = o, this.max = a, this.cluster = s, this.detour = c, this.across = Math.ceil(e.width / s), this.down = Math.ceil(e.height / s), this.clusters = Array.from({ length: this.across * this.down }, () => ({
10
+ nodes: [],
11
+ edges: /* @__PURE__ */ new Map()
12
+ }));
13
+ let l = e.cost.length;
14
+ this.dist = new Float64Array(l), this.came = new Int32Array(l), this.seen = new Uint32Array(l), this.done = new Uint32Array(l);
15
+ for (let t = 0; t < l; t++) r(e.cost[t]) && e.cost[t] < this.low && (this.low = e.cost[t]);
16
+ for (let e = 0; e < this.clusters.length; e++) this.dirty.add(e);
17
+ this.rebuild();
18
+ }
19
+ get nodes() {
20
+ this.rebuild();
21
+ let { width: e } = this.grid;
22
+ return this.clusters.flatMap((t) => t.nodes.map((t) => [t % e, Math.floor(t / e)]));
23
+ }
24
+ update(t) {
25
+ let { grid: n } = this;
26
+ for (let i of t) {
27
+ let t = e(n, i, "cell"), [a, o] = i;
28
+ r(n.cost[t]) && n.cost[t] < this.low && (this.low = n.cost[t]);
29
+ for (let e = -1; e <= 1; e++) for (let r = -1; r <= 1; r++) a + r >= 0 && o + e >= 0 && a + r < n.width && o + e < n.height && this.dirty.add(this.clusterOf(t + e * n.width + r));
30
+ }
31
+ return this;
32
+ }
33
+ findPath(n, i, { smooth: a = !0 } = {}) {
34
+ let { grid: s } = this, { cost: l, width: u } = s, d = e(s, n, "start"), f = e(s, i, "goal");
35
+ if (!r(l[d]) || !r(l[f])) return null;
36
+ this.rebuild(), this.expanded = 0;
37
+ let p = this.clusterOf(d), m = this.clusterOf(f), h = t(s, this.square, this.diagonal, this.low);
38
+ this.explore(d, this.inside(p), -1, !1);
39
+ let g = this.reached([...this.clusters[p].nodes, ...p === m ? [f] : []]);
40
+ this.explore(f, this.inside(m), -1, !0);
41
+ let _ = this.reached(this.clusters[m].nodes), v = /* @__PURE__ */ new Map([[d, 0]]), y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set(), x = new o();
42
+ for (x.push(d, h(d, f)); x.size;) {
43
+ let e = x.pop();
44
+ if (b.has(e)) continue;
45
+ if (b.add(e), e === f) break;
46
+ if (++this.expanded > this.max) return null;
47
+ let t = v.get(e), n = (n, r) => {
48
+ let i = t + r;
49
+ i < (v.get(n) ?? Infinity) && (v.set(n, i), y.set(n, e), x.push(n, i + h(n, f)));
50
+ };
51
+ if (e === d) for (let [e, t] of g) n(e, t);
52
+ let r = this.clusterOf(e), i = this.clusters[r].edges.get(e);
53
+ if (i) for (let e = 0; e < i.to.length; e++) n(i.to[e], i.cost[e]);
54
+ for (let t of this.links.get(e) ?? []) {
55
+ let r = t.a === e ? t.b : t.a;
56
+ n(r, l[r] * t.length);
57
+ }
58
+ let a = r === m ? _.get(e) : void 0;
59
+ a !== void 0 && n(f, a);
60
+ }
61
+ if (!b.has(f)) return null;
62
+ let S = [f];
63
+ for (; S[S.length - 1] !== d;) S.push(y.get(S[S.length - 1]));
64
+ S.reverse();
65
+ let C = [d];
66
+ for (let e = 1; e < S.length; e++) {
67
+ let t = S[e - 1], n = S[e], r = this.clusterOf(t);
68
+ if (this.clusterOf(n) !== r) C.push(n);
69
+ else {
70
+ if (!this.explore(t, this.inside(r), n, !1)) return null;
71
+ let e = this.trace(n);
72
+ for (let t = 1; t < e.length; t++) C.push(e[t]);
73
+ }
74
+ }
75
+ if (C = c(C), a && (C = c(this.shorten(C))), this.expanded > this.max) return null;
76
+ let w = 0;
77
+ for (let e = 1; e < C.length; e++) w += this.price(C[e - 1], C[e]);
78
+ return {
79
+ cells: C.map((e) => [e % u, Math.floor(e / u)]),
80
+ cost: w,
81
+ searched: this.expanded,
82
+ scanned: 0
83
+ };
84
+ }
85
+ clusterOf(e) {
86
+ let t = e % this.grid.width, n = (e - t) / this.grid.width;
87
+ return Math.floor(n / this.cluster) * this.across + Math.floor(t / this.cluster);
88
+ }
89
+ inside(e) {
90
+ return (t) => this.clusterOf(t) === e;
91
+ }
92
+ price(e, t) {
93
+ let { width: r, cost: i } = this.grid, a = this.square && e % r !== t % r && Math.floor(e / r) !== Math.floor(t / r);
94
+ return i[t] * (a ? n : 1);
95
+ }
96
+ explore(e, n, r, i) {
97
+ let { grid: s, dist: c, came: l, seen: u, done: d } = this, { cost: f } = s, p = ++this.stamp, m = r < 0 ? void 0 : t(s, this.square, this.diagonal, this.low), h = new o();
98
+ for (u[e] = p, c[e] = 0, l[e] = -1, h.push(e, 0); h.size;) {
99
+ let e = h.pop();
100
+ if (d[e] !== p) {
101
+ if (d[e] = p, e === r) return !0;
102
+ this.expanded++, a(s, this.square, this.diagonal, e, (t, a) => {
103
+ if (d[t] === p || !n(t)) return;
104
+ let o = c[e] + f[i ? e : t] * a;
105
+ (u[t] !== p || o < c[t]) && (u[t] = p, c[t] = o, l[t] = e, h.push(t, m ? o + m(t, r) : o));
106
+ });
107
+ }
108
+ }
109
+ return r < 0;
110
+ }
111
+ reached(e) {
112
+ let t = /* @__PURE__ */ new Map();
113
+ for (let n of e) this.done[n] === this.stamp && t.set(n, this.dist[n]);
114
+ return t;
115
+ }
116
+ trace(e) {
117
+ let t = [];
118
+ for (let n = e; n !== -1; n = this.came[n]) t.push(n);
119
+ return t.reverse();
120
+ }
121
+ shorten(e) {
122
+ let { width: t } = this.grid, n = this.cluster, r = n >> 1 || 1;
123
+ for (let i = 0; i + 2 < e.length; i += r) {
124
+ let a = Math.min(e.length - 1, i + n), o = t, s = this.grid.height, c = 0, l = 0, u = 0;
125
+ for (let n = i; n <= a; n++) {
126
+ let r = e[n] % t, a = (e[n] - r) / t;
127
+ o = Math.min(o, r), c = Math.max(c, r), s = Math.min(s, a), l = Math.max(l, a), n > i && (u += this.price(e[n - 1], e[n]));
128
+ }
129
+ let d = (e) => {
130
+ let n = e % t, i = (e - n) / t;
131
+ return n >= o - r && n <= c + r && i >= s - r && i <= l + r;
132
+ };
133
+ if (this.expanded > this.max) break;
134
+ if (this.explore(e[i], d, e[a], !1) && this.dist[e[a]] < u - u * 1e-9) {
135
+ let t = this.trace(e[a]);
136
+ e = e.slice(0, i).concat(t, e.slice(a + 1));
137
+ }
138
+ }
139
+ return e;
140
+ }
141
+ rebuild() {
142
+ if (!this.dirty.size) return;
143
+ let { across: e, down: t, clusters: n, borders: r, links: i } = this, a = /* @__PURE__ */ new Set(), o = new Set(this.dirty);
144
+ for (let r of this.dirty) {
145
+ let i = r % e, o = (r - i) / e;
146
+ for (let s = -1; s <= 1; s++) for (let c = -1; c <= 1; c++) {
147
+ if (!c && !s || i + c < 0 || o + s < 0 || i + c >= e || o + s >= t) continue;
148
+ let l = r + s * e + c;
149
+ a.add(Math.min(r, l) * n.length + Math.max(r, l));
150
+ }
151
+ }
152
+ for (let e of a) {
153
+ let t = e % n.length, a = (e - t) / n.length, s = r.get(e) ?? [], c = this.transitions(a, t);
154
+ if (!(s.length === c.length && s.every((e, t) => e.a === c[t].a && e.b === c[t].b))) {
155
+ for (let e of s) for (let t of [e.a, e.b]) {
156
+ let n = i.get(t).filter((t) => t !== e);
157
+ n.length ? i.set(t, n) : i.delete(t);
158
+ }
159
+ for (let e of c) for (let t of [e.a, e.b]) i.set(t, [...i.get(t) ?? [], e]);
160
+ r.set(e, c), o.add(a), o.add(t);
161
+ }
162
+ }
163
+ for (let i of o) {
164
+ let a = i % e, o = (i - a) / e, s = /* @__PURE__ */ new Set();
165
+ for (let c = -1; c <= 1; c++) for (let l = -1; l <= 1; l++) {
166
+ if (!l && !c || a + l < 0 || o + c < 0 || a + l >= e || o + c >= t) continue;
167
+ let u = i + c * e + l;
168
+ for (let e of r.get(Math.min(i, u) * n.length + Math.max(i, u)) ?? []) s.add(i < u ? e.a : e.b);
169
+ }
170
+ let c = n[i];
171
+ c.nodes = [...s].sort((e, t) => e - t), c.edges = /* @__PURE__ */ new Map();
172
+ for (let e of c.nodes) {
173
+ this.explore(e, this.inside(i), -1, !1);
174
+ let t = this.reached(c.nodes);
175
+ t.delete(e), c.edges.set(e, {
176
+ to: [...t.keys()],
177
+ cost: [...t.values()]
178
+ });
179
+ }
180
+ }
181
+ this.dirty.clear();
182
+ }
183
+ transitions(e, t) {
184
+ let { grid: n, across: i, cluster: o, detour: s } = this, { width: c, height: l, cost: u } = n, d = e % i * o, f = Math.floor(e / i) * o, p = Math.min(c, d + o) - 1, m = Math.min(l, f + o) - 1, h = [], g = /* @__PURE__ */ new Map();
185
+ for (let e = f; e <= m; e++) for (let i = d; i <= p; i += e === f || e === m || i === p ? 1 : p - d) {
186
+ let o = e * c + i;
187
+ r(u[o]) && a(n, this.square, this.diagonal, o, (e, n) => {
188
+ if (this.clusterOf(e) !== t) return;
189
+ let r = g.get(o);
190
+ r ? r.push(h.length) : g.set(o, [h.length]), h.push({
191
+ a: o,
192
+ b: e,
193
+ length: n
194
+ });
195
+ });
196
+ }
197
+ if (!s || h.length < 2) return h;
198
+ let _ = (e, t) => {
199
+ let r = /* @__PURE__ */ new Set([e]);
200
+ return a(n, this.square, this.diagonal, e, (e) => {
201
+ this.clusterOf(e) === t && r.add(e);
202
+ }), r;
203
+ }, v = [], y = (n) => {
204
+ let r = v[n];
205
+ if (r) return r;
206
+ r = [];
207
+ let i = _(h[n].b, t);
208
+ for (let t of _(h[n].a, e)) for (let e of g.get(t) ?? []) e !== n && i.has(h[e].b) && r.push(e);
209
+ return v[n] = r, r;
210
+ }, b = (e) => {
211
+ let t = /* @__PURE__ */ new Map([[e, 0]]);
212
+ for (let [e, n] of t) if (n < s) for (let r of y(e)) t.has(r) || t.set(r, n + 1);
213
+ return t;
214
+ }, x = new Uint8Array(h.length), S = [];
215
+ for (let e = 0; e < h.length; e++) {
216
+ if (x[e]) continue;
217
+ let t, n = e, r = -1, i = 0;
218
+ for (let a of b(e).keys()) {
219
+ let e = b(a), o = 0, s = 0;
220
+ for (let [t, n] of e) x[t] || (o++, s += n);
221
+ let c = h[a].length - h[n].length;
222
+ (o > r || o === r && (c < 0 || c === 0 && s < i)) && (t = e, n = a, r = o, i = s);
223
+ }
224
+ for (let e of t.keys()) x[e] = 1;
225
+ S.push(h[n]);
226
+ }
227
+ return S;
228
+ }
229
+ }, c = (e) => {
230
+ let t = /* @__PURE__ */ new Map(), n = [];
231
+ for (let r of e) {
232
+ let e = t.get(r);
233
+ if (e === void 0) t.set(r, n.length), n.push(r);
234
+ else for (let r of n.splice(e + 1)) t.delete(r);
235
+ }
236
+ return n;
237
+ };
238
+ //#endregion
239
+ export { s as PathHierarchy };
@@ -0,0 +1,33 @@
1
+ import { a as e, r as t } from "./src-CJvCfCkX.js";
2
+ //#region src/import.ts
3
+ var n = class extends Error {
4
+ constructor(e, t, n) {
5
+ super(`${e}: ${n}`), this.name = "MapImportError", this.format = e, this.code = t;
6
+ }
7
+ }, r = 1 << 24, i = (e) => typeof e == "object" && !!e && !Array.isArray(e), a = (e, t, n = 0) => {
8
+ let r = e[t];
9
+ return typeof r == "number" && Number.isFinite(r) ? r : n;
10
+ }, o = (e, t) => typeof e[t] == "string" ? e[t] : void 0, s = (e, t) => Array.isArray(e[t]) ? e[t] : [], c = (n, r = !1) => (n & (e | t | (r ? 268435456 : 0))) >>> 0;
11
+ function l(e, t, n) {
12
+ Object.defineProperty(e, t, {
13
+ value: n,
14
+ enumerable: !0,
15
+ writable: !0,
16
+ configurable: !0
17
+ });
18
+ }
19
+ function u(e, t) {
20
+ let r = t;
21
+ if (t instanceof Uint8Array && (r = new TextDecoder().decode(t)), typeof r == "string") try {
22
+ r = JSON.parse(r);
23
+ } catch {
24
+ throw new n(e, "syntax", "the text is not valid JSON; pass the file contents as saved by the editor.");
25
+ }
26
+ if (!i(r)) throw new n(e, "syntax", "expected a JSON object at the top level.");
27
+ return r;
28
+ }
29
+ function d(e, t) {
30
+ if (t?.aborted) throw new n(e, "aborted", "the import was aborted by its signal.");
31
+ }
32
+ //#endregion
33
+ export { s as a, l as c, i, o as l, n, a as o, c as r, u as s, r as t, d as u };
@@ -0,0 +1,29 @@
1
+ import { type PropertyValue, type Properties } from './index.js';
2
+ /** What went wrong in an import: bad text, a missing piece, something this importer does not read, a size limit. */
3
+ export type MapImportErrorCode = 'syntax' | 'truncated' | 'missing' | 'unsupported' | 'limit' | 'aborted';
4
+ /** Thrown by the Tiled and LDtk importers for malformed, truncated, oversized or unsupported input. The message names the fix. */
5
+ export declare class MapImportError extends Error {
6
+ readonly format: string;
7
+ readonly code: MapImportErrorCode;
8
+ constructor(format: string, code: MapImportErrorCode, message: string);
9
+ }
10
+ /** Cells per tile layer (4096 x 4096). */
11
+ export declare const MAX_TILES: number;
12
+ /** A parsed JSON object. */
13
+ export type Obj = {
14
+ readonly [key: string]: unknown;
15
+ };
16
+ export declare const isObj: (v: unknown) => v is Obj;
17
+ export declare const num: (o: Obj, key: string, fallback?: number) => number;
18
+ export declare const str: (o: Obj, key: string) => string | undefined;
19
+ export declare const list: (o: Obj, key: string) => readonly unknown[];
20
+ /** Keep the id bits and the three flip bits; drop Tiled's hex rotation bit unless `hex` (a hexagonal map). */
21
+ export declare const cleanGid: (value: number, hex?: boolean) => number;
22
+ /** Set an own property by name even when the name is `__proto__`. */
23
+ export declare function setOwn<T>(target: {
24
+ [key: string]: T;
25
+ }, key: string, value: T): void;
26
+ /** Parse JSON text, or pass an object through. */
27
+ export declare function parseJson(format: string, input: unknown): Obj;
28
+ export declare function throwIfAborted(format: string, signal?: AbortSignal): void;
29
+ export type { PropertyValue, Properties };