@lwrjs/types 0.10.0-alpha.2 → 0.10.0-alpha.20
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/build/config.d.ts +39 -15
- package/build/index.d.ts +78 -58
- package/build/lwr-shim.d.ts +1 -1
- package/build/server.d.ts +9 -9
- package/build/serviceAPI/appMetadata/appMetadata.d.ts +1 -1
- package/build/serviceAPI/handleStaleModule/handleStaleModule.d.ts +2 -2
- package/build/serviceAPI/loaderPlugins/loaderPlugins.d.ts +9 -9
- package/build/serviceAPI/serviceAPI.d.ts +3 -3
- package/build/views.d.ts +14 -16
- package/package.json +3 -3
package/build/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetProvider, AssetTransformPlugin, BundleProvider, CacheResponse, LwrService, ModuleProvider, RenderOptions, ResourceProvider, RouteHandlerViewResponse, RuntimeEnvironment, ServerTypes, ServiceCtor, Specifier, ViewParams, ViewProvider, ViewRequest, ViewResponse, ViewTransformPlugin } from './index';
|
|
1
|
+
import type { AssetProvider, AssetTransformPlugin, BundleProvider, CacheResponse, LwrService, ModuleProvider, RenderOptions, ResourceProvider, RouteHandlerViewResponse, RuntimeEnvironment, ServerTypes, ServiceCtor, Specifier, UriTransformPlugin, ViewParams, ViewProvider, ViewRequest, ViewResponse, ViewTransformPlugin } from './index';
|
|
2
2
|
export interface View {
|
|
3
3
|
id: string;
|
|
4
4
|
rootComponent?: string;
|
|
@@ -8,7 +8,7 @@ export interface View {
|
|
|
8
8
|
}
|
|
9
9
|
export interface LwrBaseRoute extends View {
|
|
10
10
|
properties?: Record<string, any>;
|
|
11
|
-
routeHandler?:
|
|
11
|
+
routeHandler?: ServiceConfig;
|
|
12
12
|
cache?: CacheResponse;
|
|
13
13
|
subRoutes?: string;
|
|
14
14
|
}
|
|
@@ -18,12 +18,14 @@ export interface LwrRoute extends LwrBaseRoute {
|
|
|
18
18
|
}
|
|
19
19
|
export interface NormalizedLwrRoute extends LwrRoute {
|
|
20
20
|
bootstrap: NormalizedLwrAppBootstrapConfig;
|
|
21
|
+
routeHandler?: ServiceEntry;
|
|
21
22
|
}
|
|
22
23
|
export interface LwrErrorRoute extends LwrBaseRoute {
|
|
23
24
|
status: 404 | 500;
|
|
24
25
|
}
|
|
25
26
|
export interface NormalizedLwrErrorRoute extends LwrErrorRoute {
|
|
26
27
|
bootstrap: NormalizedLwrAppBootstrapConfig;
|
|
28
|
+
routeHandler?: ServiceEntry;
|
|
27
29
|
}
|
|
28
30
|
export interface NormalizedLwrAppBootstrapConfig {
|
|
29
31
|
autoBoot: boolean;
|
|
@@ -37,29 +39,32 @@ export interface NormalizedLwrAppBootstrapConfig {
|
|
|
37
39
|
module: string | undefined;
|
|
38
40
|
preloadModules: string[];
|
|
39
41
|
}
|
|
40
|
-
export
|
|
42
|
+
export type LwrAppBootstrapConfig = Partial<NormalizedLwrAppBootstrapConfig>;
|
|
41
43
|
export interface LwrLockerConfig {
|
|
42
44
|
enabled: boolean;
|
|
43
45
|
trustedComponents?: string[];
|
|
44
46
|
clientOnly?: boolean;
|
|
45
47
|
}
|
|
46
48
|
export interface RouteHandlersConfig {
|
|
47
|
-
[id: string]:
|
|
49
|
+
[id: string]: ServiceConfig;
|
|
50
|
+
}
|
|
51
|
+
export interface NormalizedRouteHandlersConfig {
|
|
52
|
+
[id: string]: ServiceEntry;
|
|
48
53
|
}
|
|
49
54
|
export interface LocalizedViewRequest extends ViewRequest {
|
|
50
55
|
locale?: string;
|
|
51
56
|
}
|
|
52
|
-
export
|
|
57
|
+
export type RouteHandlerFunction = (viewRequest: LocalizedViewRequest, handlerContext: HandlerContext, routeHandlerOptions?: any) => Promise<RouteHandlerViewResponse> | RouteHandlerViewResponse;
|
|
53
58
|
export interface ResourcePaths {
|
|
54
59
|
rootDir: string;
|
|
55
60
|
assets: AssetConfig[];
|
|
56
61
|
layoutsDir: string;
|
|
57
62
|
contentDir: string;
|
|
58
63
|
}
|
|
59
|
-
export
|
|
64
|
+
export type RouteHandlerView = Pick<View, 'contentTemplate' | 'layoutTemplate' | 'rootComponent'>;
|
|
60
65
|
export interface RouteHandlerViewApi {
|
|
61
66
|
hasViewResponse(view: RouteHandlerView, viewParams?: ViewParams, renderOptions?: RenderOptions): boolean;
|
|
62
|
-
getViewResponse(view: RouteHandlerView, viewParams?: ViewParams, renderOptions?: RenderOptions): Promise<ViewResponse
|
|
67
|
+
getViewResponse(view: RouteHandlerView, viewParams?: ViewParams, renderOptions?: RenderOptions): Promise<ViewResponse>;
|
|
63
68
|
}
|
|
64
69
|
export interface HandlerContext extends ResourcePaths {
|
|
65
70
|
route: LwrRoute | LwrErrorRoute;
|
|
@@ -100,6 +105,7 @@ export interface LwrGlobalConfig {
|
|
|
100
105
|
serverType?: ServerTypes;
|
|
101
106
|
staticSiteGenerator?: StaticSiteGenerator;
|
|
102
107
|
locker?: LwrLockerConfig;
|
|
108
|
+
uriTransformers?: ServiceConfig[];
|
|
103
109
|
}
|
|
104
110
|
export interface BuildOptions {
|
|
105
111
|
target?: string;
|
|
@@ -114,6 +120,7 @@ export interface BuildOptions {
|
|
|
114
120
|
export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig, 'lwc'>> {
|
|
115
121
|
routes: NormalizedLwrRoute[];
|
|
116
122
|
errorRoutes: NormalizedLwrErrorRoute[];
|
|
123
|
+
routeHandlers: NormalizedRouteHandlersConfig;
|
|
117
124
|
assets: AssetConfig[];
|
|
118
125
|
lwrVersion: string;
|
|
119
126
|
amdLoader: string;
|
|
@@ -126,6 +133,7 @@ export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig
|
|
|
126
133
|
resourceProviders: ServiceEntry[];
|
|
127
134
|
assetProviders: ServiceEntry[];
|
|
128
135
|
assetTransformers: ServiceEntry[];
|
|
136
|
+
uriTransformers: ServiceEntry[];
|
|
129
137
|
lwc: NormalizedLwcConfig;
|
|
130
138
|
}
|
|
131
139
|
export interface StaticSiteGenerator {
|
|
@@ -153,43 +161,51 @@ export interface Services {
|
|
|
153
161
|
resourceProviders: ResolvedServiceEntry<ResourceProvider>[];
|
|
154
162
|
assetProviders: ResolvedServiceEntry<AssetProvider>[];
|
|
155
163
|
assetTransformers: ResolvedServiceEntry<AssetTransformPlugin>[];
|
|
164
|
+
uriTransformers: ResolvedServiceEntry<UriTransformPlugin>[];
|
|
156
165
|
}
|
|
157
166
|
export interface RouteHandlers {
|
|
158
|
-
[id: string]: RouteHandlerFunction;
|
|
167
|
+
[id: string]: [RouteHandlerFunction, any?];
|
|
159
168
|
}
|
|
160
169
|
interface AssetConfigCommon {
|
|
161
|
-
urlPath
|
|
170
|
+
urlPath?: string;
|
|
162
171
|
alias?: string;
|
|
163
172
|
}
|
|
164
173
|
export interface AssetDirConfig extends AssetConfigCommon {
|
|
165
174
|
dir: string;
|
|
175
|
+
root?: boolean;
|
|
176
|
+
}
|
|
177
|
+
export interface AssetRootDirConfig extends AssetDirConfig {
|
|
178
|
+
dir: string;
|
|
179
|
+
root: true;
|
|
166
180
|
}
|
|
167
181
|
export interface AssetFileConfig extends AssetConfigCommon {
|
|
168
182
|
file: string;
|
|
169
183
|
}
|
|
170
|
-
export
|
|
184
|
+
export type AssetConfig = AssetRootDirConfig | AssetDirConfig | AssetFileConfig;
|
|
171
185
|
export interface LwcConfig {
|
|
172
186
|
modules: ResolverModuleRecord[];
|
|
173
187
|
interchangeable?: string[];
|
|
174
188
|
interchangeableModules?: InterchangeableModuleRecord[];
|
|
175
189
|
}
|
|
176
|
-
export
|
|
190
|
+
export type InterchangeableModuleMap = Map<Specifier, Map<Environment, Specifier>>;
|
|
177
191
|
export interface NormalizedLwcConfig extends Omit<LwcConfig, 'interchangeableModules'> {
|
|
178
192
|
interchangeableModulesMap?: InterchangeableModuleMap;
|
|
179
193
|
}
|
|
180
|
-
export
|
|
181
|
-
export
|
|
182
|
-
export
|
|
194
|
+
export type ServiceEntry = [string, any?];
|
|
195
|
+
export type ServiceConfig = string | ServiceEntry;
|
|
196
|
+
export type ResolvedServiceEntry<T extends LwrService> = [ServiceCtor<T>, any?];
|
|
183
197
|
export interface BundleConfig {
|
|
184
198
|
exclude?: string[];
|
|
185
199
|
UNSAFE_lwrDefaultExclude?: string[];
|
|
186
200
|
external?: Record<string, string>;
|
|
187
201
|
alias?: Record<string, string>;
|
|
202
|
+
groups?: BundleGroups;
|
|
188
203
|
}
|
|
189
204
|
export interface BundleConfigOverrides extends BundleConfig {
|
|
190
205
|
appendExcludes?: boolean;
|
|
191
206
|
}
|
|
192
|
-
export
|
|
207
|
+
export type BundleGroups = Record<string, string[]>;
|
|
208
|
+
export type Environment = string;
|
|
193
209
|
export interface EnvironmentConfig {
|
|
194
210
|
default?: Environment;
|
|
195
211
|
supported?: Environment[];
|
|
@@ -233,6 +249,14 @@ export interface HooksPlugin {
|
|
|
233
249
|
*
|
|
234
250
|
*/
|
|
235
251
|
initConfigs?: (lwrConfig: NormalizedLwrGlobalConfig, dataConfig: GlobalData, runtimeConfig: RuntimeEnvironment) => Promise<void> | void;
|
|
252
|
+
/**
|
|
253
|
+
* Setup instrumentation utilities
|
|
254
|
+
*
|
|
255
|
+
* @remarks
|
|
256
|
+
* - When running LWR server, these hooks are invoked after `initConfigs` hooks and before `onStart` hooks
|
|
257
|
+
* - When running LWR handler, these hooks are invoked before config normalization and `onStart` hooks
|
|
258
|
+
*/
|
|
259
|
+
initInstrumentation?: () => void;
|
|
236
260
|
/**
|
|
237
261
|
* Load routes on application start up.
|
|
238
262
|
*
|
package/build/index.d.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
/// <reference types="node" />
|
|
5
5
|
import type { WatchOptions } from 'chokidar';
|
|
6
|
-
import { EventEmitter } from 'events';
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import { Readable } from 'stream';
|
|
9
|
-
import { BundleConfig, EnvironmentConfig, HooksPlugin, LwrLockerConfig, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, ResolverModuleRecord, BundleConfigOverrides, RouteHandlers, AssetConfig } from './config.js';
|
|
10
|
-
import { AssetReference, CompiledView, PublicViewRegistry, ViewProvider, ViewRegistry, ViewTransformPlugin } from './views.js';
|
|
6
|
+
import type { EventEmitter } from 'events';
|
|
7
|
+
import type fs from 'fs';
|
|
8
|
+
import type { Readable } from 'stream';
|
|
9
|
+
import type { BundleConfig, EnvironmentConfig, HooksPlugin, LwrLockerConfig, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, ResolverModuleRecord, BundleConfigOverrides, RouteHandlers, AssetConfig } from './config.js';
|
|
10
|
+
import type { AssetReference, CompiledView, PublicViewRegistry, ViewProvider, ViewRegistry, ViewTransformPlugin } from './views.js';
|
|
11
11
|
export * from './lwr-shim.js';
|
|
12
12
|
export * from './config.js';
|
|
13
13
|
export * from './server.js';
|
|
@@ -16,16 +16,16 @@ export * from './serviceAPI/serviceAPI.js';
|
|
|
16
16
|
export * from './serviceAPI/loaderPlugins/loaderPlugins.js';
|
|
17
17
|
export * from './serviceAPI/handleStaleModule/handleStaleModule.js';
|
|
18
18
|
export * from './serviceAPI/appMetadata/appMetadata.js';
|
|
19
|
-
export
|
|
19
|
+
export type Json = undefined | null | boolean | number | string | Json[] | {
|
|
20
20
|
[prop: string]: Json;
|
|
21
21
|
};
|
|
22
|
-
export
|
|
23
|
-
export
|
|
22
|
+
export type Dict<T> = Record<string, T>;
|
|
23
|
+
export type JsonCompatible<T> = {
|
|
24
24
|
[P in keyof T]: T[P] extends Json ? T[P] : Pick<T, P> extends Required<Pick<T, P>> ? never : JsonCompatible<T[P]>;
|
|
25
25
|
};
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
26
|
+
export type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
27
|
+
export type Specifier = string;
|
|
28
|
+
export type Version = string;
|
|
29
29
|
export interface AbstractModuleId {
|
|
30
30
|
specifier: string;
|
|
31
31
|
namespace?: string;
|
|
@@ -68,7 +68,7 @@ export interface ImportMetadataImports {
|
|
|
68
68
|
export interface ImportMetadataIndex {
|
|
69
69
|
[specifier: string]: string;
|
|
70
70
|
}
|
|
71
|
-
export
|
|
71
|
+
export type ModuleEntry = FsModuleEntry | VirtualModuleEntry;
|
|
72
72
|
interface BaseModuleEntry {
|
|
73
73
|
id: string;
|
|
74
74
|
entry: string;
|
|
@@ -111,6 +111,7 @@ export interface DynamicImportReference extends BaseDynamicModuleReference {
|
|
|
111
111
|
export interface ModuleRecord {
|
|
112
112
|
imports?: ImportModuleReference[];
|
|
113
113
|
dynamicImports?: DynamicImportReference[];
|
|
114
|
+
importMeta?: ImportMeta[];
|
|
114
115
|
}
|
|
115
116
|
export interface ChildHashObject {
|
|
116
117
|
[specifier: string]: string;
|
|
@@ -147,8 +148,8 @@ export interface CodeSource {
|
|
|
147
148
|
export interface SignedSource extends CodeSource {
|
|
148
149
|
signedCode?: string;
|
|
149
150
|
}
|
|
150
|
-
export
|
|
151
|
-
export
|
|
151
|
+
export type CompatMode = '0' | '1';
|
|
152
|
+
export type ModuleFormat = 'esm' | 'amd';
|
|
152
153
|
export interface ServerModeConfig {
|
|
153
154
|
format: ModuleFormat;
|
|
154
155
|
bundle: boolean;
|
|
@@ -165,10 +166,11 @@ export interface ServerModeConfig {
|
|
|
165
166
|
featureFlags: FeatureFlags;
|
|
166
167
|
}
|
|
167
168
|
export interface FeatureFlags extends Record<string, boolean | undefined> {
|
|
169
|
+
ASSETS_ON_LAMBDA?: boolean;
|
|
168
170
|
LEGACY_LOADER?: boolean;
|
|
169
|
-
SSR_STATIC_BUNDLES?: boolean;
|
|
170
171
|
SSR_SANDBOX_WORKER?: boolean;
|
|
171
|
-
|
|
172
|
+
SSR_STATIC_BUNDLES?: boolean;
|
|
173
|
+
EXPERIMENTAL_UNVERSIONED_ALIASES?: boolean;
|
|
172
174
|
}
|
|
173
175
|
export interface RuntimeEnvironment extends ServerModeConfig {
|
|
174
176
|
apiVersion: string;
|
|
@@ -180,7 +182,7 @@ export interface RuntimeEnvironment extends ServerModeConfig {
|
|
|
180
182
|
export interface SourceMapRuntimeEnvironment extends RuntimeEnvironment {
|
|
181
183
|
sourceMapUrl?: string;
|
|
182
184
|
}
|
|
183
|
-
export
|
|
185
|
+
export type RuntimeParams = Record<string, string | number | boolean | null | undefined | Record<string, string>>;
|
|
184
186
|
export interface ModuleIdentity {
|
|
185
187
|
signature: string;
|
|
186
188
|
moduleId: AbstractModuleId;
|
|
@@ -236,14 +238,14 @@ export interface LwrAppEmitter {
|
|
|
236
238
|
notifyViewSourceChanged(payload: CompiledView): void;
|
|
237
239
|
notifyAssetSourceChanged(payload: AssetSource): void;
|
|
238
240
|
}
|
|
239
|
-
export
|
|
241
|
+
export type EVENT_MODULE_DEFINITION_CHANGED = 'module_definition_changed';
|
|
240
242
|
export interface ModuleDefinitionChangedEvent {
|
|
241
243
|
eventType: EVENT_MODULE_DEFINITION_CHANGED;
|
|
242
244
|
payload: LinkedModuleDefinition;
|
|
243
245
|
}
|
|
244
|
-
export
|
|
245
|
-
export
|
|
246
|
-
export
|
|
246
|
+
export type EVENT_MODULE_SOURCE_CHANGED = 'module_source_changed';
|
|
247
|
+
export type EVENT_ASSET_SOURCE_CHANGED = 'asset_source_changed';
|
|
248
|
+
export type EVENT_VIEW_SOURCE_CHANGED = 'view_source_changed';
|
|
247
249
|
export interface ModuleSourceChangedEvent {
|
|
248
250
|
eventType: EVENT_MODULE_SOURCE_CHANGED;
|
|
249
251
|
payload: ModuleCompiled;
|
|
@@ -261,7 +263,7 @@ export interface ModuleProvider {
|
|
|
261
263
|
getModule<T extends AbstractModuleId>(moduleId: T, runtimeParams?: RuntimeParams): Promise<ModuleCompiled | undefined>;
|
|
262
264
|
getModuleEntry<T extends AbstractModuleId>(moduleId: T, runtimeParams?: RuntimeParams): Promise<ModuleEntry | undefined>;
|
|
263
265
|
}
|
|
264
|
-
export
|
|
266
|
+
export type LwrService = ModuleProvider | ResourceProvider | ViewProvider | AssetProvider | HooksPlugin | AssetTransformPlugin | ViewTransformPlugin;
|
|
265
267
|
export interface ServiceCtor<T extends LwrService, R extends Record<string, Json> = {}> {
|
|
266
268
|
new (providerConfig: R, serviceProviderConfig?: any, ...args: any[]): T;
|
|
267
269
|
}
|
|
@@ -275,18 +277,19 @@ export interface ModuleRegistry {
|
|
|
275
277
|
resolveModuleUriSync<R extends RuntimeEnvironment, S extends string | undefined>(moduleId: Required<Pick<ModuleId, 'specifier' | 'version'>>, signature: S, runtimeEnvironment: R, runtimeParams?: RuntimeParams): string;
|
|
276
278
|
getPublicApi(): PublicModuleRegistry;
|
|
277
279
|
}
|
|
278
|
-
export
|
|
280
|
+
export type PublicModuleRegistry = Pick<ModuleRegistry, 'getModule' | 'getModuleEntry' | 'getLinkedModule' | 'resolveModuleUri'>;
|
|
279
281
|
export interface BundleProvider {
|
|
280
282
|
name: string;
|
|
281
283
|
bundle<T extends AbstractModuleId, R extends RuntimeEnvironment>(moduleId: T, runtimeEnvironment: R, runtimeParams: RuntimeParams, configOverrides?: BundleConfig): Promise<BundleDefinition | undefined>;
|
|
282
284
|
}
|
|
283
285
|
export interface ModuleBundler {
|
|
284
286
|
addBundleProviders(providers: BundleProvider[]): void;
|
|
287
|
+
addBundleTransformers(transformers: UriTransformPlugin[]): void;
|
|
285
288
|
getModuleBundle<T extends AbstractModuleId, R extends RuntimeEnvironment>(moduleId: T, runtimeEnvironment: R, runtimeParams?: RuntimeParams, bundleConfigOverrides?: BundleConfigOverrides): Promise<BundleDefinition>;
|
|
286
289
|
resolveModuleUri(moduleId: Required<Pick<ModuleId, 'specifier' | 'version'>>, runtimeEnvironment: RuntimeEnvironment, runtimeParams?: RuntimeParams, signature?: string): Promise<string>;
|
|
287
290
|
getPublicApi(): PublicModuleBundler;
|
|
288
291
|
}
|
|
289
|
-
export
|
|
292
|
+
export type PublicModuleBundler = Pick<ModuleBundler, 'getModuleBundle' | 'resolveModuleUri'>;
|
|
290
293
|
export interface BundleRecord {
|
|
291
294
|
imports?: BaseModuleReference[];
|
|
292
295
|
dynamicImports?: BaseDynamicModuleReference[];
|
|
@@ -337,13 +340,14 @@ export interface AssetIdentifier {
|
|
|
337
340
|
type?: AssetType;
|
|
338
341
|
importer?: string;
|
|
339
342
|
}
|
|
340
|
-
export interface
|
|
343
|
+
export interface UriDefinition {
|
|
341
344
|
uri: string;
|
|
342
345
|
immutable: boolean;
|
|
346
|
+
artifactType: ArtifactType;
|
|
343
347
|
entry: string;
|
|
344
348
|
external?: boolean;
|
|
345
349
|
}
|
|
346
|
-
export
|
|
350
|
+
export type ResourceType = 'application/javascript' | 'application/json' | 'text/css' | 'lwr-importmap' | 'module' | string;
|
|
347
351
|
export interface ResourceDefinition {
|
|
348
352
|
specifier?: string;
|
|
349
353
|
type: ResourceType;
|
|
@@ -370,13 +374,13 @@ export interface AssetSource {
|
|
|
370
374
|
type?: AssetType;
|
|
371
375
|
noTransform?: boolean;
|
|
372
376
|
}
|
|
373
|
-
export
|
|
377
|
+
export type AssetType = 'asset' | 'content-asset' | 'external' | 'unknown';
|
|
374
378
|
export interface AssetDefinition extends AssetSource {
|
|
375
379
|
uri: string;
|
|
376
380
|
type: AssetType;
|
|
377
381
|
stream: (encoding?: BufferEncoding) => Readable;
|
|
378
382
|
}
|
|
379
|
-
export
|
|
383
|
+
export type ResourceJson = Pick<ResourceDefinition, 'type' | 'src'>;
|
|
380
384
|
export interface ResourceProvider {
|
|
381
385
|
name: string;
|
|
382
386
|
getResource<R extends ResourceIdentifier, T extends BootstrapRuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T, runtimeParams?: RuntimeParams): Promise<ResourceDefinition | undefined>;
|
|
@@ -385,27 +389,25 @@ export interface AssetProvider {
|
|
|
385
389
|
name: string;
|
|
386
390
|
getAsset(assetIdentifier: AssetIdentifier): Promise<AssetSource | undefined>;
|
|
387
391
|
}
|
|
388
|
-
export
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
};
|
|
394
|
-
declare type AssetPluginExtractMetaHook = (code: string | Buffer, assetSource: AssetSource, context?: TransformPluginContext) => Promise<AssetPluginExtractMetaHookReturn>;
|
|
395
|
-
declare type AssetPluginExtractMetaHookReturn = null | undefined | false | {
|
|
392
|
+
export type ArtifactType = 'asset' | 'bundle' | 'resource';
|
|
393
|
+
export type ArtifactDefinition = AssetDefinition | BundleDefinition | ResourceDefinition;
|
|
394
|
+
export type AssetTransformSourceHook = (assetSource: AssetSource, runtimeEnvironment: RuntimeEnvironment) => Promise<AssetTransformSourceHookReturn>;
|
|
395
|
+
export type AssetTransformSourceHookReturn = undefined | {
|
|
396
|
+
source: string | Buffer;
|
|
396
397
|
metadata?: AssetMetadata;
|
|
397
|
-
context?: TransformPluginContext;
|
|
398
|
-
};
|
|
399
|
-
declare type AssetPluginOptimizeHook = (code: string | Buffer, assetSource: AssetSource, context?: TransformPluginContext) => Promise<AssetPluginOptimizeHookReturn>;
|
|
400
|
-
declare type AssetPluginOptimizeHookReturn = null | undefined | false | string | Buffer | {
|
|
401
|
-
code: string | Buffer;
|
|
402
|
-
map?: any;
|
|
403
|
-
context?: TransformPluginContext;
|
|
404
398
|
};
|
|
399
|
+
export type UriTransformHook = (uri: UriDefinition, artifactDef?: ArtifactDefinition, runtimeEnvironment?: RuntimeEnvironment) => Promise<UriTransformHookReturn>;
|
|
400
|
+
export type UriTransformHookReturn = undefined | UriDefinition;
|
|
401
|
+
export interface UriTransformHooks {
|
|
402
|
+
transformUri: UriTransformHook;
|
|
403
|
+
}
|
|
404
|
+
export interface UriTransformPlugin extends UriTransformHooks {
|
|
405
|
+
name: string;
|
|
406
|
+
}
|
|
407
|
+
export type AssetUriTransformHook = (uri: UriDefinition, assetDef: AssetDefinition, runtimeEnvironment: RuntimeEnvironment) => Promise<UriTransformHookReturn>;
|
|
405
408
|
export interface AssetTransformHooks {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
optimize: AssetPluginOptimizeHook;
|
|
409
|
+
transformUri: AssetUriTransformHook;
|
|
410
|
+
transformSource: AssetTransformSourceHook;
|
|
409
411
|
}
|
|
410
412
|
export interface AssetTransformPlugin extends Partial<AssetTransformHooks> {
|
|
411
413
|
name: string;
|
|
@@ -413,30 +415,32 @@ export interface AssetTransformPlugin extends Partial<AssetTransformHooks> {
|
|
|
413
415
|
export interface ResourceRegistry {
|
|
414
416
|
name: string;
|
|
415
417
|
addResourceProviders(provider: ResourceProvider[]): void;
|
|
418
|
+
addResourceTransformers(provider: UriTransformPlugin[]): void;
|
|
416
419
|
getResource<R extends ResourceIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T, runtimeParams?: RuntimeParams): Promise<ResourceDefinition | undefined>;
|
|
417
|
-
resolveResourceUri<R extends ResourceIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T): string
|
|
420
|
+
resolveResourceUri<R extends ResourceIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T): Promise<string>;
|
|
418
421
|
getPublicApi(): PublicResourceRegistry;
|
|
419
422
|
}
|
|
420
|
-
export
|
|
423
|
+
export type PublicResourceRegistry = Pick<ResourceRegistry, 'getResource' | 'resolveResourceUri'>;
|
|
421
424
|
export interface AssetRegistry {
|
|
422
425
|
name: string;
|
|
423
426
|
addAssetProviders(provider: AssetProvider[]): void;
|
|
424
|
-
addAssetTransformers(transformers: AssetTransformPlugin[]): void;
|
|
427
|
+
addAssetTransformers(transformers: (AssetTransformPlugin | UriTransformPlugin)[]): void;
|
|
425
428
|
getAsset<R extends AssetIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T, includeMetadata?: boolean): Promise<AssetDefinition>;
|
|
426
|
-
resolveAssetUri<R extends AssetIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T): Promise<
|
|
429
|
+
resolveAssetUri<R extends AssetIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T): Promise<UriDefinition>;
|
|
427
430
|
getPublicApi(): PublicAssetRegistry;
|
|
428
431
|
}
|
|
429
|
-
export
|
|
432
|
+
export type PublicAssetRegistry = Pick<AssetRegistry, 'getAsset' | 'resolveAssetUri'>;
|
|
430
433
|
export interface LwcCompilerConfig {
|
|
431
434
|
name: string;
|
|
432
435
|
namespace?: string;
|
|
433
436
|
filename: string;
|
|
434
437
|
scopedStyles?: boolean;
|
|
435
438
|
}
|
|
436
|
-
export
|
|
439
|
+
export type SourceMap = string | null | undefined;
|
|
437
440
|
export interface CompiledMetadata {
|
|
438
441
|
imports?: Import[];
|
|
439
442
|
dynamicImports?: DynamicImport[];
|
|
443
|
+
importMeta?: ImportMeta[];
|
|
440
444
|
}
|
|
441
445
|
export interface SourceLocation {
|
|
442
446
|
startColumn: number;
|
|
@@ -446,13 +450,17 @@ export interface Import {
|
|
|
446
450
|
moduleSpecifier: string;
|
|
447
451
|
location: SourceLocation;
|
|
448
452
|
}
|
|
449
|
-
export
|
|
453
|
+
export type ModuleNameType = 'string' | 'unresolved';
|
|
450
454
|
export interface DynamicImport {
|
|
451
455
|
moduleSpecifier: string;
|
|
452
456
|
location: SourceLocation;
|
|
453
457
|
importLocation: SourceLocation;
|
|
454
458
|
moduleNameType: ModuleNameType;
|
|
455
459
|
}
|
|
460
|
+
export interface ImportMeta {
|
|
461
|
+
statement: string;
|
|
462
|
+
location: SourceLocation;
|
|
463
|
+
}
|
|
456
464
|
export interface CompilerResult {
|
|
457
465
|
code: string;
|
|
458
466
|
map?: SourceMap;
|
|
@@ -461,6 +469,15 @@ export interface CompilerResult {
|
|
|
461
469
|
export interface BundleFiles {
|
|
462
470
|
[filename: string]: string;
|
|
463
471
|
}
|
|
472
|
+
interface ImportMetaEnv {
|
|
473
|
+
[key: string]: any;
|
|
474
|
+
SSR: boolean;
|
|
475
|
+
}
|
|
476
|
+
declare global {
|
|
477
|
+
interface ImportMeta {
|
|
478
|
+
readonly env: ImportMetaEnv;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
464
481
|
export interface ClientBootstrapConfig {
|
|
465
482
|
appId?: string;
|
|
466
483
|
bootstrapModule: string;
|
|
@@ -541,7 +558,7 @@ export interface GraphDepthOptions {
|
|
|
541
558
|
dynamic: number;
|
|
542
559
|
includeId?: IncludeIdHook;
|
|
543
560
|
}
|
|
544
|
-
export
|
|
561
|
+
export type GraphDepth = 'all' | 'direct' | 'none';
|
|
545
562
|
export interface FlatGraphNode {
|
|
546
563
|
specifier: Specifier;
|
|
547
564
|
static: Specifier[];
|
|
@@ -551,14 +568,14 @@ export interface GraphNode {
|
|
|
551
568
|
static: Specifier[];
|
|
552
569
|
dynamic: Specifier[];
|
|
553
570
|
}
|
|
554
|
-
export
|
|
555
|
-
export
|
|
571
|
+
export type URIMap = Record<string, string>;
|
|
572
|
+
export type LinkedModuleDefinitionMap = Record<string, LinkedModuleDefinition | BundleDefinition>;
|
|
556
573
|
export interface FlattenedModuleGraphs {
|
|
557
574
|
graphs: FlatGraphNode[];
|
|
558
575
|
uriMap: URIMap;
|
|
559
576
|
linkedDefinitions: LinkedModuleDefinitionMap;
|
|
560
577
|
}
|
|
561
|
-
export
|
|
578
|
+
export type ImportMapImports = {
|
|
562
579
|
[key: string]: string;
|
|
563
580
|
};
|
|
564
581
|
export interface LwrBuilderOverwriteOptions {
|
|
@@ -617,7 +634,7 @@ export interface SiteBundles {
|
|
|
617
634
|
bundles: Record<string, SiteBundle>;
|
|
618
635
|
}
|
|
619
636
|
export interface SiteResources {
|
|
620
|
-
resources: Record<string,
|
|
637
|
+
resources: Record<string, SiteResource>;
|
|
621
638
|
}
|
|
622
639
|
export interface SiteAssets {
|
|
623
640
|
assets: Record<string, SiteArtifact>;
|
|
@@ -626,6 +643,9 @@ export interface SiteArtifact {
|
|
|
626
643
|
path: string;
|
|
627
644
|
mimeType?: string;
|
|
628
645
|
}
|
|
646
|
+
export interface SiteResource extends SiteArtifact {
|
|
647
|
+
inline?: boolean;
|
|
648
|
+
}
|
|
629
649
|
export interface SiteBundle extends SiteArtifact {
|
|
630
650
|
version?: Version;
|
|
631
651
|
imports: string[];
|
package/build/lwr-shim.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetProvider, HooksPlugin, ModuleProvider, ProviderContext, ResourceProvider, ViewProvider, ViewTransformPlugin } from './index';
|
|
1
|
+
import type { AssetProvider, HooksPlugin, ModuleProvider, ProviderContext, ResourceProvider, ViewProvider, ViewTransformPlugin } from './index';
|
|
2
2
|
interface LwrShim {
|
|
3
3
|
LWC_VERSION: string;
|
|
4
4
|
LEGACY_LOADER: boolean;
|
package/build/server.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Application as ExpressApp } from 'express';
|
|
4
|
-
import Koa,
|
|
5
|
-
import http from 'http';
|
|
6
|
-
import { Readable } from 'stream';
|
|
3
|
+
import type { Application as ExpressApp } from 'express';
|
|
4
|
+
import type { default as Koa, Context } from 'koa';
|
|
5
|
+
import type http from 'http';
|
|
6
|
+
import type { Readable } from 'stream';
|
|
7
7
|
import type { NormalizedLwrGlobalConfig, RuntimeContext, RuntimeEnvironment } from './index.js';
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export type ServerTypes = 'koa' | 'express' | 'fs';
|
|
9
|
+
export type ServerTypeImpl<T extends ServerTypes> = T extends 'koa' ? Koa : T extends 'express' ? ExpressApp : T extends 'fs' ? LwrDispatcher : never;
|
|
10
10
|
export interface FsContext extends Context {
|
|
11
11
|
fs?: {
|
|
12
12
|
headers?: http.IncomingHttpHeaders;
|
|
@@ -35,8 +35,8 @@ export interface InternalAppServer<T extends ServerTypes> {
|
|
|
35
35
|
useCompression(): void;
|
|
36
36
|
getRegexWildcard(): string;
|
|
37
37
|
}
|
|
38
|
-
export
|
|
39
|
-
export
|
|
38
|
+
export type PublicAppServer<T extends ServerTypes> = Pick<InternalAppServer<T>, 'use' | 'all' | 'get' | 'post' | 'getRegexWildcard'>;
|
|
39
|
+
export type InternalAppServerOptions = {
|
|
40
40
|
app?: ServerTypeImpl<ServerTypes>;
|
|
41
41
|
basePath?: string;
|
|
42
42
|
};
|
|
@@ -46,7 +46,7 @@ export interface InternalAppServerConstructable {
|
|
|
46
46
|
export interface MiddlewareFunction {
|
|
47
47
|
(req: MiddlewareRequest, res: MiddlewareResponse, next: Function): void;
|
|
48
48
|
}
|
|
49
|
-
export
|
|
49
|
+
export type Headers = http.IncomingHttpHeaders;
|
|
50
50
|
export interface MiddlewareRequest {
|
|
51
51
|
params: any;
|
|
52
52
|
originalUrl: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export interface RegisterHandleStaleModuleHook {
|
|
2
2
|
(hook: HandleStaleModuleHook): void;
|
|
3
3
|
}
|
|
4
|
-
export
|
|
4
|
+
export type HandleStaleModuleHookArgs = {
|
|
5
5
|
name: string;
|
|
6
6
|
oldUrl: string;
|
|
7
7
|
newUrl: string;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type DEPRECIATEDHandleStaleModuleHookArgs = {
|
|
10
10
|
name: string;
|
|
11
11
|
oldHash: string;
|
|
12
12
|
newHash: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ImportMetadata } from '../..';
|
|
2
|
-
|
|
1
|
+
import type { ImportMetadata } from '../..';
|
|
2
|
+
type ResolveParams = {
|
|
3
3
|
parentUrl: string;
|
|
4
4
|
};
|
|
5
5
|
export interface RegisterLoaderHooks {
|
|
6
6
|
(hook: LoaderHooks): void;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
8
|
+
export type LoaderHooks = {
|
|
9
9
|
resolveModule?: ResolveModuleHook;
|
|
10
10
|
loadModule?: LoadModuleHook;
|
|
11
11
|
loadMapping?: LoadMappingHook;
|
|
@@ -19,19 +19,19 @@ export interface LoadModuleHook {
|
|
|
19
19
|
export interface LoadMappingHook {
|
|
20
20
|
(specifier: string, params: MappingResolveParams): Promise<MappingResponse> | MappingResponse;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export type MappingResolveParams = {
|
|
23
23
|
knownModules: string[];
|
|
24
24
|
};
|
|
25
|
-
export
|
|
26
|
-
export
|
|
25
|
+
export type MappingResponse = ImportMetadata | null;
|
|
26
|
+
export type URLResponse = {
|
|
27
27
|
url: string;
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export type CustomResponse = {
|
|
30
30
|
data: string;
|
|
31
31
|
status: number;
|
|
32
32
|
statusText?: string;
|
|
33
33
|
};
|
|
34
|
-
export
|
|
35
|
-
export
|
|
34
|
+
export type LoadHookResponse = CustomResponse | globalThis.Response | null;
|
|
35
|
+
export type ResolveHookResponse = URLResponse | string | null;
|
|
36
36
|
export {};
|
|
37
37
|
//# sourceMappingURL=loaderPlugins.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RegisterLoaderHooks } from './loaderPlugins/loaderPlugins';
|
|
2
|
-
import { RegisterHandleStaleModuleHook } from './handleStaleModule/handleStaleModule';
|
|
3
|
-
import { AppMetadata } from './appMetadata/appMetadata';
|
|
1
|
+
import type { RegisterLoaderHooks } from './loaderPlugins/loaderPlugins';
|
|
2
|
+
import type { RegisterHandleStaleModuleHook } from './handleStaleModule/handleStaleModule';
|
|
3
|
+
import type { AppMetadata } from './appMetadata/appMetadata';
|
|
4
4
|
export interface ServiceAPI {
|
|
5
5
|
addLoaderPlugin: NoOp | RegisterLoaderHooks;
|
|
6
6
|
handleStaleModule: RegisterHandleStaleModuleHook;
|
package/build/views.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { LwrErrorRoute, LwrRoute, RouteHandlerFunction, RouteHandlerView, View } from './config.js';
|
|
3
|
-
import { AssetSource,
|
|
4
|
-
export
|
|
2
|
+
import type { LwrErrorRoute, LwrRoute, RouteHandlerFunction, RouteHandlerView, View } from './config.js';
|
|
3
|
+
import type { AssetSource, UriDefinition, Endpoints, FlattenedModuleGraphs, ImportMetadata, Json, LwrStringBuilder, ResourceDefinition, RuntimeEnvironment, RuntimeParams, Specifier } from './index.js';
|
|
4
|
+
export type ViewIdentity = Pick<View, 'rootComponent' | 'contentTemplate'>;
|
|
5
5
|
export interface ViewSource {
|
|
6
6
|
name: string;
|
|
7
7
|
slug: string;
|
|
@@ -18,7 +18,7 @@ export interface CompiledView extends ViewSource {
|
|
|
18
18
|
};
|
|
19
19
|
render: (context?: any) => Promise<RenderingResult>;
|
|
20
20
|
}
|
|
21
|
-
export
|
|
21
|
+
export type NormalizedRenderingResult = Required<RenderingResult>;
|
|
22
22
|
export interface RenderingResult {
|
|
23
23
|
renderedView: string;
|
|
24
24
|
metadata?: RenderedViewMetadata;
|
|
@@ -48,7 +48,7 @@ export interface RenderedViewMetadata {
|
|
|
48
48
|
export interface RenderedAssetReference {
|
|
49
49
|
url: string;
|
|
50
50
|
tagName?: string;
|
|
51
|
-
override?:
|
|
51
|
+
override?: UriDefinition;
|
|
52
52
|
}
|
|
53
53
|
export interface AssetReference extends RenderedAssetReference {
|
|
54
54
|
importer?: string;
|
|
@@ -107,7 +107,7 @@ export interface ViewResponse {
|
|
|
107
107
|
viewDefinition?: LinkedViewDefinition;
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
-
export
|
|
110
|
+
export type RouteHandlerViewResponse = ViewDefinitionResponse | ViewResponse;
|
|
111
111
|
export interface ViewDefinitionResponse {
|
|
112
112
|
status?: number;
|
|
113
113
|
view: RouteHandlerView;
|
|
@@ -122,7 +122,7 @@ export interface ViewProvider {
|
|
|
122
122
|
initialize(): Promise<void>;
|
|
123
123
|
getView(viewId: ViewIdentity): Promise<CompiledView | undefined>;
|
|
124
124
|
}
|
|
125
|
-
export interface
|
|
125
|
+
export interface ViewTransformPluginContext {
|
|
126
126
|
view: View;
|
|
127
127
|
viewParams: ViewParams;
|
|
128
128
|
runtimeEnvironment: RuntimeEnvironment;
|
|
@@ -133,17 +133,15 @@ export interface ViewTranformPluginContext {
|
|
|
133
133
|
};
|
|
134
134
|
importer?: string;
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
type ViewPluginLinkHook = (builder: LwrStringBuilder, viewContext: ViewTransformPluginContext, viewMetadata: RenderedViewMetadata) => Promise<ViewPluginLinkHookReturn>;
|
|
137
|
+
type ViewPluginLinkHookReturn = void | null | undefined | false | LwrStringBuilder | {
|
|
138
138
|
builder?: LwrStringBuilder;
|
|
139
|
-
context?: TransformPluginContext;
|
|
140
139
|
cache?: CacheResponse;
|
|
141
140
|
};
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
type ViewPluginOptimizeHook = (code: string, assetSource: AssetSource) => Promise<ViewPluginOptimizeHookReturn>;
|
|
142
|
+
type ViewPluginOptimizeHookReturn = null | undefined | false | string | {
|
|
144
143
|
code: string;
|
|
145
144
|
map?: any;
|
|
146
|
-
context?: TransformPluginContext;
|
|
147
145
|
};
|
|
148
146
|
export interface ViewTransformHooks {
|
|
149
147
|
link: ViewPluginLinkHook;
|
|
@@ -152,7 +150,7 @@ export interface ViewTransformHooks {
|
|
|
152
150
|
export interface ViewTransformPlugin extends Partial<ViewTransformHooks> {
|
|
153
151
|
name: string;
|
|
154
152
|
}
|
|
155
|
-
export
|
|
153
|
+
export type ViewParams = Record<string, Json>;
|
|
156
154
|
export interface ViewInfo {
|
|
157
155
|
id: string;
|
|
158
156
|
url: string;
|
|
@@ -169,7 +167,7 @@ export interface ViewPageContext {
|
|
|
169
167
|
title?: string;
|
|
170
168
|
url: string;
|
|
171
169
|
}
|
|
172
|
-
export
|
|
170
|
+
export type ViewModuleResourceContext = {
|
|
173
171
|
isPreload?: boolean;
|
|
174
172
|
isSSR?: boolean;
|
|
175
173
|
async?: boolean;
|
|
@@ -183,7 +181,7 @@ export interface ViewRegistry {
|
|
|
183
181
|
hasViewDefinition<R extends RuntimeEnvironment>(view: View, viewParams: ViewParams, runtimeEnvironment: R, runtimeParams?: RuntimeParams, renderOptions?: RenderOptions): boolean;
|
|
184
182
|
getPublicApi(): PublicViewRegistry;
|
|
185
183
|
}
|
|
186
|
-
export
|
|
184
|
+
export type PublicViewRegistry = Pick<ViewRegistry, 'getView' | 'getViewDefinition'>;
|
|
187
185
|
export interface ViewHandler {
|
|
188
186
|
getViewContent(viewRequest: ViewRequest, route: LwrRoute | LwrErrorRoute, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams): Promise<ViewResponse>;
|
|
189
187
|
getViewJson(viewRequest: ViewRequest, route: LwrRoute | LwrErrorRoute, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams): Promise<ViewResponse>;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"build": "tsc -b"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
|
-
"version": "0.10.0-alpha.
|
|
11
|
+
"version": "0.10.0-alpha.20",
|
|
12
12
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"chokidar": "^3.5.3"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=16.0.0
|
|
30
|
+
"node": ">=16.0.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "45a867fc54e98f77dd442ccd5f668e23027b9246"
|
|
33
33
|
}
|