forgepress 0.0.0 → 0.0.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 (57) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md +42 -0
  2. package/dist/_chunks/client.d.mts +2 -0
  3. package/dist/_chunks/config.mjs +79 -0
  4. package/dist/_chunks/content.mjs +733 -0
  5. package/dist/_chunks/error.mjs +4 -0
  6. package/dist/_chunks/fetch.mjs +13 -0
  7. package/dist/_chunks/files.mjs +32 -0
  8. package/dist/_chunks/libs/diff.mjs +485 -0
  9. package/dist/_chunks/locate.mjs +7 -0
  10. package/dist/_chunks/media.mjs +282 -0
  11. package/dist/_chunks/once.mjs +16 -0
  12. package/dist/_chunks/output.mjs +104 -0
  13. package/dist/_chunks/overlay.mjs +8 -0
  14. package/dist/_chunks/plugin.mjs +87 -0
  15. package/dist/_chunks/preview.mjs +248 -0
  16. package/dist/_chunks/project.d.mts +7 -0
  17. package/dist/_chunks/reader.mjs +19 -0
  18. package/dist/_chunks/reader2.mjs +797 -0
  19. package/dist/_chunks/references.mjs +56 -0
  20. package/dist/_chunks/resolve.d.mts +2 -0
  21. package/dist/_chunks/response.mjs +5 -0
  22. package/dist/_chunks/routes.mjs +9 -0
  23. package/dist/_chunks/serialize.mjs +82 -0
  24. package/dist/_chunks/settings.mjs +328 -0
  25. package/dist/_chunks/settings2.mjs +2 -0
  26. package/dist/_chunks/types.d.mts +230 -0
  27. package/dist/_chunks/types2.d.mts +25 -0
  28. package/dist/_chunks/value.mjs +139 -0
  29. package/dist/cli/bin.d.mts +1 -0
  30. package/dist/cli/bin.mjs +61 -0
  31. package/dist/disk/reader.d.mts +4 -0
  32. package/dist/disk/reader.mjs +2 -0
  33. package/dist/editor/index.d.mts +3 -0
  34. package/dist/editor/index.mjs +61951 -0
  35. package/dist/index.d.mts +104 -0
  36. package/dist/index.mjs +237 -0
  37. package/dist/next/preview.d.mts +1 -0
  38. package/dist/next/preview.mjs +3 -0
  39. package/dist/next/reload.d.mts +1 -0
  40. package/dist/next/reload.mjs +20 -0
  41. package/dist/next/settings.d.mts +12 -0
  42. package/dist/next/settings.mjs +2 -0
  43. package/dist/plugin/next.d.mts +11 -0
  44. package/dist/plugin/next.mjs +213 -0
  45. package/dist/plugin/nuxt.d.mts +7 -0
  46. package/dist/plugin/nuxt.mjs +52 -0
  47. package/dist/plugin/watcher.d.mts +1 -0
  48. package/dist/plugin/watcher.mjs +23 -0
  49. package/dist/preview/index.d.mts +4 -0
  50. package/dist/preview/index.mjs +2 -0
  51. package/dist/preview/react.d.mts +1 -0
  52. package/dist/preview/react.mjs +34 -0
  53. package/dist/query/fetch.d.mts +3 -0
  54. package/dist/query/fetch.mjs +2 -0
  55. package/dist/unplugin.d.mts +13 -0
  56. package/dist/unplugin.mjs +2 -0
  57. package/package.json +146 -2
