@openfairygui/functions 0.1.1 → 0.2.0-alpha.0
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 +36 -1
- package/dist/index.cjs +37 -4
- package/dist/index.d.cts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +38 -6
- package/package.json +1 -1
- package/src/atlas.ts +0 -56
- package/src/index.ts +6 -0
- package/src/max-rects-packer-compat.ts +3 -3
- package/src/uam-transaction.ts +68 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @openfairygui/functions
|
|
2
2
|
|
|
3
|
-
Composable authoring and
|
|
3
|
+
Composable authoring workflows and thin application seams built on top of `@openfairygui/core`.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -21,6 +21,41 @@ const report = inspect(doc);
|
|
|
21
21
|
await doc.transform(publish({ output: './release' }));
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
## Phase A UAM authoring seam
|
|
25
|
+
|
|
26
|
+
`@openfairygui/functions` also exposes a thin stateless wrapper over the Phase A UAM
|
|
27
|
+
transaction contract from `@openfairygui/core`.
|
|
28
|
+
|
|
29
|
+
This seam:
|
|
30
|
+
|
|
31
|
+
- accepts `UamProject` + `UamTransactionOperation[]`
|
|
32
|
+
- returns structured app-level success / failure results
|
|
33
|
+
- does not expose `Document`
|
|
34
|
+
- does not define a second selector / operation grammar
|
|
35
|
+
- does not wrap `publish` or `restore`
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import {
|
|
39
|
+
type UamProject,
|
|
40
|
+
type UamTransactionOperation,
|
|
41
|
+
} from '@openfairygui/core';
|
|
42
|
+
import { applyUamTransactionApp } from '@openfairygui/functions';
|
|
43
|
+
|
|
44
|
+
const project: UamProject = /* ... */;
|
|
45
|
+
const operations: UamTransactionOperation[] = [
|
|
46
|
+
{
|
|
47
|
+
kind: 'renameResource',
|
|
48
|
+
selector: { packageId: 'pkg001', resourceId: 'img001' },
|
|
49
|
+
newName: 'renamed.png',
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
const result = applyUamTransactionApp({ project, operations });
|
|
54
|
+
if (!result.ok) {
|
|
55
|
+
console.error(result.error.code, result.error.stage, result.error.message);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
24
59
|
Repository:
|
|
25
60
|
|
|
26
61
|
- https://github.com/OpenFairyGUI/OpenFairyGUI
|
package/dist/index.cjs
CHANGED
|
@@ -721,7 +721,7 @@ var BinarySearchCompat = class {
|
|
|
721
721
|
return this.getCurrent();
|
|
722
722
|
}
|
|
723
723
|
getCurrent() {
|
|
724
|
-
if (this.pot) return Math.trunc(
|
|
724
|
+
if (this.pot) return Math.trunc(2 ** this.current);
|
|
725
725
|
if (this.mof) return this.current * 4;
|
|
726
726
|
return this.current;
|
|
727
727
|
}
|
|
@@ -944,8 +944,8 @@ function swapCompat(items, left, right) {
|
|
|
944
944
|
function initSizeScheme() {
|
|
945
945
|
const result = [];
|
|
946
946
|
for (let w = 5; w <= 13; w += 1) for (let h = 5; h <= 13; h += 1) {
|
|
947
|
-
const width =
|
|
948
|
-
const height =
|
|
947
|
+
const width = 2 ** w;
|
|
948
|
+
const height = 2 ** h;
|
|
949
949
|
const area = width * height;
|
|
950
950
|
const aspectRatio = width > height ? width / height : height / width;
|
|
951
951
|
result.push({
|
|
@@ -1915,7 +1915,6 @@ function _readUint32BE(data, offset) {
|
|
|
1915
1915
|
}
|
|
1916
1916
|
/** Collect a Bitmap Font's texture image, packed under the font's ID. */
|
|
1917
1917
|
async function _collectFontTexture(doc, fontRes, pkg, options) {
|
|
1918
|
-
fontRes.getExtras();
|
|
1919
1918
|
const textureId = fontRes.getTextureId?.() ?? "";
|
|
1920
1919
|
if (textureId) {
|
|
1921
1920
|
const fontId = fontRes.getId();
|
|
@@ -3911,8 +3910,42 @@ function _computeDependencies(pkg, pkgMap) {
|
|
|
3911
3910
|
}
|
|
3912
3911
|
}
|
|
3913
3912
|
//#endregion
|
|
3913
|
+
//#region src/uam-transaction.ts
|
|
3914
|
+
function mapTransactionErrorStage(error) {
|
|
3915
|
+
switch (error.code) {
|
|
3916
|
+
case "transaction_unsupported": return "preflight";
|
|
3917
|
+
case "invalid_uam": return "preflight";
|
|
3918
|
+
case "execution_failure": return error.opIndex === void 0 && error.issues !== void 0 ? "postflight" : "execution";
|
|
3919
|
+
case "selector_ambiguity": return error.opIndex === void 0 ? "preflight" : "execution";
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
function applyUamTransactionApp(input) {
|
|
3923
|
+
try {
|
|
3924
|
+
return {
|
|
3925
|
+
ok: true,
|
|
3926
|
+
project: (0, _openfairygui_core.applyUamTransaction)(input.project, input.operations)
|
|
3927
|
+
};
|
|
3928
|
+
} catch (error) {
|
|
3929
|
+
if (error instanceof _openfairygui_core.UamTransactionError) return {
|
|
3930
|
+
ok: false,
|
|
3931
|
+
error: {
|
|
3932
|
+
code: error.code,
|
|
3933
|
+
stage: mapTransactionErrorStage(error),
|
|
3934
|
+
message: error.message,
|
|
3935
|
+
opIndex: error.opIndex,
|
|
3936
|
+
opId: error.opId,
|
|
3937
|
+
opKind: error.opKind,
|
|
3938
|
+
selector: error.selector,
|
|
3939
|
+
issues: error.issues
|
|
3940
|
+
}
|
|
3941
|
+
};
|
|
3942
|
+
throw error;
|
|
3943
|
+
}
|
|
3944
|
+
}
|
|
3945
|
+
//#endregion
|
|
3914
3946
|
exports.AUTO_GENERATED_CODE_MARK = AUTO_GENERATED_CODE_MARK;
|
|
3915
3947
|
exports.ValidationSeverity = ValidationSeverity;
|
|
3948
|
+
exports.applyUamTransactionApp = applyUamTransactionApp;
|
|
3916
3949
|
exports.atlas = atlas;
|
|
3917
3950
|
exports.createTransform = createTransform;
|
|
3918
3951
|
exports.inspect = inspect;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Document, FileSystem, Package, ProjectSettings, PublishSettings, Transform } from "@openfairygui/core";
|
|
1
|
+
import { Document, FileSystem, Package, ProjectSettings, PublishSettings, Transform, UamProject, UamTransactionErrorCode, UamTransactionOperation, UamTransactionSupportIssue, UamValidationIssue } from "@openfairygui/core";
|
|
2
2
|
|
|
3
3
|
//#region src/inspect.d.ts
|
|
4
4
|
/**
|
|
@@ -456,10 +456,34 @@ declare function resolvePublishOptions(doc: Document, overrides?: ResolvePublish
|
|
|
456
456
|
*/
|
|
457
457
|
declare function publish(options: PublishOptions): Transform;
|
|
458
458
|
//#endregion
|
|
459
|
+
//#region src/uam-transaction.d.ts
|
|
460
|
+
interface ApplyUamTransactionAppInput {
|
|
461
|
+
project: UamProject;
|
|
462
|
+
operations: UamTransactionOperation[];
|
|
463
|
+
}
|
|
464
|
+
interface ApplyUamTransactionAppError {
|
|
465
|
+
code: UamTransactionErrorCode;
|
|
466
|
+
stage: 'preflight' | 'execution' | 'postflight';
|
|
467
|
+
message: string;
|
|
468
|
+
opIndex?: number;
|
|
469
|
+
opId?: string;
|
|
470
|
+
opKind?: UamTransactionOperation['kind'];
|
|
471
|
+
selector?: Record<string, unknown>;
|
|
472
|
+
issues?: UamValidationIssue[] | UamTransactionSupportIssue[];
|
|
473
|
+
}
|
|
474
|
+
type ApplyUamTransactionAppResult = {
|
|
475
|
+
ok: true;
|
|
476
|
+
project: UamProject;
|
|
477
|
+
} | {
|
|
478
|
+
ok: false;
|
|
479
|
+
error: ApplyUamTransactionAppError;
|
|
480
|
+
};
|
|
481
|
+
declare function applyUamTransactionApp(input: ApplyUamTransactionAppInput): ApplyUamTransactionAppResult;
|
|
482
|
+
//#endregion
|
|
459
483
|
//#region src/utils.d.ts
|
|
460
484
|
/**
|
|
461
485
|
* Wraps a transform function, assigning it a name for the transform stack.
|
|
462
486
|
*/
|
|
463
487
|
declare function createTransform(name: string, fn: Transform): Transform;
|
|
464
488
|
//#endregion
|
|
465
|
-
export { AUTO_GENERATED_CODE_MARK, type AtlasOptions, type CliAtlasSettings, type CliPublishSettings, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type InspectCategoryReport, type InspectReport, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
|
|
489
|
+
export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, type CliAtlasSettings, type CliPublishSettings, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type InspectCategoryReport, type InspectReport, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, applyUamTransactionApp, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Document, FileSystem, Package, ProjectSettings, PublishSettings, Transform } from "@openfairygui/core";
|
|
1
|
+
import { Document, FileSystem, Package, ProjectSettings, PublishSettings, Transform, UamProject, UamTransactionErrorCode, UamTransactionOperation, UamTransactionSupportIssue, UamValidationIssue } from "@openfairygui/core";
|
|
2
2
|
|
|
3
3
|
//#region src/inspect.d.ts
|
|
4
4
|
/**
|
|
@@ -456,10 +456,34 @@ declare function resolvePublishOptions(doc: Document, overrides?: ResolvePublish
|
|
|
456
456
|
*/
|
|
457
457
|
declare function publish(options: PublishOptions): Transform;
|
|
458
458
|
//#endregion
|
|
459
|
+
//#region src/uam-transaction.d.ts
|
|
460
|
+
interface ApplyUamTransactionAppInput {
|
|
461
|
+
project: UamProject;
|
|
462
|
+
operations: UamTransactionOperation[];
|
|
463
|
+
}
|
|
464
|
+
interface ApplyUamTransactionAppError {
|
|
465
|
+
code: UamTransactionErrorCode;
|
|
466
|
+
stage: 'preflight' | 'execution' | 'postflight';
|
|
467
|
+
message: string;
|
|
468
|
+
opIndex?: number;
|
|
469
|
+
opId?: string;
|
|
470
|
+
opKind?: UamTransactionOperation['kind'];
|
|
471
|
+
selector?: Record<string, unknown>;
|
|
472
|
+
issues?: UamValidationIssue[] | UamTransactionSupportIssue[];
|
|
473
|
+
}
|
|
474
|
+
type ApplyUamTransactionAppResult = {
|
|
475
|
+
ok: true;
|
|
476
|
+
project: UamProject;
|
|
477
|
+
} | {
|
|
478
|
+
ok: false;
|
|
479
|
+
error: ApplyUamTransactionAppError;
|
|
480
|
+
};
|
|
481
|
+
declare function applyUamTransactionApp(input: ApplyUamTransactionAppInput): ApplyUamTransactionAppResult;
|
|
482
|
+
//#endregion
|
|
459
483
|
//#region src/utils.d.ts
|
|
460
484
|
/**
|
|
461
485
|
* Wraps a transform function, assigning it a name for the transform stack.
|
|
462
486
|
*/
|
|
463
487
|
declare function createTransform(name: string, fn: Transform): Transform;
|
|
464
488
|
//#endregion
|
|
465
|
-
export { AUTO_GENERATED_CODE_MARK, type AtlasOptions, type CliAtlasSettings, type CliPublishSettings, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type InspectCategoryReport, type InspectReport, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
|
|
489
|
+
export { AUTO_GENERATED_CODE_MARK, type ApplyUamTransactionAppError, type ApplyUamTransactionAppInput, type ApplyUamTransactionAppResult, type AtlasOptions, type CliAtlasSettings, type CliPublishSettings, type ExtrasMap, type HasOptionalFont, type HasOptionalSrc, type HasOptionalUrl, type InspectCategoryReport, type InspectReport, type PruneOptions, type PublishCodeGenerationOptions, type PublishDependency, type PublishFileSystem, type PublishOptions, type RenameOptions, type ResolvePublishOptionsOverrides, type ResolvedPublishAtlasOptions, type ResolvedPublishOptions, type RestoreFileSystem, type RestoreImageCropInput, type RestoreImageCropper, type RestoreImageExtractInput, type RestoreImageExtractor, type RestoreOptions, type RestoreResult, type RootProjectSettings, type ValidateOptions, type ValidationIssue, type ValidationResult, ValidationSeverity, applyUamTransactionApp, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter, GearType, ProjectType, ProjectWriter, TransitionActionType, generateId } from "@openfairygui/core";
|
|
1
|
+
import { BinaryReader, BinaryWriter, GearType, ProjectType, ProjectWriter, TransitionActionType, UamTransactionError, applyUamTransaction, generateId } from "@openfairygui/core";
|
|
2
2
|
//#region src/inspect.ts
|
|
3
3
|
function mapResource(resource) {
|
|
4
4
|
return {
|
|
@@ -720,7 +720,7 @@ var BinarySearchCompat = class {
|
|
|
720
720
|
return this.getCurrent();
|
|
721
721
|
}
|
|
722
722
|
getCurrent() {
|
|
723
|
-
if (this.pot) return Math.trunc(
|
|
723
|
+
if (this.pot) return Math.trunc(2 ** this.current);
|
|
724
724
|
if (this.mof) return this.current * 4;
|
|
725
725
|
return this.current;
|
|
726
726
|
}
|
|
@@ -943,8 +943,8 @@ function swapCompat(items, left, right) {
|
|
|
943
943
|
function initSizeScheme() {
|
|
944
944
|
const result = [];
|
|
945
945
|
for (let w = 5; w <= 13; w += 1) for (let h = 5; h <= 13; h += 1) {
|
|
946
|
-
const width =
|
|
947
|
-
const height =
|
|
946
|
+
const width = 2 ** w;
|
|
947
|
+
const height = 2 ** h;
|
|
948
948
|
const area = width * height;
|
|
949
949
|
const aspectRatio = width > height ? width / height : height / width;
|
|
950
950
|
result.push({
|
|
@@ -1914,7 +1914,6 @@ function _readUint32BE(data, offset) {
|
|
|
1914
1914
|
}
|
|
1915
1915
|
/** Collect a Bitmap Font's texture image, packed under the font's ID. */
|
|
1916
1916
|
async function _collectFontTexture(doc, fontRes, pkg, options) {
|
|
1917
|
-
fontRes.getExtras();
|
|
1918
1917
|
const textureId = fontRes.getTextureId?.() ?? "";
|
|
1919
1918
|
if (textureId) {
|
|
1920
1919
|
const fontId = fontRes.getId();
|
|
@@ -3910,4 +3909,37 @@ function _computeDependencies(pkg, pkgMap) {
|
|
|
3910
3909
|
}
|
|
3911
3910
|
}
|
|
3912
3911
|
//#endregion
|
|
3913
|
-
|
|
3912
|
+
//#region src/uam-transaction.ts
|
|
3913
|
+
function mapTransactionErrorStage(error) {
|
|
3914
|
+
switch (error.code) {
|
|
3915
|
+
case "transaction_unsupported": return "preflight";
|
|
3916
|
+
case "invalid_uam": return "preflight";
|
|
3917
|
+
case "execution_failure": return error.opIndex === void 0 && error.issues !== void 0 ? "postflight" : "execution";
|
|
3918
|
+
case "selector_ambiguity": return error.opIndex === void 0 ? "preflight" : "execution";
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
function applyUamTransactionApp(input) {
|
|
3922
|
+
try {
|
|
3923
|
+
return {
|
|
3924
|
+
ok: true,
|
|
3925
|
+
project: applyUamTransaction(input.project, input.operations)
|
|
3926
|
+
};
|
|
3927
|
+
} catch (error) {
|
|
3928
|
+
if (error instanceof UamTransactionError) return {
|
|
3929
|
+
ok: false,
|
|
3930
|
+
error: {
|
|
3931
|
+
code: error.code,
|
|
3932
|
+
stage: mapTransactionErrorStage(error),
|
|
3933
|
+
message: error.message,
|
|
3934
|
+
opIndex: error.opIndex,
|
|
3935
|
+
opId: error.opId,
|
|
3936
|
+
opKind: error.opKind,
|
|
3937
|
+
selector: error.selector,
|
|
3938
|
+
issues: error.issues
|
|
3939
|
+
}
|
|
3940
|
+
};
|
|
3941
|
+
throw error;
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
//#endregion
|
|
3945
|
+
export { AUTO_GENERATED_CODE_MARK, ValidationSeverity, applyUamTransactionApp, atlas, createTransform, inspect, prune, publish, publishCodeGeneration, rename, resolvePublishOptions, restore, validate };
|
package/package.json
CHANGED
package/src/atlas.ts
CHANGED
|
@@ -131,7 +131,6 @@ interface TrimInfo {
|
|
|
131
131
|
type PackageResource = ReturnType<Package['listResources']>[number];
|
|
132
132
|
type PackableResource = ImageResource | MovieClipResource | FontResource;
|
|
133
133
|
type PackInputResource = ImageResource | MovieClipResource;
|
|
134
|
-
type ParsedFnt = ReturnType<typeof _parseFnt>;
|
|
135
134
|
|
|
136
135
|
function getPublishedItemId(resource: { getId(): string; getExtras(): ExtrasMap | undefined }): string {
|
|
137
136
|
return ((resource.getExtras() as ImageResourceExtras | undefined) ?? {})._publishedId ?? resource.getId();
|
|
@@ -253,60 +252,6 @@ function resolveFontFileName(fontName: string): string {
|
|
|
253
252
|
return /\.fnt$/i.test(fontName) ? fontName : `${fontName}.fnt`;
|
|
254
253
|
}
|
|
255
254
|
|
|
256
|
-
function addLocalResourceByUiUrl(
|
|
257
|
-
target: PackageResource[],
|
|
258
|
-
added: Set<string>,
|
|
259
|
-
resourceMap: Map<string, PackageResource>,
|
|
260
|
-
pkgId: string,
|
|
261
|
-
value: string | null | undefined,
|
|
262
|
-
): void {
|
|
263
|
-
if (!value || typeof value !== 'string' || !value.startsWith('ui://')) return;
|
|
264
|
-
const normalized = value.slice(5).split(',')[0] ?? '';
|
|
265
|
-
if (!normalized) return;
|
|
266
|
-
let resourceId = '';
|
|
267
|
-
const slashIndex = normalized.indexOf('/');
|
|
268
|
-
if (slashIndex >= 0) {
|
|
269
|
-
const packageToken = normalized.slice(0, slashIndex);
|
|
270
|
-
if (packageToken !== pkgId) return;
|
|
271
|
-
resourceId = normalized.slice(slashIndex + 1);
|
|
272
|
-
} else if (normalized.length > 8) {
|
|
273
|
-
const packageToken = normalized.slice(0, 8);
|
|
274
|
-
if (packageToken !== pkgId) return;
|
|
275
|
-
resourceId = normalized.slice(8);
|
|
276
|
-
}
|
|
277
|
-
if (!resourceId) return;
|
|
278
|
-
const resource = resourceMap.get(resourceId);
|
|
279
|
-
if (!resource || added.has(resourceId)) return;
|
|
280
|
-
added.add(resourceId);
|
|
281
|
-
target.push(resource);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function addLocalResourcesByText(
|
|
285
|
-
target: PackageResource[],
|
|
286
|
-
added: Set<string>,
|
|
287
|
-
resourceMap: Map<string, PackageResource>,
|
|
288
|
-
pkgId: string,
|
|
289
|
-
value: string | null | undefined,
|
|
290
|
-
): void {
|
|
291
|
-
if (!value || typeof value !== 'string') return;
|
|
292
|
-
for (const match of value.matchAll(/ui:\/\/[0-9a-z]{8}[0-9a-z]+/gi)) {
|
|
293
|
-
addLocalResourceByUiUrl(target, added, resourceMap, pkgId, match[0]);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
function addResourceById(
|
|
298
|
-
target: PackageResource[],
|
|
299
|
-
added: Set<string>,
|
|
300
|
-
resourceMap: Map<string, PackageResource>,
|
|
301
|
-
resourceId: string | null | undefined,
|
|
302
|
-
): void {
|
|
303
|
-
if (!resourceId) return;
|
|
304
|
-
const resource = resourceMap.get(resourceId);
|
|
305
|
-
if (!resource || added.has(resourceId)) return;
|
|
306
|
-
added.add(resourceId);
|
|
307
|
-
target.push(resource);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
255
|
async function resolveEditorCompatibleResourceOrder(
|
|
311
256
|
pkg: Package,
|
|
312
257
|
allResources: PackageResource[],
|
|
@@ -1473,7 +1418,6 @@ async function _collectFontTexture(
|
|
|
1473
1418
|
pkg: Package,
|
|
1474
1419
|
options: AtlasOptions,
|
|
1475
1420
|
): Promise<void> {
|
|
1476
|
-
const extras = fontRes.getExtras() as FontResourceExtras;
|
|
1477
1421
|
const textureId = fontRes.getTextureId?.() ?? '';
|
|
1478
1422
|
|
|
1479
1423
|
if (textureId) {
|
package/src/index.ts
CHANGED
|
@@ -22,6 +22,12 @@ export {
|
|
|
22
22
|
type ResolvedPublishOptions,
|
|
23
23
|
type ResolvePublishOptionsOverrides,
|
|
24
24
|
} from './publish.js';
|
|
25
|
+
export {
|
|
26
|
+
applyUamTransactionApp,
|
|
27
|
+
type ApplyUamTransactionAppError,
|
|
28
|
+
type ApplyUamTransactionAppInput,
|
|
29
|
+
type ApplyUamTransactionAppResult,
|
|
30
|
+
} from './uam-transaction.js';
|
|
25
31
|
export { createTransform } from './utils.js';
|
|
26
32
|
export type {
|
|
27
33
|
CliAtlasSettings,
|
|
@@ -78,7 +78,7 @@ class BinarySearchCompat {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
private getCurrent(): number {
|
|
81
|
-
if (this.pot) return Math.trunc(
|
|
81
|
+
if (this.pot) return Math.trunc(2 ** this.current);
|
|
82
82
|
if (this.mof) return this.current * 4;
|
|
83
83
|
return this.current;
|
|
84
84
|
}
|
|
@@ -323,8 +323,8 @@ function initSizeScheme(): Array<{ width: number; height: number; area: number;
|
|
|
323
323
|
const result = [];
|
|
324
324
|
for (let w = 5; w <= 13; w += 1) {
|
|
325
325
|
for (let h = 5; h <= 13; h += 1) {
|
|
326
|
-
const width =
|
|
327
|
-
const height =
|
|
326
|
+
const width = 2 ** w;
|
|
327
|
+
const height = 2 ** h;
|
|
328
328
|
const area = width * height;
|
|
329
329
|
const aspectRatio = width > height ? width / height : height / width;
|
|
330
330
|
result.push({ width, height, area, aspectRatio, len: Math.max(width, height) });
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyUamTransaction,
|
|
3
|
+
type UamProject,
|
|
4
|
+
UamTransactionError,
|
|
5
|
+
type UamTransactionErrorCode,
|
|
6
|
+
type UamTransactionOperation,
|
|
7
|
+
type UamTransactionSupportIssue,
|
|
8
|
+
type UamValidationIssue,
|
|
9
|
+
} from '@openfairygui/core';
|
|
10
|
+
|
|
11
|
+
export interface ApplyUamTransactionAppInput {
|
|
12
|
+
project: UamProject;
|
|
13
|
+
operations: UamTransactionOperation[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ApplyUamTransactionAppError {
|
|
17
|
+
code: UamTransactionErrorCode;
|
|
18
|
+
stage: 'preflight' | 'execution' | 'postflight';
|
|
19
|
+
message: string;
|
|
20
|
+
opIndex?: number;
|
|
21
|
+
opId?: string;
|
|
22
|
+
opKind?: UamTransactionOperation['kind'];
|
|
23
|
+
selector?: Record<string, unknown>;
|
|
24
|
+
issues?: UamValidationIssue[] | UamTransactionSupportIssue[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type ApplyUamTransactionAppResult =
|
|
28
|
+
| { ok: true; project: UamProject }
|
|
29
|
+
| { ok: false; error: ApplyUamTransactionAppError };
|
|
30
|
+
|
|
31
|
+
function mapTransactionErrorStage(error: UamTransactionError): ApplyUamTransactionAppError['stage'] {
|
|
32
|
+
switch (error.code) {
|
|
33
|
+
case 'transaction_unsupported':
|
|
34
|
+
return 'preflight';
|
|
35
|
+
case 'invalid_uam':
|
|
36
|
+
return 'preflight';
|
|
37
|
+
case 'execution_failure':
|
|
38
|
+
return error.opIndex === undefined && error.issues !== undefined ? 'postflight' : 'execution';
|
|
39
|
+
case 'selector_ambiguity':
|
|
40
|
+
return error.opIndex === undefined ? 'preflight' : 'execution';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function applyUamTransactionApp(input: ApplyUamTransactionAppInput): ApplyUamTransactionAppResult {
|
|
45
|
+
try {
|
|
46
|
+
return {
|
|
47
|
+
ok: true,
|
|
48
|
+
project: applyUamTransaction(input.project, input.operations),
|
|
49
|
+
};
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (error instanceof UamTransactionError) {
|
|
52
|
+
return {
|
|
53
|
+
ok: false,
|
|
54
|
+
error: {
|
|
55
|
+
code: error.code,
|
|
56
|
+
stage: mapTransactionErrorStage(error),
|
|
57
|
+
message: error.message,
|
|
58
|
+
opIndex: error.opIndex,
|
|
59
|
+
opId: error.opId,
|
|
60
|
+
opKind: error.opKind,
|
|
61
|
+
selector: error.selector,
|
|
62
|
+
issues: error.issues,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|