@openfairygui/functions 0.2.0-alpha.11 → 0.2.0-alpha.13

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/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
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 ResolvedPublishAtlasOptions, C as HasOptionalFont, D as RootProjectSettings, E as PublishDependency, M as publish, N as resolvePublishOptions, O as PublishOptions, S as ExtrasMap, T as HasOptionalUrl, _ as PluginManifest, a as PublishCodeGenerationOptions, b as CliCodeGenerationSettings, c as decodeText, d as resolvePackageCodegenPlan, f as CodeWriter, g as Plugin, h as MaybePromise, i as CodegenReferencedComponent, j as ResolvedPublishOptions, k as ResolvePublishOptionsOverrides, l as encodeText, m as LoadedPlugin, n as CodegenClass, o as ResolvedPackageCodegenPlan, p as ICodeWriterConfig, r as CodegenMember, s as buildCodegenClasses, t as AUTO_GENERATED_CODE_MARK, u as publishCodeGeneration, v as PluginModule, w as HasOptionalSrc, x as CliPublishSettings, y as CliAtlasSettings } from "./codegen-C7PPZrB3.cjs";
1
3
  import { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp } from "./uam-transaction.cjs";
2
- import { Component, Document, FileSystem, Package, ProjectSettings, PublishSettings, Transform } from "@openfairygui/core";
4
+ import { Document, FileSystem, Transform } from "@openfairygui/core";
3
5
 
4
6
  //#region src/inspect.d.ts
