create-tinybase 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/cli.js +2 -2
  2. package/package.json +3 -2
  3. package/screenshots/chat.png +0 -0
  4. package/screenshots/drawing.png +0 -0
  5. package/screenshots/game.png +0 -0
  6. package/screenshots/todos.png +0 -0
  7. package/templates/README.md.hbs +18 -19
  8. package/templates/client/.npmrc.hbs +1 -0
  9. package/templates/client/index.html.hbs +46 -9
  10. package/templates/client/package.json.hbs +28 -19
  11. package/templates/client/public/browser.svg +81 -0
  12. package/templates/client/public/js.svg +5 -0
  13. package/templates/client/public/pglite.svg +8 -0
  14. package/templates/client/public/react.svg +9 -0
  15. package/templates/client/public/sqlite.svg +58 -0
  16. package/templates/client/public/svelte.svg +23 -0
  17. package/templates/client/public/sync.svg +4 -0
  18. package/templates/client/public/ts.svg +6 -0
  19. package/templates/client/src/chat/App.svelte.hbs +31 -0
  20. package/templates/client/src/chat/Message.svelte.hbs +17 -0
  21. package/templates/client/src/chat/MessageInput.svelte.hbs +53 -0
  22. package/templates/client/src/chat/Messages.svelte.hbs +34 -0
  23. package/templates/client/src/chat/UsernameInput.svelte.hbs +45 -0
  24. package/templates/client/src/drawing/App.svelte.hbs +28 -0
  25. package/templates/client/src/drawing/BrushSize.svelte.hbs +45 -0
  26. package/templates/client/src/drawing/Canvas.svelte.hbs +145 -0
  27. package/templates/client/src/drawing/ColorPicker.svelte.hbs +39 -0
  28. package/templates/client/src/drawing/DrawingControls.svelte.hbs +22 -0
  29. package/templates/client/src/game/App.svelte.hbs +23 -0
  30. package/templates/client/src/game/Board.svelte.hbs +71 -0
  31. package/templates/client/src/game/Game.svelte.hbs +64 -0
  32. package/templates/client/src/game/GameStatus.svelte.hbs +37 -0
  33. package/templates/client/src/game/Square.svelte.hbs +25 -0
  34. package/templates/client/src/index.tsx.hbs +16 -5
  35. package/templates/client/src/shared/Loading.svelte.hbs +7 -0
  36. package/templates/client/src/shared/sqlite.ts.hbs +5 -2
  37. package/templates/client/src/todos/App.svelte.hbs +26 -0
  38. package/templates/client/src/todos/TodoInput.svelte.hbs +45 -0
  39. package/templates/client/src/todos/TodoItem.svelte.hbs +47 -0
  40. package/templates/client/src/todos/TodoList.svelte.hbs +29 -0
  41. package/templates/client/tsconfig.json.hbs +7 -1
  42. package/templates/client/vite-env.d.ts.hbs +11 -1
  43. package/templates/client/vite.config.js.hbs +7 -1
  44. package/templates/server/package.json.hbs +3 -3
@@ -0,0 +1,7 @@
1
+ <script>
2
+ import './loading.css';
3
+ </script>
4
+
5
+ {{includeFile template="client/src/shared/loading.css.hbs" output="client/src/loading.css"}}
6
+
7
+ <div id="loading"></div>
@@ -2,10 +2,13 @@
2
2
 
3
3
  let sqlite3Promise: Promise<Sqlite3Static> | null = null;
4
4
  let db: Database | null = null;
5
+ const initSqlite = sqlite3InitModule as (config?: {
6
+ locateFile?: () => string;
7
+ }) => Promise<Sqlite3Static>;
5
8
 
