@lwrjs/types 0.9.0-alpha.14 → 0.9.0-alpha.16

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 { AssetProvider, AssetTransformPlugin, CacheResponse, LwrService, ModuleProvider, RenderOptions, ResourceProvider, RouteHandlerViewResponse, RuntimeEnvironment, ServerTypes, ServiceCtor, Specifier, ViewParams, ViewProvider, ViewRequest, ViewResponse, ViewTransformPlugin } 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;
@@ -121,12 +121,14 @@ export interface ServerBuild {
121
121
  appConfig: NormalizedLwrGlobalConfig;
122
122
  runtimeEnvironment: RuntimeEnvironment;
123
123
  globalData: GlobalData;
124
+ hooks: HooksPlugin[];
124
125
  services: Services;
125
126
  routes: Route<NormalizedLwrRoute>[];
126
127
  errorRoutes: Route<NormalizedLwrErrorRoute>[];
127
128
  }
128
129
  export interface Services {
129
130
  moduleProviders: ResolvedServiceEntry<ModuleProvider>[];
131
+ bundleProviders: ResolvedServiceEntry<BundleProvider>[];
130
132
  viewProviders: ResolvedServiceEntry<ViewProvider>[];
131
133
  viewTransformers: ResolvedServiceEntry<ViewTransformPlugin>[];
132
134
  resourceProviders: ResolvedServiceEntry<ResourceProvider>[];
@@ -165,6 +167,9 @@ export interface BundleConfig {
165
167
  external?: Record<string, string>;
166
168
  alias?: Record<string, string>;
167
169
  }
170
+ export interface BundleConfigOverrides extends BundleConfig {
171
+ appendExcludes?: boolean;
172
+ }
168
173
  export declare type Environment = string;
169
174
  export interface EnvironmentConfig {
170
175
  default?: Environment;
@@ -191,7 +196,35 @@ export interface InterchangeableModuleRecord {
191
196
  };
192
197
  }
193
198
  export interface HooksPlugin {
194
- initConfigs(lwrConfig: NormalizedLwrGlobalConfig, dataConfig: GlobalData, runtimeConfig: RuntimeEnvironment): Promise<void> | void;
199
+ /**
200
+ * Programmatically modify application and runtime configurations.
201
+ *
202
+ * @remarks
203
+ * These hooks are invoked both at build time and runtime for Express and Koa(not MRT).
204
+ *
205
+ * During server build, config hooks are invoked prior to static site generation
206
+ * and server bundling.
207
+ *
208
+ * For the `createServer`(ie. Express/Koa) runtime, these config hooks are invoked before all other hooks
209
+ * during server context initialization
210
+ *
211
+ * For the `createHandler`(ie. MRT Serverless Express) runtime, these config hooks are NOT invoked. This runtime does
212
+ * not support asynchronous execution during initialization. These hooks MUST be ran during
213
+ * the server build.
214
+ *
215
+ */
216
+ initConfigs?: (lwrConfig: NormalizedLwrGlobalConfig, dataConfig: GlobalData, runtimeConfig: RuntimeEnvironment) => Promise<void> | void;
217
+ /**
218
+ * Load routes on application start up.
219
+ *
220
+ * @remarks
221
+ * These hooks are invoked ONLY at runtime.
222
+ *
223
+ * For the `createServer` runtime, these hooks are invoked AFTER config hooks.
224
+ *
225
+ * For the `createHandler` runtime, these hooks are invoked during server context initialization.
226
+ */
227
+ onStart?: (routes: LwrRoute[]) => void;
195
228
  }
196
229
  export {};
197
230
  //# sourceMappingURL=config.d.ts.map
package/build/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import type { WatchOptions } from 'chokidar';
6
6
  import { EventEmitter } from 'events';
7
7
  import fs from 'fs';
8
8
  import { Readable } from 'stream';
9
- import { BundleConfig, EnvironmentConfig, HooksPlugin, LwrLockerConfig, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, ResolverModuleRecord } from './config.js';
9
+ import { BundleConfig, EnvironmentConfig, HooksPlugin, LwrLockerConfig, LwrRoute, LwrErrorRoute, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, ResolverModuleRecord, Route, BundleConfigOverrides } from './config.js';
10
10
  import { AssetReference, CompiledView, PublicViewRegistry, ViewProvider, ViewRegistry, ViewTransformPlugin } from './views.js';
11
11
  export * from './lwr-shim.js';
12
12
  export * from './config.js';
@@ -271,15 +271,16 @@ export interface ModuleRegistry {
271
271
  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>;
272
272
  getPublicApi(): PublicModuleRegistry;
273
273
  }
274
- export declare type PublicModuleRegistry = Pick<ModuleRegistry, 'getModule' | 'getModuleEntry' | 'resolveModuleUri'>;
274
+ export declare type PublicModuleRegistry = Pick<ModuleRegistry, 'getModule' | 'getModuleEntry' | 'getLinkedModule' | 'resolveModuleUri'>;
275
275
  export interface BundleProvider {
276
276
  name: string;
277
277
  bundle<T extends AbstractModuleId, R extends RuntimeEnvironment>(moduleId: T, runtimeEnvironment: R, runtimeParams: RuntimeParams, configOverrides?: BundleConfig): Promise<BundleDefinition | undefined>;
278
278
  }
279
279
  export interface ModuleBundler {
280
280
  addBundleProviders(providers: BundleProvider[]): void;
281
- getModuleBundle<T extends AbstractModuleId, R extends RuntimeEnvironment>(moduleId: T, runtimeEnvironment: R, runtimeParams?: RuntimeParams, bundleConfigOverrides?: BundleConfig): Promise<BundleDefinition>;
282
- 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>;
281
+ getModuleBundle<T extends AbstractModuleId, R extends RuntimeEnvironment>(moduleId: T, runtimeEnvironment: R, runtimeParams?: RuntimeParams, bundleConfigOverrides?: BundleConfigOverrides): Promise<BundleDefinition>;
282
+ resolveModuleUri(moduleId: Required<Pick<ModuleId, 'specifier' | 'version'>>, runtimeEnvironment: RuntimeEnvironment, runtimeParams?: RuntimeParams, signature?: string): Promise<string>;
283
+ getPublicApi(): PublicModuleBundler;
283
284
  }
284
285
  export declare type PublicModuleBundler = Pick<ModuleBundler, 'getModuleBundle' | 'resolveModuleUri'>;
285
286
  export interface BundleRecord {
@@ -292,6 +293,7 @@ export interface BundleDefinition extends ModuleId {
292
293
  config: BundleConfig;
293
294
  map?: any;
294
295
  bundleRecord: BundleRecord;
296
+ src?: string;
295
297
  }
296
298
  export interface ProviderAppConfig {
297
299
  modules: ResolverModuleRecord[];
@@ -319,6 +321,7 @@ export interface ProviderContext {
319
321
  config: ProviderAppConfig;
320
322
  runtimeEnvironment: RuntimeEnvironment;
321
323
  watcherFactory?: WatcherFactory;
324
+ siteMetadata?: SiteMetadata;
322
325
  }
323
326
  export interface ResourceIdentifier {
324
327
  specifier: string;
@@ -334,7 +337,7 @@ export interface AssetUri {
334
337
  immutable: boolean;
335
338
  entry: string;
336
339
  }
337
- export declare type ResourceType = 'application/javascript' | 'application/json' | 'text/css' | 'lwr-importmap' | 'module';
340
+ export declare type ResourceType = 'application/javascript' | 'application/json' | 'text/css' | 'lwr-importmap' | 'module' | string;
338
341
  export interface ResourceDefinition {
339
342
  specifier?: string;
340
343
  type: ResourceType;
@@ -344,7 +347,7 @@ export interface ResourceDefinition {
344
347
  defer?: boolean;
345
348
  nonce?: string;
346
349
  content?: string;
347
- stream?: Readable;
350
+ stream?: () => Readable;
348
351
  isPreload?: boolean;
349
352
  }
350
353
  export interface AssetMetadata {
@@ -497,10 +500,12 @@ export interface ServerContext {
497
500
  viewRegistry: ViewRegistry;
498
501
  resourceRegistry: ResourceRegistry;
499
502
  assetRegistry: AssetRegistry;
500
- appConfig: NormalizedLwrGlobalConfig;
501
- runtimeEnvironment: RuntimeEnvironment;
502
503
  watcherFactory?: WatcherFactory;
503
504
  siteMetadata?: SiteMetadata;
505
+ appConfig: NormalizedLwrGlobalConfig;
506
+ runtimeEnvironment: RuntimeEnvironment;
507
+ routes: Route<LwrRoute>[];
508
+ errorRoutes: Route<LwrErrorRoute>[];
504
509
  }
505
510
  export interface Observer<V> {
506
511
  next: (value: V) => void;
@@ -578,6 +583,10 @@ export interface LwrStringBuilder {
578
583
  original: string;
579
584
  }
580
585
  export interface SiteMetadata {
586
+ /**
587
+ * Get the path that all site metadata is relative to
588
+ */
589
+ getSiteRootDir(): string;
581
590
  /**
582
591
  * Get the current metadata about the pre-built module bundles for the site.
583
592
  */
@@ -623,7 +632,7 @@ export interface SiteArtifact {
623
632
  export interface SiteBundle extends SiteArtifact {
624
633
  version?: Version;
625
634
  bundleRecord: {
626
- includedModules: string[];
635
+ includedModules?: string[];
627
636
  imports: string[];
628
637
  };
629
638
  }
package/package.json CHANGED
@@ -8,15 +8,15 @@
8
8
  "build": "tsc -b"
9
9
  },
10
10
  "type": "module",
11
- "version": "0.9.0-alpha.14",
11
+ "version": "0.9.0-alpha.16",
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": [
@@ -29,5 +29,9 @@
29
29
  "devDependencies": {
30
30
  "chokidar": "^3.5.3"
31
31
  },
32
- "gitHead": "64e0ba617151429da6e09f1a9686628f64183d25"
32
+ "volta": {
33
+ "node": "14.19.1",
34
+ "yarn": "1.22.19"
35
+ },
36
+ "gitHead": "03fe3982780e7c63b96ef0733b58529057db61fa"
33
37
  }