@kubohiroya/turbowarp-plus-editor-git 0.0.0-stage → 0.8.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/LICENSE +373 -0
- package/README.ja.md +121 -0
- package/README.md +43 -2
- package/THIRD_PARTY_NOTICES.md +5 -0
- package/dist/THIRD_PARTY_NOTICES.md +1186 -0
- package/dist/block-diff-location.d.ts +22 -0
- package/dist/block-diff-preview.d.ts +33 -0
- package/dist/browser.d.ts +4 -0
- package/dist/connection-settings.d.ts +35 -0
- package/dist/file-diff-view.d.ts +18 -0
- package/dist/filesystem.d.ts +89 -0
- package/dist/github-pull-requests.d.ts +38 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +3563 -0
- package/dist/messages.d.ts +112 -0
- package/dist/mutation-fs.d.ts +58 -0
- package/dist/objectSpread2-Dkd68nJH.js +101 -0
- package/dist/project-asset-paths-KV715791.js +761 -0
- package/dist/project-asset-paths.d.ts +12 -0
- package/dist/project-assets.d.ts +19 -0
- package/dist/project-source-diff.d.ts +26 -0
- package/dist/project-source-diff.js +172 -0
- package/dist/project-source-patch.d.ts +39 -0
- package/dist/project-source-review-model.d.ts +23 -0
- package/dist/project-source-review.d.ts +38 -0
- package/dist/pull-request-panel.d.ts +8 -0
- package/dist/remote-operations.d.ts +5 -0
- package/dist/repository-BQkADJmK.js +17280 -0
- package/dist/repository.d.ts +71 -0
- package/dist/repository.js +1 -0
- package/dist/scratch-block-diff-renderer-xS8OYsRl.js +1830 -0
- package/dist/scratch-block-diff-renderer.d.ts +128 -0
- package/dist/smart-http-BmHEkE7K.js +303 -0
- package/dist/smart-http.d.ts +60 -0
- package/dist/smart-http.js +1 -0
- package/dist/style.css +138 -0
- package/package.json +65 -4
- package/src/block-diff-location.ts +63 -0
- package/src/block-diff-preview.tsx +117 -0
- package/src/browser.ts +5 -0
- package/src/connection-settings.tsx +103 -0
- package/src/file-diff-view.tsx +44 -0
- package/src/filesystem.ts +125 -0
- package/src/github-pull-requests.ts +229 -0
- package/src/index.tsx +352 -0
- package/src/messages.ts +64 -0
- package/src/mutation-fs.ts +204 -0
- package/src/project-asset-paths.ts +33 -0
- package/src/project-assets.ts +66 -0
- package/src/project-source-diff.css +108 -0
- package/src/project-source-diff.tsx +139 -0
- package/src/project-source-patch.ts +126 -0
- package/src/project-source-review-model.ts +116 -0
- package/src/project-source-review.tsx +250 -0
- package/src/pull-request-panel.tsx +134 -0
- package/src/remote-operations.ts +90 -0
- package/src/repository.ts +364 -0
- package/src/scratch-block-diff-renderer.ts +331 -0
- package/src/smart-http.ts +190 -0
- package/src/style.css +29 -0
- package/src/styles.d.ts +1 -0
- package/tsconfig.json +18 -0
- package/vite.config.ts +26 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3563 @@
|
|
|
1
|
+
import { a as gitHubRepositoryFromOrigin, i as createGitHubPullRequests, o as ProjectSourceComparison, r as PullRequestError, s as ProjectSourceReview, t as createScratchBlocksDiffRenderer } from "./scratch-block-diff-renderer-xS8OYsRl.js";
|
|
2
|
+
import { n as init_objectSpread2, r as __commonJSMin, t as _objectSpread2$1 } from "./objectSpread2-Dkd68nJH.js";
|
|
3
|
+
import { n as GitPanelError, r as createReadOnlyFs, t as openRepository } from "./repository-BQkADJmK.js";
|
|
4
|
+
import * as m from "react";
|
|
5
|
+
import React, { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { render, unmountComponentAtNode } from "react-dom";
|
|
7
|
+
// builtin:esm-external-require-react
|
|
8
|
+
var require_builtin_esm_external_require_react = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9
|
+
init_objectSpread2();
|
|
10
|
+
module.exports = Object.prototype.hasOwnProperty.call(m, "module.exports") ? m["module.exports"] : _objectSpread2$1({}, m);
|
|
11
|
+
}));
|
|
12
|
+
// node_modules/react/cjs/react-jsx-runtime.production.min.js
|
|
13
|
+
/** @license React v16.14.0
|
|
14
|
+
* react-jsx-runtime.production.min.js
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
17
|
+
*
|
|
18
|
+
* This source code is licensed under the MIT license found in the
|
|
19
|
+
* LICENSE file in the root directory of this source tree.
|
|
20
|
+
*/
|
|
21
|
+
var require_react_jsx_runtime_production_min = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
22
|
+
var f = require_builtin_esm_external_require_react();
|
|
23
|
+
var g = 60103;
|
|
24
|
+
exports.Fragment = 60107;
|
|
25
|
+
if ("function" === typeof Symbol && Symbol.for) {
|
|
26
|
+
var h = Symbol.for;
|
|
27
|
+
g = h("react.element");
|
|
28
|
+
exports.Fragment = h("react.fragment");
|
|
29
|
+
}
|
|
30
|
+
var m = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner;
|
|
31
|
+
var n = Object.prototype.hasOwnProperty;
|
|
32
|
+
var p = {
|
|
33
|
+
key: !0,
|
|
34
|
+
ref: !0,
|
|
35
|
+
__self: !0,
|
|
36
|
+
__source: !0
|
|
37
|
+
};
|
|
38
|
+
function q(c, a, k) {
|
|
39
|
+
var b, d = {}, e = null, l = null;
|
|
40
|
+
void 0 !== k && (e = "" + k);
|
|
41
|
+
void 0 !== a.key && (e = "" + a.key);
|
|
42
|
+
void 0 !== a.ref && (l = a.ref);
|
|
43
|
+
for (b in a) n.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
44
|
+
if (c && c.defaultProps) for (b in a = c.defaultProps, a) void 0 === d[b] && (d[b] = a[b]);
|
|
45
|
+
return {
|
|
46
|
+
$$typeof: g,
|
|
47
|
+
type: c,
|
|
48
|
+
key: e,
|
|
49
|
+
ref: l,
|
|
50
|
+
props: d,
|
|
51
|
+
_owner: m.current
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.jsx = q;
|
|
55
|
+
exports.jsxs = q;
|
|
56
|
+
}));
|
|
57
|
+
// node_modules/react/cjs/react-jsx-runtime.development.js
|
|
58
|
+
/** @license React v16.14.0
|
|
59
|
+
* react-jsx-runtime.development.js
|
|
60
|
+
*
|
|
61
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
62
|
+
*
|
|
63
|
+
* This source code is licensed under the MIT license found in the
|
|
64
|
+
* LICENSE file in the root directory of this source tree.
|
|
65
|
+
*/
|
|
66
|
+
var require_react_jsx_runtime_development = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
67
|
+
if (process.env.NODE_ENV !== "production") (function() {
|
|
68
|
+
"use strict";
|
|
69
|
+
var React = require_builtin_esm_external_require_react();
|
|
70
|
+
var REACT_ELEMENT_TYPE = 60103;
|
|
71
|
+
var REACT_PORTAL_TYPE = 60106;
|
|
72
|
+
exports.Fragment = 60107;
|
|
73
|
+
var REACT_STRICT_MODE_TYPE = 60108;
|
|
74
|
+
var REACT_PROFILER_TYPE = 60114;
|
|
75
|
+
var REACT_PROVIDER_TYPE = 60109;
|
|
76
|
+
var REACT_CONTEXT_TYPE = 60110;
|
|
77
|
+
var REACT_FORWARD_REF_TYPE = 60112;
|
|
78
|
+
var REACT_SUSPENSE_TYPE = 60113;
|
|
79
|
+
var REACT_SUSPENSE_LIST_TYPE = 60120;
|
|
80
|
+
var REACT_MEMO_TYPE = 60115;
|
|
81
|
+
var REACT_LAZY_TYPE = 60116;
|
|
82
|
+
var REACT_BLOCK_TYPE = 60121;
|
|
83
|
+
var REACT_SERVER_BLOCK_TYPE = 60122;
|
|
84
|
+
var REACT_FUNDAMENTAL_TYPE = 60117;
|
|
85
|
+
var REACT_DEBUG_TRACING_MODE_TYPE = 60129;
|
|
86
|
+
var REACT_LEGACY_HIDDEN_TYPE = 60131;
|
|
87
|
+
if (typeof Symbol === "function" && Symbol.for) {
|
|
88
|
+
var symbolFor = Symbol.for;
|
|
89
|
+
REACT_ELEMENT_TYPE = symbolFor("react.element");
|
|
90
|
+
REACT_PORTAL_TYPE = symbolFor("react.portal");
|
|
91
|
+
exports.Fragment = symbolFor("react.fragment");
|
|
92
|
+
REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode");
|
|
93
|
+
REACT_PROFILER_TYPE = symbolFor("react.profiler");
|
|
94
|
+
REACT_PROVIDER_TYPE = symbolFor("react.provider");
|
|
95
|
+
REACT_CONTEXT_TYPE = symbolFor("react.context");
|
|
96
|
+
REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref");
|
|
97
|
+
REACT_SUSPENSE_TYPE = symbolFor("react.suspense");
|
|
98
|
+
REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list");
|
|
99
|
+
REACT_MEMO_TYPE = symbolFor("react.memo");
|
|
100
|
+
REACT_LAZY_TYPE = symbolFor("react.lazy");
|
|
101
|
+
REACT_BLOCK_TYPE = symbolFor("react.block");
|
|
102
|
+
REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block");
|
|
103
|
+
REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental");
|
|
104
|
+
symbolFor("react.scope");
|
|
105
|
+
symbolFor("react.opaque.id");
|
|
106
|
+
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode");
|
|
107
|
+
symbolFor("react.offscreen");
|
|
108
|
+
REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
|
|
109
|
+
}
|
|
110
|
+
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
|
|
111
|
+
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
|
112
|
+
function getIteratorFn(maybeIterable) {
|
|
113
|
+
if (maybeIterable === null || typeof maybeIterable !== "object") return null;
|
|
114
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
115
|
+
if (typeof maybeIterator === "function") return maybeIterator;
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
119
|
+
function error(format) {
|
|
120
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) args[_key2 - 1] = arguments[_key2];
|
|
121
|
+
printWarning("error", format, args);
|
|
122
|
+
}
|
|
123
|
+
function printWarning(level, format, args) {
|
|
124
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
125
|
+
var stack = "";
|
|
126
|
+
if (currentlyValidatingElement) {
|
|
127
|
+
var name = getComponentName(currentlyValidatingElement.type);
|
|
128
|
+
var owner = currentlyValidatingElement._owner;
|
|
129
|
+
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
130
|
+
}
|
|
131
|
+
stack += ReactDebugCurrentFrame.getStackAddendum();
|
|
132
|
+
if (stack !== "") {
|
|
133
|
+
format += "%s";
|
|
134
|
+
args = args.concat([stack]);
|
|
135
|
+
}
|
|
136
|
+
var argsWithFormat = args.map(function(item) {
|
|
137
|
+
return "" + item;
|
|
138
|
+
});
|
|
139
|
+
argsWithFormat.unshift("Warning: " + format);
|
|
140
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
141
|
+
}
|
|
142
|
+
var enableScopeAPI = false;
|
|
143
|
+
function isValidElementType(type) {
|
|
144
|
+
if (typeof type === "string" || typeof type === "function") return true;
|
|
145
|
+
if (type === exports.Fragment || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI) return true;
|
|
146
|
+
if (typeof type === "object" && type !== null) {
|
|
147
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) return true;
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
152
|
+
function describeComponentFrame(name, source, ownerName) {
|
|
153
|
+
var sourceInfo = "";
|
|
154
|
+
if (source) {
|
|
155
|
+
var path = source.fileName;
|
|
156
|
+
var fileName = path.replace(BEFORE_SLASH_RE, "");
|
|
157
|
+
if (/^index\./.test(fileName)) {
|
|
158
|
+
var match = path.match(BEFORE_SLASH_RE);
|
|
159
|
+
if (match) {
|
|
160
|
+
var pathBeforeSlash = match[1];
|
|
161
|
+
if (pathBeforeSlash) fileName = pathBeforeSlash.replace(BEFORE_SLASH_RE, "") + "/" + fileName;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")";
|
|
165
|
+
} else if (ownerName) sourceInfo = " (created by " + ownerName + ")";
|
|
166
|
+
return "\n in " + (name || "Unknown") + sourceInfo;
|
|
167
|
+
}
|
|
168
|
+
var Resolved = 1;
|
|
169
|
+
function refineResolvedLazyComponent(lazyComponent) {
|
|
170
|
+
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
|
171
|
+
}
|
|
172
|
+
function getWrappedName(outerType, innerType, wrapperName) {
|
|
173
|
+
var functionName = innerType.displayName || innerType.name || "";
|
|
174
|
+
return outerType.displayName || (functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
175
|
+
}
|
|
176
|
+
function getComponentName(type) {
|
|
177
|
+
if (type == null) return null;
|
|
178
|
+
if (typeof type.tag === "number") error("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue.");
|
|
179
|
+
if (typeof type === "function") return type.displayName || type.name || null;
|
|
180
|
+
if (typeof type === "string") return type;
|
|
181
|
+
switch (type) {
|
|
182
|
+
case exports.Fragment: return "Fragment";
|
|
183
|
+
case REACT_PORTAL_TYPE: return "Portal";
|
|
184
|
+
case REACT_PROFILER_TYPE: return "Profiler";
|
|
185
|
+
case REACT_STRICT_MODE_TYPE: return "StrictMode";
|
|
186
|
+
case REACT_SUSPENSE_TYPE: return "Suspense";
|
|
187
|
+
case REACT_SUSPENSE_LIST_TYPE: return "SuspenseList";
|
|
188
|
+
}
|
|
189
|
+
if (typeof type === "object") switch (type.$$typeof) {
|
|
190
|
+
case REACT_CONTEXT_TYPE: return "Context.Consumer";
|
|
191
|
+
case REACT_PROVIDER_TYPE: return "Context.Provider";
|
|
192
|
+
case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef");
|
|
193
|
+
case REACT_MEMO_TYPE: return getComponentName(type.type);
|
|
194
|
+
case REACT_BLOCK_TYPE: return getComponentName(type.render);
|
|
195
|
+
case REACT_LAZY_TYPE:
|
|
196
|
+
var resolvedThenable = refineResolvedLazyComponent(type);
|
|
197
|
+
if (resolvedThenable) return getComponentName(resolvedThenable);
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
var loggedTypeFailures = {};
|
|
202
|
+
ReactSharedInternals.ReactDebugCurrentFrame;
|
|
203
|
+
var currentlyValidatingElement = null;
|
|
204
|
+
function setCurrentlyValidatingElement(element) {
|
|
205
|
+
currentlyValidatingElement = element;
|
|
206
|
+
}
|
|
207
|
+
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
208
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
209
|
+
for (var typeSpecName in typeSpecs) if (has(typeSpecs, typeSpecName)) {
|
|
210
|
+
var error$1 = void 0;
|
|
211
|
+
try {
|
|
212
|
+
if (typeof typeSpecs[typeSpecName] !== "function") {
|
|
213
|
+
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
214
|
+
err.name = "Invariant Violation";
|
|
215
|
+
throw err;
|
|
216
|
+
}
|
|
217
|
+
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
218
|
+
} catch (ex) {
|
|
219
|
+
error$1 = ex;
|
|
220
|
+
}
|
|
221
|
+
if (error$1 && !(error$1 instanceof Error)) {
|
|
222
|
+
setCurrentlyValidatingElement(element);
|
|
223
|
+
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
|
|
224
|
+
setCurrentlyValidatingElement(null);
|
|
225
|
+
}
|
|
226
|
+
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
227
|
+
loggedTypeFailures[error$1.message] = true;
|
|
228
|
+
setCurrentlyValidatingElement(element);
|
|
229
|
+
error("Failed %s type: %s", location, error$1.message);
|
|
230
|
+
setCurrentlyValidatingElement(null);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
235
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
236
|
+
var RESERVED_PROPS = {
|
|
237
|
+
key: true,
|
|
238
|
+
ref: true,
|
|
239
|
+
__self: true,
|
|
240
|
+
__source: true
|
|
241
|
+
};
|
|
242
|
+
var specialPropKeyWarningShown;
|
|
243
|
+
var specialPropRefWarningShown;
|
|
244
|
+
var didWarnAboutStringRefs = {};
|
|
245
|
+
function hasValidRef(config) {
|
|
246
|
+
if (hasOwnProperty.call(config, "ref")) {
|
|
247
|
+
var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
|
|
248
|
+
if (getter && getter.isReactWarning) return false;
|
|
249
|
+
}
|
|
250
|
+
return config.ref !== void 0;
|
|
251
|
+
}
|
|
252
|
+
function hasValidKey(config) {
|
|
253
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
254
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
255
|
+
if (getter && getter.isReactWarning) return false;
|
|
256
|
+
}
|
|
257
|
+
return config.key !== void 0;
|
|
258
|
+
}
|
|
259
|
+
function warnIfStringRefCannotBeAutoConverted(config, self) {
|
|
260
|
+
if (typeof config.ref === "string" && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
|
|
261
|
+
var componentName = getComponentName(ReactCurrentOwner.current.type);
|
|
262
|
+
if (!didWarnAboutStringRefs[componentName]) {
|
|
263
|
+
error("Component \"%s\" contains the string ref \"%s\". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref", getComponentName(ReactCurrentOwner.current.type), config.ref);
|
|
264
|
+
didWarnAboutStringRefs[componentName] = true;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
269
|
+
var warnAboutAccessingKey = function() {
|
|
270
|
+
if (!specialPropKeyWarningShown) {
|
|
271
|
+
specialPropKeyWarningShown = true;
|
|
272
|
+
error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
276
|
+
Object.defineProperty(props, "key", {
|
|
277
|
+
get: warnAboutAccessingKey,
|
|
278
|
+
configurable: true
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
function defineRefPropWarningGetter(props, displayName) {
|
|
282
|
+
var warnAboutAccessingRef = function() {
|
|
283
|
+
if (!specialPropRefWarningShown) {
|
|
284
|
+
specialPropRefWarningShown = true;
|
|
285
|
+
error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
warnAboutAccessingRef.isReactWarning = true;
|
|
289
|
+
Object.defineProperty(props, "ref", {
|
|
290
|
+
get: warnAboutAccessingRef,
|
|
291
|
+
configurable: true
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Factory method to create a new React element. This no longer adheres to
|
|
296
|
+
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
297
|
+
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
298
|
+
* if something is a React Element.
|
|
299
|
+
*
|
|
300
|
+
* @param {*} type
|
|
301
|
+
* @param {*} props
|
|
302
|
+
* @param {*} key
|
|
303
|
+
* @param {string|object} ref
|
|
304
|
+
* @param {*} owner
|
|
305
|
+
* @param {*} self A *temporary* helper to detect places where `this` is
|
|
306
|
+
* different from the `owner` when React.createElement is called, so that we
|
|
307
|
+
* can warn. We want to get rid of owner and replace string `ref`s with arrow
|
|
308
|
+
* functions, and as long as `this` and owner are the same, there will be no
|
|
309
|
+
* change in behavior.
|
|
310
|
+
* @param {*} source An annotation object (added by a transpiler or otherwise)
|
|
311
|
+
* indicating filename, line number, and/or other information.
|
|
312
|
+
* @internal
|
|
313
|
+
*/
|
|
314
|
+
var ReactElement = function(type, key, ref, self, source, owner, props) {
|
|
315
|
+
var element = {
|
|
316
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
317
|
+
type,
|
|
318
|
+
key,
|
|
319
|
+
ref,
|
|
320
|
+
props,
|
|
321
|
+
_owner: owner
|
|
322
|
+
};
|
|
323
|
+
element._store = {};
|
|
324
|
+
Object.defineProperty(element._store, "validated", {
|
|
325
|
+
configurable: false,
|
|
326
|
+
enumerable: false,
|
|
327
|
+
writable: true,
|
|
328
|
+
value: false
|
|
329
|
+
});
|
|
330
|
+
Object.defineProperty(element, "_self", {
|
|
331
|
+
configurable: false,
|
|
332
|
+
enumerable: false,
|
|
333
|
+
writable: false,
|
|
334
|
+
value: self
|
|
335
|
+
});
|
|
336
|
+
Object.defineProperty(element, "_source", {
|
|
337
|
+
configurable: false,
|
|
338
|
+
enumerable: false,
|
|
339
|
+
writable: false,
|
|
340
|
+
value: source
|
|
341
|
+
});
|
|
342
|
+
if (Object.freeze) {
|
|
343
|
+
Object.freeze(element.props);
|
|
344
|
+
Object.freeze(element);
|
|
345
|
+
}
|
|
346
|
+
return element;
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* https://github.com/reactjs/rfcs/pull/107
|
|
350
|
+
* @param {*} type
|
|
351
|
+
* @param {object} props
|
|
352
|
+
* @param {string} key
|
|
353
|
+
*/
|
|
354
|
+
function jsxDEV(type, config, maybeKey, source, self) {
|
|
355
|
+
var propName;
|
|
356
|
+
var props = {};
|
|
357
|
+
var key = null;
|
|
358
|
+
var ref = null;
|
|
359
|
+
if (maybeKey !== void 0) key = "" + maybeKey;
|
|
360
|
+
if (hasValidKey(config)) key = "" + config.key;
|
|
361
|
+
if (hasValidRef(config)) {
|
|
362
|
+
ref = config.ref;
|
|
363
|
+
warnIfStringRefCannotBeAutoConverted(config, self);
|
|
364
|
+
}
|
|
365
|
+
for (propName in config) if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) props[propName] = config[propName];
|
|
366
|
+
if (type && type.defaultProps) {
|
|
367
|
+
var defaultProps = type.defaultProps;
|
|
368
|
+
for (propName in defaultProps) if (props[propName] === void 0) props[propName] = defaultProps[propName];
|
|
369
|
+
}
|
|
370
|
+
if (key || ref) {
|
|
371
|
+
var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
|
|
372
|
+
if (key) defineKeyPropWarningGetter(props, displayName);
|
|
373
|
+
if (ref) defineRefPropWarningGetter(props, displayName);
|
|
374
|
+
}
|
|
375
|
+
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
376
|
+
}
|
|
377
|
+
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
378
|
+
ReactSharedInternals.ReactDebugCurrentFrame;
|
|
379
|
+
function setCurrentlyValidatingElement$1(element) {
|
|
380
|
+
currentlyValidatingElement = element;
|
|
381
|
+
}
|
|
382
|
+
var propTypesMisspellWarningShown = false;
|
|
383
|
+
/**
|
|
384
|
+
* Verifies the object is a ReactElement.
|
|
385
|
+
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
386
|
+
* @param {?object} object
|
|
387
|
+
* @return {boolean} True if `object` is a ReactElement.
|
|
388
|
+
* @final
|
|
389
|
+
*/
|
|
390
|
+
function isValidElement(object) {
|
|
391
|
+
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
392
|
+
}
|
|
393
|
+
function getDeclarationErrorAddendum() {
|
|
394
|
+
if (ReactCurrentOwner$1.current) {
|
|
395
|
+
var name = getComponentName(ReactCurrentOwner$1.current.type);
|
|
396
|
+
if (name) return "\n\nCheck the render method of `" + name + "`.";
|
|
397
|
+
}
|
|
398
|
+
return "";
|
|
399
|
+
}
|
|
400
|
+
function getSourceInfoErrorAddendum(source) {
|
|
401
|
+
if (source !== void 0) {
|
|
402
|
+
var fileName = source.fileName.replace(/^.*[\\\/]/, "");
|
|
403
|
+
var lineNumber = source.lineNumber;
|
|
404
|
+
return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
|
|
405
|
+
}
|
|
406
|
+
return "";
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
410
|
+
* object keys are not valid. This allows us to keep track of children between
|
|
411
|
+
* updates.
|
|
412
|
+
*/
|
|
413
|
+
var ownerHasKeyUseWarning = {};
|
|
414
|
+
function getCurrentComponentErrorInfo(parentType) {
|
|
415
|
+
var info = getDeclarationErrorAddendum();
|
|
416
|
+
if (!info) {
|
|
417
|
+
var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
|
|
418
|
+
if (parentName) info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
419
|
+
}
|
|
420
|
+
return info;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Warn if the element doesn't have an explicit key assigned to it.
|
|
424
|
+
* This element is in an array. The array could grow and shrink or be
|
|
425
|
+
* reordered. All children that haven't already been validated are required to
|
|
426
|
+
* have a "key" property assigned to it. Error statuses are cached so a warning
|
|
427
|
+
* will only be shown once.
|
|
428
|
+
*
|
|
429
|
+
* @internal
|
|
430
|
+
* @param {ReactElement} element Element that requires a key.
|
|
431
|
+
* @param {*} parentType element's parent's type.
|
|
432
|
+
*/
|
|
433
|
+
function validateExplicitKey(element, parentType) {
|
|
434
|
+
if (!element._store || element._store.validated || element.key != null) return;
|
|
435
|
+
element._store.validated = true;
|
|
436
|
+
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
437
|
+
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) return;
|
|
438
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
|
439
|
+
var childOwner = "";
|
|
440
|
+
if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
|
441
|
+
setCurrentlyValidatingElement$1(element);
|
|
442
|
+
error("Each child in a list should have a unique \"key\" prop.%s%s See https://reactjs.org/link/warning-keys for more information.", currentComponentErrorInfo, childOwner);
|
|
443
|
+
setCurrentlyValidatingElement$1(null);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Ensure that every element either is passed in a static location, in an
|
|
447
|
+
* array with an explicit keys property defined, or in an object literal
|
|
448
|
+
* with valid key property.
|
|
449
|
+
*
|
|
450
|
+
* @internal
|
|
451
|
+
* @param {ReactNode} node Statically passed child of any type.
|
|
452
|
+
* @param {*} parentType node's parent's type.
|
|
453
|
+
*/
|
|
454
|
+
function validateChildKeys(node, parentType) {
|
|
455
|
+
if (typeof node !== "object") return;
|
|
456
|
+
if (Array.isArray(node)) for (var i = 0; i < node.length; i++) {
|
|
457
|
+
var child = node[i];
|
|
458
|
+
if (isValidElement(child)) validateExplicitKey(child, parentType);
|
|
459
|
+
}
|
|
460
|
+
else if (isValidElement(node)) {
|
|
461
|
+
if (node._store) node._store.validated = true;
|
|
462
|
+
} else if (node) {
|
|
463
|
+
var iteratorFn = getIteratorFn(node);
|
|
464
|
+
if (typeof iteratorFn === "function") {
|
|
465
|
+
if (iteratorFn !== node.entries) {
|
|
466
|
+
var iterator = iteratorFn.call(node);
|
|
467
|
+
var step;
|
|
468
|
+
while (!(step = iterator.next()).done) if (isValidElement(step.value)) validateExplicitKey(step.value, parentType);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Given an element, validate that its props follow the propTypes definition,
|
|
475
|
+
* provided by the type.
|
|
476
|
+
*
|
|
477
|
+
* @param {ReactElement} element
|
|
478
|
+
*/
|
|
479
|
+
function validatePropTypes(element) {
|
|
480
|
+
var type = element.type;
|
|
481
|
+
if (type === null || type === void 0 || typeof type === "string") return;
|
|
482
|
+
var propTypes;
|
|
483
|
+
if (typeof type === "function") propTypes = type.propTypes;
|
|
484
|
+
else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_MEMO_TYPE)) propTypes = type.propTypes;
|
|
485
|
+
else return;
|
|
486
|
+
if (propTypes) {
|
|
487
|
+
var name = getComponentName(type);
|
|
488
|
+
checkPropTypes(propTypes, element.props, "prop", name, element);
|
|
489
|
+
} else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
|
|
490
|
+
propTypesMisspellWarningShown = true;
|
|
491
|
+
error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", getComponentName(type) || "Unknown");
|
|
492
|
+
}
|
|
493
|
+
if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Given a fragment, validate that it can only be provided with fragment props
|
|
497
|
+
* @param {ReactElement} fragment
|
|
498
|
+
*/
|
|
499
|
+
function validateFragmentProps(fragment) {
|
|
500
|
+
var keys = Object.keys(fragment.props);
|
|
501
|
+
for (var i = 0; i < keys.length; i++) {
|
|
502
|
+
var key = keys[i];
|
|
503
|
+
if (key !== "children" && key !== "key") {
|
|
504
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
505
|
+
error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
|
|
506
|
+
setCurrentlyValidatingElement$1(null);
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (fragment.ref !== null) {
|
|
511
|
+
setCurrentlyValidatingElement$1(fragment);
|
|
512
|
+
error("Invalid attribute `ref` supplied to `React.Fragment`.");
|
|
513
|
+
setCurrentlyValidatingElement$1(null);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
517
|
+
var validType = isValidElementType(type);
|
|
518
|
+
if (!validType) {
|
|
519
|
+
var info = "";
|
|
520
|
+
if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
|
|
521
|
+
var sourceInfo = getSourceInfoErrorAddendum(source);
|
|
522
|
+
if (sourceInfo) info += sourceInfo;
|
|
523
|
+
else info += getDeclarationErrorAddendum();
|
|
524
|
+
var typeString;
|
|
525
|
+
if (type === null) typeString = "null";
|
|
526
|
+
else if (Array.isArray(type)) typeString = "array";
|
|
527
|
+
else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
528
|
+
typeString = "<" + (getComponentName(type.type) || "Unknown") + " />";
|
|
529
|
+
info = " Did you accidentally export a JSX literal instead of a component?";
|
|
530
|
+
} else typeString = typeof type;
|
|
531
|
+
error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
|
|
532
|
+
}
|
|
533
|
+
var element = jsxDEV(type, props, key, source, self);
|
|
534
|
+
if (element == null) return element;
|
|
535
|
+
if (validType) {
|
|
536
|
+
var children = props.children;
|
|
537
|
+
if (children !== void 0) {
|
|
538
|
+
if (isStaticChildren) {
|
|
539
|
+
if (Array.isArray(children)) {
|
|
540
|
+
for (var i = 0; i < children.length; i++) validateChildKeys(children[i], type);
|
|
541
|
+
if (Object.freeze) Object.freeze(children);
|
|
542
|
+
} else error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
543
|
+
} else validateChildKeys(children, type);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
if (type === exports.Fragment) validateFragmentProps(element);
|
|
547
|
+
else validatePropTypes(element);
|
|
548
|
+
return element;
|
|
549
|
+
}
|
|
550
|
+
function jsxWithValidationStatic(type, props, key) {
|
|
551
|
+
return jsxWithValidation(type, props, key, true);
|
|
552
|
+
}
|
|
553
|
+
function jsxWithValidationDynamic(type, props, key) {
|
|
554
|
+
return jsxWithValidation(type, props, key, false);
|
|
555
|
+
}
|
|
556
|
+
var jsx = jsxWithValidationDynamic;
|
|
557
|
+
var jsxs = jsxWithValidationStatic;
|
|
558
|
+
exports.jsx = jsx;
|
|
559
|
+
exports.jsxs = jsxs;
|
|
560
|
+
})();
|
|
561
|
+
}));
|
|
562
|
+
// node_modules/react-diff-view/es/index.js
|
|
563
|
+
var import_jsx_runtime = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
564
|
+
if (process.env.NODE_ENV === "production") module.exports = require_react_jsx_runtime_production_min();
|
|
565
|
+
else module.exports = require_react_jsx_runtime_development();
|
|
566
|
+
})))();
|
|
567
|
+
function ownKeys(e, r) {
|
|
568
|
+
var t = Object.keys(e);
|
|
569
|
+
if (Object.getOwnPropertySymbols) {
|
|
570
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
571
|
+
r && (o = o.filter((function(r) {
|
|
572
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
573
|
+
}))), t.push.apply(t, o);
|
|
574
|
+
}
|
|
575
|
+
return t;
|
|
576
|
+
}
|
|
577
|
+
function _objectSpread2(e) {
|
|
578
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
579
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
580
|
+
r % 2 ? ownKeys(Object(t), !0).forEach((function(r) {
|
|
581
|
+
_defineProperty$1(e, r, t[r]);
|
|
582
|
+
})) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach((function(r) {
|
|
583
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
584
|
+
}));
|
|
585
|
+
}
|
|
586
|
+
return e;
|
|
587
|
+
}
|
|
588
|
+
function _defineProperty$1(obj, key, value) {
|
|
589
|
+
return (key = function(arg) {
|
|
590
|
+
var key = function(input, hint) {
|
|
591
|
+
if ("object" != typeof input || null === input) return input;
|
|
592
|
+
var prim = input[Symbol.toPrimitive];
|
|
593
|
+
if (void 0 !== prim) {
|
|
594
|
+
var res = prim.call(input, hint || "default");
|
|
595
|
+
if ("object" != typeof res) return res;
|
|
596
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
597
|
+
}
|
|
598
|
+
return ("string" === hint ? String : Number)(input);
|
|
599
|
+
}(arg, "string");
|
|
600
|
+
return "symbol" == typeof key ? key : String(key);
|
|
601
|
+
}(key)) in obj ? Object.defineProperty(obj, key, {
|
|
602
|
+
value,
|
|
603
|
+
enumerable: !0,
|
|
604
|
+
configurable: !0,
|
|
605
|
+
writable: !0
|
|
606
|
+
}) : obj[key] = value, obj;
|
|
607
|
+
}
|
|
608
|
+
function _objectWithoutProperties(source, excluded) {
|
|
609
|
+
if (null == source) return {};
|
|
610
|
+
var key, i, target = function(source, excluded) {
|
|
611
|
+
if (null == source) return {};
|
|
612
|
+
var key, i, target = {}, sourceKeys = Object.keys(source);
|
|
613
|
+
for (i = 0; i < sourceKeys.length; i++) key = sourceKeys[i], excluded.indexOf(key) >= 0 || (target[key] = source[key]);
|
|
614
|
+
return target;
|
|
615
|
+
}(source, excluded);
|
|
616
|
+
if (Object.getOwnPropertySymbols) {
|
|
617
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
618
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) key = sourceSymbolKeys[i], excluded.indexOf(key) >= 0 || Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
619
|
+
}
|
|
620
|
+
return target;
|
|
621
|
+
}
|
|
622
|
+
function _slicedToArray(arr, i) {
|
|
623
|
+
return _arrayWithHoles(arr) || function(r, l) {
|
|
624
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
625
|
+
if (null != t) {
|
|
626
|
+
var e, n, i, u, a = [], f = !0, o = !1;
|
|
627
|
+
try {
|
|
628
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
629
|
+
if (Object(t) !== t) return;
|
|
630
|
+
f = !1;
|
|
631
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
632
|
+
} catch (r) {
|
|
633
|
+
o = !0, n = r;
|
|
634
|
+
} finally {
|
|
635
|
+
try {
|
|
636
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
637
|
+
} finally {
|
|
638
|
+
if (o) throw n;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return a;
|
|
642
|
+
}
|
|
643
|
+
}(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
644
|
+
}
|
|
645
|
+
function _toConsumableArray(arr) {
|
|
646
|
+
return function(arr) {
|
|
647
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
648
|
+
}(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || function() {
|
|
649
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
650
|
+
}();
|
|
651
|
+
}
|
|
652
|
+
function _arrayWithHoles(arr) {
|
|
653
|
+
if (Array.isArray(arr)) return arr;
|
|
654
|
+
}
|
|
655
|
+
function _iterableToArray(iter) {
|
|
656
|
+
if ("undefined" != typeof Symbol && null != iter[Symbol.iterator] || null != iter["@@iterator"]) return Array.from(iter);
|
|
657
|
+
}
|
|
658
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
659
|
+
if (o) {
|
|
660
|
+
if ("string" == typeof o) return _arrayLikeToArray(o, minLen);
|
|
661
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
662
|
+
return "Object" === n && o.constructor && (n = o.constructor.name), "Map" === n || "Set" === n ? Array.from(o) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? _arrayLikeToArray(o, minLen) : void 0;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
function _arrayLikeToArray(arr, len) {
|
|
666
|
+
(null == len || len > arr.length) && (len = arr.length);
|
|
667
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
668
|
+
return arr2;
|
|
669
|
+
}
|
|
670
|
+
function _nonIterableRest() {
|
|
671
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
672
|
+
}
|
|
673
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
674
|
+
var it = "undefined" != typeof Symbol && o[Symbol.iterator] || o["@@iterator"];
|
|
675
|
+
if (!it) {
|
|
676
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && "number" == typeof o.length) {
|
|
677
|
+
it && (o = it);
|
|
678
|
+
var i = 0, F = function() {};
|
|
679
|
+
return {
|
|
680
|
+
s: F,
|
|
681
|
+
n: function() {
|
|
682
|
+
return i >= o.length ? { done: !0 } : {
|
|
683
|
+
done: !1,
|
|
684
|
+
value: o[i++]
|
|
685
|
+
};
|
|
686
|
+
},
|
|
687
|
+
e: function(e) {
|
|
688
|
+
throw e;
|
|
689
|
+
},
|
|
690
|
+
f: F
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
694
|
+
}
|
|
695
|
+
var err, normalCompletion = !0, didErr = !1;
|
|
696
|
+
return {
|
|
697
|
+
s: function() {
|
|
698
|
+
it = it.call(o);
|
|
699
|
+
},
|
|
700
|
+
n: function() {
|
|
701
|
+
var step = it.next();
|
|
702
|
+
return normalCompletion = step.done, step;
|
|
703
|
+
},
|
|
704
|
+
e: function(e) {
|
|
705
|
+
didErr = !0, err = e;
|
|
706
|
+
},
|
|
707
|
+
f: function() {
|
|
708
|
+
try {
|
|
709
|
+
normalCompletion || null == it.return || it.return();
|
|
710
|
+
} finally {
|
|
711
|
+
if (didErr) throw err;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
var commonjsGlobal = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};
|
|
717
|
+
function createCommonjsModule(fn, module) {
|
|
718
|
+
return fn(module = { exports: {} }, module.exports), module.exports;
|
|
719
|
+
}
|
|
720
|
+
var classnames = createCommonjsModule((function(module) {
|
|
721
|
+
/*!
|
|
722
|
+
Copyright (c) 2018 Jed Watson.
|
|
723
|
+
Licensed under the MIT License (MIT), see
|
|
724
|
+
http://jedwatson.github.io/classnames
|
|
725
|
+
*/
|
|
726
|
+
(function() {
|
|
727
|
+
var hasOwn = {}.hasOwnProperty;
|
|
728
|
+
function classNames() {
|
|
729
|
+
for (var classes = [], i = 0; i < arguments.length; i++) {
|
|
730
|
+
var arg = arguments[i];
|
|
731
|
+
if (arg) {
|
|
732
|
+
var argType = typeof arg;
|
|
733
|
+
if ("string" === argType || "number" === argType) classes.push(arg);
|
|
734
|
+
else if (Array.isArray(arg)) {
|
|
735
|
+
if (arg.length) {
|
|
736
|
+
var inner = classNames.apply(null, arg);
|
|
737
|
+
inner && classes.push(inner);
|
|
738
|
+
}
|
|
739
|
+
} else if ("object" === argType) {
|
|
740
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
741
|
+
classes.push(arg.toString());
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
for (var key in arg) hasOwn.call(arg, key) && arg[key] && classes.push(key);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return classes.join(" ");
|
|
749
|
+
}
|
|
750
|
+
module.exports ? (classNames.default = classNames, module.exports = classNames) : window.classNames = classNames;
|
|
751
|
+
})();
|
|
752
|
+
}));
|
|
753
|
+
var DEFAULT_CONTEXT_VALUE = {
|
|
754
|
+
hunkClassName: "",
|
|
755
|
+
lineClassName: "",
|
|
756
|
+
gutterClassName: "",
|
|
757
|
+
codeClassName: "",
|
|
758
|
+
monotonous: !1,
|
|
759
|
+
gutterType: "default",
|
|
760
|
+
viewType: "split",
|
|
761
|
+
widgets: {},
|
|
762
|
+
hideGutter: !1,
|
|
763
|
+
selectedChanges: [],
|
|
764
|
+
generateAnchorID: function() {},
|
|
765
|
+
generateLineClassName: function() {},
|
|
766
|
+
renderGutter: function(_ref) {
|
|
767
|
+
var renderDefault = _ref.renderDefault;
|
|
768
|
+
return (0, _ref.wrapInAnchor)(renderDefault());
|
|
769
|
+
},
|
|
770
|
+
codeEvents: {},
|
|
771
|
+
gutterEvents: {}
|
|
772
|
+
};
|
|
773
|
+
var ContextType = createContext(DEFAULT_CONTEXT_VALUE);
|
|
774
|
+
var Provider = ContextType.Provider;
|
|
775
|
+
var useDiffSettings = function() {
|
|
776
|
+
return useContext(ContextType);
|
|
777
|
+
};
|
|
778
|
+
var gitdiffParser = createCommonjsModule((function(module, exports) {
|
|
779
|
+
(function(root) {
|
|
780
|
+
function parsePathFromFirstLine(line) {
|
|
781
|
+
var filesStr = line.slice(11), oldPath = null, newPath = null;
|
|
782
|
+
switch (filesStr.indexOf("\"")) {
|
|
783
|
+
case -1:
|
|
784
|
+
oldPath = (segs = filesStr.split(" "))[0].slice(2), newPath = segs[1].slice(2);
|
|
785
|
+
break;
|
|
786
|
+
case 0:
|
|
787
|
+
var nextQuoteIndex = filesStr.indexOf("\"", 2);
|
|
788
|
+
oldPath = filesStr.slice(3, nextQuoteIndex);
|
|
789
|
+
var newQuoteIndex = filesStr.indexOf("\"", nextQuoteIndex + 1);
|
|
790
|
+
newPath = newQuoteIndex < 0 ? filesStr.slice(nextQuoteIndex + 4) : filesStr.slice(newQuoteIndex + 3, -1);
|
|
791
|
+
break;
|
|
792
|
+
default:
|
|
793
|
+
var segs;
|
|
794
|
+
oldPath = (segs = filesStr.split(" "))[0].slice(2), newPath = segs[1].slice(3, -1);
|
|
795
|
+
}
|
|
796
|
+
return {
|
|
797
|
+
oldPath,
|
|
798
|
+
newPath
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
module.exports = { parse: function(source) {
|
|
802
|
+
for (var currentInfo, currentHunk, changeOldLine, changeNewLine, paths, infos = [], stat = 2, lines = source.split("\n"), linesLen = lines.length, i = 0; i < linesLen;) {
|
|
803
|
+
var line = lines[i];
|
|
804
|
+
if (0 === line.indexOf("diff --git")) {
|
|
805
|
+
currentInfo = {
|
|
806
|
+
hunks: [],
|
|
807
|
+
oldEndingNewLine: !0,
|
|
808
|
+
newEndingNewLine: !0,
|
|
809
|
+
oldPath: (paths = parsePathFromFirstLine(line)).oldPath,
|
|
810
|
+
newPath: paths.newPath
|
|
811
|
+
}, infos.push(currentInfo);
|
|
812
|
+
var simiLine, currentInfoType = null;
|
|
813
|
+
simiLoop: for (; simiLine = lines[++i];) {
|
|
814
|
+
var spaceIndex = simiLine.indexOf(" "), infoType = spaceIndex > -1 ? simiLine.slice(0, spaceIndex) : infoType;
|
|
815
|
+
switch (infoType) {
|
|
816
|
+
case "diff":
|
|
817
|
+
i--;
|
|
818
|
+
break simiLoop;
|
|
819
|
+
case "deleted":
|
|
820
|
+
case "new":
|
|
821
|
+
var leftStr = simiLine.slice(spaceIndex + 1);
|
|
822
|
+
0 === leftStr.indexOf("file mode") && (currentInfo["new" === infoType ? "newMode" : "oldMode"] = leftStr.slice(10));
|
|
823
|
+
break;
|
|
824
|
+
case "similarity":
|
|
825
|
+
currentInfo.similarity = parseInt(simiLine.split(" ")[2], 10);
|
|
826
|
+
break;
|
|
827
|
+
case "index":
|
|
828
|
+
var segs = simiLine.slice(spaceIndex + 1).split(" "), revs = segs[0].split("..");
|
|
829
|
+
currentInfo.oldRevision = revs[0], currentInfo.newRevision = revs[1], segs[1] && (currentInfo.oldMode = currentInfo.newMode = segs[1]);
|
|
830
|
+
break;
|
|
831
|
+
case "copy":
|
|
832
|
+
case "rename":
|
|
833
|
+
var infoStr = simiLine.slice(spaceIndex + 1);
|
|
834
|
+
0 === infoStr.indexOf("from") ? currentInfo.oldPath = infoStr.slice(5) : currentInfo.newPath = infoStr.slice(3), currentInfoType = infoType;
|
|
835
|
+
break;
|
|
836
|
+
case "---":
|
|
837
|
+
var oldPath = simiLine.slice(spaceIndex + 1), newPath = lines[++i].slice(4);
|
|
838
|
+
"/dev/null" === oldPath ? (newPath = newPath.slice(2), currentInfoType = "add") : "/dev/null" === newPath ? (oldPath = oldPath.slice(2), currentInfoType = "delete") : (currentInfoType = "modify", oldPath = oldPath.slice(2), newPath = newPath.slice(2)), oldPath && (currentInfo.oldPath = oldPath), newPath && (currentInfo.newPath = newPath), stat = 5;
|
|
839
|
+
break simiLoop;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
currentInfo.type = currentInfoType || "modify";
|
|
843
|
+
} else if (0 === line.indexOf("Binary")) currentInfo.isBinary = !0, currentInfo.type = line.indexOf("/dev/null and") >= 0 ? "add" : line.indexOf("and /dev/null") >= 0 ? "delete" : "modify", stat = 2, currentInfo = null;
|
|
844
|
+
else if (5 === stat) if (0 === line.indexOf("@@")) {
|
|
845
|
+
var match = /^@@\s+-([0-9]+)(,([0-9]+))?\s+\+([0-9]+)(,([0-9]+))?/.exec(line);
|
|
846
|
+
currentHunk = {
|
|
847
|
+
content: line,
|
|
848
|
+
oldStart: match[1] - 0,
|
|
849
|
+
newStart: match[4] - 0,
|
|
850
|
+
oldLines: match[3] - 0 || 1,
|
|
851
|
+
newLines: match[6] - 0 || 1,
|
|
852
|
+
changes: []
|
|
853
|
+
}, currentInfo.hunks.push(currentHunk), changeOldLine = currentHunk.oldStart, changeNewLine = currentHunk.newStart;
|
|
854
|
+
} else {
|
|
855
|
+
var typeChar = line.slice(0, 1), change = { content: line.slice(1) };
|
|
856
|
+
switch (typeChar) {
|
|
857
|
+
case "+":
|
|
858
|
+
change.type = "insert", change.isInsert = !0, change.lineNumber = changeNewLine, changeNewLine++;
|
|
859
|
+
break;
|
|
860
|
+
case "-":
|
|
861
|
+
change.type = "delete", change.isDelete = !0, change.lineNumber = changeOldLine, changeOldLine++;
|
|
862
|
+
break;
|
|
863
|
+
case " ":
|
|
864
|
+
change.type = "normal", change.isNormal = !0, change.oldLineNumber = changeOldLine, change.newLineNumber = changeNewLine, changeOldLine++, changeNewLine++;
|
|
865
|
+
break;
|
|
866
|
+
case "\\":
|
|
867
|
+
var lastChange = currentHunk.changes[currentHunk.changes.length - 1];
|
|
868
|
+
lastChange.isDelete || (currentInfo.newEndingNewLine = !1), lastChange.isInsert || (currentInfo.oldEndingNewLine = !1);
|
|
869
|
+
}
|
|
870
|
+
change.type && currentHunk.changes.push(change);
|
|
871
|
+
}
|
|
872
|
+
i++;
|
|
873
|
+
}
|
|
874
|
+
return infos;
|
|
875
|
+
} };
|
|
876
|
+
})();
|
|
877
|
+
}));
|
|
878
|
+
function isInsert(change) {
|
|
879
|
+
return "insert" === change.type;
|
|
880
|
+
}
|
|
881
|
+
function isDelete(change) {
|
|
882
|
+
return "delete" === change.type;
|
|
883
|
+
}
|
|
884
|
+
function isNormal(change) {
|
|
885
|
+
return "normal" === change.type;
|
|
886
|
+
}
|
|
887
|
+
function mapHunk(hunk, options) {
|
|
888
|
+
var changes = "zip" === options.nearbySequences ? function(changes) {
|
|
889
|
+
return _slicedToArray(changes.reduce((function(_ref, current, i) {
|
|
890
|
+
var _ref2 = _slicedToArray(_ref, 3), result = _ref2[0], last = _ref2[1], lastDeletionIndex = _ref2[2];
|
|
891
|
+
return last ? isInsert(current) && lastDeletionIndex >= 0 ? (result.splice(lastDeletionIndex + 1, 0, current), [
|
|
892
|
+
result,
|
|
893
|
+
current,
|
|
894
|
+
lastDeletionIndex + 2
|
|
895
|
+
]) : (result.push(current), [
|
|
896
|
+
result,
|
|
897
|
+
current,
|
|
898
|
+
isDelete(current) && isDelete(last) ? lastDeletionIndex : i
|
|
899
|
+
]) : (result.push(current), [
|
|
900
|
+
result,
|
|
901
|
+
current,
|
|
902
|
+
isDelete(current) ? i : -1
|
|
903
|
+
]);
|
|
904
|
+
}), [
|
|
905
|
+
[],
|
|
906
|
+
null,
|
|
907
|
+
-1
|
|
908
|
+
]), 1)[0];
|
|
909
|
+
}(hunk.changes) : hunk.changes;
|
|
910
|
+
return _objectSpread2(_objectSpread2({}, hunk), {}, {
|
|
911
|
+
isPlain: !1,
|
|
912
|
+
changes
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
function parseDiff(text) {
|
|
916
|
+
var options = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, diffText = function(text) {
|
|
917
|
+
if (text.startsWith("diff --git")) return text;
|
|
918
|
+
var indexOfFirstLineBreak = text.indexOf("\n"), indexOfSecondLineBreak = text.indexOf("\n", indexOfFirstLineBreak + 1), firstLine = text.slice(0, indexOfFirstLineBreak), secondLine = text.slice(indexOfFirstLineBreak + 1, indexOfSecondLineBreak), oldPath = firstLine.split(" ").slice(1, -3).join(" "), newPath = secondLine.split(" ").slice(1, -3).join(" ");
|
|
919
|
+
return [
|
|
920
|
+
"diff --git a/".concat(oldPath, " b/").concat(newPath),
|
|
921
|
+
"index 1111111..2222222 100644",
|
|
922
|
+
"--- a/".concat(oldPath),
|
|
923
|
+
"+++ b/".concat(newPath),
|
|
924
|
+
text.slice(indexOfSecondLineBreak + 1)
|
|
925
|
+
].join("\n");
|
|
926
|
+
}(text.trimStart());
|
|
927
|
+
return gitdiffParser.parse(diffText).map((function(file) {
|
|
928
|
+
return function(file, options) {
|
|
929
|
+
var hunks = file.hunks.map((function(hunk) {
|
|
930
|
+
return mapHunk(hunk, options);
|
|
931
|
+
}));
|
|
932
|
+
return _objectSpread2(_objectSpread2({}, file), {}, { hunks });
|
|
933
|
+
}(file, options);
|
|
934
|
+
}));
|
|
935
|
+
}
|
|
936
|
+
function first(array) {
|
|
937
|
+
return array[0];
|
|
938
|
+
}
|
|
939
|
+
function last$1(array) {
|
|
940
|
+
return array[array.length - 1];
|
|
941
|
+
}
|
|
942
|
+
function sideToProperty(side) {
|
|
943
|
+
return ["".concat(side, "Start"), "".concat(side, "Lines")];
|
|
944
|
+
}
|
|
945
|
+
function computeLineNumberFactory(side) {
|
|
946
|
+
return "old" === side ? function(change) {
|
|
947
|
+
return isInsert(change) ? -1 : isNormal(change) ? change.oldLineNumber : change.lineNumber;
|
|
948
|
+
} : function(change) {
|
|
949
|
+
return isDelete(change) ? -1 : isNormal(change) ? change.newLineNumber : change.lineNumber;
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
function isInHunkFactory(startProperty, linesProperty) {
|
|
953
|
+
return function(hunk, lineNumber) {
|
|
954
|
+
var start = hunk[startProperty], end = start + hunk[linesProperty];
|
|
955
|
+
return lineNumber >= start && lineNumber < end;
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function isBetweenHunksFactory(startProperty, linesProperty) {
|
|
959
|
+
return function(previousHunk, nextHunk, lineNumber) {
|
|
960
|
+
var start = previousHunk[startProperty] + previousHunk[linesProperty], end = nextHunk[startProperty];
|
|
961
|
+
return lineNumber >= start && lineNumber < end;
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function findChangeByLineNumberFactory(side) {
|
|
965
|
+
var computeLineNumber = computeLineNumberFactory(side), findContainerHunk = function(side) {
|
|
966
|
+
var _sideToProperty2 = _slicedToArray(sideToProperty(side), 2), isInHunk = isInHunkFactory(_sideToProperty2[0], _sideToProperty2[1]);
|
|
967
|
+
return function(hunks, lineNumber) {
|
|
968
|
+
return hunks.find((function(hunk) {
|
|
969
|
+
return isInHunk(hunk, lineNumber);
|
|
970
|
+
}));
|
|
971
|
+
};
|
|
972
|
+
}(side);
|
|
973
|
+
return function(hunks, lineNumber) {
|
|
974
|
+
var containerHunk = findContainerHunk(hunks, lineNumber);
|
|
975
|
+
if (containerHunk) return containerHunk.changes.find((function(change) {
|
|
976
|
+
return computeLineNumber(change) === lineNumber;
|
|
977
|
+
}));
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
function getCorrespondingLineNumberFactory(baseSide) {
|
|
981
|
+
var anotherSide = "old" === baseSide ? "new" : "old", _sideToProperty4 = _slicedToArray(sideToProperty(baseSide), 2), baseStart = _sideToProperty4[0], baseLines = _sideToProperty4[1], _sideToProperty6 = _slicedToArray(sideToProperty(anotherSide), 2), correspondingStart = _sideToProperty6[0], correspondingLines = _sideToProperty6[1], baseLineNumber = computeLineNumberFactory(baseSide), correspondingLineNumber = computeLineNumberFactory(anotherSide), isInHunk = isInHunkFactory(baseStart, baseLines), isBetweenHunks = isBetweenHunksFactory(baseStart, baseLines);
|
|
982
|
+
return function(hunks, lineNumber) {
|
|
983
|
+
var firstHunk = first(hunks);
|
|
984
|
+
if (lineNumber < firstHunk[baseStart]) {
|
|
985
|
+
var spanFromStart = firstHunk[baseStart] - lineNumber;
|
|
986
|
+
return firstHunk[correspondingStart] - spanFromStart;
|
|
987
|
+
}
|
|
988
|
+
var lastHunk = last$1(hunks);
|
|
989
|
+
if (lastHunk[baseStart] + lastHunk[baseLines] <= lineNumber) {
|
|
990
|
+
var spanFromEnd = lineNumber - lastHunk[baseStart] - lastHunk[baseLines];
|
|
991
|
+
return lastHunk[correspondingStart] + lastHunk[correspondingLines] + spanFromEnd;
|
|
992
|
+
}
|
|
993
|
+
for (var i = 0; i < hunks.length; i++) {
|
|
994
|
+
var currentHunk = hunks[i], nextHunk = hunks[i + 1];
|
|
995
|
+
if (isInHunk(currentHunk, lineNumber)) {
|
|
996
|
+
var changeIndex = currentHunk.changes.findIndex((function(change) {
|
|
997
|
+
return baseLineNumber(change) === lineNumber;
|
|
998
|
+
})), change = currentHunk.changes[changeIndex];
|
|
999
|
+
if (isNormal(change)) return correspondingLineNumber(change);
|
|
1000
|
+
var possibleCorrespondingChangeIndex = isDelete(change) ? changeIndex + 1 : changeIndex - 1, possibleCorrespondingChange = currentHunk.changes[possibleCorrespondingChangeIndex];
|
|
1001
|
+
if (!possibleCorrespondingChange) return -1;
|
|
1002
|
+
var negativeChangeType = isInsert(change) ? "delete" : "insert";
|
|
1003
|
+
return possibleCorrespondingChange.type === negativeChangeType ? correspondingLineNumber(possibleCorrespondingChange) : -1;
|
|
1004
|
+
}
|
|
1005
|
+
if (isBetweenHunks(currentHunk, nextHunk, lineNumber)) {
|
|
1006
|
+
var _spanFromEnd = lineNumber - currentHunk[baseStart] - currentHunk[baseLines];
|
|
1007
|
+
return currentHunk[correspondingStart] + currentHunk[correspondingLines] + _spanFromEnd;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
throw new Error("Unexpected line position ".concat(lineNumber));
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
var _listCacheClear = function() {
|
|
1014
|
+
this.__data__ = [], this.size = 0;
|
|
1015
|
+
};
|
|
1016
|
+
var eq_1 = function(value, other) {
|
|
1017
|
+
return value === other || value != value && other != other;
|
|
1018
|
+
};
|
|
1019
|
+
var _assocIndexOf = function(array, key) {
|
|
1020
|
+
for (var length = array.length; length--;) if (eq_1(array[length][0], key)) return length;
|
|
1021
|
+
return -1;
|
|
1022
|
+
};
|
|
1023
|
+
var splice = Array.prototype.splice;
|
|
1024
|
+
var _listCacheDelete = function(key) {
|
|
1025
|
+
var data = this.__data__, index = _assocIndexOf(data, key);
|
|
1026
|
+
return !(index < 0) && (index == data.length - 1 ? data.pop() : splice.call(data, index, 1), --this.size, !0);
|
|
1027
|
+
};
|
|
1028
|
+
var _listCacheGet = function(key) {
|
|
1029
|
+
var data = this.__data__, index = _assocIndexOf(data, key);
|
|
1030
|
+
return index < 0 ? void 0 : data[index][1];
|
|
1031
|
+
};
|
|
1032
|
+
var _listCacheHas = function(key) {
|
|
1033
|
+
return _assocIndexOf(this.__data__, key) > -1;
|
|
1034
|
+
};
|
|
1035
|
+
var _listCacheSet = function(key, value) {
|
|
1036
|
+
var data = this.__data__, index = _assocIndexOf(data, key);
|
|
1037
|
+
return index < 0 ? (++this.size, data.push([key, value])) : data[index][1] = value, this;
|
|
1038
|
+
};
|
|
1039
|
+
function ListCache(entries) {
|
|
1040
|
+
var index = -1, length = null == entries ? 0 : entries.length;
|
|
1041
|
+
for (this.clear(); ++index < length;) {
|
|
1042
|
+
var entry = entries[index];
|
|
1043
|
+
this.set(entry[0], entry[1]);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
ListCache.prototype.clear = _listCacheClear, ListCache.prototype.delete = _listCacheDelete, ListCache.prototype.get = _listCacheGet, ListCache.prototype.has = _listCacheHas, ListCache.prototype.set = _listCacheSet;
|
|
1047
|
+
var _ListCache = ListCache;
|
|
1048
|
+
var _stackClear = function() {
|
|
1049
|
+
this.__data__ = new _ListCache(), this.size = 0;
|
|
1050
|
+
};
|
|
1051
|
+
var _stackDelete = function(key) {
|
|
1052
|
+
var data = this.__data__, result = data.delete(key);
|
|
1053
|
+
return this.size = data.size, result;
|
|
1054
|
+
};
|
|
1055
|
+
var _stackGet = function(key) {
|
|
1056
|
+
return this.__data__.get(key);
|
|
1057
|
+
};
|
|
1058
|
+
var _stackHas = function(key) {
|
|
1059
|
+
return this.__data__.has(key);
|
|
1060
|
+
};
|
|
1061
|
+
var _freeGlobal = "object" == typeof commonjsGlobal && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
1062
|
+
var freeSelf = "object" == typeof self && self && self.Object === Object && self;
|
|
1063
|
+
var _root = _freeGlobal || freeSelf || Function("return this")();
|
|
1064
|
+
var _Symbol = _root.Symbol;
|
|
1065
|
+
var objectProto$d = Object.prototype;
|
|
1066
|
+
var hasOwnProperty$a = objectProto$d.hasOwnProperty;
|
|
1067
|
+
var nativeObjectToString$1 = objectProto$d.toString;
|
|
1068
|
+
var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : void 0;
|
|
1069
|
+
var _getRawTag = function(value) {
|
|
1070
|
+
var isOwn = hasOwnProperty$a.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
1071
|
+
try {
|
|
1072
|
+
value[symToStringTag$1] = void 0;
|
|
1073
|
+
var unmasked = !0;
|
|
1074
|
+
} catch (e) {}
|
|
1075
|
+
var result = nativeObjectToString$1.call(value);
|
|
1076
|
+
return unmasked && (isOwn ? value[symToStringTag$1] = tag : delete value[symToStringTag$1]), result;
|
|
1077
|
+
};
|
|
1078
|
+
var nativeObjectToString = Object.prototype.toString;
|
|
1079
|
+
var _objectToString = function(value) {
|
|
1080
|
+
return nativeObjectToString.call(value);
|
|
1081
|
+
};
|
|
1082
|
+
var symToStringTag = _Symbol ? _Symbol.toStringTag : void 0;
|
|
1083
|
+
var _baseGetTag = function(value) {
|
|
1084
|
+
return null == value ? void 0 === value ? "[object Undefined]" : "[object Null]" : symToStringTag && symToStringTag in Object(value) ? _getRawTag(value) : _objectToString(value);
|
|
1085
|
+
};
|
|
1086
|
+
var isObject_1 = function(value) {
|
|
1087
|
+
var type = typeof value;
|
|
1088
|
+
return null != value && ("object" == type || "function" == type);
|
|
1089
|
+
};
|
|
1090
|
+
var isFunction_1 = function(value) {
|
|
1091
|
+
if (!isObject_1(value)) return !1;
|
|
1092
|
+
var tag = _baseGetTag(value);
|
|
1093
|
+
return "[object Function]" == tag || "[object GeneratorFunction]" == tag || "[object AsyncFunction]" == tag || "[object Proxy]" == tag;
|
|
1094
|
+
};
|
|
1095
|
+
var _coreJsData = _root["__core-js_shared__"];
|
|
1096
|
+
var maskSrcKey = function() {
|
|
1097
|
+
var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || "");
|
|
1098
|
+
return uid ? "Symbol(src)_1." + uid : "";
|
|
1099
|
+
}();
|
|
1100
|
+
var _isMasked = function(func) {
|
|
1101
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
1102
|
+
};
|
|
1103
|
+
var funcToString$1 = Function.prototype.toString;
|
|
1104
|
+
var _toSource = function(func) {
|
|
1105
|
+
if (null != func) {
|
|
1106
|
+
try {
|
|
1107
|
+
return funcToString$1.call(func);
|
|
1108
|
+
} catch (e) {}
|
|
1109
|
+
try {
|
|
1110
|
+
return func + "";
|
|
1111
|
+
} catch (e) {}
|
|
1112
|
+
}
|
|
1113
|
+
return "";
|
|
1114
|
+
};
|
|
1115
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
1116
|
+
var funcProto = Function.prototype;
|
|
1117
|
+
var objectProto$b = Object.prototype;
|
|
1118
|
+
var funcToString = funcProto.toString;
|
|
1119
|
+
var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
|
|
1120
|
+
var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty$9).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
|
|
1121
|
+
var _baseIsNative = function(value) {
|
|
1122
|
+
return !(!isObject_1(value) || _isMasked(value)) && (isFunction_1(value) ? reIsNative : reIsHostCtor).test(_toSource(value));
|
|
1123
|
+
};
|
|
1124
|
+
var _getValue = function(object, key) {
|
|
1125
|
+
return null == object ? void 0 : object[key];
|
|
1126
|
+
};
|
|
1127
|
+
var _getNative = function(object, key) {
|
|
1128
|
+
var value = _getValue(object, key);
|
|
1129
|
+
return _baseIsNative(value) ? value : void 0;
|
|
1130
|
+
};
|
|
1131
|
+
var _Map = _getNative(_root, "Map");
|
|
1132
|
+
var _nativeCreate = _getNative(Object, "create");
|
|
1133
|
+
var _hashClear = function() {
|
|
1134
|
+
this.__data__ = _nativeCreate ? _nativeCreate(null) : {}, this.size = 0;
|
|
1135
|
+
};
|
|
1136
|
+
var _hashDelete = function(key) {
|
|
1137
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
1138
|
+
return this.size -= result ? 1 : 0, result;
|
|
1139
|
+
};
|
|
1140
|
+
var hasOwnProperty$8 = Object.prototype.hasOwnProperty;
|
|
1141
|
+
var _hashGet = function(key) {
|
|
1142
|
+
var data = this.__data__;
|
|
1143
|
+
if (_nativeCreate) {
|
|
1144
|
+
var result = data[key];
|
|
1145
|
+
return "__lodash_hash_undefined__" === result ? void 0 : result;
|
|
1146
|
+
}
|
|
1147
|
+
return hasOwnProperty$8.call(data, key) ? data[key] : void 0;
|
|
1148
|
+
};
|
|
1149
|
+
var hasOwnProperty$7 = Object.prototype.hasOwnProperty;
|
|
1150
|
+
var _hashHas = function(key) {
|
|
1151
|
+
var data = this.__data__;
|
|
1152
|
+
return _nativeCreate ? void 0 !== data[key] : hasOwnProperty$7.call(data, key);
|
|
1153
|
+
};
|
|
1154
|
+
var _hashSet = function(key, value) {
|
|
1155
|
+
var data = this.__data__;
|
|
1156
|
+
return this.size += this.has(key) ? 0 : 1, data[key] = _nativeCreate && void 0 === value ? "__lodash_hash_undefined__" : value, this;
|
|
1157
|
+
};
|
|
1158
|
+
function Hash(entries) {
|
|
1159
|
+
var index = -1, length = null == entries ? 0 : entries.length;
|
|
1160
|
+
for (this.clear(); ++index < length;) {
|
|
1161
|
+
var entry = entries[index];
|
|
1162
|
+
this.set(entry[0], entry[1]);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
Hash.prototype.clear = _hashClear, Hash.prototype.delete = _hashDelete, Hash.prototype.get = _hashGet, Hash.prototype.has = _hashHas, Hash.prototype.set = _hashSet;
|
|
1166
|
+
var _Hash = Hash;
|
|
1167
|
+
var _mapCacheClear = function() {
|
|
1168
|
+
this.size = 0, this.__data__ = {
|
|
1169
|
+
hash: new _Hash(),
|
|
1170
|
+
map: new (_Map || _ListCache)(),
|
|
1171
|
+
string: new _Hash()
|
|
1172
|
+
};
|
|
1173
|
+
};
|
|
1174
|
+
var _isKeyable = function(value) {
|
|
1175
|
+
var type = typeof value;
|
|
1176
|
+
return "string" == type || "number" == type || "symbol" == type || "boolean" == type ? "__proto__" !== value : null === value;
|
|
1177
|
+
};
|
|
1178
|
+
var _getMapData = function(map, key) {
|
|
1179
|
+
var data = map.__data__;
|
|
1180
|
+
return _isKeyable(key) ? data["string" == typeof key ? "string" : "hash"] : data.map;
|
|
1181
|
+
};
|
|
1182
|
+
var _mapCacheDelete = function(key) {
|
|
1183
|
+
var result = _getMapData(this, key).delete(key);
|
|
1184
|
+
return this.size -= result ? 1 : 0, result;
|
|
1185
|
+
};
|
|
1186
|
+
var _mapCacheGet = function(key) {
|
|
1187
|
+
return _getMapData(this, key).get(key);
|
|
1188
|
+
};
|
|
1189
|
+
var _mapCacheHas = function(key) {
|
|
1190
|
+
return _getMapData(this, key).has(key);
|
|
1191
|
+
};
|
|
1192
|
+
var _mapCacheSet = function(key, value) {
|
|
1193
|
+
var data = _getMapData(this, key), size = data.size;
|
|
1194
|
+
return data.set(key, value), this.size += data.size == size ? 0 : 1, this;
|
|
1195
|
+
};
|
|
1196
|
+
function MapCache(entries) {
|
|
1197
|
+
var index = -1, length = null == entries ? 0 : entries.length;
|
|
1198
|
+
for (this.clear(); ++index < length;) {
|
|
1199
|
+
var entry = entries[index];
|
|
1200
|
+
this.set(entry[0], entry[1]);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
MapCache.prototype.clear = _mapCacheClear, MapCache.prototype.delete = _mapCacheDelete, MapCache.prototype.get = _mapCacheGet, MapCache.prototype.has = _mapCacheHas, MapCache.prototype.set = _mapCacheSet;
|
|
1204
|
+
var _MapCache = MapCache;
|
|
1205
|
+
var _stackSet = function(key, value) {
|
|
1206
|
+
var data = this.__data__;
|
|
1207
|
+
if (data instanceof _ListCache) {
|
|
1208
|
+
var pairs = data.__data__;
|
|
1209
|
+
if (!_Map || pairs.length < 199) return pairs.push([key, value]), this.size = ++data.size, this;
|
|
1210
|
+
data = this.__data__ = new _MapCache(pairs);
|
|
1211
|
+
}
|
|
1212
|
+
return data.set(key, value), this.size = data.size, this;
|
|
1213
|
+
};
|
|
1214
|
+
function Stack(entries) {
|
|
1215
|
+
var data = this.__data__ = new _ListCache(entries);
|
|
1216
|
+
this.size = data.size;
|
|
1217
|
+
}
|
|
1218
|
+
Stack.prototype.clear = _stackClear, Stack.prototype.delete = _stackDelete, Stack.prototype.get = _stackGet, Stack.prototype.has = _stackHas, Stack.prototype.set = _stackSet;
|
|
1219
|
+
var _Stack = Stack;
|
|
1220
|
+
var _setCacheAdd = function(value) {
|
|
1221
|
+
return this.__data__.set(value, "__lodash_hash_undefined__"), this;
|
|
1222
|
+
};
|
|
1223
|
+
var _setCacheHas = function(value) {
|
|
1224
|
+
return this.__data__.has(value);
|
|
1225
|
+
};
|
|
1226
|
+
function SetCache(values) {
|
|
1227
|
+
var index = -1, length = null == values ? 0 : values.length;
|
|
1228
|
+
for (this.__data__ = new _MapCache(); ++index < length;) this.add(values[index]);
|
|
1229
|
+
}
|
|
1230
|
+
SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd, SetCache.prototype.has = _setCacheHas;
|
|
1231
|
+
var _SetCache = SetCache;
|
|
1232
|
+
var _arraySome = function(array, predicate) {
|
|
1233
|
+
for (var index = -1, length = null == array ? 0 : array.length; ++index < length;) if (predicate(array[index], index, array)) return !0;
|
|
1234
|
+
return !1;
|
|
1235
|
+
};
|
|
1236
|
+
var _cacheHas = function(cache, key) {
|
|
1237
|
+
return cache.has(key);
|
|
1238
|
+
};
|
|
1239
|
+
var _equalArrays = function(array, other, bitmask, customizer, equalFunc, stack) {
|
|
1240
|
+
var isPartial = 1 & bitmask, arrLength = array.length, othLength = other.length;
|
|
1241
|
+
if (arrLength != othLength && !(isPartial && othLength > arrLength)) return !1;
|
|
1242
|
+
var arrStacked = stack.get(array), othStacked = stack.get(other);
|
|
1243
|
+
if (arrStacked && othStacked) return arrStacked == other && othStacked == array;
|
|
1244
|
+
var index = -1, result = !0, seen = 2 & bitmask ? new _SetCache() : void 0;
|
|
1245
|
+
for (stack.set(array, other), stack.set(other, array); ++index < arrLength;) {
|
|
1246
|
+
var arrValue = array[index], othValue = other[index];
|
|
1247
|
+
if (customizer) var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
|
|
1248
|
+
if (void 0 !== compared) {
|
|
1249
|
+
if (compared) continue;
|
|
1250
|
+
result = !1;
|
|
1251
|
+
break;
|
|
1252
|
+
}
|
|
1253
|
+
if (seen) {
|
|
1254
|
+
if (!_arraySome(other, (function(othValue, othIndex) {
|
|
1255
|
+
if (!_cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) return seen.push(othIndex);
|
|
1256
|
+
}))) {
|
|
1257
|
+
result = !1;
|
|
1258
|
+
break;
|
|
1259
|
+
}
|
|
1260
|
+
} else if (arrValue !== othValue && !equalFunc(arrValue, othValue, bitmask, customizer, stack)) {
|
|
1261
|
+
result = !1;
|
|
1262
|
+
break;
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
return stack.delete(array), stack.delete(other), result;
|
|
1266
|
+
};
|
|
1267
|
+
var _Uint8Array = _root.Uint8Array;
|
|
1268
|
+
var _mapToArray = function(map) {
|
|
1269
|
+
var index = -1, result = Array(map.size);
|
|
1270
|
+
return map.forEach((function(value, key) {
|
|
1271
|
+
result[++index] = [key, value];
|
|
1272
|
+
})), result;
|
|
1273
|
+
};
|
|
1274
|
+
var _setToArray = function(set) {
|
|
1275
|
+
var index = -1, result = Array(set.size);
|
|
1276
|
+
return set.forEach((function(value) {
|
|
1277
|
+
result[++index] = value;
|
|
1278
|
+
})), result;
|
|
1279
|
+
};
|
|
1280
|
+
var symbolProto$1 = _Symbol ? _Symbol.prototype : void 0;
|
|
1281
|
+
var symbolValueOf = symbolProto$1 ? symbolProto$1.valueOf : void 0;
|
|
1282
|
+
var _equalByTag = function(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
1283
|
+
switch (tag) {
|
|
1284
|
+
case "[object DataView]":
|
|
1285
|
+
if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) return !1;
|
|
1286
|
+
object = object.buffer, other = other.buffer;
|
|
1287
|
+
case "[object ArrayBuffer]": return !(object.byteLength != other.byteLength || !equalFunc(new _Uint8Array(object), new _Uint8Array(other)));
|
|
1288
|
+
case "[object Boolean]":
|
|
1289
|
+
case "[object Date]":
|
|
1290
|
+
case "[object Number]": return eq_1(+object, +other);
|
|
1291
|
+
case "[object Error]": return object.name == other.name && object.message == other.message;
|
|
1292
|
+
case "[object RegExp]":
|
|
1293
|
+
case "[object String]": return object == other + "";
|
|
1294
|
+
case "[object Map]": var convert = _mapToArray;
|
|
1295
|
+
case "[object Set]":
|
|
1296
|
+
var isPartial = 1 & bitmask;
|
|
1297
|
+
if (convert || (convert = _setToArray), object.size != other.size && !isPartial) return !1;
|
|
1298
|
+
var stacked = stack.get(object);
|
|
1299
|
+
if (stacked) return stacked == other;
|
|
1300
|
+
bitmask |= 2, stack.set(object, other);
|
|
1301
|
+
var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
|
1302
|
+
return stack.delete(object), result;
|
|
1303
|
+
case "[object Symbol]": if (symbolValueOf) return symbolValueOf.call(object) == symbolValueOf.call(other);
|
|
1304
|
+
}
|
|
1305
|
+
return !1;
|
|
1306
|
+
};
|
|
1307
|
+
var _arrayPush = function(array, values) {
|
|
1308
|
+
for (var index = -1, length = values.length, offset = array.length; ++index < length;) array[offset + index] = values[index];
|
|
1309
|
+
return array;
|
|
1310
|
+
};
|
|
1311
|
+
var isArray_1 = Array.isArray;
|
|
1312
|
+
var _baseGetAllKeys = function(object, keysFunc, symbolsFunc) {
|
|
1313
|
+
var result = keysFunc(object);
|
|
1314
|
+
return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
|
|
1315
|
+
};
|
|
1316
|
+
var _arrayFilter = function(array, predicate) {
|
|
1317
|
+
for (var index = -1, length = null == array ? 0 : array.length, resIndex = 0, result = []; ++index < length;) {
|
|
1318
|
+
var value = array[index];
|
|
1319
|
+
predicate(value, index, array) && (result[resIndex++] = value);
|
|
1320
|
+
}
|
|
1321
|
+
return result;
|
|
1322
|
+
};
|
|
1323
|
+
var stubArray_1 = function() {
|
|
1324
|
+
return [];
|
|
1325
|
+
};
|
|
1326
|
+
var propertyIsEnumerable$1 = Object.prototype.propertyIsEnumerable;
|
|
1327
|
+
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
1328
|
+
var _getSymbols = nativeGetSymbols ? function(object) {
|
|
1329
|
+
return null == object ? [] : (object = Object(object), _arrayFilter(nativeGetSymbols(object), (function(symbol) {
|
|
1330
|
+
return propertyIsEnumerable$1.call(object, symbol);
|
|
1331
|
+
})));
|
|
1332
|
+
} : stubArray_1;
|
|
1333
|
+
var _baseTimes = function(n, iteratee) {
|
|
1334
|
+
for (var index = -1, result = Array(n); ++index < n;) result[index] = iteratee(index);
|
|
1335
|
+
return result;
|
|
1336
|
+
};
|
|
1337
|
+
var isObjectLike_1 = function(value) {
|
|
1338
|
+
return null != value && "object" == typeof value;
|
|
1339
|
+
};
|
|
1340
|
+
var _baseIsArguments = function(value) {
|
|
1341
|
+
return isObjectLike_1(value) && "[object Arguments]" == _baseGetTag(value);
|
|
1342
|
+
};
|
|
1343
|
+
var objectProto$7 = Object.prototype;
|
|
1344
|
+
var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
|
|
1345
|
+
var propertyIsEnumerable = objectProto$7.propertyIsEnumerable;
|
|
1346
|
+
var isArguments_1 = _baseIsArguments(function() {
|
|
1347
|
+
return arguments;
|
|
1348
|
+
}()) ? _baseIsArguments : function(value) {
|
|
1349
|
+
return isObjectLike_1(value) && hasOwnProperty$6.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
|
|
1350
|
+
};
|
|
1351
|
+
var stubFalse_1 = function() {
|
|
1352
|
+
return !1;
|
|
1353
|
+
};
|
|
1354
|
+
var isBuffer_1 = createCommonjsModule((function(module, exports) {
|
|
1355
|
+
var freeExports = exports && !exports.nodeType && exports, freeModule = freeExports && module && !module.nodeType && module, Buffer = freeModule && freeModule.exports === freeExports ? _root.Buffer : void 0;
|
|
1356
|
+
module.exports = (Buffer ? Buffer.isBuffer : void 0) || stubFalse_1;
|
|
1357
|
+
}));
|
|
1358
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
1359
|
+
var _isIndex = function(value, length) {
|
|
1360
|
+
var type = typeof value;
|
|
1361
|
+
return !!(length = null == length ? 9007199254740991 : length) && ("number" == type || "symbol" != type && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
|
|
1362
|
+
};
|
|
1363
|
+
var isLength_1 = function(value) {
|
|
1364
|
+
return "number" == typeof value && value > -1 && value % 1 == 0 && value <= 9007199254740991;
|
|
1365
|
+
};
|
|
1366
|
+
var typedArrayTags = {};
|
|
1367
|
+
typedArrayTags["[object Float32Array]"] = typedArrayTags["[object Float64Array]"] = typedArrayTags["[object Int8Array]"] = typedArrayTags["[object Int16Array]"] = typedArrayTags["[object Int32Array]"] = typedArrayTags["[object Uint8Array]"] = typedArrayTags["[object Uint8ClampedArray]"] = typedArrayTags["[object Uint16Array]"] = typedArrayTags["[object Uint32Array]"] = !0, typedArrayTags["[object Arguments]"] = typedArrayTags["[object Array]"] = typedArrayTags["[object ArrayBuffer]"] = typedArrayTags["[object Boolean]"] = typedArrayTags["[object DataView]"] = typedArrayTags["[object Date]"] = typedArrayTags["[object Error]"] = typedArrayTags["[object Function]"] = typedArrayTags["[object Map]"] = typedArrayTags["[object Number]"] = typedArrayTags["[object Object]"] = typedArrayTags["[object RegExp]"] = typedArrayTags["[object Set]"] = typedArrayTags["[object String]"] = typedArrayTags["[object WeakMap]"] = !1;
|
|
1368
|
+
var _baseIsTypedArray = function(value) {
|
|
1369
|
+
return isObjectLike_1(value) && isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
|
|
1370
|
+
};
|
|
1371
|
+
var _baseUnary = function(func) {
|
|
1372
|
+
return function(value) {
|
|
1373
|
+
return func(value);
|
|
1374
|
+
};
|
|
1375
|
+
};
|
|
1376
|
+
var _nodeUtil = createCommonjsModule((function(module, exports) {
|
|
1377
|
+
var freeExports = exports && !exports.nodeType && exports, freeModule = freeExports && module && !module.nodeType && module, freeProcess = freeModule && freeModule.exports === freeExports && _freeGlobal.process;
|
|
1378
|
+
module.exports = function() {
|
|
1379
|
+
try {
|
|
1380
|
+
return freeModule && freeModule.require && freeModule.require("util").types || freeProcess && freeProcess.binding && freeProcess.binding("util");
|
|
1381
|
+
} catch (e) {}
|
|
1382
|
+
}();
|
|
1383
|
+
}));
|
|
1384
|
+
var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
|
|
1385
|
+
var isTypedArray_1 = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
|
|
1386
|
+
var hasOwnProperty$5 = Object.prototype.hasOwnProperty;
|
|
1387
|
+
var _arrayLikeKeys = function(value, inherited) {
|
|
1388
|
+
var isArr = isArray_1(value), isArg = !isArr && isArguments_1(value), isBuff = !isArr && !isArg && isBuffer_1(value), isType = !isArr && !isArg && !isBuff && isTypedArray_1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? _baseTimes(value.length, String) : [], length = result.length;
|
|
1389
|
+
for (var key in value) !inherited && !hasOwnProperty$5.call(value, key) || skipIndexes && ("length" == key || isBuff && ("offset" == key || "parent" == key) || isType && ("buffer" == key || "byteLength" == key || "byteOffset" == key) || _isIndex(key, length)) || result.push(key);
|
|
1390
|
+
return result;
|
|
1391
|
+
};
|
|
1392
|
+
var objectProto$5 = Object.prototype;
|
|
1393
|
+
var _isPrototype = function(value) {
|
|
1394
|
+
var Ctor = value && value.constructor;
|
|
1395
|
+
return value === ("function" == typeof Ctor && Ctor.prototype || objectProto$5);
|
|
1396
|
+
};
|
|
1397
|
+
var _nativeKeys = function(func, transform) {
|
|
1398
|
+
return function(arg) {
|
|
1399
|
+
return func(transform(arg));
|
|
1400
|
+
};
|
|
1401
|
+
}(Object.keys, Object);
|
|
1402
|
+
var hasOwnProperty$4 = Object.prototype.hasOwnProperty;
|
|
1403
|
+
var _baseKeys = function(object) {
|
|
1404
|
+
if (!_isPrototype(object)) return _nativeKeys(object);
|
|
1405
|
+
var result = [];
|
|
1406
|
+
for (var key in Object(object)) hasOwnProperty$4.call(object, key) && "constructor" != key && result.push(key);
|
|
1407
|
+
return result;
|
|
1408
|
+
};
|
|
1409
|
+
var isArrayLike_1 = function(value) {
|
|
1410
|
+
return null != value && isLength_1(value.length) && !isFunction_1(value);
|
|
1411
|
+
};
|
|
1412
|
+
var keys_1 = function(object) {
|
|
1413
|
+
return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
|
|
1414
|
+
};
|
|
1415
|
+
var _getAllKeys = function(object) {
|
|
1416
|
+
return _baseGetAllKeys(object, keys_1, _getSymbols);
|
|
1417
|
+
};
|
|
1418
|
+
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1419
|
+
var _equalObjects = function(object, other, bitmask, customizer, equalFunc, stack) {
|
|
1420
|
+
var isPartial = 1 & bitmask, objProps = _getAllKeys(object), objLength = objProps.length;
|
|
1421
|
+
if (objLength != _getAllKeys(other).length && !isPartial) return !1;
|
|
1422
|
+
for (var index = objLength; index--;) {
|
|
1423
|
+
var key = objProps[index];
|
|
1424
|
+
if (!(isPartial ? key in other : hasOwnProperty$3.call(other, key))) return !1;
|
|
1425
|
+
}
|
|
1426
|
+
var objStacked = stack.get(object), othStacked = stack.get(other);
|
|
1427
|
+
if (objStacked && othStacked) return objStacked == other && othStacked == object;
|
|
1428
|
+
var result = !0;
|
|
1429
|
+
stack.set(object, other), stack.set(other, object);
|
|
1430
|
+
for (var skipCtor = isPartial; ++index < objLength;) {
|
|
1431
|
+
var objValue = object[key = objProps[index]], othValue = other[key];
|
|
1432
|
+
if (customizer) var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
|
|
1433
|
+
if (!(void 0 === compared ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
|
|
1434
|
+
result = !1;
|
|
1435
|
+
break;
|
|
1436
|
+
}
|
|
1437
|
+
skipCtor || (skipCtor = "constructor" == key);
|
|
1438
|
+
}
|
|
1439
|
+
if (result && !skipCtor) {
|
|
1440
|
+
var objCtor = object.constructor, othCtor = other.constructor;
|
|
1441
|
+
objCtor == othCtor || !("constructor" in object) || !("constructor" in other) || "function" == typeof objCtor && objCtor instanceof objCtor && "function" == typeof othCtor && othCtor instanceof othCtor || (result = !1);
|
|
1442
|
+
}
|
|
1443
|
+
return stack.delete(object), stack.delete(other), result;
|
|
1444
|
+
};
|
|
1445
|
+
var _DataView = _getNative(_root, "DataView");
|
|
1446
|
+
var _Promise = _getNative(_root, "Promise");
|
|
1447
|
+
var _Set = _getNative(_root, "Set");
|
|
1448
|
+
var _WeakMap = _getNative(_root, "WeakMap");
|
|
1449
|
+
var dataViewCtorString = _toSource(_DataView);
|
|
1450
|
+
var mapCtorString = _toSource(_Map);
|
|
1451
|
+
var promiseCtorString = _toSource(_Promise);
|
|
1452
|
+
var setCtorString = _toSource(_Set);
|
|
1453
|
+
var weakMapCtorString = _toSource(_WeakMap);
|
|
1454
|
+
var getTag = _baseGetTag;
|
|
1455
|
+
(_DataView && "[object DataView]" != getTag(new _DataView(/* @__PURE__ */ new ArrayBuffer(1))) || _Map && "[object Map]" != getTag(new _Map()) || _Promise && "[object Promise]" != getTag(_Promise.resolve()) || _Set && "[object Set]" != getTag(new _Set()) || _WeakMap && "[object WeakMap]" != getTag(new _WeakMap())) && (getTag = function(value) {
|
|
1456
|
+
var result = _baseGetTag(value), Ctor = "[object Object]" == result ? value.constructor : void 0, ctorString = Ctor ? _toSource(Ctor) : "";
|
|
1457
|
+
if (ctorString) switch (ctorString) {
|
|
1458
|
+
case dataViewCtorString: return "[object DataView]";
|
|
1459
|
+
case mapCtorString: return "[object Map]";
|
|
1460
|
+
case promiseCtorString: return "[object Promise]";
|
|
1461
|
+
case setCtorString: return "[object Set]";
|
|
1462
|
+
case weakMapCtorString: return "[object WeakMap]";
|
|
1463
|
+
}
|
|
1464
|
+
return result;
|
|
1465
|
+
});
|
|
1466
|
+
var _getTag = getTag;
|
|
1467
|
+
var objectTag = "[object Object]";
|
|
1468
|
+
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1469
|
+
var _baseIsEqualDeep = function(object, other, bitmask, customizer, equalFunc, stack) {
|
|
1470
|
+
var objIsArr = isArray_1(object), othIsArr = isArray_1(other), objTag = objIsArr ? "[object Array]" : _getTag(object), othTag = othIsArr ? "[object Array]" : _getTag(other), objIsObj = (objTag = "[object Arguments]" == objTag ? objectTag : objTag) == objectTag, othIsObj = (othTag = "[object Arguments]" == othTag ? objectTag : othTag) == objectTag, isSameTag = objTag == othTag;
|
|
1471
|
+
if (isSameTag && isBuffer_1(object)) {
|
|
1472
|
+
if (!isBuffer_1(other)) return !1;
|
|
1473
|
+
objIsArr = !0, objIsObj = !1;
|
|
1474
|
+
}
|
|
1475
|
+
if (isSameTag && !objIsObj) return stack || (stack = new _Stack()), objIsArr || isTypedArray_1(object) ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack) : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
1476
|
+
if (!(1 & bitmask)) {
|
|
1477
|
+
var objIsWrapped = objIsObj && hasOwnProperty$2.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty$2.call(other, "__wrapped__");
|
|
1478
|
+
if (objIsWrapped || othIsWrapped) {
|
|
1479
|
+
var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
|
|
1480
|
+
return stack || (stack = new _Stack()), equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
return !!isSameTag && (stack || (stack = new _Stack()), _equalObjects(object, other, bitmask, customizer, equalFunc, stack));
|
|
1484
|
+
};
|
|
1485
|
+
var _baseIsEqual = function baseIsEqual(value, other, bitmask, customizer, stack) {
|
|
1486
|
+
return value === other || (null == value || null == other || !isObjectLike_1(value) && !isObjectLike_1(other) ? value != value && other != other : _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack));
|
|
1487
|
+
};
|
|
1488
|
+
var _baseIsMatch = function(object, source, matchData, customizer) {
|
|
1489
|
+
var index = matchData.length, length = index, noCustomizer = !customizer;
|
|
1490
|
+
if (null == object) return !length;
|
|
1491
|
+
for (object = Object(object); index--;) {
|
|
1492
|
+
var data = matchData[index];
|
|
1493
|
+
if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) return !1;
|
|
1494
|
+
}
|
|
1495
|
+
for (; ++index < length;) {
|
|
1496
|
+
var key = (data = matchData[index])[0], objValue = object[key], srcValue = data[1];
|
|
1497
|
+
if (noCustomizer && data[2]) {
|
|
1498
|
+
if (void 0 === objValue && !(key in object)) return !1;
|
|
1499
|
+
} else {
|
|
1500
|
+
var stack = new _Stack();
|
|
1501
|
+
if (customizer) var result = customizer(objValue, srcValue, key, object, source, stack);
|
|
1502
|
+
if (!(void 0 === result ? _baseIsEqual(srcValue, objValue, 3, customizer, stack) : result)) return !1;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
return !0;
|
|
1506
|
+
};
|
|
1507
|
+
var _isStrictComparable = function(value) {
|
|
1508
|
+
return value == value && !isObject_1(value);
|
|
1509
|
+
};
|
|
1510
|
+
var _getMatchData = function(object) {
|
|
1511
|
+
for (var result = keys_1(object), length = result.length; length--;) {
|
|
1512
|
+
var key = result[length], value = object[key];
|
|
1513
|
+
result[length] = [
|
|
1514
|
+
key,
|
|
1515
|
+
value,
|
|
1516
|
+
_isStrictComparable(value)
|
|
1517
|
+
];
|
|
1518
|
+
}
|
|
1519
|
+
return result;
|
|
1520
|
+
};
|
|
1521
|
+
var _matchesStrictComparable = function(key, srcValue) {
|
|
1522
|
+
return function(object) {
|
|
1523
|
+
return null != object && object[key] === srcValue && (void 0 !== srcValue || key in Object(object));
|
|
1524
|
+
};
|
|
1525
|
+
};
|
|
1526
|
+
var _baseMatches = function(source) {
|
|
1527
|
+
var matchData = _getMatchData(source);
|
|
1528
|
+
return 1 == matchData.length && matchData[0][2] ? _matchesStrictComparable(matchData[0][0], matchData[0][1]) : function(object) {
|
|
1529
|
+
return object === source || _baseIsMatch(object, source, matchData);
|
|
1530
|
+
};
|
|
1531
|
+
};
|
|
1532
|
+
var isSymbol_1 = function(value) {
|
|
1533
|
+
return "symbol" == typeof value || isObjectLike_1(value) && "[object Symbol]" == _baseGetTag(value);
|
|
1534
|
+
};
|
|
1535
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;
|
|
1536
|
+
var reIsPlainProp = /^\w*$/;
|
|
1537
|
+
var _isKey = function(value, object) {
|
|
1538
|
+
if (isArray_1(value)) return !1;
|
|
1539
|
+
var type = typeof value;
|
|
1540
|
+
return !("number" != type && "symbol" != type && "boolean" != type && null != value && !isSymbol_1(value)) || reIsPlainProp.test(value) || !reIsDeepProp.test(value) || null != object && value in Object(object);
|
|
1541
|
+
};
|
|
1542
|
+
function memoize(func, resolver) {
|
|
1543
|
+
if ("function" != typeof func || null != resolver && "function" != typeof resolver) throw new TypeError("Expected a function");
|
|
1544
|
+
var memoized = function() {
|
|
1545
|
+
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
|
|
1546
|
+
if (cache.has(key)) return cache.get(key);
|
|
1547
|
+
var result = func.apply(this, args);
|
|
1548
|
+
return memoized.cache = cache.set(key, result) || cache, result;
|
|
1549
|
+
};
|
|
1550
|
+
return memoized.cache = new (memoize.Cache || _MapCache)(), memoized;
|
|
1551
|
+
}
|
|
1552
|
+
memoize.Cache = _MapCache;
|
|
1553
|
+
var memoize_1 = memoize;
|
|
1554
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
1555
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
1556
|
+
var _stringToPath = function(func) {
|
|
1557
|
+
var result = memoize_1(func, (function(key) {
|
|
1558
|
+
return 500 === cache.size && cache.clear(), key;
|
|
1559
|
+
})), cache = result.cache;
|
|
1560
|
+
return result;
|
|
1561
|
+
}((function(string) {
|
|
1562
|
+
var result = [];
|
|
1563
|
+
return 46 === string.charCodeAt(0) && result.push(""), string.replace(rePropName, (function(match, number, quote, subString) {
|
|
1564
|
+
result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
|
|
1565
|
+
})), result;
|
|
1566
|
+
}));
|
|
1567
|
+
var _arrayMap = function(array, iteratee) {
|
|
1568
|
+
for (var index = -1, length = null == array ? 0 : array.length, result = Array(length); ++index < length;) result[index] = iteratee(array[index], index, array);
|
|
1569
|
+
return result;
|
|
1570
|
+
};
|
|
1571
|
+
var symbolProto = _Symbol ? _Symbol.prototype : void 0;
|
|
1572
|
+
var symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
1573
|
+
var _baseToString = function baseToString(value) {
|
|
1574
|
+
if ("string" == typeof value) return value;
|
|
1575
|
+
if (isArray_1(value)) return _arrayMap(value, baseToString) + "";
|
|
1576
|
+
if (isSymbol_1(value)) return symbolToString ? symbolToString.call(value) : "";
|
|
1577
|
+
var result = value + "";
|
|
1578
|
+
return "0" == result && 1 / value == -Infinity ? "-0" : result;
|
|
1579
|
+
};
|
|
1580
|
+
var toString_1 = function(value) {
|
|
1581
|
+
return null == value ? "" : _baseToString(value);
|
|
1582
|
+
};
|
|
1583
|
+
var _castPath = function(value, object) {
|
|
1584
|
+
return isArray_1(value) ? value : _isKey(value, object) ? [value] : _stringToPath(toString_1(value));
|
|
1585
|
+
};
|
|
1586
|
+
var _toKey = function(value) {
|
|
1587
|
+
if ("string" == typeof value || isSymbol_1(value)) return value;
|
|
1588
|
+
var result = value + "";
|
|
1589
|
+
return "0" == result && 1 / value == -Infinity ? "-0" : result;
|
|
1590
|
+
};
|
|
1591
|
+
var _baseGet = function(object, path) {
|
|
1592
|
+
for (var index = 0, length = (path = _castPath(path, object)).length; null != object && index < length;) object = object[_toKey(path[index++])];
|
|
1593
|
+
return index && index == length ? object : void 0;
|
|
1594
|
+
};
|
|
1595
|
+
var get_1 = function(object, path, defaultValue) {
|
|
1596
|
+
var result = null == object ? void 0 : _baseGet(object, path);
|
|
1597
|
+
return void 0 === result ? defaultValue : result;
|
|
1598
|
+
};
|
|
1599
|
+
var _baseHasIn = function(object, key) {
|
|
1600
|
+
return null != object && key in Object(object);
|
|
1601
|
+
};
|
|
1602
|
+
var _hasPath = function(object, path, hasFunc) {
|
|
1603
|
+
for (var index = -1, length = (path = _castPath(path, object)).length, result = !1; ++index < length;) {
|
|
1604
|
+
var key = _toKey(path[index]);
|
|
1605
|
+
if (!(result = null != object && hasFunc(object, key))) break;
|
|
1606
|
+
object = object[key];
|
|
1607
|
+
}
|
|
1608
|
+
return result || ++index != length ? result : !!(length = null == object ? 0 : object.length) && isLength_1(length) && _isIndex(key, length) && (isArray_1(object) || isArguments_1(object));
|
|
1609
|
+
};
|
|
1610
|
+
var hasIn_1 = function(object, path) {
|
|
1611
|
+
return null != object && _hasPath(object, path, _baseHasIn);
|
|
1612
|
+
};
|
|
1613
|
+
var _baseMatchesProperty = function(path, srcValue) {
|
|
1614
|
+
return _isKey(path) && _isStrictComparable(srcValue) ? _matchesStrictComparable(_toKey(path), srcValue) : function(object) {
|
|
1615
|
+
var objValue = get_1(object, path);
|
|
1616
|
+
return void 0 === objValue && objValue === srcValue ? hasIn_1(object, path) : _baseIsEqual(srcValue, objValue, 3);
|
|
1617
|
+
};
|
|
1618
|
+
};
|
|
1619
|
+
var identity_1 = function(value) {
|
|
1620
|
+
return value;
|
|
1621
|
+
};
|
|
1622
|
+
var _baseProperty = function(key) {
|
|
1623
|
+
return function(object) {
|
|
1624
|
+
return null == object ? void 0 : object[key];
|
|
1625
|
+
};
|
|
1626
|
+
};
|
|
1627
|
+
var _basePropertyDeep = function(path) {
|
|
1628
|
+
return function(object) {
|
|
1629
|
+
return _baseGet(object, path);
|
|
1630
|
+
};
|
|
1631
|
+
};
|
|
1632
|
+
var property_1 = function(path) {
|
|
1633
|
+
return _isKey(path) ? _baseProperty(_toKey(path)) : _basePropertyDeep(path);
|
|
1634
|
+
};
|
|
1635
|
+
var _baseIteratee = function(value) {
|
|
1636
|
+
return "function" == typeof value ? value : null == value ? identity_1 : "object" == typeof value ? isArray_1(value) ? _baseMatchesProperty(value[0], value[1]) : _baseMatches(value) : property_1(value);
|
|
1637
|
+
};
|
|
1638
|
+
function getChangeKey(change) {
|
|
1639
|
+
if (!change) throw new Error("change is not provided");
|
|
1640
|
+
if (isNormal(change)) return "N".concat(change.oldLineNumber);
|
|
1641
|
+
var prefix = isInsert(change) ? "I" : "D";
|
|
1642
|
+
return "".concat(prefix).concat(change.lineNumber);
|
|
1643
|
+
}
|
|
1644
|
+
getCorrespondingLineNumberFactory("old");
|
|
1645
|
+
var computeOldLineNumber = computeLineNumberFactory("old");
|
|
1646
|
+
var computeNewLineNumber = computeLineNumberFactory("new");
|
|
1647
|
+
findChangeByLineNumberFactory("old");
|
|
1648
|
+
findChangeByLineNumberFactory("new");
|
|
1649
|
+
getCorrespondingLineNumberFactory("new");
|
|
1650
|
+
getCorrespondingLineNumberFactory("old");
|
|
1651
|
+
var _defineProperty = function() {
|
|
1652
|
+
try {
|
|
1653
|
+
var func = _getNative(Object, "defineProperty");
|
|
1654
|
+
return func({}, "", {}), func;
|
|
1655
|
+
} catch (e) {}
|
|
1656
|
+
}();
|
|
1657
|
+
var _baseAssignValue = function(object, key, value) {
|
|
1658
|
+
"__proto__" == key && _defineProperty ? _defineProperty(object, key, {
|
|
1659
|
+
configurable: !0,
|
|
1660
|
+
enumerable: !0,
|
|
1661
|
+
value,
|
|
1662
|
+
writable: !0
|
|
1663
|
+
}) : object[key] = value;
|
|
1664
|
+
};
|
|
1665
|
+
var _createBaseFor = function(fromRight) {
|
|
1666
|
+
return function(object, iteratee, keysFunc) {
|
|
1667
|
+
for (var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length; length--;) {
|
|
1668
|
+
var key = props[fromRight ? length : ++index];
|
|
1669
|
+
if (!1 === iteratee(iterable[key], key, iterable)) break;
|
|
1670
|
+
}
|
|
1671
|
+
return object;
|
|
1672
|
+
};
|
|
1673
|
+
};
|
|
1674
|
+
var _baseFor = _createBaseFor();
|
|
1675
|
+
var _baseForOwn = function(object, iteratee) {
|
|
1676
|
+
return object && _baseFor(object, iteratee, keys_1);
|
|
1677
|
+
};
|
|
1678
|
+
var mapValues_1 = function(object, iteratee) {
|
|
1679
|
+
var result = {};
|
|
1680
|
+
return iteratee = _baseIteratee(iteratee), _baseForOwn(object, (function(value, key, object) {
|
|
1681
|
+
_baseAssignValue(result, key, iteratee(value, key, object));
|
|
1682
|
+
})), result;
|
|
1683
|
+
};
|
|
1684
|
+
var _excluded$7 = [
|
|
1685
|
+
"changeKey",
|
|
1686
|
+
"text",
|
|
1687
|
+
"tokens",
|
|
1688
|
+
"renderToken"
|
|
1689
|
+
];
|
|
1690
|
+
var defaultRenderToken = function defaultRenderToken(_ref, i) {
|
|
1691
|
+
var type = _ref.type, value = _ref.value, markType = _ref.markType, properties = _ref.properties, className = _ref.className, children = _ref.children, renderWithClassName = function(className) {
|
|
1692
|
+
return (0, import_jsx_runtime.jsx)("span", {
|
|
1693
|
+
className,
|
|
1694
|
+
children: value || children && children.map(defaultRenderToken)
|
|
1695
|
+
}, i);
|
|
1696
|
+
};
|
|
1697
|
+
switch (type) {
|
|
1698
|
+
case "text": return value;
|
|
1699
|
+
case "mark": return renderWithClassName("diff-code-mark diff-code-mark-".concat(markType));
|
|
1700
|
+
case "edit": return renderWithClassName("diff-code-edit");
|
|
1701
|
+
default:
|
|
1702
|
+
var legacyClassName = properties && properties.className;
|
|
1703
|
+
return renderWithClassName(classnames(className || legacyClassName));
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
function isEmptyToken(tokens) {
|
|
1707
|
+
if (!Array.isArray(tokens)) return !0;
|
|
1708
|
+
if (tokens.length > 1) return !1;
|
|
1709
|
+
if (1 === tokens.length) {
|
|
1710
|
+
var token = _slicedToArray(tokens, 1)[0];
|
|
1711
|
+
return "text" === token.type && !token.value;
|
|
1712
|
+
}
|
|
1713
|
+
return !0;
|
|
1714
|
+
}
|
|
1715
|
+
function CodeCell(props) {
|
|
1716
|
+
var changeKey = props.changeKey, text = props.text, tokens = props.tokens, renderToken = props.renderToken, attributes = _objectWithoutProperties(props, _excluded$7), actualRenderToken = renderToken ? function(token, i) {
|
|
1717
|
+
return renderToken(token, defaultRenderToken, i);
|
|
1718
|
+
} : defaultRenderToken;
|
|
1719
|
+
return (0, import_jsx_runtime.jsx)("td", _objectSpread2(_objectSpread2({}, attributes), {}, {
|
|
1720
|
+
"data-change-key": changeKey,
|
|
1721
|
+
children: tokens ? isEmptyToken(tokens) ? " " : tokens.map(actualRenderToken) : text || " "
|
|
1722
|
+
}));
|
|
1723
|
+
}
|
|
1724
|
+
var CodeCell$1 = memo(CodeCell);
|
|
1725
|
+
function renderDefaultBy(change, side) {
|
|
1726
|
+
return function() {
|
|
1727
|
+
var lineNumber = "old" === side ? computeOldLineNumber(change) : computeNewLineNumber(change);
|
|
1728
|
+
return -1 === lineNumber ? void 0 : lineNumber;
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
function wrapInAnchorBy(gutterAnchor, anchorTarget) {
|
|
1732
|
+
return function(element) {
|
|
1733
|
+
return gutterAnchor && element ? (0, import_jsx_runtime.jsx)("a", {
|
|
1734
|
+
href: anchorTarget ? "#" + anchorTarget : void 0,
|
|
1735
|
+
children: element
|
|
1736
|
+
}) : element;
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
function composeCallback(own, custom) {
|
|
1740
|
+
return custom ? function(e) {
|
|
1741
|
+
own(), custom(e);
|
|
1742
|
+
} : own;
|
|
1743
|
+
}
|
|
1744
|
+
function useBoundCallbacks(callbacks, arg, hoverOn, hoverOff) {
|
|
1745
|
+
return useMemo((function() {
|
|
1746
|
+
var output = mapValues_1(callbacks, (function(fn) {
|
|
1747
|
+
return function(e) {
|
|
1748
|
+
return fn && fn(arg, e);
|
|
1749
|
+
};
|
|
1750
|
+
}));
|
|
1751
|
+
return output.onMouseEnter = composeCallback(hoverOn, output.onMouseEnter), output.onMouseLeave = composeCallback(hoverOff, output.onMouseLeave), output;
|
|
1752
|
+
}), [
|
|
1753
|
+
callbacks,
|
|
1754
|
+
hoverOn,
|
|
1755
|
+
hoverOff,
|
|
1756
|
+
arg
|
|
1757
|
+
]);
|
|
1758
|
+
}
|
|
1759
|
+
function renderGutterCell(className, change, changeKey, side, gutterAnchor, anchorTarget, events, inHoverState, renderGutter) {
|
|
1760
|
+
var gutterOptions = {
|
|
1761
|
+
change,
|
|
1762
|
+
side,
|
|
1763
|
+
inHoverState,
|
|
1764
|
+
renderDefault: renderDefaultBy(change, side),
|
|
1765
|
+
wrapInAnchor: wrapInAnchorBy(gutterAnchor, anchorTarget)
|
|
1766
|
+
};
|
|
1767
|
+
return (0, import_jsx_runtime.jsx)("td", _objectSpread2(_objectSpread2({ className }, events), {}, {
|
|
1768
|
+
"data-change-key": changeKey,
|
|
1769
|
+
children: renderGutter(gutterOptions)
|
|
1770
|
+
}));
|
|
1771
|
+
}
|
|
1772
|
+
function UnifiedChange(props) {
|
|
1773
|
+
var _useState2, value, setValue, change = props.change, selected = props.selected, tokens = props.tokens, className = props.className, generateLineClassName = props.generateLineClassName, gutterClassName = props.gutterClassName, codeClassName = props.codeClassName, gutterEvents = props.gutterEvents, codeEvents = props.codeEvents, hideGutter = props.hideGutter, gutterAnchor = props.gutterAnchor, generateAnchorID = props.generateAnchorID, renderToken = props.renderToken, renderGutter = props.renderGutter, type = change.type, content = change.content, changeKey = getChangeKey(change), _useBoolean2 = _slicedToArray((_useState2 = _slicedToArray(useState(!1), 2), value = _useState2[0], setValue = _useState2[1], [
|
|
1774
|
+
value,
|
|
1775
|
+
useCallback((function() {
|
|
1776
|
+
return setValue(!0);
|
|
1777
|
+
}), []),
|
|
1778
|
+
useCallback((function() {
|
|
1779
|
+
return setValue(!1);
|
|
1780
|
+
}), [])
|
|
1781
|
+
]), 3), hover = _useBoolean2[0], hoverOn = _useBoolean2[1], hoverOff = _useBoolean2[2], eventArg = useMemo((function() {
|
|
1782
|
+
return { change };
|
|
1783
|
+
}), [change]), boundGutterEvents = useBoundCallbacks(gutterEvents, eventArg, hoverOn, hoverOff), boundCodeEvents = useBoundCallbacks(codeEvents, eventArg, hoverOn, hoverOff), anchorID = generateAnchorID(change), lineClassName = generateLineClassName({
|
|
1784
|
+
changes: [change],
|
|
1785
|
+
defaultGenerate: function() {
|
|
1786
|
+
return className;
|
|
1787
|
+
}
|
|
1788
|
+
}), gutterClassNameValue = classnames("diff-gutter", "diff-gutter-".concat(type), gutterClassName, { "diff-gutter-selected": selected }), codeClassNameValue = classnames("diff-code", "diff-code-".concat(type), codeClassName, { "diff-code-selected": selected });
|
|
1789
|
+
return (0, import_jsx_runtime.jsxs)("tr", {
|
|
1790
|
+
id: anchorID,
|
|
1791
|
+
className: classnames("diff-line", lineClassName),
|
|
1792
|
+
children: [
|
|
1793
|
+
!hideGutter && renderGutterCell(gutterClassNameValue, change, changeKey, "old", gutterAnchor, anchorID, boundGutterEvents, hover, renderGutter),
|
|
1794
|
+
!hideGutter && renderGutterCell(gutterClassNameValue, change, changeKey, "new", gutterAnchor, anchorID, boundGutterEvents, hover, renderGutter),
|
|
1795
|
+
(0, import_jsx_runtime.jsx)(CodeCell$1, _objectSpread2({
|
|
1796
|
+
className: codeClassNameValue,
|
|
1797
|
+
changeKey,
|
|
1798
|
+
text: content,
|
|
1799
|
+
tokens,
|
|
1800
|
+
renderToken
|
|
1801
|
+
}, boundCodeEvents))
|
|
1802
|
+
]
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
var UnifiedChange$1 = memo(UnifiedChange);
|
|
1806
|
+
function UnifiedWidget(_ref) {
|
|
1807
|
+
var hideGutter = _ref.hideGutter, element = _ref.element;
|
|
1808
|
+
return (0, import_jsx_runtime.jsx)("tr", {
|
|
1809
|
+
className: "diff-widget",
|
|
1810
|
+
children: (0, import_jsx_runtime.jsx)("td", {
|
|
1811
|
+
colSpan: hideGutter ? 1 : 3,
|
|
1812
|
+
className: "diff-widget-content",
|
|
1813
|
+
children: element
|
|
1814
|
+
})
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
var _excluded$6 = [
|
|
1818
|
+
"hideGutter",
|
|
1819
|
+
"selectedChanges",
|
|
1820
|
+
"tokens",
|
|
1821
|
+
"lineClassName"
|
|
1822
|
+
];
|
|
1823
|
+
var _excluded2$2 = [
|
|
1824
|
+
"hunk",
|
|
1825
|
+
"widgets",
|
|
1826
|
+
"className"
|
|
1827
|
+
];
|
|
1828
|
+
function UnifiedHunk(props) {
|
|
1829
|
+
var hunk = props.hunk, widgets = props.widgets, className = props.className, childrenProps = _objectWithoutProperties(props, _excluded2$2), elements = function(changes, widgets) {
|
|
1830
|
+
return changes.reduce((function(elements, change) {
|
|
1831
|
+
var key = getChangeKey(change);
|
|
1832
|
+
elements.push([
|
|
1833
|
+
"change",
|
|
1834
|
+
key,
|
|
1835
|
+
change
|
|
1836
|
+
]);
|
|
1837
|
+
var widget = widgets[key];
|
|
1838
|
+
return widget && elements.push([
|
|
1839
|
+
"widget",
|
|
1840
|
+
key,
|
|
1841
|
+
widget
|
|
1842
|
+
]), elements;
|
|
1843
|
+
}), []);
|
|
1844
|
+
}(hunk.changes, widgets);
|
|
1845
|
+
return (0, import_jsx_runtime.jsx)("tbody", {
|
|
1846
|
+
className: classnames("diff-hunk", className),
|
|
1847
|
+
children: elements.map((function(element) {
|
|
1848
|
+
return function(_ref, props) {
|
|
1849
|
+
var _ref2 = _slicedToArray(_ref, 3), type = _ref2[0], key = _ref2[1], value = _ref2[2], hideGutter = props.hideGutter, selectedChanges = props.selectedChanges, tokens = props.tokens, lineClassName = props.lineClassName, changeProps = _objectWithoutProperties(props, _excluded$6);
|
|
1850
|
+
if ("change" === type) {
|
|
1851
|
+
var side = isDelete(value) ? "old" : "new", lineNumber = isDelete(value) ? computeOldLineNumber(value) : computeNewLineNumber(value), tokensOfLine = tokens ? tokens[side][lineNumber - 1] : null;
|
|
1852
|
+
return (0, import_jsx_runtime.jsx)(UnifiedChange$1, _objectSpread2({
|
|
1853
|
+
className: lineClassName,
|
|
1854
|
+
change: value,
|
|
1855
|
+
hideGutter,
|
|
1856
|
+
selected: selectedChanges.includes(key),
|
|
1857
|
+
tokens: tokensOfLine
|
|
1858
|
+
}, changeProps), "change".concat(key));
|
|
1859
|
+
}
|
|
1860
|
+
return "widget" === type ? (0, import_jsx_runtime.jsx)(UnifiedWidget, {
|
|
1861
|
+
hideGutter,
|
|
1862
|
+
element: value
|
|
1863
|
+
}, "widget".concat(key)) : null;
|
|
1864
|
+
}(element, childrenProps);
|
|
1865
|
+
}))
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
var SIDE_OLD = 0;
|
|
1869
|
+
function useCallbackOnSide(side, setHover, change, customCallbacks) {
|
|
1870
|
+
var markHover = useCallback((function() {
|
|
1871
|
+
return setHover(side);
|
|
1872
|
+
}), [side, setHover]), unmarkHover = useCallback((function() {
|
|
1873
|
+
return setHover("");
|
|
1874
|
+
}), [setHover]);
|
|
1875
|
+
return useMemo((function() {
|
|
1876
|
+
var callbacks = mapValues_1(customCallbacks, (function(fn) {
|
|
1877
|
+
return function(e) {
|
|
1878
|
+
return fn && fn({
|
|
1879
|
+
side,
|
|
1880
|
+
change
|
|
1881
|
+
}, e);
|
|
1882
|
+
};
|
|
1883
|
+
}));
|
|
1884
|
+
return callbacks.onMouseEnter = composeCallback(markHover, callbacks.onMouseEnter), callbacks.onMouseLeave = composeCallback(unmarkHover, callbacks.onMouseLeave), callbacks;
|
|
1885
|
+
}), [
|
|
1886
|
+
change,
|
|
1887
|
+
customCallbacks,
|
|
1888
|
+
markHover,
|
|
1889
|
+
side,
|
|
1890
|
+
unmarkHover
|
|
1891
|
+
]);
|
|
1892
|
+
}
|
|
1893
|
+
function renderCells(args) {
|
|
1894
|
+
var change = args.change, side = args.side, selected = args.selected, tokens = args.tokens, gutterClassName = args.gutterClassName, codeClassName = args.codeClassName, gutterEvents = args.gutterEvents, codeEvents = args.codeEvents, anchorID = args.anchorID, gutterAnchor = args.gutterAnchor, gutterAnchorTarget = args.gutterAnchorTarget, hideGutter = args.hideGutter, hover = args.hover, renderToken = args.renderToken, renderGutter = args.renderGutter;
|
|
1895
|
+
if (!change) {
|
|
1896
|
+
var _gutterClassNameValue = classnames("diff-gutter", "diff-gutter-omit", gutterClassName), _codeClassNameValue = classnames("diff-code", "diff-code-omit", codeClassName);
|
|
1897
|
+
return [!hideGutter && (0, import_jsx_runtime.jsx)("td", { className: _gutterClassNameValue }, "gutter"), (0, import_jsx_runtime.jsx)("td", { className: _codeClassNameValue }, "code")];
|
|
1898
|
+
}
|
|
1899
|
+
var type = change.type, content = change.content, changeKey = getChangeKey(change), sideName = side === SIDE_OLD ? "old" : "new", gutterProps = _objectSpread2({
|
|
1900
|
+
id: anchorID || void 0,
|
|
1901
|
+
className: classnames("diff-gutter", "diff-gutter-".concat(type), _defineProperty$1({ "diff-gutter-selected": selected }, "diff-line-hover-" + sideName, hover), gutterClassName),
|
|
1902
|
+
children: renderGutter({
|
|
1903
|
+
change,
|
|
1904
|
+
side: sideName,
|
|
1905
|
+
inHoverState: hover,
|
|
1906
|
+
renderDefault: renderDefaultBy(change, sideName),
|
|
1907
|
+
wrapInAnchor: wrapInAnchorBy(gutterAnchor, gutterAnchorTarget)
|
|
1908
|
+
})
|
|
1909
|
+
}, gutterEvents), codeClassNameValue = classnames("diff-code", "diff-code-".concat(type), _defineProperty$1({ "diff-code-selected": selected }, "diff-line-hover-" + sideName, hover), codeClassName);
|
|
1910
|
+
return [!hideGutter && (0, import_jsx_runtime.jsx)("td", _objectSpread2(_objectSpread2({}, gutterProps), {}, { "data-change-key": changeKey }), "gutter"), (0, import_jsx_runtime.jsx)(CodeCell$1, _objectSpread2({
|
|
1911
|
+
className: codeClassNameValue,
|
|
1912
|
+
changeKey,
|
|
1913
|
+
text: content,
|
|
1914
|
+
tokens,
|
|
1915
|
+
renderToken
|
|
1916
|
+
}, codeEvents), "code")];
|
|
1917
|
+
}
|
|
1918
|
+
function SplitChange(props) {
|
|
1919
|
+
var className = props.className, oldChange = props.oldChange, newChange = props.newChange, oldSelected = props.oldSelected, newSelected = props.newSelected, oldTokens = props.oldTokens, newTokens = props.newTokens, monotonous = props.monotonous, gutterClassName = props.gutterClassName, codeClassName = props.codeClassName, gutterEvents = props.gutterEvents, codeEvents = props.codeEvents, hideGutter = props.hideGutter, generateAnchorID = props.generateAnchorID, generateLineClassName = props.generateLineClassName, gutterAnchor = props.gutterAnchor, renderToken = props.renderToken, renderGutter = props.renderGutter, _useState2 = _slicedToArray(useState(""), 2), hover = _useState2[0], setHover = _useState2[1], oldGutterEvents = useCallbackOnSide("old", setHover, oldChange, gutterEvents), newGutterEvents = useCallbackOnSide("new", setHover, newChange, gutterEvents), oldCodeEvents = useCallbackOnSide("old", setHover, oldChange, codeEvents), newCodeEvents = useCallbackOnSide("new", setHover, newChange, codeEvents), oldAnchorID = oldChange && generateAnchorID(oldChange), newAnchorID = newChange && generateAnchorID(newChange), lineClassName = generateLineClassName({
|
|
1920
|
+
changes: [oldChange, newChange],
|
|
1921
|
+
defaultGenerate: function() {
|
|
1922
|
+
return className;
|
|
1923
|
+
}
|
|
1924
|
+
}), commons = {
|
|
1925
|
+
monotonous,
|
|
1926
|
+
hideGutter,
|
|
1927
|
+
gutterClassName,
|
|
1928
|
+
codeClassName,
|
|
1929
|
+
gutterEvents,
|
|
1930
|
+
codeEvents,
|
|
1931
|
+
renderToken,
|
|
1932
|
+
renderGutter
|
|
1933
|
+
}, oldArgs = _objectSpread2(_objectSpread2({}, commons), {}, {
|
|
1934
|
+
change: oldChange,
|
|
1935
|
+
side: SIDE_OLD,
|
|
1936
|
+
selected: oldSelected,
|
|
1937
|
+
tokens: oldTokens,
|
|
1938
|
+
gutterEvents: oldGutterEvents,
|
|
1939
|
+
codeEvents: oldCodeEvents,
|
|
1940
|
+
anchorID: oldAnchorID,
|
|
1941
|
+
gutterAnchor,
|
|
1942
|
+
gutterAnchorTarget: oldAnchorID,
|
|
1943
|
+
hover: "old" === hover
|
|
1944
|
+
}), newArgs = _objectSpread2(_objectSpread2({}, commons), {}, {
|
|
1945
|
+
change: newChange,
|
|
1946
|
+
side: 1,
|
|
1947
|
+
selected: newSelected,
|
|
1948
|
+
tokens: newTokens,
|
|
1949
|
+
gutterEvents: newGutterEvents,
|
|
1950
|
+
codeEvents: newCodeEvents,
|
|
1951
|
+
anchorID: oldChange === newChange ? null : newAnchorID,
|
|
1952
|
+
gutterAnchor,
|
|
1953
|
+
gutterAnchorTarget: oldChange === newChange ? oldAnchorID : newAnchorID,
|
|
1954
|
+
hover: "new" === hover
|
|
1955
|
+
});
|
|
1956
|
+
if (monotonous) return (0, import_jsx_runtime.jsx)("tr", {
|
|
1957
|
+
className: classnames("diff-line", lineClassName),
|
|
1958
|
+
children: renderCells(oldChange ? oldArgs : newArgs)
|
|
1959
|
+
});
|
|
1960
|
+
return (0, import_jsx_runtime.jsxs)("tr", {
|
|
1961
|
+
className: classnames("diff-line", function(oldChange, newChange) {
|
|
1962
|
+
return oldChange && !newChange ? "diff-line-old-only" : !oldChange && newChange ? "diff-line-new-only" : oldChange === newChange ? "diff-line-normal" : "diff-line-compare";
|
|
1963
|
+
}(oldChange, newChange), lineClassName),
|
|
1964
|
+
children: [renderCells(oldArgs), renderCells(newArgs)]
|
|
1965
|
+
});
|
|
1966
|
+
}
|
|
1967
|
+
var SplitChange$1 = memo(SplitChange);
|
|
1968
|
+
function SplitWidget(_ref) {
|
|
1969
|
+
var hideGutter = _ref.hideGutter, oldElement = _ref.oldElement, newElement = _ref.newElement;
|
|
1970
|
+
return _ref.monotonous ? (0, import_jsx_runtime.jsx)("tr", {
|
|
1971
|
+
className: "diff-widget",
|
|
1972
|
+
children: (0, import_jsx_runtime.jsx)("td", {
|
|
1973
|
+
colSpan: hideGutter ? 1 : 2,
|
|
1974
|
+
className: "diff-widget-content",
|
|
1975
|
+
children: oldElement || newElement
|
|
1976
|
+
})
|
|
1977
|
+
}) : oldElement === newElement ? (0, import_jsx_runtime.jsx)("tr", {
|
|
1978
|
+
className: "diff-widget",
|
|
1979
|
+
children: (0, import_jsx_runtime.jsx)("td", {
|
|
1980
|
+
colSpan: hideGutter ? 2 : 4,
|
|
1981
|
+
className: "diff-widget-content",
|
|
1982
|
+
children: oldElement
|
|
1983
|
+
})
|
|
1984
|
+
}) : (0, import_jsx_runtime.jsxs)("tr", {
|
|
1985
|
+
className: "diff-widget",
|
|
1986
|
+
children: [(0, import_jsx_runtime.jsx)("td", {
|
|
1987
|
+
colSpan: hideGutter ? 1 : 2,
|
|
1988
|
+
className: "diff-widget-content",
|
|
1989
|
+
children: oldElement
|
|
1990
|
+
}), (0, import_jsx_runtime.jsx)("td", {
|
|
1991
|
+
colSpan: hideGutter ? 1 : 2,
|
|
1992
|
+
className: "diff-widget-content",
|
|
1993
|
+
children: newElement
|
|
1994
|
+
})]
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
var _excluded$5 = [
|
|
1998
|
+
"selectedChanges",
|
|
1999
|
+
"monotonous",
|
|
2000
|
+
"hideGutter",
|
|
2001
|
+
"tokens",
|
|
2002
|
+
"lineClassName"
|
|
2003
|
+
];
|
|
2004
|
+
var _excluded2$1 = [
|
|
2005
|
+
"hunk",
|
|
2006
|
+
"widgets",
|
|
2007
|
+
"className"
|
|
2008
|
+
];
|
|
2009
|
+
function keyForPair(x, y) {
|
|
2010
|
+
return (x ? getChangeKey(x) : "00") + (y ? getChangeKey(y) : "00");
|
|
2011
|
+
}
|
|
2012
|
+
function SplitHunk(props) {
|
|
2013
|
+
var hunk = props.hunk, widgets = props.widgets, className = props.className, childrenProps = _objectWithoutProperties(props, _excluded2$1), elements = function(changes, widgets) {
|
|
2014
|
+
for (var findWidget = function(change) {
|
|
2015
|
+
if (!change) return null;
|
|
2016
|
+
return widgets[getChangeKey(change)] || null;
|
|
2017
|
+
}, elements = [], i = 0; i < changes.length; i++) {
|
|
2018
|
+
var current = changes[i];
|
|
2019
|
+
if (isNormal(current)) elements.push([
|
|
2020
|
+
"change",
|
|
2021
|
+
keyForPair(current, current),
|
|
2022
|
+
current,
|
|
2023
|
+
current
|
|
2024
|
+
]);
|
|
2025
|
+
else if (isDelete(current)) {
|
|
2026
|
+
var next = changes[i + 1];
|
|
2027
|
+
next && isInsert(next) ? (i += 1, elements.push([
|
|
2028
|
+
"change",
|
|
2029
|
+
keyForPair(current, next),
|
|
2030
|
+
current,
|
|
2031
|
+
next
|
|
2032
|
+
])) : elements.push([
|
|
2033
|
+
"change",
|
|
2034
|
+
keyForPair(current, null),
|
|
2035
|
+
current,
|
|
2036
|
+
null
|
|
2037
|
+
]);
|
|
2038
|
+
} else elements.push([
|
|
2039
|
+
"change",
|
|
2040
|
+
keyForPair(null, current),
|
|
2041
|
+
null,
|
|
2042
|
+
current
|
|
2043
|
+
]);
|
|
2044
|
+
var rowChanges = elements[elements.length - 1], oldWidget = findWidget(rowChanges[2]), newWidget = findWidget(rowChanges[3]);
|
|
2045
|
+
if (oldWidget || newWidget) {
|
|
2046
|
+
var key = rowChanges[1];
|
|
2047
|
+
elements.push([
|
|
2048
|
+
"widget",
|
|
2049
|
+
key,
|
|
2050
|
+
oldWidget,
|
|
2051
|
+
newWidget
|
|
2052
|
+
]);
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
return elements;
|
|
2056
|
+
}(hunk.changes, widgets);
|
|
2057
|
+
return (0, import_jsx_runtime.jsx)("tbody", {
|
|
2058
|
+
className: classnames("diff-hunk", className),
|
|
2059
|
+
children: elements.map((function(item) {
|
|
2060
|
+
return function(_ref, props) {
|
|
2061
|
+
var _ref2 = _slicedToArray(_ref, 4), type = _ref2[0], key = _ref2[1], oldValue = _ref2[2], newValue = _ref2[3], selectedChanges = props.selectedChanges, monotonous = props.monotonous, hideGutter = props.hideGutter, tokens = props.tokens, lineClassName = props.lineClassName, changeProps = _objectWithoutProperties(props, _excluded$5);
|
|
2062
|
+
if ("change" === type) {
|
|
2063
|
+
var oldSelected = !!oldValue && selectedChanges.includes(getChangeKey(oldValue)), newSelected = !!newValue && selectedChanges.includes(getChangeKey(newValue)), oldTokens = oldValue && tokens ? tokens.old[computeOldLineNumber(oldValue) - 1] : null, newTokens = newValue && tokens ? tokens.new[computeNewLineNumber(newValue) - 1] : null;
|
|
2064
|
+
return (0, import_jsx_runtime.jsx)(SplitChange$1, _objectSpread2({
|
|
2065
|
+
className: lineClassName,
|
|
2066
|
+
oldChange: oldValue,
|
|
2067
|
+
newChange: newValue,
|
|
2068
|
+
monotonous,
|
|
2069
|
+
hideGutter,
|
|
2070
|
+
oldSelected,
|
|
2071
|
+
newSelected,
|
|
2072
|
+
oldTokens,
|
|
2073
|
+
newTokens
|
|
2074
|
+
}, changeProps), "change".concat(key));
|
|
2075
|
+
}
|
|
2076
|
+
return "widget" === type ? (0, import_jsx_runtime.jsx)(SplitWidget, {
|
|
2077
|
+
monotonous,
|
|
2078
|
+
hideGutter,
|
|
2079
|
+
oldElement: oldValue,
|
|
2080
|
+
newElement: newValue
|
|
2081
|
+
}, "widget".concat(key)) : null;
|
|
2082
|
+
}(item, childrenProps);
|
|
2083
|
+
}))
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
var _excluded$4 = ["gutterType", "hunkClassName"];
|
|
2087
|
+
function Hunk(_ref) {
|
|
2088
|
+
var hunk = _ref.hunk, _useDiffSettings = useDiffSettings(), gutterType = _useDiffSettings.gutterType, hunkClassName = _useDiffSettings.hunkClassName, context = _objectWithoutProperties(_useDiffSettings, _excluded$4), hideGutter = "none" === gutterType, gutterAnchor = "anchor" === gutterType, RenderingHunk = "unified" === context.viewType ? UnifiedHunk : SplitHunk;
|
|
2089
|
+
return (0, import_jsx_runtime.jsx)(RenderingHunk, _objectSpread2(_objectSpread2({}, context), {}, {
|
|
2090
|
+
hunk,
|
|
2091
|
+
hideGutter,
|
|
2092
|
+
gutterAnchor,
|
|
2093
|
+
className: hunkClassName
|
|
2094
|
+
}));
|
|
2095
|
+
}
|
|
2096
|
+
function noop() {}
|
|
2097
|
+
function setUserSelectStyle(element, selectable) {
|
|
2098
|
+
var value = selectable ? "auto" : "none";
|
|
2099
|
+
element instanceof HTMLElement && element.style.userSelect !== value && (element.style.userSelect = value);
|
|
2100
|
+
}
|
|
2101
|
+
function defaultRenderChildren(hunks) {
|
|
2102
|
+
return hunks.map((function(hunk) {
|
|
2103
|
+
return (0, import_jsx_runtime.jsx)(Hunk, { hunk }, function(hunk) {
|
|
2104
|
+
return "-".concat(hunk.oldStart, ",").concat(hunk.oldLines, " +").concat(hunk.newStart, ",").concat(hunk.newLines);
|
|
2105
|
+
}(hunk));
|
|
2106
|
+
}));
|
|
2107
|
+
}
|
|
2108
|
+
function Diff(props) {
|
|
2109
|
+
var diffType = props.diffType, hunks = props.hunks, optimizeSelection = props.optimizeSelection, className = props.className, _props$hunkClassName = props.hunkClassName, hunkClassName = void 0 === _props$hunkClassName ? DEFAULT_CONTEXT_VALUE.hunkClassName : _props$hunkClassName, _props$lineClassName = props.lineClassName, lineClassName = void 0 === _props$lineClassName ? DEFAULT_CONTEXT_VALUE.lineClassName : _props$lineClassName, _props$generateLineCl = props.generateLineClassName, generateLineClassName = void 0 === _props$generateLineCl ? DEFAULT_CONTEXT_VALUE.generateLineClassName : _props$generateLineCl, _props$gutterClassNam = props.gutterClassName, gutterClassName = void 0 === _props$gutterClassNam ? DEFAULT_CONTEXT_VALUE.gutterClassName : _props$gutterClassNam, _props$codeClassName = props.codeClassName, codeClassName = void 0 === _props$codeClassName ? DEFAULT_CONTEXT_VALUE.codeClassName : _props$codeClassName, _props$gutterType = props.gutterType, gutterType = void 0 === _props$gutterType ? DEFAULT_CONTEXT_VALUE.gutterType : _props$gutterType, _props$viewType = props.viewType, viewType = void 0 === _props$viewType ? DEFAULT_CONTEXT_VALUE.viewType : _props$viewType, _props$gutterEvents = props.gutterEvents, gutterEvents = void 0 === _props$gutterEvents ? DEFAULT_CONTEXT_VALUE.gutterEvents : _props$gutterEvents, _props$codeEvents = props.codeEvents, codeEvents = void 0 === _props$codeEvents ? DEFAULT_CONTEXT_VALUE.codeEvents : _props$codeEvents, _props$generateAnchor = props.generateAnchorID, generateAnchorID = void 0 === _props$generateAnchor ? DEFAULT_CONTEXT_VALUE.generateAnchorID : _props$generateAnchor, _props$selectedChange = props.selectedChanges, selectedChanges = void 0 === _props$selectedChange ? DEFAULT_CONTEXT_VALUE.selectedChanges : _props$selectedChange, _props$widgets = props.widgets, widgets = void 0 === _props$widgets ? DEFAULT_CONTEXT_VALUE.widgets : _props$widgets, _props$renderGutter = props.renderGutter, renderGutter = void 0 === _props$renderGutter ? DEFAULT_CONTEXT_VALUE.renderGutter : _props$renderGutter, tokens = props.tokens, renderToken = props.renderToken, _props$children = props.children, children = void 0 === _props$children ? defaultRenderChildren : _props$children, root = useRef(null), enableColumnSelection = useCallback((function(_ref) {
|
|
2110
|
+
var target = _ref.target;
|
|
2111
|
+
if (0 === _ref.button) {
|
|
2112
|
+
var closestCell = function(target, className) {
|
|
2113
|
+
for (var current = target; current && current !== document.documentElement && !current.classList.contains(className);) current = current.parentElement;
|
|
2114
|
+
return current === document.documentElement ? null : current;
|
|
2115
|
+
}(target, "diff-code");
|
|
2116
|
+
if (closestCell && closestCell.parentElement) {
|
|
2117
|
+
var selection = window.getSelection();
|
|
2118
|
+
selection && selection.removeAllRanges();
|
|
2119
|
+
var index = _toConsumableArray(closestCell.parentElement.children).indexOf(closestCell);
|
|
2120
|
+
if (1 === index || 3 === index) {
|
|
2121
|
+
var _step, _iterator = _createForOfIteratorHelper(root.current ? root.current.querySelectorAll(".diff-line") : []);
|
|
2122
|
+
try {
|
|
2123
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2124
|
+
var cells = _step.value.children;
|
|
2125
|
+
setUserSelectStyle(cells[1], 1 === index), setUserSelectStyle(cells[3], 3 === index);
|
|
2126
|
+
}
|
|
2127
|
+
} catch (err) {
|
|
2128
|
+
_iterator.e(err);
|
|
2129
|
+
} finally {
|
|
2130
|
+
_iterator.f();
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
}), []), hideGutter = "none" === gutterType, monotonous = "add" === diffType || "delete" === diffType, onTableMouseDown = "split" === viewType && !monotonous && optimizeSelection ? enableColumnSelection : noop, cols = useMemo((function() {
|
|
2136
|
+
return (0, import_jsx_runtime.jsxs)("colgroup", "unified" === viewType ? { children: [
|
|
2137
|
+
!hideGutter && (0, import_jsx_runtime.jsx)("col", { className: "diff-gutter-col" }),
|
|
2138
|
+
!hideGutter && (0, import_jsx_runtime.jsx)("col", { className: "diff-gutter-col" }),
|
|
2139
|
+
(0, import_jsx_runtime.jsx)("col", {})
|
|
2140
|
+
] } : monotonous ? { children: [!hideGutter && (0, import_jsx_runtime.jsx)("col", { className: "diff-gutter-col" }), (0, import_jsx_runtime.jsx)("col", {})] } : { children: [
|
|
2141
|
+
!hideGutter && (0, import_jsx_runtime.jsx)("col", { className: "diff-gutter-col" }),
|
|
2142
|
+
(0, import_jsx_runtime.jsx)("col", {}),
|
|
2143
|
+
!hideGutter && (0, import_jsx_runtime.jsx)("col", { className: "diff-gutter-col" }),
|
|
2144
|
+
(0, import_jsx_runtime.jsx)("col", {})
|
|
2145
|
+
] });
|
|
2146
|
+
}), [
|
|
2147
|
+
viewType,
|
|
2148
|
+
monotonous,
|
|
2149
|
+
hideGutter
|
|
2150
|
+
]), settingsContextValue = useMemo((function() {
|
|
2151
|
+
return {
|
|
2152
|
+
hunkClassName,
|
|
2153
|
+
lineClassName,
|
|
2154
|
+
generateLineClassName,
|
|
2155
|
+
gutterClassName,
|
|
2156
|
+
codeClassName,
|
|
2157
|
+
monotonous,
|
|
2158
|
+
hideGutter,
|
|
2159
|
+
viewType,
|
|
2160
|
+
gutterType,
|
|
2161
|
+
codeEvents,
|
|
2162
|
+
gutterEvents,
|
|
2163
|
+
generateAnchorID,
|
|
2164
|
+
selectedChanges,
|
|
2165
|
+
widgets,
|
|
2166
|
+
renderGutter,
|
|
2167
|
+
tokens,
|
|
2168
|
+
renderToken
|
|
2169
|
+
};
|
|
2170
|
+
}), [
|
|
2171
|
+
codeClassName,
|
|
2172
|
+
codeEvents,
|
|
2173
|
+
generateAnchorID,
|
|
2174
|
+
gutterClassName,
|
|
2175
|
+
gutterEvents,
|
|
2176
|
+
gutterType,
|
|
2177
|
+
hideGutter,
|
|
2178
|
+
hunkClassName,
|
|
2179
|
+
lineClassName,
|
|
2180
|
+
generateLineClassName,
|
|
2181
|
+
monotonous,
|
|
2182
|
+
renderGutter,
|
|
2183
|
+
renderToken,
|
|
2184
|
+
selectedChanges,
|
|
2185
|
+
tokens,
|
|
2186
|
+
viewType,
|
|
2187
|
+
widgets
|
|
2188
|
+
]);
|
|
2189
|
+
return (0, import_jsx_runtime.jsx)(Provider, {
|
|
2190
|
+
value: settingsContextValue,
|
|
2191
|
+
children: (0, import_jsx_runtime.jsxs)("table", {
|
|
2192
|
+
ref: root,
|
|
2193
|
+
className: classnames("diff", "diff-".concat(viewType), className),
|
|
2194
|
+
onMouseDown: onTableMouseDown,
|
|
2195
|
+
children: [cols, children(hunks)]
|
|
2196
|
+
})
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
var index = memo(Diff);
|
|
2200
|
+
if ("production" !== process.env.NODE_ENV) var printWarning = function(format, args) {
|
|
2201
|
+
var len = arguments.length;
|
|
2202
|
+
args = new Array(len > 1 ? len - 1 : 0);
|
|
2203
|
+
for (var key = 1; key < len; key++) args[key - 1] = arguments[key];
|
|
2204
|
+
var argIndex = 0, message = "Warning: " + format.replace(/%s/g, (function() {
|
|
2205
|
+
return args[argIndex++];
|
|
2206
|
+
}));
|
|
2207
|
+
"undefined" != typeof console && console.error(message);
|
|
2208
|
+
try {
|
|
2209
|
+
throw new Error(message);
|
|
2210
|
+
} catch (x) {}
|
|
2211
|
+
};
|
|
2212
|
+
_Symbol && _Symbol.isConcatSpreadable;
|
|
2213
|
+
var diffMatchPatch = createCommonjsModule((function(module) {
|
|
2214
|
+
var diff_match_patch = function() {
|
|
2215
|
+
this.Diff_Timeout = 1, this.Diff_EditCost = 4, this.Match_Threshold = .5, this.Match_Distance = 1e3, this.Patch_DeleteThreshold = .5, this.Patch_Margin = 4, this.Match_MaxBits = 32;
|
|
2216
|
+
};
|
|
2217
|
+
diff_match_patch.Diff = function(op, text) {
|
|
2218
|
+
return [op, text];
|
|
2219
|
+
}, diff_match_patch.prototype.diff_main = function(text1, text2, opt_checklines, opt_deadline) {
|
|
2220
|
+
void 0 === opt_deadline && (opt_deadline = this.Diff_Timeout <= 0 ? Number.MAX_VALUE : (/* @__PURE__ */ new Date()).getTime() + 1e3 * this.Diff_Timeout);
|
|
2221
|
+
var deadline = opt_deadline;
|
|
2222
|
+
if (null == text1 || null == text2) throw new Error("Null input. (diff_main)");
|
|
2223
|
+
if (text1 == text2) return text1 ? [new diff_match_patch.Diff(0, text1)] : [];
|
|
2224
|
+
void 0 === opt_checklines && (opt_checklines = !0);
|
|
2225
|
+
var checklines = opt_checklines, commonlength = this.diff_commonPrefix(text1, text2), commonprefix = text1.substring(0, commonlength);
|
|
2226
|
+
text1 = text1.substring(commonlength), text2 = text2.substring(commonlength), commonlength = this.diff_commonSuffix(text1, text2);
|
|
2227
|
+
var commonsuffix = text1.substring(text1.length - commonlength);
|
|
2228
|
+
text1 = text1.substring(0, text1.length - commonlength), text2 = text2.substring(0, text2.length - commonlength);
|
|
2229
|
+
var diffs = this.diff_compute_(text1, text2, checklines, deadline);
|
|
2230
|
+
return commonprefix && diffs.unshift(new diff_match_patch.Diff(0, commonprefix)), commonsuffix && diffs.push(new diff_match_patch.Diff(0, commonsuffix)), this.diff_cleanupMerge(diffs), diffs;
|
|
2231
|
+
}, diff_match_patch.prototype.diff_compute_ = function(text1, text2, checklines, deadline) {
|
|
2232
|
+
var diffs;
|
|
2233
|
+
if (!text1) return [new diff_match_patch.Diff(1, text2)];
|
|
2234
|
+
if (!text2) return [new diff_match_patch.Diff(-1, text1)];
|
|
2235
|
+
var longtext = text1.length > text2.length ? text1 : text2, shorttext = text1.length > text2.length ? text2 : text1, i = longtext.indexOf(shorttext);
|
|
2236
|
+
if (-1 != i) return diffs = [
|
|
2237
|
+
new diff_match_patch.Diff(1, longtext.substring(0, i)),
|
|
2238
|
+
new diff_match_patch.Diff(0, shorttext),
|
|
2239
|
+
new diff_match_patch.Diff(1, longtext.substring(i + shorttext.length))
|
|
2240
|
+
], text1.length > text2.length && (diffs[0][0] = diffs[2][0] = -1), diffs;
|
|
2241
|
+
if (1 == shorttext.length) return [new diff_match_patch.Diff(-1, text1), new diff_match_patch.Diff(1, text2)];
|
|
2242
|
+
var hm = this.diff_halfMatch_(text1, text2);
|
|
2243
|
+
if (hm) {
|
|
2244
|
+
var text1_a = hm[0], text1_b = hm[1], text2_a = hm[2], text2_b = hm[3], mid_common = hm[4], diffs_a = this.diff_main(text1_a, text2_a, checklines, deadline), diffs_b = this.diff_main(text1_b, text2_b, checklines, deadline);
|
|
2245
|
+
return diffs_a.concat([new diff_match_patch.Diff(0, mid_common)], diffs_b);
|
|
2246
|
+
}
|
|
2247
|
+
return checklines && text1.length > 100 && text2.length > 100 ? this.diff_lineMode_(text1, text2, deadline) : this.diff_bisect_(text1, text2, deadline);
|
|
2248
|
+
}, diff_match_patch.prototype.diff_lineMode_ = function(text1, text2, deadline) {
|
|
2249
|
+
var a = this.diff_linesToChars_(text1, text2);
|
|
2250
|
+
text1 = a.chars1, text2 = a.chars2;
|
|
2251
|
+
var linearray = a.lineArray, diffs = this.diff_main(text1, text2, !1, deadline);
|
|
2252
|
+
this.diff_charsToLines_(diffs, linearray), this.diff_cleanupSemantic(diffs), diffs.push(new diff_match_patch.Diff(0, ""));
|
|
2253
|
+
for (var pointer = 0, count_delete = 0, count_insert = 0, text_delete = "", text_insert = ""; pointer < diffs.length;) {
|
|
2254
|
+
switch (diffs[pointer][0]) {
|
|
2255
|
+
case 1:
|
|
2256
|
+
count_insert++, text_insert += diffs[pointer][1];
|
|
2257
|
+
break;
|
|
2258
|
+
case -1:
|
|
2259
|
+
count_delete++, text_delete += diffs[pointer][1];
|
|
2260
|
+
break;
|
|
2261
|
+
case 0:
|
|
2262
|
+
if (count_delete >= 1 && count_insert >= 1) {
|
|
2263
|
+
diffs.splice(pointer - count_delete - count_insert, count_delete + count_insert), pointer = pointer - count_delete - count_insert;
|
|
2264
|
+
for (var subDiff = this.diff_main(text_delete, text_insert, !1, deadline), j = subDiff.length - 1; j >= 0; j--) diffs.splice(pointer, 0, subDiff[j]);
|
|
2265
|
+
pointer += subDiff.length;
|
|
2266
|
+
}
|
|
2267
|
+
count_insert = 0, count_delete = 0, text_delete = "", text_insert = "";
|
|
2268
|
+
}
|
|
2269
|
+
pointer++;
|
|
2270
|
+
}
|
|
2271
|
+
return diffs.pop(), diffs;
|
|
2272
|
+
}, diff_match_patch.prototype.diff_bisect_ = function(text1, text2, deadline) {
|
|
2273
|
+
for (var text1_length = text1.length, text2_length = text2.length, max_d = Math.ceil((text1_length + text2_length) / 2), v_offset = max_d, v_length = 2 * max_d, v1 = new Array(v_length), v2 = new Array(v_length), x = 0; x < v_length; x++) v1[x] = -1, v2[x] = -1;
|
|
2274
|
+
v1[v_offset + 1] = 0, v2[v_offset + 1] = 0;
|
|
2275
|
+
for (var delta = text1_length - text2_length, front = delta % 2 != 0, k1start = 0, k1end = 0, k2start = 0, k2end = 0, d = 0; d < max_d && !((/* @__PURE__ */ new Date()).getTime() > deadline); d++) {
|
|
2276
|
+
for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) {
|
|
2277
|
+
for (var k1_offset = v_offset + k1, y1 = (x1 = k1 == -d || k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1] ? v1[k1_offset + 1] : v1[k1_offset - 1] + 1) - k1; x1 < text1_length && y1 < text2_length && text1.charAt(x1) == text2.charAt(y1);) x1++, y1++;
|
|
2278
|
+
if (v1[k1_offset] = x1, x1 > text1_length) k1end += 2;
|
|
2279
|
+
else if (y1 > text2_length) k1start += 2;
|
|
2280
|
+
else if (front) {
|
|
2281
|
+
if ((k2_offset = v_offset + delta - k1) >= 0 && k2_offset < v_length && -1 != v2[k2_offset]) {
|
|
2282
|
+
if (x1 >= (x2 = text1_length - v2[k2_offset])) return this.diff_bisectSplit_(text1, text2, x1, y1, deadline);
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) {
|
|
2287
|
+
for (var x2, k2_offset = v_offset + k2, y2 = (x2 = k2 == -d || k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1] ? v2[k2_offset + 1] : v2[k2_offset - 1] + 1) - k2; x2 < text1_length && y2 < text2_length && text1.charAt(text1_length - x2 - 1) == text2.charAt(text2_length - y2 - 1);) x2++, y2++;
|
|
2288
|
+
if (v2[k2_offset] = x2, x2 > text1_length) k2end += 2;
|
|
2289
|
+
else if (y2 > text2_length) k2start += 2;
|
|
2290
|
+
else if (!front) {
|
|
2291
|
+
if ((k1_offset = v_offset + delta - k2) >= 0 && k1_offset < v_length && -1 != v1[k1_offset]) {
|
|
2292
|
+
var x1;
|
|
2293
|
+
y1 = v_offset + (x1 = v1[k1_offset]) - k1_offset;
|
|
2294
|
+
if (x1 >= (x2 = text1_length - x2)) return this.diff_bisectSplit_(text1, text2, x1, y1, deadline);
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
return [new diff_match_patch.Diff(-1, text1), new diff_match_patch.Diff(1, text2)];
|
|
2300
|
+
}, diff_match_patch.prototype.diff_bisectSplit_ = function(text1, text2, x, y, deadline) {
|
|
2301
|
+
var text1a = text1.substring(0, x), text2a = text2.substring(0, y), text1b = text1.substring(x), text2b = text2.substring(y), diffs = this.diff_main(text1a, text2a, !1, deadline), diffsb = this.diff_main(text1b, text2b, !1, deadline);
|
|
2302
|
+
return diffs.concat(diffsb);
|
|
2303
|
+
}, diff_match_patch.prototype.diff_linesToChars_ = function(text1, text2) {
|
|
2304
|
+
var lineArray = [], lineHash = {};
|
|
2305
|
+
function diff_linesToCharsMunge_(text) {
|
|
2306
|
+
for (var chars = "", lineStart = 0, lineEnd = -1, lineArrayLength = lineArray.length; lineEnd < text.length - 1;) {
|
|
2307
|
+
-1 == (lineEnd = text.indexOf("\n", lineStart)) && (lineEnd = text.length - 1);
|
|
2308
|
+
var line = text.substring(lineStart, lineEnd + 1);
|
|
2309
|
+
(lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : void 0 !== lineHash[line]) ? chars += String.fromCharCode(lineHash[line]) : (lineArrayLength == maxLines && (line = text.substring(lineStart), lineEnd = text.length), chars += String.fromCharCode(lineArrayLength), lineHash[line] = lineArrayLength, lineArray[lineArrayLength++] = line), lineStart = lineEnd + 1;
|
|
2310
|
+
}
|
|
2311
|
+
return chars;
|
|
2312
|
+
}
|
|
2313
|
+
lineArray[0] = "";
|
|
2314
|
+
var maxLines = 4e4, chars1 = diff_linesToCharsMunge_(text1);
|
|
2315
|
+
return maxLines = 65535, {
|
|
2316
|
+
chars1,
|
|
2317
|
+
chars2: diff_linesToCharsMunge_(text2),
|
|
2318
|
+
lineArray
|
|
2319
|
+
};
|
|
2320
|
+
}, diff_match_patch.prototype.diff_charsToLines_ = function(diffs, lineArray) {
|
|
2321
|
+
for (var i = 0; i < diffs.length; i++) {
|
|
2322
|
+
for (var chars = diffs[i][1], text = [], j = 0; j < chars.length; j++) text[j] = lineArray[chars.charCodeAt(j)];
|
|
2323
|
+
diffs[i][1] = text.join("");
|
|
2324
|
+
}
|
|
2325
|
+
}, diff_match_patch.prototype.diff_commonPrefix = function(text1, text2) {
|
|
2326
|
+
if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) return 0;
|
|
2327
|
+
for (var pointermin = 0, pointermax = Math.min(text1.length, text2.length), pointermid = pointermax, pointerstart = 0; pointermin < pointermid;) text1.substring(pointerstart, pointermid) == text2.substring(pointerstart, pointermid) ? pointerstart = pointermin = pointermid : pointermax = pointermid, pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
|
2328
|
+
return pointermid;
|
|
2329
|
+
}, diff_match_patch.prototype.diff_commonSuffix = function(text1, text2) {
|
|
2330
|
+
if (!text1 || !text2 || text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) return 0;
|
|
2331
|
+
for (var pointermin = 0, pointermax = Math.min(text1.length, text2.length), pointermid = pointermax, pointerend = 0; pointermin < pointermid;) text1.substring(text1.length - pointermid, text1.length - pointerend) == text2.substring(text2.length - pointermid, text2.length - pointerend) ? pointerend = pointermin = pointermid : pointermax = pointermid, pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin);
|
|
2332
|
+
return pointermid;
|
|
2333
|
+
}, diff_match_patch.prototype.diff_commonOverlap_ = function(text1, text2) {
|
|
2334
|
+
var text1_length = text1.length, text2_length = text2.length;
|
|
2335
|
+
if (0 == text1_length || 0 == text2_length) return 0;
|
|
2336
|
+
text1_length > text2_length ? text1 = text1.substring(text1_length - text2_length) : text1_length < text2_length && (text2 = text2.substring(0, text1_length));
|
|
2337
|
+
var text_length = Math.min(text1_length, text2_length);
|
|
2338
|
+
if (text1 == text2) return text_length;
|
|
2339
|
+
for (var best = 0, length = 1;;) {
|
|
2340
|
+
var pattern = text1.substring(text_length - length), found = text2.indexOf(pattern);
|
|
2341
|
+
if (-1 == found) return best;
|
|
2342
|
+
length += found, 0 != found && text1.substring(text_length - length) != text2.substring(0, length) || (best = length, length++);
|
|
2343
|
+
}
|
|
2344
|
+
}, diff_match_patch.prototype.diff_halfMatch_ = function(text1, text2) {
|
|
2345
|
+
if (this.Diff_Timeout <= 0) return null;
|
|
2346
|
+
var longtext = text1.length > text2.length ? text1 : text2, shorttext = text1.length > text2.length ? text2 : text1;
|
|
2347
|
+
if (longtext.length < 4 || 2 * shorttext.length < longtext.length) return null;
|
|
2348
|
+
var dmp = this;
|
|
2349
|
+
function diff_halfMatchI_(longtext, shorttext, i) {
|
|
2350
|
+
for (var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b, seed = longtext.substring(i, i + Math.floor(longtext.length / 4)), j = -1, best_common = ""; -1 != (j = shorttext.indexOf(seed, j + 1));) {
|
|
2351
|
+
var prefixLength = dmp.diff_commonPrefix(longtext.substring(i), shorttext.substring(j)), suffixLength = dmp.diff_commonSuffix(longtext.substring(0, i), shorttext.substring(0, j));
|
|
2352
|
+
best_common.length < suffixLength + prefixLength && (best_common = shorttext.substring(j - suffixLength, j) + shorttext.substring(j, j + prefixLength), best_longtext_a = longtext.substring(0, i - suffixLength), best_longtext_b = longtext.substring(i + prefixLength), best_shorttext_a = shorttext.substring(0, j - suffixLength), best_shorttext_b = shorttext.substring(j + prefixLength));
|
|
2353
|
+
}
|
|
2354
|
+
return 2 * best_common.length >= longtext.length ? [
|
|
2355
|
+
best_longtext_a,
|
|
2356
|
+
best_longtext_b,
|
|
2357
|
+
best_shorttext_a,
|
|
2358
|
+
best_shorttext_b,
|
|
2359
|
+
best_common
|
|
2360
|
+
] : null;
|
|
2361
|
+
}
|
|
2362
|
+
var hm, text1_a, text1_b, text2_a, text2_b, hm1 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 4)), hm2 = diff_halfMatchI_(longtext, shorttext, Math.ceil(longtext.length / 2));
|
|
2363
|
+
return hm1 || hm2 ? (hm = hm2 ? hm1 && hm1[4].length > hm2[4].length ? hm1 : hm2 : hm1, text1.length > text2.length ? (text1_a = hm[0], text1_b = hm[1], text2_a = hm[2], text2_b = hm[3]) : (text2_a = hm[0], text2_b = hm[1], text1_a = hm[2], text1_b = hm[3]), [
|
|
2364
|
+
text1_a,
|
|
2365
|
+
text1_b,
|
|
2366
|
+
text2_a,
|
|
2367
|
+
text2_b,
|
|
2368
|
+
hm[4]
|
|
2369
|
+
]) : null;
|
|
2370
|
+
}, diff_match_patch.prototype.diff_cleanupSemantic = function(diffs) {
|
|
2371
|
+
for (var changes = !1, equalities = [], equalitiesLength = 0, lastEquality = null, pointer = 0, length_insertions1 = 0, length_deletions1 = 0, length_insertions2 = 0, length_deletions2 = 0; pointer < diffs.length;) 0 == diffs[pointer][0] ? (equalities[equalitiesLength++] = pointer, length_insertions1 = length_insertions2, length_deletions1 = length_deletions2, length_insertions2 = 0, length_deletions2 = 0, lastEquality = diffs[pointer][1]) : (1 == diffs[pointer][0] ? length_insertions2 += diffs[pointer][1].length : length_deletions2 += diffs[pointer][1].length, lastEquality && lastEquality.length <= Math.max(length_insertions1, length_deletions1) && lastEquality.length <= Math.max(length_insertions2, length_deletions2) && (diffs.splice(equalities[equalitiesLength - 1], 0, new diff_match_patch.Diff(-1, lastEquality)), diffs[equalities[equalitiesLength - 1] + 1][0] = 1, equalitiesLength--, pointer = --equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1, length_insertions1 = 0, length_deletions1 = 0, length_insertions2 = 0, length_deletions2 = 0, lastEquality = null, changes = !0)), pointer++;
|
|
2372
|
+
for (changes && this.diff_cleanupMerge(diffs), this.diff_cleanupSemanticLossless(diffs), pointer = 1; pointer < diffs.length;) {
|
|
2373
|
+
if (-1 == diffs[pointer - 1][0] && 1 == diffs[pointer][0]) {
|
|
2374
|
+
var deletion = diffs[pointer - 1][1], insertion = diffs[pointer][1], overlap_length1 = this.diff_commonOverlap_(deletion, insertion), overlap_length2 = this.diff_commonOverlap_(insertion, deletion);
|
|
2375
|
+
overlap_length1 >= overlap_length2 ? (overlap_length1 >= deletion.length / 2 || overlap_length1 >= insertion.length / 2) && (diffs.splice(pointer, 0, new diff_match_patch.Diff(0, insertion.substring(0, overlap_length1))), diffs[pointer - 1][1] = deletion.substring(0, deletion.length - overlap_length1), diffs[pointer + 1][1] = insertion.substring(overlap_length1), pointer++) : (overlap_length2 >= deletion.length / 2 || overlap_length2 >= insertion.length / 2) && (diffs.splice(pointer, 0, new diff_match_patch.Diff(0, deletion.substring(0, overlap_length2))), diffs[pointer - 1][0] = 1, diffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlap_length2), diffs[pointer + 1][0] = -1, diffs[pointer + 1][1] = deletion.substring(overlap_length2), pointer++), pointer++;
|
|
2376
|
+
}
|
|
2377
|
+
pointer++;
|
|
2378
|
+
}
|
|
2379
|
+
}, diff_match_patch.prototype.diff_cleanupSemanticLossless = function(diffs) {
|
|
2380
|
+
function diff_cleanupSemanticScore_(one, two) {
|
|
2381
|
+
if (!one || !two) return 6;
|
|
2382
|
+
var char1 = one.charAt(one.length - 1), char2 = two.charAt(0), nonAlphaNumeric1 = char1.match(diff_match_patch.nonAlphaNumericRegex_), nonAlphaNumeric2 = char2.match(diff_match_patch.nonAlphaNumericRegex_), whitespace1 = nonAlphaNumeric1 && char1.match(diff_match_patch.whitespaceRegex_), whitespace2 = nonAlphaNumeric2 && char2.match(diff_match_patch.whitespaceRegex_), lineBreak1 = whitespace1 && char1.match(diff_match_patch.linebreakRegex_), lineBreak2 = whitespace2 && char2.match(diff_match_patch.linebreakRegex_), blankLine1 = lineBreak1 && one.match(diff_match_patch.blanklineEndRegex_), blankLine2 = lineBreak2 && two.match(diff_match_patch.blanklineStartRegex_);
|
|
2383
|
+
return blankLine1 || blankLine2 ? 5 : lineBreak1 || lineBreak2 ? 4 : nonAlphaNumeric1 && !whitespace1 && whitespace2 ? 3 : whitespace1 || whitespace2 ? 2 : nonAlphaNumeric1 || nonAlphaNumeric2 ? 1 : 0;
|
|
2384
|
+
}
|
|
2385
|
+
for (var pointer = 1; pointer < diffs.length - 1;) {
|
|
2386
|
+
if (0 == diffs[pointer - 1][0] && 0 == diffs[pointer + 1][0]) {
|
|
2387
|
+
var equality1 = diffs[pointer - 1][1], edit = diffs[pointer][1], equality2 = diffs[pointer + 1][1], commonOffset = this.diff_commonSuffix(equality1, edit);
|
|
2388
|
+
if (commonOffset) {
|
|
2389
|
+
var commonString = edit.substring(edit.length - commonOffset);
|
|
2390
|
+
equality1 = equality1.substring(0, equality1.length - commonOffset), edit = commonString + edit.substring(0, edit.length - commonOffset), equality2 = commonString + equality2;
|
|
2391
|
+
}
|
|
2392
|
+
for (var bestEquality1 = equality1, bestEdit = edit, bestEquality2 = equality2, bestScore = diff_cleanupSemanticScore_(equality1, edit) + diff_cleanupSemanticScore_(edit, equality2); edit.charAt(0) === equality2.charAt(0);) {
|
|
2393
|
+
equality1 += edit.charAt(0), edit = edit.substring(1) + equality2.charAt(0), equality2 = equality2.substring(1);
|
|
2394
|
+
var score = diff_cleanupSemanticScore_(equality1, edit) + diff_cleanupSemanticScore_(edit, equality2);
|
|
2395
|
+
score >= bestScore && (bestScore = score, bestEquality1 = equality1, bestEdit = edit, bestEquality2 = equality2);
|
|
2396
|
+
}
|
|
2397
|
+
diffs[pointer - 1][1] != bestEquality1 && (bestEquality1 ? diffs[pointer - 1][1] = bestEquality1 : (diffs.splice(pointer - 1, 1), pointer--), diffs[pointer][1] = bestEdit, bestEquality2 ? diffs[pointer + 1][1] = bestEquality2 : (diffs.splice(pointer + 1, 1), pointer--));
|
|
2398
|
+
}
|
|
2399
|
+
pointer++;
|
|
2400
|
+
}
|
|
2401
|
+
}, diff_match_patch.nonAlphaNumericRegex_ = /[^a-zA-Z0-9]/, diff_match_patch.whitespaceRegex_ = /\s/, diff_match_patch.linebreakRegex_ = /[\r\n]/, diff_match_patch.blanklineEndRegex_ = /\n\r?\n$/, diff_match_patch.blanklineStartRegex_ = /^\r?\n\r?\n/, diff_match_patch.prototype.diff_cleanupEfficiency = function(diffs) {
|
|
2402
|
+
for (var changes = !1, equalities = [], equalitiesLength = 0, lastEquality = null, pointer = 0, pre_ins = !1, pre_del = !1, post_ins = !1, post_del = !1; pointer < diffs.length;) 0 == diffs[pointer][0] ? (diffs[pointer][1].length < this.Diff_EditCost && (post_ins || post_del) ? (equalities[equalitiesLength++] = pointer, pre_ins = post_ins, pre_del = post_del, lastEquality = diffs[pointer][1]) : (equalitiesLength = 0, lastEquality = null), post_ins = post_del = !1) : (-1 == diffs[pointer][0] ? post_del = !0 : post_ins = !0, lastEquality && (pre_ins && pre_del && post_ins && post_del || lastEquality.length < this.Diff_EditCost / 2 && pre_ins + pre_del + post_ins + post_del == 3) && (diffs.splice(equalities[equalitiesLength - 1], 0, new diff_match_patch.Diff(-1, lastEquality)), diffs[equalities[equalitiesLength - 1] + 1][0] = 1, equalitiesLength--, lastEquality = null, pre_ins && pre_del ? (post_ins = post_del = !0, equalitiesLength = 0) : (pointer = --equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1, post_ins = post_del = !1), changes = !0)), pointer++;
|
|
2403
|
+
changes && this.diff_cleanupMerge(diffs);
|
|
2404
|
+
}, diff_match_patch.prototype.diff_cleanupMerge = function(diffs) {
|
|
2405
|
+
diffs.push(new diff_match_patch.Diff(0, ""));
|
|
2406
|
+
for (var commonlength, pointer = 0, count_delete = 0, count_insert = 0, text_delete = "", text_insert = ""; pointer < diffs.length;) switch (diffs[pointer][0]) {
|
|
2407
|
+
case 1:
|
|
2408
|
+
count_insert++, text_insert += diffs[pointer][1], pointer++;
|
|
2409
|
+
break;
|
|
2410
|
+
case -1:
|
|
2411
|
+
count_delete++, text_delete += diffs[pointer][1], pointer++;
|
|
2412
|
+
break;
|
|
2413
|
+
case 0: count_delete + count_insert > 1 ? (0 !== count_delete && 0 !== count_insert && (0 !== (commonlength = this.diff_commonPrefix(text_insert, text_delete)) && (pointer - count_delete - count_insert > 0 && 0 == diffs[pointer - count_delete - count_insert - 1][0] ? diffs[pointer - count_delete - count_insert - 1][1] += text_insert.substring(0, commonlength) : (diffs.splice(0, 0, new diff_match_patch.Diff(0, text_insert.substring(0, commonlength))), pointer++), text_insert = text_insert.substring(commonlength), text_delete = text_delete.substring(commonlength)), 0 !== (commonlength = this.diff_commonSuffix(text_insert, text_delete)) && (diffs[pointer][1] = text_insert.substring(text_insert.length - commonlength) + diffs[pointer][1], text_insert = text_insert.substring(0, text_insert.length - commonlength), text_delete = text_delete.substring(0, text_delete.length - commonlength))), pointer -= count_delete + count_insert, diffs.splice(pointer, count_delete + count_insert), text_delete.length && (diffs.splice(pointer, 0, new diff_match_patch.Diff(-1, text_delete)), pointer++), text_insert.length && (diffs.splice(pointer, 0, new diff_match_patch.Diff(1, text_insert)), pointer++), pointer++) : 0 !== pointer && 0 == diffs[pointer - 1][0] ? (diffs[pointer - 1][1] += diffs[pointer][1], diffs.splice(pointer, 1)) : pointer++, count_insert = 0, count_delete = 0, text_delete = "", text_insert = "";
|
|
2414
|
+
}
|
|
2415
|
+
"" === diffs[diffs.length - 1][1] && diffs.pop();
|
|
2416
|
+
var changes = !1;
|
|
2417
|
+
for (pointer = 1; pointer < diffs.length - 1;) 0 == diffs[pointer - 1][0] && 0 == diffs[pointer + 1][0] && (diffs[pointer][1].substring(diffs[pointer][1].length - diffs[pointer - 1][1].length) == diffs[pointer - 1][1] ? (diffs[pointer][1] = diffs[pointer - 1][1] + diffs[pointer][1].substring(0, diffs[pointer][1].length - diffs[pointer - 1][1].length), diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1], diffs.splice(pointer - 1, 1), changes = !0) : diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) == diffs[pointer + 1][1] && (diffs[pointer - 1][1] += diffs[pointer + 1][1], diffs[pointer][1] = diffs[pointer][1].substring(diffs[pointer + 1][1].length) + diffs[pointer + 1][1], diffs.splice(pointer + 1, 1), changes = !0)), pointer++;
|
|
2418
|
+
changes && this.diff_cleanupMerge(diffs);
|
|
2419
|
+
}, diff_match_patch.prototype.diff_xIndex = function(diffs, loc) {
|
|
2420
|
+
var x, chars1 = 0, chars2 = 0, last_chars1 = 0, last_chars2 = 0;
|
|
2421
|
+
for (x = 0; x < diffs.length && (1 !== diffs[x][0] && (chars1 += diffs[x][1].length), -1 !== diffs[x][0] && (chars2 += diffs[x][1].length), !(chars1 > loc)); x++) last_chars1 = chars1, last_chars2 = chars2;
|
|
2422
|
+
return diffs.length != x && -1 === diffs[x][0] ? last_chars2 : last_chars2 + (loc - last_chars1);
|
|
2423
|
+
}, diff_match_patch.prototype.diff_prettyHtml = function(diffs) {
|
|
2424
|
+
for (var html = [], pattern_amp = /&/g, pattern_lt = /</g, pattern_gt = />/g, pattern_para = /\n/g, x = 0; x < diffs.length; x++) {
|
|
2425
|
+
var op = diffs[x][0], text = diffs[x][1].replace(pattern_amp, "&").replace(pattern_lt, "<").replace(pattern_gt, ">").replace(pattern_para, "¶<br>");
|
|
2426
|
+
switch (op) {
|
|
2427
|
+
case 1:
|
|
2428
|
+
html[x] = "<ins style=\"background:#e6ffe6;\">" + text + "</ins>";
|
|
2429
|
+
break;
|
|
2430
|
+
case -1:
|
|
2431
|
+
html[x] = "<del style=\"background:#ffe6e6;\">" + text + "</del>";
|
|
2432
|
+
break;
|
|
2433
|
+
case 0: html[x] = "<span>" + text + "</span>";
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
return html.join("");
|
|
2437
|
+
}, diff_match_patch.prototype.diff_text1 = function(diffs) {
|
|
2438
|
+
for (var text = [], x = 0; x < diffs.length; x++) 1 !== diffs[x][0] && (text[x] = diffs[x][1]);
|
|
2439
|
+
return text.join("");
|
|
2440
|
+
}, diff_match_patch.prototype.diff_text2 = function(diffs) {
|
|
2441
|
+
for (var text = [], x = 0; x < diffs.length; x++) -1 !== diffs[x][0] && (text[x] = diffs[x][1]);
|
|
2442
|
+
return text.join("");
|
|
2443
|
+
}, diff_match_patch.prototype.diff_levenshtein = function(diffs) {
|
|
2444
|
+
for (var levenshtein = 0, insertions = 0, deletions = 0, x = 0; x < diffs.length; x++) {
|
|
2445
|
+
var op = diffs[x][0], data = diffs[x][1];
|
|
2446
|
+
switch (op) {
|
|
2447
|
+
case 1:
|
|
2448
|
+
insertions += data.length;
|
|
2449
|
+
break;
|
|
2450
|
+
case -1:
|
|
2451
|
+
deletions += data.length;
|
|
2452
|
+
break;
|
|
2453
|
+
case 0: levenshtein += Math.max(insertions, deletions), insertions = 0, deletions = 0;
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
return levenshtein += Math.max(insertions, deletions);
|
|
2457
|
+
}, diff_match_patch.prototype.diff_toDelta = function(diffs) {
|
|
2458
|
+
for (var text = [], x = 0; x < diffs.length; x++) switch (diffs[x][0]) {
|
|
2459
|
+
case 1:
|
|
2460
|
+
text[x] = "+" + encodeURI(diffs[x][1]);
|
|
2461
|
+
break;
|
|
2462
|
+
case -1:
|
|
2463
|
+
text[x] = "-" + diffs[x][1].length;
|
|
2464
|
+
break;
|
|
2465
|
+
case 0: text[x] = "=" + diffs[x][1].length;
|
|
2466
|
+
}
|
|
2467
|
+
return text.join(" ").replace(/%20/g, " ");
|
|
2468
|
+
}, diff_match_patch.prototype.diff_fromDelta = function(text1, delta) {
|
|
2469
|
+
for (var diffs = [], diffsLength = 0, pointer = 0, tokens = delta.split(/\t/g), x = 0; x < tokens.length; x++) {
|
|
2470
|
+
var param = tokens[x].substring(1);
|
|
2471
|
+
switch (tokens[x].charAt(0)) {
|
|
2472
|
+
case "+":
|
|
2473
|
+
try {
|
|
2474
|
+
diffs[diffsLength++] = new diff_match_patch.Diff(1, decodeURI(param));
|
|
2475
|
+
} catch (ex) {
|
|
2476
|
+
throw new Error("Illegal escape in diff_fromDelta: " + param);
|
|
2477
|
+
}
|
|
2478
|
+
break;
|
|
2479
|
+
case "-":
|
|
2480
|
+
case "=":
|
|
2481
|
+
var n = parseInt(param, 10);
|
|
2482
|
+
if (isNaN(n) || n < 0) throw new Error("Invalid number in diff_fromDelta: " + param);
|
|
2483
|
+
var text = text1.substring(pointer, pointer += n);
|
|
2484
|
+
"=" == tokens[x].charAt(0) ? diffs[diffsLength++] = new diff_match_patch.Diff(0, text) : diffs[diffsLength++] = new diff_match_patch.Diff(-1, text);
|
|
2485
|
+
break;
|
|
2486
|
+
default: if (tokens[x]) throw new Error("Invalid diff operation in diff_fromDelta: " + tokens[x]);
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
if (pointer != text1.length) throw new Error("Delta length (" + pointer + ") does not equal source text length (" + text1.length + ").");
|
|
2490
|
+
return diffs;
|
|
2491
|
+
}, diff_match_patch.prototype.match_main = function(text, pattern, loc) {
|
|
2492
|
+
if (null == text || null == pattern || null == loc) throw new Error("Null input. (match_main)");
|
|
2493
|
+
return loc = Math.max(0, Math.min(loc, text.length)), text == pattern ? 0 : text.length ? text.substring(loc, loc + pattern.length) == pattern ? loc : this.match_bitap_(text, pattern, loc) : -1;
|
|
2494
|
+
}, diff_match_patch.prototype.match_bitap_ = function(text, pattern, loc) {
|
|
2495
|
+
if (pattern.length > this.Match_MaxBits) throw new Error("Pattern too long for this browser.");
|
|
2496
|
+
var s = this.match_alphabet_(pattern), dmp = this;
|
|
2497
|
+
function match_bitapScore_(e, x) {
|
|
2498
|
+
var accuracy = e / pattern.length, proximity = Math.abs(loc - x);
|
|
2499
|
+
return dmp.Match_Distance ? accuracy + proximity / dmp.Match_Distance : proximity ? 1 : accuracy;
|
|
2500
|
+
}
|
|
2501
|
+
var score_threshold = this.Match_Threshold, best_loc = text.indexOf(pattern, loc);
|
|
2502
|
+
-1 != best_loc && (score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold), -1 != (best_loc = text.lastIndexOf(pattern, loc + pattern.length)) && (score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold)));
|
|
2503
|
+
var bin_min, bin_mid, matchmask = 1 << pattern.length - 1;
|
|
2504
|
+
best_loc = -1;
|
|
2505
|
+
for (var last_rd, bin_max = pattern.length + text.length, d = 0; d < pattern.length; d++) {
|
|
2506
|
+
for (bin_min = 0, bin_mid = bin_max; bin_min < bin_mid;) match_bitapScore_(d, loc + bin_mid) <= score_threshold ? bin_min = bin_mid : bin_max = bin_mid, bin_mid = Math.floor((bin_max - bin_min) / 2 + bin_min);
|
|
2507
|
+
bin_max = bin_mid;
|
|
2508
|
+
var start = Math.max(1, loc - bin_mid + 1), finish = Math.min(loc + bin_mid, text.length) + pattern.length, rd = Array(finish + 2);
|
|
2509
|
+
rd[finish + 1] = (1 << d) - 1;
|
|
2510
|
+
for (var j = finish; j >= start; j--) {
|
|
2511
|
+
var charMatch = s[text.charAt(j - 1)];
|
|
2512
|
+
if (rd[j] = 0 === d ? (rd[j + 1] << 1 | 1) & charMatch : (rd[j + 1] << 1 | 1) & charMatch | (last_rd[j + 1] | last_rd[j]) << 1 | 1 | last_rd[j + 1], rd[j] & matchmask) {
|
|
2513
|
+
var score = match_bitapScore_(d, j - 1);
|
|
2514
|
+
if (score <= score_threshold) {
|
|
2515
|
+
if (score_threshold = score, !((best_loc = j - 1) > loc)) break;
|
|
2516
|
+
start = Math.max(1, 2 * loc - best_loc);
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
if (match_bitapScore_(d + 1, loc) > score_threshold) break;
|
|
2521
|
+
last_rd = rd;
|
|
2522
|
+
}
|
|
2523
|
+
return best_loc;
|
|
2524
|
+
}, diff_match_patch.prototype.match_alphabet_ = function(pattern) {
|
|
2525
|
+
for (var s = {}, i = 0; i < pattern.length; i++) s[pattern.charAt(i)] = 0;
|
|
2526
|
+
for (i = 0; i < pattern.length; i++) s[pattern.charAt(i)] |= 1 << pattern.length - i - 1;
|
|
2527
|
+
return s;
|
|
2528
|
+
}, diff_match_patch.prototype.patch_addContext_ = function(patch, text) {
|
|
2529
|
+
if (0 != text.length) {
|
|
2530
|
+
if (null === patch.start2) throw Error("patch not initialized");
|
|
2531
|
+
for (var pattern = text.substring(patch.start2, patch.start2 + patch.length1), padding = 0; text.indexOf(pattern) != text.lastIndexOf(pattern) && pattern.length < this.Match_MaxBits - this.Patch_Margin - this.Patch_Margin;) padding += this.Patch_Margin, pattern = text.substring(patch.start2 - padding, patch.start2 + patch.length1 + padding);
|
|
2532
|
+
padding += this.Patch_Margin;
|
|
2533
|
+
var prefix = text.substring(patch.start2 - padding, patch.start2);
|
|
2534
|
+
prefix && patch.diffs.unshift(new diff_match_patch.Diff(0, prefix));
|
|
2535
|
+
var suffix = text.substring(patch.start2 + patch.length1, patch.start2 + patch.length1 + padding);
|
|
2536
|
+
suffix && patch.diffs.push(new diff_match_patch.Diff(0, suffix)), patch.start1 -= prefix.length, patch.start2 -= prefix.length, patch.length1 += prefix.length + suffix.length, patch.length2 += prefix.length + suffix.length;
|
|
2537
|
+
}
|
|
2538
|
+
}, diff_match_patch.prototype.patch_make = function(a, opt_b, opt_c) {
|
|
2539
|
+
var text1, diffs;
|
|
2540
|
+
if ("string" == typeof a && "string" == typeof opt_b && void 0 === opt_c) text1 = a, (diffs = this.diff_main(text1, opt_b, !0)).length > 2 && (this.diff_cleanupSemantic(diffs), this.diff_cleanupEfficiency(diffs));
|
|
2541
|
+
else if (a && "object" == typeof a && void 0 === opt_b && void 0 === opt_c) diffs = a, text1 = this.diff_text1(diffs);
|
|
2542
|
+
else if ("string" == typeof a && opt_b && "object" == typeof opt_b && void 0 === opt_c) text1 = a, diffs = opt_b;
|
|
2543
|
+
else {
|
|
2544
|
+
if ("string" != typeof a || "string" != typeof opt_b || !opt_c || "object" != typeof opt_c) throw new Error("Unknown call format to patch_make.");
|
|
2545
|
+
text1 = a, diffs = opt_c;
|
|
2546
|
+
}
|
|
2547
|
+
if (0 === diffs.length) return [];
|
|
2548
|
+
for (var patches = [], patch = new diff_match_patch.patch_obj(), patchDiffLength = 0, char_count1 = 0, char_count2 = 0, prepatch_text = text1, postpatch_text = text1, x = 0; x < diffs.length; x++) {
|
|
2549
|
+
var diff_type = diffs[x][0], diff_text = diffs[x][1];
|
|
2550
|
+
switch (patchDiffLength || 0 === diff_type || (patch.start1 = char_count1, patch.start2 = char_count2), diff_type) {
|
|
2551
|
+
case 1:
|
|
2552
|
+
patch.diffs[patchDiffLength++] = diffs[x], patch.length2 += diff_text.length, postpatch_text = postpatch_text.substring(0, char_count2) + diff_text + postpatch_text.substring(char_count2);
|
|
2553
|
+
break;
|
|
2554
|
+
case -1:
|
|
2555
|
+
patch.length1 += diff_text.length, patch.diffs[patchDiffLength++] = diffs[x], postpatch_text = postpatch_text.substring(0, char_count2) + postpatch_text.substring(char_count2 + diff_text.length);
|
|
2556
|
+
break;
|
|
2557
|
+
case 0: diff_text.length <= 2 * this.Patch_Margin && patchDiffLength && diffs.length != x + 1 ? (patch.diffs[patchDiffLength++] = diffs[x], patch.length1 += diff_text.length, patch.length2 += diff_text.length) : diff_text.length >= 2 * this.Patch_Margin && patchDiffLength && (this.patch_addContext_(patch, prepatch_text), patches.push(patch), patch = new diff_match_patch.patch_obj(), patchDiffLength = 0, prepatch_text = postpatch_text, char_count1 = char_count2);
|
|
2558
|
+
}
|
|
2559
|
+
1 !== diff_type && (char_count1 += diff_text.length), -1 !== diff_type && (char_count2 += diff_text.length);
|
|
2560
|
+
}
|
|
2561
|
+
return patchDiffLength && (this.patch_addContext_(patch, prepatch_text), patches.push(patch)), patches;
|
|
2562
|
+
}, diff_match_patch.prototype.patch_deepCopy = function(patches) {
|
|
2563
|
+
for (var patchesCopy = [], x = 0; x < patches.length; x++) {
|
|
2564
|
+
var patch = patches[x], patchCopy = new diff_match_patch.patch_obj();
|
|
2565
|
+
patchCopy.diffs = [];
|
|
2566
|
+
for (var y = 0; y < patch.diffs.length; y++) patchCopy.diffs[y] = new diff_match_patch.Diff(patch.diffs[y][0], patch.diffs[y][1]);
|
|
2567
|
+
patchCopy.start1 = patch.start1, patchCopy.start2 = patch.start2, patchCopy.length1 = patch.length1, patchCopy.length2 = patch.length2, patchesCopy[x] = patchCopy;
|
|
2568
|
+
}
|
|
2569
|
+
return patchesCopy;
|
|
2570
|
+
}, diff_match_patch.prototype.patch_apply = function(patches, text) {
|
|
2571
|
+
if (0 == patches.length) return [text, []];
|
|
2572
|
+
patches = this.patch_deepCopy(patches);
|
|
2573
|
+
var nullPadding = this.patch_addPadding(patches);
|
|
2574
|
+
text = nullPadding + text + nullPadding, this.patch_splitMax(patches);
|
|
2575
|
+
for (var delta = 0, results = [], x = 0; x < patches.length; x++) {
|
|
2576
|
+
var start_loc, text2, expected_loc = patches[x].start2 + delta, text1 = this.diff_text1(patches[x].diffs), end_loc = -1;
|
|
2577
|
+
if (text1.length > this.Match_MaxBits ? -1 != (start_loc = this.match_main(text, text1.substring(0, this.Match_MaxBits), expected_loc)) && (-1 == (end_loc = this.match_main(text, text1.substring(text1.length - this.Match_MaxBits), expected_loc + text1.length - this.Match_MaxBits)) || start_loc >= end_loc) && (start_loc = -1) : start_loc = this.match_main(text, text1, expected_loc), -1 == start_loc) results[x] = !1, delta -= patches[x].length2 - patches[x].length1;
|
|
2578
|
+
else if (results[x] = !0, delta = start_loc - expected_loc, text1 == (text2 = -1 == end_loc ? text.substring(start_loc, start_loc + text1.length) : text.substring(start_loc, end_loc + this.Match_MaxBits))) text = text.substring(0, start_loc) + this.diff_text2(patches[x].diffs) + text.substring(start_loc + text1.length);
|
|
2579
|
+
else {
|
|
2580
|
+
var diffs = this.diff_main(text1, text2, !1);
|
|
2581
|
+
if (text1.length > this.Match_MaxBits && this.diff_levenshtein(diffs) / text1.length > this.Patch_DeleteThreshold) results[x] = !1;
|
|
2582
|
+
else {
|
|
2583
|
+
this.diff_cleanupSemanticLossless(diffs);
|
|
2584
|
+
for (var index2, index1 = 0, y = 0; y < patches[x].diffs.length; y++) {
|
|
2585
|
+
var mod = patches[x].diffs[y];
|
|
2586
|
+
0 !== mod[0] && (index2 = this.diff_xIndex(diffs, index1)), 1 === mod[0] ? text = text.substring(0, start_loc + index2) + mod[1] + text.substring(start_loc + index2) : -1 === mod[0] && (text = text.substring(0, start_loc + index2) + text.substring(start_loc + this.diff_xIndex(diffs, index1 + mod[1].length))), -1 !== mod[0] && (index1 += mod[1].length);
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
return [text = text.substring(nullPadding.length, text.length - nullPadding.length), results];
|
|
2592
|
+
}, diff_match_patch.prototype.patch_addPadding = function(patches) {
|
|
2593
|
+
for (var paddingLength = this.Patch_Margin, nullPadding = "", x = 1; x <= paddingLength; x++) nullPadding += String.fromCharCode(x);
|
|
2594
|
+
for (x = 0; x < patches.length; x++) patches[x].start1 += paddingLength, patches[x].start2 += paddingLength;
|
|
2595
|
+
var patch = patches[0], diffs = patch.diffs;
|
|
2596
|
+
if (0 == diffs.length || 0 != diffs[0][0]) diffs.unshift(new diff_match_patch.Diff(0, nullPadding)), patch.start1 -= paddingLength, patch.start2 -= paddingLength, patch.length1 += paddingLength, patch.length2 += paddingLength;
|
|
2597
|
+
else if (paddingLength > diffs[0][1].length) {
|
|
2598
|
+
var extraLength = paddingLength - diffs[0][1].length;
|
|
2599
|
+
diffs[0][1] = nullPadding.substring(diffs[0][1].length) + diffs[0][1], patch.start1 -= extraLength, patch.start2 -= extraLength, patch.length1 += extraLength, patch.length2 += extraLength;
|
|
2600
|
+
}
|
|
2601
|
+
if (0 == (diffs = (patch = patches[patches.length - 1]).diffs).length || 0 != diffs[diffs.length - 1][0]) diffs.push(new diff_match_patch.Diff(0, nullPadding)), patch.length1 += paddingLength, patch.length2 += paddingLength;
|
|
2602
|
+
else if (paddingLength > diffs[diffs.length - 1][1].length) {
|
|
2603
|
+
extraLength = paddingLength - diffs[diffs.length - 1][1].length;
|
|
2604
|
+
diffs[diffs.length - 1][1] += nullPadding.substring(0, extraLength), patch.length1 += extraLength, patch.length2 += extraLength;
|
|
2605
|
+
}
|
|
2606
|
+
return nullPadding;
|
|
2607
|
+
}, diff_match_patch.prototype.patch_splitMax = function(patches) {
|
|
2608
|
+
for (var patch_size = this.Match_MaxBits, x = 0; x < patches.length; x++) if (!(patches[x].length1 <= patch_size)) {
|
|
2609
|
+
var bigpatch = patches[x];
|
|
2610
|
+
patches.splice(x--, 1);
|
|
2611
|
+
for (var start1 = bigpatch.start1, start2 = bigpatch.start2, precontext = ""; 0 !== bigpatch.diffs.length;) {
|
|
2612
|
+
var patch = new diff_match_patch.patch_obj(), empty = !0;
|
|
2613
|
+
for (patch.start1 = start1 - precontext.length, patch.start2 = start2 - precontext.length, "" !== precontext && (patch.length1 = patch.length2 = precontext.length, patch.diffs.push(new diff_match_patch.Diff(0, precontext))); 0 !== bigpatch.diffs.length && patch.length1 < patch_size - this.Patch_Margin;) {
|
|
2614
|
+
var diff_type = bigpatch.diffs[0][0], diff_text = bigpatch.diffs[0][1];
|
|
2615
|
+
1 === diff_type ? (patch.length2 += diff_text.length, start2 += diff_text.length, patch.diffs.push(bigpatch.diffs.shift()), empty = !1) : -1 === diff_type && 1 == patch.diffs.length && 0 == patch.diffs[0][0] && diff_text.length > 2 * patch_size ? (patch.length1 += diff_text.length, start1 += diff_text.length, empty = !1, patch.diffs.push(new diff_match_patch.Diff(diff_type, diff_text)), bigpatch.diffs.shift()) : (diff_text = diff_text.substring(0, patch_size - patch.length1 - this.Patch_Margin), patch.length1 += diff_text.length, start1 += diff_text.length, 0 === diff_type ? (patch.length2 += diff_text.length, start2 += diff_text.length) : empty = !1, patch.diffs.push(new diff_match_patch.Diff(diff_type, diff_text)), diff_text == bigpatch.diffs[0][1] ? bigpatch.diffs.shift() : bigpatch.diffs[0][1] = bigpatch.diffs[0][1].substring(diff_text.length));
|
|
2616
|
+
}
|
|
2617
|
+
precontext = (precontext = this.diff_text2(patch.diffs)).substring(precontext.length - this.Patch_Margin);
|
|
2618
|
+
var postcontext = this.diff_text1(bigpatch.diffs).substring(0, this.Patch_Margin);
|
|
2619
|
+
"" !== postcontext && (patch.length1 += postcontext.length, patch.length2 += postcontext.length, 0 !== patch.diffs.length && 0 === patch.diffs[patch.diffs.length - 1][0] ? patch.diffs[patch.diffs.length - 1][1] += postcontext : patch.diffs.push(new diff_match_patch.Diff(0, postcontext))), empty || patches.splice(++x, 0, patch);
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
}, diff_match_patch.prototype.patch_toText = function(patches) {
|
|
2623
|
+
for (var text = [], x = 0; x < patches.length; x++) text[x] = patches[x];
|
|
2624
|
+
return text.join("");
|
|
2625
|
+
}, diff_match_patch.prototype.patch_fromText = function(textline) {
|
|
2626
|
+
var patches = [];
|
|
2627
|
+
if (!textline) return patches;
|
|
2628
|
+
for (var text = textline.split("\n"), textPointer = 0, patchHeader = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/; textPointer < text.length;) {
|
|
2629
|
+
var m = text[textPointer].match(patchHeader);
|
|
2630
|
+
if (!m) throw new Error("Invalid patch string: " + text[textPointer]);
|
|
2631
|
+
var patch = new diff_match_patch.patch_obj();
|
|
2632
|
+
for (patches.push(patch), patch.start1 = parseInt(m[1], 10), "" === m[2] ? (patch.start1--, patch.length1 = 1) : "0" == m[2] ? patch.length1 = 0 : (patch.start1--, patch.length1 = parseInt(m[2], 10)), patch.start2 = parseInt(m[3], 10), "" === m[4] ? (patch.start2--, patch.length2 = 1) : "0" == m[4] ? patch.length2 = 0 : (patch.start2--, patch.length2 = parseInt(m[4], 10)), textPointer++; textPointer < text.length;) {
|
|
2633
|
+
var sign = text[textPointer].charAt(0);
|
|
2634
|
+
try {
|
|
2635
|
+
var line = decodeURI(text[textPointer].substring(1));
|
|
2636
|
+
} catch (ex) {
|
|
2637
|
+
throw new Error("Illegal escape in patch_fromText: " + line);
|
|
2638
|
+
}
|
|
2639
|
+
if ("-" == sign) patch.diffs.push(new diff_match_patch.Diff(-1, line));
|
|
2640
|
+
else if ("+" == sign) patch.diffs.push(new diff_match_patch.Diff(1, line));
|
|
2641
|
+
else if (" " == sign) patch.diffs.push(new diff_match_patch.Diff(0, line));
|
|
2642
|
+
else {
|
|
2643
|
+
if ("@" == sign) break;
|
|
2644
|
+
if ("" !== sign) throw new Error("Invalid patch mode \"" + sign + "\" in: " + line);
|
|
2645
|
+
}
|
|
2646
|
+
textPointer++;
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
return patches;
|
|
2650
|
+
}, (diff_match_patch.patch_obj = function() {
|
|
2651
|
+
this.diffs = [], this.start1 = null, this.start2 = null, this.length1 = 0, this.length2 = 0;
|
|
2652
|
+
}).prototype.toString = function() {
|
|
2653
|
+
for (var op, text = ["@@ -" + (0 === this.length1 ? this.start1 + ",0" : 1 == this.length1 ? this.start1 + 1 : this.start1 + 1 + "," + this.length1) + " +" + (0 === this.length2 ? this.start2 + ",0" : 1 == this.length2 ? this.start2 + 1 : this.start2 + 1 + "," + this.length2) + " @@\n"], x = 0; x < this.diffs.length; x++) {
|
|
2654
|
+
switch (this.diffs[x][0]) {
|
|
2655
|
+
case 1:
|
|
2656
|
+
op = "+";
|
|
2657
|
+
break;
|
|
2658
|
+
case -1:
|
|
2659
|
+
op = "-";
|
|
2660
|
+
break;
|
|
2661
|
+
case 0: op = " ";
|
|
2662
|
+
}
|
|
2663
|
+
text[x + 1] = op + encodeURI(this.diffs[x][1]) + "\n";
|
|
2664
|
+
}
|
|
2665
|
+
return text.join("").replace(/%20/g, " ");
|
|
2666
|
+
}, module.exports = diff_match_patch, module.exports.diff_match_patch = diff_match_patch, module.exports.DIFF_DELETE = -1, module.exports.DIFF_INSERT = 1, module.exports.DIFF_EQUAL = 0;
|
|
2667
|
+
}));
|
|
2668
|
+
diffMatchPatch.DIFF_EQUAL;
|
|
2669
|
+
diffMatchPatch.DIFF_DELETE;
|
|
2670
|
+
diffMatchPatch.DIFF_INSERT;
|
|
2671
|
+
// src/file-diff-view.tsx
|
|
2672
|
+
var en$2 = {
|
|
2673
|
+
view: "Show changes as",
|
|
2674
|
+
blocks: "Blocks",
|
|
2675
|
+
text: "Text"
|
|
2676
|
+
};
|
|
2677
|
+
var ja$2 = {
|
|
2678
|
+
view: "変更の表示",
|
|
2679
|
+
blocks: "ブロック",
|
|
2680
|
+
text: "テキスト"
|
|
2681
|
+
};
|
|
2682
|
+
/** Project sources are the files the panel opens as projects. */
|
|
2683
|
+
var isProjectSource = (path) => path.split("/").pop() === "project.source.json";
|
|
2684
|
+
/**
|
|
2685
|
+
* Shows one changed file. Project sources are compared as blocks by default, with their text diff one switch away.
|
|
2686
|
+
*/
|
|
2687
|
+
function FileDiffView({ change, diff, labels, locale, renderBlock, loadAsset }) {
|
|
2688
|
+
var _change$oldMode, _change$newMode;
|
|
2689
|
+
const [view, setView] = useState("blocks");
|
|
2690
|
+
const names = locale.startsWith("ja") ? ja$2 : en$2;
|
|
2691
|
+
const parsed = (diff === null || diff === void 0 ? void 0 : diff.patch) ? parseDiff(diff.patch)[0] : null;
|
|
2692
|
+
const text = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, labels.mode, " · ", ((_change$oldMode = change.oldMode) === null || _change$oldMode === void 0 ? void 0 : _change$oldMode.toString(8)) || "—", " → ", ((_change$newMode = change.newMode) === null || _change$newMode === void 0 ? void 0 : _change$newMode.toString(8)) || "—"), diff && /* @__PURE__ */ React.createElement("p", null, diff.beforeSize, " → ", diff.afterSize, " ", labels.bytes), (diff === null || diff === void 0 ? void 0 : diff.binary) && /* @__PURE__ */ React.createElement("p", null, labels.binary), (diff === null || diff === void 0 ? void 0 : diff.tooLarge) && /* @__PURE__ */ React.createElement("p", null, labels.large), parsed && /* @__PURE__ */ React.createElement(index, {
|
|
2693
|
+
viewType: "unified",
|
|
2694
|
+
diffType: parsed.type,
|
|
2695
|
+
hunks: parsed.hunks
|
|
2696
|
+
}, (hunks) => hunks.map((hunk) => /* @__PURE__ */ React.createElement(Hunk, {
|
|
2697
|
+
key: hunk.content,
|
|
2698
|
+
hunk
|
|
2699
|
+
}))), diff && !diff.binary && !diff.tooLarge && !(parsed === null || parsed === void 0 ? void 0 : parsed.hunks.length) && /* @__PURE__ */ React.createElement("p", null, labels.unchanged));
|
|
2700
|
+
const sources = renderBlock && (diff === null || diff === void 0 ? void 0 : diff.text) && isProjectSource(change.path) ? diff.text : null;
|
|
2701
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h3", null, change.path), sources && /* @__PURE__ */ React.createElement("div", {
|
|
2702
|
+
className: "twgit-view-switch",
|
|
2703
|
+
role: "group",
|
|
2704
|
+
"aria-label": names.view
|
|
2705
|
+
}, ["blocks", "text"].map((mode) => /* @__PURE__ */ React.createElement("button", {
|
|
2706
|
+
key: mode,
|
|
2707
|
+
type: "button",
|
|
2708
|
+
"aria-pressed": view === mode,
|
|
2709
|
+
"data-git-view": mode,
|
|
2710
|
+
onClick: () => setView(mode)
|
|
2711
|
+
}, names[mode]))), sources && view === "blocks" ? /* @__PURE__ */ React.createElement(ProjectSourceComparison, {
|
|
2712
|
+
renderBlock,
|
|
2713
|
+
locale,
|
|
2714
|
+
fallback: text,
|
|
2715
|
+
loadAsset,
|
|
2716
|
+
before: change.before === null ? null : sources.before,
|
|
2717
|
+
after: change.after === null ? null : sources.after
|
|
2718
|
+
}) : text);
|
|
2719
|
+
}
|
|
2720
|
+
// src/messages.ts
|
|
2721
|
+
var messages = {
|
|
2722
|
+
en: {
|
|
2723
|
+
pullRequests: "Pull requests",
|
|
2724
|
+
localChanges: "Local changes",
|
|
2725
|
+
title: "Local Git",
|
|
2726
|
+
menu: "Local Git…",
|
|
2727
|
+
close: "Close",
|
|
2728
|
+
choose: "Choose Repository…",
|
|
2729
|
+
refresh: "Refresh",
|
|
2730
|
+
empty: "Choose an existing Git repository to inspect its files and history.",
|
|
2731
|
+
repository: "Repository",
|
|
2732
|
+
project: "Project folder",
|
|
2733
|
+
none: "No project selected",
|
|
2734
|
+
root: "Repository root",
|
|
2735
|
+
open: "Open This Project",
|
|
2736
|
+
reload: "Reload Project",
|
|
2737
|
+
up: "Parent folder",
|
|
2738
|
+
browse: "Choose a project inside this repository",
|
|
2739
|
+
replace: "Replace the open project and discard its unsaved changes?",
|
|
2740
|
+
dirty: "The Editor has unsaved changes.",
|
|
2741
|
+
saved: "The Editor has no unsaved changes.",
|
|
2742
|
+
staged: "Staged",
|
|
2743
|
+
unstaged: "Unstaged",
|
|
2744
|
+
untracked: "Untracked",
|
|
2745
|
+
commit: "Commit changes",
|
|
2746
|
+
history: "History",
|
|
2747
|
+
worktree: "Working tree",
|
|
2748
|
+
clean: "No changes in the selected folder.",
|
|
2749
|
+
branches: "Local branches",
|
|
2750
|
+
unborn: "No commits yet",
|
|
2751
|
+
detached: "Detached HEAD",
|
|
2752
|
+
select: "Select a file to view its diff.",
|
|
2753
|
+
binary: "Binary asset",
|
|
2754
|
+
large: "Text preview exceeds its display limit.",
|
|
2755
|
+
bytes: "bytes",
|
|
2756
|
+
mode: "Git file mode",
|
|
2757
|
+
permissions: "Working-tree executable permission changes are unavailable in the browser.",
|
|
2758
|
+
unchanged: "The text is unchanged.",
|
|
2759
|
+
loading: "Reading repository…",
|
|
2760
|
+
invalid: "Choose a repository with a .git directory, and a project inside that repository.",
|
|
2761
|
+
changed: "Files or Git state changed while reading. Refresh to read the current state.",
|
|
2762
|
+
outdated: "The repository changed outside the Editor. Refresh to read the current state.",
|
|
2763
|
+
unsupported: "This repository contains an entry the browser cannot represent.",
|
|
2764
|
+
pullUnsafe: "Stop the project and clear unsaved or local Git changes before pulling.",
|
|
2765
|
+
diverged: "Pull requires a fast-forward. Your local branch and files are intact.",
|
|
2766
|
+
session: "Reconnect GitHub for this repository and requested permission.",
|
|
2767
|
+
pushUnknown: "The push result is unknown. Fetch and check the remote branch before retrying.",
|
|
2768
|
+
pushRefresh: "The push succeeded. Fetch to refresh the local tracking branch.",
|
|
2769
|
+
rollbackFailed: "Git could not restore all local changes. Check the working tree and Git status.",
|
|
2770
|
+
remoteFailed: "The Git operation failed. Check the selected connection and retry.",
|
|
2771
|
+
remoteDone: "Git operation completed.",
|
|
2772
|
+
pulledProject: "Pull completed. Use Reload Project to open the updated files.",
|
|
2773
|
+
confirmPush: "Push the current branch to its GitHub origin?",
|
|
2774
|
+
failed: "Could not read the repository. Check folder access and refresh."
|
|
2775
|
+
},
|
|
2776
|
+
ja: {
|
|
2777
|
+
pullRequests: "プルリクエスト",
|
|
2778
|
+
localChanges: "ローカルの変更",
|
|
2779
|
+
title: "ローカル Git",
|
|
2780
|
+
menu: "ローカル Git…",
|
|
2781
|
+
close: "閉じる",
|
|
2782
|
+
choose: "リポジトリを選択…",
|
|
2783
|
+
refresh: "再取得",
|
|
2784
|
+
empty: "既存の Git リポジトリを選び、ファイルの状態と履歴を確認できます。",
|
|
2785
|
+
repository: "リポジトリ",
|
|
2786
|
+
project: "作品フォルダ",
|
|
2787
|
+
none: "作品は未選択",
|
|
2788
|
+
root: "リポジトリルート",
|
|
2789
|
+
open: "この作品を開く",
|
|
2790
|
+
reload: "作品を再読込",
|
|
2791
|
+
up: "上のフォルダ",
|
|
2792
|
+
browse: "リポジトリ内の作品を選択",
|
|
2793
|
+
replace: "未保存の変更を破棄して、別の作品を開きますか?",
|
|
2794
|
+
dirty: "Editor に未保存の変更があります。",
|
|
2795
|
+
saved: "Editor に未保存の変更はありません。",
|
|
2796
|
+
staged: "ステージ済み",
|
|
2797
|
+
unstaged: "未ステージ",
|
|
2798
|
+
untracked: "未追跡",
|
|
2799
|
+
commit: "コミットの変更",
|
|
2800
|
+
history: "履歴",
|
|
2801
|
+
worktree: "作業ツリー",
|
|
2802
|
+
clean: "対象フォルダに変更はありません。",
|
|
2803
|
+
branches: "ローカルブランチ",
|
|
2804
|
+
unborn: "コミットはまだありません",
|
|
2805
|
+
detached: "ブランチ未選択の HEAD",
|
|
2806
|
+
select: "ファイルを選ぶと差分を表示します。",
|
|
2807
|
+
binary: "バイナリアセット",
|
|
2808
|
+
large: "テキスト差分の表示上限を超えています。",
|
|
2809
|
+
bytes: "バイト",
|
|
2810
|
+
mode: "Git のファイルモード",
|
|
2811
|
+
permissions: "作業ツリーの実行権限の変更はブラウザーから確認できません。",
|
|
2812
|
+
unchanged: "テキストに変更はありません。",
|
|
2813
|
+
loading: "リポジトリを読込中…",
|
|
2814
|
+
invalid: ".git ディレクトリを持つリポジトリと、その配下の作品を選んでください。",
|
|
2815
|
+
changed: "読込中にファイルまたは Git の状態が変わりました。再取得してください。",
|
|
2816
|
+
outdated: "Editor の外でリポジトリが変更されました。再取得すると最新の状態を読み込みます。",
|
|
2817
|
+
unsupported: "ブラウザーで扱えない種類の Git エントリーがあります。",
|
|
2818
|
+
pullUnsafe: "pull の前に実行を止め、未保存編集とローカルの Git 変更を解消してください。",
|
|
2819
|
+
diverged: "fast-forward できません。ローカルブランチとファイルは保持されています。",
|
|
2820
|
+
session: "このリポジトリと操作に必要な権限で GitHub に接続してください。",
|
|
2821
|
+
pushUnknown: "push の結果が不明です。再試行する前に fetch でリモートブランチを確認してください。",
|
|
2822
|
+
pushRefresh: "push は成功しました。fetch でローカルの追跡ブランチを更新してください。",
|
|
2823
|
+
rollbackFailed: "Git がローカルの変更をすべて復元できませんでした。作業ツリーと Git の状態を確認してください。",
|
|
2824
|
+
remoteFailed: "Git 操作に失敗しました。選択中の接続を確認して再試行してください。",
|
|
2825
|
+
remoteDone: "Git 操作が完了しました。",
|
|
2826
|
+
pulledProject: "pull が完了しました。「作品を再読込」で更新済みのファイルを開けます。",
|
|
2827
|
+
confirmPush: "現在のブランチを GitHub の origin に push しますか?",
|
|
2828
|
+
failed: "リポジトリを読み込めませんでした。フォルダへのアクセスを確認し、再取得してください。"
|
|
2829
|
+
}
|
|
2830
|
+
};
|
|
2831
|
+
var labelsFor = (locale) => locale.startsWith("ja") ? messages.ja : messages.en;
|
|
2832
|
+
// src/connection-settings.tsx
|
|
2833
|
+
var en$1 = {
|
|
2834
|
+
title: "GitHub connection",
|
|
2835
|
+
mode: "Connection mode",
|
|
2836
|
+
select: "Choose a connection",
|
|
2837
|
+
desktop: "Desktop local",
|
|
2838
|
+
cloudflare: "Cloudflare",
|
|
2839
|
+
proxy: "Proxy",
|
|
2840
|
+
account: "Account",
|
|
2841
|
+
"disconnected": "Disconnected",
|
|
2842
|
+
"connecting": "Waiting for GitHub",
|
|
2843
|
+
"connected": "Connected",
|
|
2844
|
+
"reauth-required": "Sign in again",
|
|
2845
|
+
connect: "Connect to GitHub",
|
|
2846
|
+
open: "Open GitHub authorization",
|
|
2847
|
+
check: "Check connection",
|
|
2848
|
+
disconnect: "Disconnect",
|
|
2849
|
+
noRemote: "Choose a repository with a GitHub HTTPS origin.",
|
|
2850
|
+
unavailable: "No GitHub connection is configured.",
|
|
2851
|
+
changed: "Switching disconnects the current session.",
|
|
2852
|
+
error: "GitHub connection failed. Retry using the selected connection.",
|
|
2853
|
+
invalid: "The selected repository needs a GitHub HTTPS origin.",
|
|
2854
|
+
allowPush: "Authorize push",
|
|
2855
|
+
fetch: "Fetch",
|
|
2856
|
+
pull: "Pull (fast-forward only)",
|
|
2857
|
+
push: "Push"
|
|
2858
|
+
};
|
|
2859
|
+
var ja$1 = {
|
|
2860
|
+
title: "GitHub 接続",
|
|
2861
|
+
mode: "接続方式",
|
|
2862
|
+
select: "接続方式を選択",
|
|
2863
|
+
desktop: "Desktop ローカル",
|
|
2864
|
+
cloudflare: "Cloudflare",
|
|
2865
|
+
proxy: "プロキシ",
|
|
2866
|
+
account: "アカウント",
|
|
2867
|
+
"disconnected": "未接続",
|
|
2868
|
+
"connecting": "GitHub の認証待ち",
|
|
2869
|
+
"connected": "接続済み",
|
|
2870
|
+
"reauth-required": "再認証が必要",
|
|
2871
|
+
connect: "GitHub に接続",
|
|
2872
|
+
open: "GitHub の認証を開く",
|
|
2873
|
+
check: "接続を確認",
|
|
2874
|
+
disconnect: "切断",
|
|
2875
|
+
noRemote: "GitHub の HTTPS リモート origin があるリポジトリを選択してください。",
|
|
2876
|
+
unavailable: "GitHub 接続先が設定されていません。",
|
|
2877
|
+
changed: "方式を切り替えると現在のセッションを切断します。",
|
|
2878
|
+
error: "GitHub 接続に失敗しました。選択中の方式で再試行してください。",
|
|
2879
|
+
invalid: "選択したリポジトリには GitHub の HTTPS リモート origin が必要です。",
|
|
2880
|
+
allowPush: "push を許可する",
|
|
2881
|
+
fetch: "Fetch",
|
|
2882
|
+
pull: "Pull(fast-forward のみ)",
|
|
2883
|
+
push: "Push"
|
|
2884
|
+
};
|
|
2885
|
+
function ConnectionSettings({ settings, locale, readOrigin, runOperation }) {
|
|
2886
|
+
const labels = locale.startsWith("ja") ? ja$1 : en$1;
|
|
2887
|
+
const [, update] = useState(0);
|
|
2888
|
+
const [busy, setBusy] = useState(false);
|
|
2889
|
+
const [allowPush, setAllowPush] = useState(false);
|
|
2890
|
+
const [error, setError] = useState(null);
|
|
2891
|
+
const active = useRef(true);
|
|
2892
|
+
useEffect(() => {
|
|
2893
|
+
active.current = true;
|
|
2894
|
+
return () => {
|
|
2895
|
+
active.current = false;
|
|
2896
|
+
};
|
|
2897
|
+
}, []);
|
|
2898
|
+
const run = async (action) => {
|
|
2899
|
+
if (busy) return;
|
|
2900
|
+
setBusy(true);
|
|
2901
|
+
setError(null);
|
|
2902
|
+
try {
|
|
2903
|
+
await action();
|
|
2904
|
+
} catch (failure) {
|
|
2905
|
+
if (active.current) setError(failure.message === "INVALID_REMOTE" ? "invalid" : "error");
|
|
2906
|
+
} finally {
|
|
2907
|
+
if (active.current) {
|
|
2908
|
+
setBusy(false);
|
|
2909
|
+
update((value) => value + 1);
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
};
|
|
2913
|
+
const { mode, state, proxyOrigin, authorization, write } = settings.getView();
|
|
2914
|
+
const connect = () => run(async () => {
|
|
2915
|
+
const remote = await (readOrigin === null || readOrigin === void 0 ? void 0 : readOrigin());
|
|
2916
|
+
if (!remote) throw new Error("INVALID_REMOTE");
|
|
2917
|
+
await settings.connect(remote, allowPush);
|
|
2918
|
+
});
|
|
2919
|
+
return /* @__PURE__ */ React.createElement("details", { className: "twgit-connection" }, /* @__PURE__ */ React.createElement("summary", null, labels.title), !settings.modes.length ? /* @__PURE__ */ React.createElement("p", null, labels.unavailable) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("label", null, labels.mode, " ", /* @__PURE__ */ React.createElement("select", {
|
|
2920
|
+
value: mode !== null && mode !== void 0 ? mode : "",
|
|
2921
|
+
disabled: busy,
|
|
2922
|
+
onChange: (event) => {
|
|
2923
|
+
const choice = event.currentTarget.value;
|
|
2924
|
+
run(() => settings.select(choice));
|
|
2925
|
+
}
|
|
2926
|
+
}, /* @__PURE__ */ React.createElement("option", {
|
|
2927
|
+
value: "",
|
|
2928
|
+
disabled: true
|
|
2929
|
+
}, labels.select), settings.modes.map((choice) => /* @__PURE__ */ React.createElement("option", {
|
|
2930
|
+
key: choice,
|
|
2931
|
+
value: choice
|
|
2932
|
+
}, labels[choice])))), /* @__PURE__ */ React.createElement("p", null, labels.changed), /* @__PURE__ */ React.createElement("p", {
|
|
2933
|
+
"data-git-connection-state": "",
|
|
2934
|
+
role: "status"
|
|
2935
|
+
}, labels[state.status]), proxyOrigin && /* @__PURE__ */ React.createElement("p", null, labels.proxy, " · ", /* @__PURE__ */ React.createElement("code", null, proxyOrigin)), state.account && /* @__PURE__ */ React.createElement("p", null, labels.account, " · ", state.account.login), !readOrigin && /* @__PURE__ */ React.createElement("p", null, labels.noRemote), mode && /* @__PURE__ */ React.createElement(React.Fragment, null, runOperation && /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("input", {
|
|
2936
|
+
type: "checkbox",
|
|
2937
|
+
checked: allowPush,
|
|
2938
|
+
disabled: busy || state.status === "connecting" || state.status === "connected",
|
|
2939
|
+
onChange: (event) => setAllowPush(event.currentTarget.checked)
|
|
2940
|
+
}), " ", labels.allowPush), /* @__PURE__ */ React.createElement("button", {
|
|
2941
|
+
disabled: busy || !readOrigin || state.status === "connecting" || state.status === "connected",
|
|
2942
|
+
onClick: connect
|
|
2943
|
+
}, labels.connect), authorization && /* @__PURE__ */ React.createElement("p", null, authorization.userCode && /* @__PURE__ */ React.createElement("code", null, authorization.userCode, " "), /* @__PURE__ */ React.createElement("a", {
|
|
2944
|
+
href: authorization.url,
|
|
2945
|
+
target: "_blank",
|
|
2946
|
+
rel: "noopener noreferrer"
|
|
2947
|
+
}, labels.open)), state.status !== "disconnected" && /* @__PURE__ */ React.createElement("button", {
|
|
2948
|
+
disabled: busy,
|
|
2949
|
+
onClick: () => void run(settings.refresh)
|
|
2950
|
+
}, labels.check), /* @__PURE__ */ React.createElement("button", {
|
|
2951
|
+
disabled: busy,
|
|
2952
|
+
onClick: () => void run(settings.disconnect)
|
|
2953
|
+
}, labels.disconnect), runOperation && state.status === "connected" && [
|
|
2954
|
+
"fetch",
|
|
2955
|
+
"pull",
|
|
2956
|
+
"push"
|
|
2957
|
+
].map((operation) => /* @__PURE__ */ React.createElement("button", {
|
|
2958
|
+
key: operation,
|
|
2959
|
+
disabled: busy || !readOrigin || operation === "push" && !write,
|
|
2960
|
+
onClick: () => void run(() => runOperation(operation))
|
|
2961
|
+
}, labels[operation]))), error && /* @__PURE__ */ React.createElement("p", {
|
|
2962
|
+
className: "twgit-error",
|
|
2963
|
+
role: "alert"
|
|
2964
|
+
}, labels[error])));
|
|
2965
|
+
}
|
|
2966
|
+
// src/pull-request-panel.tsx
|
|
2967
|
+
var en = {
|
|
2968
|
+
title: "Pull requests",
|
|
2969
|
+
number: "Pull request number",
|
|
2970
|
+
openNumber: "Open pull request",
|
|
2971
|
+
open: "Open",
|
|
2972
|
+
closed: "Closed",
|
|
2973
|
+
merged: "Merged",
|
|
2974
|
+
draft: "Draft",
|
|
2975
|
+
prev: "Previous page",
|
|
2976
|
+
next: "Next page",
|
|
2977
|
+
empty: "No pull requests on this page.",
|
|
2978
|
+
loading: "Reading GitHub…",
|
|
2979
|
+
select: "Select a pull request to review its changes.",
|
|
2980
|
+
onGitHub: "Open on GitHub",
|
|
2981
|
+
noOrigin: "Choose a repository whose origin is on GitHub.",
|
|
2982
|
+
unavailable: "GitHub could not read this repository or pull request. The panel supports public repositories.",
|
|
2983
|
+
rateLimit: "The public GitHub API rate limit was reached. Try again after the limit resets.",
|
|
2984
|
+
failed: "Could not read GitHub. Try again.",
|
|
2985
|
+
changed: "The pull request changed while it was being read. Open it again.",
|
|
2986
|
+
tooManyFiles: "GitHub only returns the first 3,000 changed files. This pull request exceeds that limit."
|
|
2987
|
+
};
|
|
2988
|
+
var ja = {
|
|
2989
|
+
title: "プルリクエスト",
|
|
2990
|
+
number: "プルリクエスト番号",
|
|
2991
|
+
openNumber: "PR を開く",
|
|
2992
|
+
open: "オープン",
|
|
2993
|
+
closed: "クローズ済み",
|
|
2994
|
+
merged: "マージ済み",
|
|
2995
|
+
draft: "ドラフト",
|
|
2996
|
+
prev: "前のページ",
|
|
2997
|
+
next: "次のページ",
|
|
2998
|
+
empty: "このページにプルリクエストはありません。",
|
|
2999
|
+
loading: "GitHub から取得中…",
|
|
3000
|
+
select: "プルリクエストを選ぶと差分内容を確認できます。",
|
|
3001
|
+
onGitHub: "GitHub で開く",
|
|
3002
|
+
noOrigin: "GitHub のリポジトリを origin に設定した作業フォルダを選んでください。",
|
|
3003
|
+
unavailable: "GitHub のリポジトリまたは PR を取得できません。公開リポジトリに対応しています。",
|
|
3004
|
+
rateLimit: "公開 GitHub API の利用上限に達しました。上限の解除後に再試行してください。",
|
|
3005
|
+
failed: "GitHub から取得できませんでした。再試行してください。",
|
|
3006
|
+
changed: "取得中にプルリクエストが更新されました。もう一度開いてください。",
|
|
3007
|
+
tooManyFiles: "変更ファイルが GitHub API の取得上限である 3,000 件を超えています。"
|
|
3008
|
+
};
|
|
3009
|
+
function errorMessage(error, labels) {
|
|
3010
|
+
return error instanceof PullRequestError ? labels[error.code] : labels.failed;
|
|
3011
|
+
}
|
|
3012
|
+
function PullRequests({ name, labels, locale, renderBlock }) {
|
|
3013
|
+
const client = useMemo(() => createGitHubPullRequests(name), [name]);
|
|
3014
|
+
const [page, setPage] = useState(1);
|
|
3015
|
+
const [listing, setListing] = useState();
|
|
3016
|
+
const [input, setInput] = useState("");
|
|
3017
|
+
const [selection, setSelection] = useState();
|
|
3018
|
+
const [loaded, setLoaded] = useState();
|
|
3019
|
+
const list = (listing === null || listing === void 0 ? void 0 : listing.page) === page ? listing.result : void 0;
|
|
3020
|
+
const detail = (loaded === null || loaded === void 0 ? void 0 : loaded.selection) === selection ? loaded === null || loaded === void 0 ? void 0 : loaded.result : void 0;
|
|
3021
|
+
useEffect(() => {
|
|
3022
|
+
const controller = new AbortController();
|
|
3023
|
+
setListing(void 0);
|
|
3024
|
+
client.list(page, controller.signal).then((data) => {
|
|
3025
|
+
if (!controller.signal.aborted) setListing({
|
|
3026
|
+
page,
|
|
3027
|
+
result: { data }
|
|
3028
|
+
});
|
|
3029
|
+
}, (error) => {
|
|
3030
|
+
if (!controller.signal.aborted) setListing({
|
|
3031
|
+
page,
|
|
3032
|
+
result: { error: errorMessage(error, labels) }
|
|
3033
|
+
});
|
|
3034
|
+
});
|
|
3035
|
+
return () => controller.abort();
|
|
3036
|
+
}, [
|
|
3037
|
+
client,
|
|
3038
|
+
page,
|
|
3039
|
+
labels
|
|
3040
|
+
]);
|
|
3041
|
+
useEffect(() => {
|
|
3042
|
+
if (!selection) return;
|
|
3043
|
+
const controller = new AbortController();
|
|
3044
|
+
client.load(selection.number, controller.signal).then((data) => {
|
|
3045
|
+
if (!controller.signal.aborted) setLoaded({
|
|
3046
|
+
selection,
|
|
3047
|
+
result: { data }
|
|
3048
|
+
});
|
|
3049
|
+
}, (error) => {
|
|
3050
|
+
if (!controller.signal.aborted) setLoaded({
|
|
3051
|
+
selection,
|
|
3052
|
+
result: { error: errorMessage(error, labels) }
|
|
3053
|
+
});
|
|
3054
|
+
});
|
|
3055
|
+
return () => controller.abort();
|
|
3056
|
+
}, [
|
|
3057
|
+
client,
|
|
3058
|
+
selection,
|
|
3059
|
+
labels
|
|
3060
|
+
]);
|
|
3061
|
+
const choose = (number) => {
|
|
3062
|
+
if (!Number.isSafeInteger(number) || number < 1) return;
|
|
3063
|
+
setSelection({ number });
|
|
3064
|
+
setInput(String(number));
|
|
3065
|
+
};
|
|
3066
|
+
const pr = detail === null || detail === void 0 ? void 0 : detail.data;
|
|
3067
|
+
return /* @__PURE__ */ React.createElement("div", { className: "twgit-content" }, /* @__PURE__ */ React.createElement("aside", null, /* @__PURE__ */ React.createElement("h3", null, labels.title), /* @__PURE__ */ React.createElement("p", null, name), /* @__PURE__ */ React.createElement("form", {
|
|
3068
|
+
className: "twgit-pr-number",
|
|
3069
|
+
onSubmit: (event) => {
|
|
3070
|
+
event.preventDefault();
|
|
3071
|
+
choose(Number(input));
|
|
3072
|
+
}
|
|
3073
|
+
}, /* @__PURE__ */ React.createElement("label", null, labels.number, /* @__PURE__ */ React.createElement("input", {
|
|
3074
|
+
type: "number",
|
|
3075
|
+
required: true,
|
|
3076
|
+
min: 1,
|
|
3077
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
3078
|
+
value: input,
|
|
3079
|
+
onChange: (event) => setInput(event.currentTarget.value)
|
|
3080
|
+
})), /* @__PURE__ */ React.createElement("button", { type: "submit" }, labels.openNumber)), !list && /* @__PURE__ */ React.createElement("p", { role: "status" }, labels.loading), (list === null || list === void 0 ? void 0 : list.error) && /* @__PURE__ */ React.createElement("p", { role: "alert" }, list.error), (list === null || list === void 0 ? void 0 : list.data) && /* @__PURE__ */ React.createElement(React.Fragment, null, !list.data.items.length && /* @__PURE__ */ React.createElement("p", null, labels.empty), /* @__PURE__ */ React.createElement("ul", null, list.data.items.map((item) => /* @__PURE__ */ React.createElement("li", { key: item.number }, /* @__PURE__ */ React.createElement("button", {
|
|
3081
|
+
className: "twgit-file",
|
|
3082
|
+
type: "button",
|
|
3083
|
+
"aria-pressed": (selection === null || selection === void 0 ? void 0 : selection.number) === item.number,
|
|
3084
|
+
onClick: () => choose(item.number)
|
|
3085
|
+
}, "#", item.number, " ", item.title)))), /* @__PURE__ */ React.createElement("div", { className: "twgit-pr-paging" }, /* @__PURE__ */ React.createElement("button", {
|
|
3086
|
+
type: "button",
|
|
3087
|
+
disabled: page === 1,
|
|
3088
|
+
onClick: () => setPage(page - 1)
|
|
3089
|
+
}, labels.prev), /* @__PURE__ */ React.createElement("button", {
|
|
3090
|
+
type: "button",
|
|
3091
|
+
disabled: !list.data.more,
|
|
3092
|
+
onClick: () => setPage(page + 1)
|
|
3093
|
+
}, labels.next)))), /* @__PURE__ */ React.createElement("main", { className: "twgit-diff" }, !selection && /* @__PURE__ */ React.createElement("p", null, labels.select), selection && !detail && /* @__PURE__ */ React.createElement("p", { role: "status" }, labels.loading), (detail === null || detail === void 0 ? void 0 : detail.error) && /* @__PURE__ */ React.createElement("p", { role: "alert" }, detail.error), pr && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", { className: "twgit-pr-revision" }, /* @__PURE__ */ React.createElement("strong", null, "#", pr.number, " · ", labels[pr.state]), pr.author && /* @__PURE__ */ React.createElement("span", null, pr.author), /* @__PURE__ */ React.createElement("code", { title: pr.head.sha }, pr.head.ref, " → ", pr.base.ref), /* @__PURE__ */ React.createElement("a", {
|
|
3094
|
+
href: pr.url,
|
|
3095
|
+
target: "_blank",
|
|
3096
|
+
rel: "noreferrer"
|
|
3097
|
+
}, labels.onGitHub)), /* @__PURE__ */ React.createElement(ProjectSourceReview, {
|
|
3098
|
+
title: pr.title,
|
|
3099
|
+
description: pr.description,
|
|
3100
|
+
files: pr.files,
|
|
3101
|
+
renderBlock,
|
|
3102
|
+
locale
|
|
3103
|
+
}))));
|
|
3104
|
+
}
|
|
3105
|
+
function PullRequestReviewPanel({ repository, locale, renderBlock }) {
|
|
3106
|
+
const labels = locale.startsWith("ja") ? ja : en;
|
|
3107
|
+
const [origin, setOrigin] = useState();
|
|
3108
|
+
useEffect(() => {
|
|
3109
|
+
let active = true;
|
|
3110
|
+
repository.readOrigin().then((value) => {
|
|
3111
|
+
if (active) setOrigin({
|
|
3112
|
+
repository,
|
|
3113
|
+
name: gitHubRepositoryFromOrigin(value)
|
|
3114
|
+
});
|
|
3115
|
+
}, () => {
|
|
3116
|
+
if (active) setOrigin({
|
|
3117
|
+
repository,
|
|
3118
|
+
name: null,
|
|
3119
|
+
failed: true
|
|
3120
|
+
});
|
|
3121
|
+
});
|
|
3122
|
+
return () => {
|
|
3123
|
+
active = false;
|
|
3124
|
+
};
|
|
3125
|
+
}, [repository]);
|
|
3126
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.repository) !== repository) return /* @__PURE__ */ React.createElement("p", {
|
|
3127
|
+
role: "status",
|
|
3128
|
+
className: "twgit-context"
|
|
3129
|
+
}, labels.loading);
|
|
3130
|
+
if (!origin.name) return /* @__PURE__ */ React.createElement("p", {
|
|
3131
|
+
className: "twgit-context",
|
|
3132
|
+
role: "status"
|
|
3133
|
+
}, origin.failed ? labels.failed : labels.noOrigin);
|
|
3134
|
+
return /* @__PURE__ */ React.createElement(PullRequests, {
|
|
3135
|
+
key: origin.name,
|
|
3136
|
+
name: origin.name,
|
|
3137
|
+
labels,
|
|
3138
|
+
locale,
|
|
3139
|
+
renderBlock
|
|
3140
|
+
});
|
|
3141
|
+
}
|
|
3142
|
+
// src/index.tsx
|
|
3143
|
+
init_objectSpread2();
|
|
3144
|
+
var initial = {
|
|
3145
|
+
repository: null,
|
|
3146
|
+
snapshot: null,
|
|
3147
|
+
project: null,
|
|
3148
|
+
browser: null,
|
|
3149
|
+
changes: [],
|
|
3150
|
+
selected: null,
|
|
3151
|
+
diff: null,
|
|
3152
|
+
commit: null,
|
|
3153
|
+
error: null,
|
|
3154
|
+
busy: false
|
|
3155
|
+
};
|
|
3156
|
+
var controllers = /* @__PURE__ */ new WeakMap();
|
|
3157
|
+
var watchInterval = 2e3;
|
|
3158
|
+
function GitPanel({ document, host, controller }) {
|
|
3159
|
+
var _state$repository, _state$snapshot, _state$snapshot2, _state$snapshot3, _state$snapshot4, _state$snapshot5;
|
|
3160
|
+
const [visible, setVisible] = useState(false);
|
|
3161
|
+
const [review, setReview] = useState(false);
|
|
3162
|
+
const [locale, setLocale] = useState(document.documentElement.lang || "en");
|
|
3163
|
+
const [dirty, setDirty] = useState(host.isProjectDirty());
|
|
3164
|
+
const [state, setState] = useState(initial);
|
|
3165
|
+
const current = useRef(state);
|
|
3166
|
+
current.current = state;
|
|
3167
|
+
const epoch = useRef(0);
|
|
3168
|
+
const running = useRef(false);
|
|
3169
|
+
const refreshPending = useRef(false);
|
|
3170
|
+
const remoteRequest = useRef();
|
|
3171
|
+
const alive = useRef(true);
|
|
3172
|
+
const opening = useRef(false);
|
|
3173
|
+
const dialog = useRef(null);
|
|
3174
|
+
const reviewing = useRef(review);
|
|
3175
|
+
reviewing.current = review;
|
|
3176
|
+
const handled = useRef(null);
|
|
3177
|
+
const labels = labelsFor(locale);
|
|
3178
|
+
const background = useRef(null);
|
|
3179
|
+
const run = async (operation, automatic = false) => {
|
|
3180
|
+
if (running.current && !automatic && background.current) await background.current;
|
|
3181
|
+
if (running.current || !alive.current) return;
|
|
3182
|
+
let settle = () => {};
|
|
3183
|
+
if (automatic) background.current = new Promise((resolve) => {
|
|
3184
|
+
settle = resolve;
|
|
3185
|
+
});
|
|
3186
|
+
running.current = true;
|
|
3187
|
+
const ticket = ++epoch.current;
|
|
3188
|
+
setState((previous) => automatic ? _objectSpread2$1(_objectSpread2$1({}, previous), {}, { busy: true }) : _objectSpread2$1(_objectSpread2$1({}, previous), {}, {
|
|
3189
|
+
busy: true,
|
|
3190
|
+
error: null,
|
|
3191
|
+
notice: void 0
|
|
3192
|
+
}));
|
|
3193
|
+
try {
|
|
3194
|
+
const update = await operation();
|
|
3195
|
+
if (epoch.current === ticket) setState((previous) => _objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, previous), update), {}, { busy: false }));
|
|
3196
|
+
} catch (error) {
|
|
3197
|
+
if (epoch.current !== ticket) return;
|
|
3198
|
+
const code = error instanceof GitPanelError ? error.code : "failed";
|
|
3199
|
+
const message = labels[code] || labels.failed;
|
|
3200
|
+
setState((previous) => _objectSpread2$1(_objectSpread2$1({}, previous), {}, {
|
|
3201
|
+
error: automatic && previous.error ? previous.error : message,
|
|
3202
|
+
busy: false,
|
|
3203
|
+
diff: null
|
|
3204
|
+
}));
|
|
3205
|
+
} finally {
|
|
3206
|
+
running.current = false;
|
|
3207
|
+
if (automatic) {
|
|
3208
|
+
background.current = null;
|
|
3209
|
+
settle();
|
|
3210
|
+
}
|
|
3211
|
+
if (refreshPending.current) {
|
|
3212
|
+
refreshPending.current = false;
|
|
3213
|
+
queueMicrotask(() => void controller.refresh());
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
};
|
|
3217
|
+
controller.open = (language) => {
|
|
3218
|
+
setLocale(language);
|
|
3219
|
+
setVisible(true);
|
|
3220
|
+
};
|
|
3221
|
+
controller.refresh = async (automatic = false) => {
|
|
3222
|
+
if (!alive.current || !current.current.repository) return;
|
|
3223
|
+
if (running.current) {
|
|
3224
|
+
if (!automatic) refreshPending.current = true;
|
|
3225
|
+
return;
|
|
3226
|
+
}
|
|
3227
|
+
await run(async () => {
|
|
3228
|
+
const { repository, project } = current.current;
|
|
3229
|
+
const snapshot = await repository.read(project !== null && project !== void 0 ? project : "");
|
|
3230
|
+
return {
|
|
3231
|
+
snapshot,
|
|
3232
|
+
changes: snapshot.changes,
|
|
3233
|
+
selected: null,
|
|
3234
|
+
diff: null,
|
|
3235
|
+
commit: null
|
|
3236
|
+
};
|
|
3237
|
+
}, automatic);
|
|
3238
|
+
};
|
|
3239
|
+
useEffect(() => {
|
|
3240
|
+
var _host$subscribe;
|
|
3241
|
+
alive.current = true;
|
|
3242
|
+
const unsubscribe = (_host$subscribe = host.subscribe) === null || _host$subscribe === void 0 ? void 0 : _host$subscribe.call(host, (event) => {
|
|
3243
|
+
setDirty(host.isProjectDirty());
|
|
3244
|
+
if (event === "loaded" && !opening.current) {
|
|
3245
|
+
epoch.current++;
|
|
3246
|
+
setState((previous) => _objectSpread2$1(_objectSpread2$1({}, previous), {}, {
|
|
3247
|
+
project: null,
|
|
3248
|
+
snapshot: null,
|
|
3249
|
+
changes: [],
|
|
3250
|
+
selected: null,
|
|
3251
|
+
diff: null,
|
|
3252
|
+
commit: null,
|
|
3253
|
+
busy: false
|
|
3254
|
+
}));
|
|
3255
|
+
queueMicrotask(() => void controller.refresh());
|
|
3256
|
+
}
|
|
3257
|
+
});
|
|
3258
|
+
return () => {
|
|
3259
|
+
var _remoteRequest$curren;
|
|
3260
|
+
alive.current = false;
|
|
3261
|
+
epoch.current++;
|
|
3262
|
+
(_remoteRequest$curren = remoteRequest.current) === null || _remoteRequest$curren === void 0 || _remoteRequest$curren.abort();
|
|
3263
|
+
unsubscribe === null || unsubscribe === void 0 || unsubscribe();
|
|
3264
|
+
};
|
|
3265
|
+
}, [host]);
|
|
3266
|
+
useEffect(() => {
|
|
3267
|
+
const repository = state.repository;
|
|
3268
|
+
if (!visible || !repository) return;
|
|
3269
|
+
const view = document.defaultView;
|
|
3270
|
+
let stopped = false;
|
|
3271
|
+
let checking = false;
|
|
3272
|
+
const check = async () => {
|
|
3273
|
+
const { snapshot } = current.current;
|
|
3274
|
+
if (stopped || checking || running.current || document.visibilityState === "hidden" || !snapshot || current.current.repository !== repository) return;
|
|
3275
|
+
checking = true;
|
|
3276
|
+
try {
|
|
3277
|
+
const probe = await repository.probe(snapshot.scope);
|
|
3278
|
+
if (stopped || probe === "locked" || probe === snapshot.probe || probe === handled.current || current.current.snapshot !== snapshot) return;
|
|
3279
|
+
handled.current = probe;
|
|
3280
|
+
const { selected, commit } = current.current;
|
|
3281
|
+
if (selected || commit || reviewing.current) setState((previous) => previous.snapshot === snapshot ? _objectSpread2$1(_objectSpread2$1({}, previous), {}, { notice: labelsFor(locale).outdated }) : previous);
|
|
3282
|
+
else await controller.refresh(true);
|
|
3283
|
+
} catch (_unused) {} finally {
|
|
3284
|
+
checking = false;
|
|
3285
|
+
}
|
|
3286
|
+
};
|
|
3287
|
+
let soon;
|
|
3288
|
+
const schedule = () => {
|
|
3289
|
+
view.clearTimeout(soon);
|
|
3290
|
+
soon = view.setTimeout(() => void check(), 300);
|
|
3291
|
+
};
|
|
3292
|
+
const interval = view.setInterval(() => void check(), watchInterval);
|
|
3293
|
+
const onFocus = () => void check();
|
|
3294
|
+
view.addEventListener("focus", onFocus);
|
|
3295
|
+
document.addEventListener("visibilitychange", onFocus);
|
|
3296
|
+
let observer = null;
|
|
3297
|
+
try {
|
|
3298
|
+
if (view.FileSystemObserver) {
|
|
3299
|
+
observer = new view.FileSystemObserver(schedule);
|
|
3300
|
+
observer.observe(repository.root, { recursive: true }).catch(() => {});
|
|
3301
|
+
}
|
|
3302
|
+
} catch (_unused2) {
|
|
3303
|
+
observer = null;
|
|
3304
|
+
}
|
|
3305
|
+
check();
|
|
3306
|
+
return () => {
|
|
3307
|
+
stopped = true;
|
|
3308
|
+
view.clearInterval(interval);
|
|
3309
|
+
view.clearTimeout(soon);
|
|
3310
|
+
view.removeEventListener("focus", onFocus);
|
|
3311
|
+
document.removeEventListener("visibilitychange", onFocus);
|
|
3312
|
+
observer === null || observer === void 0 || observer.disconnect();
|
|
3313
|
+
};
|
|
3314
|
+
}, [
|
|
3315
|
+
visible,
|
|
3316
|
+
state.repository,
|
|
3317
|
+
locale
|
|
3318
|
+
]);
|
|
3319
|
+
useEffect(() => {
|
|
3320
|
+
var _dialog$current;
|
|
3321
|
+
if (!visible) return;
|
|
3322
|
+
const previous = document.activeElement;
|
|
3323
|
+
(_dialog$current = dialog.current) === null || _dialog$current === void 0 || _dialog$current.focus();
|
|
3324
|
+
return () => {
|
|
3325
|
+
if (previous === null || previous === void 0 ? void 0 : previous.isConnected) previous.focus();
|
|
3326
|
+
};
|
|
3327
|
+
}, [visible]);
|
|
3328
|
+
const chooseRoot = async () => {
|
|
3329
|
+
const view = document.defaultView;
|
|
3330
|
+
await run(async () => {
|
|
3331
|
+
var _host$connectionSetti;
|
|
3332
|
+
let root;
|
|
3333
|
+
try {
|
|
3334
|
+
root = await view.showDirectoryPicker({
|
|
3335
|
+
id: "turbowarp-plus-git-root",
|
|
3336
|
+
mode: "readwrite"
|
|
3337
|
+
});
|
|
3338
|
+
} catch (error) {
|
|
3339
|
+
if (error.name === "AbortError") return {};
|
|
3340
|
+
throw error;
|
|
3341
|
+
}
|
|
3342
|
+
const repository = await openRepository(root);
|
|
3343
|
+
const snapshot = await repository.read();
|
|
3344
|
+
const browser = await repository.browse();
|
|
3345
|
+
await ((_host$connectionSetti = host.connectionSettings) === null || _host$connectionSetti === void 0 ? void 0 : _host$connectionSetti.disconnect());
|
|
3346
|
+
setReview(false);
|
|
3347
|
+
return _objectSpread2$1(_objectSpread2$1({}, initial), {}, {
|
|
3348
|
+
repository,
|
|
3349
|
+
snapshot,
|
|
3350
|
+
browser,
|
|
3351
|
+
changes: snapshot.changes
|
|
3352
|
+
});
|
|
3353
|
+
});
|
|
3354
|
+
};
|
|
3355
|
+
const browse = (path) => run(async () => ({ browser: await state.repository.browse(path) }));
|
|
3356
|
+
const openProject = (path) => run(async () => {
|
|
3357
|
+
const directory = await state.repository.openProject(path);
|
|
3358
|
+
opening.current = true;
|
|
3359
|
+
try {
|
|
3360
|
+
if (await host.openProject(directory, () => document.defaultView.confirm(labels.replace)) === "cancelled") return {};
|
|
3361
|
+
} finally {
|
|
3362
|
+
opening.current = false;
|
|
3363
|
+
}
|
|
3364
|
+
if (!alive.current) return {};
|
|
3365
|
+
setDirty(host.isProjectDirty());
|
|
3366
|
+
setState((previous) => _objectSpread2$1(_objectSpread2$1({}, previous), {}, {
|
|
3367
|
+
project: path,
|
|
3368
|
+
snapshot: null,
|
|
3369
|
+
changes: [],
|
|
3370
|
+
selected: null,
|
|
3371
|
+
diff: null,
|
|
3372
|
+
commit: null
|
|
3373
|
+
}));
|
|
3374
|
+
const snapshot = await state.repository.read(path);
|
|
3375
|
+
return {
|
|
3376
|
+
project: path,
|
|
3377
|
+
snapshot,
|
|
3378
|
+
changes: snapshot.changes,
|
|
3379
|
+
selected: null,
|
|
3380
|
+
diff: null,
|
|
3381
|
+
commit: null
|
|
3382
|
+
};
|
|
3383
|
+
});
|
|
3384
|
+
const selectFile = (selected) => run(async () => ({
|
|
3385
|
+
selected,
|
|
3386
|
+
diff: await state.repository.readDiff(state.snapshot, selected)
|
|
3387
|
+
}));
|
|
3388
|
+
const selectCommit = (commit) => run(async () => ({
|
|
3389
|
+
commit,
|
|
3390
|
+
changes: await state.repository.historyChanges(state.snapshot, commit),
|
|
3391
|
+
selected: null,
|
|
3392
|
+
diff: null
|
|
3393
|
+
}));
|
|
3394
|
+
const remoteOperation = async (operation) => {
|
|
3395
|
+
var _host$connectionSetti2, _document$defaultView;
|
|
3396
|
+
const repository = current.current.repository;
|
|
3397
|
+
const getSession = (_host$connectionSetti2 = host.connectionSettings) === null || _host$connectionSetti2 === void 0 ? void 0 : _host$connectionSetti2.getSession;
|
|
3398
|
+
if (!repository || !getSession) return;
|
|
3399
|
+
if (operation === "push" && !((_document$defaultView = document.defaultView) === null || _document$defaultView === void 0 ? void 0 : _document$defaultView.confirm(labels.confirmPush))) return;
|
|
3400
|
+
await run(async () => {
|
|
3401
|
+
var _current$current$proj;
|
|
3402
|
+
const ticket = epoch.current;
|
|
3403
|
+
const request = new AbortController();
|
|
3404
|
+
remoteRequest.current = request;
|
|
3405
|
+
try {
|
|
3406
|
+
await repository.remoteOperation(operation, getSession, () => {
|
|
3407
|
+
var _host$isProjectRunnin;
|
|
3408
|
+
if (epoch.current !== ticket) throw new GitPanelError("changed");
|
|
3409
|
+
if (operation === "pull" && (host.isProjectDirty() || ((_host$isProjectRunnin = host.isProjectRunning) === null || _host$isProjectRunnin === void 0 ? void 0 : _host$isProjectRunnin.call(host)))) throw new GitPanelError("pullUnsafe");
|
|
3410
|
+
}, request.signal);
|
|
3411
|
+
} finally {
|
|
3412
|
+
remoteRequest.current = void 0;
|
|
3413
|
+
}
|
|
3414
|
+
const snapshot = await repository.read((_current$current$proj = current.current.project) !== null && _current$current$proj !== void 0 ? _current$current$proj : "");
|
|
3415
|
+
return {
|
|
3416
|
+
snapshot,
|
|
3417
|
+
changes: snapshot.changes,
|
|
3418
|
+
selected: null,
|
|
3419
|
+
diff: null,
|
|
3420
|
+
commit: null,
|
|
3421
|
+
notice: operation === "pull" && current.current.project !== null ? labels.pulledProject : labels.remoteDone
|
|
3422
|
+
};
|
|
3423
|
+
});
|
|
3424
|
+
};
|
|
3425
|
+
const focusTrap = (event) => {
|
|
3426
|
+
if (event.key === "Escape") {
|
|
3427
|
+
event.stopPropagation();
|
|
3428
|
+
setVisible(false);
|
|
3429
|
+
return;
|
|
3430
|
+
}
|
|
3431
|
+
if (event.key !== "Tab") return;
|
|
3432
|
+
const items = [...event.currentTarget.querySelectorAll("button:not(:disabled), input:not(:disabled), select:not(:disabled), a[href], summary, [tabindex=\"0\"]")].filter((item) => item.getClientRects().length > 0);
|
|
3433
|
+
const first = items[0], last = items[items.length - 1];
|
|
3434
|
+
if (event.shiftKey && (document.activeElement === first || document.activeElement === event.currentTarget)) {
|
|
3435
|
+
event.preventDefault();
|
|
3436
|
+
last === null || last === void 0 || last.focus();
|
|
3437
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
3438
|
+
event.preventDefault();
|
|
3439
|
+
first === null || first === void 0 || first.focus();
|
|
3440
|
+
}
|
|
3441
|
+
};
|
|
3442
|
+
const loadAsset = useMemo(() => state.repository && state.snapshot && state.selected ? state.repository.assetLoader(state.snapshot, state.selected) : void 0, [
|
|
3443
|
+
state.repository,
|
|
3444
|
+
state.snapshot,
|
|
3445
|
+
state.selected
|
|
3446
|
+
]);
|
|
3447
|
+
if (!visible) return null;
|
|
3448
|
+
const groups = state.commit ? ["commit"] : [
|
|
3449
|
+
"staged",
|
|
3450
|
+
"unstaged",
|
|
3451
|
+
"untracked"
|
|
3452
|
+
];
|
|
3453
|
+
return /* @__PURE__ */ React.createElement("div", { className: "twgit-backdrop" }, /* @__PURE__ */ React.createElement("div", {
|
|
3454
|
+
className: "twgit-panel",
|
|
3455
|
+
ref: dialog,
|
|
3456
|
+
tabIndex: -1,
|
|
3457
|
+
role: "dialog",
|
|
3458
|
+
"aria-modal": "true",
|
|
3459
|
+
"aria-label": labels.title,
|
|
3460
|
+
onKeyDown: focusTrap
|
|
3461
|
+
}, /* @__PURE__ */ React.createElement("header", null, /* @__PURE__ */ React.createElement("h2", null, labels.title), /* @__PURE__ */ React.createElement("button", {
|
|
3462
|
+
onClick: chooseRoot,
|
|
3463
|
+
disabled: state.busy
|
|
3464
|
+
}, labels.choose), !review && /* @__PURE__ */ React.createElement("button", {
|
|
3465
|
+
onClick: () => void controller.refresh(),
|
|
3466
|
+
disabled: !state.repository || state.busy
|
|
3467
|
+
}, labels.refresh), !review && state.project !== null && /* @__PURE__ */ React.createElement("button", {
|
|
3468
|
+
disabled: state.busy,
|
|
3469
|
+
onClick: () => void openProject(state.project)
|
|
3470
|
+
}, labels.reload), state.repository && host.renderReviewBlock && /* @__PURE__ */ React.createElement("button", {
|
|
3471
|
+
type: "button",
|
|
3472
|
+
disabled: state.busy,
|
|
3473
|
+
onClick: () => setReview(!review)
|
|
3474
|
+
}, review ? labels.localChanges : labels.pullRequests), /* @__PURE__ */ React.createElement("button", { onClick: () => setVisible(false) }, labels.close)), /* @__PURE__ */ React.createElement("div", { className: "twgit-context" }, /* @__PURE__ */ React.createElement("span", null, labels.repository, " · ", ((_state$repository = state.repository) === null || _state$repository === void 0 ? void 0 : _state$repository.root.name) || "—"), /* @__PURE__ */ React.createElement("span", null, labels.project, " · ", state.project === null ? labels.none : state.project || labels.root), /* @__PURE__ */ React.createElement("strong", null, ((_state$snapshot = state.snapshot) === null || _state$snapshot === void 0 ? void 0 : _state$snapshot.branch) || (((_state$snapshot2 = state.snapshot) === null || _state$snapshot2 === void 0 ? void 0 : _state$snapshot2.head) ? labels.detached : labels.unborn)), /* @__PURE__ */ React.createElement("code", null, (_state$snapshot3 = state.snapshot) === null || _state$snapshot3 === void 0 || (_state$snapshot3 = _state$snapshot3.head) === null || _state$snapshot3 === void 0 ? void 0 : _state$snapshot3.slice(0, 12)), /* @__PURE__ */ React.createElement("span", { "data-git-dirty": "" }, dirty ? labels.dirty : labels.saved)), !review && host.connectionSettings && /* @__PURE__ */ React.createElement(ConnectionSettings, {
|
|
3475
|
+
settings: host.connectionSettings,
|
|
3476
|
+
locale,
|
|
3477
|
+
runOperation: host.connectionSettings.getSession ? remoteOperation : void 0,
|
|
3478
|
+
readOrigin: state.repository && !state.busy ? async () => {
|
|
3479
|
+
const ticket = epoch.current;
|
|
3480
|
+
const remote = await state.repository.readOrigin();
|
|
3481
|
+
return epoch.current === ticket ? remote : void 0;
|
|
3482
|
+
} : void 0
|
|
3483
|
+
}), state.error && /* @__PURE__ */ React.createElement("p", {
|
|
3484
|
+
className: "twgit-error",
|
|
3485
|
+
role: "alert"
|
|
3486
|
+
}, state.error), state.notice && /* @__PURE__ */ React.createElement("p", {
|
|
3487
|
+
className: "twgit-context",
|
|
3488
|
+
role: "status"
|
|
3489
|
+
}, state.notice), state.busy && /* @__PURE__ */ React.createElement("p", { role: "status" }, labels.loading), !state.repository && /* @__PURE__ */ React.createElement("p", null, labels.empty), review && state.repository && host.renderReviewBlock && /* @__PURE__ */ React.createElement(PullRequestReviewPanel, {
|
|
3490
|
+
repository: state.repository,
|
|
3491
|
+
locale,
|
|
3492
|
+
renderBlock: host.renderReviewBlock
|
|
3493
|
+
}), !review && state.repository && /* @__PURE__ */ React.createElement("div", { className: "twgit-content" }, /* @__PURE__ */ React.createElement("aside", null, state.browser && /* @__PURE__ */ React.createElement("details", null, /* @__PURE__ */ React.createElement("summary", null, labels.browse), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("code", null, state.browser.path || "/")), /* @__PURE__ */ React.createElement("button", {
|
|
3494
|
+
disabled: state.busy || !state.browser.path,
|
|
3495
|
+
onClick: () => void browse(state.browser.path.split("/").slice(0, -1).join("/"))
|
|
3496
|
+
}, labels.up), /* @__PURE__ */ React.createElement("button", {
|
|
3497
|
+
"data-git-open-project": "",
|
|
3498
|
+
disabled: state.busy || !state.browser.isProject,
|
|
3499
|
+
onClick: () => void openProject(state.browser.path)
|
|
3500
|
+
}, labels.open), /* @__PURE__ */ React.createElement("ul", null, state.browser.children.map((name) => /* @__PURE__ */ React.createElement("li", { key: name }, /* @__PURE__ */ React.createElement("button", {
|
|
3501
|
+
disabled: state.busy,
|
|
3502
|
+
onClick: () => void browse([state.browser.path, name].filter(Boolean).join("/"))
|
|
3503
|
+
}, name, "/"))))), /* @__PURE__ */ React.createElement("h3", null, /* @__PURE__ */ React.createElement("button", {
|
|
3504
|
+
disabled: state.busy,
|
|
3505
|
+
onClick: () => void controller.refresh()
|
|
3506
|
+
}, labels.worktree)), groups.map((group) => /* @__PURE__ */ React.createElement("section", { key: group }, /* @__PURE__ */ React.createElement("h3", null, labels[group], " · ", state.changes.filter((change) => change.group === group).length), /* @__PURE__ */ React.createElement("ul", null, state.changes.filter((change) => change.group === group).map((change) => /* @__PURE__ */ React.createElement("li", { key: change.path }, /* @__PURE__ */ React.createElement("button", {
|
|
3507
|
+
className: "twgit-file",
|
|
3508
|
+
"data-git-group": group,
|
|
3509
|
+
disabled: state.busy,
|
|
3510
|
+
"aria-pressed": state.selected === change,
|
|
3511
|
+
onClick: () => void selectFile(change)
|
|
3512
|
+
}, /* @__PURE__ */ React.createElement("span", null, !change.after ? "D" : !change.before ? "A" : "M"), " ", change.path)))))), !state.changes.length && /* @__PURE__ */ React.createElement("p", null, labels.clean), /* @__PURE__ */ React.createElement("details", null, /* @__PURE__ */ React.createElement("summary", null, labels.branches), /* @__PURE__ */ React.createElement("ul", null, (_state$snapshot4 = state.snapshot) === null || _state$snapshot4 === void 0 ? void 0 : _state$snapshot4.branches.map((branch) => /* @__PURE__ */ React.createElement("li", { key: branch }, branch)))), /* @__PURE__ */ React.createElement("h3", null, labels.history), /* @__PURE__ */ React.createElement("ol", { className: "twgit-history" }, (_state$snapshot5 = state.snapshot) === null || _state$snapshot5 === void 0 ? void 0 : _state$snapshot5.commits.map((commit) => /* @__PURE__ */ React.createElement("li", { key: commit.oid }, /* @__PURE__ */ React.createElement("button", {
|
|
3513
|
+
disabled: state.busy,
|
|
3514
|
+
"aria-pressed": state.commit === commit.oid,
|
|
3515
|
+
title: commit.oid,
|
|
3516
|
+
onClick: () => void selectCommit(commit.oid)
|
|
3517
|
+
}, commit.message.split("\n")[0]), /* @__PURE__ */ React.createElement("small", null, /* @__PURE__ */ React.createElement("code", null, commit.oid.slice(0, 8)), " · ", commit.author, " · ", (/* @__PURE__ */ new Date(commit.timestamp * 1e3)).toLocaleString(locale)))))), /* @__PURE__ */ React.createElement("main", { className: "twgit-diff" }, state.selected ? /* @__PURE__ */ React.createElement(FileDiffView, {
|
|
3518
|
+
change: state.selected,
|
|
3519
|
+
diff: state.diff,
|
|
3520
|
+
labels,
|
|
3521
|
+
locale,
|
|
3522
|
+
renderBlock: host.renderReviewBlock,
|
|
3523
|
+
loadAsset
|
|
3524
|
+
}) : /* @__PURE__ */ React.createElement("p", null, labels.select))), /* @__PURE__ */ React.createElement("footer", null, labels.permissions)));
|
|
3525
|
+
}
|
|
3526
|
+
function mountGitPanel({ vm, document, host }) {
|
|
3527
|
+
var _document$defaultView2;
|
|
3528
|
+
if (!((_document$defaultView2 = document.defaultView) === null || _document$defaultView2 === void 0 ? void 0 : _document$defaultView2.showDirectoryPicker)) return null;
|
|
3529
|
+
const root = document.createElement("div");
|
|
3530
|
+
document.body.append(root);
|
|
3531
|
+
const controller = {
|
|
3532
|
+
open() {},
|
|
3533
|
+
async refresh() {}
|
|
3534
|
+
};
|
|
3535
|
+
controllers.set(vm, controller);
|
|
3536
|
+
render(/* @__PURE__ */ React.createElement(GitPanel, {
|
|
3537
|
+
document,
|
|
3538
|
+
host,
|
|
3539
|
+
controller
|
|
3540
|
+
}), root);
|
|
3541
|
+
return {
|
|
3542
|
+
refresh: () => controller.refresh(),
|
|
3543
|
+
dispose() {
|
|
3544
|
+
var _host$connectionSetti3;
|
|
3545
|
+
if (controllers.get(vm) === controller) controllers.delete(vm);
|
|
3546
|
+
(_host$connectionSetti3 = host.connectionSettings) === null || _host$connectionSetti3 === void 0 || _host$connectionSetti3.disconnect().catch(() => {});
|
|
3547
|
+
unmountComponentAtNode(root);
|
|
3548
|
+
root.remove();
|
|
3549
|
+
}
|
|
3550
|
+
};
|
|
3551
|
+
}
|
|
3552
|
+
function renderGitMenu(createElement, { vm, locale = "en", MenuItem, MenuSection, onRequestClose }) {
|
|
3553
|
+
const controller = controllers.get(vm);
|
|
3554
|
+
if (!controller) return null;
|
|
3555
|
+
return createElement(MenuSection, null, createElement(MenuItem, {
|
|
3556
|
+
command: "local-git",
|
|
3557
|
+
onClick() {
|
|
3558
|
+
onRequestClose();
|
|
3559
|
+
controller.open(locale);
|
|
3560
|
+
}
|
|
3561
|
+
}, labelsFor(locale).menu));
|
|
3562
|
+
}
|
|
3563
|
+
export { GitPanelError, createReadOnlyFs, createScratchBlocksDiffRenderer, mountGitPanel, openRepository, renderGitMenu };
|