goatly 0.1.0 → 0.1.2

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 (161) hide show
  1. package/README.md +874 -1
  2. package/bin/goatly.js +99 -0
  3. package/dist/cli/index.js +234 -0
  4. package/dist/compat/gatsby-node-entry.js +16 -0
  5. package/dist/compat/gatsby-package.json +6 -0
  6. package/dist/compat/md5-file.js +47 -0
  7. package/dist/compat-apis.json +72 -0
  8. package/dist/compat-apis.json.js +62 -0
  9. package/dist/graphql.js +3 -0
  10. package/dist/node/actions/index.js +619 -0
  11. package/dist/node/actions/job-store.js +180 -0
  12. package/dist/node/actions/jobs.js +174 -0
  13. package/dist/node/api-runner.js +258 -0
  14. package/dist/node/bootstrap.js +569 -0
  15. package/dist/node/build/assets.js +110 -0
  16. package/dist/node/build/incremental.js +208 -0
  17. package/dist/node/build/index.js +763 -0
  18. package/dist/node/build/memory-governor.js +450 -0
  19. package/dist/node/build/output-dirs.js +70 -0
  20. package/dist/node/build/page-data.js +40 -0
  21. package/dist/node/build/page-files.js +186 -0
  22. package/dist/node/build/partitioned-state.js +258 -0
  23. package/dist/node/build/query-worker.js +626 -0
  24. package/dist/node/build/query-workers.js +863 -0
  25. package/dist/node/build/render-thread.js +103 -0
  26. package/dist/node/build/render-worker.js +162 -0
  27. package/dist/node/build/state.js +24 -0
  28. package/dist/node/build/timing-breakdown.js +216 -0
  29. package/dist/node/build/work-clock.js +75 -0
  30. package/dist/node/build/worker-pool.js +242 -0
  31. package/dist/node/cache-layout.js +99 -0
  32. package/dist/node/cache.js +1430 -0
  33. package/dist/node/compat/chokidar-shim.js +148 -0
  34. package/dist/node/compat/core-utils-lmdb.js +145 -0
  35. package/dist/node/compat/create-node-id-shim.js +1 -0
  36. package/dist/node/compat/module-hooks.js +245 -0
  37. package/dist/node/compat/redux-shim.js +1 -0
  38. package/dist/node/config/index.js +162 -0
  39. package/dist/node/config/not-found-pages.js +95 -0
  40. package/dist/node/datastore/codec.js +144 -0
  41. package/dist/node/datastore/index.js +127 -0
  42. package/dist/node/datastore/logfile/cache.js +89 -0
  43. package/dist/node/datastore/logfile/index.js +1329 -0
  44. package/dist/node/datastore/logfile/record.js +71 -0
  45. package/dist/node/datastore/types.js +1 -0
  46. package/dist/node/develop/express-compat.js +207 -0
  47. package/dist/node/develop/graphiql.js +22 -0
  48. package/dist/node/develop/hydration-report.js +41 -0
  49. package/dist/node/develop/index.js +618 -0
  50. package/dist/node/develop/local-url.js +10 -0
  51. package/dist/node/develop/ssr-runner.js +66 -0
  52. package/dist/node/gql.js +5 -0
  53. package/dist/node/index.js +15 -0
  54. package/dist/node/info.js +270 -0
  55. package/dist/node/internal-plugins/data-bridge.js +196 -0
  56. package/dist/node/internal-plugins/page-creator.js +318 -0
  57. package/dist/node/loader/import-module.js +160 -0
  58. package/dist/node/node-helpers.js +66 -0
  59. package/dist/node/not-found-pages.js +220 -0
  60. package/dist/node/plugins/api-list.js +12 -0
  61. package/dist/node/plugins/load-plugins.js +427 -0
  62. package/dist/node/plugins/resolve-plugin.js +79 -0
  63. package/dist/node/plugins/static-exports.js +64 -0
  64. package/dist/node/query/compile.js +326 -0
  65. package/dist/node/query/dependencies.js +45 -0
  66. package/dist/node/query/execute.js +417 -0
  67. package/dist/node/query/extract.js +372 -0
  68. package/dist/node/query/gql-tada-introspection.js +124 -0
  69. package/dist/node/query/graphql-env.js +231 -0
  70. package/dist/node/query/graphql-runner.js +79 -0
  71. package/dist/node/redux/actions.js +1 -0
  72. package/dist/node/redux/index.js +133 -0
  73. package/dist/node/redux/node-changes.js +128 -0
  74. package/dist/node/redux/reducers.js +193 -0
  75. package/dist/node/redux/state.js +71 -0
  76. package/dist/node/renderer.js +124 -0
  77. package/dist/node/reporter-transports.js +259 -0
  78. package/dist/node/reporter.js +497 -0
  79. package/dist/node/schema/date.js +539 -0
  80. package/dist/node/schema/extensions.js +315 -0
  81. package/dist/node/schema/index.js +542 -0
  82. package/dist/node/schema/infer.js +388 -0
  83. package/dist/node/schema/inline-objects.js +128 -0
  84. package/dist/node/schema/naming.js +20 -0
  85. package/dist/node/schema/node-model.js +207 -0
  86. package/dist/node/schema/query-engine.js +1808 -0
  87. package/dist/node/schema/resolver-kinds.js +7 -0
  88. package/dist/node/schema/resolvers.js +273 -0
  89. package/dist/node/schema/type-builders.js +45 -0
  90. package/dist/node/schema/types.js +241 -0
  91. package/dist/node/serve.js +90 -0
  92. package/dist/node/site-page-nodes.js +277 -0
  93. package/dist/node/types.js +1 -0
  94. package/dist/node/utils/content-digest.js +107 -0
  95. package/dist/node/utils/cpus.js +104 -0
  96. package/dist/node/utils/create-node-id.js +51 -0
  97. package/dist/node/utils/env.js +25 -0
  98. package/dist/node/utils/fs-retry.js +74 -0
  99. package/dist/node/utils/memory-signals.js +441 -0
  100. package/dist/node/utils/memory.js +657 -0
  101. package/dist/node/utils/murmurhash.js +32 -0
  102. package/dist/node/utils/parser.js +33 -0
  103. package/dist/node/utils/partition-hash.js +19 -0
  104. package/dist/node/utils/paths.js +122 -0
  105. package/dist/node/utils/resolver.js +48 -0
  106. package/dist/node/utils/runtime.js +5 -0
  107. package/dist/node/utils/serializable.js +41 -0
  108. package/dist/node/utils/strings.js +41 -0
  109. package/dist/node/vite/config.js +289 -0
  110. package/dist/node/vite/paths.js +12 -0
  111. package/dist/node/vite/plugin-deps.js +232 -0
  112. package/dist/node/vite/plugin.js +283 -0
  113. package/dist/node/vite/react-compiler.js +362 -0
  114. package/dist/node/vite/source-files.js +83 -0
  115. package/dist/node/vite/static-image.js +136 -0
  116. package/dist/node/vite/styled-components.js +73 -0
  117. package/dist/node/vite/transforms.js +330 -0
  118. package/dist/node/wasm-data/host.js +406 -0
  119. package/dist/node/wasm-data/lower.js +406 -0
  120. package/dist/node/wasm-data/runner.js +79 -0
  121. package/dist/node/wasm-data/worker.js +95 -0
  122. package/dist/reporter.js +5 -0
  123. package/dist/runtime/api-runner.js +81 -0
  124. package/dist/runtime/app.js +256 -0
  125. package/dist/runtime/client-entry.js +4 -0
  126. package/dist/runtime/client.js +383 -0
  127. package/dist/runtime/default-html.js +31 -0
  128. package/dist/runtime/head-markup.js +100 -0
  129. package/dist/runtime/head-sync.js +101 -0
  130. package/dist/runtime/head-tags.js +45 -0
  131. package/dist/runtime/hydration-report.js +111 -0
  132. package/dist/runtime/index.js +12 -0
  133. package/dist/runtime/link.js +293 -0
  134. package/dist/runtime/loader.js +449 -0
  135. package/dist/runtime/not-found.js +61 -0
  136. package/dist/runtime/page-renderer.js +35 -0
  137. package/dist/runtime/preamble.js +47 -0
  138. package/dist/runtime/react-compat.js +14 -0
  139. package/dist/runtime/renderer-shared.js +10 -0
  140. package/dist/runtime/renderers/react-client.js +14 -0
  141. package/dist/runtime/renderers/react-server.js +99 -0
  142. package/dist/runtime/renderers/react.js +17 -0
  143. package/dist/runtime/renderers/types.js +1 -0
  144. package/dist/runtime/root-error-handlers.js +29 -0
  145. package/dist/runtime/router/history.js +132 -0
  146. package/dist/runtime/router/index.js +240 -0
  147. package/dist/runtime/router/utils.js +118 -0
  148. package/dist/runtime/script.js +110 -0
  149. package/dist/runtime/scroll.js +40 -0
  150. package/dist/runtime/slice.js +11 -0
  151. package/dist/runtime/ssr.js +240 -0
  152. package/dist/runtime/static-query.js +47 -0
  153. package/dist/utils.js +4 -0
  154. package/package.json +105 -3
  155. package/types/graphql-tada.d.ts +223 -0
  156. package/types/graphql.d.ts +2 -0
  157. package/types/index.d.ts +2287 -0
  158. package/types/node.d.ts +389 -0
  159. package/types/reporter.d.ts +187 -0
  160. package/types/router.d.ts +102 -0
  161. package/types/vendor/gql-tada.d.ts +2529 -0
