Skip to content

Commit 858fcea

Browse files
author
DavidQ
committed
fix(asset-pipeline-tool): always emit output on invalid input, add workspace state capture/apply adapter support, and disable generic shared-asset binding for pipeline surface
1 parent 907645d commit 858fcea

3 files changed

Lines changed: 73 additions & 6 deletions

File tree

tools/Asset Pipeline Tool/main.js

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ const refs = {
99
output: document.getElementById("assetPipelineOutput")
1010
};
1111

12+
function setOutput(value) {
13+
if (!(refs.output instanceof HTMLElement)) {
14+
return;
15+
}
16+
refs.output.textContent = typeof value === "string" ? value : toPrettyJson(value);
17+
}
18+
1219
function normalizeText(value) {
1320
return typeof value === "string" ? value.trim() : "";
1421
}
@@ -175,12 +182,23 @@ function runPipeline() {
175182
const payload = getInputPayload();
176183
if (!payload) {
177184
setStatus("Input JSON is invalid. Provide a pipeline options object.");
185+
setOutput({
186+
schema: "html-js-gaming.asset-pipeline-tooling",
187+
version: 1,
188+
status: "invalid",
189+
errors: [
190+
{
191+
code: "PIPELINE_INPUT_INVALID",
192+
stage: "load",
193+
message: "Pipeline input must be a valid JSON object."
194+
}
195+
],
196+
records: []
197+
});
178198
return;
179199
}
180200
const result = runAssetPipelineTooling(payload);
181-
if (refs.output instanceof HTMLElement) {
182-
refs.output.textContent = toPrettyJson(result);
183-
}
201+
setOutput(result);
184202
const recordCount = Array.isArray(result.records) ? result.records.length : 0;
185203
setStatus(`Pipeline ${result.status || "unknown"}; records=${recordCount}.`);
186204
}
@@ -249,16 +267,42 @@ function bootAssetPipelineTool() {
249267
setStatus("Awaiting source pipeline JSON. No default payload is applied.");
250268
}
251269
void tryLoadPresetFromQuery();
252-
return { runPipeline };
270+
window.assetPipelineToolApp = assetPipelineToolApi;
271+
return assetPipelineToolApi;
253272
}
254273

274+
const assetPipelineToolApi = {
275+
captureProjectState() {
276+
return {
277+
pipelineInput: refs.input instanceof HTMLTextAreaElement ? refs.input.value : ""
278+
};
279+
},
280+
applyProjectState(snapshot) {
281+
if (!(refs.input instanceof HTMLTextAreaElement)) {
282+
return false;
283+
}
284+
const nextInput = typeof snapshot?.pipelineInput === "string"
285+
? snapshot.pipelineInput
286+
: (snapshot?.pipelinePayload && typeof snapshot.pipelinePayload === "object"
287+
? toPrettyJson(snapshot.pipelinePayload)
288+
: "");
289+
if (!nextInput) {
290+
return false;
291+
}
292+
refs.input.value = nextInput;
293+
setStatus("Pipeline state loaded from workspace source data.");
294+
return true;
295+
},
296+
runPipeline
297+
};
298+
255299
registerToolBootContract("asset-pipeline-tool", {
256300
init: bootAssetPipelineTool,
257301
destroy() {
258302
return true;
259303
},
260304
getApi() {
261-
return { runPipeline };
305+
return window.assetPipelineToolApp || assetPipelineToolApi;
262306
}
263307
});
264308

tools/shared/platformShell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ function resolveAcceptedAssetKindsForTool(toolId = "") {
605605
"3d-asset-viewer": ["3d", "model", "mesh"],
606606
"3d-camera-path-editor": ["camera-path", "3d-camera-path"],
607607
"asset-browser": ["*"],
608-
"asset-pipeline-tool": ["*"],
608+
"asset-pipeline-tool": [],
609609
"tile-model-converter": ["tilemap", "tileset", "vector", "model", "3d"]
610610
};
611611
return byTool[normalizedToolId] || [];

tools/shared/projectSystemAdapters.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,27 @@ function createPaletteBrowserAdapter() {
236236
};
237237
}
238238

239+
function createAssetPipelineAdapter() {
240+
const api = readToolApi("asset-pipeline-tool", "assetPipelineToolApp");
241+
if (!api || typeof api.captureProjectState !== "function" || typeof api.applyProjectState !== "function") {
242+
return buildUnavailableAdapter("asset-pipeline-tool");
243+
}
244+
245+
return {
246+
toolId: "asset-pipeline-tool",
247+
ready: true,
248+
getProjectName() {
249+
return "Asset Pipeline Workflow";
250+
},
251+
captureState() {
252+
return cloneValue(api.captureProjectState());
253+
},
254+
applyState(state) {
255+
return api.applyProjectState(cloneValue(state)) === true;
256+
}
257+
};
258+
}
259+
239260
export function getProjectAdapter(toolId) {
240261
switch (toolId) {
241262
case "vector-map-editor":
@@ -252,6 +273,8 @@ export function getProjectAdapter(toolId) {
252273
return createAssetBrowserAdapter();
253274
case "palette-browser":
254275
return createPaletteBrowserAdapter();
276+
case "asset-pipeline-tool":
277+
return createAssetPipelineAdapter();
255278
default:
256279
return buildUnavailableAdapter(toolId);
257280
}

0 commit comments

Comments
 (0)