@sanity/util 5.0.0-next.0-9b570ece82-202507150640 → 5.0.0-next.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.
Files changed (41) hide show
  1. package/LICENSE +1 -1
  2. package/lib/client.js +9 -8
  3. package/lib/client.js.map +1 -1
  4. package/lib/concurrency-limiter.js +3 -3
  5. package/lib/concurrency-limiter.js.map +1 -1
  6. package/lib/content.js +11 -15
  7. package/lib/content.js.map +1 -1
  8. package/lib/{createSafeJsonParser.mjs → createSafeJsonParser.cjs} +5 -5
  9. package/lib/{createSafeJsonParser.mjs.map → createSafeJsonParser.cjs.map} +1 -1
  10. package/lib/createSafeJsonParser.js +4 -4
  11. package/lib/createSafeJsonParser.js.map +1 -1
  12. package/lib/fs.js +13 -15
  13. package/lib/fs.js.map +1 -1
  14. package/lib/index.js +1 -1
  15. package/lib/legacyDateFormat.js +160 -78
  16. package/lib/legacyDateFormat.js.map +1 -1
  17. package/lib/paths.js +25 -25
  18. package/lib/paths.js.map +1 -1
  19. package/package.json +18 -30
  20. package/lib/client.d.mts +0 -12
  21. package/lib/client.mjs +0 -64
  22. package/lib/client.mjs.map +0 -1
  23. package/lib/concurrency-limiter.d.mts +0 -22
  24. package/lib/concurrency-limiter.mjs +0 -32
  25. package/lib/concurrency-limiter.mjs.map +0 -1
  26. package/lib/content.d.mts +0 -39
  27. package/lib/content.mjs +0 -89
  28. package/lib/content.mjs.map +0 -1
  29. package/lib/fs.d.mts +0 -7
  30. package/lib/fs.mjs +0 -31
  31. package/lib/fs.mjs.map +0 -1
  32. package/lib/index.d.mts +0 -1
  33. package/lib/index.mjs +0 -2
  34. package/lib/index.mjs.map +0 -1
  35. package/lib/legacyDateFormat.d.mts +0 -39
  36. package/lib/legacyDateFormat.mjs +0 -213
  37. package/lib/legacyDateFormat.mjs.map +0 -1
  38. package/lib/paths.d.mts +0 -53
  39. package/lib/paths.mjs +0 -153
  40. package/lib/paths.mjs.map +0 -1
  41. /package/lib/{createSafeJsonParser.d.mts → createSafeJsonParser.d.cts} +0 -0
