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

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 (68) hide show
  1. package/README.md +34 -15
  2. package/dist/cli.js +386 -57
  3. package/dist/cli.js.map +1 -1
  4. package/dist/server-DFOUQnLA.js +11263 -0
  5. package/dist/server-DFOUQnLA.js.map +1 -0
  6. package/dist/templates/showcase/.env +3 -0
  7. package/dist/templates/showcase/dot.ts +22 -0
  8. package/dist/templates/showcase/pages/carousel/controller.ts +10 -0
  9. package/dist/templates/showcase/pages/carousel/state.ts +40 -0
  10. package/dist/templates/showcase/pages/carousel/view.dml +37 -0
  11. package/dist/templates/showcase/pages/device/controller.ts +70 -0
  12. package/dist/templates/showcase/pages/device/state.ts +7 -0
  13. package/dist/templates/showcase/pages/device/view.dml +44 -0
  14. package/dist/templates/showcase/pages/feedback/controller.ts +16 -0
  15. package/dist/templates/showcase/pages/feedback/state.ts +7 -0
  16. package/dist/templates/showcase/pages/feedback/view.dml +87 -0
  17. package/dist/templates/showcase/pages/files/controller.ts +47 -0
  18. package/dist/templates/showcase/pages/files/state.ts +11 -0
  19. package/dist/templates/showcase/pages/files/view.dml +35 -0
  20. package/dist/templates/showcase/pages/filters/controller.ts +28 -0
  21. package/dist/templates/showcase/pages/filters/state.ts +72 -0
  22. package/dist/templates/showcase/pages/filters/view.dml +43 -0
  23. package/dist/templates/showcase/pages/forms/controller.ts +44 -0
  24. package/dist/templates/showcase/pages/forms/state.ts +15 -0
  25. package/dist/templates/showcase/pages/forms/view.dml +39 -0
  26. package/dist/templates/showcase/pages/images/controller.ts +15 -0
  27. package/dist/templates/showcase/pages/images/state.ts +7 -0
  28. package/dist/templates/showcase/pages/images/view.dml +38 -0
  29. package/dist/templates/showcase/pages/index/controller.ts +10 -0
  30. package/dist/templates/showcase/pages/index/state.ts +116 -0
  31. package/dist/templates/showcase/pages/index/view.dml +20 -0
  32. package/dist/templates/showcase/pages/layout/controller.ts +26 -0
  33. package/dist/templates/showcase/pages/layout/state.ts +14 -0
  34. package/dist/templates/showcase/pages/layout/view.dml +80 -0
  35. package/dist/templates/showcase/pages/lists/controller.ts +36 -0
  36. package/dist/templates/showcase/pages/lists/state.ts +96 -0
  37. package/dist/templates/showcase/pages/lists/view.dml +59 -0
  38. package/dist/templates/showcase/pages/navigation/controller.ts +64 -0
  39. package/dist/templates/showcase/pages/navigation/state.ts +17 -0
  40. package/dist/templates/showcase/pages/navigation/view.dml +34 -0
  41. package/dist/templates/showcase/pages/network/controller.ts +107 -0
  42. package/dist/templates/showcase/pages/network/state.ts +15 -0
  43. package/dist/templates/showcase/pages/network/view.dml +56 -0
  44. package/dist/templates/showcase/pages/payments/controller.ts +42 -0
  45. package/dist/templates/showcase/pages/payments/state.ts +10 -0
  46. package/dist/templates/showcase/pages/payments/view.dml +35 -0
  47. package/dist/templates/showcase/pages/state/controller.ts +22 -0
  48. package/dist/templates/showcase/pages/state/state.ts +10 -0
  49. package/dist/templates/showcase/pages/state/view.dml +33 -0
  50. package/dist/templates/showcase/pages/text/controller.ts +10 -0
  51. package/dist/templates/showcase/pages/text/state.ts +7 -0
  52. package/dist/templates/showcase/pages/text/view.dml +49 -0
  53. package/dist/templates/starter/.env +3 -0
  54. package/dist/templates/starter/dot.ts +3 -0
  55. package/dist/templates/starter/pages/index/controller.ts +9 -0
  56. package/dist/templates/starter/pages/index/state.ts +4 -0
  57. package/dist/templates/starter/pages/index/view.dml +16 -0
  58. package/dist/templates/starter/statics/logo.png +0 -0
  59. package/package.json +12 -7
  60. package/dist/template/.env +0 -3
  61. package/dist/template/dot.ts +0 -6
  62. package/dist/template/pages/help/tips/controller.ts +0 -30
  63. package/dist/template/pages/help/tips/state.ts +0 -11
  64. package/dist/template/pages/help/tips/view.dml +0 -15
  65. package/dist/template/pages/index/controller.ts +0 -67
  66. package/dist/template/pages/index/state.ts +0 -17
  67. package/dist/template/pages/index/view.dml +0 -66
  68. /package/dist/{template → templates/showcase}/statics/logo.png +0 -0
