ima2-gen 3.25.0 → 3.26.0
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/CHANGELOG.md +7 -0
- package/README.md +10 -2
- package/bin/commands/update.js +161 -0
- package/bin/ima2.js +11 -8
- package/bin/lib/helpText.js +1 -0
- package/bin/lib/npmUpdate.js +149 -0
- package/bin/lib/updateNotice.js +30 -0
- package/config.js +10 -0
- package/docs/API.md +13 -0
- package/docs/migration/runtime-test-inventory.md +6 -1
- package/lib/updateCache.js +128 -0
- package/lib/updateCheck.js +118 -0
- package/lib/updateVersion.js +59 -0
- package/package.json +2 -2
- package/routes/events.js +8 -3
- package/routes/index.js +2 -0
- package/routes/update.js +67 -0
- package/server.js +7 -0
- package/skills/ima2/SKILL.md +4 -0
- package/ui/dist/.vite/manifest.json +71 -64
- package/ui/dist/assets/{AgentWorkspace-DXPJup3F.js → AgentWorkspace-DGEWNErN.js} +1 -1
- package/ui/dist/assets/App-CZZNsSpb.css +1 -0
- package/ui/dist/assets/App-b7KJO01r.js +9 -0
- package/ui/dist/assets/AssetGenWorkspace-woj0orEW.js +2 -0
- package/ui/dist/assets/{AssetMediaLightbox-CV9ME5oR.js → AssetMediaLightbox-39eeVLgg.js} +1 -1
- package/ui/dist/assets/{AssetsWorkspace-DWzOEvQE.js → AssetsWorkspace-feT-v8BY.js} +1 -1
- package/ui/dist/assets/{CardNewsWorkspace-B1qS17V6.js → CardNewsWorkspace-Bce7Qq0s.js} +1 -1
- package/ui/dist/assets/{GenerationRequestLogPanel-DyFi62oC.js → GenerationRequestLogPanel-D6jO_fXj.js} +1 -1
- package/ui/dist/assets/{HomeWorkspace-BHdt4qCg.js → HomeWorkspace-C7SABT2o.js} +1 -1
- package/ui/dist/assets/{KeyingPanel-CyycINzW.js → KeyingPanel-DWaV9fRG.js} +1 -1
- package/ui/dist/assets/{NodeCanvas-BdKhUDjc.js → NodeCanvas-ybOBBYto.js} +1 -1
- package/ui/dist/assets/{PromptBuilderPanel-CMXjpe3Y.js → PromptBuilderPanel-C1DLHD9Q.js} +1 -1
- package/ui/dist/assets/PromptImportDialog-OGyYU5K5.js +2 -0
- package/ui/dist/assets/{PromptImportDiscoverySection-C0WBOpMu.js → PromptImportDiscoverySection-Cwigr40k.js} +1 -1
- package/ui/dist/assets/{PromptImportFolderSection-DqAoW1I_.js → PromptImportFolderSection-B1XqjRbl.js} +1 -1
- package/ui/dist/assets/{PromptLibraryPanel-B6a4fySv.js → PromptLibraryPanel-v7hIoYy-.js} +2 -2
- package/ui/dist/assets/{SettingsWorkspace-BF_e8kUk.js → SettingsWorkspace-CGZXJLgN.js} +1 -1
- package/ui/dist/assets/{SpriteRecipeWorkspace-BbkGaNby.js → SpriteRecipeWorkspace-Cm5wizr5.js} +1 -1
- package/ui/dist/assets/{index-CDZTiRZg.js → index-CJ-sBrSx.js} +9 -8
- package/ui/dist/assets/{index-BrM_ZMPs.js → index-CUMOJ4Vx.js} +3 -3
- package/ui/dist/assets/{pptxgen.es-DWAWViwz.js → pptxgen.es-XHiluGIr.js} +1 -1
- package/ui/dist/assets/{promptBuilderStore-CCMVetZf.js → promptBuilderStore-BKNNtgtk.js} +1 -1
- package/ui/dist/assets/useAgentDialogFocus-CZabQdET.js +1 -0
- package/ui/dist/index.html +1 -1
- package/ui/dist/assets/App-BdynRa0c.js +0 -9
- package/ui/dist/assets/AssetGenWorkspace-CFjZEEJn.js +0 -2
- package/ui/dist/assets/PromptImportDialog-Dd1sw7H6.js +0 -2
- package/ui/dist/assets/useAgentDialogFocus-Cxfj1Zq7.js +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SpriteRecipeWorkspace-BbkGaNby.js","assets/index-CDZTiRZg.js","assets/index-Dznqt1dP.css","assets/App-BdynRa0c.js","assets/AssetMediaLightbox-CV9ME5oR.js","assets/useAgentDialogFocus-Cxfj1Zq7.js","assets/KeyingPanel-CyycINzW.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as p,j as e,_ as U}from"./index-CDZTiRZg.js";import{u as G,a as n,ac as Q,ad as Z,aa as J,k as X,ae as Y,af as ee,ab as se}from"./App-BdynRa0c.js";import{A as te}from"./AssetMediaLightbox-CV9ME5oR.js";import{K as ae}from"./KeyingPanel-CyycINzW.js";const ne=48;function le({selectedAssetId:t,onPreview:g,onAssetsLoaded:c}){const{t:r}=G(),l=n(d=>d.selectedProjectId),i=n(d=>d.assetGenItems.length),[m,h]=p.useState([]),[v,u]=p.useState(!1);return p.useEffect(()=>{let d=!1;return Q({kind:null,folderId:l,tag:null,q:"",limit:ne}).then(b=>{if(d)return;const o=b.assets.filter(j=>j.filePath&&(j.kind==="image"||j.kind==="video"));h(o),c?.(o.length),u(!1)}).catch(()=>{d||u(!0)}),()=>{d=!0}},[l,i]),e.jsxs("aside",{className:"assetgen-rail","aria-label":r("assetGen.railTitle"),children:[e.jsx("h2",{className:"assetgen-rail__title",children:r("assetGen.railTitle")}),v?e.jsx("p",{className:"assetgen-rail__empty",children:r("assetGen.railError")}):m.length===0?e.jsx("p",{className:"assetgen-rail__empty",children:r("assetGen.railEmpty")}):e.jsx("div",{className:"assetgen-rail__list",role:"listbox","aria-label":r("assetGen.railTitle"),children:(()=>{const d=new Map;for(const o of m)d.set(o.name,(d.get(o.name)??0)+1);const b=new Map;return m.map(o=>{const j=o.filePath?Z(o.filePath):null;if(!j)return null;const a=t===o.id,k=d.get(o.name)??1,x=(b.get(o.name)??0)+1;b.set(o.name,x);const f=k>1?`#${x} ${o.name}`:o.name;return e.jsxs("button",{type:"button",role:"option","aria-selected":a,className:`assetgen-rail__tile${a?" is-selected":""}`,title:f,onClick:()=>g(J(o),o.id),children:[o.kind==="video"?e.jsx("video",{src:j,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}):e.jsx("img",{src:j,alt:"",loading:"lazy",decoding:"async"}),e.jsx("span",{className:"assetgen-rail__name",children:f})]},o.id)})})()})]})}const re=[{value:"chroma-green",swatch:"#00c853",labelKey:"assetGen.bgChroma"},{value:"white",swatch:"#ffffff",labelKey:"assetGen.bgWhite"},{value:"black",swatch:"#111111",labelKey:"assetGen.bgBlack"},{value:"transparent",swatch:null,labelKey:"assetGen.bgTransparent"}];function ie(){const{t}=G(),g=n(i=>i.assetGenBackground),c=n(i=>i.setAssetGenBackground),r=n(i=>i.assetGenProvider),l=r!=="grok"&&r!=="grok-api";return e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-bg-label",children:t("assetGen.background")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-bg-label",children:re.map(i=>{const m=i.value==="transparent"&&!l;return e.jsxs("button",{type:"button",className:g===i.value?"is-active":"","aria-pressed":g===i.value,disabled:m,...m?{title:t("assetGen.bgTransparentGptOnly")}:{},onClick:()=>c(i.value),children:[e.jsx("span",{className:i.swatch===null?"assetgen-bg-picker__swatch assetgen-bg-picker__swatch--alpha":"assetgen-bg-picker__swatch",...i.swatch===null?{}:{style:{background:i.swatch}},"aria-hidden":"true"}),t(i.labelKey)]},i.value)})}),e.jsx("p",{className:"assetgen-field__hint",children:t(l?g==="transparent"?"assetGen.backgroundHintTransparent":"assetGen.backgroundHint":"assetGen.bgTransparentGptOnly")})]})}const oe=[{value:"oauth",labelKey:"assetGen.modelGpt"},{value:"grok",labelKey:"assetGen.modelGrok"}];function ce(){const{t}=G(),g=n(l=>l.assetGenProvider),c=n(l=>l.setAssetGenProvider),r=g==="grok"||g==="grok-api"?"grok":"oauth";return e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-model-label",children:t("assetGen.model")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-model-label",children:oe.map(l=>e.jsx("button",{type:"button",className:r===l.value?"is-active":"","aria-pressed":r===l.value,onClick:()=>c(l.value),children:t(l.labelKey)},l.value))})]})}function de({onClose:t,onSelect:g}){const{t:c}=G(),r=n(u=>u.assetsFolders),[l,i]=p.useState(""),m=p.useRef(null),h=X(!0,t),v=p.useMemo(()=>{const u=r.filter(b=>b.parentId===null),d=l.trim().toLowerCase();return d?u.filter(b=>b.name.toLowerCase().includes(d)):u},[r,l]);return e.jsx("div",{className:"assetgen-popup-backdrop",onClick:t,children:e.jsxs("div",{ref:h,className:"assetgen-popup",role:"dialog","aria-modal":"true","aria-label":c("project.search"),onClick:u=>u.stopPropagation(),children:[e.jsx("input",{ref:m,type:"search",value:l,placeholder:c("project.searchPlaceholder"),"aria-label":c("project.search"),onChange:u=>i(u.target.value)}),e.jsxs("ul",{role:"listbox","aria-label":c("project.select"),children:[e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{g(null),t()},children:c("project.unassigned")})}),v.map(u=>e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{g(u.id),t()},children:u.name})},u.id)),v.length===0&&l.trim()?e.jsx("li",{className:"assetgen-popup__empty",children:c("project.searchEmpty")}):null]}),e.jsx("button",{type:"button",className:"assetgen-popup__close",onClick:t,children:c("project.close")})]})})}function ue(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})})}function pe(){const{t}=G(),g=n(a=>a.assetsFolders),c=n(a=>a.selectedProjectId),r=n(a=>a.setSelectedProject),l=n(a=>a.loadAssetFolders),i=n(a=>a.createAssetFolder),[m,h]=p.useState(!1),[v,u]=p.useState(!1),d=p.useRef(null);p.useEffect(()=>{l()},[l]),p.useEffect(()=>{c&&g.length>0&&!g.some(a=>a.id===c)&&r(null)},[g,c,r]),p.useEffect(()=>{if(!m)return;const a=x=>{d.current&&!d.current.contains(x.target)&&h(!1)},k=x=>{x.key==="Escape"&&h(!1)};return window.addEventListener("mousedown",a),window.addEventListener("keydown",k),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",k)}},[m]);const b=g.filter(a=>a.parentId===null),o=b.find(a=>a.id===c),j=async()=>{const a=window.prompt(t("project.newPrompt"));if(!a||!a.trim())return;if(await i(a.trim(),null)){await l();const x=n.getState().assetsFolders.find(f=>f.parentId===null&&f.name===a.trim());x&&r(x.id)}h(!1)};return e.jsxs("div",{className:"assetgen-field assetgen-project",ref:d,children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-project-label",children:t("project.select")}),e.jsxs("button",{type:"button",className:"assetgen-project__trigger","aria-haspopup":"listbox","aria-expanded":m,"aria-labelledby":"assetgen-project-label",onClick:()=>h(a=>!a),children:[e.jsx(ue,{}),o?o.name:t("project.unassigned"),e.jsx("span",{className:"assetgen-project__caret","aria-hidden":"true",children:"▾"})]}),m?e.jsxs("ul",{className:"assetgen-project__menu",role:"listbox","aria-labelledby":"assetgen-project-label",children:[e.jsx("li",{children:e.jsx("button",{type:"button","aria-selected":c===null,onClick:()=>{r(null),h(!1)},children:t("project.unassigned")})}),b.map(a=>e.jsx("li",{children:e.jsx("button",{type:"button","aria-selected":c===a.id,onClick:()=>{r(a.id),h(!1)},children:a.name})},a.id)),e.jsx("li",{className:"assetgen-project__menu-divider","aria-hidden":"true"}),e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{j()},children:t("project.new")})}),e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{h(!1),u(!0)},children:t("project.search")})})]}):null,v?e.jsx(de,{onClose:()=>u(!1),onSelect:a=>r(a)}):null]})}const ge=p.lazy(()=>U(()=>import("./SpriteRecipeWorkspace-BbkGaNby.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(t=>({default:t.SpriteRecipeWorkspace})));function me(){const{t}=G(),g=n(s=>s.assetGenPrompt),c=n(s=>s.setAssetGenPrompt),r=n(s=>s.assetGenKind),l=n(s=>s.setAssetGenKind),i=n(s=>s.assetGenProvider),m=n(s=>s.assetGenVideoDuration),h=n(s=>s.setAssetGenVideoDuration),v=n(s=>s.assetGenVideoResolution),u=n(s=>s.setAssetGenVideoResolution),d=n(s=>s.assetGenVideoAspect),b=n(s=>s.setAssetGenVideoAspect),o=n(s=>s.activeGenerations),j=n(s=>s.assetGenItems),a=n(s=>s.generateAssetGen),k=n(s=>s.assetGenSaveFailures),x=n(s=>s.retryAssetGenSave),f=n(s=>s.setKeyingTarget),F=n(s=>s.setVectorizeTarget),A=n(s=>s.assetGenLastError),V=n(s=>s.setAssetGenLastError),I=n(s=>s.setUIMode),_=n(s=>s.assetGenWorkflow),S=n(s=>s.setAssetGenWorkflow),M=Y(),[T,C]=p.useState(null),[O,E]=p.useState(null),[D,W]=p.useState(0),z=p.useCallback(()=>{C(null),E(null)},[]),B=p.useCallback((s,y)=>{E(y),C(s)},[]),H=p.useCallback(()=>{document.getElementById("assetgen-prompt")?.focus()},[]),P=i==="grok"||i==="grok-api",N=r==="video"&&!P?"image":r,K=g.trim().length>0,L=e.jsxs("div",{className:"assetgen-workflow-tabs",role:"tablist","aria-label":t("sprite.tabs.label"),onKeyDown:M,children:[e.jsx("button",{type:"button",role:"tab","aria-selected":_==="generate",tabIndex:_==="generate"?0:-1,onClick:()=>S("generate"),children:t("sprite.tabs.generate")}),e.jsx("button",{type:"button",role:"tab","aria-selected":_==="sprite",tabIndex:_==="sprite"?0:-1,onClick:()=>S("sprite"),children:t("sprite.tabs.sprite")})]});return _==="sprite"?e.jsxs("section",{className:"assetgen-workspace","aria-labelledby":"assetgen-title",children:[e.jsxs("aside",{className:"assetgen-form",children:[e.jsx("h1",{id:"assetgen-title",children:t("sprite.title")}),e.jsx("p",{className:"assetgen-form__lede",children:t("sprite.lede")}),L]}),e.jsx("main",{className:"assetgen-results",children:e.jsx(p.Suspense,{fallback:e.jsx("p",{role:"status",children:t("sprite.loading")}),children:e.jsx(ge,{})})})]}):e.jsxs("section",{className:"assetgen-workspace","aria-labelledby":"assetgen-title",children:[e.jsxs("aside",{className:"assetgen-form",children:[e.jsx("h1",{id:"assetgen-title",children:t("assetGen.title")}),e.jsx("p",{className:"assetgen-form__lede",children:t("assetGen.lede")}),L,e.jsx(pe,{}),e.jsxs("div",{className:"assetgen-field",children:[e.jsx("label",{className:"assetgen-field__label",htmlFor:"assetgen-prompt",children:t("assetGen.prompt")}),e.jsx("textarea",{id:"assetgen-prompt",value:g,rows:4,placeholder:t("assetGen.promptPlaceholder"),onChange:s=>c(s.target.value)})]}),e.jsx(ie,{}),e.jsx(ce,{}),e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-kind-label",children:t("assetGen.kind")}),e.jsxs("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-kind-label",children:[e.jsx("button",{type:"button",className:N==="image"?"is-active":"","aria-pressed":N==="image",onClick:()=>l("image"),children:t("assetGen.kindImage")}),e.jsx("button",{type:"button",className:N==="video"?"is-active":"","aria-pressed":N==="video",disabled:!P,title:P?void 0:t("assetGen.videoGrokOnly"),onClick:()=>l("video"),children:t("assetGen.kindVideo")})]}),P?null:e.jsx("p",{className:"assetgen-field__hint",children:t("assetGen.videoGrokOnly")})]}),N==="video"?e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-video-label",children:t("assetGen.videoOptions")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoDuration"),children:[3,5,8].map(s=>e.jsxs("button",{type:"button",className:m===s?"is-active":"","aria-pressed":m===s,onClick:()=>h(s),children:[s,"s"]},s))}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoResolution"),children:["480p","720p"].map(s=>e.jsx("button",{type:"button",className:v===s?"is-active":"","aria-pressed":v===s,onClick:()=>u(s),children:s},s))}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoAspect"),children:["1:1","16:9","9:16"].map(s=>e.jsx("button",{type:"button",className:d===s?"is-active":"","aria-pressed":d===s,onClick:()=>b(s),children:s},s))})]}):null,e.jsx("button",{type:"button",className:"assetgen-generate",disabled:!K,onClick:()=>{a()},children:o>0?t("assetGen.generating"):t("assetGen.generate")}),K?null:e.jsx("p",{className:"assetgen-generate__hint",children:t("assetGen.generateHint")}),e.jsx(ee,{})]}),e.jsxs("main",{className:"assetgen-results",children:[e.jsxs("div",{className:"assetgen-results__main",children:[A?e.jsxs("div",{className:"assetgen-error",role:"alert",children:[e.jsxs("div",{className:"assetgen-error__text",children:[e.jsx("strong",{children:t("assetGen.errorTitle")}),e.jsx("span",{children:A})]}),e.jsx("button",{type:"button",className:"assetgen-error__dismiss",onClick:()=>V(null),children:t("assetGen.errorDismiss")})]}):null,j.length===0?e.jsx("div",{className:"assetgen-empty",children:D>0?e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:t("assetGen.emptySessionTitle")}),e.jsx("p",{children:t("assetGen.emptySessionBody")}),e.jsx("button",{type:"button",className:"assetgen-empty__cta",onClick:()=>I("assets"),children:t("assetGen.emptySessionCta")})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:t("assetGen.emptyTitle")}),e.jsx("p",{children:t("assetGen.emptyBody")}),e.jsx("button",{type:"button",className:"assetgen-empty__cta",onClick:H,children:t("assetGen.emptyCta")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"assetgen-saved-hint",children:[t("assetGen.savedHint")," ",e.jsx("button",{type:"button",className:"assetgen-saved-hint__link",onClick:()=>I("assets"),children:t("assetGen.savedLink")})]}),e.jsx("div",{className:"assetgen-grid",children:j.map(s=>{const y=s.kind==="edit",R=s.backgroundPreset==="transparent",w=s.mediaType==="video",$=t(w?"assetGen.videoFallback":"assetGen.imageFallback"),q=t(w?"assetGen.previewVideo":"assetGen.previewImage",{prompt:s.prompt?.trim()||$});return e.jsxs("figure",{className:`assetgen-tile${y?" is-keyed":""}${R?" is-alpha":""}`,children:[y?e.jsx("span",{className:"assetgen-tile__badge",children:t("keying.resultBadge")}):null,e.jsxs("button",{type:"button",className:"assetgen-tile__media","aria-label":q,onClick:()=>C(s),children:[w?e.jsx("video",{src:s.url||s.image,poster:s.thumb||void 0,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}):e.jsx("img",{src:s.url||s.image,alt:"",loading:"lazy"}),e.jsx("span",{className:"assetgen-tile__open-hint","aria-hidden":"true",children:t(w?"assetGen.openHintVideo":"assetGen.openHintImage")})]}),e.jsx("figcaption",{title:s.prompt,children:s.prompt}),!y&&!R?e.jsx("button",{type:"button",className:"assetgen-tile__key",onClick:()=>f(s),children:t("keying.open")}):null,w?null:e.jsx("button",{type:"button",className:"assetgen-tile__key",onClick:()=>F(s),children:t("vectorize.open")}),!y&&s.requestId&&k.includes(s.requestId)?e.jsx("button",{type:"button",className:"assetgen-tile__retry",onClick:()=>{x(s.requestId)},children:t("project.saveRetry")}):null]},`${s.requestId}-${s.filename??s.createdAt}`)})})]})]}),e.jsx(le,{selectedAssetId:O,onPreview:B,onAssetsLoaded:W})]}),e.jsx(ae,{}),e.jsx(se,{}),T?e.jsx(te,{item:T,onClose:z}):null]})}const ke=Object.freeze(Object.defineProperty({__proto__:null,AssetGenWorkspace:me},Symbol.toStringTag,{value:"Module"}));export{ke as A,pe as P};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PromptImportDiscoverySection-C0WBOpMu.js","assets/index-CDZTiRZg.js","assets/index-Dznqt1dP.css","assets/App-BdynRa0c.js","assets/PromptImportFolderSection-DqAoW1I_.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{j as e,f as o,_ as J}from"./index-CDZTiRZg.js";import{u as O,a as ne,k as ce,aQ as U,aR as M,aS as pe,aT as de,aU as me}from"./App-BdynRa0c.js";function ue(i){const t=i.source;if(!t)return"";if(t.owner&&t.repo){const h=t.ref?`@${t.ref}`:"",s=t.path?`:${t.path}`:"";return`${t.owner}/${t.repo}${h}${s}`}return t.filename??t.sourceId??t.kind??""}function he(i,t){const h=i.tags.find(s=>s.toLowerCase().startsWith(t));return h?h.slice(t.length):null}function be(i){return i.tags.includes("attribution-required")||i.warnings?.some(t=>t.toLowerCase().includes("attribution"))===!0}function ge({candidate:i,selected:t,disabled:h=!1,onToggleSelected:s,onImportOne:g}){const{t:c}=O();if(!i)return e.jsx("aside",{className:"prompt-import-dialog__candidate-preview","aria-label":c("promptLibrary.previewPrompt"),children:e.jsx("div",{className:"prompt-import-dialog__empty",children:c("promptLibrary.importPreviewEmpty")})});const x=ue(i),b=he(i,"license:"),v=be(i);return e.jsxs("aside",{className:"prompt-import-dialog__candidate-preview","aria-label":c("promptLibrary.previewPrompt"),children:[e.jsxs("div",{className:"prompt-import-dialog__preview-header",children:[e.jsxs("div",{children:[e.jsx("span",{children:c("promptLibrary.previewPrompt")}),e.jsx("h4",{children:i.name})]}),e.jsx("button",{type:"button",onClick:()=>g(i),disabled:h,children:c("promptLibrary.importThisPrompt")})]}),e.jsxs("label",{className:"prompt-import-dialog__preview-select",children:[e.jsx("input",{type:"checkbox",checked:t,disabled:h,onChange:l=>s(i.id,l.target.checked)}),e.jsx("span",{children:c(t?"promptLibrary.selectedPrompt":"promptLibrary.selectPrompt")})]}),e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.promptText")}),e.jsx("p",{children:i.text})]}),i.tags.length>0?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.tags")}),e.jsx("div",{className:"prompt-import-dialog__preview-chips",children:i.tags.map(l=>e.jsx("em",{children:l},l))})]}):null,i.warnings?.length?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.compatibilityWarnings")}),e.jsx("div",{className:"prompt-import-dialog__preview-chips",children:i.warnings.map(l=>e.jsx("b",{children:l},l))})]}):null,x||b||v?e.jsxs("div",{className:"prompt-import-dialog__preview-field",children:[e.jsx("strong",{children:c("promptLibrary.sourceDetails")}),x?e.jsx("small",{children:x}):null,b?e.jsxs("small",{children:[c("promptLibrary.license"),": ",b]}):null,v?e.jsx("small",{children:c("promptLibrary.attributionRequired")}):null]}):null]})}function xe(i){const t=i.source;if(!t)return"";if(t.owner&&t.repo){const h=t.path?` · ${t.path}`:"";return`github · ${t.owner}/${t.repo}${h}`}return t.filename?t.filename:t.sourceId?t.sourceId:t.kind??""}function ye(i){const t=i.replace(/\s+/g," ").trim();return t.length>220?`${t.slice(0,220)}...`:t}function fe({candidates:i,selectedIds:t,activeCandidateId:h,busy:s=!1,onSelectCandidate:g,onToggleSelected:c,onSelectAll:x,onClearSelection:b,onImportOne:v}){const{t:l}=O();if(i.length===0)return e.jsx("section",{className:"prompt-import-dialog__results","aria-label":l("promptLibrary.searchResults"),children:e.jsx("div",{className:"prompt-import-dialog__empty",children:l("promptLibrary.importPreviewEmpty")})});const F=i.every(n=>t.has(n.id));return e.jsxs("section",{className:"prompt-import-dialog__results","aria-label":l("promptLibrary.searchResults"),children:[e.jsxs("header",{className:"prompt-import-dialog__results-header",children:[e.jsx("strong",{children:l("promptLibrary.searchResultsHeader",{count:i.length})}),e.jsxs("div",{className:"prompt-import-dialog__results-header-actions",children:[e.jsx("button",{type:"button",onClick:x,disabled:F,children:l("promptLibrary.selectAllCandidates")}),e.jsx("button",{type:"button",onClick:b,disabled:t.size===0,children:l("promptLibrary.clearCandidateSelection")})]})]}),i.map(n=>{const y=t.has(n.id),j=h===n.id,L=xe(n);return e.jsxs("article",{className:`prompt-import-dialog__result-card${j?" active":""}`,children:[e.jsxs("button",{type:"button",className:"prompt-import-dialog__result-main",onClick:()=>g(n),children:[e.jsx("strong",{children:n.name}),e.jsx("span",{children:ye(n.text)}),L?e.jsx("small",{children:L}):null]}),e.jsxs("div",{className:"prompt-import-dialog__result-meta",children:[n.warnings?.slice(0,2).map(m=>e.jsx("b",{className:"prompt-import-dialog__hint-chip",children:m},m)),n.tags.slice(0,4).map(m=>e.jsx("em",{children:m},m))]}),e.jsxs("div",{className:"prompt-import-dialog__result-actions",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:y,onChange:m=>c(n.id,m.target.checked)}),e.jsx("span",{children:l(y?"promptLibrary.selectedPrompt":"promptLibrary.selectPrompt")})]}),e.jsx("button",{type:"button",onClick:()=>g(n),children:l("promptLibrary.previewPrompt")}),e.jsx("button",{type:"button",onClick:()=>v(n),disabled:s,children:l("promptLibrary.importThisPrompt")})]})]},n.id)})]})}const ve=o.lazy(()=>J(()=>import("./PromptImportDiscoverySection-C0WBOpMu.js"),__vite__mapDeps([0,1,2,3])).then(i=>({default:i.PromptImportDiscoverySection}))),je=o.lazy(()=>J(()=>import("./PromptImportFolderSection-DqAoW1I_.js"),__vite__mapDeps([4,1,2,3])).then(i=>({default:i.PromptImportFolderSection}))),_e=/\.(txt|md|markdown)$/i;function Le({open:i,onClose:t,onImported:h}){const{t:s}=O(),g=ne(r=>r.showToast),c=o.useRef(null),x=ce(i,t),[b,v]=o.useState(""),[l,F]=o.useState([]),[n,y]=o.useState(new Set),[j,L]=o.useState(null),[m,_]=o.useState(!1),[V,u]=o.useState(null),[K,C]=o.useState(!1),[X,R]=o.useState([]),[A,Y]=o.useState(""),[k,$]=o.useState(new Set),[z,N]=o.useState(!1),[W,P]=o.useState([]),[w,q]=o.useState("curated"),[B,Z]=o.useState(!1),G=l.length>0,I=!G||B,ee=o.useCallback(async()=>{const r=await U();R(r.sources),$(new Set)},[]);o.useEffect(()=>{if(!i)return;let r=!1;return U().then(a=>{r||(R(a.sources),$(new Set))}).catch(()=>{r||R([])}),()=>{r=!0}},[i]);const f=o.useCallback(r=>{F(a=>{const p=new Set(a.map(S=>S.id)),d=[...a];for(const S of r)p.has(S.id)||d.push(S);return L(S=>S??d[0]?.id??null),d})},[]),E=o.useCallback(async r=>{const a=r.filter(p=>_e.test(p.name));if(a.length===0){u(s("promptLibrary.importNoValidFiles"));return}_(!0),u(null);try{const p=[];for(const d of a)p.push(await M({source:{kind:"local",filename:d.name,text:await d.text()}}));f(p.flatMap(d=>d.candidates))}catch(p){u(p instanceof Error?p.message:s("promptLibrary.importFailed"))}finally{_(!1)}},[f,s]),re=o.useCallback(async()=>{if(b.trim()){_(!0),u(null);try{const r=await M({source:{kind:"github",input:b.trim()}});f(r.candidates)}catch(r){u(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{_(!1)}}},[f,b,s]),te=o.useCallback(async()=>{N(!0),u(null),P([]);try{const r=await pe({q:A.trim(),sourceIds:[...k]});f(r.results),P(r.warnings),r.results.length===0&&u(s("promptLibrary.noCuratedResults"))}catch(r){u(r instanceof Error?r.message:s("promptLibrary.importFailed"))}finally{N(!1)}},[f,A,k,s]),se=o.useCallback(async r=>{N(!0),u(null),P([]);try{const a=await de({sourceId:r});P(a.warnings),g(s("promptLibrary.curatedRefreshed",{count:a.candidateCount}))}catch(a){u(a instanceof Error?a.message:s("promptLibrary.importFailed"))}finally{N(!1)}},[g,s]),H=o.useCallback((r,a)=>{y(p=>{const d=new Set(p);return a?d.add(r):d.delete(r),d})},[]),ie=o.useCallback(()=>{y(new Set(l.map(r=>r.id)))},[l]),oe=o.useCallback(()=>{y(new Set)},[]),D=o.useCallback(async r=>{if(r.length===0){u(s("promptLibrary.importSelectAtLeastOne"));return}_(!0),u(null);try{const a=await me({candidates:r});await h(),g(s("promptLibrary.imported",{count:a.promptsImported})),t()}catch(a){u(a instanceof Error?a.message:s("promptLibrary.importFailed"))}finally{_(!1)}},[t,h,g,s]),ae=o.useCallback(async()=>{const r=l.filter(a=>n.has(a.id));await D(r)},[l,D,n]),Q=o.useCallback(r=>{y(new Set([r.id])),D([r])},[D]),le=o.useCallback(r=>{const a=Array.from(r.target.files??[]);a.length>0&&E(a),r.target.value=""},[E]),T=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),C(!1);const a=Array.from(r.dataTransfer?.files??[]);a.length>0&&E(a)},[E]);return o.useEffect(()=>{if(!i)return;const r=p=>{p.preventDefault(),C(!0)},a=p=>{p.relatedTarget===null&&C(!1)};return window.addEventListener("dragover",r),window.addEventListener("dragleave",a),window.addEventListener("drop",T),()=>{window.removeEventListener("dragover",r),window.removeEventListener("dragleave",a),window.removeEventListener("drop",T)}},[T,i]),i?e.jsxs("div",{className:"prompt-import-dialog",role:"presentation",children:[e.jsx("div",{className:"prompt-import-dialog__backdrop",onClick:t}),e.jsxs("div",{ref:x,className:"prompt-import-dialog__panel",role:"dialog","aria-modal":"true","aria-labelledby":"prompt-import-title",tabIndex:-1,children:[e.jsxs("div",{className:"prompt-import-dialog__header",children:[e.jsx("h3",{id:"prompt-import-title",children:s("promptLibrary.importTitle")}),e.jsx("button",{type:"button",onClick:t,"aria-label":s("common.close"),children:"×"})]}),I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`prompt-import-dialog__dropzone${K?" active":""}`,onDragOver:r=>{r.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:T,children:[e.jsx("strong",{children:s("promptLibrary.importDropTitle")}),e.jsx("span",{children:s("promptLibrary.importDropHint")}),e.jsx("button",{type:"button",onClick:()=>c.current?.click(),children:s("promptLibrary.importChooseFiles")}),e.jsx("input",{ref:c,className:"prompt-library-panel__file-input",type:"file",accept:".txt,.md,.markdown,text/plain,text/markdown",multiple:!0,onChange:le})]}),e.jsxs("div",{className:"prompt-import-dialog__github",children:[e.jsx("label",{htmlFor:"prompt-import-github",children:s("promptLibrary.importGithubLabel")}),e.jsxs("div",{children:[e.jsx("input",{id:"prompt-import-github",type:"text",value:b,onChange:r=>v(r.target.value),placeholder:"owner/repo:path/to/prompts.md"}),e.jsx("button",{type:"button",onClick:()=>{re()},disabled:m||!b.trim(),children:s("promptLibrary.importPreview")})]})]}),e.jsx(o.Suspense,{fallback:null,children:e.jsx(je,{input:b,disabled:m,onCandidates:f,onError:u})}),e.jsxs("div",{className:"prompt-import-dialog__source-tabs",role:"tablist","aria-label":s("promptLibrary.curatedSources"),children:[e.jsx("button",{type:"button",className:w==="curated"?"active":"",onClick:()=>q("curated"),"aria-pressed":w==="curated",children:s("promptLibrary.curatedSources")}),e.jsx("button",{type:"button",className:w==="discovery"?"active":"",onClick:()=>q("discovery"),"aria-pressed":w==="discovery",children:s("promptLibrary.discovery")})]})]}),(I?w==="curated":!0)&&e.jsxs("div",{className:"prompt-import-dialog__curated",children:[I&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"prompt-import-dialog__section-title",children:[e.jsx("strong",{children:s("promptLibrary.curatedSources")}),e.jsx("span",{children:s("promptLibrary.curatedSourcesHint")})]}),e.jsx("div",{className:"prompt-import-dialog__source-list",children:X.filter(r=>r.trustTier!=="manual-review").map(r=>e.jsxs("label",{className:"prompt-import-dialog__source",children:[e.jsx("input",{type:"checkbox",checked:k.has(r.id),onChange:a=>{$(p=>{const d=new Set(p);return a.target.checked?d.add(r.id):d.delete(r.id),d})}}),e.jsxs("span",{children:[e.jsx("strong",{children:r.displayName}),e.jsxs("small",{children:[r.licenseSpdx," · ",r.trustTier]})]}),e.jsx("button",{type:"button",onClick:()=>{se(r.id)},disabled:z,children:s("promptLibrary.refreshSource")})]},r.id))})]}),e.jsxs("div",{className:"prompt-import-dialog__search-results",children:[e.jsx("input",{type:"text",value:A,onChange:r=>Y(r.target.value),placeholder:s("promptLibrary.curatedSearchPlaceholder"),"aria-label":s("promptLibrary.curatedSearch")}),e.jsx("button",{type:"button",onClick:()=>{te()},disabled:z||k.size===0,children:s(z?"common.loading":"promptLibrary.curatedSearch")})]}),W.length>0?e.jsx("div",{className:"prompt-import-dialog__warning",children:W.slice(0,3).join(" · ")}):null]}),I&&w==="discovery"&&e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"prompt-import-dialog__empty",children:s("common.loading")}),children:e.jsx(ve,{disabled:m,onError:u,onSourcesChanged:ee})}),G&&!B&&e.jsx("button",{type:"button",className:"prompt-import-dialog__add-source-toggle",onClick:()=>Z(!0),children:s("promptLibrary.addAnotherSource")}),V?e.jsx("div",{className:"prompt-import-dialog__error",role:"alert",children:V}):null,e.jsxs("div",{className:"prompt-import-dialog__workspace","aria-live":"polite",children:[e.jsx(fe,{candidates:l,selectedIds:n,activeCandidateId:j,busy:m,onSelectCandidate:r=>L(r.id),onToggleSelected:H,onSelectAll:ie,onClearSelection:oe,onImportOne:Q}),e.jsx(ge,{candidate:l.find(r=>r.id===j)??null,selected:j?n.has(j):!1,disabled:m,onToggleSelected:H,onImportOne:Q})]}),e.jsxs("div",{className:"prompt-import-dialog__footer",children:[e.jsx("button",{type:"button",onClick:t,children:s("common.cancel")}),e.jsx("button",{type:"button",onClick:()=>{ae()},disabled:m||n.size===0,children:m?s("common.loading"):s("promptLibrary.importSelected",{count:n.size})})]})]})]}):null}export{Le as PromptImportDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{k as u}from"./App-BdynRa0c.js";function r(o,a,s={}){return u(o,a,{trap:s.modal!==!1})}export{r as u};
|