format
This commit is contained in:
@@ -7,3 +7,9 @@ bun.lockb
|
||||
|
||||
# Miscellaneous
|
||||
/static/
|
||||
|
||||
# Cloudflare
|
||||
worker-configuration.d.ts
|
||||
|
||||
# SpacetimeDB generated bindings
|
||||
src/lib/st-bindings/*
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
{
|
||||
"useTabs": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"singleQuote": false,
|
||||
"trailingComma": "all",
|
||||
"printWidth": 100,
|
||||
"plugins": [
|
||||
"prettier-plugin-svelte",
|
||||
"prettier-plugin-tailwindcss"
|
||||
],
|
||||
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
|
||||
"tailwindStylesheet": "./src/routes/layout.css",
|
||||
"overrides": [
|
||||
{
|
||||
|
||||
6
.vscode/extensions.json
vendored
6
.vscode/extensions.json
vendored
@@ -1,7 +1,3 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"svelte.svelte-vscode",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
"esbenp.prettier-vscode"
|
||||
]
|
||||
"recommendations": ["svelte.svelte-vscode", "bradlc.vscode-tailwindcss", "esbenp.prettier-vscode"]
|
||||
}
|
||||
|
||||
@@ -37,4 +37,4 @@
|
||||
"vite-plugin-devtools-json": "^1.0.0",
|
||||
"wrangler": "^4.81.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"module-path": "./spacetimedb",
|
||||
"server": "maincloud"
|
||||
}
|
||||
"module-path": "./spacetimedb",
|
||||
"server": "maincloud"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"database": "space-stream-b8trs"
|
||||
}
|
||||
"database": "space-stream-b8trs"
|
||||
}
|
||||
|
||||
@@ -1,18 +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"
|
||||
}
|
||||
}
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,34 @@
|
||||
import { schema, table, t } from 'spacetimedb/server';
|
||||
import { schema, table, t } from "spacetimedb/server";
|
||||
|
||||
const spacetimedb = schema({
|
||||
person: table(
|
||||
{ public: true },
|
||||
{
|
||||
name: t.string(),
|
||||
}
|
||||
),
|
||||
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 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 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 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!');
|
||||
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!");
|
||||
});
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
* some options are required by SpacetimeDB.
|
||||
*/
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"jsx": "react-jsx",
|
||||
"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": ["./**/*"]
|
||||
/* The following options are required by SpacetimeDB
|
||||
* and should not be modified
|
||||
*/
|
||||
"target": "ESNext",
|
||||
"lib": ["ES2021", "dom"],
|
||||
"module": "ESNext",
|
||||
"isolatedModules": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["./**/*"]
|
||||
}
|
||||
|
||||
14
src/app.d.ts
vendored
14
src/app.d.ts
vendored
@@ -2,12 +2,12 @@
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
interface Platform {
|
||||
env: Env;
|
||||
cf: CfProperties;
|
||||
ctx: ExecutionContext;
|
||||
}
|
||||
}
|
||||
interface Platform {
|
||||
env: Env;
|
||||
cf: CfProperties;
|
||||
ctx: ExecutionContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
export {};
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
<script lang="ts">
|
||||
import { env } from '$env/dynamic/public';
|
||||
import type { Identity } from 'spacetimedb';
|
||||
import { createSpacetimeDBProvider } from 'spacetimedb/svelte';
|
||||
import { DbConnection, type ErrorContext } from '$lib/st-bindings';
|
||||
import './layout.css';
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
import { browser } from '$app/environment';
|
||||
import { env } from "$env/dynamic/public";
|
||||
import type { Identity } from "spacetimedb";
|
||||
import { createSpacetimeDBProvider } from "spacetimedb/svelte";
|
||||
import { DbConnection, type ErrorContext } from "$lib/st-bindings";
|
||||
import "./layout.css";
|
||||
import favicon from "$lib/assets/favicon.svg";
|
||||
import { browser } from "$app/environment";
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
const HOST = env.PUBLIC_SPACETIMEDB_HOST ?? 'ws://localhost:3000';
|
||||
const DB_NAME = env.PUBLIC_SPACETIMEDB_DB_NAME ?? 'svelte-ts';
|
||||
const HOST = env.PUBLIC_SPACETIMEDB_HOST ?? "ws://localhost:3000";
|
||||
const DB_NAME = env.PUBLIC_SPACETIMEDB_DB_NAME ?? "svelte-ts";
|
||||
const TOKEN_KEY = `${HOST}/${DB_NAME}/auth_token`;
|
||||
|
||||
console.log(HOST, DB_NAME, TOKEN_KEY);
|
||||
|
||||
const onConnect = (_conn: DbConnection, identity: Identity, token: string) => {
|
||||
if (browser) localStorage.setItem(TOKEN_KEY, token);
|
||||
console.log('Connected to SpacetimeDB with identity:', identity.toHexString());
|
||||
console.log("Connected to SpacetimeDB with identity:", identity.toHexString());
|
||||
};
|
||||
|
||||
const onDisconnect = () => {
|
||||
console.log('Disconnected from SpacetimeDB');
|
||||
console.log("Disconnected from SpacetimeDB");
|
||||
};
|
||||
|
||||
const onConnectError = (_ctx: ErrorContext, err: Error) => {
|
||||
console.log('Error connecting to SpacetimeDB:', err);
|
||||
console.log("Error connecting to SpacetimeDB:", err);
|
||||
};
|
||||
|
||||
const connectionBuilder = DbConnection.builder()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { useSpacetimeDB, useTable, useReducer } from 'spacetimedb/svelte';
|
||||
import { tables, reducers } from '$lib/st-bindings';
|
||||
import { useSpacetimeDB, useTable, useReducer } from "spacetimedb/svelte";
|
||||
import { tables, reducers } from "$lib/st-bindings";
|
||||
|
||||
const conn = useSpacetimeDB();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
const addReducer = useReducer(reducers.add);
|
||||
|
||||
let name = $state('');
|
||||
let name = $state("");
|
||||
|
||||
function addPerson(e: SubmitEvent) {
|
||||
e.preventDefault();
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// Call the add reducer
|
||||
addReducer({ name: name });
|
||||
name = '';
|
||||
name = "";
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<div style="margin-bottom: 1rem;">
|
||||
Status:
|
||||
<strong style="color: {$conn.isActive ? 'green' : 'red'}">
|
||||
{$conn.isActive ? 'Connected' : 'Disconnected'}
|
||||
{$conn.isActive ? "Connected" : "Disconnected"}
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
@import 'tailwindcss';
|
||||
@import "tailwindcss";
|
||||
|
||||
@@ -6,8 +6,8 @@ const config = {
|
||||
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
||||
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
||||
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
||||
adapter: adapter()
|
||||
}
|
||||
adapter: adapter(),
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
export default config;
|
||||
|
||||
@@ -11,10 +11,7 @@
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "bundler",
|
||||
"types": [
|
||||
"./src/worker-configuration.d.ts",
|
||||
"node"
|
||||
]
|
||||
"types": ["./src/worker-configuration.d.ts", "node"]
|
||||
}
|
||||
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
|
||||
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import devtoolsJson from 'vite-plugin-devtools-json';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
import devtoolsJson from "vite-plugin-devtools-json";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { sveltekit } from "@sveltejs/kit/vite";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
export default defineConfig({ plugins: [tailwindcss(), sveltekit(), devtoolsJson()] });
|
||||
|
||||
@@ -7,18 +7,15 @@
|
||||
"name": "space-stream",
|
||||
"main": ".svelte-kit/cloudflare/_worker.js",
|
||||
"compatibility_date": "2026-04-11",
|
||||
"compatibility_flags": [
|
||||
"nodejs_compat",
|
||||
"nodejs_als"
|
||||
],
|
||||
"compatibility_flags": ["nodejs_compat", "nodejs_als"],
|
||||
"assets": {
|
||||
"binding": "ASSETS",
|
||||
"directory": ".svelte-kit/cloudflare"
|
||||
"directory": ".svelte-kit/cloudflare",
|
||||
},
|
||||
"observability": {
|
||||
"enabled": true
|
||||
"enabled": true,
|
||||
},
|
||||
"upload_source_maps": true
|
||||
"upload_source_maps": true,
|
||||
/**
|
||||
* Smart Placement
|
||||
* https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
|
||||
@@ -42,4 +39,4 @@
|
||||
* https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
|
||||
*/
|
||||
// "services": [ { "binding": "MY_SERVICE", "service": "my-service" } ]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user