@lwrjs/core 0.12.0-alpha.13 → 0.12.0-alpha.15
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/cjs/index.cjs +13 -22
- package/build/es/index.d.ts +12 -5
- package/build/es/index.js +13 -23
- package/package.json +34 -33
package/build/cjs/index.cjs
CHANGED
|
@@ -102,24 +102,23 @@ async function initContext(appConfig, runtimeEnvironment, globalData) {
|
|
|
102
102
|
return serverContext;
|
|
103
103
|
}
|
|
104
104
|
var LwrApp = class {
|
|
105
|
-
constructor(
|
|
105
|
+
constructor(configs) {
|
|
106
106
|
this.initialized = false;
|
|
107
107
|
const span = (0, import_instrumentation.getTracer)().startSpan({name: import_instrumentation.CoreSpan.CreateServer});
|
|
108
|
-
const {appConfig, runtimeEnvironment, globalData} =
|
|
108
|
+
const {appConfig, runtimeEnvironment, globalData} = configs;
|
|
109
109
|
this.config = appConfig;
|
|
110
110
|
this.runtimeEnvironment = runtimeEnvironment;
|
|
111
111
|
this.globalData = globalData;
|
|
112
|
-
const {basePath} = this.config;
|
|
113
|
-
this.
|
|
112
|
+
const {basePath, serverType} = this.config;
|
|
113
|
+
this.serverType = serverType;
|
|
114
|
+
this.app = (0, import_server.createInternalServer)(serverType, {basePath});
|
|
114
115
|
this.server = this.app.createHttpServer();
|
|
116
|
+
this.use = this.app.use.bind(this.app);
|
|
117
|
+
this.all = this.app.all.bind(this.app);
|
|
118
|
+
this.get = this.app.get.bind(this.app);
|
|
119
|
+
this.post = this.app.post.bind(this.app);
|
|
115
120
|
span.end();
|
|
116
121
|
}
|
|
117
|
-
setConfig(config) {
|
|
118
|
-
const {appConfig, runtimeEnvironment, globalData} = (0, import_config.loadConfig)(config);
|
|
119
|
-
this.config = appConfig;
|
|
120
|
-
this.runtimeEnvironment = runtimeEnvironment;
|
|
121
|
-
this.globalData = globalData;
|
|
122
|
-
}
|
|
123
122
|
getConfig() {
|
|
124
123
|
return this.config;
|
|
125
124
|
}
|
|
@@ -171,24 +170,16 @@ var LwrApp = class {
|
|
|
171
170
|
});
|
|
172
171
|
});
|
|
173
172
|
}
|
|
174
|
-
|
|
175
|
-
this.server?.close &&
|
|
173
|
+
close() {
|
|
174
|
+
this.server?.close && this.server.close();
|
|
176
175
|
}
|
|
177
176
|
getInternalServer() {
|
|
178
177
|
return this.app.getImpl();
|
|
179
178
|
}
|
|
180
|
-
getServer() {
|
|
181
|
-
return {
|
|
182
|
-
use: this.app.use.bind(this.app),
|
|
183
|
-
all: this.app.all.bind(this.app),
|
|
184
|
-
get: this.app.get.bind(this.app),
|
|
185
|
-
post: this.app.post.bind(this.app),
|
|
186
|
-
getRegexWildcard: this.app.getRegexWildcard.bind(this.app)
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
179
|
};
|
|
190
180
|
function createServer(config) {
|
|
191
|
-
|
|
181
|
+
const configs = (0, import_config.loadConfig)(config);
|
|
182
|
+
return new LwrApp(configs);
|
|
192
183
|
}
|
|
193
184
|
async function generateStaticSite(config) {
|
|
194
185
|
config = config || {};
|
package/build/es/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LwrGlobalConfig, NormalizedLwrGlobalConfig, ServerTypeImpl,
|
|
1
|
+
import type { LwrGlobalConfig, NormalizedLwrGlobalConfig, ServerTypeImpl, ServerTypes, RuntimeEnvironment, GlobalData, MiddlewareFunction } from '@lwrjs/types';
|
|
2
2
|
export declare class LwrApp {
|
|
3
3
|
private app;
|
|
4
4
|
private server;
|
|
@@ -6,8 +6,16 @@ export declare class LwrApp {
|
|
|
6
6
|
private config;
|
|
7
7
|
private runtimeEnvironment;
|
|
8
8
|
private globalData;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
serverType: ServerTypes;
|
|
10
|
+
use: (m: MiddlewareFunction) => void;
|
|
11
|
+
all: (path: string | string[], m: MiddlewareFunction) => void;
|
|
12
|
+
get: (path: string | string[], m: MiddlewareFunction) => void;
|
|
13
|
+
post: (path: string | string[], m: MiddlewareFunction) => void;
|
|
14
|
+
constructor(configs: {
|
|
15
|
+
appConfig: NormalizedLwrGlobalConfig;
|
|
16
|
+
runtimeEnvironment: RuntimeEnvironment;
|
|
17
|
+
globalData: GlobalData;
|
|
18
|
+
});
|
|
11
19
|
getConfig(): NormalizedLwrGlobalConfig;
|
|
12
20
|
init(): Promise<void>;
|
|
13
21
|
listen(callback?: ((opts: {
|
|
@@ -17,9 +25,8 @@ export declare class LwrApp {
|
|
|
17
25
|
serverMode: string;
|
|
18
26
|
port: number;
|
|
19
27
|
}>;
|
|
20
|
-
close():
|
|
28
|
+
close(): void;
|
|
21
29
|
getInternalServer<S extends ServerTypes>(): ServerTypeImpl<S>;
|
|
22
|
-
getServer(): PublicAppServer<ServerTypes>;
|
|
23
30
|
}
|
|
24
31
|
export declare function createServer(config?: LwrGlobalConfig): LwrApp;
|
|
25
32
|
export declare function generateStaticSite(config?: LwrGlobalConfig): Promise<NormalizedLwrGlobalConfig>;
|
package/build/es/index.js
CHANGED
|
@@ -91,24 +91,23 @@ async function initContext(appConfig, runtimeEnvironment, globalData) {
|
|
|
91
91
|
return serverContext;
|
|
92
92
|
}
|
|
93
93
|
export class LwrApp {
|
|
94
|
-
constructor(
|
|
94
|
+
constructor(configs) {
|
|
95
95
|
this.initialized = false;
|
|
96
96
|
const span = getTracer().startSpan({ name: CoreSpan.CreateServer });
|
|
97
|
-
const { appConfig, runtimeEnvironment, globalData } =
|
|
97
|
+
const { appConfig, runtimeEnvironment, globalData } = configs;
|
|
98
98
|
this.config = appConfig;
|
|
99
99
|
this.runtimeEnvironment = runtimeEnvironment;
|
|
100
100
|
this.globalData = globalData;
|
|
101
|
-
const { basePath } = this.config;
|
|
102
|
-
this.
|
|
101
|
+
const { basePath, serverType } = this.config;
|
|
102
|
+
this.serverType = serverType;
|
|
103
|
+
this.app = createInternalServer(serverType, { basePath });
|
|
103
104
|
this.server = this.app.createHttpServer();
|
|
105
|
+
this.use = this.app.use.bind(this.app);
|
|
106
|
+
this.all = this.app.all.bind(this.app);
|
|
107
|
+
this.get = this.app.get.bind(this.app);
|
|
108
|
+
this.post = this.app.post.bind(this.app);
|
|
104
109
|
span.end();
|
|
105
110
|
}
|
|
106
|
-
setConfig(config) {
|
|
107
|
-
const { appConfig, runtimeEnvironment, globalData } = loadConfig(config);
|
|
108
|
-
this.config = appConfig;
|
|
109
|
-
this.runtimeEnvironment = runtimeEnvironment;
|
|
110
|
-
this.globalData = globalData;
|
|
111
|
-
}
|
|
112
111
|
getConfig() {
|
|
113
112
|
return this.config;
|
|
114
113
|
}
|
|
@@ -166,26 +165,17 @@ export class LwrApp {
|
|
|
166
165
|
});
|
|
167
166
|
});
|
|
168
167
|
}
|
|
169
|
-
|
|
170
|
-
this.server?.close &&
|
|
168
|
+
close() {
|
|
169
|
+
this.server?.close && this.server.close();
|
|
171
170
|
}
|
|
172
171
|
// Get the underlying server (e.g. express, koa...)
|
|
173
172
|
getInternalServer() {
|
|
174
173
|
return this.app.getImpl();
|
|
175
174
|
}
|
|
176
|
-
// Return the public server interface which is compatible with all server types
|
|
177
|
-
getServer() {
|
|
178
|
-
return {
|
|
179
|
-
use: this.app.use.bind(this.app),
|
|
180
|
-
all: this.app.all.bind(this.app),
|
|
181
|
-
get: this.app.get.bind(this.app),
|
|
182
|
-
post: this.app.post.bind(this.app),
|
|
183
|
-
getRegexWildcard: this.app.getRegexWildcard.bind(this.app),
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
175
|
}
|
|
187
176
|
export function createServer(config) {
|
|
188
|
-
|
|
177
|
+
const configs = loadConfig(config);
|
|
178
|
+
return new LwrApp(configs);
|
|
189
179
|
}
|
|
190
180
|
export async function generateStaticSite(config) {
|
|
191
181
|
config = config || {};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.12.0-alpha.
|
|
7
|
+
"version": "0.12.0-alpha.15",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -43,45 +43,46 @@
|
|
|
43
43
|
"build": "tsc -b"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@lwrjs/app-service": "0.12.0-alpha.
|
|
47
|
-
"@lwrjs/asset-registry": "0.12.0-alpha.
|
|
48
|
-
"@lwrjs/asset-transformer": "0.12.0-alpha.
|
|
49
|
-
"@lwrjs/base-view-provider": "0.12.0-alpha.
|
|
50
|
-
"@lwrjs/base-view-transformer": "0.12.0-alpha.
|
|
51
|
-
"@lwrjs/client-modules": "0.12.0-alpha.
|
|
52
|
-
"@lwrjs/config": "0.12.0-alpha.
|
|
53
|
-
"@lwrjs/diagnostics": "0.12.0-alpha.
|
|
54
|
-
"@lwrjs/esbuild": "0.12.0-alpha.
|
|
55
|
-
"@lwrjs/fs-asset-provider": "0.12.0-alpha.
|
|
56
|
-
"@lwrjs/fs-watch": "0.12.0-alpha.
|
|
57
|
-
"@lwrjs/html-view-provider": "0.12.0-alpha.
|
|
58
|
-
"@lwrjs/instrumentation": "0.12.0-alpha.
|
|
59
|
-
"@lwrjs/loader": "0.12.0-alpha.
|
|
60
|
-
"@lwrjs/lwc-module-provider": "0.12.0-alpha.
|
|
61
|
-
"@lwrjs/lwc-ssr": "0.12.0-alpha.
|
|
62
|
-
"@lwrjs/markdown-view-provider": "0.12.0-alpha.
|
|
63
|
-
"@lwrjs/module-bundler": "0.12.0-alpha.
|
|
64
|
-
"@lwrjs/module-registry": "0.12.0-alpha.
|
|
65
|
-
"@lwrjs/npm-module-provider": "0.12.0-alpha.
|
|
66
|
-
"@lwrjs/nunjucks-view-provider": "0.12.0-alpha.
|
|
67
|
-
"@lwrjs/o11y": "0.12.0-alpha.
|
|
68
|
-
"@lwrjs/resource-registry": "0.12.0-alpha.
|
|
69
|
-
"@lwrjs/router": "0.12.0-alpha.
|
|
70
|
-
"@lwrjs/server": "0.12.0-alpha.
|
|
71
|
-
"@lwrjs/shared-utils": "0.12.0-alpha.
|
|
72
|
-
"@lwrjs/static": "0.12.0-alpha.
|
|
73
|
-
"@lwrjs/view-registry": "0.12.0-alpha.
|
|
46
|
+
"@lwrjs/app-service": "0.12.0-alpha.15",
|
|
47
|
+
"@lwrjs/asset-registry": "0.12.0-alpha.15",
|
|
48
|
+
"@lwrjs/asset-transformer": "0.12.0-alpha.15",
|
|
49
|
+
"@lwrjs/base-view-provider": "0.12.0-alpha.15",
|
|
50
|
+
"@lwrjs/base-view-transformer": "0.12.0-alpha.15",
|
|
51
|
+
"@lwrjs/client-modules": "0.12.0-alpha.15",
|
|
52
|
+
"@lwrjs/config": "0.12.0-alpha.15",
|
|
53
|
+
"@lwrjs/diagnostics": "0.12.0-alpha.15",
|
|
54
|
+
"@lwrjs/esbuild": "0.12.0-alpha.15",
|
|
55
|
+
"@lwrjs/fs-asset-provider": "0.12.0-alpha.15",
|
|
56
|
+
"@lwrjs/fs-watch": "0.12.0-alpha.15",
|
|
57
|
+
"@lwrjs/html-view-provider": "0.12.0-alpha.15",
|
|
58
|
+
"@lwrjs/instrumentation": "0.12.0-alpha.15",
|
|
59
|
+
"@lwrjs/loader": "0.12.0-alpha.15",
|
|
60
|
+
"@lwrjs/lwc-module-provider": "0.12.0-alpha.15",
|
|
61
|
+
"@lwrjs/lwc-ssr": "0.12.0-alpha.15",
|
|
62
|
+
"@lwrjs/markdown-view-provider": "0.12.0-alpha.15",
|
|
63
|
+
"@lwrjs/module-bundler": "0.12.0-alpha.15",
|
|
64
|
+
"@lwrjs/module-registry": "0.12.0-alpha.15",
|
|
65
|
+
"@lwrjs/npm-module-provider": "0.12.0-alpha.15",
|
|
66
|
+
"@lwrjs/nunjucks-view-provider": "0.12.0-alpha.15",
|
|
67
|
+
"@lwrjs/o11y": "0.12.0-alpha.15",
|
|
68
|
+
"@lwrjs/resource-registry": "0.12.0-alpha.15",
|
|
69
|
+
"@lwrjs/router": "0.12.0-alpha.15",
|
|
70
|
+
"@lwrjs/server": "0.12.0-alpha.15",
|
|
71
|
+
"@lwrjs/shared-utils": "0.12.0-alpha.15",
|
|
72
|
+
"@lwrjs/static": "0.12.0-alpha.15",
|
|
73
|
+
"@lwrjs/view-registry": "0.12.0-alpha.15",
|
|
74
74
|
"chokidar": "^3.5.3",
|
|
75
75
|
"esbuild": "^0.9.7",
|
|
76
76
|
"fs-extra": "^11.1.1",
|
|
77
77
|
"path-to-regexp": "^6.2.0",
|
|
78
78
|
"qs": "^6.11.2",
|
|
79
79
|
"rollup": "^2.78.0",
|
|
80
|
-
"ws": "^8.
|
|
80
|
+
"ws": "^8.16.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@lwrjs/types": "0.12.0-alpha.
|
|
84
|
-
"@types/ws": "^8.5.
|
|
83
|
+
"@lwrjs/types": "0.12.0-alpha.15",
|
|
84
|
+
"@types/ws": "^8.5.10",
|
|
85
|
+
"mock-fs": "^5.2.0"
|
|
85
86
|
},
|
|
86
87
|
"peerDependencies": {
|
|
87
88
|
"lwc": ">= 2.x"
|
|
@@ -92,5 +93,5 @@
|
|
|
92
93
|
"volta": {
|
|
93
94
|
"extends": "../../../package.json"
|
|
94
95
|
},
|
|
95
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "ec5b8babc9f0b07389bcb5575665ceddd77b37a1"
|
|
96
97
|
}
|