@cartridge/controller 0.5.3 → 0.5.5

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 (42) hide show
  1. package/.turbo/turbo-build$colon$deps.log +39 -36
  2. package/.turbo/turbo-build.log +39 -36
  3. package/dist/account.d.ts +2 -2
  4. package/dist/account.js.map +1 -1
  5. package/dist/controller.d.ts +2 -2
  6. package/dist/controller.js +5 -1
  7. package/dist/controller.js.map +1 -1
  8. package/dist/iframe/base.d.ts +2 -2
  9. package/dist/iframe/base.js +5 -1
  10. package/dist/iframe/base.js.map +1 -1
  11. package/dist/iframe/index.d.ts +2 -2
  12. package/dist/iframe/index.js +5 -1
  13. package/dist/iframe/index.js.map +1 -1
  14. package/dist/iframe/keychain.d.ts +2 -2
  15. package/dist/iframe/keychain.js +5 -1
  16. package/dist/iframe/keychain.js.map +1 -1
  17. package/dist/iframe/profile.d.ts +2 -2
  18. package/dist/iframe/profile.js +5 -1
  19. package/dist/iframe/profile.js.map +1 -1
  20. package/dist/index.d-BbTUPBeO.d.ts +68 -0
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +8562 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/provider.d.ts +2 -2
  25. package/dist/session/account.d.ts +2 -2
  26. package/dist/session/account.js.map +1 -1
  27. package/dist/session/index.d.ts +2 -2
  28. package/dist/session/index.js.map +1 -1
  29. package/dist/session/provider.d.ts +2 -2
  30. package/dist/session/provider.js.map +1 -1
  31. package/dist/telegram/provider.d.ts +2 -2
  32. package/dist/telegram/provider.js.map +1 -1
  33. package/dist/{types-1WsOoNO2.d.ts → types-CCH1I4-O.d.ts} +5 -3
  34. package/dist/types.d.ts +2 -2
  35. package/dist/types.js.map +1 -1
  36. package/dist/utils.d.ts +4 -2
  37. package/dist/utils.js +1 -0
  38. package/dist/utils.js.map +1 -1
  39. package/package.json +3 -4
  40. package/src/iframe/base.ts +7 -2
  41. package/src/types.ts +3 -1
  42. package/src/utils.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  import '@cartridge/penpal';
2
- export { o as IFrame, n as IFrameOptions } from '../types-1WsOoNO2.js';
2
+ export { o as IFrame, n as IFrameOptions } from '../types-CCH1I4-O.js';
3
3
  import 'starknet';
4
4
  import '@starknet-io/types-js';
