@lwrjs/shared-utils 0.9.0-alpha.0 → 0.9.0-alpha.2
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/fs.cjs +15 -0
- package/build/cjs/urls.cjs +5 -0
- package/build/es/fs.js +16 -1
- package/build/es/urls.d.ts +1 -0
- package/build/es/urls.js +4 -0
- package/package.json +4 -4
package/build/cjs/fs.cjs
CHANGED
|
@@ -44,10 +44,13 @@ var import_chokidar = __toModule(require("chokidar"));
|
|
|
44
44
|
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
45
45
|
var import_mime_types = __toModule(require("mime-types"));
|
|
46
46
|
var import_logger = __toModule(require("./logger.cjs"));
|
|
47
|
+
var fileCount = 0;
|
|
48
|
+
var files = new Map();
|
|
47
49
|
function hashContent(source) {
|
|
48
50
|
return import_crypto.default.createHash("md5").update(source).digest("hex");
|
|
49
51
|
}
|
|
50
52
|
function readFile(filePath) {
|
|
53
|
+
logMetrics(filePath);
|
|
51
54
|
return import_fs.default.readFileSync(filePath, "utf8");
|
|
52
55
|
}
|
|
53
56
|
function resolveFileExtension(filePath) {
|
|
@@ -125,3 +128,15 @@ function normalizeResourcePath(rawPath, {rootDir, assets, contentDir, layoutsDir
|
|
|
125
128
|
return alias;
|
|
126
129
|
});
|
|
127
130
|
}
|
|
131
|
+
function logMetrics(filePath) {
|
|
132
|
+
if (import_logger.logger.currentLevel == import_logger.DEBUG || import_logger.logger.currentLevel == import_logger.VERBOSE) {
|
|
133
|
+
let count = files.get(filePath) || 0;
|
|
134
|
+
if (++count % 100 === 0) {
|
|
135
|
+
import_logger.logger.debug(`[${count}] Repeat Read ${filePath}`);
|
|
136
|
+
}
|
|
137
|
+
files.set(filePath, count);
|
|
138
|
+
if (++fileCount % 1e3 === 0) {
|
|
139
|
+
import_logger.logger.debug(`Open file count [${fileCount}]`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
package/build/cjs/urls.cjs
CHANGED
|
@@ -29,6 +29,7 @@ __export(exports, {
|
|
|
29
29
|
getClientBootstrapConfigurationRoutes: () => getClientBootstrapConfigurationRoutes,
|
|
30
30
|
getClientBootstrapConfigurationUri: () => getClientBootstrapConfigurationUri,
|
|
31
31
|
getClientBootstrapConfigurationUriPrefix: () => getClientBootstrapConfigurationUriPrefix,
|
|
32
|
+
isModuleOrBundleUrl: () => isModuleOrBundleUrl,
|
|
32
33
|
removeClientBootstrapConfigurationSuffix: () => removeClientBootstrapConfigurationSuffix
|
|
33
34
|
});
|
|
34
35
|
var import_path_to_regexp = __toModule(require("path-to-regexp"));
|
|
@@ -95,3 +96,7 @@ function extractRequestParams(parameterizedRoute, resolvedUrl, existingParams) {
|
|
|
95
96
|
}
|
|
96
97
|
return params;
|
|
97
98
|
}
|
|
99
|
+
var isModuleOrBundleRegEx = /^\/.*\/(module|bundle)\//i;
|
|
100
|
+
function isModuleOrBundleUrl(url) {
|
|
101
|
+
return isModuleOrBundleRegEx.test(url);
|
|
102
|
+
}
|
package/build/es/fs.js
CHANGED
|
@@ -6,7 +6,9 @@ import { debounce } from './object.js';
|
|
|
6
6
|
import chokidar from 'chokidar';
|
|
7
7
|
import { LwrUnresolvableError, createSingleDiagnosticError, descriptions } from '@lwrjs/diagnostics';
|
|
8
8
|
import { lookup } from 'mime-types';
|
|
9
|
-
import { logger } from './logger.js';
|
|
9
|
+
import { DEBUG, logger, VERBOSE } from './logger.js';
|
|
10
|
+
let fileCount = 0;
|
|
11
|
+
const files = new Map();
|
|
10
12
|
/**
|
|
11
13
|
* Create a hash string for a source
|
|
12
14
|
* @param source
|
|
@@ -19,6 +21,7 @@ export function hashContent(source) {
|
|
|
19
21
|
* @param filePath
|
|
20
22
|
*/
|
|
21
23
|
export function readFile(filePath) {
|
|
24
|
+
logMetrics(filePath);
|
|
22
25
|
return fs.readFileSync(filePath, 'utf8');
|
|
23
26
|
}
|
|
24
27
|
/**
|
|
@@ -138,4 +141,16 @@ export function normalizeResourcePath(rawPath, { rootDir, assets, contentDir, la
|
|
|
138
141
|
});
|
|
139
142
|
}
|
|
140
143
|
export { lookup as mimeLookup };
|
|
144
|
+
function logMetrics(filePath) {
|
|
145
|
+
if (logger.currentLevel == DEBUG || logger.currentLevel == VERBOSE) {
|
|
146
|
+
let count = files.get(filePath) || 0;
|
|
147
|
+
if (++count % 100 === 0) {
|
|
148
|
+
logger.debug(`[${count}] Repeat Read ${filePath}`);
|
|
149
|
+
}
|
|
150
|
+
files.set(filePath, count);
|
|
151
|
+
if (++fileCount % 1000 === 0) {
|
|
152
|
+
logger.debug(`Open file count [${fileCount}]`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
141
156
|
//# sourceMappingURL=fs.js.map
|
package/build/es/urls.d.ts
CHANGED
|
@@ -27,4 +27,5 @@ export declare function getClientBootstrapConfigurationRoutes(): string[];
|
|
|
27
27
|
* @returns A parameter maps with existing parameters plus token value pairs from route and url
|
|
28
28
|
*/
|
|
29
29
|
export declare function extractRequestParams(parameterizedRoute: string, resolvedUrl: string, existingParams?: Record<string, string>): Record<string, string>;
|
|
30
|
+
export declare function isModuleOrBundleUrl(url: string): boolean;
|
|
30
31
|
//# sourceMappingURL=urls.d.ts.map
|
package/build/es/urls.js
CHANGED
|
@@ -87,4 +87,8 @@ export function extractRequestParams(parameterizedRoute, resolvedUrl, existingPa
|
|
|
87
87
|
}
|
|
88
88
|
return params;
|
|
89
89
|
}
|
|
90
|
+
const isModuleOrBundleRegEx = /^\/.*\/(module|bundle)\//i;
|
|
91
|
+
export function isModuleOrBundleUrl(url) {
|
|
92
|
+
return isModuleOrBundleRegEx.test(url);
|
|
93
|
+
}
|
|
90
94
|
//# sourceMappingURL=urls.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.9.0-alpha.
|
|
7
|
+
"version": "0.9.0-alpha.2",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"winston": "^3.7.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@lwrjs/diagnostics": "0.9.0-alpha.
|
|
49
|
-
"@lwrjs/types": "0.9.0-alpha.
|
|
48
|
+
"@lwrjs/diagnostics": "0.9.0-alpha.2",
|
|
49
|
+
"@lwrjs/types": "0.9.0-alpha.2",
|
|
50
50
|
"@types/mime-types": "2.1.1",
|
|
51
51
|
"@types/path-to-regexp": "^1.7.0"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=14.15.4 <19"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "bcf63de23d1a2a53fb0e961dba4396e8753710dd"
|
|
57
57
|
}
|