@openfairygui/functions 0.2.0-alpha.33 → 0.2.0-alpha.35
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 +3 -1
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/node.cjs +2 -2
- package/dist/node.js +2 -2
- package/dist/{publish-BJk8UzRP.js → publish--8vagaSA.js} +135 -210
- package/dist/{publish-DCP0AYx2.cjs → publish-Bv7E2fZE.cjs} +139 -208
- package/dist/{restore-C98ugT2H.js → restore-CknfGMJM.js} +9 -1
- package/dist/{restore-BUaCK8ui.cjs → restore-iTgeWr7-.cjs} +9 -1
- package/dist/uam-transaction.cjs +29 -14
- package/dist/uam-transaction.d.cts +2 -1
- package/dist/uam-transaction.d.ts +2 -1
- package/dist/uam-transaction.js +30 -16
- package/dist/web.cjs +33 -4
- package/dist/web.d.cts +3 -0
- package/dist/web.d.ts +3 -0
- package/dist/web.js +33 -4
- package/package.json +2 -2
- package/src/adapters/web/publish.ts +40 -3
- package/src/atlas/inputs.ts +72 -110
- package/src/atlas/jta.ts +116 -170
- package/src/atlas.ts +12 -1
- package/src/index.ts +1 -0
- package/src/publish.ts +45 -2
- package/src/restore.ts +10 -0
- package/src/uam-transaction.ts +34 -17
|
@@ -599,153 +599,76 @@ function parseFnt(text) {
|
|
|
599
599
|
}
|
|
600
600
|
//#endregion
|
|
601
601
|
//#region src/atlas/jta.ts
|
|
602
|
-
const PNG_SIGNATURE = new Uint8Array([
|
|
603
|
-
137,
|
|
604
|
-
80,
|
|
605
|
-
78,
|
|
606
|
-
71,
|
|
607
|
-
13,
|
|
608
|
-
10,
|
|
609
|
-
26,
|
|
610
|
-
10
|
|
611
|
-
]);
|
|
612
602
|
function extractJtaFrames(data) {
|
|
613
|
-
const
|
|
614
|
-
|
|
615
|
-
let firstPngOffset = -1;
|
|
616
|
-
while (offset < data.length) {
|
|
617
|
-
const signatureIndex = findPngSignature(data, offset);
|
|
618
|
-
if (signatureIndex === -1) break;
|
|
619
|
-
if (firstPngOffset === -1) firstPngOffset = signatureIndex;
|
|
620
|
-
const end = findPngEnd(data, signatureIndex);
|
|
621
|
-
if (end === -1) break;
|
|
622
|
-
frames.push(data.subarray(signatureIndex, end));
|
|
623
|
-
offset = end;
|
|
624
|
-
}
|
|
625
|
-
if (firstPngOffset === -1 || frames.length === 0) return { frames: [] };
|
|
603
|
+
const parsed = (0, _openfairygui_core.parseJta)(data);
|
|
604
|
+
const derived = (0, _openfairygui_core.deriveMovieClipModel)(parsed);
|
|
626
605
|
return {
|
|
627
|
-
frames,
|
|
628
|
-
meta:
|
|
606
|
+
frames: parsed.textures.map((texture) => texture.raw),
|
|
607
|
+
meta: {
|
|
608
|
+
interval: derived.interval,
|
|
609
|
+
repeatDelay: derived.repeatDelay,
|
|
610
|
+
swing: derived.swing,
|
|
611
|
+
width: derived.dimensions.width,
|
|
612
|
+
height: derived.dimensions.height,
|
|
613
|
+
frames: derived.frames.map((frame) => ({
|
|
614
|
+
addDelay: frame.addDelay,
|
|
615
|
+
offsetX: frame.rectX,
|
|
616
|
+
offsetY: frame.rectY,
|
|
617
|
+
width: frame.rectWidth,
|
|
618
|
+
height: frame.rectHeight,
|
|
619
|
+
textureIndex: frame.textureIndex
|
|
620
|
+
}))
|
|
621
|
+
}
|
|
629
622
|
};
|
|
630
623
|
}
|
|
631
|
-
function
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
const speedRaw = readUint8At(data, state, end);
|
|
673
|
-
const repeatDelayRaw = readUint8At(data, state, end);
|
|
674
|
-
const swingRaw = readInt8At(data, state, end);
|
|
675
|
-
const frameTableCount = readInt16BEAt(data, state, end);
|
|
676
|
-
if (speedRaw == null || repeatDelayRaw == null || swingRaw == null || frameTableCount == null) return void 0;
|
|
677
|
-
const frames = [];
|
|
678
|
-
for (let index = 0; index < frameTableCount; index += 1) {
|
|
679
|
-
const delayRaw = readInt16BEAt(data, state, end);
|
|
680
|
-
const offsetX = readInt16BEAt(data, state, end);
|
|
681
|
-
const offsetY = readInt16BEAt(data, state, end);
|
|
682
|
-
const frameWidth = readInt16BEAt(data, state, end);
|
|
683
|
-
const frameHeight = readInt16BEAt(data, state, end);
|
|
684
|
-
const textureIndex = readInt16BEAt(data, state, end);
|
|
685
|
-
if (delayRaw == null || offsetX == null || offsetY == null || frameWidth == null || frameHeight == null || textureIndex == null) break;
|
|
686
|
-
frames.push({
|
|
687
|
-
addDelay: Math.trunc(1e3 / fps * delayRaw),
|
|
688
|
-
offsetX,
|
|
689
|
-
offsetY,
|
|
690
|
-
width: frameWidth,
|
|
691
|
-
height: frameHeight,
|
|
692
|
-
textureIndex
|
|
624
|
+
function detectSupportedRasterFormat(data) {
|
|
625
|
+
if (data.length >= 8 && data[0] === 137 && data[1] === 80 && data[2] === 78 && data[3] === 71 && data[4] === 13 && data[5] === 10 && data[6] === 26 && data[7] === 10) return "png";
|
|
626
|
+
if (data.length >= 2 && data[0] === 255 && data[1] === 216) return "jpeg";
|
|
627
|
+
return null;
|
|
628
|
+
}
|
|
629
|
+
function couldNotDecode(filePath, frameIndex, textureIndex) {
|
|
630
|
+
return /* @__PURE__ */ new Error(`atlas: Could not decode MovieClip "${filePath}" frame ${frameIndex} (texture ${textureIndex}).`);
|
|
631
|
+
}
|
|
632
|
+
async function prepareJtaForPublish(data, encoder, filePath) {
|
|
633
|
+
const extracted = extractJtaFrames(data);
|
|
634
|
+
const firstFrameIndexByTextureIndex = /* @__PURE__ */ new Map();
|
|
635
|
+
for (let frameIndex = 0; frameIndex < extracted.meta.frames.length; frameIndex += 1) {
|
|
636
|
+
const textureIndex = extracted.meta.frames[frameIndex].textureIndex;
|
|
637
|
+
if (textureIndex >= 0 && !firstFrameIndexByTextureIndex.has(textureIndex)) firstFrameIndexByTextureIndex.set(textureIndex, frameIndex);
|
|
638
|
+
}
|
|
639
|
+
const referencedTextures = [];
|
|
640
|
+
for (let textureIndex = 0; textureIndex < extracted.frames.length; textureIndex += 1) {
|
|
641
|
+
const firstFrameIndex = firstFrameIndexByTextureIndex.get(textureIndex);
|
|
642
|
+
if (firstFrameIndex === void 0) continue;
|
|
643
|
+
const raw = extracted.frames[textureIndex];
|
|
644
|
+
if (raw.byteLength === 0) throw new Error(`atlas: MovieClip "${filePath}" frame ${firstFrameIndex} references empty texture ${textureIndex}.`);
|
|
645
|
+
const detectedFormat = detectSupportedRasterFormat(raw);
|
|
646
|
+
if (!detectedFormat) throw new Error(`atlas: MovieClip "${filePath}" frame ${firstFrameIndex} (texture ${textureIndex}) uses an unsupported raster format; only PNG and JPEG are supported.`);
|
|
647
|
+
const imageInfo = (0, _openfairygui_core.probeRasterImage)(raw);
|
|
648
|
+
if (!imageInfo || imageInfo.format !== detectedFormat) throw couldNotDecode(filePath, firstFrameIndex, textureIndex);
|
|
649
|
+
let buffer = raw;
|
|
650
|
+
if (encoder) {
|
|
651
|
+
try {
|
|
652
|
+
buffer = await encoder(raw).png().toBuffer();
|
|
653
|
+
} catch {
|
|
654
|
+
throw couldNotDecode(filePath, firstFrameIndex, textureIndex);
|
|
655
|
+
}
|
|
656
|
+
const normalizedInfo = (0, _openfairygui_core.probeRasterImage)(buffer);
|
|
657
|
+
if (!normalizedInfo || normalizedInfo.format !== "png" || normalizedInfo.width !== imageInfo.width || normalizedInfo.height !== imageInfo.height) throw couldNotDecode(filePath, firstFrameIndex, textureIndex);
|
|
658
|
+
}
|
|
659
|
+
referencedTextures.push({
|
|
660
|
+
textureIndex,
|
|
661
|
+
firstFrameIndex,
|
|
662
|
+
buffer,
|
|
663
|
+
width: imageInfo.width,
|
|
664
|
+
height: imageInfo.height
|
|
693
665
|
});
|
|
694
666
|
}
|
|
695
667
|
return {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
swing: swingRaw === 1,
|
|
699
|
-
width,
|
|
700
|
-
height,
|
|
701
|
-
frames: frames.length === 0 && frameCount > 0 ? [] : frames
|
|
668
|
+
...extracted,
|
|
669
|
+
referencedTextures
|
|
702
670
|
};
|
|
703
671
|
}
|
|
704
|
-
function readUtfBE(data, state, end) {
|
|
705
|
-
const length = readUint16BEAt(data, state, end);
|
|
706
|
-
if (length == null || state.offset + length > end) return null;
|
|
707
|
-
const value = new TextDecoder().decode(data.subarray(state.offset, state.offset + length));
|
|
708
|
-
state.offset += length;
|
|
709
|
-
return value;
|
|
710
|
-
}
|
|
711
|
-
function readUint8At(data, state, end) {
|
|
712
|
-
if (state.offset + 1 > end) return null;
|
|
713
|
-
const value = data[state.offset];
|
|
714
|
-
state.offset += 1;
|
|
715
|
-
return value ?? 0;
|
|
716
|
-
}
|
|
717
|
-
function readInt8At(data, state, end) {
|
|
718
|
-
if (state.offset + 1 > end) return null;
|
|
719
|
-
const value = new DataView(data.buffer, data.byteOffset, data.byteLength).getInt8(state.offset);
|
|
720
|
-
state.offset += 1;
|
|
721
|
-
return value;
|
|
722
|
-
}
|
|
723
|
-
function readUint16BEAt(data, state, end) {
|
|
724
|
-
if (state.offset + 2 > end) return null;
|
|
725
|
-
const value = readUint16BE(data, state.offset);
|
|
726
|
-
state.offset += 2;
|
|
727
|
-
return value;
|
|
728
|
-
}
|
|
729
|
-
function readInt16BEAt(data, state, end) {
|
|
730
|
-
if (state.offset + 2 > end) return null;
|
|
731
|
-
const value = new DataView(data.buffer, data.byteOffset, data.byteLength).getInt16(state.offset, false);
|
|
732
|
-
state.offset += 2;
|
|
733
|
-
return value;
|
|
734
|
-
}
|
|
735
|
-
function readInt32BEAt(data, state, end) {
|
|
736
|
-
if (state.offset + 4 > end) return null;
|
|
737
|
-
const value = new DataView(data.buffer, data.byteOffset, data.byteLength).getInt32(state.offset, false);
|
|
738
|
-
state.offset += 4;
|
|
739
|
-
return value;
|
|
740
|
-
}
|
|
741
|
-
function readUint16BE(data, offset) {
|
|
742
|
-
if (offset + 1 >= data.length) return 0;
|
|
743
|
-
return data[offset] << 8 | data[offset + 1];
|
|
744
|
-
}
|
|
745
|
-
function readUint32BE(data, offset) {
|
|
746
|
-
if (offset + 3 >= data.length) return 0;
|
|
747
|
-
return data[offset] * 16777216 + ((data[offset + 1] ?? 0) << 16) + ((data[offset + 2] ?? 0) << 8) + (data[offset + 3] ?? 0);
|
|
748
|
-
}
|
|
749
672
|
//#endregion
|
|
750
673
|
//#region src/atlas/inputs.ts
|
|
751
674
|
function getPublishedItemId(resource) {
|
|
@@ -815,6 +738,27 @@ async function _trimImage(encoder, input, originalWidth, originalHeight) {
|
|
|
815
738
|
};
|
|
816
739
|
}
|
|
817
740
|
}
|
|
741
|
+
function resolveMovieClipSourcePath(resource, pkg, basePath) {
|
|
742
|
+
const fileName = `${resource.getName()}.jta`;
|
|
743
|
+
const resourcePath = resource.getPath() ?? "/";
|
|
744
|
+
return `${basePath}/${pkg.getName()}${resourcePath}${fileName}`;
|
|
745
|
+
}
|
|
746
|
+
async function prepareMovieClipResource(resource, pkg, encoder, basePath, readFileRaw) {
|
|
747
|
+
const filePath = resolveMovieClipSourcePath(resource, pkg, basePath);
|
|
748
|
+
let raw;
|
|
749
|
+
try {
|
|
750
|
+
raw = await readFileRaw(filePath);
|
|
751
|
+
} catch {
|
|
752
|
+
throw new Error(`atlas: Could not read MovieClip "${filePath}".`);
|
|
753
|
+
}
|
|
754
|
+
try {
|
|
755
|
+
return await prepareJtaForPublish(raw, encoder, filePath);
|
|
756
|
+
} catch (error) {
|
|
757
|
+
if (error instanceof Error && error.message.startsWith("atlas:")) throw error;
|
|
758
|
+
const detail = error instanceof Error ? ` ${error.message}` : "";
|
|
759
|
+
throw new Error(`atlas: Could not parse MovieClip "${filePath}".${detail}`);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
818
762
|
/** Collect a single ImageResource into the inputs array. */
|
|
819
763
|
async function collectImage(resource, pkg, inputs, encoder, options, doTrim, logger) {
|
|
820
764
|
let origW = resource.getWidth() ?? 0;
|
|
@@ -888,82 +832,45 @@ async function collectMovieClipFrames(doc, resource, pkg, inputs, encoder, optio
|
|
|
888
832
|
}
|
|
889
833
|
if (!encoder && options.strictOutput) throw new Error(`atlas: MovieClip "${resource.getId()}" requires an encoder for complete raster output.`);
|
|
890
834
|
const mcId = resource.getId();
|
|
891
|
-
const
|
|
892
|
-
const mcPath = resource.getPath() ?? "/";
|
|
893
|
-
const filePath = `${options.basePath}/${pkg.getName()}${mcPath}${mcName}`;
|
|
835
|
+
const filePath = resolveMovieClipSourcePath(resource, pkg, options.basePath);
|
|
894
836
|
try {
|
|
895
|
-
const jta =
|
|
896
|
-
if (jta.frames.length === 0) return;
|
|
897
|
-
const frameMetas = jta.meta?.frames ?? [];
|
|
837
|
+
const jta = options.preparedMovieClips?.get(resource) ?? await prepareMovieClipResource(resource, pkg, encoder, options.basePath, options.readFileRaw);
|
|
898
838
|
for (const frame of resource.listFrames()) resource.removeFrame(frame);
|
|
899
|
-
resource.setInterval(jta.meta
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
resource.addFrame(frame);
|
|
923
|
-
}
|
|
924
|
-
} else for (let frameIndex = 0; frameIndex < jta.frames.length; frameIndex += 1) {
|
|
925
|
-
const itemId = `${mcId}_${frameIndex}`;
|
|
926
|
-
const input = await createMovieClipFrameInput(jta.frames[frameIndex], itemId, resource, encoder, options.strictOutput);
|
|
927
|
-
if (!input) continue;
|
|
928
|
-
inputs.push(input);
|
|
929
|
-
const frame = doc.createMovieFrame(itemId);
|
|
930
|
-
frame.setRectX(0).setRectY(0).setRectWidth(input.originalWidth).setRectHeight(input.originalHeight).setAddDelay(0).setSpriteId(itemId);
|
|
839
|
+
resource.setInterval(jta.meta.interval).setSwing(jta.meta.swing).setRepeatDelay(jta.meta.repeatDelay);
|
|
840
|
+
const spriteIdByTextureIndex = /* @__PURE__ */ new Map();
|
|
841
|
+
for (const texture of jta.referencedTextures) {
|
|
842
|
+
if (texture.width <= 0 || texture.height <= 0) continue;
|
|
843
|
+
const itemId = `${mcId}_${texture.firstFrameIndex}`;
|
|
844
|
+
inputs.push({
|
|
845
|
+
id: itemId,
|
|
846
|
+
width: texture.width,
|
|
847
|
+
height: texture.height,
|
|
848
|
+
originalWidth: texture.width,
|
|
849
|
+
originalHeight: texture.height,
|
|
850
|
+
offsetX: 0,
|
|
851
|
+
offsetY: 0,
|
|
852
|
+
resource,
|
|
853
|
+
trimBuffer: texture.buffer,
|
|
854
|
+
sourceKind: "movieclip-frame"
|
|
855
|
+
});
|
|
856
|
+
spriteIdByTextureIndex.set(texture.textureIndex, itemId);
|
|
857
|
+
}
|
|
858
|
+
for (let frameIndex = 0; frameIndex < jta.meta.frames.length; frameIndex += 1) {
|
|
859
|
+
const meta = jta.meta.frames[frameIndex];
|
|
860
|
+
const frame = doc.createMovieFrame(`${mcId}_${frameIndex}`);
|
|
861
|
+
frame.setRectX(meta.offsetX).setRectY(meta.offsetY).setRectWidth(meta.width).setRectHeight(meta.height).setAddDelay(meta.addDelay).setSpriteId(meta.textureIndex === -1 ? "" : spriteIdByTextureIndex.get(meta.textureIndex) ?? "");
|
|
931
862
|
resource.addFrame(frame);
|
|
932
863
|
}
|
|
933
|
-
if (
|
|
934
|
-
resource.setWidth(jta.meta
|
|
935
|
-
resource.setHeight(jta.meta
|
|
864
|
+
if (jta.meta.width > 0 && jta.meta.height > 0) {
|
|
865
|
+
resource.setWidth(jta.meta.width);
|
|
866
|
+
resource.setHeight(jta.meta.height);
|
|
936
867
|
}
|
|
937
|
-
} catch {
|
|
938
|
-
const message = `atlas: Could not parse MovieClip "${filePath}".`;
|
|
939
|
-
if (options.strictOutput) throw
|
|
868
|
+
} catch (error) {
|
|
869
|
+
const message = error instanceof Error ? error.message : `atlas: Could not parse MovieClip "${filePath}".`;
|
|
870
|
+
if (options.strictOutput) throw error;
|
|
940
871
|
logger.warn(`${message} Skipping frames.`);
|
|
941
872
|
}
|
|
942
873
|
}
|
|
943
|
-
async function createMovieClipFrameInput(buffer, itemId, resource, encoder, strictOutput) {
|
|
944
|
-
if (!encoder || buffer.length === 0) return null;
|
|
945
|
-
try {
|
|
946
|
-
const meta = await encoder(buffer).metadata();
|
|
947
|
-
const width = meta.width ?? 0;
|
|
948
|
-
const height = meta.height ?? 0;
|
|
949
|
-
if (width <= 0 || height <= 0) return null;
|
|
950
|
-
return {
|
|
951
|
-
id: itemId,
|
|
952
|
-
width,
|
|
953
|
-
height,
|
|
954
|
-
originalWidth: width,
|
|
955
|
-
originalHeight: height,
|
|
956
|
-
offsetX: 0,
|
|
957
|
-
offsetY: 0,
|
|
958
|
-
resource,
|
|
959
|
-
trimBuffer: buffer,
|
|
960
|
-
sourceKind: "movieclip-frame"
|
|
961
|
-
};
|
|
962
|
-
} catch {
|
|
963
|
-
if (strictOutput) throw new Error(`atlas: Could not decode MovieClip frame "${itemId}".`);
|
|
964
|
-
return null;
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
874
|
/** Collect a Bitmap Font's texture image, packed under the font's ID. */
|
|
968
875
|
async function collectFontTexture(doc, fontRes, pkg, options) {
|
|
969
876
|
const textureId = fontRes.getTextureId?.() ?? "";
|
|
@@ -3137,7 +3044,7 @@ function publish(options) {
|
|
|
3137
3044
|
return paths.join("/");
|
|
3138
3045
|
}
|
|
3139
3046
|
});
|
|
3140
|
-
const publishPackage = async (plan, writerFs, packageIndex) => {
|
|
3047
|
+
const publishPackage = async (plan, writerFs, packageIndex, preparedMovieClips) => {
|
|
3141
3048
|
if (options.fs && !plan.outputDir) throw new Error("publish: no output directory resolved. Provide --output, or configure global publish.path / package publishPath.");
|
|
3142
3049
|
if (options.fs) {
|
|
3143
3050
|
await options.fs.mkdir(plan.outputDir);
|
|
@@ -3155,6 +3062,7 @@ function publish(options) {
|
|
|
3155
3062
|
mkdir: options.fs ? options.fs.mkdir : void 0,
|
|
3156
3063
|
readFileRaw: options.atlas?.readFileRaw ?? options.fs?.readFileRaw,
|
|
3157
3064
|
strictOutput: options.fs !== void 0,
|
|
3065
|
+
preparedMovieClips,
|
|
3158
3066
|
packages: [plan.pkg.getName()],
|
|
3159
3067
|
...atlasRuntimeOptions
|
|
3160
3068
|
})(doc);
|
|
@@ -3207,8 +3115,25 @@ function publish(options) {
|
|
|
3207
3115
|
}
|
|
3208
3116
|
const unresolvedPlan = plans.find((plan) => !plan.outputDir);
|
|
3209
3117
|
if (unresolvedPlan) throw new Error(`publish: no output directory resolved for package "${unresolvedPlan.pkg.getName()}". Provide --output, or configure global publish.path / package publishPath.`);
|
|
3118
|
+
const publishedMovieClips = allPackages.flatMap((pkg) => {
|
|
3119
|
+
const publishedResourceIds = getAnnotatedPublishedResourceIds(pkg);
|
|
3120
|
+
return pkg.listResources().filter((resource) => {
|
|
3121
|
+
return publishedResourceIds.has(resource.getId()) && isMovieClipResource(resource);
|
|
3122
|
+
}).map((resource) => ({
|
|
3123
|
+
pkg,
|
|
3124
|
+
resource
|
|
3125
|
+
}));
|
|
3126
|
+
});
|
|
3127
|
+
const preparedMovieClips = /* @__PURE__ */ new Map();
|
|
3128
|
+
if (publishedMovieClips.length > 0) {
|
|
3129
|
+
if (!options.encoder) throw new Error("publish: MovieClip output requires an encoder.");
|
|
3130
|
+
if (!options.basePath) throw new Error("publish: MovieClip output requires basePath.");
|
|
3131
|
+
const readFileRaw = options.atlas?.readFileRaw ?? options.fs.readFileRaw;
|
|
3132
|
+
if (!readFileRaw) throw new Error("publish: MovieClip output requires readFileRaw.");
|
|
3133
|
+
for (const { pkg, resource } of publishedMovieClips) preparedMovieClips.set(resource, await prepareMovieClipResource(resource, pkg, options.encoder, options.basePath, readFileRaw));
|
|
3134
|
+
}
|
|
3210
3135
|
const writerFs = toBinaryWriterFileSystem(options.fs);
|
|
3211
|
-
for (const plan of plans) await publishPackage(plan, writerFs, allDocPackages.indexOf(plan.pkg));
|
|
3136
|
+
for (const plan of plans) await publishPackage(plan, writerFs, allDocPackages.indexOf(plan.pkg), preparedMovieClips);
|
|
3212
3137
|
if (options.codeGeneration !== false) await publishCodeGeneration(doc, {
|
|
3213
3138
|
basePath: options.basePath,
|
|
3214
3139
|
fs: options.fs,
|
|
@@ -3309,6 +3234,12 @@ Object.defineProperty(exports, "publishCodeGeneration", {
|
|
|
3309
3234
|
return publishCodeGeneration;
|
|
3310
3235
|
}
|
|
3311
3236
|
});
|
|
3237
|
+
Object.defineProperty(exports, "resolveCodeGenerationSettings", {
|
|
3238
|
+
enumerable: true,
|
|
3239
|
+
get: function() {
|
|
3240
|
+
return resolveCodeGenerationSettings;
|
|
3241
|
+
}
|
|
3242
|
+
});
|
|
3312
3243
|
Object.defineProperty(exports, "resolvePackageCodegenPlan", {
|
|
3313
3244
|
enumerable: true,
|
|
3314
3245
|
get: function() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as
|
|
1
|
+
import { d as basename, f as normalizeComparablePath, p as trimTrailingSlashes } from "./publish--8vagaSA.js";
|
|
2
2
|
import { BinaryReader, ProjectType, ProjectWriter, generateId } from "@openfairygui/core";
|
|
3
3
|
//#region src/restore-internals/output-transaction.ts
|
|
4
4
|
function isPathWithin(root, candidate) {
|
|
@@ -486,6 +486,14 @@ var RestoreWorkflow = class {
|
|
|
486
486
|
common: {},
|
|
487
487
|
adaptation: {}
|
|
488
488
|
});
|
|
489
|
+
for (const pkg of doc.getRoot().listPackages()) pkg.setSourceAtlasSettings({
|
|
490
|
+
...pkg.getSourceAtlasSettings(),
|
|
491
|
+
atlases: pkg.listAtlases().map((atlas) => ({
|
|
492
|
+
index: atlas.getIndex(),
|
|
493
|
+
name: atlas.getIndex() === 0 ? "Default" : atlas.getName(),
|
|
494
|
+
compression: false
|
|
495
|
+
}))
|
|
496
|
+
});
|
|
489
497
|
}
|
|
490
498
|
_initializeImageFileNames(doc) {
|
|
491
499
|
for (const pkg of doc.getRoot().listPackages()) for (const resource of pkg.listResources()) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_publish = require("./publish-
|
|
1
|
+
const require_publish = require("./publish-Bv7E2fZE.cjs");
|
|
2
2
|
let _openfairygui_core = require("@openfairygui/core");
|
|
3
3
|
//#region src/restore-internals/output-transaction.ts
|
|
4
4
|
function isPathWithin(root, candidate) {
|
|
@@ -486,6 +486,14 @@ var RestoreWorkflow = class {
|
|
|
486
486
|
common: {},
|
|
487
487
|
adaptation: {}
|
|
488
488
|
});
|
|
489
|
+
for (const pkg of doc.getRoot().listPackages()) pkg.setSourceAtlasSettings({
|
|
490
|
+
...pkg.getSourceAtlasSettings(),
|
|
491
|
+
atlases: pkg.listAtlases().map((atlas) => ({
|
|
492
|
+
index: atlas.getIndex(),
|
|
493
|
+
name: atlas.getIndex() === 0 ? "Default" : atlas.getName(),
|
|
494
|
+
compression: false
|
|
495
|
+
}))
|
|
496
|
+
});
|
|
489
497
|
}
|
|
490
498
|
_initializeImageFileNames(doc) {
|
|
491
499
|
for (const pkg of doc.getRoot().listPackages()) for (const resource of pkg.listResources()) {
|
package/dist/uam-transaction.cjs
CHANGED
|
@@ -50,6 +50,23 @@ function mapTransactionDiagnostics(error) {
|
|
|
50
50
|
opId: error.opId
|
|
51
51
|
})];
|
|
52
52
|
}
|
|
53
|
+
function transactionFailure(error) {
|
|
54
|
+
return {
|
|
55
|
+
ok: false,
|
|
56
|
+
error: {
|
|
57
|
+
code: error.code,
|
|
58
|
+
stage: mapTransactionErrorStage(error),
|
|
59
|
+
message: error.message,
|
|
60
|
+
opIndex: error.opIndex,
|
|
61
|
+
opId: error.opId,
|
|
62
|
+
opKind: error.opKind,
|
|
63
|
+
operationKind: error.opKind,
|
|
64
|
+
selector: error.selector,
|
|
65
|
+
issues: error.issues,
|
|
66
|
+
diagnostics: mapTransactionDiagnostics(error)
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
53
70
|
function applyUamTransactionApp(input) {
|
|
54
71
|
try {
|
|
55
72
|
return {
|
|
@@ -57,23 +74,21 @@ function applyUamTransactionApp(input) {
|
|
|
57
74
|
project: (0, _openfairygui_core_uam.applyUamTransaction)(input.project, input.operations)
|
|
58
75
|
};
|
|
59
76
|
} catch (error) {
|
|
60
|
-
if (error instanceof _openfairygui_core_uam.UamTransactionError) return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
operationKind: error.opKind,
|
|
70
|
-
selector: error.selector,
|
|
71
|
-
issues: error.issues,
|
|
72
|
-
diagnostics: mapTransactionDiagnostics(error)
|
|
73
|
-
}
|
|
77
|
+
if (error instanceof _openfairygui_core_uam.UamTransactionError) return transactionFailure(error);
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function applyUamTransactionAppAsync(input) {
|
|
82
|
+
try {
|
|
83
|
+
return {
|
|
84
|
+
ok: true,
|
|
85
|
+
project: await (0, _openfairygui_core_uam.applyUamTransactionAsync)(input.project, input.operations)
|
|
74
86
|
};
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error instanceof _openfairygui_core_uam.UamTransactionError) return transactionFailure(error);
|
|
75
89
|
throw error;
|
|
76
90
|
}
|
|
77
91
|
}
|
|
78
92
|
//#endregion
|
|
79
93
|
exports.applyUamTransactionApp = applyUamTransactionApp;
|
|
94
|
+
exports.applyUamTransactionAppAsync = applyUamTransactionAppAsync;
|
|
@@ -38,5 +38,6 @@ interface ApplyUamTransactionAppDiagnostic {
|
|
|
38
38
|
opId?: string;
|
|
39
39
|
}
|
|
40
40
|
declare function applyUamTransactionApp(input: ApplyUamTransactionAppInput): ApplyUamTransactionAppResult;
|
|
41
|
+
declare function applyUamTransactionAppAsync(input: ApplyUamTransactionAppInput): Promise<ApplyUamTransactionAppResult>;
|
|
41
42
|
//#endregion
|
|
42
|
-
export { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp };
|
|
43
|
+
export { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp, applyUamTransactionAppAsync };
|
|
@@ -38,5 +38,6 @@ interface ApplyUamTransactionAppDiagnostic {
|
|
|
38
38
|
opId?: string;
|
|
39
39
|
}
|
|
40
40
|
declare function applyUamTransactionApp(input: ApplyUamTransactionAppInput): ApplyUamTransactionAppResult;
|
|
41
|
+
declare function applyUamTransactionAppAsync(input: ApplyUamTransactionAppInput): Promise<ApplyUamTransactionAppResult>;
|
|
41
42
|
//#endregion
|
|
42
|
-
export { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp };
|
|
43
|
+
export { ApplyUamTransactionAppDiagnostic, ApplyUamTransactionAppError, ApplyUamTransactionAppInput, ApplyUamTransactionAppResult, applyUamTransactionApp, applyUamTransactionAppAsync };
|
package/dist/uam-transaction.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UamTransactionError, applyUamTransaction } from "@openfairygui/core/uam";
|
|
1
|
+
import { UamTransactionError, applyUamTransaction, applyUamTransactionAsync } from "@openfairygui/core/uam";
|
|
2
2
|
//#region src/uam-transaction.ts
|
|
3
3
|
function mapTransactionErrorStage(error) {
|
|
4
4
|
switch (error.code) {
|
|
@@ -49,6 +49,23 @@ function mapTransactionDiagnostics(error) {
|
|
|
49
49
|
opId: error.opId
|
|
50
50
|
})];
|
|
51
51
|
}
|
|
52
|
+
function transactionFailure(error) {
|
|
53
|
+
return {
|
|
54
|
+
ok: false,
|
|
55
|
+
error: {
|
|
56
|
+
code: error.code,
|
|
57
|
+
stage: mapTransactionErrorStage(error),
|
|
58
|
+
message: error.message,
|
|
59
|
+
opIndex: error.opIndex,
|
|
60
|
+
opId: error.opId,
|
|
61
|
+
opKind: error.opKind,
|
|
62
|
+
operationKind: error.opKind,
|
|
63
|
+
selector: error.selector,
|
|
64
|
+
issues: error.issues,
|
|
65
|
+
diagnostics: mapTransactionDiagnostics(error)
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
52
69
|
function applyUamTransactionApp(input) {
|
|
53
70
|
try {
|
|
54
71
|
return {
|
|
@@ -56,23 +73,20 @@ function applyUamTransactionApp(input) {
|
|
|
56
73
|
project: applyUamTransaction(input.project, input.operations)
|
|
57
74
|
};
|
|
58
75
|
} catch (error) {
|
|
59
|
-
if (error instanceof UamTransactionError) return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
operationKind: error.opKind,
|
|
69
|
-
selector: error.selector,
|
|
70
|
-
issues: error.issues,
|
|
71
|
-
diagnostics: mapTransactionDiagnostics(error)
|
|
72
|
-
}
|
|
76
|
+
if (error instanceof UamTransactionError) return transactionFailure(error);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function applyUamTransactionAppAsync(input) {
|
|
81
|
+
try {
|
|
82
|
+
return {
|
|
83
|
+
ok: true,
|
|
84
|
+
project: await applyUamTransactionAsync(input.project, input.operations)
|
|
73
85
|
};
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (error instanceof UamTransactionError) return transactionFailure(error);
|
|
74
88
|
throw error;
|
|
75
89
|
}
|
|
76
90
|
}
|
|
77
91
|
//#endregion
|
|
78
|
-
export { applyUamTransactionApp };
|
|
92
|
+
export { applyUamTransactionApp, applyUamTransactionAppAsync };
|