-
Notifications
You must be signed in to change notification settings - Fork 255
Move 3D module to separate @opentui/3d package #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
remorses
wants to merge
15
commits into
sst:main
Choose a base branch
from
remorses:move-3d-to-separate-package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
be652e9
create 3d package
remorses e48f864
pin node types
kommander f471742
add build and publish scripts for @opentui/3d
remorses 5779db5
move 3D examples and benchmark to @opentui/3d package
remorses df292ca
remove 3D examples from core examples index
remorses 8e396e4
move assets from core to 3d package (git rename)
remorses 15b803d
format
remorses e9c8d59
align 3d package.json with repo conventions
remorses abdb5e1
remove unnecessary @types/node from 3d package
remorses 42c8186
simplify 3d build: publish TS source directly (152KB vs 1.1MB)
remorses 75332e7
use packages:external in 3d build (168KB vs 1.1MB)
remorses 8a1c3f5
Keep 3d examples in core, import from @opentui/3d package
remorses e70bef8
Fix build order: core before 3d
remorses 1c74ff7
fix: remove three types from core tsconfig
remorses 83d0b11
fix: remove unused ts-expect-error from reconciler
remorses File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "name": "@opentui/3d", | ||
| "version": "0.1.60", | ||
| "description": "3D rendering module for OpenTUI", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/sst/opentui", | ||
| "directory": "packages/3d" | ||
| }, | ||
| "module": "src/index.ts", | ||
| "type": "module", | ||
| "main": "src/index.ts", | ||
| "license": "MIT", | ||
| "scripts": { | ||
| "build": "bun scripts/build.ts", | ||
| "publish": "bun scripts/publish.ts" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/bun": "latest", | ||
| "@types/three": "0.177.0", | ||
| "typescript": "^5" | ||
| }, | ||
| "dependencies": { | ||
| "@opentui/core": "workspace:*" | ||
| }, | ||
| "optionalDependencies": { | ||
| "@dimforge/rapier2d-simd-compat": "^0.17.3", | ||
| "bun-webgpu": "0.1.4", | ||
| "planck": "^1.4.2", | ||
| "three": "0.177.0" | ||
| }, | ||
| "exports": { | ||
| ".": { | ||
| "types": "./src/index.ts", | ||
| "import": "./src/index.ts" | ||
| } | ||
| }, | ||
| "engines": { | ||
| "bun": ">=1.2.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import { spawnSync, type SpawnSyncReturns } from "node:child_process" | ||
| import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs" | ||
| import { dirname, join, resolve } from "path" | ||
| import { fileURLToPath } from "url" | ||
| import process from "process" | ||
|
|
||
| interface PackageJson { | ||
| name: string | ||
| version: string | ||
| license?: string | ||
| repository?: any | ||
| description?: string | ||
| homepage?: string | ||
| author?: string | ||
| bugs?: any | ||
| keywords?: string[] | ||
| module?: string | ||
| main?: string | ||
| types?: string | ||
| type?: string | ||
| exports?: any | ||
| dependencies?: Record<string, string> | ||
| devDependencies?: Record<string, string> | ||
| peerDependencies?: Record<string, string> | ||
| optionalDependencies?: Record<string, string> | ||
| engines?: Record<string, string> | ||
| } | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url) | ||
| const __dirname = dirname(__filename) | ||
| const rootDir = resolve(__dirname, "..") | ||
| const projectRootDir = resolve(rootDir, "../..") | ||
| const licensePath = join(projectRootDir, "LICENSE") | ||
| const packageJson: PackageJson = JSON.parse(readFileSync(join(rootDir, "package.json"), "utf8")) | ||
|
|
||
| const args = process.argv.slice(2) | ||
| const isCi = args.includes("--ci") | ||
|
|
||
| console.log("Building @opentui/3d library...") | ||
|
|
||
| const distDir = join(rootDir, "dist") | ||
| rmSync(distDir, { recursive: true, force: true }) | ||
| mkdirSync(distDir, { recursive: true }) | ||
|
|
||
| if (!packageJson.module) { | ||
| console.error("Error: 'module' field not found in package.json") | ||
| process.exit(1) | ||
| } | ||
|
|
||
| console.log("Building main entry point...") | ||
| const mainBuildResult = await Bun.build({ | ||
| entrypoints: [join(rootDir, packageJson.module)], | ||
| target: "bun", | ||
| outdir: distDir, | ||
| packages: "external", | ||
| splitting: true, | ||
| }) | ||
|
|
||
| if (!mainBuildResult.success) { | ||
| console.error("Build failed:", mainBuildResult.logs) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| console.log("Generating TypeScript declarations...") | ||
| const tsconfigBuildPath = join(rootDir, "tsconfig.build.json") | ||
| const tscResult: SpawnSyncReturns<Buffer> = spawnSync("bunx", ["tsc", "-p", tsconfigBuildPath], { | ||
| cwd: rootDir, | ||
| stdio: "inherit", | ||
| }) | ||
|
|
||
| if (tscResult.status !== 0) { | ||
| if (isCi) { | ||
| console.error("Error: TypeScript declaration generation failed") | ||
| process.exit(1) | ||
| } | ||
| console.warn("Warning: TypeScript declaration generation failed") | ||
| } else { | ||
| console.log("TypeScript declarations generated") | ||
| } | ||
|
|
||
| const exports = { | ||
| ".": { | ||
| types: "./src/index.d.ts", | ||
| import: "./index.js", | ||
| require: "./index.js", | ||
| }, | ||
| } | ||
|
|
||
| const processedDependencies = { ...packageJson.dependencies } | ||
| if (processedDependencies["@opentui/core"] === "workspace:*") { | ||
| processedDependencies["@opentui/core"] = packageJson.version | ||
| } | ||
|
|
||
| writeFileSync( | ||
| join(distDir, "package.json"), | ||
| JSON.stringify( | ||
| { | ||
| name: packageJson.name, | ||
| version: packageJson.version, | ||
| description: packageJson.description, | ||
| repository: packageJson.repository, | ||
| module: "index.js", | ||
| main: "index.js", | ||
| types: "src/index.d.ts", | ||
| type: packageJson.type, | ||
| license: packageJson.license, | ||
| exports, | ||
| dependencies: processedDependencies, | ||
| optionalDependencies: packageJson.optionalDependencies, | ||
| engines: packageJson.engines, | ||
| }, | ||
| null, | ||
| 2, | ||
| ), | ||
| ) | ||
|
|
||
| const readmePath = join(rootDir, "README.md") | ||
| if (existsSync(readmePath)) { | ||
| copyFileSync(readmePath, join(distDir, "README.md")) | ||
| } | ||
|
|
||
| if (existsSync(licensePath)) { | ||
| copyFileSync(licensePath, join(distDir, "LICENSE")) | ||
| } | ||
|
|
||
| console.log("Library built at:", distDir) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { spawnSync, type SpawnSyncReturns } from "node:child_process" | ||
| import { readFileSync } from "node:fs" | ||
| import { dirname, join, resolve } from "node:path" | ||
| import process from "node:process" | ||
| import { fileURLToPath } from "node:url" | ||
|
|
||
| interface PackageJson { | ||
| name: string | ||
| version: string | ||
| dependencies?: Record<string, string> | ||
| } | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url) | ||
| const __dirname = dirname(__filename) | ||
| const rootDir = resolve(__dirname, "..") | ||
|
|
||
| const packageJson: PackageJson = JSON.parse(readFileSync(join(rootDir, "package.json"), "utf8")) | ||
|
|
||
| console.log(`Publishing @opentui/3d@${packageJson.version}...`) | ||
| console.log("Make sure you've run the pre-publish validation script first!") | ||
|
|
||
| const distDir = join(rootDir, "dist") | ||
|
|
||
| console.log(`\nPublishing ${packageJson.name}@${packageJson.version}...`) | ||
|
|
||
| const isSnapshot = packageJson.version.includes("-snapshot") || /^0\.0\.0-\d{8}-[a-f0-9]{8}$/.test(packageJson.version) | ||
| const publishArgs = ["publish", "--access=public"] | ||
|
|
||
| if (isSnapshot) { | ||
| publishArgs.push("--tag", "snapshot") | ||
| console.log(` Publishing as snapshot (--tag snapshot)`) | ||
| } | ||
|
|
||
| const publish: SpawnSyncReturns<Buffer> = spawnSync("npm", publishArgs, { | ||
| cwd: distDir, | ||
| stdio: "inherit", | ||
| }) | ||
|
|
||
| if (publish.status !== 0) { | ||
| console.error(`Failed to publish '${packageJson.name}@${packageJson.version}'.`) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| console.log(`Successfully published '${packageJson.name}@${packageJson.version}'`) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions
4
packages/core/src/3d/WGPURenderer.ts → packages/3d/src/WGPURenderer.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/tsconfig", | ||
| "extends": "./tsconfig.json", | ||
| "compilerOptions": { | ||
| "declaration": true, | ||
| "emitDeclarationOnly": true, | ||
| "outDir": "./dist", | ||
| "noEmit": false, | ||
| "rootDir": ".", | ||
| "types": ["bun"], | ||
| "skipLibCheck": true, | ||
| "moduleResolution": "bundler", | ||
| "baseUrl": ".", | ||
| "paths": { | ||
| "@opentui/core": ["../core/dist"], | ||
| "@opentui/core/*": ["../core/dist/*"] | ||
| } | ||
| }, | ||
| "include": ["src/**/*"], | ||
| "exclude": ["**/*.test.ts", "**/*.spec.ts", "scripts/**/*", "node_modules/**/*", "../core/**/*"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "compilerOptions": { | ||
| // Enable latest features | ||
| "lib": ["ESNext", "DOM"], | ||
| "target": "ESNext", | ||
| "module": "ESNext", | ||
| "moduleDetection": "force", | ||
| "jsx": "react-jsx", | ||
| "allowJs": true, | ||
|
|
||
| // Bundler mode | ||
| "moduleResolution": "bundler", | ||
| "allowImportingTsExtensions": true, | ||
| "verbatimModuleSyntax": true, | ||
| "noEmit": true, | ||
|
|
||
| // Best practices | ||
| "strict": true, | ||
| "skipLibCheck": true, | ||
| "noFallthroughCasesInSwitch": true, | ||
|
|
||
| // Some stricter flags (disabled by default) | ||
| "noUnusedLocals": false, | ||
| "noUnusedParameters": false, | ||
| "noPropertyAccessFromIndexSignature": false | ||
| }, | ||
| "exclude": ["dist"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.