@lwrjs/shared-utils 0.11.0-alpha.8 → 0.11.0-alpha.9
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/identity.cjs +9 -1
- package/build/es/identity.d.ts +5 -0
- package/build/es/identity.js +14 -0
- package/package.json +4 -4
package/build/cjs/identity.cjs
CHANGED
|
@@ -54,7 +54,8 @@ __export(exports, {
|
|
|
54
54
|
normalizeVersionToUri: () => normalizeVersionToUri,
|
|
55
55
|
parsePackageSpecifier: () => parsePackageSpecifier,
|
|
56
56
|
prettyModuleUriSuffix: () => prettyModuleUriSuffix,
|
|
57
|
-
slugify: () => slugify
|
|
57
|
+
slugify: () => slugify,
|
|
58
|
+
stringToVariableName: () => stringToVariableName
|
|
58
59
|
});
|
|
59
60
|
var import_slugify = __toModule(require("slugify"));
|
|
60
61
|
var import_fast_json_stable_stringify = __toModule(require("fast-json-stable-stringify"));
|
|
@@ -212,3 +213,10 @@ function isAssetSourceExternal(assetSource) {
|
|
|
212
213
|
function isBundleDefinition(definition) {
|
|
213
214
|
return definition.bundleRecord !== void 0;
|
|
214
215
|
}
|
|
216
|
+
function stringToVariableName(inputString) {
|
|
217
|
+
const cleanedString = inputString.replace(/@/g, "").replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
218
|
+
if (!cleanedString || /^[0-9$]+/.test(cleanedString)) {
|
|
219
|
+
return `_${cleanedString}`;
|
|
220
|
+
}
|
|
221
|
+
return cleanedString;
|
|
222
|
+
}
|
package/build/es/identity.d.ts
CHANGED
|
@@ -141,4 +141,9 @@ export { getCacheKeyFromJson };
|
|
|
141
141
|
export declare function isExternalUrl(url: string): boolean;
|
|
142
142
|
export declare function isAssetSourceExternal(assetSource: AssetSource): boolean;
|
|
143
143
|
export declare function isBundleDefinition(definition: ModuleDefinition | BundleDefinition): definition is BundleDefinition;
|
|
144
|
+
/**
|
|
145
|
+
* Create a js safe variable name
|
|
146
|
+
* @param name - Proposed name
|
|
147
|
+
*/
|
|
148
|
+
export declare function stringToVariableName(inputString: string): string;
|
|
144
149
|
//# sourceMappingURL=identity.d.ts.map
|
package/build/es/identity.js
CHANGED
|
@@ -258,4 +258,18 @@ export function isAssetSourceExternal(assetSource) {
|
|
|
258
258
|
export function isBundleDefinition(definition) {
|
|
259
259
|
return definition.bundleRecord !== undefined;
|
|
260
260
|
}
|
|
261
|
+
/**
|
|
262
|
+
* Create a js safe variable name
|
|
263
|
+
* @param name - Proposed name
|
|
264
|
+
*/
|
|
265
|
+
export function stringToVariableName(inputString) {
|
|
266
|
+
// Remove at symbols (@)
|
|
267
|
+
// Remove non-alphanumeric characters except for underscore (_) and dollar sign ($)
|
|
268
|
+
const cleanedString = inputString.replace(/@/g, '').replace(/[^a-zA-Z0-9_$]/g, '_');
|
|
269
|
+
// Prepend an underscore if the resulting name is empty or starts with a number, underscore (_) and dollar sign ($)
|
|
270
|
+
if (!cleanedString || /^[0-9$]+/.test(cleanedString)) {
|
|
271
|
+
return `_${cleanedString}`;
|
|
272
|
+
}
|
|
273
|
+
return cleanedString;
|
|
274
|
+
}
|
|
261
275
|
//# sourceMappingURL=identity.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.11.0-alpha.
|
|
7
|
+
"version": "0.11.0-alpha.9",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"rollup": "^2.78.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@lwrjs/diagnostics": "0.11.0-alpha.
|
|
65
|
-
"@lwrjs/types": "0.11.0-alpha.
|
|
64
|
+
"@lwrjs/diagnostics": "0.11.0-alpha.9",
|
|
65
|
+
"@lwrjs/types": "0.11.0-alpha.9",
|
|
66
66
|
"@types/mime-types": "2.1.1",
|
|
67
67
|
"@types/path-to-regexp": "^1.7.0"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=16.0.0"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "bc50e3f828be56ebdd2f8206cafe8158ab722470"
|
|
73
73
|
}
|