modifywithai 1.1.0 → 1.2.1
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/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/nextjs/api.d.ts +0 -12
- package/dist/nextjs/api.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/head.d.ts
|
|
@@ -6,7 +6,7 @@ declare const MWAIHead: ({
|
|
|
6
6
|
basePath
|
|
7
7
|
}?: {
|
|
8
8
|
basePath?: string;
|
|
9
|
-
}) =>
|
|
9
|
+
}) => react_jsx_runtime0.JSX.Element;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/provider.d.ts
|
|
12
12
|
declare const MWAIProvider: ({
|
|
@@ -15,7 +15,7 @@ declare const MWAIProvider: ({
|
|
|
15
15
|
}: {
|
|
16
16
|
id: string;
|
|
17
17
|
children: ReactNode;
|
|
18
|
-
}) =>
|
|
18
|
+
}) => react_jsx_runtime0.JSX.Element;
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/popover.d.ts
|
|
21
21
|
type ModificationPopoverProps = {
|
|
@@ -51,10 +51,10 @@ declare function MWAIButton({
|
|
|
51
51
|
loadingText,
|
|
52
52
|
side,
|
|
53
53
|
align
|
|
54
|
-
}: ModificationPopoverProps):
|
|
54
|
+
}: ModificationPopoverProps): react_jsx_runtime0.JSX.Element;
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region src/hook.d.ts
|
|
57
|
-
declare const useMWAIComponents: () =>
|
|
58
|
-
declare const MWAIComponents: () =>
|
|
57
|
+
declare const useMWAIComponents: () => react_jsx_runtime0.JSX.Element | null;
|
|
58
|
+
declare const MWAIComponents: () => react_jsx_runtime0.JSX.Element | null;
|
|
59
59
|
//#endregion
|
|
60
60
|
export { MWAIButton, MWAIComponents, MWAIHead, MWAIProvider, useMWAIComponents };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as e from"react/jsx-runtime";import{Fragment as t,jsx as n,jsxs as r}from"react/jsx-runtime";import*as i from"react";import{createContext as a,useContext as o,useLayoutEffect as s,useState as c}from"react";import{Popover as l}from"@base-ui-components/react/popover";import{createFetch as u,createSchema as d}from"@better-fetch/fetch";import{z as f}from"zod";import{logger as p}from"@better-fetch/logger";import*as m from"react-dom";var h=Object.create,g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,v=Object.getOwnPropertyNames,y=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty,x=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=v(t),a=0,o=i.length,s;a<o;a++)s=i[a],!b.call(e,s)&&s!==n&&g(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=_(t,s))||r.enumerable});return e},te=(e,t,n)=>(n=e==null?{}:h(y(e)),ee(t||!e||!e.__esModule?g(n,`default`,{value:e,enumerable:!0}):n,e)),ne=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function.")});const re=({basePath:e=`/api/mwai`}={})=>n(`script`,{type:`importmap`,dangerouslySetInnerHTML:{__html:JSON.stringify({imports:{react:`${e}/shims/react-shim.js`,"react/jsx-runtime":`${e}/shims/react-jsx-shim.js`,"react-dom":`${e}/shims/react-dom-shim.js`,"react-dom/client":`${e}/shims/react-dom-client-shim.js`}})}}),ie=a(null),ae=({id:e,children:t})=>n(ie.Provider,{value:e,children:t}),oe=u({schema:d({"/api/mwai/api/list":{output:f.array(f.object({id:f.string(),title:f.string(),description:f.string().nullable(),status:f.enum([`pending`,`success`,`error`]),createdAt:f.number(),updatedAt:f.number(),enabled:f.boolean()}))},"/api/mwai/api/modify":{input:f.object({prompt:f.string()}),output:f.object({success:f.boolean()})}}),retry:{type:`exponential`,attempts:5,baseDelay:1e3,maxDelay:1e4},plugins:[p({enabled:!1})]}),se={triggerButton:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,height:`32px`,padding:`0 10px`,fontSize:`14px`,fontWeight:500,fontFamily:`system-ui, -apple-system, sans-serif`,borderRadius:`8px`,border:`1px solid #e5e5e5`,backgroundColor:`#fff`,color:`#171717`,cursor:`pointer`,transition:`all 150ms`,outline:`none`,userSelect:`none`,whiteSpace:`nowrap`},popoverContent:{display:`flex`,flexDirection:`column`,gap:`10px`,width:`320px`,padding:`12px`,backgroundColor:`#fff`,borderRadius:`10px`,boxShadow:`0 10px 38px -10px rgba(22, 23, 24, 0.35), 0 10px 20px -15px rgba(22, 23, 24, 0.2)`,border:`1px solid #e5e5e5`,fontSize:`14px`,fontFamily:`system-ui, -apple-system, sans-serif`,color:`#171717`,zIndex:50},header:{display:`flex`,flexDirection:`column`,gap:`2px`},title:{fontWeight:600,fontSize:`14px`,color:`#171717`,margin:0},description:{fontSize:`13px`,color:`#737373`,margin:0},textarea:{width:`100%`,minHeight:`96px`,padding:`10px`,fontSize:`14px`,fontFamily:`system-ui, -apple-system, sans-serif`,borderRadius:`8px`,borderWidth:`1px`,borderStyle:`solid`,borderColor:`#e5e5e5`,backgroundColor:`#fff`,color:`#171717`,resize:`none`,outline:`none`,transition:`border-color 150ms, box-shadow 150ms`,boxShadow:`none`},textareaFocus:{borderColor:`#a3a3a3`,boxShadow:`0 0 0 3px rgba(163, 163, 163, 0.2)`},buttonGroup:{display:`flex`,justifyContent:`flex-end`,gap:`8px`},cancelButton:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,height:`28px`,padding:`0 10px`,fontSize:`13px`,fontWeight:500,fontFamily:`system-ui, -apple-system, sans-serif`,borderRadius:`6px`,border:`1px solid #e5e5e5`,backgroundColor:`#fff`,color:`#171717`,cursor:`pointer`,transition:`all 150ms`,outline:`none`},submitButton:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,height:`28px`,padding:`0 10px`,fontSize:`13px`,fontWeight:500,fontFamily:`system-ui, -apple-system, sans-serif`,borderRadius:`6px`,border:`1px solid transparent`,backgroundColor:`#6366f1`,color:`#fff`,cursor:`pointer`,transition:`all 150ms`,outline:`none`},submitButtonDisabled:{opacity:.5,cursor:`not-allowed`}};function ce({children:e=`Modify With AI`,onSuccess:t,onError:i,title:a=`Modify with AI`,description:o=`Describe the changes you want to make`,placeholder:s=`E.g., Make the header sticky, change the button color to blue...`,submitText:u=`Submit`,loadingText:d=`Submitting...`,side:f=`bottom`,align:p=`center`}){let[m,h]=c(``),[g,_]=c(!1),[v,y]=c(!1),[b,x]=c(!1),[ee,te]=c(!1),[ne,re]=c(!1),[ie,ae]=c(!1),ce=async()=>{if(!(!m.trim()||g)){_(!0);try{let{error:e}=await oe(`/api/mwai/api/modify`,{method:`POST`,body:{prompt:m.trim()}});if(e)throw Error(e.message||`Request failed`);h(``),y(!1),t?.()}catch(e){let t=e instanceof Error?e:Error(`Unknown error`);console.error(`Modification failed:`,t),i?.(t)}finally{_(!1)}}},le=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ce())},ue=!m.trim()||g;return r(l.Root,{open:v,onOpenChange:y,children:[n(l.Trigger,{style:{...se.triggerButton,...ee?{backgroundColor:`#f5f5f5`}:{}},onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),children:e}),n(l.Portal,{children:n(l.Positioner,{align:p,side:f,sideOffset:4,style:{zIndex:50},children:r(l.Popup,{style:se.popoverContent,children:[r(`div`,{style:se.header,children:[n(l.Title,{style:se.title,children:a}),n(l.Description,{style:se.description,children:o})]}),n(`textarea`,{placeholder:s,value:m,onChange:e=>h(e.target.value),onKeyDown:le,onFocus:()=>x(!0),onBlur:()=>x(!1),disabled:g,style:{...se.textarea,...b?se.textareaFocus:{}}}),r(`div`,{style:se.buttonGroup,children:[n(`button`,{type:`button`,onClick:()=>y(!1),disabled:g,onMouseEnter:()=>re(!0),onMouseLeave:()=>re(!1),style:{...se.cancelButton,...ne?{backgroundColor:`#f5f5f5`}:{}},children:`Cancel`}),n(`button`,{type:`button`,onClick:ce,disabled:ue,onMouseEnter:()=>ae(!0),onMouseLeave:()=>ae(!1),style:{...se.submitButton,...ue?se.submitButtonDisabled:{},...ie&&!ue?{backgroundColor:`#4f46e5`}:{}},children:g?d:u})]})]})})})]})}
|
|
1
|
+
"use client";import*as e from"react/jsx-runtime";import{Fragment as t,jsx as n,jsxs as r}from"react/jsx-runtime";import*as i from"react";import{createContext as a,useContext as o,useLayoutEffect as s,useState as c}from"react";import{Popover as l}from"@base-ui-components/react/popover";import{createFetch as u,createSchema as d}from"@better-fetch/fetch";import{z as f}from"zod";import{logger as p}from"@better-fetch/logger";import*as m from"react-dom";var h=Object.create,g=Object.defineProperty,_=Object.getOwnPropertyDescriptor,v=Object.getOwnPropertyNames,y=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty,x=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=v(t),a=0,o=i.length,s;a<o;a++)s=i[a],!b.call(e,s)&&s!==n&&g(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=_(t,s))||r.enumerable});return e},te=(e,t,n)=>(n=e==null?{}:h(y(e)),ee(t||!e||!e.__esModule?g(n,`default`,{value:e,enumerable:!0}):n,e)),ne=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function.")});const re=({basePath:e=`/api/mwai`}={})=>n(`script`,{type:`importmap`,dangerouslySetInnerHTML:{__html:JSON.stringify({imports:{react:`${e}/shims/react-shim.js`,"react/jsx-runtime":`${e}/shims/react-jsx-shim.js`,"react-dom":`${e}/shims/react-dom-shim.js`,"react-dom/client":`${e}/shims/react-dom-client-shim.js`}})}}),ie=a(null),ae=({id:e,children:t})=>n(ie.Provider,{value:e,children:t}),oe=u({schema:d({"/api/mwai/api/list":{output:f.array(f.object({id:f.string(),title:f.string(),description:f.string().nullable(),status:f.enum([`pending`,`success`,`error`]),createdAt:f.number(),updatedAt:f.number(),enabled:f.boolean()}))},"/api/mwai/api/modify":{input:f.object({prompt:f.string()}),output:f.object({success:f.boolean()})}}),retry:{type:`exponential`,attempts:5,baseDelay:1e3,maxDelay:1e4},plugins:[p({enabled:!1})]}),se={triggerButton:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,height:`32px`,padding:`0 10px`,fontSize:`14px`,fontWeight:500,fontFamily:`system-ui, -apple-system, sans-serif`,borderRadius:`8px`,border:`1px solid #e5e5e5`,backgroundColor:`#fff`,color:`#171717`,cursor:`pointer`,transition:`all 150ms`,outline:`none`,userSelect:`none`,whiteSpace:`nowrap`},popoverContent:{display:`flex`,flexDirection:`column`,gap:`10px`,width:`320px`,padding:`12px`,backgroundColor:`#fff`,borderRadius:`10px`,boxShadow:`0 10px 38px -10px rgba(22, 23, 24, 0.35), 0 10px 20px -15px rgba(22, 23, 24, 0.2)`,border:`1px solid #e5e5e5`,fontSize:`14px`,fontFamily:`system-ui, -apple-system, sans-serif`,color:`#171717`,zIndex:50},header:{display:`flex`,flexDirection:`column`,gap:`2px`},title:{fontWeight:600,fontSize:`14px`,color:`#171717`,margin:0},description:{fontSize:`13px`,color:`#737373`,margin:0},textarea:{width:`100%`,minHeight:`96px`,padding:`10px`,fontSize:`14px`,fontFamily:`system-ui, -apple-system, sans-serif`,borderRadius:`8px`,borderWidth:`1px`,borderStyle:`solid`,borderColor:`#e5e5e5`,backgroundColor:`#fff`,color:`#171717`,resize:`none`,outline:`none`,transition:`border-color 150ms, box-shadow 150ms`,boxShadow:`none`},textareaFocus:{borderColor:`#a3a3a3`,boxShadow:`0 0 0 3px rgba(163, 163, 163, 0.2)`},buttonGroup:{display:`flex`,justifyContent:`flex-end`,gap:`8px`},cancelButton:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,height:`28px`,padding:`0 10px`,fontSize:`13px`,fontWeight:500,fontFamily:`system-ui, -apple-system, sans-serif`,borderRadius:`6px`,border:`1px solid #e5e5e5`,backgroundColor:`#fff`,color:`#171717`,cursor:`pointer`,transition:`all 150ms`,outline:`none`},submitButton:{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,height:`28px`,padding:`0 10px`,fontSize:`13px`,fontWeight:500,fontFamily:`system-ui, -apple-system, sans-serif`,borderRadius:`6px`,border:`1px solid transparent`,backgroundColor:`#6366f1`,color:`#fff`,cursor:`pointer`,transition:`all 150ms`,outline:`none`},submitButtonDisabled:{opacity:.5,cursor:`not-allowed`}};function ce({children:e=`Modify With AI`,onSuccess:t,onError:i,title:a=`Modify with AI`,description:o=`Describe the changes you want to make`,placeholder:s=`E.g., Make the header sticky, change the button color to blue...`,submitText:u=`Submit`,loadingText:d=`Submitting...`,side:f=`bottom`,align:p=`center`}){let[m,h]=c(``),[g,_]=c(!1),[v,y]=c(!1),[b,x]=c(!1),[ee,te]=c(!1),[ne,re]=c(!1),[ie,ae]=c(!1),ce=async()=>{if(!(!m.trim()||g)){_(!0);try{let{error:e}=await oe(`/api/mwai/api/modify`,{method:`POST`,body:{prompt:m.trim()}});if(e)throw Error(e.message||`Request failed`);h(``),y(!1),t?.()}catch(e){let t=e instanceof Error?e:Error(`Unknown error`);console.error(`Modification failed:`,t),i?.(t)}finally{_(!1)}}},le=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ce())},ue=!m.trim()||g;return r(l.Root,{open:v,onOpenChange:y,children:[n(l.Trigger,{style:{...se.triggerButton,...ee?{backgroundColor:`#f5f5f5`}:{}},onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),children:e}),n(l.Portal,{children:n(l.Positioner,{align:p,side:f,sideOffset:4,style:{zIndex:50},children:r(l.Popup,{style:se.popoverContent,children:[r(`div`,{style:se.header,children:[n(l.Title,{style:se.title,children:a}),n(l.Description,{style:se.description,children:o})]}),n(`textarea`,{placeholder:s,value:m,onChange:e=>h(e.target.value),onKeyDown:le,onFocus:()=>x(!0),onBlur:()=>x(!1),disabled:g,style:{...se.textarea,...b?se.textareaFocus:{}}}),r(`div`,{style:se.buttonGroup,children:[n(`button`,{type:`button`,onClick:()=>y(!1),disabled:g,onMouseEnter:()=>re(!0),onMouseLeave:()=>re(!1),style:{...se.cancelButton,...ne?{backgroundColor:`#f5f5f5`}:{}},children:`Cancel`}),n(`button`,{type:`button`,onClick:ce,disabled:ue,onMouseEnter:()=>ae(!0),onMouseLeave:()=>ae(!1),style:{...se.submitButton,...ue?se.submitButtonDisabled:{},...ie&&!ue?{backgroundColor:`#4f46e5`}:{}},children:g?d:u})]})]})})})]})}
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* scheduler.production.js
|
package/dist/nextjs/api.d.ts
CHANGED
|
@@ -17,18 +17,6 @@ type CreateApiProxyHandlerOptions = {
|
|
|
17
17
|
* This will be injected into API calls that require endUserId
|
|
18
18
|
*/
|
|
19
19
|
getEndUserId: (request: NextRequest) => Promise<string | null>;
|
|
20
|
-
/**
|
|
21
|
-
* GitHub username for the repository owner
|
|
22
|
-
*/
|
|
23
|
-
githubUsername: string;
|
|
24
|
-
/**
|
|
25
|
-
* GitHub repository name
|
|
26
|
-
*/
|
|
27
|
-
githubRepo: string;
|
|
28
|
-
/**
|
|
29
|
-
* GitHub App installation ID
|
|
30
|
-
*/
|
|
31
|
-
githubInstallationId: string;
|
|
32
20
|
};
|
|
33
21
|
declare function generateStaticParams(): Promise<{
|
|
34
22
|
path: "list" | "enable" | "disable" | "modify" | "status";
|
package/dist/nextjs/api.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server";const t=[`list`,`enable`,`disable`,`modify`,`status`],n={modify:{method:`POST`,inBody:!0},disable:{method:`POST`,inBody:!0},enable:{method:`POST`,inBody:!0},list:{method:`GET`,inBody:!1}};async function r(){return t.map(e=>({path:e}))}function i(r){let{baseUrl:i=`https://modifywithai.com`,apiKey:a=process.env.MWAI_API_KEY,getEndUserId:o
|
|
1
|
+
import{NextResponse as e}from"next/server";const t=[`list`,`enable`,`disable`,`modify`,`status`],n={modify:{method:`POST`,inBody:!0},disable:{method:`POST`,inBody:!0},enable:{method:`POST`,inBody:!0},list:{method:`GET`,inBody:!1}};async function r(){return t.map(e=>({path:e}))}function i(r){let{baseUrl:i=`https://modifywithai.com`,apiKey:a=process.env.MWAI_API_KEY,getEndUserId:o}=r;if(!a)throw Error(`MWAI API key is required. Provide it via the apiKey option or set the MWAI_API_KEY environment variable.`);async function s(r,{params:s}){let c=(await s).path;if(!t.includes(c))return e.json({error:`Not found`},{status:404});let l=c,u=await o(r),d=n[l];if(d&&!u)return e.json({error:`Unauthorized - end user ID required`},{status:401});let f=new URL(`/api/${c}`,i);r.nextUrl.searchParams.forEach((e,t)=>{f.searchParams.set(t,e)});let p=new Headers({"Content-Type":`application/json`,"x-api-key":a}),m;if(r.method===`POST`||r.method===`PUT`||r.method===`PATCH`)try{let e=await r.json();d?.inBody&&u&&(e.endUserId=u),m=JSON.stringify(e)}catch{}r.method===`GET`&&d&&!d.inBody&&u&&f.searchParams.set(`endUserId`,u);let h=await fetch(f.toString(),{method:r.method,headers:p,body:m}),g=await h.text();return new Response(g,{status:h.status,statusText:h.statusText,headers:{"Content-Type":h.headers.get(`Content-Type`)||`application/json`}})}return{GET:s,POST:s,PUT:s,PATCH:s,DELETE:s}}export{i as createNextjsHandler,r as generateStaticParams};
|