@bundleup/core 0.0.2
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/README.md +4 -0
- package/dist/chunk-B6T6V2FR.mjs +24 -0
- package/dist/chunk-GKEHPYLJ.mjs +17 -0
- package/dist/chunk-U6VVRHFA.mjs +17 -0
- package/dist/client.d.mts +8 -0
- package/dist/client.d.ts +8 -0
- package/dist/client.js +118 -0
- package/dist/client.mjs +83 -0
- package/dist/server.d.mts +21 -0
- package/dist/server.d.ts +21 -0
- package/dist/server.js +90 -0
- package/dist/server.mjs +57 -0
- package/dist/utils.d.mts +5 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +50 -0
- package/dist/utils.mjs +10 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
function isClient() {
|
|
3
|
+
return typeof window !== "undefined";
|
|
4
|
+
}
|
|
5
|
+
function logger(isDebug) {
|
|
6
|
+
return (message, ...args) => {
|
|
7
|
+
if (!isDebug) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
console.log("%c[BundleUp]", "color: #00f;", message, ...args);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function isTrue(val) {
|
|
14
|
+
if (!val) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return val.toLowerCase() === "true";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
isClient,
|
|
22
|
+
logger,
|
|
23
|
+
isTrue
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
function isClient() {
|
|
3
|
+
return typeof window !== "undefined";
|
|
4
|
+
}
|
|
5
|
+
function logger(isDebug) {
|
|
6
|
+
return (message, ...args) => {
|
|
7
|
+
if (!isDebug) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
console.log("%c[BundleUp]", "color: #00f;", message, ...args);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
isClient,
|
|
16
|
+
logger
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/utils.ts
|
|
2
|
+
function isClient() {
|
|
3
|
+
return typeof window !== "undefined";
|
|
4
|
+
}
|
|
5
|
+
function logger(isDebug) {
|
|
6
|
+
return (message, ...args) => {
|
|
7
|
+
if (!isDebug) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
console.log("%c[BundleUp]", "color: #00f;", message, ...args);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
isClient,
|
|
16
|
+
logger
|
|
17
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface AuthenticateWithPopupOptions {
|
|
2
|
+
width?: number;
|
|
3
|
+
height?: number;
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare function authenticateWithPopup(token: string, options?: AuthenticateWithPopupOptions): Promise<void>;
|
|
7
|
+
|
|
8
|
+
export { AuthenticateWithPopupOptions, authenticateWithPopup };
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface AuthenticateWithPopupOptions {
|
|
2
|
+
width?: number;
|
|
3
|
+
height?: number;
|
|
4
|
+
debug?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare function authenticateWithPopup(token: string, options?: AuthenticateWithPopupOptions): Promise<void>;
|
|
7
|
+
|
|
8
|
+
export { AuthenticateWithPopupOptions, authenticateWithPopup };
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/client.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
authenticateWithPopup: () => authenticateWithPopup
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(client_exports);
|
|
26
|
+
|
|
27
|
+
// src/utils.ts
|
|
28
|
+
function isClient() {
|
|
29
|
+
return typeof window !== "undefined";
|
|
30
|
+
}
|
|
31
|
+
function logger(isDebug) {
|
|
32
|
+
return (message, ...args) => {
|
|
33
|
+
if (!isDebug) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
console.log("%c[BundleUp]", "color: #00f;", message, ...args);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/client.ts
|
|
41
|
+
function authenticateWithPopup(token, options = {}) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
if (!token) {
|
|
44
|
+
return reject(new Error("Token is required"));
|
|
45
|
+
}
|
|
46
|
+
const width = options?.width ?? 500;
|
|
47
|
+
const height = options?.height ?? 600;
|
|
48
|
+
const debug = options?.debug ?? false;
|
|
49
|
+
const client = isClient();
|
|
50
|
+
const log = logger(debug);
|
|
51
|
+
if (!client) {
|
|
52
|
+
log("Authentication failed: not in client environment");
|
|
53
|
+
return reject(
|
|
54
|
+
new Error(
|
|
55
|
+
"authenticateWithPopup can only be used in a client environment"
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
log("Starting authentication with popup");
|
|
60
|
+
const popup = window.open(
|
|
61
|
+
`https://auth.bundleup.io/${token}`,
|
|
62
|
+
"bundleup-auth",
|
|
63
|
+
`width=${width},height=${height},scrollbars=yes,resizable=yes`
|
|
64
|
+
);
|
|
65
|
+
if (!popup) {
|
|
66
|
+
log("Failed to open popup window. Please check popup blocker settings.");
|
|
67
|
+
return reject(
|
|
68
|
+
new Error(
|
|
69
|
+
"Failed to open popup window. Please check popup blocker settings."
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
const handleMessage = (event) => {
|
|
74
|
+
if (event.origin !== "https://auth.bundleup.io") {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!event.data?.type) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
log("Received authentication message", event.data);
|
|
81
|
+
cleanup();
|
|
82
|
+
popup.close();
|
|
83
|
+
if (event.data.type === "bundleup-auth-success") {
|
|
84
|
+
log("Authentication successful");
|
|
85
|
+
return resolve();
|
|
86
|
+
}
|
|
87
|
+
if (event.data.type === "bundleup-auth-error") {
|
|
88
|
+
log("Authentication failed", event.data.error);
|
|
89
|
+
return reject(new Error(event.data.error || "Authentication failed"));
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const checkClosed = setInterval(() => {
|
|
93
|
+
if (!popup.closed) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
cleanup();
|
|
97
|
+
log("Authentication popup closed by user");
|
|
98
|
+
reject(new Error("Authentication popup was closed by user"));
|
|
99
|
+
}, 1e3);
|
|
100
|
+
const cleanup = () => {
|
|
101
|
+
window.removeEventListener("message", handleMessage);
|
|
102
|
+
clearInterval(checkClosed);
|
|
103
|
+
};
|
|
104
|
+
window.addEventListener("message", handleMessage);
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
if (!popup.closed) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
cleanup();
|
|
110
|
+
log("Authentication popup was blocked or closed immediately");
|
|
111
|
+
reject(new Error("Popup was blocked or closed immediately"));
|
|
112
|
+
}, 100);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 && (module.exports = {
|
|
117
|
+
authenticateWithPopup
|
|
118
|
+
});
|
package/dist/client.mjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isClient,
|
|
3
|
+
logger
|
|
4
|
+
} from "./chunk-B6T6V2FR.mjs";
|
|
5
|
+
|
|
6
|
+
// src/client.ts
|
|
7
|
+
function authenticateWithPopup(token, options = {}) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
if (!token) {
|
|
10
|
+
return reject(new Error("Token is required"));
|
|
11
|
+
}
|
|
12
|
+
const width = options?.width ?? 500;
|
|
13
|
+
const height = options?.height ?? 600;
|
|
14
|
+
const debug = options?.debug ?? false;
|
|
15
|
+
const client = isClient();
|
|
16
|
+
const log = logger(debug);
|
|
17
|
+
if (!client) {
|
|
18
|
+
log("Authentication failed: not in client environment");
|
|
19
|
+
return reject(
|
|
20
|
+
new Error(
|
|
21
|
+
"authenticateWithPopup can only be used in a client environment"
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
log("Starting authentication with popup");
|
|
26
|
+
const popup = window.open(
|
|
27
|
+
`https://auth.bundleup.io/${token}`,
|
|
28
|
+
"bundleup-auth",
|
|
29
|
+
`width=${width},height=${height},scrollbars=yes,resizable=yes`
|
|
30
|
+
);
|
|
31
|
+
if (!popup) {
|
|
32
|
+
log("Failed to open popup window. Please check popup blocker settings.");
|
|
33
|
+
return reject(
|
|
34
|
+
new Error(
|
|
35
|
+
"Failed to open popup window. Please check popup blocker settings."
|
|
36
|
+
)
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
const handleMessage = (event) => {
|
|
40
|
+
if (event.origin !== "https://auth.bundleup.io") {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!event.data?.type) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
log("Received authentication message", event.data);
|
|
47
|
+
cleanup();
|
|
48
|
+
popup.close();
|
|
49
|
+
if (event.data.type === "bundleup-auth-success") {
|
|
50
|
+
log("Authentication successful");
|
|
51
|
+
return resolve();
|
|
52
|
+
}
|
|
53
|
+
if (event.data.type === "bundleup-auth-error") {
|
|
54
|
+
log("Authentication failed", event.data.error);
|
|
55
|
+
return reject(new Error(event.data.error || "Authentication failed"));
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const checkClosed = setInterval(() => {
|
|
59
|
+
if (!popup.closed) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
cleanup();
|
|
63
|
+
log("Authentication popup closed by user");
|
|
64
|
+
reject(new Error("Authentication popup was closed by user"));
|
|
65
|
+
}, 1e3);
|
|
66
|
+
const cleanup = () => {
|
|
67
|
+
window.removeEventListener("message", handleMessage);
|
|
68
|
+
clearInterval(checkClosed);
|
|
69
|
+
};
|
|
70
|
+
window.addEventListener("message", handleMessage);
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
if (!popup.closed) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
cleanup();
|
|
76
|
+
log("Authentication popup was blocked or closed immediately");
|
|
77
|
+
reject(new Error("Popup was blocked or closed immediately"));
|
|
78
|
+
}, 100);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
authenticateWithPopup
|
|
83
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface BundleUpConfig {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
}
|
|
5
|
+
interface BundleUpResponse {
|
|
6
|
+
token: string;
|
|
7
|
+
expires_in: number;
|
|
8
|
+
externalId: string;
|
|
9
|
+
}
|
|
10
|
+
interface ConnectionOptions {
|
|
11
|
+
externalId?: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
declare class BundleUp {
|
|
15
|
+
private config;
|
|
16
|
+
constructor(config?: BundleUpConfig);
|
|
17
|
+
private log;
|
|
18
|
+
createConnection(integrationId: string, options: ConnectionOptions): Promise<BundleUpResponse>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { BundleUp, BundleUpConfig, BundleUpResponse, ConnectionOptions };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface BundleUpConfig {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
}
|
|
5
|
+
interface BundleUpResponse {
|
|
6
|
+
token: string;
|
|
7
|
+
expires_in: number;
|
|
8
|
+
externalId: string;
|
|
9
|
+
}
|
|
10
|
+
interface ConnectionOptions {
|
|
11
|
+
externalId?: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
declare class BundleUp {
|
|
15
|
+
private config;
|
|
16
|
+
constructor(config?: BundleUpConfig);
|
|
17
|
+
private log;
|
|
18
|
+
createConnection(integrationId: string, options: ConnectionOptions): Promise<BundleUpResponse>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { BundleUp, BundleUpConfig, BundleUpResponse, ConnectionOptions };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/server.ts
|
|
21
|
+
var server_exports = {};
|
|
22
|
+
__export(server_exports, {
|
|
23
|
+
BundleUp: () => BundleUp
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(server_exports);
|
|
26
|
+
|
|
27
|
+
// src/utils.ts
|
|
28
|
+
function logger(isDebug) {
|
|
29
|
+
return (message, ...args) => {
|
|
30
|
+
if (!isDebug) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
console.log("%c[BundleUp]", "color: #00f;", message, ...args);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// src/server.ts
|
|
38
|
+
var BundleUp = class {
|
|
39
|
+
constructor(config = {}) {
|
|
40
|
+
if (!config.apiKey) {
|
|
41
|
+
throw new Error("API key is required for authentication");
|
|
42
|
+
}
|
|
43
|
+
this.config = {
|
|
44
|
+
apiKey: config.apiKey,
|
|
45
|
+
debug: config.debug ?? false
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
log(message, ...args) {
|
|
49
|
+
return logger(!!this.config.debug)(message, ...args);
|
|
50
|
+
}
|
|
51
|
+
async createConnection(integrationId, options) {
|
|
52
|
+
this.log(`Creating connection for integration: ${integrationId}`, options);
|
|
53
|
+
if (!integrationId) {
|
|
54
|
+
this.log("Integration ID is missing");
|
|
55
|
+
throw new Error("Integration ID is required to create a connection");
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const response = await fetch("https://auth.bundleup.io/authorize", {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: {
|
|
61
|
+
"Content-Type": "application/json",
|
|
62
|
+
Authorization: `Bearer ${this.config.apiKey}`
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify({
|
|
65
|
+
integrationId,
|
|
66
|
+
externalId: options.externalId ?? void 0,
|
|
67
|
+
metadata: options.metadata ?? {}
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
this.log(`Authentication request failed: ${response.status} ${response.statusText}`);
|
|
72
|
+
throw new Error(`Authentication request failed: ${response.status} ${response.statusText}`);
|
|
73
|
+
}
|
|
74
|
+
const data = await response.json();
|
|
75
|
+
if (!data.token) {
|
|
76
|
+
this.log("Invalid response: token not found");
|
|
77
|
+
throw new Error("Invalid response: token not found");
|
|
78
|
+
}
|
|
79
|
+
this.log("Authentication token received successfully");
|
|
80
|
+
return data;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
this.log("Error creating connection", error);
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
BundleUp
|
|
90
|
+
});
|
package/dist/server.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logger
|
|
3
|
+
} from "./chunk-B6T6V2FR.mjs";
|
|
4
|
+
|
|
5
|
+
// src/server.ts
|
|
6
|
+
var BundleUp = class {
|
|
7
|
+
constructor(config = {}) {
|
|
8
|
+
if (!config.apiKey) {
|
|
9
|
+
throw new Error("API key is required for authentication");
|
|
10
|
+
}
|
|
11
|
+
this.config = {
|
|
12
|
+
apiKey: config.apiKey,
|
|
13
|
+
debug: config.debug ?? false
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
log(message, ...args) {
|
|
17
|
+
return logger(!!this.config.debug)(message, ...args);
|
|
18
|
+
}
|
|
19
|
+
async createConnection(integrationId, options) {
|
|
20
|
+
this.log(`Creating connection for integration: ${integrationId}`, options);
|
|
21
|
+
if (!integrationId) {
|
|
22
|
+
this.log("Integration ID is missing");
|
|
23
|
+
throw new Error("Integration ID is required to create a connection");
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const response = await fetch("https://auth.bundleup.io/authorize", {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": "application/json",
|
|
30
|
+
Authorization: `Bearer ${this.config.apiKey}`
|
|
31
|
+
},
|
|
32
|
+
body: JSON.stringify({
|
|
33
|
+
integrationId,
|
|
34
|
+
externalId: options.externalId ?? void 0,
|
|
35
|
+
metadata: options.metadata ?? {}
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
this.log(`Authentication request failed: ${response.status} ${response.statusText}`);
|
|
40
|
+
throw new Error(`Authentication request failed: ${response.status} ${response.statusText}`);
|
|
41
|
+
}
|
|
42
|
+
const data = await response.json();
|
|
43
|
+
if (!data.token) {
|
|
44
|
+
this.log("Invalid response: token not found");
|
|
45
|
+
throw new Error("Invalid response: token not found");
|
|
46
|
+
}
|
|
47
|
+
this.log("Authentication token received successfully");
|
|
48
|
+
return data;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
this.log("Error creating connection", error);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
BundleUp
|
|
57
|
+
};
|
package/dist/utils.d.mts
ADDED
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils.ts
|
|
21
|
+
var utils_exports = {};
|
|
22
|
+
__export(utils_exports, {
|
|
23
|
+
isClient: () => isClient,
|
|
24
|
+
isTrue: () => isTrue,
|
|
25
|
+
logger: () => logger
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(utils_exports);
|
|
28
|
+
function isClient() {
|
|
29
|
+
return typeof window !== "undefined";
|
|
30
|
+
}
|
|
31
|
+
function logger(isDebug) {
|
|
32
|
+
return (message, ...args) => {
|
|
33
|
+
if (!isDebug) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
console.log("%c[BundleUp]", "color: #00f;", message, ...args);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function isTrue(val) {
|
|
40
|
+
if (!val) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return val.toLowerCase() === "true";
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
isClient,
|
|
48
|
+
isTrue,
|
|
49
|
+
logger
|
|
50
|
+
});
|
package/dist/utils.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bundleup/core",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Core package for BundleUp",
|
|
5
|
+
"exports": {
|
|
6
|
+
"./client": {
|
|
7
|
+
"types": "./dist/client.d.ts",
|
|
8
|
+
"import": "./dist/client.mjs",
|
|
9
|
+
"require": "./dist/client.js"
|
|
10
|
+
},
|
|
11
|
+
"./server": {
|
|
12
|
+
"types": "./dist/server.d.ts",
|
|
13
|
+
"import": "./dist/server.mjs",
|
|
14
|
+
"require": "./dist/server.js"
|
|
15
|
+
},
|
|
16
|
+
"./utils": {
|
|
17
|
+
"types": "./dist/utils.d.ts",
|
|
18
|
+
"import": "./dist/utils.mjs",
|
|
19
|
+
"require": "./dist/utils.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup src/client.ts src/server.ts src/utils.ts --format cjs,esm --dts",
|
|
24
|
+
"dev": "tsup src/client.ts src/server.ts src/utils.ts --format cjs,esm --dts --watch",
|
|
25
|
+
"lint": "eslint src/",
|
|
26
|
+
"test": "jest",
|
|
27
|
+
"clean": "rm -rf dist"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"tsup": "^7.0.0",
|
|
31
|
+
"typescript": "^5.0.0",
|
|
32
|
+
"eslint": "^8.0.0",
|
|
33
|
+
"jest": "^29.0.0"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"author": "BundleUp",
|
|
39
|
+
"license": "ISC"
|
|
40
|
+
}
|