@lwc/lwc-dev-server 7.0.0-6.6.3
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/LICENSE.txt +21 -0
- package/README.md +7 -0
- package/bin/dev-server.js +2 -0
- package/dist/cli/cli.d.ts +1 -0
- package/dist/cli/cli.js +4 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/commands/devServer.d.ts +4 -0
- package/dist/cli/commands/devServer.js +115 -0
- package/dist/cli/commands/devServer.js.map +1 -0
- package/dist/cli/commands/index.d.ts +2 -0
- package/dist/cli/commands/index.js +21 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/server/bundler/lexBundler.d.ts +6 -0
- package/dist/server/bundler/lexBundler.js +73 -0
- package/dist/server/bundler/lexBundler.js.map +1 -0
- package/dist/server/connection/clientConnection.d.ts +19 -0
- package/dist/server/connection/clientConnection.js +30 -0
- package/dist/server/connection/clientConnection.js.map +1 -0
- package/dist/server/connection/index.d.ts +28 -0
- package/dist/server/connection/index.js +73 -0
- package/dist/server/connection/index.js.map +1 -0
- package/dist/server/consoleLogger.d.ts +6 -0
- package/dist/server/consoleLogger.js +33 -0
- package/dist/server/consoleLogger.js.map +1 -0
- package/dist/server/index.d.ts +18 -0
- package/dist/server/index.js +95 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/moduleGraph/index.d.ts +25 -0
- package/dist/server/moduleGraph/index.js +45 -0
- package/dist/server/moduleGraph/index.js.map +1 -0
- package/dist/server/moduleGraph/workspaceScanner/fileReader.d.ts +9 -0
- package/dist/server/moduleGraph/workspaceScanner/fileReader.js +81 -0
- package/dist/server/moduleGraph/workspaceScanner/fileReader.js.map +1 -0
- package/dist/server/moduleGraph/workspaceScanner/index.d.ts +3 -0
- package/dist/server/moduleGraph/workspaceScanner/index.js +15 -0
- package/dist/server/moduleGraph/workspaceScanner/index.js.map +1 -0
- package/dist/server/moduleGraph/workspaceScanner/internal.d.ts +8 -0
- package/dist/server/moduleGraph/workspaceScanner/internal.js +23 -0
- package/dist/server/moduleGraph/workspaceScanner/internal.js.map +1 -0
- package/dist/server/moduleGraph/workspaceScanner/mrt.d.ts +5 -0
- package/dist/server/moduleGraph/workspaceScanner/mrt.js +19 -0
- package/dist/server/moduleGraph/workspaceScanner/mrt.js.map +1 -0
- package/dist/server/moduleGraph/workspaceScanner/salesforceCli.d.ts +8 -0
- package/dist/server/moduleGraph/workspaceScanner/salesforceCli.js +26 -0
- package/dist/server/moduleGraph/workspaceScanner/salesforceCli.js.map +1 -0
- package/dist/server/moduleGraph/workspaceScanner/scanner.d.ts +56 -0
- package/dist/server/moduleGraph/workspaceScanner/scanner.js +35 -0
- package/dist/server/moduleGraph/workspaceScanner/scanner.js.map +1 -0
- package/dist/server/util/fileUtil.d.ts +1 -0
- package/dist/server/util/fileUtil.js +8 -0
- package/dist/server/util/fileUtil.js.map +1 -0
- package/dist/server/watcher/index.d.ts +3 -0
- package/dist/server/watcher/index.js +11 -0
- package/dist/server/watcher/index.js.map +1 -0
- package/dist/types/devServer.d.ts +10 -0
- package/dist/types/devServer.js +2 -0
- package/dist/types/devServer.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/serverConfig.d.ts +64 -0
- package/dist/types/serverConfig.js +24 -0
- package/dist/types/serverConfig.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,QAAQ,EAAkD,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,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,cAAc,CAAC,CAAC;4BAC/D,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gCACf,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,QAAQ,CAAC,KAAK,EACd,aAAa,cAAc,4CAA4C,IAAI,CAAC,SAAS,CACjF,MAAM,CAAC,QAAQ,CAClB,EAAE,CACN,CAAC;gCACF,MAAM;4BACV,CAAC;4BACD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;4BACpD,MAAM;wBACV,CAAC;wBACD;4BACI,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,QAAQ,CAAC,OAAO,EAChB,iBAAiB,MAAM,CAAC,MAAM,2BAA2B,CAC5D,CAAC;4BACF,MAAM;oBACd,CAAC;gBACL,CAAC,CAAC,CAAC;gBACH,MAAM;YACV,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Logger, type Workspace } from '../../types/index.js';
|
|
2
|
+
import type { HMR_Register } from '@lwc/lwc-dev-server-types';
|
|
3
|
+
import type { ModuleMapEntry, WorkspaceScanner } from './workspaceScanner/scanner';
|
|
4
|
+
export declare class ModuleGraph {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
workspaceScanner: WorkspaceScanner;
|
|
7
|
+
/**
|
|
8
|
+
* All LWC modules and their parts with absolute file paths, for the current workspace.
|
|
9
|
+
*/
|
|
10
|
+
moduleMap: ModuleMapEntry[];
|
|
11
|
+
/**
|
|
12
|
+
* All modules paths that are being used by the various client connections
|
|
13
|
+
*/
|
|
14
|
+
activeModulePaths: string[];
|
|
15
|
+
fileToModuleMap: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
};
|
|
18
|
+
moduleToFileMap: {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
};
|
|
21
|
+
constructor(workspace: Workspace, paths: string[], logger: Logger);
|
|
22
|
+
getModuleByFile(path: string): string | undefined;
|
|
23
|
+
getFileByModulePath(modulePath: string): string | undefined;
|
|
24
|
+
registerActivePaths(activeModules: HMR_Register[]): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LogLevel } from '../../types/index.js';
|
|
2
|
+
import { getWorkspaceScanner } from './workspaceScanner/index.js';
|
|
3
|
+
export class ModuleGraph {
|
|
4
|
+
constructor(workspace, paths, logger) {
|
|
5
|
+
/**
|
|
6
|
+
* All modules paths that are being used by the various client connections
|
|
7
|
+
*/
|
|
8
|
+
this.activeModulePaths = [];
|
|
9
|
+
// Mapping from <absolute file path> => "<namespace>/<componentname>/component.js"
|
|
10
|
+
this.fileToModuleMap = Object.create(null);
|
|
11
|
+
// Mapping from "<namespace>/<componentname>/component.js" => <absolute file path>
|
|
12
|
+
this.moduleToFileMap = Object.create(null);
|
|
13
|
+
this.workspaceScanner = getWorkspaceScanner(workspace, paths);
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
this.moduleMap = this.workspaceScanner.getModulesMap();
|
|
16
|
+
if (this.moduleMap.length) {
|
|
17
|
+
this.logger.log(LogLevel.debug, `Found ${this.moduleMap.length} LWC components in the current workspace.`);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.logger.log(LogLevel.debug, `Found no LWC components in the current workspace, check your settings in lwc.config.json.`);
|
|
21
|
+
}
|
|
22
|
+
this.moduleMap.forEach(({ moduleParts }) => {
|
|
23
|
+
Object.assign(this.moduleToFileMap, moduleParts);
|
|
24
|
+
for (const [modulePath, filePath] of Object.entries(moduleParts)) {
|
|
25
|
+
this.fileToModuleMap[filePath] = modulePath;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
getModuleByFile(path) {
|
|
30
|
+
return this.fileToModuleMap[path];
|
|
31
|
+
}
|
|
32
|
+
getFileByModulePath(modulePath) {
|
|
33
|
+
return this.moduleToFileMap[modulePath];
|
|
34
|
+
}
|
|
35
|
+
// Register the active paths that the client is interested in
|
|
36
|
+
registerActivePaths(activeModules) {
|
|
37
|
+
activeModules.forEach((mod) => {
|
|
38
|
+
const { data: { modulePath }, } = mod;
|
|
39
|
+
if (modulePath.trim()) {
|
|
40
|
+
this.activeModulePaths.push(modulePath);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/moduleGraph/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA+B,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAIlE,MAAM,OAAO,WAAW;IAiBpB,YAAY,SAAoB,EAAE,KAAe,EAAE,MAAc;QAVjE;;WAEG;QACH,sBAAiB,GAAa,EAAE,CAAC;QAEjC,kFAAkF;QAClF,oBAAe,GAA8B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjE,kFAAkF;QAClF,oBAAe,GAA8B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAG7D,IAAI,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC;QAEvD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YACxB,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,QAAQ,CAAC,KAAK,EACd,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,2CAA2C,CAC5E,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,QAAQ,CAAC,KAAK,EACd,2FAA2F,CAC9F,CAAC;QACN,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;YACvC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;YACjD,KAAK,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/D,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC;YAChD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAED,eAAe,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,mBAAmB,CAAC,UAAkB;QAClC,OAAO,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,6DAA6D;IAC7D,mBAAmB,CAAC,aAA6B;QAC7C,aAAa,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC1B,MAAM,EACF,IAAI,EAAE,EAAE,UAAU,EAAE,GACvB,GAAG,GAAG,CAAC;YACR,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;gBACpB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC5C,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get all parts of an LWC component.
|
|
3
|
+
* @param componentDir A directory representing an LWC Component.
|
|
4
|
+
* @returns A map representing all valid parts of the LWC with the short path as the key and full
|
|
5
|
+
* canonical path as value.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getComponentParts(componentDir: string, namespace: string): {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
} | undefined;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Is the file a valid LWC component part?
|
|
5
|
+
* @param {string} file
|
|
6
|
+
* @param {string} componentName Component name
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
function isValidLwcFile(file, componentName) {
|
|
10
|
+
const { name: fileName, dir: dirPath, ext } = path.parse(file);
|
|
11
|
+
const dir = path.basename(dirPath);
|
|
12
|
+
if (['.ts', '.js', '.html', '.css'].includes(ext))
|
|
13
|
+
return true;
|
|
14
|
+
if (dir === '__docs__' && (ext === '.md' || ext === '.auradoc') && fileName === componentName)
|
|
15
|
+
return true;
|
|
16
|
+
if (dir === componentName && ext === '.svg' && fileName === componentName)
|
|
17
|
+
return true;
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Should the directory be processed as a valid LWC module part?
|
|
22
|
+
*/
|
|
23
|
+
function shouldProcessDirectory(file) {
|
|
24
|
+
const name = path.basename(file);
|
|
25
|
+
return !name.startsWith('__') || name === '__docs__';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get valid LWC files recursively from a directory
|
|
29
|
+
* @param {string} dir Component Directory
|
|
30
|
+
* @param {string} name Component name
|
|
31
|
+
* @returns {Promise<string[]>} valid LWC file paths
|
|
32
|
+
*/
|
|
33
|
+
function getFiles(dir, name) {
|
|
34
|
+
if (!shouldProcessDirectory(dir)) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const dirents = readdirSync(dir, { withFileTypes: true });
|
|
38
|
+
return dirents.flatMap((dirent) => {
|
|
39
|
+
const file = path.resolve(dir, dirent.name);
|
|
40
|
+
if (dirent.isDirectory()) {
|
|
41
|
+
return getFiles(file, name);
|
|
42
|
+
}
|
|
43
|
+
return isValidLwcFile(file, name) ? [file] : [];
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Verify if a given directory represents an LWC component directory by checking if a valid entry file exists.
|
|
48
|
+
* @param entryPoint The directory to test.
|
|
49
|
+
* @param componentName The component name.
|
|
50
|
+
* @returns {boolean} true if directory has an entry file.
|
|
51
|
+
*/
|
|
52
|
+
function isValidEntryPoint(entryPoint, componentName) {
|
|
53
|
+
const jsEntryFile = path.join(entryPoint, componentName + '.js');
|
|
54
|
+
const tsEntryFile = path.join(entryPoint, componentName + '.ts');
|
|
55
|
+
const cssOnlyModuleEntryFile = path.join(entryPoint, componentName + '.css');
|
|
56
|
+
return existsSync(jsEntryFile) || existsSync(tsEntryFile) || existsSync(cssOnlyModuleEntryFile);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get all parts of an LWC component.
|
|
60
|
+
* @param componentDir A directory representing an LWC Component.
|
|
61
|
+
* @returns A map representing all valid parts of the LWC with the short path as the key and full
|
|
62
|
+
* canonical path as value.
|
|
63
|
+
*/
|
|
64
|
+
export function getComponentParts(componentDir, namespace) {
|
|
65
|
+
if (!existsSync(componentDir)) {
|
|
66
|
+
throw new Error('The LWC component directory does not exist.');
|
|
67
|
+
}
|
|
68
|
+
const name = path.basename(componentDir);
|
|
69
|
+
if (!isValidEntryPoint(componentDir, name)) {
|
|
70
|
+
// Not an LWC directory, return
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
const files = getFiles(componentDir, name);
|
|
74
|
+
return Object.fromEntries(
|
|
75
|
+
// Note: The file separator in the key should match that used by the
|
|
76
|
+
// @lwc/dev-server-plugin-lex and not the host system where the dev server runs
|
|
77
|
+
files.map((file) => {
|
|
78
|
+
return [`${namespace}/${name}/${path.relative(componentDir, file)}`, file];
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=fileReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileReader.js","sourceRoot":"","sources":["../../../../src/server/moduleGraph/workspaceScanner/fileReader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,E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AC,CAAC;IAC3C,OAAO,MAAM,CAAC,WAAW;IACrB,oEAAoE;IACpE,+EAA+E;IAC/E,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACf,OAAO,CAAC,GAAG,SAAS,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC/E,CAAC,CAAC,CACL,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Workspace } from '../../../types/index.js';
|
|
2
|
+
import InternalWorkspaceScanner from './internal.js';
|
|
3
|
+
import SalesforceCliWorkspaceScanner from './salesforceCli.js';
|
|
4
|
+
import MrtWorkspaceScanner from './mrt.js';
|
|
5
|
+
export function getWorkspaceScanner(workspace, modulesPaths) {
|
|
6
|
+
switch (workspace) {
|
|
7
|
+
case Workspace.Internal:
|
|
8
|
+
return new InternalWorkspaceScanner(Workspace.Internal, modulesPaths);
|
|
9
|
+
case Workspace.SfCli:
|
|
10
|
+
return new SalesforceCliWorkspaceScanner(Workspace.SfCli, modulesPaths);
|
|
11
|
+
case Workspace.Mrt:
|
|
12
|
+
return new MrtWorkspaceScanner(Workspace.Mrt, modulesPaths);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/server/moduleGraph/workspaceScanner/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,wBAAwB,MAAM,eAAe,CAAC;AACrD,OAAO,6BAA6B,MAAM,oBAAoB,CAAC;AAC/D,OAAO,mBAAmB,MAAM,UAAU,CAAC;AAG3C,MAAM,UAAU,mBAAmB,CAC/B,SAAoB,EACpB,YAAsB;IAEtB,QAAQ,SAAS,EAAE,CAAC;QAChB,KAAK,SAAS,CAAC,QAAQ;YACnB,OAAO,IAAI,wBAAwB,CAAC,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC1E,KAAK,SAAS,CAAC,KAAK;YAChB,OAAO,IAAI,6BAA6B,CAAC,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC5E,KAAK,SAAS,CAAC,GAAG;YACd,OAAO,IAAI,mBAAmB,CAAC,SAAS,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IACpE,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseWorkspaceScanner } from './scanner.js';
|
|
2
|
+
/**
|
|
3
|
+
* This scanner will accept paths and builds a list of module ids to component paths.
|
|
4
|
+
*/
|
|
5
|
+
export default class InternalWorkspaceScanner extends BaseWorkspaceScanner {
|
|
6
|
+
findModuleDirs(): string[];
|
|
7
|
+
getNamespace(moduleDir: string): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { getChildDirPaths } from '../../util/fileUtil.js';
|
|
3
|
+
import { BaseWorkspaceScanner } from './scanner.js';
|
|
4
|
+
/**
|
|
5
|
+
* This scanner will accept paths and builds a list of module ids to component paths.
|
|
6
|
+
*/
|
|
7
|
+
export default class InternalWorkspaceScanner extends BaseWorkspaceScanner {
|
|
8
|
+
findModuleDirs() {
|
|
9
|
+
const lwcDirs = [];
|
|
10
|
+
this.modulesPaths.forEach((uimodule) => {
|
|
11
|
+
const modulesDir = path.join(uimodule, 'modules');
|
|
12
|
+
const namespaces = getChildDirPaths(modulesDir);
|
|
13
|
+
namespaces.forEach((namespace) => {
|
|
14
|
+
lwcDirs.push(...getChildDirPaths(namespace));
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
return lwcDirs;
|
|
18
|
+
}
|
|
19
|
+
getNamespace(moduleDir) {
|
|
20
|
+
return path.basename(path.dirname(moduleDir));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../../src/server/moduleGraph/workspaceScanner/internal.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,oBAAoB;IACtE,cAAc;QACV,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACnC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAClD,MAAM,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;YAChD,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBAC7B,OAAO,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,YAAY,CAAC,SAAiB;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { getChildDirPaths } from '../../util/fileUtil';
|
|
3
|
+
import { BaseWorkspaceScanner } from './scanner';
|
|
4
|
+
export default class MrtWorkspaceScanner extends BaseWorkspaceScanner {
|
|
5
|
+
getNamespace(moduleDir) {
|
|
6
|
+
return path.basename(path.dirname(moduleDir));
|
|
7
|
+
}
|
|
8
|
+
findModuleDirs() {
|
|
9
|
+
const lwcDirs = [];
|
|
10
|
+
for (const modPath of this.modulesPaths) {
|
|
11
|
+
const namespaces = getChildDirPaths(modPath);
|
|
12
|
+
for (const namespacePath of namespaces) {
|
|
13
|
+
lwcDirs.push(...getChildDirPaths(namespacePath));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return lwcDirs;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=mrt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mrt.js","sourceRoot":"","sources":["../../../../src/server/moduleGraph/workspaceScanner/mrt.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,oBAAoB;IACjE,YAAY,CAAC,SAAiB;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,cAAc;QACV,MAAM,OAAO,GAAa,EAAE,CAAC;QAE7B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAE7C,KAAK,MAAM,aAAa,IAAI,UAAU,EAAE,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC;YACrD,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseWorkspaceScanner } from './scanner.js';
|
|
2
|
+
/**
|
|
3
|
+
* This scanner will accept paths and builds a list of module ids to component paths.
|
|
4
|
+
*/
|
|
5
|
+
export default class SalesforceCliWorkspaceScanner extends BaseWorkspaceScanner {
|
|
6
|
+
findModuleDirs(): string[];
|
|
7
|
+
getNamespace(_moduleDir: string): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { getChildDirPaths } from '../../util/fileUtil.js';
|
|
4
|
+
import { BaseWorkspaceScanner } from './scanner.js';
|
|
5
|
+
/**
|
|
6
|
+
* This scanner will accept paths and builds a list of module ids to component paths.
|
|
7
|
+
*/
|
|
8
|
+
export default class SalesforceCliWorkspaceScanner extends BaseWorkspaceScanner {
|
|
9
|
+
findModuleDirs() {
|
|
10
|
+
const lwcDirs = [];
|
|
11
|
+
if (this.modulesPaths.length !== 1) {
|
|
12
|
+
throw new Error('Expected workspace to have one lwc folder');
|
|
13
|
+
}
|
|
14
|
+
this.modulesPaths.forEach((uimodule) => {
|
|
15
|
+
const lwcDir = path.join(uimodule, 'lwc');
|
|
16
|
+
if (existsSync(lwcDir)) {
|
|
17
|
+
lwcDirs.push(...getChildDirPaths(lwcDir));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return lwcDirs;
|
|
21
|
+
}
|
|
22
|
+
getNamespace(_moduleDir) {
|
|
23
|
+
return 'c';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=salesforceCli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"salesforceCli.js","sourceRoot":"","sources":["../../../../src/server/moduleGraph/workspaceScanner/salesforceCli.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,6BAA8B,SAAQ,oBAAoB;IAC3E,cAAc;QACV,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YACnC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC1C,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBACrB,OAAO,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;YAC9C,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,YAAY,CAAC,UAAkB;QAC3B,OAAO,GAAG,CAAC;IACf,CAAC;CACJ"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Workspace } from '../../../types/index';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a Module entry per LWC component
|
|
4
|
+
*/
|
|
5
|
+
export interface ModuleMapEntry {
|
|
6
|
+
/**
|
|
7
|
+
* Owner module in format like <namespace>/<component-name>.
|
|
8
|
+
* Example for internal modules, "lightning/global".
|
|
9
|
+
* Example for custom modules, "c/myComponent".
|
|
10
|
+
*/
|
|
11
|
+
ownerModuleId: string;
|
|
12
|
+
/**
|
|
13
|
+
* Various parts of the module.
|
|
14
|
+
* For example:
|
|
15
|
+
* {
|
|
16
|
+
* "c/myComponent/myComponent.js": "workspace/ui-module/my-project/force-app/main/default/lwc/myComponent/myComponent.js",
|
|
17
|
+
* "c/myComponent/myComponent.html": "workspace/ui-module/my-project/force-app/main/default/lwc/myComponent/myComponent.html",
|
|
18
|
+
* "c/myComponent/util/util.js": "workspace/ui-module/my-project/force-app/main/default/lwc/myComponent/util/util.js",
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
moduleParts: {
|
|
22
|
+
[key: string]: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* An interface to define a workspace scanner that will build a map of modules and its assets in a given workspace.
|
|
27
|
+
* It accepts a set of directories and returns a map of Module Ids to file paths.
|
|
28
|
+
*/
|
|
29
|
+
export interface WorkspaceScanner {
|
|
30
|
+
/**
|
|
31
|
+
* Defines the type of workspace.
|
|
32
|
+
*/
|
|
33
|
+
workspace: Workspace;
|
|
34
|
+
/**
|
|
35
|
+
* The LWC modules directories contained in this workspace.
|
|
36
|
+
* In internal workspace type, the values will be the ["core/ui-xx-modules"] folders.
|
|
37
|
+
* In Salesforce CLI workspace type, the value will be ["workspace/ui-module/my-project/force-app/main/default/"] folder.
|
|
38
|
+
*/
|
|
39
|
+
modulesPaths: string[];
|
|
40
|
+
/**
|
|
41
|
+
* Get information about LWC modules contained in the workspace.
|
|
42
|
+
*/
|
|
43
|
+
getModulesMap(): ModuleMapEntry[];
|
|
44
|
+
}
|
|
45
|
+
export declare abstract class BaseWorkspaceScanner implements WorkspaceScanner {
|
|
46
|
+
workspace: Workspace;
|
|
47
|
+
modulesPaths: string[];
|
|
48
|
+
constructor(workspace: Workspace, modulesPaths: string[]);
|
|
49
|
+
/**
|
|
50
|
+
* Get information about LWC modules contained in the workspace.
|
|
51
|
+
*/
|
|
52
|
+
getModulesMap(): ModuleMapEntry[];
|
|
53
|
+
abstract getNamespace(moduleDir: string): string;
|
|
54
|
+
abstract findModuleDirs(): string[];
|
|
55
|
+
scanAModule(moduleDir: string): ModuleMapEntry | undefined;
|
|
56
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { getComponentParts } from './fileReader';
|
|
3
|
+
export class BaseWorkspaceScanner {
|
|
4
|
+
constructor(workspace, modulesPaths) {
|
|
5
|
+
this.workspace = workspace;
|
|
6
|
+
this.modulesPaths = modulesPaths;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get information about LWC modules contained in the workspace.
|
|
10
|
+
*/
|
|
11
|
+
getModulesMap() {
|
|
12
|
+
const modulesMap = [];
|
|
13
|
+
this.findModuleDirs().forEach((dir) => {
|
|
14
|
+
const moduleMap = this.scanAModule(dir);
|
|
15
|
+
if (moduleMap) {
|
|
16
|
+
modulesMap.push(moduleMap);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return modulesMap;
|
|
20
|
+
}
|
|
21
|
+
scanAModule(moduleDir) {
|
|
22
|
+
const { base } = path.parse(moduleDir);
|
|
23
|
+
const namespace = this.getNamespace(moduleDir);
|
|
24
|
+
const moduleParts = getComponentParts(moduleDir, namespace);
|
|
25
|
+
if (!moduleParts) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const moduleMap = {
|
|
29
|
+
ownerModuleId: `${namespace}/${base}`,
|
|
30
|
+
moduleParts,
|
|
31
|
+
};
|
|
32
|
+
return moduleMap;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../../../src/server/moduleGraph/workspaceScanner/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AA4CjD,MAAM,OAAgB,oBAAoB;IAGtC,YAAY,SAAoB,EAAE,YAAsB;QACpD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,aAAa;QACT,MAAM,UAAU,GAAqB,EAAE,CAAC;QACxC,IAAI,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAClC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,SAAS,EAAE,CAAC;gBACZ,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,UAAU,CAAC;IACtB,CAAC;IAKD,WAAW,CAAC,SAAiB;QACzB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC/C,MAAM,WAAW,GAAG,iBAAiB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,OAAO;QACX,CAAC;QAED,MAAM,SAAS,GAAmB;YAC9B,aAAa,EAAE,GAAG,SAAS,IAAI,IAAI,EAAE;YACrC,WAAW;SACd,CAAC;QACF,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getChildDirPaths(entryDir: string): string[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { readdirSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export function getChildDirPaths(entryDir) {
|
|
4
|
+
return readdirSync(entryDir, { withFileTypes: true })
|
|
5
|
+
.filter((dirent) => dirent.isDirectory())
|
|
6
|
+
.map((dirent) => path.resolve(entryDir, dirent.name));
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=fileUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileUtil.js","sourceRoot":"","sources":["../../../src/server/util/fileUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC7C,OAAO,WAAW,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;SAChD,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;SACxC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { watch } from 'chokidar';
|
|
2
|
+
const watchOptions = {};
|
|
3
|
+
let watcher;
|
|
4
|
+
export function startWatch(dirPaths) {
|
|
5
|
+
watcher = watch([...dirPaths], watchOptions);
|
|
6
|
+
return watcher;
|
|
7
|
+
}
|
|
8
|
+
export function stopWatch() {
|
|
9
|
+
watcher?.close();
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/watcher/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA2B,MAAM,UAAU,CAAC;AAE1D,MAAM,YAAY,GAAiB,EAAE,CAAC;AACtC,IAAI,OAA8B,CAAC;AACnC,MAAM,UAAU,UAAU,CAAC,QAAkB;IACzC,OAAO,GAAG,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;IAC7C,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,SAAS;IACrB,OAAO,EAAE,KAAK,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModuleGraph } from '../server/moduleGraph/index.js';
|
|
2
|
+
import { LogLevel, ServerConfig } from './serverConfig.js';
|
|
3
|
+
export interface Logger {
|
|
4
|
+
log(level: LogLevel, message: string): void;
|
|
5
|
+
}
|
|
6
|
+
export interface DevServer {
|
|
7
|
+
config?: ServerConfig;
|
|
8
|
+
logger?: Logger;
|
|
9
|
+
moduleGraph: ModuleGraph;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devServer.js","sourceRoot":"","sources":["../../src/types/devServer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ClientTarget } from '@lwc/lwc-dev-server-types';
|
|
3
|
+
/**
|
|
4
|
+
* Define the type of workspace.
|
|
5
|
+
* Internal is for salesforce internal developers.
|
|
6
|
+
* SfCli is for the Salesforce CLI project setup.
|
|
7
|
+
*/
|
|
8
|
+
export declare enum Workspace {
|
|
9
|
+
Internal = "internal",
|
|
10
|
+
SfCli = "SalesforceCLI",
|
|
11
|
+
Mrt = "mrt"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Logging level in decreasing order of severity and increasing order of noise.
|
|
15
|
+
*/
|
|
16
|
+
export declare enum LogLevel {
|
|
17
|
+
silent = 0,
|
|
18
|
+
error = 1,
|
|
19
|
+
warn = 2,
|
|
20
|
+
info = 3,
|
|
21
|
+
debug = 4,
|
|
22
|
+
verbose = 5
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Config for HTTPS server
|
|
26
|
+
* Technically all the supported fields that `require('ndoe:https').createServer` accepts can be passed here,
|
|
27
|
+
* https://nodejs.org/api/https.html#httpscreateserveroptions-requestlistener
|
|
28
|
+
*
|
|
29
|
+
* but we handpicked the ones that are most used here.
|
|
30
|
+
* Usually users either provide a cert and a key or pfx and a passphrase
|
|
31
|
+
*/
|
|
32
|
+
export type HttpsConfig = Partial<{
|
|
33
|
+
cert: string;
|
|
34
|
+
key: string;
|
|
35
|
+
pfx: Buffer;
|
|
36
|
+
passphrase: string;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Interface representing the LWC Local Development server config.
|
|
40
|
+
*/
|
|
41
|
+
export interface ServerConfig {
|
|
42
|
+
/**
|
|
43
|
+
* The root directory for the project, config files and path will be referenced as relative to this directory
|
|
44
|
+
* For internal developers: core home
|
|
45
|
+
* For Salesforce CLI customers: The Salesforce DX Project dir
|
|
46
|
+
*/
|
|
47
|
+
rootDir: string;
|
|
48
|
+
/** Port at which the web socket will communicating from. */
|
|
49
|
+
port: number;
|
|
50
|
+
/** Websocket protocol to use */
|
|
51
|
+
protocol: string;
|
|
52
|
+
/** Host where the dev server is running. Will be used to send information to the client. */
|
|
53
|
+
host: string;
|
|
54
|
+
/**
|
|
55
|
+
* Component paths to watch
|
|
56
|
+
* For SF CLI: force-app/main/default
|
|
57
|
+
*/
|
|
58
|
+
paths: string[];
|
|
59
|
+
/** Container targets to bundle modules for. */
|
|
60
|
+
targets: ClientTarget[];
|
|
61
|
+
workspace: Workspace;
|
|
62
|
+
logLevel: LogLevel;
|
|
63
|
+
https?: HttpsConfig;
|
|
64
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Define the type of workspace.
|
|
3
|
+
* Internal is for salesforce internal developers.
|
|
4
|
+
* SfCli is for the Salesforce CLI project setup.
|
|
5
|
+
*/
|
|
6
|
+
export var Workspace;
|
|
7
|
+
(function (Workspace) {
|
|
8
|
+
Workspace["Internal"] = "internal";
|
|
9
|
+
Workspace["SfCli"] = "SalesforceCLI";
|
|
10
|
+
Workspace["Mrt"] = "mrt";
|
|
11
|
+
})(Workspace || (Workspace = {}));
|
|
12
|
+
/**
|
|
13
|
+
* Logging level in decreasing order of severity and increasing order of noise.
|
|
14
|
+
*/
|
|
15
|
+
export var LogLevel;
|
|
16
|
+
(function (LogLevel) {
|
|
17
|
+
LogLevel[LogLevel["silent"] = 0] = "silent";
|
|
18
|
+
LogLevel[LogLevel["error"] = 1] = "error";
|
|
19
|
+
LogLevel[LogLevel["warn"] = 2] = "warn";
|
|
20
|
+
LogLevel[LogLevel["info"] = 3] = "info";
|
|
21
|
+
LogLevel[LogLevel["debug"] = 4] = "debug";
|
|
22
|
+
LogLevel[LogLevel["verbose"] = 5] = "verbose";
|
|
23
|
+
})(LogLevel || (LogLevel = {}));
|
|
24
|
+
//# sourceMappingURL=serverConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverConfig.js","sourceRoot":"","sources":["../../src/types/serverConfig.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAN,IAAY,SAIX;AAJD,WAAY,SAAS;IACjB,kCAAqB,CAAA;IACrB,oCAAuB,CAAA;IACvB,wBAAW,CAAA;AACf,CAAC,EAJW,SAAS,KAAT,SAAS,QAIpB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAChB,2CAAU,CAAA;IACV,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,6CAAW,CAAA;AACf,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lwc/lwc-dev-server",
|
|
3
|
+
"description": "A development server to get quick feedback on your LWC component development.",
|
|
4
|
+
"version": "7.0.0-6.6.3",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lwc dev server"
|
|
7
|
+
],
|
|
8
|
+
"bin": {
|
|
9
|
+
"lwc-dev-server": "./bin/dev-server.js"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"typings": "dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"bin",
|
|
17
|
+
"LICENSE.txt"
|
|
18
|
+
],
|
|
19
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"start": "node ./bin/dev-server.js start"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/ws": "^8.5.10",
|
|
26
|
+
"@lwc/compiler": "6.6.3",
|
|
27
|
+
"@lwc/lwc-dev-server-types": "7.0.0-6.6.3"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"chalk": "~5.3.0",
|
|
31
|
+
"chokidar": "~3.6.0",
|
|
32
|
+
"commander": "~10.0.0",
|
|
33
|
+
"ws": "~8.16.0"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@lwc/sfdc-lwc-compiler": "7.0.0-6.6.3"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=16"
|
|
40
|
+
}
|
|
41
|
+
}
|