pixifact-cli 0.8.0 → 0.9.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 +7 -1
- package/editor/assets/browserAll-CG--e3R8.js +1 -0
- package/editor/assets/index-BUZ_WtnT.js +1130 -0
- package/editor/assets/init-CzHI7RKj.js +1 -0
- package/editor/assets/webworkerAll-D-3iZ4fC.js +1 -0
- package/editor/index.html +1 -1
- package/package.json +2 -2
- package/src/automation.ts +1 -2
- package/src/editorServer.ts +47 -0
- package/src/pixifact-cli.ts +10 -3
- package/editor/assets/browserAll-DePxC4RK.js +0 -1
- package/editor/assets/index-DoPhYWF1.js +0 -1130
- package/editor/assets/init-CuKNsO_k.js +0 -1
- package/editor/assets/webworkerAll-DM9kdU0t.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n,u as r}from"./index-BUZ_WtnT.js";r.add(n,t),r.add(e);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./index-BUZ_WtnT.js";import"./init-CzHI7RKj.js";
|
package/editor/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-BUZ_WtnT.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-D3t5XxiB.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixifact-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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.
|
|
35
|
+
"pixifact": "^0.9.0",
|
|
36
36
|
"vite": "^8.0.10"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/automation.ts
CHANGED
|
@@ -33,7 +33,6 @@ interface ToolInput {
|
|
|
33
33
|
projectRoot?: unknown;
|
|
34
34
|
scenePath?: unknown;
|
|
35
35
|
node?: unknown;
|
|
36
|
-
name?: unknown;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
type CompilerSceneValidationSuccess = ReturnType<typeof validateCompilerSceneFile> & { ok: true };
|
|
@@ -576,8 +575,8 @@ export function createPixifactAutomation() {
|
|
|
576
575
|
createScene(input: unknown) {
|
|
577
576
|
const args = assertRecord(input, 'input') as ToolInput;
|
|
578
577
|
const { root, target } = resolveProjectPath(args.projectRoot, args.scenePath);
|
|
579
|
-
const sceneName = assertString(args.name, 'name');
|
|
580
578
|
const scenePath = normalizeSceneAssetId(path.relative(root, target));
|
|
579
|
+
const sceneName = sceneLocalName(scenePath);
|
|
581
580
|
const sourceRootFailure = compilerSceneSourceRootFailure(scenePath);
|
|
582
581
|
if (sourceRootFailure) {
|
|
583
582
|
return sourceRootFailure;
|
package/src/editorServer.ts
CHANGED
|
@@ -36,6 +36,10 @@ interface EditorProjectFile {
|
|
|
36
36
|
path: string;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
interface EditorUiState {
|
|
40
|
+
assetTreeExpandedDirectories?: string[];
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
interface BunServer {
|
|
40
44
|
hostname: string;
|
|
41
45
|
port: number;
|
|
@@ -163,6 +167,35 @@ function requestPath(url: URL) {
|
|
|
163
167
|
return url.searchParams.get('path') ?? '';
|
|
164
168
|
}
|
|
165
169
|
|
|
170
|
+
function editorUiStatePath(projectRoot: string) {
|
|
171
|
+
return path.join(projectRoot, '.pixifact', 'editor', 'ui-state.json');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function parseEditorUiState(value: unknown): EditorUiState {
|
|
175
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
176
|
+
throw new Error('Editor UI state must be a JSON object.');
|
|
177
|
+
}
|
|
178
|
+
const directories = (value as Record<string, unknown>).assetTreeExpandedDirectories;
|
|
179
|
+
if (directories === undefined) return {};
|
|
180
|
+
if (!Array.isArray(directories) || directories.some((directory) => typeof directory !== 'string')) {
|
|
181
|
+
throw new Error('Editor UI state assetTreeExpandedDirectories must be a string array.');
|
|
182
|
+
}
|
|
183
|
+
return { assetTreeExpandedDirectories: directories };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function readEditorUiState(projectRoot: string): EditorUiState {
|
|
187
|
+
const statePath = editorUiStatePath(projectRoot);
|
|
188
|
+
if (!fs.existsSync(statePath)) return {};
|
|
189
|
+
return parseEditorUiState(JSON.parse(fs.readFileSync(statePath, 'utf8')));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function writeEditorUiState(projectRoot: string, state: EditorUiState) {
|
|
193
|
+
const statePath = editorUiStatePath(projectRoot);
|
|
194
|
+
fs.mkdirSync(path.dirname(statePath), { recursive: true });
|
|
195
|
+
fs.writeFileSync(statePath, JSON.stringify(state, null, 2) + '\n', 'utf8');
|
|
196
|
+
return state;
|
|
197
|
+
}
|
|
198
|
+
|
|
166
199
|
async function readJsonBody(request: Request) {
|
|
167
200
|
const value = await request.json();
|
|
168
201
|
if (!value || typeof value !== 'object') {
|
|
@@ -205,6 +238,17 @@ export function createEditorProjectService(options: EditorProjectServiceOptions)
|
|
|
205
238
|
images: files.filter((file) => file.kind === 'image').map((file) => file.path),
|
|
206
239
|
});
|
|
207
240
|
}
|
|
241
|
+
if (url.pathname === '/api/editor-ui-state' && request.method === 'GET') {
|
|
242
|
+
return jsonResponse(readEditorUiState(projectRoot));
|
|
243
|
+
}
|
|
244
|
+
if (url.pathname === '/api/editor-ui-state' && request.method === 'PUT') {
|
|
245
|
+
const body = await readJsonBody(request);
|
|
246
|
+
const state = parseEditorUiState(body);
|
|
247
|
+
if (!state.assetTreeExpandedDirectories) {
|
|
248
|
+
throw new EditorRequestError(400, 'Editor UI state requires assetTreeExpandedDirectories.');
|
|
249
|
+
}
|
|
250
|
+
return jsonResponse(writeEditorUiState(projectRoot, state));
|
|
251
|
+
}
|
|
208
252
|
if (url.pathname === '/api/scene' && request.method === 'GET') {
|
|
209
253
|
const scenePath = requestPath(url);
|
|
210
254
|
if (path.extname(scenePath).toLowerCase() !== '.scene') {
|
|
@@ -275,6 +319,9 @@ export function watchEditorProject(projectRoot: string, onProjectFileChanged: (p
|
|
|
275
319
|
const watcher = fs.watch(projectRoot, { recursive: true }, (_event, fileName) => {
|
|
276
320
|
if (!fileName) return;
|
|
277
321
|
const filePath = String(fileName);
|
|
322
|
+
if (filePath.split(/[\\/]/).some((segment) => ignoredDirectories.has(segment))) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
278
325
|
const absolutePath = path.resolve(projectRoot, filePath);
|
|
279
326
|
if (fs.existsSync(absolutePath) && fs.statSync(absolutePath).isDirectory()) {
|
|
280
327
|
return;
|
package/src/pixifact-cli.ts
CHANGED
|
@@ -491,10 +491,17 @@ async function executeFileCommand(
|
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
if (area === 'scene' && action === 'create') {
|
|
494
|
+
assertAllowedFlags(flags, ['project-root'], 'scene create');
|
|
495
|
+
const scenePath = positionals[2];
|
|
496
|
+
if (!scenePath) {
|
|
497
|
+
throw new Error('Scene create requires a project-relative .scene path.');
|
|
498
|
+
}
|
|
499
|
+
if (positionals[3] !== undefined) {
|
|
500
|
+
throw new Error('Scene create accepts exactly one scene path.');
|
|
501
|
+
}
|
|
494
502
|
return automation.createScene({
|
|
495
503
|
projectRoot,
|
|
496
|
-
scenePath
|
|
497
|
-
name: requireFlag(flags, 'name'),
|
|
504
|
+
scenePath,
|
|
498
505
|
});
|
|
499
506
|
}
|
|
500
507
|
|
|
@@ -567,7 +574,7 @@ export async function executePixifactCli(argv: string[], options: CliOptions = {
|
|
|
567
574
|
'editor',
|
|
568
575
|
'editor context',
|
|
569
576
|
'editor screenshot --output <png-path>',
|
|
570
|
-
'scene create
|
|
577
|
+
'scene create <scene-path>',
|
|
571
578
|
'node inspect --scene <scene-path> --node <locator>',
|
|
572
579
|
],
|
|
573
580
|
nodeLocatorSource: 'scene inspect --scene <scene-path> returns node locator values',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,l as r,o as i,s as a,u as o}from"./index-DoPhYWF1.js";import"./init-CuKNsO_k.js";o.add(t),o.mixin(r,a),o.add(i),o.add(e),o.mixin(r,n);
|