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.
@@ -892,16 +892,44 @@ function ms() {
892
892
  }
893
893
 
894
894
  // src/lib/internal/path-utils.ts
895
- var PATH_SEGMENT_PATTERN = /\w+|\[(\d+)\]/g;
895
+ var PATH_SEGMENT_PATTERN = /(\w+)|\[(\d+)\]|\["((?:[^"\\]|\\.)*)"\]|\['((?:[^'\\]|\\.)*)'\]/y;
896
+ function unescapeQuotedPathPart(value) {
897
+ return value.replace(/\\(["'\\])/g, "$1");
898
+ }
896
899
  function getPathParts(path) {
897
- return Array.from(
898
- path.matchAll(PATH_SEGMENT_PATTERN),
899
- (match) => match[1] ?? match[0]
900
- );
900
+ const parts = [];
901
+ let index = 0;
902
+ while (index < path.length) {
903
+ if (path[index] === ".") {
904
+ index++;
905
+ if (index >= path.length) {
906
+ return null;
907
+ }
908
+ }
909
+ PATH_SEGMENT_PATTERN.lastIndex = index;
910
+ const match = PATH_SEGMENT_PATTERN.exec(path);
911
+ if (!match) {
912
+ return null;
913
+ }
914
+ if (match[1] !== void 0) {
915
+ parts.push(match[1]);
916
+ } else if (match[2] !== void 0) {
917
+ parts.push(match[2]);
918
+ } else if (match[3] !== void 0) {
919
+ parts.push(unescapeQuotedPathPart(match[3]));
920
+ } else if (match[4] !== void 0) {
921
+ parts.push(unescapeQuotedPathPart(match[4]));
922
+ }
923
+ index = PATH_SEGMENT_PATTERN.lastIndex;
924
+ if (index < path.length && path[index] !== "." && path[index] !== "[") {
925
+ return null;
926
+ }
927
+ }
928
+ return parts;
901
929
  }
902
930
 
903
931
  // src/lib/curly-brackets.ts
904
- var PLACEHOLDER_PATTERN = /(?:\\)?{{(\s*\w+(?:\[\d+\])*(?:\.\w+(?:\[\d+\])*)*\s*)(?:\\)?\s*}}/g;
932
+ var PLACEHOLDER_PATTERN = /(?:\\)?{{(\s*[^{}]+?\s*)(?:\\)?\s*}}/g;
905
933
  var CurlyBrackets = function(str = "", locals = {}, fallback = "(null)") {
906
934
  if (!str.includes("{{")) {
907
935
  return str;
@@ -929,6 +957,9 @@ CurlyBrackets.compileTemplate = function(str, fallback = "(null)") {
929
957
  }
930
958
  const key = p1.trim();
931
959
  const parts = getPathParts(key);
960
+ if (!parts || parts.length === 0) {
961
+ return match;
962
+ }
932
963
  let replacement = locals;
933
964
  for (const part of parts) {
934
965
  if (replacement !== void 0 && replacement !== null && typeof replacement === "object" && part in replacement) {
@@ -1275,6 +1306,9 @@ var defaultRedactFunction = (_keyName, value) => {
1275
1306
  };
1276
1307
  function setNestedValue(obj, path, value) {
1277
1308
  const parts = getPathParts(path);
1309
+ if (!parts || parts.length === 0) {
1310
+ return;
1311
+ }
1278
1312
  let current = obj;
1279
1313
  for (let i = 0; i < parts.length - 1; i++) {
1280
1314
  const part = parts[i];
@@ -1294,6 +1328,9 @@ function setNestedValue(obj, path, value) {
1294
1328
  }
1295
1329
  function getNestedValue(obj, path) {
1296
1330
  const parts = getPathParts(path);
1331
+ if (!parts || parts.length === 0) {
1332
+ return void 0;
1333
+ }
1297
1334
  let current = obj;
1298
1335
  for (const part of parts) {
1299
1336
  if (current === void 0 || current === null || typeof current !== "object" || !(part in current)) {