pixifact-cli 0.19.0 → 0.20.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.
@@ -0,0 +1 @@
1
+ import{b as e,d as t,l as n,u as r}from"./captureCompilerScenePreview-4K1ehGWd.js";e.add(n,t),e.add(r);
@@ -0,0 +1 @@
1
+ import"./captureCompilerScenePreview-4K1ehGWd.js";import"./init-B6Wk-3NE.js";
@@ -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-BGSCjpR1.js"></script>
7
- <link rel="modulepreload" crossorigin href="/assets/captureCompilerScenePreview-BYHGr0JS.js">
6
+ <script type="module" crossorigin src="/assets/capture-CUhA-7Mo.js"></script>
7
+ <link rel="modulepreload" crossorigin href="/assets/captureCompilerScenePreview-4K1ehGWd.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-DdhHqfDl.js"></script>
8
- <link rel="modulepreload" crossorigin href="/assets/captureCompilerScenePreview-BYHGr0JS.js">
7
+ <script type="module" crossorigin src="/assets/editor-C18Nctzn.js"></script>
8
+ <link rel="modulepreload" crossorigin href="/assets/captureCompilerScenePreview-4K1ehGWd.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.19.0",
3
+ "version": "0.20.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.19.0",
35
+ "pixifact": "^0.20.0",
36
36
  "playwright": "1.58.2",
37
37
  "vite": "^8.0.10"
38
38
  }
@@ -138,8 +138,8 @@ function listProjectFiles(projectRoot: string) {
138
138
  return files.sort((left, right) => left.path.localeCompare(right.path));
139
139
  }
140
140
 
