@lwrjs/types 0.10.0-alpha.8 → 0.10.0
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 +32 -8
- package/build/index.d.ts +51 -30
- package/build/lwr-shim.d.ts +1 -1
- package/build/server.d.ts +4 -4
- package/build/serviceAPI/loaderPlugins/loaderPlugins.d.ts +1 -1
- package/build/serviceAPI/serviceAPI.d.ts +3 -3
- package/build/views.d.ts +7 -8
- package/package.json +3 -3
package/build/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetProvider, AssetTransformPlugin, BundleProvider, CacheResponse, LwrService, ModuleProvider, RenderOptions, ResourceProvider, RouteHandlerViewResponse, RuntimeEnvironment, ServerTypes, ServiceCtor, Specifier, ViewParams, ViewProvider, ViewRequest, ViewResponse, ViewTransformPlugin } from './index';
|
|
1
|
+
import type { AssetProvider, AssetTransformPlugin, BundleProvider, CacheResponse, LwrService, ModuleProvider, RenderOptions, ResourceProvider, RouteHandlerViewResponse, RuntimeEnvironment, ServerTypes, ServiceCtor, Specifier, UriTransformPlugin, ViewParams, ViewProvider, ViewRequest, ViewResponse, ViewTransformPlugin } from './index';
|
|
2
2
|
export interface View {
|
|
3
3
|
id: string;
|
|
4
4
|
rootComponent?: string;
|
|
@@ -8,7 +8,7 @@ export interface View {
|
|
|
8
8
|
}
|
|
9
9
|
export interface LwrBaseRoute extends View {
|
|
10
10
|
properties?: Record<string, any>;
|
|
11
|
-
routeHandler?:
|
|
11
|
+
routeHandler?: ServiceConfig;
|
|
12
12
|
cache?: CacheResponse;
|
|
13
13
|
subRoutes?: string;
|
|
14
14
|
}
|
|
@@ -18,12 +18,14 @@ export interface LwrRoute extends LwrBaseRoute {
|
|
|
18
18
|
}
|
|
19
19
|
export interface NormalizedLwrRoute extends LwrRoute {
|
|
20
20
|
bootstrap: NormalizedLwrAppBootstrapConfig;
|
|
21
|
+
routeHandler?: ServiceEntry;
|
|
21
22
|
}
|
|
22
23
|
export interface LwrErrorRoute extends LwrBaseRoute {
|
|
23
24
|
status: 404 | 500;
|
|
24
25
|
}
|
|
25
26
|
export interface NormalizedLwrErrorRoute extends LwrErrorRoute {
|
|
26
27
|
bootstrap: NormalizedLwrAppBootstrapConfig;
|
|
28
|
+
routeHandler?: ServiceEntry;
|
|
27
29
|
}
|
|
28
30
|
export interface NormalizedLwrAppBootstrapConfig {
|
|
29
31
|
autoBoot: boolean;
|
|
@@ -44,12 +46,15 @@ export interface LwrLockerConfig {
|
|
|
44
46
|
clientOnly?: boolean;
|
|
45
47
|
}
|
|
46
48
|
export interface RouteHandlersConfig {
|
|
47
|
-
[id: string]:
|
|
49
|
+
[id: string]: ServiceConfig;
|
|
50
|
+
}
|
|
51
|
+
export interface NormalizedRouteHandlersConfig {
|
|
52
|
+
[id: string]: ServiceEntry;
|
|
48
53
|
}
|
|
49
54
|
export interface LocalizedViewRequest extends ViewRequest {
|
|
50
55
|
locale?: string;
|
|
51
56
|
}
|
|
52
|
-
export type RouteHandlerFunction = (viewRequest: LocalizedViewRequest, handlerContext: HandlerContext) => Promise<RouteHandlerViewResponse
|
|
57
|
+
export type RouteHandlerFunction = (viewRequest: LocalizedViewRequest, handlerContext: HandlerContext, routeHandlerOptions?: any) => Promise<RouteHandlerViewResponse> | RouteHandlerViewResponse;
|
|
53
58
|
export interface ResourcePaths {
|
|
54
59
|
rootDir: string;
|
|
55
60
|
assets: AssetConfig[];
|
|
@@ -59,7 +64,7 @@ export interface ResourcePaths {
|
|
|
59
64
|
export type RouteHandlerView = Pick<View, 'contentTemplate' | 'layoutTemplate' | 'rootComponent'>;
|
|
60
65
|
export interface RouteHandlerViewApi {
|
|
61
66
|
hasViewResponse(view: RouteHandlerView, viewParams?: ViewParams, renderOptions?: RenderOptions): boolean;
|
|
62
|
-
getViewResponse(view: RouteHandlerView, viewParams?: ViewParams, renderOptions?: RenderOptions): Promise<ViewResponse
|
|
67
|
+
getViewResponse(view: RouteHandlerView, viewParams?: ViewParams, renderOptions?: RenderOptions): Promise<ViewResponse>;
|
|
63
68
|
}
|
|
64
69
|
export interface HandlerContext extends ResourcePaths {
|
|
65
70
|
route: LwrRoute | LwrErrorRoute;
|
|
@@ -100,6 +105,7 @@ export interface LwrGlobalConfig {
|
|
|
100
105
|
serverType?: ServerTypes;
|
|
101
106
|
staticSiteGenerator?: StaticSiteGenerator;
|
|
102
107
|
locker?: LwrLockerConfig;
|
|
108
|
+
uriTransformers?: ServiceConfig[];
|
|
103
109
|
}
|
|
104
110
|
export interface BuildOptions {
|
|
105
111
|
target?: string;
|
|
@@ -114,6 +120,7 @@ export interface BuildOptions {
|
|
|
114
120
|
export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig, 'lwc'>> {
|
|
115
121
|
routes: NormalizedLwrRoute[];
|
|
116
122
|
errorRoutes: NormalizedLwrErrorRoute[];
|
|
123
|
+
routeHandlers: NormalizedRouteHandlersConfig;
|
|
117
124
|
assets: AssetConfig[];
|
|
118
125
|
lwrVersion: string;
|
|
119
126
|
amdLoader: string;
|
|
@@ -126,6 +133,7 @@ export interface NormalizedLwrGlobalConfig extends Required<Omit<LwrGlobalConfig
|
|
|
126
133
|
resourceProviders: ServiceEntry[];
|
|
127
134
|
assetProviders: ServiceEntry[];
|
|
128
135
|
assetTransformers: ServiceEntry[];
|
|
136
|
+
uriTransformers: ServiceEntry[];
|
|
129
137
|
lwc: NormalizedLwcConfig;
|
|
130
138
|
}
|
|
131
139
|
export interface StaticSiteGenerator {
|
|
@@ -153,21 +161,27 @@ export interface Services {
|
|
|
153
161
|
resourceProviders: ResolvedServiceEntry<ResourceProvider>[];
|
|
154
162
|
assetProviders: ResolvedServiceEntry<AssetProvider>[];
|
|
155
163
|
assetTransformers: ResolvedServiceEntry<AssetTransformPlugin>[];
|
|
164
|
+
uriTransformers: ResolvedServiceEntry<UriTransformPlugin>[];
|
|
156
165
|
}
|
|
157
166
|
export interface RouteHandlers {
|
|
158
|
-
[id: string]: RouteHandlerFunction;
|
|
167
|
+
[id: string]: [RouteHandlerFunction, any?];
|
|
159
168
|
}
|
|
160
169
|
interface AssetConfigCommon {
|
|
161
|
-
urlPath
|
|
170
|
+
urlPath?: string;
|
|
162
171
|
alias?: string;
|
|
163
172
|
}
|
|
164
173
|
export interface AssetDirConfig extends AssetConfigCommon {
|
|
165
174
|
dir: string;
|
|
175
|
+
root?: boolean;
|
|
176
|
+
}
|
|
177
|
+
export interface AssetRootDirConfig extends AssetDirConfig {
|
|
178
|
+
dir: string;
|
|
179
|
+
root: true;
|
|
166
180
|
}
|
|
167
181
|
export interface AssetFileConfig extends AssetConfigCommon {
|
|
168
182
|
file: string;
|
|
169
183
|
}
|
|
170
|
-
export type AssetConfig = AssetDirConfig | AssetFileConfig;
|
|
184
|
+
export type AssetConfig = AssetRootDirConfig | AssetDirConfig | AssetFileConfig;
|
|
171
185
|
export interface LwcConfig {
|
|
172
186
|
modules: ResolverModuleRecord[];
|
|
173
187
|
interchangeable?: string[];
|
|
@@ -185,10 +199,12 @@ export interface BundleConfig {
|
|
|
185
199
|
UNSAFE_lwrDefaultExclude?: string[];
|
|
186
200
|
external?: Record<string, string>;
|
|
187
201
|
alias?: Record<string, string>;
|
|
202
|
+
groups?: BundleGroups;
|
|
188
203
|
}
|
|
189
204
|
export interface BundleConfigOverrides extends BundleConfig {
|
|
190
205
|
appendExcludes?: boolean;
|
|
191
206
|
}
|
|
207
|
+
export type BundleGroups = Record<string, string[]>;
|
|
192
208
|
export type Environment = string;
|
|
193
209
|
export interface EnvironmentConfig {
|
|
194
210
|
default?: Environment;
|
|
@@ -233,6 +249,14 @@ export interface HooksPlugin {
|
|
|
233
249
|
*
|
|
234
250
|
*/
|
|
235
251
|
initConfigs?: (lwrConfig: NormalizedLwrGlobalConfig, dataConfig: GlobalData, runtimeConfig: RuntimeEnvironment) => Promise<void> | void;
|
|
252
|
+
/**
|
|
253
|
+
* Setup instrumentation utilities
|
|
254
|
+
*
|
|
255
|
+
* @remarks
|
|
256
|
+
* - When running LWR server, these hooks are invoked after `initConfigs` hooks and before `onStart` hooks
|
|
257
|
+
* - When running LWR handler, these hooks are invoked before config normalization and `onStart` hooks
|
|
258
|
+
*/
|
|
259
|
+
initInstrumentation?: () => void;
|
|
236
260
|
/**
|
|
237
261
|
* Load routes on application start up.
|
|
238
262
|
*
|
package/build/index.d.ts
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
/// <reference types="node" />
|
|
5
5
|
import type { WatchOptions } from 'chokidar';
|
|
6
|
-
import { EventEmitter } from 'events';
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import { Readable } from 'stream';
|
|
9
|
-
import { BundleConfig, EnvironmentConfig, HooksPlugin, LwrLockerConfig, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, ResolverModuleRecord, BundleConfigOverrides, RouteHandlers, AssetConfig } from './config.js';
|
|
10
|
-
import { AssetReference, CompiledView, PublicViewRegistry, ViewProvider, ViewRegistry, ViewTransformPlugin } from './views.js';
|
|
6
|
+
import type { EventEmitter } from 'events';
|
|
7
|
+
import type fs from 'fs';
|
|
8
|
+
import type { Readable } from 'stream';
|
|
9
|
+
import type { BundleConfig, EnvironmentConfig, HooksPlugin, LwrLockerConfig, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, ResolverModuleRecord, BundleConfigOverrides, RouteHandlers, AssetConfig } from './config.js';
|
|
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';
|
|
13
13
|
export * from './server.js';
|
|
@@ -111,6 +111,7 @@ export interface DynamicImportReference extends BaseDynamicModuleReference {
|
|
|
111
111
|
export interface ModuleRecord {
|
|
112
112
|
imports?: ImportModuleReference[];
|
|
113
113
|
dynamicImports?: DynamicImportReference[];
|
|
114
|
+
importMeta?: ImportMeta[];
|
|
114
115
|
}
|
|
115
116
|
export interface ChildHashObject {
|
|
116
117
|
[specifier: string]: string;
|
|
@@ -165,10 +166,11 @@ export interface ServerModeConfig {
|
|
|
165
166
|
featureFlags: FeatureFlags;
|
|
166
167
|
}
|
|
167
168
|
export interface FeatureFlags extends Record<string, boolean | undefined> {
|
|
169
|
+
ASSETS_ON_LAMBDA?: boolean;
|
|
168
170
|
LEGACY_LOADER?: boolean;
|
|
169
|
-
SSR_STATIC_BUNDLES?: boolean;
|
|
170
171
|
SSR_SANDBOX_WORKER?: boolean;
|
|
171
|
-
|
|
172
|
+
SSR_STATIC_BUNDLES?: boolean;
|
|
173
|
+
EXPERIMENTAL_UNVERSIONED_ALIASES?: boolean;
|
|
172
174
|
}
|
|
173
175
|
export interface RuntimeEnvironment extends ServerModeConfig {
|
|
174
176
|
apiVersion: string;
|
|
@@ -282,6 +284,7 @@ export interface BundleProvider {
|
|
|
282
284
|
}
|
|
283
285
|
export interface ModuleBundler {
|
|
284
286
|
addBundleProviders(providers: BundleProvider[]): void;
|
|
287
|
+
addBundleTransformers(transformers: UriTransformPlugin[]): void;
|
|
285
288
|
getModuleBundle<T extends AbstractModuleId, R extends RuntimeEnvironment>(moduleId: T, runtimeEnvironment: R, runtimeParams?: RuntimeParams, bundleConfigOverrides?: BundleConfigOverrides): Promise<BundleDefinition>;
|
|
286
289
|
resolveModuleUri(moduleId: Required<Pick<ModuleId, 'specifier' | 'version'>>, runtimeEnvironment: RuntimeEnvironment, runtimeParams?: RuntimeParams, signature?: string): Promise<string>;
|
|
287
290
|
getPublicApi(): PublicModuleBundler;
|
|
@@ -337,9 +340,10 @@ export interface AssetIdentifier {
|
|
|
337
340
|
type?: AssetType;
|
|
338
341
|
importer?: string;
|
|
339
342
|
}
|
|
340
|
-
export interface
|
|
343
|
+
export interface UriDefinition {
|
|
341
344
|
uri: string;
|
|
342
345
|
immutable: boolean;
|
|
346
|
+
artifactType: ArtifactType;
|
|
343
347
|
entry: string;
|
|
344
348
|
external?: boolean;
|
|
345
349
|
}
|
|
@@ -385,27 +389,25 @@ export interface AssetProvider {
|
|
|
385
389
|
name: string;
|
|
386
390
|
getAsset(assetIdentifier: AssetIdentifier): Promise<AssetSource | undefined>;
|
|
387
391
|
}
|
|
388
|
-
export type
|
|
389
|
-
type
|
|
390
|
-
type
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
};
|
|
394
|
-
type AssetPluginExtractMetaHook = (code: string | Buffer, assetSource: AssetSource, context?: TransformPluginContext) => Promise<AssetPluginExtractMetaHookReturn>;
|
|
395
|
-
type AssetPluginExtractMetaHookReturn = null | undefined | false | {
|
|
392
|
+
export type ArtifactType = 'asset' | 'bundle' | 'resource';
|
|
393
|
+
export type ArtifactDefinition = AssetDefinition | BundleDefinition | ResourceDefinition;
|
|
394
|
+
export type AssetTransformSourceHook = (assetSource: AssetSource, runtimeEnvironment: RuntimeEnvironment) => Promise<AssetTransformSourceHookReturn>;
|
|
395
|
+
export type AssetTransformSourceHookReturn = undefined | {
|
|
396
|
+
source: string | Buffer;
|
|
396
397
|
metadata?: AssetMetadata;
|
|
397
|
-
context?: TransformPluginContext;
|
|
398
|
-
};
|
|
399
|
-
type AssetPluginOptimizeHook = (code: string | Buffer, assetSource: AssetSource, context?: TransformPluginContext) => Promise<AssetPluginOptimizeHookReturn>;
|
|
400
|
-
type AssetPluginOptimizeHookReturn = null | undefined | false | string | Buffer | {
|
|
401
|
-
code: string | Buffer;
|
|
402
|
-
map?: any;
|
|
403
|
-
context?: TransformPluginContext;
|
|
404
398
|
};
|
|
399
|
+
export type UriTransformHook = (uri: UriDefinition, artifactDef?: ArtifactDefinition, runtimeEnvironment?: RuntimeEnvironment) => Promise<UriTransformHookReturn>;
|
|
400
|
+
export type UriTransformHookReturn = undefined | UriDefinition;
|
|
401
|
+
export interface UriTransformHooks {
|
|
402
|
+
transformUri: UriTransformHook;
|
|
403
|
+
}
|
|
404
|
+
export interface UriTransformPlugin extends UriTransformHooks {
|
|
405
|
+
name: string;
|
|
406
|
+
}
|
|
407
|
+
export type AssetUriTransformHook = (uri: UriDefinition, assetDef: AssetDefinition, runtimeEnvironment: RuntimeEnvironment) => Promise<UriTransformHookReturn>;
|
|
405
408
|
export interface AssetTransformHooks {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
optimize: AssetPluginOptimizeHook;
|
|
409
|
+
transformUri: AssetUriTransformHook;
|
|
410
|
+
transformSource: AssetTransformSourceHook;
|
|
409
411
|
}
|
|
410
412
|
export interface AssetTransformPlugin extends Partial<AssetTransformHooks> {
|
|
411
413
|
name: string;
|
|
@@ -413,17 +415,18 @@ export interface AssetTransformPlugin extends Partial<AssetTransformHooks> {
|
|
|
413
415
|
export interface ResourceRegistry {
|
|
414
416
|
name: string;
|
|
415
417
|
addResourceProviders(provider: ResourceProvider[]): void;
|
|
418
|
+
addResourceTransformers(provider: UriTransformPlugin[]): void;
|
|
416
419
|
getResource<R extends ResourceIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T, runtimeParams?: RuntimeParams): Promise<ResourceDefinition | undefined>;
|
|
417
|
-
resolveResourceUri<R extends ResourceIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T): string
|
|
420
|
+
resolveResourceUri<R extends ResourceIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T): Promise<string>;
|
|
418
421
|
getPublicApi(): PublicResourceRegistry;
|
|
419
422
|
}
|
|
420
423
|
export type PublicResourceRegistry = Pick<ResourceRegistry, 'getResource' | 'resolveResourceUri'>;
|
|
421
424
|
export interface AssetRegistry {
|
|
422
425
|
name: string;
|
|
423
426
|
addAssetProviders(provider: AssetProvider[]): void;
|
|
424
|
-
addAssetTransformers(transformers: AssetTransformPlugin[]): void;
|
|
427
|
+
addAssetTransformers(transformers: (AssetTransformPlugin | UriTransformPlugin)[]): void;
|
|
425
428
|
getAsset<R extends AssetIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T, includeMetadata?: boolean): Promise<AssetDefinition>;
|
|
426
|
-
resolveAssetUri<R extends AssetIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T): Promise<
|
|
429
|
+
resolveAssetUri<R extends AssetIdentifier, T extends RuntimeEnvironment>(resourceIdentity: R, runtimeEnvironment: T): Promise<UriDefinition>;
|
|
427
430
|
getPublicApi(): PublicAssetRegistry;
|
|
428
431
|
}
|
|
429
432
|
export type PublicAssetRegistry = Pick<AssetRegistry, 'getAsset' | 'resolveAssetUri'>;
|
|
@@ -431,12 +434,14 @@ export interface LwcCompilerConfig {
|
|
|
431
434
|
name: string;
|
|
432
435
|
namespace?: string;
|
|
433
436
|
filename: string;
|
|
437
|
+
enableLightningWebSecurityTransforms?: boolean;
|
|
434
438
|
scopedStyles?: boolean;
|
|
435
439
|
}
|
|
436
440
|
export type SourceMap = string | null | undefined;
|
|
437
441
|
export interface CompiledMetadata {
|
|
438
442
|
imports?: Import[];
|
|
439
443
|
dynamicImports?: DynamicImport[];
|
|
444
|
+
importMeta?: ImportMeta[];
|
|
440
445
|
}
|
|
441
446
|
export interface SourceLocation {
|
|
442
447
|
startColumn: number;
|
|
@@ -453,6 +458,10 @@ export interface DynamicImport {
|
|
|
453
458
|
importLocation: SourceLocation;
|
|
454
459
|
moduleNameType: ModuleNameType;
|
|
455
460
|
}
|
|
461
|
+
export interface ImportMeta {
|
|
462
|
+
statement: string;
|
|
463
|
+
location: SourceLocation;
|
|
464
|
+
}
|
|
456
465
|
export interface CompilerResult {
|
|
457
466
|
code: string;
|
|
458
467
|
map?: SourceMap;
|
|
@@ -461,6 +470,15 @@ export interface CompilerResult {
|
|
|
461
470
|
export interface BundleFiles {
|
|
462
471
|
[filename: string]: string;
|
|
463
472
|
}
|
|
473
|
+
interface ImportMetaEnv {
|
|
474
|
+
[key: string]: any;
|
|
475
|
+
SSR: boolean;
|
|
476
|
+
}
|
|
477
|
+
declare global {
|
|
478
|
+
interface ImportMeta {
|
|
479
|
+
readonly env: ImportMetaEnv;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
464
482
|
export interface ClientBootstrapConfig {
|
|
465
483
|
appId?: string;
|
|
466
484
|
bootstrapModule: string;
|
|
@@ -617,7 +635,7 @@ export interface SiteBundles {
|
|
|
617
635
|
bundles: Record<string, SiteBundle>;
|
|
618
636
|
}
|
|
619
637
|
export interface SiteResources {
|
|
620
|
-
resources: Record<string,
|
|
638
|
+
resources: Record<string, SiteResource>;
|
|
621
639
|
}
|
|
622
640
|
export interface SiteAssets {
|
|
623
641
|
assets: Record<string, SiteArtifact>;
|
|
@@ -626,6 +644,9 @@ export interface SiteArtifact {
|
|
|
626
644
|
path: string;
|
|
627
645
|
mimeType?: string;
|
|
628
646
|
}
|
|
647
|
+
export interface SiteResource extends SiteArtifact {
|
|
648
|
+
inline?: boolean;
|
|
649
|
+
}
|
|
629
650
|
export interface SiteBundle extends SiteArtifact {
|
|
630
651
|
version?: Version;
|
|
631
652
|
imports: string[];
|
package/build/lwr-shim.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetProvider, HooksPlugin, ModuleProvider, ProviderContext, ResourceProvider, ViewProvider, ViewTransformPlugin } from './index';
|
|
1
|
+
import type { AssetProvider, HooksPlugin, ModuleProvider, ProviderContext, ResourceProvider, ViewProvider, ViewTransformPlugin } from './index';
|
|
2
2
|
interface LwrShim {
|
|
3
3
|
LWC_VERSION: string;
|
|
4
4
|
LEGACY_LOADER: boolean;
|
package/build/server.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Application as ExpressApp } from 'express';
|
|
4
|
-
import Koa,
|
|
5
|
-
import http from 'http';
|
|
6
|
-
import { Readable } from 'stream';
|
|
3
|
+
import type { Application as ExpressApp } from 'express';
|
|
4
|
+
import type { default as Koa, Context } from 'koa';
|
|
5
|
+
import type http from 'http';
|
|
6
|
+
import type { Readable } from 'stream';
|
|
7
7
|
import type { 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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RegisterLoaderHooks } from './loaderPlugins/loaderPlugins';
|
|
2
|
-
import { RegisterHandleStaleModuleHook } from './handleStaleModule/handleStaleModule';
|
|
3
|
-
import { AppMetadata } from './appMetadata/appMetadata';
|
|
1
|
+
import type { RegisterLoaderHooks } from './loaderPlugins/loaderPlugins';
|
|
2
|
+
import type { RegisterHandleStaleModuleHook } from './handleStaleModule/handleStaleModule';
|
|
3
|
+
import type { AppMetadata } from './appMetadata/appMetadata';
|
|
4
4
|
export interface ServiceAPI {
|
|
5
5
|
addLoaderPlugin: NoOp | RegisterLoaderHooks;
|
|
6
6
|
handleStaleModule: RegisterHandleStaleModuleHook;
|
package/build/views.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { LwrErrorRoute, LwrRoute, RouteHandlerFunction, RouteHandlerView, View } from './config.js';
|
|
3
|
-
import { AssetSource,
|
|
2
|
+
import type { LwrErrorRoute, LwrRoute, RouteHandlerFunction, RouteHandlerView, View } from './config.js';
|
|
3
|
+
import type { AssetSource, UriDefinition, Endpoints, FlattenedModuleGraphs, ImportMetadata, Json, LwrStringBuilder, ResourceDefinition, RuntimeEnvironment, RuntimeParams, Specifier } from './index.js';
|
|
4
4
|
export type ViewIdentity = Pick<View, 'rootComponent' | 'contentTemplate'>;
|
|
5
5
|
export interface ViewSource {
|
|
6
6
|
name: string;
|
|
@@ -48,7 +48,7 @@ export interface RenderedViewMetadata {
|
|
|
48
48
|
export interface RenderedAssetReference {
|
|
49
49
|
url: string;
|
|
50
50
|
tagName?: string;
|
|
51
|
-
override?:
|
|
51
|
+
override?: UriDefinition;
|
|
52
52
|
}
|
|
53
53
|
export interface AssetReference extends RenderedAssetReference {
|
|
54
54
|
importer?: string;
|
|
@@ -89,6 +89,7 @@ interface ViewRequestQs {
|
|
|
89
89
|
}
|
|
90
90
|
export interface ViewRequest {
|
|
91
91
|
url: string;
|
|
92
|
+
originalUrl?: string;
|
|
92
93
|
requestPath: string;
|
|
93
94
|
params?: any;
|
|
94
95
|
query?: ViewRequestQs;
|
|
@@ -122,7 +123,7 @@ export interface ViewProvider {
|
|
|
122
123
|
initialize(): Promise<void>;
|
|
123
124
|
getView(viewId: ViewIdentity): Promise<CompiledView | undefined>;
|
|
124
125
|
}
|
|
125
|
-
export interface
|
|
126
|
+
export interface ViewTransformPluginContext {
|
|
126
127
|
view: View;
|
|
127
128
|
viewParams: ViewParams;
|
|
128
129
|
runtimeEnvironment: RuntimeEnvironment;
|
|
@@ -133,17 +134,15 @@ export interface ViewTranformPluginContext {
|
|
|
133
134
|
};
|
|
134
135
|
importer?: string;
|
|
135
136
|
}
|
|
136
|
-
type ViewPluginLinkHook = (builder: LwrStringBuilder, viewContext:
|
|
137
|
+
type ViewPluginLinkHook = (builder: LwrStringBuilder, viewContext: ViewTransformPluginContext, viewMetadata: RenderedViewMetadata) => Promise<ViewPluginLinkHookReturn>;
|
|
137
138
|
type ViewPluginLinkHookReturn = void | null | undefined | false | LwrStringBuilder | {
|
|
138
139
|
builder?: LwrStringBuilder;
|
|
139
|
-
context?: TransformPluginContext;
|
|
140
140
|
cache?: CacheResponse;
|
|
141
141
|
};
|
|
142
|
-
type ViewPluginOptimizeHook = (code: string, assetSource: AssetSource
|
|
142
|
+
type ViewPluginOptimizeHook = (code: string, assetSource: AssetSource) => Promise<ViewPluginOptimizeHookReturn>;
|
|
143
143
|
type ViewPluginOptimizeHookReturn = null | undefined | false | string | {
|
|
144
144
|
code: string;
|
|
145
145
|
map?: any;
|
|
146
|
-
context?: TransformPluginContext;
|
|
147
146
|
};
|
|
148
147
|
export interface ViewTransformHooks {
|
|
149
148
|
link: ViewPluginLinkHook;
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"build": "tsc -b"
|
|
9
9
|
},
|
|
10
10
|
"type": "module",
|
|
11
|
-
"version": "0.10.0
|
|
11
|
+
"version": "0.10.0",
|
|
12
12
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"chokidar": "^3.5.3"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=16.0.0
|
|
30
|
+
"node": ">=16.0.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "e6deaeef3db8aa079acefed508897eca19b3218a"
|
|
33
33
|
}
|