@ycodium-ai/plugin-visualize 0.2.3608 → 0.2.3614
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/assets/ui.js +10 -33
- package/locales/en.json +1 -4
- package/locales/zh-CN.json +1 -4
- package/package.json +2 -2
package/assets/ui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var J=window.__ycodiumPluginHost.react;var{Activity:he,Children:
|
|
2
|
-
`,r:"\r",t:" "};function T(e){return Q(e,!1)}function Q(e,t){let n=/"fragment"\s*:\s*"/u.exec(e);if(!n)return;let r="";for(let i=n.index+n[0].length;i<e.length;i++){let o=e[i];if(o===void 0)break;if(o==='"')return r;if(o!=="\\"){r+=o;continue}let l=e[i+1];if(l===void 0)return t?void 0:r;if(l==="u"){let s=e.slice(i+2,i+6);if(s.length<4||!/^[0-9a-fA-F]{4}$/u.test(s))return t?void 0:r;r+=String.fromCharCode(Number.parseInt(s,16)),i+=5;continue}let d=Z[l];if(d===void 0)return t?void 0:r;r+=d,i+=1}return t?void 0:r}var q=/<script\b[^>]*>?(?![\s\S]*<script\b)/iu;function A(e){let t=q.exec(e);if(!t)return e;let n=e.slice(t.index+t[0].length);return/<\/script\s*>/iu.test(n)?e:e.slice(0,t.index)}var K=/(?:workspace copy at|updated card at) (viz\/[a-z0-9][a-z0-9-]{0,80}-[0-9a-f]{8}\.html)/u;function v(e){return e==null?null:K.exec(e)?.[1]??null}function
|
|
1
|
+
var J=window.__ycodiumPluginHost.react;var{Activity:he,Children:pe,Component:ye,Fragment:ve,Profiler:be,PureComponent:xe,StrictMode:ze,Suspense:we,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:ke,__COMPILER_RUNTIME:Se,act:Ie,cache:Ce,cacheSignal:Ee,captureOwnerStack:Te,cloneElement:Ae,createContext:Pe,createElement:m,createRef:Re,forwardRef:Ve,isValidElement:Ne,lazy:_e,memo:Fe,startTransition:Me,unstable_useCacheRefresh:Oe,use:De,useActionState:Le,useCallback:Be,useContext:He,useDebugValue:$e,useDeferredValue:Ue,useEffect:g,useEffectEvent:je,useId:Ge,useImperativeHandle:Ye,useInsertionEffect:We,useLayoutEffect:Je,useMemo:u,useOptimistic:Ze,useReducer:Qe,useRef:E,useState:y,useSyncExternalStore:qe,useTransition:Ke,version:Xe}=J;var Z={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" "};function T(e){return Q(e,!1)}function Q(e,t){let n=/"fragment"\s*:\s*"/u.exec(e);if(!n)return;let r="";for(let i=n.index+n[0].length;i<e.length;i++){let o=e[i];if(o===void 0)break;if(o==='"')return r;if(o!=="\\"){r+=o;continue}let l=e[i+1];if(l===void 0)return t?void 0:r;if(l==="u"){let s=e.slice(i+2,i+6);if(s.length<4||!/^[0-9a-fA-F]{4}$/u.test(s))return t?void 0:r;r+=String.fromCharCode(Number.parseInt(s,16)),i+=5;continue}let d=Z[l];if(d===void 0)return t?void 0:r;r+=d,i+=1}return t?void 0:r}var q=/<script\b[^>]*>?(?![\s\S]*<script\b)/iu;function A(e){let t=q.exec(e);if(!t)return e;let n=e.slice(t.index+t[0].length);return/<\/script\s*>/iu.test(n)?e:e.slice(0,t.index)}var K=/(?:workspace copy at|updated card at) (viz\/[a-z0-9][a-z0-9-]{0,80}-[0-9a-f]{8}\.html)/u;function v(e){return e==null?null:K.exec(e)?.[1]??null}function R(e){if(typeof e!="object"||e===null)return null;let t=e;if(t.kind!=="visualize")return null;let n=t.fragment,r=t.title,i=t.path,o=t.mode,l=t.invocationId,d=t.action,s=t.sizeBytes;return typeof n!="string"||n.trim().length===0||typeof r!="string"||r.trim().length===0||typeof i!="string"||o!=="inline"&&o!=="wide"||d!=="create"&&d!=="update"||typeof l!="string"||typeof s!="number"||!Number.isFinite(s)?null:{kind:"visualize",invocationId:l,fragment:n,title:r,mode:o,path:i,sizeBytes:s,action:d}}function P(e,t){return R(e)??z(t)}function V(e){let t=v(e.confirmation),n=P(e.presentation,e.commandData);if(n!==null&&X(n,e.invocationId,t))return n;if(t===null)return null;let r=P(void 0,e.pathCommandData);return r===null||r.path!==t?null:r}function X(e,t,n){return!(n!==null&&e.path!==n||t.length>0&&e.invocationId!==t&&n===null)}function z(e){return typeof e!="object"||e===null?null:R(e.card)}function N(e){if(typeof e!="object"||e===null)return[];let t=e.cards;if(!Array.isArray(t))return[];let n=[];for(let r of t){if(typeof r!="object"||r===null)continue;let i=r,o=i.mode,l=i.action;typeof i.invocationId!="string"||typeof i.title!="string"||typeof i.path=="string"&&(o!=="inline"&&o!=="wide"||l!=="create"&&l!=="update"||typeof i.sizeBytes=="number"&&n.push({invocationId:i.invocationId,title:i.title,mode:o,path:i.path,sizeBytes:i.sizeBytes,action:l}))}return n}function w(e){return e===void 0?{}:{background:e.surface,foreground:e.foreground,card:e.surface,"muted-foreground":e.muted,border:e.border,primary:e.accent,"primary-foreground":e.surface}}function _(e){return e.querySelector('meta[name="ycodium-plugin-surface"]')!==null}function f(e){return e.i18n.usePluginTranslation()}var F=`
|
|
3
3
|
.ycodium-visualize-ui {
|
|
4
4
|
box-sizing: border-box;
|
|
5
5
|
width: 100%;
|
|
@@ -46,29 +46,6 @@ var J=window.__ycodiumPluginHost.react;var{Activity:he,Children:ye,Component:ve,
|
|
|
46
46
|
text-overflow: ellipsis;
|
|
47
47
|
white-space: nowrap;
|
|
48
48
|
}
|
|
49
|
-
.ycodium-visualize-chips {
|
|
50
|
-
display: flex;
|
|
51
|
-
flex-wrap: wrap;
|
|
52
|
-
gap: 6px;
|
|
53
|
-
}
|
|
54
|
-
.ycodium-visualize-chip {
|
|
55
|
-
display: inline-flex;
|
|
56
|
-
align-items: center;
|
|
57
|
-
gap: 6px;
|
|
58
|
-
max-width: 100%;
|
|
59
|
-
padding: 2px 8px;
|
|
60
|
-
border: 1px solid var(--viz-border, var(--border));
|
|
61
|
-
border-radius: 999px;
|
|
62
|
-
color: var(--viz-muted, var(--muted-foreground));
|
|
63
|
-
font-size: 11px;
|
|
64
|
-
letter-spacing: 0.02em;
|
|
65
|
-
}
|
|
66
|
-
.ycodium-visualize-dot {
|
|
67
|
-
width: 7px;
|
|
68
|
-
height: 7px;
|
|
69
|
-
border-radius: 999px;
|
|
70
|
-
background: var(--viz-accent, var(--primary));
|
|
71
|
-
}
|
|
72
49
|
.ycodium-visualize-copy {
|
|
73
50
|
margin-left: auto;
|
|
74
51
|
}
|
|
@@ -113,7 +90,7 @@ var J=window.__ycodiumPluginHost.react;var{Activity:he,Children:ye,Component:ve,
|
|
|
113
90
|
width: 100%;
|
|
114
91
|
min-width: 0;
|
|
115
92
|
}
|
|
116
|
-
`;var{jsx:a,jsxs:
|
|
93
|
+
`;var{jsx:a,jsxs:h,Fragment:lt}=window.__ycodiumPluginHost.jsxRuntime;function p(e){let t=f(e.bridge),[n,r]=y(!1),i=e.bridge.ui;g(()=>{r(!1)},[e.path]);let o={...e.colors===void 0?{}:{"--viz-fg":e.colors.foreground,"--viz-surface":e.colors.surface,"--viz-muted":e.colors.muted,"--viz-border":e.colors.border,"--viz-accent":e.colors.accent},colorScheme:e.colorScheme};return h("div",{className:"ycodium-visualize-ui","data-mode":e.mode,"data-status":e.status,"data-visualize-card":"",style:o,children:[a("style",{children:F}),h("article",{className:"ycodium-visualize-card","data-mode":e.mode,"data-status":e.status,children:[a("div",{className:"ycodium-visualize-accent"}),h("header",{className:"ycodium-visualize-header",children:[a("h3",{className:"ycodium-visualize-title",children:e.title}),e.path.length>0?m(i.Button,{type:"button",size:"xs",variant:"outline",className:"ycodium-visualize-copy","aria-label":t(n?"card.copied":"card.copyPath"),onClick:()=>{e.bridge.writeClipboard(e.path).then(()=>{r(!0)})}},t(n?"card.copied":"card.copyPath")):null]}),e.sizeBytes!==null||e.path.length>0?h("div",{className:"ycodium-visualize-meta",children:[e.sizeBytes!==null?a("span",{children:t("card.bytes",{count:e.sizeBytes})}):null,e.path.length>0?a("span",{className:"ycodium-visualize-path",children:t("card.path",{path:e.path})}):null]}):null,e.children]})]})}function M(e){return e.className.split(/\s+/u).includes("dark")||e.prefersDark?"dark":"light"}var k="ycodium-visualize:height",b="ycodium-visualize:stream";function O(e,t){if(typeof e!="object"||e===null)return null;let n=e;if(n.type!==k||n.token!==t)return null;let r=n.height;return typeof r!="number"||!Number.isFinite(r)||r<0?null:r}function D(e){return Math.min(960,Math.max(96,Math.round(e)))}var L=`
|
|
117
94
|
:root {
|
|
118
95
|
--control-cursor: var(--ycodium-viz-control-cursor, pointer);
|
|
119
96
|
color-scheme: light dark;
|
|
@@ -232,21 +209,21 @@ table { border-collapse: collapse; width: 100%; }
|
|
|
232
209
|
th, td { text-align: left; padding: 5px 10px; border-bottom: 1px solid var(--border); }
|
|
233
210
|
th { font-weight: 500; color: var(--muted-foreground); font-size: 12px; }
|
|
234
211
|
.table-responsive { overflow-x: auto; }
|
|
235
|
-
`;var
|
|
212
|
+
`;var ee=["https://cdnjs.cloudflare.com","https://cdn.jsdelivr.net","https://esm.sh","https://fonts.bunny.net","https://fonts.googleapis.com","https://fonts.gstatic.com","https://unpkg.com"],S=["blob:","data:",...ee].join(" "),te="'unsafe-inline' 'unsafe-eval' 'wasm-unsafe-eval' blob: data:",ne="'unsafe-inline' blob: data:",re=["default-src 'none'",`script-src ${te}`,`style-src ${ne}`,`img-src ${S}`,`font-src ${S}`,`media-src ${S}`,"worker-src blob:","connect-src blob: data:","frame-src 'none'","object-src 'none'","base-uri 'none'","form-action 'none'"].join("; ");function ie(e){let t=e.trim();return/[;{}<>]/u.test(t)?"":t}function I(e){let t=Object.entries(e.themeVars).map(([n,r])=>[n,ie(r)]).filter(([,n])=>n.length>0).map(([n,r])=>`--ycodium-viz-${n}: ${r};`).join(" ");return`<!doctype html>
|
|
236
213
|
<html lang="en">
|
|
237
214
|
<head>
|
|
238
215
|
<meta charset="utf-8">
|
|
239
216
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
240
217
|
<meta name="referrer" content="no-referrer">
|
|
241
|
-
<meta http-equiv="Content-Security-Policy" content="${
|
|
242
|
-
<title>${
|
|
218
|
+
<meta http-equiv="Content-Security-Policy" content="${re}">
|
|
219
|
+
<title>${se(e.title)}</title>
|
|
243
220
|
<style>${L}
|
|
244
221
|
:root { ${t} color-scheme: ${e.colorScheme}; }
|
|
245
222
|
body { padding: 4px 2px; }</style>
|
|
246
223
|
</head>
|
|
247
224
|
<body>
|
|
248
225
|
${e.fragment}
|
|
249
|
-
<script>${
|
|
226
|
+
<script>${oe(e.reportToken)}<\/script>
|
|
250
227
|
</body>
|
|
251
228
|
</html>
|
|
252
229
|
`}function B(e){return I({...e,title:"preview",fragment:`<div id="ycodium-viz-stream-root"></div>
|
|
@@ -255,7 +232,7 @@ ${e.fragment}
|
|
|
255
232
|
@keyframes ycodium-viz-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
|
|
256
233
|
@media (prefers-reduced-motion: reduce) { .ycodium-viz-enter { animation: none; } }
|
|
257
234
|
</style>
|
|
258
|
-
<script>${
|
|
235
|
+
<script>${ae(e.reportToken)}<\/script>`})}function oe(e){let t=x(e);return`
|
|
259
236
|
(function () {
|
|
260
237
|
var post = function () {
|
|
261
238
|
parent.postMessage({
|
|
@@ -268,7 +245,7 @@ ${e.fragment}
|
|
|
268
245
|
addEventListener('load', post);
|
|
269
246
|
post();
|
|
270
247
|
})();
|
|
271
|
-
`}function
|
|
248
|
+
`}function ae(e){return`
|
|
272
249
|
(function () {
|
|
273
250
|
var root = document.getElementById('ycodium-viz-stream-root');
|
|
274
251
|
var token = ${x(e)};
|
|
@@ -324,4 +301,4 @@ ${e.fragment}
|
|
|
324
301
|
sync(root, next);
|
|
325
302
|
});
|
|
326
303
|
})();
|
|
327
|
-
`}function x(e){return JSON.stringify(e).replaceAll("<","\\u003c")}function
|
|
304
|
+
`}function x(e){return JSON.stringify(e).replaceAll("<","\\u003c")}function se(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function H(e){let t=e.colorScheme??j(),n=G(),r=u(()=>I({fragment:e.fragment,title:e.title,themeVars:{...w(e.colors),"control-cursor":n},colorScheme:t,reportToken:e.token}),[e.colors,e.fragment,e.title,e.token,t,n]);return a(U,{srcDoc:r,token:e.token,title:e.frameLabel,fragment:null})}function $(e){let t=j(),n=G(),r=u(()=>B({themeVars:{...w(e.colors),"control-cursor":n},colorScheme:t,reportToken:e.token}),[e.colors,e.token,t,n]);return a(U,{srcDoc:r,token:e.token,title:e.frameLabel,fragment:A(e.fragment)})}function U(e){let t=E(null),[n,r]=y(160);return g(()=>{let i=t.current;if(i===null)return;let o=l=>{if(l.source!==i.contentWindow)return;let d=O(l.data,e.token);d!==null&&r(D(d))};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[e.token]),g(()=>{let i=t.current;if(i===null||e.fragment===null)return;let o=()=>{i.contentWindow?.postMessage({type:b,token:e.token,fragment:e.fragment},"*")};return i.addEventListener("load",o),o(),()=>i.removeEventListener("load",o)},[e.fragment,e.token]),a("div",{className:"ycodium-visualize-viewport",children:a("iframe",{ref:t,title:e.title,sandbox:"allow-scripts",srcDoc:e.srcDoc,style:{height:n}})})}function j(){let e=window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1;return M({className:document.documentElement.className,prefersDark:e})}function G(){return window.getComputedStyle?.(document.documentElement).getPropertyValue("--control-cursor").trim()||"pointer"}function C(e){let t=f(e.bridge),n=e.threadRef?.threadId??"",r=e.invocationId??"",i=ue(e.entry,e.details),o=v(i),l=e.bridge.commands.useQuery("card",{threadId:n,invocationId:r,path:""},{environmentId:e.environmentId}),d=e.bridge.commands.useQuery("card",{threadId:n,invocationId:o??"",path:o??""},{environmentId:e.environmentId}),s=V({invocationId:r,presentation:e.presentation,commandData:l.data,pathCommandData:d.data,confirmation:i}),c=e.colors;return s===null&&(l.isPending||o!==null&&d.isPending)?a(p,{bridge:e.bridge,title:t("status.loading"),mode:"inline",path:"",sizeBytes:null,status:"loading",...c===void 0?{}:{colors:c},...e.colorScheme===void 0?{}:{colorScheme:e.colorScheme},children:a("p",{className:"ycodium-visualize-note",children:t("card.loading")})}):s===null?a(p,{bridge:e.bridge,title:t("status.missing"),mode:"inline",path:"",sizeBytes:null,status:"missing",...c===void 0?{}:{colors:c},...e.colorScheme===void 0?{}:{colorScheme:e.colorScheme},children:a(ce,{bridge:e.bridge,description:t("card.missing")})}):a(p,{bridge:e.bridge,title:s.title,mode:s.mode,path:s.path,sizeBytes:s.sizeBytes,status:"ready",...c===void 0?{}:{colors:c},...e.colorScheme===void 0?{}:{colorScheme:e.colorScheme},children:a(H,{fragment:s.fragment,title:s.title,token:s.invocationId.length>0?s.invocationId:r,frameLabel:t("card.frame",{title:s.title}),...c===void 0?{}:{colors:c},...e.colorScheme===void 0?{}:{colorScheme:e.colorScheme}})})}function Y(e){return typeof e.argumentsText!="string"?null:a(le,{...e})}function le(e){let t=f(e.bridge),n=T(e.argumentsText),r=n===void 0?"":n.trim();return a(p,{bridge:e.bridge,title:t("status.streaming"),mode:"inline",path:"",sizeBytes:r.length===0?null:new TextEncoder().encode(r).length,status:"streaming",children:r.length===0?a("p",{className:"ycodium-visualize-note",children:t("dock.waiting")}):a($,{fragment:r,token:e.threadId,frameLabel:t("card.frame",{title:t("status.streaming")})})})}function W(e){return!_(document)||e.environmentId===void 0||e.threadId===void 0||e.threadId.length===0?null:a(de,{bridge:e.bridge,environmentId:e.environmentId,threadId:e.threadId})}function de(e){let t=e.bridge.commands.useSubscription("cards",{threadId:e.threadId},{environmentId:e.environmentId}),n=u(()=>N(t.data),[t.data]),r=u(()=>n.map(o=>({environmentId:e.environmentId,payload:{threadId:e.threadId,invocationId:o.invocationId}})),[n,e.environmentId,e.threadId]),i=e.bridge.commands.useQueryEach("card",r);return n.length===0?null:a("div",{className:"ycodium-visualize-stack",children:n.map((o,l)=>{let d=me(i.rows[l]?.data);return a(C,{bridge:e.bridge,environmentId:e.environmentId,invocationId:o.invocationId,entry:ge(o.invocationId),details:{files:[],inputFields:[]},...d===void 0?{}:{presentation:d},...e.threadId.length>0?{threadRef:{environmentId:e.environmentId,threadId:e.threadId}}:{}},o.invocationId)})})}function ce(e){let t=e.bridge.ui;return m(t.Alert,{variant:"error",layout:"inline"},m(t.AlertDescription,null,e.description))}function ue(e,t){let n=e.toolIo?.output??t.output?.text??e.detail;return typeof n=="string"&&n.length>0?n:null}function me(e){return z(e)??void 0}function ge(e){return{id:e,label:"",displayFailed:!1}}function fe(e){return{views:{card(t){return a(C,{bridge:e,...t})}},slots:[{name:"conversation.input.dock",component(t){return a(Y,{bridge:e,...t})}},{name:"conversation.chat.turnTail",component(t){return a(W,{bridge:e,...t})}}]}}export{fe as default};
|
package/locales/en.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"settings": {
|
|
3
3
|
"card": {
|
|
4
4
|
"title": "Visualize",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "The card is sandboxed. Nothing is sent from the card back into the chat."
|
|
6
6
|
},
|
|
7
7
|
"maxFragmentBytes": {
|
|
8
8
|
"label": "Maximum fragment size",
|
|
@@ -11,13 +11,10 @@
|
|
|
11
11
|
},
|
|
12
12
|
"status": {
|
|
13
13
|
"streaming": "Preview",
|
|
14
|
-
"ready": "Ready",
|
|
15
14
|
"loading": "Loading",
|
|
16
15
|
"missing": "Unavailable"
|
|
17
16
|
},
|
|
18
17
|
"card": {
|
|
19
|
-
"modeInline": "Inline",
|
|
20
|
-
"modeWide": "Wide",
|
|
21
18
|
"bytes": "{{count}} bytes",
|
|
22
19
|
"path": "Workspace copy: {{path}}",
|
|
23
20
|
"copyPath": "Copy path",
|
package/locales/zh-CN.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"settings": {
|
|
3
3
|
"card": {
|
|
4
4
|
"title": "可视化",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "卡片在沙箱里运行。卡片里的操作不会发回对话。"
|
|
6
6
|
},
|
|
7
7
|
"maxFragmentBytes": {
|
|
8
8
|
"label": "片段大小上限",
|
|
@@ -11,13 +11,10 @@
|
|
|
11
11
|
},
|
|
12
12
|
"status": {
|
|
13
13
|
"streaming": "预览",
|
|
14
|
-
"ready": "已就绪",
|
|
15
14
|
"loading": "加载中",
|
|
16
15
|
"missing": "不可用"
|
|
17
16
|
},
|
|
18
17
|
"card": {
|
|
19
|
-
"modeInline": "标准",
|
|
20
|
-
"modeWide": "加宽",
|
|
21
18
|
"bytes": "{{count}} 字节",
|
|
22
19
|
"path": "工作区副本:{{path}}",
|
|
23
20
|
"copyPath": "复制路径",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/plugin-visualize",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3614",
|
|
4
4
|
"description": "Renders an inline HTML fragment as a sandboxed card in the conversation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visualization",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"react": "19.2.6",
|
|
26
26
|
"typescript": "~6.0.3",
|
|
27
27
|
"vite-plus": "0.2.2",
|
|
28
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
28
|
+
"@ycodium-ai/plugin-api": "0.2.3614"
|
|
29
29
|
},
|
|
30
30
|
"ycodium": {
|
|
31
31
|
"plugin": "./dist/index.js",
|