lifecycleion 0.0.5 → 0.0.6
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 +1 -1
- package/dist/lib/curly-brackets.cjs +37 -6
- package/dist/lib/curly-brackets.cjs.map +1 -1
- package/dist/lib/curly-brackets.js +37 -6
- package/dist/lib/curly-brackets.js.map +1 -1
- package/dist/lib/logger/index.cjs +43 -6
- package/dist/lib/logger/index.cjs.map +1 -1
- package/dist/lib/logger/index.js +43 -6
- package/dist/lib/logger/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,16 +25,44 @@ __export(curly_brackets_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(curly_brackets_exports);
|
|
26
26
|
|
|
27
27
|
// src/lib/internal/path-utils.ts
|
|
28
|
-
var PATH_SEGMENT_PATTERN =
|
|
28
|
+
var PATH_SEGMENT_PATTERN = /(\w+)|\[(\d+)\]|\["((?:[^"\\]|\\.)*)"\]|\['((?:[^'\\]|\\.)*)'\]/y;
|
|
29
|
+
function unescapeQuotedPathPart(value) {
|
|
30
|
+
return value.replace(/\\(["'\\])/g, "$1");
|
|
31
|
+
}
|
|
29
32
|
function getPathParts(path) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
const parts = [];
|
|
34
|
+
let index = 0;
|
|
35
|
+
while (index < path.length) {
|
|
36
|
+
if (path[index] === ".") {
|
|
37
|
+
index++;
|
|
38
|
+
if (index >= path.length) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
PATH_SEGMENT_PATTERN.lastIndex = index;
|
|
43
|
+
const match = PATH_SEGMENT_PATTERN.exec(path);
|
|
44
|
+
if (!match) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
if (match[1] !== void 0) {
|
|
48
|
+
parts.push(match[1]);
|
|
49
|
+
} else if (match[2] !== void 0) {
|
|
50
|
+
parts.push(match[2]);
|
|
51
|
+
} else if (match[3] !== void 0) {
|
|
52
|
+
parts.push(unescapeQuotedPathPart(match[3]));
|
|
53
|
+
} else if (match[4] !== void 0) {
|
|
54
|
+
parts.push(unescapeQuotedPathPart(match[4]));
|
|
55
|
+
}
|
|
56
|
+
index = PATH_SEGMENT_PATTERN.lastIndex;
|
|
57
|
+
if (index < path.length && path[index] !== "." && path[index] !== "[") {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return parts;
|
|
34
62
|
}
|
|
35
63
|
|
|
36
64
|
// src/lib/curly-brackets.ts
|
|
37
|
-
var PLACEHOLDER_PATTERN = /(?:\\)?{{(\s
|
|
65
|
+
var PLACEHOLDER_PATTERN = /(?:\\)?{{(\s*[^{}]+?\s*)(?:\\)?\s*}}/g;
|
|
38
66
|
var CurlyBrackets = function(str = "", locals = {}, fallback = "(null)") {
|
|
39
67
|
if (!str.includes("{{")) {
|
|
40
68
|
return str;
|
|
@@ -62,6 +90,9 @@ CurlyBrackets.compileTemplate = function(str, fallback = "(null)") {
|
|
|
62
90
|
}
|
|
63
91
|
const key = p1.trim();
|
|
64
92
|
const parts = getPathParts(key);
|
|
93
|
+
if (!parts || parts.length === 0) {
|
|
94
|
+
return match;
|
|
95
|
+
}
|
|
65
96
|
let replacement = locals;
|
|
66
97
|
for (const part of parts) {
|
|
67
98
|
if (replacement !== void 0 && replacement !== null && typeof replacement === "object" && part in replacement) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/curly-brackets.ts","../../src/lib/internal/path-utils.ts"],"sourcesContent":["import { getPathParts } from './internal/path-utils';\n\nexport type TemplateFunction = (locals: Record<string, unknown>) => string;\n\ninterface CurlyBracketsFunction {\n (str?: string, locals?: Record<string, unknown>, fallback?: string): string;\n compileTemplate: (str: string, fallback?: string) => TemplateFunction;\n escape: (str: string) => string;\n}\n\nconst PLACEHOLDER_PATTERN
|
|
1
|
+
{"version":3,"sources":["../../src/lib/curly-brackets.ts","../../src/lib/internal/path-utils.ts"],"sourcesContent":["import { getPathParts } from './internal/path-utils';\n\nexport type TemplateFunction = (locals: Record<string, unknown>) => string;\n\ninterface CurlyBracketsFunction {\n (str?: string, locals?: Record<string, unknown>, fallback?: string): string;\n compileTemplate: (str: string, fallback?: string) => TemplateFunction;\n escape: (str: string) => string;\n}\n\nconst PLACEHOLDER_PATTERN = /(?:\\\\)?{{(\\s*[^{}]+?\\s*)(?:\\\\)?\\s*}}/g;\n\n/**\n * Processes a template string, replacing placeholders with corresponding values from a provided object.\n *\n * @param {string} str - The template string to process.\n * @param locals - An object containing key-value pairs for placeholder replacement.\n * @param fallback - A default string to use when a placeholder's corresponding value is not found.\n * @returns - The processed string with placeholders replaced by their corresponding values.\n */\n\nconst CurlyBrackets: CurlyBracketsFunction = function (\n str: string = '',\n locals: Record<string, unknown> = {},\n fallback: string = '(null)',\n): string {\n // Short-circuit if no brackets - no need to process\n if (!str.includes('{{')) {\n return str;\n }\n\n const compiled = CurlyBrackets.compileTemplate(str, fallback);\n\n return compiled(locals);\n} as CurlyBracketsFunction;\n\n/**\n * Compiles a template string into a reusable function, which can be called with different sets of locals.\n * This is more efficient when you have a template that you want to use with different sets of locals,\n * as it avoids the overhead of parsing the template string each time it is used.\n *\n * @param {string} str - The template string to compile.\n * @param {string} fallback - A default string to use when a placeholder's corresponding value is not found in locals.\n * @returns A function that takes an object of locals and returns a processed string.\n */\n\nCurlyBrackets.compileTemplate = function (\n str: string,\n fallback: string = '(null)',\n): TemplateFunction {\n return (locals: Record<string, unknown>): string => {\n return str.replace(PLACEHOLDER_PATTERN, (match, p1: string) => {\n if (typeof p1 !== 'string') {\n return match;\n }\n\n const hasLeadingEscape = match.startsWith('\\\\');\n const hasEndingEscape = match.endsWith('\\\\}}');\n const isFullyEscaped = hasLeadingEscape && hasEndingEscape;\n\n if (isFullyEscaped) {\n return match.slice(1, -3) + '}}';\n }\n\n if (hasLeadingEscape) {\n return match.slice(1);\n }\n\n if (hasEndingEscape) {\n return '{{' + p1.trim() + '}}';\n }\n\n const key = p1.trim();\n const parts = getPathParts(key);\n\n if (!parts || parts.length === 0) {\n return match;\n }\n\n // Use a more specific approach to ensure the type is consistent\n let replacement: unknown = locals;\n\n for (const part of parts) {\n if (\n replacement !== undefined &&\n replacement !== null &&\n typeof replacement === 'object' &&\n part in replacement\n ) {\n replacement = (replacement as Record<string, unknown>)[part];\n } else {\n replacement = undefined;\n break;\n }\n }\n\n if (replacement === undefined || replacement === null) {\n return fallback;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n return String(replacement);\n });\n };\n};\n\n/**\n * Escapes placeholders in a string by prefixing them with a backslash, preventing them from being replaced when processed.\n *\n * @param {string} str - The string in which to escape placeholders.\n * @returns {string} - The string with placeholders escaped.\n */\n\nCurlyBrackets.escape = function (str: string): string {\n // Use a regex to replace instances of {{ and }} that are not already preceded by a backslash\n return str\n .replace(/(\\\\)?{{/g, (match, backslash) => (backslash ? match : '\\\\{{'))\n .replace(/(\\\\)?}}/g, (match, backslash) => (backslash ? match : '\\\\}}'));\n};\n\nexport { CurlyBrackets };\n","const PATH_SEGMENT_PATTERN =\n /(\\w+)|\\[(\\d+)\\]|\\[\"((?:[^\"\\\\]|\\\\.)*)\"\\]|\\['((?:[^'\\\\]|\\\\.)*)'\\]/y;\n\nfunction unescapeQuotedPathPart(value: string): string {\n return value.replace(/\\\\([\"'\\\\])/g, '$1');\n}\n\n/**\n * Parses a mixed object/array path such as \"user.roles[0].name\" into lookup parts.\n */\nexport function getPathParts(path: string): string[] | null {\n const parts: string[] = [];\n let index = 0;\n\n while (index < path.length) {\n if (path[index] === '.') {\n index++;\n\n if (index >= path.length) {\n return null;\n }\n }\n\n PATH_SEGMENT_PATTERN.lastIndex = index;\n const match = PATH_SEGMENT_PATTERN.exec(path);\n\n if (!match) {\n return null;\n }\n\n if (match[1] !== undefined) {\n parts.push(match[1]);\n } else if (match[2] !== undefined) {\n parts.push(match[2]);\n } else if (match[3] !== undefined) {\n parts.push(unescapeQuotedPathPart(match[3]));\n } else if (match[4] !== undefined) {\n parts.push(unescapeQuotedPathPart(match[4]));\n }\n\n index = PATH_SEGMENT_PATTERN.lastIndex;\n\n if (index < path.length && path[index] !== '.' && path[index] !== '[') {\n return null;\n }\n }\n\n return parts;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,uBACJ;AAEF,SAAS,uBAAuB,OAAuB;AACrD,SAAO,MAAM,QAAQ,eAAe,IAAI;AAC1C;AAKO,SAAS,aAAa,MAA+B;AAC1D,QAAM,QAAkB,CAAC;AACzB,MAAI,QAAQ;AAEZ,SAAO,QAAQ,KAAK,QAAQ;AAC1B,QAAI,KAAK,KAAK,MAAM,KAAK;AACvB;AAEA,UAAI,SAAS,KAAK,QAAQ;AACxB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,yBAAqB,YAAY;AACjC,UAAM,QAAQ,qBAAqB,KAAK,IAAI;AAE5C,QAAI,CAAC,OAAO;AACV,aAAO;AAAA,IACT;AAEA,QAAI,MAAM,CAAC,MAAM,QAAW;AAC1B,YAAM,KAAK,MAAM,CAAC,CAAC;AAAA,IACrB,WAAW,MAAM,CAAC,MAAM,QAAW;AACjC,YAAM,KAAK,MAAM,CAAC,CAAC;AAAA,IACrB,WAAW,MAAM,CAAC,MAAM,QAAW;AACjC,YAAM,KAAK,uBAAuB,MAAM,CAAC,CAAC,CAAC;AAAA,IAC7C,WAAW,MAAM,CAAC,MAAM,QAAW;AACjC,YAAM,KAAK,uBAAuB,MAAM,CAAC,CAAC,CAAC;AAAA,IAC7C;AAEA,YAAQ,qBAAqB;AAE7B,QAAI,QAAQ,KAAK,UAAU,KAAK,KAAK,MAAM,OAAO,KAAK,KAAK,MAAM,KAAK;AACrE,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;;;ADtCA,IAAM,sBAAsB;AAW5B,IAAM,gB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AQ,MAAO,EACtE,QAAQ,YAAY,CAAC,OAAO,cAAe,YAAY,QAAQ,MAAO;AAC3E;","names":[]}
|
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
// src/lib/internal/path-utils.ts
|
|
2
|
-
var PATH_SEGMENT_PATTERN =
|
|
2
|
+
var PATH_SEGMENT_PATTERN = /(\w+)|\[(\d+)\]|\["((?:[^"\\]|\\.)*)"\]|\['((?:[^'\\]|\\.)*)'\]/y;
|
|
3
|
+
function unescapeQuotedPathPart(value) {
|
|
4
|
+
return value.replace(/\\(["'\\])/g, "$1");
|
|
5
|
+
}
|
|
3
6
|
function getPathParts(path) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const parts = [];
|
|
8
|
+
let index = 0;
|
|
9
|
+
while (index < path.length) {
|
|
10
|
+
if (path[index] === ".") {
|
|
11
|
+
index++;
|
|
12
|
+
if (index >= path.length) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
PATH_SEGMENT_PATTERN.lastIndex = index;
|
|
17
|
+
const match = PATH_SEGMENT_PATTERN.exec(path);
|
|
18
|
+
if (!match) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (match[1] !== void 0) {
|
|
22
|
+
parts.push(match[1]);
|
|
23
|
+
} else if (match[2] !== void 0) {
|
|
24
|
+
parts.push(match[2]);
|
|
25
|
+
} else if (match[3] !== void 0) {
|
|
26
|
+
parts.push(unescapeQuotedPathPart(match[3]));
|
|
27
|
+
} else if (match[4] !== void 0) {
|
|
28
|
+
parts.push(unescapeQuotedPathPart(match[4]));
|
|
29
|
+
}
|
|
30
|
+
index = PATH_SEGMENT_PATTERN.lastIndex;
|
|
31
|
+
if (index < path.length && path[index] !== "." && path[index] !== "[") {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return parts;
|
|
8
36
|
}
|
|
9
37
|
|
|
10
38
|
// src/lib/curly-brackets.ts
|
|
11
|
-
var PLACEHOLDER_PATTERN = /(?:\\)?{{(\s
|
|
39
|
+
var PLACEHOLDER_PATTERN = /(?:\\)?{{(\s*[^{}]+?\s*)(?:\\)?\s*}}/g;
|
|
12
40
|
var CurlyBrackets = function(str = "", locals = {}, fallback = "(null)") {
|
|
13
41
|
if (!str.includes("{{")) {
|
|
14
42
|
return str;
|
|
@@ -36,6 +64,9 @@ CurlyBrackets.compileTemplate = function(str, fallback = "(null)") {
|
|
|
36
64
|
}
|
|
37
65
|
const key = p1.trim();
|
|
38
66
|
const parts = getPathParts(key);
|
|
67
|
+
if (!parts || parts.length === 0) {
|
|
68
|
+
return match;
|
|
69
|
+
}
|
|
39
70
|
let replacement = locals;
|
|
40
71
|
for (const part of parts) {
|
|
41
72
|
if (replacement !== void 0 && replacement !== null && typeof replacement === "object" && part in replacement) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/internal/path-utils.ts","../../src/lib/curly-brackets.ts"],"sourcesContent":["const PATH_SEGMENT_PATTERN
|
|
1
|
+
{"version":3,"sources":["../../src/lib/internal/path-utils.ts","../../src/lib/curly-brackets.ts"],"sourcesContent":["const PATH_SEGMENT_PATTERN =\n /(\\w+)|\\[(\\d+)\\]|\\[\"((?:[^\"\\\\]|\\\\.)*)\"\\]|\\['((?:[^'\\\\]|\\\\.)*)'\\]/y;\n\nfunction unescapeQuotedPathPart(value: string): string {\n return value.replace(/\\\\([\"'\\\\])/g, '$1');\n}\n\n/**\n * Parses a mixed object/array path such as \"user.roles[0].name\" into lookup parts.\n */\nexport function getPathParts(path: string): string[] | null {\n const parts: string[] = [];\n let index = 0;\n\n while (index < path.length) {\n if (path[index] === '.') {\n index++;\n\n if (index >= path.length) {\n return null;\n }\n }\n\n PATH_SEGMENT_PATTERN.lastIndex = index;\n const match = PATH_SEGMENT_PATTERN.exec(path);\n\n if (!match) {\n return null;\n }\n\n if (match[1] !== undefined) {\n parts.push(match[1]);\n } else if (match[2] !== undefined) {\n parts.push(match[2]);\n } else if (match[3] !== undefined) {\n parts.push(unescapeQuotedPathPart(match[3]));\n } else if (match[4] !== undefined) {\n parts.push(unescapeQuotedPathPart(match[4]));\n }\n\n index = PATH_SEGMENT_PATTERN.lastIndex;\n\n if (index < path.length && path[index] !== '.' && path[index] !== '[') {\n return null;\n }\n }\n\n return parts;\n}\n","import { getPathParts } from './internal/path-utils';\n\nexport type TemplateFunction = (locals: Record<string, unknown>) => string;\n\ninterface CurlyBracketsFunction {\n (str?: string, locals?: Record<string, unknown>, fallback?: string): string;\n compileTemplate: (str: string, fallback?: string) => TemplateFunction;\n escape: (str: string) => string;\n}\n\nconst PLACEHOLDER_PATTERN = /(?:\\\\)?{{(\\s*[^{}]+?\\s*)(?:\\\\)?\\s*}}/g;\n\n/**\n * Processes a template string, replacing placeholders with corresponding values from a provided object.\n *\n * @param {string} str - The template string to process.\n * @param locals - An object containing key-value pairs for placeholder replacement.\n * @param fallback - A default string to use when a placeholder's corresponding value is not found.\n * @returns - The processed string with placeholders replaced by their corresponding values.\n */\n\nconst CurlyBrackets: CurlyBracketsFunction = function (\n str: string = '',\n locals: Record<string, unknown> = {},\n fallback: string = '(null)',\n): string {\n // Short-circuit if no brackets - no need to process\n if (!str.includes('{{')) {\n return str;\n }\n\n const compiled = CurlyBrackets.compileTemplate(str, fallback);\n\n return compiled(locals);\n} as CurlyBracketsFunction;\n\n/**\n * Compiles a template string into a reusable function, which can be called with different sets of locals.\n * This is more efficient when you have a template that you want to use with different sets of locals,\n * as it avoids the overhead of parsing the template string each time it is used.\n *\n * @param {string} str - The template string to compile.\n * @param {string} fallback - A default string to use when a placeholder's corresponding value is not found in locals.\n * @returns A function that takes an object of locals and returns a processed string.\n */\n\nCurlyBrackets.compileTemplate = function (\n str: string,\n fallback: string = '(null)',\n): TemplateFunction {\n return (locals: Record<string, unknown>): string => {\n return str.replace(PLACEHOLDER_PATTERN, (match, p1: string) => {\n if (typeof p1 !== 'string') {\n return match;\n }\n\n const hasLeadingEscape = match.startsWith('\\\\');\n const hasEndingEscape = match.endsWith('\\\\}}');\n const isFullyEscaped = hasLeadingEscape && hasEndingEscape;\n\n if (isFullyEscaped) {\n return match.slice(1, -3) + '}}';\n }\n\n if (hasLeadingEscape) {\n return match.slice(1);\n }\n\n if (hasEndingEscape) {\n return '{{' + p1.trim() + '}}';\n }\n\n const key = p1.trim();\n const parts = getPathParts(key);\n\n if (!parts || parts.length === 0) {\n return match;\n }\n\n // Use a more specific approach to ensure the type is consistent\n let replacement: unknown = locals;\n\n for (const part of parts) {\n if (\n replacement !== undefined &&\n replacement !== null &&\n typeof replacement === 'object' &&\n part in replacement\n ) {\n replacement = (replacement as Record<string, unknown>)[part];\n } else {\n replacement = undefined;\n break;\n }\n }\n\n if (replacement === undefined || replacement === null) {\n return fallback;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\n return String(replacement);\n });\n };\n};\n\n/**\n * Escapes placeholders in a string by prefixing them with a backslash, preventing them from being replaced when processed.\n *\n * @param {string} str - The string in which to escape placeholders.\n * @returns {string} - The string with placeholders escaped.\n */\n\nCurlyBrackets.escape = function (str: string): string {\n // Use a regex to replace instances of {{ and }} that are not already preceded by a backslash\n return str\n .replace(/(\\\\)?{{/g, (match, backslash) => (backslash ? match : '\\\\{{'))\n .replace(/(\\\\)?}}/g, (match, backslash) => (backslash ? match : '\\\\}}'));\n};\n\nexport { CurlyBrackets };\n"],"mappings":";AAAA,IAAM,uBACJ;AAEF,SAAS,uBAAuB,OAAuB;AACrD,SAAO,MAAM,QAAQ,eAAe,IAAI;AAC1C;AAKO,SAAS,aAAa,MAA+B;AAC1D,QAAM,QAAkB,CAAC;AACzB,MAAI,QAAQ;AAEZ,SAAO,QAAQ,KAAK,QAAQ;AAC1B,QAAI,KAAK,KAAK,MAAM,KAAK;AACvB;AAEA,UAAI,SAAS,KAAK,QAAQ;AACxB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,yBAAqB,YAAY;AAC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AAC;AAAA,MACtB;AAEA,UAAI,iBAAiB;AACnB,eAAO,OAAO,GAAG,KAAK,IAAI;AAAA,MAC5B;AAEA,YAAM,MAAM,GAAG,KAAK;AACpB,YAAM,QAAQ,aAAa,GAAG;AAE9B,UAAI,CAAC,SAAS,MAAM,WAAW,GAAG;AAChC,eAAO;AAAA,MACT;AAGA,UAAI,cAAuB;AAE3B,iBAAW,QAAQ,OAAO;AACxB,YACE,gBAAgB,UAChB,gBAAgB,QAChB,OAAO,gBAAgB,YACvB,QAAQ,aACR;AACA,wBAAe,YAAwC,IAAI;AAAA,QAC7D,OAAO;AACL,wBAAc;AACd;AAAA,QACF;AAAA,MACF;AAEA,UAAI,gBAAgB,UAAa,gBAAgB,MAAM;AACrD,eAAO;AAAA,MACT;AAGA,aAAO,OAAO,WAAW;AAAA,IAC3B,CAAC;AAAA,EACH;AACF;AASA,cAAc,SAAS,SAAU,KAAqB;AAEpD,SAAO,IACJ,QAAQ,YAAY,CAAC,OAAO,cAAe,YAAY,QAAQ,MAAO,EACtE,QAAQ,YAAY,CAAC,OAAO,cAAe,YAAY,QAAQ,MAAO;AAC3E;","names":[]}
|
|
@@ -935,16 +935,44 @@ function ms() {
|
|
|
935
935
|
}
|
|
936
936
|
|
|
937
937
|
// src/lib/internal/path-utils.ts
|
|
938
|
-
var PATH_SEGMENT_PATTERN =
|
|
938
|
+
var PATH_SEGMENT_PATTERN = /(\w+)|\[(\d+)\]|\["((?:[^"\\]|\\.)*)"\]|\['((?:[^'\\]|\\.)*)'\]/y;
|
|
939
|
+
function unescapeQuotedPathPart(value) {
|
|
940
|
+
return value.replace(/\\(["'\\])/g, "$1");
|
|
941
|
+
}
|
|
939
942
|
function getPathParts(path) {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
943
|
+
const parts = [];
|
|
944
|
+
let index = 0;
|
|
945
|
+
while (index < path.length) {
|
|
946
|
+
if (path[index] === ".") {
|
|
947
|
+
index++;
|
|
948
|
+
if (index >= path.length) {
|
|
949
|
+
return null;
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
PATH_SEGMENT_PATTERN.lastIndex = index;
|
|
953
|
+
const match = PATH_SEGMENT_PATTERN.exec(path);
|
|
954
|
+
if (!match) {
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
if (match[1] !== void 0) {
|
|
958
|
+
parts.push(match[1]);
|
|
959
|
+
} else if (match[2] !== void 0) {
|
|
960
|
+
parts.push(match[2]);
|
|
961
|
+
} else if (match[3] !== void 0) {
|
|
962
|
+
parts.push(unescapeQuotedPathPart(match[3]));
|
|
963
|
+
} else if (match[4] !== void 0) {
|
|
964
|
+
parts.push(unescapeQuotedPathPart(match[4]));
|
|
965
|
+
}
|
|
966
|
+
index = PATH_SEGMENT_PATTERN.lastIndex;
|
|
967
|
+
if (index < path.length && path[index] !== "." && path[index] !== "[") {
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
return parts;
|
|
944
972
|
}
|
|
945
973
|
|
|
946
974
|
// src/lib/curly-brackets.ts
|
|
947
|
-
var PLACEHOLDER_PATTERN = /(?:\\)?{{(\s
|
|
975
|
+
var PLACEHOLDER_PATTERN = /(?:\\)?{{(\s*[^{}]+?\s*)(?:\\)?\s*}}/g;
|
|
948
976
|
var CurlyBrackets = function(str = "", locals = {}, fallback = "(null)") {
|
|
949
977
|
if (!str.includes("{{")) {
|
|
950
978
|
return str;
|
|
@@ -972,6 +1000,9 @@ CurlyBrackets.compileTemplate = function(str, fallback = "(null)") {
|
|
|
972
1000
|
}
|
|
973
1001
|
const key = p1.trim();
|
|
974
1002
|
const parts = getPathParts(key);
|
|
1003
|
+
if (!parts || parts.length === 0) {
|
|
1004
|
+
return match;
|
|
1005
|
+
}
|
|
975
1006
|
let replacement = locals;
|
|
976
1007
|
for (const part of parts) {
|
|
977
1008
|
if (replacement !== void 0 && replacement !== null && typeof replacement === "object" && part in replacement) {
|
|
@@ -1318,6 +1349,9 @@ var defaultRedactFunction = (_keyName, value) => {
|
|
|
1318
1349
|
};
|
|
1319
1350
|
function setNestedValue(obj, path, value) {
|
|
1320
1351
|
const parts = getPathParts(path);
|
|
1352
|
+
if (!parts || parts.length === 0) {
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1321
1355
|
let current = obj;
|
|
1322
1356
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
1323
1357
|
const part = parts[i];
|
|
@@ -1337,6 +1371,9 @@ function setNestedValue(obj, path, value) {
|
|
|
1337
1371
|
}
|
|
1338
1372
|
function getNestedValue(obj, path) {
|
|
1339
1373
|
const parts = getPathParts(path);
|
|
1374
|
+
if (!parts || parts.length === 0) {
|
|
1375
|
+
return void 0;
|
|
1376
|
+
}
|
|
1340
1377
|
let current = obj;
|
|
1341
1378
|
for (const part of parts) {
|
|
1342
1379
|
if (current === void 0 || current === null || typeof current !== "object" || !(part in current)) {
|