@arcadia-eternity/content-sdk 4.9.1 → 4.10.0

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.
@@ -12,11 +12,18 @@ import { withSourceLock } from './source-lock.js';
12
12
  import { contentError, readJson, materialFiles, writeMaterials } from './workspace-materials.js';
13
13
  import { errorCode, isRecord } from './types.js';
14
14
  import { compactMaterials, expandSharedMaterials, exportDependencies, } from './environment-sharing.js';
15
- import { environmentShareMaterials } from './environment-host-base.js';
15
+ import { environmentShareMaterials, hostBaseName } from './environment-host-base.js';
16
16
  export { copyEnvironmentMember } from './environment-member-transfer.js';
17
17
  import { parseManifestDraft, preparedDocument } from './prepared-document.js';
18
18
  export { readInstalledEnvironmentDocument } from './prepared-document.js';
19
19
  export { normalizeEnvironmentDocument } from './debug-environments.js';
20
+ function hasHostBase(document) {
21
+ return Object.hasOwn(document.packages, hostBaseName) || document.sources.includes(hostBaseName);
22
+ }
23
+ function assertBaseRetained(before, after) {
24
+ if (before && hasHostBase(before) && !hasHostBase(after))
25
+ throw contentError('ENVIRONMENT_BASE_REQUIRED', '环境必须保留官方基础包。');
26
+ }
20
27
  const compositionSchema = z
21
28
  .object({
22
29
  rules: EnvironmentRulesSchema,
@@ -350,6 +357,8 @@ class ContentWorkspaceImplementation {
350
357
  });
351
358
  if ((previous === null ? null : sha256Hex(previous)) !== input.expectedRevision)
352
359
  throw contentError('REVISION_CONFLICT');
360
+ if (previous !== null)
361
+ assertBaseRetained(parseManifestDraft(previous).document, document);
353
362
  await regularDirectory(directory);
354
363
  await this.#archiveRemovedDeclarations(document.id);
355
364
  if (previous !== null) {
@@ -451,6 +460,7 @@ class ContentWorkspaceImplementation {
451
460
  const document = normalizeEnvironmentDocument(input.document ?? draft?.document);
452
461
  if (document.id !== input.environmentId)
453
462
  throw contentError('ENVIRONMENT_ID_MISMATCH');
463
+ assertBaseRetained(draft?.document, document);
454
464
  const source = input.projectDirectory ??
455
465
  input.directory ??
456
466
  input.seedDirectory ??
@@ -479,15 +489,14 @@ class ContentWorkspaceImplementation {
479
489
  }
480
490
  await writeMaterials(staging, materials, limits);
481
491
  const manifest = await readJson(join(staging, 'package.json'));
482
- const base = '@arcadia-eternity/data-pack-base';
483
- if (Object.hasOwn(document.packages, base) || document.sources.includes(base)) {
484
- const installed = await readJson(join(staging, 'node_modules', base, 'package.json'));
492
+ if (hasHostBase(document)) {
493
+ const installed = await readJson(join(staging, 'node_modules', hostBaseName, 'package.json'));
485
494
  if (typeof installed.version !== 'string')
486
495
  throw contentError('BUNDLED_PACKAGE_INVALID');
487
496
  document = {
488
497
  ...document,
489
- packages: { ...document.packages, [base]: installed.version },
490
- sources: document.sources.filter(name => name !== base),
498
+ packages: { ...document.packages, [hostBaseName]: installed.version },
499
+ sources: document.sources.filter(name => name !== hostBaseName),
491
500
  };
492
501
  }
493
502
  await writeFile(join(staging, 'package.json'), json({ ...this.#manifest(document, manifest), dependencies: manifest.dependencies ?? {} }));
@@ -819,6 +828,7 @@ class ContentWorkspaceImplementation {
819
828
  });
820
829
  if ((previous?.revision ?? null) !== (input.expectedRevision ?? null))
821
830
  throw contentError('REVISION_CONFLICT');
831
+ assertBaseRetained(previous?.document, document);
822
832
  const staging = join(this.root, 'staging', `import-${randomUUID()}`);
823
833
  await mkdir(staging);
824
834
  try {
@@ -1033,6 +1043,8 @@ async function changeEnvironmentPackage(workspace, input) {
1033
1043
  changed = true;
1034
1044
  }
1035
1045
  }
1046
+ if (affected.has(hostBaseName))
1047
+ throw contentError('ENVIRONMENT_BASE_REQUIRED', '环境必须保留官方基础包。');
1036
1048
  const roots = [...active].filter(key => affected.has(key));
1037
1049
  if (!roots.length)
1038
1050
  throw contentError('ENVIRONMENT_PACKAGE_NOT_FOUND');
@@ -1,4 +1,5 @@
1
1
  import type { EnvironmentDocumentV2 } from './debug-environments.js';
2
+ export declare const hostBaseName = "@arcadia-eternity/data-pack-base";
2
3
  type Material = {
3
4
  path: string;
4
5
  bytes: Buffer;
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
3
3
  import { readFile } from 'node:fs/promises';
4
4
  import { withShippedEnvironmentProject, withShippedCatalogArchive } from '@arcadia-eternity/pack-loader/node';
5
5
  import { contentError, materialFiles } from './workspace-materials.js';
6
- const hostBaseName = '@arcadia-eternity/data-pack-base';
6
+ export const hostBaseName = '@arcadia-eternity/data-pack-base';
7
7
  const baseLocation = 'node_modules/' + hostBaseName;
8
8
  export function isBaseMaterial(path) {
9
9
  return ('/' + path.toLowerCase() + '/').includes('/' + baseLocation + '/');
@@ -21,7 +21,7 @@
21
21
  "devDependencies": {
22
22
  "@types/node": "26.6.6",
23
23
  "typescript": "6.0.3",
24
- "@arcadia-eternity/content-sdk": "4.9.1",
24
+ "@arcadia-eternity/content-sdk": "4.10.0",
25
25
  "fflate": "0.8.3"
26
26
  },
27
27
  "arcadia": {
@@ -38,6 +38,6 @@
38
38
  "license": "MIT",
39
39
  "engines": {
40
40
  "node": ">=24 <25",
41
- "arcadia": "^4.9.1"
41
+ "arcadia": "^4.10.0"
42
42
  }
43
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcadia-eternity/content-sdk",
3
- "version": "4.9.1",
3
+ "version": "4.10.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -63,10 +63,10 @@
63
63
  "zod": "4.6.7",
64
64
  "fflate": "0.8.3",
65
65
  "simple-git": "4.1.0",
66
- "@arcadia-eternity/battle": "4.9.1",
67
- "@arcadia-eternity/pack-loader": "4.9.1",
68
- "@arcadia-eternity/schema": "4.9.1",
69
- "@arcadia-eternity/const": "4.9.1"
66
+ "@arcadia-eternity/battle": "4.10.0",
67
+ "@arcadia-eternity/const": "4.10.0",
68
+ "@arcadia-eternity/pack-loader": "4.10.0",
69
+ "@arcadia-eternity/schema": "4.10.0"
70
70
  },
71
71
  "repository": {
72
72
  "type": "git",