@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.
Files changed (64) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +281 -231
  3. package/dist/js/notabene.js +1 -0
  4. package/dist/notabene.cjs +1 -1
  5. package/dist/notabene.d.ts +1052 -209
  6. package/dist/notabene.js +275 -105
  7. package/dist/tsdoc-metadata.json +1 -1
  8. package/package.json +36 -26
  9. package/src/__tests__/notabene.test.ts +43 -0
  10. package/src/components/EmbeddedComponent.ts +141 -22
  11. package/src/components/__tests__/EmbeddedComponent.test.ts +73 -20
  12. package/src/ivms/types.ts +230 -152
  13. package/src/locales.ts +47 -0
  14. package/src/notabene.ts +243 -90
  15. package/src/types.ts +723 -144
  16. package/src/utils/MessageEventManager.ts +70 -12
  17. package/src/utils/__tests__/MessageEventManager.test.ts +13 -5
  18. package/src/utils/arbitraries.ts +9 -4
  19. package/.editorconfig +0 -10
  20. package/.gitlab-ci.yml +0 -85
  21. package/.husky/commit-msg +0 -4
  22. package/.husky/pre-commit +0 -4
  23. package/.husky/pre-push +0 -4
  24. package/.prettierrc +0 -4
  25. package/.releaserc.json +0 -16
  26. package/.vscode/extensions.json +0 -3
  27. package/.vscode/settings.json +0 -11
  28. package/.yarn/releases/yarn-berry.cjs +0 -925
  29. package/.yarnrc.yml +0 -3
  30. package/CODEOWNERS +0 -1
  31. package/api-extractor.json +0 -434
  32. package/eslint.config.js +0 -24
  33. package/etc/javascript-sdk.api.md +0 -363
  34. package/index.html +0 -137
  35. package/temp/javascript-sdk.api.json +0 -3509
  36. package/temp/javascript-sdk.api.md +0 -363
  37. package/ts-out/src/__tests__/notabene.test.d.ts +0 -1
  38. package/ts-out/src/__tests__/notabene.test.js +0 -88
  39. package/ts-out/src/arbitraries.d.ts +0 -4
  40. package/ts-out/src/arbitraries.js +0 -8
  41. package/ts-out/src/components/EmbeddedComponent.d.ts +0 -25
  42. package/ts-out/src/components/EmbeddedComponent.js +0 -87
  43. package/ts-out/src/components/__tests__/EmbeddedComponent.test.d.ts +0 -1
  44. package/ts-out/src/components/__tests__/EmbeddedComponent.test.js +0 -132
  45. package/ts-out/src/ivms/types.d.ts +0 -252
  46. package/ts-out/src/ivms/types.js +0 -1
  47. package/ts-out/src/notabene.d.ts +0 -35
  48. package/ts-out/src/notabene.js +0 -59
  49. package/ts-out/src/types.d.ts +0 -357
  50. package/ts-out/src/types.js +0 -85
  51. package/ts-out/src/utils/MessageEventManager.d.ts +0 -12
  52. package/ts-out/src/utils/MessageEventManager.js +0 -45
  53. package/ts-out/src/utils/__tests__/MessageEventManager.test.d.ts +0 -1
  54. package/ts-out/src/utils/__tests__/MessageEventManager.test.js +0 -73
  55. package/ts-out/src/utils/arbitraries.d.ts +0 -6
  56. package/ts-out/src/utils/arbitraries.js +0 -7
  57. package/ts-out/src/utils/caip.d.ts +0 -13
  58. package/ts-out/src/utils/caip.js +0 -15
  59. package/ts-out/src/utils/urls.d.ts +0 -1
  60. package/ts-out/src/utils/urls.js +0 -14
  61. package/ts-out/tsconfig.tsbuildinfo +0 -1
  62. package/tsconfig.json +0 -22
  63. package/tsconfig.tsbuildinfo +0 -1
  64. package/vite.config.js +0 -13
