@hangtime/grip-connect 0.8.2 → 0.8.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.
package/README.md CHANGED
@@ -178,6 +178,8 @@ A special thank you to:
178
178
  [simulator](https://github.com/1-max-1/fake_kilter_board) that I coverted to
179
179
  [hangtime-arduino-kilterboard](https://github.com/Stevie-Ray/hangtime-arduino-kilterboard).
180
180
  - [@sebws](https://github.com/sebws) for a [code sample](https://github.com/sebws/Crane) of the Weiheng WH-C06 App.
181
+ - [@olrut](https://github.com/olrut) for the React Native / Expo [CraneGrip](https://github.com/olrut/CraneGrip) example
182
+ App.
181
183
 
182
184
  ## Disclaimer
183
185
 
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hangtime/grip-connect",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "license": "BSD-2-Clause",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
@@ -4,5 +4,10 @@ export declare abstract class BaseModel {
4
4
  createdAt?: Date;
5
5
  updatedAt?: Date;
6
6
  constructor(base: IBase);
7
+ /**
8
+ * Generates a UUID using a simple algorithm.
9
+ * @returns A string representing a UUID.
10
+ */
11
+ private static generateUUID;
7
12
  }
8
13
  //# sourceMappingURL=base.model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.model.d.ts","sourceRoot":"","sources":["../../src/models/base.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAE5D,8BAAsB,SAAS;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAA;IAEX,SAAS,CAAC,EAAE,IAAI,CAAA;IAEhB,SAAS,CAAC,EAAE,IAAI,CAAA;gBAEJ,IAAI,EAAE,KAAK;CAMxB"}
1
+ {"version":3,"file":"base.model.d.ts","sourceRoot":"","sources":["../../src/models/base.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAA;AAE5D,8BAAsB,SAAS;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,SAAS,CAAC,EAAE,IAAI,CAAA;gBAEJ,IAAI,EAAE,KAAK;IAOvB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;CAO5B"}
@@ -3,9 +3,20 @@ export class BaseModel {
3
3
  createdAt;
4
4
  updatedAt;
5
5
  constructor(base) {
6
- this.id = base.id ?? globalThis.crypto?.randomUUID();
6
+ this.id = base.id ?? globalThis.crypto?.randomUUID?.() ?? BaseModel.generateUUID();
7
7
  this.createdAt = base.createdAt;
8
8
  this.updatedAt = base.updatedAt;
9
9
  }
10
+ /**
11
+ * Generates a UUID using a simple algorithm.
12
+ * @returns A string representing a UUID.
13
+ */
14
+ static generateUUID() {
15
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
16
+ const r = Math.floor(Math.random() * 16);
17
+ const v = c === "x" ? r : (r & 0x3) | 0x8;
18
+ return v.toString(16);
19
+ });
20
+ }
10
21
  }
11
22
  //# sourceMappingURL=base.model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base.model.js","sourceRoot":"","sources":["../../src/models/base.model.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,SAAS;IAC7B,EAAE,CAAS;IAEX,SAAS,CAAO;IAEhB,SAAS,CAAO;IAEhB,YAAY,IAAW;QACrB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,CAAA;QAEpD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;IACjC,CAAC;CACF"}
1
+ {"version":3,"file":"base.model.js","sourceRoot":"","sources":["../../src/models/base.model.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,SAAS;IAC7B,EAAE,CAAS;IACX,SAAS,CAAO;IAChB,SAAS,CAAO;IAEhB,YAAY,IAAW;QACrB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,SAAS,CAAC,YAAY,EAAE,CAAA;QAElF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;QAC/B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAA;IACjC,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,YAAY;QACzB,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACnE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;YACxC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;YACzC,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QACvB,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hangtime/grip-connect",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "Griptonite Motherboard, Tindeq Progressor, PitchSix Force Board, WHC-06, Entralpi, Climbro, mySmartBoard: Bluetooth API Force-Sensing strength analysis for climbers",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -2,15 +2,25 @@ import type { IBase } from "../interfaces/base.interface.js"
2
2
 
3
3
  export abstract class BaseModel {
4
4
  id?: string
5
-
6
5
  createdAt?: Date
7
-
8
6
  updatedAt?: Date
9
7
 
10
8
  constructor(base: IBase) {
11
- this.id = base.id ?? globalThis.crypto?.randomUUID()
9
+ this.id = base.id ?? globalThis.crypto?.randomUUID?.() ?? BaseModel.generateUUID()
12
10
 
13
11
  this.createdAt = base.createdAt
14
12
  this.updatedAt = base.updatedAt
15
13
  }
14
+
15
+ /**
16
+ * Generates a UUID using a simple algorithm.
17
+ * @returns A string representing a UUID.
18
+ */
19
+ private static generateUUID(): string {
20
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
21
+ const r = Math.floor(Math.random() * 16)
22
+ const v = c === "x" ? r : (r & 0x3) | 0x8
23
+ return v.toString(16)
24
+ })
25
+ }
16
26
  }