@codexo/exojs-tilemap 0.19.0 → 0.20.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/README.md +7 -163
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +12 -20
- package/dist/esm/ChunkSource.d.ts +0 -33
- package/dist/esm/ChunkSource.d.ts.map +0 -1
- package/dist/esm/ChunkStreamer.d.ts +0 -104
- package/dist/esm/ChunkStreamer.d.ts.map +0 -1
- package/dist/esm/ChunkStreamer.js +0 -229
- package/dist/esm/ChunkStreamer.js.map +0 -1
- package/dist/esm/ImageLayer.d.ts +0 -89
- package/dist/esm/ImageLayer.d.ts.map +0 -1
- package/dist/esm/ImageLayer.js +0 -74
- package/dist/esm/ImageLayer.js.map +0 -1
- package/dist/esm/ImageLayerNode.d.ts +0 -91
- package/dist/esm/ImageLayerNode.d.ts.map +0 -1
- package/dist/esm/ImageLayerNode.js +0 -210
- package/dist/esm/ImageLayerNode.js.map +0 -1
- package/dist/esm/MapObject.d.ts +0 -70
- package/dist/esm/MapObject.d.ts.map +0 -1
- package/dist/esm/MapObject.js +0 -34
- package/dist/esm/MapObject.js.map +0 -1
- package/dist/esm/MapObjectSpawner.d.ts +0 -133
- package/dist/esm/MapObjectSpawner.d.ts.map +0 -1
- package/dist/esm/MapObjectSpawner.js +0 -147
- package/dist/esm/MapObjectSpawner.js.map +0 -1
- package/dist/esm/MapSpawnSession.d.ts +0 -46
- package/dist/esm/MapSpawnSession.d.ts.map +0 -1
- package/dist/esm/MapSpawnSession.js +0 -88
- package/dist/esm/MapSpawnSession.js.map +0 -1
- package/dist/esm/MapWorld.d.ts +0 -134
- package/dist/esm/MapWorld.d.ts.map +0 -1
- package/dist/esm/MapWorld.js +0 -150
- package/dist/esm/MapWorld.js.map +0 -1
- package/dist/esm/MapWorldRuntime.d.ts +0 -180
- package/dist/esm/MapWorldRuntime.d.ts.map +0 -1
- package/dist/esm/MapWorldRuntime.js +0 -261
- package/dist/esm/MapWorldRuntime.js.map +0 -1
- package/dist/esm/ObjectLayer.d.ts +0 -379
- package/dist/esm/ObjectLayer.d.ts.map +0 -1
- package/dist/esm/ObjectLayer.js +0 -221
- package/dist/esm/ObjectLayer.js.map +0 -1
- package/dist/esm/SampledChunkSource.d.ts +0 -43
- package/dist/esm/SampledChunkSource.d.ts.map +0 -1
- package/dist/esm/SampledChunkSource.js +0 -48
- package/dist/esm/SampledChunkSource.js.map +0 -1
- package/dist/esm/TileAnimator.d.ts +0 -72
- package/dist/esm/TileAnimator.d.ts.map +0 -1
- package/dist/esm/TileAnimator.js +0 -158
- package/dist/esm/TileAnimator.js.map +0 -1
- package/dist/esm/TileChunk.d.ts +0 -103
- package/dist/esm/TileChunk.d.ts.map +0 -1
- package/dist/esm/TileChunk.js +0 -194
- package/dist/esm/TileChunk.js.map +0 -1
- package/dist/esm/TileChunkNode.d.ts +0 -2
- package/dist/esm/TileChunkNode.d.ts.map +0 -1
- package/dist/esm/TileChunkNode.js +0 -145
- package/dist/esm/TileChunkNode.js.map +0 -1
- package/dist/esm/TileLayer.d.ts +0 -286
- package/dist/esm/TileLayer.d.ts.map +0 -1
- package/dist/esm/TileLayer.js +0 -526
- package/dist/esm/TileLayer.js.map +0 -1
- package/dist/esm/TileLayerNode.d.ts +0 -129
- package/dist/esm/TileLayerNode.d.ts.map +0 -1
- package/dist/esm/TileLayerNode.js +0 -245
- package/dist/esm/TileLayerNode.js.map +0 -1
- package/dist/esm/TileMap.d.ts +0 -317
- package/dist/esm/TileMap.d.ts.map +0 -1
- package/dist/esm/TileMap.js +0 -406
- package/dist/esm/TileMap.js.map +0 -1
- package/dist/esm/TileMapBand.d.ts +0 -80
- package/dist/esm/TileMapBand.d.ts.map +0 -1
- package/dist/esm/TileMapBand.js +0 -155
- package/dist/esm/TileMapBand.js.map +0 -1
- package/dist/esm/TileMapNode.d.ts +0 -92
- package/dist/esm/TileMapNode.d.ts.map +0 -1
- package/dist/esm/TileMapNode.js +0 -134
- package/dist/esm/TileMapNode.js.map +0 -1
- package/dist/esm/TileMapView.d.ts +0 -248
- package/dist/esm/TileMapView.d.ts.map +0 -1
- package/dist/esm/TileMapView.js +0 -394
- package/dist/esm/TileMapView.js.map +0 -1
- package/dist/esm/TileProjection.d.ts +0 -59
- package/dist/esm/TileProjection.d.ts.map +0 -1
- package/dist/esm/TileProjection.js +0 -106
- package/dist/esm/TileProjection.js.map +0 -1
- package/dist/esm/TileSet.d.ts +0 -116
- package/dist/esm/TileSet.d.ts.map +0 -1
- package/dist/esm/TileSet.js +0 -168
- package/dist/esm/TileSet.js.map +0 -1
- package/dist/esm/WangSet.d.ts +0 -80
- package/dist/esm/WangSet.d.ts.map +0 -1
- package/dist/esm/WangSet.js +0 -73
- package/dist/esm/WangSet.js.map +0 -1
- package/dist/esm/WorkerSampledChunkSource.d.ts +0 -94
- package/dist/esm/WorkerSampledChunkSource.d.ts.map +0 -1
- package/dist/esm/WorkerSampledChunkSource.js +0 -113
- package/dist/esm/WorkerSampledChunkSource.js.map +0 -1
- package/dist/esm/autoTile.d.ts +0 -88
- package/dist/esm/autoTile.d.ts.map +0 -1
- package/dist/esm/autoTile.js +0 -173
- package/dist/esm/autoTile.js.map +0 -1
- package/dist/esm/chunkGeometry.d.ts +0 -2
- package/dist/esm/chunkGeometry.d.ts.map +0 -1
- package/dist/esm/chunkGeometry.js +0 -116
- package/dist/esm/chunkGeometry.js.map +0 -1
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -27
- package/dist/esm/nodeBounds.d.ts +0 -2
- package/dist/esm/nodeBounds.d.ts.map +0 -1
- package/dist/esm/nodeBounds.js +0 -40
- package/dist/esm/nodeBounds.js.map +0 -1
- package/dist/esm/pixelSnap.d.ts +0 -2
- package/dist/esm/pixelSnap.d.ts.map +0 -1
- package/dist/esm/pixelSnap.js +0 -21
- package/dist/esm/pixelSnap.js.map +0 -1
- package/dist/esm/projectObject.d.ts +0 -4
- package/dist/esm/projectObject.d.ts.map +0 -1
- package/dist/esm/projectObject.js +0 -87
- package/dist/esm/projectObject.js.map +0 -1
- package/dist/esm/public.d.ts +0 -48
- package/dist/esm/public.d.ts.map +0 -1
- package/dist/esm/tileCollision.d.ts +0 -190
- package/dist/esm/tileCollision.d.ts.map +0 -1
- package/dist/esm/tileCollision.js +0 -399
- package/dist/esm/tileCollision.js.map +0 -1
- package/dist/esm/tileWord.d.ts +0 -2
- package/dist/esm/tileWord.d.ts.map +0 -1
- package/dist/esm/tileWord.js +0 -16
- package/dist/esm/tileWord.js.map +0 -1
- package/dist/esm/tilemapExtension.d.ts +0 -20
- package/dist/esm/tilemapExtension.d.ts.map +0 -1
- package/dist/esm/tilemapExtension.js +0 -53
- package/dist/esm/tilemapExtension.js.map +0 -1
- package/dist/esm/tilemapSerializers.d.ts +0 -2
- package/dist/esm/tilemapSerializers.d.ts.map +0 -1
- package/dist/esm/tilemapSerializers.js +0 -54
- package/dist/esm/tilemapSerializers.js.map +0 -1
- package/dist/esm/types.d.ts +0 -231
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -129
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts +0 -2
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.d.ts.map +0 -1
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js +0 -376
- package/dist/esm/webgl2/WebGl2TileChunkRenderer.js.map +0 -1
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js +0 -6
- package/dist/esm/webgl2/shaders/tile-chunk.frag.js.map +0 -1
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js +0 -6
- package/dist/esm/webgl2/shaders/tile-chunk.vert.js.map +0 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts +0 -2
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.d.ts.map +0 -1
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js +0 -539
- package/dist/esm/webgpu/WebGpuTileChunkRenderer.js.map +0 -1
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js +0 -6
- package/dist/esm/webgpu/shaders/tile-chunk.wgsl.js.map +0 -1
package/dist/esm/nodeBounds.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Rectangle } from "@codexo/exojs";
|
|
2
|
-
|
|
3
|
-
//#region src/nodeBounds.ts
|
|
4
|
-
/**
|
|
5
|
-
* Grow `out` to the union of `children`'s local bounds, each transformed by
|
|
6
|
-
* the child's own (translation-only, in practice) local transform - i.e. the
|
|
7
|
-
* children's combined extent expressed in the *parent's* local coordinate
|
|
8
|
-
* space, not the parent's own position/scale/rotation.
|
|
9
|
-
*
|
|
10
|
-
* Used as the unbounded-layer/-map fallback for `getLocalBounds()`: `Container`
|
|
11
|
-
* does not aggregate children into its own local bounds automatically (only
|
|
12
|
-
* `getBounds()` - global - does that), so nodes that want a children-derived
|
|
13
|
-
* local rect must compute it explicitly. Mirrors `Container.updateBounds()`'s
|
|
14
|
-
* own aggregation semantics, including skipping invisible children. Callers
|
|
15
|
-
* are expected to only invoke this when `children.length > 0`; `out` is left
|
|
16
|
-
* untouched otherwise (also guarded internally in case a future call site
|
|
17
|
-
* forgets to check).
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
const aggregateChildLocalBounds = (children, out) => {
|
|
21
|
-
if (children.length === 0) return;
|
|
22
|
-
let minX = Infinity;
|
|
23
|
-
let minY = Infinity;
|
|
24
|
-
let maxX = -Infinity;
|
|
25
|
-
let maxY = -Infinity;
|
|
26
|
-
for (const child of children) {
|
|
27
|
-
if (!child.visible) continue;
|
|
28
|
-
const rect = child.getLocalBounds().transform(child.getTransform(), Rectangle.temp);
|
|
29
|
-
minX = Math.min(minX, rect.left);
|
|
30
|
-
minY = Math.min(minY, rect.top);
|
|
31
|
-
maxX = Math.max(maxX, rect.right);
|
|
32
|
-
maxY = Math.max(maxY, rect.bottom);
|
|
33
|
-
}
|
|
34
|
-
if (minX === Infinity) return;
|
|
35
|
-
out.set(minX, minY, maxX - minX, maxY - minY);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
export { aggregateChildLocalBounds };
|
|
40
|
-
//# sourceMappingURL=nodeBounds.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nodeBounds.js","names":[],"sources":["../../src/nodeBounds.ts"],"sourcesContent":["import type { SceneNode } from '@codexo/exojs';\nimport { Rectangle } from '@codexo/exojs';\n\n/**\n * Grow `out` to the union of `children`'s local bounds, each transformed by\n * the child's own (translation-only, in practice) local transform - i.e. the\n * children's combined extent expressed in the *parent's* local coordinate\n * space, not the parent's own position/scale/rotation.\n *\n * Used as the unbounded-layer/-map fallback for `getLocalBounds()`: `Container`\n * does not aggregate children into its own local bounds automatically (only\n * `getBounds()` - global - does that), so nodes that want a children-derived\n * local rect must compute it explicitly. Mirrors `Container.updateBounds()`'s\n * own aggregation semantics, including skipping invisible children. Callers\n * are expected to only invoke this when `children.length > 0`; `out` is left\n * untouched otherwise (also guarded internally in case a future call site\n * forgets to check).\n * @internal\n */\nexport const aggregateChildLocalBounds = (children: readonly SceneNode[], out: Rectangle): void => {\n if (children.length === 0) {\n return;\n }\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const child of children) {\n if (!child.visible) {\n continue;\n }\n\n const rect = child.getLocalBounds().transform(child.getTransform(), Rectangle.temp);\n\n minX = Math.min(minX, rect.left);\n minY = Math.min(minY, rect.top);\n maxX = Math.max(maxX, rect.right);\n maxY = Math.max(maxY, rect.bottom);\n }\n\n if (minX === Infinity) {\n // Every child was invisible; nothing to aggregate.\n return;\n }\n\n out.set(minX, minY, maxX - minX, maxY - minY);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAa,6BAA6B,UAAgC,QAAyB;CACjG,IAAI,SAAS,WAAW,GACtB;CAGF,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,OAAO;CACX,IAAI,OAAO;CAEX,KAAK,MAAM,SAAS,UAAU;EAC5B,IAAI,CAAC,MAAM,SACT;EAGF,MAAM,OAAO,MAAM,eAAe,CAAC,CAAC,UAAU,MAAM,aAAa,GAAG,UAAU,IAAI;EAElF,OAAO,KAAK,IAAI,MAAM,KAAK,IAAI;EAC/B,OAAO,KAAK,IAAI,MAAM,KAAK,GAAG;EAC9B,OAAO,KAAK,IAAI,MAAM,KAAK,KAAK;EAChC,OAAO,KAAK,IAAI,MAAM,KAAK,MAAM;CACnC;CAEA,IAAI,SAAS,UAEX;CAGF,IAAI,IAAI,MAAM,MAAM,OAAO,MAAM,OAAO,IAAI;AAC9C"}
|
package/dist/esm/pixelSnap.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pixelSnap.d.ts","sourceRoot":"","sources":["../../src/pixelSnap.ts"],"names":[],"mappings":""}
|
package/dist/esm/pixelSnap.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { PixelSnapMode } from "@codexo/exojs/renderer-sdk";
|
|
2
|
-
|
|
3
|
-
//#region src/pixelSnap.ts
|
|
4
|
-
/**
|
|
5
|
-
* Throw a deterministic error when `mode` is not a valid {@link PixelSnapMode}.
|
|
6
|
-
*
|
|
7
|
-
* Mirrors the core `Drawable` setter's guard so the tilemap node passthroughs
|
|
8
|
-
* (`TileMapView` / `TileMapNode` / `TileLayerNode`) reject JavaScript-invalid
|
|
9
|
-
* values atomically - even for an empty layer that has no chunk drawable to
|
|
10
|
-
* delegate the validation to. Kept local because the core guard is not part of
|
|
11
|
-
* the public API surface.
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
const assertPixelSnapMode = (mode) => {
|
|
15
|
-
const value = mode;
|
|
16
|
-
if (value !== PixelSnapMode.None && value !== PixelSnapMode.Position && value !== PixelSnapMode.Geometry) throw new Error(`pixelSnapMode must be a PixelSnapMode enum value (got ${String(mode)}).`);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { assertPixelSnapMode };
|
|
21
|
-
//# sourceMappingURL=pixelSnap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pixelSnap.js","names":[],"sources":["../../src/pixelSnap.ts"],"sourcesContent":["import { PixelSnapMode } from '@codexo/exojs/renderer-sdk';\n\n/**\n * Throw a deterministic error when `mode` is not a valid {@link PixelSnapMode}.\n *\n * Mirrors the core `Drawable` setter's guard so the tilemap node passthroughs\n * (`TileMapView` / `TileMapNode` / `TileLayerNode`) reject JavaScript-invalid\n * values atomically - even for an empty layer that has no chunk drawable to\n * delegate the validation to. Kept local because the core guard is not part of\n * the public API surface.\n * @internal\n */\nexport const assertPixelSnapMode = (mode: PixelSnapMode): void => {\n // Widen first: the parameter type would otherwise narrow the third\n // comparison to a statically-false branch, but JavaScript callers can pass\n // anything.\n const value: unknown = mode;\n\n if (value !== PixelSnapMode.None && value !== PixelSnapMode.Position && value !== PixelSnapMode.Geometry) {\n throw new Error(`pixelSnapMode must be a PixelSnapMode enum value (got ${String(mode)}).`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,uBAAuB,SAA8B;CAIhE,MAAM,QAAiB;CAEvB,IAAI,UAAU,cAAc,QAAQ,UAAU,cAAc,YAAY,UAAU,cAAc,UAC9F,MAAM,IAAI,MAAM,yDAAyD,OAAO,IAAI,EAAE,GAAG;AAE7F"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TileMapObject } from './ObjectLayer';
|
|
2
|
-
/** Affine object geometry mapping; tile images and text keep their display dimensions. */
|
|
3
|
-
export declare const projectObject: (object: TileMapObject, a: number, b: number, c: number, d: number, offsetX: number, offsetY: number) => TileMapObject;
|
|
4
|
-
//# sourceMappingURL=projectObject.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projectObject.d.ts","sourceRoot":"","sources":["../../src/projectObject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,0FAA0F;AAC1F,eAAO,MAAM,aAAa,WAAY,aAAa,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,WAAW,MAAM,WAAW,MAAM,KAAG,aAmDnI,CAAC"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
//#region src/projectObject.ts
|
|
2
|
-
/** Affine object geometry mapping; tile images and text keep their display dimensions. */
|
|
3
|
-
const projectObject = (object, a, b, c, d, offsetX, offsetY) => {
|
|
4
|
-
const x = a * object.x + c * object.y + offsetX;
|
|
5
|
-
const y = b * object.x + d * object.y + offsetY;
|
|
6
|
-
const base = {
|
|
7
|
-
...object,
|
|
8
|
-
x,
|
|
9
|
-
y
|
|
10
|
-
};
|
|
11
|
-
if (object.kind === "tile" && object.rotationOrigin) {
|
|
12
|
-
const pivot = object.rotationOrigin;
|
|
13
|
-
return {
|
|
14
|
-
...object,
|
|
15
|
-
x,
|
|
16
|
-
y,
|
|
17
|
-
rotationOrigin: {
|
|
18
|
-
x: a * pivot.x + c * pivot.y + offsetX,
|
|
19
|
-
y: b * pivot.x + d * pivot.y + offsetY
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
if (object.kind === "point" || object.kind === "tile" || object.kind === "text") return base;
|
|
24
|
-
const angle = object.rotation * Math.PI / 180;
|
|
25
|
-
const cos = Math.cos(angle);
|
|
26
|
-
const sin = Math.sin(angle);
|
|
27
|
-
const ax = a * cos + c * sin;
|
|
28
|
-
const ay = b * cos + d * sin;
|
|
29
|
-
const bx = c * cos - a * sin;
|
|
30
|
-
const by = d * cos - b * sin;
|
|
31
|
-
if (object.kind === "ellipse") {
|
|
32
|
-
const rx = object.width / 2;
|
|
33
|
-
const ry = object.height / 2;
|
|
34
|
-
const xx = (ax * rx) ** 2 + (bx * ry) ** 2;
|
|
35
|
-
const yy = (ay * rx) ** 2 + (by * ry) ** 2;
|
|
36
|
-
const xy = ax * ay * rx * rx + bx * by * ry * ry;
|
|
37
|
-
const spread = Math.hypot(xx - yy, 2 * xy);
|
|
38
|
-
const major = Math.sqrt(Math.max(0, (xx + yy + spread) / 2));
|
|
39
|
-
const minor = Math.sqrt(Math.max(0, (xx + yy - spread) / 2));
|
|
40
|
-
const rotation = Math.atan2(2 * xy, xx - yy) / 2;
|
|
41
|
-
const u = Math.cos(rotation);
|
|
42
|
-
const v = Math.sin(rotation);
|
|
43
|
-
return {
|
|
44
|
-
...base,
|
|
45
|
-
kind: "ellipse",
|
|
46
|
-
x: x + ax * rx + bx * ry - u * major + v * minor,
|
|
47
|
-
y: y + ay * rx + by * ry - v * major - u * minor,
|
|
48
|
-
width: major * 2,
|
|
49
|
-
height: minor * 2,
|
|
50
|
-
rotation: rotation * 180 / Math.PI
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
const points = (object.kind === "rectangle" ? [
|
|
54
|
-
{
|
|
55
|
-
x: 0,
|
|
56
|
-
y: 0
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
x: object.width,
|
|
60
|
-
y: 0
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
x: object.width,
|
|
64
|
-
y: object.height
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
x: 0,
|
|
68
|
-
y: object.height
|
|
69
|
-
}
|
|
70
|
-
] : object.points).map((point) => ({
|
|
71
|
-
x: ax * point.x + bx * point.y,
|
|
72
|
-
y: ay * point.x + by * point.y
|
|
73
|
-
}));
|
|
74
|
-
if (a * d - b * c < 0) points.reverse();
|
|
75
|
-
return {
|
|
76
|
-
...base,
|
|
77
|
-
kind: object.kind === "polyline" ? "polyline" : "polygon",
|
|
78
|
-
width: 0,
|
|
79
|
-
height: 0,
|
|
80
|
-
rotation: 0,
|
|
81
|
-
points
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
//#endregion
|
|
86
|
-
export { projectObject };
|
|
87
|
-
//# sourceMappingURL=projectObject.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projectObject.js","names":[],"sources":["../../src/projectObject.ts"],"sourcesContent":["import type { TileMapObject } from './ObjectLayer';\n\n/** Affine object geometry mapping; tile images and text keep their display dimensions. */\nexport const projectObject = (object: TileMapObject, a: number, b: number, c: number, d: number, offsetX: number, offsetY: number): TileMapObject => {\n const x = a * object.x + c * object.y + offsetX;\n const y = b * object.x + d * object.y + offsetY;\n const base = { ...object, x, y };\n if (object.kind === 'tile' && object.rotationOrigin) {\n const pivot = object.rotationOrigin;\n return { ...object, x, y, rotationOrigin: { x: a * pivot.x + c * pivot.y + offsetX, y: b * pivot.x + d * pivot.y + offsetY } };\n }\n if (object.kind === 'point' || object.kind === 'tile' || object.kind === 'text') return base;\n\n const angle = (object.rotation * Math.PI) / 180;\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const ax = a * cos + c * sin;\n const ay = b * cos + d * sin;\n const bx = c * cos - a * sin;\n const by = d * cos - b * sin;\n if (object.kind === 'ellipse') {\n const rx = object.width / 2;\n const ry = object.height / 2;\n const xx = (ax * rx) ** 2 + (bx * ry) ** 2;\n const yy = (ay * rx) ** 2 + (by * ry) ** 2;\n const xy = ax * ay * rx * rx + bx * by * ry * ry;\n const spread = Math.hypot(xx - yy, 2 * xy);\n const major = Math.sqrt(Math.max(0, (xx + yy + spread) / 2));\n const minor = Math.sqrt(Math.max(0, (xx + yy - spread) / 2));\n const rotation = Math.atan2(2 * xy, xx - yy) / 2;\n const u = Math.cos(rotation);\n const v = Math.sin(rotation);\n return {\n ...base,\n kind: 'ellipse',\n x: x + ax * rx + bx * ry - u * major + v * minor,\n y: y + ay * rx + by * ry - v * major - u * minor,\n width: major * 2,\n height: minor * 2,\n rotation: (rotation * 180) / Math.PI,\n };\n }\n const source =\n object.kind === 'rectangle'\n ? [\n { x: 0, y: 0 },\n { x: object.width, y: 0 },\n { x: object.width, y: object.height },\n { x: 0, y: object.height },\n ]\n : object.points;\n const points = source.map(point => ({ x: ax * point.x + bx * point.y, y: ay * point.x + by * point.y }));\n if (a * d - b * c < 0) points.reverse();\n return { ...base, kind: object.kind === 'polyline' ? 'polyline' : 'polygon', width: 0, height: 0, rotation: 0, points };\n};\n"],"mappings":";;AAGA,MAAa,iBAAiB,QAAuB,GAAW,GAAW,GAAW,GAAW,SAAiB,YAAmC;CACnJ,MAAM,IAAI,IAAI,OAAO,IAAI,IAAI,OAAO,IAAI;CACxC,MAAM,IAAI,IAAI,OAAO,IAAI,IAAI,OAAO,IAAI;CACxC,MAAM,OAAO;EAAE,GAAG;EAAQ;EAAG;CAAE;CAC/B,IAAI,OAAO,SAAS,UAAU,OAAO,gBAAgB;EACnD,MAAM,QAAQ,OAAO;EACrB,OAAO;GAAE,GAAG;GAAQ;GAAG;GAAG,gBAAgB;IAAE,GAAG,IAAI,MAAM,IAAI,IAAI,MAAM,IAAI;IAAS,GAAG,IAAI,MAAM,IAAI,IAAI,MAAM,IAAI;GAAQ;EAAE;CAC/H;CACA,IAAI,OAAO,SAAS,WAAW,OAAO,SAAS,UAAU,OAAO,SAAS,QAAQ,OAAO;CAExF,MAAM,QAAS,OAAO,WAAW,KAAK,KAAM;CAC5C,MAAM,MAAM,KAAK,IAAI,KAAK;CAC1B,MAAM,MAAM,KAAK,IAAI,KAAK;CAC1B,MAAM,KAAK,IAAI,MAAM,IAAI;CACzB,MAAM,KAAK,IAAI,MAAM,IAAI;CACzB,MAAM,KAAK,IAAI,MAAM,IAAI;CACzB,MAAM,KAAK,IAAI,MAAM,IAAI;CACzB,IAAI,OAAO,SAAS,WAAW;EAC7B,MAAM,KAAK,OAAO,QAAQ;EAC1B,MAAM,KAAK,OAAO,SAAS;EAC3B,MAAM,MAAM,KAAK,OAAO,KAAK,KAAK,OAAO;EACzC,MAAM,MAAM,KAAK,OAAO,KAAK,KAAK,OAAO;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ilemapExtension } from './tilemapExtension';
|
|
2
|
-
export type { Extension } from '@codexo/exojs/extensions';
|
|
3
|
-
export type { ChunkPayload, ChunkSource } from './ChunkSource';
|
|
4
|
-
export type { ImageLayerOptions } from './ImageLayer';
|
|
5
|
-
export { ImageLayer } from './ImageLayer';
|
|
6
|
-
export type { EllipseObject, ObjectLayerOptions, ObjectPoint, ObjectQuery, ObjectSchema, PointObject, PolygonObject, PolylineObject, RectangleObject, TextObject, TextStyle, TileMapObject, TileMapObjectKind, TileObject, TypedObject, } from './ObjectLayer';
|
|
7
|
-
export { ObjectKind, ObjectLayer } from './ObjectLayer';
|
|
8
|
-
export type { MapBounds, MapLevel, MapLevelNeighbour, MapWorldOptions } from './MapWorld';
|
|
9
|
-
export { MapLevelSide, MapWorld } from './MapWorld';
|
|
10
|
-
export type { MapLevelCancelOptions, MapLevelLoadContext, MapLevelLoadOptions, MapLevelProvider, MapWorldRuntimeOptions } from './MapWorldRuntime';
|
|
11
|
-
export { MapLevelRuntime, MapWorldRuntime } from './MapWorldRuntime';
|
|
12
|
-
export type { MapObjectDescriptor } from './MapObject';
|
|
13
|
-
export { mapObjectDescriptor, mapObjectDescriptors } from './MapObject';
|
|
14
|
-
export type { MapObjectFactories, MapObjectFactory, MapObjectSpawnerOptions, MapSpawnErrorReason, MapSpawnOptions, UnknownMapObjectPolicy, } from './MapObjectSpawner';
|
|
15
|
-
export { MapObjectSpawner, MapSpawnError } from './MapObjectSpawner';
|
|
16
|
-
export { MapSpawnSession } from './MapSpawnSession';
|
|
17
|
-
export type { ReadonlyTileChunk } from './TileChunk';
|
|
18
|
-
export type { ChunkRange, TileLayerOptions } from './TileLayer';
|
|
19
|
-
export { TileLayer } from './TileLayer';
|
|
20
|
-
export type { TileMapOptions } from './TileMap';
|
|
21
|
-
export { TileMap } from './TileMap';
|
|
22
|
-
export type { TileSetOptions } from './TileSet';
|
|
23
|
-
export { TileSet } from './TileSet';
|
|
24
|
-
export { ImageLayerNode } from './ImageLayerNode';
|
|
25
|
-
export type { TileLayerNodeOptions } from './TileLayerNode';
|
|
26
|
-
export { TileLayerNode } from './TileLayerNode';
|
|
27
|
-
export type { TileMapNodeOptions } from './TileMapNode';
|
|
28
|
-
export { TileMapNode } from './TileMapNode';
|
|
29
|
-
export { TileMapBand } from './TileMapBand';
|
|
30
|
-
export type { TileLayerSelector, TileMapBandDefinition, TileMapViewOptions } from './TileMapView';
|
|
31
|
-
export { TileMapView } from './TileMapView';
|
|
32
|
-
export type { ChunkCoord, PackedTile, ResolvedTile, TileAnimationFrame, TileDefinition, TileProperties, TilePropertyObjectRef, TilePropertyPoint, TilePropertyTileRef, TilePropertyValue, TileTransform, } from './types';
|
|
33
|
-
export { packTile, TILE_TRANSFORM_IDENTITY, TilePropertyKind, tileToChunkCoord, tileToLocalInChunk, unpackTile } from './types';
|
|
34
|
-
export { TileAnimator } from './TileAnimator';
|
|
35
|
-
export type { TileCellSource, TileCollisionGeometry, TileCollisionOptions, TileCollisionRect, TileCollisionShape, TileCollisionShapeKind, TileRegion, } from './tileCollision';
|
|
36
|
-
export { buildTileCollisionGeometry } from './tileCollision';
|
|
37
|
-
export type { ChunkStreamerOptions } from './ChunkStreamer';
|
|
38
|
-
export { ChunkStreamer } from './ChunkStreamer';
|
|
39
|
-
export type { SampledChunkSourceOptions } from './SampledChunkSource';
|
|
40
|
-
export { createSampledChunkSource } from './SampledChunkSource';
|
|
41
|
-
export type { WorkerSampledChunkSourceOptions } from './WorkerSampledChunkSource';
|
|
42
|
-
export { createWorkerSampledChunkSource } from './WorkerSampledChunkSource';
|
|
43
|
-
export type { AutoTileOptions } from './autoTile';
|
|
44
|
-
export { autoTile, refreshCell } from './autoTile';
|
|
45
|
-
export { TileProjection, type TileProjectionOptions } from './TileProjection';
|
|
46
|
-
export type { WangSetOptions } from './WangSet';
|
|
47
|
-
export { WangSet } from './WangSet';
|
|
48
|
-
//# sourceMappingURL=public.d.ts.map
|
package/dist/esm/public.d.ts.map
DELETED
|
@@ -1 +0,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EACrB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAE7D,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,YAAY,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,YAAY,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAClF,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAE5E,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import type { ObjectPoint, TileMapObject } from './ObjectLayer';
|
|
2
|
-
import { ObjectKind } from './ObjectLayer';
|
|
3
|
-
import type { TileLayer } from './TileLayer';
|
|
4
|
-
/**
|
|
5
|
-
* The geometry kinds a {@link TileCollisionShape} can carry. Tile (GID) and
|
|
6
|
-
* text objects describe no collision area and are never emitted, so they are
|
|
7
|
-
* excluded from the union.
|
|
8
|
-
* @advanced
|
|
9
|
-
*/
|
|
10
|
-
export type TileCollisionShapeKind = typeof ObjectKind.Rectangle | typeof ObjectKind.Ellipse | typeof ObjectKind.Polygon | typeof ObjectKind.Polyline | typeof ObjectKind.Point;
|
|
11
|
-
/**
|
|
12
|
-
* A half-open tile-coordinate rectangle covering
|
|
13
|
-
* `[x, x + width)` × `[y, y + height)`.
|
|
14
|
-
*
|
|
15
|
-
* Used to scope {@link buildTileCollisionGeometry} to part of a layer - a
|
|
16
|
-
* streamed chunk, the tiles around the player, a hand-picked room - instead of
|
|
17
|
-
* always rebuilding the whole map.
|
|
18
|
-
* @advanced
|
|
19
|
-
*/
|
|
20
|
-
export interface TileRegion {
|
|
21
|
-
/** Leftmost tile column (inclusive). */
|
|
22
|
-
readonly x: number;
|
|
23
|
-
/** Topmost tile row (inclusive). */
|
|
24
|
-
readonly y: number;
|
|
25
|
-
/** Width in tiles. */
|
|
26
|
-
readonly width: number;
|
|
27
|
-
/** Height in tiles. */
|
|
28
|
-
readonly height: number;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* An axis-aligned collision rectangle in logical tile-layer pixel space (+Y down),
|
|
32
|
-
* covering one or more whole tile cells.
|
|
33
|
-
*
|
|
34
|
-
* Rectangles are synthesized geometry, not source objects: a merged run has no
|
|
35
|
-
* single originating object, so it carries no object `id`/`name`/`properties` -
|
|
36
|
-
* only the `type` string shared by every shape merged into it. Anything that
|
|
37
|
-
* does not exactly cover whole cells stays a {@link TileCollisionShape}, which
|
|
38
|
-
* does keep its source object.
|
|
39
|
-
* @advanced
|
|
40
|
-
*/
|
|
41
|
-
export interface TileCollisionRect {
|
|
42
|
-
/** Left edge in layer pixel space. */
|
|
43
|
-
readonly x: number;
|
|
44
|
-
/** Top edge in layer pixel space. */
|
|
45
|
-
readonly y: number;
|
|
46
|
-
/** Width in pixels (a whole number of tile cells). */
|
|
47
|
-
readonly width: number;
|
|
48
|
-
/** Height in pixels (a whole number of tile cells). */
|
|
49
|
-
readonly height: number;
|
|
50
|
-
/** Class/type string shared by every source shape merged into this rectangle. */
|
|
51
|
-
readonly type: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* A per-tile collision shape placed in logical tile-layer pixel space (+Y down).
|
|
55
|
-
*
|
|
56
|
-
* Emitted for every collision shape that does not exactly cover a whole tile
|
|
57
|
-
* cell: partial boxes, ellipses, polygons, polylines, points, and rotated
|
|
58
|
-
* geometry. Shapes are never merged with one another.
|
|
59
|
-
* @advanced
|
|
60
|
-
*/
|
|
61
|
-
export interface TileCollisionShape {
|
|
62
|
-
/** Geometry discriminant. */
|
|
63
|
-
readonly kind: TileCollisionShapeKind;
|
|
64
|
-
/** X of the shape origin in layer pixel space. */
|
|
65
|
-
readonly x: number;
|
|
66
|
-
/** Y of the shape origin in layer pixel space. */
|
|
67
|
-
readonly y: number;
|
|
68
|
-
/** Bounding width in px (`0` for polygons, polylines and points). */
|
|
69
|
-
readonly width: number;
|
|
70
|
-
/** Bounding height in px (`0` for polygons, polylines and points). */
|
|
71
|
-
readonly height: number;
|
|
72
|
-
/**
|
|
73
|
-
* Rotation in degrees, clockwise, about `(x, y)`, normalised to `[0, 360)`.
|
|
74
|
-
* Always `0` for polygons and polylines - their rotation is baked into
|
|
75
|
-
* {@link points}.
|
|
76
|
-
*/
|
|
77
|
-
readonly rotation: number;
|
|
78
|
-
/** Polygon/polyline vertices relative to `(x, y)`; absent for other kinds. */
|
|
79
|
-
readonly points?: readonly ObjectPoint[];
|
|
80
|
-
/** Tile column the shape came from. */
|
|
81
|
-
readonly tx: number;
|
|
82
|
-
/** Tile row the shape came from. */
|
|
83
|
-
readonly ty: number;
|
|
84
|
-
/** The tile-local source object, for `name`/`type`/`properties` lookups. */
|
|
85
|
-
readonly source: TileMapObject;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Collision geometry extracted from a tile layer: whole-cell boxes merged into
|
|
89
|
-
* as few {@link TileCollisionRect}s as a greedy pass can manage, plus every
|
|
90
|
-
* other shape passed through individually.
|
|
91
|
-
* @advanced
|
|
92
|
-
*/
|
|
93
|
-
export interface TileCollisionGeometry {
|
|
94
|
-
/** Merged whole-cell rectangles, in row-major order. */
|
|
95
|
-
readonly rects: readonly TileCollisionRect[];
|
|
96
|
-
/** Non-whole-cell shapes, in the order their tiles were walked. */
|
|
97
|
-
readonly shapes: readonly TileCollisionShape[];
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Per-cell collision classification for a tile layer, independent of the tiles
|
|
101
|
-
* the layer renders.
|
|
102
|
-
*
|
|
103
|
-
* Returns the class/type string for the cell, or `null` when the cell carries
|
|
104
|
-
* no collision. The string is opaque: it is the merge key for adjacent cells
|
|
105
|
-
* and reaches the consumer unchanged, exactly like the `type` of a tile
|
|
106
|
-
* collision object.
|
|
107
|
-
*
|
|
108
|
-
* A source is sampled while geometry is being built and is expected to answer
|
|
109
|
-
* identically for as long as the geometry is used. Changing what it returns
|
|
110
|
-
* does not invalidate geometry that was already built; rebuild instead.
|
|
111
|
-
* @advanced
|
|
112
|
-
*/
|
|
113
|
-
export type TileCellSource = (tx: number, ty: number) => string | null;
|
|
114
|
-
/**
|
|
115
|
-
* Options for {@link buildTileCollisionGeometry}.
|
|
116
|
-
* @advanced
|
|
117
|
-
*/
|
|
118
|
-
export interface TileCollisionOptions {
|
|
119
|
-
/**
|
|
120
|
-
* Tile-coordinate region to walk. Defaults to the bounding box of the
|
|
121
|
-
* layer's currently loaded chunks, so an unbounded (streamed) layer works
|
|
122
|
-
* without the caller computing anything - or, with {@link cells} on a
|
|
123
|
-
* bounded layer, to the layer's full tile extent.
|
|
124
|
-
*/
|
|
125
|
-
readonly region?: TileRegion;
|
|
126
|
-
/**
|
|
127
|
-
* Second occupancy source, consulted once per cell of the walked region in
|
|
128
|
-
* addition to the tiles' own collision shapes. Lets collision authored per
|
|
129
|
-
* cell rather than per tile reach the same geometry, without the layer
|
|
130
|
-
* having to render a tile there.
|
|
131
|
-
*/
|
|
132
|
-
readonly cells?: TileCellSource | undefined;
|
|
133
|
-
/**
|
|
134
|
-
* Merge adjacent whole-cell boxes that share a `type` into larger
|
|
135
|
-
* rectangles. Default `true`. With `false`, every whole-cell box becomes its
|
|
136
|
-
* own single-cell rectangle.
|
|
137
|
-
*/
|
|
138
|
-
readonly merge?: boolean;
|
|
139
|
-
/**
|
|
140
|
-
* Drop source shapes before any geometry is built (e.g. by a custom
|
|
141
|
-
* property). Return `true` to keep a shape. Default keeps all of them.
|
|
142
|
-
*/
|
|
143
|
-
readonly accept?: (object: TileMapObject, tx: number, ty: number) => boolean;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Extract collision geometry from a tile layer's per-tile
|
|
147
|
-
* {@link import('./types').TileDefinition.collision} shapes.
|
|
148
|
-
*
|
|
149
|
-
* Every placed tile in `region` is resolved back to its tileset definition, and
|
|
150
|
-
* each collision shape is transformed from tile-local pixel space into layer
|
|
151
|
-
* pixel space (+Y down) - applying the tile's flip/rotation transform, the
|
|
152
|
-
* tileset draw offset, and the layer's pixel offset, so the geometry lands
|
|
153
|
-
* exactly where the tile is drawn.
|
|
154
|
-
*
|
|
155
|
-
* Shapes that end up covering exactly one whole tile cell are collected into an
|
|
156
|
-
* occupancy grid and merged into as few {@link TileCollisionRect}s as a greedy
|
|
157
|
-
* pass manages - a 200×200 solid region becomes one rectangle instead of 40 000.
|
|
158
|
-
* Cells only merge with neighbours whose source object carries the same `type`
|
|
159
|
-
* string, so a `water` run never fuses into an adjacent `solid` run. Everything
|
|
160
|
-
* else (partial boxes, ellipses, polygons, polylines, points, rotated geometry)
|
|
161
|
-
* passes through individually as a {@link TileCollisionShape}.
|
|
162
|
-
*
|
|
163
|
-
* A {@link TileCollisionOptions.cells} source feeds the same occupancy grid
|
|
164
|
-
* from outside the tiles, for collision authored per cell rather than per tile.
|
|
165
|
-
* It is consulted first, so a whole-cell tile box landing on a cell the source
|
|
166
|
-
* already claimed passes through as a shape rather than overwriting it. With a
|
|
167
|
-
* cell source and no explicit region, a bounded layer walks its full tile
|
|
168
|
-
* extent - a layer that renders nothing at all still produces geometry.
|
|
169
|
-
*
|
|
170
|
-
* This package has no physics dependency and builds no bodies: the result is
|
|
171
|
-
* plain geometry. Turning it into colliders is a short loop in application code.
|
|
172
|
-
*
|
|
173
|
-
* @param layer - The layer to walk.
|
|
174
|
-
* @param options - Region scoping, merge toggle, a source-shape filter, and an
|
|
175
|
-
* optional per-cell occupancy source.
|
|
176
|
-
* @returns Merged rectangles plus pass-through shapes; both empty when the
|
|
177
|
-
* region holds no tile carrying collision data.
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```ts
|
|
181
|
-
* const { rects, shapes } = buildTileCollisionGeometry(layer);
|
|
182
|
-
*
|
|
183
|
-
* for (const rect of rects) {
|
|
184
|
-
* world.add(makeStaticBox(rect.x, rect.y, rect.width, rect.height));
|
|
185
|
-
* }
|
|
186
|
-
* ```
|
|
187
|
-
* @advanced
|
|
188
|
-
*/
|
|
189
|
-
export declare const buildTileCollisionGeometry: (layer: TileLayer, options?: TileCollisionOptions) => TileCollisionGeometry;
|
|
190
|
-
//# sourceMappingURL=tileCollision.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tileCollision.d.ts","sourceRoot":"","sources":["../../src/tileCollision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAChC,OAAO,UAAU,CAAC,SAAS,GAAG,OAAO,UAAU,CAAC,OAAO,GAAG,OAAO,UAAU,CAAC,OAAO,GAAG,OAAO,UAAU,CAAC,QAAQ,GAAG,OAAO,UAAU,CAAC,KAAK,CAAC;AAE7I;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC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