@kirill.konshin/browser 0.0.2 → 0.0.3
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/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-test.log +4 -4
- package/CHANGELOG.md +6 -0
- package/dist/files.d.ts +1 -1
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js.map +1 -1
- package/package.json +8 -2
- package/src/files.ts +3 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -14,8 +14,8 @@ rendering chunks...
|
|
|
14
14
|
[vite:dts] Start generate declaration files...
|
|
15
15
|
[2mdist/[22m[36mindex.js [39m[1m[2m0.20 kB[22m[1m[22m[2m │ map: 0.09 kB[22m
|
|
16
16
|
[2mdist/[22m[36mls.js [39m[1m[2m0.44 kB[22m[1m[22m[2m │ map: 1.05 kB[22m
|
|
17
|
-
[2mdist/[22m[36mfiles.js [39m[1m[2m0.84 kB[22m[1m[22m[2m │ map: 1.
|
|
18
|
-
[vite:dts] Declaration files built in
|
|
17
|
+
[2mdist/[22m[36mfiles.js [39m[1m[2m0.84 kB[22m[1m[22m[2m │ map: 1.93 kB[22m
|
|
18
|
+
[vite:dts] Declaration files built in 1487ms.
|
|
19
19
|
|
|
20
|
-
[32m✓ built in
|
|
20
|
+
[32m✓ built in 6.01s[39m
|
|
21
21
|
Updated package.json with exports
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
[1m[46m RUN [49m[22m [36mv3.2.4 [39m[90m/home/runner/work/utils/utils/packages/browser[39m
|
|
11
11
|
[2mCoverage enabled with [22m[33mv8[39m
|
|
12
12
|
|
|
13
|
-
[2m[90m↓[39m[22m src/files.test.ts [2m([22m[2m1 test[22m[2m | [22m[33m1 skipped[39m[2m)[22m
|
|
14
13
|
[2m[90m↓[39m[22m src/ls.test.ts [2m([22m[2m1 test[22m[2m | [22m[33m1 skipped[39m[2m)[22m
|
|
14
|
+
[2m[90m↓[39m[22m src/files.test.ts [2m([22m[2m1 test[22m[2m | [22m[33m1 skipped[39m[2m)[22m
|
|
15
15
|
|
|
16
16
|
[2m Test Files [22m [33m2 skipped[39m[90m (2)[39m
|
|
17
17
|
[2m Tests [22m [33m2 skipped[39m[90m (2)[39m
|
|
18
|
-
[2m Start at [22m
|
|
19
|
-
[2m Duration [22m
|
|
18
|
+
[2m Start at [22m 06:55:01
|
|
19
|
+
[2m Duration [22m 437ms[2m (transform 48ms, setup 0ms, collect 41ms, tests 0ms, environment 1ms, prepare 199ms)[22m
|
|
20
20
|
|
|
21
21
|
[34m % [39m[2mCoverage report from [22m[33mv8[39m
|
|
22
22
|
----------|---------|----------|---------|---------|-------------------
|
|
23
23
|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
|
|
24
24
|
----------|---------|----------|---------|---------|-------------------
|
|
25
25
|
All files | 0 | 0 | 0 | 0 |
|
|
26
|
-
files.ts | 0 | 0 | 0 | 0 | 1-
|
|
26
|
+
files.ts | 0 | 0 | 0 | 0 | 1-30
|
|
27
27
|
index.ts | 0 | 0 | 0 | 0 | 1-2
|
|
28
28
|
ls.ts | 0 | 0 | 0 | 0 | 1-15
|
|
29
29
|
----------|---------|----------|---------|---------|-------------------
|
package/CHANGELOG.md
CHANGED
package/dist/files.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const downloadFile: (file: File) => Promise<void>;
|
|
2
2
|
export declare const createFile: (text: any, filename?: string, type?: string) => Promise<File>;
|
|
3
|
-
export declare const openFile: () => Promise<string>;
|
|
3
|
+
export declare const openFile: () => Promise<ArrayBuffer | string | null | undefined>;
|
|
4
4
|
//# sourceMappingURL=files.d.ts.map
|
package/dist/files.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAU,MAAM,IAAI,KAAG,OAAO,CAAC,IAAI,CAM3D,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,MAAM,GAAG,EAAE,iBAAsB,EAAE,aAAyB,KAAG,OAAO,CAAC,IAAI,CAE3G,CAAC;
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAU,MAAM,IAAI,KAAG,OAAO,CAAC,IAAI,CAM3D,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,MAAM,GAAG,EAAE,iBAAsB,EAAE,aAAyB,KAAG,OAAO,CAAC,IAAI,CAE3G,CAAC;AAGF,eAAO,MAAM,QAAQ,QAAO,OAAO,CAAC,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAgBrE,CAAC"}
|
package/dist/files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sources":["../src/files.ts"],"sourcesContent":["export const downloadFile = async (file: File): Promise<void> => {\n //FIXME https://github.com/eligrey/FileSaver.js/issues/471\n const { saveAs } = require('file-saver');\n\n //FIXME https://github.com/eligrey/FileSaver.js/issues/731\n return saveAs(file, file.name);\n};\n\nexport const createFile = async (text: any, filename = 'file.json', type = 'application/json'): Promise<File> => {\n return new File([new Blob([text], { type })], filename);\n};\n\nexport const openFile = (): Promise<string> =>\n new Promise((res, rej) => {\n const input = document.createElement('input');\n input.type = 'file';\n input.addEventListener('change', function readFile(e) {\n input.removeEventListener('change', readFile);\n // @ts-expect-error file is always there\n const [file] = e.target.files;\n if (!file) return;\n const reader = new FileReader();\n reader.onload = (e) => res(e.target?.result
|
|
1
|
+
{"version":3,"file":"files.js","sources":["../src/files.ts"],"sourcesContent":["export const downloadFile = async (file: File): Promise<void> => {\n //FIXME https://github.com/eligrey/FileSaver.js/issues/471\n const { saveAs } = require('file-saver');\n\n //FIXME https://github.com/eligrey/FileSaver.js/issues/731\n return saveAs(file, file.name);\n};\n\nexport const createFile = async (text: any, filename = 'file.json', type = 'application/json'): Promise<File> => {\n return new File([new Blob([text], { type })], filename);\n};\n\n// TODO Filter types\nexport const openFile = (): Promise<ArrayBuffer | string | null | undefined> =>\n new Promise((res, rej) => {\n const input = document.createElement('input');\n input.type = 'file';\n input.addEventListener('change', function readFile(e) {\n input.removeEventListener('change', readFile);\n // @ts-expect-error file is always there\n const [file] = e.target.files;\n if (!file) return;\n const reader = new FileReader();\n reader.onload = (e) => res(e.target?.result);\n reader.onerror = rej;\n reader.onabort = rej;\n reader.readAsText(file);\n });\n input.click();\n });\n"],"names":["e"],"mappings":"AAAO,MAAM,eAAe,OAAO,SAA8B;AAE7D,QAAM,EAAE,OAAA,IAAW,QAAQ,YAAY;AAGvC,SAAO,OAAO,MAAM,KAAK,IAAI;AACjC;AAEO,MAAM,aAAa,OAAO,MAAW,WAAW,aAAa,OAAO,uBAAsC;AAC7G,SAAO,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,EAAE,KAAA,CAAM,CAAC,GAAG,QAAQ;AAC1D;AAGO,MAAM,WAAW,MACpB,IAAI,QAAQ,CAAC,KAAK,QAAQ;AACtB,QAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,QAAM,OAAO;AACb,QAAM,iBAAiB,UAAU,SAAS,SAAS,GAAG;AAClD,UAAM,oBAAoB,UAAU,QAAQ;AAE5C,UAAM,CAAC,IAAI,IAAI,EAAE,OAAO;AACxB,QAAI,CAAC,KAAM;AACX,UAAM,SAAS,IAAI,WAAA;AACnB,WAAO,SAAS,CAACA,OAAM,IAAIA,GAAE,QAAQ,MAAM;AAC3C,WAAO,UAAU;AACjB,WAAO,UAAU;AACjB,WAAO,WAAW,IAAI;AAAA,EAC1B,CAAC;AACD,QAAM,MAAA;AACV,CAAC;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kirill.konshin/browser",
|
|
3
3
|
"description": "Browser Utilities",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"----- BUILD -----": "",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"@kirill.konshin/utils-private": "*"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
|
-
"access": "public"
|
|
28
|
+
"access": "public",
|
|
29
|
+
"provenance": true
|
|
29
30
|
},
|
|
30
31
|
"author": "Kirill Konshin <kirill@konshin.org> (https://konshin.org)",
|
|
31
32
|
"license": "MIT",
|
|
@@ -40,5 +41,10 @@
|
|
|
40
41
|
"main": "./dist/index.js",
|
|
41
42
|
"module": "./dist/index.js",
|
|
42
43
|
"types": "./dist/index.d.ts",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "https://github.com/kirill-konshin/utils.git",
|
|
47
|
+
"directory": "packages/browser"
|
|
48
|
+
},
|
|
43
49
|
"peerDependenciesMeta": {}
|
|
44
50
|
}
|
package/src/files.ts
CHANGED
|
@@ -10,7 +10,8 @@ export const createFile = async (text: any, filename = 'file.json', type = 'appl
|
|
|
10
10
|
return new File([new Blob([text], { type })], filename);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// TODO Filter types
|
|
14
|
+
export const openFile = (): Promise<ArrayBuffer | string | null | undefined> =>
|
|
14
15
|
new Promise((res, rej) => {
|
|
15
16
|
const input = document.createElement('input');
|
|
16
17
|
input.type = 'file';
|
|
@@ -20,7 +21,7 @@ export const openFile = (): Promise<string> =>
|
|
|
20
21
|
const [file] = e.target.files;
|
|
21
22
|
if (!file) return;
|
|
22
23
|
const reader = new FileReader();
|
|
23
|
-
reader.onload = (e) => res(e.target?.result
|
|
24
|
+
reader.onload = (e) => res(e.target?.result);
|
|
24
25
|
reader.onerror = rej;
|
|
25
26
|
reader.onabort = rej;
|
|
26
27
|
reader.readAsText(file);
|