@lwrjs/types 0.9.9-alpha.8 → 0.10.0-alpha.1

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 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;
@@ -25,22 +25,27 @@ export interface LwrErrorRoute extends LwrBaseRoute {
25
25
  export interface NormalizedLwrErrorRoute extends LwrErrorRoute {
26
26
  bootstrap: NormalizedLwrAppBootstrapConfig;
27
27
  }
28
- export interface LwrAppBootstrapConfig {
29
- autoBoot?: boolean;
30
- syntheticShadow?: boolean;
31
- workers?: {
28
+ export interface NormalizedLwrAppBootstrapConfig {
29
+ autoBoot: boolean;
30
+ syntheticShadow: boolean;
31
+ workers: {
32
32
  [id: string]: string;
33
33
  };
34
- services?: string[];
35
- configAsSrc?: boolean;
36
- ssr?: boolean;
34
+ services: string[];
35
+ configAsSrc: boolean;
36
+ ssr: boolean;
37
+ module: string | undefined;
38
+ preloadModules: string[];
37
39
  }
38
- export declare type NormalizedLwrAppBootstrapConfig = Required<LwrAppBootstrapConfig>;
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;
@@ -82,18 +88,29 @@ export interface LwrGlobalConfig {
82
88
  hooks?: ServiceConfig[];
83
89
  environment?: EnvironmentConfig;
84
90
  lwc?: LwcConfig;
91
+ bundleProviders?: ServiceConfig[];
85
92
  moduleProviders?: ServiceConfig[];
86
93
  resourceProviders?: ServiceConfig[];
87
94
  viewProviders?: ServiceConfig[];
88
95
  viewTransformers?: ServiceConfig[];
89
- templateEngine?: string;
90
96
  routes?: LwrRoute[];
91
97
  errorRoutes?: LwrErrorRoute[];
98
+ routeHandlers?: RouteHandlersConfig;
92
99
  bundleConfig?: BundleConfig;
93
100
  serverType?: ServerTypes;
94
101
  staticSiteGenerator?: StaticSiteGenerator;
95
102
  locker?: LwrLockerConfig;
96
103
  }
104
+ export interface BuildOptions {
105
+ target?: string;
106
+ input?: string;
107
+ output?: string;
108
+ routes?: string[];
109
+ modules?: string[];
110
+ locales?: string[];
111
+ clean?: boolean;
112
+ mode?: string;
113
+ }
97
114
  export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig, 'lwc'>> {
98
115
  routes: NormalizedLwrRoute[];
99
116
  errorRoutes: NormalizedLwrErrorRoute[];
@@ -101,6 +118,8 @@ export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig
101
118
  lwrVersion: string;
102
119
  amdLoader: string;
103
120
  esmLoader: string;
121
+ hooks: ServiceEntry[];
122
+ bundleProviders: ServiceEntry[];
104
123
  moduleProviders: ServiceEntry[];
105
124
  viewProviders: ServiceEntry[];
106
125
  viewTransformers: ServiceEntry[];
@@ -112,9 +131,32 @@ export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig
112
131
  export interface StaticSiteGenerator {
113
132
  outputDir?: string;
114
133
  locales?: string[];
134
+ skipCleanOutputDir?: boolean;
135
+ skipBaseDocumentGeneration?: boolean;
115
136
  _additionalRoutePaths?: string[];
116
137
  _additionalModules?: string[];
117
138
  }
139
+ export interface ServerBuild {
140
+ buildDir: string;
141
+ appConfig: NormalizedLwrGlobalConfig;
142
+ runtimeEnvironment: RuntimeEnvironment;
143
+ globalData: GlobalData;
144
+ hooks: HooksPlugin[];
145
+ services: Services;
146
+ routeHandlers: RouteHandlers;
147
+ }
148
+ export interface Services {
149
+ moduleProviders: ResolvedServiceEntry<ModuleProvider>[];
150
+ bundleProviders: ResolvedServiceEntry<BundleProvider>[];
151
+ viewProviders: ResolvedServiceEntry<ViewProvider>[];
152
+ viewTransformers: ResolvedServiceEntry<ViewTransformPlugin>[];
153
+ resourceProviders: ResolvedServiceEntry<ResourceProvider>[];
154
+ assetProviders: ResolvedServiceEntry<AssetProvider>[];
155
+ assetTransformers: ResolvedServiceEntry<AssetTransformPlugin>[];
156
+ }
157
+ export interface RouteHandlers {
158
+ [id: string]: RouteHandlerFunction;
159
+ }
118
160
  interface AssetConfigCommon {
119
161
  urlPath: string;
120
162
  alias?: string;
@@ -137,12 +179,16 @@ export interface NormalizedLwcConfig extends Omit<LwcConfig, 'interchangeableMod
137
179
  }
138
180
  export declare type ServiceEntry = [string, any?];
139
181
  export declare type ServiceConfig = string | ServiceEntry;
182
+ export declare type ResolvedServiceEntry<T extends LwrService> = [ServiceCtor<T>, any?];
140
183
  export interface BundleConfig {
141
184
  exclude?: string[];
142
185
  UNSAFE_lwrDefaultExclude?: string[];
143
186
  external?: Record<string, string>;
144
187
  alias?: Record<string, string>;
145
188
  }
189
+ export interface BundleConfigOverrides extends BundleConfig {
190
+ appendExcludes?: boolean;
191
+ }
146
192
  export declare type Environment = string;
147
193
  export interface EnvironmentConfig {
148
194
  default?: Environment;
@@ -169,7 +215,35 @@ export interface InterchangeableModuleRecord {
169
215
  };
170
216
  }
171
217
  export interface HooksPlugin {
172
- initConfigs(lwrConfig: NormalizedLwrGlobalConfig, dataConfig: GlobalData, runtimeConfig: RuntimeEnvironment): Promise<void> | void;
218
+ /**
219
+ * Programmatically modify application and runtime configurations.
220
+ *
221
+ * @remarks
222
+ * These hooks are invoked both at build time and runtime for Express and Koa(not MRT).
223
+ *
224
+ * During server build, config hooks are invoked prior to static site generation
225
+ * and server bundling.
226
+ *
227
+ * For the `createServer`(ie. Express/Koa) runtime, these config hooks are invoked before all other hooks
228
+ * during server context initialization
229
+ *
230
+ * For the `createHandler`(ie. MRT Serverless Express) runtime, these config hooks are NOT invoked. This runtime does
231
+ * not support asynchronous execution during initialization. These hooks MUST be ran during
232
+ * the server build.
233
+ *
234
+ */
235
+ initConfigs?: (lwrConfig: NormalizedLwrGlobalConfig, dataConfig: GlobalData, runtimeConfig: RuntimeEnvironment) => Promise<void> | void;
236
+ /**
237
+ * Load routes on application start up.
238
+ *
239
+ * @remarks
240
+ * These hooks are invoked ONLY at runtime.
241
+ *
242
+ * For the `createServer` runtime, these hooks are invoked AFTER config hooks.
243
+ *
244
+ * For the `createHandler` runtime, these hooks are invoked during server context initialization.
245
+ */
246
+ onStart?: (routes: LwrRoute[]) => void;
173
247
  }
174
248
  export {};
175
249
  //# sourceMappingURL=config.d.ts.map
package/build/index.d.ts CHANGED
@@ -2,10 +2,11 @@
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
4
  /// <reference types="node" />
5
+ import type { WatchOptions } from 'chokidar';
5
6
  import { EventEmitter } from 'events';
6
7
  import fs from 'fs';
7
8
  import { Readable } from 'stream';
8
- 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';
9
10
  import { AssetReference, CompiledView, PublicViewRegistry, ViewProvider, ViewRegistry, ViewTransformPlugin } from './views.js';
10
11
  export * from './lwr-shim.js';
11
12
  export * from './config.js';
@@ -76,6 +77,7 @@ interface BaseModuleEntry {
76
77
  specifier: Specifier;
77
78
  version: Version;
78
79
  interchangeable?: boolean;
80
+ src?: string;
79
81
  }
80
82
  export interface FsModuleEntry extends BaseModuleEntry {
81
83
  virtual?: false;
@@ -162,8 +164,11 @@ export interface ServerModeConfig {
162
164
  };
163
165
  featureFlags: FeatureFlags;
164
166
  }
165
- export interface FeatureFlags {
166
- LEGACY_LOADER: boolean;
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;
167
172
  }
168
173
  export interface RuntimeEnvironment extends ServerModeConfig {
169
174
  apiVersion: string;
@@ -190,6 +195,7 @@ export interface ResourceIdentity {
190
195
  export interface AssetIdentity {
191
196
  assetId: AssetIdentifier;
192
197
  signature: string;
198
+ immutable: boolean;
193
199
  }
194
200
  export interface RuntimeContext {
195
201
  runtimeEnvironment: RuntimeEnvironment;
@@ -199,6 +205,11 @@ export interface BootstrapRuntimeEnvironment extends RuntimeEnvironment {
199
205
  bootstrapImports?: string[];
200
206
  bootstrapDynamicImports?: string[];
201
207
  }
208
+ export type { WatchOptions } from 'chokidar';
209
+ export interface WatcherFactory {
210
+ createFileWatcher(options?: WatchOptions): Watcher;
211
+ setupWatcher(onModuleChange: Function): Watcher;
212
+ }
202
213
  export interface Watcher extends EventEmitter {
203
214
  add(paths: string | ReadonlyArray<string>): void;
204
215
  unwatch(paths: string | ReadonlyArray<string>): void;
@@ -252,7 +263,7 @@ export interface ModuleProvider {
252
263
  }
253
264
  export declare type LwrService = ModuleProvider | ResourceProvider | ViewProvider | AssetProvider | HooksPlugin | AssetTransformPlugin | ViewTransformPlugin;
254
265
  export interface ServiceCtor<T extends LwrService, R extends Record<string, Json> = {}> {
255
- new (moduleProviderConfig: R, serviceProviderConfig?: any, ...args: any[]): T;
266
+ new (providerConfig: R, serviceProviderConfig?: any, ...args: any[]): T;
256
267
  }
257
268
  export interface ModuleRegistry {
258
269
  name: string;
@@ -260,14 +271,22 @@ export interface ModuleRegistry {
260
271
  getLinkedModule<T extends AbstractModuleId>(moduleId: T, runtimeEnvironment: RuntimeEnvironment, runtimeParams?: RuntimeParams): Promise<LinkedModuleDefinition>;
261
272
  getModule<T extends AbstractModuleId>(moduleId: T, runtimeParams?: RuntimeParams): Promise<ModuleDefinition>;
262
273
  getModuleEntry(moduleId: AbstractModuleId, runtimeParams?: RuntimeParams): Promise<ModuleEntry>;
263
- resolveModuleUri<R extends RuntimeEnvironment, S extends string | undefined>(moduleId: Required<Pick<ModuleId, 'specifier' | 'version'>>, runtimeEnvironment: R, runtimeParams?: RuntimeParams, signature?: S): S extends string ? string : Promise<string>;
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;
264
276
  getPublicApi(): PublicModuleRegistry;
265
277
  }
266
- 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
+ }
267
283
  export interface ModuleBundler {
268
- getModuleBundle<T extends AbstractModuleId, R extends RuntimeEnvironment>(moduleId: T, runtimeEnvironment: R, runtimeParams?: RuntimeParams, bundleConfigOverrides?: BundleConfig): Promise<BundleDefinition>;
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;
269
288
  }
270
- export declare type PublicModuleBundler = Pick<ModuleBundler, 'getModuleBundle'>;
289
+ export declare type PublicModuleBundler = Pick<ModuleBundler, 'getModuleBundle' | 'resolveModuleUri'>;
271
290
  export interface BundleRecord {
272
291
  imports?: BaseModuleReference[];
273
292
  dynamicImports?: BaseDynamicModuleReference[];
@@ -278,6 +297,7 @@ export interface BundleDefinition extends ModuleId {
278
297
  config: BundleConfig;
279
298
  map?: any;
280
299
  bundleRecord: BundleRecord;
300
+ src?: string;
281
301
  }
282
302
  export interface ProviderAppConfig {
283
303
  modules: ResolverModuleRecord[];
@@ -292,9 +312,10 @@ export interface ProviderAppConfig {
292
312
  amdLoader: string;
293
313
  esmLoader: string;
294
314
  environment?: EnvironmentConfig;
315
+ bundleConfig: BundleConfig;
316
+ assets: AssetConfig[];
295
317
  }
296
318
  export interface ProviderContext {
297
- compiler: Compiler;
298
319
  appObserver: Pick<LwrAppObserver, 'onModuleDefinitionChange' | 'onModuleSourceChange' | 'onAssetSourceChange' | 'onViewSourceChange'>;
299
320
  appEmitter: Pick<LwrAppEmitter, 'notifyModuleDefinitionChanged' | 'notifyAssetSourceChanged' | 'notifyModuleSourceChanged' | 'notifyViewSourceChanged'>;
300
321
  moduleRegistry: PublicModuleRegistry;
@@ -304,6 +325,8 @@ export interface ProviderContext {
304
325
  assetRegistry: PublicAssetRegistry;
305
326
  config: ProviderAppConfig;
306
327
  runtimeEnvironment: RuntimeEnvironment;
328
+ watcherFactory?: WatcherFactory;
329
+ siteMetadata?: SiteMetadata;
307
330
  }
308
331
  export interface ResourceIdentifier {
309
332
  specifier: string;
@@ -318,8 +341,9 @@ export interface AssetUri {
318
341
  uri: string;
319
342
  immutable: boolean;
320
343
  entry: string;
344
+ external?: boolean;
321
345
  }
322
- 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;
323
347
  export interface ResourceDefinition {
324
348
  specifier?: string;
325
349
  type: ResourceType;
@@ -329,7 +353,7 @@ export interface ResourceDefinition {
329
353
  defer?: boolean;
330
354
  nonce?: string;
331
355
  content?: string;
332
- stream?: Readable;
356
+ stream?: () => Readable;
333
357
  isPreload?: boolean;
334
358
  }
335
359
  export interface AssetMetadata {
@@ -343,6 +367,8 @@ export interface AssetSource {
343
367
  content: (encoding?: BufferEncoding) => string | Buffer;
344
368
  uri?: string;
345
369
  metadata?: AssetMetadata;
370
+ type?: AssetType;
371
+ noTransform?: boolean;
346
372
  }
347
373
  export declare type AssetType = 'asset' | 'content-asset' | 'external' | 'unknown';
348
374
  export interface AssetDefinition extends AssetSource {
@@ -357,7 +383,7 @@ export interface ResourceProvider {
357
383
  }
358
384
  export interface AssetProvider {
359
385
  name: string;
360
- getAsset(fileAssetPath: string): Promise<AssetSource | undefined>;
386
+ getAsset(assetIdentifier: AssetIdentifier): Promise<AssetSource | undefined>;
361
387
  }
362
388
  export declare type TransformPluginContext = Record<string, any>;
363
389
  declare type AssetPluginTransformHook = (code: string | Buffer, assetSource: AssetSource, context?: TransformPluginContext) => Promise<AssetPluginTransformHookReturn>;
@@ -401,7 +427,7 @@ export interface AssetRegistry {
401
427
  getPublicApi(): PublicAssetRegistry;
402
428
  }
403
429
  export declare type PublicAssetRegistry = Pick<AssetRegistry, 'getAsset' | 'resolveAssetUri'>;
404
- export interface CompilerConfig {
430
+ export interface LwcCompilerConfig {
405
431
  name: string;
406
432
  namespace?: string;
407
433
  filename: string;
@@ -435,22 +461,6 @@ export interface CompilerResult {
435
461
  export interface BundleFiles {
436
462
  [filename: string]: string;
437
463
  }
438
- export interface Compiler {
439
- convertToAmd(source: string, { id }: {
440
- id: string;
441
- }): Promise<CompilerResult>;
442
- getModuleMetadata(compiledSource: string): Promise<Partial<CompiledMetadata>>;
443
- lockerize(compiledModule: ModuleCompiled, lockerConfig: LwrLockerConfig, sourcemap: boolean): CompilerResult;
444
- minifyJavascript(source: string): Promise<CompilerResult>;
445
- parseJavascript(source: string, options: ParseOptions): Promise<CompilerResult>;
446
- minifyCSS(source: string): Promise<CompilerResult>;
447
- }
448
- export interface ParseOptions {
449
- envMode: string;
450
- }
451
- export interface CompilerContext {
452
- runtimeEnvironment: RuntimeEnvironment;
453
- }
454
464
  export interface ClientBootstrapConfig {
455
465
  appId?: string;
456
466
  bootstrapModule: string;
@@ -493,14 +503,16 @@ export interface MetricsConfig {
493
503
  export interface ServerContext {
494
504
  appObserver: LwrAppObserver;
495
505
  appEmitter: LwrAppEmitter;
496
- compiler: Compiler;
497
506
  moduleRegistry: ModuleRegistry;
498
507
  moduleBundler: ModuleBundler;
499
508
  viewRegistry: ViewRegistry;
500
509
  resourceRegistry: ResourceRegistry;
501
510
  assetRegistry: AssetRegistry;
511
+ watcherFactory?: WatcherFactory;
512
+ siteMetadata?: SiteMetadata;
502
513
  appConfig: NormalizedLwrGlobalConfig;
503
514
  runtimeEnvironment: RuntimeEnvironment;
515
+ routeHandlers: RouteHandlers;
504
516
  }
505
517
  export interface Observer<V> {
506
518
  next: (value: V) => void;
@@ -577,4 +589,46 @@ export interface LwrStringBuilder {
577
589
  toString(): string;
578
590
  original: string;
579
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
+ }
580
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 {
@@ -60,6 +60,9 @@ export interface MiddlewareRequest {
60
60
  acceptsLanguages(): string[];
61
61
  get(field: string): string | undefined;
62
62
  cookie(name: string): string | undefined;
63
+ /**
64
+ * Return true if the request has a `json` query parameter
65
+ */
63
66
  hasJsonParam(): boolean;
64
67
  /**
65
68
  * Return JSON if:
@@ -67,20 +70,27 @@ export interface MiddlewareRequest {
67
70
  * - the Accept header explicitly requests "application/json"
68
71
  */
69
72
  isJsonRequest(): boolean;
73
+ /**
74
+ * Return true if the request was initiated by static generation
75
+ */
76
+ isSiteGeneration(): boolean;
70
77
  /**
71
78
  * Return false when both Accept and JSON query param are applied, but do not semantically match
72
79
  */
73
80
  validateJsonRequest(): boolean;
74
81
  /**
75
- * Use the Express Request parameters to create a Module/Resource Identifier and RuntimeEnvironment
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)
76
87
  */
77
88
  getRuntimeContext(defaultRuntimeEnvironment: RuntimeEnvironment): RuntimeContext;
78
- isSiteGeneration(): boolean;
79
89
  }
80
90
  export interface MiddlewareResponse {
81
91
  set(header: any): void;
82
92
  setHeader(name: string, value: string | string[]): void;
83
- setMetadata(metadata: any): void;
93
+ setSiteGenerationMetadata(metadata: any): void;
84
94
  status(status: number): MiddlewareResponse;
85
95
  send(object: any): void;
86
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 | {
@@ -182,6 +184,11 @@ export interface ViewRegistry {
182
184
  getPublicApi(): PublicViewRegistry;
183
185
  }
184
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
+ }
185
192
  export interface SsrRequestContext {
186
193
  props: Json;
187
194
  params: {
@@ -202,6 +209,7 @@ export interface PageDataResponse {
202
209
  fetchpriority?: 'high' | 'low' | 'auto';
203
210
  }[];
204
211
  };
212
+ cache?: CacheResponse;
205
213
  }
206
214
  export {};
207
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.9-alpha.8",
11
+ "version": "0.10.0-alpha.1",
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": ">=14.15.4 <19"
30
+ "node": ">=16.0.0 <20"
28
31
  },
29
- "gitHead": "ac15f9c862f53f0fab34ea229c8c27b1d66c9f7e"
32
+ "gitHead": "2683dd5839b4da2ed93d42874cfceb78cbb5bf0d"
30
33
  }