@supabase/gotrue-js 2.46.1 → 2.47.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/dist/main/GoTrueClient.d.ts +19 -1
- package/dist/main/GoTrueClient.d.ts.map +1 -1
- package/dist/main/GoTrueClient.js +179 -103
- package/dist/main/GoTrueClient.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +0 -29
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +1 -117
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/locks.d.ts.map +1 -1
- package/dist/main/lib/locks.js +18 -58
- package/dist/main/lib/locks.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/module/GoTrueClient.d.ts +19 -1
- package/dist/module/GoTrueClient.d.ts.map +1 -1
- package/dist/module/GoTrueClient.js +180 -104
- package/dist/module/GoTrueClient.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +0 -29
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +0 -113
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/locks.d.ts.map +1 -1
- package/dist/module/lib/locks.js +18 -58
- package/dist/module/lib/locks.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/GoTrueClient.ts +235 -135
- package/src/lib/helpers.ts +0 -140
- package/src/lib/locks.ts +20 -73
- package/src/lib/version.ts +1 -1
package/src/lib/locks.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { supportsLocalStorage } from './helpers'
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @experimental
|
|
3
5
|
*/
|
|
@@ -7,6 +9,7 @@ export const internals = {
|
|
|
7
9
|
*/
|
|
8
10
|
debug: !!(
|
|
9
11
|
globalThis &&
|
|
12
|
+
supportsLocalStorage() &&
|
|
10
13
|
globalThis.localStorage &&
|
|
11
14
|
globalThis.localStorage.getItem('supabase.gotrue-js.locks.debug') === 'true'
|
|
12
15
|
),
|
|
@@ -56,106 +59,50 @@ export async function navigatorLock<R>(
|
|
|
56
59
|
console.log('@supabase/gotrue-js: navigatorLock: acquire lock', name, acquireTimeout)
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
let beginOperation: (() => void) | null = null
|
|
60
|
-
let rejectOperation: ((error: any) => void) | null = null
|
|
61
|
-
const beginOperationPromise = new Promise<void>((accept, reject) => {
|
|
62
|
-
beginOperation = accept
|
|
63
|
-
rejectOperation = reject
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
// this lets us preserve stack traces over the operation, which the
|
|
67
|
-
// navigator.locks.request function does not preserve well still
|
|
68
|
-
const result = (async () => {
|
|
69
|
-
await beginOperationPromise
|
|
70
|
-
|
|
71
|
-
if (internals.debug) {
|
|
72
|
-
console.log('@supabase/gotrue-js: navigatorLock: operation start')
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
return await fn()
|
|
77
|
-
} finally {
|
|
78
|
-
if (internals.debug) {
|
|
79
|
-
console.log('@supabase/gotrue-js: navigatorLock: operation end')
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
})()
|
|
83
|
-
|
|
84
62
|
const abortController = new globalThis.AbortController()
|
|
85
63
|
|
|
86
64
|
if (acquireTimeout > 0) {
|
|
87
65
|
setTimeout(() => {
|
|
88
|
-
beginOperation = null
|
|
89
66
|
abortController.abort()
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (internals.debug) {
|
|
93
|
-
console.log('@supabase/gotrue-js: navigatorLock acquire timed out', name)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (rejectOperation) {
|
|
97
|
-
rejectOperation(
|
|
98
|
-
new NavigatorLockAcquireTimeoutError(
|
|
99
|
-
`Acquiring an exclusive Navigator LockManager lock "${name}" timed out after ${acquireTimeout}ms`
|
|
100
|
-
)
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
beginOperation = null
|
|
104
|
-
rejectOperation = null
|
|
67
|
+
if (internals.debug) {
|
|
68
|
+
console.log('@supabase/gotrue-js: navigatorLock acquire timed out', name)
|
|
105
69
|
}
|
|
106
70
|
}, acquireTimeout)
|
|
107
71
|
}
|
|
108
72
|
|
|
109
|
-
await globalThis.navigator.locks.request(
|
|
73
|
+
return await globalThis.navigator.locks.request(
|
|
110
74
|
name,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
75
|
+
acquireTimeout === 0
|
|
76
|
+
? {
|
|
77
|
+
mode: 'exclusive',
|
|
78
|
+
ifAvailable: true,
|
|
79
|
+
}
|
|
80
|
+
: {
|
|
81
|
+
mode: 'exclusive',
|
|
82
|
+
signal: abortController.signal,
|
|
83
|
+
},
|
|
116
84
|
async (lock) => {
|
|
117
85
|
if (lock) {
|
|
118
86
|
if (internals.debug) {
|
|
119
|
-
console.log('@supabase/gotrue-js: navigatorLock acquired', name)
|
|
87
|
+
console.log('@supabase/gotrue-js: navigatorLock: acquired', name)
|
|
120
88
|
}
|
|
121
89
|
|
|
122
90
|
try {
|
|
123
|
-
|
|
124
|
-
beginOperation()
|
|
125
|
-
beginOperation = null
|
|
126
|
-
rejectOperation = null
|
|
127
|
-
await result
|
|
128
|
-
}
|
|
129
|
-
} catch (e: any) {
|
|
130
|
-
// not important to handle the error here
|
|
91
|
+
return await fn()
|
|
131
92
|
} finally {
|
|
132
93
|
if (internals.debug) {
|
|
133
|
-
console.log('@supabase/gotrue-js: navigatorLock released', name)
|
|
94
|
+
console.log('@supabase/gotrue-js: navigatorLock: released', name)
|
|
134
95
|
}
|
|
135
96
|
}
|
|
136
97
|
} else {
|
|
137
98
|
if (internals.debug) {
|
|
138
|
-
console.log('@supabase/gotrue-js: navigatorLock not immediately available', name)
|
|
99
|
+
console.log('@supabase/gotrue-js: navigatorLock: not immediately available', name)
|
|
139
100
|
}
|
|
140
101
|
|
|
141
|
-
|
|
142
|
-
const timeout: any = new Error(
|
|
102
|
+
throw new NavigatorLockAcquireTimeoutError(
|
|
143
103
|
`Acquiring an exclusive Navigator LockManager lock "${name}" immediately failed`
|
|
144
104
|
)
|
|
145
|
-
timeout.isAcquireTimeout = true
|
|
146
|
-
|
|
147
|
-
if (rejectOperation) {
|
|
148
|
-
rejectOperation(
|
|
149
|
-
new NavigatorLockAcquireTimeoutError(
|
|
150
|
-
`Acquiring an exclusive Navigator LockManager lock "${name}" immediately failed`
|
|
151
|
-
)
|
|
152
|
-
)
|
|
153
|
-
}
|
|
154
|
-
beginOperation = null
|
|
155
|
-
rejectOperation = null
|
|
156
105
|
}
|
|
157
106
|
}
|
|
158
107
|
)
|
|
159
|
-
|
|
160
|
-
return await result
|
|
161
108
|
}
|
package/src/lib/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '2.
|
|
2
|
+
export const version = '2.47.0'
|