pixifact-cli 0.20.0 → 0.20.1
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 +2 -0
- package/editor/assets/browserAll-BK5tSRnW.js +1 -0
- package/editor/assets/capture-C7kX9ccS.js +1 -0
- package/editor/assets/{captureCompilerScenePreview-4K1ehGWd.js → captureCompilerScenePreview-D1crYVOi.js} +83 -83
- package/editor/assets/editor-DXfKrkh3.js +5 -0
- package/editor/assets/{init-B6Wk-3NE.js → init-ChKChotc.js} +1 -1
- package/editor/assets/webworkerAll-DUy-YwIE.js +1 -0
- package/editor/capture.html +2 -2
- package/editor/index.html +2 -2
- package/package.json +2 -2
- package/src/editorServer.ts +36 -2
- package/editor/assets/browserAll-BJUI9ZxT.js +0 -1
- package/editor/assets/capture-CUhA-7Mo.js +0 -1
- package/editor/assets/editor-C18Nctzn.js +0 -5
- package/editor/assets/webworkerAll-iPsb_ehV.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,d as t,l as n,u as r}from"./captureCompilerScenePreview-
|
|
1
|
+
import{b as e,d as t,l as n,u as r}from"./captureCompilerScenePreview-D1crYVOi.js";e.add(n,t),e.add(r);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./captureCompilerScenePreview-D1crYVOi.js";import"./init-ChKChotc.js";
|
package/editor/capture.html
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<title>Pixifact Scene Capture</title>
|
|
6
|
-
<script type="module" crossorigin src="/assets/capture-
|
|
7
|
-
<link rel="modulepreload" crossorigin href="/assets/captureCompilerScenePreview-
|
|
6
|
+
<script type="module" crossorigin src="/assets/capture-C7kX9ccS.js"></script>
|
|
7
|
+
<link rel="modulepreload" crossorigin href="/assets/captureCompilerScenePreview-D1crYVOi.js">
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
10
|
</body>
|
package/editor/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Pixifact Editor</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/editor-
|
|
8
|
-
<link rel="modulepreload" crossorigin href="/assets/captureCompilerScenePreview-
|
|
7
|
+
<script type="module" crossorigin src="/assets/editor-DXfKrkh3.js"></script>
|
|
8
|
+
<link rel="modulepreload" crossorigin href="/assets/captureCompilerScenePreview-D1crYVOi.js">
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/editor-DmOIioK0.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixifact-cli",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"description": "Pixifact Scene 自动化 CLI。",
|
|
5
5
|
"packageManager": "bun@1.3.13",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"start": "bun src/pixifact-cli.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"pixifact": "^0.20.
|
|
35
|
+
"pixifact": "^0.20.1",
|
|
36
36
|
"playwright": "1.58.2",
|
|
37
37
|
"vite": "^8.0.10"
|
|
38
38
|
}
|
package/src/editorServer.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createHash, randomBytes } from 'node:crypto';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import
|
|
4
|
+
import childProcess from 'node:child_process';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
5
6
|
import {
|
|
6
7
|
normalizeSceneAssetId,
|
|
7
8
|
pairedSceneScriptPath,
|
|
@@ -330,6 +331,29 @@ export function createEditorProjectService(options: EditorProjectServiceOptions)
|
|
|
330
331
|
},
|
|
331
332
|
});
|
|
332
333
|
}
|
|
334
|
+
if (url.pathname === '/api/open-file' && request.method === 'POST') {
|
|
335
|
+
if (request.headers.get('origin') !== url.origin) {
|
|
336
|
+
throw new EditorRequestError(403, '资源打开请求必须来自当前 Editor。');
|
|
337
|
+
}
|
|
338
|
+
let filePath: string;
|
|
339
|
+
try {
|
|
340
|
+
filePath = resolveInsideRoot(projectRoot, requestPath(url));
|
|
341
|
+
if (!fs.statSync(filePath).isFile()) {
|
|
342
|
+
throw new EditorRequestError(400, '只能使用系统默认程序打开项目内的文件。');
|
|
343
|
+
}
|
|
344
|
+
} catch (error) {
|
|
345
|
+
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
346
|
+
throw new EditorRequestError(404, '资源文件不存在,请刷新资产列表。');
|
|
347
|
+
}
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
try {
|
|
351
|
+
await openSystemFile(filePath);
|
|
352
|
+
} catch (error) {
|
|
353
|
+
throw new EditorRequestError(500, `无法使用系统默认程序打开文件:${error instanceof Error ? error.message : String(error)}`);
|
|
354
|
+
}
|
|
355
|
+
return jsonResponse({ ok: true });
|
|
356
|
+
}
|
|
333
357
|
if (url.pathname.startsWith('/api/')) {
|
|
334
358
|
return jsonResponse({ ok: false, error: 'Editor API route was not found.' }, 404);
|
|
335
359
|
}
|
|
@@ -349,13 +373,23 @@ function defaultEditorStaticRoot() {
|
|
|
349
373
|
return path.resolve(import.meta.dir, '..', 'editor');
|
|
350
374
|
}
|
|
351
375
|
|
|
376
|
+
async function openSystemFile(filePath: string) {
|
|
377
|
+
const command = process.platform === 'win32'
|
|
378
|
+
? [
|
|
379
|
+
'powershell.exe', '-NoProfile', '-NonInteractive', '-Command',
|
|
380
|
+
`Start-Process -FilePath ([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${Buffer.from(filePath).toString('base64')}'))) -ErrorAction Stop`,
|
|
381
|
+
]
|
|
382
|
+
: [process.platform === 'darwin' ? 'open' : 'xdg-open', filePath];
|
|
383
|
+
await promisify(childProcess.execFile)(command[0], command.slice(1), { windowsHide: true });
|
|
384
|
+
}
|
|
385
|
+
|
|
352
386
|
function openBrowser(url: string) {
|
|
353
387
|
const command = process.platform === 'darwin'
|
|
354
388
|
? ['open', url]
|
|
355
389
|
: process.platform === 'win32'
|
|
356
390
|
? ['cmd', '/c', 'start', '', url]
|
|
357
391
|
: ['xdg-open', url];
|
|
358
|
-
spawn(command[0], command.slice(1), { detached: true, stdio: 'ignore' }).unref();
|
|
392
|
+
childProcess.spawn(command[0], command.slice(1), { detached: true, stdio: 'ignore' }).unref();
|
|
359
393
|
}
|
|
360
394
|
|
|
361
395
|
export function watchEditorProject(projectRoot: string, onProjectFileChanged: (path: string) => void) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,b as t,f as n,g as r,m as i,p as a,v as o}from"./captureCompilerScenePreview-4K1ehGWd.js";import"./init-B6Wk-3NE.js";t.add(e),t.mixin(o,r),t.add(i),t.add(a),t.mixin(o,n);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as e,E as t,S as n,h as r,i,n as a,r as o,t as s,w as c}from"./captureCompilerScenePreview-4K1ehGWd.js";window.capturePixifactScene=async l=>{let[u,d]=await Promise.all([c(),t(l)]),f=new a,p,m=new r,h=!1;try{return p=await o({cache:f,document:{template:e(d.source),sceneInterfaces:{}},projectTree:n(u),scenePath:l}),await m.init({width:p.width,height:p.height,backgroundAlpha:0,antialias:!0,autoStart:!1,resolution:1}),h=!0,m.stage.addChild(p.root),{scenePath:d.path,revision:d.version,width:p.width,height:p.height,dataUrl:await s(m,p)}}finally{h&&(m.stage.removeChild(p.root),m.destroy({removeView:!0},{children:!1})),i(p),await f.clear()}};
|