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