@monimesl/dot-cli 0.1.0-alpha.2 → 0.1.0-alpha.3

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 (46) hide show
  1. package/dist/cli.js +151 -35
  2. package/dist/cli.js.map +1 -1
  3. package/dist/server-z7M4FLjf.js +10886 -0
  4. package/dist/server-z7M4FLjf.js.map +1 -0
  5. package/dist/template/.env +3 -3
  6. package/dist/template/dot.ts +14 -1
  7. package/dist/template/pages/device/controller.ts +70 -0
  8. package/dist/template/pages/device/state.ts +7 -0
  9. package/dist/template/pages/device/view.dml +44 -0
  10. package/dist/template/pages/feedback/controller.ts +16 -0
  11. package/dist/template/pages/feedback/state.ts +7 -0
  12. package/dist/template/pages/feedback/view.dml +87 -0
  13. package/dist/template/pages/files/controller.ts +47 -0
  14. package/dist/template/pages/files/state.ts +11 -0
  15. package/dist/template/pages/files/view.dml +35 -0
  16. package/dist/template/pages/forms/controller.ts +44 -0
  17. package/dist/template/pages/forms/state.ts +15 -0
  18. package/dist/template/pages/forms/view.dml +39 -0
  19. package/dist/template/pages/images/controller.ts +15 -0
  20. package/dist/template/pages/images/state.ts +7 -0
  21. package/dist/template/pages/images/view.dml +38 -0
  22. package/dist/template/pages/index/controller.ts +2 -59
  23. package/dist/template/pages/index/state.ts +93 -12
  24. package/dist/template/pages/index/view.dml +17 -63
  25. package/dist/template/pages/layout/controller.ts +23 -0
  26. package/dist/template/pages/layout/state.ts +12 -0
  27. package/dist/template/pages/layout/view.dml +63 -0
  28. package/dist/template/pages/lists/controller.ts +36 -0
  29. package/dist/template/pages/lists/state.ts +96 -0
  30. package/dist/template/pages/lists/view.dml +59 -0
  31. package/dist/template/pages/navigation/controller.ts +42 -0
  32. package/dist/template/pages/navigation/state.ts +13 -0
  33. package/dist/template/pages/navigation/view.dml +24 -0
  34. package/dist/template/pages/network/controller.ts +107 -0
  35. package/dist/template/pages/network/state.ts +15 -0
  36. package/dist/template/pages/network/view.dml +56 -0
  37. package/dist/template/pages/state/controller.ts +22 -0
  38. package/dist/template/pages/state/state.ts +10 -0
  39. package/dist/template/pages/state/view.dml +33 -0
  40. package/dist/template/pages/text/controller.ts +10 -0
  41. package/dist/template/pages/text/state.ts +7 -0
  42. package/dist/template/pages/text/view.dml +49 -0
  43. package/package.json +10 -6
  44. package/dist/template/pages/help/tips/controller.ts +0 -30
  45. package/dist/template/pages/help/tips/state.ts +0 -11
  46. package/dist/template/pages/help/tips/view.dml +0 -15
