@mmapp/react 0.1.0-alpha.1 → 0.1.0-alpha.3

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 (94) hide show
  1. package/README.md +112 -0
  2. package/dist/index.d.mts +27 -2
  3. package/dist/index.d.ts +27 -2
  4. package/dist/index.js +70 -3
  5. package/dist/index.mjs +74 -12
  6. package/package.json +4 -3
  7. package/package.json.backup +0 -41
  8. package/src/Blueprint.ts +0 -216
  9. package/src/__tests__/Blueprint.test.ts +0 -106
  10. package/src/__tests__/action-context.test.ts +0 -166
  11. package/src/__tests__/actionCreators.test.ts +0 -179
  12. package/src/__tests__/builders.test.ts +0 -336
  13. package/src/__tests__/defineBlueprint-composition.test.ts +0 -106
  14. package/src/__tests__/factories.test.ts +0 -229
  15. package/src/__tests__/loader.test.ts +0 -159
  16. package/src/__tests__/logger.test.ts +0 -70
  17. package/src/__tests__/type-inference.test.ts +0 -160
  18. package/src/__tests__/typed-transitions.test.ts +0 -126
  19. package/src/__tests__/useModuleConfig.test.ts +0 -61
  20. package/src/actionCreators.ts +0 -132
  21. package/src/actions.ts +0 -547
  22. package/src/atoms/index.ts +0 -600
  23. package/src/authoring.ts +0 -92
  24. package/src/browser-player.ts +0 -783
  25. package/src/builders.ts +0 -1342
  26. package/src/components/ExperienceWorkflowBridge.tsx +0 -123
  27. package/src/components/PlayerProvider.tsx +0 -43
  28. package/src/components/atoms/index.tsx +0 -269
  29. package/src/components/index.ts +0 -36
  30. package/src/conditions.ts +0 -692
  31. package/src/config/defineBlueprint.ts +0 -329
  32. package/src/config/defineModel.ts +0 -753
  33. package/src/config/defineWorkspace.ts +0 -24
  34. package/src/core/WorkflowRuntime.ts +0 -153
  35. package/src/factories.ts +0 -425
  36. package/src/grammar/index.ts +0 -173
  37. package/src/hooks/index.ts +0 -106
  38. package/src/hooks/useAuth.ts +0 -288
  39. package/src/hooks/useChannel.ts +0 -304
  40. package/src/hooks/useComputed.ts +0 -154
  41. package/src/hooks/useDomainSubscription.ts +0 -110
  42. package/src/hooks/useDuringAction.ts +0 -99
  43. package/src/hooks/useExperienceState.ts +0 -59
  44. package/src/hooks/useExpressionLibrary.ts +0 -129
  45. package/src/hooks/useForm.ts +0 -352
  46. package/src/hooks/useGeolocation.ts +0 -207
  47. package/src/hooks/useMapView.ts +0 -259
  48. package/src/hooks/useMiddleware.ts +0 -291
  49. package/src/hooks/useModel.ts +0 -363
  50. package/src/hooks/useModule.ts +0 -59
  51. package/src/hooks/useModuleConfig.ts +0 -61
  52. package/src/hooks/useMutation.ts +0 -237
  53. package/src/hooks/useNotification.ts +0 -151
  54. package/src/hooks/useOnChange.ts +0 -30
  55. package/src/hooks/useOnEnter.ts +0 -59
  56. package/src/hooks/useOnEvent.ts +0 -37
  57. package/src/hooks/useOnExit.ts +0 -27
  58. package/src/hooks/useOnTransition.ts +0 -30
  59. package/src/hooks/usePackage.ts +0 -128
  60. package/src/hooks/useParams.ts +0 -33
  61. package/src/hooks/usePlayer.ts +0 -308
  62. package/src/hooks/useQuery.ts +0 -184
  63. package/src/hooks/useRealtimeQuery.ts +0 -222
  64. package/src/hooks/useRole.ts +0 -191
  65. package/src/hooks/useRouteParams.ts +0 -100
  66. package/src/hooks/useRouter.ts +0 -347
  67. package/src/hooks/useServerAction.ts +0 -178
  68. package/src/hooks/useServerState.ts +0 -284
  69. package/src/hooks/useToast.ts +0 -164
  70. package/src/hooks/useTransition.ts +0 -39
  71. package/src/hooks/useView.ts +0 -102
  72. package/src/hooks/useWhileIn.ts +0 -48
  73. package/src/hooks/useWorkflow.ts +0 -63
  74. package/src/index.ts +0 -465
  75. package/src/loader/experience-workflow-loader.ts +0 -192
  76. package/src/loader/index.ts +0 -6
  77. package/src/local/LocalEngine.ts +0 -388
  78. package/src/local/LocalEngineAdapter.ts +0 -175
  79. package/src/local/LocalEngineContext.ts +0 -30
  80. package/src/logger.ts +0 -37
  81. package/src/mixins.ts +0 -1160
  82. package/src/providers/RuntimeContext.ts +0 -20
  83. package/src/providers/WorkflowProvider.tsx +0 -28
  84. package/src/routing/instance-key.ts +0 -107
  85. package/src/server/transition-context.ts +0 -172
  86. package/src/testing/index.ts +0 -9
  87. package/src/testing/useBlueprintTestRunner.ts +0 -91
  88. package/src/testing/useGraphAnalysis.ts +0 -18
  89. package/src/testing/useTestRunner.ts +0 -77
  90. package/src/testing.ts +0 -995
  91. package/src/types/workflow-inference.ts +0 -158
  92. package/src/types.ts +0 -114
  93. package/tsconfig.json +0 -27
  94. package/vitest.config.ts +0 -8
