@rpgjs/tiledmap 5.0.0-alpha.1-local.1 → 5.0.0-alpha.11
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/client/index.js +11 -5
- package/dist/client/index2.js +1 -1
- package/dist/client/index3.js +4649 -12
- package/dist/client/index4.js +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/server/index.js +1 -1
- package/dist/server/index2.js +1 -1
- package/dist/server/index3.js +5232 -0
- package/dist/server.d.ts +1 -1
- package/package.json +10 -8
- package/src/client.ts +1 -1
- package/src/index.ts +27 -18
- package/src/server.ts +1 -4
- package/src/tiled.ce +3 -2
package/dist/server.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpgjs/tiledmap",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.11",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -22,13 +22,12 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"description": "RPGJS is a framework for creating RPG/MMORPG games",
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"canvasengine": "2.0.0-beta.
|
|
26
|
-
"@
|
|
27
|
-
"@rpgjs/common": "5.0.0-alpha.
|
|
28
|
-
"@rpgjs/server": "5.0.0-alpha.
|
|
29
|
-
"@rpgjs/vite": "5.0.0-alpha.
|
|
30
|
-
"
|
|
31
|
-
"@rpgjs/client": "5.0.0-alpha.1"
|
|
25
|
+
"@canvasengine/presets": "2.0.0-beta.25",
|
|
26
|
+
"@rpgjs/client": "5.0.0-alpha.11",
|
|
27
|
+
"@rpgjs/common": "5.0.0-alpha.11",
|
|
28
|
+
"@rpgjs/server": "5.0.0-alpha.11",
|
|
29
|
+
"@rpgjs/vite": "5.0.0-alpha.11",
|
|
30
|
+
"canvasengine": "2.0.0-beta.25"
|
|
32
31
|
},
|
|
33
32
|
"publishConfig": {
|
|
34
33
|
"access": "public"
|
|
@@ -39,6 +38,9 @@
|
|
|
39
38
|
"vite-plugin-dts": "^4.5.3"
|
|
40
39
|
},
|
|
41
40
|
"type": "module",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@canvasengine/tiled": "2.0.0-beta.25"
|
|
43
|
+
},
|
|
42
44
|
"scripts": {
|
|
43
45
|
"dev": "vite build --watch",
|
|
44
46
|
"build": "vite build"
|
package/src/client.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,11 +2,12 @@ import server from "./server";
|
|
|
2
2
|
import client from "./client";
|
|
3
3
|
import { createModule } from "@rpgjs/common";
|
|
4
4
|
import { provideLoadMap } from "@rpgjs/client";
|
|
5
|
-
import { TiledParser } from "@
|
|
5
|
+
import { TiledParser } from "@canvasengine/tiled";
|
|
6
6
|
import Tiled from "./tiled.ce";
|
|
7
7
|
|
|
8
8
|
export function provideTiledMap(options: {
|
|
9
9
|
basePath: string;
|
|
10
|
+
onLoadMap?: (map: string) => Promise<void>;
|
|
10
11
|
}) {
|
|
11
12
|
return createModule("TiledMap", [
|
|
12
13
|
{
|
|
@@ -14,33 +15,41 @@ export function provideTiledMap(options: {
|
|
|
14
15
|
client,
|
|
15
16
|
},
|
|
16
17
|
provideLoadMap?.(async (map) => {
|
|
17
|
-
|
|
18
|
-
const response = await fetch(`${options.basePath}/${map}.tmx`)
|
|
19
|
-
const mapData = (await response.text())
|
|
18
|
+
"use client";
|
|
19
|
+
const response = await fetch(`${options.basePath}/${map}.tmx`);
|
|
20
|
+
const mapData = (await response.text());
|
|
20
21
|
const parser = new TiledParser(mapData);
|
|
21
22
|
const parsedMap = parser.parseMap();
|
|
22
|
-
const tilesets: any = []
|
|
23
|
+
const tilesets: any = [];
|
|
23
24
|
for (let tileset of parsedMap.tilesets) {
|
|
24
|
-
const response = await fetch(`${tileset.source}`);
|
|
25
|
+
const response = await fetch(`${options.basePath}/${tileset.source}`);
|
|
25
26
|
const tilesetData = await response.text();
|
|
26
27
|
const parser = new TiledParser(tilesetData);
|
|
27
28
|
const parsedTileset = parser.parseTileset();
|
|
28
|
-
parsedTileset.image.source = `${options.basePath}/${parsedTileset.image.source}
|
|
29
|
+
parsedTileset.image.source = `${options.basePath}/${parsedTileset.image.source}`;
|
|
29
30
|
// Preserve firstgid from the original tileset reference
|
|
30
31
|
tilesets.push({
|
|
31
|
-
...tileset,
|
|
32
|
-
...parsedTileset
|
|
33
|
-
})
|
|
32
|
+
...tileset, // Preserve original properties including firstgid
|
|
33
|
+
...parsedTileset, // Merge with parsed tileset data
|
|
34
|
+
});
|
|
34
35
|
}
|
|
35
|
-
parsedMap.tilesets = tilesets
|
|
36
|
-
|
|
36
|
+
parsedMap.tilesets = tilesets;
|
|
37
|
+
|
|
37
38
|
const obj = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
data: mapData,
|
|
40
|
+
component: Tiled,
|
|
41
|
+
parsedMap,
|
|
42
|
+
id: map,
|
|
43
|
+
params: {
|
|
44
|
+
basePath: options.basePath,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (options.onLoadMap) {
|
|
49
|
+
await options.onLoadMap(map);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return obj;
|
|
44
53
|
}),
|
|
45
54
|
]);
|
|
46
55
|
}
|
package/src/server.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { RpgMap, RpgServer } from "@rpgjs/server";
|
|
2
|
-
import {
|
|
2
|
+
import { MapClass } from "@canvasengine/tiled";
|
|
3
3
|
import { defineModule } from "@rpgjs/common";
|
|
4
4
|
|
|
5
|
-
// Import TileInfo depuis le bon endroit
|
|
6
|
-
import type { TileInfo } from "@rpgjs/tiled/src/classes/Map";
|
|
7
|
-
|
|
8
5
|
// Extend RpgMap interface to include tiled property
|
|
9
6
|
declare module "@rpgjs/server" {
|
|
10
7
|
interface RpgMap {
|
package/src/tiled.ce
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<Container>
|
|
2
|
-
<TiledMap map basePath
|
|
2
|
+
<TiledMap map basePath createLayersPerTilesZ={true} objectLayer={() => <EventLayerComponent />} />
|
|
3
3
|
</Container>
|
|
4
4
|
|
|
5
5
|
<script>
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import { TiledMap } from "@canvasengine/presets";
|
|
8
8
|
import { signal } from "canvasengine";
|
|
9
9
|
|
|
10
|
-
const { data,
|
|
10
|
+
const { data, params } = defineProps()
|
|
11
11
|
|
|
12
12
|
const map = signal(data())
|
|
13
|
+
const basePath = signal(params().basePath)
|
|
13
14
|
</script>
|