@lwrjs/types 0.11.0-alpha.0 → 0.11.0-alpha.10

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
@@ -2,7 +2,7 @@ import type { AssetProvider, AssetTransformPlugin, BundleProvider, CacheResponse
2
2
  export interface View {
3
3
  id: string;
4
4
  rootComponent?: string;
5
- contentTemplate?: string;
5
+ contentTemplate?: string | Record<string, string>;
6
6
  layoutTemplate?: string;
7
7
  bootstrap?: LwrAppBootstrapConfig;
8
8
  }
@@ -27,29 +27,37 @@ export interface NormalizedLwrErrorRoute extends LwrErrorRoute {
27
27
  bootstrap: NormalizedLwrAppBootstrapConfig;
28
28
  routeHandler?: ServiceEntry;
29
29
  }
30
- export interface NormalizedLwrAppBootstrapConfig {
31
- autoBoot: boolean;
32
- syntheticShadow: boolean;
33
- workers: {
30
+ export interface BootstrapService {
31
+ name: string;
32
+ ssr: boolean;
33
+ }
34
+ export interface LwrAppBootstrapConfig {
35
+ autoBoot?: boolean;
36
+ syntheticShadow?: boolean;
37
+ workers?: {
34
38
  [id: string]: string;
35
39
  };
36
- services: string[];
37
- configAsSrc: boolean;
38
- ssr: boolean;
40
+ services?: (string | BootstrapService)[];
41
+ configAsSrc?: boolean;
42
+ ssr?: boolean;
43
+ mixedMode?: boolean;
44
+ module?: string | undefined;
45
+ preloadModules?: string[];
46
+ }
47
+ export interface NormalizedLwrAppBootstrapConfig extends Required<Omit<LwrAppBootstrapConfig, 'module'>> {
48
+ services: BootstrapService[];
39
49
  module: string | undefined;
40
- preloadModules: string[];
41
50
  }
42
- export type LwrAppBootstrapConfig = Partial<NormalizedLwrAppBootstrapConfig>;
43
51
  export interface LwrLockerConfig {
44
52
  enabled: boolean;
45
53
  trustedComponents?: string[];
46
54
  clientOnly?: boolean;
47
55
  }
48
56
  export interface RouteHandlersConfig {
49
- [id: string]: ServiceConfig;
57
+ [id: string]: string | null;
50
58
  }
51
59
  export interface NormalizedRouteHandlersConfig {
52
- [id: string]: ServiceEntry;
60
+ [id: string]: string | null;
53
61
  }
54
62
  export interface LocalizedViewRequest extends ViewRequest {
55
63
  locale?: string;
@@ -106,7 +114,12 @@ export interface LwrGlobalConfig {
106
114
  staticSiteGenerator?: StaticSiteGenerator;
107
115
  locker?: LwrLockerConfig;
108
116
  uriTransformers?: ServiceConfig[];
117
+ i18n?: I18NConfig;
109
118
  }
119
+ type RequiredPick<T, K extends keyof T> = {
120
+ [P in K]-?: T[P];
121
+ };
122
+ export type OnStartConfig = RequiredPick<LwrGlobalConfig, 'basePath' | 'i18n' | 'routes'>;
110
123
  export interface BuildOptions {
111
124
  target?: string;
112
125
  input?: string;
@@ -135,10 +148,10 @@ export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig
135
148
  assetTransformers: ServiceEntry[];
136
149
  uriTransformers: ServiceEntry[];
137
150
  lwc: NormalizedLwcConfig;
151
+ i18n: I18NConfig;
138
152
  }
139
153
  export interface StaticSiteGenerator {
140
154
  outputDir?: string;
141
- locales?: string[];
142
155
  skipCleanOutputDir?: boolean;
143
156
  skipBaseDocumentGeneration?: boolean;
144
157
  _additionalRoutePaths?: string[];
@@ -164,7 +177,7 @@ export interface Services {
164
177
  uriTransformers: ResolvedServiceEntry<UriTransformPlugin>[];
165
178
  }
166
179
  export interface RouteHandlers {
167
- [id: string]: [RouteHandlerFunction, any?];
180
+ [id: string]: RouteHandlerFunction;
168
181
  }
169
182
  interface AssetConfigCommon {
170
183
  urlPath?: string;
@@ -258,7 +271,7 @@ export interface HooksPlugin {
258
271
  */
259
272
  initInstrumentation?: () => void;
260
273
  /**
261
- * Load routes on application start up.
274
+ * Set a subset of LWR Configuration at runtime. Works in mrt
262
275
  *
263
276
  * @remarks
264
277
  * These hooks are invoked ONLY at runtime.
@@ -267,7 +280,17 @@ export interface HooksPlugin {
267
280
  *
268
281
  * For the `createHandler` runtime, these hooks are invoked during server context initialization.
269
282
  */
270
- onStart?: (routes: LwrRoute[]) => void;
283
+ onStart?: (config: OnStartConfig) => void;
284
+ }
285
+ export interface Locale {
286
+ id: string;
287
+ fallback?: string;
288
+ }
289
+ export interface I18NConfig {
290
+ defaultLocale: string;
291
+ locales: Locale[];
292
+ uriPattern?: UriPattern;
271
293
  }
294
+ export type UriPattern = undefined | 'path-prefix' | 'query-param';
272
295
  export {};
273
296
  //# sourceMappingURL=config.d.ts.map
package/build/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import type { WatchOptions } from 'chokidar';
6
6
  import type { EventEmitter } from 'events';
7
7
  import type fs from 'fs';
8
8
  import type { Readable } from 'stream';
9
- import type { BundleConfig, EnvironmentConfig, HooksPlugin, LwrLockerConfig, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, ResolverModuleRecord, BundleConfigOverrides, RouteHandlers, AssetConfig } from './config.js';
9
+ import type { BundleConfig, EnvironmentConfig, HooksPlugin, LwrLockerConfig, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, ResolverModuleRecord, BundleConfigOverrides, RouteHandlers, AssetConfig, I18NConfig } from './config.js';
10
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';
@@ -139,7 +139,7 @@ export interface LinkedModuleDefinition extends ModuleDefinition {
139
139
  linkedModuleRecord: ModuleRecord;
140
140
  linkedConfig: LinkedModuleDefinitionConfig;
141
141
  runtimeEnvironment: RuntimeEnvironment;
142
- runtimeParams?: RuntimeParams;
142
+ runtimeParams: RuntimeParams;
143
143
  }
144
144
  export interface CodeSource {
145
145
  code: string;
@@ -165,11 +165,12 @@ export interface ServerModeConfig {
165
165
  };
166
166
  featureFlags: FeatureFlags;
167
167
  }
168
- export interface FeatureFlags extends Record<string, boolean | undefined> {
168
+ export interface FeatureFlags extends Record<string, boolean | string | undefined> {
169
169
  ASSETS_ON_LAMBDA?: boolean;
170
170
  LEGACY_LOADER?: boolean;
171
171
  SSR_SANDBOX_WORKER?: boolean;
172
172
  SSR_STATIC_BUNDLES?: boolean;
173
+ SSR_WITH_CSR_FALLBACK?: boolean;
173
174
  EXPERIMENTAL_UNVERSIONED_ALIASES?: boolean;
174
175
  }
175
176
  export interface RuntimeEnvironment extends ServerModeConfig {
@@ -178,11 +179,18 @@ export interface RuntimeEnvironment extends ServerModeConfig {
178
179
  debug: boolean;
179
180
  serverMode: string;
180
181
  basePath: string;
182
+ defaultAssetPath: string;
181
183
  }
182
184
  export interface SourceMapRuntimeEnvironment extends RuntimeEnvironment {
183
185
  sourceMapUrl?: string;
184
186
  }
185
187
  export type RuntimeParams = Record<string, string | number | boolean | null | undefined | Record<string, string>>;
188
+ export interface EnvironmentContext {
189
+ basePath: string;
190
+ locale: string;
191
+ assetBasePath: string;
192
+ uiBasePath: string;
193
+ }
186
194
  export interface ModuleIdentity {
187
195
  signature: string;
188
196
  moduleId: AbstractModuleId;
@@ -317,6 +325,7 @@ export interface ProviderAppConfig {
317
325
  environment?: EnvironmentConfig;
318
326
  bundleConfig: BundleConfig;
319
327
  assets: AssetConfig[];
328
+ i18n: I18NConfig;
320
329
  }
321
330
  export interface ProviderContext {
322
331
  appObserver: Pick<LwrAppObserver, 'onModuleDefinitionChange' | 'onModuleSourceChange' | 'onAssetSourceChange' | 'onViewSourceChange'>;
@@ -487,7 +496,7 @@ export interface ClientBootstrapConfig {
487
496
  preloadModules?: string[];
488
497
  rootComponent?: string;
489
498
  rootComponents?: string[];
490
- ssrProps?: Json;
499
+ serverData?: Json;
491
500
  customInit?: Function;
492
501
  onError?: Function;
493
502
  baseUrl?: string;
@@ -616,10 +625,18 @@ export interface SiteMetadata {
616
625
  * Get the current metadata about the pre-built module bundles for the site.
617
626
  */
618
627
  getSiteBundles(): SiteBundles;
628
+ /**
629
+ * Get the current debug metadata about the pre-built module bundles for the site.
630
+ */
631
+ getDebugSiteBundles(): SiteBundles;
619
632
  /**
620
633
  * Get the current metadata about the pre-built resources for the site.
621
634
  */
622
635
  getSiteResources(): SiteResources;
636
+ /**
637
+ * Get the current debug metadata about the pre-built resources for the site.
638
+ */
639
+ getDebugSiteResources(): SiteResources;
623
640
  /**
624
641
  * Get the current metadata about the pre-built assets for the site.
625
642
  */
package/build/server.d.ts CHANGED
@@ -4,7 +4,7 @@ import type { Application as ExpressApp } from 'express';
4
4
  import type { default as Koa, Context } from 'koa';
5
5
  import type http from 'http';
6
6
  import type { Readable } from 'stream';
7
- import type { NormalizedLwrGlobalConfig, RuntimeContext, RuntimeEnvironment } from './index.js';
7
+ import type { I18NConfig, NormalizedLwrGlobalConfig, RuntimeContext, RuntimeEnvironment } from './index.js';
8
8
  export type ServerTypes = 'koa' | 'express' | 'fs';
9
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 {
@@ -32,7 +32,6 @@ export interface InternalAppServer<T extends ServerTypes> {
32
32
  get(path: string | Array<string>, middleware: MiddlewareFunction): void;
33
33
  post(path: string | Array<string>, middleware: MiddlewareFunction): void;
34
34
  initRoutes(): void;
35
- useCompression(): void;
36
35
  getRegexWildcard(): string;
37
36
  }
38
37
  export type PublicAppServer<T extends ServerTypes> = Pick<InternalAppServer<T>, 'use' | 'all' | 'get' | 'post' | 'getRegexWildcard'>;
@@ -57,6 +56,7 @@ export interface MiddlewareRequest {
57
56
  headers: Headers;
58
57
  protocol: string;
59
58
  locale: string;
59
+ basePath: string;
60
60
  acceptsLanguages(): string[];
61
61
  get(field: string): string | undefined;
62
62
  cookie(name: string): string | undefined;
@@ -85,7 +85,7 @@ export interface MiddlewareRequest {
85
85
  /**
86
86
  * Use the request parameters to resolve the runtime context(ie. environment and parameters)
87
87
  */
88
- getRuntimeContext(defaultRuntimeEnvironment: RuntimeEnvironment): RuntimeContext;
88
+ getRuntimeContext(defaultRuntimeEnvironment: RuntimeEnvironment, i18n: I18NConfig): RuntimeContext;
89
89
  }
90
90
  export interface MiddlewareResponse {
91
91
  set(header: any): void;
package/build/views.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { LwrErrorRoute, LwrRoute, RouteHandlerFunction, RouteHandlerView, View } from './config.js';
3
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'>;
4
+ export type ViewIdentity = Pick<View, 'id' | 'rootComponent' | 'contentTemplate'>;
5
5
  export interface ViewSource {
6
6
  name: string;
7
7
  slug: string;
@@ -44,6 +44,12 @@ export interface CustomElementReference {
44
44
  export interface RenderedViewMetadata {
45
45
  customElements: CustomElementReference[];
46
46
  assetReferences: AssetReference[];
47
+ serverData?: {
48
+ [prop: string]: Json;
49
+ };
50
+ serverDebug?: {
51
+ message?: string;
52
+ };
47
53
  }
48
54
  export interface RenderedAssetReference {
49
55
  url: string;
@@ -156,6 +162,7 @@ export interface ViewInfo {
156
162
  id: string;
157
163
  url: string;
158
164
  configAsSrc: boolean;
165
+ mixedMode: boolean;
159
166
  }
160
167
  export interface RenderOptions {
161
168
  skipMetadataCollection?: boolean;
@@ -167,6 +174,8 @@ export interface ViewPageContext {
167
174
  id: string;
168
175
  title?: string;
169
176
  url: string;
177
+ basePath?: string;
178
+ locale?: string;
170
179
  }
171
180
  export type ViewModuleResourceContext = {
172
181
  isPreload?: boolean;
@@ -190,16 +199,18 @@ export interface ViewHandler {
190
199
  }
191
200
  export interface SsrRequestContext {
192
201
  props: Json;
202
+ url: string;
193
203
  params: {
194
204
  [key: string]: string;
195
205
  };
196
- query: {
197
- [key: string]: string;
198
- };
206
+ query: ViewRequestQs;
199
207
  locale: string;
208
+ basePath: string;
200
209
  }
201
- export interface PageDataResponse {
202
- props?: Json;
210
+ export interface SsrDataResponse {
211
+ props?: {
212
+ [prop: string]: Json;
213
+ };
203
214
  markup?: {
204
215
  links?: {
205
216
  href: string;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "build": "tsc -b"
9
9
  },
10
10
  "type": "module",
11
- "version": "0.11.0-alpha.0",
11
+ "version": "0.11.0-alpha.10",
12
12
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
13
13
  "repository": {
14
14
  "type": "git",
@@ -29,5 +29,5 @@
29
29
  "engines": {
30
30
  "node": ">=16.0.0"
31
31
  },
32
- "gitHead": "6917abefe32752eeed0f9ba98505ca2b76f1df9d"
32
+ "gitHead": "34b1e289e8de12531f5624b64512e870157195d4"
33
33
  }