@arcgis/toolkit 5.0.0-next.30 → 5.0.0-next.31
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/dist/log/index.cjs +11 -10
- package/dist/log/index.d.cts +26 -11
- package/dist/log/index.d.ts +26 -11
- package/dist/log/index.js +11 -10
- package/package.json +1 -1
package/dist/log/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@ const getContextString = (context) => {
|
|
|
19
19
|
};
|
|
20
20
|
const log = (level, context, message, options) => {
|
|
21
21
|
const contextString = getContextString(context);
|
|
22
|
-
if (options
|
|
22
|
+
if (options?.once) {
|
|
23
23
|
const key = `${level}${contextString}${message}`;
|
|
24
24
|
if (loggedMessages.has(key)) {
|
|
25
25
|
return;
|
|
@@ -29,19 +29,20 @@ const log = (level, context, message, options) => {
|
|
|
29
29
|
esriConfig?.log.interceptors?.forEach((interceptor) => interceptor(level, contextString, message));
|
|
30
30
|
console[level](`[${contextString}]`, message);
|
|
31
31
|
};
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
32
|
+
const composeMissingPropertyMessage = (property) => (
|
|
33
|
+
//#endregion composeMissingPropertyMessage
|
|
34
|
+
`The property \`${property.toString()}\` is required but missing.`
|
|
35
|
+
);
|
|
36
|
+
const composeEmptyPropertyMessage = (property) => (
|
|
37
|
+
//#endregion composeEmptyPropertyMessage
|
|
38
|
+
`The property \`${property.toString()}\` is empty but must have at least one element.`
|
|
39
|
+
);
|
|
40
40
|
const logDeprecatedProperty = (context, oldName, newName, options) => (
|
|
41
41
|
//#endregion logDeprecatedProperty
|
|
42
42
|
log("warn", context, `\`${oldName.toString()}\` is deprecated. Use \`${newName.toString()}\` instead.`, options)
|
|
43
43
|
);
|
|
44
|
+
exports.composeEmptyPropertyMessage = composeEmptyPropertyMessage;
|
|
45
|
+
exports.composeMissingPropertyMessage = composeMissingPropertyMessage;
|
|
44
46
|
exports.log = log;
|
|
45
47
|
exports.logDeprecatedProperty = logDeprecatedProperty;
|
|
46
|
-
exports.logIfMissingProperty = logIfMissingProperty;
|
|
47
48
|
exports.setEsriConfig = setEsriConfig;
|
package/dist/log/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type LogLevel = "error" | "info" | "warn";
|
|
1
|
+
export type LogLevel = "error" | "info" | "warn";
|
|
2
2
|
type CustomElementLike = {
|
|
3
3
|
el: {
|
|
4
4
|
localName: string;
|
|
@@ -9,9 +9,8 @@ type CustomElementLike = {
|
|
|
9
9
|
type AccessorLike = {
|
|
10
10
|
declaredClass: string;
|
|
11
11
|
};
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
type LoggerOptions = {
|
|
12
|
+
export type LogContext = AccessorLike | CustomElementLike | string;
|
|
13
|
+
type LogOptions = {
|
|
15
14
|
/** Whether the message should only be logged once */
|
|
16
15
|
once?: boolean;
|
|
17
16
|
};
|
|
@@ -55,17 +54,33 @@ export declare const setEsriConfig: (config: EsriConfig) => void;
|
|
|
55
54
|
* );
|
|
56
55
|
* ```
|
|
57
56
|
*/
|
|
58
|
-
export declare const log:
|
|
57
|
+
export declare const log: (level: LogLevel, context: LogContext, message: unknown, options?: LogOptions) => void;
|
|
58
|
+
type LogContextOrObject = Exclude<LogContext, string> | object;
|
|
59
|
+
type InferPropertyType<T extends LogContextOrObject> = [object] extends [T] ? string : keyof T;
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @param property The
|
|
62
|
-
* @param params Parameters to forward to the logger
|
|
61
|
+
* Returns a string that can be used in log messages for missing required properties.
|
|
62
|
+
* @param property The name of the required property
|
|
63
63
|
* @example
|
|
64
64
|
* ```ts
|
|
65
|
-
*
|
|
65
|
+
* // returns "The property `x` is required but missing."
|
|
66
|
+
* composeMissingPropertyMessage<YourClass>("x");
|
|
67
|
+
* // you don't need to provide a generic type argument if you don't have one
|
|
68
|
+
* composeMissingPropertyMessage("object.sub.property");
|
|
66
69
|
* ```
|
|
67
70
|
*/
|
|
68
|
-
export declare const
|
|
71
|
+
export declare const composeMissingPropertyMessage: <T extends LogContextOrObject = object>(property: InferPropertyType<T>) => string;
|
|
72
|
+
/**
|
|
73
|
+
* Returns a string that can be used in log messages for empty required arrays.
|
|
74
|
+
* @param property The name of the required property
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* // returns "The property `x` is empty but must have at least one element."
|
|
78
|
+
* composeEmptyPropertyMessage<YourClass>("x");
|
|
79
|
+
* // you don't need to provide a generic type argument if you don't have one
|
|
80
|
+
* composeEmptyPropertyMessage("object.sub.property");
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare const composeEmptyPropertyMessage: <T extends LogContextOrObject = object>(property: InferPropertyType<T>) => string;
|
|
69
84
|
/**
|
|
70
85
|
* Logs a warning message for deprecated object properties.
|
|
71
86
|
* @example
|
|
@@ -75,5 +90,5 @@ export declare const logIfMissingProperty: <T extends ErrorContext>(level: LogLe
|
|
|
75
90
|
* });
|
|
76
91
|
* ```
|
|
77
92
|
*/
|
|
78
|
-
export declare const logDeprecatedProperty: <T extends
|
|
93
|
+
export declare const logDeprecatedProperty: <T extends LogContext>(context: T, oldName: keyof T, newName: keyof T, options?: LogOptions) => ReturnType<typeof log>;
|
|
79
94
|
export {};
|
package/dist/log/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type LogLevel = "error" | "info" | "warn";
|
|
1
|
+
export type LogLevel = "error" | "info" | "warn";
|
|
2
2
|
type CustomElementLike = {
|
|
3
3
|
el: {
|
|
4
4
|
localName: string;
|
|
@@ -9,9 +9,8 @@ type CustomElementLike = {
|
|
|
9
9
|
type AccessorLike = {
|
|
10
10
|
declaredClass: string;
|
|
11
11
|
};
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
type LoggerOptions = {
|
|
12
|
+
export type LogContext = AccessorLike | CustomElementLike | string;
|
|
13
|
+
type LogOptions = {
|
|
15
14
|
/** Whether the message should only be logged once */
|
|
16
15
|
once?: boolean;
|
|
17
16
|
};
|
|
@@ -55,17 +54,33 @@ export declare const setEsriConfig: (config: EsriConfig) => void;
|
|
|
55
54
|
* );
|
|
56
55
|
* ```
|
|
57
56
|
*/
|
|
58
|
-
export declare const log:
|
|
57
|
+
export declare const log: (level: LogLevel, context: LogContext, message: unknown, options?: LogOptions) => void;
|
|
58
|
+
type LogContextOrObject = Exclude<LogContext, string> | object;
|
|
59
|
+
type InferPropertyType<T extends LogContextOrObject> = [object] extends [T] ? string : keyof T;
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @param property The
|
|
62
|
-
* @param params Parameters to forward to the logger
|
|
61
|
+
* Returns a string that can be used in log messages for missing required properties.
|
|
62
|
+
* @param property The name of the required property
|
|
63
63
|
* @example
|
|
64
64
|
* ```ts
|
|
65
|
-
*
|
|
65
|
+
* // returns "The property `x` is required but missing."
|
|
66
|
+
* composeMissingPropertyMessage<YourClass>("x");
|
|
67
|
+
* // you don't need to provide a generic type argument if you don't have one
|
|
68
|
+
* composeMissingPropertyMessage("object.sub.property");
|
|
66
69
|
* ```
|
|
67
70
|
*/
|
|
68
|
-
export declare const
|
|
71
|
+
export declare const composeMissingPropertyMessage: <T extends LogContextOrObject = object>(property: InferPropertyType<T>) => string;
|
|
72
|
+
/**
|
|
73
|
+
* Returns a string that can be used in log messages for empty required arrays.
|
|
74
|
+
* @param property The name of the required property
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* // returns "The property `x` is empty but must have at least one element."
|
|
78
|
+
* composeEmptyPropertyMessage<YourClass>("x");
|
|
79
|
+
* // you don't need to provide a generic type argument if you don't have one
|
|
80
|
+
* composeEmptyPropertyMessage("object.sub.property");
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare const composeEmptyPropertyMessage: <T extends LogContextOrObject = object>(property: InferPropertyType<T>) => string;
|
|
69
84
|
/**
|
|
70
85
|
* Logs a warning message for deprecated object properties.
|
|
71
86
|
* @example
|
|
@@ -75,5 +90,5 @@ export declare const logIfMissingProperty: <T extends ErrorContext>(level: LogLe
|
|
|
75
90
|
* });
|
|
76
91
|
* ```
|
|
77
92
|
*/
|
|
78
|
-
export declare const logDeprecatedProperty: <T extends
|
|
93
|
+
export declare const logDeprecatedProperty: <T extends LogContext>(context: T, oldName: keyof T, newName: keyof T, options?: LogOptions) => ReturnType<typeof log>;
|
|
79
94
|
export {};
|
package/dist/log/index.js
CHANGED
|
@@ -17,7 +17,7 @@ const getContextString = (context) => {
|
|
|
17
17
|
};
|
|
18
18
|
const log = (level, context, message, options) => {
|
|
19
19
|
const contextString = getContextString(context);
|
|
20
|
-
if (options
|
|
20
|
+
if (options?.once) {
|
|
21
21
|
const key = `${level}${contextString}${message}`;
|
|
22
22
|
if (loggedMessages.has(key)) {
|
|
23
23
|
return;
|
|
@@ -27,21 +27,22 @@ const log = (level, context, message, options) => {
|
|
|
27
27
|
esriConfig?.log.interceptors?.forEach((interceptor) => interceptor(level, contextString, message));
|
|
28
28
|
console[level](`[${contextString}]`, message);
|
|
29
29
|
};
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
30
|
+
const composeMissingPropertyMessage = (property) => (
|
|
31
|
+
//#endregion composeMissingPropertyMessage
|
|
32
|
+
`The property \`${property.toString()}\` is required but missing.`
|
|
33
|
+
);
|
|
34
|
+
const composeEmptyPropertyMessage = (property) => (
|
|
35
|
+
//#endregion composeEmptyPropertyMessage
|
|
36
|
+
`The property \`${property.toString()}\` is empty but must have at least one element.`
|
|
37
|
+
);
|
|
38
38
|
const logDeprecatedProperty = (context, oldName, newName, options) => (
|
|
39
39
|
//#endregion logDeprecatedProperty
|
|
40
40
|
log("warn", context, `\`${oldName.toString()}\` is deprecated. Use \`${newName.toString()}\` instead.`, options)
|
|
41
41
|
);
|
|
42
42
|
export {
|
|
43
|
+
composeEmptyPropertyMessage,
|
|
44
|
+
composeMissingPropertyMessage,
|
|
43
45
|
log,
|
|
44
46
|
logDeprecatedProperty,
|
|
45
|
-
logIfMissingProperty,
|
|
46
47
|
setEsriConfig
|
|
47
48
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/toolkit",
|
|
3
|
-
"version": "5.0.0-next.
|
|
3
|
+
"version": "5.0.0-next.31",
|
|
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,
|