Skip to content

Commit c1f1fd5

Browse files
shiqiWang0beier
andauthored
Bump/[email protected] alpha10 (#190)
* feat: update [email protected] * feat: add welcome * feat: init colortheme && reset workbench * feat: add website ui * feat: improve UI * feat: imporve workbench to support sidebar * feat: support problem panel * feat: support snippetCompletion * feat: support to register action * feat: apiDocPage && unitTest init * feat: improve ui in quick github to visit * feat(website): support quickStart to create new file && code review * fix(website): create file to share data * chore(release): 1.0.0-beta.0 * chore(release): 1.0.0-beta.1 * chore(release): 1.0.0-beta.2 * chore(release): 1.0.0-beta.3 * chore(release): 1.0.0-beta.4 * chore(release): 1.0.0-beta.5 * feat: update demo and others after upgrade monaco-editor's version * feat: update contribute ts and update unit test * feat: bump molecule2.0 from alpha.8 to alpha.10 with [email protected] --------- Co-authored-by: beier <[email protected]> Co-authored-by: zhaoge <>
1 parent 2289858 commit c1f1fd5

File tree

56 files changed

+4367
-471
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4367
-471
lines changed

website/package.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"@dtinsight/molecule": "^1.3.4",
13+
"@dtinsight/molecule": "2.0.0-alpha.10",
1414
"@jcubic/lips": "^0.20.3",
15-
"monaco-editor": "0.31.0",
15+
"@vscode/codicons": "^0.0.41",
16+
"classnames": "^2.5.1",
17+
"esbuild": "^0.24.2",
18+
"idb-keyval": "^6.2.1",
19+
"immer": "^10.1.3",
20+
"monaco-editor": "0.52.2",
21+
"rc-tabs": "^15.5.1",
1622
"react": "^18.2.0",
1723
"react-dom": "^18.2.0",
18-
"reflect-metadata": "^0.1.13"
24+
"reflect-metadata": "^0.1.13",
25+
"tsyringe": "^4.8.0",
26+
"vscode-oniguruma": "^2.0.1",
27+
"vscode-textmate": "^9.2.0"
1928
},
2029
"devDependencies": {
2130
"@types/node": "^20.2.5",
@@ -24,11 +33,16 @@
2433
"@typescript-eslint/eslint-plugin": "^5.59.0",
2534
"@typescript-eslint/parser": "^5.59.0",
2635
"@vitejs/plugin-react": "^4.0.0",
36+
"autoprefixer": "^10.4.21",
2737
"eslint": "^8.38.0",
2838
"eslint-plugin-react-hooks": "^4.6.0",
2939
"eslint-plugin-react-refresh": "^0.3.4",
40+
"postcss": "^8.5.6",
41+
"sass": "^1.93.2",
42+
"tailwindcss": "3",
3043
"typescript": "^5.0.2",
31-
"vite": "^4.3.9"
44+
"vite": "^4.3.9",
45+
"vite-plugin-mock-dev-server": "^2.0.1"
3246
},
3347
"engines": {
3448
"node": ">=18"

website/plugin.ts

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { Plugin as EsbuildPlugin } from 'esbuild';
2+
import * as fs from 'fs';
3+
4+
/**
5+
* 在vite中dev模式下会使用esbuild对node_modules进行预编译,导致找不到映射表中的filepath,
6+
* 需要在预编译之前进行替换
7+
* @param options 替换语言包
8+
* @returns
9+
*/
10+
export function esbuildPluginMonacoEditorNls(): EsbuildPlugin {
11+
return {
12+
name: 'esbuild-plugin-monaco-editor-nls',
13+
setup(build) {
14+
build.onLoad({ filter: /esm[\\\/]vs[\\\/]nls\.js/ }, async () => {
15+
return {
16+
contents: getLocalizeCode(),
17+
loader: 'js'
18+
};
19+
});
20+
21+
build.onLoad({ filter: /monaco-editor[\\\/]esm[\\\/]vs.+\.js/ }, async (args) => {
22+
return {
23+
contents: transformLocalizeFuncCode(args.path),
24+
loader: 'js'
25+
};
26+
});
27+
}
28+
};
29+
}
30+
31+
/**
32+
* 替换调用方法接口参数,替换成相应语言包语言
33+
* @param filepath 路径
34+
* @param CURRENT_LOCALE_DATA 替换规则
35+
* @returns
36+
*/
37+
function transformLocalizeFuncCode(filepath: string) {
38+
let code = fs.readFileSync(filepath, 'utf8');
39+
const re = /(?:monaco-editor[\\\/]esm[\\\/])(.+)(?=\.js)/;
40+
if (re.exec(filepath)) {
41+
let path = RegExp.$1;
42+
path = path.replaceAll('\\', '/');
43+
code = code.replace(/localize\(/g, `localize('${path}', `);
44+
}
45+
return code;
46+
}
47+
48+
function getLocalizeCode() {
49+
return `
50+
// replace monaco-editor/esm/vs/nls.js _format
51+
function _format(message, args) {
52+
let result;
53+
if (args.length === 0) {
54+
result = message;
55+
} else {
56+
result = String(message).replace(/\{(\d+)\}/g, function (match, rest) {
57+
const index = rest[0];
58+
return typeof args[index] !== "undefined" ? args[index] : match;
59+
});
60+
}
61+
return result;
62+
}
63+
64+
// replace monaco-editor/esm/vs/nls.js localize
65+
function localize(path, data, defaultMessage) {
66+
const key = typeof data === "object" ? data.key : data;
67+
const lang = document?.documentElement.getAttribute("lang") || "en";
68+
const _data = window.__locale__?.[lang] || {};
69+
let message = (_data[path] || {})[key];
70+
if (!message) {
71+
message = defaultMessage;
72+
}
73+
const args = [];
74+
for (let _i = 3; _i < arguments.length; _i++) {
75+
args[_i - 3] = arguments[_i];
76+
}
77+
return _format(message, args);
78+
}
79+
module.exports["localize"] = localize;
80+
81+
function loadMessageBundle(_file) {
82+
return localize;
83+
}
84+
module.exports["loadMessageBundle"] = loadMessageBundle;
85+
86+
function config(_opt) {
87+
return loadMessageBundle;
88+
}
89+
module.exports["config"] = config;
90+
91+
function getConfiguredDefaultLocale() {
92+
return undefined;
93+
}
94+
module.exports["getConfiguredDefaultLocale"] = getConfiguredDefaultLocale;`;
95+
}

0 commit comments

Comments
 (0)