-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Lint script * modernize: pnpm & prettier (#51) * Push * Push * Run prettier * Prettier stuff * modernize: Remove Husky & pre-commit (#53) * modernize: tsup (#54) * Push * jest * modernize: jest to vitest (#55) * modernize: pnpm workspace (#56) * Monorepo * Readme * Move tsconfig * Fix test * modernize: CRA -> Vite apps (#57) * Quickstart * test app too * Run pnpm * Remove eslint files * Format * modernize: ES2017 classes (#58) * modernize: in-house EventEmitter (#64) * Push * Undo min change * modernize: undici for WebSocket in Node (#59) * Use undici, remove other unneeded dependencies * pnpm install * Bundle everything * Move everything to devDependency * headers object * Bump version to 0.11.0 * Push * Hmm not working still * Add undici to peerDependencies * Measure size * Push * Fix formatting * Working on node!! --------- Co-authored-by: Zeke Foppa <github.com/bfops> Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com> * modernize: Single output (#68) * modernize: quickstart, move server into client (#69) * Push * Run pnpm install * modernize: Engines field (#70) * modernize: Continuous Releases (#71) * Add pkg.pr.new * Fix directory * modernize: Changesets;provenance (#72) * Push * Push * pnpm install * Any update * modernize: Split lint and test GH actions (#73) * Push * Forgot to rename * We only care about Lint at commit level * modernize: pkg.pr.new compact mode (#75) * modernize: tweak prettier configuration (#74) * docs: Undici as peerDependency * modernize: webpackIgnore undici (#77) * Push * Webpackignore * modernize: Conditional browser build (#79) * Push * Remove webpackIgnore * fix: Remove obsolete comment * modernize: isolatedDeclarations;de-cyclic imports (#81) * Push * Fix test --------- Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
- Loading branch information
Showing
185 changed files
with
8,307 additions
and
71,508 deletions.
There are no files selected for viewing
This file contains 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,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains 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,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/config@3.0.2/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains 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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
## Description of Changes | ||
*Describe what has been changed, any new features or bug fixes* | ||
|
||
## API | ||
_Describe what has been changed, any new features or bug fixes_ | ||
|
||
- [ ] This is an API breaking change to the SDK | ||
## API | ||
|
||
*If the API is breaking, please state below what will break* | ||
- [ ] This is an API breaking change to the SDK | ||
|
||
_If the API is breaking, please state below what will break_ | ||
|
||
## Requires SpacetimeDB PRs | ||
*List any PRs here that are required for this SDK change to work* | ||
|
||
_List any PRs here that are required for this SDK change to work_ |
This file contains 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,24 @@ | ||
name: Continuous Releases | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9.7 | ||
run_install: true | ||
|
||
- name: Compile | ||
run: pnpm compile | ||
|
||
- name: Release | ||
run: cd packages/sdk && pnpm dlx pkg-pr-new publish --compact |
This file contains 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,38 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9.7 | ||
run_install: true | ||
|
||
- name: Get pnpm store directory | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
- uses: actions/cache@v4 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Lint | ||
run: pnpm lint |
This file contains 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,40 @@ | ||
name: Publish | ||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
contents: write | ||
packages: write | ||
pull-requests: write | ||
issues: read | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18.x | ||
cache: 'pnpm' | ||
|
||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9.7 | ||
run_install: true | ||
|
||
- run: pnpm compile | ||
|
||
- name: Create Release Pull Request or Publish | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
publish: pnpm run ci:release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules/ | ||
.envrc | ||
dist/ | ||
.DS_Store |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
tests | ||
jest.config.js | ||
.envrc | ||
node_modules |
This file contains 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,5 @@ | ||
node_modules | ||
pnpm-lock.yaml | ||
dist | ||
target | ||
module_bindings |
This file contains 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,11 @@ | ||
{ | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"arrowParens": "avoid", | ||
"jsxSingleQuote": false, | ||
"trailingComma": "es5", | ||
"endOfLine": "auto", | ||
"printWidth": 80 | ||
} |
This file contains 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 |
---|---|---|
@@ -1,77 +1,3 @@ | ||
## SpacetimeDB SDK | ||
`@clockworklabs/spacetimedb-sdk` is a TypeScript SDK for SpacetimeDB. | ||
|
||
### Overview | ||
|
||
This repository contains the TypeScript SDK for SpacetimeDB. The SDK allows to interact with the database server and is prepared to work with code generated from a SpacetimeDB backend code. | ||
|
||
### Installation | ||
|
||
The SDK is an NPM package, thus you can use your package manager of choice like NPM or Yarn, for example: | ||
|
||
``` | ||
npm install --save @clockworklabs/spacetimedb-sdk | ||
``` | ||
|
||
You can use the package in the browser, using a bundler like webpack of vite, and in terminal applications | ||
|
||
### Usage | ||
|
||
In order to connect to a database you have to create a new client: | ||
|
||
```ts | ||
import { SpacetimeDBClient } from "@clockworklabs/spacetimedb-sdk"; | ||
|
||
let client = new SpacetimeDBClient("spacetimedb.com/spacetimedb", "<db-name>"); | ||
``` | ||
|
||
If you would like to connect to the client you can call the below method. This also takes optional parameters to override the host or credentials: | ||
|
||
```ts | ||
client.connect(); | ||
``` | ||
|
||
If for some reason you need to disconnect the client: | ||
|
||
```ts | ||
client.disconnect(); | ||
``` | ||
|
||
This will connect to a database instance without a specified identity. If you want to persist an identity fetched on connection you can register an `onConnect` callback, which will receive a new assigned identity as an argument: | ||
|
||
```ts | ||
client.onConnect((identity: string) => { | ||
console.log(identity); | ||
console.log(client.token); | ||
}); | ||
``` | ||
|
||
You may also pass credentials as an optional third argument: | ||
|
||
```ts | ||
let credentials = { identity: "<identity>", token: "<token>" }; | ||
let client = new SpacetimeDBClient( | ||
"spacetimedb.com/spacetimedb", | ||
"<db-name>", | ||
credentials | ||
); | ||
``` | ||
|
||
Typically, you will use the SDK with types generated from a backend DB service. For example, given a component named `Player` you can subscribe to player updates by registering the component: | ||
|
||
```ts | ||
client.registerComponent(Player, "Player"); | ||
``` | ||
|
||
Then you will be able to register callbacks on insert and delete events, for example: | ||
|
||
```ts | ||
Player.onInsert((newPlayer: Player) => { | ||
console.log(newPlayer); | ||
}); | ||
``` | ||
|
||
Given a reducer called `CreatePlayer` you can call it using a call method: | ||
|
||
```ts | ||
CreatePlayer.call("Nickname"); | ||
``` | ||
Source code can be found here on [GitHub](https://github.com/clockworklabs/spacetimedb-typescript-sdk/blob/main/packages/sdk). |
This file contains 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,27 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
server | ||
module_bindings |
This file contains 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,8 @@ | ||
# React + TypeScript + Vite | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.