@kirill.konshin/browser 0.0.3 → 0.0.4

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.
@@ -0,0 +1,5 @@
1
+ import { createRequire } from "node:module";
2
+ //#region \0rolldown/runtime.js
3
+ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
4
+ //#endregion
5
+ export { __require };
package/dist/files.js CHANGED
@@ -1,28 +1,28 @@
1
- const downloadFile = async (file) => {
2
- const { saveAs } = require("file-saver");
3
- return saveAs(file, file.name);
1
+ import { __require } from "./_virtual/_rolldown/runtime.js";
2
+ //#region src/files.ts
3
+ var downloadFile = async (file) => {
4
+ const { saveAs } = __require("file-saver");
5
+ return saveAs(file, file.name);
4
6
  };
5
- const createFile = async (text, filename = "file.json", type = "application/json") => {
6
- return new File([new Blob([text], { type })], filename);
7
+ var createFile = async (text, filename = "file.json", type = "application/json") => {
8
+ return new File([new Blob([text], { type })], filename);
7
9
  };
8
- const openFile = () => new Promise((res, rej) => {
9
- const input = document.createElement("input");
10
- input.type = "file";
11
- input.addEventListener("change", function readFile(e) {
12
- input.removeEventListener("change", readFile);
13
- const [file] = e.target.files;
14
- if (!file) return;
15
- const reader = new FileReader();
16
- reader.onload = (e2) => res(e2.target?.result);
17
- reader.onerror = rej;
18
- reader.onabort = rej;
19
- reader.readAsText(file);
20
- });
21
- input.click();
10
+ var openFile = () => new Promise((res, rej) => {
11
+ const input = document.createElement("input");
12
+ input.type = "file";
13
+ input.addEventListener("change", function readFile(e) {
14
+ input.removeEventListener("change", readFile);
15
+ const [file] = e.target.files;
16
+ if (!file) return;
17
+ const reader = new FileReader();
18
+ reader.onload = (e) => res(e.target?.result);
19
+ reader.onerror = rej;
20
+ reader.onabort = rej;
21
+ reader.readAsText(file);
22
+ });
23
+ input.click();
22
24
  });
23
- export {
24
- createFile,
25
- downloadFile,
26
- openFile
27
- };
28
- //# sourceMappingURL=files.js.map
25
+ //#endregion
26
+ export { createFile, downloadFile, openFile };
27
+
28
+ //# sourceMappingURL=files.js.map
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\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;"}
1
+ {"version":3,"file":"files.js","names":[],"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"],"mappings":";;AAAA,IAAa,eAAe,OAAO,SAA8B;CAE7D,MAAM,EAAE,WAAA,UAAmB,YAAY;CAGvC,OAAO,OAAO,MAAM,KAAK,IAAI;AACjC;AAEA,IAAa,aAAa,OAAO,MAAW,WAAW,aAAa,OAAO,uBAAsC;CAC7G,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC,GAAG,QAAQ;AAC1D;AAGA,IAAa,iBACT,IAAI,SAAS,KAAK,QAAQ;CACtB,MAAM,QAAQ,SAAS,cAAc,OAAO;CAC5C,MAAM,OAAO;CACb,MAAM,iBAAiB,UAAU,SAAS,SAAS,GAAG;EAClD,MAAM,oBAAoB,UAAU,QAAQ;EAE5C,MAAM,CAAC,QAAQ,EAAE,OAAO;EACxB,IAAI,CAAC,MAAM;EACX,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,UAAU,MAAM,IAAI,EAAE,QAAQ,MAAM;EAC3C,OAAO,UAAU;EACjB,OAAO,UAAU;EACjB,OAAO,WAAW,IAAI;CAC1B,CAAC;CACD,MAAM,MAAM;AAChB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './files';
2
- export * from './ls';
1
+ export * from './files.js';
2
+ export * from './ls.js';
3
3
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,9 +1,3 @@
1
1
  import { createFile, downloadFile, openFile } from "./files.js";
2
2
  import { getStorage } from "./ls.js";
3
- export {
4
- createFile,
5
- downloadFile,
6
- getStorage,
7
- openFile
8
- };
9
- //# sourceMappingURL=index.js.map
3
+ export { createFile, downloadFile, getStorage, openFile };
package/dist/ls.js CHANGED
@@ -1,12 +1,17 @@
1
+ //#region src/ls.ts
1
2
  function getStorage(pref) {
2
- const prefix = (key) => `${pref}-${key}`;
3
- const ls = typeof window !== "undefined" ? localStorage : null;
4
- const read = (key) => JSON.parse(ls?.getItem(prefix(key)) || "null");
5
- const write = (key, value) => ls?.setItem(prefix(key), JSON.stringify(value));
6
- const remove = (key) => ls?.removeItem(prefix(key));
7
- return { read, write, remove };
3
+ const prefix = (key) => `${pref}-${key}`;
4
+ const ls = typeof window !== "undefined" ? localStorage : null;
5
+ const read = (key) => JSON.parse(ls?.getItem(prefix(key)) || "null");
6
+ const write = (key, value) => ls?.setItem(prefix(key), JSON.stringify(value));
7
+ const remove = (key) => ls?.removeItem(prefix(key));
8
+ return {
9
+ read,
10
+ write,
11
+ remove
12
+ };
8
13
  }
9
- export {
10
- getStorage
11
- };
12
- //# sourceMappingURL=ls.js.map
14
+ //#endregion
15
+ export { getStorage };
16
+
17
+ //# sourceMappingURL=ls.js.map
package/dist/ls.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ls.js","sources":["../src/ls.ts"],"sourcesContent":["export function getStorage(pref: string): {\n read: (key: string) => null | any;\n write: (key: string, value: any) => void;\n remove: (key: string) => void;\n} {\n const prefix = (key) => `${pref}-${key}`;\n\n const ls = (typeof window !== 'undefined' ? localStorage : null) as Storage;\n\n const read = (key: string): any => JSON.parse(ls?.getItem(prefix(key)) || 'null');\n const write = (key: string, value: any): void => ls?.setItem(prefix(key), JSON.stringify(value));\n const remove = (key: string): void => ls?.removeItem(prefix(key));\n\n return { read, write, remove };\n}\n"],"names":[],"mappings":"AAAO,SAAS,WAAW,MAIzB;AACE,QAAM,SAAS,CAAC,QAAQ,GAAG,IAAI,IAAI,GAAG;AAEtC,QAAM,KAAM,OAAO,WAAW,cAAc,eAAe;AAE3D,QAAM,OAAO,CAAC,QAAqB,KAAK,MAAM,IAAI,QAAQ,OAAO,GAAG,CAAC,KAAK,MAAM;AAChF,QAAM,QAAQ,CAAC,KAAa,UAAqB,IAAI,QAAQ,OAAO,GAAG,GAAG,KAAK,UAAU,KAAK,CAAC;AAC/F,QAAM,SAAS,CAAC,QAAsB,IAAI,WAAW,OAAO,GAAG,CAAC;AAEhE,SAAO,EAAE,MAAM,OAAO,OAAA;AAC1B;"}
1
+ {"version":3,"file":"ls.js","names":[],"sources":["../src/ls.ts"],"sourcesContent":["export function getStorage(pref: string): {\n read: (key: string) => null | any;\n write: (key: string, value: any) => void;\n remove: (key: string) => void;\n} {\n const prefix = (key) => `${pref}-${key}`;\n\n const ls = (typeof window !== 'undefined' ? localStorage : null) as Storage;\n\n const read = (key: string): any => JSON.parse(ls?.getItem(prefix(key)) || 'null');\n const write = (key: string, value: any): void => ls?.setItem(prefix(key), JSON.stringify(value));\n const remove = (key: string): void => ls?.removeItem(prefix(key));\n\n return { read, write, remove };\n}\n"],"mappings":";AAAA,SAAgB,WAAW,MAIzB;CACE,MAAM,UAAU,QAAQ,GAAG,KAAK,GAAG;CAEnC,MAAM,KAAM,OAAO,WAAW,cAAc,eAAe;CAE3D,MAAM,QAAQ,QAAqB,KAAK,MAAM,IAAI,QAAQ,OAAO,GAAG,CAAC,KAAK,MAAM;CAChF,MAAM,SAAS,KAAa,UAAqB,IAAI,QAAQ,OAAO,GAAG,GAAG,KAAK,UAAU,KAAK,CAAC;CAC/F,MAAM,UAAU,QAAsB,IAAI,WAAW,OAAO,GAAG,CAAC;CAEhE,OAAO;EAAE;EAAM;EAAO;CAAO;AACjC"}
package/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "@kirill.konshin/browser",
3
3
  "description": "Browser Utilities",
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "----- BUILD -----": "",
8
8
  "clean": "rm -rf dist .tscache tsconfig.tsbuildinfo",
9
9
  "build": "vite build",
10
- "build:index": "ctix build",
11
- "build:check-types": "attw --pack .",
12
10
  "start": "yarn build --watch",
13
11
  "wait": "wait-on ./dist/index.js",
14
12
  "----- TEST -----": "",
@@ -25,8 +23,7 @@
25
23
  "@kirill.konshin/utils-private": "*"
26
24
  },
27
25
  "publishConfig": {
28
- "access": "public",
29
- "provenance": true
26
+ "access": "public"
30
27
  },
31
28
  "author": "Kirill Konshin <kirill@konshin.org> (https://konshin.org)",
32
29
  "license": "MIT",
@@ -46,5 +43,12 @@
46
43
  "url": "https://github.com/kirill-konshin/utils.git",
47
44
  "directory": "packages/browser"
48
45
  },
49
- "peerDependenciesMeta": {}
46
+ "nx": {
47
+ "tags": [
48
+ "platform:browser"
49
+ ]
50
+ },
51
+ "files": [
52
+ "dist"
53
+ ]
50
54
  }
package/.ctirc DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "options": [
3
- {
4
- "mode": "create",
5
- "project": "tsconfig.json",
6
- "include": "src/**/*.{ts,tsx}",
7
- "exclude": [
8
- "**/*.stories.*",
9
- "**/*.test.*",
10
- "**/*.fixture.*"
11
- ],
12
- "startFrom": "src",
13
- "backup": false,
14
- "overwrite": true,
15
- "generationStyle": "default-alias-named-star",
16
- "output": "src",
17
- "verbose": true
18
- }
19
- ]
20
- }
@@ -1,21 +0,0 @@
1
- vite v7.0.6 building SSR bundle for production...
2
- - ctix 'create' mode start, ...
3
- ✔ /home/runner/work/utils/utils/packages/browser/tsconfig.json loading complete!
4
- ✔ analysis export statements completed!
5
- - build "index.ts" file start
6
- - output file exists check, ...
7
-
8
-
9
- ✔ ctix 'create' mode complete!
10
- transforming...
11
- ✓ 3 modules transformed.
12
- rendering chunks...
13
-
14
- [vite:dts] Start generate declaration files...
15
- dist/index.js 0.20 kB │ map: 0.09 kB
16
- dist/ls.js 0.44 kB │ map: 1.05 kB
17
- dist/files.js 0.84 kB │ map: 1.93 kB
18
- [vite:dts] Declaration files built in 1487ms.
19
-
20
- ✓ built in 6.01s
21
- Updated package.json with exports
@@ -1,31 +0,0 @@
1
- - ctix 'create' mode start, ...
2
- ✔ /home/runner/work/utils/utils/packages/browser/tsconfig.json loading complete!
3
- ✔ analysis export statements completed!
4
- - build "index.ts" file start
5
- - output file exists check, ...
6
-
7
-
8
- ✔ ctix 'create' mode complete!
9
-
10
-  RUN  v3.2.4 /home/runner/work/utils/utils/packages/browser
11
- Coverage enabled with v8
12
-
13
- ↓ src/ls.test.ts (1 test | 1 skipped)
14
- ↓ src/files.test.ts (1 test | 1 skipped)
15
-
16
-  Test Files  2 skipped (2)
17
-  Tests  2 skipped (2)
18
-  Start at  06:55:01
19
-  Duration  437ms (transform 48ms, setup 0ms, collect 41ms, tests 0ms, environment 1ms, prepare 199ms)
20
-
21
-  % Coverage report from v8
22
- ----------|---------|----------|---------|---------|-------------------
23
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
24
- ----------|---------|----------|---------|---------|-------------------
25
- All files | 0 | 0 | 0 | 0 |
26
- files.ts | 0 | 0 | 0 | 0 | 1-30
27
- index.ts | 0 | 0 | 0 | 0 | 1-2
28
- ls.ts | 0 | 0 | 0 | 0 | 1-15
29
- ----------|---------|----------|---------|---------|-------------------
30
- Updated package.json with exports
31
- Updated package.json with exports
package/CHANGELOG.md DELETED
@@ -1,13 +0,0 @@
1
- # @kirill.konshin/browser
2
-
3
- ## 0.0.3
4
-
5
- ### Patch Changes
6
-
7
- - Minor fixes
8
-
9
- ## 0.0.2
10
-
11
- ### Patch Changes
12
-
13
- - 63fdba8: Divided core to browser/node/worker-specific packages, CTIX upgrade, etc.
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=files.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"files.test.d.ts","sourceRoot":"","sources":["../src/files.test.ts"],"names":[],"mappings":""}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
package/dist/ls.test.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ls.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ls.test.d.ts","sourceRoot":"","sources":["../src/ls.test.ts"],"names":[],"mappings":""}
package/src/files.test.ts DELETED
@@ -1,3 +0,0 @@
1
- import { expect, describe, test, vi } from 'vitest';
2
-
3
- test.skip('Dummy', () => {});
package/src/files.ts DELETED
@@ -1,30 +0,0 @@
1
- export const downloadFile = async (file: File): Promise<void> => {
2
- //FIXME https://github.com/eligrey/FileSaver.js/issues/471
3
- const { saveAs } = require('file-saver');
4
-
5
- //FIXME https://github.com/eligrey/FileSaver.js/issues/731
6
- return saveAs(file, file.name);
7
- };
8
-
9
- export const createFile = async (text: any, filename = 'file.json', type = 'application/json'): Promise<File> => {
10
- return new File([new Blob([text], { type })], filename);
11
- };
12
-
13
- // TODO Filter types
14
- export const openFile = (): Promise<ArrayBuffer | string | null | undefined> =>
15
- new Promise((res, rej) => {
16
- const input = document.createElement('input');
17
- input.type = 'file';
18
- input.addEventListener('change', function readFile(e) {
19
- input.removeEventListener('change', readFile);
20
- // @ts-expect-error file is always there
21
- const [file] = e.target.files;
22
- if (!file) return;
23
- const reader = new FileReader();
24
- reader.onload = (e) => res(e.target?.result);
25
- reader.onerror = rej;
26
- reader.onabort = rej;
27
- reader.readAsText(file);
28
- });
29
- input.click();
30
- });
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './files';
2
- export * from './ls';
package/src/ls.test.ts DELETED
@@ -1,3 +0,0 @@
1
- import { expect, describe, test, vi } from 'vitest';
2
-
3
- test.skip('Dummy', () => {});
package/src/ls.ts DELETED
@@ -1,15 +0,0 @@
1
- export function getStorage(pref: string): {
2
- read: (key: string) => null | any;
3
- write: (key: string, value: any) => void;
4
- remove: (key: string) => void;
5
- } {
6
- const prefix = (key) => `${pref}-${key}`;
7
-
8
- const ls = (typeof window !== 'undefined' ? localStorage : null) as Storage;
9
-
10
- const read = (key: string): any => JSON.parse(ls?.getItem(prefix(key)) || 'null');
11
- const write = (key: string, value: any): void => ls?.setItem(prefix(key), JSON.stringify(value));
12
- const remove = (key: string): void => ls?.removeItem(prefix(key));
13
-
14
- return { read, write, remove };
15
- }
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../utils-private/tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "dist",
6
- "declarationDir": "dist"
7
- },
8
- "include": ["src"],
9
- "exclude": []
10
- }
package/turbo.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "$schema": "https://turbo.build/schema.json",
3
- "extends": ["//"],
4
- "tasks": {
5
- "build": {
6
- "dependsOn": ["^build"],
7
- "outputs": ["src/**/*/index.ts", "package.json", "dist/**/*"]
8
- }
9
- }
10
- }
package/vite.config.ts DELETED
@@ -1,2 +0,0 @@
1
- import config from '../utils-private/vite.config';
2
- export default config;