@@ -0,0 +1,4 @@
1
+ function errorMessage(cause) {
2
+ return cause instanceof Error ? cause.message : String(cause);
3
+ }
4
+ export { errorMessage };
@@ -0,0 +1,13 @@
1
+ import { isPage } from "./response.mjs";
2
+ function fetchReader(url) {
3
+ const base = url.replace(/\/+$/, "");
4
+ return async (path) => {
5
+ const location = `${base}/${path}`;
6
+ const response = await fetch(location, path === "index.json" ? { cache: "no-cache" } : {});
7
+ if (response.status === 404 || response.ok && isPage(response)) return void 0;
8
+ if (!response.ok) throw new Error(`[forgepress] could not load ${location}: ${response.status} ${response.statusText}`.trim());
9
+ return response.json();
10
+ };
11
+ }
12
+ const reader = fetchReader("/content");
13
+ export { fetchReader, reader };
@@ -0,0 +1,32 @@
1
+ import { readFile, readdir } from "node:fs/promises";
2
+ import { isAbsolute, join, relative, sep } from "node:path";
3
+ import { existsSync } from "node:fs";
4
+ function toPosix(path) {
5
+ return path.split(sep).join("/");
6
+ }
7
+ function isInside(parent, child) {
8
+ const path = relative(parent, child);
9
+ return path !== "" && path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path);
10
+ }
11
+ async function listFiles(folder) {
12
+ if (!existsSync(folder)) return [];
13
+ return (await readdir(folder, {
14
+ withFileTypes: true,
15
+ recursive: true
16
+ })).filter((item) => item.isFile()).map((item) => toPosix(relative(folder, join(item.parentPath, item.name))));
17
+ }
18
+ async function readText(file) {
19
+ try {
20
+ return await readFile(file, "utf8");
21
+ } catch (error) {
22
+ if (error.code === "ENOENT") return void 0;
23
+ throw error;
24
+ }
25
+ }
26
+ function diskFiles(root) {
27
+ return {
28
+ list: async (directory) => (await listFiles(join(root, directory))).map((path) => `${directory}/${path}`),
29
+ read: (path) => readText(join(root, path))
30
+ };
31
+ }
32
+ export { diskFiles, isInside, listFiles, readText, toPosix };
@@ -0,0 +1,485 @@
1
+ var Diff = class {
2
+ diff(oldStr, newStr, options = {}) {
3
+ let callback;
4
+ if (typeof options === "function") {
5
+ callback = options;
6
+ options = {};
7
+ } else if ("callback" in options) callback = options.callback;
8
+ const oldString = this.castInput(oldStr, options);
9
+ const newString = this.castInput(newStr, options);
10
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
11
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
12
+ return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
13
+ }
14
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
15
+ var _a;
16
+ const done = (value) => {
17
+ value = this.postProcess(value, options);
18
+ if (callback) {
19
+ setTimeout(function() {
20
+ callback(value);
21
+ }, 0);
22
+ return;
23
+ } else return value;
24
+ };
25
+ const newLen = newTokens.length, oldLen = oldTokens.length;
26
+ let editLength = 1;
27
+ let maxEditLength = newLen + oldLen;
28
+ if (options.maxEditLength != null) maxEditLength = Math.min(maxEditLength, options.maxEditLength);
29
+ const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
30
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
31
+ const bestPath = [{
32
+ oldPos: -1,
33
+ lastComponent: void 0
34
+ }];
35
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
36
+ if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
37
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
38
+ const execEditLength = () => {
39
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
40
+ let basePath;
41
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
42
+ if (removePath) bestPath[diagonalPath - 1] = void 0;
43
+ let canAdd = false;
44
+ if (addPath) {
45
+ const addPathNewPos = addPath.oldPos - diagonalPath;
46
+ canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
47
+ }
48
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
49
+ if (!canAdd && !canRemove) {
50
+ bestPath[diagonalPath] = void 0;
51
+ continue;
52
+ }
53
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) basePath = this.addToPath(addPath, true, false, 0, options);
54
+ else basePath = this.addToPath(removePath, false, true, 1, options);
55
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
56
+ if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
57
+ else {
58
+ bestPath[diagonalPath] = basePath;
59
+ if (basePath.oldPos + 1 >= oldLen) maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
60
+ if (newPos + 1 >= newLen) minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
61
+ }
62
+ }
63
+ editLength++;
64
+ };
65
+ if (callback) (function exec() {
66
+ setTimeout(function() {
67
+ if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) return callback(void 0);
68
+ if (!execEditLength()) exec();
69
+ }, 0);
70
+ })();
71
+ else while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
72
+ const ret = execEditLength();
73
+ if (ret) return ret;
74
+ }
75
+ }
76
+ addToPath(path, added, removed, oldPosInc, options) {
77
+ const last = path.lastComponent;
78
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) return {
79
+ oldPos: path.oldPos + oldPosInc,
80
+ lastComponent: {
81
+ count: last.count + 1,
82
+ added,
83
+ removed,
84
+ previousComponent: last.previousComponent
85
+ }
86
+ };
87
+ else return {
88
+ oldPos: path.oldPos + oldPosInc,
89
+ lastComponent: {
90
+ count: 1,
91
+ added,
92
+ removed,
93
+ previousComponent: last
94
+ }
95
+ };
96
+ }
97
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
98
+ const newLen = newTokens.length, oldLen = oldTokens.length;
99
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
100
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
101
+ newPos++;
102
+ oldPos++;
103
+ commonCount++;
104
+ if (options.oneChangePerToken) basePath.lastComponent = {
105
+ count: 1,
106
+ previousComponent: basePath.lastComponent,
107
+ added: false,
108
+ removed: false
109
+ };
110
+ }
111
+ if (commonCount && !options.oneChangePerToken) basePath.lastComponent = {
112
+ count: commonCount,
113
+ previousComponent: basePath.lastComponent,
114
+ added: false,
115
+ removed: false
116
+ };
117
+ basePath.oldPos = oldPos;
118
+ return newPos;
119
+ }
120
+ equals(left, right, options) {
121
+ if (options.comparator) return options.comparator(left, right);
122
+ else return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
123
+ }
124
+ removeEmpty(array) {
125
+ const ret = [];
126
+ for (let i = 0; i < array.length; i++) if (array[i]) ret.push(array[i]);
127
+ return ret;
128
+ }
129
+ castInput(value, options) {
130
+ return value;
131
+ }
132
+ tokenize(value, options) {
133
+ return Array.from(value);
134
+ }
135
+ join(chars) {
136
+ return chars.join("");
137
+ }
138
+ postProcess(changeObjects, options) {
139
+ return changeObjects;
140
+ }
141
+ get useLongestToken() {
142
+ return false;
143
+ }
144
+ buildValues(lastComponent, newTokens, oldTokens) {
145
+ const components = [];
146
+ let nextComponent;
147
+ while (lastComponent) {
148
+ components.push(lastComponent);
149
+ nextComponent = lastComponent.previousComponent;
150
+ delete lastComponent.previousComponent;
151
+ lastComponent = nextComponent;
152
+ }
153
+ components.reverse();
154
+ const componentLen = components.length;
155
+ let componentPos = 0, newPos = 0, oldPos = 0;
156
+ for (; componentPos < componentLen; componentPos++) {
157
+ const component = components[componentPos];
158
+ if (!component.removed) {
159
+ if (!component.added && this.useLongestToken) {
160
+ let value = newTokens.slice(newPos, newPos + component.count);
161
+ value = value.map(function(value, i) {
162
+ const oldValue = oldTokens[oldPos + i];
163
+ return oldValue.length > value.length ? oldValue : value;
164
+ });
165
+ component.value = this.join(value);
166
+ } else component.value = this.join(newTokens.slice(newPos, newPos + component.count));
167
+ newPos += component.count;
168
+ if (!component.added) oldPos += component.count;
169
+ } else {
170
+ component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
171
+ oldPos += component.count;
172
+ }
173
+ }
174
+ return components;
175
+ }
176
+ };
177
+ var CharacterDiff = class extends Diff {};
178
+ new CharacterDiff();
179
+ function longestCommonPrefix(str1, str2) {
180
+ let i = 0;
181
+ for (; i < str1.length && i < str2.length; i++) if (str1[i] != str2[i]) return str1.slice(0, i);
182
+ return str1.slice(0, i);
183
+ }
184
+ function longestCommonSuffix(str1, str2) {
185
+ let i;
186
+ if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) return "";
187
+ for (i = 0; i < str1.length && i < str2.length; i++) if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) return str1.slice(-i);
188
+ return str1.slice(-i);
189
+ }
190
+ function replacePrefix(string, oldPrefix, newPrefix) {
191
+ if (string.slice(0, oldPrefix.length) != oldPrefix) throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);
192
+ return newPrefix + string.slice(oldPrefix.length);
193
+ }
194
+ function replaceSuffix(string, oldSuffix, newSuffix) {
195
+ if (!oldSuffix) return string + newSuffix;
196
+ if (string.slice(-oldSuffix.length) != oldSuffix) throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);
197
+ return string.slice(0, -oldSuffix.length) + newSuffix;
198
+ }
199
+ function removePrefix(string, oldPrefix) {
200
+ return replacePrefix(string, oldPrefix, "");
201
+ }
202
+ function removeSuffix(string, oldSuffix) {
203
+ return replaceSuffix(string, oldSuffix, "");
204
+ }
205
+ function maximumOverlap(string1, string2) {
206
+ return string2.slice(0, overlapCount(string1, string2));
207
+ }
208
+ function overlapCount(a, b) {
209
+ let startA = 0;
210
+ if (a.length > b.length) startA = a.length - b.length;
211
+ let endB = b.length;
212
+ if (a.length < b.length) endB = a.length;
213
+ const map = Array(endB);
214
+ let k = 0;
215
+ map[0] = 0;
216
+ for (let j = 1; j < endB; j++) {
217
+ if (b[j] == b[k]) map[j] = map[k];
218
+ else map[j] = k;
219
+ while (k > 0 && b[j] != b[k]) k = map[k];
220
+ if (b[j] == b[k]) k++;
221
+ }
222
+ k = 0;
223
+ for (let i = startA; i < a.length; i++) {
224
+ while (k > 0 && a[i] != b[k]) k = map[k];
225
+ if (a[i] == b[k]) k++;
226
+ }
227
+ return k;
228
+ }
229
+ function segment(string, segmenter) {
230
+ const parts = [];
231
+ for (const segmentObj of Array.from(segmenter.segment(string))) {
232
+ const segment = segmentObj.segment;
233
+ if (parts.length && /\s/.test(parts[parts.length - 1]) && /\s/.test(segment)) parts[parts.length - 1] += segment;
234
+ else parts.push(segment);
235
+ }
236
+ return parts;
237
+ }
238
+ function trailingWs(string, segmenter) {
239
+ if (segmenter) return leadingAndTrailingWs(string, segmenter)[1];
240
+ let i;
241
+ for (i = string.length - 1; i >= 0; i--) if (!string[i].match(/\s/)) break;
242
+ return string.substring(i + 1);
243
+ }
244
+ function leadingWs(string, segmenter) {
245
+ if (segmenter) return leadingAndTrailingWs(string, segmenter)[0];
246
+ const match = string.match(/^\s*/);
247
+ return match ? match[0] : "";
248
+ }
249
+ function leadingAndTrailingWs(string, segmenter) {
250
+ if (!segmenter) return [leadingWs(string), trailingWs(string)];
251
+ if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
252
+ const segments = segment(string, segmenter);
253
+ const firstSeg = segments[0];
254
+ const lastSeg = segments[segments.length - 1];
255
+ return [/\s/.test(firstSeg) ? firstSeg : "", /\s/.test(lastSeg) ? lastSeg : ""];
256
+ }
257
+ const extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
258
+ const tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
259
+ var WordDiff = class extends Diff {
260
+ equals(left, right, options) {
261
+ if (options.ignoreCase) {
262
+ left = left.toLowerCase();
263
+ right = right.toLowerCase();
264
+ }
265
+ return left.trim() === right.trim();
266
+ }
267
+ tokenize(value, options = {}) {
268
+ let parts;
269
+ if (options.intlSegmenter) {
270
+ const segmenter = options.intlSegmenter;
271
+ if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
272
+ parts = segment(value, segmenter);
273
+ } else parts = value.match(tokenizeIncludingWhitespace) || [];
274
+ const tokens = [];
275
+ let prevPart = null;
276
+ parts.forEach((part) => {
277
+ if (/\s/.test(part)) {
278
+ if (prevPart == null) tokens.push(part);
279
+ else tokens.push(tokens.pop() + part);
280
+ } else if (prevPart != null && /\s/.test(prevPart)) {
281
+ if (tokens[tokens.length - 1] == prevPart) tokens.push(tokens.pop() + part);
282
+ else tokens.push(prevPart + part);
283
+ } else tokens.push(part);
284
+ prevPart = part;
285
+ });
286
+ return tokens;
287
+ }
288
+ join(tokens) {
289
+ return tokens.map((token, i) => {
290
+ if (i == 0) return token;
291
+ else return token.replace(/^\s+/, "");
292
+ }).join("");
293
+ }
294
+ postProcess(changes, options) {
295
+ if (!changes || options.oneChangePerToken) return changes;
296
+ let lastKeep = null;
297
+ let insertion = null;
298
+ let deletion = null;
299
+ changes.forEach((change) => {
300
+ if (change.added) insertion = change;
301
+ else if (change.removed) deletion = change;
302
+ else {
303
+ if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change, options.intlSegmenter);
304
+ lastKeep = change;
305
+ insertion = null;
306
+ deletion = null;
307
+ }
308
+ });
309
+ if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null, options.intlSegmenter);
310
+ return changes;
311
+ }
312
+ };
313
+ new WordDiff();
314
+ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep, segmenter) {
315
+ if (deletion && insertion) {
316
+ const [oldWsPrefix, oldWsSuffix] = leadingAndTrailingWs(deletion.value, segmenter);
317
+ const [newWsPrefix, newWsSuffix] = leadingAndTrailingWs(insertion.value, segmenter);
318
+ if (startKeep) {
319
+ const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
320
+ startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
321
+ deletion.value = removePrefix(deletion.value, commonWsPrefix);
322
+ insertion.value = removePrefix(insertion.value, commonWsPrefix);
323
+ }
324
+ if (endKeep) {
325
+ const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
326
+ endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
327
+ deletion.value = removeSuffix(deletion.value, commonWsSuffix);
328
+ insertion.value = removeSuffix(insertion.value, commonWsSuffix);
329
+ }
330
+ } else if (insertion) {
331
+ if (startKeep) {
332
+ const ws = leadingWs(insertion.value, segmenter);
333
+ insertion.value = insertion.value.substring(ws.length);
334
+ }
335
+ if (endKeep) {
336
+ const ws = leadingWs(endKeep.value, segmenter);
337
+ endKeep.value = endKeep.value.substring(ws.length);
338
+ }
339
+ } else if (startKeep && endKeep) {
340
+ const newWsFull = leadingWs(endKeep.value, segmenter), [delWsStart, delWsEnd] = leadingAndTrailingWs(deletion.value, segmenter);
341
+ const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
342
+ deletion.value = removePrefix(deletion.value, newWsStart);
343
+ const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
344
+ deletion.value = removeSuffix(deletion.value, newWsEnd);
345
+ endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
346
+ startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
347
+ } else if (endKeep) {
348
+ const endKeepWsPrefix = leadingWs(endKeep.value, segmenter);
349
+ const overlap = maximumOverlap(trailingWs(deletion.value, segmenter), endKeepWsPrefix);
350
+ deletion.value = removeSuffix(deletion.value, overlap);
351
+ } else if (startKeep) {
352
+ const overlap = maximumOverlap(trailingWs(startKeep.value, segmenter), leadingWs(deletion.value, segmenter));
353
+ deletion.value = removePrefix(deletion.value, overlap);
354
+ }
355
+ }
356
+ var WordsWithSpaceDiff = class extends Diff {
357
+ tokenize(value) {
358
+ const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
359
+ return value.match(regex) || [];
360
+ }
361
+ };
362
+ new WordsWithSpaceDiff();
363
+ var LineDiff = class extends Diff {
364
+ constructor() {
365
+ super(...arguments);
366
+ this.tokenize = tokenize;
367
+ }
368
+ equals(left, right, options) {
369
+ if (options.ignoreWhitespace) {
370
+ if (!options.newlineIsToken || !left.includes("\n")) left = left.trim();
371
+ if (!options.newlineIsToken || !right.includes("\n")) right = right.trim();
372
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
373
+ if (left.endsWith("\n")) left = left.slice(0, -1);
374
+ if (right.endsWith("\n")) right = right.slice(0, -1);
375
+ }
376
+ return super.equals(left, right, options);
377
+ }
378
+ };
379
+ new LineDiff();
380
+ function tokenize(value, options) {
381
+ if (options.stripTrailingCr) value = value.replace(/\r\n/g, "\n");
382
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
383
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) linesAndNewlines.pop();
384
+ for (let i = 0; i < linesAndNewlines.length; i++) {
385
+ const line = linesAndNewlines[i];
386
+ if (i % 2 && !options.newlineIsToken) retLines[retLines.length - 1] += line;
387
+ else retLines.push(line);
388
+ }
389
+ return retLines;
390
+ }
391
+ function isSentenceEndPunct(char) {
392
+ return char == "." || char == "!" || char == "?";
393
+ }
394
+ var SentenceDiff = class extends Diff {
395
+ tokenize(value) {
396
+ var _a;
397
+ const result = [];
398
+ let tokenStartI = 0;
399
+ for (let i = 0; i < value.length; i++) {
400
+ if (i == value.length - 1) {
401
+ result.push(value.slice(tokenStartI));
402
+ break;
403
+ }
404
+ if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
405
+ result.push(value.slice(tokenStartI, i + 1));
406
+ i = tokenStartI = i + 1;
407
+ while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\s/)) i++;
408
+ result.push(value.slice(tokenStartI, i + 1));
409
+ tokenStartI = i + 1;
410
+ }
411
+ }
412
+ return result;
413
+ }
414
+ };
415
+ new SentenceDiff();
416
+ var CssDiff = class extends Diff {
417
+ tokenize(value) {
418
+ return value.split(/([{}:;,]|\s+)/);
419
+ }
420
+ };
421
+ new CssDiff();
422
+ var JsonDiff = class extends Diff {
423
+ constructor() {
424
+ super(...arguments);
425
+ this.tokenize = tokenize;
426
+ }
427
+ get useLongestToken() {
428
+ return true;
429
+ }
430
+ castInput(value, options) {
431
+ const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
432
+ return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
433
+ }
434
+ equals(left, right, options) {
435
+ return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
436
+ }
437
+ };
438
+ new JsonDiff();
439
+ function canonicalize(obj, stack, replacementStack, replacer, key) {
440
+ stack = stack || [];
441
+ replacementStack = replacementStack || [];
442
+ if (replacer) obj = replacer(key === void 0 ? "" : key, obj);
443
+ let i = 0;
444
+ for (; i < stack.length; i += 1) if (stack[i] === obj) return replacementStack[i];
445
+ let canonicalizedObj;
446
+ if ("[object Array]" === Object.prototype.toString.call(obj)) {
447
+ stack.push(obj);
448
+ canonicalizedObj = new Array(obj.length);
449
+ replacementStack.push(canonicalizedObj);
450
+ for (i = 0; i < obj.length; i += 1) canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
451
+ stack.pop();
452
+ replacementStack.pop();
453
+ return canonicalizedObj;
454
+ }
455
+ if (obj && obj.toJSON) obj = obj.toJSON();
456
+ if (typeof obj === "object" && obj !== null) {
457
+ stack.push(obj);
458
+ canonicalizedObj = {};
459
+ replacementStack.push(canonicalizedObj);
460
+ const sortedKeys = [];
461
+ let key;
462
+ for (key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) sortedKeys.push(key);
463
+ sortedKeys.sort();
464
+ for (i = 0; i < sortedKeys.length; i += 1) {
465
+ key = sortedKeys[i];
466
+ canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key);
467
+ }
468
+ stack.pop();
469
+ replacementStack.pop();
470
+ } else canonicalizedObj = obj;
471
+ return canonicalizedObj;
472
+ }
473
+ var ArrayDiff = class extends Diff {
474
+ tokenize(value) {
475
+ return value.slice();
476
+ }
477
+ join(value) {
478
+ return value;
479
+ }
480
+ removeEmpty(value) {
481
+ return value;
482
+ }
483
+ };
484
+ new ArrayDiff();
485
+ export {};
@@ -0,0 +1,7 @@
1
+ import { findRoot, loadConfig, resolveConfig } from "./config.mjs";
2
+ import { join } from "node:path";
3
+ async function locateOutput(start) {
4
+ const root = findRoot(start);
5
+ return join(root, resolveConfig(await loadConfig(root)).output.dir);
6
+ }
7
+ export { locateOutput };