Skip to content

Commit 164872a

Browse files
committed
accept files for extract/compress/decompress
1 parent e3a6217 commit 164872a

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

packages/runtime/src/artifact.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ export namespace Artifact {
5858
return value;
5959
};
6060

61-
export let extract = async (blob: tg.Blob): Promise<Artifact> => {
61+
export let extract = async (blob: tg.Blob | tg.File): Promise<Artifact> => {
62+
if (blob instanceof tg.File) {
63+
blob = await blob.contents();
64+
}
6265
let value = await tg.build({
6366
args: ["extract", blob],
6467
env: undefined,

packages/runtime/src/blob.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ export namespace Blob {
7070
};
7171

7272
export let compress = async (
73-
blob: Blob,
73+
blob: Blob | tg.File,
7474
format: CompressionFormat,
7575
): Promise<Blob> => {
76+
if (blob instanceof tg.File) {
77+
blob = await blob.contents();
78+
}
7679
let value = await tg.build({
7780
args: ["compress", blob, format],
7881
env: undefined,
@@ -82,7 +85,10 @@ export namespace Blob {
8285
return value;
8386
};
8487

85-
export let decompress = async (blob: Blob): Promise<Blob> => {
88+
export let decompress = async (blob: Blob | tg.File): Promise<Blob> => {
89+
if (blob instanceof tg.File) {
90+
blob = await blob.contents();
91+
}
8692
let value = await tg.build({
8793
args: ["decompress", blob],
8894
env: undefined,

packages/runtime/tangram.d.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ declare namespace tg {
9292

9393
/** Compress a blob. **/
9494
export let compress: (
95-
blob: tg.Blob,
95+
blob: tg.Blob | tg.File,
9696
format: tg.Blob.CompressionFormat,
9797
) => Promise<tg.Blob>;
9898

9999
/** Decompress a blob. **/
100100
export let decompress: (
101-
blob: tg.Blob,
101+
blob: tg.Blob | tg.File,
102102
) => Promise<tg.Blob>;
103103

104104
/** Download the contents of a URL. */
@@ -125,13 +125,13 @@ declare namespace tg {
125125

126126
/** Compress a blob. **/
127127
export let compress: (
128-
blob: tg.Blob,
128+
blob: tg.Blob | tg.File,
129129
format: tg.Blob.CompressionFormat,
130130
) => Promise<tg.Blob>;
131131

132132
/** Decompress a blob. **/
133133
export let decompress: (
134-
blob: tg.Blob,
134+
blob: tg.Blob | tg.File,
135135
) => Promise<tg.Blob>;
136136

137137
/** Download a blob. **/
@@ -238,7 +238,7 @@ declare namespace tg {
238238

239239
/** Extract an artifact from an archive. **/
240240
export let extract: (
241-
blob: tg.Blob,
241+
blob: tg.Blob | tg.File,
242242
) => Promise<tg.Artifact>;
243243

244244
/** Bundle an artifact. **/
@@ -271,7 +271,7 @@ declare namespace tg {
271271

272272
/** Extract an artifact from an archive. **/
273273
export let extract: (
274-
blob: tg.Blob,
274+
blob: tg.Blob | tg.File,
275275
) => Promise<tg.Artifact>;
276276

277277
/** Bundle an artifact. **/

0 commit comments

Comments
 (0)