@@ -1,329 +0,0 @@
1
- /**
2
- * defineBlueprint — declarative configuration for a MindMatrix workflow blueprint.
3
- *
4
- * Everything is a workflow. Blueprints, modules, and apps are all workflow
5
- * definitions distinguished only by category labels. A definition can be
6
- * ["workflow", "blueprint", "module"] simultaneously.
7
- *
8
- * This is the SINGLE manifest file (mm.config.ts) for any project. It declares
9
- * what the project provides (models, routes, actions) and what
10
- * it requires (dependencies, capabilities).
11
- *
12
- * Usage in mm.config.ts:
13
- * import { defineBlueprint } from '@mindmatrix/react';
14
- *
15
- * export default defineBlueprint({
16
- * slug: 'mod-authentication',
17
- * name: 'Authentication & Authorization',
18
- * version: '3.0.0',
19
- * category: 'module',
20
- * models: ['models/authentication', 'models/user'],
21
- * routes: [{ path: '/login', view: 'app/login', label: 'Login' }],
22
- * actions: [{ id: 'server:authenticate', handler: 'actions.server' }],
23
- * });
24
- */
25
-
26
- import type { RuntimeProfile } from '@mindmatrix/player-core';
27
-
28
- // =============================================================================
29
- // Shared Sub-Types (used by BlueprintConfig)
30
- // =============================================================================
31
-
32
- /**
33
- * Slot contributions from this blueprint to a target blueprint.
34
- * Keys are slot names, values are component identifiers that fill them.
35
- */
36
- export type SlotContributions = Record<string, string[]>;
37
-
38
- /** A route this definition adds to the host application. */
39
- export interface BlueprintRoute {
40
- /** Route path (e.g., '/login', '/admin/auth/users'). */
41
- path: string;
42
- /** Display label for navigation. */
43
- label?: string;
44
- /** The view component file path (relative to project root). */
45
- view: string;
46
- /** Route guard expression (e.g., 'context.actor_role == "admin"'). */
47
- guard?: string;
48
- /** Redirect path when guard fails. */
49
- redirect?: string;
50
- /** Route group for organization (e.g., 'auth', 'admin'). */
51
- group?: string;
52
- /** Icon name for navigation. */
53
- icon?: string;
54
- /** Whether to show in navigation menus. */
55
- showInNav?: boolean;
56
- }
57
-
58
- /** A slot contribution — what this definition injects into parent slots. */
59
- export interface BlueprintSlotContribution {
60
- /** Target slot name (e.g., 'app:sidebar', 'app:settings-tabs'). */
61
- slot: string;
62
- /** Component to render in the slot. */
63
- view: string;
64
- /** Priority for ordering (lower = earlier). */
65
- priority?: number;
66
- /** Guard expression for conditional rendering. */
67
- guard?: string;
68
- }
69
-
70
- /** A server action this definition registers. */
71
- export interface BlueprintAction {
72
- /** Action identifier (e.g., 'server:authenticate'). */
73
- id: string;
74
- /** Description. */
75
- description?: string;
76
- /** Source file path (relative to project root). */
77
- handler: string;
78
- /** Function name in the handler file. */
79
- functionName?: string;
80
- }
81
-
82
- /** Setup wizard step definition. */
83
- export interface SetupWizardStep {
84
- /** Step identifier. */
85
- id: string;
86
- /** Step label. */
87
- label: string;
88
- /** Step description. */
89
- description?: string;
90
- /** View component for this step. */
91
- view: string;
92
- /** Whether this step can be skipped. */
93
- optional?: boolean;
94
- /** Validation expression — must be truthy to proceed. */
95
- validate?: string;
96
- /** Config fields collected in this step. */
97
- fields?: Array<{
98
- key: string;
99
- label: string;
100
- type: 'text' | 'number' | 'boolean' | 'select';
101
- defaultValue?: unknown;
102
- description?: string;
103
- options?: Array<{ value: string; label: string }>;
104
- }>;
105
- }
106
-
107
- /** Setup wizard definition. */
108
- export interface SetupWizard {
109
- /** Title shown during setup. */
110
- title: string;
111
- /** Description shown on the wizard landing. */
112
- description?: string;
113
- /** Ordered list of setup steps. */
114
- steps: SetupWizardStep[];
115
- /** View component for the completion screen. */
116
- completionView?: string;
117
- }
118
-
119
- /** Configuration schema. */
120
- export interface BlueprintConfigSchema {
121
- /** Slug of the configuration model (must be one of this definition's models). */
122
- modelSlug: string;
123
- /** Default configuration values. */
124
- defaults?: Record<string, unknown>;
125
- }
126
-
127
- /** Route configuration for a module dependency. */
128
- export interface ModuleRouteConfig {
129
- /** URL prefix for all module routes (e.g., '/auth'). Derived from slug if omitted. */
130
- prefix?: string;
131
- /**
132
- * Per-route overrides. Keys are module route paths, values are:
133
- * - string: remap to this parent path (e.g., '/login' → '/')
134
- * - false: disable this route entirely
135
- * Unmapped routes use the prefix.
136
- */
137
- routes?: Record<string, string | false>;
138
- }
139
-
140
- /** Dependency on another definition. */
141
- export interface BlueprintDependency {
142
- /** Definition slug. */
143
- slug: string;
144
- /** Semver version range (e.g., '>=2.0.0', '^3.0.0'). */
145
- version?: string;
146
- /** Whether the dependency is optional. */
147
- optional?: boolean;
148
- /** Whether this dependency is required (default: false). */
149
- required?: boolean;
150
- /** Route composition configuration. */
151
- routeConfig?: ModuleRouteConfig;
152
- /**
153
- * Slot name remapping. Keys are module's internal slot names,
154
- * values are the parent's slot namespace.
155
- * E.g., { 'auth:login-providers': 'app:social-login' }
156
- */
157
- slotMapping?: Record<string, string>;
158
- /** Configuration values passed to the module at install time. */
159
- config?: Record<string, unknown>;
160
- }
161
-
162
- // =============================================================================
163
- // Blueprint Config
164
- // =============================================================================
165
-
166
- /**
167
- * Blueprint configuration — the input to defineBlueprint().
168
- *
169
- * This is the unified manifest for any MindMatrix project. Everything is a
170
- * workflow definition — blueprints, modules, and apps are distinguished only
171
- * by their category label.
172
- */
173
- export interface BlueprintConfig {
174
- /** Unique identifier for this definition (kebab-case). */
175
- slug: string;
176
- /** Human-readable display name. */
177
- name: string;
178
- /** Semantic version string. */
179
- version: string;
180
- /** Optional description. */
181
- description?: string;
182
- /** Author name. */
183
- author?: string;
184
- /** License identifier. */
185
- license?: string;
186
- /** Icon URL or icon name. */
187
- icon?: string;
188
- /** Tags for discovery. */
189
- tags?: string[];
190
- /** Compilation mode: strict enforces @mindmatrix/react-only hooks; infer allows escape hatches. */
191
- mode?: 'strict' | 'infer';
192
- /** Default runtime profile for all workflows in this definition. */
193
- defaultRuntime?: RuntimeProfile;
194
- /**
195
- * Category for the compiled workflow definition.
196
- * Can be a single string or an array of categories.
197
- * A definition can be ["workflow", "blueprint", "module"] simultaneously.
198
- */
199
- category?: string | string[];
200
-
201
- // ── Structure ──
202
-
203
- /**
204
- * Entry file paths relative to the project root.
205
- * If omitted, auto-discovered from app/ directory.
206
- */
207
- entries?: string[];
208
- /**
209
- * Model file paths relative to the project root.
210
- * If omitted, auto-discovered from models/ directory.
211
- */
212
- models?: string[];
213
-
214
- // ── Provides ──
215
-
216
- /** Routes this definition adds. */
217
- routes?: BlueprintRoute[];
218
- /** Slot contributions to parent blueprints (structured). */
219
- contributions?: BlueprintSlotContribution[];
220
- /**
221
- * Slot contributions to other blueprints (legacy shorthand).
222
- * Key = target blueprint slug, value = slot name → component list.
223
- */
224
- contributes_to?: Record<string, SlotContributions>;
225
- /** Server actions this definition registers. */
226
- actions?: BlueprintAction[];
227
- /**
228
- * Public model surface — model slugs that consuming blueprints can query.
229
- * E.g., ['user', 'session', 'role'] exposes these models for cross-module data access.
230
- */
231
- exports?: string[];
232
-
233
- // ── Requires ──
234
-
235
- /** Dependencies on other definitions. */
236
- dependencies?: BlueprintDependency[];
237
- /** Required host capabilities (e.g., 'email', 'oauth', 'file-storage'). */
238
- capabilities?: string[];
239
- /** Required host slots that must exist for contributions. */
240
- requiredSlots?: string[];
241
-
242
- // ── Configuration ──
243
-
244
- /** Configuration schema. */
245
- configSchema?: BlueprintConfigSchema;
246
- /** Setup wizard definition. */
247
- setupWizard?: SetupWizard;
248
- }
249
-
250
- /**
251
- * Blueprint manifest — the resolved output of defineBlueprint().
252
- * Used by the compiler and build pipeline.
253
- */
254
- export interface BlueprintManifest extends BlueprintConfig {
255
- /** Always populated with defaults applied. */
256
- slug: string;
257
- name: string;
258
- version: string;
259
- mode: 'strict' | 'infer';
260
- defaultRuntime: RuntimeProfile;
261
- category: string | string[];
262
- }
263
-
264
- // =============================================================================
265
- // Implementation
266
- // =============================================================================
267
-
268
- /**
269
- * Creates a validated blueprint manifest from configuration.
270
- *
271
- * Applies defaults:
272
- * - mode: 'infer'
273
- * - defaultRuntime: 'local'
274
- * - category: 'blueprint'
275
- */
276
- export function defineBlueprint(config: BlueprintConfig): BlueprintManifest {
277
- if (!config.slug) {
278
- throw new Error('defineBlueprint: slug is required');
279
- }
280
- if (!config.name) {
281
- throw new Error('defineBlueprint: name is required');
282
- }
283
- if (!config.version) {
284
- throw new Error('defineBlueprint: version is required');
285
- }
286
-
287
- // Validate slug format (kebab-case)
288
- if (!/^[a-z][a-z0-9-]*$/.test(config.slug)) {
289
- throw new Error(
290
- `defineBlueprint: slug must be kebab-case (got "${config.slug}")`
291
- );
292
- }
293
-
294
- // Validate version format (semver-like)
295
- if (!/^\d+\.\d+\.\d+/.test(config.version)) {
296
- throw new Error(
297
- `defineBlueprint: version must be semver (got "${config.version}")`
298
- );
299
- }
300
-
301
- return {
302
- ...config,
303
- mode: config.mode || 'infer',
304
- defaultRuntime: config.defaultRuntime || 'local',
305
- category: config.category || 'blueprint',
306
- };
307
- }
308
-
309
- // =============================================================================
310
- // Legacy Aliases (backwards compatibility with defineModule types)
311
- // =============================================================================
312
-
313
- /** @deprecated Use BlueprintRoute */
314
- export type ModuleRoute = BlueprintRoute;
315
- /** @deprecated Use BlueprintSlotContribution */
316
- export type SlotContribution = BlueprintSlotContribution;
317
- /** @deprecated Use BlueprintAction */
318
- export type ModuleAction = BlueprintAction;
319
- /** @deprecated Use BlueprintConfigSchema */
320
- export type ModuleConfigSchema = BlueprintConfigSchema;
321
- /** @deprecated Use BlueprintDependency */
322
- export type ModuleDependency = BlueprintDependency;
323
- /** @deprecated Use BlueprintConfig */
324
- export type ModuleManifest = BlueprintConfig;
325
-
326
- /** @deprecated Use defineBlueprint() — modules and blueprints are the same thing. */
327
- export function defineModule<const M extends BlueprintConfig>(manifest: M): M & { mode: 'strict' | 'infer'; defaultRuntime: RuntimeProfile; category: string | string[] } {
328
- return defineBlueprint(manifest as BlueprintConfig) as M & { mode: 'strict' | 'infer'; defaultRuntime: RuntimeProfile; category: string | string[] };
329
- }