@cloudflare/workspace 0.0.0-alpha.0
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/README.md +98 -0
- package/dist/bin/wsd-linux-x64 +0 -0
- package/dist/git.d.ts +119 -0
- package/dist/git.js +271 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +384 -0
- package/dist/index.js +2902 -0
- package/dist/index.js.map +1 -0
- package/dist/shared-Dj4r_9xb.js +737 -0
- package/dist/shared-Dj4r_9xb.js.map +1 -0
- package/dist/shared-RIdME5uo.d.ts +302 -0
- package/package.json +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-Dj4r_9xb.js","names":[],"sources":["../../../node_modules/diff/libesm/diff/base.js","../../../node_modules/diff/libesm/diff/character.js","../../../node_modules/diff/libesm/util/string.js","../../../node_modules/diff/libesm/diff/word.js","../../../node_modules/diff/libesm/diff/line.js","../../../node_modules/diff/libesm/diff/sentence.js","../../../node_modules/diff/libesm/diff/css.js","../../../node_modules/diff/libesm/diff/json.js","../../../node_modules/diff/libesm/diff/array.js","../../../node_modules/diff/libesm/patch/create.js"],"sourcesContent":["export default class Diff {\n diff(oldStr, newStr, \n // Type below is not accurate/complete - see above for full possibilities - but it compiles\n options = {}) {\n let callback;\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n else if ('callback' in options) {\n callback = options.callback;\n }\n // Allow subclasses to massage the input prior to running\n const oldString = this.castInput(oldStr, options);\n const newString = this.castInput(newStr, options);\n const oldTokens = this.removeEmpty(this.tokenize(oldString, options));\n const newTokens = this.removeEmpty(this.tokenize(newString, options));\n return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);\n }\n diffWithOptionsObj(oldTokens, newTokens, options, callback) {\n var _a;\n const done = (value) => {\n value = this.postProcess(value, options);\n if (callback) {\n setTimeout(function () { callback(value); }, 0);\n return undefined;\n }\n else {\n return value;\n }\n };\n const newLen = newTokens.length, oldLen = oldTokens.length;\n let editLength = 1;\n let maxEditLength = newLen + oldLen;\n if (options.maxEditLength != null) {\n maxEditLength = Math.min(maxEditLength, options.maxEditLength);\n }\n const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;\n const abortAfterTimestamp = Date.now() + maxExecutionTime;\n const bestPath = [{ oldPos: -1, lastComponent: undefined }];\n // Seed editLength = 0, i.e. the content starts with the same values\n let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);\n if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {\n // Identity per the equality and tokenizer\n return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));\n }\n // Once we hit the right edge of the edit graph on some diagonal k, we can\n // definitely reach the end of the edit graph in no more than k edits, so\n // there's no point in considering any moves to diagonal k+1 any more (from\n // which we're guaranteed to need at least k+1 more edits).\n // Similarly, once we've reached the bottom of the edit graph, there's no\n // point considering moves to lower diagonals.\n // We record this fact by setting minDiagonalToConsider and\n // maxDiagonalToConsider to some finite value once we've hit the edge of\n // the edit graph.\n // This optimization is not faithful to the original algorithm presented in\n // Myers's paper, which instead pointlessly extends D-paths off the end of\n // the edit graph - see page 7 of Myers's paper which notes this point\n // explicitly and illustrates it with a diagram. This has major performance\n // implications for some common scenarios. For instance, to compute a diff\n // where the new text simply appends d characters on the end of the\n // original text of length n, the true Myers algorithm will take O(n+d^2)\n // time while this optimization needs only O(n+d) time.\n let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;\n // Main worker method. checks all permutations of a given edit length for acceptance.\n const execEditLength = () => {\n for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {\n let basePath;\n const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];\n if (removePath) {\n // No one else is going to attempt to use this value, clear it\n // @ts-expect-error - perf optimisation. This type-violating value will never be read.\n bestPath[diagonalPath - 1] = undefined;\n }\n let canAdd = false;\n if (addPath) {\n // what newPos will be after we do an insertion:\n const addPathNewPos = addPath.oldPos - diagonalPath;\n canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;\n }\n const canRemove = removePath && removePath.oldPos + 1 < oldLen;\n if (!canAdd && !canRemove) {\n // If this path is a terminal then prune\n // @ts-expect-error - perf optimisation. This type-violating value will never be read.\n bestPath[diagonalPath] = undefined;\n continue;\n }\n // Select the diagonal that we want to branch from. We select the prior\n // path whose position in the old string is the farthest from the origin\n // and does not pass the bounds of the diff graph\n if (!canRemove || (canAdd && removePath.oldPos < addPath.oldPos)) {\n basePath = this.addToPath(addPath, true, false, 0, options);\n }\n else {\n basePath = this.addToPath(removePath, false, true, 1, options);\n }\n newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);\n if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {\n // If we have hit the end of both strings, then we are done\n return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;\n }\n else {\n bestPath[diagonalPath] = basePath;\n if (basePath.oldPos + 1 >= oldLen) {\n maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);\n }\n if (newPos + 1 >= newLen) {\n minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);\n }\n }\n }\n editLength++;\n };\n // Performs the length of edit iteration. Is a bit fugly as this has to support the\n // sync and async mode which is never fun. Loops over execEditLength until a value\n // is produced, or until the edit length exceeds options.maxEditLength (if given),\n // in which case it will return undefined.\n if (callback) {\n (function exec() {\n setTimeout(function () {\n if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {\n return callback(undefined);\n }\n if (!execEditLength()) {\n exec();\n }\n }, 0);\n }());\n }\n else {\n while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {\n const ret = execEditLength();\n if (ret) {\n return ret;\n }\n }\n }\n }\n addToPath(path, added, removed, oldPosInc, options) {\n const last = path.lastComponent;\n if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {\n return {\n oldPos: path.oldPos + oldPosInc,\n lastComponent: { count: last.count + 1, added: added, removed: removed, previousComponent: last.previousComponent }\n };\n }\n else {\n return {\n oldPos: path.oldPos + oldPosInc,\n lastComponent: { count: 1, added: added, removed: removed, previousComponent: last }\n };\n }\n }\n extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {\n const newLen = newTokens.length, oldLen = oldTokens.length;\n let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;\n while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {\n newPos++;\n oldPos++;\n commonCount++;\n if (options.oneChangePerToken) {\n basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };\n }\n }\n if (commonCount && !options.oneChangePerToken) {\n basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };\n }\n basePath.oldPos = oldPos;\n return newPos;\n }\n equals(left, right, options) {\n if (options.comparator) {\n return options.comparator(left, right);\n }\n else {\n return left === right\n || (!!options.ignoreCase && left.toLowerCase() === right.toLowerCase());\n }\n }\n removeEmpty(array) {\n const ret = [];\n for (let i = 0; i < array.length; i++) {\n if (array[i]) {\n ret.push(array[i]);\n }\n }\n return ret;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n castInput(value, options) {\n return value;\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n tokenize(value, options) {\n return Array.from(value);\n }\n join(chars) {\n // Assumes ValueT is string, which is the case for most subclasses.\n // When it's false, e.g. in diffArrays, this method needs to be overridden (e.g. with a no-op)\n // Yes, the casts are verbose and ugly, because this pattern - of having the base class SORT OF\n // assume tokens and values are strings, but not completely - is weird and janky.\n return chars.join('');\n }\n postProcess(changeObjects, \n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n options) {\n return changeObjects;\n }\n get useLongestToken() {\n return false;\n }\n buildValues(lastComponent, newTokens, oldTokens) {\n // First we convert our linked list of components in reverse order to an\n // array in the right order:\n const components = [];\n let nextComponent;\n while (lastComponent) {\n components.push(lastComponent);\n nextComponent = lastComponent.previousComponent;\n delete lastComponent.previousComponent;\n lastComponent = nextComponent;\n }\n components.reverse();\n const componentLen = components.length;\n let componentPos = 0, newPos = 0, oldPos = 0;\n for (; componentPos < componentLen; componentPos++) {\n const component = components[componentPos];\n if (!component.removed) {\n if (!component.added && this.useLongestToken) {\n let value = newTokens.slice(newPos, newPos + component.count);\n value = value.map(function (value, i) {\n const oldValue = oldTokens[oldPos + i];\n return oldValue.length > value.length ? oldValue : value;\n });\n component.value = this.join(value);\n }\n else {\n component.value = this.join(newTokens.slice(newPos, newPos + component.count));\n }\n newPos += component.count;\n // Common case\n if (!component.added) {\n oldPos += component.count;\n }\n }\n else {\n component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));\n oldPos += component.count;\n }\n }\n return components;\n }\n}\n","import Diff from './base.js';\nclass CharacterDiff extends Diff {\n}\nexport const characterDiff = new CharacterDiff();\nexport function diffChars(oldStr, newStr, options) {\n return characterDiff.diff(oldStr, newStr, options);\n}\n","export function longestCommonPrefix(str1, str2) {\n let i;\n for (i = 0; i < str1.length && i < str2.length; i++) {\n if (str1[i] != str2[i]) {\n return str1.slice(0, i);\n }\n }\n return str1.slice(0, i);\n}\nexport function longestCommonSuffix(str1, str2) {\n let i;\n // Unlike longestCommonPrefix, we need a special case to handle all scenarios\n // where we return the empty string since str1.slice(-0) will return the\n // entire string.\n if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {\n return '';\n }\n for (i = 0; i < str1.length && i < str2.length; i++) {\n if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {\n return str1.slice(-i);\n }\n }\n return str1.slice(-i);\n}\nexport function replacePrefix(string, oldPrefix, newPrefix) {\n if (string.slice(0, oldPrefix.length) != oldPrefix) {\n throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`);\n }\n return newPrefix + string.slice(oldPrefix.length);\n}\nexport function replaceSuffix(string, oldSuffix, newSuffix) {\n if (!oldSuffix) {\n return string + newSuffix;\n }\n if (string.slice(-oldSuffix.length) != oldSuffix) {\n throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`);\n }\n return string.slice(0, -oldSuffix.length) + newSuffix;\n}\nexport function removePrefix(string, oldPrefix) {\n return replacePrefix(string, oldPrefix, '');\n}\nexport function removeSuffix(string, oldSuffix) {\n return replaceSuffix(string, oldSuffix, '');\n}\nexport function maximumOverlap(string1, string2) {\n return string2.slice(0, overlapCount(string1, string2));\n}\n// Nicked from https://stackoverflow.com/a/60422853/1709587\nfunction overlapCount(a, b) {\n // Deal with cases where the strings differ in length\n let startA = 0;\n if (a.length > b.length) {\n startA = a.length - b.length;\n }\n let endB = b.length;\n if (a.length < b.length) {\n endB = a.length;\n }\n // Create a back-reference for each index\n // that should be followed in case of a mismatch.\n // We only need B to make these references:\n const map = Array(endB);\n let k = 0; // Index that lags behind j\n map[0] = 0;\n for (let j = 1; j < endB; j++) {\n if (b[j] == b[k]) {\n map[j] = map[k]; // skip over the same character (optional optimisation)\n }\n else {\n map[j] = k;\n }\n while (k > 0 && b[j] != b[k]) {\n k = map[k];\n }\n if (b[j] == b[k]) {\n k++;\n }\n }\n // Phase 2: use these references while iterating over A\n k = 0;\n for (let i = startA; i < a.length; i++) {\n while (k > 0 && a[i] != b[k]) {\n k = map[k];\n }\n if (a[i] == b[k]) {\n k++;\n }\n }\n return k;\n}\n/**\n * Returns true if the string consistently uses Windows line endings.\n */\nexport function hasOnlyWinLineEndings(string) {\n return string.includes('\\r\\n') && !string.startsWith('\\n') && !string.match(/[^\\r]\\n/);\n}\n/**\n * Returns true if the string consistently uses Unix line endings.\n */\nexport function hasOnlyUnixLineEndings(string) {\n return !string.includes('\\r\\n') && string.includes('\\n');\n}\n/**\n * Split a string into segments using a word segmenter, merging consecutive\n * segments if they are both whitespace segments. Whitespace segments can\n * appear adjacent to one another for two reasons:\n * - newlines always get their own segment\n * - where a diacritic is attached to a whitespace character in the text, the\n * segment ends after the diacritic, so e.g. \" \\u0300 \" becomes two segments.\n * This function therefore runs the segmenter's .segment() method and then\n * merges consecutive segments of whitespace into a single part.\n */\nexport function segment(string, segmenter) {\n const parts = [];\n for (const segmentObj of Array.from(segmenter.segment(string))) {\n const segment = segmentObj.segment;\n if (parts.length && (/\\s/).test(parts[parts.length - 1]) && (/\\s/).test(segment)) {\n parts[parts.length - 1] += segment;\n }\n else {\n parts.push(segment);\n }\n }\n return parts;\n}\n// The functions below take a `segmenter` argument so that, when called from\n// diffWords when it is using a segmenter, they can use a notion of what\n// constitutes \"whitespace\" that is consistent with the segmenter.\n//\n// USUALLY this will be identical to the result of the non-segmenter-based\n// logic, but it differs in at least one case: when whitespace characters are\n// modified by diacritics. A word segmenter considers these diacritics to be\n// part of the whitespace, whereas our non-segmenter-based logic does not.\n//\n// Because the segmenter-based approach necessarily requires segmenting the\n// entire string, we offer a leadingAndTrailingWs function to allow getting the\n// whitespace prefix AND whitespace suffix with a single call to the segmenter,\n// for efficiency's sake.\nexport function trailingWs(string, segmenter) {\n if (segmenter) {\n return leadingAndTrailingWs(string, segmenter)[1];\n }\n // Yes, this looks overcomplicated and dumb - why not replace the whole function with\n // return string.match(/\\s*$/)[0]\n // you ask? Because:\n // 1. the trap described at https://markamery.com/blog/quadratic-time-regexes/ would mean doing\n // this would cause this function to take O(n²) time in the worst case (specifically when\n // there is a massive run of NON-TRAILING whitespace in `string`), and\n // 2. the fix proposed in the same blog post, of using a negative lookbehind, is incompatible\n // with old Safari versions that we'd like to not break if possible (see\n // https://github.com/kpdecker/jsdiff/pull/550)\n // It feels absurd to do this with an explicit loop instead of a regex, but I really can't see a\n // better way that doesn't result in broken behaviour.\n let i;\n for (i = string.length - 1; i >= 0; i--) {\n if (!string[i].match(/\\s/)) {\n break;\n }\n }\n return string.substring(i + 1);\n}\nexport function leadingWs(string, segmenter) {\n if (segmenter) {\n return leadingAndTrailingWs(string, segmenter)[0];\n }\n // Thankfully the annoying considerations described in trailingWs don't apply here:\n const match = string.match(/^\\s*/);\n return match ? match[0] : '';\n}\nexport function leadingAndTrailingWs(string, segmenter) {\n if (!segmenter) {\n return [leadingWs(string), trailingWs(string)];\n }\n if (segmenter.resolvedOptions().granularity != 'word') {\n throw new Error('The segmenter passed must have a granularity of \"word\"');\n }\n const segments = segment(string, segmenter);\n const firstSeg = segments[0];\n const lastSeg = segments[segments.length - 1];\n const head = (/\\s/).test(firstSeg) ? firstSeg : '';\n const tail = (/\\s/).test(lastSeg) ? lastSeg : '';\n return [head, tail];\n}\n","import Diff from './base.js';\nimport { longestCommonPrefix, longestCommonSuffix, replacePrefix, replaceSuffix, removePrefix, removeSuffix, maximumOverlap, leadingWs, trailingWs, leadingAndTrailingWs, segment } from '../util/string.js';\n// Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode\n//\n// Chars/ranges counted as \"word\" characters by this regex are as follows:\n//\n// + U+00AD Soft hyphen\n// + 00C0–00FF (letters with diacritics from the Latin-1 Supplement), except:\n// - U+00D7 × Multiplication sign\n// - U+00F7 ÷ Division sign\n// + Latin Extended-A, 0100–017F\n// + Latin Extended-B, 0180–024F\n// + IPA Extensions, 0250–02AF\n// + Spacing Modifier Letters, 02B0–02FF, except:\n// - U+02C7 ˇ ˇ Caron\n// - U+02D8 ˘ ˘ Breve\n// - U+02D9 ˙ ˙ Dot Above\n// - U+02DA ˚ ˚ Ring Above\n// - U+02DB ˛ ˛ Ogonek\n// - U+02DC ˜ ˜ Small Tilde\n// - U+02DD ˝ ˝ Double Acute Accent\n// + Latin Extended Additional, 1E00–1EFF\nconst 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}';\n// Each token is one of the following:\n// - A punctuation mark plus the surrounding whitespace\n// - A word plus the surrounding whitespace\n// - Pure whitespace (but only in the special case where the entire text\n// is just whitespace)\n//\n// We have to include surrounding whitespace in the tokens because the two\n// alternative approaches produce horribly broken results:\n// * If we just discard the whitespace, we can't fully reproduce the original\n// text from the sequence of tokens and any attempt to render the diff will\n// get the whitespace wrong.\n// * If we have separate tokens for whitespace, then in a typical text every\n// second token will be a single space character. But this often results in\n// the optimal diff between two texts being a perverse one that preserves\n// the spaces between words but deletes and reinserts actual common words.\n// See https://github.com/kpdecker/jsdiff/issues/160#issuecomment-1866099640\n// for an example.\n//\n// Keeping the surrounding whitespace of course has implications for .equals\n// and .join, not just .tokenize.\n// This regex does NOT fully implement the tokenization rules described above.\n// Instead, it gives runs of whitespace their own \"token\". The tokenize method\n// then handles stitching whitespace tokens onto adjacent word or punctuation\n// tokens.\nconst tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\\\s+|[^${extendedWordChars}]`, 'ug');\nclass WordDiff extends Diff {\n equals(left, right, options) {\n if (options.ignoreCase) {\n left = left.toLowerCase();\n right = right.toLowerCase();\n }\n return left.trim() === right.trim();\n }\n tokenize(value, options = {}) {\n let parts;\n if (options.intlSegmenter) {\n const segmenter = options.intlSegmenter;\n if (segmenter.resolvedOptions().granularity != 'word') {\n throw new Error('The segmenter passed must have a granularity of \"word\"');\n }\n // We want `parts` to be an array whose elements alternate between being\n // pure whitespace and being pure non-whitespace. This is ALMOST what the\n // segments returned by a word-based Intl.Segmenter already look like,\n // but not quite - see explanation in the docs of our custom segment()\n // function.\n parts = segment(value, segmenter);\n }\n else {\n parts = value.match(tokenizeIncludingWhitespace) || [];\n }\n const tokens = [];\n let prevPart = null;\n parts.forEach(part => {\n if ((/\\s/).test(part)) {\n if (prevPart == null) {\n tokens.push(part);\n }\n else {\n tokens.push(tokens.pop() + part);\n }\n }\n else if (prevPart != null && (/\\s/).test(prevPart)) {\n if (tokens[tokens.length - 1] == prevPart) {\n tokens.push(tokens.pop() + part);\n }\n else {\n tokens.push(prevPart + part);\n }\n }\n else {\n tokens.push(part);\n }\n prevPart = part;\n });\n return tokens;\n }\n join(tokens) {\n // Tokens being joined here will always have appeared consecutively in the\n // same text, so we can simply strip off the leading whitespace from all the\n // tokens except the first (and except any whitespace-only tokens - but such\n // a token will always be the first and only token anyway) and then join them\n // and the whitespace around words and punctuation will end up correct.\n return tokens.map((token, i) => {\n if (i == 0) {\n return token;\n }\n else {\n return token.replace((/^\\s+/), '');\n }\n }).join('');\n }\n postProcess(changes, options) {\n if (!changes || options.oneChangePerToken) {\n return changes;\n }\n let lastKeep = null;\n // Change objects representing any insertion or deletion since the last\n // \"keep\" change object. There can be at most one of each.\n let insertion = null;\n let deletion = null;\n changes.forEach(change => {\n if (change.added) {\n insertion = change;\n }\n else if (change.removed) {\n deletion = change;\n }\n else {\n if (insertion || deletion) { // May be false at start of text\n dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change, options.intlSegmenter);\n }\n lastKeep = change;\n insertion = null;\n deletion = null;\n }\n });\n if (insertion || deletion) {\n dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null, options.intlSegmenter);\n }\n return changes;\n }\n}\nexport const wordDiff = new WordDiff();\nexport function diffWords(oldStr, newStr, options) {\n // This option has never been documented and never will be (it's clearer to\n // just call `diffWordsWithSpace` directly if you need that behavior), but\n // has existed in jsdiff for a long time, so we retain support for it here\n // for the sake of backwards compatibility.\n if ((options === null || options === void 0 ? void 0 : options.ignoreWhitespace) != null && !options.ignoreWhitespace) {\n return diffWordsWithSpace(oldStr, newStr, options);\n }\n return wordDiff.diff(oldStr, newStr, options);\n}\nfunction dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep, segmenter) {\n // Before returning, we tidy up the leading and trailing whitespace of the\n // change objects to eliminate cases where trailing whitespace in one object\n // is repeated as leading whitespace in the next.\n // Below are examples of the outcomes we want here to explain the code.\n // I=insert, K=keep, D=delete\n // 1. diffing 'foo bar baz' vs 'foo baz'\n // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'\n // After cleanup, we want: K:'foo ' D:'bar ' K:'baz'\n //\n // 2. Diffing 'foo bar baz' vs 'foo qux baz'\n // Prior to cleanup, we have K:'foo ' D:' bar ' I:' qux ' K:' baz'\n // After cleanup, we want K:'foo ' D:'bar' I:'qux' K:' baz'\n //\n // 3. Diffing 'foo\\nbar baz' vs 'foo baz'\n // Prior to cleanup, we have K:'foo ' D:'\\nbar ' K:' baz'\n // After cleanup, we want K'foo' D:'\\nbar' K:' baz'\n //\n // 4. Diffing 'foo baz' vs 'foo\\nbar baz'\n // Prior to cleanup, we have K:'foo\\n' I:'\\nbar ' K:' baz'\n // After cleanup, we ideally want K'foo' I:'\\nbar' K:' baz'\n // but don't actually manage this currently (the pre-cleanup change\n // objects don't contain enough information to make it possible).\n //\n // 5. Diffing 'foo bar baz' vs 'foo baz'\n // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'\n // After cleanup, we want K:'foo ' D:' bar ' K:'baz'\n //\n // Our handling is unavoidably imperfect in the case where there's a single\n // indel between keeps and the whitespace has changed. For instance, consider\n // diffing 'foo\\tbar\\nbaz' vs 'foo baz'. Unless we create an extra change\n // object to represent the insertion of the space character (which isn't even\n // a token), we have no way to avoid losing information about the texts'\n // original whitespace in the result we return. Still, we do our best to\n // output something that will look sensible if we e.g. print it with\n // insertions in green and deletions in red.\n // Between two \"keep\" change objects (or before the first or after the last\n // change object), we can have either:\n // * A \"delete\" followed by an \"insert\"\n // * Just an \"insert\"\n // * Just a \"delete\"\n // We handle the three cases separately.\n if (deletion && insertion) {\n const [oldWsPrefix, oldWsSuffix] = leadingAndTrailingWs(deletion.value, segmenter);\n const [newWsPrefix, newWsSuffix] = leadingAndTrailingWs(insertion.value, segmenter);\n if (startKeep) {\n const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);\n startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);\n deletion.value = removePrefix(deletion.value, commonWsPrefix);\n insertion.value = removePrefix(insertion.value, commonWsPrefix);\n }\n if (endKeep) {\n const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);\n endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);\n deletion.value = removeSuffix(deletion.value, commonWsSuffix);\n insertion.value = removeSuffix(insertion.value, commonWsSuffix);\n }\n }\n else if (insertion) {\n // The whitespaces all reflect what was in the new text rather than\n // the old, so we essentially have no information about whitespace\n // insertion or deletion. We just want to dedupe the whitespace.\n // We do that by having each change object keep its trailing\n // whitespace and deleting duplicate leading whitespace where\n // present.\n if (startKeep) {\n const ws = leadingWs(insertion.value, segmenter);\n insertion.value = insertion.value.substring(ws.length);\n }\n if (endKeep) {\n const ws = leadingWs(endKeep.value, segmenter);\n endKeep.value = endKeep.value.substring(ws.length);\n }\n // otherwise we've got a deletion and no insertion\n }\n else if (startKeep && endKeep) {\n const newWsFull = leadingWs(endKeep.value, segmenter), [delWsStart, delWsEnd] = leadingAndTrailingWs(deletion.value, segmenter);\n // Any whitespace that comes straight after startKeep in both the old and\n // new texts, assign to startKeep and remove from the deletion.\n const newWsStart = longestCommonPrefix(newWsFull, delWsStart);\n deletion.value = removePrefix(deletion.value, newWsStart);\n // Any whitespace that comes straight before endKeep in both the old and\n // new texts, and hasn't already been assigned to startKeep, assign to\n // endKeep and remove from the deletion.\n const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);\n deletion.value = removeSuffix(deletion.value, newWsEnd);\n endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);\n // If there's any whitespace from the new text that HASN'T already been\n // assigned, assign it to the start:\n startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));\n }\n else if (endKeep) {\n // We are at the start of the text. Preserve all the whitespace on\n // endKeep, and just remove whitespace from the end of deletion to the\n // extent that it overlaps with the start of endKeep.\n const endKeepWsPrefix = leadingWs(endKeep.value, segmenter);\n const deletionWsSuffix = trailingWs(deletion.value, segmenter);\n const overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);\n deletion.value = removeSuffix(deletion.value, overlap);\n }\n else if (startKeep) {\n // We are at the END of the text. Preserve all the whitespace on\n // startKeep, and just remove whitespace from the start of deletion to\n // the extent that it overlaps with the end of startKeep.\n const startKeepWsSuffix = trailingWs(startKeep.value, segmenter);\n const deletionWsPrefix = leadingWs(deletion.value, segmenter);\n const overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);\n deletion.value = removePrefix(deletion.value, overlap);\n }\n}\nclass WordsWithSpaceDiff extends Diff {\n tokenize(value) {\n // Slightly different to the tokenizeIncludingWhitespace regex used above in\n // that this one treats each individual newline as a distinct token, rather\n // than merging them into other surrounding whitespace. This was requested\n // in https://github.com/kpdecker/jsdiff/issues/180 &\n // https://github.com/kpdecker/jsdiff/issues/211\n const regex = new RegExp(`(\\\\r?\\\\n)|[${extendedWordChars}]+|[^\\\\S\\\\n\\\\r]+|[^${extendedWordChars}]`, 'ug');\n return value.match(regex) || [];\n }\n}\nexport const wordsWithSpaceDiff = new WordsWithSpaceDiff();\nexport function diffWordsWithSpace(oldStr, newStr, options) {\n return wordsWithSpaceDiff.diff(oldStr, newStr, options);\n}\n","import Diff from './base.js';\nimport { generateOptions } from '../util/params.js';\nclass LineDiff extends Diff {\n constructor() {\n super(...arguments);\n this.tokenize = tokenize;\n }\n equals(left, right, options) {\n // If we're ignoring whitespace, we need to normalise lines by stripping\n // whitespace before checking equality. (This has an annoying interaction\n // with newlineIsToken that requires special handling: if newlines get their\n // own token, then we DON'T want to trim the *newline* tokens down to empty\n // strings, since this would cause us to treat whitespace-only line content\n // as equal to a separator between lines, which would be weird and\n // inconsistent with the documented behavior of the options.)\n if (options.ignoreWhitespace) {\n if (!options.newlineIsToken || !left.includes('\\n')) {\n left = left.trim();\n }\n if (!options.newlineIsToken || !right.includes('\\n')) {\n right = right.trim();\n }\n }\n else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {\n if (left.endsWith('\\n')) {\n left = left.slice(0, -1);\n }\n if (right.endsWith('\\n')) {\n right = right.slice(0, -1);\n }\n }\n return super.equals(left, right, options);\n }\n}\nexport const lineDiff = new LineDiff();\nexport function diffLines(oldStr, newStr, options) {\n return lineDiff.diff(oldStr, newStr, options);\n}\nexport function diffTrimmedLines(oldStr, newStr, options) {\n options = generateOptions(options, { ignoreWhitespace: true });\n return lineDiff.diff(oldStr, newStr, options);\n}\n// Exported standalone so it can be used from jsonDiff too.\nexport function tokenize(value, options) {\n if (options.stripTrailingCr) {\n // remove one \\r before \\n to match GNU diff's --strip-trailing-cr behavior\n value = value.replace(/\\r\\n/g, '\\n');\n }\n const retLines = [], linesAndNewlines = value.split(/(\\n|\\r\\n)/);\n // Ignore the final empty token that occurs if the string ends with a new line\n if (!linesAndNewlines[linesAndNewlines.length - 1]) {\n linesAndNewlines.pop();\n }\n // Merge the content and line separators into single tokens\n for (let i = 0; i < linesAndNewlines.length; i++) {\n const line = linesAndNewlines[i];\n if (i % 2 && !options.newlineIsToken) {\n retLines[retLines.length - 1] += line;\n }\n else {\n retLines.push(line);\n }\n }\n return retLines;\n}\n","import Diff from './base.js';\nfunction isSentenceEndPunct(char) {\n return char == '.' || char == '!' || char == '?';\n}\nclass SentenceDiff extends Diff {\n tokenize(value) {\n var _a;\n // If in future we drop support for environments that don't support lookbehinds, we can replace\n // this entire function with:\n // return value.split(/(?<=[.!?])(\\s+|$)/);\n // but until then, for similar reasons to the trailingWs function in string.ts, we are forced\n // to do this verbosely \"by hand\" instead of using a regex.\n const result = [];\n let tokenStartI = 0;\n for (let i = 0; i < value.length; i++) {\n if (i == value.length - 1) {\n result.push(value.slice(tokenStartI));\n break;\n }\n if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\\s/)) {\n // We've hit a sentence break - i.e. a punctuation mark followed by whitespace.\n // We now want to push TWO tokens to the result:\n // 1. the sentence\n result.push(value.slice(tokenStartI, i + 1));\n // 2. the whitespace\n i = tokenStartI = i + 1;\n while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\\s/)) {\n i++;\n }\n result.push(value.slice(tokenStartI, i + 1));\n // Then the next token (a sentence) starts on the character after the whitespace.\n // (It's okay if this is off the end of the string - then the outer loop will terminate\n // here anyway.)\n tokenStartI = i + 1;\n }\n }\n return result;\n }\n}\nexport const sentenceDiff = new SentenceDiff();\nexport function diffSentences(oldStr, newStr, options) {\n return sentenceDiff.diff(oldStr, newStr, options);\n}\n","import Diff from './base.js';\nclass CssDiff extends Diff {\n tokenize(value) {\n return value.split(/([{}:;,]|\\s+)/);\n }\n}\nexport const cssDiff = new CssDiff();\nexport function diffCss(oldStr, newStr, options) {\n return cssDiff.diff(oldStr, newStr, options);\n}\n","import Diff from './base.js';\nimport { tokenize } from './line.js';\nclass JsonDiff extends Diff {\n constructor() {\n super(...arguments);\n this.tokenize = tokenize;\n }\n get useLongestToken() {\n // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a\n // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:\n return true;\n }\n castInput(value, options) {\n const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === 'undefined' ? undefinedReplacement : v } = options;\n return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, ' ');\n }\n equals(left, right, options) {\n return super.equals(left.replace(/,([\\r\\n])/g, '$1'), right.replace(/,([\\r\\n])/g, '$1'), options);\n }\n}\nexport const jsonDiff = new JsonDiff();\nexport function diffJson(oldStr, newStr, options) {\n return jsonDiff.diff(oldStr, newStr, options);\n}\n// This function handles the presence of circular references by bailing out when encountering an\n// object that is already on the \"stack\" of items being processed. Accepts an optional replacer\nexport function canonicalize(obj, stack, replacementStack, replacer, key) {\n stack = stack || [];\n replacementStack = replacementStack || [];\n if (replacer) {\n obj = replacer(key === undefined ? '' : key, obj);\n }\n let i;\n for (i = 0; i < stack.length; i += 1) {\n if (stack[i] === obj) {\n return replacementStack[i];\n }\n }\n let canonicalizedObj;\n if ('[object Array]' === Object.prototype.toString.call(obj)) {\n stack.push(obj);\n canonicalizedObj = new Array(obj.length);\n replacementStack.push(canonicalizedObj);\n for (i = 0; i < obj.length; i += 1) {\n canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));\n }\n stack.pop();\n replacementStack.pop();\n return canonicalizedObj;\n }\n if (obj && obj.toJSON) {\n obj = obj.toJSON();\n }\n if (typeof obj === 'object' && obj !== null) {\n stack.push(obj);\n canonicalizedObj = {};\n replacementStack.push(canonicalizedObj);\n const sortedKeys = [];\n let key;\n for (key in obj) {\n /* istanbul ignore else */\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n sortedKeys.push(key);\n }\n }\n sortedKeys.sort();\n for (i = 0; i < sortedKeys.length; i += 1) {\n key = sortedKeys[i];\n canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key);\n }\n stack.pop();\n replacementStack.pop();\n }\n else {\n canonicalizedObj = obj;\n }\n return canonicalizedObj;\n}\n","import Diff from './base.js';\nclass ArrayDiff extends Diff {\n tokenize(value) {\n return value.slice();\n }\n join(value) {\n return value;\n }\n removeEmpty(value) {\n return value;\n }\n}\nexport const arrayDiff = new ArrayDiff();\nexport function diffArrays(oldArr, newArr, options) {\n return arrayDiff.diff(oldArr, newArr, options);\n}\n","import { diffLines } from '../diff/line.js';\n/**\n * Returns true if the filename contains characters that require C-style\n * quoting (as used by Git and GNU diffutils in diff output).\n */\nfunction needsQuoting(s) {\n for (let i = 0; i < s.length; i++) {\n if (s[i] < '\\x20' || s[i] > '\\x7e' || s[i] === '\"' || s[i] === '\\\\') {\n return true;\n }\n }\n return false;\n}\n/**\n * C-style quotes a filename, encoding special characters as escape sequences\n * and non-ASCII bytes as octal escapes. This is the inverse of\n * `parseQuotedFileName` in parse.ts.\n *\n * Non-ASCII bytes are encoded as UTF-8 before being emitted as octal escapes.\n * This matches the behaviour of both Git and GNU diffutils, which always emit\n * UTF-8 octal escapes regardless of the underlying filesystem encoding (e.g.\n * Git for Windows converts from NTFS's UTF-16 to UTF-8 internally).\n *\n * If the filename doesn't need quoting, returns it as-is.\n */\nfunction quoteFileNameIfNeeded(s) {\n if (!needsQuoting(s)) {\n return s;\n }\n let result = '\"';\n const bytes = new TextEncoder().encode(s);\n let i = 0;\n while (i < bytes.length) {\n const b = bytes[i];\n // See https://en.wikipedia.org/wiki/Escape_sequences_in_C#Escape_sequences\n if (b === 0x07) {\n result += '\\\\a';\n }\n else if (b === 0x08) {\n result += '\\\\b';\n }\n else if (b === 0x09) {\n result += '\\\\t';\n }\n else if (b === 0x0a) {\n result += '\\\\n';\n }\n else if (b === 0x0b) {\n result += '\\\\v';\n }\n else if (b === 0x0c) {\n result += '\\\\f';\n }\n else if (b === 0x0d) {\n result += '\\\\r';\n }\n else if (b === 0x22) {\n result += '\\\\\"';\n }\n else if (b === 0x5c) {\n result += '\\\\\\\\';\n }\n else if (b >= 0x20 && b <= 0x7e) {\n // Just a printable ASCII character that is neither a double quote nor a\n // backslash; no need to escape it.\n result += String.fromCharCode(b);\n }\n else {\n // Either part of a non-ASCII character or a control character without a\n // special escape sequence; needs escaping as a 3-digit octal escape\n result += '\\\\' + b.toString(8).padStart(3, '0');\n }\n i++;\n }\n result += '\"';\n return result;\n}\nexport const INCLUDE_HEADERS = {\n includeIndex: true,\n includeUnderline: true,\n includeFileHeaders: true\n};\nexport const FILE_HEADERS_ONLY = {\n includeIndex: false,\n includeUnderline: false,\n includeFileHeaders: true\n};\nexport const OMIT_HEADERS = {\n includeIndex: false,\n includeUnderline: false,\n includeFileHeaders: false\n};\nexport function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {\n let optionsObj;\n if (!options) {\n optionsObj = {};\n }\n else if (typeof options === 'function') {\n optionsObj = { callback: options };\n }\n else {\n optionsObj = options;\n }\n if (typeof optionsObj.context === 'undefined') {\n optionsObj.context = 4;\n }\n // We copy this into its own variable to placate TypeScript, which thinks\n // optionsObj.context might be undefined in the callbacks below.\n const context = optionsObj.context;\n // @ts-expect-error (runtime check for something that is correctly a static type error)\n if (optionsObj.newlineIsToken) {\n throw new Error('newlineIsToken may not be used with patch-generation functions, only with diffing functions');\n }\n if (!optionsObj.callback) {\n return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));\n }\n else {\n const { callback } = optionsObj;\n diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {\n const patch = diffLinesResultToPatch(diff);\n // TypeScript is unhappy without the cast because it does not understand that `patch` may\n // be undefined here only if `callback` is StructuredPatchCallbackAbortable:\n callback(patch);\n } }));\n }\n function diffLinesResultToPatch(diff) {\n // STEP 1: Build up the patch with no \"\\" lines and with the arrays\n // of lines containing trailing newline characters. We'll tidy up later...\n if (!diff) {\n return;\n }\n diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier\n function contextLines(lines) {\n return lines.map(function (entry) { return ' ' + entry; });\n }\n const hunks = [];\n let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;\n for (let i = 0; i < diff.length; i++) {\n const current = diff[i], lines = current.lines || splitLines(current.value);\n current.lines = lines;\n if (current.added || current.removed) {\n // If we have previous context, start with that\n if (!oldRangeStart) {\n const prev = diff[i - 1];\n oldRangeStart = oldLine;\n newRangeStart = newLine;\n if (prev) {\n curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];\n oldRangeStart -= curRange.length;\n newRangeStart -= curRange.length;\n }\n }\n // Output our changes\n for (const line of lines) {\n curRange.push((current.added ? '+' : '-') + line);\n }\n // Track the updated file position\n if (current.added) {\n newLine += lines.length;\n }\n else {\n oldLine += lines.length;\n }\n }\n else {\n // Identical context lines. Track line changes\n if (oldRangeStart) {\n // Close out any changes that have been output (or join overlapping)\n if (lines.length <= context * 2 && i < diff.length - 2) {\n // Overlapping\n for (const line of contextLines(lines)) {\n curRange.push(line);\n }\n }\n else {\n // end the range and output\n const contextSize = Math.min(lines.length, context);\n for (const line of contextLines(lines.slice(0, contextSize))) {\n curRange.push(line);\n }\n const hunk = {\n oldStart: oldRangeStart,\n oldLines: (oldLine - oldRangeStart + contextSize),\n newStart: newRangeStart,\n newLines: (newLine - newRangeStart + contextSize),\n lines: curRange\n };\n hunks.push(hunk);\n oldRangeStart = 0;\n newRangeStart = 0;\n curRange = [];\n }\n }\n oldLine += lines.length;\n newLine += lines.length;\n }\n }\n // Step 2: eliminate the trailing `\\n` from each line of each hunk, and, where needed, add\n // \"\\".\n for (const hunk of hunks) {\n for (let i = 0; i < hunk.lines.length; i++) {\n if (hunk.lines[i].endsWith('\\n')) {\n hunk.lines[i] = hunk.lines[i].slice(0, -1);\n }\n else {\n hunk.lines.splice(i + 1, 0, '\\\');\n i++; // Skip the line we just added, then continue iterating\n }\n }\n }\n return {\n oldFileName: oldFileName, newFileName: newFileName,\n oldHeader: oldHeader, newHeader: newHeader,\n hunks: hunks\n };\n }\n}\n/**\n * creates a unified diff patch.\n *\n * @param patch either a single structured patch object (as returned by `structuredPatch`) or an\n * array of them (as returned by `parsePatch`).\n * @param headerOptions behaves the same as the `headerOptions` option of `createTwoFilesPatch`.\n * Ignored for patches where `isGit` is `true`.\n *\n * When a patch has `isGit: true`, `formatPatch` output is changed to more closely match Git's\n * output: it emits a `diff --git` header, emits Git extended headers as appropriate based on\n * properties like `isRename`, `isCreate`, `newMode`, etc, and will omit `---`/`+++` file\n * headers for patches with no hunks (e.g. renames without content changes).\n */\nexport function formatPatch(patch, headerOptions) {\n var _a, _b, _c, _d, _e, _f;\n if (!headerOptions) {\n headerOptions = INCLUDE_HEADERS;\n }\n if (Array.isArray(patch)) {\n if (patch.length > 1 && !headerOptions.includeFileHeaders && !patch.every(p => p.isGit)) {\n throw new Error('Cannot omit file headers on a multi-file patch. '\n + '(The result would be unparseable; how would a tool trying to apply '\n + 'the patch know which changes are to which file?)');\n }\n return patch.map(p => formatPatch(p, headerOptions)).join('\\n');\n }\n const ret = [];\n // Git patches have a fixed header format (diff --git, extended headers,\n // and ---/+++ when hunks are present), so headerOptions is ignored.\n if (patch.isGit) {\n headerOptions = INCLUDE_HEADERS;\n // Emit Git-style diff --git header and extended headers.\n // Git never puts /dev/null in the \"diff --git\" line; for file\n // creations/deletions it uses the real filename on both sides.\n if (!patch.oldFileName) {\n throw new Error('oldFileName must be specified for Git patches');\n }\n if (!patch.newFileName) {\n throw new Error('newFileName must be specified for Git patches');\n }\n let gitOldName = patch.oldFileName;\n let gitNewName = patch.newFileName;\n if (patch.isCreate && gitOldName === '/dev/null') {\n gitOldName = gitNewName.replace(/^b\\//, 'a/');\n }\n else if (patch.isDelete && gitNewName === '/dev/null') {\n gitNewName = gitOldName.replace(/^a\\//, 'b/');\n }\n ret.push('diff --git ' + quoteFileNameIfNeeded(gitOldName) + ' ' + quoteFileNameIfNeeded(gitNewName));\n if (patch.isDelete) {\n ret.push('deleted file mode ' + ((_a = patch.oldMode) !== null && _a !== void 0 ? _a : '100644'));\n }\n if (patch.isCreate) {\n ret.push('new file mode ' + ((_b = patch.newMode) !== null && _b !== void 0 ? _b : '100644'));\n }\n if (patch.oldMode && patch.newMode && !patch.isDelete && !patch.isCreate) {\n ret.push('old mode ' + patch.oldMode);\n ret.push('new mode ' + patch.newMode);\n }\n if (patch.isRename) {\n ret.push('rename from ' + quoteFileNameIfNeeded(((_c = patch.oldFileName) !== null && _c !== void 0 ? _c : '').replace(/^a\\//, '')));\n ret.push('rename to ' + quoteFileNameIfNeeded(((_d = patch.newFileName) !== null && _d !== void 0 ? _d : '').replace(/^b\\//, '')));\n }\n if (patch.isCopy) {\n ret.push('copy from ' + quoteFileNameIfNeeded(((_e = patch.oldFileName) !== null && _e !== void 0 ? _e : '').replace(/^a\\//, '')));\n ret.push('copy to ' + quoteFileNameIfNeeded(((_f = patch.newFileName) !== null && _f !== void 0 ? _f : '').replace(/^b\\//, '')));\n }\n }\n else {\n if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName && patch.oldFileName !== undefined) {\n ret.push('Index: ' + patch.oldFileName);\n }\n if (headerOptions.includeUnderline) {\n ret.push('===================================================================');\n }\n }\n // Emit --- / +++ file headers. For Git patches with no hunks (e.g.\n // pure renames, mode-only changes), Git omits these, so we do too.\n const hasHunks = patch.hunks.length > 0;\n if (headerOptions.includeFileHeaders && patch.oldFileName !== undefined && patch.newFileName !== undefined\n && (!patch.isGit || hasHunks)) {\n ret.push('--- ' + quoteFileNameIfNeeded(patch.oldFileName) + (patch.oldHeader ? '\\t' + patch.oldHeader : ''));\n ret.push('+++ ' + quoteFileNameIfNeeded(patch.newFileName) + (patch.newHeader ? '\\t' + patch.newHeader : ''));\n }\n for (let i = 0; i < patch.hunks.length; i++) {\n const hunk = patch.hunks[i];\n // Unified Diff Format quirk: If the chunk size is 0,\n // the first number is one lower than one would expect.\n // https://www.artima.com/weblogs/viewpost.jsp?thread=164293\n const oldStart = hunk.oldLines === 0 ? hunk.oldStart - 1 : hunk.oldStart;\n const newStart = hunk.newLines === 0 ? hunk.newStart - 1 : hunk.newStart;\n ret.push('@@ -' + oldStart + ',' + hunk.oldLines\n + ' +' + newStart + ',' + hunk.newLines\n + ' @@');\n for (const line of hunk.lines) {\n ret.push(line);\n }\n }\n return ret.join('\\n') + '\\n';\n}\nexport function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {\n if (typeof options === 'function') {\n options = { callback: options };\n }\n if (!(options === null || options === void 0 ? void 0 : options.callback)) {\n const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);\n if (!patchObj) {\n return;\n }\n return formatPatch(patchObj, options === null || options === void 0 ? void 0 : options.headerOptions);\n }\n else {\n const { callback } = options;\n structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: patchObj => {\n if (!patchObj) {\n callback(undefined);\n }\n else {\n callback(formatPatch(patchObj, options.headerOptions));\n }\n } }));\n }\n}\nexport function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {\n return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);\n}\n/**\n * Split `text` into an array of lines, including the trailing newline character (where present)\n */\nfunction splitLines(text) {\n const hasTrailingNl = text.endsWith('\\n');\n const result = text.split('\\n').map(line => line + '\\n');\n if (hasTrailingNl) {\n result.pop();\n }\n else {\n result.push(result.pop().slice(0, -1));\n }\n return result;\n}\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9],"mappings":";AAAA,IAAqB,OAArB,MAA0B;CACtB,KAAK,QAAQ,QAEb,UAAU,CAAC,GAAG;EACV,IAAI;EACJ,IAAI,OAAO,YAAY,YAAY;GAC/B,WAAW;GACX,UAAU,CAAC;EACf,OACK,IAAI,cAAc,SACnB,WAAW,QAAQ;EAGvB,MAAM,YAAY,KAAK,UAAU,QAAQ,OAAO;EAChD,MAAM,YAAY,KAAK,UAAU,QAAQ,OAAO;EAChD,MAAM,YAAY,KAAK,YAAY,KAAK,SAAS,WAAW,OAAO,CAAC;EACpE,MAAM,YAAY,KAAK,YAAY,KAAK,SAAS,WAAW,OAAO,CAAC;EACpE,OAAO,KAAK,mBAAmB,WAAW,WAAW,SAAS,QAAQ;CAC1E;CACA,mBAAmB,WAAW,WAAW,SAAS,UAAU;EACxD,IAAI;EACJ,MAAM,QAAQ,UAAU;GACpB,QAAQ,KAAK,YAAY,OAAO,OAAO;GACvC,IAAI,UAAU;IACV,WAAW,WAAY;KAAE,SAAS,KAAK;IAAG,GAAG,CAAC;IAC9C;GACJ,OAEI,OAAO;EAEf;EACA,MAAM,SAAS,UAAU,QAAQ,SAAS,UAAU;EACpD,IAAI,aAAa;EACjB,IAAI,gBAAgB,SAAS;EAC7B,IAAI,QAAQ,iBAAiB,MACzB,gBAAgB,KAAK,IAAI,eAAe,QAAQ,aAAa;EAEjE,MAAM,oBAAoB,KAAK,QAAQ,aAAa,QAAQ,OAAO,KAAK,IAAI,KAAK;EACj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AAK,OAAO,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC;CAEzC,OAAO;AACX"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
|
|
3
|
+
//#region ../dofs/dist/types.d.ts
|
|
4
|
+
interface SQLCursorLike<Row extends object = Record<string, unknown>> {
|
|
5
|
+
toArray(): Row[];
|
|
6
|
+
}
|
|
7
|
+
interface SQLStorageLike {
|
|
8
|
+
exec<Row extends object = Record<string, unknown>>(query: string, ...bindings: unknown[]): SQLCursorLike<Row>;
|
|
9
|
+
}
|
|
10
|
+
interface DurableObjectStorageLike {
|
|
11
|
+
sql: SQLStorageLike;
|
|
12
|
+
transaction?<T>(closure: () => T | Promise<T>): T | Promise<T>;
|
|
13
|
+
transactionSync?<T>(closure: () => T): T;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region ../dofs/dist/storage.d.ts
|
|
17
|
+
declare class Database {
|
|
18
|
+
#private;
|
|
19
|
+
readonly sql: SQLStorageLike;
|
|
20
|
+
readonly transactionSync: <T>(closure: () => T) => T;
|
|
21
|
+
constructor(storage: DurableObjectStorageLike);
|
|
22
|
+
run(query: string, ...bindings: unknown[]): void;
|
|
23
|
+
all<Row extends object>(query: string, ...bindings: unknown[]): Row[];
|
|
24
|
+
one<Row extends object>(query: string, ...bindings: unknown[]): Row | undefined;
|
|
25
|
+
scalar<T>(query: string, ...bindings: unknown[]): T | undefined;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region ../dofs/dist/fs/find.d.ts
|
|
29
|
+
interface WorkspaceFoundEntry {
|
|
30
|
+
path: string;
|
|
31
|
+
type: "file" | "dir";
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region ../dofs/dist/fs/grep.d.ts
|
|
35
|
+
interface WorkspaceGrepMatch {
|
|
36
|
+
path: string;
|
|
37
|
+
line: number;
|
|
38
|
+
text: string;
|
|
39
|
+
}
|
|
40
|
+
interface GrepOptions {
|
|
41
|
+
ignoreCase?: boolean;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region ../dofs/dist/fs/mkdir.d.ts
|
|
45
|
+
interface MkdirOptions {
|
|
46
|
+
recursive?: boolean;
|
|
47
|
+
mode?: number;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region ../dofs/dist/fs/readdir.d.ts
|
|
51
|
+
interface WorkspaceDirentResult {
|
|
52
|
+
name: string;
|
|
53
|
+
parentPath: string;
|
|
54
|
+
isFile: boolean;
|
|
55
|
+
isDirectory: boolean;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region ../dofs/dist/fs/readFile.d.ts
|
|
59
|
+
interface ReadFileOptions {
|
|
60
|
+
encoding?: "utf8";
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region ../dofs/dist/fs/rm.d.ts
|
|
64
|
+
interface RmOptions {
|
|
65
|
+
recursive?: boolean;
|
|
66
|
+
force?: boolean;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region ../dofs/dist/fs/stat.d.ts
|
|
70
|
+
interface WorkspaceStatResult {
|
|
71
|
+
name: string;
|
|
72
|
+
mode: number;
|
|
73
|
+
mtime: number;
|
|
74
|
+
size: number;
|
|
75
|
+
isFile: boolean;
|
|
76
|
+
isDirectory: boolean;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region ../dofs/dist/fs/writeFile.d.ts
|
|
80
|
+
type WriteFileContent = string | Uint8Array | ReadableStream<Uint8Array>;
|
|
81
|
+
interface WriteFileOptions {
|
|
82
|
+
mode?: number;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region ../dofs/dist/fs/filesystem.d.ts
|
|
86
|
+
interface WorkspaceFilesystemOptions {
|
|
87
|
+
now?: () => number;
|
|
88
|
+
}
|
|
89
|
+
declare class WorkspaceFilesystem {
|
|
90
|
+
readonly db: Database;
|
|
91
|
+
readonly now: () => number;
|
|
92
|
+
constructor(db: Database, options?: WorkspaceFilesystemOptions);
|
|
93
|
+
readFile(path: string): Promise<ReadableStream<Uint8Array>>;
|
|
94
|
+
readFile(path: string, encoding: "utf8"): Promise<string>;
|
|
95
|
+
readFile(path: string, options: ReadFileOptions): Promise<string | ReadableStream<Uint8Array>>;
|
|
96
|
+
stat(path: string): Promise<WorkspaceStatResult>;
|
|
97
|
+
readdir(path: string): Promise<WorkspaceDirentResult[]>;
|
|
98
|
+
find(directory: string, pattern?: string): Promise<WorkspaceFoundEntry[]>;
|
|
99
|
+
ls(prefix: string): Promise<string[]>;
|
|
100
|
+
grep(pattern: string, path: string, options?: GrepOptions): Promise<WorkspaceGrepMatch[]>;
|
|
101
|
+
writeFile(path: string, content: WriteFileContent, options?: WriteFileOptions): Promise<void>;
|
|
102
|
+
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
103
|
+
rm(path: string, options?: RmOptions): Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region ../dofs/dist/fs/watch.d.ts
|
|
107
|
+
interface WatchOptions {
|
|
108
|
+
recursive?: boolean;
|
|
109
|
+
signal?: AbortSignal;
|
|
110
|
+
interval?: number;
|
|
111
|
+
}
|
|
112
|
+
interface WatchEvent {
|
|
113
|
+
eventType: "rename" | "change";
|
|
114
|
+
filename: string;
|
|
115
|
+
}
|
|
116
|
+
interface WatchHandle extends EventEmitter {
|
|
117
|
+
close(): void;
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region ../dofs/dist/provider.d.ts
|
|
121
|
+
interface SQLiteWorkspaceProviderOptions {
|
|
122
|
+
now?: () => number;
|
|
123
|
+
watchIntervalMs?: number;
|
|
124
|
+
}
|
|
125
|
+
interface VirtualStatsLike {
|
|
126
|
+
dev: number;
|
|
127
|
+
mode: number;
|
|
128
|
+
nlink: number;
|
|
129
|
+
uid: number;
|
|
130
|
+
gid: number;
|
|
131
|
+
rdev: number;
|
|
132
|
+
blksize: number;
|
|
133
|
+
ino: number;
|
|
134
|
+
size: number;
|
|
135
|
+
blocks: number;
|
|
136
|
+
atimeMs: number;
|
|
137
|
+
mtimeMs: number;
|
|
138
|
+
ctimeMs: number;
|
|
139
|
+
birthtimeMs: number;
|
|
140
|
+
atime: Date;
|
|
141
|
+
mtime: Date;
|
|
142
|
+
ctime: Date;
|
|
143
|
+
birthtime: Date;
|
|
144
|
+
isFile(): boolean;
|
|
145
|
+
isDirectory(): boolean;
|
|
146
|
+
isSymbolicLink(): boolean;
|
|
147
|
+
isBlockDevice(): boolean;
|
|
148
|
+
isCharacterDevice(): boolean;
|
|
149
|
+
isFIFO(): boolean;
|
|
150
|
+
isSocket(): boolean;
|
|
151
|
+
}
|
|
152
|
+
interface VirtualDirentLike {
|
|
153
|
+
name: string;
|
|
154
|
+
parentPath: string;
|
|
155
|
+
path: string;
|
|
156
|
+
isFile(): boolean;
|
|
157
|
+
isDirectory(): boolean;
|
|
158
|
+
isSymbolicLink(): boolean;
|
|
159
|
+
isBlockDevice(): boolean;
|
|
160
|
+
isCharacterDevice(): boolean;
|
|
161
|
+
isFIFO(): boolean;
|
|
162
|
+
isSocket(): boolean;
|
|
163
|
+
}
|
|
164
|
+
declare class SQLiteWorkspaceProvider {
|
|
165
|
+
#private;
|
|
166
|
+
readonly db: Database;
|
|
167
|
+
readonly now: () => number;
|
|
168
|
+
readonly readonly = false;
|
|
169
|
+
readonly supportsSymlinks = true;
|
|
170
|
+
readonly supportsWatch = true;
|
|
171
|
+
readonly watchIntervalMs: number;
|
|
172
|
+
constructor(db: Database, options?: SQLiteWorkspaceProviderOptions);
|
|
173
|
+
open(path: string, flags?: string, mode?: number): Promise<number>;
|
|
174
|
+
openSync(path: string, flags?: string, _mode?: number): number;
|
|
175
|
+
stat(path: string, options?: {
|
|
176
|
+
bigint?: boolean;
|
|
177
|
+
}): Promise<VirtualStatsLike>;
|
|
178
|
+
statSync(path: string, _options?: {
|
|
179
|
+
bigint?: boolean;
|
|
180
|
+
}): VirtualStatsLike;
|
|
181
|
+
lstat(path: string, options?: {
|
|
182
|
+
bigint?: boolean;
|
|
183
|
+
}): Promise<VirtualStatsLike>;
|
|
184
|
+
lstatSync(path: string, _options?: {
|
|
185
|
+
bigint?: boolean;
|
|
186
|
+
}): VirtualStatsLike;
|
|
187
|
+
readdir(path: string, options?: {
|
|
188
|
+
withFileTypes?: boolean;
|
|
189
|
+
}): Promise<string[] | VirtualDirentLike[]>;
|
|
190
|
+
readdirSync(path: string, options?: {
|
|
191
|
+
withFileTypes?: boolean;
|
|
192
|
+
}): string[] | VirtualDirentLike[];
|
|
193
|
+
mkdir(path: string, options?: MkdirOptions): Promise<string | undefined>;
|
|
194
|
+
mkdirSync(path: string, options?: MkdirOptions): string | undefined;
|
|
195
|
+
rmdir(path: string): Promise<void>;
|
|
196
|
+
rmdirSync(path: string): void;
|
|
197
|
+
unlink(path: string): Promise<void>;
|
|
198
|
+
unlinkSync(path: string): void;
|
|
199
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
200
|
+
renameSync(oldPath: string, newPath: string): void;
|
|
201
|
+
readFile(path: string, options?: BufferEncoding | {
|
|
202
|
+
encoding?: BufferEncoding | null;
|
|
203
|
+
} | null): Promise<Buffer | string>;
|
|
204
|
+
readFileSync(path: string, options?: BufferEncoding | {
|
|
205
|
+
encoding?: BufferEncoding | null;
|
|
206
|
+
} | null): Buffer | string;
|
|
207
|
+
writeFile(path: string, data: string | Buffer, options?: {
|
|
208
|
+
encoding?: BufferEncoding;
|
|
209
|
+
mode?: number;
|
|
210
|
+
} | BufferEncoding): Promise<void>;
|
|
211
|
+
writeFileSync(path: string, data: string | Buffer, options?: {
|
|
212
|
+
encoding?: BufferEncoding;
|
|
213
|
+
mode?: number;
|
|
214
|
+
} | BufferEncoding): void;
|
|
215
|
+
appendFile(_path: string, _data: string | Buffer, _options?: {
|
|
216
|
+
encoding?: BufferEncoding;
|
|
217
|
+
mode?: number;
|
|
218
|
+
} | BufferEncoding): Promise<void>;
|
|
219
|
+
appendFileSync(_path: string, _data: string | Buffer, _options?: {
|
|
220
|
+
encoding?: BufferEncoding;
|
|
221
|
+
mode?: number;
|
|
222
|
+
} | BufferEncoding): void;
|
|
223
|
+
exists(path: string): Promise<boolean>;
|
|
224
|
+
existsSync(path: string): boolean;
|
|
225
|
+
copyFile(_src: string, _dest: string, _mode?: number): Promise<void>;
|
|
226
|
+
copyFileSync(_src: string, _dest: string, _mode?: number): void;
|
|
227
|
+
internalModuleStat(_path: string): number;
|
|
228
|
+
realpath(path: string, _options?: {
|
|
229
|
+
encoding?: BufferEncoding;
|
|
230
|
+
}): Promise<string>;
|
|
231
|
+
realpathSync(path: string, _options?: {
|
|
232
|
+
encoding?: BufferEncoding;
|
|
233
|
+
}): string;
|
|
234
|
+
access(path: string, _mode?: number): Promise<void>;
|
|
235
|
+
accessSync(path: string, _mode?: number): void;
|
|
236
|
+
closeSync(fd: number): void;
|
|
237
|
+
readSync(fd: number, buffer: Buffer | Uint8Array, offset: number, length: number, position: number | null): number;
|
|
238
|
+
writeSync(fd: number, buffer: Buffer | Uint8Array, offset?: number, length?: number, position?: number | null): number;
|
|
239
|
+
fstatSync(fd: number, _options?: {
|
|
240
|
+
bigint?: boolean;
|
|
241
|
+
}): VirtualStatsLike;
|
|
242
|
+
truncateSync(path: string, len: number): void;
|
|
243
|
+
ftruncateSync(fd: number, len: number): void;
|
|
244
|
+
readlink(path: string, _options?: {
|
|
245
|
+
encoding?: BufferEncoding;
|
|
246
|
+
}): Promise<string>;
|
|
247
|
+
readlinkSync(path: string, _options?: {
|
|
248
|
+
encoding?: BufferEncoding;
|
|
249
|
+
}): string;
|
|
250
|
+
symlink(target: string, path: string, _type?: string): Promise<void>;
|
|
251
|
+
symlinkSync(target: string, path: string, _type?: string): void;
|
|
252
|
+
watch(path: string, options?: WatchOptions): WatchHandle;
|
|
253
|
+
watchAsync(path: string, options?: WatchOptions): AsyncIterable<WatchEvent>;
|
|
254
|
+
watchFile(_path: string, _options?: unknown, _listener?: (curr: VirtualStatsLike, prev: VirtualStatsLike) => void): unknown;
|
|
255
|
+
unwatchFile(_path: string, _listener?: (curr: VirtualStatsLike, prev: VirtualStatsLike) => void): void;
|
|
256
|
+
}
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region ../dofs/dist/sync/changes.d.ts
|
|
259
|
+
type ChangeEntry = {
|
|
260
|
+
kind: "file";
|
|
261
|
+
rev: number;
|
|
262
|
+
path: string;
|
|
263
|
+
mode: number;
|
|
264
|
+
mtime: number;
|
|
265
|
+
size: number;
|
|
266
|
+
chunks: {
|
|
267
|
+
hash: Uint8Array;
|
|
268
|
+
size: number;
|
|
269
|
+
}[];
|
|
270
|
+
} | {
|
|
271
|
+
kind: "dir";
|
|
272
|
+
rev: number;
|
|
273
|
+
path: string;
|
|
274
|
+
mode: number;
|
|
275
|
+
mtime: number;
|
|
276
|
+
} | {
|
|
277
|
+
kind: "symlink";
|
|
278
|
+
rev: number;
|
|
279
|
+
path: string;
|
|
280
|
+
target: string;
|
|
281
|
+
mode: number;
|
|
282
|
+
mtime: number;
|
|
283
|
+
} | {
|
|
284
|
+
kind: "delete";
|
|
285
|
+
rev: number;
|
|
286
|
+
path: string;
|
|
287
|
+
};
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region ../dofs/dist/sync/apply.d.ts
|
|
290
|
+
interface SkippedEntry {
|
|
291
|
+
path: string;
|
|
292
|
+
mountRoot: string;
|
|
293
|
+
op: "write" | "delete";
|
|
294
|
+
reason: "read-only";
|
|
295
|
+
}
|
|
296
|
+
interface ApplyResult {
|
|
297
|
+
applied: number;
|
|
298
|
+
skipped: SkippedEntry[];
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
export { Database as _, SQLiteWorkspaceProviderOptions as a, WriteFileOptions as c, ReadFileOptions as d, WorkspaceDirentResult as f, WorkspaceFoundEntry as g, WorkspaceGrepMatch as h, SQLiteWorkspaceProvider as i, WorkspaceStatResult as l, GrepOptions as m, SkippedEntry as n, WorkspaceFilesystem as o, MkdirOptions as p, ChangeEntry as r, WriteFileContent as s, ApplyResult as t, RmOptions as u, DurableObjectStorageLike as v };
|
|
302
|
+
//# sourceMappingURL=shared-RIdME5uo.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cloudflare/workspace",
|
|
3
|
+
"version": "0.0.0-alpha.0",
|
|
4
|
+
"description": "Cloudflare Workspace — a SQLite-backed virtual filesystem with sync to a container-side daemon (wsd).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"directory": "packages/workspace",
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/cloudflare/workspace.git"
|
|
10
|
+
},
|
|
11
|
+
"private": false,
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./git": {
|
|
19
|
+
"types": "./dist/git.d.ts",
|
|
20
|
+
"import": "./dist/git.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "rolldown -c",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
32
|
+
"test": "vitest run && vitest run --config vitest.config.proxy.ts && vitest run --config vitest.config.stub-soak.ts",
|
|
33
|
+
"test:stub-soak": "vitest run --config vitest.config.stub-soak.ts",
|
|
34
|
+
"test:harness": "./test-harness/run-harness.sh",
|
|
35
|
+
"bench:harness": "./test-harness/run-harness.sh bench",
|
|
36
|
+
"prepublishOnly": "npm run build && npm test"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"capnweb": "^0.8.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@platformatic/vfs": "*",
|
|
43
|
+
"diff": "^9.0.0",
|
|
44
|
+
"isomorphic-git": "^1.27.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"@platformatic/vfs": {
|
|
48
|
+
"optional": true
|
|
49
|
+
},
|
|
50
|
+
"diff": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"isomorphic-git": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@cloudflare/dofs": "*",
|
|
59
|
+
"@cloudflare/vitest-pool-workers": "^0.16.10",
|
|
60
|
+
"@cloudflare/workers-types": "^4.20250529.0",
|
|
61
|
+
"@cloudflare/workspace-rpc": "*",
|
|
62
|
+
"@platformatic/vfs": "^0.4.0",
|
|
63
|
+
"diff": "^9.0.0",
|
|
64
|
+
"isomorphic-git": "^1.38.3",
|
|
65
|
+
"memfs": "^4.57.6",
|
|
66
|
+
"rolldown": "^1.0.2",
|
|
67
|
+
"rolldown-plugin-dts": "^0.25.2",
|
|
68
|
+
"typescript": "^6.0.3",
|
|
69
|
+
"vitest": "^4.1.7",
|
|
70
|
+
"wrangler": "^4.95.0"
|
|
71
|
+
}
|
|
72
|
+
}
|