@motiadev/workbench 0.7.1-beta.132 → 0.7.2-beta.133

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.
@@ -1,2 +1,2 @@
1
1
  import type { Express } from 'express';
2
- export declare const applyMiddleware: (app: Express, port: number) => Promise<void>;
2
+ export declare const applyMiddleware: (app: Express, port: number, workbenchBase?: string) => Promise<void>;
@@ -35,10 +35,11 @@ const reoPlugin = () => {
35
35
  },
36
36
  };
37
37
  };
38
- const applyMiddleware = async (app, port) => {
38
+ const applyMiddleware = async (app, port, workbenchBase = '') => {
39
39
  const vite = await (0, vite_1.createServer)({
40
40
  appType: 'spa',
41
41
  root: __dirname,
42
+ base: workbenchBase,
42
43
  server: {
43
44
  middlewareMode: true,
44
45
  allowedHosts: true,
@@ -54,14 +55,17 @@ const applyMiddleware = async (app, port) => {
54
55
  },
55
56
  },
56
57
  resolve: {
57
- alias: { '@': path_1.default.resolve(__dirname, './src') },
58
+ alias: {
59
+ '@': path_1.default.resolve(__dirname, './src'),
60
+ '@/assets': path_1.default.resolve(__dirname, './src/assets'),
61
+ },
58
62
  },
59
63
  plugins: [(0, plugin_react_1.default)(), processCwdPlugin(), reoPlugin()],
64
+ assetsInclude: ['**/*.png', '**/*.jpg', '**/*.jpeg', '**/*.gif', '**/*.svg', '**/*.ico', '**/*.webp', '**/*.avif'],
60
65
  });
61
- app.use(vite.middlewares);
62
- app.use('*', async (req, res, next) => {
66
+ app.use(workbenchBase, vite.middlewares);
67
+ app.use(`${workbenchBase}/*`, async (req, res, next) => {
63
68
  const url = req.originalUrl;
64
- console.log('[UI] Request', { url });
65
69
  try {
66
70
  const index = fs_1.default.readFileSync(path_1.default.resolve(__dirname, 'index.html'), 'utf-8');
67
71
  const html = await vite.transformIndexHtml(url, index);
package/dist/src/App.js CHANGED
@@ -12,7 +12,6 @@ import { LogsPage } from './components/logs/logs-page';
12
12
  import { TracesPage } from './components/observability/traces-page';
13
13
  import { APP_SIDEBAR_CONTAINER_ID } from './components/sidebar/sidebar';
14
14
  import { StatesPage } from './components/states/states-page';
15
- import { Tutorial } from './components/tutorial/tutorial';
16
15
  import { useTabsStore } from './stores/use-tabs-store';
17
16
  var TabLocation;
18
17
  (function (TabLocation) {
@@ -53,5 +52,5 @@ export const App = () => {
53
52
  },
54
53
  ] }) }), _jsx("div", { id: APP_SIDEBAR_CONTAINER_ID })] }));
55
54
  }
