@comate/zulu 0.2.1-beta.2 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/comate-engine/bin/comate.js +9 -0
- package/comate-engine/node_modules/@comate/plugin-engine/dist/index.js +8 -8
- package/comate-engine/node_modules/@comate/plugin-host/dist/index.js +1 -1
- package/comate-engine/node_modules/@comate/plugin-host/dist/main.js +1 -1
- package/comate-engine/node_modules/@comate/plugin-host/dist/user-DQgjkMe9.js +44 -0
- package/comate-engine/node_modules/@comate/plugin-shared-internals/dist/index.d.ts +24 -6
- package/comate-engine/node_modules/@comate/plugin-shared-internals/dist/index.js +8 -8
- package/comate-engine/node_modules/@comate/preview-proxy/dist/index.js +59 -72
- package/comate-engine/node_modules/@comate/preview-proxy/static/comate-preview-injector.css +1 -1
- package/comate-engine/node_modules/@comate/preview-proxy/static/comate-preview-injector.js +1 -1
- package/comate-engine/node_modules/better-sqlite3/node_modules/.bin/prebuild-install +2 -2
- package/comate-engine/plugins/demo-feature/dist/index.js +337 -30
- package/comate-engine/server.js +11 -11
- package/dist/bundle/index.js +8 -8
- package/package.json +1 -1
- package/comate-engine/node_modules/@comate/plugin-host/dist/user-Buhpnssj.js +0 -44
- package/comate-engine/plugins/aiscan/assets/icon.svg +0 -12
- package/comate-engine/plugins/aiscan/dist/index.js +0 -53861
- package/comate-engine/plugins/aiscan/package.json +0 -67
- package/comate-engine/plugins/appdev/assets/icon.png +0 -0
- package/comate-engine/plugins/appdev/dist/help.md +0 -12
- package/comate-engine/plugins/appdev/dist/index.d.ts +0 -2
- package/comate-engine/plugins/appdev/dist/index.js +0 -194
- package/comate-engine/plugins/appdev/dist/providers/err.d.ts +0 -8
- package/comate-engine/plugins/appdev/dist/providers/err.js +0 -37
- package/comate-engine/plugins/appdev/dist/providers/fallback.d.ts +0 -5
- package/comate-engine/plugins/appdev/dist/providers/fallback.js +0 -28
- package/comate-engine/plugins/appdev/dist/providers/help.d.ts +0 -8
- package/comate-engine/plugins/appdev/dist/providers/help.js +0 -19
- package/comate-engine/plugins/appdev/dist/providers/medusa.d.ts +0 -8
- package/comate-engine/plugins/appdev/dist/providers/medusa.js +0 -39
- package/comate-engine/plugins/appdev/dist/providers/qa.d.ts +0 -8
- package/comate-engine/plugins/appdev/dist/providers/qa.js +0 -33
- package/comate-engine/plugins/appdev/package.json +0 -67
- package/comate-engine/plugins/bfc/assets/bfc-icon.png +0 -0
- package/comate-engine/plugins/bfc/dist/config/config.d.ts +0 -4
- package/comate-engine/plugins/bfc/dist/config/config.js +0 -4
- package/comate-engine/plugins/bfc/dist/help.md +0 -11
- package/comate-engine/plugins/bfc/dist/index.d.ts +0 -2
- package/comate-engine/plugins/bfc/dist/index.js +0 -452
- package/comate-engine/plugins/bfc/dist/providers/bfcInstructMode.d.ts +0 -8
- package/comate-engine/plugins/bfc/dist/providers/bfcInstructMode.js +0 -77
- package/comate-engine/plugins/bfc/dist/providers/genAbnormalCode.d.ts +0 -8
- package/comate-engine/plugins/bfc/dist/providers/genAbnormalCode.js +0 -71
- package/comate-engine/plugins/bfc/dist/providers/genBfcCode.d.ts +0 -8
- package/comate-engine/plugins/bfc/dist/providers/genBfcCode.js +0 -74
- package/comate-engine/plugins/bfc/dist/providers/getBatchCases.d.ts +0 -10
- package/comate-engine/plugins/bfc/dist/providers/getBatchCases.js +0 -71
- package/comate-engine/plugins/bfc/dist/providers/help.d.ts +0 -8
- package/comate-engine/plugins/bfc/dist/providers/help.js +0 -19
- package/comate-engine/plugins/bfc/dist/service/generateService.d.ts +0 -14
- package/comate-engine/plugins/bfc/dist/service/generateService.js +0 -27
- package/comate-engine/plugins/bfc/package.json +0 -85
- package/comate-engine/plugins/bpm/assets/bpm.png +0 -0
- package/comate-engine/plugins/bpm/dist/index.js +0 -313
- package/comate-engine/plugins/bpm/package.json +0 -65
- package/comate-engine/plugins/casebuilder/assets/icon.svg +0 -1
- package/comate-engine/plugins/casebuilder/dist/help.md +0 -33
- package/comate-engine/plugins/casebuilder/dist/index.js +0 -837
- package/comate-engine/plugins/casebuilder/package.json +0 -80
- package/comate-engine/plugins/centrino/assets/icon.png +0 -0
- package/comate-engine/plugins/centrino/dist/help.md +0 -30
- package/comate-engine/plugins/centrino/dist/index.js +0 -1046
- package/comate-engine/plugins/centrino/package.json +0 -68
- package/comate-engine/plugins/cnap/assets/cnap.png +0 -0
- package/comate-engine/plugins/cnap/dist/help.md +0 -11
- package/comate-engine/plugins/cnap/dist/index.js +0 -171
- package/comate-engine/plugins/cnap/package.json +0 -65
- package/comate-engine/plugins/demo-timer/assets/icon.svg +0 -2
- package/comate-engine/plugins/demo-timer/dist/index.js +0 -463
- package/comate-engine/plugins/demo-timer/package.json +0 -73
- package/comate-engine/plugins/dev-tools/assets/icon.png +0 -0
- package/comate-engine/plugins/dev-tools/dist/help.md +0 -18
- package/comate-engine/plugins/dev-tools/dist/index.js +0 -166160
- package/comate-engine/plugins/dev-tools/package.json +0 -95
- package/comate-engine/plugins/devaux/assets/icon.svg +0 -1
- package/comate-engine/plugins/devaux/dist/help.md +0 -41
- package/comate-engine/plugins/devaux/dist/index.js +0 -74138
- package/comate-engine/plugins/devaux/dist/static/tree-sitter-cpp.wasm +0 -0
- package/comate-engine/plugins/devaux/dist/static/tree-sitter-go.wasm +0 -0
- package/comate-engine/plugins/devaux/dist/static/tree-sitter.wasm +0 -0
- package/comate-engine/plugins/devaux/dist/tree-sitter.wasm +0 -0
- package/comate-engine/plugins/devaux/package.json +0 -83
- package/comate-engine/plugins/f2c/assets/icon.svg +0 -11
- package/comate-engine/plugins/f2c/dist/help.md +0 -13
- package/comate-engine/plugins/f2c/dist/index.js +0 -81787
- package/comate-engine/plugins/f2c/package.json +0 -56
- package/comate-engine/plugins/fcnap/assets/icon.png +0 -0
- package/comate-engine/plugins/fcnap/dist/help.md +0 -9
- package/comate-engine/plugins/fcnap/dist/index.js +0 -105
- package/comate-engine/plugins/fcnap/package.json +0 -50
- package/comate-engine/plugins/front-end-skills/assets/icon.svg +0 -1
- package/comate-engine/plugins/front-end-skills/dist/help.md +0 -17
- package/comate-engine/plugins/front-end-skills/dist/index.js +0 -8172
- package/comate-engine/plugins/front-end-skills/package.json +0 -79
- package/comate-engine/plugins/gdp/assets/icon.png +0 -0
- package/comate-engine/plugins/gdp/dist/help.md +0 -11
- package/comate-engine/plugins/gdp/dist/index.js +0 -53065
- package/comate-engine/plugins/gdp/package.json +0 -79
- package/comate-engine/plugins/git/assets/git.svg +0 -1
- package/comate-engine/plugins/git/assets/icon.svg +0 -1
- package/comate-engine/plugins/git/dist/help.md +0 -7
- package/comate-engine/plugins/git/dist/index.js +0 -32675
- package/comate-engine/plugins/git/package.json +0 -91
- package/comate-engine/plugins/harmonyos/assets/harmonyos.png +0 -0
- package/comate-engine/plugins/harmonyos/dist/index.js +0 -78
- package/comate-engine/plugins/harmonyos/package.json +0 -37
- package/comate-engine/plugins/iapi/assets/icon.png +0 -0
- package/comate-engine/plugins/iapi/dist/help.md +0 -13
- package/comate-engine/plugins/iapi/dist/index.js +0 -458
- package/comate-engine/plugins/iapi/dist/static/lang/tree-sitter-go.wasm +0 -0
- package/comate-engine/plugins/iapi/dist/static/lang/tree-sitter-java.wasm +0 -0
- package/comate-engine/plugins/iapi/dist/static/tree-sitter-go.wasm +0 -0
- package/comate-engine/plugins/iapi/dist/static/tree-sitter-java.wasm +0 -0
- package/comate-engine/plugins/iapi/dist/tree-sitter.wasm +0 -0
- package/comate-engine/plugins/iapi/package.json +0 -102
- package/comate-engine/plugins/icafe/assets/icafe.svg +0 -1
- package/comate-engine/plugins/icafe/dist/help.md +0 -5
- package/comate-engine/plugins/icafe/dist/index.js +0 -885
- package/comate-engine/plugins/icafe/package.json +0 -74
- package/comate-engine/plugins/ievalue/assets/iEValue.svg +0 -10
- package/comate-engine/plugins/ievalue/dist/index.js +0 -2920
- package/comate-engine/plugins/ievalue/package.json +0 -88
- package/comate-engine/plugins/ipipe/assets/iPipePlugin.png +0 -0
- package/comate-engine/plugins/ipipe/dist/help.md +0 -15
- package/comate-engine/plugins/ipipe/dist/index.js +0 -7264
- package/comate-engine/plugins/ipipe/package.json +0 -62
- package/comate-engine/plugins/jarvis/assets/icon.svg +0 -1
- package/comate-engine/plugins/jarvis/dist/help.md +0 -17
- package/comate-engine/plugins/jarvis/dist/index.js +0 -140416
- package/comate-engine/plugins/jarvis/package.json +0 -93
- package/comate-engine/plugins/mapsearch/assets/mapsearchicon.png +0 -0
- package/comate-engine/plugins/mapsearch/dist/help.md +0 -4
- package/comate-engine/plugins/mapsearch/dist/index.js +0 -145
- package/comate-engine/plugins/mapsearch/package.json +0 -53
- package/comate-engine/plugins/paddle/assets/icon.png +0 -0
- package/comate-engine/plugins/paddle/assets/paconvert-3.0.1-py3-none-any.whl +0 -0
- package/comate-engine/plugins/paddle/dist/help.md +0 -31
- package/comate-engine/plugins/paddle/dist/index.js +0 -1011
- package/comate-engine/plugins/paddle/package.json +0 -129
- package/comate-engine/plugins/robot/assets/Robot.png +0 -0
- package/comate-engine/plugins/robot/dist/index.js +0 -288
- package/comate-engine/plugins/robot/package.json +0 -67
- package/comate-engine/plugins/security/assets/comate.png +0 -0
- package/comate-engine/plugins/security/dist/index.js +0 -18393
- package/comate-engine/plugins/security/package.json +0 -82
- package/comate-engine/plugins/smartapp/assets/icon.png +0 -0
- package/comate-engine/plugins/smartapp/dist/help.md +0 -4
- package/comate-engine/plugins/smartapp/dist/index.js +0 -113
- package/comate-engine/plugins/smartapp/package.json +0 -54
- package/comate-engine/plugins/testmate/assets/icon.svg +0 -1
- package/comate-engine/plugins/testmate/dist/help.md +0 -62
- package/comate-engine/plugins/testmate/dist/index.js +0 -21483
- package/comate-engine/plugins/testmate/package.json +0 -85
- package/comate-engine/plugins/tor/assets/TorPlugin.png +0 -0
- package/comate-engine/plugins/tor/dist/help.md +0 -22
- package/comate-engine/plugins/tor/dist/index.js +0 -807
- package/comate-engine/plugins/tor/package.json +0 -99
- package/comate-engine/plugins/weiyun/assets/icon.png +0 -0
- package/comate-engine/plugins/weiyun/dist/help.md +0 -11
- package/comate-engine/plugins/weiyun/dist/index.js +0 -100491
- package/comate-engine/plugins/weiyun/package.json +0 -55
- package/comate-engine/plugins/workcard/assets/favicon.png +0 -0
- package/comate-engine/plugins/workcard/dist/help.md +0 -30
- package/comate-engine/plugins/workcard/dist/index.js +0 -490
- package/comate-engine/plugins/workcard/package.json +0 -95
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/Users/bear/baidu/ide/comate-plugin-host/node_modules/.pnpm/prebuild-install@7.1.2/node_modules/prebuild-install/node_modules:/Users/bear/baidu/ide/comate-plugin-host/node_modules/.pnpm/prebuild-install@7.1.2/node_modules:/Users/bear/baidu/ide/comate-plugin-host/node_modules/.pnpm/node_modules"
|
|
9
|
+
export NODE_PATH="/Users/bear/baidu/ide/comate-plugin-host-copy/node_modules/.pnpm/prebuild-install@7.1.2/node_modules/prebuild-install/node_modules:/Users/bear/baidu/ide/comate-plugin-host-copy/node_modules/.pnpm/prebuild-install@7.1.2/node_modules:/Users/bear/baidu/ide/comate-plugin-host-copy/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="/Users/bear/baidu/ide/comate-plugin-host/node_modules/.pnpm/prebuild-install@7.1.2/node_modules/prebuild-install/node_modules:/Users/bear/baidu/ide/comate-plugin-host/node_modules/.pnpm/prebuild-install@7.1.2/node_modules:/Users/bear/baidu/ide/comate-plugin-host/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
11
|
+
export NODE_PATH="/Users/bear/baidu/ide/comate-plugin-host-copy/node_modules/.pnpm/prebuild-install@7.1.2/node_modules/prebuild-install/node_modules:/Users/bear/baidu/ide/comate-plugin-host-copy/node_modules/.pnpm/prebuild-install@7.1.2/node_modules:/Users/bear/baidu/ide/comate-plugin-host-copy/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../../../../../prebuild-install@7.1.2/node_modules/prebuild-install/bin.js" "$@"
|
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
4
4
|
import require$$0$4, { dirname } from 'path';
|
|
5
5
|
import path$p from 'node:path';
|
|
6
6
|
import 'node:fs/promises';
|
|
7
|
-
import
|
|
7
|
+
import 'node:fs';
|
|
8
8
|
import require$$0$1 from 'constants';
|
|
9
9
|
import stream$5, { Readable } from 'stream';
|
|
10
10
|
import require$$0$3 from 'util';
|
|
@@ -17,7 +17,7 @@ import crypto from 'crypto';
|
|
|
17
17
|
import require$$0$7 from 'tty';
|
|
18
18
|
import zlib from 'zlib';
|
|
19
19
|
import require$$0$8, { EventEmitter } from 'events';
|
|
20
|
-
import
|
|
20
|
+
import 'node:os';
|
|
21
21
|
import 'node:process';
|
|
22
22
|
import 'node:stream';
|
|
23
23
|
import 'node:crypto';
|
|
@@ -3336,7 +3336,7 @@ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream',
|
|
|
3336
3336
|
*
|
|
3337
3337
|
* @returns {String} The String freed of excess whitespace
|
|
3338
3338
|
*/
|
|
3339
|
-
const trim = (str) => str.trim ?
|
|
3339
|
+
const trim$1 = (str) => str.trim ?
|
|
3340
3340
|
str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
3341
3341
|
|
|
3342
3342
|
/**
|
|
@@ -3829,7 +3829,7 @@ var utils$m = {
|
|
|
3829
3829
|
forEach,
|
|
3830
3830
|
merge: merge$1,
|
|
3831
3831
|
extend,
|
|
3832
|
-
trim,
|
|
3832
|
+
trim: trim$1,
|
|
3833
3833
|
stripBOM,
|
|
3834
3834
|
inherits,
|
|
3835
3835
|
toFlatObject,
|
|
@@ -22021,35 +22021,11 @@ var WEBVIEW_CONSUMER;
|
|
|
22021
22021
|
WEBVIEW_CONSUMER["JETBRAINS"] = "jetbrains";
|
|
22022
22022
|
})(WEBVIEW_CONSUMER || (WEBVIEW_CONSUMER = {}));
|
|
22023
22023
|
|
|
22024
|
-
const COMATE = 'Comate';
|
|
22025
|
-
function getUserDataPathForEditor() {
|
|
22026
|
-
const productName = COMATE;
|
|
22027
|
-
switch(os$2.platform()){
|
|
22028
|
-
case 'win32':
|
|
22029
|
-
return path$p.join(homedir(), 'AppData', 'Roaming', productName, 'User');
|
|
22030
|
-
case 'darwin':
|
|
22031
|
-
return path$p.join(homedir(), 'Library', 'Application Support', productName, 'User');
|
|
22032
|
-
default:
|
|
22033
|
-
return path$p.join(homedir(), '.config', productName, 'User');
|
|
22034
|
-
}
|
|
22035
|
-
}
|
|
22036
22024
|
const SAAS_API_HOST = 'https://comate.baidu.com';
|
|
22037
22025
|
const INTERNAL_API_HOST = 'https://comate.baidu-int.com';
|
|
22038
22026
|
const SAAS_TEST_API_HOST = 'https://comate-cop.now.baidu.com';
|
|
22039
22027
|
const INTERNAL_TEST_API_HOST = 'https://comate-test.now.baidu.com';
|
|
22040
|
-
|
|
22041
|
-
try {
|
|
22042
|
-
if (process.env.IDE === 'ide') {
|
|
22043
|
-
const file = path$p.join(getUserDataPathForEditor(), 'loginMode.json');
|
|
22044
|
-
return JSON.parse(fs$s.readFileSync(file, 'utf8'));
|
|
22045
|
-
}
|
|
22046
|
-
return {};
|
|
22047
|
-
} catch (e) {
|
|
22048
|
-
return {};
|
|
22049
|
-
}
|
|
22050
|
-
})();
|
|
22051
|
-
const isUuapLoginUser = loginMode.loginMode === 'uuap';
|
|
22052
|
-
let platform = process.env.IDE === 'ide' && isUuapLoginUser ? PLATFORM.INTERNAL : process.env.PLATFORM || PLATFORM.INTERNAL;
|
|
22028
|
+
let platform = process.env.PLATFORM || PLATFORM.INTERNAL;
|
|
22053
22029
|
let environment = process.env.ENVIRONMENT || ENVIRONMENT.PRODUCTION;
|
|
22054
22030
|
let displayLanguage = process.env.DISPLAY_LANGUAGE || 'zh';
|
|
22055
22031
|
let acceptLanguage = process.env.ACCEPT_LANGUAGE || 'zh-CN,zh';
|
|
@@ -22116,7 +22092,6 @@ function parseProxyUrl(proxyUrl) {
|
|
|
22116
22092
|
return defaults;
|
|
22117
22093
|
}
|
|
22118
22094
|
}
|
|
22119
|
-
platform === PLATFORM.SAAS ? SAAS_API_HOST : INTERNAL_API_HOST;
|
|
22120
22095
|
const config = {
|
|
22121
22096
|
};
|
|
22122
22097
|
const proxyURL = process.env.HTTP_PROXY_URL || '';
|
|
@@ -51671,6 +51646,338 @@ var VirtualDocumentAction;
|
|
|
51671
51646
|
VirtualDocumentAction["PREVIEW"] = "preview";
|
|
51672
51647
|
})(VirtualDocumentAction || (VirtualDocumentAction = {}));
|
|
51673
51648
|
|
|
51649
|
+
class Diff {
|
|
51650
|
+
diff(oldStr, newStr,
|
|
51651
|
+
// Type below is not accurate/complete - see above for full possibilities - but it compiles
|
|
51652
|
+
options = {}) {
|
|
51653
|
+
let callback;
|
|
51654
|
+
if (typeof options === 'function') {
|
|
51655
|
+
callback = options;
|
|
51656
|
+
options = {};
|
|
51657
|
+
}
|
|
51658
|
+
else if ('callback' in options) {
|
|
51659
|
+
callback = options.callback;
|
|
51660
|
+
}
|
|
51661
|
+
// Allow subclasses to massage the input prior to running
|
|
51662
|
+
const oldString = this.castInput(oldStr, options);
|
|
51663
|
+
const newString = this.castInput(newStr, options);
|
|
51664
|
+
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
51665
|
+
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
51666
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
51667
|
+
}
|
|
51668
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
51669
|
+
var _a;
|
|
51670
|
+
const done = (value) => {
|
|
51671
|
+
value = this.postProcess(value, options);
|
|
51672
|
+
if (callback) {
|
|
51673
|
+
setTimeout(function () { callback(value); }, 0);
|
|
51674
|
+
return undefined;
|
|
51675
|
+
}
|
|
51676
|
+
else {
|
|
51677
|
+
return value;
|
|
51678
|
+
}
|
|
51679
|
+
};
|
|
51680
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
51681
|
+
let editLength = 1;
|
|
51682
|
+
let maxEditLength = newLen + oldLen;
|
|
51683
|
+
if (options.maxEditLength != null) {
|
|
51684
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
51685
|
+
}
|
|
51686
|
+
const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
|
|
51687
|
+
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
51688
|
+
const bestPath = [{ oldPos: -1, lastComponent: undefined }];
|
|
51689
|
+
// Seed editLength = 0, i.e. the content starts with the same values
|
|
51690
|
+
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
51691
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
51692
|
+
// Identity per the equality and tokenizer
|
|
51693
|
+
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
51694
|
+
}
|
|
51695
|
+
// Once we hit the right edge of the edit graph on some diagonal k, we can
|
|
51696
|
+
// definitely reach the end of the edit graph in no more than k edits, so
|
|
51697
|
+
// there's no point in considering any moves to diagonal k+1 any more (from
|
|
51698
|
+
// which we're guaranteed to need at least k+1 more edits).
|
|
51699
|
+
// Similarly, once we've reached the bottom of the edit graph, there's no
|
|
51700
|
+
// point considering moves to lower diagonals.
|
|
51701
|
+
// We record this fact by setting minDiagonalToConsider and
|
|
51702
|
+
// maxDiagonalToConsider to some finite value once we've hit the edge of
|
|
51703
|
+
// the edit graph.
|
|
51704
|
+
// This optimization is not faithful to the original algorithm presented in
|
|
51705
|
+
// Myers's paper, which instead pointlessly extends D-paths off the end of
|
|
51706
|
+
// the edit graph - see page 7 of Myers's paper which notes this point
|
|
51707
|
+
// explicitly and illustrates it with a diagram. This has major performance
|
|
51708
|
+
// implications for some common scenarios. For instance, to compute a diff
|
|
51709
|
+
// where the new text simply appends d characters on the end of the
|
|
51710
|
+
// original text of length n, the true Myers algorithm will take O(n+d^2)
|
|
51711
|
+
// time while this optimization needs only O(n+d) time.
|
|
51712
|
+
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
51713
|
+
// Main worker method. checks all permutations of a given edit length for acceptance.
|
|
51714
|
+
const execEditLength = () => {
|
|
51715
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
51716
|
+
let basePath;
|
|
51717
|
+
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
51718
|
+
if (removePath) {
|
|
51719
|
+
// No one else is going to attempt to use this value, clear it
|
|
51720
|
+
// @ts-expect-error - perf optimisation. This type-violating value will never be read.
|
|
51721
|
+
bestPath[diagonalPath - 1] = undefined;
|
|
51722
|
+
}
|
|
51723
|
+
let canAdd = false;
|
|
51724
|
+
if (addPath) {
|
|
51725
|
+
// what newPos will be after we do an insertion:
|
|
51726
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
51727
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
51728
|
+
}
|
|
51729
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
51730
|
+
if (!canAdd && !canRemove) {
|
|
51731
|
+
// If this path is a terminal then prune
|
|
51732
|
+
// @ts-expect-error - perf optimisation. This type-violating value will never be read.
|
|
51733
|
+
bestPath[diagonalPath] = undefined;
|
|
51734
|
+
continue;
|
|
51735
|
+
}
|
|
51736
|
+
// Select the diagonal that we want to branch from. We select the prior
|
|
51737
|
+
// path whose position in the old string is the farthest from the origin
|
|
51738
|
+
// and does not pass the bounds of the diff graph
|
|
51739
|
+
if (!canRemove || (canAdd && removePath.oldPos < addPath.oldPos)) {
|
|
51740
|
+
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
51741
|
+
}
|
|
51742
|
+
else {
|
|
51743
|
+
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
51744
|
+
}
|
|
51745
|
+
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
51746
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
51747
|
+
// If we have hit the end of both strings, then we are done
|
|
51748
|
+
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
51749
|
+
}
|
|
51750
|
+
else {
|
|
51751
|
+
bestPath[diagonalPath] = basePath;
|
|
51752
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
51753
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
51754
|
+
}
|
|
51755
|
+
if (newPos + 1 >= newLen) {
|
|
51756
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
51757
|
+
}
|
|
51758
|
+
}
|
|
51759
|
+
}
|
|
51760
|
+
editLength++;
|
|
51761
|
+
};
|
|
51762
|
+
// Performs the length of edit iteration. Is a bit fugly as this has to support the
|
|
51763
|
+
// sync and async mode which is never fun. Loops over execEditLength until a value
|
|
51764
|
+
// is produced, or until the edit length exceeds options.maxEditLength (if given),
|
|
51765
|
+
// in which case it will return undefined.
|
|
51766
|
+
if (callback) {
|
|
51767
|
+
(function exec() {
|
|
51768
|
+
setTimeout(function () {
|
|
51769
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
51770
|
+
return callback(undefined);
|
|
51771
|
+
}
|
|
51772
|
+
if (!execEditLength()) {
|
|
51773
|
+
exec();
|
|
51774
|
+
}
|
|
51775
|
+
}, 0);
|
|
51776
|
+
}());
|
|
51777
|
+
}
|
|
51778
|
+
else {
|
|
51779
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
51780
|
+
const ret = execEditLength();
|
|
51781
|
+
if (ret) {
|
|
51782
|
+
return ret;
|
|
51783
|
+
}
|
|
51784
|
+
}
|
|
51785
|
+
}
|
|
51786
|
+
}
|
|
51787
|
+
addToPath(path, added, removed, oldPosInc, options) {
|
|
51788
|
+
const last = path.lastComponent;
|
|
51789
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
51790
|
+
return {
|
|
51791
|
+
oldPos: path.oldPos + oldPosInc,
|
|
51792
|
+
lastComponent: { count: last.count + 1, added: added, removed: removed, previousComponent: last.previousComponent }
|
|
51793
|
+
};
|
|
51794
|
+
}
|
|
51795
|
+
else {
|
|
51796
|
+
return {
|
|
51797
|
+
oldPos: path.oldPos + oldPosInc,
|
|
51798
|
+
lastComponent: { count: 1, added: added, removed: removed, previousComponent: last }
|
|
51799
|
+
};
|
|
51800
|
+
}
|
|
51801
|
+
}
|
|
51802
|
+
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
51803
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
51804
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
51805
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
51806
|
+
newPos++;
|
|
51807
|
+
oldPos++;
|
|
51808
|
+
commonCount++;
|
|
51809
|
+
if (options.oneChangePerToken) {
|
|
51810
|
+
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
51811
|
+
}
|
|
51812
|
+
}
|
|
51813
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
51814
|
+
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
51815
|
+
}
|
|
51816
|
+
basePath.oldPos = oldPos;
|
|
51817
|
+
return newPos;
|
|
51818
|
+
}
|
|
51819
|
+
equals(left, right, options) {
|
|
51820
|
+
if (options.comparator) {
|
|
51821
|
+
return options.comparator(left, right);
|
|
51822
|
+
}
|
|
51823
|
+
else {
|
|
51824
|
+
return left === right
|
|
51825
|
+
|| (!!options.ignoreCase && left.toLowerCase() === right.toLowerCase());
|
|
51826
|
+
}
|
|
51827
|
+
}
|
|
51828
|
+
removeEmpty(array) {
|
|
51829
|
+
const ret = [];
|
|
51830
|
+
for (let i = 0; i < array.length; i++) {
|
|
51831
|
+
if (array[i]) {
|
|
51832
|
+
ret.push(array[i]);
|
|
51833
|
+
}
|
|
51834
|
+
}
|
|
51835
|
+
return ret;
|
|
51836
|
+
}
|
|
51837
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51838
|
+
castInput(value, options) {
|
|
51839
|
+
return value;
|
|
51840
|
+
}
|
|
51841
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51842
|
+
tokenize(value, options) {
|
|
51843
|
+
return Array.from(value);
|
|
51844
|
+
}
|
|
51845
|
+
join(chars) {
|
|
51846
|
+
// Assumes ValueT is string, which is the case for most subclasses.
|
|
51847
|
+
// When it's false, e.g. in diffArrays, this method needs to be overridden (e.g. with a no-op)
|
|
51848
|
+
// Yes, the casts are verbose and ugly, because this pattern - of having the base class SORT OF
|
|
51849
|
+
// assume tokens and values are strings, but not completely - is weird and janky.
|
|
51850
|
+
return chars.join('');
|
|
51851
|
+
}
|
|
51852
|
+
postProcess(changeObjects,
|
|
51853
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51854
|
+
options) {
|
|
51855
|
+
return changeObjects;
|
|
51856
|
+
}
|
|
51857
|
+
get useLongestToken() {
|
|
51858
|
+
return false;
|
|
51859
|
+
}
|
|
51860
|
+
buildValues(lastComponent, newTokens, oldTokens) {
|
|
51861
|
+
// First we convert our linked list of components in reverse order to an
|
|
51862
|
+
// array in the right order:
|
|
51863
|
+
const components = [];
|
|
51864
|
+
let nextComponent;
|
|
51865
|
+
while (lastComponent) {
|
|
51866
|
+
components.push(lastComponent);
|
|
51867
|
+
nextComponent = lastComponent.previousComponent;
|
|
51868
|
+
delete lastComponent.previousComponent;
|
|
51869
|
+
lastComponent = nextComponent;
|
|
51870
|
+
}
|
|
51871
|
+
components.reverse();
|
|
51872
|
+
const componentLen = components.length;
|
|
51873
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
51874
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
51875
|
+
const component = components[componentPos];
|
|
51876
|
+
if (!component.removed) {
|
|
51877
|
+
if (!component.added && this.useLongestToken) {
|
|
51878
|
+
let value = newTokens.slice(newPos, newPos + component.count);
|
|
51879
|
+
value = value.map(function (value, i) {
|
|
51880
|
+
const oldValue = oldTokens[oldPos + i];
|
|
51881
|
+
return oldValue.length > value.length ? oldValue : value;
|
|
51882
|
+
});
|
|
51883
|
+
component.value = this.join(value);
|
|
51884
|
+
}
|
|
51885
|
+
else {
|
|
51886
|
+
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
51887
|
+
}
|
|
51888
|
+
newPos += component.count;
|
|
51889
|
+
// Common case
|
|
51890
|
+
if (!component.added) {
|
|
51891
|
+
oldPos += component.count;
|
|
51892
|
+
}
|
|
51893
|
+
}
|
|
51894
|
+
else {
|
|
51895
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
51896
|
+
oldPos += component.count;
|
|
51897
|
+
}
|
|
51898
|
+
}
|
|
51899
|
+
return components;
|
|
51900
|
+
}
|
|
51901
|
+
}
|
|
51902
|
+
|
|
51903
|
+
let LineDiff$1 = class LineDiff extends Diff {
|
|
51904
|
+
constructor() {
|
|
51905
|
+
super(...arguments);
|
|
51906
|
+
this.tokenize = tokenize;
|
|
51907
|
+
}
|
|
51908
|
+
equals(left, right, options) {
|
|
51909
|
+
// If we're ignoring whitespace, we need to normalise lines by stripping
|
|
51910
|
+
// whitespace before checking equality. (This has an annoying interaction
|
|
51911
|
+
// with newlineIsToken that requires special handling: if newlines get their
|
|
51912
|
+
// own token, then we DON'T want to trim the *newline* tokens down to empty
|
|
51913
|
+
// strings, since this would cause us to treat whitespace-only line content
|
|
51914
|
+
// as equal to a separator between lines, which would be weird and
|
|
51915
|
+
// inconsistent with the documented behavior of the options.)
|
|
51916
|
+
if (options.ignoreWhitespace) {
|
|
51917
|
+
if (!options.newlineIsToken || !left.includes('\n')) {
|
|
51918
|
+
left = left.trim();
|
|
51919
|
+
}
|
|
51920
|
+
if (!options.newlineIsToken || !right.includes('\n')) {
|
|
51921
|
+
right = right.trim();
|
|
51922
|
+
}
|
|
51923
|
+
}
|
|
51924
|
+
else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
51925
|
+
if (left.endsWith('\n')) {
|
|
51926
|
+
left = left.slice(0, -1);
|
|
51927
|
+
}
|
|
51928
|
+
if (right.endsWith('\n')) {
|
|
51929
|
+
right = right.slice(0, -1);
|
|
51930
|
+
}
|
|
51931
|
+
}
|
|
51932
|
+
return super.equals(left, right, options);
|
|
51933
|
+
}
|
|
51934
|
+
};
|
|
51935
|
+
new LineDiff$1();
|
|
51936
|
+
// Exported standalone so it can be used from jsonDiff too.
|
|
51937
|
+
function tokenize(value, options) {
|
|
51938
|
+
if (options.stripTrailingCr) {
|
|
51939
|
+
// remove one \r before \n to match GNU diff's --strip-trailing-cr behavior
|
|
51940
|
+
value = value.replace(/\r\n/g, '\n');
|
|
51941
|
+
}
|
|
51942
|
+
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
51943
|
+
// Ignore the final empty token that occurs if the string ends with a new line
|
|
51944
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
51945
|
+
linesAndNewlines.pop();
|
|
51946
|
+
}
|
|
51947
|
+
// Merge the content and line separators into single tokens
|
|
51948
|
+
for (let i = 0; i < linesAndNewlines.length; i++) {
|
|
51949
|
+
const line = linesAndNewlines[i];
|
|
51950
|
+
if (i % 2 && !options.newlineIsToken) {
|
|
51951
|
+
retLines[retLines.length - 1] += line;
|
|
51952
|
+
}
|
|
51953
|
+
else {
|
|
51954
|
+
retLines.push(line);
|
|
51955
|
+
}
|
|
51956
|
+
}
|
|
51957
|
+
return retLines;
|
|
51958
|
+
}
|
|
51959
|
+
|
|
51960
|
+
const trim = (str)=>str.replace(/\s|\t/g, '').replace(/[;|,]$/, '').toLowerCase();
|
|
51961
|
+
const roughEqual = (left, right)=>trim(left) === trim(right);
|
|
51962
|
+
class LineDiff extends Diff {
|
|
51963
|
+
constructor(){
|
|
51964
|
+
super();
|
|
51965
|
+
this.tokenize = tokenize;
|
|
51966
|
+
}
|
|
51967
|
+
equals(left, right, options) {
|
|
51968
|
+
const equal = super.equals(left, right, options);
|
|
51969
|
+
if (!equal) {
|
|
51970
|
+
if (left.length > 12 && right.length > 12) {
|
|
51971
|
+
// 去除所有行间的空格和制表符,再比较
|
|
51972
|
+
// 去除尾巴的分号和逗号
|
|
51973
|
+
return roughEqual(left, right);
|
|
51974
|
+
}
|
|
51975
|
+
}
|
|
51976
|
+
return equal;
|
|
51977
|
+
}
|
|
51978
|
+
}
|
|
51979
|
+
new LineDiff();
|
|
51980
|
+
|
|
51674
51981
|
var TOKEN = '';
|
|
51675
51982
|
var mult = 0x100000000; // Math.pow(16, 8);
|
|
51676
51983
|
for (var i = 0; i < 4; i++) {
|