@lwrjs/types 0.11.0-alpha.1 → 0.11.0-alpha.11

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,30 +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;
39
- mixedMode: 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[];
40
49
  module: string | undefined;
41
- preloadModules: string[];
42
50
  }
43
- export type LwrAppBootstrapConfig = Partial<NormalizedLwrAppBootstrapConfig>;
44
51
  export interface LwrLockerConfig {
45
52
  enabled: boolean;
46
53
  trustedComponents?: string[];
47
54
  clientOnly?: boolean;
48
55
  }
49
56
  export interface RouteHandlersConfig {
50
- [id: string]: ServiceConfig;
57
+ [id: string]: string | null;
51
58
  }
52
59
  export interface NormalizedRouteHandlersConfig {
53
- [id: string]: ServiceEntry;
60
+ [id: string]: string | null;
54
61
  }
55
62
  export interface LocalizedViewRequest extends ViewRequest {
56
63
  locale?: string;
@@ -107,11 +114,12 @@ export interface LwrGlobalConfig {
107
114
  staticSiteGenerator?: StaticSiteGenerator;
108
115
  locker?: LwrLockerConfig;
109
116
  uriTransformers?: ServiceConfig[];
117
+ i18n?: I18NConfig;
110
118
  }
111
119
  type RequiredPick<T, K extends keyof T> = {
112
120
  [P in K]-?: T[P];
113
121
  };
114
- export type OnStartConfig = RequiredPick<LwrGlobalConfig, 'routes' | 'basePath'>;
122
+ export type OnStartConfig = RequiredPick<LwrGlobalConfig, 'basePath' | 'i18n' | 'routes'>;
115
123
  export interface BuildOptions {
116
124
  target?: string;
117
125
  input?: string;
@@ -140,10 +148,10 @@ export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig
140
148
  assetTransformers: ServiceEntry[];
141
149
  uriTransformers: ServiceEntry[];
142
150
  lwc: NormalizedLwcConfig;
151
+ i18n: I18NConfig;
143
152
  }
144
153
  export interface StaticSiteGenerator {
145
154
  outputDir?: string;
146
- locales?: string[];
147
155
  skipCleanOutputDir?: boolean;
148
156
  skipBaseDocumentGeneration?: boolean;
149
157
  _additionalRoutePaths?: string[];
@@ -169,7 +177,7 @@ export interface Services {
169
177
  uriTransformers: ResolvedServiceEntry<UriTransformPlugin>[];
170
178
  }
171
179
  export interface RouteHandlers {
172
- [id: string]: [RouteHandlerFunction, any?];
180
+ [id: string]: RouteHandlerFunction;
173
181
  }
174
182
  interface AssetConfigCommon {
175
183
  urlPath?: string;
@@ -276,6 +284,13 @@ export interface HooksPlugin {
276
284
  }
277
285
  export interface Locale {
278
286
  id: string;
287
+ fallback?: string;
288
+ }
289
+ export interface I18NConfig {
290
+ defaultLocale: string;
291
+ locales: Locale[];
292
+ uriPattern?: UriPattern;
279
293
  }
294
+ export type UriPattern = undefined | 'path-prefix' | 'query-param';
280
295
  export {};
281
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';
@@ -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,9 +44,12 @@ export interface CustomElementReference {
44
44
  export interface RenderedViewMetadata {
45
45
  customElements: CustomElementReference[];
46
46
  assetReferences: AssetReference[];
47
- ssrProps?: {
47
+ serverData?: {
48
48
  [prop: string]: Json;
49
49
  };
50
+ serverDebug?: {
51
+ message?: string;
52
+ };
50
53
  }
51
54
  export interface RenderedAssetReference {
52
55
  url: string;
@@ -171,6 +174,8 @@ export interface ViewPageContext {
171
174
  id: string;
172
175
  title?: string;
173
176
  url: string;
177
+ basePath?: string;
178
+ locale?: string;
174
179
  }
175
180
  export type ViewModuleResourceContext = {
176
181
  isPreload?: boolean;
@@ -194,16 +199,18 @@ export interface ViewHandler {
194
199
  }
195
200
  export interface SsrRequestContext {
196
201
  props: Json;
202
+ url: string;
197
203
  params: {
198
204
  [key: string]: string;
199
205
  };
200
- query: {
201
- [key: string]: string;
202
- };
206
+ query: ViewRequestQs;
203
207
  locale: string;
208
+ basePath: string;
204
209
  }
205
- export interface PageDataResponse {
206
- props?: Json;
210
+ export interface SsrDataResponse {
211
+ props?: {
212
+ [prop: string]: Json;
213
+ };
207
214
  markup?: {
208
215
  links?: {
209
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.1",
11
+ "version": "0.11.0-alpha.11",
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": "6a840d4694fac9f0be5c3a21707015379cbadad7"
32
+ "gitHead": "acb9df6ee7887b683e28ad43e00df311256d6018"
33
33
  }