@cartridge/controller 0.7.9 → 0.7.10

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.
@@ -1,13 +1,13 @@
1
1
 
2
- > @cartridge/controller@0.7.9 build:deps /home/runner/work/controller/controller/packages/controller
2
+ > @cartridge/controller@0.7.10 build:deps /home/runner/work/controller/controller/packages/controller
3
3
  > pnpm build
4
4
 
5
5
 
6
- > @cartridge/controller@0.7.9 build /home/runner/work/controller/controller/packages/controller
6
+ > @cartridge/controller@0.7.10 build /home/runner/work/controller/controller/packages/controller
7
7
  > pnpm build:browser && pnpm build:node
8
8
 
9
9
 
10
- > @cartridge/controller@0.7.9 build:browser /home/runner/work/controller/controller/packages/controller
10
+ > @cartridge/controller@0.7.10 build:browser /home/runner/work/controller/controller/packages/controller
11
11
  > vite build
12
12
 
13
13
  vite v6.1.0 building for production...
@@ -18,14 +18,14 @@ rendering chunks...
18
18
 
19
19
  [vite:dts] Start generate declaration files...
20
20
  computing gzip size...
21
- dist/session.js  10.81 kB │ gzip: 3.37 kB │ map: 56.40 kB
22
- dist/provider-CH2PlazB.js  23.20 kB │ gzip: 13.54 kB │ map: 40.69 kB
23
- dist/index.js 135.41 kB │ gzip: 24.24 kB │ map: 257.61 kB
24
- [vite:dts] Declaration files built in 3492ms.
21
+ dist/session.js  10.81 kB │ gzip: 3.36 kB │ map: 56.40 kB
22
+ dist/provider-Dr912mPw.js  23.20 kB │ gzip: 13.54 kB │ map: 40.69 kB
23
+ dist/index.js 135.80 kB │ gzip: 24.34 kB │ map: 258.51 kB
24
+ [vite:dts] Declaration files built in 3451ms.
25
25
 
26
- ✓ built in 4.25s
26
+ ✓ built in 4.21s
27
27
 
28
- > @cartridge/controller@0.7.9 build:node /home/runner/work/controller/controller/packages/controller
28
+ > @cartridge/controller@0.7.10 build:node /home/runner/work/controller/controller/packages/controller
29
29
  > tsup --config tsup.node.config.ts
30
30
 
31
31
  CLI Building entry: src/node/index.ts
@@ -36,16 +36,16 @@ computing gzip size...
36
36
  CLI Cleaning output folder
37
37
  ESM Build start
38
38
  CJS Build start
39
+ "constants", "getChecksumAddress", "Provider" and "shortString" are imported from external module "starknet" but never used in "dist/node/index.js".
39
40
  "constants", "getChecksumAddress", "Provider" and "shortString" are imported from external module "starknet" but never used in "dist/node/index.cjs".
