@rickyzhangca/fpsr 0.0.1

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 (41) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +21 -0
  3. package/README.md +267 -0
  4. package/dist/abort-CrgARaZd.js +43 -0
  5. package/dist/abort-CrgARaZd.js.map +1 -0
  6. package/dist/assets-Dy4fqZBV.d.ts +85 -0
  7. package/dist/assets-Dy4fqZBV.d.ts.map +1 -0
  8. package/dist/canvas.d.ts +98 -0
  9. package/dist/canvas.d.ts.map +1 -0
  10. package/dist/canvas.js +3 -0
  11. package/dist/execute-CRZV5zw1.js +963 -0
  12. package/dist/execute-CRZV5zw1.js.map +1 -0
  13. package/dist/host-DdX4g1YM.d.ts +34 -0
  14. package/dist/host-DdX4g1YM.d.ts.map +1 -0
  15. package/dist/index.d.ts +463 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +1776 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/node.d.ts +16 -0
  20. package/dist/node.d.ts.map +1 -0
  21. package/dist/node.js +101 -0
  22. package/dist/node.js.map +1 -0
  23. package/dist/planner.d.ts +418 -0
  24. package/dist/planner.d.ts.map +1 -0
  25. package/dist/planner.js +96 -0
  26. package/dist/planner.js.map +1 -0
  27. package/dist/profile-CTN1Q5SI.d.ts +365 -0
  28. package/dist/profile-CTN1Q5SI.d.ts.map +1 -0
  29. package/dist/profile-DR4i6HDp.js +610 -0
  30. package/dist/profile-DR4i6HDp.js.map +1 -0
  31. package/dist/render-db-BFQIspDB.d.ts +426 -0
  32. package/dist/render-db-BFQIspDB.d.ts.map +1 -0
  33. package/dist/render-db.d.ts +2 -0
  34. package/dist/render-db.js +1 -0
  35. package/dist/tiled-draw-list-Dc-5Ledi.js +3990 -0
  36. package/dist/tiled-draw-list-Dc-5Ledi.js.map +1 -0
  37. package/dist/types-CHgZBSra.d.ts +105 -0
  38. package/dist/types-CHgZBSra.d.ts.map +1 -0
  39. package/dist/upgrade-planner-CNjnMHPJ.d.ts +385 -0
  40. package/dist/upgrade-planner-CNjnMHPJ.d.ts.map +1 -0
  41. package/package.json +86 -0
