@akinon/app-shared 1.0.1 → 1.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["../../src/sha256.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,QAAe,OAAO,oBAY3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAe,OAAO,oBAGhD,CAAC"}
1
+ {"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["../../src/sha256.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAU,KAAK,OAAO,oBAY3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAU,KAAK,OAAO,oBAGhD,CAAC"}
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.getShortSha256 = exports.hashValue = void 0;
13
4
  /**
@@ -16,21 +7,21 @@ exports.getShortSha256 = exports.hashValue = void 0;
16
7
  * @param val - Any object or value to hash with SHA256.
17
8
  * @returns
18
9
  */
19
- const hashValue = (val) => __awaiter(void 0, void 0, void 0, function* () {
20
- const hash = yield crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify(val)));
10
+ const hashValue = async (val) => {
11
+ const hash = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify(val)));
21
12
  const hexes = [], view = new DataView(hash);
22
13
  for (let i = 0; i < view.byteLength; i += 4)
23
14
  hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8));
24
15
  return hexes.join('');
25
- });
16
+ };
26
17
  exports.hashValue = hashValue;
27
18
  /**
28
19
  * Returns the first 7 chars of hashed value. Sohuld be unique.
29
20
  *
30
21
  * @param val - Any object or value to hash with SHA256.
31
22
  */
32
- const getShortSha256 = (val) => __awaiter(void 0, void 0, void 0, function* () {
33
- const hash = yield (0, exports.hashValue)(val);
23
+ const getShortSha256 = async (val) => {
24
+ const hash = await (0, exports.hashValue)(val);
34
25
  return hash.slice(0, 7);
35
- });
26
+ };
36
27
  exports.getShortSha256 = getShortSha256;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,0BAGjC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,WAAwD,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAAI,uBAGrC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,WAAwD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["../../src/sha256.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,QAAe,OAAO,oBAY3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAe,OAAO,oBAGhD,CAAC"}
1
+ {"version":3,"file":"sha256.d.ts","sourceRoot":"","sources":["../../src/sha256.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAU,KAAK,OAAO,oBAY3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAU,KAAK,OAAO,oBAGhD,CAAC"}
@@ -1,31 +1,22 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  /**
11
2
  * Hashes the value with SHA256.
12
3
  *
13
4
  * @param val - Any object or value to hash with SHA256.
14
5
  * @returns
15
6
  */
16
- export const hashValue = (val) => __awaiter(void 0, void 0, void 0, function* () {
17
- const hash = yield crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify(val)));
7
+ export const hashValue = async (val) => {
8
+ const hash = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify(val)));
18
9
  const hexes = [], view = new DataView(hash);
19
10
  for (let i = 0; i < view.byteLength; i += 4)
20
11
  hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8));
21
12
  return hexes.join('');
22
- });
13
+ };
23
14
  /**
24
15
  * Returns the first 7 chars of hashed value. Sohuld be unique.
25
16
  *
26
17
  * @param val - Any object or value to hash with SHA256.
27
18
  */
28
- export const getShortSha256 = (val) => __awaiter(void 0, void 0, void 0, function* () {
29
- const hash = yield hashValue(val);
19
+ export const getShortSha256 = async (val) => {
20
+ const hash = await hashValue(val);
30
21
  return hash.slice(0, 7);
31
- });
22
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,0BAGjC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,WAAwD,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,GAAI,uBAGrC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,WAAwD,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@akinon/app-shared",
3
- "description": "Shared utilities and helper functions for app-shell and app-client packages.",
4
- "version": "1.0.1",
3
+ "version": "1.2.0",
5
4
  "private": false,
5
+ "description": "Shared utilities and helper functions for app-shell and app-client packages.",
6
6
  "type": "module",
7
7
  "main": "dist/esm/index.js",
8
8
  "module": "dist/esm/index.js",
@@ -15,7 +15,8 @@
15
15
  "copyfiles": "^2.4.1",
16
16
  "rimraf": "^5.0.5",
17
17
  "typescript": "*",
18
- "@akinon/typescript-config": "1.0.1"
18
+ "@akinon/typescript-config": "1.1.0",
19
+ "@akinon/vitest-config": "1.1.0"
19
20
  },
20
21
  "clean-package": "../../clean-package.config.json",
21
22
  "types": "dist/esm/index.d.ts",
@@ -29,10 +30,14 @@
29
30
  },
30
31
  "scripts": {
31
32
  "build": "pnpm run build:esm && pnpm run build:commonjs && pnpm run copy:files",
32
- "build:esm": "tsc --outDir dist/esm",
33
33
  "build:commonjs": "tsc --module commonjs --outDir dist/cjs",
34
- "copy:files": "copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/esm && copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/cjs",
34
+ "build:esm": "tsc --outDir dist/esm",
35
35
  "clean": "rimraf dist/",
36
+ "copy:files": "copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/esm && copyfiles -u 1 \"src/**/*.!(ts|tsx)\" dist/cjs",
37
+ "test": "vitest",
38
+ "test:coverage": "vitest run --coverage",
39
+ "test:run": "vitest run",
40
+ "test:ui": "vitest --ui",
36
41
  "typecheck": "tsc --noEmit"
37
42
  }
38
43
  }