@motiadev/workbench 0.8.2-beta.140-628177 → 0.8.2-beta.140-111855

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 (142) hide show
  1. package/dist/components.json +1 -1
  2. package/dist/index.d.ts +7 -7
  3. package/dist/index.js +5 -5
  4. package/dist/middleware.d.ts +1 -1
  5. package/dist/middleware.js +3 -3
  6. package/dist/motia-plugin/__tests__/generator.test.js +97 -0
  7. package/dist/motia-plugin/__tests__/resolver.test.d.ts +1 -0
  8. package/dist/motia-plugin/__tests__/resolver.test.js +64 -0
  9. package/dist/motia-plugin/__tests__/validator.test.d.ts +1 -0
  10. package/dist/motia-plugin/__tests__/validator.test.js +59 -0
  11. package/dist/motia-plugin/generator.d.ts +78 -0
  12. package/dist/motia-plugin/generator.js +128 -0
  13. package/dist/motia-plugin/hmr.d.ts +19 -0
  14. package/dist/motia-plugin/hmr.js +66 -0
  15. package/dist/motia-plugin/index.d.ts +27 -0
  16. package/dist/motia-plugin/index.js +118 -0
  17. package/dist/motia-plugin/resolver.d.ts +63 -0
  18. package/dist/motia-plugin/resolver.js +92 -0
  19. package/dist/motia-plugin/types.d.ts +169 -0
  20. package/dist/motia-plugin/types.js +36 -0
  21. package/dist/motia-plugin/utils.d.ts +57 -0
  22. package/dist/motia-plugin/utils.js +75 -0
  23. package/dist/motia-plugin/validator.d.ts +19 -0
  24. package/dist/motia-plugin/validator.js +163 -0
  25. package/dist/postcss.config.mjs +1 -1
  26. package/dist/src/App.d.ts +1 -1
  27. package/dist/src/App.js +1 -18
  28. package/dist/src/components/flow/base-edge.d.ts +2 -2
  29. package/dist/src/components/flow/base-edge.js +1 -1
  30. package/dist/src/components/flow/flow-page.js +2 -2
  31. package/dist/src/components/flow/flow-tab-menu-item.js +2 -2
  32. package/dist/src/components/flow/flow-view.d.ts +3 -3
  33. package/dist/src/components/flow/hooks/use-get-flow-state.d.ts +2 -2
  34. package/dist/src/components/flow/hooks/use-get-flow-state.js +0 -4
  35. package/dist/src/components/flow/hooks/use-save-workflow-config.d.ts +1 -1
  36. package/dist/src/components/flow/node-organizer.d.ts +3 -3
  37. package/dist/src/components/flow/nodes/api-flow-node.d.ts +1 -1
  38. package/dist/src/components/flow/nodes/cron-flow-node.d.ts +1 -1
  39. package/dist/src/components/flow/nodes/event-flow-node.d.ts +1 -1
  40. package/dist/src/components/flow/nodes/noop-flow-node.d.ts +1 -1
  41. package/dist/src/components/header/deploy-button.js +2 -2
  42. package/dist/src/components/header/header.d.ts +1 -1
  43. package/dist/src/components/header/header.js +2 -2
  44. package/dist/src/components/root-motia.d.ts +2 -1
  45. package/dist/src/components/tutorial/engine/tutorial-engine.d.ts +1 -1
  46. package/dist/src/components/tutorial/hooks/use-tutorial-engine.d.ts +1 -1
  47. package/dist/src/components/tutorial/hooks/use-tutorial.d.ts +1 -1
  48. package/dist/src/components/tutorial/tutorial-button.d.ts +1 -1
  49. package/dist/src/components/tutorial/tutorial-button.js +1 -1
  50. package/dist/src/components/tutorial/tutorial-step.d.ts +2 -2
  51. package/dist/src/components/tutorial/tutorial-step.js +1 -1
  52. package/dist/src/components/tutorial/tutorial.css +8 -8
  53. package/dist/src/components/ui/json-editor.d.ts +1 -1
  54. package/dist/src/components/ui/json-editor.js +1 -1
  55. package/dist/src/components/ui/table.js +1 -1
  56. package/dist/src/components/ui/theme-toggle.d.ts +1 -1
  57. package/dist/src/components/ui/tooltip.d.ts +1 -1
  58. package/dist/src/hooks/use-fetch-flows.js +1 -1
  59. package/dist/src/hooks/use-update-handle-positions.d.ts +1 -1
  60. package/dist/src/index.css +5 -5
  61. package/dist/src/lib/plugins.js +3 -3
  62. package/dist/src/main.js +2 -3
  63. package/dist/src/project-view-mode.js +1 -1
  64. package/dist/src/publicComponents/api-node.d.ts +2 -2
  65. package/dist/src/publicComponents/base-node/base-handle.d.ts +3 -2
  66. package/dist/src/publicComponents/base-node/base-node.d.ts +3 -2
  67. package/dist/src/publicComponents/base-node/base-node.js +1 -1
  68. package/dist/src/publicComponents/base-node/code-display.d.ts +2 -2
  69. package/dist/src/publicComponents/base-node/code-display.js +1 -1
  70. package/dist/src/publicComponents/base-node/emits.d.ts +2 -2
  71. package/dist/src/publicComponents/base-node/feature-card.d.ts +2 -2
  72. package/dist/src/publicComponents/base-node/language-indicator.d.ts +2 -2
  73. package/dist/src/publicComponents/base-node/node-header.d.ts +3 -2
  74. package/dist/src/publicComponents/base-node/node-sidebar.d.ts +2 -2
  75. package/dist/src/publicComponents/base-node/subscribe.d.ts +1 -1
  76. package/dist/src/publicComponents/cron-node.d.ts +3 -2
  77. package/dist/src/publicComponents/event-node.d.ts +3 -2
  78. package/dist/src/publicComponents/node-props.d.ts +1 -1
  79. package/dist/src/publicComponents/noop-node.d.ts +3 -2
  80. package/dist/src/stores/use-global-store.d.ts +0 -6
  81. package/dist/src/stores/use-global-store.js +0 -6
  82. package/dist/src/types/flow.d.ts +1 -1
  83. package/dist/tsconfig.app.tsbuildinfo +1 -1
  84. package/dist/tsconfig.node.tsbuildinfo +1 -1
  85. package/motia-plugin/__tests__/generator.test.ts +129 -0
  86. package/motia-plugin/__tests__/resolver.test.ts +82 -0
  87. package/motia-plugin/__tests__/validator.test.ts +71 -0
  88. package/motia-plugin/generator.ts +130 -0
  89. package/motia-plugin/hmr.ts +78 -0
  90. package/motia-plugin/index.ts +143 -0
  91. package/motia-plugin/resolver.ts +96 -0
  92. package/motia-plugin/types.ts +198 -0
  93. package/motia-plugin/utils.ts +70 -0
  94. package/motia-plugin/validator.ts +197 -0
  95. package/package.json +9 -9
  96. package/postcss.config.mjs +1 -1
  97. package/dist/src/components/observability/events/code/function-call.d.ts +0 -13
  98. package/dist/src/components/observability/events/code/function-call.js +0 -16
  99. package/dist/src/components/observability/events/event-icon.d.ts +0 -7
  100. package/dist/src/components/observability/events/event-icon.js +0 -16
  101. package/dist/src/components/observability/events/trace-emit-event.d.ts +0 -5
  102. package/dist/src/components/observability/events/trace-emit-event.js +0 -5
  103. package/dist/src/components/observability/events/trace-event.d.ts +0 -5
  104. package/dist/src/components/observability/events/trace-event.js +0 -20
  105. package/dist/src/components/observability/events/trace-log-event.d.ts +0 -5
  106. package/dist/src/components/observability/events/trace-log-event.js +0 -5
  107. package/dist/src/components/observability/events/trace-state-event.d.ts +0 -5
  108. package/dist/src/components/observability/events/trace-state-event.js +0 -5
  109. package/dist/src/components/observability/events/trace-stream-event.d.ts +0 -5
  110. package/dist/src/components/observability/events/trace-stream-event.js +0 -5
  111. package/dist/src/components/observability/hooks/use-get-endtime.d.ts +0 -2
  112. package/dist/src/components/observability/hooks/use-get-endtime.js +0 -15
  113. package/dist/src/components/observability/trace-item/trace-item-detail.d.ts +0 -8
  114. package/dist/src/components/observability/trace-item/trace-item-detail.js +0 -10
  115. package/dist/src/components/observability/trace-item/trace-item.d.ts +0 -10
  116. package/dist/src/components/observability/trace-item/trace-item.js +0 -14
  117. package/dist/src/components/observability/trace-status.d.ts +0 -8
  118. package/dist/src/components/observability/trace-status.js +0 -18
  119. package/dist/src/components/observability/trace-tab-label.d.ts +0 -1
  120. package/dist/src/components/observability/trace-tab-label.js +0 -5
  121. package/dist/src/components/observability/trace-timeline.d.ts +0 -6
  122. package/dist/src/components/observability/trace-timeline.js +0 -30
  123. package/dist/src/components/observability/traces-groups.d.ts +0 -9
  124. package/dist/src/components/observability/traces-groups.js +0 -9
  125. package/dist/src/components/observability/traces-page.d.ts +0 -1
  126. package/dist/src/components/observability/traces-page.js +0 -33
  127. package/dist/src/components/states/hooks/states-hooks.d.ts +0 -13
  128. package/dist/src/components/states/hooks/states-hooks.js +0 -26
  129. package/dist/src/components/states/state-details.d.ts +0 -7
  130. package/dist/src/components/states/state-details.js +0 -3
  131. package/dist/src/components/states/state-editor.d.ts +0 -7
  132. package/dist/src/components/states/state-editor.js +0 -71
  133. package/dist/src/components/states/state-sidebar.d.ts +0 -8
  134. package/dist/src/components/states/state-sidebar.js +0 -17
  135. package/dist/src/components/states/state-tab-label.d.ts +0 -1
  136. package/dist/src/components/states/state-tab-label.js +0 -5
  137. package/dist/src/components/states/states-page.d.ts +0 -1
  138. package/dist/src/components/states/states-page.js +0 -56
  139. package/dist/src/types/observability.d.ts +0 -78
  140. package/dist/vite-plugin-motia-plugins.d.ts +0 -9
  141. package/dist/vite-plugin-motia-plugins.js +0 -69
  142. /package/dist/{src/types/observability.js → motia-plugin/__tests__/generator.test.d.ts} +0 -0
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = motiaPluginsPlugin;
4
+ const generator_1 = require("./generator");
5
+ const hmr_1 = require("./hmr");
6
+ const resolver_1 = require("./resolver");
7
+ const types_1 = require("./types");
8
+ const utils_1 = require("./utils");
9
+ const validator_1 = require("./validator");
10
+ /**
11
+ * Vite plugin for loading and managing Motia workbench plugins.
12
+ *
13
+ * Features:
14
+ * - Hot Module Replacement (HMR) support
15
+ * - Runtime validation with detailed error messages
16
+ * - Verbose logging for debugging
17
+ * - CSS injection for plugin styles
18
+ *
19
+ * @param plugins - Array of plugin configurations
20
+ * @param options - Optional loader configuration
21
+ * @returns Vite plugin instance
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * export default defineConfig({
26
+ * plugins: [
27
+ * motiaPluginsPlugin([
28
+ * { packageName: '@my-org/plugin', label: 'My Plugin' }
29
+ * ])
30
+ * ]
31
+ * })
32
+ * ```
33
+ */
34
+ function motiaPluginsPlugin(plugins) {
35
+ let devServer = null;
36
+ try {
37
+ const validationResult = (0, validator_1.validatePlugins)(plugins, {
38
+ failFast: false,
39
+ });
40
+ if (!validationResult.valid) {
41
+ console.error('[motia-plugins] Plugin configuration validation failed:');
42
+ validationResult.errors.forEach((err) => console.error(`[motia-plugins] ${err}`));
43
+ throw new Error('Invalid plugin configuration. See errors above.');
44
+ }
45
+ if (validationResult.warnings.length > 0) {
46
+ validationResult.warnings.forEach((warning) => console.warn('[motia-plugins]', warning));
47
+ }
48
+ }
49
+ catch (error) {
50
+ console.error('[motia-plugins] Failed to validate plugins:', error);
51
+ throw error;
52
+ }
53
+ const alias = (0, resolver_1.createAliasConfig)(plugins);
54
+ console.log(`[motia-plugins] Initialized with ${plugins.length} plugin(s)`);
55
+ return {
56
+ name: 'vite-plugin-motia-plugins',
57
+ enforce: 'pre',
58
+ buildStart() {
59
+ console.log('[motia-plugins] Build started');
60
+ },
61
+ config: () => ({
62
+ resolve: {
63
+ alias,
64
+ },
65
+ }),
66
+ configureServer(server) {
67
+ devServer = server;
68
+ console.log('[motia-plugins] Dev server configured, HMR enabled');
69
+ },
70
+ resolveId(id) {
71
+ if (id === types_1.CONSTANTS.VIRTUAL_MODULE_ID) {
72
+ return types_1.CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID;
73
+ }
74
+ },
75
+ load(id) {
76
+ if (id !== types_1.CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID) {
77
+ return null;
78
+ }
79
+ console.log('[motia-plugins] Loading plugins virtual module');
80
+ console.log('[motia-plugins] Generating plugin code...');
81
+ const code = (0, generator_1.generatePluginCode)(plugins);
82
+ if (!(0, generator_1.isValidCode)(code)) {
83
+ console.error('[motia-plugins] Generated code is invalid or empty');
84
+ return 'export const plugins = []';
85
+ }
86
+ console.log('[motia-plugins] Plugin code generated successfully');
87
+ return code;
88
+ },
89
+ async transform(code, id) {
90
+ const normalizedId = (0, utils_1.normalizePath)(id);
91
+ if (!normalizedId.endsWith('/workbench/src/index.css')) {
92
+ return null;
93
+ }
94
+ console.log('[motia-plugins] Injecting plugin CSS imports');
95
+ const cssImports = (0, generator_1.generateCssImports)(plugins);
96
+ if (!cssImports) {
97
+ return null;
98
+ }
99
+ return {
100
+ code: `${cssImports}\n${code}`,
101
+ map: null,
102
+ };
103
+ },
104
+ handleHotUpdate(ctx) {
105
+ if (!devServer) {
106
+ return;
107
+ }
108
+ const modulesToUpdate = (0, hmr_1.handlePluginHotUpdate)(ctx, plugins);
109
+ if (modulesToUpdate) {
110
+ console.log('[motia-plugins] Hot reloaded plugins');
111
+ return modulesToUpdate;
112
+ }
113
+ },
114
+ buildEnd() {
115
+ console.log('[motia-plugins] Build ended');
116
+ },
117
+ };
118
+ }
@@ -0,0 +1,63 @@
1
+ import type { ResolvedPackage, WorkbenchPlugin } from './types';
2
+ /**
3
+ * Resolves a plugin package to its absolute path and creates an alias.
4
+ *
5
+ * @param plugin - The plugin configuration to resolve
6
+ * @returns Resolved package information including path and alias
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * // Local plugin
11
+ * resolvePluginPackage({ packageName: '~/plugins/my-plugin' })
12
+ * // Returns: {
13
+ * // packageName: '~/plugins/my-plugin',
14
+ * // resolvedPath: '/Users/project/plugins/my-plugin',
15
+ * // isLocal: true,
16
+ * // alias: '~/plugins/my-plugin'
17
+ * // }
18
+ *
19
+ * // NPM package
20
+ * resolvePluginPackage({ packageName: '@org/plugin' })
21
+ * // Returns: {
22
+ * // packageName: '@org/plugin',
23
+ * // resolvedPath: '/Users/project/node_modules/@org/plugin',
24
+ * // isLocal: false,
25
+ * // alias: '@org/plugin'
26
+ * // }
27
+ * ```
28
+ */
29
+ export declare function resolvePluginPackage(plugin: WorkbenchPlugin): ResolvedPackage;
30
+ /**
31
+ * Resolves all plugin packages and creates a Vite alias configuration.
32
+ *
33
+ * @param plugins - Array of plugin configurations
34
+ * @returns Vite alias configuration object
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const plugins = [
39
+ * { packageName: '~/plugins/local' },
40
+ * { packageName: '@org/npm-plugin' }
41
+ * ]
42
+ * const aliases = createAliasConfig(plugins)
43
+ * // Returns: {
44
+ * // '~/plugins/local': '/Users/project/plugins/local',
45
+ * // '@org/npm-plugin': '/Users/project/node_modules/@org/npm-plugin'
46
+ * // }
47
+ * ```
48
+ */
49
+ export declare function createAliasConfig(plugins: WorkbenchPlugin[]): Record<string, string>;
50
+ /**
51
+ * Resolves all plugins and returns their resolved package information.
52
+ *
53
+ * @param plugins - Array of plugin configurations
54
+ * @returns Array of resolved package information
55
+ */
56
+ export declare function resolveAllPlugins(plugins: WorkbenchPlugin[]): ResolvedPackage[];
57
+ /**
58
+ * Gets the unique set of package names from plugins.
59
+ *
60
+ * @param plugins - Array of plugin configurations
61
+ * @returns Array of unique package names
62
+ */
63
+ export declare function getUniquePackageNames(plugins: WorkbenchPlugin[]): string[];
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvePluginPackage = resolvePluginPackage;
4
+ exports.createAliasConfig = createAliasConfig;
5
+ exports.resolveAllPlugins = resolveAllPlugins;
6
+ exports.getUniquePackageNames = getUniquePackageNames;
7
+ const utils_1 = require("./utils");
8
+ /**
9
+ * Resolves a plugin package to its absolute path and creates an alias.
10
+ *
11
+ * @param plugin - The plugin configuration to resolve
12
+ * @returns Resolved package information including path and alias
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // Local plugin
17
+ * resolvePluginPackage({ packageName: '~/plugins/my-plugin' })
18
+ * // Returns: {
19
+ * // packageName: '~/plugins/my-plugin',
20
+ * // resolvedPath: '/Users/project/plugins/my-plugin',
21
+ * // isLocal: true,
22
+ * // alias: '~/plugins/my-plugin'
23
+ * // }
24
+ *
25
+ * // NPM package
26
+ * resolvePluginPackage({ packageName: '@org/plugin' })
27
+ * // Returns: {
28
+ * // packageName: '@org/plugin',
29
+ * // resolvedPath: '/Users/project/node_modules/@org/plugin',
30
+ * // isLocal: false,
31
+ * // alias: '@org/plugin'
32
+ * // }
33
+ * ```
34
+ */
35
+ function resolvePluginPackage(plugin) {
36
+ const { packageName } = plugin;
37
+ const local = (0, utils_1.isLocalPlugin)(packageName);
38
+ const resolvedPath = local ? (0, utils_1.resolveLocalPath)(packageName) : (0, utils_1.resolveNpmPath)(packageName);
39
+ return {
40
+ packageName,
41
+ resolvedPath: (0, utils_1.normalizePath)(resolvedPath),
42
+ isLocal: local,
43
+ alias: packageName,
44
+ };
45
+ }
46
+ /**
47
+ * Resolves all plugin packages and creates a Vite alias configuration.
48
+ *
49
+ * @param plugins - Array of plugin configurations
50
+ * @returns Vite alias configuration object
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const plugins = [
55
+ * { packageName: '~/plugins/local' },
56
+ * { packageName: '@org/npm-plugin' }
57
+ * ]
58
+ * const aliases = createAliasConfig(plugins)
59
+ * // Returns: {
60
+ * // '~/plugins/local': '/Users/project/plugins/local',
61
+ * // '@org/npm-plugin': '/Users/project/node_modules/@org/npm-plugin'
62
+ * // }
63
+ * ```
64
+ */
65
+ function createAliasConfig(plugins) {
66
+ // Get unique package names to avoid duplicate aliases
67
+ const uniquePackages = Array.from(new Set(plugins.map((p) => p.packageName)));
68
+ const aliases = {};
69
+ for (const packageName of uniquePackages) {
70
+ const resolved = resolvePluginPackage({ packageName });
71
+ aliases[packageName] = resolved.resolvedPath;
72
+ }
73
+ return aliases;
74
+ }
75
+ /**
76
+ * Resolves all plugins and returns their resolved package information.
77
+ *
78
+ * @param plugins - Array of plugin configurations
79
+ * @returns Array of resolved package information
80
+ */
81
+ function resolveAllPlugins(plugins) {
82
+ return plugins.map((plugin) => resolvePluginPackage(plugin));
83
+ }
84
+ /**
85
+ * Gets the unique set of package names from plugins.
86
+ *
87
+ * @param plugins - Array of plugin configurations
88
+ * @returns Array of unique package names
89
+ */
90
+ function getUniquePackageNames(plugins) {
91
+ return Array.from(new Set(plugins.map((p) => p.packageName)));
92
+ }
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Configuration for a single workbench plugin.
3
+ * This interface defines how plugins are registered and configured in the Motia workbench.
4
+ */
5
+ export interface WorkbenchPlugin {
6
+ /**
7
+ * The package name or local path to the plugin.
8
+ * - For npm packages: use the package name (e.g., '@my-org/my-plugin')
9
+ * - For local plugins: use the tilde prefix (e.g., '~/plugins/my-plugin')
10
+ */
11
+ packageName: string;
12
+ /**
13
+ * Optional named export to use from the plugin package.
14
+ * If not specified, the default export will be used.
15
+ * Can be overridden by the plugin's own config.
16
+ */
17
+ componentName?: string;
18
+ /**
19
+ * Position where the plugin tab should appear in the workbench.
20
+ * - 'top': Display in the top tab bar
21
+ * - 'bottom': Display in the bottom tab bar
22
+ * @default 'top'
23
+ */
24
+ position?: 'top' | 'bottom';
25
+ /**
26
+ * Display label for the plugin tab.
27
+ * Can be overridden by the plugin's own config.
28
+ */
29
+ label?: string;
30
+ /**
31
+ * Icon name from lucide-react to display next to the label.
32
+ * Can be overridden by the plugin's own config.
33
+ * @default 'toy-brick'
34
+ */
35
+ labelIcon?: string;
36
+ /**
37
+ * Array of CSS package imports to inject into the workbench.
38
+ * These will be added to the main index.css file.
39
+ * Example: ['@my-org/my-plugin/styles.css']
40
+ */
41
+ cssImports?: string[];
42
+ /**
43
+ * Props to pass to the plugin component when it's rendered.
44
+ * Can be overridden by the plugin's own config.
45
+ */
46
+ props?: Record<string, any>;
47
+ }
48
+ /**
49
+ * Result of validating a plugin configuration.
50
+ */
51
+ export interface ValidationResult {
52
+ /**
53
+ * Whether the validation passed
54
+ */
55
+ valid: boolean;
56
+ /**
57
+ * Array of error messages if validation failed
58
+ */
59
+ errors: string[];
60
+ /**
61
+ * Array of warning messages for non-critical issues
62
+ */
63
+ warnings: string[];
64
+ /**
65
+ * The validated and normalized plugin configuration (if valid)
66
+ */
67
+ plugin?: WorkbenchPlugin;
68
+ }
69
+ /**
70
+ * Context object passed to various plugin internals functions.
71
+ * Contains shared state and configuration.
72
+ */
73
+ export interface PluginContext {
74
+ /**
75
+ * Array of plugin configurations
76
+ */
77
+ plugins: WorkbenchPlugin[];
78
+ /**
79
+ * Vite dev server instance (only available in dev mode)
80
+ */
81
+ server?: any;
82
+ }
83
+ /**
84
+ * Package resolution result.
85
+ */
86
+ export interface ResolvedPackage {
87
+ /**
88
+ * The original package name from the configuration
89
+ */
90
+ packageName: string;
91
+ /**
92
+ * Resolved absolute path to the package
93
+ */
94
+ resolvedPath: string;
95
+ /**
96
+ * Whether this is a local plugin (starts with ~/)
97
+ */
98
+ isLocal: boolean;
99
+ /**
100
+ * Alias to use for imports
101
+ */
102
+ alias: string;
103
+ }
104
+ /**
105
+ * Generated virtual module exports interface.
106
+ * This is what consumers will import from 'virtual:motia-plugins'.
107
+ */
108
+ export interface VirtualModuleExports {
109
+ /**
110
+ * Array of processed plugin configurations ready to be registered
111
+ */
112
+ plugins: ProcessedPlugin[];
113
+ }
114
+ /**
115
+ * A plugin configuration after processing and normalization.
116
+ * This is the format used by the workbench to register tabs.
117
+ */
118
+ export interface ProcessedPlugin {
119
+ /**
120
+ * Display label for the plugin tab
121
+ */
122
+ label: string;
123
+ /**
124
+ * Icon name from lucide-react
125
+ */
126
+ labelIcon: string;
127
+ /**
128
+ * Position in the workbench ('top' or 'bottom')
129
+ */
130
+ position: 'top' | 'bottom';
131
+ /**
132
+ * Props to pass to the component
133
+ */
134
+ props: Record<string, any>;
135
+ /**
136
+ * The React component to render
137
+ */
138
+ component: any;
139
+ }
140
+ /**
141
+ * Type guard to check if position is valid.
142
+ */
143
+ export declare function isValidPosition(position: any): position is 'top' | 'bottom';
144
+ /**
145
+ * Constants used throughout the plugin system.
146
+ */
147
+ export declare const CONSTANTS: {
148
+ /**
149
+ * Virtual module ID for importing plugins
150
+ */
151
+ readonly VIRTUAL_MODULE_ID: "virtual:motia-plugins";
152
+ /**
153
+ * Resolved virtual module ID (with null byte prefix for Vite)
154
+ */
155
+ readonly RESOLVED_VIRTUAL_MODULE_ID: "\0virtual:motia-plugins";
156
+ /**
157
+ * Log prefix for all plugin messages
158
+ */
159
+ readonly LOG_PREFIX: "[motia-plugins]";
160
+ /**
161
+ * Default values for optional plugin fields
162
+ */
163
+ readonly DEFAULTS: {
164
+ readonly POSITION: "top";
165
+ readonly LABEL: "Plugin label";
166
+ readonly ICON: "toy-brick";
167
+ readonly PROPS: {};
168
+ };
169
+ };
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONSTANTS = void 0;
4
+ exports.isValidPosition = isValidPosition;
5
+ /**
6
+ * Type guard to check if position is valid.
7
+ */
8
+ function isValidPosition(position) {
9
+ return position === 'top' || position === 'bottom';
10
+ }
11
+ /**
12
+ * Constants used throughout the plugin system.
13
+ */
14
+ exports.CONSTANTS = {
15
+ /**
16
+ * Virtual module ID for importing plugins
17
+ */
18
+ VIRTUAL_MODULE_ID: 'virtual:motia-plugins',
19
+ /**
20
+ * Resolved virtual module ID (with null byte prefix for Vite)
21
+ */
22
+ RESOLVED_VIRTUAL_MODULE_ID: '\0virtual:motia-plugins',
23
+ /**
24
+ * Log prefix for all plugin messages
25
+ */
26
+ LOG_PREFIX: '[motia-plugins]',
27
+ /**
28
+ * Default values for optional plugin fields
29
+ */
30
+ DEFAULTS: {
31
+ POSITION: 'top',
32
+ LABEL: 'Plugin label',
33
+ ICON: 'toy-brick',
34
+ PROPS: {},
35
+ },
36
+ };
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Normalizes a file path by replacing backslashes with forward slashes.
3
+ * This is useful for consistent path comparisons across different operating systems.
4
+ *
5
+ * @param filePath - The file path to normalize
6
+ * @returns The normalized file path with forward slashes
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * normalizePath('C:\\Users\\file.ts') // Returns: 'C:/Users/file.ts'
11
+ * normalizePath('/Users/file.ts') // Returns: '/Users/file.ts'
12
+ * ```
13
+ */
14
+ export declare function normalizePath(filePath: string): string;
15
+ /**
16
+ * Checks if a package name represents a local plugin (starts with ~/).
17
+ *
18
+ * @param packageName - The package name to check
19
+ * @returns True if the package is a local plugin
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * isLocalPlugin('~/plugins/my-plugin') // Returns: true
24
+ * isLocalPlugin('@my-org/my-plugin') // Returns: false
25
+ * isLocalPlugin('my-plugin') // Returns: false
26
+ * ```
27
+ */
28
+ export declare function isLocalPlugin(packageName: string): boolean;
29
+ /**
30
+ * Resolves a local plugin path to an absolute path.
31
+ * Strips the ~/ prefix and joins with the current working directory.
32
+ *
33
+ * @param packageName - The local plugin package name (must start with ~/)
34
+ * @returns The absolute path to the local plugin
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * // If cwd is /Users/project
39
+ * resolveLocalPath('~/plugins/my-plugin')
40
+ * // Returns: '/Users/project/plugins/my-plugin'
41
+ * ```
42
+ */
43
+ export declare function resolveLocalPath(packageName: string): string;
44
+ /**
45
+ * Resolves an npm package path to the node_modules directory.
46
+ *
47
+ * @param packageName - The npm package name
48
+ * @returns The absolute path to the package in node_modules
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * // If cwd is /Users/project
53
+ * resolveNpmPath('@my-org/my-plugin')
54
+ * // Returns: '/Users/project/node_modules/@my-org/my-plugin'
55
+ * ```
56
+ */
57
+ export declare function resolveNpmPath(packageName: string): string;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.normalizePath = normalizePath;
7
+ exports.isLocalPlugin = isLocalPlugin;
8
+ exports.resolveLocalPath = resolveLocalPath;
9
+ exports.resolveNpmPath = resolveNpmPath;
10
+ const path_1 = __importDefault(require("path"));
11
+ /**
12
+ * Normalizes a file path by replacing backslashes with forward slashes.
13
+ * This is useful for consistent path comparisons across different operating systems.
14
+ *
15
+ * @param filePath - The file path to normalize
16
+ * @returns The normalized file path with forward slashes
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * normalizePath('C:\\Users\\file.ts') // Returns: 'C:/Users/file.ts'
21
+ * normalizePath('/Users/file.ts') // Returns: '/Users/file.ts'
22
+ * ```
23
+ */
24
+ function normalizePath(filePath) {
25
+ return filePath.replace(/\\/g, '/');
26
+ }
27
+ /**
28
+ * Checks if a package name represents a local plugin (starts with ~/).
29
+ *
30
+ * @param packageName - The package name to check
31
+ * @returns True if the package is a local plugin
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * isLocalPlugin('~/plugins/my-plugin') // Returns: true
36
+ * isLocalPlugin('@my-org/my-plugin') // Returns: false
37
+ * isLocalPlugin('my-plugin') // Returns: false
38
+ * ```
39
+ */
40
+ function isLocalPlugin(packageName) {
41
+ return packageName.startsWith('~/');
42
+ }
43
+ /**
44
+ * Resolves a local plugin path to an absolute path.
45
+ * Strips the ~/ prefix and joins with the current working directory.
46
+ *
47
+ * @param packageName - The local plugin package name (must start with ~/)
48
+ * @returns The absolute path to the local plugin
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * // If cwd is /Users/project
53
+ * resolveLocalPath('~/plugins/my-plugin')
54
+ * // Returns: '/Users/project/plugins/my-plugin'
55
+ * ```
56
+ */
57
+ function resolveLocalPath(packageName) {
58
+ return path_1.default.join(process.cwd(), packageName.replace('~/', ''));
59
+ }
60
+ /**
61
+ * Resolves an npm package path to the node_modules directory.
62
+ *
63
+ * @param packageName - The npm package name
64
+ * @returns The absolute path to the package in node_modules
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * // If cwd is /Users/project
69
+ * resolveNpmPath('@my-org/my-plugin')
70
+ * // Returns: '/Users/project/node_modules/@my-org/my-plugin'
71
+ * ```
72
+ */
73
+ function resolveNpmPath(packageName) {
74
+ return path_1.default.join(process.cwd(), 'node_modules', packageName);
75
+ }
@@ -0,0 +1,19 @@
1
+ import type { ValidationResult } from './types';
2
+ /**
3
+ * Validates a single plugin configuration.
4
+ *
5
+ * @param plugin - The plugin configuration to validate
6
+ * @param index - The index of the plugin in the array (for error messages)
7
+ * @returns A validation result with errors, warnings, and normalized plugin
8
+ */
9
+ export declare function validatePluginConfig(plugin: any, index: number): ValidationResult;
10
+ /**
11
+ * Validates an array of plugin configurations.
12
+ *
13
+ * @param plugins - Array of plugin configurations to validate
14
+ * @param options - Validation options
15
+ * @returns Combined validation result for all plugins
16
+ */
17
+ export declare function validatePlugins(plugins: any[], options?: {
18
+ failFast?: boolean;
19
+ }): ValidationResult;