@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.
Files changed (54) hide show
  1. package/README.md +48 -6
  2. package/dist/atlas-C6tbl7nn.d.ts +193 -0
  3. package/dist/atlas-CHsu2Y8i.d.cts +193 -0
  4. package/dist/index.cjs +16 -3603
  5. package/dist/index.d.cts +5 -294
  6. package/dist/index.d.ts +5 -294
  7. package/dist/index.js +3 -3594
  8. package/dist/node.cjs +256 -0
  9. package/dist/node.d.cts +36 -0
  10. package/dist/node.d.ts +36 -0
  11. package/dist/node.js +254 -0
  12. package/dist/publish-BJ_eelME.js +3267 -0
  13. package/dist/publish-xFWT9Slz.cjs +3338 -0
  14. package/dist/restore-BW2xacB3.cjs +936 -0
  15. package/dist/restore-BeWaJNjR.d.cts +288 -0
  16. package/dist/restore-Clk62n0O.js +931 -0
  17. package/dist/restore-Dh0-Nvms.d.ts +288 -0
  18. package/dist/uam-transaction.cjs +44 -1
  19. package/dist/uam-transaction.d.cts +16 -1
  20. package/dist/uam-transaction.d.ts +16 -1
  21. package/dist/uam-transaction.js +44 -1
  22. package/dist/web.cjs +274 -0
  23. package/dist/web.d.cts +41 -0
  24. package/dist/web.d.ts +41 -0
  25. package/dist/web.js +273 -0
  26. package/package.json +28 -4
  27. package/src/adapters/node/plugins.ts +82 -0
  28. package/src/adapters/node/publish.ts +130 -0
  29. package/src/adapters/node/restore.ts +187 -0
  30. package/src/adapters/web/publish.ts +159 -0
  31. package/src/adapters/web/raster.ts +251 -0
  32. package/src/atlas/font.ts +95 -0
  33. package/src/atlas/inputs.ts +515 -0
  34. package/src/atlas/jta.ts +211 -0
  35. package/src/atlas/packing.ts +767 -0
  36. package/src/atlas.ts +116 -1221
  37. package/src/codegen.ts +106 -67
  38. package/src/index.ts +43 -3
  39. package/src/node.ts +8 -0
  40. package/src/plugins/types.ts +56 -0
  41. package/src/publish/contracts.ts +80 -0
  42. package/src/publish/external-resources.ts +117 -0
  43. package/src/publish/options.ts +180 -0
  44. package/src/publish/package-context.ts +608 -0
  45. package/src/publish/resource-references.ts +210 -0
  46. package/src/publish.ts +290 -968
  47. package/src/restore-internals/font.ts +100 -0
  48. package/src/restore-internals/movie-clip.ts +104 -0
  49. package/src/restore-internals/output-transaction.ts +164 -0
  50. package/src/restore.ts +112 -311
  51. package/src/shared-types.ts +4 -8
  52. package/src/uam-transaction.ts +68 -0
  53. package/src/utils.ts +28 -0
  54. package/src/web.ts +11 -0
