@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.
- package/LICENSE +201 -0
- package/README.md +38 -3
- package/dist/build/bundle-hooks.d.ts +23 -0
- package/dist/build/bundle-hooks.js +79 -0
- package/dist/build/classic-script.d.ts +11 -0
- package/dist/build/classic-script.js +46 -0
- package/dist/build/compress.d.ts +29 -0
- package/dist/build/compress.js +63 -0
- package/dist/build/dependency-imports.d.ts +53 -0
- package/dist/build/dependency-imports.js +239 -0
- package/dist/build/dev-manifest.d.ts +10 -0
- package/dist/build/dev-manifest.js +25 -0
- package/dist/build/editor-flush.d.ts +42 -0
- package/dist/build/editor-flush.js +91 -0
- package/dist/build/finish.d.ts +11 -0
- package/dist/build/finish.js +126 -0
- package/dist/build/output-plugins.d.ts +26 -0
- package/dist/build/output-plugins.js +88 -0
- package/dist/build/plan.d.ts +75 -0
- package/dist/build/plan.js +162 -0
- package/dist/build/player-modules.d.ts +99 -0
- package/dist/build/player-modules.js +204 -0
- package/dist/build/project-manifest.d.ts +57 -0
- package/dist/build/project-manifest.js +169 -0
- package/dist/build/record.d.ts +25 -0
- package/dist/build/record.js +14 -0
- package/dist/build/report.d.ts +114 -0
- package/dist/build/report.js +102 -0
- package/dist/build/scan.d.ts +84 -0
- package/dist/build/scan.js +375 -0
- package/dist/build/strip-decision.d.ts +27 -0
- package/dist/build/strip-decision.js +82 -0
- package/dist/build/strippable-runtime-modules.d.ts +85 -0
- package/dist/build/strippable-runtime-modules.js +309 -0
- package/dist/build/zip.d.ts +6 -0
- package/dist/build/zip.js +28 -0
- package/dist/client/host-files.d.ts +96 -0
- package/dist/client/host-files.js +169 -0
- package/dist/client/index.d.ts +218 -0
- package/dist/client/index.js +381 -0
- package/dist/dev-info.d.ts +55 -0
- package/dist/dev-info.js +116 -0
- package/dist/dev-server.d.ts +28 -0
- package/dist/dev-server.js +139 -0
- package/dist/editor-page.d.ts +31 -0
- package/dist/editor-page.js +74 -0
- package/dist/files/changeset.d.ts +84 -0
- package/dist/files/changeset.js +321 -0
- package/dist/files/content-type.d.ts +1 -0
- package/dist/files/content-type.js +56 -0
- package/dist/files/history.d.ts +67 -0
- package/dist/files/history.js +162 -0
- package/dist/files/paths.d.ts +41 -0
- package/dist/files/paths.js +144 -0
- package/dist/files/project-files.d.ts +208 -0
- package/dist/files/project-files.js +1062 -0
- package/dist/files/scan.d.ts +71 -0
- package/dist/files/scan.js +252 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +278 -0
- package/dist/module-paths.d.ts +13 -0
- package/dist/module-paths.js +32 -0
- package/dist/player/index.d.ts +31 -0
- package/dist/player/index.js +102 -0
- package/dist/server/editor-socket.d.ts +53 -0
- package/dist/server/editor-socket.js +134 -0
- package/dist/server/guard.d.ts +61 -0
- package/dist/server/guard.js +165 -0
- package/dist/server/http.d.ts +24 -0
- package/dist/server/http.js +70 -0
- package/dist/server/image-keys.d.ts +46 -0
- package/dist/server/image-keys.js +118 -0
- package/dist/server/image-proxy.d.ts +32 -0
- package/dist/server/image-proxy.js +124 -0
- package/dist/server/router.d.ts +54 -0
- package/dist/server/router.js +147 -0
- package/dist/sync/barrier.d.ts +69 -0
- package/dist/sync/barrier.js +240 -0
- package/dist/sync/hot-update.d.ts +16 -0
- package/dist/sync/hot-update.js +58 -0
- package/dist/sync/script-graph.d.ts +79 -0
- package/dist/sync/script-graph.js +214 -0
- package/dist/vite-config.d.ts +12 -0
- package/dist/vite-config.js +62 -0
- 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
|
|
4
|
-
"
|
|
5
|
-
"
|
|
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
|
+
}
|