@motiadev/workbench 0.13.0-beta.162-315243 → 0.13.0-beta.162-158257

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.
@@ -657,9 +657,7 @@ const applyMiddleware = async ({ app, port, workbenchBase, plugins }) => {
657
657
  },
658
658
  resolve: { alias: {
659
659
  "@": path.resolve(__dirname, "./src"),
660
- "@/assets": path.resolve(__dirname, "./src/assets"),
661
- "lucide-react/dynamic": "lucide-react/dynamic.mjs",
662
- "lucide-react": "lucide-react/dist/cjs/lucide-react.js"
660
+ "@/assets": path.resolve(__dirname, "./src/assets")
663
661
  } },
664
662
  plugins: [
665
663
  react(),
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","names":["path","normalizePath","filePath","replace","isLocalPlugin","packageName","startsWith","resolveLocalPath","join","process","cwd","resolveNpmPath","ResolvedPackage","WorkbenchPlugin","isLocalPlugin","normalizePath","resolveLocalPath","resolveNpmPath","resolvePluginPackage","plugin","packageName","local","resolvedPath","isLocal","alias","createAliasConfig","plugins","Record","uniquePackages","Array","from","Set","map","p","aliases","resolved","resolveAllPlugins","getUniquePackageNames","getUniquePackageNames","WorkbenchPlugin","generateImports","packages","map","packageName","index","join","generatePackageMap","entries","generatePluginLogic","plugins","JSON","stringify","generatePluginCode","length","imports","packageMap","logic","generateCssImports","cssImports","flatMap","plugin","filter","cssImport","trim","isValidCode","code","WorkbenchPlugin","packageName","componentName","position","label","labelIcon","cssImports","props","Record","ValidationResult","valid","errors","warnings","plugin","PluginContext","plugins","server","ResolvedPackage","resolvedPath","isLocal","alias","VirtualModuleExports","ProcessedPlugin","component","isValidPosition","CONSTANTS","VIRTUAL_MODULE_ID","RESOLVED_VIRTUAL_MODULE_ID","LOG_PREFIX","DEFAULTS","POSITION","const","LABEL","ICON","PROPS","Printer","path","HmrContext","ModuleNode","resolvePluginPackage","WorkbenchPlugin","CONSTANTS","isLocalPlugin","normalizePath","WATCHED_EXTENSIONS","isConfigFile","file","normalizedFile","endsWith","shouldInvalidatePlugins","plugins","absoluteFile","isAbsolute","resolve","process","cwd","hasWatchedExtension","some","ext","plugin","packageName","resolved","pluginAbsolutePath","resolvedPath","normalizedPluginPath","sep","startsWith","handlePluginHotUpdate","ctx","printer","server","timestamp","printPluginLog","printPluginWarn","ws","send","type","virtualModule","moduleGraph","getModuleById","RESOLVED_VIRTUAL_MODULE_ID","invalidateModule","Set","modulesToUpdateSet","processedModules","importer","importers","has","add","modulesToUpdate","Array","from","length","existsSync","z","ValidationResult","WorkbenchPlugin","CONSTANTS","isValidPosition","isLocalPlugin","resolveLocalPath","WorkbenchPluginSchema","object","packageName","string","min","refine","name","startsWith","test","message","componentName","optional","position","enum","pos","undefined","label","labelIcon","cssImports","array","props","record","any","validatePluginConfig","plugin","index","errors","warnings","valid","result","safeParse","success","error","issues","forEach","err","core","$ZodIssue","path","join","push","validatedPlugin","data","resolvedPath","DEFAULTS","LABEL","ICON","POSITION","Object","keys","length","cssImport","cssIndex","trim","validatePlugins","plugins","options","failFast","allErrors","allWarnings","validatedPlugins","Array","isArray","console","warn","i","packageNames","map","p","duplicates","filter","indexOf","uniqueDuplicates","Set","dup","log","Printer","path","Plugin","ViteDevServer","generateCssImports","generatePluginCode","isValidCode","handlePluginHotUpdate","createAliasConfig","resolvePluginPackage","WorkbenchPlugin","CONSTANTS","isLocalPlugin","normalizePath","validatePlugins","printer","process","cwd","motiaPluginsPlugin","plugins","devServer","validationResult","failFast","valid","printPluginError","err","errors","Error","warnings","length","warning","printPluginWarn","error","alias","printPluginLog","name","enforce","buildStart","config","resolve","configureServer","server","configPaths","join","configPath","watcher","add","localPlugins","filter","p","packageName","plugin","resolved","watchPath","resolvedPath","on","file","normalizedFile","resolveId","id","VIRTUAL_MODULE_ID","RESOLVED_VIRTUAL_MODULE_ID","load","code","transform","normalizedId","endsWith","cssImports","map","handleHotUpdate","ctx","modulesToUpdate","merged","Array","from","Set","modules","buildEnd","react","Express","NextFunction","Request","Response","fs","path","fileURLToPath","createServer","createViteServer","motiaPluginsPlugin","WorkbenchPlugin","workbenchBasePlugin","workbenchBase","name","transformIndexHtml","html","replace","JSON","stringify","processCwdPlugin","cwd","process","reoPlugin","isAnalyticsEnabled","env","MOTIA_ANALYTICS_DISABLED","ApplyMiddlewareParams","app","port","plugins","__dirname","dirname","import","meta","url","applyMiddleware","vite","appType","root","base","server","middlewareMode","allowedHosts","host","hmr","allow","join","resolve","alias","assetsInclude","use","middlewares","req","res","next","originalUrl","index","readFileSync","status","set","end","e"],"sources":["../motia-plugin/utils.ts","../motia-plugin/resolver.ts","../motia-plugin/generator.ts","../motia-plugin/types.ts","../motia-plugin/hmr.ts","../motia-plugin/validator.ts","../motia-plugin/index.ts","../middleware.ts"],"sourcesContent":["import path from 'path'\n\n/**\n * Normalizes a file path by replacing backslashes with forward slashes.\n * This is useful for consistent path comparisons across different operating systems.\n *\n * @param filePath - The file path to normalize\n * @returns The normalized file path with forward slashes\n *\n * @example\n * ```ts\n * normalizePath('C:\\\\Users\\\\file.ts') // Returns: 'C:/Users/file.ts'\n * normalizePath('/Users/file.ts') // Returns: '/Users/file.ts'\n * ```\n */\nexport function normalizePath(filePath: string): string {\n return filePath.replace(/\\\\/g, '/')\n}\n\n/**\n * Checks if a package name represents a local plugin (starts with ~/).\n *\n * @param packageName - The package name to check\n * @returns True if the package is a local plugin\n *\n * @example\n * ```ts\n * isLocalPlugin('~/plugins/my-plugin') // Returns: true\n * isLocalPlugin('@my-org/my-plugin') // Returns: false\n * isLocalPlugin('my-plugin') // Returns: false\n * ```\n */\nexport function isLocalPlugin(packageName: string): boolean {\n return packageName.startsWith('~/')\n}\n\n/**\n * Resolves a local plugin path to an absolute path.\n * Strips the ~/ prefix and joins with the current working directory.\n *\n * @param packageName - The local plugin package name (must start with ~/)\n * @returns The absolute path to the local plugin\n *\n * @example\n * ```ts\n * // If cwd is /Users/project\n * resolveLocalPath('~/plugins/my-plugin')\n * // Returns: '/Users/project/plugins/my-plugin'\n * ```\n */\nexport function resolveLocalPath(packageName: string): string {\n return path.join(process.cwd(), packageName.replace('~/', ''))\n}\n\n/**\n * Resolves an npm package path to the node_modules directory.\n *\n * @param packageName - The npm package name\n * @returns The absolute path to the package in node_modules\n *\n * @example\n * ```ts\n * // If cwd is /Users/project\n * resolveNpmPath('@my-org/my-plugin')\n * // Returns: '/Users/project/node_modules/@my-org/my-plugin'\n * ```\n */\nexport function resolveNpmPath(packageName: string): string {\n return path.join(process.cwd(), 'node_modules', packageName)\n}\n","import type { ResolvedPackage, WorkbenchPlugin } from './types'\nimport { isLocalPlugin, normalizePath, resolveLocalPath, resolveNpmPath } from './utils'\n\n/**\n * Resolves a plugin package to its absolute path and creates an alias.\n *\n * @param plugin - The plugin configuration to resolve\n * @returns Resolved package information including path and alias\n *\n * @example\n * ```ts\n * // Local plugin\n * resolvePluginPackage({ packageName: '~/plugins/my-plugin' })\n * // Returns: {\n * // packageName: '~/plugins/my-plugin',\n * // resolvedPath: '/Users/project/plugins/my-plugin',\n * // isLocal: true,\n * // alias: '~/plugins/my-plugin'\n * // }\n *\n * // NPM package\n * resolvePluginPackage({ packageName: '@org/plugin' })\n * // Returns: {\n * // packageName: '@org/plugin',\n * // resolvedPath: '/Users/project/node_modules/@org/plugin',\n * // isLocal: false,\n * // alias: '@org/plugin'\n * // }\n * ```\n */\nexport function resolvePluginPackage(plugin: WorkbenchPlugin): ResolvedPackage {\n const { packageName } = plugin\n const local = isLocalPlugin(packageName)\n\n const resolvedPath = local ? resolveLocalPath(packageName) : resolveNpmPath(packageName)\n\n return {\n packageName,\n resolvedPath: normalizePath(resolvedPath),\n isLocal: local,\n alias: packageName,\n }\n}\n\n/**\n * Resolves all plugin packages and creates a Vite alias configuration.\n *\n * @param plugins - Array of plugin configurations\n * @returns Vite alias configuration object\n *\n * @example\n * ```ts\n * const plugins = [\n * { packageName: '~/plugins/local' },\n * { packageName: '@org/npm-plugin' }\n * ]\n * const aliases = createAliasConfig(plugins)\n * // Returns: {\n * // '~/plugins/local': '/Users/project/plugins/local',\n * // '@org/npm-plugin': '/Users/project/node_modules/@org/npm-plugin'\n * // }\n * ```\n */\nexport function createAliasConfig(plugins: WorkbenchPlugin[]): Record<string, string> {\n // Get unique package names to avoid duplicate aliases\n const uniquePackages = Array.from(new Set(plugins.map((p) => p.packageName)))\n\n const aliases: Record<string, string> = {}\n\n for (const packageName of uniquePackages) {\n const resolved = resolvePluginPackage({ packageName } as WorkbenchPlugin)\n aliases[packageName] = resolved.resolvedPath\n }\n\n return aliases\n}\n\n/**\n * Resolves all plugins and returns their resolved package information.\n *\n * @param plugins - Array of plugin configurations\n * @returns Array of resolved package information\n */\nexport function resolveAllPlugins(plugins: WorkbenchPlugin[]): ResolvedPackage[] {\n return plugins.map((plugin) => resolvePluginPackage(plugin))\n}\n\n/**\n * Gets the unique set of package names from plugins.\n *\n * @param plugins - Array of plugin configurations\n * @returns Array of unique package names\n */\nexport function getUniquePackageNames(plugins: WorkbenchPlugin[]): string[] {\n return Array.from(new Set(plugins.map((p) => p.packageName)))\n}\n","import { getUniquePackageNames } from './resolver'\nimport type { WorkbenchPlugin } from './types'\n\n/**\n * Generates import statements for all unique plugin packages.\n *\n * @param packages - Array of unique package names\n * @returns JavaScript code string with import statements\n *\n * @example\n * ```ts\n * generateImports(['@org/plugin-1', '~/plugins/local'])\n * // Returns:\n * // import * as plugin_0 from '@org/plugin-1'\n * // import * as plugin_1 from '~/plugins/local'\n * ```\n */\nexport function generateImports(packages: string[]): string {\n return packages.map((packageName, index) => `import * as plugin_${index} from '${packageName}'`).join('\\n')\n}\n\n/**\n * Generates the package map that links package names to their imported modules.\n *\n * @param packages - Array of unique package names\n * @returns JavaScript code string defining the package map\n *\n * @example\n * ```ts\n * generatePackageMap(['@org/plugin-1', '~/plugins/local'])\n * // Returns: const packageMap = {'@org/plugin-1': plugin_0,'~/plugins/local': plugin_1}\n * ```\n */\nexport function generatePackageMap(packages: string[]): string {\n const entries = packages.map((packageName, index) => `'${packageName}': plugin_${index}`)\n return `const packageMap = {${entries.join(',')}}`\n}\n\n/**\n * Generates the plugin transformation logic that processes plugin configurations.\n *\n * @param plugins - Array of plugin configurations\n * @returns JavaScript code string with plugin processing logic\n */\nexport function generatePluginLogic(plugins: WorkbenchPlugin[]): string {\n return `\n const motiaPlugins = ${JSON.stringify(plugins)}\n\n export const plugins = motiaPlugins.map((plugin) => {\n const component = packageMap[plugin.packageName]\n const config = component.config || {}\n const componentName = config.componentName || plugin.componentName\n\n return {\n label: plugin.label || config.label || 'Plugin label',\n labelIcon: plugin.labelIcon || config.labelIcon || 'toy-brick',\n position: plugin.position || config.position || 'top',\n props: plugin.props || config.props || {},\n component: componentName ? component[componentName] : component.default,\n }\n })\n`\n}\n\n/**\n * Generates the complete virtual module code for all plugins.\n * This is the main code generation function that combines all parts.\n *\n * @param plugins - Array of plugin configurations\n * @returns Complete JavaScript code string for the virtual module\n *\n * @example\n * ```ts\n * const plugins = [\n * { packageName: '@test/plugin', label: 'Test' }\n * ]\n * const code = generatePluginCode(plugins)\n * // Returns complete module code with imports, map, and logic\n * ```\n */\nexport function generatePluginCode(plugins: WorkbenchPlugin[]): string {\n if (!plugins || plugins.length === 0) {\n return 'export const plugins = []'\n }\n\n const packages = getUniquePackageNames(plugins)\n const imports = generateImports(packages)\n const packageMap = generatePackageMap(packages)\n const logic = generatePluginLogic(plugins)\n\n return `${imports}\n${packageMap}\n${logic}`\n}\n\n/**\n * Generates CSS imports for plugins that specify cssImports.\n *\n * @param plugins - Array of plugin configurations\n * @returns CSS import statements as a string\n *\n * @example\n * ```ts\n * const plugins = [\n * { packageName: '@test/plugin', cssImports: ['styles.css', 'theme.css'] }\n * ]\n * generateCssImports(plugins)\n * // Returns:\n * // @import 'styles.css';\n * // @import 'theme.css';\n * ```\n */\nexport function generateCssImports(plugins: WorkbenchPlugin[]): string {\n const cssImports = plugins\n .flatMap((plugin) => plugin.cssImports || [])\n .filter((cssImport) => cssImport && cssImport.trim() !== '')\n .map((cssImport) => `@import '${cssImport}';`)\n\n return cssImports.join('\\n')\n}\n\n/**\n * Checks if the generated code is valid (non-empty and has content).\n *\n * @param code - The generated code to check\n * @returns True if code is valid\n */\nexport function isValidCode(code: string): boolean {\n return typeof code === 'string' && code.trim().length > 0\n}\n","/**\n * Configuration for a single workbench plugin.\n * This interface defines how plugins are registered and configured in the Motia workbench.\n */\nexport interface WorkbenchPlugin {\n /**\n * The package name or local path to the plugin.\n * - For npm packages: use the package name (e.g., '@my-org/my-plugin')\n * - For local plugins: use the tilde prefix (e.g., '~/plugins/my-plugin')\n */\n packageName: string\n\n /**\n * Optional named export to use from the plugin package.\n * If not specified, the default export will be used.\n * Can be overridden by the plugin's own config.\n */\n componentName?: string\n\n /**\n * Position where the plugin tab should appear in the workbench.\n * - 'top': Display in the top tab bar\n * - 'bottom': Display in the bottom tab bar\n * @default 'top'\n */\n position?: 'top' | 'bottom'\n\n /**\n * Display label for the plugin tab.\n * Can be overridden by the plugin's own config.\n */\n label?: string\n\n /**\n * Icon name from lucide-react to display next to the label.\n * Can be overridden by the plugin's own config.\n * @default 'toy-brick'\n */\n labelIcon?: string\n\n /**\n * Array of CSS package imports to inject into the workbench.\n * These will be added to the main index.css file.\n * Example: ['@my-org/my-plugin/styles.css']\n */\n cssImports?: string[]\n\n /**\n * Props to pass to the plugin component when it's rendered.\n * Can be overridden by the plugin's own config.\n */\n props?: Record<string, any>\n}\n\n/**\n * Result of validating a plugin configuration.\n */\nexport interface ValidationResult {\n /**\n * Whether the validation passed\n */\n valid: boolean\n\n /**\n * Array of error messages if validation failed\n */\n errors: string[]\n\n /**\n * Array of warning messages for non-critical issues\n */\n warnings: string[]\n\n /**\n * The validated and normalized plugin configuration (if valid)\n */\n plugin?: WorkbenchPlugin\n}\n\n/**\n * Context object passed to various plugin internals functions.\n * Contains shared state and configuration.\n */\nexport interface PluginContext {\n /**\n * Array of plugin configurations\n */\n plugins: WorkbenchPlugin[]\n\n /**\n * Vite dev server instance (only available in dev mode)\n */\n server?: any\n}\n\n/**\n * Package resolution result.\n */\nexport interface ResolvedPackage {\n /**\n * The original package name from the configuration\n */\n packageName: string\n\n /**\n * Resolved absolute path to the package\n */\n resolvedPath: string\n\n /**\n * Whether this is a local plugin (starts with ~/)\n */\n isLocal: boolean\n\n /**\n * Alias to use for imports\n */\n alias: string\n}\n\n/**\n * Generated virtual module exports interface.\n * This is what consumers will import from 'virtual:motia-plugins'.\n */\nexport interface VirtualModuleExports {\n /**\n * Array of processed plugin configurations ready to be registered\n */\n plugins: ProcessedPlugin[]\n}\n\n/**\n * A plugin configuration after processing and normalization.\n * This is the format used by the workbench to register tabs.\n */\nexport interface ProcessedPlugin {\n /**\n * Display label for the plugin tab\n */\n label: string\n\n /**\n * Icon name from lucide-react\n */\n labelIcon: string\n\n /**\n * Position in the workbench ('top' or 'bottom')\n */\n position: 'top' | 'bottom'\n\n /**\n * Props to pass to the component\n */\n props: Record<string, any>\n\n /**\n * The React component to render\n */\n component: any\n}\n\n/**\n * Type guard to check if position is valid.\n */\nexport function isValidPosition(position: any): position is 'top' | 'bottom' {\n return position === 'top' || position === 'bottom'\n}\n\n/**\n * Constants used throughout the plugin system.\n */\nexport const CONSTANTS = {\n /**\n * Virtual module ID for importing plugins\n */\n VIRTUAL_MODULE_ID: 'virtual:motia-plugins',\n\n /**\n * Resolved virtual module ID (with null byte prefix for Vite)\n */\n RESOLVED_VIRTUAL_MODULE_ID: '\\0virtual:motia-plugins',\n\n /**\n * Log prefix for all plugin messages\n */\n LOG_PREFIX: '[motia-plugins]',\n\n /**\n * Default values for optional plugin fields\n */\n DEFAULTS: {\n POSITION: 'top' as const,\n LABEL: 'Plugin label',\n ICON: 'toy-brick',\n PROPS: {},\n },\n} as const\n","import type { Printer } from '@motiadev/core'\nimport path from 'path'\nimport type { HmrContext, ModuleNode } from 'vite'\nimport { resolvePluginPackage } from './resolver'\nimport type { WorkbenchPlugin } from './types'\nimport { CONSTANTS } from './types'\nimport { isLocalPlugin, normalizePath } from './utils'\n\nconst WATCHED_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.css', '.scss', '.less']\n\nexport function isConfigFile(file: string): boolean {\n const normalizedFile = normalizePath(file)\n return normalizedFile.endsWith('motia.config.ts') || normalizedFile.endsWith('motia.config.js')\n}\n\n/**\n * Checks if a file change should trigger HMR for plugins.\n *\n * @param file - The file path that changed\n * @param plugins - Current plugin configurations\n * @returns True if the change affects plugins\n */\nexport function shouldInvalidatePlugins(file: string, plugins: WorkbenchPlugin[]): boolean {\n const normalizedFile = normalizePath(file)\n const absoluteFile = path.isAbsolute(normalizedFile) ? normalizedFile : path.resolve(process.cwd(), normalizedFile)\n\n if (isConfigFile(file)) {\n return true\n }\n\n const hasWatchedExtension = WATCHED_EXTENSIONS.some((ext) => absoluteFile.endsWith(ext))\n if (!hasWatchedExtension) {\n return false\n }\n\n for (const plugin of plugins) {\n if (isLocalPlugin(plugin.packageName)) {\n const resolved = resolvePluginPackage(plugin)\n const pluginAbsolutePath = path.isAbsolute(resolved.resolvedPath)\n ? resolved.resolvedPath\n : path.resolve(process.cwd(), resolved.resolvedPath)\n\n const normalizedPluginPath = pluginAbsolutePath.endsWith(path.sep)\n ? pluginAbsolutePath\n : `${pluginAbsolutePath}${path.sep}`\n\n if (absoluteFile.startsWith(normalizedPluginPath) || absoluteFile === pluginAbsolutePath) {\n return true\n }\n }\n }\n\n return false\n}\n\n/**\n * Handles hot updates for the plugin system.\n * This function is called by Vite's handleHotUpdate hook.\n *\n * @param ctx - Vite's HMR context\n * @param plugins - Current plugin configurations\n * @param printer - Printer instance for logging\n * @returns Array of modules to update, or undefined to continue with default behavior\n */\nexport function handlePluginHotUpdate(\n ctx: HmrContext,\n plugins: WorkbenchPlugin[],\n printer: Printer,\n): ModuleNode[] | undefined {\n const { file, server, timestamp } = ctx\n\n printer.printPluginLog(`HMR: File changed: ${normalizePath(file)}`)\n\n if (isConfigFile(file)) {\n printer.printPluginLog('HMR: Config file changed, triggering full page reload')\n printer.printPluginWarn(\n 'Configuration changes require a server restart for full effect. Please restart the dev server to apply all changes.',\n )\n server.ws.send({\n type: 'full-reload',\n path: '*',\n })\n return\n }\n\n if (!shouldInvalidatePlugins(file, plugins)) {\n printer.printPluginLog('HMR: Change outside plugin scope, delegating to Vite default handling')\n return\n }\n\n printer.printPluginLog('HMR: Plugin change detected, invalidating virtual module')\n\n const virtualModule = server.moduleGraph.getModuleById(CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID)\n\n if (!virtualModule) {\n printer.printPluginWarn('HMR: Virtual module not found, triggering full reload as fallback')\n server.ws.send({\n type: 'full-reload',\n path: '*',\n })\n return\n }\n\n server.moduleGraph.invalidateModule(virtualModule, new Set(), timestamp)\n printer.printPluginLog('HMR: Virtual module invalidated')\n\n const modulesToUpdateSet = new Set<ModuleNode>([virtualModule])\n const processedModules = new Set<ModuleNode>([virtualModule])\n\n for (const importer of virtualModule.importers) {\n if (!processedModules.has(importer)) {\n processedModules.add(importer)\n modulesToUpdateSet.add(importer)\n server.moduleGraph.invalidateModule(importer, new Set(), timestamp)\n }\n }\n\n const modulesToUpdate = Array.from(modulesToUpdateSet)\n\n printer.printPluginLog(`HMR: Updated ${modulesToUpdate.length} module(s)`)\n\n return modulesToUpdate\n}\n","import { existsSync } from 'fs'\nimport { z } from 'zod'\nimport type { ValidationResult, WorkbenchPlugin } from './types'\nimport { CONSTANTS, isValidPosition } from './types'\nimport { isLocalPlugin, resolveLocalPath } from './utils'\n\n/**\n * Zod schema for WorkbenchPlugin configuration.\n * Provides runtime type validation with detailed error messages.\n */\nconst WorkbenchPluginSchema = z.object({\n packageName: z\n .string()\n .min(1, 'packageName is required and cannot be empty')\n .refine((name) => name.startsWith('~/') || name.startsWith('@') || /^[a-z0-9-_]+$/i.test(name), {\n message: 'packageName must be a valid npm package name or local path (starting with ~/)',\n }),\n\n componentName: z.string().optional(),\n\n position: z\n .enum(['top', 'bottom'])\n .optional()\n .refine((pos) => pos === undefined || isValidPosition(pos), {\n message: 'position must be either \"top\" or \"bottom\"',\n }),\n\n label: z.string().optional(),\n\n labelIcon: z.string().optional(),\n\n cssImports: z.array(z.string()).optional(),\n\n props: z.record(z.any(), z.any()).optional(),\n})\n\n/**\n * Validates a single plugin configuration.\n *\n * @param plugin - The plugin configuration to validate\n * @param index - The index of the plugin in the array (for error messages)\n * @returns A validation result with errors, warnings, and normalized plugin\n */\nexport function validatePluginConfig(plugin: any, index: number): ValidationResult {\n const errors: string[] = []\n const warnings: string[] = []\n\n if (typeof plugin !== 'object' || plugin === null) {\n return {\n valid: false,\n errors: [`Plugin at index ${index}: expected object, got ${typeof plugin}`],\n warnings: [],\n }\n }\n\n try {\n const result = WorkbenchPluginSchema.safeParse(plugin)\n\n if (!result.success) {\n result.error.issues.forEach((err: z.core.$ZodIssue) => {\n const path = err.path.join('.')\n errors.push(`Plugin at index ${index}, field \"${path}\": ${err.message}`)\n })\n\n return { valid: false, errors, warnings }\n }\n\n const validatedPlugin = result.data as WorkbenchPlugin\n\n if (isLocalPlugin(validatedPlugin.packageName)) {\n const resolvedPath = resolveLocalPath(validatedPlugin.packageName)\n if (!existsSync(resolvedPath)) {\n warnings.push(\n `Plugin at index ${index}: local path \"${validatedPlugin.packageName}\" does not exist at \"${resolvedPath}\". ` +\n `Make sure the path is correct relative to the project root.`,\n )\n }\n }\n\n if (!validatedPlugin.label) {\n warnings.push(`Plugin at index ${index}: \"label\" not specified, will use default \"${CONSTANTS.DEFAULTS.LABEL}\"`)\n }\n\n if (!validatedPlugin.labelIcon) {\n warnings.push(\n `Plugin at index ${index}: \"labelIcon\" not specified, will use default \"${CONSTANTS.DEFAULTS.ICON}\"`,\n )\n }\n\n if (!validatedPlugin.position) {\n warnings.push(\n `Plugin at index ${index}: \"position\" not specified, will use default \"${CONSTANTS.DEFAULTS.POSITION}\"`,\n )\n }\n\n if (validatedPlugin.props && Object.keys(validatedPlugin.props).length === 0) {\n warnings.push(`Plugin at index ${index}: \"props\" is an empty object`)\n }\n\n if (validatedPlugin.cssImports) {\n if (validatedPlugin.cssImports.length === 0) {\n warnings.push(`Plugin at index ${index}: \"cssImports\" is an empty array`)\n }\n\n validatedPlugin.cssImports.forEach((cssImport, cssIndex) => {\n if (!cssImport || cssImport.trim() === '') {\n warnings.push(`Plugin at index ${index}: cssImport at index ${cssIndex} is empty or whitespace`)\n }\n })\n }\n\n return {\n valid: true,\n errors: [],\n warnings,\n plugin: validatedPlugin,\n }\n } catch (error) {\n return {\n valid: false,\n errors: [`Plugin at index ${index}: unexpected validation error: ${error}`],\n warnings: [],\n }\n }\n}\n\n/**\n * Validates an array of plugin configurations.\n *\n * @param plugins - Array of plugin configurations to validate\n * @param options - Validation options\n * @returns Combined validation result for all plugins\n */\nexport function validatePlugins(plugins: any[], options: { failFast?: boolean } = {}): ValidationResult {\n const allErrors: string[] = []\n const allWarnings: string[] = []\n const validatedPlugins: WorkbenchPlugin[] = []\n\n if (!Array.isArray(plugins)) {\n return {\n valid: false,\n errors: [`Expected plugins to be an array, got ${typeof plugins}`],\n warnings: [],\n }\n }\n\n if (plugins.length === 0) {\n console.warn('[motia-plugins] No plugins provided to validate')\n return {\n valid: true,\n errors: [],\n warnings: ['No plugins configured'],\n }\n }\n\n for (let i = 0; i < plugins.length; i++) {\n const result = validatePluginConfig(plugins[i], i)\n\n allErrors.push(...result.errors)\n allWarnings.push(...result.warnings)\n\n if (result.valid && result.plugin) {\n validatedPlugins.push(result.plugin)\n }\n\n if (options.failFast && result.errors.length > 0) {\n break\n }\n }\n\n const packageNames = validatedPlugins.map((p) => p.packageName)\n const duplicates = packageNames.filter((name, index) => packageNames.indexOf(name) !== index)\n\n if (duplicates.length > 0) {\n const uniqueDuplicates = [...new Set(duplicates)]\n uniqueDuplicates.forEach((dup) => {\n allWarnings.push(`Duplicate package name found: \"${dup}\". This may cause conflicts.`)\n })\n }\n\n const valid = allErrors.length === 0\n\n if (valid) {\n console.log(`[motia-plugins] ✓ Validated ${validatedPlugins.length} plugin(s) successfully`)\n if (allWarnings.length > 0) {\n console.warn(`[motia-plugins] Found ${allWarnings.length} warning(s)`)\n }\n } else {\n console.error(`[motia-plugins] ✗ Validation failed with ${allErrors.length} error(s)`)\n }\n\n return {\n valid,\n errors: allErrors,\n warnings: allWarnings,\n }\n}\n","import { Printer } from '@motiadev/core'\nimport path from 'path'\nimport type { Plugin, ViteDevServer } from 'vite'\nimport { generateCssImports, generatePluginCode, isValidCode } from './generator'\nimport { handlePluginHotUpdate } from './hmr'\nimport { createAliasConfig, resolvePluginPackage } from './resolver'\nimport type { WorkbenchPlugin } from './types'\nimport { CONSTANTS } from './types'\nimport { isLocalPlugin, normalizePath } from './utils'\nimport { validatePlugins } from './validator'\n\n/**\n * Vite plugin for loading and managing Motia workbench plugins.\n *\n * Features:\n * - Hot Module Replacement (HMR) support\n * - Runtime validation with detailed error messages\n * - Verbose logging for debugging\n * - CSS injection for plugin styles\n *\n * @param plugins - Array of plugin configurations\n * @param options - Optional loader configuration\n * @returns Vite plugin instance\n *\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [\n * motiaPluginsPlugin([\n * { packageName: '@my-org/plugin', label: 'My Plugin' }\n * ])\n * ]\n * })\n * ```\n */\nconst printer = new Printer(process.cwd())\n\nexport default function motiaPluginsPlugin(plugins: WorkbenchPlugin[]): Plugin {\n let devServer: ViteDevServer | null = null\n\n try {\n const validationResult = validatePlugins(plugins, {\n failFast: false,\n })\n\n if (!validationResult.valid) {\n printer.printPluginError('Plugin configuration validation failed:')\n for (const err of validationResult.errors) {\n printer.printPluginError(` ${err}`)\n }\n throw new Error('Invalid plugin configuration. See errors above.')\n }\n\n if (validationResult.warnings.length > 0) {\n for (const warning of validationResult.warnings) {\n printer.printPluginWarn(warning)\n }\n }\n } catch (error) {\n printer.printPluginError(`Failed to validate plugins: ${error}`)\n throw error\n }\n\n const alias = createAliasConfig(plugins)\n\n printer.printPluginLog(`Initialized with ${plugins.length} plugin(s)`)\n\n return {\n name: 'vite-plugin-motia-plugins',\n enforce: 'pre',\n\n buildStart() {\n printer.printPluginLog('Build started')\n },\n\n config: () => ({\n resolve: {\n alias,\n },\n }),\n\n configureServer(server) {\n devServer = server\n printer.printPluginLog('Dev server configured, HMR enabled')\n\n const configPaths = [path.join(process.cwd(), 'motia.config.ts'), path.join(process.cwd(), 'motia.config.js')]\n\n for (const configPath of configPaths) {\n server.watcher.add(configPath)\n }\n printer.printPluginLog('Watching for config file changes')\n\n const localPlugins = plugins.filter((p) => isLocalPlugin(p.packageName))\n if (localPlugins.length > 0) {\n printer.printPluginLog(`Watching ${localPlugins.length} local plugin(s)`)\n\n for (const plugin of localPlugins) {\n const resolved = resolvePluginPackage(plugin)\n const watchPath = resolved.resolvedPath\n\n server.watcher.add(watchPath)\n printer.printPluginLog(`Watching: ${watchPath}`)\n }\n\n server.watcher.on('change', (file) => {\n const normalizedFile = normalizePath(file)\n printer.printPluginLog(`File watcher detected change: ${normalizedFile}`)\n })\n\n server.watcher.on('add', (file) => {\n const normalizedFile = normalizePath(file)\n printer.printPluginLog(`File watcher detected new file: ${normalizedFile}`)\n })\n }\n },\n\n resolveId(id) {\n if (id === CONSTANTS.VIRTUAL_MODULE_ID) {\n return CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID\n }\n },\n\n load(id) {\n if (id !== CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID) {\n return null\n }\n\n printer.printPluginLog('Loading plugins virtual module')\n printer.printPluginLog('Generating plugin code...')\n\n const code = generatePluginCode(plugins)\n\n if (!isValidCode(code)) {\n printer.printPluginError('Generated code is invalid or empty')\n return 'export const plugins = []'\n }\n\n printer.printPluginLog('Plugin code generated successfully')\n\n return code\n },\n\n async transform(code, id) {\n const normalizedId = normalizePath(id)\n\n if (!normalizedId.endsWith('src/index.css')) {\n return null\n }\n\n printer.printPluginLog('Injecting plugin CSS imports')\n\n const cssImports = generateCssImports(plugins)\n\n if (!cssImports) {\n return null\n }\n\n return {\n code: `${cssImports}\\n${code}`,\n map: null,\n }\n },\n\n handleHotUpdate(ctx) {\n if (!devServer) {\n printer.printPluginWarn('HMR: Dev server not available')\n return\n }\n\n const modulesToUpdate = handlePluginHotUpdate(ctx, plugins, printer)\n\n if (modulesToUpdate && modulesToUpdate.length > 0) {\n const merged = Array.from(new Set([...(ctx.modules || []), ...modulesToUpdate]))\n printer.printPluginLog(`HMR: Successfully updated ${merged.length} module(s)`)\n return merged\n }\n },\n\n buildEnd() {\n printer.printPluginLog('Build ended')\n },\n }\n}\n","import react from '@vitejs/plugin-react'\nimport type { Express, NextFunction, Request, Response } from 'express'\nimport fs from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\nimport { createServer as createViteServer } from 'vite'\nimport motiaPluginsPlugin from './motia-plugin/index.js'\nimport type { WorkbenchPlugin } from './motia-plugin/types.js'\n\nconst workbenchBasePlugin = (workbenchBase: string) => {\n return {\n name: 'html-transform',\n transformIndexHtml: (html: string) => {\n return html.replace('</head>', `<script>const workbenchBase = ${JSON.stringify(workbenchBase)};</script></head>`)\n },\n }\n}\n\nconst processCwdPlugin = () => {\n return {\n name: 'html-transform',\n transformIndexHtml: (html: string) => {\n // Normalize path for cross-platform compatibility\n const cwd = process.cwd().replace(/\\\\/g, '/')\n return html.replace('</head>', `<script>const processCwd = \"${cwd}\";</script></head>`)\n },\n }\n}\n\nconst reoPlugin = () => {\n return {\n name: 'html-transform',\n transformIndexHtml(html: string) {\n const isAnalyticsEnabled = process.env.MOTIA_ANALYTICS_DISABLED !== 'true'\n\n if (!isAnalyticsEnabled) {\n return html\n }\n\n // inject before </head>\n return html.replace(\n '</head>',\n `\n <script type=\"text/javascript\">\n !function(){var e,t,n;e=\"d8f0ce9cae8ae64\",t=function(){Reo.init({clientID:\"d8f0ce9cae8ae64\", source: \"internal\"})},(n=document.createElement(\"script\")).src=\"https://static.reo.dev/\"+e+\"/reo.js\",n.defer=!0,n.onload=t,document.head.appendChild(n)}();\n </script>\n </head>`,\n )\n },\n }\n}\n\nexport type ApplyMiddlewareParams = {\n app: Express\n port: number\n workbenchBase: string\n plugins: WorkbenchPlugin[]\n}\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\n\nexport const applyMiddleware = async ({ app, port, workbenchBase, plugins }: ApplyMiddlewareParams) => {\n const vite = await createViteServer({\n appType: 'spa',\n root: __dirname,\n base: workbenchBase,\n server: {\n middlewareMode: true,\n allowedHosts: true,\n host: true,\n hmr: { port: 21678 + port },\n fs: {\n allow: [\n __dirname, // workbench root\n path.join(process.cwd(), './steps'), // steps directory\n path.join(process.cwd(), './src'), // src directory\n path.join(process.cwd(), './tutorial'), // tutorial directory\n path.join(process.cwd(), './node_modules'), // node_modules directory\n path.join(__dirname, './node_modules'), // node_modules directory\n ],\n },\n },\n resolve: {\n alias: {\n '@': path.resolve(__dirname, './src'),\n '@/assets': path.resolve(__dirname, './src/assets'),\n 'lucide-react/dynamic': 'lucide-react/dynamic.mjs',\n 'lucide-react': 'lucide-react/dist/cjs/lucide-react.js',\n },\n },\n plugins: [\n react(),\n processCwdPlugin(),\n reoPlugin(),\n motiaPluginsPlugin(plugins),\n workbenchBasePlugin(workbenchBase),\n ],\n assetsInclude: ['**/*.png', '**/*.jpg', '**/*.jpeg', '**/*.gif', '**/*.svg', '**/*.ico', '**/*.webp', '**/*.avif'],\n })\n\n app.use(workbenchBase, vite.middlewares)\n app.use(`${workbenchBase}/*`, async (req: Request, res: Response, next: NextFunction) => {\n const url = req.originalUrl\n\n try {\n const index = fs.readFileSync(path.resolve(__dirname, 'index.html'), 'utf-8')\n const html = await vite.transformIndexHtml(url, index)\n\n res.status(200).set({ 'Content-Type': 'text/html' }).end(html)\n } catch (e) {\n next(e)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeA,SAAgBC,cAAcC,UAA0B;AACtD,QAAOA,SAASC,QAAQ,OAAO,IAAI;;;;;;;;;;;;;;;AAgBrC,SAAgBC,cAAcC,aAA8B;AAC1D,QAAOA,YAAYC,WAAW,KAAK;;;;;;;;;;;;;;;;AAiBrC,SAAgBC,iBA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AAGqD,aAAapD,KAAK0C,QAAQjB,WAAW,aAAa,EAAE,QAAQ;GAC7E,MAAMf,OAAO,MAAMqB,KAAKtB,mBAAmBoB,KAAKsB,MAAM;AAEtDH,OAAIK,OAAO,IAAI,CAACC,IAAI,EAAE,gBAAgB,aAAa,CAAC,CAACC,IAAI7C,KAAK;WACvD8C,GAAG;AACVP,QAAKO,EAAE;;GAET"}
1
+ {"version":3,"file":"middleware.js","names":["path","normalizePath","filePath","replace","isLocalPlugin","packageName","startsWith","resolveLocalPath","join","process","cwd","resolveNpmPath","ResolvedPackage","WorkbenchPlugin","isLocalPlugin","normalizePath","resolveLocalPath","resolveNpmPath","resolvePluginPackage","plugin","packageName","local","resolvedPath","isLocal","alias","createAliasConfig","plugins","Record","uniquePackages","Array","from","Set","map","p","aliases","resolved","resolveAllPlugins","getUniquePackageNames","getUniquePackageNames","WorkbenchPlugin","generateImports","packages","map","packageName","index","join","generatePackageMap","entries","generatePluginLogic","plugins","JSON","stringify","generatePluginCode","length","imports","packageMap","logic","generateCssImports","cssImports","flatMap","plugin","filter","cssImport","trim","isValidCode","code","WorkbenchPlugin","packageName","componentName","position","label","labelIcon","cssImports","props","Record","ValidationResult","valid","errors","warnings","plugin","PluginContext","plugins","server","ResolvedPackage","resolvedPath","isLocal","alias","VirtualModuleExports","ProcessedPlugin","component","isValidPosition","CONSTANTS","VIRTUAL_MODULE_ID","RESOLVED_VIRTUAL_MODULE_ID","LOG_PREFIX","DEFAULTS","POSITION","const","LABEL","ICON","PROPS","Printer","path","HmrContext","ModuleNode","resolvePluginPackage","WorkbenchPlugin","CONSTANTS","isLocalPlugin","normalizePath","WATCHED_EXTENSIONS","isConfigFile","file","normalizedFile","endsWith","shouldInvalidatePlugins","plugins","absoluteFile","isAbsolute","resolve","process","cwd","hasWatchedExtension","some","ext","plugin","packageName","resolved","pluginAbsolutePath","resolvedPath","normalizedPluginPath","sep","startsWith","handlePluginHotUpdate","ctx","printer","server","timestamp","printPluginLog","printPluginWarn","ws","send","type","virtualModule","moduleGraph","getModuleById","RESOLVED_VIRTUAL_MODULE_ID","invalidateModule","Set","modulesToUpdateSet","processedModules","importer","importers","has","add","modulesToUpdate","Array","from","length","existsSync","z","ValidationResult","WorkbenchPlugin","CONSTANTS","isValidPosition","isLocalPlugin","resolveLocalPath","WorkbenchPluginSchema","object","packageName","string","min","refine","name","startsWith","test","message","componentName","optional","position","enum","pos","undefined","label","labelIcon","cssImports","array","props","record","any","validatePluginConfig","plugin","index","errors","warnings","valid","result","safeParse","success","error","issues","forEach","err","core","$ZodIssue","path","join","push","validatedPlugin","data","resolvedPath","DEFAULTS","LABEL","ICON","POSITION","Object","keys","length","cssImport","cssIndex","trim","validatePlugins","plugins","options","failFast","allErrors","allWarnings","validatedPlugins","Array","isArray","console","warn","i","packageNames","map","p","duplicates","filter","indexOf","uniqueDuplicates","Set","dup","log","Printer","path","Plugin","ViteDevServer","generateCssImports","generatePluginCode","isValidCode","handlePluginHotUpdate","createAliasConfig","resolvePluginPackage","WorkbenchPlugin","CONSTANTS","isLocalPlugin","normalizePath","validatePlugins","printer","process","cwd","motiaPluginsPlugin","plugins","devServer","validationResult","failFast","valid","printPluginError","err","errors","Error","warnings","length","warning","printPluginWarn","error","alias","printPluginLog","name","enforce","buildStart","config","resolve","configureServer","server","configPaths","join","configPath","watcher","add","localPlugins","filter","p","packageName","plugin","resolved","watchPath","resolvedPath","on","file","normalizedFile","resolveId","id","VIRTUAL_MODULE_ID","RESOLVED_VIRTUAL_MODULE_ID","load","code","transform","normalizedId","endsWith","cssImports","map","handleHotUpdate","ctx","modulesToUpdate","merged","Array","from","Set","modules","buildEnd","react","Express","NextFunction","Request","Response","fs","path","fileURLToPath","createServer","createViteServer","motiaPluginsPlugin","WorkbenchPlugin","workbenchBasePlugin","workbenchBase","name","transformIndexHtml","html","replace","JSON","stringify","processCwdPlugin","cwd","process","reoPlugin","isAnalyticsEnabled","env","MOTIA_ANALYTICS_DISABLED","ApplyMiddlewareParams","app","port","plugins","__dirname","dirname","import","meta","url","applyMiddleware","vite","appType","root","base","server","middlewareMode","allowedHosts","host","hmr","allow","join","resolve","alias","assetsInclude","use","middlewares","req","res","next","originalUrl","index","readFileSync","status","set","end","e"],"sources":["../motia-plugin/utils.ts","../motia-plugin/resolver.ts","../motia-plugin/generator.ts","../motia-plugin/types.ts","../motia-plugin/hmr.ts","../motia-plugin/validator.ts","../motia-plugin/index.ts","../middleware.ts"],"sourcesContent":["import path from 'path'\n\n/**\n * Normalizes a file path by replacing backslashes with forward slashes.\n * This is useful for consistent path comparisons across different operating systems.\n *\n * @param filePath - The file path to normalize\n * @returns The normalized file path with forward slashes\n *\n * @example\n * ```ts\n * normalizePath('C:\\\\Users\\\\file.ts') // Returns: 'C:/Users/file.ts'\n * normalizePath('/Users/file.ts') // Returns: '/Users/file.ts'\n * ```\n */\nexport function normalizePath(filePath: string): string {\n return filePath.replace(/\\\\/g, '/')\n}\n\n/**\n * Checks if a package name represents a local plugin (starts with ~/).\n *\n * @param packageName - The package name to check\n * @returns True if the package is a local plugin\n *\n * @example\n * ```ts\n * isLocalPlugin('~/plugins/my-plugin') // Returns: true\n * isLocalPlugin('@my-org/my-plugin') // Returns: false\n * isLocalPlugin('my-plugin') // Returns: false\n * ```\n */\nexport function isLocalPlugin(packageName: string): boolean {\n return packageName.startsWith('~/')\n}\n\n/**\n * Resolves a local plugin path to an absolute path.\n * Strips the ~/ prefix and joins with the current working directory.\n *\n * @param packageName - The local plugin package name (must start with ~/)\n * @returns The absolute path to the local plugin\n *\n * @example\n * ```ts\n * // If cwd is /Users/project\n * resolveLocalPath('~/plugins/my-plugin')\n * // Returns: '/Users/project/plugins/my-plugin'\n * ```\n */\nexport function resolveLocalPath(packageName: string): string {\n return path.join(process.cwd(), packageName.replace('~/', ''))\n}\n\n/**\n * Resolves an npm package path to the node_modules directory.\n *\n * @param packageName - The npm package name\n * @returns The absolute path to the package in node_modules\n *\n * @example\n * ```ts\n * // If cwd is /Users/project\n * resolveNpmPath('@my-org/my-plugin')\n * // Returns: '/Users/project/node_modules/@my-org/my-plugin'\n * ```\n */\nexport function resolveNpmPath(packageName: string): string {\n return path.join(process.cwd(), 'node_modules', packageName)\n}\n","import type { ResolvedPackage, WorkbenchPlugin } from './types'\nimport { isLocalPlugin, normalizePath, resolveLocalPath, resolveNpmPath } from './utils'\n\n/**\n * Resolves a plugin package to its absolute path and creates an alias.\n *\n * @param plugin - The plugin configuration to resolve\n * @returns Resolved package information including path and alias\n *\n * @example\n * ```ts\n * // Local plugin\n * resolvePluginPackage({ packageName: '~/plugins/my-plugin' })\n * // Returns: {\n * // packageName: '~/plugins/my-plugin',\n * // resolvedPath: '/Users/project/plugins/my-plugin',\n * // isLocal: true,\n * // alias: '~/plugins/my-plugin'\n * // }\n *\n * // NPM package\n * resolvePluginPackage({ packageName: '@org/plugin' })\n * // Returns: {\n * // packageName: '@org/plugin',\n * // resolvedPath: '/Users/project/node_modules/@org/plugin',\n * // isLocal: false,\n * // alias: '@org/plugin'\n * // }\n * ```\n */\nexport function resolvePluginPackage(plugin: WorkbenchPlugin): ResolvedPackage {\n const { packageName } = plugin\n const local = isLocalPlugin(packageName)\n\n const resolvedPath = local ? resolveLocalPath(packageName) : resolveNpmPath(packageName)\n\n return {\n packageName,\n resolvedPath: normalizePath(resolvedPath),\n isLocal: local,\n alias: packageName,\n }\n}\n\n/**\n * Resolves all plugin packages and creates a Vite alias configuration.\n *\n * @param plugins - Array of plugin configurations\n * @returns Vite alias configuration object\n *\n * @example\n * ```ts\n * const plugins = [\n * { packageName: '~/plugins/local' },\n * { packageName: '@org/npm-plugin' }\n * ]\n * const aliases = createAliasConfig(plugins)\n * // Returns: {\n * // '~/plugins/local': '/Users/project/plugins/local',\n * // '@org/npm-plugin': '/Users/project/node_modules/@org/npm-plugin'\n * // }\n * ```\n */\nexport function createAliasConfig(plugins: WorkbenchPlugin[]): Record<string, string> {\n // Get unique package names to avoid duplicate aliases\n const uniquePackages = Array.from(new Set(plugins.map((p) => p.packageName)))\n\n const aliases: Record<string, string> = {}\n\n for (const packageName of uniquePackages) {\n const resolved = resolvePluginPackage({ packageName } as WorkbenchPlugin)\n aliases[packageName] = resolved.resolvedPath\n }\n\n return aliases\n}\n\n/**\n * Resolves all plugins and returns their resolved package information.\n *\n * @param plugins - Array of plugin configurations\n * @returns Array of resolved package information\n */\nexport function resolveAllPlugins(plugins: WorkbenchPlugin[]): ResolvedPackage[] {\n return plugins.map((plugin) => resolvePluginPackage(plugin))\n}\n\n/**\n * Gets the unique set of package names from plugins.\n *\n * @param plugins - Array of plugin configurations\n * @returns Array of unique package names\n */\nexport function getUniquePackageNames(plugins: WorkbenchPlugin[]): string[] {\n return Array.from(new Set(plugins.map((p) => p.packageName)))\n}\n","import { getUniquePackageNames } from './resolver'\nimport type { WorkbenchPlugin } from './types'\n\n/**\n * Generates import statements for all unique plugin packages.\n *\n * @param packages - Array of unique package names\n * @returns JavaScript code string with import statements\n *\n * @example\n * ```ts\n * generateImports(['@org/plugin-1', '~/plugins/local'])\n * // Returns:\n * // import * as plugin_0 from '@org/plugin-1'\n * // import * as plugin_1 from '~/plugins/local'\n * ```\n */\nexport function generateImports(packages: string[]): string {\n return packages.map((packageName, index) => `import * as plugin_${index} from '${packageName}'`).join('\\n')\n}\n\n/**\n * Generates the package map that links package names to their imported modules.\n *\n * @param packages - Array of unique package names\n * @returns JavaScript code string defining the package map\n *\n * @example\n * ```ts\n * generatePackageMap(['@org/plugin-1', '~/plugins/local'])\n * // Returns: const packageMap = {'@org/plugin-1': plugin_0,'~/plugins/local': plugin_1}\n * ```\n */\nexport function generatePackageMap(packages: string[]): string {\n const entries = packages.map((packageName, index) => `'${packageName}': plugin_${index}`)\n return `const packageMap = {${entries.join(',')}}`\n}\n\n/**\n * Generates the plugin transformation logic that processes plugin configurations.\n *\n * @param plugins - Array of plugin configurations\n * @returns JavaScript code string with plugin processing logic\n */\nexport function generatePluginLogic(plugins: WorkbenchPlugin[]): string {\n return `\n const motiaPlugins = ${JSON.stringify(plugins)}\n\n export const plugins = motiaPlugins.map((plugin) => {\n const component = packageMap[plugin.packageName]\n const config = component.config || {}\n const componentName = config.componentName || plugin.componentName\n\n return {\n label: plugin.label || config.label || 'Plugin label',\n labelIcon: plugin.labelIcon || config.labelIcon || 'toy-brick',\n position: plugin.position || config.position || 'top',\n props: plugin.props || config.props || {},\n component: componentName ? component[componentName] : component.default,\n }\n })\n`\n}\n\n/**\n * Generates the complete virtual module code for all plugins.\n * This is the main code generation function that combines all parts.\n *\n * @param plugins - Array of plugin configurations\n * @returns Complete JavaScript code string for the virtual module\n *\n * @example\n * ```ts\n * const plugins = [\n * { packageName: '@test/plugin', label: 'Test' }\n * ]\n * const code = generatePluginCode(plugins)\n * // Returns complete module code with imports, map, and logic\n * ```\n */\nexport function generatePluginCode(plugins: WorkbenchPlugin[]): string {\n if (!plugins || plugins.length === 0) {\n return 'export const plugins = []'\n }\n\n const packages = getUniquePackageNames(plugins)\n const imports = generateImports(packages)\n const packageMap = generatePackageMap(packages)\n const logic = generatePluginLogic(plugins)\n\n return `${imports}\n${packageMap}\n${logic}`\n}\n\n/**\n * Generates CSS imports for plugins that specify cssImports.\n *\n * @param plugins - Array of plugin configurations\n * @returns CSS import statements as a string\n *\n * @example\n * ```ts\n * const plugins = [\n * { packageName: '@test/plugin', cssImports: ['styles.css', 'theme.css'] }\n * ]\n * generateCssImports(plugins)\n * // Returns:\n * // @import 'styles.css';\n * // @import 'theme.css';\n * ```\n */\nexport function generateCssImports(plugins: WorkbenchPlugin[]): string {\n const cssImports = plugins\n .flatMap((plugin) => plugin.cssImports || [])\n .filter((cssImport) => cssImport && cssImport.trim() !== '')\n .map((cssImport) => `@import '${cssImport}';`)\n\n return cssImports.join('\\n')\n}\n\n/**\n * Checks if the generated code is valid (non-empty and has content).\n *\n * @param code - The generated code to check\n * @returns True if code is valid\n */\nexport function isValidCode(code: string): boolean {\n return typeof code === 'string' && code.trim().length > 0\n}\n","/**\n * Configuration for a single workbench plugin.\n * This interface defines how plugins are registered and configured in the Motia workbench.\n */\nexport interface WorkbenchPlugin {\n /**\n * The package name or local path to the plugin.\n * - For npm packages: use the package name (e.g., '@my-org/my-plugin')\n * - For local plugins: use the tilde prefix (e.g., '~/plugins/my-plugin')\n */\n packageName: string\n\n /**\n * Optional named export to use from the plugin package.\n * If not specified, the default export will be used.\n * Can be overridden by the plugin's own config.\n */\n componentName?: string\n\n /**\n * Position where the plugin tab should appear in the workbench.\n * - 'top': Display in the top tab bar\n * - 'bottom': Display in the bottom tab bar\n * @default 'top'\n */\n position?: 'top' | 'bottom'\n\n /**\n * Display label for the plugin tab.\n * Can be overridden by the plugin's own config.\n */\n label?: string\n\n /**\n * Icon name from lucide-react to display next to the label.\n * Can be overridden by the plugin's own config.\n * @default 'toy-brick'\n */\n labelIcon?: string\n\n /**\n * Array of CSS package imports to inject into the workbench.\n * These will be added to the main index.css file.\n * Example: ['@my-org/my-plugin/styles.css']\n */\n cssImports?: string[]\n\n /**\n * Props to pass to the plugin component when it's rendered.\n * Can be overridden by the plugin's own config.\n */\n props?: Record<string, any>\n}\n\n/**\n * Result of validating a plugin configuration.\n */\nexport interface ValidationResult {\n /**\n * Whether the validation passed\n */\n valid: boolean\n\n /**\n * Array of error messages if validation failed\n */\n errors: string[]\n\n /**\n * Array of warning messages for non-critical issues\n */\n warnings: string[]\n\n /**\n * The validated and normalized plugin configuration (if valid)\n */\n plugin?: WorkbenchPlugin\n}\n\n/**\n * Context object passed to various plugin internals functions.\n * Contains shared state and configuration.\n */\nexport interface PluginContext {\n /**\n * Array of plugin configurations\n */\n plugins: WorkbenchPlugin[]\n\n /**\n * Vite dev server instance (only available in dev mode)\n */\n server?: any\n}\n\n/**\n * Package resolution result.\n */\nexport interface ResolvedPackage {\n /**\n * The original package name from the configuration\n */\n packageName: string\n\n /**\n * Resolved absolute path to the package\n */\n resolvedPath: string\n\n /**\n * Whether this is a local plugin (starts with ~/)\n */\n isLocal: boolean\n\n /**\n * Alias to use for imports\n */\n alias: string\n}\n\n/**\n * Generated virtual module exports interface.\n * This is what consumers will import from 'virtual:motia-plugins'.\n */\nexport interface VirtualModuleExports {\n /**\n * Array of processed plugin configurations ready to be registered\n */\n plugins: ProcessedPlugin[]\n}\n\n/**\n * A plugin configuration after processing and normalization.\n * This is the format used by the workbench to register tabs.\n */\nexport interface ProcessedPlugin {\n /**\n * Display label for the plugin tab\n */\n label: string\n\n /**\n * Icon name from lucide-react\n */\n labelIcon: string\n\n /**\n * Position in the workbench ('top' or 'bottom')\n */\n position: 'top' | 'bottom'\n\n /**\n * Props to pass to the component\n */\n props: Record<string, any>\n\n /**\n * The React component to render\n */\n component: any\n}\n\n/**\n * Type guard to check if position is valid.\n */\nexport function isValidPosition(position: any): position is 'top' | 'bottom' {\n return position === 'top' || position === 'bottom'\n}\n\n/**\n * Constants used throughout the plugin system.\n */\nexport const CONSTANTS = {\n /**\n * Virtual module ID for importing plugins\n */\n VIRTUAL_MODULE_ID: 'virtual:motia-plugins',\n\n /**\n * Resolved virtual module ID (with null byte prefix for Vite)\n */\n RESOLVED_VIRTUAL_MODULE_ID: '\\0virtual:motia-plugins',\n\n /**\n * Log prefix for all plugin messages\n */\n LOG_PREFIX: '[motia-plugins]',\n\n /**\n * Default values for optional plugin fields\n */\n DEFAULTS: {\n POSITION: 'top' as const,\n LABEL: 'Plugin label',\n ICON: 'toy-brick',\n PROPS: {},\n },\n} as const\n","import type { Printer } from '@motiadev/core'\nimport path from 'path'\nimport type { HmrContext, ModuleNode } from 'vite'\nimport { resolvePluginPackage } from './resolver'\nimport type { WorkbenchPlugin } from './types'\nimport { CONSTANTS } from './types'\nimport { isLocalPlugin, normalizePath } from './utils'\n\nconst WATCHED_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.css', '.scss', '.less']\n\nexport function isConfigFile(file: string): boolean {\n const normalizedFile = normalizePath(file)\n return normalizedFile.endsWith('motia.config.ts') || normalizedFile.endsWith('motia.config.js')\n}\n\n/**\n * Checks if a file change should trigger HMR for plugins.\n *\n * @param file - The file path that changed\n * @param plugins - Current plugin configurations\n * @returns True if the change affects plugins\n */\nexport function shouldInvalidatePlugins(file: string, plugins: WorkbenchPlugin[]): boolean {\n const normalizedFile = normalizePath(file)\n const absoluteFile = path.isAbsolute(normalizedFile) ? normalizedFile : path.resolve(process.cwd(), normalizedFile)\n\n if (isConfigFile(file)) {\n return true\n }\n\n const hasWatchedExtension = WATCHED_EXTENSIONS.some((ext) => absoluteFile.endsWith(ext))\n if (!hasWatchedExtension) {\n return false\n }\n\n for (const plugin of plugins) {\n if (isLocalPlugin(plugin.packageName)) {\n const resolved = resolvePluginPackage(plugin)\n const pluginAbsolutePath = path.isAbsolute(resolved.resolvedPath)\n ? resolved.resolvedPath\n : path.resolve(process.cwd(), resolved.resolvedPath)\n\n const normalizedPluginPath = pluginAbsolutePath.endsWith(path.sep)\n ? pluginAbsolutePath\n : `${pluginAbsolutePath}${path.sep}`\n\n if (absoluteFile.startsWith(normalizedPluginPath) || absoluteFile === pluginAbsolutePath) {\n return true\n }\n }\n }\n\n return false\n}\n\n/**\n * Handles hot updates for the plugin system.\n * This function is called by Vite's handleHotUpdate hook.\n *\n * @param ctx - Vite's HMR context\n * @param plugins - Current plugin configurations\n * @param printer - Printer instance for logging\n * @returns Array of modules to update, or undefined to continue with default behavior\n */\nexport function handlePluginHotUpdate(\n ctx: HmrContext,\n plugins: WorkbenchPlugin[],\n printer: Printer,\n): ModuleNode[] | undefined {\n const { file, server, timestamp } = ctx\n\n printer.printPluginLog(`HMR: File changed: ${normalizePath(file)}`)\n\n if (isConfigFile(file)) {\n printer.printPluginLog('HMR: Config file changed, triggering full page reload')\n printer.printPluginWarn(\n 'Configuration changes require a server restart for full effect. Please restart the dev server to apply all changes.',\n )\n server.ws.send({\n type: 'full-reload',\n path: '*',\n })\n return\n }\n\n if (!shouldInvalidatePlugins(file, plugins)) {\n printer.printPluginLog('HMR: Change outside plugin scope, delegating to Vite default handling')\n return\n }\n\n printer.printPluginLog('HMR: Plugin change detected, invalidating virtual module')\n\n const virtualModule = server.moduleGraph.getModuleById(CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID)\n\n if (!virtualModule) {\n printer.printPluginWarn('HMR: Virtual module not found, triggering full reload as fallback')\n server.ws.send({\n type: 'full-reload',\n path: '*',\n })\n return\n }\n\n server.moduleGraph.invalidateModule(virtualModule, new Set(), timestamp)\n printer.printPluginLog('HMR: Virtual module invalidated')\n\n const modulesToUpdateSet = new Set<ModuleNode>([virtualModule])\n const processedModules = new Set<ModuleNode>([virtualModule])\n\n for (const importer of virtualModule.importers) {\n if (!processedModules.has(importer)) {\n processedModules.add(importer)\n modulesToUpdateSet.add(importer)\n server.moduleGraph.invalidateModule(importer, new Set(), timestamp)\n }\n }\n\n const modulesToUpdate = Array.from(modulesToUpdateSet)\n\n printer.printPluginLog(`HMR: Updated ${modulesToUpdate.length} module(s)`)\n\n return modulesToUpdate\n}\n","import { existsSync } from 'fs'\nimport { z } from 'zod'\nimport type { ValidationResult, WorkbenchPlugin } from './types'\nimport { CONSTANTS, isValidPosition } from './types'\nimport { isLocalPlugin, resolveLocalPath } from './utils'\n\n/**\n * Zod schema for WorkbenchPlugin configuration.\n * Provides runtime type validation with detailed error messages.\n */\nconst WorkbenchPluginSchema = z.object({\n packageName: z\n .string()\n .min(1, 'packageName is required and cannot be empty')\n .refine((name) => name.startsWith('~/') || name.startsWith('@') || /^[a-z0-9-_]+$/i.test(name), {\n message: 'packageName must be a valid npm package name or local path (starting with ~/)',\n }),\n\n componentName: z.string().optional(),\n\n position: z\n .enum(['top', 'bottom'])\n .optional()\n .refine((pos) => pos === undefined || isValidPosition(pos), {\n message: 'position must be either \"top\" or \"bottom\"',\n }),\n\n label: z.string().optional(),\n\n labelIcon: z.string().optional(),\n\n cssImports: z.array(z.string()).optional(),\n\n props: z.record(z.any(), z.any()).optional(),\n})\n\n/**\n * Validates a single plugin configuration.\n *\n * @param plugin - The plugin configuration to validate\n * @param index - The index of the plugin in the array (for error messages)\n * @returns A validation result with errors, warnings, and normalized plugin\n */\nexport function validatePluginConfig(plugin: any, index: number): ValidationResult {\n const errors: string[] = []\n const warnings: string[] = []\n\n if (typeof plugin !== 'object' || plugin === null) {\n return {\n valid: false,\n errors: [`Plugin at index ${index}: expected object, got ${typeof plugin}`],\n warnings: [],\n }\n }\n\n try {\n const result = WorkbenchPluginSchema.safeParse(plugin)\n\n if (!result.success) {\n result.error.issues.forEach((err: z.core.$ZodIssue) => {\n const path = err.path.join('.')\n errors.push(`Plugin at index ${index}, field \"${path}\": ${err.message}`)\n })\n\n return { valid: false, errors, warnings }\n }\n\n const validatedPlugin = result.data as WorkbenchPlugin\n\n if (isLocalPlugin(validatedPlugin.packageName)) {\n const resolvedPath = resolveLocalPath(validatedPlugin.packageName)\n if (!existsSync(resolvedPath)) {\n warnings.push(\n `Plugin at index ${index}: local path \"${validatedPlugin.packageName}\" does not exist at \"${resolvedPath}\". ` +\n `Make sure the path is correct relative to the project root.`,\n )\n }\n }\n\n if (!validatedPlugin.label) {\n warnings.push(`Plugin at index ${index}: \"label\" not specified, will use default \"${CONSTANTS.DEFAULTS.LABEL}\"`)\n }\n\n if (!validatedPlugin.labelIcon) {\n warnings.push(\n `Plugin at index ${index}: \"labelIcon\" not specified, will use default \"${CONSTANTS.DEFAULTS.ICON}\"`,\n )\n }\n\n if (!validatedPlugin.position) {\n warnings.push(\n `Plugin at index ${index}: \"position\" not specified, will use default \"${CONSTANTS.DEFAULTS.POSITION}\"`,\n )\n }\n\n if (validatedPlugin.props && Object.keys(validatedPlugin.props).length === 0) {\n warnings.push(`Plugin at index ${index}: \"props\" is an empty object`)\n }\n\n if (validatedPlugin.cssImports) {\n if (validatedPlugin.cssImports.length === 0) {\n warnings.push(`Plugin at index ${index}: \"cssImports\" is an empty array`)\n }\n\n validatedPlugin.cssImports.forEach((cssImport, cssIndex) => {\n if (!cssImport || cssImport.trim() === '') {\n warnings.push(`Plugin at index ${index}: cssImport at index ${cssIndex} is empty or whitespace`)\n }\n })\n }\n\n return {\n valid: true,\n errors: [],\n warnings,\n plugin: validatedPlugin,\n }\n } catch (error) {\n return {\n valid: false,\n errors: [`Plugin at index ${index}: unexpected validation error: ${error}`],\n warnings: [],\n }\n }\n}\n\n/**\n * Validates an array of plugin configurations.\n *\n * @param plugins - Array of plugin configurations to validate\n * @param options - Validation options\n * @returns Combined validation result for all plugins\n */\nexport function validatePlugins(plugins: any[], options: { failFast?: boolean } = {}): ValidationResult {\n const allErrors: string[] = []\n const allWarnings: string[] = []\n const validatedPlugins: WorkbenchPlugin[] = []\n\n if (!Array.isArray(plugins)) {\n return {\n valid: false,\n errors: [`Expected plugins to be an array, got ${typeof plugins}`],\n warnings: [],\n }\n }\n\n if (plugins.length === 0) {\n console.warn('[motia-plugins] No plugins provided to validate')\n return {\n valid: true,\n errors: [],\n warnings: ['No plugins configured'],\n }\n }\n\n for (let i = 0; i < plugins.length; i++) {\n const result = validatePluginConfig(plugins[i], i)\n\n allErrors.push(...result.errors)\n allWarnings.push(...result.warnings)\n\n if (result.valid && result.plugin) {\n validatedPlugins.push(result.plugin)\n }\n\n if (options.failFast && result.errors.length > 0) {\n break\n }\n }\n\n const packageNames = validatedPlugins.map((p) => p.packageName)\n const duplicates = packageNames.filter((name, index) => packageNames.indexOf(name) !== index)\n\n if (duplicates.length > 0) {\n const uniqueDuplicates = [...new Set(duplicates)]\n uniqueDuplicates.forEach((dup) => {\n allWarnings.push(`Duplicate package name found: \"${dup}\". This may cause conflicts.`)\n })\n }\n\n const valid = allErrors.length === 0\n\n if (valid) {\n console.log(`[motia-plugins] ✓ Validated ${validatedPlugins.length} plugin(s) successfully`)\n if (allWarnings.length > 0) {\n console.warn(`[motia-plugins] Found ${allWarnings.length} warning(s)`)\n }\n } else {\n console.error(`[motia-plugins] ✗ Validation failed with ${allErrors.length} error(s)`)\n }\n\n return {\n valid,\n errors: allErrors,\n warnings: allWarnings,\n }\n}\n","import { Printer } from '@motiadev/core'\nimport path from 'path'\nimport type { Plugin, ViteDevServer } from 'vite'\nimport { generateCssImports, generatePluginCode, isValidCode } from './generator'\nimport { handlePluginHotUpdate } from './hmr'\nimport { createAliasConfig, resolvePluginPackage } from './resolver'\nimport type { WorkbenchPlugin } from './types'\nimport { CONSTANTS } from './types'\nimport { isLocalPlugin, normalizePath } from './utils'\nimport { validatePlugins } from './validator'\n\n/**\n * Vite plugin for loading and managing Motia workbench plugins.\n *\n * Features:\n * - Hot Module Replacement (HMR) support\n * - Runtime validation with detailed error messages\n * - Verbose logging for debugging\n * - CSS injection for plugin styles\n *\n * @param plugins - Array of plugin configurations\n * @param options - Optional loader configuration\n * @returns Vite plugin instance\n *\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [\n * motiaPluginsPlugin([\n * { packageName: '@my-org/plugin', label: 'My Plugin' }\n * ])\n * ]\n * })\n * ```\n */\nconst printer = new Printer(process.cwd())\n\nexport default function motiaPluginsPlugin(plugins: WorkbenchPlugin[]): Plugin {\n let devServer: ViteDevServer | null = null\n\n try {\n const validationResult = validatePlugins(plugins, {\n failFast: false,\n })\n\n if (!validationResult.valid) {\n printer.printPluginError('Plugin configuration validation failed:')\n for (const err of validationResult.errors) {\n printer.printPluginError(` ${err}`)\n }\n throw new Error('Invalid plugin configuration. See errors above.')\n }\n\n if (validationResult.warnings.length > 0) {\n for (const warning of validationResult.warnings) {\n printer.printPluginWarn(warning)\n }\n }\n } catch (error) {\n printer.printPluginError(`Failed to validate plugins: ${error}`)\n throw error\n }\n\n const alias = createAliasConfig(plugins)\n\n printer.printPluginLog(`Initialized with ${plugins.length} plugin(s)`)\n\n return {\n name: 'vite-plugin-motia-plugins',\n enforce: 'pre',\n\n buildStart() {\n printer.printPluginLog('Build started')\n },\n\n config: () => ({\n resolve: {\n alias,\n },\n }),\n\n configureServer(server) {\n devServer = server\n printer.printPluginLog('Dev server configured, HMR enabled')\n\n const configPaths = [path.join(process.cwd(), 'motia.config.ts'), path.join(process.cwd(), 'motia.config.js')]\n\n for (const configPath of configPaths) {\n server.watcher.add(configPath)\n }\n printer.printPluginLog('Watching for config file changes')\n\n const localPlugins = plugins.filter((p) => isLocalPlugin(p.packageName))\n if (localPlugins.length > 0) {\n printer.printPluginLog(`Watching ${localPlugins.length} local plugin(s)`)\n\n for (const plugin of localPlugins) {\n const resolved = resolvePluginPackage(plugin)\n const watchPath = resolved.resolvedPath\n\n server.watcher.add(watchPath)\n printer.printPluginLog(`Watching: ${watchPath}`)\n }\n\n server.watcher.on('change', (file) => {\n const normalizedFile = normalizePath(file)\n printer.printPluginLog(`File watcher detected change: ${normalizedFile}`)\n })\n\n server.watcher.on('add', (file) => {\n const normalizedFile = normalizePath(file)\n printer.printPluginLog(`File watcher detected new file: ${normalizedFile}`)\n })\n }\n },\n\n resolveId(id) {\n if (id === CONSTANTS.VIRTUAL_MODULE_ID) {\n return CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID\n }\n },\n\n load(id) {\n if (id !== CONSTANTS.RESOLVED_VIRTUAL_MODULE_ID) {\n return null\n }\n\n printer.printPluginLog('Loading plugins virtual module')\n printer.printPluginLog('Generating plugin code...')\n\n const code = generatePluginCode(plugins)\n\n if (!isValidCode(code)) {\n printer.printPluginError('Generated code is invalid or empty')\n return 'export const plugins = []'\n }\n\n printer.printPluginLog('Plugin code generated successfully')\n\n return code\n },\n\n async transform(code, id) {\n const normalizedId = normalizePath(id)\n\n if (!normalizedId.endsWith('src/index.css')) {\n return null\n }\n\n printer.printPluginLog('Injecting plugin CSS imports')\n\n const cssImports = generateCssImports(plugins)\n\n if (!cssImports) {\n return null\n }\n\n return {\n code: `${cssImports}\\n${code}`,\n map: null,\n }\n },\n\n handleHotUpdate(ctx) {\n if (!devServer) {\n printer.printPluginWarn('HMR: Dev server not available')\n return\n }\n\n const modulesToUpdate = handlePluginHotUpdate(ctx, plugins, printer)\n\n if (modulesToUpdate && modulesToUpdate.length > 0) {\n const merged = Array.from(new Set([...(ctx.modules || []), ...modulesToUpdate]))\n printer.printPluginLog(`HMR: Successfully updated ${merged.length} module(s)`)\n return merged\n }\n },\n\n buildEnd() {\n printer.printPluginLog('Build ended')\n },\n }\n}\n","import react from '@vitejs/plugin-react'\nimport type { Express, NextFunction, Request, Response } from 'express'\nimport fs from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\nimport { createServer as createViteServer } from 'vite'\nimport motiaPluginsPlugin from './motia-plugin/index.js'\nimport type { WorkbenchPlugin } from './motia-plugin/types.js'\n\nconst workbenchBasePlugin = (workbenchBase: string) => {\n return {\n name: 'html-transform',\n transformIndexHtml: (html: string) => {\n return html.replace('</head>', `<script>const workbenchBase = ${JSON.stringify(workbenchBase)};</script></head>`)\n },\n }\n}\n\nconst processCwdPlugin = () => {\n return {\n name: 'html-transform',\n transformIndexHtml: (html: string) => {\n // Normalize path for cross-platform compatibility\n const cwd = process.cwd().replace(/\\\\/g, '/')\n return html.replace('</head>', `<script>const processCwd = \"${cwd}\";</script></head>`)\n },\n }\n}\n\nconst reoPlugin = () => {\n return {\n name: 'html-transform',\n transformIndexHtml(html: string) {\n const isAnalyticsEnabled = process.env.MOTIA_ANALYTICS_DISABLED !== 'true'\n\n if (!isAnalyticsEnabled) {\n return html\n }\n\n // inject before </head>\n return html.replace(\n '</head>',\n `\n <script type=\"text/javascript\">\n !function(){var e,t,n;e=\"d8f0ce9cae8ae64\",t=function(){Reo.init({clientID:\"d8f0ce9cae8ae64\", source: \"internal\"})},(n=document.createElement(\"script\")).src=\"https://static.reo.dev/\"+e+\"/reo.js\",n.defer=!0,n.onload=t,document.head.appendChild(n)}();\n </script>\n </head>`,\n )\n },\n }\n}\n\nexport type ApplyMiddlewareParams = {\n app: Express\n port: number\n workbenchBase: string\n plugins: WorkbenchPlugin[]\n}\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\n\nexport const applyMiddleware = async ({ app, port, workbenchBase, plugins }: ApplyMiddlewareParams) => {\n const vite = await createViteServer({\n appType: 'spa',\n root: __dirname,\n base: workbenchBase,\n server: {\n middlewareMode: true,\n allowedHosts: true,\n host: true,\n hmr: { port: 21678 + port },\n fs: {\n allow: [\n __dirname, // workbench root\n path.join(process.cwd(), './steps'), // steps directory\n path.join(process.cwd(), './src'), // src directory\n path.join(process.cwd(), './tutorial'), // tutorial directory\n path.join(process.cwd(), './node_modules'), // node_modules directory\n path.join(__dirname, './node_modules'), // node_modules directory\n ],\n },\n },\n resolve: {\n alias: {\n '@': path.resolve(__dirname, './src'),\n '@/assets': path.resolve(__dirname, './src/assets'),\n },\n },\n plugins: [\n react(),\n processCwdPlugin(),\n reoPlugin(),\n motiaPluginsPlugin(plugins),\n workbenchBasePlugin(workbenchBase),\n ],\n assetsInclude: ['**/*.png', '**/*.jpg', '**/*.jpeg', '**/*.gif', '**/*.svg', '**/*.ico', '**/*.webp', '**/*.avif'],\n })\n\n app.use(workbenchBase, vite.middlewares)\n app.use(`${workbenchBase}/*`, async (req: Request, res: Response, next: NextFunction) => {\n const url = req.originalUrl\n\n try {\n const index = fs.readFileSync(path.resolve(__dirname, 'index.html'), 'utf-8')\n const html = await vite.transformIndexHtml(url, index)\n\n res.status(200).set({ 'Content-Type': 'text/html' }).end(html)\n } catch (e) {\n next(e)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeA,SAAgBC,cAAcC,UAA0B;AACtD,QAAOA,SAASC,QAAQ,OAAO,IAAI;;;;;;;;;;;;;;;AAgBrC,SAAgBC,cAAcC,aAA8B;AAC1D,QAAOA,YAAYC,WAAW,KAAK;;;;;;;;;;;;;;;;AAiBrC,SAAgBC,iBAAiBF,aAA6B;AAC5D,QAAOL,KAAKQ,KAAKC,QAAQC,KAAK,EAAEL,YAAYF,QAAQ,MAAM,GAAG,CAAC;;;;;;;;;;;;;;;AAgBhE,SAAgBQ,eAAeN,aAA6B;AAC1D,QAAOL,KAAKQ,KAAKC,QAAQC,KAAK,EAAE,gBAAgBL,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACtC9D,SAAgBa,qBAAq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
2
  import type React from 'react'
3
3
  import { memo, useEffect } from 'react'
4
- import { useMotiaConfigStore } from '../../stores/use-motia-config-store'
5
4
  // @ts-expect-error: PNG asset types
6
- import motiaLogoDark from '../assets/motia-dark.png'
5
+ import motiaLogoDark from '../../assets/motia-dark.png'
7
6
  // @ts-expect-error: PNG asset types
8
- import motiaLogoLight from '../assets/motia-light.png'
7
+ import motiaLogoLight from '../../assets/motia-light.png'
8
+ import { useMotiaConfigStore } from '../../stores/use-motia-config-store'
9
9
  import { Tutorial } from '../tutorial/tutorial'
10
10
  import { TutorialButton } from '../tutorial/tutorial-button'
11
11
  import { ThemeToggle } from '../ui/theme-toggle'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@motiadev/workbench",
3
3
  "description": "A web-based interface for building and managing Motia workflows.",
4
- "version": "0.13.0-beta.162-315243",
4
+ "version": "0.13.0-beta.162-158257",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -51,9 +51,9 @@
51
51
  "vite": "^7.2.4",
52
52
  "zod": "^4.1.13",
53
53
  "zustand": "^5.0.8",
54
- "@motiadev/core": "0.13.0-beta.162-315243",
55
- "@motiadev/ui": "0.13.0-beta.162-315243",
56
- "@motiadev/stream-client-react": "0.13.0-beta.162-315243"
54
+ "@motiadev/stream-client-react": "0.13.0-beta.162-158257",
55
+ "@motiadev/ui": "0.13.0-beta.162-158257",
56
+ "@motiadev/core": "0.13.0-beta.162-158257"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@bosh-code/tsdown-plugin-inject-css": "^2.0.0",