minerender 2.1.0-alpha.90 → 2.1.0-alpha.92

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.
@@ -3155,6 +3155,19 @@ declare class ChunkData {
3155
3155
  }
3156
3156
 
3157
3157
  type RegionInput = Uint8Array | ArrayBuffer;
3158
+ /** Reads `c.<x>.<z>.mcc` at absolute chunk coordinates, or returns `undefined` when the file is missing. */
3159
+ type AnvilExternalChunkReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
3160
+ interface AnvilParseOptions {
3161
+ /** Region coordinates from `r.<x>.<z>.mca`, required when reading external chunks. */
3162
+ region?: {
3163
+ x: number;
3164
+ z: number;
3165
+ };
3166
+ /** Reads external chunk payloads without their region-file header. */
3167
+ readExternalChunk?: AnvilExternalChunkReader;
3168
+ /** Cancels parsing and forwards the signal to external chunk reads. */
3169
+ signal?: AbortSignal;
3170
+ }
3158
3171
  /** Chunk columns decoded from an Anvil region file. */
3159
3172
  interface AnvilRegion {
3160
3173
  chunks: AnvilChunk[];
@@ -3177,15 +3190,16 @@ declare class AnvilParser {
3177
3190
  x: number;
3178
3191
  z: number;
3179
3192
  }[];
3180
- /** Decodes all stored chunks. Gzip, zlib, and uncompressed payloads are supported. */
3181
- static parse(data: RegionInput): Promise<AnvilRegion>;
3193
+ /** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
3194
+ static parse(data: RegionInput, options?: AnvilParseOptions): Promise<AnvilRegion>;
3182
3195
  /**
3183
3196
  * Decodes one chunk for {@link MineRenderWorld.placeChunk}.
3184
3197
  * @param localX - Chunk x within the region, from 0 to 31.
3185
3198
  * @param localZ - Chunk z within the region, from 0 to 31.
3186
3199
  * @returns The chunk with absolute coordinates, or `undefined` if the region has no chunk there.
3187
3200
  */
3188
- static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
3201
+ static parseChunk(data: RegionInput, localX: number, localZ: number, options?: AnvilParseOptions): Promise<AnvilChunk | undefined>;
3202
+ private static abortable;
3189
3203
  private static bytes;
3190
3204
  private static locations;
3191
3205
  private static readChunk;
@@ -3206,8 +3220,10 @@ interface WorldChunkSource {
3206
3220
  * Forward `signal` to file or network I/O; it aborts when every caller waiting for the region cancels.
3207
3221
  */
3208
3222
  type AnvilRegionReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
3209
- /** Cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
3223
+ /** Readers and cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
3210
3224
  interface AnvilWorldSourceOptions {
3225
+ /** Reads external `c.<x>.<z>.mcc` payloads at absolute chunk coordinates in the same dimension. */
3226
+ readExternalChunk?: AnvilExternalChunkReader;
3211
3227
  /** Maximum cached regions, including missing regions. Defaults to 4; 0 disables caching. */
3212
3228
  maxCachedRegions?: number;
3213
3229
  /** Maximum retained region bytes. Defaults to 64 MiB; larger regions are read without caching. */
@@ -3220,6 +3236,7 @@ declare class AnvilWorldSource implements WorldChunkSource {
3220
3236
  private readonly pending;
3221
3237
  private readonly maxCachedRegions;
3222
3238
  private readonly maxCachedBytes;
3239
+ private readonly readExternalChunk?;
3223
3240
  private cachedBytes;
3224
3241
  constructor(readRegion: AnvilRegionReader, options?: AnvilWorldSourceOptions);
3225
3242
  /** Decodes one column at absolute chunk coordinates. Aborting a caller leaves other shared readers active. */
@@ -3576,4 +3593,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
3576
3593
  */
3577
3594
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
3578
3595
 
3579
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionGeometryInput, type SectionGeometryPage, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
3596
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionGeometryInput, type SectionGeometryPage, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
@@ -3155,6 +3155,19 @@ declare class ChunkData {
3155
3155
  }
3156
3156
 
3157
3157
  type RegionInput = Uint8Array | ArrayBuffer;
3158
+ /** Reads `c.<x>.<z>.mcc` at absolute chunk coordinates, or returns `undefined` when the file is missing. */
3159
+ type AnvilExternalChunkReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
3160
+ interface AnvilParseOptions {
3161
+ /** Region coordinates from `r.<x>.<z>.mca`, required when reading external chunks. */
3162
+ region?: {
3163
+ x: number;
3164
+ z: number;
3165
+ };
3166
+ /** Reads external chunk payloads without their region-file header. */
3167
+ readExternalChunk?: AnvilExternalChunkReader;
3168
+ /** Cancels parsing and forwards the signal to external chunk reads. */
3169
+ signal?: AbortSignal;
3170
+ }
3158
3171
  /** Chunk columns decoded from an Anvil region file. */
3159
3172
  interface AnvilRegion {
3160
3173
  chunks: AnvilChunk[];
@@ -3177,15 +3190,16 @@ declare class AnvilParser {
3177
3190
  x: number;
3178
3191
  z: number;
3179
3192
  }[];
3180
- /** Decodes all stored chunks. Gzip, zlib, and uncompressed payloads are supported. */
3181
- static parse(data: RegionInput): Promise<AnvilRegion>;
3193
+ /** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
3194
+ static parse(data: RegionInput, options?: AnvilParseOptions): Promise<AnvilRegion>;
3182
3195
  /**
3183
3196
  * Decodes one chunk for {@link MineRenderWorld.placeChunk}.
3184
3197
  * @param localX - Chunk x within the region, from 0 to 31.
3185
3198
  * @param localZ - Chunk z within the region, from 0 to 31.
3186
3199
  * @returns The chunk with absolute coordinates, or `undefined` if the region has no chunk there.
3187
3200
  */
3188
- static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
3201
+ static parseChunk(data: RegionInput, localX: number, localZ: number, options?: AnvilParseOptions): Promise<AnvilChunk | undefined>;
3202
+ private static abortable;
3189
3203
  private static bytes;
3190
3204
  private static locations;
3191
3205
  private static readChunk;
@@ -3206,8 +3220,10 @@ interface WorldChunkSource {
3206
3220
  * Forward `signal` to file or network I/O; it aborts when every caller waiting for the region cancels.
3207
3221
  */
3208
3222
  type AnvilRegionReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
3209
- /** Cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
3223
+ /** Readers and cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
3210
3224
  interface AnvilWorldSourceOptions {
3225
+ /** Reads external `c.<x>.<z>.mcc` payloads at absolute chunk coordinates in the same dimension. */
3226
+ readExternalChunk?: AnvilExternalChunkReader;
3211
3227
  /** Maximum cached regions, including missing regions. Defaults to 4; 0 disables caching. */
3212
3228
  maxCachedRegions?: number;
3213
3229
  /** Maximum retained region bytes. Defaults to 64 MiB; larger regions are read without caching. */
@@ -3220,6 +3236,7 @@ declare class AnvilWorldSource implements WorldChunkSource {
3220
3236
  private readonly pending;
3221
3237
  private readonly maxCachedRegions;
3222
3238
  private readonly maxCachedBytes;
3239
+ private readonly readExternalChunk?;
3223
3240
  private cachedBytes;
3224
3241
  constructor(readRegion: AnvilRegionReader, options?: AnvilWorldSourceOptions);
3225
3242
  /** Decodes one column at absolute chunk coordinates. Aborting a caller leaves other shared readers active. */
@@ -3576,4 +3593,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
3576
3593
  */
3577
3594
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
3578
3595
 
3579
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionGeometryInput, type SectionGeometryPage, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
3596
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionGeometryInput, type SectionGeometryPage, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
@@ -29066,17 +29066,138 @@ var ChunkData = class _ChunkData {
29066
29066
  }
29067
29067
  };
29068
29068
 
29069
+ // src/world/_compression/Lz4.ts
29070
+ init_MineRenderError();
29071
+ function decodeAnvilLz4(data) {
29072
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
29073
+ const blocks = [];
29074
+ let cursor = 0, totalSize = 0;
29075
+ while (true) {
29076
+ if (cursor + 21 > data.length) throw invalid("truncated block header or missing terminator");
29077
+ if (view.getUint32(cursor) !== 1280980034 || view.getUint32(cursor + 4) !== 1819239275) {
29078
+ throw invalid("invalid block signature");
29079
+ }
29080
+ const token = data[cursor + 8];
29081
+ const method = token & 240;
29082
+ const size = view.getInt32(cursor + 9, true);
29083
+ const decodedSize = view.getInt32(cursor + 13, true);
29084
+ const checksum = view.getUint32(cursor + 17, true);
29085
+ cursor += 21;
29086
+ if (method !== 16 && method !== 32) throw invalid("unsupported block method");
29087
+ if (size < 0 || decodedSize < 0 || decodedSize > 2 ** (10 + (token & 15)) || size === 0 !== (decodedSize === 0) || method === 16 && size !== decodedSize) {
29088
+ throw invalid("invalid block lengths");
29089
+ }
29090
+ if (size === 0) {
29091
+ if (checksum !== 0 || cursor !== data.length) throw invalid("invalid terminator or trailing bytes");
29092
+ break;
29093
+ }
29094
+ if (cursor + size > data.length || decodedSize > size * 255) throw invalid("invalid block lengths");
29095
+ blocks.push({ start: cursor, size, decodedSize, raw: method === 16, checksum });
29096
+ totalSize += decodedSize;
29097
+ cursor += size;
29098
+ }
29099
+ const output = new Uint8Array(totalSize);
29100
+ let offset = 0;
29101
+ for (const block of blocks) {
29102
+ const source = data.subarray(block.start, block.start + block.size);
29103
+ const target = output.subarray(offset, offset + block.decodedSize);
29104
+ if (block.raw) target.set(source);
29105
+ else decodeBlock(source, target);
29106
+ if (checksum32(target) !== block.checksum) throw invalid("block checksum mismatch");
29107
+ offset += block.decodedSize;
29108
+ }
29109
+ return output;
29110
+ }
29111
+ function decodeBlock(source, target) {
29112
+ let input = 0, output = 0, matched = false;
29113
+ const length = (nibble) => {
29114
+ let value = nibble;
29115
+ if (value === 15) {
29116
+ let extension;
29117
+ do {
29118
+ if (input === source.length) throw invalid("truncated sequence length");
29119
+ extension = source[input++];
29120
+ value += extension;
29121
+ } while (extension === 255);
29122
+ }
29123
+ return value;
29124
+ };
29125
+ while (input < source.length) {
29126
+ const token = source[input++];
29127
+ const literals = length(token >>> 4);
29128
+ if (input + literals > source.length || output + literals > target.length) {
29129
+ throw invalid("literal sequence exceeds block bounds");
29130
+ }
29131
+ target.set(source.subarray(input, input + literals), output);
29132
+ input += literals;
29133
+ output += literals;
29134
+ if (input === source.length) {
29135
+ if (output !== target.length || matched && literals < 5) throw invalid("invalid final literal sequence");
29136
+ return;
29137
+ }
29138
+ if (input + 2 > source.length) throw invalid("truncated match offset");
29139
+ const distance = source[input] | source[input + 1] << 8;
29140
+ input += 2;
29141
+ if (distance === 0 || distance > output) throw invalid("match offset exceeds block history");
29142
+ const count = length(token & 15) + 4;
29143
+ if (output > target.length - 12 || output + count > target.length - 5) {
29144
+ throw invalid("match exceeds block bounds");
29145
+ }
29146
+ for (let end = output + count; output < end; output++) target[output] = target[output - distance];
29147
+ matched = true;
29148
+ }
29149
+ throw invalid("missing final literal sequence");
29150
+ }
29151
+ function checksum32(data) {
29152
+ const prime1 = 2654435761, prime2 = 2246822519, prime3 = 3266489917, prime4 = 668265263, prime5 = 374761393;
29153
+ const seed = 2538058380;
29154
+ const rotate = (value, bits) => value << bits | value >>> 32 - bits;
29155
+ const round = (value, word) => Math.imul(rotate(value + Math.imul(word, prime2), 13), prime1);
29156
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
29157
+ let cursor = 0, hash;
29158
+ if (data.length >= 16) {
29159
+ let a = seed + prime1 + prime2, b = seed + prime2, c = seed, d = seed - prime1;
29160
+ while (cursor + 16 <= data.length) {
29161
+ a = round(a, view.getUint32(cursor, true));
29162
+ b = round(b, view.getUint32(cursor + 4, true));
29163
+ c = round(c, view.getUint32(cursor + 8, true));
29164
+ d = round(d, view.getUint32(cursor + 12, true));
29165
+ cursor += 16;
29166
+ }
29167
+ hash = rotate(a, 1) + rotate(b, 7) + rotate(c, 12) + rotate(d, 18);
29168
+ } else {
29169
+ hash = seed + prime5;
29170
+ }
29171
+ hash += data.length;
29172
+ while (cursor + 4 <= data.length) {
29173
+ hash = Math.imul(rotate(hash + Math.imul(view.getUint32(cursor, true), prime3), 17), prime4);
29174
+ cursor += 4;
29175
+ }
29176
+ while (cursor < data.length) {
29177
+ hash = Math.imul(rotate(hash + Math.imul(data[cursor++], prime5), 11), prime1);
29178
+ }
29179
+ hash = Math.imul(hash ^ hash >>> 15, prime2);
29180
+ hash = Math.imul(hash ^ hash >>> 13, prime3);
29181
+ return (hash ^ hash >>> 16) & 268435455;
29182
+ }
29183
+ function invalid(detail) {
29184
+ return new MineRenderError(`Invalid Anvil LZ4 stream: ${detail}`);
29185
+ }
29186
+
29069
29187
  // src/world/AnvilParser.ts
29070
29188
  var AnvilParser = class {
29071
29189
  /** Lists occupied chunk positions within the region, using local coordinates from 0 to 31. */
29072
29190
  static getChunkList(data) {
29073
29191
  return this.locations(this.bytes(data)).map(({ x, z }) => ({ x, z }));
29074
29192
  }
29075
- /** Decodes all stored chunks. Gzip, zlib, and uncompressed payloads are supported. */
29076
- static async parse(data) {
29193
+ /** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
29194
+ static async parse(data, options = {}) {
29195
+ options.signal?.throwIfAborted();
29077
29196
  const bytes = this.bytes(data);
29078
29197
  const chunks = [];
29079
- for (const location of this.locations(bytes)) chunks.push(await this.readChunk(bytes, location));
29198
+ for (const location of this.locations(bytes)) {
29199
+ chunks.push(await this.abortable(this.readChunk(bytes, location, options), options.signal));
29200
+ }
29080
29201
  return { chunks };
29081
29202
  }
29082
29203
  /**
@@ -29085,13 +29206,28 @@ var AnvilParser = class {
29085
29206
  * @param localZ - Chunk z within the region, from 0 to 31.
29086
29207
  * @returns The chunk with absolute coordinates, or `undefined` if the region has no chunk there.
29087
29208
  */
29088
- static async parseChunk(data, localX, localZ) {
29209
+ static async parseChunk(data, localX, localZ, options = {}) {
29210
+ options.signal?.throwIfAborted();
29089
29211
  if (![localX, localZ].every((value) => Number.isInteger(value) && value >= 0 && value < 32)) {
29090
29212
  throw new RangeError("Region-local chunk coordinates must be integers from 0 to 31");
29091
29213
  }
29092
29214
  const bytes = this.bytes(data);
29093
29215
  const location = this.locations(bytes).find(({ x, z }) => x === localX && z === localZ);
29094
- return location ? this.readChunk(bytes, location) : void 0;
29216
+ return location ? this.abortable(this.readChunk(bytes, location, options), options.signal) : void 0;
29217
+ }
29218
+ static async abortable(promise, signal) {
29219
+ if (!signal) return promise;
29220
+ let abort;
29221
+ const cancelled = new Promise((_, reject) => {
29222
+ abort = () => reject(signal.reason);
29223
+ signal.addEventListener("abort", abort, { once: true });
29224
+ if (signal.aborted) abort();
29225
+ });
29226
+ try {
29227
+ return await Promise.race([promise, cancelled]);
29228
+ } finally {
29229
+ signal.removeEventListener("abort", abort);
29230
+ }
29095
29231
  }
29096
29232
  static bytes(data) {
29097
29233
  return data instanceof Uint8Array ? data : new Uint8Array(data);
@@ -29117,18 +29253,41 @@ var AnvilParser = class {
29117
29253
  }
29118
29254
  return locations;
29119
29255
  }
29120
- static async readChunk(data, location) {
29121
- const compression = data[location.offset + 4];
29122
- if (compression & 128) throw new MineRenderError("External Anvil .mcc chunks are not supported");
29123
- if (compression !== 1 && compression !== 2 && compression !== 3) {
29124
- throw new MineRenderError(`Unsupported Anvil compression ${compression}${compression === 4 ? " (LZ4)" : ""}`);
29256
+ static async readChunk(data, location, options) {
29257
+ options.signal?.throwIfAborted();
29258
+ const format2 = data[location.offset + 4];
29259
+ const external = (format2 & 128) !== 0;
29260
+ const compression = format2 & 127;
29261
+ if (compression !== 1 && compression !== 2 && compression !== 3 && compression !== 4) {
29262
+ throw new MineRenderError(`Unsupported Anvil compression ${compression}`);
29125
29263
  }
29126
29264
  let payload = data.subarray(location.offset + 5, location.offset + 4 + location.length);
29127
- if (compression !== 3) {
29265
+ let expected;
29266
+ if (external) {
29267
+ if (!options.region || !options.readExternalChunk) {
29268
+ throw new MineRenderError("External Anvil .mcc chunks require region coordinates and readExternalChunk");
29269
+ }
29270
+ if (![options.region.x, options.region.z].every(Number.isSafeInteger)) {
29271
+ throw new RangeError("Anvil region coordinates must be safe integers");
29272
+ }
29273
+ expected = { x: options.region.x * 32 + location.x, z: options.region.z * 32 + location.z };
29274
+ if (![expected.x, expected.z].every(Number.isSafeInteger)) {
29275
+ throw new RangeError("External Anvil chunk coordinates must be safe integers");
29276
+ }
29277
+ const externalData = await options.readExternalChunk(expected.x, expected.z, options.signal);
29278
+ options.signal?.throwIfAborted();
29279
+ if (externalData === void 0) throw new MineRenderError(`External Anvil chunk c.${expected.x}.${expected.z}.mcc is missing`);
29280
+ payload = this.bytes(externalData);
29281
+ }
29282
+ if (compression === 4) {
29283
+ payload = decodeAnvilLz4(payload);
29284
+ } else if (compression !== 3) {
29128
29285
  const stream = new Blob([payload]).stream().pipeThrough(new DecompressionStream(compression === 1 ? "gzip" : "deflate"));
29129
29286
  payload = new Uint8Array(await new Response(stream).arrayBuffer());
29130
29287
  }
29288
+ options.signal?.throwIfAborted();
29131
29289
  const nbt = await NBTHelper.fromBuffer(payload, "big");
29290
+ options.signal?.throwIfAborted();
29132
29291
  const root = nbt.value;
29133
29292
  const level = root.Level?.type === "compound" ? root.Level.value : root;
29134
29293
  const dataVersion = root.DataVersion?.type === "int" ? root.DataVersion.value : void 0;
@@ -29141,6 +29300,9 @@ var AnvilParser = class {
29141
29300
  if ((chunk.x % 32 + 32) % 32 !== location.x || (chunk.z % 32 + 32) % 32 !== location.z) {
29142
29301
  throw new MineRenderError("Anvil chunk coordinates do not match its region location");
29143
29302
  }
29303
+ if (expected && (chunk.x !== expected.x || chunk.z !== expected.z)) {
29304
+ throw new MineRenderError(`Anvil chunk coordinates do not match external file c.${expected.x}.${expected.z}.mcc`);
29305
+ }
29144
29306
  for (const section of this.compounds(level.sections ?? level.Sections, "sections")) {
29145
29307
  const y = this.integer(section.Y, "section Y");
29146
29308
  if (section.Blocks || section.Data || section.Add) {
@@ -29272,6 +29434,7 @@ var AnvilWorldSource = class {
29272
29434
  this.cachedBytes = 0;
29273
29435
  this.maxCachedRegions = options.maxCachedRegions ?? 4;
29274
29436
  this.maxCachedBytes = options.maxCachedBytes ?? 64 * 1024 * 1024;
29437
+ this.readExternalChunk = options.readExternalChunk;
29275
29438
  for (const [name, value] of Object.entries({ maxCachedRegions: this.maxCachedRegions, maxCachedBytes: this.maxCachedBytes })) {
29276
29439
  if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`${name} must be a nonnegative safe integer`);
29277
29440
  }
@@ -29285,7 +29448,11 @@ var AnvilWorldSource = class {
29285
29448
  const data = await this.getRegion(regionX, regionZ, signal);
29286
29449
  signal?.throwIfAborted();
29287
29450
  if (!data) return void 0;
29288
- const chunk = await abortable2(AnvilParser.parseChunk(data, x - regionX * 32, z - regionZ * 32), signal);
29451
+ const chunk = await AnvilParser.parseChunk(data, x - regionX * 32, z - regionZ * 32, {
29452
+ region: { x: regionX, z: regionZ },
29453
+ readExternalChunk: this.readExternalChunk,
29454
+ signal
29455
+ });
29289
29456
  signal?.throwIfAborted();
29290
29457
  if (chunk && (chunk.x !== x || chunk.z !== z)) {
29291
29458
  throw new MineRenderError(`Anvil chunk coordinates ${chunk.x},${chunk.z} do not match requested column ${x},${z}`);
@@ -29316,7 +29483,7 @@ var AnvilWorldSource = class {
29316
29483
  settled: false,
29317
29484
  promise: Promise.resolve().then(() => {
29318
29485
  controller.signal.throwIfAborted();
29319
- return this.readRegion(x, z, controller.signal);
29486
+ return abortable2(this.readRegion(x, z, controller.signal), controller.signal);
29320
29487
  }).then((data) => {
29321
29488
  controller.signal.throwIfAborted();
29322
29489
  let bytes = data instanceof Uint8Array ? data : data === void 0 ? void 0 : new Uint8Array(data);