@umicat/phaser-sdk 1.0.18 → 1.0.19
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/editor/EditorBridge.js +20 -7
- package/dist/protocol.d.ts +9 -0
- package/package.json +1 -1
|
@@ -79,7 +79,7 @@ function handleMessage(game, msg) {
|
|
|
79
79
|
applyPanZoomToWorld(game, msg);
|
|
80
80
|
break;
|
|
81
81
|
case 'umicat:editor:createEntity':
|
|
82
|
-
void createEntity(game, msg.entity, msg.manifestAsset);
|
|
82
|
+
void createEntity(game, msg.entity, msg.manifestAsset, msg.tilemapFile);
|
|
83
83
|
break;
|
|
84
84
|
case 'umicat:editor:deleteEntity':
|
|
85
85
|
deleteEntity(game, msg.entityId);
|
|
@@ -1206,7 +1206,7 @@ function applyVisualPatch(go, v) {
|
|
|
1206
1206
|
* the host would have to coordinate a build before showing a dropped
|
|
1207
1207
|
* sprite, which defeats the point of drag-to-place.
|
|
1208
1208
|
*/
|
|
1209
|
-
async function createEntity(game, entity, manifestAsset) {
|
|
1209
|
+
async function createEntity(game, entity, manifestAsset, tilemapFile) {
|
|
1210
1210
|
// HUD mode dispatches to the HUD-runtime spawner (slice 5). The host
|
|
1211
1211
|
// sends HudEntity records (not WorldEntity), so we type-erase.
|
|
1212
1212
|
if (getEditorMode(game) === 'hud') {
|
|
@@ -1288,13 +1288,26 @@ async function createEntity(game, entity, manifestAsset) {
|
|
|
1288
1288
|
// dropped tilemap renders LIVE without a save+reload round-trip.
|
|
1289
1289
|
const tilemapId = entity.tilemapId;
|
|
1290
1290
|
if (tilemapId) {
|
|
1291
|
-
|
|
1292
|
-
|
|
1291
|
+
const key = tilemapFileCacheKey(tilemapId);
|
|
1292
|
+
// Prefer the host-supplied file CONTENT (the workspace truth). The dist
|
|
1293
|
+
// copy that `loadTilemapFileIntoScene` fetches is STALE until the next
|
|
1294
|
+
// game build, so a freshly-authored/edited tilemap 404s there → magenta
|
|
1295
|
+
// placeholder until save+rebuild. Injecting the passed content renders it
|
|
1296
|
+
// LIVE. Fall back to the dist fetch when the host didn't supply it.
|
|
1297
|
+
if (tilemapFile) {
|
|
1298
|
+
if (sceneRef.cache.json.exists(key))
|
|
1299
|
+
sceneRef.cache.json.remove(key);
|
|
1300
|
+
sceneRef.cache.json.add(key, tilemapFile);
|
|
1293
1301
|
}
|
|
1294
|
-
|
|
1295
|
-
|
|
1302
|
+
else {
|
|
1303
|
+
try {
|
|
1304
|
+
await loadTilemapFileIntoScene(sceneRef, tilemapId);
|
|
1305
|
+
}
|
|
1306
|
+
catch (e) {
|
|
1307
|
+
console.warn('[umicat/editor] createEntity: tilemap-ref file load failed:', e);
|
|
1308
|
+
}
|
|
1296
1309
|
}
|
|
1297
|
-
const file = sceneRef.cache.json.get(
|
|
1310
|
+
const file = sceneRef.cache.json.get(key);
|
|
1298
1311
|
for (const layer of file?.layers ?? []) {
|
|
1299
1312
|
for (const tid of layer.tilesetIds ?? []) {
|
|
1300
1313
|
queueIfMissing(resolveById(tid));
|
package/dist/protocol.d.ts
CHANGED
|
@@ -194,6 +194,15 @@ export interface EditorCreateEntityMessage {
|
|
|
194
194
|
entity: unknown;
|
|
195
195
|
/** Asset record to add to runtime cache before spawn. Omit if assetId is already loaded. */
|
|
196
196
|
manifestAsset?: unknown;
|
|
197
|
+
/**
|
|
198
|
+
* For a `tilemap-ref`: the standalone tilemap file's CONTENT (the parsed
|
|
199
|
+
* `public/tilemaps/{id}.json`). The host fetches it from the WORKSPACE
|
|
200
|
+
* (current truth) and passes it so the SDK injects it into the JSON cache
|
|
201
|
+
* directly. Without this the SDK fetches the file from the deployed dist,
|
|
202
|
+
* which is STALE until the next game build — so a freshly-authored/edited
|
|
203
|
+
* tilemap renders as the magenta placeholder until save+reload.
|
|
204
|
+
*/
|
|
205
|
+
tilemapFile?: unknown;
|
|
197
206
|
}
|
|
198
207
|
export interface EditorDeleteEntityMessage {
|
|
199
208
|
type: 'umicat:editor:deleteEntity';
|