@notabene/javascript-sdk 2.0.0-next.2 → 2.0.0-next.20
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.md +21 -0
- package/README.md +281 -231
- package/dist/js/notabene.js +1 -0
- package/dist/notabene.cjs +1 -1
- package/dist/notabene.d.ts +1052 -209
- package/dist/notabene.js +275 -105
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +36 -26
- package/src/__tests__/notabene.test.ts +43 -0
- package/src/components/EmbeddedComponent.ts +141 -22
- package/src/components/__tests__/EmbeddedComponent.test.ts +73 -20
- package/src/ivms/types.ts +230 -152
- package/src/locales.ts +47 -0
- package/src/notabene.ts +243 -90
- package/src/types.ts +723 -144
- package/src/utils/MessageEventManager.ts +70 -12
- package/src/utils/__tests__/MessageEventManager.test.ts +13 -5
- package/src/utils/arbitraries.ts +9 -4
- package/.editorconfig +0 -10
- package/.gitlab-ci.yml +0 -85
- package/.husky/commit-msg +0 -4
- package/.husky/pre-commit +0 -4
- package/.husky/pre-push +0 -4
- package/.prettierrc +0 -4
- package/.releaserc.json +0 -16
- package/.vscode/extensions.json +0 -3
- package/.vscode/settings.json +0 -11
- package/.yarn/releases/yarn-berry.cjs +0 -925
- package/.yarnrc.yml +0 -3
- package/CODEOWNERS +0 -1
- package/api-extractor.json +0 -434
- package/eslint.config.js +0 -24
- package/etc/javascript-sdk.api.md +0 -363
- package/index.html +0 -137
- package/temp/javascript-sdk.api.json +0 -3509
- package/temp/javascript-sdk.api.md +0 -363
- package/ts-out/src/__tests__/notabene.test.d.ts +0 -1
- package/ts-out/src/__tests__/notabene.test.js +0 -88
- package/ts-out/src/arbitraries.d.ts +0 -4
- package/ts-out/src/arbitraries.js +0 -8
- package/ts-out/src/components/EmbeddedComponent.d.ts +0 -25
- package/ts-out/src/components/EmbeddedComponent.js +0 -87
- package/ts-out/src/components/__tests__/EmbeddedComponent.test.d.ts +0 -1
- package/ts-out/src/components/__tests__/EmbeddedComponent.test.js +0 -132
- package/ts-out/src/ivms/types.d.ts +0 -252
- package/ts-out/src/ivms/types.js +0 -1
- package/ts-out/src/notabene.d.ts +0 -35
- package/ts-out/src/notabene.js +0 -59
- package/ts-out/src/types.d.ts +0 -357
- package/ts-out/src/types.js +0 -85
- package/ts-out/src/utils/MessageEventManager.d.ts +0 -12
- package/ts-out/src/utils/MessageEventManager.js +0 -45
- package/ts-out/src/utils/__tests__/MessageEventManager.test.d.ts +0 -1
- package/ts-out/src/utils/__tests__/MessageEventManager.test.js +0 -73
- package/ts-out/src/utils/arbitraries.d.ts +0 -6
- package/ts-out/src/utils/arbitraries.js +0 -7
- package/ts-out/src/utils/caip.d.ts +0 -13
- package/ts-out/src/utils/caip.js +0 -15
- package/ts-out/src/utils/urls.d.ts +0 -1
- package/ts-out/src/utils/urls.js +0 -14
- package/ts-out/tsconfig.tsbuildinfo +0 -1
- package/tsconfig.json +0 -22
- package/tsconfig.tsbuildinfo +0 -1
- package/vite.config.js +0 -13
package/dist/notabene.js
CHANGED
|
@@ -1,187 +1,357 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (
|
|
4
|
-
var
|
|
5
|
-
class
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var m = (t, e, s) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
|
|
3
|
+
var o = (t, e, s) => m(t, typeof e != "symbol" ? e + "" : e, s);
|
|
4
|
+
var u = /* @__PURE__ */ ((t) => (t.PRIVATE = "WALLET", t.VASP = "VASP", t))(u || {}), f = /* @__PURE__ */ ((t) => (t.NATURAL = "natural", t.LEGAL = "legal", t.SELF = "self", t))(f || {}), E = /* @__PURE__ */ ((t) => (t.EMPTY = "empty", t.VERIFY = "verify", t.PENDING = "pending", t.VERIFIED = "verified", t.BANNED = "banned", t))(E || {}), a = /* @__PURE__ */ ((t) => (t.COMPLETE = "complete", t.RESIZE = "resize", t.RESULT = "result", t.READY = "ready", t.INVALID = "invalid", t.ERROR = "error", t.CANCEL = "cancel", t))(a || {}), d = /* @__PURE__ */ ((t) => (t.UPDATE = "update", t.REQUEST_RESPONSE = "requestResponse", t))(d || {}), p = /* @__PURE__ */ ((t) => (t.PENDING = "pending", t.FAILED = "rejected", t.FLAGGED = "flagged", t.VERIFIED = "verified", t))(p || {}), g = /* @__PURE__ */ ((t) => (t.SelfDeclaration = "self-declaration", t.PersonalSignEIP191 = "eip-191", t.SIWE = "siwe", t.PersonalSignEIP712 = "eip-712", t.PersonalSignBIP137 = "bip-137", t.PersonalSignXPUB = "xpub", t.MicroTransfer = "microtransfer", t.Screenshot = "screenshot", t))(g || {});
|
|
5
|
+
class v {
|
|
6
6
|
constructor() {
|
|
7
7
|
o(this, "listeners", /* @__PURE__ */ new Map());
|
|
8
8
|
o(this, "port");
|
|
9
9
|
this.handleMessage = this.handleMessage.bind(this);
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Sets up the message port for communication.
|
|
13
|
+
*
|
|
14
|
+
* Initializes the MessagePort for receiving messages by setting up the message handler
|
|
15
|
+
* and starting the port.
|
|
16
|
+
*
|
|
17
|
+
* @param port - The MessagePort instance to use for communication
|
|
18
|
+
*/
|
|
11
19
|
setPort(e) {
|
|
12
20
|
this.port = e, this.port.onmessage = this.handleMessage, this.port.start();
|
|
13
21
|
}
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Registers a callback for a specific message type.
|
|
24
|
+
*
|
|
25
|
+
* When messages of the specified type are received, the callback will be executed
|
|
26
|
+
* with the message data.
|
|
27
|
+
*
|
|
28
|
+
* @param messageType - The type of message to listen for
|
|
29
|
+
* @param callback - The callback function to execute when matching messages are received
|
|
30
|
+
*/
|
|
31
|
+
on(e, s) {
|
|
32
|
+
this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(s);
|
|
16
33
|
}
|
|
17
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Removes a callback for a specific message type.
|
|
36
|
+
*
|
|
37
|
+
* If the callback is the last one registered for the message type,
|
|
38
|
+
* the message type entry will be removed entirely.
|
|
39
|
+
*
|
|
40
|
+
* @param messageType - The type of message to remove listener from
|
|
41
|
+
* @param callback - The callback function to remove
|
|
42
|
+
*/
|
|
43
|
+
off(e, s) {
|
|
18
44
|
const r = this.listeners.get(e);
|
|
19
|
-
r && (r.delete(
|
|
45
|
+
r && (r.delete(s), r.size === 0 && this.listeners.delete(e));
|
|
20
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Internal message handler for processing received messages.
|
|
49
|
+
*
|
|
50
|
+
* Validates incoming messages and dispatches them to registered callbacks
|
|
51
|
+
* based on the message type.
|
|
52
|
+
*
|
|
53
|
+
* @param event - The message event containing the component message
|
|
54
|
+
*/
|
|
21
55
|
handleMessage(e) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
i && i.forEach((n) => n(t));
|
|
56
|
+
const s = e.data;
|
|
57
|
+
if (typeof s == "object" && s !== null && "type" in s) {
|
|
58
|
+
const r = s.type, i = this.listeners.get(r);
|
|
59
|
+
i && i.forEach((n) => n(s));
|
|
27
60
|
}
|
|
28
61
|
}
|
|
29
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Sends a message through the message port
|
|
64
|
+
* @param message The host message to send
|
|
65
|
+
*/
|
|
30
66
|
send(e) {
|
|
31
|
-
|
|
32
|
-
throw new Error("No port set");
|
|
33
|
-
this.port.postMessage(e);
|
|
67
|
+
this.port && this.port.postMessage(e);
|
|
34
68
|
}
|
|
35
69
|
}
|
|
36
|
-
class
|
|
37
|
-
|
|
70
|
+
class I {
|
|
71
|
+
/**
|
|
72
|
+
* Creates an instance of EmbeddedComponent.
|
|
73
|
+
* @param url - The URL of the embedded component
|
|
74
|
+
* @param value - The initial transaction value
|
|
75
|
+
*/
|
|
76
|
+
constructor(e, s, r) {
|
|
38
77
|
o(this, "_url");
|
|
39
78
|
o(this, "_value");
|
|
79
|
+
o(this, "_options");
|
|
40
80
|
o(this, "_errors", []);
|
|
41
81
|
o(this, "iframe");
|
|
42
82
|
o(this, "eventManager");
|
|
43
|
-
o(this, "
|
|
44
|
-
this._url = e, this._value =
|
|
45
|
-
|
|
46
|
-
}), this.on(
|
|
47
|
-
|
|
83
|
+
o(this, "modal");
|
|
84
|
+
this._url = e, this._value = s, this._options = r, this.eventManager = new v(), this.on(a.INVALID, (i) => {
|
|
85
|
+
i.type === a.INVALID && (this._errors = i.errors, this._value = i.value);
|
|
86
|
+
}), this.on(a.RESIZE, (i) => {
|
|
87
|
+
i.type === a.RESIZE && this.iframe && (this.iframe.style.height = `${i.height}px`);
|
|
48
88
|
});
|
|
49
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Gets the URL of the embedded component
|
|
92
|
+
* @returns The URL of the embedded component
|
|
93
|
+
*/
|
|
50
94
|
get url() {
|
|
51
95
|
return this._url;
|
|
52
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Gets the current transaction value
|
|
99
|
+
* @returns The current transaction value
|
|
100
|
+
*/
|
|
53
101
|
get value() {
|
|
54
102
|
return this._value;
|
|
55
103
|
}
|
|
104
|
+
get options() {
|
|
105
|
+
return this._options;
|
|
106
|
+
}
|
|
56
107
|
get errors() {
|
|
57
108
|
return this._errors;
|
|
58
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Opens the component URL in the current window
|
|
112
|
+
*/
|
|
59
113
|
open() {
|
|
60
114
|
document.location.href = this.url;
|
|
61
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Mounts the component to a parent element
|
|
118
|
+
* @param parentId - The ID of the parent element
|
|
119
|
+
* @throws Will throw an error if the parent element is not found
|
|
120
|
+
*/
|
|
62
121
|
mount(e) {
|
|
122
|
+
const s = document.querySelector(e);
|
|
123
|
+
if (!s) throw new Error(`parentID ${e} not found`);
|
|
124
|
+
this.embed(s);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Embeds the component into a parent element
|
|
128
|
+
* @param parent - The parent element to embed the component into
|
|
129
|
+
*/
|
|
130
|
+
embed(e, s = !1) {
|
|
63
131
|
var r, i;
|
|
64
|
-
this.iframe = document.createElement("iframe"), this.iframe.src = this.url, this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", window.addEventListener("message", (n) => {
|
|
65
|
-
var
|
|
66
|
-
n.source === ((
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
132
|
+
this.removeEmbed(), this.iframe = document.createElement("iframe"), this.iframe.src = this.url + (s ? "" : "&embedded=true"), this.iframe.allow = "web-share", this.iframe.style.width = "100%", this.iframe.style.height = "100px", this.iframe.style.border = "none", this.iframe.style.overflow = "hidden", e.appendChild(this.iframe), window.addEventListener("message", (n) => {
|
|
133
|
+
var h, l;
|
|
134
|
+
n.source === ((h = this.iframe) == null ? void 0 : h.contentWindow) && ((l = this.eventManager) == null || l.setPort(n.ports[0]));
|
|
135
|
+
}), (i = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || i.focus();
|
|
136
|
+
}
|
|
137
|
+
removeEmbed() {
|
|
138
|
+
this.iframe && this.iframe.remove();
|
|
71
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Sends a message to the embedded component
|
|
142
|
+
* @param message - The message to send
|
|
143
|
+
*/
|
|
72
144
|
send(e) {
|
|
73
145
|
this.eventManager.send(e);
|
|
74
146
|
}
|
|
75
|
-
|
|
76
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Adds an event listener for a specific message type
|
|
149
|
+
* @param messageType - The type of message to listen for
|
|
150
|
+
* @param callback - The callback function to execute when the message is received
|
|
151
|
+
*/
|
|
152
|
+
on(e, s) {
|
|
153
|
+
this.eventManager.on(e, s);
|
|
77
154
|
}
|
|
78
|
-
|
|
79
|
-
|
|
155
|
+
/**
|
|
156
|
+
* Removes an event listener for a specific message type
|
|
157
|
+
* @param messageType - The type of message to stop listening for
|
|
158
|
+
* @param callback - The callback function to remove
|
|
159
|
+
*/
|
|
160
|
+
off(e, s) {
|
|
161
|
+
this.eventManager.off(e, s);
|
|
80
162
|
}
|
|
81
|
-
|
|
82
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Updates the transaction value and sends an update message to the component
|
|
165
|
+
* @param value - The new transaction value
|
|
166
|
+
*/
|
|
167
|
+
update(e, s) {
|
|
168
|
+
this._value = e, s && (this._options = s), this.send({ type: d.UPDATE, value: e, options: this._options });
|
|
83
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Waits for the component to complete and returns the transaction response
|
|
172
|
+
* @returns A promise that resolves with the transaction response
|
|
173
|
+
*/
|
|
84
174
|
completion() {
|
|
85
|
-
return new Promise((e,
|
|
86
|
-
this.on(
|
|
175
|
+
return new Promise((e, s) => {
|
|
176
|
+
this.on(a.COMPLETE, (r) => {
|
|
87
177
|
e(r.response);
|
|
88
178
|
}), this.on("error", (r) => {
|
|
89
|
-
|
|
179
|
+
s(new Error(r.message));
|
|
90
180
|
});
|
|
91
181
|
});
|
|
92
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Opens the component in a modal dialog
|
|
185
|
+
*/
|
|
186
|
+
openModal() {
|
|
187
|
+
return this.modal && this.closeModal(), this.modal = document.createElement("dialog"), this.modal.style.border = "none", this.modal.style.backgroundColor = "white", this.modal.style.maxWidth = "100vw", this.modal.style.maxHeight = "100vh", this.modal.style.width = "600px", this.modal.style.height = "600px", document.body.appendChild(this.modal), this.embed(this.modal, !0), this.on(a.CANCEL, () => {
|
|
188
|
+
this.closeModal();
|
|
189
|
+
}), this.on(a.COMPLETE, () => {
|
|
190
|
+
this.closeModal();
|
|
191
|
+
}), this.modal.showModal(), this.modal.addEventListener("click", () => {
|
|
192
|
+
this.closeModal();
|
|
193
|
+
}), this.completion();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Closes the modal dialog
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
closeModal() {
|
|
200
|
+
var e;
|
|
201
|
+
this.modal && ((e = this.modal) == null || e.close(), this.modal.remove(), this.modal = void 0);
|
|
202
|
+
}
|
|
93
203
|
}
|
|
94
|
-
function
|
|
95
|
-
return Object.entries(
|
|
96
|
-
if (!(e &&
|
|
204
|
+
function w(t) {
|
|
205
|
+
return Object.entries(t).map(([e, s]) => {
|
|
206
|
+
if (!(e && s)) return;
|
|
97
207
|
const r = encodeURIComponent(e), i = encodeURIComponent(
|
|
98
|
-
typeof
|
|
208
|
+
typeof s == "object" ? JSON.stringify(s) : s
|
|
99
209
|
);
|
|
100
210
|
return `${r}=${i}`;
|
|
101
211
|
}).filter((e) => !!e).join("&");
|
|
102
212
|
}
|
|
103
|
-
class
|
|
213
|
+
class b {
|
|
214
|
+
/**
|
|
215
|
+
* Creates a new instance of the Notabene SDK
|
|
216
|
+
*
|
|
217
|
+
* @param config - Configuration options for the Notabene SDK
|
|
218
|
+
*/
|
|
104
219
|
constructor(e) {
|
|
105
220
|
o(this, "nodeUrl");
|
|
106
221
|
o(this, "authToken");
|
|
107
222
|
o(this, "uxUrl");
|
|
108
223
|
o(this, "theme");
|
|
109
|
-
o(this, "
|
|
110
|
-
this.uxUrl = e.uxUrl || "https://
|
|
224
|
+
o(this, "locale");
|
|
225
|
+
this.uxUrl = e.uxUrl || "https://connect.notabene.id", this.nodeUrl = e.nodeUrl, this.authToken = e.authToken, this.theme = e.theme, this.locale = e.locale;
|
|
111
226
|
}
|
|
112
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Generates a URL for a Notabene component
|
|
229
|
+
*
|
|
230
|
+
* @param path - The path of the component
|
|
231
|
+
* @param value - Transaction data
|
|
232
|
+
* @param configuration - Optional transaction configuration
|
|
233
|
+
* @param callbacks - Optional callback configuration
|
|
234
|
+
* @returns component URL
|
|
235
|
+
* @internal
|
|
236
|
+
*/
|
|
237
|
+
componentUrl(e, s, r, i) {
|
|
113
238
|
const n = new URL(this.uxUrl);
|
|
114
239
|
n.pathname = e;
|
|
115
|
-
const
|
|
240
|
+
const h = w({
|
|
116
241
|
authToken: this.authToken,
|
|
117
|
-
value:
|
|
242
|
+
value: s,
|
|
118
243
|
configuration: r
|
|
119
244
|
});
|
|
120
|
-
return n.hash =
|
|
245
|
+
return n.hash = h, this.nodeUrl && n.searchParams.set("nodeUrl", this.nodeUrl), this.theme && n.searchParams.set("theme", JSON.stringify(this.theme)), this.locale && n.searchParams.set("locale", this.locale), i && (i.callback && n.searchParams.set("callback_url", i.callback), i.redirectUri && n.searchParams.set("redirect_uri", i.redirectUri)), n.toString();
|
|
121
246
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
247
|
+
/**
|
|
248
|
+
* Creates a new embedded component
|
|
249
|
+
*
|
|
250
|
+
* @param path - The path of the component
|
|
251
|
+
* @param value - Transaction data
|
|
252
|
+
* @param options - Optional transaction options
|
|
253
|
+
* @param callbacks - Optional callback configuration
|
|
254
|
+
* @returns A new EmbeddedComponent instance
|
|
255
|
+
* @internal
|
|
256
|
+
*/
|
|
257
|
+
createComponent(e, s, r, i) {
|
|
258
|
+
return new I(
|
|
259
|
+
this.componentUrl(e, s, r, i),
|
|
260
|
+
s,
|
|
261
|
+
r
|
|
126
262
|
);
|
|
127
263
|
}
|
|
128
|
-
|
|
129
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Creates a withdrawal assist component
|
|
266
|
+
*
|
|
267
|
+
* @param value - Withdrawal transaction data
|
|
268
|
+
* @param options - Optional transaction options
|
|
269
|
+
* @param callbacks - Optional callback configuration
|
|
270
|
+
* @returns A new EmbeddedComponent instance for withdrawal assistance
|
|
271
|
+
*/
|
|
272
|
+
createWithdrawalAssist(e, s, r) {
|
|
273
|
+
return this.createComponent(
|
|
274
|
+
"withdrawal-assist",
|
|
275
|
+
e,
|
|
276
|
+
s,
|
|
277
|
+
r
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Creates a deposit assist component
|
|
282
|
+
*
|
|
283
|
+
* @param value - Deposit transaction data
|
|
284
|
+
* @param options - Optional transaction options
|
|
285
|
+
* @param callbacks - Optional callback configuration
|
|
286
|
+
* @returns A new EmbeddedComponent instance for deposit assistance
|
|
287
|
+
* @alpha
|
|
288
|
+
*/
|
|
289
|
+
createDepositAssist(e, s, r) {
|
|
290
|
+
return this.createComponent(
|
|
291
|
+
"deposit-assist",
|
|
292
|
+
e,
|
|
293
|
+
s,
|
|
294
|
+
r
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Creates a connect component
|
|
299
|
+
*
|
|
300
|
+
* @param value - Connection request data
|
|
301
|
+
* @param options - Optional transaction options
|
|
302
|
+
* @param callbacks - Optional callback configuration
|
|
303
|
+
* @returns A new EmbeddedComponent instance for connection
|
|
304
|
+
* @alpha
|
|
305
|
+
*/
|
|
306
|
+
createConnectWallet(e, s, r) {
|
|
307
|
+
return this.createComponent(
|
|
308
|
+
"connect",
|
|
309
|
+
e,
|
|
310
|
+
s,
|
|
311
|
+
r
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Creates a deposit request component
|
|
316
|
+
*
|
|
317
|
+
* @param value - Deposit request data
|
|
318
|
+
* @param options - Optional transaction options
|
|
319
|
+
* @param callbacks - Optional callback configuration
|
|
320
|
+
* @returns A new EmbeddedComponent instance for deposit requests
|
|
321
|
+
* @public
|
|
322
|
+
*/
|
|
323
|
+
createDepositRequest(e, s, r) {
|
|
324
|
+
return this.createComponent(
|
|
325
|
+
"deposit-request",
|
|
326
|
+
e,
|
|
327
|
+
s,
|
|
328
|
+
r
|
|
329
|
+
);
|
|
130
330
|
}
|
|
331
|
+
/**
|
|
332
|
+
* Decodes a URL fragment into an object
|
|
333
|
+
*
|
|
334
|
+
* @param fragment - The URL fragment to decode
|
|
335
|
+
* @returns An object containing the decoded key-value pairs
|
|
336
|
+
*/
|
|
131
337
|
decodeFragmentToObject(e) {
|
|
132
338
|
return e.slice(1).split("&").reduce(
|
|
133
339
|
(r, i) => {
|
|
134
|
-
const [n,
|
|
135
|
-
return r[decodeURIComponent(n)] = decodeURIComponent(
|
|
340
|
+
const [n, h] = i.split("=");
|
|
341
|
+
return r[decodeURIComponent(n)] = decodeURIComponent(h), r;
|
|
136
342
|
},
|
|
137
343
|
{}
|
|
138
344
|
);
|
|
139
345
|
}
|
|
140
|
-
// private openModal(url: string): void {
|
|
141
|
-
// if (this.modal) {
|
|
142
|
-
// this.closeModal();
|
|
143
|
-
// }
|
|
144
|
-
// this.modal = document.createElement('div');
|
|
145
|
-
// this.modal.style.position = 'fixed';
|
|
146
|
-
// this.modal.style.top = '0';
|
|
147
|
-
// this.modal.style.left = '0';
|
|
148
|
-
// this.modal.style.width = '100%';
|
|
149
|
-
// this.modal.style.height = '100%';
|
|
150
|
-
// this.modal.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
|
|
151
|
-
// this.modal.style.display = 'flex';
|
|
152
|
-
// this.modal.style.justifyContent = 'center';
|
|
153
|
-
// this.modal.style.alignItems = 'center';
|
|
154
|
-
// const iframe = document.createElement('iframe');
|
|
155
|
-
// iframe.src = url;
|
|
156
|
-
// iframe.setAttribute('allowtransparency', 'true');
|
|
157
|
-
// // iframe.allowtransparency = true;
|
|
158
|
-
// iframe.style.backgroundColor = 'transparent';
|
|
159
|
-
// iframe.style.width = '90%';
|
|
160
|
-
// iframe.style.height = '90%';
|
|
161
|
-
// iframe.style.border = 'none';
|
|
162
|
-
// iframe.style.overflow = 'hidden';
|
|
163
|
-
// this.modal.appendChild(iframe);
|
|
164
|
-
// document.body.appendChild(this.modal);
|
|
165
|
-
// this.modal.addEventListener('click', () => {
|
|
166
|
-
// console.log('click');
|
|
167
|
-
// this.closeModal();
|
|
168
|
-
// });
|
|
169
|
-
// document.addEventListener('keydown', ({ key }) => {
|
|
170
|
-
// console.log(`key: ${key}`);
|
|
171
|
-
// if (key === 'Escape') {
|
|
172
|
-
// console.log('esc');
|
|
173
|
-
// this.closeModal();
|
|
174
|
-
// }
|
|
175
|
-
// });
|
|
176
|
-
// }
|
|
177
|
-
// private closeModal(): void {
|
|
178
|
-
// if (this.modal) {
|
|
179
|
-
// console.log('this.closeModal');
|
|
180
|
-
// this.modal.remove();
|
|
181
|
-
// this.modal = undefined;
|
|
182
|
-
// }
|
|
183
|
-
// }
|
|
184
346
|
}
|
|
185
347
|
export {
|
|
186
|
-
|
|
348
|
+
u as AgentType,
|
|
349
|
+
a as CMType,
|
|
350
|
+
I as EmbeddedComponent,
|
|
351
|
+
d as HMType,
|
|
352
|
+
f as PersonType,
|
|
353
|
+
p as ProofStatus,
|
|
354
|
+
g as ProofTypes,
|
|
355
|
+
E as Status,
|
|
356
|
+
b as default
|
|
187
357
|
};
|
package/dist/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -9,51 +9,61 @@
|
|
|
9
9
|
},
|
|
10
10
|
"author": "Notabene <developers@notabene.id>",
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "2.0.0-next.
|
|
12
|
+
"version": "2.0.0-next.20",
|
|
13
13
|
"source": "src/notabene.ts",
|
|
14
14
|
"main": "dist/notabene.js",
|
|
15
15
|
"types": "dist/notabene.d.ts",
|
|
16
16
|
"browserslist": "> 0.5%, last 2 versions, not dead",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"src",
|
|
20
|
+
"package.json",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
17
23
|
"scripts": {
|
|
24
|
+
"docs": "typedoc --options typedoc.json",
|
|
18
25
|
"prepare": "husky install",
|
|
19
26
|
"dev": "vite",
|
|
20
27
|
"preview": "vite preview",
|
|
21
28
|
"watch": "parcel watch",
|
|
22
29
|
"build:dev": "yarn build && yarn dev",
|
|
23
30
|
"build:clean": "rimraf dist/ ts-out",
|
|
24
|
-
"build": "vite build && tsc && api-extractor run",
|
|
31
|
+
"build": "yarn lint && vite build && tsc && api-extractor run && yarn docs ",
|
|
25
32
|
"lint": "eslint .",
|
|
33
|
+
"format": "prettier --write .",
|
|
26
34
|
"test": "vitest",
|
|
27
|
-
"release": "semantic-release"
|
|
35
|
+
"release": "semantic-release",
|
|
36
|
+
"publish": "yarn build && npm publish --tag next"
|
|
28
37
|
},
|
|
29
38
|
"devDependencies": {
|
|
30
|
-
"@commitlint/cli": "^
|
|
31
|
-
"@commitlint/config-conventional": "^
|
|
32
|
-
"@eslint/js": "^9.
|
|
33
|
-
"@fast-check/vitest": "^0.1.
|
|
34
|
-
"@microsoft/api-extractor": "^7.47.
|
|
39
|
+
"@commitlint/cli": "^19.5.0",
|
|
40
|
+
"@commitlint/config-conventional": "^19.5.0",
|
|
41
|
+
"@eslint/js": "^9.13.0",
|
|
42
|
+
"@fast-check/vitest": "^0.1.3",
|
|
43
|
+
"@microsoft/api-extractor": "^7.47.11",
|
|
35
44
|
"@semantic-release/git": "^10.0.1",
|
|
36
|
-
"@semantic-release/gitlab": "^
|
|
37
|
-
"@semantic-release/npm": "^
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
39
|
-
"@typescript-eslint/parser": "^8.
|
|
40
|
-
"eslint": "^9.
|
|
45
|
+
"@semantic-release/gitlab": "^13.2.1",
|
|
46
|
+
"@semantic-release/npm": "^12.0.1",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.11.0",
|
|
48
|
+
"@typescript-eslint/parser": "^8.11.0",
|
|
49
|
+
"eslint": "^9.13.0",
|
|
41
50
|
"eslint-config-prettier": "^9.1.0",
|
|
42
|
-
"eslint-config-standard": "^17.1.0",
|
|
43
|
-
"eslint-plugin-import": "^2.25.4",
|
|
44
|
-
"eslint-plugin-node": "^11.1.0",
|
|
45
51
|
"eslint-plugin-prettier": "^5.2.1",
|
|
46
|
-
"fast-check": "^3.
|
|
47
|
-
"globals": "^15.
|
|
48
|
-
"husky": "^
|
|
49
|
-
"
|
|
50
|
-
"
|
|
52
|
+
"fast-check": "^3.22.0",
|
|
53
|
+
"globals": "^15.11.0",
|
|
54
|
+
"husky": "^9.1.6",
|
|
55
|
+
"jsdom": "^25.0.1",
|
|
56
|
+
"lint-staged": "^15.2.10",
|
|
57
|
+
"organize-imports-cli": "^0.10.0",
|
|
51
58
|
"prettier": "^3.3.3",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
59
|
+
"rimraf": "^6.0.1",
|
|
60
|
+
"semantic-release": "^24.1.3",
|
|
61
|
+
"typedoc": "^0.26.10",
|
|
62
|
+
"typedoc-plugin-markdown": "^4.2.9",
|
|
63
|
+
"typescript": "^5.6.3",
|
|
64
|
+
"typescript-eslint": "^8.11.0",
|
|
65
|
+
"vite": "^5.4.10",
|
|
66
|
+
"vitest": "^2.1.3"
|
|
57
67
|
},
|
|
58
68
|
"lint-staged": {
|
|
59
69
|
"*.ts": [
|
|
@@ -2,6 +2,7 @@ import { fc, test } from '@fast-check/vitest';
|
|
|
2
2
|
import { describe } from 'vitest';
|
|
3
3
|
import { abitraryCallbackOptions, arbitraryComponent } from '../arbitraries';
|
|
4
4
|
import Notabene from '../notabene';
|
|
5
|
+
import { arbitraryLocale } from '../utils/arbitraries';
|
|
5
6
|
|
|
6
7
|
describe('Notabene', () => {
|
|
7
8
|
describe('defaults', () => {
|
|
@@ -28,6 +29,48 @@ describe('Notabene', () => {
|
|
|
28
29
|
);
|
|
29
30
|
});
|
|
30
31
|
|
|
32
|
+
describe('locale', () => {
|
|
33
|
+
test.prop([
|
|
34
|
+
fc.string({ minLength: 3 }),
|
|
35
|
+
fc.webUrl(),
|
|
36
|
+
arbitraryComponent(),
|
|
37
|
+
fc.object(),
|
|
38
|
+
arbitraryLocale(),
|
|
39
|
+
])(
|
|
40
|
+
'Should set the correct values',
|
|
41
|
+
(authToken, nodeUrl, component, value, locale) => {
|
|
42
|
+
const notabene = new Notabene({
|
|
43
|
+
nodeUrl,
|
|
44
|
+
authToken,
|
|
45
|
+
locale,
|
|
46
|
+
});
|
|
47
|
+
const url = new URL(notabene.componentUrl(component, value));
|
|
48
|
+
return (
|
|
49
|
+
url.hash ===
|
|
50
|
+
`#authToken=${encodeURIComponent(authToken)}&value=${encodeURIComponent(JSON.stringify(value))}` &&
|
|
51
|
+
url.searchParams.get('nodeUrl') === nodeUrl &&
|
|
52
|
+
url.searchParams.get('locale') === locale &&
|
|
53
|
+
url.pathname === `/${component}`
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('minimal', () => {
|
|
60
|
+
test.prop([arbitraryComponent(), fc.object()])(
|
|
61
|
+
'Should set the correct values',
|
|
62
|
+
(component, value) => {
|
|
63
|
+
const notabene = new Notabene({});
|
|
64
|
+
const url = new URL(notabene.componentUrl(component, value));
|
|
65
|
+
return (
|
|
66
|
+
url.hash === `#value=${encodeURIComponent(JSON.stringify(value))}` &&
|
|
67
|
+
url.hostname === 'connect.notabene.id' &&
|
|
68
|
+
url.pathname === `/${component}`
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
31
74
|
describe('with uxUrl', () => {
|
|
32
75
|
test.prop([
|
|
33
76
|
fc.string({ minLength: 3 }),
|