@nasti-toolchain/nasti 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -0
- package/dist/cli.cjs +15 -14
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +15 -14
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +227 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +226 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
- **内置 React 支持** - JSX 自动转换 + React Fast Refresh HMR
|
|
25
25
|
- **内置 Vue 支持** - SFC 编译 + Vue HMR(可选依赖 `@vue/compiler-sfc`)
|
|
26
26
|
- **Electron 41+ 支持** - 一键构建主进程 / Preload / 渲染进程,支持 ESM 主进程
|
|
27
|
+
- **Monaco Editor 集成** - 内置 `monacoEditorPlugin`,预打包 Web Worker,修复 HMR 期间的 EMFILE
|
|
27
28
|
- **Dev Server + HMR** - 开发服务器 + WebSocket 热模块替换
|
|
28
29
|
- **TypeScript 优先** - 原生 TS 支持,零配置
|
|
29
30
|
|
|
@@ -243,6 +244,57 @@ app.whenReady().then(createWindow)
|
|
|
243
244
|
|
|
244
245
|
> 详细说明见 [Electron 指南](https://nasti.zixiaolabs.com/pages/electron.html)。
|
|
245
246
|
|
|
247
|
+
## Monaco Editor 支持
|
|
248
|
+
|
|
249
|
+
内置 `monacoEditorPlugin`(对标 `vite-plugin-monaco-editor`),解决两个老大难问题:
|
|
250
|
+
|
|
251
|
+
1. Monaco 的 Web Worker 是独立入口,必须单独打包
|
|
252
|
+
2. `monaco-editor` 包含 2000+ 源文件,按 ESM 逐文件服务会在 HMR 时触发 **EMFILE(too many open files)** — 本插件将 Worker 预打包到磁盘缓存,并把 `monaco-editor` 目录显式从 watcher 中剔除
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
npm install monaco-editor
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
// nasti.config.ts
|
|
260
|
+
import { defineConfig, monacoEditorPlugin } from '@nasti-toolchain/nasti'
|
|
261
|
+
|
|
262
|
+
export default defineConfig({
|
|
263
|
+
plugins: [
|
|
264
|
+
monacoEditorPlugin({
|
|
265
|
+
// 默认全部启用:editorWorkerService / css / html / json / typescript
|
|
266
|
+
languageWorkers: ['editorWorkerService', 'json', 'typescript'],
|
|
267
|
+
|
|
268
|
+
// 自定义 Worker(如 monaco-graphql)
|
|
269
|
+
customWorkers: [
|
|
270
|
+
{ label: 'graphql', entry: 'monaco-graphql/esm/graphql.worker' },
|
|
271
|
+
],
|
|
272
|
+
|
|
273
|
+
// Worker URL 前缀,可指向 CDN 绝对 URL
|
|
274
|
+
publicPath: 'monacoeditorwork',
|
|
275
|
+
|
|
276
|
+
// 兼容旧 API:将 monaco 暴露到 window.monaco
|
|
277
|
+
globalAPI: false,
|
|
278
|
+
}),
|
|
279
|
+
],
|
|
280
|
+
})
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
应用代码无需任何胶水:
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
import * as monaco from 'monaco-editor'
|
|
287
|
+
|
|
288
|
+
monaco.editor.create(document.getElementById('editor')!, {
|
|
289
|
+
value: 'function hi() { console.log("hello monaco") }',
|
|
290
|
+
language: 'typescript',
|
|
291
|
+
theme: 'vs-dark',
|
|
292
|
+
automaticLayout: true,
|
|
293
|
+
})
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
> 详细说明见 [Monaco Editor 指南](https://nasti.zixiaolabs.com/pages/monaco.html)。
|
|
297
|
+
|
|
246
298
|
## License
|
|
247
299
|
|
|
248
300
|
[MIT](./LICENSE) - Made by [zixiao-labs](https://github.com/zixiao-labs)
|
package/dist/cli.cjs
CHANGED
|
@@ -1437,15 +1437,6 @@ async function createServer(inlineConfig = {}) {
|
|
|
1437
1437
|
watcher.on("add", (file) => {
|
|
1438
1438
|
handleFileChange(file, server);
|
|
1439
1439
|
});
|
|
1440
|
-
const postMiddlewares = [];
|
|
1441
|
-
for (const plugin of allPlugins) {
|
|
1442
|
-
if (plugin.configureServer) {
|
|
1443
|
-
const result = await plugin.configureServer(server);
|
|
1444
|
-
if (typeof result === "function") {
|
|
1445
|
-
postMiddlewares.push(result);
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
1440
|
server = {
|
|
1450
1441
|
config: configWithPlugins,
|
|
1451
1442
|
middlewares: app,
|
|
@@ -1464,7 +1455,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1464
1455
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1465
1456
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1466
1457
|
console.log();
|
|
1467
|
-
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.
|
|
1458
|
+
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.5.0"}`));
|
|
1468
1459
|
console.log();
|
|
1469
1460
|
console.log(` ${import_picocolors.default.green(">")} Local: ${import_picocolors.default.cyan(localUrl)}`);
|
|
1470
1461
|
if (networkUrl) {
|
|
@@ -1497,6 +1488,16 @@ async function createServer(inlineConfig = {}) {
|
|
|
1497
1488
|
httpServer.close();
|
|
1498
1489
|
}
|
|
1499
1490
|
};
|
|
1491
|
+
const postMiddlewares = [];
|
|
1492
|
+
for (const plugin of allPlugins) {
|
|
1493
|
+
if (plugin.configureServer) {
|
|
1494
|
+
const result = await plugin.configureServer(server);
|
|
1495
|
+
if (typeof result === "function") {
|
|
1496
|
+
postMiddlewares.push(result);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
for (const run of postMiddlewares) run();
|
|
1500
1501
|
return server;
|
|
1501
1502
|
}
|
|
1502
1503
|
function getNetworkAddress() {
|
|
@@ -1581,7 +1582,7 @@ __export(build_exports, {
|
|
|
1581
1582
|
async function build(inlineConfig = {}) {
|
|
1582
1583
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1583
1584
|
const startTime = performance.now();
|
|
1584
|
-
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.
|
|
1585
|
+
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.5.0"}`));
|
|
1585
1586
|
console.log(import_picocolors2.default.dim(` root: ${config.root}`));
|
|
1586
1587
|
console.log(import_picocolors2.default.dim(` mode: ${config.mode}`));
|
|
1587
1588
|
const outDir = import_node_path10.default.resolve(config.root, config.build.outDir);
|
|
@@ -1742,7 +1743,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
1742
1743
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
1743
1744
|
const startTime = performance.now();
|
|
1744
1745
|
assertElectronVersion(config);
|
|
1745
|
-
console.log(import_picocolors3.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors3.default.dim(` v${"1.
|
|
1746
|
+
console.log(import_picocolors3.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors3.default.dim(` v${"1.5.0"}`));
|
|
1746
1747
|
console.log(import_picocolors3.default.dim(` root: ${config.root}`));
|
|
1747
1748
|
console.log(import_picocolors3.default.dim(` mode: ${config.mode}`));
|
|
1748
1749
|
console.log(import_picocolors3.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -1894,7 +1895,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
1894
1895
|
const { noSpawn, ...rest } = inlineConfig;
|
|
1895
1896
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
1896
1897
|
warnElectronVersion(config);
|
|
1897
|
-
console.log(import_picocolors4.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors4.default.dim(` v${"1.
|
|
1898
|
+
console.log(import_picocolors4.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors4.default.dim(` v${"1.5.0"}`));
|
|
1898
1899
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
1899
1900
|
const server = await createServer2({ ...rest, target: "electron" });
|
|
1900
1901
|
await server.listen();
|
|
@@ -2210,6 +2211,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
2210
2211
|
}
|
|
2211
2212
|
});
|
|
2212
2213
|
cli.help();
|
|
2213
|
-
cli.version("1.
|
|
2214
|
+
cli.version("1.5.0");
|
|
2214
2215
|
cli.parse();
|
|
2215
2216
|
//# sourceMappingURL=cli.cjs.map
|