@@ -0,0 +1,15 @@
1
+ export interface Profile {
2
+ login: string;
3
+ name: string;
4
+ followers: number;
5
+ }
6
+
7
+ export default {
8
+ zen: '',
9
+ profile: null as Profile | null,
10
+ echo: '',
11
+ picture: { id: '', url: '', size: 0 },
12
+ uploaded: '',
13
+ kept: false,
14
+ note: '',
15
+ };
@@ -0,0 +1,56 @@
1
+ <View>
2
+ <Text variant="title">Network</Text>
3
+ <Text>Dash sends a dot's requests, and only to the hosts its dot.json lists.</Text>
4
+
5
+ <Text variant="caption" tone="muted">A request, read as text</Text>
6
+ <View variant="card" gap="small">
7
+ <Button variant="secondary" onClick="fetchZen">Ask GitHub for wisdom</Button>
8
+ <If condition="{{ zen }}">
9
+ <Text>"{{ zen }}"</Text>
10
+ </If>
11
+ </View>
12
+
13
+ <Text variant="caption" tone="muted">JSON, parsed with as: 'json'</Text>
14
+ <View variant="card" gap="small">
15
+ <View direction="row" wrap gap="small">
16
+ <Button variant="secondary" onClick="fetchProfile">Load a profile</Button>
17
+ <Button variant="secondary" onClick="sendJson">Send JSON</Button>
18
+ </View>
19
+ <If condition="{{ profile }}">
20
+ <Text>{{ profile.name }} (@{{ profile.login }}) has {{ profile.followers }} followers</Text>
21
+ </If>
22
+ <If condition="{{ echo }}">
23
+ <Text>httpbin got {{ echo }}</Text>
24
+ </If>
25
+ </View>
26
+
27
+ <Text variant="caption" tone="muted">Files: download, upload and keep</Text>
28
+ <View variant="card" gap="small">
29
+ <View direction="row" wrap gap="small">
30
+ <Button variant="secondary" onClick="download">Download</Button>
31
+ <Button variant="secondary" onClick="upload" disabled="{{ !picture.id }}">Upload</Button>
32
+ <Button variant="secondary" onClick="sharePicture" disabled="{{ !picture.id }}">Share</Button>
33
+ <Button variant="secondary" onClick="keep" disabled="{{ !picture.id || kept }}">Keep</Button>
34
+ </View>
35
+ <If condition="{{ picture.url }}">
36
+ <View direction="row" align="center" gap="medium">
37
+ <Image src="{{ picture.url }}" alt="Octocat" width="64" height="64" />
38
+ <Text variant="caption" tone="muted">{{ picture.size }} bytes, in a temporary file until the dot closes</Text>
39
+ </View>
40
+ </If>
41
+ <If condition="{{ uploaded }}">
42
+ <Text>httpbin got the file field "{{ uploaded }}"</Text>
43
+ </If>
44
+ <If condition="{{ kept }}">
45
+ <Text>Kept in the dot's own files: see the Files page</Text>
46
+ </If>
47
+ </View>
48
+
49
+ <Text variant="caption" tone="muted">A host dot.json doesn't list</Text>
50
+ <View variant="card" gap="small">
51
+ <Button variant="secondary" onClick="tryUnlistedHost">Reach example.com</Button>
52
+ <If condition="{{ note }}">
53
+ <Text variant="caption" tone="muted">{{ note }}</Text>
54
+ </If>
55
+ </View>
56
+ </View>
@@ -0,0 +1,22 @@
1
+ import state from './state';
2
+
3
+ export default definePage({
4
+ initialState: state,
5
+ mutations: {
6
+ increment: (state) => {
7
+ const count = state.count + 1;
8
+ return { count, taps: [{ id: count }, ...state.taps] };
9
+ },
10
+ reset: () => ({ count: 0, taps: [] }),
11
+ },
12
+ actions: {
13
+ fillUp() {
14
+ while (this.state.count < this.state.limit) {
15
+ this.mutations.increment();
16
+ }
17
+ },
18
+ undo() {
19
+ this.setState((current) => ({ count: current.count - 1, taps: current.taps.slice(1) }));
20
+ },
21
+ },
22
+ });
@@ -0,0 +1,10 @@
1
+ export interface Tap {
2
+ id: number;
3
+ }
4
+
5
+ export default {
6
+ title: 'taps',
7
+ count: 0,
8
+ limit: 5,
9
+ taps: [] as Tap[],
10
+ };
@@ -0,0 +1,33 @@
1
+ <View>
2
+ <Text variant="title">State, mutations and actions</Text>
3
+ <Text>The page's state lives in the controller. A mutation turns an event into new state; an action can run several, or wait for Dash.</Text>
4
+
5
+ <View variant="card" gap="small">
6
+ <Text variant="title">{{ count }} of {{ limit }} {{ title }}</Text>
7
+ <If condition="{{ count >= limit }}">
8
+ <Text>That's the limit</Text>
9
+ </If>
10
+ <ElseIf condition="{{ count > 0 }}">
11
+ <Text>{{ limit - count }} to go</Text>
12
+ </ElseIf>
13
+ <Else>
14
+ <Text>Tap Add one to start</Text>
15
+ </Else>
16
+ <View direction="row" wrap gap="small">
17
+ <Button onClick="increment" disabled="{{ count >= limit }}">Add one</Button>
18
+ <Button variant="secondary" onClick="fillUp" disabled="{{ count >= limit }}">Fill up</Button>
19
+ <Button variant="secondary" onClick="undo" disabled="{{ count === 0 }}">Undo</Button>
20
+ <Button variant="secondary" onClick="reset" disabled="{{ count === 0 }}">Reset</Button>
21
+ </View>
22
+ </View>
23
+
24
+ <Text variant="caption" tone="muted">Each tap, newest first</Text>
25
+ <View variant="card" gap="small">
26
+ <For each="{{ taps }}" index="position" item="tap" key="id">
27
+ <Text>{{ position + 1 }}. Tap #{{ tap.id }}</Text>
28
+ </For>
29
+ <If condition="{{ taps.length === 0 }}">
30
+ <Text variant="caption" tone="muted">No taps yet</Text>
31
+ </If>
32
+ </View>
33
+ </View>
@@ -0,0 +1,10 @@
1
+ import state from './state';
2
+
3
+ export default definePage({
4
+ initialState: state,
5
+ mutations: {
6
+ addOne: (state) => ({ quantity: state.quantity + 1 }),
7
+ removeOne: (state) => ({ quantity: Math.max(0, state.quantity - 1) }),
8
+ toggleNickname: (state) => ({ nickname: state.nickname === null ? 'Countess' : null }),
9
+ },
10
+ });
@@ -0,0 +1,7 @@
1
+ export default {
2
+ name: 'Ada',
3
+ nickname: null as string | null,
4
+ price: 2.5,
5
+ quantity: 4,
6
+ tags: ['fast', 'small', 'typed'],
7
+ };
@@ -0,0 +1,49 @@
1
+ <View>
2
+ <Text variant="title">Text and bindings</Text>
3
+
4
+ <View variant="card" gap="small">
5
+ <Text variant="title">A title</Text>
6
+ <Text>Body text, the default</Text>
7
+ <Text variant="caption" tone="muted">A caption</Text>
8
+ <Text>Text can hold{{ ' ' }}<Text variant="title">bigger</Text>{{ ' ' }}and{{ ' ' }}<Text variant="caption" tone="muted">smaller</Text>{{ ' ' }}words.</Text>
9
+ </View>
10
+
11
+ <Text variant="caption" tone="muted">Tones, weights and alignment</Text>
12
+ <View variant="card" gap="small">
13
+ <View direction="row" wrap gap="medium">
14
+ <Text tone="muted">muted</Text>
15
+ <Text tone="info">info</Text>
16
+ <Text tone="success">success</Text>
17
+ <Text tone="warning">warning</Text>
18
+ <Text tone="danger">danger</Text>
19
+ </View>
20
+ <View direction="row" gap="medium">
21
+ <Text weight="regular">regular</Text>
22
+ <Text weight="medium">medium</Text>
23
+ <Text weight="bold">bold</Text>
24
+ </View>
25
+ <Text align="center">In the center</Text>
26
+ <Text align="end">At the end</Text>
27
+ <Text maxLines="2">A long description is cut off after the lines you allow, so a list of them stays tidy however much each one says about itself.</Text>
28
+ </View>
29
+
30
+ <Text variant="caption" tone="muted">Bindings put state into the view</Text>
31
+ <View variant="card" gap="small">
32
+ <Text>Hello, {{ name }}</Text>
33
+ <Text>{{ quantity }} {{ quantity === 1 ? 'item' : 'items' }} at {{ price }} each: {{ quantity * price }}</Text>
34
+ <Text>Nickname: {{ nickname ?? 'none yet' }}</Text>
35
+ <Text>{{ tags.length }} tags, the first is "{{ tags[0] }}"</Text>
36
+ <View direction="row" wrap gap="small">
37
+ <Button variant="secondary" onClick="addOne">Add one</Button>
38
+ <Button variant="secondary" onClick="removeOne" disabled="{{ quantity === 0 }}">Remove one</Button>
39
+ <Button variant="secondary" onClick="toggleNickname">{{ nickname === null ? 'Give a nickname' : 'Drop the nickname' }}</Button>
40
+ </View>
41
+ </View>
42
+
43
+ <Text variant="caption" tone="muted">A list, one line per item</Text>
44
+ <View variant="card" gap="small">
45
+ <For each="{{ tags }}" item="tag" index="position" key="*this">
46
+ <Text>{{ position + 1 }}. {{ tag }}</Text>
47
+ </For>
48
+ </View>
49
+ </View>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monimesl/dot-cli",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "0.1.0-alpha.3",
4
4
  "description": "The dotctl command: build mini apps and run them in the simulator",
