@galacean/cli 2.0.0-alpha.7 → 2.0.0-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.
Files changed (2) hide show
  1. package/dist/cli.bundle.cjs +73 -32
  2. package/package.json +1 -1
@@ -88499,7 +88499,7 @@ var init_scene_parser = __esm({
88499
88499
  });
88500
88500
 
88501
88501
  // src/domain-bridge/load.ts
88502
- async function readLocalTextAsset(projectDir, entryPath, _entryUrl, label) {
88502
+ async function readLocalTextAsset(projectDir, entryPath, label) {
88503
88503
  try {
88504
88504
  return await import_promises8.default.readFile(`${projectDir}/${entryPath}`, "utf-8");
88505
88505
  } catch (error49) {
@@ -88588,19 +88588,19 @@ async function loadDomainState(projectDir) {
88588
88588
  throw new Error(`[domain-bridge] failed to parse scene file ${entry2.path}: ${errorMessage(error49)}`);
88589
88589
  }
88590
88590
  } else if (entry2.type === "script") {
88591
- const text2 = await readLocalTextAsset(projectDir, entry2.path, entry2.url, "script");
88591
+ const text2 = await readLocalTextAsset(projectDir, entry2.path, "script");
88592
88592
  if (text2 !== null)
88593
88593
  assetState.content = { code: text2 };
88594
88594
  } else if (entry2.type === "Prefab") {
88595
- const text2 = await readLocalTextAsset(projectDir, entry2.path, entry2.url, "prefab");
88595
+ const text2 = await readLocalTextAsset(projectDir, entry2.path, "prefab");
88596
88596
  if (text2 !== null)
88597
88597
  assetState.content = parseJsonWithPath(text2, entry2.path);
88598
88598
  } else if (entry2.type === "Shader" || entry2.type === "ShaderChunk") {
88599
- const text2 = await readLocalTextAsset(projectDir, entry2.path, entry2.url, entry2.type.toLowerCase());
88599
+ const text2 = await readLocalTextAsset(projectDir, entry2.path, entry2.type.toLowerCase());
88600
88600
  if (text2 !== null)
88601
88601
  assetState.content = { source: text2 };
88602
88602
  } else if (entry2.type === "Material") {
88603
- const text2 = await readLocalTextAsset(projectDir, entry2.path, entry2.url, "material");
88603
+ const text2 = await readLocalTextAsset(projectDir, entry2.path, "material");
88604
88604
  if (text2 !== null) {
88605
88605
  const matData = parseJsonWithPath(text2, entry2.path);
88606
88606
  const props = extractMaterialProps(matData);
@@ -109470,7 +109470,7 @@ var init_schema10 = __esm({
109470
109470
  textureType: textureTypeEnum.optional().default("Texture").describe("\u7EB9\u7406\u7C7B\u578B\uFF0C\u9ED8\u8BA4 Texture2D"),
109471
109471
  folderId: external_exports.string().optional().describe("\u76EE\u6807\u6587\u4EF6\u5939 ID\uFF0C\u7701\u7565\u5219\u521B\u5EFA\u5728\u6839\u76EE\u5F55"),
109472
109472
  // 纹理来源(三选一)
109473
- url: external_exports.string().url().optional().describe("\u7EB9\u7406 URL \u5730\u5740"),
109473
+ url: external_exports.string().min(1).optional().describe("\u7EB9\u7406 URL \u6216\u672C\u5730\u6587\u4EF6\u8DEF\u5F84"),
109474
109474
  base64: external_exports.string().max(FILE_SIZE_LIMITS.MAX_BASE64_STRING_LENGTH).optional().describe(`Base64 \u7F16\u7801\u7684\u56FE\u7247\u6570\u636E\uFF08\u6700\u5927 ${FILE_SIZE_LIMITS.MAX_BASE64_IMAGE_SIZE / 1024 / 1024}MB\uFF09`),
109475
109475
  // 纹理设置
109476
109476
  filterMode: textureFilterModeEnum.optional().describe("\u8FC7\u6EE4\u6A21\u5F0F"),
@@ -109630,12 +109630,42 @@ var init_upload_helpers = __esm({
109630
109630
  });
109631
109631
 
109632
109632
  // ../editor-api/src/tools/asset/texture/create.ts
109633
- async function fetchImageBlob(url2) {
109634
- validateImageUrl(url2);
109633
+ function isUrl(input) {
109634
+ return /^https?:\/\/|^data:/i.test(input);
109635
+ }
109636
+ async function fetchImageBlob(urlOrPath) {
109637
+ if (!isUrl(urlOrPath)) {
109638
+ const { readFile: readFile5 } = await import("node:fs/promises");
109639
+ const { resolve: resolve5, extname: extname4 } = await import("node:path");
109640
+ const resolved = resolve5(urlOrPath);
109641
+ let buf;
109642
+ try {
109643
+ buf = await readFile5(resolved);
109644
+ } catch (e5) {
109645
+ throw new EditorAPIError("OPERATION_FAILED", `\u65E0\u6CD5\u8BFB\u53D6\u672C\u5730\u56FE\u7247: ${resolved} (${e5.code || e5.message})`);
109646
+ }
109647
+ const ext = extname4(resolved).toLowerCase();
109648
+ const mimeMap = {
109649
+ ".png": "image/png",
109650
+ ".jpg": "image/jpeg",
109651
+ ".jpeg": "image/jpeg",
109652
+ ".webp": "image/webp",
109653
+ ".gif": "image/gif",
109654
+ ".svg": "image/svg+xml",
109655
+ ".hdr": "image/vnd.radiance"
109656
+ };
109657
+ const mime = mimeMap[ext];
109658
+ if (!mime) {
109659
+ throw new EditorAPIError("INVALID_PARAMETER", `\u4E0D\u652F\u6301\u7684\u56FE\u7247\u683C\u5F0F: ${ext}`);
109660
+ }
109661
+ const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
109662
+ return new Blob([ab], { type: mime });
109663
+ }
109664
+ validateImageUrl(urlOrPath);
109635
109665
  const controller = new AbortController();
109636
109666
  const timeoutId = setTimeout(() => controller.abort(), NETWORK_SETTINGS.DEFAULT_TIMEOUT);
109637
109667
  try {
109638
- const response = await fetch(url2, {
109668
+ const response = await fetch(urlOrPath, {
109639
109669
  signal: controller.signal,
109640
109670
  redirect: "error"
109641
109671
  // 禁止跟随重定向到不安全的地址
@@ -211135,9 +211165,6 @@ var init_en2 = __esm({
211135
211165
  lottie: {
211136
211166
  title: "Lottie"
211137
211167
  },
211138
- texture: {
211139
- title: "Texture"
211140
- },
211141
211168
  "spine-skeleton-data": {
211142
211169
  title: "Spine Skeleton Data"
211143
211170
  },
@@ -214559,9 +214586,6 @@ var init_zh = __esm({
214559
214586
  lottie: {
214560
214587
  title: "Lottie"
214561
214588
  },
214562
- texture: {
214563
- title: "\u7EB9\u7406"
214564
- },
214565
214589
  "spine-skeleton-data": {
214566
214590
  title: "Spine\u9AA8\u9ABC\u6570\u636E"
214567
214591
  },
@@ -217996,9 +218020,6 @@ var init_ja2 = __esm({
217996
218020
  lottie: {
217997
218021
  title: "Lottie"
217998
218022
  },
217999
- texture: {
218000
- title: "\u30C6\u30AF\u30B9\u30C1\u30E3"
218001
- },
218002
218023
  "spine-skeleton-data": {
218003
218024
  title: "Spine\u30B9\u30B1\u30EB\u30C8\u30F3\u30C7\u30FC\u30BF"
218004
218025
  },
@@ -323046,6 +323067,8 @@ var init_HeadlessAssetProxy = __esm({
323046
323067
  }
323047
323068
  async ensureReady() {
323048
323069
  }
323070
+ async collectDependencies() {
323071
+ }
323049
323072
  async flushPendingSave() {
323050
323073
  }
323051
323074
  /**
@@ -323121,11 +323144,12 @@ var init_HeadlessAssetProxy = __esm({
323121
323144
  scale: { ...e5.transform.scale }
323122
323145
  }
323123
323146
  },
323124
- components: Object.entries(e5.components).map(([id, c5]) => ({
323125
- id,
323126
- class: c5.type,
323127
- props: { ...c5.props }
323128
- })),
323147
+ components: Object.entries(e5.components).map(([id, c5]) => {
323148
+ const comp = { id, class: c5.type, props: { ...c5.props } };
323149
+ if (c5.methods && Object.keys(c5.methods).length > 0)
323150
+ comp.methods = { ...c5.methods };
323151
+ return comp;
323152
+ }),
323129
323153
  ...overrides
323130
323154
  };
323131
323155
  };
@@ -334620,6 +334644,27 @@ async function createContainerFolder(packageName, assetFacade) {
334620
334644
  }
334621
334645
  return folder.id;
334622
334646
  }
334647
+ function isUrl2(input) {
334648
+ return /^https?:\/\/|^data:/i.test(input);
334649
+ }
334650
+ async function readGrpZip(urlOrPath) {
334651
+ if (isUrl2(urlOrPath)) {
334652
+ const response = await fetch(urlOrPath);
334653
+ if (!response.ok) {
334654
+ throw new EditorAPIError("OPERATION_FAILED", `Failed to fetch GRP: ${response.status} ${response.statusText}`);
334655
+ }
334656
+ return response.arrayBuffer();
334657
+ }
334658
+ const { readFile: readFile5 } = await import("node:fs/promises");
334659
+ const { resolve: resolve5 } = await import("node:path");
334660
+ const resolved = resolve5(urlOrPath);
334661
+ try {
334662
+ const buf = await readFile5(resolved);
334663
+ return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
334664
+ } catch (e5) {
334665
+ throw new EditorAPIError("OPERATION_FAILED", `Failed to read local GRP file: ${resolved} (${e5.code || e5.message})`);
334666
+ }
334667
+ }
334623
334668
  var import_jszip, manifestSchema, grpImportInputSchema, grpImportOutputSchema, grpImport;
334624
334669
  var init_import = __esm({
334625
334670
  "../editor-api/src/tools/grp/import.ts"() {
@@ -334666,7 +334711,7 @@ var init_import = __esm({
334666
334711
  }).optional()
334667
334712
  });
334668
334713
  grpImportInputSchema = external_exports.object({
334669
- url: external_exports.string().url().describe("GRP \u5305\u7684 CDN URL")
334714
+ source: external_exports.string().min(1).describe("GRP \u5305\u7684 URL \u6216\u672C\u5730\u6587\u4EF6\u8DEF\u5F84")
334670
334715
  });
334671
334716
  grpImportOutputSchema = external_exports.object({
334672
334717
  success: external_exports.boolean(),
@@ -334682,13 +334727,9 @@ var init_import = __esm({
334682
334727
  output: grpImportOutputSchema,
334683
334728
  handler: async (params, ctx) => {
334684
334729
  const { assetFacade, assetStore } = ctx;
334685
- const { url: url2 } = params;
334730
+ const { source } = params;
334686
334731
  try {
334687
- const response = await fetch(url2);
334688
- if (!response.ok) {
334689
- throw new EditorAPIError("OPERATION_FAILED", `Failed to fetch GRP: ${response.status} ${response.statusText}`);
334690
- }
334691
- const zipData = await response.arrayBuffer();
334732
+ const zipData = await readGrpZip(source);
334692
334733
  const zip = await import_jszip.default.loadAsync(zipData);
334693
334734
  const manifestFile = zip.file("manifest.json");
334694
334735
  if (!manifestFile) {
@@ -334703,7 +334744,7 @@ var init_import = __esm({
334703
334744
  );
334704
334745
  }
334705
334746
  const manifest = parseResult.data;
334706
- const packageName = extractPackageName(url2);
334747
+ const packageName = extractPackageName(source);
334707
334748
  const containerFolderId = await createContainerFolder(packageName, assetFacade);
334708
334749
  const isCdnMode = manifest.mode === "cdn";
334709
334750
  const files = /* @__PURE__ */ new Map();
@@ -352736,7 +352777,7 @@ function readCliVersionFromPackageJson() {
352736
352777
  const parsed = JSON.parse(raw);
352737
352778
  return typeof parsed.version === "string" && parsed.version.length > 0 ? parsed.version : "0.0.0";
352738
352779
  }
352739
- var CLI_VERSION = "2.0.0-alpha.7".length > 0 ? "2.0.0-alpha.7" : readCliVersionFromPackageJson();
352780
+ var CLI_VERSION = "2.0.0-alpha.8".length > 0 ? "2.0.0-alpha.8" : readCliVersionFromPackageJson();
352740
352781
 
352741
352782
  // src/cli.ts
352742
352783
  init_config();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/cli",
3
- "version": "2.0.0-alpha.7",
3
+ "version": "2.0.0-alpha.8",
4
4
  "main": "dist/cli.bundle.cjs",
5
5
  "bin": {
6
6
  "galacean": "bin/galacean.js"