56
- return (_jsxs("div", { className: "grid grid-rows-[auto_1fr] grid-cols-[1fr_auto] bg-background text-foreground h-screen", children: [_jsx("div", { className: "col-span-2", children: _jsx(Header, {}) }), _jsx("main", { className: "m-2 overflow-hidden", role: "main", children: _jsxs(CollapsiblePanelGroup, { autoSaveId: "app-panel", direction: "vertical", className: "gap-1 h-full", "aria-label": "Workbench panels", children: [_jsxs(CollapsiblePanel, { id: "top-panel", variant: 'tabs', defaultTab: tab.top, onTabChange: onTabChange(TabLocation.TOP), header: _jsxs(TabsList, { children: [_jsx(TabsTrigger, { value: "flow", "data-testid": "flows-link", children: _jsx(FlowTabMenuItem, {}) }), _jsxs(TabsTrigger, { value: "endpoint", "data-testid": "endpoints-link", className: "cursor-pointer", children: [_jsx(Link2, {}), "Endpoint"] })] }), children: [_jsx(TabsContent, { value: "flow", className: "h-full", asChild: true, children: _jsx(ReactFlowProvider, { children: _jsx(FlowPage, {}) }) }), _jsx(TabsContent, { value: "endpoint", asChild: true, children: _jsx(EndpointsPage, {}) })] }), _jsxs(CollapsiblePanel, { id: "bottom-panel", variant: 'tabs', defaultTab: tab.bottom, onTabChange: onTabChange(TabLocation.BOTTOM), header: _jsxs(TabsList, { children: [_jsxs(TabsTrigger, { value: "tracing", "data-testid": "traces-link", className: "cursor-pointer", children: [_jsx(GanttChart, {}), " Tracing"] }), _jsxs(TabsTrigger, { value: "logs", "data-testid": "logs-link", className: "cursor-pointer", children: [_jsx(LogsIcon, {}), "Logs"] }), _jsxs(TabsTrigger, { value: "states", "data-testid": "states-link", className: "cursor-pointer", children: [_jsx(File, {}), "States"] })] }), children: [_jsx(TabsContent, { value: "tracing", className: "max-h-fit", asChild: true, children: _jsx(TracesPage, {}) }), _jsx(TabsContent, { value: "logs", asChild: true, children: _jsx(LogsPage, {}) }), _jsx(TabsContent, { value: "states", asChild: true, children: _jsx(StatesPage, {}) })] })] }) }), _jsx("div", { id: APP_SIDEBAR_CONTAINER_ID }), _jsx(Tutorial, {})] }));
55
+ return (_jsxs("div", { className: "grid grid-rows-[auto_1fr] grid-cols-[1fr_auto] bg-background text-foreground h-screen", children: [_jsx("div", { className: "col-span-2", children: _jsx(Header, {}) }), _jsx("main", { className: "m-2 overflow-hidden", role: "main", children: _jsxs(CollapsiblePanelGroup, { autoSaveId: "app-panel", direction: "vertical", className: "gap-1 h-full", "aria-label": "Workbench panels", children: [_jsxs(CollapsiblePanel, { id: "top-panel", variant: 'tabs', defaultTab: tab.top, onTabChange: onTabChange(TabLocation.TOP), header: _jsxs(TabsList, { children: [_jsx(TabsTrigger, { value: "flow", "data-testid": "flows-link", children: _jsx(FlowTabMenuItem, {}) }), _jsxs(TabsTrigger, { value: "endpoint", "data-testid": "endpoints-link", className: "cursor-pointer", children: [_jsx(Link2, {}), "Endpoint"] })] }), children: [_jsx(TabsContent, { value: "flow", className: "h-full", asChild: true, children: _jsx(ReactFlowProvider, { children: _jsx(FlowPage, {}) }) }), _jsx(TabsContent, { value: "endpoint", asChild: true, children: _jsx(EndpointsPage, {}) })] }), _jsxs(CollapsiblePanel, { id: "bottom-panel", variant: 'tabs', defaultTab: tab.bottom, onTabChange: onTabChange(TabLocation.BOTTOM), header: _jsxs(TabsList, { children: [_jsxs(TabsTrigger, { value: "tracing", "data-testid": "traces-link", className: "cursor-pointer", children: [_jsx(GanttChart, {}), " Tracing"] }), _jsxs(TabsTrigger, { value: "logs", "data-testid": "logs-link", className: "cursor-pointer", children: [_jsx(LogsIcon, {}), "Logs"] }), _jsxs(TabsTrigger, { value: "states", "data-testid": "states-link", className: "cursor-pointer", children: [_jsx(File, {}), "States"] })] }), children: [_jsx(TabsContent, { value: "tracing", className: "max-h-fit", asChild: true, children: _jsx(TracesPage, {}) }), _jsx(TabsContent, { value: "logs", asChild: true, children: _jsx(LogsPage, {}) }), _jsx(TabsContent, { value: "states", asChild: true, children: _jsx(StatesPage, {}) })] })] }) }), _jsx("div", { id: APP_SIDEBAR_CONTAINER_ID })] }));
57
56
  };
