@mmapp/player-core 0.1.0-alpha.1 → 0.1.0-alpha.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 (64) hide show
  1. package/README.md +66 -0
  2. package/dist/index.d.mts +87 -1
  3. package/dist/index.d.ts +87 -1
  4. package/dist/index.js +81 -2
  5. package/dist/index.mjs +79 -2
  6. package/package.json +3 -2
  7. package/package.json.backup +0 -35
  8. package/src/__tests__/actions.test.ts +0 -187
  9. package/src/__tests__/blueprint-e2e.test.ts +0 -706
  10. package/src/__tests__/blueprint-test-runner.test.ts +0 -680
  11. package/src/__tests__/core-functions.test.ts +0 -78
  12. package/src/__tests__/dsl-compiler.test.ts +0 -1382
  13. package/src/__tests__/dsl-grammar.test.ts +0 -1682
  14. package/src/__tests__/events.test.ts +0 -200
  15. package/src/__tests__/expression.test.ts +0 -296
  16. package/src/__tests__/failure-policies.test.ts +0 -110
  17. package/src/__tests__/frontend-context.test.ts +0 -182
  18. package/src/__tests__/integration.test.ts +0 -256
  19. package/src/__tests__/security.test.ts +0 -190
  20. package/src/__tests__/state-machine.test.ts +0 -450
  21. package/src/__tests__/testing-engine.test.ts +0 -671
  22. package/src/actions/dispatcher.ts +0 -80
  23. package/src/actions/index.ts +0 -7
  24. package/src/actions/types.ts +0 -25
  25. package/src/dsl/compiler/component-mapper.ts +0 -289
  26. package/src/dsl/compiler/field-mapper.ts +0 -187
  27. package/src/dsl/compiler/index.ts +0 -82
  28. package/src/dsl/compiler/manifest-compiler.ts +0 -76
  29. package/src/dsl/compiler/symbol-table.ts +0 -214
  30. package/src/dsl/compiler/utils.ts +0 -48
  31. package/src/dsl/compiler/view-compiler.ts +0 -286
  32. package/src/dsl/compiler/workflow-compiler.ts +0 -600
  33. package/src/dsl/index.ts +0 -66
  34. package/src/dsl/ir-migration.ts +0 -221
  35. package/src/dsl/ir-types.ts +0 -416
  36. package/src/dsl/lexer.ts +0 -579
  37. package/src/dsl/parser.ts +0 -115
  38. package/src/dsl/types.ts +0 -256
  39. package/src/events/event-bus.ts +0 -68
  40. package/src/events/index.ts +0 -9
  41. package/src/events/pattern-matcher.ts +0 -61
  42. package/src/events/types.ts +0 -27
  43. package/src/expression/evaluator.ts +0 -676
  44. package/src/expression/functions.ts +0 -214
  45. package/src/expression/index.ts +0 -13
  46. package/src/expression/types.ts +0 -64
  47. package/src/index.ts +0 -61
  48. package/src/state-machine/index.ts +0 -16
  49. package/src/state-machine/interpreter.ts +0 -319
  50. package/src/state-machine/types.ts +0 -89
  51. package/src/testing/action-trace.ts +0 -209
  52. package/src/testing/blueprint-test-runner.ts +0 -214
  53. package/src/testing/graph-walker.ts +0 -249
  54. package/src/testing/index.ts +0 -69
  55. package/src/testing/nrt-comparator.ts +0 -199
  56. package/src/testing/nrt-types.ts +0 -230
  57. package/src/testing/test-actions.ts +0 -645
  58. package/src/testing/test-compiler.ts +0 -278
  59. package/src/testing/test-runner.ts +0 -444
  60. package/src/testing/types.ts +0 -231
  61. package/src/validation/definition-validator.ts +0 -812
  62. package/src/validation/index.ts +0 -13
  63. package/tsconfig.json +0 -26
  64. package/vitest.config.ts +0 -8
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @mmapp/player-core
2
+
3
+ Framework-agnostic workflow engine for browser-side state machines, expression evaluation, and event-driven reactions.
4
+
5
+ Published on npm as `@mmapp/player-core` (internal workspace name: `@mindmatrix/player-core`).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @mmapp/player-core
11
+ ```
12
+
13
+ ## What's Inside
14
+
15
+ - **StateMachine** — state machine interpreter with transition guards, actions, and event subscriptions
16
+ - **ActionDispatcher** — action execution pipeline with failure policies
17
+ - **EventBus** — pub/sub event system with pattern matching
18
+ - **Evaluator** — expression evaluation engine (Pratt parser + tree-walk)
19
+ - **DSL Compiler** — compiles workflow DSL to IR (Intermediate Representation)
20
+ - **Validator** — validates workflow definitions against the IR schema
21
+ - **Testing** — test runner, blueprint test runner, graph analysis, NRT tracing
22
+
23
+ ## Usage
24
+
25
+ ```typescript
26
+ import { StateMachine, createEvaluator, validateDefinition } from '@mmapp/player-core';
27
+
28
+ // Validate a workflow definition
29
+ const errors = validateDefinition(myDefinition);
30
+
31
+ // Create and run a state machine
32
+ const machine = new StateMachine(myDefinition);
33
+ machine.transition('submit');
34
+ ```
35
+
36
+ ## npm Publishing
37
+
38
+ This package is published to npm under the `@mmapp` scope.
39
+
40
+ | npm name | workspace name | current version |
41
+ |----------|---------------|-----------------|
42
+ | `@mmapp/player-core` | `@mindmatrix/player-core` | 0.1.0-alpha.1 |
43
+
44
+ ### Publishing a new version
45
+
46
+ Use the publish script from the monorepo root:
47
+
48
+ ```bash
49
+ # Publish all 3 packages (player-core, react, react-compiler)
50
+ ./scripts/publish-npm.sh patch # 0.1.0-alpha.1 → 0.1.0-alpha.2
51
+ ./scripts/publish-npm.sh minor # 0.1.0-alpha.1 → 0.2.0-alpha.1
52
+ ./scripts/publish-npm.sh 0.2.0-beta.1 # explicit version
53
+ ```
54
+
55
+ Or publish just this package:
56
+
57
+ ```bash
58
+ cd packages/player-core
59
+ pnpm run publish:alpha # auto-increments alpha version
60
+ ```
61
+
62
+ ### Version strategy
63
+
64
+ - `0.1.0-alpha.X` — internal development (current)
65
+ - `0.1.0-beta.X` — user testing
66
+ - `1.0.0` — production launch
package/dist/index.d.mts CHANGED
@@ -360,6 +360,8 @@ declare class ActionDispatcher {
360
360
  execute(actions: ActionDefinition[], context: ExpressionContext, evaluator?: Evaluator): Promise<ActionResult[]>;
361
361
  /** Get count of registered handlers */
362
362
  get size(): number;
363
+ /** Get all registered action type names */
364
+ getRegisteredTypes(): string[];
363
365
  /** Remove all handlers */
364
366
  clear(): void;
365
367
  }
@@ -1039,6 +1041,8 @@ interface IRActionDefinition {
1039
1041
  mode: IRActionMode;
1040
1042
  config: Record<string, unknown>;
1041
1043
  condition?: string;
1044
+ /** Saga compensation: action to run if a subsequent action fails (Design 28). */
1045
+ compensate?: IRActionDefinition;
1042
1046
  }
1043
1047
  interface IRDuringAction {
1044
1048
  id: string;
@@ -1072,6 +1076,8 @@ interface IRStateDefinition {
1072
1076
  during: IRDuringAction[];
1073
1077
  on_exit: IRActionDefinition[];
1074
1078
  on_event?: IROnEventSubscription[];
1079
+ /** Where this state executes at runtime (server, client, worker, edge, any). */
1080
+ runtime?: string;
1075
1081
  }
1076
1082
  interface IRConditionDefinition {
1077
1083
  type?: string;
@@ -1092,6 +1098,8 @@ interface IRTransitionDefinition {
1092
1098
  roles?: string[];
1093
1099
  auto?: boolean;
1094
1100
  required_fields?: string[];
1101
+ /** Where this transition executes at runtime (server, client, worker, edge, any). */
1102
+ runtime?: string;
1095
1103
  }
1096
1104
  interface IRFieldValidation {
1097
1105
  min?: number;
@@ -1378,6 +1386,84 @@ declare function validateDefinition(def: IRWorkflowDefinition, options?: Validat
1378
1386
  */
1379
1387
  declare function isViableDefinition(def: unknown): def is IRWorkflowDefinition;
1380
1388
 
1389
+ /**
1390
+ * Player Capability Declaration & Compatibility Check (ISS-059)
1391
+ *
1392
+ * Each player runtime (web, iOS, console, TUI) declares its capabilities
1393
+ * via a PlayerManifest. When loading a blueprint, the compatibility checker
1394
+ * compares manifest against requirements to produce warnings/errors.
1395
+ *
1396
+ * This is informational, not blocking — players should still attempt to render.
1397
+ */
1398
+ /** Declares what a player runtime can render and execute. */
1399
+ interface PlayerManifest {
1400
+ /** Player identifier (e.g., "web", "ios", "console", "tui") */
1401
+ player: string;
1402
+ /** Player version */
1403
+ version: string;
1404
+ /** Supported atom component IDs */
1405
+ atoms: string[];
1406
+ /** Supported action types */
1407
+ actions: string[];
1408
+ /** Whether the player can evaluate expressions natively */
1409
+ expressions: boolean;
1410
+ /** Whether the player works offline */
1411
+ offline: boolean;
1412
+ }
1413
+ /** What a blueprint requires from a player to render correctly. */
1414
+ interface BlueprintRequirements {
1415
+ /** Atom component IDs used in the experience tree */
1416
+ atoms: string[];
1417
+ /** Action types referenced in transitions/states */
1418
+ actions: string[];
1419
+ /** Whether the blueprint uses expressions */
1420
+ expressions: boolean;
1421
+ }
1422
+ /** Result of comparing a PlayerManifest against BlueprintRequirements. */
1423
+ interface CompatibilityResult {
1424
+ /** Whether the player can render the blueprint without missing critical features */
1425
+ compatible: boolean;
1426
+ /** Atom component IDs the blueprint uses but the player doesn't support */
1427
+ missingAtoms: string[];
1428
+ /** Action types the blueprint references but the player can't handle */
1429
+ missingActions: string[];
1430
+ /** Human-readable warnings (non-blocking issues) */
1431
+ warnings: string[];
1432
+ }
1433
+ /**
1434
+ * Compare a player's capabilities against a blueprint's requirements.
1435
+ *
1436
+ * Missing atoms produce warnings (graceful degradation — render fallback).
1437
+ * Missing actions produce errors (may cause runtime failures).
1438
+ * The check is informational — players should still attempt to load.
1439
+ */
1440
+ declare function checkCompatibility(manifest: PlayerManifest, requirements: BlueprintRequirements): CompatibilityResult;
1441
+ /**
1442
+ * Walk a JSON experience tree and transition/state actions to extract
1443
+ * all atom component IDs and action types referenced.
1444
+ *
1445
+ * This mirrors the Rust `WorkflowDefinition::extract_requirements()`.
1446
+ */
1447
+ declare function extractRequirements(definition: {
1448
+ experience?: unknown;
1449
+ states?: Array<{
1450
+ on_enter?: Array<{
1451
+ action_type?: string;
1452
+ type?: string;
1453
+ }>;
1454
+ on_exit?: Array<{
1455
+ action_type?: string;
1456
+ type?: string;
1457
+ }>;
1458
+ }>;
1459
+ transitions?: Array<{
1460
+ actions?: Array<{
1461
+ action_type?: string;
1462
+ type?: string;
1463
+ }>;
1464
+ }>;
1465
+ }): BlueprintRequirements;
1466
+
1381
1467
  /**
1382
1468
  * DSL Compiler — entry point.
1383
1469
  *
@@ -1433,4 +1519,4 @@ declare function normalizeDefinition(def: Record<string, unknown>): MigrationRes
1433
1519
  */
1434
1520
  declare function needsMigration(def: Record<string, unknown>): boolean;
1435
1521
 
1436
- export { type ActionDefinition, ActionDispatcher, type ActionHandler, type ActionHandlerFn, type ActionRecorder, type ActionResult, type ActionTick, type ActionTrace, type AnalysisResult, type AnalysisSummary, type ApiInstanceSnapshot, type ApiTestAdapter, type ApiTestRunnerConfig, type ApiTransitionResult, type AssertionResult, type BlueprintRunnerConfig, type BusEvent, CORE_FUNCTIONS, CURRENT_IR_VERSION, type CompilationResult, type CompiledOutput, type CompilerError, type CompilerErrorCode, type Evaluator, type EvaluatorConfig, EventBus, type EventHandler, type EventSubscription, type ExpressionContext, type ExpressionDiagnostics, type ExpressionFunction, type ExpressionResult, type FailurePolicy, type FailurePolicyContext, type GraphPath, type IRActionDefinition, type IRActionMode, type IRApiDataSource, type IRBlueprintManifest, type IRConditionDefinition, type IRDataSource, type IRDuringAction, type IRExperienceDefinition, type IRExperienceNode, type IRFieldDefinition, type IRFieldValidation, type IRGrammarIsland, type IROnEventAction, type IROnEventSubscription, type IRRefDataSource, type IRRoleDefinition, type IRStateDefinition, type IRStateHome, type IRStateType, type IRStaticDataSource, type IRTransitionDefinition, type IRWorkflowDataSource, type IRWorkflowDefinition, type IRWorkflowFieldType, type MigrationResult, type NRT, type NRTChange, type NRTDiff, type NRTEvent, type NRTEventTarget, type NRTNavState, type NRTNode, type PlayerAction, type PlayerInstance, type PlayerOnEventSubscription, type PlayerStateDefinition, type PlayerTransitionDefinition, type PlayerWorkflowDefinition, type PureFormWorkflow, type RuntimeProfile, type ScenarioResult, StateMachine, type StateMachineConfig, type StateMachineEvent, type StateMachineListener, type StateNode, type StateType, type StepResult, type TestActionState, type TestAssertion, type TestInstance, type TestProgram, type TestProgramResult, type TestRunnerConfig, type TestScenario, type TestStep, type TransitionEdge, type TransitionResult, type Unsubscribe, type ValidationCategory, type ValidationIssue, type ValidationResult, type ValidationSeverity, type ValidatorOptions, WEB_FAILURE_POLICIES, analyzeDefinition, buildFunctionMap, clearExpressionCache, clearPatternCache, compareNRT, compile, compilePattern, compileTestProgram, compileTestScenario, countByKind, countNodes, createActionRecorder, createApiTestActions, createEmptyNRT, createEvaluator, createInProcessTestActions, detectIRVersion, findInteractiveNodes, findNode, findVisibleNodes, generateCoverageScenarios, getFinalState, getTransitionPath, hasTransition, isViableDefinition, matchTopic, needsMigration, normalizeCategory, normalizeDefinition, runBlueprintScenario, runBlueprintTestProgram, runScenario, runTestProgram, validateDefinition };
1522
+ export { type ActionDefinition, ActionDispatcher, type ActionHandler, type ActionHandlerFn, type ActionRecorder, type ActionResult, type ActionTick, type ActionTrace, type AnalysisResult, type AnalysisSummary, type ApiInstanceSnapshot, type ApiTestAdapter, type ApiTestRunnerConfig, type ApiTransitionResult, type AssertionResult, type BlueprintRequirements, type BlueprintRunnerConfig, type BusEvent, CORE_FUNCTIONS, CURRENT_IR_VERSION, type CompatibilityResult, type CompilationResult, type CompiledOutput, type CompilerError, type CompilerErrorCode, type Evaluator, type EvaluatorConfig, EventBus, type EventHandler, type EventSubscription, type ExpressionContext, type ExpressionDiagnostics, type ExpressionFunction, type ExpressionResult, type FailurePolicy, type FailurePolicyContext, type GraphPath, type IRActionDefinition, type IRActionMode, type IRApiDataSource, type IRBlueprintManifest, type IRConditionDefinition, type IRDataSource, type IRDuringAction, type IRExperienceDefinition, type IRExperienceNode, type IRFieldDefinition, type IRFieldValidation, type IRGrammarIsland, type IROnEventAction, type IROnEventSubscription, type IRRefDataSource, type IRRoleDefinition, type IRStateDefinition, type IRStateHome, type IRStateType, type IRStaticDataSource, type IRTransitionDefinition, type IRWorkflowDataSource, type IRWorkflowDefinition, type IRWorkflowFieldType, type MigrationResult, type NRT, type NRTChange, type NRTDiff, type NRTEvent, type NRTEventTarget, type NRTNavState, type NRTNode, type PlayerAction, type PlayerInstance, type PlayerManifest, type PlayerOnEventSubscription, type PlayerStateDefinition, type PlayerTransitionDefinition, type PlayerWorkflowDefinition, type PureFormWorkflow, type RuntimeProfile, type ScenarioResult, StateMachine, type StateMachineConfig, type StateMachineEvent, type StateMachineListener, type StateNode, type StateType, type StepResult, type TestActionState, type TestAssertion, type TestInstance, type TestProgram, type TestProgramResult, type TestRunnerConfig, type TestScenario, type TestStep, type TransitionEdge, type TransitionResult, type Unsubscribe, type ValidationCategory, type ValidationIssue, type ValidationResult, type ValidationSeverity, type ValidatorOptions, WEB_FAILURE_POLICIES, analyzeDefinition, buildFunctionMap, checkCompatibility, clearExpressionCache, clearPatternCache, compareNRT, compile, compilePattern, compileTestProgram, compileTestScenario, countByKind, countNodes, createActionRecorder, createApiTestActions, createEmptyNRT, createEvaluator, createInProcessTestActions, detectIRVersion, extractRequirements, findInteractiveNodes, findNode, findVisibleNodes, generateCoverageScenarios, getFinalState, getTransitionPath, hasTransition, isViableDefinition, matchTopic, needsMigration, normalizeCategory, normalizeDefinition, runBlueprintScenario, runBlueprintTestProgram, runScenario, runTestProgram, validateDefinition };
package/dist/index.d.ts CHANGED
@@ -360,6 +360,8 @@ declare class ActionDispatcher {
360
360
  execute(actions: ActionDefinition[], context: ExpressionContext, evaluator?: Evaluator): Promise<ActionResult[]>;
361
361
  /** Get count of registered handlers */
362
362
  get size(): number;
363
+ /** Get all registered action type names */
364
+ getRegisteredTypes(): string[];
363
365
  /** Remove all handlers */
364
366
  clear(): void;
365
367
  }
@@ -1039,6 +1041,8 @@ interface IRActionDefinition {
1039
1041
  mode: IRActionMode;
1040
1042
  config: Record<string, unknown>;
1041
1043
  condition?: string;
1044
+ /** Saga compensation: action to run if a subsequent action fails (Design 28). */
1045
+ compensate?: IRActionDefinition;
1042
1046
  }
1043
1047
  interface IRDuringAction {
1044
1048
  id: string;
@@ -1072,6 +1076,8 @@ interface IRStateDefinition {
1072
1076
  during: IRDuringAction[];
1073
1077
  on_exit: IRActionDefinition[];
1074
1078
  on_event?: IROnEventSubscription[];
1079
+ /** Where this state executes at runtime (server, client, worker, edge, any). */
1080
+ runtime?: string;
1075
1081
  }
1076
1082
  interface IRConditionDefinition {
1077
1083
  type?: string;
@@ -1092,6 +1098,8 @@ interface IRTransitionDefinition {
1092
1098
  roles?: string[];
1093
1099
  auto?: boolean;
1094
1100
  required_fields?: string[];
1101
+ /** Where this transition executes at runtime (server, client, worker, edge, any). */
1102
+ runtime?: string;
1095
1103
  }
1096
1104
  interface IRFieldValidation {
1097
1105
  min?: number;
@@ -1378,6 +1386,84 @@ declare function validateDefinition(def: IRWorkflowDefinition, options?: Validat
1378
1386
  */
1379
1387
  declare function isViableDefinition(def: unknown): def is IRWorkflowDefinition;
1380
1388
 
1389
+ /**
1390
+ * Player Capability Declaration & Compatibility Check (ISS-059)
1391
+ *
1392
+ * Each player runtime (web, iOS, console, TUI) declares its capabilities
1393
+ * via a PlayerManifest. When loading a blueprint, the compatibility checker
1394
+ * compares manifest against requirements to produce warnings/errors.
1395
+ *
1396
+ * This is informational, not blocking — players should still attempt to render.
1397
+ */
1398
+ /** Declares what a player runtime can render and execute. */
1399
+ interface PlayerManifest {
1400
+ /** Player identifier (e.g., "web", "ios", "console", "tui") */
1401
+ player: string;
1402
+ /** Player version */
1403
+ version: string;
1404
+ /** Supported atom component IDs */
1405
+ atoms: string[];
1406
+ /** Supported action types */
1407
+ actions: string[];
1408
+ /** Whether the player can evaluate expressions natively */
1409
+ expressions: boolean;
1410
+ /** Whether the player works offline */
1411
+ offline: boolean;
1412
+ }
1413
+ /** What a blueprint requires from a player to render correctly. */
1414
+ interface BlueprintRequirements {
1415
+ /** Atom component IDs used in the experience tree */
1416
+ atoms: string[];
1417
+ /** Action types referenced in transitions/states */
1418
+ actions: string[];
1419
+ /** Whether the blueprint uses expressions */
1420
+ expressions: boolean;
1421
+ }
1422
+ /** Result of comparing a PlayerManifest against BlueprintRequirements. */
1423
+ interface CompatibilityResult {
1424
+ /** Whether the player can render the blueprint without missing critical features */
1425
+ compatible: boolean;
1426
+ /** Atom component IDs the blueprint uses but the player doesn't support */
1427
+ missingAtoms: string[];
1428
+ /** Action types the blueprint references but the player can't handle */
1429
+ missingActions: string[];
1430
+ /** Human-readable warnings (non-blocking issues) */
1431
+ warnings: string[];
1432
+ }
1433
+ /**
1434
+ * Compare a player's capabilities against a blueprint's requirements.
1435
+ *
1436
+ * Missing atoms produce warnings (graceful degradation — render fallback).
1437
+ * Missing actions produce errors (may cause runtime failures).
1438
+ * The check is informational — players should still attempt to load.
1439
+ */
1440
+ declare function checkCompatibility(manifest: PlayerManifest, requirements: BlueprintRequirements): CompatibilityResult;
1441
+ /**
1442
+ * Walk a JSON experience tree and transition/state actions to extract
1443
+ * all atom component IDs and action types referenced.
1444
+ *
1445
+ * This mirrors the Rust `WorkflowDefinition::extract_requirements()`.
1446
+ */
1447
+ declare function extractRequirements(definition: {
1448
+ experience?: unknown;
1449
+ states?: Array<{
1450
+ on_enter?: Array<{
1451
+ action_type?: string;
1452
+ type?: string;
1453
+ }>;
1454
+ on_exit?: Array<{
1455
+ action_type?: string;
1456
+ type?: string;
1457
+ }>;
1458
+ }>;
1459
+ transitions?: Array<{
1460
+ actions?: Array<{
1461
+ action_type?: string;
1462
+ type?: string;
1463
+ }>;
1464
+ }>;
1465
+ }): BlueprintRequirements;
1466
+
1381
1467
  /**
1382
1468
  * DSL Compiler — entry point.
1383
1469
  *
@@ -1433,4 +1519,4 @@ declare function normalizeDefinition(def: Record<string, unknown>): MigrationRes
1433
1519
  */
1434
1520
  declare function needsMigration(def: Record<string, unknown>): boolean;
1435
1521
 
1436
- export { type ActionDefinition, ActionDispatcher, type ActionHandler, type ActionHandlerFn, type ActionRecorder, type ActionResult, type ActionTick, type ActionTrace, type AnalysisResult, type AnalysisSummary, type ApiInstanceSnapshot, type ApiTestAdapter, type ApiTestRunnerConfig, type ApiTransitionResult, type AssertionResult, type BlueprintRunnerConfig, type BusEvent, CORE_FUNCTIONS, CURRENT_IR_VERSION, type CompilationResult, type CompiledOutput, type CompilerError, type CompilerErrorCode, type Evaluator, type EvaluatorConfig, EventBus, type EventHandler, type EventSubscription, type ExpressionContext, type ExpressionDiagnostics, type ExpressionFunction, type ExpressionResult, type FailurePolicy, type FailurePolicyContext, type GraphPath, type IRActionDefinition, type IRActionMode, type IRApiDataSource, type IRBlueprintManifest, type IRConditionDefinition, type IRDataSource, type IRDuringAction, type IRExperienceDefinition, type IRExperienceNode, type IRFieldDefinition, type IRFieldValidation, type IRGrammarIsland, type IROnEventAction, type IROnEventSubscription, type IRRefDataSource, type IRRoleDefinition, type IRStateDefinition, type IRStateHome, type IRStateType, type IRStaticDataSource, type IRTransitionDefinition, type IRWorkflowDataSource, type IRWorkflowDefinition, type IRWorkflowFieldType, type MigrationResult, type NRT, type NRTChange, type NRTDiff, type NRTEvent, type NRTEventTarget, type NRTNavState, type NRTNode, type PlayerAction, type PlayerInstance, type PlayerOnEventSubscription, type PlayerStateDefinition, type PlayerTransitionDefinition, type PlayerWorkflowDefinition, type PureFormWorkflow, type RuntimeProfile, type ScenarioResult, StateMachine, type StateMachineConfig, type StateMachineEvent, type StateMachineListener, type StateNode, type StateType, type StepResult, type TestActionState, type TestAssertion, type TestInstance, type TestProgram, type TestProgramResult, type TestRunnerConfig, type TestScenario, type TestStep, type TransitionEdge, type TransitionResult, type Unsubscribe, type ValidationCategory, type ValidationIssue, type ValidationResult, type ValidationSeverity, type ValidatorOptions, WEB_FAILURE_POLICIES, analyzeDefinition, buildFunctionMap, clearExpressionCache, clearPatternCache, compareNRT, compile, compilePattern, compileTestProgram, compileTestScenario, countByKind, countNodes, createActionRecorder, createApiTestActions, createEmptyNRT, createEvaluator, createInProcessTestActions, detectIRVersion, findInteractiveNodes, findNode, findVisibleNodes, generateCoverageScenarios, getFinalState, getTransitionPath, hasTransition, isViableDefinition, matchTopic, needsMigration, normalizeCategory, normalizeDefinition, runBlueprintScenario, runBlueprintTestProgram, runScenario, runTestProgram, validateDefinition };
1522
+ export { type ActionDefinition, ActionDispatcher, type ActionHandler, type ActionHandlerFn, type ActionRecorder, type ActionResult, type ActionTick, type ActionTrace, type AnalysisResult, type AnalysisSummary, type ApiInstanceSnapshot, type ApiTestAdapter, type ApiTestRunnerConfig, type ApiTransitionResult, type AssertionResult, type BlueprintRequirements, type BlueprintRunnerConfig, type BusEvent, CORE_FUNCTIONS, CURRENT_IR_VERSION, type CompatibilityResult, type CompilationResult, type CompiledOutput, type CompilerError, type CompilerErrorCode, type Evaluator, type EvaluatorConfig, EventBus, type EventHandler, type EventSubscription, type ExpressionContext, type ExpressionDiagnostics, type ExpressionFunction, type ExpressionResult, type FailurePolicy, type FailurePolicyContext, type GraphPath, type IRActionDefinition, type IRActionMode, type IRApiDataSource, type IRBlueprintManifest, type IRConditionDefinition, type IRDataSource, type IRDuringAction, type IRExperienceDefinition, type IRExperienceNode, type IRFieldDefinition, type IRFieldValidation, type IRGrammarIsland, type IROnEventAction, type IROnEventSubscription, type IRRefDataSource, type IRRoleDefinition, type IRStateDefinition, type IRStateHome, type IRStateType, type IRStaticDataSource, type IRTransitionDefinition, type IRWorkflowDataSource, type IRWorkflowDefinition, type IRWorkflowFieldType, type MigrationResult, type NRT, type NRTChange, type NRTDiff, type NRTEvent, type NRTEventTarget, type NRTNavState, type NRTNode, type PlayerAction, type PlayerInstance, type PlayerManifest, type PlayerOnEventSubscription, type PlayerStateDefinition, type PlayerTransitionDefinition, type PlayerWorkflowDefinition, type PureFormWorkflow, type RuntimeProfile, type ScenarioResult, StateMachine, type StateMachineConfig, type StateMachineEvent, type StateMachineListener, type StateNode, type StateType, type StepResult, type TestActionState, type TestAssertion, type TestInstance, type TestProgram, type TestProgramResult, type TestRunnerConfig, type TestScenario, type TestStep, type TransitionEdge, type TransitionResult, type Unsubscribe, type ValidationCategory, type ValidationIssue, type ValidationResult, type ValidationSeverity, type ValidatorOptions, WEB_FAILURE_POLICIES, analyzeDefinition, buildFunctionMap, checkCompatibility, clearExpressionCache, clearPatternCache, compareNRT, compile, compilePattern, compileTestProgram, compileTestScenario, countByKind, countNodes, createActionRecorder, createApiTestActions, createEmptyNRT, createEvaluator, createInProcessTestActions, detectIRVersion, extractRequirements, findInteractiveNodes, findNode, findVisibleNodes, generateCoverageScenarios, getFinalState, getTransitionPath, hasTransition, isViableDefinition, matchTopic, needsMigration, normalizeCategory, normalizeDefinition, runBlueprintScenario, runBlueprintTestProgram, runScenario, runTestProgram, validateDefinition };
package/dist/index.js CHANGED
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  WEB_FAILURE_POLICIES: () => WEB_FAILURE_POLICIES,
29
29
  analyzeDefinition: () => analyzeDefinition,
30
30
  buildFunctionMap: () => buildFunctionMap,
31
+ checkCompatibility: () => checkCompatibility,
31
32
  clearExpressionCache: () => clearExpressionCache,
32
33
  clearPatternCache: () => clearPatternCache,
33
34
  compareNRT: () => compareNRT,
@@ -43,6 +44,7 @@ __export(index_exports, {
43
44
  createEvaluator: () => createEvaluator,
44
45
  createInProcessTestActions: () => createInProcessTestActions,
45
46
  detectIRVersion: () => detectIRVersion,
47
+ extractRequirements: () => extractRequirements,
46
48
  findInteractiveNodes: () => findInteractiveNodes,
47
49
  findNode: () => findNode,
48
50
  findVisibleNodes: () => findVisibleNodes,
@@ -1137,8 +1139,8 @@ var ActionDispatcher = class {
1137
1139
  }
1138
1140
  const handler = this.handlers.get(action.type);
1139
1141
  if (!handler) {
1140
- console.warn(`[player-core] No handler registered for action type "${action.type}"`);
1141
- results.push({ type: action.type, success: false, error: `No handler for "${action.type}"` });
1142
+ console.warn(`[player-core] No handler registered for action type "${action.type}" \u2014 unsupported action`);
1143
+ results.push({ type: action.type, success: false, error: `unsupported action: "${action.type}"` });
1142
1144
  continue;
1143
1145
  }
1144
1146
  try {
@@ -1156,6 +1158,10 @@ var ActionDispatcher = class {
1156
1158
  get size() {
1157
1159
  return this.handlers.size;
1158
1160
  }
1161
+ /** Get all registered action type names */
1162
+ getRegisteredTypes() {
1163
+ return Array.from(this.handlers.keys());
1164
+ }
1159
1165
  /** Remove all handlers */
1160
1166
  clear() {
1161
1167
  this.handlers.clear();
@@ -3155,6 +3161,77 @@ function isViableDefinition(def) {
3155
3161
  return typeof d.slug === "string" && Array.isArray(d.states) && d.states.length > 0 && Array.isArray(d.transitions) && Array.isArray(d.fields);
3156
3162
  }
3157
3163
 
3164
+ // src/capabilities.ts
3165
+ function checkCompatibility(manifest, requirements) {
3166
+ const manifestAtomSet = new Set(manifest.atoms);
3167
+ const manifestActionSet = new Set(manifest.actions);
3168
+ const missingAtoms = requirements.atoms.filter((a) => !manifestAtomSet.has(a));
3169
+ const missingActions = requirements.actions.filter((a) => !manifestActionSet.has(a));
3170
+ const warnings = [];
3171
+ if (missingAtoms.length > 0) {
3172
+ warnings.push(
3173
+ `Player "${manifest.player}" is missing ${missingAtoms.length} atom(s): ${missingAtoms.join(", ")}. These components will render as fallbacks.`
3174
+ );
3175
+ }
3176
+ if (missingActions.length > 0) {
3177
+ warnings.push(
3178
+ `Player "${manifest.player}" is missing ${missingActions.length} action type(s): ${missingActions.join(", ")}. These actions will fail at runtime.`
3179
+ );
3180
+ }
3181
+ if (requirements.expressions && !manifest.expressions) {
3182
+ warnings.push(
3183
+ `Blueprint uses expressions but player "${manifest.player}" has no expression engine. Bindings and conditions will not evaluate.`
3184
+ );
3185
+ }
3186
+ const compatible = missingActions.length === 0 && !(requirements.expressions && !manifest.expressions);
3187
+ return { compatible, missingAtoms, missingActions, warnings };
3188
+ }
3189
+ function extractRequirements(definition) {
3190
+ const atoms = /* @__PURE__ */ new Set();
3191
+ const actions = /* @__PURE__ */ new Set();
3192
+ let expressions = false;
3193
+ if (definition.experience) {
3194
+ walkTree(definition.experience, atoms, (v) => {
3195
+ expressions = expressions || v;
3196
+ });
3197
+ }
3198
+ for (const t of definition.transitions ?? []) {
3199
+ for (const a of t.actions ?? []) {
3200
+ const type = a.action_type ?? a.type;
3201
+ if (type) actions.add(type);
3202
+ }
3203
+ }
3204
+ for (const s of definition.states ?? []) {
3205
+ for (const a of s.on_enter ?? []) {
3206
+ const type = a.action_type ?? a.type;
3207
+ if (type) actions.add(type);
3208
+ }
3209
+ for (const a of s.on_exit ?? []) {
3210
+ const type = a.action_type ?? a.type;
3211
+ if (type) actions.add(type);
3212
+ }
3213
+ }
3214
+ return {
3215
+ atoms: Array.from(atoms).sort(),
3216
+ actions: Array.from(actions).sort(),
3217
+ expressions
3218
+ };
3219
+ }
3220
+ function walkTree(node, atoms, setExpressions) {
3221
+ if (Array.isArray(node)) {
3222
+ for (const item of node) walkTree(item, atoms, setExpressions);
3223
+ return;
3224
+ }
3225
+ if (node && typeof node === "object") {
3226
+ const obj = node;
3227
+ if (typeof obj.component === "string") atoms.add(obj.component);
3228
+ if (obj.bindings || obj.condition || obj.when) setExpressions(true);
3229
+ if (obj.children) walkTree(obj.children, atoms, setExpressions);
3230
+ if (obj.routes) walkTree(obj.routes, atoms, setExpressions);
3231
+ if (obj.view) walkTree(obj.view, atoms, setExpressions);
3232
+ }
3233
+ }
3234
+
3158
3235
  // src/dsl/lexer.ts
3159
3236
  var SECTION_KEYWORDS = /* @__PURE__ */ new Set([
3160
3237
  "things",
@@ -4793,6 +4870,7 @@ function needsMigration(def) {
4793
4870
  WEB_FAILURE_POLICIES,
4794
4871
  analyzeDefinition,
4795
4872
  buildFunctionMap,
4873
+ checkCompatibility,
4796
4874
  clearExpressionCache,
4797
4875
  clearPatternCache,
4798
4876
  compareNRT,
@@ -4808,6 +4886,7 @@ function needsMigration(def) {
4808
4886
  createEvaluator,
4809
4887
  createInProcessTestActions,
4810
4888
  detectIRVersion,
4889
+ extractRequirements,
4811
4890
  findInteractiveNodes,
4812
4891
  findNode,
4813
4892
  findVisibleNodes,
package/dist/index.mjs CHANGED
@@ -1072,8 +1072,8 @@ var ActionDispatcher = class {
1072
1072
  }
1073
1073
  const handler = this.handlers.get(action.type);
1074
1074
  if (!handler) {
1075
- console.warn(`[player-core] No handler registered for action type "${action.type}"`);
1076
- results.push({ type: action.type, success: false, error: `No handler for "${action.type}"` });
1075
+ console.warn(`[player-core] No handler registered for action type "${action.type}" \u2014 unsupported action`);
1076
+ results.push({ type: action.type, success: false, error: `unsupported action: "${action.type}"` });
1077
1077
  continue;
1078
1078
  }
1079
1079
  try {
@@ -1091,6 +1091,10 @@ var ActionDispatcher = class {
1091
1091
  get size() {
1092
1092
  return this.handlers.size;
1093
1093
  }
1094
+ /** Get all registered action type names */
1095
+ getRegisteredTypes() {
1096
+ return Array.from(this.handlers.keys());
1097
+ }
1094
1098
  /** Remove all handlers */
1095
1099
  clear() {
1096
1100
  this.handlers.clear();
@@ -3090,6 +3094,77 @@ function isViableDefinition(def) {
3090
3094
  return typeof d.slug === "string" && Array.isArray(d.states) && d.states.length > 0 && Array.isArray(d.transitions) && Array.isArray(d.fields);
3091
3095
  }
3092
3096
 
3097
+ // src/capabilities.ts
3098
+ function checkCompatibility(manifest, requirements) {
3099
+ const manifestAtomSet = new Set(manifest.atoms);
3100
+ const manifestActionSet = new Set(manifest.actions);
3101
+ const missingAtoms = requirements.atoms.filter((a) => !manifestAtomSet.has(a));
3102
+ const missingActions = requirements.actions.filter((a) => !manifestActionSet.has(a));
3103
+ const warnings = [];
3104
+ if (missingAtoms.length > 0) {
3105
+ warnings.push(
3106
+ `Player "${manifest.player}" is missing ${missingAtoms.length} atom(s): ${missingAtoms.join(", ")}. These components will render as fallbacks.`
3107
+ );
3108
+ }
3109
+ if (missingActions.length > 0) {
3110
+ warnings.push(
3111
+ `Player "${manifest.player}" is missing ${missingActions.length} action type(s): ${missingActions.join(", ")}. These actions will fail at runtime.`
3112
+ );
3113
+ }
3114
+ if (requirements.expressions && !manifest.expressions) {
3115
+ warnings.push(
3116
+ `Blueprint uses expressions but player "${manifest.player}" has no expression engine. Bindings and conditions will not evaluate.`
3117
+ );
3118
+ }
3119
+ const compatible = missingActions.length === 0 && !(requirements.expressions && !manifest.expressions);
3120
+ return { compatible, missingAtoms, missingActions, warnings };
3121
+ }
3122
+ function extractRequirements(definition) {
3123
+ const atoms = /* @__PURE__ */ new Set();
3124
+ const actions = /* @__PURE__ */ new Set();
3125
+ let expressions = false;
3126
+ if (definition.experience) {
3127
+ walkTree(definition.experience, atoms, (v) => {
3128
+ expressions = expressions || v;
3129
+ });
3130
+ }
3131
+ for (const t of definition.transitions ?? []) {
3132
+ for (const a of t.actions ?? []) {
3133
+ const type = a.action_type ?? a.type;
3134
+ if (type) actions.add(type);
3135
+ }
3136
+ }
3137
+ for (const s of definition.states ?? []) {
3138
+ for (const a of s.on_enter ?? []) {
3139
+ const type = a.action_type ?? a.type;
3140
+ if (type) actions.add(type);
3141
+ }
3142
+ for (const a of s.on_exit ?? []) {
3143
+ const type = a.action_type ?? a.type;
3144
+ if (type) actions.add(type);
3145
+ }
3146
+ }
3147
+ return {
3148
+ atoms: Array.from(atoms).sort(),
3149
+ actions: Array.from(actions).sort(),
3150
+ expressions
3151
+ };
3152
+ }
3153
+ function walkTree(node, atoms, setExpressions) {
3154
+ if (Array.isArray(node)) {
3155
+ for (const item of node) walkTree(item, atoms, setExpressions);
3156
+ return;
3157
+ }
3158
+ if (node && typeof node === "object") {
3159
+ const obj = node;
3160
+ if (typeof obj.component === "string") atoms.add(obj.component);
3161
+ if (obj.bindings || obj.condition || obj.when) setExpressions(true);
3162
+ if (obj.children) walkTree(obj.children, atoms, setExpressions);
3163
+ if (obj.routes) walkTree(obj.routes, atoms, setExpressions);
3164
+ if (obj.view) walkTree(obj.view, atoms, setExpressions);
3165
+ }
3166
+ }
3167
+
3093
3168
  // src/dsl/lexer.ts
3094
3169
  var SECTION_KEYWORDS = /* @__PURE__ */ new Set([
3095
3170
  "things",
@@ -4727,6 +4802,7 @@ export {
4727
4802
  WEB_FAILURE_POLICIES,
4728
4803
  analyzeDefinition,
4729
4804
  buildFunctionMap,
4805
+ checkCompatibility,
4730
4806
  clearExpressionCache,
4731
4807
  clearPatternCache,
4732
4808
  compareNRT,
@@ -4742,6 +4818,7 @@ export {
4742
4818
  createEvaluator,
4743
4819
  createInProcessTestActions,
4744
4820
  detectIRVersion,
4821
+ extractRequirements,
4745
4822
  findInteractiveNodes,
4746
4823
  findNode,
4747
4824
  findVisibleNodes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmapp/player-core",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.10",
4
4
  "description": "Framework-agnostic workflow engine for browser-side state machines, expression evaluation, and event-driven reactions",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -18,7 +18,8 @@
18
18
  "test": "vitest run",
19
19
  "test:watch": "vitest --watch",
20
20
  "test:coverage": "vitest --coverage",
21
- "type-check": "tsc --noEmit"
21
+ "type-check": "tsc --noEmit",
22
+ "publish:alpha": "cd ../.. && ./scripts/publish-npm.sh"
22
23
  },
23
24
  "keywords": [
24
25
  "workflow",
@@ -1,35 +0,0 @@
1
- {
2
- "name": "@mmapp/player-core",
3
- "version": "0.1.0-alpha.1",
4
- "description": "Framework-agnostic workflow engine for browser-side state machines, expression evaluation, and event-driven reactions",
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
- },
15
- "scripts": {
16
- "build": "tsup src/index.ts --format cjs,esm --dts",
17
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
18
- "test": "vitest run",
19
- "test:watch": "vitest --watch",
20
- "test:coverage": "vitest --coverage",
21
- "type-check": "tsc --noEmit"
22
- },
23
- "keywords": [
24
- "workflow",
25
- "state-machine",
26
- "expression-engine",
27
- "player",
28
- "reactive"
29
- ],
30
- "author": "MindMatrix Team",
31
- "license": "MIT",
32
- "publishConfig": {
33
- "access": "public"
34
- }
35
- }