efficient-shell 16.5.0 → 16.7.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/README.md +17 -4
- package/dist/{Browser-OCUD3UXN.js → Browser-XCKNVOAU.js} +14 -14
- package/dist/{Calculator-ZG5RX2HX.js → Calculator-VOZDVOYE.js} +22 -22
- package/dist/{CurrencyConverter-AHGYTGKM.js → CurrencyConverter-AMGFHBJE.js} +5 -5
- package/dist/{Files-RC4ASEJ3.js → Files-FACH4PUV.js} +62 -62
- package/dist/{Notepad-BN22VIPZ.js → Notepad-4H26PYBU.js} +8 -8
- package/dist/{PomodoroTimer-GN2OSLJ6.js → PomodoroTimer-77VMHGDE.js} +4 -4
- package/dist/{Preview-KQNGAVBU.js → Preview-RVVXOMRS.js} +9 -9
- package/dist/{Stock-44BSCZOL.js → Stock-PXLNR6A6.js} +3 -3
- package/dist/{Weather-GNGUF6A4.js → Weather-WGLPPZPX.js} +16 -16
- package/dist/{WorldClock-EBZJRH5F.js → WorldClock-UY4B5VKZ.js} +7 -7
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.js +8 -8
- package/dist/apps/index.js +1 -1
- package/dist/bin/browser-check.js +1 -1
- package/dist/bin/media-host-check.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/{chunk-3C7JKJGL.js → chunk-2SOK37OP.js} +1 -1
- package/dist/{chunk-N7EZ2BFE.js → chunk-AG2DEQYB.js} +6 -6
- package/dist/{chunk-H6JJAVYL.js → chunk-EC6XKOAE.js} +1 -1
- package/dist/chunk-EJFJOHPZ.js +1 -0
- package/dist/{chunk-UQPVUPSS.js → chunk-FFCVC4ES.js} +1 -1
- package/dist/{chunk-C4AQXXL3.js → chunk-KTZGG242.js} +1 -1
- package/dist/{chunk-HOTIZZXC.js → chunk-LBXKYVM3.js} +1 -1
- package/dist/chunk-MHKTBQ53.js +5 -0
- package/dist/{chunk-EJTAPBGB.js → chunk-MIHPFJCP.js} +13 -13
- package/dist/chunk-MWJNMENV.js +2 -0
- package/dist/chunk-OHC6Q4QD.js +1 -0
- package/dist/chunk-OYB2ZLJ3.js +1 -0
- package/dist/{chunk-R2QC77NA.js → chunk-RWOBYP7Q.js} +2 -2
- package/dist/{chunk-ATTQTQJI.js → chunk-S24LTOBM.js} +4 -4
- package/dist/chunk-S3TQ3VOK.js +2 -0
- package/dist/chunk-XCTS44UZ.js +1 -0
- package/dist/{chunk-YYGA4Y6E.js → chunk-YAVIKKIQ.js} +1 -1
- package/dist/engine-4U3WOFMO.js +1 -0
- package/dist/format/index.d.ts +24 -6
- package/dist/format/index.js +1 -1
- package/dist/forms/LinkPicker.js +1 -1
- package/dist/forms/MediaLibrary.js +1 -1
- package/dist/forms/Select.d.ts +1 -1
- package/dist/forms/TextToolbar.d.ts +1 -1
- package/dist/forms/textAlign.d.ts +1 -1
- package/dist/icons/efficient-glyphs.d.ts +1 -0
- package/dist/icons/efficient-glyphs.js +1 -1
- package/dist/icons/efficient-looks.d.ts +2 -0
- package/dist/icons/efficient-looks.js +1 -1
- package/dist/icons/efficient-meanings.d.ts +1 -0
- package/dist/icons/efficient-meanings.js +1 -1
- package/dist/icons/efficient.d.ts +1 -0
- package/dist/icons/efficient.js +1 -1
- package/dist/icons/glyphs/ScrollExpandIcon.d.ts +8 -0
- package/dist/icons/glyphs/ScrollExpandIcon.js +1 -0
- package/dist/icons/index.d.ts +2 -2
- package/dist/icons/index.js +1 -1
- package/dist/icons/looks/ScrollExpandMiniIcon.d.ts +8 -0
- package/dist/icons/looks/ScrollExpandMiniIcon.js +1 -0
- package/dist/icons/looks/ScrollExpandSolidIcon.d.ts +8 -0
- package/dist/icons/looks/ScrollExpandSolidIcon.js +1 -0
- package/dist/icons/looks/map.js +1 -1
- package/dist/icons/sets.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +162 -162
- package/dist/model-stage/index.d.ts +69 -5
- package/dist/model-stage/index.js +3 -3
- package/dist/motion/entrance.js +1 -1
- package/dist/motion/values.d.ts +7 -2
- package/dist/motion/values.js +1 -1
- package/dist/motion.css +28 -5
- package/dist/{names-CpcmfUzD.d.ts → names-Bw6ChIJl.d.ts} +1 -1
- package/dist/routine-index.json +1 -1
- package/dist/shell/LanguageSelect.js +1 -1
- package/dist/shell/Markdown.d.ts +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/dist/value-index.json +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-AIJ3G6BD.js +0 -1
- package/dist/chunk-KT57MRN4.js +0 -1
- package/dist/chunk-OMOAD5LL.js +0 -1
- package/dist/chunk-ZHBKWBIJ.js +0 -1
- package/dist/engine-T4D3AZOO.js +0 -1
- /package/dist/{chunk-OQOWFHRZ.js → chunk-4B54NLXF.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{AVAILABLE_CITIES as e,fetchCityWeather as t,cityClock as r,getCondition as n,toFahrenheit as s}from"./chunk-HYHZEQMG.js";import{loadAppearance as i,WidgetSettingsModal as a}from"./chunk-
|
|
1
|
+
import{AVAILABLE_CITIES as e,fetchCityWeather as t,cityClock as r,getCondition as n,toFahrenheit as s}from"./chunk-HYHZEQMG.js";import{loadAppearance as i,WidgetSettingsModal as a}from"./chunk-LBXKYVM3.js";import"./chunk-NHKT5IH6.js";import"./chunk-36BRD5J3.js";import"./chunk-JRQMX4PK.js";import"./chunk-LF27WIN2.js";import{useWidgetSettings as c}from"./chunk-MIHPFJCP.js";import"./chunk-VIPNHDD3.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-PSVGB7KT.js";import"./chunk-5A7MWTXX.js";import"./chunk-YI4T5I5D.js";import"./chunk-TJ5YMXVB.js";import"./chunk-OLXUMB2V.js";import"./chunk-R7OZ2AQD.js";import"./chunk-ZLB5GRL6.js";import"./chunk-EIFNESXS.js";import"./chunk-PO2KNVCC.js";import"./chunk-CJ4OEY3T.js";import"./chunk-LLXI57MB.js";import"./chunk-NQWORKZD.js";import"./chunk-VWGWZY7A.js";import"./chunk-DBQNYJZ6.js";import"./chunk-L2WQOJ3T.js";import"./chunk-5VJVEKVM.js";import"./chunk-YPXONNBV.js";import"./chunk-4PJFL26P.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import{useShellPrefs as o}from"./chunk-POBVGDZP.js";import"./chunk-F3ZOO23R.js";import"./chunk-NJY4HPNB.js";import"./chunk-PM6HY5BH.js";import"./chunk-DWGYC7OD.js";import"./chunk-4YH7U7WL.js";import"./chunk-ABIWAS5K.js";import"./chunk-P56YLT73.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-37FQVY2O.js";import"./chunk-TSZPGDU3.js";import"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as m}from"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-FAPZFMS3.js";import"./chunk-CIZAUBWA.js";import"./chunk-PGN5ME7B.js";import"./chunk-5QRHQCRG.js";import"./chunk-62LW225J.js";import"./chunk-TAHHZGRH.js";import"./chunk-KEFNQEXZ.js";import"./chunk-PU2GJVMG.js";import"./chunk-3FININUU.js";import"./chunk-STKJA4PV.js";import"./chunk-GZ4AMXEU.js";import"./chunk-M6UKCZHT.js";import"./chunk-3AUPCKBR.js";import"./chunk-LYGIOJ3J.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-NRHG4R2Q.js";import"./chunk-C3QOHMR6.js";import{useState as h,useEffect as l,useCallback as p}from"react";import{jsxs as u,Fragment as k,jsx as d}from"react/jsx-runtime";var j="world_clock_appearance",g=["London","Shanghai","New York"];function x(){const{prefs:x,save:b}=o(),[N,f]=h(()=>i(j)),[y,v]=h(!1),[w,F]=h([]),[H,P]=h(N),J={useFahrenheit:!!x.weather_prefs?.useFahrenheit},[B,D]=h(J),[Z,C]=h(()=>/* @__PURE__ */new Date);l(()=>{const e=setInterval(()=>C(/* @__PURE__ */new Date),3e4);return()=>clearInterval(e)},[]);const M=Object.fromEntries(Object.entries(e).map(([e,t])=>[t.tz,e])),O=x.world_clocks,R=(()=>{if(!Array.isArray(O)||0===O.length)return g;const t=[];for(const r of O){const n=e[r]?r:M[r];n&&!t.includes(n)&&t.push(n)}return t.length?t:g})(),[V,G]=h({}),[L,T]=h(!0);l(()=>{let e=!1;return T(!0),(async()=>{const r={};await Promise.all(R.map(async e=>{const n=await t(e);n&&(r[e]=n)})),e||(G(r),T(!1))})(),()=>{e=!0}},[R.join(",")]),c(p(()=>{F([...R]),P({...N}),D({...J}),v(!0)},[R.join(","),N,J.useFahrenheit]));const Y=e=>J.useFahrenheit?`${s(e)}°`:`${e}°`;/* @__PURE__ */
|
|
2
2
|
return u(k,{children:[
|
|
3
|
-
/* @__PURE__ */d("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${N.activeOpacity/100})`,backdropFilter:N.activeBlur>0?`blur(${N.activeBlur}px)`:void 0},children:/* @__PURE__ */u("div",{className:"divide-y divide-gray-200",children:[
|
|
3
|
+
/* @__PURE__ */d("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${N.activeOpacity/100})`,backdropFilter:N.activeBlur>0?`blur(${N.activeBlur}px)`:void 0},children:/* @__PURE__ */u("div",{className:"divide-y divide-gray-200",children:[L&&R.every(e=>!V[e])&&/* @__PURE__ */d(m,{size:"sm",padding:"py-6",label:"Loading"}),R.map(t=>{const s=V[t],{time:i,ampm:a}=r(e[t]?.tz,Z);if(!s)/* @__PURE__ */
|
|
4
4
|
return u("div",{className:"px-4 py-3",children:[
|
|
5
5
|
/* @__PURE__ */u("div",{className:"flex items-baseline justify-between gap-2",children:[
|
|
6
6
|
/* @__PURE__ */d("span",{className:"text-base font-semibold tracking-tight text-ink-strongest truncate",children:t}),
|
|
@@ -10,7 +10,7 @@ return u("div",{className:"px-4 py-3",children:[
|
|
|
10
10
|
return u("div",{className:"px-4 py-3",children:[
|
|
11
11
|
/* @__PURE__ */u("div",{className:"flex items-baseline justify-between gap-2",children:[
|
|
12
12
|
/* @__PURE__ */d("span",{className:"text-base font-semibold tracking-tight text-ink-strongest truncate",children:t}),
|
|
13
|
-
/* @__PURE__ */d("span",{className:"text-2xl font-extralight leading-none tabular-nums tracking-tight text-ink-strongest shrink-0",children:
|
|
13
|
+
/* @__PURE__ */d("span",{className:"text-2xl font-extralight leading-none tabular-nums tracking-tight text-ink-strongest shrink-0",children:Y(s.temp)})]}),
|
|
14
14
|
/* @__PURE__ */u("div",{className:"flex items-center justify-between gap-2 mt-2 text-2xs",children:[
|
|
15
15
|
/* @__PURE__ */u("div",{className:"flex items-center gap-2 min-w-0 text-ink-faint",children:[
|
|
16
16
|
/* @__PURE__ */d("span",{className:"text-base leading-none shrink-0",children:o}),
|
|
@@ -18,15 +18,15 @@ return u("div",{className:"px-4 py-3",children:[
|
|
|
18
18
|
/* @__PURE__ */d("span",{className:"text-3xs font-medium ml-0.5 opacity-70",children:a})]}),
|
|
19
19
|
/* @__PURE__ */d("span",{className:"text-gray-300 shrink-0",children:"·"}),
|
|
20
20
|
/* @__PURE__ */d("span",{className:"truncate",children:c})]}),
|
|
21
|
-
/* @__PURE__ */u("span",{className:"tabular-nums text-gray-500 shrink-0",children:["H:",
|
|
22
|
-
/* @__PURE__ */u(a,{open:y,onClose:()=>v(!1),title:"World Clock Settings",appearance:
|
|
21
|
+
/* @__PURE__ */u("span",{className:"tabular-nums text-gray-500 shrink-0",children:["H:",Y(s.high)," L:",Y(s.low)]})]})]},t)})]})}),
|
|
22
|
+
/* @__PURE__ */u(a,{open:y,onClose:()=>v(!1),title:"World Clock Settings",appearance:H,onAppearanceChange:P,onSave:()=>{0!==w.length&&(b({world_clocks:w,weather_prefs:{...x.weather_prefs??{},useFahrenheit:B.useFahrenheit}}),f(H),localStorage.setItem(j,JSON.stringify(H)),v(!1))},children:[
|
|
23
23
|
/* @__PURE__ */u("div",{children:[
|
|
24
24
|
/* @__PURE__ */d("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Display"}),
|
|
25
25
|
/* @__PURE__ */u("div",{className:"flex items-center gap-3 mb-2",children:[
|
|
26
26
|
/* @__PURE__ */d("span",{className:"text-sm text-gray-600 w-24",children:"Temperature"}),
|
|
27
|
-
/* @__PURE__ */d("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */d("button",{onClick:()=>
|
|
27
|
+
/* @__PURE__ */d("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */d("button",{onClick:()=>D(t=>({...t,useFahrenheit:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(B.useFahrenheit===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
|
|
28
28
|
/* @__PURE__ */d("p",{className:"text-2xs text-ink-faintest mt-1",children:"Shared with the Weather widget."})]}),
|
|
29
29
|
/* @__PURE__ */u("div",{children:[
|
|
30
30
|
/* @__PURE__ */d("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Cities"}),
|
|
31
31
|
/* @__PURE__ */d("div",{className:"grid grid-cols-2 gap-1 max-h-56 overflow-y-auto",children:Object.keys(e).map(e=>/* @__PURE__ */u("label",{className:"flex items-center gap-2 text-sm py-1 cursor-pointer hover:bg-gray-50 rounded px-2",children:[
|
|
32
|
-
/* @__PURE__ */d("input",{type:"checkbox",checked:w.includes(e),onChange:()=>
|
|
32
|
+
/* @__PURE__ */d("input",{type:"checkbox",checked:w.includes(e),onChange:()=>F(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 h-3.5 w-3.5"}),e]},e))})]})]})]})}export{x as default};
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { UIMessage, FileUIPart } from 'ai';
|
|
4
|
-
import { a as IconName } from '../names-
|
|
4
|
+
import { a as IconName } from '../names-Bw6ChIJl.js';
|
|
5
5
|
import { MarkdownTableAction } from '../shell/Markdown.js';
|
|
6
6
|
|
|
7
7
|
/** The conversation the server keeps for this chat. `guestToken` is set for an
|
package/dist/ai/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{StepChainItem as e,StepChain as t}from"../chunk-Z2Z653OO.js";import{Markdown as n}from"../chunk-NPBRNEMR.js";import{Divider as a}from"../chunk-DFOFEBYX.js";import{Avatar as r}from"../chunk-SCNQK5NF.js";import
|
|
2
|
+
import{StepChainItem as e,StepChain as t}from"../chunk-Z2Z653OO.js";import{Markdown as n}from"../chunk-NPBRNEMR.js";import{Divider as a}from"../chunk-DFOFEBYX.js";import{Avatar as r}from"../chunk-SCNQK5NF.js";import{useContextMenu as s,ContextMenu as o}from"../chunk-MF7OELXP.js";import{Banner as i}from"../chunk-OSMRYND3.js";import"../chunk-UJUTS6LJ.js";import"../chunk-Z5TE3MEG.js";import{AttachmentDropZone as l}from"../chunk-43YU7YWL.js";import{Input_default as c}from"../chunk-BYTQRQ5P.js";import{CloseGlyph as d}from"../chunk-TAIH2VIW.js";import"../chunk-TAB3K2WF.js";import"../chunk-AYZY3YNC.js";import{useFileIntake as u,humanSize as p,FileIntakeAlert as m}from"../chunk-TNGIXSTM.js";import{parseChartSpec as h}from"../chunk-CR7T435F.js";import{SpecChart as f}from"../chunk-CMEPDSYB.js";import{formatBytes as g}from"../chunk-OJI4ROSD.js";import{formatTime as x}from"../chunk-NHKT5IH6.js";import"../chunk-36BRD5J3.js";import"../chunk-JRQMX4PK.js";import"../chunk-LF27WIN2.js";import"../chunk-P5TSGXL4.js";import{FlowChart as b}from"../chunk-2EBHJGMM.js";import{parseFlowSpec as v}from"../chunk-FAERBT6Y.js";import"../chunk-SAMPXZF3.js";import"../chunk-CK2YOGUS.js";import"../chunk-A6TOHNJY.js";import"../chunk-VFC6QUEN.js";import"../chunk-AQVPWUJ3.js";import"../chunk-465RRWBY.js";import{ChartSkeleton as y}from"../chunk-MEFB2KGF.js";import"../chunk-CNYAHYE6.js";import"../chunk-NJY4HPNB.js";import"../chunk-PM6HY5BH.js";import"../chunk-DWGYC7OD.js";import{IconButton_default as w}from"../chunk-4YH7U7WL.js";import"../chunk-ABIWAS5K.js";import"../chunk-P56YLT73.js";import"../chunk-URHGHXDN.js";import"../chunk-5QFPTDQF.js";import{Button_default as k}from"../chunk-37FQVY2O.js";import"../chunk-TSZPGDU3.js";import{Icon as N}from"../chunk-ISVODSRP.js";import"../chunk-J75ZT2JQ.js";import{SpinnerRing as A}from"../chunk-R2VKEMZH.js";import"../chunk-BWJZTHZ6.js";import"../chunk-FAPZFMS3.js";import"../chunk-CIZAUBWA.js";import"../chunk-PGN5ME7B.js";import{createShellPortal as C}from"../chunk-5QRHQCRG.js";import"../chunk-62LW225J.js";import"../chunk-TAHHZGRH.js";import"../chunk-KEFNQEXZ.js";import"../chunk-PU2GJVMG.js";import"../chunk-3FININUU.js";import"../chunk-LYGIOJ3J.js";import"../chunk-MRJKZWWV.js";import"../chunk-S4RD6UJU.js";import"../chunk-LLSGIMLG.js";import"../chunk-2JWPNR2U.js";import"../chunk-WDQI3FV6.js";import"../chunk-TZFACUMR.js";import{registerModalEscapeInterceptor as T}from"../chunk-TWVUQUUD.js";import"../chunk-5FYDNH4Y.js";import"../chunk-LNXBTK7Q.js";import"../chunk-MAFUXCPZ.js";import{useShellStrings as j}from"../chunk-NRHG4R2Q.js";import"../chunk-C3QOHMR6.js";import{useRef as S,useEffect as $,useState as R,Fragment as O,useId as _,useLayoutEffect as M,useCallback as D,useMemo as I}from"react";import{isToolUIPart as P,getToolName as L,DefaultChatTransport as z,lastAssistantMessageIsCompleteWithApprovalResponses as F}from"ai";import{jsx as B,jsxs as E,Fragment as U}from"react/jsx-runtime";import{useChat as q}from"@ai-sdk/react";function H(e){if(!P(e))return null;const t=e;return{toolName:L(e),toolCallId:t.toolCallId,state:t.state,input:t.input,output:t.output,errorText:t.errorText,approvalId:t.approval?.id,approved:t.approval?.approved}}function W(e){const t=/* @__PURE__ */new Map;for(const n of e.parts){if("data-tool-summary"!==n.type)continue;const e=n.data;e&&"string"==typeof e.tool_call_id&&Array.isArray(e.rows)&&e.rows.length>0&&t.set(e.tool_call_id,e)}return t}function Y(e){const t=/* @__PURE__ */new Map;for(const n of e.parts){if("data-file"!==n.type)continue;const e=n.data;e&&"string"==typeof e.id&&"string"==typeof e.filename&&t.set(e.id,e)}return[...t.values()]}function Q(e){return e.parts.map(e=>"text"===e.type?e.text:"").join("")}var J="efficient-attachment:";function G(e){return{type:"file",mediaType:e.content_type,filename:e.filename,url:`${J}${e.id}`,providerMetadata:{efficient:{size:e.size}}}}function Z(e){const t=[];for(const n of e.parts){if("file"!==n.type||!n.url.startsWith(J))continue;const e=n.providerMetadata?.efficient?.size;t.push({id:n.url.slice(21),filename:n.filename??"",content_type:n.mediaType,size:"number"==typeof e?e:0})}return t}var K=/* @__PURE__ */new Set(["data-conversation","data-plan","data-followups","data-choices","data-tool-summary","data-error","data-file","data-approval","data-busy"]);function V(e,t){const n=e[e.length-1];if(!n)throw new Error("assistant chat: no message to send");if("user"===n.role){const e=Q(n).trim();if(!e)throw new Error("assistant chat: empty message");const a=Z(n).map(e=>e.id),r=n.metadata?.replyTo?.id;return{conversation_id:t,text:e,approvals:[],...a.length>0?{attachments:a}:{},...r?{reply_to:r}:{}}}const a=function(e){const t=[];for(const n of e.parts){if(!P(n))continue;const e=n;if("approval-responded"!==e.state||!e.approval||"boolean"!=typeof e.approval.approved)continue;const a={approval_id:e.approval.id,approved:e.approval.approved};e.approval.reason&&(a.reason=e.approval.reason),t.push(a)}return t}(n);if(0===a.length)throw new Error("assistant chat: no approval decision to send");return{conversation_id:t,text:null,approvals:a}}var X=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function ee(e,t,n=""){const a=[t.trim(),n.trim()].filter(Boolean).map(X);return 0!==a.length&&new RegExp(`(^|[^\\p{L}\\p{N}_@])(?:${a.join("|")})(?![\\p{L}\\p{N}_@])`,"iu").test(e)}function te(e,t){const n=("string"==typeof t?[t]:[...t]).map(e=>e.trim()).filter(Boolean).sort((e,t)=>t.length-e.length);if(!n.length||!e)return e?[{text:e,mention:!1}]:[];const a=[];let r=0;const s=new RegExp(`(^|[^\\p{L}\\p{N}_@])(${n.map(X).join("|")})(?![\\p{L}\\p{N}_@])`,"giu");for(const t of e.matchAll(s)){const n=(t.index??0)+t[1].length;n>r&&a.push({text:e.slice(r,n),mention:!1}),a.push({text:t[2],mention:!0}),r=n+t[2].length}return r<e.length&&a.push({text:e.slice(r),mention:!1}),a}function ne(e,t){return ee(e,t)?e:`${t.trim()} ${e.trimStart()}`}function ae(e){const t=e.map(e=>e.name).filter(Boolean);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}var re=/* @__PURE__ */new Set(["proposed","approved","running"]);function se(e){return re.has(e.status)}function oe(e){const t=[];for(const n of e.parts)"data-plan"===n.type&&t.push(n.data);return t}function ie(e){const t=/* @__PURE__ */new Map;for(const n of e)for(const e of oe(n))t.delete(e.id),t.set(e.id,e);return t}function le(e){const t=[...ie(e).values()],n=t[t.length-1];if(!n)return null;if(se(n))return n;const a=e[e.length-1];return a&&"assistant"===a.role&&oe(a).some(e=>e.id===n.id)?n:null}function ce(e){const t={};return e.source&&e.source!==e.role&&(t.source=e.source),e.author&&(t.author=e.author),e.asked_by&&(t.askedBy=e.asked_by),e.created_at&&(t.createdAt=e.created_at),e.reply_to&&(t.replyTo=e.reply_to),"assistant"===e.role&&e.run_id&&(t.run_id=e.run_id,t.rating=e.rating??null),Object.keys(t).length>0?{metadata:t}:{}}function de(e,t){const n=/* @__PURE__ */new Map;for(const a of e.parts){if("data-approval"!==a.type)continue;const e=a.data,r=e?.[t];"string"==typeof e?.approval_id&&"string"==typeof r&&r&&n.set(e.approval_id,r)}return n}function ue(e){const t=e.messages.filter(e=>e.text).map(e=>({id:e.id,role:e.role,parts:[...(e.attachments??[]).map(G),{type:"text",text:e.text},...(e.files??[]).map(e=>({type:"data-file",id:`file-${e.id}`,data:e})),...e.update?[{type:"data-update",id:`update-${e.update.id}`,data:e.update}]:[]],...ce(e)})),n=(e.plans??[]).filter(se);return(e.pending_approvals.length>0||n.length>0)&&t.push({id:`pending-approvals-${e.id}`,role:"assistant",parts:[...n.map(e=>({type:"data-plan",id:e.id,data:e})),...e.pending_approvals.map(e=>({type:`tool-${e.tool_name}`,toolCallId:e.tool_call_id??e.approval_id,state:"approval-requested",input:e.input,approval:{id:e.approval_id}})),...e.pending_approvals.filter(e=>e.expires_at||e.notice).map(e=>({type:"data-approval",id:e.approval_id,data:{approval_id:e.approval_id,expires_at:e.expires_at,...e.notice?{notice:e.notice}:{}}}))]}),t}function pe(e,t){const n=e?.message?.trim();if(!n)return t;if(n.startsWith("{")){try{const e=JSON.parse(n);for(const t of["detail","errorText","message","title","error"]){const n=e[t];if("string"==typeof n&&n.trim())return n.trim()}for(const t of Object.values(e)){const e=Array.isArray(t)?t[0]:void 0;if("string"==typeof e&&e.trim()&&e.length<=400)return e.trim()}}catch{return t}return t}return n.startsWith("<")||n.length>400?t:n}var me=/^(load failed|failed to fetch|network ?error( when attempting to fetch resource)?|(the )?network connection was lost|error in input stream|terminated)\.?$/i;function he(e){return!(!e||"AbortError"===e.name)&&me.test(e.message?.trim()??"")}var fe=/* @__PURE__ */new Set(["budget_reached","not_permitted"]);function ge(e,t,n){return he(e)?{text:n.connectionDropped,retryable:!0}:{text:pe(e,n.genericError),retryable:!(t&&fe.has(t))}}function xe(e){const t=e[e.length-1];if(!t)return!1;if("user"===t.role)return""!==Q(t).trim();const n=e[e.length-2];return!(!n||"user"!==n.role||!Q(n).trim())&&!t.parts.some(e=>void 0!==H(e)?.approvalId)}var be=["👍","✅","👀"],ve=["👍","👎","❤️","😂","😮","😢","🙏","🎉","✅","❌","👀","🔥","💯","🚀","👏","🙌","😀","😅","🤔","😬","🤝","💪","📦","🚚","📅","⏰","💰","📈","⚠️","❓","➕","👌"];function ye(e,t,n="You"){const a=e.names.map(a=>t&&a===t&&e.mine?n:a),r=e.mine?[n,...a.filter(e=>e!==n)]:a;return r.length<=1?r[0]??"":`${r.slice(0,-1).join(", ")} and ${r[r.length-1]}`}function we({onPick:e,onClose:t,label:n="Add reaction"}){const a=S(null);$(()=>{const e=e=>{a.current&&!a.current.contains(e.target)&&t()};return document.addEventListener("mousedown",e),a.current?.querySelector("button")?.focus(),()=>document.removeEventListener("mousedown",e)},[t]);/* @__PURE__ */
|
|
3
3
|
return B("div",{ref:a,role:"dialog","aria-label":n,className:"absolute z-20 mt-1 grid w-max grid-cols-8 gap-0.5 rounded-md border border-line bg-surface p-1 shadow-lg","data-emoji-picker":"",onKeyDown:e=>{"Escape"===e.key&&(e.stopPropagation(),t())},children:ve.map(n=>/* @__PURE__ */B("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded text-base hover:bg-surface-sunken focus-visible:bg-surface-sunken","aria-label":n,onClick:()=>{e(n),t()},children:n},n))})}function ke({onReact:e,label:t="Add reaction"}){const[n,a]=R(!1);/* @__PURE__ */
|
|
4
4
|
return E("span",{className:"relative flex items-center gap-0.5","data-reaction-bar":"",children:[be.map(t=>/* @__PURE__ */B("button",{type:"button",className:"flex h-6 w-6 items-center justify-center rounded text-sm hover:bg-surface-sunken","aria-label":`React ${t}`,title:`React ${t}`,onClick:()=>e(t),children:t},t)),
|
|
5
5
|
/* @__PURE__ */B(w,{size:"sm",variant:"ghost","aria-label":t,title:t,"aria-haspopup":"dialog",onClick:()=>a(e=>!e),children:/* @__PURE__ */B(N,{name:"face-smile",className:"h-3.5 w-3.5"})}),n&&/* @__PURE__ */B("span",{className:"absolute right-0 top-full",children:/* @__PURE__ */B(we,{label:t,onPick:e,onClose:()=>a(!1)})})]})}function Ne({reactions:e,onToggle:t,selfName:n,label:a="Add reaction"}){const[r,s]=R(!1);return e.length?/* @__PURE__ */E("div",{className:"relative mt-1 flex flex-wrap items-center gap-1","data-reactions":"",children:[e.map(e=>{const a=ye(e,n),r="inline-flex h-6 items-center gap-1 rounded-full border px-2 text-xs tabular-nums "+(e.mine?"border-accent-border bg-accent-tint text-accent-text":"border-line bg-surface text-ink");/* @__PURE__ */
|
|
@@ -49,12 +49,12 @@ return E("div",{className:"flex items-center gap-2 text-sm text-ink-faint","data
|
|
|
49
49
|
/* @__PURE__ */B("span",{className:"sr-only",children:r}),
|
|
50
50
|
/* @__PURE__ */B(Ke,{}),
|
|
51
51
|
/* @__PURE__ */B("span",{"aria-hidden":"true",className:"min-w-0 truncate",children:`${l}…`}),
|
|
52
|
-
/* @__PURE__ */B("span",{"aria-hidden":"true",className:"shrink-0 text-xs tabular-nums",children:a.replace("{seconds}",String(i))})]})}function Xe({labels:e,placeholder:t,busy:n,focusWhen:a,onSend:r,onStop:s,onNewChat:o,actions:i,attachments:
|
|
53
|
-
/* @__PURE__ */B("span",{role:"status",className:"min-w-0 flex-1 truncate "+(H?"text-accent-text":"text-ink-faint"),children:Y}),Q&&/* @__PURE__ */B(k,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Q.onClick(),M.current?.focus()},children:Q.label})]}):null,G=/* @__PURE__ */E("form",{className:"flex items-end gap-1 p-1",onSubmit:e=>{e.preventDefault(),q()},children:[o&&/* @__PURE__ */B(w,{type:"button",variant:"ghost","aria-label":e.newChat,title:e.newChat,onClick:o,children:/* @__PURE__ */B(N,{name:"compose"})}),
|
|
54
|
-
/* @__PURE__ */B("textarea",{ref:M,"aria-label":e.inputLabel,placeholder:t,rows:1,value:C,onChange:e=>T(e.target.value),onInput:F,onKeyDown:e=>{if("Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing)return e.preventDefault(),void q();"Escape"===e.key&&v&&y&&(e.preventDefault(),y())},className:"block max-h-48 min-w-0 flex-1 resize-none overflow-y-auto bg-transparent py-1 text-sm leading-6 text-ink-strong outline-none placeholder:text-[color:var(--ink-placeholder)] "+(o||
|
|
52
|
+
/* @__PURE__ */B("span",{"aria-hidden":"true",className:"shrink-0 text-xs tabular-nums",children:a.replace("{seconds}",String(i))})]})}function Xe({labels:e,placeholder:t,busy:n,focusWhen:a,onSend:r,onStop:s,onNewChat:o,actions:i,attachments:c,people:h,assistantDecides:f,deciding:g,quiet:x,onAskToReply:b,quote:v,onClearQuote:y}){const[C,T]=R(""),[O,_]=R(!1),M=S(null),I=function(e){const[t,n]=R([]),a=S(0),r=S(!0);$(()=>()=>{r.current=!1},[]);const s=e?.upload,o=D(e=>{if(s)for(const t of e){const e=a.current++;n(n=>[...n,{key:e,name:t.name,size:t.size}]),s(t).then(t=>{r.current&&n(n=>n.map(n=>n.key===e?{...n,attachment:t}:n))},t=>{const a=t instanceof Error&&t.message?t.message:String(t);r.current&&n(t=>t.map(t=>t.key===e?{...t,error:a}:t))})}},[s]),i=t.some(e=>!e.attachment&&!e.error),l=t.flatMap(e=>e.attachment?[e.attachment]:[]);return{pending:t,add:o,remove:e=>n(t=>t.filter(t=>t.key!==e)),clear:()=>n([]),uploading:i,ready:l}}(c),P=j().files,L=u({accept:c?.accept,maxSizeBytes:c?.maxSizeBytes,maxFiles:c?.maxFiles??5,acceptHint:c?.acceptHint,currentCount:I.pending.length,disabled:!c,onAccept:I.add});$(()=>{a&&M.current?.focus()},[a]);const z=v?.id;$(()=>{z&&M.current?.focus()},[z]);const F=()=>{const e=M.current;e&&(e.value&&0!==e.clientWidth?(e.style.height="auto",e.style.height=`${e.scrollHeight}px`):e.style.height="")};$(F,[C]),$(()=>{const e=M.current;if(!e||"undefined"==typeof ResizeObserver)return;let t=e.clientWidth;const n=new ResizeObserver(()=>{e.clientWidth!==t&&(t=e.clientWidth,F())});return n.observe(e),()=>n.disconnect()},[]);const U=n||g||I.uploading||!C.trim(),q=()=>{U||(r(C,I.ready,{peopleOnly:!!f&&O,...v?{reply_to:v.id}:{}}),T(""),I.clear(),L.clearRejections(),v&&y?.())},H=!!h&&(ee(C,e.assistantMention,e.assistantName)||I.pending.length>0),W=!!f&&!O,Y=H?e.toAssistant:W?e.assistantDecides:e.toPeople.replace("{names}",h??""),Q=H||g?null:f?{label:W?e.peopleOnly:e.letAssistantDecide,onClick:()=>_(W)}:{label:e.askAssistant,onClick:()=>T(t=>ne(t,e.assistantMention))},J=h?/* @__PURE__ */E("div",{className:"flex items-center gap-2 px-3 pt-1 text-xs",children:[
|
|
53
|
+
/* @__PURE__ */B("span",{role:"status",className:"min-w-0 flex-1 truncate "+(H?"text-accent-text":"text-ink-faint"),children:Y}),Q&&/* @__PURE__ */B(k,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Q.onClick(),M.current?.focus()},children:Q.label})]}):null,G=/* @__PURE__ */E("form",{className:"flex items-end gap-1 p-1",onSubmit:e=>{e.preventDefault(),q()},children:[o&&/* @__PURE__ */B(w,{type:"button",variant:"ghost","aria-label":e.newChat,title:e.newChat,onClick:o,children:/* @__PURE__ */B(N,{name:"compose"})}),c&&/* @__PURE__ */B(w,{type:"button",variant:"ghost","aria-label":e.attach,title:e.attach,onClick:L.open,disabled:n,children:/* @__PURE__ */B(N,{name:"add"})}),
|
|
54
|
+
/* @__PURE__ */B("textarea",{ref:M,"aria-label":e.inputLabel,placeholder:t,rows:1,value:C,onChange:e=>T(e.target.value),onInput:F,onKeyDown:e=>{if("Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing)return e.preventDefault(),void q();"Escape"===e.key&&v&&y&&(e.preventDefault(),y())},className:"block max-h-48 min-w-0 flex-1 resize-none overflow-y-auto bg-transparent py-1 text-sm leading-6 text-ink-strong outline-none placeholder:text-[color:var(--ink-placeholder)] "+(o||c?"px-1":"px-2")}),i?.map(e=>e.icon?/* @__PURE__ */B(w,{type:"button",variant:"ghost","aria-label":e.label,title:e.label,disabled:!C.trim(),onClick:()=>e.onSelect(C.trim()),children:/* @__PURE__ */B(N,{name:e.icon})},e.key):/* @__PURE__ */B(k,{type:"button",variant:"ghost",disabled:!C.trim(),onClick:()=>e.onSelect(C.trim()),children:e.label},e.key)),/* @__PURE__ */B(w,n?{type:"button",variant:"ghost","aria-label":e.stop,title:e.stop,onClick:s,children:/* @__PURE__ */B(N,{name:"stop-circle"})}:{type:"submit",variant:"ghost","aria-label":e.send,title:e.send,disabled:U,children:/* @__PURE__ */B(N,{name:"enter"})})]}),Z=h&&g?/* @__PURE__ */B("div",{className:"px-1 pb-1",children:/* @__PURE__ */B(Ve,{label:e.deciding,words:[],secondsLabel:e.waitingSeconds,steadyLabel:e.deciding})}):h&&x&&b?/* @__PURE__ */E("div",{className:"flex items-center gap-2 px-1 pb-1 text-xs text-ink-faint",children:[
|
|
55
55
|
/* @__PURE__ */B(Ke,{resting:!0}),
|
|
56
56
|
/* @__PURE__ */B("span",{role:"status",className:"min-w-0 flex-1 truncate",children:e.notReplied}),
|
|
57
|
-
/* @__PURE__ */B(k,{type:"button",size:"sm",variant:"secondary",onClick:b,children:e.askToReply})]}):null,K=v?/* @__PURE__ */B(We,{quote:v,labels:e,onClear:y?()=>{y(),M.current?.focus()}:void 0}):null,V="rounded-2xl border border-line bg-surface shadow-sm transition-colors focus-within:border-line-strong";return
|
|
57
|
+
/* @__PURE__ */B(k,{type:"button",size:"sm",variant:"secondary",onClick:b,children:e.askToReply})]}):null,K=v?/* @__PURE__ */B(We,{quote:v,labels:e,onClear:y?()=>{y(),M.current?.focus()}:void 0}):null,V="rounded-2xl border border-line bg-surface shadow-sm transition-colors focus-within:border-line-strong";return c?/* @__PURE__ */E(l,{intake:L,className:"px-3 pt-2 pb-3",children:[Z,
|
|
58
58
|
/* @__PURE__ */E("div",{className:V,children:[I.pending.length>0&&/* @__PURE__ */B("ul",{className:"flex flex-wrap gap-2 px-3 pt-3",children:I.pending.map(t=>/* @__PURE__ */E("li",{className:"flex max-w-full items-center gap-2 rounded-md border py-1 pl-2 pr-1 text-xs "+(t.error?"border-red-200 bg-red-50 text-red-700":"border-gray-200 bg-gray-50 text-gray-700"),children:[t.attachment||t.error?/* @__PURE__ */B(N,{name:"page",size:14,"aria-hidden":"true"}):/* @__PURE__ */B("span",{role:"status","aria-label":e.attaching,className:"inline-flex",children:/* @__PURE__ */B(A,{className:"h-3 w-3"})}),
|
|
59
59
|
/* @__PURE__ */B("span",{className:"min-w-0 truncate",title:t.error??t.name,children:t.name}),
|
|
60
60
|
/* @__PURE__ */B("span",{className:"shrink-0 tabular-nums text-gray-400",children:p(t.size,P)}),
|
|
@@ -97,11 +97,11 @@ return E("li",{children:[
|
|
|
97
97
|
/* @__PURE__ */B("div",{className:"font-medium text-gray-900",children:Mt(e,r)}),e.title&&/* @__PURE__ */B("div",{className:"text-xs text-gray-600",children:e.title}),t.length>0&&/* @__PURE__ */B("dl",{className:"mt-1 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:t.map(e=>/* @__PURE__ */E("div",{className:"contents",children:[
|
|
98
98
|
/* @__PURE__ */B("dt",{className:"text-gray-500",children:e.label}),
|
|
99
99
|
/* @__PURE__ */B("dd",{className:"min-w-0 break-words text-gray-800",children:e.value})]},e.label))})]},e.key)})}),
|
|
100
|
-
/* @__PURE__ */B(Tt,{approvalId:e,expiresAt:o,expired:"expired"===t?.status,approveLabel:a.approvePlan,labels:a,onApprove:s})]})}function zt({choices:e,label:t,onAnswer:n}){return 0===e.length?null:/* @__PURE__ */B("div",{role:"group","aria-label":t,className:"flex flex-col items-start gap-2 pl-1",children:e.map(e=>/* @__PURE__ */B(k,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function Ft({questions:e,label:t,onAsk:n}){return 0===e.length?null:/* @__PURE__ */B("div",{role:"group","aria-label":t,className:"flex flex-wrap gap-2 pl-1",children:e.map(e=>/* @__PURE__ */B(k,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function Bt({initial:e,labels:t,onRate:n}){const[a,r]=R(e??null),[s,o]=R(!1),[i,
|
|
101
|
-
return B(w,{size:"sm","aria-label":n,title:n,"aria-pressed":a?.verdict===e,disabled:h,onClick:()=>{(async e=>{if(u(!1),a?.verdict===e)return o(!1),void await g(null);const t=await g({verdict:e,note:""});o(t&&"down"===e),
|
|
100
|
+
/* @__PURE__ */B(Tt,{approvalId:e,expiresAt:o,expired:"expired"===t?.status,approveLabel:a.approvePlan,labels:a,onApprove:s})]})}function zt({choices:e,label:t,onAnswer:n}){return 0===e.length?null:/* @__PURE__ */B("div",{role:"group","aria-label":t,className:"flex flex-col items-start gap-2 pl-1",children:e.map(e=>/* @__PURE__ */B(k,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function Ft({questions:e,label:t,onAsk:n}){return 0===e.length?null:/* @__PURE__ */B("div",{role:"group","aria-label":t,className:"flex flex-wrap gap-2 pl-1",children:e.map(e=>/* @__PURE__ */B(k,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function Bt({initial:e,labels:t,onRate:n}){const[a,r]=R(e??null),[s,o]=R(!1),[i,l]=R(""),[d,u]=R(!1),[p,m]=R(!1),[h,f]=R(!1),g=async e=>{const t=a;r(e),m(!1),f(!0);try{return await n(e),!0}catch{return r(t),m(!0),!1}finally{f(!1)}},x=e=>{const n="up"===e?t.rateUp:t.rateDown;/* @__PURE__ */
|
|
101
|
+
return B(w,{size:"sm","aria-label":n,title:n,"aria-pressed":a?.verdict===e,disabled:h,onClick:()=>{(async e=>{if(u(!1),a?.verdict===e)return o(!1),void await g(null);const t=await g({verdict:e,note:""});o(t&&"down"===e),l("")})(e)},children:/* @__PURE__ */B(N,{name:"hand-thumb-up",className:"down"===e?"h-3.5 w-3.5 rotate-180":"h-3.5 w-3.5"})})};/* @__PURE__ */
|
|
102
102
|
return E("div",{role:"group","aria-label":t.rateAnswer,className:"flex min-w-0 flex-1 flex-col gap-1",children:[
|
|
103
103
|
/* @__PURE__ */E("div",{className:"flex items-center gap-1",children:[x("up"),x("down"),d&&/* @__PURE__ */B("span",{role:"status",className:"px-1 text-xs text-gray-500",children:t.rateThanks}),p&&/* @__PURE__ */B("span",{role:"alert",className:"px-1 text-xs text-red-600",children:t.rateFailed})]}),s&&/* @__PURE__ */E("form",{className:"flex items-center gap-2",onSubmit:e=>{(async e=>{e.preventDefault();const t=i.trim();t&&!await g({verdict:"down",note:t})||(o(!1),u(Boolean(t)))})(e)},children:[
|
|
104
|
-
/* @__PURE__ */B("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */B(
|
|
104
|
+
/* @__PURE__ */B("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */B(c,{size:"sm","aria-label":t.rateNote,placeholder:t.rateNote,maxLength:500,value:i,onChange:e=>l(e.target.value),autoFocus:!0})}),
|
|
105
105
|
/* @__PURE__ */B(k,{type:"submit",size:"sm",variant:"secondary",disabled:h||!i.trim(),children:t.rateNoteSend}),
|
|
106
106
|
/* @__PURE__ */B(k,{type:"button",size:"sm",variant:"ghost",onClick:()=>o(!1),children:t.rateNoteSkip})]})]})}function Et(e,t){return n=>{if("chart"===n.lang){if(!n.closed)/* @__PURE__ */return B(y,{height:200});const e=h(n.code);return e?/* @__PURE__ */B(f,{spec:e}):null}if("flow"===n.lang){if(!n.closed)/* @__PURE__ */return B(y,{height:200});const a=v(n.code);return a?/* @__PURE__ */B(b,{spec:a,labels:{downloadPng:e.flowDownloadPng,downloadSvg:e.flowDownloadSvg,toPdf:e.flowToPdf},onToPdf:t?()=>t(e.flowToPdfText):void 0}):null}return null}}function Ut(e,t){return"approval-responded"===e.state&&t.some(t=>{return t.toolName===e.toolName&&"approval-requested"!==t.state&&(t.toolCallId===e.toolCallId||(n=t.input,a=e.input,JSON.stringify(n)===JSON.stringify(a)));var n,a})}function qt(e,t,n,a){const r=e.flatMap(e=>"tool"===e.kind?[$t(e.tool,n,a)]:[]);if(t){const e=r.find(e=>"running"===e.kind);return e?e.base:a.working}const s=[...new Set(r.map(e=>e.base))];return s.length>0?s.join(" · "):a.reasoning}function Ht({message:e,live:t,labels:n}){const a=Q(e),r=a.length>0,s=S(null),[o,i]=R(0);$(()=>{if(!t)return;null===s.current&&(s.current=performance.now());const e=setInterval(()=>i(performance.now()-(s.current??performance.now())),500);return()=>clearInterval(e)},[t]);const l=e.metadata?.usage;let c=null;return t?c=r?bt(a,o,n):null:l&&(c=xt(l,n)),c?/* @__PURE__ */B("div",{className:"px-1 text-xs leading-6 tabular-nums text-gray-500",children:c}):null}function Wt({files:e,labels:t,onOpen:n,start:a}){const r="flex max-w-full items-center gap-2 rounded-md border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700";/* @__PURE__ */
|
|
107
107
|
return B("ul",{className:a?"mt-1 flex flex-wrap gap-2":"flex max-w-[85%] flex-wrap justify-end gap-2",children:e.map(e=>{const a=/* @__PURE__ */E(U,{children:[
|
package/dist/apps/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export{
|
|
2
|
+
export{FILES_ROUTE,chooseInFiles,openFilesInTrashMode,setFilesDemoTree,withdrawFilesChoice}from"../chunk-WAUD3BFJ.js";export{setBrowserStartUrl}from"../chunk-LWLCNQY7.js";export{BUILTIN_APP_INFO}from"../chunk-RWOBYP7Q.js";import{setSpreadsheetPreview as e}from"../chunk-ST6FPYJ7.js";export{FILES_OFFICE_EXTENSIONS,FILES_ROLE_LABELS,FilesQuotaError,SPREADSHEET_PREVIEW_UPDATE_EVENT,claimSpreadsheetPreviewStage,createFileServerStore,filesRoleWrites,peekSpreadsheetPreviewStage,setFilesStore,setSpreadsheetPreview}from"../chunk-ST6FPYJ7.js";import{setPdfPreview as t}from"../chunk-I4RJAMLJ.js";export{setPdfPreview}from"../chunk-I4RJAMLJ.js";import"../chunk-MIHPFJCP.js";import"../chunk-VIPNHDD3.js";import"../chunk-KNUR2UEG.js";import"../chunk-JDCM2VHG.js";import"../chunk-PSVGB7KT.js";import"../chunk-5A7MWTXX.js";import"../chunk-YI4T5I5D.js";import"../chunk-TJ5YMXVB.js";import"../chunk-OLXUMB2V.js";import"../chunk-R7OZ2AQD.js";import"../chunk-ZLB5GRL6.js";import"../chunk-EIFNESXS.js";import"../chunk-PO2KNVCC.js";import"../chunk-CJ4OEY3T.js";import"../chunk-LLXI57MB.js";import"../chunk-NQWORKZD.js";import"../chunk-VWGWZY7A.js";import"../chunk-DBQNYJZ6.js";import"../chunk-L2WQOJ3T.js";import"../chunk-5VJVEKVM.js";import"../chunk-YPXONNBV.js";import"../chunk-4PJFL26P.js";import"../chunk-2QY5BJLA.js";import"../chunk-UGTRSRIW.js";import"../chunk-POBVGDZP.js";import"../chunk-F3ZOO23R.js";import"../chunk-OYB2ZLJ3.js";import"../chunk-NJY4HPNB.js";import"../chunk-PM6HY5BH.js";import"../chunk-DWGYC7OD.js";import"../chunk-4YH7U7WL.js";import"../chunk-ABIWAS5K.js";import"../chunk-P56YLT73.js";import"../chunk-URHGHXDN.js";import"../chunk-5QFPTDQF.js";import"../chunk-37FQVY2O.js";import"../chunk-TSZPGDU3.js";import"../chunk-ISVODSRP.js";import"../chunk-J75ZT2JQ.js";import"../chunk-R2VKEMZH.js";import"../chunk-BWJZTHZ6.js";import"../chunk-FAPZFMS3.js";import"../chunk-CIZAUBWA.js";import"../chunk-PGN5ME7B.js";import"../chunk-5QRHQCRG.js";import"../chunk-62LW225J.js";import"../chunk-TAHHZGRH.js";import"../chunk-KEFNQEXZ.js";import"../chunk-PU2GJVMG.js";import"../chunk-3FININUU.js";import"../chunk-STKJA4PV.js";import"../chunk-GZ4AMXEU.js";import"../chunk-M6UKCZHT.js";import"../chunk-3AUPCKBR.js";import{toast_default as o}from"../chunk-VLT4ZEHT.js";import"../chunk-LYGIOJ3J.js";import"../chunk-MRJKZWWV.js";import"../chunk-TWVUQUUD.js";import"../chunk-5FYDNH4Y.js";import"../chunk-LNXBTK7Q.js";import"../chunk-MAFUXCPZ.js";import{currentShellStrings as n}from"../chunk-NRHG4R2Q.js";import"../chunk-C3QOHMR6.js";import{lazy as i}from"react";function r(e){const t=/\.([a-z0-9]+)(?:[?#].*)?$/i.exec((e||"").trim());return t?t[1].toLowerCase():""}var s=/* @__PURE__ */new Set(["csv","tsv"]),c=/* @__PURE__ */new Set(["xlsx","xls","xlsm","ods"]),m=/* @__PURE__ */new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif"]),a=/* @__PURE__ */new Set(["step","stp","stl","obj","gltf","glb","3mf","iges","igs"]);function u(e){const t=r(e);return"pdf"===t?"pdf":"dxf"===t?"dxf":s.has(t)?"csv":m.has(t)?"image":a.has(t)?"3d":null}function p(e){window.open(e,"_blank","noopener,noreferrer")}async function l(e,t,o){if(t.fetchBlob)return(await t.fetchBlob(o)).text();const n=await fetch(e);if(!n.ok)throw new Error(`fetch failed: ${n.status}`);return n.text()}function h(e,t){return(e instanceof Error?e.message:"")||t}async function k(i,s,m={}){const a=n().attachment,k=i?.url||"",j=i?.filename||a.fallbackName;if(!k&&!m.fetchBlob)return void o.error(a.noLink);const f=u(j)??u(k);if("csv"===f){try{e({csv:await l(k,m,i),filename:j}),s("/spreadsheet")}catch{o.error(a.spreadsheetFailed),k&&p(k)}return}if(c.has(r(j)||r(k)))return o.error(a.workbookUnavailable),void(k&&p(k));if(!f)return k?(o.info(a.noViewer),void p(k)):void o.error(a.noLink);if(!m.fetchBlob)return t({url:k,filename:j,kind:f}),void s("/preview");const d=t({filename:j,kind:f,converting:!0,convertingMessage:m.loadingMessage||a.loading});s("/preview");try{const e=await m.fetchBlob(i);d.update({url:URL.createObjectURL(e),filename:j,kind:f})}catch(e){d.update({filename:j,kind:f,converting:!1,convertingMessage:h(e,a.loadFailed)})}}function j(e,t,o={}){const i=n().attachment,s=[];let m=-1;return e.forEach((e,n)=>{const a=e?.url||"";if(!a&&!o.fetchBlob)return;const p=e?.filename||i.fallbackName;if(c.has(r(p)||r(a)))return;const l=u(p)??u(a);l&&"csv"!==l&&(n===t&&(m=s.length),s.push({att:e,sourceIndex:n,filename:p,url:a,kind:l}))}),{items:s,start:m}}async function f(e,o,i,r={}){const{items:s,start:c}=j(e,o,r);if(c<0||s.length<2){const t=e[o];return void(t&&await k(t,i,r))}const m=n().attachment,a=s.length;let u=null,p=-1;const l=e=>({position:{index:e,count:a},onPrevious:e>0?()=>{d(e-1)}:void 0,onNext:e<a-1?()=>{d(e+1)}:void 0}),f=e=>{u?u.update(e):(u=t(e),i("/preview"))};async function d(e){p=e;const{att:t,filename:o,url:n,kind:i}=s[e];if(r.fetchBlob){f({filename:o,kind:i,converting:!0,convertingMessage:r.loadingMessage||m.loading,...l(e)});try{const n=await r.fetchBlob(t),s=URL.createObjectURL(n);if(p!==e)return void URL.revokeObjectURL(s);f({url:s,filename:o,kind:i,...l(e)})}catch(t){if(p!==e)return;f({filename:o,kind:i,converting:!1,convertingMessage:h(t,m.loadFailed),...l(e)})}}else f({url:n,filename:o,kind:i,...l(e)})}await d(c)}var d=i(()=>import("../Calculator-VOZDVOYE.js")),P=i(()=>import("../Weather-WGLPPZPX.js")),w=i(()=>import("../CurrencyConverter-AMGFHBJE.js")),g=i(()=>import("../PomodoroTimer-77VMHGDE.js")),v=i(()=>import("../Notepad-4H26PYBU.js")),S=i(()=>import("../WorldClock-UY4B5VKZ.js")),B=i(()=>import("../Stock-PXLNR6A6.js")),F=i(()=>import("../Preview-RVVXOMRS.js")),L=i(()=>import("../PdfViewer-KS2BCFSA.js")),E=i(()=>import("../Files-FACH4PUV.js")),R=i(()=>import("../Browser-XCKNVOAU.js")),U={"/calculator":{component:d,label:"Calculator",size:"sm",allowPinOnTop:!0,utility:!0,widget:!0,dimensions:[280,420]},"/notepad":{component:v,label:"Notepad",size:"lg",allowPinOnTop:!0,flushBody:!0},"/weather":{component:P,label:"Weather",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,400]},"/currency":{component:w,label:"Currency Converter",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/pomodoro":{component:g,label:"Pomodoro Timer",size:"sm",utility:!0,widget:!0,dimensions:[320,600]},"/world-clock":{component:S,label:"World Clock",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/stock":{component:B,label:"Stocks",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,360]}},T={"/preview":{component:F,label:"Preview",size:"2xl",appStyle:!0,multiInstance:!0},"/files":{component:E,label:"Files",size:"xl",appStyle:!0}},V={"/browser":{component:R,label:"Browser",size:"2xl",appStyle:!0,multiInstance:!0}},b={...U,...T,...V};export{R as Browser,d as Calculator,w as CurrencyConverter,E as Files,v as Notepad,L as PdfViewer,g as PomodoroTimer,F as Preview,B as Stock,P as Weather,S as WorldClock,u as attachmentKind,b as bundledApps,T as documentApps,k as openAttachment,f as openAttachments,U as utilityApps,j as viewableAttachments,V as webApps};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"module";import{extname as t,isAbsolute as r,join as s,resolve as n}from"path";import{readFileSync as i,existsSync as o,statSync as c,readdirSync as a,mkdtempSync as l,rmSync as d}from"fs";import{execFileSync as h}from"child_process";import{tmpdir as f}from"os";import u from"assert/strict";import{createServer as w}from"http";import{pathToFileURL as p}from"url";function m(t,r){for(const n of[s(process.cwd(),"package.json"),r])try{return e(n)(t)}catch{}throw new Error(`${t} is not installed; add it to this repository's devDependencies`)}var g=class extends Error{};var y="efficient-shell-browser-check",v=`${y}: run real-browser checks, one <name>.entry.tsx page and one <name>.check.mjs check per scenario.\n\n ${y} [--dir tests/browser] [--css <file>]... [--tailwind <entry.css>]... [--serve <urlPath>=<file>]... [--define KEY=JSON]...\n\n --dir <folder> the scenario folder (default tests/browser)\n --css <file> a stylesheet every page links, in the order given\n --tailwind <entry.css> a Tailwind entry, compiled with this repository's @tailwindcss/cli,\n linked like a --css sheet, in the order given\n --serve <urlPath>=<file> a file the page can fetch at urlPath (starts with /)\n --define KEY=JSON replace KEY in the bundle with the JSON value\n --version, --help\n\nesbuild and playwright come from this repository's devDependencies.\nBROWSER_SHARD=<i>/<n> runs one shard. Exits 1 when a check fails.`,b={".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".html":"text/html; charset=utf-8",".json":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".pdf":"application/pdf",".wasm":"application/wasm",".woff2":"font/woff2",".glb":"model/gltf-binary"},$=class extends Error{};function x(e,t,n){const i=r(t)?t:s(e,t);if(!o(i)||!c(i).isFile())throw new $(`${n} ${t}: no such file`);return i}function E(e,t,r){return i(x(e,t,r))}async function j(e){const{dir:t,root:r=process.cwd(),esbuild:i,chromium:o,stylesheets:c=[],serve:l={},define:d={},shard:h,reactDir:f,out:m=e=>console.log(e),err:g=(...e)=>console.error(...e)}=e,y=a(t).filter(e=>e.endsWith(".entry.tsx")).map(e=>e.replace(/\.entry\.tsx$/,"")).sort();if(0===y.length)throw new Error(`no *.entry.tsx found in ${t}`);const v=function(e,t){if(!t)return e;const r=/^(\d+)\/(\d+)$/.exec(t);if(!r)throw new Error(`BROWSER_SHARD must look like 1/3, got ${JSON.stringify(t)}`);const[s,n]=[Number(r[1]),Number(r[2])];if(!(n>=1&&s>=1&&s<=n))throw new Error(`BROWSER_SHARD ${t} is out of range`);return e.filter((e,t)=>t%n===s-1)}(y,h);h&&m(`shard ${h}: ${v.length} of ${y.length} scenarios`);const b=c.map((e,t)=>`/styles-${t+1}.css`),$=new Map(Object.entries(l));c.forEach((e,t)=>$.set(b[t],{contentType:"text/css; charset=utf-8",body:e}));const x=await o.launch({headless:!0});let E=!1;try{for(const e of v){const{default:o,describe:c,viewport:a}=await(import(p(s(t,`${e}.check.mjs`)).href)),l=await i.build({entryPoints:[s(t,`${e}.entry.tsx`)],bundle:!0,write:!1,outdir:s(r,"node_modules",".cache","efficient-shell-browser"),entryNames:"bundle",format:"esm",platform:"browser",target:"chrome120",jsx:"automatic",define:d,logLevel:"warning",...f&&{alias:{react:s(n(f),"react"),"react-dom":s(n(f),"react-dom")}}}),h=l.outputFiles.find(e=>e.path.endsWith(".js")).text,y=l.outputFiles.find(e=>e.path.endsWith(".css"))?.text??null,v=w((e,t)=>{const r=e.url??"/";if("/bundle.js"===r)return t.writeHead(200,{"content-type":"text/javascript; charset=utf-8"}),void t.end(h);if("/bundle.css"===r&&null!==y)return t.writeHead(200,{"content-type":"text/css; charset=utf-8"}),void t.end(y);const s=$.get(r);if(s)return t.writeHead(200,{"content-type":s.contentType}),void t.end(s.body);t.writeHead(200,{"content-type":"text/html; charset=utf-8"}),t.end("<!doctype html><html><head>"+b.map(e=>`<link rel="stylesheet" href="${e}">`).join("")+(null!==y?'<link rel="stylesheet" href="/bundle.css">':"")+'</head><body><div id="root"></div><script type="module" src="/bundle.js"><\/script></body></html>')});await new Promise((e,t)=>{v.once("error",t),v.listen(0,"127.0.0.1",e)});const j=v.address();u.ok(j&&"object"==typeof j);const R=`http://127.0.0.1:${j.port}`,S=await x.newPage({viewport:a??{width:1280,height:720}}),k=(e="")=>S.goto(`${R}/${e}`,{waitUntil:"networkidle"});S.setDefaultTimeout(15e3);const O=[];S.on("pageerror",e=>O.push(e));try{await k(),await o(S,{pageErrors:O,baseUrl:R,open:k}),m(`✔ ${c??e}`)}catch(t){E=!0,g(`✖ ${c??e}`),g(t);for(const e of O)g(" page error:",e.message)}finally{await S.close(),await new Promise(e=>v.close(e))}}}finally{await x.close()}return!E}var R=import.meta.url;process.exitCode=await async function(e,n){let i;try{i=function(e,n,i){let o="tests/browser";const c=[],a={},l={};for(let r=0;r<e.length;r++){const s=e[r];if("--help"===s||"-h"===s)return"help";if("--version"===s||"-v"===s)return"version";const d=s.indexOf("="),h=s.startsWith("--")&&d>0?s.slice(0,d):s;if(!["--dir","--css","--tailwind","--serve","--define"].includes(h))throw new $(`unknown argument "${s}"`);let f;if(h!==s)f=s.slice(d+1);else{if(r+1>=e.length)throw new $(`${h} needs a value`);f=e[++r]}if("--dir"===h)o=f;else if("--css"===h)c.push(E(n,f,h).toString("utf8"));else if("--tailwind"===h){const e=x(n,f,h);try{c.push(i(e))}catch(e){if(e instanceof g)throw new $(e.message);throw e}}else if("--serve"===h){const e=f.indexOf("=");if(e<=0)throw new $(`--serve ${f}: expected <urlPath>=<file>`);const r=f.slice(0,e);if(!r.startsWith("/"))throw new $(`--serve ${f}: the URL path must start with /`);const s=f.slice(e+1);a[r]={contentType:b[t(s).toLowerCase()]??"application/octet-stream",body:E(n,s,h)}}else{const e=f.indexOf("=");if(e<=0)throw new $(`--define ${f}: expected KEY=JSON`);const t=f.slice(0,e),r=f.slice(e+1);try{JSON.parse(r)}catch{throw new $(`--define ${t}: ${JSON.stringify(r)} is not JSON (a string needs its quotes: KEY='"text"')`)}l[t]=r}}return{dir:r(o)?o:s(n,o),stylesheets:c,serve:a,define:l}}(e,n.cwd,n.compileTailwind)}catch(e){if(!(e instanceof $))throw e;return n.err(`${y}: ${e.message}\n\n${v}`),1}if("help"===i)return n.out(v),0;if("version"===i)return n.out(n.version),0;n.env.BROWSER_SHARD&&(i.shard=n.env.BROWSER_SHARD),n.env.REACT_DIR&&(i.reactDir=n.env.REACT_DIR),i.root=n.cwd;try{return await n.runLane(i)?0:1}catch(e){return n.err(`${y}: ${e instanceof Error?e.message:String(e)}`),1}}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),version:"16.
|
|
2
|
+
import{createRequire as e}from"module";import{extname as t,isAbsolute as r,join as s,resolve as n}from"path";import{readFileSync as i,existsSync as o,statSync as c,readdirSync as a,mkdtempSync as l,rmSync as d}from"fs";import{execFileSync as h}from"child_process";import{tmpdir as f}from"os";import u from"assert/strict";import{createServer as w}from"http";import{pathToFileURL as p}from"url";function m(t,r){for(const n of[s(process.cwd(),"package.json"),r])try{return e(n)(t)}catch{}throw new Error(`${t} is not installed; add it to this repository's devDependencies`)}var g=class extends Error{};var y="efficient-shell-browser-check",v=`${y}: run real-browser checks, one <name>.entry.tsx page and one <name>.check.mjs check per scenario.\n\n ${y} [--dir tests/browser] [--css <file>]... [--tailwind <entry.css>]... [--serve <urlPath>=<file>]... [--define KEY=JSON]...\n\n --dir <folder> the scenario folder (default tests/browser)\n --css <file> a stylesheet every page links, in the order given\n --tailwind <entry.css> a Tailwind entry, compiled with this repository's @tailwindcss/cli,\n linked like a --css sheet, in the order given\n --serve <urlPath>=<file> a file the page can fetch at urlPath (starts with /)\n --define KEY=JSON replace KEY in the bundle with the JSON value\n --version, --help\n\nesbuild and playwright come from this repository's devDependencies.\nBROWSER_SHARD=<i>/<n> runs one shard. Exits 1 when a check fails.`,b={".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".html":"text/html; charset=utf-8",".json":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".pdf":"application/pdf",".wasm":"application/wasm",".woff2":"font/woff2",".glb":"model/gltf-binary"},$=class extends Error{};function x(e,t,n){const i=r(t)?t:s(e,t);if(!o(i)||!c(i).isFile())throw new $(`${n} ${t}: no such file`);return i}function E(e,t,r){return i(x(e,t,r))}async function j(e){const{dir:t,root:r=process.cwd(),esbuild:i,chromium:o,stylesheets:c=[],serve:l={},define:d={},shard:h,reactDir:f,out:m=e=>console.log(e),err:g=(...e)=>console.error(...e)}=e,y=a(t).filter(e=>e.endsWith(".entry.tsx")).map(e=>e.replace(/\.entry\.tsx$/,"")).sort();if(0===y.length)throw new Error(`no *.entry.tsx found in ${t}`);const v=function(e,t){if(!t)return e;const r=/^(\d+)\/(\d+)$/.exec(t);if(!r)throw new Error(`BROWSER_SHARD must look like 1/3, got ${JSON.stringify(t)}`);const[s,n]=[Number(r[1]),Number(r[2])];if(!(n>=1&&s>=1&&s<=n))throw new Error(`BROWSER_SHARD ${t} is out of range`);return e.filter((e,t)=>t%n===s-1)}(y,h);h&&m(`shard ${h}: ${v.length} of ${y.length} scenarios`);const b=c.map((e,t)=>`/styles-${t+1}.css`),$=new Map(Object.entries(l));c.forEach((e,t)=>$.set(b[t],{contentType:"text/css; charset=utf-8",body:e}));const x=await o.launch({headless:!0});let E=!1;try{for(const e of v){const{default:o,describe:c,viewport:a}=await(import(p(s(t,`${e}.check.mjs`)).href)),l=await i.build({entryPoints:[s(t,`${e}.entry.tsx`)],bundle:!0,write:!1,outdir:s(r,"node_modules",".cache","efficient-shell-browser"),entryNames:"bundle",format:"esm",platform:"browser",target:"chrome120",jsx:"automatic",define:d,logLevel:"warning",...f&&{alias:{react:s(n(f),"react"),"react-dom":s(n(f),"react-dom")}}}),h=l.outputFiles.find(e=>e.path.endsWith(".js")).text,y=l.outputFiles.find(e=>e.path.endsWith(".css"))?.text??null,v=w((e,t)=>{const r=e.url??"/";if("/bundle.js"===r)return t.writeHead(200,{"content-type":"text/javascript; charset=utf-8"}),void t.end(h);if("/bundle.css"===r&&null!==y)return t.writeHead(200,{"content-type":"text/css; charset=utf-8"}),void t.end(y);const s=$.get(r);if(s)return t.writeHead(200,{"content-type":s.contentType}),void t.end(s.body);t.writeHead(200,{"content-type":"text/html; charset=utf-8"}),t.end("<!doctype html><html><head>"+b.map(e=>`<link rel="stylesheet" href="${e}">`).join("")+(null!==y?'<link rel="stylesheet" href="/bundle.css">':"")+'</head><body><div id="root"></div><script type="module" src="/bundle.js"><\/script></body></html>')});await new Promise((e,t)=>{v.once("error",t),v.listen(0,"127.0.0.1",e)});const j=v.address();u.ok(j&&"object"==typeof j);const R=`http://127.0.0.1:${j.port}`,S=await x.newPage({viewport:a??{width:1280,height:720}}),k=(e="")=>S.goto(`${R}/${e}`,{waitUntil:"networkidle"});S.setDefaultTimeout(15e3);const O=[];S.on("pageerror",e=>O.push(e));try{await k(),await o(S,{pageErrors:O,baseUrl:R,open:k}),m(`✔ ${c??e}`)}catch(t){E=!0,g(`✖ ${c??e}`),g(t);for(const e of O)g(" page error:",e.message)}finally{await S.close(),await new Promise(e=>v.close(e))}}}finally{await x.close()}return!E}var R=import.meta.url;process.exitCode=await async function(e,n){let i;try{i=function(e,n,i){let o="tests/browser";const c=[],a={},l={};for(let r=0;r<e.length;r++){const s=e[r];if("--help"===s||"-h"===s)return"help";if("--version"===s||"-v"===s)return"version";const d=s.indexOf("="),h=s.startsWith("--")&&d>0?s.slice(0,d):s;if(!["--dir","--css","--tailwind","--serve","--define"].includes(h))throw new $(`unknown argument "${s}"`);let f;if(h!==s)f=s.slice(d+1);else{if(r+1>=e.length)throw new $(`${h} needs a value`);f=e[++r]}if("--dir"===h)o=f;else if("--css"===h)c.push(E(n,f,h).toString("utf8"));else if("--tailwind"===h){const e=x(n,f,h);try{c.push(i(e))}catch(e){if(e instanceof g)throw new $(e.message);throw e}}else if("--serve"===h){const e=f.indexOf("=");if(e<=0)throw new $(`--serve ${f}: expected <urlPath>=<file>`);const r=f.slice(0,e);if(!r.startsWith("/"))throw new $(`--serve ${f}: the URL path must start with /`);const s=f.slice(e+1);a[r]={contentType:b[t(s).toLowerCase()]??"application/octet-stream",body:E(n,s,h)}}else{const e=f.indexOf("=");if(e<=0)throw new $(`--define ${f}: expected KEY=JSON`);const t=f.slice(0,e),r=f.slice(e+1);try{JSON.parse(r)}catch{throw new $(`--define ${t}: ${JSON.stringify(r)} is not JSON (a string needs its quotes: KEY='"text"')`)}l[t]=r}}return{dir:r(o)?o:s(n,o),stylesheets:c,serve:a,define:l}}(e,n.cwd,n.compileTailwind)}catch(e){if(!(e instanceof $))throw e;return n.err(`${y}: ${e.message}\n\n${v}`),1}if("help"===i)return n.out(v),0;if("version"===i)return n.out(n.version),0;n.env.BROWSER_SHARD&&(i.shard=n.env.BROWSER_SHARD),n.env.REACT_DIR&&(i.reactDir=n.env.REACT_DIR),i.root=n.cwd;try{return await n.runLane(i)?0:1}catch(e){return n.err(`${y}: ${e instanceof Error?e.message:String(e)}`),1}}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),version:"16.7.0",compileTailwind:e=>function(e,t){if(!o(e)||!c(e).isFile())throw new g(`--tailwind ${e}: no such file`);const r=s(t,"node_modules",".bin","tailwindcss");if(!o(r))throw new g("--tailwind needs the Tailwind CLI: add @tailwindcss/cli to this repository's devDependencies");const n=l(s(f(),"browser-check-css-"));try{const o=s(n,"styles.css");return h(r,["-i",e,"-o",o],{cwd:t,stdio:["ignore","ignore","inherit"]}),i(o,"utf8")}finally{d(n,{recursive:!0,force:!0})}}(e,process.cwd()),runLane:e=>j({...e,esbuild:m("esbuild",R),chromium:m("playwright",R).chromium})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"module";import{join as n}from"path";import{existsSync as t,readFileSync as i,readdirSync as r}from"fs";function o(t){return function(t,i){for(const r of[n(process.cwd(),"package.json"),i])try{return e(r)(t)}catch{}throw new Error(`${t} is not installed; add it to this repository's devDependencies`)}("typescript",t)}var s=/[.+^$()|[\]\\]/g;function a(e){let n="",t=0;for(let i=0;i<e.length;i++){const r=e[i];"*"===r?"*"===e[i+1]?"/"===e[i+2]?(n+="(?:[^/]+/)*",i+=2):(n+=".*",i+=1):n+="[^/]*":"?"===r?n+="[^/]":"{"===r?(n+="(?:",t+=1):"}"===r&&t>0?(n+=")",t-=1):n+=","===r&&t>0?"|":r.replace(s,"\\$&")}if(0!==t)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${n}$`)}function g(e){const n=e.map(a);return e=>n.some(n=>n.test(e))}var c=new Set(["node_modules",".git"]),l=new Set(["dist","coverage",".next",".turbo"]);function d(e){const n=e.search(/[*?{]/),t=-1===n?e:e.slice(0,n),i=t.lastIndexOf("/");return-1===i?"":t.slice(0,i)}function h(e,t){const i=g(t),o=[...new Set(t.map(d))].sort(),s=o.filter(e=>!o.some(n=>n!==e&&(""===n||e.startsWith(`${n}/`)))),a=new Set,h=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?c.has(e.name)||""===t&&l.has(e.name)||h(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)h(e);return[...a].sort(u)}var u=(e,n)=>e<n?-1:e>n?1:0;Object.keys({fast:120,base:160}).map(e=>`--motion-${e}`).join(", "),Object.keys({body:400,control:500,heading:600,figure:700}).map(e=>`--weight-${e}`).join(", "),Object.keys({hairline:1,strong:2,accent:4}).map(e=>`--border-${e}`).join(", "),[2,4,8,12,16,20,24,32,40,48].join("/");var p=(...e)=>["origin",...e].join("-");new RegExp(["(?:transformOrigin|transform-origin)\\s*[:=]\\s*[\"'`]?\\s*(?:top left|left top|0 0|0% 0%|0px 0px)(?![\\w%-])",`(?<![\\w-])!?${p("top","left")}(?![\\w-])`,`(?<![\\w-])!?${p("\\[0_0\\]")}`].join("|"));var f=(...e)=>e.join(""),m="3xs|2xs|xs|sm|base|lg|xl|[2-9]xl";new RegExp(`(?<![\\w-])!?(?:${f("te","xt-")}(?:(?:${m})(?:\\/[\\w.()-]+)?|\\[(?:length:)?[\\d.]+(?:px|rem|em)\\])|${f("fo","nt-")}(?:thin|extralight|light|normal|medium|semibold|bold|extrabold|black|\\[\\d+\\]))(?![\\w-])`),new RegExp(`(?<![\\w-])${f("round","ed")}(?:-(?:full|sm|md|lg|xl|[23]xl|[trblse]|tl|tr|br|bl|\\([^)]*\\)|\\[[^\\]]*\\]))*(?![\\w-])`);new RegExp(`(?<![\\w-])${f("b","g-")}(?!(?:none|transparent|current|inherit|cover|contain|auto|fixed|local|scroll|center|top|bottom|left|right|repeat|no-repeat|clip|origin|blend|linear|radial|conic|gradient|position|size|image)(?![\\w]))[\\w\\[(#][^\\s'"\`]*`);var w=`${m}|left|center|right|justify|start|end|wrap|nowrap|balance|pretty|ellipsis|clip|transparent|current|inherit|shadow`;new RegExp(`(?<![\\w-])${f("te","xt-")}(?!(?:${w})(?![\\w]))(?!\\[[\\d.]+(?:px|rem|em)\\])(?!\\[length:)[\\w\\[(#][^\\s'"\`]*`),new RegExp(`(?<![\\w-])${f("p","[xs]?-")}(?:\\d|\\[|\\()`),new RegExp(`(?<![\\w-])${f("p","y-")}(?:0|px|0\\.5|\\[[0-3](?:\\.\\d+)?px\\])(?![\\w.-])`),new RegExp(`(?<![\\w-])${f("round","ed-full")}(?![\\w-])`),new RegExp(`(?<![\\w-])${f("te","xt-")}(?:xs|2xs|3xs|\\[(?:9|10|11|12)px\\])(?![\\w-])`),new RegExp(`(?<![\\w-])${f("p","y-")}`),new RegExp(`(?<![\\w-])!?(?:${f("dura","tion-")}|${f("del","ay-")})(?:\\d+|\\[[^\\]]+\\])(?![\\w-])|(?<![\\w-])!?${f("fo","nt-")}\\[\\d+\\](?![\\w-])|(?<![\\w-])!?${f("bor","der")}(?:-[xytrblse])?-\\[[\\d.]+px\\](?![\\w-])`,"g");var $={busy:{words:["Accepting","Adding","Applying","Approving","Arranging","Asking","Assigning","Booking","Building","Calculating","Cancelling","Capturing","Changing","Checking","Choosing","Closing","Combining","Comparing","Completing","Confirming","Connecting","Converting","Copying","Correcting","Counting","Creating","Deleting","Detaching","Downloading","Drawing","Duplicating","Emailing","Ending","Exporting","Fetching","Filing","Finding","Flushing","Generating","Grouping","Importing","Linking","Loading","Locating","Looking","Making","Marking","Matching","Measuring","Merging","Moving","Opening","Ordering","Paying","Pending","Posting","Preparing","Previewing","Pricing","Processing","Provisioning","Publishing","Purging","Pushing","Queued","Queuing","Quoting","Re-booking","Re-importing","Re-opening","Reading","Rebooting","Rebuilding","Receiving","Reconciling","Reconnecting","Recording","Refreshing","Refunding","Regenerating","Registering","Reinstating","Rejecting","Removing","Reopening","Requesting","Resending","Resetting","Resolving","Restarting","Restoring","Resuming","Retrying","Reversing","Reverting","Running","Saving","Searching","Sending","Setting","Settling","Sharing","Signing","Splitting","Starting","Submitting","Suggesting","Switching","Syncing","Taking","Testing","Transferring","Typing","Updating","Uploading","Verifying","Waiting","Withdrawing","Working"]}};new Set(($.busy?.words??[]).map(e=>e.toLowerCase()));var x=(...e)=>e.join("-");x("p[xytrblse]?",""),x("max","[wh]",""),x("h",""),x("w",""),x("[wh]",""),x("min","h","");var y=class extends Error{},b=new Set(["$schema","schema","include","exclude","allow"]),R=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),S=e=>"string"==typeof e&&""!==e.trim();var v="d3as2htf4hwbtr.cloudfront.net",k={dealer:{bucket:"inovit-dealer-portal-assets",hosts:["d201q0i87q901p.cloudfront.net"],key_pattern:"^marketing/"},media:{bucket:"regis-media-production",hosts:["media.regis.design","d21nnr9ivf9hcc.cloudfront.net"],key_pattern:"^[a-z0-9_]+/storefront/(?!uploads/thumbs/)"},site:{bucket:"inovit-ecommerce-media",hosts:["cdn.inovit.com","dhxlibd8r3td0.cloudfront.net"],key_pattern:"^images/"}},j=Object.values(k),C=Object.freeze([...new Set([...j.flatMap(e=>e.hosts),v,...j.map(e=>e.bucket)])].sort()),A=new RegExp([...C.map(e=>{return`(?<![\\w-])${n=e,n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w-])`;var n}),"(?<![\\w-])[a-z0-9]+\\.cloudfront\\.net(?![\\w-])","(?<![\\w-])(?:[a-z0-9-]+\\.)*s3(?:[.-][a-z0-9-]+)*\\.amazonaws\\.com(?![\\w-])","s3://"].join("|"),"gi");function E(e,n,t){const i=e.createSourceFile(n,t,e.ScriptTarget.Latest,!0,function(e,n){return n.endsWith(".tsx")?e.ScriptKind.TSX:n.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(n)?e.ScriptKind.JS:e.ScriptKind.TS}(e,n)),r=[],o=(e,n)=>{const t=i.getLineAndCharacterOfPosition(e.getStart(i)).line+1;for(const e of function(e){return[...e.matchAll(A)].map(e=>({match:e[0],index:e.index??0}))}(n)){const i=n.slice(0,e.index);r.push({line:t+(i.match(/\n/g)?.length??0),match:e.match})}},s=n=>{e.isStringLiteral(n)||e.isNoSubstitutionTemplateLiteral(n)||e.isTemplateHead(n)||e.isTemplateMiddle(n)||e.isTemplateTail(n)?o(n,n.text):e.isRegularExpressionLiteral(n)&&o(n,n.text.replace(/\\(.)/g,"$1")),e.forEachChild(n,s)};return s(i),r}var O="media-host-check.config.json",T="efficient-shell-media-host-check",P=`${T}: no code writes a media origin; files are reached through the storage backend, the API's URL, media() or imageCopyUrl() (harness API-15, SSOT-2).\n\n ${T} check this repository; exits 1 on a finding\n ${T} --json print the result as JSON\n\nRefused in any string, template or regular expression: every host and bucket in\nthe image-copies contract, any *.cloudfront.net host, any S3 endpoint, and s3://.\nReads ${O} in the current directory.`;function L(e,t,r){const o=[],s=g(r.exclude);for(const e of r.include)0===h(t,[e]).length&&o.push(`include "${e}" matches no file; delete it`);const a=h(t,r.include).filter(e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!s(e)),c=[];for(const r of a)for(const o of E(e,r,i(n(t,r),"utf8")))c.push({file:r,...o});const l=(e,n)=>e.toLowerCase()===n.toLowerCase();for(const e of r.allow)c.some(n=>n.file===e.file&&l(e.match,n.match))||o.push(`allow ${e.file} "${e.match}" matches nothing any more; delete it`);return{files:a.length,findings:c.filter(e=>!(e=>r.allow.some(n=>n.file===e.file&&l(n.match,e.match)))(e)),problems:o}}process.exitCode=function(e,r){let o=!1;for(const n of e){if("--help"===n||"-h"===n)return r.out(P),0;if("--version"===n||"-v"===n)return r.out(r.version),0;if("--json"!==n)return r.err(`${T}: unknown argument "${n}"\n\n${P}`),2;o=!0}const s=n(r.cwd,O);if(!t(s))return r.err(`${T}: no ${O} in ${r.cwd}. Run it from the repository root.`),2;let a;try{const e=function(e,n="media-host-check.config.json"){const t=[];if(!R(e))throw new y(`${n}: expected an object`);for(const n of Object.keys(e))b.has(n)||t.push(`unknown key "${n}"`);1!==e.schema&&t.push('"schema" must be 1');const i=(n,i)=>{const r=e[n];return void 0!==r||i?!Array.isArray(r)||!r.every(S)||i&&0===r.length?(t.push(`"${n}" must be ${i?"a non-empty":"an"} array of globs`),[]):r:[]},r=i("include",!0),o=i("exclude",!1),s=[];void 0===e.allow||Array.isArray(e.allow)||t.push('"allow" must be an array');for(const[n,i]of(Array.isArray(e.allow)?e.allow:[]).entries()){if(!(R(i)&&S(i.file)&&S(i.match)&&S(i.reason))){t.push(`allow[${n}] needs "file", "match" and "reason", each a non-empty string`);continue}const e=Object.keys(i).filter(e=>!["file","match","reason"].includes(e));e.length&&t.push(`allow[${n}] has unknown keys: ${e.join(", ")}`),s.push({file:i.file,match:i.match,reason:i.reason})}if(t.length)throw new y(`${n}:\n ${t.join("\n ")}`);return{schema:1,include:r,exclude:o,allow:s}}(JSON.parse(i(s,"utf8")),O);a=L(r.loadTypeScript(),r.cwd,e)}catch(e){return r.err(`${T}: ${e instanceof y||e instanceof SyntaxError?e.message:String(e)}`),2}const g=a.findings.length>0||a.problems.length>0;if(o)return r.out(JSON.stringify({ok:!g,...a},null,2)),g?1:0;if(!g)return r.out(`${T}: ${a.files} files, no media origin written in code (harness API-15, SSOT-2).`),0;for(const e of a.findings)r.err(`${e.file}:${e.line} "${e.match}" is a media origin written in code.`);for(const e of a.problems)r.err(`${O}: ${e}`);return a.findings.length&&r.err(`\nReach the file through the storage backend, the URL the API returns, media() or imageCopyUrl() (harness API-15, SSOT-2). An origin that must stay goes in "allow" in ${O}, with its reason.`),1}(process.argv.slice(2),{cwd:process.cwd(),out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>o(import.meta.url),version:"16.5.0"});
|
|
2
|
+
import{createRequire as e}from"module";import{join as n}from"path";import{existsSync as t,readFileSync as i,readdirSync as r}from"fs";function o(t){return function(t,i){for(const r of[n(process.cwd(),"package.json"),i])try{return e(r)(t)}catch{}throw new Error(`${t} is not installed; add it to this repository's devDependencies`)}("typescript",t)}var s=/[.+^$()|[\]\\]/g;function a(e){let n="",t=0;for(let i=0;i<e.length;i++){const r=e[i];"*"===r?"*"===e[i+1]?"/"===e[i+2]?(n+="(?:[^/]+/)*",i+=2):(n+=".*",i+=1):n+="[^/]*":"?"===r?n+="[^/]":"{"===r?(n+="(?:",t+=1):"}"===r&&t>0?(n+=")",t-=1):n+=","===r&&t>0?"|":r.replace(s,"\\$&")}if(0!==t)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${n}$`)}function g(e){const n=e.map(a);return e=>n.some(n=>n.test(e))}var c=new Set(["node_modules",".git"]),l=new Set(["dist","coverage",".next",".turbo"]);function d(e){const n=e.search(/[*?{]/),t=-1===n?e:e.slice(0,n),i=t.lastIndexOf("/");return-1===i?"":t.slice(0,i)}function h(e,t){const i=g(t),o=[...new Set(t.map(d))].sort(),s=o.filter(e=>!o.some(n=>n!==e&&(""===n||e.startsWith(`${n}/`)))),a=new Set,h=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?c.has(e.name)||""===t&&l.has(e.name)||h(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)h(e);return[...a].sort(u)}var u=(e,n)=>e<n?-1:e>n?1:0;Object.keys({fast:120,base:160}).map(e=>`--motion-${e}`).join(", "),Object.keys({body:400,control:500,heading:600,figure:700}).map(e=>`--weight-${e}`).join(", "),Object.keys({hairline:1,strong:2,accent:4}).map(e=>`--border-${e}`).join(", "),[2,4,8,12,16,20,24,32,40,48].join("/");var p=(...e)=>["origin",...e].join("-");new RegExp(["(?:transformOrigin|transform-origin)\\s*[:=]\\s*[\"'`]?\\s*(?:top left|left top|0 0|0% 0%|0px 0px)(?![\\w%-])",`(?<![\\w-])!?${p("top","left")}(?![\\w-])`,`(?<![\\w-])!?${p("\\[0_0\\]")}`].join("|"));var f=(...e)=>e.join(""),m="3xs|2xs|xs|sm|base|lg|xl|[2-9]xl";new RegExp(`(?<![\\w-])!?(?:${f("te","xt-")}(?:(?:${m})(?:\\/[\\w.()-]+)?|\\[(?:length:)?[\\d.]+(?:px|rem|em)\\])|${f("fo","nt-")}(?:thin|extralight|light|normal|medium|semibold|bold|extrabold|black|\\[\\d+\\]))(?![\\w-])`),new RegExp(`(?<![\\w-])${f("round","ed")}(?:-(?:full|sm|md|lg|xl|[23]xl|[trblse]|tl|tr|br|bl|\\([^)]*\\)|\\[[^\\]]*\\]))*(?![\\w-])`);new RegExp(`(?<![\\w-])${f("b","g-")}(?!(?:none|transparent|current|inherit|cover|contain|auto|fixed|local|scroll|center|top|bottom|left|right|repeat|no-repeat|clip|origin|blend|linear|radial|conic|gradient|position|size|image)(?![\\w]))[\\w\\[(#][^\\s'"\`]*`);var w=`${m}|left|center|right|justify|start|end|wrap|nowrap|balance|pretty|ellipsis|clip|transparent|current|inherit|shadow`;new RegExp(`(?<![\\w-])${f("te","xt-")}(?!(?:${w})(?![\\w]))(?!\\[[\\d.]+(?:px|rem|em)\\])(?!\\[length:)[\\w\\[(#][^\\s'"\`]*`),new RegExp(`(?<![\\w-])${f("p","[xs]?-")}(?:\\d|\\[|\\()`),new RegExp(`(?<![\\w-])${f("p","y-")}(?:0|px|0\\.5|\\[[0-3](?:\\.\\d+)?px\\])(?![\\w.-])`),new RegExp(`(?<![\\w-])${f("round","ed-full")}(?![\\w-])`),new RegExp(`(?<![\\w-])${f("te","xt-")}(?:xs|2xs|3xs|\\[(?:9|10|11|12)px\\])(?![\\w-])`),new RegExp(`(?<![\\w-])${f("p","y-")}`),new RegExp(`(?<![\\w-])!?(?:${f("dura","tion-")}|${f("del","ay-")})(?:\\d+|\\[[^\\]]+\\])(?![\\w-])|(?<![\\w-])!?${f("fo","nt-")}\\[\\d+\\](?![\\w-])|(?<![\\w-])!?${f("bor","der")}(?:-[xytrblse])?-\\[[\\d.]+px\\](?![\\w-])`,"g");var $={busy:{words:["Accepting","Adding","Applying","Approving","Arranging","Asking","Assigning","Booking","Building","Calculating","Cancelling","Capturing","Changing","Checking","Choosing","Closing","Combining","Comparing","Completing","Confirming","Connecting","Converting","Copying","Correcting","Counting","Creating","Deleting","Detaching","Downloading","Drawing","Duplicating","Emailing","Ending","Exporting","Fetching","Filing","Finding","Flushing","Generating","Grouping","Importing","Linking","Loading","Locating","Looking","Making","Marking","Matching","Measuring","Merging","Moving","Opening","Ordering","Paying","Pending","Posting","Preparing","Previewing","Pricing","Processing","Provisioning","Publishing","Purging","Pushing","Queued","Queuing","Quoting","Re-booking","Re-importing","Re-opening","Reading","Rebooting","Rebuilding","Receiving","Reconciling","Reconnecting","Recording","Refreshing","Refunding","Regenerating","Registering","Reinstating","Rejecting","Removing","Reopening","Requesting","Resending","Resetting","Resolving","Restarting","Restoring","Resuming","Retrying","Reversing","Reverting","Running","Saving","Searching","Sending","Setting","Settling","Sharing","Signing","Splitting","Starting","Submitting","Suggesting","Switching","Syncing","Taking","Testing","Transferring","Typing","Updating","Uploading","Verifying","Waiting","Withdrawing","Working"]}};new Set(($.busy?.words??[]).map(e=>e.toLowerCase()));var x=(...e)=>e.join("-");x("p[xytrblse]?",""),x("max","[wh]",""),x("h",""),x("w",""),x("[wh]",""),x("min","h","");var y=class extends Error{},b=new Set(["$schema","schema","include","exclude","allow"]),R=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),S=e=>"string"==typeof e&&""!==e.trim();var v="d3as2htf4hwbtr.cloudfront.net",k={dealer:{bucket:"inovit-dealer-portal-assets",hosts:["d201q0i87q901p.cloudfront.net"],key_pattern:"^marketing/"},media:{bucket:"regis-media-production",hosts:["media.regis.design","d21nnr9ivf9hcc.cloudfront.net"],key_pattern:"^[a-z0-9_]+/storefront/(?!uploads/thumbs/)"},site:{bucket:"inovit-ecommerce-media",hosts:["cdn.inovit.com","dhxlibd8r3td0.cloudfront.net"],key_pattern:"^images/"}},j=Object.values(k),C=Object.freeze([...new Set([...j.flatMap(e=>e.hosts),v,...j.map(e=>e.bucket)])].sort()),A=new RegExp([...C.map(e=>{return`(?<![\\w-])${n=e,n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w-])`;var n}),"(?<![\\w-])[a-z0-9]+\\.cloudfront\\.net(?![\\w-])","(?<![\\w-])(?:[a-z0-9-]+\\.)*s3(?:[.-][a-z0-9-]+)*\\.amazonaws\\.com(?![\\w-])","s3://"].join("|"),"gi");function E(e,n,t){const i=e.createSourceFile(n,t,e.ScriptTarget.Latest,!0,function(e,n){return n.endsWith(".tsx")?e.ScriptKind.TSX:n.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(n)?e.ScriptKind.JS:e.ScriptKind.TS}(e,n)),r=[],o=(e,n)=>{const t=i.getLineAndCharacterOfPosition(e.getStart(i)).line+1;for(const e of function(e){return[...e.matchAll(A)].map(e=>({match:e[0],index:e.index??0}))}(n)){const i=n.slice(0,e.index);r.push({line:t+(i.match(/\n/g)?.length??0),match:e.match})}},s=n=>{e.isStringLiteral(n)||e.isNoSubstitutionTemplateLiteral(n)||e.isTemplateHead(n)||e.isTemplateMiddle(n)||e.isTemplateTail(n)?o(n,n.text):e.isRegularExpressionLiteral(n)&&o(n,n.text.replace(/\\(.)/g,"$1")),e.forEachChild(n,s)};return s(i),r}var O="media-host-check.config.json",T="efficient-shell-media-host-check",P=`${T}: no code writes a media origin; files are reached through the storage backend, the API's URL, media() or imageCopyUrl() (harness API-15, SSOT-2).\n\n ${T} check this repository; exits 1 on a finding\n ${T} --json print the result as JSON\n\nRefused in any string, template or regular expression: every host and bucket in\nthe image-copies contract, any *.cloudfront.net host, any S3 endpoint, and s3://.\nReads ${O} in the current directory.`;function L(e,t,r){const o=[],s=g(r.exclude);for(const e of r.include)0===h(t,[e]).length&&o.push(`include "${e}" matches no file; delete it`);const a=h(t,r.include).filter(e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!s(e)),c=[];for(const r of a)for(const o of E(e,r,i(n(t,r),"utf8")))c.push({file:r,...o});const l=(e,n)=>e.toLowerCase()===n.toLowerCase();for(const e of r.allow)c.some(n=>n.file===e.file&&l(e.match,n.match))||o.push(`allow ${e.file} "${e.match}" matches nothing any more; delete it`);return{files:a.length,findings:c.filter(e=>!(e=>r.allow.some(n=>n.file===e.file&&l(n.match,e.match)))(e)),problems:o}}process.exitCode=function(e,r){let o=!1;for(const n of e){if("--help"===n||"-h"===n)return r.out(P),0;if("--version"===n||"-v"===n)return r.out(r.version),0;if("--json"!==n)return r.err(`${T}: unknown argument "${n}"\n\n${P}`),2;o=!0}const s=n(r.cwd,O);if(!t(s))return r.err(`${T}: no ${O} in ${r.cwd}. Run it from the repository root.`),2;let a;try{const e=function(e,n="media-host-check.config.json"){const t=[];if(!R(e))throw new y(`${n}: expected an object`);for(const n of Object.keys(e))b.has(n)||t.push(`unknown key "${n}"`);1!==e.schema&&t.push('"schema" must be 1');const i=(n,i)=>{const r=e[n];return void 0!==r||i?!Array.isArray(r)||!r.every(S)||i&&0===r.length?(t.push(`"${n}" must be ${i?"a non-empty":"an"} array of globs`),[]):r:[]},r=i("include",!0),o=i("exclude",!1),s=[];void 0===e.allow||Array.isArray(e.allow)||t.push('"allow" must be an array');for(const[n,i]of(Array.isArray(e.allow)?e.allow:[]).entries()){if(!(R(i)&&S(i.file)&&S(i.match)&&S(i.reason))){t.push(`allow[${n}] needs "file", "match" and "reason", each a non-empty string`);continue}const e=Object.keys(i).filter(e=>!["file","match","reason"].includes(e));e.length&&t.push(`allow[${n}] has unknown keys: ${e.join(", ")}`),s.push({file:i.file,match:i.match,reason:i.reason})}if(t.length)throw new y(`${n}:\n ${t.join("\n ")}`);return{schema:1,include:r,exclude:o,allow:s}}(JSON.parse(i(s,"utf8")),O);a=L(r.loadTypeScript(),r.cwd,e)}catch(e){return r.err(`${T}: ${e instanceof y||e instanceof SyntaxError?e.message:String(e)}`),2}const g=a.findings.length>0||a.problems.length>0;if(o)return r.out(JSON.stringify({ok:!g,...a},null,2)),g?1:0;if(!g)return r.out(`${T}: ${a.files} files, no media origin written in code (harness API-15, SSOT-2).`),0;for(const e of a.findings)r.err(`${e.file}:${e.line} "${e.match}" is a media origin written in code.`);for(const e of a.problems)r.err(`${O}: ${e}`);return a.findings.length&&r.err(`\nReach the file through the storage backend, the URL the API returns, media() or imageCopyUrl() (harness API-15, SSOT-2). An origin that must stay goes in "allow" in ${O}, with its reason.`),1}(process.argv.slice(2),{cwd:process.cwd(),out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>o(import.meta.url),version:"16.7.0"});
|