tool: add spacetimedb
This commit is contained in:
36
spacetimedb/bun.lock
Normal file
36
spacetimedb/bun.lock
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"configVersion": 1,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "space-stream",
|
||||
"dependencies": {
|
||||
"spacetimedb": "^2.1.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "~5.6.2",
|
||||
},
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
"base64-js": ["base64-js@1.5.1", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="],
|
||||
|
||||
"headers-polyfill": ["headers-polyfill@4.0.3", "", {}, "sha512-IScLbePpkvO846sIwOtOTDjutRMWdXdJmXdMvk6gCBHxFO8d+QKOQedyZSxFTTFYRSmlgSTDtXqqq4pcenBXLQ=="],
|
||||
|
||||
"object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
|
||||
|
||||
"prettier": ["prettier@3.8.2", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-8c3mgTe0ASwWAJK+78dpviD+A8EqhndQPUBpNUIPt6+xWlIigCwfN01lWr9MAede4uqXGTEKeQWTvzb3vjia0Q=="],
|
||||
|
||||
"pure-rand": ["pure-rand@7.0.1", "", {}, "sha512-oTUZM/NAZS8p7ANR3SHh30kXB+zK2r2BPcEn/awJIbOvq82WoMN4p62AWWp3Hhw50G0xMsw1mhIBLqHw64EcNQ=="],
|
||||
|
||||
"safe-stable-stringify": ["safe-stable-stringify@2.5.0", "", {}, "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA=="],
|
||||
|
||||
"spacetimedb": ["spacetimedb@2.1.0", "", { "dependencies": { "base64-js": "^1.5.1", "headers-polyfill": "^4.0.3", "object-inspect": "^1.13.4", "prettier": "^3.3.3", "pure-rand": "^7.0.1", "safe-stable-stringify": "^2.5.0", "statuses": "^2.0.2", "url-polyfill": "^1.1.14" }, "peerDependencies": { "@angular/core": ">=17.0.0", "@tanstack/react-query": "^5.0.0", "react": "^18.0.0 || ^19.0.0-0 || ^19.0.0", "svelte": "^4.0.0 || ^5.0.0", "undici": "^6.19.2", "vue": "^3.3.0" }, "optionalPeers": ["@angular/core", "@tanstack/react-query", "react", "svelte", "undici", "vue"] }, "sha512-Kzs+HXCRj15ryld03ztU4a2uQg0M8ivV/9Bk/gvMpb59lLc/A2/r7UkGCYBePsBL7Zwqgr8gE8FeufoZVXtPnA=="],
|
||||
|
||||
"statuses": ["statuses@2.0.2", "", {}, "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw=="],
|
||||
|
||||
"typescript": ["typescript@5.6.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw=="],
|
||||
|
||||
"url-polyfill": ["url-polyfill@1.1.14", "", {}, "sha512-p4f3TTAG6ADVF3mwbXw7hGw+QJyw5CnNGvYh5fCuQQZIiuKUswqcznyV3pGDP9j0TSmC4UvRKm8kl1QsX1diiQ=="],
|
||||
}
|
||||
}
|
||||
18
spacetimedb/package.json
Normal file
18
spacetimedb/package.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "space-stream",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build": "spacetime build",
|
||||
"publish": "spacetime publish"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"spacetimedb": "^2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "~5.6.2"
|
||||
}
|
||||
}
|
||||
37
spacetimedb/src/index.ts
Normal file
37
spacetimedb/src/index.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { schema, table, t } from 'spacetimedb/server';
|
||||
|
||||
const spacetimedb = schema({
|
||||
person: table(
|
||||
{ public: true },
|
||||
{
|
||||
name: t.string(),
|
||||
}
|
||||
),
|
||||
});
|
||||
export default spacetimedb;
|
||||
|
||||
export const init = spacetimedb.init(_ctx => {
|
||||
// Called when the module is initially published
|
||||
});
|
||||
|
||||
export const onConnect = spacetimedb.clientConnected(_ctx => {
|
||||
// Called every time a new client connects
|
||||
});
|
||||
|
||||
export const onDisconnect = spacetimedb.clientDisconnected(_ctx => {
|
||||
// Called every time a client disconnects
|
||||
});
|
||||
|
||||
export const add = spacetimedb.reducer(
|
||||
{ name: t.string() },
|
||||
(ctx, { name }) => {
|
||||
ctx.db.person.insert({ name });
|
||||
}
|
||||
);
|
||||
|
||||
export const sayHello = spacetimedb.reducer(ctx => {
|
||||
for (const person of ctx.db.person.iter()) {
|
||||
console.info(`Hello, ${person.name}!`);
|
||||
}
|
||||
console.info('Hello, World!');
|
||||
});
|
||||
23
spacetimedb/tsconfig.json
Normal file
23
spacetimedb/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* This tsconfig is used for TypeScript projects created with `spacetimedb init
|
||||
* --lang typescript`. You can modify it as needed for your project, although
|
||||
* some options are required by SpacetimeDB.
|
||||
*/
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* The following options are required by SpacetimeDB
|
||||
* and should not be modified
|
||||
*/
|
||||
"target": "ESNext",
|
||||
"lib": ["ES2021", "dom"],
|
||||
"module": "ESNext",
|
||||
"isolatedModules": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["./**/*"]
|
||||
}
|
||||
Reference in New Issue
Block a user