@cartridge/controller 0.5.5 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build$colon$deps.log +29 -29
- package/.turbo/turbo-build.log +30 -30
- package/dist/account.d.ts +1 -1
- package/dist/controller.d.ts +2 -2
- package/dist/controller.js +87 -12
- package/dist/controller.js.map +1 -1
- package/dist/iframe/base.d.ts +1 -1
- package/dist/iframe/base.js +8 -0
- package/dist/iframe/base.js.map +1 -1
- package/dist/iframe/index.d.ts +1 -1
- package/dist/iframe/index.js +15 -3
- package/dist/iframe/index.js.map +1 -1
- package/dist/iframe/keychain.d.ts +1 -1
- package/dist/iframe/keychain.js +8 -0
- package/dist/iframe/keychain.js.map +1 -1
- package/dist/iframe/profile.d.ts +1 -1
- package/dist/iframe/profile.js +15 -3
- package/dist/iframe/profile.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +335 -202
- package/dist/index.js.map +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +51 -1
- package/dist/provider.js.map +1 -1
- package/dist/session/account.d.ts +1 -1
- package/dist/session/account.js.map +1 -1
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.js +51 -1
- package/dist/session/index.js.map +1 -1
- package/dist/session/provider.d.ts +1 -1
- package/dist/session/provider.js +51 -1
- package/dist/session/provider.js.map +1 -1
- package/dist/telegram/backend.d.ts +1 -1
- package/dist/telegram/backend.js.map +1 -1
- package/dist/telegram/provider.d.ts +1 -1
- package/dist/telegram/provider.js +51 -1
- package/dist/telegram/provider.js.map +1 -1
- package/dist/{types-CCH1I4-O.d.ts → types-BReKRAuh.d.ts} +6 -2
- package/dist/types.d.ts +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
- package/src/controller.ts +20 -7
- package/src/iframe/base.ts +10 -0
- package/src/iframe/profile.ts +9 -3
- package/src/provider.ts +2 -1
- package/src/telegram/backend.ts +1 -1
- package/src/types.ts +2 -1
- package/tsconfig.json +2 -3
|
@@ -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 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
|
|
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 sendBackward() {\n if (!this.container) return;\n this.container.style.zIndex = \"9999\";\n }\n\n sendForward() {\n if (!this.container) return;\n this.container.style.zIndex = \"10000\";\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 version?: 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 version,\n username,\n slot,\n namespace,\n tokens,\n ...iframeOptions\n }: ProfileIFrameOptions) {\n const _profileUrl = (profileUrl || PROFILE_URL).replace(/\\/$/, \"\");\n let _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 if (version) {\n _url.searchParams.set(\"v\", encodeURIComponent(version));\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,GAM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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;;;AC3JO,IAAM,gBAAN,cAA4B,OAAgB;AAAA,EACjD,YAAY;AAAA,IACV;AAAA,IACA;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,QAAI,OAAO,IAAI;AAAA,MACb,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,QAAI,SAAS;AACX,WAAK,aAAa,IAAI,KAAK,mBAAmB,OAAO,CAAC;AAAA,IACxD;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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
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-BReKRAuh.js';
|
|
4
4
|
export { lookupAddresses, lookupUsernames } from './lookup.js';
|
|
5
5
|
export { toArray, toSessionPolicies, toWasmPolicies } from './utils.js';
|
|
6
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';
|