@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.
@@ -0,0 +1,241 @@
1
+ import { l as PublishFileSystem, r as AtlasRasterBackend, t as AtlasOptions } from "./atlas-CDn6TirX.js";
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 };