@pix3/vite-plugin 0.0.0-stage → 2.0.0-alpha.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.
Files changed (85) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +38 -3
  3. package/dist/build/bundle-hooks.d.ts +23 -0
  4. package/dist/build/bundle-hooks.js +79 -0
  5. package/dist/build/classic-script.d.ts +11 -0
  6. package/dist/build/classic-script.js +46 -0
  7. package/dist/build/compress.d.ts +29 -0
  8. package/dist/build/compress.js +63 -0
  9. package/dist/build/dependency-imports.d.ts +53 -0
  10. package/dist/build/dependency-imports.js +239 -0
  11. package/dist/build/dev-manifest.d.ts +10 -0
  12. package/dist/build/dev-manifest.js +25 -0
  13. package/dist/build/editor-flush.d.ts +42 -0
  14. package/dist/build/editor-flush.js +91 -0
  15. package/dist/build/finish.d.ts +11 -0
  16. package/dist/build/finish.js +126 -0
  17. package/dist/build/output-plugins.d.ts +26 -0
  18. package/dist/build/output-plugins.js +88 -0
  19. package/dist/build/plan.d.ts +75 -0
  20. package/dist/build/plan.js +162 -0
  21. package/dist/build/player-modules.d.ts +99 -0
  22. package/dist/build/player-modules.js +204 -0
  23. package/dist/build/project-manifest.d.ts +57 -0
  24. package/dist/build/project-manifest.js +169 -0
  25. package/dist/build/record.d.ts +25 -0
  26. package/dist/build/record.js +14 -0
  27. package/dist/build/report.d.ts +114 -0
  28. package/dist/build/report.js +102 -0
  29. package/dist/build/scan.d.ts +84 -0
  30. package/dist/build/scan.js +375 -0
  31. package/dist/build/strip-decision.d.ts +27 -0
  32. package/dist/build/strip-decision.js +82 -0
  33. package/dist/build/strippable-runtime-modules.d.ts +85 -0
  34. package/dist/build/strippable-runtime-modules.js +309 -0
  35. package/dist/build/zip.d.ts +6 -0
  36. package/dist/build/zip.js +28 -0
  37. package/dist/client/host-files.d.ts +96 -0
  38. package/dist/client/host-files.js +169 -0
  39. package/dist/client/index.d.ts +218 -0
  40. package/dist/client/index.js +381 -0
  41. package/dist/dev-info.d.ts +55 -0
  42. package/dist/dev-info.js +116 -0
  43. package/dist/dev-server.d.ts +28 -0
  44. package/dist/dev-server.js +139 -0
  45. package/dist/editor-page.d.ts +31 -0
  46. package/dist/editor-page.js +74 -0
  47. package/dist/files/changeset.d.ts +84 -0
  48. package/dist/files/changeset.js +321 -0
  49. package/dist/files/content-type.d.ts +1 -0
  50. package/dist/files/content-type.js +56 -0
  51. package/dist/files/history.d.ts +67 -0
  52. package/dist/files/history.js +162 -0
  53. package/dist/files/paths.d.ts +41 -0
  54. package/dist/files/paths.js +144 -0
  55. package/dist/files/project-files.d.ts +208 -0
  56. package/dist/files/project-files.js +1062 -0
  57. package/dist/files/scan.d.ts +71 -0
  58. package/dist/files/scan.js +252 -0
  59. package/dist/index.d.ts +56 -0
  60. package/dist/index.js +278 -0
  61. package/dist/module-paths.d.ts +13 -0
  62. package/dist/module-paths.js +32 -0
  63. package/dist/player/index.d.ts +31 -0
  64. package/dist/player/index.js +102 -0
  65. package/dist/server/editor-socket.d.ts +53 -0
  66. package/dist/server/editor-socket.js +134 -0
  67. package/dist/server/guard.d.ts +61 -0
  68. package/dist/server/guard.js +165 -0
  69. package/dist/server/http.d.ts +24 -0
  70. package/dist/server/http.js +70 -0
  71. package/dist/server/image-keys.d.ts +46 -0
  72. package/dist/server/image-keys.js +118 -0
  73. package/dist/server/image-proxy.d.ts +32 -0
  74. package/dist/server/image-proxy.js +124 -0
  75. package/dist/server/router.d.ts +54 -0
  76. package/dist/server/router.js +147 -0
  77. package/dist/sync/barrier.d.ts +69 -0
  78. package/dist/sync/barrier.js +240 -0
  79. package/dist/sync/hot-update.d.ts +16 -0
  80. package/dist/sync/hot-update.js +58 -0
  81. package/dist/sync/script-graph.d.ts +79 -0
  82. package/dist/sync/script-graph.js +214 -0
  83. package/dist/vite-config.d.ts +12 -0
  84. package/dist/vite-config.js +62 -0
  85. package/package.json +60 -6
