@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.
@@ -14,8 +14,8 @@ rendering chunks...
14
14
  [vite:dts] Start generate declaration files...
15
15
  dist/index.js 0.20 kB │ map: 0.09 kB
16
16
  dist/ls.js 0.44 kB │ map: 1.05 kB
17
- dist/files.js 0.84 kB │ map: 1.89 kB
18
- [vite:dts] Declaration files built in 1625ms.
17
+ dist/files.js 0.84 kB │ map: 1.93 kB
18
+ [vite:dts] Declaration files built in 1487ms.
19
19
 
20
- ✓ built in 4.84s
20
+ ✓ built in 6.01s
21
21
  Updated package.json with exports
@@ -10,20 +10,20 @@
10
10
   RUN  v3.2.4 /home/runner/work/utils/utils/packages/browser
11
11
  Coverage enabled with v8
12
12
 
13
- ↓ src/files.test.ts (1 test | 1 skipped)
14
13
  ↓ src/ls.test.ts (1 test | 1 skipped)
14
+ ↓ src/files.test.ts (1 test | 1 skipped)
15
15
 
16
16
   Test Files  2 skipped (2)
17
17
   Tests  2 skipped (2)
18
-  Start at  03:27:03
19
-  Duration  456ms (transform 39ms, setup 0ms, collect 39ms, tests 0ms, environment 1ms, prepare 236ms)
18
+  Start at  06:55:01
19
+  Duration  437ms (transform 48ms, setup 0ms, collect 41ms, tests 0ms, environment 1ms, prepare 199ms)
20
20
 
21
21
   % Coverage report from v8
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-29
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
@@ -1,5 +1,11 @@
1
1
  # @kirill.konshin/browser
2
2
 
3
+ ## 0.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Minor fixes
8
+
3
9
  ## 0.0.2
4
10
 
5
11
  ### Patch Changes
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
@@ -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;AAEF,eAAO,MAAM,QAAQ,QAAO,OAAO,CAAC,MAAM,CAgBpC,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 as string);\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;AAEO,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,MAAgB;AACrD,WAAO,UAAU;AACjB,WAAO,UAAU;AACjB,WAAO,WAAW,IAAI;AAAA,EAC1B,CAAC;AACD,QAAM,MAAA;AACV,CAAC;"}
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.2",
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
- export const openFile = (): Promise<string> =>
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 as string);
24
+ reader.onload = (e) => res(e.target?.result);
24
25
  reader.onerror = rej;
25
26
  reader.onabort = rej;
26
27
  reader.readAsText(file);