@bundleup/react 0.0.2 → 0.0.4
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 +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +14 -16
- package/dist/index.mjs +15 -17
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AuthenticateWithPopupOptions } from '@bundleup/core/client';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
declare function useBundleup(options?: AuthenticateWithPopupOptions): {
|
|
4
|
+
connect: (token: string) => Promise<{
|
|
5
|
+
success: boolean;
|
|
6
|
+
data: Record<string, any>;
|
|
7
|
+
error?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
success: boolean;
|
|
10
|
+
error: Error;
|
|
11
|
+
data?: undefined;
|
|
12
|
+
} | undefined>;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export { useBundleup };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { AuthenticateWithPopupOptions } from '@bundleup/core/client';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
declare function useBundleup(options?: AuthenticateWithPopupOptions): {
|
|
4
|
+
connect: (token: string) => Promise<{
|
|
5
|
+
success: boolean;
|
|
6
|
+
data: Record<string, any>;
|
|
7
|
+
error?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
success: boolean;
|
|
10
|
+
error: Error;
|
|
11
|
+
data?: undefined;
|
|
12
|
+
} | undefined>;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export { useBundleup };
|
package/dist/index.js
CHANGED
|
@@ -26,32 +26,30 @@ module.exports = __toCommonJS(src_exports);
|
|
|
26
26
|
var import_react = require("react");
|
|
27
27
|
var import_client = require("@bundleup/core/client");
|
|
28
28
|
var import_utils = require("@bundleup/core/utils");
|
|
29
|
-
function useBundleup(
|
|
30
|
-
const [options, setOptions] = (0, import_react.useState)(opts);
|
|
31
|
-
(0, import_react.useEffect)(() => {
|
|
32
|
-
setOptions(opts);
|
|
33
|
-
}, [opts]);
|
|
29
|
+
function useBundleup(options = {}) {
|
|
34
30
|
const log = (0, import_react.useCallback)(
|
|
35
31
|
(msg, ...args) => (0, import_utils.logger)(!!options.debug)(msg, ...args),
|
|
36
32
|
[options.debug]
|
|
37
33
|
);
|
|
38
|
-
const
|
|
39
|
-
(token) => {
|
|
34
|
+
const connect = (0, import_react.useCallback)(
|
|
35
|
+
async (token) => {
|
|
40
36
|
if (!token) {
|
|
41
37
|
log("No token provided, skipping BundleUp authentication.");
|
|
42
38
|
return;
|
|
43
39
|
}
|
|
44
|
-
|
|
45
|
-
log("BundleUp authentication
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
try {
|
|
41
|
+
log("Starting BundleUp authentication with token:", token);
|
|
42
|
+
const result = await (0, import_client.authenticateWithPopup)(token, options);
|
|
43
|
+
log("BundleUp authentication successful:", result);
|
|
44
|
+
return { success: true, data: result };
|
|
45
|
+
} catch (error) {
|
|
46
|
+
log("Error occurred while starting authentication:", error);
|
|
47
|
+
return { success: false, error };
|
|
48
|
+
}
|
|
51
49
|
},
|
|
52
|
-
[options,
|
|
50
|
+
[options, log]
|
|
53
51
|
);
|
|
54
|
-
return {
|
|
52
|
+
return { connect };
|
|
55
53
|
}
|
|
56
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
57
55
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { useCallback
|
|
2
|
+
import { useCallback } from "react";
|
|
3
3
|
import {
|
|
4
4
|
authenticateWithPopup
|
|
5
5
|
} from "@bundleup/core/client";
|
|
6
6
|
import { logger } from "@bundleup/core/utils";
|
|
7
|
-
function useBundleup(
|
|
8
|
-
const [options, setOptions] = useState(opts);
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
setOptions(opts);
|
|
11
|
-
}, [opts]);
|
|
7
|
+
function useBundleup(options = {}) {
|
|
12
8
|
const log = useCallback(
|
|
13
9
|
(msg, ...args) => logger(!!options.debug)(msg, ...args),
|
|
14
10
|
[options.debug]
|
|
15
11
|
);
|
|
16
|
-
const
|
|
17
|
-
(token) => {
|
|
12
|
+
const connect = useCallback(
|
|
13
|
+
async (token) => {
|
|
18
14
|
if (!token) {
|
|
19
15
|
log("No token provided, skipping BundleUp authentication.");
|
|
20
16
|
return;
|
|
21
17
|
}
|
|
22
|
-
|
|
23
|
-
log("BundleUp authentication
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
try {
|
|
19
|
+
log("Starting BundleUp authentication with token:", token);
|
|
20
|
+
const result = await authenticateWithPopup(token, options);
|
|
21
|
+
log("BundleUp authentication successful:", result);
|
|
22
|
+
return { success: true, data: result };
|
|
23
|
+
} catch (error) {
|
|
24
|
+
log("Error occurred while starting authentication:", error);
|
|
25
|
+
return { success: false, error };
|
|
26
|
+
}
|
|
29
27
|
},
|
|
30
|
-
[options,
|
|
28
|
+
[options, log]
|
|
31
29
|
);
|
|
32
|
-
return {
|
|
30
|
+
return { connect };
|
|
33
31
|
}
|
|
34
32
|
export {
|
|
35
33
|
useBundleup
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bundleup/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "BundleUp plugin for React applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"clean": "rm -rf dist"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@bundleup/core": "0.0.
|
|
23
|
+
"@bundleup/core": "0.0.3"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": ">=16.8.0"
|