@rpgjs/tiledmap 5.0.0-alpha.2 → 5.0.0-alpha.21

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.
@@ -1,24 +1,23 @@
1
1
  import client from "./index2.js";
2
2
  import { createModule } from "@rpgjs/common";
3
3
  import { provideLoadMap } from "@rpgjs/client";
4
- import { TiledParser } from "@rpgjs/tiled";
5
- import component from "./index3.js";
4
+ import { TiledParser } from "./index3.js";
5
+ import component from "./index4.js";
6
6
  const server = null;
7
7
  function provideTiledMap(options) {
8
- var _a;
9
8
  return createModule("TiledMap", [
10
9
  {
11
10
  server,
12
11
  client
13
12
  },
14
- (_a = provideLoadMap) == null ? void 0 : _a(async (map) => {
13
+ provideLoadMap?.(async (map) => {
15
14
  const response = await fetch(`${options.basePath}/${map}.tmx`);
16
- const mapData = (await response.text()).replace(/source="([^"]+)"/g, `source="${options.basePath}/$1"`);
15
+ const mapData = await response.text();
17
16
  const parser = new TiledParser(mapData);
18
17
  const parsedMap = parser.parseMap();
19
18
  const tilesets = [];
20
19
  for (let tileset of parsedMap.tilesets) {
21
- const response2 = await fetch(`${tileset.source}`);
20
+ const response2 = await fetch(`${options.basePath}/${tileset.source}`);
22
21
  const tilesetData = await response2.text();
23
22
  const parser2 = new TiledParser(tilesetData);
24
23
  const parsedTileset = parser2.parseTileset();
@@ -35,8 +34,14 @@ function provideTiledMap(options) {
35
34
  data: mapData,
36
35
  component,
37
36
  parsedMap,
38
- id: map
37
+ id: map,
38
+ params: {
39
+ basePath: options.basePath
40
+ }
39
41
  };
42
+ if (options.onLoadMap) {
43
+ await options.onLoadMap(map);
44
+ }
40
45
  return obj;
41
46
  })
42
47
  ]);
@@ -1,6 +1,6 @@
1
1
  import { defineModule } from "@rpgjs/common";
2
2
  const client = defineModule({
3
- effects: []
3
+ componentAnimations: []
4
4
  });
5
5
  export {
6
6
  client as default