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