@@ -1,67 +0,0 @@
1
- import state from './state';
2
-
3
- export default definePage({
4
- initialState: state,
5
- hooks: {
6
- onShow() {
7
- this.setState((current) => ({ visits: current.visits + 1 }));
8
- },
9
- },
10
- mutations: {
11
- increment: (state) => {
12
- const count = state.count + 1;
13
- return { count, taps: [{ id: count }, ...state.taps] };
14
- },
15
- reset: () => ({ count: 0, taps: [] }),
16
- rename: (_state, event: DotEvent<{ value: string }>) => ({ title: event.detail.value }),
17
- logoLoaded: (_state, event: DotEvent<{ width: number; height: number }>) => ({
18
- logoStatus: 'loaded' as const,
19
- logoSize: `${event.detail.width}x${event.detail.height}`,
20
- }),
21
- logoFailed: () => ({ logoStatus: 'failed' as const }),
22
- },
23
- actions: {
24
- fillUp() {
25
- while (this.state.count < this.state.limit) {
26
- this.mutations.increment();
27
- }
28
- },
29
- async sayHello(state) {
30
- try {
31
- const { action } = await dash.ui.alert(
32
- {
33
- title: `Hello from ${state.title}`,
34
- message: env.DOT_PUBLIC_GREETING,
35
- actions: [
36
- { id: 'nice', label: 'Nice' },
37
- { id: 'close', label: 'Close', role: 'cancel' },
38
- ],
39
- },
40
- { timeout: 30_000 },
41
- );
42
- this.setState({ dashNote: `You chose "${action}"` });
43
- } catch (error) {
44
- this.setState({ dashNote: errorMessage(error) });
45
- }
46
- },
47
- async vibrate() {
48
- await dash.system.vibrate({ style: 'success' });
49
- },
50
- async toggleTorch(state) {
51
- const next = state.torch === 'on' ? 'off' : 'on';
52
- try {
53
- await dash.system.torch(next);
54
- this.setState({ torch: next, dashNote: `Torch ${next}` });
55
- } catch (error) {
56
- this.setState({ dashNote: errorMessage(error) });
57
- }
58
- },
59
- openTips(state) {
60
- this.navigation.push('help/tips', { count: String(state.count), trail: 'Home', depth: '1' });
61
- },
62
- },
63
- });
64
-
65
- function errorMessage(error: unknown): string {
66
- return error instanceof Error ? error.message : String(error);
67
- }
@@ -1,17 +0,0 @@
1
- export interface Tap {
2
- id: number;
3
- }
4
-
5
- export type LogoStatus = 'loading' | 'loaded' | 'failed';
6
-
7
- export default {
8
- title: 'Dot Counter',
9
- logoStatus: 'loading' as LogoStatus,
10
- logoSize: '',
11
- count: 0,
12
- limit: 5,
13
- taps: [] as Tap[],
14
- visits: 0,
15
- torch: 'off' as 'on' | 'off',
16
- dashNote: '',
17
- };
@@ -1,66 +0,0 @@
1
- <Text variant="caption">Home</Text>
2
-
3
- <View direction="row" align="center" gap="large">
4
- <Image src="statics/logo.png" alt="Dot logo" width="48" height="48" onLoad="logoLoaded" onError="logoFailed" />
5
- <View gap="none">
6
- <Text variant="title">{{ title }}</Text>
7
- <If condition="{{ logoStatus === 'loaded' }}">
8
- <Text variant="caption">Logo loaded at {{ logoSize }}</Text>
9
- </If>
10
- <ElseIf condition="{{ logoStatus === 'failed' }}">
11
- <Text variant="caption">Logo failed to load</Text>
12
- </ElseIf>
13
- <Else>
14
- <Text variant="caption">Loading logo…</Text>
15
- </Else>
16
- </View>
17
- </View>
18
-
19
- <View variant="card">
20
- <Text variant="title">{{ count }} / {{ limit }}</Text>
21
- <If condition="{{ count >= limit }}">
22
- <Text>Limit reached</Text>
23
- </If>
24
- <ElseIf condition="{{ count > 0 }}">
25
- <Text>Keep tapping</Text>
26
- </ElseIf>
27
- <Else>
28
- <Text>Tap to start 🚀</Text>
29
- </Else>
30
- <View direction="row">
31
- <Button onClick="increment" disabled="{{ count >= limit }}">Add one</Button>
32
- <Button variant="secondary" onClick="reset" disabled="{{ count === 0 }}">Reset</Button>
33
- <Button variant="secondary" onClick="fillUp" disabled="{{ count >= limit }}">Fill up</Button>
34
- </View>
35
- </View>
36
-
37
- <View variant="card" gap="small">
38
- <Text variant="caption">Name your counter</Text>
39
- <Input label="Counter name" placeholder="Dot Counter" value="{{ title }}" maxLength="24" onChange="rename" />
40
- </View>
41
-
42
- <View variant="card" gap="small">
43
- <Text variant="caption">Dash</Text>
44
- <View direction="row">
45
- <Button variant="secondary" onClick="sayHello">Say hello</Button>
46
- <Button variant="secondary" onClick="vibrate">Vibrate</Button>
47
- <Button variant="secondary" onClick="toggleTorch">{{ torch === 'on' ? 'Torch off' : 'Torch on' }}</Button>
48
- </View>
49
- <If condition="{{ dashNote }}">
50
- <Text variant="caption">{{ dashNote }}</Text>
51
- </If>
52
- </View>
53
-
54
- <View variant="card" onTap="openTips">
55
- <Text>Tips -> </Text>
56
- <Text variant="caption">Shown {{ visits }} {{ visits === 1 ? 'time' : 'times' }}</Text>
57
- </View>
58
-
59
- <If condition="{{ taps.length > 0 }}">
60
- <View variant="card" gap="small">
61
- <Text variant="caption">History</Text>
62
- <For each="{{ taps }}" index="i" item="tap" key="id">
63
- <Text>{{ i + 1 }}. Tap #{{ tap.id }}</Text>
64
- </For>
65
- </View>
66
- </If>