@heycys/gallery 0.2.3 → 0.2.4

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 (220) hide show
  1. package/README.md +1 -1
  2. package/THIRD-PARTY-NOTICES.md +1 -1
  3. package/assets/preview/runtime.js +156 -0
  4. package/assets/preview/shell.html +107 -0
  5. package/assets/writing-preferences.md +1 -1
  6. package/browser/editor/components/divider/index.mjs +1 -1
  7. package/browser/editor/page/annotate/card.mjs +6 -0
  8. package/browser/editor/page/annotate/index.mjs +22 -2
  9. package/browser/editor/page/columns/index.mjs +1 -1
  10. package/browser/editor/page/conflicts.mjs +1 -1
  11. package/browser/editor/page/drag/index.mjs +1 -1
  12. package/browser/editor/page/editor.mjs +39 -3
  13. package/browser/editor/page/focus.mjs +104 -0
  14. package/browser/editor/page/handle/index.mjs +14 -2
  15. package/browser/editor/page/links/index.mjs +2 -2
  16. package/browser/editor/page/quiet.mjs +3 -3
  17. package/browser/editor/page/resize/index.mjs +1 -1
  18. package/browser/editor/page/session.mjs +4 -1
  19. package/browser/editor/page/ui.mjs +1 -1
  20. package/browser/shared/annotations.mjs +22 -3
  21. package/browser/shared/block-packs.mjs +13 -4
  22. package/browser/shared/document-look.mjs +14 -0
  23. package/browser/shared/drafts.mjs +1 -1
  24. package/browser/shared/extension-manifest.mjs +40 -12
  25. package/browser/shared/favorite-merge.mjs +17 -0
  26. package/browser/shared/favorites.mjs +77 -0
  27. package/browser/shared/i18n/en.mjs +123 -24
  28. package/browser/shared/outline-ops.mjs +109 -0
  29. package/browser/shared/outline.mjs +6 -0
  30. package/browser/shared/pages.mjs +20 -8
  31. package/browser/shared/paths.mjs +5 -2
  32. package/browser/shared/preference-documents.mjs +137 -0
  33. package/browser/shared/presence.mjs +94 -0
  34. package/browser/shared/preview-server.mjs +8 -5
  35. package/browser/shared/qa-levels.mjs +9 -1
  36. package/browser/shared/session.mjs +4 -0
  37. package/browser/shared/shipped-blocks.mjs +22 -4
  38. package/browser/shared/startup.mjs +101 -0
  39. package/browser/shared/workspace-columns.mjs +1 -1
  40. package/browser/shared/workspace-look.mjs +21 -8
  41. package/browser/shared/workspace-registry.mjs +6 -3
  42. package/browser/shared/workspace.mjs +37 -10
  43. package/browser/shared/writing-preferences.mjs +2 -42
  44. package/dist/chunk-25LYSMAE.mjs +2 -0
  45. package/dist/chunk-2I6ZVC5O.mjs +2 -0
  46. package/dist/{chunk-M4NRDYI5.mjs → chunk-2MYTOOP6.mjs} +1 -1
  47. package/dist/chunk-2VNENLER.mjs +2 -0
  48. package/dist/chunk-3FERXZF5.mjs +4 -0
  49. package/dist/chunk-3M6SBBGU.mjs +2 -0
  50. package/dist/chunk-3VCAAF34.mjs +2 -0
  51. package/dist/{chunk-WD4U6XXT.mjs → chunk-3ZTRLGSA.mjs} +1 -1
  52. package/dist/chunk-4FRA5AUE.mjs +2 -0
  53. package/dist/chunk-4LR2QEC2.mjs +4 -0
  54. package/dist/chunk-56SVJENP.mjs +966 -0
  55. package/dist/chunk-5CQISL2G.mjs +4 -0
  56. package/dist/{chunk-RRKJMHNX.mjs → chunk-5I5ZDDWC.mjs} +5 -5
  57. package/dist/chunk-5IHDLEB4.mjs +10 -0
  58. package/dist/chunk-5LRDMV7O.mjs +2 -0
  59. package/dist/chunk-5MVUYRKG.mjs +5 -0
  60. package/dist/chunk-5TLLIZT7.mjs +2 -0
  61. package/dist/chunk-6ILJWFYW.mjs +4 -0
  62. package/dist/chunk-6N25CJ6Y.mjs +3 -0
  63. package/dist/{chunk-SQ6Y2ZMA.mjs → chunk-7DTINW6U.mjs} +2 -2
  64. package/dist/chunk-7KWAGKIK.mjs +2 -0
  65. package/dist/chunk-7WNUOAFK.mjs +2 -0
  66. package/dist/chunk-7XCRW5RC.mjs +2 -0
  67. package/dist/{chunk-BYNPEUDS.mjs → chunk-7XSDTILF.mjs} +1 -1
  68. package/dist/chunk-ABKYFOVR.mjs +2 -0
  69. package/dist/chunk-AMUF7PUN.mjs +2 -0
  70. package/dist/{chunk-FJLM7YE7.mjs → chunk-B2EIMERT.mjs} +2 -2
  71. package/dist/{chunk-QNECWMGR.mjs → chunk-B45IAAU6.mjs} +1 -1
  72. package/dist/chunk-B6RAGF4R.mjs +2 -0
  73. package/dist/chunk-BSJKFE7I.mjs +4 -0
  74. package/dist/chunk-C72EEVLK.mjs +2 -0
  75. package/dist/chunk-CRAUKZ23.mjs +4 -0
  76. package/dist/chunk-F4CT35KL.mjs +2 -0
  77. package/dist/chunk-F63BNJLG.mjs +2 -0
  78. package/dist/chunk-FBKUPS44.mjs +2 -0
  79. package/dist/chunk-FL52ZL5Z.mjs +15 -0
  80. package/dist/chunk-FOZCU4VW.mjs +2 -0
  81. package/dist/chunk-G5HV7BC3.mjs +2 -0
  82. package/dist/{chunk-ERLAIBOA.mjs → chunk-GB5SOYQJ.mjs} +2 -2
  83. package/dist/chunk-GN3SG3IF.mjs +2 -0
  84. package/dist/{chunk-6QWQXHAV.mjs → chunk-HFTBVEZK.mjs} +1 -1
  85. package/dist/chunk-IOW5HLRK.mjs +2 -0
  86. package/dist/chunk-IQ3GJNTI.mjs +6 -0
  87. package/dist/chunk-K6SPFBUJ.mjs +2 -0
  88. package/dist/chunk-K7Y7SPTS.mjs +2 -0
  89. package/dist/chunk-L2IJCEUH.mjs +2 -0
  90. package/dist/{chunk-GPIWQ4X4.mjs → chunk-L3VT6LM4.mjs} +1 -1
  91. package/dist/chunk-L4WLQYFC.mjs +5 -0
  92. package/dist/{chunk-NLDF35P5.mjs → chunk-LAMCAGK6.mjs} +1 -1
  93. package/dist/chunk-LHGKPMTI.mjs +2 -0
  94. package/dist/chunk-LJZIYVNA.mjs +3 -0
  95. package/dist/chunk-LSVCTLS2.mjs +2 -0
  96. package/dist/chunk-LZY74XTP.mjs +2 -0
  97. package/dist/chunk-MC4LRSVH.mjs +2 -0
  98. package/dist/chunk-MCEXN4G5.mjs +2 -0
  99. package/dist/chunk-MTLAOCFF.mjs +181 -0
  100. package/dist/chunk-MZ66LN3B.mjs +2 -0
  101. package/dist/chunk-N5QWJRRI.mjs +2 -0
  102. package/dist/chunk-NF4MMOUB.mjs +2 -0
  103. package/dist/chunk-NHJYAJ73.mjs +3 -0
  104. package/dist/chunk-NRSD7SVY.mjs +2 -0
  105. package/dist/chunk-NT23I4XW.mjs +2 -0
  106. package/dist/chunk-NUALABIS.mjs +3 -0
  107. package/dist/chunk-NW6LAU22.mjs +2 -0
  108. package/dist/chunk-NWWHDGKF.mjs +5 -0
  109. package/dist/chunk-OFRCVMSJ.mjs +2 -0
  110. package/dist/chunk-OKVQQ3CX.mjs +4 -0
  111. package/dist/chunk-OM24O4KR.mjs +8 -0
  112. package/dist/{chunk-4B2TB5K2.mjs → chunk-PBMOC7KA.mjs} +2 -2
  113. package/dist/chunk-PVTCP43W.mjs +2 -0
  114. package/dist/chunk-Q62HZAJS.mjs +2 -0
  115. package/dist/chunk-QBJWIR3Q.mjs +2 -0
  116. package/dist/chunk-QDSEZX7Z.mjs +6 -0
  117. package/dist/chunk-QR4V4A2Z.mjs +15 -0
  118. package/dist/{chunk-QVGOPHOF.mjs → chunk-QRLVVZ3R.mjs} +1 -1
  119. package/dist/chunk-QW3QG67J.mjs +2 -0
  120. package/dist/chunk-R2T2EVWY.mjs +8 -0
  121. package/dist/{chunk-JJNHKGTD.mjs → chunk-R5RERE6G.mjs} +1 -1
  122. package/dist/chunk-RFHEWT3Y.mjs +5 -0
  123. package/dist/chunk-RS2Z2JQP.mjs +2 -0
  124. package/dist/chunk-S6YEC4GE.mjs +16 -0
  125. package/dist/chunk-SHZLMGGW.mjs +2 -0
  126. package/dist/chunk-TALJQM2O.mjs +2 -0
  127. package/dist/chunk-TLNJWEFY.mjs +22 -0
  128. package/dist/{chunk-ZLS2FRS6.mjs → chunk-TQZU7D7C.mjs} +1 -1
  129. package/dist/chunk-UTKNWYBA.mjs +2 -0
  130. package/dist/chunk-V3TM3TEN.mjs +2 -0
  131. package/dist/chunk-V3XROSP5.mjs +7 -0
  132. package/dist/{chunk-6QBHU4DF.mjs → chunk-V5JTW2LH.mjs} +1 -1
  133. package/dist/chunk-VAXLSISW.mjs +4 -0
  134. package/dist/chunk-VBHI3RG6.mjs +2 -0
  135. package/dist/{chunk-CRDG6EF2.mjs → chunk-VKZJRGDR.mjs} +1 -1
  136. package/dist/chunk-VZXZM7NS.mjs +2 -0
  137. package/dist/chunk-WDS6HEPE.mjs +2 -0
  138. package/dist/chunk-WHGANNEY.mjs +13 -0
  139. package/dist/chunk-WMJWC4QY.mjs +56 -0
  140. package/dist/{chunk-UTMAY3WK.mjs → chunk-WWONJJQS.mjs} +1 -1
  141. package/dist/chunk-X4WNLFIK.mjs +2 -0
  142. package/dist/chunk-XNNCQROX.mjs +11 -0
  143. package/dist/chunk-XRYECF23.mjs +170 -0
  144. package/dist/{chunk-225ALKYI.mjs → chunk-Z4NEXXFK.mjs} +1 -1
  145. package/dist/{chunk-PKVK6WFC.mjs → chunk-ZFVF2YPV.mjs} +2 -2
  146. package/dist/chunk-ZM2IX3R2.mjs +2 -0
  147. package/dist/chunk-ZNGGDUZI.mjs +2 -0
  148. package/dist/chunk-ZOEJQOKT.mjs +2 -0
  149. package/dist/cli.mjs +1 -1
  150. package/dist/server.mjs +1 -1
  151. package/dist/update-fetch.mjs +1 -1
  152. package/dist/worker.mjs +1 -1
  153. package/package.json +1 -1
  154. package/release.json +3 -3
  155. package/skill/SKILL.md +54 -148
  156. package/skill/references/building-blocks.md +4 -4
  157. package/skill/references/charts-and-figures.md +73 -0
  158. package/skill/references/extensions.md +47 -4
  159. package/skill/references/pages-and-data.md +22 -3
  160. package/skill/references/preference-files.md +7 -0
  161. package/skill/references/previews.md +17 -0
  162. package/skill/references/writing-html.md +21 -82
  163. package/web/assets/index-B4uUluLM.js +15 -0
  164. package/web/assets/index-C3vHT8sH.css +1 -0
  165. package/web/index.html +2 -2
  166. package/dist/chunk-2HS7ZBPU.mjs +0 -2
  167. package/dist/chunk-3F57LEN5.mjs +0 -2
  168. package/dist/chunk-4OZWXZE5.mjs +0 -5
  169. package/dist/chunk-5GK7HS62.mjs +0 -2
  170. package/dist/chunk-6GV3CBB2.mjs +0 -2
  171. package/dist/chunk-6NLXUKAY.mjs +0 -4
  172. package/dist/chunk-6XD6U3QA.mjs +0 -5
  173. package/dist/chunk-6Y3HYOBM.mjs +0 -2
  174. package/dist/chunk-7EFHNQ5B.mjs +0 -3
  175. package/dist/chunk-7M2BQQGZ.mjs +0 -2
  176. package/dist/chunk-7UZUQQ7Q.mjs +0 -554
  177. package/dist/chunk-ALZ6ZENZ.mjs +0 -3
  178. package/dist/chunk-BX5AKINW.mjs +0 -15
  179. package/dist/chunk-DR73Y2UJ.mjs +0 -3
  180. package/dist/chunk-EURLTOTZ.mjs +0 -4
  181. package/dist/chunk-F4ZA6JRZ.mjs +0 -3
  182. package/dist/chunk-FNCCVGKX.mjs +0 -2
  183. package/dist/chunk-FOJ3K5Z3.mjs +0 -6
  184. package/dist/chunk-FQ72LZHB.mjs +0 -2
  185. package/dist/chunk-G7N7YFVD.mjs +0 -2
  186. package/dist/chunk-GIRXJBGC.mjs +0 -2
  187. package/dist/chunk-GKOBB6DH.mjs +0 -2
  188. package/dist/chunk-GMJD7ID3.mjs +0 -2
  189. package/dist/chunk-GQJMVSSN.mjs +0 -2
  190. package/dist/chunk-HX4DLE3J.mjs +0 -10
  191. package/dist/chunk-IS7N3N6Q.mjs +0 -168
  192. package/dist/chunk-JEUK3ZO7.mjs +0 -2
  193. package/dist/chunk-JPG2LBQM.mjs +0 -11
  194. package/dist/chunk-JYK5WJPM.mjs +0 -2
  195. package/dist/chunk-KLQP46Y3.mjs +0 -4
  196. package/dist/chunk-L55NOXBE.mjs +0 -4
  197. package/dist/chunk-LCB6MARS.mjs +0 -5
  198. package/dist/chunk-LJLVCU6W.mjs +0 -16
  199. package/dist/chunk-LMUZQK5O.mjs +0 -2
  200. package/dist/chunk-NMF3IPYA.mjs +0 -13
  201. package/dist/chunk-ONKC4BCC.mjs +0 -2
  202. package/dist/chunk-OU6ZZVBX.mjs +0 -5
  203. package/dist/chunk-PUOQ65NC.mjs +0 -2
  204. package/dist/chunk-QJAVCTY7.mjs +0 -2
  205. package/dist/chunk-QP7BOHE4.mjs +0 -2
  206. package/dist/chunk-S3SX3COT.mjs +0 -20
  207. package/dist/chunk-SQ3FQCCN.mjs +0 -8
  208. package/dist/chunk-T4Y2ZSVX.mjs +0 -4
  209. package/dist/chunk-TANZRINB.mjs +0 -2
  210. package/dist/chunk-UGWMMEJ5.mjs +0 -15
  211. package/dist/chunk-UTF7GBQU.mjs +0 -4
  212. package/dist/chunk-V4ZHRALW.mjs +0 -170
  213. package/dist/chunk-XBNFXWAW.mjs +0 -6
  214. package/dist/chunk-XZV72SQ4.mjs +0 -2
  215. package/dist/chunk-YFJB534W.mjs +0 -2
  216. package/dist/chunk-Z6OKLRHC.mjs +0 -2
  217. package/dist/chunk-ZMHUDYLV.mjs +0 -2
  218. package/web/assets/index-D8P8uhDW.js +0 -15
  219. package/web/assets/index-FLb9jCfl.css +0 -1
  220. /package/dist/{chunk-PAREWQGB.mjs → chunk-NOGQX56R.mjs} +0 -0
