@monimesl/dot-cli 0.1.0-alpha.16 → 0.1.0-alpha.19

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 (109) hide show
  1. package/dist/cli.js +16 -9
  2. package/dist/cli.js.map +1 -1
  3. package/dist/templates/showcase/dot.ts +32 -17
  4. package/dist/templates/showcase/pages/basics/bars/controller.ts +36 -0
  5. package/dist/templates/showcase/pages/basics/bars/state.ts +6 -0
  6. package/dist/templates/showcase/pages/basics/bars/view.dml +28 -0
  7. package/dist/templates/showcase/pages/{text → basics/bindings}/controller.ts +5 -0
  8. package/dist/templates/showcase/pages/basics/bindings/state.ts +14 -0
  9. package/dist/templates/showcase/pages/basics/bindings/view.dml +41 -0
  10. package/dist/templates/showcase/pages/basics/control-flow/controller.ts +18 -0
  11. package/dist/templates/showcase/pages/basics/control-flow/state.ts +16 -0
  12. package/dist/templates/showcase/pages/basics/control-flow/view.dml +55 -0
  13. package/dist/templates/showcase/pages/basics/events/controller.ts +43 -0
  14. package/dist/templates/showcase/pages/basics/events/state.ts +11 -0
  15. package/dist/templates/showcase/pages/basics/events/view.dml +51 -0
  16. package/dist/templates/showcase/pages/basics/hooks/controller.ts +37 -0
  17. package/dist/templates/showcase/pages/basics/hooks/state.ts +10 -0
  18. package/dist/templates/showcase/pages/basics/hooks/view.dml +32 -0
  19. package/dist/templates/showcase/pages/basics/navigation/controller.ts +34 -0
  20. package/dist/templates/showcase/pages/basics/navigation/state.ts +9 -0
  21. package/dist/templates/showcase/pages/basics/navigation/view.dml +37 -0
  22. package/dist/templates/showcase/pages/{state → basics/state}/controller.ts +1 -0
  23. package/dist/templates/showcase/pages/basics/state/view.dml +46 -0
  24. package/dist/templates/showcase/pages/{carousel → components/carousel}/controller.ts +1 -0
  25. package/dist/templates/showcase/pages/{carousel → components/carousel}/view.dml +7 -5
  26. package/dist/templates/showcase/pages/{feedback → components/feedback}/controller.ts +1 -0
  27. package/dist/templates/showcase/pages/{feedback → components/feedback}/view.dml +18 -9
  28. package/dist/templates/showcase/pages/{forms → components/forms}/controller.ts +5 -1
  29. package/dist/templates/showcase/pages/{forms → components/forms}/state.ts +3 -0
  30. package/dist/templates/showcase/pages/components/forms/view.dml +90 -0
  31. package/dist/templates/showcase/pages/components/icons/controller.ts +15 -0
  32. package/dist/templates/showcase/pages/components/icons/state.ts +75 -0
  33. package/dist/templates/showcase/pages/components/icons/view.dml +36 -0
  34. package/dist/templates/showcase/pages/{images → components/images}/controller.ts +1 -0
  35. package/dist/templates/showcase/pages/components/images/view.dml +70 -0
  36. package/dist/templates/showcase/pages/{layout → components/layout}/controller.ts +1 -0
  37. package/dist/templates/showcase/pages/components/layout/view.dml +143 -0
  38. package/dist/templates/showcase/pages/components/lists/controller.ts +18 -0
  39. package/dist/templates/showcase/pages/{lists → components/lists}/state.ts +43 -30
  40. package/dist/templates/showcase/pages/components/lists/view.dml +70 -0
  41. package/dist/templates/showcase/pages/{payments → components/money}/controller.ts +1 -0
  42. package/dist/templates/showcase/pages/{payments → components/money}/view.dml +17 -8
  43. package/dist/templates/showcase/pages/components/reading/controller.ts +6 -0
  44. package/dist/templates/showcase/pages/components/reading/state.ts +23 -0
  45. package/dist/templates/showcase/pages/components/reading/view.dml +42 -0
  46. package/dist/templates/showcase/pages/{lists → components/sheets}/controller.ts +9 -10
  47. package/dist/templates/showcase/pages/components/sheets/state.ts +26 -0
  48. package/dist/templates/showcase/pages/components/sheets/view.dml +38 -0
  49. package/dist/templates/showcase/pages/{styles → components/styles}/controller.ts +1 -0
  50. package/dist/templates/showcase/pages/components/styles/view.dml +101 -0
  51. package/dist/templates/showcase/pages/{filters → components/tabs}/controller.ts +2 -0
  52. package/dist/templates/showcase/pages/{filters → components/tabs}/state.ts +1 -0
  53. package/dist/templates/showcase/pages/components/tabs/view.dml +56 -0
  54. package/dist/templates/showcase/pages/components/text/controller.ts +10 -0
  55. package/dist/templates/showcase/pages/components/text/state.ts +3 -0
  56. package/dist/templates/showcase/pages/components/text/view.dml +95 -0
  57. package/dist/templates/showcase/pages/{cache → dash/cache}/controller.ts +5 -0
  58. package/dist/templates/showcase/pages/dash/cache/view.dml +48 -0
  59. package/dist/templates/showcase/pages/dash/calls/controller.ts +49 -0
  60. package/dist/templates/showcase/pages/dash/calls/state.ts +6 -0
  61. package/dist/templates/showcase/pages/dash/calls/view.dml +51 -0
  62. package/dist/templates/showcase/pages/{files → dash/files}/controller.ts +1 -0
  63. package/dist/templates/showcase/pages/dash/files/view.dml +79 -0
  64. package/dist/templates/showcase/pages/dash/media/controller.ts +33 -0
  65. package/dist/templates/showcase/pages/dash/media/state.ts +8 -0
  66. package/dist/templates/showcase/pages/dash/media/view.dml +34 -0
  67. package/dist/templates/showcase/pages/{network → dash/network}/controller.ts +14 -5
  68. package/dist/templates/showcase/pages/{network → dash/network}/state.ts +4 -1
  69. package/dist/templates/showcase/pages/dash/network/view.dml +80 -0
  70. package/dist/templates/showcase/pages/{secrets → dash/secrets}/controller.ts +1 -0
  71. package/dist/templates/showcase/pages/dash/secrets/view.dml +26 -0
  72. package/dist/templates/showcase/pages/dash/system/controller.ts +62 -0
  73. package/dist/templates/showcase/pages/dash/system/state.ts +9 -0
  74. package/dist/templates/showcase/pages/dash/system/view.dml +59 -0
  75. package/dist/templates/showcase/pages/dash/ui/controller.ts +70 -0
  76. package/dist/templates/showcase/pages/dash/ui/state.ts +8 -0
  77. package/dist/templates/showcase/pages/dash/ui/view.dml +31 -0
  78. package/dist/templates/showcase/pages/index/state.ts +135 -64
  79. package/dist/templates/showcase/pages/index/view.dml +6 -3
  80. package/package.json +6 -6
  81. package/dist/templates/showcase/pages/cache/view.dml +0 -36
  82. package/dist/templates/showcase/pages/device/controller.ts +0 -105
  83. package/dist/templates/showcase/pages/device/state.ts +0 -16
  84. package/dist/templates/showcase/pages/device/view.dml +0 -69
  85. package/dist/templates/showcase/pages/files/view.dml +0 -64
  86. package/dist/templates/showcase/pages/filters/view.dml +0 -44
  87. package/dist/templates/showcase/pages/forms/view.dml +0 -49
  88. package/dist/templates/showcase/pages/images/view.dml +0 -53
  89. package/dist/templates/showcase/pages/layout/view.dml +0 -103
  90. package/dist/templates/showcase/pages/lists/view.dml +0 -59
  91. package/dist/templates/showcase/pages/navigation/controller.ts +0 -65
  92. package/dist/templates/showcase/pages/navigation/state.ts +0 -17
  93. package/dist/templates/showcase/pages/navigation/view.dml +0 -34
  94. package/dist/templates/showcase/pages/network/view.dml +0 -67
  95. package/dist/templates/showcase/pages/secrets/view.dml +0 -24
  96. package/dist/templates/showcase/pages/state/view.dml +0 -33
  97. package/dist/templates/showcase/pages/styles/view.dml +0 -61
  98. package/dist/templates/showcase/pages/text/state.ts +0 -8
  99. package/dist/templates/showcase/pages/text/view.dml +0 -58
  100. /package/dist/templates/showcase/pages/{state → basics/state}/state.ts +0 -0
  101. /package/dist/templates/showcase/pages/{carousel → components/carousel}/state.ts +0 -0
  102. /package/dist/templates/showcase/pages/{feedback → components/feedback}/state.ts +0 -0
  103. /package/dist/templates/showcase/pages/{images → components/images}/state.ts +0 -0
  104. /package/dist/templates/showcase/pages/{layout → components/layout}/state.ts +0 -0
  105. /package/dist/templates/showcase/pages/{payments → components/money}/state.ts +0 -0
  106. /package/dist/templates/showcase/pages/{styles → components/styles}/state.ts +0 -0
  107. /package/dist/templates/showcase/pages/{cache → dash/cache}/state.ts +0 -0
  108. /package/dist/templates/showcase/pages/{files → dash/files}/state.ts +0 -0
  109. /package/dist/templates/showcase/pages/{secrets → dash/secrets}/state.ts +0 -0