@@ -0,0 +1,62 @@
1
+ import { readFileSync, realpathSync } from 'node:fs';
2
+ import { join, resolve } from 'node:path';
3
+ import { searchForWorkspaceRoot } from 'vite';
4
+ import { findPackageDir } from "./dev-info.js";
5
+ /** `dist/optimize-deps.json` of the installed editor, or nothing. */
6
+ const editorOptimizeDeps = (editorCoreDir) => {
7
+ if (!editorCoreDir)
8
+ return [];
9
+ try {
10
+ const list = JSON.parse(readFileSync(join(editorCoreDir, 'dist', 'optimize-deps.json'), 'utf8'));
11
+ return Array.isArray(list) ? list.filter((id) => typeof id === 'string') : [];
12
+ }
13
+ catch {
14
+ return [];
15
+ }
16
+ };
17
+ /** The plugin's `config` hook: what it adds to the user's Vite config. */
18
+ export const pix3ViteConfig = (options) => {
19
+ const { user, format } = options;
20
+ const projectRoot = resolve(user.root ?? process.cwd());
21
+ const linkedEditorCore = findPackageDir(projectRoot, '@pix3/editor-core');
22
+ // Vite checks `fs.allow` against real paths; a workspace or pnpm link points elsewhere.
23
+ const editorCoreDir = linkedEditorCore ? realpathSync(linkedEditorCore) : null;
24
+ // An explicit `fs.allow` switches off Vite's workspace-root default; keep it when the user
25
+ // set none, and add this package (the page client and the player are served from it by
26
+ // `/@fs/`) and the prebuilt editor (served from wherever npm put it: hoisted, pnpm, a
27
+ // workspace link).
28
+ const own = [options.packageDir, ...(editorCoreDir ? [editorCoreDir] : [])];
29
+ const allow = user.server?.fs?.allow ? own : [searchForWorkspaceRoot(projectRoot), ...own];
30
+ // rolldown's output option is `codeSplitting`; rollup spells the same `inlineDynamicImports`.
31
+ const singleChunk = options.rolldown ? { codeSplitting: false } : { inlineDynamicImports: true };
32
+ // A compressed build is injected as script text: `iife`, so it declares nothing global.
33
+ const outputFormat = options.compress && format === 'html' ? { format: 'iife' } : {};
34
+ return {
35
+ resolve: { dedupe: ['three', '@pix3/runtime'] },
36
+ optimizeDeps: {
37
+ // One runtime and one three for the game and the editor (plan §B.2, S1), plus the bare
38
+ // subpaths the prebuilt editor imports (`dist/optimize-deps.json`).
39
+ include: ['@pix3/runtime', 'three', ...editorOptimizeDeps(editorCoreDir)],
40
+ exclude: ['@pix3/editor-core'],
41
+ },
42
+ server: { fs: { allow } },
43
+ ...(format
44
+ ? {
45
+ // Relative URLs: the artifact runs from `file://`, a subfolder or a sandboxed frame.
46
+ base: './',
47
+ build: format === 'html'
48
+ ? {
49
+ // Everything inlined (the single-file plugin's recommended config, set here
50
+ // so the chunking flag follows the bundler, not Vite's version string).
51
+ assetsInlineLimit: () => true,
52
+ chunkSizeWarningLimit: 100_000_000,
53
+ cssCodeSplit: false,
54
+ assetsDir: '',
55
+ modulePreload: false,
56
+ rollupOptions: { output: { ...singleChunk, ...outputFormat } },
57
+ }
58
+ : {},
59
+ }
60
+ : {}),
61
+ };
62
+ };
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
- {
2
- "name": "@pix3/vite-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "@pix3/vite-plugin",
3
+ "version": "2.0.0-alpha.0",
4
+ "description": "Pix3 editor, file API, sync barrier and build as a Vite plugin.",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/pix3dev/pix3-core.git",
9
+ "directory": "packages/vite-plugin"
10
+ },
11
+ "homepage": "https://github.com/pix3dev/pix3-core/tree/main/packages/vite-plugin#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/pix3dev/pix3-core/issues"
14
+ },
15
+ "engines": {
16
+ "node": ">=20.19"
17
+ },
18
+ "main": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js"
24
+ },
25
+ "./player": {
26
+ "types": "./dist/player/index.d.ts",
27
+ "import": "./dist/player/index.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "README.md"
33
+ ],
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.build.json && tsc -p player/tsconfig.build.json",
36
+ "prepack": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && npm run build",
37
+ "type-check": "tsc --noEmit && tsc --noEmit -p tsconfig.build.json && tsc --noEmit -p player/tsconfig.json"
38
+ },
39
+ "dependencies": {
40
+ "fflate": "^0.8.3",
41
+ "vite-plugin-singlefile": "^2.3.3",
42
+ "ws": "^8.18.0",
43
+ "yaml": "^2.6.0"
44
+ },
45
+ "peerDependencies": {
46
+ "@pix3/runtime": "2.0.0-alpha.0",
47
+ "vite": "^7 || ^8"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "^24.5.2",
51
+ "@types/ws": "^8.18.1",
52
+ "typescript": "~5.8.3",
53
+ "vite": "^8.3.3"
54
+ },
55
+ "license": "Apache-2.0",
56
+ "publishConfig": {
57
+ "access": "public",
58
+ "tag": "next"
59
+ }
60
+ }