@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
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # @mmapp/react
2
+
3
+ React hooks, components, and runtime bridge for building MindMatrix workflow applications.
4
+
5
+ Published on npm as `@mmapp/react` (internal workspace name: `@mindmatrix/react`).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @mmapp/react @mmapp/player-core
11
+ ```
12
+
13
+ ## Hooks
14
+
15
+ | Hook | Purpose |
16
+ |------|---------|
17
+ | `useQuery(slug)` | Fetch workflow instances by slug |
18
+ | `useMutation(slug)` | Create, update, transition workflow instances |
19
+ | `usePlayer(definition)` | Run a state machine in the browser |
20
+ | `useRouter()` | Blueprint-aware navigation |
21
+ | `useAuth()` | Authentication state |
22
+ | `useToast()` | Toast notifications |
23
+ | `useForm(fields)` | Form state management with validation |
24
+ | `useChannel(name)` | Real-time WebSocket channels |
25
+ | `useRole(slug)` | Role-based access control |
26
+ | `useComputed(expr)` | Computed field evaluation |
27
+ | `useModel(definition)` | Type-safe model access |
28
+ | `useModule(slug)` | Module configuration |
29
+ | `useServerAction(name)` | Server-side action execution |
30
+ | `useServerState(slug)` | Server-synced state |
31
+
32
+ ## Configuration
33
+
34
+ ### defineBlueprint
35
+
36
+ ```typescript
37
+ import { defineBlueprint } from '@mmapp/react';
38
+
39
+ export default defineBlueprint({
40
+ slug: 'my-app',
41
+ name: 'My App',
42
+ version: '1.0.0',
43
+ models: [employeeModel, departmentModel],
44
+ views: {
45
+ '/': HomePage,
46
+ '/employees': EmployeeList,
47
+ '/employees/:id': EmployeeDetail,
48
+ },
49
+ });
50
+ ```
51
+
52
+ ### defineModel
53
+
54
+ ```typescript
55
+ import { defineModel } from '@mmapp/react';
56
+
57
+ export default defineModel({
58
+ slug: 'employee',
59
+ fields: {
60
+ name: { type: 'string', required: true },
61
+ salary: { type: 'number', default: 0 },
62
+ department: { type: 'string' },
63
+ },
64
+ states: {
65
+ active: { type: 'initial' },
66
+ terminated: { type: 'terminal' },
67
+ },
68
+ transitions: {
69
+ terminate: { from: ['active'], to: 'terminated' },
70
+ },
71
+ });
72
+ ```
73
+
74
+ ## Atoms
75
+
76
+ Pre-built UI components available via `@mmapp/react/atoms`:
77
+
78
+ ```typescript
79
+ import { Box, Text, Button, Input, Select, Modal, Card } from '@mmapp/react/atoms';
80
+ ```
81
+
82
+ ## npm Publishing
83
+
84
+ This package is published to npm under the `@mmapp` scope.
85
+
86
+ | npm name | workspace name | current version |
87
+ |----------|---------------|-----------------|
88
+ | `@mmapp/react` | `@mindmatrix/react` | 0.1.0-alpha.1 |
89
+
90
+ ### Publishing a new version
91
+
92
+ Use the publish script from the monorepo root:
93
+
94
+ ```bash
95
+ # Publish all 3 packages (player-core, react, react-compiler)
96
+ ./scripts/publish-npm.sh patch # 0.1.0-alpha.1 → 0.1.0-alpha.2
97
+ ./scripts/publish-npm.sh minor # 0.1.0-alpha.1 → 0.2.0-alpha.1
98
+ ./scripts/publish-npm.sh 0.2.0-beta.1 # explicit version
99
+ ```
100
+
101
+ Or publish just this package:
102
+
103
+ ```bash
104
+ cd packages/react
105
+ pnpm run publish:alpha # auto-increments alpha version
106
+ ```
107
+
108
+ ### Version strategy
109
+
110
+ - `0.1.0-alpha.X` — internal development (current)
111
+ - `0.1.0-beta.X` — user testing
112
+ - `1.0.0` — production launch
package/dist/index.d.mts CHANGED
@@ -4746,9 +4746,34 @@ declare function getInstalledModule(slug: string): InstalledModuleRef | undefine
4746
4746
  declare function getInstalledModules(): InstalledModuleRef[];
4747
4747
  /**
4748
4748
  * Read the merged configuration for a module.
4749
- * Merges: configSchema.defaults ← install-time config
4749
+ * Merges: configSchema.defaults ← persisted server config ← install-time overrides
4750
4750
  */
4751
4751
  declare function useModuleConfig(moduleSlug: string): Record<string, unknown>;
4752
+ /** Set persisted config for a module (loaded from server at boot) */
4753
+ declare function setPersistedModuleConfig(moduleSlug: string, config: Record<string, unknown>): void;
4754
+ /**
4755
+ * Sync module config defaults to the server at install time.
4756
+ * Creates or updates the config for a module with its default values.
4757
+ * Called by handleInstallModule when a module is first installed.
4758
+ */
4759
+ declare function syncConfigDefaults(moduleSlug: string, defaults: Record<string, unknown>, definitionId?: string): Promise<void>;
4760
+ /** Set the active definition context for config mutations */
4761
+ declare function setConfigContext(definitionId: string, apiBaseUrl?: string): void;
4762
+ /**
4763
+ * Update config values for the active definition.
4764
+ * PATCHes /api/v1/workflow/definitions/{id}/config with the provided key-value pairs.
4765
+ * Returns the updated config object from the server.
4766
+ */
4767
+ declare function updateDefinitionConfig(values: Record<string, unknown>, definitionId?: string): Promise<Record<string, unknown>>;
4768
+ /**
4769
+ * Hook that returns the merged config + an updateConfig function.
4770
+ * Combines read (useModuleConfig) with write (updateDefinitionConfig).
4771
+ */
4772
+ declare function useModuleConfigWithMutation(moduleSlug: string): {
4773
+ config: Record<string, unknown>;
4774
+ updateConfig: (values: Record<string, unknown>) => Promise<Record<string, unknown>>;
4775
+ isSaving: boolean;
4776
+ };
4752
4777
 
4753
4778
  /**
4754
4779
  * @mindmatrix/react/builders — Fluent builder API for ModelDefinition objects.
@@ -6996,4 +7021,4 @@ declare class BrowserPlayer {
6996
7021
  private log;
6997
7022
  }
6998
7023
 
6999
- export { Accordion, type ActionContext, type ActionCreator, type ActionCreators, type ActionDefinition, type ActionEnvironment, type ActionHandler, type ActionManifest, type ActionManifestEntry, type ActionNotifyOptions, type ActionOptions, type ActionResult, AnimatedBox, type ApprovalConfig, type AuthOptions, type AuthResolver, type AuthResult, type AuthUser, Badge, type BadgeProps, Blueprint, type BlueprintAction, type BlueprintConfig, type BlueprintConfigSchema, type BlueprintDependency, type BlueprintManifest, type BlueprintRoute, type BlueprintServerActionDeclaration, type BlueprintSlotContribution, type BlueprintViewDeclaration, BrowserPlayer, type BrowserPlayerConfig, type TransitionResult as BrowserTransitionResult, Button, type ButtonProps, type CRUDConfig, Canvas3D, Card, type CardProps, type CedarPolicy, type ChannelHandle, type ChannelMessage, type ChannelOptions, type ChannelTransport, Chart, type CollectionHandle, Column, type ColumnProps, type ComputedFieldMode, type ComputedFieldResult, type CronFields, type CrudConfig, DataGrid, type DataSource, type DataSourceResult, Divider, type DividerProps, type DmnRule, type DomainEvent, type DomainSubscriptionConfig, type DomainSubscriptionTransport, type DuringAction, type DuringActionConfig, Each, type EachProps, type EscalationConfig, type EventPayload, type EventSubscription, type ExperienceViewConfig, ExperienceWorkflowBridge, type ExperienceWorkflowBridgeProps, type ExperienceWorkflowDefinition, type ExpressionLibraryRecord, type ExpressionLibraryResolver, type ExpressionLibraryResult, Field, FieldBuilder, type FieldRegistration, type FieldTypeMap, type FieldValidation, type FieldValidator, type FormConfig, type FormHandle, type FormValidator, type GeoPosition, type GeolocationError, type GeolocationOptions, type GeolocationResult, type GrammarIsland, Grid, Heading, type HeadingProps, Icon, Image, type InferFieldNames, type InferFields, type InferSlug, type InferStates, type InferTransitions, type InstalledModuleRef, type InstanceData, type InstanceKeyParams, type InstanceRef, type LatLng, type LatLngBounds, type LibraryParam, Link, type LocalDataResolver, type LocalEngineAdapter, type LocalEngineContextValue, LocalEngineProvider, type LocalEngineStore, LocalWorkflowEngine, type LoginCredentials, type MapMarker, type MapViewHandle, type MapViewOptions, Markdown, MetricCard, type MiddlewareContext, type MiddlewareFn, type MiddlewareHandle, type MiddlewareOptions, type MiddlewareResult, type MmWasmModule, Modal, ModelBuilder, type ModelDefinition, type ModelHandle, type ModelMixin, type ModelTestContext, type ModuleAction, type ModuleConfigSchema, type ModuleDependency, type ModuleHandle, type ModuleManifest, type ModuleRoute, type ModuleRouteConfig, type MutationHandle, type MutationResolver, NavLink, type NotificationResult, type NotifyOptions, type PackageChild, type PackageManifest, type PackageResult, type PipelineConfig, type PipelineStage, type PlayerConfig, type PlayerEvent, type PlayerEventCallback, type PlayerEventListener, type PlayerHandle, type PlayerInstance, type PlayerLogEntry, PlayerProvider, type PlayerProviderProps, type QueryParams$1 as QueryParams, type QueryResolver, type QueryResult, type RealtimeQueryParams, type RealtimeQueryResult, type ReviewConfig, type RoleDefinition, RoleGuard, type RoleOptions, type RoleResult, Route, type RouteDefinition, type RouteGuard, type RouteLocation, type RouteParamsOptions, Router, type RouterHandle, type RouterOptions, Row, type RowProps, type RuntimeConfig, RuntimeContext, type RuntimeSnapshot, ScrollArea, Section, Select, type ServerActionFn, type ServerActionHandle, type ServerActionOptions, type ServerActionResolver, type ServerActionResult, ServerGrid, type ServerStateOptions, type ServerStateResolver, type ServerStateResult, type ServerStateSnapshot, type SetupWizard, type SetupWizardStep, Show, type ShowProps, Slot, type SlotContribution, type SlotContributions, type SlotProps, Spacer, type SpawnActionOptions, type SpawnOptions, Stack, type StackProps, StateBuilder, type StateDescriptor, type StateHome, type Subscription, Tabs, type TestChain, type TestStep, Text, TextInput, type TextInputProps, type TextProps, type ToastConfig, type ToastHandle, type ToastInstance, type ToastVariant, TransitionBuilder, type TransitionCondition, type TransitionConfig, type TransitionContext, type TransitionDescriptor, type TransitionHandle, type TypedMutationHandle, TypedTransitionBuilder, type UseCollectionOptions, type UseComputedOptions, type UseModelOptions, type UseModuleOptions, type UseOnEventOptions, type UseWorkflowOptions, type ValidationIssue, type ValidationResult, type ValidationRule, type ViewDefinitionResult, type ViewRecord, type ViewResolver, type WithAuditTrailOptions, type WithOwnershipOptions, type WithRBACOptions, type WithSearchOptions, type WithSlugOptions, type WithSoftDeleteOptions, type WithVersioningOptions, type WorkflowDataSource, type WorkflowDefinition, type WorkflowEvent, type WorkflowEventHandler, type WorkflowFieldDef, type WorkflowFieldDescriptor, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceWithEvents, WorkflowProvider, type WorkflowProviderProps, WorkflowRuntime, type WorkflowState, type WorkflowTransition, action, and, applyMixins, approval, assertModelValid, cedar, connector, createActions, createCRUD, createLocalDataResolver, createLocalEngineAdapter, createPipeline, cron, crud, defineBlueprint, defineModel, defineModule, defineWorkspace, deriveInstanceKey, deriveInstanceKeySync, describeModel, deviceAction, dmn, escalation, expr, field, fieldContains, fieldEquals, fieldGreaterThan, fieldIn, fieldIsEmpty, fieldIsSet, fieldLessThan, fieldMatches, fieldNotEquals, fieldNotIn, getInstalledModule, getInstalledModules, graphql, hasAnyRole, hasRole, inState, inputEquals, inputRequired, isActor, isCreator, isOwner, isPlayerDebug, isSender, jsonpath, llm, loadExperienceWorkflow, logEvent, model, normalizeDefinition, not, notInState, notify, or, pipe, playerLog, prefetchData, refHasAnyRole, refHasRole, requireAuth, requireRole, review, serverAction, setAuthResolver, setChannelTransport, setExpressionLibraryResolver, setField, setFields, setInstalledModules, setModuleConfigDefaults, setMutationResolver, setPlayerDebug, setQueryResolver, setRealtimeQueryResolver, setRoleHierarchy, setServerActionResolver, setServerStateResolver, setViewResolver, spawn, sql, state, testModel, transition, useAuth, useChannel, useCollection, useComputed, useComputedWithMeta, useDomainSubscription, useDuringAction, useExperienceState, useExpressionLibrary, useForm, useGeolocation, useLocalEngine, useMapView, useMiddleware, useModel, useModule, useModuleConfig, useMutation, useNotification, useOnChange, useOnEnter, useOnEvent, useOnExit, useOnTransition, usePackage, useParams, usePlayer, usePlayerContext, usePlayerContextSafe, useQuery, useRealtimeQuery, useRole, useRouteParams, useRouter, useRuntimeContext, useServerAction, useServerState, useStateField, useToast, useTransition, useView, useWhileIn, useWorkflow, useState as useWorkflowState, validateExperienceWorkflow, validateModel, when, withAuditTrail, withOwnership, withPagination, withRBAC, withSearch, withSlug, withSoftDelete, withTags, withTimestamps, withVersioning };
7024
+ export { Accordion, type ActionContext, type ActionCreator, type ActionCreators, type ActionDefinition, type ActionEnvironment, type ActionHandler, type ActionManifest, type ActionManifestEntry, type ActionNotifyOptions, type ActionOptions, type ActionResult, AnimatedBox, type ApprovalConfig, type AuthOptions, type AuthResolver, type AuthResult, type AuthUser, Badge, type BadgeProps, Blueprint, type BlueprintAction, type BlueprintConfig, type BlueprintConfigSchema, type BlueprintDependency, type BlueprintManifest, type BlueprintRoute, type BlueprintServerActionDeclaration, type BlueprintSlotContribution, type BlueprintViewDeclaration, BrowserPlayer, type BrowserPlayerConfig, type TransitionResult as BrowserTransitionResult, Button, type ButtonProps, type CRUDConfig, Canvas3D, Card, type CardProps, type CedarPolicy, type ChannelHandle, type ChannelMessage, type ChannelOptions, type ChannelTransport, Chart, type CollectionHandle, Column, type ColumnProps, type ComputedFieldMode, type ComputedFieldResult, type CronFields, type CrudConfig, DataGrid, type DataSource, type DataSourceResult, Divider, type DividerProps, type DmnRule, type DomainEvent, type DomainSubscriptionConfig, type DomainSubscriptionTransport, type DuringAction, type DuringActionConfig, Each, type EachProps, type EscalationConfig, type EventPayload, type EventSubscription, type ExperienceViewConfig, ExperienceWorkflowBridge, type ExperienceWorkflowBridgeProps, type ExperienceWorkflowDefinition, type ExpressionLibraryRecord, type ExpressionLibraryResolver, type ExpressionLibraryResult, Field, FieldBuilder, type FieldRegistration, type FieldTypeMap, type FieldValidation, type FieldValidator, type FormConfig, type FormHandle, type FormValidator, type GeoPosition, type GeolocationError, type GeolocationOptions, type GeolocationResult, type GrammarIsland, Grid, Heading, type HeadingProps, Icon, Image, type InferFieldNames, type InferFields, type InferSlug, type InferStates, type InferTransitions, type InstalledModuleRef, type InstanceData, type InstanceKeyParams, type InstanceRef, type LatLng, type LatLngBounds, type LibraryParam, Link, type LocalDataResolver, type LocalEngineAdapter, type LocalEngineContextValue, LocalEngineProvider, type LocalEngineStore, LocalWorkflowEngine, type LoginCredentials, type MapMarker, type MapViewHandle, type MapViewOptions, Markdown, MetricCard, type MiddlewareContext, type MiddlewareFn, type MiddlewareHandle, type MiddlewareOptions, type MiddlewareResult, type MmWasmModule, Modal, ModelBuilder, type ModelDefinition, type ModelHandle, type ModelMixin, type ModelTestContext, type ModuleAction, type ModuleConfigSchema, type ModuleDependency, type ModuleHandle, type ModuleManifest, type ModuleRoute, type ModuleRouteConfig, type MutationHandle, type MutationResolver, NavLink, type NotificationResult, type NotifyOptions, type PackageChild, type PackageManifest, type PackageResult, type PipelineConfig, type PipelineStage, type PlayerConfig, type PlayerEvent, type PlayerEventCallback, type PlayerEventListener, type PlayerHandle, type PlayerInstance, type PlayerLogEntry, PlayerProvider, type PlayerProviderProps, type QueryParams$1 as QueryParams, type QueryResolver, type QueryResult, type RealtimeQueryParams, type RealtimeQueryResult, type ReviewConfig, type RoleDefinition, RoleGuard, type RoleOptions, type RoleResult, Route, type RouteDefinition, type RouteGuard, type RouteLocation, type RouteParamsOptions, Router, type RouterHandle, type RouterOptions, Row, type RowProps, type RuntimeConfig, RuntimeContext, type RuntimeSnapshot, ScrollArea, Section, Select, type ServerActionFn, type ServerActionHandle, type ServerActionOptions, type ServerActionResolver, type ServerActionResult, ServerGrid, type ServerStateOptions, type ServerStateResolver, type ServerStateResult, type ServerStateSnapshot, type SetupWizard, type SetupWizardStep, Show, type ShowProps, Slot, type SlotContribution, type SlotContributions, type SlotProps, Spacer, type SpawnActionOptions, type SpawnOptions, Stack, type StackProps, StateBuilder, type StateDescriptor, type StateHome, type Subscription, Tabs, type TestChain, type TestStep, Text, TextInput, type TextInputProps, type TextProps, type ToastConfig, type ToastHandle, type ToastInstance, type ToastVariant, TransitionBuilder, type TransitionCondition, type TransitionConfig, type TransitionContext, type TransitionDescriptor, type TransitionHandle, type TypedMutationHandle, TypedTransitionBuilder, type UseCollectionOptions, type UseComputedOptions, type UseModelOptions, type UseModuleOptions, type UseOnEventOptions, type UseWorkflowOptions, type ValidationIssue, type ValidationResult, type ValidationRule, type ViewDefinitionResult, type ViewRecord, type ViewResolver, type WithAuditTrailOptions, type WithOwnershipOptions, type WithRBACOptions, type WithSearchOptions, type WithSlugOptions, type WithSoftDeleteOptions, type WithVersioningOptions, type WorkflowDataSource, type WorkflowDefinition, type WorkflowEvent, type WorkflowEventHandler, type WorkflowFieldDef, type WorkflowFieldDescriptor, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceWithEvents, WorkflowProvider, type WorkflowProviderProps, WorkflowRuntime, type WorkflowState, type WorkflowTransition, action, and, applyMixins, approval, assertModelValid, cedar, connector, createActions, createCRUD, createLocalDataResolver, createLocalEngineAdapter, createPipeline, cron, crud, defineBlueprint, defineModel, defineModule, defineWorkspace, deriveInstanceKey, deriveInstanceKeySync, describeModel, deviceAction, dmn, escalation, expr, field, fieldContains, fieldEquals, fieldGreaterThan, fieldIn, fieldIsEmpty, fieldIsSet, fieldLessThan, fieldMatches, fieldNotEquals, fieldNotIn, getInstalledModule, getInstalledModules, graphql, hasAnyRole, hasRole, inState, inputEquals, inputRequired, isActor, isCreator, isOwner, isPlayerDebug, isSender, jsonpath, llm, loadExperienceWorkflow, logEvent, model, normalizeDefinition, not, notInState, notify, or, pipe, playerLog, prefetchData, refHasAnyRole, refHasRole, requireAuth, requireRole, review, serverAction, setAuthResolver, setChannelTransport, setConfigContext, setExpressionLibraryResolver, setField, setFields, setInstalledModules, setModuleConfigDefaults, setMutationResolver, setPersistedModuleConfig, setPlayerDebug, setQueryResolver, setRealtimeQueryResolver, setRoleHierarchy, setServerActionResolver, setServerStateResolver, setViewResolver, spawn, sql, state, syncConfigDefaults, testModel, transition, updateDefinitionConfig, useAuth, useChannel, useCollection, useComputed, useComputedWithMeta, useDomainSubscription, useDuringAction, useExperienceState, useExpressionLibrary, useForm, useGeolocation, useLocalEngine, useMapView, useMiddleware, useModel, useModule, useModuleConfig, useModuleConfigWithMutation, useMutation, useNotification, useOnChange, useOnEnter, useOnEvent, useOnExit, useOnTransition, usePackage, useParams, usePlayer, usePlayerContext, usePlayerContextSafe, useQuery, useRealtimeQuery, useRole, useRouteParams, useRouter, useRuntimeContext, useServerAction, useServerState, useStateField, useToast, useTransition, useView, useWhileIn, useWorkflow, useState as useWorkflowState, validateExperienceWorkflow, validateModel, when, withAuditTrail, withOwnership, withPagination, withRBAC, withSearch, withSlug, withSoftDelete, withTags, withTimestamps, withVersioning };
package/dist/index.d.ts CHANGED
@@ -4746,9 +4746,34 @@ declare function getInstalledModule(slug: string): InstalledModuleRef | undefine
4746
4746
  declare function getInstalledModules(): InstalledModuleRef[];
4747
4747
  /**
4748
4748
  * Read the merged configuration for a module.
4749
- * Merges: configSchema.defaults ← install-time config
4749
+ * Merges: configSchema.defaults ← persisted server config ← install-time overrides
4750
4750
  */
4751
4751
  declare function useModuleConfig(moduleSlug: string): Record<string, unknown>;
4752
+ /** Set persisted config for a module (loaded from server at boot) */
4753
+ declare function setPersistedModuleConfig(moduleSlug: string, config: Record<string, unknown>): void;
4754
+ /**
4755
+ * Sync module config defaults to the server at install time.
4756
+ * Creates or updates the config for a module with its default values.
4757
+ * Called by handleInstallModule when a module is first installed.
4758
+ */
4759
+ declare function syncConfigDefaults(moduleSlug: string, defaults: Record<string, unknown>, definitionId?: string): Promise<void>;
4760
+ /** Set the active definition context for config mutations */
4761
+ declare function setConfigContext(definitionId: string, apiBaseUrl?: string): void;
4762
+ /**
4763
+ * Update config values for the active definition.
4764
+ * PATCHes /api/v1/workflow/definitions/{id}/config with the provided key-value pairs.
4765
+ * Returns the updated config object from the server.
4766
+ */
4767
+ declare function updateDefinitionConfig(values: Record<string, unknown>, definitionId?: string): Promise<Record<string, unknown>>;
4768
+ /**
4769
+ * Hook that returns the merged config + an updateConfig function.
4770
+ * Combines read (useModuleConfig) with write (updateDefinitionConfig).
4771
+ */
4772
+ declare function useModuleConfigWithMutation(moduleSlug: string): {
4773
+ config: Record<string, unknown>;
4774
+ updateConfig: (values: Record<string, unknown>) => Promise<Record<string, unknown>>;
4775
+ isSaving: boolean;
4776
+ };
4752
4777
 
4753
4778
  /**
4754
4779
  * @mindmatrix/react/builders — Fluent builder API for ModelDefinition objects.
@@ -6996,4 +7021,4 @@ declare class BrowserPlayer {
6996
7021
  private log;
6997
7022
  }
6998
7023
 
6999
- export { Accordion, type ActionContext, type ActionCreator, type ActionCreators, type ActionDefinition, type ActionEnvironment, type ActionHandler, type ActionManifest, type ActionManifestEntry, type ActionNotifyOptions, type ActionOptions, type ActionResult, AnimatedBox, type ApprovalConfig, type AuthOptions, type AuthResolver, type AuthResult, type AuthUser, Badge, type BadgeProps, Blueprint, type BlueprintAction, type BlueprintConfig, type BlueprintConfigSchema, type BlueprintDependency, type BlueprintManifest, type BlueprintRoute, type BlueprintServerActionDeclaration, type BlueprintSlotContribution, type BlueprintViewDeclaration, BrowserPlayer, type BrowserPlayerConfig, type TransitionResult as BrowserTransitionResult, Button, type ButtonProps, type CRUDConfig, Canvas3D, Card, type CardProps, type CedarPolicy, type ChannelHandle, type ChannelMessage, type ChannelOptions, type ChannelTransport, Chart, type CollectionHandle, Column, type ColumnProps, type ComputedFieldMode, type ComputedFieldResult, type CronFields, type CrudConfig, DataGrid, type DataSource, type DataSourceResult, Divider, type DividerProps, type DmnRule, type DomainEvent, type DomainSubscriptionConfig, type DomainSubscriptionTransport, type DuringAction, type DuringActionConfig, Each, type EachProps, type EscalationConfig, type EventPayload, type EventSubscription, type ExperienceViewConfig, ExperienceWorkflowBridge, type ExperienceWorkflowBridgeProps, type ExperienceWorkflowDefinition, type ExpressionLibraryRecord, type ExpressionLibraryResolver, type ExpressionLibraryResult, Field, FieldBuilder, type FieldRegistration, type FieldTypeMap, type FieldValidation, type FieldValidator, type FormConfig, type FormHandle, type FormValidator, type GeoPosition, type GeolocationError, type GeolocationOptions, type GeolocationResult, type GrammarIsland, Grid, Heading, type HeadingProps, Icon, Image, type InferFieldNames, type InferFields, type InferSlug, type InferStates, type InferTransitions, type InstalledModuleRef, type InstanceData, type InstanceKeyParams, type InstanceRef, type LatLng, type LatLngBounds, type LibraryParam, Link, type LocalDataResolver, type LocalEngineAdapter, type LocalEngineContextValue, LocalEngineProvider, type LocalEngineStore, LocalWorkflowEngine, type LoginCredentials, type MapMarker, type MapViewHandle, type MapViewOptions, Markdown, MetricCard, type MiddlewareContext, type MiddlewareFn, type MiddlewareHandle, type MiddlewareOptions, type MiddlewareResult, type MmWasmModule, Modal, ModelBuilder, type ModelDefinition, type ModelHandle, type ModelMixin, type ModelTestContext, type ModuleAction, type ModuleConfigSchema, type ModuleDependency, type ModuleHandle, type ModuleManifest, type ModuleRoute, type ModuleRouteConfig, type MutationHandle, type MutationResolver, NavLink, type NotificationResult, type NotifyOptions, type PackageChild, type PackageManifest, type PackageResult, type PipelineConfig, type PipelineStage, type PlayerConfig, type PlayerEvent, type PlayerEventCallback, type PlayerEventListener, type PlayerHandle, type PlayerInstance, type PlayerLogEntry, PlayerProvider, type PlayerProviderProps, type QueryParams$1 as QueryParams, type QueryResolver, type QueryResult, type RealtimeQueryParams, type RealtimeQueryResult, type ReviewConfig, type RoleDefinition, RoleGuard, type RoleOptions, type RoleResult, Route, type RouteDefinition, type RouteGuard, type RouteLocation, type RouteParamsOptions, Router, type RouterHandle, type RouterOptions, Row, type RowProps, type RuntimeConfig, RuntimeContext, type RuntimeSnapshot, ScrollArea, Section, Select, type ServerActionFn, type ServerActionHandle, type ServerActionOptions, type ServerActionResolver, type ServerActionResult, ServerGrid, type ServerStateOptions, type ServerStateResolver, type ServerStateResult, type ServerStateSnapshot, type SetupWizard, type SetupWizardStep, Show, type ShowProps, Slot, type SlotContribution, type SlotContributions, type SlotProps, Spacer, type SpawnActionOptions, type SpawnOptions, Stack, type StackProps, StateBuilder, type StateDescriptor, type StateHome, type Subscription, Tabs, type TestChain, type TestStep, Text, TextInput, type TextInputProps, type TextProps, type ToastConfig, type ToastHandle, type ToastInstance, type ToastVariant, TransitionBuilder, type TransitionCondition, type TransitionConfig, type TransitionContext, type TransitionDescriptor, type TransitionHandle, type TypedMutationHandle, TypedTransitionBuilder, type UseCollectionOptions, type UseComputedOptions, type UseModelOptions, type UseModuleOptions, type UseOnEventOptions, type UseWorkflowOptions, type ValidationIssue, type ValidationResult, type ValidationRule, type ViewDefinitionResult, type ViewRecord, type ViewResolver, type WithAuditTrailOptions, type WithOwnershipOptions, type WithRBACOptions, type WithSearchOptions, type WithSlugOptions, type WithSoftDeleteOptions, type WithVersioningOptions, type WorkflowDataSource, type WorkflowDefinition, type WorkflowEvent, type WorkflowEventHandler, type WorkflowFieldDef, type WorkflowFieldDescriptor, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceWithEvents, WorkflowProvider, type WorkflowProviderProps, WorkflowRuntime, type WorkflowState, type WorkflowTransition, action, and, applyMixins, approval, assertModelValid, cedar, connector, createActions, createCRUD, createLocalDataResolver, createLocalEngineAdapter, createPipeline, cron, crud, defineBlueprint, defineModel, defineModule, defineWorkspace, deriveInstanceKey, deriveInstanceKeySync, describeModel, deviceAction, dmn, escalation, expr, field, fieldContains, fieldEquals, fieldGreaterThan, fieldIn, fieldIsEmpty, fieldIsSet, fieldLessThan, fieldMatches, fieldNotEquals, fieldNotIn, getInstalledModule, getInstalledModules, graphql, hasAnyRole, hasRole, inState, inputEquals, inputRequired, isActor, isCreator, isOwner, isPlayerDebug, isSender, jsonpath, llm, loadExperienceWorkflow, logEvent, model, normalizeDefinition, not, notInState, notify, or, pipe, playerLog, prefetchData, refHasAnyRole, refHasRole, requireAuth, requireRole, review, serverAction, setAuthResolver, setChannelTransport, setExpressionLibraryResolver, setField, setFields, setInstalledModules, setModuleConfigDefaults, setMutationResolver, setPlayerDebug, setQueryResolver, setRealtimeQueryResolver, setRoleHierarchy, setServerActionResolver, setServerStateResolver, setViewResolver, spawn, sql, state, testModel, transition, useAuth, useChannel, useCollection, useComputed, useComputedWithMeta, useDomainSubscription, useDuringAction, useExperienceState, useExpressionLibrary, useForm, useGeolocation, useLocalEngine, useMapView, useMiddleware, useModel, useModule, useModuleConfig, useMutation, useNotification, useOnChange, useOnEnter, useOnEvent, useOnExit, useOnTransition, usePackage, useParams, usePlayer, usePlayerContext, usePlayerContextSafe, useQuery, useRealtimeQuery, useRole, useRouteParams, useRouter, useRuntimeContext, useServerAction, useServerState, useStateField, useToast, useTransition, useView, useWhileIn, useWorkflow, useState as useWorkflowState, validateExperienceWorkflow, validateModel, when, withAuditTrail, withOwnership, withPagination, withRBAC, withSearch, withSlug, withSoftDelete, withTags, withTimestamps, withVersioning };
7024
+ export { Accordion, type ActionContext, type ActionCreator, type ActionCreators, type ActionDefinition, type ActionEnvironment, type ActionHandler, type ActionManifest, type ActionManifestEntry, type ActionNotifyOptions, type ActionOptions, type ActionResult, AnimatedBox, type ApprovalConfig, type AuthOptions, type AuthResolver, type AuthResult, type AuthUser, Badge, type BadgeProps, Blueprint, type BlueprintAction, type BlueprintConfig, type BlueprintConfigSchema, type BlueprintDependency, type BlueprintManifest, type BlueprintRoute, type BlueprintServerActionDeclaration, type BlueprintSlotContribution, type BlueprintViewDeclaration, BrowserPlayer, type BrowserPlayerConfig, type TransitionResult as BrowserTransitionResult, Button, type ButtonProps, type CRUDConfig, Canvas3D, Card, type CardProps, type CedarPolicy, type ChannelHandle, type ChannelMessage, type ChannelOptions, type ChannelTransport, Chart, type CollectionHandle, Column, type ColumnProps, type ComputedFieldMode, type ComputedFieldResult, type CronFields, type CrudConfig, DataGrid, type DataSource, type DataSourceResult, Divider, type DividerProps, type DmnRule, type DomainEvent, type DomainSubscriptionConfig, type DomainSubscriptionTransport, type DuringAction, type DuringActionConfig, Each, type EachProps, type EscalationConfig, type EventPayload, type EventSubscription, type ExperienceViewConfig, ExperienceWorkflowBridge, type ExperienceWorkflowBridgeProps, type ExperienceWorkflowDefinition, type ExpressionLibraryRecord, type ExpressionLibraryResolver, type ExpressionLibraryResult, Field, FieldBuilder, type FieldRegistration, type FieldTypeMap, type FieldValidation, type FieldValidator, type FormConfig, type FormHandle, type FormValidator, type GeoPosition, type GeolocationError, type GeolocationOptions, type GeolocationResult, type GrammarIsland, Grid, Heading, type HeadingProps, Icon, Image, type InferFieldNames, type InferFields, type InferSlug, type InferStates, type InferTransitions, type InstalledModuleRef, type InstanceData, type InstanceKeyParams, type InstanceRef, type LatLng, type LatLngBounds, type LibraryParam, Link, type LocalDataResolver, type LocalEngineAdapter, type LocalEngineContextValue, LocalEngineProvider, type LocalEngineStore, LocalWorkflowEngine, type LoginCredentials, type MapMarker, type MapViewHandle, type MapViewOptions, Markdown, MetricCard, type MiddlewareContext, type MiddlewareFn, type MiddlewareHandle, type MiddlewareOptions, type MiddlewareResult, type MmWasmModule, Modal, ModelBuilder, type ModelDefinition, type ModelHandle, type ModelMixin, type ModelTestContext, type ModuleAction, type ModuleConfigSchema, type ModuleDependency, type ModuleHandle, type ModuleManifest, type ModuleRoute, type ModuleRouteConfig, type MutationHandle, type MutationResolver, NavLink, type NotificationResult, type NotifyOptions, type PackageChild, type PackageManifest, type PackageResult, type PipelineConfig, type PipelineStage, type PlayerConfig, type PlayerEvent, type PlayerEventCallback, type PlayerEventListener, type PlayerHandle, type PlayerInstance, type PlayerLogEntry, PlayerProvider, type PlayerProviderProps, type QueryParams$1 as QueryParams, type QueryResolver, type QueryResult, type RealtimeQueryParams, type RealtimeQueryResult, type ReviewConfig, type RoleDefinition, RoleGuard, type RoleOptions, type RoleResult, Route, type RouteDefinition, type RouteGuard, type RouteLocation, type RouteParamsOptions, Router, type RouterHandle, type RouterOptions, Row, type RowProps, type RuntimeConfig, RuntimeContext, type RuntimeSnapshot, ScrollArea, Section, Select, type ServerActionFn, type ServerActionHandle, type ServerActionOptions, type ServerActionResolver, type ServerActionResult, ServerGrid, type ServerStateOptions, type ServerStateResolver, type ServerStateResult, type ServerStateSnapshot, type SetupWizard, type SetupWizardStep, Show, type ShowProps, Slot, type SlotContribution, type SlotContributions, type SlotProps, Spacer, type SpawnActionOptions, type SpawnOptions, Stack, type StackProps, StateBuilder, type StateDescriptor, type StateHome, type Subscription, Tabs, type TestChain, type TestStep, Text, TextInput, type TextInputProps, type TextProps, type ToastConfig, type ToastHandle, type ToastInstance, type ToastVariant, TransitionBuilder, type TransitionCondition, type TransitionConfig, type TransitionContext, type TransitionDescriptor, type TransitionHandle, type TypedMutationHandle, TypedTransitionBuilder, type UseCollectionOptions, type UseComputedOptions, type UseModelOptions, type UseModuleOptions, type UseOnEventOptions, type UseWorkflowOptions, type ValidationIssue, type ValidationResult, type ValidationRule, type ViewDefinitionResult, type ViewRecord, type ViewResolver, type WithAuditTrailOptions, type WithOwnershipOptions, type WithRBACOptions, type WithSearchOptions, type WithSlugOptions, type WithSoftDeleteOptions, type WithVersioningOptions, type WorkflowDataSource, type WorkflowDefinition, type WorkflowEvent, type WorkflowEventHandler, type WorkflowFieldDef, type WorkflowFieldDescriptor, type WorkflowHandle, type WorkflowInstance, type WorkflowInstanceWithEvents, WorkflowProvider, type WorkflowProviderProps, WorkflowRuntime, type WorkflowState, type WorkflowTransition, action, and, applyMixins, approval, assertModelValid, cedar, connector, createActions, createCRUD, createLocalDataResolver, createLocalEngineAdapter, createPipeline, cron, crud, defineBlueprint, defineModel, defineModule, defineWorkspace, deriveInstanceKey, deriveInstanceKeySync, describeModel, deviceAction, dmn, escalation, expr, field, fieldContains, fieldEquals, fieldGreaterThan, fieldIn, fieldIsEmpty, fieldIsSet, fieldLessThan, fieldMatches, fieldNotEquals, fieldNotIn, getInstalledModule, getInstalledModules, graphql, hasAnyRole, hasRole, inState, inputEquals, inputRequired, isActor, isCreator, isOwner, isPlayerDebug, isSender, jsonpath, llm, loadExperienceWorkflow, logEvent, model, normalizeDefinition, not, notInState, notify, or, pipe, playerLog, prefetchData, refHasAnyRole, refHasRole, requireAuth, requireRole, review, serverAction, setAuthResolver, setChannelTransport, setConfigContext, setExpressionLibraryResolver, setField, setFields, setInstalledModules, setModuleConfigDefaults, setMutationResolver, setPersistedModuleConfig, setPlayerDebug, setQueryResolver, setRealtimeQueryResolver, setRoleHierarchy, setServerActionResolver, setServerStateResolver, setViewResolver, spawn, sql, state, syncConfigDefaults, testModel, transition, updateDefinitionConfig, useAuth, useChannel, useCollection, useComputed, useComputedWithMeta, useDomainSubscription, useDuringAction, useExperienceState, useExpressionLibrary, useForm, useGeolocation, useLocalEngine, useMapView, useMiddleware, useModel, useModule, useModuleConfig, useModuleConfigWithMutation, useMutation, useNotification, useOnChange, useOnEnter, useOnEvent, useOnExit, useOnTransition, usePackage, useParams, usePlayer, usePlayerContext, usePlayerContextSafe, useQuery, useRealtimeQuery, useRole, useRouteParams, useRouter, useRuntimeContext, useServerAction, useServerState, useStateField, useToast, useTransition, useView, useWhileIn, useWorkflow, useState as useWorkflowState, validateExperienceWorkflow, validateModel, when, withAuditTrail, withOwnership, withPagination, withRBAC, withSearch, withSlug, withSoftDelete, withTags, withTimestamps, withVersioning };
package/dist/index.js CHANGED
@@ -150,12 +150,14 @@ __export(index_exports, {
150
150
  serverAction: () => serverAction,
151
151
  setAuthResolver: () => setAuthResolver,
152
152
  setChannelTransport: () => setChannelTransport,
153
+ setConfigContext: () => setConfigContext,
153
154
  setExpressionLibraryResolver: () => setExpressionLibraryResolver,
154
155
  setField: () => setField,
155
156
  setFields: () => setFields,
156
157
  setInstalledModules: () => setInstalledModules,
157
158
  setModuleConfigDefaults: () => setModuleConfigDefaults,
158
159
  setMutationResolver: () => setMutationResolver,
160
+ setPersistedModuleConfig: () => setPersistedModuleConfig,
159
161
  setPlayerDebug: () => setPlayerDebug,
160
162
  setQueryResolver: () => setQueryResolver,
161
163
  setRealtimeQueryResolver: () => setRealtimeQueryResolver,
@@ -166,8 +168,10 @@ __export(index_exports, {
166
168
  spawn: () => spawn,
167
169
  sql: () => sql,
168
170
  state: () => state,
171
+ syncConfigDefaults: () => syncConfigDefaults,
169
172
  testModel: () => testModel,
170
173
  transition: () => transition,
174
+ updateDefinitionConfig: () => updateDefinitionConfig,
171
175
  useAuth: () => useAuth,
172
176
  useChannel: () => useChannel,
173
177
  useCollection: () => useCollection,
@@ -185,6 +189,7 @@ __export(index_exports, {
185
189
  useModel: () => useModel,
186
190
  useModule: () => useModule,
187
191
  useModuleConfig: () => useModuleConfig,
192
+ useModuleConfigWithMutation: () => useModuleConfigWithMutation,
188
193
  useMutation: () => useMutation,
189
194
  useNotification: () => useNotification,
190
195
  useOnChange: () => useOnChange,
@@ -1286,8 +1291,8 @@ var ActionDispatcher = class {
1286
1291
  }
1287
1292
  const handler = this.handlers.get(action2.type);
1288
1293
  if (!handler) {
1289
- console.warn(`[player-core] No handler registered for action type "${action2.type}"`);
1290
- results.push({ type: action2.type, success: false, error: `No handler for "${action2.type}"` });
1294
+ console.warn(`[player-core] No handler registered for action type "${action2.type}" \u2014 unsupported action`);
1295
+ results.push({ type: action2.type, success: false, error: `unsupported action: "${action2.type}"` });
1291
1296
  continue;
1292
1297
  }
1293
1298
  try {
@@ -1305,6 +1310,10 @@ var ActionDispatcher = class {
1305
1310
  get size() {
1306
1311
  return this.handlers.size;
1307
1312
  }
1313
+ /** Get all registered action type names */
1314
+ getRegisteredTypes() {
1315
+ return Array.from(this.handlers.keys());
1316
+ }
1308
1317
  /** Remove all handlers */
1309
1318
  clear() {
1310
1319
  this.handlers.clear();
@@ -4745,9 +4754,62 @@ function useModuleConfig(moduleSlug) {
4745
4754
  return (0, import_react34.useMemo)(() => {
4746
4755
  const installed = getInstalledModule(moduleSlug);
4747
4756
  const defaults = configDefaultsStore.get(moduleSlug) ?? {};
4748
- return { ...defaults, ...installed?.config };
4757
+ const persisted = persistedConfigStore.get(moduleSlug) ?? {};
4758
+ return { ...defaults, ...persisted, ...installed?.config };
4749
4759
  }, [moduleSlug]);
4750
4760
  }
4761
+ var persistedConfigStore = /* @__PURE__ */ new Map();
4762
+ function setPersistedModuleConfig(moduleSlug, config) {
4763
+ persistedConfigStore.set(moduleSlug, config);
4764
+ }
4765
+ async function syncConfigDefaults(moduleSlug, defaults, definitionId) {
4766
+ const id = definitionId ?? activeDefinitionIdStore;
4767
+ if (!id) return;
4768
+ try {
4769
+ const moduleKey = `module_config.${moduleSlug}`;
4770
+ await updateDefinitionConfig({ [moduleKey]: defaults }, id);
4771
+ persistedConfigStore.set(moduleSlug, defaults);
4772
+ } catch (e) {
4773
+ console.warn(`[useModuleConfig] Failed to sync config for ${moduleSlug}:`, e);
4774
+ }
4775
+ }
4776
+ var activeDefinitionIdStore = null;
4777
+ var apiBaseUrlStore = "/api/v1/workflow";
4778
+ function setConfigContext(definitionId, apiBaseUrl) {
4779
+ activeDefinitionIdStore = definitionId;
4780
+ if (apiBaseUrl) apiBaseUrlStore = apiBaseUrl;
4781
+ }
4782
+ async function updateDefinitionConfig(values, definitionId) {
4783
+ const id = definitionId ?? activeDefinitionIdStore;
4784
+ if (!id) throw new Error("No active definition ID. Call setConfigContext() first.");
4785
+ const token = typeof localStorage !== "undefined" ? localStorage.getItem("auth_token") : null;
4786
+ const response = await fetch(`${apiBaseUrlStore}/definitions/${id}/config`, {
4787
+ method: "PATCH",
4788
+ headers: {
4789
+ "Content-Type": "application/json",
4790
+ ...token ? { Authorization: `Bearer ${token}` } : {}
4791
+ },
4792
+ body: JSON.stringify(values)
4793
+ });
4794
+ if (!response.ok) {
4795
+ const err = await response.json().catch(() => ({ message: response.statusText }));
4796
+ throw new Error(err.message || `Failed to update config: ${response.status}`);
4797
+ }
4798
+ return response.json();
4799
+ }
4800
+ function useModuleConfigWithMutation(moduleSlug) {
4801
+ const config = useModuleConfig(moduleSlug);
4802
+ const [isSaving, setIsSaving] = (0, import_react34.useState)(false);
4803
+ const updateConfig = (0, import_react34.useCallback)(async (values) => {
4804
+ setIsSaving(true);
4805
+ try {
4806
+ return await updateDefinitionConfig(values);
4807
+ } finally {
4808
+ setIsSaving(false);
4809
+ }
4810
+ }, []);
4811
+ return { config, updateConfig, isSaving };
4812
+ }
4751
4813
 
4752
4814
  // src/builders.ts
4753
4815
  function handlerToAction(handler, qualifier) {
@@ -8169,12 +8231,14 @@ var BrowserPlayer = class {
8169
8231
  serverAction,
8170
8232
  setAuthResolver,
8171
8233
  setChannelTransport,
8234
+ setConfigContext,
8172
8235
  setExpressionLibraryResolver,
8173
8236
  setField,
8174
8237
  setFields,
8175
8238
  setInstalledModules,
8176
8239
  setModuleConfigDefaults,
8177
8240
  setMutationResolver,
8241
+ setPersistedModuleConfig,
8178
8242
  setPlayerDebug,
8179
8243
  setQueryResolver,
8180
8244
  setRealtimeQueryResolver,
@@ -8185,8 +8249,10 @@ var BrowserPlayer = class {
8185
8249
  spawn,
8186
8250
  sql,
8187
8251
  state,
8252
+ syncConfigDefaults,
8188
8253
  testModel,
8189
8254
  transition,
8255
+ updateDefinitionConfig,
8190
8256
  useAuth,
8191
8257
  useChannel,
8192
8258
  useCollection,
@@ -8204,6 +8270,7 @@ var BrowserPlayer = class {
8204
8270
  useModel,
8205
8271
  useModule,
8206
8272
  useModuleConfig,
8273
+ useModuleConfigWithMutation,
8207
8274
  useMutation,
8208
8275
  useNotification,
8209
8276
  useOnChange,
package/dist/index.mjs CHANGED
@@ -1056,8 +1056,8 @@ var ActionDispatcher = class {
1056
1056
  }
1057
1057
  const handler = this.handlers.get(action2.type);
1058
1058
  if (!handler) {
1059
- console.warn(`[player-core] No handler registered for action type "${action2.type}"`);
1060
- results.push({ type: action2.type, success: false, error: `No handler for "${action2.type}"` });
1059
+ console.warn(`[player-core] No handler registered for action type "${action2.type}" \u2014 unsupported action`);
1060
+ results.push({ type: action2.type, success: false, error: `unsupported action: "${action2.type}"` });
1061
1061
  continue;
1062
1062
  }
1063
1063
  try {
@@ -1075,6 +1075,10 @@ var ActionDispatcher = class {
1075
1075
  get size() {
1076
1076
  return this.handlers.size;
1077
1077
  }
1078
+ /** Get all registered action type names */
1079
+ getRegisteredTypes() {
1080
+ return Array.from(this.handlers.keys());
1081
+ }
1078
1082
  /** Remove all handlers */
1079
1083
  clear() {
1080
1084
  this.handlers.clear();
@@ -4496,7 +4500,7 @@ function useModule(slug, config = {}, options = {}) {
4496
4500
  }
4497
4501
 
4498
4502
  // src/hooks/useModuleConfig.ts
4499
- import { useMemo as useMemo17 } from "react";
4503
+ import { useCallback as useCallback20, useMemo as useMemo17, useState as useState21 } from "react";
4500
4504
  var installedModulesStore = [];
4501
4505
  var configDefaultsStore = /* @__PURE__ */ new Map();
4502
4506
  function setInstalledModules(modules) {
@@ -4515,9 +4519,62 @@ function useModuleConfig(moduleSlug) {
4515
4519
  return useMemo17(() => {
4516
4520
  const installed = getInstalledModule(moduleSlug);
4517
4521
  const defaults = configDefaultsStore.get(moduleSlug) ?? {};
4518
- return { ...defaults, ...installed?.config };
4522
+ const persisted = persistedConfigStore.get(moduleSlug) ?? {};
4523
+ return { ...defaults, ...persisted, ...installed?.config };
4519
4524
  }, [moduleSlug]);
4520
4525
  }
4526
+ var persistedConfigStore = /* @__PURE__ */ new Map();
4527
+ function setPersistedModuleConfig(moduleSlug, config) {
4528
+ persistedConfigStore.set(moduleSlug, config);
4529
+ }
4530
+ async function syncConfigDefaults(moduleSlug, defaults, definitionId) {
4531
+ const id = definitionId ?? activeDefinitionIdStore;
4532
+ if (!id) return;
4533
+ try {
4534
+ const moduleKey = `module_config.${moduleSlug}`;
4535
+ await updateDefinitionConfig({ [moduleKey]: defaults }, id);
4536
+ persistedConfigStore.set(moduleSlug, defaults);
4537
+ } catch (e) {
4538
+ console.warn(`[useModuleConfig] Failed to sync config for ${moduleSlug}:`, e);
4539
+ }
4540
+ }
4541
+ var activeDefinitionIdStore = null;
4542
+ var apiBaseUrlStore = "/api/v1/workflow";
4543
+ function setConfigContext(definitionId, apiBaseUrl) {
4544
+ activeDefinitionIdStore = definitionId;
4545
+ if (apiBaseUrl) apiBaseUrlStore = apiBaseUrl;
4546
+ }
4547
+ async function updateDefinitionConfig(values, definitionId) {
4548
+ const id = definitionId ?? activeDefinitionIdStore;
4549
+ if (!id) throw new Error("No active definition ID. Call setConfigContext() first.");
4550
+ const token = typeof localStorage !== "undefined" ? localStorage.getItem("auth_token") : null;
4551
+ const response = await fetch(`${apiBaseUrlStore}/definitions/${id}/config`, {
4552
+ method: "PATCH",
4553
+ headers: {
4554
+ "Content-Type": "application/json",
4555
+ ...token ? { Authorization: `Bearer ${token}` } : {}
4556
+ },
4557
+ body: JSON.stringify(values)
4558
+ });
4559
+ if (!response.ok) {
4560
+ const err = await response.json().catch(() => ({ message: response.statusText }));
4561
+ throw new Error(err.message || `Failed to update config: ${response.status}`);
4562
+ }
4563
+ return response.json();
4564
+ }
4565
+ function useModuleConfigWithMutation(moduleSlug) {
4566
+ const config = useModuleConfig(moduleSlug);
4567
+ const [isSaving, setIsSaving] = useState21(false);
4568
+ const updateConfig = useCallback20(async (values) => {
4569
+ setIsSaving(true);
4570
+ try {
4571
+ return await updateDefinitionConfig(values);
4572
+ } finally {
4573
+ setIsSaving(false);
4574
+ }
4575
+ }, []);
4576
+ return { config, updateConfig, isSaving };
4577
+ }
4521
4578
 
4522
4579
  // src/builders.ts
4523
4580
  function handlerToAction(handler, qualifier) {
@@ -6711,7 +6768,7 @@ function describeModel(def) {
6711
6768
  }
6712
6769
 
6713
6770
  // src/hooks/usePlayer.ts
6714
- import { useCallback as useCallback20, useEffect as useEffect21, useMemo as useMemo18, useRef as useRef24, useState as useState21 } from "react";
6771
+ import { useCallback as useCallback21, useEffect as useEffect21, useMemo as useMemo18, useRef as useRef24, useState as useState22 } from "react";
6715
6772
 
6716
6773
  // src/logger.ts
6717
6774
  var debugEnabled = false;
@@ -6816,7 +6873,7 @@ function usePlayer(config) {
6816
6873
  return { sm: sm2, eventBus: eventBus2, dispatcher };
6817
6874
  }, [config.definition.id, evaluator]);
6818
6875
  const { sm, eventBus } = engine;
6819
- const [playerState, setPlayerState] = useState21(() => computePlayerState(sm));
6876
+ const [playerState, setPlayerState] = useState22(() => computePlayerState(sm));
6820
6877
  useEffect21(() => {
6821
6878
  const stateDef = sm.getCurrentStateDefinition();
6822
6879
  if (!stateDef?.on_event?.length) return;
@@ -6897,7 +6954,7 @@ function usePlayer(config) {
6897
6954
  });
6898
6955
  return unsub;
6899
6956
  }, [sm]);
6900
- const transition2 = useCallback20(
6957
+ const transition2 = useCallback21(
6901
6958
  async (name, data) => {
6902
6959
  playerLog({
6903
6960
  level: "info",
@@ -6924,20 +6981,20 @@ function usePlayer(config) {
6924
6981
  },
6925
6982
  [sm]
6926
6983
  );
6927
- const setField2 = useCallback20(
6984
+ const setField2 = useCallback21(
6928
6985
  (field2, value) => {
6929
6986
  sm.setField(field2, value);
6930
6987
  setPlayerState(computePlayerState(sm));
6931
6988
  },
6932
6989
  [sm]
6933
6990
  );
6934
- const setMemory = useCallback20(
6991
+ const setMemory = useCallback21(
6935
6992
  (key, value) => {
6936
6993
  sm.setMemory(key, value);
6937
6994
  },
6938
6995
  [sm]
6939
6996
  );
6940
- const publishEvent = useCallback20(
6997
+ const publishEvent = useCallback21(
6941
6998
  (topic, payload) => {
6942
6999
  playerLog({
6943
7000
  level: "debug",
@@ -7020,11 +7077,11 @@ function useDomainSubscription(eventBus, transport, config) {
7020
7077
  }
7021
7078
 
7022
7079
  // src/hooks/useExperienceState.ts
7023
- import { useCallback as useCallback21, useRef as useRef26 } from "react";
7080
+ import { useCallback as useCallback22, useRef as useRef26 } from "react";
7024
7081
  function useExperienceState(player, selector) {
7025
7082
  const selectorRef = useRef26(selector);
7026
7083
  selectorRef.current = selector;
7027
- const getSnapshot = useCallback21(() => {
7084
+ const getSnapshot = useCallback22(() => {
7028
7085
  return selectorRef.current({
7029
7086
  currentState: player.currentState,
7030
7087
  stateData: player.stateData,
@@ -7938,12 +7995,14 @@ export {
7938
7995
  serverAction,
7939
7996
  setAuthResolver,
7940
7997
  setChannelTransport,
7998
+ setConfigContext,
7941
7999
  setExpressionLibraryResolver,
7942
8000
  setField,
7943
8001
  setFields,
7944
8002
  setInstalledModules,
7945
8003
  setModuleConfigDefaults,
7946
8004
  setMutationResolver,
8005
+ setPersistedModuleConfig,
7947
8006
  setPlayerDebug,
7948
8007
  setQueryResolver,
7949
8008
  setRealtimeQueryResolver,
@@ -7954,8 +8013,10 @@ export {
7954
8013
  spawn,
7955
8014
  sql,
7956
8015
  state,
8016
+ syncConfigDefaults,
7957
8017
  testModel,
7958
8018
  transition,
8019
+ updateDefinitionConfig,
7959
8020
  useAuth,
7960
8021
  useChannel,
7961
8022
  useCollection,
@@ -7973,6 +8034,7 @@ export {
7973
8034
  useModel,
7974
8035
  useModule,
7975
8036
  useModuleConfig,
8037
+ useModuleConfigWithMutation,
7976
8038
  useMutation,
7977
8039
  useNotification,
7978
8040
  useOnChange,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmapp/react",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.3",
4
4
  "description": "React integration for the MindMatrix Player — hooks, components, and WebSocket bridge for browser-side workflow engines",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -22,14 +22,15 @@
22
22
  "dev": "tsup src/index.ts --format cjs,esm --dts --external react --watch",
23
23
  "test": "vitest run",
24
24
  "test:watch": "vitest --watch",
25
- "type-check": "tsc --noEmit"
25
+ "type-check": "tsc --noEmit",
26
+ "publish:alpha": "cd ../.. && ./scripts/publish-npm.sh"
26
27
  },
27
28
  "peerDependencies": {
28
29
  "react": ">=18.0.0",
29
30
  "@tanstack/react-query": ">=5.0.0"
30
31
  },
31
32
  "dependencies": {
32
- "@mmapp/player-core": "^0.1.0-alpha.1"
33
+ "@mmapp/player-core": "^0.1.0-alpha.3"
33
34
  },
34
35
  "publishConfig": {
35
36
  "access": "public"
@@ -1,41 +0,0 @@
1
- {
2
- "name": "@mindmatrix/react",
3
- "version": "0.1.0",
4
- "description": "React integration for the MindMatrix Player — hooks, components, and WebSocket bridge for browser-side workflow engines",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- },
14
- "./atoms": {
15
- "types": "./dist/atoms/index.d.ts",
16
- "import": "./dist/atoms/index.mjs",
17
- "require": "./dist/atoms/index.js"
18
- }
19
- },
20
- "scripts": {
21
- "build": "tsup src/index.ts --format cjs,esm --dts --external react",
22
- "dev": "tsup src/index.ts --format cjs,esm --dts --external react --watch",
23
- "test": "vitest run",
24
- "test:watch": "vitest --watch",
25
- "type-check": "tsc --noEmit"
26
- },
27
- "peerDependencies": {
28
- "react": ">=18.0.0",
29
- "@tanstack/react-query": ">=5.0.0"
30
- },
31
- "dependencies": {
32
- "@mindmatrix/player-core": "workspace:*"
33
- },
34
- "devDependencies": {
35
- "@types/react": "^19.0.0",
36
- "react": "^19.0.0",
37
- "tsup": "^8.0.0",
38
- "typescript": "^5.4.0",
39
- "vitest": "^1.5.0"
40
- }
41
- }