@linabase/js 0.4.0 → 0.4.1
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/index.cjs +8 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -694,6 +694,8 @@ var BucketClient = class {
|
|
|
694
694
|
var AuthClient = class {
|
|
695
695
|
request;
|
|
696
696
|
listeners = [];
|
|
697
|
+
/** Promise that resolves when session restore from storage is complete. */
|
|
698
|
+
_restorePromise = Promise.resolve();
|
|
697
699
|
currentSession = null;
|
|
698
700
|
/**
|
|
699
701
|
* Callback that the parent LinabaseClient can set to update the Authorization
|
|
@@ -1064,6 +1066,11 @@ var AuthClient = class {
|
|
|
1064
1066
|
// ─── Auth State Listener ───────────────────────────────────
|
|
1065
1067
|
onAuthStateChange(callback) {
|
|
1066
1068
|
this.listeners.push(callback);
|
|
1069
|
+
this._restorePromise.then(() => {
|
|
1070
|
+
if (this.listeners.includes(callback)) {
|
|
1071
|
+
callback("INITIAL_SESSION", this.currentSession);
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1067
1074
|
return {
|
|
1068
1075
|
unsubscribe: () => {
|
|
1069
1076
|
this.listeners = this.listeners.filter((l) => l !== callback);
|
|
@@ -1161,7 +1168,7 @@ function createClient(config) {
|
|
|
1161
1168
|
sessionStorage.removeItem(sessionKey);
|
|
1162
1169
|
}
|
|
1163
1170
|
});
|
|
1164
|
-
Promise.resolve(sessionStorage.getItem(sessionKey)).then((raw) => {
|
|
1171
|
+
authClient._restorePromise = Promise.resolve(sessionStorage.getItem(sessionKey)).then((raw) => {
|
|
1165
1172
|
if (raw) {
|
|
1166
1173
|
try {
|
|
1167
1174
|
authClient.setSession(JSON.parse(raw));
|
package/dist/index.d.cts
CHANGED
|
@@ -266,6 +266,8 @@ interface AuthUser {
|
|
|
266
266
|
declare class AuthClient {
|
|
267
267
|
private request;
|
|
268
268
|
private listeners;
|
|
269
|
+
/** Promise that resolves when session restore from storage is complete. */
|
|
270
|
+
_restorePromise: Promise<void>;
|
|
269
271
|
private currentSession;
|
|
270
272
|
/**
|
|
271
273
|
* Callback that the parent LinabaseClient can set to update the Authorization
|
package/dist/index.d.ts
CHANGED
|
@@ -266,6 +266,8 @@ interface AuthUser {
|
|
|
266
266
|
declare class AuthClient {
|
|
267
267
|
private request;
|
|
268
268
|
private listeners;
|
|
269
|
+
/** Promise that resolves when session restore from storage is complete. */
|
|
270
|
+
_restorePromise: Promise<void>;
|
|
269
271
|
private currentSession;
|
|
270
272
|
/**
|
|
271
273
|
* Callback that the parent LinabaseClient can set to update the Authorization
|
package/dist/index.js
CHANGED
|
@@ -662,6 +662,8 @@ var BucketClient = class {
|
|
|
662
662
|
var AuthClient = class {
|
|
663
663
|
request;
|
|
664
664
|
listeners = [];
|
|
665
|
+
/** Promise that resolves when session restore from storage is complete. */
|
|
666
|
+
_restorePromise = Promise.resolve();
|
|
665
667
|
currentSession = null;
|
|
666
668
|
/**
|
|
667
669
|
* Callback that the parent LinabaseClient can set to update the Authorization
|
|
@@ -1032,6 +1034,11 @@ var AuthClient = class {
|
|
|
1032
1034
|
// ─── Auth State Listener ───────────────────────────────────
|
|
1033
1035
|
onAuthStateChange(callback) {
|
|
1034
1036
|
this.listeners.push(callback);
|
|
1037
|
+
this._restorePromise.then(() => {
|
|
1038
|
+
if (this.listeners.includes(callback)) {
|
|
1039
|
+
callback("INITIAL_SESSION", this.currentSession);
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1035
1042
|
return {
|
|
1036
1043
|
unsubscribe: () => {
|
|
1037
1044
|
this.listeners = this.listeners.filter((l) => l !== callback);
|
|
@@ -1129,7 +1136,7 @@ function createClient(config) {
|
|
|
1129
1136
|
sessionStorage.removeItem(sessionKey);
|
|
1130
1137
|
}
|
|
1131
1138
|
});
|
|
1132
|
-
Promise.resolve(sessionStorage.getItem(sessionKey)).then((raw) => {
|
|
1139
|
+
authClient._restorePromise = Promise.resolve(sessionStorage.getItem(sessionKey)).then((raw) => {
|
|
1133
1140
|
if (raw) {
|
|
1134
1141
|
try {
|
|
1135
1142
|
authClient.setSession(JSON.parse(raw));
|