@openfairygui/functions 0.2.0-alpha.2 → 0.2.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -6
- package/dist/atlas-C6tbl7nn.d.ts +193 -0
- package/dist/atlas-CHsu2Y8i.d.cts +193 -0
- package/dist/index.cjs +16 -3603
- package/dist/index.d.cts +5 -294
- package/dist/index.d.ts +5 -294
- package/dist/index.js +3 -3594
- package/dist/node.cjs +256 -0
- package/dist/node.d.cts +36 -0
- package/dist/node.d.ts +36 -0
- package/dist/node.js +254 -0
- package/dist/publish-BJ_eelME.js +3267 -0
- package/dist/publish-xFWT9Slz.cjs +3338 -0
- package/dist/restore-BW2xacB3.cjs +936 -0
- package/dist/restore-BeWaJNjR.d.cts +288 -0
- package/dist/restore-Clk62n0O.js +931 -0
- package/dist/restore-Dh0-Nvms.d.ts +288 -0
- package/dist/uam-transaction.cjs +44 -1
- package/dist/uam-transaction.d.cts +16 -1
- package/dist/uam-transaction.d.ts +16 -1
- package/dist/uam-transaction.js +44 -1
- package/dist/web.cjs +274 -0
- package/dist/web.d.cts +41 -0
- package/dist/web.d.ts +41 -0
- package/dist/web.js +273 -0
- package/package.json +28 -4
- package/src/adapters/node/plugins.ts +82 -0
- package/src/adapters/node/publish.ts +130 -0
- package/src/adapters/node/restore.ts +187 -0
- package/src/adapters/web/publish.ts +159 -0
- package/src/adapters/web/raster.ts +251 -0
- package/src/atlas/font.ts +95 -0
- package/src/atlas/inputs.ts +515 -0
- package/src/atlas/jta.ts +211 -0
- package/src/atlas/packing.ts +767 -0
- package/src/atlas.ts +116 -1221
- package/src/codegen.ts +106 -67
- package/src/index.ts +43 -3
- package/src/node.ts +8 -0
- package/src/plugins/types.ts +56 -0
- package/src/publish/contracts.ts +80 -0
- package/src/publish/external-resources.ts +117 -0
- package/src/publish/options.ts +180 -0
- package/src/publish/package-context.ts +608 -0
- package/src/publish/resource-references.ts +210 -0
- package/src/publish.ts +290 -968
- package/src/restore-internals/font.ts +100 -0
- package/src/restore-internals/movie-clip.ts +104 -0
- package/src/restore-internals/output-transaction.ts +164 -0
- package/src/restore.ts +112 -311
- package/src/shared-types.ts +4 -8
- package/src/uam-transaction.ts +68 -0
- package/src/utils.ts +28 -0
- package/src/web.ts +11 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as AtlasRasterInput, c as AtlasRasterResolvedBuffer, d as PublishSourceFileSystem, i as AtlasRasterCompositeInput, l as PublishFileSystem, n as atlas, o as AtlasRasterMetadata, r as AtlasRasterBackend, s as AtlasRasterPipeline, t as AtlasOptions, u as PublishOutputFileSystem } from "./atlas-CHsu2Y8i.cjs";
|
|
2
|
+
import { A as ExtrasMap, B as ResolvedPublishOptions, C as MaybePromise, D as CliAtlasSettings, E as PluginModule, F as RootProjectSettings, I as publish, L as PublishOptions, M as HasOptionalSrc, N as HasOptionalUrl, O as CliCodeGenerationSettings, P as PublishDependency, R as ResolvePublishOptionsOverrides, S as LoadedPlugin, T as PluginManifest, V as resolvePublishOptions, _ as encodeText, a as RestoreImageExtractor, b as CodeWriter, c as restore, d as CodegenMember, f as CodegenReferencedComponent, g as decodeText, h as buildCodegenClasses, i as RestoreImageExtractInput, j as HasOptionalFont, k as CliPublishSettings, l as AUTO_GENERATED_CODE_MARK, m as ResolvedPackageCodegenPlan, n as RestoreImageCropInput, o as RestoreOptions, p as PublishCodeGenerationOptions, r as RestoreImageCropper, s as RestoreResult, t as RestoreFileSystem, u as CodegenClass, v as publishCodeGeneration, w as Plugin, x as ICodeWriterConfig, y as resolvePackageCodegenPlan, z as ResolvedPublishAtlasOptions } from "./restore-BeWaJNjR.cjs";
|
|
3
|
+
import { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp } from "./uam-transaction.cjs";
|
|
4
|
+
import { Document, Transform } from "@openfairygui/core";
|
|
3
5
|
|
|
4
6
|
//#region src/inspect.d.ts
|
|
5
7
|
/**
|
|
@@ -166,301 +168,10 @@ interface RenameOptions {
|
|
|
166
168
|
*/
|
|
167
169
|
declare function rename(options: RenameOptions): Transform;
|
|
168
170
|
//#endregion
|
|
169
|
-
//#region src/atlas.d.ts
|
|
170
|
-
interface AtlasOptions {
|
|
171
|
-
/**
|
|
172
|
-
* Sharp module instance, injected by the caller.
|
|
173
|
-
* Required for actual image compositing and trimImage.
|
|
174
|
-
*
|
|
175
|
-
* ```ts
|
|
176
|
-
* import sharp from 'sharp';
|
|
177
|
-
* await doc.transform(atlas({ encoder: sharp }));
|
|
178
|
-
* ```
|
|
179
|
-
*/
|
|
180
|
-
encoder?: unknown;
|
|
181
|
-
/** Maximum atlas texture size (width and height). Default: 2048. */
|
|
182
|
-
maxSize?: number;
|
|
183
|
-
/** Whether to use the fast editor-compatible packing heuristics. Default: true. */
|
|
184
|
-
fast?: boolean;
|
|
185
|
-
/** Allow rotating sprites 90° for better packing. Default: true. */
|
|
186
|
-
allowRotation?: boolean;
|
|
187
|
-
/** Pixel padding between sprites. Default: 1. */
|
|
188
|
-
padding?: number;
|
|
189
|
-
/** Constrain atlas dimensions to powers of two. Default: false. */
|
|
190
|
-
powerOfTwo?: boolean;
|
|
191
|
-
/** Force square atlas (width === height). Default: false. */
|
|
192
|
-
square?: boolean;
|
|
193
|
-
/** Allow spilling into multiple atlas pages. Default: true. */
|
|
194
|
-
multiPage?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* Trim transparent pixels from image edges before packing.
|
|
197
|
-
* Requires encoder (sharp). Stores offset/originalSize in Sprite nodes.
|
|
198
|
-
* Default: false.
|
|
199
|
-
*/
|
|
200
|
-
trimImage?: boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Base path for reading source images. If not set, images must have
|
|
203
|
-
* their pixel data stored in extras._imageData as Uint8Array.
|
|
204
|
-
*/
|
|
205
|
-
basePath?: string;
|
|
206
|
-
/**
|
|
207
|
-
* Output directory for generated atlas PNGs.
|
|
208
|
-
* Required when encoder is provided.
|
|
209
|
-
*/
|
|
210
|
-
outputPath?: string;
|
|
211
|
-
/**
|
|
212
|
-
* Optional mkdir function to ensure output directory exists.
|
|
213
|
-
* If not provided, the outputPath directory must already exist.
|
|
214
|
-
*/
|
|
215
|
-
mkdir?: (path: string) => Promise<void>;
|
|
216
|
-
/**
|
|
217
|
-
* Optional raw file reader for reading .jta MovieClip files.
|
|
218
|
-
* Required for MovieClip frame atlas packing.
|
|
219
|
-
*/
|
|
220
|
-
readFileRaw?: (path: string) => Promise<Uint8Array>;
|
|
221
|
-
/**
|
|
222
|
-
* Keep original input order when MaxRects tie-break scores are equal.
|
|
223
|
-
* This is an internal publish detail used to mirror editor/CLI behavior.
|
|
224
|
-
*/
|
|
225
|
-
preserveInputOrderOnTie?: boolean;
|
|
226
|
-
/**
|
|
227
|
-
* Internal publish detail used by Unity binary output:
|
|
228
|
-
* allow single untrimmed PNG image packages to bypass the packer and
|
|
229
|
-
* write atlas0 directly, matching the reference CLI behavior.
|
|
230
|
-
*/
|
|
231
|
-
directSingleImageOutput?: boolean;
|
|
232
|
-
/**
|
|
233
|
-
* Internal publish detail used by the direct-image-output path.
|
|
234
|
-
* When extractAlpha is enabled, the direct output shortcut must be disabled.
|
|
235
|
-
*/
|
|
236
|
-
extractAlpha?: boolean;
|
|
237
|
-
/**
|
|
238
|
-
* When branchProcessing keeps branch resources, publish branch images into
|
|
239
|
-
* separate atlas pages/files per branch instead of mixing them with main.
|
|
240
|
-
*/
|
|
241
|
-
separatedAtlasForBranch?: boolean;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Packs image resources into texture atlases.
|
|
245
|
-
*
|
|
246
|
-
* This transform performs MaxRects bin-packing on all ImageResource items
|
|
247
|
-
* within each package, creating Atlas and Sprite property nodes. When an
|
|
248
|
-
* `encoder` (sharp) is provided, it also composites the actual PNG files.
|
|
249
|
-
*
|
|
250
|
-
* When `trimImage` is enabled and encoder is available, transparent pixels
|
|
251
|
-
* at image edges are trimmed before packing. The trimmed offset and original
|
|
252
|
-
* dimensions are stored in the Sprite nodes for runtime reconstruction.
|
|
253
|
-
*
|
|
254
|
-
* ```ts
|
|
255
|
-
* import sharp from 'sharp';
|
|
256
|
-
* await doc.transform(atlas({
|
|
257
|
-
* encoder: sharp,
|
|
258
|
-
* maxSize: 2048,
|
|
259
|
-
* trimImage: true,
|
|
260
|
-
* basePath: './assets/',
|
|
261
|
-
* outputPath: './dist/',
|
|
262
|
-
* }));
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
declare function atlas(_options?: AtlasOptions): Transform;
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region src/shared-types.d.ts
|
|
268
|
-
type ExtrasMap = Record<string, unknown>;
|
|
269
|
-
interface CliCodeGenerationSettings extends NonNullable<PublishSettings['codeGeneration']> {
|
|
270
|
-
allowGenCode?: boolean;
|
|
271
|
-
classNamePrefix?: string;
|
|
272
|
-
codePath?: string;
|
|
273
|
-
codeType?: string;
|
|
274
|
-
getMemberByName?: boolean;
|
|
275
|
-
ignoreNoname?: boolean;
|
|
276
|
-
memberNamePrefix?: string;
|
|
277
|
-
packageName?: string;
|
|
278
|
-
}
|
|
279
|
-
interface CliAtlasSettings extends NonNullable<PublishSettings['atlasSetting']> {
|
|
280
|
-
maxSize?: number;
|
|
281
|
-
paging?: boolean;
|
|
282
|
-
sizeOption?: string;
|
|
283
|
-
forceSquare?: boolean;
|
|
284
|
-
fast?: boolean;
|
|
285
|
-
allowRotation?: boolean;
|
|
286
|
-
padding?: number;
|
|
287
|
-
trimImage?: boolean;
|
|
288
|
-
extractAlpha?: boolean;
|
|
289
|
-
}
|
|
290
|
-
interface CliPublishSettings extends PublishSettings {
|
|
291
|
-
atlasSetting?: CliAtlasSettings;
|
|
292
|
-
codeGeneration?: CliCodeGenerationSettings;
|
|
293
|
-
}
|
|
294
|
-
type RootProjectSettings = ProjectSettings & {
|
|
295
|
-
publish?: CliPublishSettings;
|
|
296
|
-
};
|
|
297
|
-
interface PublishDependency {
|
|
298
|
-
id: string;
|
|
299
|
-
name: string;
|
|
300
|
-
}
|
|
301
|
-
interface HasOptionalFont {
|
|
302
|
-
getFont?(): string | string[] | null | undefined;
|
|
303
|
-
}
|
|
304
|
-
interface HasOptionalSrc {
|
|
305
|
-
getSrc?(): string | undefined;
|
|
306
|
-
}
|
|
307
|
-
interface HasOptionalUrl {
|
|
308
|
-
getUrl?(): string | undefined;
|
|
309
|
-
}
|
|
310
|
-
type PublishFileSystem = Pick<FileSystem, 'join' | 'mkdir' | 'writeFileRaw'> & {
|
|
311
|
-
deleteFile?: (path: string) => Promise<void>;
|
|
312
|
-
exists?: FileSystem['exists'];
|
|
313
|
-
readdir?: FileSystem['readdir'];
|
|
314
|
-
readFileRaw?: FileSystem['readFileRaw'];
|
|
315
|
-
};
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region src/codegen.d.ts
|
|
318
|
-
declare const AUTO_GENERATED_CODE_MARK = "/** This is an automatically generated class by FairyGUI. Please do not modify it. **/";
|
|
319
|
-
interface PublishCodeGenerationOptions {
|
|
320
|
-
basePath?: string;
|
|
321
|
-
fs: PublishFileSystem;
|
|
322
|
-
packages: Package[];
|
|
323
|
-
}
|
|
324
|
-
declare function publishCodeGeneration(doc: Document, options: PublishCodeGenerationOptions): Promise<void>;
|
|
325
|
-
//#endregion
|
|
326
|
-
//#region src/restore.d.ts
|
|
327
|
-
interface RestoreImageCropInput {
|
|
328
|
-
sourcePath: string;
|
|
329
|
-
outputPath: string;
|
|
330
|
-
left: number;
|
|
331
|
-
top: number;
|
|
332
|
-
width: number;
|
|
333
|
-
height: number;
|
|
334
|
-
rotated: boolean;
|
|
335
|
-
offsetX: number;
|
|
336
|
-
offsetY: number;
|
|
337
|
-
expectedWidth: number;
|
|
338
|
-
expectedHeight: number;
|
|
339
|
-
}
|
|
340
|
-
type RestoreImageCropper = (input: RestoreImageCropInput) => Promise<void>;
|
|
341
|
-
type RestoreImageExtractInput = Omit<RestoreImageCropInput, 'outputPath'>;
|
|
342
|
-
type RestoreImageExtractor = (input: RestoreImageExtractInput) => Promise<Uint8Array>;
|
|
343
|
-
interface RestoreResult {
|
|
344
|
-
document: Document;
|
|
345
|
-
projectPath: string;
|
|
346
|
-
warnings: string[];
|
|
347
|
-
}
|
|
348
|
-
interface RestoreFileSystem extends Pick<FileSystem, 'readFile' | 'readFileRaw' | 'writeFile' | 'writeFileRaw' | 'mkdir' | 'exists' | 'join' | 'dirname'> {
|
|
349
|
-
readdir(path: string): Promise<string[]>;
|
|
350
|
-
isFile(path: string): Promise<boolean>;
|
|
351
|
-
resolvePath(path: string): string | Promise<string>;
|
|
352
|
-
rm?: (path: string, options?: {
|
|
353
|
-
recursive?: boolean;
|
|
354
|
-
force?: boolean;
|
|
355
|
-
}) => Promise<void>;
|
|
356
|
-
}
|
|
357
|
-
interface RestoreOptions {
|
|
358
|
-
inputDir: string;
|
|
359
|
-
output: string;
|
|
360
|
-
fs: RestoreFileSystem;
|
|
361
|
-
packages?: string[];
|
|
362
|
-
force?: boolean;
|
|
363
|
-
projectType?: number;
|
|
364
|
-
cropImage?: RestoreImageCropper;
|
|
365
|
-
extractImage?: RestoreImageExtractor;
|
|
366
|
-
}
|
|
367
|
-
declare function restore(options: RestoreOptions): Promise<RestoreResult>;
|
|
368
|
-
//#endregion
|
|
369
|
-
//#region src/publish.d.ts
|
|
370
|
-
interface PublishOptions {
|
|
371
|
-
/**
|
|
372
|
-
* Output directory for published files (.fui + atlas PNGs).
|
|
373
|
-
* Required.
|
|
374
|
-
*/
|
|
375
|
-
output: string;
|
|
376
|
-
/**
|
|
377
|
-
* Compress the binary data with zlib raw deflate. Default: false.
|
|
378
|
-
*/
|
|
379
|
-
compressed?: boolean;
|
|
380
|
-
/**
|
|
381
|
-
* File extension for the binary output. Default: 'fui'.
|
|
382
|
-
* Unity projects typically use 'bytes'.
|
|
383
|
-
*/
|
|
384
|
-
fileExtension?: string;
|
|
385
|
-
/**
|
|
386
|
-
* Sharp module instance for atlas image compositing.
|
|
387
|
-
* If not provided, atlas packing only computes layout (no PNGs generated).
|
|
388
|
-
*/
|
|
389
|
-
encoder?: unknown;
|
|
390
|
-
/**
|
|
391
|
-
* Base path for reading source images (project assets root).
|
|
392
|
-
* Required when encoder is provided.
|
|
393
|
-
*/
|
|
394
|
-
basePath?: string;
|
|
395
|
-
/**
|
|
396
|
-
* Atlas packing options.
|
|
397
|
-
*/
|
|
398
|
-
atlas?: Omit<AtlasOptions, 'encoder' | 'basePath' | 'outputPath'>;
|
|
399
|
-
/**
|
|
400
|
-
* Filter which packages to publish by name. If not set, all packages are published.
|
|
401
|
-
*/
|
|
402
|
-
packages?: string[];
|
|
403
|
-
/**
|
|
404
|
-
* FileSystem abstraction for writing output files.
|
|
405
|
-
* Required for actual file output. Without it, only the Document model
|
|
406
|
-
* is updated (atlas layout computed, sprite nodes created).
|
|
407
|
-
*/
|
|
408
|
-
fs?: PublishFileSystem;
|
|
409
|
-
/**
|
|
410
|
-
* Active branch name used when branchProcessing is "主干合并活跃分支".
|
|
411
|
-
* Empty or omitted means publishing the main branch.
|
|
412
|
-
*/
|
|
413
|
-
branch?: string;
|
|
414
|
-
}
|
|
415
|
-
interface ResolvedPublishAtlasOptions extends Pick<AtlasOptions, 'maxSize' | 'fast' | 'allowRotation' | 'padding' | 'powerOfTwo' | 'square' | 'multiPage' | 'trimImage' | 'extractAlpha'> {}
|
|
416
|
-
interface ResolvePublishOptionsOverrides {
|
|
417
|
-
compressed?: boolean;
|
|
418
|
-
fileExtension?: string;
|
|
419
|
-
packages?: string[];
|
|
420
|
-
atlas?: Partial<ResolvedPublishAtlasOptions>;
|
|
421
|
-
}
|
|
422
|
-
interface ResolvedPublishOptions {
|
|
423
|
-
compressed: boolean;
|
|
424
|
-
fileExtension: string;
|
|
425
|
-
packages?: string[];
|
|
426
|
-
atlas: ResolvedPublishAtlasOptions;
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Resolve publish defaults from the document's project settings.
|
|
430
|
-
*
|
|
431
|
-
* This keeps the editor-aligned publish rules reusable across environments,
|
|
432
|
-
* while callers still provide environment-specific concerns such as fs/encoder/basePath.
|
|
433
|
-
*/
|
|
434
|
-
declare function resolvePublishOptions(doc: Document, overrides?: ResolvePublishOptionsOverrides): ResolvedPublishOptions;
|
|
435
|
-
/**
|
|
436
|
-
* Publishes a FairyGUI project.
|
|
437
|
-
*
|
|
438
|
-
* Orchestrates:
|
|
439
|
-
* 1. Atlas packing (MaxRects layout + optional sharp compositing)
|
|
440
|
-
* 2. Per-package .fui binary serialization
|
|
441
|
-
* 3. File writing to the output directory
|
|
442
|
-
*
|
|
443
|
-
* ```ts
|
|
444
|
-
* import sharp from 'sharp';
|
|
445
|
-
* const io = new NodeIO();
|
|
446
|
-
* const doc = await io.readProject('./project.fairy');
|
|
447
|
-
*
|
|
448
|
-
* await doc.transform(publish({
|
|
449
|
-
* output: './release/',
|
|
450
|
-
* compressed: true,
|
|
451
|
-
* encoder: sharp,
|
|
452
|
-
* basePath: './assets/',
|
|
453
|
-
* fileExtension: 'bytes',
|
|
454
|
-
* fs: io.createFileSystem(),
|
|
455
|
-
* }));
|
|
456
|
-
* ```
|
|
457
|
-
*/
|
|
458
|
-
declare function publish(options: PublishOptions): Transform;
|
|
459
|
-
//#endregion
|
|
460
171
|
//#region src/utils.d.ts
|
|
461
172
|
/**
|
|
462
173
|
* Wraps a transform function, assigning it a name for the transform stack.
|
|
463
174
|
*/
|
|
464
175
|
declare function createTransform(name: string, fn: Transform): Transform;
|
|
465
176
|
//#endregion
|
|
466
|
-
export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, type CliAtlasSettings, type CliPublishSettings, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type InspectCategoryReport, type InspectReport, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, applyUamTransactionApp, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
|
|
177
|
+
export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppDiagnostic, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, type AtlasRasterBackend, type AtlasRasterCompositeInput, type AtlasRasterInput, type AtlasRasterMetadata, type AtlasRasterPipeline, type AtlasRasterResolvedBuffer, type CliAtlasSettings, type CliCodeGenerationSettings, type CliPublishSettings, type CodeWriter, type CodegenClass, type CodegenMember, type CodegenReferencedComponent, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type ICodeWriterConfig, type InspectCategoryReport, type InspectReport, type LoadedPlugin, type MaybePromise, type Plugin, type PluginManifest, type PluginModule, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type PublishOutputFileSystem, type PublishSourceFileSystem, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPackageCodegenPlan, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, applyUamTransactionApp, atlas, buildCodegenClasses, createTransform, decodeText, encodeText, inspect, prune, publish, publishCodeGeneration, rename, resolvePackageCodegenPlan, resolvePublishOptions, restore, validate };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as AtlasRasterInput, c as AtlasRasterResolvedBuffer, d as PublishSourceFileSystem, i as AtlasRasterCompositeInput, l as PublishFileSystem, n as atlas, o as AtlasRasterMetadata, r as AtlasRasterBackend, s as AtlasRasterPipeline, t as AtlasOptions, u as PublishOutputFileSystem } from "./atlas-C6tbl7nn.js";
|
|
2
|
+
import { A as ExtrasMap, B as ResolvedPublishOptions, C as MaybePromise, D as CliAtlasSettings, E as PluginModule, F as RootProjectSettings, I as publish, L as PublishOptions, M as HasOptionalSrc, N as HasOptionalUrl, O as CliCodeGenerationSettings, P as PublishDependency, R as ResolvePublishOptionsOverrides, S as LoadedPlugin, T as PluginManifest, V as resolvePublishOptions, _ as encodeText, a as RestoreImageExtractor, b as CodeWriter, c as restore, d as CodegenMember, f as CodegenReferencedComponent, g as decodeText, h as buildCodegenClasses, i as RestoreImageExtractInput, j as HasOptionalFont, k as CliPublishSettings, l as AUTO_GENERATED_CODE_MARK, m as ResolvedPackageCodegenPlan, n as RestoreImageCropInput, o as RestoreOptions, p as PublishCodeGenerationOptions, r as RestoreImageCropper, s as RestoreResult, t as RestoreFileSystem, u as CodegenClass, v as publishCodeGeneration, w as Plugin, x as ICodeWriterConfig, y as resolvePackageCodegenPlan, z as ResolvedPublishAtlasOptions } from "./restore-Dh0-Nvms.js";
|
|
3
|
+
import { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp } from "./uam-transaction.js";
|
|
4
|
+
import { Document, Transform } from "@openfairygui/core";
|
|
3
5
|
|
|
4
6
|
//#region src/inspect.d.ts
|
|
5
7
|
/**
|
|
@@ -166,301 +168,10 @@ interface RenameOptions {
|
|
|
166
168
|
*/
|
|
167
169
|
declare function rename(options: RenameOptions): Transform;
|
|
168
170
|
//#endregion
|
|
169
|
-
//#region src/atlas.d.ts
|
|
170
|
-
interface AtlasOptions {
|
|
171
|
-
/**
|
|
172
|
-
* Sharp module instance, injected by the caller.
|
|
173
|
-
* Required for actual image compositing and trimImage.
|
|
174
|
-
*
|
|
175
|
-
* ```ts
|
|
176
|
-
* import sharp from 'sharp';
|
|
177
|
-
* await doc.transform(atlas({ encoder: sharp }));
|
|
178
|
-
* ```
|
|
179
|
-
*/
|
|
180
|
-
encoder?: unknown;
|
|
181
|
-
/** Maximum atlas texture size (width and height). Default: 2048. */
|
|
182
|
-
maxSize?: number;
|
|
183
|
-
/** Whether to use the fast editor-compatible packing heuristics. Default: true. */
|
|
184
|
-
fast?: boolean;
|
|
185
|
-
/** Allow rotating sprites 90° for better packing. Default: true. */
|
|
186
|
-
allowRotation?: boolean;
|
|
187
|
-
/** Pixel padding between sprites. Default: 1. */
|
|
188
|
-
padding?: number;
|
|
189
|
-
/** Constrain atlas dimensions to powers of two. Default: false. */
|
|
190
|
-
powerOfTwo?: boolean;
|
|
191
|
-
/** Force square atlas (width === height). Default: false. */
|
|
192
|
-
square?: boolean;
|
|
193
|
-
/** Allow spilling into multiple atlas pages. Default: true. */
|
|
194
|
-
multiPage?: boolean;
|
|
195
|
-
/**
|
|
196
|
-
* Trim transparent pixels from image edges before packing.
|
|
197
|
-
* Requires encoder (sharp). Stores offset/originalSize in Sprite nodes.
|
|
198
|
-
* Default: false.
|
|
199
|
-
*/
|
|
200
|
-
trimImage?: boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Base path for reading source images. If not set, images must have
|
|
203
|
-
* their pixel data stored in extras._imageData as Uint8Array.
|
|
204
|
-
*/
|
|
205
|
-
basePath?: string;
|
|
206
|
-
/**
|
|
207
|
-
* Output directory for generated atlas PNGs.
|
|
208
|
-
* Required when encoder is provided.
|
|
209
|
-
*/
|
|
210
|
-
outputPath?: string;
|
|
211
|
-
/**
|
|
212
|
-
* Optional mkdir function to ensure output directory exists.
|
|
213
|
-
* If not provided, the outputPath directory must already exist.
|
|
214
|
-
*/
|
|
215
|
-
mkdir?: (path: string) => Promise<void>;
|
|
216
|
-
/**
|
|
217
|
-
* Optional raw file reader for reading .jta MovieClip files.
|
|
218
|
-
* Required for MovieClip frame atlas packing.
|
|
219
|
-
*/
|
|
220
|
-
readFileRaw?: (path: string) => Promise<Uint8Array>;
|
|
221
|
-
/**
|
|
222
|
-
* Keep original input order when MaxRects tie-break scores are equal.
|
|
223
|
-
* This is an internal publish detail used to mirror editor/CLI behavior.
|
|
224
|
-
*/
|
|
225
|
-
preserveInputOrderOnTie?: boolean;
|
|
226
|
-
/**
|
|
227
|
-
* Internal publish detail used by Unity binary output:
|
|
228
|
-
* allow single untrimmed PNG image packages to bypass the packer and
|
|
229
|
-
* write atlas0 directly, matching the reference CLI behavior.
|
|
230
|
-
*/
|
|
231
|
-
directSingleImageOutput?: boolean;
|
|
232
|
-
/**
|
|
233
|
-
* Internal publish detail used by the direct-image-output path.
|
|
234
|
-
* When extractAlpha is enabled, the direct output shortcut must be disabled.
|
|
235
|
-
*/
|
|
236
|
-
extractAlpha?: boolean;
|
|
237
|
-
/**
|
|
238
|
-
* When branchProcessing keeps branch resources, publish branch images into
|
|
239
|
-
* separate atlas pages/files per branch instead of mixing them with main.
|
|
240
|
-
*/
|
|
241
|
-
separatedAtlasForBranch?: boolean;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Packs image resources into texture atlases.
|
|
245
|
-
*
|
|
246
|
-
* This transform performs MaxRects bin-packing on all ImageResource items
|
|
247
|
-
* within each package, creating Atlas and Sprite property nodes. When an
|
|
248
|
-
* `encoder` (sharp) is provided, it also composites the actual PNG files.
|
|
249
|
-
*
|
|
250
|
-
* When `trimImage` is enabled and encoder is available, transparent pixels
|
|
251
|
-
* at image edges are trimmed before packing. The trimmed offset and original
|
|
252
|
-
* dimensions are stored in the Sprite nodes for runtime reconstruction.
|
|
253
|
-
*
|
|
254
|
-
* ```ts
|
|
255
|
-
* import sharp from 'sharp';
|
|
256
|
-
* await doc.transform(atlas({
|
|
257
|
-
* encoder: sharp,
|
|
258
|
-
* maxSize: 2048,
|
|
259
|
-
* trimImage: true,
|
|
260
|
-
* basePath: './assets/',
|
|
261
|
-
* outputPath: './dist/',
|
|
262
|
-
* }));
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
declare function atlas(_options?: AtlasOptions): Transform;
|
|
266
|
-
//#endregion
|
|
267
|
-
//#region src/shared-types.d.ts
|
|
268
|
-
type ExtrasMap = Record<string, unknown>;
|
|
269
|
-
interface CliCodeGenerationSettings extends NonNullable<PublishSettings['codeGeneration']> {
|
|
270
|
-
allowGenCode?: boolean;
|
|
271
|
-
classNamePrefix?: string;
|
|
272
|
-
codePath?: string;
|
|
273
|
-
codeType?: string;
|
|
274
|
-
getMemberByName?: boolean;
|
|
275
|
-
ignoreNoname?: boolean;
|
|
276
|
-
memberNamePrefix?: string;
|
|
277
|
-
packageName?: string;
|
|
278
|
-
}
|
|
279
|
-
interface CliAtlasSettings extends NonNullable<PublishSettings['atlasSetting']> {
|
|
280
|
-
maxSize?: number;
|
|
281
|
-
paging?: boolean;
|
|
282
|
-
sizeOption?: string;
|
|
283
|
-
forceSquare?: boolean;
|
|
284
|
-
fast?: boolean;
|
|
285
|
-
allowRotation?: boolean;
|
|
286
|
-
padding?: number;
|
|
287
|
-
trimImage?: boolean;
|
|
288
|
-
extractAlpha?: boolean;
|
|
289
|
-
}
|
|
290
|
-
interface CliPublishSettings extends PublishSettings {
|
|
291
|
-
atlasSetting?: CliAtlasSettings;
|
|
292
|
-
codeGeneration?: CliCodeGenerationSettings;
|
|
293
|
-
}
|
|
294
|
-
type RootProjectSettings = ProjectSettings & {
|
|
295
|
-
publish?: CliPublishSettings;
|
|
296
|
-
};
|
|
297
|
-
interface PublishDependency {
|
|
298
|
-
id: string;
|
|
299
|
-
name: string;
|
|
300
|
-
}
|
|
301
|
-
interface HasOptionalFont {
|
|
302
|
-
getFont?(): string | string[] | null | undefined;
|
|
303
|
-
}
|
|
304
|
-
interface HasOptionalSrc {
|
|
305
|
-
getSrc?(): string | undefined;
|
|
306
|
-
}
|
|
307
|
-
interface HasOptionalUrl {
|
|
308
|
-
getUrl?(): string | undefined;
|
|
309
|
-
}
|
|
310
|
-
type PublishFileSystem = Pick<FileSystem, 'join' | 'mkdir' | 'writeFileRaw'> & {
|
|
311
|
-
deleteFile?: (path: string) => Promise<void>;
|
|
312
|
-
exists?: FileSystem['exists'];
|
|
313
|
-
readdir?: FileSystem['readdir'];
|
|
314
|
-
readFileRaw?: FileSystem['readFileRaw'];
|
|
315
|
-
};
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region src/codegen.d.ts
|
|
318
|
-
declare const AUTO_GENERATED_CODE_MARK = "/** This is an automatically generated class by FairyGUI. Please do not modify it. **/";
|
|
319
|
-
interface PublishCodeGenerationOptions {
|
|
320
|
-
basePath?: string;
|
|
321
|
-
fs: PublishFileSystem;
|
|
322
|
-
packages: Package[];
|
|
323
|
-
}
|
|
324
|
-
declare function publishCodeGeneration(doc: Document, options: PublishCodeGenerationOptions): Promise<void>;
|
|
325
|
-
//#endregion
|
|
326
|
-
//#region src/restore.d.ts
|
|
327
|
-
interface RestoreImageCropInput {
|
|
328
|
-
sourcePath: string;
|
|
329
|
-
outputPath: string;
|
|
330
|
-
left: number;
|
|
331
|
-
top: number;
|
|
332
|
-
width: number;
|
|
333
|
-
height: number;
|
|
334
|
-
rotated: boolean;
|
|
335
|
-
offsetX: number;
|
|
336
|
-
offsetY: number;
|
|
337
|
-
expectedWidth: number;
|
|
338
|
-
expectedHeight: number;
|
|
339
|
-
}
|
|
340
|
-
type RestoreImageCropper = (input: RestoreImageCropInput) => Promise<void>;
|
|
341
|
-
type RestoreImageExtractInput = Omit<RestoreImageCropInput, 'outputPath'>;
|
|
342
|
-
type RestoreImageExtractor = (input: RestoreImageExtractInput) => Promise<Uint8Array>;
|
|
343
|
-
interface RestoreResult {
|
|
344
|
-
document: Document;
|
|
345
|
-
projectPath: string;
|
|
346
|
-
warnings: string[];
|
|
347
|
-
}
|
|
348
|
-
interface RestoreFileSystem extends Pick<FileSystem, 'readFile' | 'readFileRaw' | 'writeFile' | 'writeFileRaw' | 'mkdir' | 'exists' | 'join' | 'dirname'> {
|
|
349
|
-
readdir(path: string): Promise<string[]>;
|
|
350
|
-
isFile(path: string): Promise<boolean>;
|
|
351
|
-
resolvePath(path: string): string | Promise<string>;
|
|
352
|
-
rm?: (path: string, options?: {
|
|
353
|
-
recursive?: boolean;
|
|
354
|
-
force?: boolean;
|
|
355
|
-
}) => Promise<void>;
|
|
356
|
-
}
|
|
357
|
-
interface RestoreOptions {
|
|
358
|
-
inputDir: string;
|
|
359
|
-
output: string;
|
|
360
|
-
fs: RestoreFileSystem;
|
|
361
|
-
packages?: string[];
|
|
362
|
-
force?: boolean;
|
|
363
|
-
projectType?: number;
|
|
364
|
-
cropImage?: RestoreImageCropper;
|
|
365
|
-
extractImage?: RestoreImageExtractor;
|
|
366
|
-
}
|
|
367
|
-
declare function restore(options: RestoreOptions): Promise<RestoreResult>;
|
|
368
|
-
//#endregion
|
|
369
|
-
//#region src/publish.d.ts
|
|
370
|
-
interface PublishOptions {
|
|
371
|
-
/**
|
|
372
|
-
* Output directory for published files (.fui + atlas PNGs).
|
|
373
|
-
* Required.
|
|
374
|
-
*/
|
|
375
|
-
output: string;
|
|
376
|
-
/**
|
|
377
|
-
* Compress the binary data with zlib raw deflate. Default: false.
|
|
378
|
-
*/
|
|
379
|
-
compressed?: boolean;
|
|
380
|
-
/**
|
|
381
|
-
* File extension for the binary output. Default: 'fui'.
|
|
382
|
-
* Unity projects typically use 'bytes'.
|
|
383
|
-
*/
|
|
384
|
-
fileExtension?: string;
|
|
385
|
-
/**
|
|
386
|
-
* Sharp module instance for atlas image compositing.
|
|
387
|
-
* If not provided, atlas packing only computes layout (no PNGs generated).
|
|
388
|
-
*/
|
|
389
|
-
encoder?: unknown;
|
|
390
|
-
/**
|
|
391
|
-
* Base path for reading source images (project assets root).
|
|
392
|
-
* Required when encoder is provided.
|
|
393
|
-
*/
|
|
394
|
-
basePath?: string;
|
|
395
|
-
/**
|
|
396
|
-
* Atlas packing options.
|
|
397
|
-
*/
|
|
398
|
-
atlas?: Omit<AtlasOptions, 'encoder' | 'basePath' | 'outputPath'>;
|
|
399
|
-
/**
|
|
400
|
-
* Filter which packages to publish by name. If not set, all packages are published.
|
|
401
|
-
*/
|
|
402
|
-
packages?: string[];
|
|
403
|
-
/**
|
|
404
|
-
* FileSystem abstraction for writing output files.
|
|
405
|
-
* Required for actual file output. Without it, only the Document model
|
|
406
|
-
* is updated (atlas layout computed, sprite nodes created).
|
|
407
|
-
*/
|
|
408
|
-
fs?: PublishFileSystem;
|
|
409
|
-
/**
|
|
410
|
-
* Active branch name used when branchProcessing is "主干合并活跃分支".
|
|
411
|
-
* Empty or omitted means publishing the main branch.
|
|
412
|
-
*/
|
|
413
|
-
branch?: string;
|
|
414
|
-
}
|
|
415
|
-
interface ResolvedPublishAtlasOptions extends Pick<AtlasOptions, 'maxSize' | 'fast' | 'allowRotation' | 'padding' | 'powerOfTwo' | 'square' | 'multiPage' | 'trimImage' | 'extractAlpha'> {}
|
|
416
|
-
interface ResolvePublishOptionsOverrides {
|
|
417
|
-
compressed?: boolean;
|
|
418
|
-
fileExtension?: string;
|
|
419
|
-
packages?: string[];
|
|
420
|
-
atlas?: Partial<ResolvedPublishAtlasOptions>;
|
|
421
|
-
}
|
|
422
|
-
interface ResolvedPublishOptions {
|
|
423
|
-
compressed: boolean;
|
|
424
|
-
fileExtension: string;
|
|
425
|
-
packages?: string[];
|
|
426
|
-
atlas: ResolvedPublishAtlasOptions;
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Resolve publish defaults from the document's project settings.
|
|
430
|
-
*
|
|
431
|
-
* This keeps the editor-aligned publish rules reusable across environments,
|
|
432
|
-
* while callers still provide environment-specific concerns such as fs/encoder/basePath.
|
|
433
|
-
*/
|
|
434
|
-
declare function resolvePublishOptions(doc: Document, overrides?: ResolvePublishOptionsOverrides): ResolvedPublishOptions;
|
|
435
|
-
/**
|
|
436
|
-
* Publishes a FairyGUI project.
|
|
437
|
-
*
|
|
438
|
-
* Orchestrates:
|
|
439
|
-
* 1. Atlas packing (MaxRects layout + optional sharp compositing)
|
|
440
|
-
* 2. Per-package .fui binary serialization
|
|
441
|
-
* 3. File writing to the output directory
|
|
442
|
-
*
|
|
443
|
-
* ```ts
|
|
444
|
-
* import sharp from 'sharp';
|
|
445
|
-
* const io = new NodeIO();
|
|
446
|
-
* const doc = await io.readProject('./project.fairy');
|
|
447
|
-
*
|
|
448
|
-
* await doc.transform(publish({
|
|
449
|
-
* output: './release/',
|
|
450
|
-
* compressed: true,
|
|
451
|
-
* encoder: sharp,
|
|
452
|
-
* basePath: './assets/',
|
|
453
|
-
* fileExtension: 'bytes',
|
|
454
|
-
* fs: io.createFileSystem(),
|
|
455
|
-
* }));
|
|
456
|
-
* ```
|
|
457
|
-
*/
|
|
458
|
-
declare function publish(options: PublishOptions): Transform;
|
|
459
|
-
//#endregion
|
|
460
171
|
//#region src/utils.d.ts
|
|
461
172
|
/**
|
|
462
173
|
* Wraps a transform function, assigning it a name for the transform stack.
|
|
463
174
|
*/
|
|
464
175
|
declare function createTransform(name: string, fn: Transform): Transform;
|
|
465
176
|
//#endregion
|
|
466
|
-
export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, type CliAtlasSettings, type CliPublishSettings, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type InspectCategoryReport, type InspectReport, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, applyUamTransactionApp, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
|
|
177
|
+
export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppDiagnostic, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, type AtlasRasterBackend, type AtlasRasterCompositeInput, type AtlasRasterInput, type AtlasRasterMetadata, type AtlasRasterPipeline, type AtlasRasterResolvedBuffer, type CliAtlasSettings, type CliCodeGenerationSettings, type CliPublishSettings, type CodeWriter, type CodegenClass, type CodegenMember, type CodegenReferencedComponent, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type ICodeWriterConfig, type InspectCategoryReport, type InspectReport, type LoadedPlugin, type MaybePromise, type Plugin, type PluginManifest, type PluginModule, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type PublishOutputFileSystem, type PublishSourceFileSystem, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPackageCodegenPlan, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, applyUamTransactionApp, atlas, buildCodegenClasses, createTransform, decodeText, encodeText, inspect, prune, publish, publishCodeGeneration, rename, resolvePackageCodegenPlan, resolvePublishOptions, restore, validate };
|