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

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 (159) hide show
  1. package/README.md +91 -17
  2. package/dist/cli.js +776 -199
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{server-z7M4FLjf.js → server-DMnWDdJ6.js} +702 -280
  5. package/dist/server-DMnWDdJ6.js.map +1 -0
  6. package/dist/templates/showcase/.env +3 -0
  7. package/dist/templates/showcase/dot.ts +60 -0
  8. package/dist/templates/showcase/pages/basics/bars/controller.ts +47 -0
  9. package/dist/templates/showcase/pages/basics/bars/state.ts +7 -0
  10. package/dist/templates/showcase/pages/basics/bars/view.dml +36 -0
  11. package/dist/templates/showcase/pages/basics/bindings/controller.ts +15 -0
  12. package/dist/templates/showcase/pages/basics/bindings/state.ts +14 -0
  13. package/dist/templates/showcase/pages/basics/bindings/view.dml +41 -0
  14. package/dist/templates/showcase/pages/basics/colors/controller.ts +112 -0
  15. package/dist/templates/showcase/pages/basics/colors/palette.ts +52 -0
  16. package/dist/templates/showcase/pages/basics/colors/state.ts +17 -0
  17. package/dist/templates/showcase/pages/basics/colors/view.dml +142 -0
  18. package/dist/templates/showcase/pages/basics/concert/controller.ts +16 -0
  19. package/dist/templates/showcase/pages/basics/concert/state.ts +7 -0
  20. package/dist/templates/showcase/pages/basics/concert/view.dml +20 -0
  21. package/dist/templates/showcase/pages/basics/control-flow/controller.ts +18 -0
  22. package/dist/templates/showcase/pages/basics/control-flow/state.ts +16 -0
  23. package/dist/templates/showcase/pages/basics/control-flow/view.dml +55 -0
  24. package/dist/templates/showcase/pages/basics/events/controller.ts +43 -0
  25. package/dist/templates/showcase/pages/basics/events/state.ts +11 -0
  26. package/dist/templates/showcase/pages/basics/events/view.dml +51 -0
  27. package/dist/templates/showcase/pages/basics/hooks/controller.ts +43 -0
  28. package/dist/templates/showcase/pages/basics/hooks/state.ts +10 -0
  29. package/dist/templates/showcase/pages/basics/hooks/view.dml +37 -0
  30. package/dist/templates/showcase/pages/basics/navigation/controller.ts +41 -0
  31. package/dist/templates/showcase/pages/basics/navigation/state.ts +11 -0
  32. package/dist/templates/showcase/pages/basics/navigation/view.dml +48 -0
  33. package/dist/templates/showcase/pages/basics/pick-genre/controller.ts +18 -0
  34. package/dist/templates/showcase/pages/basics/pick-genre/state.ts +3 -0
  35. package/dist/templates/showcase/pages/basics/pick-genre/view.dml +10 -0
  36. package/dist/templates/showcase/pages/basics/share/concerts.ts +31 -0
  37. package/dist/templates/showcase/pages/basics/share/controller.ts +12 -0
  38. package/dist/templates/showcase/pages/basics/share/state.ts +5 -0
  39. package/dist/templates/showcase/pages/basics/share/view.dml +21 -0
  40. package/dist/{template/pages → templates/showcase/pages/basics}/state/controller.ts +1 -0
  41. package/dist/{template/pages → templates/showcase/pages/basics}/state/state.ts +1 -1
  42. package/dist/templates/showcase/pages/basics/state/view.dml +46 -0
  43. package/dist/templates/showcase/pages/components/carousel/controller.ts +41 -0
  44. package/dist/templates/showcase/pages/components/carousel/state.ts +77 -0
  45. package/dist/templates/showcase/pages/components/carousel/view.dml +42 -0
  46. package/dist/templates/showcase/pages/components/feedback/controller.ts +32 -0
  47. package/dist/templates/showcase/pages/components/feedback/state.ts +41 -0
  48. package/dist/templates/showcase/pages/components/feedback/view.dml +116 -0
  49. package/dist/templates/showcase/pages/components/forms/controller.ts +72 -0
  50. package/dist/templates/showcase/pages/components/forms/state.ts +37 -0
  51. package/dist/templates/showcase/pages/components/forms/view.dml +97 -0
  52. package/dist/templates/showcase/pages/components/icons/controller.ts +15 -0
  53. package/dist/templates/showcase/pages/components/icons/state.ts +75 -0
  54. package/dist/templates/showcase/pages/components/icons/view.dml +36 -0
  55. package/dist/templates/showcase/pages/components/images/controller.ts +44 -0
  56. package/dist/{template/pages → templates/showcase/pages/components}/images/state.ts +3 -0
  57. package/dist/templates/showcase/pages/components/images/view.dml +83 -0
  58. package/dist/templates/showcase/pages/components/layout/controller.ts +61 -0
  59. package/dist/templates/showcase/pages/components/layout/state.ts +34 -0
  60. package/dist/templates/showcase/pages/components/layout/view.dml +143 -0
  61. package/dist/templates/showcase/pages/components/lists/controller.ts +18 -0
  62. package/dist/templates/showcase/pages/components/lists/state.ts +130 -0
  63. package/dist/templates/showcase/pages/components/lists/view.dml +88 -0
  64. package/dist/templates/showcase/pages/components/money/controller.ts +45 -0
  65. package/dist/templates/showcase/pages/components/money/state.ts +13 -0
  66. package/dist/templates/showcase/pages/components/money/view.dml +54 -0
  67. package/dist/templates/showcase/pages/components/reading/controller.ts +6 -0
  68. package/dist/templates/showcase/pages/components/reading/state.ts +23 -0
  69. package/dist/templates/showcase/pages/components/reading/view.dml +42 -0
  70. package/dist/templates/showcase/pages/components/sheets/controller.ts +36 -0
  71. package/dist/templates/showcase/pages/components/sheets/state.ts +26 -0
  72. package/dist/templates/showcase/pages/components/sheets/view.dml +38 -0
  73. package/dist/templates/showcase/pages/components/styles/controller.ts +6 -0
  74. package/dist/templates/showcase/pages/components/styles/state.ts +3 -0
  75. package/dist/templates/showcase/pages/components/styles/view.dml +101 -0
  76. package/dist/templates/showcase/pages/components/tabs/controller.ts +41 -0
  77. package/dist/templates/showcase/pages/components/tabs/state.ts +127 -0
  78. package/dist/templates/showcase/pages/components/tabs/view.dml +57 -0
  79. package/dist/templates/showcase/pages/components/text/controller.ts +10 -0
  80. package/dist/templates/showcase/pages/components/text/state.ts +3 -0
  81. package/dist/templates/showcase/pages/components/text/view.dml +95 -0
  82. package/dist/templates/showcase/pages/dash/account/controller.ts +32 -0
  83. package/dist/templates/showcase/pages/dash/account/state.ts +9 -0
  84. package/dist/templates/showcase/pages/dash/account/view.dml +33 -0
  85. package/dist/templates/showcase/pages/dash/cache/controller.ts +50 -0
  86. package/dist/templates/showcase/pages/dash/cache/state.ts +17 -0
  87. package/dist/templates/showcase/pages/dash/cache/view.dml +48 -0
  88. package/dist/templates/showcase/pages/dash/calls/controller.ts +67 -0
  89. package/dist/templates/showcase/pages/dash/calls/state.ts +9 -0
  90. package/dist/templates/showcase/pages/dash/calls/view.dml +69 -0
  91. package/dist/templates/showcase/pages/dash/contacts/controller.ts +30 -0
  92. package/dist/templates/showcase/pages/dash/contacts/state.ts +6 -0
  93. package/dist/templates/showcase/pages/dash/contacts/view.dml +33 -0
  94. package/dist/templates/showcase/pages/dash/crypto/controller.ts +38 -0
  95. package/dist/templates/showcase/pages/dash/crypto/state.ts +10 -0
  96. package/dist/templates/showcase/pages/dash/crypto/view.dml +48 -0
  97. package/dist/templates/showcase/pages/dash/files/controller.ts +71 -0
  98. package/dist/templates/showcase/pages/dash/files/state.ts +23 -0
  99. package/dist/templates/showcase/pages/dash/files/view.dml +78 -0
  100. package/dist/templates/showcase/pages/dash/media/controller.ts +65 -0
  101. package/dist/templates/showcase/pages/dash/media/state.ts +12 -0
  102. package/dist/templates/showcase/pages/dash/media/view.dml +53 -0
  103. package/dist/templates/showcase/pages/dash/network/controller.ts +215 -0
  104. package/dist/templates/showcase/pages/dash/network/state.ts +35 -0
  105. package/dist/templates/showcase/pages/dash/network/view.dml +108 -0
  106. package/dist/templates/showcase/pages/dash/secrets/controller.ts +44 -0
  107. package/dist/templates/showcase/pages/dash/secrets/state.ts +5 -0
  108. package/dist/templates/showcase/pages/dash/secrets/view.dml +26 -0
  109. package/dist/templates/showcase/pages/dash/system/controller.ts +89 -0
  110. package/dist/templates/showcase/pages/dash/system/state.ts +13 -0
  111. package/dist/templates/showcase/pages/dash/system/view.dml +96 -0
  112. package/dist/templates/showcase/pages/dash/ui/controller.ts +70 -0
  113. package/dist/templates/showcase/pages/dash/ui/state.ts +8 -0
  114. package/dist/templates/showcase/pages/dash/ui/view.dml +31 -0
  115. package/dist/{template → templates/showcase}/pages/index/controller.ts +1 -1
  116. package/dist/templates/showcase/pages/index/state.ts +237 -0
  117. package/dist/templates/showcase/pages/index/view.dml +23 -0
  118. package/dist/templates/showcase/statics/logo.png +0 -0
  119. package/dist/{template → templates/starter}/.env +1 -1
  120. package/dist/templates/starter/dot.ts +3 -0
  121. package/dist/templates/starter/pages/index/controller.ts +9 -0
  122. package/dist/templates/starter/pages/index/state.ts +4 -0
  123. package/dist/templates/starter/pages/index/view.dml +16 -0
  124. package/package.json +8 -7
  125. package/dist/server-z7M4FLjf.js.map +0 -1
  126. package/dist/template/dot.ts +0 -19
  127. package/dist/template/pages/device/controller.ts +0 -70
  128. package/dist/template/pages/device/state.ts +0 -7
  129. package/dist/template/pages/device/view.dml +0 -44
  130. package/dist/template/pages/feedback/controller.ts +0 -16
  131. package/dist/template/pages/feedback/state.ts +0 -7
  132. package/dist/template/pages/feedback/view.dml +0 -87
  133. package/dist/template/pages/files/controller.ts +0 -47
  134. package/dist/template/pages/files/state.ts +0 -11
  135. package/dist/template/pages/files/view.dml +0 -35
  136. package/dist/template/pages/forms/controller.ts +0 -44
  137. package/dist/template/pages/forms/state.ts +0 -15
  138. package/dist/template/pages/forms/view.dml +0 -39
  139. package/dist/template/pages/images/controller.ts +0 -15
  140. package/dist/template/pages/images/view.dml +0 -38
  141. package/dist/template/pages/index/state.ts +0 -98
  142. package/dist/template/pages/index/view.dml +0 -20
  143. package/dist/template/pages/layout/controller.ts +0 -23
  144. package/dist/template/pages/layout/state.ts +0 -12
  145. package/dist/template/pages/layout/view.dml +0 -63
  146. package/dist/template/pages/lists/controller.ts +0 -36
  147. package/dist/template/pages/lists/state.ts +0 -96
  148. package/dist/template/pages/lists/view.dml +0 -59
  149. package/dist/template/pages/navigation/controller.ts +0 -42
  150. package/dist/template/pages/navigation/state.ts +0 -13
  151. package/dist/template/pages/navigation/view.dml +0 -24
  152. package/dist/template/pages/network/controller.ts +0 -107
  153. package/dist/template/pages/network/state.ts +0 -15
  154. package/dist/template/pages/network/view.dml +0 -56
  155. package/dist/template/pages/state/view.dml +0 -33
  156. package/dist/template/pages/text/controller.ts +0 -10
  157. package/dist/template/pages/text/state.ts +0 -7
  158. package/dist/template/pages/text/view.dml +0 -49
  159. /package/dist/{template → templates/starter}/statics/logo.png +0 -0
