@trypattern/sdk 0.0.0-stage → 0.1.1

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 (273) hide show
  1. package/README.md +127 -2
  2. package/dist/access.d.ts +31 -0
  3. package/dist/access.js +72 -0
  4. package/dist/actions.d.ts +57 -0
  5. package/dist/actions.js +198 -0
  6. package/dist/api.d.ts +30 -0
  7. package/dist/api.js +60 -0
  8. package/dist/app.d.ts +115 -0
  9. package/dist/app.js +266 -0
  10. package/dist/appInfo.d.ts +35 -0
  11. package/dist/appInfo.js +67 -0
  12. package/dist/appTitle.d.ts +6 -0
  13. package/dist/appTitle.js +3 -0
  14. package/dist/appearance.d.ts +7 -0
  15. package/dist/appearance.js +2 -0
  16. package/dist/auth/sessionApi.d.ts +41 -0
  17. package/dist/auth/sessionApi.js +158 -0
  18. package/dist/auth/sessionStore.d.ts +20 -0
  19. package/dist/auth/sessionStore.js +40 -0
  20. package/dist/auth/user.d.ts +11 -0
  21. package/dist/auth/user.js +9 -0
  22. package/dist/builtins/Account.d.ts +25 -0
  23. package/dist/builtins/Account.js +15 -0
  24. package/dist/builtins/AppSettings.d.ts +12 -0
  25. package/dist/builtins/AppSettings.js +31 -0
  26. package/dist/builtins/Palette.d.ts +29 -0
  27. package/dist/builtins/Palette.js +63 -0
  28. package/dist/builtins/SignIn.d.ts +28 -0
  29. package/dist/builtins/SignIn.js +60 -0
  30. package/dist/builtins/Toasts.d.ts +32 -0
  31. package/dist/builtins/Toasts.js +25 -0
  32. package/dist/builtins/actions.d.ts +2 -0
  33. package/dist/builtins/actions.js +45 -0
  34. package/dist/cache.d.ts +24 -0
  35. package/dist/cache.js +112 -0
  36. package/dist/cli/app.d.ts +2 -0
  37. package/dist/cli/app.js +1406 -0
  38. package/dist/cli/publishing.d.ts +21 -0
  39. package/dist/cli/publishing.js +493 -0
  40. package/dist/cli/screenshot.d.ts +1 -0
  41. package/dist/cli/screenshot.js +96 -0
  42. package/dist/cli/tools.d.ts +12 -0
  43. package/dist/cli/tools.js +35 -0
  44. package/dist/clock.d.ts +6 -0
  45. package/dist/clock.js +31 -0
  46. package/dist/components/AppFrame.d.ts +14 -0
  47. package/dist/components/AppFrame.js +64 -0
  48. package/dist/components/AppearancePicker.d.ts +1 -0
  49. package/dist/components/AppearancePicker.js +12 -0
  50. package/dist/components/Avatar.d.ts +9 -0
  51. package/dist/components/Avatar.js +63 -0
  52. package/dist/components/Badge.d.ts +11 -0
  53. package/dist/components/Badge.js +87 -0
  54. package/dist/components/Button.d.ts +24 -0
  55. package/dist/components/Button.js +252 -0
  56. package/dist/components/Card.d.ts +12 -0
  57. package/dist/components/Card.js +38 -0
  58. package/dist/components/CommandMenu.d.ts +23 -0
  59. package/dist/components/CommandMenu.js +214 -0
  60. package/dist/components/CommandPalette.d.ts +1 -0
  61. package/dist/components/CommandPalette.js +7 -0
  62. package/dist/components/Content.d.ts +7 -0
  63. package/dist/components/Content.js +24 -0
  64. package/dist/components/ContextMenu.d.ts +8 -0
  65. package/dist/components/ContextMenu.js +23 -0
  66. package/dist/components/CopyButton.d.ts +11 -0
  67. package/dist/components/CopyButton.js +16 -0
  68. package/dist/components/Dialog.d.ts +11 -0
  69. package/dist/components/Dialog.js +81 -0
  70. package/dist/components/Divider.d.ts +7 -0
  71. package/dist/components/Divider.js +30 -0
  72. package/dist/components/EmptyState.d.ts +8 -0
  73. package/dist/components/EmptyState.js +24 -0
  74. package/dist/components/Form.d.ts +9 -0
  75. package/dist/components/Form.js +23 -0
  76. package/dist/components/Icon.d.ts +10 -0
  77. package/dist/components/Icon.js +22 -0
  78. package/dist/components/IconButton.d.ts +14 -0
  79. package/dist/components/IconButton.js +53 -0
  80. package/dist/components/Kbd.d.ts +6 -0
  81. package/dist/components/Kbd.js +67 -0
  82. package/dist/components/Link.d.ts +14 -0
  83. package/dist/components/Link.js +44 -0
  84. package/dist/components/ListRow.d.ts +12 -0
  85. package/dist/components/ListRow.js +62 -0
  86. package/dist/components/LoadingRows.d.ts +5 -0
  87. package/dist/components/LoadingRows.js +6 -0
  88. package/dist/components/Menu.d.ts +12 -0
  89. package/dist/components/Menu.js +33 -0
  90. package/dist/components/MenuItems.d.ts +21 -0
  91. package/dist/components/MenuItems.js +32 -0
  92. package/dist/components/Placement.d.ts +21 -0
  93. package/dist/components/Placement.js +1 -0
  94. package/dist/components/Popup.d.ts +8 -0
  95. package/dist/components/Popup.js +43 -0
  96. package/dist/components/PopupItem.d.ts +8 -0
  97. package/dist/components/PopupItem.js +51 -0
  98. package/dist/components/PropertyRow.d.ts +7 -0
  99. package/dist/components/PropertyRow.js +23 -0
  100. package/dist/components/RadioGroup.d.ts +18 -0
  101. package/dist/components/RadioGroup.js +85 -0
  102. package/dist/components/Row.d.ts +16 -0
  103. package/dist/components/Row.js +27 -0
  104. package/dist/components/Screen.d.ts +13 -0
  105. package/dist/components/Screen.js +56 -0
  106. package/dist/components/Scrim.d.ts +8 -0
  107. package/dist/components/Scrim.js +40 -0
  108. package/dist/components/ScrollArea.d.ts +15 -0
  109. package/dist/components/ScrollArea.js +13 -0
  110. package/dist/components/SegmentedControl.d.ts +17 -0
  111. package/dist/components/SegmentedControl.js +68 -0
  112. package/dist/components/Select.d.ts +17 -0
  113. package/dist/components/Select.js +107 -0
  114. package/dist/components/SettingsRow.d.ts +8 -0
  115. package/dist/components/SettingsRow.js +32 -0
  116. package/dist/components/Sidebar.d.ts +20 -0
  117. package/dist/components/Sidebar.js +137 -0
  118. package/dist/components/SignInScreen.d.ts +1 -0
  119. package/dist/components/SignInScreen.js +40 -0
  120. package/dist/components/Size.d.ts +1 -0
  121. package/dist/components/Size.js +1 -0
  122. package/dist/components/Skeleton.d.ts +8 -0
  123. package/dist/components/Skeleton.js +48 -0
  124. package/dist/components/Spinner.d.ts +6 -0
  125. package/dist/components/Spinner.js +54 -0
  126. package/dist/components/Stack.d.ts +14 -0
  127. package/dist/components/Stack.js +19 -0
  128. package/dist/components/Switch.d.ts +10 -0
  129. package/dist/components/Switch.js +72 -0
  130. package/dist/components/Text.d.ts +21 -0
  131. package/dist/components/Text.js +77 -0
  132. package/dist/components/TextField.d.ts +25 -0
  133. package/dist/components/TextField.js +68 -0
  134. package/dist/components/Toaster.d.ts +1 -0
  135. package/dist/components/Toaster.js +83 -0
  136. package/dist/components/Tooltip.d.ts +8 -0
  137. package/dist/components/Tooltip.js +43 -0
  138. package/dist/components/controlLook.d.ts +70 -0
  139. package/dist/components/controlLook.js +80 -0
  140. package/dist/components/frame.d.ts +4 -0
  141. package/dist/components/frame.js +2 -0
  142. package/dist/components/icons.d.ts +59 -0
  143. package/dist/components/icons.js +111 -0
  144. package/dist/components/interaction.d.ts +12 -0
  145. package/dist/components/interaction.js +22 -0
  146. package/dist/components/spacing.d.ts +118 -0
  147. package/dist/components/spacing.js +46 -0
  148. package/dist/components/tones.d.ts +28 -0
  149. package/dist/components/tones.js +12 -0
  150. package/dist/entityStore.d.ts +46 -0
  151. package/dist/entityStore.js +160 -0
  152. package/dist/flows/accessFlows.d.ts +9 -0
  153. package/dist/flows/accessFlows.js +167 -0
  154. package/dist/flows/browser.d.ts +34 -0
  155. package/dist/flows/browser.js +167 -0
  156. package/dist/flows/contactSheet.d.ts +1 -0
  157. package/dist/flows/contactSheet.js +63 -0
  158. package/dist/flows/flowBrowser.d.ts +25 -0
  159. package/dist/flows/flowBrowser.js +23 -0
  160. package/dist/flows/flowSetup.d.ts +3 -0
  161. package/dist/flows/flowSetup.js +35 -0
  162. package/dist/flows/flows.d.ts +47 -0
  163. package/dist/flows/flows.js +175 -0
  164. package/dist/flows/screenshotName.d.ts +1 -0
  165. package/dist/flows/screenshotName.js +6 -0
  166. package/dist/gate.d.ts +8 -0
  167. package/dist/gate.js +52 -0
  168. package/dist/hooks/appContext.d.ts +15 -0
  169. package/dist/hooks/appContext.js +5 -0
  170. package/dist/hooks/appHooks.d.ts +21 -0
  171. package/dist/hooks/appHooks.js +24 -0
  172. package/dist/hooks/useAnimatesOnChange.d.ts +1 -0
  173. package/dist/hooks/useAnimatesOnChange.js +14 -0
  174. package/dist/hooks/useStoreState.d.ts +6 -0
  175. package/dist/hooks/useStoreState.js +5 -0
  176. package/dist/index.d.ts +44 -0
  177. package/dist/index.js +21 -0
  178. package/dist/memoryApi.d.ts +19 -0
  179. package/dist/memoryApi.js +42 -0
  180. package/dist/model.d.ts +94 -0
  181. package/dist/model.js +243 -0
  182. package/dist/page.d.ts +11 -0
  183. package/dist/page.js +9 -0
  184. package/dist/platform.d.ts +1 -0
  185. package/dist/platform.js +5 -0
  186. package/dist/publishWire.d.ts +271 -0
  187. package/dist/publishWire.js +168 -0
  188. package/dist/react.d.ts +49 -0
  189. package/dist/react.js +40 -0
  190. package/dist/registered.d.ts +60 -0
  191. package/dist/registered.js +19 -0
  192. package/dist/routes.d.ts +38 -0
  193. package/dist/routes.js +21 -0
  194. package/dist/rules/checkAllFiles.d.ts +1 -0
  195. package/dist/rules/checkAllFiles.js +749 -0
  196. package/dist/rules/checkApiRouting.d.ts +1 -0
  197. package/dist/rules/checkApiRouting.js +112 -0
  198. package/dist/rules/lintPlugin.d.ts +252 -0
  199. package/dist/rules/lintPlugin.js +1159 -0
  200. package/dist/rules/messages.d.ts +48 -0
  201. package/dist/rules/messages.js +48 -0
  202. package/dist/rules/themeTokens.d.ts +6 -0
  203. package/dist/rules/themeTokens.js +64 -0
  204. package/dist/schema.d.ts +4 -0
  205. package/dist/schema.js +2 -0
  206. package/dist/server/auth.d.ts +115 -0
  207. package/dist/server/auth.js +134 -0
  208. package/dist/server/authService.d.ts +9 -0
  209. package/dist/server/authService.js +50 -0
  210. package/dist/server/createServer.d.ts +402 -0
  211. package/dist/server/createServer.js +82 -0
  212. package/dist/server/env.d.ts +15 -0
  213. package/dist/server/env.js +1 -0
  214. package/dist/server/index.d.ts +13 -0
  215. package/dist/server/index.js +9 -0
  216. package/dist/server/services.d.ts +9 -0
  217. package/dist/server/services.js +47 -0
  218. package/dist/server/session.d.ts +29 -0
  219. package/dist/server/session.js +65 -0
  220. package/dist/server/sessions.d.ts +92 -0
  221. package/dist/server/sessions.js +47 -0
  222. package/dist/server/settings.d.ts +49 -0
  223. package/dist/server/settings.js +25 -0
  224. package/dist/server/signInWire.d.ts +53 -0
  225. package/dist/server/signInWire.js +23 -0
  226. package/dist/server/tables.d.ts +242 -0
  227. package/dist/server/tables.js +246 -0
  228. package/dist/server/users.d.ts +189 -0
  229. package/dist/server/users.js +49 -0
  230. package/dist/serviceClients.d.ts +5 -0
  231. package/dist/serviceClients.js +70 -0
  232. package/dist/services.d.ts +53 -0
  233. package/dist/services.js +30 -0
  234. package/dist/shortcuts.d.ts +3 -0
  235. package/dist/shortcuts.js +40 -0
  236. package/dist/start.d.ts +20 -0
  237. package/dist/start.js +145 -0
  238. package/dist/state.d.ts +14 -0
  239. package/dist/state.js +17 -0
  240. package/dist/store.d.ts +45 -0
  241. package/dist/store.js +208 -0
  242. package/dist/subscribers.d.ts +5 -0
  243. package/dist/subscribers.js +13 -0
  244. package/dist/table.d.ts +143 -0
  245. package/dist/table.js +91 -0
  246. package/dist/tables.d.ts +77 -0
  247. package/dist/tables.js +216 -0
  248. package/dist/theme/reset.css +84 -0
  249. package/dist/theme/scales.d.ts +76 -0
  250. package/dist/theme/scales.js +82 -0
  251. package/dist/theme/tokens.stylex.d.ts +218 -0
  252. package/dist/theme/tokens.stylex.js +233 -0
  253. package/dist/vite/commandBridge.d.ts +2 -0
  254. package/dist/vite/commandBridge.js +46 -0
  255. package/dist/vite/designManifest.d.ts +25 -0
  256. package/dist/vite/designManifest.js +191 -0
  257. package/dist/vite/localWorker.d.ts +4 -0
  258. package/dist/vite/localWorker.js +60 -0
  259. package/dist/vite/projectFile.d.ts +9 -0
  260. package/dist/vite/projectFile.js +17 -0
  261. package/dist/vite/rootAlias.d.ts +2 -0
  262. package/dist/vite/rootAlias.js +15 -0
  263. package/dist/vite/vite.d.ts +8 -0
  264. package/dist/vite/vite.js +95 -0
  265. package/dist/wire.d.ts +7 -0
  266. package/dist/wire.js +1 -0
  267. package/package.json +103 -3
  268. package/presets/lintPlugin.js +7 -0
  269. package/presets/oxlint.json +167 -0
  270. package/presets/register.d.ts +21 -0
  271. package/presets/server.d.ts +2 -0
  272. package/presets/tsconfig.app.json +29 -0
  273. package/presets/tsconfig.server.json +27 -0
