@openfairygui/functions 0.2.0-alpha.1 → 0.2.0-alpha.12

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 CHANGED
@@ -11,16 +11,45 @@ npm install --save @openfairygui/core @openfairygui/functions
11
11
  ## Usage
12
12
 
13
13
  ```ts
14
- import { NodeIO } from '@openfairygui/core';
15
- import { inspect, publish } from '@openfairygui/functions';
14
+ import { NodeIO } from '@openfairygui/core/node';
15
+ import { inspect } from '@openfairygui/functions';
16
+ import { publishNode } from '@openfairygui/functions/node';
16
17
 
17
18
  const io = new NodeIO();
18
19
  const doc = await io.readProject('./MyProject/MyProject.fairy');
19
20
 
20
21
  const report = inspect(doc);
21
- await doc.transform(publish({ output: './release' }));
22
+ await publishNode({ document: doc, output: './release' });
22
23
  ```
23
24
 
25
+ `publishNode` owns the standard Node filesystem, Sharp raster backend, and project plugin discovery. The root `publish()` export remains the lower-level capability-injected core for custom hosts.
26
+
27
+ ## Browser LayaBox publish
28
+
29
+ Use `@openfairygui/core/web` to read the raw project, then publish through the browser-only entry. Both filesystems are caller-owned, so they can be File System Access, OPFS, IndexedDB, ZIP, or memory adapters.
30
+
31
+ ```ts
32
+ import { WebIO } from '@openfairygui/core/web';
33
+ import { publishBrowser } from '@openfairygui/functions/web';
34
+
35
+ const document = await new WebIO(sourceFileSystem).readProject('Project.fairy');
36
+ const result = await publishBrowser({
37
+ document,
38
+ sourceFileSystem,
39
+ outputFileSystem,
40
+ projectType: 'layabox',
41
+ output: '.fairygui-runtime',
42
+ });
43
+
44
+ if (!result.success) console.error(result.diagnostics);
45
+ ```
46
+
47
+ The browser entry uses native Canvas APIs for atlas PNGs, writes only through `outputFileSystem`, supplies no Node plugin capability, and disables non-runtime code generation.
48
+
49
+ Publish plugins are documented in the repository guide:
50
+
51
+ - https://github.com/OpenFairyGUI/OpenFairyGUI/blob/main/docs/publish-plugins.md
52
+
24
53
  ## Phase A UAM authoring seam
25
54
 
26
55
  `@openfairygui/functions` also exposes a thin stateless wrapper over the Phase A UAM