5
7
  /**
@@ -166,341 +168,6 @@ 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
- * Limit atlas generation to specific package names.
173
- * When omitted, all packages are processed.
174
- */
175
- packages?: string[];
176
- /**
177
- * Sharp module instance, injected by the caller.
178
- * Required for actual image compositing and trimImage.
179
- *
180
- * ```ts
181
- * import sharp from 'sharp';
182
- * await doc.transform(atlas({ encoder: sharp }));
183
- * ```
184
- */
185
- encoder?: unknown;
186
- /** Maximum atlas texture size (width and height). Default: 2048. */
187
- maxSize?: number;
188
- /** Whether to use the fast editor-compatible packing heuristics. Default: true. */
189
- fast?: boolean;
190
- /** Allow rotating sprites 90° for better packing. Default: true. */
191
- allowRotation?: boolean;
192
- /** Pixel padding between sprites. Default: 1. */
193
- padding?: number;
194
- /** Constrain atlas dimensions to powers of two. Default: false. */
195
- powerOfTwo?: boolean;
196
- /** Force square atlas (width === height). Default: false. */
197
- square?: boolean;
198
- /** Allow spilling into multiple atlas pages. Default: true. */
199
- multiPage?: boolean;
200
- /**
201
- * Trim transparent pixels from image edges before packing.
202
- * Requires encoder (sharp). Stores offset/originalSize in Sprite nodes.
203
- * Default: false.
204
- */
205
- trimImage?: boolean;
206
- /**
207
- * Base path for reading source images. If not set, images must have
208
- * their pixel data stored in extras._imageData as Uint8Array.
209
- */
210
- basePath?: string;
211
- /**
212
- * Output directory for generated atlas PNGs.
213
- * Required when encoder is provided.
214
- */
215
- outputPath?: string;
216
- /**
217
- * Optional mkdir function to ensure output directory exists.
218
- * If not provided, the outputPath directory must already exist.
219
- */
220
- mkdir?: (path: string) => Promise<void>;
221
- /**
222
- * Optional raw file reader for reading .jta MovieClip files.
223
- * Required for MovieClip frame atlas packing.
224
- */
225
- readFileRaw?: (path: string) => Promise<Uint8Array>;
226
- /**
227
- * Keep original input order when MaxRects tie-break scores are equal.
228
- * This is an internal publish detail used to mirror editor/CLI behavior.
229
- */
230
- preserveInputOrderOnTie?: boolean;
231
- /**
232
- * Internal publish detail used by Unity binary output:
233
- * allow single untrimmed PNG image packages to bypass the packer and
234
- * write atlas0 directly, matching the reference CLI behavior.
235
- */
236
- directSingleImageOutput?: boolean;
237
- /**
238
- * Internal publish detail used by the direct-image-output path.
239
- * When extractAlpha is enabled, the direct output shortcut must be disabled.
240
- */
241
- extractAlpha?: boolean;
242
- /**
243
- * When branchProcessing keeps branch resources, publish branch images into
244
- * separate atlas pages/files per branch instead of mixing them with main.
245
- */
246
- separatedAtlasForBranch?: boolean;
247
- }
248
- /**
249
- * Packs image resources into texture atlases.
250
- *
251
- * This transform performs MaxRects bin-packing on all ImageResource items
252
- * within each package, creating Atlas and Sprite property nodes. When an
253
- * `encoder` (sharp) is provided, it also composites the actual PNG files.
254
- *
255
- * When `trimImage` is enabled and encoder is available, transparent pixels
256
- * at image edges are trimmed before packing. The trimmed offset and original
257
- * dimensions are stored in the Sprite nodes for runtime reconstruction.
258
- *
259
- * ```ts
260
- * import sharp from 'sharp';
261
- * await doc.transform(atlas({
262
- * encoder: sharp,
263
- * maxSize: 2048,
264
- * trimImage: true,
265
- * basePath: './assets/',
266
- * outputPath: './dist/',
267
- * }));
268
- * ```
269
- */
270
- declare function atlas(_options?: AtlasOptions): Transform;
271
- //#endregion
272
- //#region src/shared-types.d.ts
273
- type ExtrasMap = Record<string, unknown>;
274
- interface CliCodeGenerationSettings extends NonNullable<PublishSettings['codeGeneration']> {
275
- allowGenCode?: boolean;
276
- classNamePrefix?: string;
277
- codePath?: string;
278
- codeType?: string;
279
- getMemberByName?: boolean;
280
- ignoreNoname?: boolean;
281
- memberNamePrefix?: string;
282
- packageName?: string;
283
- }
284
- interface CliAtlasSettings extends NonNullable<PublishSettings['atlasSetting']> {
285
- maxSize?: number;
286
- paging?: boolean;
287
- sizeOption?: string;
288
- forceSquare?: boolean;
289
- fast?: boolean;
290
- allowRotation?: boolean;
291
- padding?: number;
292
- trimImage?: boolean;
293
- extractAlpha?: boolean;
294
- }
295
- interface CliPublishSettings extends PublishSettings {
296
- atlasSetting?: CliAtlasSettings;
297
- codeGeneration?: CliCodeGenerationSettings;
298
- }
299
- type RootProjectSettings = ProjectSettings & {
300
- publish?: CliPublishSettings;
301
- };
302
- interface PublishDependency {
303
- id: string;
304
- name: string;
305
- }
306
- interface HasOptionalFont {
307
- getFont?(): string | string[] | null | undefined;
308
- }
309
- interface HasOptionalSrc {
310
- getSrc?(): string | undefined;
311
- }
312
- interface HasOptionalUrl {
313
- getUrl?(): string | undefined;
314
- }
315
- type PublishFileSystem = Pick<FileSystem, 'join' | 'mkdir' | 'writeFileRaw'> & {
316
- deleteFile?: (path: string) => Promise<void>;
317
- exists?: FileSystem['exists'];
318
- readdir?: FileSystem['readdir'];
319
- readFileRaw?: FileSystem['readFileRaw'];
320
- };
321
- //#endregion
322
- //#region src/publish.d.ts
323
- interface PublishOptions {
324
- /**
325
- * Output directory override for published files (.fui + atlas PNGs).
326
- * When omitted, publish uses package-level or project-level publish paths.
327
- */
328
- output?: string;
329
- /**
330
- * Compress the binary data with zlib raw deflate. Default: false.
331
- */
332
- compressed?: boolean;
333
- /**
334
- * File extension for the binary output. Default: 'fui'.
335
- * Unity projects typically use 'bytes'.
336
- */
337
- fileExtension?: string;
338
- /**
339
- * Sharp module instance for atlas image compositing.
340
- * If not provided, atlas packing only computes layout (no PNGs generated).
341
- */
342
- encoder?: unknown;
343
- /**
344
- * Base path for reading source images (project assets root).
345
- * Required when encoder is provided.
346
- */
347
- basePath?: string;
348
- /**
349
- * Atlas packing options.
350
- */
351
- atlas?: Omit<AtlasOptions, 'encoder' | 'basePath' | 'outputPath'>;
352
- /**
353
- * Filter which packages to publish by name. If not set, all packages are published.
354
- */
355
- packages?: string[];
356
- /**
357
- * FileSystem abstraction for writing output files.
358
- * Required for actual file output. Without it, only the Document model
359
- * is updated (atlas layout computed, sprite nodes created).
360
- */
361
- fs?: PublishFileSystem;
362
- /**
363
- * Active branch name used when branchProcessing is "主干合并活跃分支".
364
- * Empty or omitted means publishing the main branch.
365
- */
366
- branch?: string;
367
- }
368
- interface ResolvedPublishAtlasOptions extends Pick<AtlasOptions, 'maxSize' | 'fast' | 'allowRotation' | 'padding' | 'powerOfTwo' | 'square' | 'multiPage' | 'trimImage' | 'extractAlpha'> {}
369
- interface ResolvePublishOptionsOverrides {
370
- compressed?: boolean;
371
- fileExtension?: string;
372
- packages?: string[];
373
- atlas?: Partial<ResolvedPublishAtlasOptions>;
374
- }
375
- interface ResolvedPublishOptions {
376
- compressed: boolean;
377
- fileExtension: string;
378
- packages?: string[];
379
- atlas: ResolvedPublishAtlasOptions;
380
- }
381
- /**
382
- * Resolve publish defaults from the document's project settings.
383
- *
384
- * This keeps the editor-aligned publish rules reusable across environments,
385
- * while callers still provide environment-specific concerns such as fs/encoder/basePath.
386
- */
387
- declare function resolvePublishOptions(doc: Document, overrides?: ResolvePublishOptionsOverrides): ResolvedPublishOptions;
388
- /**
389
- * Publishes a FairyGUI project.
390
- *
391
- * Orchestrates:
392
- * 1. Atlas packing (MaxRects layout + optional sharp compositing)
393
- * 2. Per-package .fui binary serialization
394
- * 3. File writing to the output directory
395
- *
396
- * ```ts
397
- * import sharp from 'sharp';
398
- * const io = new NodeIO();
399
- * const doc = await io.readProject('./project.fairy');
400
- *
401
- * await doc.transform(publish({
402
- * output: './release/',
403
- * compressed: true,
404
- * encoder: sharp,
405
- * basePath: './assets/',
406
- * fileExtension: 'bytes',
407
- * fs: io.createFileSystem(),
408
- * }));
409
- * ```
410
- */
411
- declare function publish(options: PublishOptions): Transform;
412
- //#endregion
413
- //#region src/plugins/types.d.ts
414
- type MaybePromise<T> = T | Promise<T>;
415
- interface PluginManifest {
416
- name: string;
417
- displayName?: string;
418
- description?: string;
419
- version?: string;
420
- author?: {
421
- name?: string;
422
- };
423
- icon?: string;
424
- main: string;
425
- }
426
- interface ICodeWriterConfig {
427
- blockStart?: string;
428
- blockEnd?: string;
429
- blockFromNewLine?: boolean;
430
- usingTabs?: boolean;
431
- endOfLine?: string;
432
- fileMark?: string;
433
- }
434
- interface CodeWriter {
435
- writeMark(): void;
436
- writeln(fmt?: string, ...args: any[]): CodeWriter;
437
- startBlock(): CodeWriter;
438
- endBlock(): CodeWriter;
439
- incIndent(): CodeWriter;
440
- decIndent(): CodeWriter;
441
- reset(): void;
442
- toString(): string;
443
- save(filePath: string): void;
444
- }
445
- interface Plugin {
446
- genCode?: (doc: Document, settings: Required<CliCodeGenerationSettings>, options: PublishCodeGenerationOptions) => MaybePromise<void>;
447
- onPublishStart?: (doc: Document, options: PublishOptions) => MaybePromise<void>;
448
- onPublishEnd?: (doc: Document, options: PublishOptions) => MaybePromise<void>;
449
- }
450
- type PluginModule = Plugin & {
451
- default?: Plugin;
452
- };
453
- //#endregion
454
- //#region src/plugins/loader.d.ts
455
- interface LoadedPlugin {
456
- name: string;
457
- plugin: Plugin;
458
- }
459
- //#endregion
460
- //#region src/codegen.d.ts
461
- declare const AUTO_GENERATED_CODE_MARK = "/** This is an automatically generated class by FairyGUI. Please do not modify it. **/";
462
- interface PublishCodeGenerationOptions {
463
- basePath?: string;
464
- fs: PublishFileSystem;
465
- packages: Package[];
466
- plugins?: LoadedPlugin[];
467
- }
468
- interface ResolvedPackageCodegenPlan {
469
- outputDir: string;
470
- packageFolderName: string;
471
- packageNamespace: string;
472
- binderClassName: string;
473
- settings: CliCodeGenerationSettings;
474
- }
475
- interface CodegenMember {
476
- index: number;
477
- kind: 'child' | 'controller' | 'transition';
478
- name: string;
479
- originalName: string;
480
- type: string;
481
- ignored: boolean;
482
- referencedComponent?: CodegenReferencedComponent;
483
- }
484
- interface CodegenReferencedComponent {
485
- component: Component;
486
- package: Package;
487
- }
488
- interface CodegenClass {
489
- classId: string;
490
- className: string;
491
- encodedClassName: string;
492
- componentType: string;
493
- componentName: string;
494
- packageName: string;
495
- url: string;
496
- members: CodegenMember[];
497
- }
498
- declare function publishCodeGeneration(doc: Document, options: PublishCodeGenerationOptions): Promise<void>;
499
- declare function resolvePackageCodegenPlan(pkg: Package, settings: CliCodeGenerationSettings, options: PublishCodeGenerationOptions): ResolvedPackageCodegenPlan | null;
500
- declare function buildCodegenClasses(doc: Document, pkg: Package, plan: ResolvedPackageCodegenPlan): CodegenClass[];
501
- declare function encodeText(value: string): Uint8Array;
502
- declare function decodeText(value: Uint8Array): string;
503
- //#endregion
504
171
  //#region src/restore.d.ts
505
172
  interface RestoreImageCropInput {
506
173
  sourcePath: string;
@@ -550,4 +217,4 @@ declare function restore(options: RestoreOptions): Promise<RestoreResult>;
550
217
  */
551
218
  declare function createTransform(name: string, fn: Transform): Transform;
552
219
  //#endregion
553
- export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppDiagnostic, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, 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 MaybePromise, type Plugin, type PluginManifest, type PluginModule, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, 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 };
220
+ 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 };