@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.
Files changed (144) hide show
  1. package/THIRD-PARTY-NOTICES.md +1 -1
  2. package/browser/editor/components/icon/page.mjs +6 -4
  3. package/browser/editor/components/icons.mjs +2 -2
  4. package/browser/editor/page/annotate/index.mjs +3 -2
  5. package/browser/editor/page/board/index.mjs +2 -1
  6. package/browser/editor/page/board/settings.mjs +2 -1
  7. package/browser/editor/page/clipboard/import/read.mjs +20 -2
  8. package/browser/editor/page/core.mjs +3 -2
  9. package/browser/editor/page/custom-page.mjs +4 -3
  10. package/browser/editor/page/editor.mjs +9 -5
  11. package/browser/editor/page/emoji-picker/support.mjs +3 -2
  12. package/browser/editor/page/links/index.mjs +1 -12
  13. package/browser/editor/page/links/pages.mjs +3 -2
  14. package/browser/editor/page/outline/folds.mjs +3 -0
  15. package/browser/editor/page/post.mjs +2 -1
  16. package/browser/editor/page/present-links.mjs +4 -3
  17. package/browser/editor/page/present-shell.mjs +3 -58
  18. package/browser/editor/page/session.mjs +3 -37
  19. package/browser/editor/page/storage.mjs +5 -5
  20. package/browser/shared/component-catalog.mjs +2 -2
  21. package/browser/shared/document-copy.mjs +43 -0
  22. package/browser/shared/drafts.mjs +32 -50
  23. package/browser/shared/emoji/icon-value.mjs +4 -3
  24. package/browser/shared/extension-manifest.mjs +90 -0
  25. package/browser/shared/extensions.mjs +93 -7
  26. package/browser/shared/http.mjs +1 -1
  27. package/browser/shared/i18n/en.mjs +55 -14
  28. package/browser/shared/media.mjs +2 -1
  29. package/browser/shared/outline-shape.mjs +6 -0
  30. package/browser/shared/outline.mjs +95 -10
  31. package/browser/shared/page-address.mjs +8 -15
  32. package/browser/shared/paths.mjs +2 -1
  33. package/browser/shared/preferences.mjs +3 -1
  34. package/browser/shared/preview-server.mjs +51 -63
  35. package/browser/shared/service-location.mjs +18 -0
  36. package/browser/shared/session.mjs +3 -6
  37. package/browser/shared/workspace-address.mjs +19 -0
  38. package/browser/shared/workspace-columns.mjs +12 -9
  39. package/browser/shared/workspace-registry.mjs +6 -40
  40. package/browser/shared/workspace.mjs +3 -6
  41. package/browser/shared/writing-preferences.mjs +6 -4
  42. package/dist/{chunk-W7665ZEC.mjs → chunk-236JJXWY.mjs} +2 -2
  43. package/dist/{chunk-EAIFITAV.mjs → chunk-2KAVXMKG.mjs} +1 -1
  44. package/dist/chunk-2T4PZQEP.mjs +2 -0
  45. package/dist/{chunk-HXG7EOPJ.mjs → chunk-3SKOU6OZ.mjs} +1 -1
  46. package/dist/{chunk-AR5D57ZD.mjs → chunk-3XZOA7AH.mjs} +2 -2
  47. package/dist/{chunk-UYVCQK3H.mjs → chunk-4B2TB5K2.mjs} +1 -1
  48. package/dist/{chunk-3MBRL2PM.mjs → chunk-4KUO7R2M.mjs} +8 -8
  49. package/dist/chunk-4SNV4HA5.mjs +2 -0
  50. package/dist/chunk-53XDTHTG.mjs +4 -0
  51. package/dist/chunk-5XV3YYLG.mjs +2 -0
  52. package/dist/{chunk-ZDLPUOAG.mjs → chunk-65NTKF4N.mjs} +1 -1
  53. package/dist/chunk-6GV3CBB2.mjs +2 -0
  54. package/dist/{chunk-WQDQWCX5.mjs → chunk-6L6V7YR2.mjs} +1 -1
  55. package/dist/{chunk-ITOH5EGO.mjs → chunk-6NLXUKAY.mjs} +1 -1
  56. package/dist/chunk-6Q7ASAXJ.mjs +3 -0
  57. package/dist/{chunk-7OG26PGF.mjs → chunk-6QWQXHAV.mjs} +1 -1
  58. package/dist/chunk-6XD6U3QA.mjs +5 -0
  59. package/dist/{chunk-YNAWBAYN.mjs → chunk-7EFHNQ5B.mjs} +1 -1
  60. package/dist/{chunk-OFHXGWOX.mjs → chunk-7ISBBDJR.mjs} +1 -1
  61. package/dist/{chunk-QE5RG76S.mjs → chunk-7UZUQQ7Q.mjs} +29 -24
  62. package/dist/chunk-BLNQUR5R.mjs +168 -0
  63. package/dist/chunk-BMX3VUHY.mjs +2 -0
  64. package/dist/chunk-BN7M3IN7.mjs +8 -0
  65. package/dist/{chunk-K5XATEOO.mjs → chunk-BQNTTFPL.mjs} +1 -1
  66. package/dist/chunk-C257H6IA.mjs +2 -0
  67. package/dist/chunk-CHQU37CA.mjs +2 -0
  68. package/dist/{chunk-CMA72MAG.mjs → chunk-E4IHAIJ7.mjs} +1 -1
  69. package/dist/{chunk-VS7JIGJW.mjs → chunk-E7656LR7.mjs} +1 -1
  70. package/dist/{chunk-VFX2KNHP.mjs → chunk-ECZBLQKK.mjs} +1 -1
  71. package/dist/{chunk-MN7BZL4R.mjs → chunk-ERE2BXYV.mjs} +1 -1
  72. package/dist/chunk-FFV733MA.mjs +2 -0
  73. package/dist/{chunk-AHN3NFKJ.mjs → chunk-GJJRBGMY.mjs} +1 -1
  74. package/dist/{chunk-BZ5RAF7L.mjs → chunk-GKOBB6DH.mjs} +1 -1
  75. package/dist/chunk-GMJD7ID3.mjs +2 -0
  76. package/dist/{chunk-OEXWRJME.mjs → chunk-IA2SIEJQ.mjs} +1 -1
  77. package/dist/chunk-JPG2LBQM.mjs +11 -0
  78. package/dist/{chunk-POTA2FV4.mjs → chunk-JXXHAXYH.mjs} +1 -1
  79. package/dist/{chunk-FDMAXMQA.mjs → chunk-K3JKPFL5.mjs} +1 -1
  80. package/dist/{chunk-J5PUIV3Y.mjs → chunk-KLQP46Y3.mjs} +1 -1
  81. package/dist/chunk-LMUZQK5O.mjs +2 -0
  82. package/dist/{chunk-JLTZF4LA.mjs → chunk-M4NRDYI5.mjs} +1 -1
  83. package/dist/{chunk-HPOI4ZX7.mjs → chunk-MKIBJTJZ.mjs} +1 -1
  84. package/dist/{chunk-5K44HLTZ.mjs → chunk-MNWJ4EZY.mjs} +1 -1
  85. package/dist/{chunk-FETSREUN.mjs → chunk-NHP66IWR.mjs} +1 -1
  86. package/dist/{chunk-PGDE24N5.mjs → chunk-OEIJLMPI.mjs} +1 -1
  87. package/dist/{chunk-YROX2O22.mjs → chunk-PDZR3L3C.mjs} +1 -1
  88. package/dist/{chunk-6N3PX4XX.mjs → chunk-PLB7L22J.mjs} +1 -1
  89. package/dist/{chunk-LM4XFQHZ.mjs → chunk-Q4MS6OFC.mjs} +1 -1
  90. package/dist/{chunk-7JDX4E65.mjs → chunk-Q7P3Q5YX.mjs} +1 -1
  91. package/dist/{chunk-ZHEHPMBK.mjs → chunk-QNECWMGR.mjs} +1 -1
  92. package/dist/{chunk-YI43RG4P.mjs → chunk-QP7BOHE4.mjs} +1 -1
  93. package/dist/chunk-QVGOPHOF.mjs +2 -0
  94. package/dist/{chunk-DAZL73VK.mjs → chunk-RRKJMHNX.mjs} +2 -2
  95. package/dist/chunk-S3SX3COT.mjs +20 -0
  96. package/dist/{chunk-HDWTZ763.mjs → chunk-TKWEX4FD.mjs} +2 -2
  97. package/dist/{chunk-YLPSMDIS.mjs → chunk-ULXSPX5H.mjs} +2 -2
  98. package/dist/chunk-USIHBCSW.mjs +15 -0
  99. package/dist/{chunk-TR7TWGHB.mjs → chunk-VPMRP2TL.mjs} +1 -1
  100. package/dist/{chunk-ZQS6H473.mjs → chunk-VRPVVMRB.mjs} +1 -1
  101. package/dist/{chunk-F6HVDZR4.mjs → chunk-VZ2RQ3AM.mjs} +1 -1
  102. package/dist/{chunk-R2ZDLJYT.mjs → chunk-W5NPH5UA.mjs} +1 -1
  103. package/dist/chunk-WFGPMCTZ.mjs +4 -0
  104. package/dist/chunk-XZCFPKGO.mjs +2 -0
  105. package/dist/{chunk-4OKWZY5E.mjs → chunk-YN37ZDLW.mjs} +1 -1
  106. package/dist/chunk-ZFGMJVJC.mjs +2 -0
  107. package/dist/cli.mjs +1 -1
  108. package/dist/server.mjs +1 -1
  109. package/dist/worker.mjs +1 -1
  110. package/kit/report.css +3 -3
  111. package/kit/runtime.js +12 -2
  112. package/kit/state.js +2 -0
  113. package/kit/ui.js +5 -1
  114. package/package.json +1 -1
  115. package/release.json +7 -7
  116. package/skill/SKILL.md +13 -12
  117. package/skill/references/building-blocks.md +1 -1
  118. package/skill/references/extensions.md +48 -8
  119. package/web/assets/index-FLb9jCfl.css +1 -0
  120. package/web/assets/index-czjrXVjf.js +15 -0
  121. package/web/index.html +2 -2
  122. package/dist/chunk-5XA2ZBAE.mjs +0 -8
  123. package/dist/chunk-67N2QJYT.mjs +0 -2
  124. package/dist/chunk-6KBYRA2C.mjs +0 -2
  125. package/dist/chunk-DJISHPUL.mjs +0 -3
  126. package/dist/chunk-EKNHM3P4.mjs +0 -2
  127. package/dist/chunk-EP25HDAJ.mjs +0 -2
  128. package/dist/chunk-GHOYKMQ3.mjs +0 -4
  129. package/dist/chunk-IV64FFI4.mjs +0 -2
  130. package/dist/chunk-J43Z6LSS.mjs +0 -2
  131. package/dist/chunk-JA7G53PC.mjs +0 -2
  132. package/dist/chunk-JZT7I2OJ.mjs +0 -2
  133. package/dist/chunk-L2SUIS5S.mjs +0 -2
  134. package/dist/chunk-L7UP52JO.mjs +0 -2
  135. package/dist/chunk-MTYYHM2G.mjs +0 -15
  136. package/dist/chunk-MXUBKDRO.mjs +0 -15
  137. package/dist/chunk-NAMN3RAF.mjs +0 -2
  138. package/dist/chunk-ORID3AE7.mjs +0 -166
  139. package/dist/chunk-SWUTTZCN.mjs +0 -2
  140. package/dist/chunk-U7NZI6N4.mjs +0 -4
  141. package/dist/chunk-UJQJKNGK.mjs +0 -2
  142. package/dist/chunk-ZWWC4KLF.mjs +0 -20
  143. package/web/assets/index-BM_K-Auu.css +0 -1
  144. 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{b as Q}from"./chunk-YROX2O22.mjs";import{c as _,d as z,e as B,l as G}from"./chunk-5XA2ZBAE.mjs";import"./chunk-JA7G53PC.mjs";import"./chunk-YI43RG4P.mjs";import{i as q}from"./chunk-NAMN3RAF.mjs";import{a as b,b as J}from"./chunk-JEUK3ZO7.mjs";import{a as Z}from"./chunk-AHN3NFKJ.mjs";import{a as ee}from"./chunk-MTYYHM2G.mjs";import"./chunk-ALZ6ZENZ.mjs";import"./chunk-IA4PSIMD.mjs";import{c as V,d as Y,e as M}from"./chunk-DAZL73VK.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-ITOH5EGO.mjs";import{b as W,h as X}from"./chunk-ZQS6H473.mjs";import"./chunk-GHOYKMQ3.mjs";import"./chunk-QE5RG76S.mjs";import{b as T,f as C,g as H}from"./chunk-4OZWXZE5.mjs";import"./chunk-ZTHICSSF.mjs";import{k as U}from"./chunk-6N3PX4XX.mjs";import{b as K}from"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-R2ZDLJYT.mjs";import"./chunk-VFX2KNHP.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import v from"node:fs/promises";import se from"node:os";import x from"node:path";import{IMPORT_EXT as re,kindOf as ie}from"../browser/shared/import-types.mjs";import{reportsDirectory as O}from"../browser/shared/paths.mjs";import{kebab as S}from"../browser/shared/web-links.mjs";import{documentDirectory as oe,documentFiles as E,newDocSlug as ae}from"../browser/shared/workspace.mjs";var ce=Object.values(re).flat().join(" "),j=(d,g)=>`${d} ${g}${d===1?"":"s"}`;function fe(d,g,p){let n=(f,r=g)=>(r.match(f)??[]).length,c=n(/<ol class="doc-flow"/g,p),$=n(/<li id="fn-\d+"/g,p),w=[[n(/<section class="doc-section"/g),"section"],[n(/<h[2-4][\s>]/g),"heading"],[n(/<p[\s>]/g),"paragraph"],[n(/<(?:ul|ol)[\s>]/g),"list"],[n(/<table\b/g),"table"],[n(/class="doc-math-(?:inline|block)"/g,p),"formula"],[n(/<div class="doc-code"/g),"code block"],[n(/<figure class="doc-image"/g),"picture"],[c,"flow"],[$,"footnote"]].filter(([f])=>f>0).map(([f,r])=>j(f,r)),h=(d.raws?.length??0)-c-($?1:0);return h>0&&w.push(`${j(h,"HTML block")} kept as written`),w}async function Se(d){let{positional:g,options:p}=C({options:["--no-preview","--no-browser"],argv:d}),[n,c,$]=g;if(g.length<1||g.length>3||!n)throw new T("Name the file; then the slug and the title, if you choose them.");let w=ie(n);if(!w)throw new T(`Not a kind of file gallery import takes: ${n} (${ce}).`);c!==void 0&&H(c);let h=x.resolve(n);await v.stat(h).then(i=>i.isFile(),()=>!1)||(console.error(`No such file: ${n}`),process.exit(1));let f=c!==void 0?await Q(c):null;f&&(console.error(f),process.exit(1));let r=x.basename(h),F=await v.mkdtemp(x.join(se.tmpdir(),"gallery-import-")),L,y,R;try{let i,u=[];if(w==="markdown")i=[{...await Y(h,F),from:r,children:[]}];else try{({pages:i,skipped:u}=await V([{file:h,name:r}],F))}catch(e){console.error(`${r} could not be read: ${e.message}`),process.exit(1)}i.length===0&&(console.error(`Nothing in ${r} could be read as a page${u.length?` (not taken: ${u.join(", ")})`:""}.`),process.exit(1)),$?.trim()&&(i[0]={...i[0],title:$.replace(/\s+/g," ").trim()});let I=new Map,te=ee({edits:{},reports:{},reportsDirectory:O});y=(await Z(i,{create:async(e,t,l,{lang:s})=>{let{directory:o}=await K(e,t,l,{blank:!0,lang:s});I.set(e,await v.readFile(E(o).html,"utf8"))},slugOf:(e,t)=>{if(t===0&&c!==void 0)return c;let l=S(e.title)||S(e.from?.replace(/\.[^.]+$/,"")??"")||S(r.replace(/\.[^.]+$/,""));return l?te.freeSlug(l):ae(O)},folderOf:e=>oe(e,O),fill:e=>M(e),place:(e,t)=>q(e,{parent:t})})).made;let P=[],A=(e,t)=>{P.push({page:e,depth:t});for(let l of e.children??[])A(l,t+1)};for(let e of i)A(e,0);let m=await Promise.all(P.map(async({page:e,depth:t},l)=>{let s=y[l],o=oe(s,O),a=E(o).html,k=await v.readFile(a,"utf8"),ne=(await M({source:I.get(s),nodes:e.nodes,icon:e.icon,own:e.own})).replace(/<p>\u{E000}\d+\u{E001}<\/p>/gu,""),le=X(W(k,{finish:U}).text);return{slug:s,depth:t,page:e,directory:o,htmlFile:a,made:fe(e,ne,k),readOnly:le}}));if(L={slug:y[0]},m.length===1){let[{page:e,directory:t,htmlFile:l,made:s,readOnly:o}]=m;if(console.log(`Created ${b(l)} and ${x.basename(E(t).json)} from ${r}`),console.log(`Title: ${e.title}`),console.log(`Made: ${s.length?s.join(", "):"nothing but the title"}${e.files.length?` (${j(e.files.length,"file")} in ${b(x.join(t,"assets"))})`:""}`),e.notes?.length){console.log(`Not brought as the file has it (${e.notes.length}):`);for(let a of e.notes)console.log(` ${a.line?`line ${a.line}: `:""}${a.text}`)}if(o.length){console.log(`Text the preview leaves read-only (${o.length}), by doc.html's lines as gallery check gives them:`);for(let a of o)console.log(` ${a}`)}}else{console.log(`Created ${j(m.length,"document")} from ${r} (each nested as in the file):`);for(let{slug:l,depth:s,page:o,htmlFile:a,made:k}of m)console.log(`${" ".repeat(s+1)}${l} ${o.title} ${b(a)}`),console.log(`${" ".repeat(s+2)}Made: ${k.length?k.join(", "):"nothing but the title"}${o.files.length?` (${j(o.files.length,"file")} in its assets/)`:""}`);let e=m.flatMap(({slug:l,page:s})=>(s.notes??[]).map(o=>` ${l}: ${o.line?`line ${o.line}: `:""}${o.text}`));e.length&&console.log(`Not brought as the file has it (${e.length}):
