create-foldkit-app 0.27.3 → 0.28.0
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.
- package/dist/index.js +1 -5
- package/{templates → dist/templates}/base/AGENTS.md +17 -19
- package/dist/templates/examples/api-cache/package.json +29 -0
- package/dist/templates/examples/api-cache/src/data.test.ts +28 -0
- package/dist/templates/examples/api-cache/src/data.ts +126 -0
- package/dist/templates/examples/api-cache/src/entry.ts +17 -0
- package/dist/templates/examples/api-cache/src/main.fixtures.ts +70 -0
- package/dist/templates/examples/api-cache/src/main.ts +744 -0
- package/dist/templates/examples/api-cache/src/scene.test.ts +120 -0
- package/dist/templates/examples/api-cache/src/story.test.ts +288 -0
- package/dist/templates/examples/api-cache/src/styles.css +1 -0
- package/dist/templates/examples/api-cache/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/auth/package.json +30 -0
- package/dist/templates/examples/auth/src/command.ts +49 -0
- package/dist/templates/examples/auth/src/constant.ts +1 -0
- package/dist/templates/examples/auth/src/domain/session.ts +9 -0
- package/dist/templates/examples/auth/src/entry.ts +25 -0
- package/dist/templates/examples/auth/src/main.ts +75 -0
- package/dist/templates/examples/auth/src/message.ts +22 -0
- package/dist/templates/examples/auth/src/model.ts +9 -0
- package/dist/templates/examples/auth/src/notFoundView.ts +25 -0
- package/dist/templates/examples/auth/src/page/index.ts +2 -0
- package/dist/templates/examples/auth/src/page/loggedIn/index.ts +4 -0
- package/dist/templates/examples/auth/src/page/loggedIn/message.ts +17 -0
- package/dist/templates/examples/auth/src/page/loggedIn/model.ts +21 -0
- package/dist/templates/examples/auth/src/page/loggedIn/page/dashboard.ts +40 -0
- package/dist/templates/examples/auth/src/page/loggedIn/page/settings.ts +71 -0
- package/dist/templates/examples/auth/src/page/loggedIn/update.ts +16 -0
- package/dist/templates/examples/auth/src/page/loggedIn/view.ts +87 -0
- package/dist/templates/examples/auth/src/page/loggedOut/index.ts +4 -0
- package/dist/templates/examples/auth/src/page/loggedOut/message.ts +20 -0
- package/dist/templates/examples/auth/src/page/loggedOut/model.ts +21 -0
- package/dist/templates/examples/auth/src/page/loggedOut/page/home.ts +68 -0
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.scene.test.ts +116 -0
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.story.test.ts +112 -0
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.ts +346 -0
- package/dist/templates/examples/auth/src/page/loggedOut/update.ts +32 -0
- package/dist/templates/examples/auth/src/page/loggedOut/view.ts +31 -0
- package/dist/templates/examples/auth/src/route.ts +56 -0
- package/dist/templates/examples/auth/src/scene.test.ts +61 -0
- package/dist/templates/examples/auth/src/styles.css +1 -0
- package/dist/templates/examples/auth/src/update.ts +179 -0
- package/dist/templates/examples/auth/src/view.ts +40 -0
- package/dist/templates/examples/auth/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/canvas-art/package.json +29 -0
- package/dist/templates/examples/canvas-art/src/entry.ts +17 -0
- package/dist/templates/examples/canvas-art/src/main.ts +274 -0
- package/dist/templates/examples/canvas-art/src/scene.test.ts +70 -0
- package/dist/templates/examples/canvas-art/src/story.test.ts +155 -0
- package/dist/templates/examples/canvas-art/src/styles.css +1 -0
- package/dist/templates/examples/canvas-art/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/charting/package.json +31 -0
- package/dist/templates/examples/charting/src/chartHost.ts +20 -0
- package/dist/templates/examples/charting/src/command.ts +62 -0
- package/dist/templates/examples/charting/src/domain.ts +175 -0
- package/dist/templates/examples/charting/src/echarts.ts +408 -0
- package/dist/templates/examples/charting/src/entry.ts +25 -0
- package/dist/templates/examples/charting/src/githubApi.ts +271 -0
- package/dist/templates/examples/charting/src/http.ts +50 -0
- package/dist/templates/examples/charting/src/init.test.ts +14 -0
- package/dist/templates/examples/charting/src/init.ts +29 -0
- package/dist/templates/examples/charting/src/main.fixtures.ts +162 -0
- package/dist/templates/examples/charting/src/message.ts +23 -0
- package/dist/templates/examples/charting/src/model.ts +22 -0
- package/dist/templates/examples/charting/src/npmApi.ts +75 -0
- package/dist/templates/examples/charting/src/radioGroups.ts +11 -0
- package/dist/templates/examples/charting/src/scene.test.ts +103 -0
- package/dist/templates/examples/charting/src/story.test.ts +145 -0
- package/dist/templates/examples/charting/src/styles.css +1 -0
- package/dist/templates/examples/charting/src/subscription.ts +70 -0
- package/dist/templates/examples/charting/src/telemetry.test.ts +64 -0
- package/dist/templates/examples/charting/src/telemetry.ts +432 -0
- package/dist/templates/examples/charting/src/update.ts +217 -0
- package/dist/templates/examples/charting/src/view/chart.ts +129 -0
- package/dist/templates/examples/charting/src/view/format.ts +23 -0
- package/dist/templates/examples/charting/src/view/index.ts +1 -0
- package/dist/templates/examples/charting/src/view/layout.ts +175 -0
- package/dist/templates/examples/charting/src/view/sidebar.ts +309 -0
- package/dist/templates/examples/charting/src/view/view.ts +23 -0
- package/dist/templates/examples/charting/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/charting/src/weeks.ts +105 -0
- package/dist/templates/examples/counter/package.json +29 -0
- package/dist/templates/examples/counter/src/entry.ts +16 -0
- package/dist/templates/examples/counter/src/main.ts +95 -0
- package/dist/templates/examples/counter/src/scene.test.ts +57 -0
- package/dist/templates/examples/counter/src/story.test.ts +71 -0
- package/dist/templates/examples/counter/src/styles.css +1 -0
- package/dist/templates/examples/counter/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/counters/package.json +29 -0
- package/dist/templates/examples/counters/src/counter.ts +70 -0
- package/dist/templates/examples/counters/src/entry.ts +16 -0
- package/dist/templates/examples/counters/src/main.ts +171 -0
- package/dist/templates/examples/counters/src/scene.test.ts +90 -0
- package/dist/templates/examples/counters/src/story.test.ts +127 -0
- package/dist/templates/examples/counters/src/styles.css +1 -0
- package/dist/templates/examples/counters/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/crash-view/package.json +29 -0
- package/dist/templates/examples/crash-view/src/entry.ts +28 -0
- package/dist/templates/examples/crash-view/src/main.ts +104 -0
- package/dist/templates/examples/crash-view/src/scene.test.ts +14 -0
- package/dist/templates/examples/crash-view/src/story.test.ts +11 -0
- package/dist/templates/examples/crash-view/src/styles.css +1 -0
- package/dist/templates/examples/crash-view/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/embedding/package.json +29 -0
- package/dist/templates/examples/embedding/src/entry.ts +3 -0
- package/dist/templates/examples/embedding/src/host.ts +108 -0
- package/dist/templates/examples/embedding/src/main.ts +144 -0
- package/dist/templates/examples/embedding/src/scene.test.ts +28 -0
- package/dist/templates/examples/embedding/src/story.test.ts +64 -0
- package/dist/templates/examples/embedding/src/styles.css +1 -0
- package/dist/templates/examples/embedding/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/form/package.json +30 -0
- package/dist/templates/examples/form/src/entry.ts +16 -0
- package/dist/templates/examples/form/src/main.ts +493 -0
- package/dist/templates/examples/form/src/scene.test.ts +165 -0
- package/dist/templates/examples/form/src/story.test.ts +190 -0
- package/dist/templates/examples/form/src/styles.css +1 -0
- package/dist/templates/examples/form/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/generative-art/package.json +29 -0
- package/dist/templates/examples/generative-art/src/command.ts +109 -0
- package/dist/templates/examples/generative-art/src/constant.ts +68 -0
- package/dist/templates/examples/generative-art/src/entry.ts +22 -0
- package/dist/templates/examples/generative-art/src/main.ts +59 -0
- package/dist/templates/examples/generative-art/src/message.ts +35 -0
- package/dist/templates/examples/generative-art/src/model.ts +33 -0
- package/dist/templates/examples/generative-art/src/noise.ts +93 -0
- package/dist/templates/examples/generative-art/src/scene.test.ts +103 -0
- package/dist/templates/examples/generative-art/src/story.test.ts +203 -0
- package/dist/templates/examples/generative-art/src/styles.css +1 -0
- package/dist/templates/examples/generative-art/src/subscription.ts +35 -0
- package/dist/templates/examples/generative-art/src/update.ts +319 -0
- package/dist/templates/examples/generative-art/src/view.ts +451 -0
- package/dist/templates/examples/generative-art/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/interrupting-commands/package.json +29 -0
- package/dist/templates/examples/interrupting-commands/src/entry.ts +16 -0
- package/dist/templates/examples/interrupting-commands/src/main.ts +354 -0
- package/dist/templates/examples/interrupting-commands/src/scene.test.ts +89 -0
- package/dist/templates/examples/interrupting-commands/src/story.test.ts +224 -0
- package/dist/templates/examples/interrupting-commands/src/styles.css +1 -0
- package/dist/templates/examples/interrupting-commands/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/job-application/package.json +30 -0
- package/dist/templates/examples/job-application/src/command.ts +23 -0
- package/dist/templates/examples/job-application/src/domain/index.ts +3 -0
- package/dist/templates/examples/job-application/src/domain/proficiencyLevel.ts +11 -0
- package/dist/templates/examples/job-application/src/domain/pronounOption.ts +13 -0
- package/dist/templates/examples/job-application/src/domain/step.ts +28 -0
- package/dist/templates/examples/job-application/src/entry.ts +17 -0
- package/dist/templates/examples/job-application/src/main.ts +69 -0
- package/dist/templates/examples/job-application/src/message.ts +44 -0
- package/dist/templates/examples/job-application/src/model.ts +47 -0
- package/dist/templates/examples/job-application/src/scene.test.ts +269 -0
- package/dist/templates/examples/job-application/src/step/attachments.ts +111 -0
- package/dist/templates/examples/job-application/src/step/coverLetter.ts +34 -0
- package/dist/templates/examples/job-application/src/step/education/education.ts +121 -0
- package/dist/templates/examples/job-application/src/step/education/entry.ts +168 -0
- package/dist/templates/examples/job-application/src/step/education/index.ts +2 -0
- package/dist/templates/examples/job-application/src/step/index.ts +6 -0
- package/dist/templates/examples/job-application/src/step/personalInfo.ts +305 -0
- package/dist/templates/examples/job-application/src/step/skills/entry.ts +126 -0
- package/dist/templates/examples/job-application/src/step/skills/index.ts +2 -0
- package/dist/templates/examples/job-application/src/step/skills/skills.ts +118 -0
- package/dist/templates/examples/job-application/src/step/validation.ts +6 -0
- package/dist/templates/examples/job-application/src/step/workHistory/entry.ts +206 -0
- package/dist/templates/examples/job-application/src/step/workHistory/index.ts +2 -0
- package/dist/templates/examples/job-application/src/step/workHistory/workHistory.ts +121 -0
- package/dist/templates/examples/job-application/src/story.test.ts +775 -0
- package/dist/templates/examples/job-application/src/styles.css +1 -0
- package/dist/templates/examples/job-application/src/update.ts +183 -0
- package/dist/templates/examples/job-application/src/view/attachments.ts +215 -0
- package/dist/templates/examples/job-application/src/view/coverLetter.ts +73 -0
- package/dist/templates/examples/job-application/src/view/datePicker.ts +207 -0
- package/dist/templates/examples/job-application/src/view/education.ts +63 -0
- package/dist/templates/examples/job-application/src/view/educationEntry.ts +165 -0
- package/dist/templates/examples/job-application/src/view/field.ts +183 -0
- package/dist/templates/examples/job-application/src/view/format.ts +50 -0
- package/dist/templates/examples/job-application/src/view/icon.ts +21 -0
- package/dist/templates/examples/job-application/src/view/index.ts +352 -0
- package/dist/templates/examples/job-application/src/view/personalInfo.ts +224 -0
- package/dist/templates/examples/job-application/src/view/preview.ts +265 -0
- package/dist/templates/examples/job-application/src/view/review.ts +388 -0
- package/dist/templates/examples/job-application/src/view/skillEntry.ts +102 -0
- package/dist/templates/examples/job-application/src/view/skills.ts +49 -0
- package/dist/templates/examples/job-application/src/view/stepNav.ts +181 -0
- package/dist/templates/examples/job-application/src/view/workEntry.ts +159 -0
- package/dist/templates/examples/job-application/src/view/workHistory.ts +55 -0
- package/dist/templates/examples/job-application/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/kanban/package.json +31 -0
- package/dist/templates/examples/kanban/src/command.ts +46 -0
- package/dist/templates/examples/kanban/src/constant.ts +149 -0
- package/dist/templates/examples/kanban/src/domain/card.ts +10 -0
- package/dist/templates/examples/kanban/src/domain/column.ts +115 -0
- package/dist/templates/examples/kanban/src/domain/index.ts +2 -0
- package/dist/templates/examples/kanban/src/entry.ts +27 -0
- package/dist/templates/examples/kanban/src/main.ts +56 -0
- package/dist/templates/examples/kanban/src/message.ts +21 -0
- package/dist/templates/examples/kanban/src/model.ts +21 -0
- package/dist/templates/examples/kanban/src/scene.test.ts +161 -0
- package/dist/templates/examples/kanban/src/story.test.ts +461 -0
- package/dist/templates/examples/kanban/src/styles.css +1 -0
- package/dist/templates/examples/kanban/src/subscription.ts +16 -0
- package/dist/templates/examples/kanban/src/update.ts +205 -0
- package/dist/templates/examples/kanban/src/view/card.ts +79 -0
- package/dist/templates/examples/kanban/src/view/column.ts +283 -0
- package/dist/templates/examples/kanban/src/view/index.ts +71 -0
- package/dist/templates/examples/kanban/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/managed-resource-layer/package.json +29 -0
- package/dist/templates/examples/managed-resource-layer/src/entry.ts +17 -0
- package/dist/templates/examples/managed-resource-layer/src/main.ts +309 -0
- package/dist/templates/examples/managed-resource-layer/src/scene.test.ts +117 -0
- package/dist/templates/examples/managed-resource-layer/src/story.test.ts +118 -0
- package/dist/templates/examples/managed-resource-layer/src/styles.css +1 -0
- package/dist/templates/examples/managed-resource-layer/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/map/package.json +31 -0
- package/dist/templates/examples/map/src/entry.ts +17 -0
- package/dist/templates/examples/map/src/locations.ts +69 -0
- package/dist/templates/examples/map/src/main.fixtures.ts +28 -0
- package/dist/templates/examples/map/src/main.ts +781 -0
- package/dist/templates/examples/map/src/mapHost.ts +23 -0
- package/dist/templates/examples/map/src/scene.test.ts +136 -0
- package/dist/templates/examples/map/src/story.test.ts +190 -0
- package/dist/templates/examples/map/src/styles.css +2 -0
- package/dist/templates/examples/map/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/pixel-art/package.json +31 -0
- package/dist/templates/examples/pixel-art/src/command.ts +87 -0
- package/dist/templates/examples/pixel-art/src/comparison.bench.test.ts +204 -0
- package/dist/templates/examples/pixel-art/src/constant.ts +21 -0
- package/dist/templates/examples/pixel-art/src/entry.ts +27 -0
- package/dist/templates/examples/pixel-art/src/grid.ts +134 -0
- package/dist/templates/examples/pixel-art/src/main.bench.ts +133 -0
- package/dist/templates/examples/pixel-art/src/main.ts +85 -0
- package/dist/templates/examples/pixel-art/src/message.ts +36 -0
- package/dist/templates/examples/pixel-art/src/model.ts +79 -0
- package/dist/templates/examples/pixel-art/src/palette.ts +134 -0
- package/dist/templates/examples/pixel-art/src/scene.test.ts +250 -0
- package/dist/templates/examples/pixel-art/src/story.test.ts +482 -0
- package/dist/templates/examples/pixel-art/src/styles.css +1 -0
- package/dist/templates/examples/pixel-art/src/subscription.ts +61 -0
- package/dist/templates/examples/pixel-art/src/update.ts +469 -0
- package/dist/templates/examples/pixel-art/src/view/canvas.ts +134 -0
- package/dist/templates/examples/pixel-art/src/view/dialog.ts +152 -0
- package/dist/templates/examples/pixel-art/src/view/history.ts +214 -0
- package/dist/templates/examples/pixel-art/src/view/index.ts +1 -0
- package/dist/templates/examples/pixel-art/src/view/toolbar.ts +452 -0
- package/dist/templates/examples/pixel-art/src/view/view.ts +183 -0
- package/dist/templates/examples/pixel-art/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/query-sync/package.json +30 -0
- package/dist/templates/examples/query-sync/src/data.ts +166 -0
- package/dist/templates/examples/query-sync/src/entry.ts +20 -0
- package/dist/templates/examples/query-sync/src/main.ts +898 -0
- package/dist/templates/examples/query-sync/src/scene.test.ts +89 -0
- package/dist/templates/examples/query-sync/src/story.test.ts +151 -0
- package/dist/templates/examples/query-sync/src/styles.css +1 -0
- package/dist/templates/examples/query-sync/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/route-transitions/package.json +28 -0
- package/dist/templates/examples/route-transitions/src/data.ts +61 -0
- package/dist/templates/examples/route-transitions/src/entry.ts +20 -0
- package/dist/templates/examples/route-transitions/src/main.ts +798 -0
- package/dist/templates/examples/route-transitions/src/route.ts +48 -0
- package/dist/templates/examples/route-transitions/src/story.test.ts +225 -0
- package/dist/templates/examples/route-transitions/src/styles.css +1 -0
- package/dist/templates/examples/route-transitions/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/routing/package.json +29 -0
- package/dist/templates/examples/routing/src/entry.ts +20 -0
- package/dist/templates/examples/routing/src/fileTree.ts +98 -0
- package/dist/templates/examples/routing/src/main.ts +573 -0
- package/dist/templates/examples/routing/src/page/index.ts +1 -0
- package/dist/templates/examples/routing/src/page/people.ts +349 -0
- package/dist/templates/examples/routing/src/route.ts +82 -0
- package/dist/templates/examples/routing/src/scene.test.ts +180 -0
- package/dist/templates/examples/routing/src/story.test.ts +242 -0
- package/dist/templates/examples/routing/src/styles.css +1 -0
- package/dist/templates/examples/routing/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/shopping-cart/package.json +29 -0
- package/dist/templates/examples/shopping-cart/src/data/products.ts +10 -0
- package/dist/templates/examples/shopping-cart/src/domain/cart.ts +77 -0
- package/dist/templates/examples/shopping-cart/src/domain/index.ts +2 -0
- package/dist/templates/examples/shopping-cart/src/domain/item.ts +16 -0
- package/dist/templates/examples/shopping-cart/src/entry.ts +20 -0
- package/dist/templates/examples/shopping-cart/src/main.ts +307 -0
- package/dist/templates/examples/shopping-cart/src/page/cart.ts +203 -0
- package/dist/templates/examples/shopping-cart/src/page/checkout.ts +205 -0
- package/dist/templates/examples/shopping-cart/src/page/index.ts +3 -0
- package/dist/templates/examples/shopping-cart/src/page/products.ts +267 -0
- package/dist/templates/examples/shopping-cart/src/route.ts +43 -0
- package/dist/templates/examples/shopping-cart/src/scene.test.ts +138 -0
- package/dist/templates/examples/shopping-cart/src/story.test.ts +233 -0
- package/dist/templates/examples/shopping-cart/src/styles.css +1 -0
- package/dist/templates/examples/shopping-cart/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/slow-warnings/package.json +28 -0
- package/dist/templates/examples/slow-warnings/src/entry.ts +29 -0
- package/dist/templates/examples/slow-warnings/src/handleSlow.test.ts +43 -0
- package/dist/templates/examples/slow-warnings/src/main.ts +574 -0
- package/dist/templates/examples/slow-warnings/src/scene.test.ts +57 -0
- package/dist/templates/examples/slow-warnings/src/story.test.ts +118 -0
- package/dist/templates/examples/slow-warnings/src/styles.css +1 -0
- package/dist/templates/examples/slow-warnings/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/snake/package.json +28 -0
- package/dist/templates/examples/snake/src/constants.ts +11 -0
- package/dist/templates/examples/snake/src/domain/apple.ts +22 -0
- package/dist/templates/examples/snake/src/domain/direction.ts +17 -0
- package/dist/templates/examples/snake/src/domain/index.ts +4 -0
- package/dist/templates/examples/snake/src/domain/position.ts +32 -0
- package/dist/templates/examples/snake/src/domain/snake.ts +43 -0
- package/dist/templates/examples/snake/src/entry.ts +17 -0
- package/dist/templates/examples/snake/src/main.ts +345 -0
- package/dist/templates/examples/snake/src/scene.test.ts +77 -0
- package/dist/templates/examples/snake/src/story.test.ts +165 -0
- package/dist/templates/examples/snake/src/styles.css +1 -0
- package/dist/templates/examples/snake/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/ssg/package.json +29 -0
- package/dist/templates/examples/ssg/src/entry.server.ts +14 -0
- package/{templates/rendering → dist/templates/examples}/ssg/src/entry.ts +3 -11
- package/dist/templates/examples/ssg/src/main.ts +163 -0
- package/dist/templates/examples/ssg/src/styles.css +1 -0
- package/dist/templates/examples/ssr/package.json +33 -0
- package/dist/templates/examples/ssr/src/cookie.ts +13 -0
- package/dist/templates/examples/ssr/src/entry.server.ts +51 -0
- package/dist/templates/examples/ssr/src/main.ts +170 -0
- package/{templates/rendering → dist/templates/examples}/ssr/src/scene.test.ts +5 -8
- package/dist/templates/examples/ssr/src/styles.css +1 -0
- package/dist/templates/examples/ssr/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/state-machine/package.json +30 -0
- package/dist/templates/examples/state-machine/src/entry.ts +17 -0
- package/dist/templates/examples/state-machine/src/icon.ts +51 -0
- package/dist/templates/examples/state-machine/src/main.ts +420 -0
- package/dist/templates/examples/state-machine/src/scene.test.ts +85 -0
- package/dist/templates/examples/state-machine/src/story.test.ts +199 -0
- package/dist/templates/examples/state-machine/src/styles.css +53 -0
- package/dist/templates/examples/state-machine/src/view.ts +1675 -0
- package/dist/templates/examples/state-machine/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/stopwatch/package.json +29 -0
- package/dist/templates/examples/stopwatch/src/entry.ts +17 -0
- package/dist/templates/examples/stopwatch/src/main.ts +237 -0
- package/dist/templates/examples/stopwatch/src/scene.test.ts +124 -0
- package/dist/templates/examples/stopwatch/src/story.test.ts +126 -0
- package/dist/templates/examples/stopwatch/src/styles.css +1 -0
- package/dist/templates/examples/stopwatch/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/todo/package.json +30 -0
- package/dist/templates/examples/todo/src/entry.ts +17 -0
- package/dist/templates/examples/todo/src/main.ts +682 -0
- package/dist/templates/examples/todo/src/scene.test.ts +177 -0
- package/dist/templates/examples/todo/src/story.test.ts +374 -0
- package/dist/templates/examples/todo/src/styles.css +1 -0
- package/dist/templates/examples/todo/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/ui-showcase/package.json +30 -0
- package/dist/templates/examples/ui-showcase/src/entry.ts +31 -0
- package/dist/templates/examples/ui-showcase/src/icon.ts +64 -0
- package/dist/templates/examples/ui-showcase/src/main.ts +673 -0
- package/dist/templates/examples/ui-showcase/src/scene.test.ts +102 -0
- package/dist/templates/examples/ui-showcase/src/story.test.ts +128 -0
- package/dist/templates/examples/ui-showcase/src/styles.css +21 -0
- package/dist/templates/examples/ui-showcase/src/ui/init.ts +185 -0
- package/dist/templates/examples/ui-showcase/src/ui/message.ts +164 -0
- package/dist/templates/examples/ui-showcase/src/ui/model.ts +138 -0
- package/dist/templates/examples/ui-showcase/src/ui/subscriptions.ts +55 -0
- package/dist/templates/examples/ui-showcase/src/ui/toast.ts +13 -0
- package/dist/templates/examples/ui-showcase/src/ui/update.ts +1234 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/animation.ts +58 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/button.ts +64 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/calendar.ts +202 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/checkbox.ts +185 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/combobox.ts +326 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/datePicker.ts +263 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/dialog.ts +427 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/disclosure.ts +142 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/dragAndDrop.ts +230 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/fieldset.ts +284 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/fileDrop.ts +119 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/index.ts +24 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/input.ts +90 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/listbox.ts +263 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/menu.ts +172 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/popover.ts +262 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/radioGroup.ts +192 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/select.ts +129 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/slider.ts +135 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/switch.ts +82 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/tabs.ts +187 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/textarea.ts +99 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/toast.ts +165 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/tooltip.ts +123 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/virtualList.ts +361 -0
- package/dist/templates/examples/ui-showcase/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/view-transitions/package.json +28 -0
- package/dist/templates/examples/view-transitions/src/artwork.ts +80 -0
- package/dist/templates/examples/view-transitions/src/entry.ts +21 -0
- package/dist/templates/examples/view-transitions/src/main.ts +348 -0
- package/dist/templates/examples/view-transitions/src/route.ts +29 -0
- package/dist/templates/examples/view-transitions/src/scene.test.ts +130 -0
- package/dist/templates/examples/view-transitions/src/styles.css +66 -0
- package/dist/templates/examples/view-transitions/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/weather/package.json +29 -0
- package/dist/templates/examples/weather/src/entry.ts +16 -0
- package/dist/templates/examples/weather/src/main.fixtures.ts +59 -0
- package/dist/templates/examples/weather/src/main.ts +356 -0
- package/dist/templates/examples/weather/src/scene.test.ts +109 -0
- package/dist/templates/examples/weather/src/story.test.ts +125 -0
- package/dist/templates/examples/weather/src/styles.css +1 -0
- package/dist/templates/examples/weather/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/web-components/package.json +32 -0
- package/dist/templates/examples/web-components/src/entry.ts +16 -0
- package/dist/templates/examples/web-components/src/main.ts +327 -0
- package/dist/templates/examples/web-components/src/scene.test.ts +90 -0
- package/dist/templates/examples/web-components/src/story.test.ts +90 -0
- package/dist/templates/examples/web-components/src/styles.css +1 -0
- package/dist/templates/examples/web-components/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/websocket-chat/package.json +29 -0
- package/dist/templates/examples/websocket-chat/src/entry.ts +26 -0
- package/dist/templates/examples/websocket-chat/src/main.ts +626 -0
- package/dist/templates/examples/websocket-chat/src/scene.test.ts +166 -0
- package/dist/templates/examples/websocket-chat/src/story.test.ts +183 -0
- package/dist/templates/examples/websocket-chat/src/styles.css +1 -0
- package/dist/templates/examples/websocket-chat/src/vitest-setup.ts +3 -0
- package/dist/templates/release.json +27 -0
- package/dist/templates/rendering/ssg/src/entry.ts +20 -0
- package/{templates → dist/templates}/rendering/ssg/src/main.ts +36 -43
- package/dist/templates/rendering/ssg/src/route.ts +20 -0
- package/dist/templates/rendering/ssg/src/vite-env.d.ts +19 -0
- package/dist/templates/rendering/ssr/src/entry.ts +17 -0
- package/{templates → dist/templates}/rendering/ssr/src/main.ts +17 -25
- package/dist/templates/rendering/ssr/src/scene.test.ts +40 -0
- package/dist/templates/rendering/ssr/src/vite-env.d.ts +19 -0
- package/dist/utils/files.js +23 -71
- package/dist/utils/packages.js +63 -44
- package/package.json +3 -4
- /package/{templates → dist/templates}/base/.mcp.json +0 -0
- /package/{templates → dist/templates}/base/.oxlintrc.json +0 -0
- /package/{templates → dist/templates}/base/.prettierignore +0 -0
- /package/{templates → dist/templates}/base/.prettierrc +0 -0
- /package/{templates → dist/templates}/base/README.md +0 -0
- /package/{templates → dist/templates}/base/gitignore +0 -0
- /package/{templates → dist/templates}/base/ignore +0 -0
- /package/{templates → dist/templates}/base/index.html +0 -0
- /package/{templates → dist/templates}/base/package.json +0 -0
- /package/{templates → dist/templates}/base/src/styles.css +0 -0
- /package/{templates → dist/templates}/base/src/vitest-setup.ts +0 -0
- /package/{templates → dist/templates}/base/tsconfig.json +0 -0
- /package/{templates → dist/templates}/base/vite.config.ts +0 -0
- /package/{templates → dist/templates}/base/vitest.config.ts +0 -0
- /package/{templates/rendering → dist/templates/examples}/ssg/src/route.ts +0 -0
- /package/{templates/rendering → dist/templates/examples}/ssg/src/vite-env.d.ts +0 -0
- /package/{templates/rendering → dist/templates/examples}/ssr/src/entry.ts +0 -0
- /package/{templates/rendering → dist/templates/examples}/ssr/src/vite-env.d.ts +0 -0
- /package/{templates → dist/templates}/package-managers/pnpm/pnpm-workspace.yaml +0 -0
- /package/{templates → dist/templates}/rendering/ssg/README.md +0 -0
- /package/{templates → dist/templates}/rendering/ssg/package.json +0 -0
- /package/{templates → dist/templates}/rendering/ssg/scripts/build.mjs +0 -0
- /package/{templates → dist/templates}/rendering/ssg/scripts/prerender.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssg/src/entry.server.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssg/src/scene.test.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssg/tsconfig.json +0 -0
- /package/{templates → dist/templates}/rendering/ssg/vite.config.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssr/README.md +0 -0
- /package/{templates → dist/templates}/rendering/ssr/package.json +0 -0
- /package/{templates → dist/templates}/rendering/ssr/scripts/build.mjs +0 -0
- /package/{templates → dist/templates}/rendering/ssr/server/main.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssr/src/cookie.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssr/src/entry.server.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssr/tsconfig.json +0 -0
- /package/{templates → dist/templates}/rendering/ssr/vite.config.ts +0 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { FieldValidation } from 'foldkit'
|
|
2
|
+
import { Command, given, message, model, story } from 'foldkit/story'
|
|
3
|
+
import { describe, expect, test } from 'vitest'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Message,
|
|
7
|
+
type Model,
|
|
8
|
+
SubmitForm,
|
|
9
|
+
ValidateEmail,
|
|
10
|
+
initialModel,
|
|
11
|
+
update,
|
|
12
|
+
} from './main'
|
|
13
|
+
|
|
14
|
+
const validModel: Model = {
|
|
15
|
+
...initialModel,
|
|
16
|
+
name: FieldValidation.Valid({ value: 'Alice' }),
|
|
17
|
+
email: FieldValidation.Valid({ value: 'alice@example.com' }),
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe('update', () => {
|
|
21
|
+
describe('name field', () => {
|
|
22
|
+
test('typing a long name produces a Valid field', () => {
|
|
23
|
+
story(
|
|
24
|
+
update,
|
|
25
|
+
given(initialModel),
|
|
26
|
+
message(Message.UpdatedName({ value: 'Alice' })),
|
|
27
|
+
model(model => {
|
|
28
|
+
expect(model.name._tag).toBe('Valid')
|
|
29
|
+
expect(model.name.value).toBe('Alice')
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('typing a short name produces an Invalid field with the min-length error', () => {
|
|
35
|
+
story(
|
|
36
|
+
update,
|
|
37
|
+
given(initialModel),
|
|
38
|
+
message(Message.UpdatedName({ value: 'A' })),
|
|
39
|
+
model(model => {
|
|
40
|
+
expect(model.name._tag).toBe('Invalid')
|
|
41
|
+
if (model.name._tag === 'Invalid') {
|
|
42
|
+
expect(model.name.errors).toContain(
|
|
43
|
+
'Name must be at least 2 characters',
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
)
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
describe('email field', () => {
|
|
52
|
+
test('typing a well-formed email transitions to Validating and fires ValidateEmail', () => {
|
|
53
|
+
story(
|
|
54
|
+
update,
|
|
55
|
+
given(initialModel),
|
|
56
|
+
message(Message.UpdatedEmail({ value: 'alice@example.com' })),
|
|
57
|
+
model(model => {
|
|
58
|
+
expect(model.email._tag).toBe('Validating')
|
|
59
|
+
}),
|
|
60
|
+
Command.expectHas(ValidateEmail),
|
|
61
|
+
Command.resolve(
|
|
62
|
+
ValidateEmail,
|
|
63
|
+
Message.CompletedValidateEmail({
|
|
64
|
+
field: FieldValidation.Valid({ value: 'alice@example.com' }),
|
|
65
|
+
}),
|
|
66
|
+
),
|
|
67
|
+
model(model => {
|
|
68
|
+
expect(model.email._tag).toBe('Valid')
|
|
69
|
+
}),
|
|
70
|
+
)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('typing a malformed email produces Invalid without an async command', () => {
|
|
74
|
+
story(
|
|
75
|
+
update,
|
|
76
|
+
given(initialModel),
|
|
77
|
+
message(Message.UpdatedEmail({ value: 'not-an-email' })),
|
|
78
|
+
Command.expectNone(),
|
|
79
|
+
model(model => {
|
|
80
|
+
expect(model.email._tag).toBe('Invalid')
|
|
81
|
+
}),
|
|
82
|
+
)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('a validation result for a superseded email value is ignored', () => {
|
|
86
|
+
const inFlightModel: Model = {
|
|
87
|
+
...initialModel,
|
|
88
|
+
email: FieldValidation.Validating({ value: 'alice@example.com' }),
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
story(
|
|
92
|
+
update,
|
|
93
|
+
given(inFlightModel),
|
|
94
|
+
message(
|
|
95
|
+
Message.CompletedValidateEmail({
|
|
96
|
+
field: FieldValidation.Valid({ value: 'old@example.com' }),
|
|
97
|
+
}),
|
|
98
|
+
),
|
|
99
|
+
model(model => {
|
|
100
|
+
expect(model.email._tag).toBe('Validating')
|
|
101
|
+
}),
|
|
102
|
+
)
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('a validation result for the current email value updates the field', () => {
|
|
106
|
+
const inFlightModel: Model = {
|
|
107
|
+
...initialModel,
|
|
108
|
+
email: FieldValidation.Validating({ value: 'taken@example.com' }),
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
story(
|
|
112
|
+
update,
|
|
113
|
+
given(inFlightModel),
|
|
114
|
+
message(
|
|
115
|
+
Message.CompletedValidateEmail({
|
|
116
|
+
field: FieldValidation.Invalid({
|
|
117
|
+
value: 'taken@example.com',
|
|
118
|
+
errors: ['This email is already on our waitlist'],
|
|
119
|
+
}),
|
|
120
|
+
}),
|
|
121
|
+
),
|
|
122
|
+
model(model => {
|
|
123
|
+
expect(model.email._tag).toBe('Invalid')
|
|
124
|
+
}),
|
|
125
|
+
)
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
describe('message text field', () => {
|
|
130
|
+
test('UpdatedMessageText stores the value as Valid', () => {
|
|
131
|
+
story(
|
|
132
|
+
update,
|
|
133
|
+
given(initialModel),
|
|
134
|
+
message(Message.UpdatedMessageText({ value: 'Hello there.' })),
|
|
135
|
+
model(model => {
|
|
136
|
+
expect(model.messageText._tag).toBe('Valid')
|
|
137
|
+
expect(model.messageText.value).toBe('Hello there.')
|
|
138
|
+
}),
|
|
139
|
+
)
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
describe('submission', () => {
|
|
144
|
+
test('ClickedFormSubmit on an invalid form is ignored', () => {
|
|
145
|
+
story(
|
|
146
|
+
update,
|
|
147
|
+
given(initialModel),
|
|
148
|
+
message(Message.ClickedFormSubmit()),
|
|
149
|
+
Command.expectNone(),
|
|
150
|
+
model(model => {
|
|
151
|
+
expect(model.submission._tag).toBe('NotSubmitted')
|
|
152
|
+
}),
|
|
153
|
+
)
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
test('ClickedFormSubmit on a valid form fires SubmitForm and enters Submitting', () => {
|
|
157
|
+
story(
|
|
158
|
+
update,
|
|
159
|
+
given(validModel),
|
|
160
|
+
message(Message.ClickedFormSubmit()),
|
|
161
|
+
model(model => {
|
|
162
|
+
expect(model.submission._tag).toBe('Submitting')
|
|
163
|
+
}),
|
|
164
|
+
Command.expectHas(SubmitForm),
|
|
165
|
+
Command.resolve(
|
|
166
|
+
SubmitForm,
|
|
167
|
+
Message.SucceededSubmitForm({ name: 'Alice' }),
|
|
168
|
+
),
|
|
169
|
+
model(model => {
|
|
170
|
+
expect(model.submission._tag).toBe('SubmitSuccess')
|
|
171
|
+
if (model.submission._tag === 'SubmitSuccess') {
|
|
172
|
+
expect(model.submission.confirmationText).toContain('Alice')
|
|
173
|
+
}
|
|
174
|
+
}),
|
|
175
|
+
)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
test('FailedSubmitForm sets SubmitError', () => {
|
|
179
|
+
story(
|
|
180
|
+
update,
|
|
181
|
+
given(validModel),
|
|
182
|
+
message(Message.ClickedFormSubmit()),
|
|
183
|
+
Command.resolve(SubmitForm, Message.FailedSubmitForm()),
|
|
184
|
+
model(model => {
|
|
185
|
+
expect(model.submission._tag).toBe('SubmitError')
|
|
186
|
+
}),
|
|
187
|
+
)
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "generative-art-example",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"typecheck": "tsc --noEmit",
|
|
9
|
+
"test": "vitest run"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.109",
|
|
13
|
+
"@foldkit/ui": "workspace:*",
|
|
14
|
+
"@tailwindcss/vite": "^4.3.1",
|
|
15
|
+
"effect": "4.0.0-rc.109",
|
|
16
|
+
"foldkit": "workspace:*",
|
|
17
|
+
"tailwindcss": "^4.3.1"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@foldkit/devtools": "workspace:*",
|
|
21
|
+
"@foldkit/vite-plugin": "workspace:*",
|
|
22
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
23
|
+
"happy-dom": "^20.10.4",
|
|
24
|
+
"prettier": "^3.8.4",
|
|
25
|
+
"typescript": "^6.0.3",
|
|
26
|
+
"vite": "^8.0.16",
|
|
27
|
+
"vitest": "^4.1.9"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Effect, Option, Random, Schema as S } from 'effect'
|
|
2
|
+
import { Command } from 'foldkit'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
CANVAS_HEIGHT,
|
|
6
|
+
CANVAS_WIDTH,
|
|
7
|
+
HUE_DRIFT_MAX,
|
|
8
|
+
HUE_DRIFT_MIN,
|
|
9
|
+
HUE_MAX,
|
|
10
|
+
HUE_MIN,
|
|
11
|
+
PARTICLE_LIFESPAN_MAX_MS,
|
|
12
|
+
PARTICLE_LIFESPAN_MIN_MS,
|
|
13
|
+
PARTICLE_SPEED_MAX,
|
|
14
|
+
PARTICLE_SPEED_MIN,
|
|
15
|
+
SETTLE_BAND_PX,
|
|
16
|
+
} from './constant'
|
|
17
|
+
import { Message } from './message'
|
|
18
|
+
|
|
19
|
+
export const GenerateAmbientParticle = Command.define(
|
|
20
|
+
'GenerateAmbientParticle',
|
|
21
|
+
{
|
|
22
|
+
messages: [Message.CompletedGenerateAmbientParticle],
|
|
23
|
+
execute: Effect.gen(function* () {
|
|
24
|
+
const x = yield* Random.nextBetween(
|
|
25
|
+
SETTLE_BAND_PX,
|
|
26
|
+
CANVAS_WIDTH - SETTLE_BAND_PX,
|
|
27
|
+
)
|
|
28
|
+
const y = yield* Random.nextBetween(
|
|
29
|
+
SETTLE_BAND_PX,
|
|
30
|
+
CANVAS_HEIGHT - SETTLE_BAND_PX,
|
|
31
|
+
)
|
|
32
|
+
const baseHue = yield* Random.nextBetween(HUE_MIN, HUE_MAX)
|
|
33
|
+
const hueDriftPerSecond = yield* Random.nextBetween(
|
|
34
|
+
HUE_DRIFT_MIN,
|
|
35
|
+
HUE_DRIFT_MAX,
|
|
36
|
+
)
|
|
37
|
+
const lifespanMs = yield* Random.nextBetween(
|
|
38
|
+
PARTICLE_LIFESPAN_MIN_MS,
|
|
39
|
+
PARTICLE_LIFESPAN_MAX_MS,
|
|
40
|
+
)
|
|
41
|
+
const speed = yield* Random.nextBetween(
|
|
42
|
+
PARTICLE_SPEED_MIN,
|
|
43
|
+
PARTICLE_SPEED_MAX,
|
|
44
|
+
)
|
|
45
|
+
return Message.CompletedGenerateAmbientParticle({
|
|
46
|
+
x,
|
|
47
|
+
y,
|
|
48
|
+
baseHue,
|
|
49
|
+
hueDriftPerSecond,
|
|
50
|
+
lifespanMs,
|
|
51
|
+
speed,
|
|
52
|
+
initialAngle: Option.none(),
|
|
53
|
+
initialSpeedScale: 1,
|
|
54
|
+
})
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
const BURST_POSITION_JITTER_PX = 6
|
|
60
|
+
const BURST_LIFESPAN_FACTOR = 0.85
|
|
61
|
+
const BURST_INITIAL_SPEED_SCALE_MIN = 1.4
|
|
62
|
+
const BURST_INITIAL_SPEED_SCALE_MAX = 2.2
|
|
63
|
+
const BURST_HUE_JITTER_DEGREES = 30
|
|
64
|
+
|
|
65
|
+
export const GenerateBurstParticle = Command.define('GenerateBurstParticle', {
|
|
66
|
+
args: { x: S.Number, y: S.Number, angle: S.Number, hueAnchor: S.Number },
|
|
67
|
+
messages: [Message.CompletedGenerateBurstParticle],
|
|
68
|
+
execute: ({ x, y, angle, hueAnchor }) =>
|
|
69
|
+
Effect.gen(function* () {
|
|
70
|
+
const jitterX = yield* Random.nextBetween(
|
|
71
|
+
-BURST_POSITION_JITTER_PX,
|
|
72
|
+
BURST_POSITION_JITTER_PX,
|
|
73
|
+
)
|
|
74
|
+
const jitterY = yield* Random.nextBetween(
|
|
75
|
+
-BURST_POSITION_JITTER_PX,
|
|
76
|
+
BURST_POSITION_JITTER_PX,
|
|
77
|
+
)
|
|
78
|
+
const hueOffset = yield* Random.nextBetween(
|
|
79
|
+
-BURST_HUE_JITTER_DEGREES,
|
|
80
|
+
BURST_HUE_JITTER_DEGREES,
|
|
81
|
+
)
|
|
82
|
+
const hueDriftPerSecond = yield* Random.nextBetween(
|
|
83
|
+
HUE_DRIFT_MIN,
|
|
84
|
+
HUE_DRIFT_MAX,
|
|
85
|
+
)
|
|
86
|
+
const lifespanMs = yield* Random.nextBetween(
|
|
87
|
+
PARTICLE_LIFESPAN_MIN_MS * BURST_LIFESPAN_FACTOR,
|
|
88
|
+
PARTICLE_LIFESPAN_MAX_MS * BURST_LIFESPAN_FACTOR,
|
|
89
|
+
)
|
|
90
|
+
const speed = yield* Random.nextBetween(
|
|
91
|
+
PARTICLE_SPEED_MIN,
|
|
92
|
+
PARTICLE_SPEED_MAX,
|
|
93
|
+
)
|
|
94
|
+
const initialSpeedScale = yield* Random.nextBetween(
|
|
95
|
+
BURST_INITIAL_SPEED_SCALE_MIN,
|
|
96
|
+
BURST_INITIAL_SPEED_SCALE_MAX,
|
|
97
|
+
)
|
|
98
|
+
return Message.CompletedGenerateBurstParticle({
|
|
99
|
+
x: x + jitterX,
|
|
100
|
+
y: y + jitterY,
|
|
101
|
+
baseHue: (hueAnchor + hueOffset + HUE_MAX) % HUE_MAX,
|
|
102
|
+
hueDriftPerSecond,
|
|
103
|
+
lifespanMs,
|
|
104
|
+
speed,
|
|
105
|
+
initialAngle: Option.some(angle),
|
|
106
|
+
initialSpeedScale,
|
|
107
|
+
})
|
|
108
|
+
}),
|
|
109
|
+
})
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export const CANVAS_WIDTH = 960
|
|
2
|
+
export const CANVAS_HEIGHT = 600
|
|
3
|
+
|
|
4
|
+
export const MS_PER_SECOND = 1000
|
|
5
|
+
export const TWO_PI = Math.PI * 2
|
|
6
|
+
export const HALF_PI = Math.PI / 2
|
|
7
|
+
|
|
8
|
+
export const DELTA_SECONDS_CAP = 0.05
|
|
9
|
+
|
|
10
|
+
export const TARGET_PARTICLE_COUNT = 55
|
|
11
|
+
export const INITIAL_PARTICLE_COUNT = 45
|
|
12
|
+
export const BURST_PARTICLE_COUNT = 22
|
|
13
|
+
|
|
14
|
+
export const TRAIL_LENGTH = 36
|
|
15
|
+
export const PARTICLE_LIFESPAN_MIN_MS = 4500
|
|
16
|
+
export const PARTICLE_LIFESPAN_MAX_MS = 9000
|
|
17
|
+
export const PARTICLE_SPEED_MIN = 60
|
|
18
|
+
export const PARTICLE_SPEED_MAX = 140
|
|
19
|
+
|
|
20
|
+
export const HUE_MIN = 0
|
|
21
|
+
export const HUE_MAX = 360
|
|
22
|
+
export const HUE_DRIFT_MIN = -45
|
|
23
|
+
export const HUE_DRIFT_MAX = 45
|
|
24
|
+
export const SATURATION_PERCENT = 90
|
|
25
|
+
export const CORE_LIGHTNESS_PERCENT = 78
|
|
26
|
+
export const GLOW_LIGHTNESS_PERCENT = 60
|
|
27
|
+
export const CORE_ALPHA_BASE = 0.85
|
|
28
|
+
export const GLOW_ALPHA_BASE = 0.18
|
|
29
|
+
|
|
30
|
+
export const FADE_IN_MS = 350
|
|
31
|
+
export const FADE_OUT_MS = 900
|
|
32
|
+
|
|
33
|
+
export const NOISE_SPATIAL_SCALE = 0.0028
|
|
34
|
+
export const NOISE_TIME_SCALE = 0.085
|
|
35
|
+
export const NOISE_DRIFT_X = 12
|
|
36
|
+
export const NOISE_DRIFT_Y = 7
|
|
37
|
+
export const FLOW_OCTAVES = 3
|
|
38
|
+
export const FLOW_PERSISTENCE = 0.5
|
|
39
|
+
export const FLOW_LACUNARITY = 2.0
|
|
40
|
+
|
|
41
|
+
export const MOUSE_INFLUENCE_RADIUS = 130
|
|
42
|
+
export const MOUSE_VORTEX_WEIGHT = 1
|
|
43
|
+
export const MOUSE_RADIAL_BIAS = -0.4
|
|
44
|
+
|
|
45
|
+
export const BURST_BOOST_DURATION_MS = 700
|
|
46
|
+
export const BURST_HUE_ANCHOR_DRIFT_DEG_PER_SECOND = 35
|
|
47
|
+
export const SPAWN_PER_FRAME_MAX = 3
|
|
48
|
+
|
|
49
|
+
export const CORE_LINE_WIDTH = 1.4
|
|
50
|
+
export const GLOW_LINE_WIDTH = 5
|
|
51
|
+
|
|
52
|
+
export const HEAD_RADIUS = 2.4
|
|
53
|
+
export const HEAD_LIGHTNESS_PERCENT = 92
|
|
54
|
+
export const HEAD_ALPHA = 0.95
|
|
55
|
+
|
|
56
|
+
export const BACKGROUND_COLOR_TOP = '#04030a'
|
|
57
|
+
export const VIGNETTE_ALPHA = 0.55
|
|
58
|
+
|
|
59
|
+
export const SETTLE_BAND_PX = 80
|
|
60
|
+
|
|
61
|
+
export const FLOW_STRENGTH_MIN = 0.25
|
|
62
|
+
export const FLOW_STRENGTH_MAX = 3
|
|
63
|
+
export const FLOW_STRENGTH_STEP = 0.05
|
|
64
|
+
export const INITIAL_FLOW_STRENGTH = 1.4
|
|
65
|
+
export const NOISE_SCALE_MIN_DIVISOR = 0.4
|
|
66
|
+
export const NOISE_SCALE_MAX_DIVISOR = 2.4
|
|
67
|
+
export const NOISE_SCALE_STEP = 0.05
|
|
68
|
+
export const INITIAL_NOISE_SCALE = 1
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Runtime } from 'foldkit'
|
|
2
|
+
|
|
3
|
+
import { Message, Model, init, subscriptions, update, view } from './main'
|
|
4
|
+
|
|
5
|
+
const application = Runtime.makeApplication({
|
|
6
|
+
Model,
|
|
7
|
+
init,
|
|
8
|
+
update,
|
|
9
|
+
view,
|
|
10
|
+
subscriptions,
|
|
11
|
+
container: document.getElementById('root'),
|
|
12
|
+
devTools: {
|
|
13
|
+
Message,
|
|
14
|
+
excludeFromHistory: [
|
|
15
|
+
'TickedFrame',
|
|
16
|
+
'MovedPointer',
|
|
17
|
+
'CompletedGenerateAmbientParticle',
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
Runtime.run(application)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Array, Option } from 'effect'
|
|
2
|
+
import { Runtime } from 'foldkit'
|
|
3
|
+
|
|
4
|
+
import { Slider } from '@foldkit/ui'
|
|
5
|
+
|
|
6
|
+
import { GenerateAmbientParticle } from './command'
|
|
7
|
+
import {
|
|
8
|
+
FLOW_STRENGTH_MAX,
|
|
9
|
+
FLOW_STRENGTH_MIN,
|
|
10
|
+
FLOW_STRENGTH_STEP,
|
|
11
|
+
INITIAL_FLOW_STRENGTH,
|
|
12
|
+
INITIAL_NOISE_SCALE,
|
|
13
|
+
INITIAL_PARTICLE_COUNT,
|
|
14
|
+
NOISE_SCALE_MAX_DIVISOR,
|
|
15
|
+
NOISE_SCALE_MIN_DIVISOR,
|
|
16
|
+
NOISE_SCALE_STEP,
|
|
17
|
+
} from './constant'
|
|
18
|
+
import { Message } from './message'
|
|
19
|
+
import { Model } from './model'
|
|
20
|
+
import { subscriptions } from './subscription'
|
|
21
|
+
import { update } from './update'
|
|
22
|
+
import { view } from './view'
|
|
23
|
+
|
|
24
|
+
export const init: Runtime.ApplicationInit<Model, Message> = () => [
|
|
25
|
+
{
|
|
26
|
+
particles: [],
|
|
27
|
+
nextId: 0,
|
|
28
|
+
elapsedSeconds: 0,
|
|
29
|
+
maybeMousePosition: Option.none(),
|
|
30
|
+
isRunning: true,
|
|
31
|
+
flowStrength: Slider.snapAndClamp(
|
|
32
|
+
INITIAL_FLOW_STRENGTH,
|
|
33
|
+
FLOW_STRENGTH_MIN,
|
|
34
|
+
FLOW_STRENGTH_MAX,
|
|
35
|
+
FLOW_STRENGTH_STEP,
|
|
36
|
+
),
|
|
37
|
+
flowStrengthSlider: Slider.init({
|
|
38
|
+
id: 'flow-strength-slider',
|
|
39
|
+
min: FLOW_STRENGTH_MIN,
|
|
40
|
+
max: FLOW_STRENGTH_MAX,
|
|
41
|
+
step: FLOW_STRENGTH_STEP,
|
|
42
|
+
}),
|
|
43
|
+
noiseScale: Slider.snapAndClamp(
|
|
44
|
+
INITIAL_NOISE_SCALE,
|
|
45
|
+
NOISE_SCALE_MIN_DIVISOR,
|
|
46
|
+
NOISE_SCALE_MAX_DIVISOR,
|
|
47
|
+
NOISE_SCALE_STEP,
|
|
48
|
+
),
|
|
49
|
+
noiseScaleSlider: Slider.init({
|
|
50
|
+
id: 'noise-scale-slider',
|
|
51
|
+
min: NOISE_SCALE_MIN_DIVISOR,
|
|
52
|
+
max: NOISE_SCALE_MAX_DIVISOR,
|
|
53
|
+
step: NOISE_SCALE_STEP,
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
Array.makeBy(INITIAL_PARTICLE_COUNT, () => GenerateAmbientParticle()),
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
export { Message, Model, subscriptions, update, view }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Schema as S } from 'effect'
|
|
2
|
+
import { defineMessageUnion } from 'foldkit/message'
|
|
3
|
+
|
|
4
|
+
import { Slider } from '@foldkit/ui'
|
|
5
|
+
|
|
6
|
+
const generatedParticleFields = {
|
|
7
|
+
x: S.Number,
|
|
8
|
+
y: S.Number,
|
|
9
|
+
baseHue: S.Number,
|
|
10
|
+
hueDriftPerSecond: S.Number,
|
|
11
|
+
lifespanMs: S.Number,
|
|
12
|
+
speed: S.Number,
|
|
13
|
+
initialAngle: S.Option(S.Number),
|
|
14
|
+
initialSpeedScale: S.Number,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const Message = defineMessageUnion({
|
|
18
|
+
TickedFrame: { deltaTimeMs: S.Number },
|
|
19
|
+
CompletedGenerateAmbientParticle: generatedParticleFields,
|
|
20
|
+
CompletedGenerateBurstParticle: generatedParticleFields,
|
|
21
|
+
PressedCanvas: {
|
|
22
|
+
x: S.Number,
|
|
23
|
+
y: S.Number,
|
|
24
|
+
},
|
|
25
|
+
MovedPointer: {
|
|
26
|
+
x: S.Number,
|
|
27
|
+
y: S.Number,
|
|
28
|
+
},
|
|
29
|
+
ClickedTogglePlay: {},
|
|
30
|
+
ClickedReset: {},
|
|
31
|
+
GotFlowStrengthSliderMessage: { message: Slider.Message },
|
|
32
|
+
GotNoiseScaleSliderMessage: { message: Slider.Message },
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
export type Message = typeof Message.Type
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Schema as S } from 'effect'
|
|
2
|
+
|
|
3
|
+
import { Slider } from '@foldkit/ui'
|
|
4
|
+
|
|
5
|
+
export const Point = S.Struct({ x: S.Number, y: S.Number })
|
|
6
|
+
export type Point = typeof Point.Type
|
|
7
|
+
|
|
8
|
+
export const Particle = S.Struct({
|
|
9
|
+
id: S.Number,
|
|
10
|
+
trail: S.Array(Point),
|
|
11
|
+
baseHue: S.Number,
|
|
12
|
+
hueDriftPerSecond: S.Number,
|
|
13
|
+
ageMs: S.Number,
|
|
14
|
+
lifespanMs: S.Number,
|
|
15
|
+
speed: S.Number,
|
|
16
|
+
bornAtSeconds: S.Number,
|
|
17
|
+
initialAngle: S.Option(S.Number),
|
|
18
|
+
initialSpeedScale: S.Number,
|
|
19
|
+
})
|
|
20
|
+
export type Particle = typeof Particle.Type
|
|
21
|
+
|
|
22
|
+
export const Model = S.Struct({
|
|
23
|
+
particles: S.Array(Particle),
|
|
24
|
+
nextId: S.Number,
|
|
25
|
+
elapsedSeconds: S.Number,
|
|
26
|
+
maybeMousePosition: S.Option(Point),
|
|
27
|
+
isRunning: S.Boolean,
|
|
28
|
+
flowStrength: S.Number,
|
|
29
|
+
flowStrengthSlider: Slider.Model,
|
|
30
|
+
noiseScale: S.Number,
|
|
31
|
+
noiseScaleSlider: Slider.Model,
|
|
32
|
+
})
|
|
33
|
+
export type Model = typeof Model.Type
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Array } from 'effect'
|
|
2
|
+
|
|
3
|
+
const FADE_QUINTIC_COEFFICIENT = 6
|
|
4
|
+
const FADE_QUARTIC_COEFFICIENT = 15
|
|
5
|
+
const FADE_CUBIC_COEFFICIENT = 10
|
|
6
|
+
|
|
7
|
+
const HASH_PRIME_X = 374761393
|
|
8
|
+
const HASH_PRIME_Y = 668265263
|
|
9
|
+
const HASH_PRIME_FINAL = 1274126177
|
|
10
|
+
const HASH_SHIFT_INTERMIX = 13
|
|
11
|
+
const HASH_SHIFT_AVALANCHE = 16
|
|
12
|
+
const UINT32_RANGE = 0x100000000
|
|
13
|
+
|
|
14
|
+
const TWO_PI = Math.PI * 2
|
|
15
|
+
|
|
16
|
+
const fade = (t: number): number =>
|
|
17
|
+
t *
|
|
18
|
+
t *
|
|
19
|
+
t *
|
|
20
|
+
(t * (t * FADE_QUINTIC_COEFFICIENT - FADE_QUARTIC_COEFFICIENT) +
|
|
21
|
+
FADE_CUBIC_COEFFICIENT)
|
|
22
|
+
|
|
23
|
+
const lerp = (a: number, b: number, t: number): number => a + (b - a) * t
|
|
24
|
+
|
|
25
|
+
const gradientAngle = (ix: number, iy: number): number => {
|
|
26
|
+
const seeded = (ix * HASH_PRIME_X + iy * HASH_PRIME_Y) | 0
|
|
27
|
+
const mixed =
|
|
28
|
+
((seeded ^ (seeded >>> HASH_SHIFT_INTERMIX)) * HASH_PRIME_FINAL) | 0
|
|
29
|
+
const avalanched = (mixed ^ (mixed >>> HASH_SHIFT_AVALANCHE)) >>> 0
|
|
30
|
+
return (avalanched / UINT32_RANGE) * TWO_PI
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const dotGradient = (
|
|
34
|
+
ix: number,
|
|
35
|
+
iy: number,
|
|
36
|
+
dx: number,
|
|
37
|
+
dy: number,
|
|
38
|
+
): number => {
|
|
39
|
+
const angle = gradientAngle(ix, iy)
|
|
40
|
+
return Math.cos(angle) * dx + Math.sin(angle) * dy
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 2D Perlin noise. Returns a smooth pseudo-random value in roughly [-1, 1] for
|
|
45
|
+
* any real-valued `(x, y)`. The same input always produces the same output;
|
|
46
|
+
* neighbouring inputs produce smoothly varying outputs. Use small fractional
|
|
47
|
+
* scales (e.g. multiply coordinates by 0.005) to get broad organic gradients.
|
|
48
|
+
*/
|
|
49
|
+
export const perlin2 = (x: number, y: number): number => {
|
|
50
|
+
const x0 = Math.floor(x)
|
|
51
|
+
const y0 = Math.floor(y)
|
|
52
|
+
const x1 = x0 + 1
|
|
53
|
+
const y1 = y0 + 1
|
|
54
|
+
const fx = x - x0
|
|
55
|
+
const fy = y - y0
|
|
56
|
+
const u = fade(fx)
|
|
57
|
+
const v = fade(fy)
|
|
58
|
+
const n00 = dotGradient(x0, y0, fx, fy)
|
|
59
|
+
const n10 = dotGradient(x1, y0, fx - 1, fy)
|
|
60
|
+
const n01 = dotGradient(x0, y1, fx, fy - 1)
|
|
61
|
+
const n11 = dotGradient(x1, y1, fx - 1, fy - 1)
|
|
62
|
+
return lerp(lerp(n00, n10, u), lerp(n01, n11, u), v)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Sum several octaves of `perlin2` into fractal Brownian motion. Higher
|
|
67
|
+
* `octaves` add finer detail; `persistence` (0..1) controls how quickly
|
|
68
|
+
* higher octaves fade, and `lacunarity` (>1) controls how much frequency
|
|
69
|
+
* each octave adds. The result is normalised back to roughly [-1, 1].
|
|
70
|
+
*/
|
|
71
|
+
export const fractalNoise = (
|
|
72
|
+
x: number,
|
|
73
|
+
y: number,
|
|
74
|
+
octaves: number,
|
|
75
|
+
persistence: number,
|
|
76
|
+
lacunarity: number,
|
|
77
|
+
): number => {
|
|
78
|
+
const seed = { total: 0, weight: 0, amplitude: 1, frequency: 1 }
|
|
79
|
+
const accumulated = Array.reduce(
|
|
80
|
+
Array.makeBy(octaves, octaveIndex => octaveIndex),
|
|
81
|
+
seed,
|
|
82
|
+
accumulator => ({
|
|
83
|
+
total:
|
|
84
|
+
accumulator.total +
|
|
85
|
+
perlin2(x * accumulator.frequency, y * accumulator.frequency) *
|
|
86
|
+
accumulator.amplitude,
|
|
87
|
+
weight: accumulator.weight + accumulator.amplitude,
|
|
88
|
+
amplitude: accumulator.amplitude * persistence,
|
|
89
|
+
frequency: accumulator.frequency * lacunarity,
|
|
90
|
+
}),
|
|
91
|
+
)
|
|
92
|
+
return accumulated.total / accumulated.weight
|
|
93
|
+
}
|