@galacean/cli 0.0.1-alpha.7 → 0.0.1-alpha.8
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 +656 -665
- package/package.json +1 -1
package/dist/cli.bundle.cjs
CHANGED
|
@@ -1197,7 +1197,7 @@ var require_command = __commonJS({
|
|
|
1197
1197
|
var EventEmitter3 = require("node:events").EventEmitter;
|
|
1198
1198
|
var childProcess = require("node:child_process");
|
|
1199
1199
|
var path16 = require("node:path");
|
|
1200
|
-
var
|
|
1200
|
+
var fs5 = require("node:fs");
|
|
1201
1201
|
var process5 = require("node:process");
|
|
1202
1202
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
1203
1203
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -2191,7 +2191,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2191
2191
|
* @param {string} subcommandName
|
|
2192
2192
|
*/
|
|
2193
2193
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
2194
|
-
if (
|
|
2194
|
+
if (fs5.existsSync(executableFile)) return;
|
|
2195
2195
|
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
2196
2196
|
const executableMissing = `'${executableFile}' does not exist
|
|
2197
2197
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -2210,10 +2210,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2210
2210
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2211
2211
|
function findFile(baseDir, baseName) {
|
|
2212
2212
|
const localBin = path16.resolve(baseDir, baseName);
|
|
2213
|
-
if (
|
|
2213
|
+
if (fs5.existsSync(localBin)) return localBin;
|
|
2214
2214
|
if (sourceExt.includes(path16.extname(baseName))) return void 0;
|
|
2215
2215
|
const foundExt = sourceExt.find(
|
|
2216
|
-
(ext) =>
|
|
2216
|
+
(ext) => fs5.existsSync(`${localBin}${ext}`)
|
|
2217
2217
|
);
|
|
2218
2218
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
2219
2219
|
return void 0;
|
|
@@ -2225,7 +2225,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2225
2225
|
if (this._scriptPath) {
|
|
2226
2226
|
let resolvedScriptPath;
|
|
2227
2227
|
try {
|
|
2228
|
-
resolvedScriptPath =
|
|
2228
|
+
resolvedScriptPath = fs5.realpathSync(this._scriptPath);
|
|
2229
2229
|
} catch {
|
|
2230
2230
|
resolvedScriptPath = this._scriptPath;
|
|
2231
2231
|
}
|
|
@@ -3515,16 +3515,16 @@ var init_utils = __esm({
|
|
|
3515
3515
|
// ../storage/src/manifest.ts
|
|
3516
3516
|
function generateManifest(pathMap, contentHashes) {
|
|
3517
3517
|
const entries = {};
|
|
3518
|
-
for (const [assetId,
|
|
3518
|
+
for (const [assetId, entry2] of pathMap) {
|
|
3519
3519
|
entries[assetId] = {
|
|
3520
3520
|
assetId,
|
|
3521
|
-
name:
|
|
3522
|
-
path:
|
|
3523
|
-
type:
|
|
3521
|
+
name: entry2.name,
|
|
3522
|
+
path: entry2.localPath,
|
|
3523
|
+
type: entry2.metaType,
|
|
3524
3524
|
contentHash: contentHashes.get(assetId) ?? "",
|
|
3525
|
-
remoteVersion:
|
|
3526
|
-
serverId:
|
|
3527
|
-
url:
|
|
3525
|
+
remoteVersion: entry2.meta.version ?? "",
|
|
3526
|
+
serverId: entry2.serverId,
|
|
3527
|
+
url: entry2.url
|
|
3528
3528
|
};
|
|
3529
3529
|
}
|
|
3530
3530
|
return { version: 1, entries };
|
|
@@ -3536,13 +3536,13 @@ var init_manifest = __esm({
|
|
|
3536
3536
|
});
|
|
3537
3537
|
|
|
3538
3538
|
// ../storage/src/meta-file.ts
|
|
3539
|
-
function generateMetaFile(
|
|
3540
|
-
const { locked: _locked, id: _id, ...restMeta } =
|
|
3539
|
+
function generateMetaFile(entry2) {
|
|
3540
|
+
const { locked: _locked, id: _id, ...restMeta } = entry2.meta;
|
|
3541
3541
|
return {
|
|
3542
3542
|
...restMeta,
|
|
3543
|
-
type:
|
|
3544
|
-
assetId:
|
|
3545
|
-
serverId:
|
|
3543
|
+
type: entry2.metaType,
|
|
3544
|
+
assetId: entry2.assetId,
|
|
3545
|
+
serverId: entry2.serverId
|
|
3546
3546
|
};
|
|
3547
3547
|
}
|
|
3548
3548
|
function metaFilePath(contentPath) {
|
|
@@ -4294,9 +4294,9 @@ async function resetNodeManagedProjectPaths(dirPath) {
|
|
|
4294
4294
|
)
|
|
4295
4295
|
);
|
|
4296
4296
|
}
|
|
4297
|
-
async function assertDirectoryEmpty(
|
|
4297
|
+
async function assertDirectoryEmpty(fs5, dirPath) {
|
|
4298
4298
|
try {
|
|
4299
|
-
const entries = await
|
|
4299
|
+
const entries = await fs5.readdir(dirPath);
|
|
4300
4300
|
if (entries.length > 0) {
|
|
4301
4301
|
throw new Error(`Output directory is not empty: ${dirPath}. Use --force to continue.`);
|
|
4302
4302
|
}
|
|
@@ -4304,8 +4304,8 @@ async function assertDirectoryEmpty(fs6, dirPath) {
|
|
|
4304
4304
|
if (!isMissingPathError(err)) throw err;
|
|
4305
4305
|
}
|
|
4306
4306
|
}
|
|
4307
|
-
async function resetManagedProjectPaths(
|
|
4308
|
-
await Promise.all(MANAGED_PROJECT_PATHS.map((managedPath) =>
|
|
4307
|
+
async function resetManagedProjectPaths(fs5, dirPath) {
|
|
4308
|
+
await Promise.all(MANAGED_PROJECT_PATHS.map((managedPath) => fs5.remove(import_node_path3.default.join(dirPath, managedPath))));
|
|
4309
4309
|
}
|
|
4310
4310
|
async function readProjectConfig(projectDir) {
|
|
4311
4311
|
return readJsonFile(import_node_path3.default.resolve(projectDir, "project.galacean"), "project config");
|
|
@@ -4319,9 +4319,9 @@ async function readNodeRemoteConfig(projectDir) {
|
|
|
4319
4319
|
}
|
|
4320
4320
|
return { projectId, serverUrl: typeof serverUrl === "string" ? serverUrl : "" };
|
|
4321
4321
|
}
|
|
4322
|
-
async function readRemoteConfig(
|
|
4322
|
+
async function readRemoteConfig(fs5, projectDir) {
|
|
4323
4323
|
const remotePath = import_node_path3.default.resolve(projectDir, ".galacean/remote.json");
|
|
4324
|
-
const raw = decodeUtf8(await
|
|
4324
|
+
const raw = decodeUtf8(await fs5.readFile(remotePath));
|
|
4325
4325
|
const parsed = safeParseJsonObject(raw);
|
|
4326
4326
|
const projectId = parsed.projectId;
|
|
4327
4327
|
const serverUrl = parsed.serverUrl;
|
|
@@ -4403,21 +4403,21 @@ var init_path_utils = __esm({
|
|
|
4403
4403
|
});
|
|
4404
4404
|
|
|
4405
4405
|
// ../storage/src/fs.ts
|
|
4406
|
-
async function atomicWriteFile(
|
|
4407
|
-
if (
|
|
4406
|
+
async function atomicWriteFile(fs5, filePath, content) {
|
|
4407
|
+
if (fs5.rename) {
|
|
4408
4408
|
const tmp = filePath + ".tmp";
|
|
4409
|
-
await
|
|
4409
|
+
await fs5.writeFile(tmp, content);
|
|
4410
4410
|
try {
|
|
4411
|
-
await
|
|
4411
|
+
await fs5.rename(tmp, filePath);
|
|
4412
4412
|
} catch (err) {
|
|
4413
4413
|
try {
|
|
4414
|
-
await
|
|
4414
|
+
await fs5.remove(tmp);
|
|
4415
4415
|
} catch {
|
|
4416
4416
|
}
|
|
4417
4417
|
throw err;
|
|
4418
4418
|
}
|
|
4419
4419
|
} else {
|
|
4420
|
-
await
|
|
4420
|
+
await fs5.writeFile(filePath, content);
|
|
4421
4421
|
}
|
|
4422
4422
|
}
|
|
4423
4423
|
var init_fs = __esm({
|
|
@@ -43063,10 +43063,10 @@ void main () {
|
|
|
43063
43063
|
}
|
|
43064
43064
|
};
|
|
43065
43065
|
_proto._emitByBurst = function _emitByBurst(lastPlayTime, playTime) {
|
|
43066
|
-
var
|
|
43067
|
-
var duration3 =
|
|
43066
|
+
var main2 = this._generator.main;
|
|
43067
|
+
var duration3 = main2.duration;
|
|
43068
43068
|
var cycleCount = Math.floor((playTime - lastPlayTime) / duration3);
|
|
43069
|
-
if (
|
|
43069
|
+
if (main2.isLoop && (cycleCount > 0 || playTime % duration3 < lastPlayTime % duration3)) {
|
|
43070
43070
|
var middleTime = Math.ceil(lastPlayTime / duration3) * duration3;
|
|
43071
43071
|
this._emitBySubBurst(lastPlayTime, middleTime, duration3);
|
|
43072
43072
|
this._currentBurstIndex = 0;
|
|
@@ -44476,16 +44476,16 @@ void main () {
|
|
|
44476
44476
|
_proto._emit = function _emit(playTime, count) {
|
|
44477
44477
|
var emission = this.emission;
|
|
44478
44478
|
if (emission.enabled) {
|
|
44479
|
-
var
|
|
44479
|
+
var main2 = this.main;
|
|
44480
44480
|
var notRetireParticleCount = this._getNotRetiredParticleCount();
|
|
44481
|
-
if (notRetireParticleCount >=
|
|
44481
|
+
if (notRetireParticleCount >= main2.maxParticles) {
|
|
44482
44482
|
return;
|
|
44483
44483
|
}
|
|
44484
44484
|
var position = ParticleGenerator2._tempVector30;
|
|
44485
44485
|
var direction = ParticleGenerator2._tempVector31;
|
|
44486
44486
|
var transform2 = this._renderer.entity.transform;
|
|
44487
44487
|
var shape = emission.shape;
|
|
44488
|
-
var positionScale =
|
|
44488
|
+
var positionScale = main2._getPositionScale();
|
|
44489
44489
|
for (var i = 0; i < count; i++) {
|
|
44490
44490
|
if (shape == null ? void 0 : shape.enabled) {
|
|
44491
44491
|
shape._generatePositionAndDirection(emission._shapeRand, playTime, position, direction);
|
|
@@ -44494,7 +44494,7 @@ void main () {
|
|
|
44494
44494
|
} else {
|
|
44495
44495
|
position.set(0, 0, 0);
|
|
44496
44496
|
direction.set(0, 0, -1);
|
|
44497
|
-
if (
|
|
44497
|
+
if (main2.simulationSpace === ParticleSimulationSpace.Local) {
|
|
44498
44498
|
direction.multiply(positionScale);
|
|
44499
44499
|
}
|
|
44500
44500
|
}
|
|
@@ -44504,10 +44504,10 @@ void main () {
|
|
|
44504
44504
|
};
|
|
44505
44505
|
_proto._update = function _update(elapsedTime) {
|
|
44506
44506
|
var lastAlive = this.isAlive;
|
|
44507
|
-
var _this = this,
|
|
44508
|
-
var duration3 =
|
|
44507
|
+
var _this = this, main2 = _this.main, emission = _this.emission;
|
|
44508
|
+
var duration3 = main2.duration;
|
|
44509
44509
|
var lastPlayTime = this._playTime;
|
|
44510
|
-
var deltaTime = elapsedTime *
|
|
44510
|
+
var deltaTime = elapsedTime * main2.simulationSpeed;
|
|
44511
44511
|
if (this._playStartDelay > 0) {
|
|
44512
44512
|
var remainingDelay = this._playStartDelay -= deltaTime;
|
|
44513
44513
|
if (remainingDelay < 0) {
|
|
@@ -44520,23 +44520,23 @@ void main () {
|
|
|
44520
44520
|
this._playTime += deltaTime;
|
|
44521
44521
|
this._retireActiveParticles();
|
|
44522
44522
|
this._freeRetiredParticles();
|
|
44523
|
-
if (
|
|
44523
|
+
if (main2.simulationSpace === ParticleSimulationSpace.World) {
|
|
44524
44524
|
this._retireTransformedBounds();
|
|
44525
44525
|
}
|
|
44526
44526
|
if (emission.enabled && this._isPlaying) {
|
|
44527
|
-
if (this._currentParticleCount >
|
|
44527
|
+
if (this._currentParticleCount > main2._maxParticleBuffer) {
|
|
44528
44528
|
var notRetireParticleCount = this._getNotRetiredParticleCount();
|
|
44529
|
-
if (notRetireParticleCount <
|
|
44529
|
+
if (notRetireParticleCount < main2._maxParticleBuffer) {
|
|
44530
44530
|
this._resizeInstanceBuffer(false);
|
|
44531
44531
|
}
|
|
44532
44532
|
}
|
|
44533
44533
|
emission._emit(lastPlayTime, this._playTime);
|
|
44534
|
-
if (!
|
|
44534
|
+
if (!main2.isLoop && this._playTime > duration3) {
|
|
44535
44535
|
this._isPlaying = false;
|
|
44536
44536
|
}
|
|
44537
44537
|
}
|
|
44538
44538
|
if (this.isAlive) {
|
|
44539
|
-
if (
|
|
44539
|
+
if (main2.simulationSpace === ParticleSimulationSpace.World) {
|
|
44540
44540
|
this._generateTransformedBounds();
|
|
44541
44541
|
}
|
|
44542
44542
|
} else {
|
|
@@ -44786,9 +44786,9 @@ void main () {
|
|
|
44786
44786
|
if (nextFreeElement >= this._currentParticleCount) {
|
|
44787
44787
|
nextFreeElement = 0;
|
|
44788
44788
|
}
|
|
44789
|
-
var
|
|
44789
|
+
var main2 = this.main;
|
|
44790
44790
|
if (nextFreeElement === this._firstRetiredElement) {
|
|
44791
|
-
var increaseCount = Math.min(ParticleGenerator2._particleIncreaseCount,
|
|
44791
|
+
var increaseCount = Math.min(ParticleGenerator2._particleIncreaseCount, main2._maxParticleBuffer - this._currentParticleCount);
|
|
44792
44792
|
if (increaseCount === 0) {
|
|
44793
44793
|
return;
|
|
44794
44794
|
}
|
|
@@ -44796,42 +44796,42 @@ void main () {
|
|
|
44796
44796
|
nextFreeElement = firstFreeElement + 1;
|
|
44797
44797
|
}
|
|
44798
44798
|
var pos, rot;
|
|
44799
|
-
if (
|
|
44799
|
+
if (main2.simulationSpace === ParticleSimulationSpace.World) {
|
|
44800
44800
|
pos = transform2.worldPosition;
|
|
44801
44801
|
rot = transform2.worldRotationQuaternion;
|
|
44802
44802
|
}
|
|
44803
|
-
var startSpeed =
|
|
44803
|
+
var startSpeed = main2.startSpeed.evaluate(void 0, main2._startSpeedRand.random());
|
|
44804
44804
|
var instanceVertices = this._instanceVertices;
|
|
44805
44805
|
var offset = firstFreeElement * ParticleBufferUtils.instanceVertexFloatStride;
|
|
44806
44806
|
position.copyToArray(instanceVertices, offset);
|
|
44807
|
-
instanceVertices[offset + ParticleBufferUtils.startLifeTimeOffset] =
|
|
44807
|
+
instanceVertices[offset + ParticleBufferUtils.startLifeTimeOffset] = main2.startLifetime.evaluate(void 0, main2._startLifeTimeRand.random());
|
|
44808
44808
|
direction.copyToArray(instanceVertices, offset + 4);
|
|
44809
44809
|
instanceVertices[offset + ParticleBufferUtils.timeOffset] = playTime;
|
|
44810
44810
|
var startColor = ParticleGenerator2._tempColor0;
|
|
44811
|
-
|
|
44811
|
+
main2.startColor.evaluate(void 0, main2._startColorRand.random(), startColor);
|
|
44812
44812
|
startColor.copyToArray(instanceVertices, offset + 8);
|
|
44813
44813
|
var duration3 = this.main.duration;
|
|
44814
44814
|
var normalizedEmitAge = playTime % duration3 / duration3;
|
|
44815
|
-
var startSizeRand =
|
|
44816
|
-
if (
|
|
44817
|
-
instanceVertices[offset + 12] =
|
|
44818
|
-
instanceVertices[offset + 13] =
|
|
44819
|
-
instanceVertices[offset + 14] =
|
|
44815
|
+
var startSizeRand = main2._startSizeRand;
|
|
44816
|
+
if (main2.startSize3D) {
|
|
44817
|
+
instanceVertices[offset + 12] = main2.startSizeX.evaluate(normalizedEmitAge, startSizeRand.random());
|
|
44818
|
+
instanceVertices[offset + 13] = main2.startSizeY.evaluate(normalizedEmitAge, startSizeRand.random());
|
|
44819
|
+
instanceVertices[offset + 14] = main2.startSizeZ.evaluate(normalizedEmitAge, startSizeRand.random());
|
|
44820
44820
|
} else {
|
|
44821
|
-
var size =
|
|
44821
|
+
var size = main2.startSize.evaluate(normalizedEmitAge, startSizeRand.random());
|
|
44822
44822
|
instanceVertices[offset + 12] = size;
|
|
44823
44823
|
instanceVertices[offset + 13] = size;
|
|
44824
44824
|
instanceVertices[offset + 14] = size;
|
|
44825
44825
|
}
|
|
44826
|
-
var startRotationRand =
|
|
44826
|
+
var startRotationRand = main2._startRotationRand, flipRotation = main2.flipRotation;
|
|
44827
44827
|
var isFlip = flipRotation > startRotationRand.random();
|
|
44828
44828
|
if (this._renderer.renderMode !== ParticleRenderMode.Mesh) {
|
|
44829
44829
|
isFlip = !isFlip;
|
|
44830
44830
|
}
|
|
44831
|
-
var rotationZ =
|
|
44832
|
-
if (
|
|
44833
|
-
var rotationX =
|
|
44834
|
-
var rotationY =
|
|
44831
|
+
var rotationZ = main2.startRotationZ.evaluate(void 0, startRotationRand.random());
|
|
44832
|
+
if (main2.startRotation3D) {
|
|
44833
|
+
var rotationX = main2.startRotationX.evaluate(void 0, startRotationRand.random());
|
|
44834
|
+
var rotationY = main2.startRotationY.evaluate(void 0, startRotationRand.random());
|
|
44835
44835
|
instanceVertices[offset + 15] = isFlip ? -rotationX : rotationX;
|
|
44836
44836
|
instanceVertices[offset + 16] = isFlip ? -rotationY : rotationY;
|
|
44837
44837
|
instanceVertices[offset + 17] = isFlip ? -rotationZ : rotationZ;
|
|
@@ -44839,12 +44839,12 @@ void main () {
|
|
|
44839
44839
|
instanceVertices[offset + 15] = isFlip ? -rotationZ : rotationZ;
|
|
44840
44840
|
}
|
|
44841
44841
|
instanceVertices[offset + 18] = startSpeed;
|
|
44842
|
-
switch (
|
|
44842
|
+
switch (main2.gravityModifier.mode) {
|
|
44843
44843
|
case ParticleCurveMode.Constant:
|
|
44844
|
-
instanceVertices[offset + 19] =
|
|
44844
|
+
instanceVertices[offset + 19] = main2.gravityModifier.constant;
|
|
44845
44845
|
break;
|
|
44846
44846
|
case ParticleCurveMode.TwoConstants:
|
|
44847
|
-
instanceVertices[offset + 19] =
|
|
44847
|
+
instanceVertices[offset + 19] = main2.gravityModifier.evaluate(void 0, main2._gravityModifierRand.random());
|
|
44848
44848
|
break;
|
|
44849
44849
|
}
|
|
44850
44850
|
var colorOverLifetime = this.colorOverLifetime;
|
|
@@ -45000,7 +45000,7 @@ void main () {
|
|
|
45000
45000
|
_proto._calculateGeneratorBounds = function _calculateGeneratorBounds(maxLifetime, bounds) {
|
|
45001
45001
|
var directionMax = ParticleGenerator2._tempVector30, directionMin = ParticleGenerator2._tempVector31, speedMinMax = ParticleGenerator2._tempVector20;
|
|
45002
45002
|
var min = bounds.min, max = bounds.max;
|
|
45003
|
-
var
|
|
45003
|
+
var main2 = this.main;
|
|
45004
45004
|
var shape = this.emission.shape;
|
|
45005
45005
|
if (shape == null ? void 0 : shape.enabled) {
|
|
45006
45006
|
shape._getPositionRange(min, max);
|
|
@@ -45011,19 +45011,19 @@ void main () {
|
|
|
45011
45011
|
directionMin.set(0, 0, -1);
|
|
45012
45012
|
directionMax.set(0, 0, 0);
|
|
45013
45013
|
}
|
|
45014
|
-
this._getExtremeValueFromZero(
|
|
45014
|
+
this._getExtremeValueFromZero(main2.startSpeed, speedMinMax);
|
|
45015
45015
|
var speedMin = speedMinMax.x, speedMax = speedMinMax.y;
|
|
45016
45016
|
var dirMinX = directionMin.x, dirMinY = directionMin.y, dirMinZ = directionMin.z;
|
|
45017
45017
|
var dirMaxX = directionMax.x, dirMaxY = directionMax.y, dirMaxZ = directionMax.z;
|
|
45018
45018
|
min.set(min.x + Math.min(dirMinX * speedMax, dirMaxX * speedMin) * maxLifetime, min.y + Math.min(dirMinY * speedMax, dirMaxY * speedMin) * maxLifetime, min.z + Math.min(dirMinZ * speedMax, dirMaxZ * speedMin) * maxLifetime);
|
|
45019
45019
|
max.set(max.x + Math.max(dirMinX * speedMin, dirMaxX * speedMax) * maxLifetime, max.y + Math.max(dirMinY * speedMin, dirMaxY * speedMax) * maxLifetime, max.z + Math.max(dirMinZ * speedMin, dirMaxZ * speedMax) * maxLifetime);
|
|
45020
|
-
var maxSize =
|
|
45021
|
-
if (
|
|
45022
|
-
var startSizeYMax =
|
|
45020
|
+
var maxSize = main2.startSize._getMax();
|
|
45021
|
+
if (main2.startSize3D) {
|
|
45022
|
+
var startSizeYMax = main2.startSizeY._getMax();
|
|
45023
45023
|
if (this._renderer.renderMode === ParticleRenderMode.Billboard || ParticleRenderMode.StretchBillboard || ParticleRenderMode.HorizontalBillboard) {
|
|
45024
45024
|
maxSize = Math.max(maxSize, startSizeYMax);
|
|
45025
45025
|
} else {
|
|
45026
|
-
var startSizeZMax =
|
|
45026
|
+
var startSizeZMax = main2.startSizeZ._getMax();
|
|
45027
45027
|
maxSize = Math.max(maxSize, startSizeYMax, startSizeZMax);
|
|
45028
45028
|
}
|
|
45029
45029
|
}
|
|
@@ -53009,13 +53009,13 @@ var require_main4 = __commonJS({
|
|
|
53009
53009
|
});
|
|
53010
53010
|
};
|
|
53011
53011
|
_proto._getBufferData = function _getBufferData(buffers, restoreInfo) {
|
|
53012
|
-
var
|
|
53012
|
+
var main2 = restoreInfo.main;
|
|
53013
53013
|
var data;
|
|
53014
|
-
if (
|
|
53015
|
-
var buffer2 = buffers[
|
|
53016
|
-
data = new
|
|
53014
|
+
if (main2) {
|
|
53015
|
+
var buffer2 = buffers[main2.bufferIndex];
|
|
53016
|
+
data = new main2.TypedArray(buffer2, main2.byteOffset, main2.length);
|
|
53017
53017
|
} else {
|
|
53018
|
-
data = new
|
|
53018
|
+
data = new main2.TypedArray(main2.length);
|
|
53019
53019
|
}
|
|
53020
53020
|
var sparseCount = restoreInfo.sparseCount;
|
|
53021
53021
|
if (sparseCount) {
|
|
@@ -53054,8 +53054,8 @@ var require_main4 = __commonJS({
|
|
|
53054
53054
|
this.buffer = buffer2;
|
|
53055
53055
|
this.data = data;
|
|
53056
53056
|
};
|
|
53057
|
-
var BufferDataRestoreInfo = function BufferDataRestoreInfo2(
|
|
53058
|
-
this.main =
|
|
53057
|
+
var BufferDataRestoreInfo = function BufferDataRestoreInfo2(main2, typeSize, sparseCount, sparseIndices, sparseValues) {
|
|
53058
|
+
this.main = main2;
|
|
53059
53059
|
this.typeSize = typeSize;
|
|
53060
53060
|
this.sparseCount = sparseCount;
|
|
53061
53061
|
this.sparseIndices = sparseIndices;
|
|
@@ -84845,15 +84845,15 @@ var require_mobx_cjs_development = __commonJS({
|
|
|
84845
84845
|
if (!globalState.trackingDerivation) {
|
|
84846
84846
|
return this.has_(key);
|
|
84847
84847
|
}
|
|
84848
|
-
var
|
|
84849
|
-
if (!
|
|
84850
|
-
var newEntry =
|
|
84848
|
+
var entry2 = this.hasMap_.get(key);
|
|
84849
|
+
if (!entry2) {
|
|
84850
|
+
var newEntry = entry2 = new ObservableValue(this.has_(key), referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?", false);
|
|
84851
84851
|
this.hasMap_.set(key, newEntry);
|
|
84852
84852
|
onBecomeUnobserved(newEntry, function() {
|
|
84853
84853
|
return _this2.hasMap_["delete"](key);
|
|
84854
84854
|
});
|
|
84855
84855
|
}
|
|
84856
|
-
return
|
|
84856
|
+
return entry2.get();
|
|
84857
84857
|
};
|
|
84858
84858
|
_proto.set = function set3(key, value) {
|
|
84859
84859
|
var hasKey = this.has_(key);
|
|
@@ -85549,12 +85549,12 @@ var require_mobx_cjs_development = __commonJS({
|
|
|
85549
85549
|
return key in this.target_;
|
|
85550
85550
|
}
|
|
85551
85551
|
this.pendingKeys_ || (this.pendingKeys_ = /* @__PURE__ */ new Map());
|
|
85552
|
-
var
|
|
85553
|
-
if (!
|
|
85554
|
-
|
|
85555
|
-
this.pendingKeys_.set(key,
|
|
85552
|
+
var entry2 = this.pendingKeys_.get(key);
|
|
85553
|
+
if (!entry2) {
|
|
85554
|
+
entry2 = new ObservableValue(key in this.target_, referenceEnhancer, this.name_ + "." + stringifyKey(key) + "?", false);
|
|
85555
|
+
this.pendingKeys_.set(key, entry2);
|
|
85556
85556
|
}
|
|
85557
|
-
return
|
|
85557
|
+
return entry2.get();
|
|
85558
85558
|
};
|
|
85559
85559
|
_proto.make_ = function make_2(key, annotation) {
|
|
85560
85560
|
if (annotation === true) {
|
|
@@ -88642,20 +88642,20 @@ var init_VanillaPackage = __esm({
|
|
|
88642
88642
|
}, "");
|
|
88643
88643
|
this._eta.configure({ functionHeader });
|
|
88644
88644
|
const eta = this._eta;
|
|
88645
|
-
const
|
|
88646
|
-
const
|
|
88645
|
+
const entry2 = eta.renderString(templates.entry, params);
|
|
88646
|
+
const html2 = eta.renderString(templates.html, params);
|
|
88647
88647
|
const mainEntry = eta.renderString(templates.main, params);
|
|
88648
|
-
const
|
|
88649
|
-
const
|
|
88650
|
-
const
|
|
88648
|
+
const scriptEntry2 = eta.renderString(templates.scriptEntry, params);
|
|
88649
|
+
const packageJson2 = eta.renderString(templates.packageJson, params);
|
|
88650
|
+
const viteConfig2 = eta.renderString(templates.viteConfig, params);
|
|
88651
88651
|
const vfs = this._vfs;
|
|
88652
|
-
vfs.getFileByPath("/src/index.ts").content =
|
|
88653
|
-
vfs.getFileByPath("/src/scripts/index.ts").content =
|
|
88654
|
-
vfs.getFileByPath("/package.json").content = JSON.stringify(JSON.parse(
|
|
88655
|
-
vfs.getFileByPath("/index.html").content =
|
|
88652
|
+
vfs.getFileByPath("/src/index.ts").content = entry2;
|
|
88653
|
+
vfs.getFileByPath("/src/scripts/index.ts").content = scriptEntry2;
|
|
88654
|
+
vfs.getFileByPath("/package.json").content = JSON.stringify(JSON.parse(packageJson2), null, 2);
|
|
88655
|
+
vfs.getFileByPath("/index.html").content = html2;
|
|
88656
88656
|
vfs.getFileByPath("/main.js").content = mainEntry;
|
|
88657
88657
|
vfs.getFileByPath("/tsconfig.json").content = templates.tsconfig;
|
|
88658
|
-
vfs.getFileByPath("/vite.config.ts").content =
|
|
88658
|
+
vfs.getFileByPath("/vite.config.ts").content = viteConfig2;
|
|
88659
88659
|
}
|
|
88660
88660
|
/**
|
|
88661
88661
|
* 写入文件到虚拟文件系统
|
|
@@ -88691,30 +88691,21 @@ function cliUploadFactory() {
|
|
|
88691
88691
|
upload.download = true;
|
|
88692
88692
|
return upload;
|
|
88693
88693
|
}
|
|
88694
|
-
var
|
|
88694
|
+
var import_index_ts, import_index_ts2, import_package_json, import_index_html, import_main_js, import_tsconfig_json, import_vite_config_ts, CLIVanillaPackage;
|
|
88695
88695
|
var init_cli_vanilla_package = __esm({
|
|
88696
88696
|
"src/cli-vanilla-package.ts"() {
|
|
88697
88697
|
"use strict";
|
|
88698
|
-
import_promises8 = __toESM(require("node:fs/promises"));
|
|
88699
|
-
import_node_path12 = __toESM(require("node:path"));
|
|
88700
|
-
import_node_module = require("node:module");
|
|
88701
88698
|
init_VanillaPackage();
|
|
88702
|
-
|
|
88703
|
-
|
|
88704
|
-
|
|
88705
|
-
|
|
88699
|
+
import_index_ts = __toESM(require_index_ts());
|
|
88700
|
+
import_index_ts2 = __toESM(require_index_ts2());
|
|
88701
|
+
import_package_json = __toESM(require_package_json());
|
|
88702
|
+
import_index_html = __toESM(require_index_html());
|
|
88703
|
+
import_main_js = __toESM(require_main_js());
|
|
88704
|
+
import_tsconfig_json = __toESM(require_tsconfig_json());
|
|
88705
|
+
import_vite_config_ts = __toESM(require_vite_config_ts());
|
|
88706
88706
|
CLIVanillaPackage = class extends VanillaPackage {
|
|
88707
88707
|
async _loadTemplate() {
|
|
88708
|
-
|
|
88709
|
-
import_promises8.default.readFile(import_node_path12.default.join(templateDir, "src/index.ts.ejs"), "utf-8"),
|
|
88710
|
-
import_promises8.default.readFile(import_node_path12.default.join(templateDir, "src/scripts/index.ts.ejs"), "utf-8"),
|
|
88711
|
-
import_promises8.default.readFile(import_node_path12.default.join(templateDir, "package.json.ejs"), "utf-8"),
|
|
88712
|
-
import_promises8.default.readFile(import_node_path12.default.join(templateDir, "index.html.ejs"), "utf-8"),
|
|
88713
|
-
import_promises8.default.readFile(import_node_path12.default.join(templateDir, "main.js.ejs"), "utf-8"),
|
|
88714
|
-
import_promises8.default.readFile(import_node_path12.default.join(templateDir, "tsconfig.json.ejs"), "utf-8"),
|
|
88715
|
-
import_promises8.default.readFile(import_node_path12.default.join(templateDir, "vite.config.ts.ejs"), "utf-8")
|
|
88716
|
-
]);
|
|
88717
|
-
return { entry, scriptEntry, packageJson, html, main, tsconfig, viteConfig };
|
|
88708
|
+
return { entry: import_index_ts.default, scriptEntry: import_index_ts2.default, packageJson: import_package_json.default, html: import_index_html.default, main: import_main_js.default, tsconfig: import_tsconfig_json.default, viteConfig: import_vite_config_ts.default };
|
|
88718
88709
|
}
|
|
88719
88710
|
async _writeFiles(project, cacheMap, download = false) {
|
|
88720
88711
|
const needWrittenLocally = download && !this._buildOptions.assetOptions.uploadCDN;
|
|
@@ -89271,9 +89262,9 @@ function toArrayBuffer(buffer2) {
|
|
|
89271
89262
|
}
|
|
89272
89263
|
function resolveBundledAssetPath(filename) {
|
|
89273
89264
|
const candidates = [
|
|
89274
|
-
(0,
|
|
89265
|
+
(0, import_node_path12.join)(__dirname, "../assets", filename),
|
|
89275
89266
|
// dev: running from src/, assets at package root
|
|
89276
|
-
(0,
|
|
89267
|
+
(0, import_node_path12.join)(__dirname, "assets", filename)
|
|
89277
89268
|
// prod: running from dist/, assets copied by build.mjs
|
|
89278
89269
|
];
|
|
89279
89270
|
for (const candidate of candidates) {
|
|
@@ -89296,7 +89287,7 @@ async function loadBundledBasisAssets() {
|
|
|
89296
89287
|
bundledBasisAssetsPromise = (async () => {
|
|
89297
89288
|
const jsPath = resolveBundledAssetPath(BASIS_JS_FILENAME);
|
|
89298
89289
|
const wasmPath = resolveBundledAssetPath(BASIS_WASM_FILENAME);
|
|
89299
|
-
const [jsBuffer, wasmBuffer] = await Promise.all([(0,
|
|
89290
|
+
const [jsBuffer, wasmBuffer] = await Promise.all([(0, import_promises8.readFile)(jsPath), (0, import_promises8.readFile)(wasmPath)]);
|
|
89300
89291
|
assertChecksum(BASIS_JS_FILENAME, jsBuffer, BASIS_JS_SHA256);
|
|
89301
89292
|
assertChecksum(BASIS_WASM_FILENAME, wasmBuffer, BASIS_WASM_SHA256);
|
|
89302
89293
|
return { workerCode: buildWorkerCode(jsBuffer.toString("utf-8")), wasmBinary: toArrayBuffer(wasmBuffer) };
|
|
@@ -89364,15 +89355,15 @@ parentPort.on("message", async (msg) => {
|
|
|
89364
89355
|
});
|
|
89365
89356
|
`;
|
|
89366
89357
|
}
|
|
89367
|
-
var import_node_worker_threads, import_node_crypto4,
|
|
89358
|
+
var import_node_worker_threads, import_node_crypto4, import_promises8, import_node_fs, import_node_path12, BASIS_JS_FILENAME, BASIS_WASM_FILENAME, BASIS_JS_SHA256, BASIS_WASM_SHA256, bundledBasisAssetsPromise, CLIKtx2Encoder;
|
|
89368
89359
|
var init_cli_ktx2_encoder = __esm({
|
|
89369
89360
|
"src/cli-ktx2-encoder.ts"() {
|
|
89370
89361
|
"use strict";
|
|
89371
89362
|
import_node_worker_threads = require("node:worker_threads");
|
|
89372
89363
|
import_node_crypto4 = require("node:crypto");
|
|
89373
|
-
|
|
89364
|
+
import_promises8 = require("node:fs/promises");
|
|
89374
89365
|
import_node_fs = require("node:fs");
|
|
89375
|
-
|
|
89366
|
+
import_node_path12 = require("node:path");
|
|
89376
89367
|
init_ktx_parse_modern();
|
|
89377
89368
|
BASIS_JS_FILENAME = "basis_encoder.js";
|
|
89378
89369
|
BASIS_WASM_FILENAME = "basis_encoder.wasm";
|
|
@@ -89598,11 +89589,11 @@ function createManifestEntryIndex(entries, options = {}) {
|
|
|
89598
89589
|
const localPathRegistry = createLocalPathRegistry();
|
|
89599
89590
|
const pathToId = /* @__PURE__ */ new Map();
|
|
89600
89591
|
const folderIdByPath = /* @__PURE__ */ new Map();
|
|
89601
|
-
for (const [assetId,
|
|
89602
|
-
const canonicalPath = assertCanonicalAssetPath(
|
|
89592
|
+
for (const [assetId, entry2] of Object.entries(entries)) {
|
|
89593
|
+
const canonicalPath = assertCanonicalAssetPath(entry2.path, `Manifest entry '${assetId}' path`);
|
|
89603
89594
|
registerLocalPathOrThrow(localPathRegistry, assetId, canonicalPath, caseFold);
|
|
89604
89595
|
pathToId.set(canonicalPath, assetId);
|
|
89605
|
-
if (
|
|
89596
|
+
if (entry2.type === "Folder") {
|
|
89606
89597
|
folderIdByPath.set(canonicalPath, assetId);
|
|
89607
89598
|
}
|
|
89608
89599
|
}
|
|
@@ -89729,8 +89720,8 @@ var init_sync_adapter = __esm({
|
|
|
89729
89720
|
function extractMaterialProps(matData) {
|
|
89730
89721
|
const props = {};
|
|
89731
89722
|
if (matData.shaderData && typeof matData.shaderData === "object") {
|
|
89732
|
-
for (const [key,
|
|
89733
|
-
props[key] =
|
|
89723
|
+
for (const [key, entry2] of Object.entries(matData.shaderData)) {
|
|
89724
|
+
props[key] = entry2.value !== void 0 ? entry2.value : entry2;
|
|
89734
89725
|
}
|
|
89735
89726
|
} else {
|
|
89736
89727
|
for (const [key, value] of Object.entries(matData)) {
|
|
@@ -89947,11 +89938,11 @@ function buildMaterialMainData(name, props, original) {
|
|
|
89947
89938
|
const shaderData = Object.fromEntries(shaderDataEntries);
|
|
89948
89939
|
if (original) {
|
|
89949
89940
|
const originalShaderData = original.shaderData ?? {};
|
|
89950
|
-
for (const [key,
|
|
89941
|
+
for (const [key, entry2] of Object.entries(shaderData)) {
|
|
89951
89942
|
const orig = originalShaderData[key];
|
|
89952
89943
|
if (orig && typeof orig === "object" && typeof orig.type === "string") {
|
|
89953
89944
|
;
|
|
89954
|
-
|
|
89945
|
+
entry2.type = orig.type;
|
|
89955
89946
|
}
|
|
89956
89947
|
}
|
|
89957
89948
|
const preservedOriginalEntries = Object.fromEntries(
|
|
@@ -90006,7 +89997,7 @@ var init_scene_parser = __esm({
|
|
|
90006
89997
|
async function readLocalTextAsset(projectDir, entryPath, entryUrl, label) {
|
|
90007
89998
|
if (isCdnUrl(entryUrl)) return null;
|
|
90008
89999
|
try {
|
|
90009
|
-
return await
|
|
90000
|
+
return await import_promises9.default.readFile(`${projectDir}/${entryPath}`, "utf-8");
|
|
90010
90001
|
} catch (error49) {
|
|
90011
90002
|
if (isEnoent(error49)) return null;
|
|
90012
90003
|
throw new Error(`[domain-bridge] failed to read ${label} ${entryPath}: ${errorMessage(error49)}`);
|
|
@@ -90020,7 +90011,7 @@ function parseJsonWithPath(text, filePath) {
|
|
|
90020
90011
|
}
|
|
90021
90012
|
}
|
|
90022
90013
|
function resolveSceneAssetId(config2, manifest) {
|
|
90023
|
-
const sceneAssetIds = Object.entries(manifest.entries).filter(([,
|
|
90014
|
+
const sceneAssetIds = Object.entries(manifest.entries).filter(([, entry2]) => entry2.type === "Scene").map(([assetId]) => assetId);
|
|
90024
90015
|
if (typeof config2.sceneId === "string" && config2.sceneId.length > 0) {
|
|
90025
90016
|
const configuredEntry = manifest.entries[config2.sceneId];
|
|
90026
90017
|
if (configuredEntry?.type === "Scene") {
|
|
@@ -90031,7 +90022,7 @@ function resolveSceneAssetId(config2, manifest) {
|
|
|
90031
90022
|
}
|
|
90032
90023
|
async function readRemoteProjectId(projectDir) {
|
|
90033
90024
|
try {
|
|
90034
|
-
const remoteText = await
|
|
90025
|
+
const remoteText = await import_promises9.default.readFile(`${projectDir}/.galacean/remote.json`, "utf-8");
|
|
90035
90026
|
const remote = JSON.parse(remoteText);
|
|
90036
90027
|
return typeof remote.projectId === "string" ? remote.projectId : "";
|
|
90037
90028
|
} catch (error49) {
|
|
@@ -90040,10 +90031,10 @@ async function readRemoteProjectId(projectDir) {
|
|
|
90040
90031
|
}
|
|
90041
90032
|
}
|
|
90042
90033
|
async function loadDomainState(projectDir) {
|
|
90043
|
-
const configText = await
|
|
90034
|
+
const configText = await import_promises9.default.readFile(`${projectDir}/project.galacean`, "utf-8");
|
|
90044
90035
|
const config2 = JSON.parse(configText);
|
|
90045
90036
|
const remoteProjectId = await readRemoteProjectId(projectDir);
|
|
90046
|
-
const manifestText = await
|
|
90037
|
+
const manifestText = await import_promises9.default.readFile(`${projectDir}/.galacean/manifest.json`, "utf-8");
|
|
90047
90038
|
const manifest = JSON.parse(manifestText);
|
|
90048
90039
|
const sceneAssetId = resolveSceneAssetId(config2, manifest);
|
|
90049
90040
|
if (sceneAssetId) {
|
|
@@ -90054,25 +90045,25 @@ async function loadDomainState(projectDir) {
|
|
|
90054
90045
|
const rootEntityIds = [];
|
|
90055
90046
|
let sceneSettings;
|
|
90056
90047
|
const assetMeta = /* @__PURE__ */ new Map();
|
|
90057
|
-
for (const [assetId,
|
|
90048
|
+
for (const [assetId, entry2] of Object.entries(manifest.entries)) {
|
|
90058
90049
|
let meta3;
|
|
90059
|
-
const inlineMeta =
|
|
90050
|
+
const inlineMeta = entry2.meta;
|
|
90060
90051
|
if (inlineMeta && typeof inlineMeta === "object") {
|
|
90061
90052
|
meta3 = inlineMeta;
|
|
90062
90053
|
} else {
|
|
90063
|
-
const metaText = await
|
|
90054
|
+
const metaText = await import_promises9.default.readFile(`${projectDir}/${metaFilePath(entry2.path)}`, "utf-8");
|
|
90064
90055
|
meta3 = JSON.parse(metaText);
|
|
90065
90056
|
}
|
|
90066
|
-
const serverId = meta3.serverId ||
|
|
90057
|
+
const serverId = meta3.serverId || entry2.serverId || `local-${assetId}`;
|
|
90067
90058
|
assetMeta.set(assetId, { serverId, meta: meta3 });
|
|
90068
|
-
const isFolder =
|
|
90069
|
-
const parentId = findParentAssetId(
|
|
90059
|
+
const isFolder = entry2.type === "Folder";
|
|
90060
|
+
const parentId = findParentAssetId(entry2.path, manifest.entries);
|
|
90070
90061
|
const assetState = {
|
|
90071
90062
|
id: assetId,
|
|
90072
|
-
name: assetNameFromPath(
|
|
90073
|
-
type:
|
|
90063
|
+
name: assetNameFromPath(entry2.path, entry2.type),
|
|
90064
|
+
type: entry2.type,
|
|
90074
90065
|
parentFolderId: parentId,
|
|
90075
|
-
url:
|
|
90066
|
+
url: entry2.url || void 0,
|
|
90076
90067
|
meta: meta3,
|
|
90077
90068
|
serverId,
|
|
90078
90069
|
status: "ready"
|
|
@@ -90080,34 +90071,34 @@ async function loadDomainState(projectDir) {
|
|
|
90080
90071
|
if (!isFolder) {
|
|
90081
90072
|
if (assetId === sceneAssetId) {
|
|
90082
90073
|
try {
|
|
90083
|
-
const sceneText = await
|
|
90074
|
+
const sceneText = await import_promises9.default.readFile(`${projectDir}/${entry2.path}`, "utf-8");
|
|
90084
90075
|
const sceneFile = JSON.parse(sceneText);
|
|
90085
90076
|
parseSceneEntities(sceneFile, entities, rootEntityIds);
|
|
90086
90077
|
if (sceneFile.scene && typeof sceneFile.scene === "object") {
|
|
90087
90078
|
sceneSettings = sceneFile.scene;
|
|
90088
90079
|
}
|
|
90089
90080
|
} catch (error49) {
|
|
90090
|
-
throw new Error(`[domain-bridge] failed to parse scene file ${
|
|
90081
|
+
throw new Error(`[domain-bridge] failed to parse scene file ${entry2.path}: ${errorMessage(error49)}`);
|
|
90091
90082
|
}
|
|
90092
|
-
} else if (
|
|
90093
|
-
const text = await readLocalTextAsset(projectDir,
|
|
90083
|
+
} else if (entry2.type === "script") {
|
|
90084
|
+
const text = await readLocalTextAsset(projectDir, entry2.path, entry2.url, "script");
|
|
90094
90085
|
if (text !== null) assetState.content = { code: text };
|
|
90095
|
-
} else if (
|
|
90096
|
-
const text = await readLocalTextAsset(projectDir,
|
|
90097
|
-
if (text !== null) assetState.content = parseJsonWithPath(text,
|
|
90098
|
-
} else if (
|
|
90099
|
-
const text = await readLocalTextAsset(projectDir,
|
|
90086
|
+
} else if (entry2.type === "Prefab") {
|
|
90087
|
+
const text = await readLocalTextAsset(projectDir, entry2.path, entry2.url, "prefab");
|
|
90088
|
+
if (text !== null) assetState.content = parseJsonWithPath(text, entry2.path);
|
|
90089
|
+
} else if (entry2.type === "Shader" || entry2.type === "ShaderChunk") {
|
|
90090
|
+
const text = await readLocalTextAsset(projectDir, entry2.path, entry2.url, entry2.type.toLowerCase());
|
|
90100
90091
|
if (text !== null) assetState.content = { source: text };
|
|
90101
|
-
} else if (
|
|
90102
|
-
const text = await readLocalTextAsset(projectDir,
|
|
90092
|
+
} else if (entry2.type === "Material") {
|
|
90093
|
+
const text = await readLocalTextAsset(projectDir, entry2.path, entry2.url, "material");
|
|
90103
90094
|
if (text !== null) {
|
|
90104
|
-
const matData = parseJsonWithPath(text,
|
|
90095
|
+
const matData = parseJsonWithPath(text, entry2.path);
|
|
90105
90096
|
const props = extractMaterialProps(matData);
|
|
90106
90097
|
if (Object.keys(props).length > 0) assetState.props = props;
|
|
90107
90098
|
assetState.content = matData;
|
|
90108
90099
|
}
|
|
90109
|
-
} else if (isCdnUrl(
|
|
90110
|
-
assetState.url =
|
|
90100
|
+
} else if (isCdnUrl(entry2.url)) {
|
|
90101
|
+
assetState.url = entry2.url;
|
|
90111
90102
|
} else {
|
|
90112
90103
|
assetState.url = "";
|
|
90113
90104
|
}
|
|
@@ -90130,11 +90121,11 @@ async function loadDomainState(projectDir) {
|
|
|
90130
90121
|
}
|
|
90131
90122
|
};
|
|
90132
90123
|
}
|
|
90133
|
-
var
|
|
90124
|
+
var import_promises9;
|
|
90134
90125
|
var init_load = __esm({
|
|
90135
90126
|
"src/domain-bridge/load.ts"() {
|
|
90136
90127
|
"use strict";
|
|
90137
|
-
|
|
90128
|
+
import_promises9 = __toESM(require("node:fs/promises"));
|
|
90138
90129
|
init_meta_file();
|
|
90139
90130
|
init_sync_adapter();
|
|
90140
90131
|
init_utils();
|
|
@@ -90145,7 +90136,7 @@ var init_load = __esm({
|
|
|
90145
90136
|
// src/domain-bridge/save.ts
|
|
90146
90137
|
async function isSameFileSystemEntry(pathA, pathB) {
|
|
90147
90138
|
try {
|
|
90148
|
-
const [a, b] = await Promise.all([
|
|
90139
|
+
const [a, b] = await Promise.all([import_promises10.default.stat(pathA), import_promises10.default.stat(pathB)]);
|
|
90149
90140
|
return a.dev === b.dev && a.ino === b.ino;
|
|
90150
90141
|
} catch (error49) {
|
|
90151
90142
|
if (isEnoent(error49)) return false;
|
|
@@ -90154,8 +90145,8 @@ async function isSameFileSystemEntry(pathA, pathB) {
|
|
|
90154
90145
|
}
|
|
90155
90146
|
async function atomicWriteNodeFs(filePath, content) {
|
|
90156
90147
|
const tmp = filePath + ".tmp";
|
|
90157
|
-
await
|
|
90158
|
-
await
|
|
90148
|
+
await import_promises10.default.writeFile(tmp, content);
|
|
90149
|
+
await import_promises10.default.rename(tmp, filePath);
|
|
90159
90150
|
}
|
|
90160
90151
|
async function saveDomainState(projectDir, state, ctx) {
|
|
90161
90152
|
let sceneJson;
|
|
@@ -90183,7 +90174,7 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
90183
90174
|
const newPathMap = buildLocalPathMap(remoteAssets);
|
|
90184
90175
|
const useCaseFoldGuards = await shouldUseCaseFoldGuards(projectDir);
|
|
90185
90176
|
if (useCaseFoldGuards) {
|
|
90186
|
-
const pathCollisions = findCaseFoldPathCollisions(Array.from(newPathMap.values(), (
|
|
90177
|
+
const pathCollisions = findCaseFoldPathCollisions(Array.from(newPathMap.values(), (entry2) => entry2.localPath));
|
|
90187
90178
|
if (pathCollisions.length > 0) {
|
|
90188
90179
|
const preview = formatConflictPreview(pathCollisions.map((item) => `${item.firstPath} <-> ${item.secondPath}`));
|
|
90189
90180
|
throw new Error(
|
|
@@ -90192,18 +90183,18 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
90192
90183
|
}
|
|
90193
90184
|
}
|
|
90194
90185
|
const contentHashes = /* @__PURE__ */ new Map();
|
|
90195
|
-
const removedEntries = Object.entries(ctx.manifest.entries).filter(([assetId]) => !state.assets[assetId]).map(([,
|
|
90196
|
-
for (const [,
|
|
90197
|
-
if (
|
|
90198
|
-
await
|
|
90186
|
+
const removedEntries = Object.entries(ctx.manifest.entries).filter(([assetId]) => !state.assets[assetId]).map(([, entry2]) => entry2);
|
|
90187
|
+
for (const [, entry2] of newPathMap) {
|
|
90188
|
+
if (entry2.isFolder) {
|
|
90189
|
+
await import_promises10.default.mkdir(`${projectDir}/${entry2.localPath}`, { recursive: true });
|
|
90199
90190
|
}
|
|
90200
90191
|
}
|
|
90201
90192
|
const pendingFileMoves = [];
|
|
90202
|
-
for (const [assetId,
|
|
90203
|
-
if (
|
|
90193
|
+
for (const [assetId, entry2] of newPathMap) {
|
|
90194
|
+
if (entry2.isFolder) continue;
|
|
90204
90195
|
const oldEntry = ctx.manifest.entries[assetId];
|
|
90205
|
-
if (oldEntry && oldEntry.path !==
|
|
90206
|
-
pendingFileMoves.push({ assetId, oldPath: oldEntry.path, newPath:
|
|
90196
|
+
if (oldEntry && oldEntry.path !== entry2.localPath) {
|
|
90197
|
+
pendingFileMoves.push({ assetId, oldPath: oldEntry.path, newPath: entry2.localPath });
|
|
90207
90198
|
}
|
|
90208
90199
|
}
|
|
90209
90200
|
if (useCaseFoldGuards) {
|
|
@@ -90227,12 +90218,12 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
90227
90218
|
}
|
|
90228
90219
|
const tempPath = `${move.oldPath}.__tmp_move__${tempMoveIndex++}`;
|
|
90229
90220
|
try {
|
|
90230
|
-
await
|
|
90221
|
+
await import_promises10.default.rename(`${projectDir}/${move.oldPath}`, `${projectDir}/${tempPath}`);
|
|
90231
90222
|
} catch (e) {
|
|
90232
90223
|
if (!isEnoent(e)) throw e;
|
|
90233
90224
|
}
|
|
90234
90225
|
try {
|
|
90235
|
-
await
|
|
90226
|
+
await import_promises10.default.rename(`${projectDir}/${metaFilePath(move.oldPath)}`, `${projectDir}/${metaFilePath(tempPath)}`);
|
|
90236
90227
|
} catch (e) {
|
|
90237
90228
|
if (!isEnoent(e)) throw e;
|
|
90238
90229
|
}
|
|
@@ -90244,19 +90235,19 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
90244
90235
|
await atomicWriteNodeFs(`${projectDir}/${sceneNewEntry.localPath}`, sceneJson);
|
|
90245
90236
|
}
|
|
90246
90237
|
}
|
|
90247
|
-
for (const [assetId,
|
|
90248
|
-
if (
|
|
90238
|
+
for (const [assetId, entry2] of newPathMap) {
|
|
90239
|
+
if (entry2.isFolder) continue;
|
|
90249
90240
|
if (assetId === ctx.sceneAssetId && sceneJson) {
|
|
90250
90241
|
const oldEntry2 = ctx.manifest.entries[assetId];
|
|
90251
|
-
if (oldEntry2 && oldEntry2.path !==
|
|
90242
|
+
if (oldEntry2 && oldEntry2.path !== entry2.localPath) {
|
|
90252
90243
|
const sourcePath = moveSourceByAssetId.get(assetId) ?? oldEntry2.path;
|
|
90253
90244
|
try {
|
|
90254
|
-
await
|
|
90245
|
+
await import_promises10.default.unlink(`${projectDir}/${sourcePath}`);
|
|
90255
90246
|
} catch (e) {
|
|
90256
90247
|
if (!isEnoent(e)) throw e;
|
|
90257
90248
|
}
|
|
90258
90249
|
try {
|
|
90259
|
-
await
|
|
90250
|
+
await import_promises10.default.unlink(`${projectDir}/${metaFilePath(sourcePath)}`);
|
|
90260
90251
|
} catch (e) {
|
|
90261
90252
|
if (!isEnoent(e)) throw e;
|
|
90262
90253
|
}
|
|
@@ -90267,31 +90258,31 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
90267
90258
|
const asset2 = state.assets[assetId];
|
|
90268
90259
|
if (!asset2) continue;
|
|
90269
90260
|
const oldEntry = ctx.manifest.entries[assetId];
|
|
90270
|
-
const newPath =
|
|
90261
|
+
const newPath = entry2.localPath;
|
|
90271
90262
|
let renameSourceMissing = false;
|
|
90272
90263
|
if (oldEntry && oldEntry.path !== newPath) {
|
|
90273
90264
|
const sourcePath = moveSourceByAssetId.get(assetId) ?? oldEntry.path;
|
|
90274
90265
|
try {
|
|
90275
|
-
await
|
|
90266
|
+
await import_promises10.default.rename(`${projectDir}/${sourcePath}`, `${projectDir}/${newPath}`);
|
|
90276
90267
|
} catch (e) {
|
|
90277
90268
|
if (!isEnoent(e)) throw e;
|
|
90278
90269
|
renameSourceMissing = true;
|
|
90279
90270
|
}
|
|
90280
90271
|
try {
|
|
90281
|
-
await
|
|
90272
|
+
await import_promises10.default.rename(`${projectDir}/${metaFilePath(sourcePath)}`, `${projectDir}/${metaFilePath(newPath)}`);
|
|
90282
90273
|
} catch (e) {
|
|
90283
90274
|
if (!isEnoent(e)) throw e;
|
|
90284
90275
|
}
|
|
90285
90276
|
}
|
|
90286
90277
|
if (asset2.type === "script" && asset2.content) {
|
|
90287
90278
|
const code = typeof asset2.content.code === "string" ? asset2.content.code : JSON.stringify(asset2.content);
|
|
90288
|
-
await
|
|
90279
|
+
await import_promises10.default.writeFile(`${projectDir}/${newPath}`, code);
|
|
90289
90280
|
contentHashes.set(assetId, md5Text(code));
|
|
90290
90281
|
continue;
|
|
90291
90282
|
}
|
|
90292
90283
|
if (asset2.type === "Prefab" && asset2.content) {
|
|
90293
90284
|
const json2 = JSON.stringify(asset2.content);
|
|
90294
|
-
await
|
|
90285
|
+
await import_promises10.default.writeFile(`${projectDir}/${newPath}`, json2);
|
|
90295
90286
|
contentHashes.set(assetId, md5Text(json2));
|
|
90296
90287
|
continue;
|
|
90297
90288
|
}
|
|
@@ -90299,19 +90290,19 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
90299
90290
|
const json2 = JSON.stringify(
|
|
90300
90291
|
buildMaterialMainData(asset2.name, asset2.props ?? {}, asset2.content)
|
|
90301
90292
|
);
|
|
90302
|
-
await
|
|
90293
|
+
await import_promises10.default.writeFile(`${projectDir}/${newPath}`, json2);
|
|
90303
90294
|
contentHashes.set(assetId, md5Text(json2));
|
|
90304
90295
|
continue;
|
|
90305
90296
|
}
|
|
90306
90297
|
if ((asset2.type === "Shader" || asset2.type === "ShaderChunk") && asset2.content != null) {
|
|
90307
90298
|
const source = typeof asset2.content.source === "string" ? asset2.content.source : "";
|
|
90308
|
-
await
|
|
90299
|
+
await import_promises10.default.writeFile(`${projectDir}/${newPath}`, source);
|
|
90309
90300
|
contentHashes.set(assetId, md5Text(source));
|
|
90310
90301
|
continue;
|
|
90311
90302
|
}
|
|
90312
90303
|
if (asset2.content != null) {
|
|
90313
90304
|
const text = JSON.stringify(asset2.content);
|
|
90314
|
-
await
|
|
90305
|
+
await import_promises10.default.writeFile(`${projectDir}/${newPath}`, text);
|
|
90315
90306
|
contentHashes.set(assetId, md5Text(text));
|
|
90316
90307
|
continue;
|
|
90317
90308
|
}
|
|
@@ -90325,7 +90316,7 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
90325
90316
|
throw new Error(`[saveDomainState] Invalid data URL for asset '${assetId}': missing base64 payload`);
|
|
90326
90317
|
}
|
|
90327
90318
|
const buf = Buffer.from(base643, "base64");
|
|
90328
|
-
await
|
|
90319
|
+
await import_promises10.default.writeFile(`${projectDir}/${newPath}`, buf);
|
|
90329
90320
|
contentHashes.set(assetId, md5Buffer(buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)));
|
|
90330
90321
|
continue;
|
|
90331
90322
|
}
|
|
@@ -90339,28 +90330,28 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
90339
90330
|
}
|
|
90340
90331
|
}
|
|
90341
90332
|
const newFolderPathKeys = /* @__PURE__ */ new Set();
|
|
90342
|
-
for (const [,
|
|
90343
|
-
if (
|
|
90333
|
+
for (const [, entry2] of newPathMap) {
|
|
90334
|
+
if (entry2.isFolder) newFolderPathKeys.add(pathCompareKey(entry2.localPath, useCaseFoldGuards));
|
|
90344
90335
|
}
|
|
90345
|
-
for (const [assetId,
|
|
90346
|
-
if (!
|
|
90336
|
+
for (const [assetId, entry2] of newPathMap) {
|
|
90337
|
+
if (!entry2.isFolder) continue;
|
|
90347
90338
|
const oldEntry = ctx.manifest.entries[assetId];
|
|
90348
90339
|
const oldPathReusedAsTarget = oldEntry ? newFolderPathKeys.has(pathCompareKey(oldEntry.path, useCaseFoldGuards)) : false;
|
|
90349
|
-
if (oldEntry && oldEntry.path !==
|
|
90340
|
+
if (oldEntry && oldEntry.path !== entry2.localPath) {
|
|
90350
90341
|
const oldFolderPath = `${projectDir}/${oldEntry.path}`;
|
|
90351
|
-
const newFolderPath = `${projectDir}/${
|
|
90352
|
-
if (isCaseOnlyPathChange(oldEntry.path,
|
|
90353
|
-
await
|
|
90342
|
+
const newFolderPath = `${projectDir}/${entry2.localPath}`;
|
|
90343
|
+
if (isCaseOnlyPathChange(oldEntry.path, entry2.localPath) && await isSameFileSystemEntry(oldFolderPath, newFolderPath)) {
|
|
90344
|
+
await import_promises10.default.rename(oldFolderPath, newFolderPath);
|
|
90354
90345
|
continue;
|
|
90355
90346
|
}
|
|
90356
90347
|
if (!oldPathReusedAsTarget) {
|
|
90357
90348
|
try {
|
|
90358
|
-
await
|
|
90349
|
+
await import_promises10.default.unlink(`${projectDir}/${metaFilePath(oldEntry.path)}`);
|
|
90359
90350
|
} catch (e) {
|
|
90360
90351
|
if (!isEnoent(e)) throw e;
|
|
90361
90352
|
}
|
|
90362
90353
|
try {
|
|
90363
|
-
await
|
|
90354
|
+
await import_promises10.default.rm(`${projectDir}/${oldEntry.path}`, { recursive: true, force: true });
|
|
90364
90355
|
} catch (e) {
|
|
90365
90356
|
if (!isEnoent(e)) throw e;
|
|
90366
90357
|
}
|
|
@@ -90368,28 +90359,28 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
90368
90359
|
}
|
|
90369
90360
|
}
|
|
90370
90361
|
const newPathKeys = new Set(
|
|
90371
|
-
Array.from(newPathMap.values(), (
|
|
90362
|
+
Array.from(newPathMap.values(), (entry2) => pathCompareKey(entry2.localPath, useCaseFoldGuards))
|
|
90372
90363
|
);
|
|
90373
90364
|
const removedOrdered = [
|
|
90374
|
-
...removedEntries.filter((
|
|
90375
|
-
...removedEntries.filter((
|
|
90365
|
+
...removedEntries.filter((entry2) => entry2.type !== "Folder"),
|
|
90366
|
+
...removedEntries.filter((entry2) => entry2.type === "Folder").sort((a, b) => b.path.split("/").length - a.path.split("/").length)
|
|
90376
90367
|
];
|
|
90377
|
-
for (const
|
|
90378
|
-
if (newPathKeys.has(pathCompareKey(
|
|
90368
|
+
for (const entry2 of removedOrdered) {
|
|
90369
|
+
if (newPathKeys.has(pathCompareKey(entry2.path, useCaseFoldGuards))) continue;
|
|
90379
90370
|
try {
|
|
90380
|
-
await
|
|
90371
|
+
await import_promises10.default.unlink(`${projectDir}/${metaFilePath(entry2.path)}`);
|
|
90381
90372
|
} catch (e) {
|
|
90382
90373
|
if (!isEnoent(e)) throw e;
|
|
90383
90374
|
}
|
|
90384
90375
|
try {
|
|
90385
|
-
await
|
|
90376
|
+
await import_promises10.default.rm(`${projectDir}/${entry2.path}`, { recursive: true, force: true });
|
|
90386
90377
|
} catch (e) {
|
|
90387
90378
|
if (!isEnoent(e)) throw e;
|
|
90388
90379
|
}
|
|
90389
90380
|
}
|
|
90390
90381
|
const manifestPath = `${projectDir}/.galacean/manifest.json`;
|
|
90391
90382
|
try {
|
|
90392
|
-
const diskManifestText = await
|
|
90383
|
+
const diskManifestText = await import_promises10.default.readFile(manifestPath, "utf-8");
|
|
90393
90384
|
const diskManifest = JSON.parse(diskManifestText);
|
|
90394
90385
|
if (diskManifest.entries) {
|
|
90395
90386
|
for (const [assetId, diskEntry] of Object.entries(diskManifest.entries)) {
|
|
@@ -90403,20 +90394,20 @@ async function saveDomainState(projectDir, state, ctx) {
|
|
|
90403
90394
|
console.warn("[saveDomainState] Failed to read existing manifest for serverId merge:", err);
|
|
90404
90395
|
}
|
|
90405
90396
|
await Promise.all(
|
|
90406
|
-
[...newPathMap.values()].map((
|
|
90407
|
-
const meta3 = generateMetaFile(
|
|
90408
|
-
return
|
|
90397
|
+
[...newPathMap.values()].map((entry2) => {
|
|
90398
|
+
const meta3 = generateMetaFile(entry2);
|
|
90399
|
+
return import_promises10.default.writeFile(`${projectDir}/${metaFilePath(entry2.localPath)}`, JSON.stringify(meta3, null, 2));
|
|
90409
90400
|
})
|
|
90410
90401
|
);
|
|
90411
90402
|
const newManifest = generateManifest(newPathMap, contentHashes);
|
|
90412
90403
|
await atomicWriteNodeFs(manifestPath, JSON.stringify(newManifest, null, 2));
|
|
90413
90404
|
await atomicWriteNodeFs(`${projectDir}/project.galacean`, JSON.stringify(ctx.config, null, 2));
|
|
90414
90405
|
}
|
|
90415
|
-
var
|
|
90406
|
+
var import_promises10;
|
|
90416
90407
|
var init_save = __esm({
|
|
90417
90408
|
"src/domain-bridge/save.ts"() {
|
|
90418
90409
|
"use strict";
|
|
90419
|
-
|
|
90410
|
+
import_promises10 = __toESM(require("node:fs/promises"));
|
|
90420
90411
|
init_hash();
|
|
90421
90412
|
init_manifest();
|
|
90422
90413
|
init_meta_file();
|
|
@@ -90517,12 +90508,12 @@ function toBlobArrayBuffer(bytes) {
|
|
|
90517
90508
|
return copy2.buffer;
|
|
90518
90509
|
}
|
|
90519
90510
|
function normalizePathForComparison(filePath) {
|
|
90520
|
-
const normalized =
|
|
90511
|
+
const normalized = import_node_path13.default.resolve(filePath);
|
|
90521
90512
|
return process.platform === "linux" ? normalized : normalized.toLowerCase();
|
|
90522
90513
|
}
|
|
90523
90514
|
function isSameOrNestedPath(targetPath, basePath) {
|
|
90524
|
-
const relative5 =
|
|
90525
|
-
return relative5 === "" || !relative5.startsWith("..") && !
|
|
90515
|
+
const relative5 = import_node_path13.default.relative(basePath, targetPath);
|
|
90516
|
+
return relative5 === "" || !relative5.startsWith("..") && !import_node_path13.default.isAbsolute(relative5);
|
|
90526
90517
|
}
|
|
90527
90518
|
function assertSafeBuildOutputDir(projectDir, outputDir) {
|
|
90528
90519
|
const normalizedProjectDir = normalizePathForComparison(projectDir);
|
|
@@ -90533,7 +90524,7 @@ function assertSafeBuildOutputDir(projectDir, outputDir) {
|
|
|
90533
90524
|
);
|
|
90534
90525
|
}
|
|
90535
90526
|
for (const managedPath of MANAGED_PROJECT_PATHS) {
|
|
90536
|
-
const normalizedManagedPath = normalizePathForComparison(
|
|
90527
|
+
const normalizedManagedPath = normalizePathForComparison(import_node_path13.default.join(projectDir, managedPath));
|
|
90537
90528
|
const overlapsManagedPath = managedPath === "project.galacean" ? normalizedOutputDir === normalizedManagedPath : isSameOrNestedPath(normalizedOutputDir, normalizedManagedPath);
|
|
90538
90529
|
if (overlapsManagedPath) {
|
|
90539
90530
|
throw new Error(
|
|
@@ -90543,8 +90534,8 @@ function assertSafeBuildOutputDir(projectDir, outputDir) {
|
|
|
90543
90534
|
}
|
|
90544
90535
|
}
|
|
90545
90536
|
async function buildProject(options) {
|
|
90546
|
-
const projectDir =
|
|
90547
|
-
const outputDir =
|
|
90537
|
+
const projectDir = import_node_path13.default.resolve(options.projectDir);
|
|
90538
|
+
const outputDir = import_node_path13.default.resolve(options.output);
|
|
90548
90539
|
assertSafeBuildOutputDir(projectDir, outputDir);
|
|
90549
90540
|
console.log("Reading project...");
|
|
90550
90541
|
const { state, ctx } = await loadDomainState(projectDir);
|
|
@@ -90602,13 +90593,13 @@ function buildProjectAssets(manifest, projectDir) {
|
|
|
90602
90593
|
for (const [id, e] of Object.entries(entries)) {
|
|
90603
90594
|
if (e.type === "Folder") folderPathToId.set(e.path, id);
|
|
90604
90595
|
}
|
|
90605
|
-
for (const [assetId,
|
|
90596
|
+
for (const [assetId, entry2] of Object.entries(entries)) {
|
|
90606
90597
|
let meta3;
|
|
90607
|
-
const inlineMeta =
|
|
90598
|
+
const inlineMeta = entry2.meta;
|
|
90608
90599
|
if (inlineMeta && typeof inlineMeta === "object") {
|
|
90609
90600
|
meta3 = inlineMeta;
|
|
90610
90601
|
} else {
|
|
90611
|
-
const metaPath =
|
|
90602
|
+
const metaPath = import_node_path13.default.join(projectDir, metaFilePath(entry2.path));
|
|
90612
90603
|
let metaText;
|
|
90613
90604
|
try {
|
|
90614
90605
|
metaText = import_node_fs2.default.readFileSync(metaPath, "utf-8");
|
|
@@ -90616,7 +90607,7 @@ function buildProjectAssets(manifest, projectDir) {
|
|
|
90616
90607
|
console.warn(`[buildProjectAssets] Failed to read meta file: ${metaPath}`, e);
|
|
90617
90608
|
skippedAssets.push({
|
|
90618
90609
|
assetId,
|
|
90619
|
-
path:
|
|
90610
|
+
path: entry2.path,
|
|
90620
90611
|
reason: `failed to read meta file: ${e instanceof Error ? e.message : String(e)}`
|
|
90621
90612
|
});
|
|
90622
90613
|
continue;
|
|
@@ -90627,28 +90618,28 @@ function buildProjectAssets(manifest, projectDir) {
|
|
|
90627
90618
|
console.warn(`[buildProjectAssets] Failed to parse meta JSON: ${metaPath}`, e);
|
|
90628
90619
|
skippedAssets.push({
|
|
90629
90620
|
assetId,
|
|
90630
|
-
path:
|
|
90621
|
+
path: entry2.path,
|
|
90631
90622
|
reason: `failed to parse meta JSON: ${e instanceof Error ? e.message : String(e)}`
|
|
90632
90623
|
});
|
|
90633
90624
|
continue;
|
|
90634
90625
|
}
|
|
90635
90626
|
}
|
|
90636
90627
|
metaMap.set(assetId, meta3);
|
|
90637
|
-
const parts =
|
|
90628
|
+
const parts = entry2.path.split("/");
|
|
90638
90629
|
const fileName = parts[parts.length - 1];
|
|
90639
|
-
const ext = TYPE_EXTENSION[
|
|
90630
|
+
const ext = TYPE_EXTENSION[entry2.type];
|
|
90640
90631
|
const name = ext && fileName.endsWith(ext) ? fileName.slice(0, -ext.length) : fileName;
|
|
90641
90632
|
let parentId = null;
|
|
90642
90633
|
if (parts.length > 2) {
|
|
90643
90634
|
parentId = folderPathToId.get(parts.slice(0, -1).join("/")) ?? null;
|
|
90644
90635
|
}
|
|
90645
|
-
const isFolder =
|
|
90646
|
-
const filePath =
|
|
90636
|
+
const isFolder = entry2.type === "Folder";
|
|
90637
|
+
const filePath = import_node_path13.default.join(projectDir, entry2.path);
|
|
90647
90638
|
const fileUrl = !isFolder && import_node_fs2.default.existsSync(filePath) ? `file://${filePath}` : (
|
|
90648
90639
|
// Non-http URLs are treated as local/non-materialized inputs and will be validated later in compile.
|
|
90649
|
-
!isFolder && isHttpUrl(
|
|
90640
|
+
!isFolder && isHttpUrl(entry2.url) ? entry2.url : isFolder ? "" : `file://${filePath}`
|
|
90650
90641
|
);
|
|
90651
|
-
const serverId = typeof meta3.serverId === "string" && meta3.serverId.length > 0 ? meta3.serverId : typeof
|
|
90642
|
+
const serverId = typeof meta3.serverId === "string" && meta3.serverId.length > 0 ? meta3.serverId : typeof entry2.serverId === "string" && entry2.serverId.length > 0 ? entry2.serverId : `local-${assetId}`;
|
|
90652
90643
|
assets.push({
|
|
90653
90644
|
id: serverId,
|
|
90654
90645
|
uuid: assetId,
|
|
@@ -90698,7 +90689,7 @@ async function cliCompile(vfs, config2, options) {
|
|
|
90698
90689
|
if (url2?.startsWith("file://")) {
|
|
90699
90690
|
const filePath = url2.slice(7);
|
|
90700
90691
|
try {
|
|
90701
|
-
const buf = await
|
|
90692
|
+
const buf = await import_promises11.default.readFile(filePath);
|
|
90702
90693
|
content = TEXT_ASSET_TYPES.has(type) ? buf.toString("utf-8") : new Blob([buf]);
|
|
90703
90694
|
} catch (e) {
|
|
90704
90695
|
console.warn(`[cliCompile] Failed to read asset file: ${filePath}`, e);
|
|
@@ -90873,33 +90864,33 @@ function createSkippedAssetsError(skippedAssets) {
|
|
|
90873
90864
|
${details}`);
|
|
90874
90865
|
}
|
|
90875
90866
|
async function writeOutputToDisk(vfs, outputDir) {
|
|
90876
|
-
await
|
|
90877
|
-
await
|
|
90867
|
+
await import_promises11.default.rm(outputDir, { recursive: true, force: true });
|
|
90868
|
+
await import_promises11.default.mkdir(outputDir, { recursive: true });
|
|
90878
90869
|
const writes = [];
|
|
90879
90870
|
for (const [vfsPath, vfile] of vfs.filePathMap) {
|
|
90880
90871
|
if (vfile.type === "Folder" || vfile.type === 1) continue;
|
|
90881
90872
|
const content = vfile.content;
|
|
90882
90873
|
if (content == null) continue;
|
|
90883
|
-
const outputPath =
|
|
90874
|
+
const outputPath = import_node_path13.default.join(outputDir, vfsPath);
|
|
90884
90875
|
writes.push(
|
|
90885
|
-
|
|
90876
|
+
import_promises11.default.mkdir(import_node_path13.default.dirname(outputPath), { recursive: true }).then(async () => {
|
|
90886
90877
|
if (content instanceof Blob) {
|
|
90887
|
-
await
|
|
90878
|
+
await import_promises11.default.writeFile(outputPath, Buffer.from(await content.arrayBuffer()));
|
|
90888
90879
|
} else {
|
|
90889
|
-
await
|
|
90880
|
+
await import_promises11.default.writeFile(outputPath, content, "utf-8");
|
|
90890
90881
|
}
|
|
90891
90882
|
})
|
|
90892
90883
|
);
|
|
90893
90884
|
}
|
|
90894
90885
|
await Promise.all(writes);
|
|
90895
90886
|
}
|
|
90896
|
-
var
|
|
90887
|
+
var import_promises11, import_node_fs2, import_node_path13, import_js_md52;
|
|
90897
90888
|
var init_cli_builder = __esm({
|
|
90898
90889
|
"src/cli-builder.ts"() {
|
|
90899
90890
|
"use strict";
|
|
90900
|
-
|
|
90891
|
+
import_promises11 = __toESM(require("node:fs/promises"));
|
|
90901
90892
|
import_node_fs2 = __toESM(require("node:fs"));
|
|
90902
|
-
|
|
90893
|
+
import_node_path13 = __toESM(require("node:path"));
|
|
90903
90894
|
import_js_md52 = __toESM(require_md52());
|
|
90904
90895
|
init_src();
|
|
90905
90896
|
init_meta_file();
|
|
@@ -101820,42 +101811,42 @@ function extractDefs(ctx, schema) {
|
|
|
101820
101811
|
if (!root2)
|
|
101821
101812
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
101822
101813
|
const idToSchema = /* @__PURE__ */ new Map();
|
|
101823
|
-
for (const
|
|
101824
|
-
const id = ctx.metadataRegistry.get(
|
|
101814
|
+
for (const entry2 of ctx.seen.entries()) {
|
|
101815
|
+
const id = ctx.metadataRegistry.get(entry2[0])?.id;
|
|
101825
101816
|
if (id) {
|
|
101826
101817
|
const existing = idToSchema.get(id);
|
|
101827
|
-
if (existing && existing !==
|
|
101818
|
+
if (existing && existing !== entry2[0]) {
|
|
101828
101819
|
throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
101829
101820
|
}
|
|
101830
|
-
idToSchema.set(id,
|
|
101821
|
+
idToSchema.set(id, entry2[0]);
|
|
101831
101822
|
}
|
|
101832
101823
|
}
|
|
101833
|
-
const makeURI = (
|
|
101824
|
+
const makeURI = (entry2) => {
|
|
101834
101825
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
101835
101826
|
if (ctx.external) {
|
|
101836
|
-
const externalId = ctx.external.registry.get(
|
|
101827
|
+
const externalId = ctx.external.registry.get(entry2[0])?.id;
|
|
101837
101828
|
const uriGenerator = ctx.external.uri ?? ((id2) => id2);
|
|
101838
101829
|
if (externalId) {
|
|
101839
101830
|
return { ref: uriGenerator(externalId) };
|
|
101840
101831
|
}
|
|
101841
|
-
const id =
|
|
101842
|
-
|
|
101832
|
+
const id = entry2[1].defId ?? entry2[1].schema.id ?? `schema${ctx.counter++}`;
|
|
101833
|
+
entry2[1].defId = id;
|
|
101843
101834
|
return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
|
|
101844
101835
|
}
|
|
101845
|
-
if (
|
|
101836
|
+
if (entry2[1] === root2) {
|
|
101846
101837
|
return { ref: "#" };
|
|
101847
101838
|
}
|
|
101848
101839
|
const uriPrefix = `#`;
|
|
101849
101840
|
const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
|
|
101850
|
-
const defId =
|
|
101841
|
+
const defId = entry2[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
101851
101842
|
return { defId, ref: defUriPrefix + defId };
|
|
101852
101843
|
};
|
|
101853
|
-
const extractToDef = (
|
|
101854
|
-
if (
|
|
101844
|
+
const extractToDef = (entry2) => {
|
|
101845
|
+
if (entry2[1].schema.$ref) {
|
|
101855
101846
|
return;
|
|
101856
101847
|
}
|
|
101857
|
-
const seen =
|
|
101858
|
-
const { ref, defId } = makeURI(
|
|
101848
|
+
const seen = entry2[1];
|
|
101849
|
+
const { ref, defId } = makeURI(entry2);
|
|
101859
101850
|
seen.def = { ...seen.schema };
|
|
101860
101851
|
if (defId)
|
|
101861
101852
|
seen.defId = defId;
|
|
@@ -101866,8 +101857,8 @@ function extractDefs(ctx, schema) {
|
|
|
101866
101857
|
schema2.$ref = ref;
|
|
101867
101858
|
};
|
|
101868
101859
|
if (ctx.cycles === "throw") {
|
|
101869
|
-
for (const
|
|
101870
|
-
const seen =
|
|
101860
|
+
for (const entry2 of ctx.seen.entries()) {
|
|
101861
|
+
const seen = entry2[1];
|
|
101871
101862
|
if (seen.cycle) {
|
|
101872
101863
|
throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
101873
101864
|
|
|
@@ -101875,31 +101866,31 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
101875
101866
|
}
|
|
101876
101867
|
}
|
|
101877
101868
|
}
|
|
101878
|
-
for (const
|
|
101879
|
-
const seen =
|
|
101880
|
-
if (schema ===
|
|
101881
|
-
extractToDef(
|
|
101869
|
+
for (const entry2 of ctx.seen.entries()) {
|
|
101870
|
+
const seen = entry2[1];
|
|
101871
|
+
if (schema === entry2[0]) {
|
|
101872
|
+
extractToDef(entry2);
|
|
101882
101873
|
continue;
|
|
101883
101874
|
}
|
|
101884
101875
|
if (ctx.external) {
|
|
101885
|
-
const ext = ctx.external.registry.get(
|
|
101886
|
-
if (schema !==
|
|
101887
|
-
extractToDef(
|
|
101876
|
+
const ext = ctx.external.registry.get(entry2[0])?.id;
|
|
101877
|
+
if (schema !== entry2[0] && ext) {
|
|
101878
|
+
extractToDef(entry2);
|
|
101888
101879
|
continue;
|
|
101889
101880
|
}
|
|
101890
101881
|
}
|
|
101891
|
-
const id = ctx.metadataRegistry.get(
|
|
101882
|
+
const id = ctx.metadataRegistry.get(entry2[0])?.id;
|
|
101892
101883
|
if (id) {
|
|
101893
|
-
extractToDef(
|
|
101884
|
+
extractToDef(entry2);
|
|
101894
101885
|
continue;
|
|
101895
101886
|
}
|
|
101896
101887
|
if (seen.cycle) {
|
|
101897
|
-
extractToDef(
|
|
101888
|
+
extractToDef(entry2);
|
|
101898
101889
|
continue;
|
|
101899
101890
|
}
|
|
101900
101891
|
if (seen.count > 1) {
|
|
101901
101892
|
if (ctx.reused === "ref") {
|
|
101902
|
-
extractToDef(
|
|
101893
|
+
extractToDef(entry2);
|
|
101903
101894
|
continue;
|
|
101904
101895
|
}
|
|
101905
101896
|
}
|
|
@@ -101971,8 +101962,8 @@ function finalize(ctx, schema) {
|
|
|
101971
101962
|
path: seen.path ?? []
|
|
101972
101963
|
});
|
|
101973
101964
|
};
|
|
101974
|
-
for (const
|
|
101975
|
-
flattenRef(
|
|
101965
|
+
for (const entry2 of [...ctx.seen.entries()].reverse()) {
|
|
101966
|
+
flattenRef(entry2[0]);
|
|
101976
101967
|
}
|
|
101977
101968
|
const result = {};
|
|
101978
101969
|
if (ctx.target === "draft-2020-12") {
|
|
@@ -101992,8 +101983,8 @@ function finalize(ctx, schema) {
|
|
|
101992
101983
|
}
|
|
101993
101984
|
Object.assign(result, root2.def ?? root2.schema);
|
|
101994
101985
|
const defs = ctx.external?.defs ?? {};
|
|
101995
|
-
for (const
|
|
101996
|
-
const seen =
|
|
101986
|
+
for (const entry2 of ctx.seen.entries()) {
|
|
101987
|
+
const seen = entry2[1];
|
|
101997
101988
|
if (seen.def && seen.defId) {
|
|
101998
101989
|
defs[seen.defId] = seen.def;
|
|
101999
101990
|
}
|
|
@@ -102103,8 +102094,8 @@ function toJSONSchema(input, params) {
|
|
|
102103
102094
|
const registry2 = input;
|
|
102104
102095
|
const ctx2 = initializeContext({ ...params, processors: allProcessors });
|
|
102105
102096
|
const defs = {};
|
|
102106
|
-
for (const
|
|
102107
|
-
const [_24, schema] =
|
|
102097
|
+
for (const entry2 of registry2._idmap.entries()) {
|
|
102098
|
+
const [_24, schema] = entry2;
|
|
102108
102099
|
process3(schema, ctx2);
|
|
102109
102100
|
}
|
|
102110
102101
|
const schemas = {};
|
|
@@ -102114,8 +102105,8 @@ function toJSONSchema(input, params) {
|
|
|
102114
102105
|
defs
|
|
102115
102106
|
};
|
|
102116
102107
|
ctx2.external = external;
|
|
102117
|
-
for (const
|
|
102118
|
-
const [key, schema] =
|
|
102108
|
+
for (const entry2 of registry2._idmap.entries()) {
|
|
102109
|
+
const [key, schema] = entry2;
|
|
102119
102110
|
extractDefs(ctx2, schema);
|
|
102120
102111
|
schemas[key] = finalize(ctx2, schema);
|
|
102121
102112
|
}
|
|
@@ -117574,16 +117565,16 @@ var require_BufferList = __commonJS({
|
|
|
117574
117565
|
this.length = 0;
|
|
117575
117566
|
}
|
|
117576
117567
|
BufferList.prototype.push = function push(v) {
|
|
117577
|
-
var
|
|
117578
|
-
if (this.length > 0) this.tail.next =
|
|
117579
|
-
else this.head =
|
|
117580
|
-
this.tail =
|
|
117568
|
+
var entry2 = { data: v, next: null };
|
|
117569
|
+
if (this.length > 0) this.tail.next = entry2;
|
|
117570
|
+
else this.head = entry2;
|
|
117571
|
+
this.tail = entry2;
|
|
117581
117572
|
++this.length;
|
|
117582
117573
|
};
|
|
117583
117574
|
BufferList.prototype.unshift = function unshift(v) {
|
|
117584
|
-
var
|
|
117585
|
-
if (this.length === 0) this.tail =
|
|
117586
|
-
this.head =
|
|
117575
|
+
var entry2 = { data: v, next: this.head };
|
|
117576
|
+
if (this.length === 0) this.tail = entry2;
|
|
117577
|
+
this.head = entry2;
|
|
117587
117578
|
++this.length;
|
|
117588
117579
|
};
|
|
117589
117580
|
BufferList.prototype.shift = function shift() {
|
|
@@ -118001,18 +117992,18 @@ var require_stream_writable = __commonJS({
|
|
|
118001
117992
|
}
|
|
118002
117993
|
function clearBuffer(stream, state) {
|
|
118003
117994
|
state.bufferProcessing = true;
|
|
118004
|
-
var
|
|
118005
|
-
if (stream._writev &&
|
|
117995
|
+
var entry2 = state.bufferedRequest;
|
|
117996
|
+
if (stream._writev && entry2 && entry2.next) {
|
|
118006
117997
|
var l = state.bufferedRequestCount;
|
|
118007
117998
|
var buffer2 = new Array(l);
|
|
118008
117999
|
var holder = state.corkedRequestsFree;
|
|
118009
|
-
holder.entry =
|
|
118000
|
+
holder.entry = entry2;
|
|
118010
118001
|
var count = 0;
|
|
118011
118002
|
var allBuffers = true;
|
|
118012
|
-
while (
|
|
118013
|
-
buffer2[count] =
|
|
118014
|
-
if (!
|
|
118015
|
-
|
|
118003
|
+
while (entry2) {
|
|
118004
|
+
buffer2[count] = entry2;
|
|
118005
|
+
if (!entry2.isBuf) allBuffers = false;
|
|
118006
|
+
entry2 = entry2.next;
|
|
118016
118007
|
count += 1;
|
|
118017
118008
|
}
|
|
118018
118009
|
buffer2.allBuffers = allBuffers;
|
|
@@ -118027,21 +118018,21 @@ var require_stream_writable = __commonJS({
|
|
|
118027
118018
|
}
|
|
118028
118019
|
state.bufferedRequestCount = 0;
|
|
118029
118020
|
} else {
|
|
118030
|
-
while (
|
|
118031
|
-
var chunk =
|
|
118032
|
-
var encoding =
|
|
118033
|
-
var cb =
|
|
118021
|
+
while (entry2) {
|
|
118022
|
+
var chunk = entry2.chunk;
|
|
118023
|
+
var encoding = entry2.encoding;
|
|
118024
|
+
var cb = entry2.callback;
|
|
118034
118025
|
var len = state.objectMode ? 1 : chunk.length;
|
|
118035
118026
|
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
118036
|
-
|
|
118027
|
+
entry2 = entry2.next;
|
|
118037
118028
|
state.bufferedRequestCount--;
|
|
118038
118029
|
if (state.writing) {
|
|
118039
118030
|
break;
|
|
118040
118031
|
}
|
|
118041
118032
|
}
|
|
118042
|
-
if (
|
|
118033
|
+
if (entry2 === null) state.lastBufferedRequest = null;
|
|
118043
118034
|
}
|
|
118044
|
-
state.bufferedRequest =
|
|
118035
|
+
state.bufferedRequest = entry2;
|
|
118045
118036
|
state.bufferProcessing = false;
|
|
118046
118037
|
}
|
|
118047
118038
|
Writable.prototype._write = function(chunk, encoding, cb) {
|
|
@@ -118113,13 +118104,13 @@ var require_stream_writable = __commonJS({
|
|
|
118113
118104
|
stream.writable = false;
|
|
118114
118105
|
}
|
|
118115
118106
|
function onCorkedFinish(corkReq, state, err) {
|
|
118116
|
-
var
|
|
118107
|
+
var entry2 = corkReq.entry;
|
|
118117
118108
|
corkReq.entry = null;
|
|
118118
|
-
while (
|
|
118119
|
-
var cb =
|
|
118109
|
+
while (entry2) {
|
|
118110
|
+
var cb = entry2.callback;
|
|
118120
118111
|
state.pendingcb--;
|
|
118121
118112
|
cb(err);
|
|
118122
|
-
|
|
118113
|
+
entry2 = entry2.next;
|
|
118123
118114
|
}
|
|
118124
118115
|
state.corkedRequestsFree.next = corkReq;
|
|
118125
118116
|
}
|
|
@@ -125962,9 +125953,9 @@ var require_object = __commonJS({
|
|
|
125962
125953
|
*/
|
|
125963
125954
|
filter: function(search) {
|
|
125964
125955
|
var result = [];
|
|
125965
|
-
this.forEach(function(relativePath2,
|
|
125966
|
-
if (search(relativePath2,
|
|
125967
|
-
result.push(
|
|
125956
|
+
this.forEach(function(relativePath2, entry2) {
|
|
125957
|
+
if (search(relativePath2, entry2)) {
|
|
125958
|
+
result.push(entry2);
|
|
125968
125959
|
}
|
|
125969
125960
|
});
|
|
125970
125961
|
return result;
|
|
@@ -127005,24 +126996,24 @@ var init_import = __esm({
|
|
|
127005
126996
|
const manifest = parseResult.data;
|
|
127006
126997
|
const isCdnMode = manifest.mode === "cdn";
|
|
127007
126998
|
const files = /* @__PURE__ */ new Map();
|
|
127008
|
-
for (const
|
|
127009
|
-
const metaFile = zip.file(
|
|
126999
|
+
for (const entry2 of manifest.assets) {
|
|
127000
|
+
const metaFile = zip.file(entry2.metaFile);
|
|
127010
127001
|
if (!metaFile) {
|
|
127011
|
-
throw new EditorAPIError("OPERATION_FAILED", `Missing metadata for asset: ${
|
|
127002
|
+
throw new EditorAPIError("OPERATION_FAILED", `Missing metadata for asset: ${entry2.name} (${entry2.metaFile})`);
|
|
127012
127003
|
}
|
|
127013
127004
|
const meta3 = JSON.parse(await metaFile.async("text"));
|
|
127014
127005
|
if (isCdnMode) {
|
|
127015
|
-
files.set(
|
|
127006
|
+
files.set(entry2.uuid, { main: new Blob([]), meta: meta3 });
|
|
127016
127007
|
} else {
|
|
127017
|
-
const mainFile = zip.file(
|
|
127008
|
+
const mainFile = zip.file(entry2.mainFile);
|
|
127018
127009
|
if (!mainFile) {
|
|
127019
127010
|
throw new EditorAPIError(
|
|
127020
127011
|
"OPERATION_FAILED",
|
|
127021
|
-
`Missing main file for asset: ${
|
|
127012
|
+
`Missing main file for asset: ${entry2.name} (${entry2.mainFile})`
|
|
127022
127013
|
);
|
|
127023
127014
|
}
|
|
127024
|
-
const
|
|
127025
|
-
files.set(
|
|
127015
|
+
const main2 = await mainFile.async("blob");
|
|
127016
|
+
files.set(entry2.uuid, { main: main2, meta: meta3 });
|
|
127026
127017
|
}
|
|
127027
127018
|
}
|
|
127028
127019
|
const result = await assetFacade.importResourcePackageData(manifest, files, {
|
|
@@ -129827,9 +129818,9 @@ var init_ContextQuery = __esm({
|
|
|
129827
129818
|
}
|
|
129828
129819
|
return null;
|
|
129829
129820
|
}
|
|
129830
|
-
const
|
|
129831
|
-
if (!
|
|
129832
|
-
return deepClone2({ id:
|
|
129821
|
+
const entry2 = Object.entries(entity.components).find(([, c]) => types.includes(c.type));
|
|
129822
|
+
if (!entry2) return null;
|
|
129823
|
+
return deepClone2({ id: entry2[0], ...entry2[1] });
|
|
129833
129824
|
}
|
|
129834
129825
|
/**
|
|
129835
129826
|
* 收集实体及其所有后代 ID(含自身),迭代实现。
|
|
@@ -130104,7 +130095,7 @@ var init_EditorCoreAPI = __esm({
|
|
|
130104
130095
|
|
|
130105
130096
|
// src/cli.ts
|
|
130106
130097
|
var import_node_os2 = __toESM(require("node:os"));
|
|
130107
|
-
var
|
|
130098
|
+
var import_node_path17 = __toESM(require("node:path"));
|
|
130108
130099
|
var import_node_process2 = __toESM(require("node:process"));
|
|
130109
130100
|
|
|
130110
130101
|
// node_modules/commander/esm.mjs
|
|
@@ -130142,7 +130133,7 @@ var NodeFs = class {
|
|
|
130142
130133
|
}
|
|
130143
130134
|
async readdir(p) {
|
|
130144
130135
|
const entries = await (0, import_promises.readdir)(p, { withFileTypes: true });
|
|
130145
|
-
return entries.map((
|
|
130136
|
+
return entries.map((entry2) => ({ name: entry2.name, kind: entry2.isDirectory() ? "directory" : "file" }));
|
|
130146
130137
|
}
|
|
130147
130138
|
async remove(p) {
|
|
130148
130139
|
await (0, import_promises.rm)(p, { recursive: true, force: true });
|
|
@@ -130714,23 +130705,23 @@ init_hash();
|
|
|
130714
130705
|
|
|
130715
130706
|
// ../storage/src/project-writer.ts
|
|
130716
130707
|
init_meta_file();
|
|
130717
|
-
async function writeProject(
|
|
130708
|
+
async function writeProject(fs5, root2, opts) {
|
|
130718
130709
|
const { pathMap, manifest, remoteConfig, projectConfig, metaFiles, contents } = opts;
|
|
130719
|
-
await
|
|
130720
|
-
await
|
|
130721
|
-
await
|
|
130722
|
-
await
|
|
130723
|
-
await
|
|
130724
|
-
for (const [,
|
|
130725
|
-
if (
|
|
130726
|
-
}
|
|
130727
|
-
for (const [assetId,
|
|
130728
|
-
if (!
|
|
130710
|
+
await fs5.mkdir(`${root2}/.galacean`);
|
|
130711
|
+
await fs5.mkdir(`${root2}/.galacean/cache`);
|
|
130712
|
+
await fs5.writeFile(`${root2}/.galacean/manifest.json`, JSON.stringify(manifest, null, 2));
|
|
130713
|
+
await fs5.writeFile(`${root2}/.galacean/remote.json`, JSON.stringify(remoteConfig, null, 2));
|
|
130714
|
+
await fs5.writeFile(`${root2}/project.galacean`, JSON.stringify(projectConfig, null, 2));
|
|
130715
|
+
for (const [, entry2] of pathMap) {
|
|
130716
|
+
if (entry2.isFolder) await fs5.mkdir(`${root2}/${entry2.localPath}`);
|
|
130717
|
+
}
|
|
130718
|
+
for (const [assetId, entry2] of pathMap) {
|
|
130719
|
+
if (!entry2.isFolder) {
|
|
130729
130720
|
const content = contents.get(assetId);
|
|
130730
|
-
if (content) await
|
|
130721
|
+
if (content) await fs5.writeFile(`${root2}/${entry2.localPath}`, content);
|
|
130731
130722
|
}
|
|
130732
130723
|
const meta3 = metaFiles.get(assetId);
|
|
130733
|
-
if (meta3) await
|
|
130724
|
+
if (meta3) await fs5.writeFile(`${root2}/${metaFilePath(entry2.localPath)}`, JSON.stringify(meta3, null, 2));
|
|
130734
130725
|
}
|
|
130735
130726
|
}
|
|
130736
130727
|
|
|
@@ -130738,9 +130729,9 @@ async function writeProject(fs6, root2, opts) {
|
|
|
130738
130729
|
init_local_project();
|
|
130739
130730
|
init_utils();
|
|
130740
130731
|
async function initProject(opts) {
|
|
130741
|
-
const { projectId, outputDir, apiClient, fs:
|
|
130732
|
+
const { projectId, outputDir, apiClient, fs: fs5, serverUrl = "", force = false } = opts;
|
|
130742
130733
|
if (!force) {
|
|
130743
|
-
await assertDirectoryEmpty(
|
|
130734
|
+
await assertDirectoryEmpty(fs5, outputDir);
|
|
130744
130735
|
}
|
|
130745
130736
|
const project = await apiClient.fetchProject(projectId);
|
|
130746
130737
|
let sceneId = "";
|
|
@@ -130781,13 +130772,13 @@ async function initProject(opts) {
|
|
|
130781
130772
|
}
|
|
130782
130773
|
const manifest = generateManifest(pathMap, hashes);
|
|
130783
130774
|
const metaFiles = /* @__PURE__ */ new Map();
|
|
130784
|
-
for (const [id,
|
|
130785
|
-
metaFiles.set(id, generateMetaFile(
|
|
130775
|
+
for (const [id, entry2] of pathMap) {
|
|
130776
|
+
metaFiles.set(id, generateMetaFile(entry2));
|
|
130786
130777
|
}
|
|
130787
130778
|
if (force) {
|
|
130788
|
-
await resetManagedProjectPaths(
|
|
130779
|
+
await resetManagedProjectPaths(fs5, outputDir);
|
|
130789
130780
|
}
|
|
130790
|
-
await writeProject(
|
|
130781
|
+
await writeProject(fs5, outputDir, {
|
|
130791
130782
|
pathMap,
|
|
130792
130783
|
manifest,
|
|
130793
130784
|
remoteConfig: { projectId, serverUrl },
|
|
@@ -130813,9 +130804,9 @@ init_local_project();
|
|
|
130813
130804
|
init_path_case_guard();
|
|
130814
130805
|
init_utils();
|
|
130815
130806
|
var CONCURRENCY_LIMIT = 5;
|
|
130816
|
-
async function readManifest2(
|
|
130807
|
+
async function readManifest2(fs5, projectDir) {
|
|
130817
130808
|
const manifestPath = import_node_path5.default.resolve(projectDir, ".galacean/manifest.json");
|
|
130818
|
-
const raw = decodeUtf8(await
|
|
130809
|
+
const raw = decodeUtf8(await fs5.readFile(manifestPath));
|
|
130819
130810
|
let parsed;
|
|
130820
130811
|
try {
|
|
130821
130812
|
parsed = JSON.parse(raw);
|
|
@@ -130833,16 +130824,16 @@ function isPathUnderFolder(assetPath, folderPath) {
|
|
|
130833
130824
|
return normalizedAsset === normalizedFolder || normalizedAsset.startsWith(`${normalizedFolder}/`);
|
|
130834
130825
|
}
|
|
130835
130826
|
async function pullProject(opts) {
|
|
130836
|
-
const { projectDir, apiClient, fs:
|
|
130827
|
+
const { projectDir, apiClient, fs: fs5, signal, caseFoldGuards } = opts;
|
|
130837
130828
|
throwIfAborted(signal);
|
|
130838
|
-
const remote = await readRemoteConfig(
|
|
130839
|
-
const manifest = await readManifest2(
|
|
130829
|
+
const remote = await readRemoteConfig(fs5, projectDir);
|
|
130830
|
+
const manifest = await readManifest2(fs5, projectDir);
|
|
130840
130831
|
throwIfAborted(signal);
|
|
130841
130832
|
const project = await apiClient.fetchProject(remote.projectId, { signal });
|
|
130842
130833
|
const newPathMap = buildLocalPathMap(project.assets);
|
|
130843
130834
|
const useCaseFoldGuards = caseFoldGuards ?? await shouldUseCaseFoldGuards(projectDir);
|
|
130844
130835
|
if (useCaseFoldGuards) {
|
|
130845
|
-
const pathCollisions = findCaseFoldPathCollisions(Array.from(newPathMap.values(), (
|
|
130836
|
+
const pathCollisions = findCaseFoldPathCollisions(Array.from(newPathMap.values(), (entry2) => entry2.localPath));
|
|
130846
130837
|
if (pathCollisions.length > 0) {
|
|
130847
130838
|
const preview = formatConflictPreview(pathCollisions.map((item) => `${item.firstPath} <-> ${item.secondPath}`));
|
|
130848
130839
|
throw new Error(
|
|
@@ -130850,10 +130841,10 @@ async function pullProject(opts) {
|
|
|
130850
130841
|
);
|
|
130851
130842
|
}
|
|
130852
130843
|
}
|
|
130853
|
-
for (const [,
|
|
130854
|
-
if (!
|
|
130844
|
+
for (const [, entry2] of newPathMap) {
|
|
130845
|
+
if (!entry2.isFolder && entry2.url?.startsWith("data:")) {
|
|
130855
130846
|
throw new Error(
|
|
130856
|
-
`[pull] Unexpected data: URL for asset '${
|
|
130847
|
+
`[pull] Unexpected data: URL for asset '${entry2.assetId}' (path: ${entry2.localPath}). Server should return http(s) URLs; data: URLs indicate a server-side issue.`
|
|
130857
130848
|
);
|
|
130858
130849
|
}
|
|
130859
130850
|
}
|
|
@@ -130909,12 +130900,12 @@ async function pullProject(opts) {
|
|
|
130909
130900
|
const foldersToDelete = toDelete.filter((e) => e.type === "Folder").sort((a, b) => b.path.split("/").length - a.path.split("/").length);
|
|
130910
130901
|
for (const local of filesToDelete) {
|
|
130911
130902
|
try {
|
|
130912
|
-
await
|
|
130903
|
+
await fs5.remove(import_node_path5.default.resolve(projectDir, local.path));
|
|
130913
130904
|
} catch (err) {
|
|
130914
130905
|
if (!isEnoent(err)) throw err;
|
|
130915
130906
|
}
|
|
130916
130907
|
try {
|
|
130917
|
-
await
|
|
130908
|
+
await fs5.remove(import_node_path5.default.resolve(projectDir, metaFilePath(local.path)));
|
|
130918
130909
|
} catch (err) {
|
|
130919
130910
|
if (!isEnoent(err)) throw err;
|
|
130920
130911
|
}
|
|
@@ -130922,14 +130913,14 @@ async function pullProject(opts) {
|
|
|
130922
130913
|
}
|
|
130923
130914
|
const movedResult = [];
|
|
130924
130915
|
const pullWarnings = [];
|
|
130925
|
-
const fileMoves = toMove.filter(({ entry }) => !
|
|
130926
|
-
const folderMoves = toMove.filter(({ entry }) =>
|
|
130916
|
+
const fileMoves = toMove.filter(({ entry: entry2 }) => !entry2.isFolder);
|
|
130917
|
+
const folderMoves = toMove.filter(({ entry: entry2 }) => entry2.isFolder);
|
|
130927
130918
|
if (useCaseFoldGuards) {
|
|
130928
130919
|
const moveConflicts = findCaseFoldMoveConflicts(
|
|
130929
|
-
fileMoves.map(({ entry, oldPath }) => ({
|
|
130930
|
-
assetId:
|
|
130920
|
+
fileMoves.map(({ entry: entry2, oldPath }) => ({
|
|
130921
|
+
assetId: entry2.assetId,
|
|
130931
130922
|
oldPath,
|
|
130932
|
-
newPath:
|
|
130923
|
+
newPath: entry2.localPath
|
|
130933
130924
|
}))
|
|
130934
130925
|
);
|
|
130935
130926
|
if (moveConflicts.length > 0) {
|
|
@@ -130941,22 +130932,22 @@ async function pullProject(opts) {
|
|
|
130941
130932
|
}
|
|
130942
130933
|
const preparedFileMoves = [];
|
|
130943
130934
|
const skippedFileMoveSourcePathSet = /* @__PURE__ */ new Set();
|
|
130944
|
-
for (const { entry, oldPath } of fileMoves) {
|
|
130935
|
+
for (const { entry: entry2, oldPath } of fileMoves) {
|
|
130945
130936
|
const oldAbs = import_node_path5.default.resolve(projectDir, oldPath);
|
|
130946
|
-
const newAbs = import_node_path5.default.resolve(projectDir,
|
|
130937
|
+
const newAbs = import_node_path5.default.resolve(projectDir, entry2.localPath);
|
|
130947
130938
|
const isCaseOnlyRename = oldAbs.toLowerCase() === newAbs.toLowerCase() && oldAbs !== newAbs;
|
|
130948
130939
|
let content;
|
|
130949
130940
|
try {
|
|
130950
|
-
content = await
|
|
130941
|
+
content = await fs5.readFile(oldAbs);
|
|
130951
130942
|
} catch (err) {
|
|
130952
|
-
const warnMsg = `Skip move for ${oldPath} -> ${
|
|
130943
|
+
const warnMsg = `Skip move for ${oldPath} -> ${entry2.localPath}: failed to read source file`;
|
|
130953
130944
|
console.warn(`[pull] ${warnMsg}`, err);
|
|
130954
130945
|
pullWarnings.push(warnMsg);
|
|
130955
130946
|
skippedFileMoveSourcePathSet.add(normalizePath(oldPath));
|
|
130956
130947
|
continue;
|
|
130957
130948
|
}
|
|
130958
130949
|
preparedFileMoves.push({
|
|
130959
|
-
entry,
|
|
130950
|
+
entry: entry2,
|
|
130960
130951
|
oldPath,
|
|
130961
130952
|
oldAbs,
|
|
130962
130953
|
newAbs,
|
|
@@ -130977,41 +130968,41 @@ async function pullProject(opts) {
|
|
|
130977
130968
|
}
|
|
130978
130969
|
return !blockedByFolder;
|
|
130979
130970
|
});
|
|
130980
|
-
const activeFileMoveTargetPathSet = new Set(activeFileMoves.map(({ entry }) => normalizePath(
|
|
130971
|
+
const activeFileMoveTargetPathSet = new Set(activeFileMoves.map(({ entry: entry2 }) => normalizePath(entry2.localPath)));
|
|
130981
130972
|
for (const move of activeFileMoves) {
|
|
130982
|
-
const { entry, oldPath, oldAbs, newAbs, isCaseOnlyRename, content } = move;
|
|
130973
|
+
const { entry: entry2, oldPath, oldAbs, newAbs, isCaseOnlyRename, content } = move;
|
|
130983
130974
|
const parentDir = import_node_path5.default.dirname(newAbs);
|
|
130984
130975
|
try {
|
|
130985
|
-
await
|
|
130976
|
+
await fs5.mkdir(parentDir);
|
|
130986
130977
|
} catch {
|
|
130987
130978
|
}
|
|
130988
130979
|
if (isCaseOnlyRename) {
|
|
130989
130980
|
try {
|
|
130990
|
-
await
|
|
130981
|
+
await fs5.remove(oldAbs);
|
|
130991
130982
|
} catch (err) {
|
|
130992
130983
|
if (!isEnoent(err)) throw err;
|
|
130993
130984
|
}
|
|
130994
130985
|
try {
|
|
130995
|
-
await
|
|
130986
|
+
await fs5.remove(oldAbs + ".meta.json");
|
|
130996
130987
|
} catch (err) {
|
|
130997
130988
|
if (!isEnoent(err)) throw err;
|
|
130998
130989
|
}
|
|
130999
130990
|
}
|
|
131000
|
-
await
|
|
131001
|
-
await
|
|
131002
|
-
manifest.entries[
|
|
131003
|
-
assetId:
|
|
131004
|
-
path:
|
|
131005
|
-
type:
|
|
131006
|
-
contentHash: manifest.entries[
|
|
131007
|
-
remoteVersion:
|
|
131008
|
-
serverId:
|
|
131009
|
-
url:
|
|
130991
|
+
await fs5.writeFile(newAbs, content);
|
|
130992
|
+
await fs5.writeFile(newAbs + ".meta.json", JSON.stringify(generateMetaFile(entry2), null, 2));
|
|
130993
|
+
manifest.entries[entry2.assetId] = {
|
|
130994
|
+
assetId: entry2.assetId,
|
|
130995
|
+
path: entry2.localPath,
|
|
130996
|
+
type: entry2.metaType,
|
|
130997
|
+
contentHash: manifest.entries[entry2.assetId]?.contentHash ?? "",
|
|
130998
|
+
remoteVersion: entry2.meta.version ?? "",
|
|
130999
|
+
serverId: entry2.serverId,
|
|
131000
|
+
url: entry2.url
|
|
131010
131001
|
};
|
|
131011
131002
|
movedResult.push({
|
|
131012
|
-
assetId:
|
|
131003
|
+
assetId: entry2.assetId,
|
|
131013
131004
|
oldPath,
|
|
131014
|
-
path:
|
|
131005
|
+
path: entry2.localPath
|
|
131015
131006
|
});
|
|
131016
131007
|
}
|
|
131017
131008
|
for (const move of activeFileMoves) {
|
|
@@ -131021,142 +131012,142 @@ async function pullProject(opts) {
|
|
|
131021
131012
|
continue;
|
|
131022
131013
|
}
|
|
131023
131014
|
try {
|
|
131024
|
-
await
|
|
131015
|
+
await fs5.remove(oldAbs);
|
|
131025
131016
|
} catch (err) {
|
|
131026
131017
|
if (!isEnoent(err)) throw err;
|
|
131027
131018
|
}
|
|
131028
131019
|
try {
|
|
131029
|
-
await
|
|
131020
|
+
await fs5.remove(oldAbs + ".meta.json");
|
|
131030
131021
|
} catch (err) {
|
|
131031
131022
|
if (!isEnoent(err)) throw err;
|
|
131032
131023
|
}
|
|
131033
131024
|
}
|
|
131034
131025
|
const activeFolderMoveTargetPathSet = new Set(
|
|
131035
|
-
folderMoves.filter(({ oldPath }) => !blockedFolderMoveOldPathSet.has(normalizePath(oldPath))).map(({ entry }) => pathCompareKey(
|
|
131026
|
+
folderMoves.filter(({ oldPath }) => !blockedFolderMoveOldPathSet.has(normalizePath(oldPath))).map(({ entry: entry2 }) => pathCompareKey(entry2.localPath, useCaseFoldGuards))
|
|
131036
131027
|
);
|
|
131037
|
-
for (const { entry, oldPath } of folderMoves) {
|
|
131028
|
+
for (const { entry: entry2, oldPath } of folderMoves) {
|
|
131038
131029
|
const normalizedOldPath = normalizePath(oldPath);
|
|
131039
131030
|
if (blockedFolderMoveOldPathSet.has(normalizedOldPath)) {
|
|
131040
|
-
console.warn(`[pull] Skip folder move for ${oldPath} -> ${
|
|
131031
|
+
console.warn(`[pull] Skip folder move for ${oldPath} -> ${entry2.localPath}: child file move source read failed`);
|
|
131041
131032
|
continue;
|
|
131042
131033
|
}
|
|
131043
131034
|
const oldAbs = import_node_path5.default.resolve(projectDir, oldPath);
|
|
131044
|
-
const newAbs = import_node_path5.default.resolve(projectDir,
|
|
131035
|
+
const newAbs = import_node_path5.default.resolve(projectDir, entry2.localPath);
|
|
131045
131036
|
const isCaseOnlyRename = oldAbs.toLowerCase() === newAbs.toLowerCase() && oldAbs !== newAbs;
|
|
131046
131037
|
const oldPathReusedAsMoveTarget = activeFolderMoveTargetPathSet.has(pathCompareKey(oldPath, useCaseFoldGuards));
|
|
131047
131038
|
if (isCaseOnlyRename && useCaseFoldGuards) {
|
|
131048
|
-
if (
|
|
131049
|
-
await
|
|
131039
|
+
if (fs5.rename) {
|
|
131040
|
+
await fs5.rename(oldAbs, newAbs);
|
|
131050
131041
|
}
|
|
131051
131042
|
try {
|
|
131052
|
-
await
|
|
131043
|
+
await fs5.remove(oldAbs + ".meta.json");
|
|
131053
131044
|
} catch (err) {
|
|
131054
131045
|
if (!isEnoent(err)) throw err;
|
|
131055
131046
|
}
|
|
131056
131047
|
} else {
|
|
131057
131048
|
try {
|
|
131058
|
-
await
|
|
131049
|
+
await fs5.mkdir(newAbs);
|
|
131059
131050
|
} catch {
|
|
131060
131051
|
}
|
|
131061
131052
|
if (!oldPathReusedAsMoveTarget) {
|
|
131062
131053
|
try {
|
|
131063
|
-
await
|
|
131054
|
+
await fs5.remove(oldAbs);
|
|
131064
131055
|
} catch (err) {
|
|
131065
131056
|
if (!isEnoent(err)) throw err;
|
|
131066
131057
|
}
|
|
131067
131058
|
try {
|
|
131068
|
-
await
|
|
131059
|
+
await fs5.remove(oldAbs + ".meta.json");
|
|
131069
131060
|
} catch (err) {
|
|
131070
131061
|
if (!isEnoent(err)) throw err;
|
|
131071
131062
|
}
|
|
131072
131063
|
}
|
|
131073
131064
|
}
|
|
131074
|
-
await
|
|
131075
|
-
manifest.entries[
|
|
131076
|
-
assetId:
|
|
131077
|
-
path:
|
|
131078
|
-
type:
|
|
131079
|
-
contentHash: manifest.entries[
|
|
131080
|
-
remoteVersion:
|
|
131081
|
-
serverId:
|
|
131082
|
-
url:
|
|
131065
|
+
await fs5.writeFile(newAbs + ".meta.json", JSON.stringify(generateMetaFile(entry2), null, 2));
|
|
131066
|
+
manifest.entries[entry2.assetId] = {
|
|
131067
|
+
assetId: entry2.assetId,
|
|
131068
|
+
path: entry2.localPath,
|
|
131069
|
+
type: entry2.metaType,
|
|
131070
|
+
contentHash: manifest.entries[entry2.assetId]?.contentHash ?? "",
|
|
131071
|
+
remoteVersion: entry2.meta.version ?? "",
|
|
131072
|
+
serverId: entry2.serverId,
|
|
131073
|
+
url: entry2.url
|
|
131083
131074
|
};
|
|
131084
131075
|
movedResult.push({
|
|
131085
|
-
assetId:
|
|
131076
|
+
assetId: entry2.assetId,
|
|
131086
131077
|
oldPath,
|
|
131087
|
-
path:
|
|
131078
|
+
path: entry2.localPath
|
|
131088
131079
|
});
|
|
131089
131080
|
}
|
|
131090
131081
|
for (const local of foldersToDelete) {
|
|
131091
131082
|
try {
|
|
131092
|
-
await
|
|
131083
|
+
await fs5.remove(import_node_path5.default.resolve(projectDir, local.path));
|
|
131093
131084
|
} catch (err) {
|
|
131094
131085
|
if (!isEnoent(err)) throw err;
|
|
131095
131086
|
}
|
|
131096
131087
|
try {
|
|
131097
|
-
await
|
|
131088
|
+
await fs5.remove(import_node_path5.default.resolve(projectDir, metaFilePath(local.path)));
|
|
131098
131089
|
} catch (err) {
|
|
131099
131090
|
if (!isEnoent(err)) throw err;
|
|
131100
131091
|
}
|
|
131101
131092
|
delete manifest.entries[local.assetId];
|
|
131102
131093
|
}
|
|
131103
131094
|
const addedFolders = toAdd.filter((e) => e.isFolder).sort((a, b) => a.localPath.split("/").length - b.localPath.split("/").length);
|
|
131104
|
-
for (const
|
|
131105
|
-
await
|
|
131106
|
-
await
|
|
131107
|
-
import_node_path5.default.resolve(projectDir,
|
|
131108
|
-
JSON.stringify(generateMetaFile(
|
|
131095
|
+
for (const entry2 of addedFolders) {
|
|
131096
|
+
await fs5.mkdir(import_node_path5.default.resolve(projectDir, entry2.localPath));
|
|
131097
|
+
await fs5.writeFile(
|
|
131098
|
+
import_node_path5.default.resolve(projectDir, entry2.localPath) + ".meta.json",
|
|
131099
|
+
JSON.stringify(generateMetaFile(entry2), null, 2)
|
|
131109
131100
|
);
|
|
131110
|
-
manifest.entries[
|
|
131111
|
-
assetId:
|
|
131112
|
-
path:
|
|
131113
|
-
type:
|
|
131101
|
+
manifest.entries[entry2.assetId] = {
|
|
131102
|
+
assetId: entry2.assetId,
|
|
131103
|
+
path: entry2.localPath,
|
|
131104
|
+
type: entry2.metaType,
|
|
131114
131105
|
contentHash: "",
|
|
131115
|
-
remoteVersion:
|
|
131116
|
-
serverId:
|
|
131117
|
-
url:
|
|
131106
|
+
remoteVersion: entry2.meta.version ?? "",
|
|
131107
|
+
serverId: entry2.serverId,
|
|
131108
|
+
url: entry2.url
|
|
131118
131109
|
};
|
|
131119
131110
|
}
|
|
131120
131111
|
const addedResult = [];
|
|
131121
|
-
for (const
|
|
131122
|
-
const abs = import_node_path5.default.resolve(projectDir,
|
|
131123
|
-
const content = downloadedContent.get(
|
|
131124
|
-
if (content !== void 0) await
|
|
131125
|
-
await
|
|
131126
|
-
manifest.entries[
|
|
131127
|
-
assetId:
|
|
131128
|
-
path:
|
|
131129
|
-
type:
|
|
131130
|
-
contentHash: downloadedHash.get(
|
|
131131
|
-
remoteVersion:
|
|
131132
|
-
serverId:
|
|
131133
|
-
url:
|
|
131134
|
-
};
|
|
131135
|
-
addedResult.push({ assetId:
|
|
131112
|
+
for (const entry2 of toAdd.filter((e) => !e.isFolder)) {
|
|
131113
|
+
const abs = import_node_path5.default.resolve(projectDir, entry2.localPath);
|
|
131114
|
+
const content = downloadedContent.get(entry2.assetId);
|
|
131115
|
+
if (content !== void 0) await fs5.writeFile(abs, content);
|
|
131116
|
+
await fs5.writeFile(abs + ".meta.json", JSON.stringify(generateMetaFile(entry2), null, 2));
|
|
131117
|
+
manifest.entries[entry2.assetId] = {
|
|
131118
|
+
assetId: entry2.assetId,
|
|
131119
|
+
path: entry2.localPath,
|
|
131120
|
+
type: entry2.metaType,
|
|
131121
|
+
contentHash: downloadedHash.get(entry2.assetId) ?? "",
|
|
131122
|
+
remoteVersion: entry2.meta.version ?? "",
|
|
131123
|
+
serverId: entry2.serverId,
|
|
131124
|
+
url: entry2.url
|
|
131125
|
+
};
|
|
131126
|
+
addedResult.push({ assetId: entry2.assetId, path: entry2.localPath });
|
|
131136
131127
|
}
|
|
131137
131128
|
const updatedResult = [];
|
|
131138
|
-
for (const
|
|
131139
|
-
const abs = import_node_path5.default.resolve(projectDir,
|
|
131140
|
-
const content = downloadedContent.get(
|
|
131141
|
-
if (content !== void 0) await
|
|
131142
|
-
await
|
|
131143
|
-
manifest.entries[
|
|
131144
|
-
...manifest.entries[
|
|
131145
|
-
contentHash: downloadedHash.get(
|
|
131146
|
-
remoteVersion:
|
|
131147
|
-
serverId:
|
|
131148
|
-
url:
|
|
131149
|
-
};
|
|
131150
|
-
updatedResult.push({ assetId:
|
|
131151
|
-
}
|
|
131152
|
-
await atomicWriteFile(
|
|
131129
|
+
for (const entry2 of toUpdate) {
|
|
131130
|
+
const abs = import_node_path5.default.resolve(projectDir, entry2.localPath);
|
|
131131
|
+
const content = downloadedContent.get(entry2.assetId);
|
|
131132
|
+
if (content !== void 0) await fs5.writeFile(abs, content);
|
|
131133
|
+
await fs5.writeFile(abs + ".meta.json", JSON.stringify(generateMetaFile(entry2), null, 2));
|
|
131134
|
+
manifest.entries[entry2.assetId] = {
|
|
131135
|
+
...manifest.entries[entry2.assetId],
|
|
131136
|
+
contentHash: downloadedHash.get(entry2.assetId) ?? manifest.entries[entry2.assetId]?.contentHash ?? "",
|
|
131137
|
+
remoteVersion: entry2.meta.version ?? "",
|
|
131138
|
+
serverId: entry2.serverId,
|
|
131139
|
+
url: entry2.url
|
|
131140
|
+
};
|
|
131141
|
+
updatedResult.push({ assetId: entry2.assetId, path: entry2.localPath });
|
|
131142
|
+
}
|
|
131143
|
+
await atomicWriteFile(fs5, import_node_path5.default.resolve(projectDir, ".galacean/manifest.json"), JSON.stringify(manifest, null, 2));
|
|
131153
131144
|
let sceneId = "";
|
|
131154
131145
|
if (project.content && typeof project.content === "object") {
|
|
131155
131146
|
sceneId = project.content.scene ?? "";
|
|
131156
131147
|
}
|
|
131157
131148
|
const dependencies = extractProjectDependencies(project, "pull");
|
|
131158
131149
|
await atomicWriteFile(
|
|
131159
|
-
|
|
131150
|
+
fs5,
|
|
131160
131151
|
import_node_path5.default.resolve(projectDir, "project.galacean"),
|
|
131161
131152
|
JSON.stringify(
|
|
131162
131153
|
{
|
|
@@ -131764,7 +131755,7 @@ function areStringRecordEqual(a, b) {
|
|
|
131764
131755
|
}
|
|
131765
131756
|
function resolveProjectSceneId(projectConfig, manifest) {
|
|
131766
131757
|
const configuredSceneId = typeof projectConfig.sceneId === "string" ? projectConfig.sceneId : "";
|
|
131767
|
-
const sceneAssetIds = Object.entries(manifest.entries).filter(([,
|
|
131758
|
+
const sceneAssetIds = Object.entries(manifest.entries).filter(([, entry2]) => entry2.type === "Scene").map(([assetId]) => assetId);
|
|
131768
131759
|
if (configuredSceneId) {
|
|
131769
131760
|
if (manifest.entries[configuredSceneId]?.type === "Scene") return configuredSceneId;
|
|
131770
131761
|
if (Object.keys(manifest.entries).length === 0) return configuredSceneId;
|
|
@@ -131789,33 +131780,33 @@ function isPathInsideFolder(childPath, folderPath) {
|
|
|
131789
131780
|
const normalizedFolder = folderPath.replaceAll("\\", "/").replace(/\/+$/, "");
|
|
131790
131781
|
return normalizedChild.startsWith(`${normalizedFolder}/`);
|
|
131791
131782
|
}
|
|
131792
|
-
function shouldTreatMissingLocalFileAsDelete(
|
|
131793
|
-
if (!
|
|
131794
|
-
if (
|
|
131795
|
-
if (typeof
|
|
131783
|
+
function shouldTreatMissingLocalFileAsDelete(entry2) {
|
|
131784
|
+
if (!entry2.serverId || entry2.serverId.startsWith("local-")) return true;
|
|
131785
|
+
if (entry2.contentHash) return true;
|
|
131786
|
+
if (typeof entry2.url === "string" && entry2.url.length > 0) return false;
|
|
131796
131787
|
return true;
|
|
131797
131788
|
}
|
|
131798
131789
|
function hasMaterializedDescendant(manifestEntries, folderPath) {
|
|
131799
|
-
for (const
|
|
131800
|
-
if (!isPathInsideFolder(
|
|
131801
|
-
if (
|
|
131790
|
+
for (const entry2 of Object.values(manifestEntries)) {
|
|
131791
|
+
if (!isPathInsideFolder(entry2.path, folderPath)) continue;
|
|
131792
|
+
if (entry2.contentHash) return true;
|
|
131802
131793
|
}
|
|
131803
131794
|
return false;
|
|
131804
131795
|
}
|
|
131805
131796
|
function hasRemoteOnlyDescendant(manifestEntries, folderPath) {
|
|
131806
|
-
for (const
|
|
131807
|
-
if (
|
|
131808
|
-
if (!isPathInsideFolder(
|
|
131809
|
-
if (!shouldTreatMissingLocalFileAsDelete(
|
|
131797
|
+
for (const entry2 of Object.values(manifestEntries)) {
|
|
131798
|
+
if (entry2.type === "Folder") continue;
|
|
131799
|
+
if (!isPathInsideFolder(entry2.path, folderPath)) continue;
|
|
131800
|
+
if (!shouldTreatMissingLocalFileAsDelete(entry2)) return true;
|
|
131810
131801
|
}
|
|
131811
131802
|
return false;
|
|
131812
131803
|
}
|
|
131813
131804
|
|
|
131814
131805
|
// src/commands/push/io.ts
|
|
131815
|
-
async function assertNoCaseOnlyPathCoexistence(
|
|
131806
|
+
async function assertNoCaseOnlyPathCoexistence(fs5, projectDir, manifestEntries, localDirs, localFiles, manifestEntryByPath) {
|
|
131816
131807
|
const manifestByLowerPath = /* @__PURE__ */ new Map();
|
|
131817
|
-
for (const [assetId,
|
|
131818
|
-
const normalizedPath = normalizePath(
|
|
131808
|
+
for (const [assetId, entry2] of Object.entries(manifestEntries)) {
|
|
131809
|
+
const normalizedPath = normalizePath(entry2.path);
|
|
131819
131810
|
const lowerPath = normalizePathLower(normalizedPath);
|
|
131820
131811
|
const existing = manifestByLowerPath.get(lowerPath);
|
|
131821
131812
|
if (existing && existing.assetId !== assetId && existing.path !== normalizedPath) {
|
|
@@ -131823,7 +131814,7 @@ async function assertNoCaseOnlyPathCoexistence(fs6, projectDir, manifestEntries,
|
|
|
131823
131814
|
`[push] Manifest has case-colliding paths: '${existing.path}' and '${normalizedPath}'. Keep only one path and retry.`
|
|
131824
131815
|
);
|
|
131825
131816
|
}
|
|
131826
|
-
manifestByLowerPath.set(lowerPath, { assetId, path: normalizedPath, type:
|
|
131817
|
+
manifestByLowerPath.set(lowerPath, { assetId, path: normalizedPath, type: entry2.type });
|
|
131827
131818
|
}
|
|
131828
131819
|
const localDirSet = new Set(localDirs.map((p) => normalizePath(p)));
|
|
131829
131820
|
const localFileSet = new Set(localFiles.map((p) => normalizePath(p)));
|
|
@@ -131847,7 +131838,7 @@ async function assertNoCaseOnlyPathCoexistence(fs6, projectDir, manifestEntries,
|
|
|
131847
131838
|
continue;
|
|
131848
131839
|
}
|
|
131849
131840
|
if (localFileSet.has(localPath) && matched.type !== "Folder" && !localFileSet.has(matched.path)) {
|
|
131850
|
-
const localMeta = await readMetaFileIfExists(
|
|
131841
|
+
const localMeta = await readMetaFileIfExists(fs5, import_node_path7.default.resolve(projectDir, localPath)) ?? {};
|
|
131851
131842
|
const persistedId = resolvePersistedId(localMeta);
|
|
131852
131843
|
if (persistedId && persistedId === matched.assetId) {
|
|
131853
131844
|
continue;
|
|
@@ -131858,10 +131849,10 @@ async function assertNoCaseOnlyPathCoexistence(fs6, projectDir, manifestEntries,
|
|
|
131858
131849
|
);
|
|
131859
131850
|
}
|
|
131860
131851
|
}
|
|
131861
|
-
async function readEngineVersion(
|
|
131852
|
+
async function readEngineVersion(fs5, projectDir) {
|
|
131862
131853
|
const projectPath = import_node_path7.default.resolve(projectDir, "project.galacean");
|
|
131863
131854
|
try {
|
|
131864
|
-
const raw = decodeUtf8(await
|
|
131855
|
+
const raw = decodeUtf8(await fs5.readFile(projectPath));
|
|
131865
131856
|
const parsed = parseJsonObjectOrThrow(raw, projectPath);
|
|
131866
131857
|
const engineVersion = parsed.engineVersion;
|
|
131867
131858
|
return typeof engineVersion === "string" && engineVersion.length > 0 ? engineVersion : void 0;
|
|
@@ -131870,17 +131861,17 @@ async function readEngineVersion(fs6, projectDir) {
|
|
|
131870
131861
|
throw error49;
|
|
131871
131862
|
}
|
|
131872
131863
|
}
|
|
131873
|
-
async function readProjectConfig2(
|
|
131864
|
+
async function readProjectConfig2(fs5, projectDir) {
|
|
131874
131865
|
const projectPath = import_node_path7.default.resolve(projectDir, "project.galacean");
|
|
131875
131866
|
try {
|
|
131876
|
-
const raw = decodeUtf8(await
|
|
131867
|
+
const raw = decodeUtf8(await fs5.readFile(projectPath));
|
|
131877
131868
|
return parseJsonObjectOrThrow(raw, projectPath);
|
|
131878
131869
|
} catch (error49) {
|
|
131879
131870
|
if (isEnoent(error49)) return {};
|
|
131880
131871
|
throw error49;
|
|
131881
131872
|
}
|
|
131882
131873
|
}
|
|
131883
|
-
async function autoCreateRemoteProject(
|
|
131874
|
+
async function autoCreateRemoteProject(fs5, projectDir, opts, projectConfig, resolvedSceneId) {
|
|
131884
131875
|
const { serverUrl, apiClient } = opts;
|
|
131885
131876
|
if (!serverUrl || !apiClient) {
|
|
131886
131877
|
throw new Error("No remote.json found. To auto-create, provide --serverUrl and --token.");
|
|
@@ -131909,7 +131900,7 @@ async function autoCreateRemoteProject(fs6, projectDir, opts, projectConfig, res
|
|
|
131909
131900
|
const remoteConfig = { projectId, serverUrl };
|
|
131910
131901
|
throwIfAborted(opts.signal);
|
|
131911
131902
|
const remotePath = import_node_path7.default.resolve(projectDir, ".galacean/remote.json");
|
|
131912
|
-
await
|
|
131903
|
+
await fs5.writeFile(remotePath, JSON.stringify(remoteConfig, null, 2));
|
|
131913
131904
|
return remoteConfig;
|
|
131914
131905
|
}
|
|
131915
131906
|
async function syncRemoteProjectMetadata(apiClient, projectId, localConfig, resolvedSceneId, remoteProject, signal) {
|
|
@@ -131936,31 +131927,31 @@ async function syncRemoteProjectMetadata(apiClient, projectId, localConfig, reso
|
|
|
131936
131927
|
await apiClient.updateProjectSchema(projectId, { scene: localSceneId }, { signal });
|
|
131937
131928
|
}
|
|
131938
131929
|
}
|
|
131939
|
-
async function listFilesAndDirs(
|
|
131930
|
+
async function listFilesAndDirs(fs5, root2) {
|
|
131940
131931
|
const files = [];
|
|
131941
131932
|
const dirs = [];
|
|
131942
131933
|
const stack = [root2];
|
|
131943
131934
|
while (stack.length) {
|
|
131944
131935
|
const current = stack.pop();
|
|
131945
|
-
const entries = await
|
|
131946
|
-
for (const
|
|
131947
|
-
if (isIgnoredLocalEntryName(
|
|
131948
|
-
const fullPath = import_node_path7.default.join(current,
|
|
131949
|
-
if (
|
|
131936
|
+
const entries = await fs5.readdir(current);
|
|
131937
|
+
for (const entry2 of entries) {
|
|
131938
|
+
if (isIgnoredLocalEntryName(entry2.name)) continue;
|
|
131939
|
+
const fullPath = import_node_path7.default.join(current, entry2.name);
|
|
131940
|
+
if (entry2.kind === "directory") {
|
|
131950
131941
|
if (fullPath !== root2) dirs.push(fullPath);
|
|
131951
131942
|
stack.push(fullPath);
|
|
131952
131943
|
} else {
|
|
131953
|
-
if (
|
|
131944
|
+
if (entry2.name.endsWith(".meta.json")) continue;
|
|
131954
131945
|
files.push(fullPath);
|
|
131955
131946
|
}
|
|
131956
131947
|
}
|
|
131957
131948
|
}
|
|
131958
131949
|
return { files, dirs };
|
|
131959
131950
|
}
|
|
131960
|
-
async function readMetaFileIfExists(
|
|
131951
|
+
async function readMetaFileIfExists(fs5, absContentPath) {
|
|
131961
131952
|
const p = metaFilePath(absContentPath);
|
|
131962
131953
|
try {
|
|
131963
|
-
const raw = decodeUtf8(await
|
|
131954
|
+
const raw = decodeUtf8(await fs5.readFile(p));
|
|
131964
131955
|
return safeParseJsonObject(raw);
|
|
131965
131956
|
} catch (err) {
|
|
131966
131957
|
if (!isEnoent(err)) {
|
|
@@ -131969,7 +131960,7 @@ async function readMetaFileIfExists(fs6, absContentPath) {
|
|
|
131969
131960
|
return void 0;
|
|
131970
131961
|
}
|
|
131971
131962
|
}
|
|
131972
|
-
async function writeMetaFile(
|
|
131963
|
+
async function writeMetaFile(fs5, absContentPath, meta3, assetId, serverId, metaType) {
|
|
131973
131964
|
const p = metaFilePath(absContentPath);
|
|
131974
131965
|
const { locked: _locked, ...restMeta } = meta3;
|
|
131975
131966
|
const merged = {
|
|
@@ -131978,17 +131969,17 @@ async function writeMetaFile(fs6, absContentPath, meta3, assetId, serverId, meta
|
|
|
131978
131969
|
assetId,
|
|
131979
131970
|
serverId
|
|
131980
131971
|
};
|
|
131981
|
-
await
|
|
131972
|
+
await fs5.writeFile(p, JSON.stringify(merged, null, 2));
|
|
131982
131973
|
}
|
|
131983
131974
|
|
|
131984
131975
|
// src/commands/push/push-project.ts
|
|
131985
131976
|
async function pushProject(opts) {
|
|
131986
|
-
const { projectDir, apiClient, fs:
|
|
131977
|
+
const { projectDir, apiClient, fs: fs5, signal } = opts;
|
|
131987
131978
|
throwIfAborted(signal);
|
|
131988
131979
|
const manifestPath = import_node_path8.default.resolve(projectDir, ".galacean/manifest.json");
|
|
131989
|
-
const manifestRaw = await
|
|
131980
|
+
const manifestRaw = await fs5.readFile(manifestPath);
|
|
131990
131981
|
const manifest = parseManifest(manifestRaw, manifestPath);
|
|
131991
|
-
const projectConfig = await readProjectConfig2(
|
|
131982
|
+
const projectConfig = await readProjectConfig2(fs5, projectDir);
|
|
131992
131983
|
const resolvedProjectSceneId = resolveProjectSceneId(projectConfig, manifest);
|
|
131993
131984
|
const pushed = [];
|
|
131994
131985
|
const deleted = [];
|
|
@@ -131997,32 +131988,32 @@ async function pushProject(opts) {
|
|
|
131997
131988
|
try {
|
|
131998
131989
|
const assetsRoot = import_node_path8.default.resolve(projectDir, "assets");
|
|
131999
131990
|
throwIfAborted(signal);
|
|
132000
|
-
const { files: localFilesAbs, dirs: localDirsAbs } = await listFilesAndDirs(
|
|
131991
|
+
const { files: localFilesAbs, dirs: localDirsAbs } = await listFilesAndDirs(fs5, assetsRoot);
|
|
132001
131992
|
const manifestEntryByPath = /* @__PURE__ */ new Map();
|
|
132002
131993
|
const folderIdByPath = /* @__PURE__ */ new Map();
|
|
132003
|
-
for (const [assetId,
|
|
132004
|
-
manifestEntryByPath.set(
|
|
132005
|
-
if (
|
|
131994
|
+
for (const [assetId, entry2] of Object.entries(manifest.entries)) {
|
|
131995
|
+
manifestEntryByPath.set(entry2.path, { assetId, entry: entry2 });
|
|
131996
|
+
if (entry2.type === "Folder") folderIdByPath.set(entry2.path, assetId);
|
|
132006
131997
|
}
|
|
132007
131998
|
const localDirs = localDirsAbs.map((abs) => toManifestPath(projectDir, abs)).filter((p) => p !== "assets");
|
|
132008
131999
|
const localFiles = localFilesAbs.map((abs) => toManifestPath(projectDir, abs));
|
|
132009
|
-
await assertNoCaseOnlyPathCoexistence(
|
|
132000
|
+
await assertNoCaseOnlyPathCoexistence(fs5, projectDir, manifest.entries, localDirs, localFiles, manifestEntryByPath);
|
|
132010
132001
|
const newFolderPaths = localDirs.filter((p) => !manifestEntryByPath.has(p));
|
|
132011
132002
|
const newFilePaths = localFiles.filter((p) => !manifestEntryByPath.has(p));
|
|
132012
132003
|
const localDirSet = new Set(localDirs);
|
|
132013
132004
|
const localFileSet = new Set(localFiles);
|
|
132014
132005
|
const folderCaseRenameMap = /* @__PURE__ */ new Map();
|
|
132015
132006
|
const manifestFolderByLowerPath = /* @__PURE__ */ new Map();
|
|
132016
|
-
for (const [assetId,
|
|
132017
|
-
if (
|
|
132018
|
-
const lowerPath = normalizePathLower(
|
|
132007
|
+
for (const [assetId, entry2] of Object.entries(manifest.entries)) {
|
|
132008
|
+
if (entry2.type !== "Folder") continue;
|
|
132009
|
+
const lowerPath = normalizePathLower(entry2.path);
|
|
132019
132010
|
const existing = manifestFolderByLowerPath.get(lowerPath);
|
|
132020
132011
|
if (existing && existing.assetId !== assetId) {
|
|
132021
132012
|
throw new Error(
|
|
132022
|
-
`[push] Manifest has case-colliding folder paths: '${existing.path}' and '${
|
|
132013
|
+
`[push] Manifest has case-colliding folder paths: '${existing.path}' and '${entry2.path}'. Keep only one path and retry.`
|
|
132023
132014
|
);
|
|
132024
132015
|
}
|
|
132025
|
-
manifestFolderByLowerPath.set(lowerPath, { assetId, path:
|
|
132016
|
+
manifestFolderByLowerPath.set(lowerPath, { assetId, path: entry2.path });
|
|
132026
132017
|
}
|
|
132027
132018
|
for (const folderPath of newFolderPaths) {
|
|
132028
132019
|
const matched = manifestFolderByLowerPath.get(normalizePathLower(folderPath));
|
|
@@ -132039,7 +132030,7 @@ async function pushProject(opts) {
|
|
|
132039
132030
|
const effectiveNewFolderPaths = newFolderPaths;
|
|
132040
132031
|
let remote = null;
|
|
132041
132032
|
try {
|
|
132042
|
-
remote = await readRemoteConfig(
|
|
132033
|
+
remote = await readRemoteConfig(fs5, projectDir);
|
|
132043
132034
|
} catch (err) {
|
|
132044
132035
|
if (!isEnoent(err)) throw err;
|
|
132045
132036
|
}
|
|
@@ -132047,12 +132038,12 @@ async function pushProject(opts) {
|
|
|
132047
132038
|
const backup = new Map(
|
|
132048
132039
|
Object.entries(manifest.entries).map(([id, e]) => [id, { serverId: e.serverId, contentHash: e.contentHash }])
|
|
132049
132040
|
);
|
|
132050
|
-
for (const
|
|
132051
|
-
|
|
132052
|
-
|
|
132041
|
+
for (const entry2 of Object.values(manifest.entries)) {
|
|
132042
|
+
entry2.serverId = "";
|
|
132043
|
+
entry2.contentHash = "";
|
|
132053
132044
|
}
|
|
132054
132045
|
try {
|
|
132055
|
-
remote = await autoCreateRemoteProject(
|
|
132046
|
+
remote = await autoCreateRemoteProject(fs5, projectDir, opts, projectConfig, resolvedProjectSceneId);
|
|
132056
132047
|
} catch (err) {
|
|
132057
132048
|
for (const [id, orig] of backup) {
|
|
132058
132049
|
if (manifest.entries[id]) {
|
|
@@ -132062,13 +132053,13 @@ async function pushProject(opts) {
|
|
|
132062
132053
|
}
|
|
132063
132054
|
const remotePath = import_node_path8.default.resolve(projectDir, ".galacean/remote.json");
|
|
132064
132055
|
try {
|
|
132065
|
-
await
|
|
132056
|
+
await fs5.remove(remotePath);
|
|
132066
132057
|
} catch {
|
|
132067
132058
|
}
|
|
132068
132059
|
throw err;
|
|
132069
132060
|
}
|
|
132070
132061
|
}
|
|
132071
|
-
const engineVersion = await readEngineVersion(
|
|
132062
|
+
const engineVersion = await readEngineVersion(fs5, projectDir);
|
|
132072
132063
|
const existingServerAssets = /* @__PURE__ */ new Map();
|
|
132073
132064
|
const serverAssetDetails = [];
|
|
132074
132065
|
let remoteProjectDetail = null;
|
|
@@ -132085,54 +132076,54 @@ async function pushProject(opts) {
|
|
|
132085
132076
|
}
|
|
132086
132077
|
}
|
|
132087
132078
|
const unregisteredBuiltins = [];
|
|
132088
|
-
for (const [assetId,
|
|
132089
|
-
const isUnregistered = !
|
|
132090
|
-
const isFolderOrCdn =
|
|
132079
|
+
for (const [assetId, entry2] of Object.entries(manifest.entries)) {
|
|
132080
|
+
const isUnregistered = !entry2.serverId || entry2.serverId.startsWith("local-");
|
|
132081
|
+
const isFolderOrCdn = entry2.type === "Folder" || entry2.url?.startsWith("http");
|
|
132091
132082
|
if (!isUnregistered || !isFolderOrCdn) continue;
|
|
132092
|
-
if (
|
|
132093
|
-
if (localDirSet.has(
|
|
132094
|
-
unregisteredBuiltins.push([assetId,
|
|
132083
|
+
if (entry2.type === "Folder") {
|
|
132084
|
+
if (localDirSet.has(entry2.path) || isBuiltinFolderAssetId(assetId)) {
|
|
132085
|
+
unregisteredBuiltins.push([assetId, entry2]);
|
|
132095
132086
|
continue;
|
|
132096
132087
|
}
|
|
132097
|
-
const folderMeta = await readMetaFileIfExists(
|
|
132088
|
+
const folderMeta = await readMetaFileIfExists(fs5, import_node_path8.default.resolve(projectDir, entry2.path));
|
|
132098
132089
|
if (folderMeta) {
|
|
132099
|
-
unregisteredBuiltins.push([assetId,
|
|
132090
|
+
unregisteredBuiltins.push([assetId, entry2]);
|
|
132100
132091
|
}
|
|
132101
132092
|
continue;
|
|
132102
132093
|
}
|
|
132103
|
-
if (localFileSet.has(
|
|
132104
|
-
unregisteredBuiltins.push([assetId,
|
|
132094
|
+
if (localFileSet.has(entry2.path) || isBuiltinAssetId(assetId)) {
|
|
132095
|
+
unregisteredBuiltins.push([assetId, entry2]);
|
|
132105
132096
|
continue;
|
|
132106
132097
|
}
|
|
132107
|
-
const fileMeta = await readMetaFileIfExists(
|
|
132098
|
+
const fileMeta = await readMetaFileIfExists(fs5, import_node_path8.default.resolve(projectDir, entry2.path));
|
|
132108
132099
|
if (fileMeta) {
|
|
132109
|
-
unregisteredBuiltins.push([assetId,
|
|
132100
|
+
unregisteredBuiltins.push([assetId, entry2]);
|
|
132110
132101
|
}
|
|
132111
132102
|
}
|
|
132112
132103
|
if (unregisteredBuiltins.length > 0) {
|
|
132113
132104
|
if (!remote) {
|
|
132114
|
-
remote = await autoCreateRemoteProject(
|
|
132105
|
+
remote = await autoCreateRemoteProject(fs5, projectDir, opts, projectConfig, resolvedProjectSceneId);
|
|
132115
132106
|
}
|
|
132116
132107
|
const builtinFolders = unregisteredBuiltins.filter(([_24, e]) => e.type === "Folder").sort(([, a], [, b]) => a.path.split("/").length - b.path.split("/").length);
|
|
132117
132108
|
const builtinFiles = unregisteredBuiltins.filter(([_24, e]) => e.type !== "Folder");
|
|
132118
|
-
for (const [assetId,
|
|
132109
|
+
for (const [assetId, entry2] of [...builtinFolders, ...builtinFiles]) {
|
|
132119
132110
|
throwIfAborted(signal);
|
|
132120
|
-
const absPath = import_node_path8.default.resolve(projectDir,
|
|
132121
|
-
const existingMeta = await readMetaFileIfExists(
|
|
132111
|
+
const absPath = import_node_path8.default.resolve(projectDir, entry2.path);
|
|
132112
|
+
const existingMeta = await readMetaFileIfExists(fs5, absPath) ?? {};
|
|
132122
132113
|
const existingId = existingServerAssets.get(assetId);
|
|
132123
132114
|
if (existingId) {
|
|
132124
|
-
|
|
132125
|
-
await writeMetaFile(
|
|
132115
|
+
entry2.serverId = existingId;
|
|
132116
|
+
await writeMetaFile(fs5, absPath, existingMeta, assetId, existingId, entry2.type);
|
|
132126
132117
|
continue;
|
|
132127
132118
|
}
|
|
132128
|
-
const parentId = resolveParentId(import_node_path8.default.posix.dirname(
|
|
132129
|
-
const serverName = getServerFileName(
|
|
132119
|
+
const parentId = resolveParentId(import_node_path8.default.posix.dirname(entry2.path), folderIdByPath, entry2.path);
|
|
132120
|
+
const serverName = getServerFileName(entry2.path, entry2.type);
|
|
132130
132121
|
const lockedFromMeta = existingMeta.locked;
|
|
132131
132122
|
const shouldForceLocked = isBuiltinAssetId(assetId);
|
|
132132
132123
|
const lockedForServer = shouldForceLocked ? true : typeof lockedFromMeta === "boolean" ? lockedFromMeta : void 0;
|
|
132133
132124
|
const metaForServer = {
|
|
132134
132125
|
...stripLocalMetaFields(existingMeta),
|
|
132135
|
-
type:
|
|
132126
|
+
type: entry2.type,
|
|
132136
132127
|
id: assetId,
|
|
132137
132128
|
version: existingMeta.version || engineVersion,
|
|
132138
132129
|
...lockedForServer === void 0 ? {} : { locked: lockedForServer }
|
|
@@ -132144,12 +132135,12 @@ async function pushProject(opts) {
|
|
|
132144
132135
|
name: serverName,
|
|
132145
132136
|
meta: JSON.stringify(metaForServer),
|
|
132146
132137
|
parentId,
|
|
132147
|
-
url:
|
|
132138
|
+
url: entry2.type !== "Folder" ? entry2.url : void 0
|
|
132148
132139
|
},
|
|
132149
132140
|
{ signal }
|
|
132150
132141
|
);
|
|
132151
|
-
|
|
132152
|
-
await writeMetaFile(
|
|
132142
|
+
entry2.serverId = created.id;
|
|
132143
|
+
await writeMetaFile(fs5, absPath, existingMeta, assetId, created.id, entry2.type);
|
|
132153
132144
|
}
|
|
132154
132145
|
}
|
|
132155
132146
|
effectiveNewFolderPaths.sort((a, b) => a.split("/").length - b.split("/").length);
|
|
@@ -132164,9 +132155,9 @@ async function pushProject(opts) {
|
|
|
132164
132155
|
if (!existingEntry || existingEntry.type !== "Folder") {
|
|
132165
132156
|
throw new Error(`[push] Missing tracked folder entry for case-only rename: '${oldPath}' -> '${folderPath}'`);
|
|
132166
132157
|
}
|
|
132167
|
-
let existingMeta2 = await readMetaFileIfExists(
|
|
132158
|
+
let existingMeta2 = await readMetaFileIfExists(fs5, absFolderPath) ?? {};
|
|
132168
132159
|
if (Object.keys(existingMeta2).length === 0) {
|
|
132169
|
-
existingMeta2 = await readMetaFileIfExists(
|
|
132160
|
+
existingMeta2 = await readMetaFileIfExists(fs5, import_node_path8.default.resolve(projectDir, oldPath)) ?? {};
|
|
132170
132161
|
}
|
|
132171
132162
|
const baseMeta2 = {
|
|
132172
132163
|
...stripLocalMetaFields(existingMeta2),
|
|
@@ -132174,7 +132165,7 @@ async function pushProject(opts) {
|
|
|
132174
132165
|
id: assetId2,
|
|
132175
132166
|
version: engineVersion
|
|
132176
132167
|
};
|
|
132177
|
-
await writeMetaFile(
|
|
132168
|
+
await writeMetaFile(fs5, absFolderPath, baseMeta2, assetId2, existingEntry.serverId, "Folder");
|
|
132178
132169
|
existingEntry.path = folderPath;
|
|
132179
132170
|
existingEntry.remoteVersion = existingEntry.remoteVersion || engineVersion || "";
|
|
132180
132171
|
manifestEntryByPath.delete(oldPath);
|
|
@@ -132184,7 +132175,7 @@ async function pushProject(opts) {
|
|
|
132184
132175
|
continue;
|
|
132185
132176
|
}
|
|
132186
132177
|
const parentId = resolveParentId(import_node_path8.default.posix.dirname(folderPath), folderIdByPath, folderPath);
|
|
132187
|
-
const existingMeta = await readMetaFileIfExists(
|
|
132178
|
+
const existingMeta = await readMetaFileIfExists(fs5, absFolderPath) ?? {};
|
|
132188
132179
|
const persistedId = resolvePersistedId(existingMeta);
|
|
132189
132180
|
const assetId = persistedId ?? (0, import_node_crypto3.randomUUID)();
|
|
132190
132181
|
const baseMeta = {
|
|
@@ -132195,7 +132186,7 @@ async function pushProject(opts) {
|
|
|
132195
132186
|
};
|
|
132196
132187
|
const existingId = existingServerAssets.get(assetId);
|
|
132197
132188
|
if (existingId) {
|
|
132198
|
-
await writeMetaFile(
|
|
132189
|
+
await writeMetaFile(fs5, absFolderPath, baseMeta, assetId, existingId, "Folder");
|
|
132199
132190
|
manifest.entries[assetId] = {
|
|
132200
132191
|
assetId,
|
|
132201
132192
|
path: folderPath,
|
|
@@ -132210,7 +132201,7 @@ async function pushProject(opts) {
|
|
|
132210
132201
|
continue;
|
|
132211
132202
|
}
|
|
132212
132203
|
if (!persistedId) {
|
|
132213
|
-
await writeMetaFile(
|
|
132204
|
+
await writeMetaFile(fs5, absFolderPath, baseMeta, assetId, "", "Folder");
|
|
132214
132205
|
}
|
|
132215
132206
|
const metaForServer = safeParseJsonObject(JSON.stringify(baseMeta));
|
|
132216
132207
|
const created = await apiClient.createAsset(
|
|
@@ -132224,7 +132215,7 @@ async function pushProject(opts) {
|
|
|
132224
132215
|
{ signal }
|
|
132225
132216
|
);
|
|
132226
132217
|
const returnedMeta = parseJsonObjectOrThrow(created.meta, `createAsset response for folder '${folderPath}'`);
|
|
132227
|
-
await writeMetaFile(
|
|
132218
|
+
await writeMetaFile(fs5, absFolderPath, returnedMeta, assetId, created.id, "Folder");
|
|
132228
132219
|
manifest.entries[assetId] = {
|
|
132229
132220
|
assetId,
|
|
132230
132221
|
path: folderPath,
|
|
@@ -132241,8 +132232,8 @@ async function pushProject(opts) {
|
|
|
132241
132232
|
throwIfAborted(signal);
|
|
132242
132233
|
const parentId = resolveParentId(import_node_path8.default.posix.dirname(filePath), folderIdByPath, filePath);
|
|
132243
132234
|
const absFilePath = import_node_path8.default.resolve(projectDir, filePath);
|
|
132244
|
-
const content = await
|
|
132245
|
-
const existingMeta = await readMetaFileIfExists(
|
|
132235
|
+
const content = await fs5.readFile(absFilePath);
|
|
132236
|
+
const existingMeta = await readMetaFileIfExists(fs5, absFilePath) ?? {};
|
|
132246
132237
|
const persistedType = existingMeta.type;
|
|
132247
132238
|
const localFileName = import_node_path8.default.posix.basename(filePath);
|
|
132248
132239
|
const metaType = (typeof persistedType === "string" && persistedType.length > 0 ? persistedType : void 0) ?? (localFileName.endsWith(".ts") ? "script" : void 0);
|
|
@@ -132264,7 +132255,7 @@ async function pushProject(opts) {
|
|
|
132264
132255
|
const existingId = existingServerAssets.get(assetId);
|
|
132265
132256
|
if (existingId) {
|
|
132266
132257
|
const upload = await apiClient.uploadAsset(existingId, content, serverName, { signal });
|
|
132267
|
-
await writeMetaFile(
|
|
132258
|
+
await writeMetaFile(fs5, absFilePath, baseMeta, assetId, existingId, metaType);
|
|
132268
132259
|
manifest.entries[assetId] = {
|
|
132269
132260
|
assetId,
|
|
132270
132261
|
path: filePath,
|
|
@@ -132279,7 +132270,7 @@ async function pushProject(opts) {
|
|
|
132279
132270
|
continue;
|
|
132280
132271
|
}
|
|
132281
132272
|
if (!persistedId) {
|
|
132282
|
-
await writeMetaFile(
|
|
132273
|
+
await writeMetaFile(fs5, absFilePath, baseMeta, assetId, "", metaType);
|
|
132283
132274
|
}
|
|
132284
132275
|
const metaForServer = safeParseJsonObject(JSON.stringify(baseMeta));
|
|
132285
132276
|
const created = await apiClient.createAsset(
|
|
@@ -132294,7 +132285,7 @@ async function pushProject(opts) {
|
|
|
132294
132285
|
{ signal }
|
|
132295
132286
|
);
|
|
132296
132287
|
const returnedMeta = parseJsonObjectOrThrow(created.meta, `createAsset response for file '${filePath}'`);
|
|
132297
|
-
await writeMetaFile(
|
|
132288
|
+
await writeMetaFile(fs5, absFilePath, returnedMeta, assetId, created.id, metaType);
|
|
132298
132289
|
manifest.entries[assetId] = {
|
|
132299
132290
|
assetId,
|
|
132300
132291
|
path: filePath,
|
|
@@ -132308,56 +132299,56 @@ async function pushProject(opts) {
|
|
|
132308
132299
|
pushed.push({ assetId, path: filePath, serverId: created.id, url: created.url });
|
|
132309
132300
|
}
|
|
132310
132301
|
const deletedLocalAssetIds = /* @__PURE__ */ new Set();
|
|
132311
|
-
for (const [assetId,
|
|
132302
|
+
for (const [assetId, entry2] of Object.entries(manifest.entries)) {
|
|
132312
132303
|
throwIfAborted(signal);
|
|
132313
|
-
if (
|
|
132314
|
-
const filePath = import_node_path8.default.resolve(projectDir,
|
|
132304
|
+
if (entry2.type === "Folder") continue;
|
|
132305
|
+
const filePath = import_node_path8.default.resolve(projectDir, entry2.path);
|
|
132315
132306
|
let content;
|
|
132316
132307
|
try {
|
|
132317
|
-
content = await
|
|
132308
|
+
content = await fs5.readFile(filePath);
|
|
132318
132309
|
} catch (err) {
|
|
132319
132310
|
if (!isEnoent(err)) {
|
|
132320
132311
|
throw err;
|
|
132321
132312
|
}
|
|
132322
|
-
if (shouldTreatMissingLocalFileAsDelete(
|
|
132313
|
+
if (shouldTreatMissingLocalFileAsDelete(entry2)) {
|
|
132323
132314
|
deletedLocalAssetIds.add(assetId);
|
|
132324
132315
|
continue;
|
|
132325
132316
|
}
|
|
132326
132317
|
warnings.push(
|
|
132327
|
-
`[push] Missing local file for remote-only asset '${
|
|
132318
|
+
`[push] Missing local file for remote-only asset '${entry2.path}'; leaving manifest entry unchanged.`
|
|
132328
132319
|
);
|
|
132329
132320
|
continue;
|
|
132330
132321
|
}
|
|
132331
132322
|
const currentHash = md5Buffer(content);
|
|
132332
|
-
const isLocalOnly = !
|
|
132333
|
-
if (currentHash ===
|
|
132334
|
-
const serverName = getServerFileName(
|
|
132323
|
+
const isLocalOnly = !entry2.serverId || entry2.serverId.startsWith("local-");
|
|
132324
|
+
if (currentHash === entry2.contentHash && !isLocalOnly) continue;
|
|
132325
|
+
const serverName = getServerFileName(entry2.path, entry2.type);
|
|
132335
132326
|
if (isLocalOnly) {
|
|
132336
132327
|
const existingId = existingServerAssets.get(assetId);
|
|
132337
132328
|
if (existingId) {
|
|
132338
132329
|
const upload = await apiClient.uploadAsset(existingId, content, serverName, { signal });
|
|
132339
|
-
const absFilePath = import_node_path8.default.resolve(projectDir,
|
|
132340
|
-
const existingMeta = await readMetaFileIfExists(
|
|
132341
|
-
const metaType = typeof existingMeta.type === "string" && existingMeta.type ||
|
|
132342
|
-
await writeMetaFile(
|
|
132343
|
-
|
|
132344
|
-
|
|
132345
|
-
|
|
132346
|
-
pushed.push({ assetId, path:
|
|
132330
|
+
const absFilePath = import_node_path8.default.resolve(projectDir, entry2.path);
|
|
132331
|
+
const existingMeta = await readMetaFileIfExists(fs5, absFilePath) ?? {};
|
|
132332
|
+
const metaType = typeof existingMeta.type === "string" && existingMeta.type || entry2.type;
|
|
132333
|
+
await writeMetaFile(fs5, absFilePath, existingMeta, assetId, existingId, metaType);
|
|
132334
|
+
entry2.contentHash = currentHash;
|
|
132335
|
+
entry2.serverId = existingId;
|
|
132336
|
+
entry2.url = upload.url;
|
|
132337
|
+
pushed.push({ assetId, path: entry2.path, serverId: existingId, url: upload.url });
|
|
132347
132338
|
} else {
|
|
132348
132339
|
if (!remote) {
|
|
132349
|
-
remote = await autoCreateRemoteProject(
|
|
132340
|
+
remote = await autoCreateRemoteProject(fs5, projectDir, opts, projectConfig, resolvedProjectSceneId);
|
|
132350
132341
|
}
|
|
132351
|
-
const absFilePath = import_node_path8.default.resolve(projectDir,
|
|
132352
|
-
const existingMeta = await readMetaFileIfExists(
|
|
132353
|
-
const metaType = typeof existingMeta.type === "string" && existingMeta.type ||
|
|
132342
|
+
const absFilePath = import_node_path8.default.resolve(projectDir, entry2.path);
|
|
132343
|
+
const existingMeta = await readMetaFileIfExists(fs5, absFilePath) ?? {};
|
|
132344
|
+
const metaType = typeof existingMeta.type === "string" && existingMeta.type || entry2.type;
|
|
132354
132345
|
const metaForServer = {
|
|
132355
132346
|
...stripLocalMetaFields(existingMeta),
|
|
132356
132347
|
type: metaType,
|
|
132357
132348
|
id: assetId,
|
|
132358
132349
|
version: engineVersion
|
|
132359
132350
|
};
|
|
132360
|
-
const parentId = resolveParentId(import_node_path8.default.posix.dirname(
|
|
132351
|
+
const parentId = resolveParentId(import_node_path8.default.posix.dirname(entry2.path), folderIdByPath, entry2.path);
|
|
132361
132352
|
const created = await apiClient.createAsset(
|
|
132362
132353
|
{
|
|
132363
132354
|
projectId: remote.projectId,
|
|
@@ -132369,28 +132360,28 @@ async function pushProject(opts) {
|
|
|
132369
132360
|
},
|
|
132370
132361
|
{ signal }
|
|
132371
132362
|
);
|
|
132372
|
-
const returnedMeta = parseJsonObjectOrThrow(created.meta, `createAsset response for file '${
|
|
132373
|
-
await writeMetaFile(
|
|
132374
|
-
|
|
132375
|
-
|
|
132376
|
-
|
|
132377
|
-
pushed.push({ assetId, path:
|
|
132363
|
+
const returnedMeta = parseJsonObjectOrThrow(created.meta, `createAsset response for file '${entry2.path}'`);
|
|
132364
|
+
await writeMetaFile(fs5, absFilePath, returnedMeta, assetId, created.id, metaType);
|
|
132365
|
+
entry2.contentHash = currentHash;
|
|
132366
|
+
entry2.serverId = created.id;
|
|
132367
|
+
entry2.url = created.url;
|
|
132368
|
+
pushed.push({ assetId, path: entry2.path, serverId: created.id, url: created.url });
|
|
132378
132369
|
}
|
|
132379
132370
|
} else {
|
|
132380
|
-
const upload = await apiClient.uploadAsset(
|
|
132381
|
-
|
|
132382
|
-
|
|
132383
|
-
pushed.push({ assetId, path:
|
|
132371
|
+
const upload = await apiClient.uploadAsset(entry2.serverId, content, serverName, { signal });
|
|
132372
|
+
entry2.contentHash = currentHash;
|
|
132373
|
+
entry2.url = upload.url;
|
|
132374
|
+
pushed.push({ assetId, path: entry2.path, serverId: entry2.serverId, url: upload.url });
|
|
132384
132375
|
}
|
|
132385
132376
|
}
|
|
132386
132377
|
const deletedFolderPaths = [];
|
|
132387
132378
|
const folderDeleteCandidates = Object.values(manifest.entries).filter(
|
|
132388
|
-
(
|
|
132379
|
+
(entry2) => entry2.type === "Folder" && !localDirSet.has(entry2.path)
|
|
132389
132380
|
);
|
|
132390
132381
|
for (const folderEntry of folderDeleteCandidates) {
|
|
132391
132382
|
const folderPath = folderEntry.path;
|
|
132392
132383
|
const hasDeletedDescendant = Object.entries(manifest.entries).some(
|
|
132393
|
-
([assetId,
|
|
132384
|
+
([assetId, entry2]) => deletedLocalAssetIds.has(assetId) && isPathInsideFolder(entry2.path, folderPath)
|
|
132394
132385
|
);
|
|
132395
132386
|
if (hasDeletedDescendant || hasMaterializedDescendant(manifest.entries, folderPath)) {
|
|
132396
132387
|
deletedFolderPaths.push(folderPath);
|
|
@@ -132402,9 +132393,9 @@ async function pushProject(opts) {
|
|
|
132402
132393
|
}
|
|
132403
132394
|
deletedFolderPaths.sort((a, b) => a.length - b.length);
|
|
132404
132395
|
for (const folderPath of deletedFolderPaths) {
|
|
132405
|
-
for (const [assetId,
|
|
132406
|
-
if (
|
|
132407
|
-
if (
|
|
132396
|
+
for (const [assetId, entry2] of Object.entries(manifest.entries)) {
|
|
132397
|
+
if (entry2.path === folderPath || isPathInsideFolder(entry2.path, folderPath)) {
|
|
132398
|
+
if (entry2.type !== "Folder" && !shouldTreatMissingLocalFileAsDelete(entry2)) continue;
|
|
132408
132399
|
deletedLocalAssetIds.add(assetId);
|
|
132409
132400
|
}
|
|
132410
132401
|
}
|
|
@@ -132424,12 +132415,12 @@ async function pushProject(opts) {
|
|
|
132424
132415
|
pendingManifestDeletes.push({ assetId, entry: removedEntry });
|
|
132425
132416
|
const absFilePath = import_node_path8.default.resolve(projectDir, removedEntry.path);
|
|
132426
132417
|
try {
|
|
132427
|
-
await
|
|
132418
|
+
await fs5.remove(metaFilePath(absFilePath));
|
|
132428
132419
|
} catch (err) {
|
|
132429
132420
|
if (!isEnoent(err)) throw err;
|
|
132430
132421
|
}
|
|
132431
132422
|
try {
|
|
132432
|
-
await
|
|
132423
|
+
await fs5.remove(absFilePath);
|
|
132433
132424
|
} catch (err) {
|
|
132434
132425
|
if (!isEnoent(err)) throw err;
|
|
132435
132426
|
}
|
|
@@ -132461,10 +132452,10 @@ async function pushProject(opts) {
|
|
|
132461
132452
|
await apiClient.deleteAssets(remote.projectId, toDelete, { signal });
|
|
132462
132453
|
deleted.push(...toDelete);
|
|
132463
132454
|
}
|
|
132464
|
-
for (const { assetId, entry } of pendingManifestDeletes) {
|
|
132455
|
+
for (const { assetId, entry: entry2 } of pendingManifestDeletes) {
|
|
132465
132456
|
delete manifest.entries[assetId];
|
|
132466
|
-
manifestEntryByPath.delete(
|
|
132467
|
-
if (
|
|
132457
|
+
manifestEntryByPath.delete(entry2.path);
|
|
132458
|
+
if (entry2.type === "Folder") folderIdByPath.delete(entry2.path);
|
|
132468
132459
|
}
|
|
132469
132460
|
if (remote && remoteProjectDetail) {
|
|
132470
132461
|
await syncRemoteProjectMetadata(
|
|
@@ -132481,7 +132472,7 @@ async function pushProject(opts) {
|
|
|
132481
132472
|
}
|
|
132482
132473
|
let writeError;
|
|
132483
132474
|
try {
|
|
132484
|
-
await atomicWriteFile(
|
|
132475
|
+
await atomicWriteFile(fs5, manifestPath, JSON.stringify(manifest, null, 2));
|
|
132485
132476
|
} catch (err) {
|
|
132486
132477
|
writeError = err;
|
|
132487
132478
|
}
|
|
@@ -132551,11 +132542,11 @@ var normalizeFilter = (filter) => {
|
|
|
132551
132542
|
return filter;
|
|
132552
132543
|
if (typeof filter === "string") {
|
|
132553
132544
|
const fl = filter.trim();
|
|
132554
|
-
return (
|
|
132545
|
+
return (entry2) => entry2.basename === fl;
|
|
132555
132546
|
}
|
|
132556
132547
|
if (Array.isArray(filter)) {
|
|
132557
132548
|
const trItems = filter.map((item) => item.trim());
|
|
132558
|
-
return (
|
|
132549
|
+
return (entry2) => trItems.some((f) => entry2.basename === f);
|
|
132559
132550
|
}
|
|
132560
132551
|
return emptyFn;
|
|
132561
132552
|
};
|
|
@@ -132600,23 +132591,23 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
132600
132591
|
const { path: path16, depth } = par;
|
|
132601
132592
|
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path16));
|
|
132602
132593
|
const awaited = await Promise.all(slice);
|
|
132603
|
-
for (const
|
|
132604
|
-
if (!
|
|
132594
|
+
for (const entry2 of awaited) {
|
|
132595
|
+
if (!entry2)
|
|
132605
132596
|
continue;
|
|
132606
132597
|
if (this.destroyed)
|
|
132607
132598
|
return;
|
|
132608
|
-
const entryType = await this._getEntryType(
|
|
132609
|
-
if (entryType === "directory" && this._directoryFilter(
|
|
132599
|
+
const entryType = await this._getEntryType(entry2);
|
|
132600
|
+
if (entryType === "directory" && this._directoryFilter(entry2)) {
|
|
132610
132601
|
if (depth <= this._maxDepth) {
|
|
132611
|
-
this.parents.push(this._exploreDir(
|
|
132602
|
+
this.parents.push(this._exploreDir(entry2.fullPath, depth + 1));
|
|
132612
132603
|
}
|
|
132613
132604
|
if (this._wantsDir) {
|
|
132614
|
-
this.push(
|
|
132605
|
+
this.push(entry2);
|
|
132615
132606
|
batch--;
|
|
132616
132607
|
}
|
|
132617
|
-
} else if ((entryType === "file" || this._includeAsFile(
|
|
132608
|
+
} else if ((entryType === "file" || this._includeAsFile(entry2)) && this._fileFilter(entry2)) {
|
|
132618
132609
|
if (this._wantsFile) {
|
|
132619
|
-
this.push(
|
|
132610
|
+
this.push(entry2);
|
|
132620
132611
|
batch--;
|
|
132621
132612
|
}
|
|
132622
132613
|
}
|
|
@@ -132648,17 +132639,17 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
132648
132639
|
return { files, depth, path: path16 };
|
|
132649
132640
|
}
|
|
132650
132641
|
async _formatEntry(dirent, path16) {
|
|
132651
|
-
let
|
|
132642
|
+
let entry2;
|
|
132652
132643
|
const basename4 = this._isDirent ? dirent.name : dirent;
|
|
132653
132644
|
try {
|
|
132654
132645
|
const fullPath = (0, import_node_path9.resolve)((0, import_node_path9.join)(path16, basename4));
|
|
132655
|
-
|
|
132656
|
-
|
|
132646
|
+
entry2 = { path: (0, import_node_path9.relative)(this._root, fullPath), fullPath, basename: basename4 };
|
|
132647
|
+
entry2[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
132657
132648
|
} catch (err) {
|
|
132658
132649
|
this._onError(err);
|
|
132659
132650
|
return;
|
|
132660
132651
|
}
|
|
132661
|
-
return
|
|
132652
|
+
return entry2;
|
|
132662
132653
|
}
|
|
132663
132654
|
_onError(err) {
|
|
132664
132655
|
if (isNormalFlowError(err) && !this.destroyed) {
|
|
@@ -132667,17 +132658,17 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
132667
132658
|
this.destroy(err);
|
|
132668
132659
|
}
|
|
132669
132660
|
}
|
|
132670
|
-
async _getEntryType(
|
|
132671
|
-
if (!
|
|
132661
|
+
async _getEntryType(entry2) {
|
|
132662
|
+
if (!entry2 && this._statsProp in entry2) {
|
|
132672
132663
|
return "";
|
|
132673
132664
|
}
|
|
132674
|
-
const stats =
|
|
132665
|
+
const stats = entry2[this._statsProp];
|
|
132675
132666
|
if (stats.isFile())
|
|
132676
132667
|
return "file";
|
|
132677
132668
|
if (stats.isDirectory())
|
|
132678
132669
|
return "directory";
|
|
132679
132670
|
if (stats && stats.isSymbolicLink()) {
|
|
132680
|
-
const full =
|
|
132671
|
+
const full = entry2.fullPath;
|
|
132681
132672
|
try {
|
|
132682
132673
|
const entryRealPath = await (0, import_promises5.realpath)(full);
|
|
132683
132674
|
const entryRealPathStats = await (0, import_promises5.lstat)(entryRealPath);
|
|
@@ -132699,8 +132690,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
|
|
|
132699
132690
|
}
|
|
132700
132691
|
}
|
|
132701
132692
|
}
|
|
132702
|
-
_includeAsFile(
|
|
132703
|
-
const stats =
|
|
132693
|
+
_includeAsFile(entry2) {
|
|
132694
|
+
const stats = entry2 && entry2[this._statsProp];
|
|
132704
132695
|
return stats && this._wantsEverything && !stats.isDirectory();
|
|
132705
132696
|
}
|
|
132706
132697
|
};
|
|
@@ -133026,10 +133017,10 @@ var foreach = (val, fn) => {
|
|
|
133026
133017
|
fn(val);
|
|
133027
133018
|
}
|
|
133028
133019
|
};
|
|
133029
|
-
var addAndConvert = (
|
|
133030
|
-
let container =
|
|
133020
|
+
var addAndConvert = (main2, prop, item) => {
|
|
133021
|
+
let container = main2[prop];
|
|
133031
133022
|
if (!(container instanceof Set)) {
|
|
133032
|
-
|
|
133023
|
+
main2[prop] = container = /* @__PURE__ */ new Set([container]);
|
|
133033
133024
|
}
|
|
133034
133025
|
container.add(item);
|
|
133035
133026
|
};
|
|
@@ -133041,12 +133032,12 @@ var clearItem = (cont) => (key) => {
|
|
|
133041
133032
|
delete cont[key];
|
|
133042
133033
|
}
|
|
133043
133034
|
};
|
|
133044
|
-
var delFromSet = (
|
|
133045
|
-
const container =
|
|
133035
|
+
var delFromSet = (main2, prop, item) => {
|
|
133036
|
+
const container = main2[prop];
|
|
133046
133037
|
if (container instanceof Set) {
|
|
133047
133038
|
container.delete(item);
|
|
133048
133039
|
} else if (container === item) {
|
|
133049
|
-
delete
|
|
133040
|
+
delete main2[prop];
|
|
133050
133041
|
}
|
|
133051
133042
|
};
|
|
133052
133043
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
@@ -133281,11 +133272,11 @@ var NodeFsHandler = class {
|
|
|
133281
133272
|
* @param item basename of this item
|
|
133282
133273
|
* @returns true if no more processing is needed for this entry.
|
|
133283
133274
|
*/
|
|
133284
|
-
async _handleSymlink(
|
|
133275
|
+
async _handleSymlink(entry2, directory, path16, item) {
|
|
133285
133276
|
if (this.fsw.closed) {
|
|
133286
133277
|
return;
|
|
133287
133278
|
}
|
|
133288
|
-
const full =
|
|
133279
|
+
const full = entry2.fullPath;
|
|
133289
133280
|
const dir = this.fsw._getWatchedDir(directory);
|
|
133290
133281
|
if (!this.fsw.options.followSymlinks) {
|
|
133291
133282
|
this.fsw._incrReadyCount();
|
|
@@ -133301,12 +133292,12 @@ var NodeFsHandler = class {
|
|
|
133301
133292
|
if (dir.has(item)) {
|
|
133302
133293
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
133303
133294
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
133304
|
-
this.fsw._emit(EV.CHANGE, path16,
|
|
133295
|
+
this.fsw._emit(EV.CHANGE, path16, entry2.stats);
|
|
133305
133296
|
}
|
|
133306
133297
|
} else {
|
|
133307
133298
|
dir.add(item);
|
|
133308
133299
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
133309
|
-
this.fsw._emit(EV.ADD, path16,
|
|
133300
|
+
this.fsw._emit(EV.ADD, path16, entry2.stats);
|
|
133310
133301
|
}
|
|
133311
133302
|
this.fsw._emitReady();
|
|
133312
133303
|
return true;
|
|
@@ -133324,20 +133315,20 @@ var NodeFsHandler = class {
|
|
|
133324
133315
|
const previous = this.fsw._getWatchedDir(wh.path);
|
|
133325
133316
|
const current = /* @__PURE__ */ new Set();
|
|
133326
133317
|
let stream = this.fsw._readdirp(directory, {
|
|
133327
|
-
fileFilter: (
|
|
133328
|
-
directoryFilter: (
|
|
133318
|
+
fileFilter: (entry2) => wh.filterPath(entry2),
|
|
133319
|
+
directoryFilter: (entry2) => wh.filterDir(entry2)
|
|
133329
133320
|
});
|
|
133330
133321
|
if (!stream)
|
|
133331
133322
|
return;
|
|
133332
|
-
stream.on(STR_DATA, async (
|
|
133323
|
+
stream.on(STR_DATA, async (entry2) => {
|
|
133333
133324
|
if (this.fsw.closed) {
|
|
133334
133325
|
stream = void 0;
|
|
133335
133326
|
return;
|
|
133336
133327
|
}
|
|
133337
|
-
const item =
|
|
133328
|
+
const item = entry2.path;
|
|
133338
133329
|
let path16 = sysPath.join(directory, item);
|
|
133339
133330
|
current.add(item);
|
|
133340
|
-
if (
|
|
133331
|
+
if (entry2.stats.isSymbolicLink() && await this._handleSymlink(entry2, directory, path16, item)) {
|
|
133341
133332
|
return;
|
|
133342
133333
|
}
|
|
133343
133334
|
if (this.fsw.closed) {
|
|
@@ -133424,8 +133415,8 @@ var NodeFsHandler = class {
|
|
|
133424
133415
|
}
|
|
133425
133416
|
const wh = this.fsw._getWatchHelpers(path16);
|
|
133426
133417
|
if (priorWh) {
|
|
133427
|
-
wh.filterPath = (
|
|
133428
|
-
wh.filterDir = (
|
|
133418
|
+
wh.filterPath = (entry2) => priorWh.filterPath(entry2);
|
|
133419
|
+
wh.filterDir = (entry2) => priorWh.filterDir(entry2);
|
|
133429
133420
|
}
|
|
133430
133421
|
try {
|
|
133431
133422
|
const stats = await statMethods[wh.statMethod](wh.watchPath);
|
|
@@ -133654,18 +133645,18 @@ var WatchHelper = class {
|
|
|
133654
133645
|
this.followSymlinks = follow;
|
|
133655
133646
|
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
|
133656
133647
|
}
|
|
133657
|
-
entryPath(
|
|
133658
|
-
return sysPath2.join(this.watchPath, sysPath2.relative(this.watchPath,
|
|
133648
|
+
entryPath(entry2) {
|
|
133649
|
+
return sysPath2.join(this.watchPath, sysPath2.relative(this.watchPath, entry2.fullPath));
|
|
133659
133650
|
}
|
|
133660
|
-
filterPath(
|
|
133661
|
-
const { stats } =
|
|
133651
|
+
filterPath(entry2) {
|
|
133652
|
+
const { stats } = entry2;
|
|
133662
133653
|
if (stats && stats.isSymbolicLink())
|
|
133663
|
-
return this.filterDir(
|
|
133664
|
-
const resolvedPath = this.entryPath(
|
|
133654
|
+
return this.filterDir(entry2);
|
|
133655
|
+
const resolvedPath = this.entryPath(entry2);
|
|
133665
133656
|
return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
|
|
133666
133657
|
}
|
|
133667
|
-
filterDir(
|
|
133668
|
-
return this.fsw._isntIgnored(this.entryPath(
|
|
133658
|
+
filterDir(entry2) {
|
|
133659
|
+
return this.fsw._isntIgnored(this.entryPath(entry2), entry2.stats);
|
|
133669
133660
|
}
|
|
133670
133661
|
};
|
|
133671
133662
|
var FSWatcher = class extends import_events.EventEmitter {
|
|
@@ -133852,10 +133843,10 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
133852
133843
|
*/
|
|
133853
133844
|
getWatched() {
|
|
133854
133845
|
const watchList = {};
|
|
133855
|
-
this._watched.forEach((
|
|
133846
|
+
this._watched.forEach((entry2, dir) => {
|
|
133856
133847
|
const key = this.options.cwd ? sysPath2.relative(this.options.cwd, dir) : dir;
|
|
133857
133848
|
const index2 = key || ONE_DOT;
|
|
133858
|
-
watchList[index2] =
|
|
133849
|
+
watchList[index2] = entry2.getChildren().sort();
|
|
133859
133850
|
});
|
|
133860
133851
|
return watchList;
|
|
133861
133852
|
}
|
|
@@ -133895,9 +133886,9 @@ var FSWatcher = class extends import_events.EventEmitter {
|
|
|
133895
133886
|
if (event === EVENTS.UNLINK) {
|
|
133896
133887
|
this._pendingUnlinks.set(path16, [event, ...args]);
|
|
133897
133888
|
setTimeout(() => {
|
|
133898
|
-
this._pendingUnlinks.forEach((
|
|
133899
|
-
this.emit(...
|
|
133900
|
-
this.emit(EVENTS.ALL, ...
|
|
133889
|
+
this._pendingUnlinks.forEach((entry2, path17) => {
|
|
133890
|
+
this.emit(...entry2);
|
|
133891
|
+
this.emit(EVENTS.ALL, ...entry2);
|
|
133901
133892
|
this._pendingUnlinks.delete(path17);
|
|
133902
133893
|
});
|
|
133903
133894
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
@@ -134286,7 +134277,7 @@ function watchProject(opts) {
|
|
|
134286
134277
|
const {
|
|
134287
134278
|
projectDir,
|
|
134288
134279
|
apiClient,
|
|
134289
|
-
fs:
|
|
134280
|
+
fs: fs5,
|
|
134290
134281
|
debounceMs,
|
|
134291
134282
|
onPush,
|
|
134292
134283
|
onError,
|
|
@@ -134310,7 +134301,7 @@ function watchProject(opts) {
|
|
|
134310
134301
|
const result = await pushProject({
|
|
134311
134302
|
projectDir: import_node_path11.default.resolve(projectDir),
|
|
134312
134303
|
apiClient,
|
|
134313
|
-
fs:
|
|
134304
|
+
fs: fs5,
|
|
134314
134305
|
signal,
|
|
134315
134306
|
serverUrl,
|
|
134316
134307
|
token
|
|
@@ -134478,25 +134469,25 @@ function registerAssetInfo(parent) {
|
|
|
134478
134469
|
const dir = projectDir ?? process.cwd();
|
|
134479
134470
|
const globals = parent.optsWithGlobals();
|
|
134480
134471
|
const manifest = await readManifest(dir);
|
|
134481
|
-
const
|
|
134482
|
-
if (!
|
|
134472
|
+
const entry2 = manifest.entries[assetId];
|
|
134473
|
+
if (!entry2) {
|
|
134483
134474
|
throw new Error(`Asset "${assetId}" not found in manifest`);
|
|
134484
134475
|
}
|
|
134485
134476
|
let meta3 = null;
|
|
134486
134477
|
try {
|
|
134487
|
-
meta3 = await readAssetMeta(dir, metaFilePath(
|
|
134478
|
+
meta3 = await readAssetMeta(dir, metaFilePath(entry2.path));
|
|
134488
134479
|
} catch (err) {
|
|
134489
134480
|
if (!(err instanceof FileReadError)) throw err;
|
|
134490
134481
|
}
|
|
134491
134482
|
if (globals.json) {
|
|
134492
|
-
console.log(JSON.stringify({ ...
|
|
134483
|
+
console.log(JSON.stringify({ ...entry2, meta: meta3 }, null, 2));
|
|
134493
134484
|
} else {
|
|
134494
|
-
console.log(`Asset ID: ${
|
|
134495
|
-
console.log(`Path: ${
|
|
134496
|
-
console.log(`Type: ${
|
|
134497
|
-
console.log(`Content Hash: ${
|
|
134498
|
-
console.log(`Server ID: ${
|
|
134499
|
-
console.log(`URL: ${
|
|
134485
|
+
console.log(`Asset ID: ${entry2.assetId}`);
|
|
134486
|
+
console.log(`Path: ${entry2.path}`);
|
|
134487
|
+
console.log(`Type: ${entry2.type}`);
|
|
134488
|
+
console.log(`Content Hash: ${entry2.contentHash}`);
|
|
134489
|
+
console.log(`Server ID: ${entry2.serverId}`);
|
|
134490
|
+
console.log(`URL: ${entry2.url}`);
|
|
134500
134491
|
if (meta3) {
|
|
134501
134492
|
console.log(`Meta: ${JSON.stringify(meta3, null, 2)}`);
|
|
134502
134493
|
}
|
|
@@ -134508,8 +134499,8 @@ function registerAssetInfo(parent) {
|
|
|
134508
134499
|
init_local_project();
|
|
134509
134500
|
function buildTreeFromPaths(entries) {
|
|
134510
134501
|
const root2 = { name: "", children: [] };
|
|
134511
|
-
for (const
|
|
134512
|
-
const parts =
|
|
134502
|
+
for (const entry2 of Object.values(entries)) {
|
|
134503
|
+
const parts = entry2.path.split("/").filter(Boolean);
|
|
134513
134504
|
let current = root2;
|
|
134514
134505
|
for (let i = 0; i < parts.length; i++) {
|
|
134515
134506
|
const part = parts[i];
|
|
@@ -134517,7 +134508,7 @@ function buildTreeFromPaths(entries) {
|
|
|
134517
134508
|
if (!current.children) current.children = [];
|
|
134518
134509
|
let child = current.children.find((c) => c.name === part);
|
|
134519
134510
|
if (!child) {
|
|
134520
|
-
child = isLeaf ? { name: part, type:
|
|
134511
|
+
child = isLeaf ? { name: part, type: entry2.type } : { name: part, children: [] };
|
|
134521
134512
|
current.children.push(child);
|
|
134522
134513
|
}
|
|
134523
134514
|
if (!isLeaf) current = child;
|
|
@@ -134554,7 +134545,7 @@ function registerAssetTree(parent) {
|
|
|
134554
134545
|
}
|
|
134555
134546
|
|
|
134556
134547
|
// src/commands/build.ts
|
|
134557
|
-
var
|
|
134548
|
+
var import_node_path14 = __toESM(require("node:path"));
|
|
134558
134549
|
function parseKtx2Quality(raw) {
|
|
134559
134550
|
if (raw == null) return void 0;
|
|
134560
134551
|
const value = Number(raw);
|
|
@@ -134574,8 +134565,8 @@ function registerBuildCommand(program3) {
|
|
|
134574
134565
|
try {
|
|
134575
134566
|
const { buildProject: buildProject2 } = await Promise.resolve().then(() => (init_cli_builder(), cli_builder_exports));
|
|
134576
134567
|
await buildProject2({
|
|
134577
|
-
projectDir:
|
|
134578
|
-
output:
|
|
134568
|
+
projectDir: import_node_path14.default.resolve(dir),
|
|
134569
|
+
output: import_node_path14.default.resolve(cmdOpts.output),
|
|
134579
134570
|
ktx2: cmdOpts.ktx2 ?? false,
|
|
134580
134571
|
ktx2Mode: cmdOpts.ktx2Mode,
|
|
134581
134572
|
ktx2Quality,
|
|
@@ -134588,8 +134579,8 @@ function registerBuildCommand(program3) {
|
|
|
134588
134579
|
}
|
|
134589
134580
|
|
|
134590
134581
|
// src/commands/create.ts
|
|
134591
|
-
var
|
|
134592
|
-
var
|
|
134582
|
+
var import_promises12 = require("node:fs/promises");
|
|
134583
|
+
var import_node_path15 = __toESM(require("node:path"));
|
|
134593
134584
|
init_manifest();
|
|
134594
134585
|
init_meta_file();
|
|
134595
134586
|
init_path_tree();
|
|
@@ -134813,14 +134804,14 @@ function buildDefaultScene(platform) {
|
|
|
134813
134804
|
async function createProject(opts) {
|
|
134814
134805
|
const { name, platform = "3d", engineVersion = "1.6.0", force = false } = opts;
|
|
134815
134806
|
const outputDir = opts.outputDir ?? `./${slugify(name)}`;
|
|
134816
|
-
const absDir =
|
|
134817
|
-
await (0,
|
|
134807
|
+
const absDir = import_node_path15.default.resolve(outputDir);
|
|
134808
|
+
await (0, import_promises12.mkdir)(absDir, { recursive: true });
|
|
134818
134809
|
if (!force) {
|
|
134819
134810
|
await assertNodeDirectoryEmpty(absDir);
|
|
134820
134811
|
} else {
|
|
134821
134812
|
await resetNodeManagedProjectPaths(absDir);
|
|
134822
134813
|
}
|
|
134823
|
-
await (0,
|
|
134814
|
+
await (0, import_promises12.mkdir)(import_node_path15.default.join(absDir, ".galacean/cache"), { recursive: true });
|
|
134824
134815
|
const sceneJson = JSON.stringify(buildDefaultScene(platform), null, 2);
|
|
134825
134816
|
const sceneAsset = {
|
|
134826
134817
|
id: `local-${DEFAULT_SCENE_ID}`,
|
|
@@ -134834,24 +134825,24 @@ async function createProject(opts) {
|
|
|
134834
134825
|
const allAssets = [sceneAsset, ...BUILTIN_REMOTE_ASSETS];
|
|
134835
134826
|
const pathMap = buildLocalPathMap(allAssets);
|
|
134836
134827
|
const contentHashes = /* @__PURE__ */ new Map();
|
|
134837
|
-
for (const [,
|
|
134838
|
-
if (
|
|
134839
|
-
await (0,
|
|
134828
|
+
for (const [, entry2] of pathMap) {
|
|
134829
|
+
if (entry2.isFolder) {
|
|
134830
|
+
await (0, import_promises12.mkdir)(import_node_path15.default.join(absDir, entry2.localPath), { recursive: true });
|
|
134840
134831
|
}
|
|
134841
134832
|
}
|
|
134842
134833
|
const sceneEntry = pathMap.get(DEFAULT_SCENE_ID);
|
|
134843
|
-
await (0,
|
|
134834
|
+
await (0, import_promises12.writeFile)(import_node_path15.default.join(absDir, sceneEntry.localPath), sceneJson);
|
|
134844
134835
|
contentHashes.set(DEFAULT_SCENE_ID, md5Text(sceneJson));
|
|
134845
|
-
for (const [,
|
|
134846
|
-
const meta3 = generateMetaFile(
|
|
134847
|
-
const metaPath =
|
|
134848
|
-
await (0,
|
|
134849
|
-
await (0,
|
|
134836
|
+
for (const [, entry2] of pathMap) {
|
|
134837
|
+
const meta3 = generateMetaFile(entry2);
|
|
134838
|
+
const metaPath = import_node_path15.default.join(absDir, metaFilePath(entry2.localPath));
|
|
134839
|
+
await (0, import_promises12.mkdir)(import_node_path15.default.dirname(metaPath), { recursive: true });
|
|
134840
|
+
await (0, import_promises12.writeFile)(metaPath, JSON.stringify(meta3, null, 2));
|
|
134850
134841
|
}
|
|
134851
134842
|
const manifest = generateManifest(pathMap, contentHashes);
|
|
134852
|
-
await (0,
|
|
134843
|
+
await (0, import_promises12.writeFile)(import_node_path15.default.join(absDir, ".galacean/manifest.json"), JSON.stringify(manifest, null, 2));
|
|
134853
134844
|
const projectConfig = { name, platform, engineVersion, sceneId: DEFAULT_SCENE_ID };
|
|
134854
|
-
await (0,
|
|
134845
|
+
await (0, import_promises12.writeFile)(import_node_path15.default.join(absDir, "project.galacean"), JSON.stringify(projectConfig, null, 2));
|
|
134855
134846
|
return { outputDir };
|
|
134856
134847
|
}
|
|
134857
134848
|
function registerCreateCommand(program3) {
|
|
@@ -134863,12 +134854,12 @@ function registerCreateCommand(program3) {
|
|
|
134863
134854
|
engineVersion: options.engineVersion,
|
|
134864
134855
|
force: options.force
|
|
134865
134856
|
});
|
|
134866
|
-
console.log(`Project created at: ${
|
|
134857
|
+
console.log(`Project created at: ${import_node_path15.default.resolve(outputDir)}`);
|
|
134867
134858
|
});
|
|
134868
134859
|
}
|
|
134869
134860
|
|
|
134870
134861
|
// src/commands/exec.ts
|
|
134871
|
-
var
|
|
134862
|
+
var import_node_path16 = __toESM(require("node:path"));
|
|
134872
134863
|
var UNSUPPORTED_HEADLESS_TOOL_IDS = /* @__PURE__ */ new Set(["prefab.create", "prefab.instantiate", "grp.import"]);
|
|
134873
134864
|
var HEADLESS_TOOL_FOLLOWUP_ISSUES = {
|
|
134874
134865
|
"prefab.create": 3583,
|
|
@@ -134919,7 +134910,7 @@ async function execTool(options) {
|
|
|
134919
134910
|
}
|
|
134920
134911
|
const { HeadlessRoot: HeadlessRoot2 } = await Promise.resolve().then(() => (init_headless(), headless_exports));
|
|
134921
134912
|
const { loadDomainState: loadDomainState2, saveDomainState: saveDomainState2 } = await Promise.resolve().then(() => (init_domain_bridge(), domain_bridge_exports));
|
|
134922
|
-
const projectDir =
|
|
134913
|
+
const projectDir = import_node_path16.default.resolve(options.projectDir);
|
|
134923
134914
|
const { state, ctx } = await loadDomainState2(projectDir);
|
|
134924
134915
|
const root2 = new HeadlessRoot2(ctx.remoteProjectId, {
|
|
134925
134916
|
name: ctx.config.name,
|
|
@@ -134940,7 +134931,7 @@ function registerExecCommand(program3) {
|
|
|
134940
134931
|
program3.command("exec [toolId] [params]").description("Execute an editor-api tool on a local project").option("-p, --project <dir>", "project directory", ".").option("--list", "list all available tools").option("--schema <toolId>", "show tool input schema").option("--dry-run", "show what would change without saving").action(async (toolId, paramsStr, opts) => {
|
|
134941
134932
|
try {
|
|
134942
134933
|
const result = await execTool({
|
|
134943
|
-
projectDir:
|
|
134934
|
+
projectDir: import_node_path16.default.resolve(opts.project),
|
|
134944
134935
|
toolId,
|
|
134945
134936
|
params: paramsStr,
|
|
134946
134937
|
list: opts.list,
|
|
@@ -134960,13 +134951,13 @@ function registerExecCommand(program3) {
|
|
|
134960
134951
|
|
|
134961
134952
|
// src/cli-version.ts
|
|
134962
134953
|
var import_node_fs3 = require("node:fs");
|
|
134963
|
-
var
|
|
134954
|
+
var import_meta = {};
|
|
134964
134955
|
function readCliVersionFromPackageJson() {
|
|
134965
|
-
const raw = (0, import_node_fs3.readFileSync)(new URL("../package.json",
|
|
134956
|
+
const raw = (0, import_node_fs3.readFileSync)(new URL("../package.json", import_meta.url), "utf-8");
|
|
134966
134957
|
const parsed = JSON.parse(raw);
|
|
134967
134958
|
return typeof parsed.version === "string" && parsed.version.length > 0 ? parsed.version : "0.0.0";
|
|
134968
134959
|
}
|
|
134969
|
-
var CLI_VERSION = "0.0.1-alpha.
|
|
134960
|
+
var CLI_VERSION = "0.0.1-alpha.8".length > 0 ? "0.0.1-alpha.8" : readCliVersionFromPackageJson();
|
|
134970
134961
|
|
|
134971
134962
|
// src/push-output.ts
|
|
134972
134963
|
function printPushResult(result, options = {}) {
|
|
@@ -135015,7 +135006,7 @@ program2.command("init <projectId>").description("Initialize a project locally")
|
|
|
135015
135006
|
const globals = program2.optsWithGlobals();
|
|
135016
135007
|
const serverUrl = await getServerUrl(globals);
|
|
135017
135008
|
const token = getToken(globals);
|
|
135018
|
-
const outputDir = cmdOpts.output ?? cmdOpts.outputDir ??
|
|
135009
|
+
const outputDir = cmdOpts.output ?? cmdOpts.outputDir ?? import_node_path17.default.resolve(globals._config?.projectsDir ?? import_node_path17.default.join(import_node_os2.default.homedir(), ".galacean/workspace"), projectId);
|
|
135019
135010
|
await initProject({
|
|
135020
135011
|
projectId,
|
|
135021
135012
|
outputDir,
|
|
@@ -135031,7 +135022,7 @@ program2.command("pull [projectDir]").description("Pull remote changes to local"
|
|
|
135031
135022
|
const serverUrl = await getServerUrl(globals, dir);
|
|
135032
135023
|
const token = getToken(globals);
|
|
135033
135024
|
const result = await pullProject({
|
|
135034
|
-
projectDir:
|
|
135025
|
+
projectDir: import_node_path17.default.resolve(dir),
|
|
135035
135026
|
apiClient: new HttpSyncApiClient(serverUrl, token),
|
|
135036
135027
|
fs: new NodeFs()
|
|
135037
135028
|
});
|
|
@@ -135063,7 +135054,7 @@ program2.command("push [projectDir]").description("Push local changes to remote"
|
|
|
135063
135054
|
const serverUrl = await getServerUrl(globals, dir);
|
|
135064
135055
|
const token = getToken(globals);
|
|
135065
135056
|
const result = await pushProject({
|
|
135066
|
-
projectDir:
|
|
135057
|
+
projectDir: import_node_path17.default.resolve(dir),
|
|
135067
135058
|
apiClient: new HttpSyncApiClient(serverUrl, token),
|
|
135068
135059
|
fs: new NodeFs(),
|
|
135069
135060
|
serverUrl,
|
|
@@ -135076,7 +135067,7 @@ program2.command("watch [projectDir]").description("Watch for local changes and
|
|
|
135076
135067
|
const globals = program2.optsWithGlobals();
|
|
135077
135068
|
const serverUrl = await getServerUrl(globals, dir);
|
|
135078
135069
|
const token = getToken(globals);
|
|
135079
|
-
const absProjectDir =
|
|
135070
|
+
const absProjectDir = import_node_path17.default.resolve(dir);
|
|
135080
135071
|
const handle2 = watchProject({
|
|
135081
135072
|
projectDir: absProjectDir,
|
|
135082
135073
|
apiClient: new HttpSyncApiClient(serverUrl, token),
|
|
@@ -135090,7 +135081,7 @@ program2.command("watch [projectDir]").description("Watch for local changes and
|
|
|
135090
135081
|
console.error(err);
|
|
135091
135082
|
}
|
|
135092
135083
|
});
|
|
135093
|
-
console.log(`Watching ${
|
|
135084
|
+
console.log(`Watching ${import_node_path17.default.join(absProjectDir, "assets")} for changes...`);
|
|
135094
135085
|
console.log("Press Ctrl+C to stop");
|
|
135095
135086
|
await new Promise((resolve4) => {
|
|
135096
135087
|
const shutdown = () => {
|