@motiadev/workbench 0.8.2-beta.140-709523 → 0.8.2-beta.140-504654
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.
- package/dist/motia-plugin/hmr.d.ts +4 -1
- package/dist/motia-plugin/hmr.js +77 -27
- package/dist/motia-plugin/index.d.ts +0 -24
- package/dist/motia-plugin/index.js +50 -16
- package/dist/src/App.js +18 -16
- package/dist/src/lib/plugins.d.ts +2 -1
- package/dist/src/lib/plugins.js +3 -3
- package/dist/src/stores/use-app-tabs-store.d.ts +0 -2
- package/dist/src/stores/use-app-tabs-store.js +0 -6
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/tsconfig.node.tsbuildinfo +1 -1
- package/motia-plugin/hmr.ts +90 -28
- package/motia-plugin/index.ts +59 -20
- package/package.json +4 -4
package/motia-plugin/index.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Printer } from '@motiadev/core'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import type { Plugin, ViteDevServer } from 'vite'
|
|
2
4
|
import { generateCssImports, generatePluginCode, isValidCode } from './generator'
|
|
3
5
|
import { handlePluginHotUpdate } from './hmr'
|
|
4
|
-
import { createAliasConfig } from './resolver'
|
|
6
|
+
import { createAliasConfig, resolvePluginPackage } from './resolver'
|
|
5
7
|
import type { WorkbenchPlugin } from './types'
|
|
6
8
|
import { CONSTANTS } from './types'
|
|
7
|
-
import { normalizePath } from './utils'
|
|
9
|
+
import { isLocalPlugin, normalizePath } from './utils'
|
|
8
10
|
import { validatePlugins } from './validator'
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -31,8 +33,10 @@ import { validatePlugins } from './validator'
|
|
|
31
33
|
* })
|
|
32
34
|
* ```
|
|
33
35
|
*/
|
|
36
|
+
const printer = new Printer(process.cwd())
|
|
37
|
+
|
|
34
38
|
export default function motiaPluginsPlugin(plugins: WorkbenchPlugin[]): Plugin {
|
|
35
|
-
let devServer:
|
|
39
|
+
let devServer: ViteDevServer | null = null
|
|
36
40
|
|
|
37
41
|
try {
|
|
38
42
|
const validationResult = validatePlugins(plugins, {
|
|
@@ -40,29 +44,33 @@ export default function motiaPluginsPlugin(plugins: WorkbenchPlugin[]): Plugin {
|
|
|
40
44
|
})
|
|
41
45
|
|
|
42
46
|
if (!validationResult.valid) {
|
|
43
|
-
|
|
44
|
-
validationResult.errors
|
|
47
|
+
printer.printPluginError('Plugin configuration validation failed:')
|
|
48
|
+
for (const err of validationResult.errors) {
|
|
49
|
+
printer.printPluginError(` ${err}`)
|
|
50
|
+
}
|
|
45
51
|
throw new Error('Invalid plugin configuration. See errors above.')
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
if (validationResult.warnings.length > 0) {
|
|
49
|
-
|
|
55
|
+
for (const warning of validationResult.warnings) {
|
|
56
|
+
printer.printPluginWarn(warning)
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
} catch (error) {
|
|
52
|
-
|
|
60
|
+
printer.printPluginError(`Failed to validate plugins: ${error}`)
|
|
53
61
|
throw error
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
const alias = createAliasConfig(plugins)
|
|
57
65
|
|
|
58
|
-
|
|
66
|
+
printer.printPluginLog(`Initialized with ${plugins.length} plugin(s)`)
|
|
59
67
|
|
|
60
68
|
return {
|
|
61
69
|
name: 'vite-plugin-motia-plugins',
|
|
62
70
|
enforce: 'pre',
|
|
63
71
|
|
|
64
72
|
buildStart() {
|
|
65
|
-
|
|
73
|
+
printer.printPluginLog('Build started')
|
|
66
74
|
},
|
|
67
75
|
|
|
68
76
|
config: () => ({
|
|
@@ -73,7 +81,37 @@ export default function motiaPluginsPlugin(plugins: WorkbenchPlugin[]): Plugin {
|
|
|
73
81
|
|
|
74
82
|
configureServer(server) {
|
|
75
83
|
devServer = server
|
|
76
|
-
|
|
84
|
+
printer.printPluginLog('Dev server configured, HMR enabled')
|
|
85
|
+
|
|
86
|
+
const configPaths = [path.join(process.cwd(), 'motia.config.ts'), path.join(process.cwd(), 'motia.config.js')]
|
|
87
|
+
|
|
88
|
+
for (const configPath of configPaths) {
|
|
89
|
+
server.watcher.add(configPath)
|
|
90
|
+
}
|
|
91
|
+
printer.printPluginLog('Watching for config file changes')
|
|
92
|
+
|
|
93
|
+
const localPlugins = plugins.filter((p) => isLocalPlugin(p.packageName))
|
|
94
|
+
if (localPlugins.length > 0) {
|
|
95
|
+
printer.printPluginLog(`Watching ${localPlugins.length} local plugin(s)`)
|
|
96
|
+
|
|
97
|
+
for (const plugin of localPlugins) {
|
|
98
|
+
const resolved = resolvePluginPackage(plugin)
|
|
99
|
+
const watchPath = resolved.resolvedPath
|
|
100
|
+
|
|
101
|
+
server.watcher.add(watchPath)
|
|
102
|
+
printer.printPluginLog(`Watching: ${watchPath}`)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
server.watcher.on('change', (file) => {
|
|
106
|
+
const normalizedFile = normalizePath(file)
|
|
107
|
+
printer.printPluginLog(`File watcher detected change: ${normalizedFile}`)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
server.watcher.on('add', (file) => {
|
|
111
|
+
const normalizedFile = normalizePath(file)
|
|
112
|
+
printer.printPluginLog(`File watcher detected new file: ${normalizedFile}`)
|
|
113
|
+
})
|
|
114
|
+
}
|
|
77
115
|
},
|
|
78
116
|
|
|
79
117
|
resolveId(id) {
|
|
@@ -87,17 +125,17 @@ export default function motiaPluginsPlugin(plugins: WorkbenchPlugin[]): Plugin {
|
|
|
87
125
|
return null
|
|
88
126
|
}
|
|
89
127
|
|
|
90
|
-
|
|
91
|
-
|
|
128
|
+
printer.printPluginLog('Loading plugins virtual module')
|
|
129
|
+
printer.printPluginLog('Generating plugin code...')
|
|
92
130
|
|
|
93
131
|
const code = generatePluginCode(plugins)
|
|
94
132
|
|
|
95
133
|
if (!isValidCode(code)) {
|
|
96
|
-
|
|
134
|
+
printer.printPluginError('Generated code is invalid or empty')
|
|
97
135
|
return 'export const plugins = []'
|
|
98
136
|
}
|
|
99
137
|
|
|
100
|
-
|
|
138
|
+
printer.printPluginLog('Plugin code generated successfully')
|
|
101
139
|
|
|
102
140
|
return code
|
|
103
141
|
},
|
|
@@ -109,7 +147,7 @@ export default function motiaPluginsPlugin(plugins: WorkbenchPlugin[]): Plugin {
|
|
|
109
147
|
return null
|
|
110
148
|
}
|
|
111
149
|
|
|
112
|
-
|
|
150
|
+
printer.printPluginLog('Injecting plugin CSS imports')
|
|
113
151
|
|
|
114
152
|
const cssImports = generateCssImports(plugins)
|
|
115
153
|
|
|
@@ -125,19 +163,20 @@ export default function motiaPluginsPlugin(plugins: WorkbenchPlugin[]): Plugin {
|
|
|
125
163
|
|
|
126
164
|
handleHotUpdate(ctx) {
|
|
127
165
|
if (!devServer) {
|
|
166
|
+
printer.printPluginWarn('HMR: Dev server not available')
|
|
128
167
|
return
|
|
129
168
|
}
|
|
130
169
|
|
|
131
|
-
const modulesToUpdate = handlePluginHotUpdate(ctx, plugins)
|
|
170
|
+
const modulesToUpdate = handlePluginHotUpdate(ctx, plugins, printer)
|
|
132
171
|
|
|
133
|
-
if (modulesToUpdate) {
|
|
134
|
-
|
|
172
|
+
if (modulesToUpdate && modulesToUpdate.length > 0) {
|
|
173
|
+
printer.printPluginLog(`HMR: Successfully updated ${modulesToUpdate.length} module(s)`)
|
|
135
174
|
return modulesToUpdate
|
|
136
175
|
}
|
|
137
176
|
},
|
|
138
177
|
|
|
139
178
|
buildEnd() {
|
|
140
|
-
|
|
179
|
+
printer.printPluginLog('Build ended')
|
|
141
180
|
},
|
|
142
181
|
}
|
|
143
182
|
}
|
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.8.2-beta.140-
|
|
4
|
+
"version": "0.8.2-beta.140-504654",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@monaco-editor/react": "^4.6.1",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"vite": "^6.3.5",
|
|
44
44
|
"zod": "^3.24.1",
|
|
45
45
|
"zustand": "^5.0.6",
|
|
46
|
-
"@motiadev/core": "0.8.2-beta.140-
|
|
47
|
-
"@motiadev/
|
|
48
|
-
"@motiadev/
|
|
46
|
+
"@motiadev/core": "0.8.2-beta.140-504654",
|
|
47
|
+
"@motiadev/stream-client-react": "0.8.2-beta.140-504654",
|
|
48
|
+
"@motiadev/ui": "0.8.2-beta.140-504654"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@testing-library/jest-dom": "^6.6.3",
|