@heycys/gallery 0.2.0 → 0.2.2
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/THIRD-PARTY-NOTICES.md +1 -1
- package/browser/editor/components/icon/page.mjs +6 -4
- package/browser/editor/components/icons.mjs +2 -2
- package/browser/editor/page/annotate/index.mjs +3 -2
- package/browser/editor/page/board/index.mjs +2 -1
- package/browser/editor/page/board/settings.mjs +2 -1
- package/browser/editor/page/clipboard/import/read.mjs +20 -2
- package/browser/editor/page/core.mjs +3 -2
- package/browser/editor/page/custom-page.mjs +4 -3
- package/browser/editor/page/editor.mjs +9 -5
- package/browser/editor/page/emoji-picker/support.mjs +3 -2
- package/browser/editor/page/links/index.mjs +1 -12
- package/browser/editor/page/links/pages.mjs +3 -2
- package/browser/editor/page/outline/folds.mjs +3 -0
- package/browser/editor/page/post.mjs +2 -1
- package/browser/editor/page/present-links.mjs +4 -3
- package/browser/editor/page/present-shell.mjs +3 -58
- package/browser/editor/page/session.mjs +3 -37
- package/browser/editor/page/storage.mjs +5 -5
- package/browser/shared/component-catalog.mjs +2 -2
- package/browser/shared/document-copy.mjs +43 -0
- package/browser/shared/drafts.mjs +32 -50
- package/browser/shared/emoji/icon-value.mjs +4 -3
- package/browser/shared/extension-manifest.mjs +90 -0
- package/browser/shared/extensions.mjs +93 -7
- package/browser/shared/http.mjs +1 -1
- package/browser/shared/i18n/en.mjs +55 -14
- package/browser/shared/media.mjs +2 -1
- package/browser/shared/outline-shape.mjs +6 -0
- package/browser/shared/outline.mjs +95 -10
- package/browser/shared/page-address.mjs +8 -15
- package/browser/shared/paths.mjs +2 -1
- package/browser/shared/preferences.mjs +3 -1
- package/browser/shared/preview-server.mjs +51 -63
- package/browser/shared/service-location.mjs +18 -0
- package/browser/shared/session.mjs +3 -6
- package/browser/shared/workspace-address.mjs +19 -0
- package/browser/shared/workspace-columns.mjs +12 -9
- package/browser/shared/workspace-registry.mjs +6 -40
- package/browser/shared/workspace.mjs +3 -6
- package/browser/shared/writing-preferences.mjs +6 -4
- package/dist/{chunk-W7665ZEC.mjs → chunk-236JJXWY.mjs} +2 -2
- package/dist/{chunk-EAIFITAV.mjs → chunk-2KAVXMKG.mjs} +1 -1
- package/dist/chunk-2T4PZQEP.mjs +2 -0
- package/dist/{chunk-HXG7EOPJ.mjs → chunk-3SKOU6OZ.mjs} +1 -1
- package/dist/{chunk-AR5D57ZD.mjs → chunk-3XZOA7AH.mjs} +2 -2
- package/dist/{chunk-UYVCQK3H.mjs → chunk-4B2TB5K2.mjs} +1 -1
- package/dist/{chunk-3MBRL2PM.mjs → chunk-4KUO7R2M.mjs} +8 -8
- package/dist/chunk-4SNV4HA5.mjs +2 -0
- package/dist/chunk-53XDTHTG.mjs +4 -0
- package/dist/chunk-5XV3YYLG.mjs +2 -0
- package/dist/{chunk-ZDLPUOAG.mjs → chunk-65NTKF4N.mjs} +1 -1
- package/dist/chunk-6GV3CBB2.mjs +2 -0
- package/dist/{chunk-WQDQWCX5.mjs → chunk-6L6V7YR2.mjs} +1 -1
- package/dist/{chunk-ITOH5EGO.mjs → chunk-6NLXUKAY.mjs} +1 -1
- package/dist/chunk-6Q7ASAXJ.mjs +3 -0
- package/dist/{chunk-7OG26PGF.mjs → chunk-6QWQXHAV.mjs} +1 -1
- package/dist/chunk-6XD6U3QA.mjs +5 -0
- package/dist/{chunk-YNAWBAYN.mjs → chunk-7EFHNQ5B.mjs} +1 -1
- package/dist/{chunk-OFHXGWOX.mjs → chunk-7ISBBDJR.mjs} +1 -1
- package/dist/{chunk-QE5RG76S.mjs → chunk-7UZUQQ7Q.mjs} +29 -24
- package/dist/chunk-BLNQUR5R.mjs +168 -0
- package/dist/chunk-BMX3VUHY.mjs +2 -0
- package/dist/chunk-BN7M3IN7.mjs +8 -0
- package/dist/{chunk-K5XATEOO.mjs → chunk-BQNTTFPL.mjs} +1 -1
- package/dist/chunk-C257H6IA.mjs +2 -0
- package/dist/chunk-CHQU37CA.mjs +2 -0
- package/dist/{chunk-CMA72MAG.mjs → chunk-E4IHAIJ7.mjs} +1 -1
- package/dist/{chunk-VS7JIGJW.mjs → chunk-E7656LR7.mjs} +1 -1
- package/dist/{chunk-VFX2KNHP.mjs → chunk-ECZBLQKK.mjs} +1 -1
- package/dist/{chunk-MN7BZL4R.mjs → chunk-ERE2BXYV.mjs} +1 -1
- package/dist/chunk-FFV733MA.mjs +2 -0
- package/dist/{chunk-AHN3NFKJ.mjs → chunk-GJJRBGMY.mjs} +1 -1
- package/dist/{chunk-BZ5RAF7L.mjs → chunk-GKOBB6DH.mjs} +1 -1
- package/dist/chunk-GMJD7ID3.mjs +2 -0
- package/dist/{chunk-OEXWRJME.mjs → chunk-IA2SIEJQ.mjs} +1 -1
- package/dist/chunk-JPG2LBQM.mjs +11 -0
- package/dist/{chunk-POTA2FV4.mjs → chunk-JXXHAXYH.mjs} +1 -1
- package/dist/{chunk-FDMAXMQA.mjs → chunk-K3JKPFL5.mjs} +1 -1
- package/dist/{chunk-J5PUIV3Y.mjs → chunk-KLQP46Y3.mjs} +1 -1
- package/dist/chunk-LMUZQK5O.mjs +2 -0
- package/dist/{chunk-JLTZF4LA.mjs → chunk-M4NRDYI5.mjs} +1 -1
- package/dist/{chunk-HPOI4ZX7.mjs → chunk-MKIBJTJZ.mjs} +1 -1
- package/dist/{chunk-5K44HLTZ.mjs → chunk-MNWJ4EZY.mjs} +1 -1
- package/dist/{chunk-FETSREUN.mjs → chunk-NHP66IWR.mjs} +1 -1
- package/dist/{chunk-PGDE24N5.mjs → chunk-OEIJLMPI.mjs} +1 -1
- package/dist/{chunk-YROX2O22.mjs → chunk-PDZR3L3C.mjs} +1 -1
- package/dist/{chunk-6N3PX4XX.mjs → chunk-PLB7L22J.mjs} +1 -1
- package/dist/{chunk-LM4XFQHZ.mjs → chunk-Q4MS6OFC.mjs} +1 -1
- package/dist/{chunk-7JDX4E65.mjs → chunk-Q7P3Q5YX.mjs} +1 -1
- package/dist/{chunk-ZHEHPMBK.mjs → chunk-QNECWMGR.mjs} +1 -1
- package/dist/{chunk-YI43RG4P.mjs → chunk-QP7BOHE4.mjs} +1 -1
- package/dist/chunk-QVGOPHOF.mjs +2 -0
- package/dist/{chunk-DAZL73VK.mjs → chunk-RRKJMHNX.mjs} +2 -2
- package/dist/chunk-S3SX3COT.mjs +20 -0
- package/dist/{chunk-HDWTZ763.mjs → chunk-TKWEX4FD.mjs} +2 -2
- package/dist/{chunk-YLPSMDIS.mjs → chunk-ULXSPX5H.mjs} +2 -2
- package/dist/chunk-USIHBCSW.mjs +15 -0
- package/dist/{chunk-TR7TWGHB.mjs → chunk-VPMRP2TL.mjs} +1 -1
- package/dist/{chunk-ZQS6H473.mjs → chunk-VRPVVMRB.mjs} +1 -1
- package/dist/{chunk-F6HVDZR4.mjs → chunk-VZ2RQ3AM.mjs} +1 -1
- package/dist/{chunk-R2ZDLJYT.mjs → chunk-W5NPH5UA.mjs} +1 -1
- package/dist/chunk-WFGPMCTZ.mjs +4 -0
- package/dist/chunk-XZCFPKGO.mjs +2 -0
- package/dist/{chunk-4OKWZY5E.mjs → chunk-YN37ZDLW.mjs} +1 -1
- package/dist/chunk-ZFGMJVJC.mjs +2 -0
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/worker.mjs +1 -1
- package/kit/report.css +3 -3
- package/kit/runtime.js +12 -2
- package/kit/state.js +2 -0
- package/kit/ui.js +5 -1
- package/package.json +1 -1
- package/release.json +7 -7
- package/skill/SKILL.md +13 -12
- package/skill/references/building-blocks.md +1 -1
- package/skill/references/extensions.md +48 -8
- package/web/assets/index-FLb9jCfl.css +1 -0
- package/web/assets/index-czjrXVjf.js +15 -0
- package/web/index.html +2 -2
- package/dist/chunk-5XA2ZBAE.mjs +0 -8
- package/dist/chunk-67N2QJYT.mjs +0 -2
- package/dist/chunk-6KBYRA2C.mjs +0 -2
- package/dist/chunk-DJISHPUL.mjs +0 -3
- package/dist/chunk-EKNHM3P4.mjs +0 -2
- package/dist/chunk-EP25HDAJ.mjs +0 -2
- package/dist/chunk-GHOYKMQ3.mjs +0 -4
- package/dist/chunk-IV64FFI4.mjs +0 -2
- package/dist/chunk-J43Z6LSS.mjs +0 -2
- package/dist/chunk-JA7G53PC.mjs +0 -2
- package/dist/chunk-JZT7I2OJ.mjs +0 -2
- package/dist/chunk-L2SUIS5S.mjs +0 -2
- package/dist/chunk-L7UP52JO.mjs +0 -2
- package/dist/chunk-MTYYHM2G.mjs +0 -15
- package/dist/chunk-MXUBKDRO.mjs +0 -15
- package/dist/chunk-NAMN3RAF.mjs +0 -2
- package/dist/chunk-ORID3AE7.mjs +0 -166
- package/dist/chunk-SWUTTZCN.mjs +0 -2
- package/dist/chunk-U7NZI6N4.mjs +0 -4
- package/dist/chunk-UJQJKNGK.mjs +0 -2
- package/dist/chunk-ZWWC4KLF.mjs +0 -20
- package/web/assets/index-BM_K-Auu.css +0 -1
- package/web/assets/index-DRslOBiv.js +0 -15
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as We}from"./chunk-UMHUSOPJ.mjs";import{d as Ue,e as Vt,g as Xt,j as ze,k as qe,l as Je,m as Zt}from"./chunk-
|
|
2
|
+
import{a as We}from"./chunk-UMHUSOPJ.mjs";import{d as Ue,e as Vt,g as Xt,j as ze,k as qe,l as Je,m as Zt}from"./chunk-ECZBLQKK.mjs";import{B as Pe,c as lt,d as Ke,q as St,r as He,y as Jt,z as ft}from"./chunk-E7656LR7.mjs";import{b as rt,e as fn}from"./chunk-A55HN5OK.mjs";fn();import dn from"node:path";import{attr as w,curlyQuoted as un}from"../browser/shared/html-tree.mjs";import{FOLDED_LINES as Ve,LINE_START as Xe,NOWRAP as Qt,lineStart as mn,validFolded as hn}from"../browser/shared/code-lines.mjs";import{COLORS as gn}from"../browser/shared/colors.mjs";import{FLOWS as pn,instanceSlots as at,isInstance as it,isSlot as fs,matchesNode as pt}from"../browser/shared/components/index.mjs";import{HEADED as dt}from"../browser/shared/components/dialog.mjs";import{pageLanguage as Nn}from"../browser/shared/components/page.mjs";import{SHEETS_LABEL as Ze,shortSheets as On}from"../browser/shared/components/sheets.mjs";import{iconMarkup as Qe,iconValueOf as ds}from"../browser/shared/emoji/icon-value.mjs";import{escapeText as mt}from"../browser/shared/escape.mjs";import{COLUMN_GAP as $n,READING_WIDTH as Tt,SPAN as Ye,SPAN_SIZE as ut}from"../browser/shared/media.mjs";import{kitNamespace as us}from"../browser/shared/old-names.mjs";import{CHART_DATA as wn,CHART_SOURCE as tt,TABLE_READERS as bn,nextChartKey as kn}from"../browser/shared/table-chart.mjs";import{ALIGNS as Yt}from"../browser/editor/components/align.mjs";import{BLOCK_COLORS as ie}from"../browser/editor/components/colors.mjs";import{DETAILS as Ln,DIALOG as ee,PAGE as ms,SECTION as yn,SHEETS as vn}from"../browser/editor/components/kit.mjs";import{DIALOG_TRIGGER as Cn}from"../browser/editor/components/dialog/index.mjs";import{CHECKED as ce,FLOW as ht,TODO as se}from"../browser/editor/components/list/index.mjs";import{texSource as xn}from"../browser/editor/components/math/index.mjs";import{BOX_CLASSES as hs,HOLDS_ONE as Sn,UNIT_KINDS as Tn}from"../browser/editor/components/registry.mjs";import{HEADER_LOOK as ts}from"../browser/editor/components/table/index.mjs";import{backgroundColor as En,parseColor as An,textColor as In}from"../browser/editor/page/clipboard/import/colors.mjs";var re=new Set(["script","style","template","textarea","noscript","code","svg","math","select","option","button","iframe","video","audio","canvas","object","picture"]),jt=["doc-figure","doc-code","doc-diff","doc-math-inline","doc-math-block","doc-link-mention","doc-sheet-tabs","doc-state-fields","doc-filter-row","doc-image","doc-file","doc-bookmark","doc-embed","doc-icon","doc-title","doc-table-meta"],le=new Set(["p","h1","h2","h3","h4","h5","h6","li","td","th","dt","dd","blockquote","figcaption","caption","summary"]),Et=new Set(["main","section","div","article","aside","blockquote","li","details","dialog"]),_n=new Set(gn.map(({name:e})=>e)),C=e=>(w(e,"class")??"").split(/\s+/).filter(Boolean),es=e=>C(e).every(n=>ie.includes(n)),jn=ie.filter(e=>e.startsWith("doc-highlight-")),ct=e=>C(e).some(n=>!us(n)),D=e=>e.nodeName==="#text",Bt=/^[\s\u200b-\u200d\u2060\ufeff]*$/,V=e=>D(e)&&Bt.test(e.value),y=e=>(e.childNodes??[]).filter(n=>n.tagName),Z=e=>(e.attrs??[]).map(n=>n.name),F=(e,n)=>Z(e).every(f=>n.includes(f)),Bn=[yn.match,Ln.match,ee.match,vn.match,"table.doc-table"].join(", ");function gs(e){let n=C(e);return n.some(f=>jt.includes(f))||Ke(e)||pt(e,Bn)||hs.some(([f])=>n.includes(f))||Tn.some(f=>f.class&&n.includes(f.class)&&(!f.tag||[f.tag].flat().includes(e.tagName)))}var Mn=e=>{for(let n=e.parentNode;n?.tagName&&n.tagName!=="main";n=n.parentNode)if(n.tagName==="figure")return!0;return!1},ps=new Set(["thead","tbody","tfoot","tr","colgroup","col"]),fe=e=>ct(e)&&e.tagName!=="figure"&&!le.has(e.tagName)&&!ps.has(e.tagName)&&!gs(e),Ns=new Set([...lt].filter(e=>!["header","main","dialog","form","fieldset","caption","dd","dt","figcaption","summary","li","td","th",...ps].includes(e))),Rn=/\\\(([\s\S]*?)\\\)/g,wt=e=>xn(e)&&/\S/.test(e);function Dn(e,n=!0){let f=n?e:/^\s*(?:\\\[[\s\S]*?\\\]|\$\$[\s\S]*?\$\$)/.exec(e)?.[0]??"";return/[<>]/.test(f)&&wt(f.replace(/</g,"\\lt ").replace(/>/g,"\\gt "))}var ne=new Set(["br","wbr","img","input"]),Os=new Set([...lt,"script","style","template","noscript","link","meta"]),$s=new Set(["input","select","textarea","button","label","option"]),Gn=new Set([...lt,"hgroup","search","center","dir","listing","xmp","plaintext"]),oe=e=>y(e).some(n=>Gn.has(n.tagName)||oe(n)),ws=new Set(["main","section","div","article","aside","blockquote"]),Fn=pn.join(", "),bs=e=>ws.has(e.tagName)&&!ct(e)&&(C(e).length===0||pt(e,Fn))||fs(e),et=e=>D(e)?!Bt.test(e.value):(e.childNodes??[]).some(et),Kn=hs.filter(([,e])=>Sn.has(e)).map(([e])=>e),Hn=e=>bs(e)&&C(e).some(n=>Kn.includes(n)),ks=e=>e.childNodes.some(n=>D(n)&&!Bt.test(n.value))&&y(e).some(n=>lt.has(n.tagName)),Pn=/^[ \t\n\r\f]*/;function te(e){let n=[],f=[];for(let u of e)u.tagName&&Os.has(u.tagName)?(n.push(f),f=[]):f.push(u);n.push(f);let p=u=>!u.tagName&&!et(u),O=u=>(D(u)||u.tagName&&!$s.has(u.tagName))&&et(u);return n.map(u=>{let $=u.findIndex(m=>!p(m));return $<0?[]:u.slice($,u.findLastIndex(m=>!p(m))+1)}).filter(u=>u.some(O))}function Wn(e){let n=[],f=p=>{for(let O of p.childNodes??[])O.tagName==="style"?n.push(O.childNodes.map(u=>u.value??"").join("")):O.tagName&&O.tagName!=="template"&&f(O)};return f(e),n.flatMap(p=>[...p.replace(/\/\*[\s\S]*?(?:\*\/|$)/g," ").matchAll(/([^{};]*)\{/g)].map(([,O])=>O))}var Un=(e,{tags:n=[],classes:f=[]})=>{let p=[...n.map(u=>`(?<![\\w.#-])${u}`),...f.map(u=>`\\.${u}`)],O=p.length?new RegExp(`(?:${p.join("|")})(?![\\w-])`,"i"):null;return!!O&&e.some(u=>O.test(u))};function zn(e){let n=[],f=p=>{for(let O of p.childNodes??[])O.tagName==="script"?n.push(O.childNodes.map(u=>u.value??"").join("")):O.tagName&&O.tagName!=="template"&&f(O)};return f(e),n.join(`
|
|
3
3
|
`)}var de=["contains-task-list","task-list-item"],ue=["task-list-item"],Ls=["task-list-item-checkbox"],me=(e,n)=>C(e).every(f=>n.includes(f));function ys(e){let n=e.childNodes.find(f=>!V(f));return n?.tagName==="input"&&F(n,["type","checked","disabled","class"])&&w(n,"type")?.toLowerCase()==="checkbox"&&me(n,Ls)&&n.sourceCodeLocation?.startTag?n:null}var vs=e=>e.tagName==="li"&&me(e,ue)&&w(e,ce)===void 0&&e.sourceCodeLocation?.startTag&&ys(e),qn=e=>e.tagName==="ul"&&me(e,de)&&y(e).length>0&&e.childNodes.every(n=>n.tagName==="li"||V(n))&&y(e).every(vs),Jn={classes:[...new Set([...de,...ue,...Ls])]},Vn=/checkbox|task-list/i,ae=e=>e.tagName==="ol"&&(w(e,"data-doc-chart")==="flow"||w(e,"data-flow")!==void 0&&w(e,"data-doc-chart")===void 0),Xn=e=>e?.tagName==="ol"&&!ct(e)&&(C(e).includes(ht)||ae(e)),Zn=e=>e.tagName==="li"&&Xn(e.parentNode),_t="doc-icon",Qn=e=>e.some(n=>n.tagName==="strong"||n.tagName==="b")&&e.every(n=>n.tagName==="strong"||n.tagName==="b"||D(n)&&Bt.test(n.value)||n.nodeName==="#comment"),Yn=/^(?:inherit|unset|currentcolor|none)$/i,to=/^(?:inherit|initial|unset|revert|revert-layer|transparent|none)$/i,P=e=>e.replace(/\s+/g," ").trim(),ss=/^\s*--doc-(?:table-height|span)\s*:/i,eo=/^(?:p|h[1-4])$/,so=/^(center|right)$/i;function It(e){let n=e.replace(/\/\*[\s\S]*?(?:\*\/|$)/g," "),f=[],p="",O=0,u=0;for(let $=0;$<=n.length;$++){let m=n[$];p?m==="\\"?$++:m===p&&(p=""):m==='"'||m==="'"?p=m:m==="("?O++:m===")"?O=Math.max(0,O-1):(m===";"&&O===0||$===n.length)&&(f.push(n.slice(u,$)),u=$+1)}return f.filter($=>$.trim())}function Cs(e){let n=new Map;for(let r of It(e)){let N=r.indexOf(":"),i=P(N<0?r:r.slice(0,N)).toLowerCase();n.set(i==="background-color"?"background":i,N<0?"":P(r.slice(N+1).replace(/!\s*important\s*$/i,"")))}let f=[],p=[],O,u,$=new Set,m=(r,N,i)=>{if((r==="color"?Yn:to).test(N))return;let d=An(N);if(!d||d.a===0&&r==="color"){f.push(r);return}if(d.a===0)return;let g=i(N,{nearest:!0})?.replace(/_background$/,"");if(!g||!_n.has(g)){p.push(`${r} ${N} left out: the ${r==="color"?"text's":"page's"} own is the nearest`);return}return i(N)?.replace(/_background$/,"")!==g&&p.push(`${r} ${N} written as the kit's ${g}${r==="color"?"":" highlight"}`),g};for(let[r,N]of n)r==="color"?O=m(r,N,In):r==="background"?u=m(r,N,En):r==="font-weight"&&/^(?:bold|bolder|[6-9]\d\d)$/i.test(N)?$.add("strong"):r==="font-style"&&/^(?:italic|oblique)\b/i.test(N)?$.add("em"):(r==="text-decoration"||r==="text-decoration-line")&&/^(?:(?:underline|line-through|solid)\s*)+$/i.test(N)&&/underline|line-through/i.test(N)?(/underline/i.test(N)&&$.add("u"),/line-through/i.test(N)&&$.add("s")):f.push(r);if(f.length)return{foreign:[...new Set(f)]};let v=[];O&&v.push([`<span class="doc-text-${O}">`,"</span>"]),u&&v.push([`<span class="doc-highlight-${u}">`,"</span>"]);for(let r of["strong","em","u","s"])$.has(r)&&v.push([`<${r}>`,`</${r}>`]);return{open:v.map(([r])=>r).join(""),close:v.map(([,r])=>r).reverse().join(""),notes:p}}var ns=/^(?:language|lang)-([\w#+.-]+)$/,no=new Set(["data-language","data-lang","data-block-id"]),oo=[{name:Xe,names:[Xe,"data-start"],value:e=>mn(e)?.toString()??null,says:"the number of its first line is a whole number from 1"},{name:"data-line-numbers",names:["data-line-numbers"],value:e=>/^\s*(?:true|false)\s*$/i.test(e)?e.trim().toLowerCase():null,says:"false hides its line numbers, true shows them"},{name:Ve,names:[Ve],value:e=>hn(P(e))?P(e):null,says:"its folded lines are their numbers from 1, spaces between"}],os="data-title",as="data-wrap",ao=e=>y(e).length===1&&y(e)[0].tagName==="code"&&e.childNodes.every(n=>n.tagName||V(n))?y(e)[0]:null,io=new Set(["a","abbr","b","bdi","bdo","cite","code","data","del","dfn","em","font","i","ins","kbd","mark","q","s","samp","small","span","strike","strong","sub","sup","time","tt","u","var","br","wbr"]),co=new Set(["code","kbd","samp","tt","var"]);function xs(e){for(let n of e.childNodes){if(D(n))continue;if(!n.tagName)return"a comment in its <figcaption>";if(["img","picture","svg"].includes(n.tagName))return"a picture in its <figcaption>";if(!io.has(n.tagName))return`a <${n.tagName}> in its <figcaption>`;if(!n.sourceCodeLocation?.startTag||!(n.sourceCodeLocation.endTag||ne.has(n.tagName)))return`a <${n.tagName}> not closed in its <figcaption>`;let f=xs(n);if(f)return f}return""}function is(e){let n=y(e),f=n.filter(v=>v.tagName==="pre"),p=n.filter(v=>v.tagName==="figcaption");if(!f.length)return null;let[O]=f,[u=null]=p,$=e.childNodes.find(v=>!v.tagName&&!V(v)),m=f.length>1||p.length>1||n.length>f.length+p.length?"more than the pre and one <figcaption> in its <figure>":$?D($)?"words in its <figure> outside its caption":"a comment in its <figure>":u?Z(u).length?`its <figcaption> has an attribute of its own (${Z(u).join(", ")})`:u.sourceCodeLocation?.endTag?xs(u):"its <figcaption> is not closed in the file":"";return m?{pre:O,caption:u,why:m}:{pre:O,caption:u}}function At(e){let n=(e.attrs??[]).filter(({value:p})=>p.trim()),f=e.tagName==="abbr";return n.map(p=>`${p.name} ${JSON.stringify(P(p.value))} dropped: ${f&&p.name==="title"?"write the full name in the text":"write it in the text if the reader needs it"}`)}var z=e=>e.replace(/&/g,"&").replace(/"/g,""");function ro(e){let n=new Set,f=p=>{for(let O of p.childNodes??[])if(O.tagName){for(let u of[tt,...bn])w(O,u)!==void 0&&n.add(w(O,u));f(O.tagName==="template"?O.content:O)}};return f(e),n}function lo(e){let n=new Map,f=p=>{for(let O of p.childNodes??[]){if(!O.tagName)continue;let u=w(O,"id");u!==void 0&&n.set(u,(n.get(u)??0)+1),f(O.tagName==="template"?O.content:O)}};return f(e),n}var fo=/^[A-Za-z][\w-]{0,63}$/;function uo(e){let n=We(e),f=rt(n,{sourceCodeLocationInfo:!0}),p=bt(f);if(!p)return{text:n,changes:[]};let O=[],u=[],$=t=>n.slice(0,t).split(`
|
|
4
4
|
`).length,m=(t,s,o=[],l={})=>{let a=$(t.sourceCodeLocation.startOffset);o.length||u.push({line:a,rule:s,...l});for(let c of o)u.push({line:a,rule:s,note:c,...l})},v=0,r=(t,s,o,{opens:l=null,closes:a=null,move:c=null,leaves:h=!1}={})=>O.push({start:t,end:s,text:o,order:v++,opens:l,closes:a,move:c,leaves:h}),N=(t,s,o,l)=>{r(t,t,o,{opens:s}),r(s,s,l,{closes:t})},i=t=>t.sourceCodeLocation?.startTag,d=t=>t.sourceCodeLocation?.endTag,g=(t,s,{drop:o=[]}={})=>{let l=C(t).filter(h=>!o.includes(h)),a=[...l,...s.filter(h=>!l.includes(h))],c=t.sourceCodeLocation.attrs?.class;if(a.join(" ")!==C(t).join(" "))if(c&&a.length)r(c.startOffset,c.endOffset,`class="${z(a.join(" "))}"`);else if(c)x(t,"class");else{let h=i(t).startOffset+1+t.tagName.length;r(h,h,` class="${z(a.join(" "))}"`)}},x=(t,s)=>{let o=t.sourceCodeLocation.attrs[s],l=o.startOffset;for(;/[ \t\n\r\f]/.test(n[l-1]??"");)l--;r(l,o.endOffset,"")},A=(t,s,{classes:o=[],drop:l=[]}={})=>{let a=t.sourceCodeLocation,c=Object.entries(a.attrs??{}).filter(([L])=>L!=="class"&&!l.includes(L)).map(([,L])=>` ${n.slice(L.startOffset,L.endOffset)}`).join(""),h=[...o,...C(t).filter(L=>!o.includes(L))];return`<${s}${h.length?` class="${z(h.join(" "))}"`:""}${c}>`},M,q=t=>Un(M??=Wn(f),t),Q,Ms=t=>t.test(Q??=zn(f)),K=(t,s,o)=>{r(i(t).startOffset,i(t).endOffset,s),d(t)&&r(d(t).startOffset,d(t).endOffset,o)},Rt=t=>K(t,"",""),W=t=>!!(i(t)&&(d(t)||t.tagName==="img")),ge,pe=t=>{let s=w(t,"id");if(t.tagName!=="dialog"||!F(t,["id"])||!fo.test(s??"")||!W(t))return!1;let o=y(t);return!(o.length?Ns.has(o[0].tagName)&&W(o[0]):t.childNodes.some(a=>!V(a)&&a.nodeName!=="#comment"))||o.some(a=>a.tagName==="form")?!1:(ge??=lo(f),ge.get(s)===1)},Rs=t=>{let s=y(t)[0];return!pt(s,ee.short)||Z(s).length?null:t.childNodes.slice(0,t.childNodes.indexOf(s)).every(V)?s:null},Ne=t=>t.tagName==="dialog"&&(C(t).includes("doc-dialog")||pe(t)),Dt=(t,s=[])=>{for(let o of t.childNodes??[])if(o!==p){if(it(o)){at(o).forEach(l=>Dt(l,s));continue}Ne(o)&&W(o)?s.push(o):Dt(o,s)}return s},Gt=d(p)?Dt(f):[],Oe,Ds=t=>(Oe??=new Set((function s(o,l=[]){for(let a of o.childNodes??[])if(a.tagName){if(it(a)){at(a).forEach(c=>s(c,l));continue}Ne(a)&&l.push(w(a,"id")),s(a,l)}return l})({childNodes:[p,...Gt]})),/^#./.test(t??"")&&Oe.has(t.slice(1))),Gs=t=>{let[s,...o]=y(t);if(!s||o.length||!C(s).includes("doc-dialog-panel"))return null;let[l,a,...c]=y(s);if(c.length||!l||!a||!C(l).includes(dt.header)||!C(a).includes("doc-dialog-content"))return null;let h=T=>T.childNodes.some(_=>!_.tagName&&!V(_)&&_.nodeName!=="#comment");if(h(s)||h(l)||!W(l)||!i(a))return null;let L=y(l),b=L.filter(T=>C(T).includes(dt.title)),S=L.filter(T=>!b.includes(T)),E=T=>(C(T).includes(dt.close)||w(T,dt.closeAttribute)!==void 0)&&W(T);return b.length!==1||!W(b[0])||S.length>1||!S.every(E)?null:{header:l,title:b[0],close:S[0]??null,content:a}},Nt,$e=(t,s=[])=>{for(let o of t.childNodes??[])if(o.tagName){for(let{name:l,value:a}of o.attrs)l!=="id"&&l!=="class"&&s.push(a);(o.tagName==="script"||o.tagName==="style")&&s.push(o.childNodes.map(l=>l.value??"").join("")),$e(o,s)}return s},Fs=(t,s)=>{Nt??=$e(f).join(`
|
|
5
5
|
`);let o=0;for(let l=Nt.indexOf(t);l>=0;l=Nt.indexOf(t,l+t.length))!/[\w-]/.test(Nt[l-1]??"")&&!/[\w-]/.test(Nt[l+t.length]??"")&&o++;return o>(s?1:0)};function Ks(t){let s=Gs(t);if(!s)return;let{header:o,title:l,close:a,content:c}=s,h=w(l,"id"),L=!!h&&w(t,"aria-labelledby")?.trim()===h;L&&x(t,"aria-labelledby"),r(i(o).startOffset,i(o).endOffset,n.slice(i(c).startOffset,i(c).endOffset));let b=i(l).startOffset+1;r(b,b+l.tagName.length,"h3"),g(l,[],{drop:[dt.title]}),h!==void 0&&!(h&&Fs(h,L))&&x(l,"id"),r(d(l).startOffset,d(l).endOffset,"</h3>"),a&&r(a.sourceCodeLocation.startOffset,a.sourceCodeLocation.endOffset,""),r(d(o).startOffset,d(o).endOffset,""),r(i(c).startOffset,i(c).endOffset,"")}let Ft=t=>{for(let s of t.childNodes??[]){if(it(s)){at(s).forEach(Ft);continue}s.tagName&&pt(s,ee.match)&&Ks(s),Ft(s)}},we=new Set;function be(t){let s=t.tagName;if(!W(t))return!1;let o=[];if(s==="mark"&&F(t,[]))K(t,'<span class="doc-highlight-yellow">',"</span>");else if((s==="del"||s==="strike")&&F(t,["cite","datetime"]))K(t,"<s>","</s>"),o=At(t);else if(s==="ins"&&F(t,["cite","datetime"]))K(t,"<u>","</u>"),o=At(t);else{if(["kbd","samp","tt","var"].includes(s)&&F(t,[]))return K(t,"<code>","</code>"),we.add(t),m(t,s),!0;if(s==="a"&&F(t,["href"])&&Ds(w(t,"href")))return g(t,[Cn]),m(t,"dialog link"),!1;if(s==="small"&&F(t,[]))K(t,'<span class="doc-text-gray">',"</span>");else if(s==="q"&&F(t,["cite"]))K(t,"\u201C","\u201D"),o=At(t);else if(["abbr","cite","dfn","time","bdi","data"].includes(s)&&F(t,["title","datetime","value"]))Rt(t),o=At(t);else if(s==="span"&&F(t,[])||s==="font"&&F(t,["color"])&&!w(t,"color")?.trim())Rt(t);else if(s==="span"&&F(t,["style"])||s==="font"&&F(t,["color"])){let l=Cs(s==="span"?w(t,"style")??"":`color: ${w(t,"color")}`);if(l.foreign)return!1;K(t,l.open,l.close),o=l.notes}else return!1}return we.add(t),m(t,s,o),!1}function Hs(t){let{startOffset:s,endOffset:o}=t.sourceCodeLocation,l=n.slice(s,o);for(let a of l.matchAll(Rn))N(s+a.index,s+a.index+a[0].length,'<span class="doc-math-inline">',"</span>"),u.push({line:$(s+a.index),rule:"formula"})}let Kt=new Set,ke=new Set;function kt(t,s=()=>!1){for(let o of te(t)){if(!o.every(b=>b.tagName?i(b)&&(d(b)||ne.has(b.tagName))&&!oe(b):b.sourceCodeLocation))continue;let l=o[0].sourceCodeLocation.startOffset,a=o.at(-1).sourceCodeLocation.endOffset,c=n.slice(l,a),h=l+Pn.exec(c)[0].length,L=a-/[ \t\n\r\f]*$/.exec(c)[0].length;if(o.every(D)&&wt(n.slice(h,L)))N(h,L,'<div class="doc-math-block">',"</div>"),u.push({line:$(h),rule:"display formula"}),o.forEach(b=>ke.add(b));else if(s(o)){let b=Qn(o);N(h,L,b?"<p>":"<p><strong>",b?"</p>":"</strong></p>"),u.push({line:$(h),rule:"step title",...ye(o[0].parentNode)}),o.forEach(S=>Kt.add(S))}else N(h,L,"<p>","</p>"),u.push({line:$(h),rule:"loose words"}),o.forEach(b=>Kt.add(b))}}let Ps=t=>t[0].parentNode.childNodes.slice(0,t[0].parentNode.childNodes.indexOf(t[0])).every(s=>!s.tagName||C(s).includes(_t)),Le=new Set,ye=t=>Le.has(t.parentNode)?{}:(Le.add(t.parentNode),{note:"a step's own words written as its title, the first block of its node: <li><p><strong>\u2026</strong></p> then its content (a paragraph, a list\u2026)</li>"}),Ws=t=>{if(kt(t.childNodes,Ps),t.childNodes.filter(a=>a.tagName&&!C(a).includes(_t)).length>0||te(t.childNodes).length>0||!i(t)||!d(t))return;let l=t.childNodes.filter(a=>a.tagName).at(-1)?.sourceCodeLocation?.endOffset??i(t).endOffset;r(l,l,"<p></p>"),u.push({line:$(l),rule:"step title",...ye(t)})},Ht,ve=()=>{Ht??=ro(f);let t=kn(Ht);return Ht.add(t),t},Us=(t,s)=>`<div data-doc-chart="${z(w(t,"data-doc-chart"))}" ${wn}="${z(s)}"></div>`,Ot=n.includes(`\r
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-FFV733MA.mjs";import"./chunk-WFGPMCTZ.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-4B2TB5K2.mjs";import"./chunk-KLQP46Y3.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as copiedLines,b as run};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as Je,b as Qe,c as ge,e as At,h as Xe,i as tn}from"./chunk-
|
|
2
|
+
import{a as Je,b as Qe,c as ge,e as At,h as Xe,i as tn}from"./chunk-ECZBLQKK.mjs";import{A as Ye,B as We,C as Te,D as Q,E as Ze,a as me,g as Oe,h as He,j as Ne,l as Fe,m as wt,n as ke,o as $e,p as ne,q as Ft,r as De,s as Ve,t as vt,u as Le,v as Ge,w as Me,x as kt,y as G,z as je}from"./chunk-E7656LR7.mjs";import{g as Ct}from"./chunk-TKWEX4FD.mjs";import{b as pe,c as he,e as Ee}from"./chunk-A55HN5OK.mjs";import{BLOCK_TYPES as Ie,COPIED_AS_ITSELF as Kn,IDENTITY as gn}from"../browser/editor/components/registry.mjs";import{copyKeys as Un}from"../browser/editor/components/figure/index.mjs";import{accepts as xe,attributeValue as An,BLOCK_TYPES as Dt,boxRole as we,CHAPTER as En,holdsStraight as On,IDENTITY as Ke,isLead as rn,SIZES as Nn,sizeValue as ln,TOGGLES as an}from"../browser/editor/components/registry.mjs";import{iconMarkup as $n,iconValueOf as Ln,validIcon as Mn}from"../browser/editor/components/icon/index.mjs";Ee();import{attributeValue as bn,BLOCK_TYPES as en,HOSTS as xn,TOGGLES as wn}from"../browser/editor/components/registry.mjs";import{texSource as nn}from"../browser/editor/components/math/index.mjs";var Ce=new Set(Object.entries(en).filter(([,s])=>!s.box&&!s.bare).map(([s])=>s)),se=(s,m,I="")=>{let k=Q[m.type]?.leaf;if(k)return k(s,m,I);let g=[s.className,...m.classes??[]].filter(Boolean).join(" ");return`<${s.tag}${g?` class="${g}"`:""}${ke(m.attributes)}${I}>${m.html}</${s.tag}>`},Be=(s,m)=>s===void 0||!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(s).every(([I,k])=>typeof k=="string"&&bn(m,I,k)),qe=s=>s?.empty===!0,Pe=(s,m)=>s===void 0?null:I=>s.includes(m.slice(I.startOffset,I.endOffset));function ye(s,m,{empty:I=!1,file:k}={}){if(typeof m!="string"||!m.trim()&&!(I&&m===""))return!1;if(m==="")return!0;if(s.tex&&!nn(m))return!1;let g=s.inside??s.tag,$=`<${g}>${m}</${g}>`,[w,...u]=he($,{sourceCodeLocationInfo:!0}).childNodes;return u.length===0&&w?.tagName===g&&ge(w,[],s.inside!==void 0,{cell:g==="td"||g==="th",known:Pe(k,$)})===null}var vn=new Set(Object.values(en).filter(s=>s.text&&s.className).map(s=>s.kind));function ze(s,m){if(s.keep?.reason==="script")return null;if(s.kind==="list")return m.some(k=>k.unit===s.id&&k.kind==="list")?"list":null;let I=Q[s.kind];return I?.written?I.written(s)?"written":null:s.text===void 0||s.nested?null:["p","h1","h2","h3","h4","li"].includes(s.tag)||vn.has(s.kind)?"text":null}function be(s,m,I){if(!Array.isArray(m)||!m.every(g=>Sn(s,g,I)))return"invalid";let k=m.filter(g=>g.keep);return k.length>1?"invalid":m.length>k.length&&!s.caps.split||k.length===0&&!s.caps.remove||m.length===0&&s.nested?"fixed":k.length===1&&k[0].html.trim()===""&&!s.caps.empty?"empty":null}function sn(s,m,I){let k=`<table><tbody><tr><${s}>${m}</${s}></tr></tbody></table>`,[g,...$]=he(k,{sourceCodeLocationInfo:!0}).childNodes,w=$.length===0&&g?.tagName==="table"&&g.childNodes.length===1?g.childNodes[0]:null,u=w?.childNodes.length===1?w.childNodes[0]:null,h=u?.childNodes.length===1?u.childNodes[0]:null;return h?.tagName===s&&ge(h,[],!1,{cell:!0,known:Pe(I,k)})===null}var on={p:"paragraph",h1:"heading",h2:"heading",h3:"heading",h4:"heading",li:"item"},In=(s,m)=>s.classes===void 0||!s.keep&&Array.isArray(s.classes)&&new Set(s.classes).size===s.classes.length&&s.classes.every(I=>(wn[on[m]]??[]).includes(I));function Sn(s,m,I){if(!m||typeof m.html!="string"||xn[s.kind]?.tex&&!nn(m.html))return!1;let k=m.keep?s.tag:m.tag;if(!m.keep&&Je[s.tag]!==k||!In(m,k)||m.attributes!==void 0&&(m.keep||!Be(m.attributes,on[k])))return!1;let g=k==="td"||k==="th",$=g?`<table><tbody><tr><${k}>${m.html}</${k}></tr></tbody></table>`:`<${k}>${m.html}</${k}>`,[w,...u]=he($,{sourceCodeLocationInfo:!0}).childNodes;if(u.length>0||!w)return!1;let h=w;if(g){let p=w.tagName==="table"&&w.childNodes.length===1?w.childNodes[0]:null,f=p?.childNodes.length===1?p.childNodes[0]:null;h=f?.childNodes.length===1?f.childNodes[0]:null}return h?.tagName===k&&ge(h,[],Qe(s.kind,s.tag,s.caps),{cell:g,known:Pe(I,$)})===null}import{attr as cn}from"../browser/shared/html-tree.mjs";import{pageLanguage as jn}from"../browser/shared/components/page.mjs";import{SHEETS as Tn}from"../browser/editor/components/kit.mjs";import{BLOCK_ID as Cn}from"../browser/shared/ids.mjs";function fn({current:s,edits:m,units:I=[],partial:k=!1,ids:g=!1,touch:$=[],proposals:w=null}){let u=At(s),h=u.blocks,p=s.includes(`\r
|
|
3
3
|
`)?`\r
|
|
4
4
|
`:`
|
|
5
5
|
`,f=[],O=[],j=[],K=new Map,q=null,X,xt=!1,tt=(t,n)=>f.push({unit:t.id,reason:n}),et=t=>{let o=Ft(t).replace(/[0-9.]/g,l=>String.fromCharCode(l.charCodeAt(0)-65248)).replace(/[\s,,]/g,"").replace(/[−–]/g,"-").match(/-?\d+(?:\.\d+)?/)?.[0];return o===void 0?null:Number(o)},ht=(t,n,o)=>{if(t.kind!=="cell")return;let l=s.slice(t.start,t.innerStart),a=/\sdata-sort-value(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/.exec(l);if(!a)return;let d=(a[1]??a[2]??a[3]??"").trim(),x=/^-?\d+(\.\d+)?(e[-+]?\d+)?$/i.test(d)?Number(d):null,[S,c]=[et(s.slice(t.innerStart,t.innerEnd)),et(n)],b="";x!==null&&c!==null?b=` data-sort-value="${Number((c*(S?x/S:1)).toPrecision(12))}"`:x!==null&&S===null&&(b=a[0]),b!==a[0]&&O.push({start:t.start+a.index,end:t.start+a.index+a[0].length,text:b,of:[{id:o}]})},Vt=t=>{t.keep&&ee(t)?tt(t,"referenced"):j.push({start:t.start,end:t.end},...t.companion?[t.companion]:[])},oe=(t,n)=>{let o=t.classAttr,l=o?o.value.split(/\s+/).filter(Boolean):[],a=l;for(let[x,S]of n)a=S?a.includes(x)?a:[...a,x]:a.filter(c=>c!==x);if(a.join(" ")===l.join(" "))return;if(ut(t),!o){let x=/^<[A-Za-z][\w-]*/.exec(s.slice(t.elStart,t.elStart+40));if(!x)return tt(t,"unknown");let S=t.elStart+x[0].length;O.push({start:S,end:S,text:` class="${a.join(" ")}"`});return}if(a.length===0){O.push({...ne(s,o.start,o.end),text:""});return}let d=/=\s*'/.test(s.slice(o.start,o.end))?"'":'"';O.push({start:o.start,end:o.end,text:`class=${d}${a.join(" ")}${d}`})},It=typeof g=="function"?g:g?Xe:null,ct=new Set([...s.matchAll(tn)].map(t=>t[1]??t[2])),qt=()=>{for(;;){let t=It();if(!ct.has(t))return ct.add(t)&&t}},re=[],Pt=[],Gt=t=>t?` ${Ke}="${t}"`:"",le=t=>typeof t=="string"&&Cn.test(t)&&!ct.has(t),ft=(t,n)=>{let o=It?le(n)?(ct.add(n),n):qt():null;return o&&t!==void 0&&Pt.push({key:t,id:o}),Gt(o)},ot=new Set,zt=t=>{ot.add(t.at);let n=w?.get(t.id),o=It?le(n)?(ct.add(n),n):qt():null;return o&&re.push({at:t.at,id:o}),Gt(o)},ut=t=>{if(!It||!t||t.blockId||t.at===void 0||ot.has(t.at))return;let n=$e(s,t.at);O.push({start:n,end:n,text:zt(t)})},St=t=>{let{element:n,source:o}=vt(t.restore),l=n.sourceCodeLocation,a=cn(n,Ke);if(a&&!ct.has(a))return ct.add(a),t.key!==void 0&&Pt.push({key:t.key,id:a}),o;let d=o,x=l.startTag.endOffset-1;if(a){let S=l.attrs[Ke],c=ne(d,S.startOffset,S.endOffset);d=d.slice(0,c.start)+d.slice(c.end),x-=c.end-c.start}return x=$e(d,x),d.slice(0,x)+ft(t.key,t.blockId)+d.slice(x)},gt=t=>{let n=null;for(let o of u.units)o.elStart<=t.start&&t.start<o.end&&(!n||o.elStart>n.elStart)&&(n=o);return n},_=new Set;for(let t of m){let{id:n,parts:o}=t??{},l=Number.isInteger(n)?h[n]:void 0;if(!l){f.push({id:n,reason:"unknown"});continue}if(Array.isArray(o)&&o.length===0&&l.self!==null&&u.units[l.self].keep){f.push({id:n,reason:"referenced"});continue}let a=be(l,o,s);if(a){f.push({id:n,reason:a});continue}if(o.length===0){let N={...je(s,l.start,l.end),of:[{id:n}]};O.push(N),K.set(n,N),l.self!==null&&_.add(l.self);continue}let d=G(s,l.start),x=d===null?"":p+d,S=N=>`<${N.tag}${N.classes?` class="${N.classes.join(" ")}"`:""}${ke(N.attributes)}${ft(N.key,N.blockId)}>${N.html}</${N.tag}>`,c=o.findIndex(N=>N.keep),b=gt(l),v=b&&b.at===l.innerStart-1;if((!v||l.tag==="li")&&ut(b),l.tag==="li"&&c>=0){let N=o.slice(0,c),z=o.slice(c+1),C=b?{start:b.start,end:b.end}:null;O.push({start:l.innerStart,end:l.innerEnd,text:o[c].html,of:[{id:n}]}),N.length>0&&O.push({start:l.start,end:l.start,seq:1/0,text:N.map(S).join(x)+x,edge:C,of:[{id:n}]}),z.length>0&&O.push({start:l.end,end:l.end,text:x+z.map(S).join(x),edge:C,of:[{id:n}]})}else{let N=s.slice(l.start,l.innerStart);if(v&&It&&!b.blockId&&!ot.has(b.at)&&(N=`${N.slice(0,-1)}${zt(b)}>`),o.length===1&&c===0&&N===s.slice(l.start,l.innerStart)){O.push({start:l.innerStart,end:l.innerEnd,text:o[0].html,of:[{id:n}]}),ht(l,o[0].html,n),l.kind==="title"&&(q={from:Ft(s.slice(l.innerStart,l.innerEnd)),to:Ft(o[0].html)});continue}let z=o.map(C=>C.keep?N+C.html+s.slice(l.innerEnd,l.end):S(C)).join(x);O.push({start:l.start,end:l.end,text:z,of:[{id:n}]})}l.kind==="title"&&(q={from:Ft(s.slice(l.innerStart,l.innerEnd)),to:Ft(o[0].html)})}let Y=(t,n,o)=>{let l=u.units.filter(c=>c.box===t),a=[];for(let c=1;c<l.length;c++){let b=s.slice(l[c-1].end,l[c].start);b.trim()||a.push({pair:[l[c-1],l[c]],gap:b})}let d=a.find(({pair:c})=>c.includes(n))??a[0];if(d)return d.gap.replace(/\r?\n/g,p);let x=G(s,o.start),S=we(u.boxes[t]?.kind)==="root"?p:"";return x===null?"":S+p+x},Yt=t=>{if(t.kind!=="nest"||G(s,t.innerEnd)!==null)return null;let n=u.units[t.unit];return n?G(s,n.elStart):null},Wt=(t,n)=>{let o=s.slice(t.at+1,t.innerEnd).match(/\n([ \t]*)\S/);return o?o[1]:`${n??""} `},Kt=(t,n)=>n!==null&&we(t.kind)==="root",mt=[],Zt=(t,n,o,l)=>{let a=Number.isInteger(n?.into)?u.boxes[n.into]:null,d=Number.isInteger(n?.after),x=a?null:u.units[d?n.after:n?.before],S=a??(x?u.boxes[x.box]:null),c=z=>z>=t.start&&z<t.end;if(!S||!(xe(S.kind,te(t))||l===S.kind)||t.kind==="tab"&&S.id!==t.box||x&&(x===t||!o.has(x.id)||c(x.elStart))||a&&c(S.at))return tt(t,"position");let b=G(s,t.start);if(ut(t),a){if(a.innerEnd===null)return tt(t,"missing");let z=Yt(a);if(z!==null){mt.push({start:t.start,end:t.end,at:a.innerEnd,seq:lt++,from:b,to:z+nt,wrap:R=>p+z+nt+R+p+z});return}let C=G(s,a.innerEnd),W=Wt(a,C),T=C!==null&&W.startsWith(C)?W.slice(C.length):" ",P=Kt(a,C);mt.push({start:t.start,end:t.end,at:P?a.innerEnd-C.length:a.innerEnd,seq:lt++,from:b,to:W,wrap:R=>C===null?R:P?C+T+R+p:T+R+p+C});return}let v=Y(x.box,x,x),N=d?v.includes(`
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
+
import{a as w,b as k,c as f,g as u}from"./chunk-7UZUQQ7Q.mjs";import{readFileSync as E,realpathSync as S}from"node:fs";import p from"node:path";import{fileURLToPath as $}from"node:url";var j=p.dirname($(import.meta.url));function v(r=j){for(let o=r;;o=p.dirname(o)){try{let n=JSON.parse(E(p.join(o,"package.json"),"utf8"));if(n.name==="@heycys/gallery")return n.version}catch{}if(p.dirname(o)===o)return"0.0.0"}}var x={init:()=>import("./chunk-VZ2RQ3AM.mjs"),new:()=>import("./chunk-Q4MS6OFC.mjs"),import:()=>import("./chunk-65NTKF4N.mjs"),open:()=>import("./chunk-MNWJ4EZY.mjs"),serve:()=>import("./chunk-53XDTHTG.mjs"),stop:()=>import("./chunk-QVGOPHOF.mjs"),check:()=>import("./chunk-BMX3VUHY.mjs"),export:()=>import("./chunk-E4IHAIJ7.mjs"),qa:()=>import("./chunk-VPMRP2TL.mjs"),list:()=>import("./chunk-QNECWMGR.mjs"),workspaces:()=>import("./chunk-ERE2BXYV.mjs"),move:()=>import("./chunk-GKOBB6DH.mjs"),set:()=>import("./chunk-7EFHNQ5B.mjs"),link:()=>import("./chunk-LMUZQK5O.mjs"),extension:()=>import("./chunk-6XD6U3QA.mjs"),block:()=>import("./chunk-OEIJLMPI.mjs"),page:()=>import("./chunk-2T4PZQEP.mjs"),skill:()=>import("./chunk-JXXHAXYH.mjs")},N=new Set(["stop","init","skill","workspaces"]),A=(r,o)=>`${r.split(`
|
|
3
|
+
`)[0]} (gallery ${o?`${o} --help`:"help"} says more)`,g=r=>/^--.|^-[A-Za-z]/.test(r);function L(r){let o=r.indexOf("--"),n=o===-1?r:r.slice(0,o),h=o===-1?[]:r.slice(o),i=[],a=null;for(let e=0;e<n.length;e++){let s=n[e];if(s==="--workspace"||s.startsWith("--workspace=")){let t=s.includes("=")?s.slice(s.indexOf("=")+1):e+1<n.length&&!g(n[e+1])?n[++e]:"";if(!t)return{error:"--workspace takes a folder: --workspace <dir>",usage:u};if(a!==null&&p.resolve(a)!==p.resolve(t))return{error:`Two workspaces named: ${a} and ${t}.`,usage:u};a=t;continue}i.push(s)}if(i[0]==="--version"||i[0]==="-v"||i[0]==="-V")return i.length===1&&h.length===0?{version:!0}:{error:"--version takes nothing else.",usage:u};if(i.length===0||i[0]==="help"||i[0]==="--help"||i[0]==="-h"){let e=i[0]==="help"?i[1]:void 0;return e===void 0?{help:u}:Object.hasOwn(f,e)?{help:f[e]}:{error:`No such command: ${e} (${w.join(", ")}).`,usage:u}}let[c,...m]=i,l=k[c]??c;if(!Object.hasOwn(x,l))return{error:g(l)?`Unknown option: ${l} (the command comes first: gallery <command> [options]).`:`No such command: ${l} (${w.join(", ")}).`,usage:u};let d=[...m,...h];if(m.some(e=>e==="--help"||e==="-h"))return{help:f[l]};if(l==="init"){let e=new Set(["--from","--name"]),s=[];for(let t=0;t<m.length;t++)e.has(m[t])?t++:g(m[t])||s.push(m[t]);if(s.push(...h.slice(1)),s.length>1)return{error:"Name one folder at most.",usage:f.init,command:l};if(s.length===1){if(a!==null&&p.resolve(a)!==p.resolve(s[0]))return{error:`Two workspaces named: ${s[0]} and --workspace ${a}.`,usage:f.init,command:l};a=s[0]}}return{command:l,argv:d,flag:a}}var G=(r,o)=>`Cannot write the workspace ${r} (${o}): allow Gallery to write there, or pass --workspace <a folder you may write>.`,b=(r,o=!0)=>o?`${p.join(r,"gallery.json")} is not Gallery's (another program's file of that name): pass --workspace <another folder> for Gallery's documents.`:`${p.join(r,"gallery.json")} does not read as JSON: mend the file, or pass --workspace <another folder> for Gallery's documents.`;async function W(r=process.argv.slice(2)){process.stdout.on("error",e=>{throw e.code==="EPIPE"&&process.exit(process.exitCode??0),e});let o=L(r);if(o.version){let e=v();console.log(e);try{let{versionNotes:s}=await import("./chunk-TANZRINB.mjs");for(let t of s(e))console.log(t)}catch{}return}if(o.help)return void console.log(o.help);o.error&&(console.error(`${o.error}
|
|
4
|
+
${A(o.usage,o.command)}`),process.exit(2));let{command:n,flag:h}=o,{findWorkspace:i,defaultWorkspace:a}=await import("../browser/shared/workspace.mjs"),c=["page","block","extension"].includes(n)?{root:a(),how:"default"}:i({flag:h});if(process.env.GALLERY_WORKSPACE=c.root,!N.has(n)){let{ensureWorkspace:e}=await import("../browser/shared/workspace.mjs");try{await e(a());let{ours:t,reads:O}=await e(c.root,{state:n!=="init"||c.root===a()});t||(console.error(b(c.root,O)),process.exit(1))}catch(t){if(!t.code)throw t;console.error(G(c.root,t.code)),process.exit(1)}let{registerQuietly:s}=await import("../browser/shared/workspace-registry.mjs");await s(c.root)}let{UsageError:m,usageFailureText:l}=await import("./chunk-GPIWQ4X4.mjs"),d=await x[n]();try{await d.run(o.argv,{command:n,workspace:c.root,how:c.how,version:v()})}catch(e){if(!(e instanceof m))throw e;console.error(l(f[n],e.message,e.synopsis)),process.exit(2)}}var y=r=>{try{return S.native(r)}catch{return null}};process.argv[1]&&y(process.argv[1])===y($(import.meta.url))&&W();export{v as a,L as b,G as c,b as d,W as e};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
+
import{i as p}from"./chunk-S3SX3COT.mjs";import{g as b}from"./chunk-VRPVVMRB.mjs";import{g as k}from"./chunk-USIHBCSW.mjs";import{k as d}from"./chunk-PLB7L22J.mjs";import{workspaceBase as v}from"../browser/shared/service-location.mjs";import j from"node:fs/promises";import f from"node:path";import{editStateDirectory as m,reportsDirectory as h}from"../browser/shared/paths.mjs";import{findPreviewServer as $}from"../browser/shared/preview-server.mjs";import{documentDirectory as S,documentFiles as g,isDocumentSource as D}from"../browser/shared/workspace.mjs";var u=e=>f.resolve(e),N=e=>f.basename(g(f.dirname(e)).json),O={busy:"it kept changing while it was being written (an Agent writing it?); nothing written. Run the export again.",timeout:"the workspace's Gallery server did not answer in 30s; nothing written. Run the export again."};async function w(e,n,o="hand-in",l=3e4){let t=`127.0.0.1:${e.port}`,s;try{s=await fetch(`http://${t}${v(h)}/__gallery/edit/${o}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${t}`,"X-Gallery-Token":e.token},body:JSON.stringify({slug:n,workspace:h}),signal:AbortSignal.timeout(l)})}catch(a){return a.name==="TimeoutError"?{ok:!1,reason:"timeout"}:null}let i=await s.json().catch(()=>null);return typeof i?.ok!="boolean"||["elsewhere","token","host","origin"].includes(i.reason)?null:i}async function C(e){let n=await $(),o=null,l=[],t=new Map,s=[];for(let i of e){let{html:a,json:c}=g(S(i,h)),r=n?await w(n,i):null;if(r===null&&(o??=p({reportsDirectory:h,stateDirectory:m,finish:d}),r=await o.handIn(i),r.ok&&await o.settleNotes(i)),!r.ok){r.reason!=="missing"&&t.set(i,[`${u(a)} was not handed in: ${O[r.reason]??r.message??r.reason}`]);continue}if(r.repeated?.length){t.set(i,k(r.repeated));continue}s.push(...R(a,r)),r.written&&(r.changes.length&&s.push(...b(a,r.changes,{reread:!1})),r.added&&s.push(...L(a,r.given,r.added)),l.push(u(a))),T(r)&&l.push(u(c))}return{written:l,failures:t,lines:s}}async function H(e){let n=await $();if(n){for(let o of e)if(await w(n,o,"settle")===null)return}}async function K(e,{wait:n=3e4}={}){try{let o=await $(),l=o?await w(o,e,"round",n):null;return l!==null?l.ok?l.ended===!0:null:await p({reportsDirectory:h,stateDirectory:m,finish:d}).beginRound(e)}catch{return null}}async function W(e){try{let n=p({reportsDirectory:h,stateDirectory:m,finish:d}),{html:o}=g(S(e,h));await n.noteTaken(e,await j.readFile(o,"utf8"))}catch{}}var T=({title:e=null,icon:n=null})=>!!(e&&typeof e.from=="string"&&e.from!==e.to||n&&!n.missing),x=10;function L(e,n,o=n?.length??0,{pending:l=!1}={}){let t=`${o} block${o===1?"":"s"}`;if(l){let i=[`ids ${u(e)}: ${t} without an id yet: the export gives ${o===1?"it":"each"} one`];return o>x?i:[...i,...n.map(({line:a,tag:c})=>` line ${a} ${c}`)]}let s=[`ids ${u(e)}: ${t} given an id`];return!n||o>x?s:[...s,...n.map(({line:i,tag:a,id:c})=>` line ${i} ${a} \u2192 ${c}`)]}function R(e,{title:n=null,icon:o=null}={},{pending:l=!1}={}){let t=u(f.dirname(e)),s=N(e),i=(c,r,y)=>l?`${c} not ${r} yet (${y}): the export writes ${c.includes(" and ")?"them":"it"}`:`${c} written ${r}: ${y}`,a=[];if(n){let c=[...n.page?["<title>"]:[],...typeof n.from=="string"&&n.from!==n.to?[`${s}'s title`]:[]];c.length&&a.push(`title ${t}: ${i(c.join(" and "),"as its h1 says it",JSON.stringify(n.to))}`)}return o?.missing?a.push(`icon ${t}: ${s} has the icon ${JSON.stringify(o.from)} and the page's header none: write it there (<div class="doc-icon">\u2026</div> before the h1) or take "icon" out of ${s} (the export leaves ${s}'s as it is)`):o&&a.push(`icon ${t}: ${i(`${s}'s icon`,"as its header has it",o.to===null?"none":JSON.stringify(o.to))}`),a}function X(e,{by:n="this export"}={}){let o=e.length===1,l=[...e.filter(t=>D(f.basename(t))).map(t=>f.basename(t)).filter((t,s,i)=>i.indexOf(t)===s).map(t=>`${t}: the kit's markup, block ids`),...e.filter(t=>/^(doc|report)\.json$/.test(f.basename(t))).map(t=>f.basename(t)).filter((t,s,i)=>i.indexOf(t)===s).map(t=>`${t}: the title or icon said above`)];return`Re-read ${e.join(", ")} before editing ${o?"it":"them"}: ${n} wrote ${o?"it":"them"} (${l.join("; ")}).`}export{C as a,H as b,K as c,W as d,L as e,R as f,X as g};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-VRPVVMRB.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{g as changeLines,c as handedInSource,f as headerChanged,e as inStep,a as naturalize,d as pendingBlockIds,h as readOnlyTexts,j as scriptKept,b as shownSource,i as writingNotes};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
+
import{a as D,b as M}from"./chunk-QP7BOHE4.mjs";import{c as y,d as j}from"./chunk-WFGPMCTZ.mjs";import{b as w,f as A}from"./chunk-4OZWXZE5.mjs";import L from"node:fs/promises";import k from"node:path";import{readAnnouncement as T}from"../browser/shared/preview-server.mjs";import{nameProblem as _,nameStops as v,ownName as B,workspaceLabels as K,workspaceName as b,writeWorkspaceName as Q}from"../browser/shared/workspace-name.mjs";import{forgetWorkspace as R,isWorkspace as C,isWorkspaceId as U,readRegistry as F,registerQuietly as x,registerWorkspace as q,SCAN_DEPTH as P,SCAN_LIMIT as z,scanForWorkspaces as J,workspaceId as V,workspaceKey as l}from"../browser/shared/workspace-registry.mjs";import{defaultWorkspace as X,documentsFolder as E,ensureWorkspace as Y,layoutOf as Z}from"../browser/shared/workspace.mjs";import{clashingIds as ee}from"../browser/shared/drafts.mjs";var u=(o,t)=>`${o} ${t}${o===1?"":"s"}`,W=(o,t)=>l(o)===l(t);function oe(o){if(B(o)||W(o,X()))return null;let{name:t}=b(o,{stops:v()});return`\u5DE5\u4F5C\u533A\u540D\u5B57\uFF1A\u6CA1\u6709\uFF08\u522B\u5904\u6309\u6587\u4EF6\u5939\u53EB\u5B83"${t}"\uFF09\uFF1B\u8FD9\u4E2A\u5DE5\u4F5C\u533A\u662F\u4E3A\u4E00\u4E2A\u9879\u76EE\u5EFA\u7684\uFF0C\u5C31\u7528 gallery workspaces --name "<\u9879\u76EE\u540D>" \u5199\u4E0A\u9879\u76EE\u540D`}async function se(o,t){let n=_(t);if(n)throw new w(n);try{let{ours:r,reads:f}=await Y(o);r||(console.error(j(o,f)),process.exit(1))}catch(r){if(!r.code)throw r;console.error(y(o,r.code)),process.exit(1)}let s;try{s=await Q(o,t)}catch(r){console.error(r.code?y(o,r.code):r.message),process.exit(1)}await x(o),console.log(`\u5DE5\u4F5C\u533A\uFF1A${o}`),console.log(`\u540D\u5B57\uFF1A${s.name} (in ${Z(o).marker}${s.before&&s.before!==s.name?`; it was "${s.before}"`:""}): the sidebar and gallery workspaces call it so.`)}async function re(o,t){let n=await R(o);n.length||(console.error(`No registered workspace is ${U(o)?o:k.resolve(o)}: gallery workspaces lists them, with their paths and ws- ids.`),process.exit(1));for(let s of n)console.log(`Forgot ${s} (only the registry changed: nothing on disk).${W(s,t)?" It is the current workspace: the next command run in it registers it again.":""}`)}async function te(o){let t=k.resolve(o??E());await L.stat(t).then(a=>a.isDirectory(),()=>!1)||(console.error(`No such folder: ${t} (--scan names a folder to look in).`),process.exit(1));let n=new Set(F().workspaces.map(({root:a})=>l(a))),{found:s,read:r,cut:f}=await J(t);console.log(`Scanned ${t}, ${P} levels down (${u(r,"folder")}): ${s.length?`${u(s.length,"workspace")}.`:"no workspace."}`);let i=v();for(let a of s){let{name:d}=b(a,{stops:i});if(n.has(l(a))){await x(a),console.log(` \u5DF2\u767B\u8BB0\uFF1A${a}\uFF08${d}\uFF09`);continue}try{await q(a)}catch(m){console.log(` \u6CA1\u80FD\u767B\u8BB0\uFF08${m.code??m.message}\uFF09\uFF1A${a}`);continue}console.log(` \u65B0\u767B\u8BB0\uFF1A${a}\uFF08${d}\uFF09`)}f&&console.log(`Stopped after ${u(z,"folder")}: gallery workspaces --scan <a folder further down> looks at the rest.`),s.length&&console.log("gallery workspaces lists them; gallery list <words> --all searches their documents.")}async function ne(o){let t=C(o);t&&await x(o);let n=F().workspaces,s=[o,...n.map(({root:e})=>e).filter(e=>!W(e,o))],r=new Map(n.map(({root:e,seen:c})=>[l(e),Date.parse(c)])),f=E(),i=v({documents:f}),a=await Promise.all(s.map(async e=>{let c=C(e),p=c?await D(e):[];return{root:e,there:c,count:p.length,edited:p.reduce((g,{edited:h})=>Math.max(g,h),0),named:{root:e,...b(e,{stops:i})}}})),[d,...m]=a;m.sort((e,c)=>c.there-e.there||c.edited-e.edited||(r.get(l(c.root))??0)-(r.get(l(e.root))??0));let I=[d,...m],G=new Map(K(I.map(({named:e})=>e)).map(e=>[l(e.root),e])),$=await T();console.log($?`Gallery \u670D\u52A1\uFF1Ahttp://127.0.0.1:${$.port}/ (pid ${$.pid})`:"Gallery \u670D\u52A1\uFF1A\u672A\u542F\u52A8");let N=n.length;console.log(`${u(N,"workspace")} on this machine's registry; the current one first (*):`);for(let e of I){let{name:c,own:p,above:g}=G.get(l(e.root)),h=e===d,S=[...p||!e.there?[]:["\u6CA1\u6709\u8D77\u540D\uFF1A\u7528\u7684\u662F\u6587\u4EF6\u5939\u7684\u540D\u5B57"],...e.there?[]:[h?"\u8FD8\u6CA1\u6709\u5EFA":"\u4E0D\u5728\u4E86\uFF1A\u6587\u4EF6\u5939\u6216\u5B83\u7684 gallery.json \u627E\u4E0D\u5230\u4E86"]],H=g?k.isAbsolute(g)?`\uFF08${g}\uFF09`:`\uFF08\u4E0A\u4E00\u7EA7\uFF1A${g}\uFF09`:"";console.log(`${h?"*":" "} ${c}${H} ${V(e.root)}${S.length?` \uFF08${S.join("\uFF1B")}\uFF09`:""}`),console.log(` \u8DEF\u5F84\uFF1A${e.root}`),e.there&&console.log(` \u6587\u6863\uFF1A${e.count?`${e.count} \u7BC7\uFF1B\u4E0A\u6B21\u7F16\u8F91\uFF1A${M(e.edited)}`:"\u6CA1\u6709"}`)}for(let{id:e,roots:c}of ee())console.log(`${e} \u662F ${c.length} \u4E2A\u767B\u8BB0\u7684\u5DE5\u4F5C\u533A\u5171\u7528\u7684\u7F16\u53F7\uFF08${c.join("\u3001")}\uFF09\uFF1A\u4FA7\u8FB9\u680F\u91CC\u5B83\u4EEC\u7684\u5E95\u7A3F\u90FD\u627E\u4E0D\u5230\uFF1Bgallery workspaces --forget <\u8DEF\u5F84> \u53BB\u6389\u5176\u4E2D\u4E00\u4E2A`);let O=t?oe(o):null;O&&console.log(O),m.some(({there:e})=>!e)&&console.log("One no longer there stays registered (a drive may come back): gallery workspaces --forget <\u8DEF\u5F84> takes it off, nothing on disk changed."),N<=1&&console.log(`gallery workspaces --scan registers the workspaces already on this machine (in the Documents folder, ${P} levels down; or --scan <folder>).`),console.log("gallery list <words> --all searches the documents of them all; every command takes --workspace <\u8DEF\u5F84> to work in one.")}async function we(o,t){let{positional:n,options:s,values:r}=A({options:["--scan"],values:["--name","--forget"],argv:o});if([s.has("--scan"),r.has("--name"),r.has("--forget")].filter(Boolean).length>1)throw new w("One of --scan, --name and --forget at a time.");if(n.length>(s.has("--scan")?1:0))throw new w(s.has("--scan")?"--scan takes one folder at most.":"gallery workspaces names no folder: --scan <folder> looks in one, --workspace <dir> names the current workspace.");let i=k.resolve(t.workspace);return r.has("--name")?se(i,r.get("--name")):r.has("--forget")?re(r.get("--forget"),i):s.has("--scan")?te(n[0]):ne(i)}export{oe as a,we as b};
|
package/dist/cli.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a,b,c,d,e}from"./chunk-
|
|
2
|
+
import{a,b,c,d,e}from"./chunk-WFGPMCTZ.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-5L7RYZCL.mjs";export{e as main,d as notOurs,b as readCommandLine,c as unwritable,a as versionOf};
|
package/dist/server.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as o}from"./chunk-
|
|
2
|
+
import{a as o}from"./chunk-BLNQUR5R.mjs";import"./chunk-6GV3CBB2.mjs";import"./chunk-DR73Y2UJ.mjs";import"./chunk-M4NRDYI5.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-6QWQXHAV.mjs";import"./chunk-6Q7ASAXJ.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-GJJRBGMY.mjs";import"./chunk-JPG2LBQM.mjs";import"./chunk-ALZ6ZENZ.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-4B2TB5K2.mjs";import"./chunk-KLQP46Y3.mjs";import"./chunk-USIHBCSW.mjs";import"./chunk-3SKOU6OZ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-PLB7L22J.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";var t=process.argv.indexOf("--port"),r=t===-1?Number.NaN:Number(process.argv[t+1]);(!Number.isInteger(r)||r<=0||r>=65536)&&(console.error("Usage: node dist/server.mjs --port <n> (GALLERY_WORKSPACE names the workspace). The gallery command starts it: gallery open."),process.exit(2));try{let{port:e}=await o({port:r});console.log(`[gallery] ${new Date().toISOString()} listening on http://127.0.0.1:${e}/ (pid ${process.pid})`)}catch(e){console.error(`[gallery] could not start on port ${r}: ${e.message}`),process.exit(1)}
|
package/dist/worker.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as P,b as W,c as B,e as H}from"./chunk-
|
|
2
|
+
import{a as P,b as W,c as B,e as H}from"./chunk-RRKJMHNX.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import{c as F}from"./chunk-E7656LR7.mjs";import{g as R,i as M}from"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{parentPort as N}from"node:worker_threads";import{PAGE as U}from"../browser/editor/components/kit.mjs";import{APART as T,clipboardOf as X,tagKind as j,unitClipboard as _,writtenApart as Y}from"../browser/editor/components/registry.mjs";import{WRITERS as h,heldToWords as Z,unitOpening as tt,wordsIn as et}from"../browser/editor/page/clipboard/own/writers.mjs";import{escapeAttribute as v}from"../browser/shared/escape.mjs";import{referencedFile as rt}from"../browser/shared/media.mjs";var nt=/^\s*\\\(([\s\S]*)\\\)\s*$/,ot=" ",st=["script","style","template","noscript",T,U.header,`${U.header} > h1`].join(", ");function it(r,u){let f=globalThis.document.createElement("template");f.innerHTML=r??"";let d=g=>[...g.childNodes].map(n=>{if(n.nodeType===3)return n.data.replace(/ /g," ");if(n.nodeType!==1)return"";if(n.matches(".doc-math-inline")){let i=nt.exec(n.textContent)?.[1];return i!==void 0?i.trim()?`$${i.trim()}$`:"":n.textContent}if(n.localName==="img"){let i=n.getAttribute("src");return i?`)})`:""}if(n.matches("a.doc-link-mention")){let i=(n.querySelector(".doc-link-mention-title")??n).textContent.replace(/\s+/g," ").trim();return n.getAttribute("href")?`[${i||n.getAttribute("href")}](${n.getAttribute("href")})`:i}let l=d(n);if(n.localName==="br")return`
|
|
3
3
|
`;if(!l.trim())return l;let[c,m,p]=[l.match(/^\s*/)[0],l.trim(),l.match(/\s*$/)[0]];switch(n.localName){case"strong":case"b":return`${c}**${m}**${p}`;case"em":case"i":return`${c}*${m}*${p}`;case"s":case"del":case"strike":return`${c}~~${m}~~${p}`;case"code":return`${c}\`${m}\`${p}`;case"a":{let i=n.getAttribute("href")??"";return!i||i.startsWith("#")?l:rt(i)?`${c}[${m}](${u(i,"file",n.getAttribute("download")||D(i))})${p}`:m===i?`${c}${i}${p}`:`${c}[${m}](${i})${p}`}default:return n.classList.contains("doc-tab")?` ${l}`:l}}).join("");return Z(d(f.content).replace(/[ \t]+\n/g,`
|
|
4
4
|
`).trim())}function b(r){if(!r.querySelector(T))return r;let u=r.cloneNode(!0);for(let f of u.querySelectorAll(T))f.remove();return u}var ct=r=>(r?.textContent??"").replace(/\s+/g," ").trim(),D=r=>r.replace(/[?#].*$/,"").split("/").pop(),at=r=>r.replace(/[\\[\]]/g,"\\$&"),ut=/(\d+)/g;async function K(r,{title:u,media:f=g=>g,chart:d=()=>null}){let{UNIT:g,unitsOf:n,serializeInner:l,nestedBlocks:c,isHost:m}=await P(),p=e=>it(e,f),i=e=>{let t=b(e),o=[...t.querySelectorAll("img")];if(o.length===0)return l(t);let s=t.cloneNode(!0);return s.querySelectorAll("img").forEach((a,A)=>a.replaceWith(`\uE000${A}\uE001`)),l(s).replace(ut,(a,A)=>`<img src="${v(o[A].getAttribute("src")??"")}" alt="${v(o[A].getAttribute("alt")??"")}">`)},z=e=>p(i(e)),G=(e,{tables:t=!0}={})=>{let o=b(e);return[...o.querySelectorAll("img[src]")].filter(s=>!s.closest("a.doc-link-mention")&&(t||!o.contains(s.closest("table")))).map(s=>p(s.outerHTML))},x=e=>(j(e)&&!e.matches(g)&&e.setAttribute("data-ge-unit-kind",j(e)),e);function w(e){let t=[],o=null;for(let s of e.childNodes){let a=s.nodeType===1;(a?s.matches(st):s.nodeType!==3)||(a&&(s.matches(g)||F.has(s.localName))?(t.push(x(s)),o=null):(a||o||s.data.trim())&&(o||t.push(o=x(r.createElement("p"))),o.append(s.cloneNode(!0))))}return t}let y=e=>h[_(e).kind].list,C=e=>e.map(t=>t&&`${ot}${t}`);function k(e){let t=[],o=null;for(let s of e){let a=E(s);a.length!==0&&(o!==null&&!(y(o)&&y(s))&&t.push(""),t.push(...a),o=s)}return t}function S(e){let t=[];for(let o of e){let s=E(o);if(s.length===0)continue;let a=y(o);!a&&t.length>0&&t.at(-1)!==""&&t.push(""),!a&&t.length===0&&t.push(""),t.push(...C(s)),a||t.push("")}for(;t.at(-1)==="";)t.pop();return t}function J(e,t=null){let s=n(e).length>0?[]:h.words.exported(e,$,{without:t});return s.length>0?["",...C(s)]:S(w(e).filter(a=>a!==t))}function E(e){let t=_(e);return h[t.kind].exported(e,$,t)}function V(e,t){let o=/^en(?:-|$)/i.test(e.ownerDocument.documentElement.getAttribute("lang")??"");return t?o?"Chart":"\u56FE\u8868":o?"Figure":"\u56FE"}let $={isHost:m,nestedBlocks:c,serializeInner:l,media:f,chart:d,inline:p,own:z,withPictures:i,picturesIn:G,lines:k,held:S,heldIn:J,untitled:V,wordsIn:(e,t,o)=>et(b(e),t,o),plain:ct,unitsOf:w,words:e=>h.words.exported(e,$),packageOf:e=>R().packages.get(e),opening:(e,t)=>tt(e,t,$),writtenAs(e,t){let o=X(e);return h[o.kind].exported(t,$,o)}},I=r.querySelector(".doc-header"),O=I?k(w(I)):[],q=r.querySelector("main"),L=k(q?w(q):[]),Q=Y(r).flatMap(({element:e,clipboard:t})=>["",...h[t.kind].exported(e,$,t)]);return[`# ${u||"Untitled"}`,...O.length?["",...O]:[],...L.length?["",...L]:[],...Q].join(`
|
|
5
5
|
`)}import{saying as lt}from"../browser/shared/i18n/index.mjs";import{referencedFile as pt}from"../browser/shared/media.mjs";var ft=r=>`\0F${r}\0`,mt=r=>`\0C${r}\0`,dt={async markdown({source:r,title:u,pictures:f}){let{document:d}=await W(r),g=[],n=[...d.querySelectorAll("main figure.doc-figure")];return{text:await K(d,{title:u,media:(c,m,p)=>{let i=pt(c);return i?ft(g.push({src:i,kind:m,name:p})-1):c},chart:c=>f&&n.includes(c)?mt(n.indexOf(c)):null}),files:g,charts:n.length,charted:n.map(c=>!!c.querySelector("[data-doc-chart]"))}},import:({uploads:r,scratch:u})=>B(r,u),fill:r=>H(r)};N.on("message",async({id:r,type:u,payload:f})=>{try{M(),N.postMessage({id:r,result:await dt[u](f)})}catch(d){N.postMessage({id:r,error:{...lt(d),stack:d.stack}})}});
|
package/kit/report.css
CHANGED
|
@@ -1193,10 +1193,10 @@ span.doc-link-mention-icon {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
|
|
1195
1195
|
/* A page block: the address is a document's. An empty icon is a page, as a page with none has in the
|
|
1196
|
-
workbench's tree (Lucide's file
|
|
1196
|
+
workbench's tree (Lucide's plain file outline), and the pointer lights it up as Notion's page mention, a whole to click on. */
|
|
1197
1197
|
.doc-link-mention[href]:not([href^="http" i]) > span.doc-link-mention-icon {
|
|
1198
|
-
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z'/%3E%3Cpath d='M14 2v5a1 1 0 0 0 1 1h5'/%3E%
|
|
1199
|
-
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z'/%3E%3Cpath d='M14 2v5a1 1 0 0 0 1 1h5'/%3E%
|
|
1198
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z'/%3E%3Cpath d='M14 2v5a1 1 0 0 0 1 1h5'/%3E%3C/svg%3E");
|
|
1199
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z'/%3E%3Cpath d='M14 2v5a1 1 0 0 0 1 1h5'/%3E%3C/svg%3E");
|
|
1200
1200
|
}
|
|
1201
1201
|
.doc-link-mention[href]:not([href^="http" i]):hover {
|
|
1202
1202
|
border-radius: 1px;
|
package/kit/runtime.js
CHANGED
|
@@ -1392,6 +1392,16 @@ ${indent}${list2 ? "]" : "}"}`;
|
|
|
1392
1392
|
};
|
|
1393
1393
|
}
|
|
1394
1394
|
|
|
1395
|
+
// src/shared/workspace-address.mjs
|
|
1396
|
+
var PROJECT = /^(\/~(ws-[0-9a-f]{6}))(?=\/|$)/;
|
|
1397
|
+
var projectOfPath = (pathname) => PROJECT.exec(pathname)?.[2] ?? null;
|
|
1398
|
+
var localPath = (pathname) => pathname.replace(PROJECT, "") || "/";
|
|
1399
|
+
var currentProjectBase = () => PROJECT.exec(globalThis.location?.pathname ?? "")?.[1] ?? "";
|
|
1400
|
+
function workspaceAddress(address, base = currentProjectBase()) {
|
|
1401
|
+
if (!base || typeof address !== "string" || projectOfPath(address)) return address;
|
|
1402
|
+
return /^\/(?:__gallery\/|generated\/|pages\/)/.test(address) ? base + address : address;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1395
1405
|
// src/shared/page-links.mjs
|
|
1396
1406
|
var DOC_SLUG = /^doc-([a-z][a-z0-9]{7})$/;
|
|
1397
1407
|
function hashId(slug) {
|
|
@@ -1454,7 +1464,7 @@ ${indent}${list2 ? "]" : "}"}`;
|
|
|
1454
1464
|
if (inFile) return known(inFile[1], decoded(inFile[2] ?? ""));
|
|
1455
1465
|
const url = ownAddress(address);
|
|
1456
1466
|
if (!url) return null;
|
|
1457
|
-
const path = PAGE3.exec(url.pathname) ?? OWN_FILE.exec(url.pathname);
|
|
1467
|
+
const path = PAGE3.exec(localPath(url.pathname)) ?? OWN_FILE.exec(localPath(url.pathname));
|
|
1458
1468
|
if (path) return known(path[1], decoded(url.hash.slice(1)));
|
|
1459
1469
|
return url.pathname === "/" && url.hash.length > 1 ? hashAddress(decoded(url.hash.slice(1)), links) : null;
|
|
1460
1470
|
}
|
|
@@ -1957,7 +1967,7 @@ ${indent}${list2 ? "]" : "}"}`;
|
|
|
1957
1967
|
const detail = page ? { page } : { slug, block };
|
|
1958
1968
|
const asked = new CustomEvent(OPEN_EVENT, { cancelable: true, detail });
|
|
1959
1969
|
if (!globalThis.dispatchEvent(asked)) return;
|
|
1960
|
-
globalThis.location.assign(page ? `/pages/${page}` : `/generated/${slug}.html${block ? `#${encodeURIComponent(block)}` : ""}`);
|
|
1970
|
+
globalThis.location.assign(workspaceAddress(page ? `/pages/${page}` : `/generated/${slug}.html${block ? `#${encodeURIComponent(block)}` : ""}`));
|
|
1961
1971
|
}
|
|
1962
1972
|
};
|
|
1963
1973
|
if (place !== "export") {
|
package/kit/state.js
CHANGED
package/kit/ui.js
CHANGED
|
@@ -133,6 +133,10 @@ ${source}
|
|
|
133
133
|
var GENERATORS = [GENERATOR, "HTML Report Studio"];
|
|
134
134
|
var OWN_METAS = new RegExp(`<head\\b[^>]*>\\s*<meta name="generator" content="(?:${GENERATORS.join("|")})">\\s*<meta http-equiv="Content-Security-Policy" content="[^"]*">\\s*<meta name="${SOURCE_META}" content="sha256:([0-9a-f]{64})">(?:\\s*<meta name="${PACKAGES_META}" content="([^"]*)">)?`, "i");
|
|
135
135
|
|
|
136
|
+
// src/shared/workspace-address.mjs
|
|
137
|
+
var PROJECT = /^(\/~(ws-[0-9a-f]{6}))(?=\/|$)/;
|
|
138
|
+
var localPath = (pathname) => pathname.replace(PROJECT, "") || "/";
|
|
139
|
+
|
|
136
140
|
// src/shared/page-links.mjs
|
|
137
141
|
var DOC_SLUG = /^doc-([a-z][a-z0-9]{7})$/;
|
|
138
142
|
function hashId(slug) {
|
|
@@ -196,7 +200,7 @@ ${source}
|
|
|
196
200
|
if (inFile) return known(inFile[1], decoded(inFile[2] ?? ""));
|
|
197
201
|
const url = ownAddress(address);
|
|
198
202
|
if (!url) return null;
|
|
199
|
-
const path = PAGE.exec(url.pathname) ?? OWN_FILE.exec(url.pathname);
|
|
203
|
+
const path = PAGE.exec(localPath(url.pathname)) ?? OWN_FILE.exec(localPath(url.pathname));
|
|
200
204
|
if (path) return known(path[1], decoded(url.hash.slice(1)));
|
|
201
205
|
return url.pathname === "/" && url.hash.length > 1 ? hashAddress(decoded(url.hash.slice(1)), links) : null;
|
|
202
206
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heycys/gallery",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Gallery: documents written as HTML by an AI agent, shown and edited in the browser, delivered as one offline file. The gallery command and its local server.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gallery",
|
package/release.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heycys/gallery",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"built": "2026-11-
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"built": "2026-11-10T21:34:10.314Z",
|
|
5
5
|
"stamps": {
|
|
6
|
-
"editor": "
|
|
6
|
+
"editor": "be1ff844b4b5b768",
|
|
7
7
|
"kit": {
|
|
8
|
-
"styles": "
|
|
8
|
+
"styles": "fd4d4ec8d57ef8d1",
|
|
9
9
|
"katex-styles": "81d0a0b4dcb41846",
|
|
10
|
-
"runtime": "
|
|
10
|
+
"runtime": "0295165d44a79a92",
|
|
11
11
|
"code": "f893c8b464096161",
|
|
12
|
-
"state": "
|
|
12
|
+
"state": "81377b50855ccd0f",
|
|
13
13
|
"sheets": "fda7b7b754e01019",
|
|
14
14
|
"tokens": "a218d5d5f9008530",
|
|
15
|
-
"ui": "
|
|
15
|
+
"ui": "1666564002ba1acc",
|
|
16
16
|
"dialogs": "42866e832540bf9f",
|
|
17
17
|
"katex": "1b0a973a02ab84f0",
|
|
18
18
|
"katex-auto-render": "63e7162ddec186d6",
|
package/skill/SKILL.md
CHANGED
|
@@ -9,16 +9,16 @@ Create a self-contained HTML document whose claims, numbers, and visual encoding
|
|
|
9
9
|
|
|
10
10
|
## Before anything: the gallery command
|
|
11
11
|
|
|
12
|
-
This skill holds the instructions; the tools are the npm package `@heycys/gallery`, the `gallery` command. This skill is Gallery 0.2.
|
|
12
|
+
This skill holds the instructions; the tools are the npm package `@heycys/gallery`, the `gallery` command. This skill is Gallery 0.2.2's and needs `@heycys/gallery` ^0.2.2: a version npm's range `^0.2.2` takes, 0.2.2 or a later 0.2.x.
|
|
13
13
|
|
|
14
14
|
1. Run `gallery --version`. Its first line is the version: when it is such a version, go on to step 3. A line after it may say that something is newer; that never stops the task: say it once (the handoff will do) and go on, and update nothing without the user's yes, unless they already said in this conversation to update.
|
|
15
15
|
- `技能:<folder> …`: the Gallery skill there (this one, maybe) is older than the gallery. Tell the user so and offer to run the command the line gives (`gallery skill install`, with `--project` for a project's skill; run by `npx`, the line gives `npx -y @heycys/gallery@^<version> skill install`); after their yes, run it and tell them a new Agent session reads the new skill. Finish this task with the skill as it is.
|
|
16
16
|
- `新版本:…`: npm has a newer Gallery. Tell the user once in the conversation and offer to update; after their yes, run the line's `npm i -g …`, then `gallery skill install`, and tell them a new Agent session reads the new skill. Where you run Gallery by `npx` (no global install), the line gives `npx -y @heycys/gallery@^<its version> skill install` instead: run that after their yes, and tell them the next commands can take the newer range: `npx -y @heycys/gallery@^<its version> …`.
|
|
17
|
-
2. When `gallery` is not found, or prints a version older than `^0.2.
|
|
18
|
-
- When it prints a version newer than `^0.2.
|
|
17
|
+
2. When `gallery` is not found, or prints a version older than `^0.2.2` takes, install it with `npm i -g @heycys/gallery@^0.2.2`, then run `gallery --version` again. When the user has already said to install it (in this request or earlier in the conversation), run it without asking again; otherwise ask the user before you install anything: say that Gallery's command is missing (or which version it is) and that you would run that command, and run it once they agree.
|
|
18
|
+
- When it prints a version newer than `^0.2.2` takes, install nothing (that would take Gallery back to an older version): this skill is older than their Gallery. Tell the user and offer to run `gallery skill install` (with `--project` when the skill is the project's, in its `.claude/skills/`; a `技能:` line gives it); after their yes, run it and ask them to start a new Agent session, which reads the new skill.
|
|
19
19
|
- No Node, or `node --version` older than 22.13: tell the user to install the current LTS from https://nodejs.org (or with their system's package manager), then start again.
|
|
20
|
-
- npm says `EACCES` (macOS and Linux, where npm's global folder belongs to the system): never use `sudo`. Tell the user, and offer either of these: give npm a folder of their own (`npm config set prefix ~/.npm-global`, add `~/.npm-global/bin` to `PATH` in their shell profile, open a new terminal, install again); or run every command as `npx -y @heycys/gallery@^0.2.
|
|
21
|
-
- Use `npx -y @heycys/gallery@^0.2.
|
|
20
|
+
- npm says `EACCES` (macOS and Linux, where npm's global folder belongs to the system): never use `sudo`. Tell the user, and offer either of these: give npm a folder of their own (`npm config set prefix ~/.npm-global`, add `~/.npm-global/bin` to `PATH` in their shell profile, open a new terminal, install again); or run every command as `npx -y @heycys/gallery@^0.2.2 <command> …` instead of `gallery <command> …`.
|
|
21
|
+
- Use `npx -y @heycys/gallery@^0.2.2 <command> …` likewise wherever a global install is not allowed (a sandbox, CI). It is slower: a few seconds more per command.
|
|
22
22
|
- On Windows, `gallery` works in PowerShell right after the install, in the same terminal. Only when PowerShell says running scripts is disabled (`gallery.ps1`): run `gallery.cmd` with the same arguments, or ask the user to run `Set-ExecutionPolicy -Scope CurrentUser RemoteSigned` once.
|
|
23
23
|
- After an upgrade, run `gallery open --no-browser` once: the server of the version before stops by itself, and this starts the new one. Tell the user that `gallery skill install` brings this skill to the new version too (an Agent session started after it reads it).
|
|
24
24
|
3. The documents live in a workspace, a folder: `--workspace <dir>` (every command takes it), else `GALLERY_WORKSPACE`, else the nearest folder up from the current one holding `gallery.json`, else `Gallery` in the user's Documents folder, `~/Documents/Gallery` (made on first use; on Windows the Documents folder Explorer shows, OneDrive's when OneDrive backs it up). `gallery new`, `gallery import`, `gallery list` and `gallery open` print it as `工作区:<path>`. When a command prints `Cannot write the workspace <path> (…)` (a sandbox that allows writes only in the project, or a system that has not let the terminal into Documents), ask the user to allow Gallery to write there, or pass `--workspace <a folder in the project>` to every command.
|
|
@@ -27,7 +27,7 @@ This skill holds the instructions; the tools are the npm package `@heycys/galler
|
|
|
27
27
|
4. The browser service: `gallery new` and `gallery import` start the workspace's local server (or use the one running) and open the user's browser at the document, `gallery open [<slug>]` starts or reuses it and opens the user's browser (each takes `--no-browser`: the address without a tab), and each prints the address on its `交给用户` line: give it to the user all the same (the browser opened may not be Chrome or Edge, or not in front of them). Editing in the browser and `gallery qa` need Chrome or Edge. In a cloud sandbox the user cannot reach (`127.0.0.1` there is not their computer), skip the address: hand over the exported file instead. `gallery stop` stops the server (`Stopped the server on port …`, or `No Gallery server runs for <workspace>.`).
|
|
28
28
|
5. Every command but `gallery serve` returns by itself, the server's included (it runs on after the command; `gallery serve` runs it in the foreground, for the user's own terminal: you start it with `gallery open --no-browser`): run each in the foreground, with no `timeout` wrapper, background job or `Start-Process`. When you ask the user to allow commands, `gallery *` covers them all (`gallery.cmd *` in PowerShell). In Windows PowerShell 5.1, give a command no `2>&1` (it makes its warnings errors) and read files with the file tool or `Get-Content -Encoding UTF8`. Resolve `references/` and `sdk/` from the folder holding this `SKILL.md`.
|
|
29
29
|
|
|
30
|
-
**写作偏好** (`<
|
|
30
|
+
**写作偏好** (`<home>/preferences.md`) holds the user's rules for writing a document: what to write and in what order, the opening summary, titles, fidelity to the materials, evidence and data. Read it before you write and follow it. When instructions differ, the user's request comes first, then 写作偏好, then this skill. Only the user changes 写作偏好: never edit it unless asked, and never write `"instructions": true` in a document's `doc.json` (it marks the page holding 写作偏好). Where 写作偏好 says `report.json`, a document made by Gallery 0.1 or later has `doc.json`; an older one keeps `report.json`.
|
|
31
31
|
|
|
32
32
|
A document has one writer at a time: never let two Agents, or an Agent and a script, write the same `doc.html` at once. The user may edit it in the browser meanwhile; Gallery merges their edits with yours.
|
|
33
33
|
|
|
@@ -35,7 +35,7 @@ A document is the folder `<workspace>/<slug>/`: `doc.html`, the page you write,
|
|
|
35
35
|
|
|
36
36
|
## Workflow
|
|
37
37
|
|
|
38
|
-
1. Read 写作偏好 before anything else (for a document: a custom page has none, [Custom pages](#custom-pages-自定义页)). When `<
|
|
38
|
+
1. Read 写作偏好 before anything else (for a document: a custom page has none, [Custom pages](#custom-pages-自定义页)). When `<home>/preferences.md` is not there yet, `gallery new` (step 2) makes it from Gallery's defaults and prints its path (`gallery import` and `gallery list` print it too; `gallery open` does not): read it then, before you write. When `gallery new` prints `写作偏好:空`, the user emptied it: write from the request, this skill and the materials, and leave the file as it is.
|
|
39
39
|
2. Create the document as soon as you know its title: `gallery new <slug> "<title>" "<description>"` (a lowercase kebab-case slug).
|
|
40
40
|
- Its place in the sidebar's tree: [Organizing documents](#organizing-documents) (`--under` or `--after` where the user says).
|
|
41
41
|
- It prints where it wrote, the workspace, the path of 写作偏好 and the next steps, starts the browser service (or uses the one running), and ends with its `交给用户` line: the address where the user watches and edits the document (step 3). The line before it, the page alone, is yours.
|
|
@@ -108,7 +108,7 @@ Paths are absolute, as this system writes them: use them as they are.
|
|
|
108
108
|
|
|
109
109
|
When the user names a document by its title or topic, find it with `gallery list <words>` (words of its title or topic; those whose title, description or slug holds them come first, then those whose text does, with `正文:` and the first place; `gallery list` alone lists every document, the one edited last first): it prints each document's slug, title, description, place in the tree, address, last edit and file. A search of the `doc.html` files themselves (grep) is fine too. An address the user gives (`http://127.0.0.1:<port>/#<title words>-<page id>`, the workbench's address bar or 复制块链接, `/<block id>` after it for a block) names its document by the id at its end, and the words before it may be out of date: `gallery list <address>` prints that document, or says it is in the trash, and every command that takes a slug takes the address, or the link after its `#`, as well. The id comes from the folder's name, so an address from another workspace can name this workspace's folder of that name: before you change anything, compare the title `gallery list <address>` prints, and its `工作区:` line, with what the user means. A path the user gives (the workbench's 复制本地路径 copies one) is that document's `doc.html`; its folder's name is its slug, the folder holding it the workspace (pass it as `--workspace` when it is not the one the commands find).
|
|
110
110
|
|
|
111
|
-
Before you change anything, run `gallery open <slug> --no-browser` and give the user the address on its `交给用户` line, even when they say the page is open: it reuses the running server without opening another tab, and it keeps the document as it stands so that the first `gallery qa` pictures what you change. It prints no `写作偏好` line: read `<
|
|
111
|
+
Before you change anything, run `gallery open <slug> --no-browser` and give the user the address on its `交给用户` line, even when they say the page is open: it reuses the running server without opening another tab, and it keeps the document as it stands so that the first `gallery qa` pictures what you change. It prints no `写作偏好` line: read `<home>/preferences.md` before you change anything.
|
|
112
112
|
|
|
113
113
|
A long `doc.html` may not fit one read: map it first with a search of its headings and ids (`<h2`, `<h3`, `data-block-id`, with line numbers), then read the part you change by its lines. Right before each change, re-read the part you change and replace only it; never rewrite the whole file from an earlier read or regenerate it with a script. A script may read the file at that moment, replace several exact spans, each found once in it, and write it once (its read is the re-read); it stops without writing when a span is missing or repeated. Write it for Node (`node`), which Gallery runs on and so is always there: `python` may be missing, or a stub that runs nothing and says nothing (Windows' app alias). Keep the start tag of each block you change: its `data-block-id`, `style` and classes may be the user's edits.
|
|
114
114
|
|
|
@@ -132,7 +132,8 @@ The workbench's sidebar shows the documents as a tree: a document may sit under
|
|
|
132
132
|
- A new document goes where the user says: `gallery new <slug> "<title>" "<description>" --under <document>` (last under it; `--first`, first) or `--after <document>` (right after it, at its level). When they name no place, run `gallery list --tree` first when the workspace has documents, and put it under the document whose topic it belongs to (a week's notes under their project); at the top level when none fits. Say in the handoff where it went.
|
|
133
133
|
- Move documents only when the user asks you to organize them: `gallery move <document> --under <document>` (or `--top`), `--after <document>` or `--first` for its place there, each with the documents under it. No file changes, and links between documents still work. Name every move in the handoff.
|
|
134
134
|
- The sidebar lists custom pages (自定义页) too, among 新建 and 搜索 in the order the user drags them to: pages, not documents ([Custom pages](#custom-pages-自定义页)). A page's slug and a document's are one set: `gallery new` refuses a page's, `gallery page new` a document's.
|
|
135
|
-
-
|
|
135
|
+
- One Gallery service per user data directory serves all registered document folders. Their documents, manual links, order and hierarchy share the default workspace’s tree; files stay with their owner. Reorder within a folder; crossing folders confirms a copy, including descendants. Extensions, pages, blocks and writing preferences belong only to the default workspace. For extension tasks, run `gallery extension list` and read the listed AGENT.md first.
|
|
136
|
+
- Web links: `gallery link add <url> "<name>"` (`--column`, `--under`, `--after`, `--first` choose the place); `gallery link set` edits, `gallery link remove` removes. `gallery list --tree` shows them. Links have no check/export/search; Gallery’s own server URLs are refused (link the document). Report their place (`位置:`) in the handoff.
|
|
136
137
|
- Change a document's title, page icon or description with `gallery set <document> --title "…" --icon <emoji, or none> --description "…"` (any of them): it writes the header of `doc.html` and `doc.json` in step, and the open page and the sidebar show it. Never edit `doc.json`'s title or icon, or the header, by hand for that. Re-read `doc.html` after it before you edit it.
|
|
137
138
|
|
|
138
139
|
## Custom pages (自定义页)
|
|
@@ -153,7 +154,7 @@ A custom page is the user's own page in the workbench's sidebar, yours to design
|
|
|
153
154
|
|
|
154
155
|
## Output contract
|
|
155
156
|
|
|
156
|
-
- `<workspace>/<slug>/doc.html` and `doc.json` are the editable sources; what Gallery keeps of its own is under `<workspace>/.gallery/`, never yours to edit; `<
|
|
157
|
+
- `<workspace>/<slug>/doc.html` and `doc.json` are the editable sources; what Gallery keeps of its own is under `<workspace>/.gallery/`, never yours to edit; `<home>/components/` holds custom blocks (自定义块: their files keep the word component, `component.json` and `data-doc-component`), no document, and is no slug a new document can take; `<home>/pages/` holds the custom pages ([Custom pages](#custom-pages-自定义页)), each with its own files in its `assets/`; `<workspace>/exports/<slug>.html` is the offline, single-file deliverable. Re-export after the last source edit. In the handoff the clickable HTML is the export or a verified byte-identical copy of it, never a source or a page of the local server.
|
|
157
158
|
- Everything document-specific (data, visuals, styles, scripts) stays in `doc.html` and its `assets/`. Gallery's shared kit (its blocks, styles and `sdk/` types) is not yours to change; the workspace's custom blocks are. A document uses the kit's blocks and whole blocks. A document's own script cannot write the file: a control that must keep what a reader enters (a ledger, a checklist, a form) is a custom block's data part (`gallery block new <id> --data`), though the user does not say to use it again. Otherwise make a custom block only when the user clearly wants a block to use again, never one per document: run `gallery block list` first (Gallery's own blocks among what it lists, each added as it ships by `gallery block add <name>`), then read [references/building-blocks.md](references/building-blocks.md) (a block with a script: [references/block-script.md](references/block-script.md); one that reads the workspace, a table or the web: [references/pages-and-data.md](references/pages-and-data.md)). `gallery component …` is another name for `gallery block …`. When the user wants a document that uses it too, create that document first, even when they say to make the block first: Workflow steps 1–3 (`gallery new`, the address sent), then its skeleton with the heading of the section the instance goes in. Then make the block, and write the instance into its section last. An instance of a block `gallery block list` gives under 文档里可用 is written as `gallery block show <id>` prints.
|
|
158
159
|
|
|
159
160
|
## Handoff
|
|
@@ -172,12 +173,12 @@ Before you hand over, do the review 写作偏好 asks for before handing in (a r
|
|
|
172
173
|
|
|
173
174
|
| Need | Read |
|
|
174
175
|
| --- | --- |
|
|
175
|
-
| The user's rules for writing: what to write, the opening summary, titles, fidelity, evidence and data | 写作偏好, `<
|
|
176
|
+
| The user's rules for writing: what to write, the opening summary, titles, fidelity, evidence and data | 写作偏好, `<home>/preferences.md` |
|
|
176
177
|
| How a block is written | [references/example-report.html](references/example-report.html) |
|
|
177
178
|
| The rules behind the blocks: the page, what plain HTML becomes, figures and charts you draw yourself | [references/writing-html.md](references/writing-html.md) |
|
|
178
179
|
| A custom block (a block to use again), when the user asks for one: the block, its flow, files, manifest and instance; sharing a block pack | [references/building-blocks.md](references/building-blocks.md) |
|
|
179
180
|
| A block's script (`kit.js`) and how it writes back to the file | [references/block-script.md](references/block-script.md) |
|
|
180
181
|
| A card of a custom page (size, settings), and a block that reads the workspace's data, a table of its document or the web | [references/pages-and-data.md](references/pages-and-data.md) |
|
|
181
|
-
|
|
|
182
|
+
| Sidebar columns or workbench/backend extensions (`gallery extension new/install/list/check/remove`), when requested | [references/extensions.md](references/extensions.md) |
|
|
182
183
|
| Exact API types | `sdk/*.d.ts`, from [`sdk/index.d.ts`](sdk/index.d.ts) |
|
|
183
184
|
| What each command does and prints | `gallery help`, `gallery <command> --help` |
|
|
@@ -41,7 +41,7 @@ One block, one manifest and one `context` stand in either place; the two differ
|
|
|
41
41
|
When the user wants a document that uses the block too, the document comes first: `gallery new`, its address sent, its skeleton written (SKILL.md, Workflow steps 1–4). Then make the block as below, write the instance in its section at step 5, and try it there at step 6.
|
|
42
42
|
|
|
43
43
|
1. `gallery block list` first: what the workspace has now, in two groups by where a block may stand (文档里可用, in documents; 自定义页可用, on custom pages), each with its version, whether the menus can insert it, and what is there and cannot be used, with why; then Gallery's own blocks it has not added yet. When one does what the user asks, use it: `gallery block show <id>` prints its parts, how to write it and its example (`gallery block show gallery/<name>` does so for one of Gallery's own the workspace has not added yet, and ends with the line that adds it; `show` and `check` take its bare name too, `gallery block show heatmap`, as `add` does, a block of the workspace's own by that name staying `local/`'s). When one of Gallery's own does, `gallery block add <name>` puts it in as it ships, and it needs no check and no try (Gallery's own blocks, below).
|
|
44
|
-
2. `gallery block new <id>`: a new block in `<
|
|
44
|
+
2. `gallery block new <id>`: a new block in `<home>/components/<scope>/<name>/`, its `id` being `<scope>/<name>`, the scope `local` when you name none: the default pack (默认块包, first in 设置 › 组件列表), where a single block goes, with no pack of its own to make. It writes a block that passes the check, for you to replace. Add `--script` only when the block must do something when a reader uses it: a static block runs no code, is the one to start with, and is all most blocks need. Add `--flow` when it holds blocks of the document's own under its markup (a card around any content): a slot, `body` (Slots, below). Add `--data` for a block that keeps what a reader enters in the file, the usual reason to make one (a list of lines, a field that adds one, a button that takes one away): a data part `items` (JSON on one line, as `context.editJSON` writes it), a `kit.js` that reads it with `context.readJSON` and writes it with `context.editJSON`, a field (`DocKit.input`) and buttons hidden where nothing is written, and an `example()` that adds a line, which works on `template.html`'s empty instance as on `example.html`'s: rename the part and its fields for what the block keeps, and keep that shape. Add `--page` for a custom page's card (its places `["page"]`, a `card` of two sizes). `--data` and `--page` go together or alone, and either goes with `--script`; neither goes with `--flow` (a page has no slot, and `--data` is a part of its own), nor with `--recipe <name>`, which starts from one of Gallery's own (below). Each scaffold passes `gallery block check`, and `gallery block try` on its field (`--type .component-field "words" --then Enter`), as it is.
|
|
45
45
|
3. Write its files (below): the manifest, `template.html`, `example.html`, its style and, with `--script`, `kit.js`, then what a writer needs to know.
|
|
46
46
|
4. `gallery block check <id>`, until it prints `OK`. It says each problem at its file and line; one with no line is of that file, or of the page, as a whole. Then open `overview-light.png` and `overview-dark.png` in the folder it prints, each the pictures of 360, 736 and 1024px wide of a theme side by side, `example.html` above the line and `template.html` below it, then at full size each width where they show something to fix, and `edit-1024-light.png` and `edit-360-light.png`, as the editing page draws it, `context.canEdit()` true: what the block draws only where a reader can edit (a handle, a button), which an export leaves out. A block that draws nothing more there gives the export's pictures again, and the check says so. It has run them and looked at nothing for you: a `Not opened yet: …` line right before the verdict lists every picture of the run in one place, as `gallery qa`'s does: count by it. In the handoff name the pictures you opened. A block with a data part whose export (`1024-light.png`, where `context.canEdit()` is false) still shows an enabled button, field, select or textarea gets a note: a control that writes is drawn hidden there, which you see by comparing that picture with `edit-1024-light.png`.
|
|
47
47
|
5. Use it where the user asked: in a document, write the element as `example.html` does (when the user wants no document, in one of its own made with `gallery new`, named in the handoff: step 6 tries the block there). The user finds it in "/" under its name. `gallery export <slug>` exports it as any block, and `gallery qa <slug>` pictures it among the cards. Around an instance, the document's words say what the block is and where its data comes from. A value that a reader's gesture changes (a count by column, a status, a score, a total) goes in the document's words only with when it held ("截至 11 月 5 日,…"), as an opening summary may need it; otherwise point to the block, which shows it as it is now. How to use the block on the editing page (drag a card, press a dot) goes in the handoff and in writing.md, not in the document: its export and PDF show the block read-only. Then `gallery block check <id> --documents`: it runs each instance the workspace's documents hold as step 4 runs the example, a section for each document, each problem at its line of the document's file (`board/doc.html:15`), the pictures in `documents/<slug>/` of the folder it prints, so that an instance filled otherwise than the example (a long title, an empty table) is tried as the reader's page runs it. It writes no document.
|