2
+ import{b as Q}from"./chunk-PDZR3L3C.mjs";import{c as _,d as z,e as B,l as G}from"./chunk-BN7M3IN7.mjs";import"./chunk-ZFGMJVJC.mjs";import"./chunk-QP7BOHE4.mjs";import{i as q}from"./chunk-GMJD7ID3.mjs";import{a as b,b as J}from"./chunk-JEUK3ZO7.mjs";import{a as Z}from"./chunk-GJJRBGMY.mjs";import{a as ee}from"./chunk-JPG2LBQM.mjs";import"./chunk-ALZ6ZENZ.mjs";import"./chunk-IA4PSIMD.mjs";import{c as V,d as Y,e as M}from"./chunk-RRKJMHNX.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import{b as W,h as X}from"./chunk-VRPVVMRB.mjs";import"./chunk-WFGPMCTZ.mjs";import"./chunk-7UZUQQ7Q.mjs";import{b as T,f as C,g as H}from"./chunk-4OZWXZE5.mjs";import"./chunk-ZTHICSSF.mjs";import{k as U}from"./chunk-PLB7L22J.mjs";import{b as K}from"./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";import v from"node:fs/promises";import se from"node:os";import x from"node:path";import{IMPORT_EXT as re,kindOf as ie}from"../browser/shared/import-types.mjs";import{reportsDirectory as O}from"../browser/shared/paths.mjs";import{kebab as S}from"../browser/shared/web-links.mjs";import{documentDirectory as oe,documentFiles as E,newDocSlug as ae}from"../browser/shared/workspace.mjs";var ce=Object.values(re).flat().join(" "),j=(d,g)=>`${d} ${g}${d===1?"":"s"}`;function fe(d,g,p){let n=(f,r=g)=>(r.match(f)??[]).length,c=n(/<ol class="doc-flow"/g,p),$=n(/<li id="fn-\d+"/g,p),w=[[n(/<section class="doc-section"/g),"section"],[n(/<h[2-4][\s>]/g),"heading"],[n(/<p[\s>]/g),"paragraph"],[n(/<(?:ul|ol)[\s>]/g),"list"],[n(/<table\b/g),"table"],[n(/class="doc-math-(?:inline|block)"/g,p),"formula"],[n(/<div class="doc-code"/g),"code block"],[n(/<figure class="doc-image"/g),"picture"],[c,"flow"],[$,"footnote"]].filter(([f])=>f>0).map(([f,r])=>j(f,r)),h=(d.raws?.length??0)-c-($?1:0);return h>0&&w.push(`${j(h,"HTML block")} kept as written`),w}async function Se(d){let{positional:g,options:p}=C({options:["--no-preview","--no-browser"],argv:d}),[n,c,$]=g;if(g.length<1||g.length>3||!n)throw new T("Name the file; then the slug and the title, if you choose them.");let w=ie(n);if(!w)throw new T(`Not a kind of file gallery import takes: ${n} (${ce}).`);c!==void 0&&H(c);let h=x.resolve(n);await v.stat(h).then(i=>i.isFile(),()=>!1)||(console.error(`No such file: ${n}`),process.exit(1));let f=c!==void 0?await Q(c):null;f&&(console.error(f),process.exit(1));let r=x.basename(h),F=await v.mkdtemp(x.join(se.tmpdir(),"gallery-import-")),L,y,R;try{let i,u=[];if(w==="markdown")i=[{...await Y(h,F),from:r,children:[]}];else try{({pages:i,skipped:u}=await V([{file:h,name:r}],F))}catch(e){console.error(`${r} could not be read: ${e.message}`),process.exit(1)}i.length===0&&(console.error(`Nothing in ${r} could be read as a page${u.length?` (not taken: ${u.join(", ")})`:""}.`),process.exit(1)),$?.trim()&&(i[0]={...i[0],title:$.replace(/\s+/g," ").trim()});let I=new Map,te=ee({edits:{},reports:{},reportsDirectory:O});y=(await Z(i,{create:async(e,t,l,{lang:s})=>{let{directory:o}=await K(e,t,l,{blank:!0,lang:s});I.set(e,await v.readFile(E(o).html,"utf8"))},slugOf:(e,t)=>{if(t===0&&c!==void 0)return c;let l=S(e.title)||S(e.from?.replace(/\.[^.]+$/,"")??"")||S(r.replace(/\.[^.]+$/,""));return l?te.freeSlug(l):ae(O)},folderOf:e=>oe(e,O),fill:e=>M(e),place:(e,t)=>q(e,{parent:t})})).made;let P=[],A=(e,t)=>{P.push({page:e,depth:t});for(let l of e.children??[])A(l,t+1)};for(let e of i)A(e,0);let m=await Promise.all(P.map(async({page:e,depth:t},l)=>{let s=y[l],o=oe(s,O),a=E(o).html,k=await v.readFile(a,"utf8"),ne=(await M({source:I.get(s),nodes:e.nodes,icon:e.icon,own:e.own})).replace(/<p>\u{E000}\d+\u{E001}<\/p>/gu,""),le=X(W(k,{finish:U}).text);return{slug:s,depth:t,page:e,directory:o,htmlFile:a,made:fe(e,ne,k),readOnly:le}}));if(L={slug:y[0]},m.length===1){let[{page:e,directory:t,htmlFile:l,made:s,readOnly:o}]=m;if(console.log(`Created ${b(l)} and ${x.basename(E(t).json)} from ${r}`),console.log(`Title: ${e.title}`),console.log(`Made: ${s.length?s.join(", "):"nothing but the title"}${e.files.length?` (${j(e.files.length,"file")} in ${b(x.join(t,"assets"))})`:""}`),e.notes?.length){console.log(`Not brought as the file has it (${e.notes.length}):`);for(let a of e.notes)console.log(` ${a.line?`line ${a.line}: `:""}${a.text}`)}if(o.length){console.log(`Text the preview leaves read-only (${o.length}), by doc.html's lines as gallery check gives them:`);for(let a of o)console.log(` ${a}`)}}else{console.log(`Created ${j(m.length,"document")} from ${r} (each nested as in the file):`);for(let{slug:l,depth:s,page:o,htmlFile:a,made:k}of m)console.log(`${" ".repeat(s+1)}${l} ${o.title} ${b(a)}`),console.log(`${" ".repeat(s+2)}Made: ${k.length?k.join(", "):"nothing but the title"}${o.files.length?` (${j(o.files.length,"file")} in its assets/)`:""}`);let e=m.flatMap(({slug:l,page:s})=>(s.notes??[]).map(o=>` ${l}: ${o.line?`line ${o.line}: `:""}${o.text}`));e.length&&console.log(`Not brought as the file has it (${e.length}):
3
3
  ${e.join(`
4
4
  `)}`);let t=m.flatMap(({slug:l,readOnly:s})=>s.map(o=>` ${l}: ${o}`));t.length&&console.log(`Text the preview leaves read-only (${t.length}), by doc.html's lines as gallery check gives them:
