@nocios/crudify-ui 1.0.65 → 1.0.67
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.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.js +72 -26
- package/dist/index.mjs +72 -26
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -55,9 +55,7 @@ interface UseCrudifyLoginOptions {
|
|
|
55
55
|
declare const useCrudifyLogin: (config: CrudifyLoginConfig, _options?: UseCrudifyLoginOptions) => {
|
|
56
56
|
crudify: {
|
|
57
57
|
login: (identifier: string, password: string) => Promise<_nocios_crudify_browser.CrudifyResponse>;
|
|
58
|
-
transaction: (data: any, options?:
|
|
59
|
-
signal?: AbortSignal;
|
|
60
|
-
}) => Promise<_nocios_crudify_browser.CrudifyResponse>;
|
|
58
|
+
transaction: (data: any, options?: any) => Promise<_nocios_crudify_browser.CrudifyResponse>;
|
|
61
59
|
} | null;
|
|
62
60
|
};
|
|
63
61
|
|
package/dist/index.d.ts
CHANGED
|
@@ -55,9 +55,7 @@ interface UseCrudifyLoginOptions {
|
|
|
55
55
|
declare const useCrudifyLogin: (config: CrudifyLoginConfig, _options?: UseCrudifyLoginOptions) => {
|
|
56
56
|
crudify: {
|
|
57
57
|
login: (identifier: string, password: string) => Promise<_nocios_crudify_browser.CrudifyResponse>;
|
|
58
|
-
transaction: (data: any, options?:
|
|
59
|
-
signal?: AbortSignal;
|
|
60
|
-
}) => Promise<_nocios_crudify_browser.CrudifyResponse>;
|
|
58
|
+
transaction: (data: any, options?: any) => Promise<_nocios_crudify_browser.CrudifyResponse>;
|
|
61
59
|
} | null;
|
|
62
60
|
};
|
|
63
61
|
|
package/dist/index.js
CHANGED
|
@@ -1117,6 +1117,10 @@ var getCookie = (name) => {
|
|
|
1117
1117
|
};
|
|
1118
1118
|
|
|
1119
1119
|
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1120
|
+
var globalInitPromise = null;
|
|
1121
|
+
var isGloballyInitialized = false;
|
|
1122
|
+
var lastApiKey = "";
|
|
1123
|
+
var lastEnv = "";
|
|
1120
1124
|
var useCrudifyLogin = (config, _options = {}) => {
|
|
1121
1125
|
const [isInitialized, setIsInitialized] = (0, import_react7.useState)(false);
|
|
1122
1126
|
const finalConfig = (0, import_react7.useMemo)(() => {
|
|
@@ -1143,37 +1147,70 @@ var useCrudifyLogin = (config, _options = {}) => {
|
|
|
1143
1147
|
console.log("\u{1F527} useCrudifyLogin useEffect triggered:", {
|
|
1144
1148
|
publicApiKey: !!finalConfig.publicApiKey,
|
|
1145
1149
|
env: finalConfig.env,
|
|
1146
|
-
hasPublicApiKey: !!finalConfig.publicApiKey
|
|
1150
|
+
hasPublicApiKey: !!finalConfig.publicApiKey,
|
|
1151
|
+
isGloballyInitialized,
|
|
1152
|
+
lastApiKey: lastApiKey ? lastApiKey.substring(0, 10) + "..." : "none",
|
|
1153
|
+
lastEnv
|
|
1147
1154
|
});
|
|
1148
1155
|
if (!finalConfig.publicApiKey) {
|
|
1149
1156
|
console.log("\u274C No publicApiKey, skipping crudify initialization");
|
|
1150
1157
|
setIsInitialized(false);
|
|
1151
1158
|
return;
|
|
1152
1159
|
}
|
|
1160
|
+
const currentApiKey = finalConfig.publicApiKey;
|
|
1161
|
+
const currentEnv = finalConfig.env;
|
|
1162
|
+
if (isGloballyInitialized && lastApiKey === currentApiKey && lastEnv === currentEnv) {
|
|
1163
|
+
console.log("\u2705 Crudify already initialized with same config, reusing");
|
|
1164
|
+
setIsInitialized(true);
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1153
1167
|
const initializeCrudify = async () => {
|
|
1154
|
-
|
|
1155
|
-
console.log("\
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
console.log("\u2705 Crudify initialization verified and ready");
|
|
1163
|
-
setIsInitialized(true);
|
|
1164
|
-
} else {
|
|
1165
|
-
console.log("\u274C Crudify methods not properly initialized");
|
|
1166
|
-
setIsInitialized(false);
|
|
1168
|
+
if (globalInitPromise) {
|
|
1169
|
+
console.log("\u23F3 Waiting for existing initialization to complete");
|
|
1170
|
+
try {
|
|
1171
|
+
await globalInitPromise;
|
|
1172
|
+
setIsInitialized(isGloballyInitialized);
|
|
1173
|
+
return;
|
|
1174
|
+
} catch (error) {
|
|
1175
|
+
console.error("\u274C Previous initialization failed:", error);
|
|
1167
1176
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1177
|
+
}
|
|
1178
|
+
globalInitPromise = (async () => {
|
|
1179
|
+
try {
|
|
1180
|
+
console.log("\u2699\uFE0F Configuring crudify with env:", currentEnv);
|
|
1181
|
+
import_crudify_browser.default.config(currentEnv);
|
|
1182
|
+
console.log("\u{1F680} Initializing crudify with publicApiKey:", currentApiKey.substring(0, 10) + "...");
|
|
1183
|
+
await import_crudify_browser.default.init(currentApiKey, "none");
|
|
1184
|
+
console.log("\u{1F9EA} Testing crudify initialization...");
|
|
1185
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
1186
|
+
if (typeof import_crudify_browser.default.transaction === "function" && typeof import_crudify_browser.default.login === "function") {
|
|
1187
|
+
console.log("\u2705 Crudify initialization verified and ready");
|
|
1188
|
+
isGloballyInitialized = true;
|
|
1189
|
+
lastApiKey = currentApiKey;
|
|
1190
|
+
lastEnv = currentEnv;
|
|
1191
|
+
} else {
|
|
1192
|
+
console.log("\u274C Crudify methods not properly initialized");
|
|
1193
|
+
isGloballyInitialized = false;
|
|
1194
|
+
}
|
|
1195
|
+
console.log("\u{1F50D} Crudify state after init:", {
|
|
1196
|
+
hasTransaction: typeof import_crudify_browser.default.transaction === "function",
|
|
1197
|
+
hasLogin: typeof import_crudify_browser.default.login === "function",
|
|
1198
|
+
isGloballyInitialized,
|
|
1199
|
+
crudifyObject: import_crudify_browser.default
|
|
1200
|
+
});
|
|
1201
|
+
} catch (error) {
|
|
1202
|
+
console.error("\u274C Error initializing crudify:", error);
|
|
1203
|
+
isGloballyInitialized = false;
|
|
1204
|
+
throw error;
|
|
1205
|
+
}
|
|
1206
|
+
})();
|
|
1207
|
+
try {
|
|
1208
|
+
await globalInitPromise;
|
|
1209
|
+
setIsInitialized(isGloballyInitialized);
|
|
1174
1210
|
} catch (error) {
|
|
1175
|
-
console.error("\u274C Error initializing crudify:", error);
|
|
1176
1211
|
setIsInitialized(false);
|
|
1212
|
+
} finally {
|
|
1213
|
+
globalInitPromise = null;
|
|
1177
1214
|
}
|
|
1178
1215
|
};
|
|
1179
1216
|
initializeCrudify();
|
|
@@ -1182,28 +1219,37 @@ var useCrudifyLogin = (config, _options = {}) => {
|
|
|
1182
1219
|
console.log("\u{1F504} crudifyMethods useMemo triggered:", {
|
|
1183
1220
|
publicApiKey: !!finalConfig.publicApiKey,
|
|
1184
1221
|
isInitialized,
|
|
1222
|
+
isGloballyInitialized,
|
|
1185
1223
|
crudifyLogin: typeof import_crudify_browser.default.login,
|
|
1186
1224
|
crudifyTransaction: typeof import_crudify_browser.default.transaction
|
|
1187
1225
|
});
|
|
1188
|
-
if (!finalConfig.publicApiKey || !isInitialized) {
|
|
1226
|
+
if (!finalConfig.publicApiKey || !isInitialized || !isGloballyInitialized) {
|
|
1189
1227
|
console.log("\u274C Crudify not ready:", {
|
|
1190
1228
|
publicApiKey: !!finalConfig.publicApiKey,
|
|
1191
|
-
isInitialized
|
|
1229
|
+
isInitialized,
|
|
1230
|
+
isGloballyInitialized
|
|
1192
1231
|
});
|
|
1193
1232
|
return null;
|
|
1194
1233
|
}
|
|
1195
1234
|
const methods = {
|
|
1196
|
-
login:
|
|
1197
|
-
|
|
1235
|
+
login: async (identifier, password) => {
|
|
1236
|
+
console.log("\u{1F517} Wrapper login called, isGloballyInitialized:", isGloballyInitialized);
|
|
1237
|
+
return await import_crudify_browser.default.login(identifier, password);
|
|
1238
|
+
},
|
|
1239
|
+
transaction: async (data, options) => {
|
|
1240
|
+
console.log("\u{1F517} Wrapper transaction called, isGloballyInitialized:", isGloballyInitialized);
|
|
1241
|
+
return await import_crudify_browser.default.transaction(data, options);
|
|
1242
|
+
}
|
|
1198
1243
|
};
|
|
1199
1244
|
console.log("\u2705 Returning ready crudifyMethods:", {
|
|
1200
1245
|
hasLogin: typeof methods.login === "function",
|
|
1201
1246
|
hasTransaction: typeof methods.transaction === "function",
|
|
1202
1247
|
isInitialized,
|
|
1248
|
+
isGloballyInitialized,
|
|
1203
1249
|
methods
|
|
1204
1250
|
});
|
|
1205
1251
|
return methods;
|
|
1206
|
-
}, [finalConfig.publicApiKey, isInitialized]);
|
|
1252
|
+
}, [finalConfig.publicApiKey, isInitialized, isGloballyInitialized]);
|
|
1207
1253
|
return { crudify: crudifyMethods };
|
|
1208
1254
|
};
|
|
1209
1255
|
|
package/dist/index.mjs
CHANGED
|
@@ -1073,6 +1073,10 @@ var getCookie = (name) => {
|
|
|
1073
1073
|
};
|
|
1074
1074
|
|
|
1075
1075
|
// src/components/CrudifyLogin/hooks/useCrudifyLogin.ts
|
|
1076
|
+
var globalInitPromise = null;
|
|
1077
|
+
var isGloballyInitialized = false;
|
|
1078
|
+
var lastApiKey = "";
|
|
1079
|
+
var lastEnv = "";
|
|
1076
1080
|
var useCrudifyLogin = (config, _options = {}) => {
|
|
1077
1081
|
const [isInitialized, setIsInitialized] = useState6(false);
|
|
1078
1082
|
const finalConfig = useMemo2(() => {
|
|
@@ -1099,37 +1103,70 @@ var useCrudifyLogin = (config, _options = {}) => {
|
|
|
1099
1103
|
console.log("\u{1F527} useCrudifyLogin useEffect triggered:", {
|
|
1100
1104
|
publicApiKey: !!finalConfig.publicApiKey,
|
|
1101
1105
|
env: finalConfig.env,
|
|
1102
|
-
hasPublicApiKey: !!finalConfig.publicApiKey
|
|
1106
|
+
hasPublicApiKey: !!finalConfig.publicApiKey,
|
|
1107
|
+
isGloballyInitialized,
|
|
1108
|
+
lastApiKey: lastApiKey ? lastApiKey.substring(0, 10) + "..." : "none",
|
|
1109
|
+
lastEnv
|
|
1103
1110
|
});
|
|
1104
1111
|
if (!finalConfig.publicApiKey) {
|
|
1105
1112
|
console.log("\u274C No publicApiKey, skipping crudify initialization");
|
|
1106
1113
|
setIsInitialized(false);
|
|
1107
1114
|
return;
|
|
1108
1115
|
}
|
|
1116
|
+
const currentApiKey = finalConfig.publicApiKey;
|
|
1117
|
+
const currentEnv = finalConfig.env;
|
|
1118
|
+
if (isGloballyInitialized && lastApiKey === currentApiKey && lastEnv === currentEnv) {
|
|
1119
|
+
console.log("\u2705 Crudify already initialized with same config, reusing");
|
|
1120
|
+
setIsInitialized(true);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1109
1123
|
const initializeCrudify = async () => {
|
|
1110
|
-
|
|
1111
|
-
console.log("\
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
console.log("\u2705 Crudify initialization verified and ready");
|
|
1119
|
-
setIsInitialized(true);
|
|
1120
|
-
} else {
|
|
1121
|
-
console.log("\u274C Crudify methods not properly initialized");
|
|
1122
|
-
setIsInitialized(false);
|
|
1124
|
+
if (globalInitPromise) {
|
|
1125
|
+
console.log("\u23F3 Waiting for existing initialization to complete");
|
|
1126
|
+
try {
|
|
1127
|
+
await globalInitPromise;
|
|
1128
|
+
setIsInitialized(isGloballyInitialized);
|
|
1129
|
+
return;
|
|
1130
|
+
} catch (error) {
|
|
1131
|
+
console.error("\u274C Previous initialization failed:", error);
|
|
1123
1132
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1133
|
+
}
|
|
1134
|
+
globalInitPromise = (async () => {
|
|
1135
|
+
try {
|
|
1136
|
+
console.log("\u2699\uFE0F Configuring crudify with env:", currentEnv);
|
|
1137
|
+
crudify.config(currentEnv);
|
|
1138
|
+
console.log("\u{1F680} Initializing crudify with publicApiKey:", currentApiKey.substring(0, 10) + "...");
|
|
1139
|
+
await crudify.init(currentApiKey, "none");
|
|
1140
|
+
console.log("\u{1F9EA} Testing crudify initialization...");
|
|
1141
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
1142
|
+
if (typeof crudify.transaction === "function" && typeof crudify.login === "function") {
|
|
1143
|
+
console.log("\u2705 Crudify initialization verified and ready");
|
|
1144
|
+
isGloballyInitialized = true;
|
|
1145
|
+
lastApiKey = currentApiKey;
|
|
1146
|
+
lastEnv = currentEnv;
|
|
1147
|
+
} else {
|
|
1148
|
+
console.log("\u274C Crudify methods not properly initialized");
|
|
1149
|
+
isGloballyInitialized = false;
|
|
1150
|
+
}
|
|
1151
|
+
console.log("\u{1F50D} Crudify state after init:", {
|
|
1152
|
+
hasTransaction: typeof crudify.transaction === "function",
|
|
1153
|
+
hasLogin: typeof crudify.login === "function",
|
|
1154
|
+
isGloballyInitialized,
|
|
1155
|
+
crudifyObject: crudify
|
|
1156
|
+
});
|
|
1157
|
+
} catch (error) {
|
|
1158
|
+
console.error("\u274C Error initializing crudify:", error);
|
|
1159
|
+
isGloballyInitialized = false;
|
|
1160
|
+
throw error;
|
|
1161
|
+
}
|
|
1162
|
+
})();
|
|
1163
|
+
try {
|
|
1164
|
+
await globalInitPromise;
|
|
1165
|
+
setIsInitialized(isGloballyInitialized);
|
|
1130
1166
|
} catch (error) {
|
|
1131
|
-
console.error("\u274C Error initializing crudify:", error);
|
|
1132
1167
|
setIsInitialized(false);
|
|
1168
|
+
} finally {
|
|
1169
|
+
globalInitPromise = null;
|
|
1133
1170
|
}
|
|
1134
1171
|
};
|
|
1135
1172
|
initializeCrudify();
|
|
@@ -1138,28 +1175,37 @@ var useCrudifyLogin = (config, _options = {}) => {
|
|
|
1138
1175
|
console.log("\u{1F504} crudifyMethods useMemo triggered:", {
|
|
1139
1176
|
publicApiKey: !!finalConfig.publicApiKey,
|
|
1140
1177
|
isInitialized,
|
|
1178
|
+
isGloballyInitialized,
|
|
1141
1179
|
crudifyLogin: typeof crudify.login,
|
|
1142
1180
|
crudifyTransaction: typeof crudify.transaction
|
|
1143
1181
|
});
|
|
1144
|
-
if (!finalConfig.publicApiKey || !isInitialized) {
|
|
1182
|
+
if (!finalConfig.publicApiKey || !isInitialized || !isGloballyInitialized) {
|
|
1145
1183
|
console.log("\u274C Crudify not ready:", {
|
|
1146
1184
|
publicApiKey: !!finalConfig.publicApiKey,
|
|
1147
|
-
isInitialized
|
|
1185
|
+
isInitialized,
|
|
1186
|
+
isGloballyInitialized
|
|
1148
1187
|
});
|
|
1149
1188
|
return null;
|
|
1150
1189
|
}
|
|
1151
1190
|
const methods = {
|
|
1152
|
-
login:
|
|
1153
|
-
|
|
1191
|
+
login: async (identifier, password) => {
|
|
1192
|
+
console.log("\u{1F517} Wrapper login called, isGloballyInitialized:", isGloballyInitialized);
|
|
1193
|
+
return await crudify.login(identifier, password);
|
|
1194
|
+
},
|
|
1195
|
+
transaction: async (data, options) => {
|
|
1196
|
+
console.log("\u{1F517} Wrapper transaction called, isGloballyInitialized:", isGloballyInitialized);
|
|
1197
|
+
return await crudify.transaction(data, options);
|
|
1198
|
+
}
|
|
1154
1199
|
};
|
|
1155
1200
|
console.log("\u2705 Returning ready crudifyMethods:", {
|
|
1156
1201
|
hasLogin: typeof methods.login === "function",
|
|
1157
1202
|
hasTransaction: typeof methods.transaction === "function",
|
|
1158
1203
|
isInitialized,
|
|
1204
|
+
isGloballyInitialized,
|
|
1159
1205
|
methods
|
|
1160
1206
|
});
|
|
1161
1207
|
return methods;
|
|
1162
|
-
}, [finalConfig.publicApiKey, isInitialized]);
|
|
1208
|
+
}, [finalConfig.publicApiKey, isInitialized, isGloballyInitialized]);
|
|
1163
1209
|
return { crudify: crudifyMethods };
|
|
1164
1210
|
};
|
|
1165
1211
|
|