@@ -0,0 +1,70 @@
1
+ import { HostError } from '@monimesl/dot-runtime';
2
+
3
+ import state from './state';
4
+
5
+ // Closing a picker isn't a problem to show. Anything else is.
6
+ function problemToShow(error: unknown): string {
7
+ const closedByPerson = error instanceof HostError && error.code === 'cancelled';
8
+ return closedByPerson ? '' : (error as Error).message;
9
+ }
10
+
11
+ export default definePage({
12
+ initialState: state,
13
+ configs: { navigationBar: { title: 'dash.ui' } },
14
+ actions: {
15
+ async greet() {
16
+ try {
17
+ const { action } = await this.dash.ui.alert({
18
+ title: 'Kushé',
19
+ message: 'Kushé means hello in Krio, and tenki means thanks.',
20
+ actions: [
21
+ { id: 'tenki', label: 'Tenki' },
22
+ { id: 'close', label: 'Close', role: 'cancel' },
23
+ ],
24
+ });
25
+ this.setState({ choice: action, note: '' });
26
+ } catch (error) {
27
+ this.setState({ note: problemToShow(error) });
28
+ }
29
+ },
30
+ async confirmRemove() {
31
+ try {
32
+ const { action } = await this.dash.ui.alert({
33
+ title: 'Remove this song from your library?',
34
+ message: 'Its download goes too.',
35
+ actions: [
36
+ { id: 'keep', label: 'Keep', role: 'cancel' },
37
+ { id: 'remove', label: 'Remove', role: 'destructive' },
38
+ ],
39
+ });
40
+ this.setState({ choice: action, note: '' });
41
+ } catch (error) {
42
+ this.setState({ note: problemToShow(error) });
43
+ }
44
+ },
45
+ async chooseNight(state) {
46
+ try {
47
+ const night = await this.dash.ui.pickDate({
48
+ title: 'Choose a night',
49
+ value: state.night || undefined,
50
+ min: '2026-10-01',
51
+ max: '2026-12-31',
52
+ });
53
+ this.setState({ night, note: '' });
54
+ } catch (error) {
55
+ this.setState({ note: problemToShow(error) });
56
+ }
57
+ },
58
+ async chooseArrival(state) {
59
+ try {
60
+ const arrival = await this.dash.ui.pickTime({
61
+ title: 'Arriving at',
62
+ value: state.arrival || '18:00',
63
+ });
64
+ this.setState({ arrival, note: '' });
65
+ } catch (error) {
66
+ this.setState({ note: problemToShow(error) });
67
+ }
68
+ },
69
+ },
70
+ });
@@ -0,0 +1,8 @@
1
+ export default {
2
+ // The id of the alert button tapped.
3
+ choice: '',
4
+ // A date such as "2026-10-24", and a time such as "19:30", from the phone's own pickers.
5
+ night: '',
6
+ arrival: '',
7
+ note: '',
8
+ };
@@ -0,0 +1,31 @@
1
+ <View>
2
+ <Text variant="title">dash.ui</Text>
3
+ <Text>Dash shows these over the dot, in the phone's own style. Each call waits until the person answers.</Text>
4
+
5
+ <View gap="small">
6
+ <Text variant="subtitle">alert</Text>
7
+ <Text variant="caption" tone="muted">A title, a message and buttons. It gives back the id of the button tapped. role="cancel" and role="destructive" style a button.</Text>
8
+ <View variant="card" gap="small">
9
+ <View direction="row" wrap gap="small">
10
+ <Button onClick="greet">Say kushé</Button>
11
+ <Button variant="secondary" onClick="confirmRemove">Remove a song</Button>
12
+ </View>
13
+ <If condition="{{ choice }}">
14
+ <Text>You tapped "{{ choice }}"</Text>
15
+ </If>
16
+ </View>
17
+ </View>
18
+
19
+ <View gap="small">
20
+ <Text variant="subtitle">pickDate and pickTime</Text>
21
+ <Text variant="caption" tone="muted">The phone's own pickers. A date comes back as "2026-10-24" and a time as "19:30". min and max limit the dates. Closing a picker rejects with a HostError coded cancelled.</Text>
22
+ <List>
23
+ <ListItem icon="calendar" title="Night" subtitle="Shows run from October to December" value="{{ night || 'Choose' }}" onTap="chooseNight" />
24
+ <ListItem icon="clock" title="Arriving at" subtitle="Doors open at 18:00" value="{{ arrival || 'Choose' }}" onTap="chooseArrival" />
25
+ </List>
26
+ </View>
27
+
28
+ <If condition="{{ note }}">
29
+ <Notice tone="danger">{{ note }}</Notice>
30
+ </If>
31
+ </View>
@@ -1,133 +1,204 @@
1
- export interface Feature {
1
+ export interface Topic {
2
2
  page: PageId;
3
3
  title: string;
4
- summary: string;
4
+ // The API names the page shows, so it's easy to find the one you need.
5
+ covers: string;
5
6
  icon: string;
6
7
  }
7
8
 
8
9
  export interface Section {
9
10
  title: string;
10
- features: Feature[];
11
+ text: string;
12
+ topics: Topic[];
11
13
  }
12
14
 
13
15
  export default {
14
16
  title: 'Salone Sounds',
15
17
  sections: [
16
18
  {
17
- title: 'Views',
18
- features: [
19
+ title: 'Basics',
20
+ text: 'How a page works: pages/<name>/ with state.ts, view.dml and controller.ts',
21
+ topics: [
19
22
  {
20
- page: 'layout',
23
+ page: 'basics/state',
24
+ title: 'State, mutations and actions',
25
+ covers: 'state.ts, setState, mutations, actions',
26
+ icon: 'refresh',
27
+ },
28
+ {
29
+ page: 'basics/bindings',
30
+ title: 'Bindings',
31
+ covers: '{{ }}, expressions, env',
32
+ icon: 'link',
33
+ },
34
+ {
35
+ page: 'basics/control-flow',
36
+ title: 'If and For',
37
+ covers: 'If, ElseIf, Else, For',
38
+ icon: 'list',
39
+ },
40
+ {
41
+ page: 'basics/events',
42
+ title: 'Events',
43
+ covers: 'onTap, onChange, event.detail, data-*',
44
+ icon: 'bolt',
45
+ },
46
+ {
47
+ page: 'basics/navigation',
48
+ title: 'Navigation',
49
+ covers: 'push, replace, back, reset',
50
+ icon: 'arrow-right',
51
+ },
52
+ {
53
+ page: 'basics/hooks',
54
+ title: 'Page hooks',
55
+ covers: 'onLoad, onShow, onHide, onUnload',
56
+ icon: 'history',
57
+ },
58
+ {
59
+ page: 'basics/bars',
60
+ title: "Dash's bars",
61
+ covers: 'configs, setNavigationBar, setTabBar',
62
+ icon: 'settings',
63
+ },
64
+ ],
65
+ },
66
+ {
67
+ title: 'Components',
68
+ text: 'What a view.dml can show',
69
+ topics: [
70
+ {
71
+ page: 'components/layout',
21
72
  title: 'Layout',
22
- summary: 'Rows, columns, cards, a shelf to scroll and a grid',
73
+ covers: 'View, Stack, Scroll, Grid, Divider',
23
74
  icon: 'grid',
24
75
  },
25
76
  {
26
- page: 'text',
27
- title: 'Text and bindings',
28
- summary: 'Text styles, tones, links and bindings',
77
+ page: 'components/styles',
78
+ title: 'Styles',
79
+ covers: 'background, border, radius, sizes, theme colours',
80
+ icon: 'star',
81
+ },
82
+ {
83
+ page: 'components/text',
84
+ title: 'Text and links',
85
+ covers: 'Text, Link',
29
86
  icon: 'edit',
30
87
  },
31
88
  {
32
- page: 'styles',
33
- title: 'Styles',
34
- summary: 'Colours, outlines, corners, sizes and layers',
35
- icon: 'star',
89
+ page: 'components/icons',
90
+ title: 'Icons',
91
+ covers: 'Icon, every name',
92
+ icon: 'heart',
93
+ },
94
+ {
95
+ page: 'components/reading',
96
+ title: 'Reading',
97
+ covers: 'Prose, Quote, BulletList, RichText',
98
+ icon: 'file',
36
99
  },
37
100
  {
38
- page: 'images',
101
+ page: 'components/images',
39
102
  title: 'Images',
40
- summary: 'Pictures from the dot and from the web',
103
+ covers: 'Image',
41
104
  icon: 'image',
42
105
  },
43
106
  {
44
- page: 'carousel',
107
+ page: 'components/carousel',
45
108
  title: 'Carousel',
46
- summary: 'Slides of Gen Z artists and Salone history',
47
- icon: 'image',
109
+ covers: 'Carousel',
110
+ icon: 'video',
48
111
  },
49
112
  {
50
- page: 'lists',
51
- title: 'Lists and icons',
52
- summary: 'Rows to tap, badges and icons',
113
+ page: 'components/lists',
114
+ title: 'Lists',
115
+ covers: 'List, ListItem, DetailRow, EmptyState',
53
116
  icon: 'list',
54
117
  },
55
118
  {
56
- page: 'filters',
57
- title: 'Tabs and filters',
58
- summary: 'Tabs, chips and empty states',
119
+ page: 'components/tabs',
120
+ title: 'Tabs and chips',
121
+ covers: 'Tabs, Tab, Chip',
59
122
  icon: 'search',
60
123
  },
61
124
  {
62
- page: 'forms',
125
+ page: 'components/forms',
63
126
  title: 'Forms',
64
- summary: 'Fields, choices and switches for buying tickets',
127
+ covers: 'Input, TextArea, Select, Checkbox, Radio, Switch, Slider, Footer',
65
128
  icon: 'check',
66
129
  },
67
130
  {
68
- page: 'payments',
69
- title: 'Payments',
70
- summary: 'Amounts, QR codes and one-time codes',
131
+ page: 'components/money',
132
+ title: 'Money and codes',
133
+ covers: 'AmountInput, CodeInput, QRCode',
71
134
  icon: 'cash',
72
135
  },
73
136
  {
74
- page: 'feedback',
137
+ page: 'components/feedback',
75
138
  title: 'Feedback',
76
- summary: 'Loading, toasts, progress and notices',
139
+ covers: 'Spinner, Skeleton, ProgressBar, Notice, Badge, Toast',
77
140
  icon: 'bell',
78
141
  },
79
- ],
80
- },
81
- {
82
- title: 'Logic',
83
- features: [
84
142
  {
85
- page: 'state',
86
- title: 'State, mutations and actions',
87
- summary: 'State, conditions and lists',
88
- icon: 'refresh',
89
- },
90
- {
91
- page: 'navigation',
92
- title: 'Navigation and hooks',
93
- summary: 'Opening pages, going back, and page hooks',
94
- icon: 'arrow-right',
143
+ page: 'components/sheets',
144
+ title: 'Sheets',
145
+ covers: 'Sheet',
146
+ icon: 'more',
95
147
  },
96
148
  ],
97
149
  },
98
150
  {
99
151
  title: 'Dash',
100
- features: [
152
+ text: "The phone's features, through this.dash",
153
+ topics: [
101
154
  {
102
- page: 'device',
103
- title: 'Alerts and device',
104
- summary: 'Alerts, sharing, links, photos, QR codes and the torch',
155
+ page: 'dash/ui',
156
+ title: 'dash.ui',
157
+ covers: 'alert, pickDate, pickTime',
158
+ icon: 'calendar',
159
+ },
160
+ {
161
+ page: 'dash/system',
162
+ title: 'dash.system',
163
+ covers: 'vibrate, copyText, share, openUrl, delay, torch',
105
164
  icon: 'mobile',
106
165
  },
107
166
  {
108
- page: 'network',
109
- title: 'Network',
110
- summary: 'Requests, JSON, downloads and uploads',
167
+ page: 'dash/media',
168
+ title: 'dash.media',
169
+ covers: 'pickPhoto, scanCode',
170
+ icon: 'image',
171
+ },
172
+ {
173
+ page: 'dash/network',
174
+ title: 'dash.network.http',
175
+ covers: 'request, download, upload',
111
176
  icon: 'wifi',
112
177
  },
113
178
  {
114
- page: 'files',
115
- title: 'Files',
116
- summary: "Saving files in the dot's own folder, and picking them",
179
+ page: 'dash/files',
180
+ title: 'dash.storage.file',
181
+ covers: 'write, read, list, move, copy, pick, save',
117
182
  icon: 'file',
118
183
  },
119
184
  {
120
- page: 'cache',
121
- title: 'Cache',
122
- summary: 'Values that expire after a while',
123
- icon: 'refresh',
185
+ page: 'dash/cache',
186
+ title: 'dash.storage.cache',
187
+ covers: 'set, get, keys, exists, remove, clear',
188
+ icon: 'history',
124
189
  },
125
190
  {
126
- page: 'secrets',
127
- title: 'Secrets',
128
- summary: 'Sign-in tokens kept encrypted',
191
+ page: 'dash/secrets',
192
+ title: 'dash.storage.secret',
193
+ covers: 'set, get, remove, clear',
129
194
  icon: 'lock',
130
195
  },
196
+ {
197
+ page: 'dash/calls',
198
+ title: 'Calls and errors',
199
+ covers: 'timeout, cancel, HostError',
200
+ icon: 'warning',
201
+ },
131
202
  ],
132
203
  },
133
204
  ] as Section[],
@@ -9,10 +9,13 @@
9
9
 
10
10
  <For each="{{ sections }}" item="section" key="title">
11
11
  <View gap="small">
12
- <Text variant="caption" tone="muted">{{ section.title }}</Text>
12
+ <View gap="none">
13
+ <Text variant="subtitle">{{ section.title }}</Text>
14
+ <Text variant="caption" tone="muted">{{ section.text }}</Text>
15
+ </View>
13
16
  <List>
14
- <For each="{{ section.features }}" item="feature" key="page">
15
- <ListItem icon="{{ feature.icon }}" title="{{ feature.title }}" subtitle="{{ feature.summary }}" data-page="{{ feature.page }}" onTap="open" />
17
+ <For each="{{ section.topics }}" item="topic" key="page">
18
+ <ListItem icon="{{ topic.icon }}" title="{{ topic.title }}" subtitle="{{ topic.covers }}" data-page="{{ topic.page }}" onTap="open" />
16
19
  </For>
17
20
  </List>
18
21
  </View>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monimesl/dot-cli",
3
- "version": "0.1.0-alpha.16",
3
+ "version": "0.1.0-alpha.19",
4
4
  "description": "The dotctl command: build mini apps and run them in the simulator",
5
5
  "type": "module",
6
6
  "repository": {
@@ -24,11 +24,11 @@
24
24
  "dependencies": {
25
25
  "typescript": "^5.9.3",
26
26
  "uqr": "^0.1.3",
27
- "@monimesl/dot-compiler": "0.1.0-alpha.16",
28
- "@monimesl/dot-dml-parser": "0.1.0-alpha.16",
29
- "@monimesl/dot-simulator": "0.1.0-alpha.16",
30
- "@monimesl/dot-script-parser": "0.1.0-alpha.16",
31
- "@monimesl/dot-core": "0.1.0-alpha.16"
27
+ "@monimesl/dot-compiler": "0.1.0-alpha.19",
28
+ "@monimesl/dot-dml-parser": "0.1.0-alpha.19",
29
+ "@monimesl/dot-script-parser": "0.1.0-alpha.19",
30
+ "@monimesl/dot-core": "0.1.0-alpha.19",
31
+ "@monimesl/dot-simulator": "0.1.0-alpha.19"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^22.20.4",
@@ -1,36 +0,0 @@
1
- <View>
2
- <Text variant="title">Cache</Text>
3
- <Text>The cache saves small values by name. A value can expire after a set time, or stay until it is removed.</Text>
4
-
5
- <Text variant="caption" tone="muted">Tap an artist. It is remembered for 30 seconds.</Text>
6
- <List>
7
- <For each="{{ artists }}" item="artist" key="id">
8
- <ListItem icon="microphone" title="{{ artist.name }}" data-id="{{ artist.id }}" data-name="{{ artist.name }}" onTap="view" />
9
- </For>
10
- </List>
11
- <View variant="card" gap="small">
12
- <If condition="{{ recent.length > 0 }}">
13
- <For each="{{ recent }}" item="name" key="name">
14
- <Text>{{ name }}</Text>
15
- </For>
16
- </If>
17
- <Else>
18
- <Text variant="caption" tone="muted">No artists viewed in the last 30 seconds</Text>
19
- </Else>
20
- <Button variant="secondary" onClick="refresh">Check again</Button>
21
- </View>
22
-
23
- <Text variant="caption" tone="muted">Your favourite genre. It stays until you clear the cache.</Text>
24
- <View variant="card">
25
- <Select label="Genre" placeholder="Choose a genre" value="{{ genre }}" onChange="setGenre">
26
- <Option value="Afropop" label="Afropop" />
27
- <Option value="Palm-wine" label="Palm-wine" />
28
- <Option value="Gumbe" label="Gumbe" />
29
- </Select>
30
- </View>
31
-
32
- <View variant="card" gap="small">
33
- <Text variant="caption" tone="muted">Keys in the cache: {{ keys || 'none' }}</Text>
34
- <Button variant="secondary" onClick="clear" disabled="{{ !keys }}">Clear the cache</Button>
35
- </View>
36
- </View>
@@ -1,105 +0,0 @@
1
- import { HostError } from '@monimesl/dot-runtime';
2
-
3
- import state from './state';
4
-
5
- // Closing a picker or scanner isn't a problem to show.
6
- function problemToShow(error: unknown): string {
7
- const closedByPerson = error instanceof HostError && error.code === 'cancelled';
8
- return closedByPerson ? '' : (error as Error).message;
9
- }
10
-
11
- export default definePage({
12
- initialState: state,
13
- mutations: {
14
- clearToast: () => ({ toast: '' }),
15
- },
16
- actions: {
17
- async greet() {
18
- try {
19
- const { action } = await this.dash.ui.alert({
20
- title: 'Kushé',
21
- message: env.GREETING,
22
- actions: [
23
- { id: 'tenki', label: 'Tenki' },
24
- { id: 'close', label: 'Close', role: 'cancel' },
25
- ],
26
- });
27
- this.setState({ choice: action });
28
- } catch (error) {
29
- this.setState({ note: (error as Error).message });
30
- }
31
- },
32
- async confirmDelete() {
33
- try {
34
- const { action } = await this.dash.ui.alert({
35
- title: 'Remove this song from your library?',
36
- message: 'Its download goes too.',
37
- actions: [
38
- { id: 'keep', label: 'Keep', role: 'cancel' },
39
- { id: 'remove', label: 'Remove', role: 'destructive' },
40
- ],
41
- });
42
- this.setState({ choice: action });
43
- } catch (error) {
44
- this.setState({ note: (error as Error).message });
45
- }
46
- },
47
- async vibrate(_state, event: DotEvent<unknown, { style: 'light' | 'success' | 'error' }>) {
48
- await this.dash.system.vibrate({ style: event.data.style });
49
- },
50
- async copySong() {
51
- await this.dash.system.copyText('Exodus, by Drizilik');
52
- this.setState({ toast: 'Song copied' });
53
- },
54
- async shareLink() {
55
- try {
56
- await this.dash.system.share({
57
- title: 'Music of Sierra Leone',
58
- url: 'https://en.wikipedia.org/wiki/Music_of_Sierra_Leone',
59
- });
60
- } catch (error) {
61
- this.setState({ note: (error as Error).message });
62
- }
63
- },
64
- async openDrizilik() {
65
- try {
66
- await this.dash.system.openUrl('https://drizilik.com/');
67
- } catch (error) {
68
- this.setState({ note: (error as Error).message });
69
- }
70
- },
71
- async countDown() {
72
- for (let seconds = 10; seconds > 0; seconds--) {
73
- this.setState({ showIn: seconds });
74
- await this.dash.system.delay(1000);
75
- }
76
- this.setState({ showIn: 0, toast: "It's showtime" });
77
- },
78
- async pickPhoto(_state, event: DotEvent<unknown, { source: 'library' | 'camera' }>) {
79
- try {
80
- const photo = await this.dash.media.pickPhoto({ source: event.data.source });
81
- const details = `${photo.name}, ${Math.round(photo.size / 1024)} KB as a JPEG`;
82
- this.setState({ photo, photoDetails: details, note: '' });
83
- } catch (error) {
84
- this.setState({ note: problemToShow(error) });
85
- }
86
- },
87
- async scanTicket() {
88
- try {
89
- const { text } = await this.dash.media.scanCode();
90
- this.setState({ scanned: text, note: '' });
91
- } catch (error) {
92
- this.setState({ note: problemToShow(error) });
93
- }
94
- },
95
- async toggleTorch(state) {
96
- const next = state.torch === 'on' ? 'off' : 'on';
97
- try {
98
- await this.dash.system.torch(next);
99
- this.setState({ torch: next, note: '' });
100
- } catch (error) {
101
- this.setState({ note: (error as Error).message });
102
- }
103
- },
104
- },
105
- });
@@ -1,16 +0,0 @@
1
- export interface Photo {
2
- name: string;
3
- size: number;
4
- url: string;
5
- }
6
-
7
- export default {
8
- photo: null as Photo | null,
9
- photoDetails: '',
10
- scanned: '',
11
- choice: '',
12
- torch: 'off' as 'on' | 'off',
13
- note: '',
14
- toast: '',
15
- showIn: 0,
16
- };
@@ -1,69 +0,0 @@
1
- <View>
2
- <Text variant="title">Alerts and device</Text>
3
- <Text>Dash shows these, not the dot. The dot asks for them through dash.</Text>
4
-
5
- <Text variant="caption" tone="muted">dash.ui.alert</Text>
6
- <View variant="card" gap="small">
7
- <View direction="row" wrap gap="small">
8
- <Button onClick="greet">Say kushé</Button>
9
- <Button variant="secondary" onClick="confirmDelete">Remove a song</Button>
10
- </View>
11
- <If condition="{{ choice }}">
12
- <Text>You chose "{{ choice }}"</Text>
13
- </If>
14
- <Text variant="caption" tone="muted">Kushé means hello in Krio, and tenki means thanks. The message comes from GREETING in the .env file.</Text>
15
- </View>
16
-
17
- <Text variant="caption" tone="muted">dash.system.vibrate</Text>
18
- <View variant="card" direction="row" wrap gap="small">
19
- <Button variant="secondary" data-style="light" onClick="vibrate">Light</Button>
20
- <Button variant="secondary" data-style="success" onClick="vibrate">Success</Button>
21
- <Button variant="secondary" data-style="error" onClick="vibrate">Error</Button>
22
- </View>
23
-
24
- <Text variant="caption" tone="muted">dash.system.copyText and dash.system.share</Text>
25
- <View variant="card" direction="row" wrap gap="small">
26
- <Button variant="secondary" onClick="copySong">Copy a song</Button>
27
- <Button variant="secondary" onClick="shareLink">Share Sierra Leone's music</Button>
28
- </View>
29
-
30
- <Text variant="caption" tone="muted">dash.system.openUrl opens a web page in the phone's browser</Text>
31
- <View variant="card">
32
- <Button variant="secondary" onClick="openDrizilik">Open Drizilik's website</Button>
33
- </View>
34
-
35
- <Text variant="caption" tone="muted">dash.system.delay</Text>
36
- <View variant="card">
37
- <Button variant="secondary" onClick="countDown" disabled="{{ showIn > 0 }}">{{ showIn > 0 ? 'Showtime in ' + showIn + 's' : 'Count down to showtime' }}</Button>
38
- </View>
39
-
40
- <Text variant="caption" tone="muted">dash.media.pickPhoto, with the photoLibrary and camera permissions</Text>
41
- <View variant="card" gap="small">
42
- <View direction="row" wrap gap="small">
43
- <Button variant="secondary" data-source="library" onClick="pickPhoto">Choose a photo</Button>
44
- <Button variant="secondary" data-source="camera" onClick="pickPhoto">Take a photo</Button>
45
- </View>
46
- <If condition="{{ photo }}">
47
- <Image src="{{ photo.url }}" alt="The photo you picked" aspect="4:3" fit="contain" />
48
- <Text variant="caption" tone="muted">{{ photoDetails }}. It goes when the dot closes, unless the dot saves it.</Text>
49
- </If>
50
- </View>
51
-
52
- <Text variant="caption" tone="muted">dash.media.scanCode, with Dash's own scanner and the camera permission</Text>
53
- <View variant="card" gap="small">
54
- <Button variant="secondary" onClick="scanTicket">Scan a ticket's QR code</Button>
55
- <If condition="{{ scanned }}">
56
- <Text>{{ scanned }}</Text>
57
- </If>
58
- </View>
59
-
60
- <Text variant="caption" tone="muted">dash.system.torch</Text>
61
- <View variant="card" gap="small">
62
- <Button variant="secondary" onClick="toggleTorch">{{ torch === 'on' ? 'Turn the torch off' : 'Lights up for the slow song' }}</Button>
63
- <If condition="{{ note }}">
64
- <Text variant="caption" tone="muted">{{ note }}</Text>
65
- </If>
66
- </View>
67
-
68
- <Toast message="{{ toast }}" tone="success" onHide="clearToast" />
69
- </View>