5
5
  "type": "module",
6
6
  "repository": {
@@ -22,10 +22,11 @@
22
22
  "./package.json": "./package.json"
23
23
  },
24
24
  "dependencies": {
25
- "@monimesl/dot-dml-parser": "0.1.0-alpha.2",
26
- "@monimesl/dot-script-parser": "0.1.0-alpha.2",
27
- "@monimesl/dot-compiler": "0.1.0-alpha.2",
28
- "@monimesl/dot-simulator": "0.1.0-alpha.2"
25
+ "@monimesl/dot-compiler": "0.1.0-alpha.3",
26
+ "@monimesl/dot-core": "0.1.0-alpha.3",
27
+ "@monimesl/dot-script-parser": "0.1.0-alpha.3",
28
+ "@monimesl/dot-dml-parser": "0.1.0-alpha.3",
29
+ "@monimesl/dot-simulator": "0.1.0-alpha.3"
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/node": "^22.20.4",
@@ -33,7 +34,10 @@
33
34
  "rimraf": "^6.1.3",
34
35
  "tsdown": "^0.23.0",
35
36
  "typescript": "^5.9.3",
36
- "vitest": "^5.0.1"
37
+ "vitest": "^5.0.1",
38
+ "vscode-languageserver": "^9.0.1",
39
+ "vscode-languageserver-protocol": "^3.17.5",
40
+ "vscode-languageserver-textdocument": "^1.0.15"
37
41
  },
