wp-studio 1.7.7-alpha1
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/LICENSE.md +257 -0
- package/README.md +87 -0
- package/dist/cli/_events-BeOo0LuG.js +116 -0
- package/dist/cli/appdata-07CF2rhg.js +21090 -0
- package/dist/cli/archive-xDmkN4wb.js +15942 -0
- package/dist/cli/browser-CgWK-yoe.js +44 -0
- package/dist/cli/certificate-manager-DdBumKZp.js +250 -0
- package/dist/cli/create-BHVhkvTx.js +80 -0
- package/dist/cli/create-ZS29BDDi.js +40999 -0
- package/dist/cli/delete-BgQn-elT.js +56 -0
- package/dist/cli/delete-g8pgaLna.js +132 -0
- package/dist/cli/get-wordpress-version-BwSCJujO.js +18 -0
- package/dist/cli/index-7pbG_s_U.js +434 -0
- package/dist/cli/index-BXRYeCYG.js +1393 -0
- package/dist/cli/index-T3F1GwxX.js +2668 -0
- package/dist/cli/is-errno-exception-t38xF2pB.js +6 -0
- package/dist/cli/list-BE_UBjL5.js +105 -0
- package/dist/cli/list-DKz0XxM7.js +1032 -0
- package/dist/cli/logger-actions-OaIvl-ai.js +45 -0
- package/dist/cli/login-B4PkfKOu.js +82 -0
- package/dist/cli/logout-BC9gKlTj.js +48 -0
- package/dist/cli/main.js +5 -0
- package/dist/cli/mu-plugins-GEfKsl5U.js +530 -0
- package/dist/cli/passwords-DyzWd9Xi.js +80 -0
- package/dist/cli/process-manager-daemon.js +327 -0
- package/dist/cli/process-manager-ipc-AUZeYYDT.js +454 -0
- package/dist/cli/proxy-daemon.js +197 -0
- package/dist/cli/run-wp-cli-command-BctnMDWG.js +88 -0
- package/dist/cli/sequential-BQFuixXz.js +46 -0
- package/dist/cli/server-files-C_oy-mnI.js +26 -0
- package/dist/cli/set-DknhAZpw.js +327 -0
- package/dist/cli/site-utils-CfsabjUn.js +243 -0
- package/dist/cli/snapshots-6XE53y_F.js +874 -0
- package/dist/cli/sqlite-integration-H4OwSlwR.js +83 -0
- package/dist/cli/start-CRJqm09_.js +90 -0
- package/dist/cli/status-CWNHIOaY.js +44 -0
- package/dist/cli/status-CWWx9jYF.js +110 -0
- package/dist/cli/stop-CQosmjqA.js +117 -0
- package/dist/cli/update-BgL2HKHW.js +101 -0
- package/dist/cli/validation-error-DqLxqQuA.js +40 -0
- package/dist/cli/wordpress-server-child.js +514 -0
- package/dist/cli/wordpress-server-ipc-Dwsg9jSb.js +140 -0
- package/dist/cli/wordpress-server-manager-CtiuJqEb.js +566 -0
- package/dist/cli/wordpress-version-utils-B6UVeTh_.js +51 -0
- package/dist/cli/wp-UGSnlkN0.js +103 -0
- package/package.json +73 -0
- package/patches/@wp-playground+wordpress+3.1.12.patch +28 -0
- package/scripts/postinstall-npm.mjs +38 -0
|
@@ -0,0 +1,874 @@
|
|
|
1
|
+
import { k as getSiteByFolder, l as lockAppdata, r as readAppdata, g as getAuthToken, s as saveAppdata, u as unlockAppdata, L as LoggerError, o as DEMO_SITE_EXPIRATION_DAYS, N as HOUR_MS, O as DAY_MS } from "./appdata-07CF2rhg.js";
|
|
2
|
+
import { sprintf, __ } from "@wordpress/i18n";
|
|
3
|
+
import { t as toDate, a as getDefaultOptions } from "./index-7pbG_s_U.js";
|
|
4
|
+
function constructFrom(date, value) {
|
|
5
|
+
if (date instanceof Date) {
|
|
6
|
+
return new date.constructor(value);
|
|
7
|
+
} else {
|
|
8
|
+
return new Date(value);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function addDays(date, amount) {
|
|
12
|
+
const _date = toDate(date);
|
|
13
|
+
if (isNaN(amount)) return constructFrom(date, NaN);
|
|
14
|
+
if (!amount) {
|
|
15
|
+
return _date;
|
|
16
|
+
}
|
|
17
|
+
_date.setDate(_date.getDate() + amount);
|
|
18
|
+
return _date;
|
|
19
|
+
}
|
|
20
|
+
function addMonths(date, amount) {
|
|
21
|
+
const _date = toDate(date);
|
|
22
|
+
if (isNaN(amount)) return constructFrom(date, NaN);
|
|
23
|
+
if (!amount) {
|
|
24
|
+
return _date;
|
|
25
|
+
}
|
|
26
|
+
const dayOfMonth = _date.getDate();
|
|
27
|
+
const endOfDesiredMonth = constructFrom(date, _date.getTime());
|
|
28
|
+
endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
|
|
29
|
+
const daysInMonth = endOfDesiredMonth.getDate();
|
|
30
|
+
if (dayOfMonth >= daysInMonth) {
|
|
31
|
+
return endOfDesiredMonth;
|
|
32
|
+
} else {
|
|
33
|
+
_date.setFullYear(
|
|
34
|
+
endOfDesiredMonth.getFullYear(),
|
|
35
|
+
endOfDesiredMonth.getMonth(),
|
|
36
|
+
dayOfMonth
|
|
37
|
+
);
|
|
38
|
+
return _date;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function add(date, duration) {
|
|
42
|
+
const {
|
|
43
|
+
years = 0,
|
|
44
|
+
months = 0,
|
|
45
|
+
weeks = 0,
|
|
46
|
+
days = 0,
|
|
47
|
+
hours = 0,
|
|
48
|
+
minutes = 0,
|
|
49
|
+
seconds = 0
|
|
50
|
+
} = duration;
|
|
51
|
+
const _date = toDate(date);
|
|
52
|
+
const dateWithMonths = months || years ? addMonths(_date, months + years * 12) : _date;
|
|
53
|
+
const dateWithDays = days || weeks ? addDays(dateWithMonths, days + weeks * 7) : dateWithMonths;
|
|
54
|
+
const minutesToAdd = minutes + hours * 60;
|
|
55
|
+
const secondsToAdd = seconds + minutesToAdd * 60;
|
|
56
|
+
const msToAdd = secondsToAdd * 1e3;
|
|
57
|
+
const finalDate = constructFrom(date, dateWithDays.getTime() + msToAdd);
|
|
58
|
+
return finalDate;
|
|
59
|
+
}
|
|
60
|
+
function addMilliseconds(date, amount) {
|
|
61
|
+
const timestamp = +toDate(date);
|
|
62
|
+
return constructFrom(date, timestamp + amount);
|
|
63
|
+
}
|
|
64
|
+
const millisecondsInWeek = 6048e5;
|
|
65
|
+
const millisecondsInDay = 864e5;
|
|
66
|
+
const millisecondsInMinute = 6e4;
|
|
67
|
+
const millisecondsInHour = 36e5;
|
|
68
|
+
function addHours(date, amount) {
|
|
69
|
+
return addMilliseconds(date, amount * millisecondsInHour);
|
|
70
|
+
}
|
|
71
|
+
function startOfDay(date) {
|
|
72
|
+
const _date = toDate(date);
|
|
73
|
+
_date.setHours(0, 0, 0, 0);
|
|
74
|
+
return _date;
|
|
75
|
+
}
|
|
76
|
+
function getTimezoneOffsetInMilliseconds(date) {
|
|
77
|
+
const _date = toDate(date);
|
|
78
|
+
const utcDate = new Date(
|
|
79
|
+
Date.UTC(
|
|
80
|
+
_date.getFullYear(),
|
|
81
|
+
_date.getMonth(),
|
|
82
|
+
_date.getDate(),
|
|
83
|
+
_date.getHours(),
|
|
84
|
+
_date.getMinutes(),
|
|
85
|
+
_date.getSeconds(),
|
|
86
|
+
_date.getMilliseconds()
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
utcDate.setUTCFullYear(_date.getFullYear());
|
|
90
|
+
return +date - +utcDate;
|
|
91
|
+
}
|
|
92
|
+
function differenceInCalendarDays(dateLeft, dateRight) {
|
|
93
|
+
const startOfDayLeft = startOfDay(dateLeft);
|
|
94
|
+
const startOfDayRight = startOfDay(dateRight);
|
|
95
|
+
const timestampLeft = +startOfDayLeft - getTimezoneOffsetInMilliseconds(startOfDayLeft);
|
|
96
|
+
const timestampRight = +startOfDayRight - getTimezoneOffsetInMilliseconds(startOfDayRight);
|
|
97
|
+
return Math.round((timestampLeft - timestampRight) / millisecondsInDay);
|
|
98
|
+
}
|
|
99
|
+
function compareAsc(dateLeft, dateRight) {
|
|
100
|
+
const _dateLeft = toDate(dateLeft);
|
|
101
|
+
const _dateRight = toDate(dateRight);
|
|
102
|
+
const diff = _dateLeft.getTime() - _dateRight.getTime();
|
|
103
|
+
if (diff < 0) {
|
|
104
|
+
return -1;
|
|
105
|
+
} else if (diff > 0) {
|
|
106
|
+
return 1;
|
|
107
|
+
} else {
|
|
108
|
+
return diff;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function differenceInCalendarMonths(dateLeft, dateRight) {
|
|
112
|
+
const _dateLeft = toDate(dateLeft);
|
|
113
|
+
const _dateRight = toDate(dateRight);
|
|
114
|
+
const yearDiff = _dateLeft.getFullYear() - _dateRight.getFullYear();
|
|
115
|
+
const monthDiff = _dateLeft.getMonth() - _dateRight.getMonth();
|
|
116
|
+
return yearDiff * 12 + monthDiff;
|
|
117
|
+
}
|
|
118
|
+
function differenceInCalendarYears(dateLeft, dateRight) {
|
|
119
|
+
const _dateLeft = toDate(dateLeft);
|
|
120
|
+
const _dateRight = toDate(dateRight);
|
|
121
|
+
return _dateLeft.getFullYear() - _dateRight.getFullYear();
|
|
122
|
+
}
|
|
123
|
+
function differenceInDays(dateLeft, dateRight) {
|
|
124
|
+
const _dateLeft = toDate(dateLeft);
|
|
125
|
+
const _dateRight = toDate(dateRight);
|
|
126
|
+
const sign = compareLocalAsc(_dateLeft, _dateRight);
|
|
127
|
+
const difference = Math.abs(differenceInCalendarDays(_dateLeft, _dateRight));
|
|
128
|
+
_dateLeft.setDate(_dateLeft.getDate() - sign * difference);
|
|
129
|
+
const isLastDayNotFull = Number(
|
|
130
|
+
compareLocalAsc(_dateLeft, _dateRight) === -sign
|
|
131
|
+
);
|
|
132
|
+
const result = sign * (difference - isLastDayNotFull);
|
|
133
|
+
return result === 0 ? 0 : result;
|
|
134
|
+
}
|
|
135
|
+
function compareLocalAsc(dateLeft, dateRight) {
|
|
136
|
+
const diff = dateLeft.getFullYear() - dateRight.getFullYear() || dateLeft.getMonth() - dateRight.getMonth() || dateLeft.getDate() - dateRight.getDate() || dateLeft.getHours() - dateRight.getHours() || dateLeft.getMinutes() - dateRight.getMinutes() || dateLeft.getSeconds() - dateRight.getSeconds() || dateLeft.getMilliseconds() - dateRight.getMilliseconds();
|
|
137
|
+
if (diff < 0) {
|
|
138
|
+
return -1;
|
|
139
|
+
} else if (diff > 0) {
|
|
140
|
+
return 1;
|
|
141
|
+
} else {
|
|
142
|
+
return diff;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function getRoundingMethod(method) {
|
|
146
|
+
return (number) => {
|
|
147
|
+
const round = method ? Math[method] : Math.trunc;
|
|
148
|
+
const result = round(number);
|
|
149
|
+
return result === 0 ? 0 : result;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function differenceInMilliseconds(dateLeft, dateRight) {
|
|
153
|
+
return +toDate(dateLeft) - +toDate(dateRight);
|
|
154
|
+
}
|
|
155
|
+
function differenceInHours(dateLeft, dateRight, options) {
|
|
156
|
+
const diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;
|
|
157
|
+
return getRoundingMethod(options?.roundingMethod)(diff);
|
|
158
|
+
}
|
|
159
|
+
function differenceInMinutes(dateLeft, dateRight, options) {
|
|
160
|
+
const diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;
|
|
161
|
+
return getRoundingMethod(options?.roundingMethod)(diff);
|
|
162
|
+
}
|
|
163
|
+
function endOfDay(date) {
|
|
164
|
+
const _date = toDate(date);
|
|
165
|
+
_date.setHours(23, 59, 59, 999);
|
|
166
|
+
return _date;
|
|
167
|
+
}
|
|
168
|
+
function endOfMonth(date) {
|
|
169
|
+
const _date = toDate(date);
|
|
170
|
+
const month = _date.getMonth();
|
|
171
|
+
_date.setFullYear(_date.getFullYear(), month + 1, 0);
|
|
172
|
+
_date.setHours(23, 59, 59, 999);
|
|
173
|
+
return _date;
|
|
174
|
+
}
|
|
175
|
+
function isLastDayOfMonth(date) {
|
|
176
|
+
const _date = toDate(date);
|
|
177
|
+
return +endOfDay(_date) === +endOfMonth(_date);
|
|
178
|
+
}
|
|
179
|
+
function differenceInMonths(dateLeft, dateRight) {
|
|
180
|
+
const _dateLeft = toDate(dateLeft);
|
|
181
|
+
const _dateRight = toDate(dateRight);
|
|
182
|
+
const sign = compareAsc(_dateLeft, _dateRight);
|
|
183
|
+
const difference = Math.abs(
|
|
184
|
+
differenceInCalendarMonths(_dateLeft, _dateRight)
|
|
185
|
+
);
|
|
186
|
+
let result;
|
|
187
|
+
if (difference < 1) {
|
|
188
|
+
result = 0;
|
|
189
|
+
} else {
|
|
190
|
+
if (_dateLeft.getMonth() === 1 && _dateLeft.getDate() > 27) {
|
|
191
|
+
_dateLeft.setDate(30);
|
|
192
|
+
}
|
|
193
|
+
_dateLeft.setMonth(_dateLeft.getMonth() - sign * difference);
|
|
194
|
+
let isLastMonthNotFull = compareAsc(_dateLeft, _dateRight) === -sign;
|
|
195
|
+
if (isLastDayOfMonth(toDate(dateLeft)) && difference === 1 && compareAsc(dateLeft, _dateRight) === 1) {
|
|
196
|
+
isLastMonthNotFull = false;
|
|
197
|
+
}
|
|
198
|
+
result = sign * (difference - Number(isLastMonthNotFull));
|
|
199
|
+
}
|
|
200
|
+
return result === 0 ? 0 : result;
|
|
201
|
+
}
|
|
202
|
+
function differenceInSeconds(dateLeft, dateRight, options) {
|
|
203
|
+
const diff = differenceInMilliseconds(dateLeft, dateRight) / 1e3;
|
|
204
|
+
return getRoundingMethod(options?.roundingMethod)(diff);
|
|
205
|
+
}
|
|
206
|
+
function differenceInYears(dateLeft, dateRight) {
|
|
207
|
+
const _dateLeft = toDate(dateLeft);
|
|
208
|
+
const _dateRight = toDate(dateRight);
|
|
209
|
+
const sign = compareAsc(_dateLeft, _dateRight);
|
|
210
|
+
const difference = Math.abs(differenceInCalendarYears(_dateLeft, _dateRight));
|
|
211
|
+
_dateLeft.setFullYear(1584);
|
|
212
|
+
_dateRight.setFullYear(1584);
|
|
213
|
+
const isLastYearNotFull = compareAsc(_dateLeft, _dateRight) === -sign;
|
|
214
|
+
const result = sign * (difference - +isLastYearNotFull);
|
|
215
|
+
return result === 0 ? 0 : result;
|
|
216
|
+
}
|
|
217
|
+
const formatDistanceLocale = {
|
|
218
|
+
lessThanXSeconds: {
|
|
219
|
+
one: "less than a second",
|
|
220
|
+
other: "less than {{count}} seconds"
|
|
221
|
+
},
|
|
222
|
+
xSeconds: {
|
|
223
|
+
one: "1 second",
|
|
224
|
+
other: "{{count}} seconds"
|
|
225
|
+
},
|
|
226
|
+
halfAMinute: "half a minute",
|
|
227
|
+
lessThanXMinutes: {
|
|
228
|
+
one: "less than a minute",
|
|
229
|
+
other: "less than {{count}} minutes"
|
|
230
|
+
},
|
|
231
|
+
xMinutes: {
|
|
232
|
+
one: "1 minute",
|
|
233
|
+
other: "{{count}} minutes"
|
|
234
|
+
},
|
|
235
|
+
aboutXHours: {
|
|
236
|
+
one: "about 1 hour",
|
|
237
|
+
other: "about {{count}} hours"
|
|
238
|
+
},
|
|
239
|
+
xHours: {
|
|
240
|
+
one: "1 hour",
|
|
241
|
+
other: "{{count}} hours"
|
|
242
|
+
},
|
|
243
|
+
xDays: {
|
|
244
|
+
one: "1 day",
|
|
245
|
+
other: "{{count}} days"
|
|
246
|
+
},
|
|
247
|
+
aboutXWeeks: {
|
|
248
|
+
one: "about 1 week",
|
|
249
|
+
other: "about {{count}} weeks"
|
|
250
|
+
},
|
|
251
|
+
xWeeks: {
|
|
252
|
+
one: "1 week",
|
|
253
|
+
other: "{{count}} weeks"
|
|
254
|
+
},
|
|
255
|
+
aboutXMonths: {
|
|
256
|
+
one: "about 1 month",
|
|
257
|
+
other: "about {{count}} months"
|
|
258
|
+
},
|
|
259
|
+
xMonths: {
|
|
260
|
+
one: "1 month",
|
|
261
|
+
other: "{{count}} months"
|
|
262
|
+
},
|
|
263
|
+
aboutXYears: {
|
|
264
|
+
one: "about 1 year",
|
|
265
|
+
other: "about {{count}} years"
|
|
266
|
+
},
|
|
267
|
+
xYears: {
|
|
268
|
+
one: "1 year",
|
|
269
|
+
other: "{{count}} years"
|
|
270
|
+
},
|
|
271
|
+
overXYears: {
|
|
272
|
+
one: "over 1 year",
|
|
273
|
+
other: "over {{count}} years"
|
|
274
|
+
},
|
|
275
|
+
almostXYears: {
|
|
276
|
+
one: "almost 1 year",
|
|
277
|
+
other: "almost {{count}} years"
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
const formatDistance = (token, count, options) => {
|
|
281
|
+
let result;
|
|
282
|
+
const tokenValue = formatDistanceLocale[token];
|
|
283
|
+
if (typeof tokenValue === "string") {
|
|
284
|
+
result = tokenValue;
|
|
285
|
+
} else if (count === 1) {
|
|
286
|
+
result = tokenValue.one;
|
|
287
|
+
} else {
|
|
288
|
+
result = tokenValue.other.replace("{{count}}", count.toString());
|
|
289
|
+
}
|
|
290
|
+
if (options?.addSuffix) {
|
|
291
|
+
if (options.comparison && options.comparison > 0) {
|
|
292
|
+
return "in " + result;
|
|
293
|
+
} else {
|
|
294
|
+
return result + " ago";
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return result;
|
|
298
|
+
};
|
|
299
|
+
function buildFormatLongFn(args) {
|
|
300
|
+
return (options = {}) => {
|
|
301
|
+
const width = options.width ? String(options.width) : args.defaultWidth;
|
|
302
|
+
const format = args.formats[width] || args.formats[args.defaultWidth];
|
|
303
|
+
return format;
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const dateFormats = {
|
|
307
|
+
full: "EEEE, MMMM do, y",
|
|
308
|
+
long: "MMMM do, y",
|
|
309
|
+
medium: "MMM d, y",
|
|
310
|
+
short: "MM/dd/yyyy"
|
|
311
|
+
};
|
|
312
|
+
const timeFormats = {
|
|
313
|
+
full: "h:mm:ss a zzzz",
|
|
314
|
+
long: "h:mm:ss a z",
|
|
315
|
+
medium: "h:mm:ss a",
|
|
316
|
+
short: "h:mm a"
|
|
317
|
+
};
|
|
318
|
+
const dateTimeFormats = {
|
|
319
|
+
full: "{{date}} 'at' {{time}}",
|
|
320
|
+
long: "{{date}} 'at' {{time}}",
|
|
321
|
+
medium: "{{date}}, {{time}}",
|
|
322
|
+
short: "{{date}}, {{time}}"
|
|
323
|
+
};
|
|
324
|
+
const formatLong = {
|
|
325
|
+
date: buildFormatLongFn({
|
|
326
|
+
formats: dateFormats,
|
|
327
|
+
defaultWidth: "full"
|
|
328
|
+
}),
|
|
329
|
+
time: buildFormatLongFn({
|
|
330
|
+
formats: timeFormats,
|
|
331
|
+
defaultWidth: "full"
|
|
332
|
+
}),
|
|
333
|
+
dateTime: buildFormatLongFn({
|
|
334
|
+
formats: dateTimeFormats,
|
|
335
|
+
defaultWidth: "full"
|
|
336
|
+
})
|
|
337
|
+
};
|
|
338
|
+
const formatRelativeLocale = {
|
|
339
|
+
lastWeek: "'last' eeee 'at' p",
|
|
340
|
+
yesterday: "'yesterday at' p",
|
|
341
|
+
today: "'today at' p",
|
|
342
|
+
tomorrow: "'tomorrow at' p",
|
|
343
|
+
nextWeek: "eeee 'at' p",
|
|
344
|
+
other: "P"
|
|
345
|
+
};
|
|
346
|
+
const formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
|
|
347
|
+
function buildLocalizeFn(args) {
|
|
348
|
+
return (value, options) => {
|
|
349
|
+
const context = options?.context ? String(options.context) : "standalone";
|
|
350
|
+
let valuesArray;
|
|
351
|
+
if (context === "formatting" && args.formattingValues) {
|
|
352
|
+
const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
|
|
353
|
+
const width = options?.width ? String(options.width) : defaultWidth;
|
|
354
|
+
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
|
|
355
|
+
} else {
|
|
356
|
+
const defaultWidth = args.defaultWidth;
|
|
357
|
+
const width = options?.width ? String(options.width) : args.defaultWidth;
|
|
358
|
+
valuesArray = args.values[width] || args.values[defaultWidth];
|
|
359
|
+
}
|
|
360
|
+
const index = args.argumentCallback ? args.argumentCallback(value) : value;
|
|
361
|
+
return valuesArray[index];
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
const eraValues = {
|
|
365
|
+
narrow: ["B", "A"],
|
|
366
|
+
abbreviated: ["BC", "AD"],
|
|
367
|
+
wide: ["Before Christ", "Anno Domini"]
|
|
368
|
+
};
|
|
369
|
+
const quarterValues = {
|
|
370
|
+
narrow: ["1", "2", "3", "4"],
|
|
371
|
+
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
|
|
372
|
+
wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
|
|
373
|
+
};
|
|
374
|
+
const monthValues = {
|
|
375
|
+
narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
|
|
376
|
+
abbreviated: [
|
|
377
|
+
"Jan",
|
|
378
|
+
"Feb",
|
|
379
|
+
"Mar",
|
|
380
|
+
"Apr",
|
|
381
|
+
"May",
|
|
382
|
+
"Jun",
|
|
383
|
+
"Jul",
|
|
384
|
+
"Aug",
|
|
385
|
+
"Sep",
|
|
386
|
+
"Oct",
|
|
387
|
+
"Nov",
|
|
388
|
+
"Dec"
|
|
389
|
+
],
|
|
390
|
+
wide: [
|
|
391
|
+
"January",
|
|
392
|
+
"February",
|
|
393
|
+
"March",
|
|
394
|
+
"April",
|
|
395
|
+
"May",
|
|
396
|
+
"June",
|
|
397
|
+
"July",
|
|
398
|
+
"August",
|
|
399
|
+
"September",
|
|
400
|
+
"October",
|
|
401
|
+
"November",
|
|
402
|
+
"December"
|
|
403
|
+
]
|
|
404
|
+
};
|
|
405
|
+
const dayValues = {
|
|
406
|
+
narrow: ["S", "M", "T", "W", "T", "F", "S"],
|
|
407
|
+
short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
|
|
408
|
+
abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
409
|
+
wide: [
|
|
410
|
+
"Sunday",
|
|
411
|
+
"Monday",
|
|
412
|
+
"Tuesday",
|
|
413
|
+
"Wednesday",
|
|
414
|
+
"Thursday",
|
|
415
|
+
"Friday",
|
|
416
|
+
"Saturday"
|
|
417
|
+
]
|
|
418
|
+
};
|
|
419
|
+
const dayPeriodValues = {
|
|
420
|
+
narrow: {
|
|
421
|
+
am: "a",
|
|
422
|
+
pm: "p",
|
|
423
|
+
midnight: "mi",
|
|
424
|
+
noon: "n",
|
|
425
|
+
morning: "morning",
|
|
426
|
+
afternoon: "afternoon",
|
|
427
|
+
evening: "evening",
|
|
428
|
+
night: "night"
|
|
429
|
+
},
|
|
430
|
+
abbreviated: {
|
|
431
|
+
am: "AM",
|
|
432
|
+
pm: "PM",
|
|
433
|
+
midnight: "midnight",
|
|
434
|
+
noon: "noon",
|
|
435
|
+
morning: "morning",
|
|
436
|
+
afternoon: "afternoon",
|
|
437
|
+
evening: "evening",
|
|
438
|
+
night: "night"
|
|
439
|
+
},
|
|
440
|
+
wide: {
|
|
441
|
+
am: "a.m.",
|
|
442
|
+
pm: "p.m.",
|
|
443
|
+
midnight: "midnight",
|
|
444
|
+
noon: "noon",
|
|
445
|
+
morning: "morning",
|
|
446
|
+
afternoon: "afternoon",
|
|
447
|
+
evening: "evening",
|
|
448
|
+
night: "night"
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
const formattingDayPeriodValues = {
|
|
452
|
+
narrow: {
|
|
453
|
+
am: "a",
|
|
454
|
+
pm: "p",
|
|
455
|
+
midnight: "mi",
|
|
456
|
+
noon: "n",
|
|
457
|
+
morning: "in the morning",
|
|
458
|
+
afternoon: "in the afternoon",
|
|
459
|
+
evening: "in the evening",
|
|
460
|
+
night: "at night"
|
|
461
|
+
},
|
|
462
|
+
abbreviated: {
|
|
463
|
+
am: "AM",
|
|
464
|
+
pm: "PM",
|
|
465
|
+
midnight: "midnight",
|
|
466
|
+
noon: "noon",
|
|
467
|
+
morning: "in the morning",
|
|
468
|
+
afternoon: "in the afternoon",
|
|
469
|
+
evening: "in the evening",
|
|
470
|
+
night: "at night"
|
|
471
|
+
},
|
|
472
|
+
wide: {
|
|
473
|
+
am: "a.m.",
|
|
474
|
+
pm: "p.m.",
|
|
475
|
+
midnight: "midnight",
|
|
476
|
+
noon: "noon",
|
|
477
|
+
morning: "in the morning",
|
|
478
|
+
afternoon: "in the afternoon",
|
|
479
|
+
evening: "in the evening",
|
|
480
|
+
night: "at night"
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
const ordinalNumber = (dirtyNumber, _options) => {
|
|
484
|
+
const number = Number(dirtyNumber);
|
|
485
|
+
const rem100 = number % 100;
|
|
486
|
+
if (rem100 > 20 || rem100 < 10) {
|
|
487
|
+
switch (rem100 % 10) {
|
|
488
|
+
case 1:
|
|
489
|
+
return number + "st";
|
|
490
|
+
case 2:
|
|
491
|
+
return number + "nd";
|
|
492
|
+
case 3:
|
|
493
|
+
return number + "rd";
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return number + "th";
|
|
497
|
+
};
|
|
498
|
+
const localize = {
|
|
499
|
+
ordinalNumber,
|
|
500
|
+
era: buildLocalizeFn({
|
|
501
|
+
values: eraValues,
|
|
502
|
+
defaultWidth: "wide"
|
|
503
|
+
}),
|
|
504
|
+
quarter: buildLocalizeFn({
|
|
505
|
+
values: quarterValues,
|
|
506
|
+
defaultWidth: "wide",
|
|
507
|
+
argumentCallback: (quarter) => quarter - 1
|
|
508
|
+
}),
|
|
509
|
+
month: buildLocalizeFn({
|
|
510
|
+
values: monthValues,
|
|
511
|
+
defaultWidth: "wide"
|
|
512
|
+
}),
|
|
513
|
+
day: buildLocalizeFn({
|
|
514
|
+
values: dayValues,
|
|
515
|
+
defaultWidth: "wide"
|
|
516
|
+
}),
|
|
517
|
+
dayPeriod: buildLocalizeFn({
|
|
518
|
+
values: dayPeriodValues,
|
|
519
|
+
defaultWidth: "wide",
|
|
520
|
+
formattingValues: formattingDayPeriodValues,
|
|
521
|
+
defaultFormattingWidth: "wide"
|
|
522
|
+
})
|
|
523
|
+
};
|
|
524
|
+
function buildMatchFn(args) {
|
|
525
|
+
return (string, options = {}) => {
|
|
526
|
+
const width = options.width;
|
|
527
|
+
const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
|
|
528
|
+
const matchResult = string.match(matchPattern);
|
|
529
|
+
if (!matchResult) {
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
const matchedString = matchResult[0];
|
|
533
|
+
const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
|
|
534
|
+
const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
|
|
535
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
|
|
536
|
+
findKey(parsePatterns, (pattern) => pattern.test(matchedString))
|
|
537
|
+
);
|
|
538
|
+
let value;
|
|
539
|
+
value = args.valueCallback ? args.valueCallback(key) : key;
|
|
540
|
+
value = options.valueCallback ? (
|
|
541
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
|
|
542
|
+
options.valueCallback(value)
|
|
543
|
+
) : value;
|
|
544
|
+
const rest = string.slice(matchedString.length);
|
|
545
|
+
return { value, rest };
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function findKey(object, predicate) {
|
|
549
|
+
for (const key in object) {
|
|
550
|
+
if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
|
|
551
|
+
return key;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return void 0;
|
|
555
|
+
}
|
|
556
|
+
function findIndex(array, predicate) {
|
|
557
|
+
for (let key = 0; key < array.length; key++) {
|
|
558
|
+
if (predicate(array[key])) {
|
|
559
|
+
return key;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return void 0;
|
|
563
|
+
}
|
|
564
|
+
function buildMatchPatternFn(args) {
|
|
565
|
+
return (string, options = {}) => {
|
|
566
|
+
const matchResult = string.match(args.matchPattern);
|
|
567
|
+
if (!matchResult) return null;
|
|
568
|
+
const matchedString = matchResult[0];
|
|
569
|
+
const parseResult = string.match(args.parsePattern);
|
|
570
|
+
if (!parseResult) return null;
|
|
571
|
+
let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
|
|
572
|
+
value = options.valueCallback ? options.valueCallback(value) : value;
|
|
573
|
+
const rest = string.slice(matchedString.length);
|
|
574
|
+
return { value, rest };
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
const matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
|
|
578
|
+
const parseOrdinalNumberPattern = /\d+/i;
|
|
579
|
+
const matchEraPatterns = {
|
|
580
|
+
narrow: /^(b|a)/i,
|
|
581
|
+
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
|
|
582
|
+
wide: /^(before christ|before common era|anno domini|common era)/i
|
|
583
|
+
};
|
|
584
|
+
const parseEraPatterns = {
|
|
585
|
+
any: [/^b/i, /^(a|c)/i]
|
|
586
|
+
};
|
|
587
|
+
const matchQuarterPatterns = {
|
|
588
|
+
narrow: /^[1234]/i,
|
|
589
|
+
abbreviated: /^q[1234]/i,
|
|
590
|
+
wide: /^[1234](th|st|nd|rd)? quarter/i
|
|
591
|
+
};
|
|
592
|
+
const parseQuarterPatterns = {
|
|
593
|
+
any: [/1/i, /2/i, /3/i, /4/i]
|
|
594
|
+
};
|
|
595
|
+
const matchMonthPatterns = {
|
|
596
|
+
narrow: /^[jfmasond]/i,
|
|
597
|
+
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
|
|
598
|
+
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
|
|
599
|
+
};
|
|
600
|
+
const parseMonthPatterns = {
|
|
601
|
+
narrow: [
|
|
602
|
+
/^j/i,
|
|
603
|
+
/^f/i,
|
|
604
|
+
/^m/i,
|
|
605
|
+
/^a/i,
|
|
606
|
+
/^m/i,
|
|
607
|
+
/^j/i,
|
|
608
|
+
/^j/i,
|
|
609
|
+
/^a/i,
|
|
610
|
+
/^s/i,
|
|
611
|
+
/^o/i,
|
|
612
|
+
/^n/i,
|
|
613
|
+
/^d/i
|
|
614
|
+
],
|
|
615
|
+
any: [
|
|
616
|
+
/^ja/i,
|
|
617
|
+
/^f/i,
|
|
618
|
+
/^mar/i,
|
|
619
|
+
/^ap/i,
|
|
620
|
+
/^may/i,
|
|
621
|
+
/^jun/i,
|
|
622
|
+
/^jul/i,
|
|
623
|
+
/^au/i,
|
|
624
|
+
/^s/i,
|
|
625
|
+
/^o/i,
|
|
626
|
+
/^n/i,
|
|
627
|
+
/^d/i
|
|
628
|
+
]
|
|
629
|
+
};
|
|
630
|
+
const matchDayPatterns = {
|
|
631
|
+
narrow: /^[smtwf]/i,
|
|
632
|
+
short: /^(su|mo|tu|we|th|fr|sa)/i,
|
|
633
|
+
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
|
|
634
|
+
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
|
|
635
|
+
};
|
|
636
|
+
const parseDayPatterns = {
|
|
637
|
+
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
|
|
638
|
+
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
|
|
639
|
+
};
|
|
640
|
+
const matchDayPeriodPatterns = {
|
|
641
|
+
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
|
|
642
|
+
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
|
|
643
|
+
};
|
|
644
|
+
const parseDayPeriodPatterns = {
|
|
645
|
+
any: {
|
|
646
|
+
am: /^a/i,
|
|
647
|
+
pm: /^p/i,
|
|
648
|
+
midnight: /^mi/i,
|
|
649
|
+
noon: /^no/i,
|
|
650
|
+
morning: /morning/i,
|
|
651
|
+
afternoon: /afternoon/i,
|
|
652
|
+
evening: /evening/i,
|
|
653
|
+
night: /night/i
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
const match = {
|
|
657
|
+
ordinalNumber: buildMatchPatternFn({
|
|
658
|
+
matchPattern: matchOrdinalNumberPattern,
|
|
659
|
+
parsePattern: parseOrdinalNumberPattern,
|
|
660
|
+
valueCallback: (value) => parseInt(value, 10)
|
|
661
|
+
}),
|
|
662
|
+
era: buildMatchFn({
|
|
663
|
+
matchPatterns: matchEraPatterns,
|
|
664
|
+
defaultMatchWidth: "wide",
|
|
665
|
+
parsePatterns: parseEraPatterns,
|
|
666
|
+
defaultParseWidth: "any"
|
|
667
|
+
}),
|
|
668
|
+
quarter: buildMatchFn({
|
|
669
|
+
matchPatterns: matchQuarterPatterns,
|
|
670
|
+
defaultMatchWidth: "wide",
|
|
671
|
+
parsePatterns: parseQuarterPatterns,
|
|
672
|
+
defaultParseWidth: "any",
|
|
673
|
+
valueCallback: (index) => index + 1
|
|
674
|
+
}),
|
|
675
|
+
month: buildMatchFn({
|
|
676
|
+
matchPatterns: matchMonthPatterns,
|
|
677
|
+
defaultMatchWidth: "wide",
|
|
678
|
+
parsePatterns: parseMonthPatterns,
|
|
679
|
+
defaultParseWidth: "any"
|
|
680
|
+
}),
|
|
681
|
+
day: buildMatchFn({
|
|
682
|
+
matchPatterns: matchDayPatterns,
|
|
683
|
+
defaultMatchWidth: "wide",
|
|
684
|
+
parsePatterns: parseDayPatterns,
|
|
685
|
+
defaultParseWidth: "any"
|
|
686
|
+
}),
|
|
687
|
+
dayPeriod: buildMatchFn({
|
|
688
|
+
matchPatterns: matchDayPeriodPatterns,
|
|
689
|
+
defaultMatchWidth: "any",
|
|
690
|
+
parsePatterns: parseDayPeriodPatterns,
|
|
691
|
+
defaultParseWidth: "any"
|
|
692
|
+
})
|
|
693
|
+
};
|
|
694
|
+
const enUS = {
|
|
695
|
+
code: "en-US",
|
|
696
|
+
formatDistance,
|
|
697
|
+
formatLong,
|
|
698
|
+
formatRelative,
|
|
699
|
+
localize,
|
|
700
|
+
match,
|
|
701
|
+
options: {
|
|
702
|
+
weekStartsOn: 0,
|
|
703
|
+
firstWeekContainsDate: 1
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
const defaultFormat = [
|
|
707
|
+
"years",
|
|
708
|
+
"months",
|
|
709
|
+
"weeks",
|
|
710
|
+
"days",
|
|
711
|
+
"hours",
|
|
712
|
+
"minutes",
|
|
713
|
+
"seconds"
|
|
714
|
+
];
|
|
715
|
+
function formatDuration(duration, options) {
|
|
716
|
+
const defaultOptions = getDefaultOptions();
|
|
717
|
+
const locale = options?.locale ?? defaultOptions.locale ?? enUS;
|
|
718
|
+
const format = options?.format ?? defaultFormat;
|
|
719
|
+
const zero = options?.zero ?? false;
|
|
720
|
+
const delimiter = options?.delimiter;
|
|
721
|
+
if (!locale.formatDistance) {
|
|
722
|
+
return "";
|
|
723
|
+
}
|
|
724
|
+
const result = format.reduce((acc, unit) => {
|
|
725
|
+
const token = `x${unit.replace(/(^.)/, (m) => m.toUpperCase())}`;
|
|
726
|
+
const value = duration[unit];
|
|
727
|
+
if (value !== void 0 && (zero || duration[unit])) {
|
|
728
|
+
return acc.concat(locale.formatDistance(token, value));
|
|
729
|
+
}
|
|
730
|
+
return acc;
|
|
731
|
+
}, []).join(delimiter);
|
|
732
|
+
return result;
|
|
733
|
+
}
|
|
734
|
+
function intervalToDuration(interval) {
|
|
735
|
+
const start = toDate(interval.start);
|
|
736
|
+
const end = toDate(interval.end);
|
|
737
|
+
const duration = {};
|
|
738
|
+
const years = differenceInYears(end, start);
|
|
739
|
+
if (years) duration.years = years;
|
|
740
|
+
const remainingMonths = add(start, { years: duration.years });
|
|
741
|
+
const months = differenceInMonths(end, remainingMonths);
|
|
742
|
+
if (months) duration.months = months;
|
|
743
|
+
const remainingDays = add(remainingMonths, { months: duration.months });
|
|
744
|
+
const days = differenceInDays(end, remainingDays);
|
|
745
|
+
if (days) duration.days = days;
|
|
746
|
+
const remainingHours = add(remainingDays, { days: duration.days });
|
|
747
|
+
const hours = differenceInHours(end, remainingHours);
|
|
748
|
+
if (hours) duration.hours = hours;
|
|
749
|
+
const remainingMinutes = add(remainingHours, { hours: duration.hours });
|
|
750
|
+
const minutes = differenceInMinutes(end, remainingMinutes);
|
|
751
|
+
if (minutes) duration.minutes = minutes;
|
|
752
|
+
const remainingSeconds = add(remainingMinutes, { minutes: duration.minutes });
|
|
753
|
+
const seconds = differenceInSeconds(end, remainingSeconds);
|
|
754
|
+
if (seconds) duration.seconds = seconds;
|
|
755
|
+
return duration;
|
|
756
|
+
}
|
|
757
|
+
async function getSnapshotsFromAppdata(userId, siteFolder) {
|
|
758
|
+
const userData = await readAppdata();
|
|
759
|
+
let snapshots = userData.snapshots;
|
|
760
|
+
snapshots = snapshots.filter((snapshot) => snapshot.userId === userId);
|
|
761
|
+
if (siteFolder) {
|
|
762
|
+
const site = await getSiteByFolder(siteFolder);
|
|
763
|
+
snapshots = snapshots.filter((snapshot) => snapshot.localSiteId === site.id);
|
|
764
|
+
}
|
|
765
|
+
return snapshots;
|
|
766
|
+
}
|
|
767
|
+
async function updateSnapshotInAppdata(atomicSiteId, siteFolder) {
|
|
768
|
+
try {
|
|
769
|
+
const site = await getSiteByFolder(siteFolder);
|
|
770
|
+
await lockAppdata();
|
|
771
|
+
const userData = await readAppdata();
|
|
772
|
+
const snapshot = userData.snapshots.find((s) => s.atomicSiteId === atomicSiteId);
|
|
773
|
+
if (!snapshot) {
|
|
774
|
+
throw new LoggerError(__("Failed to find existing preview site in appdata"));
|
|
775
|
+
}
|
|
776
|
+
snapshot.localSiteId = site.id;
|
|
777
|
+
snapshot.date = Date.now();
|
|
778
|
+
await saveAppdata(userData);
|
|
779
|
+
return snapshot;
|
|
780
|
+
} finally {
|
|
781
|
+
await unlockAppdata();
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
const getNextSequenceNumber = (siteId, snapshots, userId) => {
|
|
785
|
+
const siteSnapshots = snapshots.filter(
|
|
786
|
+
(s) => s.localSiteId === siteId && s.userId === userId
|
|
787
|
+
);
|
|
788
|
+
const existingSequences = siteSnapshots.map((s) => s.sequence ?? 0).filter((n) => !isNaN(n));
|
|
789
|
+
return existingSequences.length > 0 ? Math.max(...existingSequences) + 1 : siteSnapshots.length + 1;
|
|
790
|
+
};
|
|
791
|
+
async function saveSnapshotToAppdata(siteFolder, atomicSiteId, previewUrl) {
|
|
792
|
+
try {
|
|
793
|
+
const site = await getSiteByFolder(siteFolder);
|
|
794
|
+
await lockAppdata();
|
|
795
|
+
const userData = await readAppdata();
|
|
796
|
+
const authToken = await getAuthToken();
|
|
797
|
+
const nextSequenceNumber = getNextSequenceNumber(site.id, userData.snapshots, authToken.id);
|
|
798
|
+
const snapshot = {
|
|
799
|
+
url: previewUrl,
|
|
800
|
+
atomicSiteId,
|
|
801
|
+
localSiteId: site.id,
|
|
802
|
+
date: Date.now(),
|
|
803
|
+
name: sprintf(
|
|
804
|
+
/* translators: 1: Site name 2: Sequence number (e.g. "My Site Name Preview 1") */
|
|
805
|
+
__("%1$s Preview %2$d"),
|
|
806
|
+
site.name,
|
|
807
|
+
nextSequenceNumber
|
|
808
|
+
),
|
|
809
|
+
sequence: nextSequenceNumber,
|
|
810
|
+
userId: authToken.id
|
|
811
|
+
};
|
|
812
|
+
userData.snapshots.push(snapshot);
|
|
813
|
+
await saveAppdata(userData);
|
|
814
|
+
return snapshot;
|
|
815
|
+
} finally {
|
|
816
|
+
await unlockAppdata();
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
async function deleteSnapshotFromAppdata(snapshotUrl) {
|
|
820
|
+
try {
|
|
821
|
+
await lockAppdata();
|
|
822
|
+
const userData = await readAppdata();
|
|
823
|
+
const snapshotIndex = userData.snapshots.findIndex((s) => s.url === snapshotUrl);
|
|
824
|
+
if (snapshotIndex === -1) {
|
|
825
|
+
return;
|
|
826
|
+
}
|
|
827
|
+
userData.snapshots.splice(snapshotIndex, 1);
|
|
828
|
+
await saveAppdata(userData);
|
|
829
|
+
} finally {
|
|
830
|
+
await unlockAppdata();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
function isSnapshotExpired(snapshot) {
|
|
834
|
+
const now = /* @__PURE__ */ new Date();
|
|
835
|
+
const endDate = addDays(snapshot.date, DEMO_SITE_EXPIRATION_DAYS);
|
|
836
|
+
return endDate < now;
|
|
837
|
+
}
|
|
838
|
+
function formatDurationUntilExpiry(lastUpdatedAt) {
|
|
839
|
+
const now = /* @__PURE__ */ new Date();
|
|
840
|
+
const endDate = addDays(lastUpdatedAt, DEMO_SITE_EXPIRATION_DAYS);
|
|
841
|
+
const difference = endDate.getTime() - now.getTime();
|
|
842
|
+
let format = ["days", "hours"];
|
|
843
|
+
if (difference < HOUR_MS) {
|
|
844
|
+
format = ["minutes"];
|
|
845
|
+
} else if (difference < DAY_MS) {
|
|
846
|
+
format = ["hours", "minutes"];
|
|
847
|
+
}
|
|
848
|
+
if (endDate < now) {
|
|
849
|
+
return __("Expired");
|
|
850
|
+
}
|
|
851
|
+
return formatDuration(
|
|
852
|
+
intervalToDuration({
|
|
853
|
+
start: now,
|
|
854
|
+
end: addHours(endDate, 1)
|
|
855
|
+
}),
|
|
856
|
+
{
|
|
857
|
+
format,
|
|
858
|
+
delimiter: ", "
|
|
859
|
+
}
|
|
860
|
+
);
|
|
861
|
+
}
|
|
862
|
+
export {
|
|
863
|
+
deleteSnapshotFromAppdata as a,
|
|
864
|
+
addDays as b,
|
|
865
|
+
constructFrom as c,
|
|
866
|
+
differenceInCalendarDays as d,
|
|
867
|
+
enUS as e,
|
|
868
|
+
formatDurationUntilExpiry as f,
|
|
869
|
+
getSnapshotsFromAppdata as g,
|
|
870
|
+
isSnapshotExpired as i,
|
|
871
|
+
millisecondsInWeek as m,
|
|
872
|
+
saveSnapshotToAppdata as s,
|
|
873
|
+
updateSnapshotInAppdata as u
|
|
874
|
+
};
|