@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
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { type Document, ProjectType } from '@openfairygui/core';
|
|
2
|
+
import type { AtlasOptions } from '../atlas.js';
|
|
3
|
+
import type { LoadedPlugin } from '../plugins/types.js';
|
|
4
|
+
import type { AtlasRasterBackend, PublishFileSystem } from './contracts.js';
|
|
5
|
+
import type { CliPublishSettings, RootProjectSettings } from '../shared-types.js';
|
|
6
|
+
|
|
7
|
+
export interface PublishOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Output directory override for published files (.fui + atlas PNGs).
|
|
10
|
+
* When omitted, publish uses package-level or project-level publish paths.
|
|
11
|
+
*/
|
|
12
|
+
output?: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Compress the binary data with zlib raw deflate. Default: false.
|
|
16
|
+
*/
|
|
17
|
+
compressed?: boolean;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* File extension for the binary output. Default: 'fui'.
|
|
21
|
+
* Unity projects typically use 'bytes'.
|
|
22
|
+
*/
|
|
23
|
+
fileExtension?: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Raster backend for atlas image compositing.
|
|
27
|
+
* Required when a filesystem-backed publish has packable resources.
|
|
28
|
+
* Without a filesystem, publish remains an explicit layout-only transform.
|
|
29
|
+
*/
|
|
30
|
+
encoder?: AtlasRasterBackend;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Base path for reading source images (project assets root).
|
|
34
|
+
* Required when encoder is provided.
|
|
35
|
+
*/
|
|
36
|
+
basePath?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Atlas packing options.
|
|
40
|
+
*/
|
|
41
|
+
atlas?: Omit<AtlasOptions, 'encoder' | 'basePath' | 'outputPath'>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Filter which packages to publish by name. If not set, all packages are published.
|
|
45
|
+
*/
|
|
46
|
+
packages?: string[];
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* FileSystem abstraction for writing output files.
|
|
50
|
+
* Required for actual file output. Calling publish with a resolved output
|
|
51
|
+
* directory but no filesystem is rejected; omit output entirely for a
|
|
52
|
+
* layout-only transform.
|
|
53
|
+
*/
|
|
54
|
+
fs?: PublishFileSystem;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Active branch name used when branchProcessing is "主干合并活跃分支".
|
|
58
|
+
* Empty or omitted means publishing the main branch.
|
|
59
|
+
*/
|
|
60
|
+
branch?: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Publish hooks supplied by the host adapter.
|
|
64
|
+
*
|
|
65
|
+
* Node adapters load project plugins. Browser adapters pass an empty list.
|
|
66
|
+
*/
|
|
67
|
+
plugins?: LoadedPlugin[];
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Run generic code generation after runtime artifacts. Default: true.
|
|
71
|
+
*/
|
|
72
|
+
codeGeneration?: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface ResolvedPublishAtlasOptions
|
|
76
|
+
extends Pick<
|
|
77
|
+
AtlasOptions,
|
|
78
|
+
| 'maxSize'
|
|
79
|
+
| 'fast'
|
|
80
|
+
| 'allowRotation'
|
|
81
|
+
| 'padding'
|
|
82
|
+
| 'powerOfTwo'
|
|
83
|
+
| 'square'
|
|
84
|
+
| 'multiPage'
|
|
85
|
+
| 'trimImage'
|
|
86
|
+
| 'extractAlpha'
|
|
87
|
+
> {}
|
|
88
|
+
|
|
89
|
+
export interface ResolvePublishOptionsOverrides {
|
|
90
|
+
compressed?: boolean;
|
|
91
|
+
fileExtension?: string;
|
|
92
|
+
packages?: string[];
|
|
93
|
+
atlas?: Partial<ResolvedPublishAtlasOptions>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface ResolvedPublishOptions {
|
|
97
|
+
compressed: boolean;
|
|
98
|
+
fileExtension: string;
|
|
99
|
+
packages?: string[];
|
|
100
|
+
atlas: ResolvedPublishAtlasOptions;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const UNITY_PROJECT_TYPE = ProjectType.Unity;
|
|
104
|
+
const COCOS_CREATOR_PROJECT_TYPE = ProjectType.CocosCreator;
|
|
105
|
+
|
|
106
|
+
function resolveDefaultPublishFileExtension(projectType: number, publishSettings: CliPublishSettings): string {
|
|
107
|
+
if (projectType === UNITY_PROJECT_TYPE) {
|
|
108
|
+
return 'bytes';
|
|
109
|
+
}
|
|
110
|
+
if (projectType === COCOS_CREATOR_PROJECT_TYPE) {
|
|
111
|
+
return publishSettings.fileExtension || 'bin';
|
|
112
|
+
}
|
|
113
|
+
// publish() is currently a binary forward-publish path. For non-Unity projects,
|
|
114
|
+
// keep the emitted contract driven by the configured extension, falling back to
|
|
115
|
+
// `fui`, which intentionally covers the shared generic binary contract outside
|
|
116
|
+
// Unity and the Creator-specific default-to-bin rule.
|
|
117
|
+
return publishSettings.fileExtension || 'fui';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface PublishAtlasRuntimeOptions {
|
|
121
|
+
preserveInputOrderOnTie: boolean;
|
|
122
|
+
directSingleImageOutput: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function resolvePublishAtlasRuntimeOptions(fileExtension: string): PublishAtlasRuntimeOptions {
|
|
126
|
+
return {
|
|
127
|
+
preserveInputOrderOnTie: fileExtension === 'fui',
|
|
128
|
+
directSingleImageOutput: fileExtension === 'bytes',
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function resolvePublishFileName(publishName: string, fileExtension: string): string {
|
|
133
|
+
if (fileExtension === 'bytes') {
|
|
134
|
+
return `${publishName}_fui.bytes`;
|
|
135
|
+
}
|
|
136
|
+
return `${publishName}.${fileExtension}`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Resolve publish defaults from the document's project settings.
|
|
141
|
+
*
|
|
142
|
+
* This keeps the editor-aligned publish rules reusable across environments,
|
|
143
|
+
* while callers still provide environment-specific concerns such as fs/encoder/basePath.
|
|
144
|
+
*/
|
|
145
|
+
export function resolvePublishOptions(
|
|
146
|
+
doc: Document,
|
|
147
|
+
overrides: ResolvePublishOptionsOverrides = {},
|
|
148
|
+
): ResolvedPublishOptions {
|
|
149
|
+
const root = doc.getRoot();
|
|
150
|
+
const settings = (root.getSettings?.() ?? {}) as RootProjectSettings;
|
|
151
|
+
const publishSettings: CliPublishSettings = settings.publish ?? {};
|
|
152
|
+
const atlasSetting = publishSettings.atlasSetting ?? {};
|
|
153
|
+
const projectType = root.getProjectType();
|
|
154
|
+
|
|
155
|
+
const fileExtension = overrides.fileExtension ?? resolveDefaultPublishFileExtension(projectType, publishSettings);
|
|
156
|
+
|
|
157
|
+
let compressed = overrides.compressed ?? publishSettings.compressDesc ?? false;
|
|
158
|
+
if (projectType === UNITY_PROJECT_TYPE) {
|
|
159
|
+
compressed = overrides.compressed ?? false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const atlasOptions: ResolvedPublishAtlasOptions = {
|
|
163
|
+
maxSize: overrides.atlas?.maxSize ?? atlasSetting.maxSize ?? 2048,
|
|
164
|
+
fast: overrides.atlas?.fast ?? atlasSetting.fast ?? true,
|
|
165
|
+
allowRotation: overrides.atlas?.allowRotation ?? atlasSetting.allowRotation ?? false,
|
|
166
|
+
padding: overrides.atlas?.padding ?? atlasSetting.padding ?? 2,
|
|
167
|
+
powerOfTwo: overrides.atlas?.powerOfTwo ?? atlasSetting.sizeOption === 'pot',
|
|
168
|
+
square: overrides.atlas?.square ?? atlasSetting.forceSquare ?? false,
|
|
169
|
+
multiPage: overrides.atlas?.multiPage ?? atlasSetting.paging ?? true,
|
|
170
|
+
trimImage: overrides.atlas?.trimImage ?? atlasSetting.trimImage ?? false,
|
|
171
|
+
extractAlpha: overrides.atlas?.extractAlpha ?? atlasSetting.extractAlpha ?? false,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
compressed,
|
|
176
|
+
fileExtension,
|
|
177
|
+
packages: overrides.packages,
|
|
178
|
+
atlas: atlasOptions,
|
|
179
|
+
};
|
|
180
|
+
}
|