5
5
  ${t.join(`
@@ -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{d as v}from"./chunk-2OHANJ6Q.mjs";import t from"node:fs/promises";import a from"node:path";import{randomBytes as F}from"node:crypto";import{defaultWorkspace as k,layoutOf as M}from"../browser/shared/workspace.mjs";import{withOutlineLock as L}from"../browser/shared/outline.mjs";import{extensionDirectory as P,extensionPath as x,forgetExtensionGrant as z,readManifest as O}from"../browser/shared/extension-manifest.mjs";import{findPreviewServer as T}from"../browser/shared/preview-server.mjs";var b=100*1024*1024,B=1e4;async function I(e,p){let c=await T({answering:!0});if(!c)return null;let n=`http://127.0.0.1:${c.port}`,o=await fetch(`${n}/__gallery/extensions/${e}`,{method:"POST",headers:{Origin:n,"Content-Type":"application/json","X-Gallery-Token":c.token},body:JSON.stringify(p)}),y=await o.json();if(!o.ok)throw new Error(y.message??"\u6269\u5C55\u64CD\u4F5C\u5931\u8D25");return y}async function N(e,{inService:p=!1,beforeReplace:c=async()=>{}}={}){if(e=a.resolve(e),!p){let s=await I("install",{path:e});if(s)return s.installed}let n=M(k()).extensions;if(await t.mkdir(n,{recursive:!0}),(await t.lstat(n)).isSymbolicLink())throw new Error("\u6269\u5C55\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");let o=await t.mkdtemp(a.join(n,".install-")),y=0,Z=0,d=s=>{if(y+=s,++Z>B||y>b)throw new Error("\u6269\u5C55\u8D85\u8FC7 100MB \u6216 10000 \u4E2A\u6587\u4EF6")};try{let s=await t.lstat(e);if(s.isSymbolicLink())throw new Error("\u5B89\u88C5\u6E90\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");if(s.isDirectory()){let r=async(f,u)=>{for(let w of await t.readdir(f,{withFileTypes:!0})){x(w.name);let i=a.join(f,w.name),m=a.join(u,w.name);if(w.isDirectory())d(0),await t.mkdir(m),await r(i,m);else if(w.isFile())d((await t.stat(i)).size),await t.copyFile(i,m);else throw new Error("\u6269\u5C55\u53EA\u80FD\u5305\u542B\u666E\u901A\u6587\u4EF6\u548C\u6587\u4EF6\u5939")}};await r(e,o)}else if(s.isFile()&&e.toLowerCase().endsWith(".zip")){if(s.size>b)throw new Error("\u6269\u5C55 ZIP \u8D85\u8FC7 100MB");let r=v(e);try{let f=new Set,u=r.entries.find(i=>i.name==="extension.json")??r.entries.find(i=>/^[^/]+\/extension.json$/.test(i.name));if(!u)throw new Error("ZIP \u4E2D\u6CA1\u6709 extension.json");let w=u.name.slice(0,-14);for(let i of r.entries){if(x(i.name),!i.name.startsWith(w))throw new Error("ZIP \u7684\u6587\u4EF6\u5FC5\u987B\u5728\u540C\u4E00\u4E2A\u6269\u5C55\u6587\u4EF6\u5939\u5185");let m=i.name.slice(w.length),$=x(m),S=m.toLowerCase();if(f.has(S))throw new Error("ZIP \u4E2D\u5B58\u5728\u91CD\u540D\u6587\u4EF6");f.add(S),d(i.size);let j=a.join(o,...$);await t.mkdir(a.dirname(j),{recursive:!0}),await r.extract(i,j)}}finally{r.close()}}else throw new Error("\u8BF7\u9009\u62E9\u6269\u5C55\u6587\u4EF6\u5939\u6216 ZIP");let E=await O(o),h=E.id??a.basename(e).replace(/\.zip$/i,""),l=P(h),g=a.join(n,`.old-${F(8).toString("hex")}`);return await c(h),await L(k(),async()=>{let r=await t.lstat(l).catch(()=>null);if(r?.isSymbolicLink())throw new Error("\u5DF2\u5B89\u88C5\u7684\u6269\u5C55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");await z(h),r&&await t.rename(l,g);try{await t.rename(o,l)}catch(f){throw r&&await t.rename(g,l),f}r&&await t.rm(g,{recursive:!0,force:!0})}),{id:h,folder:l,agent:E.agent?a.join(l,E.agent):null}}finally{await t.rm(o,{recursive:!0,force:!0})}}async function Y(e,{inService:p=!1,beforeReplace:c=async()=>{}}={}){if(!p&&await I("remove",{id:e}))return;let n=P(e);if((await t.lstat(a.dirname(n))).isSymbolicLink())throw new Error("\u6269\u5C55\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");await c(e),await L(k(),async()=>{if((await t.lstat(n)).isSymbolicLink())throw new Error("\u6269\u5C55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");await z(e),await t.rm(n,{recursive:!0})})}export{N as a,Y as b};
@@ -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{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q}from"./chunk-MXUBKDRO.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{h as buildReports,d as checkReports,f as checkSelectedReports,b as exportFailures,k as exportReports,p as failureSummary,e as handInBlockers,l as notesByKind,m as notesOf,j as offlineReports,o as printFailures,c as quickFailures,a as repeatedIdFailures,q as reportFailures,n as reportNotes,i as withExportPolicy,g as writeSharedAssets};
2
+ import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q}from"./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-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{h as buildReports,d as checkReports,f as checkSelectedReports,b as exportFailures,k as exportReports,p as failureSummary,e as handInBlockers,l as notesByKind,m as notesOf,j as offlineReports,o as printFailures,c as quickFailures,a as repeatedIdFailures,q as reportFailures,n as reportNotes,i as withExportPolicy,g as writeSharedAssets};
@@ -1,4 +1,4 @@
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 U,b as Z,c as ot,d as q}from"./chunk-R2ZDLJYT.mjs";import{e as L}from"./chunk-VFX2KNHP.mjs";import{D as nt,a as _,b as V,l as tt,m as D,o as et}from"./chunk-VS7JIGJW.mjs";import{b as J,c as P,e as Q}from"./chunk-A55HN5OK.mjs";import{IDENTITY as Ne}from"../browser/editor/components/registry.mjs";function gt(e){let{blocks:a,locks:r,units:n,boxes:c}=L(e),l=wt(e,[...a.map(t=>({at:t.innerStart-1,text:` data-ge-block="${t.id}"`})),...r.map(t=>({at:t.at,text:` data-ge-lock="${t.reason}"`})),...n.map(t=>({at:t.at,text:` data-ge-unit="${t.id}"${t.grid?" data-ge-grid":""}${t.keep?` data-ge-keep="${t.keep.reason}"${t.keep.own?" data-ge-keep-own":""}`:""}`})),...n.filter(t=>t.lead!==null).map(t=>({at:t.lead,text:` data-ge-lead="${t.id}"`})),...c.map(t=>({at:t.at,text:` data-ge-box="${t.id}"${t.pure?" data-ge-pure":""}`}))]),p={version:_(e),blocks:a.map(t=>({id:t.id,tag:t.tag,kind:t.kind,caps:Object.keys(t.caps),inner:e.slice(t.innerStart,t.innerEnd),atoms:t.atoms,unit:t.unit,...t.path?{path:t.path}:{},...t.self!==null?{self:!0}:{}})),units:n.map(t=>({id:t.id,kind:t.kind,parent:t.parent,hash:D(e,t),...t.blockId?{blockId:t.blockId}:{},...t.keep?{keep:t.keep}:{},...t.grid?{grid:!0}:{},...t.parts?{parts:t.parts}:{}})),boxes:c.map(t=>({id:t.id,kind:t.kind,unit:t.unit,...t.key!==null?{key:t.key}:{}}))};return{html:l,map:p}}function wt(e,a,r=!0){let n=[],c=0;for(let l of[...a].sort((p,t)=>p.at-t.at)){if(e[l.at]!==">"){if(r)throw new Error(`Unexpected start tag before offset ${l.at}.`);continue}let p=et(e,l.at);n.push(e.slice(c,p),l.text),c=p}return n.push(e.slice(c)),n.join("")}Q();import{COMPONENTS as kt,instancesOf as xt,partOf as st}from"../browser/shared/components/index.mjs";import{attr as rt}from"../browser/shared/html-tree.mjs";var at=new Set(["main","section","article","aside","nav","header","footer","div","details","dialog","figure","blockquote","table","ul","ol","dl"]),Nt=new Set(["script","style","template","textarea","title","xmp","iframe","noembed","noframes","noscript","plaintext","pre","code","kbd","samp","var","svg","math"]),It=kt.filter(e=>e.match&&e.pairs);function Ot(e){let a=e.replace(/^/," "),r=J(a,{sourceCodeLocationInfo:!0}),n=f=>a.slice(0,f).split(`
2
+ import{a as U,b as Z,c as ot,d as q}from"./chunk-W5NPH5UA.mjs";import{e as L}from"./chunk-ECZBLQKK.mjs";import{D as nt,a as _,b as V,l as tt,m as D,o as et}from"./chunk-E7656LR7.mjs";import{b as J,c as P,e as Q}from"./chunk-A55HN5OK.mjs";import{IDENTITY as Ne}from"../browser/editor/components/registry.mjs";function gt(e){let{blocks:a,locks:r,units:n,boxes:c}=L(e),l=wt(e,[...a.map(t=>({at:t.innerStart-1,text:` data-ge-block="${t.id}"`})),...r.map(t=>({at:t.at,text:` data-ge-lock="${t.reason}"`})),...n.map(t=>({at:t.at,text:` data-ge-unit="${t.id}"${t.grid?" data-ge-grid":""}${t.keep?` data-ge-keep="${t.keep.reason}"${t.keep.own?" data-ge-keep-own":""}`:""}`})),...n.filter(t=>t.lead!==null).map(t=>({at:t.lead,text:` data-ge-lead="${t.id}"`})),...c.map(t=>({at:t.at,text:` data-ge-box="${t.id}"${t.pure?" data-ge-pure":""}`}))]),p={version:_(e),blocks:a.map(t=>({id:t.id,tag:t.tag,kind:t.kind,caps:Object.keys(t.caps),inner:e.slice(t.innerStart,t.innerEnd),atoms:t.atoms,unit:t.unit,...t.path?{path:t.path}:{},...t.self!==null?{self:!0}:{}})),units:n.map(t=>({id:t.id,kind:t.kind,parent:t.parent,hash:D(e,t),...t.blockId?{blockId:t.blockId}:{},...t.keep?{keep:t.keep}:{},...t.grid?{grid:!0}:{},...t.parts?{parts:t.parts}:{}})),boxes:c.map(t=>({id:t.id,kind:t.kind,unit:t.unit,...t.key!==null?{key:t.key}:{}}))};return{html:l,map:p}}function wt(e,a,r=!0){let n=[],c=0;for(let l of[...a].sort((p,t)=>p.at-t.at)){if(e[l.at]!==">"){if(r)throw new Error(`Unexpected start tag before offset ${l.at}.`);continue}let p=et(e,l.at);n.push(e.slice(c,p),l.text),c=p}return n.push(e.slice(c)),n.join("")}Q();import{COMPONENTS as kt,instancesOf as xt,partOf as st}from"../browser/shared/components/index.mjs";import{attr as rt}from"../browser/shared/html-tree.mjs";var at=new Set(["main","section","article","aside","nav","header","footer","div","details","dialog","figure","blockquote","table","ul","ol","dl"]),Nt=new Set(["script","style","template","textarea","title","xmp","iframe","noembed","noframes","noscript","plaintext","pre","code","kbd","samp","var","svg","math"]),It=kt.filter(e=>e.match&&e.pairs);function Ot(e){let a=e.replace(/^/," "),r=J(a,{sourceCodeLocationInfo:!0}),n=f=>a.slice(0,f).split(`
3
3
  `).length,c=[],l=(f,d,s)=>c.push({key:f,tag:a.slice(d,s).replace(/\s+/g," "),line:n(d),offset:d});V(r,"main")||l("no <main> in the file",0,0);let p=[],t=new Set,k=f=>{for(let d of f.childNodes??[]){let s=d.sourceCodeLocation;if(d.nodeName==="#comment"){s&&p.push([s.startOffset,s.endOffset]);continue}if(d.tagName){if(s?.startTag&&p.push([s.startTag.startOffset,s.startTag.endOffset]),Nt.has(d.tagName)){s&&p.push([s.startOffset,s.endOffset??a.length]);continue}s?.endTag&&t.add(s.endTag.startOffset),at.has(d.tagName)&&s?.startTag&&!s.endTag&&l(`<${d.tagName}> not closed`,s.startTag.startOffset,s.startTag.endOffset),k(d)}}};k(r),p.sort((f,d)=>f[0]-d[0]);let N="",h=0;for(let[f,d]of p)d<=h||(N+=a.slice(h,Math.max(h,f))+" ".repeat(d-Math.max(h,f)),h=d);N+=a.slice(h);for(let f of N.matchAll(/<\/([A-Za-z][A-Za-z0-9]*)[^<>]*>?/g)){let d=f[1].toLowerCase();at.has(d)&&!t.has(f.index)&&l(`</${d}> closes nothing`,f.index,f.index+f[0].length)}for(let f of It)for(let d of xt(r,f))for(let{a:s,attrA:g,b:x,attrB:A}of f.pairs){let o=st(d,f.parts[s].at).map(M=>rt(M,g)),u=st(d,f.parts[x].at).map(M=>rt(M,A)),j=M=>new Set(M).size===M.length,I=j(o)&&j(u)&&o.length===u.length&&o.every(M=>u.includes(M)),b=d.sourceCodeLocation;!I&&b&&l(`${f.id}: ${s} and ${x} do not pair`,b.startOffset,b.startTag?.endOffset??b.startOffset)}return c.sort((f,d)=>f.offset-d.offset).map(({key:f,tag:d,line:s})=>({key:f,tag:d,line:s,text:`${f} (line ${s})`}))}Q();import{treeText as z}from"../browser/shared/annotations.mjs";import{attr as F}from"../browser/shared/html-tree.mjs";var it=2e3*2e3,G=2e3,ct=50,lt=1500;function ft(e,a,r,n){let c="",l=a;for(let p of n)p.end<=l||p.start>=r||(p.start>l&&(c+=e.slice(l,p.start)),l=Math.max(l,p.end));return c+e.slice(l,r)}var dt=e=>e.replace(/\s+/g," ").trim(),bt=e=>/\S/.test(e.replace(/<!--[^]*?-->/g,"").replace(/<[^>]*>/g,"").replace(/\u0000/g,"")),pt=e=>e.companion?[{start:e.start,end:e.end},{start:e.companion.start,end:e.companion.end}]:[{start:e.start,end:e.end}];function H(e){let a=L(e),{units:r,blocks:n}=a,c=r[0]?.node??n[0]?.node??null;for(;c?.parentNode;)c=c.parentNode;let l=c?tt(e,[c]):[],p=[...r].sort((o,u)=>o.start-u.start||u.end-o.end),t=new Map,k=[];for(let o of p){for(;k.length&&k.at(-1).end<=o.start;)k.pop();t.set(o,k.at(-1)??null),k.push(o)}for(let o of r.filter(u=>u.companion)){let{start:u,end:j}=o.companion;for(let I of r){if(I===o||I.start<u||I.end>j)continue;let b=t.get(I);(!b||b.start<u)&&t.set(I,o)}}let N=new Map;for(let o of r){let u=t.get(o);u&&N.set(u,[...N.get(u)??[],o])}let h=n.find(o=>o.kind==="title")??null,f=[...r.map(o=>({unit:o,at:o.elStart})),...h?[{unit:null,at:h.start}]:[]].sort((o,u)=>o.at-u.at),d=new Map(f.map((o,u)=>[o.unit,u])),s=new Map;for(let o of r)o.blockId&&s.set(o.blockId,(s.get(o.blockId)??0)+1);let g=f.map(({unit:o})=>{if(!o){let $=dt(ft(e,h.start,h.end,l));return{unit:null,title:!0,kind:"title",key:`title\0${$}`,own:$,counts:1,parent:null,blockId:null,text:z(h.node).slice(0,G)}}let u=N.get(o)??[],j=[...u.flatMap(pt),...l].sort(($,R)=>$.start-R.start),I=dt(pt(o).map(({start:$,end:R})=>ft(e,$,R,j)).join("\0")),b=u.length>0&&!bt(I),M=t.get(o);return{unit:o,kind:o.kind,key:`${o.kind}\0${I}`,own:I,counts:b?0:1,parent:M?d.get(M):null,blockId:o.blockId,text:z(o.node).slice(0,G)}}),x=null;return{rows:g,scanned:a,ref:o=>o.title?{title:!0}:o.blockId&&s.get(o.blockId)===1?{id:o.blockId}:(x??=(()=>{let u=new Map,j=new Map;for(let{unit:I}of f){if(!I)continue;let b=D(e,I);j.set(I,{hash:b,nth:u.get(b)??0}),u.set(b,(u.get(b)??0)+1)}return j})(),x.get(o.unit))}}function St(e,a){if(e.length*a.length<=it)return Z(e,a);let r=s=>s.reduce((g,x)=>g.set(x,(g.get(x)??0)+1),new Map),[n,c]=[r(e),r(a)],l=new Map;a.forEach((s,g)=>{c.get(s)===1&&n.get(s)===1&&l.set(s,g)});let p=[];e.forEach((s,g)=>{l.has(s)&&p.push([g,l.get(s)])});let t=[],k=[];p.forEach(([,s],g)=>{let x=0,A=t.length;for(;x<A;){let o=x+A>>1;p[t[o]][1]<s?x=o+1:A=o}k[g]=x>0?t[x-1]:-1,t[x]=g});let N=[];for(let s=t.at(-1)??-1;s>=0;s=k[s])N.unshift(p[s]);let h=[],[f,d]=[0,0];for(let[s,g]of[...N,[e.length,a.length]]){if((s-f)*(g-d)<=it)for(let[x,A]of Z(e.slice(f,s),a.slice(d,g)))h.push([f+x,d+A]);s<e.length&&h.push([s,g]),[f,d]=[s+1,g+1]}return h}var ut=(e,a)=>a.nested?z(P(e.slice(a.innerStart,a.innerEnd))):z(a.node),mt=e=>e.match(/[A-Za-z0-9]+|\s+|[^A-Za-z0-9\s]/gu)?.length??0,ht=({scanned:e},a)=>(a.title?e.blocks.filter(r=>r.kind==="title"):e.blocks.filter(r=>r.unit===a.unit.id)).sort((r,n)=>r.innerStart-n.innerStart);function yt(e){let a=[],r=n=>{for(let c of n.childNodes??[])c.tagName==="tr"?a.push((c.childNodes??[]).filter(l=>l.tagName==="td"||l.tagName==="th").map(l=>z(l).replace(/\s+/g," ")).join(" \xB7 ")):c.tagName&&r(c.tagName==="template"?c.content:c)};return r(e),a.length?a.join(`
4
4
  `):z(e)}function Mt(e,a,r){let n=e[a],c=0;for(let N=n.parent;N!==null;N=e[N].parent)r(N)&&(c+=1);let l=n.title?"h1":n.unit.node.tagName,p=n.title?n.text:yt(P(n.own.replace(/\u0000/g," "))).slice(0,G),t={kind:n.kind,tag:l,depth:c,text:p},k=l==="li"?n.unit.node.parentNode:null;if((k?.tagName==="ul"||k?.tagName==="ol")&&(t.marker=k.tagName,k.tagName==="ol")){let N=(k.childNodes??[]).filter(h=>h.tagName==="li");t.number=(Number.parseInt(F(k,"start")??"1",10)||1)+N.indexOf(n.unit.node)}return t}function $t(e,a){if(e===a)return null;let r=H(e),n=H(a),[c,l]=[r.rows.map(i=>i.key),n.rows.map(i=>i.key)],p=St(c,l);if(p.length===c.length&&p.length===l.length)return null;let t=i=>{let w=new Map;for(let S of i)S.blockId&&w.set(S.blockId,(w.get(S.blockId)??0)+1);return S=>!!S.blockId&&w.get(S.blockId)===1},[k,N]=[t(r.rows),t(n.rows)],h=[],[f,d]=[0,0];for(let[i,w]of[...p,[c.length,l.length]]){let S=new Map;for(let m=d;m<w;m++)N(n.rows[m])&&S.set(n.rows[m].blockId,m);let T=[],v=d-1;for(let m=f;m<i;m++){let O=k(r.rows[m])?S.get(r.rows[m].blockId):void 0;O!==void 0&&O>v&&(T.push([m,O]),v=O)}let B=[],[y,E]=[f,d];for(let[m,O]of[...T,[i,w]]){for(;y<m;y++){let C=r.rows[y];for(let W=E;W<O;W++){let Y=n.rows[W];if(Y.kind===C.kind&&(C.title||ot(C.own,Y.own))){B.push([y,W]),E=W+1;break}}}m<i&&B.push([m,O]),[y,E]=[m+1,O+1]}B.sort((m,O)=>m[0]-O[0]),[y,E]=[f,d];for(let[m,O]of[...B,[i,w]]){for(;y<m;y++)h.push({type:"del",i:y});for(;E<O;E++)h.push({type:"ins",j:E});m<i&&h.push({type:"chg",i:m,j:O}),[y,E]=[m+1,O+1]}i<c.length&&h.push({type:"same",i,j:w}),[f,d]=[i+1,w+1]}let s=new Set(h.filter(i=>i.type==="ins").map(i=>i.j)),g=new Set(h.filter(i=>i.type==="del").map(i=>i.i)),x=(i,w)=>{let S=new Set;for(let T of w)if(i[T].counts)for(let v=i[T].parent;v!==null;v=i[v].parent)S.add(v);return T=>i[T].counts||(S.has(T)?0:1)},[A,o]=[x(n.rows,s),x(r.rows,g)],u={added:0,changed:0,removed:0},j=[],I=[],b=[],M,$=null,R=null,K=i=>{if(!$)return;let w=Math.max(0,$.rows.length-ct);b.push({...i!==null?{before:n.ref(n.rows[i])}:R!==null?{after:n.ref(n.rows[R])}:{into:"main"},count:$.count,rows:$.rows.slice(0,ct),...w?{more:w}:{}}),$=null},X=i=>g.has(i)&&r.rows[i].counts>0;for(let i of h){if(i.type==="del"){$??={count:0,rows:[]},$.count+=o(i.i),u.removed+=o(i.i),X(i.i)&&$.rows.push(Mt(r.rows,i.i,X));continue}if(K(i.j),R=i.j,i.type==="ins"){let w=n.rows[i.j];u.added+=A(i.j),(w.parent===null||!s.has(w.parent))&&j.push({ref:n.ref(w)})}else if(i.type==="chg"){let[w,S]=[r.rows[i.i],n.rows[i.j]];u.changed+=1;let T=ht(r,w),v=ht(n,S),B=[],y=T.length!==v.length||T.length===0||T.some((E,m)=>E.tag!==v[m].tag);y||(T.forEach((E,m)=>{let[O,C]=[ut(e,E),ut(a,v[m])];mt(O)>lt||mt(C)>lt?y=!0:O!==C&&B.push({nth:m,base:O})}),B.length===0&&(y=!0)),y&&(B=[]),I.push({ref:n.ref(S),...y?{whole:!0}:{texts:B}}),S.title&&(M={base:w.text})}}return K(null),{counts:u,added:j,changed:I,...M?{title:M}:{},removed:b}}function Tt(e){let{units:a}=L(e),r=c=>{for(let l=c;l;l=l.parentNode)if(l.tagName&&(F(l,"data-doc-placeholder")!==void 0||l.tagName==="header"||(F(l,"class")??"").split(/\s+/).includes("doc-header")))return!1;return!0},n=c=>/^(img|picture|svg|canvas|video|audio|iframe|object|embed)$/.test(c.tagName??"")||(c.childNodes??[]).some(n);return!a.some(c=>r(c.node)&&(z(c.node)!==""||n(c.node)))}function jt(e,a){try{return q({current:e,ids:!0,...a}).text}catch{return e}}function Et(e,a){try{let r=L(e).blocks.find(c=>c.kind==="title");if(!r)return e;let n=U({current:e,edits:[{id:r.id,parts:[{keep:!0,html:a}]}],ids:!1});return n.ok?n.text:e}catch{return e}}var we=(e,a,r,n)=>nt.installed.rewrite(e,a,r,{packages:n});export{gt as a,Ot as b,$t as c,Tt as d,jt as e,Et as f,we as g};
@@ -0,0 +1,3 @@
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{b as D}from"./chunk-VRPVVMRB.mjs";import{g as I}from"./chunk-3SKOU6OZ.mjs";import{a as $}from"./chunk-HYMEEXKN.mjs";import{e as E,j as F}from"./chunk-ECZBLQKK.mjs";import d from"node:fs/promises";import x from"node:path";import{isInstance as T}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as _}from"../browser/shared/components/installed.mjs";import{exportSourceOf as z}from"../browser/shared/export-wrap.mjs";import{sha256 as b}from"../browser/shared/files.mjs";import{attr as w,hasClass as k}from"../browser/shared/html-tree.mjs";import{reportsDirectory as j}from"../browser/shared/paths.mjs";import{documentDirectory as G,documentFiles as H,layoutOf as B}from"../browser/shared/workspace.mjs";function K(e,t=null){return e.tagName==="figure"&&k(e,"doc-figure")||e.tagName==="div"&&(k(e,"doc-code")||k(e,"doc-diff"))||t===R||T(e)||k(e,"doc-flow")||k(e,"doc-sheet-shell")||w(e,"data-doc-sheets")!==void 0?0:e.tagName==="figure"||k(e,"doc-columns")?1:k(e,"doc-table-wrap")?2:3}function Q(e){let t=new Map,s=new Map;for(let a of E(e).units)a.blockId&&!s.has(a.blockId)&&s.set(a.blockId,a.kind);let l=new Map,n=new Map,c=new Map,i=a=>!!a.tagName&&w(a,"data-block-id")!==void 0,u=(a,f)=>{if(a.nodeName==="#text")return a.value;if(!a.tagName||a.tagName==="template")return"";let r=w(a,"data-doc-chart-data")?.trim();r&&l.get(f).push(r);let o=w(a,"data-doc-chart-source")?.trim();o&&!n.has(o)&&n.set(o,f);let h=a.attrs.map(({name:g,value:y})=>`${g}="${y}"`).sort().join(" ");return`<${a.tagName} ${h}>${(a.childNodes??[]).map(g=>i(g)?"":u(g,f)).join("")}</${a.tagName}>`},p=(a,f)=>{for(let r of a.childNodes??[]){if(!r.tagName||r.tagName==="template")continue;let o=w(r,"data-block-id"),h=f;if(o!==void 0&&!t.has(o)){let g=[r.tagName,...(w(r,"class")??"").split(/\s+/).filter(Boolean).slice(0,1)].join("."),y=c.get(f)??0;c.set(f,y+1),l.set(o,[]);let M=K(r,s.get(o)),N=r.sourceCodeLocation,U=N?(N.endOffset??N.startTag?.endOffset??N.startOffset)-N.startOffset:0,S=u(r,o).replace(L," ");t.set(o,{hash:b(S).slice(0,16),bare:b(S.replace(`data-block-id="${o}"`,"")).slice(0,16),rank:M,card:M<3,whole:s.get(o)===R,figure:s.get(o)===Y,tag:g,parent:f,at:y,size:U,package:T(r)?w(r,_)??null:null}),h=o}p(r,h)}};p($(e),null);let m=new Map([...t].map(([a,{hash:f,bare:r}])=>[a,{hash:f,bare:r}]));for(let[a,f]of l){let r=f.map(o=>m.get(n.get(o))).filter(Boolean);r.length&&(t.get(a).hash=b([m.get(a).hash,...r.map(({hash:o})=>o)].join("|")).slice(0,16),t.get(a).bare=b([m.get(a).bare,...r.map(({bare:o})=>o)].join("|")).slice(0,16))}return t}function V(e){let t=[],s=l=>{for(let n of l.childNodes??[])if(!(!n.tagName||n.tagName==="template"||w(n,"data-block-id")!==void 0))if(n.tagName==="script"||n.tagName==="style"){let c=n.attrs.map(({name:i,value:u})=>`${i}="${u}"`).sort().join(" ");t.push(`<${n.tagName} ${c}>${(n.childNodes??[]).map(i=>i.value??"").join("")}`.replace(L," "))}else s(n)};return s($(e)),t.length?b(t.join("|")).slice(0,16):""}var X=e=>Object.fromEntries(I(e).map(({id:t,stamp:s})=>[t,s])),R="block",Y="figure",L=/[ \t\n\f\r]+/g,Z=["export","preview"];function tt(e){if(e==null)return null;try{let{blocks:t,places:s,moved:l,unseen:n,from:c,time:i,idless:u,page:p,packages:m}=JSON.parse(e)??{};if(!t||typeof t!="object"||Array.isArray(t))return null;let a=s&&typeof s=="object"&&!Array.isArray(s)?s:{},f=r=>Array.isArray(r)?r.filter(o=>typeof o=="string"):[];return{blocks:Object.fromEntries(Object.entries(t).filter(([,r])=>typeof r=="string")),places:Object.fromEntries(Object.entries(a).filter(([,r])=>Array.isArray(r)&&r.length===2&&(r[0]===null||typeof r[0]=="string")&&Number.isInteger(r[1]))),moved:f(l),unseen:f(n),...Z.includes(c)?{from:c,time:Number.isFinite(i)?i:null}:{},...f(u).length?{idless:f(u)}:{},...typeof p=="string"?{page:p}:{},...m&&typeof m=="object"&&!Array.isArray(m)?{packages:Object.fromEntries(Object.entries(m).filter(([,r])=>typeof r=="string"))}:{}}}catch{return null}}var A="ge-idless-";function et(e,{from:t,time:s}){let l=0,{text:n}=F(D(e).text,()=>`${A}${l++}`),c=X(n),i={blocks:{},places:{},moved:[],unseen:[],from:t,time:s,page:V(n),...Object.keys(c).length?{packages:c}:{}},u=[];for(let[p,{hash:m,bare:a,card:f,parent:r,at:o}]of Q(n)){if(p.startsWith(A)){u.push(a);continue}i.blocks[p]=m,r?.startsWith(A)||(i.places[p]=[r,o]),f&&i.unseen.push(p)}return u.length?{...i,idless:u}:i}function bt(e,t){if(!t?.idless?.length)return t;let s=new Map;for(let c of t.idless)s.set(c,(s.get(c)??0)+1);let l={...t,blocks:{...t.blocks},unseen:[...t.unseen]};for(let[c,{hash:i,bare:u,card:p}]of e)Object.hasOwn(t.blocks,c)||!s.get(u)||(s.set(u,s.get(u)-1),l.blocks[c]=i,p&&l.unseen.push(c));let n=[...s].flatMap(([c,i])=>Array(i).fill(c));return n.length?l.idless=n:delete l.idless,l}var st=/<[^>]*\sdata-doc-placeholder\b/,O=(e,t)=>x.join(B(t).qa,e),P=(e,t)=>x.join(O(e,t),"blocks.json"),W=(e,t)=>x.join(O(e,t),"exported.html");async function q(e,t=j){return tt(await d.readFile(P(e,t),"utf8").catch(()=>null))!==null}async function C(e,t,s,l=j){let n=B(l).state,c=async o=>d.readFile(o).then(h=>({bytes:h,file:o}),()=>null),i=await c(W(e,l)),u=[i];if(t){let o=t.slice(0,16),h=x.join(n,"history",e),g=await d.readdir(h).catch(()=>[]);u.push(...await Promise.all(g.filter(y=>y.endsWith(`-${o}.html`)).map(y=>c(x.join(h,y))))),u.push(await c(x.join(n,"snapshots",`${o}.html`)))}let p=i?(await d.stat(i.file).catch(()=>null))?.mtimeMs??null:null,a=!(i&&t&&s!==null&&p!==null&&p>s&&b(i.bytes)!==t)&&t&&u.find(o=>o&&b(o.bytes)===t),f=a||i;if(!f)return null;let r=a&&s!==null?s:f===i?p??s:(await d.stat(f.file).catch(()=>null))?.mtimeMs??s;return{text:f.bytes.toString("utf8"),time:r??null}}async function v(e,t){let s=B(t).exports,l=x.join(s,`${e}.html`),[n,c]=await Promise.all([d.readFile(l,"utf8").catch(()=>null),d.stat(l).catch(()=>null)]);return n===null||!c?null:{said:z(n),time:c.mtimeMs}}async function J(e,t,s,l){if(st.test(t))return!1;let n=et(t,s);return!Object.keys(n.blocks).length&&!n.idless?!1:(await d.mkdir(O(e,l),{recursive:!0}),await d.writeFile(P(e,l),`${JSON.stringify(n)}
3
+ `),!0)}async function kt(e,t=j){let s=new Map(await Promise.all(e.map(async n=>[n,await v(n,t).catch(()=>null)])));return{keep:async(n,c=null)=>{for(let i of n)try{if(!await q(i,t)){let m=s.get(i),a=await C(i,m?.said??null,m?.time??null,t);a&&await J(i,a.text,{from:"export",time:a.time},t)}let[u,p]=await Promise.all([d.readFile(H(G(i,t)).html),c?{said:c.get(i)??null}:v(i,t)]);p?.said&&b(u)===p.said&&(await d.mkdir(O(i,t),{recursive:!0}),await d.writeFile(W(i,t),u))}catch{}}}}async function xt(e,t,s=j){try{if(await q(e,s))return!1;let l=await v(e,s),n=await C(e,l?.said??null,l?.time??null,s);return await J(e,n?.text??t,n?{from:"export",time:n.time}:{from:"preview",time:Date.now()},s)}catch{return!1}}export{K as a,Q as b,V as c,X as d,Z as e,tt as f,et as g,bt as h,q as i,C as j,kt as k,xt as l};
@@ -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{b as p,d as m}from"./chunk-2OHANJ6Q.mjs";import{q as d}from"./chunk-J5PUIV3Y.mjs";import c from"node:fs";import u from"node:os";import s from"node:path";import{refusal as o,said as t}from"../browser/shared/i18n/index.mjs";var f=64*1024*1024,l=2e3;function h(i){let r;try{r=m(i)}catch{throw o(t("{0} \u8BFB\u4E0D\u51FA\u6765\uFF1A\u4E0D\u662F\u5B8C\u597D\u7684 zip",s.basename(i)),{code:"kind"})}try{let e=r.entries;if(e.length>l||e.reduce((n,{size:a})=>n+a,0)>f)throw o(t("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",l,f/1024/1024),{code:"size"});return e.map(n=>({name:n.name,data:Buffer.from(r.read(n))}))}catch(e){throw e.code?e:o(t("{0} \u8BFB\u4E0D\u51FA\u6765\uFF1A\u4E0D\u662F\u5B8C\u597D\u7684 zip",s.basename(i)),{code:"kind"})}finally{r.close()}}function g(i){let r=s.resolve(String(i??"").trim().replace(/^"(.*)"$/,"$1")),e;try{e=c.statSync(r)}catch{throw o(t("\u627E\u4E0D\u5230 {0}",r),{code:"missing"})}if(e.isDirectory())return d(r);if(!e.isFile())throw o(t("{0} \u4E0D\u662F\u6587\u4EF6\u5939\uFF0C\u4E5F\u4E0D\u662F zip",r),{code:"kind"});let n=Buffer.alloc(4),a=c.openSync(r,"r");try{c.readSync(a,n,0,4,0)}finally{c.closeSync(a)}if(!p(n))throw o(t("{0} \u4E0D\u662F\u6587\u4EF6\u5939\uFF0C\u4E5F\u4E0D\u662F zip",r),{code:"kind"});return h(r)}function B(i){if(!p(i))throw o(t("\u9009\u7684\u6587\u4EF6\u4E0D\u662F zip"),{code:"kind"});if(i.length>f)throw o(t("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",l,f/1024/1024),{code:"size"});let r=c.mkdtempSync(s.join(u.tmpdir(),"gallery-pack-")),e=s.join(r,"pack.zip");try{return c.writeFileSync(e,i),h(e)}finally{c.rmSync(r,{recursive:!0,force:!0})}}export{g as a,B as b};
2
+ import{b as p,d as m}from"./chunk-2OHANJ6Q.mjs";import{q as d}from"./chunk-KLQP46Y3.mjs";import c from"node:fs";import u from"node:os";import s from"node:path";import{refusal as o,said as t}from"../browser/shared/i18n/index.mjs";var f=64*1024*1024,l=2e3;function h(i){let r;try{r=m(i)}catch{throw o(t("{0} \u8BFB\u4E0D\u51FA\u6765\uFF1A\u4E0D\u662F\u5B8C\u597D\u7684 zip",s.basename(i)),{code:"kind"})}try{let e=r.entries;if(e.length>l||e.reduce((n,{size:a})=>n+a,0)>f)throw o(t("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",l,f/1024/1024),{code:"size"});return e.map(n=>({name:n.name,data:Buffer.from(r.read(n))}))}catch(e){throw e.code?e:o(t("{0} \u8BFB\u4E0D\u51FA\u6765\uFF1A\u4E0D\u662F\u5B8C\u597D\u7684 zip",s.basename(i)),{code:"kind"})}finally{r.close()}}function g(i){let r=s.resolve(String(i??"").trim().replace(/^"(.*)"$/,"$1")),e;try{e=c.statSync(r)}catch{throw o(t("\u627E\u4E0D\u5230 {0}",r),{code:"missing"})}if(e.isDirectory())return d(r);if(!e.isFile())throw o(t("{0} \u4E0D\u662F\u6587\u4EF6\u5939\uFF0C\u4E5F\u4E0D\u662F zip",r),{code:"kind"});let n=Buffer.alloc(4),a=c.openSync(r,"r");try{c.readSync(a,n,0,4,0)}finally{c.closeSync(a)}if(!p(n))throw o(t("{0} \u4E0D\u662F\u6587\u4EF6\u5939\uFF0C\u4E5F\u4E0D\u662F zip",r),{code:"kind"});return h(r)}function B(i){if(!p(i))throw o(t("\u9009\u7684\u6587\u4EF6\u4E0D\u662F zip"),{code:"kind"});if(i.length>f)throw o(t("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",l,f/1024/1024),{code:"size"});let r=c.mkdtempSync(s.join(u.tmpdir(),"gallery-pack-")),e=s.join(r,"pack.zip");try{return c.writeFileSync(e,i),h(e)}finally{c.rmSync(r,{recursive:!0,force:!0})}}export{g as a,B as b};
@@ -0,0 +1,5 @@
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 $,b as u}from"./chunk-6GV3CBB2.mjs";import"./chunk-2OHANJ6Q.mjs";import{b as r,f as c}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{listCapabilities as k,readManifest as v}from"../browser/shared/extension-manifest.mjs";import x from"node:path";import d from"node:fs/promises";import{SIDEBAR_FILE as w,readSidebarText as E}from"../browser/shared/extension-sidebar.mjs";import{extensionSource as N,listExtensions as S,readExtension as I}from"../browser/shared/extensions.mjs";import{isExtensionId as y}from"../browser/shared/outline-shape.mjs";import{withOutlineLock as A}from"../browser/shared/outline.mjs";import{reportsDirectory as f}from"../browser/shared/paths.mjs";import{defaultWorkspace as p,ensureWorkspace as O,layoutOf as g}from"../browser/shared/workspace.mjs";var h=s=>`${s} ${s===1?"entry":"entries"}`;async function L(s){if(s.length>0)throw new r("list takes nothing: gallery extension check <id> reads one.");let o=await k();return S(f,{all:!0}).then(t=>{if(console.log(`Public columns: ${g(p()).extensions} (gallery extension new <id> "<title>").`),t.length===0){console.log(`No extensions visible from ${f}. Use gallery extension new <id> "<title>" (references/extensions.md says how to fill its entries).`);return}console.log(`${t.length} extension${t.length===1?"":"s"} visible from ${f}:`);for(let e of t){let n=e.missing?`no ${w}: it gives the sidebar no column`:e.error?`\u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.error.message}`:`${e.title}, ${h(e.count)}${e.notes.length?`, ${e.notes.length} note${e.notes.length===1?"":"s"}`:""}`;console.log(` ${e.id} ${n}`),console.log(` ${e.file}`);let i=o.find(a=>a.id===e.id);i?.manifest&&console.log(` Script: ${!!i.manifest.workbench?.script}; backend: ${!!i.manifest.server}; enabled: ${i.enabled}`),i?.agent&&console.log(` Agent instructions: ${i.agent}`)}console.log("gallery extension check <id> prints what the sidebar shows of one.")})}function b(s,o,t=[]){for(let e of s){let n=e.url?e.url:"(no address: a click opens and closes what is under it)";t.push(`${" ".repeat(o)}${e.id} ${e.icon?`${e.icon} `:""}${e.title} ${n}`),b(e.children??[],o+1,t)}return t}async function F(s){if(s.length!==1)throw new r("Name one extension: gallery extension check <id>.");let[o]=s;if(!y(o))throw new r(`Not an extension's id: ${o} (its folder's name under extensions/: lowercase letters, digits and dashes, 48 at most).`);let t=await N(f,o);t||(console.error(`No extension "${o}" visible from ${f}: gallery extension list shows them.`),process.exit(1));let e=await I(t.root,o),n=t.file;if(e.missing){if(await v(t.folder).catch(()=>null)){console.log(`OK ${o}: extension.json (${t.folder})`);return}console.error(`FAIL ${n}: there is no ${w}; the folder gives the sidebar no column until it has one (references/extensions.md says how it is written).`),process.exit(1)}e.error&&(console.error(`FAIL ${n}: ${e.error.message}`),console.error(`The sidebar shows the column "${e.title}" with one row: \u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.error.message}`),process.exit(1)),console.log(`The sidebar shows the column ${e.title}${e.icon?` (${e.icon})`:""}, ${h(e.count)}, in the order the file gives (an entry with an address opens it beside the sidebar, one without opens and closes what is under it):`),console.log(e.title);for(let i of b(e.entries,1))console.log(i);for(let i of e.notes)console.log(`note: ${i.message}`);console.log(`OK ${o}: ${h(e.count)} (${n})`)}async function T(s){if(s.length!==2||!y(s[0]))throw new r('Use gallery extension new <id> "<title>".');let[o,t]=s,e=E(JSON.stringify({title:t,entries:[]}));if(e.error)throw new r(e.error.message);let n=p();if(!(await O(n)).ours)throw new r(`Not a Gallery workspace: ${n}`);let i=x.join(g(n).extensions,o),a=x.join(i,w);await A(n,async()=>{for(let l of[g(n).extensions,i]){await d.mkdir(l,{recursive:!0});let m=await d.lstat(l);if(!m.isDirectory()||m.isSymbolicLink())throw new r(`Not an ordinary directory: ${l}`)}try{await d.writeFile(a,JSON.stringify({title:e.sidebar.title,entries:[]},null,2)+`
3
+ `,{flag:"wx"})}catch(l){throw l.code==="EEXIST"?new r(`Already exists: ${a}. Read and edit this file instead.`):l}}),console.log(`Created public extension ${o}
4
+ ${a}`)}async function M(s){let[o,...t]=s;if(o==="new"){let{positional:e}=c({argv:t});return T(e)}if(o==="install"||o==="remove"){let{positional:e}=c({argv:t});if(e.length!==1)throw new r(`gallery extension ${o} <${o==="install"?"folder | zip":"id"}>`);if(o==="remove")await u(e[0]),console.log(`Removed extension ${e[0]}`);else{let n=await $(e[0]);console.log(`Installed ${n.id}: ${n.folder}
5
+ Next: enable it in Gallery Settings > Extensions. Its backend starts on first use after enabling.`),n.agent&&console.log(`Agent instructions: ${n.agent}`)}return}if(o==="list"){let{positional:e}=c({argv:t});return L(e)}if(o==="check"){let{positional:e}=c({argv:t});return F(e)}throw new r(o?`No such action: extension ${o} (new, list, check, install, remove).`:"Say what to do: gallery extension new <id> <title>, list or check <id>.")}export{M as run};
@@ -1,3 +1,3 @@
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}from"./chunk-JEUK3ZO7.mjs";import"./chunk-ITOH5EGO.mjs";import{f as D}from"./chunk-ZQS6H473.mjs";import{b as d,f as J,i as k}from"./chunk-4OZWXZE5.mjs";import{c as F}from"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import{a as A}from"./chunk-UMHUSOPJ.mjs";import"./chunk-R2ZDLJYT.mjs";import"./chunk-VFX2KNHP.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{existsSync as E}from"node:fs";import R from"node:fs/promises";import m from"node:path";import{iconKind as q}from"../browser/shared/emoji/icon-value.mjs";import{writeAtomic as z}from"../browser/shared/files.mjs";import{reportsDirectory as C}from"../browser/shared/paths.mjs";import{roleOf as M}from"../browser/shared/reports.mjs";import{documentDirectory as P,documentFiles as T,pageSlug as U}from"../browser/shared/workspace.mjs";var K=o=>o.replace(/\s+/g," ").trim(),_=o=>o.replace(/^[a-z]:\/(?:[^/]+\/)*?(?=icons\/(?:tabler\/)?[^/]+$)/i,"/"),h=o=>o===null?"none":JSON.stringify(o);async function ie(o){let{positional:u,values:c}=J({values:["--title","--icon","--description"],argv:o});if(u.length!==1)throw new d("Name one document, then what to set: --title, --icon, --description.");if(!["--title","--icon","--description"].some(e=>c.has(e)))throw new d('Say what to set: --title "<title>", --icon <emoji|none|\u2026>, --description "<text>".');let n=c.has("--title")?K(c.get("--title")):void 0,p=c.has("--description")?K(c.get("--description")):void 0;if(n==="")throw new d("--title takes the words of the title: a document's title is never empty.");if(p==="")throw new d("--description takes words: a document's description is never empty.");let t;if(c.has("--icon")){let e=_(c.get("--icon").trim()),f=e==="none"?"none":q(e);if(!f||/["<>&]/.test(e))throw new d(`Not a page icon: ${e} (an emoji, none, an icon of the \u56FE\u6807 tab as /icons/<name>_<color>.svg, or a picture of the document's assets/).`);if(f==="glyph"&&!F(e))throw new d(`No such icon of the \u56FE\u6807 tab: ${e}.`);t=f==="none"?null:e}let{slug:w}=await k(u[0]),$=P(w,C);(w===await U(C)||await M($)==="instructions")&&(console.error(`${u[0]} is the \u5199\u4F5C\u504F\u597D page: only the user changes it.`),process.exit(1));let{html:r,json:s}=T($);E(r)||(console.error(`No document "${u[0]}": ${a(r)} does not exist (gallery list lists those there are).`),process.exit(1)),t&&q(t)==="image"&&!E(m.join($,...t.split("/")))&&(console.error(`No picture ${t} in ${a($)}: put it in its assets/ first.`),process.exit(1));let i;try{if(i=JSON.parse(await R.readFile(s,"utf8")),!i||typeof i!="object"||Array.isArray(i))throw new Error("not an object")}catch(e){console.error(`${a(s)} does not read (${e.code??e.message}): mend it first.`),process.exit(1)}let b=null,N=!1;for(let e=1;n!==void 0||t!==void 0;e++){let f=await R.readFile(r,"utf8"),v=A(f),y=D(v,{title:n,icon:t});if(y.missing&&(console.error(`${a(r)} has no title to ${n!==void 0?"set":"put the icon before"}: write it as an h1.doc-title in the page's header (writing-html.md, "The page").`),process.exit(1)),b=y.before,y.text===v)break;if(await z(r,y.text,{expect:f})){N=!0;break}e===3&&(console.error(`${a(r)} kept changing while it was being written (the page saving, or an Agent writing it?): nothing written. Run gallery set again.`),process.exit(1))}let l={...i};n!==void 0&&(l.title=n),p!==void 0&&(l.description=p),t===null?delete l.icon:t!==void 0&&(l.icon=t);let x=JSON.stringify(l)!==JSON.stringify(i);x&&await z(s,`${JSON.stringify(l,null,2)}
2
+ import{a}from"./chunk-JEUK3ZO7.mjs";import"./chunk-6NLXUKAY.mjs";import{f as D}from"./chunk-VRPVVMRB.mjs";import{b as d,f as J,i as k}from"./chunk-4OZWXZE5.mjs";import{c as F}from"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import{a as A}from"./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";import{existsSync as E}from"node:fs";import R from"node:fs/promises";import m from"node:path";import{iconKind as q}from"../browser/shared/emoji/icon-value.mjs";import{writeAtomic as z}from"../browser/shared/files.mjs";import{reportsDirectory as C}from"../browser/shared/paths.mjs";import{roleOf as M}from"../browser/shared/reports.mjs";import{documentDirectory as P,documentFiles as T,pageSlug as U}from"../browser/shared/workspace.mjs";var K=o=>o.replace(/\s+/g," ").trim(),_=o=>o.replace(/^[a-z]:\/(?:[^/]+\/)*?(?=icons\/(?:tabler\/)?[^/]+$)/i,"/"),h=o=>o===null?"none":JSON.stringify(o);async function ie(o){let{positional:u,values:c}=J({values:["--title","--icon","--description"],argv:o});if(u.length!==1)throw new d("Name one document, then what to set: --title, --icon, --description.");if(!["--title","--icon","--description"].some(e=>c.has(e)))throw new d('Say what to set: --title "<title>", --icon <emoji|none|\u2026>, --description "<text>".');let n=c.has("--title")?K(c.get("--title")):void 0,p=c.has("--description")?K(c.get("--description")):void 0;if(n==="")throw new d("--title takes the words of the title: a document's title is never empty.");if(p==="")throw new d("--description takes words: a document's description is never empty.");let t;if(c.has("--icon")){let e=_(c.get("--icon").trim()),f=e==="none"?"none":q(e);if(!f||/["<>&]/.test(e))throw new d(`Not a page icon: ${e} (an emoji, none, an icon of the \u56FE\u6807 tab as /icons/<name>_<color>.svg, or a picture of the document's assets/).`);if(f==="glyph"&&!F(e))throw new d(`No such icon of the \u56FE\u6807 tab: ${e}.`);t=f==="none"?null:e}let{slug:w}=await k(u[0]),$=P(w,C);(w===await U(C)||await M($)==="instructions")&&(console.error(`${u[0]} is the \u5199\u4F5C\u504F\u597D page: only the user changes it.`),process.exit(1));let{html:r,json:s}=T($);E(r)||(console.error(`No document "${u[0]}": ${a(r)} does not exist (gallery list lists those there are).`),process.exit(1)),t&&q(t)==="image"&&!E(m.join($,...t.split("/")))&&(console.error(`No picture ${t} in ${a($)}: put it in its assets/ first.`),process.exit(1));let i;try{if(i=JSON.parse(await R.readFile(s,"utf8")),!i||typeof i!="object"||Array.isArray(i))throw new Error("not an object")}catch(e){console.error(`${a(s)} does not read (${e.code??e.message}): mend it first.`),process.exit(1)}let b=null,N=!1;for(let e=1;n!==void 0||t!==void 0;e++){let f=await R.readFile(r,"utf8"),v=A(f),y=D(v,{title:n,icon:t});if(y.missing&&(console.error(`${a(r)} has no title to ${n!==void 0?"set":"put the icon before"}: write it as an h1.doc-title in the page's header (writing-html.md, "The page").`),process.exit(1)),b=y.before,y.text===v)break;if(await z(r,y.text,{expect:f})){N=!0;break}e===3&&(console.error(`${a(r)} kept changing while it was being written (the page saving, or an Agent writing it?): nothing written. Run gallery set again.`),process.exit(1))}let l={...i};n!==void 0&&(l.title=n),p!==void 0&&(l.description=p),t===null?delete l.icon:t!==void 0&&(l.icon=t);let x=JSON.stringify(l)!==JSON.stringify(i);x&&await z(s,`${JSON.stringify(l,null,2)}
3
3
  `);let S=m.basename(r),g=[];n!==void 0&&g.push(` title: ${h(b.title)} \u2192 ${h(n)} (${S}'s h1 and <title>, ${m.basename(s)})`),t!==void 0&&g.push(` icon: ${h(b.icon)} \u2192 ${h(t)} (${S}'s header, ${m.basename(s)})`),p!==void 0&&g.push(` description: ${h(typeof i.description=="string"?i.description:null)} \u2192 ${h(p)} (${m.basename(s)})`);let j=[...N?[a(r)]:[],...x?[a(s)]:[]];if(j.length===0){console.log(`Nothing to change: ${w} has ${g.length===1?"that already":"those already"}.`);return}console.log(`Set ${w}:`);for(let e of g)console.log(e);let O=j.length===1;console.log(`Re-read ${j.join(", ")} before editing ${O?"it":"them"}: gallery set wrote ${O?"it":"them"} (${[...N?[`${S}: its header`]:[],...x?[`${m.basename(s)}: ${["title","icon","description"].filter(e=>JSON.stringify(l[e])!==JSON.stringify(i[e])).join(", ")}`]:[]].join("; ")}).`)}export{ie as run};
