@lwrjs/types 0.9.0-alpha.3 → 0.9.0-alpha.31
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 +84 -12
- package/build/index.d.ts +85 -33
- package/build/server.d.ts +15 -4
- package/build/views.d.ts +10 -1
- package/package.json +8 -5
package/build/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CacheResponse, RenderOptions, RouteHandlerViewResponse, RuntimeEnvironment, ServerTypes, Specifier, ViewParams, ViewRequest, ViewResponse } from './index';
|
|
1
|
+
import { AssetProvider, AssetTransformPlugin, BundleProvider, CacheResponse, LwrService, ModuleProvider, RenderOptions, ResourceProvider, RouteHandlerViewResponse, RuntimeEnvironment, ServerTypes, ServiceCtor, Specifier, ViewParams, ViewProvider, ViewRequest, ViewResponse, ViewTransformPlugin } from './index';
|
|
2
2
|
export interface View {
|
|
3
3
|
id: string;
|
|
4
4
|
rootComponent?: string;
|
|
@@ -22,25 +22,30 @@ export interface NormalizedLwrRoute extends LwrRoute {
|
|
|
22
22
|
export interface LwrErrorRoute extends LwrBaseRoute {
|
|
23
23
|
status: 404 | 500;
|
|
24
24
|
}
|
|
25
|
-
export interface NormalizedLwrErrorRoute extends
|
|
25
|
+
export interface NormalizedLwrErrorRoute extends LwrErrorRoute {
|
|
26
26
|
bootstrap: NormalizedLwrAppBootstrapConfig;
|
|
27
27
|
}
|
|
28
|
-
export interface
|
|
29
|
-
autoBoot
|
|
30
|
-
syntheticShadow
|
|
31
|
-
workers
|
|
28
|
+
export interface NormalizedLwrAppBootstrapConfig {
|
|
29
|
+
autoBoot: boolean;
|
|
30
|
+
syntheticShadow: boolean;
|
|
31
|
+
workers: {
|
|
32
32
|
[id: string]: string;
|
|
33
33
|
};
|
|
34
|
-
services
|
|
35
|
-
configAsSrc
|
|
36
|
-
ssr
|
|
34
|
+
services: string[];
|
|
35
|
+
configAsSrc: boolean;
|
|
36
|
+
ssr: boolean;
|
|
37
|
+
module: string | undefined;
|
|
38
|
+
preloadModules: string[];
|
|
37
39
|
}
|
|
38
|
-
export declare type
|
|
40
|
+
export declare type LwrAppBootstrapConfig = Partial<NormalizedLwrAppBootstrapConfig>;
|
|
39
41
|
export interface LwrLockerConfig {
|
|
40
42
|
enabled: boolean;
|
|
41
43
|
trustedComponents?: string[];
|
|
42
44
|
clientOnly?: boolean;
|
|
43
45
|
}
|
|
46
|
+
export interface RouteHandlersConfig {
|
|
47
|
+
[id: string]: string;
|
|
48
|
+
}
|
|
44
49
|
export interface LocalizedViewRequest extends ViewRequest {
|
|
45
50
|
locale?: string;
|
|
46
51
|
}
|
|
@@ -69,6 +74,7 @@ export interface LwrGlobalConfig {
|
|
|
69
74
|
lwrConfigFile?: string;
|
|
70
75
|
port?: number;
|
|
71
76
|
serverMode?: string;
|
|
77
|
+
minify?: boolean | null;
|
|
72
78
|
basePath?: string;
|
|
73
79
|
rootDir?: string;
|
|
74
80
|
cacheDir?: string;
|
|
@@ -86,20 +92,32 @@ export interface LwrGlobalConfig {
|
|
|
86
92
|
resourceProviders?: ServiceConfig[];
|
|
87
93
|
viewProviders?: ServiceConfig[];
|
|
88
94
|
viewTransformers?: ServiceConfig[];
|
|
89
|
-
templateEngine?: string;
|
|
90
95
|
routes?: LwrRoute[];
|
|
91
96
|
errorRoutes?: LwrErrorRoute[];
|
|
97
|
+
routeHandlers?: RouteHandlersConfig;
|
|
92
98
|
bundleConfig?: BundleConfig;
|
|
93
99
|
serverType?: ServerTypes;
|
|
94
100
|
staticSiteGenerator?: StaticSiteGenerator;
|
|
95
101
|
locker?: LwrLockerConfig;
|
|
96
102
|
}
|
|
103
|
+
export interface BuildOptions {
|
|
104
|
+
target?: string;
|
|
105
|
+
input?: string;
|
|
106
|
+
output?: string;
|
|
107
|
+
routes?: string[];
|
|
108
|
+
modules?: string[];
|
|
109
|
+
locales?: string[];
|
|
110
|
+
clean?: boolean;
|
|
111
|
+
mode?: string;
|
|
112
|
+
}
|
|
97
113
|
export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig, 'lwc'>> {
|
|
98
114
|
routes: NormalizedLwrRoute[];
|
|
115
|
+
errorRoutes: NormalizedLwrErrorRoute[];
|
|
99
116
|
assets: AssetConfig[];
|
|
100
117
|
lwrVersion: string;
|
|
101
118
|
amdLoader: string;
|
|
102
119
|
esmLoader: string;
|
|
120
|
+
hooks: ServiceEntry[];
|
|
103
121
|
moduleProviders: ServiceEntry[];
|
|
104
122
|
viewProviders: ServiceEntry[];
|
|
105
123
|
viewTransformers: ServiceEntry[];
|
|
@@ -111,9 +129,31 @@ export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig
|
|
|
111
129
|
export interface StaticSiteGenerator {
|
|
112
130
|
outputDir?: string;
|
|
113
131
|
locales?: string[];
|
|
132
|
+
skipCleanOutputDir?: boolean;
|
|
133
|
+
skipBaseDocumentGeneration?: boolean;
|
|
114
134
|
_additionalRoutePaths?: string[];
|
|
115
135
|
_additionalModules?: string[];
|
|
116
136
|
}
|
|
137
|
+
export interface ServerBuild {
|
|
138
|
+
appConfig: NormalizedLwrGlobalConfig;
|
|
139
|
+
runtimeEnvironment: RuntimeEnvironment;
|
|
140
|
+
globalData: GlobalData;
|
|
141
|
+
hooks: HooksPlugin[];
|
|
142
|
+
services: Services;
|
|
143
|
+
routeHandlers: RouteHandlers;
|
|
144
|
+
}
|
|
145
|
+
export interface Services {
|
|
146
|
+
moduleProviders: ResolvedServiceEntry<ModuleProvider>[];
|
|
147
|
+
bundleProviders: ResolvedServiceEntry<BundleProvider>[];
|
|
148
|
+
viewProviders: ResolvedServiceEntry<ViewProvider>[];
|
|
149
|
+
viewTransformers: ResolvedServiceEntry<ViewTransformPlugin>[];
|
|
150
|
+
resourceProviders: ResolvedServiceEntry<ResourceProvider>[];
|
|
151
|
+
assetProviders: ResolvedServiceEntry<AssetProvider>[];
|
|
152
|
+
assetTransformers: ResolvedServiceEntry<AssetTransformPlugin>[];
|
|
153
|
+
}
|
|
154
|
+
export interface RouteHandlers {
|
|
155
|
+
[id: string]: RouteHandlerFunction;
|
|
156
|
+
}
|
|
117
157
|
interface AssetConfigCommon {
|
|
118
158
|
urlPath: string;
|
|
119
159
|
alias?: string;
|
|
@@ -136,12 +176,16 @@ export interface NormalizedLwcConfig extends Omit<LwcConfig, 'interchangeableMod
|
|
|
136
176
|
}
|
|
137
177
|
export declare type ServiceEntry = [string, any?];
|
|
138
178
|
export declare type ServiceConfig = string | ServiceEntry;
|
|
179
|
+
export declare type ResolvedServiceEntry<T extends LwrService> = [ServiceCtor<T>, any?];
|
|
139
180
|
export interface BundleConfig {
|
|
140
181
|
exclude?: string[];
|
|
141
182
|
UNSAFE_lwrDefaultExclude?: string[];
|
|
142
183
|
external?: Record<string, string>;
|
|
143
184
|
alias?: Record<string, string>;
|
|
144
185
|
}
|
|
186
|
+
export interface BundleConfigOverrides extends BundleConfig {
|
|
187
|
+
appendExcludes?: boolean;
|
|
188
|
+
}
|
|
145
189
|
export declare type Environment = string;
|
|
146
190
|
export interface EnvironmentConfig {
|
|
147
191
|
default?: Environment;
|
|
@@ -168,7 +212,35 @@ export interface InterchangeableModuleRecord {
|
|
|
168
212
|
};
|
|
169
213
|
}
|
|
170
214
|
export interface HooksPlugin {
|
|
171
|
-
|
|
215
|
+
/**
|
|
216
|
+
* Programmatically modify application and runtime configurations.
|
|
217
|
+
*
|
|
218
|
+
* @remarks
|
|
219
|
+
* These hooks are invoked both at build time and runtime for Express and Koa(not MRT).
|
|
220
|
+
*
|
|
221
|
+
* During server build, config hooks are invoked prior to static site generation
|
|
222
|
+
* and server bundling.
|
|
223
|
+
*
|
|
224
|
+
* For the `createServer`(ie. Express/Koa) runtime, these config hooks are invoked before all other hooks
|
|
225
|
+
* during server context initialization
|
|
226
|
+
*
|
|
227
|
+
* For the `createHandler`(ie. MRT Serverless Express) runtime, these config hooks are NOT invoked. This runtime does
|
|
228
|
+
* not support asynchronous execution during initialization. These hooks MUST be ran during
|
|
229
|
+
* the server build.
|
|
230
|
+
*
|
|
231
|
+
*/
|
|
232
|
+
initConfigs?: (lwrConfig: NormalizedLwrGlobalConfig, dataConfig: GlobalData, runtimeConfig: RuntimeEnvironment) => Promise<void> | void;
|
|
233
|
+
/**
|
|
234
|
+
* Load routes on application start up.
|
|
235
|
+
*
|
|
236
|
+
* @remarks
|
|
237
|
+
* These hooks are invoked ONLY at runtime.
|
|
238
|
+
*
|
|
239
|
+
* For the `createServer` runtime, these hooks are invoked AFTER config hooks.
|
|
240
|
+
*
|
|
241
|
+
* For the `createHandler` runtime, these hooks are invoked during server context initialization.
|
|
242
|
+
*/
|
|
243
|
+
onStart?: (routes: LwrRoute[]) => void;
|
|
172
244
|
}
|
|
173
245
|
export {};
|
|
174
246
|
//# sourceMappingURL=config.d.ts.map
|
package/build/index.d.ts
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
/// <reference types="node" />
|
|
5
|
-
|
|
5
|
+
import type { WatchOptions } from 'chokidar';
|
|
6
6
|
import { EventEmitter } from 'events';
|
|
7
7
|
import fs from 'fs';
|
|
8
|
-
import { Server } from 'http';
|
|
9
8
|
import { Readable } from 'stream';
|
|
10
|
-
import { BundleConfig, EnvironmentConfig, HooksPlugin, LwrLockerConfig, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, ResolverModuleRecord } from './config.js';
|
|
9
|
+
import { BundleConfig, EnvironmentConfig, HooksPlugin, LwrLockerConfig, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, ResolverModuleRecord, BundleConfigOverrides, RouteHandlers, AssetConfig } from './config.js';
|
|
11
10
|
import { AssetReference, CompiledView, PublicViewRegistry, ViewProvider, ViewRegistry, ViewTransformPlugin } from './views.js';
|
|
12
11
|
export * from './lwr-shim.js';
|
|
13
12
|
export * from './config.js';
|
|
@@ -78,6 +77,7 @@ interface BaseModuleEntry {
|
|
|
78
77
|
specifier: Specifier;
|
|
79
78
|
version: Version;
|
|
80
79
|
interchangeable?: boolean;
|
|
80
|
+
src?: string;
|
|
81
81
|
}
|
|
82
82
|
export interface FsModuleEntry extends BaseModuleEntry {
|
|
83
83
|
virtual?: false;
|
|
@@ -164,8 +164,11 @@ export interface ServerModeConfig {
|
|
|
164
164
|
};
|
|
165
165
|
featureFlags: FeatureFlags;
|
|
166
166
|
}
|
|
167
|
-
export interface FeatureFlags {
|
|
168
|
-
LEGACY_LOADER
|
|
167
|
+
export interface FeatureFlags extends Record<string, boolean | undefined> {
|
|
168
|
+
LEGACY_LOADER?: boolean;
|
|
169
|
+
SSR_STATIC_BUNDLES?: boolean;
|
|
170
|
+
SSR_SANDBOX_WORKER?: boolean;
|
|
171
|
+
ASSETS_ON_LAMBDA?: boolean;
|
|
169
172
|
}
|
|
170
173
|
export interface RuntimeEnvironment extends ServerModeConfig {
|
|
171
174
|
apiVersion: string;
|
|
@@ -192,6 +195,7 @@ export interface ResourceIdentity {
|
|
|
192
195
|
export interface AssetIdentity {
|
|
193
196
|
assetId: AssetIdentifier;
|
|
194
197
|
signature: string;
|
|
198
|
+
immutable: boolean;
|
|
195
199
|
}
|
|
196
200
|
export interface RuntimeContext {
|
|
197
201
|
runtimeEnvironment: RuntimeEnvironment;
|
|
@@ -201,6 +205,11 @@ export interface BootstrapRuntimeEnvironment extends RuntimeEnvironment {
|
|
|
201
205
|
bootstrapImports?: string[];
|
|
202
206
|
bootstrapDynamicImports?: string[];
|
|
203
207
|
}
|
|
208
|
+
export type { WatchOptions } from 'chokidar';
|
|
209
|
+
export interface WatcherFactory {
|
|
210
|
+
createFileWatcher(options?: WatchOptions): Watcher;
|
|
211
|
+
setupWatcher(onModuleChange: Function): Watcher;
|
|
212
|
+
}
|
|
204
213
|
export interface Watcher extends EventEmitter {
|
|
205
214
|
add(paths: string | ReadonlyArray<string>): void;
|
|
206
215
|
unwatch(paths: string | ReadonlyArray<string>): void;
|
|
@@ -254,7 +263,7 @@ export interface ModuleProvider {
|
|
|
254
263
|
}
|
|
255
264
|
export declare type LwrService = ModuleProvider | ResourceProvider | ViewProvider | AssetProvider | HooksPlugin | AssetTransformPlugin | ViewTransformPlugin;
|
|
256
265
|
export interface ServiceCtor<T extends LwrService, R extends Record<string, Json> = {}> {
|
|
257
|
-
new (
|
|
266
|
+
new (providerConfig: R, serviceProviderConfig?: any, ...args: any[]): T;
|
|
258
267
|
}
|
|
259
268
|
export interface ModuleRegistry {
|
|
260
269
|
name: string;
|
|
@@ -262,14 +271,22 @@ export interface ModuleRegistry {
|
|
|
262
271
|
getLinkedModule<T extends AbstractModuleId>(moduleId: T, runtimeEnvironment: RuntimeEnvironment, runtimeParams?: RuntimeParams): Promise<LinkedModuleDefinition>;
|
|
263
272
|
getModule<T extends AbstractModuleId>(moduleId: T, runtimeParams?: RuntimeParams): Promise<ModuleDefinition>;
|
|
264
273
|
getModuleEntry(moduleId: AbstractModuleId, runtimeParams?: RuntimeParams): Promise<ModuleEntry>;
|
|
265
|
-
resolveModuleUri<R extends RuntimeEnvironment, S extends string | undefined>(moduleId: Required<Pick<ModuleId, 'specifier' | 'version'>>, runtimeEnvironment: R, runtimeParams?: RuntimeParams, signature?: S):
|
|
274
|
+
resolveModuleUri<R extends RuntimeEnvironment, S extends string | undefined>(moduleId: Required<Pick<ModuleId, 'specifier' | 'version'>>, runtimeEnvironment: R, runtimeParams?: RuntimeParams, signature?: S): Promise<string>;
|
|
275
|
+
resolveModuleUriSync<R extends RuntimeEnvironment, S extends string | undefined>(moduleId: Required<Pick<ModuleId, 'specifier' | 'version'>>, signature: S, runtimeEnvironment: R, runtimeParams?: RuntimeParams): string;
|
|
266
276
|
getPublicApi(): PublicModuleRegistry;
|
|
267
277
|
}
|
|
268
|
-
export declare type PublicModuleRegistry = Pick<ModuleRegistry, 'getModule' | 'getModuleEntry' | 'resolveModuleUri'>;
|
|
278
|
+
export declare type PublicModuleRegistry = Pick<ModuleRegistry, 'getModule' | 'getModuleEntry' | 'getLinkedModule' | 'resolveModuleUri'>;
|
|
279
|
+
export interface BundleProvider {
|
|
280
|
+
name: string;
|
|
281
|
+
bundle<T extends AbstractModuleId, R extends RuntimeEnvironment>(moduleId: T, runtimeEnvironment: R, runtimeParams: RuntimeParams, configOverrides?: BundleConfig): Promise<BundleDefinition | undefined>;
|
|
282
|
+
}
|
|
269
283
|
export interface ModuleBundler {
|
|
270
|
-
|
|
284
|
+
addBundleProviders(providers: BundleProvider[]): void;
|
|
285
|
+
getModuleBundle<T extends AbstractModuleId, R extends RuntimeEnvironment>(moduleId: T, runtimeEnvironment: R, runtimeParams?: RuntimeParams, bundleConfigOverrides?: BundleConfigOverrides): Promise<BundleDefinition>;
|
|
286
|
+
resolveModuleUri(moduleId: Required<Pick<ModuleId, 'specifier' | 'version'>>, runtimeEnvironment: RuntimeEnvironment, runtimeParams?: RuntimeParams, signature?: string): Promise<string>;
|
|
287
|
+
getPublicApi(): PublicModuleBundler;
|
|
271
288
|
}
|
|
272
|
-
export declare type PublicModuleBundler = Pick<ModuleBundler, 'getModuleBundle'>;
|
|
289
|
+
export declare type PublicModuleBundler = Pick<ModuleBundler, 'getModuleBundle' | 'resolveModuleUri'>;
|
|
273
290
|
export interface BundleRecord {
|
|
274
291
|
imports?: BaseModuleReference[];
|
|
275
292
|
dynamicImports?: BaseDynamicModuleReference[];
|
|
@@ -280,6 +297,7 @@ export interface BundleDefinition extends ModuleId {
|
|
|
280
297
|
config: BundleConfig;
|
|
281
298
|
map?: any;
|
|
282
299
|
bundleRecord: BundleRecord;
|
|
300
|
+
src?: string;
|
|
283
301
|
}
|
|
284
302
|
export interface ProviderAppConfig {
|
|
285
303
|
modules: ResolverModuleRecord[];
|
|
@@ -294,9 +312,10 @@ export interface ProviderAppConfig {
|
|
|
294
312
|
amdLoader: string;
|
|
295
313
|
esmLoader: string;
|
|
296
314
|
environment?: EnvironmentConfig;
|
|
315
|
+
bundleConfig: BundleConfig;
|
|
316
|
+
assets: AssetConfig[];
|
|
297
317
|
}
|
|
298
318
|
export interface ProviderContext {
|
|
299
|
-
compiler: Compiler;
|
|
300
319
|
appObserver: Pick<LwrAppObserver, 'onModuleDefinitionChange' | 'onModuleSourceChange' | 'onAssetSourceChange' | 'onViewSourceChange'>;
|
|
301
320
|
appEmitter: Pick<LwrAppEmitter, 'notifyModuleDefinitionChanged' | 'notifyAssetSourceChanged' | 'notifyModuleSourceChanged' | 'notifyViewSourceChanged'>;
|
|
302
321
|
moduleRegistry: PublicModuleRegistry;
|
|
@@ -306,6 +325,8 @@ export interface ProviderContext {
|
|
|
306
325
|
assetRegistry: PublicAssetRegistry;
|
|
307
326
|
config: ProviderAppConfig;
|
|
308
327
|
runtimeEnvironment: RuntimeEnvironment;
|
|
328
|
+
watcherFactory?: WatcherFactory;
|
|
329
|
+
siteMetadata?: SiteMetadata;
|
|
309
330
|
}
|
|
310
331
|
export interface ResourceIdentifier {
|
|
311
332
|
specifier: string;
|
|
@@ -320,8 +341,9 @@ export interface AssetUri {
|
|
|
320
341
|
uri: string;
|
|
321
342
|
immutable: boolean;
|
|
322
343
|
entry: string;
|
|
344
|
+
external?: boolean;
|
|
323
345
|
}
|
|
324
|
-
export declare type ResourceType = 'application/javascript' | 'application/json' | 'text/css' | 'lwr-importmap' | 'module';
|
|
346
|
+
export declare type ResourceType = 'application/javascript' | 'application/json' | 'text/css' | 'lwr-importmap' | 'module' | string;
|
|
325
347
|
export interface ResourceDefinition {
|
|
326
348
|
specifier?: string;
|
|
327
349
|
type: ResourceType;
|
|
@@ -331,7 +353,7 @@ export interface ResourceDefinition {
|
|
|
331
353
|
defer?: boolean;
|
|
332
354
|
nonce?: string;
|
|
333
355
|
content?: string;
|
|
334
|
-
stream?: Readable;
|
|
356
|
+
stream?: () => Readable;
|
|
335
357
|
isPreload?: boolean;
|
|
336
358
|
}
|
|
337
359
|
export interface AssetMetadata {
|
|
@@ -345,6 +367,8 @@ export interface AssetSource {
|
|
|
345
367
|
content: (encoding?: BufferEncoding) => string | Buffer;
|
|
346
368
|
uri?: string;
|
|
347
369
|
metadata?: AssetMetadata;
|
|
370
|
+
type?: AssetType;
|
|
371
|
+
noTransform?: boolean;
|
|
348
372
|
}
|
|
349
373
|
export declare type AssetType = 'asset' | 'content-asset' | 'external' | 'unknown';
|
|
350
374
|
export interface AssetDefinition extends AssetSource {
|
|
@@ -359,7 +383,7 @@ export interface ResourceProvider {
|
|
|
359
383
|
}
|
|
360
384
|
export interface AssetProvider {
|
|
361
385
|
name: string;
|
|
362
|
-
getAsset(
|
|
386
|
+
getAsset(assetIdentifier: AssetIdentifier): Promise<AssetSource | undefined>;
|
|
363
387
|
}
|
|
364
388
|
export declare type TransformPluginContext = Record<string, any>;
|
|
365
389
|
declare type AssetPluginTransformHook = (code: string | Buffer, assetSource: AssetSource, context?: TransformPluginContext) => Promise<AssetPluginTransformHookReturn>;
|
|
@@ -397,12 +421,13 @@ export declare type PublicResourceRegistry = Pick<ResourceRegistry, 'getResource
|
|
|
397
421
|
export interface AssetRegistry {
|
|
398
422
|
name: string;
|
|
399
423
|
addAssetProviders(provider: AssetProvider[]): void;
|
|
424
|
+
addAssetTransformers(transformers: AssetTransformPlugin[]): void;
|
|
400
425
|
getAsset<R extends AssetIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T, includeMetadata?: boolean): Promise<AssetDefinition>;
|
|
401
426
|
resolveAssetUri<R extends AssetIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T): Promise<AssetUri>;
|
|
402
427
|
getPublicApi(): PublicAssetRegistry;
|
|
403
428
|
}
|
|
404
429
|
export declare type PublicAssetRegistry = Pick<AssetRegistry, 'getAsset' | 'resolveAssetUri'>;
|
|
405
|
-
export interface
|
|
430
|
+
export interface LwcCompilerConfig {
|
|
406
431
|
name: string;
|
|
407
432
|
namespace?: string;
|
|
408
433
|
filename: string;
|
|
@@ -436,22 +461,6 @@ export interface CompilerResult {
|
|
|
436
461
|
export interface BundleFiles {
|
|
437
462
|
[filename: string]: string;
|
|
438
463
|
}
|
|
439
|
-
export interface Compiler {
|
|
440
|
-
convertToAmd(source: string, { id }: {
|
|
441
|
-
id: string;
|
|
442
|
-
}): Promise<CompilerResult>;
|
|
443
|
-
getModuleMetadata(compiledSource: string): Promise<Partial<CompiledMetadata>>;
|
|
444
|
-
lockerize(compiledModule: ModuleCompiled, lockerConfig: LwrLockerConfig, sourcemap: boolean): CompilerResult;
|
|
445
|
-
minifyJavascript(source: string): Promise<CompilerResult>;
|
|
446
|
-
parseJavascript(source: string, options: ParseOptions): Promise<CompilerResult>;
|
|
447
|
-
minifyCSS(source: string): Promise<CompilerResult>;
|
|
448
|
-
}
|
|
449
|
-
export interface ParseOptions {
|
|
450
|
-
envMode: string;
|
|
451
|
-
}
|
|
452
|
-
export interface CompilerContext {
|
|
453
|
-
runtimeEnvironment: RuntimeEnvironment;
|
|
454
|
-
}
|
|
455
464
|
export interface ClientBootstrapConfig {
|
|
456
465
|
appId?: string;
|
|
457
466
|
bootstrapModule: string;
|
|
@@ -494,15 +503,16 @@ export interface MetricsConfig {
|
|
|
494
503
|
export interface ServerContext {
|
|
495
504
|
appObserver: LwrAppObserver;
|
|
496
505
|
appEmitter: LwrAppEmitter;
|
|
497
|
-
server: Server;
|
|
498
|
-
compiler: Compiler;
|
|
499
506
|
moduleRegistry: ModuleRegistry;
|
|
500
507
|
moduleBundler: ModuleBundler;
|
|
501
508
|
viewRegistry: ViewRegistry;
|
|
502
509
|
resourceRegistry: ResourceRegistry;
|
|
503
510
|
assetRegistry: AssetRegistry;
|
|
511
|
+
watcherFactory?: WatcherFactory;
|
|
512
|
+
siteMetadata?: SiteMetadata;
|
|
504
513
|
appConfig: NormalizedLwrGlobalConfig;
|
|
505
514
|
runtimeEnvironment: RuntimeEnvironment;
|
|
515
|
+
routeHandlers: RouteHandlers;
|
|
506
516
|
}
|
|
507
517
|
export interface Observer<V> {
|
|
508
518
|
next: (value: V) => void;
|
|
@@ -579,4 +589,46 @@ export interface LwrStringBuilder {
|
|
|
579
589
|
toString(): string;
|
|
580
590
|
original: string;
|
|
581
591
|
}
|
|
592
|
+
export interface SiteMetadata {
|
|
593
|
+
/**
|
|
594
|
+
* Get the path that all site metadata is relative to
|
|
595
|
+
*/
|
|
596
|
+
getSiteRootDir(): string;
|
|
597
|
+
/**
|
|
598
|
+
* Get the current metadata about the pre-built module bundles for the site.
|
|
599
|
+
*/
|
|
600
|
+
getSiteBundles(): SiteBundles;
|
|
601
|
+
/**
|
|
602
|
+
* Get the current metadata about the pre-built resources for the site.
|
|
603
|
+
*/
|
|
604
|
+
getSiteResources(): SiteResources;
|
|
605
|
+
/**
|
|
606
|
+
* Get the current metadata about the pre-built assets for the site.
|
|
607
|
+
*/
|
|
608
|
+
getSiteAssets(): SiteAssets;
|
|
609
|
+
/**
|
|
610
|
+
* To save out metadata for the current site
|
|
611
|
+
* @param staticRoot
|
|
612
|
+
* @returns
|
|
613
|
+
*/
|
|
614
|
+
persistSiteMetadata(): Promise<void>;
|
|
615
|
+
}
|
|
616
|
+
export interface SiteBundles {
|
|
617
|
+
bundles: Record<string, SiteBundle>;
|
|
618
|
+
}
|
|
619
|
+
export interface SiteResources {
|
|
620
|
+
resources: Record<string, SiteArtifact>;
|
|
621
|
+
}
|
|
622
|
+
export interface SiteAssets {
|
|
623
|
+
assets: Record<string, SiteArtifact>;
|
|
624
|
+
}
|
|
625
|
+
export interface SiteArtifact {
|
|
626
|
+
path: string;
|
|
627
|
+
mimeType?: string;
|
|
628
|
+
}
|
|
629
|
+
export interface SiteBundle extends SiteArtifact {
|
|
630
|
+
version?: Version;
|
|
631
|
+
imports: string[];
|
|
632
|
+
includedModules?: string[];
|
|
633
|
+
}
|
|
582
634
|
//# sourceMappingURL=index.d.ts.map
|
package/build/server.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Application as ExpressApp } from 'express';
|
|
|
4
4
|
import Koa, { Context } from 'koa';
|
|
5
5
|
import http from 'http';
|
|
6
6
|
import { Readable } from 'stream';
|
|
7
|
-
import { RuntimeContext, RuntimeEnvironment } from './index';
|
|
7
|
+
import type { NormalizedLwrGlobalConfig, RuntimeContext, RuntimeEnvironment } from './index.js';
|
|
8
8
|
export declare type ServerTypes = 'koa' | 'express' | 'fs';
|
|
9
9
|
export declare 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 {
|
|
@@ -37,6 +37,7 @@ export interface InternalAppServer<T extends ServerTypes> {
|
|
|
37
37
|
}
|
|
38
38
|
export declare type PublicAppServer<T extends ServerTypes> = Pick<InternalAppServer<T>, 'use' | 'all' | 'get' | 'post' | 'getRegexWildcard'>;
|
|
39
39
|
export declare type InternalAppServerOptions = {
|
|
40
|
+
app?: ServerTypeImpl<ServerTypes>;
|
|
40
41
|
basePath?: string;
|
|
41
42
|
};
|
|
42
43
|
export interface InternalAppServerConstructable {
|
|
@@ -59,6 +60,9 @@ export interface MiddlewareRequest {
|
|
|
59
60
|
acceptsLanguages(): string[];
|
|
60
61
|
get(field: string): string | undefined;
|
|
61
62
|
cookie(name: string): string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Return true if the request has a `json` query parameter
|
|
65
|
+
*/
|
|
62
66
|
hasJsonParam(): boolean;
|
|
63
67
|
/**
|
|
64
68
|
* Return JSON if:
|
|
@@ -66,20 +70,27 @@ export interface MiddlewareRequest {
|
|
|
66
70
|
* - the Accept header explicitly requests "application/json"
|
|
67
71
|
*/
|
|
68
72
|
isJsonRequest(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Return true if the request was initiated by static generation
|
|
75
|
+
*/
|
|
76
|
+
isSiteGeneration(): boolean;
|
|
69
77
|
/**
|
|
70
78
|
* Return false when both Accept and JSON query param are applied, but do not semantically match
|
|
71
79
|
*/
|
|
72
80
|
validateJsonRequest(): boolean;
|
|
73
81
|
/**
|
|
74
|
-
*
|
|
82
|
+
* Return true when the environment path parameter exists and is supported
|
|
83
|
+
*/
|
|
84
|
+
validateEnvironmentRequest(config: NormalizedLwrGlobalConfig): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Use the request parameters to resolve the runtime context(ie. environment and parameters)
|
|
75
87
|
*/
|
|
76
88
|
getRuntimeContext(defaultRuntimeEnvironment: RuntimeEnvironment): RuntimeContext;
|
|
77
|
-
isSiteGeneration(): boolean;
|
|
78
89
|
}
|
|
79
90
|
export interface MiddlewareResponse {
|
|
80
91
|
set(header: any): void;
|
|
81
92
|
setHeader(name: string, value: string | string[]): void;
|
|
82
|
-
|
|
93
|
+
setSiteGenerationMetadata(metadata: any): void;
|
|
83
94
|
status(status: number): MiddlewareResponse;
|
|
84
95
|
send(object: any): void;
|
|
85
96
|
sendStatus(httpCode: number): void;
|
package/build/views.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { RouteHandlerFunction, RouteHandlerView, View } from './config.js';
|
|
2
|
+
import { LwrErrorRoute, LwrRoute, RouteHandlerFunction, RouteHandlerView, View } from './config.js';
|
|
3
3
|
import { AssetSource, AssetUri, Endpoints, FlattenedModuleGraphs, ImportMetadata, Json, LwrStringBuilder, ResourceDefinition, RuntimeEnvironment, RuntimeParams, Specifier, TransformPluginContext } from './index.js';
|
|
4
4
|
export declare type ViewIdentity = Pick<View, 'rootComponent' | 'contentTemplate'>;
|
|
5
5
|
export interface ViewSource {
|
|
@@ -82,6 +82,7 @@ export interface LinkedViewDefinition {
|
|
|
82
82
|
renderedView: string;
|
|
83
83
|
viewRecord: RenderedViewRecord;
|
|
84
84
|
immutable: boolean;
|
|
85
|
+
cache?: CacheResponse;
|
|
85
86
|
}
|
|
86
87
|
interface ViewRequestQs {
|
|
87
88
|
[key: string]: undefined | string | string[];
|
|
@@ -136,6 +137,7 @@ declare type ViewPluginLinkHook = (builder: LwrStringBuilder, viewContext: ViewT
|
|
|
136
137
|
declare type ViewPluginLinkHookReturn = void | null | undefined | false | LwrStringBuilder | {
|
|
137
138
|
builder?: LwrStringBuilder;
|
|
138
139
|
context?: TransformPluginContext;
|
|
140
|
+
cache?: CacheResponse;
|
|
139
141
|
};
|
|
140
142
|
declare type ViewPluginOptimizeHook = (code: string, assetSource: AssetSource, context?: TransformPluginContext) => Promise<ViewPluginOptimizeHookReturn>;
|
|
141
143
|
declare type ViewPluginOptimizeHookReturn = null | undefined | false | string | {
|
|
@@ -174,6 +176,7 @@ export declare type ViewModuleResourceContext = {
|
|
|
174
176
|
};
|
|
175
177
|
export interface ViewRegistry {
|
|
176
178
|
addViewProviders(providers: ViewProvider[]): void;
|
|
179
|
+
addViewTransformers(transformers: ViewTransformPlugin[]): void;
|
|
177
180
|
initializeViewProviders(): Promise<void[]>;
|
|
178
181
|
getView(viewId: ViewIdentity, skipCaching?: boolean): Promise<CompiledView>;
|
|
179
182
|
getViewDefinition<R extends RuntimeEnvironment>(view: View, viewParams: ViewParams, runtimeEnvironment: R, runtimeParams?: RuntimeParams, renderOptions?: RenderOptions): Promise<LinkedViewDefinition>;
|
|
@@ -181,6 +184,11 @@ export interface ViewRegistry {
|
|
|
181
184
|
getPublicApi(): PublicViewRegistry;
|
|
182
185
|
}
|
|
183
186
|
export declare type PublicViewRegistry = Pick<ViewRegistry, 'getView' | 'getViewDefinition'>;
|
|
187
|
+
export interface ViewHandler {
|
|
188
|
+
getViewContent(viewRequest: ViewRequest, route: LwrRoute | LwrErrorRoute, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams): Promise<ViewResponse>;
|
|
189
|
+
getViewJson(viewRequest: ViewRequest, route: LwrRoute | LwrErrorRoute, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams): Promise<ViewResponse>;
|
|
190
|
+
getViewConfiguration(viewRequest: ViewRequest, route: LwrRoute | LwrErrorRoute, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams): Promise<ViewResponse | undefined>;
|
|
191
|
+
}
|
|
184
192
|
export interface SsrRequestContext {
|
|
185
193
|
props: Json;
|
|
186
194
|
params: {
|
|
@@ -201,6 +209,7 @@ export interface PageDataResponse {
|
|
|
201
209
|
fetchpriority?: 'high' | 'low' | 'auto';
|
|
202
210
|
}[];
|
|
203
211
|
};
|
|
212
|
+
cache?: CacheResponse;
|
|
204
213
|
}
|
|
205
214
|
export {};
|
|
206
215
|
//# sourceMappingURL=views.d.ts.map
|
package/package.json
CHANGED
|
@@ -8,23 +8,26 @@
|
|
|
8
8
|
"build": "tsc -b"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
|
-
"version": "0.9.0-alpha.
|
|
11
|
+
"version": "0.9.0-alpha.31",
|
|
12
12
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "https://github.com/salesforce/lwr.git",
|
|
15
|
+
"url": "https://github.com/salesforce-experience-platform-emu/lwr.git",
|
|
16
16
|
"directory": "packages/@lwrjs/types"
|
|
17
17
|
},
|
|
18
18
|
"bugs": {
|
|
19
|
-
"url": "https://github.com/salesforce/lwr/issues"
|
|
19
|
+
"url": "https://github.com/salesforce-experience-platform-emu/lwr/issues"
|
|
20
20
|
},
|
|
21
21
|
"main": "build/index.js",
|
|
22
22
|
"files": [
|
|
23
23
|
"build/**/*.js",
|
|
24
24
|
"build/**/*.d.ts"
|
|
25
25
|
],
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"chokidar": "^3.5.3"
|
|
28
|
+
},
|
|
26
29
|
"engines": {
|
|
27
|
-
"node": ">=
|
|
30
|
+
"node": ">=16.0.0 <20"
|
|
28
31
|
},
|
|
29
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "be668a80891cd00d1fb689aa99037b0f05cc4061"
|
|
30
33
|
}
|