@leancodepl/api-binary-blob 8.3.6 → 8.5.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/package.json CHANGED
@@ -1,23 +1,60 @@
1
1
  {
2
2
  "name": "@leancodepl/api-binary-blob",
3
- "version": "8.3.6",
3
+ "version": "8.5.0",
4
4
  "license": "Apache-2.0",
5
5
  "dependencies": {
6
- "@leancodepl/api-binary": "8.3.6"
6
+ "@leancodepl/api-binary": "8.5.0"
7
7
  },
8
8
  "devDependencies": {
9
- "blob-polyfill": "^7.0.0"
9
+ "blob-polyfill": "^9.0.0"
10
10
  },
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "registry": "https://registry.npmjs.org/"
14
+ },
15
+ "engines": {
16
+ "node": ">=18.0.0"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/leancodepl/js_corelibrary.git",
21
+ "directory": "packages/cqrs-clients/custom-types/binary/api-binary-blob"
22
+ },
23
+ "homepage": "https://github.com/leancodepl/js_corelibrary",
24
+ "bugs": {
25
+ "url": "https://github.com/leancodepl/js_corelibrary/issues"
26
+ },
27
+ "description": "Binary data conversion utilities for Blob handling",
28
+ "keywords": [
29
+ "binary",
30
+ "blob",
31
+ "conversion",
32
+ "api",
33
+ "browser",
34
+ "typescript",
35
+ "javascript",
36
+ "leancode"
37
+ ],
38
+ "author": {
39
+ "name": "LeanCode",
40
+ "url": "https://leancode.co"
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "README.md",
45
+ "CHANGELOG.md"
46
+ ],
47
+ "sideEffects": false,
11
48
  "exports": {
12
49
  "./package.json": "./package.json",
13
50
  ".": {
14
51
  "module": "./index.esm.js",
15
- "types": "./index.esm.d.ts",
52
+ "types": "./index.d.ts",
16
53
  "import": "./index.cjs.mjs",
17
54
  "default": "./index.cjs.js"
18
55
  }
19
56
  },
20
57
  "module": "./index.esm.js",
21
58
  "main": "./index.cjs.js",
22
- "types": "./index.esm.d.ts"
59
+ "types": "./index.d.ts"
23
60
  }
package/index.cjs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";
@@ -1 +0,0 @@
1
- exports._default = require('./index.cjs.js').default;
package/index.cjs.js DELETED
@@ -1,58 +0,0 @@
1
- 'use strict';
2
-
3
- var apiBinary = require('@leancodepl/api-binary');
4
-
5
- function fromBlob(blob) {
6
- if (!blob) return Promise.resolve(undefined);
7
- return new Promise((resolve, reject)=>{
8
- try {
9
- const reader = new FileReader();
10
- reader.onloadend = ()=>{
11
- const result = reader.result;
12
- if (typeof result === "string") {
13
- // we need to strip the `data:*/*;base64,` from the beginning
14
- resolve(apiBinary.fromRaw(result.substring(1 + result.indexOf(",", result.indexOf(";")))));
15
- return;
16
- }
17
- throw new Error("Unknown blob result received for ApiBinary creation");
18
- };
19
- reader.onerror = reject;
20
- reader.readAsDataURL(blob);
21
- } catch (e) {
22
- reject(e);
23
- }
24
- });
25
- }
26
-
27
- function base64toBlob(base64Data, contentType, sliceSize = 512) {
28
- const byteCharacters = atob(base64Data);
29
- const byteArrays = [];
30
- for(let offset = 0; offset < byteCharacters.length; offset += sliceSize){
31
- const slice = byteCharacters.slice(offset, offset + sliceSize);
32
- const byteNumbers = new Array(slice.length);
33
- for(let i = 0; i < slice.length; i++){
34
- byteNumbers[i] = slice.charCodeAt(i);
35
- }
36
- byteArrays.push(new Uint8Array(byteNumbers));
37
- }
38
- const blob = new Blob(byteArrays, {
39
- type: contentType
40
- });
41
- return blob;
42
- }
43
-
44
- function toBlob(apiBinary$1, contentType) {
45
- if (apiBinary$1 === undefined || apiBinary$1 === null) {
46
- return undefined;
47
- }
48
- return base64toBlob(apiBinary.toRaw(apiBinary$1), contentType);
49
- }
50
-
51
- exports.fromBlob = fromBlob;
52
- exports.toBlob = toBlob;
53
- Object.keys(apiBinary).forEach(function (k) {
54
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
55
- enumerable: true,
56
- get: function () { return apiBinary[k]; }
57
- });
58
- });
package/index.cjs.mjs DELETED
@@ -1,2 +0,0 @@
1
- export * from './index.cjs.js';
2
- export { _default as default } from './index.cjs.default.js';
package/index.esm.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";
package/index.esm.js DELETED
@@ -1,50 +0,0 @@
1
- import { fromRaw, toRaw } from '@leancodepl/api-binary';
2
- export * from '@leancodepl/api-binary';
3
-
4
- function fromBlob(blob) {
5
- if (!blob) return Promise.resolve(undefined);
6
- return new Promise((resolve, reject)=>{
7
- try {
8
- const reader = new FileReader();
9
- reader.onloadend = ()=>{
10
- const result = reader.result;
11
- if (typeof result === "string") {
12
- // we need to strip the `data:*/*;base64,` from the beginning
13
- resolve(fromRaw(result.substring(1 + result.indexOf(",", result.indexOf(";")))));
14
- return;
15
- }
16
- throw new Error("Unknown blob result received for ApiBinary creation");
17
- };
18
- reader.onerror = reject;
19
- reader.readAsDataURL(blob);
20
- } catch (e) {
21
- reject(e);
22
- }
23
- });
24
- }
25
-
26
- function base64toBlob(base64Data, contentType, sliceSize = 512) {
27
- const byteCharacters = atob(base64Data);
28
- const byteArrays = [];
29
- for(let offset = 0; offset < byteCharacters.length; offset += sliceSize){
30
- const slice = byteCharacters.slice(offset, offset + sliceSize);
31
- const byteNumbers = new Array(slice.length);
32
- for(let i = 0; i < slice.length; i++){
33
- byteNumbers[i] = slice.charCodeAt(i);
34
- }
35
- byteArrays.push(new Uint8Array(byteNumbers));
36
- }
37
- const blob = new Blob(byteArrays, {
38
- type: contentType
39
- });
40
- return blob;
41
- }
42
-
43
- function toBlob(apiBinary, contentType) {
44
- if (apiBinary === undefined || apiBinary === null) {
45
- return undefined;
46
- }
47
- return base64toBlob(toRaw(apiBinary), contentType);
48
- }
49
-
50
- export { fromBlob, toBlob };
package/src/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "@leancodepl/api-binary";
2
- export * from "./lib/fromBlob";
3
- export * from "./lib/toBlob";
@@ -1 +0,0 @@
1
- export declare function base64toBlob(base64Data: string, contentType?: string, sliceSize?: number): Blob;
@@ -1,3 +0,0 @@
1
- import { ApiBinary } from "@leancodepl/api-binary";
2
- export declare function fromBlob(blob: Blob): Promise<ApiBinary>;
3
- export declare function fromBlob(blob?: Blob): Promise<ApiBinary | undefined>;
@@ -1,3 +0,0 @@
1
- import { ApiBinary } from "@leancodepl/api-binary";
2
- export declare function toBlob(apiBinary: ApiBinary, contentType?: string): Blob;
3
- export declare function toBlob(apiBinary?: ApiBinary | null, contentType?: string): Blob | undefined;