@@ -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,K,L,M,N,O,P,Q,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-7JDX4E65.mjs";import"./chunk-3MBRL2PM.mjs";import"./chunk-HPOI4ZX7.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-EAIFITAV.mjs";import"./chunk-67N2QJYT.mjs";import"./chunk-5XA2ZBAE.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-JLTZF4LA.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-DJISHPUL.mjs";import"./chunk-ZWWC4KLF.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-ITOH5EGO.mjs";import"./chunk-ZQS6H473.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-MXUBKDRO.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-R2ZDLJYT.mjs";import"./chunk-VFX2KNHP.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{b as BEGIN,e as GESTURES,M as INSIDE_ALONE,N as OPEN_IT,a as READY,c as SAVING,L as TRY_LINES,m as asShown,o as changesOf,k as chosenInstance,z as cutOffSaid,D as documentHost,y as dragPath,x as drawn,s as dropScratch,t as dropStale,v as fallbackSaid,g as gestureOf,i as instancesIn,d as keysOf,B as listen,P as madeSaid,A as nothingSaid,n as partsOf,j as placeSaid,r as scratchCopy,f as stepOf,E as stepsCalled,h as stepsOf,K as stoppedTrial,C as takenAgain,u as takenBy,q as toldBy,J as trial,O as trialSaid,Q as tryCommand,w as untilTaken,l as withoutIds,F as wordsDiffer,G as wordsIn,p as writtenLines,I as writtenOtherwise,H as writtenWords};
2
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-Q7P3Q5YX.mjs";import"./chunk-4KUO7R2M.mjs";import"./chunk-MKIBJTJZ.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-2KAVXMKG.mjs";import"./chunk-XZCFPKGO.mjs";import"./chunk-BN7M3IN7.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-M4NRDYI5.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-6Q7ASAXJ.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-4OZWXZE5.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";export{b as BEGIN,e as GESTURES,M as INSIDE_ALONE,N as OPEN_IT,a as READY,c as SAVING,L as TRY_LINES,m as asShown,o as changesOf,k as chosenInstance,z as cutOffSaid,D as documentHost,y as dragPath,x as drawn,s as dropScratch,t as dropStale,v as fallbackSaid,g as gestureOf,i as instancesIn,d as keysOf,B as listen,P as madeSaid,A as nothingSaid,n as partsOf,j as placeSaid,r as scratchCopy,f as stepOf,E as stepsCalled,h as stepsOf,K as stoppedTrial,C as takenAgain,u as takenBy,q as toldBy,J as trial,O as trialSaid,Q as tryCommand,w as untilTaken,l as withoutIds,F as wordsDiffer,G as wordsIn,p as writtenLines,I as writtenOtherwise,H as writtenWords};
@@ -6,7 +6,7 @@ sidebar's \u9ED8\u8BA4\u6587\u6863 (GALLERY_DEFAULT_WORKSPACE names another fold
6
6
  whole address, as a user hands one over (http://127.0.0.1:4317/#\u5468\u62A5-k3xv9q2a, a block's id after a / or not): the
7
7
  words in a link are a label, and a title changed since leaves the address good.`,a={init:`Usage: gallery init [<dir>] [--from <old reports dir>] [--name "<name>"]
8
8
  Makes a workspace: <dir> (else the workspace found as every command finds it) with its gallery.json
9
- and .gallery/ (never over a gallery.json that is there). Prints \u5DE5\u4F5C\u533A\uFF1A<abs>\uFF08\u65B0\u5EFA or \u5DF2\u6709\uFF09.
9
+ only (never over a gallery.json that is there); the home workspace also gets its application folders. Prints \u5DE5\u4F5C\u533A\uFF1A<abs>\uFF08\u65B0\u5EFA or \u5DF2\u6709\uFF09.
10
10
  --name writes the workspace's name in its gallery.json (the project's: what the sidebar and gallery
11
11
  workspaces call it; else its folder's), said as \u540D\u5B57\uFF1A<name>; gallery workspaces --name changes it.
12
12
  The workspace goes on this machine's registry, as every command's does (gallery workspaces).
@@ -15,7 +15,7 @@ holding report.html or doc.html) into the workspace: every document whose slug i
15
15
  others listed as skipped), its preferences.md when the workspace has none, the sidebar's order, the