40
41
  Entry module "dist/node/index.cjs" is using named and default exports together. Consumers of your bundle will have to use `chunk.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
41
- "constants", "getChecksumAddress", "Provider" and "shortString" are imported from external module "starknet" but never used in "dist/node/index.js".
42
- CJS dist/node/index.cjs 31.90 KB
43
- CJS dist/node/index.cjs.map 58.78 KB
44
- CJS ⚡️ Build success in 402ms
45
42
  ESM dist/node/index.js 31.14 KB
46
43
  ESM dist/node/index.js.map 58.58 KB
47
- ESM ⚡️ Build success in 403ms
44
+ ESM ⚡️ Build success in 395ms
45
+ CJS dist/node/index.cjs 31.90 KB
46
+ CJS dist/node/index.cjs.map 58.78 KB
47
+ CJS ⚡️ Build success in 395ms
48
48
  DTS Build start
49
- DTS ⚡️ Build success in 3089ms
49
+ DTS ⚡️ Build success in 3035ms
50
50
  DTS dist/node/index.d.ts 5.09 KB
51
51
  DTS dist/node/index.d.cts 5.09 KB
@@ -1,9 +1,9 @@
1
1
 
2
- > @cartridge/controller@0.7.9 build /home/runner/work/controller/controller/packages/controller
2
+ > @cartridge/controller@0.7.10 build /home/runner/work/controller/controller/packages/controller
3
3
  > pnpm build:browser && pnpm build:node
4
4
 
5
5
 
6
- > @cartridge/controller@0.7.9 build:browser /home/runner/work/controller/controller/packages/controller
6
+ > @cartridge/controller@0.7.10 build:browser /home/runner/work/controller/controller/packages/controller
7
7
  > vite build
8
8
 
9
9
  vite v6.1.0 building for production...
@@ -14,14 +14,14 @@ rendering chunks...
14
14
 
15
15
  [vite:dts] Start generate declaration files...
16
16
  computing gzip size...
17
- dist/session.js  10.81 kB │ gzip: 3.37 kB │ map: 56.40 kB
18
- dist/provider-CH2PlazB.js  23.20 kB │ gzip: 13.54 kB │ map: 40.69 kB
19
- dist/index.js 135.41 kB │ gzip: 24.24 kB │ map: 257.61 kB
20
- [vite:dts] Declaration files built in 3311ms.
17
+ dist/session.js  10.81 kB │ gzip: 3.36 kB │ map: 56.40 kB
18
+ dist/provider-Dr912mPw.js  23.20 kB │ gzip: 13.54 kB │ map: 40.69 kB
19
+ dist/index.js 135.80 kB │ gzip: 24.34 kB │ map: 258.51 kB
20
+ [vite:dts] Declaration files built in 3300ms.
21
21
 
22
- ✓ built in 4.34s
22
+ ✓ built in 4.20s
23
23
 
24
- > @cartridge/controller@0.7.9 build:node /home/runner/work/controller/controller/packages/controller
24
+ > @cartridge/controller@0.7.10 build:node /home/runner/work/controller/controller/packages/controller
25
25
  > tsup --config tsup.node.config.ts
26
26
 
27
27
  CLI Building entry: src/node/index.ts
@@ -37,11 +37,11 @@ computing gzip size...
37
37
  Entry module "dist/node/index.cjs" is using named and default exports together. Consumers of your bundle will have to use `chunk.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
38
38
  ESM dist/node/index.js 31.14 KB
39
39
  ESM dist/node/index.js.map 58.58 KB
40
- ESM ⚡️ Build success in 325ms
40
+ ESM ⚡️ Build success in 289ms
41
41
  CJS dist/node/index.cjs 31.90 KB
42
42
  CJS dist/node/index.cjs.map 58.78 KB
43
- CJS ⚡️ Build success in 326ms
43
+ CJS ⚡️ Build success in 293ms
44
44
  DTS Build start
45
- DTS ⚡️ Build success in 3251ms
45
+ DTS ⚡️ Build success in 3297ms
46
46
  DTS dist/node/index.d.ts 5.09 KB
47
47
  DTS dist/node/index.d.cts 5.09 KB
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { WalletAccount as L, shortString as M, num as O } from "starknet";
2
- import { R as A, t as Y, K as $, P as W, B as H, N as b, p as K, A as q } from "./provider-CH2PlazB.js";
3
- import { h as Oe, n as Ye, a as $e, b as We } from "./provider-CH2PlazB.js";
2
+ import { R as A, t as Y, K as $, P as W, B as H, N as u, p as K, A as q } from "./provider-Dr912mPw.js";
3
+ import { h as Oe, n as Ye, a as $e, b as We } from "./provider-Dr912mPw.js";
4
4
  import { MetaMaskSDK as G } from "@metamask/sdk";
5
5
  import { Transaction as V } from "@solana/web3.js";
6
6
  import { connect as J } from "starknetkit";
@@ -77,18 +77,18 @@ class z extends L {
77
77
  });
78
78
  }
79
79
  }
80
- var u;
80
+ var y;
81
81
  (function(o) {
82
82
  o.Call = "call", o.Reply = "reply", o.Syn = "syn", o.SynAck = "synAck", o.Ack = "ack";
83
- })(u || (u = {}));
83
+ })(y || (y = {}));
84
84
  var C;
85
85
  (function(o) {
86
86
  o.Fulfilled = "fulfilled", o.Rejected = "rejected";
87
87
  })(C || (C = {}));