@@ -0,0 +1,193 @@
1
+ import { FileSystem, Transform } from "@openfairygui/core";
2
+
3
+ //#region src/publish/contracts.d.ts
4
+ /**
5
+ * Source files required by a publish adapter.
6
+ *
7
+ * The host owns this filesystem: Node adapters use native paths while web
8
+ * adapters can use File System Access, OPFS, IndexedDB, ZIP, or memory.
9
+ */
10
+ type PublishSourceFileSystem = Pick<FileSystem, 'readFileRaw' | 'join'>;
11
+ /**
12
+ * Output files required by a publish adapter.
13
+ */
14
+ type PublishOutputFileSystem = Pick<FileSystem, 'writeFileRaw' | 'mkdir' | 'join'>;
15
+ /**
16
+ * Full filesystem contract consumed by the capability-injected publish core.
17
+ *
18
+ * Read, enumeration, and delete operations are optional because individual
19
+ * publish lanes only request them when needed.
20
+ */
21
+ type PublishFileSystem = PublishOutputFileSystem & {
22
+ deleteFile?: (path: string) => Promise<void>;
23
+ exists?: FileSystem['exists'];
24
+ readdir?: FileSystem['readdir'];
25
+ readFileRaw?: FileSystem['readFileRaw'];
26
+ };
27
+ interface AtlasRasterMetadata {
28
+ width?: number;
29
+ height?: number;
30
+ channels?: number;
31
+ hasAlpha?: boolean;
32
+ trimOffsetLeft?: number;
33
+ trimOffsetTop?: number;
34
+ }
35
+ interface AtlasRasterResolvedBuffer {
36
+ data: Uint8Array;
37
+ info: Required<Pick<AtlasRasterMetadata, 'width' | 'height' | 'channels'>> & AtlasRasterMetadata;
38
+ }
39
+ interface AtlasRasterCompositeInput {
40
+ input: Uint8Array;
41
+ left: number;
42
+ top: number;
43
+ }
44
+ type AtlasRasterInput = string | Uint8Array | {
45
+ create: {
46
+ width: number;
47
+ height: number;
48
+ channels: 4;
49
+ background: {
50
+ r: number;
51
+ g: number;
52
+ b: number;
53
+ alpha: number;
54
+ };
55
+ };
56
+ };
57
+ /**
58
+ * Host-provided raster pipeline used by atlas packing.
59
+ *
60
+ * Sharp and the browser Canvas adapter both satisfy this contract.
61
+ */
62
+ interface AtlasRasterPipeline {
63
+ ensureAlpha(): AtlasRasterPipeline;
64
+ resize(options: {
65
+ width: number;
66
+ height: number;
67
+ fit?: 'fill';
68
+ }): AtlasRasterPipeline;
69
+ raw(): AtlasRasterPipeline;
70
+ extract(options: {
71
+ left: number;
72
+ top: number;
73
+ width: number;
74
+ height: number;
75
+ }): AtlasRasterPipeline;
76
+ png(): AtlasRasterPipeline;
77
+ rotate(angle: number): AtlasRasterPipeline;
78
+ composite(inputs: AtlasRasterCompositeInput[]): AtlasRasterPipeline;
79
+ metadata(): Promise<AtlasRasterMetadata>;
80
+ toBuffer(options: {
81
+ resolveWithObject: true;
82
+ }): Promise<AtlasRasterResolvedBuffer>;
83
+ toBuffer(options?: {
84
+ resolveWithObject?: false;
85
+ }): Promise<Uint8Array>;
86
+ toFile(path: string): Promise<unknown>;
87
+ }
88
+ type AtlasRasterBackend = (input: AtlasRasterInput) => AtlasRasterPipeline;
89
+ //#endregion
90
+ //#region src/atlas.d.ts
91
+ interface AtlasOptions {
92
+ /**
93
+ * Limit atlas generation to specific package names.
94
+ * When omitted, all packages are processed.
95
+ */
96
+ packages?: string[];
97
+ /**
98
+ * Raster backend, injected by the host adapter.
99
+ * Required for actual image compositing and trimImage.
100
+ *
101
+ * ```ts
102
+ * import sharp from 'sharp';
103
+ * await doc.transform(atlas({ encoder: sharp }));
104
+ * ```
105
+ */
106
+ encoder?: AtlasRasterBackend;
107
+ /** Maximum atlas texture size (width and height). Default: 2048. */
108
+ maxSize?: number;
109
+ /** Whether to use the fast editor-compatible packing heuristics. Default: true. */
110
+ fast?: boolean;
111
+ /** Allow rotating sprites 90° for better packing. Default: true. */
112
+ allowRotation?: boolean;
113
+ /** Pixel padding between sprites. Default: 1. */
114
+ padding?: number;
115
+ /** Constrain atlas dimensions to powers of two. Default: false. */
116
+ powerOfTwo?: boolean;
117
+ /** Force square atlas (width === height). Default: false. */
118
+ square?: boolean;
119
+ /** Allow spilling into multiple atlas pages. Default: true. */
120
+ multiPage?: boolean;
121
+ /**
122
+ * Trim transparent pixels from image edges before packing.
123
+ * Requires a raster backend. Stores offset/originalSize in Sprite nodes.
124
+ * Default: false.
125
+ */
126
+ trimImage?: boolean;
127
+ /**
128
+ * Base path for reading source images. If not set, images must have
129
+ * their pixel data stored in extras._imageData as Uint8Array.
130
+ */
131
+ basePath?: string;
132
+ /**
133
+ * Output directory for generated atlas PNGs.
134
+ * Required when encoder is provided.
135
+ */
136
+ outputPath?: string;
137
+ /**
138
+ * Optional mkdir function to ensure output directory exists.
139
+ * If not provided, the outputPath directory must already exist.
140
+ */
141
+ mkdir?: (path: string) => Promise<void>;
142
+ /**
143
+ * Optional raw file reader for reading .jta MovieClip files.
144
+ * Required for MovieClip frame atlas packing.
145
+ */
146
+ readFileRaw?: (path: string) => Promise<Uint8Array>;
147
+ /**
148
+ * Keep original input order when MaxRects tie-break scores are equal.
149
+ * This is an internal publish detail used to mirror editor/CLI behavior.
150
+ */
151
+ preserveInputOrderOnTie?: boolean;
152
+ /**
153
+ * Internal publish detail used by Unity binary output:
154
+ * allow single untrimmed PNG image packages to bypass the packer and
155
+ * write atlas0 directly, matching the reference CLI behavior.
156
+ */
157
+ directSingleImageOutput?: boolean;
158
+ /**
159
+ * Internal publish detail used by the direct-image-output path.
160
+ * When extractAlpha is enabled, the direct output shortcut must be disabled.
161
+ */
162
+ extractAlpha?: boolean;
163
+ /**
164
+ * When branchProcessing keeps branch resources, publish branch images into
165
+ * separate atlas pages/files per branch instead of mixing them with main.
166
+ */
167
+ separatedAtlasForBranch?: boolean;
168
+ }
169
+ /**
170
+ * Packs image resources into texture atlases.
171
+ *
172
+ * This transform performs MaxRects bin-packing on all ImageResource items
173
+ * within each package, creating Atlas and Sprite property nodes. When an
174
+ * a raster backend is provided, it also composites the actual PNG files.
175
+ *
176
+ * When `trimImage` is enabled and encoder is available, transparent pixels
177
+ * at image edges are trimmed before packing. The trimmed offset and original
178
+ * dimensions are stored in the Sprite nodes for runtime reconstruction.
179
+ *
180
+ * ```ts
181
+ * import sharp from 'sharp';
182
+ * await doc.transform(atlas({
183
+ * encoder: sharp,
184
+ * maxSize: 2048,
185
+ * trimImage: true,
186
+ * basePath: './assets/',
187
+ * outputPath: './dist/',
188
+ * }));
189
+ * ```
190
+ */
191
+ declare function atlas(_options?: AtlasOptions): Transform;
192
+ //#endregion
193
+ export { AtlasRasterInput as a, AtlasRasterResolvedBuffer as c, PublishSourceFileSystem as d, AtlasRasterCompositeInput as i, PublishFileSystem as l, atlas as n, AtlasRasterMetadata as o, AtlasRasterBackend as r, AtlasRasterPipeline as s, AtlasOptions as t, PublishOutputFileSystem as u };
@@ -0,0 +1,193 @@
1
+ import { FileSystem, Transform } from "@openfairygui/core";
2
+
3
+ //#region src/publish/contracts.d.ts
4
+ /**
5
+ * Source files required by a publish adapter.
6
+ *
7
+ * The host owns this filesystem: Node adapters use native paths while web
8
+ * adapters can use File System Access, OPFS, IndexedDB, ZIP, or memory.
9
+ */
10
+ type PublishSourceFileSystem = Pick<FileSystem, 'readFileRaw' | 'join'>;
11
+ /**
12
+ * Output files required by a publish adapter.
13
+ */
14
+ type PublishOutputFileSystem = Pick<FileSystem, 'writeFileRaw' | 'mkdir' | 'join'>;
15
+ /**
16
+ * Full filesystem contract consumed by the capability-injected publish core.
17
+ *
18
+ * Read, enumeration, and delete operations are optional because individual
19
+ * publish lanes only request them when needed.
20
+ */
21
+ type PublishFileSystem = PublishOutputFileSystem & {
22
+ deleteFile?: (path: string) => Promise<void>;
23
+ exists?: FileSystem['exists'];
24
+ readdir?: FileSystem['readdir'];
25
+ readFileRaw?: FileSystem['readFileRaw'];
26
+ };
27
+ interface AtlasRasterMetadata {
28
+ width?: number;
29
+ height?: number;
30
+ channels?: number;
31
+ hasAlpha?: boolean;
32
+ trimOffsetLeft?: number;
33
+ trimOffsetTop?: number;
34
+ }
35
+ interface AtlasRasterResolvedBuffer {
36
+ data: Uint8Array;
37
+ info: Required<Pick<AtlasRasterMetadata, 'width' | 'height' | 'channels'>> & AtlasRasterMetadata;
38
+ }
39
+ interface AtlasRasterCompositeInput {
40
+ input: Uint8Array;
41
+ left: number;
42
+ top: number;
43
+ }
44
+ type AtlasRasterInput = string | Uint8Array | {
45
+ create: {
46
+ width: number;
47
+ height: number;
48
+ channels: 4;
49
+ background: {
50
+ r: number;
51
+ g: number;
52
+ b: number;
53
+ alpha: number;
54
+ };
55
+ };
56
+ };
57
+ /**
58
+ * Host-provided raster pipeline used by atlas packing.
59
+ *
60
+ * Sharp and the browser Canvas adapter both satisfy this contract.
61
+ */
62
+ interface AtlasRasterPipeline {
63
+ ensureAlpha(): AtlasRasterPipeline;
64
+ resize(options: {
65
+ width: number;
66
+ height: number;
67
+ fit?: 'fill';
68
+ }): AtlasRasterPipeline;
69
+ raw(): AtlasRasterPipeline;
70
+ extract(options: {
71
+ left: number;
72
+ top: number;
73
+ width: number;
74
+ height: number;
75
+ }): AtlasRasterPipeline;
76
+ png(): AtlasRasterPipeline;
77
+ rotate(angle: number): AtlasRasterPipeline;
78
+ composite(inputs: AtlasRasterCompositeInput[]): AtlasRasterPipeline;
79
+ metadata(): Promise<AtlasRasterMetadata>;
80
+ toBuffer(options: {
81
+ resolveWithObject: true;
82
+ }): Promise<AtlasRasterResolvedBuffer>;
83
+ toBuffer(options?: {
84
+ resolveWithObject?: false;
85
+ }): Promise<Uint8Array>;
86
+ toFile(path: string): Promise<unknown>;
87
+ }
88
+ type AtlasRasterBackend = (input: AtlasRasterInput) => AtlasRasterPipeline;
89
+ //#endregion
90
+ //#region src/atlas.d.ts
91
+ interface AtlasOptions {
92
+ /**
93
+ * Limit atlas generation to specific package names.
94
+ * When omitted, all packages are processed.
95
+ */
96
+ packages?: string[];
97
+ /**
98
+ * Raster backend, injected by the host adapter.
99
+ * Required for actual image compositing and trimImage.
100
+ *
101
+ * ```ts
102
+ * import sharp from 'sharp';
103
+ * await doc.transform(atlas({ encoder: sharp }));
104
+ * ```
105
+ */
106
+ encoder?: AtlasRasterBackend;
107
+ /** Maximum atlas texture size (width and height). Default: 2048. */
108
+ maxSize?: number;
109
+ /** Whether to use the fast editor-compatible packing heuristics. Default: true. */
110
+ fast?: boolean;
111
+ /** Allow rotating sprites 90° for better packing. Default: true. */
112
+ allowRotation?: boolean;
113
+ /** Pixel padding between sprites. Default: 1. */
114
+ padding?: number;
115
+ /** Constrain atlas dimensions to powers of two. Default: false. */
116
+ powerOfTwo?: boolean;
117
+ /** Force square atlas (width === height). Default: false. */
118
+ square?: boolean;
119
+ /** Allow spilling into multiple atlas pages. Default: true. */
120
+ multiPage?: boolean;
121
+ /**
122
+ * Trim transparent pixels from image edges before packing.
123
+ * Requires a raster backend. Stores offset/originalSize in Sprite nodes.
124
+ * Default: false.
125
+ */
126
+ trimImage?: boolean;
127
+ /**
128
+ * Base path for reading source images. If not set, images must have
129
+ * their pixel data stored in extras._imageData as Uint8Array.
130
+ */
131
+ basePath?: string;
132
+ /**
133
+ * Output directory for generated atlas PNGs.
134
+ * Required when encoder is provided.
135
+ */
136
+ outputPath?: string;
137
+ /**
138
+ * Optional mkdir function to ensure output directory exists.
139
+ * If not provided, the outputPath directory must already exist.
140
+ */
141
+ mkdir?: (path: string) => Promise<void>;
142
+ /**
143
+ * Optional raw file reader for reading .jta MovieClip files.
144
+ * Required for MovieClip frame atlas packing.
145
+ */
146
+ readFileRaw?: (path: string) => Promise<Uint8Array>;
147
+ /**
148
+ * Keep original input order when MaxRects tie-break scores are equal.
149
+ * This is an internal publish detail used to mirror editor/CLI behavior.
150
+ */
151
+ preserveInputOrderOnTie?: boolean;
152
+ /**
153
+ * Internal publish detail used by Unity binary output:
154
+ * allow single untrimmed PNG image packages to bypass the packer and
155
+ * write atlas0 directly, matching the reference CLI behavior.
156
+ */
157
+ directSingleImageOutput?: boolean;
158
+ /**
159
+ * Internal publish detail used by the direct-image-output path.
160
+ * When extractAlpha is enabled, the direct output shortcut must be disabled.
161
+ */
162
+ extractAlpha?: boolean;
163
+ /**
164
+ * When branchProcessing keeps branch resources, publish branch images into
165
+ * separate atlas pages/files per branch instead of mixing them with main.
166
+ */
167
+ separatedAtlasForBranch?: boolean;
168
+ }
169
+ /**
170
+ * Packs image resources into texture atlases.
171
+ *
172
+ * This transform performs MaxRects bin-packing on all ImageResource items
173
+ * within each package, creating Atlas and Sprite property nodes. When an
174
+ * a raster backend is provided, it also composites the actual PNG files.
175
+ *
176
+ * When `trimImage` is enabled and encoder is available, transparent pixels
177
+ * at image edges are trimmed before packing. The trimmed offset and original
178
+ * dimensions are stored in the Sprite nodes for runtime reconstruction.
179
+ *
180
+ * ```ts
181
+ * import sharp from 'sharp';
182
+ * await doc.transform(atlas({
183
+ * encoder: sharp,
184
+ * maxSize: 2048,
185
+ * trimImage: true,
186
+ * basePath: './assets/',
187
+ * outputPath: './dist/',
188
+ * }));
189
+ * ```
190
+ */
191
+ declare function atlas(_options?: AtlasOptions): Transform;
192
+ //#endregion
193
+ export { AtlasRasterInput as a, AtlasRasterResolvedBuffer as c, PublishSourceFileSystem as d, AtlasRasterCompositeInput as i, PublishFileSystem as l, atlas as n, AtlasRasterMetadata as o, AtlasRasterBackend as r, AtlasRasterPipeline as s, AtlasOptions as t, PublishOutputFileSystem as u };
@@ -0,0 +1,241 @@
1
+ import { l as PublishFileSystem, r as AtlasRasterBackend, t as AtlasOptions } from "./atlas-CHsu2Y8i.cjs";
2
+ import { Component, Document, Package, ProjectSettings, PublishSettings, Transform } from "@openfairygui/core";
3
+
4
+ //#region src/publish.d.ts
5
+ interface PublishOptions {
6
+ /**
7
+ * Output directory override for published files (.fui + atlas PNGs).
8
+ * When omitted, publish uses package-level or project-level publish paths.
9
+ */
10
+ output?: string;
11
+ /**
12
+ * Compress the binary data with zlib raw deflate. Default: false.
13
+ */
14
+ compressed?: boolean;
15
+ /**
16
+ * File extension for the binary output. Default: 'fui'.
17
+ * Unity projects typically use 'bytes'.
18
+ */
19
+ fileExtension?: string;
20
+ /**
21
+ * Raster backend for atlas image compositing.
22
+ * If not provided, atlas packing only computes layout (no PNGs generated).
23
+ */
24
+ encoder?: AtlasRasterBackend;
25
+ /**
26
+ * Base path for reading source images (project assets root).
27
+ * Required when encoder is provided.
28
+ */
29
+ basePath?: string;
30
+ /**
31
+ * Atlas packing options.
32
+ */
33
+ atlas?: Omit<AtlasOptions, 'encoder' | 'basePath' | 'outputPath'>;
34
+ /**
35
+ * Filter which packages to publish by name. If not set, all packages are published.
36
+ */
37
+ packages?: string[];
38
+ /**
39
+ * FileSystem abstraction for writing output files.
40
+ * Required for actual file output. Without it, only the Document model
41
+ * is updated (atlas layout computed, sprite nodes created).
42
+ */
43
+ fs?: PublishFileSystem;
44
+ /**
45
+ * Active branch name used when branchProcessing is "主干合并活跃分支".
46
+ * Empty or omitted means publishing the main branch.
47
+ */
48
+ branch?: string;
49
+ /**
50
+ * Publish hooks supplied by the host adapter.
51
+ *
52
+ * Node adapters load project plugins. Browser adapters pass an empty list.
53
+ */
54
+ plugins?: LoadedPlugin[];
55
+ /**
56
+ * Run generic code generation after runtime artifacts. Default: true.
57
+ */
58
+ codeGeneration?: boolean;
59
+ }
60
+ interface ResolvedPublishAtlasOptions extends Pick<AtlasOptions, 'maxSize' | 'fast' | 'allowRotation' | 'padding' | 'powerOfTwo' | 'square' | 'multiPage' | 'trimImage' | 'extractAlpha'> {}
61
+ interface ResolvePublishOptionsOverrides {
62
+ compressed?: boolean;
63
+ fileExtension?: string;
64
+ packages?: string[];
65
+ atlas?: Partial<ResolvedPublishAtlasOptions>;
66
+ }
67
+ interface ResolvedPublishOptions {
68
+ compressed: boolean;
69
+ fileExtension: string;
70
+ packages?: string[];
71
+ atlas: ResolvedPublishAtlasOptions;
72
+ }
73
+ /**
74
+ * Resolve publish defaults from the document's project settings.
75
+ *
76
+ * This keeps the editor-aligned publish rules reusable across environments,
77
+ * while callers still provide environment-specific concerns such as fs/encoder/basePath.
78
+ */
79
+ declare function resolvePublishOptions(doc: Document, overrides?: ResolvePublishOptionsOverrides): ResolvedPublishOptions;
80
+ /**
81
+ * Publishes a FairyGUI project.
82
+ *
83
+ * Orchestrates:
84
+ * 1. Atlas packing (MaxRects layout + optional raster compositing)
85
+ * 2. Per-package .fui binary serialization
86
+ * 3. File writing to the output directory
87
+ *
88
+ * This is the capability-injected core. Standard hosts should use
89
+ * `publishNode()` or `publishBrowser()` through their dedicated entries.
90
+ *
91
+ * ```ts
92
+ * import sharp from 'sharp';
93
+ * const io = new NodeIO();
94
+ * const doc = await io.readProject('./project.fairy');
95
+ *
96
+ * await doc.transform(publish({
97
+ * output: './release/',
98
+ * compressed: true,
99
+ * encoder: sharp,
100
+ * basePath: './assets/',
101
+ * fileExtension: 'bytes',
102
+ * fs: io.createFileSystem(),
103
+ * }));
104
+ * ```
105
+ */
106
+ declare function publish(options: PublishOptions): Transform;
107
+ //#endregion
108
+ //#region src/shared-types.d.ts
109
+ type ExtrasMap = Record<string, unknown>;
110
+ interface CliCodeGenerationSettings extends NonNullable<PublishSettings['codeGeneration']> {
111
+ allowGenCode?: boolean;
112
+ classNamePrefix?: string;
113
+ codePath?: string;
114
+ codeType?: string;
115
+ getMemberByName?: boolean;
116
+ ignoreNoname?: boolean;
117
+ memberNamePrefix?: string;
118
+ packageName?: string;
119
+ }
120
+ interface CliAtlasSettings extends NonNullable<PublishSettings['atlasSetting']> {
121
+ maxSize?: number;
122
+ paging?: boolean;
123
+ sizeOption?: string;
124
+ forceSquare?: boolean;
125
+ fast?: boolean;
126
+ allowRotation?: boolean;
127
+ padding?: number;
128
+ trimImage?: boolean;
129
+ extractAlpha?: boolean;
130
+ }
131
+ interface CliPublishSettings extends PublishSettings {
132
+ atlasSetting?: CliAtlasSettings;
133
+ codeGeneration?: CliCodeGenerationSettings;
134
+ }
135
+ type RootProjectSettings = ProjectSettings & {
136
+ publish?: CliPublishSettings;
137
+ };
138
+ interface PublishDependency {
139
+ id: string;
140
+ name: string;
141
+ }
142
+ interface HasOptionalFont {
143
+ getFont?(): string | string[] | null | undefined;
144
+ }
145
+ interface HasOptionalSrc {
146
+ getSrc?(): string | undefined;
147
+ }
148
+ interface HasOptionalUrl {
149
+ getUrl?(): string | undefined;
150
+ }
151
+ //#endregion
152
+ //#region src/plugins/types.d.ts
153
+ type MaybePromise<T> = T | Promise<T>;
154
+ interface PluginManifest {
155
+ name: string;
156
+ displayName?: string;
157
+ description?: string;
158
+ version?: string;
159
+ author?: {
160
+ name?: string;
161
+ };
162
+ icon?: string;
163
+ main: string;
164
+ }
165
+ interface ICodeWriterConfig {
166
+ blockStart?: string;
167
+ blockEnd?: string;
168
+ blockFromNewLine?: boolean;
169
+ usingTabs?: boolean;
170
+ endOfLine?: string;
171
+ fileMark?: string;
172
+ }
173
+ interface CodeWriter {
174
+ writeMark(): void;
175
+ writeln(fmt?: string, ...args: any[]): CodeWriter;
176
+ startBlock(): CodeWriter;
177
+ endBlock(): CodeWriter;
178
+ incIndent(): CodeWriter;
179
+ decIndent(): CodeWriter;
180
+ reset(): void;
181
+ toString(): string;
182
+ save(filePath: string): void;
183
+ }
184
+ interface Plugin {
185
+ genCode?: (doc: Document, settings: Required<CliCodeGenerationSettings>, options: PublishCodeGenerationOptions) => MaybePromise<void>;
186
+ onPublishStart?: (doc: Document, options: PublishOptions) => MaybePromise<void>;
187
+ onPublishEnd?: (doc: Document, options: PublishOptions) => MaybePromise<void>;
188
+ }
189
+ interface LoadedPlugin {
190
+ name: string;
191
+ plugin: Plugin;
192
+ }
193
+ type PluginModule = Plugin & {
194
+ default?: Plugin;
195
+ };
196
+ //#endregion
197
+ //#region src/codegen.d.ts
198
+ declare const AUTO_GENERATED_CODE_MARK = "/** This is an automatically generated class by FairyGUI. Please do not modify it. **/";
199
+ interface PublishCodeGenerationOptions {
200
+ basePath?: string;
201
+ fs: PublishFileSystem;
202
+ packages: Package[];
203
+ plugins?: LoadedPlugin[];
204
+ }
205
+ interface ResolvedPackageCodegenPlan {
206
+ outputDir: string;
207
+ packageFolderName: string;
208
+ packageNamespace: string;
209
+ binderClassName: string;
210
+ settings: CliCodeGenerationSettings;
211
+ }
212
+ interface CodegenMember {
213
+ index: number;
214
+ kind: 'child' | 'controller' | 'transition';
215
+ name: string;
216
+ originalName: string;
217
+ type: string;
218
+ ignored: boolean;
219
+ referencedComponent?: CodegenReferencedComponent;
220
+ }
221
+ interface CodegenReferencedComponent {
222
+ component: Component;
223
+ package: Package;
224
+ }
225
+ interface CodegenClass {
226
+ classId: string;
227
+ className: string;
228
+ encodedClassName: string;
229
+ componentType: string;
230
+ componentName: string;
231
+ packageName: string;
232
+ url: string;
233
+ members: CodegenMember[];
234
+ }
235
+ declare function publishCodeGeneration(doc: Document, options: PublishCodeGenerationOptions): Promise<void>;
236
+ declare function resolvePackageCodegenPlan(pkg: Package, settings: CliCodeGenerationSettings, options: PublishCodeGenerationOptions): ResolvedPackageCodegenPlan | null;
237
+ declare function buildCodegenClasses(doc: Document, pkg: Package, plan: ResolvedPackageCodegenPlan): CodegenClass[];
238
+ declare function encodeText(value: string): Uint8Array;
239
+ declare function decodeText(value: Uint8Array): string;
240
+ //#endregion
241
+ export { ResolvedPublishAtlasOptions as A, HasOptionalFont as C, RootProjectSettings as D, PublishDependency as E, publish as M, resolvePublishOptions as N, PublishOptions as O, ExtrasMap as S, HasOptionalUrl as T, PluginManifest as _, PublishCodeGenerationOptions as a, CliCodeGenerationSettings as b, decodeText as c, resolvePackageCodegenPlan as d, CodeWriter as f, Plugin as g, MaybePromise as h, CodegenReferencedComponent as i, ResolvedPublishOptions as j, ResolvePublishOptionsOverrides as k, encodeText as l, LoadedPlugin as m, CodegenClass as n, ResolvedPackageCodegenPlan as o, ICodeWriterConfig as p, CodegenMember as r, buildCodegenClasses as s, AUTO_GENERATED_CODE_MARK as t, publishCodeGeneration as u, PluginModule as v, HasOptionalSrc as w, CliPublishSettings as x, CliAtlasSettings as y };