16
16
  \u5199\u4F5C\u504F\u597D page, the custom emoji and the documents' recent versions. The old folder is only read:
17
17
  nothing there is changed, moved or deleted.
18
- A workspace that never had one gets its home page (\u9996\u9875, pages/home/: Gallery's today and note cards),
18
+ Only the default workspace gets its home page (\u9996\u9875, pages/home/: Gallery's today and note cards),
19
19
  as a server's first start gives it, said in a line; once made, nothing makes it again.
20
20
  Exits 1 when the workspace cannot be written or --from names no folder; 2 for a name that is empty,
21
21
  over 80 characters or more than one line.`,new:`Usage: gallery new <slug> "<title>" ["<description>"] [--under <document>] [--after <document> | --first] [--no-preview] [--no-browser]
@@ -25,13 +25,13 @@ in the sidebar's tree: under --under's document, last (first with --first), or r
25
25
  (at that one's level); neither, at the top level, last. A document is named there by its slug, link
26
26
  or address (gallery help says how), and must be there, not in the trash; the \u5199\u4F5C\u504F\u597D page holds none.
27
27
  Then says where it went (Placed it \u2026), where it wrote (the workspace), where the user's writing preferences are (\u5199\u4F5C\u504F\u597D,
28
- <workspace>/preferences.md, to read first: made from Gallery's default when there are none yet) and
29
- the next steps (the first: send the user the address now), and last starts this workspace's Gallery
28
+ <home>/preferences.md, to read first: made from Gallery's default when there are none yet) and
29
+ the next steps (the first: send the user the address now), and last starts the one Gallery
30
30
  server (or uses the one running: it runs on after this command), opens the default browser at the
31
31
  document and prints the address to give the user, as gallery open does. In a workspace other than the
32
32
  default one, the document also joins the default workspace's sidebar (when there is one), in its
33
33
  workspace's column: a line says where, \u9ED8\u8BA4\u5DE5\u4F5C\u533A\uFF08\u2026\uFF09\u7684\u4FA7\u8FB9\u680F\uFF1A\u5DF2\u52A0\u8FDB\u2026; it is a display only, the file stays in
34
- its own workspace. GALLERY_NO_DEFAULT_TREE=1 leaves that out. --no-preview (or
34
+ its own workspace. --no-preview (or
35
35
  GALLERY_NO_PREVIEW=1) leaves the server alone; --no-browser (or GALLERY_NO_BROWSER=1) opens no
36
36
  browser. Editing needs Chrome or Edge.
37
37
  A title or a description that starts with "-" and a letter would be read as an option: put "--"
@@ -54,7 +54,7 @@ Put "--" before a title that starts with "-" and a letter.
54
54
  Exits 1 when the file is not there, cannot be read, or gallery new would refuse the slug; 2 for a
55
55
  kind it does not take.`,open:`Usage: gallery open [<slug>] [--no-browser]
56
56
  Starts this workspace's Gallery server (or uses the one running: it runs on after this command, its
57
- log in <workspace>/.gallery/logs/server.log), waits until it answers, and opens the default browser
57
+ log in <data>/logs/server.log), waits until it answers, and opens the default browser
58
58
  at the workbench, or at the document <slug>, at its block when an address names one (--no-browser,
59
59
  or GALLERY_NO_BROWSER=1, opens none).
60
60
  ${t}
@@ -63,7 +63,7 @@ the address to give the user. With a slug in a workspace other than the default
63
63
  them says the document joined the default workspace's sidebar (as gallery new's does). Editing needs Chrome or Edge: open the address there.
64
64
  With a slug and no qa baseline yet, it first keeps one of the document as it is now, so that the
65
65
  first gallery qa after the changes pictures what changed.
66
- Exits 1 when there is no such document, no server answers, or the workspace's server takes the
66
+ Exits 1 when there is no such document, no server answers, or the shared Gallery server takes the
67
67
  request and gives no answer (a second server is never started beside it).`,serve:`Usage: gallery serve [--port <n>]
68
68
  Runs this workspace's Gallery server in the foreground until Ctrl+C (gallery open runs one in the
69
69
  background instead). Prints the address once it answers. --port picks the port (else the last one
@@ -83,7 +83,7 @@ Exits 1 when a document fails, unless --allow-failures.`,export:`Usage: gallery
83
83
  gallery export --all [--allow-failures]
84
84
  Hands each named document in: its doc.html (report.html in an older document) written as its
85
85
  preview shows it, natural HTML as the kit's markup and every block given an id (through the
86
- workspace's server while one runs); then checks it and writes one standalone offline file per
86
+ shared Gallery server while one runs); then checks it and writes one standalone offline file per
87
87
  passing document, <workspace>/exports/<slug>.html. A document the quick checks fail is not handed in.
