@cartridge/controller 0.5.0-alpha.4 → 0.5.0-alpha.6

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 (71) hide show
  1. package/.turbo/turbo-build$colon$deps.log +116 -4
  2. package/dist/account.d.ts +9 -6
  3. package/dist/account.js +84 -74
  4. package/dist/account.js.map +1 -1
  5. package/dist/constants.d.ts +4 -2
  6. package/dist/constants.js +7 -2
  7. package/dist/constants.js.map +1 -1
  8. package/dist/controller.d.ts +12 -5
  9. package/dist/controller.js +739 -182
  10. package/dist/controller.js.map +1 -1
  11. package/dist/errors.d.ts +3 -1
  12. package/dist/errors.js +10 -6
  13. package/dist/errors.js.map +1 -1
  14. package/dist/icon.d.ts +3 -1
  15. package/dist/icon.js +5 -1
  16. package/dist/icon.js.map +1 -1
  17. package/dist/iframe/base.d.ts +5 -23
  18. package/dist/iframe/base.js +272 -98
  19. package/dist/iframe/base.js.map +1 -1
  20. package/dist/iframe/index.d.ts +5 -3
  21. package/dist/iframe/index.js +331 -3
  22. package/dist/iframe/index.js.map +1 -1
  23. package/dist/iframe/keychain.d.ts +5 -7
  24. package/dist/iframe/keychain.js +294 -13
  25. package/dist/iframe/keychain.js.map +1 -1
  26. package/dist/iframe/profile.d.ts +5 -11
  27. package/dist/iframe/profile.js +308 -16
  28. package/dist/iframe/profile.js.map +1 -1
  29. package/dist/index.d.ts +9 -4
  30. package/dist/index.js +767 -4
  31. package/dist/index.js.map +1 -1
  32. package/dist/presets.d.ts +9 -2
  33. package/dist/presets.js +159 -146
  34. package/dist/presets.js.map +1 -1
  35. package/dist/provider.d.ts +9 -4
  36. package/dist/provider.js +138 -124
  37. package/dist/provider.js.map +1 -1
  38. package/dist/session/account.d.ts +14 -8
  39. package/dist/session/account.js +235 -27
  40. package/dist/session/account.js.map +1 -1
  41. package/dist/session/backend.d.ts +4 -2
  42. package/dist/session/backend.js +38 -37
  43. package/dist/session/backend.js.map +1 -1
  44. package/dist/session/index.d.ts +9 -5
  45. package/dist/session/index.js +467 -5
  46. package/dist/session/index.js.map +1 -1
  47. package/dist/session/provider.d.ts +12 -8
  48. package/dist/session/provider.js +281 -81
  49. package/dist/session/provider.js.map +1 -1
  50. package/dist/telegram/backend.d.ts +5 -2
  51. package/dist/telegram/backend.js +38 -37
  52. package/dist/telegram/backend.js.map +1 -1
  53. package/dist/telegram/provider.d.ts +7 -4
  54. package/dist/telegram/provider.js +283 -70
  55. package/dist/telegram/provider.js.map +1 -1
  56. package/dist/types-DIeWpu0p.d.ts +196 -0
  57. package/dist/types.d.ts +5 -159
  58. package/dist/types.js +12 -8
  59. package/dist/types.js.map +1 -1
  60. package/dist/utils.d.ts +7 -3
  61. package/dist/utils.js +12 -8
  62. package/dist/utils.js.map +1 -1
  63. package/package.json +17 -14
  64. package/src/controller.ts +13 -25
  65. package/src/iframe/base.ts +3 -0
  66. package/src/iframe/profile.ts +17 -9
  67. package/src/presets.ts +10 -1
  68. package/src/session/provider.ts +1 -2
  69. package/src/types.ts +3 -7
  70. package/tsconfig.json +4 -1
  71. package/tsconfig.tsbuildinfo +0 -1
