@xmachines/docs 1.0.0-beta.10

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 (197) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/api/@xmachines/play/README.md +130 -0
  4. package/api/@xmachines/play/type-aliases/PlayEvent.md +81 -0
  5. package/api/@xmachines/play-actor/README.md +247 -0
  6. package/api/@xmachines/play-actor/classes/AbstractActor.md +520 -0
  7. package/api/@xmachines/play-actor/interfaces/Routable.md +29 -0
  8. package/api/@xmachines/play-actor/interfaces/ViewMetadata.md +17 -0
  9. package/api/@xmachines/play-actor/interfaces/Viewable.md +12 -0
  10. package/api/@xmachines/play-catalog/README.md +331 -0
  11. package/api/@xmachines/play-catalog/functions/defineCatalog.md +98 -0
  12. package/api/@xmachines/play-catalog/functions/defineComponents.md +134 -0
  13. package/api/@xmachines/play-catalog/type-aliases/Catalog.md +48 -0
  14. package/api/@xmachines/play-catalog/type-aliases/ComponentsFor.md +20 -0
  15. package/api/@xmachines/play-catalog/type-aliases/InferComponentProps.md +65 -0
  16. package/api/@xmachines/play-catalog/type-aliases/NoExtraKeys.md +17 -0
  17. package/api/@xmachines/play-react/README.md +423 -0
  18. package/api/@xmachines/play-react/classes/PlayErrorBoundary.md +613 -0
  19. package/api/@xmachines/play-react/functions/useSignalEffect.md +68 -0
  20. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryProps.md +15 -0
  21. package/api/@xmachines/play-react/interfaces/PlayErrorBoundaryState.md +14 -0
  22. package/api/@xmachines/play-react/interfaces/PlayRendererProps.md +15 -0
  23. package/api/@xmachines/play-react/variables/PlayRenderer.md +64 -0
  24. package/api/@xmachines/play-react-router/README.md +198 -0
  25. package/api/@xmachines/play-react-router/classes/ReactRouterBridge.md +321 -0
  26. package/api/@xmachines/play-react-router/classes/RouteMap.md +137 -0
  27. package/api/@xmachines/play-react-router/functions/PlayRouterProvider.md +19 -0
  28. package/api/@xmachines/play-react-router/functions/createRouteMapFromTree.md +35 -0
  29. package/api/@xmachines/play-react-router/interfaces/PlayRouteEvent.md +119 -0
  30. package/api/@xmachines/play-react-router/interfaces/PlayRouterProviderProps.md +14 -0
  31. package/api/@xmachines/play-react-router/interfaces/RouteMapping.md +17 -0
  32. package/api/@xmachines/play-react-router/interfaces/RouterBridge.md +104 -0
  33. package/api/@xmachines/play-react-router-demo/README.md +137 -0
  34. package/api/@xmachines/play-router/README.md +502 -0
  35. package/api/@xmachines/play-router/classes/BaseRouteMap.md +142 -0
  36. package/api/@xmachines/play-router/classes/RouterBridgeBase.md +300 -0
  37. package/api/@xmachines/play-router/functions/buildRouteTree.md +27 -0
  38. package/api/@xmachines/play-router/functions/connectRouter.md +67 -0
  39. package/api/@xmachines/play-router/functions/crawlMachine.md +92 -0
  40. package/api/@xmachines/play-router/functions/createBrowserHistory.md +47 -0
  41. package/api/@xmachines/play-router/functions/createRouteMap.md +53 -0
  42. package/api/@xmachines/play-router/functions/createRouter.md +76 -0
  43. package/api/@xmachines/play-router/functions/detectDuplicateRoutes.md +32 -0
  44. package/api/@xmachines/play-router/functions/extractMachineRoutes.md +64 -0
  45. package/api/@xmachines/play-router/functions/extractRoute.md +45 -0
  46. package/api/@xmachines/play-router/functions/findRouteById.md +37 -0
  47. package/api/@xmachines/play-router/functions/findRouteByPath.md +39 -0
  48. package/api/@xmachines/play-router/functions/getNavigableRoutes.md +35 -0
  49. package/api/@xmachines/play-router/functions/getRoutableRoutes.md +39 -0
  50. package/api/@xmachines/play-router/functions/routeExists.md +26 -0
  51. package/api/@xmachines/play-router/functions/validateRouteFormat.md +29 -0
  52. package/api/@xmachines/play-router/functions/validateStateExists.md +29 -0
  53. package/api/@xmachines/play-router/interfaces/BaseRouteMapping.md +27 -0
  54. package/api/@xmachines/play-router/interfaces/BrowserHistory.md +172 -0
  55. package/api/@xmachines/play-router/interfaces/BrowserWindow.md +69 -0
  56. package/api/@xmachines/play-router/interfaces/ConnectRouterOptions.md +13 -0
  57. package/api/@xmachines/play-router/interfaces/PlayRouteEvent.md +119 -0
  58. package/api/@xmachines/play-router/interfaces/RouteInfo.md +19 -0
  59. package/api/@xmachines/play-router/interfaces/RouteMap.md +56 -0
  60. package/api/@xmachines/play-router/interfaces/RouteNode.md +21 -0
  61. package/api/@xmachines/play-router/interfaces/RouteObject.md +21 -0
  62. package/api/@xmachines/play-router/interfaces/RouteTree.md +20 -0
  63. package/api/@xmachines/play-router/interfaces/RouterBridge.md +104 -0
  64. package/api/@xmachines/play-router/interfaces/StateVisit.md +15 -0
  65. package/api/@xmachines/play-router/interfaces/VanillaRouter.md +28 -0
  66. package/api/@xmachines/play-router/type-aliases/RouteMetadata.md +11 -0
  67. package/api/@xmachines/play-router-demo/README.md +137 -0
  68. package/api/@xmachines/play-signals/README.md +176 -0
  69. package/api/@xmachines/play-signals/interfaces/ComputedOptions.md +34 -0
  70. package/api/@xmachines/play-signals/interfaces/SignalComputed.md +49 -0
  71. package/api/@xmachines/play-signals/interfaces/SignalOptions.md +35 -0
  72. package/api/@xmachines/play-signals/interfaces/SignalState.md +68 -0
  73. package/api/@xmachines/play-signals/interfaces/SignalWatcher.md +97 -0
  74. package/api/@xmachines/play-signals/namespaces/Signal/README.md +22 -0
  75. package/api/@xmachines/play-signals/namespaces/Signal/classes/Computed.md +52 -0
  76. package/api/@xmachines/play-signals/namespaces/Signal/classes/State.md +72 -0
  77. package/api/@xmachines/play-signals/namespaces/Signal/interfaces/Options.md +19 -0
  78. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/README.md +21 -0
  79. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/classes/Watcher.md +85 -0
  80. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/currentComputed.md +13 -0
  81. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSinks.md +19 -0
  82. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/hasSources.md +19 -0
  83. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSinks.md +19 -0
  84. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/introspectSources.md +19 -0
  85. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/functions/untrack.md +25 -0
  86. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/unwatched.md +9 -0
  87. package/api/@xmachines/play-signals/namespaces/Signal/namespaces/subtle/variables/watched.md +9 -0
  88. package/api/@xmachines/play-signals/namespaces/Signal/variables/isComputed.md +19 -0
  89. package/api/@xmachines/play-signals/namespaces/Signal/variables/isState.md +19 -0
  90. package/api/@xmachines/play-signals/namespaces/Signal/variables/isWatcher.md +19 -0
  91. package/api/@xmachines/play-signals/type-aliases/WatcherNotify.md +32 -0
  92. package/api/@xmachines/play-solid/README.md +311 -0
  93. package/api/@xmachines/play-solid/interfaces/PlayRendererProps.md +15 -0
  94. package/api/@xmachines/play-solid/variables/PlayRenderer.md +70 -0
  95. package/api/@xmachines/play-solid-router/README.md +666 -0
  96. package/api/@xmachines/play-solid-router/classes/RouteMap.md +150 -0
  97. package/api/@xmachines/play-solid-router/classes/SolidRouterBridge.md +347 -0
  98. package/api/@xmachines/play-solid-router/functions/PlayRouterProvider.md +19 -0
  99. package/api/@xmachines/play-solid-router/functions/createRouteMap.md +32 -0
  100. package/api/@xmachines/play-solid-router/interfaces/AbstractActor.md +486 -0
  101. package/api/@xmachines/play-solid-router/interfaces/PlayRouteEvent.md +119 -0
  102. package/api/@xmachines/play-solid-router/interfaces/PlayRouterProviderProps.md +14 -0
  103. package/api/@xmachines/play-solid-router/interfaces/RouteMapping.md +14 -0
  104. package/api/@xmachines/play-solid-router/interfaces/RouterBridge.md +104 -0
  105. package/api/@xmachines/play-solid-router/type-aliases/RoutableActor.md +9 -0
  106. package/api/@xmachines/play-solid-router/type-aliases/SolidRouterHooks.md +51 -0
  107. package/api/@xmachines/play-solid-router-demo/README.md +127 -0
  108. package/api/@xmachines/play-tanstack-react-router/README.md +226 -0
  109. package/api/@xmachines/play-tanstack-react-router/classes/RouteMap.md +137 -0
  110. package/api/@xmachines/play-tanstack-react-router/classes/TanStackReactRouterBridge.md +348 -0
  111. package/api/@xmachines/play-tanstack-react-router/functions/PlayRouterProvider.md +19 -0
  112. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMap.md +53 -0
  113. package/api/@xmachines/play-tanstack-react-router/functions/createRouteMapFromTree.md +35 -0
  114. package/api/@xmachines/play-tanstack-react-router/functions/extractParams.md +38 -0
  115. package/api/@xmachines/play-tanstack-react-router/functions/extractQueryParams.md +33 -0
  116. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouteEvent.md +119 -0
  117. package/api/@xmachines/play-tanstack-react-router/interfaces/PlayRouterProviderProps.md +14 -0
  118. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteMapping.md +17 -0
  119. package/api/@xmachines/play-tanstack-react-router/interfaces/RouteNavigateEvent.md +26 -0
  120. package/api/@xmachines/play-tanstack-react-router/interfaces/RouterBridge.md +104 -0
  121. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterInstance.md +9 -0
  122. package/api/@xmachines/play-tanstack-react-router/type-aliases/TanStackRouterLike.md +78 -0
  123. package/api/@xmachines/play-tanstack-react-router/variables/extractMachineRoutes.md +64 -0
  124. package/api/@xmachines/play-tanstack-react-router-demo/README.md +126 -0
  125. package/api/@xmachines/play-tanstack-solid-router/README.md +285 -0
  126. package/api/@xmachines/play-tanstack-solid-router/classes/RouteMap.md +150 -0
  127. package/api/@xmachines/play-tanstack-solid-router/classes/SolidRouterBridge.md +343 -0
  128. package/api/@xmachines/play-tanstack-solid-router/functions/PlayRouterProvider.md +19 -0
  129. package/api/@xmachines/play-tanstack-solid-router/functions/createRouteMap.md +32 -0
  130. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouteEvent.md +119 -0
  131. package/api/@xmachines/play-tanstack-solid-router/interfaces/PlayRouterProviderProps.md +14 -0
  132. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouteMapping.md +23 -0
  133. package/api/@xmachines/play-tanstack-solid-router/interfaces/RouterBridge.md +104 -0
  134. package/api/@xmachines/play-tanstack-solid-router/type-aliases/RoutableActor.md +9 -0
  135. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterInstance.md +9 -0
  136. package/api/@xmachines/play-tanstack-solid-router/type-aliases/TanStackRouterLike.md +78 -0
  137. package/api/@xmachines/play-tanstack-solid-router-demo/README.md +126 -0
  138. package/api/@xmachines/play-vue/README.md +292 -0
  139. package/api/@xmachines/play-vue/interfaces/PlayRendererProps.md +14 -0
  140. package/api/@xmachines/play-vue/variables/PlayRenderer.md +9 -0
  141. package/api/@xmachines/play-vue-router/README.md +604 -0
  142. package/api/@xmachines/play-vue-router/classes/RouteMap.md +209 -0
  143. package/api/@xmachines/play-vue-router/classes/VueBaseRouteMap.md +201 -0
  144. package/api/@xmachines/play-vue-router/classes/VueRouterBridge.md +360 -0
  145. package/api/@xmachines/play-vue-router/functions/createRouteMap.md +19 -0
  146. package/api/@xmachines/play-vue-router/interfaces/PlayRouteEvent.md +119 -0
  147. package/api/@xmachines/play-vue-router/interfaces/RouteMapping.md +15 -0
  148. package/api/@xmachines/play-vue-router/interfaces/RouterBridge.md +104 -0
  149. package/api/@xmachines/play-vue-router/type-aliases/RoutableActor.md +9 -0
  150. package/api/@xmachines/play-vue-router/variables/PlayRouterProvider.md +67 -0
  151. package/api/@xmachines/play-vue-router-demo/README.md +133 -0
  152. package/api/@xmachines/play-xstate/README.md +512 -0
  153. package/api/@xmachines/play-xstate/classes/PlayerActor.md +527 -0
  154. package/api/@xmachines/play-xstate/functions/buildRouteUrl.md +43 -0
  155. package/api/@xmachines/play-xstate/functions/composeGuards.md +79 -0
  156. package/api/@xmachines/play-xstate/functions/composeGuardsOr.md +67 -0
  157. package/api/@xmachines/play-xstate/functions/definePlayer.md +127 -0
  158. package/api/@xmachines/play-xstate/functions/deriveRoute.md +109 -0
  159. package/api/@xmachines/play-xstate/functions/eventMatches.md +40 -0
  160. package/api/@xmachines/play-xstate/functions/formatPlayRouteTransitions.md +54 -0
  161. package/api/@xmachines/play-xstate/functions/hasContext.md +42 -0
  162. package/api/@xmachines/play-xstate/functions/isAbsoluteRoute.md +41 -0
  163. package/api/@xmachines/play-xstate/functions/mergeViewProps.md +26 -0
  164. package/api/@xmachines/play-xstate/functions/negateGuard.md +61 -0
  165. package/api/@xmachines/play-xstate/functions/stateMatches.md +25 -0
  166. package/api/@xmachines/play-xstate/functions/validateComponentBinding.md +39 -0
  167. package/api/@xmachines/play-xstate/functions/validateViewProps.md +80 -0
  168. package/api/@xmachines/play-xstate/interfaces/CatalogEntry.md +16 -0
  169. package/api/@xmachines/play-xstate/interfaces/PlayerConfig.md +24 -0
  170. package/api/@xmachines/play-xstate/interfaces/PlayerOptions.md +26 -0
  171. package/api/@xmachines/play-xstate/interfaces/RouteContext.md +22 -0
  172. package/api/@xmachines/play-xstate/type-aliases/Catalog.md +21 -0
  173. package/api/@xmachines/play-xstate/type-aliases/ComposedGuard.md +14 -0
  174. package/api/@xmachines/play-xstate/type-aliases/Guard.md +34 -0
  175. package/api/@xmachines/play-xstate/type-aliases/GuardArray.md +20 -0
  176. package/api/@xmachines/play-xstate/type-aliases/PlayerFactory.md +29 -0
  177. package/api/@xmachines/play-xstate/type-aliases/RouteMachineConfig.md +45 -0
  178. package/api/@xmachines/play-xstate/type-aliases/RouteStateNode.md +51 -0
  179. package/api/@xmachines/play-xstate/type-aliases/ValidationResult.md +17 -0
  180. package/api/@xmachines/play-xstate/type-aliases/ViewMergeContext.md +35 -0
  181. package/api/@xmachines/shared/README.md +379 -0
  182. package/api/@xmachines/shared/functions/defineXmVitestConfig.md +29 -0
  183. package/api/@xmachines/shared/functions/xmAliases.md +24 -0
  184. package/api/README.md +25 -0
  185. package/api/llms.txt +26 -0
  186. package/examples/README.md +63 -0
  187. package/examples/basic-state-machine.md +70 -0
  188. package/examples/form-validation.md +167 -0
  189. package/examples/multi-router-integration.md +277 -0
  190. package/examples/routing-patterns.md +260 -0
  191. package/examples/traffic-light.md +99 -0
  192. package/guides/README.md +29 -0
  193. package/guides/getting-started.md +223 -0
  194. package/guides/installation.md +323 -0
  195. package/index.d.ts +3 -0
  196. package/index.js +4 -0
  197. package/package.json +54 -0
