mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-06 07:26:43 -04:00
34d8cd4dd4
# Description of Changes
This adds `react` as an optional peer dependency. If the TypeScript SDK
is imported into a library that uses React (of the appropriate version)
then they will have access to two new React hooks:
```ts
useSpacetimeDB<DbConnection>();
useTable<DbConnection, MyTable>('my_table');
```
This PR also updates the TypeScript `quickstart-chat` tutorial in the
docs to use the new React hooks. I will split that tutorial into
separate `React` and `TypeScript` tutorials in a future PR.
# API and ABI breaking changes
This is a purely additive change to the SDK
# Expected complexity level and risk
2 because it changes how the SDK is built a bit. Namely it makes the
`spacetimedb` library an external dependency.
# Testing
TODO: I am not through testing yet.
---------
Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Julien Lavocat <JulienLavocat@users.noreply.github.com>
183 lines
5.1 KiB
JSON
183 lines
5.1 KiB
JSON
{
|
|
"name": "spacetimedb",
|
|
"version": "0.0.1",
|
|
"description": "API and ABI bindings for the SpacetimeDB TypeScript module library",
|
|
"homepage": "https://github.com/clockworklabs/SpacetimeDB#readme",
|
|
"bugs": {
|
|
"url": "https://github.com/clockworklabs/SpacetimeDB/issues"
|
|
},
|
|
"files": [
|
|
"src",
|
|
"dist",
|
|
"README.md",
|
|
"LICENSE.txt"
|
|
],
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/clockworklabs/SpacetimeDB.git"
|
|
},
|
|
"license": "ISC",
|
|
"author": "Clockwork Labs",
|
|
"type": "module",
|
|
"sideEffects": false,
|
|
"scripts": {
|
|
"build": "tsup",
|
|
"format": "prettier . --write --ignore-path ../../.prettierignore",
|
|
"lint": "eslint . && prettier . --check --ignore-path ../../.prettierignore",
|
|
"test": "vitest run",
|
|
"coverage": "vitest run --coverage",
|
|
"brotli-size": "brotli-size dist/index.js",
|
|
"size": "pnpm -s build && size-limit",
|
|
"generate:moduledef": "cargo run -p spacetimedb-codegen --example regen-typescript-moduledef && prettier --write src/lib/autogen",
|
|
"generate:client-api": "cargo build -p spacetimedb-standalone && cargo run -p spacetimedb-client-api-messages --example get_ws_schema > ws_schema.json && cargo run -p spacetimedb-cli generate --lang typescript --out-dir src/sdk/client_api --module-def ws_schema.json && rm ws_schema.json && find src/sdk/client_api -type f -exec perl -pi -e 's#\\@clockworklabs/spacetimedb-sdk#../../index#g' {} + && prettier --write src/sdk/client_api",
|
|
"generate:test-app": "pnpm --filter @clockworklabs/test-app generate",
|
|
"generate": "pnpm generate:moduledef && pnpm generate:client-api && pnpm generate:test-app"
|
|
},
|
|
"source": "src/index.ts",
|
|
"main": "dist/index.cjs",
|
|
"module": "dist/index.mjs",
|
|
"types": "src/index.ts",
|
|
"exports": {
|
|
".": {
|
|
"types": "./src/index.ts",
|
|
"source": "./src/index.ts",
|
|
"development": "./src/index.ts",
|
|
"browser": "./dist/index.browser.mjs",
|
|
"import": "./dist/index.mjs",
|
|
"require": "./dist/index.cjs",
|
|
"default": "./dist/index.mjs"
|
|
},
|
|
"./sdk": {
|
|
"types": "./src/sdk/index.ts",
|
|
"browser": "./dist/sdk/index.browser.mjs",
|
|
"import": "./dist/sdk/index.mjs",
|
|
"require": "./dist/sdk/index.cjs",
|
|
"default": "./dist/sdk/index.mjs"
|
|
},
|
|
"./react": {
|
|
"types": "./src/react/index.ts",
|
|
"import": "./dist/react/index.mjs",
|
|
"require": "./dist/react/index.cjs",
|
|
"default": "./dist/react/index.mjs"
|
|
},
|
|
"./server": {
|
|
"types": "./src/server/index.ts",
|
|
"import": "./dist/server/index.mjs",
|
|
"require": "./dist/server/index.cjs",
|
|
"default": "./dist/server/index.mjs"
|
|
}
|
|
},
|
|
"size-limit": [
|
|
{
|
|
"name": "cjs (brotli)",
|
|
"path": "dist/index.cjs",
|
|
"brotli": true,
|
|
"limit": "25 kB"
|
|
},
|
|
{
|
|
"name": "esm (brotli)",
|
|
"path": "dist/index.mjs",
|
|
"brotli": true,
|
|
"limit": "20 kB"
|
|
},
|
|
{
|
|
"name": "esm (gzip)",
|
|
"path": "dist/index.mjs",
|
|
"gzip": true,
|
|
"limit": "25 kB"
|
|
},
|
|
{
|
|
"name": "esm (uncompressed)",
|
|
"path": "dist/index.mjs",
|
|
"brotli": false,
|
|
"limit": "150 kB"
|
|
},
|
|
{
|
|
"name": "esm min (brotli)",
|
|
"path": "dist/min/index.mjs",
|
|
"brotli": true,
|
|
"limit": "10 kB"
|
|
},
|
|
{
|
|
"name": "esm min (gzip)",
|
|
"path": "dist/min/index.mjs",
|
|
"gzip": true,
|
|
"limit": "15 kB"
|
|
},
|
|
{
|
|
"name": "esm min (uncompressed)",
|
|
"path": "dist/min/index.mjs",
|
|
"brotli": false,
|
|
"limit": "60 kB"
|
|
},
|
|
{
|
|
"name": "react esm min (brotli)",
|
|
"path": "dist/min/react/index.mjs",
|
|
"brotli": true,
|
|
"limit": "10 kB"
|
|
},
|
|
{
|
|
"name": "react esm min (uncompressed)",
|
|
"path": "dist/min/react/index.mjs",
|
|
"limit": "10 kB"
|
|
},
|
|
{
|
|
"name": "react esm min (gzip)",
|
|
"path": "dist/min/react/index.mjs",
|
|
"gzip": true,
|
|
"limit": "15 kB"
|
|
},
|
|
{
|
|
"name": "sdk esm min (brotli)",
|
|
"path": "dist/min/sdk/index.browser.mjs",
|
|
"brotli": true,
|
|
"limit": "10 kB"
|
|
},
|
|
{
|
|
"name": "sdk esm min (gzip)",
|
|
"path": "dist/min/sdk/index.browser.mjs",
|
|
"gzip": true,
|
|
"limit": "15 kB"
|
|
},
|
|
{
|
|
"name": "sdk esm min (uncompressed)",
|
|
"path": "dist/min/sdk/index.browser.mjs",
|
|
"limit": "10 kB"
|
|
}
|
|
],
|
|
"dependencies": {
|
|
"base64-js": "^1.5.1",
|
|
"prettier": "^3.3.3"
|
|
},
|
|
"peerDependencies": {
|
|
"react": "^18.0.0 || ^19.0.0-0 || ^19.0.0",
|
|
"undici": "^6.19.2"
|
|
},
|
|
"peerDependenciesMeta": {
|
|
"react": {
|
|
"optional": true
|
|
},
|
|
"undici": {
|
|
"optional": true
|
|
}
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/js": "^9.17.0",
|
|
"@size-limit/file": "^11.2.0",
|
|
"@types/react": "^19.1.13",
|
|
"@typescript-eslint/eslint-plugin": "^8.18.2",
|
|
"@typescript-eslint/parser": "^8.18.2",
|
|
"@vitest/coverage-v8": "^3.2.4",
|
|
"brotli-size-cli": "^1.0.0",
|
|
"eslint": "^9.33.0",
|
|
"globals": "^15.14.0",
|
|
"size-limit": "^11.2.0",
|
|
"ts-node": "^10.9.2",
|
|
"tsup": "^8.1.0",
|
|
"typescript": "^5.9.2",
|
|
"typescript-eslint": "^8.18.2",
|
|
"vite": "^7.1.5",
|
|
"vitest": "^3.2.4"
|
|
}
|
|
}
|