6
9
  export const getDb = async () => {
7
10
  if (!sqlite3Promise) {
8
- sqlite3Promise = sqlite3InitModule({
11
+ sqlite3Promise = initSqlite({
9
12
  locateFile: () => '/sqlite3.wasm',
10
13
  });
11
14
  }
@@ -14,4 +17,4 @@ let sqlite3Promise: Promise<Sqlite3Static> | null = null;
14
17
  db = new sqlite3.oo1.DB('file:local?vfs=kvvfs', 'c');
15
18
  }
16
19
  return {sqlite3: await sqlite3Promise, db};
17
- };
20
+ };
@@ -0,0 +1,26 @@
1
+ {{includeFile template="client/src/todos/store.ts.hbs" output="client/src/store.ts"}}
2
+ {{includeFile template="client/src/shared/Loading.svelte.hbs" output="client/src/Loading.svelte"}}
3
+ {{includeFile template="client/src/todos/TodoInput.svelte.hbs" output="client/src/TodoInput.svelte"}}
4
+ {{includeFile template="client/src/todos/TodoList.svelte.hbs" output="client/src/TodoList.svelte"}}
5
+
6
+ <script{{#if typescript}} lang="ts"{{/if}}>
7
+ import {onMount} from 'svelte';
8
+ import Loading from './Loading.svelte';
9
+ import TodoInput from './TodoInput.svelte';
10
+ import TodoList from './TodoList.svelte';
11
+ import {storeReady} from './store';
12
+
13
+ let loading = $state(true);
14
+
15
+ onMount(async () => {
16
+ await storeReady;
17
+ loading = false;
18
+ });
19
+ </script>
20
+
21
+ {#if loading}
22
+ <Loading />
23
+ {:else}
24
+ <TodoInput />
25
+ <TodoList />
26
+ {/if}
@@ -0,0 +1,45 @@
1
+ {{includeFile template="client/src/shared/button.css.hbs" output="client/src/button.css"}}
2
+ {{includeFile template="client/src/shared/input.css.hbs" output="client/src/input.css"}}
3
+ {{includeFile template="client/src/todos/todoInput.css.hbs" output="client/src/todoInput.css"}}
4
+
5
+ <script{{#if typescript}} lang="ts"{{/if}}>
6
+ import './button.css';
7
+ import './input.css';
8
+ import './todoInput.css';
9
+ import {onMount} from 'svelte';
10
+ import {store} from './store';
11
+
12
+ let text = $state('');
13
+ let input{{#if typescript}}: HTMLInputElement | undefined{{/if}};
14
+
15
+ const addTodo = () => {
16
+ const trimmedText = text.trim();
17
+ if (trimmedText) {
18
+ store.addRow('todos', {text: trimmedText, completed: false});
19
+ text = '';
20
+ input?.focus();
21
+ }
22
+ };
23
+
24
+ const handleKeyDown = (event{{#if typescript}}: KeyboardEvent{{/if}}) => {
25
+ if (event.key === 'Enter') {
26
+ event.preventDefault();
27
+ addTodo();
28
+ }
29
+ };
30
+
31
+ onMount(() => {
32
+ input?.focus();
33
+ });
34
+ </script>
35
+
36
+ <div id="todoInput">
37
+ <input
38
+ bind:this={input}
39
+ bind:value={text}
40
+ type="text"
41
+ placeholder="What needs to be done?"
42
+ onkeydown={handleKeyDown}
43
+ />
44
+ <button class="primary" onclick={addTodo}>Add</button>
45
+ </div>
@@ -0,0 +1,47 @@
1
+ {{includeFile template="client/src/shared/button.css.hbs" output="client/src/button.css"}}
2
+ {{includeFile template="client/src/todos/todoItem.css.hbs" output="client/src/todoItem.css"}}
3
+
4
+ <script{{#if typescript}} lang="ts"{{/if}}>
5
+ import './button.css';
6
+ import './todoItem.css';
7
+ import {useRow} from 'tinybase/ui-svelte';
8
+ import {store} from './store';
9
+ {{#if typescript}}
10
+ {{#if schemas}}
11
+ import type {Store as TinyBaseStore} from 'tinybase';
12
+ {{/if}}
13
+ import type {TodoRow} from './store';
14
+ {{/if}}
15
+
16
+ let {rowId}{{#if typescript}}: {rowId: string}{{/if}} = $props();
17
+
18
+ const todo = useRow(
19
+ 'todos',
20
+ () => rowId,
21
+ {{#if schemas}}store as unknown as TinyBaseStore{{else}}store{{/if}},
22
+ ){{#if typescript}} as {readonly current: TodoRow}{{/if}};
23
+
24
+ const toggleTodo = (event{{#if typescript}}: Event{{/if}}) => {
25
+ {{#if typescript}}
26
+ const input = event.currentTarget as HTMLInputElement;
27
+ store.setPartialRow('todos', rowId, {completed: input.checked});
28
+ {{else}}
29
+ store.setPartialRow('todos', rowId, {completed: event.currentTarget.checked});
30
+ {{/if}}
31
+ };
32
+
33
+ const deleteTodo = () => {
34
+ store.delRow('todos', rowId);
35
+ };
36
+ </script>
37
+
38
+ <div class="todoItem" class:completed={todo.current.completed}>
39
+ <input
40
+ id={`todo-${rowId}`}
41
+ type="checkbox"
42
+ checked={todo.current.completed}
43
+ onchange={toggleTodo}
44
+ />
45
+ <label for={`todo-${rowId}`}>{todo.current.text}</label>
46
+ <button onclick={deleteTodo}>Delete</button>
47
+ </div>
@@ -0,0 +1,29 @@
1
+ {{includeFile template="client/src/todos/todoList.css.hbs" output="client/src/todoList.css"}}
2
+ {{includeFile template="client/src/todos/TodoItem.svelte.hbs" output="client/src/TodoItem.svelte"}}
3
+
4
+ <script{{#if typescript}} lang="ts"{{/if}}>
5
+ import './todoList.css';
6
+ import {useSortedRowIds} from 'tinybase/ui-svelte';
7
+ import TodoItem from './TodoItem.svelte';
8
+ import {store} from './store';
9
+ {{#if schemas}}
10
+ {{#if typescript}}
11
+ import type {Store as TinyBaseStore} from 'tinybase';
12
+ {{/if}}
13
+ {{/if}}
14
+
15
+ const todoIds = useSortedRowIds(
16
+ 'todos',
17
+ undefined,
18
+ false,
19
+ 0,
20
+ undefined,
21
+ {{#if schemas}}store as unknown as TinyBaseStore{{else}}store{{/if}},
22
+ );
23
+ </script>
24
+
25
+ <div id="todoList">
26
+ {#each todoIds.current as rowId (rowId)}
27
+ <TodoItem {rowId} />
28
+ {/each}
29
+ </div>
@@ -1,4 +1,7 @@
1
1
  {
2
+ {{#if svelte}}
3
+ "extends": "@tsconfig/svelte/tsconfig.json",
4
+ {{/if}}
2
5
  "compilerOptions": {
3
6
  "target": "ES2020",
4
7
  "useDefineForClassFields": true,
@@ -8,6 +11,9 @@
8
11
  "moduleResolution": "bundler",
9
12
  "allowImportingTsExtensions": true,
10
13
  "isolatedModules": true,
14
+ {{#if svelte}}
15
+ "verbatimModuleSyntax": true,
16
+ {{/if}}
11
17
  "moduleDetection": "force",
12
18
  "noEmit": true,
13
19
  {{#if react}}
@@ -20,4 +26,4 @@
20
26
  "noUncheckedSideEffectImports": true
21
27
  },
22
28
  "include": ["src"]
23
- }
29
+ }
@@ -1,4 +1,14 @@
1
+ {{#if svelte}}
2
+ /// <reference types="vite/client" />
3
+
4
+ declare module '*.svelte' {
5
+ import type {Component} from 'svelte';
6
+ const component: Component<Record<string, never>>;
7
+ export default component;
8
+ }
9
+
10
+ {{/if}}
1
11
  declare module '*.css' {
2
12
  const content: string;
3
13
  export default content;
4
- }
14
+ }
@@ -2,6 +2,9 @@
2
2
  {{#if react}}
3
3
  {{addImport "import react from '@vitejs/plugin-react';"}}
4
4
  {{/if}}
5
+ {{#if svelte}}
6
+ {{addImport "import {svelte} from '@sveltejs/vite-plugin-svelte';"}}
7
+ {{/if}}
5
8
  {{#if persistSqlite}}
6
9
  {{addImport "import {viteStaticCopy} from 'vite-plugin-static-copy';"}}
7
10
  {{/if}}
@@ -16,6 +19,9 @@ plugins: [
16
19
  jsxRuntime: 'automatic',
17
20
  }),
18
21
  {{/if}}
22
+ {{#if svelte}}
23
+ svelte(),
24
+ {{/if}}
19
25
  {{#if persistSqlite}}
20
26
  viteStaticCopy({
21
27
  targets: [
@@ -59,4 +65,4 @@ plugins: [
59
65
  exclude: ['@electric-sql/pglite'],
60
66
  },
61
67
  {{/if}}
62
- });
68
+ });
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  {{#list}}
25
- "tinybase": "^8.0.0"
25
+ "tinybase": "^8.0.2"
26
26
  {{#if (eq serverType "node")}}
27
27
  "ws": "^8.19.0"
28
28
  {{/if}}
@@ -33,7 +33,7 @@
33
33
  {{#if (eq serverType "node")}}
34
34
  "@types/ws": "^8.18.1"
35
35
  {{else}}
36
- "@cloudflare/workers-types": "^4.20260307.1"
36
+ "@cloudflare/workers-types": "^4.20260317.1"
37
37
  {{/if}}
38
38
  {{#if typescript}}
39
39
  "typescript": "^5.9.3"
@@ -42,7 +42,7 @@
42
42
  {{/if}}
43
43
  {{/if}}
44
44
  {{#if (eq serverType "durable-objects")}}
45
- "wrangler": "^4.71.0"
45
+ "wrangler": "^4.75.0"
46
46
  {{/if}}
47
47
  {{/list}}
48
48
  }