@@ -1,102 +1,276 @@
1
+ // src/iframe/base.ts
1
2
  import { connectToChild } from "@cartridge/penpal";
2
- import { defaultPresets } from "../presets";
3
- export class IFrame {
4
- constructor({ id, url, theme, config, colorMode, onClose, onConnect, methods = {}, }) {
5
- if (typeof document === "undefined") {
6
- return;
7
- }
8
- url.searchParams.set("theme", encodeURIComponent(JSON.stringify(config?.presets?.[theme ?? "cartridge"] ?? defaultPresets.cartridge)));
9
- if (colorMode) {
10
- url.searchParams.set("colorMode", colorMode);
11
- }
12
- const iframe = document.createElement("iframe");
13
- iframe.src = url.toString();
14
- iframe.id = id;
15
- iframe.style.border = "none";
16
- iframe.sandbox.add("allow-forms");
17
- iframe.sandbox.add("allow-popups");
18
- iframe.sandbox.add("allow-scripts");
19
- iframe.sandbox.add("allow-same-origin");
20
- iframe.allow =
21
- "publickey-credentials-create *; publickey-credentials-get *; clipboard-write";
22
- if (!!document.hasStorageAccess) {
23
- iframe.sandbox.add("allow-storage-access-by-user-activation");
24
- }
25
- const container = document.createElement("div");
26
- container.id = "controller";
27
- container.style.position = "fixed";
28
- container.style.height = "100%";
29
- container.style.width = "100%";
30
- container.style.top = "0";
31
- container.style.left = "0";
32
- container.style.zIndex = "10000";
33
- container.style.backgroundColor = "rgba(0,0,0,0.6)";
34
- container.style.display = "flex";
35
- container.style.alignItems = "center";
36
- container.style.justifyContent = "center";
37
- container.style.visibility = "hidden";
38
- container.style.opacity = "0";
39
- container.style.transition = "opacity 0.2s ease";
40
- container.appendChild(iframe);
41
- this.iframe = iframe;
42
- this.container = container;
43
- connectToChild({
44
- iframe: this.iframe,
45
- methods: { close: () => this.close(), ...methods },
46
- }).promise.then(onConnect);
47
- this.resize();
48
- window.addEventListener("resize", () => this.resize());
49
- const observer = new MutationObserver(() => {
50
- const existingController = document.getElementById("controller");
51
- if (document.body) {
52
- if ((id === "controller-keychain" && !existingController) ||
53
- id === "controller-profile") {
54
- document.body.appendChild(container);
55
- observer.disconnect();
56
- }
57
- }
58
- });
59
- observer.observe(document.documentElement, {
60
- childList: true,
61
- subtree: true,
62
- });
63
- const existingController = document.getElementById("controller");
64
- if (document.body) {
65
- if ((id === "controller-keychain" && !existingController) ||
66
- id === "controller-profile") {
67
- document.body.appendChild(container);
68
- }
69
- }
70
- this.onClose = onClose;
71
- }
72
- open() {
73
- if (!this.container)
74
- return;
75
- document.body.style.overflow = "hidden";
76
- this.container.style.visibility = "visible";
77
- this.container.style.opacity = "1";
78
- }
79
- close() {
80
- if (!this.container)
81
- return;
82
- this.onClose?.();
83
- document.body.style.overflow = "auto";
84
- this.container.style.visibility = "hidden";
85
- this.container.style.opacity = "0";
86
- }
87
- resize() {
88
- if (!this.iframe)
89
- return;
90
- this.iframe.style.userSelect = "none";
91
- if (window.innerWidth < 768) {
92
- this.iframe.style.height = "100%";
93
- this.iframe.style.width = "100%";
94
- this.iframe.style.borderRadius = "0";
95
- return;
3
+
4
+ // src/presets.ts
5
+ var defaultPresets = {
6
+ cartridge: {
7
+ id: "cartridge",
8
+ name: "Cartridge",
9
+ icon: "/whitelabel/cartridge/icon.svg",
10
+ cover: {
11
+ light: "/whitelabel/cartridge/cover-light.png",
12
+ dark: "/whitelabel/cartridge/cover-dark.png"
13
+ }
14
+ },
15
+ "force-prime": {
16
+ id: "force-prime",
17
+ name: "Force Prime",
18
+ icon: "/whitelabel/force-prime/icon.png",
19
+ cover: "/whitelabel/force-prime/cover.png",
20
+ colors: {
21
+ primary: "#E1CC89"
22
+ }
23
+ },
24
+ paved: {
25
+ id: "paved",
26
+ name: "Paved",
27
+ icon: "/whitelabel/paved/icon.svg",
28
+ cover: "/whitelabel/paved/cover.png",
29
+ colors: {
30
+ primary: "#B0CAF8"
31
+ }
32
+ },
33
+ eternum: {
34
+ id: "eternum",
35
+ name: "Eternum",
36
+ icon: "/whitelabel/eternum/icon.gif",
37
+ cover: "/whitelabel/eternum/cover.png",
38
+ colors: {
39
+ primary: "#CE9822"
40
+ }
41
+ },
42
+ pistols: {
43
+ id: "pistols",
44
+ name: "Pistols at Ten Blocks",
45
+ icon: "/whitelabel/pistols/icon.png",
46
+ cover: "/whitelabel/pistols/cover.png",
47
+ colors: {
48
+ primary: "#EF9758"
49
+ }
50
+ },
51
+ pixelaw: {
52
+ id: "pixelaw",
53
+ name: "Pixelaw",
54
+ icon: "/whitelabel/pixelaw/icon.svg",
55
+ cover: "/whitelabel/pixelaw/cover.png",
56
+ colors: {
57
+ primary: "#7C00B1",
58
+ primaryForeground: "white"
59
+ }
60
+ },
61
+ "dope-wars": {
62
+ id: "dope-wars",
63
+ name: "Dope Wars",
64
+ icon: "/whitelabel/dope-wars/icon.png",
65
+ cover: "/whitelabel/dope-wars/cover.png",
66
+ colors: {
67
+ primary: "#11ED83"
68
+ }
69
+ },
70
+ zkastle: {
71
+ id: "zkastle",
72
+ name: "zKastle",
73
+ icon: "/whitelabel/zkastle/icon.svg",
74
+ cover: "/whitelabel/zkastle/cover.png",
75
+ colors: {
76
+ primary: "#E50D2C"
77
+ }
78
+ },
79
+ "loot-survivor": {
80
+ id: "loot-survivor",
81
+ name: "Loot Survivor",
82
+ icon: "/whitelabel/loot-survivor/icon.png",
83
+ cover: "/whitelabel/loot-survivor/cover.png",
84
+ colors: {
85
+ primary: "#33FF33"
86
+ }
87
+ },
88
+ "tale-weaver": {
89
+ id: "tale-weaver",
90
+ name: "Tale Weaver",
91
+ icon: "/whitelabel/tale-weaver/icon.png",
92
+ cover: "/whitelabel/tale-weaver/cover.png",
93
+ colors: {
94
+ primary: "#fce377"
95
+ }
96
+ },
97
+ "realm-of-ra": {
98
+ id: "realm-of-ra",
99
+ name: "Realm of Ra",
100
+ icon: "/whitelabel/realm-of-ra/icon.png",
101
+ cover: "/whitelabel/realm-of-ra/cover.png",
102
+ colors: {
103
+ primary: "#de9534"
104
+ }
105
+ },
106
+ "jokers-of-neon": {
107
+ id: "jokers-of-neon",
108
+ name: "Jokers of Neon",
109
+ icon: "/whitelabel/jokers-of-neon/icon.png",
110
+ cover: "/whitelabel/jokers-of-neon/cover.png",
111
+ colors: {
112
+ primary: "#A144B2"
113
+ }
114
+ },
115
+ flippyflop: {
116
+ id: "flippyflop",
117
+ name: "FlippyFlop",
118
+ icon: "/whitelabel/flippyflop/icon.png",
119
+ cover: "/whitelabel/flippyflop/cover.png",
120
+ colors: {
121
+ primary: "#F38332"
122
+ }
123
+ },
124
+ "savage-summit": {
125
+ id: "savage-summit",
126
+ name: "Savage Summit",
127
+ icon: "/whitelabel/savage-summit/icon.png",
128
+ cover: "/whitelabel/savage-summit/cover.png",
129
+ colors: {
130
+ primary: "#fbf7da"
131
+ }
132
+ },
133
+ "dark-shuffle": {
134
+ id: "dark-shuffle",
135
+ name: "Dark Shuffle",
136
+ icon: "/whitelabel/dark-shuffle/icon.svg",
137
+ cover: "/whitelabel/dark-shuffle/cover.png",
138
+ colors: {
139
+ primary: "#F59100"
140
+ }
141
+ },
142
+ "blob-arena": {
143
+ id: "blob-arena",
144
+ name: "Blob Arena",
145
+ icon: "/whitelabel/blob-arena/icon.png",
146
+ cover: "/whitelabel/blob-arena/cover.png",
147
+ colors: {
148
+ primary: "#980f06"
149
+ }
150
+ },
151
+ zkube: {
152
+ id: "zkube",
153
+ name: "zKube",
154
+ icon: "/whitelabel/zkube/icon.png",
155
+ cover: "/whitelabel/zkube/cover.png",
156
+ colors: {
157
+ primary: "#5bc3e6"
158
+ }
159
+ }
160
+ };
161
+
162
+ // src/iframe/base.ts
163
+ var IFrame = class {
164
+ constructor({
165
+ id,
166
+ url,
167
+ theme,
168
+ config,
169
+ colorMode,
170
+ onClose,
171
+ onConnect,
172
+ methods = {}
173
+ }) {
174
+ if (typeof document === "undefined") {
175
+ return;
176
+ }
177
+ url.searchParams.set(
178
+ "theme",
179
+ encodeURIComponent(
180
+ JSON.stringify(
181
+ config?.presets?.[theme ?? "cartridge"] ?? defaultPresets.cartridge
182
+ )
183
+ )
184
+ );
185
+ if (colorMode) {
186
+ url.searchParams.set("colorMode", colorMode);
187
+ }
188
+ this.url = url;
189
+ const iframe = document.createElement("iframe");
190
+ iframe.src = url.toString();
191
+ iframe.id = id;
192
+ iframe.style.border = "none";
193
+ iframe.sandbox.add("allow-forms");
194
+ iframe.sandbox.add("allow-popups");
195
+ iframe.sandbox.add("allow-scripts");
196
+ iframe.sandbox.add("allow-same-origin");
197
+ iframe.allow = "publickey-credentials-create *; publickey-credentials-get *; clipboard-write";
198
+ if (!!document.hasStorageAccess) {
199
+ iframe.sandbox.add("allow-storage-access-by-user-activation");
200
+ }
201
+ const container = document.createElement("div");
202
+ container.id = "controller";
203
+ container.style.position = "fixed";
204
+ container.style.height = "100%";
205
+ container.style.width = "100%";
206
+ container.style.top = "0";
207
+ container.style.left = "0";
208
+ container.style.zIndex = "10000";
209
+ container.style.backgroundColor = "rgba(0,0,0,0.6)";
210
+ container.style.display = "flex";
211
+ container.style.alignItems = "center";
212
+ container.style.justifyContent = "center";
213
+ container.style.visibility = "hidden";
214
+ container.style.opacity = "0";
215
+ container.style.transition = "opacity 0.2s ease";
216
+ container.appendChild(iframe);
217
+ this.iframe = iframe;
218
+ this.container = container;
219
+ connectToChild({
220
+ iframe: this.iframe,
221
+ methods: { close: () => this.close(), ...methods }
222
+ }).promise.then(onConnect);
223
+ this.resize();
224
+ window.addEventListener("resize", () => this.resize());
225
+ const observer = new MutationObserver(() => {
226
+ const existingController2 = document.getElementById("controller");
227
+ if (document.body) {
228
+ if (id === "controller-keychain" && !existingController2 || id === "controller-profile") {
229
+ document.body.appendChild(container);
230
+ observer.disconnect();
96
231
  }
97
- this.iframe.style.height = "600px";
98
- this.iframe.style.width = "432px";
99
- this.iframe.style.borderRadius = "8px";
232
+ }
233
+ });
234
+ observer.observe(document.documentElement, {
235
+ childList: true,
236
+ subtree: true
237
+ });
238
+ const existingController = document.getElementById("controller");
239
+ if (document.body) {
240
+ if (id === "controller-keychain" && !existingController || id === "controller-profile") {
241
+ document.body.appendChild(container);
242
+ }
243
+ }
244
+ this.onClose = onClose;
245
+ }
246
+ open() {
247
+ if (!this.container) return;
248
+ document.body.style.overflow = "hidden";
249
+ this.container.style.visibility = "visible";
250
+ this.container.style.opacity = "1";
251
+ }
252
+ close() {
253
+ if (!this.container) return;
254
+ this.onClose?.();
255
+ document.body.style.overflow = "auto";
256
+ this.container.style.visibility = "hidden";
257
+ this.container.style.opacity = "0";
258
+ }
259
+ resize() {
260
+ if (!this.iframe) return;
261
+ this.iframe.style.userSelect = "none";
262
+ if (window.innerWidth < 768) {
263
+ this.iframe.style.height = "100%";
264
+ this.iframe.style.width = "100%";
265
+ this.iframe.style.borderRadius = "0";
266
+ return;
100
267
  }
101
- }
268
+ this.iframe.style.height = "600px";
269
+ this.iframe.style.width = "432px";
270
+ this.iframe.style.borderRadius = "8px";
271
+ }
272
+ };
273
+ export {
274
+ IFrame
275
+ };
102
276
  //# sourceMappingURL=base.js.map
@@ -1 +1 @@
1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,CAAC,KAAK,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;IACrC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAO;QAC5B,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;QAEjB,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC;QAEtC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC;QAC3C,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;IACrC,CAAC;IAEO,MAAM;QACZ,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO;QAEzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC;QAEtC,IAAI,MAAM,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;YAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,GAAG,CAAC;YACrC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC;IACzC,CAAC;CACF"}
1
+ {"version":3,"sources":["../../src/iframe/base.ts","../../src/presets.ts"],"sourcesContent":["import { AsyncMethodReturns, connectToChild } from \"@cartridge/penpal\";\nimport { defaultPresets } from \"../presets\";\nimport { ControllerOptions, Modal } from \"../types\";\n\nexport type IFrameOptions<CallSender> = Omit<\n ConstructorParameters<typeof IFrame>[0],\n \"id\" | \"url\" | \"onConnect\"\n> & {\n url?: string;\n onConnect: (child: AsyncMethodReturns<CallSender>) => void;\n};\n\nexport class IFrame<CallSender extends {}> implements Modal {\n url?: URL;\n private iframe?: HTMLIFrameElement;\n private container?: HTMLDivElement;\n private onClose?: () => void;\n\n constructor({\n id,\n url,\n theme,\n config,\n colorMode,\n onClose,\n onConnect,\n methods = {},\n }: Pick<ControllerOptions, \"theme\" | \"config\" | \"colorMode\"> & {\n id: string;\n url: URL;\n onClose?: () => void;\n onConnect: (child: AsyncMethodReturns<CallSender>) => void;\n methods?: { [key: string]: (...args: any[]) => void };\n }) {\n if (typeof document === \"undefined\") {\n return;\n }\n\n url.searchParams.set(\n \"theme\",\n encodeURIComponent(\n JSON.stringify(\n config?.presets?.[theme ?? \"cartridge\"] ?? defaultPresets.cartridge,\n ),\n ),\n );\n\n if (colorMode) {\n url.searchParams.set(\"colorMode\", colorMode);\n }\n\n this.url = url;\n\n const iframe = document.createElement(\"iframe\");\n iframe.src = url.toString();\n iframe.id = id;\n iframe.style.border = \"none\";\n iframe.sandbox.add(\"allow-forms\");\n iframe.sandbox.add(\"allow-popups\");\n iframe.sandbox.add(\"allow-scripts\");\n iframe.sandbox.add(\"allow-same-origin\");\n iframe.allow =\n \"publickey-credentials-create *; publickey-credentials-get *; clipboard-write\";\n if (!!document.hasStorageAccess) {\n iframe.sandbox.add(\"allow-storage-access-by-user-activation\");\n }\n\n const container = document.createElement(\"div\");\n container.id = \"controller\";\n container.style.position = \"fixed\";\n container.style.height = \"100%\";\n container.style.width = \"100%\";\n container.style.top = \"0\";\n container.style.left = \"0\";\n container.style.zIndex = \"10000\";\n container.style.backgroundColor = \"rgba(0,0,0,0.6)\";\n container.style.display = \"flex\";\n container.style.alignItems = \"center\";\n container.style.justifyContent = \"center\";\n container.style.visibility = \"hidden\";\n container.style.opacity = \"0\";\n container.style.transition = \"opacity 0.2s ease\";\n container.appendChild(iframe);\n\n this.iframe = iframe;\n this.container = container;\n\n connectToChild<CallSender>({\n iframe: this.iframe,\n methods: { close: () => this.close(), ...methods },\n }).promise.then(onConnect);\n\n this.resize();\n window.addEventListener(\"resize\", () => this.resize());\n\n const observer = new MutationObserver(() => {\n const existingController = document.getElementById(\"controller\");\n if (document.body) {\n if (\n (id === \"controller-keychain\" && !existingController) ||\n id === \"controller-profile\"\n ) {\n document.body.appendChild(container);\n observer.disconnect();\n }\n }\n });\n\n observer.observe(document.documentElement, {\n childList: true,\n subtree: true,\n });\n\n const existingController = document.getElementById(\"controller\");\n if (document.body) {\n if (\n (id === \"controller-keychain\" && !existingController) ||\n id === \"controller-profile\"\n ) {\n document.body.appendChild(container);\n }\n }\n\n this.onClose = onClose;\n }\n\n open() {\n if (!this.container) return;\n document.body.style.overflow = \"hidden\";\n\n this.container.style.visibility = \"visible\";\n this.container.style.opacity = \"1\";\n }\n\n close() {\n if (!this.container) return;\n this.onClose?.();\n\n document.body.style.overflow = \"auto\";\n\n this.container.style.visibility = \"hidden\";\n this.container.style.opacity = \"0\";\n }\n\n private resize() {\n if (!this.iframe) return;\n\n this.iframe.style.userSelect = \"none\";\n\n if (window.innerWidth < 768) {\n this.iframe.style.height = \"100%\";\n this.iframe.style.width = \"100%\";\n this.iframe.style.borderRadius = \"0\";\n return;\n }\n\n this.iframe.style.height = \"600px\";\n this.iframe.style.width = \"432px\";\n this.iframe.style.borderRadius = \"8px\";\n }\n}\n","import { ControllerThemePresets } from \"./types\";\n\nexport const defaultPresets: ControllerThemePresets = {\n cartridge: {\n id: \"cartridge\",\n name: \"Cartridge\",\n icon: \"/whitelabel/cartridge/icon.svg\",\n cover: {\n light: \"/whitelabel/cartridge/cover-light.png\",\n dark: \"/whitelabel/cartridge/cover-dark.png\",\n },\n },\n \"force-prime\": {\n id: \"force-prime\",\n name: \"Force Prime\",\n icon: \"/whitelabel/force-prime/icon.png\",\n cover: \"/whitelabel/force-prime/cover.png\",\n colors: {\n primary: \"#E1CC89\",\n },\n },\n paved: {\n id: \"paved\",\n name: \"Paved\",\n icon: \"/whitelabel/paved/icon.svg\",\n cover: \"/whitelabel/paved/cover.png\",\n colors: {\n primary: \"#B0CAF8\",\n },\n },\n eternum: {\n id: \"eternum\",\n name: \"Eternum\",\n icon: \"/whitelabel/eternum/icon.gif\",\n cover: \"/whitelabel/eternum/cover.png\",\n colors: {\n primary: \"#CE9822\",\n },\n },\n pistols: {\n id: \"pistols\",\n name: \"Pistols at Ten Blocks\",\n icon: \"/whitelabel/pistols/icon.png\",\n cover: \"/whitelabel/pistols/cover.png\",\n colors: {\n primary: \"#EF9758\",\n },\n },\n pixelaw: {\n id: \"pixelaw\",\n name: \"Pixelaw\",\n icon: \"/whitelabel/pixelaw/icon.svg\",\n cover: \"/whitelabel/pixelaw/cover.png\",\n colors: {\n primary: \"#7C00B1\",\n primaryForeground: \"white\",\n },\n },\n \"dope-wars\": {\n id: \"dope-wars\",\n name: \"Dope Wars\",\n icon: \"/whitelabel/dope-wars/icon.png\",\n cover: \"/whitelabel/dope-wars/cover.png\",\n colors: {\n primary: \"#11ED83\",\n },\n },\n zkastle: {\n id: \"zkastle\",\n name: \"zKastle\",\n icon: \"/whitelabel/zkastle/icon.svg\",\n cover: \"/whitelabel/zkastle/cover.png\",\n colors: {\n primary: \"#E50D2C\",\n },\n },\n \"loot-survivor\": {\n id: \"loot-survivor\",\n name: \"Loot Survivor\",\n icon: \"/whitelabel/loot-survivor/icon.png\",\n cover: \"/whitelabel/loot-survivor/cover.png\",\n colors: {\n primary: \"#33FF33\",\n },\n },\n \"tale-weaver\": {\n id: \"tale-weaver\",\n name: \"Tale Weaver\",\n icon: \"/whitelabel/tale-weaver/icon.png\",\n cover: \"/whitelabel/tale-weaver/cover.png\",\n colors: {\n primary: \"#fce377\",\n },\n },\n \"realm-of-ra\": {\n id: \"realm-of-ra\",\n name: \"Realm of Ra\",\n icon: \"/whitelabel/realm-of-ra/icon.png\",\n cover: \"/whitelabel/realm-of-ra/cover.png\",\n colors: {\n primary: \"#de9534\",\n },\n },\n \"jokers-of-neon\": {\n id: \"jokers-of-neon\",\n name: \"Jokers of Neon\",\n icon: \"/whitelabel/jokers-of-neon/icon.png\",\n cover: \"/whitelabel/jokers-of-neon/cover.png\",\n colors: {\n primary: \"#A144B2\",\n },\n },\n flippyflop: {\n id: \"flippyflop\",\n name: \"FlippyFlop\",\n icon: \"/whitelabel/flippyflop/icon.png\",\n cover: \"/whitelabel/flippyflop/cover.png\",\n colors: {\n primary: \"#F38332\",\n },\n },\n \"savage-summit\": {\n id: \"savage-summit\",\n name: \"Savage Summit\",\n icon: \"/whitelabel/savage-summit/icon.png\",\n cover: \"/whitelabel/savage-summit/cover.png\",\n colors: {\n primary: \"#fbf7da\",\n },\n },\n \"dark-shuffle\": {\n id: \"dark-shuffle\",\n name: \"Dark Shuffle\",\n icon: \"/whitelabel/dark-shuffle/icon.svg\",\n cover: \"/whitelabel/dark-shuffle/cover.png\",\n colors: {\n primary: \"#F59100\",\n },\n },\n \"blob-arena\": {\n id: \"blob-arena\",\n name: \"Blob Arena\",\n icon: \"/whitelabel/blob-arena/icon.png\",\n cover: \"/whitelabel/blob-arena/cover.png\",\n colors: {\n primary: \"#980f06\",\n },\n },\n zkube: {\n id: \"zkube\",\n name: \"zKube\",\n icon: \"/whitelabel/zkube/icon.png\",\n cover: \"/whitelabel/zkube/cover.png\",\n colors: {\n primary: \"#5bc3e6\",\n },\n },\n};\n"],"mappings":";AAAA,SAA6B,sBAAsB;;;ACE5C,IAAM,iBAAyC;AAAA,EACpD,WAAW;AAAA,IACT,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,MACL,OAAO;AAAA,MACP,MAAM;AAAA,IACR;AAAA,EACF;AAAA,EACA,eAAe;AAAA,IACb,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,MACN,SAAS;AAAA,IACX;AAA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UAAI,SAAS,MAAM;AACjB,YACG,OAAO,yBAAyB,CAACA,uBAClC,OAAO,sBACP;AACA,mBAAS,KAAK,YAAY,SAAS;AACnC,mBAAS,WAAW;AAAA,QACtB;AAAA,MACF;AAAA,IACF,CAAC;AAED,aAAS,QAAQ,SAAS,iBAAiB;AAAA,MACzC,WAAW;AAAA,MACX,SAAS;AAAA,IACX,CAAC;AAED,UAAM,qBAAqB,SAAS,eAAe,YAAY;AAC/D,QAAI,SAAS,MAAM;AACjB,UACG,OAAO,yBAAyB,CAAC,sBAClC,OAAO,sBACP;AACA,iBAAS,KAAK,YAAY,SAAS;AAAA,MACrC;AAAA,IACF;AAEA,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,OAAO;AACL,QAAI,CAAC,KAAK,UAAW;AACrB,aAAS,KAAK,MAAM,WAAW;AAE/B,SAAK,UAAU,MAAM,aAAa;AAClC,SAAK,UAAU,MAAM,UAAU;AAAA,EACjC;AAAA,EAEA,QAAQ;AACN,QAAI,CAAC,KAAK,UAAW;AACrB,SAAK,UAAU;AAEf,aAAS,KAAK,MAAM,WAAW;AAE/B,SAAK,UAAU,MAAM,aAAa;AAClC,SAAK,UAAU,MAAM,UAAU;AAAA,EACjC;AAAA,EAEQ,SAAS;AACf,QAAI,CAAC,KAAK,OAAQ;AAElB,SAAK,OAAO,MAAM,aAAa;AAE/B,QAAI,OAAO,aAAa,KAAK;AAC3B,WAAK,OAAO,MAAM,SAAS;AAC3B,WAAK,OAAO,MAAM,QAAQ;AAC1B,WAAK,OAAO,MAAM,eAAe;AACjC;AAAA,IACF;AAEA,SAAK,OAAO,MAAM,SAAS;AAC3B,SAAK,OAAO,MAAM,QAAQ;AAC1B,SAAK,OAAO,MAAM,eAAe;AAAA,EACnC;AACF;","names":["existingController"]}
@@ -1,3 +1,5 @@
1
- export * from "./base";
2
- export * from "./keychain";
3
- export * from "./profile";
1
+ export { u as IFrame, t as IFrameOptions, v as KeychainIFrame, x as ProfileIFrame, w as ProfileIFrameOptions } from '../types-DIeWpu0p.js';
2
+ import 'starknet';
3
+ import '@starknet-io/types-js';
4
+ import '@cartridge/penpal';
5
+ import '@cartridge/account-wasm/controller';