@@ -0,0 +1,288 @@
1
+ import { l as PublishFileSystem, r as AtlasRasterBackend, t as AtlasOptions } from "./atlas-CHsu2Y8i.cjs";
2
+ import { Component, Document, FileSystem, Package, ProjectSettings, PublishSettings, Transform } from "@openfairygui/core";
3
+
4
+ //#region src/publish/options.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
+ * Required when a filesystem-backed publish has packable resources.
23
+ * Without a filesystem, publish remains an explicit layout-only transform.
24
+ */
25
+ encoder?: AtlasRasterBackend;
26
+ /**
27
+ * Base path for reading source images (project assets root).
28
+ * Required when encoder is provided.
29
+ */
30
+ basePath?: string;
31
+ /**
32
+ * Atlas packing options.
33
+ */
34
+ atlas?: Omit<AtlasOptions, 'encoder' | 'basePath' | 'outputPath'>;
35
+ /**
36
+ * Filter which packages to publish by name. If not set, all packages are published.
37
+ */
38
+ packages?: string[];
39
+ /**
40
+ * FileSystem abstraction for writing output files.
41
+ * Required for actual file output. Calling publish with a resolved output
42
+ * directory but no filesystem is rejected; omit output entirely for a
43
+ * layout-only transform.
44
+ */
45
+ fs?: PublishFileSystem;
46
+ /**
47
+ * Active branch name used when branchProcessing is "主干合并活跃分支".
48
+ * Empty or omitted means publishing the main branch.
49
+ */
50
+ branch?: string;
51
+ /**
52
+ * Publish hooks supplied by the host adapter.
53
+ *
54
+ * Node adapters load project plugins. Browser adapters pass an empty list.
55
+ */
56
+ plugins?: LoadedPlugin[];
57
+ /**
58
+ * Run generic code generation after runtime artifacts. Default: true.
59
+ */
60
+ codeGeneration?: boolean;
61
+ }
62
+ interface ResolvedPublishAtlasOptions extends Pick<AtlasOptions, 'maxSize' | 'fast' | 'allowRotation' | 'padding' | 'powerOfTwo' | 'square' | 'multiPage' | 'trimImage' | 'extractAlpha'> {}
63
+ interface ResolvePublishOptionsOverrides {
64
+ compressed?: boolean;
65
+ fileExtension?: string;
66
+ packages?: string[];
67
+ atlas?: Partial<ResolvedPublishAtlasOptions>;
68
+ }
69
+ interface ResolvedPublishOptions {
70
+ compressed: boolean;
71
+ fileExtension: string;
72
+ packages?: string[];
73
+ atlas: ResolvedPublishAtlasOptions;
74
+ }
75
+ /**
76
+ * Resolve publish defaults from the document's project settings.
77
+ *
78
+ * This keeps the editor-aligned publish rules reusable across environments,
79
+ * while callers still provide environment-specific concerns such as fs/encoder/basePath.
80
+ */
81
+ declare function resolvePublishOptions(doc: Document, overrides?: ResolvePublishOptionsOverrides): ResolvedPublishOptions;
82
+ //#endregion
83
+ //#region src/publish.d.ts
84
+ /**
85
+ * Publishes a FairyGUI project.
86
+ *
87
+ * Orchestrates:
88
+ * 1. Atlas packing (MaxRects layout + optional raster compositing)
89
+ * 2. Per-package .fui binary serialization
90
+ * 3. File writing to the output directory
91
+ *
92
+ * This is the capability-injected core. Standard hosts should use
93
+ * `publishNode()` or `publishBrowser()` through their dedicated entries.
94
+ *
95
+ * ```ts
96
+ * import { NodeIO } from '@openfairygui/core/node';
97
+ * import { publishNode } from '@openfairygui/functions/node';
98
+ * const doc = await new NodeIO().readProject('./project.fairy');
99
+ *
100
+ * await publishNode({
101
+ * document: doc,
102
+ * output: './release/',
103
+ * compressed: true,
104
+ * assetsPath: './assets/',
105
+ * fileExtension: 'bytes',
106
+ * });
107
+ * ```
108
+ */
109
+ declare function publish(options: PublishOptions): Transform;
110
+ //#endregion
111
+ //#region src/shared-types.d.ts
112
+ type ExtrasMap = Record<string, unknown>;
113
+ interface CliCodeGenerationSettings extends NonNullable<PublishSettings['codeGeneration']> {
114
+ allowGenCode?: boolean;
115
+ classNamePrefix?: string;
116
+ codePath?: string;
117
+ codeType?: string;
118
+ getMemberByName?: boolean;
119
+ ignoreNoname?: boolean;
120
+ memberNamePrefix?: string;
121
+ packageName?: string;
122
+ }
123
+ interface CliAtlasSettings extends NonNullable<PublishSettings['atlasSetting']> {
124
+ maxSize?: number;
125
+ paging?: boolean;
126
+ sizeOption?: string;
127
+ forceSquare?: boolean;
128
+ fast?: boolean;
129
+ allowRotation?: boolean;
130
+ padding?: number;
131
+ trimImage?: boolean;
132
+ extractAlpha?: boolean;
133
+ }
134
+ interface CliPublishSettings extends PublishSettings {
135
+ atlasSetting?: CliAtlasSettings;
136
+ codeGeneration?: CliCodeGenerationSettings;
137
+ }
138
+ type RootProjectSettings = ProjectSettings & {
139
+ publish?: CliPublishSettings;
140
+ };
141
+ interface PublishDependency {
142
+ id: string;
143
+ name: string;
144
+ }
145
+ interface HasOptionalFont {
146
+ getFont?(): string | string[] | null | undefined;
147
+ }
148
+ interface HasOptionalSrc {
149
+ getSrc?(): string | undefined;
150
+ }
151
+ interface HasOptionalUrl {
152
+ getUrl?(): string | undefined;
153
+ }
154
+ //#endregion
155
+ //#region src/plugins/types.d.ts
156
+ type MaybePromise<T> = T | Promise<T>;
157
+ interface PluginManifest {
158
+ name: string;
159
+ displayName?: string;
160
+ description?: string;
161
+ version?: string;
162
+ author?: {
163
+ name?: string;
164
+ };
165
+ icon?: string;
166
+ main: string;
167
+ }
168
+ interface ICodeWriterConfig {
169
+ blockStart?: string;
170
+ blockEnd?: string;
171
+ blockFromNewLine?: boolean;
172
+ usingTabs?: boolean;
173
+ endOfLine?: string;
174
+ fileMark?: string;
175
+ }
176
+ interface CodeWriter {
177
+ writeMark(): void;
178
+ writeln(fmt?: string, ...args: any[]): CodeWriter;
179
+ startBlock(): CodeWriter;
180
+ endBlock(): CodeWriter;
181
+ incIndent(): CodeWriter;
182
+ decIndent(): CodeWriter;
183
+ reset(): void;
184
+ toString(): string;
185
+ save(filePath: string): void;
186
+ }
187
+ interface Plugin {
188
+ genCode?: (doc: Document, settings: Required<CliCodeGenerationSettings>, options: PublishCodeGenerationOptions) => MaybePromise<void>;
189
+ onPublishStart?: (doc: Document, options: PublishOptions) => MaybePromise<void>;
190
+ onPublishEnd?: (doc: Document, options: PublishOptions) => MaybePromise<void>;
191
+ }
192
+ interface LoadedPlugin {
193
+ name: string;
194
+ plugin: Plugin;
195
+ }
196
+ type PluginModule = Plugin & {
197
+ default?: Plugin;
198
+ };
199
+ //#endregion
200
+ //#region src/codegen.d.ts
201
+ declare const AUTO_GENERATED_CODE_MARK = "/** This is an automatically generated class by FairyGUI. Please do not modify it. **/";
202
+ interface PublishCodeGenerationOptions {
203
+ basePath?: string;
204
+ fs: PublishFileSystem;
205
+ packages: Package[];
206
+ plugins?: LoadedPlugin[];
207
+ }
208
+ interface ResolvedPackageCodegenPlan {
209
+ outputDir: string;
210
+ packageFolderName: string;
211
+ packageNamespace: string;
212
+ binderClassName: string;
213
+ settings: CliCodeGenerationSettings;
214
+ }
215
+ interface CodegenMember {
216
+ index: number;
217
+ kind: 'child' | 'controller' | 'transition';
218
+ name: string;
219
+ originalName: string;
220
+ type: string;
221
+ ignored: boolean;
222
+ referencedComponent?: CodegenReferencedComponent;
223
+ }
224
+ interface CodegenReferencedComponent {
225
+ component: Component;
226
+ package: Package;
227
+ }
228
+ interface CodegenClass {
229
+ classId: string;
230
+ className: string;
231
+ encodedClassName: string;
232
+ componentType: string;
233
+ componentName: string;
234
+ packageName: string;
235
+ url: string;
236
+ members: CodegenMember[];
237
+ }
238
+ declare function publishCodeGeneration(doc: Document, options: PublishCodeGenerationOptions): Promise<void>;
239
+ declare function resolvePackageCodegenPlan(pkg: Package, settings: CliCodeGenerationSettings, options: PublishCodeGenerationOptions): ResolvedPackageCodegenPlan | null;
240
+ declare function buildCodegenClasses(doc: Document, pkg: Package, plan: ResolvedPackageCodegenPlan): CodegenClass[];
241
+ declare function encodeText(value: string): Uint8Array;
242
+ declare function decodeText(value: Uint8Array): string;
243
+ //#endregion
244
+ //#region src/restore.d.ts
245
+ interface RestoreImageCropInput {
246
+ sourcePath: string;
247
+ outputPath: string;
248
+ left: number;
249
+ top: number;
250
+ width: number;
251
+ height: number;
252
+ rotated: boolean;
253
+ offsetX: number;
254
+ offsetY: number;
255
+ expectedWidth: number;
256
+ expectedHeight: number;
257
+ }
258
+ type RestoreImageCropper = (input: RestoreImageCropInput) => Promise<void>;
259
+ type RestoreImageExtractInput = Omit<RestoreImageCropInput, 'outputPath'>;
260
+ type RestoreImageExtractor = (input: RestoreImageExtractInput) => Promise<Uint8Array>;
261
+ interface RestoreResult {
262
+ document: Document;
263
+ projectPath: string;
264
+ warnings: string[];
265
+ }
266
+ interface RestoreFileSystem extends Pick<FileSystem, 'readFile' | 'readFileRaw' | 'writeFile' | 'writeFileRaw' | 'mkdir' | 'exists' | 'join' | 'dirname'> {
267
+ readdir(path: string): Promise<string[]>;
268
+ isFile(path: string): Promise<boolean>;
269
+ resolvePath(path: string): string | Promise<string>;
270
+ rm(path: string, options?: {
271
+ recursive?: boolean;
272
+ force?: boolean;
273
+ }): Promise<void>;
274
+ rename(from: string, to: string): Promise<void>;
275
+ }
276
+ interface RestoreOptions {
277
+ inputDir: string;
278
+ output: string;
279
+ fs: RestoreFileSystem;
280
+ packages?: string[];
281
+ force?: boolean;
282
+ projectType?: number;
283
+ cropImage?: RestoreImageCropper;
284
+ extractImage?: RestoreImageExtractor;
285
+ }
286
+ declare function restore(options: RestoreOptions): Promise<RestoreResult>;
287
+ //#endregion
288
+ export { ExtrasMap as A, ResolvedPublishOptions as B, MaybePromise as C, CliAtlasSettings as D, PluginModule as E, RootProjectSettings as F, publish as I, PublishOptions as L, HasOptionalSrc as M, HasOptionalUrl as N, CliCodeGenerationSettings as O, PublishDependency as P, ResolvePublishOptionsOverrides as R, LoadedPlugin as S, PluginManifest as T, resolvePublishOptions as V, encodeText as _, RestoreImageExtractor as a, CodeWriter as b, restore as c, CodegenMember as d, CodegenReferencedComponent as f, decodeText as g, buildCodegenClasses as h, RestoreImageExtractInput as i, HasOptionalFont as j, CliPublishSettings as k, AUTO_GENERATED_CODE_MARK as l, ResolvedPackageCodegenPlan as m, RestoreImageCropInput as n, RestoreOptions as o, PublishCodeGenerationOptions as p, RestoreImageCropper as r, RestoreResult as s, RestoreFileSystem as t, CodegenClass as u, publishCodeGeneration as v, Plugin as w, ICodeWriterConfig as x, resolvePackageCodegenPlan as y, ResolvedPublishAtlasOptions as z };