package/dist/notabene.js CHANGED
@@ -1,187 +1,357 @@
1
- var l = Object.defineProperty;
2
- var u = (s, e, t) => e in s ? l(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var o = (s, e, t) => u(s, typeof e != "symbol" ? e + "" : e, t);
4
- var h = /* @__PURE__ */ ((s) => (s.COMPLETE = "complete", s.RESIZE = "resize", s.RESULT = "result", s.READY = "ready", s.INVALID = "invalid", s.MODAL = "openModal", s.ERROR = "error", s.CLOSE = "closeModal", s.CANCEL = "cancel", s))(h || {}), c = /* @__PURE__ */ ((s) => (s.UPDATE = "update", s.REQUEST_RESPONSE = "requestResponse", s))(c || {});
5
- class m {
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
- on(e, t) {
15
- this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t);
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
- off(e, t) {
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(t), r.size === 0 && this.listeners.delete(e));
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
- console.log("received message", e.data);
23
- const t = e.data;
24
- if (typeof t == "object" && t !== null && "type" in t) {
25
- const r = t.type, i = this.listeners.get(r);
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
- // Method to send messages through the port
62
+ /**
63
+ * Sends a message through the message port
64
+ * @param message The host message to send
65
+ */
30
66
  send(e) {
31
- if (!this.port)
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 f {
37
- constructor(e, t) {
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, "ready", !1);
44
- this._url = e, this._value = t, this.eventManager = new m(), this.on(h.INVALID, (r) => {
45
- r.type === h.INVALID && (this._errors = r.errors, this._value = r.value);
46
- }), this.on(h.RESIZE, (r) => {
47
- r.type === h.RESIZE && this.iframe && (this.iframe.style.height = `${r.height}px`);
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 a, d;
66
- n.source === ((a = this.iframe) == null ? void 0 : a.contentWindow) && (console.log("received message from iframe", n.data), (d = this.eventManager) == null || d.setPort(n.ports[0]), this.ready = !0);
67
- });
68
- const t = document.querySelector(e);
69
- if (!t) throw new Error(`parentID ${e} not found`);
70
- t.appendChild(this.iframe), (i = (r = this.iframe) == null ? void 0 : r.contentWindow) == null || i.focus();
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
- on(e, t) {
76
- this.eventManager.on(e, t);
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
- off(e, t) {
79
- this.eventManager.off(e, t);
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
- update(e) {
82
- this._value = e, this.send({ type: c.UPDATE, value: e });
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, t) => {
86
- this.on(h.COMPLETE, (r) => {
175
+ return new Promise((e, s) => {
176
+ this.on(a.COMPLETE, (r) => {
87
177
  e(r.response);
88
178
  }), this.on("error", (r) => {
89
- t(new Error(r.message));
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 p(s) {
95
- return Object.entries(s).map(([e, t]) => {
96
- if (!(e && t)) return;
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 t == "object" ? JSON.stringify(t) : t
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 g {
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, "dictionary");
110
- this.uxUrl = e.uxUrl || "https://ux.notabene.id", this.nodeUrl = e.nodeUrl, this.authToken = e.authToken, this.theme = e.theme, this.dictionary = e.dictionary;
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
- componentUrl(e, t, r, i) {
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 a = p({
240
+ const h = w({
116
241
  authToken: this.authToken,
117
- value: t,
242
+ value: s,
118
243
  configuration: r
119
244
  });
120
- return n.hash = a, n.searchParams.set("nodeUrl", this.nodeUrl), this.theme && n.searchParams.set("theme", JSON.stringify(this.theme)), this.dictionary && n.searchParams.set("dictionary", JSON.stringify(this.dictionary)), i && (i.callback && n.searchParams.set("callback_url", i.callback), i.redirectUri && n.searchParams.set("redirect_uri", i.redirectUri)), n.toString();
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
- createComponent(e, t, r, i) {
123
- return new f(
124
- this.componentUrl(e, t, r, i),
125
- t
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
- createWithdrawalAssist(e, t, r) {
129
- return this.createComponent("withdrawal-assist", e, t, r);
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, a] = i.split("=");
135
- return r[decodeURIComponent(n)] = decodeURIComponent(a), r;
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
- g as default
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
  };
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.7"
8
+ "packageVersion": "7.47.11"
9
9
  }
10
10
  ]
11
11
  }
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.2",
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": "^16.2.1",
31
- "@commitlint/config-conventional": "^16.2.1",
32
- "@eslint/js": "^9.7.0",
33
- "@fast-check/vitest": "^0.1.2",
34
- "@microsoft/api-extractor": "^7.47.7",
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": "^9.3.0",
37
- "@semantic-release/npm": "^9.0.1",
38
- "@typescript-eslint/eslint-plugin": "^8.2.0",
39
- "@typescript-eslint/parser": "^8.2.0",
40
- "eslint": "^9.9.0",
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.20.0",
47
- "globals": "^15.8.0",
48
- "husky": "^7.0.4",
49
- "lint-staged": "^12.3.4",
50
- "organize-imports-cli": "^0.9.0",
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
- "semantic-release": "^19.0.2",
53
- "typescript": "^5.5.4",
54
- "typescript-eslint": "^8.2.0",
55
- "vite": "^5.4.2",
56
- "vitest": "^2.0.5"
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 }),