@@ -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 g}from"./chunk-NF4MMOUB.mjs";import"./chunk-ZNGGDUZI.mjs";import{a as l,e as f,n as d}from"./chunk-B6RAGF4R.mjs";import"./chunk-5TLLIZT7.mjs";import"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import{b as s,f as c}from"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";import{readFavorites as h}from"../browser/shared/favorites.mjs";import{reportsDirectory as p}from"../browser/shared/paths.mjs";async function x(m){let{positional:e,options:u}=c({options:["--off"],argv:m});if(e.length!==1)throw new s("Name one entry to put in \u6536\u85CF (or take out of it with --off).");let t=u.has("--off"),r=await l(),o=await g(e[0],r).catch(a=>{if(!(a instanceof s)||!t)throw a;return{kind:"gone",slug:e[0],title:e[0]}});o.refused&&(console.error(o.refused),process.exit(1)),o.kind==="page"&&(console.error(`${o.slug} (${o.title}) is a custom page: the sidebar's \u6536\u85CF holds documents and web links.`),process.exit(1)),o.kind==="gone"&&!(await h(p)).includes(o.slug)&&(console.error(`No entry "${e[0]}" in the sidebar, and \u6536\u85CF does not hold it: gallery list --tree shows the entries.`),process.exit(1));let n=await d("favorite",t?{remove:[o.slug]}:{add:[o.slug]});n?.ok||(console.error(`Not changed: ${n?.message??n?.reason??"no answer"}.`),process.exit(1));let i=o.kind==="gone"?o.slug:f(r,o.slug);n.changed?console.log(`${t?"Took":"Put"} ${i} ${t?"out of":"in"} the sidebar's \u6536\u85CF (${n.favorites.length} now).`):console.log(`${i} is ${t?"not in \u6536\u85CF":"in \u6536\u85CF"} already: nothing to change.`)}export{x as run};
@@ -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{b as $,f as b,g as A}from"./chunk-XRYECF23.mjs";import{j as P}from"./chunk-B6RAGF4R.mjs";import"./chunk-5TLLIZT7.mjs";import{a as j}from"./chunk-2VNENLER.mjs";import"./chunk-HFTBVEZK.mjs";import"./chunk-5IHDLEB4.mjs";import"./chunk-B2EIMERT.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-56SVJENP.mjs";import{c as T,t as p,u as C}from"./chunk-BSJKFE7I.mjs";import{b as h}from"./chunk-L4WLQYFC.mjs";import{f as g,i as S,v as w}from"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{LISTED_BLOCKS as L}from"../browser/editor/components/registry.mjs";import{inLanguage as u,told as O}from"../browser/shared/i18n/index.mjs";import{netHostsOf as D}from"../browser/shared/net-policy.mjs";import{PACK_ID as G}from"../browser/shared/pack-manifest.mjs";import{findPreviewServer as N}from"../browser/shared/preview-server.mjs";var z=o=>u("en",()=>O(o))??o?.message??o?.reason??"no answer";async function m(o,e){let s=await N(),t=s?await P(s,e,"components"):null;if(t)return t;try{return{ok:!0,...await j({root:o,taken:()=>S(o)}).write(e)}}catch(n){return{ok:!1,reason:"components",message:n.message,...typeof n.text=="string"&&Array.isArray(n.values)?{text:n.text,values:n.values}:{}}}}var k=(o,e)=>{console.error(`${o}: ${z(e)}`),process.exit(1)},f=o=>o?"on":"off";async function V(o,e,s){if(s===void 0)throw new h(`gallery block pack ${f(e)} takes one pack's id: gallery block pack ${f(e)} <pack> (gallery block pack list says each).`);if(!G.test(s))throw new h(`Not a pack's id: ${s} (lowercase letters, digits and hyphens: gallery block pack list says each pack's).`);let t=p(o);if(!t.some(a=>a.id===s)&&T().includes(s)){let a=await C(o);a.did==="done"&&console.log(`Installed Gallery's own packs first, as gallery init and a server's start do (${a.packs.filter(l=>!l.failed).map(l=>l.id).join(", ")}).`),t=p(o)}let n=t.find(a=>a.id===s);n||(console.error(`No pack ${s} in this workspace (${t.map(a=>a.id).join(", ")}): gallery block pack list says which there are.`),process.exit(1));let i=`${s} (${A(n.name)})`;if(n.enabled===e)return void console.log(`The pack ${i} is ${f(e)} already: nothing changed.`);let r=await m(o,{pack:s,enabled:e});r.ok||k(`The pack ${s} was not switched ${f(e)}`,r),console.log(`Switched the pack ${i} ${f(e)}: ${e?'its blocks are offered by "/" and \u6DFB\u52A0\u81EA\u5B9A\u4E49\u5757':"no menu or library offers its blocks, and what is written of them shows as ever"} (\u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 shows the same switch).`)}function E(o,e){let s=e.includes("/")?null:L.find(({id:t,name:n})=>t===e||[u("zh",n),u("en",n)].some(i=>i.toLowerCase()===e.toLowerCase()))??null;if(s){let t=g(o);if(!t.packages.has(`local/${e}`)&&!t.problems.has(`local/${e}`))return{builtin:s}}try{return{id:$(o,e)}}catch(t){throw t instanceof h?new h(`${t.message} A built-in block of the menus is named by its id or its name: ${L.map(({id:n})=>n).join(", ")}.`):t}}async function X(o,e,s){let t=E(o,s),n=g(o);if(t.builtin){let{id:c,name:y,hideable:v}=t.builtin,d=`${c} (${u("zh",y)} / ${u("en",y)})`,I=v&&n.settings.hidden.includes(c);if(!v){if(e)return void console.log(`The built-in block ${d} is always in the document's menus: nothing changed.`);console.error(`The built-in block ${d} stays in the document's menus: it cannot be taken out.`),process.exit(1)}if(I===!e)return void console.log(`The built-in block ${d} is ${e?"in":"out of"} the document's menus already: nothing changed.`);let x=await m(o,{id:c,hidden:!e});x.ok||k(`The built-in block ${c} was not ${e?"put in":"taken out of"} the document's menus`,x),console.log(e?`Put the built-in block ${d} in the document's menus again ("/", \u5728\u4E0B\u65B9\u65B0\u5EFA, the handle's grid).`:`Took the built-in block ${d} out of the document's menus ("/", \u5728\u4E0B\u65B9\u65B0\u5EFA, the handle's grid): a document can still write it, and what is written of it still runs and exports. gallery block menu on ${c} puts it back.`);return}let{id:i}=t,r=w(n).find(c=>c.id===i);if(r||(console.error(b(o,i)),process.exit(1)),r.menu===e)return void console.log(`${i} is ${e?"in":"out of"} the document's menus already: nothing changed.`);let a=(r.places??["document"]).includes("document"),l=await m(o,a?{id:i,hidden:!e}:{id:i,shown:e});l.ok||k(`${i} was not ${e?"put in":"taken out of"} the document's menus`,l),console.log(e?`Put ${i} in the document's menus ("/", \u5728\u4E0B\u65B9\u65B0\u5EFA, the handle's grid).`:`Took ${i} out of the document's menus ("/", \u5728\u4E0B\u65B9\u65B0\u5EFA, the handle's grid): a document can still write it, and what is written of it still runs and exports. gallery block menu on ${i} puts it back.`)}async function Y(o,e,s){let t=$(o,s),n=w(g(o)).find(l=>l.id===t);n||(console.error(b(o,t)),process.exit(1));let i=D(n.needs),r=i.length>0&&i.every(l=>n.allowed.includes(l));if(e){if(i.length===0&&(console.error(`${t} reaches no website: its manifest's needs name no net:<host>, so there is nothing to allow (gallery block show ${t} says its needs).`),process.exit(1)),console.log(`${t} will reach these websites: ${i.join(", ")}`),console.log("Gallery fetches for it, only from those sites, with none of the user's logins; what it gets is shown in Gallery and the last of it is kept in an export."),console.log(`\u63D0\u793A\uFF1Aturn this on only when the user asked for it; gallery block net off ${t} takes it back.`),r)return void console.log(`${t} is allowed to reach them already: nothing changed.`);let l=await m(o,{id:t,net:!0});l.ok||k(`${t} was not allowed online`,l),console.log(`Allowed ${t} to reach ${i.join(", ")} (\u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 \u203A \u5141\u8BB8\u8054\u7F51 is on for it).`);return}if(n.allowed.length===0)return void console.log(`${t} is not allowed to reach any website: nothing to take back.`);let a=await m(o,{id:t,net:!1});a.ok||k(`${t} was not taken offline`,a),console.log(`Took back ${t}'s reach to ${n.allowed.join(", ")} (\u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 \u203A \u5141\u8BB8\u8054\u7F51 is off for it).`)}export{X as menuSwitch,Y as netSwitch,V as packSwitch};
@@ -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,b,c}from"./chunk-F63BNJLG.mjs";import"./chunk-ZNGGDUZI.mjs";import"./chunk-B6RAGF4R.mjs";import"./chunk-5TLLIZT7.mjs";import"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import"./chunk-VAXLSISW.mjs";import"./chunk-56SVJENP.mjs";import"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";export{b as hideWorkspaceColumn,a as nameHint,c 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}from"./chunk-3F57LEN5.mjs";import"./chunk-QP7BOHE4.mjs";import"./chunk-GMJD7ID3.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-L55NOXBE.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";export{a as nameHint,b as run};
2
+ import{a,b,c}from"./chunk-ZNGGDUZI.mjs";import"./chunk-B6RAGF4R.mjs";import"./chunk-5TLLIZT7.mjs";import"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";export{a as documentsOf,c as run,b as when};
@@ -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 B,a as O,i as Y,v as k,y as P}from"./chunk-4LR2QEC2.mjs";import"./chunk-Q4UEPUWF.mjs";import{a as N}from"./chunk-VAXLSISW.mjs";import"./chunk-56SVJENP.mjs";import{f as W}from"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";import{existsSync as C,readFileSync as F,statSync as U}from"node:fs";import D from"node:fs/promises";import h from"node:path";import{compareVersions as G}from"../browser/shared/versions.mjs";import{markerOf as H}from"../browser/shared/workspace.mjs";var x="22.13.0",_="\u7136\u540E\u5F00\u4E00\u4E2A\u65B0\u7684\u4F1A\u8BDD",J=e=>[...new Set(e)];async function V({version:e=N(),workspace:t,how:r=null,env:a=process.env,cwd:o=process.cwd(),node:f=process.versions.node,npx:d=Y(),browser:w=null}={}){let $=[],S=[],b=(s,{id:u,text:g,...A})=>({id:u,status:s,text:g,...A}),m=(s,u,g)=>{$.push(b("problem",s)),S.push([u,g])},y=s=>$.push(b("ok",s)),j=s=>$.push(b("note",s));G(f,x)<0?m({id:"node",version:f,required:`>=${x}`,text:`Node ${f} is older than the ${x} Gallery needs`},0,"\u88C5 Node 22.13 \u6216\u66F4\u65B0\u7684\u7248\u672C\uFF08https://nodejs.org \u7684 LTS\uFF09\uFF0C\u7136\u540E\u518D\u8FD0\u884C\u8FD9\u6761\u547D\u4EE4"):y({id:"node",version:f,required:`>=${x}`,text:`Node ${f}\uFF08\u8981 ${x} \u4EE5\u4E0A\uFF09`});let c=B(e,{env:a,refresh:!0}),K=c.latest?d?k("skill install",c.latest,!0):`npm i -g ${O}@^${c.latest}\uFF0C\u518D\u8FD0\u884C gallery skill install`:"";c.newer?m({id:"gallery",version:e,latest:c.latest,text:`Gallery ${e}\uFF0Cnpm \u4E0A\u6709\u65B0\u7248 ${c.latest}`},3,`\u95EE\u8FC7\u7528\u6237\u540E\u8FD0\u884C ${K}\uFF0C${_}`):c.off?j({id:"gallery",version:e,latest:null,text:`Gallery ${e}\uFF08\u6CA1\u6709\u67E5 npm\uFF1AGALLERY_NO_UPDATE_CHECK\u3001CI \u6216 NO_UPDATE_NOTIFIER \u8BBE\u4E86\uFF09`}):c.latest?y({id:"gallery",version:e,latest:c.latest,text:`Gallery ${e}\uFF08npm \u4E0A\u6700\u65B0\u7684\u662F ${c.latest}\uFF0C\u6CA1\u6709\u66F4\u65B0\u7684\uFF09`}):j({id:"gallery",version:e,latest:null,text:`Gallery ${e}\uFF08\u8FD8\u4E0D\u77E5\u9053 npm \u4E0A\u6709\u6CA1\u6709\u65B0\u7248\uFF1A\u540E\u53F0\u6B63\u5728\u67E5\uFF0C\u4E0B\u6B21 gallery doctor \u5C31\u6709\u7B54\u6848\uFF09`});let I=P(e,{env:a,cwd:o});if(I.length===0)j({id:"skill",installed:[],text:"\u6CA1\u6709\u627E\u5230\u88C5\u597D\u7684 Gallery \u6280\u80FD\uFF08gallery skill install \u88C5\u4E00\u4EFD\uFF1B\u6280\u80FD\u5728\u522B\u5904\u52A0\u8F7D\u7684\uFF0C\u4E0D\u7528\u7BA1\u8FD9\u4E00\u6761\uFF09"});else{let s=I.map(({folder:l,project:n,made:i,older:T})=>({folder:l,project:n,version:i,older:T&&(!i||G(i,e)<0),newer:!!i&&G(i,e)>0})),u=s.filter(l=>l.older),g=s.filter(l=>l.newer),A=l=>`${l.folder} \u662F${l.version?` Gallery ${l.version} `:"\u65E7\u7248 Gallery\uFF08\u6CA1\u5199\u7248\u672C\uFF09"}\u7684`,L=s.map(l=>`${A(l)}${l.older?`\uFF0C\u6BD4\u8FD9\u4E2A gallery ${e} \u65E7`:l.newer?`\uFF0C\u6BD4\u8FD9\u4E2A gallery ${e} \u65B0`:"\uFF0C\u548C\u8FD9\u4E2A gallery \u4E00\u6837\u65B0"}`).join("\uFF1B");if(u.length){let l=J(u.map(n=>k(`skill install${n.project?" --project":""}`,e,d)));m({id:"skill",installed:s.map(({newer:n,...i})=>i),text:`\u6280\u80FD ${L}`},2,`\u8FD0\u884C ${l.join("\uFF0C\u518D\u8FD0\u884C ")}\uFF0C${_}`)}else if(g.length){let l=g.map(n=>n.version).sort((n,i)=>G(i,n))[0];m({id:"skill",installed:s.map(({newer:n,...i})=>i),text:`\u6280\u80FD ${L}`},2,`\u95EE\u8FC7\u7528\u6237\u540E\u8FD0\u884C ${d?k("skill install",l,!0):`npm i -g ${O}@^${l}`}\uFF0C\u628A gallery \u5347\u5230\u6280\u80FD\u7684\u7248\u672C\uFF0C${_}`)}else y({id:"skill",installed:s.map(({newer:l,...n})=>n),text:`\u6280\u80FD ${L}`})}let p=await z(t),E=r?`\uFF08${{flag:"--workspace",env:"GALLERY_WORKSPACE",found:"\u4E0A\u5C42\u7684 gallery.json",default:"\u9ED8\u8BA4\u4F4D\u7F6E"}[r]??r}\uFF09`:"";p.writable?p.foreign?m({id:"workspace",path:t,exists:!0,writable:!0,text:`\u5DE5\u4F5C\u533A ${t} \u91CC\u7684 gallery.json ${p.foreign==="json"?"\u8BFB\u4E0D\u6210 JSON":"\u4E0D\u662F Gallery \u7684"}${E}`},1,`${p.foreign==="json"?`\u4FEE\u597D ${h.join(t,"gallery.json")}`:"\u6362\u4E00\u4E2A\u6587\u4EF6\u5939\u653E Gallery \u7684\u6587\u6863"}\uFF1A\u6BCF\u6761\u547D\u4EE4\u52A0 --workspace <\u6587\u4EF6\u5939>\uFF0C\u6216\u8BBE\u73AF\u5883\u53D8\u91CF GALLERY_WORKSPACE`):p.exists?y({id:"workspace",path:t,exists:!0,writable:!0,text:`\u5DE5\u4F5C\u533A ${t} \u53EF\u4EE5\u5199${E}`}):y({id:"workspace",path:t,exists:!1,writable:!0,text:`\u5DE5\u4F5C\u533A ${t} \u8FD8\u6CA1\u5EFA\uFF0C\u5199\u5F97\u8FDB\u53BB\uFF08\u7B2C\u4E00\u6761\u5199\u6587\u6863\u7684\u547D\u4EE4\u4F1A\u5EFA\u5B83\uFF09${E}`}):m({id:"workspace",path:t,exists:p.exists,writable:!1,text:`\u5DE5\u4F5C\u533A ${t} \u5199\u4E0D\u8FDB\u53BB${p.code?`\uFF08${p.code}\uFF09`:""}${E}`},1,"\u7ED9 Gallery \u4E00\u4E2A\u80FD\u5199\u7684\u6587\u4EF6\u5939\uFF1A\u6BCF\u6761\u547D\u4EE4\u52A0 --workspace <\u6587\u4EF6\u5939>\uFF0C\u6216\u8BBE\u73AF\u5883\u53D8\u91CF GALLERY_WORKSPACE");let R=w===null?await Q(a):w;R.path?y({id:"browser",path:R.path,text:`\u6D4F\u89C8\u5668 ${R.path}`}):m({id:"browser",path:null,text:`\u6D4F\u89C8\u5668\uFF1A${R.why}`},4,"\u88C5 Chrome \u6216 Edge\uFF0C\u6216\u7528 GALLERY_BROWSER=<\u6D4F\u89C8\u5668\u7684\u53EF\u6267\u884C\u6587\u4EF6> \u6307\u4E00\u4E2A\uFF1B\u88C5\u4E0D\u4E86\u7684\u8BDD\uFF0Cgallery qa \u4F1A\u8BF4 UNVERIFIED\uFF0C\u5BFC\u51FA\u7684\u6587\u4EF6\u8981\u81EA\u5DF1\u5728 1024\u3001736 \u548C 360px \u770B\uFF0C\u5E76\u544A\u8BC9\u7528\u6237");let q=S.sort((s,u)=>s[0]-u[0])[0]?.[1]??null;return{checks:$,next:q,ok:S.length===0}}async function Q(e){let{findBrowser:t}=await import("./chunk-4FRA5AUE.mjs"),r=t();return r?e.GALLERY_BROWSER&&!C(r)?{path:null,why:`GALLERY_BROWSER \u6307\u7684 ${r} \u4E0D\u5B58\u5728`}:{path:r}:{path:null,why:"\u627E\u4E0D\u5230 Chrome \u6216 Edge\uFF08gallery qa \u548C\u5728\u6D4F\u89C8\u5668\u91CC\u7F16\u8F91\u8981\u7528\uFF09"}}async function z(e){let t=C(e),r=h.resolve(e);for(;!C(r)&&h.dirname(r)!==r;)r=h.dirname(r);try{if(!U(r).isDirectory())return{exists:t,writable:!1,code:"ENOTDIR"};let o=h.join(r,`.gallery-doctor-${process.pid}.tmp`);await D.writeFile(o,"",{flag:"wx"}),await D.rm(o,{force:!0})}catch(o){return{exists:t,writable:!1,code:o.code??o.message}}if(!t)return{exists:t,writable:!0};let a=null;try{a=F(h.join(e,"gallery.json"),"utf8")}catch{}if(a!==null){let o=H(a);if(!o.reads)return{exists:t,writable:!0,foreign:"json"};if(!o.ours)return{exists:t,writable:!0,foreign:"ours"}}return{exists:t,writable:!0}}async function se(e,t={}){let{options:r}=W({options:["--json"],argv:e}),a=t.version??N(),o=t.workspace??process.env.GALLERY_WORKSPACE,{checks:f,next:d,ok:w}=await V({version:a,workspace:o,how:t.how??null});if(r.has("--json"))console.log(JSON.stringify({ok:w,version:a,workspace:o,checks:f,next:d},null,2));else{for(let $ of f)console.log(`${{ok:"\u597D ",problem:"\u95EE\u9898 ",note:"\u63D0\u793A "}[$.status]}${$.text}`);console.log(d?`\u4E0B\u4E00\u6B65\uFF1A${d}`:"\u4E00\u5207\u6B63\u5E38\u3002")}w||(process.exitCode=1)}export{V as examine,se as run,z as writable};
@@ -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,b,c}from"./chunk-NF4MMOUB.mjs";import"./chunk-ZNGGDUZI.mjs";import"./chunk-B6RAGF4R.mjs";import"./chunk-5TLLIZT7.mjs";import"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";export{a as entryNamed,c as run,b as trashEntry};
@@ -1,8 +1,8 @@
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 g}from"./chunk-HYMEEXKN.mjs";import{createRequire as re}from"node:module";import{typescriptFile as ae}from"../browser/shared/paths.mjs";var ce=re(import.meta.url),B=null;function fe(){return B??=ce(ae??"typescript"),B}var b=new Proxy({},{get:(e,n)=>fe()[n]});import _ from"node:fs/promises";import h from"node:path";import{COMPONENTS as D,instancesOf as ue}from"../browser/shared/components/index.mjs";import{PACKAGE_MARK as q}from"../browser/shared/components/installed.mjs";import{MATH_IGNORED_TAGS as pe}from"../browser/shared/components/math.mjs";import{attr as x,elementsOf as O,walk as y}from"../browser/shared/html-tree.mjs";import I from"node:path";import de from"node:vm";var L=()=>{throw new Error("esbuild is not in the release: Gallery 0.2.3 calls it only in a source checkout")},Le=L,J=L;var Te=new Proxy({},{get:L});import{projectRoot as le}from"../browser/shared/paths.mjs";var T=I.join(le,"src","shared","components","index.mjs");function F(e){let{outputFiles:n}=J({stdin:{contents:`import { FLOWS, FLOW_BLOCKS, runtimeDescriptions } from ${JSON.stringify(e)}; module.exports = { descriptions: runtimeDescriptions(), flows: FLOWS, blockFlows: FLOW_BLOCKS };`,resolveDir:I.dirname(e),loader:"js"},bundle:!0,write:!1,format:"cjs",platform:"node",logLevel:"silent"}),s={module:{exports:null}};return de.runInNewContext(n[0].text,s),JSON.parse(JSON.stringify(s.module.exports))}var W=(e=T)=>F(e).descriptions,G=(e=T)=>F(e).flows,U=(e=T)=>F(e).blockFlows;import{kitPublicDirectory as me,projectRoot as H,release as Y,vendorDirectory as z}from"../browser/shared/paths.mjs";var P=h.join(H,"node_modules"),he=h.join(P,"d3","dist","d3.min.js"),S=Y?h.join(z,"katex"):h.join(P,"katex","dist"),xe=h.join(S,"fonts"),He=h.join(S,"contrib","mhchem.min.js"),u=[{id:"styles",file:"report.css",build:{styles:"styles/index.css"},always:!0},{id:"katex-styles",vendor:{path:"/vendor/katex/katex.min.css",source:h.join(S,"katex.min.css")}},{id:"runtime",file:"runtime.js",build:{bundle:"runtime/index.js",options:()=>({minify:!1,define:{__COMPONENT_RUNTIME__:JSON.stringify(W()),__COMPONENT_FLOWS__:JSON.stringify(G()),__COMPONENT_BLOCK_FLOWS__:JSON.stringify(U())}})},api:"DocKit",always:!0},{id:"code",file:"code.js",build:{bundle:"code.js",options:{minify:!0,legalComments:"inline"}},api:"DocCode",after:["runtime"]},{id:"state",file:"state.js",build:{read:"state.js"},api:"DocState",always:!0},{id:"sheets",file:"sheets.js",build:{read:"sheets.js"},api:"DocSheets",after:["runtime","state"]},{id:"tokens",file:"tokens.js",build:{read:"tokens.js"},api:"DocTokens",always:!0},{id:"ui",file:"ui.js",build:{bundle:"ui.js",options:{minify:!1}},added:!0,after:["runtime","state","tokens"]},{id:"dialogs",file:"dialogs.js",build:{read:"dialogs.js"},api:"DocDialogs",after:["runtime"]},{id:"katex",vendor:{path:"/vendor/katex/katex.min.js",source:h.join(S,"katex.min.js")},umd:!0},{id:"katex-auto-render",vendor:{path:"/vendor/katex/auto-render.min.js",source:h.join(S,"contrib","auto-render.min.js")},umd:!0,after:["katex"]},{id:"math",file:"math.js",build:{bundle:"math-bundle.js",options:{minify:!1,legalComments:"inline",alias:{katex:h.join(H,"src","render","kit","page-katex.js")},nodePaths:[h.join(P,"katex")]}},api:"DocMath",after:["runtime","katex-styles","katex","katex-auto-render"]},{id:"d3",vendor:{path:"/vendor/d3.v7.9.0.min.js",source:he},api:"d3",umd:!0},{id:"charts",file:"charts.js",build:{bundle:"charts/index.js",options:{minify:!1}},api:"DocCharts",after:["runtime","tokens"]},{id:"tables",file:"tables.js",build:{bundle:"tables/index.js",options:{minify:!1}},api:"DocTables",after:["runtime"]},{id:"board-styles",file:"board.css",build:{styles:"board/index.css"},page:!0},{id:"board",file:"board.js",build:{bundle:"board/index.js",options:{minify:!1}},page:!0}],m=e=>e.file?`/kit/${e.file}`:e.vendor.path,ge=e=>e.file?h.join(me,e.file):h.join(z,...e.vendor.path.split("/").slice(2));if(Y)for(let e of u)e.vendor&&(e.vendor.source=ge(e));var k=e=>m(e).endsWith(".css"),E=e=>e.file?"data-doc-kit":"data-doc-vendor",C=e=>u.find(n=>n.id===e),w=(e,n=m(e))=>k(e)?`<link rel="stylesheet" href="${n}" ${E(e)}="${e.id}">`:`<script src="${n}" ${E(e)}="${e.id}"></script>`,we=u.map(e=>({id:e.id,tag:w(e),always:!!e.always,element:k(e)?"style":"script",attribute:E(e)}));function Ye(e,n=m){let s=new Set,i=t=>{s.has(t)||(s.add(t),C(t)?.after?.forEach(i))};return e.forEach(i),u.filter(t=>s.has(t.id)&&!t.always&&!t.added).map(t=>w(t,n(t)))}function ye(e=u,n=D){let s=[],i=e.map(t=>t.id);for(let t of new Set(i.filter((a,o)=>i.indexOf(a)!==o)))s.push(`the asset "${t}" is listed twice`);for(let t of e){!!t.file==!!t.vendor&&s.push(`the asset "${t.id}" is a kit file (file) or a vendor file (vendor), one of them`),t.file&&!["read","bundle","styles"].some(o=>typeof t.build?.[o]=="string")&&s.push(`the kit file "${t.file}" does not say how it is made (build: read, bundle or styles)`),t.vendor&&!(t.vendor.path&&t.vendor.source)&&s.push(`the vendor asset "${t.id}" needs its public path and its source`);for(let o of t.after??[])i.includes(o)?i.indexOf(o)>i.indexOf(t.id)&&s.push(`the asset "${t.id}" loads after "${o}", which the list puts after it`):s.push(`the asset "${t.id}" loads after "${o}", which is no asset`);let a=n.filter(o=>(o.assets??[]).includes(t.id));!t.always&&!t.api&&!t.added&&!t.page&&a.length===0&&s.push(`no report would keep the asset "${t.id}": it is not always kept, defines no global and no component needs it`)}for(let t of n)for(let a of t.assets??[])i.includes(a)||s.push(`the component "${t.id}" needs "${a}", which is no asset`);return s}{let e=ye();if(e.length>0)throw new Error(`src/render/assets.mjs: ${e.join("; ")}`)}var K=/^(?:|module|(?:text|application)\/(?:x-)?(?:javascript|ecmascript)|text\/javascript1\.[0-5]|text\/(?:jscript|livescript))$/,be=/^application\/(?:\S+\+)?json$/,N=e=>(x(e,"type")??"").trim().toLowerCase();function V(e){let n=b.createSourceFile("report.js",e,b.ScriptTarget.Latest,!1,b.ScriptKind.JS),s=[],i=[n];for(;i.length>0;){let t=i.pop();if(t.kind>=b.SyntaxKind.FirstJSDocNode&&t.kind<=b.SyntaxKind.LastJSDocNode)continue;let a=t.getChildren(n);a.length===0&&s.push(e.slice(t.getStart(n),t.end));for(let o=a.length-1;o>=0;o-=1)i.push(a[o])}return s.join(" ")}var Q=e=>new RegExp(`\\b(?:${e.filter(n=>n.api).map(n=>n.api).join("|")})\\b`);function $e(e,n){let s=[],i=t=>{n.test(t)&&s.push(V(t))};return y(e,t=>{t.tagName==="script"&&x(t,"src")===void 0&&K.test(N(t))&&i(t.childNodes.map(a=>a.value??"").join(""));for(let{name:a,value:o}of t.attrs??[]){if(/^on/.test(a)){i(o);continue}let c=o.replace(/[\t\n\r]/g,"").replace(/^[\x00-\x20]+/,"");if(!/^javascript:/i.test(c))continue;let r=c.slice(11);try{r=decodeURIComponent(r)}catch{}i(r)}}),s.join(`
2
+ import{a as g}from"./chunk-HYMEEXKN.mjs";import _ from"node:fs/promises";import h from"node:path";import{createRequire as re}from"node:module";import{typescriptFile as ae}from"../browser/shared/paths.mjs";var ce=re(import.meta.url),B=null;function fe(){return B??=ce(ae??"typescript"),B}var b=new Proxy({},{get:(e,n)=>fe()[n]});import{COMPONENTS as D,instancesOf as ue}from"../browser/shared/components/index.mjs";import{PACKAGE_MARK as q}from"../browser/shared/components/installed.mjs";import{MATH_IGNORED_TAGS as pe}from"../browser/shared/components/math.mjs";import{attr as x,elementsOf as O,walk as y}from"../browser/shared/html-tree.mjs";import I from"node:path";import de from"node:vm";var L=()=>{throw new Error("esbuild is not in the release: Gallery 0.2.4 calls it only in a source checkout")},Le=L,J=L;var Te=new Proxy({},{get:L});import{projectRoot as le}from"../browser/shared/paths.mjs";var T=I.join(le,"src","shared","components","index.mjs");function F(e){let{outputFiles:n}=J({stdin:{contents:`import { FLOWS, FLOW_BLOCKS, runtimeDescriptions } from ${JSON.stringify(e)}; module.exports = { descriptions: runtimeDescriptions(), flows: FLOWS, blockFlows: FLOW_BLOCKS };`,resolveDir:I.dirname(e),loader:"js"},bundle:!0,write:!1,format:"cjs",platform:"node",logLevel:"silent"}),s={module:{exports:null}};return de.runInNewContext(n[0].text,s),JSON.parse(JSON.stringify(s.module.exports))}var W=(e=T)=>F(e).descriptions,G=(e=T)=>F(e).flows,U=(e=T)=>F(e).blockFlows;import{kitPublicDirectory as me,projectRoot as H,release as Y,vendorDirectory as z}from"../browser/shared/paths.mjs";var P=h.join(H,"node_modules"),he=h.join(P,"d3","dist","d3.min.js"),S=Y?h.join(z,"katex"):h.join(P,"katex","dist"),xe=h.join(S,"fonts"),He=h.join(S,"contrib","mhchem.min.js"),u=[{id:"styles",file:"report.css",build:{styles:"styles/index.css"},always:!0},{id:"katex-styles",vendor:{path:"/vendor/katex/katex.min.css",source:h.join(S,"katex.min.css")}},{id:"runtime",file:"runtime.js",build:{bundle:"runtime/index.js",options:()=>({minify:!1,define:{__COMPONENT_RUNTIME__:JSON.stringify(W()),__COMPONENT_FLOWS__:JSON.stringify(G()),__COMPONENT_BLOCK_FLOWS__:JSON.stringify(U())}})},api:"DocKit",always:!0},{id:"code",file:"code.js",build:{bundle:"code.js",options:{minify:!0,legalComments:"inline"}},api:"DocCode",after:["runtime"]},{id:"state",file:"state.js",build:{read:"state.js"},api:"DocState",always:!0},{id:"sheets",file:"sheets.js",build:{read:"sheets.js"},api:"DocSheets",after:["runtime","state"]},{id:"tokens",file:"tokens.js",build:{read:"tokens.js"},api:"DocTokens",always:!0},{id:"ui",file:"ui.js",build:{bundle:"ui.js",options:{minify:!1}},added:!0,after:["runtime","state","tokens"]},{id:"dialogs",file:"dialogs.js",build:{read:"dialogs.js"},api:"DocDialogs",after:["runtime"]},{id:"katex",vendor:{path:"/vendor/katex/katex.min.js",source:h.join(S,"katex.min.js")},umd:!0},{id:"katex-auto-render",vendor:{path:"/vendor/katex/auto-render.min.js",source:h.join(S,"contrib","auto-render.min.js")},umd:!0,after:["katex"]},{id:"math",file:"math.js",build:{bundle:"math-bundle.js",options:{minify:!1,legalComments:"inline",alias:{katex:h.join(H,"src","render","kit","page-katex.js")},nodePaths:[h.join(P,"katex")]}},api:"DocMath",after:["runtime","katex-styles","katex","katex-auto-render"]},{id:"d3",vendor:{path:"/vendor/d3.v7.9.0.min.js",source:he},api:"d3",umd:!0},{id:"charts",file:"charts.js",build:{bundle:"charts/index.js",options:{minify:!1}},api:"DocCharts",after:["runtime","tokens"]},{id:"tables",file:"tables.js",build:{bundle:"tables/index.js",options:{minify:!1}},api:"DocTables",after:["runtime"]},{id:"board-styles",file:"board.css",build:{styles:"board/index.css"},page:!0},{id:"board",file:"board.js",build:{bundle:"board/index.js",options:{minify:!1}},page:!0}],m=e=>e.file?`/kit/${e.file}`:e.vendor.path,ge=e=>e.file?h.join(me,e.file):h.join(z,...e.vendor.path.split("/").slice(2));if(Y)for(let e of u)e.vendor&&(e.vendor.source=ge(e));var k=e=>m(e).endsWith(".css"),E=e=>e.file?"data-doc-kit":"data-doc-vendor",C=e=>u.find(n=>n.id===e),w=(e,n=m(e))=>k(e)?`<link rel="stylesheet" href="${n}" ${E(e)}="${e.id}">`:`<script src="${n}" ${E(e)}="${e.id}"></script>`,we=u.map(e=>({id:e.id,tag:w(e),always:!!e.always,element:k(e)?"style":"script",attribute:E(e)}));function Ye(e,n=m){let s=new Set,i=t=>{s.has(t)||(s.add(t),C(t)?.after?.forEach(i))};return e.forEach(i),u.filter(t=>s.has(t.id)&&!t.always&&!t.added).map(t=>w(t,n(t)))}function ye(e=u,n=D){let s=[],i=e.map(t=>t.id);for(let t of new Set(i.filter((a,o)=>i.indexOf(a)!==o)))s.push(`the asset "${t}" is listed twice`);for(let t of e){!!t.file==!!t.vendor&&s.push(`the asset "${t.id}" is a kit file (file) or a vendor file (vendor), one of them`),t.file&&!["read","bundle","styles"].some(o=>typeof t.build?.[o]=="string")&&s.push(`the kit file "${t.file}" does not say how it is made (build: read, bundle or styles)`),t.vendor&&!(t.vendor.path&&t.vendor.source)&&s.push(`the vendor asset "${t.id}" needs its public path and its source`);for(let o of t.after??[])i.includes(o)?i.indexOf(o)>i.indexOf(t.id)&&s.push(`the asset "${t.id}" loads after "${o}", which the list puts after it`):s.push(`the asset "${t.id}" loads after "${o}", which is no asset`);let a=n.filter(o=>(o.assets??[]).includes(t.id));!t.always&&!t.api&&!t.added&&!t.page&&a.length===0&&s.push(`no report would keep the asset "${t.id}": it is not always kept, defines no global and no component needs it`)}for(let t of n)for(let a of t.assets??[])i.includes(a)||s.push(`the component "${t.id}" needs "${a}", which is no asset`);return s}{let e=ye();if(e.length>0)throw new Error(`src/render/assets.mjs: ${e.join("; ")}`)}var K=/^(?:|module|(?:text|application)\/(?:x-)?(?:javascript|ecmascript)|text\/javascript1\.[0-5]|text\/(?:jscript|livescript))$/,be=/^application\/(?:\S+\+)?json$/,N=e=>(x(e,"type")??"").trim().toLowerCase();function V(e){let n=b.createSourceFile("report.js",e,b.ScriptTarget.Latest,!1,b.ScriptKind.JS),s=[],i=[n];for(;i.length>0;){let t=i.pop();if(t.kind>=b.SyntaxKind.FirstJSDocNode&&t.kind<=b.SyntaxKind.LastJSDocNode)continue;let a=t.getChildren(n);a.length===0&&s.push(e.slice(t.getStart(n),t.end));for(let o=a.length-1;o>=0;o-=1)i.push(a[o])}return s.join(" ")}var Q=e=>new RegExp(`\\b(?:${e.filter(n=>n.api).map(n=>n.api).join("|")})\\b`);function $e(e,n){let s=[],i=t=>{n.test(t)&&s.push(V(t))};return y(e,t=>{t.tagName==="script"&&x(t,"src")===void 0&&K.test(N(t))&&i(t.childNodes.map(a=>a.value??"").join(""));for(let{name:a,value:o}of t.attrs??[]){if(/^on/.test(a)){i(o);continue}let c=o.replace(/[\t\n\r]/g,"").replace(/^[\x00-\x20]+/,"");if(!/^javascript:/i.test(c))continue;let r=c.slice(11);try{r=decodeURIComponent(r)}catch{}i(r)}}),s.join(`
3
3
  `)}function je(e,n){let s=[],i=(o,c)=>{for(let r of o.childNodes??[]){let f=r.sourceCodeLocation;r.nodeName==="#comment"||c&&r.nodeName==="#text"?f&&s.push([f.startOffset,f.endOffset]):r.tagName==="script"?i(r,be.test(N(r))):r.tagName&&i(r.content??r,c||pe.includes(r.tagName))}};i(e,!1);let t="",a=0;for(let[o,c]of s.sort((r,f)=>r[0]-f[0]))o<a||(t+=`${n.slice(a,o)} `,a=c);return t+n.slice(a)}function R(e,n=u,s=D){let i=n.reduce((f,d)=>f.replaceAll(w(d),""),e),t=g(i),a=je(t,i),o=$e(t,Q(n)),c=new Set,r=f=>{c.has(f)||(c.add(f),(n.find(d=>d.id===f)?.after??[]).forEach(r))};for(let f of s){if(!(f.assets??[]).length)continue;((f.uses??[]).some(l=>l.test(a))||f.match&&ue(t,f).length>0)&&f.assets.forEach(r)}for(let f of n)f.api&&new RegExp(`\\b${f.api}\\b`).test(o)&&r(f.id);return c}function ze(e,n=D){let s=R(e,u,n),i=[];for(let t of u){let a=w(t);if(t.always||t.added||s.has(t.id)||!e.includes(a))continue;let o=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp(`[ \\t]*${o}[ \\t]*\\r?\\n?`),""),i.push(t.id)}return{html:e,removed:i,used:s}}function M(e,n){let s=[];return y(n,i=>{let t=Z(i),a=t===void 0?void 0:u.find(c=>m(c)===t.trim()),o=i.sourceCodeLocation;!a||!o||s.push({asset:a,start:o.startOffset,end:o.endOffset,line:o.startLine,exact:e.slice(o.startOffset,o.endOffset)===w(a)})},{inTemplates:!1}),s}var X=e=>e.tagName==="style"||e.tagName==="link"&&(x(e,"rel")??"").toLowerCase().split(/\s+/).includes("stylesheet"),Z=e=>e.tagName==="script"?x(e,"src"):X(e)?x(e,"href"):void 0,j=e=>!!e.sourceCodeLocation,A=e=>e.includes(`\r
4
4
  `)?`\r
5
5
  `:`
6
6
  `;function $(e,n,{closing:s=!1}={}){let i=n===0?0:e.lastIndexOf(`
7
7
  `,n-1)+1,t=e.slice(i,n);if(!/^[ \t]*$/.test(t))return{at:n,text:o=>o};let a=s?`${t} `:t;return{at:i,text:o=>`${a}${o}${A(e)}`}}function v(e,n){let s=/^[ \t]*/.exec(e.slice(e.lastIndexOf(`
8
- `,n-1)+1))[0];return{at:n,text:i=>`${A(e)}${s}${i}`}}function ee(e){let n;return y(e,s=>{!n&&s.tagName==="main"&&(n=s)},{inTemplates:!1}),n}var ke="http://www.w3.org/1999/xhtml";function Oe(e){let n=e;for(let s=e.parentNode;s?.tagName;s=s.parentNode)s.namespaceURI!==ke&&(n=s);return n}function te(e,n,s){let i=O(n).find(o=>o.tagName==="html"),t=O(i??{}).find(o=>o.tagName==="head"),a=O(i??{}).find(o=>o.tagName==="body");if(s){let o=O(t??{}).filter(j),c=o.find(X);if(c)return $(e,c.sourceCodeLocation.startOffset);if(t?.sourceCodeLocation?.endTag)return $(e,t.sourceCodeLocation.endTag.startOffset,{closing:!0});if(o.length>0)return v(e,o.at(-1).sourceCodeLocation.endOffset);if(t?.sourceCodeLocation)return v(e,t.sourceCodeLocation.startTag.endOffset);let r=a?.sourceCodeLocation?.startTag?.startOffset??O(a??{}).find(j)?.sourceCodeLocation.startOffset;if(r!==void 0)return $(e,r)}else{let o=ee(n),c=d=>{for(let l=d.parentNode;l;l=l.parentNode)if(l===o)return!1;return!o?.sourceCodeLocation||d.sourceCodeLocation.startOffset>o.sourceCodeLocation.startOffset},r;if(y(a??{},d=>{!r&&d.tagName==="script"&&j(d)&&K.test(N(d))&&c(d)&&(r=d)},{inTemplates:!1}),r)return $(e,Oe(r).sourceCodeLocation.startOffset);let f=a?.sourceCodeLocation?.endTag??i?.sourceCodeLocation?.endTag;if(f)return $(e,f.startOffset,{closing:!0})}return{at:e.length,text:o=>`${A(e)}${o}`}}function oe(e,n,{free:s}){let i=M(e,n),t=new Map;for(let a of[!0,!1]){let o=u.filter(d=>k(d)===a),c=d=>i.find(l=>l.asset===d),r=o.map(c).find(Boolean),f=r?$(e,r.start):s?te(e,n,a):null;for(let d of o){let l=c(d);l?(t.set(d.id,{at:l.start,written:l}),f=v(e,l.end)):f&&t.set(d.id,f)}}return t}function ne(e,n,{tree:s=g(e),free:i,href:t=m}){let a=[];for(let[r,f]of oe(e,s,{free:i})){let d=C(r);f.written?f.written.exact&&t(d)!==m(d)&&a.push({at:f.written.start,end:f.written.end,text:w(d,t(d))}):n.has(r)&&a.push({at:f.at,end:f.at,text:f.text(w(d,t(d)))})}if(a.length===0)return e;a.sort((r,f)=>r.at-f.at);let o="",c=0;for(let{at:r,end:f,text:d}of a)o+=e.slice(c,r)+d,c=f;return o+e.slice(c)}function Ve(e,{used:n=R(e),href:s=m,page:i=!1}={}){let t=g(e),a=x(ee(t)??{},"data-doc-id")!==void 0,o=new Set(u.filter(c=>c.always||n.has(c.id)||c.added&&(a||i)||c.page&&i).map(c=>c.id));return ne(e,o,{tree:t,free:!0,href:s})}function Qe(e){let n=R(e);return ne(e,new Set(u.filter(s=>!s.always&&!s.added&&n.has(s.id)).map(s=>s.id)),{free:!1})}function Xe(e,{styles:n,scripts:s}){let i=g(e),t=[];y(i,r=>{let f=u.find(d=>m(d)===Z(r)?.trim().split("?")[0]);f&&j(r)&&t.push({style:k(f),end:r.sourceCodeLocation.endOffset})},{inTemplates:!1});let a=[[!0,n],[!1,s]].filter(([,r])=>r.length>0).map(([r,f])=>{let d=t.filter(p=>p.style===r).at(-1),l=d?v(e,d.end):te(e,i,r);return{at:l.at,text:f.map(l.text).join("")}}),o="",c=0;for(let{at:r,text:f}of a.sort((d,l)=>d.at-l.at))o+=e.slice(c,r)+f,c=r;return o+e.slice(c)}function Ze(e,n=g(e)){let s=[],i=[];if(y(n,o=>{let c=["data-doc-kit","data-doc-vendor"].find(r=>x(o,r)?.endsWith("-inline"))??(x(o,q)===void 0?void 0:q);c&&j(o)&&i.push({line:o.sourceCodeLocation.startLine,mark:`${c}="${x(o,c)}"`})},{inTemplates:!1}),i.length>0){let o=i.length>1?`, and ${i.length-1} more on line${i.length>2?"s":""} ${se(i.slice(1).map(({line:c})=>c))}`:"";s.push(`line ${i[0].line}: an export's inline copy of the kit (${i[0].mark}${o}), which a document's source never holds (the kit's tags are put in as the document is shown, so it would load twice): bring an exported file in with \u5BFC\u5165 instead of copying it in`)}let t=M(e,n);for(let{asset:o,line:c,exact:r}of t)r||s.push(`line ${c}: ${m(o)} is not loaded by the kit's own tag, ${w(o)}: take the tag out (the kit's tags are put in as the document is shown and exported)`);for(let o of u){let c=t.filter(r=>r.asset===o).map(r=>r.line);c.length>1&&s.push(`${m(o)} is loaded ${c.length} times (lines ${c.join(", ")}): keep one tag, or none`)}let a=o=>t.find(c=>c.asset===o);for(let o of u){let c=a(o);if(c)for(let r of o.after??[]){let f=a(C(r));f&&f.start>c.start&&s.push(`line ${c.line}: ${m(f.asset)} (line ${f.line}) must load before ${m(o)}`)}}return[...new Set(s)]}var se=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`:e[0];function et(e,n=g(e)){let s=Q(u),i=[],t;return y(n,a=>{if(a.tagName!=="script"||x(a,"src")!==void 0||!j(a)||N(a)==="module"||!K.test(N(a)))return;let o=a.childNodes.map(p=>p.value??"").join("");if(!s.test(o))return;let c=V(o);t??=oe(e,n,{free:!0});let{startOffset:r,startLine:f}=a.sourceCodeLocation,d=u.filter(p=>p.api&&new RegExp(`\\b${p.api}\\b`).test(c)&&t.get(p.id).at>r),l=d.filter(p=>!t.get(p.id).written);l.length>0&&i.push(`line ${f}: this script names ${se(l.map(p=>p.api))} before the kit's scripts load (they are put in after </main>): move the script after </main>`);for(let p of d.filter(ie=>t.get(ie.id).written))i.push(`line ${f}: this script names ${p.api} before ${m(p)} loads (line ${t.get(p.id).written.line}): move the script after that tag`)},{inTemplates:!1}),i}function tt(e,n){let s=new Set,i="",t=0;for(let{asset:a,start:o,end:c,exact:r}of M(e,g(e)))!r||s.has(a.id)||(s.add(a.id),i+=e.slice(t,o)+n(we.find(f=>f.id===a.id)),t=c);return i+e.slice(t)}var ot=new Set(u.filter(e=>!k(e)).map(m)),nt=new Set(u.filter(k).map(m));async function Se({inlineFonts:e=!1}={}){let n=await _.readFile(C("katex-styles").vendor.source,"utf8");if(n=n.replace(/src:url\((fonts\/[^)]+\.woff2)\) format\("woff2"\),url\(fonts\/[^)]+\.woff\) format\("woff"\),url\(fonts\/[^)]+\.ttf\) format\("truetype"\)/g,'src:url($1) format("woff2")'),!e)return n;let s=[...new Set([...n.matchAll(/url\(fonts\/([^)]+\.woff2)\)/g)].map(i=>i[1]))];for(let i of s){let t=await _.readFile(h.join(xe,i));n=n.replaceAll(`url(fonts/${i})`,`url(data:font/woff2;base64,${t.toString("base64")})`)}return n}function st(e,{inline:n=!1}={}){return e.id==="katex-styles"?Se({inlineFonts:n}):_.readFile(e.vendor.source,"utf8")}export{b as a,Le as b,xe as c,He as d,u as e,m as f,ge as g,Ye as h,ze as i,Ve as j,Qe as k,Xe as l,Ze as m,et as n,tt as o,ot as p,nt as q,st as r};
8
+ `,n-1)+1))[0];return{at:n,text:i=>`${A(e)}${s}${i}`}}function ee(e){let n;return y(e,s=>{!n&&s.tagName==="main"&&(n=s)},{inTemplates:!1}),n}var ke="http://www.w3.org/1999/xhtml";function Oe(e){let n=e;for(let s=e.parentNode;s?.tagName;s=s.parentNode)s.namespaceURI!==ke&&(n=s);return n}function te(e,n,s){let i=O(n).find(o=>o.tagName==="html"),t=O(i??{}).find(o=>o.tagName==="head"),a=O(i??{}).find(o=>o.tagName==="body");if(s){let o=O(t??{}).filter(j),c=o.find(X);if(c)return $(e,c.sourceCodeLocation.startOffset);if(t?.sourceCodeLocation?.endTag)return $(e,t.sourceCodeLocation.endTag.startOffset,{closing:!0});if(o.length>0)return v(e,o.at(-1).sourceCodeLocation.endOffset);if(t?.sourceCodeLocation)return v(e,t.sourceCodeLocation.startTag.endOffset);let r=a?.sourceCodeLocation?.startTag?.startOffset??O(a??{}).find(j)?.sourceCodeLocation.startOffset;if(r!==void 0)return $(e,r)}else{let o=ee(n),c=d=>{for(let l=d.parentNode;l;l=l.parentNode)if(l===o)return!1;return!o?.sourceCodeLocation||d.sourceCodeLocation.startOffset>o.sourceCodeLocation.startOffset},r;if(y(a??{},d=>{!r&&d.tagName==="script"&&j(d)&&K.test(N(d))&&c(d)&&(r=d)},{inTemplates:!1}),r)return $(e,Oe(r).sourceCodeLocation.startOffset);let f=a?.sourceCodeLocation?.endTag??i?.sourceCodeLocation?.endTag;if(f)return $(e,f.startOffset,{closing:!0})}return{at:e.length,text:o=>`${A(e)}${o}`}}function oe(e,n,{free:s}){let i=M(e,n),t=new Map;for(let a of[!0,!1]){let o=u.filter(d=>k(d)===a),c=d=>i.find(l=>l.asset===d),r=o.map(c).find(Boolean),f=r?$(e,r.start):s?te(e,n,a):null;for(let d of o){let l=c(d);l?(t.set(d.id,{at:l.start,written:l}),f=v(e,l.end)):f&&t.set(d.id,f)}}return t}function ne(e,n,{tree:s=g(e),free:i,href:t=m}){let a=[];for(let[r,f]of oe(e,s,{free:i})){let d=C(r);f.written?f.written.exact&&t(d)!==m(d)&&a.push({at:f.written.start,end:f.written.end,text:w(d,t(d))}):n.has(r)&&a.push({at:f.at,end:f.at,text:f.text(w(d,t(d)))})}if(a.length===0)return e;a.sort((r,f)=>r.at-f.at);let o="",c=0;for(let{at:r,end:f,text:d}of a)o+=e.slice(c,r)+d,c=f;return o+e.slice(c)}function Ve(e,{used:n=R(e),href:s=m,page:i=!1}={}){let t=g(e),a=x(ee(t)??{},"data-doc-id")!==void 0,o=new Set(u.filter(c=>c.always||n.has(c.id)||c.added&&(a||i)||c.page&&i).map(c=>c.id));return ne(e,o,{tree:t,free:!0,href:s})}function Qe(e){let n=R(e);return ne(e,new Set(u.filter(s=>!s.always&&!s.added&&n.has(s.id)).map(s=>s.id)),{free:!1})}function Xe(e,{styles:n,scripts:s}){let i=g(e),t=[];y(i,r=>{let f=u.find(d=>m(d)===Z(r)?.trim().split("?")[0]);f&&j(r)&&t.push({style:k(f),end:r.sourceCodeLocation.endOffset})},{inTemplates:!1});let a=[[!0,n],[!1,s]].filter(([,r])=>r.length>0).map(([r,f])=>{let d=t.filter(p=>p.style===r).at(-1),l=d?v(e,d.end):te(e,i,r);return{at:l.at,text:f.map(l.text).join("")}}),o="",c=0;for(let{at:r,text:f}of a.sort((d,l)=>d.at-l.at))o+=e.slice(c,r)+f,c=r;return o+e.slice(c)}function Ze(e,n=g(e)){let s=[],i=[];if(y(n,o=>{let c=["data-doc-kit","data-doc-vendor"].find(r=>x(o,r)?.endsWith("-inline"))??(x(o,q)===void 0?void 0:q);c&&j(o)&&i.push({line:o.sourceCodeLocation.startLine,mark:`${c}="${x(o,c)}"`})},{inTemplates:!1}),i.length>0){let o=i.length>1?`, and ${i.length-1} more on line${i.length>2?"s":""} ${se(i.slice(1).map(({line:c})=>c))}`:"";s.push(`line ${i[0].line}: an export's inline copy of the kit (${i[0].mark}${o}), which a document's source never holds (the kit's tags are put in as the document is shown, so it would load twice): bring an exported file in with \u5BFC\u5165 instead of copying it in`)}let t=M(e,n);for(let{asset:o,line:c,exact:r}of t)r||s.push(`line ${c}: ${m(o)} is not loaded by the kit's own tag, ${w(o)}: take the tag out (the kit's tags are put in as the document is shown and exported)`);for(let o of u){let c=t.filter(r=>r.asset===o).map(r=>r.line);c.length>1&&s.push(`${m(o)} is loaded ${c.length} times (lines ${c.join(", ")}): keep one tag, or none`)}let a=o=>t.find(c=>c.asset===o);for(let o of u){let c=a(o);if(c)for(let r of o.after??[]){let f=a(C(r));f&&f.start>c.start&&s.push(`line ${c.line}: ${m(f.asset)} (line ${f.line}) must load before ${m(o)}`)}}return[...new Set(s)]}var se=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`:e[0];function et(e,n=g(e)){let s=Q(u),i=[],t;return y(n,a=>{if(a.tagName!=="script"||x(a,"src")!==void 0||!j(a)||N(a)==="module"||!K.test(N(a)))return;let o=a.childNodes.map(p=>p.value??"").join("");if(!s.test(o))return;let c=V(o);t??=oe(e,n,{free:!0});let{startOffset:r,startLine:f}=a.sourceCodeLocation,d=u.filter(p=>p.api&&new RegExp(`\\b${p.api}\\b`).test(c)&&t.get(p.id).at>r),l=d.filter(p=>!t.get(p.id).written);l.length>0&&i.push(`line ${f}: this script names ${se(l.map(p=>p.api))} before the kit's scripts load (they are put in after </main>): move the script after </main>`);for(let p of d.filter(ie=>t.get(ie.id).written))i.push(`line ${f}: this script names ${p.api} before ${m(p)} loads (line ${t.get(p.id).written.line}): move the script after that tag`)},{inTemplates:!1}),i}function tt(e,n){let s=new Set,i="",t=0;for(let{asset:a,start:o,end:c,exact:r}of M(e,g(e)))!r||s.has(a.id)||(s.add(a.id),i+=e.slice(t,o)+n(we.find(f=>f.id===a.id)),t=c);return i+e.slice(t)}var ot=new Set(u.filter(e=>!k(e)).map(m)),nt=new Set(u.filter(k).map(m));async function Se({inlineFonts:e=!1}={}){let n=await _.readFile(C("katex-styles").vendor.source,"utf8");if(n=n.replace(/src:url\((fonts\/[^)]+\.woff2)\) format\("woff2"\),url\(fonts\/[^)]+\.woff\) format\("woff"\),url\(fonts\/[^)]+\.ttf\) format\("truetype"\)/g,'src:url($1) format("woff2")'),!e)return n;let s=[...new Set([...n.matchAll(/url\(fonts\/([^)]+\.woff2)\)/g)].map(i=>i[1]))];for(let i of s){let t=await _.readFile(h.join(xe,i));n=n.replaceAll(`url(fonts/${i})`,`url(data:font/woff2;base64,${t.toString("base64")})`)}return n}function st(e,{inline:n=!1}={}){return e.id==="katex-styles"?Se({inlineFonts:n}):_.readFile(e.vendor.source,"utf8")}export{b as a,Le as b,he as c,xe as d,He as e,u as f,m as g,ge as h,w as i,we as j,Ye as k,ye as l,R as m,ze as n,Ve as o,Qe as p,Xe as q,Ze as r,et as s,tt as t,ot as u,nt as v,Se as w,st as x};
@@ -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}from"./chunk-QP7BOHE4.mjs";import"./chunk-GMJD7ID3.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";export{a as documentsOf,c as run,b as when};
2
+ import"./chunk-5L7RYZCL.mjs";var e=()=>{throw new Error("@vitejs/plugin-react is not in the release: Gallery 0.2.4 calls it only in a source checkout")},t=new Proxy({},{get:e});export{t as default};
@@ -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{b as g,i as T}from"./chunk-L4WLQYFC.mjs";import{workspaceBase as A}from"../browser/shared/service-location.mjs";import M from"node:fs/promises";import{listExtensions as W}from"../browser/shared/extensions.mjs";import{ancestorsIn as B,moveDocument as G,outlineAndFile as J,ownsOutline as K,readOutline as D,validOutline as U,withOutlineLock as q,writeOutline as z,writtenAs as R}from"../browser/shared/outline.mjs";import{DOCS as v,columnWorkspaceId as X,groupOfTop as H,isForeign as L,isTop as Q,topIn as V,topOf as E}from"../browser/shared/outline-shape.mjs";import{draftFacts as Y,draftOf as Z,registeredIds as ee,workspaceNames as te}from"../browser/shared/drafts.mjs";import{reportsDirectory as l}from"../browser/shared/paths.mjs";import{findPreviewServer as x}from"../browser/shared/preview-server.mjs";import{roleOf as ne}from"../browser/shared/reports.mjs";import{nameStops as oe,workspaceName as se}from"../browser/shared/workspace-name.mjs";import{workspaceId as re,workspaceKey as k}from"../browser/shared/workspace-registry.mjs";import{defaultWorkspace as ie,documentDirectory as $,documentFiles as ae,layoutOf as ce,pageSlug as le,readLink as ue}from"../browser/shared/workspace.mjs";async function Le(e=l,{others:t=k(e)===k(l)}={}){let{outline:{children:n,groups:o,links:s,shown:r},others:i}=await J(e,{others:t}),d=de(e,o,r),c=new Set(r.map(({id:a})=>a)),h=o.map(a=>({...a,name:d.get(a.id)??null,...t&&a.workspace&&!c.has(a.workspace)?{away:!0}:{}})),y=h.filter(a=>!a.extension),F=await W(e),N=Object.values(n).flat(),S=a=>typeof a=="string"?a.replace(/\s+/g," ").trim():"",I=N.some(L)?ee():null,_=new Map(await Promise.all(N.map(async a=>{if(L(a)){let f=Z(a),b=i.find(({id:P})=>P===f?.ws)?.facts.get(f.slug),m=b?{...b,missing:null}:await Y(a,I);return[a,{slug:a,title:m.title,description:m.description,icon:m.icon,...m.url?{url:m.url}:{},draft:{path:m.path,missing:m.missing,ws:f?.ws??null}}]}if(s.includes(a)){let f=await ue($(a,e));return[a,{slug:a,title:f?.title??a,description:"",icon:f?.icon??null,url:f?.url??""}]}let w=await M.readFile(ae($(a,e)).json,"utf8").then(JSON.parse).catch(()=>({}));return[a,{slug:a,title:S(w?.title)||a,description:S(w?.description),icon:typeof w?.icon=="string"?w.icon:null}]})));return{children:n,groups:y,columns:h,extensions:F,documents:_}}function de(e,t,n=[]){let o=k(ie()),s=new Set(t.map(({workspace:c})=>c).filter(Boolean)),r=oe(),i=s.size?te(s,{stops:r}):new Map,d=new Map;for(let c of t)if(c.id===v)d.set(c.id,k(e)===o?"\u9ED8\u8BA4\u6587\u6863":se(e,{stops:r}).name);else if(c.workspace){let h=n.find(({id:y})=>y===c.workspace);d.set(c.id,h?.isDefault?"\u9ED8\u8BA4\u6587\u6863":i.get(c.workspace)?.name??c.workspace)}else c.role==="links"&&d.set(c.id,"\u94FE\u63A5");return d}var p=e=>e?.title??e?.name??(e?.id===v?"\u6587\u6863":e?.role==="links"?"\u94FE\u63A5":e?"\u672A\u547D\u540D\u680F":"\u6587\u6863"),j=(e,t)=>e.groups?.find(({id:n})=>n===H(t));function Ee(e,t){let n=e.documents.get(t);if(!n||n.url!==void 0)return null;let o=C(e,t),s=n.draft?.ws??null,r=s?e.groups.find(i=>i.workspace===s):e.groups.find(i=>i.id===v);return r&&E(r.id)===o?null:r?r.hidden?r.name??s:p(r):s}var u=({documents:e},t)=>`${t} (${e.get(t)?.title??t})`,C=(e,t)=>V(e.children,t)??"";function je(e,t){let n=B(e.children,t).map(r=>u(e,r)),o=C(e,t),s=[...o===""?[]:[`${p(j(e,o))}\u680F`],...n];return`\u4F4D\u7F6E\uFF1A${s.length?s.join(" \u203A "):"\u9876\u5C42"}`}async function Ce(e,t,n){let{slug:o}=await T(e);if(o===await le(l))return{refused:`${e} is the \u5199\u4F5C\u504F\u597D page, which the sidebar lists apart: it moves nowhere and holds no documents (${t}).`};if(!n.documents.has(o)){let s=$(o,l);return{refused:await ne(s)==="instructions"?`${e} is the \u5199\u4F5C\u504F\u597D page, which the sidebar lists apart: it moves nowhere and holds no documents (${t}).`:`No document "${e}" (${t}): gallery list --tree shows the documents and where they are.`}}return{slug:o}}var fe={"cross-workspace":()=>"Not moved: copying to another workspace requires confirmation in Gallery; the original stays in its workspace.",missing:(e,t)=>`No document "${t}" in the sidebar's tree: gallery list --tree shows them.`,parent:(e,t,{parent:n})=>`No document "${n}" to put ${u(e,t)} under: gallery list --tree shows them.`,after:(e,t,{after:n})=>`No document "${n}" to put ${u(e,t)} after: gallery list --tree shows them.`,level:(e,t,{parent:n,after:o})=>`${u(e,o)} is not under ${n?u(e,n):"the top level"}: --after names a document at the level it goes to.`,itself:(e,t)=>`${u(e,t)} cannot go after itself.`,inside:(e,t,{parent:n,after:o})=>n===void 0&&o?`${u(e,t)} cannot go after ${u(e,o)}, which is under it.`:`${u(e,t)} cannot go under ${n===t?"itself":`${u(e,n)}, which is under it`}.`,instructions:(e,t)=>"The \u5199\u4F5C\u504F\u597D page is listed apart: it moves nowhere and holds no documents."},Fe=(e,t,n,o={})=>(fe[n]??((s,r,{message:i})=>`Not moved: ${i??n}.`))(e,t,o);async function O(e,t,n="move",o=l){let s=`127.0.0.1:${e.port}`;try{let i=await(await fetch(`http://${s}${A(o)}/__gallery/workspace/${n}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${s}`,"X-Gallery-Token":e.token},body:JSON.stringify({...t,workspace:o}),signal:AbortSignal.timeout(3e4)})).json().catch(()=>null);return typeof i?.ok!="boolean"||["elsewhere","token","host","origin","unknown"].includes(i.reason)?null:i}catch{return null}}async function Ie(e,{parent:t=void 0,after:n=null,first:o=!1}={}){let s=await x(),r={slug:e,...t!==void 0?{parent:t}:{},after:n,first:o},i=s?await O(s,r):null;return i||G(l,e,{parent:t,after:n,first:o})}function _e(e,{parent:t,index:n}){let o=e.children[t]??[],s=t===""?"at the top level":Q(t)?`at the top of the ${p(j(e,t))} column`:`under ${u(e,t)}`;return o.length===1?`${s}, the only ${o.some(r=>e.documents.get(r)?.url!==void 0)?"entry":"document"} there`:n===0?`${s}, first`:`${s}, right after ${u(e,o[n-1])}${n===o.length-1?", last":""}`}function Pe(e,t,{top:n=!0}={}){let o=e.get("--under"),s=e.get("--after"),r=e.get("--column");if(o!==void 0&&t.has("--top"))throw new g("--under and --top are two places: give one.");if(r!==void 0&&(o!==void 0||t.has("--top")))throw new g("--column and --under or --top are two places: give one.");if(s!==void 0&&t.has("--first"))throw new g("--after and --first are two places: give one.");return{under:o,top:n&&t.has("--top"),column:r,after:s,first:t.has("--first")}}async function me(e=l){let[{createEditService:t},{withNeededKitTags:n}]=await Promise.all([import("./chunk-25LYSMAE.mjs"),import("./chunk-3M6SBBGU.mjs")]);return t({reportsDirectory:e,stateDirectory:ce(e).state,finish:n})}async function Ae(e,t,{root:n=l,web:o=null}={}){let s=await x(),r=s?await O(s,t,e,n):null;if(r)return r;let{createWorkspaceService:i}=await import("./chunk-V3TM3TEN.mjs"),[,d]=await i({edits:await me(n),reports:{},reportsDirectory:n,...o?{web:o}:{}}).run(e,t);return d}function pe(e,t){let n=String(t).replace(/\s+/g," ").trim().toLowerCase();return e.groups.find(o=>!o.hidden&&!o.away&&[p(o),o.id].some(s=>s.toLowerCase()===n))??null}function Me(e,t){let n=pe(e,t),o=e.groups.filter(r=>!r.hidden&&!r.away);if(!n)return{refused:`No column "${t}" in the sidebar (${o.map(p).join(", ")}): gallery column new "<name>" makes one.`};if(n.extension)return{refused:`The column ${p(n)} is an extension's: its entries are the extension's own, which no command places.`};let s=re(l);return X(n,s)!==s?{refused:`The column ${p(n)} is another workspace's: a document made or moved here stays in this workspace (gallery copy <document> --to <workspace> copies it there).`}:{group:n,top:E(n.id)}}async function We(e,{tries:t=3}={}){let n=null;for(let o=1;o<=t;o++){let s=await D(l),r={groups:s.groups,children:s.children},i=e(r);if(i===null)return{ok:!0,outline:r,changed:!1};if(i.refused)return{ok:!1,refused:i.refused};if(!U(i)||!K(l,i))return{ok:!1,reason:"outline",message:"the outline that change makes is not one the sidebar keeps"};let d=await x(),c=d?await O(d,{outline:i,base:r},"outline"):null;if(c?.ok)return{ok:!0,outline:i,changed:!0};if(c&&c.reason!=="stale")return{ok:!1,reason:c.reason,message:c.message};if(c){n=c;continue}if(await q(l,async()=>R(r,await D(l))?(await z(l,i),!0):!1))return{ok:!0,outline:i,changed:!0};n={reason:"stale",message:"the sidebar's tree was changed elsewhere while this was made"}}return{ok:!1,reason:n?.reason??"stale",message:n?.message??"the sidebar's tree kept changing"}}export{Le as a,p as b,j as c,Ee as d,u as e,C as f,je as g,Ce as h,Fe as i,O as j,Ie as k,_e as l,Pe as m,Ae as n,pe as o,Me as p,We as q};
@@ -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{b as U,c as fe,e as de,j as V}from"./chunk-TKWEX4FD.mjs";import{createHash as Oe}from"node:crypto";import w from"node:fs";import u from"node:path";import{packsDirectory as C}from"../browser/shared/paths.mjs";import{PACKAGE_MANIFEST as M,layoutOf as Q}from"../browser/shared/workspace.mjs";var Fe="gallery",ee=/^(?:\.DS_Store|\._.*|Thumbs\.db|ehthumbs\.db|desktop\.ini)$/i,W=n=>ee.test(n);function G(n){return w.readdirSync(n,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()&&!ee.test(e.name)).map(e=>u.relative(n,u.join(e.parentPath,e.name)).split(u.sep).join("/")).sort()}var Y=n=>[...n.filter(e=>e!==M),...n.includes(M)?[M]:[]];function I(n){return w.existsSync(n)?R(G(n).map(e=>({name:e,data:w.readFileSync(u.join(n,e))}))):null}function R(n){let e=Oe("sha256"),t=n.filter(({name:s})=>!ee.test(s.split("/").at(-1))).sort((s,i)=>s.name<i.name?-1:s.name>i.name?1:0);for(let{name:s,data:i}of t)e.update(`${s}\0`).update(i).update(`
3
+ `);return e.digest("hex").slice(0,16)}var X=n=>{try{return w.readdirSync(n,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).sort()}catch{return[]}},N=(n=C)=>X(n);function K(n=C){return X(n).flatMap(e=>X(u.join(n,e)).flatMap(t=>{let s=u.join(n,e,t);try{let i=JSON.parse(w.readFileSync(u.join(s,M),"utf8"));return i.id!==`${e}/${t}`?[]:[{name:t,id:i.id,pack:e,folder:s,version:i.version,title:i.name,description:i.description,places:i.places??["document"]}]}catch{return[]}}))}function Ze(n,e=C){let t=n.includes("/")?n:`${Fe}/${n}`;return K(e).find(s=>s.id===t)??null}var Qe=(n,e=C)=>N(e).includes(String(n).split("/")[0]);function E(n){try{let e=JSON.parse(w.readFileSync(Q(n).blocks,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function L(n,e){let t=Q(n).blocks;w.mkdirSync(u.dirname(t),{recursive:!0}),w.writeFileSync(t,`${JSON.stringify(e,null,2)}
4
+ `)}var ne=(n,e)=>u.join(Q(n).components,...e.split("/"));function ye(n){try{return JSON.parse(w.readFileSync(u.join(n,M),"utf8")).version??null}catch{return null}}function te(n,e){let t=ne(n,e.id),s=I(t);if(s===null)return{added:!1,version:null,changed:!1,behind:!1};let i=ye(t),l=E(n)[e.id],o=I(e.folder),c=s!==o&&s!==l?.fingerprint;return{added:!0,version:i,changed:c,behind:!c&&s!==o}}function Ae(n,e){let t=ne(n,e.id),s=te(n,e);if(s.changed)throw Object.assign(new Error(`${e.id} was changed after it was added`),{code:"changed",folder:t});let i=I(e.folder),l=E(n);if(s.added&&!s.behind)return l[e.id]?.fingerprint!==i&&L(n,{...l,[e.id]:{version:e.version,fingerprint:i}}),{did:"same",folder:t};let o=G(e.folder);if(s.added)for(let c of G(t))o.includes(c)||w.rmSync(u.join(t,c));for(let c of Y(o))w.mkdirSync(u.dirname(u.join(t,c)),{recursive:!0}),w.copyFileSync(u.join(e.folder,c),u.join(t,c));return L(n,{...l,[e.id]:{version:e.version,fingerprint:i}}),{did:s.added?"updated":"added",from:s.version,folder:t}}var pe=n=>/^\d+\.\d+\.\d+$/.test(String(n??""))?n.split(".").map(Number):null;function T(n,e){let[t,s]=[pe(n),pe(e)];if(!t||!s)return n!==e;let i=t.findIndex((l,o)=>l!==s[o]);return i!==-1&&t[i]>s[i]}function en(n,e){if(!T(e.version,ye(ne(n,e.id))))return null;let t=te(n,e);return t.changed&&T(e.version,t.version)?e.version:null}var Z=new Map,ge=()=>{};function be(n,{updated:e,kept:t,failed:s}){let i=[];e.length&&i.push(`Gallery's own blocks in ${n}, as they were added, updated to this Gallery's: ${e.map(({id:l,from:o,to:c})=>`${l} ${o??"?"} -> ${c}`).join(", ")}`);for(let{id:l,version:o,shipped:c}of t)i.push(`${l} in ${n} was changed after it was added, so it stays at ${o??"its version"}: Gallery's is ${c} (\u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 says how to take it)`);for(let{id:l,to:o,why:c}of s)i.push(`${l} in ${n} could not be updated to Gallery's ${o}: ${c}`);return i}function Pe(n,{ids:e=null,directory:t=C,log:s=null}={}){let i={updated:[],kept:[],failed:[]},l=u.resolve(n);for(let o of K(t)){if(e&&!e.includes(o.id))continue;let c=`${l}\0${u.resolve(o.folder)}`;if(Z.get(c)!==o.version){Z.set(c,o.version);try{let r=te(n,o);if(r.changed&&T(o.version,r.version)&&i.kept.push({id:o.id,version:r.version,shipped:o.version}),!r.behind)continue;Ae(n,o).did==="updated"&&i.updated.push({id:o.id,from:r.version,to:o.version})}catch(r){i.failed.push({id:o.id,to:o.version,why:r?.message??String(r)})}}}for(let o of be(l,i))(s??ge)(o);return i}function Se(n,e){let t=u.resolve(n);for(let s of e)Z.set(`${t}\0${u.resolve(s.folder)}`,s.version)}var ue=new Set,he=n=>process.platform==="win32"?u.resolve(n).toLowerCase():u.resolve(n);function nn(n,e){ue.add(he(n)),ge=e,de((t,s)=>{ue.has(he(t))&&Pe(t,{ids:s})},N())}var me=n=>[n,n.replace("/","-")],Ee=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function tn(n,e,t=C){for(let s of K(t)){if(s.id===e)continue;let i;try{i=w.readFileSync(u.join(s.folder,"preview.svg"))}catch{continue}if(i.equals(n)||Buffer.from(_e(s,e)["preview.svg"]??"").equals(n))return s}return null}function _e(n,e){let[t,s]=[me(n.id),me(e)],i=new RegExp(t.map(Ee).join("|"),"g"),l={};for(let o of G(n.folder)){let c=w.readFileSync(u.join(n.folder,o));if(/\.(?:json|html|md|css|js|svg)$/.test(o)){let r=c.toString("utf8").replace(i,a=>s[t.indexOf(a)]);o===M&&(r=r.replace(/"version":\s*"[^"]*"/,'"version": "0.1.0"')),l[o]=r}else l[o]=c}return Object.fromEntries(Y(Object.keys(l)).map(o=>[o,l[o]]))}import S from"node:fs";import h from"node:path";import{refusal as Ie,said as $}from"../browser/shared/i18n/index.mjs";import{DEFAULT_PACK as Ne,OWN_SCOPE as se,PACK_FILE as A,PACK_ID as ve,readPackManifest as re}from"../browser/shared/pack-manifest.mjs";import{packsDirectory as ke}from"../browser/shared/paths.mjs";import{DEVICE_NAMES as Me,PACKAGE_MANIFEST as B,layoutOf as H,markerOf as Ge,packageFolders as Te}from"../browser/shared/workspace.mjs";var ce=Object.freeze(["gallery-soft"]);function un(n,e={}){let t=E(n).packs;return ce.filter(s=>e?.[s]===void 0&&!b(t?.[s]))}var Ce="GALLERY_NO_PACKS",Ke=(n=process.env)=>!["","0","false",void 0].includes(n[Ce]),q=2e3,oe=64*1024*1024,we=/^[a-z0-9][a-z0-9-]*$/,b=n=>typeof n=="object"&&n!==null&&!Array.isArray(n),j=(n,e)=>{throw Ie(e,{code:n})};function ze(n){let e=[];for(let t of S.readdirSync(n,{recursive:!0,withFileTypes:!0})){if(!t.isFile())continue;e.length>=q&&j("size",$("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",q,oe/1024/1024));let s=h.relative(n,h.join(t.parentPath,t.name)).split(h.sep).join("/");e.push({name:s,data:S.readFileSync(h.join(n,...s.split("/")))})}return e}function De(n,{refuse:e=()=>{}}={}){let t=[],s=0;for(let{name:r,data:a}of n){let f=String(r).replace(/\\/g,"/");if(f.endsWith("/"))continue;let g=f.split("/");(f.startsWith("/")||/^[A-Za-z]:/.test(f)||f.includes("\0")||g.some(p=>p===""||p==="."||p===".."))&&j("path",$("{0} \u6307\u5411\u5757\u5305\u5916\u9762\uFF0C\u4E0D\u80FD\u88C5",String(r))),!(g[0]==="__MACOSX"||W(g.at(-1)))&&(s+=a.length,t.push({name:f,data:a}))}(t.length>q||s>oe)&&j("size",$("\u5757\u5305\u592A\u5927\uFF1A\u6700\u591A {0} \u4E2A\u6587\u4EF6\u3001{1} MB",q,oe/1024/1024));let i=t;if(!t.some(({name:r})=>r===A)){let r=new Set(t.map(({name:f})=>f.split("/")[0])),[a]=r;(r.size!==1||!t.some(({name:f})=>f===`${a}/${A}`))&&j("manifest",$("\u6700\u4E0A\u4E00\u5C42\u6CA1\u6709 pack.json\uFF1A\u5757\u5305\u662F\u4E00\u4E2A\u6587\u4EF6\u5939\uFF0C\u6700\u4E0A\u4E00\u5C42\u653E pack.json\uFF0C\u6BCF\u4E2A\u5757\u4E00\u4E2A\u6587\u4EF6\u5939")),i=t.map(({name:f,data:g})=>({name:f.slice(a.length+1),data:g}))}let l=re(i.find(({name:r})=>r===A).data.toString("utf8"));e(l);let o=new Map,c=[];for(let r of i){let[a,...f]=r.name.split("/");if(f.length===0){c.push(r);continue}o.has(a)||o.set(a,[]),o.get(a).push({name:f.join("/"),data:r.data})}for(let[r,a]of o){(!we.test(r)||Me.has(r))&&j("block",$("{0} \u4E0D\u662F\u5757\u7684\u6587\u4EF6\u5939\u540D\uFF1A\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26",r));let f=a.find(p=>p.name===B);f||j("block",$("{0}/ \u91CC\u6CA1\u6709 component.json",r));let g;try{g=JSON.parse(f.data.toString("utf8").replace(/^/,"")).id}catch{j("block",$("{0}/component.json \u4E0D\u662F JSON",r))}g!==`${l.id}/${r}`&&j("block",$("{0}/component.json \u7684 id \u8981\u5199\u6210 {1}",r,`${l.id}/${r}`))}return{manifest:l,blocks:o,own:c}}function Le(n){try{let e=JSON.parse(n.find(({name:t})=>t===B).data.toString("utf8").replace(/^/,"")).version;return typeof e=="string"?e:null}catch{return null}}function $e(n){try{return S.readdirSync(n,{withFileTypes:!0}).filter(e=>e.isFile()&&!W(e.name)).map(e=>e.name).sort()}catch{return[]}}function je(n){let e=$e(n);return e.length?R(e.map(t=>({name:t,data:S.readFileSync(h.join(n,t))}))):null}function Re(n){try{return S.readdirSync(n).some(e=>!W(e))}catch{return!1}}function ie(n,e,{replacing:t=!1,last:s=B}={}){let i=e.map(({name:c})=>c);if(t)for(let c of G(n))i.includes(c)||S.rmSync(h.join(n,...c.split("/")),{force:!0});let l=new Map(e.map(c=>[c.name,c.data])),o=s===B?Y(i):[...i.filter(c=>c!==s),...i.includes(s)?[s]:[]];for(let c of o){let r=h.join(n,...c.split("/"));S.mkdirSync(h.dirname(r),{recursive:!0}),S.writeFileSync(r,l.get(c))}}function Be(n,e,{official:t=!1,shippedIds:s=N()}={}){let{manifest:i,blocks:l,own:o}=De(e,{refuse:({id:m})=>{!t&&s.includes(m)&&j("official",$("{0} \u662F Gallery \u81EA\u5E26\u7684\u5757\u5305\u7528\u7684 id\uFF1A\u6362\u4E00\u4E2A id \u518D\u88C5",m))}}),{id:c}=i,r=h.join(H(n).components,c),a=E(n),f=b(a.packs)?a.packs:{},g=b(f[c])?f[c]:null;!t&&!g&&Re(r)&&j("taken",$("\u5DE5\u4F5C\u533A\u91CC\u5DF2\u7ECF\u6709 components/{0}\uFF1A\u8FD9\u4E2A\u540D\u5B57\u88AB\u522B\u7684\u5757\u5305\u6216\u522B\u4EBA\u5199\u7684\u5757\u7528\u7740\uFF0C\u6362\u4E00\u4E2A id\uFF0C\u6216\u5148\u628A\u90A3\u4E2A\u6587\u4EF6\u5939\u632A\u8D70",c));let p={id:c,name:i.name,version:i.version,from:g?.version??null,folder:r,added:[],updated:[],same:[],kept:[],removed:[],skipped:[],ownKept:!1},d=[...l.keys()].sort();for(let m of d){let y=`${c}/${m}`,O=l.get(m),F=h.join(r,m),P=R(O),z=I(F),J=b(a[y])?a[y]:null;if(z===null){if(t&&J){p.skipped.push(y);continue}ie(F,O),p.added.push(y)}else if(z===P)p.same.push(y);else if(J&&z===J.fingerprint)ie(F,O,{replacing:!0}),p.updated.push(y);else{p.kept.push(y);continue}a[y]={version:Le(O),fingerprint:P}}for(let m of Array.isArray(g?.blocks)?g.blocks:[]){let y=String(m).split("/")[1];if(!y||l.has(y)||!we.test(y))continue;let O=h.join(r,y),F=I(O);if(F!==null&&F!==a[m]?.fingerprint){p.kept.push(m);continue}F!==null&&(S.rmSync(O,{recursive:!0,force:!0,maxRetries:5,retryDelay:100}),p.removed.push(m)),delete a[m]}let v=je(r),x=R(o);if(v!==x)if(v===null||v===g?.fingerprint){let m=o.map(({name:y})=>y);for(let y of $e(r))m.includes(y)||S.rmSync(h.join(r,y),{force:!0});S.mkdirSync(r,{recursive:!0}),ie(r,o,{last:A})}else p.ownKept=!0;let _=p.added.length+p.updated.length+p.removed.length>0||v!==x&&!p.ownKept;return p.did=g?_?"updated":"same":"installed",a.packs={...f,[c]:{version:i.version,fingerprint:p.ownKept?g.fingerprint:x,blocks:d.map(m=>`${c}/${m}`),...t?{official:!0}:{}}},L(n,a),p}function hn(n,e,{shippedIds:t=N()}={}){t.includes(e)&&j("official",$("{0} \u662F Gallery \u81EA\u5E26\u7684\u5757\u5305\uFF0C\u4E0D\u80FD\u5220\u9664\uFF1A\u5728 \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 \u91CC\u628A\u5B83\u5173\u6389",e));let s=h.join(H(n).components,e);(!ve.test(e)||!S.existsSync(s))&&j("missing",$("\u5DE5\u4F5C\u533A\u91CC\u6CA1\u6709\u5757\u5305 {0}",e));let i=E(n),l=b(i.packs)&&b(i.packs[e])?i.packs[e]:null;l||j("own",$("components/{0} \u4E0D\u662F\u88C5\u8FDB\u6765\u7684\u5757\u5305\uFF0C\u91CC\u9762\u7684\u5757\u662F\u6709\u4EBA\u5728\u8FD9\u4E2A\u5DE5\u4F5C\u533A\u5199\u7684\uFF1A\u8981\u5220\u5C31\u81EA\u5DF1\u5220\u6389\u8FD9\u4E2A\u6587\u4EF6\u5939",e)),S.rmSync(s,{recursive:!0,force:!0,maxRetries:5,retryDelay:100});for(let r of Object.keys(i))r.startsWith(`${e}/`)&&delete i[r];let{[e]:o,...c}=i.packs;return L(n,{...i,packs:c}),{id:e,version:l.version??null,blocks:Array.isArray(l.blocks)?l.blocks:[]}}var Je=n=>({zh:V("zh",n),en:V("en",n)});function mn(n,{settings:e=null,shippedIds:t=N(),directory:s=ke}={}){let{components:i}=H(n),l=E(n),o=b(l.packs)?l.packs:{},c=Te(n),r=new Set([se,...c.map(({id:d})=>d.split("/")[0])]);try{for(let d of S.readdirSync(i))ve.test(d)&&S.existsSync(h.join(i,d,A))&&r.add(d)}catch{}let a=(e??U(n)).packs??{},f,g=[...r].map(d=>{let v=h.join(i,d),x=null,_=null;if(S.existsSync(h.join(v,A)))try{x=re(S.readFileSync(h.join(v,A),"utf8")),x.id!==d&&(_=$("pack.json \u7684 id \u662F {0}\uFF0C\u5B83\u7684\u6587\u4EF6\u5939\u5374\u662F components/{1}",x.id,d),x=null)}catch(k){_=k}let m=b(o[d])?o[d]:null,y=c.filter(k=>k.id.startsWith(`${d}/`)),O=m?y.filter(k=>b(l[k.id])&&I(k.folder)!==l[k.id].fingerprint).map(k=>k.id):[];m&&je(v)!==m.fingerprint&&O.push(`${d}/${A}`);let F=t.includes(d),P=null;if(F)try{P=re(S.readFileSync(h.join(s,d,A),"utf8"))}catch{}let z=k=>{try{return JSON.parse(S.readFileSync(h.join(i,...k.split("/"),B),"utf8")).version??null}catch{return null}},xe=F&&P&&O.some(k=>{if(k.endsWith(`/${A}`))return T(P.version,x?.version??null);f??=new Map(K(s).map(ae=>[ae.id,ae]));let le=f.get(k);return le&&T(le.version,z(k))})?P.version:null,D=d===se?Ne:x??(_?null:P);return{id:d,name:D?.name??{zh:d,en:d},description:D?.description??null,version:x?.version??null,author:D?.author??null,homepage:D?.homepage??null,icon:D?.icon??null,kind:d===se?"default":F?"official":m?"installed":"own",problem:_?Je(_):null,blocks:y.length,enabled:a[d]!==!1,changed:O,newer:xe}}),p=({id:d,kind:v})=>v==="default"?-1:v==="official"?t.indexOf(d):v==="installed"?1e3:2e3;return g.sort((d,v)=>p(d)-p(v)||(d.id<v.id?-1:1))}function We(n,e,t){let s=[],i=h.resolve(n);return t?s.push(`Gallery's pack ${e.id} ${e.version} installed in ${i} (${e.added.length+e.same.length+e.updated.length} blocks)${ce.includes(e.id)?", switched off: \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 turns it on":""}`):(e.added.length&&s.push(`Gallery's pack ${e.id} in ${i} has new blocks: ${e.added.join(", ")}`),e.updated.length&&s.push(`Gallery's pack ${e.id} in ${i}, its blocks as they were installed, updated to this Gallery's: ${e.updated.join(", ")}`),e.removed.length&&s.push(`Gallery's pack ${e.id} in ${i}: ${e.removed.join(", ")} no longer in it, taken out`)),s}async function yn(n,{directory:e=ke,env:t=process.env,log:s=()=>{}}={}){if(Ke(t))return{did:"off",packs:[]};let i={ours:!1};try{i=Ge(S.readFileSync(H(n).marker,"utf8"))}catch{}if(!i.ours)return{did:"unread",packs:[]};let l=N(e),o=K(e),c=[];for(let r of l)try{let a=!b(E(n).packs?.[r]);a&&ce.includes(r)&&U(n).packs[r]===void 0&&await fe(n,{pack:r,enabled:!1});let f=Be(n,ze(h.join(e,r)),{official:!0,shippedIds:l});c.push({...f,first:a});let g=new Set([...f.added,...f.updated,...f.same]);Se(n,o.filter(p=>g.has(p.id)));for(let p of We(n,f,a))s(p)}catch(a){s(`Gallery's pack ${r} could not be installed in ${h.resolve(n)}: ${a?.message??a}`),c.push({id:r,failed:a?.message??String(a)})}return{did:"done",packs:c}}export{Fe as a,Y as b,N as c,K as d,Ze as e,Qe as f,E as g,te as h,Ae as i,T as j,en as k,Pe as l,nn as m,tn as n,_e as o,un as p,ze as q,Be as r,hn as s,mn as t,yn as u};
@@ -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 l,e as h,g as $,h as v,i as x,k as y,l as a,m as L,p as T}from"./chunk-B6RAGF4R.mjs";import{b as f,f as g}from"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";import{descendantsIn as D}from"../browser/shared/outline.mjs";async function O(I){let{positional:m,options:b,values:k}=g({options:["--top","--first"],values:["--under","--after","--column"],argv:I});if(m.length!==1)throw new f("Name the document to move, one.");let e=L(k,b);if(e.under===void 0&&!e.top&&e.column===void 0&&e.after===void 0&&!e.first)throw new f("Say where it goes: --under <document>, --top or --column <column>, and --after <document> or --first.");let s=await l(),i=async(r,A)=>{let d=await v(r,A,s);return d.refused&&(console.error(d.refused),process.exit(1)),d.slug},n=await i(m[0],"the document to move"),c=e.under!==void 0?await i(e.under,"--under"):e.top?"":void 0;if(e.column!==void 0){let r=T(s,e.column);r.refused&&(console.error(r.refused),process.exit(1)),c=r.top}let p=e.after!==void 0?await i(e.after,"--after"):null,o=await y(n,{parent:c,after:p,first:e.first});o.ok||(console.error(x(s,n,o.reason,{parent:c,after:p,message:o.message})),process.exit(1));let t=await l(),u=D(t.children,n).length,w=`${h(t,n)}${u?` with the ${u} document${u===1?"":"s"} under it`:""}`;o.moved?console.log(`Moved ${w}: now ${a(t,o)}; it was ${a(s,o.from)}.`):console.log(`${w} is there already: ${a(t,o)}.`),console.log($(t,n))}export{O as run};
@@ -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{j as g,o as i,q as h}from"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import{b as m,f as u}from"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";import{spawn as R}from"node:child_process";import v from"node:fs/promises";import G from"node:path";import{projectRoot as y,release as S,reportsDirectory as k}from"../browser/shared/paths.mjs";import{answerOf as x,findPreviewServer as b,portIsFree as $,readAnnouncement as A}from"../browser/shared/preview-server.mjs";import{serviceLocation as E}from"../browser/shared/service-location.mjs";import{registerQuietly as C}from"../browser/shared/workspace-registry.mjs";import{defaultWorkspace as I}from"../browser/shared/workspace.mjs";var n=I(),L=a=>new Promise(t=>setTimeout(t,a));async function W(a){await C(k);let{positional:t,values:l}=u({values:["--port"],argv:a});if(t.length>0)throw new m(`gallery serve takes no arguments: ${t[0]}`);let o=l.has("--port")?Number(l.get("--port")):null;if(o!==null&&!(Number.isInteger(o)&&o>0&&o<65536))throw new m(`--port takes a port number: ${l.get("--port")}`);let s=await A(),f=s?await x(s,1e4):"no";f!=="no"&&(console.error(`The shared Gallery server runs already: ${i(s.port)} (pid ${s.pid}${f==="busy"?", not answering now":""}). gallery stop stops it; one server serves a Gallery data directory.`),process.exit(1));let r=null;if(o!==null)await $(o)||(console.error(`Port ${o} is taken: name another (--port), or leave it out for the first free one.`),process.exit(1)),r=o;else{for(let e of await h())if(await $(e)){r=e;break}r===null&&(console.error(`No port from ${g()} is free: name one (--port <n>).`),process.exit(1))}if(S){process.env.GALLERY_SERVER_KIND="cli";let{startProductionServer:e}=await import("./chunk-MC4LRSVH.mjs");await e({reportsDirectory:n,port:r,kind:"cli"}),await v.writeFile(E().lastPortFile,`${r}
3
+ `).catch(()=>{}),console.log(`Gallery serves ${n} at ${i(r)} (Chrome or Edge). Ctrl+C stops it.`);return}let{writeSharedAssets:P}=await import("./chunk-VKZJRGDR.mjs");await P();let c=R(process.execPath,[G.join(y,"node_modules","vite","bin","vite.js"),"--host","127.0.0.1","--port",String(r),"--strictPort"],{cwd:y,env:{...process.env,GALLERY_WORKSPACE:n,GALLERY_SERVER_KIND:"cli"},stdio:"inherit"});for(let e of["SIGINT","SIGTERM"])process.on(e,()=>c.kill(e));let w=new Promise(e=>c.once("exit",(d,p)=>e(d??(p?1:0))));for(;;){let e=await Promise.race([w.then(p=>({code:p})),L(300).then(()=>null)]);if(e&&process.exit(e.code),(await b({answering:!0,timeout:2e3}))?.pid===c.pid)break}await v.writeFile(E().lastPortFile,`${r}
4
+ `).catch(()=>{}),console.log(`Gallery serves ${n} at ${i(r)} (Chrome or Edge). Ctrl+C stops it.`),process.exit(await w)}export{W as run};
@@ -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{refusal as ct,said as at}from"../browser/shared/i18n/index.mjs";import{SITE_ICON_BYTES as it,SITE_ICON_TYPES as lt,loginTitle as ut}from"../browser/shared/web-links.mjs";import $ from"node:http";import z from"node:https";import Y from"node:net";import S from"node:tls";import P from"node:zlib";import{Readable as B}from"node:stream";import{execFile as j}from"node:child_process";import{promisify as M}from"node:util";var A=M(j),X=/^(localhost|127\.|10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|\[?::1\]?$|0\.0\.0\.0)/i;function K(t,e){let n=t.toLowerCase();for(let r of e){let o=r.trim().toLowerCase();if(!o)continue;if(o==="*")return!0;if(o==="<local>"){if(!n.includes("."))return!0;continue}if(o.includes("*")){if(new RegExp(`^${o.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")}$`).test(n))return!0;continue}let s=o.replace(/^\./,"").replace(/:\d+$/,"");if(n===s||n.endsWith(`.${s}`))return!0}return!1}var N=t=>/^[a-z]+:\/\//i.test(t)?t:`http://${t}`;function V(t=process.env){let e=t.HTTPS_PROXY||t.https_proxy||t.HTTP_PROXY||t.http_proxy||t.ALL_PROXY||t.all_proxy;return e?{url:N(e),bypass:(t.NO_PROXY||t.no_proxy||"").split(",")}:null}async function J(){let{stdout:t}=await A("reg",["query","HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"],{windowsHide:!0,timeout:3e3}),e=o=>new RegExp(`^\\s*${o}\\s+REG_\\w+\\s+(.*)$`,"mi").exec(t)?.[1]?.trim();if(Number.parseInt(e("ProxyEnable")||"0",16)!==1)return null;let n=e("ProxyServer");if(!n)return null;let r=n;if(n.includes("=")){let o=Object.fromEntries(n.split(";").map(s=>s.split("=").map(c=>c.trim())));if(r=o.https||o.http,!r)return null}return{url:N(r),bypass:(e("ProxyOverride")||"").split(";")}}async function Q(){let{stdout:t}=await A("scutil",["--proxy"],{timeout:3e3}),e=r=>new RegExp(`\\b${r}\\s*:\\s*(\\S+)`).exec(t)?.[1];if(e("HTTPSEnable")!=="1"||!e("HTTPSProxy"))return null;let n=[...t.matchAll(/^\s*\d+\s*:\s*(\S+)\s*$/gm)].map(r=>r[1]);return{url:`http://${e("HTTPSProxy")}:${e("HTTPSPort")||80}`,bypass:n}}var C=null,I=0;async function Z(){let t=V();if(t)return t;if(C!==null&&Date.now()-I<3e4)return C||null;let e=null;try{process.platform==="win32"?e=await J():process.platform==="darwin"&&(e=await Q())}catch{e=null}return C=e||!1,I=Date.now(),e}async function tt(t){let e;try{let r=new URL(t);if(r.protocol!=="http:"&&r.protocol!=="https:")return null;e=r.hostname}catch{return null}if(X.test(e))return null;let n=await Z();return n&&!K(e,n.bypass)&&/^http:/i.test(n.url)?n.url:null}var R=t=>t.username?{"proxy-authorization":`Basic ${Buffer.from(`${decodeURIComponent(t.username)}:${decodeURIComponent(t.password)}`).toString("base64")}`}:{};function _(t,e,n,r){return new Promise((o,s)=>{let c=$.request({host:t.hostname,port:t.port||80,method:"CONNECT",path:`${e}:${n}`,headers:{host:`${e}:${n}`,...R(t)},signal:r});c.once("connect",(a,l)=>{a.statusCode===200?o(l):(l.destroy(),s(Object.assign(new Error(`the proxy answered ${a.statusCode}`),{proxyAnswered:a.statusCode})))}),c.once("error",s),c.end()})}function et(t,{method:e,headers:n,signal:r},o){let s=new URL(t),c=new URL(o),a={"accept-encoding":"gzip, deflate, br",...n};return new Promise((l,i)=>{let u=f=>{f.once("response",l),f.once("error",i),f.end()};if(s.protocol==="http:"){u($.request({host:c.hostname,port:c.port||80,method:e,path:s.href,headers:{...a,host:s.host,...R(c)},signal:r}));return}_(c,s.hostname,s.port||443,r).then(f=>{u(z.request(s,{method:e,headers:{...a,host:s.host},defaultPort:443,signal:r,createConnection:()=>S.connect({socket:f,servername:s.hostname,ALPNProtocols:["http/1.1"]})}))},i)})}function T(t,e){let n=new Headers;for(let[l,i]of Object.entries(t.headers))n.set(l,Array.isArray(i)?i.join(", "):String(i));let r=(t.headers["content-encoding"]||"").toLowerCase(),o={gzip:P.createGunzip,"x-gzip":P.createGunzip,deflate:P.createInflate,br:P.createBrotliDecompress}[r],s=o?t.pipe(o()):t;o&&(t.on("error",l=>s.destroy(l)),n.delete("content-encoding"),n.delete("content-length"));let c=[101,204,205,304].includes(t.statusCode);c&&t.resume();let a=new Response(c?null:B.toWeb(s),{status:t.statusCode,statusText:t.statusMessage,headers:n});return Object.defineProperty(a,"url",{value:e}),a}async function nt(t,{method:e="GET",headers:n={},signal:r}={},o){for(let s=0;;s++){let c=await et(t,{method:e,headers:n,signal:r},o),a=c.headers.location;if([301,302,303,307,308].includes(c.statusCode)&&a&&s<10){c.resume(),t=new URL(a,t).href,c.statusCode===303&&(e="GET");continue}return T(c,t)}}var v=t=>t.includes(":")?`[${t}]`:t,ot=t=>/^[\d.]+$/.test(t)||t.includes(":");function Pt(t,{address:e,proxy:n=null,headers:r={},signal:o,connect:s=(a,l)=>Y.connect({host:a,port:l}),ca:c=null}){let a=Number(t.port)||(t.protocol==="https:"?443:80),l=e===null;if(l&&!(n&&t.protocol==="https:"))return Promise.reject(new Error("fetchPinned: only an https address is handed to a proxy by its name"));let i=ot(t.hostname)?void 0:t.hostname,u={"accept-encoding":"gzip, deflate, br",...r,host:t.host},f=`${t.pathname}${t.search}`,L=l||c?[...S.rootCertificates,...c?[c]:[]]:null,b=d=>S.connect({socket:d,servername:i,ALPNProtocols:["http/1.1"],...L?{ca:L}:{},...l?{rejectUnauthorized:!0}:{}}),F=d=>new Promise((x,m)=>{if(o?.aborted)return d.destroy(),m(o.reason);let h=b(d),g=()=>h.destroy(o.reason);o?.addEventListener("abort",g,{once:!0}),h.on("error",p=>{o?.removeEventListener("abort",g),m(p)}),h.once("close",()=>m(new Error("the connection closed before TLS was done"))),h.once("secureConnect",()=>{if(o?.removeEventListener("abort",g),l&&!h.authorized){let p=Object.assign(new Error(`the certificate failed (${h.authorizationError})`),{code:String(h.authorizationError)});return h.destroy(),m(p)}x(h)})});return new Promise((d,x)=>{let m=p=>{let w=(t.protocol==="https:"?z:$).request({method:"GET",signal:o,...p});w.once("response",D=>d(T(D,t.href))),w.once("error",x),w.end()};if(!n){m({host:e,port:a,path:f,headers:u,createConnection:()=>t.protocol==="https:"?b(s(e,a)):s(e,a)});return}let h=new URL(n),g=p=>x(p?.proxyAnswered||o?.aborted?p:Object.assign(p??new Error("the proxy was not reached"),{proxyFailed:!0}));if(t.protocol==="http:"){let p=$.request({host:h.hostname,port:h.port||80,method:"GET",path:`http://${v(e)}:${a}${f}`,headers:{...u,...R(h)},agent:!1,signal:o});p.once("response",w=>d(T(w,t.href))),p.once("error",g),p.end();return}_(h,l?t.hostname:v(e),a,o).then(p=>F(p).then(w=>m({host:l?t.hostname:e,port:a,path:f,headers:u,createConnection:()=>w}),x),g)})}async function rt(t,e={}){let n=await tt(t);if(n)try{return await nt(t,e,n)}catch(r){if(e.signal?.aborted)throw r}return fetch(t,e)}var st="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0 Safari/537.36";async function y(t,{timeout:e=1e4,accept:n="*/*",headers:r={},unreachable:o="\u6253\u4E0D\u5F00\u8FD9\u4E2A\u7F51\u9875",protocols:s=["http:","https:"]}={}){let c;try{c=new URL(t)}catch{throw Object.assign(new Error("\u4E0D\u662F\u7F51\u5740"),{reason:"url"})}if(!s.includes(c.protocol))throw Object.assign(new Error("\u53EA\u652F\u6301 http(s) \u7F51\u5740"),{reason:"url"});return rt(c,{redirect:"follow",signal:AbortSignal.timeout(e),headers:{"user-agent":st,accept:n,...r}}).catch(()=>{throw Object.assign(new Error(o),{reason:"download"})})}async function E(t,e){let n=t.body.getReader(),r=[],o=0;for(;;){let{done:s,value:c}=await n.read();if(s)break;if(r.push(Buffer.from(c)),o+=c.length,o>=e){n.cancel().catch(()=>{});break}}return Buffer.concat(r)}async function O(t,e){let n=await E(t,e+1);return n.length<=e?n:null}var ft={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},H=t=>t.replace(/&(#x[0-9a-f]+|#\d+|\w+);/gi,(e,n)=>{if(n[0]==="#"){let r=n[1]==="x"||n[1]==="X"?parseInt(n.slice(2),16):Number(n.slice(1));return Number.isFinite(r)&&r>0&&r<=1114111?String.fromCodePoint(r):e}return ft[n.toLowerCase()]??e}),U=t=>H(String(t??"")).replace(/\s+/g," ").trim();function pt(t){let e={};for(let n of t.matchAll(/([\w:-]+)\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+))/g))e[n[1].toLowerCase()]=n[3]??n[4]??n[5]??"";return e}function k(t,e){let n=/charset=([\w-]+)/i.exec(e??"")?.[1];n||(n=/<meta[^>]+charset=["']?([\w-]+)/i.exec(t.subarray(0,4096).toString("latin1"))?.[1]);try{return new TextDecoder(n||"utf-8").decode(t)}catch{return new TextDecoder("utf-8").decode(t)}}function q(t,e){let n=t.search(/<\/head>/i),r=n>0?t.slice(0,n):t.slice(0,3e5),o={},s=[];for(let[i]of r.matchAll(/<(meta|link)\b[^>]*>/gi)){let u=pt(i);if(/^<meta/i.test(i)){let f=(u.property||u.name||u.itemprop||"").toLowerCase();f&&u.content!==void 0&&!(f in o)&&(o[f]=u.content)}else u.rel&&u.href&&/(^|\s)(icon|shortcut icon|apple-touch-icon)(\s|$)/i.test(u.rel)&&s.push({rel:u.rel.toLowerCase(),href:u.href})}let c=i=>{try{return i?new URL(H(i),e).href:null}catch{return null}},a=/<title[^>]*>([\s\S]*?)<\/title>/i.exec(r)?.[1],l=s.find(i=>/(^|\s)icon(\s|$)/.test(i.rel))??s.find(i=>i.rel.includes("icon"));return{title:U(o["og:title"]||o["twitter:title"]||a||"").slice(0,300),description:U(o["og:description"]||o["twitter:description"]||o.description||"").slice(0,600),icon:c(l?.href)||c("/favicon.ico"),cover:c(o["og:image"]||o["og:image:url"]||o["og:image:secure_url"]||o["twitter:image"]||o["twitter:image:src"])}}async function ht(t){if(!t)return null;try{let e=await y(t,{timeout:8e3,accept:"image/*,*/*;q=0.5",protocols:["http:","https:","data:"]}),n=(e.headers.get("content-type")??"").split(";")[0].trim();if(!e.ok||!/^image\//.test(n))return null;let r=await O(e,5*1024*1024);return r?.length?r:null}catch{return null}}async function Rt(t){try{let e=await y(t,{timeout:8e3,accept:"text/html,*/*;q=0.8"});if(e.body?.cancel().catch(()=>{}),[401,403].includes(e.status)||W(e.url))return{frameable:!0,reason:"auth"};if(!e.ok)return{frameable:!0,reason:"unknown"};let n=(e.headers.get("x-frame-options")??"").toLowerCase(),r=(e.headers.get("content-security-policy")??"").split(",").map(o=>/(?:^|;)\s*frame-ancestors\s+([^;]*)/i.exec(o)?.[1]?.trim().toLowerCase()).filter(o=>o!==void 0);return r.length?r.some(o=>o==="'none'"||o==="'self'")?{frameable:!1,reason:"frame-ancestors"}:{frameable:!0,...r.every(o=>o==="*")?{}:{reason:"unknown"}}:n.split(",").some(o=>/^(deny|sameorigin)$/.test(o.trim()))?{frameable:!1,reason:"x-frame-options"}:{frameable:!0}}catch(e){return e.reason==="url"?{frameable:!1,reason:"url"}:{frameable:!0,reason:"unknown"}}}function W(t){try{let e=new URL(t);return/^(?:login|signin|passport|sso)\./i.test(e.hostname)||/\/(?:login|signin|sign-in|oauth2\/challenge)(?:[/.]|$)/i.test(e.pathname)}catch{return!1}}async function Ot(t){try{let e=await y(t,{accept:"text/html,application/xhtml+xml;q=0.9,*/*;q=0.8",headers:{"accept-language":"zh-CN,zh;q=0.9,en;q=0.8"}});if([401,403].includes(e.status)||W(e.url))return e.body?.cancel().catch(()=>{}),{title:"",reason:"auth"};let n=e.headers.get("content-type")??"";if(!e.ok||!/html|xml/i.test(n))return e.body?.cancel().catch(()=>{}),{title:"",reason:"unknown"};let r=q(k(await E(e,1.5*1024*1024),n),e.url||t).title;return ut(r)?{title:"",reason:"auth"}:{title:r.slice(0,200)}}catch{return{title:"",reason:"unknown"}}}function dt(t){let e=t.subarray(0,16);return e[0]===137&&e.toString("latin1",1,4)==="PNG"?"image/png":e[0]===0&&e[1]===0&&e[2]===1&&e[3]===0?"image/x-icon":e.toString("latin1",0,3)==="GIF"?"image/gif":e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e.toString("latin1",0,4)==="RIFF"&&e.toString("latin1",8,12)==="WEBP"?"image/webp":/^\s*(<\?xml[^>]*>\s*)?<svg[\s>]/i.test(t.subarray(0,512).toString("utf8"))?"image/svg+xml":null}async function G(t,e){if(!t||e<=0)return null;try{let n=await y(t,{timeout:e,accept:"image/*,*/*;q=0.5",protocols:["http:","https:","data:"]});if(!n.ok)return n.body?.cancel().catch(()=>{}),null;let r=(n.headers.get("content-type")??"").split(";")[0].trim().toLowerCase(),o=await O(n,it);if(!o?.length)return null;let s=lt.includes(r)?r:dt(o);return s?`data:${s};base64,${o.toString("base64")}`:null}catch{return null}}async function kt(t,{timeout:e=4e3,env:n=process.env}={}){if(n.GALLERY_SITE_ICON==="off")return null;if(n.GALLERY_SITE_ICON==="local"){let i="";try{i=new URL(t).hostname.replace(/^\[|\]$/g,"")}catch{}if(!/^(127\.\d+\.\d+\.\d+|localhost|::1)$/i.test(i))return null}let r=Date.now()+e,o=()=>r-Date.now(),s=t,c=null;try{let i=await y(t,{timeout:o(),accept:"text/html,application/xhtml+xml;q=0.9,*/*;q=0.8"});s=i.url||t;let u=i.headers.get("content-type")??"";i.ok&&/html|xml/i.test(u)?c=q(k(await E(i,512*1024),u),s).icon:i.body?.cancel().catch(()=>{})}catch{return null}let a=null;try{a=new URL("/favicon.ico",s).href}catch{}return await G(c,o())??(c!==a?G(a,o()):null)}async function qt(t,e,{icon:n=!0,cover:r=!0}={}){let o=await y(t,{accept:"text/html,application/xhtml+xml;q=0.9,*/*;q=0.8",headers:{"accept-language":"zh-CN,zh;q=0.9,en;q=0.8"}}),s=o.url||new URL(t).href,c=o.headers.get("content-type")??"";if(!o.ok)throw ct(at("\u7F51\u9875\u8FD4\u56DE {0}",o.status),{reason:"download"});if(!/html|xml/i.test(c))return o.body?.cancel().catch(()=>{}),{url:s,title:"",description:"",icon:null,cover:null};let a=q(k(await E(o,1.5*1024*1024),c),s),l=async(f,L)=>{let b=await ht(f);try{return b?await e(b,L):null}catch{return null}},[i,u]=await Promise.all([n?l(a.icon,"bookmark-icon"):null,r?l(a.cover,"bookmark-cover"):null]);return{url:s,title:a.title,description:a.description,icon:i,cover:u}}export{tt as a,Pt as b,y as c,O as d,Rt as e,Ot as f,kt as g,qt as h};
@@ -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 G,b as H}from"./chunk-ZNGGDUZI.mjs";import{a as $,b,n as F,q as T}from"./chunk-B6RAGF4R.mjs";import{c as O,d as P}from"./chunk-VAXLSISW.mjs";import{b as p,f as M}from"./chunk-L4WLQYFC.mjs";import X from"node:fs/promises";import u from"node:path";import{readAnnouncement as Z}from"../browser/shared/preview-server.mjs";import{nameProblem as ee,nameStops as j,ownName as oe,workspaceLabels as se,workspaceName as W,writeWorkspaceName as te}from"../browser/shared/workspace-name.mjs";import{forgetWorkspace as re,isWorkspace as B,isWorkspaceId as _,readRegistry as J,registerQuietly as A,registerWorkspace as ne,SCAN_DEPTH as K,SCAN_LIMIT as ae,scanForWorkspaces as ie,workspaceId as y,workspaceKey as f}from"../browser/shared/workspace-registry.mjs";import{defaultWorkspace as Q,documentsFolder as R,ensureWorkspace as ce,layoutOf as le}from"../browser/shared/workspace.mjs";import{clashingIds as de,draftEntry as U,workspaceOf as Y}from"../browser/shared/drafts.mjs";import{removeColumn as he,removeDraft as fe}from"../browser/shared/outline-ops.mjs";import{reportsDirectory as L}from"../browser/shared/paths.mjs";var x=(e,r)=>`${e} ${r}${e===1?"":"s"}`,N=(e,r)=>f(e)===f(r);function me(e){if(oe(e)||N(e,Q()))return null;let{name:r}=W(e,{stops:j()});return`\u63D0\u793A\uFF1A\u8FD9\u4E2A\u5DE5\u4F5C\u533A\u8FD8\u6CA1\u6709\u540D\u5B57\uFF08\u522B\u5904\u6309\u6587\u4EF6\u5939\u53EB\u5B83"${r}"\uFF09\uFF1B\u5B83\u662F\u4E3A\u4E00\u4E2A\u9879\u76EE\u5EFA\u7684\uFF0C\u5C31\u7528 gallery workspaces --name "<\u9879\u76EE\u540D>" \u5199\u4E0A\u9879\u76EE\u540D`}async function we(e,r){let a=ee(r);if(a)throw new p(a);try{let{ours:s,reads:n}=await ce(e);s||(console.error(P(e,n)),process.exit(1))}catch(s){if(!s.code)throw s;console.error(O(e,s.code)),process.exit(1)}let o;try{o=await te(e,r)}catch(s){console.error(s.code?O(e,s.code):s.message),process.exit(1)}await A(e),console.log(`\u5DE5\u4F5C\u533A\uFF1A${e}`),console.log(`\u540D\u5B57\uFF1A${o.name} (in ${le(e).marker}${o.before&&o.before!==o.name?`; it was "${o.before}"`:""}): the sidebar and gallery workspaces call it so.`)}async function pe(e,r){let a=await re(e);a.length||(console.error(`No registered workspace is ${_(e)?e:u.resolve(e)}: gallery workspaces lists them, with their paths and ws- ids.`),process.exit(1));for(let o of a)console.log(`Forgot ${o} (only the registry changed: nothing on disk).${N(o,r)?" It is the current workspace: the next command run in it registers it again.":""}`)}async function ue(e){let r=u.resolve(e??R());await X.stat(r).then(l=>l.isDirectory(),()=>!1)||(console.error(`No such folder: ${r} (--scan names a folder to look in).`),process.exit(1));let a=new Set(J().workspaces.map(({root:l})=>f(l))),{found:o,read:s,cut:n}=await ie(r);console.log(`Scanned ${r}, ${K} levels down (${x(s,"folder")}): ${o.length?`${x(o.length,"workspace")}.`:"no workspace."}`);let c=j();for(let l of o){let{name:d}=W(l,{stops:c});if(a.has(f(l))){await A(l),console.log(` \u5DF2\u767B\u8BB0\uFF1A${l}\uFF08${d}\uFF09`);continue}try{await ne(l)}catch(h){console.log(` \u6CA1\u80FD\u767B\u8BB0\uFF08${h.code??h.message}\uFF09\uFF1A${l}`);continue}console.log(` \u65B0\u767B\u8BB0\uFF1A${l}\uFF08${d}\uFF09`)}n&&console.log(`Stopped after ${x(ae,"folder")}: gallery workspaces --scan <a folder further down> looks at the rest.`),o.length&&console.log("gallery workspaces lists them; gallery list <words> --all searches their documents.")}async function ge(e,r=!1){let a=B(e);a&&await A(e);let o=J().workspaces,s=[e,...o.map(({root:t})=>t).filter(t=>!N(t,e))],n=new Map(o.map(({root:t,seen:i})=>[f(t),Date.parse(i)])),c=R(),l=j({documents:c}),d=await Promise.all(s.map(async t=>{let i=B(t),g=i?await G(t):[];return{root:t,there:i,count:g.length,edited:g.reduce((m,{edited:v})=>Math.max(m,v),0),named:{root:t,...W(t,{stops:l})}}})),[h,...k]=d;k.sort((t,i)=>i.there-t.there||i.edited-t.edited||(n.get(f(i.root))??0)-(n.get(f(t.root))??0));let S=[h,...k],C=new Map(se(S.map(({named:t})=>t)).map(t=>[f(t.root),t])),w=await Z();if(r){let t=S.map(i=>{let{name:g,own:m}=C.get(f(i.root));return{id:y(i.root),name:g,path:i.root,current:i===h,default:N(i.root,Q()),named:!!m,exists:i.there,documents:i.count,lastEdited:i.edited?new Date(i.edited).toISOString():null}});return void console.log(JSON.stringify({current:u.resolve(e),service:w?{port:w.port,pid:w.pid,address:`http://127.0.0.1:${w.port}/`}:null,workspaces:t},null,2))}console.log(w?`Gallery \u670D\u52A1\uFF1Ahttp://127.0.0.1:${w.port}/ (pid ${w.pid})`:"Gallery \u670D\u52A1\uFF1A\u672A\u542F\u52A8");let I=o.length;console.log(`${x(I,"workspace")} on this machine's registry; the current one first (*):`);for(let t of S){let{name:i,own:g,above:m}=C.get(f(t.root)),v=t===h,E=[...g||!t.there?[]:["\u6CA1\u6709\u8D77\u540D\uFF1A\u7528\u7684\u662F\u6587\u4EF6\u5939\u7684\u540D\u5B57"],...t.there?[]:[v?"\u8FD8\u6CA1\u6709\u5EFA":"\u4E0D\u5728\u4E86\uFF1A\u6587\u4EF6\u5939\u6216\u5B83\u7684 gallery.json \u627E\u4E0D\u5230\u4E86"]],V=m?u.isAbsolute(m)?`\uFF08${m}\uFF09`:`\uFF08\u4E0A\u4E00\u7EA7\uFF1A${m}\uFF09`:"";console.log(`${v?"*":" "} ${i}${V} ${y(t.root)}${E.length?` \uFF08${E.join("\uFF1B")}\uFF09`:""}`),console.log(` \u8DEF\u5F84\uFF1A${t.root}`),t.there&&console.log(` \u6587\u6863\uFF1A${t.count?`${t.count} \u7BC7\uFF1B\u4E0A\u6B21\u7F16\u8F91\uFF1A${H(t.edited)}`:"\u6CA1\u6709"}`)}for(let{id:t,roots:i}of de())console.log(`${t} \u662F ${i.length} \u4E2A\u767B\u8BB0\u7684\u5DE5\u4F5C\u533A\u5171\u7528\u7684\u7F16\u53F7\uFF08${i.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 D=a?me(e):null;D&&console.log(D),k.some(({there:t})=>!t)&&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."),I<=1&&console.log(`gallery workspaces --scan registers the workspaces already on this machine (in the Documents folder, ${K} 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.")}function q(e){if(_(e)){let a=Y(e);return a.root?{root:a.root,id:e}:{id:e,root:null,refused:a.refused}}let r=u.resolve(e);return{root:r,id:y(r)}}var z=(e,r)=>`\u63D0\u793A\uFF1Athe sidebar still lists ${e}: this Gallery's sidebar lists every registered workspace and its documents, and the outline's hidden and left marks (written, as the sidebar's own \u4ECE\u4FA7\u8FB9\u680F\u79FB\u9664 and \u4ECE\u6587\u6863\u6811\u79FB\u9664 write them) are not read for it. To take the workspace off every sidebar, gallery workspaces --forget "${r}" (only the registry changes: nothing on disk; the next command run in it registers it again).`;async function ke(e,r){let a=Y(e.workspace).root??e.workspace,o=await T(c=>he(c,e.id));o.ok||(console.error(`Not hidden: ${o.refused??o.message??o.reason}.`),process.exit(1));let n=(await $()).columns.some(c=>c.id===e.id&&!c.hidden&&!c.away);console.log(`${o.changed?"Hid":"Already hidden:"} the column "${b(e)}" (${e.workspace}) of the sidebar: the workspace ${a}, its files and the registry are as they were.`),n&&(console.log(z(`the column "${b(e)}"`,a)),process.exitCode=1)}async function $e(e,r,a){let o=q(e);o.root||(console.error(`${e} is ${o.refused==="ambiguous"?"the id of more than one registered workspace":"no registered workspace"}: gallery workspaces lists them, with their ids and paths; --show <folder> registers one.`),process.exit(1));let s=r===void 0?o.root:u.join(o.root,r),n=await F("draft-add",{path:s,...a?{confirm:!0}:{}});n?.ok||(n?.reason==="unregistered"?console.error(`${n.message??"The folder is no workspace yet"}: nothing added. \u63D0\u793A\uFF1Arun it again with --register to make it one and show it.`):console.error(`Not added: ${n?.message??n?.reason??"no answer"}.`),process.exit(1));let c=await $(),l=y(o.root);if(n.own)return void console.log(`${o.root} is this workspace's own: ${n.kind==="draft"?`the document ${n.entry} is in its column already`:"its column is the first one"}.`);if(n.kind==="workspace"){let h=c.columns.find(k=>k.id===n.column);console.log(`${n.shown||n.moved?"Showed":"The sidebar shows"} the workspace ${o.root} as the column "${h?b(h):n.column}" (all its documents).`);return}let d=n.entry??U(l,r);console.log(`${n.existing?"The sidebar lists the document already":"Added the document to the sidebar"}: ${d} (${c.documents.get(d)?.title??r}), from ${o.root}${n.added?.length>1?`, with ${n.added.length-1} under it`:""}.`)}async function ye(e,r){let a=q(e),o=await $();if(a.id===y(L)&&(console.error(`${L} is the current workspace: its own column is never removed from its sidebar.`),process.exit(1)),r===void 0){let d=o.columns.find(h=>h.workspace===a.id);return d||(console.error(`The sidebar has no column of ${e}: gallery workspaces lists the workspaces, gallery list --tree the columns.`),process.exit(1)),ke(d,o)}let s=U(a.id,r);o.documents.has(s)||(console.error(`The sidebar's tree has no document ${r} of ${e} (${s}): gallery list --tree shows what it holds.`),process.exit(1));let n=o.documents.get(s).title,c=await T(d=>fe(d,s));c.ok||(console.error(`Not removed: ${c.refused??c.message??c.reason}.`),process.exit(1)),console.log(`Took the document ${s} (${n}) out of the sidebar's tree; its file and its workspace are untouched, and the documents under it went up to where it was.`),(await $()).documents.has(s)&&(console.log(z(`the document ${s}`,a.root??e)),process.exitCode=1)}async function Ee(e,r){let{positional:a,options:o,values:s}=M({options:["--scan","--json","--register"],values:["--name","--forget","--show","--hide","--doc"],argv:e}),n=[o.has("--scan"),s.has("--name"),s.has("--forget"),s.has("--show"),s.has("--hide")].filter(Boolean).length;if(n>1)throw new p("One of --scan, --name, --forget, --show and --hide at a time.");if(s.has("--doc")&&!s.has("--show")&&!s.has("--hide"))throw new p("--doc <slug> goes with --show or --hide: one document of that workspace.");if(o.has("--register")&&!s.has("--show"))throw new p("--register goes with --show: it makes a folder that is no workspace yet one.");if(o.has("--json")&&n>0)throw new p("--json is for the list: gallery workspaces --json.");if(a.length>(o.has("--scan")?1:0))throw new p(o.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 c=u.resolve(r.workspace);return s.has("--name")?we(c,s.get("--name")):s.has("--forget")?pe(s.get("--forget"),c):s.has("--show")?$e(s.get("--show"),s.get("--doc"),o.has("--register")):s.has("--hide")?ye(s.get("--hide"),s.get("--doc")):o.has("--scan")?ue(a[0]):ge(c,o.has("--json"))}export{me as a,ke as b,Ee as c};
@@ -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,b as g,c as l,e as u,f,g as p,h as $,i as c}from"./chunk-G5HV7BC3.mjs";import"./chunk-5TLLIZT7.mjs";import"./chunk-TLNJWEFY.mjs";import"./chunk-ZOEJQOKT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-B2EIMERT.mjs";import"./chunk-6N25CJ6Y.mjs";import"./chunk-F4CT35KL.mjs";import"./chunk-6ILJWFYW.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-HYMEEXKN.mjs";import{b as m,f as k}from"./chunk-L4WLQYFC.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 d from"node:fs/promises";function v(e){let r=e.findIndex(({by:o})=>o!=="agent");return r<=0?null:{version:e[r],after:r}}async function A(e,r){let o=await a("history",{slug:e.slug,action:"versions"});o?.ok||c(o,`\u6CA1\u80FD\u8BFB\u5230 ${e.slug} \u7684\u7248\u672C`);let i=v(o.versions);if(!i)return!1;let t=await a("history",{slug:e.slug,action:"restore",version:i.version.id,agent:!0});if(t?.ok||c(t,`\u6CA1\u6709\u64A4\u56DE ${e.slug}`),t.same)return!1;console.log(`\u64A4\u56DE\u4E86 ${e.slug}\uFF08${e.title}\uFF09\u91CC Agent \u9996\u6B21\u64B0\u5199\u5199\u4E0B\u7684\u5185\u5BB9\uFF08\u9875\u9762\u4E0A\u6CA1\u6709\u6807\u51FA\uFF1B${i.after} \u6B21\u5199\u5165\uFF1A${u(t.counts)}\uFF09\uFF0C\u56DE\u5230\u7248\u672C ${l(i.version.version)}\uFF08${g(i.version.time)}\uFF09\uFF1A`);for(let s of t.blocks??[])console.log(` ${f(s,{taken:!0})}`);return t.more&&console.log(` \u8FD8\u6709 ${t.more} \u5757`),console.log(await $(e,r)),t.kept&&console.log(`\u63D0\u793A\uFF1A\u64A4\u56DE\u524D\u7684\u6837\u5B50\u5B58\u6210\u4E86\u7248\u672C ${l(t.kept.slice(-16))}\uFF1B\u8981\u6062\u590D\u5B83\uFF1Agallery history ${e.slug} --restore ${l(t.kept.slice(-16))}`),!0}function w(e){console.error(`\u95EE\u9898\uFF1A${e.slug}\uFF08${e.title}\uFF09\u6CA1\u6709\u5F85\u5BA1\u9605\u7684 Agent \u4FEE\u6539\uFF1A\u7528\u6237\u5DF2\u7ECF\u786E\u8BA4\u6216\u64A4\u56DE\u4E86\uFF0C\u6216\u8005 Agent \u8FD8\u6CA1\u6539\u8FC7\u5B83\u3002\u4EC0\u4E48\u4E5F\u6CA1\u5199\u3002`),console.error(`\u4E0B\u4E00\u6B65\uFF1A\u8981\u56DE\u5230\u66F4\u65E9\u7684\u6837\u5B50\uFF0C\u8FD0\u884C gallery history ${e.slug} \u770B\u5404\u4E2A\u7248\u672C\uFF0C\u518D\u7528 gallery history ${e.slug} --restore <\u7248\u672C> \u6062\u590D\u3002`),process.exit(1)}async function S(e){let{positional:r}=k({argv:e});if(r.length!==1)throw new m("Name one document: gallery revert <document>.");let o=await p(r[0]),i=await d.readFile(o.json,"utf8").catch(()=>null);for(let t=1;;t++){let s=await a("changes",{slug:o.slug,action:"read"});if(s?.ok||c(s,`\u6CA1\u80FD\u8BFB\u5230 ${o.slug} \u7684 Agent \u4FEE\u6539`),!s.pending)return s.draft&&await A(o,i)?void 0:w(o);let n=await a("changes",{slug:o.slug,action:"revert",stamp:s.stamp,agent:!0});if(!n?.ok&&n?.reason==="changed"&&t<2)continue;if(n?.ok||c(n,`\u6CA1\u6709\u64A4\u56DE ${o.slug}`),n.none)return w(o);let h=s.since?`\u81EA ${g(s.since)} \u8D77 `:"";console.log(`\u64A4\u56DE\u4E86 ${o.slug}\uFF08${o.title}\uFF09\u91CC Agent \u7684\u4FEE\u6539\uFF08${h}${s.writes??1} \u6B21\u5199\u5165\uFF1A${u(n.counts??s.counts)}\uFF09\uFF1A`);for(let y of n.blocks??[])console.log(` ${f(y,{taken:!0})}`);n.more&&console.log(` \u8FD8\u6709 ${n.more} \u5757`),console.log("\u7528\u6237\u81EA\u5DF1\u5728\u9875\u9762\u4E0A\u5B58\u8FC7\u7684\u4FEE\u6539\u90FD\u7559\u7740\uFF1B\u6253\u5F00\u7740\u7684\u9875\u9762\u9A6C\u4E0A\u663E\u793A\u64A4\u56DE\u540E\u7684\u6837\u5B50\u3002"),console.log(await $(o,i)),n.kept&&console.log(`\u63D0\u793A\uFF1A\u64A4\u56DE\u524D\u7684\u6837\u5B50\u5B58\u6210\u4E86\u7248\u672C ${l(n.kept.slice(-16))}\uFF1B\u8981\u6062\u590D\u5B83\uFF1Agallery history ${o.slug} --restore ${l(n.kept.slice(-16))}\uFF08\u9875\u9762\u4E0A\u7684\u300C\u64A4\u9500\u300D\u53EA\u7ED9\u5728\u9875\u9762\u4E0A\u64A4\u56DE\u7684\u90A3\u4E2A\u6807\u7B7E\u9875\uFF09`);return}}export{S as run};
@@ -0,0 +1,15 @@
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}from"./chunk-2OHANJ6Q.mjs";import{c as L,d as F}from"./chunk-Q4UEPUWF.mjs";import{c as x,d as j,k as w}from"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";import l from"node:fs";import c from"node:path";import{pathToFileURL as K}from"node:url";import{projectRoot as p}from"../browser/shared/paths.mjs";import{sha256 as A}from"../browser/shared/files.mjs";var g=["SKILL.md","references/writing-html.md","references/charts-and-figures.md","references/building-blocks.md","references/block-script.md","references/pages-and-data.md","references/extensions.md","references/preference-files.md","references/previews.md","references/example-report.html","sdk","agents/openai.yaml"],u="## Before anything: the gallery command";function T(n){let[s,t]=n.split(/[.+-]/).map(Number);return{range:`^${n}`,takes:`${n} or a later ${s===0?`0.${t}`:s}.x`}}function v(n,s){let t=n.indexOf(`
3
+ ${u}
4
+ `);if(t<0)throw new Error(`SKILL.md has no section "${u}" (the version range of the command stands there)`);let e=n.indexOf(`
5
+ ## `,t+u.length+1),i=e<0?n.length:e,{range:r,takes:o}=T(s),a=n.slice(t,i).replace(new RegExp(L.source,"g"),F(s)).replace(/\^\d+\.\d+\.\d+(?:-[\w.]+)?/g,r).replace(/\b\d+\.\d+\.\d+(?:-[\w.]+)? or a later \d+(?:\.\d+)?\.x\b/g,o);return n.slice(0,t)+a+n.slice(i)}function y(n=p){let s=g.filter(r=>!l.existsSync(c.join(n,r)));if(s.length)return s.map(r=>`the skill takes ${r}, which is not there`);let t=E(g,n),e=r=>l.readFileSync(c.join(n,r),"utf8"),i=P(t,e).map(r=>`${r}, which the skill does not hold: link only what it holds`);for(let r of t.filter(o=>o.startsWith("sdk/")&&o.endsWith(".ts")))for(let[,o]of e(r).matchAll(/\bfrom\s+["']([^"']+)["']|\bimport\(\s*["']([^"']+)["']\s*\)/g))o&&(!o.startsWith("./")||o.includes("/../"))&&i.push(`${r} imports ${o}, outside sdk/: write the types it needs in sdk/`);return i}function N(n,{root:s=p,version:t=JSON.parse(l.readFileSync(c.join(s,"package.json"),"utf8")).version}={}){let e=y(s);if(e.length)throw new Error(`The skill cannot be made:
6
+ ${e.map(i=>` ${i}`).join(`
7
+ `)}`);l.rmSync(n,{recursive:!0,force:!0});for(let i of E(g,s)){let r=c.join(n,i);l.mkdirSync(c.dirname(r),{recursive:!0}),i==="SKILL.md"?l.writeFileSync(r,v(l.readFileSync(c.join(s,i),"utf8"),t)):l.copyFileSync(c.join(s,i),r)}return k(n)}function k(n,s=""){let t=[];for(let e of l.readdirSync(n,{withFileTypes:!0}).sort((i,r)=>i.name.localeCompare(r.name))){let i=s?`${s}/${e.name}`:e.name;e.isDirectory()?t.push(...k(c.join(n,e.name),i)):e.isFile()&&t.push(i)}return t}function E(n,s=p){return n.flatMap(t=>{let e=c.join(s,t);return l.existsSync(e)?l.statSync(e).isDirectory()?k(e,t):[t]:[]})}function R(n){let s=null;return n.split(`
8
+ `).map(t=>{let e=/^\s*(`{3,}|~{3,})(.*)$/.exec(t);return s?(e&&e[1][0]===s[0]&&e[1].length>=s.length&&!e[2].trim()&&(s=null),""):e&&!(e[1][0]==="`"&&e[2].includes("`"))?(s=e[1],""):t}).join(`
9
+ `)}function z(n){let s=R(n).replace(/(`+)(?!`)(?:(?!\n[ \t]*\n)[\s\S])*?[^`]\1(?!`)/g,e=>" ".repeat(e.length));return[...[...s.matchAll(/\]\(\s*(?:<([^<>\n]*)>|((?:[^\s()<>]|\([^\s()<>]*\))+))(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^()\n]*\)))?\s*\)/g)].map(e=>[e.index,e[1]??e[2]]),...[...s.matchAll(/^ {0,3}\[(?!\^)[^\]\n]+\]:[ \t]*(?:<([^<>\n]*)>|(\S+))/gm)].map(e=>[e.index,e[1]??e[2]]),...[...s.matchAll(/<(?:a|img)\s[^>]*?\b(?:href|src)\s*=\s*(?:"([^"]*)"|'([^']*)')/gi)].map(e=>[e.index,e[1]??e[2]])].sort(([e],[i])=>e-i).map(([,e])=>e)}function C(n,s){if(/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(s))return null;let[,t,e=""]=/^([^?#]*)(?:\?[^#]*)?(?:#(.*))?$/s.exec(s),i=o=>{try{return decodeURIComponent(o)}catch{return o}};return{file:t?c.posix.normalize(c.posix.join(c.posix.dirname(n),i(t))).replace(/\/$/,""):n,anchor:i(e)}}function P(n,s){let t=new Set(n),e=new Set(n.flatMap(r=>r.split("/").slice(0,-1).map((o,a,m)=>m.slice(0,a+1).join("/")))),i=[];for(let r of n.filter(o=>/\.md$/i.test(o)))for(let o of z(s(r))){let a=C(r,o);!a||a.file===r||!t.has(a.file)&&!e.has(a.file)&&i.push(`${r} links ${o}`)}return i}function M(n,{root:s=p,version:t=JSON.parse(l.readFileSync(c.join(s,"package.json"),"utf8")).version}={}){let e=y(s);if(e.length)throw new Error(`The skill cannot be made:
10
+ ${e.map(f=>` ${f}`).join(`
11
+ `)}`);let i=c.join(n,"skill","gallery"),r=`gallery-skill-${t}.zip`,o=c.join(n,r);l.rmSync(c.join(n,"skill"),{recursive:!0,force:!0}),l.existsSync(c.join(n,"gallery","PACKAGE-MANIFEST.json"))&&l.rmSync(c.join(n,"gallery"),{recursive:!0,force:!0});for(let f of l.existsSync(n)?l.readdirSync(n):[])/^gallery-skill-.+\.zip(?:\.sha256)?$|^PACKAGE-MANIFEST\.json$/.test(f)&&l.rmSync(c.join(n,f),{force:!0});let a=N(i,{root:s,version:t}),m=a.map(f=>({name:`gallery/${f}`,data:l.readFileSync(c.join(i,f))})),h=b(m);l.writeFileSync(o,h);let S=A(h);l.writeFileSync(`${o}.sha256`,`${S} ${r}
12
+ `);let{range:$}=T(t),I={name:"gallery",version:t,archive:r,holds:"The Agent's documents (SKILL.md, references/writing-html.md, references/charts-and-figures.md, references/building-blocks.md, references/block-script.md, references/pages-and-data.md, references/extensions.md, references/preference-files.md, references/previews.md, the example references/example-report.html), the SDK's types (sdk/) and Codex's display metadata (agents/openai.yaml). The tools are the npm package @heycys/gallery, which SKILL.md has the Agent check for and install (with the user's consent); gallery skill install writes this same skill.",skillEntrypoint:"SKILL.md",requires:`@heycys/gallery@${$}`,files:m.map(({name:f,data:d})=>({path:f.slice(8),bytes:d.byteLength,sha256:A(d)}))};l.writeFileSync(c.join(n,"PACKAGE-MANIFEST.json"),`${JSON.stringify(I,null,2)}
13
+ `);let O=m.reduce((f,{data:d})=>f+d.byteLength,0);return{archive:o,skill:i,files:a,bytes:O,zipBytes:h.byteLength,sha256:S,range:$}}if(import.meta.url===K(process.argv[1]).href){let{positional:n}=await w(import.meta.url);n.length>0&&(console.error(j(x(import.meta.url),`Unknown argument: ${n[0]} (skill:package takes none: there is one skill).`)),process.exit(2));let s=y();s.length>0&&(console.error(`Not packaged:
14
+ ${s.map(e=>` ${e}`).join(`
15
+ `)}`),process.exit(1));let t=M(c.join(p,"release"));console.log(`Packaged ${t.archive} (${t.files.length} files, ${t.bytes.toLocaleString("en-US")} bytes; the ZIP ${t.zipBytes.toLocaleString("en-US")} bytes), for @heycys/gallery ${t.range}`),console.log(`The skill's folder: ${t.skill}`),console.log(`SHA-256 ${t.sha256}`)}export{u as BOOTSTRAP,g as SKILL_FILES,N as buildSkill,P as deadLinks,E as filesOf,C as linkTarget,z as linksOf,k as listFiles,M as packageSkill,y as skillProblems,T as skillRange,v as withRange,R as withoutSamples};
@@ -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,b,c}from"./chunk-LSVCTLS2.mjs";import"./chunk-F63BNJLG.mjs";import"./chunk-ZNGGDUZI.mjs";import"./chunk-B6RAGF4R.mjs";import"./chunk-5TLLIZT7.mjs";import"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import"./chunk-VAXLSISW.mjs";import"./chunk-56SVJENP.mjs";import"./chunk-L4WLQYFC.mjs";import"./chunk-NOGQX56R.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as DEFAULT_DESCRIPTION,c as run,b as slugRefused};
@@ -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}from"./chunk-5TLLIZT7.mjs";import{i as k}from"./chunk-TLNJWEFY.mjs";import{p as S}from"./chunk-B2EIMERT.mjs";import{b as d,f as y,i as w}from"./chunk-L4WLQYFC.mjs";import{existsSync as G}from"node:fs";import h from"node:fs/promises";import{HOST_NAMES as H,KIND_NAMES as J}from"../browser/editor/components/registry.mjs";import{reportsDirectory as _}from"../browser/shared/paths.mjs";import{documentDirectory as B,documentFiles as C}from"../browser/shared/workspace.mjs";import{editStateDirectory as T,reportsDirectory as p}from"../browser/shared/paths.mjs";import{findPreviewServer as M}from"../browser/shared/preview-server.mjs";import{workspaceBase as F}from"../browser/shared/service-location.mjs";var g=null;async function $(e,o,{wait:r=3e4}={}){let n=await M();if(n){let s=`127.0.0.1:${n.port}`,l=null;try{l=await fetch(`http://${s}${F(p)}/__gallery/edit/${e}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${s}`,"X-Gallery-Token":n.token},body:JSON.stringify({...o,workspace:p}),signal:AbortSignal.timeout(r)})}catch(i){if(i.name==="TimeoutError")return{ok:!1,reason:"timeout",message:`the workspace's Gallery server did not answer in ${Math.round(r/1e3)}s`};l=null}if(l){let i=await l.json().catch(()=>null);if(i===null||typeof i.ok!="boolean")return{ok:!1,reason:"older",message:`the Gallery server running on port ${n.port} is an older one, which cannot do this: run gallery stop, then this command again`};if(!["elsewhere","token","host","origin"].includes(i.reason))return i}}g??=k({reportsDirectory:p,stateDirectory:T,finish:S});let[,t]=e==="history"?await g.historyAction(o):await g.changesAction(o);return await g.stored(),t}var v=8,K={reader:"\u7528\u6237",agent:"Agent"},c=e=>String(e).padStart(2,"0"),P=(e,o)=>e+" ".repeat(Math.max(0,o-[...e].reduce((r,n)=>r+(/[⺀-￯]/.test(n)?2:1),0)));function A(e){let o=new Date(e);return`${o.getFullYear()}-${c(o.getMonth()+1)}-${c(o.getDate())} ${c(o.getHours())}:${c(o.getMinutes())}:${c(o.getSeconds())}`}var u=e=>e.slice(0,v),b=({kind:e,title:o,name:r})=>r??(o?"\u6807\u9898":J[e]??H[e]??"\u5757");function x(e,{taken:o=!1}={}){if(!e)return"";let r=o?["\u53BB\u6389\u4E86","\u6539\u56DE\u4E86","\u653E\u56DE\u4E86"]:["\u52A0\u4E86","\u6539\u4E86","\u5220\u4E86"],n=[e.added,e.changed,e.removed].map((t,s)=>[t,r[s]]).filter(([t])=>t>0).map(([t,s])=>`${s} ${t} \u5757`);return n.length?n.join("\u3001"):"\u5757\u6CA1\u6709\u53D8\uFF08\u53EA\u662F\u7F16\u53F7\u3001\u7A7A\u767D\u6216\u5199\u6CD5\uFF09"}function N({change:e,kind:o,id:r,text:n,title:t,name:s},{taken:l=!1}={}){return`${l?{added:"\u53BB\u6389\u4E86\u52A0\u7684",changed:"\u6539\u56DE\u4E86",removed:"\u653E\u56DE\u4E86\u5220\u7684"}[e]:{added:"\u52A0\u4E86",changed:"\u6539\u4E86",removed:"\u5220\u4E86"}[e]} ${b({kind:o,title:t,name:s})}${r?` ${r}`:""}${n?`\u300C${n}\u300D`:""}`}function j({kind:e,by:o,from:r},n){return e===null?n?"\u6700\u65E9\u7684\u6837\u5B50":"\u6539\u52A8":{commit:o==="agent"?"Agent \u81EA\u7528\u9875\u9762\u4E0A\u7684\u4FEE\u6539":"\u9875\u9762\u4E0A\u7684\u4FEE\u6539",write:o===null?"\u6700\u65E9\u7684\u6837\u5B50":"\u6539\u5199\u4E86\u6587\u4EF6",revert:"\u64A4\u56DE\u4E86 Agent \u7684\u4FEE\u6539",undo:"\u64A4\u9500\u4E86\u64A4\u56DE\u6216\u6062\u590D",restore:`\u6062\u590D\u5230 ${r?u(r.slice(-16)):"\u66F4\u65E9\u7684\u7248\u672C"}`,"hand-in":"\u5BFC\u51FA\u65F6\u8865\u4E0A\u7F16\u53F7\u548C\u5199\u6CD5",rename:"\u6539\u4E86\u6807\u9898"}[e]??"\u6539\u52A8"}async function I(e){let{slug:o}=await w(e),{html:r,json:n}=C(B(o,_));G(r)||(console.error(`\u95EE\u9898\uFF1A\u6CA1\u6709\u6587\u6863 "${e}"\uFF1A${a(r)} \u4E0D\u5B58\u5728\uFF08gallery list \u5217\u51FA\u6709\u54EA\u4E9B\uFF09\u3002`),process.exit(1));let t=o;try{let s=JSON.parse(await h.readFile(n,"utf8"));typeof s?.title=="string"&&s.title.trim()&&(t=s.title.trim())}catch{}return{slug:o,title:t,file:r,json:n}}async function L(e,o){let r=await h.readFile(e.json,"utf8").catch(()=>null),n=[a(e.file),...o!==null&&r!==o?[a(e.json)]:[]];return`\u91CD\u8BFB\uFF1A${n.join("\u3001")}\uFF08\u6539\u4E4B\u524D\u5148\u91CD\u8BFB\uFF1A${n.length>1?"\u5B83\u4EEC":"\u5B83"}\u521A\u88AB\u6539\u5199\uFF09`}function O(e,o){let r={missing:"\u8FD9\u4EFD\u6587\u6863\u4E0D\u5728\u4E86",version:"\u6CA1\u6709\u8FD9\u4E2A\u7248\u672C\uFF08gallery history \u5217\u51FA\u6709\u54EA\u4E9B\uFF09",ambiguous:`\u8FD9\u51E0\u4E2A\u5F00\u5934\u76F8\u540C\uFF0C\u591A\u7ED9\u51E0\u4F4D\uFF1A${(e?.candidates??[]).map(n=>u(n.slice(-16))).join("\u3001")}`,busy:"\u6587\u4EF6\u4E00\u76F4\u5728\u53D8\uFF08Agent \u6B63\u5728\u5199\uFF1F\uFF09\uFF0C\u4EC0\u4E48\u4E5F\u6CA1\u5199\uFF1B\u7A0D\u540E\u518D\u8FD0\u884C\u4E00\u6B21",changed:"Agent \u521A\u521A\u53C8\u6539\u4E86\u6587\u6863\uFF1B\u518D\u8FD0\u884C\u4E00\u6B21",timeout:"Gallery \u670D\u52A1\u6CA1\u6709\u53CA\u65F6\u56DE\u7B54\uFF0C\u5B83\u53EF\u80FD\u8FD8\u4F1A\u5199\uFF1A\u5148 gallery history \u770B\u4E00\u773C\u518D\u8BF4"}[e?.reason]??e?.message??e?.reason??"\u6CA1\u6709\u56DE\u7B54";console.error(`\u95EE\u9898\uFF1A${o}\uFF1A${r}\u3002`),process.exit(1)}var D=({change:e,kind:o,name:r,tag:n,id:t,text:s,title:l})=>({change:e,kind:o,name:b({kind:o,title:l,name:r}),tag:n,id:t,text:s,...l?{title:l}:{}}),R=({id:e,time:o,version:r,by:n,kind:t,from:s,current:l,counts:i,blocks:f,more:m})=>({id:e,version:r,short:u(r),time:o,by:n==="reader"?"user":n,kind:t,...s?{from:s}:{},current:l,counts:i??null,blocks:(f??[]).map(D),...m?{more:m}:{}});async function U(e,{json:o}){let r=await $("history",{slug:e.slug,action:"versions"});r?.ok||O(r,`\u6CA1\u80FD\u5217\u51FA ${e.slug} \u7684\u7248\u672C`);let n={slug:e.slug,title:e.title,file:a(e.file)};if(o){console.log(JSON.stringify({document:n,current:r.current,versions:r.versions.map(R)},null,2));return}let t=r.versions;if(!t.length){console.log(`${e.slug}\uFF08${e.title}\uFF09\u8FD8\u6CA1\u6709\u5B58\u4E0B\u7684\u7248\u672C\uFF1AGallery \u7B2C\u4E00\u6B21\u770B\u5230\u5B83\u6216\u5B83\u88AB\u6539\u5199\u65F6\u5F00\u59CB\u5B58\u3002`);return}console.log(`${e.slug}\uFF08${e.title}\uFF09\u7684\u5386\u53F2\u7248\u672C\uFF0C\u6700\u65B0\u7684\u5728\u524D\uFF0C\u5171 ${t.length} \u4E2A\uFF1A`),t.forEach((s,l)=>{let i=l===t.length-1,f=K[s.by]??"\u672A\u77E5",m=i||!s.counts?j(s,!0):`${j(s,!1)}\uFF1A${x(s.counts)}`;console.log(` ${u(s.version)} ${A(s.time)} ${P(f,6)} ${m}${s.current?"\uFF08\u73B0\u5728\u7684\u6837\u5B50\uFF09":""}`);for(let E of s.blocks??[])console.log(` ${N(E)}`);s.more&&console.log(` \u8FD8\u6709 ${s.more} \u5757`)}),console.log(`\u63D0\u793A\uFF1Agallery history ${e.slug} --restore <\u7248\u672C> \u6062\u590D\u5230\u90A3\u4E00\u7248\uFF08\u4E0A\u9762\u5F00\u5934\u7684 ${v} \u4F4D\uFF09\uFF1B\u6062\u590D\u524D\u7684\u6837\u5B50\u5148\u5B58\u6210\u4E00\u4E2A\u7248\u672C\uFF0C\u6240\u4EE5\u6062\u590D\u4E5F\u80FD\u518D\u6062\u590D\u56DE\u53BB\u3002`)}async function V(e,o,{json:r}){let n=await h.readFile(e.json,"utf8").catch(()=>null),t=await $("history",{slug:e.slug,action:"restore",version:o,agent:!0});t?.ok||O(t,`\u6CA1\u6709\u6062\u590D ${e.slug}`);let s=i=>u(i.slice(-16));if(r){console.log(JSON.stringify({document:{slug:e.slug,title:e.title,file:a(e.file)},restored:t.restored,same:t.same===!0,...t.same?{}:{kept:t.kept??null,id:t.made??null,counts:t.counts??null,blocks:(t.blocks??[]).map(D),...t.more?{more:t.more}:{}}},null,2));return}let l=`${s(t.restored)}${t.restoredAt?`\uFF08${A(t.restoredAt)}\uFF09`:""}`;if(t.same){console.log(`${e.slug}\uFF08${e.title}\uFF09\u73B0\u5728\u5C31\u662F\u7248\u672C ${l} \u7684\u6837\u5B50\uFF1A\u4EC0\u4E48\u4E5F\u6CA1\u5199\u3002`);return}console.log(`\u6062\u590D\u4E86 ${e.slug}\uFF08${e.title}\uFF09\u5230\u7248\u672C ${l}\uFF08${x(t.counts,{taken:!0})}\uFF09\uFF1A`);for(let i of t.blocks??[])console.log(` ${N(i,{taken:!0})}`);t.more&&console.log(` \u8FD8\u6709 ${t.more} \u5757`),console.log("\u6253\u5F00\u7740\u7684\u9875\u9762\u9A6C\u4E0A\u663E\u793A\u6062\u590D\u540E\u7684\u6837\u5B50\uFF08\u8FD9\u662F Agent \u7684\u4FEE\u6539\uFF1A\u7528\u6237\u53EF\u4EE5\u5728\u9875\u9762\u5E95\u90E8\u786E\u8BA4\u6216\u64A4\u56DE\uFF09\u3002"),console.log(await L(e,n)),t.kept&&console.log(`\u63D0\u793A\uFF1A\u6062\u590D\u524D\u7684\u6837\u5B50\u5B58\u6210\u4E86\u7248\u672C ${s(t.kept)}\uFF1B\u8981\u64A4\u56DE\u8FD9\u6B21\u6062\u590D\uFF1Agallery history ${e.slug} --restore ${s(t.kept)}`)}async function ie(e){let{positional:o,options:r,values:n}=y({options:["--json"],values:["--restore"],argv:e});if(o.length!==1)throw new d("Name one document: gallery history <document> [--json] | --restore <version>.");let t=await I(o[0]);return n.has("--restore")?V(t,n.get("--restore"),{json:r.has("--json")}):U(t,{json:r.has("--json")})}export{$ as a,A as b,u as c,b as d,x as e,N as f,I as g,L as h,O as i,ie as j};
@@ -1,6 +1,6 @@
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{$ as zr,$a as $t,$b as ks,A as K,Aa as wt,Ab as ls,Ac as li,B as _,Ba as gt,Bb as fs,Bc as fi,Ca as bt,Cb as ps,Cc as pi,Da as Et,Db as ds,Dc as di,E as _r,Ea as xt,Eb as hs,Ec as hi,F as we,Fa as yt,Fb as ms,Fc as mi,G as Br,Ga as Dt,Gb as ws,Gc as wi,H as Sr,Ha as Pt,Hb as gs,Hc as gi,I as Fr,Ia as vt,Ib as bs,Ic as bi,J as Tr,Ja as Ot,Jb as Es,Jc as Ei,K as Ir,Ka as _t,Kb as xs,Kc as xi,L as Rr,Lb as Q,Lc as yi,M as ge,Mb as ys,Mc as Di,N as Cr,Nb as Ds,Nc as Pi,O as Ar,Oa as J,Ob as Ps,Oc as vi,P as Lr,Pb as vs,Pc as Oi,Q as kr,Qa as Bt,Qb as Os,Qc as _i,R as Wr,Ra as St,Rb as _s,Rc as Bi,S as $r,Sa as Ft,Sb as Bs,Sc as ye,T as Ur,Ta as Tt,Tb as Ss,Tc as Si,U as Nr,Ua as It,Ub as Fs,Uc as Fi,V as Mr,Va as Rt,Vb as Ts,Vc as Ti,W as Gr,Wa as Ct,Wb as Is,Wc as Ri,X as Vr,Xa as At,Xb as Rs,Xc as Ae,Y as jr,Ya as Lt,Yb as Cs,Yc as Le,Z as Xr,Za as kt,Zb as As,Zc as Ci,_ as Hr,_a as Wt,_b as Ls,_c as q,a as k,aa as Yr,ab as Ut,ac as Ws,ba as Kr,bb as Nt,bc as $s,c as oe,ca as Jr,cb as Mt,cc as Us,d as ae,da as Qr,db as Gt,dc as Ns,e as W,ea as be,eb as Vt,ec as Ms,fa as Zr,fb as jt,fc as Gs,ga as qr,gb as Xt,gc as Vs,h as ne,ha as et,hb as Ht,hc as js,i as ce,ia as rt,ib as zt,ic as Xs,j as ue,ja as tt,jb as Yt,jc as Hs,k as le,ka as st,kb as Kt,kc as zs,l as fe,la as it,lb as xe,lc as Ys,m as pe,ma as Ee,mb as Jt,mc as Ks,na as ot,nb as Qt,nc as Js,oa as at,ob as Zt,oc as Qs,pa as nt,pb as qt,pc as Zs,qa as ct,qb as es,qc as qs,r as de,ra as ut,rb as rs,rc as ei,s as he,sa as lt,sb as ts,sc as ri,t as yr,ta as ft,tb as ss,tc as ti,u as Y,ua as pt,ub as is,uc as si,v as Dr,vb as os,vc as ii,w as me,wb as as,wc as oi,x as Pr,xa as dt,xb as ns,xc as ai,y as vr,ya as ht,yb as cs,yc as ci,z as Or,za as mt,zb as us,zc as ui}from"./chunk-SQ6Y2ZMA.mjs";import{a as Ii}from"./chunk-Y34NR5JL.mjs";import{b as Z}from"./chunk-U3SSPL4K.mjs";import"./chunk-YEY3RSFQ.mjs";import{b as P,c as g,d as I}from"./chunk-W7XHE4CT.mjs";import{a as Ce}from"./chunk-MAFIGVXY.mjs";import{a as x,e as De,f as Pe,i as ve,l as Oe,m as _e,n as Be,o as Se,p as Fe,r as Te,u as Ie,v as Re}from"./chunk-742D2WWJ.mjs";import{a as ni}from"./chunk-UH4SIXTR.mjs";import"./chunk-5L7RYZCL.mjs";import p from"node:fs";import je from"node:path";import{debuglog as Xe}from"node:util";var He=p.constants.O_RDONLY|p.constants.O_NOFOLLOW,ee=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_TRUNC|p.constants.O_NOFOLLOW,ze=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_EXCL|p.constants.O_NOFOLLOW,Ye=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_EXCL,G=384;async function Ke(a,e){return!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.readFile(a,{encoding:e,flag:He}):await p.promises.readFile(a,{encoding:e})}P.value={path:je,debuglog:P.value.debuglog??Xe,ScreenRecorder:P.value.ScreenRecorder,followSymlinks:!0,readFile:Ke,writeFile:async(a,e)=>{!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.writeFile(a,e,{flag:ee,mode:G}):await p.promises.writeFile(a,e)},openFileForWriting:async a=>!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.open(a,ee,G):await p.promises.open(a,"w+"),createWriteStream:(a,e)=>{let r=e?.encoding,t=e?.overwrite??!0;if(!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0){let s=t?ee:ze,c=p.openSync(a,s,G);return p.createWriteStream("",{fd:c,mode:G,encoding:r})}if(!t){let s=p.openSync(a,Ye);return p.createWriteStream("",{fd:s,encoding:r})}return p.createWriteStream(a,r?{encoding:r}:void 0)},mkdir:async(a,e)=>{await p.promises.mkdir(a,e)}};import{mkdtemp as or}from"node:fs/promises";import ar from"node:os";import te from"node:path";import{accessSync as Je,constants as Qe,existsSync as $,rmSync as Ze}from"node:fs";import{tmpdir as qe}from"node:os";import{join as ke}from"node:path";var V=class{#e;#r=new me;#t;#i=!1;#s=[];onclose;onmessage;constructor(e,r,t){this.#e=e,this.#t=t;let s=this.#r.use(new K(r,t));s.on("data",o=>this.#o(o)),s.on("close",()=>{this.onclose&&this.onclose.call(null)}),s.on("error",o=>{this.#t?.(g.error)?.(o)}),this.#r.use(new K(e)).on("error",o=>{this.#t?.(g.error)?.(o)})}send(e){_(!this.#i,"`PipeTransport` is closed."),this.#e.write(e),this.#e.write("\0")}#o(e){if(_(!this.#i,"`PipeTransport` is closed."),this.#s.push(e),e.indexOf("\0")===-1)return;let r=Buffer.concat(this.#s),t=0,s=r.indexOf("\0");for(;s!==-1;){let c=r.toString(void 0,t,s);setImmediate(()=>{this.onmessage&&this.onmessage.call(null,c)}),t=s+1,s=r.indexOf("\0",t)}t>=r.length?this.#s=[]:this.#s=[r.subarray(t)]}close(){this.#i=!0,this.#r.dispose()}};function er(a){try{return Je(a,Qe.W_OK),!0}catch{return!$(a)}}function rr(a){switch(a){case x.FIREFOX:case x.CHROME:return a.charAt(0).toUpperCase()+a.slice(1);default:return a}}var R=class{#e;#r;puppeteer;constructor(e,r,t){this.puppeteer=e,this.#e=r,this.#r=t}get logger(){return this.#r}get browser(){return this.#e}async launch(e={}){e.logger??=this.#r;let{dumpio:r=!1,enableExtensions:t=!1,extensionsEnabledInIncognito:s=[],env:c=process.env,handleSIGINT:o=!0,handleSIGTERM:n=!0,handleSIGHUP:i=!0,acceptInsecureCerts:u=!1,networkEnabled:d=!0,issuesEnabled:f=!0,defaultViewport:h=ge,downloadBehavior:l,slowMo:b=0,timeout:E=3e4,waitForInitialPage:y=!0,protocolTimeout:D,handleDevToolsAsPage:U,idGenerator:C=xe(),blocklist:A,allowlist:B}=e,{protocol:v}=e;if(this.#e==="firefox"&&v===void 0&&(v="webDriverBiDi"),Ae({allowlist:B,blocklist:A,protocol:v}),this.#e==="firefox"&&v==="cdp")throw new Error("Connecting to Firefox using CDP is no longer supported");let m=await this.computeLaunchArguments({...e,protocol:v});if(!$(m.executablePath))throw m.isTempUserDataDir&&await this.cleanUserDataDir(m.userDataDir,{isTemp:!0}),new Error(`Browser was not found at the configured executablePath (${m.executablePath})`);let T=m.args.includes("--remote-debugging-pipe"),N=async()=>{try{await this.cleanUserDataDir(m.userDataDir,{isTemp:m.isTempUserDataDir})}finally{w?.()}};if(this.#e==="firefox"&&v==="webDriverBiDi"&&T)throw new Error("Pipe connections are not supported with Firefox and WebDriver BiDi");let w,O;try{O=Be({executablePath:m.executablePath,args:m.args,handleSIGHUP:i,handleSIGTERM:n,handleSIGINT:o,dumpio:r,env:c,pipe:T,onExit:N,signal:e.signal,logger:e.logger}),w=m.isTempUserDataDir?tr(m.userDataDir,this.#r):void 0}catch(F){throw w?.(),await this.cleanUserDataDir(m.userDataDir,{isTemp:m.isTempUserDataDir}),F}let S,L,se=!1,M=async()=>{se||(se=!0,await this.closeBrowser(O,L))};try{this.#e==="firefox"?S=await this.createBiDiBrowser(O,M,{timeout:E,protocolTimeout:D,slowMo:b,defaultViewport:h,acceptInsecureCerts:u,networkEnabled:d,idGenerator:C,logger:e.logger}):(T?L=await this.createCdpPipeConnection(O,{timeout:E,protocolTimeout:D,slowMo:b,idGenerator:C,logger:e.logger}):L=await this.createCdpSocketConnection(O,{timeout:E,protocolTimeout:D,slowMo:b,idGenerator:C,logger:e.logger}),v==="webDriverBiDi"?S=await this.createBiDiOverCdpBrowser(O,L,M,{defaultViewport:h,acceptInsecureCerts:u,networkEnabled:d,issuesEnabled:f,logger:e.logger}):S=await ye._create(L,[],u,h,l,O.nodeProcess,M,e.targetFilter,void 0,void 0,d,f,U,A,B,e.logger))}catch(F){M();let ie=O.getRecentLogs().join(`
3
- `);throw ie.includes("Failed to create a ProcessSingleton for your profile directory")||process.platform==="win32"&&$(ke(m.userDataDir,"lockfile"))?er(m.userDataDir)?new Error(`The browser is already running for ${m.userDataDir}. Use a different \`userDataDir\` or stop the running browser first.`):new Error(`The browser cannot write to ${m.userDataDir}. Make the \`userDataDir\` writable or use a different one.`):ie.includes("Missing X server")&&e.headless===!1?new Error("Missing X server to start the headful browser. Either set headless to true or use xvfb-run to run your Puppeteer script."):F instanceof Te?new we(F.message):F}return Array.isArray(t)&&await Promise.all([t.map(F=>S.installExtension(F,{enabledInIncognito:s.includes(F)}))]),y&&await this.waitForPageTarget(S,E),S}async closeBrowser(e,r){if(r)try{await r.closeBrowser(),await e.hasClosed()}catch(t){this.#r?.(g.error)?.(t),await e.close()}else await ae(le(k(e.hasClosed()),ce(5e3).pipe(W(()=>k(e.close())))))}async waitForPageTarget(e,r){try{await e.waitForTarget(t=>t.type()==="page",{timeout:r})}catch(t){throw await e.close(),t}}async createCdpSocketConnection(e,r){let t=await e.waitForLineOutput(Se,r.timeout),s=await Z.create(t,void 0,r.logger,r.wsOptions);return new Q(t,s,r.slowMo,r.protocolTimeout,!1,r.idGenerator,r.logger)}async createCdpPipeConnection(e,r){let{3:t,4:s}=e.nodeProcess.stdio,c=new V(t,s,r.logger);return new Q("",c,r.slowMo,r.protocolTimeout,!1,r.idGenerator,r.logger)}async createBiDiOverCdpBrowser(e,r,t,s){let c=process.env.PUPPETEER_WEBDRIVER_BIDI_ONLY==="true",o=await import("./chunk-6QBHU4DF.mjs"),n=await o.connectBidiOverCdp(r,s.logger);return await o.BidiBrowser.create({connection:n,cdpConnection:c?void 0:r,closeCallback:t,process:e.nodeProcess,defaultViewport:s.defaultViewport,acceptInsecureCerts:s.acceptInsecureCerts,networkEnabled:s.networkEnabled,issuesEnabled:s.issuesEnabled,logger:s.logger})}async createBiDiBrowser(e,r,t){let s=await e.waitForLineOutput(Fe,t.timeout)+"/session",c=await Z.create(s,void 0,t.logger,t.wsOptions),o=await import("./chunk-6QBHU4DF.mjs"),n=new o.BidiConnection(s,c,t.idGenerator,t.slowMo,t.protocolTimeout,t.logger);return await o.BidiBrowser.create({connection:n,closeCallback:r,process:e.nodeProcess,defaultViewport:t.defaultViewport,acceptInsecureCerts:t.acceptInsecureCerts,networkEnabled:t.networkEnabled??!0,issuesEnabled:t.issuesEnabled??!0,logger:t.logger})}async getProfilePath(){let e=await this.puppeteer.configuration();return ke(e.temporaryDirectory??qe(),`puppeteer_dev_${this.browser}_profile-`)}async resolveExecutablePath(e,r=!0){let t=await this.puppeteer.configuration(),s=t.executablePath;if(s){if(r&&!$(s))throw new Error(`Tried to find the browser at the configured path (${s}), but no executable was found.`);return s}function c(u,d){switch(u){case"chrome":return d==="shell"?x.CHROMEHEADLESSSHELL:x.CHROME;case"firefox":return x.FIREFOX}return x.CHROME}let o=c(this.browser,e),n=await this.puppeteer.defaultDownloadPath(),i=await this.puppeteer.browserVersion();if(s=Oe({cacheDir:n,browser:o,buildId:i}),r&&!$(s)){let u=t?.[this.browser]?.version;throw u?new Error(`Tried to find the browser at the configured path (${s}) for version ${u}, but no executable was found.`):new Error(`Could not find ${rr(o)} (ver. ${i}). This can occur if either
2
+ import{b as Z}from"./chunk-U3SSPL4K.mjs";import{a as Ce}from"./chunk-MAFIGVXY.mjs";import{a as x,e as De,f as Pe,i as ve,l as Oe,m as _e,n as Be,o as Se,p as Fe,r as Te,u as Ie,v as Re}from"./chunk-742D2WWJ.mjs";import{$ as zr,$a as $t,$b as ks,A as K,Aa as wt,Ab as ls,Ac as li,B as _,Ba as gt,Bb as fs,Bc as fi,Ca as bt,Cb as ps,Cc as pi,Da as Et,Db as ds,Dc as di,E as _r,Ea as xt,Eb as hs,Ec as hi,F as we,Fa as yt,Fb as ms,Fc as mi,G as Br,Ga as Dt,Gb as ws,Gc as wi,H as Sr,Ha as Pt,Hb as gs,Hc as gi,I as Fr,Ia as vt,Ib as bs,Ic as bi,J as Tr,Ja as Ot,Jb as Es,Jc as Ei,K as Ir,Ka as _t,Kb as xs,Kc as xi,L as Rr,Lb as Q,Lc as yi,M as ge,Mb as ys,Mc as Di,N as Cr,Nb as Ds,Nc as Pi,O as Ar,Oa as J,Ob as Ps,Oc as vi,P as Lr,Pb as vs,Pc as Oi,Q as kr,Qa as Bt,Qb as Os,Qc as _i,R as Wr,Ra as St,Rb as _s,Rc as Bi,S as $r,Sa as Ft,Sb as Bs,Sc as ye,T as Ur,Ta as Tt,Tb as Ss,Tc as Si,U as Nr,Ua as It,Ub as Fs,Uc as Fi,V as Mr,Va as Rt,Vb as Ts,Vc as Ti,W as Gr,Wa as Ct,Wb as Is,Wc as Ri,X as Vr,Xa as At,Xb as Rs,Xc as Ae,Y as jr,Ya as Lt,Yb as Cs,Yc as Le,Z as Xr,Za as kt,Zb as As,Zc as Ci,_ as Hr,_a as Wt,_b as Ls,_c as q,a as k,aa as Yr,ab as Ut,ac as Ws,ba as Kr,bb as Nt,bc as $s,c as oe,ca as Jr,cb as Mt,cc as Us,d as ae,da as Qr,db as Gt,dc as Ns,e as W,ea as be,eb as Vt,ec as Ms,fa as Zr,fb as jt,fc as Gs,ga as qr,gb as Xt,gc as Vs,h as ne,ha as et,hb as Ht,hc as js,i as ce,ia as rt,ib as zt,ic as Xs,j as ue,ja as tt,jb as Yt,jc as Hs,k as le,ka as st,kb as Kt,kc as zs,l as fe,la as it,lb as xe,lc as Ys,m as pe,ma as Ee,mb as Jt,mc as Ks,na as ot,nb as Qt,nc as Js,oa as at,ob as Zt,oc as Qs,pa as nt,pb as qt,pc as Zs,qa as ct,qb as es,qc as qs,r as de,ra as ut,rb as rs,rc as ei,s as he,sa as lt,sb as ts,sc as ri,t as yr,ta as ft,tb as ss,tc as ti,u as Y,ua as pt,ub as is,uc as si,v as Dr,vb as os,vc as ii,w as me,wb as as,wc as oi,x as Pr,xa as dt,xb as ns,xc as ai,y as vr,ya as ht,yb as cs,yc as ci,z as Or,za as mt,zb as us,zc as ui}from"./chunk-7DTINW6U.mjs";import"./chunk-YEY3RSFQ.mjs";import{a as ni}from"./chunk-UH4SIXTR.mjs";import{a as Ii}from"./chunk-Y34NR5JL.mjs";import{b as P,c as g,d as I}from"./chunk-W7XHE4CT.mjs";import"./chunk-5L7RYZCL.mjs";import p from"node:fs";import je from"node:path";import{debuglog as Xe}from"node:util";var He=p.constants.O_RDONLY|p.constants.O_NOFOLLOW,ee=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_TRUNC|p.constants.O_NOFOLLOW,ze=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_EXCL|p.constants.O_NOFOLLOW,Ye=p.constants.O_WRONLY|p.constants.O_CREAT|p.constants.O_EXCL,G=384;async function Ke(a,e){return!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.readFile(a,{encoding:e,flag:He}):await p.promises.readFile(a,{encoding:e})}P.value={path:je,debuglog:P.value.debuglog??Xe,ScreenRecorder:P.value.ScreenRecorder,followSymlinks:!0,readFile:Ke,writeFile:async(a,e)=>{!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.writeFile(a,e,{flag:ee,mode:G}):await p.promises.writeFile(a,e)},openFileForWriting:async a=>!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0?await p.promises.open(a,ee,G):await p.promises.open(a,"w+"),createWriteStream:(a,e)=>{let r=e?.encoding,t=e?.overwrite??!0;if(!P.value.followSymlinks&&p.constants.O_NOFOLLOW!==void 0){let s=t?ee:ze,c=p.openSync(a,s,G);return p.createWriteStream("",{fd:c,mode:G,encoding:r})}if(!t){let s=p.openSync(a,Ye);return p.createWriteStream("",{fd:s,encoding:r})}return p.createWriteStream(a,r?{encoding:r}:void 0)},mkdir:async(a,e)=>{await p.promises.mkdir(a,e)}};import{mkdtemp as or}from"node:fs/promises";import ar from"node:os";import te from"node:path";import{accessSync as Je,constants as Qe,existsSync as $,rmSync as Ze}from"node:fs";import{tmpdir as qe}from"node:os";import{join as ke}from"node:path";var V=class{#e;#r=new me;#t;#i=!1;#s=[];onclose;onmessage;constructor(e,r,t){this.#e=e,this.#t=t;let s=this.#r.use(new K(r,t));s.on("data",o=>this.#o(o)),s.on("close",()=>{this.onclose&&this.onclose.call(null)}),s.on("error",o=>{this.#t?.(g.error)?.(o)}),this.#r.use(new K(e)).on("error",o=>{this.#t?.(g.error)?.(o)})}send(e){_(!this.#i,"`PipeTransport` is closed."),this.#e.write(e),this.#e.write("\0")}#o(e){if(_(!this.#i,"`PipeTransport` is closed."),this.#s.push(e),e.indexOf("\0")===-1)return;let r=Buffer.concat(this.#s),t=0,s=r.indexOf("\0");for(;s!==-1;){let c=r.toString(void 0,t,s);setImmediate(()=>{this.onmessage&&this.onmessage.call(null,c)}),t=s+1,s=r.indexOf("\0",t)}t>=r.length?this.#s=[]:this.#s=[r.subarray(t)]}close(){this.#i=!0,this.#r.dispose()}};function er(a){try{return Je(a,Qe.W_OK),!0}catch{return!$(a)}}function rr(a){switch(a){case x.FIREFOX:case x.CHROME:return a.charAt(0).toUpperCase()+a.slice(1);default:return a}}var R=class{#e;#r;puppeteer;constructor(e,r,t){this.puppeteer=e,this.#e=r,this.#r=t}get logger(){return this.#r}get browser(){return this.#e}async launch(e={}){e.logger??=this.#r;let{dumpio:r=!1,enableExtensions:t=!1,extensionsEnabledInIncognito:s=[],env:c=process.env,handleSIGINT:o=!0,handleSIGTERM:n=!0,handleSIGHUP:i=!0,acceptInsecureCerts:u=!1,networkEnabled:d=!0,issuesEnabled:f=!0,defaultViewport:h=ge,downloadBehavior:l,slowMo:b=0,timeout:E=3e4,waitForInitialPage:y=!0,protocolTimeout:D,handleDevToolsAsPage:U,idGenerator:C=xe(),blocklist:A,allowlist:B}=e,{protocol:v}=e;if(this.#e==="firefox"&&v===void 0&&(v="webDriverBiDi"),Ae({allowlist:B,blocklist:A,protocol:v}),this.#e==="firefox"&&v==="cdp")throw new Error("Connecting to Firefox using CDP is no longer supported");let m=await this.computeLaunchArguments({...e,protocol:v});if(!$(m.executablePath))throw m.isTempUserDataDir&&await this.cleanUserDataDir(m.userDataDir,{isTemp:!0}),new Error(`Browser was not found at the configured executablePath (${m.executablePath})`);let T=m.args.includes("--remote-debugging-pipe"),N=async()=>{try{await this.cleanUserDataDir(m.userDataDir,{isTemp:m.isTempUserDataDir})}finally{w?.()}};if(this.#e==="firefox"&&v==="webDriverBiDi"&&T)throw new Error("Pipe connections are not supported with Firefox and WebDriver BiDi");let w,O;try{O=Be({executablePath:m.executablePath,args:m.args,handleSIGHUP:i,handleSIGTERM:n,handleSIGINT:o,dumpio:r,env:c,pipe:T,onExit:N,signal:e.signal,logger:e.logger}),w=m.isTempUserDataDir?tr(m.userDataDir,this.#r):void 0}catch(F){throw w?.(),await this.cleanUserDataDir(m.userDataDir,{isTemp:m.isTempUserDataDir}),F}let S,L,se=!1,M=async()=>{se||(se=!0,await this.closeBrowser(O,L))};try{this.#e==="firefox"?S=await this.createBiDiBrowser(O,M,{timeout:E,protocolTimeout:D,slowMo:b,defaultViewport:h,acceptInsecureCerts:u,networkEnabled:d,idGenerator:C,logger:e.logger}):(T?L=await this.createCdpPipeConnection(O,{timeout:E,protocolTimeout:D,slowMo:b,idGenerator:C,logger:e.logger}):L=await this.createCdpSocketConnection(O,{timeout:E,protocolTimeout:D,slowMo:b,idGenerator:C,logger:e.logger}),v==="webDriverBiDi"?S=await this.createBiDiOverCdpBrowser(O,L,M,{defaultViewport:h,acceptInsecureCerts:u,networkEnabled:d,issuesEnabled:f,logger:e.logger}):S=await ye._create(L,[],u,h,l,O.nodeProcess,M,e.targetFilter,void 0,void 0,d,f,U,A,B,e.logger))}catch(F){M();let ie=O.getRecentLogs().join(`
3
+ `);throw ie.includes("Failed to create a ProcessSingleton for your profile directory")||process.platform==="win32"&&$(ke(m.userDataDir,"lockfile"))?er(m.userDataDir)?new Error(`The browser is already running for ${m.userDataDir}. Use a different \`userDataDir\` or stop the running browser first.`):new Error(`The browser cannot write to ${m.userDataDir}. Make the \`userDataDir\` writable or use a different one.`):ie.includes("Missing X server")&&e.headless===!1?new Error("Missing X server to start the headful browser. Either set headless to true or use xvfb-run to run your Puppeteer script."):F instanceof Te?new we(F.message):F}return Array.isArray(t)&&await Promise.all([t.map(F=>S.installExtension(F,{enabledInIncognito:s.includes(F)}))]),y&&await this.waitForPageTarget(S,E),S}async closeBrowser(e,r){if(r)try{await r.closeBrowser(),await e.hasClosed()}catch(t){this.#r?.(g.error)?.(t),await e.close()}else await ae(le(k(e.hasClosed()),ce(5e3).pipe(W(()=>k(e.close())))))}async waitForPageTarget(e,r){try{await e.waitForTarget(t=>t.type()==="page",{timeout:r})}catch(t){throw await e.close(),t}}async createCdpSocketConnection(e,r){let t=await e.waitForLineOutput(Se,r.timeout),s=await Z.create(t,void 0,r.logger,r.wsOptions);return new Q(t,s,r.slowMo,r.protocolTimeout,!1,r.idGenerator,r.logger)}async createCdpPipeConnection(e,r){let{3:t,4:s}=e.nodeProcess.stdio,c=new V(t,s,r.logger);return new Q("",c,r.slowMo,r.protocolTimeout,!1,r.idGenerator,r.logger)}async createBiDiOverCdpBrowser(e,r,t,s){let c=process.env.PUPPETEER_WEBDRIVER_BIDI_ONLY==="true",o=await import("./chunk-V5JTW2LH.mjs"),n=await o.connectBidiOverCdp(r,s.logger);return await o.BidiBrowser.create({connection:n,cdpConnection:c?void 0:r,closeCallback:t,process:e.nodeProcess,defaultViewport:s.defaultViewport,acceptInsecureCerts:s.acceptInsecureCerts,networkEnabled:s.networkEnabled,issuesEnabled:s.issuesEnabled,logger:s.logger})}async createBiDiBrowser(e,r,t){let s=await e.waitForLineOutput(Fe,t.timeout)+"/session",c=await Z.create(s,void 0,t.logger,t.wsOptions),o=await import("./chunk-V5JTW2LH.mjs"),n=new o.BidiConnection(s,c,t.idGenerator,t.slowMo,t.protocolTimeout,t.logger);return await o.BidiBrowser.create({connection:n,closeCallback:r,process:e.nodeProcess,defaultViewport:t.defaultViewport,acceptInsecureCerts:t.acceptInsecureCerts,networkEnabled:t.networkEnabled??!0,issuesEnabled:t.issuesEnabled??!0,logger:t.logger})}async getProfilePath(){let e=await this.puppeteer.configuration();return ke(e.temporaryDirectory??qe(),`puppeteer_dev_${this.browser}_profile-`)}async resolveExecutablePath(e,r=!0){let t=await this.puppeteer.configuration(),s=t.executablePath;if(s){if(r&&!$(s))throw new Error(`Tried to find the browser at the configured path (${s}), but no executable was found.`);return s}function c(u,d){switch(u){case"chrome":return d==="shell"?x.CHROMEHEADLESSSHELL:x.CHROME;case"firefox":return x.FIREFOX}return x.CHROME}let o=c(this.browser,e),n=await this.puppeteer.defaultDownloadPath(),i=await this.puppeteer.browserVersion();if(s=Oe({cacheDir:n,browser:o,buildId:i}),r&&!$(s)){let u=t?.[this.browser]?.version;throw u?new Error(`Tried to find the browser at the configured path (${s}) for version ${u}, but no executable was found.`):new Error(`Could not find ${rr(o)} (ver. ${i}). This can occur if either
4
4
  1. you did not perform an installation before running the script (e.g. \`npx puppeteer browsers install ${o}\`) or
5
5
  2. your cache path is incorrectly configured (which is: ${t.cacheDirectory}).
6
6
  For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.`)}return s}},re=new WeakMap;function tr(a,e,r=process){let t=re.get(r);if(!t){let c=new Set,o=()=>{for(let n of c)try{Ze(n.userDataDir,{recursive:!0,force:!0,maxRetries:3,retryDelay:100})}catch(i){n.logger(g.error)?.(i)}};t={entries:c,onExit:o},re.set(r,t),r.once("exit",o)}let s={userDataDir:a,logger:e};return t.entries.add(s),()=>{!t?.entries.delete(s)||t.entries.size>0||(r.off("exit",t.onExit),re.delete(r))}}import sr from"node:fs";var ir={force:!0,recursive:!0,maxRetries:10,retryDelay:100};async function j(a){await sr.promises.rm(a,ir)}var X=class extends R{constructor(e,r){super(e,"chrome",r)}async launch(e={}){return(await this.puppeteer.configuration()).logLevel==="warn"&&process.platform==="darwin"&&process.arch==="x64"&&ar.cpus()[0]?.model.includes("Apple")&&console.warn(["\x1B[1m\x1B[43m\x1B[30m","Degraded performance warning:\x1B[0m\x1B[33m","Launching Chrome on Mac Silicon (arm64) from an x64 Node installation results in","Rosetta translating the Chrome binary, even if Chrome is already arm64. This would","result in huge performance issues. To resolve this, you must run Puppeteer with","a version of Node built for arm64."].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{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-XRYECF23.mjs";import"./chunk-5TLLIZT7.mjs";import"./chunk-HFTBVEZK.mjs";import"./chunk-5IHDLEB4.mjs";import"./chunk-B2EIMERT.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-56SVJENP.mjs";import"./chunk-BSJKFE7I.mjs";import"./chunk-L4WLQYFC.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{h as GESTURES,d as addName,b as blockNamed,g as bothSaid,j as keyOf,f as missingSaid,c as packageFolder,a as packageNamed,i as pairsOf,k as run,e as shallowSaid};
@@ -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-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};
2
+ import{b as p,d as m}from"./chunk-2OHANJ6Q.mjs";import{q as d}from"./chunk-BSJKFE7I.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,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,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v}from"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import"./chunk-5L7RYZCL.mjs";export{b as AGENT_LINE,h as FIRST_PORT,f as NO_PREVIEW,i as PORTS,a as USER_LINE,o as addressOf,n as agentPageOf,e as browserLine,j as firstPort,d as nextLine,l as ownerBase,m as pageOf,p as placeAddress,q as portsToTry,u as previewLines,v as previewOfNew,g as previewSkipped,c as sendFirst,k as serverEntry,r as serverFor,s as serverLine,t as serverLines};
@@ -0,0 +1,6 @@
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 V}from"./chunk-LSVCTLS2.mjs";import"./chunk-F63BNJLG.mjs";import"./chunk-ZNGGDUZI.mjs";import{k as _}from"./chunk-B6RAGF4R.mjs";import{a as b,b as Q}from"./chunk-5TLLIZT7.mjs";import{d as z,e as B,g as G,v as J}from"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import{a as ee}from"./chunk-R5RERE6G.mjs";import{c as X}from"./chunk-XNNCQROX.mjs";import"./chunk-LJZIYVNA.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-ZTHICSSF.mjs";import{p as W}from"./chunk-B2EIMERT.mjs";import{c as Y,d as Z,e as M}from"./chunk-5I5ZDDWC.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-6N25CJ6Y.mjs";import"./chunk-F4CT35KL.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-6ILJWFYW.mjs";import{b as H,h as U}from"./chunk-VRPVVMRB.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-VAXLSISW.mjs";import"./chunk-56SVJENP.mjs";import{b as T,f as C,g as K}from"./chunk-L4WLQYFC.mjs";import{b as q}from"./chunk-NOGQX56R.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 re from"node:os";import x from"node:path";import{IMPORT_EXT as se,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(se).flat().join(" "),j=(d,h)=>`${d} ${h}${d===1?"":"s"}`;function fe(d,h,p){let n=(f,s=h)=>(s.match(f)??[]).length,c=n(/<ol class="doc-flow"/g,p),u=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"],[u,"footnote"]].filter(([f])=>f>0).map(([f,s])=>j(f,s)),g=(d.raws?.length??0)-c-(u?1:0);return g>0&&w.push(`${j(g,"HTML block")} kept as written`),w}async function Se(d){let{positional:h,options:p}=C({options:["--no-preview","--no-browser"],argv:d}),[n,c,u]=h;if(h.length<1||h.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&&K(c);let g=x.resolve(n);await v.stat(g).then(a=>a.isFile(),()=>!1)||(console.error(`No such file: ${n}`),process.exit(1));let f=c!==void 0?await V(c):null;f&&(console.error(f),process.exit(1));let s=x.basename(g),F=await v.mkdtemp(x.join(re.tmpdir(),"gallery-import-")),L,y,R;try{let a,$=[];if(w==="markdown")a=[{...await Z(g,F),from:s,children:[]}];else try{({pages:a,skipped:$}=await Y([{file:g,name:s}],F))}catch(e){console.error(`${s} could not be read: ${e.message}`),process.exit(1)}a.length===0&&(console.error(`Nothing in ${s} could be read as a page${$.length?` (not taken: ${$.join(", ")})`:""}.`),process.exit(1)),u?.trim()&&(a[0]={...a[0],title:u.replace(/\s+/g," ").trim()});let I=new Map,te=X({edits:{},reports:{},reportsDirectory:O});y=(await ee(a,{create:async(e,t,l,{lang:r})=>{await import("./chunk-UTKNWYBA.mjs").then(({forgetKept:i})=>i(e));let{directory:o}=await q(e,t,l,{blank:!0,lang:r});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(s.replace(/\.[^.]+$/,""));return l?te.freeSlug(l):ae(O)},folderOf:e=>oe(e,O),fill:e=>M(e),place:(e,t)=>_(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 a)A(e,0);let m=await Promise.all(P.map(async({page:e,depth:t},l)=>{let r=y[l],o=oe(r,O),i=E(o).html,k=await v.readFile(i,"utf8"),ne=(await M({source:I.get(r),nodes:e.nodes,icon:e.icon,own:e.own})).replace(/<p>\u{E000}\d+\u{E001}<\/p>/gu,""),le=U(H(k,{finish:W}).text);return{slug:r,depth:t,page:e,directory:o,htmlFile:i,made:fe(e,ne,k),readOnly:le}}));if(L={slug:y[0]},m.length===1){let[{page:e,directory:t,htmlFile:l,made:r,readOnly:o}]=m;if(console.log(`Created ${b(l)} and ${x.basename(E(t).json)} from ${s}`),console.log(`Title: ${e.title}`),console.log(`Made: ${r.length?r.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 i of e.notes)console.log(` ${i.line?`line ${i.line}: `:""}${i.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 i of o)console.log(` ${i}`)}}else{console.log(`Created ${j(m.length,"document")} from ${s} (each nested as in the file):`);for(let{slug:l,depth:r,page:o,htmlFile:i,made:k}of m)console.log(`${" ".repeat(r+1)}${l} ${o.title} ${b(i)}`),console.log(`${" ".repeat(r+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:r})=>(r.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
+ ${e.join(`
4
+ `)}`);let t=m.flatMap(({slug:l,readOnly:r})=>r.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
+ ${t.join(`
6
+ `)}`)}$.length&&console.log(`Not taken from ${s} (${$.length}): ${$.join(", ")}`);for(let e of await Q())console.log(e);R=`edit ${b(m[0].htmlFile)}${m.length>1?" (and the others)":""} into the document as \u5199\u4F5C\u504F\u597D asks.`}finally{await v.rm(F,{recursive:!0,force:!0})}let N=await J(L.slug,{skipped:G(p),command:`gallery import ${s}`});console.log(z(N,R)),console.log(`\u63D0\u793A\uFF1Awhen they are written, hand them in: gallery export ${y.join(" ")}, then gallery qa ${y.join(" ")}`);let D=await B(N,p);D&&console.log(D);for(let a of N)console.log(a)}export{Se as run};
@@ -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{b as g}from"./chunk-6N25CJ6Y.mjs";import"./chunk-F4CT35KL.mjs";import{b as i,f as d}from"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";import{readFileSync as w}from"node:fs";import y from"node:fs/promises";import l from"node:path";import{emojiDataDirectory as $,reportsDirectory as c}from"../browser/shared/paths.mjs";import{layoutOf as h}from"../browser/shared/workspace.mjs";var b=/^[\p{Ll}\p{Lo}\d_-]{1,49}$/u,N=()=>{try{return JSON.parse(w(l.join($,"names.json"),"utf8"))}catch{return{}}},O=t=>t.trim().replace(/^:(.+):$/,"$1").toLocaleLowerCase().replace(/\s+/g,"-"),u={type:"that is not an image (PNG, JPEG, GIF, WebP, AVIF, SVG or ICO)",size:"the image is over 2 MB",download:"the address did not give the image",name:"the library has an emoji of that name already"};async function p(t){let[,{list:e}]=await t.listEmojis(),a=h(c).emojiLibrary;return e.map(o=>{let s=o.url.slice(o.url.lastIndexOf("/")+1);return{name:o.name,id:o.id,file:s,path:l.join(a,s),created:new Date(o.created_time).toISOString()}})}async function S(t){if(t.length!==2)throw new i("Name the emoji and its image: gallery emoji add <name> <image>.");let e=O(t[0]);if(!b.test(e))throw new i(`Not a name a custom emoji takes: ${t[0]} (lower-case letters, digits, - and _, under 50 characters).`);let a=t[1],o=/^https?:\/\//i.test(a),s=g({reportsDirectory:c});Object.hasOwn(N(),e)&&(console.error(`${e} is the name of a standard emoji: a custom emoji takes another name.`),process.exit(1));let r;if(o)r={name:e,url:a};else{let m=l.resolve(a),f=await y.readFile(m).catch(()=>null);f||(console.error(`No image ${m}: give the path of a PNG, JPEG, GIF, WebP, AVIF, SVG or ICO file, or its http(s) address.`),process.exit(1)),r={name:e,data:f.toString("base64")}}let[,n]=await s.addEmoji(r);n?.ok||(console.error(`Not added: ${u[n?.reason]??n?.message??n?.reason??"no answer"}${u[n?.reason]&&n?.message?` (${n.message})`:""}.`),process.exit(1));let j=(await p(s)).find(m=>m.id===n.entry.id);console.log(`Added the custom emoji ${e} (${o?a:l.basename(a)}) to the workspace's library: ${j?.path??""}`),console.log(`\u4E0B\u4E00\u6B65\uFF1Agallery set <document> --icon ${e} makes it a document's page icon (a picture copied into its assets/); the workbench's icon picker lists it too.`)}async function k(t){let e=await p(g({reportsDirectory:c}));if(t.has("--json")){console.log(JSON.stringify({workspace:c,emojis:e},null,2));return}if(e.length===0){console.log("No custom emoji yet: gallery emoji add <name> <image> adds one.");return}console.log(`${e.length} custom emoji in ${h(c).emojiLibrary}:`);for(let{name:a,file:o}of e.sort((s,r)=>s.name.localeCompare(r.name)))console.log(` ${a} ${o}`);console.log("\u63D0\u793A\uFF1Ause one as a document's icon: gallery set <document> --icon <name>.")}async function x(t){let[e,...a]=t;if(e==="add"){let{positional:o}=d({argv:a});return S(o)}if(e==="list"){let{positional:o,options:s}=d({options:["--json"],argv:a});if(o.length)throw new i("gallery emoji list takes no arguments.");return k(s)}throw new i(e?`No such action: emoji ${e} (add, list).`:"Say what to do: gallery emoji add <name> <image>, or gallery emoji list.")}export{x as run};
@@ -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,b,c,d,e,f,g,h,i}from"./chunk-NW6LAU22.mjs";import"./chunk-XRYECF23.mjs";import"./chunk-5TLLIZT7.mjs";import"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import"./chunk-HFTBVEZK.mjs";import"./chunk-5IHDLEB4.mjs";import"./chunk-B2EIMERT.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-56SVJENP.mjs";import"./chunk-PBMOC7KA.mjs";import"./chunk-BSJKFE7I.mjs";import"./chunk-L4WLQYFC.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{c as HOME_NOT_MADE,h as emptyRequiredOf,d as missingPageSaid,a as pageAddressOf,b as pageAloneOf,e as pageServiceOp,i as run,f as setsOf,g as settingsGiven};
@@ -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,b,c,d,e,f,g,h}from"./chunk-ZFVF2YPV.mjs";import"./chunk-WHGANNEY.mjs";import"./chunk-S6YEC4GE.mjs";import"./chunk-V3XROSP5.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-OKVQQ3CX.mjs";import"./chunk-NW6LAU22.mjs";import"./chunk-X4WNLFIK.mjs";import"./chunk-XRYECF23.mjs";import"./chunk-5TLLIZT7.mjs";import"./chunk-OM24O4KR.mjs";import"./chunk-LZY74XTP.mjs";import"./chunk-2MYTOOP6.mjs";import"./chunk-LHGKPMTI.mjs";import"./chunk-HFTBVEZK.mjs";import"./chunk-TLNJWEFY.mjs";import"./chunk-ZOEJQOKT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-QR4V4A2Z.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-TQZU7D7C.mjs";import"./chunk-5IHDLEB4.mjs";import"./chunk-B2EIMERT.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-6N25CJ6Y.mjs";import"./chunk-F4CT35KL.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-6ILJWFYW.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-56SVJENP.mjs";import"./chunk-PBMOC7KA.mjs";import"./chunk-BSJKFE7I.mjs";import"./chunk-L4WLQYFC.mjs";import"./chunk-NOGQX56R.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{a as PAGE_ASIDE,b as PAGE_INSIDE_ALONE,e as cardChangesOf,c as firstInstance,d as outsideWhat,g as pageHost,f as pageSaves,h as pageTryCommand};
@@ -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}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";export{b as UsageError,e as asksHelp,g as checkSlug,f as commandArguments,j as documentArguments,i as documentNamed,h as inTrashSaid,a as isOption,k as scriptArguments,d as usageFailureText,c as usageOf};
2
+ import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk-L4WLQYFC.mjs";import"./chunk-5L7RYZCL.mjs";export{b as UsageError,e as asksHelp,g as checkSlug,f as commandArguments,j as documentArguments,i as documentNamed,h as inTrashSaid,a as isOption,k as scriptArguments,d as usageFailureText,c as usageOf};
@@ -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 S from"node:fs";import{fileURLToPath as y}from"node:url";import{namedPlace as w}from"../browser/shared/page-address.mjs";import{pageLinks as g}from"../browser/shared/page-links.mjs";import{RESERVED as b,isSlugName as v,listTrash as N,slugPattern as x}from"../browser/shared/workspace.mjs";var h=t=>/^--.|^-[A-Za-z]/.test(t),a=class extends Error{constructor(s){super(s),this.name="UsageError"}};function O(t){let s=S.readFileSync(y(t),"utf8").split(/\r?\n/),n=s.findIndex(e=>!e.startsWith("//"));return s.slice(0,n===-1?s.length:n).map(e=>e.replace(/^\/\/ ?/,"")).join(`
3
+ `)}var R=t=>/^Usage: (gallery \S+|npm run \S+|node \S+)/.exec(t)?.[1]??"this command",A=t=>t.split(`
4
+ `)[0],E=(t,s,n=A(t))=>{let e=R(t);return`${s}
5
+ ${n} (${e}${e.startsWith("npm run")?" --":""} --help says more)`},P=t=>{let s=t.indexOf("--");return(s===-1?t:t.slice(0,s)).some(n=>n==="--help"||n==="-h")};function $({options:t=[],values:s=[],repeated:n=[],argv:e=process.argv.slice(2)}={}){let i=e.indexOf("--"),[o,c]=i===-1?[e,[]]:[e.slice(0,i),e.slice(i+1)],p=[],f=new Set,d=new Map;for(let l=0;l<o.length;l++){let r=o[l],[u,k]=r.startsWith("--")&&r.includes("=")?[r.slice(0,r.indexOf("=")),r.slice(r.indexOf("=")+1)]:[r,void 0];if(!h(r))p.push(r);else if(s.includes(u)||n.includes(u)){let m=k??(l+1<o.length&&!h(o[l+1])?o[++l]:void 0);if(!m)throw new a(`${u} takes a value`);n.includes(u)?d.set(u,[...d.get(u)??[],m]):d.set(u,m)}else if(t.includes(r))f.add(r);else throw new a(`Unknown option: ${r}`)}return{positional:[...p,...c],options:f,values:d}}function T(t){if(!x.test(t))throw new a(`Not a document's slug: ${t} (lowercase kebab-case).`);if(b.has(t))throw new a(`Not a document's slug: ${t} (a name the workspace keeps for itself).`);return t}async function U(t){let{reportsDirectory:s}=await import("../browser/shared/paths.mjs"),n=await N(s),e=n.filter(({kind:c})=>c==="document"),i=w(t,g(e));if(i)return`${t} is a document in the trash ("${e.find(({slug:c})=>c===i.slug).title}"): it has to be restored in the workbench first.`;let o=n.find(({kind:c,slug:p})=>c==="page"&&p===t);return o?`${t} is a custom page in the trash ("${o.title}"), not a document: once it is restored in the workbench, gallery page open ${t} opens it.`:null}async function L(t){let{listReportSlugs:s}=await import("../browser/shared/reports.mjs"),n=(await s()).filter(v),e=w(t,g(n.map(o=>({slug:o}))));if(e)return e;let i=await U(t);if(i)throw new a(i);if(!x.test(t))throw new a(`Not a document's slug, link or address: ${t} (gallery list shows them).`);return{slug:T(t),block:null}}async function W({options:t=[],values:s=[],argv:n,noneIsAll:e=!1}={}){let{listReportSlugs:i}=await import("../browser/shared/reports.mjs"),{positional:o,options:c,values:p}=$({options:["--all",...t],values:s,argv:n}),f=c.has("--all");if(f&&o.length>0)throw new a("Name documents or pass --all, not both.");if(!f&&o.length===0&&!e)throw new a("Name a document (or pass --all).");let d=await Promise.all(o.map(L));return{slugs:f||o.length===0?await i():[...new Set(d.map(({slug:l})=>l))],options:c,values:p}}async function I(t,{documents:s=!1,...n}={}){let e=O(t),i=n.argv??process.argv.slice(2);P(i)&&(console.log(e),process.exit(0));try{return s?await W({...n,argv:i}):$({...n,argv:i})}catch(o){if(!(o instanceof a))throw o;console.error(E(e,o.message)),process.exit(2)}}export{h as a,a as b,O as c,E as d,P as e,$ as f,T as g,U as h,L as i,W as j,I as k};