Script
The Script class provides utility methods for generating script URLs used with ScriptManager resolvers. It handles URL construction for different script hosting scenarios: development servers, filesystem, and remote servers.
Use Script static methods when configuring resolvers in ScriptManager.shared.addResolver() to generate properly formatted URLs for your scripts. The class handles webpack context integration and URL formatting automatically.
Usage
API Reference
Script.DEFAULT_TIMEOUT
Default timeout for script fetch requests.
- Type:
number - Value:
30000(30 seconds)
Script.getDevServerURL
Generates a URL for scripts hosted on the development server. This method returns a function that uses webpack context to construct the full URL with the correct public path and script filename.
- Type:
getDevServerURL(scriptId: string): (webpackContext) => string - Parameters:
scriptId: Id of the script to load
- Returns: Function that generates the dev server URL when called with webpack context
Script.getFileSystemURL
Generates a URL for scripts stored on the device's filesystem. Useful when scripts are bundled with the app or downloaded to local storage. The method automatically prepends file:/// to the scriptId.
- Type:
getFileSystemURL(scriptId: string): (webpackContext) => string - Parameters:
scriptId: Id of the script to load
- Returns: Function that generates the filesystem URL when called with webpack context
Script.getRemoteURL
Generates a URL for scripts hosted on a remote server. By default, appends the .chunk.bundle extension to the URL.
- Type:
getRemoteURL(url: string, options?: { excludeExtension?: boolean }): string | (webpackContext) => string - Parameters:
url: Base URL to the remote location where the script is storedoptions: Additional optionsexcludeExtension: Whentrue, returns the URL as-is without appending the chunk extension (default:false)
- Returns: URL string (if
excludeExtension: true) or function that generates the URL with extension
Script.getScriptUniqueId
Generates a unique identifier for a script, used internally for caching purposes.
- Type:
getScriptUniqueId(scriptId: string, caller?: string): string - Parameters:
scriptId: Id of the scriptcaller: Optional caller name to prefix the script id
- Returns: Unique identifier string
Related
- ScriptManager - The manager class that uses Script for URL resolution