@@ -1,213 +0,0 @@
1
- import { TZDateMini } from "@date-fns/tz";
2
- import { UTCDateMini } from "@date-fns/utc";
3
- import { format as format$1, parse as parse$1, parseISO } from "date-fns";
4
- const sanitizeLocale = (locale) => locale.replace(/@posix$/, "");
5
- function getMonthName(date, style = "long", locale = "en-US") {
6
- const validLocale = sanitizeLocale(locale);
7
- return new Intl.DateTimeFormat(validLocale, { month: style }).format(date);
8
- }
9
- function getDayName(date, style = "long", locale = "en-US") {
10
- const validLocale = sanitizeLocale(locale);
11
- return new Intl.DateTimeFormat(validLocale, { weekday: style }).format(date);
12
- }
13
- function zeroPad(num, length) {
14
- return String(num).padStart(length, "0");
15
- }
16
- function getOrdinal(day) {
17
- const j = day % 10, k = day % 100;
18
- return j === 1 && k !== 11 ? `${day}st` : j === 2 && k !== 12 ? `${day}nd` : j === 3 && k !== 13 ? `${day}rd` : `${day}th`;
19
- }
20
- function getISODayOfWeek(date) {
21
- const dow = date.getDay();
22
- return dow === 0 ? 7 : dow;
23
- }
24
- function getISOWeekYear(date) {
25
- const temp = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())), dayOfWeek = getISODayOfWeek(temp);
26
- return temp.setUTCDate(temp.getUTCDate() - dayOfWeek + 4), temp.getUTCFullYear();
27
- }
28
- function getISOWeekNumber(date) {
29
- const temp = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())), dayOfWeek = getISODayOfWeek(temp);
30
- temp.setUTCDate(temp.getUTCDate() - dayOfWeek + 4);
31
- const yearStart = new Date(Date.UTC(temp.getUTCFullYear(), 0, 1));
32
- return Math.ceil(((temp.valueOf() - yearStart.valueOf()) / 864e5 + 1) / 7);
33
- }
34
- function getDayOfYear(date) {
35
- const startOfYear = new Date(Date.UTC(date.getFullYear(), 0, 1)), diff = date.valueOf() - startOfYear.valueOf() + (startOfYear.getTimezoneOffset() - date.getTimezoneOffset()) * 6e4;
36
- return Math.floor(diff / (1e3 * 60 * 60 * 24)) + 1;
37
- }
38
- function getLocaleWeekYear(date) {
39
- return getISOWeekYear(date);
40
- }
41
- function getFractionalSeconds(date, length) {
42
- const ms = zeroPad(date.getMilliseconds(), 3);
43
- return length === 1 ? ms.slice(0, 1) : length === 2 ? ms.slice(0, 2) : length === 3 ? ms : `${ms}0`;
44
- }
45
- function getTimeZoneAbbreviation(date) {
46
- const tz = new Intl.DateTimeFormat(sanitizeLocale("en-US"), {
47
- timeZoneName: "short"
48
- }).formatToParts(date).find((part) => part.type === "timeZoneName");
49
- return tz ? tz.value : "";
50
- }
51
- function formatMomentLike(date, formatStr) {
52
- const escapeSequences = [], escapeToken = "\uE000", processedFormat = formatStr.replace(/\[([^\]]+)\]/g, (_, contents) => (escapeSequences.push(contents), escapeToken)), year = date.getFullYear(), monthIndex = date.getMonth(), dayOfMonth = date.getDate(), dayOfWeek = date.getDay(), hours = date.getHours(), minutes = date.getMinutes(), seconds = date.getSeconds(), isoWeekNum = getISOWeekNumber(date), isoWeekYear = getISOWeekYear(date), localeWeekYear = getLocaleWeekYear(date), unixMs = date.getTime(), unixSec = Math.floor(unixMs / 1e3), tokens = [
53
- // Year
54
- // 1970 1971 ... 2029 2030
55
- { key: "YYYY", value: String(year) },
56
- // 70 71 ... 29 30
57
- { key: "YY", value: String(year).slice(-2) },
58
- // 1970 1971 ... 9999 +10000 +10001
59
- { key: "Y", value: String(year) },
60
- // Expanded years, -001970 -001971 ... +001907 +001971
61
- { key: "YYYYY", value: zeroPad(year, 5) },
62
- // ISO week-year
63
- // 1970 1971 ... 2029 2030
64
- { key: "GGGG", value: String(isoWeekYear) },
65
- // 70 71 ... 29 30
66
- { key: "GG", value: String(isoWeekYear).slice(-2) },
67
- // "locale" week-year
68
- { key: "gggg", value: String(localeWeekYear) },
69
- { key: "gg", value: String(localeWeekYear).slice(-2) },
70
- // Quarter
71
- { key: "Q", value: String(Math.floor(monthIndex / 3) + 1) },
72
- { key: "Qo", value: getOrdinal(Math.floor(monthIndex / 3) + 1) },
73
- // --- Month (using Intl) ---
74
- { key: "MMMM", value: getMonthName(date, "long") },
75
- // e.g. "January"
76
- { key: "MMM", value: getMonthName(date, "short") },
77
- // e.g. "Jan"
78
- // For numeric months, we still do a manual approach:
79
- { key: "MM", value: zeroPad(monthIndex + 1, 2) },
80
- { key: "M", value: String(monthIndex + 1) },
81
- { key: "Mo", value: getOrdinal(monthIndex + 1) },
82
- // Day of Month
83
- { key: "DD", value: zeroPad(dayOfMonth, 2) },
84
- { key: "D", value: String(dayOfMonth) },
85
- { key: "Do", value: getOrdinal(dayOfMonth) },
86
- // --- Day of Week (using Intl) ---
87
- { key: "dddd", value: getDayName(date, "long") },
88
- // e.g. "Monday"
89
- { key: "ddd", value: getDayName(date, "short") },
90
- // e.g. "Mon"
91
- {
92
- key: "dd",
93
- // e.g. "Mo" => first 2 chars of short day name
94
- value: getDayName(date, "short").slice(0, 2)
95
- },
96
- { key: "d", value: String(dayOfWeek) },
97
- { key: "do", value: getOrdinal(dayOfWeek + 1) },
98
- // Day of the year
99
- { key: "DDDD", value: zeroPad(getDayOfYear(date), 3) },
100
- { key: "DDD", value: String(getDayOfYear(date)) },
101
- { key: "DDDo", value: getOrdinal(getDayOfYear(date)) },
102
- // ISO day of week
103
- { key: "E", value: String(getISODayOfWeek(date)) },
104
- // Day of Year
105
- { key: "DDDD", value: zeroPad(getDayOfYear(date), 3) },
106
- { key: "DDD", value: String(getDayOfYear(date)) },
107
- // Week of the year
108
- // w 1 2 ... 52 53
109
- { key: "w", value: zeroPad(isoWeekNum, 2) },
110
- // week 1st 2nd ... 52nd 53rd
111
- { key: "wo", value: getOrdinal(isoWeekNum) },
112
- // 01 02 ... 52 53
113
- { key: "ww", value: zeroPad(isoWeekNum, 2) },
114
- // ISO Week
115
- { key: "WW", value: zeroPad(isoWeekNum, 2) },
116
- { key: "W", value: String(isoWeekNum) },
117
- { key: "Wo", value: getOrdinal(isoWeekNum) },
118
- // or "locale" week => replace isoWeekNum
119
- // 24h hours
120
- { key: "HH", value: zeroPad(hours, 2) },
121
- { key: "H", value: String(hours) },
122
- // 12h hours
123
- { key: "hh", value: zeroPad((hours + 11) % 12 + 1, 2) },
124
- { key: "h", value: String((hours + 11) % 12 + 1) },
125
- // 1 2 ... 23 24
126
- { key: "k", value: String(hours || 24) },
127
- // 01 02 ... 23 24
128
- { key: "kk", value: zeroPad(hours || 24, 2) },
129
- // Minutes
130
- { key: "mm", value: zeroPad(minutes, 2) },
131
- { key: "m", value: String(minutes) },
132
- // Seconds
133
- { key: "ss", value: zeroPad(seconds, 2) },
134
- { key: "s", value: String(seconds) },
135
- // Fractional seconds (S..SSSS) => handled separately
136
- // Timezone offset (Z, ZZ) => handled separately
137
- // AM/PM
138
- { key: "A", value: hours < 12 ? "AM" : "PM" },
139
- { key: "a", value: hours < 12 ? "am" : "pm" },
140
- // Unix timestamps
141
- { key: "X", value: String(unixSec) },
142
- { key: "x", value: String(unixMs) },
143
- // Eras BC AD
144
- { key: "N", value: year < 0 ? "BC" : "AD" },
145
- { key: "NN", value: year < 0 ? "BC" : "AD" },
146
- { key: "NNN", value: year < 0 ? "BC" : "AD" },
147
- // Before Christ, Anno Domini
148
- { key: "NNNN", value: year < 0 ? "Before Christ" : "Anno Domini" },
149
- { key: "NNNNN", value: year < 0 ? "BC" : "AD" },
150
- // Time zone offset
151
- { key: "z", value: getTimeZoneAbbreviation(date) },
152
- { key: "zz", value: getTimeZoneAbbreviation(date) },
153
- { key: "Z", value: format$1(date, "xxx") },
154
- { key: "ZZ", value: format$1(date, "xx") }
155
- ];
156
- tokens.sort((a, b) => b.key.length - a.key.length);
157
- const fracSecRegex = /(S{1,4})/g;
158
- let output = processedFormat.replace(fracSecRegex, (match) => getFractionalSeconds(date, match.length));
159
- for (const { key, value } of tokens) {
160
- const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), tokenRegex = new RegExp(`(^|[^A-Z0-9a-z])(${escapedKey})(?![A-Z0-9a-z])`, "g");
161
- output = output.replace(tokenRegex, `$1${value}`);
162
- }
163
- return output = output.replace(new RegExp(escapeToken, "g"), () => escapeSequences.shift() || ""), output;
164
- }
165
- function momentToDateFnsFormat(momentFormat) {
166
- const formatMap = {
167
- YYYY: "yyyy",
168
- YY: "yy",
169
- MMMM: "MMMM",
170
- MMM: "MMM",
171
- MM: "MM",
172
- M: "M",
173
- DD: "dd",
174
- D: "d",
175
- dddd: "EEEE",
176
- ddd: "EEE",
177
- HH: "HH",
178
- H: "H",
179
- hh: "hh",
180
- h: "h",
181
- mm: "mm",
182
- m: "m",
183
- ss: "ss",
184
- s: "s",
185
- A: "a",
186
- a: "a"
187
- };
188
- return Object.keys(formatMap).reduce(
189
- (acc, key) => acc.replace(new RegExp(key, "g"), formatMap[key]),
190
- momentFormat
191
- );
192
- }
193
- const DEFAULT_DATE_FORMAT = "YYYY-MM-DD", DEFAULT_TIME_FORMAT = "HH:mm", DEFAULT_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone;
194
- function format(input, dateFormat, options = { useUTC: !1, timeZone: void 0 }) {
195
- const { useUTC, timeZone } = options;
196
- return formatMomentLike(useUTC ? new UTCDateMini(input) : timeZone ? new TZDateMini(input, timeZone || DEFAULT_TIMEZONE) : new Date(input), dateFormat);
197
- }
198
- function parse(dateString, dateFormat, timeZone) {
199
- const dnsFormat = dateFormat ? momentToDateFnsFormat(dateFormat) : void 0, parsed = dnsFormat ? parse$1(dateString, dnsFormat, /* @__PURE__ */ new Date()) : parseISO(dateString);
200
- return parsed && !isNaN(parsed.getTime()) ? { isValid: !0, date: timeZone && isValidTimeZoneString(timeZone) ? new TZDateMini(parsed, timeZone) : parsed } : { isValid: !1, error: `Invalid date. Must be on the format "${dateFormat}"` };
201
- }
202
- function isValidTimeZoneString(timeZone) {
203
- return Intl.supportedValuesOf("timeZone").includes(timeZone);
204
- }
205
- export {
206
- DEFAULT_DATE_FORMAT,
207
- DEFAULT_TIME_FORMAT,
208
- format,
209
- isValidTimeZoneString,
210
- parse,
211
- sanitizeLocale
212
- };
213
- //# sourceMappingURL=legacyDateFormat.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacyDateFormat.mjs","sources":["../src/datetime-formatter/sanitizeLocale.ts","../src/datetime-formatter/formatter.ts","../src/datetime-formatter/momentToDateFnsFormat.ts","../src/legacyDateFormat.ts"],"sourcesContent":["// this is used to avoid issues with the Intl.DateTimeFormat constructor as part of the efps tests\nconst sanitizeLocale = (locale: string): string => locale.replace(/@posix$/, '')\n\nexport default sanitizeLocale\n","import {format} from 'date-fns'\n\nimport sanitizeLocale from './sanitizeLocale'\n\nfunction getMonthName(\n date: Date,\n style: 'long' | 'short' | 'narrow' | undefined = 'long',\n locale = 'en-US',\n): string {\n const validLocale = sanitizeLocale(locale)\n return new Intl.DateTimeFormat(validLocale, {month: style}).format(date)\n}\n\nfunction getDayName(\n date: Date,\n style: 'long' | 'short' | 'narrow' | undefined = 'long',\n locale = 'en-US',\n): string {\n const validLocale = sanitizeLocale(locale)\n return new Intl.DateTimeFormat(validLocale, {weekday: style}).format(date)\n}\n\n/**\n * Zero-pads a number to `length` digits (e.g. zeroPad(7, 2) = \"07\").\n */\nfunction zeroPad(num: number, length: number): string {\n return String(num).padStart(length, '0')\n}\n\n/**\n * Returns an English ordinal for a given day number\n */\nfunction getOrdinal(day: number): string {\n const j = day % 10\n const k = day % 100\n if (j === 1 && k !== 11) return `${day}st`\n if (j === 2 && k !== 12) return `${day}nd`\n if (j === 3 && k !== 13) return `${day}rd`\n return `${day}th`\n}\n\nfunction getISODayOfWeek(date: Date): number {\n // Sunday=0 in JS, but ISO calls Monday=1...Sunday=7\n const dow = date.getDay()\n return dow === 0 ? 7 : dow\n}\n\nfunction getISOWeekYear(date: Date): number {\n // Clone date, shift to the \"Thursday\" of this week\n const temp = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()))\n const dayOfWeek = getISODayOfWeek(temp)\n temp.setUTCDate(temp.getUTCDate() - dayOfWeek + 4)\n return temp.getUTCFullYear()\n}\n\nfunction getISOWeekNumber(date: Date): number {\n const temp = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()))\n const dayOfWeek = getISODayOfWeek(temp)\n temp.setUTCDate(temp.getUTCDate() - dayOfWeek + 4)\n const yearStart = new Date(Date.UTC(temp.getUTCFullYear(), 0, 1))\n return Math.ceil(((temp.valueOf() - yearStart.valueOf()) / 86400000 + 1) / 7)\n}\n\nfunction getDayOfYear(date: Date): number {\n const startOfYear = new Date(Date.UTC(date.getFullYear(), 0, 1))\n // fix for local-time differences\n const diff =\n date.valueOf() -\n startOfYear.valueOf() +\n (startOfYear.getTimezoneOffset() - date.getTimezoneOffset()) * 60_000\n return Math.floor(diff / (1000 * 60 * 60 * 24)) + 1\n}\n\n// \"Locale\" week-year => approximate with ISO logic here\nfunction getLocaleWeekYear(date: Date): number {\n return getISOWeekYear(date)\n}\n\n/**\n * Returns fractional seconds based on the count of 'S' in the token.\n */\nfunction getFractionalSeconds(date: Date, length: number): string {\n const ms = zeroPad(date.getMilliseconds(), 3) // \"123\"\n if (length === 1) {\n return ms.slice(0, 1) // \"1\"\n } else if (length === 2) {\n return ms.slice(0, 2) // \"12\"\n } else if (length === 3) {\n return ms // \"123\"\n }\n // length=4 => e.g. \"1230\"\n return `${ms}0`\n}\n\nfunction getTimeZoneAbbreviation(date: Date) {\n const parts = new Intl.DateTimeFormat(sanitizeLocale('en-US'), {\n timeZoneName: 'short',\n }).formatToParts(date)\n const tz = parts.find((part) => part.type === 'timeZoneName')\n return tz ? tz.value : ''\n}\n\n/**\n * Formats a Date object using many Moment-like tokens.\n */\nfunction formatMomentLike(date: Date, formatStr: string): string {\n // Store escaped sequences to restore later\n const escapeSequences: string[] = []\n const escapeToken = '\\uE000' // Use a Unicode private use character as placeholder\n\n // Replace bracketed content with placeholders\n const processedFormat = formatStr.replace(/\\[([^\\]]+)\\]/g, (_, contents) => {\n escapeSequences.push(contents)\n return escapeToken\n })\n\n // Basic fields\n const year = date.getFullYear()\n const monthIndex = date.getMonth() // 0..11\n const dayOfMonth = date.getDate() // 1..31\n const dayOfWeek = date.getDay() // 0..6 (Sun=0)\n const hours = date.getHours() // 0..23\n const minutes = date.getMinutes() // 0..59\n const seconds = date.getSeconds() // 0..59\n\n // Week-related\n const isoWeekNum = getISOWeekNumber(date)\n const isoWeekYear = getISOWeekYear(date)\n const localeWeekYear = getLocaleWeekYear(date)\n\n // Timestamps\n const unixMs = date.getTime() // milliseconds since epoch\n const unixSec = Math.floor(unixMs / 1000) // seconds since epoch\n\n // Build token -> value map\n const tokens = [\n // Year\n // 1970 1971 ... 2029 2030\n {key: 'YYYY', value: String(year)},\n // 70 71 ... 29 30\n {key: 'YY', value: String(year).slice(-2)},\n // 1970 1971 ... 9999 +10000 +10001\n {key: 'Y', value: String(year)},\n // Expanded years, -001970 -001971 ... +001907 +001971\n {key: 'YYYYY', value: zeroPad(year, 5)},\n\n // ISO week-year\n // 1970 1971 ... 2029 2030\n {key: 'GGGG', value: String(isoWeekYear)},\n // 70 71 ... 29 30\n {key: 'GG', value: String(isoWeekYear).slice(-2)},\n\n // \"locale\" week-year\n {key: 'gggg', value: String(localeWeekYear)},\n {key: 'gg', value: String(localeWeekYear).slice(-2)},\n\n // Quarter\n {key: 'Q', value: String(Math.floor(monthIndex / 3) + 1)},\n {key: 'Qo', value: getOrdinal(Math.floor(monthIndex / 3) + 1)},\n\n // --- Month (using Intl) ---\n {key: 'MMMM', value: getMonthName(date, 'long')}, // e.g. \"January\"\n {key: 'MMM', value: getMonthName(date, 'short')}, // e.g. \"Jan\"\n // For numeric months, we still do a manual approach:\n {key: 'MM', value: zeroPad(monthIndex + 1, 2)},\n {key: 'M', value: String(monthIndex + 1)},\n {key: 'Mo', value: getOrdinal(monthIndex + 1)},\n\n // Day of Month\n {key: 'DD', value: zeroPad(dayOfMonth, 2)},\n {key: 'D', value: String(dayOfMonth)},\n {key: 'Do', value: getOrdinal(dayOfMonth)},\n\n // --- Day of Week (using Intl) ---\n {key: 'dddd', value: getDayName(date, 'long')}, // e.g. \"Monday\"\n {key: 'ddd', value: getDayName(date, 'short')}, // e.g. \"Mon\"\n {\n key: 'dd',\n // e.g. \"Mo\" => first 2 chars of short day name\n value: getDayName(date, 'short').slice(0, 2),\n },\n {key: 'd', value: String(dayOfWeek)},\n {key: 'do', value: getOrdinal(dayOfWeek + 1)},\n\n // Day of the year\n {key: 'DDDD', value: zeroPad(getDayOfYear(date), 3)},\n {key: 'DDD', value: String(getDayOfYear(date))},\n {key: 'DDDo', value: getOrdinal(getDayOfYear(date))},\n\n // ISO day of week\n {key: 'E', value: String(getISODayOfWeek(date))},\n\n // Day of Year\n {key: 'DDDD', value: zeroPad(getDayOfYear(date), 3)},\n {key: 'DDD', value: String(getDayOfYear(date))},\n\n // Week of the year\n // w 1 2 ... 52 53\n {key: 'w', value: zeroPad(isoWeekNum, 2)},\n // week 1st 2nd ... 52nd 53rd\n {key: 'wo', value: getOrdinal(isoWeekNum)},\n // 01 02 ... 52 53\n {key: 'ww', value: zeroPad(isoWeekNum, 2)},\n\n // ISO Week\n {key: 'WW', value: zeroPad(isoWeekNum, 2)},\n {key: 'W', value: String(isoWeekNum)},\n {key: 'Wo', value: getOrdinal(isoWeekNum)},\n\n // or \"locale\" week => replace isoWeekNum\n\n // 24h hours\n {key: 'HH', value: zeroPad(hours, 2)},\n {key: 'H', value: String(hours)},\n\n // 12h hours\n {key: 'hh', value: zeroPad(((hours + 11) % 12) + 1, 2)},\n {key: 'h', value: String(((hours + 11) % 12) + 1)},\n\n // 1 2 ... 23 24\n {key: 'k', value: String(hours || 24)},\n // 01 02 ... 23 24\n {key: 'kk', value: zeroPad(hours || 24, 2)},\n\n // Minutes\n {key: 'mm', value: zeroPad(minutes, 2)},\n {key: 'm', value: String(minutes)},\n\n // Seconds\n {key: 'ss', value: zeroPad(seconds, 2)},\n {key: 's', value: String(seconds)},\n\n // Fractional seconds (S..SSSS) => handled separately\n // Timezone offset (Z, ZZ) => handled separately\n\n // AM/PM\n {key: 'A', value: hours < 12 ? 'AM' : 'PM'},\n {key: 'a', value: hours < 12 ? 'am' : 'pm'},\n\n // Unix timestamps\n {key: 'X', value: String(unixSec)},\n {key: 'x', value: String(unixMs)},\n\n // Eras BC AD\n {key: 'N', value: year < 0 ? 'BC' : 'AD'},\n {key: 'NN', value: year < 0 ? 'BC' : 'AD'},\n {key: 'NNN', value: year < 0 ? 'BC' : 'AD'},\n\n // Before Christ, Anno Domini\n {key: 'NNNN', value: year < 0 ? 'Before Christ' : 'Anno Domini'},\n {key: 'NNNNN', value: year < 0 ? 'BC' : 'AD'},\n\n // Time zone offset\n {key: 'z', value: getTimeZoneAbbreviation(date)},\n {key: 'zz', value: getTimeZoneAbbreviation(date)},\n {key: 'Z', value: format(date, 'xxx')},\n {key: 'ZZ', value: format(date, 'xx')},\n ]\n\n // Sort tokens by descending length to avoid partial collisions\n tokens.sort((a, b) => b.key.length - a.key.length)\n\n // 1) Fractional seconds\n const fracSecRegex = /(S{1,4})/g\n let output = processedFormat.replace(fracSecRegex, (match) => {\n return getFractionalSeconds(date, match.length)\n })\n\n // Find each token and replace it, make sure not to replace overlapping tokens\n\n for (const {key, value} of tokens) {\n // Escape special characters\n const escapedKey = key.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n // Match the token, but only if it's not part of a larger word\n const tokenRegex = new RegExp(`(^|[^A-Z0-9a-z])(${escapedKey})(?![A-Z0-9a-z])`, 'g')\n output = output.replace(tokenRegex, `$1${value}`)\n }\n\n // After all token replacements, restore escaped sequences\n output = output.replace(new RegExp(escapeToken, 'g'), () => escapeSequences.shift() || '')\n\n return output\n}\n\nexport default formatMomentLike\n","/**\n * Converts a Moment.js format string into a UTS 35 (Unicode Technical Standard #35)\n * format string\n *\n * This function doesn't take absolutely every token into account, but should cover\n * all common cases. If you find a missing token, feel free to add it.\n *\n */\nexport function momentToDateFnsFormat(momentFormat: string): string {\n // A list of replacements from Moment tokens to date-fns tokens\n // ordered from longest to shortest to prevent partial replacements\n const formatMap: Record<string, string> = {\n YYYY: 'yyyy',\n YY: 'yy',\n MMMM: 'MMMM',\n MMM: 'MMM',\n MM: 'MM',\n M: 'M',\n DD: 'dd',\n D: 'd',\n dddd: 'EEEE',\n ddd: 'EEE',\n HH: 'HH',\n H: 'H',\n hh: 'hh',\n h: 'h',\n mm: 'mm',\n m: 'm',\n ss: 'ss',\n s: 's',\n A: 'a',\n a: 'a',\n }\n\n // Replace each token in the format string\n return Object.keys(formatMap).reduce(\n (acc, key) => acc.replace(new RegExp(key, 'g'), formatMap[key]),\n momentFormat,\n )\n}\n","import {TZDateMini} from '@date-fns/tz'\nimport {UTCDateMini} from '@date-fns/utc'\nimport {parse as dateFnsParse, parseISO} from 'date-fns'\n\nimport formatMomentLike from './datetime-formatter/formatter'\nimport {momentToDateFnsFormat} from './datetime-formatter/momentToDateFnsFormat'\nimport sanitizeLocale from './datetime-formatter/sanitizeLocale'\n\nexport {sanitizeLocale}\n\nexport const DEFAULT_DATE_FORMAT = 'YYYY-MM-DD'\nexport const DEFAULT_TIME_FORMAT = 'HH:mm'\n// take local as default time zone\nconst DEFAULT_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone\n\nexport type ParseResult = {isValid: boolean; date?: Date; error?: string} & (\n | {isValid: true; date: Date}\n | {isValid: false; error?: string}\n)\n\nexport function format(\n input: Date,\n dateFormat: string,\n options: {useUTC?: boolean; timeZone?: string} = {useUTC: false, timeZone: undefined},\n): string {\n const {useUTC, timeZone} = options\n\n if (useUTC) return formatMomentLike(new UTCDateMini(input), dateFormat)\n return formatMomentLike(\n timeZone ? new TZDateMini(input, timeZone || DEFAULT_TIMEZONE) : new Date(input),\n dateFormat,\n )\n}\n\n/*\n It would be so good to remove date-fns from this file, but it's used in the parse function. We could write our own parser,\n but this is better than moment.\n */\nexport function parse(dateString: string, dateFormat?: string, timeZone?: string): ParseResult {\n const dnsFormat = dateFormat ? momentToDateFnsFormat(dateFormat) : undefined\n\n // parse string to date using the format string from date-fns\n const parsed = dnsFormat ? dateFnsParse(dateString, dnsFormat, new Date()) : parseISO(dateString)\n if (parsed && !isNaN(parsed.getTime())) {\n const parsedDate =\n timeZone && isValidTimeZoneString(timeZone) ? new TZDateMini(parsed, timeZone) : parsed\n return {isValid: true, date: parsedDate}\n }\n return {isValid: false, error: `Invalid date. Must be on the format \"${dateFormat}\"`}\n}\n\nexport function isValidTimeZoneString(timeZone: string): boolean {\n return Intl.supportedValuesOf('timeZone').includes(timeZone)\n}\n"],"names":["format","dateFnsParse"],"mappings":";;;AACA,MAAM,iBAAiB,CAAC,WAA2B,OAAO,QAAQ,WAAW,EAAE;ACG/E,SAAS,aACP,MACA,QAAiD,QACjD,SAAS,SACD;AACF,QAAA,cAAc,eAAe,MAAM;AAClC,SAAA,IAAI,KAAK,eAAe,aAAa,EAAC,OAAO,MAAM,CAAA,EAAE,OAAO,IAAI;AACzE;AAEA,SAAS,WACP,MACA,QAAiD,QACjD,SAAS,SACD;AACF,QAAA,cAAc,eAAe,MAAM;AAClC,SAAA,IAAI,KAAK,eAAe,aAAa,EAAC,SAAS,MAAM,CAAA,EAAE,OAAO,IAAI;AAC3E;AAKA,SAAS,QAAQ,KAAa,QAAwB;AACpD,SAAO,OAAO,GAAG,EAAE,SAAS,QAAQ,GAAG;AACzC;AAKA,SAAS,WAAW,KAAqB;AACvC,QAAM,IAAI,MAAM,IACV,IAAI,MAAM;AACZ,SAAA,MAAM,KAAK,MAAM,KAAW,GAAG,GAAG,OAClC,MAAM,KAAK,MAAM,KAAW,GAAG,GAAG,OAClC,MAAM,KAAK,MAAM,KAAW,GAAG,GAAG,OAC/B,GAAG,GAAG;AACf;AAEA,SAAS,gBAAgB,MAAoB;AAErC,QAAA,MAAM,KAAK,OAAO;AACjB,SAAA,QAAQ,IAAI,IAAI;AACzB;AAEA,SAAS,eAAe,MAAoB;AAE1C,QAAM,OAAO,IAAI,KAAK,KAAK,IAAI,KAAK,eAAe,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AAG;AACtF;AAEO,SAAS,sBAAsB,UAA2B;AAC/D,SAAO,KAAK,kBAAkB,UAAU,EAAE,SAAS,QAAQ;AAC7D;"}
package/lib/paths.d.mts DELETED
@@ -1,53 +0,0 @@
1
- import {Path} from '@sanity/types'
2
- import {PathSegment} from '@sanity/types'
3
-
4
- export declare const FOCUS_TERMINATOR = '$'
5
-
6
- export declare function fromString(path: string): Path
7
-
8
- export declare function get<R>(obj: unknown, path: Path | string): R | undefined
9
-
10
- export declare function get<R>(obj: unknown, path: Path | string, defaultValue: R): R
11
-
12
- export declare function hasFocus(focusPath: Path, path: Path): boolean
13
-
14
- export declare function hasItemFocus(focusPath: Path, item: PathSegment): boolean
15
-
16
- export declare function isEqual(path: Path, otherPath: Path): boolean
17
-
18
- export declare function isExpanded(segment: PathSegment, focusPath: Path): boolean
19
-
20
- export declare function isSegmentEqual(segmentA: PathSegment, segmentB: PathSegment): boolean
21
-
22
- export declare function numEqualSegments(path: Path, otherPath: Path): number
23
-
24
- export declare function pathFor(path: Path): Path
25
-
26
- /**
27
- * Takes a value and a path that may include numeric indices and attempts to replace numeric indices with keyed paths
28
- *
29
- * @param value - any json value
30
- * @param path - a Path that may include numeric indices
31
- * @returns a path where numeric indices has been replaced by keyed segments (e.g. `{_key: <key>}`)
32
- * Will do as good attempt as possible, but in case of missing array items, it will return the best possible match:
33
- * - `resolveKeyedPath([0, 'bar'], [])` will return [] since array has no value at index 0
34
- * - `resolveKeyedPath([0, 'foo'], [{_key: 'xyz', 'foo': 'bar'}, {_key: 'abc'}])` will return `[{_key: 'xyz'}, 'foo']` since array has no value at index 0
35
- * - `resolveKeyedPath([0, 'foo', 'bar'], [{_key: 'xyz'}])` will return `[{_key: 'xyz'}, 'foo', 'bar']` since array has no value at index 0
36
- * Object keys will be preserved as-is, e.g. `resolveKeyedPath(['foo', 'bar'], undefined)` will return `['foo', 'bar']`
37
- */
38
- export declare function resolveKeyedPath(value: unknown, path: Path): Path
39
-
40
- export declare function _resolveKeyedPath(value: unknown, path: Path): Path
41
-
42
- export declare function startsWith(prefix: Path, path: Path): boolean
43
-
44
- declare function toString_2(path: Path): string
45
- export {toString_2 as toString}
46
-
47
- export declare function trimChildPath(path: Path, childPath: Path): Path
48
-
49
- export declare function trimLeft(prefix: Path, path: Path): Path
50
-
51
- export declare function trimRight(suffix: Path, path: Path): Path
52
-
53
- export {}
package/lib/paths.mjs DELETED
@@ -1,153 +0,0 @@
1
- import { isIndexSegment, isKeySegment, isIndexTuple } from "@sanity/types";
2
- const rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, reKeySegment = /_key\s*==\s*['"](.*)['"]/, EMPTY_PATH = [], FOCUS_TERMINATOR = "$", GROQ_DATA_TYPE_VALUES = ["true", "false", "null"];
3
- function get(obj, path, defaultVal) {
4
- const select = typeof path == "string" ? fromString(path) : path;
5
- if (!Array.isArray(select))
6
- throw new Error("Path must be an array or a string");
7
- let acc = obj;
8
- for (let i = 0; i < select.length; i++) {
9
- const segment = select[i];
10
- if (isIndexSegment(segment)) {
11
- if (!Array.isArray(acc))
12
- return defaultVal;
13
- acc = acc[segment];
14
- }
15
- if (isKeySegment(segment)) {
16
- if (!Array.isArray(acc))
17
- return defaultVal;
18
- acc = acc.find((item) => item._key === segment._key);
19
- }
20
- if (typeof segment == "string" && (acc = typeof acc == "object" && acc !== null ? acc[segment] : void 0), typeof acc > "u")
21
- return defaultVal;
22
- }
23
- return acc;
24
- }
25
- const pathsMemo = /* @__PURE__ */ new Map();
26
- function pathFor(path) {
27
- if (path.length === 0)
28
- return EMPTY_PATH;
29
- const asString = toString(path);
30
- return pathsMemo.has(asString) ? pathsMemo.get(asString) : (pathsMemo.set(asString, path), Object.freeze(path), path);
31
- }
32
- function isEqual(path, otherPath) {
33
- return path.length === otherPath.length && path.every((segment, i) => isSegmentEqual(segment, otherPath[i]));
34
- }
35
- function numEqualSegments(path, otherPath) {
36
- const length = Math.min(path.length, otherPath.length);
37
- for (let i = 0; i < length; i++)
38
- if (!isSegmentEqual(path[i], otherPath[i]))
39
- return i;
40
- return length;
41
- }
42
- function isSegmentEqual(segmentA, segmentB) {
43
- return isKeySegment(segmentA) && isKeySegment(segmentB) ? segmentA._key === segmentB._key : isIndexSegment(segmentA) ? Number(segmentA) === Number(segmentB) : isIndexTuple(segmentA) && isIndexTuple(segmentB) ? segmentA[0] === segmentB[0] && segmentA[1] === segmentB[1] : segmentA === segmentB;
44
- }
45
- function hasFocus(focusPath, path) {
46
- const withoutTerminator = focusPath[focusPath.length - 1] === FOCUS_TERMINATOR ? focusPath.slice(0, -1) : focusPath;
47
- return isEqual(withoutTerminator, path);
48
- }
49
- function hasItemFocus(focusPath, item) {
50
- return focusPath.length === 1 && isSegmentEqual(focusPath[0], item);
51
- }
52
- function isExpanded(segment, focusPath) {
53
- const [head, ...tail] = focusPath;
54
- return tail.length > 0 && isSegmentEqual(segment, head);
55
- }
56
- function startsWith(prefix, path) {
57
- return prefix.every((segment, i) => isSegmentEqual(segment, path[i]));
58
- }
59
- function trimLeft(prefix, path) {
60
- if (prefix.length === 0 || path.length === 0)
61
- return path;
62
- const [prefixHead, ...prefixTail] = prefix, [pathHead, ...pathTail] = path;
63
- return isSegmentEqual(prefixHead, pathHead) ? pathFor(trimLeft(prefixTail, pathTail)) : path;
64
- }
65
- function trimRight(suffix, path) {
66
- const sufLen = suffix.length, pathLen = path.length;
67
- if (sufLen === 0 || pathLen === 0)
68
- return path;
69
- let i = 0;
70
- for (; i < sufLen && i < pathLen && isSegmentEqual(path[pathLen - i - 1], suffix[sufLen - i - 1]); )
71
- i++;
72
- return pathFor(path.slice(0, pathLen - i));
73
- }
74
- function trimChildPath(path, childPath) {
75
- return startsWith(path, childPath) ? trimLeft(path, childPath) : EMPTY_PATH;
76
- }
77
- function toString(path) {
78
- if (!Array.isArray(path))
79
- throw new Error("Path is not an array");
80
- return path.reduce((target, segment, i) => {
81
- const isHead = i === 0;
82
- if (typeof segment == "number")
83
- return `${target}[${segment}]`;
84
- if (typeof segment == "string")
85
- return isHead ? segment : GROQ_DATA_TYPE_VALUES.includes(segment) ? `${target}["${segment}"]` : `${target}.${segment}`;
86
- if (isKeySegment(segment) && segment._key)
87
- return `${target}[_key=="${segment._key}"]`;
88
- if (Array.isArray(segment)) {
89
- const [from, to] = segment;
90
- return `${target}[${from}:${to}]`;
91
- }
92
- throw new Error(`Unsupported path segment \`${JSON.stringify(segment)}\``);
93
- }, "");
94
- }
95
- function _resolveKeyedPath(value, path) {
96
- if (path.length === 0)
97
- return path;
98
- const [next, ...rest] = path;
99
- if (typeof next == "number") {
100
- if (!Array.isArray(value) || !(next in value))
101
- return [];
102
- const item = value[next];
103
- return [typeof item?._key == "string" ? { _key: item._key } : next, ..._resolveKeyedPath(item, rest)];
104
- }
105
- const nextVal = get(value, [next]);
106
- return [next, ..._resolveKeyedPath(nextVal, rest)];
107
- }
108
- function resolveKeyedPath(value, path) {
109
- if (!Array.isArray(path))
110
- throw new Error("Path is not an array");
111
- return pathFor(_resolveKeyedPath(value, path));
112
- }
113
- function fromString(path) {
114
- if (typeof path != "string")
115
- throw new Error("Path is not a string");
116
- const segments = path.match(rePropName);
117
- if (!segments)
118
- throw new Error("Invalid path string");
119
- return segments.map(normalizePathSegment);
120
- }
121
- function normalizePathSegment(segment) {
122
- return isIndexSegment(segment) ? normalizeIndexSegment(segment) : isKeySegment(segment) ? normalizeKeySegment(segment) : isIndexTuple(segment) ? normalizeIndexTupleSegment(segment) : segment;
123
- }
124
- function normalizeIndexSegment(segment) {
125
- return Number(segment.replace(/[^\d]/g, ""));
126
- }
127
- function normalizeKeySegment(segment) {
128
- return { _key: segment.match(reKeySegment)[1] };
129
- }
130
- function normalizeIndexTupleSegment(segment) {
131
- const [from, to] = segment.split(":").map((seg) => seg === "" ? seg : Number(seg));
132
- return [from, to];
133
- }
134
- export {
135
- FOCUS_TERMINATOR,
136
- _resolveKeyedPath,
137
- fromString,
138
- get,
139
- hasFocus,
140
- hasItemFocus,
141
- isEqual,
142
- isExpanded,
143
- isSegmentEqual,
144
- numEqualSegments,
145
- pathFor,
146
- resolveKeyedPath,
147
- startsWith,
148
- toString,
149
- trimChildPath,
150
- trimLeft,
151
- trimRight
152
- };
153
- //# sourceMappingURL=paths.mjs.map
package/lib/paths.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.mjs","sources":["../src/paths.ts"],"sourcesContent":["import {\n type IndexTuple,\n isIndexSegment,\n isIndexTuple,\n isKeySegment,\n type KeyedSegment,\n type Path,\n type PathSegment,\n} from '@sanity/types'\n\nconst rePropName =\n /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))/g\nconst reKeySegment = /_key\\s*==\\s*['\"](.*)['\"]/\nconst EMPTY_PATH: Path = []\n\nexport const FOCUS_TERMINATOR = '$'\n\n// Fields named as GROQ data types cannot be accessed using dot notation. These fields must instead\n// be serialized using square bracket notation.\nconst GROQ_DATA_TYPE_VALUES = ['true', 'false', 'null']\n\nexport function get<R>(obj: unknown, path: Path | string): R | undefined\nexport function get<R>(obj: unknown, path: Path | string, defaultValue: R): R\nexport function get(obj: unknown, path: Path | string, defaultVal?: unknown): unknown {\n const select = typeof path === 'string' ? fromString(path) : path\n if (!Array.isArray(select)) {\n throw new Error('Path must be an array or a string')\n }\n\n let acc: unknown | undefined = obj\n for (let i = 0; i < select.length; i++) {\n const segment = select[i]\n if (isIndexSegment(segment)) {\n if (!Array.isArray(acc)) {\n return defaultVal\n }\n\n acc = acc[segment]\n }\n\n if (isKeySegment(segment)) {\n if (!Array.isArray(acc)) {\n return defaultVal\n }\n\n acc = acc.find((item) => item._key === segment._key)\n }\n\n if (typeof segment === 'string') {\n acc =\n typeof acc === 'object' && acc !== null\n ? ((acc as Record<string, unknown>)[segment] as Record<string, unknown>)\n : undefined\n }\n\n if (typeof acc === 'undefined') {\n return defaultVal\n }\n }\n\n return acc\n}\n\nconst pathsMemo = new Map<string, Path>()\nexport function pathFor(path: Path): Path {\n if (path.length === 0) {\n return EMPTY_PATH\n }\n const asString = toString(path)\n if (pathsMemo.has(asString)) {\n return pathsMemo.get(asString)!\n }\n pathsMemo.set(asString, path)\n Object.freeze(path)\n return path\n}\n\nexport function isEqual(path: Path, otherPath: Path): boolean {\n return (\n path.length === otherPath.length &&\n path.every((segment, i) => isSegmentEqual(segment, otherPath[i]))\n )\n}\n\nexport function numEqualSegments(path: Path, otherPath: Path): number {\n const length = Math.min(path.length, otherPath.length)\n for (let i = 0; i < length; i++) {\n if (!isSegmentEqual(path[i], otherPath[i])) {\n return i\n }\n }\n return length\n}\n\nexport function isSegmentEqual(segmentA: PathSegment, segmentB: PathSegment): boolean {\n if (isKeySegment(segmentA) && isKeySegment(segmentB)) {\n return segmentA._key === segmentB._key\n }\n\n if (isIndexSegment(segmentA)) {\n return Number(segmentA) === Number(segmentB)\n }\n\n if (isIndexTuple(segmentA) && isIndexTuple(segmentB)) {\n return segmentA[0] === segmentB[0] && segmentA[1] === segmentB[1]\n }\n\n return segmentA === segmentB\n}\n\nexport function hasFocus(focusPath: Path, path: Path): boolean {\n const withoutTerminator =\n focusPath[focusPath.length - 1] === FOCUS_TERMINATOR ? focusPath.slice(0, -1) : focusPath\n return isEqual(withoutTerminator, path)\n}\n\nexport function hasItemFocus(focusPath: Path, item: PathSegment): boolean {\n return focusPath.length === 1 && isSegmentEqual(focusPath[0], item)\n}\n\nexport function isExpanded(segment: PathSegment, focusPath: Path): boolean {\n const [head, ...tail] = focusPath\n return tail.length > 0 && isSegmentEqual(segment, head)\n}\n\nexport function startsWith(prefix: Path, path: Path): boolean {\n return prefix.every((segment, i) => isSegmentEqual(segment, path[i]))\n}\n\nexport function trimLeft(prefix: Path, path: Path): Path {\n if (prefix.length === 0 || path.length === 0) {\n return path\n }\n const [prefixHead, ...prefixTail] = prefix\n const [pathHead, ...pathTail] = path\n if (!isSegmentEqual(prefixHead, pathHead)) {\n return path\n }\n return pathFor(trimLeft(prefixTail, pathTail))\n}\n\nexport function trimRight(suffix: Path, path: Path): Path {\n const sufLen = suffix.length\n const pathLen = path.length\n if (sufLen === 0 || pathLen === 0) {\n return path\n }\n\n let i = 0\n while (\n i < sufLen &&\n i < pathLen &&\n isSegmentEqual(path[pathLen - i - 1], suffix[sufLen - i - 1])\n ) {\n i++\n }\n\n return pathFor(path.slice(0, pathLen - i))\n}\n\nexport function trimChildPath(path: Path, childPath: Path): Path {\n return startsWith(path, childPath) ? trimLeft(path, childPath) : EMPTY_PATH\n}\n\nexport function toString(path: Path): string {\n if (!Array.isArray(path)) {\n throw new Error('Path is not an array')\n }\n\n return path.reduce<string>((target, segment, i) => {\n const isHead = i === 0\n\n if (typeof segment === 'number') {\n return `${target}[${segment}]`\n }\n\n if (typeof segment === 'string') {\n if (isHead) {\n return segment\n }\n\n if (GROQ_DATA_TYPE_VALUES.includes(segment)) {\n return `${target}[\"${segment}\"]`\n }\n\n return `${target}.${segment}`\n }\n\n if (isKeySegment(segment) && segment._key) {\n return `${target}[_key==\"${segment._key}\"]`\n }\n\n if (Array.isArray(segment)) {\n const [from, to] = segment\n return `${target}[${from}:${to}]`\n }\n\n throw new Error(`Unsupported path segment \\`${JSON.stringify(segment)}\\``)\n }, '')\n}\n\nexport function _resolveKeyedPath(value: unknown, path: Path): Path {\n if (path.length === 0) {\n return path\n }\n const [next, ...rest] = path\n if (typeof next === 'number') {\n if (!Array.isArray(value) || !(next in value)) {\n return []\n }\n const item = value[next]\n const key = item?._key\n return [typeof key === 'string' ? {_key: item._key} : next, ..._resolveKeyedPath(item, rest)]\n }\n const nextVal = get(value, [next])\n return [next, ..._resolveKeyedPath(nextVal, rest)]\n}\n\n/**\n * Takes a value and a path that may include numeric indices and attempts to replace numeric indices with keyed paths\n *\n * @param value - any json value\n * @param path - a Path that may include numeric indices\n * @returns a path where numeric indices has been replaced by keyed segments (e.g. `{_key: <key>}`)\n * Will do as good attempt as possible, but in case of missing array items, it will return the best possible match:\n * - `resolveKeyedPath([0, 'bar'], [])` will return [] since array has no value at index 0\n * - `resolveKeyedPath([0, 'foo'], [{_key: 'xyz', 'foo': 'bar'}, {_key: 'abc'}])` will return `[{_key: 'xyz'}, 'foo']` since array has no value at index 0\n * - `resolveKeyedPath([0, 'foo', 'bar'], [{_key: 'xyz'}])` will return `[{_key: 'xyz'}, 'foo', 'bar']` since array has no value at index 0\n * Object keys will be preserved as-is, e.g. `resolveKeyedPath(['foo', 'bar'], undefined)` will return `['foo', 'bar']`\n */\nexport function resolveKeyedPath(value: unknown, path: Path): Path {\n if (!Array.isArray(path)) {\n throw new Error('Path is not an array')\n }\n return pathFor(_resolveKeyedPath(value, path))\n}\n\nexport function fromString(path: string): Path {\n if (typeof path !== 'string') {\n throw new Error('Path is not a string')\n }\n\n const segments = path.match(rePropName)\n if (!segments) {\n throw new Error('Invalid path string')\n }\n\n return segments.map(normalizePathSegment)\n}\n\nfunction normalizePathSegment(segment: string): PathSegment {\n if (isIndexSegment(segment)) {\n return normalizeIndexSegment(segment)\n }\n\n if (isKeySegment(segment)) {\n return normalizeKeySegment(segment)\n }\n\n if (isIndexTuple(segment)) {\n return normalizeIndexTupleSegment(segment)\n }\n\n return segment\n}\n\nfunction normalizeIndexSegment(segment: string): PathSegment {\n return Number(segment.replace(/[^\\d]/g, ''))\n}\n\nfunction normalizeKeySegment(segment: string): KeyedSegment {\n const segments = segment.match(reKeySegment)\n return {_key: segments![1]}\n}\n\nfunction normalizeIndexTupleSegment(segment: string): IndexTuple {\n const [from, to] = segment.split(':').map((seg) => (seg === '' ? seg : Number(seg)))\n return [from, to]\n}\n"],"names":[],"mappings":";AAUA,MAAM,aACJ,oGACI,eAAe,4BACf,aAAmB,CAAC,GAEb,mBAAmB,KAI1B,wBAAwB,CAAC,QAAQ,SAAS,MAAM;AAItC,SAAA,IA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