@seam-rpc/core 3.0.2 → 4.0.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/dist/index.d.ts +2 -14
- package/dist/index.js +3 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
export interface ISeamFile {
|
|
2
|
-
readonly data: Uint8Array;
|
|
3
|
-
readonly fileName?: string;
|
|
4
|
-
readonly mimeType?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare class SeamFile implements ISeamFile {
|
|
7
|
-
readonly data: Uint8Array;
|
|
8
|
-
readonly fileName?: string | undefined;
|
|
9
|
-
readonly mimeType?: string | undefined;
|
|
10
|
-
constructor(data: Uint8Array, fileName?: string | undefined, mimeType?: string | undefined);
|
|
11
|
-
static fromJSON(data: ISeamFile): SeamFile;
|
|
12
|
-
}
|
|
13
1
|
export declare function extractFiles(input: unknown): {
|
|
14
2
|
json: any;
|
|
15
|
-
files:
|
|
3
|
+
files: File[];
|
|
16
4
|
paths: (string | number)[][];
|
|
17
5
|
};
|
|
18
6
|
export declare function injectFiles(json: any, files: {
|
|
19
7
|
path: (string | number)[];
|
|
20
|
-
file:
|
|
8
|
+
file: File;
|
|
21
9
|
}[]): void;
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
export class SeamFile {
|
|
2
|
-
constructor(data, fileName, mimeType) {
|
|
3
|
-
this.data = data;
|
|
4
|
-
this.fileName = fileName;
|
|
5
|
-
this.mimeType = mimeType;
|
|
6
|
-
}
|
|
7
|
-
static fromJSON(data) {
|
|
8
|
-
return new SeamFile(data.data, data.fileName, data.mimeType);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
1
|
export function extractFiles(input) {
|
|
12
2
|
const files = [];
|
|
13
3
|
const paths = [];
|
|
14
4
|
function walk(value, path) {
|
|
15
|
-
if (value instanceof
|
|
5
|
+
if (value instanceof File) {
|
|
16
6
|
files.push(value);
|
|
17
7
|
paths.push(path);
|
|
18
8
|
return null;
|
|
@@ -33,13 +23,12 @@ export function extractFiles(input) {
|
|
|
33
23
|
}
|
|
34
24
|
export function injectFiles(json, files) {
|
|
35
25
|
for (const file of files) {
|
|
36
|
-
let value = json;
|
|
37
26
|
for (let i = 0; i < file.path.length; i++) {
|
|
38
27
|
const key = file.path[i];
|
|
39
28
|
if (i < file.path.length - 1)
|
|
40
|
-
|
|
29
|
+
json = json[key];
|
|
41
30
|
else
|
|
42
|
-
|
|
31
|
+
json[key] = file.file;
|
|
43
32
|
}
|
|
44
33
|
}
|
|
45
34
|
}
|