index.d.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * Get the base path to where the assets can be found. Use "setAssetPath(path)"
  3. * if the path needs to be customized.
  4. */
  5. export declare const getAssetPath: (path: string) => string;
  6. /**
  7. * Used to manually set the base path where assets can be found.
  8. * If the script is used as "module", it's recommended to use "import.meta.url",
  9. * such as "setAssetPath(import.meta.url)". Other options include
  10. * "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
  11. * dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
  12. * But do note that this configuration depends on how your script is bundled, or lack of
  13. * bundling, and where your assets can be loaded from. Additionally custom bundling
  14. * will have to ensure the static assets are copied to its build directory.
  15. */
  16. export declare const setAssetPath: (path: string) => void;
  17. /**
  18. * Used to specify a nonce value that corresponds with an application's CSP.
  19. * When set, the nonce will be added to all dynamically created script and style tags at runtime.
  20. * Alternatively, the nonce value can be set on a meta tag in the DOM head
  21. * (<meta name="csp-nonce" content="{ nonce value here }" />) which
  22. * will result in the same behavior.
  23. */
  24. export declare const setNonce: (nonce: string) => void
  25. export interface SetPlatformOptions {
  26. raf?: (c: FrameRequestCallback) => number;
  27. ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
  28. rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
  29. }
  30. export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;