141
- function readProjectSceneBindings(projectRoot: string) {
142
- const scenePaths = listProjectFiles(projectRoot)
141
+ function readProjectSceneBindings(projectRoot: string, files: readonly EditorProjectFile[]) {
142
+ const scenePaths = files
143
143
  .filter((file) => file.kind === 'scene')
144
144
  .map((file) => normalizeSceneAssetId(file.path));
145
145
  return extractSceneScriptInterfaces(scenePaths.map((scene) => {
@@ -249,12 +249,27 @@ function serveStaticFile(staticRoot: string, pathname: string) {
249
249
  export function createEditorProjectService(options: EditorProjectServiceOptions) {
250
250
  const projectRoot = fs.realpathSync(options.projectRoot);
251
251
  const staticRoot = fs.realpathSync(options.staticRoot);
252
+ let files: EditorProjectFile[] | undefined;
253
+ let bindings: ReturnType<typeof readProjectSceneBindings> | undefined;
254
+
255
+ function invalidate(changedPath: string) {
256
+ const known = files?.some((file) => file.path === changedPath);
257
+ const entry = fs.statSync(path.resolve(projectRoot, changedPath), { throwIfNoEntry: false });
258
+ if (!known || !entry?.isFile()) files = undefined;
259
+ if (!known || !entry?.isFile() || scriptExtensions.has(path.extname(changedPath))) {
260
+ bindings = undefined;
261
+ }
262
+ }
252
263
 
253
264
  async function fetch(request: Request): Promise<Response> {
254
265
  try {
255
266
  const url = new URL(request.url);
256
267
  if (url.pathname === '/api/project' && request.method === 'GET') {
257
- const files = listProjectFiles(projectRoot);
268
+ if (url.searchParams.get('refresh') === '1') {
269
+ files = undefined;
270
+ bindings = undefined;
271
+ }
272
+ files ??= listProjectFiles(projectRoot);
258
273
  return jsonResponse({
259
274
  name: path.basename(projectRoot),
260
275
  root: projectRoot,
@@ -283,7 +298,9 @@ export function createEditorProjectService(options: EditorProjectServiceOptions)
283
298
  return jsonResponse({ path: scenePath, source, version: sceneVersion(source) });
284
299
  }
285
300
  if (url.pathname === '/api/scene-bindings' && request.method === 'GET') {
286
- return jsonResponse(readProjectSceneBindings(projectRoot));
301
+ files ??= listProjectFiles(projectRoot);
302
+ bindings ??= readProjectSceneBindings(projectRoot, files);
303
+ return jsonResponse(bindings);
287
304
  }
288
305
  if (url.pathname === '/api/scene' && request.method === 'PUT') {
289
306
  const scenePath = requestPath(url);
@@ -300,6 +317,7 @@ export function createEditorProjectService(options: EditorProjectServiceOptions)
300
317
  throw new EditorRequestError(409, 'Scene file version changed.');
301
318
  }
302
319
  fs.writeFileSync(filePath, body.source, 'utf8');
320
+ invalidate(scenePath);
303
321
  return jsonResponse({ path: scenePath, version: sceneVersion(body.source) });
304
322
  }
305
323
  if (url.pathname === '/api/file' && request.method === 'GET') {
@@ -308,6 +326,7 @@ export function createEditorProjectService(options: EditorProjectServiceOptions)
308
326
  return new Response(fs.readFileSync(filePath), {
309
327
  headers: {
310
328
  'content-type': contentTypes[extension] ?? 'application/octet-stream',
329
+ 'cache-control': 'no-store',
311
330
  },
312
331
  });
313
332
  }
@@ -323,7 +342,7 @@ export function createEditorProjectService(options: EditorProjectServiceOptions)
323
342
  }
324
343
  }
325
344
 
326
- return { fetch };
345
+ return { fetch, invalidate };
327
346
  }
328
347
 
329
348
  function defaultEditorStaticRoot() {
@@ -341,14 +360,14 @@ function openBrowser(url: string) {
341
360
 
342
361
  export function watchEditorProject(projectRoot: string, onProjectFileChanged: (path: string) => void) {
343
362
  const changedPathTimers = new Map<string, ReturnType<typeof setTimeout>>();
344
- const watcher = fs.watch(projectRoot, { recursive: true }, (_event, fileName) => {
363
+ const watcher = fs.watch(projectRoot, { recursive: true }, (event, fileName) => {
345
364
  if (!fileName) return;
346
365
  const filePath = String(fileName);
347
366
  if (filePath.split(/[\\/]/).some((segment) => ignoredDirectories.has(segment))) {
348
367
  return;
349
368
  }
350
369
  const absolutePath = path.resolve(projectRoot, filePath);
351
- if (fs.existsSync(absolutePath) && fs.statSync(absolutePath).isDirectory()) {
370
+ if (event !== 'rename' && fs.existsSync(absolutePath) && fs.statSync(absolutePath).isDirectory()) {
352
371
  return;
353
372
  }
354
373
  const changedPath = filePath.split(path.sep).join('/');
@@ -414,7 +433,10 @@ export async function startEditorServer(options: StartEditorOptions): Promise<Ed
414
433
  },
415
434
  },
416
435
  });
417
- const stopWatcher = watchEditorProject(projectRoot, hostSession.notifyProjectFileChanged);
436
+ const stopWatcher = watchEditorProject(projectRoot, (changedPath) => {
437
+ service.invalidate(changedPath);
438
+ hostSession.notifyProjectFileChanged(changedPath);
439
+ });
418
440
  const url = `http://${server.hostname}:${server.port}`;
419
441
  const descriptor: EditorSessionDescriptor = {
420
442
  protocolVersion: editorSessionProtocolVersion,
package/src/viteTarget.ts CHANGED
@@ -71,6 +71,7 @@ export async function validatePixifactTarget(projectRootInput: string, mode: str
71
71
  'pixifact-platform',
72
72
  'pixifact-assets',
73
73
  'pixifact-resources',
74
+ 'pixifact-code-packages',
74
75
  'pixifact-minigame',
75
76
  ]) {
76
77
  if (!pluginNames.has(name)) {
@@ -232,7 +233,7 @@ async function collectDiagnostics(
232
233
  if (gameJson[property] !== undefined) {
233
234
  diagnostics.push({
234
235
  asset: `platforms/${platform}/game.json`,
235
- message: `${property} 由 Pixifact 根据 resourcePacks 生成,不能在源模板中重复声明。`,
236
+ message: `${property} 由 Pixifact 根据资源包和代码分包生成,不能在源模板中重复声明。`,
236
237
  });
237
238
  }
238
239
  }
@@ -1 +0,0 @@
1
- import{_ as e,d as t,f as n,g as r,h as i,p as a,y as o}from"./captureCompilerScenePreview-BYHGr0JS.js";import"./init-BOfNyIRQ.js";o.add(r),o.mixin(e,i),o.add(a),o.add(n),o.mixin(e,t);
@@ -1 +0,0 @@
1
- import{A as e,C as t,T as n,m as r,n as i,r as a,t as o,x as s}from"./captureCompilerScenePreview-BYHGr0JS.js";window.capturePixifactScene=async c=>{let[l,u]=await Promise.all([t(),n(c)]),d=await i({document:{template:e(u.source),sceneInterfaces:{}},projectTree:s(l),scenePath:c}),f=new r,p=!1;try{return await f.init({width:d.width,height:d.height,backgroundAlpha:0,antialias:!0,autoStart:!1,resolution:1}),p=!0,f.stage.addChild(d.root),{scenePath:u.path,revision:u.version,width:d.width,height:d.height,dataUrl:await o(f,d)}}finally{p&&(f.stage.removeChild(d.root),f.destroy({removeView:!0},{children:!1})),a(d)}};