@@ -1,12 +0,0 @@
1
- export type Direction = 'row' | 'column';
2
- export type Justify = 'start' | 'center' | 'end' | 'between';
3
- export type Align = 'stretch' | 'start' | 'center' | 'end';
4
- export type Space = 'none' | 'small' | 'medium' | 'large';
5
-
6
- export default {
7
- direction: 'row' as Direction,
8
- justify: 'start' as Justify,
9
- align: 'center' as Align,
10
- gap: 'small' as Space,
11
- wrap: true,
12
- };
@@ -1,63 +0,0 @@
1
- <View>
2
- <Text variant="title">Layout</Text>
3
- <Text>A View lays out what it holds in a column, or in a row. Change the one below.</Text>
4
-
5
- <View variant="card" direction="{{ direction }}" justify="{{ justify }}" align="{{ align }}" gap="{{ gap }}" wrap="{{ wrap }}">
6
- <Button variant="secondary">One</Button>
7
- <Button variant="secondary">Two</Button>
8
- <Text variant="title">Three</Text>
9
- <Button variant="secondary">Four</Button>
10
- <Text variant="caption" tone="muted">Five</Text>
11
- </View>
12
-
13
- <View gap="small">
14
- <View direction="row" align="center">
15
- <Text>direction="{{ direction }}"</Text>
16
- <View grow />
17
- <Button variant="secondary" onClick="nextDirection">Change</Button>
18
- </View>
19
- <View direction="row" align="center">
20
- <Text>justify="{{ justify }}"</Text>
21
- <View grow />
22
- <Button variant="secondary" onClick="nextJustify">Change</Button>
23
- </View>
24
- <View direction="row" align="center">
25
- <Text>align="{{ align }}"</Text>
26
- <View grow />
27
- <Button variant="secondary" onClick="nextAlign">Change</Button>
28
- </View>
29
- <View direction="row" align="center">
30
- <Text>gap="{{ gap }}"</Text>
31
- <View grow />
32
- <Button variant="secondary" onClick="nextGap">Change</Button>
33
- </View>
34
- <View direction="row" align="center">
35
- <Text>wrap="{{ wrap }}"</Text>
36
- <View grow />
37
- <Button variant="secondary" onClick="toggleWrap">Change</Button>
38
- </View>
39
- </View>
40
-
41
- <Text variant="caption" tone="muted">grow takes the space that's left</Text>
42
- <View direction="row" gap="small">
43
- <View variant="card" grow>
44
- <Text>grow</Text>
45
- </View>
46
- <View variant="card">
47
- <Text>fixed</Text>
48
- </View>
49
- </View>
50
-
51
- <Text variant="caption" tone="muted">padding, on every side or just one</Text>
52
- <View direction="row" gap="small">
53
- <View variant="card" padding="small">
54
- <Text>small</Text>
55
- </View>
56
- <View variant="card" padding="large">
57
- <Text>large</Text>
58
- </View>
59
- <View variant="card" padding="small" paddingStart="large">
60
- <Text>start</Text>
61
- </View>
62
- </View>
63
- </View>
@@ -1,36 +0,0 @@
1
- import state from './state';
2
-
3
- export default definePage({
4
- initialState: state,
5
- mutations: {
6
- choose: (state, event: DotEvent<unknown, { id: string }>) => {
7
- const account = state.accounts.find((candidate) => candidate.id === event.data.id);
8
- return { chosen: account?.name ?? '' };
9
- },
10
- openPayment: (state, event: DotEvent<unknown, { id: string }>) => ({
11
- selected: state.payments.find((payment) => payment.id === event.data.id) ?? null,
12
- }),
13
- closeSheet: () => ({ selected: null }),
14
- clearToast: () => ({ toast: '' }),
15
- },
16
- actions: {
17
- async copyReference(state) {
18
- if (!state.selected) {
19
- return;
20
- }
21
- await this.dash.system.copyText(state.selected.reference);
22
- this.setState({ selected: null, toast: 'Reference copied' });
23
- },
24
- async shareReceipt(state) {
25
- if (!state.selected) {
26
- return;
27
- }
28
- const { title, amount, status, reference } = state.selected;
29
- this.setState({ selected: null });
30
- await this.dash.system.share({
31
- title: `${title} receipt`,
32
- text: `${title}: ${amount}, ${status}. Reference ${reference}.`,
33
- });
34
- },
35
- },
36
- });
@@ -1,96 +0,0 @@
1
- export interface Account {
2
- id: string;
3
- name: string;
4
- number: string;
5
- balance: string;
6
- icon: string;
7
- }
8
-
9
- export interface Payment {
10
- id: string;
11
- title: string;
12
- date: string;
13
- amount: string;
14
- status: string;
15
- tone: string;
16
- reference: string;
17
- }
18
-
19
- export default {
20
- accounts: [
21
- {
22
- id: 'savings',
23
- name: 'Savings',
24
- number: '•••• 2041',
25
- balance: 'Le 1,250,000',
26
- icon: 'bank',
27
- },
28
- {
29
- id: 'wallet',
30
- name: 'Mobile wallet',
31
- number: '076 •••• 21',
32
- balance: 'Le 84,500',
33
- icon: 'mobile',
34
- },
35
- { id: 'card', name: 'Debit card', number: '•••• 7730', balance: 'Le 310,000', icon: 'card' },
36
- ] as Account[],
37
- payments: [
38
- {
39
- id: 'p1',
40
- title: 'Electricity',
41
- date: 'Today',
42
- amount: 'Le 50,000',
43
- status: 'Paid',
44
- tone: 'success',
45
- reference: 'EDSA-58213',
46
- },
47
- {
48
- id: 'p2',
49
- title: 'Airtime',
50
- date: 'Yesterday',
51
- amount: 'Le 10,000',
52
- status: 'Pending',
53
- tone: 'warning',
54
- reference: 'AIR-11907',
55
- },
56
- {
57
- id: 'p3',
58
- title: 'Water',
59
- date: '12 September',
60
- amount: 'Le 35,000',
61
- status: 'Failed',
62
- tone: 'danger',
63
- reference: 'GVWC-40022',
64
- },
65
- ] as Payment[],
66
- chosen: '',
67
- // The payment whose actions the sheet shows.
68
- selected: null as Payment | null,
69
- toast: '',
70
- icons: [
71
- 'home',
72
- 'search',
73
- 'bell',
74
- 'user',
75
- 'settings',
76
- 'wallet',
77
- 'bank',
78
- 'card',
79
- 'cash',
80
- 'send',
81
- 'receipt',
82
- 'qr-code',
83
- 'bolt',
84
- 'water',
85
- 'phone',
86
- 'mail',
87
- 'calendar',
88
- 'clock',
89
- 'location',
90
- 'lock',
91
- 'share',
92
- 'copy',
93
- 'download',
94
- 'star',
95
- ],
96
- };
@@ -1,59 +0,0 @@
1
- <View>
2
- <Text variant="title">Lists and icons</Text>
3
- <Text>A List draws rows in a card. A row shows an icon or a picture, a value or anything at its end, and a chevron when it can be tapped.</Text>
4
-
5
- <View gap="small">
6
- <Text variant="caption" tone="muted">Rows know which one was tapped from their data- attributes</Text>
7
- <List>
8
- <For each="{{ accounts }}" item="account" key="id">
9
- <ListItem icon="{{ account.icon }}" title="{{ account.name }}" subtitle="{{ account.number }}" value="{{ account.balance }}" data-id="{{ account.id }}" onTap="choose" />
10
- </For>
11
- </List>
12
- <If condition="{{ chosen }}">
13
- <Text>You chose {{ chosen }}</Text>
14
- </If>
15
- </View>
16
-
17
- <View gap="small">
18
- <Text variant="caption" tone="muted">A badge at the end of each row; tap one for its actions</Text>
19
- <List>
20
- <For each="{{ payments }}" item="payment" key="id">
21
- <ListItem title="{{ payment.title }}" subtitle="{{ payment.date }} · {{ payment.amount }}" data-id="{{ payment.id }}" onTap="openPayment">
22
- <Badge tone="{{ payment.tone }}">{{ payment.status }}</Badge>
23
- </ListItem>
24
- </For>
25
- </List>
26
- </View>
27
-
28
- <View gap="small">
29
- <Text variant="caption" tone="muted">Icons, by name, in any tone</Text>
30
- <View variant="card" direction="row" wrap gap="large">
31
- <For each="{{ icons }}" item="icon" key="*this">
32
- <Icon name="{{ icon }}" />
33
- </For>
34
- </View>
35
- <View variant="card" direction="row" wrap gap="large" align="center">
36
- <Icon name="info" tone="info" size="small" />
37
- <Icon name="success" tone="success" />
38
- <Icon name="warning" tone="warning" size="large" />
39
- <Icon name="error" tone="danger" size="large" />
40
- <Icon name="star" tone="muted" />
41
- </View>
42
- </View>
43
-
44
- <View gap="small">
45
- <Text variant="caption" tone="muted">A divider between things</Text>
46
- <View variant="card">
47
- <Text>Above the line</Text>
48
- <Divider />
49
- <Text>Below the line</Text>
50
- </View>
51
- </View>
52
-
53
- <Sheet open="{{ selected !== null }}" title="{{ selected.title }} · {{ selected.amount }}" onClose="closeSheet">
54
- <Button variant="secondary" onClick="copyReference">Copy reference {{ selected.reference }}</Button>
55
- <Button variant="secondary" onClick="shareReceipt">Share receipt</Button>
56
- <Button onClick="closeSheet">Cancel</Button>
57
- </Sheet>
58
- <Toast message="{{ toast }}" tone="success" onHide="clearToast" />
59
- </View>
@@ -1,42 +0,0 @@
1
- import type { HookRun } from './state';
2
- import state from './state';
3
-
4
- export default definePage({
5
- initialState: state,
6
- hooks: {
7
- // Options come from the page that opened this one, as strings.
8
- onLoad(options) {
9
- const depth = Number(options.depth ?? '1') + 1;
10
- const from = options.trail ?? 'Home';
11
- this.setState({ depth, from, trail: `${from} › ${depth}` });
12
- this.setState((current) => ({ hooks: ran(current.hooks, 'onLoad') }));
13
- },
14
- onShow() {
15
- this.setState((current) => ({ hooks: ran(current.hooks, 'onShow') }));
16
- },
17
- onHide() {
18
- this.setState((current) => ({ hooks: ran(current.hooks, 'onHide') }));
19
- },
20
- },
21
- actions: {
22
- openAnother(state) {
23
- this.navigation.push('navigation', { depth: String(state.depth), trail: state.trail });
24
- },
25
- replaceThis(state) {
26
- this.navigation.replace('navigation', { depth: String(state.depth - 1), trail: state.from });
27
- },
28
- back() {
29
- this.navigation.back();
30
- },
31
- backTwo() {
32
- this.navigation.back(2);
33
- },
34
- home() {
35
- this.navigation.reset('index');
36
- },
37
- },
38
- });
39
-
40
- function ran(hooks: readonly HookRun[], hook: string): HookRun[] {
41
- return [...hooks, { id: hooks.length + 1, hook }];
42
- }
@@ -1,13 +0,0 @@
1
- export interface HookRun {
2
- id: number;
3
- hook: string;
4
- }
5
-
6
- export default {
7
- depth: 1,
8
- maxDepth: 8,
9
- // The trail of the page that opened this one.
10
- from: '',
11
- trail: '',
12
- hooks: [] as HookRun[],
13
- };
@@ -1,24 +0,0 @@
1
- <View>
2
- <Text variant="caption" tone="muted">{{ trail }}</Text>
3
- <Text variant="title">Navigation and hooks</Text>
4
- <Text>Each page opens on top of the one before it; back returns to the one below. A dot has room for {{ maxDepth }} pages at once.</Text>
5
-
6
- <View variant="card" gap="small">
7
- <Text>This is page {{ depth }} of {{ maxDepth }}</Text>
8
- <View direction="row" wrap gap="small">
9
- <Button onClick="openAnother" disabled="{{ depth >= maxDepth }}">Open another</Button>
10
- <Button variant="secondary" onClick="replaceThis">Replace this one</Button>
11
- <Button variant="secondary" onClick="back">Back</Button>
12
- <Button variant="secondary" onClick="backTwo" disabled="{{ depth < 3 }}">Back two</Button>
13
- <Button variant="secondary" onClick="home">Start over</Button>
14
- </View>
15
- </View>
16
-
17
- <Text variant="caption" tone="muted">The hooks this page ran, in order</Text>
18
- <View variant="card" gap="small">
19
- <For each="{{ hooks }}" item="run" key="id">
20
- <Text>{{ run.id }}. {{ run.hook }}</Text>
21
- </For>
22
- <Text variant="caption" tone="muted">Open another page and come back: this one runs onHide, then onShow.</Text>
23
- </View>
24
- </View>
@@ -1,107 +0,0 @@
1
- import state from './state';
2
-
3
- const PICTURE = 'pictures/octocat.png';
4
-
5
- interface GitHubUser {
6
- login: string;
7
- name: string | null;
8
- followers: number;
9
- }
10
-
11
- interface Echo {
12
- json: unknown;
13
- files: Record<string, string>;
14
- }
15
-
16
- export default definePage({
17
- initialState: state,
18
- actions: {
19
- async fetchZen() {
20
- try {
21
- const response = await this.dash.network.http.request({
22
- url: 'https://api.github.com/zen',
23
- });
24
- this.setState({ zen: response.ok ? response.body : `GitHub answered ${response.status}` });
25
- } catch (error) {
26
- this.setState({ note: (error as Error).message });
27
- }
28
- },
29
- async fetchProfile() {
30
- try {
31
- const { body } = await this.dash.network.http.request<GitHubUser>(
32
- { url: 'https://api.github.com/users/octocat', as: 'json' },
33
- { timeout: 10_000 },
34
- );
35
- this.setState({
36
- profile: { login: body.login, name: body.name ?? body.login, followers: body.followers },
37
- });
38
- } catch (error) {
39
- this.setState({ note: (error as Error).message });
40
- }
41
- },
42
- async sendJson() {
43
- try {
44
- const { body } = await this.dash.network.http.request<Echo>({
45
- url: 'https://httpbin.org/post',
46
- method: 'POST',
47
- body: { item: 'rice', count: 2 },
48
- as: 'json',
49
- });
50
- this.setState({ echo: JSON.stringify(body.json) });
51
- } catch (error) {
52
- this.setState({ note: (error as Error).message });
53
- }
54
- },
55
- async download() {
56
- try {
57
- const response = await this.dash.network.http.download({
58
- url: 'https://avatars.githubusercontent.com/u/583231?s=128',
59
- name: 'octocat.png',
60
- });
61
- if (response.ok) {
62
- const { id, url, size } = response.file;
63
- this.setState({ picture: { id, url, size }, kept: false });
64
- } else {
65
- this.setState({ note: `GitHub answered ${response.status}` });
66
- }
67
- } catch (error) {
68
- this.setState({ note: (error as Error).message });
69
- }
70
- },
71
- async upload(state) {
72
- try {
73
- const { body } = await this.dash.network.http.upload<Echo>({
74
- url: 'https://httpbin.org/post',
75
- fields: { title: 'Octocat' },
76
- files: [{ field: 'picture', file: state.picture.id }],
77
- as: 'json',
78
- });
79
- this.setState({ uploaded: Object.keys(body.files).join(', ') });
80
- } catch (error) {
81
- this.setState({ note: (error as Error).message });
82
- }
83
- },
84
- async sharePicture(state) {
85
- try {
86
- await this.dash.system.share({ file: state.picture.id });
87
- } catch (error) {
88
- this.setState({ note: (error as Error).message });
89
- }
90
- },
91
- async keep(state) {
92
- try {
93
- await this.dash.file.save(state.picture.id, PICTURE, { overwrite: true });
94
- this.setState({ kept: true });
95
- } catch (error) {
96
- this.setState({ note: (error as Error).message });
97
- }
98
- },
99
- async tryUnlistedHost() {
100
- try {
101
- await this.dash.network.http.request({ url: 'https://example.com' });
102
- } catch (error) {
103
- this.setState({ note: (error as Error).message });
104
- }
105
- },
106
- },
107
- });
@@ -1,15 +0,0 @@
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
- };
@@ -1,56 +0,0 @@
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>
@@ -1,33 +0,0 @@
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>
@@ -1,10 +0,0 @@
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
- });
@@ -1,7 +0,0 @@
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
- };
@@ -1,49 +0,0 @@
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>