38
42
  "publishConfig": {
39
43
  "access": "public"
@@ -1,30 +0,0 @@
1
- import state from './state';
2
-
3
- export default definePage({
4
- initialState: state,
5
- hooks: {
6
- // The page that opens this one passes its own trail and depth.
7
- onLoad(options) {
8
- this.setState({
9
- count: Number(options.count ?? 0),
10
- trail: `${options.trail ?? 'Home'} › Tips`,
11
- depth: Number(options.depth ?? 1) + 1,
12
- });
13
- },
14
- },
15
- actions: {
16
- back() {
17
- this.navigation.back();
18
- },
19
- openAnother(state) {
20
- this.navigation.push('help/tips', {
21
- count: String(state.count),
22
- trail: state.trail,
23
- depth: String(state.depth),
24
- });
25
- },
26
- startOver() {
27
- this.navigation.reset('index');
28
- },
29
- },
30
- });
@@ -1,11 +0,0 @@
1
- export default {
2
- count: 0,
3
- trail: '',
4
- depth: 0,
5
- maxPages: 8,
6
- tips: [
7
- 'Every tap is handled by controller.ts in a Worker',
8
- 'The view only renders the state it receives',
9
- 'Pages open on top of each other; Back returns to the one below',
10
- ],
11
- };
@@ -1,15 +0,0 @@
1
- <Text variant="caption">{{ trail }}</Text>
2
- <Text variant="title">Tips</Text>
3
- <Text>Page {{ depth }} of {{ maxPages }}, opened at {{ count }} taps.</Text>
4
-
5
- <View variant="card" gap="small">
6
- <For each="{{ tips }}" item="tip" key="*this">
7
- <Text>{{ tip }}</Text>
8
- </For>
9
- </View>
10
-
11
- <View direction="row">
12
- <Button onClick="back">Back</Button>
13
- <Button variant="secondary" onClick="openAnother" disabled="{{ depth >= maxPages }}">Open another</Button>
14
- <Button variant="secondary" onClick="startOver">Start over</Button>
15
- </View>