@motiadev/plugin-states 0.8.2-beta.140-111855
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/dist/api.d.ts +3 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/components/json-editor.d.ts +13 -0
- package/dist/components/json-editor.d.ts.map +1 -0
- package/dist/components/state-details.d.ts +8 -0
- package/dist/components/state-details.d.ts.map +1 -0
- package/dist/components/state-editor.d.ts +8 -0
- package/dist/components/state-editor.d.ts.map +1 -0
- package/dist/components/state-sidebar.d.ts +9 -0
- package/dist/components/state-sidebar.d.ts.map +1 -0
- package/dist/components/state-tab-label.d.ts +2 -0
- package/dist/components/state-tab-label.d.ts.map +1 -0
- package/dist/components/states-page.d.ts +2 -0
- package/dist/components/states-page.d.ts.map +1 -0
- package/dist/hooks/states-hooks.d.ts +9 -0
- package/dist/hooks/states-hooks.d.ts.map +1 -0
- package/dist/index.cjs +22 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +536 -0
- package/dist/plugin-states.css +1 -0
- package/dist/plugin.cjs +1 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +80 -0
- package/dist/stores/use-states-store.d.ts +6 -0
- package/dist/stores/use-states-store.d.ts.map +1 -0
- package/dist/types/state.d.ts +7 -0
- package/dist/types/state.d.ts.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Motia
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @motiadev/plugin-states
|
|
2
|
+
|
|
3
|
+
This package provides React components for the Motia workbench states functionality.
|
|
4
|
+
|
|
5
|
+
## TailwindCSS Compilation
|
|
6
|
+
|
|
7
|
+
This package includes TailwindCSS compilation to ensure all Tailwind classes used in the components are properly compiled and available.
|
|
8
|
+
|
|
9
|
+
### Build Process
|
|
10
|
+
|
|
11
|
+
The build process includes two steps:
|
|
12
|
+
|
|
13
|
+
1. **CSS Compilation**: Compiles `src/styles.css` using PostCSS and TailwindCSS
|
|
14
|
+
2. **TypeScript Compilation**: Compiles TypeScript files to JavaScript
|
|
15
|
+
|
|
16
|
+
### Development
|
|
17
|
+
|
|
18
|
+
- `pnpm run build` - Build both CSS and TypeScript
|
|
19
|
+
- `pnpm run dev` - Watch mode for both CSS and TypeScript
|
|
20
|
+
- `pnpm run build:css` - Build only CSS
|
|
21
|
+
- `pnpm run dev:css` - Watch mode for CSS only
|
|
22
|
+
|
|
23
|
+
### Configuration Files
|
|
24
|
+
|
|
25
|
+
- `src/styles.css` - Main CSS entry point with Tailwind imports
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- **StatesPage**: Main states page component with search, filtering, and bulk delete
|
|
30
|
+
- **StateSidebar**: Sidebar component for viewing and editing state details
|
|
31
|
+
- **StateDetails**: Read-only JSON view of state values
|
|
32
|
+
- **StateEditor**: JSON editor for modifying state values with validation
|
|
33
|
+
- **useGetStateItems**: Hook for fetching and managing state items
|
|
34
|
+
- **useStatesStore**: Zustand store for managing states UI state
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwC,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAE9F,eAAO,MAAM,GAAG,GAAI,OAAO,kBAAkB,KAAG,IAuE/C,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
type JsonEditorProps = {
|
|
3
|
+
value: string;
|
|
4
|
+
height?: number | string;
|
|
5
|
+
schema?: Record<string, unknown>;
|
|
6
|
+
onChange?: (value: string) => void;
|
|
7
|
+
onValidate?: (isValid: boolean) => void;
|
|
8
|
+
language?: string;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const JsonEditor: FC<JsonEditorProps>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=json-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-editor.d.ts","sourceRoot":"","sources":["../../src/components/json-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAsB,MAAM,OAAO,CAAA;AAEnD,KAAK,eAAe,GAAG;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAmD1C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-details.d.ts","sourceRoot":"","sources":["../../src/components/state-details.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAiE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-editor.d.ts","sourceRoot":"","sources":["../../src/components/state-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA0JvC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { StateItem } from '../types/state';
|
|
3
|
+
type Props = {
|
|
4
|
+
state: StateItem;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const StateSidebar: React.FC<Props>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=state-sidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-sidebar.d.ts","sourceRoot":"","sources":["../../src/components/state-sidebar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAI/C,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,SAAS,CAAA;IAChB,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAmBxC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-tab-label.d.ts","sourceRoot":"","sources":["../../src/components/state-tab-label.tsx"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,oFAKzB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"states-page.d.ts","sourceRoot":"","sources":["../../src/components/states-page.tsx"],"names":[],"mappings":"AAmBA,eAAO,MAAM,UAAU,+CAwHtB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StateItem } from '../types/state';
|
|
2
|
+
type Output = {
|
|
3
|
+
items: StateItem[];
|
|
4
|
+
deleteItems: (ids: string[]) => void;
|
|
5
|
+
refetch: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const useGetStateItems: () => Output;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=states-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"states-hooks.d.ts","sourceRoot":"","sources":["../../src/hooks/states-hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,KAAK,MAAM,GAAG;IACZ,KAAK,EAAE,SAAS,EAAE,CAAA;IAClB,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACpC,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAO,MA6BnC,CAAA"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react"),l=require("@motiadev/ui"),k=require("lucide-react"),oe=require("zustand"),le=require("react18-json-view"),G=require("@monaco-editor/react");var A={exports:{}},I={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var H;function ce(){if(H)return I;H=1;var a=Symbol.for("react.transitional.element"),u=Symbol.for("react.fragment");function d(x,n,c){var b=null;if(c!==void 0&&(b=""+c),n.key!==void 0&&(b=""+n.key),"key"in n){c={};for(var i in n)i!=="key"&&(c[i]=n[i])}else c=n;return n=c.ref,{$$typeof:a,type:x,key:b,ref:n!==void 0?n:null,props:c}}return I.Fragment=u,I.jsx=d,I.jsxs=d,I}var P={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var B;function ie(){return B||(B=1,process.env.NODE_ENV!=="production"&&function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===se?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case R:return"Fragment";case _:return"Profiler";case t:return"StrictMode";case K:return"Suspense";case ee:return"SuspenseList";case te:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case O:return"Portal";case j:return(e.displayName||"Context")+".Provider";case N:return(e._context.displayName||"Context")+".Consumer";case Q:var s=e.render;return e=e.displayName,e||(e=s.displayName||s.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case re:return s=e.displayName||null,s!==null?s:a(e.type)||"Memo";case Y:s=e._payload,e=e._init;try{return a(e(s))}catch{}}return null}function u(e){return""+e}function d(e){try{u(e);var s=!1}catch{s=!0}if(s){s=console;var o=s.error,m=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return o.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",m),u(e)}}function x(e){if(e===R)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===Y)return"<...>";try{var s=a(e);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function n(){var e=$.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function b(e){if(F.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function i(e,s){function o(){q||(q=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",s))}o.isReactWarning=!0,Object.defineProperty(e,"key",{get:o,configurable:!0})}function p(){var e=a(this.type);return V[e]||(V[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function v(e,s,o,m,T,S,J,L){return o=S.ref,e={$$typeof:w,type:e,key:s,props:S,_owner:T},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:p}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:L}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function f(e,s,o,m,T,S,J,L){var g=s.children;if(g!==void 0)if(m)if(ae(g)){for(m=0;m<g.length;m++)y(g[m]);Object.freeze&&Object.freeze(g)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else y(g);if(F.call(s,"key")){g=a(e);var C=Object.keys(s).filter(function(ne){return ne!=="key"});m=0<C.length?"{key: someKey, "+C.join(": ..., ")+": ...}":"{key: someKey}",z[g+m]||(C=0<C.length?"{"+C.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,m,g,C,g),z[g+m]=!0)}if(g=null,o!==void 0&&(d(o),g=""+o),b(s)&&(d(s.key),g=""+s.key),"key"in s){o={};for(var M in s)M!=="key"&&(o[M]=s[M])}else o=s;return g&&i(o,typeof e=="function"?e.displayName||e.name||"Unknown":e),v(e,g,S,T,n(),o,J,L)}function y(e){typeof e=="object"&&e!==null&&e.$$typeof===w&&e._store&&(e._store.validated=1)}var E=h,w=Symbol.for("react.transitional.element"),O=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),t=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),j=Symbol.for("react.context"),Q=Symbol.for("react.forward_ref"),K=Symbol.for("react.suspense"),ee=Symbol.for("react.suspense_list"),re=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),te=Symbol.for("react.activity"),se=Symbol.for("react.client.reference"),$=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,ae=Array.isArray,D=console.createTask?console.createTask:function(){return null};E={react_stack_bottom_frame:function(e){return e()}};var q,V={},U=E.react_stack_bottom_frame.bind(E,c)(),W=D(x(c)),z={};P.Fragment=R,P.jsx=function(e,s,o,m,T){var S=1e4>$.recentlyCreatedOwnerStacks++;return f(e,s,o,!1,m,T,S?Error("react-stack-top-frame"):U,S?D(x(e)):W)},P.jsxs=function(e,s,o,m,T){var S=1e4>$.recentlyCreatedOwnerStacks++;return f(e,s,o,!0,m,T,S?Error("react-stack-top-frame"):U,S?D(x(e)):W)}}()),P}var X;function ue(){return X||(X=1,process.env.NODE_ENV==="production"?A.exports=ce():A.exports=ie()),A.exports}var r=ue();const de=()=>{const[a,u]=h.useState([]),d=h.useCallback(()=>{fetch("/__motia/state").then(async n=>{if(n.ok)return n.json();throw await n.json()}).then(u).catch(n=>console.error(n))},[]),x=n=>{fetch("/__motia/state/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:n})}).then(()=>d())};return h.useEffect(()=>{d()},[d]),{items:a,deleteItems:x,refetch:d}},Z=oe.create()(a=>({selectedStateId:void 0,selectStateId:u=>a({selectedStateId:u})})),fe=({state:a})=>r.jsx(le,{src:a.value,theme:"default"}),he=({value:a,height:u=300,schema:d,onChange:x,onValidate:n,language:c="json",readOnly:b=!1})=>{const i=G.useMonaco(),p=l.useThemeStore(f=>f.theme),v=h.useMemo(()=>p==="dark"?"vs-dark":"light",[p]);return h.useEffect(()=>{i&&(i.languages.typescript.javascriptDefaults.setCompilerOptions({isolatedModules:!0}),i.languages.json.jsonDefaults.setDiagnosticsOptions({schemas:d?[{uri:window.location.href,fileMatch:["*"],schema:d}]:[]}))},[i,d,c]),r.jsx(G,{"data-testid":"json-editor",height:u,language:c,value:a,theme:v,onChange:f=>{f||n?.(!1),x?.(f??"")},onValidate:f=>n?.(f.length===0),options:{readOnly:b,scrollBeyondLastLine:!1,minimap:{enabled:!1}}})},me=({state:a})=>{const[u,d]=h.useState(!1),[x,n]=h.useState(!0),[c,b]=h.useState(JSON.stringify(a.value,null,2)),[i,p]=h.useState(!1),[v,f]=h.useState("idle"),y=h.useRef(JSON.stringify(a.value,null,2));h.useEffect(()=>{b(JSON.stringify(a.value,null,2))},[a.value]);const E=h.useCallback(t=>{p(t!==y.current),b(t),f("idle")},[]),w=async()=>{if(!(!x||!i))try{d(!0),f("idle");const t=await fetch("/__motia/state",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:a.key,groupId:a.groupId,value:JSON.parse(c)})});if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);y.current=c,f("success"),p(!1),setTimeout(()=>{f("idle")},3e3)}catch(t){console.error("Failed to save state:",t),f("error")}finally{d(!1)}},O=h.useCallback(()=>{b(JSON.stringify(a.value,null,2)),p(!1),f("idle")},[a.value]),R=h.useMemo(()=>v==="success"?r.jsx("div",{className:"bg-green-50 dark:bg-green-950/20 border border-green-200 dark:border-green-800 rounded-lg p-2",children:r.jsxs("div",{className:"flex items-center gap-2 text-green-700 dark:text-green-400 text-sm",children:[r.jsx(k.Check,{className:"w-4 h-4"}),"State saved successfully!"]})}):v==="error"?r.jsx("div",{className:"bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-800 rounded-lg p-2",children:r.jsxs("div",{className:"flex items-center gap-2 text-red-700 dark:text-red-400 text-sm",children:[r.jsx(k.AlertCircle,{className:"w-4 h-4"}),"Failed to save state. Please try again."]})}):r.jsx("div",{className:"text-xs text-muted-foreground",children:i?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-2 h-2 bg-orange-500 rounded-full"}),"Unsaved changes"]}):r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),"Up to date"]})}),[v,i]);return r.jsxs("div",{className:"flex flex-col gap-2 h-full",children:[r.jsx("p",{className:"text-xs text-muted-foreground",children:"Modify the state value using the JSON editor below."}),r.jsx("div",{className:"space-y-3 pt-2 flex flex-col",children:r.jsxs("div",{className:"relative flex-1",children:[r.jsx(he,{value:c,onChange:E,onValidate:n,height:"calc(100vh - 300px)"}),!x&&r.jsxs("div",{className:"absolute top-2 right-2 bg-destructive/90 text-destructive-foreground px-2 py-1 rounded text-xs flex items-center gap-1",children:[r.jsx(k.AlertCircle,{className:"w-3 h-3"}),"Invalid JSON"]})]})}),r.jsxs("div",{className:"flex items-center justify-between pt-2",children:[R,r.jsxs("div",{className:"flex items-center gap-2",children:[i&&r.jsx(l.Button,{variant:"secondary",onClick:O,disabled:u,children:"Reset"}),r.jsx(l.Button,{onClick:w,variant:"accent",disabled:u||!x||!i,"data-testid":"state-save-button",children:u?r.jsxs(r.Fragment,{children:[r.jsx(k.Loader2,{className:"w-3 h-3 animate-spin mr-1"}),"Saving..."]}):r.jsxs(r.Fragment,{children:[r.jsx(k.Save,{className:"w-3 h-3 mr-1"}),"Save Changes"]})})]})]})]})},ge=({state:a,onClose:u})=>r.jsx(l.Sidebar,{onClose:u,title:"State Details",initialWidth:500,tabs:[{label:"Overview",content:r.jsx(fe,{state:a})},{label:"Editor",content:r.jsx(me,{state:a})}],actions:[{icon:r.jsx(k.X,{}),onClick:u,label:"Close"}]}),xe=()=>{const a=Z(t=>t.selectedStateId),u=Z(t=>t.selectStateId),{items:d,deleteItems:x,refetch:n}=de(),[c,b]=h.useState(""),i=h.useMemo(()=>d.filter(t=>t.groupId.toLowerCase().includes(c.toLowerCase())||t.key.toLowerCase().includes(c.toLowerCase())),[d,c]),p=h.useMemo(()=>a?i.find(t=>`${t.groupId}:${t.key}`===a):null,[i,a]),[v,f]=h.useState(new Set),y=t=>u(`${t.groupId}:${t.key}`),E=()=>u(void 0),w=()=>{x(Array.from(v)),f(new Set)},O=t=>{const _=v.has(`${t.groupId}:${t.key}`);f(N=>{const j=new Set(N);return _?j.delete(`${t.groupId}:${t.key}`):j.add(`${t.groupId}:${t.key}`),j})},R=t=>{f(_=>{const N=new Set(_);return t?i.forEach(j=>N.add(`${j.groupId}:${j.key}`)):i.forEach(j=>N.delete(`${j.groupId}:${j.key}`)),N})};return r.jsxs(r.Fragment,{children:[p&&r.jsx(ge,{state:p,onClose:E}),r.jsxs("div",{className:"grid grid-rows-[auto_1fr] h-full","data-testid":"states-container",children:[r.jsxs("div",{className:"flex p-2 border-b gap-2","data-testid":"logs-search-container",children:[r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(l.Input,{variant:"shade",value:c,onChange:t=>b(t.target.value),className:"px-9 font-medium",placeholder:"Search by Group ID or Key"}),r.jsx(k.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50"}),r.jsx(k.X,{className:"cursor-pointer absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 hover:text-muted-foreground",onClick:()=>b("")})]}),r.jsxs(l.Button,{variant:"default",className:"h-[34px]",disabled:v.size===0,onClick:w,children:[r.jsx(k.Trash,{})," Delete"]}),r.jsx(l.Button,{variant:"default",className:"h-[34px]",onClick:n,children:r.jsx(k.RefreshCw,{className:"w-4 h-4 text-muted-foreground"})})]}),r.jsxs(l.Table,{children:[r.jsx(l.TableHeader,{className:"sticky top-0 bg-background/20 backdrop-blur-sm",children:r.jsxs(l.TableRow,{children:[r.jsx(l.TableHead,{children:r.jsx(l.Checkbox,{onClick:t=>t.stopPropagation(),onCheckedChange:R})}),r.jsx(l.TableHead,{className:"rounded-0",children:"Group ID"}),r.jsx(l.TableHead,{children:"Key"}),r.jsx(l.TableHead,{children:"Type"})]})}),r.jsx(l.TableBody,{children:i.map(t=>r.jsxs(l.TableRow,{"data-testid":`item-${t}`,onClick:()=>y(t),className:l.cn("font-mono font-semibold cursor-pointer border-0",p===t?"bg-muted-foreground/10 hover:bg-muted-foreground/20":"hover:bg-muted-foreground/10"),children:[r.jsx(l.TableCell,{onClick:_=>_.stopPropagation(),children:r.jsx(l.Checkbox,{checked:v.has(`${t.groupId}:${t.key}`),onClick:()=>O(t)})}),r.jsx(l.TableCell,{className:"hover:bg-transparent",children:t.groupId}),r.jsx(l.TableCell,{className:"hover:bg-transparent",children:t.key}),r.jsx(l.TableCell,{className:"hover:bg-transparent",children:t.type})]},`${t.groupId}:${t.key}`))})]})]})]})};exports.StatesPage=xe;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
import me, { useState as S, useCallback as V, useEffect as U, useMemo as $, useRef as he } from "react";
|
|
2
|
+
import { useThemeStore as xe, Button as D, Sidebar as pe, Input as ge, Table as ve, TableHeader as be, TableRow as Z, TableHead as I, Checkbox as Q, TableBody as je, cn as ke, TableCell as P } from "@motiadev/ui";
|
|
3
|
+
import { Check as Se, AlertCircle as K, Loader2 as Ee, Save as ye, X as ae, Search as Te, Trash as _e, RefreshCw as Ne } from "lucide-react";
|
|
4
|
+
import { create as Re } from "zustand";
|
|
5
|
+
import we from "react18-json-view";
|
|
6
|
+
import Ce, { useMonaco as Oe } from "@monaco-editor/react";
|
|
7
|
+
var A = { exports: {} }, C = {};
|
|
8
|
+
/**
|
|
9
|
+
* @license React
|
|
10
|
+
* react-jsx-runtime.production.js
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the MIT license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/
|
|
17
|
+
var ee;
|
|
18
|
+
function Ie() {
|
|
19
|
+
if (ee) return C;
|
|
20
|
+
ee = 1;
|
|
21
|
+
var a = Symbol.for("react.transitional.element"), i = Symbol.for("react.fragment");
|
|
22
|
+
function d(h, n, l) {
|
|
23
|
+
var x = null;
|
|
24
|
+
if (l !== void 0 && (x = "" + l), n.key !== void 0 && (x = "" + n.key), "key" in n) {
|
|
25
|
+
l = {};
|
|
26
|
+
for (var c in n)
|
|
27
|
+
c !== "key" && (l[c] = n[c]);
|
|
28
|
+
} else l = n;
|
|
29
|
+
return n = l.ref, {
|
|
30
|
+
$$typeof: a,
|
|
31
|
+
type: h,
|
|
32
|
+
key: x,
|
|
33
|
+
ref: n !== void 0 ? n : null,
|
|
34
|
+
props: l
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return C.Fragment = i, C.jsx = d, C.jsxs = d, C;
|
|
38
|
+
}
|
|
39
|
+
var O = {};
|
|
40
|
+
/**
|
|
41
|
+
* @license React
|
|
42
|
+
* react-jsx-runtime.development.js
|
|
43
|
+
*
|
|
44
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
45
|
+
*
|
|
46
|
+
* This source code is licensed under the MIT license found in the
|
|
47
|
+
* LICENSE file in the root directory of this source tree.
|
|
48
|
+
*/
|
|
49
|
+
var re;
|
|
50
|
+
function Pe() {
|
|
51
|
+
return re || (re = 1, process.env.NODE_ENV !== "production" && function() {
|
|
52
|
+
function a(e) {
|
|
53
|
+
if (e == null) return null;
|
|
54
|
+
if (typeof e == "function")
|
|
55
|
+
return e.$$typeof === de ? null : e.displayName || e.name || null;
|
|
56
|
+
if (typeof e == "string") return e;
|
|
57
|
+
switch (e) {
|
|
58
|
+
case y:
|
|
59
|
+
return "Fragment";
|
|
60
|
+
case T:
|
|
61
|
+
return "Profiler";
|
|
62
|
+
case t:
|
|
63
|
+
return "StrictMode";
|
|
64
|
+
case oe:
|
|
65
|
+
return "Suspense";
|
|
66
|
+
case le:
|
|
67
|
+
return "SuspenseList";
|
|
68
|
+
case ie:
|
|
69
|
+
return "Activity";
|
|
70
|
+
}
|
|
71
|
+
if (typeof e == "object")
|
|
72
|
+
switch (typeof e.tag == "number" && console.error(
|
|
73
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
74
|
+
), e.$$typeof) {
|
|
75
|
+
case w:
|
|
76
|
+
return "Portal";
|
|
77
|
+
case v:
|
|
78
|
+
return (e.displayName || "Context") + ".Provider";
|
|
79
|
+
case _:
|
|
80
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
81
|
+
case ne:
|
|
82
|
+
var s = e.render;
|
|
83
|
+
return e = e.displayName, e || (e = s.displayName || s.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
84
|
+
case ce:
|
|
85
|
+
return s = e.displayName || null, s !== null ? s : a(e.type) || "Memo";
|
|
86
|
+
case W:
|
|
87
|
+
s = e._payload, e = e._init;
|
|
88
|
+
try {
|
|
89
|
+
return a(e(s));
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function i(e) {
|
|
96
|
+
return "" + e;
|
|
97
|
+
}
|
|
98
|
+
function d(e) {
|
|
99
|
+
try {
|
|
100
|
+
i(e);
|
|
101
|
+
var s = !1;
|
|
102
|
+
} catch {
|
|
103
|
+
s = !0;
|
|
104
|
+
}
|
|
105
|
+
if (s) {
|
|
106
|
+
s = console;
|
|
107
|
+
var o = s.error, f = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
108
|
+
return o.call(
|
|
109
|
+
s,
|
|
110
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
111
|
+
f
|
|
112
|
+
), i(e);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function h(e) {
|
|
116
|
+
if (e === y) return "<>";
|
|
117
|
+
if (typeof e == "object" && e !== null && e.$$typeof === W)
|
|
118
|
+
return "<...>";
|
|
119
|
+
try {
|
|
120
|
+
var s = a(e);
|
|
121
|
+
return s ? "<" + s + ">" : "<...>";
|
|
122
|
+
} catch {
|
|
123
|
+
return "<...>";
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function n() {
|
|
127
|
+
var e = J.A;
|
|
128
|
+
return e === null ? null : e.getOwner();
|
|
129
|
+
}
|
|
130
|
+
function l() {
|
|
131
|
+
return Error("react-stack-top-frame");
|
|
132
|
+
}
|
|
133
|
+
function x(e) {
|
|
134
|
+
if (q.call(e, "key")) {
|
|
135
|
+
var s = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
136
|
+
if (s && s.isReactWarning) return !1;
|
|
137
|
+
}
|
|
138
|
+
return e.key !== void 0;
|
|
139
|
+
}
|
|
140
|
+
function c(e, s) {
|
|
141
|
+
function o() {
|
|
142
|
+
G || (G = !0, console.error(
|
|
143
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
144
|
+
s
|
|
145
|
+
));
|
|
146
|
+
}
|
|
147
|
+
o.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
148
|
+
get: o,
|
|
149
|
+
configurable: !0
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function p() {
|
|
153
|
+
var e = a(this.type);
|
|
154
|
+
return z[e] || (z[e] = !0, console.error(
|
|
155
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
156
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
157
|
+
}
|
|
158
|
+
function g(e, s, o, f, k, b, Y, F) {
|
|
159
|
+
return o = b.ref, e = {
|
|
160
|
+
$$typeof: N,
|
|
161
|
+
type: e,
|
|
162
|
+
key: s,
|
|
163
|
+
props: b,
|
|
164
|
+
_owner: k
|
|
165
|
+
}, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
|
|
166
|
+
enumerable: !1,
|
|
167
|
+
get: p
|
|
168
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
169
|
+
configurable: !1,
|
|
170
|
+
enumerable: !1,
|
|
171
|
+
writable: !0,
|
|
172
|
+
value: 0
|
|
173
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
174
|
+
configurable: !1,
|
|
175
|
+
enumerable: !1,
|
|
176
|
+
writable: !0,
|
|
177
|
+
value: null
|
|
178
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
179
|
+
configurable: !1,
|
|
180
|
+
enumerable: !1,
|
|
181
|
+
writable: !0,
|
|
182
|
+
value: Y
|
|
183
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
184
|
+
configurable: !1,
|
|
185
|
+
enumerable: !1,
|
|
186
|
+
writable: !0,
|
|
187
|
+
value: F
|
|
188
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
189
|
+
}
|
|
190
|
+
function u(e, s, o, f, k, b, Y, F) {
|
|
191
|
+
var m = s.children;
|
|
192
|
+
if (m !== void 0)
|
|
193
|
+
if (f)
|
|
194
|
+
if (ue(m)) {
|
|
195
|
+
for (f = 0; f < m.length; f++)
|
|
196
|
+
E(m[f]);
|
|
197
|
+
Object.freeze && Object.freeze(m);
|
|
198
|
+
} else
|
|
199
|
+
console.error(
|
|
200
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
201
|
+
);
|
|
202
|
+
else E(m);
|
|
203
|
+
if (q.call(s, "key")) {
|
|
204
|
+
m = a(e);
|
|
205
|
+
var R = Object.keys(s).filter(function(fe) {
|
|
206
|
+
return fe !== "key";
|
|
207
|
+
});
|
|
208
|
+
f = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", B[m + f] || (R = 0 < R.length ? "{" + R.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
209
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
210
|
+
let props = %s;
|
|
211
|
+
<%s {...props} />
|
|
212
|
+
React keys must be passed directly to JSX without using spread:
|
|
213
|
+
let props = %s;
|
|
214
|
+
<%s key={someKey} {...props} />`,
|
|
215
|
+
f,
|
|
216
|
+
m,
|
|
217
|
+
R,
|
|
218
|
+
m
|
|
219
|
+
), B[m + f] = !0);
|
|
220
|
+
}
|
|
221
|
+
if (m = null, o !== void 0 && (d(o), m = "" + o), x(s) && (d(s.key), m = "" + s.key), "key" in s) {
|
|
222
|
+
o = {};
|
|
223
|
+
for (var M in s)
|
|
224
|
+
M !== "key" && (o[M] = s[M]);
|
|
225
|
+
} else o = s;
|
|
226
|
+
return m && c(
|
|
227
|
+
o,
|
|
228
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
229
|
+
), g(
|
|
230
|
+
e,
|
|
231
|
+
m,
|
|
232
|
+
b,
|
|
233
|
+
k,
|
|
234
|
+
n(),
|
|
235
|
+
o,
|
|
236
|
+
Y,
|
|
237
|
+
F
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
function E(e) {
|
|
241
|
+
typeof e == "object" && e !== null && e.$$typeof === N && e._store && (e._store.validated = 1);
|
|
242
|
+
}
|
|
243
|
+
var j = me, N = Symbol.for("react.transitional.element"), w = Symbol.for("react.portal"), y = Symbol.for("react.fragment"), t = Symbol.for("react.strict_mode"), T = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), v = Symbol.for("react.context"), ne = Symbol.for("react.forward_ref"), oe = Symbol.for("react.suspense"), le = Symbol.for("react.suspense_list"), ce = Symbol.for("react.memo"), W = Symbol.for("react.lazy"), ie = Symbol.for("react.activity"), de = Symbol.for("react.client.reference"), J = j.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, q = Object.prototype.hasOwnProperty, ue = Array.isArray, L = console.createTask ? console.createTask : function() {
|
|
244
|
+
return null;
|
|
245
|
+
};
|
|
246
|
+
j = {
|
|
247
|
+
react_stack_bottom_frame: function(e) {
|
|
248
|
+
return e();
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
var G, z = {}, H = j.react_stack_bottom_frame.bind(
|
|
252
|
+
j,
|
|
253
|
+
l
|
|
254
|
+
)(), X = L(h(l)), B = {};
|
|
255
|
+
O.Fragment = y, O.jsx = function(e, s, o, f, k) {
|
|
256
|
+
var b = 1e4 > J.recentlyCreatedOwnerStacks++;
|
|
257
|
+
return u(
|
|
258
|
+
e,
|
|
259
|
+
s,
|
|
260
|
+
o,
|
|
261
|
+
!1,
|
|
262
|
+
f,
|
|
263
|
+
k,
|
|
264
|
+
b ? Error("react-stack-top-frame") : H,
|
|
265
|
+
b ? L(h(e)) : X
|
|
266
|
+
);
|
|
267
|
+
}, O.jsxs = function(e, s, o, f, k) {
|
|
268
|
+
var b = 1e4 > J.recentlyCreatedOwnerStacks++;
|
|
269
|
+
return u(
|
|
270
|
+
e,
|
|
271
|
+
s,
|
|
272
|
+
o,
|
|
273
|
+
!0,
|
|
274
|
+
f,
|
|
275
|
+
k,
|
|
276
|
+
b ? Error("react-stack-top-frame") : H,
|
|
277
|
+
b ? L(h(e)) : X
|
|
278
|
+
);
|
|
279
|
+
};
|
|
280
|
+
}()), O;
|
|
281
|
+
}
|
|
282
|
+
var te;
|
|
283
|
+
function Ae() {
|
|
284
|
+
return te || (te = 1, process.env.NODE_ENV === "production" ? A.exports = Ie() : A.exports = Pe()), A.exports;
|
|
285
|
+
}
|
|
286
|
+
var r = Ae();
|
|
287
|
+
const $e = () => {
|
|
288
|
+
const [a, i] = S([]), d = V(() => {
|
|
289
|
+
fetch("/__motia/state").then(async (n) => {
|
|
290
|
+
if (n.ok)
|
|
291
|
+
return n.json();
|
|
292
|
+
throw await n.json();
|
|
293
|
+
}).then(i).catch((n) => console.error(n));
|
|
294
|
+
}, []), h = (n) => {
|
|
295
|
+
fetch("/__motia/state/delete", {
|
|
296
|
+
method: "POST",
|
|
297
|
+
headers: { "Content-Type": "application/json" },
|
|
298
|
+
body: JSON.stringify({ ids: n })
|
|
299
|
+
}).then(() => d());
|
|
300
|
+
};
|
|
301
|
+
return U(() => {
|
|
302
|
+
d();
|
|
303
|
+
}, [d]), { items: a, deleteItems: h, refetch: d };
|
|
304
|
+
}, se = Re()((a) => ({
|
|
305
|
+
selectedStateId: void 0,
|
|
306
|
+
selectStateId: (i) => a({ selectedStateId: i })
|
|
307
|
+
})), De = ({ state: a }) => /* @__PURE__ */ r.jsx(we, { src: a.value, theme: "default" }), Je = ({
|
|
308
|
+
value: a,
|
|
309
|
+
height: i = 300,
|
|
310
|
+
schema: d,
|
|
311
|
+
onChange: h,
|
|
312
|
+
onValidate: n,
|
|
313
|
+
language: l = "json",
|
|
314
|
+
readOnly: x = !1
|
|
315
|
+
}) => {
|
|
316
|
+
const c = Oe(), p = xe((u) => u.theme), g = $(() => p === "dark" ? "vs-dark" : "light", [p]);
|
|
317
|
+
return U(() => {
|
|
318
|
+
c && (c.languages.typescript.javascriptDefaults.setCompilerOptions({ isolatedModules: !0 }), c.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
319
|
+
schemas: d ? [
|
|
320
|
+
{
|
|
321
|
+
uri: window.location.href,
|
|
322
|
+
fileMatch: ["*"],
|
|
323
|
+
schema: d
|
|
324
|
+
}
|
|
325
|
+
] : []
|
|
326
|
+
}));
|
|
327
|
+
}, [c, d, l]), /* @__PURE__ */ r.jsx(
|
|
328
|
+
Ce,
|
|
329
|
+
{
|
|
330
|
+
"data-testid": "json-editor",
|
|
331
|
+
height: i,
|
|
332
|
+
language: l,
|
|
333
|
+
value: a,
|
|
334
|
+
theme: g,
|
|
335
|
+
onChange: (u) => {
|
|
336
|
+
u || n?.(!1), h?.(u ?? "");
|
|
337
|
+
},
|
|
338
|
+
onValidate: (u) => n?.(u.length === 0),
|
|
339
|
+
options: {
|
|
340
|
+
readOnly: x,
|
|
341
|
+
scrollBeyondLastLine: !1,
|
|
342
|
+
minimap: { enabled: !1 }
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
);
|
|
346
|
+
}, Le = ({ state: a }) => {
|
|
347
|
+
const [i, d] = S(!1), [h, n] = S(!0), [l, x] = S(JSON.stringify(a.value, null, 2)), [c, p] = S(!1), [g, u] = S("idle"), E = he(JSON.stringify(a.value, null, 2));
|
|
348
|
+
U(() => {
|
|
349
|
+
x(JSON.stringify(a.value, null, 2));
|
|
350
|
+
}, [a.value]);
|
|
351
|
+
const j = V((t) => {
|
|
352
|
+
p(t !== E.current), x(t), u("idle");
|
|
353
|
+
}, []), N = async () => {
|
|
354
|
+
if (!(!h || !c))
|
|
355
|
+
try {
|
|
356
|
+
d(!0), u("idle");
|
|
357
|
+
const t = await fetch("/__motia/state", {
|
|
358
|
+
method: "POST",
|
|
359
|
+
headers: {
|
|
360
|
+
"Content-Type": "application/json"
|
|
361
|
+
},
|
|
362
|
+
body: JSON.stringify({
|
|
363
|
+
key: a.key,
|
|
364
|
+
groupId: a.groupId,
|
|
365
|
+
value: JSON.parse(l)
|
|
366
|
+
})
|
|
367
|
+
});
|
|
368
|
+
if (!t.ok)
|
|
369
|
+
throw new Error(`HTTP error! status: ${t.status}`);
|
|
370
|
+
E.current = l, u("success"), p(!1), setTimeout(() => {
|
|
371
|
+
u("idle");
|
|
372
|
+
}, 3e3);
|
|
373
|
+
} catch (t) {
|
|
374
|
+
console.error("Failed to save state:", t), u("error");
|
|
375
|
+
} finally {
|
|
376
|
+
d(!1);
|
|
377
|
+
}
|
|
378
|
+
}, w = V(() => {
|
|
379
|
+
x(JSON.stringify(a.value, null, 2)), p(!1), u("idle");
|
|
380
|
+
}, [a.value]), y = $(() => g === "success" ? /* @__PURE__ */ r.jsx("div", { className: "bg-green-50 dark:bg-green-950/20 border border-green-200 dark:border-green-800 rounded-lg p-2", children: /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2 text-green-700 dark:text-green-400 text-sm", children: [
|
|
381
|
+
/* @__PURE__ */ r.jsx(Se, { className: "w-4 h-4" }),
|
|
382
|
+
"State saved successfully!"
|
|
383
|
+
] }) }) : g === "error" ? /* @__PURE__ */ r.jsx("div", { className: "bg-red-50 dark:bg-red-950/20 border border-red-200 dark:border-red-800 rounded-lg p-2", children: /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2 text-red-700 dark:text-red-400 text-sm", children: [
|
|
384
|
+
/* @__PURE__ */ r.jsx(K, { className: "w-4 h-4" }),
|
|
385
|
+
"Failed to save state. Please try again."
|
|
386
|
+
] }) }) : /* @__PURE__ */ r.jsx("div", { className: "text-xs text-muted-foreground", children: c ? /* @__PURE__ */ r.jsxs("span", { className: "flex items-center gap-1", children: [
|
|
387
|
+
/* @__PURE__ */ r.jsx("div", { className: "w-2 h-2 bg-orange-500 rounded-full" }),
|
|
388
|
+
"Unsaved changes"
|
|
389
|
+
] }) : /* @__PURE__ */ r.jsxs("span", { className: "flex items-center gap-1", children: [
|
|
390
|
+
/* @__PURE__ */ r.jsx("div", { className: "w-2 h-2 bg-green-500 rounded-full" }),
|
|
391
|
+
"Up to date"
|
|
392
|
+
] }) }), [g, c]);
|
|
393
|
+
return /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col gap-2 h-full", children: [
|
|
394
|
+
/* @__PURE__ */ r.jsx("p", { className: "text-xs text-muted-foreground", children: "Modify the state value using the JSON editor below." }),
|
|
395
|
+
/* @__PURE__ */ r.jsx("div", { className: "space-y-3 pt-2 flex flex-col", children: /* @__PURE__ */ r.jsxs("div", { className: "relative flex-1", children: [
|
|
396
|
+
/* @__PURE__ */ r.jsx(
|
|
397
|
+
Je,
|
|
398
|
+
{
|
|
399
|
+
value: l,
|
|
400
|
+
onChange: j,
|
|
401
|
+
onValidate: n,
|
|
402
|
+
height: "calc(100vh - 300px)"
|
|
403
|
+
}
|
|
404
|
+
),
|
|
405
|
+
!h && /* @__PURE__ */ r.jsxs("div", { className: "absolute top-2 right-2 bg-destructive/90 text-destructive-foreground px-2 py-1 rounded text-xs flex items-center gap-1", children: [
|
|
406
|
+
/* @__PURE__ */ r.jsx(K, { className: "w-3 h-3" }),
|
|
407
|
+
"Invalid JSON"
|
|
408
|
+
] })
|
|
409
|
+
] }) }),
|
|
410
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center justify-between pt-2", children: [
|
|
411
|
+
y,
|
|
412
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
413
|
+
c && /* @__PURE__ */ r.jsx(D, { variant: "secondary", onClick: w, disabled: i, children: "Reset" }),
|
|
414
|
+
/* @__PURE__ */ r.jsx(
|
|
415
|
+
D,
|
|
416
|
+
{
|
|
417
|
+
onClick: N,
|
|
418
|
+
variant: "accent",
|
|
419
|
+
disabled: i || !h || !c,
|
|
420
|
+
"data-testid": "state-save-button",
|
|
421
|
+
children: i ? /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
|
|
422
|
+
/* @__PURE__ */ r.jsx(Ee, { className: "w-3 h-3 animate-spin mr-1" }),
|
|
423
|
+
"Saving..."
|
|
424
|
+
] }) : /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
|
|
425
|
+
/* @__PURE__ */ r.jsx(ye, { className: "w-3 h-3 mr-1" }),
|
|
426
|
+
"Save Changes"
|
|
427
|
+
] })
|
|
428
|
+
}
|
|
429
|
+
)
|
|
430
|
+
] })
|
|
431
|
+
] })
|
|
432
|
+
] });
|
|
433
|
+
}, Ye = ({ state: a, onClose: i }) => /* @__PURE__ */ r.jsx(
|
|
434
|
+
pe,
|
|
435
|
+
{
|
|
436
|
+
onClose: i,
|
|
437
|
+
title: "State Details",
|
|
438
|
+
initialWidth: 500,
|
|
439
|
+
tabs: [
|
|
440
|
+
{
|
|
441
|
+
label: "Overview",
|
|
442
|
+
content: /* @__PURE__ */ r.jsx(De, { state: a })
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
label: "Editor",
|
|
446
|
+
content: /* @__PURE__ */ r.jsx(Le, { state: a })
|
|
447
|
+
}
|
|
448
|
+
],
|
|
449
|
+
actions: [{ icon: /* @__PURE__ */ r.jsx(ae, {}), onClick: i, label: "Close" }]
|
|
450
|
+
}
|
|
451
|
+
), Ge = () => {
|
|
452
|
+
const a = se((t) => t.selectedStateId), i = se((t) => t.selectStateId), { items: d, deleteItems: h, refetch: n } = $e(), [l, x] = S(""), c = $(() => d.filter((t) => t.groupId.toLowerCase().includes(l.toLowerCase()) || t.key.toLowerCase().includes(l.toLowerCase())), [d, l]), p = $(
|
|
453
|
+
() => a ? c.find((t) => `${t.groupId}:${t.key}` === a) : null,
|
|
454
|
+
[c, a]
|
|
455
|
+
), [g, u] = S(/* @__PURE__ */ new Set()), E = (t) => i(`${t.groupId}:${t.key}`), j = () => i(void 0), N = () => {
|
|
456
|
+
h(Array.from(g)), u(/* @__PURE__ */ new Set());
|
|
457
|
+
}, w = (t) => {
|
|
458
|
+
const T = g.has(`${t.groupId}:${t.key}`);
|
|
459
|
+
u((_) => {
|
|
460
|
+
const v = new Set(_);
|
|
461
|
+
return T ? v.delete(`${t.groupId}:${t.key}`) : v.add(`${t.groupId}:${t.key}`), v;
|
|
462
|
+
});
|
|
463
|
+
}, y = (t) => {
|
|
464
|
+
u((T) => {
|
|
465
|
+
const _ = new Set(T);
|
|
466
|
+
return t ? c.forEach((v) => _.add(`${v.groupId}:${v.key}`)) : c.forEach((v) => _.delete(`${v.groupId}:${v.key}`)), _;
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
return /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
|
|
470
|
+
p && /* @__PURE__ */ r.jsx(Ye, { state: p, onClose: j }),
|
|
471
|
+
/* @__PURE__ */ r.jsxs("div", { className: "grid grid-rows-[auto_1fr] h-full", "data-testid": "states-container", children: [
|
|
472
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex p-2 border-b gap-2", "data-testid": "logs-search-container", children: [
|
|
473
|
+
/* @__PURE__ */ r.jsxs("div", { className: "flex-1 relative", children: [
|
|
474
|
+
/* @__PURE__ */ r.jsx(
|
|
475
|
+
ge,
|
|
476
|
+
{
|
|
477
|
+
variant: "shade",
|
|
478
|
+
value: l,
|
|
479
|
+
onChange: (t) => x(t.target.value),
|
|
480
|
+
className: "px-9 font-medium",
|
|
481
|
+
placeholder: "Search by Group ID or Key"
|
|
482
|
+
}
|
|
483
|
+
),
|
|
484
|
+
/* @__PURE__ */ r.jsx(Te, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50" }),
|
|
485
|
+
/* @__PURE__ */ r.jsx(
|
|
486
|
+
ae,
|
|
487
|
+
{
|
|
488
|
+
className: "cursor-pointer absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 hover:text-muted-foreground",
|
|
489
|
+
onClick: () => x("")
|
|
490
|
+
}
|
|
491
|
+
)
|
|
492
|
+
] }),
|
|
493
|
+
/* @__PURE__ */ r.jsxs(D, { variant: "default", className: "h-[34px]", disabled: g.size === 0, onClick: N, children: [
|
|
494
|
+
/* @__PURE__ */ r.jsx(_e, {}),
|
|
495
|
+
" Delete"
|
|
496
|
+
] }),
|
|
497
|
+
/* @__PURE__ */ r.jsx(D, { variant: "default", className: "h-[34px]", onClick: n, children: /* @__PURE__ */ r.jsx(Ne, { className: "w-4 h-4 text-muted-foreground" }) })
|
|
498
|
+
] }),
|
|
499
|
+
/* @__PURE__ */ r.jsxs(ve, { children: [
|
|
500
|
+
/* @__PURE__ */ r.jsx(be, { className: "sticky top-0 bg-background/20 backdrop-blur-sm", children: /* @__PURE__ */ r.jsxs(Z, { children: [
|
|
501
|
+
/* @__PURE__ */ r.jsx(I, { children: /* @__PURE__ */ r.jsx(Q, { onClick: (t) => t.stopPropagation(), onCheckedChange: y }) }),
|
|
502
|
+
/* @__PURE__ */ r.jsx(I, { className: "rounded-0", children: "Group ID" }),
|
|
503
|
+
/* @__PURE__ */ r.jsx(I, { children: "Key" }),
|
|
504
|
+
/* @__PURE__ */ r.jsx(I, { children: "Type" })
|
|
505
|
+
] }) }),
|
|
506
|
+
/* @__PURE__ */ r.jsx(je, { children: c.map((t) => /* @__PURE__ */ r.jsxs(
|
|
507
|
+
Z,
|
|
508
|
+
{
|
|
509
|
+
"data-testid": `item-${t}`,
|
|
510
|
+
onClick: () => E(t),
|
|
511
|
+
className: ke(
|
|
512
|
+
"font-mono font-semibold cursor-pointer border-0",
|
|
513
|
+
p === t ? "bg-muted-foreground/10 hover:bg-muted-foreground/20" : "hover:bg-muted-foreground/10"
|
|
514
|
+
),
|
|
515
|
+
children: [
|
|
516
|
+
/* @__PURE__ */ r.jsx(P, { onClick: (T) => T.stopPropagation(), children: /* @__PURE__ */ r.jsx(
|
|
517
|
+
Q,
|
|
518
|
+
{
|
|
519
|
+
checked: g.has(`${t.groupId}:${t.key}`),
|
|
520
|
+
onClick: () => w(t)
|
|
521
|
+
}
|
|
522
|
+
) }),
|
|
523
|
+
/* @__PURE__ */ r.jsx(P, { className: "hover:bg-transparent", children: t.groupId }),
|
|
524
|
+
/* @__PURE__ */ r.jsx(P, { className: "hover:bg-transparent", children: t.key }),
|
|
525
|
+
/* @__PURE__ */ r.jsx(P, { className: "hover:bg-transparent", children: t.type })
|
|
526
|
+
]
|
|
527
|
+
},
|
|
528
|
+
`${t.groupId}:${t.key}`
|
|
529
|
+
)) })
|
|
530
|
+
] })
|
|
531
|
+
] })
|
|
532
|
+
] });
|
|
533
|
+
};
|
|
534
|
+
export {
|
|
535
|
+
Ge as StatesPage
|
|
536
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tailwindcss v4.1.14 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-200:oklch(88.5% .062 18.334);--color-red-400:oklch(70.4% .191 22.216);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-950:oklch(25.8% .092 26.042);--color-orange-500:oklch(70.5% .213 47.604);--color-green-50:oklch(98.2% .018 155.826);--color-green-200:oklch(92.5% .084 155.995);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-700:oklch(52.7% .154 150.069);--color-green-800:oklch(44.8% .119 151.328);--color-green-950:oklch(26.6% .065 152.934);--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--font-weight-medium:500;--font-weight-semibold:600;--radius-lg:.5rem;--animate-spin:spin 1s linear infinite;--blur-sm:8px;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--font-weight-500:var(--font-weight-500);--font-weight-600:var(--font-weight-600);--font-weight-700:var(--font-weight-700)}}@layer base{*{border-color:var(--border)}body{background-color:var(--background);color:var(--foreground)}*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.top-0{top:calc(var(--spacing)*0)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.right-2{right:calc(var(--spacing)*2)}.right-3{right:calc(var(--spacing)*3)}.left-3{left:calc(var(--spacing)*3)}.mr-1{margin-right:calc(var(--spacing)*1)}.flex{display:flex}.grid{display:grid}.h-2{height:calc(var(--spacing)*2)}.h-3{height:calc(var(--spacing)*3)}.h-4{height:calc(var(--spacing)*4)}.h-\[34px\]{height:34px}.h-full{height:100%}.w-2{width:calc(var(--spacing)*2)}.w-3{width:calc(var(--spacing)*3)}.w-4{width:calc(var(--spacing)*4)}.flex-1{flex:1}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.grid-rows-\[auto_1fr\]{grid-template-rows:auto 1fr}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-green-200{border-color:var(--color-green-200)}.border-red-200{border-color:var(--color-red-200)}.bg-background\/20{background-color:var(--background)}@supports (color:color-mix(in lab,red,red)){.bg-background\/20{background-color:color-mix(in oklab,var(--background)20%,transparent)}}.bg-destructive\/90{background-color:var(--destructive)}@supports (color:color-mix(in lab,red,red)){.bg-destructive\/90{background-color:color-mix(in oklab,var(--destructive)90%,transparent)}}.bg-green-50{background-color:var(--color-green-50)}.bg-green-500{background-color:var(--color-green-500)}.bg-muted-foreground\/10{background-color:var(--muted-foreground)}@supports (color:color-mix(in lab,red,red)){.bg-muted-foreground\/10{background-color:color-mix(in oklab,var(--muted-foreground)10%,transparent)}}.bg-orange-500{background-color:var(--color-orange-500)}.bg-red-50{background-color:var(--color-red-50)}.p-2{padding:calc(var(--spacing)*2)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-9{padding-inline:calc(var(--spacing)*9)}.py-1{padding-block:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.font-mono{font-family:var(--font-mono)}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.text-destructive-foreground{color:var(--destructive-foreground)}.text-green-700{color:var(--color-green-700)}.text-muted-foreground,.text-muted-foreground\/50{color:var(--muted-foreground)}@supports (color:color-mix(in lab,red,red)){.text-muted-foreground\/50{color:color-mix(in oklab,var(--muted-foreground)50%,transparent)}}.text-red-700{color:var(--color-red-700)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}@media (hover:hover){.hover\:bg-muted-foreground\/10:hover{background-color:var(--muted-foreground)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-muted-foreground\/10:hover{background-color:color-mix(in oklab,var(--muted-foreground)10%,transparent)}}.hover\:bg-muted-foreground\/20:hover{background-color:var(--muted-foreground)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-muted-foreground\/20:hover{background-color:color-mix(in oklab,var(--muted-foreground)20%,transparent)}}.hover\:bg-transparent:hover{background-color:#0000}.hover\:text-muted-foreground:hover{color:var(--muted-foreground)}}.dark\:border-green-800:is(.dark *){border-color:var(--color-green-800)}.dark\:border-red-800:is(.dark *){border-color:var(--color-red-800)}.dark\:bg-green-950\/20:is(.dark *){background-color:#032e1533}@supports (color:color-mix(in lab,red,red)){.dark\:bg-green-950\/20:is(.dark *){background-color:color-mix(in oklab,var(--color-green-950)20%,transparent)}}.dark\:bg-red-950\/20:is(.dark *){background-color:#46080933}@supports (color:color-mix(in lab,red,red)){.dark\:bg-red-950\/20:is(.dark *){background-color:color-mix(in oklab,var(--color-red-950)20%,transparent)}}.dark\:text-green-400:is(.dark *){color:var(--color-green-400)}.dark\:text-red-400:is(.dark *){color:var(--color-red-400)}}:root{--default-font-family:"DM Sans",ui-sans-serif,sans-serif;--font-dm-mono:"DM Mono",ui-monospace,monospace;color-scheme:light dark;font-size:16px;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"),serif;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-optical-sizing:auto;--font-weight-500:500;--font-weight-600:600;--font-weight-700:700;--accent-1000:#2862fe;--accent-970:#2862fef7;--accent-950:#2862fef2;--accent-900:#2862fee5;--accent-800:#2862fecc;--accent-700:#2862feb2;--accent-600:#2862fe99;--accent-500:#2862fe80;--accent-400:#2862fe66;--accent-300:#2862fe4d;--accent-200:#2862fe33;--accent-100:#2862fe1a;--accent-50:#2862fe0d;--accent-30:#2862fe08;--dark-1000:#0a0a0a;--dark-970:#0a0a0af7;--dark-950:#0a0a0af2;--dark-900:#0a0a0ae5;--dark-800:#0a0a0acc;--dark-700:#0a0a0ab2;--dark-600:#0a0a0a99;--dark-500:#0a0a0a80;--dark-400:#0a0a0a66;--dark-300:#0a0a0a4d;--dark-200:#0a0a0a33;--dark-100:#0a0a0a1a;--dark-50:#0a0a0a0d;--dark-30:#0a0a0a08;--light-1000:#fff;--light-970:#fffffff7;--light-950:#fffffff2;--light-900:#ffffffe5;--light-800:#fffc;--light-700:#ffffffb2;--light-600:#fff9;--light-500:#ffffff80;--light-400:#fff6;--light-300:#ffffff4d;--light-200:#fff3;--light-100:#ffffff1a;--light-50:#ffffff0d;--light-30:#ffffff08;--error:#d61355;--canvas-background:#ebebeb;--background:var(--light-1000);--foreground:var(--dark-1000);--surface-content:var(--dark-30);--surface-component:var(--dark-50);--surface-light-100:var(--dark-100);--surface-light-200:var(--dark-200);--border:var(--dark-100);--border-accent:var(--accent-1000);--states-hover:var(--dark-30);--states-selected:var(--dark-100);--states-active:var(--accent-1000);--text-header:var(--dark-1000);--text-body:var(--dark-600);--text-placeholder:var(--dark-400);--text-accent:var(--accent-1000);--text-error:var(--error);--icon-active:var(--dark-1000);--icon-light:var(--dark-600);--icon-component:var(--dark-400);--icon-accent:var(--accent-1000);--primary:var(--accent-1000);--primary-foreground:var(--light-1000);--secondary:var(--surface-component);--secondary-foreground:var(--text-body);--muted:var(--surface-light-100);--muted-foreground:var(--text-body);--accent:var(--accent-1000);--accent-foreground:var(--light-1000);--destructive:var(--error);--destructive-foreground:var(--light-1000);--card:var(--surface-content);--card-foreground:var(--foreground);--popover:var(--surface-content);--popover-foreground:var(--foreground);--input:var(--states-hover);--ring:var(--border-accent);--chart-1:var(--accent-1000);--chart-2:var(--accent-800);--chart-3:var(--accent-600);--chart-4:var(--accent-400);--chart-5:var(--accent-200);--header:var(--background);--header-foreground:var(--text-header);--header-primary:var(--primary);--header-primary-foreground:var(--primary-foreground);--header-accent:var(--surface-component);--header-accent-foreground:var(--text-body);--header-border:var(--border);--header-ring:var(--ring);--sidebar:var(--background);--sidebar-foreground:var(--text-header);--sidebar-primary:var(--primary);--sidebar-primary-foreground:var(--primary-foreground);--sidebar-accent:var(--surface-component);--sidebar-accent-foreground:var(--text-body);--sidebar-border:var(--border);--sidebar-ring:var(--ring);width:100%}.dark{--canvas-background:#030303;--background:var(--dark-1000);--foreground:var(--light-1000);--surface-content:var(--light-30);--surface-component:var(--light-50);--surface-light-100:var(--light-100);--surface-light-200:var(--light-200);--border:var(--light-100);--states-hover:var(--light-30);--states-selected:var(--light-100);--text-header:var(--light-1000);--text-body:var(--light-600);--text-placeholder:var(--light-400);--icon-active:var(--light-1000);--icon-light:var(--light-600);--icon-component:var(--light-400);--secondary-foreground:var(--light-600);--muted-foreground:var(--light-600);--card:var(--surface-content);--card-foreground:var(--foreground);--popover:var(--surface-content);--popover-foreground:var(--foreground);--input:var(--states-hover);--ring:var(--border-accent);--chart-1:var(--accent-1000);--chart-2:var(--accent-800);--chart-3:var(--accent-600);--chart-4:var(--accent-400);--chart-5:var(--accent-200);--header:var(--background);--header-foreground:var(--text-header);--header-primary:var(--primary);--header-primary-foreground:var(--primary-foreground);--header-accent:var(--surface-component);--header-accent-foreground:var(--text-body);--header-border:var(--border);--header-ring:var(--ring);--sidebar:var(--background);--sidebar-foreground:var(--text-header);--sidebar-primary:var(--primary);--sidebar-primary-foreground:var(--primary-foreground);--sidebar-accent:var(--surface-component);--sidebar-accent-foreground:var(--text-body);--sidebar-border:var(--border);--sidebar-ring:var(--ring)}.json-view{background-color:#0000!important}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}
|
package/dist/plugin.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=s=>{s.registerApi({method:"GET",path:"/__motia/state"},async r=>{try{const e=r.queryParams.groupId,t=r.queryParams.filter?JSON.parse(r.queryParams.filter):void 0;return{status:200,body:await s.state.items({groupId:e,filter:t})}}catch(e){return{status:500,body:{error:e instanceof Error?e.message:"Unknown error"}}}}),s.registerApi({method:"POST",path:"/__motia/state"},async(r,e)=>{try{const{key:t,groupId:a,value:o}=r.body;return await e.state.set(a,t,o),{status:200,body:{key:t,groupId:a,value:o}}}catch(t){return{status:500,body:{error:t instanceof Error?t.message:"Unknown error"}}}}),s.registerApi({method:"POST",path:"/__motia/state/delete"},async(r,e)=>{try{for(const t of r.body.ids){const[a,o]=t.split(":");await e.state.delete(a,o)}return{status:204,body:""}}catch(t){return{status:500,body:{error:t instanceof Error?t.message:"Unknown error"}}}})};function i(s){return n(s),{workbench:[{packageName:"@motiadev/plugin-states",cssImports:["@motiadev/plugin-states/dist/plugin-states.css"],label:"States",position:"bottom",componentName:"StatesPage",labelIcon:"file"}]}}module.exports=i;
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAGrE,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,WAAW,CAerE"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const n = (s) => {
|
|
2
|
+
s.registerApi(
|
|
3
|
+
{
|
|
4
|
+
method: "GET",
|
|
5
|
+
path: "/__motia/state"
|
|
6
|
+
},
|
|
7
|
+
async (r) => {
|
|
8
|
+
try {
|
|
9
|
+
const e = r.queryParams.groupId, t = r.queryParams.filter ? JSON.parse(r.queryParams.filter) : void 0;
|
|
10
|
+
return {
|
|
11
|
+
status: 200,
|
|
12
|
+
body: await s.state.items({ groupId: e, filter: t })
|
|
13
|
+
};
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return {
|
|
16
|
+
status: 500,
|
|
17
|
+
body: { error: e instanceof Error ? e.message : "Unknown error" }
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
), s.registerApi(
|
|
22
|
+
{
|
|
23
|
+
method: "POST",
|
|
24
|
+
path: "/__motia/state"
|
|
25
|
+
},
|
|
26
|
+
async (r, e) => {
|
|
27
|
+
try {
|
|
28
|
+
const { key: t, groupId: a, value: o } = r.body;
|
|
29
|
+
return await e.state.set(a, t, o), {
|
|
30
|
+
status: 200,
|
|
31
|
+
body: { key: t, groupId: a, value: o }
|
|
32
|
+
};
|
|
33
|
+
} catch (t) {
|
|
34
|
+
return {
|
|
35
|
+
status: 500,
|
|
36
|
+
body: { error: t instanceof Error ? t.message : "Unknown error" }
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
), s.registerApi(
|
|
41
|
+
{
|
|
42
|
+
method: "POST",
|
|
43
|
+
path: "/__motia/state/delete"
|
|
44
|
+
},
|
|
45
|
+
async (r, e) => {
|
|
46
|
+
try {
|
|
47
|
+
for (const t of r.body.ids) {
|
|
48
|
+
const [a, o] = t.split(":");
|
|
49
|
+
await e.state.delete(a, o);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
status: 204,
|
|
53
|
+
body: ""
|
|
54
|
+
};
|
|
55
|
+
} catch (t) {
|
|
56
|
+
return {
|
|
57
|
+
status: 500,
|
|
58
|
+
body: { error: t instanceof Error ? t.message : "Unknown error" }
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
function i(s) {
|
|
65
|
+
return n(s), {
|
|
66
|
+
workbench: [
|
|
67
|
+
{
|
|
68
|
+
packageName: "@motiadev/plugin-states",
|
|
69
|
+
cssImports: ["@motiadev/plugin-states/dist/plugin-states.css"],
|
|
70
|
+
label: "States",
|
|
71
|
+
position: "bottom",
|
|
72
|
+
componentName: "StatesPage",
|
|
73
|
+
labelIcon: "file"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
i as default
|
|
80
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-states-store.d.ts","sourceRoot":"","sources":["../../src/stores/use-states-store.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC1C,CAAA;AAED,eAAO,MAAM,cAAc,0EAGxB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/types/state.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAA;IACnE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,EAAE,GAAG,IAAI,CAAA;CAC7D"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@motiadev/plugin-states",
|
|
3
|
+
"version": "0.8.2-beta.140-111855",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
},
|
|
14
|
+
"./plugin": {
|
|
15
|
+
"types": "./dist/plugin.d.ts",
|
|
16
|
+
"import": "./dist/plugin.js",
|
|
17
|
+
"require": "./dist/plugin.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./styles.css": "./dist/plugin-states.css"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@monaco-editor/react": "^4.7.0",
|
|
26
|
+
"lucide-react": "^0.545.0",
|
|
27
|
+
"react18-json-view": "^0.2.9",
|
|
28
|
+
"zustand": "^5.0.8"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@motiadev/ui": "0.8.2-beta.140-111855",
|
|
32
|
+
"@motiadev/stream-client-browser": "0.8.2-beta.140-111855",
|
|
33
|
+
"@motiadev/core": "0.8.2-beta.140-111855"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@tailwindcss/vite": "^4.1.14",
|
|
37
|
+
"@types/express": "^5.0.3",
|
|
38
|
+
"@types/node": "^24.7.2",
|
|
39
|
+
"@types/react": "^19.2.2",
|
|
40
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
41
|
+
"react": "^19.2.0",
|
|
42
|
+
"tailwindcss": "^4.1.14",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"vite": "^7.1.10",
|
|
45
|
+
"vite-plugin-dts": "^4.5.4"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "vite build",
|
|
49
|
+
"dev": "vite build --watch",
|
|
50
|
+
"clean": "rm -rf dist"
|
|
51
|
+
}
|
|
52
|
+
}
|