@whop/embedded-components-vanilla-js 0.0.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/LICENSE +21 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +28 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/index.d.ts +283 -0
- package/dist/pure.d.ts +6 -0
- package/dist/pure.js +29 -0
- package/dist/pure.js.map +1 -0
- package/dist/pure.mjs +6 -0
- package/dist/pure.mjs.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +19 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +1 -0
- package/dist/url.d.ts +4 -0
- package/dist/url.js +27 -0
- package/dist/url.js.map +1 -0
- package/dist/url.mjs +3 -0
- package/dist/url.mjs.map +1 -0
- package/dist/util.d.ts +8 -0
- package/dist/util.js +122 -0
- package/dist/util.js.map +1 -0
- package/dist/util.mjs +97 -0
- package/dist/util.mjs.map +1 -0
- package/package.json +23 -0
- package/pure/index.d.ts +1 -0
- package/pure/index.js +27 -0
- package/pure/index.mjs +1 -0
- package/types/index.d.ts +1 -0
- package/url/index.d.ts +1 -0
- package/url/index.js +27 -0
- package/url/index.mjs +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Stripe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
loadWhopElements: () => loadWhopElements
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(index_exports);
|
|
24
|
+
var import_util = require("./util");
|
|
25
|
+
let whopElementsPromise;
|
|
26
|
+
let loadCalled = false;
|
|
27
|
+
const getWhopElementsPromise = () => {
|
|
28
|
+
if (whopElementsPromise) {
|
|
29
|
+
return whopElementsPromise;
|
|
30
|
+
}
|
|
31
|
+
whopElementsPromise = (0, import_util.loadScript)().catch((error) => {
|
|
32
|
+
whopElementsPromise = null;
|
|
33
|
+
if (error instanceof Error) {
|
|
34
|
+
return Promise.reject(error);
|
|
35
|
+
} else {
|
|
36
|
+
return Promise.reject(
|
|
37
|
+
new Error("Failed to load WhopElements", { cause: error })
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return whopElementsPromise;
|
|
42
|
+
};
|
|
43
|
+
Promise.resolve().then(() => getWhopElementsPromise()).catch((error) => {
|
|
44
|
+
if (!loadCalled) {
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const loadWhopElements = async (...args) => {
|
|
48
|
+
loadCalled = true;
|
|
49
|
+
const maybeWhopElements = await getWhopElementsPromise();
|
|
50
|
+
return (0, import_util.initWhopElements)(maybeWhopElements, args);
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { WhopElementsConstructor } from \"./types\";\nimport type { LoadWhopElements } from \"./util\";\nimport { initWhopElements, loadScript } from \"./util\";\n\nlet whopElementsPromise: Promise<WhopElementsConstructor | null> | null;\nlet loadCalled = false;\n\nconst getWhopElementsPromise: () => Promise<WhopElementsConstructor | null> =\n\t() => {\n\t\tif (whopElementsPromise) {\n\t\t\treturn whopElementsPromise;\n\t\t}\n\n\t\twhopElementsPromise = loadScript().catch((error) => {\n\t\t\t// clear cache on error\n\t\t\twhopElementsPromise = null;\n\t\t\tif (error instanceof Error) {\n\t\t\t\treturn Promise.reject(error);\n\t\t\t} else {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew Error(\"Failed to load WhopElements\", { cause: error }),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t\treturn whopElementsPromise;\n\t};\n\n// eagerly load the script\nPromise.resolve()\n\t.then(() => getWhopElementsPromise())\n\t.catch((error) => {\n\t\tif (!loadCalled) {\n\t\t\tconsole.warn(error);\n\t\t}\n\t});\n\nexport const loadWhopElements: LoadWhopElements = async (...args) => {\n\tloadCalled = true;\n\n\tconst maybeWhopElements = await getWhopElementsPromise();\n\treturn initWhopElements(maybeWhopElements, args);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,kBAA6C;AAE7C,IAAI;AACJ,IAAI,aAAa;AAEjB,MAAM,yBACL,MAAM;AACL,MAAI,qBAAqB;AACxB,WAAO;AAAA,EACR;AAEA,4BAAsB,wBAAW,EAAE,MAAM,CAAC,UAAU;AAEnD,0BAAsB;AACtB,QAAI,iBAAiB,OAAO;AAC3B,aAAO,QAAQ,OAAO,KAAK;AAAA,IAC5B,OAAO;AACN,aAAO,QAAQ;AAAA,QACd,IAAI,MAAM,+BAA+B,EAAE,OAAO,MAAM,CAAC;AAAA,MAC1D;AAAA,IACD;AAAA,EACD,CAAC;AACD,SAAO;AACR;AAGD,QAAQ,QAAQ,EACd,KAAK,MAAM,uBAAuB,CAAC,EACnC,MAAM,CAAC,UAAU;AACjB,MAAI,CAAC,YAAY;AAAA,EAEjB;AACD,CAAC;AAEK,MAAM,mBAAqC,UAAU,SAAS;AACpE,eAAa;AAEb,QAAM,oBAAoB,MAAM,uBAAuB;AACvD,aAAO,8BAAiB,mBAAmB,IAAI;AAChD;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { initWhopElements, loadScript } from "./util.mjs";
|
|
2
|
+
let whopElementsPromise;
|
|
3
|
+
let loadCalled = false;
|
|
4
|
+
const getWhopElementsPromise = ()=>{
|
|
5
|
+
if (whopElementsPromise) {
|
|
6
|
+
return whopElementsPromise;
|
|
7
|
+
}
|
|
8
|
+
whopElementsPromise = loadScript().catch((error)=>{
|
|
9
|
+
whopElementsPromise = null;
|
|
10
|
+
if (error instanceof Error) {
|
|
11
|
+
return Promise.reject(error);
|
|
12
|
+
} else {
|
|
13
|
+
return Promise.reject(new Error("Failed to load WhopElements", {
|
|
14
|
+
cause: error
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return whopElementsPromise;
|
|
19
|
+
};
|
|
20
|
+
Promise.resolve().then(()=>getWhopElementsPromise()).catch((error)=>{
|
|
21
|
+
if (!loadCalled) {}
|
|
22
|
+
});
|
|
23
|
+
const loadWhopElements = async (...args)=>{
|
|
24
|
+
loadCalled = true;
|
|
25
|
+
const maybeWhopElements = await getWhopElementsPromise();
|
|
26
|
+
return initWhopElements(maybeWhopElements, args);
|
|
27
|
+
};
|
|
28
|
+
export { loadWhopElements };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { WhopElementsConstructor } from \"./types\";\nimport type { LoadWhopElements } from \"./util\";\nimport { initWhopElements, loadScript } from \"./util\";\n\nlet whopElementsPromise: Promise<WhopElementsConstructor | null> | null;\nlet loadCalled = false;\n\nconst getWhopElementsPromise: () => Promise<WhopElementsConstructor | null> =\n\t() => {\n\t\tif (whopElementsPromise) {\n\t\t\treturn whopElementsPromise;\n\t\t}\n\n\t\twhopElementsPromise = loadScript().catch((error) => {\n\t\t\t// clear cache on error\n\t\t\twhopElementsPromise = null;\n\t\t\tif (error instanceof Error) {\n\t\t\t\treturn Promise.reject(error);\n\t\t\t} else {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew Error(\"Failed to load WhopElements\", { cause: error }),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t\treturn whopElementsPromise;\n\t};\n\n// eagerly load the script\nPromise.resolve()\n\t.then(() => getWhopElementsPromise())\n\t.catch((error) => {\n\t\tif (!loadCalled) {\n\t\t\tconsole.warn(error);\n\t\t}\n\t});\n\nexport const loadWhopElements: LoadWhopElements = async (...args) => {\n\tloadCalled = true;\n\n\tconst maybeWhopElements = await getWhopElementsPromise();\n\treturn initWhopElements(maybeWhopElements, args);\n};\n"],"mappings":"AAEA,SAAS,kBAAkB,kBAAkB;AAE7C,IAAI;AACJ,IAAI,aAAa;AAEjB,MAAM,yBACL,MAAM;AACL,MAAI,qBAAqB;AACxB,WAAO;AAAA,EACR;AAEA,wBAAsB,WAAW,EAAE,MAAM,CAAC,UAAU;AAEnD,0BAAsB;AACtB,QAAI,iBAAiB,OAAO;AAC3B,aAAO,QAAQ,OAAO,KAAK;AAAA,IAC5B,OAAO;AACN,aAAO,QAAQ;AAAA,QACd,IAAI,MAAM,+BAA+B,EAAE,OAAO,MAAM,CAAC;AAAA,MAC1D;AAAA,IACD;AAAA,EACD,CAAC;AACD,SAAO;AACR;AAGD,QAAQ,QAAQ,EACd,KAAK,MAAM,uBAAuB,CAAC,EACnC,MAAM,CAAC,UAAU;AACjB,MAAI,CAAC,YAAY;AAAA,EAEjB;AACD,CAAC;AAEK,MAAM,mBAAqC,UAAU,SAAS;AACpE,eAAa;AAEb,QAAM,oBAAoB,MAAM,uBAAuB;AACvD,SAAO,iBAAiB,mBAAmB,IAAI;AAChD;","names":[]}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
declare const locales: readonly ["en"];
|
|
2
|
+
type I18nSupportedLocale = (typeof locales)[number];
|
|
3
|
+
|
|
4
|
+
type CSSVariableKeys =
|
|
5
|
+
| "--colorAccent"
|
|
6
|
+
| "--colorAccentContrast"
|
|
7
|
+
| "--colorDanger"
|
|
8
|
+
| "--colorDangerContrast"
|
|
9
|
+
| "--colorWarning"
|
|
10
|
+
| "--colorWarningContrast"
|
|
11
|
+
| "--colorSuccess"
|
|
12
|
+
| "--colorSuccessContrast"
|
|
13
|
+
| "--colorStroke"
|
|
14
|
+
| "--colorTextPrimary"
|
|
15
|
+
| "--colorTextSecondary"
|
|
16
|
+
| "--colorTextTertiary"
|
|
17
|
+
| "--colorBackgroundPrimary"
|
|
18
|
+
| "--colorBackgroundPrimaryContrast"
|
|
19
|
+
| "--colorBackgroundSecondary"
|
|
20
|
+
| "--colorBackgroundSecondaryContrast"
|
|
21
|
+
| "--colorSurface"
|
|
22
|
+
| "--fontSize1"
|
|
23
|
+
| "--fontSize2"
|
|
24
|
+
| "--fontSize3"
|
|
25
|
+
| "--fontSize4"
|
|
26
|
+
| "--fontSize5"
|
|
27
|
+
| "--fontSize6"
|
|
28
|
+
| "--fontSize7"
|
|
29
|
+
| "--fontSize8"
|
|
30
|
+
| "--fontSize9"
|
|
31
|
+
| "--fontLetterSpacing1"
|
|
32
|
+
| "--fontLetterSpacing2"
|
|
33
|
+
| "--fontLetterSpacing3"
|
|
34
|
+
| "--fontLetterSpacing4"
|
|
35
|
+
| "--fontLetterSpacing5"
|
|
36
|
+
| "--fontLetterSpacing6"
|
|
37
|
+
| "--fontLetterSpacing7"
|
|
38
|
+
| "--fontLetterSpacing8"
|
|
39
|
+
| "--fontLetterSpacing9"
|
|
40
|
+
| "--fontLineHeight1"
|
|
41
|
+
| "--fontLineHeight2"
|
|
42
|
+
| "--fontLineHeight3"
|
|
43
|
+
| "--fontLineHeight4"
|
|
44
|
+
| "--fontLineHeight5"
|
|
45
|
+
| "--fontLineHeight6"
|
|
46
|
+
| "--fontLineHeight7"
|
|
47
|
+
| "--fontLineHeight8"
|
|
48
|
+
| "--fontLineHeight9"
|
|
49
|
+
| "--fontWeightRegular"
|
|
50
|
+
| "--fontWeightMedium"
|
|
51
|
+
| "--fontWeightSemiBold"
|
|
52
|
+
| "--fontWeightBold"
|
|
53
|
+
| "--shadowSize1"
|
|
54
|
+
| "--cursorButton"
|
|
55
|
+
| "--spacing1"
|
|
56
|
+
| "--spacing2"
|
|
57
|
+
| "--spacing3"
|
|
58
|
+
| "--spacing4"
|
|
59
|
+
| "--spacing5"
|
|
60
|
+
| "--spacing6"
|
|
61
|
+
| "--spacing7"
|
|
62
|
+
| "--spacing8"
|
|
63
|
+
| "--spacing9"
|
|
64
|
+
| "--spacing10"
|
|
65
|
+
| "--radius1"
|
|
66
|
+
| "--radius2"
|
|
67
|
+
| "--spinnerOpacity"
|
|
68
|
+
|
|
69
|
+
type CSSValue = string;
|
|
70
|
+
type CSSProps = Record<string, CSSValue>;
|
|
71
|
+
type Classes = Record<string, CSSProps>;
|
|
72
|
+
type Variables = Record<CSSVariableKeys, string>;
|
|
73
|
+
type Appearance = {
|
|
74
|
+
variables?: Variables | null;
|
|
75
|
+
classes?: Classes | null;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
interface EmbeddableElement {
|
|
79
|
+
mount: (element: HTMLElement | `#${string}`) => void;
|
|
80
|
+
unmount: () => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type ListenerSignature<L> = {
|
|
84
|
+
[E in keyof L]: (...args: any[]) => any;
|
|
85
|
+
};
|
|
86
|
+
type DefaultListener = Record<string, (...args: any[]) => any>;
|
|
87
|
+
declare const TypedEmitter: new <L extends ListenerSignature<L> = DefaultListener>() => TypedEmitterType<L>;
|
|
88
|
+
type TypedEmitter<L extends ListenerSignature<L> = DefaultListener> = InstanceType<typeof TypedEmitter<L>>;
|
|
89
|
+
declare class TypedEmitterType<L extends ListenerSignature<L> = DefaultListener> {
|
|
90
|
+
static defaultMaxListeners: number;
|
|
91
|
+
addListener<U extends keyof L>(event: U, listener: L[U]): this;
|
|
92
|
+
prependListener<U extends keyof L>(event: U, listener: L[U]): this;
|
|
93
|
+
prependOnceListener<U extends keyof L>(event: U, listener: L[U]): this;
|
|
94
|
+
removeListener<U extends keyof L>(event: U, listener: L[U]): this;
|
|
95
|
+
removeAllListeners(event?: keyof L): this;
|
|
96
|
+
once<U extends keyof L>(event: U, listener: L[U]): this;
|
|
97
|
+
on<U extends keyof L>(event: U, listener: L[U]): this;
|
|
98
|
+
off<U extends keyof L>(event: U, listener: L[U]): this;
|
|
99
|
+
emit<U extends keyof L>(event: U, ...args: Parameters<L[U]>): boolean;
|
|
100
|
+
eventNames<U extends keyof L>(): U[];
|
|
101
|
+
listenerCount(type: keyof L): number;
|
|
102
|
+
listeners<U extends keyof L>(type: U): L[U][];
|
|
103
|
+
rawListeners<U extends keyof L>(type: U): L[U][];
|
|
104
|
+
getMaxListeners(): number;
|
|
105
|
+
setMaxListeners(n: number): this;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface WhopElement<ElementOptions, ElementEvents extends ListenerSignature<ElementEvents> & {
|
|
109
|
+
snapshot: (snapshot: ElementSnapshot) => void;
|
|
110
|
+
}, ElementSnapshot> extends TypedEmitter<ElementEvents>, EmbeddableElement {
|
|
111
|
+
options: ElementOptions;
|
|
112
|
+
state: "loading" | "ready";
|
|
113
|
+
updateOptions: (options: Partial<ElementOptions>) => void;
|
|
114
|
+
getSnapshot: () => ElementSnapshot;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
interface BalanceElementEvents {
|
|
118
|
+
error: (error: unknown) => void;
|
|
119
|
+
ready: (element: BalanceElement) => void;
|
|
120
|
+
optionsUpdated: (options: BalanceElementOptions) => void;
|
|
121
|
+
snapshot: (snapshot: BalanceElementSnapshot) => void;
|
|
122
|
+
}
|
|
123
|
+
interface BalanceElementOptions {
|
|
124
|
+
hidePendingBalance?: boolean;
|
|
125
|
+
onReady?: (element: BalanceElement) => void;
|
|
126
|
+
}
|
|
127
|
+
interface BalanceElementSnapshot {
|
|
128
|
+
state: "loading" | "ready";
|
|
129
|
+
}
|
|
130
|
+
type BalanceElement = WhopElement<BalanceElementOptions, BalanceElementEvents, BalanceElementSnapshot>;
|
|
131
|
+
|
|
132
|
+
interface WithdrawButtonElementEvents {
|
|
133
|
+
error: (error: unknown) => void;
|
|
134
|
+
ready: (element: WithdrawButtonElement) => void;
|
|
135
|
+
optionsUpdated: (options: WithdrawButtonElementOptions) => void;
|
|
136
|
+
verify: (ev: CustomEvent<WithdrawButtonElement>) => void;
|
|
137
|
+
withdraw: (ev: CustomEvent<WithdrawButtonElement>) => void;
|
|
138
|
+
snapshot: (snapshot: WithdrawButtonElementSnapshot) => void;
|
|
139
|
+
}
|
|
140
|
+
interface WithdrawButtonElementOptions {
|
|
141
|
+
hidePendingBalance?: boolean;
|
|
142
|
+
onReady?: (element: WithdrawButtonElement) => void;
|
|
143
|
+
onVerificationSubmitted?: () => void;
|
|
144
|
+
onWithdraw?: () => void;
|
|
145
|
+
}
|
|
146
|
+
interface WithdrawButtonElementSnapshot {
|
|
147
|
+
state: "loading" | "ready";
|
|
148
|
+
}
|
|
149
|
+
type WithdrawButtonElement = WhopElement<WithdrawButtonElementOptions, WithdrawButtonElementEvents, WithdrawButtonElementSnapshot>;
|
|
150
|
+
|
|
151
|
+
interface WithdrawElementEvents {
|
|
152
|
+
error: (error: unknown) => void;
|
|
153
|
+
ready: (element: WithdrawElement) => void;
|
|
154
|
+
optionsUpdated: (options: WithdrawElementOptions) => void;
|
|
155
|
+
snapshot: (snapshot: WithdrawElementSnapshot) => void;
|
|
156
|
+
close: (ev: CustomEvent) => void;
|
|
157
|
+
withdraw: (ev: CustomEvent) => void;
|
|
158
|
+
}
|
|
159
|
+
interface WithdrawElementOptions {
|
|
160
|
+
onReady?: (element: WithdrawElement) => void;
|
|
161
|
+
onWithdraw?: (ev: CustomEvent) => void;
|
|
162
|
+
onClose?: (ev: CustomEvent) => void;
|
|
163
|
+
}
|
|
164
|
+
interface WithdrawElementSnapshot {
|
|
165
|
+
state: "loading" | "ready";
|
|
166
|
+
}
|
|
167
|
+
type WithdrawElement = WhopElement<WithdrawElementOptions, WithdrawElementEvents, WithdrawElementSnapshot>;
|
|
168
|
+
|
|
169
|
+
interface VerifyElementEvents {
|
|
170
|
+
error: (error: unknown) => void;
|
|
171
|
+
ready: (element: VerifyElement) => void;
|
|
172
|
+
optionsUpdated: (options: VerifyElementOptions) => void;
|
|
173
|
+
close: (ev: CustomEvent) => void;
|
|
174
|
+
snapshot: (snapshot: VerifyElementSnapshot) => void;
|
|
175
|
+
}
|
|
176
|
+
interface VerifyElementOptions {
|
|
177
|
+
includeControls?: boolean;
|
|
178
|
+
onReady?: (element: VerifyElement) => void;
|
|
179
|
+
onVerificationSubmitted?: () => void;
|
|
180
|
+
onClose?: (ev: CustomEvent) => void;
|
|
181
|
+
}
|
|
182
|
+
interface VerifyElementSnapshot {
|
|
183
|
+
state: "loading" | "ready";
|
|
184
|
+
}
|
|
185
|
+
type VerifyElement = WhopElement<VerifyElementOptions, VerifyElementEvents, VerifyElementSnapshot>;
|
|
186
|
+
|
|
187
|
+
type GetToken = (opts: {
|
|
188
|
+
abortSignal: AbortSignal;
|
|
189
|
+
}) => Promise<string | null> | string | null;
|
|
190
|
+
interface PayoutsSessionOptions {
|
|
191
|
+
/**
|
|
192
|
+
* The token to use for the session. If a function is provided, it will be called and awaited to get the token.
|
|
193
|
+
* When a function is provided, the token will be refreshed automatically before it expires.
|
|
194
|
+
*
|
|
195
|
+
* if a string is provided, it will be used as the token and not refreshed automatically. However you can update the token at runtime by
|
|
196
|
+
* calling `updateOptions` with a new token.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* // with a static token
|
|
201
|
+
* async function createPayoutsSession() {
|
|
202
|
+
* const token = await fetch("/api/token")
|
|
203
|
+
* .then(res => res.json())
|
|
204
|
+
* .then(data => data.token)
|
|
205
|
+
* return new PayoutsSession({ token })
|
|
206
|
+
* }
|
|
207
|
+
*
|
|
208
|
+
* // with a dynamic function
|
|
209
|
+
* function createPayoutsSession() {
|
|
210
|
+
* return new PayoutsSession({
|
|
211
|
+
* token: () => {
|
|
212
|
+
* return await fetch("/api/token")
|
|
213
|
+
* .then(res => res.json())
|
|
214
|
+
* .then(data => data.token)
|
|
215
|
+
* }
|
|
216
|
+
* })
|
|
217
|
+
* }
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
token: string | Promise<string | null> | null | GetToken;
|
|
221
|
+
/**
|
|
222
|
+
* The currency to use in the Elements
|
|
223
|
+
*
|
|
224
|
+
* @default "USD"
|
|
225
|
+
*/
|
|
226
|
+
currency?: string;
|
|
227
|
+
}
|
|
228
|
+
interface ExpandedPayoutsSessionOptions extends PayoutsSessionOptions {
|
|
229
|
+
}
|
|
230
|
+
interface PayoutsSessionEvents {
|
|
231
|
+
optionsUpdated: (options: ExpandedPayoutsSessionOptions) => void;
|
|
232
|
+
tokenRefreshed: (token: string) => void;
|
|
233
|
+
tokenRefreshError: (error: unknown) => void;
|
|
234
|
+
error: (error: unknown) => void;
|
|
235
|
+
}
|
|
236
|
+
type PayoutsSessionElements = {
|
|
237
|
+
"balance-element": [BalanceElementOptions, BalanceElement];
|
|
238
|
+
"withdraw-button-element": [
|
|
239
|
+
WithdrawButtonElementOptions,
|
|
240
|
+
WithdrawButtonElement
|
|
241
|
+
];
|
|
242
|
+
"withdraw-element": [WithdrawElementOptions, WithdrawElement];
|
|
243
|
+
"verify-element": [VerifyElementOptions, VerifyElement];
|
|
244
|
+
};
|
|
245
|
+
interface PayoutsSession extends TypedEmitter<PayoutsSessionEvents> {
|
|
246
|
+
token: Promise<string | null>;
|
|
247
|
+
updateOptions: (options: Partial<PayoutsSessionOptions>) => void;
|
|
248
|
+
destroy: () => void;
|
|
249
|
+
createElement<T extends keyof PayoutsSessionElements>(type: T | {
|
|
250
|
+
type: T;
|
|
251
|
+
}, options: PayoutsSessionElements[T][0]): PayoutsSessionElements[T][1];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
declare global {
|
|
255
|
+
interface Window {
|
|
256
|
+
WhopElements: WhopElementsConstructor;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
type WhopElementsOptions = {
|
|
260
|
+
/**
|
|
261
|
+
* Customize the appearance of the Whop embedded Elements
|
|
262
|
+
*/
|
|
263
|
+
appearance?: Appearance;
|
|
264
|
+
/**
|
|
265
|
+
* This locale to use in the Elements
|
|
266
|
+
*
|
|
267
|
+
* @default "en"
|
|
268
|
+
*/
|
|
269
|
+
locale?: I18nSupportedLocale;
|
|
270
|
+
};
|
|
271
|
+
type WhopElementsConstructor = {
|
|
272
|
+
new (options?: WhopElementsOptions): WhopElements;
|
|
273
|
+
};
|
|
274
|
+
interface WhopElements {
|
|
275
|
+
createPayoutsSession: (options: PayoutsSessionOptions) => PayoutsSession;
|
|
276
|
+
updateOptions: (options: Partial<WhopElementsOptions>) => void;
|
|
277
|
+
options: WhopElementsOptions;
|
|
278
|
+
}
|
|
279
|
+
interface WhopElementsEvents {
|
|
280
|
+
optionsUpdated: (options: WhopElementsOptions) => void;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export type { Appearance, BalanceElement, BalanceElementOptions, BalanceElementSnapshot, CSSVariableKeys, ExpandedPayoutsSessionOptions, GetToken, I18nSupportedLocale, PayoutsSession, PayoutsSessionEvents, PayoutsSessionOptions, VerifyElement, VerifyElementOptions, VerifyElementSnapshot, WhopElement, WhopElements, WhopElementsConstructor, WhopElementsEvents, WhopElementsOptions, WithdrawButtonElement, WithdrawButtonElementOptions, WithdrawElement, WithdrawElementOptions, WithdrawElementSnapshot };
|
package/dist/pure.d.ts
ADDED
package/dist/pure.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
var pure_exports = {};
|
|
20
|
+
__export(pure_exports, {
|
|
21
|
+
loadWhopElements: () => loadWhopElements
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(pure_exports);
|
|
24
|
+
var import_util = require("./util");
|
|
25
|
+
const loadWhopElements = async (...args) => {
|
|
26
|
+
const maybeWhopElements = await (0, import_util.loadScript)();
|
|
27
|
+
return (0, import_util.initWhopElements)(maybeWhopElements, args);
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=pure.js.map
|
package/dist/pure.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pure.ts"],"sourcesContent":["import type { LoadWhopElements } from \"./util\";\nimport { initWhopElements, loadScript } from \"./util\";\n\nexport const loadWhopElements: LoadWhopElements = async (...args) => {\n\tconst maybeWhopElements = await loadScript();\n\n\treturn initWhopElements(maybeWhopElements, args);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA6C;AAEtC,MAAM,mBAAqC,UAAU,SAAS;AACpE,QAAM,oBAAoB,UAAM,wBAAW;AAE3C,aAAO,8BAAiB,mBAAmB,IAAI;AAChD;","names":[]}
|
package/dist/pure.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pure.ts"],"sourcesContent":["import type { LoadWhopElements } from \"./util\";\nimport { initWhopElements, loadScript } from \"./util\";\n\nexport const loadWhopElements: LoadWhopElements = async (...args) => {\n\tconst maybeWhopElements = await loadScript();\n\n\treturn initWhopElements(maybeWhopElements, args);\n};\n"],"mappings":"AACA,SAAS,kBAAkB,kBAAkB;AAEtC,MAAM,mBAAqC,UAAU,SAAS;AACpE,QAAM,oBAAoB,MAAM,WAAW;AAE3C,SAAO,iBAAiB,mBAAmB,IAAI;AAChD;","names":[]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib';
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
18
|
+
__reExport(types_exports, require("./lib"), module.exports);
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["export * from \"./lib\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,kBAAd;","names":[]}
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./lib";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["export * from \"./lib\";\n"],"mappings":"AAAA,cAAc;","names":[]}
|
package/dist/url.d.ts
ADDED
package/dist/url.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
var url_exports = {};
|
|
20
|
+
__export(url_exports, {
|
|
21
|
+
ORIGIN: () => ORIGIN,
|
|
22
|
+
SCRIPT_URL: () => SCRIPT_URL
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(url_exports);
|
|
25
|
+
const ORIGIN = "https://0-0-0.elements.whop.com/";
|
|
26
|
+
const SCRIPT_URL = new URL(`/release/elements.js`, ORIGIN).toString();
|
|
27
|
+
//# sourceMappingURL=url.js.map
|
package/dist/url.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/url.ts"],"sourcesContent":["declare const _ELEMENTS_ORIGIN: string;\n\nexport const ORIGIN = _ELEMENTS_ORIGIN;\nexport const SCRIPT_URL = new URL(`/release/elements.js`, ORIGIN).toString();\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,SAAS;AACf,MAAM,aAAa,IAAI,IAAI,wBAAwB,MAAM,EAAE,SAAS;","names":[]}
|
package/dist/url.mjs
ADDED
package/dist/url.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/url.ts"],"sourcesContent":["declare const _ELEMENTS_ORIGIN: string;\n\nexport const ORIGIN = _ELEMENTS_ORIGIN;\nexport const SCRIPT_URL = new URL(`/release/elements.js`, ORIGIN).toString();\n"],"mappings":"AAEO,MAAM,SAAS;AACf,MAAM,aAAa,IAAI,IAAI,wBAAwB,MAAM,EAAE,SAAS;","names":[]}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WhopElementsConstructor, WhopElements } from './lib';
|
|
2
|
+
|
|
3
|
+
type LoadWhopElements = (...args: ConstructorParameters<WhopElementsConstructor>) => Promise<WhopElements | null>;
|
|
4
|
+
declare const findScript: () => HTMLScriptElement | null;
|
|
5
|
+
declare const loadScript: () => Promise<WhopElementsConstructor | null>;
|
|
6
|
+
declare const initWhopElements: (maybeWhopElements: WhopElementsConstructor | null, args: ConstructorParameters<WhopElementsConstructor>) => WhopElements | null;
|
|
7
|
+
|
|
8
|
+
export { type LoadWhopElements, findScript, initWhopElements, loadScript };
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
var util_exports = {};
|
|
20
|
+
__export(util_exports, {
|
|
21
|
+
findScript: () => findScript,
|
|
22
|
+
initWhopElements: () => initWhopElements,
|
|
23
|
+
loadScript: () => loadScript
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(util_exports);
|
|
26
|
+
var import_url = require("./url");
|
|
27
|
+
const isWhopElementsScriptURL = (url) => {
|
|
28
|
+
const result = url.startsWith(import_url.ORIGIN) && url.endsWith("/elements.js");
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
const findScript = () => {
|
|
32
|
+
const scripts = document.querySelectorAll(
|
|
33
|
+
`script[src^="${import_url.ORIGIN}"]`
|
|
34
|
+
);
|
|
35
|
+
for (const script of scripts) {
|
|
36
|
+
if (!script || !isWhopElementsScriptURL(script.src)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
return script;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
};
|
|
43
|
+
const injectScript = () => {
|
|
44
|
+
const script = document.createElement("script");
|
|
45
|
+
script.src = import_url.SCRIPT_URL;
|
|
46
|
+
const headOrBody = document.head || document.body;
|
|
47
|
+
if (!headOrBody) {
|
|
48
|
+
throw new Error(
|
|
49
|
+
"Expected document.body not to be null. WhopElements requires a <body> element."
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
headOrBody.appendChild(script);
|
|
53
|
+
return script;
|
|
54
|
+
};
|
|
55
|
+
let whopElementsPromise = null;
|
|
56
|
+
let onErrorListener = null;
|
|
57
|
+
let onLoadListener = null;
|
|
58
|
+
const onError = (reject) => (cause) => {
|
|
59
|
+
reject(new Error("Failed to load WhopElements", { cause }));
|
|
60
|
+
};
|
|
61
|
+
const onLoad = (resolve, reject) => () => {
|
|
62
|
+
if (window.WhopElements) {
|
|
63
|
+
resolve(window.WhopElements);
|
|
64
|
+
} else {
|
|
65
|
+
reject(new Error("WhopElements not available"));
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const loadScript = () => {
|
|
69
|
+
if (whopElementsPromise !== null) {
|
|
70
|
+
return whopElementsPromise;
|
|
71
|
+
}
|
|
72
|
+
whopElementsPromise = new Promise((resolve, reject) => {
|
|
73
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
74
|
+
resolve(null);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (window.WhopElements) {
|
|
78
|
+
resolve(window.WhopElements);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
let script = findScript();
|
|
83
|
+
if (!script) {
|
|
84
|
+
script = injectScript();
|
|
85
|
+
} else if (script && onLoadListener !== null && onErrorListener !== null) {
|
|
86
|
+
script.removeEventListener("load", onLoadListener);
|
|
87
|
+
script.removeEventListener("error", onErrorListener);
|
|
88
|
+
script.parentNode?.removeChild(script);
|
|
89
|
+
script = injectScript();
|
|
90
|
+
}
|
|
91
|
+
onLoadListener = onLoad(resolve, reject);
|
|
92
|
+
onErrorListener = onError(reject);
|
|
93
|
+
script.addEventListener("load", onLoadListener);
|
|
94
|
+
script.addEventListener("error", onErrorListener);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (error instanceof Error) {
|
|
97
|
+
reject(error);
|
|
98
|
+
} else {
|
|
99
|
+
reject(new Error("Failed to load WhopElements", { cause: error }));
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return whopElementsPromise.catch((error) => {
|
|
105
|
+
whopElementsPromise = null;
|
|
106
|
+
if (error instanceof Error) {
|
|
107
|
+
return Promise.reject(error);
|
|
108
|
+
} else {
|
|
109
|
+
return Promise.reject(
|
|
110
|
+
new Error("Failed to load WhopElements", { cause: error })
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
const initWhopElements = (maybeWhopElements, args) => {
|
|
116
|
+
if (maybeWhopElements === null) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const WhopElements = maybeWhopElements;
|
|
120
|
+
return new WhopElements(...args);
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util.ts"],"sourcesContent":["import type { WhopElements, WhopElementsConstructor } from \"./types\";\nimport { ORIGIN, SCRIPT_URL } from \"./url\";\n\nexport type LoadWhopElements = (\n\t...args: ConstructorParameters<WhopElementsConstructor>\n) => Promise<WhopElements | null>;\n\nconst isWhopElementsScriptURL = (url: string): boolean => {\n\tconst result = url.startsWith(ORIGIN) && url.endsWith(\"/elements.js\");\n\treturn result;\n};\n\nexport const findScript = (): HTMLScriptElement | null => {\n\tconst scripts = document.querySelectorAll<HTMLScriptElement>(\n\t\t`script[src^=\"${ORIGIN}\"]`,\n\t);\n\n\tfor (const script of scripts) {\n\t\tif (!script || !isWhopElementsScriptURL(script.src)) {\n\t\t\tcontinue;\n\t\t}\n\t\treturn script;\n\t}\n\treturn null;\n};\n\nconst injectScript = (): HTMLScriptElement => {\n\tconst script = document.createElement(\"script\");\n\tscript.src = SCRIPT_URL;\n\n\tconst headOrBody = document.head || document.body;\n\n\tif (!headOrBody) {\n\t\tthrow new Error(\n\t\t\t\"Expected document.body not to be null. WhopElements requires a <body> element.\",\n\t\t);\n\t}\n\n\theadOrBody.appendChild(script);\n\n\treturn script;\n};\n\nlet whopElementsPromise: Promise<WhopElementsConstructor | null> | null = null;\n\nlet onErrorListener: ((cause?: unknown) => void) | null = null;\nlet onLoadListener: (() => void) | null = null;\n\nconst onError = (reject: (reason?: unknown) => void) => (cause?: unknown) => {\n\treject(new Error(\"Failed to load WhopElements\", { cause }));\n};\n\nconst onLoad =\n\t(\n\t\tresolve: (\n\t\t\tvalue:\n\t\t\t\t| WhopElementsConstructor\n\t\t\t\t| PromiseLike<WhopElementsConstructor | null>\n\t\t\t\t| null,\n\t\t) => void,\n\t\treject: (reason?: unknown) => void,\n\t) =>\n\t() => {\n\t\tif (window.WhopElements) {\n\t\t\tresolve(window.WhopElements);\n\t\t} else {\n\t\t\treject(new Error(\"WhopElements not available\"));\n\t\t}\n\t};\n\nexport const loadScript = (): Promise<WhopElementsConstructor | null> => {\n\tif (whopElementsPromise !== null) {\n\t\treturn whopElementsPromise;\n\t}\n\n\twhopElementsPromise = new Promise((resolve, reject) => {\n\t\tif (typeof window === \"undefined\" || typeof document === \"undefined\") {\n\t\t\tresolve(null);\n\t\t\treturn;\n\t\t}\n\n\t\tif (window.WhopElements) {\n\t\t\tresolve(window.WhopElements);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tlet script = findScript();\n\n\t\t\tif (!script) {\n\t\t\t\tscript = injectScript();\n\t\t\t} else if (\n\t\t\t\tscript &&\n\t\t\t\tonLoadListener !== null &&\n\t\t\t\tonErrorListener !== null\n\t\t\t) {\n\t\t\t\t// remove event listeners\n\t\t\t\tscript.removeEventListener(\"load\", onLoadListener);\n\t\t\t\tscript.removeEventListener(\"error\", onErrorListener);\n\n\t\t\t\t// if script exists, but we are reloading due to an error,\n\t\t\t\t// reload script to trigger 'load' event\n\t\t\t\tscript.parentNode?.removeChild(script);\n\t\t\t\tscript = injectScript();\n\t\t\t}\n\n\t\t\tonLoadListener = onLoad(resolve, reject);\n\t\t\tonErrorListener = onError(reject);\n\t\t\tscript.addEventListener(\"load\", onLoadListener);\n\t\t\tscript.addEventListener(\"error\", onErrorListener);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\treject(error);\n\t\t\t} else {\n\t\t\t\treject(new Error(\"Failed to load WhopElements\", { cause: error }));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t});\n\n\treturn whopElementsPromise.catch((error) => {\n\t\twhopElementsPromise = null;\n\t\tif (error instanceof Error) {\n\t\t\treturn Promise.reject(error);\n\t\t} else {\n\t\t\treturn Promise.reject(\n\t\t\t\tnew Error(\"Failed to load WhopElements\", { cause: error }),\n\t\t\t);\n\t\t}\n\t});\n};\n\nexport const initWhopElements = (\n\tmaybeWhopElements: WhopElementsConstructor | null,\n\targs: ConstructorParameters<WhopElementsConstructor>,\n): WhopElements | null => {\n\tif (maybeWhopElements === null) {\n\t\treturn null;\n\t}\n\tconst WhopElements = maybeWhopElements;\n\n\treturn new WhopElements(...args);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAAmC;AAMnC,MAAM,0BAA0B,CAAC,QAAyB;AACzD,QAAM,SAAS,IAAI,WAAW,iBAAM,KAAK,IAAI,SAAS,cAAc;AACpE,SAAO;AACR;AAEO,MAAM,aAAa,MAAgC;AACzD,QAAM,UAAU,SAAS;AAAA,IACxB,gBAAgB,iBAAM;AAAA,EACvB;AAEA,aAAW,UAAU,SAAS;AAC7B,QAAI,CAAC,UAAU,CAAC,wBAAwB,OAAO,GAAG,GAAG;AACpD;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAEA,MAAM,eAAe,MAAyB;AAC7C,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AAEb,QAAM,aAAa,SAAS,QAAQ,SAAS;AAE7C,MAAI,CAAC,YAAY;AAChB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,aAAW,YAAY,MAAM;AAE7B,SAAO;AACR;AAEA,IAAI,sBAAsE;AAE1E,IAAI,kBAAsD;AAC1D,IAAI,iBAAsC;AAE1C,MAAM,UAAU,CAAC,WAAuC,CAAC,UAAoB;AAC5E,SAAO,IAAI,MAAM,+BAA+B,EAAE,MAAM,CAAC,CAAC;AAC3D;AAEA,MAAM,SACL,CACC,SAMA,WAED,MAAM;AACL,MAAI,OAAO,cAAc;AACxB,YAAQ,OAAO,YAAY;AAAA,EAC5B,OAAO;AACN,WAAO,IAAI,MAAM,4BAA4B,CAAC;AAAA,EAC/C;AACD;AAEM,MAAM,aAAa,MAA+C;AACxE,MAAI,wBAAwB,MAAM;AACjC,WAAO;AAAA,EACR;AAEA,wBAAsB,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtD,QAAI,OAAO,WAAW,eAAe,OAAO,aAAa,aAAa;AACrE,cAAQ,IAAI;AACZ;AAAA,IACD;AAEA,QAAI,OAAO,cAAc;AACxB,cAAQ,OAAO,YAAY;AAC3B;AAAA,IACD;AAEA,QAAI;AACH,UAAI,SAAS,WAAW;AAExB,UAAI,CAAC,QAAQ;AACZ,iBAAS,aAAa;AAAA,MACvB,WACC,UACA,mBAAmB,QACnB,oBAAoB,MACnB;AAED,eAAO,oBAAoB,QAAQ,cAAc;AACjD,eAAO,oBAAoB,SAAS,eAAe;AAInD,eAAO,YAAY,YAAY,MAAM;AACrC,iBAAS,aAAa;AAAA,MACvB;AAEA,uBAAiB,OAAO,SAAS,MAAM;AACvC,wBAAkB,QAAQ,MAAM;AAChC,aAAO,iBAAiB,QAAQ,cAAc;AAC9C,aAAO,iBAAiB,SAAS,eAAe;AAAA,IACjD,SAAS,OAAO;AACf,UAAI,iBAAiB,OAAO;AAC3B,eAAO,KAAK;AAAA,MACb,OAAO;AACN,eAAO,IAAI,MAAM,+BAA+B,EAAE,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AACA;AAAA,IACD;AAAA,EACD,CAAC;AAED,SAAO,oBAAoB,MAAM,CAAC,UAAU;AAC3C,0BAAsB;AACtB,QAAI,iBAAiB,OAAO;AAC3B,aAAO,QAAQ,OAAO,KAAK;AAAA,IAC5B,OAAO;AACN,aAAO,QAAQ;AAAA,QACd,IAAI,MAAM,+BAA+B,EAAE,OAAO,MAAM,CAAC;AAAA,MAC1D;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAEO,MAAM,mBAAmB,CAC/B,mBACA,SACyB;AACzB,MAAI,sBAAsB,MAAM;AAC/B,WAAO;AAAA,EACR;AACA,QAAM,eAAe;AAErB,SAAO,IAAI,aAAa,GAAG,IAAI;AAChC;","names":[]}
|
package/dist/util.mjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ORIGIN, SCRIPT_URL } from "./url.mjs";
|
|
2
|
+
const isWhopElementsScriptURL = (url)=>{
|
|
3
|
+
const result = url.startsWith(ORIGIN) && url.endsWith("/elements.js");
|
|
4
|
+
return result;
|
|
5
|
+
};
|
|
6
|
+
const findScript = ()=>{
|
|
7
|
+
const scripts = document.querySelectorAll(`script[src^="${ORIGIN}"]`);
|
|
8
|
+
for (const script of scripts){
|
|
9
|
+
if (!script || !isWhopElementsScriptURL(script.src)) {
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
return script;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
const injectScript = ()=>{
|
|
17
|
+
const script = document.createElement("script");
|
|
18
|
+
script.src = SCRIPT_URL;
|
|
19
|
+
const headOrBody = document.head || document.body;
|
|
20
|
+
if (!headOrBody) {
|
|
21
|
+
throw new Error("Expected document.body not to be null. WhopElements requires a <body> element.");
|
|
22
|
+
}
|
|
23
|
+
headOrBody.appendChild(script);
|
|
24
|
+
return script;
|
|
25
|
+
};
|
|
26
|
+
let whopElementsPromise = null;
|
|
27
|
+
let onErrorListener = null;
|
|
28
|
+
let onLoadListener = null;
|
|
29
|
+
const onError = (reject)=>(cause)=>{
|
|
30
|
+
reject(new Error("Failed to load WhopElements", {
|
|
31
|
+
cause
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
const onLoad = (resolve, reject)=>()=>{
|
|
35
|
+
if (window.WhopElements) {
|
|
36
|
+
resolve(window.WhopElements);
|
|
37
|
+
} else {
|
|
38
|
+
reject(new Error("WhopElements not available"));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const loadScript = ()=>{
|
|
42
|
+
if (whopElementsPromise !== null) {
|
|
43
|
+
return whopElementsPromise;
|
|
44
|
+
}
|
|
45
|
+
whopElementsPromise = new Promise((resolve, reject)=>{
|
|
46
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
47
|
+
resolve(null);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (window.WhopElements) {
|
|
51
|
+
resolve(window.WhopElements);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
let script = findScript();
|
|
56
|
+
if (!script) {
|
|
57
|
+
script = injectScript();
|
|
58
|
+
} else if (script && onLoadListener !== null && onErrorListener !== null) {
|
|
59
|
+
script.removeEventListener("load", onLoadListener);
|
|
60
|
+
script.removeEventListener("error", onErrorListener);
|
|
61
|
+
script.parentNode?.removeChild(script);
|
|
62
|
+
script = injectScript();
|
|
63
|
+
}
|
|
64
|
+
onLoadListener = onLoad(resolve, reject);
|
|
65
|
+
onErrorListener = onError(reject);
|
|
66
|
+
script.addEventListener("load", onLoadListener);
|
|
67
|
+
script.addEventListener("error", onErrorListener);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error instanceof Error) {
|
|
70
|
+
reject(error);
|
|
71
|
+
} else {
|
|
72
|
+
reject(new Error("Failed to load WhopElements", {
|
|
73
|
+
cause: error
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return whopElementsPromise.catch((error)=>{
|
|
80
|
+
whopElementsPromise = null;
|
|
81
|
+
if (error instanceof Error) {
|
|
82
|
+
return Promise.reject(error);
|
|
83
|
+
} else {
|
|
84
|
+
return Promise.reject(new Error("Failed to load WhopElements", {
|
|
85
|
+
cause: error
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const initWhopElements = (maybeWhopElements, args)=>{
|
|
91
|
+
if (maybeWhopElements === null) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const WhopElements = maybeWhopElements;
|
|
95
|
+
return new WhopElements(...args);
|
|
96
|
+
};
|
|
97
|
+
export { findScript, initWhopElements, loadScript };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/util.ts"],"sourcesContent":["import type { WhopElements, WhopElementsConstructor } from \"./types\";\nimport { ORIGIN, SCRIPT_URL } from \"./url\";\n\nexport type LoadWhopElements = (\n\t...args: ConstructorParameters<WhopElementsConstructor>\n) => Promise<WhopElements | null>;\n\nconst isWhopElementsScriptURL = (url: string): boolean => {\n\tconst result = url.startsWith(ORIGIN) && url.endsWith(\"/elements.js\");\n\treturn result;\n};\n\nexport const findScript = (): HTMLScriptElement | null => {\n\tconst scripts = document.querySelectorAll<HTMLScriptElement>(\n\t\t`script[src^=\"${ORIGIN}\"]`,\n\t);\n\n\tfor (const script of scripts) {\n\t\tif (!script || !isWhopElementsScriptURL(script.src)) {\n\t\t\tcontinue;\n\t\t}\n\t\treturn script;\n\t}\n\treturn null;\n};\n\nconst injectScript = (): HTMLScriptElement => {\n\tconst script = document.createElement(\"script\");\n\tscript.src = SCRIPT_URL;\n\n\tconst headOrBody = document.head || document.body;\n\n\tif (!headOrBody) {\n\t\tthrow new Error(\n\t\t\t\"Expected document.body not to be null. WhopElements requires a <body> element.\",\n\t\t);\n\t}\n\n\theadOrBody.appendChild(script);\n\n\treturn script;\n};\n\nlet whopElementsPromise: Promise<WhopElementsConstructor | null> | null = null;\n\nlet onErrorListener: ((cause?: unknown) => void) | null = null;\nlet onLoadListener: (() => void) | null = null;\n\nconst onError = (reject: (reason?: unknown) => void) => (cause?: unknown) => {\n\treject(new Error(\"Failed to load WhopElements\", { cause }));\n};\n\nconst onLoad =\n\t(\n\t\tresolve: (\n\t\t\tvalue:\n\t\t\t\t| WhopElementsConstructor\n\t\t\t\t| PromiseLike<WhopElementsConstructor | null>\n\t\t\t\t| null,\n\t\t) => void,\n\t\treject: (reason?: unknown) => void,\n\t) =>\n\t() => {\n\t\tif (window.WhopElements) {\n\t\t\tresolve(window.WhopElements);\n\t\t} else {\n\t\t\treject(new Error(\"WhopElements not available\"));\n\t\t}\n\t};\n\nexport const loadScript = (): Promise<WhopElementsConstructor | null> => {\n\tif (whopElementsPromise !== null) {\n\t\treturn whopElementsPromise;\n\t}\n\n\twhopElementsPromise = new Promise((resolve, reject) => {\n\t\tif (typeof window === \"undefined\" || typeof document === \"undefined\") {\n\t\t\tresolve(null);\n\t\t\treturn;\n\t\t}\n\n\t\tif (window.WhopElements) {\n\t\t\tresolve(window.WhopElements);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tlet script = findScript();\n\n\t\t\tif (!script) {\n\t\t\t\tscript = injectScript();\n\t\t\t} else if (\n\t\t\t\tscript &&\n\t\t\t\tonLoadListener !== null &&\n\t\t\t\tonErrorListener !== null\n\t\t\t) {\n\t\t\t\t// remove event listeners\n\t\t\t\tscript.removeEventListener(\"load\", onLoadListener);\n\t\t\t\tscript.removeEventListener(\"error\", onErrorListener);\n\n\t\t\t\t// if script exists, but we are reloading due to an error,\n\t\t\t\t// reload script to trigger 'load' event\n\t\t\t\tscript.parentNode?.removeChild(script);\n\t\t\t\tscript = injectScript();\n\t\t\t}\n\n\t\t\tonLoadListener = onLoad(resolve, reject);\n\t\t\tonErrorListener = onError(reject);\n\t\t\tscript.addEventListener(\"load\", onLoadListener);\n\t\t\tscript.addEventListener(\"error\", onErrorListener);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\treject(error);\n\t\t\t} else {\n\t\t\t\treject(new Error(\"Failed to load WhopElements\", { cause: error }));\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t});\n\n\treturn whopElementsPromise.catch((error) => {\n\t\twhopElementsPromise = null;\n\t\tif (error instanceof Error) {\n\t\t\treturn Promise.reject(error);\n\t\t} else {\n\t\t\treturn Promise.reject(\n\t\t\t\tnew Error(\"Failed to load WhopElements\", { cause: error }),\n\t\t\t);\n\t\t}\n\t});\n};\n\nexport const initWhopElements = (\n\tmaybeWhopElements: WhopElementsConstructor | null,\n\targs: ConstructorParameters<WhopElementsConstructor>,\n): WhopElements | null => {\n\tif (maybeWhopElements === null) {\n\t\treturn null;\n\t}\n\tconst WhopElements = maybeWhopElements;\n\n\treturn new WhopElements(...args);\n};\n"],"mappings":"AACA,SAAS,QAAQ,kBAAkB;AAMnC,MAAM,0BAA0B,CAAC,QAAyB;AACzD,QAAM,SAAS,IAAI,WAAW,MAAM,KAAK,IAAI,SAAS,cAAc;AACpE,SAAO;AACR;AAEO,MAAM,aAAa,MAAgC;AACzD,QAAM,UAAU,SAAS;AAAA,IACxB,gBAAgB,MAAM;AAAA,EACvB;AAEA,aAAW,UAAU,SAAS;AAC7B,QAAI,CAAC,UAAU,CAAC,wBAAwB,OAAO,GAAG,GAAG;AACpD;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAEA,MAAM,eAAe,MAAyB;AAC7C,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,MAAM;AAEb,QAAM,aAAa,SAAS,QAAQ,SAAS;AAE7C,MAAI,CAAC,YAAY;AAChB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,aAAW,YAAY,MAAM;AAE7B,SAAO;AACR;AAEA,IAAI,sBAAsE;AAE1E,IAAI,kBAAsD;AAC1D,IAAI,iBAAsC;AAE1C,MAAM,UAAU,CAAC,WAAuC,CAAC,UAAoB;AAC5E,SAAO,IAAI,MAAM,+BAA+B,EAAE,MAAM,CAAC,CAAC;AAC3D;AAEA,MAAM,SACL,CACC,SAMA,WAED,MAAM;AACL,MAAI,OAAO,cAAc;AACxB,YAAQ,OAAO,YAAY;AAAA,EAC5B,OAAO;AACN,WAAO,IAAI,MAAM,4BAA4B,CAAC;AAAA,EAC/C;AACD;AAEM,MAAM,aAAa,MAA+C;AACxE,MAAI,wBAAwB,MAAM;AACjC,WAAO;AAAA,EACR;AAEA,wBAAsB,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtD,QAAI,OAAO,WAAW,eAAe,OAAO,aAAa,aAAa;AACrE,cAAQ,IAAI;AACZ;AAAA,IACD;AAEA,QAAI,OAAO,cAAc;AACxB,cAAQ,OAAO,YAAY;AAC3B;AAAA,IACD;AAEA,QAAI;AACH,UAAI,SAAS,WAAW;AAExB,UAAI,CAAC,QAAQ;AACZ,iBAAS,aAAa;AAAA,MACvB,WACC,UACA,mBAAmB,QACnB,oBAAoB,MACnB;AAED,eAAO,oBAAoB,QAAQ,cAAc;AACjD,eAAO,oBAAoB,SAAS,eAAe;AAInD,eAAO,YAAY,YAAY,MAAM;AACrC,iBAAS,aAAa;AAAA,MACvB;AAEA,uBAAiB,OAAO,SAAS,MAAM;AACvC,wBAAkB,QAAQ,MAAM;AAChC,aAAO,iBAAiB,QAAQ,cAAc;AAC9C,aAAO,iBAAiB,SAAS,eAAe;AAAA,IACjD,SAAS,OAAO;AACf,UAAI,iBAAiB,OAAO;AAC3B,eAAO,KAAK;AAAA,MACb,OAAO;AACN,eAAO,IAAI,MAAM,+BAA+B,EAAE,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AACA;AAAA,IACD;AAAA,EACD,CAAC;AAED,SAAO,oBAAoB,MAAM,CAAC,UAAU;AAC3C,0BAAsB;AACtB,QAAI,iBAAiB,OAAO;AAC3B,aAAO,QAAQ,OAAO,KAAK;AAAA,IAC5B,OAAO;AACN,aAAO,QAAQ;AAAA,QACd,IAAI,MAAM,+BAA+B,EAAE,OAAO,MAAM,CAAC;AAAA,MAC1D;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAEO,MAAM,mBAAmB,CAC/B,mBACA,SACyB;AACzB,MAAI,sBAAsB,MAAM;AAC/B,WAAO;AAAA,EACR;AACA,QAAM,eAAe;AAErB,SAAO,IAAI,aAAa,GAAG,IAAI;AAChC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@whop/embedded-components-vanilla-js",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Whop Elements loading utility",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"jsnext:main": "dist/index.mjs",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"typing": "dist/index.d.ts",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"Whop",
|
|
12
|
+
"Whop.js",
|
|
13
|
+
"Elements",
|
|
14
|
+
"embedded",
|
|
15
|
+
"payments",
|
|
16
|
+
"payouts"
|
|
17
|
+
],
|
|
18
|
+
"author": "Whop (https://whop.com)",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/pure/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/pure";
|
package/pure/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
const __defProp = Object.defineProperty;
|
|
5
|
+
const __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
const __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
const __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
const __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
10
|
+
for (const key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
const __reExport = (target, mod, secondTarget) => (
|
|
20
|
+
__copyProps(target, mod, "default"),
|
|
21
|
+
secondTarget && __copyProps(secondTarget, mod, "default")
|
|
22
|
+
);
|
|
23
|
+
const __toCommonJS = (mod) =>
|
|
24
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
const types_exports = {};
|
|
26
|
+
module.exports = __toCommonJS(types_exports);
|
|
27
|
+
__reExport(types_exports, require("../dist/pure"), module.exports);
|
package/pure/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/pure.mjs";
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/types";
|
package/url/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/url";
|
package/url/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
const __defProp = Object.defineProperty;
|
|
5
|
+
const __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
const __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
const __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
const __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
10
|
+
for (const key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
const __reExport = (target, mod, secondTarget) => (
|
|
20
|
+
__copyProps(target, mod, "default"),
|
|
21
|
+
secondTarget && __copyProps(secondTarget, mod, "default")
|
|
22
|
+
);
|
|
23
|
+
const __toCommonJS = (mod) =>
|
|
24
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
const types_exports = {};
|
|
26
|
+
module.exports = __toCommonJS(types_exports);
|
|
27
|
+
__reExport(types_exports, require("../dist/url"), module.exports);
|
package/url/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/url.mjs";
|