@@ -0,0 +1,168 @@
1
+ import { z } from 'zod';
2
+ import { appTitle } from "./appTitle.js";
3
+ export { appTitle };
4
+ import { call, defineServices } from "./services.js";
5
+ export const DASHBOARD_URL = 'https://onpattern.app';
6
+ export const APPS_DOMAIN = 'onpattern.app';
7
+ export const UPLOAD_LIMIT_BYTES = 50 * 1024 * 1024;
8
+ export const UPLOAD_LIMIT_PARTS = 5000;
9
+ const RESERVED_NAMES = new Set([
10
+ 'auth',
11
+ 'www',
12
+ 'api',
13
+ 'admin',
14
+ 'app',
15
+ 'apps',
16
+ 'dashboard',
17
+ 'deploy',
18
+ 'publish',
19
+ 'onpattern',
20
+ 'trypattern',
21
+ 'mail',
22
+ 'login',
23
+ 'help',
24
+ 'docs',
25
+ 'status',
26
+ 'support',
27
+ 'blog',
28
+ 'dev',
29
+ 'test',
30
+ 'staging',
31
+ 'cdn',
32
+ 'static',
33
+ 'assets',
34
+ 'dispatch',
35
+ 'start',
36
+ 'approve'
37
+ ]);
38
+ export function nameProblem(name) {
39
+ if (!/^[a-z][a-z0-9-]{1,28}[a-z0-9]$/.test(name)) {
40
+ return 'Use 3 to 30 lowercase letters, numbers and hyphens, starting with a letter.';
41
+ }
42
+ if (name.includes('--'))
43
+ return 'Use one hyphen at a time.';
44
+ if (RESERVED_NAMES.has(name) || name.startsWith('pattern')) {
45
+ return 'That address is reserved.';
46
+ }
47
+ return undefined;
48
+ }
49
+ export const appName = z.string().superRefine((name, context) => {
50
+ const problem = nameProblem(name);
51
+ if (problem !== undefined)
52
+ context.addIssue({ code: 'custom', message: problem });
53
+ });
54
+ export function hostnameOf(name) {
55
+ return `${name}.${APPS_DOMAIN}`;
56
+ }
57
+ const PRIVATE_NAMES = new Set([
58
+ '.git',
59
+ 'node_modules',
60
+ 'dist',
61
+ '.dev',
62
+ '.wrangler',
63
+ '.dev.vars',
64
+ '.DS_Store'
65
+ ]);
66
+ export function isPrivatePath(path) {
67
+ return path.split('/').some((part) => {
68
+ if (PRIVATE_NAMES.has(part))
69
+ return true;
70
+ if (part.startsWith('.env') && part !== '.env.example')
71
+ return true;
72
+ return part.endsWith('.local') || part.endsWith('.log');
73
+ });
74
+ }
75
+ export function sourcePathProblem(path) {
76
+ if (path === '' || path.startsWith('/') || path.includes('\\')) {
77
+ return `${path} is not a relative path`;
78
+ }
79
+ if (path.split('/').some((part) => part === '' || part === '.' || part === '..')) {
80
+ return `${path} leaves the project`;
81
+ }
82
+ if (isPrivatePath(path))
83
+ return `${path} must never leave the laptop`;
84
+ return undefined;
85
+ }
86
+ export const UPLOAD = {
87
+ worker: 'worker/',
88
+ client: 'client/',
89
+ migrations: 'migrations/',
90
+ source: 'source/',
91
+ compatibilityDate: 'compatibilityDate',
92
+ sdkVersion: 'sdkVersion'
93
+ };
94
+ export const publishStep = z.enum(['reserve', 'database', 'sign-in', 'publish']);
95
+ export const publishStatus = z.enum(['running', 'live', 'failed']);
96
+ export const publishSummary = z.object({
97
+ number: z.number(),
98
+ status: publishStatus,
99
+ step: publishStep,
100
+ error: z.string().nullable(),
101
+ byEmail: z.string(),
102
+ restoredFrom: z.number().nullable(),
103
+ isStarter: z.boolean(),
104
+ startedAt: z.string(),
105
+ finishedAt: z.string().nullable()
106
+ });
107
+ export const appSummary = z.object({
108
+ name: z.string(),
109
+ title: z.string(),
110
+ url: z.string(),
111
+ pulledAt: z.string().nullable(),
112
+ latest: publishSummary.nullable()
113
+ });
114
+ export const nameSuggestion = z.object({
115
+ name: z.string(),
116
+ available: z.boolean(),
117
+ problem: z.string().nullable()
118
+ });
119
+ export const loginStarted = z.object({
120
+ secret: z.string(),
121
+ code: z.string(),
122
+ url: z.string()
123
+ });
124
+ export const loginPoll = z.union([
125
+ z.object({ status: z.literal('waiting') }),
126
+ z.object({ status: z.literal('approved'), cookie: z.string() })
127
+ ]);
128
+ export const loginToApprove = z.object({ code: z.string(), label: z.string() });
129
+ export const publishServices = defineServices({
130
+ apps: {
131
+ list: call({ get: '/apps', reply: z.array(appSummary) }),
132
+ read: call({ get: '/apps/:name', reply: appSummary }),
133
+ create: call({
134
+ post: '/apps',
135
+ input: { name: appName, title: appTitle },
136
+ reply: appSummary
137
+ })
138
+ },
139
+ names: {
140
+ suggest: call({
141
+ get: '/names',
142
+ input: { title: z.string() },
143
+ reply: z.array(nameSuggestion)
144
+ }),
145
+ check: call({ get: '/names/:name', reply: nameSuggestion })
146
+ },
147
+ publishes: {
148
+ list: call({
149
+ get: '/apps/:name/publishes',
150
+ reply: z.array(publishSummary)
151
+ }),
152
+ read: call({
153
+ get: '/apps/:name/publishes/:number',
154
+ reply: publishSummary
155
+ }),
156
+ retry: call({
157
+ post: '/apps/:name/publishes/:number/retry',
158
+ reply: publishSummary
159
+ })
160
+ },
161
+ logins: {
162
+ read: call({ get: '/cli/logins/:approval', reply: loginToApprove }),
163
+ approve: call({
164
+ post: '/cli/logins/:approval/approve',
165
+ reply: z.object({ ok: z.boolean() })
166
+ })
167
+ }
168
+ });
@@ -0,0 +1,49 @@
1
+ export { AppProvider, useModel } from './hooks/appContext.ts';
2
+ export { AppFrame } from './components/AppFrame.tsx';
3
+ export { AppearancePicker } from './components/AppearancePicker.tsx';
4
+ export { Avatar } from './components/Avatar.tsx';
5
+ export { Badge } from './components/Badge.tsx';
6
+ export { Button } from './components/Button.tsx';
7
+ export { Card } from './components/Card.tsx';
8
+ export { CommandMenu } from './components/CommandMenu.tsx';
9
+ export { CommandPalette } from './components/CommandPalette.tsx';
10
+ export type { CommandMenuItem } from './components/CommandMenu.tsx';
11
+ export { Content } from './components/Content.tsx';
12
+ export { ContextMenu } from './components/ContextMenu.tsx';
13
+ export { CopyButton } from './components/CopyButton.tsx';
14
+ export { Dialog } from './components/Dialog.tsx';
15
+ export { Divider } from './components/Divider.tsx';
16
+ export { EmptyState } from './components/EmptyState.tsx';
17
+ export { Form } from './components/Form.tsx';
18
+ export { Icon } from './components/Icon.tsx';
19
+ export { IconButton } from './components/IconButton.tsx';
20
+ export type { IconName } from './components/icons.ts';
21
+ export { Kbd } from './components/Kbd.tsx';
22
+ export { Link } from './components/Link.tsx';
23
+ export { ListRow } from './components/ListRow.tsx';
24
+ export { LoadingRows } from './components/LoadingRows.tsx';
25
+ export { Menu } from './components/Menu.tsx';
26
+ export type { MenuEntry } from './components/MenuItems.tsx';
27
+ export type { SidebarLink } from './components/Sidebar.tsx';
28
+ export type { Placement } from './components/Placement.ts';
29
+ export { PropertyRow } from './components/PropertyRow.tsx';
30
+ export { RadioGroup } from './components/RadioGroup.tsx';
31
+ export type { RadioOption } from './components/RadioGroup.tsx';
32
+ export { Row } from './components/Row.tsx';
33
+ export { Screen } from './components/Screen.tsx';
34
+ export { ScrollArea } from './components/ScrollArea.tsx';
35
+ export { SegmentedControl } from './components/SegmentedControl.tsx';
36
+ export type { SegmentedOption } from './components/SegmentedControl.tsx';
37
+ export { Select } from './components/Select.tsx';
38
+ export type { SelectOption } from './components/Select.tsx';
39
+ export { SettingsRow } from './components/SettingsRow.tsx';
40
+ export { SignInScreen } from './components/SignInScreen.tsx';
41
+ export { Skeleton } from './components/Skeleton.tsx';
42
+ export type { SpaceName } from './components/spacing.ts';
43
+ export { Spinner } from './components/Spinner.tsx';
44
+ export { Stack } from './components/Stack.tsx';
45
+ export { Switch } from './components/Switch.tsx';
46
+ export { Text } from './components/Text.tsx';
47
+ export { TextField } from './components/TextField.tsx';
48
+ export { Toaster } from './components/Toaster.tsx';
49
+ export { Tooltip } from './components/Tooltip.tsx';
package/dist/react.js ADDED
@@ -0,0 +1,40 @@
1
+ export { AppProvider, useModel } from "./hooks/appContext.js";
2
+ export { AppFrame } from "./components/AppFrame.js";
3
+ export { AppearancePicker } from "./components/AppearancePicker.js";
4
+ export { Avatar } from "./components/Avatar.js";
5
+ export { Badge } from "./components/Badge.js";
6
+ export { Button } from "./components/Button.js";
7
+ export { Card } from "./components/Card.js";
8
+ export { CommandMenu } from "./components/CommandMenu.js";
9
+ export { CommandPalette } from "./components/CommandPalette.js";
10
+ export { Content } from "./components/Content.js";
11
+ export { ContextMenu } from "./components/ContextMenu.js";
12
+ export { CopyButton } from "./components/CopyButton.js";
13
+ export { Dialog } from "./components/Dialog.js";
14
+ export { Divider } from "./components/Divider.js";
15
+ export { EmptyState } from "./components/EmptyState.js";
16
+ export { Form } from "./components/Form.js";
17
+ export { Icon } from "./components/Icon.js";
18
+ export { IconButton } from "./components/IconButton.js";
19
+ export { Kbd } from "./components/Kbd.js";
20
+ export { Link } from "./components/Link.js";
21
+ export { ListRow } from "./components/ListRow.js";
22
+ export { LoadingRows } from "./components/LoadingRows.js";
23
+ export { Menu } from "./components/Menu.js";
24
+ export { PropertyRow } from "./components/PropertyRow.js";
25
+ export { RadioGroup } from "./components/RadioGroup.js";
26
+ export { Row } from "./components/Row.js";
27
+ export { Screen } from "./components/Screen.js";
28
+ export { ScrollArea } from "./components/ScrollArea.js";
29
+ export { SegmentedControl } from "./components/SegmentedControl.js";
30
+ export { Select } from "./components/Select.js";
31
+ export { SettingsRow } from "./components/SettingsRow.js";
32
+ export { SignInScreen } from "./components/SignInScreen.js";
33
+ export { Skeleton } from "./components/Skeleton.js";
34
+ export { Spinner } from "./components/Spinner.js";
35
+ export { Stack } from "./components/Stack.js";
36
+ export { Switch } from "./components/Switch.js";
37
+ export { Text } from "./components/Text.js";
38
+ export { TextField } from "./components/TextField.js";
39
+ export { Toaster } from "./components/Toaster.js";
40
+ export { Tooltip } from "./components/Tooltip.js";
@@ -0,0 +1,60 @@
1
+ import type { AppSnapshotShape, ModelServicesOf, NavigateCommand, PressKeyCommand, StoreClasses, StoreInstances, StoresOf } from './app.ts';
2
+ import { z } from 'zod';
3
+ import type { Action, DefineActions } from './actions.ts';
4
+ import type { ServiceClient, Services } from './services.ts';
5
+ import type { Instances, MessagesOf, ModelClassLike, ModelSnapshots } from './model.ts';
6
+ import type { BUILT_IN_GROUPS } from './builtins/actions.ts';
7
+ import type { Account } from './builtins/Account.ts';
8
+ import type { AppSettings } from './builtins/AppSettings.ts';
9
+ import type { Palette } from './builtins/Palette.ts';
10
+ import type { SignIn } from './builtins/SignIn.ts';
11
+ import type { IconName } from './components/icons.ts';
12
+ import type { PageOf, PathOf, RouteShape } from './routes.ts';
13
+ import type { Tables } from './table.ts';
14
+ export interface Register {
15
+ }
16
+ type Registered<Key extends string, Fallback> = Key extends keyof Register ? Register[Key] : Fallback;
17
+ type Empty = Record<never, never>;
18
+ type RegisteredModels = Registered<'models', Empty> extends infer Classes extends Record<string, ModelClassLike> ? Classes : Empty;
19
+ type RegisteredTables = Registered<'tables', Empty> extends infer Group extends Tables ? Group : Empty;
20
+ type RegisteredStores = Registered<'stores', Empty> extends infer Classes extends StoreClasses ? Classes : Empty;
21
+ type RegisteredServices = Registered<'services', Empty> extends infer Group extends Services ? Group : Empty;
22
+ export type AppServices = ServiceClient<RegisteredServices>;
23
+ type RegisteredActionGroups = Registered<'actionGroups', readonly string[]> extends infer Groups extends readonly string[] ? Groups : readonly string[];
24
+ export type AppActionGroup = RegisteredActionGroups[number] | (typeof BUILT_IN_GROUPS)[number];
25
+ export type AppAction = Action & {
26
+ group: AppActionGroup;
27
+ icon: IconName;
28
+ };
29
+ type RegisteredAction = AppAction;
30
+ type RegisteredRoutes = Registered<'routes', readonly []> extends infer Routes extends readonly RouteShape[] ? Routes : readonly [];
31
+ type RegisteredIcons = Registered<'icons', Empty> extends infer Icons extends Record<string, unknown> ? Icons : Empty;
32
+ export type AppIconName = keyof RegisteredIcons & string;
33
+ export type BuiltInModels = {
34
+ account: typeof Account;
35
+ appSettings: typeof AppSettings;
36
+ palette: typeof Palette;
37
+ signIn: typeof SignIn;
38
+ };
39
+ export type AppModels = Instances<BuiltInModels & RegisteredModels>;
40
+ export type AppPath = PathOf<RegisteredRoutes>;
41
+ export type AppPage = PageOf<RegisteredRoutes>;
42
+ export type AppCommand = MessagesOf<AppModels> | NavigateCommand<AppPath> | PressKeyCommand;
43
+ export type AppStores = StoresOf<RegisteredTables, StoreInstances<RegisteredStores>, RegisteredAction>;
44
+ export type AppSnapshot = AppSnapshotShape<AppModels, AppStores, AppPage>;
45
+ export type ActionContext = {
46
+ readonly page: AppPage | null;
47
+ readonly models: ModelSnapshots<AppModels>;
48
+ };
49
+ export type ModelServices = ModelServicesOf<AppPath>;
50
+ export declare const Model: <S extends import("./state.ts").StateSpec = Record<never, never>, const P extends readonly (keyof S & string)[] = []>(config?: import("./model.ts").ModelConfig<S, P>) => import("./model.ts").ModelClass<AppStores, ModelServices, S, P>;
51
+ export declare const Store: <S extends import("./state.ts").StateSpec = Record<never, never>, const P extends readonly (keyof S & string)[] = []>(config: import("./store.ts").StoreConfig<S, P>) => import("./store.ts").StoreClass<S, P, ServiceClient<Empty>>;
52
+ export declare const defineActions: DefineActions<ActionContext, RegisteredAction, AppCommand>;
53
+ export declare const appPath: z.ZodCustom<AppPath, AppPath>;
54
+ type ActionInput = Pick<AppAction, 'id' | 'label' | 'group' | 'icon'> & Partial<Pick<AppAction, 'keys' | 'keywords' | 'isDanger' | 'isSearchOnly' | 'isHidden'>> & {
55
+ send: readonly AppCommand[];
56
+ };
57
+ export declare function action(input: ActionInput): AppAction & {
58
+ send: readonly AppCommand[];
59
+ };
60
+ export {};
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ import { bindActions } from "./actions.js";
3
+ import { defineModel } from "./model.js";
4
+ import { defineStore } from "./store.js";
5
+ import { isRoutedPath } from "./routes.js";
6
+ export const Model = defineModel();
7
+ export const Store = defineStore();
8
+ export const defineActions = bindActions();
9
+ export const appPath = z.custom((value) => typeof value === 'string' && isRoutedPath(value), { error: 'Not a page in src/routes.tsx' });
10
+ export function action(input) {
11
+ return {
12
+ keys: [],
13
+ keywords: '',
14
+ isDanger: false,
15
+ isSearchOnly: false,
16
+ isHidden: false,
17
+ ...input
18
+ };
19
+ }
@@ -0,0 +1,38 @@
1
+ import type { ComponentType } from 'react';
2
+ import type { RouteObject } from 'react-router';
3
+ export type RouteDefinition = {
4
+ readonly id?: string;
5
+ readonly path?: string;
6
+ readonly index?: boolean;
7
+ readonly Component?: ComponentType;
8
+ readonly children?: readonly RouteDefinition[];
9
+ };
10
+ type IdsOf<Route> = (Route extends {
11
+ readonly id: infer Id extends string;
12
+ } ? Id : never) | (Route extends {
13
+ readonly children: infer Children;
14
+ } ? PageOf<Children> : never);
15
+ export type PageOf<Routes> = Routes extends readonly (infer Route)[] ? IdsOf<Route> : never;
16
+ export type RouteShape = {
17
+ readonly id?: string;
18
+ readonly path?: string;
19
+ readonly index?: boolean;
20
+ readonly Component?: unknown;
21
+ readonly children?: readonly RouteShape[];
22
+ };
23
+ export declare function defineRoutes<const Routes extends readonly RouteShape[]>(routes: Routes): Routes;
24
+ export declare function pageIds(routes: readonly RouteDefinition[]): readonly string[];
25
+ export declare function registerRoutes(routes: readonly RouteDefinition[]): void;
26
+ export declare function isRoutedPath(path: string): boolean;
27
+ export declare function routeObjects(routes: readonly RouteDefinition[]): RouteObject[];
28
+ type Joined<Parent extends string, Path extends string> = Path extends `/${string}` ? Path : Parent extends '' | '/' ? `/${Path}` : `${Parent}/${Path}`;
29
+ type Pattern<Path extends string> = Path extends `${infer Head}:${infer Rest}` ? Rest extends `${string}/${infer Tail}` ? `${Head}${string}/${Pattern<Tail>}` : `${Head}${string}` : Path;
30
+ type PathsOfRoute<Route, Parent extends string> = Route extends {
31
+ readonly path: infer Path extends string;
32
+ } ? (Path extends '*' ? never : Pattern<Joined<Parent, Path>>) | (Route extends {
33
+ readonly children: infer Children;
34
+ } ? PathOf<Children, Joined<Parent, Path>> : never) : Route extends {
35
+ readonly children: infer Children;
36
+ } ? PathOf<Children, Parent> : never;
37
+ export type PathOf<Routes, Parent extends string = ''> = Routes extends readonly (infer Route)[] ? PathsOfRoute<Route, Parent> : never;
38
+ export {};
package/dist/routes.js ADDED
@@ -0,0 +1,21 @@
1
+ import { matchRoutes } from 'react-router';
2
+ export function defineRoutes(routes) {
3
+ return routes;
4
+ }
5
+ export function pageIds(routes) {
6
+ return routes.flatMap((route) => [
7
+ ...(route.id === undefined ? [] : [route.id]),
8
+ ...pageIds(route.children ?? [])
9
+ ]);
10
+ }
11
+ let registeredRoutes = [];
12
+ export function registerRoutes(routes) {
13
+ registeredRoutes = routeObjects(routes);
14
+ }
15
+ export function isRoutedPath(path) {
16
+ const match = matchRoutes(registeredRoutes, path)?.at(-1);
17
+ return match !== undefined && match.route.path !== '*';
18
+ }
19
+ export function routeObjects(routes) {
20
+ return routes;
21
+ }
@@ -0,0 +1 @@
1
+ export {};