@@ -0,0 +1,463 @@
1
+ import { c as ImageSource, s as ImageDataLike, t as AssetLoadOptions } from "./host-DdX4g1YM.js";
2
+ import { b as SpaceBackground, h as FrameMeta, m as FrameId, v as RenderDb } from "./render-db-BFQIspDB.js";
3
+ import { t as Canvas2DContextLike } from "./types-CHgZBSra.js";
4
+ import { a as PlanProfile, d as computeTileFrame, f as DrawCmd, i as DrawListStats, m as DrawListBounds, n as AssetEventKind, o as RenderProfile, p as DrawList, r as DecodeStats, t as AssetEvent, u as TileFrame } from "./profile-CTN1Q5SI.js";
5
+ import { A as upgradePlannerMappers, B as BlueprintItemInventoryPositions, C as UPGRADE_PLANNER_SLOT_COUNT, D as UpgradePlanner, E as UpgradeMapperSource, F as BlueprintEntity, G as Icon, H as BlueprintRollingStockConnection, I as BlueprintFilter, J as Tile, K as Position, L as BlueprintInsertPlan, M as BlueprintBook, N as BlueprintBookEntry, O as asUpgradePlanner, P as BlueprintDocument, R as BlueprintInventory, S as formatDeconstructionTileSelectionMode, T as UpgradeMapperDestination, U as BlueprintWire, V as BlueprintRef, W as Color, Y as decodeVersion, _ as deconstructionTileFilterMode, a as DECONSTRUCTION_ENTITY_FILTER_SLOT_COUNT, b as deconstructionTreesAndRocksOnly, c as DeconstructionFilterMode, d as DeconstructionTileFilter, f as DeconstructionTileSelectionMode, g as deconstructionPlannerIcons, h as deconstructionEntityFilters, i as planDeconstructionPlannerDrawList, j as Blueprint, k as upgradePlannerIcons, l as DeconstructionPlanner, m as deconstructionEntityFilterMode, n as planUpgradePlannerDrawList, o as DECONSTRUCTION_TILE_FILTER_SLOT_COUNT, p as asDeconstructionPlanner, q as SignalId, r as DECONSTRUCTION_PLANNER_COLUMNS, s as DeconstructionEntityFilter, t as UPGRADE_PLANNER_COLUMNS, u as DeconstructionPlannerSettings, v as deconstructionTileFilters, w as UpgradeMapper, x as formatDeconstructionFilterMode, y as deconstructionTileSelectionMode, z as BlueprintInventoryPosition } from "./upgrade-planner-CNjnMHPJ.js";
6
+ import { a as CdnAssetsOptions, i as AssetTierManifest, n as AssetSource, o as ManifestFont, r as AssetTier, s as cdnAssets, t as AssetManifest } from "./assets-Dy4fqZBV.js";
7
+
8
+ //#region src/book.d.ts
9
+ type BlueprintSelectReason = "not-found" | "planner" | "empty-book";
10
+ declare class BlueprintSelectError extends Error {
11
+ readonly reason: BlueprintSelectReason;
12
+ constructor(reason: BlueprintSelectReason, message?: string);
13
+ }
14
+ /**
15
+ * Depth-first flatten of all renderable blueprints inside a (possibly nested) book.
16
+ * Root bare blueprints get path [].
17
+ */
18
+ declare function listBlueprints(doc: BlueprintDocument): BlueprintRef[];
19
+ /**
20
+ * Select a blueprint from a document. Without path, follows active_index through nested books.
21
+ */
22
+ declare function selectBlueprint(doc: BlueprintDocument, path?: number[]): Blueprint;
23
+ /**
24
+ * Select a blueprint book from a document by path.
25
+ * No path / `[]` returns the root book; non-empty paths walk nested books only.
26
+ */
27
+ declare function selectBook(doc: BlueprintDocument, path?: number[]): BlueprintBook;
28
+ /**
29
+ * Select an upgrade planner from a document.
30
+ * Bare upgrade-planner documents ignore path (or require `[]`).
31
+ * Book documents require a path ending on an `upgrade_planner` entry.
32
+ */
33
+ declare function selectUpgradePlanner(doc: BlueprintDocument, path?: number[]): Record<string, unknown>;
34
+ /**
35
+ * Select a deconstruction planner from a document.
36
+ * Bare deconstruction-planner documents ignore path (or require `[]`).
37
+ * Book documents require a path ending on a `deconstruction_planner` entry.
38
+ */
39
+ declare function selectDeconstructionPlanner(doc: BlueprintDocument, path?: number[]): Record<string, unknown>;
40
+ type BookTreeItemKind = "book" | "blueprint" | "upgrade_planner" | "deconstruction_planner";
41
+ /** Hierarchical book entry for tree UIs (e.g. Headless Tree sync data loader). */
42
+ interface BookTreeItem {
43
+ id: string;
44
+ path: number[];
45
+ label: string;
46
+ kind: BookTreeItemKind;
47
+ icons?: Icon[];
48
+ /**
49
+ * When set on a book node, nest a planner composite (this paper + `icons`) as
50
+ * the single icon on the book cover — does not replace the book paper.
51
+ */
52
+ iconBackgroundKey?: string;
53
+ children: string[];
54
+ }
55
+ interface BookTree {
56
+ rootId: string;
57
+ items: Record<string, BookTreeItem>;
58
+ }
59
+ /** Nested planner thumbnail drawn as the single icon on a book cover. */
60
+ interface BlueprintBookCoverNested {
61
+ backgroundKey: string;
62
+ icons: Icon[];
63
+ }
64
+ /** Inventory thumbnail for a blueprint book: book paper plus cover contents. */
65
+ interface BlueprintBookCover {
66
+ /** Always the book paper; planner composites nest inside via `nested`. */
67
+ backgroundKey: string;
68
+ /** Flat signal icons when the first leaf is a blueprint (or empty). */
69
+ icons: Icon[];
70
+ /**
71
+ * When the first leaf is a planner, its full composite (planner paper + icons)
72
+ * is drawn as the single icon on the book cover.
73
+ */
74
+ nested?: BlueprintBookCoverNested;
75
+ }
76
+ /**
77
+ * Inventory thumbnail for a blueprint book: always the composite of the first
78
+ * child entry (lowest `index`), including nested books and planners.
79
+ * Ignores any explicit `book.icons` so the cover tracks book contents.
80
+ *
81
+ * The outer paper is always the book. Planner leaves nest their composite as
82
+ * the cover icon; blueprint leaves place signal icons directly on the book.
83
+ */
84
+ declare function blueprintBookCover(book: BlueprintBook): BlueprintBookCover;
85
+ /** Signal icons for a book cover (nested planner icons when applicable). */
86
+ declare function blueprintBookCoverIcons(book: BlueprintBook): Icon[];
87
+ /**
88
+ * Build a flat id→item map of the book hierarchy for tree UIs.
89
+ * Returns null when the document is not a blueprint book.
90
+ */
91
+ declare function buildBookTree(doc: BlueprintDocument): BookTree | null;
92
+ /**
93
+ * Resolve the concrete blueprint path by following active_index through nested books.
94
+ * Bare blueprint documents return []. Returns null when no active blueprint can be resolved.
95
+ */
96
+ declare function resolveActivePath(doc: BlueprintDocument): number[] | null;
97
+ //#endregion
98
+ //#region src/text-font.d.ts
99
+ /** CSS / canvas font-family registered from pipeline DejaVuSans.ttf. */
100
+ declare const FPSR_TEXT_FONT_FAMILY = "fpsr-dejavu";
101
+ /** Fallback stack when the bundled TTF is unavailable. */
102
+ declare const FPSR_TEXT_FONT_FALLBACK = "DejaVu Sans, sans-serif";
103
+ declare function fpsrTextFontCss(sizePx: number): string;
104
+ //#endregion
105
+ //#region src/decode.d.ts
106
+ type BlueprintDecodeReason = "unsupported-version" | "invalid-base64" | "inflate-failed" | "invalid-json" | "invalid-document";
107
+ declare class BlueprintDecodeError extends Error {
108
+ readonly reason: BlueprintDecodeReason;
109
+ constructor(reason: BlueprintDecodeReason, message?: string);
110
+ }
111
+ /**
112
+ * Decode a Factorio blueprint string (compressed or raw JSON) into a BlueprintDocument.
113
+ */
114
+ declare function decode(source: string): BlueprintDocument;
115
+ /**
116
+ * Decode a blueprint string and collect size + timing stats for profiling.
117
+ */
118
+ declare function decodeWithStats(source: string): {
119
+ doc: BlueprintDocument;
120
+ stats: DecodeStats;
121
+ };
122
+ //#endregion
123
+ //#region src/encode.d.ts
124
+ /**
125
+ * Encode a BlueprintDocument into a Factorio blueprint string (version byte 0).
126
+ */
127
+ declare function encode(doc: BlueprintDocument): string;
128
+ //#endregion
129
+ //#region src/migrate.d.ts
130
+ /**
131
+ * A single 1.x → 2.x transform. Adapters run only while the blueprint's
132
+ * encoded version major is still < 2; after the pipeline, major is bumped
133
+ * to 2 so re-entry is a no-op.
134
+ */
135
+ type BlueprintAdapter = {
136
+ /** Stable id for docs / debugging (e.g. "scale-legacy-directions"). */id: string;
137
+ apply(bp: Blueprint): Blueprint;
138
+ };
139
+ /**
140
+ * Factorio 1.x stores module/item requests as `{ "speed-module-3": 2 }`.
141
+ * 2.x uses an insert-plan array: `[{ id: { name, type }, items: { grid_count } }]`.
142
+ */
143
+ declare function legacyItemsObjectToInsertPlans(items: unknown): BlueprintInsertPlan[] | undefined;
144
+ /**
145
+ * Ordered adapter registry. Add new 1.x→2.x transforms here; document ids in
146
+ * docs/CONTRACTS.md.
147
+ */
148
+ declare const BLUEPRINT_ADAPTERS: readonly BlueprintAdapter[];
149
+ /**
150
+ * Migrate a blueprint to Factorio 2.x shape for rendering.
151
+ * Idempotent: 2.x (or already-migrated) blueprints are returned unchanged.
152
+ */
153
+ declare function migrateTo2x(bp: Blueprint): Blueprint;
154
+ /**
155
+ * Migrate every nested blueprint in a document (bare bp or book tree).
156
+ * Planners are left untouched. Idempotent.
157
+ */
158
+ declare function migrateDocumentTo2x(doc: BlueprintDocument): BlueprintDocument;
159
+ //#endregion
160
+ //#region src/blueprint-components.d.ts
161
+ /** Placing-item / remapped name + instance count. */
162
+ interface BlueprintComponentCount {
163
+ name: string;
164
+ count: number;
165
+ }
166
+ /**
167
+ * Summarize blueprint inventory for UI (item icons).
168
+ * - Migrates 1.x names first (`migrateTo2x`) so icons resolve in the 2.x render-db
169
+ * - Ground rail pieces (straight/curved/half-diagonal + legacy) → `"rail"`
170
+ * - Tiles → `db.tiles[name].item` when present, else tile prototype name
171
+ * - All other entities → prototype name
172
+ *
173
+ * Sorted by count descending, then name ascending.
174
+ */
175
+ declare function countBlueprintComponents(bp: Blueprint, db: RenderDb): BlueprintComponentCount[];
176
+ //#endregion
177
+ //#region src/blueprint-icons.d.ts
178
+ /** Display size of the composited blueprint tile (matches Factorio GUI slot). */
179
+ declare const BLUEPRINT_ICON_TILE_SIZE = 64;
180
+ type BlueprintIconVariant = "blueprint" | "book";
181
+ declare function filledBlueprintIcons(icons: Icon[] | undefined): Icon[];
182
+ /** Signal size in px for a given tile size and filled-icon count. */
183
+ declare function blueprintIconSignalSizePx(tileSize: number, count: number, variant?: BlueprintIconVariant): number;
184
+ /** Signal scale as a fraction of the tile. */
185
+ declare function blueprintIconSignalScale(count: number, variant?: BlueprintIconVariant): number;
186
+ /** Vertical offset in px for signal overlays (negative moves up). */
187
+ declare function blueprintIconSignalYOffsetPx(tileSize: number, count: number, variant?: BlueprintIconVariant): number;
188
+ /** Normalized center for a signal on the blueprint tile (rank is 0-based in sorted order). */
189
+ declare function blueprintIconSignalCenter(count: number, rank: number, variant?: BlueprintIconVariant): {
190
+ x: number;
191
+ y: number;
192
+ };
193
+ interface BlueprintIconSignalPlan {
194
+ icon: Icon;
195
+ iconKeys: string[];
196
+ left: number;
197
+ top: number;
198
+ size: number;
199
+ }
200
+ interface BlueprintIconPlan {
201
+ variant: BlueprintIconVariant;
202
+ backgroundKey: string;
203
+ tileSize: number;
204
+ signals: BlueprintIconSignalPlan[];
205
+ }
206
+ interface PlanBlueprintIconsOptions {
207
+ variant?: BlueprintIconVariant;
208
+ /** Render-db key for the paper background. */
209
+ backgroundKey?: string;
210
+ /** Outer tile size in px. */
211
+ tileSize?: number;
212
+ }
213
+ /**
214
+ * Plans blueprint preview icon layout for inventory thumbnails — background paper
215
+ * plus up to four signal overlays, matching Factorio GUI slot sizes and packing.
216
+ */
217
+ declare function planBlueprintIcons(icons: Icon[] | undefined, opts?: PlanBlueprintIconsOptions): BlueprintIconPlan;
218
+ //#endregion
219
+ //#region src/icon-resolve.d.ts
220
+ /** Resolve a render-db icon key to a frame id, including tile placing-item fallback. */
221
+ declare function resolveIconFrameId(db: RenderDb, iconKey: string): number | undefined;
222
+ //#endregion
223
+ //#region src/rich-text.d.ts
224
+ /** Parsed segment of a Factorio rich-text string. */
225
+ type RichTextToken = {
226
+ kind: "text";
227
+ value: string;
228
+ } | {
229
+ kind: "icon";
230
+ type: string;
231
+ name: string;
232
+ quality?: string;
233
+ raw: string;
234
+ };
235
+ /**
236
+ * Parse Factorio rich-text icon tags into text and icon tokens.
237
+ * Unrecognized bracket sequences are kept as literal text.
238
+ */
239
+ declare function parseRichText(text: string): RichTextToken[];
240
+ /** Ordered render-db icon keys for a parsed rich-text icon token. */
241
+ declare function richTextIconKeys(token: Extract<RichTextToken, {
242
+ kind: "icon";
243
+ }>): string[];
244
+ /** Whether a quality badge should be drawn on top of this icon token. */
245
+ declare function richTextIconQuality(token: Extract<RichTextToken, {
246
+ kind: "icon";
247
+ }>): string | undefined;
248
+ /** Strip rich-text tags, keeping only literal text segments. */
249
+ declare function stripRichText(text: string | undefined): string;
250
+ //#endregion
251
+ //#region src/png-stream.d.ts
252
+ interface StreamingPngEncoder {
253
+ readonly width: number;
254
+ readonly height: number;
255
+ readonly rowsWritten: number;
256
+ writeRgbaRows(rgba: Uint8Array, rowCount: number): void;
257
+ finish(): Blob;
258
+ }
259
+ /**
260
+ * Incremental 8-bit RGBA PNG encoder. Only compressed PNG chunks are retained;
261
+ * callers control raw working memory by choosing how many rows to submit.
262
+ */
263
+ declare function createStreamingPngEncoder(width: number, height: number): StreamingPngEncoder;
264
+ //#endregion
265
+ //#region src/background.d.ts
266
+ /**
267
+ * Discriminated background mode for {@link RenderOptions}.
268
+ *
269
+ * Replaces the former combinatorial boolean flags (`showCheckerboard`,
270
+ * `showSpace`, `showBackgroundAuto`, `terrainBackground`, …).
271
+ */
272
+ type RenderBackground = {
273
+ type: "none";
274
+ } | {
275
+ type: "solid";
276
+ color: [number, number, number, number];
277
+ } | {
278
+ type: "checkerboard";
279
+ } | {
280
+ type: "space"; /** Draw the render-db space-platform planet decoration. */
281
+ planet?: boolean; /** Factorio planet prototype name when `planet` is true. */
282
+ planetName?: string;
283
+ } | {
284
+ type: "terrain";
285
+ name: string;
286
+ } | {
287
+ /**
288
+ * Pick checkerboard vs space from the blueprint (space platform → space
289
+ * starfield without planet).
290
+ */
291
+ type: "auto";
292
+ };
293
+ declare class UnknownTerrainBackgroundError extends Error {
294
+ readonly name = "UnknownTerrainBackgroundError";
295
+ readonly terrainName: string;
296
+ constructor(terrainName: string);
297
+ }
298
+ declare class AssetDensityMismatchError extends Error {
299
+ readonly name = "AssetDensityMismatchError";
300
+ readonly tier: "1x" | "2x";
301
+ readonly expectedDensity: 1 | 2;
302
+ readonly actualDensity: 1 | 2 | undefined;
303
+ constructor(tier: "1x" | "2x", expectedDensity: 1 | 2, actualDensity: 1 | 2 | undefined);
304
+ }
305
+ //#endregion
306
+ //#region src/renderer.d.ts
307
+ interface CanvasLike {
308
+ width: number;
309
+ height: number;
310
+ getContext(type: "2d"): Canvas2DContextLike | null;
311
+ convertToBlob?(options?: {
312
+ type?: string;
313
+ quality?: number;
314
+ }): Promise<Blob>;
315
+ toBuffer?(mime?: string, options?: {
316
+ quality?: number;
317
+ }): Uint8Array | Promise<Uint8Array>;
318
+ }
319
+ type CreateCanvasFn = (width: number, height: number) => CanvasLike;
320
+ type RenderImageMimeType = "image/png" | "image/webp";
321
+ interface RenderImageOptions {
322
+ /** Output image format. Defaults to PNG. */
323
+ type?: RenderImageMimeType;
324
+ /** Encoder quality from 0 to 1 for lossy formats such as WebP. */
325
+ quality?: number;
326
+ }
327
+ interface MaxOutputSize {
328
+ width: number;
329
+ height: number;
330
+ }
331
+ interface RenderMeasurement {
332
+ tileFrame: TileFrame;
333
+ requestedPixelsPerTile: number;
334
+ pixelsPerTile: number;
335
+ requestedWidth: number;
336
+ requestedHeight: number;
337
+ width: number;
338
+ height: number;
339
+ capped: boolean;
340
+ }
341
+ interface CreateRendererOptions {
342
+ assets: AssetSource;
343
+ /** Physical atlas tier. Defaults to 2x. */
344
+ assetTier?: AssetTier;
345
+ /** Preloaded render-db; when omitted, loaded once via assets.loadRenderDb(). */
346
+ renderDb?: RenderDb;
347
+ /** Canvas factory; defaults to OffscreenCanvas / document.createElement. */
348
+ createCanvas?: CreateCanvasFn;
349
+ }
350
+ type RenderProgressEvent = {
351
+ stage: "planning";
352
+ } | {
353
+ stage: "loading-assets";
354
+ completed: number;
355
+ total: number;
356
+ } | {
357
+ stage: "baking-icons";
358
+ } | {
359
+ stage: "painting";
360
+ } | {
361
+ stage: "painting-tiles";
362
+ completed: number;
363
+ total: number;
364
+ } | {
365
+ stage: "encoding";
366
+ } | {
367
+ stage: "complete";
368
+ };
369
+ /**
370
+ * Layout-only options for {@link Renderer.measure}.
371
+ * Honored fields affect planned bounds / output size; paint-only options are omitted.
372
+ */
373
+ interface MeasureOptions {
374
+ blueprintPath?: number[];
375
+ pixelsPerTile?: number;
376
+ maxOutputSize?: MaxOutputSize;
377
+ padTiles?: number;
378
+ altMode?: boolean;
379
+ beltEndings?: boolean;
380
+ signal?: AbortSignal;
381
+ }
382
+ /** Public render options (no prepared-viewport / tiled internals). */
383
+ interface RenderOptions {
384
+ blueprintPath?: number[];
385
+ pixelsPerTile?: number;
386
+ /**
387
+ * Fit the output inside this box by lowering pixelsPerTile before painting.
388
+ * The renderer never creates a full-resolution intermediate canvas.
389
+ */
390
+ maxOutputSize?: MaxOutputSize;
391
+ altMode?: boolean;
392
+ beltEndings?: boolean;
393
+ /** Discriminated background mode. Defaults to `{ type: "none" }`. */
394
+ background?: RenderBackground;
395
+ padTiles?: number;
396
+ /** Draw tile grid lines and map-space coordinate labels. */
397
+ showCoordinates?: boolean;
398
+ /** Reuse an existing canvas instead of creating one. */
399
+ canvas?: CanvasLike;
400
+ /** Cancel before the destination canvas is resized or painted. */
401
+ signal?: AbortSignal;
402
+ /** Coarse, host-neutral render stages suitable for progress UI. */
403
+ onProgress?: (event: RenderProgressEvent) => void;
404
+ /**
405
+ * When true, collect stage timings / draw-list stats onto `RenderResult.profile`.
406
+ * Near-zero overhead when omitted/false. Ignored by {@link Renderer.renderTiledPng}.
407
+ */
408
+ profile?: boolean;
409
+ }
410
+ interface RenderResult {
411
+ canvas: CanvasLike;
412
+ width: number;
413
+ height: number;
414
+ drawList: DrawList;
415
+ tileFrame: TileFrame;
416
+ /** Present when `RenderOptions.profile` was true. */
417
+ profile?: RenderProfile;
418
+ /** Encode the current canvas directly into the requested image format. */
419
+ toImageBlob(options?: RenderImageOptions): Promise<Blob>;
420
+ /** Encode the current canvas directly into a browser- or Node-compatible byte array. */
421
+ toImageBuffer(options?: RenderImageOptions): Promise<Uint8Array>;
422
+ toPngBlob(): Promise<Blob>;
423
+ toPngBuffer(): Promise<Uint8Array>;
424
+ }
425
+ interface Renderer {
426
+ /** Plan bounds and output dimensions without loading atlases or painting. */
427
+ measure(docOrBlueprint: BlueprintDocument | Blueprint, opts?: MeasureOptions): RenderMeasurement;
428
+ render(docOrBlueprint: BlueprintDocument | Blueprint, opts?: RenderOptions): Promise<RenderResult>;
429
+ /** Render a full-resolution PNG with bounded raw-pixel working memory. */
430
+ renderTiledPng(docOrBlueprint: BlueprintDocument | Blueprint, opts?: TiledPngOptions): Promise<TiledPngResult>;
431
+ /**
432
+ * Release renderer-owned derived caches (icon crops / silhouettes).
433
+ * Does **not** dispose the caller-supplied {@link AssetSource} or close
434
+ * atlas `ImageSource` objects owned by that source.
435
+ */
436
+ dispose(): void;
437
+ }
438
+ interface TiledPngOptions extends Omit<RenderOptions, "canvas" | "maxOutputSize" | "profile" | "onProgress"> {
439
+ /** Target maximum edge of each temporary canvas. Defaults to 2048 px. */
440
+ tileSize?: number;
441
+ /** Maximum assembled raw strip memory. Defaults to 32 MiB. */
442
+ maxStripeBytes?: number;
443
+ signal?: AbortSignal;
444
+ onProgress?: (event: RenderProgressEvent) => void;
445
+ }
446
+ interface TiledPngResult {
447
+ blob: Blob;
448
+ width: number;
449
+ height: number;
450
+ tileFrame: TileFrame;
451
+ tiled: true;
452
+ }
453
+ declare function measureTileFrame(tileFrame: TileFrame, requestedPixelsPerTile: number, maxOutputSize?: MaxOutputSize): RenderMeasurement;
454
+ /** Resolve the starmap frame for an optional planet prototype name. */
455
+ declare function resolveSpacePlanetFrameId(spaceBackground: SpaceBackground | undefined, spacePlanet?: string): number | undefined;
456
+ /**
457
+ * Create a renderer that loads the render-db once and lazily loads atlases
458
+ * referenced by each draw list.
459
+ */
460
+ declare function createRenderer(options: CreateRendererOptions): Promise<Renderer>;
461
+ //#endregion
462
+ export { AssetDensityMismatchError, type AssetEvent, type AssetEventKind, type AssetLoadOptions, type AssetManifest, type AssetSource, type AssetTier, type AssetTierManifest, BLUEPRINT_ADAPTERS, BLUEPRINT_ICON_TILE_SIZE, type Blueprint, type BlueprintAdapter, type BlueprintBook, type BlueprintBookCover, type BlueprintBookCoverNested, type BlueprintBookEntry, type BlueprintComponentCount, BlueprintDecodeError, type BlueprintDecodeReason, type BlueprintDocument, type BlueprintEntity, type BlueprintFilter, type BlueprintIconPlan, type BlueprintIconSignalPlan, type BlueprintIconVariant, type BlueprintInsertPlan, type BlueprintInventory, type BlueprintInventoryPosition, type BlueprintItemInventoryPositions, type BlueprintRef, type BlueprintRollingStockConnection, BlueprintSelectError, type BlueprintSelectReason, type BlueprintWire, type BookTree, type BookTreeItem, type BookTreeItemKind, type CanvasLike, type CdnAssetsOptions, type Color, type CreateCanvasFn, type CreateRendererOptions, DECONSTRUCTION_ENTITY_FILTER_SLOT_COUNT, DECONSTRUCTION_PLANNER_COLUMNS, DECONSTRUCTION_TILE_FILTER_SLOT_COUNT, type DecodeStats, type DeconstructionEntityFilter, type DeconstructionFilterMode, type DeconstructionPlanner, type DeconstructionPlannerSettings, type DeconstructionTileFilter, type DeconstructionTileSelectionMode, type DrawCmd, type DrawList, type DrawListBounds, type DrawListStats, FPSR_TEXT_FONT_FALLBACK, FPSR_TEXT_FONT_FAMILY, type FrameId, type FrameMeta, type Icon, type ImageDataLike, type ImageSource, type ManifestFont, type MaxOutputSize, type MeasureOptions, type PlanBlueprintIconsOptions, type PlanProfile, type Position, type RenderBackground, type RenderDb, type RenderImageMimeType, type RenderImageOptions, type RenderMeasurement, type RenderOptions, type RenderProfile, type RenderProgressEvent, type RenderResult, type Renderer, type RichTextToken, type SignalId, type StreamingPngEncoder, type Tile, type TileFrame, type TiledPngOptions, type TiledPngResult, UPGRADE_PLANNER_COLUMNS, UPGRADE_PLANNER_SLOT_COUNT, UnknownTerrainBackgroundError, type UpgradeMapper, type UpgradeMapperDestination, type UpgradeMapperSource, type UpgradePlanner, asDeconstructionPlanner, asUpgradePlanner, blueprintBookCover, blueprintBookCoverIcons, blueprintIconSignalCenter, blueprintIconSignalScale, blueprintIconSignalSizePx, blueprintIconSignalYOffsetPx, buildBookTree, cdnAssets, computeTileFrame, countBlueprintComponents, createRenderer, createStreamingPngEncoder, decode, decodeVersion, decodeWithStats, deconstructionEntityFilterMode, deconstructionEntityFilters, deconstructionPlannerIcons, deconstructionTileFilterMode, deconstructionTileFilters, deconstructionTileSelectionMode, deconstructionTreesAndRocksOnly, encode, filledBlueprintIcons, formatDeconstructionFilterMode, formatDeconstructionTileSelectionMode, fpsrTextFontCss, legacyItemsObjectToInsertPlans, listBlueprints, measureTileFrame, migrateDocumentTo2x, migrateTo2x, parseRichText, planBlueprintIcons, planDeconstructionPlannerDrawList, planUpgradePlannerDrawList, resolveActivePath, resolveIconFrameId, resolveSpacePlanetFrameId, richTextIconKeys, richTextIconQuality, selectBlueprint, selectBook, selectDeconstructionPlanner, selectUpgradePlanner, stripRichText, upgradePlannerIcons, upgradePlannerMappers };
463
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/book.ts","../src/text-font.ts","../src/decode.ts","../src/encode.ts","../src/migrate.ts","../src/blueprint-components.ts","../src/blueprint-icons.ts","../src/icon-resolve.ts","../src/rich-text.ts","../src/png-stream.ts","../src/background.ts","../src/renderer.ts"],"mappings":";;;;;;;;KAYY,qBAAA;AAAA,cAEC,oBAAA,SAA6B,KAAA;EAAA,SAC/B,MAAA,EAAQ,qBAAA;cAEL,MAAA,EAAQ,qBAAA,EAAuB,OAAA;AAAA;;;AAL7C;;iBA8CgB,cAAA,CAAe,GAAA,EAAK,iBAAA,GAAoB,YAAY;;AA9CnC;AAEjC;iBA4GgB,eAAA,CAAgB,GAAA,EAAK,iBAAA,EAAmB,IAAA,cAAkB,SAAS;;;;;iBA0CnE,UAAA,CAAW,GAAA,EAAK,iBAAA,EAAmB,IAAA,cAAkB,aAAa;;;;;;iBA2ClE,oBAAA,CACd,GAAA,EAAK,iBAAA,EACL,IAAA,cACC,MAAM;;;;AAjMoD;AAyC7D;iBAiNgB,2BAAA,CACd,GAAA,EAAK,iBAAA,EACL,IAAA,cACC,MAAM;AAAA,KAwBG,gBAAA;;UAGK,YAAA;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