@d-mok/quasar-app-extension-quasar-axe 2.1.32 → 2.1.33

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-mok/quasar-app-extension-quasar-axe",
3
- "version": "2.1.32",
3
+ "version": "2.1.33",
4
4
  "description": "A Quasar App Extension",
5
5
  "author": "d-mok <49301824+d-mok@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -0,0 +1,73 @@
1
+ export function extendConsole(
2
+ key: keyof Console & string,
3
+ value: (this: Console, ...args: any[]) => any
4
+ ) {
5
+ if (console[key as keyof Console] !== undefined) {
6
+ throw '[sapphire] Extend Native Console Fail: ' + key
7
+ }
8
+ Object.defineProperty(console, key, { value })
9
+ }
10
+
11
+ function dev(this: any, ...msg: any[]) {
12
+ if (process.env.DEBUGGING) console.log(...msg)
13
+ }
14
+ extendConsole('dev', dev)
15
+
16
+ declare global {
17
+ interface Console {
18
+ dev: typeof dev
19
+ }
20
+ }
21
+
22
+ /**
23
+ * ========== UUID ==========
24
+ */
25
+
26
+ export function extendMath(
27
+ key: keyof Math & string,
28
+ value: (this: Math, ...args: any[]) => any
29
+ ) {
30
+ if (Math[key as keyof Math] !== undefined) {
31
+ throw '[sapphire] Extend Native Math Fail: ' + key
32
+ }
33
+ Object.defineProperty(Math, key, { value })
34
+ }
35
+
36
+ function uuid(): string {
37
+ var d = Date.now()
38
+ if (
39
+ typeof performance !== 'undefined' &&
40
+ typeof performance.now === 'function'
41
+ ) {
42
+ d += performance.now() //use high-precision timer if available
43
+ }
44
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(
45
+ /[xy]/g,
46
+ function (c) {
47
+ var r = (d + Math.random() * 16) % 16 | 0
48
+ d = Math.floor(d / 16)
49
+ return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16)
50
+ }
51
+ )
52
+ }
53
+
54
+ function hash(input: any, maxInt: number): number {
55
+ let s = JSON.stringify(input)
56
+ let hash = 0
57
+ for (let i = 0; i < s.length; i++) {
58
+ let chr = s.charCodeAt(i)
59
+ hash = (hash << 5) - hash + chr
60
+ hash |= 0 // Convert to 32bit integer
61
+ }
62
+ return hash % maxInt
63
+ }
64
+
65
+ extendMath('uuid', uuid)
66
+ extendMath('hash', hash)
67
+
68
+ declare global {
69
+ interface Math {
70
+ uuid: typeof uuid
71
+ hash: typeof hash
72
+ }
73
+ }
@@ -39,7 +39,7 @@ export async function read<T>(
39
39
  export async function insertRow(
40
40
  id: string,
41
41
  sheet: string,
42
- row: object
42
+ row: Record<string, string | number | boolean>
43
43
  ): Promise<void> {
44
44
  const data = await fetchAPI(id, sheet, 'insert', row)
45
45
  if (data !== true) throw new Error('[gSheet] insert failed')
@@ -49,7 +49,7 @@ export async function deleteRow(
49
49
  id: string,
50
50
  sheet: string,
51
51
  field: string,
52
- value: any
52
+ value: string | number | boolean
53
53
  ): Promise<void> {
54
54
  const data = await fetchAPI(id, sheet, 'delete', { field, value })
55
55
  if (data !== true) throw new Error('[gSheet] delete failed')
@@ -1,5 +1,5 @@
1
1
  import 'sapphire-js'
2
- import './console'
2
+ import './extension'
3
3
 
4
4
  export { qDialog } from './dialog'
5
5
  export * as qNotify from './notify'
@@ -1,20 +0,0 @@
1
- export function extendConsole(
2
- key: keyof Console & string,
3
- value: (this: Console, ...args: any[]) => any
4
- ) {
5
- if (console[key as keyof Console] !== undefined) {
6
- throw '[sapphire] Extend Native Console Fail: ' + key
7
- }
8
- Object.defineProperty(console, key, { value })
9
- }
10
-
11
- function dev(this: any, ...msg: any[]) {
12
- if (process.env.DEBUGGING) console.log(...msg)
13
- }
14
- extendConsole('dev', dev)
15
-
16
- declare global {
17
- interface Console {
18
- dev: typeof dev
19
- }
20
- }