88
88
  ${t}
89
89
  It says first, once, what the preview wrote when the reader edited a document and the \u6279\u6CE8 it deleted;
@@ -119,7 +119,7 @@ with --no-export or --blocks names an id the document has not, else 0. A warning
119
119
  gallery list [<words>...] --all
120
120
  The workspace's documents, for an Agent to find the one the user means: each one's slug and title,
121
121
  its description, where it is in the sidebar's tree when it is under another (\u4F4D\u7F6E\uFF1Athe documents above
122
- it, from the top), its address (\u5730\u5740\uFF1A/#<link>, after the port of the workspace's server), when its file
122
+ it, from the top), its address (\u5730\u5740\uFF1A/#<link>, after the port of the shared Gallery server), when its file
123
123
  was last written and where that file is, the one edited last first.
124
124
  With words, only those whose title, description or slug holds any of them (case alike, Chinese found
125
125
  inside words), the best first, then those whose text holds them, each with its first place there
@@ -145,13 +145,13 @@ Exits 1 when --tree names a document that is not there, 2 one in the trash.`,wor
145
145
  gallery workspaces --name "<name>"
146
146
  gallery workspaces --forget <path>
147
147
  The workspaces of this machine: every workspace a gallery command or a Gallery server has worked in
148
- (but one in the system's temporary folder) is registered in a file of the user's (GALLERY_DATA_DIR,
148
+ is registered in a file of the user's (GALLERY_DATA_DIR,
149
149
  else %LOCALAPPDATA%\\gallery\\workspaces.json on Windows, ~/Library/Application Support/gallery on macOS,
150
150
  $XDG_STATE_HOME/gallery or ~/.local/state/gallery elsewhere). Lists them, the current one first (*),
151
151
  then the one edited last first: each one's name (its gallery.json's, else its folder's; the folder
152
152
  above it, or its own path, after the name when two are called alike), its id (ws- and six hex
153
153
  digits), its path (\u8DEF\u5F84\uFF1A), how many documents it has and when one was last edited (\u6587\u6863\uFF1A), and its
154
- server's address while one runs (\u670D\u52A1\uFF1A); one whose folder or gallery.json is gone is marked \u4E0D\u5728\u4E86
154
+ one shared service address printed above the list (\u670D\u52A1\uFF1A); one whose folder or gallery.json is gone is marked \u4E0D\u5728\u4E86
155
155
  and stays registered (a drive may come back).
156
156
  --scan registers the workspaces in <folder> and below it, 6 levels down at most (not in node_modules,
157
157
  .git, a dot folder or the recycle bin): the Documents folder when none is named. --name names the
@@ -204,19 +204,24 @@ remove moves it to the trash, which the workbench's \u8BBE\u7F6E \u203A \u56DE\u
204
204
  Each is written through the workspace's running server when there is one (an open workbench shows it
205
205
  at once), else here.
206
206
  Exits 1 when a link, a column or an entry named is not there or the server refuses it; 2 for an
207
- address that is not http or https, an empty name, or two places at once.`,extension:`Usage: gallery extension list
207
+ address that is not http or https, an empty name, or two places at once.`,extension:`Usage: gallery extension new <id> "<title>"
208
+ gallery extension list
208
209
  gallery extension check <id>
210
+ gallery extension install <folder | .zip>
211
+ gallery extension remove <id>
209
212
  An extension (\u6269\u5C55) gives the sidebar a column of entries of its own, beside \u6587\u6863: a folder
210
213
  <workspace>/extensions/<id>/ whose sidebar.json lists them (a title, an optional icon, and entries each with
211
214
  an id, a title, an optional address (http or https), an optional icon and optional children). The workbench
212
215
  reads the file again within a second of every change; a click on an entry with an address opens that page beside
213
216
  the sidebar (as a web link's), one without opens and closes what is under it. The user may drag the column to
214
- another place; its entries are the extension's, never dragged, renamed or removed. A file that does not read
215
- shows the column with one row, \u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A<why>. Gallery only reads these files: the extension writes them
216
- (references/extensions.md in the skill says how).
217
- list prints each extension of the workspace (extensions/<id>/): its column's title and how many entries it
218
- holds, or why it shows none.
219
- check <id> reads extensions/<id>/sidebar.json as the sidebar does and prints what the sidebar will show:
217
+ another place, rename it and reorder its root entries; title/order edits write back to sidebar.json.
218
+ A file that does not read shows the column with one row, \u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A<why>.
219
+ new creates an empty sidebar.json in the default workspace. Project-local extensions are not read.
220
+ install <folder | .zip> validates and replaces an extension; remove <id> removes it.
221
+ list prints capabilities and AGENT.md paths. Executable extensions require user confirmation in Settings > Extensions.
222
+ Every sidebar reads only the default workspace's extensions. No files are copied or moved automatically.
223
+ list prints the visible extensions, their source paths, titles and entry counts, or why they show none.
224
+ check <id> resolves the same default-workspace source as the sidebar and prints what the sidebar will show:
220
225
  the column, then each entry with its id, title and address, one under another indented; notes (an icon that
221
226
  is no emoji and no icon of the \u56FE\u6807 tab, which is left out) follow. Writes nothing.
222
227
  Exits 0 when the file reads; 1 when the extension is not there, has no sidebar.json or its file does not
@@ -328,7 +333,7 @@ Exits 2 for an id no block can have.
328
333
  try makes what a reader does on an instance in a document, with the pointer and the keys, and says
329
334
  what it wrote. It makes it on a scratch copy of the document (<workspace>/.gallery/try/try-<8 hex>/,
330
335
  gone at the end, whatever came of it): doc.html is not written, and no page of the user's shows the trial;
331
- --keep makes it on the document itself and leaves what it wrote. It starts the workspace's server (or
336
+ --keep makes it on the document itself and leaves what it wrote. It starts the shared Gallery server (or
332
337
  uses the one running), as gallery open does, and opens the copy's page alone, editable, in Chrome or
333
338
  Edge, headless, in a profile of its own, and waits until the server has told the page of the writes
334
339
  made before it (a custom block changed), which load it again. Each selector is the first element of the
@@ -402,7 +407,7 @@ Documents and custom pages share one set of slugs: neither takes the other's, no
402
407
  The home page (\u9996\u9875) is pages/home, a page as any.
403
408
  new makes one: page.html with its title (in <title>: a page draws no big title) and one empty board (data-board-id="main"), and
404
409
  page.json with the title; it goes last in the sidebar's head. The server puts in the scripts and styles
405
- of the blocks its cards hold. Says where it wrote and what to write next, and with the workspace's server
410
+ of the blocks its cards hold. Says where it wrote and what to write next, and with the shared Gallery server
406
411
  running ends with the \u4EA4\u7ED9\u7528\u6237 line gallery open has: the page's whole address, to send the user at once
407
412
  (without one, gallery page open <slug> --no-browser gives it).
408
413
  Exits 1 when the slug is taken (a document's, a page's, the trash's) or kept (exports, components, pages,
@@ -411,7 +416,7 @@ its own cards; gallery open --no-browser starts one), gallery page open, add, tr
411
416
  so in place of "no such page".
412
417
  list says the workspace's custom pages in the sidebar's order (the order the user dragged them to, then
413
418
  gallery.json's pages.order, then by title): each one's slug, icon and title, its address (\u5730\u5740\uFF1A, the whole address with
414
- the workspace's server running, else /#@<slug>, after the port of a server) and where its page.html is;
419
+ the shared Gallery server running, else /#@<slug>, after the port of a server) and where its page.html is;
415
420
  in a workspace with no page whose home page is not made yet, only that the home page waits for the server.
416
421
  open starts this workspace's Gallery server (or uses the one running), as gallery open does, and opens
417
422
  the default browser at the page in the workbench (--no-browser, or GALLERY_NO_BROWSER=1, opens none).
@@ -444,7 +449,7 @@ gallery block try's gestures (--press, --drag \u2026 --to, --key, --type, --sele
444
449
  the first element of the instance it finds (gallery block --help says each). It makes them on a scratch
445
450
  copy of the page (<workspace>/.gallery/try/try-<8 hex>/, gone at the end, whatever came of it):
446
451
  page.html is not written, and no page of the user's shows the trial; --keep makes them on the page itself
447
- and leaves what they wrote. It starts the workspace's server (or uses the one running) and opens the
452
+ and leaves what they wrote. It starts the shared Gallery server (or uses the one running) and opens the
448
453
  copy's page alone (/pages/<slug>), editable, in Chrome or Edge, headless, in a profile of its own. A
449
454
  write is what the page's board sends the page service, as the user's gestures go: once each is
450
455
  answered, a Gesture line (Step N with --steps) and a Wrote line say each data part of the card's
@@ -482,7 +487,7 @@ the last check that found nothing saw it (or, before any, since the version the
482
487
  its last write): cards added, removed, moved (to another board too), resized, their data parts changed
483
488
  (with the lines), a card's own markup, the page's own HTML; each change the page wrote since, a gesture
484
489
  of the user's there (not gallery page add's), ends "(the user's, on the page)": leave it as it is. Then
485
- the page itself, a scratch copy of it on the workspace's server (started
490
+ the page itself, a scratch copy of it on the shared Gallery server (started
486
491
  or used, as gallery page open does), in Chrome or Edge at 1280, 1920 and 600px wide (a narrow board: fewer
487
492
  columns of the same 64px cells), light and dark: a card whose content does not fit it, a card drawn out of its board, the page
488
493
  wider than the window, a block that failed, a picture that does not load, what the console says; each
@@ -519,7 +524,7 @@ Gallery: documents written as HTML, edited in the browser, exported as one offli
519
524
  gallery import <file> [<slug> ["<title>"]] documents made of a file (Markdown, HTML, Word, PDF\u2026)
520
525
  gallery open [<slug>] [--no-browser] start or reuse the server and open the browser
521
526
  gallery serve [--port <n>] run the server in the foreground
522
- gallery stop stop the workspace's server
527
+ gallery stop stop the shared Gallery server
523
528
  gallery check [<slug>...] check documents (none named: all)
524
529
  gallery export <slug>... | --all write <workspace>/exports/<slug>.html
525
530
  gallery qa <slug>... [--blocks a,b] [--tiles] look at exports in Chrome or Edge