@@ -0,0 +1,539 @@
1
+ import { GraphQLScalarType, Kind } from "../gql.js";
2
+ import { createRequire } from "node:module";
3
+ import dayjs from "dayjs";
4
+ import advancedFormat from "dayjs/plugin/advancedFormat.js";
5
+ import isoWeek from "dayjs/plugin/isoWeek.js";
6
+ import localizedFormat from "dayjs/plugin/localizedFormat.js";
7
+ import relativeTime from "dayjs/plugin/relativeTime.js";
8
+ import timezone from "dayjs/plugin/timezone.js";
9
+ import utc from "dayjs/plugin/utc.js";
10
+ import weekOfYear from "dayjs/plugin/weekOfYear.js";
11
+ import weekYear from "dayjs/plugin/weekYear.js";
12
+ // src/node/schema/date.ts
13
+ dayjs.extend(utc);
14
+ dayjs.extend(advancedFormat);
15
+ dayjs.extend(localizedFormat);
16
+ dayjs.extend(relativeTime);
17
+ dayjs.extend(weekOfYear);
18
+ dayjs.extend(isoWeek);
19
+ dayjs.extend(weekYear);
20
+ dayjs.extend(timezone);
21
+ const ISO_8601_FORMAT = [
22
+ "YYYY",
23
+ "YYYY-MM",
24
+ "YYYY-MM-DD",
25
+ "YYYYMMDD",
26
+ "YYYY-MM-DDTHH",
27
+ "YYYY-MM-DDTHH:mm",
28
+ "YYYY-MM-DDTHHmm",
29
+ "YYYY-MM-DDTHH:mm:ss",
30
+ "YYYY-MM-DDTHHmmss",
31
+ "YYYY-MM-DDTHH:mm:ss.SSS",
32
+ "YYYY-MM-DDTHHmmss.SSS",
33
+ "YYYY-MM-DDTHH:mm:ss.SSSSSS",
34
+ "YYYY-MM-DDTHHmmss.SSSSSS",
35
+ "YYYY-MM-DD HH",
36
+ "YYYY-MM-DD HH:mm",
37
+ "YYYY-MM-DD HHmm",
38
+ "YYYY-MM-DD HH:mm:ss",
39
+ "YYYY-MM-DD HHmmss",
40
+ "YYYY-MM-DD HH:mm:ss.SSS",
41
+ "YYYY-MM-DD HHmmss.SSS",
42
+ "YYYY-MM-DD HH:mm:ss.SSSSSS",
43
+ "YYYY-MM-DD HHmmss.SSSSSS",
44
+ "YYYY-MM-DDTHHZ",
45
+ "YYYY-MM-DDTHH:mmZ",
46
+ "YYYY-MM-DDTHHmmZ",
47
+ "YYYY-MM-DDTHH:mm:ssZ",
48
+ "YYYY-MM-DDTHHmmssZ",
49
+ "YYYY-MM-DDTHH:mm:ss.SSSZ",
50
+ "YYYY-MM-DDTHHmmss.SSSZ",
51
+ "YYYY-MM-DDTHH:mm:ss.SSSSSSZ",
52
+ "YYYY-MM-DDTHHmmss.SSSSSSZ",
53
+ "YYYY-MM-DD HHZ",
54
+ "YYYY-MM-DD HH:mmZ",
55
+ "YYYY-MM-DD HHmmZ",
56
+ "YYYY-MM-DD HH:mm:ssZ",
57
+ "YYYY-MM-DD HHmmssZ",
58
+ "YYYY-MM-DD HH:mm:ss.SSSZ",
59
+ "YYYY-MM-DD HHmmss.SSSZ",
60
+ "YYYY-MM-DD HH:mm:ss.SSSSSSZ",
61
+ "YYYY-MM-DD HHmmss.SSSSSSZ",
62
+ "YYYY-MM-DD HH Z",
63
+ "YYYY-MM-DD HH:mm Z",
64
+ "YYYY-MM-DD HHmm Z",
65
+ "YYYY-MM-DD HH:mm:ss Z",
66
+ "YYYY-MM-DD HHmmss Z",
67
+ "YYYY-MM-DD HH:mm:ss.SSS Z",
68
+ "YYYY-MM-DD HHmmss.SSS Z",
69
+ "YYYY-MM-DD HH:mm:ss.SSSSSS Z",
70
+ "YYYY-MM-DD HHmmss.SSSSSS Z",
71
+ "YYYY-[W]WW",
72
+ "YYYY[W]WW",
73
+ "YYYY-[W]WW-E",
74
+ "YYYY[W]WWE",
75
+ "YYYY-DDDD",
76
+ "YYYYDDDD"
77
+ ];
78
+ const momentFormattingTokens = /(\[[^[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
79
+ const momentFormattingRegexes = {
80
+ YYYY: "\\d{4}",
81
+ MM: "\\d{2}",
82
+ DD: "\\d{2}",
83
+ DDDD: "\\d{4}",
84
+ HH: "\\d{2}",
85
+ mm: "\\d{2}",
86
+ ss: "\\d{2}",
87
+ SSS: "\\d{3}",
88
+ SSSSSS: "\\d{6}",
89
+ E: "\\d",
90
+ W: "\\d",
91
+ WW: "\\d{2}",
92
+ "[W]": "W",
93
+ ".": "\\.",
94
+ Z: "(Z|[+-]\\d\\d(?::?\\d\\d)?)"
95
+ };
96
+ const ISO_8601_FORMAT_AS_REGEX = ISO_8601_FORMAT.map((format) => {
97
+ const matchedFormat = format.match(momentFormattingTokens);
98
+ if (matchedFormat === null) return "";
99
+ return [...matchedFormat].map((token) => momentFormattingRegexes[token] ?? token).join("");
100
+ }).join("|");
101
+ const ISO_8601_FORMAT_LENGTHS = [...new Set(ISO_8601_FORMAT.reduce((acc, val) => {
102
+ if (!val.endsWith("Z")) return acc.concat(val.length);
103
+ return acc.concat([
104
+ val.length,
105
+ val.length + 3,
106
+ val.length + 5
107
+ ]);
108
+ }, []))];
109
+ const quickDateValidateRegex = new RegExp(`^(${ISO_8601_FORMAT_AS_REGEX})$`);
110
+ const looksLikeDateStartRegex = /^\d{4}/;
111
+ const looksLikeDateEndRegex = /(\d|Z)$/;
112
+ /** Gatsby's `isDate`: a strict parse against the ISO 8601 list (numbers are never dates). */
113
+ function strictIsDate(value) {
114
+ return typeof value !== "number" && !Number.isNaN(parseDate(String(value)));
115
+ }
116
+ /** Gatsby's `looksLikeADate`: a shape check (not a strict validity check) used for inference. */
117
+ function looksLikeADate(value) {
118
+ if (!value || value.length && !ISO_8601_FORMAT_LENGTHS.includes(value.length) || !looksLikeDateStartRegex.test(value) || !looksLikeDateEndRegex.test(value)) return false;
119
+ if (typeof value === "string" && quickDateValidateRegex.test(value)) return true;
120
+ return strictIsDate(value);
121
+ }
122
+ /**
123
+ * Whether a value should be inferred as a Date. Matches Gatsby, whose inference uses
124
+ * `looksLikeADate` (a shape check); Date objects are accepted when they hold a valid time.
125
+ */
126
+ function isDate(value) {
127
+ if (value instanceof Date) return !Number.isNaN(value.getTime());
128
+ return looksLikeADate(value);
129
+ }
130
+ const int = (s) => Math.trunc(Number(s)) || 0;
131
+ const parseMs = (s) => Math.trunc(Number(`0.${s}`) * 1e3);
132
+ function offsetMinutes(s) {
133
+ const parts = s.match(/([+-]|\d\d)/g);
134
+ if (!parts) return 0;
135
+ const extra = int(parts[2] ?? "0");
136
+ const minutes = Number(parts[1]) * 60 + extra;
137
+ if (extra > 59 || minutes > (parts[0] === "+" ? 14 : 12) * 60) return NaN;
138
+ return minutes === 0 ? 0 : parts[0] === "+" ? minutes : -minutes;
139
+ }
140
+ const PARSE_TOKENS = {
141
+ YYYY: [/\d{4}/y, (s, st) => void (st.a[0] = int(s))],
142
+ MM: [/\d\d/y, (s, st) => void (st.a[1] = int(s) - 1)],
143
+ DD: [/\d\d/y, (s, st) => void (st.a[2] = int(s))],
144
+ HH: [/\d\d/y, (s, st) => void (st.a[3] = int(s))],
145
+ mm: [/\d\d/y, (s, st) => void (st.a[4] = int(s))],
146
+ ss: [/\d\d/y, (s, st) => void (st.a[5] = int(s))],
147
+ SSS: [/\d{3}/y, (s, st) => void (st.a[6] = parseMs(s))],
148
+ SSSSSS: [/\d+/y, (s, st) => void (st.a[6] = parseMs(s))],
149
+ Z: [/Z|[+-]\d\d(?::?\d\d)?/iy, (s, st) => void (st.tzm = offsetMinutes(s))],
150
+ WW: [/\d\d/y, (s, st) => void (st.week = int(s))],
151
+ E: [/\d\d?/y, (s, st) => void (st.weekday = int(s))],
152
+ DDDD: [/\d{3}/y, (s, st) => void (st.dayOfYear = int(s))]
153
+ };
154
+ const COMPILED_FORMATS = ISO_8601_FORMAT.map((fmt) => (fmt.match(/\[[^\]]*\]|YYYY|SSSSSS|SSS|DDDD|MM|DD|HH|mm|ss|WW|E|Z|./g) ?? []).map((token) => Object.hasOwn(PARSE_TOKENS, token) ? PARSE_TOKENS[token] : token.startsWith("[") ? token.slice(1, -1) : token));
155
+ /** Matches `input` against one format; every character must be consumed. */
156
+ function matchFormat(input, steps) {
157
+ const state = { a: [] };
158
+ let pos = 0;
159
+ for (const step of steps) {
160
+ if (typeof step === "string") {
161
+ if (!input.startsWith(step, pos)) return void 0;
162
+ pos += step.length;
163
+ continue;
164
+ }
165
+ const [re, set] = step;
166
+ re.lastIndex = pos;
167
+ const m = re.exec(input);
168
+ if (!m) return void 0;
169
+ set(m[0], state);
170
+ pos += m[0].length;
171
+ }
172
+ return pos === input.length ? state : void 0;
173
+ }
174
+ /** Date.UTC, but years 0-99 stay years 0-99 instead of becoming 1900-1999. */
175
+ function utcDate(y, m = 0, d = 1, h = 0, min = 0, s = 0, ms = 0) {
176
+ const date = new Date(Date.UTC(y, m, d, h, min, s, ms));
177
+ if (y >= 0 && y < 100) date.setUTCFullYear(y, m, d);
178
+ return date;
179
+ }
180
+ const daysInMonth = (y, m) => utcDate(y, m + 1, 0).getUTCDate();
181
+ /** The UTC timestamp of the parsed fields, or NaN when one of them is out of range. */
182
+ function toTimestamp({ a, week, weekday, dayOfYear, tzm }) {
183
+ if (Number.isNaN(tzm)) return NaN;
184
+ if (week != null || weekday != null) {
185
+ const year = a[0];
186
+ const jan4 = utcDate(year, 0, 4);
187
+ const week1 = jan4.getTime() - (jan4.getUTCDay() + 6) % 7 * 864e5;
188
+ const weeks = (utcDate(year + 1, 0, 4).getTime() - week1) / 6048e5 >= 53 ? 53 : 52;
189
+ if (week < 1 || week > weeks || weekday != null && (weekday < 1 || weekday > 7)) return NaN;
190
+ const date = new Date(week1 + ((week - 1) * 7 + (weekday ?? 1) - 1) * 864e5);
191
+ a = [
192
+ date.getUTCFullYear(),
193
+ date.getUTCMonth(),
194
+ date.getUTCDate()
195
+ ];
196
+ } else if (dayOfYear != null) {
197
+ if (dayOfYear < 1 || dayOfYear > (daysInMonth(a[0], 1) === 29 ? 366 : 365)) return NaN;
198
+ const date = utcDate(a[0], 0, dayOfYear);
199
+ a = [
200
+ date.getUTCFullYear(),
201
+ date.getUTCMonth(),
202
+ date.getUTCDate()
203
+ ];
204
+ }
205
+ const [y, M = 0, D = 1, h = 0, m = 0, s = 0, ms = 0] = a;
206
+ const nextDay = h === 24 && m === 0 && s === 0 && ms === 0;
207
+ if (M < 0 || M > 11 || D < 1 || D > daysInMonth(y, M) || h > 23 && !nextDay || m > 59 || s > 59) return NaN;
208
+ return utcDate(y, M, D, nextDay ? 0 : h, m, s, ms).getTime() - (tzm ?? 0) * 6e4 + (nextDay ? 864e5 : 0);
209
+ }
210
+ /** The number in input[from, from + length), -1 unless those are all ASCII digits. */
211
+ function digits(input, from, length) {
212
+ let n = 0;
213
+ for (let i = from; i < from + length; i++) {
214
+ const c = input.charCodeAt(i) - 48;
215
+ if (!(c >= 0 && c <= 9)) return -1;
216
+ n = n * 10 + c;
217
+ }
218
+ return n;
219
+ }
220
+ const DAYS_IN_MONTH = [
221
+ 31,
222
+ 28,
223
+ 31,
224
+ 30,
225
+ 31,
226
+ 30,
227
+ 31,
228
+ 31,
229
+ 30,
230
+ 31,
231
+ 30,
232
+ 31
233
+ ];
234
+ /**
235
+ * Days since 1970-01-01 of a proleptic Gregorian date (month 1-12), like Date.UTC but for every
236
+ * year from 0 on and without its cost (Howard Hinnant's days_from_civil).
237
+ */
238
+ function daysFromCivil(y, M, D) {
239
+ const year = M <= 2 ? y - 1 : y;
240
+ const era = Math.floor(year / 400);
241
+ const yearOfEra = year - era * 400;
242
+ const dayOfYear = Math.floor((153 * (M > 2 ? M - 3 : M + 9) + 2) / 5) + D - 1;
243
+ const dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;
244
+ return era * 146097 + dayOfEra - 719468;
245
+ }
246
+ /**
247
+ * @internal (exported for tests) The canonical shapes (YYYY-MM-DD, …THH:mm, …:ss, ….SSS, the
248
+ * times optionally with Z) skip the format list: their timestamp (NaN when out of range, like
249
+ * toTimestamp), undefined for any other string. Reads the characters, no regex or Date objects:
250
+ * every formatted date string comes through here.
251
+ */
252
+ function parseCanonical(input) {
253
+ let end = input.length;
254
+ if (end > 16 && input.charCodeAt(end - 1) === 90) end--;
255
+ if (end !== 10 && end !== 16 && end !== 19 && end !== 23) return void 0;
256
+ if (input.charCodeAt(4) !== 45 || input.charCodeAt(7) !== 45) return void 0;
257
+ const y = digits(input, 0, 4);
258
+ const M = digits(input, 5, 2);
259
+ const D = digits(input, 8, 2);
260
+ let h = 0;
261
+ let m = 0;
262
+ let s = 0;
263
+ let ms = 0;
264
+ if (end > 10) {
265
+ if (input.charCodeAt(10) !== 84 || input.charCodeAt(13) !== 58) return void 0;
266
+ h = digits(input, 11, 2);
267
+ m = digits(input, 14, 2);
268
+ if (end > 16) {
269
+ if (input.charCodeAt(16) !== 58) return void 0;
270
+ s = digits(input, 17, 2);
271
+ if (end > 19) {
272
+ if (input.charCodeAt(19) !== 46) return void 0;
273
+ ms = digits(input, 20, 3);
274
+ }
275
+ }
276
+ }
277
+ if ((y | M | D | h | m | s | ms) < 0) return void 0;
278
+ const leap = y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0);
279
+ const nextDay = h === 24 && m === 0 && s === 0 && ms === 0;
280
+ if (M < 1 || M > 12 || D < 1 || D > (M === 2 && leap ? 29 : DAYS_IN_MONTH[M - 1])) return NaN;
281
+ if (h > 23 && !nextDay || m > 59 || s > 59) return NaN;
282
+ return daysFromCivil(y, M, D) * 864e5 + ((h * 60 + m) * 60 + s) * 1e3 + ms;
283
+ }
284
+ /** UTC timestamp of a Gatsby-valid ISO 8601 date string, NaN when it is not one. */
285
+ function parseDate(input) {
286
+ const canonical = parseCanonical(input);
287
+ if (canonical !== void 0) return canonical;
288
+ for (const steps of COMPILED_FORMATS) {
289
+ const state = matchFormat(input, steps);
290
+ if (state) {
291
+ const time = toTimestamp(state);
292
+ if (!Number.isNaN(time)) return time;
293
+ }
294
+ }
295
+ return NaN;
296
+ }
297
+ const require = createRequire(import.meta.url);
298
+ const DAYJS_LOCALES = new Set(require("dayjs/locale.json").map((l) => l.key));
299
+ /**
300
+ * The dayjs locale for a `locale` argument; English when dayjs has no such locale. Only names
301
+ * from dayjs' own locale list are loaded, so the argument can never reach an arbitrary file.
302
+ */
303
+ function resolveLocale(locale) {
304
+ const name = typeof locale === "string" ? locale.toLowerCase() : "en";
305
+ if (!DAYJS_LOCALES.has(name)) return "en";
306
+ if (!dayjs.Ls[name]) require(`dayjs/locale/${name}.js`);
307
+ return name;
308
+ }
309
+ /** the dayjs locale `@dateformat` formats with for a `locale` argument (English: "en") */
310
+ const dateFormatLocale = (locale) => resolveLocale(locale);
311
+ const EN = dayjs.Ls.en;
312
+ const EN_FORMATS = EN.formats;
313
+ const MONTHS = EN.months;
314
+ const WEEKDAYS = EN.weekdays;
315
+ const MONTHS_SHORT = MONTHS.map((name) => name.slice(0, 3));
316
+ const WEEKDAYS_SHORT = WEEKDAYS.map((name) => name.slice(0, 3));
317
+ const WEEKDAYS_MIN = WEEKDAYS.map((name) => name.slice(0, 2));
318
+ const ORDINALS = Array.from({ length: 54 }, (_, n) => String(EN.ordinal(n)).slice(1, -1));
319
+ const TWO_DIGITS = Array.from({ length: 100 }, (_, n) => String(n).padStart(2, "0"));
320
+ const pad3 = (n) => (n < 10 ? "00" : n < 100 ? "0" : "") + n;
321
+ const LOCALIZED = /(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g;
322
+ const ADVANCED = /\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g;
323
+ const CORE = /\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
324
+ /** The placeholder of an inserted value (formats that contain it take the dayjs path). */
325
+ const FIELD = "\0";
326
+ const MIN_TIME = Date.UTC(1e3, 0, 1);
327
+ const MAX_TIME = Date.UTC(1e4, 0, 1);
328
+ const f = {
329
+ time: 0,
330
+ days: 0,
331
+ y: 0,
332
+ M: 0,
333
+ D: 0,
334
+ W: 0,
335
+ H: 0,
336
+ m: 0,
337
+ s: 0,
338
+ ms: 0
339
+ };
340
+ const weekdayOf = (days) => ((days + 4) % 7 + 7) % 7;
341
+ const yearOf = (days) => (/* @__PURE__ */ new Date(days * 864e5)).getUTCFullYear();
342
+ /** weekOfYear in English (weeks start on Sunday, the one with January 1st is week 1). */
343
+ function weekNumber() {
344
+ if (f.M === 11 && f.D > 25 && Date.UTC(f.y + 1, 0, 1) < (f.days - f.W + 7) * 864e5 - 1) return 1;
345
+ const jan1 = Date.UTC(f.y, 0, 1);
346
+ const firstSunday = jan1 - weekdayOf(jan1 / 864e5) * 864e5;
347
+ return Math.ceil((f.time - (firstSunday - 1)) / 6048e5);
348
+ }
349
+ /** The days since 1970 of the Thursday of the ISO week (Monday to Sunday). */
350
+ const isoThursday = () => f.days + 4 - (f.W || 7);
351
+ function isoWeekNumber() {
352
+ const thursday = isoThursday();
353
+ const jan1 = Date.UTC(yearOf(thursday), 0, 1) / 864e5;
354
+ const jan1Weekday = weekdayOf(jan1) || 7;
355
+ return (thursday - (jan1 + 4 - jan1Weekday + (jan1Weekday > 4 ? 7 : 0))) / 7 + 1;
356
+ }
357
+ const ADVANCED_FIELDS = /* @__PURE__ */ new Map([
358
+ ["Q", () => Math.ceil((f.M + 1) / 3)],
359
+ ["Do", () => ORDINALS[f.D]],
360
+ ["gggg", () => {
361
+ const w = weekNumber();
362
+ return w === 1 && f.M === 11 ? f.y + 1 : f.M === 0 && w >= 52 ? f.y - 1 : f.y;
363
+ }],
364
+ ["GGGG", () => yearOf(isoThursday())],
365
+ ["wo", () => ORDINALS[weekNumber()]],
366
+ ["w", weekNumber],
367
+ ["ww", () => TWO_DIGITS[weekNumber()]],
368
+ ["W", isoWeekNumber],
369
+ ["WW", () => TWO_DIGITS[isoWeekNumber()]],
370
+ ["k", () => f.H || 24],
371
+ ["kk", () => TWO_DIGITS[f.H || 24]],
372
+ ["X", () => Math.floor(f.time / 1e3)],
373
+ ["x", () => f.time]
374
+ ]);
375
+ const CORE_FIELDS = /* @__PURE__ */ new Map([
376
+ ["YY", () => TWO_DIGITS[f.y % 100]],
377
+ ["YYYY", () => f.y],
378
+ ["M", () => f.M + 1],
379
+ ["MM", () => TWO_DIGITS[f.M + 1]],
380
+ ["MMM", () => MONTHS_SHORT[f.M]],
381
+ ["MMMM", () => MONTHS[f.M]],
382
+ ["D", () => f.D],
383
+ ["DD", () => TWO_DIGITS[f.D]],
384
+ ["d", () => f.W],
385
+ ["dd", () => WEEKDAYS_MIN[f.W]],
386
+ ["ddd", () => WEEKDAYS_SHORT[f.W]],
387
+ ["dddd", () => WEEKDAYS[f.W]],
388
+ ["H", () => f.H],
389
+ ["HH", () => TWO_DIGITS[f.H]],
390
+ ["h", () => f.H % 12 || 12],
391
+ ["hh", () => TWO_DIGITS[f.H % 12 || 12]],
392
+ ["a", () => f.H < 12 ? "am" : "pm"],
393
+ ["A", () => f.H < 12 ? "AM" : "PM"],
394
+ ["m", () => f.m],
395
+ ["mm", () => TWO_DIGITS[f.m]],
396
+ ["s", () => f.s],
397
+ ["ss", () => TWO_DIGITS[f.s]],
398
+ ["SSS", () => pad3(f.ms)],
399
+ ["Z", "+00:00"],
400
+ ["ZZ", "+0000"]
401
+ ]);
402
+ function compileFormat(format) {
403
+ if (format.includes(FIELD)) return null;
404
+ const localized = format.replace(LOCALIZED, (_, text, token) => text || EN_FORMATS[token] || EN_FORMATS[token.toUpperCase()].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (_, text, long) => text || long.slice(1)));
405
+ const inserted = [];
406
+ let timeZone = false;
407
+ const advanced = localized.replace(ADVANCED, (token) => {
408
+ const get = ADVANCED_FIELDS.get(token);
409
+ if (!get) {
410
+ if (token === "z" || token === "zzz") timeZone = true;
411
+ return token;
412
+ }
413
+ inserted.push(get);
414
+ return token === "Do" || token === "wo" ? `[${FIELD}]` : FIELD;
415
+ });
416
+ if (timeZone) return null;
417
+ const program = [];
418
+ let literal = "";
419
+ const push = (get) => {
420
+ if (literal) program.push(literal);
421
+ program.push(get);
422
+ literal = "";
423
+ };
424
+ const text = (s) => {
425
+ const pieces = s.split(FIELD);
426
+ literal += pieces[0];
427
+ for (let i = 1; i < pieces.length; i++) {
428
+ push(inserted.shift());
429
+ literal += pieces[i];
430
+ }
431
+ };
432
+ let last = 0;
433
+ for (const match of advanced.matchAll(CORE)) {
434
+ text(advanced.slice(last, match.index));
435
+ if (match[1] !== void 0) text(match[1]);
436
+ else {
437
+ const field = CORE_FIELDS.get(match[0]);
438
+ if (typeof field === "string") literal += field;
439
+ else push(field);
440
+ }
441
+ last = match.index + match[0].length;
442
+ }
443
+ text(advanced.slice(last));
444
+ if (literal) program.push(literal);
445
+ return program;
446
+ }
447
+ const programs = /* @__PURE__ */ new Map();
448
+ /** The compiled English format, cached (a few hundred formats at most, short ones only). */
449
+ function englishFormat(format) {
450
+ let program = programs.get(format);
451
+ if (program === void 0) {
452
+ if (format.length > 200) return null;
453
+ program = compileFormat(format);
454
+ if (programs.size >= 500) programs.clear();
455
+ programs.set(format, program);
456
+ }
457
+ return program;
458
+ }
459
+ /** the token name of each getter (`compileFormatTokens`) */
460
+ const GETTER_TOKENS = /* @__PURE__ */ new Map();
461
+ for (const [token, get] of [...ADVANCED_FIELDS, ...CORE_FIELDS]) if (typeof get !== "string") GETTER_TOKENS.set(get, token);
462
+ /**
463
+ * The compiled English program of a format string with the token name of each getter instead of
464
+ * the getter (`{ t: "MMMM" }`), for the WASM data side; null where dayjs formats (see
465
+ * `formatCompiled`: also for times outside years 1000-9999, which the caller handles).
466
+ */
467
+ function compileFormatTokens(format) {
468
+ const program = englishFormat(format);
469
+ if (!program) return null;
470
+ const out = [];
471
+ for (const part of program) if (typeof part === "string") out.push(part);
472
+ else {
473
+ const t = GETTER_TOKENS.get(part);
474
+ if (t === void 0) return null;
475
+ out.push({ t });
476
+ }
477
+ return out;
478
+ }
479
+ /** @internal (exported for tests) the compiled English format, undefined where dayjs formats */
480
+ function formatCompiled(time, format) {
481
+ const program = englishFormat(format);
482
+ return program && time >= MIN_TIME && time < MAX_TIME ? runFormat(program, time) : void 0;
483
+ }
484
+ function runFormat(program, time) {
485
+ const days = Math.floor(time / 864e5) | 0;
486
+ let t = time - days * 864e5 | 0;
487
+ f.time = time;
488
+ f.days = days;
489
+ f.ms = t % 1e3;
490
+ t = t / 1e3 | 0;
491
+ f.s = t % 60;
492
+ t = t / 60 | 0;
493
+ f.m = t % 60;
494
+ f.H = t / 60 | 0;
495
+ f.W = weekdayOf(days);
496
+ const z = days + 719468 | 0;
497
+ const era = z / 146097 | 0;
498
+ const dayOfEra = z - era * 146097;
499
+ const yearOfEra = (dayOfEra - (dayOfEra / 1460 | 0) + (dayOfEra / 36524 | 0) - (dayOfEra / 146096 | 0)) / 365 | 0;
500
+ const dayOfYear = dayOfEra - (365 * yearOfEra + (yearOfEra / 4 | 0) - (yearOfEra / 100 | 0));
501
+ const mp = (5 * dayOfYear + 2) / 153 | 0;
502
+ f.D = dayOfYear - ((153 * mp + 2) / 5 | 0) + 1;
503
+ f.M = mp < 10 ? mp + 2 : mp - 10;
504
+ f.y = yearOfEra + era * 400 + (mp < 10 ? 0 : 1);
505
+ let out = "";
506
+ for (let i = 0; i < program.length; i++) {
507
+ const part = program[i];
508
+ out += typeof part === "string" ? part : part();
509
+ }
510
+ return out;
511
+ }
512
+ function formatWith(date, args, locale, program) {
513
+ if (date == null) return date;
514
+ if (Array.isArray(date)) return date.map((d) => formatWith(d, args, locale, program));
515
+ const time = date instanceof Date ? date.getTime() : parseDate(String(date));
516
+ if (program && time >= MIN_TIME && time < MAX_TIME) return runFormat(program, time);
517
+ const d = dayjs.utc(time).locale(locale);
518
+ if (args.formatString) return d.format(args.formatString);
519
+ if (args.fromNow) return d.fromNow();
520
+ return dayjs().diff(d, args.difference);
521
+ }
522
+ const normalize = (date) => Array.isArray(date) ? date.map(normalize) : date instanceof Date ? Number.isNaN(date.getTime()) ? null : date.toISOString() : date;
523
+ /** The `@dateformat` extension (`formatString`, `fromNow`, `difference`, `locale`), via dayjs. */
524
+ function formatDate(date, args) {
525
+ if (date == null) return date;
526
+ if (!args.formatString && !args.fromNow && !args.difference) return normalize(date);
527
+ const locale = resolveLocale(args.locale);
528
+ return formatWith(date, args, locale, locale === "en" && typeof args.formatString === "string" && args.formatString ? englishFormat(args.formatString) : null);
529
+ }
530
+ const GraphQLDate = new GraphQLScalarType({
531
+ name: "Date",
532
+ description: "A date string, such as 2007-12-03, compliant with the ISO 8601 standard for representation of dates and times using the Gregorian calendar.",
533
+ serialize: (value) => value instanceof Date ? value.toISOString() : String(value),
534
+ parseValue: (value) => value,
535
+ parseLiteral(ast) {
536
+ return ast.kind === Kind.STRING ? ast.value : void 0;
537
+ }
538
+ });
539
+ export { GraphQLDate, compileFormatTokens, dateFormatLocale, formatCompiled, formatDate, isDate, looksLikeADate, parseCanonical, parseDate };