@enbox/create-dapp 0.0.6 → 0.0.8
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.
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ interactive terminal; scripts must provide it explicitly.
|
|
|
33
33
|
The directory's basename becomes the display name in `src/app.json`. Its
|
|
34
34
|
normalized lowercase npm name becomes both the package name and the stable
|
|
35
35
|
`app.json` ID. The ID identifies
|
|
36
|
-
the app to the wallet and defines its private demo
|
|
36
|
+
the app to the wallet and defines its private demo module namespace. Keep
|
|
37
37
|
the ID when changing the display name so saved data remains in the same
|
|
38
38
|
namespace. Source code is copied unchanged. Run `--help` for usage or
|
|
39
39
|
`--version` for the generator version.
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -55,7 +55,7 @@ src/
|
|
|
55
55
|
application.ts # features, wallet identity, and one application owner
|
|
56
56
|
App.tsx # connection shell and feature composition
|
|
57
57
|
features/tasks/
|
|
58
|
-
|
|
58
|
+
module.ts # typed encrypted records and validation
|
|
59
59
|
store.ts # shared observations, commands, and domain defaults
|
|
60
60
|
components/ # task board and its styles
|
|
61
61
|
components/ # reusable UI shared by features
|
|
@@ -64,13 +64,13 @@ src/
|
|
|
64
64
|
sw.ts
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
`createApplication` derives the
|
|
67
|
+
`createApplication` derives the module manifest from registered stores and
|
|
68
68
|
constructs the browser connection with the configured wallet identity.
|
|
69
69
|
`getApplication()` keeps one headless runtime for the page lifetime.
|
|
70
70
|
`main.tsx` waits for worker control before passing that runtime to
|
|
71
71
|
`EnboxProvider application={...}`. The provider initializes the borrowed runtime;
|
|
72
72
|
the application owns its page lifetime. Component Fast Refresh is useful for UI
|
|
73
|
-
edits, but replacing a connected runtime or its store/
|
|
73
|
+
edits, but replacing a connected runtime or its store/module definitions is
|
|
74
74
|
not a supported hot-reload operation. Disconnect before changing those files,
|
|
75
75
|
then reload the page. Apps with document writers, such as Notesd, drain edits
|
|
76
76
|
as part of disconnecting.
|
|
@@ -83,7 +83,7 @@ the expanded details still show which name is publicly published.
|
|
|
83
83
|
|
|
84
84
|
The replaceable task feature lives in `src/features/tasks`:
|
|
85
85
|
|
|
86
|
-
- `
|
|
86
|
+
- `module.ts` declares encrypted `project` and `project/task` records with
|
|
87
87
|
payload validators. Tasks store a title and completion state.
|
|
88
88
|
- `store.ts` declares one shared project collection and a task collection scoped
|
|
89
89
|
with `tasks.within(projectContextId)`. Its `activeTasks` observation keeps
|
|
@@ -123,13 +123,13 @@ commands remain on canonical `tasks.within(parentContextId)` handles.
|
|
|
123
123
|
|
|
124
124
|
To replace the task feature, register your own store in `app/application.ts`,
|
|
125
125
|
delete `src/features/tasks`, and change the feature rendered by `app/App.tsx`.
|
|
126
|
-
Enbox requires at least one application
|
|
126
|
+
Enbox requires at least one application module, so keep your replacement
|
|
127
127
|
registered. The profile card, connection shell, and service worker remain the
|
|
128
128
|
base for your app.
|
|
129
129
|
|
|
130
|
-
The demo's default
|
|
130
|
+
The demo's default module URI is
|
|
131
131
|
`https://example.com/<encoded app ID>/demo/v2`. Replace the URI expression in
|
|
132
|
-
`src/features/tasks/
|
|
132
|
+
`src/features/tasks/module.ts` with a stable URI
|
|
133
133
|
you control before publishing. This URI identifies saved records and wallet
|
|
134
134
|
grants: changing it creates a different data namespace. Once deployed, keep
|
|
135
135
|
that identifier fixed when changing the app's display name.
|
package/template/package.json
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineModule, recordCodecs } from '@enbox/browser';
|
|
2
|
+
|
|
3
|
+
import app from '../../app.json' with { type: 'json' };
|
|
4
|
+
|
|
5
|
+
export type Project = { name: string };
|
|
6
|
+
export type Task = { title: string; completed: boolean };
|
|
7
|
+
|
|
8
|
+
// Replace this example URI with one you own before publishing your app.
|
|
9
|
+
// Keep it stable after launch: it identifies the app's saved data and grants.
|
|
10
|
+
export const TaskBoardModule = defineModule({
|
|
11
|
+
definition: {
|
|
12
|
+
module: `https://example.com/${encodeURIComponent(app.id)}/demo/v2`,
|
|
13
|
+
published: false,
|
|
14
|
+
types: {
|
|
15
|
+
project: { dataFormats: ['application/json'], encryptionRequired: true },
|
|
16
|
+
task: { dataFormats: ['application/json'], encryptionRequired: true },
|
|
17
|
+
},
|
|
18
|
+
structure: { project: { task: {} } },
|
|
19
|
+
} as const,
|
|
20
|
+
codecs: {
|
|
21
|
+
project: recordCodecs.json<Project>({ validator: (value: unknown) =>
|
|
22
|
+
value !== null && typeof value === 'object' && !Array.isArray(value) && 'name' in value
|
|
23
|
+
&& typeof value.name === 'string' && value.name.trim().length > 0 && value.name.length <= 60 }),
|
|
24
|
+
task: recordCodecs.json<Task>({ validator: (value: unknown) =>
|
|
25
|
+
value !== null && typeof value === 'object' && !Array.isArray(value) && 'title' in value && 'completed' in value
|
|
26
|
+
&& typeof value.title === 'string' && value.title.trim().length > 0 && value.title.length <= 120
|
|
27
|
+
&& typeof value.completed === 'boolean' }),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { DateSort, defineStore } from '@enbox/browser';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { TaskBoardModule } from './module.js';
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/** Module observations and domain defaults are shared with every consumer. */
|
|
6
6
|
export const TaskBoardStore = defineStore({
|
|
7
|
-
|
|
8
|
-
create({
|
|
9
|
-
const projects =
|
|
10
|
-
const tasks =
|
|
7
|
+
modules: { board: TaskBoardModule },
|
|
8
|
+
create({ modules, observe }) {
|
|
9
|
+
const projects = modules.board.collection('project', { dateSort: DateSort.CreatedDescending });
|
|
10
|
+
const tasks = modules.board.collection('project/task');
|
|
11
11
|
const activeTasks = observe({ source: (parent: string) => tasks.within(parent) });
|
|
12
|
-
const taskById = (within: string, recordId: string) =>
|
|
12
|
+
const taskById = (within: string, recordId: string) => modules.board.collection('project/task', {
|
|
13
13
|
filter: { recordId }, pagination: { limit: 1 },
|
|
14
14
|
}).within(within);
|
|
15
15
|
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { defineProtocol, recordCodecs } from '@enbox/browser';
|
|
2
|
-
|
|
3
|
-
import app from '../../app.json' with { type: 'json' };
|
|
4
|
-
|
|
5
|
-
export type Project = { name: string };
|
|
6
|
-
export type Task = { title: string; completed: boolean };
|
|
7
|
-
|
|
8
|
-
// Replace this example URI with one you own before publishing your app.
|
|
9
|
-
// Keep it stable after launch: it identifies the app's saved data and grants.
|
|
10
|
-
export const TaskBoardProtocol = defineProtocol({
|
|
11
|
-
protocol: `https://example.com/${encodeURIComponent(app.id)}/demo/v2`,
|
|
12
|
-
published: false,
|
|
13
|
-
types: {
|
|
14
|
-
project: { dataFormats: ['application/json'], encryptionRequired: true },
|
|
15
|
-
task: { dataFormats: ['application/json'], encryptionRequired: true },
|
|
16
|
-
},
|
|
17
|
-
structure: { project: { task: {} } },
|
|
18
|
-
} as const, {
|
|
19
|
-
project: recordCodecs.json<Project>({ validator: (value: unknown) =>
|
|
20
|
-
value !== null && typeof value === 'object' && !Array.isArray(value) && 'name' in value
|
|
21
|
-
&& typeof value.name === 'string' && value.name.trim().length > 0 && value.name.length <= 60 }),
|
|
22
|
-
task: recordCodecs.json<Task>({ validator: (value: unknown) =>
|
|
23
|
-
value !== null && typeof value === 'object' && !Array.isArray(value) && 'title' in value && 'completed' in value
|
|
24
|
-
&& typeof value.title === 'string' && value.title.trim().length > 0 && value.title.length <= 120
|
|
25
|
-
&& typeof value.completed === 'boolean' }),
|
|
26
|
-
});
|