@openfairygui/functions 0.2.4 → 0.2.6

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.
@@ -3,7 +3,9 @@ import type { HasOptionalFont } from '../shared-types.js';
3
3
 
4
4
  interface ReferenceItem {
5
5
  icon?: string | null;
6
+ selectedIcon?: string | null;
6
7
  url?: string | null;
8
+ propertyOverrides?: Array<{ value: string }>;
7
9
  }
8
10
 
9
11
  interface ReferenceGear {
@@ -24,6 +26,7 @@ interface ReferenceChild extends HasOptionalFont {
24
26
  getPackageId?(): string;
25
27
  getSrc?(): string;
26
28
  getUrl?(): string;
29
+ getClearOnPublish?(): boolean;
27
30
  getInstanceSound?(): string;
28
31
  getDefaultItem?(): string;
29
32
  getIcon?(): string;
@@ -31,6 +34,7 @@ interface ReferenceChild extends HasOptionalFont {
31
34
  getDropdown?(): string;
32
35
  getSound?(): string;
33
36
  getText?(): string;
37
+ getAutoClearText?(): boolean;
34
38
  getInstanceIcon?(): string;
35
39
  getInstanceSelectedIcon?(): string;
36
40
  getVtScrollBarRes?(): string;
@@ -38,7 +42,10 @@ interface ReferenceChild extends HasOptionalFont {
38
42
  getHeaderRes?(): string;
39
43
  getFooterRes?(): string;
40
44
  getInstanceComboItems?(): Array<{ icon: string | null }>;
45
+ getInstanceAutoClearItems?(): boolean;
41
46
  getListItems?(): ReferenceItem[];
47
+ getAutoClearItems?(): boolean;
48
+ getPropertyOverrides?(): Array<{ value: string }>;
42
49
  listGears?(): ReferenceGear[];
43
50
  }
44
51
 
@@ -130,7 +137,7 @@ function collectComponentReferences(
130
137
  ownerPackageId: string,
131
138
  component: Component,
132
139
  ): void {
133
- const referenceComponent = component as Component & ReferenceComponent;
140
+ const referenceComponent = component as unknown as ReferenceComponent;
134
141
  for (const child of referenceComponent.listChildren()) {
135
142
  const sourceId = child.getSrc?.();
136
143
  if (sourceId) {
@@ -141,9 +148,9 @@ function collectComponentReferences(
141
148
  if (sourcePackageId && sourcePackageId !== ownerPackageId) target.packageIds.add(sourcePackageId);
142
149
 
143
150
  addFontReferences(target, ownerPackageId, child.getFont?.());
144
- addTextReferences(target, ownerPackageId, child.getText?.());
151
+ if (!child.getAutoClearText?.()) addTextReferences(target, ownerPackageId, child.getText?.());
145
152
  for (const reference of [
146
- child.getUrl?.(),
153
+ child.getClearOnPublish?.() ? undefined : child.getUrl?.(),
147
154
  child.getDefaultItem?.(),
148
155
  child.getIcon?.(),
149
156
  child.getSelectedIcon?.(),
@@ -159,13 +166,20 @@ function collectComponentReferences(
159
166
  ]) {
160
167
  addUiReference(target, ownerPackageId, reference);
161
168
  }
162
- for (const item of child.getInstanceComboItems?.() ?? []) {
169
+ for (const item of child.getInstanceAutoClearItems?.() ? [] : (child.getInstanceComboItems?.() ?? [])) {
163
170
  addUiReference(target, ownerPackageId, item.icon);
164
171
  }
165
- for (const item of child.getListItems?.() ?? []) {
172
+ for (const item of child.getAutoClearItems?.() ? [] : (child.getListItems?.() ?? [])) {
166
173
  addUiReference(target, ownerPackageId, item.icon);
174
+ addUiReference(target, ownerPackageId, item.selectedIcon);
167
175
  addUiReference(target, ownerPackageId, item.url);
176
+ addUnknownReferences(target, ownerPackageId, item.propertyOverrides?.map((property) => property.value));
168
177
  }
178
+ addUnknownReferences(
179
+ target,
180
+ ownerPackageId,
181
+ child.getPropertyOverrides?.().map((property) => property.value),
182
+ );
169
183
  for (const gear of child.listGears?.() ?? []) {
170
184
  addUnknownReferences(target, ownerPackageId, gear.getValues?.());
171
185
  addUnknownReferences(target, ownerPackageId, gear.getDefaultValue?.());
@@ -201,8 +215,9 @@ export function collectPackageResourceReferences(pkg: Package): PackageResourceR
201
215
  localResourceIds: new Set<string>(),
202
216
  packageIds: new Set<string>(),
203
217
  };
218
+ const excludedResourceIds = new Set(pkg.getSourceAtlasSettings().excludedResourceIds);
204
219
  for (const resource of pkg.listResources()) {
205
- if (resource.propertyType === 'Component') {
220
+ if (resource.propertyType === 'Component' && !excludedResourceIds.has(resource.getId())) {
206
221
  collectComponentReferences(references, pkg.getId(), resource);
207
222
  }
208
223
  }
package/src/publish.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  type FileSystem,
6
6
  type MovieClipResource,
7
7
  type Package,
8
+ ProjectType,
8
9
  type Transform,
9
10
  } from '@openfairygui/core';
10
11
  import { atlas } from './atlas.js';
@@ -194,6 +195,26 @@ export function publish(options: PublishOptions): Transform {
194
195
  }
195
196
  }
196
197
  const publishName = pkg.getPublishName() || pkg.getName();
198
+ const sourceAtlas = pkg.getSourceAtlasSettings();
199
+ const usePackageAtlas = !sourceAtlas.useGlobal;
200
+ const atlas: ResolvedPublishAtlasOptions = {
201
+ ...config.atlas,
202
+ maxSize: options.atlas?.maxSize ?? (usePackageAtlas ? sourceAtlas.maxSize : config.atlas.maxSize),
203
+ allowRotation: config.projectType === ProjectType.LayaBox
204
+ ? false
205
+ : (options.atlas?.allowRotation ?? (usePackageAtlas ? sourceAtlas.allowRotation : config.atlas.allowRotation)),
206
+ powerOfTwo: options.atlas?.powerOfTwo
207
+ ?? (usePackageAtlas ? sourceAtlas.sizeOption === 'pot' : config.atlas.powerOfTwo),
208
+ maxAtlasIndex: options.atlas?.maxAtlasIndex ?? sourceAtlas.maxIndex,
209
+ multipleOfFour: options.atlas?.multipleOfFour
210
+ ?? (usePackageAtlas ? sourceAtlas.sizeOption === 'mof' : config.atlas.multipleOfFour),
211
+ square: options.atlas?.square ?? (usePackageAtlas ? sourceAtlas.forceSquare : config.atlas.square),
212
+ multiPage: options.atlas?.multiPage ?? (usePackageAtlas ? sourceAtlas.paging : config.atlas.multiPage),
213
+ extractAlpha: config.projectType === ProjectType.Unity && (
214
+ options.atlas?.extractAlpha
215
+ ?? (usePackageAtlas || sourceAtlas.extractAlpha ? sourceAtlas.extractAlpha : config.atlas.extractAlpha)
216
+ ),
217
+ };
197
218
 
198
219
  return {
199
220
  pkg,
@@ -206,7 +227,7 @@ export function publish(options: PublishOptions): Transform {
206
227
  activeBranch: config.activeBranch,
207
228
  includeHighResolution: config.includeHighResolution,
208
229
  separatedAtlasForBranch: config.separatedAtlasForBranch,
209
- atlas: config.atlas,
230
+ atlas,
210
231
  };
211
232
  };
212
233
 
@@ -255,7 +276,6 @@ export function publish(options: PublishOptions): Transform {
255
276
  const atlasRuntimeOptions = resolvePublishAtlasRuntimeOptions(plan.fileExtension);
256
277
  await atlas({
257
278
  ...plan.atlas,
258
- ...(options.atlas ?? {}),
259
279
  separatedAtlasForBranch: plan.separatedAtlasForBranch,
260
280
  encoder: options.encoder,
261
281
  basePath: options.basePath,
package/src/utils.ts CHANGED
@@ -13,7 +13,7 @@ export function createTransform(name: string, fn: Transform): Transform {
13
13
  return fn;
14
14
  }
15
15
 
16
- export function parseTextureSetMode(value: string | null | undefined): TextureSetMode {
16
+ export function parseTextureSetMode(value: string | null | undefined, maxAtlasIndex = 10): TextureSetMode {
17
17
  const raw = value?.trim() ?? '';
18
18
  if (!raw) {
19
19
  return { kind: 'auto', raw: '' };
@@ -29,7 +29,7 @@ export function parseTextureSetMode(value: string | null | undefined): TextureSe
29
29
  }
30
30
  if (/^\d+$/.test(raw)) {
31
31
  const pageIndex = Number(raw);
32
- if (pageIndex >= 0 && pageIndex <= 10) {
32
+ if (pageIndex >= 0 && pageIndex <= maxAtlasIndex) {
33
33
  return { kind: 'page', raw, pageIndex };
34
34
  }
35
35
  }