@galacean/cli 2.0.0-alpha.26 → 2.0.0-alpha.27
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/cli.bundle.cjs +671 -777
- package/dist/preview-client/_static/{Accordion-2cd014f1.js → Accordion-4afac60c.js} +1 -1
- package/dist/preview-client/_static/{AmbientLightAsset-be9e872c.js → AmbientLightAsset-3825f3bf.js} +2 -2
- package/dist/preview-client/_static/{AnimationClipAsset-d7b37af0.js → AnimationClipAsset-660ecb36.js} +1 -1
- package/dist/preview-client/_static/{AnimatorControllerAsset-2716497a.js → AnimatorControllerAsset-dcf11a9d.js} +1 -1
- package/dist/preview-client/_static/{AnimatorStore-883a28ad.js → AnimatorStore-aa58d85c.js} +1 -1
- package/dist/preview-client/_static/{AssetViewer-3847c058.js → AssetViewer-8338dfe1.js} +1 -1
- package/dist/preview-client/_static/{AudioAsset-c28f33ab.js → AudioAsset-6e607154.js} +1 -1
- package/dist/preview-client/_static/{AudioComponent-3d6c73ce.js → AudioComponent-b70cc31e.js} +1 -1
- package/dist/preview-client/_static/{Callout-e2a89f6f.js → Callout-155c30df.js} +1 -1
- package/dist/preview-client/_static/{CameraComponent-3dc63451.js → CameraComponent-76bc9102.js} +1 -1
- package/dist/preview-client/_static/{Component-0f881fc1.js → Component-398551a0.js} +1 -1
- package/dist/preview-client/_static/{DirectLight-96dbba47.js → DirectLight-50653e81.js} +1 -1
- package/dist/preview-client/_static/{FontAsset-d34b5378.js → FontAsset-dc385d41.js} +1 -1
- package/dist/preview-client/_static/{FormItemArray-b8cda1d2.js → FormItemArray-9ca61884.js} +1 -1
- package/dist/preview-client/_static/{GlTFAsset-5970e707.js → GlTFAsset-d2ee4f95.js} +1 -1
- package/dist/preview-client/_static/{IconPlus-def01e2b.js → IconPlus-b3ed4c04.js} +1 -1
- package/dist/preview-client/_static/{IconPointFilled-62d3c3b2.js → IconPointFilled-3ba6d082.js} +1 -1
- package/dist/preview-client/_static/{LightBaseComponent-d651a276.js → LightBaseComponent-4cfc9f48.js} +1 -1
- package/dist/preview-client/_static/{LottieAnimationComponent-f10dc558.js → LottieAnimationComponent-aeb555ea.js} +1 -1
- package/dist/preview-client/_static/{MarkdownAsset-b2a3fad5.js → MarkdownAsset-02477e7c.js} +1 -1
- package/dist/preview-client/_static/{MaterialAsset-5353c4cb.js → MaterialAsset-8f3b3302.js} +1 -1
- package/dist/preview-client/_static/{MaterialInspector-8d466d59.js → MaterialInspector-3fb471d9.js} +1 -1
- package/dist/preview-client/_static/{Menu-c8e6194b.js → Menu-36c201c0.js} +1 -1
- package/dist/preview-client/_static/{MeshAsset-c2bf60c5.js → MeshAsset-3ddf1ac6.js} +1 -1
- package/dist/preview-client/_static/{MeshRendererBaseComponent-fde6b6a5.js → MeshRendererBaseComponent-cd8b743b.js} +1 -1
- package/dist/preview-client/_static/{MeshRendererComponent-430774ef.js → MeshRendererComponent-17a7fc72.js} +1 -1
- package/dist/preview-client/_static/{MeshThumbnail-07ffa076.js → MeshThumbnail-8c20ee92.js} +1 -1
- package/dist/preview-client/_static/{ParticleRendererComponent-e106bd8c.js → ParticleRendererComponent-1834a159.js} +3 -3
- package/dist/preview-client/_static/{PhysicsMaterialAsset-a2f73b5c.js → PhysicsMaterialAsset-e0491877.js} +1 -1
- package/dist/preview-client/_static/{PhysicsStore-818c2f61.js → PhysicsStore-ab32886e.js} +1 -1
- package/dist/preview-client/_static/{PointLight-add790ea.js → PointLight-97975350.js} +1 -1
- package/dist/preview-client/_static/{PostProcessComponent-af270a77.js → PostProcessComponent-9590ec29.js} +1 -1
- package/dist/preview-client/_static/PrefabAsset-2f94de73.js +1 -0
- package/dist/preview-client/_static/{PrimitiveMesh-075dda8a.js → PrimitiveMesh-0492d482.js} +1 -1
- package/dist/preview-client/_static/{ReferencedMaterial-d11151b5.js → ReferencedMaterial-49a7cbcc.js} +1 -1
- package/dist/preview-client/_static/{RenderTargetAsset-b3cd1c49.js → RenderTargetAsset-dc1f9494.js} +1 -1
- package/dist/preview-client/_static/{SceneAsset-08752701.js → SceneAsset-c3bb667f.js} +1 -1
- package/dist/preview-client/_static/{ShaderAsset-a9d667f5.js → ShaderAsset-f4eead79.js} +12 -12
- package/dist/preview-client/_static/{ShaderChunkAsset-e43dde8a.js → ShaderChunkAsset-4bea2733.js} +2 -2
- package/dist/preview-client/_static/{ShaderUIScriptAsset-e1cd0b8b.js → ShaderUIScriptAsset-3c731f3b.js} +2 -2
- package/dist/preview-client/_static/{SkinnedMeshRendererComponent-9756bd5f.js → SkinnedMeshRendererComponent-e0f9b133.js} +1 -1
- package/dist/preview-client/_static/{SpineAnimationComponent-f3e0ff44.js → SpineAnimationComponent-1e1655fd.js} +1 -1
- package/dist/preview-client/_static/{SpineSkeletonDataAsset-43b731f1.js → SpineSkeletonDataAsset-afb4afae.js} +1 -1
- package/dist/preview-client/_static/{SpotLight-649b0e21.js → SpotLight-69f361c9.js} +1 -1
- package/dist/preview-client/_static/{SpriteBaseComponent-d2a7ab4c.js → SpriteBaseComponent-2c2454ea.js} +1 -1
- package/dist/preview-client/_static/{SpriteMaskComponent-2c1cef5e.js → SpriteMaskComponent-a7ebcc50.js} +1 -1
- package/dist/preview-client/_static/{SpriteRendererComponent-33b71997.js → SpriteRendererComponent-f7604c68.js} +1 -1
- package/dist/preview-client/_static/{TextBaseComponent-9310e0c6.js → TextBaseComponent-cd7ad9f7.js} +1 -1
- package/dist/preview-client/_static/{TextRendererComponent-8dc0d7fb.js → TextRendererComponent-a5357d52.js} +1 -1
- package/dist/preview-client/_static/{TextureAsset-a7ff39b1.js → TextureAsset-ff089b5a.js} +1 -1
- package/dist/preview-client/_static/{Tooltip-b5be390f.js → Tooltip-1bcb87b5.js} +1 -1
- package/dist/preview-client/_static/{TrailRendererComponent-c4635fab.js → TrailRendererComponent-cdefa368.js} +1 -1
- package/dist/preview-client/_static/{TransformBaseComponent-1473deaa.js → TransformBaseComponent-d26ff236.js} +1 -1
- package/dist/preview-client/_static/{TransformComponent-e544f7ac.js → TransformComponent-4ec4b7b5.js} +1 -1
- package/dist/preview-client/_static/{XRReferenceImageAsset-96f516ba.js → XRReferenceImageAsset-ff82ab30.js} +1 -1
- package/dist/preview-client/_static/{audio-b5fbde34.js → audio-0a013eb6.js} +1 -1
- package/dist/preview-client/_static/{createOnModelChange-370b83da.js → createOnModelChange-89f572a6.js} +1 -1
- package/dist/preview-client/_static/{createReactComponent-58d9f0dd.js → createReactComponent-baa41397.js} +1 -1
- package/dist/preview-client/_static/index-0086cabc.js +1 -0
- package/dist/preview-client/_static/index-253f9e13.js +1 -0
- package/dist/preview-client/_static/{index-da16047f.js → index-29916a80.js} +1 -1
- package/dist/preview-client/_static/{index-ab8556cb.js → index-4845b67c.js} +3 -3
- package/dist/preview-client/_static/{index-dd0763bf.js → index-5e4dedda.js} +1 -1
- package/dist/preview-client/_static/{index-0dd5bb36.js → index-70967035.js} +1 -1
- package/dist/preview-client/_static/index-8234e4e2.js +1 -0
- package/dist/preview-client/_static/{index-88650db7.js → index-8784a43a.js} +1 -1
- package/dist/preview-client/_static/index-94594d06.js +1 -0
- package/dist/preview-client/_static/{index-74bcfad9.js → index-a0afef01.js} +1 -1
- package/dist/preview-client/_static/index-ad57c6c8.js +1 -0
- package/dist/preview-client/_static/{index-c3dec278.js → index-b126bb6b.js} +72 -72
- package/dist/preview-client/_static/{index-cdbb2f4d.js → index-c8ed2a45.js} +1 -1
- package/dist/preview-client/_static/{index-05b76766.js → index-cd09e78a.js} +1 -1
- package/dist/preview-client/_static/index-d1484803.js +1 -0
- package/dist/preview-client/_static/index-f7fcda86.js +1 -0
- package/dist/preview-client/_static/{ktx2-encoder-db93524f.js → ktx2-encoder-8498815e.js} +1 -1
- package/dist/preview-client/_static/{module-ada3dced.js → module-113ac03a.js} +1 -1
- package/dist/preview-client/_static/{module-ec094ef6.js → module-83a57161.js} +1 -1
- package/dist/preview-client/_static/{module-de7ee724.js → module-8efda49c.js} +1 -1
- package/dist/preview-client/_static/{postmen-2853c0e6.js → postmen-3b48c572.js} +2 -2
- package/dist/preview-client/_static/{shader-data-utils-f0e4f5a3.js → shader-data-utils-c90e48b8.js} +1 -1
- package/dist/preview-client/index.html +1 -1
- package/package.json +29 -24
- package/dist/preview-client/_static/PrefabAsset-59743dbb.js +0 -1
- package/dist/preview-client/_static/index-29c59aff.js +0 -1
- package/dist/preview-client/_static/index-3680d0e0.js +0 -1
- package/dist/preview-client/_static/index-42aa3a49.js +0 -1
- package/dist/preview-client/_static/index-496f331d.js +0 -1
- package/dist/preview-client/_static/index-9f0122f0.js +0 -1
- package/dist/preview-client/_static/index-c6b7045c.js +0 -1
- package/dist/preview-client/_static/index-dddcae01.js +0 -1
package/dist/cli.bundle.cjs
CHANGED
|
@@ -1226,7 +1226,7 @@ var require_command = __commonJS({
|
|
|
1226
1226
|
var childProcess = require("node:child_process");
|
|
1227
1227
|
var path23 = require("node:path");
|
|
1228
1228
|
var fs5 = require("node:fs");
|
|
1229
|
-
var
|
|
1229
|
+
var process7 = require("node:process");
|
|
1230
1230
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
1231
1231
|
var { CommanderError: CommanderError2 } = require_error();
|
|
1232
1232
|
var { Help: Help2, stripColor } = require_help();
|
|
@@ -1273,13 +1273,13 @@ var require_command = __commonJS({
|
|
|
1273
1273
|
this._showSuggestionAfterError = true;
|
|
1274
1274
|
this._savedState = null;
|
|
1275
1275
|
this._outputConfiguration = {
|
|
1276
|
-
writeOut: (str) =>
|
|
1277
|
-
writeErr: (str) =>
|
|
1276
|
+
writeOut: (str) => process7.stdout.write(str),
|
|
1277
|
+
writeErr: (str) => process7.stderr.write(str),
|
|
1278
1278
|
outputError: (str, write2) => write2(str),
|
|
1279
|
-
getOutHelpWidth: () =>
|
|
1280
|
-
getErrHelpWidth: () =>
|
|
1281
|
-
getOutHasColors: () => useColor() ?? (
|
|
1282
|
-
getErrHasColors: () => useColor() ?? (
|
|
1279
|
+
getOutHelpWidth: () => process7.stdout.isTTY ? process7.stdout.columns : void 0,
|
|
1280
|
+
getErrHelpWidth: () => process7.stderr.isTTY ? process7.stderr.columns : void 0,
|
|
1281
|
+
getOutHasColors: () => useColor() ?? (process7.stdout.isTTY && process7.stdout.hasColors?.()),
|
|
1282
|
+
getErrHasColors: () => useColor() ?? (process7.stderr.isTTY && process7.stderr.hasColors?.()),
|
|
1283
1283
|
stripColor: (str) => stripColor(str)
|
|
1284
1284
|
};
|
|
1285
1285
|
this._hidden = false;
|
|
@@ -1684,7 +1684,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1684
1684
|
if (this._exitCallback) {
|
|
1685
1685
|
this._exitCallback(new CommanderError2(exitCode, code, message));
|
|
1686
1686
|
}
|
|
1687
|
-
|
|
1687
|
+
process7.exit(exitCode);
|
|
1688
1688
|
}
|
|
1689
1689
|
/**
|
|
1690
1690
|
* Register callback `fn` for the command.
|
|
@@ -2084,16 +2084,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2084
2084
|
}
|
|
2085
2085
|
parseOptions = parseOptions || {};
|
|
2086
2086
|
if (argv === void 0 && parseOptions.from === void 0) {
|
|
2087
|
-
if (
|
|
2087
|
+
if (process7.versions?.electron) {
|
|
2088
2088
|
parseOptions.from = "electron";
|
|
2089
2089
|
}
|
|
2090
|
-
const execArgv =
|
|
2090
|
+
const execArgv = process7.execArgv ?? [];
|
|
2091
2091
|
if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) {
|
|
2092
2092
|
parseOptions.from = "eval";
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
2095
|
if (argv === void 0) {
|
|
2096
|
-
argv =
|
|
2096
|
+
argv = process7.argv;
|
|
2097
2097
|
}
|
|
2098
2098
|
this.rawArgs = argv.slice();
|
|
2099
2099
|
let userArgs;
|
|
@@ -2104,7 +2104,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2104
2104
|
userArgs = argv.slice(2);
|
|
2105
2105
|
break;
|
|
2106
2106
|
case "electron":
|
|
2107
|
-
if (
|
|
2107
|
+
if (process7.defaultApp) {
|
|
2108
2108
|
this._scriptPath = argv[1];
|
|
2109
2109
|
userArgs = argv.slice(2);
|
|
2110
2110
|
} else {
|
|
@@ -2295,11 +2295,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2295
2295
|
}
|
|
2296
2296
|
launchWithNode = sourceExt.includes(path23.extname(executableFile));
|
|
2297
2297
|
let proc;
|
|
2298
|
-
if (
|
|
2298
|
+
if (process7.platform !== "win32") {
|
|
2299
2299
|
if (launchWithNode) {
|
|
2300
2300
|
args.unshift(executableFile);
|
|
2301
|
-
args = incrementNodeInspectorPort(
|
|
2302
|
-
proc = childProcess.spawn(
|
|
2301
|
+
args = incrementNodeInspectorPort(process7.execArgv).concat(args);
|
|
2302
|
+
proc = childProcess.spawn(process7.argv[0], args, { stdio: "inherit" });
|
|
2303
2303
|
} else {
|
|
2304
2304
|
proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
|
|
2305
2305
|
}
|
|
@@ -2310,13 +2310,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2310
2310
|
subcommand._name
|
|
2311
2311
|
);
|
|
2312
2312
|
args.unshift(executableFile);
|
|
2313
|
-
args = incrementNodeInspectorPort(
|
|
2314
|
-
proc = childProcess.spawn(
|
|
2313
|
+
args = incrementNodeInspectorPort(process7.execArgv).concat(args);
|
|
2314
|
+
proc = childProcess.spawn(process7.execPath, args, { stdio: "inherit" });
|
|
2315
2315
|
}
|
|
2316
2316
|
if (!proc.killed) {
|
|
2317
2317
|
const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
|
|
2318
2318
|
signals.forEach((signal) => {
|
|
2319
|
-
|
|
2319
|
+
process7.on(signal, () => {
|
|
2320
2320
|
if (proc.killed === false && proc.exitCode === null) {
|
|
2321
2321
|
proc.kill(signal);
|
|
2322
2322
|
}
|
|
@@ -2327,7 +2327,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2327
2327
|
proc.on("close", (code) => {
|
|
2328
2328
|
code = code ?? 1;
|
|
2329
2329
|
if (!exitCallback) {
|
|
2330
|
-
|
|
2330
|
+
process7.exit(code);
|
|
2331
2331
|
} else {
|
|
2332
2332
|
exitCallback(
|
|
2333
2333
|
new CommanderError2(
|
|
@@ -2349,7 +2349,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2349
2349
|
throw new Error(`'${executableFile}' not executable`);
|
|
2350
2350
|
}
|
|
2351
2351
|
if (!exitCallback) {
|
|
2352
|
-
|
|
2352
|
+
process7.exit(1);
|
|
2353
2353
|
} else {
|
|
2354
2354
|
const wrappedError = new CommanderError2(
|
|
2355
2355
|
1,
|
|
@@ -2854,13 +2854,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2854
2854
|
*/
|
|
2855
2855
|
_parseOptionsEnv() {
|
|
2856
2856
|
this.options.forEach((option) => {
|
|
2857
|
-
if (option.envVar && option.envVar in
|
|
2857
|
+
if (option.envVar && option.envVar in process7.env) {
|
|
2858
2858
|
const optionKey = option.attributeName();
|
|
2859
2859
|
if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(
|
|
2860
2860
|
this.getOptionValueSource(optionKey)
|
|
2861
2861
|
)) {
|
|
2862
2862
|
if (option.required || option.optional) {
|
|
2863
|
-
this.emit(`optionEnv:${option.name()}`,
|
|
2863
|
+
this.emit(`optionEnv:${option.name()}`, process7.env[option.envVar]);
|
|
2864
2864
|
} else {
|
|
2865
2865
|
this.emit(`optionEnv:${option.name()}`);
|
|
2866
2866
|
}
|
|
@@ -3401,7 +3401,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3401
3401
|
*/
|
|
3402
3402
|
help(contextOptions) {
|
|
3403
3403
|
this.outputHelp(contextOptions);
|
|
3404
|
-
let exitCode = Number(
|
|
3404
|
+
let exitCode = Number(process7.exitCode ?? 0);
|
|
3405
3405
|
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
3406
3406
|
exitCode = 1;
|
|
3407
3407
|
}
|
|
@@ -3491,9 +3491,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3491
3491
|
});
|
|
3492
3492
|
}
|
|
3493
3493
|
function useColor() {
|
|
3494
|
-
if (
|
|
3494
|
+
if (process7.env.NO_COLOR || process7.env.FORCE_COLOR === "0" || process7.env.FORCE_COLOR === "false")
|
|
3495
3495
|
return false;
|
|
3496
|
-
if (
|
|
3496
|
+
if (process7.env.FORCE_COLOR || process7.env.CLICOLOR_FORCE !== void 0)
|
|
3497
3497
|
return true;
|
|
3498
3498
|
return void 0;
|
|
3499
3499
|
}
|
|
@@ -8058,9 +8058,9 @@ async function readRemoteConfig2(fs5, projectDir) {
|
|
|
8058
8058
|
return { projectId, serverUrl };
|
|
8059
8059
|
}
|
|
8060
8060
|
async function readProjectConfig2(fs5, projectDir) {
|
|
8061
|
-
const
|
|
8061
|
+
const projectPath2 = import_node_path6.default.resolve(projectDir, "project.galacean");
|
|
8062
8062
|
try {
|
|
8063
|
-
const raw = decodeUtf82(await fs5.readFile(
|
|
8063
|
+
const raw = decodeUtf82(await fs5.readFile(projectPath2));
|
|
8064
8064
|
return safeParseJsonObject2(raw);
|
|
8065
8065
|
} catch {
|
|
8066
8066
|
return {};
|
|
@@ -38908,8 +38908,13 @@ var init_src4 = __esm({
|
|
|
38908
38908
|
function contextSuffix(context) {
|
|
38909
38909
|
return context ? ` in ${context}` : "";
|
|
38910
38910
|
}
|
|
38911
|
-
function
|
|
38912
|
-
|
|
38911
|
+
function hasEditorTypeExtension(sourceRef) {
|
|
38912
|
+
const lastSegment = sourceRef.split("/").pop() ?? sourceRef;
|
|
38913
|
+
const normalizedLastSegment = lastSegment.toLowerCase();
|
|
38914
|
+
return EDITOR_TYPE_EXTENSIONS.some((extension) => normalizedLastSegment.endsWith(extension));
|
|
38915
|
+
}
|
|
38916
|
+
function isValidSourceAssetRef(sourceRef) {
|
|
38917
|
+
return typeof sourceRef === "string" && sourceRef.length > 0 && !isUrlLikeSourceRef(sourceRef) && !sourceRef.includes("/") && !sourceRef.includes("\\") && !hasEditorTypeExtension(sourceRef);
|
|
38913
38918
|
}
|
|
38914
38919
|
function isUrlLikeSourceRef(sourceRef) {
|
|
38915
38920
|
return URL_LIKE_SOURCE_REF_PATTERN.test(sourceRef);
|
|
@@ -38917,71 +38922,45 @@ function isUrlLikeSourceRef(sourceRef) {
|
|
|
38917
38922
|
function normalizeSourceVirtualPath(value) {
|
|
38918
38923
|
return value.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
38919
38924
|
}
|
|
38920
|
-
function
|
|
38925
|
+
function assertSourceAssetRef(sourceRef, context) {
|
|
38921
38926
|
if (typeof sourceRef !== "string" || sourceRef.length === 0) {
|
|
38922
|
-
throw new Error(`Source
|
|
38923
|
-
}
|
|
38924
|
-
if (isEditorAssetIdLikeSourceRef(sourceRef)) {
|
|
38925
|
-
throw new Error(`Source sentinel $ref must be a canonical virtualPath, not editor asset id "${sourceRef}"`);
|
|
38927
|
+
throw new Error(`Source $ref must not be empty${contextSuffix(context)}`);
|
|
38926
38928
|
}
|
|
38927
38929
|
if (isUrlLikeSourceRef(sourceRef)) {
|
|
38928
|
-
throw new Error(`Source
|
|
38929
|
-
}
|
|
38930
|
-
if (sourceRef.startsWith("/")) {
|
|
38931
|
-
throw new Error(`Source sentinel $ref must be a canonical virtualPath without leading slash "${sourceRef}"`);
|
|
38930
|
+
throw new Error(`Source $ref must be an asset id, not a URL: "${sourceRef}"${contextSuffix(context)}`);
|
|
38932
38931
|
}
|
|
38933
|
-
if (sourceRef.includes("\\")) {
|
|
38934
|
-
throw new Error(`Source
|
|
38932
|
+
if (sourceRef.includes("/") || sourceRef.includes("\\")) {
|
|
38933
|
+
throw new Error(`Source $ref must be an asset id, not a path: "${sourceRef}"${contextSuffix(context)}`);
|
|
38935
38934
|
}
|
|
38936
|
-
if (
|
|
38937
|
-
throw new Error(`Source
|
|
38935
|
+
if (hasEditorTypeExtension(sourceRef)) {
|
|
38936
|
+
throw new Error(`Source $ref must be an asset id, not a typed asset path: "${sourceRef}"${contextSuffix(context)}`);
|
|
38938
38937
|
}
|
|
38939
38938
|
}
|
|
38940
|
-
function
|
|
38941
|
-
|
|
38942
|
-
if (typeof sourceRef !== "string" || sourceRef.length === 0) {
|
|
38943
|
-
throw new Error(
|
|
38944
|
-
`[SceneV2] Unable to serialize asset ref "${assetId}"${contextSuffix(context)}: missing virtualPath`
|
|
38945
|
-
);
|
|
38946
|
-
}
|
|
38947
|
-
assertCanonicalSourceRef(sourceRef, context);
|
|
38939
|
+
function assertAndReturnSourceAssetRef(sourceRef, context) {
|
|
38940
|
+
assertSourceAssetRef(sourceRef, context);
|
|
38948
38941
|
return sourceRef;
|
|
38949
38942
|
}
|
|
38950
|
-
function
|
|
38951
|
-
assertCanonicalSourceRef(sourceRef, context);
|
|
38952
|
-
const assetId = resolveSourceRef2?.(sourceRef);
|
|
38953
|
-
if (typeof assetId !== "string" || assetId.length === 0) {
|
|
38954
|
-
throw new Error(
|
|
38955
|
-
`[SceneV2] Unable to resolve source asset ref "${sourceRef}"${contextSuffix(context)} to an editor asset id`
|
|
38956
|
-
);
|
|
38957
|
-
}
|
|
38958
|
-
return assetId;
|
|
38959
|
-
}
|
|
38960
|
-
function createSourceRefCodec(options) {
|
|
38943
|
+
function createSourceRefCodec(options = {}) {
|
|
38961
38944
|
return {
|
|
38962
38945
|
domainToSource(assetId, context) {
|
|
38963
|
-
return
|
|
38946
|
+
return assertAndReturnSourceAssetRef(assetId, context);
|
|
38964
38947
|
},
|
|
38965
38948
|
sourceToDomain(sourceRef, context) {
|
|
38966
|
-
return
|
|
38949
|
+
return assertAndReturnSourceAssetRef(sourceRef, context);
|
|
38967
38950
|
},
|
|
38968
38951
|
maybeResolveAssetKind(sourceRef) {
|
|
38969
|
-
|
|
38970
|
-
|
|
38971
|
-
if (typeof assetId !== "string" || assetId.length === 0)
|
|
38972
|
-
return void 0;
|
|
38973
|
-
return options.resolveAssetKind?.(sourceRef, assetId);
|
|
38952
|
+
assertSourceAssetRef(sourceRef);
|
|
38953
|
+
return options.resolveAssetKind?.(sourceRef);
|
|
38974
38954
|
}
|
|
38975
38955
|
};
|
|
38976
38956
|
}
|
|
38977
|
-
var
|
|
38957
|
+
var URL_LIKE_SOURCE_REF_PATTERN, EDITOR_TYPE_EXTENSIONS;
|
|
38978
38958
|
var init_source_ref_codec = __esm({
|
|
38979
38959
|
"../model/src/scene-file-v2/source-ref-codec.ts"() {
|
|
38980
38960
|
"use strict";
|
|
38981
|
-
|
|
38982
|
-
UUID_ASSET_ID_REF_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
38961
|
+
init_asset_path();
|
|
38983
38962
|
URL_LIKE_SOURCE_REF_PATTERN = /^[A-Za-z][A-Za-z0-9+.-]*:(?!:)/;
|
|
38984
|
-
|
|
38963
|
+
EDITOR_TYPE_EXTENSIONS = Object.values(TYPE_EXTENSION).filter((extension) => Boolean(extension)).map((extension) => extension.toLowerCase());
|
|
38985
38964
|
}
|
|
38986
38965
|
});
|
|
38987
38966
|
|
|
@@ -39086,28 +39065,28 @@ function cloneSourceValue(value) {
|
|
|
39086
39065
|
}
|
|
39087
39066
|
return result2;
|
|
39088
39067
|
}
|
|
39089
|
-
function convertSignalListenerAssetArgs(value
|
|
39068
|
+
function convertSignalListenerAssetArgs(value) {
|
|
39090
39069
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
39091
39070
|
return cloneSourceValue(value);
|
|
39092
39071
|
}
|
|
39093
39072
|
const record2 = value;
|
|
39094
39073
|
const result2 = {};
|
|
39095
39074
|
for (const [key2, child] of Object.entries(record2)) {
|
|
39096
|
-
result2[key2] = key2 === "args" && Array.isArray(child) ? child.map((item) => convertAssetRefsToDomainRefs(item
|
|
39075
|
+
result2[key2] = key2 === "args" && Array.isArray(child) ? child.map((item) => convertAssetRefsToDomainRefs(item)) : cloneSourceValue(child);
|
|
39097
39076
|
}
|
|
39098
39077
|
return result2;
|
|
39099
39078
|
}
|
|
39100
|
-
function resolveRequiredSourceRef(ref
|
|
39101
|
-
return
|
|
39079
|
+
function resolveRequiredSourceRef(ref) {
|
|
39080
|
+
return assertAndReturnSourceAssetRef(ref);
|
|
39102
39081
|
}
|
|
39103
|
-
function convertAssetRefsToDomainRefs(obj
|
|
39082
|
+
function convertAssetRefsToDomainRefs(obj) {
|
|
39104
39083
|
if (obj === null || obj === void 0 || typeof obj !== "object")
|
|
39105
39084
|
return obj;
|
|
39106
39085
|
if (Array.isArray(obj))
|
|
39107
|
-
return obj.map((value) => convertAssetRefsToDomainRefs(value
|
|
39086
|
+
return obj.map((value) => convertAssetRefsToDomainRefs(value));
|
|
39108
39087
|
const record2 = obj;
|
|
39109
39088
|
if ("$ref" in record2 && typeof record2.$ref === "string") {
|
|
39110
|
-
const refId = resolveRequiredSourceRef(record2.$ref
|
|
39089
|
+
const refId = resolveRequiredSourceRef(record2.$ref);
|
|
39111
39090
|
const result3 = { refId };
|
|
39112
39091
|
if (record2.key !== void 0)
|
|
39113
39092
|
result3.key = record2.key;
|
|
@@ -39119,7 +39098,7 @@ function convertAssetRefsToDomainRefs(obj, resolveSourceRef2) {
|
|
|
39119
39098
|
if ("$signal" in record2) {
|
|
39120
39099
|
return {
|
|
39121
39100
|
...cloneSourceValue(record2),
|
|
39122
|
-
$signal: Array.isArray(record2.$signal) ? record2.$signal.map((item) => convertSignalListenerAssetArgs(item
|
|
39101
|
+
$signal: Array.isArray(record2.$signal) ? record2.$signal.map((item) => convertSignalListenerAssetArgs(item)) : cloneSourceValue(record2.$signal)
|
|
39123
39102
|
};
|
|
39124
39103
|
}
|
|
39125
39104
|
if ("$type" in record2) {
|
|
@@ -39127,13 +39106,13 @@ function convertAssetRefsToDomainRefs(obj, resolveSourceRef2) {
|
|
|
39127
39106
|
for (const [key2, value] of Object.entries(record2)) {
|
|
39128
39107
|
if (key2 === "$type")
|
|
39129
39108
|
continue;
|
|
39130
|
-
result3[key2] = convertAssetRefsToDomainRefs(value
|
|
39109
|
+
result3[key2] = convertAssetRefsToDomainRefs(value);
|
|
39131
39110
|
}
|
|
39132
39111
|
return result3;
|
|
39133
39112
|
}
|
|
39134
39113
|
const result2 = {};
|
|
39135
39114
|
for (const [key2, value] of Object.entries(record2)) {
|
|
39136
|
-
result2[key2] = convertAssetRefsToDomainRefs(value
|
|
39115
|
+
result2[key2] = convertAssetRefsToDomainRefs(value);
|
|
39137
39116
|
}
|
|
39138
39117
|
return result2;
|
|
39139
39118
|
}
|
|
@@ -39144,7 +39123,9 @@ function isSourceId(value) {
|
|
|
39144
39123
|
return typeof value === "string" && value.length > 0;
|
|
39145
39124
|
}
|
|
39146
39125
|
function resolveInternalAssetRef(ref, options) {
|
|
39147
|
-
|
|
39126
|
+
const assetId = assertAndReturnSourceAssetRef(ref, options.context);
|
|
39127
|
+
options.validateAssetRef?.(assetId, options.context);
|
|
39128
|
+
return assetId;
|
|
39148
39129
|
}
|
|
39149
39130
|
function getSourceSentinelKeys(record2) {
|
|
39150
39131
|
return SOURCE_SENTINEL_KEYS.filter((key2) => key2 in record2);
|
|
@@ -39199,7 +39180,7 @@ function normalizeSourceAssetRefRecord(record2) {
|
|
|
39199
39180
|
if (record2.$ref.length === 0) {
|
|
39200
39181
|
throw new Error("Source sentinel $ref must not be empty");
|
|
39201
39182
|
}
|
|
39202
|
-
|
|
39183
|
+
assertSourceAssetRef(record2.$ref);
|
|
39203
39184
|
const result2 = { $ref: record2.$ref };
|
|
39204
39185
|
if (record2.key !== void 0) {
|
|
39205
39186
|
if (typeof record2.key !== "string") {
|
|
@@ -39335,8 +39316,9 @@ function normalizeDomainValueRecord(record2, options = {}) {
|
|
|
39335
39316
|
}
|
|
39336
39317
|
return result2;
|
|
39337
39318
|
}
|
|
39338
|
-
function convertInternalRefsToSourceValue(value,
|
|
39339
|
-
|
|
39319
|
+
function convertInternalRefsToSourceValue(value, contextOrOptions) {
|
|
39320
|
+
const options = typeof contextOrOptions === "string" ? { context: contextOrOptions } : contextOrOptions ?? {};
|
|
39321
|
+
return normalizeInternalSourceValue(value, options) ?? null;
|
|
39340
39322
|
}
|
|
39341
39323
|
var SOURCE_SENTINEL_KEYS;
|
|
39342
39324
|
var init_source_value = __esm({
|
|
@@ -40128,7 +40110,7 @@ function assertNoExtraKeys(record2, allowedKeys, label) {
|
|
|
40128
40110
|
}
|
|
40129
40111
|
}
|
|
40130
40112
|
}
|
|
40131
|
-
function sourceAssetRefToEditorRef(value
|
|
40113
|
+
function sourceAssetRefToEditorRef(value) {
|
|
40132
40114
|
if (value === null || value === void 0)
|
|
40133
40115
|
return value;
|
|
40134
40116
|
if (!isPlainObject2(value) || typeof value.$ref !== "string") {
|
|
@@ -40138,16 +40120,13 @@ function sourceAssetRefToEditorRef(value, resolveAssetId) {
|
|
|
40138
40120
|
if (value.key !== void 0 && typeof value.key !== "string") {
|
|
40139
40121
|
throw new Error("Source scene setting asset ref key must be a string");
|
|
40140
40122
|
}
|
|
40141
|
-
|
|
40142
|
-
if (typeof refId !== "string" || refId.length === 0) {
|
|
40143
|
-
throw new Error(`[SceneV2] Unable to resolve scene setting asset ref "${value.$ref}" to an editor asset id`);
|
|
40144
|
-
}
|
|
40123
|
+
assertSourceAssetRef(value.$ref, " in scene setting");
|
|
40145
40124
|
return {
|
|
40146
|
-
refId,
|
|
40125
|
+
refId: value.$ref,
|
|
40147
40126
|
...typeof value.key === "string" ? { key: value.key } : {}
|
|
40148
40127
|
};
|
|
40149
40128
|
}
|
|
40150
|
-
function editorAssetRefToSourceRef(value
|
|
40129
|
+
function editorAssetRefToSourceRef(value) {
|
|
40151
40130
|
if (value === null || value === void 0)
|
|
40152
40131
|
return value;
|
|
40153
40132
|
if (!isPlainObject2(value) || typeof value.refId !== "string") {
|
|
@@ -40157,15 +40136,19 @@ function editorAssetRefToSourceRef(value, resolveVirtualPath) {
|
|
|
40157
40136
|
if (value.key !== void 0 && typeof value.key !== "string") {
|
|
40158
40137
|
throw new Error("Editor scene setting asset ref key must be a string");
|
|
40159
40138
|
}
|
|
40160
|
-
|
|
40161
|
-
if (typeof sourceRef !== "string" || sourceRef.length === 0) {
|
|
40162
|
-
throw new Error(`[SceneV2] Unable to serialize scene setting asset ref "${value.refId}": missing virtualPath`);
|
|
40163
|
-
}
|
|
40139
|
+
assertSourceAssetRef(value.refId, " in scene setting");
|
|
40164
40140
|
return {
|
|
40165
|
-
$ref:
|
|
40141
|
+
$ref: value.refId,
|
|
40166
40142
|
...typeof value.key === "string" ? { key: value.key } : {}
|
|
40167
40143
|
};
|
|
40168
40144
|
}
|
|
40145
|
+
function editorAssetRefToSourceRefWithValidation(value, validateAssetRef) {
|
|
40146
|
+
const result2 = editorAssetRefToSourceRef(value);
|
|
40147
|
+
if (isPlainObject2(result2) && typeof result2.$ref === "string") {
|
|
40148
|
+
validateAssetRef?.(result2.$ref, " in scene setting");
|
|
40149
|
+
}
|
|
40150
|
+
return result2;
|
|
40151
|
+
}
|
|
40169
40152
|
function mapSceneSettingAssetRefs(settings, convert) {
|
|
40170
40153
|
const result2 = { ...settings };
|
|
40171
40154
|
for (const [category, definitions] of Object.entries(SCENE_SETTING_DEFINITIONS)) {
|
|
@@ -40197,14 +40180,14 @@ function mapSceneSettingAssetRefs(settings, convert) {
|
|
|
40197
40180
|
}
|
|
40198
40181
|
return result2;
|
|
40199
40182
|
}
|
|
40200
|
-
function sourceSceneSettingsToEditorSettings(settings
|
|
40201
|
-
return mapSceneSettingAssetRefs(settings, (value) => sourceAssetRefToEditorRef(value
|
|
40183
|
+
function sourceSceneSettingsToEditorSettings(settings) {
|
|
40184
|
+
return mapSceneSettingAssetRefs(settings, (value) => sourceAssetRefToEditorRef(value));
|
|
40202
40185
|
}
|
|
40203
|
-
function editorSceneSettingsToSourceSettings(settings,
|
|
40186
|
+
function editorSceneSettingsToSourceSettings(settings, options = {}) {
|
|
40204
40187
|
return mapSceneSettingAssetRefs(settings, (value, { category, property: property2 }) => {
|
|
40205
40188
|
if (value === null && !sourceAssetRefSettingAllowsNull(category, property2))
|
|
40206
40189
|
return void 0;
|
|
40207
|
-
return
|
|
40190
|
+
return editorAssetRefToSourceRefWithValidation(value, options.validateAssetRef);
|
|
40208
40191
|
});
|
|
40209
40192
|
}
|
|
40210
40193
|
var init_sceneSettingRefs = __esm({
|
|
@@ -40212,6 +40195,7 @@ var init_sceneSettingRefs = __esm({
|
|
|
40212
40195
|
"use strict";
|
|
40213
40196
|
init_sceneSettingDefinitions();
|
|
40214
40197
|
init_sceneSettingValueNormalization();
|
|
40198
|
+
init_source_ref_codec();
|
|
40215
40199
|
}
|
|
40216
40200
|
});
|
|
40217
40201
|
|
|
@@ -40430,7 +40414,7 @@ function assertSourceCallResult(value, kind, path23) {
|
|
|
40430
40414
|
assertSourceValueRecord(value.props, kind, `${path23}.props`);
|
|
40431
40415
|
assertSourceCalls(value.calls, kind, `${path23}.calls`);
|
|
40432
40416
|
}
|
|
40433
|
-
function
|
|
40417
|
+
function assertSourceAssetRef2(value, kind, path23) {
|
|
40434
40418
|
if (!isRecord(value)) {
|
|
40435
40419
|
throw new Error(`Invalid source v2 ${kind} file: ${path23} must be a v2 $ref object`);
|
|
40436
40420
|
}
|
|
@@ -40502,7 +40486,7 @@ function assertSourceComponentSchema(component2, kind, path23) {
|
|
|
40502
40486
|
throw new Error(`Invalid source v2 ${kind} file: ${path23}.type must be a non-empty string`);
|
|
40503
40487
|
}
|
|
40504
40488
|
if (component2.script !== void 0)
|
|
40505
|
-
|
|
40489
|
+
assertSourceAssetRef2(component2.script, kind, `${path23}.script`);
|
|
40506
40490
|
assertSourceValueRecord(component2.props, kind, `${path23}.props`);
|
|
40507
40491
|
assertCanonicalPostProcessProps(
|
|
40508
40492
|
component2.type,
|
|
@@ -40522,7 +40506,7 @@ function assertInlineComponentSchema(component2, kind, path23) {
|
|
|
40522
40506
|
throw new Error(`Invalid source v2 ${kind} file: ${path23}.type must be a non-empty string`);
|
|
40523
40507
|
}
|
|
40524
40508
|
if (component2.script !== void 0)
|
|
40525
|
-
|
|
40509
|
+
assertSourceAssetRef2(component2.script, kind, `${path23}.script`);
|
|
40526
40510
|
assertSourceValueRecord(component2.props, kind, `${path23}.props`);
|
|
40527
40511
|
assertCanonicalPostProcessProps(
|
|
40528
40512
|
component2.type,
|
|
@@ -40558,7 +40542,7 @@ function assertInlineEntitySchema(entity, kind, path23) {
|
|
|
40558
40542
|
throw new Error(`Invalid source v2 ${kind} file: ${path23}.instance must be an object`);
|
|
40559
40543
|
}
|
|
40560
40544
|
assertAllowedObjectKeys(entity.instance, SOURCE_V2_INSTANCE_KEYS, kind, `${path23}.instance`);
|
|
40561
|
-
|
|
40545
|
+
assertSourceAssetRef2(entity.instance.asset, kind, `${path23}.instance.asset`);
|
|
40562
40546
|
assertInstanceOverrides(entity.instance.overrides, kind, `${path23}.instance.overrides`);
|
|
40563
40547
|
return;
|
|
40564
40548
|
}
|
|
@@ -40679,7 +40663,7 @@ function assertSourceV2EntityArray(entities, kind) {
|
|
|
40679
40663
|
throw new Error(`Invalid source v2 ${kind} file: entities[${entityIndex}].instance must be an object`);
|
|
40680
40664
|
}
|
|
40681
40665
|
assertAllowedObjectKeys(entity.instance, SOURCE_V2_INSTANCE_KEYS, kind, `entities[${entityIndex}].instance`);
|
|
40682
|
-
|
|
40666
|
+
assertSourceAssetRef2(entity.instance.asset, kind, `entities[${entityIndex}].instance.asset`);
|
|
40683
40667
|
assertInstanceOverrides(entity.instance.overrides, kind, `entities[${entityIndex}].instance.overrides`);
|
|
40684
40668
|
const leakedBoundaryFields = ["children", "components"].filter((key2) => entity[key2] !== void 0);
|
|
40685
40669
|
if (leakedBoundaryFields.length > 0) {
|
|
@@ -40797,7 +40781,7 @@ function assertOptionalSourceAssetRef(value, kind, path23, options = {}) {
|
|
|
40797
40781
|
return;
|
|
40798
40782
|
if (value === null && options.allowNull)
|
|
40799
40783
|
return;
|
|
40800
|
-
|
|
40784
|
+
assertSourceAssetRef2(value, kind, path23);
|
|
40801
40785
|
}
|
|
40802
40786
|
function assertOptionalNumber(value, kind, path23) {
|
|
40803
40787
|
if (value === void 0)
|
|
@@ -41154,14 +41138,18 @@ var init_source_validator = __esm({
|
|
|
41154
41138
|
});
|
|
41155
41139
|
|
|
41156
41140
|
// ../model/src/scene-file-v2/prefab-overrides.ts
|
|
41157
|
-
function vec3TupleFromPartial(value,
|
|
41141
|
+
function vec3TupleFromPartial(value, source, field) {
|
|
41158
41142
|
if (!isRecord(value))
|
|
41159
41143
|
return void 0;
|
|
41160
|
-
|
|
41161
|
-
|
|
41162
|
-
typeof
|
|
41163
|
-
|
|
41164
|
-
|
|
41144
|
+
const resolveAxis = (axis) => {
|
|
41145
|
+
const axisValue = value[axis];
|
|
41146
|
+
if (typeof axisValue === "number")
|
|
41147
|
+
return axisValue;
|
|
41148
|
+
if (source)
|
|
41149
|
+
return source[axis];
|
|
41150
|
+
throw new Error(`Cannot serialize partial prefab ${field} override without source snapshot transform`);
|
|
41151
|
+
};
|
|
41152
|
+
return [resolveAxis("x"), resolveAxis("y"), resolveAxis("z")];
|
|
41165
41153
|
}
|
|
41166
41154
|
function cloneSourceTuple(value) {
|
|
41167
41155
|
if (!Array.isArray(value) || value.length < 3)
|
|
@@ -41169,8 +41157,8 @@ function cloneSourceTuple(value) {
|
|
|
41169
41157
|
const tuple2 = [Number(value[0]), Number(value[1]), Number(value[2])];
|
|
41170
41158
|
return tuple2.every(Number.isFinite) ? tuple2 : void 0;
|
|
41171
41159
|
}
|
|
41172
|
-
function entityOverridePropsToSource(props,
|
|
41173
|
-
const normalized = convertInternalRefsToSourceValue(props,
|
|
41160
|
+
function entityOverridePropsToSource(props, options = {}, sourceTransform) {
|
|
41161
|
+
const normalized = convertInternalRefsToSourceValue(props, options);
|
|
41174
41162
|
const result2 = {};
|
|
41175
41163
|
if (typeof normalized.name === "string")
|
|
41176
41164
|
result2.name = normalized.name;
|
|
@@ -41190,9 +41178,9 @@ function entityOverridePropsToSource(props, resolveRef3) {
|
|
|
41190
41178
|
if (scale2)
|
|
41191
41179
|
result2.scale = scale2;
|
|
41192
41180
|
if (isRecord(normalized.transform)) {
|
|
41193
|
-
const transformPosition = vec3TupleFromPartial(normalized.transform.position,
|
|
41194
|
-
const transformRotation = vec3TupleFromPartial(normalized.transform.rotation,
|
|
41195
|
-
const transformScale = vec3TupleFromPartial(normalized.transform.scale,
|
|
41181
|
+
const transformPosition = vec3TupleFromPartial(normalized.transform.position, sourceTransform?.position, "position");
|
|
41182
|
+
const transformRotation = vec3TupleFromPartial(normalized.transform.rotation, sourceTransform?.rotation, "rotation");
|
|
41183
|
+
const transformScale = vec3TupleFromPartial(normalized.transform.scale, sourceTransform?.scale, "scale");
|
|
41196
41184
|
if (transformPosition)
|
|
41197
41185
|
result2.position = transformPosition;
|
|
41198
41186
|
if (transformRotation)
|
|
@@ -41327,13 +41315,15 @@ function normalizePrefabRootInstanceOverrides(rootEntity, rootSourceEntityId) {
|
|
|
41327
41315
|
function prefabBindingToV2Overrides(state, binding, resolveRef3) {
|
|
41328
41316
|
if (!binding)
|
|
41329
41317
|
return void 0;
|
|
41318
|
+
const refOptions = createInternalAssetRefSerializeOptions(resolveRef3);
|
|
41330
41319
|
const overrides = {};
|
|
41331
41320
|
let hasData = false;
|
|
41332
41321
|
const entityProps = [];
|
|
41333
41322
|
for (const [sourceEntityId, props] of Object.entries(binding.overrides.entityProps ?? {})) {
|
|
41323
|
+
const sourceSnapshot = binding.sourceEntitySnapshots?.[sourceEntityId];
|
|
41334
41324
|
entityProps.push({
|
|
41335
41325
|
target: sourceEntityId,
|
|
41336
|
-
...entityOverridePropsToSource(props,
|
|
41326
|
+
...entityOverridePropsToSource(props, refOptions, sourceSnapshot?.transform)
|
|
41337
41327
|
});
|
|
41338
41328
|
}
|
|
41339
41329
|
if (entityProps.length) {
|
|
@@ -41347,7 +41337,7 @@ function prefabBindingToV2Overrides(state, binding, resolveRef3) {
|
|
|
41347
41337
|
continue;
|
|
41348
41338
|
componentProps.push({
|
|
41349
41339
|
target: sourceComponentKey,
|
|
41350
|
-
props: convertInternalRefsToSourceValue(props,
|
|
41340
|
+
props: convertInternalRefsToSourceValue(props, refOptions)
|
|
41351
41341
|
});
|
|
41352
41342
|
}
|
|
41353
41343
|
}
|
|
@@ -41413,7 +41403,6 @@ function prefabBindingsToV2OverridesForEntity(state, binding, resolveRef3) {
|
|
|
41413
41403
|
}
|
|
41414
41404
|
function parseSceneFileV2(sceneFile, entities, rootEntityIds, options = {}) {
|
|
41415
41405
|
assertSourceV2SceneFileStructure(sceneFile);
|
|
41416
|
-
const resolveSourceRef2 = options.resolveSourceRef;
|
|
41417
41406
|
const v2Entities = sceneFile.entities;
|
|
41418
41407
|
const v2Components = sceneFile.components;
|
|
41419
41408
|
const sourceIndex = buildSourceIdIndex(sceneFile);
|
|
@@ -41443,12 +41432,12 @@ function parseSceneFileV2(sceneFile, entities, rootEntityIds, options = {}) {
|
|
|
41443
41432
|
if (!sourceComponent) {
|
|
41444
41433
|
throw new Error(`Invalid source v2 scene file: component "${componentId}" must exist`);
|
|
41445
41434
|
}
|
|
41446
|
-
components[componentId] = sourceComponentToComponentState(sourceComponent
|
|
41435
|
+
components[componentId] = sourceComponentToComponentState(sourceComponent);
|
|
41447
41436
|
}
|
|
41448
41437
|
const parentId = parentById.get(entityId);
|
|
41449
41438
|
const instanceAssetRef = sourceEntity.instance?.asset?.$ref;
|
|
41450
|
-
const instanceAssetId = instanceAssetRef ? resolveRequiredSourceRef(instanceAssetRef
|
|
41451
|
-
const instanceAssetKind =
|
|
41439
|
+
const instanceAssetId = instanceAssetRef ? resolveRequiredSourceRef(instanceAssetRef) : null;
|
|
41440
|
+
const instanceAssetKind = instanceAssetId ? options.resolveAssetKind?.(instanceAssetId) : void 0;
|
|
41452
41441
|
const initialBinding = instanceAssetId ? findPrefabBindingForSourceEntity(options.initialPrefabState, entityId, {
|
|
41453
41442
|
assetId: instanceAssetId,
|
|
41454
41443
|
assetKind: instanceAssetKind
|
|
@@ -41493,13 +41482,7 @@ function parseSceneFileV2(sceneFile, entities, rootEntityIds, options = {}) {
|
|
|
41493
41482
|
entities[entityId] = entityState;
|
|
41494
41483
|
}
|
|
41495
41484
|
if (!options.deferPrefabInlineOverrideMaterialization) {
|
|
41496
|
-
materializeAddedOverridesFromSource(
|
|
41497
|
-
sceneFile,
|
|
41498
|
-
entities,
|
|
41499
|
-
resolveSourceRef2,
|
|
41500
|
-
options.resolveAssetKind,
|
|
41501
|
-
options.initialPrefabState
|
|
41502
|
-
);
|
|
41485
|
+
materializeAddedOverridesFromSource(sceneFile, entities, options.resolveAssetKind, options.initialPrefabState);
|
|
41503
41486
|
}
|
|
41504
41487
|
}
|
|
41505
41488
|
function assertInstanceOverridesDoNotRequireBinding(sourceEntity, sourceEntityId, rootOverrideTarget) {
|
|
@@ -41514,14 +41497,14 @@ function assertInstanceOverridesDoNotRequireBinding(sourceEntity, sourceEntityId
|
|
|
41514
41497
|
`Cannot parse source v2 instance entity "${sourceEntityId}" with sidecar-owned overrides without prefab binding state. Use hydrateSourceV2SceneToDomain, pass initialPrefabState, or defer prefab inline override materialization.`
|
|
41515
41498
|
);
|
|
41516
41499
|
}
|
|
41517
|
-
function sourceComponentToComponentState(component2
|
|
41500
|
+
function sourceComponentToComponentState(component2) {
|
|
41518
41501
|
assertCanonicalPostProcessProps(component2.type, component2.props, `source component ${component2.type}.props`);
|
|
41519
41502
|
return {
|
|
41520
41503
|
type: component2.type,
|
|
41521
|
-
...component2.script?.$ref ? { refId: resolveRequiredSourceRef(component2.script.$ref
|
|
41504
|
+
...component2.script?.$ref ? { refId: resolveRequiredSourceRef(component2.script.$ref) } : {},
|
|
41522
41505
|
...component2.script?.key ? { scriptKey: component2.script.key } : {},
|
|
41523
|
-
props: convertAssetRefsToDomainRefs(component2.props ?? {}
|
|
41524
|
-
...component2.calls?.length ? { calls: convertAssetRefsToDomainRefs(component2.calls
|
|
41506
|
+
props: convertAssetRefsToDomainRefs(component2.props ?? {}),
|
|
41507
|
+
...component2.calls?.length ? { calls: convertAssetRefsToDomainRefs(component2.calls) } : {}
|
|
41525
41508
|
};
|
|
41526
41509
|
}
|
|
41527
41510
|
function tupleToTransform(entity) {
|
|
@@ -41640,11 +41623,11 @@ function canMergeMaterializedNestedInstanceRoot(existing, sidecarBinding, instan
|
|
|
41640
41623
|
return false;
|
|
41641
41624
|
return sidecarBinding.instanceRootEntityId === existing.id;
|
|
41642
41625
|
}
|
|
41643
|
-
function materializeInlineAddedEntity(entities, binding, entityId, parentId, inlineEntity, prefabBindings,
|
|
41626
|
+
function materializeInlineAddedEntity(entities, binding, entityId, parentId, inlineEntity, prefabBindings, resolveAssetKind3, report, siblingIndex) {
|
|
41644
41627
|
const instanceAssetRef = inlineEntity.instance?.asset?.$ref;
|
|
41645
41628
|
if (instanceAssetRef) {
|
|
41646
|
-
const instanceAssetId = resolveRequiredSourceRef(instanceAssetRef
|
|
41647
|
-
const instanceAssetKind = resolveAssetKind3?.(
|
|
41629
|
+
const instanceAssetId = resolveRequiredSourceRef(instanceAssetRef);
|
|
41630
|
+
const instanceAssetKind = resolveAssetKind3?.(instanceAssetId);
|
|
41648
41631
|
const sidecarBinding = findPrefabBindingForSourceEntity(prefabBindings, entityId, {
|
|
41649
41632
|
assetId: instanceAssetId,
|
|
41650
41633
|
assetKind: instanceAssetKind
|
|
@@ -41690,7 +41673,6 @@ function materializeInlineAddedEntity(entities, binding, entityId, parentId, inl
|
|
|
41690
41673
|
sidecarBinding,
|
|
41691
41674
|
entities,
|
|
41692
41675
|
prefabBindings,
|
|
41693
|
-
resolveSourceRef2,
|
|
41694
41676
|
resolveAssetKind3,
|
|
41695
41677
|
report
|
|
41696
41678
|
);
|
|
@@ -41707,7 +41689,6 @@ function materializeInlineAddedEntity(entities, binding, entityId, parentId, inl
|
|
|
41707
41689
|
sidecarBinding,
|
|
41708
41690
|
entities,
|
|
41709
41691
|
prefabBindings,
|
|
41710
|
-
resolveSourceRef2,
|
|
41711
41692
|
resolveAssetKind3,
|
|
41712
41693
|
report
|
|
41713
41694
|
);
|
|
@@ -41719,7 +41700,7 @@ function materializeInlineAddedEntity(entities, binding, entityId, parentId, inl
|
|
|
41719
41700
|
componentEntries.forEach((component2, index2) => {
|
|
41720
41701
|
const componentId = `${entityId}:component-${index2}`;
|
|
41721
41702
|
components[componentId] = {
|
|
41722
|
-
...sourceComponentToComponentState(component2
|
|
41703
|
+
...sourceComponentToComponentState(component2),
|
|
41723
41704
|
instance: { bindingId: binding.id, role: "added" }
|
|
41724
41705
|
};
|
|
41725
41706
|
});
|
|
@@ -41754,14 +41735,13 @@ function materializeInlineAddedEntity(entities, binding, entityId, parentId, inl
|
|
|
41754
41735
|
entityId,
|
|
41755
41736
|
child,
|
|
41756
41737
|
prefabBindings,
|
|
41757
|
-
resolveSourceRef2,
|
|
41758
41738
|
resolveAssetKind3,
|
|
41759
41739
|
report,
|
|
41760
41740
|
index2
|
|
41761
41741
|
);
|
|
41762
41742
|
});
|
|
41763
41743
|
}
|
|
41764
|
-
function materializeAddedOverridesForBinding(overrides, binding, entities, prefabBindings,
|
|
41744
|
+
function materializeAddedOverridesForBinding(overrides, binding, entities, prefabBindings, resolveAssetKind3, report) {
|
|
41765
41745
|
const addedEntityBuckets = /* @__PURE__ */ new Map();
|
|
41766
41746
|
for (const added of Object.values(binding.overrides.addedEntities ?? {})) {
|
|
41767
41747
|
const bucket = addedEntityBuckets.get(added.parentSourceEntityId) ?? [];
|
|
@@ -41788,7 +41768,6 @@ function materializeAddedOverridesForBinding(overrides, binding, entities, prefa
|
|
|
41788
41768
|
parentSceneEntityId,
|
|
41789
41769
|
override3.entity,
|
|
41790
41770
|
prefabBindings,
|
|
41791
|
-
resolveSourceRef2,
|
|
41792
41771
|
resolveAssetKind3,
|
|
41793
41772
|
report,
|
|
41794
41773
|
added.index
|
|
@@ -41798,7 +41777,7 @@ function materializeAddedOverridesForBinding(overrides, binding, entities, prefa
|
|
|
41798
41777
|
overrides.addedComponents?.forEach((override3) => {
|
|
41799
41778
|
const ownerSourceEntityId = override3.owner;
|
|
41800
41779
|
const candidates = Object.values(binding.overrides.addedComponents?.[ownerSourceEntityId] ?? {});
|
|
41801
|
-
const component2 = sourceComponentToComponentState(override3.component
|
|
41780
|
+
const component2 = sourceComponentToComponentState(override3.component);
|
|
41802
41781
|
const inlineAdded = selectAddedComponentSidecarEntry(
|
|
41803
41782
|
candidates,
|
|
41804
41783
|
consumedAddedComponents,
|
|
@@ -41822,15 +41801,15 @@ function materializeAddedOverridesForBinding(overrides, binding, entities, prefa
|
|
|
41822
41801
|
recordMaterializedAddedComponent(report, binding.id, added.ownerSourceEntityId, added.componentId);
|
|
41823
41802
|
});
|
|
41824
41803
|
}
|
|
41825
|
-
function materializeAddedOverridesFromSource(sceneFile, entities,
|
|
41804
|
+
function materializeAddedOverridesFromSource(sceneFile, entities, resolveAssetKind3, prefabBindings, report) {
|
|
41826
41805
|
sceneFile.entities.forEach((sourceEntity) => {
|
|
41827
41806
|
const overrides = sourceEntity.instance?.overrides;
|
|
41828
41807
|
if (!overrides)
|
|
41829
41808
|
return;
|
|
41830
41809
|
const rootEntityId = sourceEntity.id;
|
|
41831
41810
|
const instanceAssetRef = sourceEntity.instance?.asset?.$ref;
|
|
41832
|
-
const instanceAssetId = instanceAssetRef ? resolveRequiredSourceRef(instanceAssetRef
|
|
41833
|
-
const instanceAssetKind =
|
|
41811
|
+
const instanceAssetId = instanceAssetRef ? resolveRequiredSourceRef(instanceAssetRef) : void 0;
|
|
41812
|
+
const instanceAssetKind = instanceAssetId ? resolveAssetKind3?.(instanceAssetId) : void 0;
|
|
41834
41813
|
const binding = rootEntityId ? findPrefabBindingForSourceEntity(prefabBindings, rootEntityId, {
|
|
41835
41814
|
assetId: instanceAssetId,
|
|
41836
41815
|
assetKind: instanceAssetKind
|
|
@@ -41843,15 +41822,7 @@ function materializeAddedOverridesFromSource(sceneFile, entities, resolveSourceR
|
|
|
41843
41822
|
}
|
|
41844
41823
|
return;
|
|
41845
41824
|
}
|
|
41846
|
-
materializeAddedOverridesForBinding(
|
|
41847
|
-
overrides,
|
|
41848
|
-
binding,
|
|
41849
|
-
entities,
|
|
41850
|
-
prefabBindings,
|
|
41851
|
-
resolveSourceRef2,
|
|
41852
|
-
resolveAssetKind3,
|
|
41853
|
-
report
|
|
41854
|
-
);
|
|
41825
|
+
materializeAddedOverridesForBinding(overrides, binding, entities, prefabBindings, resolveAssetKind3, report);
|
|
41855
41826
|
});
|
|
41856
41827
|
}
|
|
41857
41828
|
function hasNonEmptyArray(value) {
|
|
@@ -41885,41 +41856,35 @@ function findBindingForSerializableInstance(state, entity) {
|
|
|
41885
41856
|
}
|
|
41886
41857
|
return findPrefabBindingForSourceEntity(state.prefab, entity.id, expected) ?? void 0;
|
|
41887
41858
|
}
|
|
41888
|
-
function
|
|
41889
|
-
|
|
41890
|
-
|
|
41891
|
-
|
|
41892
|
-
|
|
41893
|
-
sceneSettings = editorSceneSettingsToSourceSettings(
|
|
41894
|
-
state.scene.settings,
|
|
41895
|
-
resolveRef3
|
|
41896
|
-
);
|
|
41897
|
-
} catch (err2) {
|
|
41898
|
-
if (err2 instanceof SceneV2DanglingAssetRefError) {
|
|
41899
|
-
console.warn(`[SceneV2] scene settings dangling ref, settings \u6574\u4F53\u8DF3\u8FC7: ${err2.message}`);
|
|
41900
|
-
sceneSettings = void 0;
|
|
41901
|
-
} else {
|
|
41902
|
-
throw err2;
|
|
41903
|
-
}
|
|
41859
|
+
function createSerializeAssetRefResolver(options) {
|
|
41860
|
+
return (assetId) => {
|
|
41861
|
+
const sourceRef = assertAndReturnSourceAssetRef(assetId);
|
|
41862
|
+
if (options.assetExists && !options.assetExists(sourceRef)) {
|
|
41863
|
+
throw new SceneV2DanglingAssetRefError(sourceRef);
|
|
41904
41864
|
}
|
|
41905
|
-
|
|
41865
|
+
return sourceRef;
|
|
41866
|
+
};
|
|
41867
|
+
}
|
|
41868
|
+
function createInternalAssetRefSerializeOptions(resolveRef3) {
|
|
41869
|
+
return {
|
|
41870
|
+
validateAssetRef: (assetId) => {
|
|
41871
|
+
resolveRef3(assetId);
|
|
41872
|
+
}
|
|
41873
|
+
};
|
|
41874
|
+
}
|
|
41875
|
+
function domainStateToSceneFileV2(state, _options = {}) {
|
|
41876
|
+
const resolveRef3 = createSerializeAssetRefResolver(_options);
|
|
41877
|
+
const refOptions = createInternalAssetRefSerializeOptions(resolveRef3);
|
|
41878
|
+
const sceneSettings = state.scene.settings ? editorSceneSettingsToSourceSettings(state.scene.settings, refOptions) : void 0;
|
|
41906
41879
|
const ordered = orderSceneEntities(state);
|
|
41907
41880
|
const components = [];
|
|
41908
41881
|
const candidateEntityIds = ordered.map((entity) => entity.id);
|
|
41909
41882
|
const entities = ordered.map((entity) => {
|
|
41910
41883
|
const entityComponentsBuffer = [];
|
|
41911
|
-
|
|
41912
|
-
|
|
41913
|
-
|
|
41914
|
-
|
|
41915
|
-
} catch (err2) {
|
|
41916
|
-
if (err2 instanceof SceneV2DanglingAssetRefError) {
|
|
41917
|
-
console.warn(`[SceneV2] skip entity "${entity.id}" (name="${entity.name}") from save: ${err2.message}`);
|
|
41918
|
-
return null;
|
|
41919
|
-
}
|
|
41920
|
-
throw err2;
|
|
41921
|
-
}
|
|
41922
|
-
}).filter((e6) => e6 !== null);
|
|
41884
|
+
const result3 = serializeOneEntity(entity, entityComponentsBuffer, candidateEntityIds);
|
|
41885
|
+
components.push(...entityComponentsBuffer);
|
|
41886
|
+
return result3;
|
|
41887
|
+
});
|
|
41923
41888
|
const validEntityIds = new Set(entities.map((e6) => e6.id));
|
|
41924
41889
|
for (const entity of entities) {
|
|
41925
41890
|
if (!entity.children)
|
|
@@ -42010,13 +41975,11 @@ function domainStateToSceneFileV2(state, optionsOrResolveAssetRef = {}) {
|
|
|
42010
41975
|
}
|
|
42011
41976
|
function buildSourceSceneFile(root3, currentAssetId) {
|
|
42012
41977
|
return domainStateToSceneFileV2(root3.domainStore.state, {
|
|
42013
|
-
resolveAssetRef: (assetId) => root3.assetStore?.getAssetVirtualPath?.(assetId),
|
|
42014
41978
|
currentAssetId
|
|
42015
41979
|
});
|
|
42016
41980
|
}
|
|
42017
|
-
function domainStateToPrefabFileV2(state, rootEntityId,
|
|
42018
|
-
const currentAssetId =
|
|
42019
|
-
const resolveRef3 = createAssetRefResolver(optionsOrResolveAssetRef);
|
|
41981
|
+
function domainStateToPrefabFileV2(state, rootEntityId, options = {}) {
|
|
41982
|
+
const currentAssetId = options.currentAssetId;
|
|
42020
41983
|
const selectedEntityIds = collectPrefabEntityIds(state, rootEntityId, currentAssetId);
|
|
42021
41984
|
const selectedEntityIdSet = new Set(selectedEntityIds);
|
|
42022
41985
|
collectPrefabInlineOverrideEntityIds(state, selectedEntityIdSet);
|
|
@@ -42048,7 +42011,7 @@ function domainStateToPrefabFileV2(state, rootEntityId, optionsOrResolveAssetRef
|
|
|
42048
42011
|
entities,
|
|
42049
42012
|
prefab: state.prefab
|
|
42050
42013
|
},
|
|
42051
|
-
|
|
42014
|
+
options
|
|
42052
42015
|
);
|
|
42053
42016
|
const root3 = sceneFile.scene.rootEntities[0];
|
|
42054
42017
|
if (root3 === void 0) {
|
|
@@ -42086,16 +42049,6 @@ function collectPrefabInlineOverrideEntityIds(state, selectedEntityIdSet) {
|
|
|
42086
42049
|
}
|
|
42087
42050
|
}
|
|
42088
42051
|
}
|
|
42089
|
-
function createAssetRefResolver(optionsOrResolveAssetRef) {
|
|
42090
|
-
const resolveAssetRef2 = typeof optionsOrResolveAssetRef === "function" ? optionsOrResolveAssetRef : optionsOrResolveAssetRef.resolveAssetRef;
|
|
42091
|
-
return (assetId) => {
|
|
42092
|
-
const sourceRef = resolveAssetRef2?.(assetId);
|
|
42093
|
-
if (typeof sourceRef !== "string" || sourceRef.length === 0) {
|
|
42094
|
-
throw new SceneV2DanglingAssetRefError(assetId);
|
|
42095
|
-
}
|
|
42096
|
-
return sourceRef;
|
|
42097
|
-
};
|
|
42098
|
-
}
|
|
42099
42052
|
function entityStateToInlineEntity(state, entityId, resolveRef3) {
|
|
42100
42053
|
const entity = state.entities[entityId];
|
|
42101
42054
|
if (!entity)
|
|
@@ -42176,7 +42129,8 @@ function collectPrefabEntityIds(state, rootEntityId, currentAssetId) {
|
|
|
42176
42129
|
return ordered;
|
|
42177
42130
|
}
|
|
42178
42131
|
function componentStateToSourceComponent(componentId, component2, resolveRef3) {
|
|
42179
|
-
const
|
|
42132
|
+
const refOptions = createInternalAssetRefSerializeOptions(resolveRef3);
|
|
42133
|
+
const props = convertInternalRefsToSourceValue(component2.props ?? {}, refOptions);
|
|
42180
42134
|
assertCanonicalPostProcessProps(component2.type, props, `domain component ${component2.type}.props`);
|
|
42181
42135
|
return {
|
|
42182
42136
|
id: componentId,
|
|
@@ -42188,7 +42142,7 @@ function componentStateToSourceComponent(componentId, component2, resolveRef3) {
|
|
|
42188
42142
|
}
|
|
42189
42143
|
} : {},
|
|
42190
42144
|
props,
|
|
42191
|
-
...component2.calls?.length ? { calls: convertInternalRefsToSourceValue(component2.calls,
|
|
42145
|
+
...component2.calls?.length ? { calls: convertInternalRefsToSourceValue(component2.calls, refOptions) } : {}
|
|
42192
42146
|
};
|
|
42193
42147
|
}
|
|
42194
42148
|
function isMaterializedInstanceLinkedEntity(state, entity) {
|
|
@@ -42242,12 +42196,13 @@ var init_domain_codec = __esm({
|
|
|
42242
42196
|
init_source_validator();
|
|
42243
42197
|
init_source_id_index();
|
|
42244
42198
|
init_source_value();
|
|
42199
|
+
init_source_ref_codec();
|
|
42245
42200
|
init_prefab_overrides();
|
|
42246
42201
|
init_prefab_override_utils();
|
|
42247
42202
|
SCENE_V2_DANGLING_REF_SENTINEL = Symbol("SceneV2DanglingAssetRef");
|
|
42248
42203
|
SceneV2DanglingAssetRefError = class extends Error {
|
|
42249
42204
|
constructor(assetId) {
|
|
42250
|
-
super(`[SceneV2] dangling asset ref "${assetId}"
|
|
42205
|
+
super(`[SceneV2] dangling asset ref "${assetId}"`);
|
|
42251
42206
|
this.assetId = assetId;
|
|
42252
42207
|
this.name = "SceneV2DanglingAssetRefError";
|
|
42253
42208
|
}
|
|
@@ -42546,14 +42501,14 @@ var init_prefab_source_structural_edit = __esm({
|
|
|
42546
42501
|
});
|
|
42547
42502
|
|
|
42548
42503
|
// ../model/src/scene-file-v2/scene-settings.ts
|
|
42549
|
-
function extractSceneSettings(scene
|
|
42504
|
+
function extractSceneSettings(scene) {
|
|
42550
42505
|
if (!scene || typeof scene !== "object")
|
|
42551
42506
|
return void 0;
|
|
42552
42507
|
const settings = { ...scene };
|
|
42553
42508
|
delete settings.rootEntities;
|
|
42554
42509
|
if (Object.keys(settings).length === 0)
|
|
42555
42510
|
return void 0;
|
|
42556
|
-
return convertAssetRefsToDomainRefs(settings
|
|
42511
|
+
return convertAssetRefsToDomainRefs(settings);
|
|
42557
42512
|
}
|
|
42558
42513
|
var init_scene_settings = __esm({
|
|
42559
42514
|
"../model/src/scene-file-v2/scene-settings.ts"() {
|
|
@@ -44597,7 +44552,7 @@ function createResolveInstanceAssetKind(options) {
|
|
|
44597
44552
|
return options.resolveInstanceAssetKind;
|
|
44598
44553
|
if (!options.resolveAssetKind)
|
|
44599
44554
|
return void 0;
|
|
44600
|
-
return (sourceRef) => options.resolveAssetKind?.(sourceRef
|
|
44555
|
+
return (sourceRef) => options.resolveAssetKind?.(sourceRef);
|
|
44601
44556
|
}
|
|
44602
44557
|
var init_compile_scene_like_blob_to_runtime = __esm({
|
|
44603
44558
|
"../builder/utils/compile-scene-like-blob-to-runtime.ts"() {
|
|
@@ -44695,27 +44650,15 @@ function resolveBuildAssetRef(context, ref) {
|
|
|
44695
44650
|
const byId = requireBuildPath(context.fileMap.get(ref), ref);
|
|
44696
44651
|
if (byId)
|
|
44697
44652
|
return byId;
|
|
44698
|
-
const byPath = resolveBuildPathByVirtualPath(context, ref);
|
|
44699
|
-
if (byPath)
|
|
44700
|
-
return byPath;
|
|
44701
44653
|
throw new Error(`Unable to resolve source asset ref "${ref}" to a build path`);
|
|
44702
44654
|
}
|
|
44703
44655
|
function resolveBuildSourceAssetRef(context, ref) {
|
|
44704
|
-
|
|
44705
|
-
const
|
|
44706
|
-
if (
|
|
44707
|
-
return
|
|
44656
|
+
assertSourceAssetRef(ref);
|
|
44657
|
+
const byId = requireBuildPath(context.fileMap.get(ref), ref);
|
|
44658
|
+
if (byId)
|
|
44659
|
+
return byId;
|
|
44708
44660
|
throw new Error(`Unable to resolve source asset ref "${ref}" to a build path`);
|
|
44709
44661
|
}
|
|
44710
|
-
function resolveBuildPathByVirtualPath(context, ref) {
|
|
44711
|
-
const pathCandidates = [`/${ref}`, ref];
|
|
44712
|
-
for (const path23 of pathCandidates) {
|
|
44713
|
-
const byPath = requireBuildPath(context.getFileByPath(path23), ref);
|
|
44714
|
-
if (byPath)
|
|
44715
|
-
return byPath;
|
|
44716
|
-
}
|
|
44717
|
-
return void 0;
|
|
44718
|
-
}
|
|
44719
44662
|
var init_build_asset_ref_resolver = __esm({
|
|
44720
44663
|
"../builder/utils/build-asset-ref-resolver.ts"() {
|
|
44721
44664
|
"use strict";
|
|
@@ -44725,21 +44668,9 @@ var init_build_asset_ref_resolver = __esm({
|
|
|
44725
44668
|
});
|
|
44726
44669
|
|
|
44727
44670
|
// ../builder/utils/resolve-source-file.ts
|
|
44728
|
-
function lookupByPath(vfs, path23) {
|
|
44729
|
-
if (vfs.getFileByPath)
|
|
44730
|
-
return vfs.getFileByPath(path23);
|
|
44731
|
-
return vfs.filePathMap?.get(path23);
|
|
44732
|
-
}
|
|
44733
44671
|
function resolveSourceFileByVirtualPath(vfs, value) {
|
|
44734
|
-
|
|
44735
|
-
return
|
|
44736
|
-
}
|
|
44737
|
-
function lookupSourceFileByVirtualPath(vfs, value) {
|
|
44738
|
-
const normalized = value.startsWith("/") ? value : `/${value}`;
|
|
44739
|
-
return lookupByPath(vfs, normalized);
|
|
44740
|
-
}
|
|
44741
|
-
function resolveSourceRef(vfs, value) {
|
|
44742
|
-
return resolveSourceFileByVirtualPath(vfs, value)?.id ?? value;
|
|
44672
|
+
assertSourceAssetRef(value);
|
|
44673
|
+
return vfs.fileMap.get(value);
|
|
44743
44674
|
}
|
|
44744
44675
|
function resolveAssetKind(vfs, value) {
|
|
44745
44676
|
const type = String(resolveSourceFileByVirtualPath(vfs, value)?.meta?.type ?? "");
|
|
@@ -44846,7 +44777,7 @@ function importSourceRefs(obj, resolve5) {
|
|
|
44846
44777
|
return convertRefs(obj, SOURCE_IMPORT_RULES, (value) => {
|
|
44847
44778
|
const resolved = resolve5(value);
|
|
44848
44779
|
if (resolved !== void 0)
|
|
44849
|
-
|
|
44780
|
+
assertSourceAssetRef(resolved, "source import");
|
|
44850
44781
|
return resolved;
|
|
44851
44782
|
});
|
|
44852
44783
|
}
|
|
@@ -69139,7 +69070,7 @@ var require_main2 = __commonJS({
|
|
|
69139
69070
|
array2.length--;
|
|
69140
69071
|
return true;
|
|
69141
69072
|
};
|
|
69142
|
-
Utils4.decodeText = function
|
|
69073
|
+
Utils4.decodeText = function decodeText3(array2) {
|
|
69143
69074
|
if (typeof TextDecoder !== "undefined") {
|
|
69144
69075
|
return new TextDecoder().decode(array2);
|
|
69145
69076
|
}
|
|
@@ -123819,20 +123750,17 @@ function derivePrefabSourceSnapshotsFromFile(binding, prefabFile, options, compo
|
|
|
123819
123750
|
components[sourceComponentKey] = {
|
|
123820
123751
|
sceneComponentId,
|
|
123821
123752
|
type: sourceComponent.type,
|
|
123822
|
-
...sourceComponent.script?.$ref ? { refId:
|
|
123753
|
+
...sourceComponent.script?.$ref ? { refId: resolveRequiredSourceRef(sourceComponent.script.$ref) } : {},
|
|
123823
123754
|
...sourceComponent.script?.key ? { scriptKey: sourceComponent.script.key } : {},
|
|
123824
|
-
props: convertAssetRefsToDomainRefs(sourceComponent.props ?? {}
|
|
123755
|
+
props: convertAssetRefsToDomainRefs(sourceComponent.props ?? {}),
|
|
123825
123756
|
...sourceComponent.calls?.length ? {
|
|
123826
|
-
calls: convertAssetRefsToDomainRefs(
|
|
123827
|
-
sourceComponent.calls,
|
|
123828
|
-
options.resolveSourceRef
|
|
123829
|
-
)
|
|
123757
|
+
calls: convertAssetRefsToDomainRefs(sourceComponent.calls)
|
|
123830
123758
|
} : {}
|
|
123831
123759
|
};
|
|
123832
123760
|
}
|
|
123833
123761
|
const instanceRef = sourceEntity.instance?.asset?.$ref;
|
|
123834
|
-
const assetId = instanceRef ?
|
|
123835
|
-
const instanceAssetKind =
|
|
123762
|
+
const assetId = instanceRef ? resolveRequiredSourceRef(instanceRef) : void 0;
|
|
123763
|
+
const instanceAssetKind = assetId ? resolveSourceAssetKind(assetId, options, "nested instance") : void 0;
|
|
123836
123764
|
const rootOverrideTarget = resolveSourceInstanceRootOverrideTarget({
|
|
123837
123765
|
sourceEntity,
|
|
123838
123766
|
fallbackSourceEntityId: sourceEntityId,
|
|
@@ -123869,18 +123797,11 @@ function findExactPreviousSourceComponentSnapshot(previousSnapshot, sourceCompon
|
|
|
123869
123797
|
const exact = previousSnapshot?.components?.[sourceComponentKey];
|
|
123870
123798
|
return exact?.type === sourceComponent.type ? exact : void 0;
|
|
123871
123799
|
}
|
|
123872
|
-
function
|
|
123873
|
-
const
|
|
123874
|
-
if (typeof assetId !== "string" || assetId.length === 0) {
|
|
123875
|
-
throw new Error(`Unable to resolve source asset ref "${ref}" to an editor asset id while refreshing ${label}`);
|
|
123876
|
-
}
|
|
123877
|
-
return assetId;
|
|
123878
|
-
}
|
|
123879
|
-
function resolveSourceAssetKind(ref, assetId, options, label) {
|
|
123880
|
-
const assetKind = options.resolveAssetKind?.(ref, assetId);
|
|
123800
|
+
function resolveSourceAssetKind(assetId, options, label) {
|
|
123801
|
+
const assetKind = options.resolveAssetKind?.(assetId);
|
|
123881
123802
|
if (assetKind !== "Prefab" && assetKind !== "glTF") {
|
|
123882
123803
|
throw new Error(
|
|
123883
|
-
`Unable to resolve supported source asset kind for "${
|
|
123804
|
+
`Unable to resolve supported source asset kind for "${assetId}" while refreshing ${label}; expected Prefab or glTF`
|
|
123884
123805
|
);
|
|
123885
123806
|
}
|
|
123886
123807
|
return assetKind;
|
|
@@ -123986,7 +123907,7 @@ function requireInlineOverrideId(explicitId, inlineId, label) {
|
|
|
123986
123907
|
}
|
|
123987
123908
|
return id;
|
|
123988
123909
|
}
|
|
123989
|
-
function seedPrefabOverridesFromInlineSource(overrides, prefabFile
|
|
123910
|
+
function seedPrefabOverridesFromInlineSource(overrides, prefabFile) {
|
|
123990
123911
|
const next = createEmptyPrefabOverrides();
|
|
123991
123912
|
if (!overrides)
|
|
123992
123913
|
return next;
|
|
@@ -123998,7 +123919,7 @@ function seedPrefabOverridesFromInlineSource(overrides, prefabFile, resolveSourc
|
|
|
123998
123919
|
if (!sourceIndex.entityById.has(override3.target)) {
|
|
123999
123920
|
throw new Error(`Invalid source v2 scene file: entityProps override target "${override3.target}" does not exist`);
|
|
124000
123921
|
}
|
|
124001
|
-
next.entityProps[override3.target] = inlineEntityOverrideToDomainProps(override3
|
|
123922
|
+
next.entityProps[override3.target] = inlineEntityOverrideToDomainProps(override3);
|
|
124002
123923
|
}
|
|
124003
123924
|
for (const override3 of overrides.componentProps ?? []) {
|
|
124004
123925
|
if (typeof override3.target !== "string") {
|
|
@@ -124011,7 +123932,7 @@ function seedPrefabOverridesFromInlineSource(overrides, prefabFile, resolveSourc
|
|
|
124011
123932
|
);
|
|
124012
123933
|
}
|
|
124013
123934
|
const bucket = next.componentProps[ownerSourceEntityId] ??= {};
|
|
124014
|
-
bucket[override3.target] = convertAssetRefsToDomainRefs(override3.props ?? {}
|
|
123935
|
+
bucket[override3.target] = convertAssetRefsToDomainRefs(override3.props ?? {});
|
|
124015
123936
|
}
|
|
124016
123937
|
for (const sourceEntityId of overrides.removedEntities ?? []) {
|
|
124017
123938
|
if (!sourceIndex.entityById.has(sourceEntityId)) {
|
|
@@ -124056,11 +123977,11 @@ function seedPrefabOverridesFromInlineSource(overrides, prefabFile, resolveSourc
|
|
|
124056
123977
|
ownerSourceEntityId: override3.owner,
|
|
124057
123978
|
type: component2.type,
|
|
124058
123979
|
...component2.script?.$ref ? {
|
|
124059
|
-
refId:
|
|
123980
|
+
refId: resolveRequiredSourceRef(component2.script.$ref),
|
|
124060
123981
|
...component2.script.key ? { scriptKey: component2.script.key } : {}
|
|
124061
123982
|
} : {},
|
|
124062
|
-
props: convertAssetRefsToDomainRefs(component2.props ?? {}
|
|
124063
|
-
...component2.calls?.length ? { calls: convertAssetRefsToDomainRefs(component2.calls
|
|
123983
|
+
props: convertAssetRefsToDomainRefs(component2.props ?? {}),
|
|
123984
|
+
...component2.calls?.length ? { calls: convertAssetRefsToDomainRefs(component2.calls) } : {}
|
|
124064
123985
|
};
|
|
124065
123986
|
}
|
|
124066
123987
|
return next;
|
|
@@ -124070,13 +123991,13 @@ function requireRootOnlyGLTFOverrideTarget(target, label) {
|
|
|
124070
123991
|
return;
|
|
124071
123992
|
throw new Error(`Invalid source v2 scene file: glTF ${label} target "${target}" is not the synthetic root`);
|
|
124072
123993
|
}
|
|
124073
|
-
function seedRootOnlyGLTFOverridesFromInlineSource(overrides
|
|
123994
|
+
function seedRootOnlyGLTFOverridesFromInlineSource(overrides) {
|
|
124074
123995
|
const next = createEmptyPrefabOverrides();
|
|
124075
123996
|
if (!overrides)
|
|
124076
123997
|
return next;
|
|
124077
123998
|
for (const override3 of overrides.entityProps ?? []) {
|
|
124078
123999
|
requireRootOnlyGLTFOverrideTarget(override3.target, "entityProps");
|
|
124079
|
-
next.entityProps.root = inlineEntityOverrideToDomainProps(override3
|
|
124000
|
+
next.entityProps.root = inlineEntityOverrideToDomainProps(override3);
|
|
124080
124001
|
}
|
|
124081
124002
|
for (const sourceEntityId of overrides.removedEntities ?? []) {
|
|
124082
124003
|
requireRootOnlyGLTFOverrideTarget(sourceEntityId, "removed entity");
|
|
@@ -124112,11 +124033,11 @@ function seedRootOnlyGLTFOverridesFromInlineSource(overrides, resolveSourceRef2)
|
|
|
124112
124033
|
ownerSourceEntityId: "root",
|
|
124113
124034
|
type: component2.type,
|
|
124114
124035
|
...component2.script?.$ref ? {
|
|
124115
|
-
refId:
|
|
124036
|
+
refId: resolveRequiredSourceRef(component2.script.$ref),
|
|
124116
124037
|
...component2.script.key ? { scriptKey: component2.script.key } : {}
|
|
124117
124038
|
} : {},
|
|
124118
|
-
props: convertAssetRefsToDomainRefs(component2.props ?? {}
|
|
124119
|
-
...component2.calls?.length ? { calls: convertAssetRefsToDomainRefs(component2.calls
|
|
124039
|
+
props: convertAssetRefsToDomainRefs(component2.props ?? {}),
|
|
124040
|
+
...component2.calls?.length ? { calls: convertAssetRefsToDomainRefs(component2.calls) } : {}
|
|
124120
124041
|
};
|
|
124121
124042
|
}
|
|
124122
124043
|
return next;
|
|
@@ -124303,8 +124224,8 @@ function seedSourceSceneInstanceBindings(prefab, sceneFile, options) {
|
|
|
124303
124224
|
const sourceRef = entity.instance?.asset?.$ref;
|
|
124304
124225
|
if (!sourceRef)
|
|
124305
124226
|
continue;
|
|
124306
|
-
const assetId =
|
|
124307
|
-
const assetKind = resolveSourceAssetKind(
|
|
124227
|
+
const assetId = resolveRequiredSourceRef(sourceRef);
|
|
124228
|
+
const assetKind = resolveSourceAssetKind(assetId, options, "scene instance");
|
|
124308
124229
|
if (assetKind !== "Prefab" && assetKind !== "glTF")
|
|
124309
124230
|
continue;
|
|
124310
124231
|
if (findBindingForInstanceRoot(next, entity.id, { assetId, assetKind })) {
|
|
@@ -124326,11 +124247,7 @@ function seedSourceSceneInstanceBindings(prefab, sceneFile, options) {
|
|
|
124326
124247
|
assertSourceV2PrefabFileStructure(prefabFile);
|
|
124327
124248
|
const sourceRootEntityId = prefabFile.root;
|
|
124328
124249
|
const bindingId = `binding-${assetId}-${entity.id}`;
|
|
124329
|
-
const overrides = seedPrefabOverridesFromInlineSource(
|
|
124330
|
-
entity.instance?.overrides,
|
|
124331
|
-
prefabFile,
|
|
124332
|
-
options.resolveSourceRef
|
|
124333
|
-
);
|
|
124250
|
+
const overrides = seedPrefabOverridesFromInlineSource(entity.instance?.overrides, prefabFile);
|
|
124334
124251
|
binding = {
|
|
124335
124252
|
id: bindingId,
|
|
124336
124253
|
assetId,
|
|
@@ -124359,10 +124276,7 @@ function seedSourceSceneInstanceBindings(prefab, sceneFile, options) {
|
|
|
124359
124276
|
sceneEntityId: entity.id
|
|
124360
124277
|
})
|
|
124361
124278
|
},
|
|
124362
|
-
overrides: seedRootOnlyGLTFOverridesFromInlineSource(
|
|
124363
|
-
entity.instance?.overrides,
|
|
124364
|
-
options.resolveSourceRef
|
|
124365
|
-
)
|
|
124279
|
+
overrides: seedRootOnlyGLTFOverridesFromInlineSource(entity.instance?.overrides)
|
|
124366
124280
|
};
|
|
124367
124281
|
}
|
|
124368
124282
|
next.bindings[binding.id] = binding;
|
|
@@ -124391,9 +124305,9 @@ function sourceVec3Override(value) {
|
|
|
124391
124305
|
const [x3, y5, z3] = value;
|
|
124392
124306
|
return typeof x3 === "number" && typeof y5 === "number" && typeof z3 === "number" ? { x: x3, y: y5, z: z3 } : void 0;
|
|
124393
124307
|
}
|
|
124394
|
-
function inlineEntityOverrideToDomainProps(item
|
|
124308
|
+
function inlineEntityOverrideToDomainProps(item) {
|
|
124395
124309
|
const { target, position, rotation, scale: scale2, ...rest2 } = item;
|
|
124396
|
-
const props = convertAssetRefsToDomainRefs(rest2
|
|
124310
|
+
const props = convertAssetRefsToDomainRefs(rest2);
|
|
124397
124311
|
const transform5 = {};
|
|
124398
124312
|
const nextPosition = sourceVec3Override(position);
|
|
124399
124313
|
const nextRotation = sourceVec3Override(rotation);
|
|
@@ -124441,8 +124355,8 @@ function prunePrefabBindingsToReachableSourceInstances(sceneFile, prefab, option
|
|
|
124441
124355
|
const sourceRef = sourceEntity?.instance?.asset?.$ref;
|
|
124442
124356
|
if (!sourceEntity || !sourceEntityId || !sourceRef)
|
|
124443
124357
|
continue;
|
|
124444
|
-
const assetId =
|
|
124445
|
-
const assetKind = resolveSourceAssetKind(
|
|
124358
|
+
const assetId = resolveRequiredSourceRef(sourceRef);
|
|
124359
|
+
const assetKind = resolveSourceAssetKind(assetId, options, "nested instance");
|
|
124446
124360
|
const sceneEntityId = getSceneEntityIdForSourceEntity(binding, sourceEntityId);
|
|
124447
124361
|
if (!sceneEntityId)
|
|
124448
124362
|
continue;
|
|
@@ -124456,8 +124370,8 @@ function prunePrefabBindingsToReachableSourceInstances(sceneFile, prefab, option
|
|
|
124456
124370
|
const sourceRef = entity.instance?.asset?.$ref;
|
|
124457
124371
|
if (!entityId || !sourceRef)
|
|
124458
124372
|
return;
|
|
124459
|
-
const assetId =
|
|
124460
|
-
const assetKind = resolveSourceAssetKind(
|
|
124373
|
+
const assetId = resolveRequiredSourceRef(sourceRef);
|
|
124374
|
+
const assetKind = resolveSourceAssetKind(assetId, options, "scene instance");
|
|
124461
124375
|
const binding = findBindingForInstanceRoot(prefab, entityId, { assetId, assetKind });
|
|
124462
124376
|
if (binding)
|
|
124463
124377
|
markReachableBinding(binding);
|
|
@@ -124494,8 +124408,8 @@ function collectMissingNestedSourceInstanceBindings(prefab, options) {
|
|
|
124494
124408
|
const sourceRef = sourceEntity?.instance?.asset?.$ref;
|
|
124495
124409
|
if (!sourceEntityId || !sourceRef || isRemovedSourceEntity(binding, sourceEntityId))
|
|
124496
124410
|
continue;
|
|
124497
|
-
const assetId =
|
|
124498
|
-
const assetKind = resolveSourceAssetKind(
|
|
124411
|
+
const assetId = resolveRequiredSourceRef(sourceRef);
|
|
124412
|
+
const assetKind = resolveSourceAssetKind(assetId, options, "nested instance");
|
|
124499
124413
|
const sceneEntityId = getSceneEntityIdForSourceEntity(binding, sourceEntityId);
|
|
124500
124414
|
if (!sceneEntityId) {
|
|
124501
124415
|
throw new Error(
|
|
@@ -124580,11 +124494,7 @@ function createSourceInstanceBindingFromInlineSource(input) {
|
|
|
124580
124494
|
sourceRevision: 1,
|
|
124581
124495
|
sourceToSceneEntity: { [sourceRootEntityId]: sceneEntityId },
|
|
124582
124496
|
sourceEntitySnapshots: {},
|
|
124583
|
-
overrides: seedPrefabOverridesFromInlineSource(
|
|
124584
|
-
sourceEntity.instance?.overrides,
|
|
124585
|
-
prefabFile,
|
|
124586
|
-
options.resolveSourceRef
|
|
124587
|
-
)
|
|
124497
|
+
overrides: seedPrefabOverridesFromInlineSource(sourceEntity.instance?.overrides, prefabFile)
|
|
124588
124498
|
};
|
|
124589
124499
|
}
|
|
124590
124500
|
return {
|
|
@@ -124602,10 +124512,7 @@ function createSourceInstanceBindingFromInlineSource(input) {
|
|
|
124602
124512
|
sceneEntityId
|
|
124603
124513
|
})
|
|
124604
124514
|
},
|
|
124605
|
-
overrides: seedRootOnlyGLTFOverridesFromInlineSource(
|
|
124606
|
-
sourceEntity.instance?.overrides,
|
|
124607
|
-
options.resolveSourceRef
|
|
124608
|
-
)
|
|
124515
|
+
overrides: seedRootOnlyGLTFOverridesFromInlineSource(sourceEntity.instance?.overrides)
|
|
124609
124516
|
};
|
|
124610
124517
|
}
|
|
124611
124518
|
function seedInlineAddedSourceInstanceBindings(prefab, overrides, options) {
|
|
@@ -124618,8 +124525,8 @@ function seedInlineAddedSourceInstanceBindings(prefab, overrides, options) {
|
|
|
124618
124525
|
if (!sourceRef)
|
|
124619
124526
|
continue;
|
|
124620
124527
|
const sceneEntityId = requireInlineOverrideId(override3.id, inlineEntity.id, "added entity override");
|
|
124621
|
-
const assetId =
|
|
124622
|
-
const assetKind = resolveSourceAssetKind(
|
|
124528
|
+
const assetId = resolveRequiredSourceRef(sourceRef);
|
|
124529
|
+
const assetKind = resolveSourceAssetKind(assetId, options, "inline added instance");
|
|
124623
124530
|
if (findBindingForInstanceRoot(prefab, sceneEntityId, { assetId, assetKind }))
|
|
124624
124531
|
continue;
|
|
124625
124532
|
const binding = createSourceInstanceBindingFromInlineSource({
|
|
@@ -124648,8 +124555,8 @@ function hasMissingInlineAddedSourceInstanceBindings(prefab, overrides, options)
|
|
|
124648
124555
|
if (!sourceRef)
|
|
124649
124556
|
continue;
|
|
124650
124557
|
const sceneEntityId = requireInlineOverrideId(override3.id, inlineEntity.id, "added entity override");
|
|
124651
|
-
const assetId =
|
|
124652
|
-
const assetKind = resolveSourceAssetKind(
|
|
124558
|
+
const assetId = resolveRequiredSourceRef(sourceRef);
|
|
124559
|
+
const assetKind = resolveSourceAssetKind(assetId, options, "inline added instance");
|
|
124653
124560
|
if (!findBindingForInstanceRoot(prefab, sceneEntityId, { assetId, assetKind }))
|
|
124654
124561
|
return true;
|
|
124655
124562
|
}
|
|
@@ -124679,8 +124586,8 @@ function seedInlineAddedSourceInstanceBindingsForNestedSourceInstances(prefab, o
|
|
|
124679
124586
|
const sceneEntityId = getSceneEntityIdForSourceEntity(binding, sourceEntityId);
|
|
124680
124587
|
if (!sceneEntityId)
|
|
124681
124588
|
continue;
|
|
124682
|
-
const assetId =
|
|
124683
|
-
const assetKind = resolveSourceAssetKind(
|
|
124589
|
+
const assetId = resolveRequiredSourceRef(sourceRef);
|
|
124590
|
+
const assetKind = resolveSourceAssetKind(assetId, options, "nested instance");
|
|
124684
124591
|
if (!findBindingForInstanceRoot(prefab, sceneEntityId, { assetId, assetKind }))
|
|
124685
124592
|
continue;
|
|
124686
124593
|
if (seedInlineAddedSourceInstanceBindings(prefab, sourceEntity.instance.overrides, options))
|
|
@@ -124712,8 +124619,8 @@ function hasMissingInlineAddedSourceInstanceBindingsForNestedSourceInstances(pre
|
|
|
124712
124619
|
const sceneEntityId = getSceneEntityIdForSourceEntity(binding, sourceEntityId);
|
|
124713
124620
|
if (!sceneEntityId)
|
|
124714
124621
|
continue;
|
|
124715
|
-
const assetId =
|
|
124716
|
-
const assetKind = resolveSourceAssetKind(
|
|
124622
|
+
const assetId = resolveRequiredSourceRef(sourceRef);
|
|
124623
|
+
const assetKind = resolveSourceAssetKind(assetId, options, "nested instance");
|
|
124717
124624
|
if (!findBindingForInstanceRoot(prefab, sceneEntityId, { assetId, assetKind }))
|
|
124718
124625
|
continue;
|
|
124719
124626
|
if (hasMissingInlineAddedSourceInstanceBindings(prefab, sourceEntity.instance.overrides, options))
|
|
@@ -124758,11 +124665,7 @@ function seedNestedSourceInstanceBindings(prefab, options, ancestorAssetIdsByBin
|
|
|
124758
124665
|
sourceRevision: 1,
|
|
124759
124666
|
sourceToSceneEntity: { [sourceRootEntityId]: item.sceneEntityId },
|
|
124760
124667
|
sourceEntitySnapshots: {},
|
|
124761
|
-
overrides: seedPrefabOverridesFromInlineSource(
|
|
124762
|
-
item.sourceEntity.instance?.overrides,
|
|
124763
|
-
prefabFile,
|
|
124764
|
-
options.resolveSourceRef
|
|
124765
|
-
)
|
|
124668
|
+
overrides: seedPrefabOverridesFromInlineSource(item.sourceEntity.instance?.overrides, prefabFile)
|
|
124766
124669
|
};
|
|
124767
124670
|
} else {
|
|
124768
124671
|
binding = {
|
|
@@ -124780,10 +124683,7 @@ function seedNestedSourceInstanceBindings(prefab, options, ancestorAssetIdsByBin
|
|
|
124780
124683
|
sceneEntityId: item.sceneEntityId
|
|
124781
124684
|
})
|
|
124782
124685
|
},
|
|
124783
|
-
overrides: seedRootOnlyGLTFOverridesFromInlineSource(
|
|
124784
|
-
item.sourceEntity.instance?.overrides,
|
|
124785
|
-
options.resolveSourceRef
|
|
124786
|
-
)
|
|
124686
|
+
overrides: seedRootOnlyGLTFOverridesFromInlineSource(item.sourceEntity.instance?.overrides)
|
|
124787
124687
|
};
|
|
124788
124688
|
}
|
|
124789
124689
|
next.bindings[binding.id] = binding;
|
|
@@ -125015,37 +124915,28 @@ function assertGLTFBindingsHaveSourceSnapshots(prefab) {
|
|
|
125015
124915
|
);
|
|
125016
124916
|
}
|
|
125017
124917
|
}
|
|
125018
|
-
function createRequiredHydrationSourceRefResolver(resolveSourceRef2) {
|
|
125019
|
-
const codec2 = createSourceRefCodec({ resolveSourceRef: resolveSourceRef2 });
|
|
125020
|
-
return (ref) => codec2.sourceToDomain(ref);
|
|
125021
|
-
}
|
|
125022
124918
|
function hydrateSourceV2SceneToDomain(sceneFile, options = {}) {
|
|
125023
124919
|
const parseSceneFile = sceneFile;
|
|
125024
124920
|
const entities = {};
|
|
125025
124921
|
const rootEntityIds = [];
|
|
125026
|
-
const resolveSourceRef2 = createRequiredHydrationSourceRefResolver(options.resolveSourceRef);
|
|
125027
|
-
const hydrationOptions = {
|
|
125028
|
-
...options,
|
|
125029
|
-
resolveSourceRef: resolveSourceRef2
|
|
125030
|
-
};
|
|
125031
124922
|
parseSceneFileV2(parseSceneFile, entities, rootEntityIds, {
|
|
125032
|
-
...
|
|
124923
|
+
...options,
|
|
125033
124924
|
deferPrefabInlineOverrideMaterialization: true
|
|
125034
124925
|
});
|
|
125035
124926
|
const reservedSceneEntityIds = parseSceneFile.entities.map((entity) => entity.id);
|
|
125036
124927
|
const reservedSceneComponentIds = parseSceneFile.components.map((component2) => component2.id);
|
|
125037
|
-
const initialPrefabState =
|
|
124928
|
+
const initialPrefabState = options.initialPrefabState ? clone(options.initialPrefabState) : createEmptyPrefabState();
|
|
125038
124929
|
const refreshedPrefab = refreshAndSeedPrefabBindingsFromSource(
|
|
125039
124930
|
initialPrefabState,
|
|
125040
124931
|
parseSceneFile,
|
|
125041
|
-
|
|
124932
|
+
options,
|
|
125042
124933
|
entities,
|
|
125043
124934
|
reservedSceneEntityIds,
|
|
125044
124935
|
reservedSceneComponentIds
|
|
125045
124936
|
);
|
|
125046
|
-
const prefab = prunePrefabBindingsToReachableSourceInstances(parseSceneFile, refreshedPrefab,
|
|
125047
|
-
if (!
|
|
125048
|
-
assertNestedSourceInstanceBindingsPresent(prefab,
|
|
124937
|
+
const prefab = prunePrefabBindingsToReachableSourceInstances(parseSceneFile, refreshedPrefab, options);
|
|
124938
|
+
if (!options.allowMissingNestedInstanceBindings) {
|
|
124939
|
+
assertNestedSourceInstanceBindingsPresent(prefab, options);
|
|
125049
124940
|
}
|
|
125050
124941
|
assertGLTFBindingsHaveSourceSnapshots(prefab);
|
|
125051
124942
|
materializePrefabBindingSnapshots(entities, prefab);
|
|
@@ -125053,14 +124944,13 @@ function hydrateSourceV2SceneToDomain(sceneFile, options = {}) {
|
|
|
125053
124944
|
materializeAddedOverridesFromSource(
|
|
125054
124945
|
parseSceneFile,
|
|
125055
124946
|
entities,
|
|
125056
|
-
|
|
125057
|
-
hydrationOptions.resolveAssetKind,
|
|
124947
|
+
options.resolveAssetKind,
|
|
125058
124948
|
prefab,
|
|
125059
124949
|
addedOverrideMaterializationReport
|
|
125060
124950
|
);
|
|
125061
124951
|
assertAddedOverridesMaterialized(prefab, addedOverrideMaterializationReport);
|
|
125062
|
-
assertNoUnmaterializedSourceInstances(entities, prefab,
|
|
125063
|
-
const settings = extractSceneSettings(sceneFile.scene
|
|
124952
|
+
assertNoUnmaterializedSourceInstances(entities, prefab, options);
|
|
124953
|
+
const settings = extractSceneSettings(sceneFile.scene);
|
|
125064
124954
|
return {
|
|
125065
124955
|
scene: {
|
|
125066
124956
|
rootEntityIds,
|
|
@@ -125444,65 +125334,6 @@ var init_sync_adapter = __esm({
|
|
|
125444
125334
|
}
|
|
125445
125335
|
});
|
|
125446
125336
|
|
|
125447
|
-
// src/domain-bridge/asset-virtual-path.ts
|
|
125448
|
-
function normalizeSourceVirtualPath2(value) {
|
|
125449
|
-
return value.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
125450
|
-
}
|
|
125451
|
-
function localAssetPathToSourceVirtualPath(localPath, assetType) {
|
|
125452
|
-
const parts = normalizeSourceVirtualPath2(localPath).split("/").filter(Boolean);
|
|
125453
|
-
if (parts[0] === STORAGE_ASSET_ROOT)
|
|
125454
|
-
parts.shift();
|
|
125455
|
-
if (parts.length === 0)
|
|
125456
|
-
return "";
|
|
125457
|
-
if (assetType !== "Folder") {
|
|
125458
|
-
parts[parts.length - 1] = assetNameFromPath(localPath, assetType);
|
|
125459
|
-
}
|
|
125460
|
-
return parts.join("/");
|
|
125461
|
-
}
|
|
125462
|
-
function createManifestSourceVirtualPathIndex(manifest) {
|
|
125463
|
-
const index2 = /* @__PURE__ */ new Map();
|
|
125464
|
-
for (const [assetId, entry] of Object.entries(manifest.entries)) {
|
|
125465
|
-
const virtualPath = localAssetPathToSourceVirtualPath(entry.path, entry.type);
|
|
125466
|
-
if (!virtualPath)
|
|
125467
|
-
continue;
|
|
125468
|
-
index2.set(virtualPath, assetId);
|
|
125469
|
-
index2.set(`/${virtualPath}`, assetId);
|
|
125470
|
-
}
|
|
125471
|
-
return index2;
|
|
125472
|
-
}
|
|
125473
|
-
function createDomainAssetSourceRefResolver(assets2) {
|
|
125474
|
-
const cache = /* @__PURE__ */ new Map();
|
|
125475
|
-
const resolve5 = (assetId, visiting = /* @__PURE__ */ new Set()) => {
|
|
125476
|
-
if (cache.has(assetId))
|
|
125477
|
-
return cache.get(assetId);
|
|
125478
|
-
const asset3 = assets2[assetId];
|
|
125479
|
-
if (!asset3 || visiting.has(assetId)) {
|
|
125480
|
-
cache.set(assetId, void 0);
|
|
125481
|
-
return void 0;
|
|
125482
|
-
}
|
|
125483
|
-
visiting.add(assetId);
|
|
125484
|
-
const parentPath = asset3.parentFolderId ? resolve5(asset3.parentFolderId, visiting) : void 0;
|
|
125485
|
-
visiting.delete(assetId);
|
|
125486
|
-
if (asset3.parentFolderId && !parentPath) {
|
|
125487
|
-
cache.set(assetId, void 0);
|
|
125488
|
-
return void 0;
|
|
125489
|
-
}
|
|
125490
|
-
const assetName = asset3.type === "Folder" ? asset3.name : assetNameFromPath(asset3.name, asset3.type);
|
|
125491
|
-
const virtualPath = parentPath ? `${parentPath}/${assetName}` : assetName;
|
|
125492
|
-
cache.set(assetId, virtualPath);
|
|
125493
|
-
return virtualPath;
|
|
125494
|
-
};
|
|
125495
|
-
return (assetId) => resolve5(assetId);
|
|
125496
|
-
}
|
|
125497
|
-
var STORAGE_ASSET_ROOT;
|
|
125498
|
-
var init_asset_virtual_path = __esm({
|
|
125499
|
-
"src/domain-bridge/asset-virtual-path.ts"() {
|
|
125500
|
-
"use strict";
|
|
125501
|
-
init_sync_adapter();
|
|
125502
|
-
STORAGE_ASSET_ROOT = "assets";
|
|
125503
|
-
}
|
|
125504
|
-
});
|
|
125505
|
-
|
|
125506
125337
|
// src/domain-bridge/scene-parser.ts
|
|
125507
125338
|
function isBuiltinShader(shader) {
|
|
125508
125339
|
return typeof shader === "string" && BUILTIN_SHADER_NAMES.has(shader);
|
|
@@ -125648,22 +125479,9 @@ function resolveSceneAssetId(config2, manifest) {
|
|
|
125648
125479
|
}
|
|
125649
125480
|
return sceneAssetIds[0] ?? "";
|
|
125650
125481
|
}
|
|
125651
|
-
function
|
|
125652
|
-
|
|
125653
|
-
|
|
125654
|
-
const assetId = manifestIndex.pathToId.get(ref) ?? sourceVirtualPathToId.get(ref);
|
|
125655
|
-
if (assetId)
|
|
125656
|
-
return assetId;
|
|
125657
|
-
throw new Error(
|
|
125658
|
-
`[domain-bridge] Unable to resolve source asset ref "${ref}". Source-v2 $ref must be a virtualPath.`
|
|
125659
|
-
);
|
|
125660
|
-
};
|
|
125661
|
-
}
|
|
125662
|
-
function createSourceAssetKindResolver(manifest, manifestIndex) {
|
|
125663
|
-
const sourceVirtualPathToId = createManifestSourceVirtualPathIndex(manifest);
|
|
125664
|
-
return (ref, assetId) => {
|
|
125665
|
-
const resolvedAssetId = manifest.entries[assetId] ? assetId : manifestIndex.pathToId.get(ref) ?? sourceVirtualPathToId.get(ref);
|
|
125666
|
-
const type = manifest.entries[resolvedAssetId ?? ""]?.type;
|
|
125482
|
+
function createSourceAssetKindResolver(manifest) {
|
|
125483
|
+
return (assetId) => {
|
|
125484
|
+
const type = manifest.entries[assetId]?.type;
|
|
125667
125485
|
return type === "Prefab" || type === "glTF" ? type : void 0;
|
|
125668
125486
|
};
|
|
125669
125487
|
}
|
|
@@ -125696,8 +125514,7 @@ async function loadDomainState(projectDir) {
|
|
|
125696
125514
|
let activeSceneFile;
|
|
125697
125515
|
const assetMeta = /* @__PURE__ */ new Map();
|
|
125698
125516
|
const manifestIndex = createManifestEntryIndex(manifest.entries);
|
|
125699
|
-
const
|
|
125700
|
-
const resolveAssetKind3 = createSourceAssetKindResolver(manifest, manifestIndex);
|
|
125517
|
+
const resolveAssetKind3 = createSourceAssetKindResolver(manifest);
|
|
125701
125518
|
for (const [assetId, entry] of Object.entries(manifest.entries)) {
|
|
125702
125519
|
let meta4;
|
|
125703
125520
|
const inlineMeta = entry.meta;
|
|
@@ -125771,7 +125588,6 @@ async function loadDomainState(projectDir) {
|
|
|
125771
125588
|
}
|
|
125772
125589
|
if (activeSceneFile) {
|
|
125773
125590
|
const hydrated = hydrateSourceV2SceneToDomain(activeSceneFile, {
|
|
125774
|
-
resolveSourceRef: resolveSourceRef2,
|
|
125775
125591
|
resolveAssetKind: resolveAssetKind3,
|
|
125776
125592
|
resolvePrefabSourceFile: (assetId) => {
|
|
125777
125593
|
const content = assets2[assetId]?.content;
|
|
@@ -125810,7 +125626,6 @@ var init_load = __esm({
|
|
|
125810
125626
|
init_hydrateSourceV2SceneToDomain();
|
|
125811
125627
|
init_meta_file();
|
|
125812
125628
|
init_sync_adapter();
|
|
125813
|
-
init_asset_virtual_path();
|
|
125814
125629
|
init_scene_parser();
|
|
125815
125630
|
init_utils();
|
|
125816
125631
|
emptyPrefabDomainState = () => ({ bindings: {}, byAssetId: {} });
|
|
@@ -125837,8 +125652,8 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
125837
125652
|
let currentSceneJson;
|
|
125838
125653
|
if (ctx.sceneAssetId && state.assets[ctx.sceneAssetId]) {
|
|
125839
125654
|
const sceneFile = domainStateToSceneFileV2(state, {
|
|
125840
|
-
|
|
125841
|
-
|
|
125655
|
+
currentAssetId: ctx.sceneAssetId,
|
|
125656
|
+
assetExists: (assetId) => Boolean(state.assets[assetId])
|
|
125842
125657
|
});
|
|
125843
125658
|
state.assets[ctx.sceneAssetId].content = sceneFile;
|
|
125844
125659
|
currentSceneJson = formatSourceV2SceneFile(sceneFile);
|
|
@@ -126118,7 +125933,6 @@ var init_save = __esm({
|
|
|
126118
125933
|
init_meta_file();
|
|
126119
125934
|
init_path_tree();
|
|
126120
125935
|
init_scene_file_v2();
|
|
126121
|
-
init_asset_virtual_path();
|
|
126122
125936
|
init_scene_parser();
|
|
126123
125937
|
init_path_case_guard();
|
|
126124
125938
|
init_utils();
|
|
@@ -126804,7 +126618,6 @@ async function cliCompile(vfs, config2, options, projectShaderChunks = {}) {
|
|
|
126804
126618
|
new Blob([JSON.stringify(parsedSceneLike)], { type: "application/json" }),
|
|
126805
126619
|
resolve5,
|
|
126806
126620
|
{
|
|
126807
|
-
resolveSourceRef: (value) => resolveSourceRef(vfs, value),
|
|
126808
126621
|
resolveAssetKind: (value) => resolveAssetKind(vfs, value),
|
|
126809
126622
|
resolveInstanceSourceFile: (value) => resolveInstanceSourceFile(vfs, value)
|
|
126810
126623
|
}
|
|
@@ -153103,23 +152916,29 @@ var init_AssetFacade = __esm({
|
|
|
153103
152916
|
* 删除资产
|
|
153104
152917
|
*/
|
|
153105
152918
|
async deleteAsset(assetId) {
|
|
153106
|
-
const
|
|
152919
|
+
const deleteIds = this.collectDeleteTargetAssetIds([assetId]);
|
|
152920
|
+
const flush = this.prepareFlush(deleteIds);
|
|
153107
152921
|
if (flush) {
|
|
153108
152922
|
try {
|
|
153109
152923
|
await flush;
|
|
153110
152924
|
} catch {
|
|
153111
152925
|
}
|
|
153112
152926
|
}
|
|
153113
|
-
|
|
153114
|
-
|
|
153115
|
-
|
|
152927
|
+
this.runBatch("asset.delete", () => {
|
|
152928
|
+
this.unlinkAssetInstancesBeforeDelete(deleteIds);
|
|
152929
|
+
this.executeDeleteCommands([assetId]);
|
|
152930
|
+
});
|
|
152931
|
+
for (const id of deleteIds) {
|
|
152932
|
+
this.root.assetUIStore?.clearAssetUploading(id);
|
|
152933
|
+
}
|
|
153116
152934
|
}
|
|
153117
152935
|
/**
|
|
153118
152936
|
* 批量删除资产
|
|
153119
152937
|
*/
|
|
153120
152938
|
async deleteAssets(assetIds) {
|
|
153121
152939
|
const ids = [...assetIds];
|
|
153122
|
-
const
|
|
152940
|
+
const deleteIds = this.collectDeleteTargetAssetIds(ids);
|
|
152941
|
+
const flush = this.prepareFlush(deleteIds);
|
|
153123
152942
|
if (flush) {
|
|
153124
152943
|
try {
|
|
153125
152944
|
await flush;
|
|
@@ -153127,9 +152946,10 @@ var init_AssetFacade = __esm({
|
|
|
153127
152946
|
}
|
|
153128
152947
|
}
|
|
153129
152948
|
this.runBatch("asset.deleteMultiple", () => {
|
|
152949
|
+
this.unlinkAssetInstancesBeforeDelete(deleteIds);
|
|
153130
152950
|
this.executeDeleteCommands(ids);
|
|
153131
152951
|
});
|
|
153132
|
-
for (const id of
|
|
152952
|
+
for (const id of deleteIds) {
|
|
153133
152953
|
this.root.assetUIStore?.clearAssetUploading(id);
|
|
153134
152954
|
}
|
|
153135
152955
|
}
|
|
@@ -153141,7 +152961,9 @@ var init_AssetFacade = __esm({
|
|
|
153141
152961
|
*/
|
|
153142
152962
|
async deleteAssetsWithInstances(assetIds, instanceEntityIds) {
|
|
153143
152963
|
const ids = [...assetIds];
|
|
153144
|
-
const
|
|
152964
|
+
const deleteIds = this.collectDeleteTargetAssetIds(ids);
|
|
152965
|
+
const entityIds = this.collectInstanceEntityIdsForAssets(deleteIds, instanceEntityIds);
|
|
152966
|
+
const flush = this.prepareFlush(deleteIds);
|
|
153145
152967
|
if (flush) {
|
|
153146
152968
|
try {
|
|
153147
152969
|
await flush;
|
|
@@ -153149,10 +152971,11 @@ var init_AssetFacade = __esm({
|
|
|
153149
152971
|
}
|
|
153150
152972
|
}
|
|
153151
152973
|
this.runBatch("asset.deleteWithInstances", () => {
|
|
153152
|
-
this.root.entityFacade.deleteEntities(
|
|
152974
|
+
this.root.entityFacade.deleteEntities(entityIds);
|
|
152975
|
+
this.unlinkAssetInstancesBeforeDelete(deleteIds);
|
|
153153
152976
|
this.executeDeleteCommands(ids);
|
|
153154
152977
|
});
|
|
153155
|
-
for (const id of
|
|
152978
|
+
for (const id of deleteIds) {
|
|
153156
152979
|
this.root.assetUIStore?.clearAssetUploading(id);
|
|
153157
152980
|
}
|
|
153158
152981
|
}
|
|
@@ -153176,6 +152999,47 @@ var init_AssetFacade = __esm({
|
|
|
153176
152999
|
}
|
|
153177
153000
|
}
|
|
153178
153001
|
}
|
|
153002
|
+
collectDeleteTargetAssetIds(assetIds) {
|
|
153003
|
+
const ids = /* @__PURE__ */ new Set();
|
|
153004
|
+
for (const assetId of assetIds) {
|
|
153005
|
+
if (!this.state.assets[assetId])
|
|
153006
|
+
continue;
|
|
153007
|
+
for (const id of collectAssetSubtree(this.state, assetId)) {
|
|
153008
|
+
ids.add(id);
|
|
153009
|
+
}
|
|
153010
|
+
}
|
|
153011
|
+
return Array.from(ids);
|
|
153012
|
+
}
|
|
153013
|
+
unlinkAssetInstancesBeforeDelete(assetIds) {
|
|
153014
|
+
const deleting = new Set(assetIds);
|
|
153015
|
+
for (const assetId of assetIds) {
|
|
153016
|
+
if (this.state.prefab.byAssetId[assetId]?.length) {
|
|
153017
|
+
this.root.prefabFacade.unpackByAsset(assetId);
|
|
153018
|
+
}
|
|
153019
|
+
}
|
|
153020
|
+
const directInstanceEntityIds = Object.values(this.state.entities).filter((entity) => {
|
|
153021
|
+
const instance2 = entity.instance;
|
|
153022
|
+
return Boolean(instance2?.assetId && deleting.has(instance2.assetId) && !instance2.bindingId);
|
|
153023
|
+
}).map((entity) => entity.id);
|
|
153024
|
+
for (const entityId of directInstanceEntityIds) {
|
|
153025
|
+
if (this.state.entities[entityId]?.instance) {
|
|
153026
|
+
this.root.entityFacade.updateEntity(entityId, { instance: null });
|
|
153027
|
+
}
|
|
153028
|
+
}
|
|
153029
|
+
}
|
|
153030
|
+
collectInstanceEntityIdsForAssets(assetIds, existingEntityIds) {
|
|
153031
|
+
const entityIds = new Set(existingEntityIds);
|
|
153032
|
+
for (const assetId of assetIds) {
|
|
153033
|
+
const bindingIds = this.state.prefab.byAssetId[assetId] ?? [];
|
|
153034
|
+
for (const bindingId of bindingIds) {
|
|
153035
|
+
const binding = this.state.prefab.bindings[bindingId];
|
|
153036
|
+
if (binding?.instanceRootEntityId) {
|
|
153037
|
+
entityIds.add(binding.instanceRootEntityId);
|
|
153038
|
+
}
|
|
153039
|
+
}
|
|
153040
|
+
}
|
|
153041
|
+
return Array.from(entityIds);
|
|
153042
|
+
}
|
|
153179
153043
|
/** Collect pending flush promises and track them. Returns void if nothing to flush. */
|
|
153180
153044
|
prepareFlush(assetIds) {
|
|
153181
153045
|
const pending = this.flushAllPendingSaves(assetIds);
|
|
@@ -287940,9 +287804,17 @@ function compactTransformAgainstSnapshot(snapshot, transform5) {
|
|
|
287940
287804
|
const axisPatch = transform5[key2];
|
|
287941
287805
|
if (!axisPatch)
|
|
287942
287806
|
continue;
|
|
287943
|
-
const compactedAxis =
|
|
287944
|
-
|
|
287945
|
-
|
|
287807
|
+
const compactedAxis = {};
|
|
287808
|
+
for (const axis of TRANSFORM_AXIS_KEYS) {
|
|
287809
|
+
const value = axisPatch[axis];
|
|
287810
|
+
if (value === void 0)
|
|
287811
|
+
continue;
|
|
287812
|
+
if (Math.abs(value - snapshot[key2][axis]) > TRANSFORM_OVERRIDE_EPSILON) {
|
|
287813
|
+
compactedAxis[axis] = value;
|
|
287814
|
+
}
|
|
287815
|
+
}
|
|
287816
|
+
if (Object.keys(compactedAxis).length)
|
|
287817
|
+
next[key2] = cloneState(compactedAxis);
|
|
287946
287818
|
}
|
|
287947
287819
|
return Object.keys(next).length ? next : void 0;
|
|
287948
287820
|
}
|
|
@@ -288064,7 +287936,7 @@ function isNestedInstanceSubtreeEntity(state, entity, targetBindingId, subtreeId
|
|
|
288064
287936
|
const nestedBinding = state.prefab.bindings[instance2.bindingId];
|
|
288065
287937
|
return Boolean(nestedBinding && subtreeIds.has(nestedBinding.instanceRootEntityId));
|
|
288066
287938
|
}
|
|
288067
|
-
var SetEntityOverrideCommand, SetComponentOverrideCommand, AddEntityOverrideCommand, AddExistingEntityOverrideCommand, RemoveSourceEntityOverrideCommand, AddComponentOverrideCommand, UpdateAddedComponentOverrideCommand, RemoveSourceComponentOverrideCommand;
|
|
287939
|
+
var TRANSFORM_OVERRIDE_EPSILON, TRANSFORM_AXIS_KEYS, SetEntityOverrideCommand, SetComponentOverrideCommand, AddEntityOverrideCommand, AddExistingEntityOverrideCommand, RemoveSourceEntityOverrideCommand, AddComponentOverrideCommand, UpdateAddedComponentOverrideCommand, RemoveSourceComponentOverrideCommand;
|
|
288068
287940
|
var init_OverrideCommands = __esm({
|
|
288069
287941
|
"../model/src/domain/commands/prefab/OverrideCommands.ts"() {
|
|
288070
287942
|
"use strict";
|
|
@@ -288077,6 +287949,8 @@ var init_OverrideCommands = __esm({
|
|
|
288077
287949
|
init_cloneState();
|
|
288078
287950
|
init_transformHierarchy();
|
|
288079
287951
|
init_isPlainRecord();
|
|
287952
|
+
TRANSFORM_OVERRIDE_EPSILON = 1e-8;
|
|
287953
|
+
TRANSFORM_AXIS_KEYS = ["x", "y", "z"];
|
|
288080
287954
|
SetEntityOverrideCommand = class {
|
|
288081
287955
|
name = "prefab.setEntityOverride";
|
|
288082
287956
|
execute(state, input) {
|
|
@@ -288087,6 +287961,8 @@ var init_OverrideCommands = __esm({
|
|
|
288087
287961
|
const sourceEntityId = requirePrefabSourceEntityId(entity, entityId, binding);
|
|
288088
287962
|
const encodedSourceId = encodeJsonPointerSegment(sourceEntityId);
|
|
288089
287963
|
const encodedBindingId = encodeJsonPointerSegment(binding.id);
|
|
287964
|
+
const sourceSnapshot = binding.sourceEntitySnapshots?.[sourceEntityId];
|
|
287965
|
+
const existingOverride = binding.overrides.entityProps[sourceEntityId];
|
|
288090
287966
|
if (overrides.name !== void 0) {
|
|
288091
287967
|
ops2.push({ op: "replace", path: `/entities/${encodedEntityId}/name`, value: overrides.name });
|
|
288092
287968
|
}
|
|
@@ -288126,9 +288002,8 @@ var init_OverrideCommands = __esm({
|
|
|
288126
288002
|
});
|
|
288127
288003
|
}
|
|
288128
288004
|
}
|
|
288129
|
-
const existingOverride = binding.overrides.entityProps[sourceEntityId];
|
|
288130
288005
|
const merged = mergeEntityOverrideProps2(existingOverride, overrides);
|
|
288131
|
-
const compacted = compactEntityOverrideAgainstSnapshot(
|
|
288006
|
+
const compacted = compactEntityOverrideAgainstSnapshot(sourceSnapshot, merged);
|
|
288132
288007
|
let overrideChangeAction = null;
|
|
288133
288008
|
if (compacted) {
|
|
288134
288009
|
ops2.push({
|
|
@@ -290070,7 +289945,7 @@ function isV2PrefabContent(content) {
|
|
|
290070
289945
|
function normalizeSourceIdPrefabContent(content) {
|
|
290071
289946
|
return content;
|
|
290072
289947
|
}
|
|
290073
|
-
function normalizePrefabEntities(content
|
|
289948
|
+
function normalizePrefabEntities(content) {
|
|
290074
289949
|
if (!isV2PrefabContent(content)) {
|
|
290075
289950
|
return content.entities ?? [];
|
|
290076
289951
|
}
|
|
@@ -290112,10 +289987,10 @@ function normalizePrefabEntities(content, resolveSourceRef2) {
|
|
|
290112
289987
|
{
|
|
290113
289988
|
id: componentId,
|
|
290114
289989
|
type: component2.type,
|
|
290115
|
-
props: convertAssetRefsToDomainRefs(component2.props ?? {}
|
|
290116
|
-
...component2.script?.$ref ? { refId: resolveRequiredSourceRef(component2.script.$ref
|
|
289990
|
+
props: convertAssetRefsToDomainRefs(component2.props ?? {}),
|
|
289991
|
+
...component2.script?.$ref ? { refId: resolveRequiredSourceRef(component2.script.$ref) } : {},
|
|
290117
289992
|
...component2.script?.key ? { scriptKey: component2.script.key } : {},
|
|
290118
|
-
...component2.calls?.length ? { calls: convertAssetRefsToDomainRefs(component2.calls
|
|
289993
|
+
...component2.calls?.length ? { calls: convertAssetRefsToDomainRefs(component2.calls) } : {}
|
|
290119
289994
|
}
|
|
290120
289995
|
];
|
|
290121
289996
|
})
|
|
@@ -290412,7 +290287,7 @@ var init_HeadlessAssetProxy = __esm({
|
|
|
290412
290287
|
throw new Error(`instantiate \u4EC5\u652F\u6301 Prefab \u7C7B\u578B\uFF0C\u5F53\u524D\u7C7B\u578B: ${this.type}`);
|
|
290413
290288
|
}
|
|
290414
290289
|
const content = this.asset.content;
|
|
290415
|
-
const entities = content ? normalizePrefabEntities(content
|
|
290290
|
+
const entities = content ? normalizePrefabEntities(content) : void 0;
|
|
290416
290291
|
if (!entities || !Array.isArray(entities) || entities.length === 0) {
|
|
290417
290292
|
throw new Error(`Prefab "${this.name}" content \u7F3A\u5C11\u6709\u6548\u7684 entities \u6570\u7EC4`);
|
|
290418
290293
|
}
|
|
@@ -290477,7 +290352,7 @@ var init_HeadlessAssetProxy = __esm({
|
|
|
290477
290352
|
const state = this.store.domainStore.state;
|
|
290478
290353
|
const content = domainStateToPrefabFileV2(state, entity.id, {
|
|
290479
290354
|
currentAssetId: this.asset.id,
|
|
290480
|
-
|
|
290355
|
+
assetExists: (assetId) => Boolean(state.assets[assetId])
|
|
290481
290356
|
});
|
|
290482
290357
|
this.store.root.assetFacade.writeContent(this.asset.id, content);
|
|
290483
290358
|
}
|
|
@@ -290515,8 +290390,6 @@ var init_HeadlessVFS = __esm({
|
|
|
290515
290390
|
}
|
|
290516
290391
|
/**
|
|
290517
290392
|
* 通过 vfs 绝对路径解析到资产(id + 类型)。
|
|
290518
|
-
* editor-api 的 `resolveAssetRef` 调用此入口,将 path 入参翻译成内部 uuid。
|
|
290519
|
-
*
|
|
290520
290393
|
* 这里直接复用 `resolveAssetByPath`(HeadlessVFS 既有路径解析核心),
|
|
290521
290394
|
* 因此和 file tools (read/list/write/edit) 看到的图结构完全一致。
|
|
290522
290395
|
*/
|
|
@@ -291192,51 +291065,37 @@ var init_ResourcePackageImporter = __esm({
|
|
|
291192
291065
|
manifestPathMap.set(asset3.path, asset3);
|
|
291193
291066
|
manifestPathMap.set(normalizeSourceVirtualPath(asset3.path), asset3);
|
|
291194
291067
|
}
|
|
291195
|
-
const importedVirtualPathByEntryPath = /* @__PURE__ */ new Map();
|
|
291196
|
-
let plannedTargetVirtualPathByEntryPath = /* @__PURE__ */ new Map();
|
|
291197
291068
|
const resolveExistingTargetAssetId = (entry) => {
|
|
291198
291069
|
const targetVirtualPath = desiredTargetVirtualPathByEntryPath.get(entry.path);
|
|
291199
291070
|
const targetId = targetVirtualPath ? virtualPathToId.get(targetVirtualPath) ?? virtualPathToId.get(normalizeSourceVirtualPath(targetVirtualPath)) : void 0;
|
|
291200
291071
|
return targetId ?? virtualPathToId.get(entry.path) ?? virtualPathToId.get(normalizeSourceVirtualPath(entry.path));
|
|
291201
291072
|
};
|
|
291202
291073
|
const resolveUrlToAssetId = (url2) => {
|
|
291203
|
-
const
|
|
291074
|
+
const sourceRef = normalizeSourceVirtualPath(url2);
|
|
291075
|
+
const entry = manifestPathMap.get(url2) ?? manifestPathMap.get(sourceRef);
|
|
291204
291076
|
if (entry) {
|
|
291205
291077
|
return assetIdByPath.get(entry.path) || resolveExistingTargetAssetId(entry) || void 0;
|
|
291206
291078
|
}
|
|
291207
|
-
return virtualPathToId.get(url2) ?? virtualPathToId.get(
|
|
291079
|
+
return virtualPathToId.get(url2) ?? virtualPathToId.get(sourceRef);
|
|
291208
291080
|
};
|
|
291209
291081
|
const resolveUrlToImportableSourceRef = (url2) => {
|
|
291210
291082
|
const sourceRef = normalizeSourceVirtualPath(url2);
|
|
291211
|
-
const entry = manifestPathMap.get(url2);
|
|
291083
|
+
const entry = manifestPathMap.get(url2) ?? manifestPathMap.get(sourceRef);
|
|
291212
291084
|
if (entry) {
|
|
291213
|
-
|
|
291214
|
-
|
|
291215
|
-
const targetVirtualPath = desiredTargetVirtualPathByEntryPath.get(entry.path);
|
|
291216
|
-
if (targetVirtualPath && (virtualPathToId.has(targetVirtualPath) || virtualPathToId.has(normalizeSourceVirtualPath(targetVirtualPath)))) {
|
|
291217
|
-
return normalizeSourceVirtualPath(targetVirtualPath);
|
|
291218
|
-
}
|
|
291219
|
-
if (virtualPathToId.has(url2) || virtualPathToId.has(sourceRef))
|
|
291220
|
-
return sourceRef;
|
|
291221
|
-
return void 0;
|
|
291085
|
+
const assetId = assetIdByPath.get(entry.path) || resolveExistingTargetAssetId(entry);
|
|
291086
|
+
return assetId ? assertAndReturnSourceAssetRef(assetId, ` for GRP source reference "${url2}"`) : void 0;
|
|
291222
291087
|
}
|
|
291223
|
-
const
|
|
291088
|
+
const existingTargetAssetId = virtualPathToId.get(url2) ?? virtualPathToId.get(sourceRef);
|
|
291224
291089
|
const isInternalRef = isInternalAssetPath(url2) || sourceRef.startsWith("Internal/");
|
|
291225
291090
|
if (isInternalRef) {
|
|
291226
|
-
if (
|
|
291227
|
-
return
|
|
291091
|
+
if (existingTargetAssetId) {
|
|
291092
|
+
return assertAndReturnSourceAssetRef(existingTargetAssetId, ` for GRP source reference "${url2}"`);
|
|
291093
|
+
}
|
|
291228
291094
|
throw new Error(`GRP source asset reference "${url2}" could not be resolved in the target project`);
|
|
291229
291095
|
}
|
|
291230
291096
|
throw new Error(`GRP source asset reference "${url2}" is not declared in the GRP manifest`);
|
|
291231
291097
|
};
|
|
291232
291098
|
const resolveUrlToSourceRef = (url2) => {
|
|
291233
|
-
const sourceRef = normalizeSourceVirtualPath(url2);
|
|
291234
|
-
const importedPath = importedVirtualPathByEntryPath.get(url2) ?? importedVirtualPathByEntryPath.get(sourceRef);
|
|
291235
|
-
if (importedPath)
|
|
291236
|
-
return normalizeSourceVirtualPath(importedPath);
|
|
291237
|
-
const plannedPath = plannedTargetVirtualPathByEntryPath.get(url2) ?? plannedTargetVirtualPathByEntryPath.get(sourceRef);
|
|
291238
|
-
if (plannedPath)
|
|
291239
|
-
return normalizeSourceVirtualPath(plannedPath);
|
|
291240
291099
|
return resolveUrlToImportableSourceRef(url2);
|
|
291241
291100
|
};
|
|
291242
291101
|
const entriesToImport = parsedManifest.assets.filter((entry) => assetIdByPath.has(entry.path));
|
|
@@ -291254,11 +291113,6 @@ var init_ResourcePackageImporter = __esm({
|
|
|
291254
291113
|
await this.createFolderStructure(entriesToImport, options.targetFolderId, folderIdMapping);
|
|
291255
291114
|
}
|
|
291256
291115
|
const sortedEntries = this.topologicalSort(parsedManifest);
|
|
291257
|
-
plannedTargetVirtualPathByEntryPath = this.buildPlannedTargetVirtualPathByEntryPath(
|
|
291258
|
-
sortedEntries.filter((entry) => assetIdByPath.has(entry.path)),
|
|
291259
|
-
folderIdMapping,
|
|
291260
|
-
options
|
|
291261
|
-
);
|
|
291262
291116
|
const importedAssets = [];
|
|
291263
291117
|
for (const entry of sortedEntries) {
|
|
291264
291118
|
const newId = assetIdByPath.get(entry.path);
|
|
@@ -291279,12 +291133,6 @@ var init_ResourcePackageImporter = __esm({
|
|
|
291279
291133
|
const assetId = await this.createAsset(entry, processedFileData, newId, folderIdMapping, options);
|
|
291280
291134
|
if (assetId) {
|
|
291281
291135
|
importedAssets.push(assetId);
|
|
291282
|
-
const importedAsset = this.assetStore.assets[assetId];
|
|
291283
|
-
const importedPath = importedAsset?.getRouteString(true);
|
|
291284
|
-
if (importedPath) {
|
|
291285
|
-
importedVirtualPathByEntryPath.set(entry.path, importedPath);
|
|
291286
|
-
importedVirtualPathByEntryPath.set(normalizeSourceVirtualPath(entry.path), importedPath);
|
|
291287
|
-
}
|
|
291288
291136
|
}
|
|
291289
291137
|
} catch (e6) {
|
|
291290
291138
|
const name16 = getGRPAssetName(entry);
|
|
@@ -291391,26 +291239,6 @@ var init_ResourcePackageImporter = __esm({
|
|
|
291391
291239
|
}
|
|
291392
291240
|
return targetPathByEntryPath;
|
|
291393
291241
|
}
|
|
291394
|
-
buildPlannedTargetVirtualPathByEntryPath(entries, folderIdMapping, options) {
|
|
291395
|
-
const targetPathByEntryPath = /* @__PURE__ */ new Map();
|
|
291396
|
-
const reservedNamesByFolder = /* @__PURE__ */ new Map();
|
|
291397
|
-
for (const entry of entries) {
|
|
291398
|
-
const parentFolderId = this.resolveTargetFolderId(entry, folderIdMapping, options);
|
|
291399
|
-
const folderKey = parentFolderId ?? "__ROOT__";
|
|
291400
|
-
let reservedNames = reservedNamesByFolder.get(folderKey);
|
|
291401
|
-
if (!reservedNames) {
|
|
291402
|
-
reservedNames = /* @__PURE__ */ new Set();
|
|
291403
|
-
reservedNamesByFolder.set(folderKey, reservedNames);
|
|
291404
|
-
}
|
|
291405
|
-
const rawName = getGRPAssetName(entry);
|
|
291406
|
-
const plannedName = options.conflictStrategy === "overwrite" ? rawName : this.getAvailableAssetName(rawName, parentFolderId, reservedNames);
|
|
291407
|
-
reservedNames.add(plannedName);
|
|
291408
|
-
const targetVirtualPath = joinVirtualPath([this.getFolderVirtualPath(parentFolderId), plannedName]);
|
|
291409
|
-
targetPathByEntryPath.set(entry.path, targetVirtualPath);
|
|
291410
|
-
targetPathByEntryPath.set(normalizeSourceVirtualPath(entry.path), targetVirtualPath);
|
|
291411
|
-
}
|
|
291412
|
-
return targetPathByEntryPath;
|
|
291413
|
-
}
|
|
291414
291242
|
getDesiredTargetVirtualPath(entry, options) {
|
|
291415
291243
|
const parts = [this.getFolderVirtualPath(options.targetFolderId)];
|
|
291416
291244
|
if (options.preserveStructure !== false) {
|
|
@@ -291441,25 +291269,6 @@ var init_ResourcePackageImporter = __esm({
|
|
|
291441
291269
|
return "";
|
|
291442
291270
|
}
|
|
291443
291271
|
}
|
|
291444
|
-
getAvailableAssetName(name16, parentFolderId, reservedNames) {
|
|
291445
|
-
const usedNames = new Set(reservedNames);
|
|
291446
|
-
for (const asset3 of Object.values(this.assetStore.assets)) {
|
|
291447
|
-
if ((asset3.parentFolderId ?? null) === parentFolderId) {
|
|
291448
|
-
usedNames.add(asset3.name);
|
|
291449
|
-
}
|
|
291450
|
-
}
|
|
291451
|
-
if (!usedNames.has(name16))
|
|
291452
|
-
return name16;
|
|
291453
|
-
const ext = extname2(name16);
|
|
291454
|
-
const baseName = ext ? name16.slice(0, -ext.length) : name16;
|
|
291455
|
-
let index2 = 1;
|
|
291456
|
-
while (true) {
|
|
291457
|
-
const candidate = `${baseName}${index2}${ext}`;
|
|
291458
|
-
if (!usedNames.has(candidate))
|
|
291459
|
-
return candidate;
|
|
291460
|
-
index2++;
|
|
291461
|
-
}
|
|
291462
|
-
}
|
|
291463
291272
|
/**
|
|
291464
291273
|
* 创建文件夹结构
|
|
291465
291274
|
*/
|
|
@@ -291520,7 +291329,7 @@ var init_ResourcePackageImporter = __esm({
|
|
|
291520
291329
|
/**
|
|
291521
291330
|
* 预处理文件数据:
|
|
291522
291331
|
* - metadata 始终走 editor-internal 形态(url→refId / assetUrl→assetId)。
|
|
291523
|
-
* - source scene/prefab main file 走 v2 source 形态(url→$ref(
|
|
291332
|
+
* - source scene/prefab main file 走 v2 source 形态(url→$ref(assetId))。
|
|
291524
291333
|
* - 其他 JSON main file 走 editor-internal 形态(url→refId)。
|
|
291525
291334
|
*/
|
|
291526
291335
|
async _preprocessFileData(entry, fileData, resolveUrlToAssetId, resolveUrlToSourceRef) {
|
|
@@ -292097,9 +291906,7 @@ function performHeadlessSceneSwap(args) {
|
|
|
292097
291906
|
const state = domainStore.state;
|
|
292098
291907
|
const nextAssets = { ...state.assets };
|
|
292099
291908
|
if (currentSceneId && nextAssets[currentSceneId]?.type === "Scene") {
|
|
292100
|
-
const sceneFile = domainStateToSceneFileV2(state
|
|
292101
|
-
resolveAssetRef: (assetId) => resolveAssetRefForSource(state, assetId)
|
|
292102
|
-
});
|
|
291909
|
+
const sceneFile = domainStateToSceneFileV2(state);
|
|
292103
291910
|
nextAssets[currentSceneId] = {
|
|
292104
291911
|
...nextAssets[currentSceneId],
|
|
292105
291912
|
content: sceneFile
|
|
@@ -292111,10 +291918,8 @@ function performHeadlessSceneSwap(args) {
|
|
|
292111
291918
|
let newPrefabState = { bindings: {}, byAssetId: {} };
|
|
292112
291919
|
const targetContent = nextAssets[targetSceneId]?.content;
|
|
292113
291920
|
if (targetContent && typeof targetContent === "object") {
|
|
292114
|
-
const resolveSourceRef2 = createSourceRefResolver2(state);
|
|
292115
291921
|
const resolveAssetKind3 = createSourceAssetKindResolver2(state);
|
|
292116
291922
|
const hydrated = hydrateSourceV2SceneToDomain(targetContent, {
|
|
292117
|
-
resolveSourceRef: resolveSourceRef2,
|
|
292118
291923
|
resolveAssetKind: resolveAssetKind3,
|
|
292119
291924
|
resolvePrefabSourceFile: (assetId) => {
|
|
292120
291925
|
const content = nextAssets[assetId]?.content;
|
|
@@ -292136,45 +291941,8 @@ function performHeadlessSceneSwap(args) {
|
|
|
292136
291941
|
domainStore.reset(newState);
|
|
292137
291942
|
return { entityCount: Object.keys(newEntities).length };
|
|
292138
291943
|
}
|
|
292139
|
-
function resolveAssetRefForSource(state, assetId) {
|
|
292140
|
-
return assetIdToVirtualPath(state, assetId) ?? assetId;
|
|
292141
|
-
}
|
|
292142
|
-
function assetIdToVirtualPath(state, assetId) {
|
|
292143
|
-
const asset3 = state.assets[assetId];
|
|
292144
|
-
if (!asset3)
|
|
292145
|
-
return void 0;
|
|
292146
|
-
const folders = [];
|
|
292147
|
-
let parentId = asset3.parentFolderId;
|
|
292148
|
-
while (parentId) {
|
|
292149
|
-
const folder = state.assets[parentId];
|
|
292150
|
-
if (!folder)
|
|
292151
|
-
break;
|
|
292152
|
-
folders.unshift(folder.name);
|
|
292153
|
-
parentId = folder.parentFolderId;
|
|
292154
|
-
}
|
|
292155
|
-
const assetName = asset3.type === "Folder" ? asset3.name : assetNameFromPath(asset3.name, asset3.type);
|
|
292156
|
-
return `${folders.length ? `${folders.join("/")}/` : ""}${assetName}`;
|
|
292157
|
-
}
|
|
292158
|
-
function virtualPathToAssetId(state, virtualPath) {
|
|
292159
|
-
if (state.assets[virtualPath])
|
|
292160
|
-
return virtualPath;
|
|
292161
|
-
for (const assetId of Object.keys(state.assets)) {
|
|
292162
|
-
if (assetIdToVirtualPath(state, assetId) === virtualPath)
|
|
292163
|
-
return assetId;
|
|
292164
|
-
}
|
|
292165
|
-
return void 0;
|
|
292166
|
-
}
|
|
292167
|
-
function createSourceRefResolver2(state) {
|
|
292168
|
-
return (ref) => {
|
|
292169
|
-
const assetId = virtualPathToAssetId(state, ref);
|
|
292170
|
-
if (!assetId) {
|
|
292171
|
-
throw new Error(`source v2 asset ref "${ref}" does not match any project asset`);
|
|
292172
|
-
}
|
|
292173
|
-
return assetId;
|
|
292174
|
-
};
|
|
292175
|
-
}
|
|
292176
291944
|
function createSourceAssetKindResolver2(state) {
|
|
292177
|
-
return (
|
|
291945
|
+
return (assetId) => {
|
|
292178
291946
|
const type = state.assets[assetId]?.type;
|
|
292179
291947
|
return type === "Prefab" || type === "glTF" ? type : void 0;
|
|
292180
291948
|
};
|
|
@@ -292182,7 +291950,6 @@ function createSourceAssetKindResolver2(state) {
|
|
|
292182
291950
|
var init_sceneSwap = __esm({
|
|
292183
291951
|
"../model/src/headless/sceneSwap.ts"() {
|
|
292184
291952
|
"use strict";
|
|
292185
|
-
init_sync_adapter();
|
|
292186
291953
|
init_scene_file_v2();
|
|
292187
291954
|
init_hydrateSourceV2SceneToDomain();
|
|
292188
291955
|
}
|
|
@@ -446073,7 +445840,7 @@ function combineLayers(layers) {
|
|
|
446073
445840
|
combined |= l6;
|
|
446074
445841
|
return combined;
|
|
446075
445842
|
}
|
|
446076
|
-
var TRANSFORM_PROPERTIES, TRANSFORM_COMPONENT_TYPES, SCENE_ROOT_ID, InspectorFacade;
|
|
445843
|
+
var TRANSFORM_PROPERTIES, TRANSFORM_COMPONENT_TYPES, VIRTUAL_TRANSFORM_SUFFIX, SCENE_ROOT_ID, InspectorFacade;
|
|
446077
445844
|
var init_InspectorFacade = __esm({
|
|
446078
445845
|
"../model/src/facades/InspectorFacade.ts"() {
|
|
446079
445846
|
"use strict";
|
|
@@ -446081,6 +445848,7 @@ var init_InspectorFacade = __esm({
|
|
|
446081
445848
|
init_resolveSceneChangePath();
|
|
446082
445849
|
TRANSFORM_PROPERTIES = /* @__PURE__ */ new Set(["position", "rotation", "scale"]);
|
|
446083
445850
|
TRANSFORM_COMPONENT_TYPES = /* @__PURE__ */ new Set(["Transform", "UITransform"]);
|
|
445851
|
+
VIRTUAL_TRANSFORM_SUFFIX = ":Transform";
|
|
446084
445852
|
SCENE_ROOT_ID = "__scene__";
|
|
446085
445853
|
InspectorFacade = class {
|
|
446086
445854
|
constructor(root3) {
|
|
@@ -446113,6 +445881,7 @@ var init_InspectorFacade = __esm({
|
|
|
446113
445881
|
throw new Error(`InspectorFacade.applyChange: component owner not found: ${input.objectId}`);
|
|
446114
445882
|
}
|
|
446115
445883
|
if (this.isTransformProperty(ownerEntityId, input.objectId, input.property)) {
|
|
445884
|
+
const isVirtualTransformComponent = this.isVirtualTransformComponent(input.objectId, ownerEntityId);
|
|
446116
445885
|
if (this._batchEntityId && this._batchEntityId !== ownerEntityId) {
|
|
446117
445886
|
this.flushBatch();
|
|
446118
445887
|
}
|
|
@@ -446130,9 +445899,11 @@ var init_InspectorFacade = __esm({
|
|
|
446130
445899
|
value
|
|
446131
445900
|
);
|
|
446132
445901
|
this._getOrCreateBatch().apply(ops2);
|
|
446133
|
-
|
|
446134
|
-
|
|
446135
|
-
|
|
445902
|
+
if (!isVirtualTransformComponent) {
|
|
445903
|
+
this.root.componentFacade.updateComponent(ownerEntityId, input.objectId, {
|
|
445904
|
+
[input.property]: value
|
|
445905
|
+
});
|
|
445906
|
+
}
|
|
446136
445907
|
return;
|
|
446137
445908
|
}
|
|
446138
445909
|
this.root.componentFacade.updateComponent(ownerEntityId, input.objectId, {
|
|
@@ -446259,6 +446030,8 @@ var init_InspectorFacade = __esm({
|
|
|
446259
446030
|
isTransformProperty(entityId, componentId, property2) {
|
|
446260
446031
|
if (!TRANSFORM_PROPERTIES.has(property2))
|
|
446261
446032
|
return false;
|
|
446033
|
+
if (this.isVirtualTransformComponent(componentId, entityId))
|
|
446034
|
+
return true;
|
|
446262
446035
|
const normalized = this.root.domainStore.getNormalizedState();
|
|
446263
446036
|
return normalized.relations.componentOwner[componentId] === entityId && TRANSFORM_COMPONENT_TYPES.has(normalized.components[componentId]?.type ?? "");
|
|
446264
446037
|
}
|
|
@@ -446274,7 +446047,22 @@ var init_InspectorFacade = __esm({
|
|
|
446274
446047
|
];
|
|
446275
446048
|
}
|
|
446276
446049
|
findComponentOwnerEntityId(componentId) {
|
|
446277
|
-
|
|
446050
|
+
const normalized = this.root.domainStore.getNormalizedState();
|
|
446051
|
+
const ownerEntityId = normalized.relations.componentOwner[componentId];
|
|
446052
|
+
if (ownerEntityId)
|
|
446053
|
+
return ownerEntityId;
|
|
446054
|
+
return this.resolveVirtualTransformOwnerEntityId(componentId);
|
|
446055
|
+
}
|
|
446056
|
+
resolveVirtualTransformOwnerEntityId(componentId) {
|
|
446057
|
+
if (!componentId.endsWith(VIRTUAL_TRANSFORM_SUFFIX))
|
|
446058
|
+
return null;
|
|
446059
|
+
const entityId = componentId.slice(0, -VIRTUAL_TRANSFORM_SUFFIX.length);
|
|
446060
|
+
if (!entityId)
|
|
446061
|
+
return null;
|
|
446062
|
+
return this.root.domainStore.getNormalizedState().entities[entityId] ? entityId : null;
|
|
446063
|
+
}
|
|
446064
|
+
isVirtualTransformComponent(componentId, entityId) {
|
|
446065
|
+
return this.resolveVirtualTransformOwnerEntityId(componentId) === entityId;
|
|
446278
446066
|
}
|
|
446279
446067
|
};
|
|
446280
446068
|
}
|
|
@@ -446419,6 +446207,9 @@ var init_Meta = __esm({
|
|
|
446419
446207
|
});
|
|
446420
446208
|
|
|
446421
446209
|
// ../model/src/modules/assets/collectAssetReferenceIds.ts
|
|
446210
|
+
function isSourceAssetRefRecord(node) {
|
|
446211
|
+
return typeof node.$ref === "string" && isValidSourceAssetRef(node.$ref) && Object.keys(node).every((key2) => SOURCE_ASSET_REF_KEYS.has(key2));
|
|
446212
|
+
}
|
|
446422
446213
|
function collectAssetReferenceIds(value, options, result2 = /* @__PURE__ */ new Set()) {
|
|
446423
446214
|
const visit = (node, key2) => {
|
|
446424
446215
|
if (Array.isArray(node)) {
|
|
@@ -446437,11 +446228,11 @@ function collectAssetReferenceIds(value, options, result2 = /* @__PURE__ */ new
|
|
|
446437
446228
|
if (typeof node.refId === "string" && node.refId !== options.currentAssetId) {
|
|
446438
446229
|
result2.add(node.refId);
|
|
446439
446230
|
}
|
|
446440
|
-
if (
|
|
446441
|
-
|
|
446442
|
-
|
|
446443
|
-
result2.add(resolvedAssetId);
|
|
446231
|
+
if (isSourceAssetRefRecord(node)) {
|
|
446232
|
+
if (node.$ref !== options.currentAssetId) {
|
|
446233
|
+
result2.add(node.$ref);
|
|
446444
446234
|
}
|
|
446235
|
+
return;
|
|
446445
446236
|
}
|
|
446446
446237
|
for (const [childKey, childValue] of Object.entries(node)) {
|
|
446447
446238
|
visit(childValue, childKey);
|
|
@@ -446450,10 +446241,13 @@ function collectAssetReferenceIds(value, options, result2 = /* @__PURE__ */ new
|
|
|
446450
446241
|
visit(value);
|
|
446451
446242
|
return result2;
|
|
446452
446243
|
}
|
|
446244
|
+
var SOURCE_ASSET_REF_KEYS;
|
|
446453
446245
|
var init_collectAssetReferenceIds = __esm({
|
|
446454
446246
|
"../model/src/modules/assets/collectAssetReferenceIds.ts"() {
|
|
446455
446247
|
"use strict";
|
|
446456
446248
|
init_is_record();
|
|
446249
|
+
init_source_ref_codec();
|
|
446250
|
+
SOURCE_ASSET_REF_KEYS = /* @__PURE__ */ new Set(["$ref", "key", "isClone"]);
|
|
446457
446251
|
}
|
|
446458
446252
|
});
|
|
446459
446253
|
|
|
@@ -516360,8 +516154,7 @@ var init_EditorAsset = __esm({
|
|
|
516360
516154
|
this._dependsOnAssetIds.clear();
|
|
516361
516155
|
const collectRefs = (value) => collectAssetReferenceIds(value, {
|
|
516362
516156
|
currentAssetId: this.id,
|
|
516363
|
-
extractInstanceAssetId: _EditorAsset._extractV1InstanceAssetId
|
|
516364
|
-
resolveVirtualPath: (virtualPath) => this.root?.assetStore?.getAssetByVirtualPath?.(virtualPath)?.id
|
|
516157
|
+
extractInstanceAssetId: _EditorAsset._extractV1InstanceAssetId
|
|
516365
516158
|
});
|
|
516366
516159
|
collectRefs(this.meta).forEach((refId) => this._dependsOnAssetIds.add(refId));
|
|
516367
516160
|
if (this._originMainFile) {
|
|
@@ -517024,7 +516817,6 @@ var init_ResourcePackageExporter = __esm({
|
|
|
517024
516817
|
init_types4();
|
|
517025
516818
|
init_manifest2();
|
|
517026
516819
|
init_refConverter();
|
|
517027
|
-
init_source_ref_codec();
|
|
517028
516820
|
init_collectAssetReferenceIds();
|
|
517029
516821
|
ResourcePackageExporter = class _ResourcePackageExporter {
|
|
517030
516822
|
root;
|
|
@@ -517132,23 +516924,9 @@ var init_ResourcePackageExporter = __esm({
|
|
|
517132
516924
|
collectAssetReferences(asset3, value) {
|
|
517133
516925
|
return collectAssetReferenceIds(value, {
|
|
517134
516926
|
currentAssetId: asset3.id,
|
|
517135
|
-
extractInstanceAssetId: _ResourcePackageExporter.extractEntityInstanceAssetId
|
|
517136
|
-
resolveVirtualPath: (virtualPath) => this.resolveAssetIdByVirtualPath(virtualPath)
|
|
516927
|
+
extractInstanceAssetId: _ResourcePackageExporter.extractEntityInstanceAssetId
|
|
517137
516928
|
});
|
|
517138
516929
|
}
|
|
517139
|
-
resolveAssetIdByVirtualPath(virtualPath) {
|
|
517140
|
-
const fromIndex = this.assetStore.getAssetByVirtualPath?.(virtualPath)?.id;
|
|
517141
|
-
if (fromIndex)
|
|
517142
|
-
return fromIndex;
|
|
517143
|
-
const normalizedTarget = normalizeSourceVirtualPath(virtualPath);
|
|
517144
|
-
for (const asset3 of Object.values(this.assetStore.assets)) {
|
|
517145
|
-
const assetPath = this.getVirtualPath(asset3);
|
|
517146
|
-
if (assetPath === virtualPath || normalizeSourceVirtualPath(assetPath) === normalizedTarget) {
|
|
517147
|
-
return asset3.id;
|
|
517148
|
-
}
|
|
517149
|
-
}
|
|
517150
|
-
return void 0;
|
|
517151
|
-
}
|
|
517152
516930
|
/**
|
|
517153
516931
|
* 判断资产是否应该跳过(子资产、内置锁定资产等)
|
|
517154
516932
|
*/
|
|
@@ -517253,27 +517031,16 @@ var init_ResourcePackageExporter = __esm({
|
|
|
517253
517031
|
return null;
|
|
517254
517032
|
}
|
|
517255
517033
|
createExportRefResolver() {
|
|
517256
|
-
const virtualPaths = /* @__PURE__ */ new Map();
|
|
517257
|
-
for (const asset3 of Object.values(this.assetStore.assets)) {
|
|
517258
|
-
try {
|
|
517259
|
-
const virtualPath = asset3.getRouteString(true);
|
|
517260
|
-
if (virtualPath) {
|
|
517261
|
-
virtualPaths.set(virtualPath, virtualPath);
|
|
517262
|
-
virtualPaths.set(normalizeSourceVirtualPath(virtualPath), virtualPath);
|
|
517263
|
-
}
|
|
517264
|
-
} catch {
|
|
517265
|
-
}
|
|
517266
|
-
}
|
|
517267
517034
|
return (value) => {
|
|
517268
517035
|
const asset3 = this.assetStore.assets[value];
|
|
517269
517036
|
if (asset3)
|
|
517270
517037
|
return asset3.getRouteString(true) || void 0;
|
|
517271
|
-
return
|
|
517038
|
+
return void 0;
|
|
517272
517039
|
};
|
|
517273
517040
|
}
|
|
517274
517041
|
/**
|
|
517275
517042
|
* 深度遍历对象,将资产引用转换为 GRP 包内 { url: "/virtualPath" } 格式。
|
|
517276
|
-
* 支持 editor-internal { refId: assetId } 和 source v2 { $ref:
|
|
517043
|
+
* 支持 editor-internal { refId: assetId } 和 source v2 { $ref: assetId } 两种输入。
|
|
517277
517044
|
*/
|
|
517278
517045
|
convertRefIdsInObject(obj, resolveRef3 = this.createExportRefResolver()) {
|
|
517279
517046
|
return exportRefs(obj, resolveRef3);
|
|
@@ -546707,8 +546474,8 @@ var require_registry = __commonJS({
|
|
|
546707
546474
|
if (this.exist(name16) && !force && !x6_common_1.Platform.isApplyingHMR()) {
|
|
546708
546475
|
this.onDuplicated(name16);
|
|
546709
546476
|
}
|
|
546710
|
-
const
|
|
546711
|
-
const entity =
|
|
546477
|
+
const process7 = this.options.process;
|
|
546478
|
+
const entity = process7 ? x6_common_1.FunctionExt.call(process7, this, name16, options) : options;
|
|
546712
546479
|
this.data[name16] = entity;
|
|
546713
546480
|
return entity;
|
|
546714
546481
|
}
|
|
@@ -603705,6 +603472,11 @@ var init_collectComponentPropsFromBinding = __esm({
|
|
|
603705
603472
|
});
|
|
603706
603473
|
|
|
603707
603474
|
// ../model/src/modules/entity/helpers/collectEntityPropsFromBinding.ts
|
|
603475
|
+
function vectorPatchToTuple(patch, source) {
|
|
603476
|
+
if (!patch)
|
|
603477
|
+
return void 0;
|
|
603478
|
+
return [patch.x ?? source.x, patch.y ?? source.y, patch.z ?? source.z];
|
|
603479
|
+
}
|
|
603708
603480
|
function collectEntityPropsFromBinding(binding) {
|
|
603709
603481
|
const overrides = binding.overrides?.entityProps;
|
|
603710
603482
|
if (!overrides)
|
|
@@ -603714,7 +603486,8 @@ function collectEntityPropsFromBinding(binding) {
|
|
|
603714
603486
|
for (const [sourceEntityId, state] of Object.entries(overrides)) {
|
|
603715
603487
|
if (sourceEntityIsCoveredByRemovedEntity(binding, sourceEntityId))
|
|
603716
603488
|
continue;
|
|
603717
|
-
|
|
603489
|
+
const snapshot = snapshots[sourceEntityId];
|
|
603490
|
+
if (!snapshot)
|
|
603718
603491
|
continue;
|
|
603719
603492
|
const props = {};
|
|
603720
603493
|
if (state.name !== void 0)
|
|
@@ -603725,15 +603498,15 @@ function collectEntityPropsFromBinding(binding) {
|
|
|
603725
603498
|
props.layer = state.layer;
|
|
603726
603499
|
if (state.transform) {
|
|
603727
603500
|
const t8 = state.transform;
|
|
603728
|
-
|
|
603729
|
-
|
|
603730
|
-
|
|
603731
|
-
if (
|
|
603732
|
-
props.
|
|
603733
|
-
|
|
603734
|
-
|
|
603735
|
-
|
|
603736
|
-
|
|
603501
|
+
const position = vectorPatchToTuple(t8.position, snapshot.transform.position);
|
|
603502
|
+
const rotation = vectorPatchToTuple(t8.rotation, snapshot.transform.rotation);
|
|
603503
|
+
const scale2 = vectorPatchToTuple(t8.scale, snapshot.transform.scale);
|
|
603504
|
+
if (position)
|
|
603505
|
+
props.position = position;
|
|
603506
|
+
if (rotation)
|
|
603507
|
+
props.rotation = rotation;
|
|
603508
|
+
if (scale2)
|
|
603509
|
+
props.scale = scale2;
|
|
603737
603510
|
}
|
|
603738
603511
|
if (Object.keys(props).length === 0)
|
|
603739
603512
|
continue;
|
|
@@ -606987,7 +606760,7 @@ var init_EntityModel = __esm({
|
|
|
606987
606760
|
const sourceRootAssetRef = sourceRootInstanceAsset?.$ref;
|
|
606988
606761
|
if (!sourceRootAssetRef)
|
|
606989
606762
|
return void 0;
|
|
606990
|
-
const sourceRootAsset = this.root.assetStore.
|
|
606763
|
+
const sourceRootAsset = this.root.assetStore.assets?.[sourceRootAssetRef];
|
|
606991
606764
|
const assetKind = sourceRootAsset?.getMetaConfig?.()?.type;
|
|
606992
606765
|
if (assetKind !== "glTF")
|
|
606993
606766
|
return void 0;
|
|
@@ -607426,22 +607199,19 @@ var init_SerializeContext = __esm({
|
|
|
607426
607199
|
components = [];
|
|
607427
607200
|
/** 按序收集的组件 ID。仅供调用方做局部匹配,不写入 source 文件。 */
|
|
607428
607201
|
componentIds = [];
|
|
607429
|
-
/** assetId → virtualPath 解析函数 */
|
|
607430
|
-
_resolveVirtualPath;
|
|
607431
607202
|
_sourceRefCodec;
|
|
607432
607203
|
/** 根据 componentId 查 raw 透传字段(script/calls/refId),用于补 toJSON 遗失的字段。 */
|
|
607433
607204
|
_lookupComponentState;
|
|
607434
|
-
constructor(orderedEntityIds,
|
|
607205
|
+
constructor(orderedEntityIds, lookupComponentState) {
|
|
607435
607206
|
this.entityIds = orderedEntityIds;
|
|
607436
|
-
this.
|
|
607437
|
-
this._sourceRefCodec = createSourceRefCodec({ resolveAssetRef: resolveVirtualPath });
|
|
607207
|
+
this._sourceRefCodec = createSourceRefCodec({});
|
|
607438
607208
|
this._lookupComponentState = lookupComponentState;
|
|
607439
607209
|
this.entityIndex = /* @__PURE__ */ new Map();
|
|
607440
607210
|
for (let i6 = 0; i6 < orderedEntityIds.length; i6++) {
|
|
607441
607211
|
this.entityIndex.set(orderedEntityIds[i6], i6);
|
|
607442
607212
|
}
|
|
607443
607213
|
}
|
|
607444
|
-
/** assetId →
|
|
607214
|
+
/** assetId → source $ref. In source-v2 this is identity. */
|
|
607445
607215
|
resolveVirtualPath(assetId) {
|
|
607446
607216
|
return this._sourceRefCodec.domainToSource(assetId);
|
|
607447
607217
|
}
|
|
@@ -607482,9 +607252,9 @@ var init_SerializeContext = __esm({
|
|
|
607482
607252
|
hasEntityId(entityId) {
|
|
607483
607253
|
return this.entityIndex.has(entityId);
|
|
607484
607254
|
}
|
|
607485
|
-
/** 递归转换对象中的 { refId } → { $ref:
|
|
607255
|
+
/** 递归转换对象中的 { refId } → { $ref: assetId } */
|
|
607486
607256
|
convertRefs(value) {
|
|
607487
|
-
return convertInternalRefsToSourceValue(value
|
|
607257
|
+
return convertInternalRefsToSourceValue(value);
|
|
607488
607258
|
}
|
|
607489
607259
|
};
|
|
607490
607260
|
}
|
|
@@ -607494,15 +607264,6 @@ var init_SerializeContext = __esm({
|
|
|
607494
607264
|
function isSceneFile2(file2) {
|
|
607495
607265
|
return "scene" in file2;
|
|
607496
607266
|
}
|
|
607497
|
-
function createRequiredLocalSourceRefResolver(resolveSourceRef2) {
|
|
607498
|
-
return (ref) => {
|
|
607499
|
-
const assetId = resolveSourceRef2?.(ref);
|
|
607500
|
-
if (typeof assetId !== "string" || assetId.length === 0) {
|
|
607501
|
-
throw new Error(`Unable to resolve source asset ref "${ref}" to an editor asset id during local v2 hydration`);
|
|
607502
|
-
}
|
|
607503
|
-
return assetId;
|
|
607504
|
-
};
|
|
607505
|
-
}
|
|
607506
607267
|
function buildParentById(file2) {
|
|
607507
607268
|
const parentById = /* @__PURE__ */ new Map();
|
|
607508
607269
|
file2.entities.forEach((entity) => {
|
|
@@ -607514,18 +607275,18 @@ function buildParentById(file2) {
|
|
|
607514
607275
|
});
|
|
607515
607276
|
return parentById;
|
|
607516
607277
|
}
|
|
607517
|
-
function componentToLocalSchema(component2, componentId
|
|
607278
|
+
function componentToLocalSchema(component2, componentId) {
|
|
607518
607279
|
return {
|
|
607519
607280
|
id: componentId,
|
|
607520
607281
|
type: component2.type,
|
|
607521
|
-
props: convertAssetRefsToDomainRefs(component2.props ?? {}
|
|
607282
|
+
props: convertAssetRefsToDomainRefs(component2.props ?? {}),
|
|
607522
607283
|
...component2.script?.$ref ? {
|
|
607523
607284
|
script: {
|
|
607524
|
-
$ref:
|
|
607285
|
+
$ref: component2.script.$ref,
|
|
607525
607286
|
...component2.script.key ? { key: component2.script.key } : {}
|
|
607526
607287
|
}
|
|
607527
607288
|
} : {},
|
|
607528
|
-
...component2.calls?.length ? { calls: convertAssetRefsToDomainRefs(component2.calls
|
|
607289
|
+
...component2.calls?.length ? { calls: convertAssetRefsToDomainRefs(component2.calls) } : {}
|
|
607529
607290
|
};
|
|
607530
607291
|
}
|
|
607531
607292
|
function readTransform(entity, rootOverrideTarget) {
|
|
@@ -607578,7 +607339,7 @@ function insertLocalChild(parent2, child, sourceChildOffset) {
|
|
|
607578
607339
|
return;
|
|
607579
607340
|
parent2.engineObject.addChild(Math.min(sourceChildOffset, parent2.engineObject.children.length), child.engineObject);
|
|
607580
607341
|
}
|
|
607581
|
-
async function addSourceComponents(model, sourceEntity, sourceIndex
|
|
607342
|
+
async function addSourceComponents(model, sourceEntity, sourceIndex) {
|
|
607582
607343
|
const transform5 = readTransform(sourceEntity);
|
|
607583
607344
|
if (!model.transform && !hasSourceTransformComponent(sourceEntity, sourceIndex) && EditorComponent.getRegisteredComponent("Transform")) {
|
|
607584
607345
|
await model.addEditorComponent({
|
|
@@ -607592,7 +607353,7 @@ async function addSourceComponents(model, sourceEntity, sourceIndex, resolveSour
|
|
|
607592
607353
|
if (!component2) {
|
|
607593
607354
|
throw new Error(`Invalid source v2 local hydration: component "${componentId}" is missing from source index`);
|
|
607594
607355
|
}
|
|
607595
|
-
await model.addEditorComponent(componentToLocalSchema(component2, componentId
|
|
607356
|
+
await model.addEditorComponent(componentToLocalSchema(component2, componentId));
|
|
607596
607357
|
}
|
|
607597
607358
|
}
|
|
607598
607359
|
async function createSourceEntityModel(manager, sourceIndex, entityId, options) {
|
|
@@ -607602,8 +607363,8 @@ async function createSourceEntityModel(manager, sourceIndex, entityId, options)
|
|
|
607602
607363
|
}
|
|
607603
607364
|
const instanceRef = sourceEntity.instance?.asset;
|
|
607604
607365
|
if (instanceRef?.$ref) {
|
|
607605
|
-
const assetId =
|
|
607606
|
-
const assetKind = options.resolveAssetKind(
|
|
607366
|
+
const assetId = instanceRef.$ref;
|
|
607367
|
+
const assetKind = options.resolveAssetKind(assetId);
|
|
607607
607368
|
const rootOverrideTarget = resolveSourceInstanceRootOverrideTarget({
|
|
607608
607369
|
sourceEntity,
|
|
607609
607370
|
fallbackSourceEntityId: entityId,
|
|
@@ -607637,7 +607398,7 @@ async function createSourceEntityModel(manager, sourceIndex, entityId, options)
|
|
|
607637
607398
|
await model.initImmediate();
|
|
607638
607399
|
await model.ensureReady();
|
|
607639
607400
|
applySourceEntityState(model, sourceEntity);
|
|
607640
|
-
await addSourceComponents(model, sourceEntity, sourceIndex
|
|
607401
|
+
await addSourceComponents(model, sourceEntity, sourceIndex);
|
|
607641
607402
|
applySourceEntityState(model, sourceEntity);
|
|
607642
607403
|
return model;
|
|
607643
607404
|
}
|
|
@@ -607651,9 +607412,7 @@ async function hydrateSourceV2LocalEntities(manager, file2, options = {}) {
|
|
|
607651
607412
|
if (shouldClearExisting) {
|
|
607652
607413
|
manager.clear();
|
|
607653
607414
|
}
|
|
607654
|
-
const resolveSourceRef2 = createRequiredLocalSourceRefResolver(options.resolveSourceRef);
|
|
607655
607415
|
const normalizedOptions = {
|
|
607656
|
-
resolveSourceRef: resolveSourceRef2,
|
|
607657
607416
|
resolveAssetKind: options.resolveAssetKind ?? (() => void 0),
|
|
607658
607417
|
resolvePrefabSourceFile: options.resolvePrefabSourceFile,
|
|
607659
607418
|
clearExisting: shouldClearExisting,
|
|
@@ -608682,19 +608441,9 @@ var init_EntityManager = __esm({
|
|
|
608682
608441
|
this.clear();
|
|
608683
608442
|
const raw = parsedData ?? JSON.parse(sceneAsset.getMainData());
|
|
608684
608443
|
assertSourceV2LocalHydrationFile(raw, `Asset "${sceneAsset.name ?? sceneAsset.id}"`);
|
|
608685
|
-
const getAssetByVirtualPath = (virtualPath) => this.root?.assetStore?.getAssetByVirtualPath?.(virtualPath);
|
|
608686
608444
|
await this.hydrateSourceV2LocalEntities(raw, {
|
|
608687
|
-
|
|
608688
|
-
const
|
|
608689
|
-
if (typeof assetId !== "string" || assetId.length === 0) {
|
|
608690
|
-
throw new Error(
|
|
608691
|
-
`[SceneV2] Unable to resolve asset ref "${virtualPath}" while loading asset "${sceneAsset.id}". Source-v2 $ref must be a virtualPath, not an editor asset id.`
|
|
608692
|
-
);
|
|
608693
|
-
}
|
|
608694
|
-
return assetId;
|
|
608695
|
-
},
|
|
608696
|
-
resolveAssetKind: (virtualPath) => {
|
|
608697
|
-
const type = getAssetByVirtualPath(virtualPath)?.getMetaConfig?.()?.type;
|
|
608445
|
+
resolveAssetKind: (assetId) => {
|
|
608446
|
+
const type = this.root?.assetStore?.assets?.[assetId]?.getMetaConfig?.()?.type;
|
|
608698
608447
|
return type === "Prefab" || type === "glTF" ? type : void 0;
|
|
608699
608448
|
}
|
|
608700
608449
|
});
|
|
@@ -609448,8 +609197,6 @@ var init_EntityManager = __esm({
|
|
|
609448
609197
|
toJSON(isForPrefab = false) {
|
|
609449
609198
|
const orderedEntities = this._collectOrderedEntities(isForPrefab);
|
|
609450
609199
|
const orderedIds = orderedEntities.map((e6) => e6.id);
|
|
609451
|
-
const assetStore = this.root?.assetStore;
|
|
609452
|
-
const resolveVirtualPath = (assetId) => assetStore?.getAssetVirtualPath?.(assetId);
|
|
609453
609200
|
const domainStore = this.root?.domainStore;
|
|
609454
609201
|
const lookupComponentState = domainStore ? (componentId) => {
|
|
609455
609202
|
const comp = domainStore.getNormalizedState().components[componentId];
|
|
@@ -609461,7 +609208,7 @@ var init_EntityManager = __esm({
|
|
|
609461
609208
|
...comp.calls ? { calls: comp.calls } : {}
|
|
609462
609209
|
};
|
|
609463
609210
|
} : void 0;
|
|
609464
|
-
const ctx = new SerializeContext(orderedIds,
|
|
609211
|
+
const ctx = new SerializeContext(orderedIds, lookupComponentState);
|
|
609465
609212
|
const entities = orderedEntities.map((entity) => entity.toV2(ctx, isForPrefab));
|
|
609466
609213
|
return {
|
|
609467
609214
|
entities,
|
|
@@ -610216,7 +609963,7 @@ var init_EditorScene = __esm({
|
|
|
610216
609963
|
const sourceRefs = sceneFile.entities.map((entity) => entity.instance?.asset?.$ref).filter((sourceRef) => typeof sourceRef === "string");
|
|
610217
609964
|
await Promise.all(
|
|
610218
609965
|
sourceRefs.map(async (sourceRef) => {
|
|
610219
|
-
const asset3 = this.root.assetStore.
|
|
609966
|
+
const asset3 = this.root.assetStore.assets[sourceRef];
|
|
610220
609967
|
const type = asset3?.getMetaConfig?.()?.type;
|
|
610221
609968
|
if (type !== "Prefab")
|
|
610222
609969
|
return;
|
|
@@ -610243,7 +609990,7 @@ var init_EditorScene = __esm({
|
|
|
610243
609990
|
const sourceRef = entity.instance?.asset?.$ref;
|
|
610244
609991
|
if (!sourceRef)
|
|
610245
609992
|
continue;
|
|
610246
|
-
const asset3 = this.root.assetStore.
|
|
609993
|
+
const asset3 = this.root.assetStore.assets[sourceRef];
|
|
610247
609994
|
const assetId = asset3?.id;
|
|
610248
609995
|
if (!asset3 || !assetId) {
|
|
610249
609996
|
throw new Error(
|
|
@@ -610330,17 +610077,14 @@ var init_EditorScene = __esm({
|
|
|
610330
610077
|
async init(sceneAsset) {
|
|
610331
610078
|
const sceneFile = parseSourceV2SceneFileJson(sceneAsset.getMainData());
|
|
610332
610079
|
await this.ensureSourceInstancePrefabFilesLoaded(sceneFile);
|
|
610333
|
-
const getAssetByVirtualPath = (virtualPath) => this.root.assetStore.getAssetByVirtualPath?.(virtualPath);
|
|
610334
610080
|
const sourceRefCodec = createSourceRefCodec({
|
|
610335
|
-
|
|
610336
|
-
|
|
610337
|
-
const type = getAssetByVirtualPath(virtualPath)?.getMetaConfig?.()?.type;
|
|
610081
|
+
resolveAssetKind: (assetId) => {
|
|
610082
|
+
const type = this.root.assetStore.assets[assetId]?.getMetaConfig?.()?.type;
|
|
610338
610083
|
return type === "Prefab" || type === "glTF" ? type : void 0;
|
|
610339
610084
|
}
|
|
610340
610085
|
});
|
|
610341
610086
|
const hydrated = hydrateSourceV2SceneToDomain(sceneFile, {
|
|
610342
|
-
|
|
610343
|
-
resolveAssetKind: (virtualPath) => sourceRefCodec.maybeResolveAssetKind(virtualPath),
|
|
610087
|
+
resolveAssetKind: (assetId) => sourceRefCodec.maybeResolveAssetKind(assetId),
|
|
610344
610088
|
resolvePrefabSourceFile: (assetId) => {
|
|
610345
610089
|
return readLoadedPrefabSourceFile(this.root.assetStore.assets[assetId]);
|
|
610346
610090
|
}
|
|
@@ -610424,10 +610168,7 @@ var init_EditorScene = __esm({
|
|
|
610424
610168
|
*/
|
|
610425
610169
|
deserialize(sceneFile) {
|
|
610426
610170
|
const serializeConfigs = getSerializeConfigs(this);
|
|
610427
|
-
const sceneWithEditorRefs = sourceSceneSettingsToEditorSettings(
|
|
610428
|
-
sceneFile.scene ?? {},
|
|
610429
|
-
(ref) => this.root.assetStore.getAssetByVirtualPath?.(ref)?.id
|
|
610430
|
-
);
|
|
610171
|
+
const sceneWithEditorRefs = sourceSceneSettingsToEditorSettings(sceneFile.scene ?? {});
|
|
610431
610172
|
const editorSceneFile = { ...sceneFile, scene: sceneWithEditorRefs };
|
|
610432
610173
|
Object.keys(serializeConfigs).forEach((key2) => {
|
|
610433
610174
|
const serializeConfig = serializeConfigs[key2];
|
|
@@ -610479,10 +610220,7 @@ var init_EditorScene = __esm({
|
|
|
610479
610220
|
}
|
|
610480
610221
|
set2(settingsData, serialKey, value);
|
|
610481
610222
|
});
|
|
610482
|
-
const sceneSettings = editorSceneSettingsToSourceSettings(
|
|
610483
|
-
settingsData.scene ?? {},
|
|
610484
|
-
(assetId) => this.root.assetStore.getAssetVirtualPath?.(assetId)
|
|
610485
|
-
);
|
|
610223
|
+
const sceneSettings = editorSceneSettingsToSourceSettings(settingsData.scene ?? {});
|
|
610486
610224
|
const sceneAssetName = this.root.assetStore.assets[this.refId]?.name;
|
|
610487
610225
|
const rootEntityIds = this.rootEntities.map((entity) => entity.id);
|
|
610488
610226
|
const scene = {
|
|
@@ -621940,6 +621678,7 @@ var init_AssetEffectsRunner = __esm({
|
|
|
621940
621678
|
const capturedProjectId = this.projectId;
|
|
621941
621679
|
const commandName = tx.commandName ?? "";
|
|
621942
621680
|
const shouldCreateFromAdd = commandName.startsWith("undo:") || commandName === "redo:asset.create" || commandName === "asset.copy";
|
|
621681
|
+
const createCandidates = [];
|
|
621943
621682
|
const updates = /* @__PURE__ */ new Map();
|
|
621944
621683
|
for (const op of tx.operations) {
|
|
621945
621684
|
const propertyMatch = this.parsePropertyPath(op.path);
|
|
@@ -621970,15 +621709,14 @@ var init_AssetEffectsRunner = __esm({
|
|
|
621970
621709
|
}
|
|
621971
621710
|
} else if (op.op === "add" && shouldCreateFromAdd && "value" in op) {
|
|
621972
621711
|
const state = op.value;
|
|
621973
|
-
if (state
|
|
621974
|
-
|
|
621975
|
-
assetId,
|
|
621976
|
-
() => this.handleCreate(assetId, state, rev, capturedProjectId, sessionToken),
|
|
621977
|
-
sessionToken
|
|
621978
|
-
);
|
|
621712
|
+
if (this.shouldCreateRemoteAsset(state)) {
|
|
621713
|
+
createCandidates.push({ assetId, state, revision: rev });
|
|
621979
621714
|
}
|
|
621980
621715
|
}
|
|
621981
621716
|
}
|
|
621717
|
+
if (createCandidates.length) {
|
|
621718
|
+
this.scheduleCreateBatch(createCandidates, capturedProjectId, sessionToken);
|
|
621719
|
+
}
|
|
621982
621720
|
for (const [assetId, payload] of updates) {
|
|
621983
621721
|
this.scheduleAssetTask(
|
|
621984
621722
|
assetId,
|
|
@@ -622002,6 +621740,58 @@ var init_AssetEffectsRunner = __esm({
|
|
|
622002
621740
|
);
|
|
622003
621741
|
}
|
|
622004
621742
|
}
|
|
621743
|
+
shouldCreateRemoteAsset(state) {
|
|
621744
|
+
return Boolean(state.url) || state.type === "Folder";
|
|
621745
|
+
}
|
|
621746
|
+
scheduleCreateBatch(candidates, capturedProjectId, sessionToken) {
|
|
621747
|
+
void this.runTask(this.processCreateBatch(candidates, capturedProjectId, sessionToken));
|
|
621748
|
+
}
|
|
621749
|
+
async processCreateBatch(candidates, capturedProjectId, sessionToken) {
|
|
621750
|
+
const blockedParents = /* @__PURE__ */ new Set();
|
|
621751
|
+
for (const candidate of this.orderCreateCandidates(candidates)) {
|
|
621752
|
+
if (this._sessionToken !== sessionToken)
|
|
621753
|
+
return;
|
|
621754
|
+
const parentId = candidate.state.parentFolderId ?? null;
|
|
621755
|
+
if (parentId && blockedParents.has(parentId)) {
|
|
621756
|
+
blockedParents.add(candidate.assetId);
|
|
621757
|
+
continue;
|
|
621758
|
+
}
|
|
621759
|
+
const created = await this.handleCreate(
|
|
621760
|
+
candidate.assetId,
|
|
621761
|
+
candidate.state,
|
|
621762
|
+
candidate.revision,
|
|
621763
|
+
capturedProjectId,
|
|
621764
|
+
sessionToken
|
|
621765
|
+
);
|
|
621766
|
+
if (!created) {
|
|
621767
|
+
blockedParents.add(candidate.assetId);
|
|
621768
|
+
}
|
|
621769
|
+
}
|
|
621770
|
+
}
|
|
621771
|
+
orderCreateCandidates(candidates) {
|
|
621772
|
+
const byId = new Map(candidates.map((candidate) => [candidate.assetId, candidate]));
|
|
621773
|
+
const ordered = [];
|
|
621774
|
+
const visited = /* @__PURE__ */ new Set();
|
|
621775
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
621776
|
+
const visit = (candidate) => {
|
|
621777
|
+
if (visited.has(candidate.assetId))
|
|
621778
|
+
return;
|
|
621779
|
+
if (visiting.has(candidate.assetId))
|
|
621780
|
+
return;
|
|
621781
|
+
visiting.add(candidate.assetId);
|
|
621782
|
+
const parentId = candidate.state.parentFolderId ?? null;
|
|
621783
|
+
const parent2 = parentId ? byId.get(parentId) : void 0;
|
|
621784
|
+
if (parent2)
|
|
621785
|
+
visit(parent2);
|
|
621786
|
+
visiting.delete(candidate.assetId);
|
|
621787
|
+
visited.add(candidate.assetId);
|
|
621788
|
+
ordered.push(candidate);
|
|
621789
|
+
};
|
|
621790
|
+
for (const candidate of candidates) {
|
|
621791
|
+
visit(candidate);
|
|
621792
|
+
}
|
|
621793
|
+
return ordered;
|
|
621794
|
+
}
|
|
622005
621795
|
async executeDelete(serverIds, capturedProjectId) {
|
|
622006
621796
|
const { error: error49 } = await this.retryOnce(() => this.api.assets.delete(serverIds, capturedProjectId));
|
|
622007
621797
|
if (error49) {
|
|
@@ -622055,18 +621845,22 @@ var init_AssetEffectsRunner = __esm({
|
|
|
622055
621845
|
await this.runTask(this.executeDelete(serverIds, this.projectId));
|
|
622056
621846
|
}
|
|
622057
621847
|
async handleCreate(assetId, state, rev, capturedProjectId, sessionToken) {
|
|
621848
|
+
if (this._sessionToken !== sessionToken)
|
|
621849
|
+
return false;
|
|
621850
|
+
if (this.revisions.get(assetId) !== rev || !this.domainStore.state.assets[assetId])
|
|
621851
|
+
return false;
|
|
622058
621852
|
try {
|
|
622059
621853
|
const data = await this.api.assets.create(
|
|
622060
621854
|
buildCreateAssetRequest({ assetId, projectId: capturedProjectId, state })
|
|
622061
621855
|
);
|
|
622062
621856
|
if (this._sessionToken !== sessionToken) {
|
|
622063
621857
|
void this.runTask(this.executeDelete([data.id], capturedProjectId));
|
|
622064
|
-
return;
|
|
621858
|
+
return false;
|
|
622065
621859
|
}
|
|
622066
621860
|
const currentAsset = this.domainStore.state.assets[assetId];
|
|
622067
621861
|
if (this.revisions.get(assetId) !== rev || !currentAsset) {
|
|
622068
621862
|
void this.runTask(this.executeDelete([data.id], capturedProjectId));
|
|
622069
|
-
return;
|
|
621863
|
+
return false;
|
|
622070
621864
|
}
|
|
622071
621865
|
const opType = Object.prototype.hasOwnProperty.call(currentAsset, "serverId") ? "replace" : "add";
|
|
622072
621866
|
try {
|
|
@@ -622075,6 +621869,7 @@ var init_AssetEffectsRunner = __esm({
|
|
|
622075
621869
|
void this.runTask(this.executeDelete([data.id], capturedProjectId));
|
|
622076
621870
|
throw applyError;
|
|
622077
621871
|
}
|
|
621872
|
+
return true;
|
|
622078
621873
|
} catch (error49) {
|
|
622079
621874
|
console.warn("[AssetEffectsRunner] recreate failed:", error49);
|
|
622080
621875
|
this.reportError(
|
|
@@ -622083,6 +621878,7 @@ var init_AssetEffectsRunner = __esm({
|
|
|
622083
621878
|
originalError: error49
|
|
622084
621879
|
})
|
|
622085
621880
|
);
|
|
621881
|
+
return false;
|
|
622086
621882
|
}
|
|
622087
621883
|
}
|
|
622088
621884
|
runTask(task) {
|
|
@@ -623137,7 +622933,6 @@ var init_InstanceEditorAsset = __esm({
|
|
|
623137
622933
|
}
|
|
623138
622934
|
}
|
|
623139
622935
|
afterDelete() {
|
|
623140
|
-
this.unpackAllInstances();
|
|
623141
622936
|
this.root.sceneStore.selectEntity(null);
|
|
623142
622937
|
this._clonedEntities.forEach((entity) => entity.destroy());
|
|
623143
622938
|
const dragTempEntity = this.getDragTempEntity();
|
|
@@ -713284,14 +713079,25 @@ var init_launchAssetInIde = __esm({
|
|
|
713284
713079
|
});
|
|
713285
713080
|
|
|
713286
713081
|
// ../../plugins/main/src/assets/shader/parseEnumStorageType.ts
|
|
713287
|
-
function
|
|
713082
|
+
function hasEnumStorageTypeOverride(propertyName) {
|
|
713083
|
+
return FLOAT_STORAGE_ENUM_PROPERTIES.has(propertyName);
|
|
713084
|
+
}
|
|
713085
|
+
function detectEnumStorageType(firstPair, propertyName) {
|
|
713086
|
+
if (propertyName && FLOAT_STORAGE_ENUM_PROPERTIES.has(propertyName))
|
|
713087
|
+
return "Float" /* Float */;
|
|
713288
713088
|
const rawValue = firstPair.split(":")[1] ?? "";
|
|
713289
713089
|
return rawValue.includes(".") ? "Float" /* Float */ : "Integer" /* Integer */;
|
|
713290
713090
|
}
|
|
713091
|
+
var FLOAT_STORAGE_ENUM_PROPERTIES;
|
|
713291
713092
|
var init_parseEnumStorageType = __esm({
|
|
713292
713093
|
"../../plugins/main/src/assets/shader/parseEnumStorageType.ts"() {
|
|
713293
713094
|
"use strict";
|
|
713294
713095
|
init_types9();
|
|
713096
|
+
FLOAT_STORAGE_ENUM_PROPERTIES = /* @__PURE__ */ new Set([
|
|
713097
|
+
// PBR declares this as `Enum(UV0:0, UV1:1)` in the editor UI block, but the
|
|
713098
|
+
// runtime shader uniform and PBRMaterial API store it as a float.
|
|
713099
|
+
"material_OcclusionTextureCoord"
|
|
713100
|
+
]);
|
|
713295
713101
|
}
|
|
713296
713102
|
});
|
|
713297
713103
|
|
|
@@ -714824,8 +714630,8 @@ var init_ShaderAsset = __esm({
|
|
|
714824
714630
|
static create(content, propertyName) {
|
|
714825
714631
|
const itemContent = content.slice(5, -1);
|
|
714826
714632
|
const pairs = itemContent.split(",");
|
|
714827
|
-
let type = detectEnumStorageType(pairs[0]);
|
|
714828
|
-
if (propertyName) {
|
|
714633
|
+
let type = detectEnumStorageType(pairs[0], propertyName);
|
|
714634
|
+
if (propertyName && !hasEnumStorageTypeOverride(propertyName)) {
|
|
714829
714635
|
const engineType = import_engine115.ShaderProperty.getByName(propertyName).type;
|
|
714830
714636
|
if (engineType === import_engine115.ShaderPropertyType.Int)
|
|
714831
714637
|
type = "Integer" /* Integer */;
|
|
@@ -718756,14 +718562,11 @@ function replaceAssetRefValue(value, oldRef, newRef) {
|
|
|
718756
718562
|
function replacePrefabAssetRefs(prefabFile, oldRef, newRef) {
|
|
718757
718563
|
return replaceAssetRefValue(prefabFile, oldRef, newRef);
|
|
718758
718564
|
}
|
|
718759
|
-
function replacePrefabDependentAssetRef(prefabFile, oldAsset, newAssetId
|
|
718760
|
-
const
|
|
718565
|
+
function replacePrefabDependentAssetRef(prefabFile, oldAsset, newAssetId) {
|
|
718566
|
+
const newRef = assertAndReturnSourceAssetRef(newAssetId);
|
|
718567
|
+
const oldRef = oldAsset.ref ?? oldAsset.id;
|
|
718761
718568
|
if (typeof oldRef !== "string" || oldRef.length === 0) {
|
|
718762
|
-
throw new Error(`[SceneV2] Unable to replace prefab asset ref "${oldAsset.id}": missing old
|
|
718763
|
-
}
|
|
718764
|
-
const newRef = resolveVirtualPath(newAssetId);
|
|
718765
|
-
if (typeof newRef !== "string" || newRef.length === 0) {
|
|
718766
|
-
throw new Error(`[SceneV2] Unable to replace prefab asset ref "${newAssetId}": missing new virtualPath`);
|
|
718569
|
+
throw new Error(`[SceneV2] Unable to replace prefab asset ref "${oldAsset.id}": missing old source ref`);
|
|
718767
718570
|
}
|
|
718768
718571
|
let result2 = replacePrefabAssetRefs(prefabFile, oldRef, newRef);
|
|
718769
718572
|
if (oldRef !== oldAsset.id) {
|
|
@@ -718774,6 +718577,7 @@ function replacePrefabDependentAssetRef(prefabFile, oldAsset, newAssetId, resolv
|
|
|
718774
718577
|
var init_prefabAssetRefs = __esm({
|
|
718775
718578
|
"../../plugins/main/src/assets/prefab/prefabAssetRefs.ts"() {
|
|
718776
718579
|
"use strict";
|
|
718580
|
+
init_scene_file_v2();
|
|
718777
718581
|
}
|
|
718778
718582
|
});
|
|
718779
718583
|
|
|
@@ -718976,10 +718780,7 @@ function collectSnapshotComponentMetadata(input) {
|
|
|
718976
718780
|
const componentStates = input.normalized?.components;
|
|
718977
718781
|
const componentState = (input.sceneComponentId ? componentStates?.[input.sceneComponentId] : void 0) ?? (input.component?.id ? componentStates?.[input.component.id] : void 0);
|
|
718978
718782
|
const metadata = {};
|
|
718979
|
-
const refId = componentState?.refId ?? (typeof input.schema.script?.$ref === "string" ? input.
|
|
718980
|
-
input.schema.script.$ref,
|
|
718981
|
-
`component "${input.component?.id ?? input.schema.type}" script`
|
|
718982
|
-
) : void 0);
|
|
718783
|
+
const refId = componentState?.refId ?? (typeof input.schema.script?.$ref === "string" ? resolveRequiredSourceRef(input.schema.script.$ref) : void 0);
|
|
718983
718784
|
if (refId)
|
|
718984
718785
|
metadata.refId = refId;
|
|
718985
718786
|
const scriptKey = componentState?.scriptKey ?? input.schema.script?.key;
|
|
@@ -719135,7 +718936,6 @@ function collectPrefabDomainInstanceBaseline(input) {
|
|
|
719135
718936
|
schema: schema2,
|
|
719136
718937
|
sceneComponentId,
|
|
719137
718938
|
normalized,
|
|
719138
|
-
resolveSourceAssetRefToDomainId: input.resolveSourceAssetRefToDomainId,
|
|
719139
718939
|
convertSourceRefsToDomainRefs: input.convertSourceRefsToDomainRefs
|
|
719140
718940
|
}),
|
|
719141
718941
|
props: input.collectComponentProps(component2, schema2)
|
|
@@ -719469,13 +719269,7 @@ var init_PrefabAsset = __esm({
|
|
|
719469
719269
|
});
|
|
719470
719270
|
}
|
|
719471
719271
|
replaceDependentAsset(assetInfo2, newAsset) {
|
|
719472
|
-
|
|
719473
|
-
this.prefabFile = replacePrefabDependentAssetRef(
|
|
719474
|
-
this.prefabFile,
|
|
719475
|
-
assetInfo2,
|
|
719476
|
-
newAsset.id,
|
|
719477
|
-
(assetId) => assetStore.getAssetVirtualPath?.(assetId)
|
|
719478
|
-
);
|
|
719272
|
+
this.prefabFile = replacePrefabDependentAssetRef(this.prefabFile, assetInfo2, newAsset.id);
|
|
719479
719273
|
assetInfo2.id = newAsset.id;
|
|
719480
719274
|
assetInfo2.name = newAsset.name;
|
|
719481
719275
|
assetInfo2.type = newAsset.getMetaConfig().type;
|
|
@@ -719483,30 +719277,23 @@ var init_PrefabAsset = __esm({
|
|
|
719483
719277
|
this._updateContent();
|
|
719484
719278
|
}
|
|
719485
719279
|
_createSourceSerializeContext(orderedEntityIds = []) {
|
|
719486
|
-
const assetStore = this.root.assetStore;
|
|
719487
719280
|
const normalized = this.root.domainStore?.getNormalizedState?.();
|
|
719488
|
-
return new SerializeContext(
|
|
719489
|
-
|
|
719490
|
-
|
|
719491
|
-
|
|
719492
|
-
|
|
719493
|
-
|
|
719494
|
-
|
|
719495
|
-
|
|
719496
|
-
|
|
719497
|
-
|
|
719498
|
-
calls: component2.calls
|
|
719499
|
-
};
|
|
719500
|
-
}
|
|
719501
|
-
);
|
|
719281
|
+
return new SerializeContext(orderedEntityIds, (componentId) => {
|
|
719282
|
+
const component2 = normalized?.components?.[componentId];
|
|
719283
|
+
if (!component2)
|
|
719284
|
+
return void 0;
|
|
719285
|
+
return {
|
|
719286
|
+
refId: component2.refId,
|
|
719287
|
+
scriptKey: component2.scriptKey,
|
|
719288
|
+
calls: component2.calls
|
|
719289
|
+
};
|
|
719290
|
+
});
|
|
719502
719291
|
}
|
|
719503
719292
|
_createSourceRefCodec() {
|
|
719504
719293
|
const assetStore = this.root.assetStore;
|
|
719505
719294
|
return createSourceRefCodec({
|
|
719506
|
-
|
|
719507
|
-
|
|
719508
|
-
resolveAssetKind: (sourceRef) => {
|
|
719509
|
-
const type = assetStore.getAssetByVirtualPath?.(sourceRef)?.getMetaConfig?.()?.type;
|
|
719295
|
+
resolveAssetKind: (assetId) => {
|
|
719296
|
+
const type = assetStore.assets?.[assetId]?.getMetaConfig?.()?.type;
|
|
719510
719297
|
return type === "Prefab" || type === "glTF" ? type : void 0;
|
|
719511
719298
|
}
|
|
719512
719299
|
});
|
|
@@ -719515,8 +719302,7 @@ var init_PrefabAsset = __esm({
|
|
|
719515
719302
|
return this._createSourceSerializeContext().convertRefs(value);
|
|
719516
719303
|
}
|
|
719517
719304
|
_convertSourceRefsToDomainRefs(value) {
|
|
719518
|
-
|
|
719519
|
-
return convertAssetRefsToDomainRefs(value, (sourceRef) => codec2.sourceToDomain(sourceRef, "prefab source"));
|
|
719305
|
+
return convertAssetRefsToDomainRefs(value);
|
|
719520
719306
|
}
|
|
719521
719307
|
_componentSchemaToSourceRefs(component2) {
|
|
719522
719308
|
const ctx = this._createSourceSerializeContext();
|
|
@@ -719537,10 +719323,6 @@ var init_PrefabAsset = __esm({
|
|
|
719537
719323
|
}
|
|
719538
719324
|
_componentScriptRefToSourceRef(ref) {
|
|
719539
719325
|
const codec2 = this._createSourceRefCodec();
|
|
719540
|
-
if (this.root.assetStore.getAssetByVirtualPath?.(ref)?.id) {
|
|
719541
|
-
assertCanonicalSourceRef(ref, "prefab script");
|
|
719542
|
-
return ref;
|
|
719543
|
-
}
|
|
719544
719326
|
return codec2.domainToSource(ref, "prefab script");
|
|
719545
719327
|
}
|
|
719546
719328
|
_findSourceComponentModel(sourceComponentId) {
|
|
@@ -719811,19 +719593,9 @@ var init_PrefabAsset = __esm({
|
|
|
719811
719593
|
if (rootEntity)
|
|
719812
719594
|
applyRootTransformOverride2(rootEntity, rootTransform);
|
|
719813
719595
|
const sourceIdentityMap = this._assignSceneInstanceIds(prefabFile, rootIndex, options?.expectedRootId);
|
|
719814
|
-
const getAssetByVirtualPath = (virtualPath) => this.root.assetStore.getAssetByVirtualPath?.(virtualPath);
|
|
719815
719596
|
const rootsEntityModel = await entityManager.hydrateSourceV2LocalEntities(prefabFile, {
|
|
719816
|
-
|
|
719817
|
-
const
|
|
719818
|
-
if (typeof assetId !== "string" || assetId.length === 0) {
|
|
719819
|
-
throw new Error(
|
|
719820
|
-
`[SceneV2] Unable to resolve asset ref "${virtualPath}" while instantiating prefab "${this.id}". Source-v2 $ref must be a virtualPath, not an editor asset id.`
|
|
719821
|
-
);
|
|
719822
|
-
}
|
|
719823
|
-
return assetId;
|
|
719824
|
-
},
|
|
719825
|
-
resolveAssetKind: (virtualPath) => {
|
|
719826
|
-
const type = getAssetByVirtualPath(virtualPath)?.getMetaConfig?.()?.type;
|
|
719597
|
+
resolveAssetKind: (assetId) => {
|
|
719598
|
+
const type = this.root.assetStore.assets?.[assetId]?.getMetaConfig?.()?.type;
|
|
719827
719599
|
return type === "Prefab" || type === "glTF" ? type : void 0;
|
|
719828
719600
|
},
|
|
719829
719601
|
resolvePrefabSourceFile: (assetId) => {
|
|
@@ -720082,15 +719854,15 @@ var init_PrefabAsset = __esm({
|
|
|
720082
719854
|
sceneSourceComponentKeys: options?.sourceComponentKeyBySceneComponentId,
|
|
720083
719855
|
allowMissingSceneChildSourceIds: options?.allowMissingSceneChildSourceIds,
|
|
720084
719856
|
allowMissingSceneComponentSourceKeys: options?.allowMissingSceneComponentSourceKeys,
|
|
720085
|
-
resolveInstanceAsset: (
|
|
720086
|
-
const asset3 = this.root.assetStore.
|
|
719857
|
+
resolveInstanceAsset: (assetId, sourceEntityId) => {
|
|
719858
|
+
const asset3 = this.root.assetStore.assets?.[assetId];
|
|
720087
719859
|
if (!asset3) {
|
|
720088
|
-
throw new Error(`Prefab source entity "${sourceEntityId}" references missing instance asset "${
|
|
719860
|
+
throw new Error(`Prefab source entity "${sourceEntityId}" references missing instance asset "${assetId}".`);
|
|
720089
719861
|
}
|
|
720090
719862
|
const kind = asset3.getMetaConfig?.()?.type;
|
|
720091
719863
|
if (kind !== "Prefab" && kind !== "glTF") {
|
|
720092
719864
|
throw new Error(
|
|
720093
|
-
`Prefab source entity "${sourceEntityId}" references unsupported instance asset "${
|
|
719865
|
+
`Prefab source entity "${sourceEntityId}" references unsupported instance asset "${assetId}" of type "${String(
|
|
720094
719866
|
kind
|
|
720095
719867
|
)}".`
|
|
720096
719868
|
);
|
|
@@ -720102,7 +719874,6 @@ var init_PrefabAsset = __esm({
|
|
|
720102
719874
|
...kind === "Prefab" && typeof nestedPrefabFile?.root === "string" ? { sourceRootEntityId: nestedPrefabFile.root } : {}
|
|
720103
719875
|
};
|
|
720104
719876
|
},
|
|
720105
|
-
resolveSourceAssetRefToDomainId: (sourceRef, context) => this._createSourceRefCodec().sourceToDomain(sourceRef, context),
|
|
720106
719877
|
convertSourceRefsToDomainRefs: (value) => this._convertSourceRefsToDomainRefs(value),
|
|
720107
719878
|
collectComponentProps: (component2, schema2) => this._collectSnapshotComponentProps(component2, schema2),
|
|
720108
719879
|
combineLayers: (layer) => combineLayersByBitwise(layer)
|
|
@@ -720155,15 +719926,32 @@ var init_PrefabAsset = __esm({
|
|
|
720155
719926
|
scale: { x: engineTransform.scale.x, y: engineTransform.scale.y, z: engineTransform.scale.z }
|
|
720156
719927
|
} : void 0;
|
|
720157
719928
|
const expectedBindingId = targetEntity.root.domainStore.getNormalizedState().entities[targetEntityId]?.instance?.bindingId;
|
|
719929
|
+
const deferredInstanceBindings = [];
|
|
720158
719930
|
const newEntityModel = await this.instantiate(
|
|
720159
719931
|
entityManager,
|
|
720160
719932
|
options?.resetRootTransform ? void 0 : rootTransform,
|
|
720161
719933
|
{
|
|
720162
719934
|
...options?.undoable ? { undoable: true } : {},
|
|
720163
|
-
expectedBindingId
|
|
719935
|
+
expectedBindingId,
|
|
719936
|
+
deferDomainBinding: true,
|
|
719937
|
+
deferredInstanceBindings
|
|
720164
719938
|
}
|
|
720165
719939
|
);
|
|
720166
719940
|
newEntityModel.convertToPrefabRefEntity();
|
|
719941
|
+
const domainStore = entityManager.root?.domainStore ?? targetEntity.root.domainStore;
|
|
719942
|
+
const latestTargetEntity = entityManager.entities.get(targetEntityId);
|
|
719943
|
+
const latestTargetDomainEntity = domainStore.getNormalizedState().entities[targetEntityId];
|
|
719944
|
+
if (!latestTargetEntity || !latestTargetDomainEntity?.instance) {
|
|
719945
|
+
newEntityModel.destroy();
|
|
719946
|
+
return null;
|
|
719947
|
+
}
|
|
719948
|
+
if (entityManager.isDomainScoped && !domainStore.state.entities[newEntityModel.id]) {
|
|
719949
|
+
entityManager.registerEntityTreeInDomain(newEntityModel, null, void 0, {
|
|
719950
|
+
...rootTransform && !options?.resetRootTransform ? { transform: rootTransform } : {},
|
|
719951
|
+
deferInstanceBinding: true
|
|
719952
|
+
});
|
|
719953
|
+
}
|
|
719954
|
+
deferredInstanceBindings.splice(0).forEach((bindDeferredInstance) => bindDeferredInstance());
|
|
720167
719955
|
if (options?.structuralDeltaMode) {
|
|
720168
719956
|
entityManager.replaceEntity(targetEntityId, newEntityModel, { structuralDeltaMode: options.structuralDeltaMode });
|
|
720169
719957
|
} else {
|
|
@@ -720248,7 +720036,7 @@ var init_PrefabAsset = __esm({
|
|
|
720248
720036
|
for (const ref of findKeysInObject(this.prefabFile, ["$ref"])) {
|
|
720249
720037
|
if (typeof ref !== "string" || ref === this.id)
|
|
720250
720038
|
continue;
|
|
720251
|
-
const asset3 = assetStore.
|
|
720039
|
+
const asset3 = assetStore.assets?.[ref];
|
|
720252
720040
|
if (!asset3) {
|
|
720253
720041
|
throw new Error(`[SceneV2] Unable to resolve prefab asset ref "${ref}" while collecting dependencies`);
|
|
720254
720042
|
}
|
|
@@ -720264,13 +720052,7 @@ var init_PrefabAsset = __esm({
|
|
|
720264
720052
|
id: asset3.id,
|
|
720265
720053
|
name: asset3.name,
|
|
720266
720054
|
type: asset3.getMetaConfig().type,
|
|
720267
|
-
ref:
|
|
720268
|
-
const ref = assetStore.getAssetVirtualPath?.(asset3.id);
|
|
720269
|
-
if (typeof ref !== "string" || ref.length === 0) {
|
|
720270
|
-
throw new Error(`[SceneV2] Unable to serialize prefab dependency ref "${asset3.id}": missing virtualPath`);
|
|
720271
|
-
}
|
|
720272
|
-
return ref;
|
|
720273
|
-
})()
|
|
720055
|
+
ref: asset3.id
|
|
720274
720056
|
}));
|
|
720275
720057
|
}
|
|
720276
720058
|
_updateContent(options) {
|
|
@@ -724497,26 +724279,25 @@ var init_execute = __esm({
|
|
|
724497
724279
|
function scriptComponentRefFromSchema(script) {
|
|
724498
724280
|
if (!script?.$ref)
|
|
724499
724281
|
return null;
|
|
724282
|
+
assertSourceAssetRef(script.$ref, "script component");
|
|
724500
724283
|
return {
|
|
724501
724284
|
refId: script.$ref,
|
|
724502
724285
|
...script.key ? { key: script.key } : {}
|
|
724503
724286
|
};
|
|
724504
724287
|
}
|
|
724505
|
-
function scriptComponentRefToSchema(script
|
|
724288
|
+
function scriptComponentRefToSchema(script) {
|
|
724506
724289
|
if (!script)
|
|
724507
724290
|
return void 0;
|
|
724508
|
-
|
|
724509
|
-
if (typeof sourceRef !== "string" || sourceRef.length === 0) {
|
|
724510
|
-
throw new Error(`[SceneV2] Unable to serialize script asset ref "${script.refId}": missing virtualPath`);
|
|
724511
|
-
}
|
|
724291
|
+
assertSourceAssetRef(script.refId, "script component");
|
|
724512
724292
|
return {
|
|
724513
|
-
$ref:
|
|
724293
|
+
$ref: script.refId,
|
|
724514
724294
|
...script.key ? { key: script.key } : {}
|
|
724515
724295
|
};
|
|
724516
724296
|
}
|
|
724517
724297
|
var init_script_schema = __esm({
|
|
724518
724298
|
"../../plugins/main/src/components/ScriptComponent/script-schema.ts"() {
|
|
724519
724299
|
"use strict";
|
|
724300
|
+
init_scene_file_v2();
|
|
724520
724301
|
}
|
|
724521
724302
|
});
|
|
724522
724303
|
|
|
@@ -724705,7 +724486,7 @@ var init_ScriptComponent = __esm({
|
|
|
724705
724486
|
}
|
|
724706
724487
|
}
|
|
724707
724488
|
}
|
|
724708
|
-
const script = scriptComponentRefToSchema(this.script
|
|
724489
|
+
const script = scriptComponentRefToSchema(this.script);
|
|
724709
724490
|
if (script)
|
|
724710
724491
|
data.script = script;
|
|
724711
724492
|
return data;
|
|
@@ -739190,7 +738971,7 @@ var init_audio3 = __esm({
|
|
|
739190
738971
|
// src/cli.ts
|
|
739191
738972
|
var import_node_os2 = __toESM(require("node:os"));
|
|
739192
738973
|
var import_node_path23 = __toESM(require("node:path"));
|
|
739193
|
-
var
|
|
738974
|
+
var import_node_process4 = __toESM(require("node:process"));
|
|
739194
738975
|
|
|
739195
738976
|
// node_modules/commander/esm.mjs
|
|
739196
738977
|
var import_index = __toESM(require_commander(), 1);
|
|
@@ -750393,8 +750174,8 @@ function buildDefaultScene3D() {
|
|
|
750393
750174
|
mode: 1,
|
|
750394
750175
|
color: { r: 0.05087608817155679, g: 0.05087608817155679, b: 0.05087608817155679, a: 1 },
|
|
750395
750176
|
textureFillMode: 1,
|
|
750396
|
-
skyMaterial: { $ref: "
|
|
750397
|
-
skyMesh: { $ref: "
|
|
750177
|
+
skyMaterial: { $ref: "0000201" },
|
|
750178
|
+
skyMesh: { $ref: "0000101" }
|
|
750398
750179
|
},
|
|
750399
750180
|
ambient: {
|
|
750400
750181
|
ambientLight: null,
|
|
@@ -750733,6 +750514,118 @@ function registerExecCommand(program3) {
|
|
|
750733
750514
|
});
|
|
750734
750515
|
}
|
|
750735
750516
|
|
|
750517
|
+
// src/commands/migrate-source-v2.ts
|
|
750518
|
+
var import_node_process2 = __toESM(require("node:process"));
|
|
750519
|
+
init_scene_file_v2();
|
|
750520
|
+
init_node_fs();
|
|
750521
|
+
|
|
750522
|
+
// src/domain-bridge/asset-virtual-path.ts
|
|
750523
|
+
init_sync_adapter();
|
|
750524
|
+
var STORAGE_ASSET_ROOT = "assets";
|
|
750525
|
+
function normalizeSourceVirtualPath2(value) {
|
|
750526
|
+
return value.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
750527
|
+
}
|
|
750528
|
+
function localAssetPathToSourceVirtualPath(localPath, assetType) {
|
|
750529
|
+
const parts = normalizeSourceVirtualPath2(localPath).split("/").filter(Boolean);
|
|
750530
|
+
if (parts[0] === STORAGE_ASSET_ROOT)
|
|
750531
|
+
parts.shift();
|
|
750532
|
+
if (parts.length === 0)
|
|
750533
|
+
return "";
|
|
750534
|
+
if (assetType !== "Folder") {
|
|
750535
|
+
parts[parts.length - 1] = assetNameFromPath(localPath, assetType);
|
|
750536
|
+
}
|
|
750537
|
+
return parts.join("/");
|
|
750538
|
+
}
|
|
750539
|
+
function createManifestSourceVirtualPathIndex(manifest) {
|
|
750540
|
+
const index2 = /* @__PURE__ */ new Map();
|
|
750541
|
+
for (const [assetId, entry] of Object.entries(manifest.entries)) {
|
|
750542
|
+
const virtualPath = localAssetPathToSourceVirtualPath(entry.path, entry.type);
|
|
750543
|
+
if (!virtualPath)
|
|
750544
|
+
continue;
|
|
750545
|
+
index2.set(virtualPath, assetId);
|
|
750546
|
+
index2.set(`/${virtualPath}`, assetId);
|
|
750547
|
+
}
|
|
750548
|
+
return index2;
|
|
750549
|
+
}
|
|
750550
|
+
|
|
750551
|
+
// src/commands/migrate-source-v2.ts
|
|
750552
|
+
function decodeText2(raw) {
|
|
750553
|
+
return new TextDecoder().decode(raw);
|
|
750554
|
+
}
|
|
750555
|
+
function projectPath(projectDir, relativePath2) {
|
|
750556
|
+
return `${projectDir.replace(/\/+$/, "")}/${relativePath2.replace(/^\/+/, "")}`;
|
|
750557
|
+
}
|
|
750558
|
+
function walkRefs(value, visitor) {
|
|
750559
|
+
if (value === null || typeof value !== "object")
|
|
750560
|
+
return;
|
|
750561
|
+
if (Array.isArray(value)) {
|
|
750562
|
+
value.forEach((item) => walkRefs(item, visitor));
|
|
750563
|
+
return;
|
|
750564
|
+
}
|
|
750565
|
+
const record2 = value;
|
|
750566
|
+
if (typeof record2.$ref === "string") {
|
|
750567
|
+
visitor(record2);
|
|
750568
|
+
return;
|
|
750569
|
+
}
|
|
750570
|
+
Object.values(record2).forEach((child) => walkRefs(child, visitor));
|
|
750571
|
+
}
|
|
750572
|
+
async function migrateSourceV2Refs(projectDir, fs5) {
|
|
750573
|
+
const manifestText = decodeText2(await fs5.readFile(projectPath(projectDir, ".galacean/manifest.json")));
|
|
750574
|
+
const manifest = JSON.parse(manifestText);
|
|
750575
|
+
const pathToId = createManifestSourceVirtualPathIndex(manifest);
|
|
750576
|
+
const result2 = { migrated: 0, skipped: 0, errors: [] };
|
|
750577
|
+
for (const entry of Object.values(manifest.entries)) {
|
|
750578
|
+
if (entry.type === "Folder")
|
|
750579
|
+
continue;
|
|
750580
|
+
const filePath = projectPath(projectDir, entry.path);
|
|
750581
|
+
let parsed;
|
|
750582
|
+
try {
|
|
750583
|
+
parsed = JSON.parse(decodeText2(await fs5.readFile(filePath)));
|
|
750584
|
+
} catch {
|
|
750585
|
+
result2.skipped++;
|
|
750586
|
+
continue;
|
|
750587
|
+
}
|
|
750588
|
+
const replacements = [];
|
|
750589
|
+
const fileErrors = [];
|
|
750590
|
+
walkRefs(parsed, (record2) => {
|
|
750591
|
+
const ref = record2.$ref;
|
|
750592
|
+
if (manifest.entries[ref])
|
|
750593
|
+
return;
|
|
750594
|
+
const resolved = pathToId.get(ref);
|
|
750595
|
+
if (resolved) {
|
|
750596
|
+
replacements.push({ record: record2, nextRef: resolved });
|
|
750597
|
+
return;
|
|
750598
|
+
}
|
|
750599
|
+
if (isValidSourceAssetRef(ref))
|
|
750600
|
+
return;
|
|
750601
|
+
fileErrors.push({ file: entry.path, ref, message: "unresolvable path ref" });
|
|
750602
|
+
});
|
|
750603
|
+
if (fileErrors.length) {
|
|
750604
|
+
result2.errors.push(...fileErrors);
|
|
750605
|
+
result2.skipped++;
|
|
750606
|
+
continue;
|
|
750607
|
+
}
|
|
750608
|
+
if (replacements.length) {
|
|
750609
|
+
replacements.forEach(({ record: record2, nextRef }) => {
|
|
750610
|
+
record2.$ref = nextRef;
|
|
750611
|
+
});
|
|
750612
|
+
await fs5.writeFile(filePath, JSON.stringify(parsed, null, 2));
|
|
750613
|
+
result2.migrated++;
|
|
750614
|
+
} else {
|
|
750615
|
+
result2.skipped++;
|
|
750616
|
+
}
|
|
750617
|
+
}
|
|
750618
|
+
return result2;
|
|
750619
|
+
}
|
|
750620
|
+
function registerMigrateSourceV2Command(program3) {
|
|
750621
|
+
program3.command("migrate-source-v2 [projectDir]").description("Migrate source-v2 $ref from virtualPath to asset id").action(async (projectDir) => {
|
|
750622
|
+
const result2 = await migrateSourceV2Refs(projectDir ?? import_node_process2.default.cwd(), new NodeFs());
|
|
750623
|
+
console.log(JSON.stringify(result2, null, 2));
|
|
750624
|
+
if (result2.errors.length > 0)
|
|
750625
|
+
import_node_process2.default.exitCode = 1;
|
|
750626
|
+
});
|
|
750627
|
+
}
|
|
750628
|
+
|
|
750736
750629
|
// src/commands/preview.ts
|
|
750737
750630
|
var import_node_path22 = __toESM(require("node:path"));
|
|
750738
750631
|
var import_promises17 = require("node:fs/promises");
|
|
@@ -751487,7 +751380,7 @@ async function listenWithPortFallback(server, preferredPort) {
|
|
|
751487
751380
|
// ../cli-preview/src/server/client-host.ts
|
|
751488
751381
|
var import_promises16 = require("node:fs/promises");
|
|
751489
751382
|
var import_node_path21 = __toESM(require("node:path"));
|
|
751490
|
-
var
|
|
751383
|
+
var import_node_process3 = __toESM(require("node:process"));
|
|
751491
751384
|
var import_node_child_process2 = require("node:child_process");
|
|
751492
751385
|
|
|
751493
751386
|
// ../cli-preview/src/shared/storage-adapter.ts
|
|
@@ -752001,12 +751894,12 @@ async function startClientHost(options) {
|
|
|
752001
751894
|
const viteBin = await resolveViteBin(workspaceRoot);
|
|
752002
751895
|
await (0, import_promises16.access)(configPath);
|
|
752003
751896
|
const child = (0, import_node_child_process2.spawn)(
|
|
752004
|
-
|
|
751897
|
+
import_node_process3.default.execPath,
|
|
752005
751898
|
[viteBin, "--config", configPath, "--host", host, "--port", String(port), "--strictPort", "--force"],
|
|
752006
751899
|
{
|
|
752007
751900
|
cwd: workspaceRoot,
|
|
752008
751901
|
env: {
|
|
752009
|
-
...
|
|
751902
|
+
...import_node_process3.default.env,
|
|
752010
751903
|
CLI_PREVIEW_RUNTIME_HOST: host,
|
|
752011
751904
|
CLI_PREVIEW_RUNTIME_PORT: String(options.runtimePort)
|
|
752012
751905
|
},
|
|
@@ -752037,7 +751930,7 @@ async function startClientHost(options) {
|
|
|
752037
751930
|
};
|
|
752038
751931
|
}
|
|
752039
751932
|
async function findWorkspaceRoot() {
|
|
752040
|
-
const startDirs = [__dirname,
|
|
751933
|
+
const startDirs = [__dirname, import_node_process3.default.cwd()];
|
|
752041
751934
|
for (const startDir of startDirs) {
|
|
752042
751935
|
let current = startDir;
|
|
752043
751936
|
while (true) {
|
|
@@ -752262,14 +752155,14 @@ async function resolveClientDir() {
|
|
|
752262
752155
|
}
|
|
752263
752156
|
|
|
752264
752157
|
// src/cli-version.ts
|
|
752265
|
-
var
|
|
752158
|
+
var import_node_fs5 = require("node:fs");
|
|
752266
752159
|
var import_meta3 = {};
|
|
752267
752160
|
function readCliVersionFromPackageJson() {
|
|
752268
|
-
const raw = (0,
|
|
752161
|
+
const raw = (0, import_node_fs5.readFileSync)(new URL("../package.json", import_meta3.url), "utf-8");
|
|
752269
752162
|
const parsed = JSON.parse(raw);
|
|
752270
752163
|
return typeof parsed.version === "string" && parsed.version.length > 0 ? parsed.version : "0.0.0";
|
|
752271
752164
|
}
|
|
752272
|
-
var CLI_VERSION = "2.0.0-alpha.
|
|
752165
|
+
var CLI_VERSION = "2.0.0-alpha.27".length > 0 ? "2.0.0-alpha.27" : readCliVersionFromPackageJson();
|
|
752273
752166
|
|
|
752274
752167
|
// src/cli.ts
|
|
752275
752168
|
init_config();
|
|
@@ -752282,7 +752175,7 @@ program2.hook("preAction", async (thisCommand) => {
|
|
|
752282
752175
|
const opts = thisCommand.optsWithGlobals();
|
|
752283
752176
|
const configArg = opts.config ?? opts.c;
|
|
752284
752177
|
const { config: config2 } = await loadConfig(configArg);
|
|
752285
|
-
const token = opts.token ??
|
|
752178
|
+
const token = opts.token ?? import_node_process4.default.env.GALACEAN_TOKEN ?? config2.token;
|
|
752286
752179
|
thisCommand.setOptionValue("_config", config2);
|
|
752287
752180
|
thisCommand.setOptionValue("_resolvedToken", token);
|
|
752288
752181
|
});
|
|
@@ -752295,6 +752188,7 @@ function getToken2(opts) {
|
|
|
752295
752188
|
registerCreateCommand(program2);
|
|
752296
752189
|
registerExecCommand(program2);
|
|
752297
752190
|
registerInvokeCommand(program2);
|
|
752191
|
+
registerMigrateSourceV2Command(program2);
|
|
752298
752192
|
registerPreviewCommand(program2);
|
|
752299
752193
|
registerBuildCommand(program2);
|
|
752300
752194
|
program2.command("init <projectId>").description("Initialize a project from remote").option("-o, --output <dir>", "output directory").option("--outputDir <dir>", "output directory (alias)").option("-f, --force", "overwrite managed project files in a non-empty output directory").action(async (projectId, cmdOpts) => {
|
|
@@ -752312,7 +752206,7 @@ program2.command("init <projectId>").description("Initialize a project from remo
|
|
|
752312
752206
|
});
|
|
752313
752207
|
});
|
|
752314
752208
|
program2.command("pull [projectDir]").description("Pull remote changes to local").action(async (projectDir) => {
|
|
752315
|
-
const dir = projectDir ??
|
|
752209
|
+
const dir = projectDir ?? import_node_process4.default.cwd();
|
|
752316
752210
|
const globals = program2.optsWithGlobals();
|
|
752317
752211
|
const serverUrl = await resolveServerUrl(globals, { projectDir: dir, required: true });
|
|
752318
752212
|
const token = getToken2(globals);
|
|
@@ -752348,7 +752242,7 @@ program2.command("pull [projectDir]").description("Pull remote changes to local"
|
|
|
752348
752242
|
}
|
|
752349
752243
|
});
|
|
752350
752244
|
program2.command("push [projectDir]").description("Push local changes to remote").option("--no-prune-remote", "keep remote assets that are not tracked by the current local manifest").action(async (projectDir, cmdOpts) => {
|
|
752351
|
-
const dir = projectDir ??
|
|
752245
|
+
const dir = projectDir ?? import_node_process4.default.cwd();
|
|
752352
752246
|
const globals = program2.optsWithGlobals();
|
|
752353
752247
|
const serverUrl = await resolveServerUrl(globals, { projectDir: dir, required: true });
|
|
752354
752248
|
const token = getToken2(globals);
|
|
@@ -752363,7 +752257,7 @@ program2.command("push [projectDir]").description("Push local changes to remote"
|
|
|
752363
752257
|
printPushResult(result2);
|
|
752364
752258
|
});
|
|
752365
752259
|
program2.command("watch [projectDir]").description("Watch local changes and auto-push").action(async (projectDir) => {
|
|
752366
|
-
const dir = projectDir ??
|
|
752260
|
+
const dir = projectDir ?? import_node_process4.default.cwd();
|
|
752367
752261
|
const globals = program2.optsWithGlobals();
|
|
752368
752262
|
const serverUrl = await resolveServerUrl(globals, { projectDir: dir, required: true });
|
|
752369
752263
|
const token = getToken2(globals);
|
|
@@ -752388,8 +752282,8 @@ program2.command("watch [projectDir]").description("Watch local changes and auto
|
|
|
752388
752282
|
handle2.close();
|
|
752389
752283
|
resolve5();
|
|
752390
752284
|
};
|
|
752391
|
-
|
|
752392
|
-
|
|
752285
|
+
import_node_process4.default.on("SIGINT", shutdown);
|
|
752286
|
+
import_node_process4.default.on("SIGTERM", shutdown);
|
|
752393
752287
|
});
|
|
752394
752288
|
});
|
|
752395
752289
|
var auth = program2.command("auth").description("Authentication management");
|
|
@@ -752405,9 +752299,9 @@ var asset2 = program2.command("asset").description("Asset management");
|
|
|
752405
752299
|
registerAssetList(asset2);
|
|
752406
752300
|
registerAssetInfo(asset2);
|
|
752407
752301
|
registerAssetTree(asset2);
|
|
752408
|
-
program2.parseAsync(
|
|
752302
|
+
program2.parseAsync(import_node_process4.default.argv).catch((err2) => {
|
|
752409
752303
|
console.error(err2.stack ?? err2.message ?? err2);
|
|
752410
|
-
|
|
752304
|
+
import_node_process4.default.exit(1);
|
|
752411
752305
|
});
|
|
752412
752306
|
/*! Bundled license information:
|
|
752413
752307
|
|