@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
package/dist/model.js ADDED
@@ -0,0 +1,243 @@
1
+ var _a;
2
+ import { z } from 'zod';
3
+ import { PageStore } from "./page.js";
4
+ import { StoreBase, isDevelopment, keepEqualParts, mergeReads, plainJsonProblem, readsAreCurrent, tracked, whileBuilding } from "./store.js";
5
+ import { restore } from "./state.js";
6
+ const INPUT = Symbol('pattern.commandInput');
7
+ export function command(first, second) {
8
+ const run = typeof first === 'function' ? first : second;
9
+ if (typeof run !== 'function')
10
+ throw new Error('command() needs a handler');
11
+ const options = typeof first === 'function' ? {} : first;
12
+ const shape = typeof options === 'object' && options !== null
13
+ ? Reflect.get(options, 'input')
14
+ : undefined;
15
+ return Object.assign((input) => run(input), {
16
+ [INPUT]: z.object((shape ?? {}))
17
+ });
18
+ }
19
+ export function commandFromSchema(schema, run) {
20
+ return Object.assign((input) => run(input), {
21
+ [INPUT]: schema
22
+ });
23
+ }
24
+ function isCommand(value) {
25
+ return typeof value === 'function' && INPUT in value;
26
+ }
27
+ export function commandsOf(model) {
28
+ const found = {};
29
+ for (const [name, value] of Object.entries(model)) {
30
+ if (isCommand(value))
31
+ found[name] = value[INPUT];
32
+ }
33
+ return found;
34
+ }
35
+ function sameEntries(previous, next) {
36
+ const previousKeys = Object.keys(previous);
37
+ const nextKeys = Object.keys(next);
38
+ return (previousKeys.length === nextKeys.length &&
39
+ nextKeys.every((key) => Object.is(Reflect.get(previous, key), Reflect.get(next, key))));
40
+ }
41
+ const answerNames = new WeakMap();
42
+ export function answerNamesOf(model) {
43
+ return answerNames.get(model) ?? [];
44
+ }
45
+ function getterOf(instance, name) {
46
+ let prototype = Object.getPrototypeOf(instance);
47
+ while (prototype !== null) {
48
+ const getter = Object.getOwnPropertyDescriptor(prototype, name)?.get;
49
+ if (getter !== undefined)
50
+ return getter;
51
+ prototype = Object.getPrototypeOf(prototype);
52
+ }
53
+ return undefined;
54
+ }
55
+ export class ModelBase extends StoreBase {
56
+ stores;
57
+ app;
58
+ #memos = new Map();
59
+ #snapshot;
60
+ #published;
61
+ #isDirty = true;
62
+ constructor(stores, app) {
63
+ super();
64
+ this.stores = stores;
65
+ this.app = app;
66
+ const answers = this.#derived();
67
+ answerNames.set(this, answers);
68
+ for (const derived of answers) {
69
+ const compute = getterOf(this, derived);
70
+ if (compute === undefined)
71
+ continue;
72
+ Object.defineProperty(this, derived, {
73
+ configurable: true,
74
+ enumerable: false,
75
+ get: () => this.#evaluate(derived, compute)
76
+ });
77
+ }
78
+ for (const store of Object.values(stores)) {
79
+ store.subscribe(() => this.changed());
80
+ }
81
+ }
82
+ onPageOpen(_params) {
83
+ return undefined;
84
+ }
85
+ get params() {
86
+ const page = Reflect.get(this.stores, 'page');
87
+ return page instanceof PageStore ? page.state.params : {};
88
+ }
89
+ initialState() {
90
+ throw new Error(`${this.constructor.name} must extend Model({ state }) so its first state comes from the config`);
91
+ }
92
+ get snapshot() {
93
+ if (this.#snapshot === undefined || this.#isDirty) {
94
+ const next = this.#buildSnapshot();
95
+ const kept = this.#snapshot !== undefined && sameEntries(this.#snapshot, next)
96
+ ? this.#snapshot
97
+ : next;
98
+ if (kept !== this.#snapshot)
99
+ this.#published = undefined;
100
+ this.#snapshot = kept;
101
+ this.#isDirty = false;
102
+ }
103
+ return this.#snapshot;
104
+ }
105
+ get published() {
106
+ const snapshot = this.snapshot;
107
+ this.#published ??= this.#buildPublished(snapshot);
108
+ return this.#published;
109
+ }
110
+ changed() {
111
+ this.#isDirty = true;
112
+ const previous = this.#snapshot;
113
+ if (this.snapshot === previous)
114
+ return;
115
+ super.changed();
116
+ }
117
+ #evaluate(name, compute) {
118
+ const memo = this.#memos.get(name);
119
+ if (memo !== undefined && readsAreCurrent(memo.reads)) {
120
+ mergeReads(memo.reads);
121
+ return memo.value;
122
+ }
123
+ const { value, reads } = whileBuilding(() => tracked(() => compute.call(this)));
124
+ if (isDevelopment()) {
125
+ this.#checkPure(name, compute, value);
126
+ const problem = plainJsonProblem(value, `${name}`);
127
+ if (problem !== undefined) {
128
+ throw new Error(`${this.constructor.name} must publish plain JSON from its getters, because flows compare it: ${problem}`);
129
+ }
130
+ }
131
+ const kept = memo === undefined ? value : keepEqualParts(memo.value, value);
132
+ this.#memos.set(name, { value: kept, reads });
133
+ mergeReads(reads);
134
+ return kept;
135
+ }
136
+ #checkPure(name, compute, value) {
137
+ const again = whileBuilding(() => tracked(() => compute.call(this)).value);
138
+ if (JSON.stringify(value) !== JSON.stringify(again)) {
139
+ throw new Error(`${this.constructor.name}.${name} gave two different answers for the same state and stores, so it is not a pure getter. Getters must not read the clock, randomness or a private field.`);
140
+ }
141
+ }
142
+ #buildSnapshot() {
143
+ const snapshot = {
144
+ ...this.currentState
145
+ };
146
+ for (const name of this.#derived()) {
147
+ snapshot[name] = Reflect.get(this, name);
148
+ }
149
+ return snapshot;
150
+ }
151
+ #buildPublished(snapshot) {
152
+ const published = { ...snapshot };
153
+ for (const [name, value] of Object.entries(this)) {
154
+ if (isCommand(value))
155
+ published[name] = value;
156
+ }
157
+ return Object.freeze(published);
158
+ }
159
+ #derived() {
160
+ const names = [];
161
+ let prototype = Object.getPrototypeOf(this);
162
+ while (prototype !== null && prototype !== _a.prototype) {
163
+ for (const [name, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(prototype))) {
164
+ if (descriptor.get !== undefined && !names.includes(name)) {
165
+ names.push(name);
166
+ }
167
+ }
168
+ prototype = Object.getPrototypeOf(prototype);
169
+ }
170
+ return names;
171
+ }
172
+ }
173
+ _a = ModelBase;
174
+ export function modelSnapshotsOf(models) {
175
+ return Object.fromEntries(Object.entries(models).map(([key, model]) => [key, model.snapshot]));
176
+ }
177
+ export function defineModel() {
178
+ return function Model(config = {}) {
179
+ const persist = config.persist ?? [];
180
+ class Bound extends ModelBase {
181
+ static config = config;
182
+ #device;
183
+ constructor(stores, app, device) {
184
+ super(stores, app);
185
+ this.#device = device;
186
+ }
187
+ initialState() {
188
+ return restore(config.state ?? {}, persist, this.#device);
189
+ }
190
+ set(patch) {
191
+ super.set(patch);
192
+ for (const key of persist) {
193
+ if (key in patch)
194
+ this.#device.write(key, this.state[key]);
195
+ }
196
+ }
197
+ }
198
+ return Bound;
199
+ };
200
+ }
201
+ export function createModels(classes, stores, services, persistedFor) {
202
+ const entries = Object.entries(classes).map(([key, Class]) => {
203
+ const create = Class;
204
+ return [key, new create(stores, services, persistedFor(key))];
205
+ });
206
+ return Object.fromEntries(entries);
207
+ }
208
+ export function splitType(type) {
209
+ const dot = type.indexOf('.');
210
+ return dot === -1
211
+ ? { group: '', name: type }
212
+ : { group: type.slice(0, dot), name: type.slice(dot + 1) };
213
+ }
214
+ export function parseMessage(raw, models) {
215
+ const specs = Object.entries(models).map(([group, model]) => [group, commandsOf(model)]);
216
+ const known = specs.flatMap(([group, spec]) => Object.keys(spec).map((name) => `${group}.${name}`));
217
+ const unknown = `Unknown command ${JSON.stringify(raw)}. Commands: ${known.join(', ')}`;
218
+ if (typeof raw !== 'object' || raw === null || !('type' in raw)) {
219
+ return { error: unknown };
220
+ }
221
+ const { type, ...input } = raw;
222
+ if (typeof type !== 'string')
223
+ return { error: unknown };
224
+ const { group, name } = splitType(type);
225
+ const schema = specs.find(([key]) => key === group)?.[1][name];
226
+ if (schema === undefined)
227
+ return { error: unknown };
228
+ const parsed = schema.safeParse(input);
229
+ if (!parsed.success) {
230
+ return { error: `Command ${type}: ${z.prettifyError(parsed.error)}` };
231
+ }
232
+ return { type, ...parsed.data };
233
+ }
234
+ export function sendMessage(models, { type, ...input }) {
235
+ const { group, name } = splitType(type);
236
+ const model = models[group];
237
+ const target = model === undefined ? undefined : Reflect.get(model, name);
238
+ if (!isCommand(target)) {
239
+ return Promise.reject(new Error(`Unknown command ${type}`));
240
+ }
241
+ const run = target;
242
+ return Promise.resolve(run(input));
243
+ }
package/dist/page.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { RouteParams } from './model.ts';
2
+ import { StoreBase } from './store.ts';
3
+ type PageState = {
4
+ page: string | null;
5
+ params: RouteParams;
6
+ };
7
+ export declare class PageStore extends StoreBase<PageState> {
8
+ protected initialState(): PageState;
9
+ moved(page: string | null, params: RouteParams): void;
10
+ }
11
+ export {};
package/dist/page.js ADDED
@@ -0,0 +1,9 @@
1
+ import { StoreBase } from "./store.js";
2
+ export class PageStore extends StoreBase {
3
+ initialState() {
4
+ return { page: null, params: {} };
5
+ }
6
+ moved(page, params) {
7
+ this.set({ page, params });
8
+ }
9
+ }
@@ -0,0 +1 @@
1
+ export declare function isApplePlatform(): boolean;
@@ -0,0 +1,5 @@
1
+ export function isApplePlatform() {
2
+ if (typeof navigator === 'undefined')
3
+ return false;
4
+ return /Mac|iPhone|iPad/.test(navigator.userAgent);
5
+ }
@@ -0,0 +1,271 @@
1
+ import { z } from 'zod';
2
+ import { appTitle } from './appTitle.ts';
3
+ export { appTitle };
4
+ export declare const DASHBOARD_URL = "https://onpattern.app";
5
+ export declare const APPS_DOMAIN = "onpattern.app";
6
+ export declare const UPLOAD_LIMIT_BYTES: number;
7
+ export declare const UPLOAD_LIMIT_PARTS = 5000;
8
+ export declare function nameProblem(name: string): string | undefined;
9
+ export declare const appName: z.ZodString;
10
+ export declare function hostnameOf(name: string): string;
11
+ export declare function isPrivatePath(path: string): boolean;
12
+ export declare function sourcePathProblem(path: string): string | undefined;
13
+ export declare const UPLOAD: {
14
+ readonly worker: "worker/";
15
+ readonly client: "client/";
16
+ readonly migrations: "migrations/";
17
+ readonly source: "source/";
18
+ readonly compatibilityDate: "compatibilityDate";
19
+ readonly sdkVersion: "sdkVersion";
20
+ };
21
+ export declare const publishStep: z.ZodEnum<{
22
+ publish: "publish";
23
+ reserve: "reserve";
24
+ database: "database";
25
+ "sign-in": "sign-in";
26
+ }>;
27
+ export type PublishStep = z.output<typeof publishStep>;
28
+ export declare const publishStatus: z.ZodEnum<{
29
+ failed: "failed";
30
+ running: "running";
31
+ live: "live";
32
+ }>;
33
+ export declare const publishSummary: z.ZodObject<{
34
+ number: z.ZodNumber;
35
+ status: z.ZodEnum<{
36
+ failed: "failed";
37
+ running: "running";
38
+ live: "live";
39
+ }>;
40
+ step: z.ZodEnum<{
41
+ publish: "publish";
42
+ reserve: "reserve";
43
+ database: "database";
44
+ "sign-in": "sign-in";
45
+ }>;
46
+ error: z.ZodNullable<z.ZodString>;
47
+ byEmail: z.ZodString;
48
+ restoredFrom: z.ZodNullable<z.ZodNumber>;
49
+ isStarter: z.ZodBoolean;
50
+ startedAt: z.ZodString;
51
+ finishedAt: z.ZodNullable<z.ZodString>;
52
+ }, z.core.$strip>;
53
+ export type PublishSummary = z.output<typeof publishSummary>;
54
+ export declare const appSummary: z.ZodObject<{
55
+ name: z.ZodString;
56
+ title: z.ZodString;
57
+ url: z.ZodString;
58
+ pulledAt: z.ZodNullable<z.ZodString>;
59
+ latest: z.ZodNullable<z.ZodObject<{
60
+ number: z.ZodNumber;
61
+ status: z.ZodEnum<{
62
+ failed: "failed";
63
+ running: "running";
64
+ live: "live";
65
+ }>;
66
+ step: z.ZodEnum<{
67
+ publish: "publish";
68
+ reserve: "reserve";
69
+ database: "database";
70
+ "sign-in": "sign-in";
71
+ }>;
72
+ error: z.ZodNullable<z.ZodString>;
73
+ byEmail: z.ZodString;
74
+ restoredFrom: z.ZodNullable<z.ZodNumber>;
75
+ isStarter: z.ZodBoolean;
76
+ startedAt: z.ZodString;
77
+ finishedAt: z.ZodNullable<z.ZodString>;
78
+ }, z.core.$strip>>;
79
+ }, z.core.$strip>;
80
+ export type AppSummary = z.output<typeof appSummary>;
81
+ export declare const nameSuggestion: z.ZodObject<{
82
+ name: z.ZodString;
83
+ available: z.ZodBoolean;
84
+ problem: z.ZodNullable<z.ZodString>;
85
+ }, z.core.$strip>;
86
+ export type NameSuggestion = z.output<typeof nameSuggestion>;
87
+ export declare const loginStarted: z.ZodObject<{
88
+ secret: z.ZodString;
89
+ code: z.ZodString;
90
+ url: z.ZodString;
91
+ }, z.core.$strip>;
92
+ export declare const loginPoll: z.ZodUnion<readonly [z.ZodObject<{
93
+ status: z.ZodLiteral<"waiting">;
94
+ }, z.core.$strip>, z.ZodObject<{
95
+ status: z.ZodLiteral<"approved">;
96
+ cookie: z.ZodString;
97
+ }, z.core.$strip>]>;
98
+ export declare const loginToApprove: z.ZodObject<{
99
+ code: z.ZodString;
100
+ label: z.ZodString;
101
+ }, z.core.$strip>;
102
+ export declare const publishServices: {
103
+ readonly apps: {
104
+ readonly list: NoInfer<import("./services.ts").ServiceCall<"/apps", {}, z.ZodArray<z.ZodObject<{
105
+ name: z.ZodString;
106
+ title: z.ZodString;
107
+ url: z.ZodString;
108
+ pulledAt: z.ZodNullable<z.ZodString>;
109
+ latest: z.ZodNullable<z.ZodObject<{
110
+ number: z.ZodNumber;
111
+ status: z.ZodEnum<{
112
+ failed: "failed";
113
+ running: "running";
114
+ live: "live";
115
+ }>;
116
+ step: z.ZodEnum<{
117
+ publish: "publish";
118
+ reserve: "reserve";
119
+ database: "database";
120
+ "sign-in": "sign-in";
121
+ }>;
122
+ error: z.ZodNullable<z.ZodString>;
123
+ byEmail: z.ZodString;
124
+ restoredFrom: z.ZodNullable<z.ZodNumber>;
125
+ isStarter: z.ZodBoolean;
126
+ startedAt: z.ZodString;
127
+ finishedAt: z.ZodNullable<z.ZodString>;
128
+ }, z.core.$strip>>;
129
+ }, z.core.$strip>>>>;
130
+ readonly read: NoInfer<import("./services.ts").ServiceCall<"/apps/:name", {}, z.ZodObject<{
131
+ name: z.ZodString;
132
+ title: z.ZodString;
133
+ url: z.ZodString;
134
+ pulledAt: z.ZodNullable<z.ZodString>;
135
+ latest: z.ZodNullable<z.ZodObject<{
136
+ number: z.ZodNumber;
137
+ status: z.ZodEnum<{
138
+ failed: "failed";
139
+ running: "running";
140
+ live: "live";
141
+ }>;
142
+ step: z.ZodEnum<{
143
+ publish: "publish";
144
+ reserve: "reserve";
145
+ database: "database";
146
+ "sign-in": "sign-in";
147
+ }>;
148
+ error: z.ZodNullable<z.ZodString>;
149
+ byEmail: z.ZodString;
150
+ restoredFrom: z.ZodNullable<z.ZodNumber>;
151
+ isStarter: z.ZodBoolean;
152
+ startedAt: z.ZodString;
153
+ finishedAt: z.ZodNullable<z.ZodString>;
154
+ }, z.core.$strip>>;
155
+ }, z.core.$strip>>>;
156
+ readonly create: NoInfer<import("./services.ts").ServiceCall<"/apps", {
157
+ name: z.ZodString;
158
+ title: z.ZodString;
159
+ }, z.ZodObject<{
160
+ name: z.ZodString;
161
+ title: z.ZodString;
162
+ url: z.ZodString;
163
+ pulledAt: z.ZodNullable<z.ZodString>;
164
+ latest: z.ZodNullable<z.ZodObject<{
165
+ number: z.ZodNumber;
166
+ status: z.ZodEnum<{
167
+ failed: "failed";
168
+ running: "running";
169
+ live: "live";
170
+ }>;
171
+ step: z.ZodEnum<{
172
+ publish: "publish";
173
+ reserve: "reserve";
174
+ database: "database";
175
+ "sign-in": "sign-in";
176
+ }>;
177
+ error: z.ZodNullable<z.ZodString>;
178
+ byEmail: z.ZodString;
179
+ restoredFrom: z.ZodNullable<z.ZodNumber>;
180
+ isStarter: z.ZodBoolean;
181
+ startedAt: z.ZodString;
182
+ finishedAt: z.ZodNullable<z.ZodString>;
183
+ }, z.core.$strip>>;
184
+ }, z.core.$strip>>>;
185
+ };
186
+ readonly names: {
187
+ readonly suggest: NoInfer<import("./services.ts").ServiceCall<"/names", {
188
+ title: z.ZodString;
189
+ }, z.ZodArray<z.ZodObject<{
190
+ name: z.ZodString;
191
+ available: z.ZodBoolean;
192
+ problem: z.ZodNullable<z.ZodString>;
193
+ }, z.core.$strip>>>>;
194
+ readonly check: NoInfer<import("./services.ts").ServiceCall<"/names/:name", {}, z.ZodObject<{
195
+ name: z.ZodString;
196
+ available: z.ZodBoolean;
197
+ problem: z.ZodNullable<z.ZodString>;
198
+ }, z.core.$strip>>>;
199
+ };
200
+ readonly publishes: {
201
+ readonly list: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/publishes", {}, z.ZodArray<z.ZodObject<{
202
+ number: z.ZodNumber;
203
+ status: z.ZodEnum<{
204
+ failed: "failed";
205
+ running: "running";
206
+ live: "live";
207
+ }>;
208
+ step: z.ZodEnum<{
209
+ publish: "publish";
210
+ reserve: "reserve";
211
+ database: "database";
212
+ "sign-in": "sign-in";
213
+ }>;
214
+ error: z.ZodNullable<z.ZodString>;
215
+ byEmail: z.ZodString;
216
+ restoredFrom: z.ZodNullable<z.ZodNumber>;
217
+ isStarter: z.ZodBoolean;
218
+ startedAt: z.ZodString;
219
+ finishedAt: z.ZodNullable<z.ZodString>;
220
+ }, z.core.$strip>>>>;
221
+ readonly read: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/publishes/:number", {}, z.ZodObject<{
222
+ number: z.ZodNumber;
223
+ status: z.ZodEnum<{
224
+ failed: "failed";
225
+ running: "running";
226
+ live: "live";
227
+ }>;
228
+ step: z.ZodEnum<{
229
+ publish: "publish";
230
+ reserve: "reserve";
231
+ database: "database";
232
+ "sign-in": "sign-in";
233
+ }>;
234
+ error: z.ZodNullable<z.ZodString>;
235
+ byEmail: z.ZodString;
236
+ restoredFrom: z.ZodNullable<z.ZodNumber>;
237
+ isStarter: z.ZodBoolean;
238
+ startedAt: z.ZodString;
239
+ finishedAt: z.ZodNullable<z.ZodString>;
240
+ }, z.core.$strip>>>;
241
+ readonly retry: NoInfer<import("./services.ts").ServiceCall<"/apps/:name/publishes/:number/retry", {}, z.ZodObject<{
242
+ number: z.ZodNumber;
243
+ status: z.ZodEnum<{
244
+ failed: "failed";
245
+ running: "running";
246
+ live: "live";
247
+ }>;
248
+ step: z.ZodEnum<{
249
+ publish: "publish";
250
+ reserve: "reserve";
251
+ database: "database";
252
+ "sign-in": "sign-in";
253
+ }>;
254
+ error: z.ZodNullable<z.ZodString>;
255
+ byEmail: z.ZodString;
256
+ restoredFrom: z.ZodNullable<z.ZodNumber>;
257
+ isStarter: z.ZodBoolean;
258
+ startedAt: z.ZodString;
259
+ finishedAt: z.ZodNullable<z.ZodString>;
260
+ }, z.core.$strip>>>;
261
+ };
262
+ readonly logins: {
263
+ readonly read: NoInfer<import("./services.ts").ServiceCall<"/cli/logins/:approval", {}, z.ZodObject<{
264
+ code: z.ZodString;
265
+ label: z.ZodString;
266
+ }, z.core.$strip>>>;
267
+ readonly approve: NoInfer<import("./services.ts").ServiceCall<"/cli/logins/:approval/approve", {}, z.ZodObject<{
268
+ ok: z.ZodBoolean;
269
+ }, z.core.$strip>>>;
270
+ };
271
+ };