5
- import '@cartridge/presets';
5
+ import '../index.d-BbTUPBeO.js';
@@ -4,6 +4,7 @@ var IFrame = class {
4
4
  constructor({
5
5
  id,
6
6
  url,
7
+ preset,
7
8
  theme,
8
9
  colorMode,
9
10
  onClose,
@@ -14,7 +15,10 @@ var IFrame = class {
14
15
  return;
15
16
  }
16
17
  if (theme) {
17
- url.searchParams.set("theme", encodeURIComponent(theme));
18
+ url.searchParams.set("theme", theme);
19
+ }
20
+ if (preset) {
21
+ url.searchParams.set("preset", preset);
18
22
  }
19
23
  if (colorMode) {
20
24
  url.searchParams.set("colorMode", colorMode);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/iframe/base.ts"],"sourcesContent":["import { AsyncMethodReturns, connectToChild } from \"@cartridge/penpal\";\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 colorMode,\n onClose,\n onConnect,\n methods = {},\n }: Pick<ControllerOptions, \"theme\" | \"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 if (theme) {\n url.searchParams.set(\"theme\", encodeURIComponent(theme));\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"],"mappings":";AAAA,SAA6B,sBAAsB;AAW5C,IAAM,SAAN,MAAqD;AAAA,EAM1D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,GAMG;AACD,QAAI,OAAO,aAAa,aAAa;AACnC;AAAA,IACF;AAEA,QAAI,OAAO;AACT,UAAI,aAAa,IAAI,SAAS,mBAAmB,KAAK,CAAC;AAAA,IACzD;AAEA,QAAI,WAAW;AACb,UAAI,aAAa,IAAI,aAAa,SAAS;AAAA,IAC7C;AAEA,SAAK,MAAM;AAEX,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,MAAM,IAAI,SAAS;AAC1B,WAAO,KAAK;AACZ,WAAO,MAAM,SAAS;AACtB,WAAO,QAAQ,IAAI,aAAa;AAChC,WAAO,QAAQ,IAAI,cAAc;AACjC,WAAO,QAAQ,IAAI,eAAe;AAClC,WAAO,QAAQ,IAAI,mBAAmB;AACtC,WAAO,QACL;AACF,QAAI,CAAC,CAAC,SAAS,kBAAkB;AAC/B,aAAO,QAAQ,IAAI,yCAAyC;AAAA,IAC9D;AAEA,UAAM,YAAY,SAAS,cAAc,KAAK;AAC9C,cAAU,KAAK;AACf,cAAU,MAAM,WAAW;AAC3B,cAAU,MAAM,SAAS;AACzB,cAAU,MAAM,QAAQ;AACxB,cAAU,MAAM,MAAM;AACtB,cAAU,MAAM,OAAO;AACvB,cAAU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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
+ {"version":3,"sources":["../../src/iframe/base.ts"],"sourcesContent":["import { AsyncMethodReturns, connectToChild } from \"@cartridge/penpal\";\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 preset,\n theme,\n colorMode,\n onClose,\n onConnect,\n methods = {},\n }: Pick<ControllerOptions, \"theme\" | \"preset\" | \"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 if (theme) {\n url.searchParams.set(\"theme\", theme);\n }\n\n if (preset) {\n url.searchParams.set(\"preset\", preset);\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"],"mappings":";AAAA,SAA6B,sBAAsB;AAW5C,IAAM,SAAN,MAAqD;AAAA,EAM1D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,GAMG;AACD,QAAI,OAAO,aAAa,aAAa;AACnC;AAAA,IACF;AAEA,QAAI,OAAO;AACT,UAAI,aAAa,IAAI,SAAS,KAAK;AAAA,IACrC;AAEA,QAAI,QAAQ;AACV,UAAI,aAAa,IAAI,UAAU,MAAM;AAAA,IACvC;AAEA,QAAI,WAAW;AACb,UAAI,aAAa,IAAI,aAAa,SAAS;AAAA,IAC7C;AAEA,SAAK,MAAM;AAEX,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,MAAM,IAAI,SAAS;AAC1B,WAAO,KAAK;AACZ,WAAO,MAAM,SAAS;AACtB,WAAO,QAAQ,IAAI,aAAa;AAChC,WAAO,QAAQ,IAAI,cAAc;AACjC,WAAO,QAAQ,IAAI,eAAe;AAClC,WAAO,QAAQ,IAAI,mBAAmB;AACtC,WAAO,QACL;AACF,QAAI,CAAC,CAAC,SAAS,kBAAkB;AAC/B,aAAO,QAAQ,IAAI,yCAAyC;AAAA,IAC9D;AAEA,UAAM,YAAY,SAAS,cAAc,KAAK;AAC9C,cAAU,KAAK;AACf,cAAU,MAAM,WAAW;AAC3B,cAAU,MAAM,SAAS;AACzB,cAAU,MAAM,QAAQ;AACxB,cAAU,MAAM,MAAM;AACtB,cAAU,MAAM,OAAO;AACvB,cAAU,MAAM,SAAS;AACzB,cAAU,MAAM,kBAAkB;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Aa;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,5 +1,5 @@
1
- export { o as IFrame, n as IFrameOptions, p as KeychainIFrame, r as ProfileIFrame, q as ProfileIFrameOptions } from '../types-1WsOoNO2.js';
1
+ export { o as IFrame, n as IFrameOptions, p as KeychainIFrame, r as ProfileIFrame, q as ProfileIFrameOptions } from '../types-CCH1I4-O.js';
2
2
  import 'starknet';
3
3
  import '@starknet-io/types-js';
4
4
  import '@cartridge/penpal';
5
- import '@cartridge/presets';
5
+ import '../index.d-BbTUPBeO.js';
@@ -4,6 +4,7 @@ var IFrame = class {
4
4
  constructor({
5
5
  id,
6
6
  url,
7
+ preset,
7
8
  theme,
8
9
  colorMode,
9
10
  onClose,
@@ -14,7 +15,10 @@ var IFrame = class {
14
15
  return;
15
16
  }
16
17
  if (theme) {
17
- url.searchParams.set("theme", encodeURIComponent(theme));
18
+ url.searchParams.set("theme", theme);
19
+ }
20
+ if (preset) {
21
+ url.searchParams.set("preset", preset);
18
22
  }
19
23
  if (colorMode) {
20
24
  url.searchParams.set("colorMode", colorMode);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/iframe/base.ts","../../src/constants.ts","../../src/iframe/keychain.ts","../../src/iframe/profile.ts"],"sourcesContent":["import { AsyncMethodReturns, connectToChild } from \"@cartridge/penpal\";\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 colorMode,\n onClose,\n onConnect,\n methods = {},\n }: Pick<ControllerOptions, \"theme\" | \"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 if (theme) {\n url.searchParams.set(\"theme\", encodeURIComponent(theme));\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","export const KEYCHAIN_URL = \"https://x.cartridge.gg\";\nexport const PROFILE_URL = \"https://profile.cartridge.gg\";\nexport const API_URL = \"https://api.cartridge.gg\";\n","import { KEYCHAIN_URL } from \"../constants\";\nimport { Keychain, KeychainOptions } from \"../types\";\nimport { IFrame, IFrameOptions } from \"./base\";\n\ntype KeychainIframeOptions = IFrameOptions<Keychain> & KeychainOptions;\n\nexport class KeychainIFrame extends IFrame<Keychain> {\n constructor({ url, policies, ...iframeOptions }: KeychainIframeOptions) {\n const _url = new URL(url ?? KEYCHAIN_URL);\n\n if (policies) {\n _url.searchParams.set(\n \"policies\",\n encodeURIComponent(JSON.stringify(policies)),\n );\n }\n\n super({\n ...iframeOptions,\n id: \"controller-keychain\",\n url: _url,\n });\n }\n}\n","import { PROFILE_URL } from \"../constants\";\nimport { Profile, ProfileOptions } from \"../types\";\nimport { IFrame, IFrameOptions } from \"./base\";\n\nexport type ProfileIFrameOptions = IFrameOptions<Profile> &\n ProfileOptions & {\n rpcUrl: string;\n username: string;\n slot?: string;\n namespace?: string;\n };\n\nexport class ProfileIFrame extends IFrame<Profile> {\n constructor({\n profileUrl,\n rpcUrl,\n namespace,\n slot,\n username,\n tokens,\n ...iframeOptions\n }: ProfileIFrameOptions) {\n const _profileUrl = (profileUrl || PROFILE_URL).replace(/\\/$/, \"\");\n const _url = new URL(\n slot\n ? namespace\n ? `${_profileUrl}/account/${username}/slot/${slot}?ps=${encodeURIComponent(\n slot,\n )}&ns=${encodeURIComponent(namespace)}`\n : `${_profileUrl}/account/${username}/slot/${slot}?ps=${encodeURIComponent(\n slot,\n )}`\n : `${_profileUrl}/account/${username}`,\n );\n\n _url.searchParams.set(\"rpcUrl\", encodeURIComponent(rpcUrl));\n\n if (tokens?.erc20) {\n _url.searchParams.set(\n \"erc20\",\n encodeURIComponent(tokens.erc20.toString()),\n );\n }\n\n super({\n ...iframeOptions,\n id: \"controller-profile\",\n url: _url,\n });\n }\n}\n"],"mappings":";AAAA,SAA6B,sBAAsB;AAW5C,IAAM,SAAN,MAAqD;AAAA,EAM1D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,GAMG;AACD,QAAI,OAAO,aAAa,aAAa;AACnC;AAAA,IACF;AAEA,QAAI,OAAO;AACT,UAAI,aAAa,IAAI,SAAS,mBAAmB,KAAK,CAAC;AAAA,IACzD;AAEA,QAAI,WAAW;AACb,UAAI,aAAa,IAAI,aAAa,SAAS;AAAA,IAC7C;AAEA,SAAK,MAAM;AAEX,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO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AAI;AAAA,MACJ,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACF;;;ACXO,IAAM,gBAAN,cAA4B,OAAgB;AAAA,EACjD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAAyB;AACvB,UAAM,eAAe,cAAc,aAAa,QAAQ,OAAO,EAAE;AACjE,UAAM,OAAO,IAAI;AAAA,MACf,OACI,YACE,GAAG,WAAW,YAAY,QAAQ,SAAS,IAAI,OAAO;AAAA,QACpD;AAAA,MACF,CAAC,OAAO,mBAAmB,SAAS,CAAC,KACrC,GAAG,WAAW,YAAY,QAAQ,SAAS,IAAI,OAAO;AAAA,QACpD;AAAA,MACF,CAAC,KACH,GAAG,WAAW,YAAY,QAAQ;AAAA,IACxC;AAEA,SAAK,aAAa,IAAI,UAAU,mBAAmB,MAAM,CAAC;AAE1D,QAAI,QAAQ,OAAO;AACjB,WAAK,aAAa;AAAA,QAChB;AAAA,QACA,mBAAmB,OAAO,MAAM,SAAS,CAAC;AAAA,MAC5C;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACF;","names":["existingController"]}
1
+ {"version":3,"sources":["../../src/iframe/base.ts","../../src/constants.ts","../../src/iframe/keychain.ts","../../src/iframe/profile.ts"],"sourcesContent":["import { AsyncMethodReturns, connectToChild } from \"@cartridge/penpal\";\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 preset,\n theme,\n colorMode,\n onClose,\n onConnect,\n methods = {},\n }: Pick<ControllerOptions, \"theme\" | \"preset\" | \"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 if (theme) {\n url.searchParams.set(\"theme\", theme);\n }\n\n if (preset) {\n url.searchParams.set(\"preset\", preset);\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","export const KEYCHAIN_URL = \"https://x.cartridge.gg\";\nexport const PROFILE_URL = \"https://profile.cartridge.gg\";\nexport const API_URL = \"https://api.cartridge.gg\";\n","import { KEYCHAIN_URL } from \"../constants\";\nimport { Keychain, KeychainOptions } from \"../types\";\nimport { IFrame, IFrameOptions } from \"./base\";\n\ntype KeychainIframeOptions = IFrameOptions<Keychain> & KeychainOptions;\n\nexport class KeychainIFrame extends IFrame<Keychain> {\n constructor({ url, policies, ...iframeOptions }: KeychainIframeOptions) {\n const _url = new URL(url ?? KEYCHAIN_URL);\n\n if (policies) {\n _url.searchParams.set(\n \"policies\",\n encodeURIComponent(JSON.stringify(policies)),\n );\n }\n\n super({\n ...iframeOptions,\n id: \"controller-keychain\",\n url: _url,\n });\n }\n}\n","import { PROFILE_URL } from \"../constants\";\nimport { Profile, ProfileOptions } from \"../types\";\nimport { IFrame, IFrameOptions } from \"./base\";\n\nexport type ProfileIFrameOptions = IFrameOptions<Profile> &\n ProfileOptions & {\n rpcUrl: string;\n username: string;\n slot?: string;\n namespace?: string;\n };\n\nexport class ProfileIFrame extends IFrame<Profile> {\n constructor({\n profileUrl,\n rpcUrl,\n namespace,\n slot,\n username,\n tokens,\n ...iframeOptions\n }: ProfileIFrameOptions) {\n const _profileUrl = (profileUrl || PROFILE_URL).replace(/\\/$/, \"\");\n const _url = new URL(\n slot\n ? namespace\n ? `${_profileUrl}/account/${username}/slot/${slot}?ps=${encodeURIComponent(\n slot,\n )}&ns=${encodeURIComponent(namespace)}`\n : `${_profileUrl}/account/${username}/slot/${slot}?ps=${encodeURIComponent(\n slot,\n )}`\n : `${_profileUrl}/account/${username}`,\n );\n\n _url.searchParams.set(\"rpcUrl\", encodeURIComponent(rpcUrl));\n\n if (tokens?.erc20) {\n _url.searchParams.set(\n \"erc20\",\n encodeURIComponent(tokens.erc20.toString()),\n );\n }\n\n super({\n ...iframeOptions,\n id: \"controller-profile\",\n url: _url,\n });\n }\n}\n"],"mappings":";AAAA,SAA6B,sBAAsB;AAW5C,IAAM,SAAN,MAAqD;AAAA,EAM1D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,GAMG;AACD,QAAI,OAAO,aAAa,aAAa;AACnC;AAAA,IACF;AAEA,QAAI,OAAO;AACT,UAAI,aAAa,IAAI,SAAS,KAAK;AAAA,IACrC;AAEA,QAAI,QAAQ;AACV,UAAI,aAAa,IAAI,UAAU,MAAM;AAAA,IACvC;AAEA,QAAI,WAAW;AACb,UAAI,aAAa,IAAI,aAAa,SAAS;AAAA,IAC7C;AAEA,SAAK,MAAM;AAEX,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,MAAM,IAAI,SAAS;AAC1B,WAAO,KAAK;AACZ,WAAO,MAAM,SAAS;AACtB,WAAO,QAAQ,IAAI,aAAa;AAChC,WAAO,QAAQ,IAAI,cAAc;A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IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAAyB;AACvB,UAAM,eAAe,cAAc,aAAa,QAAQ,OAAO,EAAE;AACjE,UAAM,OAAO,IAAI;AAAA,MACf,OACI,YACE,GAAG,WAAW,YAAY,QAAQ,SAAS,IAAI,OAAO;AAAA,QACpD;AAAA,MACF,CAAC,OAAO,mBAAmB,SAAS,CAAC,KACrC,GAAG,WAAW,YAAY,QAAQ,SAAS,IAAI,OAAO;AAAA,QACpD;AAAA,MACF,CAAC,KACH,GAAG,WAAW,YAAY,QAAQ;AAAA,IACxC;AAEA,SAAK,aAAa,IAAI,UAAU,mBAAmB,MAAM,CAAC;AAE1D,QAAI,QAAQ,OAAO;AACjB,WAAK,aAAa;AAAA,QAChB;AAAA,QACA,mBAAmB,OAAO,MAAM,SAAS,CAAC;AAAA,MAC5C;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACF;","names":["existingController"]}
@@ -1,5 +1,5 @@
1
- export { p as KeychainIFrame } from '../types-1WsOoNO2.js';
1
+ export { p as KeychainIFrame } from '../types-CCH1I4-O.js';
2
2
  import 'starknet';
3
3
  import '@starknet-io/types-js';
4
4
  import '@cartridge/penpal';
5
- import '@cartridge/presets';
5
+ import '../index.d-BbTUPBeO.js';
@@ -7,6 +7,7 @@ var IFrame = class {
7
7
  constructor({
8
8
  id,
9
9
  url,
10
+ preset,
10
11
  theme,
11
12
  colorMode,
12
13
  onClose,
@@ -17,7 +18,10 @@ var IFrame = class {
17
18
  return;
18
19
  }
19
20
  if (theme) {
20
- url.searchParams.set("theme", encodeURIComponent(theme));
21
+ url.searchParams.set("theme", theme);
22
+ }
23
+ if (preset) {
24
+ url.searchParams.set("preset", preset);
21
25
  }
22
26
  if (colorMode) {
23
27
  url.searchParams.set("colorMode", colorMode);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants.ts","../../src/iframe/base.ts","../../src/iframe/keychain.ts"],"sourcesContent":["export const KEYCHAIN_URL = \"https://x.cartridge.gg\";\nexport const PROFILE_URL = \"https://profile.cartridge.gg\";\nexport const API_URL = \"https://api.cartridge.gg\";\n","import { AsyncMethodReturns, connectToChild } from \"@cartridge/penpal\";\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 colorMode,\n onClose,\n onConnect,\n methods = {},\n }: Pick<ControllerOptions, \"theme\" | \"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 if (theme) {\n url.searchParams.set(\"theme\", encodeURIComponent(theme));\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 { KEYCHAIN_URL } from \"../constants\";\nimport { Keychain, KeychainOptions } from \"../types\";\nimport { IFrame, IFrameOptions } from \"./base\";\n\ntype KeychainIframeOptions = IFrameOptions<Keychain> & KeychainOptions;\n\nexport class KeychainIFrame extends IFrame<Keychain> {\n constructor({ url, policies, ...iframeOptions }: KeychainIframeOptions) {\n const _url = new URL(url ?? KEYCHAIN_URL);\n\n if (policies) {\n _url.searchParams.set(\n \"policies\",\n encodeURIComponent(JSON.stringify(policies)),\n );\n }\n\n super({\n ...iframeOptions,\n id: \"controller-keychain\",\n url: _url,\n });\n }\n}\n"],"mappings":";AAAO,IAAM,eAAe;;;ACA5B,SAA6B,sBAAsB;AAW5C,IAAM,SAAN,MAAqD;AAAA,EAM1D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,GAMG;AACD,QAAI,OAAO,aAAa,aAAa;AACnC;AAAA,IACF;AAEA,QAAI,OAAO;AACT,UAAI,aAAa,IAAI,SAAS,mBAAmB,KAAK,CAAC;AAAA,IACzD;AAEA,QAAI,WAAW;AACb,UAAI,aAAa,IAAI,aAAa,SAAS;AAAA,IAC7C;AAEA,SAAK,MAAM;AAEX,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,MAAM,IAAI,SAAS;AAC1B,WAAO,KAAK;AACZ,WAAO,MAAM,SAAS;AACtB,WAAO,QAAQ,IAAI,aAAa;AAChC,WAAO,QAAQ,IAAI,cAAc;AACjC,WAAO,QAAQ,IAAI,eAAe;AAClC,WAAO,QAAQ,IAAI,mBAAmB;AACtC,WAAO,QACL;AACF,QAAI,CAAC,CAAC,SAAS,kBAAkB;AAC/B,aAAO,QAAQ,IAAI,yCAAyC;AAAA,IAC9D;AAEA,UAAM,YAAY,SAAS,cAAc,KAAK;AAC9C,cAAU,KAAK;AACf,cAAU,MAAM,WAAW;AAC3B,cAAU,MAAM,SAAS;AACzB,cAAU,MAAM,QAAQ;AACxB,cAAU,MAAM,MAAM;AACtB,cAAU,MAAM,OAAO;AACvB,cAAU,MAAM,SAAS;AACzB,cAAU,MAAM,kBAAkB;AAClC,cAAU,MAA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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;;;ACnJO,IAAM,iBAAN,cAA6B,OAAiB;AAAA,EACnD,YAAY,EAAE,KAAK,UAAU,GAAG,cAAc,GAA0B;AACtE,UAAM,OAAO,IAAI,IAAI,OAAO,YAAY;AAExC,QAAI,UAAU;AACZ,WAAK,aAAa;AAAA,QAChB;AAAA,QACA,mBAAmB,KAAK,UAAU,QAAQ,CAAC;AAAA,MAC7C;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACF;","names":["existingController"]}
1
+ {"version":3,"sources":["../../src/constants.ts","../../src/iframe/base.ts","../../src/iframe/keychain.ts"],"sourcesContent":["export const KEYCHAIN_URL = \"https://x.cartridge.gg\";\nexport const PROFILE_URL = \"https://profile.cartridge.gg\";\nexport const API_URL = \"https://api.cartridge.gg\";\n","import { AsyncMethodReturns, connectToChild } from \"@cartridge/penpal\";\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 preset,\n theme,\n colorMode,\n onClose,\n onConnect,\n methods = {},\n }: Pick<ControllerOptions, \"theme\" | \"preset\" | \"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 if (theme) {\n url.searchParams.set(\"theme\", theme);\n }\n\n if (preset) {\n url.searchParams.set(\"preset\", preset);\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 { KEYCHAIN_URL } from \"../constants\";\nimport { Keychain, KeychainOptions } from \"../types\";\nimport { IFrame, IFrameOptions } from \"./base\";\n\ntype KeychainIframeOptions = IFrameOptions<Keychain> & KeychainOptions;\n\nexport class KeychainIFrame extends IFrame<Keychain> {\n constructor({ url, policies, ...iframeOptions }: KeychainIframeOptions) {\n const _url = new URL(url ?? KEYCHAIN_URL);\n\n if (policies) {\n _url.searchParams.set(\n \"policies\",\n encodeURIComponent(JSON.stringify(policies)),\n );\n }\n\n super({\n ...iframeOptions,\n id: \"controller-keychain\",\n url: _url,\n });\n }\n}\n"],"mappings":";AAAO,IAAM,eAAe;;;ACA5B,SAA6B,sBAAsB;AAW5C,IAAM,SAAN,MAAqD;AAAA,EAM1D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,GAMG;AACD,QAAI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AiB;AAAA,EACnD,YAAY,EAAE,KAAK,UAAU,GAAG,cAAc,GAA0B;AACtE,UAAM,OAAO,IAAI,IAAI,OAAO,YAAY;AAExC,QAAI,UAAU;AACZ,WAAK,aAAa;AAAA,QAChB;AAAA,QACA,mBAAmB,KAAK,UAAU,QAAQ,CAAC;AAAA,MAC7C;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACF;","names":["existingController"]}
@@ -1,5 +1,5 @@
1
- export { r as ProfileIFrame, q as ProfileIFrameOptions } from '../types-1WsOoNO2.js';
1
+ export { r as ProfileIFrame, q as ProfileIFrameOptions } from '../types-CCH1I4-O.js';
2
2
  import 'starknet';
3
3
  import '@starknet-io/types-js';
4
4
  import '@cartridge/penpal';
5
- import '@cartridge/presets';
5
+ import '../index.d-BbTUPBeO.js';
@@ -7,6 +7,7 @@ var IFrame = class {
7
7
  constructor({
8
8
  id,
9
9
  url,
10
+ preset,
10
11
  theme,
11
12
  colorMode,
12
13
  onClose,
@@ -17,7 +18,10 @@ var IFrame = class {
17
18
  return;
18
19
  }
19
20
  if (theme) {
20
- url.searchParams.set("theme", encodeURIComponent(theme));
21
+ url.searchParams.set("theme", theme);
22
+ }
23
+ if (preset) {
24
+ url.searchParams.set("preset", preset);
21
25
  }
22
26
  if (colorMode) {
23
27
  url.searchParams.set("colorMode", colorMode);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants.ts","../../src/iframe/base.ts","../../src/iframe/profile.ts"],"sourcesContent":["export const KEYCHAIN_URL = \"https://x.cartridge.gg\";\nexport const PROFILE_URL = \"https://profile.cartridge.gg\";\nexport const API_URL = \"https://api.cartridge.gg\";\n","import { AsyncMethodReturns, connectToChild } from \"@cartridge/penpal\";\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 colorMode,\n onClose,\n onConnect,\n methods = {},\n }: Pick<ControllerOptions, \"theme\" | \"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 if (theme) {\n url.searchParams.set(\"theme\", encodeURIComponent(theme));\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 { PROFILE_URL } from \"../constants\";\nimport { Profile, ProfileOptions } from \"../types\";\nimport { IFrame, IFrameOptions } from \"./base\";\n\nexport type ProfileIFrameOptions = IFrameOptions<Profile> &\n ProfileOptions & {\n rpcUrl: string;\n username: string;\n slot?: string;\n namespace?: string;\n };\n\nexport class ProfileIFrame extends IFrame<Profile> {\n constructor({\n profileUrl,\n rpcUrl,\n namespace,\n slot,\n username,\n tokens,\n ...iframeOptions\n }: ProfileIFrameOptions) {\n const _profileUrl = (profileUrl || PROFILE_URL).replace(/\\/$/, \"\");\n const _url = new URL(\n slot\n ? namespace\n ? `${_profileUrl}/account/${username}/slot/${slot}?ps=${encodeURIComponent(\n slot,\n )}&ns=${encodeURIComponent(namespace)}`\n : `${_profileUrl}/account/${username}/slot/${slot}?ps=${encodeURIComponent(\n slot,\n )}`\n : `${_profileUrl}/account/${username}`,\n );\n\n _url.searchParams.set(\"rpcUrl\", encodeURIComponent(rpcUrl));\n\n if (tokens?.erc20) {\n _url.searchParams.set(\n \"erc20\",\n encodeURIComponent(tokens.erc20.toString()),\n );\n }\n\n super({\n ...iframeOptions,\n id: \"controller-profile\",\n url: _url,\n });\n }\n}\n"],"mappings":";AACO,IAAM,cAAc;;;ACD3B,SAA6B,sBAAsB;AAW5C,IAAM,SAAN,MAAqD;AAAA,EAM1D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,GAMG;AACD,QAAI,OAAO,aAAa,aAAa;AACnC;AAAA,IACF;AAEA,QAAI,OAAO;AACT,UAAI,aAAa,IAAI,SAAS,mBAAmB,KAAK,CAAC;AAAA,IACzD;AAEA,QAAI,WAAW;AACb,UAAI,aAAa,IAAI,aAAa,SAAS;AAAA,IAC7C;AAEA,SAAK,MAAM;AAEX,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,MAAM,IAAI,SAAS;AAC1B,WAAO,KAAK;AACZ,WAAO,MAAM,SAAS;AACtB,WAAO,QAAQ,IAAI,aAAa;AAChC,WAAO,QAAQ,IAAI,cAAc;AACjC,WAAO,QAAQ,IAAI,eAAe;AAClC,WAAO,QAAQ,IAAI,mBAAmB;AACtC,WAAO,QACL;AACF,QAAI,CAAC,CAAC,SAAS,kBAAkB;AAC/B,aAAO,QAAQ,IAAI,yCAAyC;AAAA,IAC9D;AAEA,UAAM,YAAY,SAAS,cAAc,KAAK;AAC9C,cAAU,KAAK;AACf,cAAU,MAAM,WAAW;AAC3B,cAAU,MAAM,SAAS;AACzB,cAAU,MAAM,QAAQ;AACxB,cAAU,MAAM,MAAM;AACtB,cAAU,MAAM,OAAO;AACvB,cAAU,MAAM,SAAS;AACzB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,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;;;AC7IO,IAAM,gBAAN,cAA4B,OAAgB;AAAA,EACjD,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GAAyB;AACvB,UAAM,eAAe,cAAc,aAAa,QAAQ,OAAO,EAAE;AACjE,UAAM,OAAO,IAAI;AAAA,MACf,OACI,YACE,GAAG,WAAW,YAAY,QAAQ,SAAS,IAAI,OAAO;AAAA,QACpD;AAAA,MACF,CAAC,OAAO,mBAAmB,SAAS,CAAC,KACrC,GAAG,WAAW,YAAY,QAAQ,SAAS,IAAI,OAAO;AAAA,QACpD;AAAA,MACF,CAAC,KACH,GAAG,WAAW,YAAY,QAAQ;AAAA,IACxC;AAEA,SAAK,aAAa,IAAI,UAAU,mBAAmB,MAAM,CAAC;AAE1D,QAAI,QAAQ,OAAO;AACjB,WAAK,aAAa;AAAA,QAChB;AAAA,QACA,mBAAmB,OAAO,MAAM,SAAS,CAAC;AAAA,MAC5C;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACF;","names":["existingController"]}
1
+ {"version":3,"sources":["../../src/constants.ts","../../src/iframe/base.ts","../../src/iframe/profile.ts"],"sourcesContent":["export const KEYCHAIN_URL = \"https://x.cartridge.gg\";\nexport const PROFILE_URL = \"https://profile.cartridge.gg\";\nexport const API_URL = \"https://api.cartridge.gg\";\n","import { AsyncMethodReturns, connectToChild } from \"@cartridge/penpal\";\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 preset,\n theme,\n colorMode,\n onClose,\n onConnect,\n methods = {},\n }: Pick<ControllerOptions, \"theme\" | \"preset\" | \"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 if (theme) {\n url.searchParams.set(\"theme\", theme);\n }\n\n if (preset) {\n url.searchParams.set(\"preset\", preset);\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 { PROFILE_URL } from \"../constants\";\nimport { Profile, ProfileOptions } from \"../types\";\nimport { IFrame, IFrameOptions } from \"./base\";\n\nexport type ProfileIFrameOptions = IFrameOptions<Profile> &\n ProfileOptions & {\n rpcUrl: string;\n username: string;\n slot?: string;\n namespace?: string;\n };\n\nexport class ProfileIFrame extends IFrame<Profile> {\n constructor({\n profileUrl,\n rpcUrl,\n namespace,\n slot,\n username,\n tokens,\n ...iframeOptions\n }: ProfileIFrameOptions) {\n const _profileUrl = (profileUrl || PROFILE_URL).replace(/\\/$/, \"\");\n const _url = new URL(\n slot\n ? namespace\n ? `${_profileUrl}/account/${username}/slot/${slot}?ps=${encodeURIComponent(\n slot,\n )}&ns=${encodeURIComponent(namespace)}`\n : `${_profileUrl}/account/${username}/slot/${slot}?ps=${encodeURIComponent(\n slot,\n )}`\n : `${_profileUrl}/account/${username}`,\n );\n\n _url.searchParams.set(\"rpcUrl\", encodeURIComponent(rpcUrl));\n\n if (tokens?.erc20) {\n _url.searchParams.set(\n \"erc20\",\n encodeURIComponent(tokens.erc20.toString()),\n );\n }\n\n super({\n ...iframeOptions,\n id: \"controller-profile\",\n url: _url,\n });\n }\n}\n"],"mappings":";AACO,IAAM,cAAc;;;ACD3B,SAA6B,sBAAsB;AAW5C,IAAM,SAAN,MAAqD;AAAA,EAM1D,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,CAAC;AAAA,EACb,GAMG;AACD,QAAI,OAAO,aAAa,aAAa;AACnC;AAAA,IACF;AAEA,QAAI,OAAO;AACT,UAAI,aAAa,IAAI,SAAS,KAAK;AAAA,IACrC;AAEA,QAAI,QAAQ;AACV,UAAI,aAAa,IAAI,UAAU,MAAM;AAAA,IACvC;AAEA,QAAI,WAAW;AACb,UAAI,aAAa,IAAI,aAAa,SAAS;AAAA,IAC7C;AAEA,SAAK,MAAM;AAEX,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,MAAM,IAAI,SAAS;AAC1B,WAAO,KAAK;AACZ,WAAO,MAAM,SAAS;AACtB,WAAO,QAAQ,IAAI,aAAa;AAChC,WAAO,QAAQ,IAAI,cAAc;AACjC,WAAO,QAAQ,IAA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Aa,IAAI,UAAU,mBAAmB,MAAM,CAAC;AAE1D,QAAI,QAAQ,OAAO;AACjB,WAAK,aAAa;AAAA,QAChB;AAAA,QACA,mBAAmB,OAAO,MAAM,SAAS,CAAC;AAAA,MAC5C;AAAA,IACF;AAEA,UAAM;AAAA,MACJ,GAAG;AAAA,MACH,IAAI;AAAA,MACJ,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACF;","names":["existingController"]}
@@ -0,0 +1,68 @@
1
+ import { TypedData } from '@starknet-io/types-js';
2
+
3
+ declare const controllerConfigs: ControllerConfigs;
4
+ declare const erc20Metadata: EkuboERC20Metadata[];
5
+ declare const defaultTheme: ControllerTheme;
6
+ type EkuboERC20Metadata = {
7
+ name: string;
8
+ symbol: string;
9
+ decimals: number;
10
+ l2_token_address: string;
11
+ sort_order: number;
12
+ total_supply: number | null;
13
+ logo_url?: string;
14
+ hidden?: boolean;
15
+ disabled?: boolean;
16
+ };
17
+ type Policy = CallPolicy | TypedDataPolicy;
18
+ type CallPolicy = {
19
+ target: string;
20
+ method: string;
21
+ description?: string;
22
+ };
23
+ type TypedDataPolicy = Omit<TypedData, "message">;
24
+ type Policies = Policy[] | SessionPolicies;
25
+ type SessionPolicies = {
26
+ /** The key must be the contract address */
27
+ contracts?: ContractPolicies;
28
+ messages?: SignMessagePolicy[];
29
+ };
30
+ type ContractPolicies = Record<string, ContractPolicy>;
31
+ type ContractPolicy = {
32
+ name?: string;
33
+ description?: string;
34
+ methods: Method[];
35
+ };
36
+ type Method = {
37
+ name?: string;
38
+ description?: string;
39
+ entrypoint: string;
40
+ };
41
+ type SignMessagePolicy = TypedDataPolicy & {
42
+ name?: string;
43
+ description?: string;
44
+ };
45
+ type ControllerConfig = {
46
+ origin: string | string[];
47
+ policies?: SessionPolicies;
48
+ theme?: ControllerTheme;
49
+ };
50
+ type ControllerConfigs = Record<string, ControllerConfig>;
51
+ type ColorMode = "light" | "dark";
52
+ type ControllerTheme = {
53
+ name: string;
54
+ icon: string;
55
+ cover: ThemeValue<string>;
56
+ colors?: ControllerColors;
57
+ };
58
+ type ControllerColors = {
59
+ primary?: ControllerColor;
60
+ primaryForeground?: ControllerColor;
61
+ };
62
+ type ControllerColor = ThemeValue<string>;
63
+ type ThemeValue<T> = T | {
64
+ dark: T;
65
+ light: T;
66
+ };
67
+
68
+ export { type CallPolicy as C, type EkuboERC20Metadata as E, type Method as M, type Policies as P, type SessionPolicies as S, type ThemeValue as T, type ColorMode as a, type ContractPolicies as b, type ContractPolicy as c, type ControllerColor as d, type ControllerColors as e, type ControllerConfig as f, type ControllerConfigs as g, type ControllerTheme as h, type Policy as i, type SignMessagePolicy as j, type TypedDataPolicy as k, controllerConfigs as l, defaultTheme as m, erc20Metadata as n };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export { default } from './controller.js';
2
2
  export { NotReadyToConnect } from './errors.js';
3
- export { C as ConnectError, b as ConnectReply, e as ControllerAccounts, a as ControllerError, g as ControllerOptions, D as DeployReply, E as ExecuteReply, h as IFrameOptions, I as IFrames, K as Keychain, j as KeychainOptions, L as LookupRequest, d as LookupResponse, c as LookupResult, M as Modal, m as Prefund, P as ProbeReply, f as Profile, l as ProfileContextTypeVariant, k as ProfileOptions, i as ProviderOptions, R as ResponseCodes, S as Session, T as Tokens } from './types-1WsOoNO2.js';
3
+ export { C as ConnectError, b as ConnectReply, e as ControllerAccounts, a as ControllerError, g as ControllerOptions, D as DeployReply, E as ExecuteReply, h as IFrameOptions, I as IFrames, K as Keychain, j as KeychainOptions, L as LookupRequest, d as LookupResponse, c as LookupResult, M as Modal, m as Prefund, P as ProbeReply, f as Profile, l as ProfileContextTypeVariant, k as ProfileOptions, i as ProviderOptions, R as ResponseCodes, S as Session, T as Tokens } from './types-CCH1I4-O.js';
4
4
  export { lookupAddresses, lookupUsernames } from './lookup.js';
5
5
  export { toArray, toSessionPolicies, toWasmPolicies } from './utils.js';
6
- export * from '@cartridge/presets';
6
+ export { C as CallPolicy, a as ColorMode, b as ContractPolicies, c as ContractPolicy, d as ControllerColor, e as ControllerColors, f as ControllerConfig, g as ControllerConfigs, h as ControllerTheme, E as EkuboERC20Metadata, M as Method, P as Policies, i as Policy, S as SessionPolicies, j as SignMessagePolicy, T as ThemeValue, k as TypedDataPolicy, l as controllerConfigs, m as defaultTheme, n as erc20Metadata } from './index.d-BbTUPBeO.js';
7
7
  import './provider.js';
8
8
  import 'starknet';
9
9
  import '@starknet-io/types-js';