@arcgis/toolkit 5.1.0-next.98 → 5.2.0-next.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/README.md +2 -2
- package/dist/string/index.cjs +28 -0
- package/dist/string/index.d.cts +21 -0
- package/dist/string/index.d.ts +21 -0
- package/dist/string/index.js +28 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,5 +8,5 @@ It is not intended to be used directly, but rather used as a dependency by other
|
|
|
8
8
|
|
|
9
9
|
## License
|
|
10
10
|
|
|
11
|
-
This package is licensed under the terms described in the `LICENSE.md` file, located in the root of the package, and at https://js.arcgis.com/5.
|
|
12
|
-
For third party notices, see https://js.arcgis.com/5.
|
|
11
|
+
This package is licensed under the terms described in the `LICENSE.md` file, located in the root of the package, and at https://js.arcgis.com/5.1/LICENSE.txt.
|
|
12
|
+
For third party notices, see https://js.arcgis.com/5.1/third-party-notices.txt.
|
package/dist/string/index.cjs
CHANGED
|
@@ -75,11 +75,39 @@ const getPreamble = (version) => (
|
|
|
75
75
|
`COPYRIGHT Esri - https://js.arcgis.com/${getMinorVersion(version)}/LICENSE.txt`
|
|
76
76
|
);
|
|
77
77
|
const setValuesInString = (message, values = {}) => (message ?? "").replace(/\{(?<valueName>.*?)\}/gu, (match, valueName) => values[valueName] ?? match);
|
|
78
|
+
const regionStartPattern = /^\s*\/\/\s*#region(?::)?\s*(?<regionName>.*?)\s*$/u;
|
|
79
|
+
const regionAnyStartPattern = /^\s*\/\/\s*#region(?::)?\s*.*$/u;
|
|
80
|
+
const regionEndPattern = /^\s*\/\/\s*#endregion(?::)?(?:\s+.*)?\s*$/u;
|
|
81
|
+
const extractRegion = (source, regionName) => {
|
|
82
|
+
const lines = source.split(/\r?\n/gu);
|
|
83
|
+
const startLineIndex = lines.findIndex((line) => regionStartPattern.exec(line)?.groups?.regionName === regionName);
|
|
84
|
+
if (startLineIndex === -1) {
|
|
85
|
+
throw new Error(`Unable to locate source region "${regionName}".`);
|
|
86
|
+
}
|
|
87
|
+
let nestedRegionDepth = 0;
|
|
88
|
+
for (let lineIndex = startLineIndex + 1; lineIndex < lines.length; lineIndex++) {
|
|
89
|
+
const line = lines[lineIndex];
|
|
90
|
+
if (regionAnyStartPattern.test(line)) {
|
|
91
|
+
nestedRegionDepth++;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (!regionEndPattern.test(line)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (nestedRegionDepth > 0) {
|
|
98
|
+
nestedRegionDepth--;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
return lines.slice(startLineIndex + 1, lineIndex).join("\n").trim();
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`Unable to locate source region end for "${regionName}".`);
|
|
104
|
+
};
|
|
78
105
|
exports.addLtrMark = addLtrMark;
|
|
79
106
|
exports.camelToHuman = camelToHuman;
|
|
80
107
|
exports.camelToKebab = camelToKebab;
|
|
81
108
|
exports.capitalize = capitalize;
|
|
82
109
|
exports.createFilterExpression = createFilterExpression;
|
|
110
|
+
exports.extractRegion = extractRegion;
|
|
83
111
|
exports.generateGuid = generateGuid;
|
|
84
112
|
exports.getMinorVersion = getMinorVersion;
|
|
85
113
|
exports.getPreamble = getPreamble;
|
package/dist/string/index.d.cts
CHANGED
|
@@ -107,3 +107,24 @@ export declare const getPreamble: (version: string) => string;
|
|
|
107
107
|
* @deprecated Import from https://next.gha.afd.arcgis.com/javascript/latest/references/core/intl/#substitute instead
|
|
108
108
|
*/
|
|
109
109
|
export declare const setValuesInString: (message: string | null | undefined, values?: Record<string, string>) => string;
|
|
110
|
+
/**
|
|
111
|
+
* Use `extractRegion` when you need to read a named `#region` block from a JavaScript/TypeScript source string,
|
|
112
|
+
* such as docs or MDX snippets that should stay in sync with the real implementation.
|
|
113
|
+
*
|
|
114
|
+
* Throws when the named region cannot be found or is missing its closing marker.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* import code from "my-code-file.ts?raw";
|
|
119
|
+
* const snippet = extractRegion(code, "myRegion");
|
|
120
|
+
*
|
|
121
|
+
* // where code is:
|
|
122
|
+
* `
|
|
123
|
+
* //#region myRegion
|
|
124
|
+
* const value = 1;
|
|
125
|
+
* //#endregion
|
|
126
|
+
* `
|
|
127
|
+
* // const value = 1;
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare const extractRegion: (source: string, regionName: string) => string;
|
package/dist/string/index.d.ts
CHANGED
|
@@ -107,3 +107,24 @@ export declare const getPreamble: (version: string) => string;
|
|
|
107
107
|
* @deprecated Import from https://next.gha.afd.arcgis.com/javascript/latest/references/core/intl/#substitute instead
|
|
108
108
|
*/
|
|
109
109
|
export declare const setValuesInString: (message: string | null | undefined, values?: Record<string, string>) => string;
|
|
110
|
+
/**
|
|
111
|
+
* Use `extractRegion` when you need to read a named `#region` block from a JavaScript/TypeScript source string,
|
|
112
|
+
* such as docs or MDX snippets that should stay in sync with the real implementation.
|
|
113
|
+
*
|
|
114
|
+
* Throws when the named region cannot be found or is missing its closing marker.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* import code from "my-code-file.ts?raw";
|
|
119
|
+
* const snippet = extractRegion(code, "myRegion");
|
|
120
|
+
*
|
|
121
|
+
* // where code is:
|
|
122
|
+
* `
|
|
123
|
+
* //#region myRegion
|
|
124
|
+
* const value = 1;
|
|
125
|
+
* //#endregion
|
|
126
|
+
* `
|
|
127
|
+
* // const value = 1;
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare const extractRegion: (source: string, regionName: string) => string;
|
package/dist/string/index.js
CHANGED
|
@@ -73,12 +73,40 @@ const getPreamble = (version) => (
|
|
|
73
73
|
`COPYRIGHT Esri - https://js.arcgis.com/${getMinorVersion(version)}/LICENSE.txt`
|
|
74
74
|
);
|
|
75
75
|
const setValuesInString = (message, values = {}) => (message ?? "").replace(/\{(?<valueName>.*?)\}/gu, (match, valueName) => values[valueName] ?? match);
|
|
76
|
+
const regionStartPattern = /^\s*\/\/\s*#region(?::)?\s*(?<regionName>.*?)\s*$/u;
|
|
77
|
+
const regionAnyStartPattern = /^\s*\/\/\s*#region(?::)?\s*.*$/u;
|
|
78
|
+
const regionEndPattern = /^\s*\/\/\s*#endregion(?::)?(?:\s+.*)?\s*$/u;
|
|
79
|
+
const extractRegion = (source, regionName) => {
|
|
80
|
+
const lines = source.split(/\r?\n/gu);
|
|
81
|
+
const startLineIndex = lines.findIndex((line) => regionStartPattern.exec(line)?.groups?.regionName === regionName);
|
|
82
|
+
if (startLineIndex === -1) {
|
|
83
|
+
throw new Error(`Unable to locate source region "${regionName}".`);
|
|
84
|
+
}
|
|
85
|
+
let nestedRegionDepth = 0;
|
|
86
|
+
for (let lineIndex = startLineIndex + 1; lineIndex < lines.length; lineIndex++) {
|
|
87
|
+
const line = lines[lineIndex];
|
|
88
|
+
if (regionAnyStartPattern.test(line)) {
|
|
89
|
+
nestedRegionDepth++;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (!regionEndPattern.test(line)) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (nestedRegionDepth > 0) {
|
|
96
|
+
nestedRegionDepth--;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
return lines.slice(startLineIndex + 1, lineIndex).join("\n").trim();
|
|
100
|
+
}
|
|
101
|
+
throw new Error(`Unable to locate source region end for "${regionName}".`);
|
|
102
|
+
};
|
|
76
103
|
export {
|
|
77
104
|
addLtrMark,
|
|
78
105
|
camelToHuman,
|
|
79
106
|
camelToKebab,
|
|
80
107
|
capitalize,
|
|
81
108
|
createFilterExpression,
|
|
109
|
+
extractRegion,
|
|
82
110
|
generateGuid,
|
|
83
111
|
getMinorVersion,
|
|
84
112
|
getPreamble,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/toolkit",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0-next.0",
|
|
4
4
|
"description": "Collection of common internal patterns and utilities for ArcGIS Maps SDK for JavaScript components.",
|
|
5
5
|
"homepage": "https://developers.arcgis.com/javascript/latest/",
|
|
6
6
|
"sideEffects": false,
|