88
- var S;
88
+ var E;
89
89
  (function(o) {
90
90
  o.ConnectionDestroyed = "ConnectionDestroyed", o.ConnectionTimeout = "ConnectionTimeout", o.NoIframeSrc = "NoIframeSrc";
91
- })(S || (S = {}));
91
+ })(E || (E = {}));
92
92
  var D;
93
93
  (function(o) {
94
94
  o.DataCloneError = "DataCloneError";
@@ -134,43 +134,43 @@ const Z = (o, e) => {
134
134
  const { localName: n, local: r, remote: a, originForSending: c, originForReceiving: i } = o;
135
135
  let s = !1;
136
136
  const l = (d) => {
137
- if (d.source !== a || d.data.penpal !== u.Call)
137
+ if (d.source !== a || d.data.penpal !== y.Call)
138
138
  return;
139
139
  if (i !== "*" && d.origin !== i) {
140
140
  t(`${n} received message from origin ${d.origin} which did not match expected origin ${i}`);
141
141
  return;
142
142
  }
143
- const p = d.data, { methodName: h, args: m, id: v } = p;
143
+ const p = d.data, { methodName: h, args: g, id: f } = p;
144
144
  t(`${n}: Received ${h}() call`);
145
- const w = (f) => (k) => {
145
+ const w = (b) => (k) => {
146
146
  if (t(`${n}: Sending ${h}() reply`), s) {
147
147
  t(`${n}: Unable to send ${h}() reply due to destroyed connection`);
148
148
  return;
149
149
  }
150
- const y = {
151
- penpal: u.Reply,
152
- id: v,
153
- resolution: f,
150
+ const v = {
151
+ penpal: y.Reply,
152
+ id: f,
153
+ resolution: b,
154
154
  returnValue: k
155
155
  };
156
- f === C.Rejected && k instanceof Error && (y.returnValue = N(k), y.returnValueIsError = !0);
156
+ b === C.Rejected && k instanceof Error && (v.returnValue = N(k), v.returnValueIsError = !0);
157
157
  try {
158
- a.postMessage(y, c);
159
- } catch (g) {
160
- if (g.name === D.DataCloneError) {
158
+ a.postMessage(v, c);
159
+ } catch (m) {
160
+ if (m.name === D.DataCloneError) {
161
161
  const I = {
162
- penpal: u.Reply,
163
- id: v,
162
+ penpal: y.Reply,
163
+ id: f,
164
164
  resolution: C.Rejected,
165
- returnValue: N(g),
165
+ returnValue: N(m),
166
166
  returnValueIsError: !0
167
167
  };
168
168
  a.postMessage(I, c);
169
169
  }
170
- throw g;
170
+ throw m;
171
171
  }
172
172
  };
173
- new Promise((f) => f(e[h].call(e, d.origin).apply(e, m))).then(w(C.Fulfilled), w(C.Rejected));
173
+ new Promise((b) => b(e[h].call(e, d.origin).apply(e, g))).then(w(C.Fulfilled), w(C.Rejected));
174
174
  };
175
175
  return r.addEventListener(_.Message, l), () => {
176
176
  s = !0, r.removeEventListener(_.Message, l);
@@ -198,8 +198,8 @@ const ce = () => ++se, j = ".", B = (o) => o ? o.split(j) : [], de = (o) => o.jo
198
198
  const { localName: a, local: c, remote: i, originForSending: s, originForReceiving: l } = e;
199
199
  let d = !1;
200
200
  r(`${a}: Connecting call sender`);
201
- const p = (m) => (...v) => {
202
- r(`${a}: Sending ${m}() call`);
201
+ const p = (g) => (...f) => {
202
+ r(`${a}: Sending ${g}() call`);
203
203
  let w;
204
204
  try {
205
205
  i.closed && (w = !0);
@@ -207,32 +207,32 @@ const ce = () => ++se, j = ".", B = (o) => o ? o.split(j) : [], de = (o) => o.jo
207
207
  w = !0;
208
208
  }
209
209
  if (w && n(), d) {
210
- const f = new Error(`Unable to send ${m}() call due to destroyed connection`);
211
- throw f.code = S.ConnectionDestroyed, f;
210
+ const b = new Error(`Unable to send ${g}() call due to destroyed connection`);
211
+ throw b.code = E.ConnectionDestroyed, b;
212
212
  }
213
- return new Promise((f, k) => {
214
- const y = ce(), g = (x) => {
215
- if (x.source !== i || x.data.penpal !== u.Reply || x.data.id !== y)
213
+ return new Promise((b, k) => {
214
+ const v = ce(), m = (x) => {
215
+ if (x.source !== i || x.data.penpal !== y.Reply || x.data.id !== v)
216
216
  return;
217
217
  if (l !== "*" && x.origin !== l) {
218
218
  r(`${a} received message from origin ${x.origin} which did not match expected origin ${l}`);
219
219
  return;
220
220
  }
221
- const E = x.data;
222
- r(`${a}: Received ${m}() reply`), c.removeEventListener(_.Message, g);
223
- let P = E.returnValue;
224
- E.returnValueIsError && (P = ae(P)), (E.resolution === C.Fulfilled ? f : k)(P);
221
+ const S = x.data;
222
+ r(`${a}: Received ${g}() reply`), c.removeEventListener(_.Message, m);
223
+ let P = S.returnValue;
224
+ S.returnValueIsError && (P = ae(P)), (S.resolution === C.Fulfilled ? b : k)(P);
225
225
  };
226
- c.addEventListener(_.Message, g);
226
+ c.addEventListener(_.Message, m);
227
227
  const I = {
228
- penpal: u.Call,
229
- id: y,
230
- methodName: m,
231
- args: v
228
+ penpal: y.Call,
229
+ id: v,
230
+ methodName: g,
231
+ args: f
232
232
  };
233
233
  i.postMessage(I, s);
234
234
  });
235
- }, h = t.reduce((m, v) => (m[v] = p(v), m), {});
235
+ }, h = t.reduce((g, f) => (g[f] = p(f), g), {});
236
236
  return Object.assign(o, ge(h)), () => {
237
237
  d = !0;
238
238
  };
@@ -253,8 +253,8 @@ const ce = () => ++se, j = ".", B = (o) => o ? o.split(j) : [], de = (o) => o.jo
253
253
  originForSending: t,
254
254
  originForReceiving: e
255
255
  };
256
- i && i(), i = ie(p, o, r), c(i), s && s.forEach((m) => {
257
- delete l[m];
256
+ i && i(), i = ie(p, o, r), c(i), s && s.forEach((g) => {
257
+ delete l[g];
258
258
  }), s = d.data.methodNames;
259
259
  const h = me(l, p, s, a, r);
260
260
  return c(h), l;
@@ -268,7 +268,7 @@ const ce = () => ++se, j = ".", B = (o) => o ? o.split(j) : [], de = (o) => o.jo
268
268
  }
269
269
  o("Parent: Handshake - Received SYN, responding with SYN-ACK");
270
270
  const a = {
271
- penpal: u.SynAck,
271
+ penpal: y.SynAck,
272
272
  methodNames: Object.keys(e)
273
273
  };
274
274
  r.source.postMessage(a, n);
@@ -283,37 +283,37 @@ const ce = () => ++se, j = ".", B = (o) => o ? o.split(j) : [], de = (o) => o.jo
283
283
  let t;
284
284
  return o !== void 0 && (t = window.setTimeout(() => {
285
285
  const n = new Error(`Connection timed out after ${o}ms`);
286
- n.code = S.ConnectionTimeout, e(n);
286
+ n.code = E.ConnectionTimeout, e(n);
287
287
  }, o)), () => {
288
288
  clearTimeout(t);
289
289
  };
290
290
  }, ve = (o) => {
291
291
  if (!o.src && !o.srcdoc) {
292
292
  const e = new Error("Iframe must have src or srcdoc property defined.");
293
- throw e.code = S.NoIframeSrc, e;
293
+ throw e.code = E.NoIframeSrc, e;
294
294
  }
295
295
  }, we = (o) => {
296
296
  let { iframe: e, methods: t = {}, childOrigin: n, timeout: r, debug: a = !1 } = o;
297
297
  const c = ee(a), i = Z("Parent", c), { onDestroy: s, destroy: l } = i;
298
298
  n || (ve(e), n = re(e.src));
299
- const d = n === "null" ? "*" : n, p = T(t), h = fe(c, p, n, d), m = he(p, n, d, i, c);
299
+ const d = n === "null" ? "*" : n, p = T(t), h = fe(c, p, n, d), g = he(p, n, d, i, c);
300
300
  return {
301
- promise: new Promise((w, f) => {
302
- const k = ye(r, l), y = (g) => {
303
- if (!(g.source !== e.contentWindow || !g.data)) {
304
- if (g.data.penpal === u.Syn) {
305
- h(g);
301
+ promise: new Promise((w, b) => {
302
+ const k = ye(r, l), v = (m) => {
303
+ if (!(m.source !== e.contentWindow || !m.data)) {
304
+ if (m.data.penpal === y.Syn) {
305
+ h(m);
306
306
  return;
307
307
  }
308
- if (g.data.penpal === u.Ack) {
309
- const I = m(g);
308
+ if (m.data.penpal === y.Ack) {
309
+ const I = g(m);
310
310
  I && (k(), w(I));
311
311
  return;
312
312
  }
313
313
  }
314
314
  };
315
- window.addEventListener(_.Message, y), c("Parent: Awaiting handshake"), ue(e, i), s((g) => {
316
- window.removeEventListener(_.Message, y), g && f(g);
315
+ window.addEventListener(_.Message, v), c("Parent: Awaiting handshake"), ue(e, i), s((m) => {
316
+ window.removeEventListener(_.Message, v), m && b(m);
317
317
  });
318
318
  }),
319
319
  destroy() {
@@ -342,7 +342,19 @@ class Q {
342
342
  const s = document.createElement("div");
343
343
  s.id = "controller", s.style.position = "fixed", s.style.height = "100%", s.style.width = "100%", s.style.top = "0", s.style.left = "0", s.style.zIndex = "10000", s.style.backgroundColor = "rgba(0,0,0,0.6)", s.style.display = "flex", s.style.alignItems = "center", s.style.justifyContent = "center", s.style.visibility = "hidden", s.style.opacity = "0", s.style.transition = "opacity 0.2s ease", s.appendChild(i), this.iframe = i, this.container = s, we({
344
344
  iframe: this.iframe,
345
- methods: { close: (p) => () => this.close(), ...c }
345
+ methods: {
346
+ close: (p) => () => this.close(),
347
+ closeAll: (p) => () => {
348
+ document.querySelectorAll(
349
+ 'iframe[id^="controller-"]'
350
+ ).forEach((g) => {
351
+ const f = g.parentElement;
352
+ f && (f.style.visibility = "hidden", f.style.opacity = "0");
353
+ }), document.body.style.overflow = "auto";
354
+ },
355
+ reload: (p) => () => window.location.reload(),
356
+ ...c
357
+ }
346
358
  }).promise.then(a), this.resize(), window.addEventListener("resize", () => this.resize());
347
359
  const l = new MutationObserver(() => {
348
360
  const p = document.getElementById("controller");
@@ -839,7 +851,7 @@ class xe extends Q {
839
851
  encodeURIComponent(i.erc20.toString())
840
852
  ), s?.contracts) {
841
853
  const h = Object.values(s.contracts).flatMap(
842
- (m) => m.methods
854
+ (g) => g.methods
843
855
  );
844
856
  p.searchParams.set(
845
857
  "methods",
@@ -874,7 +886,7 @@ class Ne extends H {
874
886
  async probe() {
875
887
  try {
876
888
  if (await this.waitForKeychain(), !this.keychain) {
877
- console.error(new b().message);
889
+ console.error(new u().message);
878
890
  return;
879
891
  }
880
892
  const e = await this.keychain.probe(this.rpcUrl());
@@ -914,7 +926,7 @@ class Ne extends H {
914
926
  if (this.account)
915
927
  return this.account;
916
928
  if (!this.keychain || !this.iframes.keychain) {
917
- console.error(new b().message);
929
+ console.error(new u().message);
918
930
  return;
919
931
  }
920
932
  document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.iframes.keychain.open();
@@ -941,7 +953,7 @@ class Ne extends H {
941
953
  }
942
954
  async switchStarknetChain(e) {
943
955
  if (!this.keychain || !this.iframes.keychain)
944
- return console.error(new b().message), !1;
956
+ return console.error(new u().message), !1;
945
957
  try {
946
958
  if (this.selectedChain = e, (await this.keychain.probe(this.rpcUrl())).rpcUrl === this.rpcUrl())
947
959
  return !0;
@@ -956,7 +968,7 @@ class Ne extends H {
956
968
  }
957
969
  async disconnect() {
958
970
  if (!this.keychain) {
959
- console.error(new b().message);
971
+ console.error(new u().message);
960
972
  return;
961
973
  }
962
974
  return document.hasStorageAccess && (await document.hasStorageAccess() || await document.requestStorageAccess()), this.account = void 0, this.keychain.disconnect();
@@ -996,13 +1008,13 @@ class Ne extends H {
996
1008
  }
997
1009
  async openSettings() {
998
1010
  if (!this.keychain || !this.iframes.keychain)
999
- return console.error(new b().message), null;
1011
+ return console.error(new u().message), null;
1000
1012
  this.iframes.profile?.sendBackward ? this.iframes.profile?.sendBackward() : this.iframes.profile?.close(), this.iframes.keychain.open();
1001
1013
  const e = await this.keychain.openSettings();
1002
1014
  return this.iframes.keychain.close(), this.iframes.profile?.sendForward?.(), !(e && e.code === A.NOT_CONNECTED);
1003
1015
  }
1004
1016
  revoke(e, t) {
1005
- return this.keychain ? this.keychain.revoke(e) : (console.error(new b().message), null);
1017
+ return this.keychain ? this.keychain.revoke(e) : (console.error(new u().message), null);
1006
1018
  }
1007
1019
  rpcUrl() {
1008
1020
  const e = this.chains.get(this.selectedChain);
@@ -1018,14 +1030,14 @@ class Ne extends H {
1018
1030
  }
1019
1031
  username() {
1020
1032
  if (!this.keychain) {
1021
- console.error(new b().message);
1033
+ console.error(new u().message);
1022
1034
  return;
1023
1035
  }
1024
1036
  return this.keychain.username();
1025
1037
  }
1026
1038
  openPurchaseCredits() {
1027
1039
  if (!this.keychain || !this.iframes.keychain) {
1028
- console.error(new b().message);
1040
+ console.error(new u().message);
1029
1041
  return;
1030
1042
  }
1031
1043
  if (!this.iframes.profile) {
@@ -1036,7 +1048,7 @@ class Ne extends H {
1036
1048
  }
1037
1049
  openStarterPack() {
1038
1050
  if (!this.keychain || !this.iframes.keychain) {
1039
- console.error(new b().message);
1051
+ console.error(new u().message);
1040
1052
  return;
1041
1053
  }
1042
1054
  if (!this.iframes.profile) {
@@ -1047,7 +1059,7 @@ class Ne extends H {
1047
1059
  }
1048
1060
  async openExecute(e, t) {
1049
1061
  if (!this.keychain || !this.iframes.keychain) {
1050
- console.error(new b().message);
1062
+ console.error(new u().message);
1051
1063
  return;
1052
1064
  }
1053
1065
  if (!this.iframes.profile) {
@@ -1060,7 +1072,7 @@ class Ne extends H {
1060
1072
  return this.iframes.profile?.open(), this.iframes.keychain.close(), this.iframes.profile?.sendForward(), t && this.switchStarknetChain(n), !(r && (r.code === A.NOT_CONNECTED || r.code === A.CANCELED));
1061
1073
  }
1062
1074
  async delegateAccount() {
1063
- return this.keychain ? await this.keychain.delegateAccount() : (console.error(new b().message), null);
1075
+ return this.keychain ? await this.keychain.delegateAccount() : (console.error(new u().message), null);
1064
1076
  }
1065
1077
  async validateChains(e) {
1066
1078
  for (const t of e)
@@ -4352,7 +4364,7 @@ var U = {
4352
4364
  export {
4353
4365
  Ae as ArgentWallet,
4354
4366
  _e as MetaMaskWallet,
4355
- b as NotReadyToConnect,
4367
+ u as NotReadyToConnect,
4356
4368
  ke as PhantomWallet,
4357
4369
  A as ResponseCodes,
4358
4370
  Ce as WalletBridge,