/** * This interface describes how a client-side component is to be loaded and initialized by a SharePoint client * framework. It contains all data for loading an entrypoint script and its dependency scripts. * * @beta */ export interface IClientSideComponentLoaderConfiguration { /** * This is an array of fully-qualified paths to be prepended to each of the script resource paths with the * "internal" or "localized" type. If one fails to load, the loader will attempt to load from the next until there * are no base paths remaining. * * @remarks * All "internal" and "localized" script resources that do not have fully-qualified URLs * as their "path" field values must be hosted under each of the paths listed in this property. For example, if an * internal module's "path" field value is `"master_2015-04-20/my-application.bundle_1928f8a0.js"` and this field's * value is `[ "https://contoso.akamaihd.net/files/", "https://contoso.msecnd.net/files/" ]`, the loader will first * attempt to load this script resource from the URL * `"https://contoso.akamaihd.net/files/master_2015-04-20/my-application.bundle_1928f8a0.js"`. If loading from * that URL fails, the loader will then attempt to load this script resource from * `"https://contoso.msecnd.net/files/master_2015-04-20/my-application.bundle_1928f8a0.js"`. If that URL fails * to load, the component will fail to load and an error will be returned. It is important to note that the support * for multiple base URLs is purely for failover support. This means that all files must be present on all hosts * listed in this field. * * Usage: Base URLs for script resources with the "internal" or "localized" type. * * Supported values: Any URL that contains all internal scripts referenced in the "scriptResources" dictionary. * * Example: `[ "https://contoso.akamaihd.net/files/", "https://contoso.msecnd.net/files/" ]` */ internalModuleBaseUrls: string[]; /** * This is the ID of one of the entries in the "scriptResources" dictionary. * * @remarks * The loader will download and evaluate the script resource referenced in this field, resolve all dependencies * against the keys in the "scriptResources", and return the exported object to the loader's calling function. * The entry referenced in the "scriptResources" dictionary must be of the "internal" or the "localized" type. * * Supported values: An entry in the "scriptResources" dictionary that defines the base exported module of the * component. * * Example: `"myApplication.bundle"` */ entryModuleId: string; /** * The module referenced by the "entryModuleId" field may export an object with several fields. * * @remarks * This value optionally references the name of a field on the object exported by the module referenced by the * `entryModuleId` field. When this field has a value, the value of the referenced field on the object exported * by the module referenced by the `entryModuleId` field is returned when this manifest is loaded instead of * the base exported object. For example, if entryModuleId refers to a module with with a top-level export of * `{ foo: 'bar', baz: 123 }` and: * * - if this field is unset, the value returned by the module loader is `{ foo: 'bar', baz: 123 }` * * - if this field is set to `foo`, the value returned by the module loader is `bar` * * - if this field is set to `bar`, the value returned by the module loader is undefined (as `bar` is not a key in * the top-level export). * * Example: `mySpWebpart` */ exportName?: string; /** * This is a dictionary of named script resources. `path` and `localizedPath` modules may reference each * other and `manifest` modules are expected to be provided by the framework runtime. The resource named in the * `entryModuleId` must contain the component's exported object. * * @remarks * * Supported values: A dictionary of named script resources. * * Example: * * ``` * { * "myApplication.bundle": { * "type": "path", * "path": "master_2015-04-20/my-application.bundle_1928f8a0.js" * }, * "@microsoft/sp-client-base": { * "type": "component", * "id": "af59c2b3-2da7-41fd-8b72-3939817960af", * "version": "latest" * }, * "@microsoft/sp-client-preview": { * "type": "component", * "id": "4d5eb168-6729-49a8-aec7-0e397f486b6e", * "version": "latest" * }, * "jQuery": { * "type": "component", * "id": "00000000-0000-0000-0000-000000000000", * "version": "2.2.4", * "path": "https://code.jquery.com/jquery-2.2.4.min.js" * }, * "myApplication_strings": { * "type": "localizedPath", * "defaultPath": "master_2015-04-20/my-application_strings_default_af378e0d.js", * "paths": { * "en-us": "master_2015-04-20/my-application_strings_en-us_d38ff012.js", * "fr-fr": "master_2015-04-20/my-application_strings_fr-fr_138af7e4.js" * } * } * } * ``` */ scriptResources: { [name: string]: IModuleConfiguration; }; } /** * @beta */ export type IModuleConfiguration = IComponentModuleConfiguration | IPathModuleConfiguration | ILocalizedPathModuleConfiguration; /** * A path with the subresource integrity hash of the resource. * * @beta */ export interface IIntegrityPath { /** * The path to the resource. */ path: string; /** * The subresource integrity hash of the resource referenced in {@link IIntegrityPath.path}. */ integrity?: string; } /** * This is the base interface for a script module's definition. * * @beta */ export interface IModuleConfigurationBase { /** * The type of the script block. `"component"` modules come from a component, * `"path"` and `"localizedPath"` modules must be available on the paths provided in * the `"internalModuleBaseUrls"` field. * * @remarks * * Modules with the `"path"` type use the `IPathModuleConfiguration` interface. * * Modules with the `"component"` type use the `IComponentModuleConfiguration` interface. * Modules with the "localizedPath" type use the `ILocalizedPathModuleConfiguration` interface. * * Supported values: `"component"`, `"path"`, `"localizedPath"` * * Example: `"localized"` */ type: 'component' | 'path' | 'localizedPath'; /** * If set to `true`, this module should not be preloaded when loading the component. * * @remarks * The most common case for setting this property to "true" is when a module is defined in a manifest, * but is not required for the module referenced in "entryModuleId" to load. Modules may be defined that * are loaded asynchronously, and these modules do not need to be preloaded. This field implicitly defaults * to `false`. * * Usage: Instructs the module loader to not preload this module. */ shouldNotPreload?: boolean; } /** * This is the interface for a script module with the "component" type. Modules of this type will be provided via * manifests. In order for the dependency to be loaded, the manifest must be available on the site. * * @beta */ export interface IComponentModuleConfiguration extends IModuleConfigurationBase { type: 'component'; /** * The version of the framework-supplied component to be loaded. For framework runtime component such as * `@microsoft/sp-client-base`, it is recommended the version of the framework component the component was developed * against be specified. * * @remarks * * Supported values: string representing a {@link http://semver.org | semantic version}, or "latest". * * Example: `"2.2.4"` */ version: string; /** * The ID of the framework-supplied component to be loaded. * * @remarks * * Supported values: string representing a component's ID. * * Example: `"0d910c1c-13b9-4e1c-9aa4-b008c5e42d7d"` */ id: string; /** * A path to the framework-supplied component in case the framework fails to load the requested version. * * @remarks * This must be either a fully-qualified URL, or a path under the paths specified in the `internalModuleBaseUrls` * field. If this field is not specified and the version is not available in the framework runtime, the closest * matching version of the component will be provided instead. * * Supported values: The path to the component either as a fully-qualified URL or as a path under the * paths provided in the "internalModuleBaseUrls" field. * * Example: `"https://code.jquery.com/jquery-2.2.4.min.js"` */ failoverPath?: string | IIntegrityPath; /** * Used to specify an alternative version of the dependency to be used, under certain conditions. * @internal */ fallbackVersion?: IComponentFallbackVersion; } /** * @internal * Represents a fallback version of a component that can be used under certain conditions. * * @remarks * This field is used to specify an alternative version of the dependency to load, provided certain conditions are met. * The conditions are specified using the `condition` field, which allows an expression to be defined. This supports the following: * - AND * - OR * - NOT * - XOR * - Flight checks * - Killswitch checks * * This field should only be used if the component has a multi-version manifest. */ export interface IComponentFallbackVersion { /** * @internal * The version of the component to be used as a fallback. * * @remarks * This should be a string representing a semantic version. */ version: string; /** * @internal * The condition under which the fallback version should be used. * * @remarks * This condition is expressed as a logical operator or switch, which can include AND, OR, NOT, XOR, * Flight checks, and KillSwitch checks. The condition must evaluate to true for the fallback version to be used. */ condition: IOperatorOrSwitch; } /** * @internal * Represents the logical operators used in the flighted manifest configuration. */ export type IOperatorOrSwitch = { and: IOperatorOrSwitch[]; } | { or: IOperatorOrSwitch[]; } | { xor: [IOperatorOrSwitch, IOperatorOrSwitch]; } | { not: IOperatorOrSwitch; } | IFlightOrKillSwitch; /** * @internal * Represents a flighted component or a kill switch component. * This type is used to define components that can be toggled on or off * based on certain conditions in the configuration. */ export type IFlightOrKillSwitch = IFlightedComponent | IKillSwitchComponent; /** * @internal * Represents a Flight check definition. */ export interface IFlightedComponent { switchType: 'flight'; id: number; } /** * @internal * Represents a Kill Switch check definition. */ export interface IKillSwitchComponent { switchType: 'killswitch'; id: string; } /** * This is the interface for a script module with the "path" type. Modules of this type must be provided by the * component developer. * * @beta */ export interface IPathModuleConfiguration extends IModuleConfigurationBase { type: 'path'; /** * A path to this module's javascript resource either as a fully-qualified URL or as a path under the * paths provided in the `internalModuleBaseUrls` field. * * @remarks * * For example, if this field's value is `"master_2015-04-20/my-application.bundle_1928f8a0.js"` and * the `"internalModuleBaseUrls"` field's value is * `[ "https://contoso.akamaihd.net/files/", "https://contoso.msecnd.net/files/" ]`, the loader will * first attempt to load this script resource from the URL * `"https://contoso.akamaihd.net/files/master_2015-04-20/my-application.bundle_1928f8a0.js"`. * If loading from that URL fails, the loader will then attempt to load this script resource from * `"https://contoso.msecnd.net/files/master_2015-04-20/my-application.bundle_1928f8a0.js"`. * If that URL fails to load, the component will fail to load and an error will be returned. * * Supported values: The path to the module either as a fully-qualified URL or as a path under the * paths provided in the "internalModuleBaseUrls" field. * * Example: `"master_2015-04-20/my-application.bundle_1928f8a0.js"` */ path: string | IIntegrityPath; /** * If this property is specified, this module is considered non-AMD and * the module loader will not expect "define" or "require" to be called. * * @remarks * In order to load scripts that don't follow the AMD/module-pattern where "define" or "require" is * called and dependencies are explicitly listed and exports are explicitly returned, the module loader needs to * know which global variable must be examined. If this property is specified, this module is considered non-AMD and * the module loader will not expect "define" or "require" to be called. Instead, it will wait for the script to * finish loading and examine the global variable specified in this field. * * Supported values: Variable names that are expected to be populated after this module is loaded. For example, * if this module is describing jQuery, this value should probably be "$". If an empty string is specified, * the module loader will throw an exception and the component will fail to load. * * Example: `"$"` */ globalName?: string; /** * For non-AMD/module-pattern scripts that have dependencies (for example, jQuery plugins), the module * loader will ensure that those dependencies are already loaded. * * @remarks * Entries in the array specified in this field must refer to other non-AMD modules in this component. This field * is not required to have a value for non-AMD modules. If any values are specified that do not refer to other * modules in the same component manifest that this module is specified, the module loader will throw an exception * and the component will fail to load. * * Supported values: Names of other non-AMD-pattern modules in this loader configuration, as specified by the key * `IClientSideComponentLoaderConfiguration.scriptResources[]` * * Example: `["jquery"]` */ globalDependencies?: string[]; } /** * This is the interface for a script module with the "localizedPath" type. * * @remarks * Modules of this type must be provided by the component developer. These script resources are similar to those of * the "path" type, but they may be present at a number of different paths, to be selected by the user's locale. * Paths in this module type are loaded exactly the same way as "internal" modules are. * * @beta */ export interface ILocalizedPathModuleConfiguration extends IModuleConfigurationBase { type: 'localizedPath'; /** * A path to this module's default locale javascript resource either as a fully-qualified URL or as a * path under the paths provided in the "internalModuleBaseUrls" field. * * @remarks * If the user's locale does not resolve to one of the paths specified in the "paths" field, the path in this * field is used. Paths in this module type are treated exactly the same way paths in modules of the "internal" * type are treated. * * Supported values: The path to the default locale version of the module either as a fully-qualified URL or as a path * under the paths provided in the "internalModuleBaseUrls" field. * * Example: `"master_2015-04-20/my-application_strings_default_af378e0d.js"` */ defaultPath: string | IIntegrityPath; /** * This is a dictionary of locale keys (in the `"ll-cc"` format) to paths to this module's locale * javascript resource either as a fully-qualified URL or as a path under the paths provided in the * `"internalModuleBaseUrls"` field. * * @remarks * The loader will attempt to resolve the user's locale to one of the paths provided by this field, and will load * the script resource under that path. If the user's locale does not resolve to one of the paths specified in this * field, the path in `"defaultPath"` field is used. For example, if the user's locale is `"en-gb"`, and this field's * value contains the keys `[ "en-us", "en-gb", "fr-fr" ]`, the path specified by the `"en-gb"` key will be used. * If the user's locale is "en-gb", and this field's value contains the keys `[ "en-us", "fr-fr" ]`, the path * specified by the `"en-us"` key will be used. If the user's locale is `"en-gb"`, and this field's value contains * the keys `[ "es-es", "fr-fr" ]`, the path specified by the "defaultPath" field will be used. * Paths in this module type are treated exactly the same way paths in modules of the "internal" type are treated. * * Supported values: A dictionary of locale-to-path mappings. * * Example: * ``` * { * "en-us": "master_2015-04-20/my-application_strings_en-us_d38ff012.js", * "fr-fr": "master_2015-04-20/my-application_strings_fr-fr_138af7e4.js" * } * ``` */ paths?: { [locale: string]: string | IIntegrityPath; }; } //# sourceMappingURL=IClientSideComponentLoaderConfiguration.d.ts.map