@@ -0,0 +1,379 @@
1
+ [Documentation](../../README.md) / @xmachines/shared
2
+
3
+ # @xmachines/shared
4
+
5
+ **Shared TypeScript, linting, and formatting configurations for XMachines monorepo**
6
+
7
+ Centralized config enabling composite build system with project references.
8
+
9
+ ## Overview
10
+
11
+ `@xmachines/shared` provides shared configuration files for all XMachines packages, establishing consistent TypeScript compilation, linting rules, formatting, and Vitest setup across the monorepo.
12
+
13
+ **Enhancement:** Added TypeScript composite build system with project references enabling correct build order, incremental compilation, and IDE source navigation via declaration maps.
14
+
15
+ ## Installation
16
+
17
+ This package is automatically available to all workspace packages via npm workspaces.
18
+
19
+ ## Contents
20
+
21
+ Configuration files in `config/` directory:
22
+
23
+ - **`config/tsconfig.json`** - TypeScript compiler settings with composite project support
24
+ - **`config/oxlint.json`** - Linting rules and plugins
25
+ - **`config/oxfmt.json`** - Code formatting preferences
26
+ - **`config/vitest.ts`** - Shared Vitest config helper (`defineXmVitestConfig`)
27
+ - **`config/vitest.setup.ts`** - Shared cross-runtime Vitest setup (polyfills, jest-dom matchers)
28
+ - **`config/vitest.node.setup.ts`** - Node-only Vitest setup (Node runtime/version preflight)
29
+ - **`config/vite-aliases.ts`** - Workspace alias mapping for `@xmachines/*`
30
+
31
+ ## Usage
32
+
33
+ ### TypeScript Configuration
34
+
35
+ **Recommended (short alias):**
36
+
37
+ ```json
38
+ {
39
+ "extends": "@xmachines/shared/tsconfig",
40
+ "compilerOptions": {
41
+ "composite": true,
42
+ "rootDir": "./src",
43
+ "outDir": "./dist"
44
+ }
45
+ }
46
+ ```
47
+
48
+ **Alternative (full path):**
49
+
50
+ ```json
51
+ {
52
+ "extends": "@xmachines/shared/config/tsconfig.json",
53
+ "compilerOptions": {
54
+ "composite": true,
55
+ "rootDir": "./src",
56
+ "outDir": "./dist"
57
+ }
58
+ }
59
+ ```
60
+
61
+ > **Note:** Both import styles work. The short alias is recommended for cleaner config files.
62
+
63
+ ### Oxlint Configuration
64
+
65
+ **Recommended:**
66
+
67
+ ```json
68
+ {
69
+ "extends": ["@xmachines/shared/oxlint"]
70
+ }
71
+ ```
72
+
73
+ ### Oxfmt Configuration
74
+
75
+ **Recommended:**
76
+
77
+ ```json
78
+ {
79
+ "extends": ["@xmachines/shared/oxfmt"]
80
+ }
81
+ ```
82
+
83
+ ### Vite Alias Configuration
84
+
85
+ Use the shared alias helper in Vite and Vitest configs so workspace packages resolve to source files without requiring `dist/` builds:
86
+
87
+ ```ts
88
+ import { defineConfig } from "vite";
89
+ import { xmAliases } from "@xmachines/shared/vite-aliases";
90
+
91
+ export default defineConfig({
92
+ resolve: {
93
+ alias: xmAliases(import.meta.url),
94
+ },
95
+ });
96
+ ```
97
+
98
+ This is especially important after `npm run clean`, where package `exports` targeting `dist/` are temporarily unavailable until rebuild.
99
+
100
+ ### Vitest Configuration
101
+
102
+ Use the shared helper so package configs inherit common aliasing and runtime setup:
103
+
104
+ ```ts
105
+ import { defineXmVitestConfig } from "@xmachines/shared/vitest";
106
+
107
+ export default defineXmVitestConfig(import.meta.url, {
108
+ test: {
109
+ environment: "node",
110
+ include: ["test/**/*.test.ts"],
111
+ exclude: ["node_modules/**"],
112
+ },
113
+ });
114
+ ```
115
+
116
+ **Browser project example:**
117
+
118
+ ```ts
119
+ import { defineXmVitestConfig } from "@xmachines/shared/vitest";
120
+ import { playwright } from "@vitest/browser-playwright";
121
+
122
+ export default defineXmVitestConfig(import.meta.url, {
123
+ test: {
124
+ name: "my-demo-browser",
125
+ browser: {
126
+ enabled: true,
127
+ provider: playwright(),
128
+ headless: true,
129
+ instances: [{ browser: "chromium" }],
130
+ },
131
+ include: ["test/browser/**/*.browser.test.ts"],
132
+ exclude: ["node_modules/**"],
133
+ },
134
+ });
135
+ ```
136
+
137
+ What the shared Vitest layer provides automatically:
138
+
139
+ - `resolve.alias` for all `@xmachines/*` packages via `xmAliases(...)`
140
+ - Shared setup injection (`config/vitest.setup.ts`) unless already present
141
+ - Node setup injection (`config/vitest.node.setup.ts`) for non-browser projects
142
+ - Runtime preflight:
143
+ - Node.js runtime/version check (`>=22`) in node setup
144
+ - DOM matcher extension via `@testing-library/jest-dom/vitest`
145
+
146
+ ### Vitest Setup Injection Rules
147
+
148
+ `defineXmVitestConfig(...)` applies setup files predictably:
149
+
150
+ 1. It normalizes `test.setupFiles` into an array.
151
+ 2. It injects `config/vitest.setup.ts` if missing.
152
+ 3. It injects `config/vitest.node.setup.ts` only when `test.browser.enabled !== true`.
153
+ 4. It avoids duplicates by checking filenames (suffix match).
154
+ 5. Injected setup files run before user-provided setup files.
155
+
156
+ This gives a safe default for Node package tests while keeping browser projects compatible.
157
+
158
+ ### Vitest Exports
159
+
160
+ `@xmachines/shared` exports these Vitest entry points:
161
+
162
+ - `@xmachines/shared/vitest` → `config/vitest.ts`
163
+ - `@xmachines/shared/vitest-setup` → `config/vitest.setup.ts`
164
+ - `@xmachines/shared/vitest-node-setup` → `config/vitest.node.setup.ts`
165
+ - `@xmachines/shared/vitest-urlpattern-setup` → `config/vitest.urlpattern.setup.ts`
166
+
167
+ Use `@xmachines/shared/vitest` for package config files; direct setup exports are for advanced customization only.
168
+
169
+ `vitest-urlpattern-setup` must be added explicitly to `setupFiles` in packages that exercise URLPattern-based route matching (e.g. `play-router` and its adapter packages). It mirrors what consumers must do in production on Node < 24 or older browsers.
170
+
171
+ ## Configuration Details
172
+
173
+ ### TypeScript (`config/tsconfig.json`)
174
+
175
+ - **Target:** ESNext (Node.js 22+)
176
+ - **Module:** NodeNext (ESM with `.js` extensions required)
177
+ - **Strict:** Full strict mode enabled
178
+ - **Output:** Colocated `.d.ts` files with source maps
179
+ - **Composite:** Enabled for project references ()
180
+
181
+ **Important:** You must use `.js` extensions in imports:
182
+
183
+ ```typescript
184
+ import { foo } from "./bar.js"; // ✅ Correct
185
+ import { foo } from "./bar"; // ❌ Wrong
186
+ ```
187
+
188
+ ### Oxlint (`config/oxlint.json`)
189
+
190
+ - **Plugins:** TypeScript, Unicorn, Import
191
+ - **Categories:** Correctness (error), Suspicious (warn), Performance (warn)
192
+ - **Key Rules:**
193
+ - Circular dependency detection (`import/no-cycle`)
194
+ - Unused variables (allow `_` prefix)
195
+ - TypeScript-specific checks
196
+
197
+ ### Oxfmt (`config/oxfmt.json`)
198
+
199
+ - **Line Width:** 100 characters
200
+ - **Indentation:** Tabs (4 spaces)
201
+ - **Style:** Double quotes, semicolons, trailing commas
202
+ - **Final Newline:** Always insert
203
+
204
+ ### Vitest (`config/vitest.ts`, `config/vitest.setup.ts`, `config/vitest.node.setup.ts`, `config/vitest.urlpattern.setup.ts`)
205
+
206
+ - **Helper API:** `defineXmVitestConfig(importMetaUrl, overrides)` merges shared defaults with package-specific Vitest config
207
+ - **Auto-aliasing:** `resolve.alias` is wired to `xmAliases(importMetaUrl)` so workspace packages resolve to source
208
+ - **Cross-runtime setup (`config/vitest.setup.ts`):**
209
+ - extends `expect` with `@testing-library/jest-dom/vitest`
210
+ - **URLPattern setup (`config/vitest.urlpattern.setup.ts`):**
211
+ - loads `urlpattern-polyfill` — opt-in per package via `setupFiles: ["@xmachines/shared/vitest-urlpattern-setup"]`
212
+ - required for packages exercising URLPattern-based route matching (play-router and adapters)
213
+ - mirrors what consumers must do in production on Node < 24 or older browsers
214
+ - **Node-only setup (`config/vitest.node.setup.ts`):**
215
+ - asserts Node runtime (`process.release.name === "node"`)
216
+ - enforces Node version `>=22`
217
+ - **Browser behavior:** Browser projects do not receive node-only setup injection
218
+ - **Override model:** Package-level config still controls test environment, includes/excludes, plugins, coverage, and browser provider
219
+
220
+ ### Vite Aliases (`config/vite-aliases.ts`)
221
+
222
+ - **Helper API:** `xmAliases(importMetaUrl)` returns a complete `resolve.alias` map for all `@xmachines/*` workspace packages
223
+ - **Root discovery:** Walks upward from `import.meta.url` until it finds the workspace root (`package.json` with `workspaces`)
224
+ - **Source-first resolution:** Maps package imports to `packages/*/src/index.ts` for fast local dev without prebuild
225
+ - **Extra aliases:** Includes `@xmachines/play-router-shared` and `@xmachines/play-router-shared/index.css` for demo shared assets
226
+ - **Primary use cases:** `vite.config.ts`, `vitest` browser configs, and any local tooling relying on Vite resolver semantics
227
+
228
+ ### Vite Alias Troubleshooting
229
+
230
+ - **`[xmAliases] Could not find workspace root`**
231
+ - Ensure `xmAliases` receives `import.meta.url` from the calling config file.
232
+ - Ensure the config file lives somewhere under the monorepo root.
233
+ - **Workspace package import resolves to missing `dist/` files**
234
+ - Ensure config includes `resolve.alias: xmAliases(import.meta.url)`.
235
+ - Re-run after cleaning caches when lockfile/deps changed.
236
+
237
+ ### Vitest Troubleshooting
238
+
239
+ - **`URLPattern is unavailable after setup`**
240
+ - Ensure `test.setupFiles` is not replacing shared setup unexpectedly.
241
+ - Ensure config is created via `defineXmVitestConfig(...)`.
242
+ - **`Node runtime is required for this Vitest configuration`**
243
+ - This indicates node-only setup loaded in a browser project.
244
+ - Set `test.browser.enabled: true` in that project config.
245
+ - **Workspace import resolution failures (e.g. `@xmachines/play-signals`)**
246
+ - Confirm config uses `defineXmVitestConfig(import.meta.url, ...)` so aliases are injected.
247
+
248
+ ## TypeScript Composite Build System
249
+
250
+ This package introduced TypeScript project references for proper build-order management in the monorepo.
251
+
252
+ ### What This Means
253
+
254
+ - **Root `tsconfig.json`** coordinates all packages via `references` array
255
+ - **Each package** has `composite: true` enabling incremental builds
256
+ - **Packages with dependencies** declare `references` to their deps
257
+ - **TypeScript builds in correct order automatically** (no manual sequencing needed)
258
+
259
+ ### Building
260
+
261
+ ```bash
262
+ npm run build # Root-level tsc --build handles everything
263
+ npm run build -w <pkg> # Automatically builds dependencies first
264
+ ```
265
+
266
+ The root build command uses `tsc --build` which:
267
+
268
+ - Understands the dependency graph
269
+ - Builds packages in correct order
270
+ - Only rebuilds changed packages (incremental)
271
+ - Produces `.d.ts.map` files for IDE navigation
272
+
273
+ ### Declaration Maps
274
+
275
+ The base config enables **declaration maps** (`declarationMap: true`) for better IDE experience in composite projects.
276
+
277
+ When TypeScript compiles with `declarationMap: true`, it produces `.d.ts.map` files that map type definitions back to source. This enables:
278
+
279
+ - **Go to Definition** jumps to `.ts` source files (not compiled `.d.ts`)
280
+ - **Rename refactoring** works across package boundaries
281
+ - **Error messages** reference source locations
282
+
283
+ **Cost:** Slightly larger `dist/` output (~10% more)
284
+ **Benefit:** Dramatically better IDE experience
285
+
286
+ ### Project References
287
+
288
+ Packages with internal dependencies should declare `references` in their `tsconfig.json`:
289
+
290
+ ```json
291
+ {
292
+ "extends": "@xmachines/shared/tsconfig",
293
+ "compilerOptions": {
294
+ "composite": true,
295
+ "rootDir": "./src",
296
+ "outDir": "./dist"
297
+ },
298
+ "references": [{ "path": "../dependency-package" }]
299
+ }
300
+ ```
301
+
302
+ The root `tsconfig.json` maintains the full package reference graph, enabling TypeScript to:
303
+
304
+ - Build packages in correct dependency order
305
+ - Support incremental builds (only rebuild what changed)
306
+ - Enable cross-package type checking and navigation
307
+
308
+ ### Adding New Packages
309
+
310
+ When creating a new package:
311
+
312
+ 1. **Add to root tsconfig.json references:**
313
+
314
+ ```json
315
+ {
316
+ "references": [{ "path": "./packages/your-new-package" }]
317
+ }
318
+ ```
319
+
320
+ 2. **Enable composite in package tsconfig.json:**
321
+
322
+ ```json
323
+ {
324
+ "extends": "@xmachines/shared/tsconfig",
325
+ "compilerOptions": {
326
+ "composite": true,
327
+ "rootDir": "./src",
328
+ "outDir": "./dist"
329
+ }
330
+ }
331
+ ```
332
+
333
+ 3. **Declare dependencies (if any):**
334
+ ```json
335
+ {
336
+ "references": [{ "path": "../dependency-package" }]
337
+ }
338
+ ```
339
+
340
+ ### IDE Benefits
341
+
342
+ With `declarationMap: true` in the base config:
343
+
344
+ - **Go to Definition** jumps to source files (not compiled `.d.ts`)
345
+ - **Real-time errors** across package boundaries
346
+ - **Refactoring works** across the entire monorepo
347
+
348
+ No build required for IDE features - TypeScript understands the source graph directly.
349
+
350
+ See `AGENTS.md` (section: TypeScript Composite Build System) for complete composite build documentation.
351
+
352
+ ## Adding New Configurations
353
+
354
+ To add a new shared configuration (e.g., for Jest, Vitest, etc.):
355
+
356
+ 1. Create `config/<tool>.json` (or `.js`, `.ts` as appropriate)
357
+ 2. Add exports to `package.json` exports field:
358
+ ```json
359
+ {
360
+ "exports": {
361
+ "./<tool>": "./config/<tool>.json",
362
+ "./config/<tool>.json": "./config/<tool>.json"
363
+ }
364
+ }
365
+ ```
366
+ 3. Document in this README with usage examples
367
+ 4. Note whether the tool supports package exports or requires relative paths
368
+
369
+ ## License
370
+
371
+ Copyright (c) 2016 [Mikael Karon](mailto:mikael@karon.se). All rights reserved.
372
+
373
+ This work is licensed under the terms of the MIT license.
374
+ For a copy, see <https://opensource.org/licenses/MIT>.
375
+
376
+ ## Functions
377
+
378
+ - [defineXmVitestConfig](functions/defineXmVitestConfig.md)
379
+ - [xmAliases](functions/xmAliases.md)
@@ -0,0 +1,29 @@
1
+ [Documentation](../../../README.md) / [@xmachines/shared](../README.md) / defineXmVitestConfig
2
+
3
+ # Function: defineXmVitestConfig()
4
+
5
+ ```ts
6
+ function defineXmVitestConfig(importMetaUrl, overrides): object;
7
+ ```
8
+
9
+ Defined in: [src/index.ts:10](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/shared/src/index.ts#L10)
10
+
11
+ Create a Vitest config with XMachines workspace defaults.
12
+
13
+ This wrapper exposes the helper at the package top-level so API docs
14
+ render it under `@xmachines/shared` instead of nested module pages.
15
+
16
+ ## Parameters
17
+
18
+ | Parameter | Type |
19
+ | --------------- | ------------------------------- |
20
+ | `importMetaUrl` | `string` |
21
+ | `overrides` | `Record`\<`string`, `unknown`\> |
22
+
23
+ ## Returns
24
+
25
+ `object`
26
+
27
+ | Name | Type | Defined in |
28
+ | ------ | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
29
+ | `test` | `any` | [config/vitest.ts:82](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/shared/config/vitest.ts#L82) |
@@ -0,0 +1,24 @@
1
+ [Documentation](../../../README.md) / [@xmachines/shared](../README.md) / xmAliases
2
+
3
+ # Function: xmAliases()
4
+
5
+ ```ts
6
+ function xmAliases(importMetaUrl): Record<string, string>;
7
+ ```
8
+
9
+ Defined in: [src/index.ts:20](https://gitlab.com/xmachin-es/xmachines-js/-/blob/00a28432ed57807112288436d1ae4387d9f06919/packages/shared/src/index.ts#L20)
10
+
11
+ Build Vite/Vitest alias entries for all `@xmachines/*` workspace packages.
12
+
13
+ This wrapper exposes the helper at the package top-level so API docs
14
+ render it under `@xmachines/shared` instead of nested module pages.
15
+
16
+ ## Parameters
17
+
18
+ | Parameter | Type |
19
+ | --------------- | -------- |
20
+ | `importMetaUrl` | `string` |
21
+
22
+ ## Returns
23
+
24
+ `Record`\<`string`, `string`\>
package/api/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Documentation
2
+
3
+ ## Packages
4
+
5
+ - [@xmachines/play](@xmachines/play/README.md)
6
+ - [@xmachines/play-actor](@xmachines/play-actor/README.md)
7
+ - [@xmachines/play-catalog](@xmachines/play-catalog/README.md)
8
+ - [@xmachines/play-react](@xmachines/play-react/README.md)
9
+ - [@xmachines/play-react-router](@xmachines/play-react-router/README.md)
10
+ - [@xmachines/play-react-router-demo](@xmachines/play-react-router-demo/README.md)
11
+ - [@xmachines/play-router](@xmachines/play-router/README.md)
12
+ - [@xmachines/play-router-demo](@xmachines/play-router-demo/README.md)
13
+ - [@xmachines/play-signals](@xmachines/play-signals/README.md)
14
+ - [@xmachines/play-solid](@xmachines/play-solid/README.md)
15
+ - [@xmachines/play-solid-router](@xmachines/play-solid-router/README.md)
16
+ - [@xmachines/play-solid-router-demo](@xmachines/play-solid-router-demo/README.md)
17
+ - [@xmachines/play-tanstack-react-router](@xmachines/play-tanstack-react-router/README.md)
18
+ - [@xmachines/play-tanstack-react-router-demo](@xmachines/play-tanstack-react-router-demo/README.md)
19
+ - [@xmachines/play-tanstack-solid-router](@xmachines/play-tanstack-solid-router/README.md)
20
+ - [@xmachines/play-tanstack-solid-router-demo](@xmachines/play-tanstack-solid-router-demo/README.md)
21
+ - [@xmachines/play-vue](@xmachines/play-vue/README.md)
22
+ - [@xmachines/play-vue-router](@xmachines/play-vue-router/README.md)
23
+ - [@xmachines/play-vue-router-demo](@xmachines/play-vue-router-demo/README.md)
24
+ - [@xmachines/play-xstate](@xmachines/play-xstate/README.md)
25
+ - [@xmachines/shared](@xmachines/shared/README.md)
package/api/llms.txt ADDED
@@ -0,0 +1,26 @@
1
+ #
2
+
3
+ > Documentation for XMachines
4
+
5
+ ## API
6
+ - [@xmachines/play](@xmachines/play/README.md): @xmachines/play module
7
+ - [@xmachines/play-actor](@xmachines/play-actor/README.md): @xmachines/play-actor module
8
+ - [@xmachines/play-catalog](@xmachines/play-catalog/README.md): @xmachines/play-catalog module
9
+ - [@xmachines/play-react](@xmachines/play-react/README.md): @xmachines/play-react module
10
+ - [@xmachines/play-react-router](@xmachines/play-react-router/README.md): @xmachines/play-react-router module
11
+ - [@xmachines/play-react-router-demo](@xmachines/play-react-router-demo/README.md): @xmachines/play-react-router-demo module
12
+ - [@xmachines/play-router](@xmachines/play-router/README.md): @xmachines/play-router module
13
+ - [@xmachines/play-router-demo](@xmachines/play-router-demo/README.md): @xmachines/play-router-demo module
14
+ - [@xmachines/play-signals](@xmachines/play-signals/README.md): @xmachines/play-signals module
15
+ - [@xmachines/play-solid](@xmachines/play-solid/README.md): @xmachines/play-solid module
16
+ - [@xmachines/play-solid-router](@xmachines/play-solid-router/README.md): @xmachines/play-solid-router module
17
+ - [@xmachines/play-solid-router-demo](@xmachines/play-solid-router-demo/README.md): @xmachines/play-solid-router-demo module
18
+ - [@xmachines/play-tanstack-react-router](@xmachines/play-tanstack-react-router/README.md): @xmachines/play-tanstack-react-router module
19
+ - [@xmachines/play-tanstack-react-router-demo](@xmachines/play-tanstack-react-router-demo/README.md): @xmachines/play-tanstack-react-router-demo module
20
+ - [@xmachines/play-tanstack-solid-router](@xmachines/play-tanstack-solid-router/README.md): @xmachines/play-tanstack-solid-router module
21
+ - [@xmachines/play-tanstack-solid-router-demo](@xmachines/play-tanstack-solid-router-demo/README.md): @xmachines/play-tanstack-solid-router-demo module
22
+ - [@xmachines/play-vue](@xmachines/play-vue/README.md): @xmachines/play-vue module
23
+ - [@xmachines/play-vue-router](@xmachines/play-vue-router/README.md): @xmachines/play-vue-router module
24
+ - [@xmachines/play-vue-router-demo](@xmachines/play-vue-router-demo/README.md): @xmachines/play-vue-router-demo module
25
+ - [@xmachines/play-xstate](@xmachines/play-xstate/README.md): @xmachines/play-xstate module
26
+ - [@xmachines/shared](@xmachines/shared/README.md): @xmachines/shared module
@@ -0,0 +1,63 @@
1
+ # XMachines Examples
2
+
3
+ Practical code examples demonstrating common XMachines patterns and use cases.
4
+
5
+ ## Learning Path
6
+
7
+ ### Level 1: Basic Concepts
8
+
9
+ Start with fundamental state machine concepts:
10
+
11
+ - **[Basic State Machine](basic-state-machine.md)** - Simple two-state toggle machine
12
+ - **[Traffic Light](traffic-light.md)** - Multi-state machine with cyclic transitions
13
+ - **[Form Validation](form-validation.md)** - Validation with guards and conditional logic
14
+
15
+ ### Level 2: Routing Patterns
16
+
17
+ Learn how state machines control navigation:
18
+
19
+ - **[Routing Patterns](routing-patterns.md)** - State-driven routing and navigation guards
20
+ - **[Multi-Router Integration](multi-router-integration.md)** - Framework-agnostic routing architecture
21
+
22
+ ### Level 3: Full Applications
23
+
24
+ See complete working implementations demonstrating all architectural invariants:
25
+
26
+ ## Demo Applications
27
+
28
+ Complete working applications demonstrating all 5 architectural invariants:
29
+
30
+ - **[React + TanStack Router Demo](../../packages/play-tanstack-react-router/examples/demo-app/)** - Canonical reference implementation showing all 5 invariants, comprehensive routing, authentication guards, and browser tests
31
+ - **[Vue Router Demo](../../packages/play-vue-router/examples/demo/)** - Vue Composition API integration with same auth patterns
32
+ - **[SolidJS Router Demo](../../packages/play-solidjs-router/examples/demo/)** - Solid signals integration demonstrating framework independence
33
+
34
+ ## Running Examples
35
+
36
+ All examples are written in TypeScript and can be run in:
37
+
38
+ **Node.js:**
39
+
40
+ ```bash
41
+ npm install @xmachines/play
42
+ npx tsx example.ts
43
+ ```
44
+
45
+ **Browser:**
46
+ Include via bundler (Vite, Webpack) or use browser platform package.
47
+
48
+ **Deno:**
49
+
50
+ ```bash
51
+ deno run --allow-net example.ts
52
+ ```
53
+
54
+ ## Related Documentation
55
+
56
+ - **[Getting Started Guide](/docs/guides/getting-started)** - First steps with XMachines
57
+ - **[API Reference](/docs/api)** - Complete API documentation
58
+ - **[Core Concepts](/docs/api/guides/core-concepts)** - Architecture and design patterns
59
+
60
+ ---
61
+
62
+ **Contributing Examples:**
63
+ Have a useful example to share? See [Development Docs](/development) for contribution guidelines.
@@ -0,0 +1,70 @@
1
+ # Basic State Machine
2
+
3
+ Learn how to create a simple state machine with two states.
4
+
5
+ ## Use Case
6
+
7
+ This example demonstrates a toggle switch or on/off button - the foundation for understanding state transitions in XMachines. It's the simplest possible state machine with just two states and one event type.
8
+
9
+ ## Complete Code
10
+
11
+ ```typescript
12
+ import { createMachine } from "xstate";
13
+
14
+ // Define states
15
+ type ToggleState = "off" | "on";
16
+
17
+ // Define events
18
+ type ToggleEvent = { type: "TOGGLE" };
19
+
20
+ // Create machine
21
+ const toggleMachine = createMachine<ToggleState, ToggleEvent>({
22
+ id: "toggle",
23
+ initial: "off",
24
+ states: {
25
+ off: {
26
+ on: {
27
+ TOGGLE: "on",
28
+ },
29
+ },
30
+ on: {
31
+ on: {
32
+ TOGGLE: "off",
33
+ },
34
+ },
35
+ },
36
+ });
37
+
38
+ // Usage
39
+ let state = toggleMachine.initialState;
40
+ console.log(state); // 'off'
41
+
42
+ state = toggleMachine.transition(state, { type: "TOGGLE" });
43
+ console.log(state); // 'on'
44
+
45
+ state = toggleMachine.transition(state, { type: "TOGGLE" });
46
+ console.log(state); // 'off'
47
+ ```
48
+
49
+ ## Code Explanation
50
+
51
+ 1. **Define TypeScript types** - Create union types for states (`'off' | 'on'`) and events (`{ type: 'TOGGLE' }`) to get type safety throughout your application.
52
+
53
+ 2. **Create machine with initial state** - Use `createMachine` with an `initial` property to specify which state the machine starts in.
54
+
55
+ 3. **Define state transitions** - In the `states` config, each state has an `on` object mapping event types to target states.
56
+
57
+ 4. **Use the machine** - Call `transition(currentState, event)` to compute the next state based on the current state and incoming event.
58
+
59
+ ## Key Concepts
60
+
61
+ - **State**: The current mode or condition of the machine (`'off'` or `'on'`)
62
+ - **Event**: A trigger that causes a state change (`{ type: 'TOGGLE' }`)
63
+ - **Transition**: A rule defining how the machine moves from one state to another
64
+ - **Type Safety**: TypeScript ensures you only use valid states and events, catching errors at compile time
65
+
66
+ ## Next Steps
67
+
68
+ - **[Traffic Light Example](traffic-light.md)** - See how to handle multiple states with cyclic transitions
69
+ - **[Form Validation Example](form-validation.md)** - Learn about guards and conditional transitions
70
+ - **[API Documentation](/docs/api/xmachines/play/readme)** - Explore the complete API reference