File without changes
@@ -1,6 +1,6 @@
1
1
  export declare const useStateStream: (object: Record<string, any> | undefined) => {
2
2
  data: {};
3
- originalData: {
3
+ originalData: any[] | {
4
4
  [x: string]: any;
5
5
  };
6
6
  isStreamed: boolean;
@@ -2,7 +2,7 @@ import { useStreamItem } from '@motiadev/stream-client-react';
2
2
  export const useStateStream = (object) => {
3
3
  const { __motia, ...rest } = object || {};
4
4
  const { data } = useStreamItem(__motia);
5
- const originalData = rest || object;
5
+ const originalData = Array.isArray(object) ? object : rest || object;
6
6
  return {
7
7
  data: data || originalData,
8
8
  originalData,
@@ -32,7 +32,6 @@ async function importFlow(flow, flowConfig) {
32
32
  return;
33
33
  }
34
34
  try {
35
- console.log(path);
36
35
  const module = await import(/* @vite-ignore */ `/@fs/${path}`);
37
36
  const component = module.Node ?? module.default;
38
37
  nodeComponentCache.set(path, component);
@@ -113,7 +112,6 @@ export const useGetFlowState = (flow, flowConfig) => {
113
112
  return acc;
114
113
  }, {});
115
114
  if (!isEqual(steps, lastSavedConfigRef.current)) {
116
- console.log('steps', steps, lastSavedConfigRef.current);
117
115
  lastSavedConfigRef.current = steps;
118
116
  const newConfig = { id: flowIdRef.current, config: steps };
119
117
  try {
@@ -1,17 +1,25 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useState } from 'react';
2
+ import motiaLogoDark from '@/assets/motia-dark.png';
3
+ import motiaLogoLight from '@/assets/motia-light.png';
3
4
  import { useThemeStore } from '@/stores/use-theme-store';
4
- import { ThemeToggle } from '../ui/theme-toggle';
5
+ import { useEffect, useState } from 'react';
6
+ import { Tutorial } from '../tutorial/tutorial';
5
7
  import { TutorialButton } from '../tutorial/tutorial-button';
8
+ import { ThemeToggle } from '../ui/theme-toggle';
6
9
  import { DeployButton } from './deploy-button';
7
10
  export const Header = () => {
8
11
  const [isDevMode, setIsDevMode] = useState(false);
12
+ const [isTutorialDisabled, setIsTutorialDisabled] = useState(true);
9
13
  const theme = useThemeStore((state) => state.theme);
14
+ const logo = theme === 'light' ? motiaLogoLight : motiaLogoDark;
10
15
  useEffect(() => {
11
16
  fetch('/__motia')
12
17
  .then((res) => res.json())
13
- .then((data) => setIsDevMode(data.isDev))
18
+ .then((data) => {
19
+ setIsDevMode(data.isDev);
20
+ setIsTutorialDisabled(data.isTutorialDisabled);
21
+ })
14
22
  .catch((err) => console.error(err));
15
23
  }, []);
16
- return (_jsxs("header", { className: "min-h-16 px-4 gap-4 flex items-center bg-default text-default-foreground border-b", children: [_jsx("img", { src: `/motia-${theme}.png`, className: "h-5", id: "logo-icon", "data-testid": "logo-icon" }), _jsx("div", { className: "flex-1" }), _jsx(ThemeToggle, {}), isDevMode && _jsx(TutorialButton, {}), isDevMode && _jsx(DeployButton, {})] }));
24
+ return (_jsxs("header", { className: "min-h-16 px-4 gap-4 flex items-center bg-default text-default-foreground border-b", children: [_jsx("img", { src: logo, className: "h-5", id: "logo-icon", "data-testid": "logo-icon" }), _jsx("div", { className: "flex-1" }), _jsx(ThemeToggle, {}), isDevMode && !isTutorialDisabled && _jsx(TutorialButton, {}), isDevMode && _jsx(DeployButton, {}), !isTutorialDisabled && _jsx(Tutorial, {})] }));
17
25
  };
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
2
2
  export const useGetStateItems = () => {
3
3
  const [items, setItems] = useState([]);
4
4
  useEffect(() => {
5
- fetch('/motia/state')
5
+ fetch('/__motia/state')
6
6
  .then(async (res) => {
7
7
  if (res.ok) {
8
8
  return res.json();
@@ -24,7 +24,7 @@ export const StateEditor = ({ state }) => {
24
24
  try {
25
25
  setIsRequestLoading(true);
26
26
  setSaveStatus('idle');
27
- const response = await fetch('/motia/state', {
27
+ const response = await fetch('/__motia/state', {
28
28
  method: 'POST',
29
29
  headers: {
30
30
  'Content-Type': 'application/json',
@@ -12,7 +12,7 @@ export const BaseNode = ({ title, variant, children, disableSourceHandle, disabl
12
12
  const [content, setContent] = useState(null);
13
13
  const [features, setFeatures] = useState([]);
14
14
  const fetchContent = useCallback(async () => {
15
- const response = await fetch(`/step/${data.id}`);
15
+ const response = await fetch(`/__motia/step/${data.id}`);
16
16
  const responseData = await response.json();
17
17
  setContent(responseData.content);
18
18
  setFeatures(responseData.features);
@@ -4,6 +4,6 @@ module.exports = {
4
4
  content: [
5
5
  path.resolve(__dirname, './index.html'),
6
6
  path.resolve(__dirname, './src/**/*.{ts,tsx,js,jsx}'),
7
- path.resolve(process.cwd(), './steps/**/*.tsx'),
7
+ path.resolve(process.cwd(), './steps/**/*.{tsx,jsx}'),
8
8
  ],
9
9
  }