@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
@@ -1,15 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as we,b as q,c as X,f as be,g as L,h as ke,i as Q,l as ye,m as xe}from"./chunk-HX4DLE3J.mjs";import{a as gt}from"./chunk-ZTHICSSF.mjs";import{b as le,c as $t,e as K,f as de,i as fe,j as he,m as ue,n as pe,o as me,p as ge,q as $e,r as wt}from"./chunk-FJLM7YE7.mjs";import{a as pt}from"./chunk-PAREWQGB.mjs";import{a as te,b as ee,c as oe,d as se,e as ne,f as ie,g as ae,h as re,l as ce}from"./chunk-BFJGHSQN.mjs";import{b as mt,c as Yt,d as qt,e as Xt,g as Qt}from"./chunk-U5XL7D6A.mjs";import{a as w,b as Vt,c as Zt}from"./chunk-HYMEEXKN.mjs";import{g as T,j as Kt,l as Gt,m as Jt}from"./chunk-TKWEX4FD.mjs";import{existsSync as bo,readFileSync as ki,readdirSync as yi}from"node:fs";import S from"node:fs/promises";import N from"node:path";function Se(t){if(!t||!Array.isArray(t.lines))throw new Error("diff: lines must be an array.");t.lines.forEach(e=>{if(!e||!["added","removed","unchanged"].includes(e.type)||typeof e.content!="string"||/[\r\n]/.test(e.content))throw new Error("diff: each line needs a valid type and single-line content.");if(e.lineNumber!=null&&(!Number.isInteger(e.lineNumber)||e.lineNumber<1))throw new Error("diff: lineNumber must be a positive integer.")})}import{BODY as kt,isInstance as Wo}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as Bo}from"../browser/shared/components/installed.mjs";import{attr as F,elementsOf as Ne,hasClass as Ho,walk as yt}from"../browser/shared/html-tree.mjs";import{CHART_DATA as Ko,CHART_KEY as Go,CHART_SOURCE as z,VIEW_FROM as tt,cellWords as Jo,rowsReading as ve,tableRows as Vo}from"../browser/shared/table-chart.mjs";var Zo=t=>t.tagName==="script"&&(F(t,"type")??"").trim().toLowerCase()==="application/json",Oe=t=>t.nodeName==="#text"?t.value:(t.childNodes??[]).map(Oe).join("");function Yo(t){let e=t;for(;e&&e.tagName!=="figure";)e=e.parentNode;let s=e?Ne(e).find(o=>/^h[2-4]$/.test(o.tagName)):null;return s?Jo(Oe(s)):""}function Ee(t,e,s=w(t)){let o=[];return yt(s,n=>{let i=e(n);if(i===void 0||!n.sourceCodeLocation)return;let a=n.childNodes.find(Zo);o.push({type:i,line:n.sourceCodeLocation.startLine,text:a?a.childNodes.map(c=>c.value??"").join(""):null,source:F(n,Ko),tag:n.tagName,holder:n.parentNode?.tagName,title:Yo(n)})},kt),o}var qo=t=>t.tagName==="ol"&&F(t,"data-doc-chart")==="flow",et=(t,e)=>Ee(t,s=>qo(s)?void 0:F(s,"data-doc-chart"),e),Xo=t=>Ee(t,e=>Ho(e,"doc-diff")?"diff":void 0);function G(t){let e=new Map;return yt(t,s=>{let o=F(s,z);if(o===void 0||!s.sourceCodeLocation)return;(e.get(o)??e.set(o,[]).get(o)).push({line:s.sourceCodeLocation.startLine,offset:s.sourceCodeLocation.startOffset,table:Ne(s).find(i=>i.tagName==="table")??null})},{...kt,inTemplates:!1}),e}function xt(t,e){let s=e.get(t)??[];if(s.length===0)return{error:`no table's frame carries ${z}="${t}", so the chart has nothing to draw: put the table back, or delete the card`};if(s.length>1)return{error:`${s.length} tables carry ${z}="${t}" (lines ${s.map(({line:c})=>c).join(", ")}): a key names one table (the chart draws the first); take it off the copies`};let[{line:o,table:n}]=s;if(!n)return{error:`the frame carrying ${z}="${t}" (line ${o}) holds no table`};let i=gt(n),a=Vo(i);return a.error?{error:`its table (line ${o}) ${a.error}`}:{...a,line:o,cells:i}}function St(t){let e=[t,...L(t).filter(({files:n})=>n.includes("kit.js")).map(n=>Q(n,"kit.js")??"")].join(`
3
- `),s=new Set([...e.matchAll(/DocCharts\.define\(\s*(["'`])([a-z][a-z0-9-]*)\1/g)].map(n=>n[2])),o=new Set([...e.matchAll(/DocCharts\.define\(\s*(["'`])([^"'`\n]*)\1/g)].map(n=>n[2]).filter(n=>!s.has(n)));return{defined:s,misnamed:o}}function Nt(t){let e=w(t),s=[],{defined:o,misnamed:n}=St(t),i=null;for(let{type:a,line:c,text:l,source:r,tag:d,holder:f}of et(t,e)){let h=`data-doc-chart="${a}" (line ${c})`;if(d==="table"){s.push(f==="figure"?`${h} is on a table inside a <figure>: the chart's card is a figure of its own, so write the table outside it, its <caption> the chart's title`:`${h} is on a table the tools leave as written (inside a whole block, an element with a class of the document's own, a cell): a chart is drawn from a table outside one`);continue}if(n.has(a)){s.push(`${h}: the document's script defines "${a}" with DocCharts.define, which refuses that name: a chart type's name is lowercase letters, digits and hyphens, a letter first ("interval", "ci-plot"); rename it in both places`);continue}if(!o.has(a)){s.push(`${h}: the document's script does not define "${a}": define it once in the document's <script> with DocCharts.define("${a}", ({ host, data, tokens, width, height }) => { \u2026 }) (references/writing-html.md, "Figures and charts")`);continue}if(r!==void 0){if(l!==null){s.push(`${h}: a chart drawn from a table takes its data from the table: take its <script type="application/json"> out`);continue}let u=xt(r,i??=G(e));u.error&&s.push(`${h}: ${u.error}`);continue}if(l===null){s.push(`${h} needs its data in a <script type="application/json"> child`);continue}try{JSON.parse(l)}catch(u){s.push(`${h}: its data is not valid JSON (${u.message})`)}}s.push(...Le(e,i??=G(e)).failures);for(let{line:a,text:c}of Xo(t)){if(c===null)continue;let l=`.doc-diff (line ${a})`;try{Se(JSON.parse(c))}catch(r){s.push(`${l}: ${r instanceof SyntaxError?`its options are not valid JSON (${r.message})`:r.message}`)}}return s}function Te(t,{written:e=t}={}){let s=w(t),o=[],{defined:n}=St(t),i=null,a=null;for(let{type:c,line:l,text:r,source:d,title:f,tag:h}of et(t,s)){if(d===void 0||h==="table"||r!==null||!n.has(c))continue;let u=`data-doc-chart="${c}" (line ${l})`;if(!f){a??=new Set(e===t?[]:et(e).map(k=>k.source).filter(k=>k!==void 0));let b=e!==t&&!a.has(d);o.push(`${u}: this chart card has no title: ${b?"write a <caption> on its table (the one with data-doc-chart), which becomes the card's h3":"write an h3 in the card's figure, before the chart"}`)}let m=xt(d,i??=G(s));if(m.error)continue;let{blank:p,twice:g}=ve(m.cells,m.data);p&&o.push(`${u}: its table's header (line ${m.line}) has a cell with no words, so that column's values are keyed "" in data: write the column's name there`),g.length>0&&o.push(`${u}: its table's header (line ${m.line}) names ${g.map(b=>`"${b}"`).join(", ")} twice, so data keeps the later column's value under it: give each column a name of its own`)}return o.push(...Le(s,i??=G(s)).notes),o}var bt=500;function Le(t,e){let s=[],o=[],n=T().packages;return yt(t,i=>{let a=F(i,tt);if(a===void 0||!i.sourceCodeLocation)return;let c=F(i,Bo),l=`${c??i.tagName} (line ${i.sourceCodeLocation.startLine})`;if(!Wo(i))return void s.push(`<${i.tagName}> (line ${i.sourceCodeLocation.startLine}) carries ${tt}="${a}", which only a view of a table carries: an instance of a custom block (<div data-doc-component="<scope>/<name>">) whose block's needs hold "tables"; take it off`);if(!Go.test(a))return void s.push(`${l}: ${tt}="${a}" is no key: a letter, then letters, digits, "_" or "-", 32 at most, as the table's frame writes it in ${z}`);let r=e.get(a)??[];if(r.length===0)return void s.push(`${l}: no table's frame carries ${z}="${a}", so the view has no table to read: put the table back, or delete the view`);if(r.length>1)return void s.push(`${l}: ${r.length} tables carry ${z}="${a}" (lines ${r.map(({line:g})=>g).join(", ")}): a key names one table (the view reads the first); take it off the copies`);let[{line:d,offset:f,table:h}]=r;if(!h)return void s.push(`${l}: the frame carrying ${z}="${a}" (line ${d}) holds no table`);i.sourceCodeLocation.startOffset<f&&o.push(`${l} stands before the table it reads (${z}="${a}", line ${d}): it works there, but each block's writing.md writes the table first and the view after it, as its example does: move the view below the table, unless the document is meant to open on it`);let u=n.get(c)?.needs;u&&!u.includes("tables")&&o.push(`${l} carries ${tt}="${a}", but its block's needs hold no "tables", so it reads no table: add "tables" to needs in its component.json, or take the key off`);let m=gt(h);m.merged&&o.push(`${l}: its table (line ${d}) has merged cells, which no view reads, so the view shows nothing of it: write each value in its own cell`);let p=m.names?m.rows.length:Math.max(0,m.rows.length-1);p>bt&&o.push(`${l}: its table (line ${d}) has ${p} rows: every view of a table reads it again as it is typed in, and past ${bt} rows that slows typing in it; split it, or keep what a view shows to ${bt} rows`)},kt),{failures:s,notes:o}}function Ae(t){let e=w(t),s=[],o=[],{defined:n}=St(t),i=null,a=(c,l)=>`${c} ${l}${c===1?"":"s"}`;for(let{type:c,line:l,text:r,source:d,tag:f}of et(t,e)){if(d===void 0||f==="table"||r!==null||!n.has(c))continue;let h=xt(d,i??=G(e));if(h.error)continue;let{rows:u,columns:m,foot:p,extra:g}=ve(h.cells,h.data),b=`data-doc-chart="${c}" (line ${l})`,k=[a(u,"row")];for(let{name:x,numbers:v,words:E,empty:H}of m){let R=v+E+H,Y=v===R&&R>0?"numbers":E===R&&R>0?"words":[v&&a(v,"number"),E&&`${E} as words`,H&&`${H} empty (null)`].filter(Boolean).join(", ")||"no rows";k.push(`"${x}": ${Y}`),v>0&&E>0&&o.push(`${b}: its table's column "${x}" (line ${h.line}) reads as numbers in ${a(v,"row")} and as words in ${E}: write each of its cells as one number (an empty cell, "\u2014" or "n/a" for none: null in data), or, for a column of words, data-sort-type="text" on its header cell`)}p>0&&o.push(`${b}: its table's <tfoot> (line ${h.line}) holds ${a(p,"row")} the chart leaves out, and a table with a <tfoot> has no table tools in the preview: keep a total out of a table you chart and say it in the text`),g>0&&o.push(`${b}: ${a(g,"row")} of its table (line ${h.line}) ${g===1?"has":"have"} cells past the header, which the chart does not read: give each column a header cell`),s.push(`${c} (line ${l}) reads its table (line ${h.line}): ${k.join("; ")}`)}return{readings:s,notes:o}}import{BODY as xi,componentOf as Si,matchesNode as ko}from"../browser/shared/components/index.mjs";import{FLOW as Ni}from"../browser/shared/components/list.mjs";import{attr as O,elementsOf as yo,walk as M}from"../browser/shared/html-tree.mjs";import{GLYPH_SETS as vi,ICON_COLORS as xo,glyphOf as Oi,glyphValue as Ei,iconKind as Pt,iconMarkup as Ti,iconValueOf as Li}from"../browser/shared/emoji/icon-value.mjs";import Qo from"node:vm";import{LINE_START as nt,lineStart as ts}from"../browser/shared/code-lines.mjs";import{BODY as De,COMPONENTS as es,FLOWS as os,instanceSlots as ss,instancesOf as ns,isInstance as D,isSlot as _e,matchesNode as P,ownSlots as is,partOf as Tt,vocabulary as as}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as C,INSTANCE as rs,PACKAGE_ID as it,SCHEMA as vt,SLOT as I,schemaAhead as cs}from"../browser/shared/components/installed.mjs";import{packageScript as ls}from"../browser/shared/export-wrap.mjs";import{asDocName as ds,kitNamespace as fs}from"../browser/shared/old-names.mjs";import{shortSheets as hs}from"../browser/shared/components/sheets.mjs";import{attr as y,curlyQuoted as us,hasClass as ps,walk as J}from"../browser/shared/html-tree.mjs";var{authoring:st,runtime:Ce}=as(),ms="input, select, textarea, button, details, table",at=t=>t.sourceCodeLocation?.startLine,$=t=>at(t)?` (line ${at(t)})`:"";function ze(t){let e=(o,n)=>{let i=Array.from({length:n.length+1},(a,c)=>c);for(let a=1;a<=o.length;a++){let c=i[0];i[0]=a;for(let l=1;l<=n.length;l++){let r=i[l];i[l]=Math.min(i[l]+1,i[l-1]+1,c+(o[a-1]===n[l-1]?0:1)),c=r}}return i[n.length]},[s]=[...st.keys()].filter(o=>o.startsWith(t.slice(0,7))).map(o=>[o,e(t,o)]).sort((o,n)=>o[1]-n[1]);return s&&s[1]<=3?` (${s[0]}?)`:""}function gs(t,e,s){let{part:o,property:n,min:i}=t.shares,a=new RegExp(`(?:^|;)\\s*${n}\\s*:\\s*([^;]*)`),c=s.map(f=>a.exec(y(f,"style")??"")?.[1].trim()??null),l=c.filter(f=>f!==null);if(l.length===0)return[];let r=`${t.id}${$(e)}`;return l.length<c.length?[`${r}: ${n} on ${l.length} of its ${c.length} ${o}: write it on every one of them, or on none (equal widths)`]:l.map(Number).some(f=>!Number.isFinite(f)||f<i-1e-9||f>1)?[`${r}: ${n} is a share of the row, a number from ${Math.round(i*1e3)/1e3} to 1 (${l.join(", ")})`]:[]}var ot={"doc-dialog-header":'a detail card has no header: its content region (<div class="doc-dialog-content">) stands alone in its panel',"doc-dialog-title":"a detail card's title is an ordinary heading (<h3>), first in its content region","doc-dialog-close":"a detail card has no close button: Esc and a press outside it close it","data-doc-dialog-close":"a detail card has no close button: Esc and a press outside it close it","doc-section-header":"a section's title is a plain heading (<h2>) with an ordinary paragraph below it for the line that says what the section is: no <div> goes around them","doc-grid":'a card row is now columns: <div class="doc-columns"> holding one <div class="doc-column"> per card',"doc-grid-3":'a card row is now columns: <div class="doc-columns"> holding three <div class="doc-column">',"doc-lede":`write the line under the title as a paragraph of the header (an ordinary <p>), or as small text, <p class="doc-note"): the header's lines read as the body's paragraphs`,"doc-source":`write the line under the title as a plain paragraph of the header (an ordinary <p>), or as small text (<p class="doc-note">): the header's lines read as the body's paragraphs`,"doc-prose":"write the text straight in its flow (the page, a Sheet panel, a section, a panel, a column\u2026): it reads the same there","doc-prose-h1":"write an h1","doc-prose-h2":"write an h2","doc-prose-h3":"write an h3","doc-prose-h4":"write an h4","doc-state-grid":'put the groups side by side in columns (<div class="doc-columns">)',"doc-state-group":"write the group's title as a heading and its controls as blocks of their own in a column","doc-state-status":'write the line as small text, <p class="doc-note">',"doc-code-block":'a code block is <div class="doc-code"> holding its title (<div class="doc-code-title">) and the <pre><code>',"doc-code-card":'a code block is <div class="doc-code"> holding its title and its <pre>; a diff is <div class="doc-diff">',"doc-code-header":'write the title as <div class="doc-code-title">: the kit draws the rest of the header',"data-doc-diff":'a diff is <div class="doc-diff"> holding its title and its options as JSON (sdk/doc-code.d.ts)',"data-doc-diff-stats":"the kit shows a diff's counts in its header: remove it","doc-code--wrap":"a code block wraps its long lines by itself: remove it (doc-code--nowrap scrolls them instead)"},$s={[nt]:'write it on its <div class="doc-code">',"data-start":`write ${nt} on its <div class="doc-code">`,"data-line-numbers":'write it on its <div class="doc-code">',"data-folded-lines":'write it on its <div class="doc-code">',"data-title":'write the title in its <div class="doc-code-title">',"data-wrap":'for long lines that scroll, write class="doc-code doc-code--nowrap" on its <div class="doc-code">'};function ws(t){let e=[],s=t.tagName==="pre"?t.parentNode:t.tagName==="code"&&t.parentNode?.tagName==="pre"?t.parentNode.parentNode:null;if(s?.tagName&&P(s,".doc-code"))for(let[n,i]of Object.entries($s))y(t,n)!==void 0&&e.push(`${n}${$(t)} on the <${t.tagName}> of a code block does nothing: ${i}`);let o=t.tagName==="div"&&P(t,".doc-code")?y(t,nt):void 0;return o!==void 0&&ts(o)===null&&e.push(`${nt}="${o}"${$(t)}: the number of a code block's first line is a whole number from 1`),e}var Ie=os.join(", "),bs=t=>P(t.parentNode,Ie)||t.parentNode?.tagName==="div"&&!y(t.parentNode,"class")&&P(t.parentNode.parentNode,Ie);function ks(t,e){let s=[];J(e,n=>s.push(...us(t,n)));let o=n=>n.replace(/=(\s*)[“”]/,'=$1"').replace(/[“”]$/,'"');return s.map(({written:n,line:i},a)=>a===0?`line ${i}: attribute ${n} uses curly quotes (U+201C/U+201D), which HTML reads as part of the value: write straight quotes, ${o(n)}; an editor keeping a file's \u201C\u2026\u201D style may change them`:`line ${i}: attribute ${n} uses curly quotes too: write ${o(n)}`)}var je={details:"write a plain <details> without the class (its <summary>, then what it holds): the export makes it the kit's"},ys="write a <section> of no attribute straight in it for each tab, starting with its heading (<h2>\u2013<h4>), the tab's name, the rest its blocks, and nothing else: the export makes the kit's tabs",xs='a bookmark written the short way is a paragraph in a flow holding only <a class="doc-bookmark" href="https://\u2026">its title</a> (a title attribute its description, nothing else on it, words alone in it): the export makes the card';function Me(t){let e=[];return J(t,s=>{y(s,C)!==void 0&&e.push(s)},De),e}var Ss=t=>{let e=t.parentNode;for(;e&&!(D(e)||_e(e));)e=e.parentNode;return e??null};function Ns(t,e){let s=[];return J(t,o=>{let n=y(o,I);if(n===void 0)return;if(D(o))return void s.push(`${I}="${n}"${$(o)} on the instance itself: a slot is an element inside it`);if(!_e(o))return void s.push(`${I}${$(o)} on a <${o.tagName}>: a slot is a block-level <div> or <section>`);let i=Ss(o),a=i&&D(i)?e?.get(y(i,C)):null;if(!i||!D(i)||a&&Pe(i,a,o))return void s.push(`${I}="${n}"${$(o)} stands outside any instance's own markup: a slot is a part of a component package's instance, written in its template`);y(o,"data-block-id")!==void 0&&s.push(`${I}="${n}"${$(o)}: a slot is no block: it carries no data-block-id`)}),s}var vs=(t,e)=>{for(let s=e.parentNode;s;s=s.parentNode)if(s===t)return!0;return!1},Pe=(t,e,s)=>Object.values(e.parts??{}).filter(({edit:o})=>o==="text"||o==="data").some(({at:o})=>Tt(t,o).some(n=>vs(n,s))),Re=(t,e)=>is(t).filter(s=>!Pe(t,e,s)),Os=t=>t.flatMap(e=>D(e)?it.test(y(e,C))?[]:[`${C}="${y(e,C)}"${$(e)} names no custom block: write <scope>/<name>, the id of a custom block of the workspace's components/ folder`]:[`${C}${$(e)} on a <${e.tagName}>: an instance of a component is a block-level <div> or <section>`]);function Ue(t){let e=Me(t).filter(o=>D(o)&&it.test(y(o,C))),s=e.length>0?T():null;return e.flatMap(o=>{let n=y(o,C),i=s.packages.get(n);if(i&&!cs(y(o,vt),i.schema))return[];if(i)return[`line ${at(o)}: <${o.tagName} ${C}="${n}">: ${vt}="${y(o,vt)}" is past the ${i.schema??1} its package's manifest reads (schema): nothing can write it back, and the block shows read-only until the package reads it`];let a=s.problems.get(n)?.problem,c=a?`package ${n} does not load (${Kt("en",a)})`:`no package ${n} in this workspace (components/${n}/component.json)`;return[`line ${at(o)}: <${o.tagName} ${C}="${n}">: ${c}: the block shows what it holds, read-only, and moves, copies and deletes whole`]})}function Ot(t,e){let s=[];for(let{name:o,value:n}of t.attrs){if(ot[o]&&!st.has(o)){s.push(`${o}${$(t)} is gone: ${ot[o]}`);continue}if(o.startsWith("data-doc-")&&!st.has(o)&&s.push(Ce.has(o)?`${o}${$(t)} is the kit's to set: remove it`:`${o}${$(t)} is no attribute of the kit's${ze(o)}`),o==="class"){for(let i of n.split(/\s+/).filter(e))if(!st.has(i)){if(ot[i]){s.push(`class ${i}${$(t)} is gone: ${ot[i]}`);continue}s.push(Ce.has(i)?`class ${i}${$(t)} is the kit's to set: remove it`:`class ${i}${$(t)} is no class of the kit's${ze(ds(i))}: give a class of the document's own a name of its own (not doc-\u2026)`)}}}return s}var Fe=t=>t.startsWith("doc-");function Es(t){try{return new Qo.Script(ls(t),{filename:"kit.js"}),null}catch(e){let s=/^kit\.js:(\d+)/.exec(e.stack??"")?.[1];return{message:e.message,line:s?Number(s):null}}}var Et=new Map;function Ts(t){if(!t.files.includes("kit.js"))return null;if(Et.get(t.folder)?.stamp!==t.stamp){let e=Q(t,"kit.js"),s=e===null?null:Es(e),o=e===null?`${t.id}: its kit.js cannot be read`:s&&`${t.id}: its kit.js does not run: ${s.message}${s.line?` (line ${s.line})`:""}`;Et.set(t.folder,{stamp:t.stamp,failure:o})}return Et.get(t.folder).failure}function Lt(t,e=w(t),s=null){let o=ks(t,e),n=Me(e);o.push(...Os(n));let i=n.length>0?s??T():null,a=i?[...i.packages.values()]:[];i&&o.push(...L(t,i,e).map(Ts).filter(Boolean));for(let r of[...es,...a].filter(d=>d.match&&(d.parts||d.pairs)))for(let d of ns(e,r)){if(r.empty&&!(d.childNodes??[]).some(u=>u.tagName||u.nodeName==="#text"&&u.value.trim()))continue;let f=r.id==="sheets"?hs(d):null;if(f){o.push(`${r.id}${$(d)} has no tabs and is no short form: ${f.why??"it stands where no block does (in a whole block or a figure)"}; ${ys}`);continue}if(je[r.id]&&Object.values(r.parts??{}).some(u=>Tt(d,u.at).length<(u.optional?0:u.min??1))){o.push(`${r.id}${$(d)} carries the kit's class without the kit's parts: ${je[r.id]}`);continue}let h={};for(let[u,m]of Object.entries(r.parts??{})){if(m.edit==="flow"&&it.test(r.id)){let b=Re(d,r).filter(k=>y(k,I)===u);b.length===0&&!m.optional&&o.push(`${r.id}${$(d)} has no ${u} (${I}="${u}")`);for(let k of b.slice(1))o.push(`${r.id}${$(k)}: slot "${u}" twice`);h[u]=b.slice(0,1);continue}h[u]=Tt(d,m.at);let p=m.optional?0:m.min??1,g=m.max??1/0;h[u].length<p?o.push(`${r.id}${$(d)} has ${h[u].length===0?"no":`${h[u].length} of`} ${u} (${m.at.replace(":scope > ","")})${h[u].length>0?`, at least ${p}`:""}`):h[u].length>g&&o.push(`${r.id}${$(d)} has ${h[u].length} of ${u}, at most ${g}`)}if(r.only){let u=new Set(r.only.flatMap(m=>h[m]));for(let m of(d.childNodes??[]).filter(p=>p.tagName&&!u.has(p)))o.push(`${r.id}${$(d)} holds a <${m.tagName}>${$(m)}: only its ${r.only.join(", ")} (${r.only.map(p=>r.parts[p].at.replace(":scope > ","")).join(", ")}) go in it`)}if(r.shares&&o.push(...gs(r,d,h[r.shares.part])),it.test(r.id)){let u=Object.entries(r.parts??{}).filter(([,m])=>m.edit==="flow").map(([m])=>m);for(let m of Re(d,r).filter(p=>!u.includes(y(p,I))))o.push(`${r.id}${$(m)}: slot "${y(m,I)}" is no part of its manifest edited as flow`)}for(let{a:u,attrA:m,b:p,attrB:g}of r.pairs??[]){let b=h[u].map(x=>y(x,m)),k=h[p].map(x=>y(x,g));for(let x of new Set(b.filter((v,E)=>b.indexOf(v)!==E)))o.push(`${r.id}${$(d)}: ${u} "${x}" twice`);for(let x of b.filter(v=>!k.includes(v)))o.push(`${r.id}${$(d)}: ${u.replace(/s$/,"")} "${x}" has no ${p.replace(/s$/,"")} (${g}="${x}")`);for(let x of k.filter(v=>!b.includes(v)))o.push(`${r.id}${$(d)}: ${p.replace(/s$/,"")} "${x}" has no ${u.replace(/s$/,"")} (${m}="${x}")`)}}o.push(...Ns(e,i?.packages));let c=new Set,l=[];J(e,r=>{if(D(r)){let h=new Set(ss(r));o.push(...Ot(r,Fe)),J(r,u=>o.push(...Ot(u,Fe)),{stop:u=>h.has(u)});return}r.tagName==="pre"&&bs(r)&&o.push(`<pre>${$(r)} straight in the text: a code block is <div class="doc-code"> holding its title (<div class="doc-code-title">) and the <pre>`),o.push(...ws(r)),r.tagName==="a"&&ps(r,"doc-bookmark")&&o.push(`<a class="doc-bookmark">${$(r)} is no bookmark: ${xs}`),o.push(...Ot(r,fs));let d=y(r,"data-doc-bind");d!==void 0&&(d.trim()?P(r,ms)?r.tagName==="button"&&y(r,"value")===void 0?o.push(`data-doc-bind${$(r)} on a button without a value: give it the value a click chooses`):c.add(d.trim()):o.push(`data-doc-bind${$(r)} on a ${r.tagName}: only inputs, selects, textareas, buttons with a value, details and tables hold a key`):o.push(`data-doc-bind${$(r)} names no key`));let f=y(r,"data-doc-show");f!==void 0&&l.push([r,f])},De);for(let[r,d]of l){let f=d.split(":")[0].trim();!f||!d.includes(":")?o.push(`data-doc-show="${d}"${$(r)}: write key:value`):c.has(f)||o.push(`data-doc-show="${d}"${$(r)}: nothing binds "${f}" (data-doc-bind="${f}")`)}return o.push(...js(t,e)),o}var Ls=/(?<![\\$])\$(?=[^\s$])([^$]*?[^\s$\\])\$(?![$\d])/g,As=/(?:(?<![A-Za-z0-9_])[A-Za-z]|[)\]}])_[A-Za-z0-9{]/,Cs=t=>/[\\^]/.test(t)||!t.startsWith("{")&&As.test(t),zs=new Set(["head","code","pre","kbd","samp","script","style","template","textarea","noscript","svg","math","title","iframe","object"]),Is=`.doc-math-inline, .doc-math-block, .doc-code, .doc-diff, [data-doc-math-dollar], [data-doc-chart], ${rs}`;function js(t,e){let s=[],o=n=>{for(let i of n.childNodes??[])if(i.nodeName==="#text"&&i.sourceCodeLocation&&i.value.includes("$")){let{startOffset:a,endOffset:c}=i.sourceCodeLocation;for(let l of t.slice(a,c).matchAll(Ls)){if(!Cs(l[1]))continue;let r=l[1].replace(/\s+/g," "),d=r.length>60?`${r.slice(0,59)}\u2026`:r;s.push(`line ${Zt(t,a+l.index)}: $${d}$ is not drawn as a formula (single dollars are off: they are money): write \\(${d}\\)`)}}else i.tagName&&!zs.has(i.tagName)&&!P(i,Is)&&o(i)};return o(e),s}import V from"node:fs";import W from"node:path";import{COLOR_NAMES as Hs}from"../browser/shared/colors.mjs";import{FOLD_DOTS as Ks}from"../browser/shared/code-folds.mjs";import{kitPublicDirectory as Gs,kitSourceDirectory as Js,release as Vs}from"../browser/shared/paths.mjs";import{FLOW_LABEL as Ua}from"../browser/shared/components/list.mjs";var Rs={"code-title":{zh:"\u4EE3\u7801\u5757",en:"Code"},"plain-text":{zh:"\u7EAF\u6587\u672C",en:"Plain text"},"fold-code":{zh:"\u6298\u53E0\u6216\u5C55\u5F00\u4EE3\u7801\u5757",en:"Collapse or expand the code block"},"copy-code":{zh:"\u590D\u5236\u4EE3\u7801",en:"Copy code"},copied:{zh:"\u5DF2\u590D\u5236",en:"Copied"},wrap:{zh:"\u81EA\u52A8\u6362\u884C",en:"Wrap lines"},"no-wrap":{zh:"\u53D6\u6D88\u81EA\u52A8\u6362\u884C",en:"Stop wrapping lines"},fold:{zh:"\u6298\u53E0",en:"Collapse"},unfold:{zh:"\u5C55\u5F00",en:"Expand"},line:{zh:"\u7B2C {0} \u884C",en:"Line {0}"},lines:{zh:"\u7B2C {0}\u2013{1} \u884C",en:"Lines {0}\u2013{1}"},"diff-counts":{zh:"\u65B0\u589E {0} \u884C\uFF0C\u5220\u9664 {1} \u884C",en:"Lines added: {0}, removed: {1}"}};var We="data-ge-language",Fs={"code-title":"--doc-word-code-title"};function Ds(t,e,s,...o){let n=t[s];if(!n)throw new Error(`The kit has no word "${s}" here (src/render/kit/words.js).`);let i=n[e]??n.zh;return o.length===0?i:i.replace(/\{(\d+)\}/g,(a,c)=>c<o.length?String(o[c]):a)}var _s=`:root[${We}="en"], :root:not([${We}])[lang|="en" i]`;function Be(){let t=e=>Object.entries(Fs).map(([s,o])=>`${o}: ${JSON.stringify(Ds(Rs,e,s))};`).join(" ");return`:root { ${t("zh")} }
4
- ${_s} { ${t("en")} }`}import{LOOK as At,LOOK_ATTRIBUTES as Ms,SERIF_FONT as He,SIZE_FACTOR as Ps,SPACING as Us,WIDTH as Ct}from"../browser/shared/document-look.mjs";var Ke=[["--doc-body-font-size","--doc-body-line-height"],["--doc-small-font-size","--doc-small-line-height"],["--doc-note-font-size","--doc-note-line-height"],["--doc-title-font-size","--doc-title-line-height"],["--doc-h1-font-size","--doc-h1-line-height"],["--doc-h2-font-size","--doc-h2-line-height"],["--doc-h3-font-size","--doc-h3-line-height"],["--doc-h4-font-size","--doc-h4-line-height"],["--doc-card-title-font-size","--doc-card-title-line-height"],["--doc-table-font-size","--doc-table-line-height"]],Ws=["--doc-component-gap","--doc-block-gap","--doc-media-gap","--doc-paragraph-gap","--doc-group-gap","--doc-list-gap"],zt="--doc-content-max-width";function Bs(t){let e=new Map;for(let[,s,o]of String(t).matchAll(/^\s*(--doc-[a-z0-9-]+):\s*([^;]+);/gm))e.has(s)||e.set(s,o.trim());return e}var rt=t=>`${Math.round(t)}px`;function ct(t,{size:e="default",spacing:s="default",width:o="default"}={}){let n=r=>{let d=/^(-?[0-9.]+)px$/.exec(t.get(r)??"");if(!d)throw new Error(`src/render/kit/styles/tokens.css: ${r} is no length in px (src/render/look-css.mjs reads it)`);return Number(d[1])},i=Ps[e],{leading:a,gaps:c}=Us[s],l={};if(e!=="default"||s!=="default")for(let[r,d]of Ke){let f=n(r)*i;e!=="default"&&(l[r]=rt(f)),l[d]=rt(Math.round(f)+(n(d)-n(r))*i*a)}if(s!=="default"){for(let r of Ws)l[r]=rt(n(r)*c);l["--doc-space"]=String(c)}if(o!=="default"){if(n(zt)!==Ct.default)throw new Error(`src/render/kit/styles/tokens.css: ${zt} is not \u9ED8\u8BA4 \u6B63\u6587\u5BBD\u5EA6's ${Ct.default}px (src/shared/document-look.mjs WIDTH)`);l[zt]=rt(Ct[o])}return l}var U=(t,e)=>`${t} { ${Object.entries(e).map(([s,o])=>`${s}: ${o};`).join(" ")} }`,_=(t,e)=>`[${Ms[t]}="${e}"]`;function Ge(t){let e=Bs(t),s=e.get("--doc-font");if(!s)throw new Error("src/render/kit/styles/tokens.css: no --doc-font (src/render/look-css.mjs keeps it as --doc-sans-font)");let o=[U(`:root${_("font","serif")}`,{"--doc-sans-font":s,"--doc-font":He}),U(`:root${_("font","mixed")}`,{"--doc-heading-font":He})],[,...n]=At.size,[,...i]=At.spacing,[,...a]=At.width;for(let c of n)o.push(U(`:root${_("size",c)}`,ct(e,{size:c})));for(let c of i)o.push(U(`:root${_("spacing",c)}`,ct(e,{spacing:c})));for(let c of a)o.push(U(`:root${_("width",c)}`,ct(e,{width:c})));for(let c of n)for(let l of i){let r=ct(e,{size:c,spacing:l});o.push(U(`:root${_("size",c)}${_("spacing",l)}`,Object.fromEntries(Ke.map(([,d])=>[d,r[d]]))))}return o.join(`
5
- `)}var Je=Object.fromEntries(K.filter(t=>t.file).map(t=>[t.file,t.build])),tr=Object.keys(Je),Z=t=>W.join(Js,t),Zs=(t,e,s)=>({entryPoints:[Z(t)],bundle:!0,write:!1,format:"iife",platform:"browser",target:"es2022",...typeof e=="function"?e():e,...s}),Ys=t=>{let e=Je[t];if(!e)throw new Error(`src/render/kit-build.mjs: no kit file "${t}"`);return e},lt=new Map;function qs(t,e){let s=[...e.matchAll(/^@import\s+"\.\/([a-z0-9-]+\.css)";\s*$/gm)].map(i=>i[1]),o=V.readdirSync(W.dirname(Z(t))).filter(i=>i.endsWith(".css")&&i!==W.basename(t)),n=[...o.filter(i=>!s.includes(i)).map(i=>`${i} is not listed`),...s.filter((i,a)=>!o.includes(i)||s.indexOf(i)!==a).map(i=>`${i} is listed but missing, or listed twice`)];if(n.length>0)throw new Error(`src/render/kit/${t}: ${n.join("; ")}`);return s.map(i=>W.join(W.dirname(t),i))}var Xs=t=>t.replace(/@(text|highlight)-colors\b/g,(e,s)=>Hs.map(o=>`.doc-${s}-${o}`).join(", ")),Qs=t=>{let e=Xs(t.join(`
6
- `)).replaceAll("@fold-dots",Ks).replace(/^@kit-words;$/m,()=>Be());return e.replace(/^@kit-look;$/m,()=>Ge(e))};function It(t,{fresh:e=!1}={}){let s=Ys(t);if(Vs)return V.promises.readFile(W.join(Gs,t),"utf8");if(s.read)return V.promises.readFile(Z(s.read),"utf8");if(s.styles)return V.promises.readFile(Z(s.styles),"utf8").then(o=>Promise.all(qs(s.styles,o).map(n=>V.promises.readFile(Z(n),"utf8")))).then(Qs);if(e||!lt.has(t)){let o=le(Zs(s.bundle,s.options)).then(n=>n.outputFiles[0].text);o.catch(()=>lt.delete(t)),lt.set(t,o)}return lt.get(t)}import{kitNamespace as tn}from"../browser/shared/old-names.mjs";import{attr as jt,hasClass as ft}from"../browser/shared/html-tree.mjs";var Ve=t=>t.tagName==="section"&&ft(t,"doc-section"),en=new Set(["section","header","footer","nav","script","style","template","dialog","link","meta"]),on=t=>!en.has(t.tagName),dt=t=>t.nodeName==="#text"?t.value:(t.childNodes??[]).map(dt).join("");function Ye(t,e=[]){for(let s of t.childNodes??[])s.tagName&&((s.tagName==="main"&&ft(s,"doc-page")||jt(s,"data-doc-sheet")!==void 0)&&e.push(s),Ye(s.tagName==="template"?s.content:s,e));return e}var sn=/^(p|li|h[1-4]|blockquote|ul|ol)$/,qe=["doc-summary","doc-panel","doc-note","doc-callout"],nn=t=>sn.test(t.tagName)||qe.some(e=>ft(t,e)),an=new Set(["none","auto","100%","inherit","initial","unset","revert"]),Ze=t=>[...t.matchAll(/(?:^|[;{\s])(?:max-)?width\s*:\s*([^;}]+)/gi)].some(([,e])=>!an.has(e.replace(/!important/i,"").trim().toLowerCase())),rn=t=>{let e=t.trim().split(/\s*[\s>+~]\s*/).at(-1)??"",s=/^(p|li|h[1-4]|blockquote|ul|ol)\b/.test(e)||qe.some(n=>e.includes(`.${n}`)),o=[...t.matchAll(/\.([\w-]+)/g)].some(([,n])=>!tn(n))||t.includes("#");return s&&!o};function cn(t){let e=[],s=(o,n)=>{for(let i of o.childNodes??[]){if(!i.tagName)continue;let a=n||i.tagName==="main"&&ft(i,"doc-page");if(a&&nn(i)&&Ze(jt(i,"style")??"")&&e.push(`<${i.tagName}> with style="${jt(i,"style").trim()}"`),i.tagName==="style"){let c=dt(i).replace(/\/\*[\s\S]*?\*\//g,"");for(let[,l,r]of c.matchAll(/([^{}]+)\{([^{}]*)\}/g))if(Ze(r))for(let d of l.split(","))rn(d)&&e.push(`"${d.trim()}" in the document's style`)}s(i.tagName==="template"?i.content:i,a)}};return s(t,!1),e}function Xe(t,{written:e=t}={}){let s=[],o=w(t),n=cn(o);n.length>0&&s.push(`body text given a width of its own (${n.slice(0,3).join("; ")}${n.length>3?`; ${n.length-3} more`:""}): its lines break before the reading column's edge, leaving an extra right margin; let body text fill the column`);for(let i of Ye(o)){let a=i.childNodes.filter(c=>c.tagName);a.forEach((c,l)=>{if(!Ve(c))return;let r=l+1;for(;r<a.length&&on(a[r]);)r++;let d=a.slice(l+1,r);if(d.length===0||!Ve(a[r]??{})||/^h[1-4]$/.test(d[0].tagName))return;let f=c.childNodes.map(g=>g.tagName?g:null).filter(Boolean).map(dt).find(g=>g.trim())?.replace(/\s+/g," ").trim().slice(0,40)??"",[h]=d,u=dt(h).replace(/\s+/g," ").trim(),m=`<${h.tagName}>${u?` "${u.length>30?`${u.slice(0,30)}\u2026`:u}"`:""}`,p=h.sourceCodeLocation?.startLine;s.push(`${d.length} block${d.length===1?"":"s"} of body text right after the section "${f}" stand outside it${p?` (line ${p})`:""}, ${d.length===1?`the ${m}`:`the first a ${m}`}, between two sections, with no heading of their own: fine if meant, otherwise they belong inside that section`)})}return s.push(...Te(t,{written:e})),s}import{attr as Qe,hasClass as ln}from"../browser/shared/html-tree.mjs";var to="Write instead where it came from, in words, or a path relative to materials/ (materials/data.csv)",dn=new Set(["script","style","template","noscript","textarea","pre","code","kbd","samp","var"]),fn=["doc-math-inline","doc-math-block"],hn=/\\\([\s\S]*?\\\)|\\\[[\s\S]*?\\\]|\$\$[\s\S]*?\$\$/g,un=/(?<!\\)\$(?:\\[\s\S]|[^\\$])+\$/g,pn=/[\s"'<>|()[\]{};,。;:、!?()《》「」『』“”‘’【】]/u,mn=/[^\s"'<>|()[\]{};,。;:、!?()《》「」『』“”‘’【】]+/gu,so=/^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,gn=/\.[A-Za-z0-9]{1,8}$/,$n=[/(?<![A-Za-z0-9_\\])[A-Za-z]:[\\/]/g,/(?<![A-Za-z0-9_.~:/\\-])\/(?:Users|home|root|tmp|private|mnt|opt|Volumes|var\/folders)\/(?=\S)/g,/(?<![A-Za-z0-9_.~:/\\-])~\/(?=\S)/g,/(?<![A-Za-z0-9_$\\])\$(?:HOME|\{HOME\})\/(?=\S)/g,/(?<![A-Za-z0-9_:\\])\\\\[A-Za-z0-9][\w.$-]*\\(?=[^\s\\])/g,/%(?:TEMP|TMP|APPDATA|LOCALAPPDATA|USERPROFILE)%/gi],wn=/(?:^|[\\/])(?:AppData|scratchpad)(?=[\\/]|$)/i,bn=/^(?:[A-Za-z]:|[\\/]|%[A-Za-z]+%)[\s\S]*[\\/](?:temp|tmp)(?=[\\/])/i,kn=t=>t.includes("://")&&!/^file:/i.test(t),eo=12;function oo(t,e){let s=e;for(;s<t.length&&!pn.test(t[s])&&!(so.test(t[s])&&gn.test(t.slice(e,s)));)s++;return t.slice(e,s).replace(/[.,;:!?]+$/,"")}function yn(t,e=!1){let s=c=>c.replace(/[^\n]/g," "),o=t.replace(hn,s),n=e?o.replace(un,s):o,i=[],a=(c,l)=>i.some(r=>r.at<=c+l.length&&c<=r.at+r.path.length);for(let c of $n)for(let l of n.matchAll(c)){let r=oo(n,l.index);r.length>=l[0].length+2&&!a(l.index,r)&&i.push({at:l.index,path:r})}for(let c of n.matchAll(mn)){let l=c.index;for(;l<c.index+c[0].length&&so.test(n[l]);)l++;let r=oo(n,l);/[\\/]/.test(r)&&(wn.test(r)||bn.test(r))&&!kn(r)&&!a(l,r)&&i.push({at:l,path:r})}return i.sort((c,l)=>c.at-l.at)}function no(t,e=w(t)){let s=[],o=(a,c)=>{for(let l of a.childNodes??[])if(l.nodeName==="#text"){if(!l.sourceCodeLocation)continue;for(let{at:r,path:d}of yn(l.value,c))s.push({line:l.sourceCodeLocation.startLine+(l.value.slice(0,r).match(/\n/g)?.length??0),path:d})}else l.tagName&&!dn.has(l.tagName)&&Qe(l,"hidden")===void 0&&!fn.some(r=>ln(l,r))&&o(l,c||Qe(l,"data-doc-math-dollar")!==void 0)};o(e,!1);let n=s.slice(0,eo).map(({line:a,path:c})=>`line ${a}: "${c.length>80?`${c.slice(0,77)}\u2026`:c}" is a path of this machine in the text a reader reads: a reader on another machine cannot open it. ${to}`),i=s.slice(eo);return i.length>0&&n.push(`${i.length} more path${i.length===1?"":"s"} of this machine in the text a reader reads, on line${new Set(i.map(({line:a})=>a)).size===1?"":"s"} ${[...new Set(i.map(({line:a})=>a))].join(", ")}. ${to}`),n}import{elementsOf as io}from"../browser/shared/html-tree.mjs";import{netSnapshot as xn}from"../browser/shared/net-cache.mjs";import{hostIn as Sn,netHostsOf as Nn}from"../browser/shared/net-policy.mjs";var vn=(t,e)=>`<script type="application/json" data-doc-snapshot data-at="${e}">${JSON.stringify(t).replace(/</g,"\\u003c")}</script>`,Rt=t=>t.some(({needs:e})=>Array.isArray(e)&&e.includes("workspace"));function ao(t,{slug:e,packages:s,root:o,at:n=new Date,workspace:i=null}){let a=s.flatMap(({needs:f})=>Nn(f)),c=a.length===0?null:xn(o,e,f=>{try{return Sn(new URL(f).hostname,a)!==null}catch{return!1}}),l={...i&&Rt(s)?i:{},...c?{net:c}:{}};if(Object.keys(l).length===0)return t;let r=io(io(w(t)).find(f=>f.tagName==="html")??{}).find(f=>f.tagName==="head"),d=r?.sourceCodeLocation?.endTag?.startOffset??r?.sourceCodeLocation?.startTag?.endOffset;return d===void 0?t:`${t.slice(0,d)} ${vn(l,n.toISOString())}
7
- ${t.slice(d)}`}import{MENTION as On,MENTION_ICON as En}from"../browser/shared/components/mention.mjs";import{escapeAttribute as Tn}from"../browser/shared/escape.mjs";import{attr as ro,elementsOf as Ln,hasClass as co,walk as An}from"../browser/shared/html-tree.mjs";import{addressOn as Cn,decoded as zn,fromFile as In,hosted as jn,pageAddress as Rn,workbenchHash as Fn}from"../browser/shared/page-address.mjs";function Dn(t,e,s){let o=In(t,e),n=Cn(o,s);return n||jn(t)?n:Rn(o)??(Fn(o)===null?null:{slug:null,block:null})}function _n(t,e,s,o){let n=w(t),i=new Set,a=[];An(n,r=>{let d=ro(r,"data-block-id");d!==void 0&&i.add(d),r.tagName==="a"&&ro(r,"href")!==void 0&&r.sourceCodeLocation?.startTag&&a.push(r)});let c=new Map,l=({startOffset:r,endOffset:d})=>c.set(r,[d,""]);for(let r of a){let{prefix:d,value:f}=r.attrs.find(({name:k})=>k==="href"),h=f.startsWith("#")?zn(f.slice(1)):null,u=h===null?f&&Dn(f,e,o):i.has(h)?{slug:e,block:h}:null;if(!u)continue;let m=s(u,f);if(m===f)continue;let{attrs:p,startTag:g,endTag:b}=r.sourceCodeLocation;if(m===null)l(g),b&&l(b),co(r,On)&&Ln(r).filter(k=>co(k,En)).forEach(k=>l(k.sourceCodeLocation));else{let k=d?`${d}:href`:"href";c.set(p[k].startOffset,[p[k].endOffset,`${k}="${Tn(m)}"`])}}return[...c].sort(([r],[d])=>d-r).reduce((r,[d,[f,h]])=>`${r.slice(0,d)}${h}${r.slice(f)}`,t)}function lo(t,e,s,{blocks:o=!0,links:n}){return _n(t,e,({slug:i,block:a})=>{let c=s(i);if(c===null)return null;if(!a||!o)return i===e&&a?null:c;let l=`#${encodeURIComponent(a)}`;return i===e?l:`${c}${l}`},n)}import ht from"node:fs";import Mn from"node:path";import{extensionOf as Pn,imageFile as Un,mediaTypeOf as Wn}from"../browser/shared/media.mjs";var _t=1024*1024,Bn=_t,ho=2400,Ft=2e3,Hn=.25,Kn=new Set(["png","gif"]),fo=.75;function Gn(t){if(t.length<16||t.toString("latin1",0,4)!=="RIFF"||t.toString("latin1",8,12)!=="WEBP")return!1;for(let e=12;e+8<=t.length;){let s=t.toString("latin1",e,e+4);if(s==="VP8L")return!0;if(s==="VP8 "||s==="ANMF")return!1;let o=t.readUInt32LE(e+4);e+=8+o+o%2}return!1}function Jn(t){let e=(s,o)=>s+o<=t.length;if(e(0,24)&&t.readUInt32BE(0)===2303741511&&t.toString("latin1",12,16)==="IHDR")return{width:t.readUInt32BE(16),height:t.readUInt32BE(20)};if(e(0,10)&&/^GIF8[79]a$/.test(t.toString("latin1",0,6)))return{width:t.readUInt16LE(6),height:t.readUInt16LE(8)};if(e(0,4)&&t[0]===255&&t[1]===216){for(let s=2;e(s,4);){if(t[s]!==255)return null;let o=t[s+1];if(o===255){s+=1;continue}if(o===216||o===1||o>=208&&o<=215){s+=2;continue}if(o>=192&&o<=207&&![196,200,204].includes(o))return e(s,9)?{width:t.readUInt16BE(s+7),height:t.readUInt16BE(s+5)}:null;if(o===217||o===218)return null;s+=2+t.readUInt16BE(s+2)}return null}if(e(0,30)&&t.toString("latin1",0,4)==="RIFF"&&t.toString("latin1",8,12)==="WEBP"){let s=t.toString("latin1",12,16);if(s==="VP8 ")return{width:t.readUInt16LE(26)&16383,height:t.readUInt16LE(28)&16383};if(s==="VP8L"){let o=t.readUInt32LE(21);return{width:(o&16383)+1,height:(o>>>14&16383)+1}}return s==="VP8X"?{width:t.readUIntLE(24,3)+1,height:t.readUIntLE(27,3)+1}:null}if(e(0,12)&&t.toString("latin1",4,8)==="ftyp"&&/avi[fs]/.test(t.toString("latin1",8,Math.min(t.length,t.readUInt32BE(0))))){let s=null;for(let o=t.indexOf("ispe",0,"latin1");o>=0&&e(o,16);o=t.indexOf("ispe",o+4,"latin1")){let n={width:t.readUInt32BE(o+8),height:t.readUInt32BE(o+12)};(!s||n.width*n.height>s.width*s.height)&&(s=n)}return s}return null}var Vn=_t;function Zn(t){let e;try{e=ht.openSync(t,"r");let{size:s}=ht.fstatSync(e),o=Buffer.alloc(Math.min(s,Vn));return ht.readSync(e,o,0,o.length,0),{length:s,head:o}}catch{return null}finally{e!==void 0&&ht.closeSync(e)}}var j=t=>`${Math.max(.1,t/_t).toFixed(1)} MB`;function Yn({bytes:t,width:e,height:s,extension:o,lossless:n}){let i=Math.max(e,s),a=Math.min(1,Ft/i),c=Math.min(t,e*s*a*a*Hn);if(i>ho){if(!n)return c<=t*fo?` \u2014 a ${Ft}px copy would be about ${j(c)}`:"";let l=t*a*a;return` \u2014 a ${Ft}px copy would be about ${j(l)}${o==="png"&&c<l/2?`, or ${j(c)} as a JPEG (for a photograph)`:""}`}return!n&&c<=t*fo?` \u2014 written again as a JPEG of quality about 82, it would be about ${j(c)}`:o==="png"&&c<t/2?` \u2014 as a JPEG (for a photograph) it would be about ${j(c)}`:""}var Dt=t=>t===2?"twice":`${t} times`;function uo({html:t,directory:e,tree:s=w(t)}){let{embedded:o,unserved:n}=re({html:t,directory:e,tree:s}),i=new Map,a=(l,r,d,f=!1)=>{let h=i.get(l)??i.set(l,{at:[],shows:0,served:d}).get(l);h.at.push(r),f||(h.shows+=1)};for(let{file:l,line:r,icon:d}of o)Un(l)&&a(l,r,!0,d);for(let{file:l,line:r}of n)Wn(l).startsWith("image/")&&a(l,r,!1);let c=[];for(let[l,{at:r,shows:d,served:f}]of[...i].sort(([,h],[,u])=>Math.min(...h.at)-Math.min(...u.at))){let h=Zn(Mn.join(e,l));if(!h)continue;let{length:u,head:m}=h,p=Jn(m),g=p?Math.max(p.width,p.height):0,b=u>Bn||g>ho,k=f&&d>1;if(!b&&!k)continue;let x=[...new Set(r)],v=`line${x.length===1?"":"s"} ${x.length>1?`${x.slice(0,-1).join(", ")} and ${x.at(-1)}`:x[0]}`,E=k?`shown ${Dt(d)}: the export embeds it ${Dt(d)}; show it once and refer back to it in words`:"";if(!b){c.push(`${l} (${v}): ${E} (${j(Math.ceil(u/3)*4*d)} as data: URLs)`);continue}let H=r.length===1||!f?"":`, ${Dt(r.length)}`,R=f?r.length:1,Y=`${j(Math.ceil(u/3)*4*R)} as ${R===1?"a data: URL":"data: URLs"}`,Po=p?`, ${p.width}\xD7${p.height}px`:"",Bt=Pn(l),Ht=p?Yn({bytes:u,...p,extension:Bt,lossless:Kn.has(Bt)||Gn(m)}):"",Uo=f?`the export embeds it as it is${H}, ${Y}${Ht}`:`its name keeps it out of the preview and the export (the failure at its line says why); copied into assets/ under a name they take, the export embeds it as it is, ${Y}${Ht}: copy it in at the size the page needs`;c.push(`${l} (${v}): ${j(u)}${Po}; ${Uo}${E?`; ${E}`:""}`)}return c}import{COMPONENTS as hi}from"../browser/shared/components/index.mjs";import{withLook as ui}from"../browser/shared/document-look.mjs";import{reportsDirectory as pi}from"../browser/shared/paths.mjs";import{documentLook as mi}from"../browser/shared/workspace-look.mjs";import po from"node:fs";import{MENTION as mo,MENTION_ICON as go}from"../browser/shared/components/mention.mjs";import{escapeAttribute as qn,escapeText as Xn}from"../browser/shared/escape.mjs";import{iconUrl as Qn,validIcon as ti}from"../browser/shared/emoji/icon-value.mjs";import{attr as ei,hasClass as oi,walk as si}from"../browser/shared/html-tree.mjs";import{fromFile as ni,isFileLink as ii,pageAddress as ai}from"../browser/shared/page-address.mjs";import{reportsDirectory as ri}from"../browser/shared/paths.mjs";import{documentDirectory as ci,documentFiles as li}from"../browser/shared/workspace.mjs";function di(t,e){let{html:s,json:o}=li(ci(t,e));if(!po.existsSync(s))return null;try{let{title:n,icon:i}=JSON.parse(po.readFileSync(o,"utf8"));return{title:n,icon:i}}catch{return{}}}function fi(t,e,s,o){if(s==="words"||typeof t!="string"||!ti(t))return null;if(s==="preview")return Qn(t,e,{tab:!0});let n=qt({value:t,slug:e,tab:!0,reportsDirectory:o});return n&&`data:${n.type};base64,${n.body.toString("base64")}`}function $o(t,{slug:e,mode:s="export",reportsDirectory:o=ri}){if(!t.includes(mo))return t;let n=new Map,i=c=>(n.has(c)||n.set(c,di(c,o)),n.get(c)),a=new Map;return si(w(t),c=>{let l=c.tagName==="a"&&oi(c,mo)?ei(c,"href"):void 0,{startTag:r,endTag:d}=c.sourceCodeLocation??{};if(!l||!ii(l)||!r||!d)return;let f=ai(ni(l,e))?.slug;if(!f)return;let h=i(f);if(!h)a.set(r.endOffset-1,[r.endOffset-1," data-doc-gone"]);else if(h.title){let u=fi(h.icon,f,s,o);a.set(r.endOffset,[d.startOffset,`${u?`<img class="${go}" src="${qn(u)}" alt="">`:`<span class="${go}"></span>`}${Xn(h.title)}`])}}),[...a].sort(([c],[l])=>l-c).reduce((c,[l,[r,d]])=>`${c.slice(0,l)}${d}${c.slice(r)}`,t)}var gi=/<script\b[^>]*\bdata-doc-kit="runtime"[^>]*><\/script>/;function $i(t,e,s){let o=Gt(e).filter(({id:n})=>!s.some(i=>i.id===n)).map(Jt).join(" ");return o?t.replace(gi,n=>`${n}
8
- <script data-doc-dev>${o}</script>`):t}var wo=/(<title\b[^>]*>)\s*(<\/title>)/i;function wi(t){if(!wo.test(t))return t;let e=/^en\b/i.test(/<html\b[^>]*\slang=["']?([^"'\s>]*)/i.exec(t)?.[1]??"");return t.replace(wo,(s,o,n)=>`${o}${e?"Untitled":"\u672A\u547D\u540D\u6587\u6863"}${n}`)}function Mt(t,{slug:e,mode:s="export",files:o=!0,reportsDirectory:n,kit:i,catalog:a}){let{html:c,removed:l}=bi(t,{reportsDirectory:n,kit:i,catalog:a,describe:s==="preview"}),r={slug:e,mode:s,...n?{reportsDirectory:n}:{}},d=Xt(ui(c,mi(e,n??pi)),r),f=o?ce(te(oe(ne(d,r),r),r),r):d;return{html:wi($o(f,r)),removed:l}}function bi(t,{reportsDirectory:e,kit:s,page:o=!1,describe:n=!1,catalog:i=T()}){let a=L(t,i),{html:c,removed:l,used:r}=fe(t,[...hi,...a]),d=ke(he(c,{used:r,page:o,...s?{href:s}:{}}),a);return{html:n?$i(d,i,a):d,removed:l,packages:a}}import{exportsDirectory as Ai,kitPublicDirectory as Ci,release as zi,reportsDirectory as A,vendorDirectory as Ii}from"../browser/shared/paths.mjs";import{referencedFile as ji}from"../browser/shared/media.mjs";import{decoded as Ri,fromFile as Fi,hashAddress as Di,hosted as Lo,pageAddress as _i,workbenchHash as Mi}from"../browser/shared/page-address.mjs";import{pageLinks as Pi}from"../browser/shared/page-links.mjs";import{layoutOf as Ao}from"../browser/shared/workspace.mjs";import{documentLinks as Ui,listReportSlugs as Wi}from"../browser/shared/reports.mjs";import{documentDirectory as B,documentFiles as Wt}from"../browser/shared/workspace.mjs";import{sha256 as ut}from"../browser/shared/files.mjs";import{EXPORT_CSP as Bi,GENERATOR as Hi,isolateUmd as Ki,packagesMeta as Gi,sourceMeta as Ji}from"../browser/shared/export-wrap.mjs";var So=/__REPORT_[A-Z_]+__/,No=1e6,vo=t=>t.length>1?`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`:`${t[0]}`;function Vi(t){return t.map(({id:e,lines:s,columns:o})=>{let n=new Set(s).size<s.length,i=s.map((a,c)=>n?`${a}:${o[c]}`:`${a}`);return`data-block-id repeats: "${e}" on lines ${vo(i)}${n?" (line:column)":""}; each id names one block: remove it from the copy, which needs none (the later ${i.length>2?`ones, lines ${vo(i.slice(1))}`:`one, line ${i[1]}`}, unless the copy went before its original)`})}var Zi=({slug:t,htmlPath:e,metadataPath:s})=>{let o=e?{html:e,json:s??e.replace(/\.html$/,".json")}:Wt(B(t,A));return{htmlName:N.basename(o.html),jsonName:N.basename(o.json)}};function Yi({slug:t,html:e,metadata:s,htmlPath:o,metadataPath:n,tree:i=w(e)}){let a=[],{htmlName:c,jsonName:l}=Zi({slug:t,htmlPath:o,metadataPath:n}),r=/<h1\b[^>]*\bclass="[^"]*\bdoc-title\b[^"]*"[^>]*>\s*<\/h1>/i.test(e),d=[[/<meta\s+name=["']viewport["']/i,"missing viewport metadata"],[r?/<title>\s*<\/title>|<title>[^<]+<\/title>/i:/<title>[^<]+<\/title>/i,"missing document title"],[/<main(?:\s|>)/i,"missing semantic main element"],[/aria-label|aria-labelledby|<title>/i,"missing accessible labels"]];for(let[p,g]of d)p.test(e)||a.push(g);let f=Buffer.byteLength(e);f>No&&a.push(`the document's editable source is ${f.toLocaleString("en-US")} bytes, over the ${No.toLocaleString("en-US")}-byte limit: aggregate or sample the embedded data, or split the document`),So.test(e)&&a.push(`${c} still contains a starter placeholder such as __REPORT_TITLE__`);for(let[p,g]of Object.entries(s))typeof g=="string"&&So.test(g)&&a.push(`${l} "${p}" is still a starter placeholder such as __REPORT_TITLE__`);/<[a-z][^>]*\sdata-doc-placeholder\b/i.test(e)&&a.push("starter placeholder content ([data-doc-placeholder]) is still present; replace it with the document's content");let h=new Map;M(i,p=>{let g=O(p,"data-block-id"),b=p.sourceCodeLocation?.attrs?.["data-block-id"]??p.sourceCodeLocation;g!==void 0&&h.set(g,[...h.get(g)??[],{line:b?.startLine,column:b?.startCol}])});let u=[...h].filter(([,p])=>p.length>1);a.push(...Vi(u.map(([p,g])=>({id:p,lines:g.map(({line:b})=>b),columns:g.map(({column:b})=>b)}))));let m=null;if(M(i,p=>{!m&&p.tagName==="main"&&(m=p)},{inTemplates:!1}),m){let p=O(m,"data-doc-id");p===void 0?a.push(`main.doc-page needs data-doc-id="${t}"`):p!==t&&a.push(`main[data-doc-id] is "${p}": it must be the document's slug "${t}"`)}return a}var Co=t=>yo(yo(t).find(e=>e.tagName==="html")??{}).find(e=>e.tagName==="head")?.sourceCodeLocation?.startTag?.endOffset,Ut=new Set(["localStorage","sessionStorage"]);function zo(t){let e=[],s=[];return M(t,o=>{o.tagName==="script"&&O(o,"src")!==void 0&&e.push(O(o,"src")),(o.tagName==="link"?(O(o,"rel")??"").toLowerCase().split(/\s+/):[]).includes("stylesheet")&&O(o,"href")!==void 0&&s.push(O(o,"href"))}),{scripts:e,styles:s}}function Io({slug:t,html:e,directory:s=B(t,A),tree:o=w(e),uses:n=X(e,q,{tree:o}),catalog:i}){let a=[];Co(o)===void 0&&a.push("the page writes no <head> start tag, which an export puts its Content-Security-Policy right after: write <head> \u2026 </head> before <body>");let c=[];M(o,d=>{if(["script","link","img"].includes(d.tagName))for(let f of["src","href"]){let h=O(d,f)?.trim();h&&/^https?:\/\//i.test(h)&&c.push(h)}}),c.length>0&&a.push(`external resources are not portable: ${c.join(", ")}`);for(let{name:d,how:f,line:h,where:u}of n){if(!q.has(d))continue;let m={call:`calls ${d}(\u2026)`,new:`creates new ${d}(\u2026)`}[f]??`uses ${d}`;a.push(`line ${h}: ${u} ${m}: embed its data (inline JSON, DocState); the export blocks the network`)}let{scripts:l,styles:r}=zo(o);for(let d of l)ge.has(d)||a.push(`unsupported script dependency ${d}`);for(let d of r)$e.has(d)||a.push(`unsupported stylesheet dependency ${d}`);return a.push(...ie({html:e,directory:s,tree:o}),...se({html:e,directory:s,tree:o}),...ee({html:e,directory:s,tree:o}),...ae({html:e,directory:s,tree:o})),a.push(...ye(L(e,i,o))),[...new Set(a)]}var qi=[[/\bDocSheets\.mount\s*\(/,"Sheet areas start on their own: remove DocSheets.mount (an area keeps its tab under its data-doc-sheets name)"],[/\bDocCode\.(?:View|DiffView|DiffStats|enhance)\b/,'code blocks are highlighted on their own, and a diff is declared as <div class="doc-diff"> holding { path, lines } as JSON (sdk/doc-code.d.ts)'],[/\bDocTables\.(?:enhance|enhanceAll|makeSortable)\b/,"tables start on their own: remove the call"],[/\bDocDialogs\.(?:enhance|enhanceAll)\b/,"detail cards start on their own: remove the call"]];function Xi({html:t,tree:e=w(t),uses:s=X(t,Ut,{tree:e})}){let o=we(t,e),n=[...ue(t,e),...pe(t,e)];for(let[i,a]of qi)i.test(o)&&n.push(`${o.match(i)[0].replace(/\s*\($/,"")} is gone: ${a}`);for(let{name:i,line:a,where:c}of s)Ut.has(i)&&n.push(`line ${a}: ${c} uses ${i}: use DocState instead of direct browser storage`);return[...new Set(n)]}var Qi=(t,e)=>e.childNodes.find(s=>s.tagName||s.nodeName==="#text"&&s.value.trim())===t,ta=t=>ko(t,Si("highlight").match)||t.tagName==="li"&&ko(t.parentNode,`ol.${Ni}`),ea=`an icon is one of three kinds: an emoji, <div class="doc-icon">\u{1F3AF}</div>; an icon of Gallery's sets in one of ${xo.length} colors, <div class="doc-icon" data-icon="/icons/airplane_blue.svg"></div> (MingCute's names; Tabler's as /icons/tabler/plane_blue.svg; the colors ${xo.join(", ")}); or a picture of the document's folder, <div class="doc-icon"><img src="assets/logo.png" alt=""></div>`,jo=t=>t.nodeName==="#text"?t.value:(t.childNodes??[]).map(jo).join("");function Oo(t,e,s){let o=e.sourceCodeLocation?.attrs?.[s],n=o?t.slice(o.startOffset,o.endOffset):`${s}="${O(e,s)??""}"`;return n.length>72?`${n.slice(0,71)}\u2026`:n}function oa(t,e){let s=O(e,"data-icon");if(s!==void 0)return{held:Oo(t,e,"data-icon"),meant:Pt(s)==="glyph"?s:null};let o=null;if(M(e,i=>{o??=["img","svg"].includes(i.tagName)?i:null}),o?.tagName==="img"){let i=O(o,"src");return{held:`<img ${Oo(t,o,"src")}>`,meant:Pt(i)==="image"?i:null}}if(o)return{held:"an <svg>"};let n=jo(e).replace(/\s+/g," ").trim();return{held:n?`"${n.slice(0,40)}"`:"nothing"}}function sa({set:t,name:e,color:s}){let o=vi.find(a=>a!==t);if(mt(o).includes(e))return`; "${e}" is ${o==="tabler"?"Tabler":"MingCute"}'s: ${Ei(o,e,s)}`;let n=e.split("-").filter(a=>a.length>=3),i=mt(t).filter(a=>a.split("-").some(c=>n.includes(c))).slice(0,6);return i.length>0?`; names of its set near it: ${i.join(", ")}`:""}function na({html:t,tree:e=w(t)}){let{all:s,own:o}=Qt(e),n=[],i=a=>a.sourceCodeLocation?.startLine;o.length>1&&n.push(`line ${i(o[1])}: ${o.length} page icons (.doc-icon) in the header (the first at line ${i(o[0])}): a document has one, right before its title`);for(let a of s){let c=i(a),l=a.parentNode;!o.includes(a)&&!(ta(l)&&Qi(a,l))&&n.push(`line ${c}: an icon (.doc-icon) stands only right before the document's title, first in a highlight block (.doc-panel, .doc-summary), or first in a flowchart's step (ol.doc-flow > li, in its number's place)`);let r=Li(Vt(t,a)),{held:d,meant:f}=r?{}:oa(t,a);f?n.push(`line ${c}: an icon (.doc-icon) holds ${d}, an icon a page reads only in double quotes: write ${Ti(f)}`):r?Pt(r)==="glyph"&&!Yt(r)&&n.push(`line ${c}: the icon ${r} is none of the icon sets' (MingCute: /icons/<name>_<color>.svg, Tabler: /icons/tabler/<name>_<color>.svg; src/shared/emoji/data/icons.json lists the names of each)${sa(Oi(r))}`):n.push(`line ${c}: an icon (.doc-icon) holds no icon (it holds ${d}): ${ea}`)}return[...new Set(n)]}function Ro(t){let e=w(t.html),s={...t,tree:e,uses:X(t.html,new Set([...q,...Ut]),{tree:e})};return[...Yi(s),...Lt(t.html,e),...Xi(s),...na(s),...Io(s)]}function ia(t){let e=new Map(t.map(n=>[n.slug,[...Ro(n),...Nt(n.html)]])),s=new Map(t.map(n=>[N.resolve(n.htmlPath),n.slug])),o=new Map(t.map(n=>[N.resolve(n.htmlPath),n]));for(let n of t)n.scriptNotes=[];if(t.length>0)for(let{htmlPath:n,text:i,typeOnly:a,note:c}of be(t)){if(a){o.get(n)?.scriptNotes.push(c);continue}let l=n?[s.get(n)]:[...e.keys()];for(let r of l)e.get(r).push(n?i:`${i} (shared SDK declaration)`)}for(let[n,i]of e)i.length===0&&e.delete(n);return e}async function Rc(t=[],{prepare:e=null}={}){let{reports:s,failures:o}=await pt(t,{prepare:e});for(let n of s){let i=[...Ro(n),...Nt(n.html)];i.length&&o.set(n.slug,i)}return o}async function aa(t=[],{prepare:e=null,directory:s=A}={}){let{reports:o,failures:n}=await pt(t,{prepare:e,directory:s});for(let[i,a]of ia(o))n.set(i,a);return{reports:o,failures:n}}async function ra({fresh:t=!1,kit:e=Ci,vendor:s=Ii}={}){if(zi)return;let o=K.map(a=>[a,a.file?It(a.file,{fresh:t}):wt(a)]);await S.mkdir(e,{recursive:!0});let n=N.join(s,"katex","fonts");await S.mkdir(n,{recursive:!0});let i=(await S.readdir($t)).filter(a=>a.endsWith(".woff2"));await Promise.all(i.map(a=>S.copyFile(N.join($t,a),N.join(n,a)))),await Promise.all(o.map(async([a,c])=>S.writeFile(a.file?N.join(e,a.file):N.join(s,...a.vendor.path.split("/").slice(2)),await c)))}async function ca(t,e){let s=await S.readdir(t).catch(()=>[]);await Promise.all(s.filter(o=>o.endsWith(".html")&&!e.has(o.slice(0,-5))).map(o=>S.rm(N.join(t,o),{force:!0})))}async function la(t,e){let s=N.join(e,"reports.json"),o=await S.readFile(s,"utf8").then(JSON.parse,()=>[]),n=new Map(Array.isArray(o)?o.map(a=>[a.slug,a]):[]);for(let{entry:a}of t)n.set(a.slug,a);let i=[];for(let[a,c]of[...n].sort(([l],[r])=>l.localeCompare(r))){let l=N.join(e,`${a}.html`);await S.stat(l).then(()=>!0,()=>!1)&&i.push(c)}await S.writeFile(s,`${JSON.stringify(i,null,2)}
9
- `)}async function da(t=[],{prepare:e=null,directory:s=A}={}){let o=Ao(s).built,{reports:n,failures:i}=await aa(t,{prepare:e,directory:s});await ra(),await S.mkdir(o,{recursive:!0}),await ca(o,new Set(await Wi(s)));let a=[];for(let c of n){let l=`${c.slug}.html`,r=N.join(o,l);if(i.has(c.slug)){await S.rm(r,{force:!0});continue}let{html:d,removed:f}=Mt(c.html,{slug:c.slug,reportsDirectory:s});await S.writeFile(r,d),a.push({report:c,html:d,removed:f,entry:{slug:c.slug,...c.metadata,preview:`/generated/${l}`,sourceSha256:ut(c.html),outputSha256:ut(d)}})}return await la(a,o),{built:a,failures:i}}var fa=t=>t.replace(/<\/script/gi,"<\\/script");async function Fo(){return new Map(await Promise.all(K.map(async t=>{let e=await(t.file?It(t.file):wt(t,{inline:!0}));return de(t).endsWith(".css")||(e=fa(e)),[t.id,t.umd?Ki(e):e]})))}function ha(t,e,s=null,o=[]){let n=Co(w(e));if(n===void 0)throw new Error(`${t}: the page writes no <head> start tag, which the export's Content-Security-Policy goes right after`);let i=s?`
10
- ${Ji(s)}${o.length>0?`
11
- ${Gi(o)}`:""}`:"";return`${e.slice(0,n)}
12
- <meta name="generator" content="${Hi}">
13
- <meta http-equiv="Content-Security-Policy" content="${Bi}">${i}${e.slice(n)}`}function Do(t,e,s,o=null,n=T(),i=A,a=null){let c=L(e,n);e=ao(ha(t,e,o,c),{slug:t,packages:c,root:i,workspace:a}),e=me(xe(e,n),({id:d,element:f,attribute:h})=>{let u=s.get(d);if(typeof u!="string")throw new Error(`${t}: no inline source for the asset "${d}" (loadInlineSources in src/render/pipeline.mjs)`);return`<${f} ${h}="${d}-inline">${u}</${f}>`});let{scripts:l,styles:r}=zo(w(e));if(l.length+r.length>0)throw new Error(`${t}: export still contains a linked script or stylesheet`);return e}async function Eo(t,e=A,{components:s=!0,catalog:o=T()}={}){let n=B(t,e),i=await S.readFile(Wt(n).html),a=i.toString("utf8"),c=w(a);s||(o={packages:new Map});let l=[...s?Lt(a,c,o):[],...Io({slug:t,html:a,directory:n,tree:c,catalog:o})];if(l.length>0){let r=L(a,o,c).find(({id:d})=>l[0].startsWith(`${d}:`)||l[0].startsWith(`${d} (`))?.id;throw Object.assign(new Error(`${t}: ${l[0]}`),{reason:"check",slug:t,failures:l,...r?{component:r}:{}})}return{html:a,sha256:ut(i)}}async function Fc({directory:t=A,workspace:e=null,catalog:s=T()}={}){let o=await Fo(),n=async(i,{files:a=!0}={})=>{let c=await Eo(i,t,{catalog:s}),l=Mt(c.html,{slug:i,files:a,reportsDirectory:t,catalog:s}).html;return Do(i,l,o,c.sha256,s,t,await _o(e,i,l,s))};return n.check=async i=>{await Eo(i,t,{components:!1})},n}async function _o(t,e,s,o){return typeof t!="function"||!Rt(L(s,o))?null:await t(e).catch(()=>null)??null}async function Dc(t=[],{prepare:e=null,workspace:s=null,directory:o=A}={}){let n=Ao(o).exports,i=T(),{built:a,failures:c}=await da(t,{prepare:e,directory:o}),l=await Fo();await S.mkdir(n,{recursive:!0});let r=new Set(a.map(({report:h})=>h.slug)),{links:d}=await Ui(o),f=[];for(let{report:h,html:u}of a)try{let m=lo(u,h.slug,g=>r.has(g)?`${g}.html`:null,{links:d}),p=Do(h.slug,m,l,h.fileSha256,i,o,await _o(s,h.slug,m,i));await S.writeFile(N.join(n,`${h.slug}.html`),p),f.push({slug:h.slug,bytes:Buffer.byteLength(p),sha256:ut(p)})}catch(m){c.set(h.slug,[m.message])}return{built:a,exported:f,failures:c}}function To(t){let e=new Set;return M(t,s=>{for(let o of["id","data-block-id"])O(s,o)!==void 0&&e.add(O(s,o))}),e}function ua(t,e,s){if(Lo(t)||/^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(t)||ji(t))return!1;let{pathname:o}=new URL(e);return!o.startsWith(`/${s}/`)||o.endsWith(".html")}function pa({slug:t,tree:e,directory:s}){let o=[],n=To(e),i=s===B(N.basename(s),A)?A:N.dirname(s),a=new Map([[t,n]]),c=d=>{if(!a.has(d)){let f=Wt(B(d,i));a.set(d,bo(f.html)?To(w(ki(f.html,"utf8"))):null)}return a.get(d)},l=null,r=(d,f)=>f===null?_i(d):Di(f,l??=Pi((bo(i)?yi(i):[]).map(h=>({slug:h}))));return M(e,d=>{let f=d.tagName==="a"?O(d,"href"):void 0;if(!f||f==="#"||f==="#top")return;let h=d.sourceCodeLocation?.startLine;if(f.startsWith("#")){n.has(Ri(f.slice(1)))||o.push(`the link to ${f} (line ${h}) names no block or element of this document`);return}let u=Fi(f,t),m=Mi(u),p=r(u,m);(p?!c(p.slug):m!==null)?Lo(f)||o.push(`the link to ${f} (line ${h}) names a document that is not there: gallery list has the slugs`):p?.block&&!c(p.slug).has(p.block)?o.push(`the link to ${f} (line ${h}) names a block document ${p.slug} does not hold`):u&&!p&&ua(f,u,t)&&o.push(`the link to ${f} (line ${h}) leads to no document: a link to one is ../<slug>/doc.html, gallery list has the slugs`)},xi),o}function Mo({slug:t,html:e,directory:s=B(t,A),written:o=e,scriptNotes:n=[]}){let i=w(e),a=Ae(e);return{fix:[...no(e,i),...uo({html:e,directory:s,tree:i})],notes:[...Xe(e,{written:o}),...Ue(i),...pa({slug:t,tree:i,directory:s}),...a.notes,...n],readings:a.readings}}function _c(t){let{fix:e,notes:s}=Mo(t);return[...e,...s]}function Mc(t){let e=t.map(s=>[s.slug,Mo(s)]);for(let[s,{fix:o}]of e)for(let n of o)console.log(`fix ${s}: ${n}`);for(let[s,{notes:o}]of e)for(let n of o)console.log(`note ${s}: ${n}`);for(let[s,{readings:o}]of e)for(let n of o)console.log(`chart ${s}: ${n}`)}async function ma(t,{exportNote:e=!1}={}){for(let[s,o]of t){console.error(`
14
- FAIL ${s}: ${o.length} problem${o.length===1?"":"s"}`);for(let i of o)console.error(` - ${i}`);let n=N.join(Ai,`${s}.html`);e&&await S.stat(n).then(()=>!0,()=>!1)&&console.error(` ${n} was not updated; it still holds an earlier export.`)}}function ga(t,{above:e=!1,allow:s=process.argv.includes("--allow-failures")}={}){t.size!==0&&(console.error(`
15
- ${t.size} document${t.size===1?"":"s"} failed: ${[...t.keys()].join(", ")}${e?" (the failures are listed first, above)":""}`),s||(process.exitCode=1))}async function Pc(t,{exportNote:e=!1,allow:s}={}){await ma(t,{exportNote:e}),ga(t,{allow:s})}export{Es as a,_n as b,lo as c,$o as d,Mt as e,bi as f,Vi as g,Io as h,Ro as i,ia as j,Rc as k,aa as l,ra as m,da as n,ha as o,Fc as p,Dc as q,Mo as r,_c as s,Mc as t,ma as u,ga as v,Pc as w};
@@ -1,3 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import D from"node:fs/promises";import R from"node:path";import{writeAtomic as Y}from"../browser/shared/files.mjs";var I=371,S=1,j=["reader","agent"],T=/^\d{4}-\d{2}-\d{2}$/,$=d=>String(d).padStart(2,"0");function k(d){let s=new Date(d);return`${s.getFullYear()}-${$(s.getMonth()+1)}-${$(s.getDate())}`}function x(d,s){let[h,e,w]=d.split("-").map(Number);return k(new Date(h,e-1,w+s,12))}function F(d){let s;try{s=JSON.parse(d)}catch{return null}let h=r=>r!==null&&typeof r=="object"&&!Array.isArray(r);if(!h(s)||s.version!==S||!T.test(s.since??"")||!h(s.days)||!h(s.seen))return null;let e={};for(let[r,t]of Object.entries(s.days))if(!(!T.test(r)||!h(t)))for(let[g,p]of Object.entries(t))for(let b of j){let l=p?.[b];Array.isArray(l)&&l.length===2&&l.every(Number.isInteger)&&l[0]>0&&(((e[r]??={})[g]??={})[b]=[l[0],l[1]])}let w={};for(let[r,t]of Object.entries(s.seen))h(t)&&Number.isFinite(t.mtime)&&typeof t.hash=="string"&&Number.isInteger(t.words)&&(w[r]={mtime:t.mtime,hash:t.hash,words:t.words});return{version:S,since:s.since,days:e,seen:w}}function V({file:d,now:s=()=>new Date,wait:h=1e3}){let e=null,w=null,r=!1,t=null,g=Promise.resolve(),p=()=>k(s());function b(){return w??=D.readFile(d,"utf8").then(F,()=>null).then(n=>(e=n??{version:S,since:p(),days:{},seen:{},fresh:!0},n||(r=!0),e)),w}function l(){r=!0,!t&&(t=setTimeout(()=>{t=null,A()},h),t.unref?.())}function E(){let n=x(p(),-(I-1));for(let i of Object.keys(e.days))i<n&&delete e.days[i];let{version:a,since:c,days:u,seen:f}=e;return`${JSON.stringify({version:a,since:c<n?n:c,days:u,seen:f})}
3
- `}function A(){if(!e||!r)return g;r=!1,clearTimeout(t),t=null;let n=E();return g=g.then(async()=>{await D.mkdir(R.dirname(d),{recursive:!0}),await Y(d,n)}).catch(()=>{}),g}function N(n,a,c,u){let f=((e.days[a]??={})[n]??={})[j.includes(c)?c:"agent"]??=[0,0];f[0]+=1,f[1]+=u}return{load:b,get since(){return e?.since??p()},record(n,{hash:a,words:c,mtime:u,by:f}){if(!e)return!1;let i=e.seen[n];return e.seen[n]={mtime:u,hash:a,words:c},i?.hash===a?(i.mtime!==u&&l(),!1):(N(n,p(),f,c-(i?.words??0)),l(),!0)},async catchUp(n,a,{kept:c=[]}={}){await b();let u=e.fresh===!0;delete e.fresh;let f=0;for(let{slug:o,mtime:O}of n){let m=e.seen[o];if(m&&m.mtime===O)continue;let y=await a(o).catch(()=>null);if(!y||(e.seen[o]={mtime:y.edited,hash:y.hash,words:y.words},r=!0,u||m?.hash===y.hash))continue;let v=k(y.edited);N(o,v<e.since?e.since:v,"agent",y.words-(m?.words??0)),f+=1}let i=new Set([...n.map(({slug:o})=>o),...c]);for(let o of Object.keys(e.seen))i.has(o)||(delete e.seen[o],r=!0);return r&&l(),f},days(n=365){let a=p(),c=e?.since??a,u=x(a,-(Math.max(1,Math.min(I,n))-1));u<c&&(u=c);let f=[];for(let i=u;i<=a;i=x(i,1)){let o={date:i,edits:0,words:0,reader:{edits:0,words:0},agent:{edits:0,words:0}};for(let O of Object.values(e?.days[i]??{}))for(let m of j){let[y,v]=O[m]??[0,0];o[m].edits+=y,o[m].words+=v,o.edits+=y,o.words+=v}f.push(o)}return f},flush:A,async close(){clearTimeout(t),t=null,await A()}}}export{V as a};
@@ -1,4 +0,0 @@
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 x,b as w,e as _}from"./chunk-Q4UEPUWF.mjs";import{spawn as P}from"node:child_process";import{existsSync as T,mkdirSync as F,readFileSync as g,renameSync as I,rmSync as A,writeFileSync as C}from"node:fs";import m from"node:fs/promises";import j from"node:os";import p from"node:path";import{fileURLToPath as k}from"node:url";import{userDirectory as b}from"../browser/shared/user-directory.mjs";import{compareVersions as O,RELEASED as S}from"../browser/shared/versions.mjs";var d="@heycys/gallery",D="\u6280\u80FD\uFF1A",G="\u65B0\u7248\u672C\uFF1A",Y="update-check.json",U=1440*60*1e3,H=3600*1e3,v=5e3,X="https://registry.npmjs.org/",K=d.split("/")[0],L="\uFF08\u4E4B\u540E\u65B0\u5F00\u7684 Agent \u4F1A\u8BDD\u624D\u8BFB\u5230\u65B0\u6280\u80FD\uFF09",h=t=>!["","0","false",void 0].includes(t),W=(t=process.env)=>h(t.GALLERY_NO_UPDATE_CHECK)||h(t.CI)||h(t.NO_UPDATE_NOTIFIER),J=(t=k(import.meta.url))=>/[\\/]_npx[\\/]/.test(t),V=(t={})=>b("cache",t);function M(t,e=process.env){let o=i=>i.replace(/(?<!\\)\$\{([^${}?]+)(\?)?\}/g,(c,l,s)=>e[l]??(s?"":c)),n={},r=!1;for(let i of t.replace(/^\uFEFF/,"").split(/\r?\n/)){let c=i.trim();if(!c||/^[;#]/.test(c))continue;if(/^\[.*\]$/.test(c)){r=!0;continue}let l=c.indexOf("=");if(r||l<1)continue;let s=c.slice(l+1).trim();/^(".*"|'.*')$/.test(s)?s=s.slice(1,-1):s=s.split(/(?<!\\)[;#]/)[0].replace(/\\([;#])/g,"$1").trim(),n[o(c.slice(0,l).trim())]=o(s)}return n}function $({env:t=process.env,home:e=t.HOME||j.homedir(),platform:o=process.platform,execPath:n=process.execPath}={}){let r={};for(let[a,f]of Object.entries(t)){if(!/^npm_config_/i.test(a)||!f)continue;let y=a.slice(11);r[y.startsWith("//")?y:y.replace(/(?!^)_/g,"-").toLowerCase()]=f}let i=a=>{try{return M(g(a,"utf8"),t)}catch{return{}}},c=a=>p.resolve(/^~[\\/]/.test(a)?p.join(e,a.slice(2)):a),l=o==="win32"?p.dirname(n):p.dirname(p.dirname(n)),s=[],u=[()=>r,()=>i(c(r.userconfig||p.join(e,".npmrc"))),()=>{let a=s[3]??=u[3](),f=r.prefix||s[1].prefix||a.prefix||t.PREFIX||l;return i(c(r.globalconfig||p.join(c(f),"etc","npmrc")))},()=>i(o==="win32"?p.join(l,"node_modules","npm","npmrc"):p.join(l,"lib","node_modules","npm","npmrc"))];return a=>{for(let f=0;f<u.length;f++)if(s[f]??=u[f](),s[f][a])return s[f][a]}}function q(t=process.env,e=$({env:t})){let o=t.GALLERY_REGISTRY||e(`${K}:registry`)||e("registry")||X;return o.endsWith("/")?o:`${o}/`}function z(t=process.env,e=$({env:t})){let o={...t,NODE_USE_ENV_PROXY:"1"},n=(c,l)=>{for(let s of Object.keys(o))c.test(s)&&delete o[s];Object.assign(o,l)},r=e("https-proxy")||e("proxy");r&&n(/^https?_proxy$/i,{HTTPS_PROXY:r,HTTP_PROXY:r});let i=e("noproxy");return i&&n(/^no_proxy$/i,{NO_PROXY:i}),o}var B=t=>`${t}${d.replace("/","%2f")}/latest`;function R(t){try{let e=JSON.parse(g(t,"utf8"));return e&&typeof e=="object"?e:null}catch{return null}}function Q(t,e,o=Date.now()){if(!t||!Number.isFinite(t.checked)||t.registry!==e)return!0;let n=o-t.checked;return n<0||n>=(t.failed?H:U)}var E=(t,e)=>t?.registry===e&&typeof t.latest=="string"&&S.test(t.latest)?t.latest:null;function Z(t,e,o,n=Date.now()){let r=`${t}.${process.pid}.tmp`;try{return F(p.dirname(t),{recursive:!0}),C(r,`${JSON.stringify({checked:n,registry:e,latest:E(o,e),failed:!0,checking:!0})}
3
- `),I(r,t),!0}catch{return!1}finally{try{A(r,{force:!0})}catch{}}}async function dt(t,e,{timeout:o=v,now:n=Date.now}={}){let r=null;try{let l=await fetch(B(e),{signal:AbortSignal.timeout(o),headers:{Accept:"application/json"}});if(l.ok){let{version:s}=await l.json();typeof s=="string"&&S.test(s)&&(r=s)}}catch{}let i=r?{checked:n(),registry:e,latest:r}:{checked:n(),registry:e,latest:E(R(t),e),failed:!0};await m.mkdir(p.dirname(t),{recursive:!0});let c=`${t}.${process.pid}.tmp`;try{await m.writeFile(c,`${JSON.stringify(i)}
4
- `),await m.rename(c,t)}finally{await m.rm(c,{force:!0}).catch(()=>{})}return i}function tt(t,e,{env:o=process.env}={}){try{let n=P(process.execPath,[k(new URL("./update-fetch.mjs",import.meta.url)),t,e],{cwd:j.homedir(),env:o,detached:!0,stdio:"ignore",windowsHide:!0});return n.on("error",()=>{}),n.unref(),!0}catch{return!1}}function et({env:t=process.env,cwd:e=process.cwd()}={}){let o=[...Object.values(x).map(r=>({folder:p.join(p.resolve(r.home(t)),"skills","gallery"),project:!1})),...Object.values(x).map(r=>({folder:p.join(p.resolve(e),r.project,"skills","gallery"),project:!0}))],n=r=>process.platform==="win32"?r.toLowerCase():r;return o.filter(({folder:r},i)=>o.findIndex(c=>n(c.folder)===n(r))===i)}var N=(t,e,o)=>o?`npx -y ${d}@^${e} ${t}`:`gallery ${t}`,rt=(t,e,o,n,r=!1)=>`${D}${t} \u662F${e?` Gallery ${e} `:"\u65E7\u7248 Gallery\uFF08\u6CA1\u5199\u7248\u672C\uFF09"}\u7684\uFF0C\u6BD4\u8FD9\u4E2A gallery ${o} \u65E7\uFF1B\u95EE\u8FC7\u7528\u6237\u540E\u8FD0\u884C ${N(`skill install${n?" --project":""}`,o,r)}${L}`,ot=(t,e,o=!1)=>`${G}npm \u4E0A\u6709 Gallery ${t}\uFF0C\u8FD9\u4E2A gallery \u662F ${e}\uFF1B\u95EE\u8FC7\u7528\u6237\u540E\u8FD0\u884C ${o?N("skill install",t,!0):`npm i -g ${d}@^${t}\uFF0C\u518D\u8FD0\u884C gallery skill install`}${L}`;function nt(t,{env:e=process.env,cwd:o=process.cwd(),npx:n=!1}={}){let r=[];for(let{folder:i,project:c}of et({env:e,cwd:o})){let l;try{l=g(p.join(i,"SKILL.md"),"utf8")}catch{continue}if(!["gallery","html-report-studio"].includes(w(l))||T(p.join(i,".git")))continue;let s=_(l);s&&O(s,t)>=0||r.push(rt(i,s,t,c,n))}return r}function yt(t,{env:e=process.env,cwd:o=process.cwd(),now:n=Date.now(),npx:r=J()}={}){let i=[];try{i.push(...nt(t,{env:e,cwd:o,npx:r}))}catch{}if(W(e))return i;try{let c=$({env:e}),l=q(e,c),s=p.join(V({env:e}),Y),u=R(s);Q(u,l,n)&&Z(s,l,u,n)&&tt(s,l,{env:z(e,c)});let a=E(u,l);a&&O(a,t)>0&&i.push(ot(a,t,r))}catch{}return i}export{d as a,D as b,G as c,Y as d,U as e,H as f,v as g,W as h,J as i,V as j,M as k,$ as l,q as m,z as n,B as o,R as p,Q as q,Z as r,dt as s,tt as t,et as u,rt as v,ot as w,nt as x,yt as y};
@@ -1,3 +0,0 @@
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{c as L,d as _,e as D,h as N}from"./chunk-7M2BQQGZ.mjs";import{createHash as q,randomUUID as Q}from"node:crypto";import f from"node:fs/promises";import g from"node:path";import{refusal as V,said as T,saying as X}from"../browser/shared/i18n/index.mjs";import{extensionOf as Y,imageExtension as Z,imageFile as M,mediaTypeOf as tt,UPLOAD_LIMITS as y}from"../browser/shared/media.mjs";import{slugPattern as F}from"../browser/shared/reports.mjs";import{documentDirectory as U,documentFiles as et,layoutOf as nt}from"../browser/shared/workspace.mjs";var z=i=>Y(String(i??"").replace(/[?#].*$/,"")),it=i=>{let e=String(i??"").replace(/[?#].*$/,"");e=e.slice(e.lastIndexOf("/")+1);try{e=decodeURIComponent(e)}catch{}return e.replace(/[\u0000-\u001f<>:"/\\|?*]/g,"").trim().slice(0,120)||"file"};function rt(i){let e=i.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[0]===255&&e[1]===216?"image/jpeg":e.toString("latin1",0,4)==="GIF8"?"image/gif":e.toString("latin1",0,4)==="RIFF"&&e.toString("latin1",8,12)==="WEBP"?"image/webp":e.toString("latin1",4,12)==="ftypavif"?"image/avif":/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*<svg\b/i.test(i.subarray(0,512).toString("utf8"))?"image/svg+xml":null}var w=(i,e)=>V(e,{reason:i}),S=(i,e)=>{let l=rt(i);if(!l)throw w("type","\u4EC5\u652F\u6301\u56FE\u7247");return Z(l)},at=(i,e)=>z(e),ot=(i,e)=>{let l=z(e);if(!["html","htm","pdf"].includes(l)||l==="pdf"&&i.subarray(0,5).toString("latin1")!=="%PDF-")throw w("type","\u53EA\u80FD\u5D4C\u5165 HTML \u6216 PDF \u6587\u4EF6");return l},j={big:i=>T("\u56FE\u7247\u592A\u5927\uFF08\u6700\u591A {0} MB\uFF09",i),unreachable:"\u4E0B\u8F7D\u4E0D\u4E86\u8FD9\u5F20\u56FE\u7247"},B={big:i=>T("\u6587\u4EF6\u592A\u5927\uFF08\u6700\u591A {0} MB\uFF09",i),unreachable:"\u4E0B\u8F7D\u4E0D\u4E86\u8FD9\u4E2A\u6587\u4EF6"},k={icon:{limit:y.icon,words:j,extension:S},image:{limit:y.image,words:j,extension:S},file:{limit:y.file,words:B,extension:at,named:!0},embed:{limit:y.embed,words:B,extension:ot,named:!0}};function wt(i,e,l,b){let s=k[i].extension(l,b);return`${i}-${e.slice(0,12)}${s?`.${s}`:""}`}function bt({reportsDirectory:i}){let e=nt(i).emojiLibrary,l=async t=>{let n=U(t,i);return await f.stat(et(n).html).catch(()=>null)?n:null},b=g.join(e,"library.json"),s=(t,n,r)=>[t,{ok:!1,reason:n,...X(r)}];async function O(t,n,{stem:r,limit:a,words:c=j,extension:o=S,given:m}){let u=o(n,m);if(n.length>a)throw w("size",c.big(a/1024/1024));let p=`${r}-${q("sha256").update(n).digest("hex").slice(0,12)}${u?`.${u}`:""}`;await f.mkdir(t,{recursive:!0});let h=g.join(t,p);return await f.stat(h).catch(()=>null)||await f.writeFile(h,n),p}let E=(t,n,r,a=y.icon)=>O(t,n,{stem:r,limit:a});async function I(t,n,r=j){let a=await L(t,{unreachable:r.unreachable});if(!a.ok)throw w("download",r.unreachable);let c=await _(a,n);if(!c)throw w("size",r.big(n/1024/1024));return c}async function $(){try{let t=JSON.parse(await f.readFile(b,"utf8"));return Array.isArray(t)?t:[]}catch{return[]}}let v=t=>({id:t.id,name:t.name,url:`/__gallery/edit/emoji-library/${t.file}`,created_time:t.created,alive:!0});async function A(t){let{slug:n,data:r,url:a,library:c}=t??{},o=Object.hasOwn(k,t?.kind)?t.kind:"icon";if(typeof n!="string"||!F.test(n))return s(400,"body");let m=await l(n);if(!m)return s(404,"missing");let{limit:u,words:p,extension:h,named:J}=k[o];try{let d,x;if(typeof r=="string")d=Buffer.from(r,"base64"),x=t.name;else if(typeof a=="string")d=await I(a,u,p),x=a;else if(typeof c=="string"){let P=(await $()).find(K=>K.id===c);if(!P)return s(404,"library","\u8FD9\u4E2A\u81EA\u5B9A\u4E49\u8868\u60C5\u5DF2\u4E0D\u5728\u8868\u60C5\u5E93\u91CC");d=await f.readFile(g.join(e,P.file))}else return s(400,"body");return[200,{ok:!0,path:`assets/${await O(g.join(m,"assets"),d,{stem:o,limit:u,words:p,extension:h,given:x})}`,...J?{name:it(x),size:d.length}:{}}]}catch(d){return s(422,d.reason??"write",d)}}async function R(t){let{slug:n,url:r,parts:a="all"}=t??{};if(typeof n!="string"||!F.test(n)||typeof r!="string"||!["all","icon","title"].includes(a))return s(400,"body");let c=await l(n);if(!c)return s(404,"missing");try{return[200,{ok:!0,...await N(r,async(m,u)=>`assets/${await E(g.join(c,"assets"),m,u,y.image)}`,{icon:a!=="title",cover:a==="all"})}]}catch(o){return s(422,o.reason??"download",o)}}async function W(t){return typeof t?.url!="string"?s(400,"body"):[200,{ok:!0,...await D(t.url)}]}async function C(t){let{slug:n,name:r,url:a}=t??{};if(typeof r!="string"||!/^[\p{Ll}\p{Lo}\d_-]{1,49}$/u.test(r)||typeof a!="string")return s(400,"body");let c=await $();if(c.some(o=>o.name===r))return s(409,"name","\u540D\u79F0\u5DF2\u88AB\u5360\u7528");try{let o;M(a)&&typeof n=="string"&&F.test(n)?o=await f.readFile(g.join(U(n,i),a)):o=await I(a,y.icon);let m=await E(e,o,"emoji"),u={id:Q(),name:r,file:m,created:Date.now()};return await f.writeFile(b,`${JSON.stringify([...c,u],null,2)}
3
- `),[200,{ok:!0,entry:v(u)}]}catch(o){return s(422,o.reason??"write",o)}}let G=async()=>[200,{ok:!0,list:(await $()).map(v)}];async function H(t){if(!M(`assets/${t}`))return null;let n=await f.readFile(g.join(e,t)).catch(()=>null);return n&&{type:tt(t),body:n}}return{upload:A,unfurl:R,frameable:W,addEmoji:C,listEmojis:G,readEmoji:H}}export{wt as a,bt as b};
@@ -1,2 +0,0 @@
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 ha,A as I,B as J,C as K,D as L,E as M,F as N,G as O,H as P,I as Q,J as R,K as S,L as T,M as U,N as V,O as W,P as X,Q as Y,R as Z,S as _,T as $,U as aa,V as ba,W as ca,X as da,Y as ea,Z as fa,_ as ga,a as i,aa as ia,b as j,ba as ja,c as k,ca as ka,d as l,e as m,f as n,g as o,h as p,i as q,j as r,k as s,l as t,m as u,n as v,o as w,p as x,q as y,r as z,s as A,t as B,u as C,v as D,w as E,x as F,y as G,z as H}from"./chunk-XBNFXWAW.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-T4Y2ZSVX.mjs";import"./chunk-5GK7HS62.mjs";import"./chunk-PUOQ65NC.mjs";import{a,b,c,f as d,g as e,h as f,k as g,l as h}from"./chunk-ZLS2FRS6.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-BX5AKINW.mjs";import"./chunk-HX4DLE3J.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-FJLM7YE7.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{_ as ADVICE,t as BLOCK_PICTURES,$ as CODE_SIDEWAYS,X as HAND_OVER,u as INK_MARGIN,i as KINDS,j as LEVELS,k as LOOKS,Y as LOOK_YOURSELF,W as MORE_PICTURES,M as MOSTLY_CHANGED,y as MOVED_PART,x as MOVED_WHOLE,w as NEIGHBOUR_EDGE,p as PICTURED_INFO,ca as SCROLLS,v as SCROLL_FRAMES,s as SCROLL_SLACK,ba as WARNED,l as WIDE,m as WIDTHS,f as adoptIdless,aa as adviceOf,e as baselineOf,L as baselineSaid,b as blocksOf,N as blocksToPicture,da as describeLooks,S as disclosuresSaid,g as exportBaselines,G as exportOf,ga as exportingFirst,Q as findingKey,q as findingLevel,O as inkOf,P as inventory,n as layoutNotesOf,o as levelOf,R as lookAt,J as missedWidths,V as morePictures,H as movedBlocks,z as movedClips,ha as namedBlocks,I as nextBaseline,ea as notPicturedLine,c as pageOf,r as picturedAt,T as picturesSaid,D as placeOf,h as previewBaseline,a as rankOf,d as readBaseline,ka as run,K as seenOf,C as sourceIndex,F as staleExport,Z as startFailure,E as timeOf,ia as unknownBlocks,ja as unknownBlocksSaid,U as unopenedSaid,A as urlName,fa as verdictOf,B as wordsOf};
@@ -1,6 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{b as Q}from"./chunk-2HS7ZBPU.mjs";import{c as _,d as z,e as B,l as G}from"./chunk-SQ3FQCCN.mjs";import"./chunk-3F57LEN5.mjs";import"./chunk-QP7BOHE4.mjs";import{i as q}from"./chunk-GMJD7ID3.mjs";import{a as b,b as J}from"./chunk-JEUK3ZO7.mjs";import{a as Z}from"./chunk-JJNHKGTD.mjs";import{a as ee}from"./chunk-JPG2LBQM.mjs";import"./chunk-ALZ6ZENZ.mjs";import"./chunk-IA4PSIMD.mjs";import{c as V,d as Y,e as M}from"./chunk-RRKJMHNX.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import{b as W,h as X}from"./chunk-VRPVVMRB.mjs";import"./chunk-L55NOXBE.mjs";import"./chunk-7UZUQQ7Q.mjs";import{b as T,f as C,g as H}from"./chunk-4OZWXZE5.mjs";import"./chunk-ZTHICSSF.mjs";import{k as U}from"./chunk-FJLM7YE7.mjs";import{b as K}from"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import v from"node:fs/promises";import se from"node:os";import x from"node:path";import{IMPORT_EXT as re,kindOf as ie}from"../browser/shared/import-types.mjs";import{reportsDirectory as O}from"../browser/shared/paths.mjs";import{kebab as S}from"../browser/shared/web-links.mjs";import{documentDirectory as oe,documentFiles as E,newDocSlug as ae}from"../browser/shared/workspace.mjs";var ce=Object.values(re).flat().join(" "),j=(d,g)=>`${d} ${g}${d===1?"":"s"}`;function fe(d,g,p){let n=(f,r=g)=>(r.match(f)??[]).length,c=n(/<ol class="doc-flow"/g,p),$=n(/<li id="fn-\d+"/g,p),w=[[n(/<section class="doc-section"/g),"section"],[n(/<h[2-4][\s>]/g),"heading"],[n(/<p[\s>]/g),"paragraph"],[n(/<(?:ul|ol)[\s>]/g),"list"],[n(/<table\b/g),"table"],[n(/class="doc-math-(?:inline|block)"/g,p),"formula"],[n(/<div class="doc-code"/g),"code block"],[n(/<figure class="doc-image"/g),"picture"],[c,"flow"],[$,"footnote"]].filter(([f])=>f>0).map(([f,r])=>j(f,r)),h=(d.raws?.length??0)-c-($?1:0);return h>0&&w.push(`${j(h,"HTML block")} kept as written`),w}async function Se(d){let{positional:g,options:p}=C({options:["--no-preview","--no-browser"],argv:d}),[n,c,$]=g;if(g.length<1||g.length>3||!n)throw new T("Name the file; then the slug and the title, if you choose them.");let w=ie(n);if(!w)throw new T(`Not a kind of file gallery import takes: ${n} (${ce}).`);c!==void 0&&H(c);let h=x.resolve(n);await v.stat(h).then(i=>i.isFile(),()=>!1)||(console.error(`No such file: ${n}`),process.exit(1));let f=c!==void 0?await Q(c):null;f&&(console.error(f),process.exit(1));let r=x.basename(h),F=await v.mkdtemp(x.join(se.tmpdir(),"gallery-import-")),L,y,R;try{let i,u=[];if(w==="markdown")i=[{...await Y(h,F),from:r,children:[]}];else try{({pages:i,skipped:u}=await V([{file:h,name:r}],F))}catch(e){console.error(`${r} could not be read: ${e.message}`),process.exit(1)}i.length===0&&(console.error(`Nothing in ${r} could be read as a page${u.length?` (not taken: ${u.join(", ")})`:""}.`),process.exit(1)),$?.trim()&&(i[0]={...i[0],title:$.replace(/\s+/g," ").trim()});let I=new Map,te=ee({edits:{},reports:{},reportsDirectory:O});y=(await Z(i,{create:async(e,t,l,{lang:s})=>{let{directory:o}=await K(e,t,l,{blank:!0,lang:s});I.set(e,await v.readFile(E(o).html,"utf8"))},slugOf:(e,t)=>{if(t===0&&c!==void 0)return c;let l=S(e.title)||S(e.from?.replace(/\.[^.]+$/,"")??"")||S(r.replace(/\.[^.]+$/,""));return l?te.freeSlug(l):ae(O)},folderOf:e=>oe(e,O),fill:e=>M(e),place:(e,t)=>q(e,{parent:t})})).made;let P=[],A=(e,t)=>{P.push({page:e,depth:t});for(let l of e.children??[])A(l,t+1)};for(let e of i)A(e,0);let m=await Promise.all(P.map(async({page:e,depth:t},l)=>{let s=y[l],o=oe(s,O),a=E(o).html,k=await v.readFile(a,"utf8"),ne=(await M({source:I.get(s),nodes:e.nodes,icon:e.icon,own:e.own})).replace(/<p>\u{E000}\d+\u{E001}<\/p>/gu,""),le=X(W(k,{finish:U}).text);return{slug:s,depth:t,page:e,directory:o,htmlFile:a,made:fe(e,ne,k),readOnly:le}}));if(L={slug:y[0]},m.length===1){let[{page:e,directory:t,htmlFile:l,made:s,readOnly:o}]=m;if(console.log(`Created ${b(l)} and ${x.basename(E(t).json)} from ${r}`),console.log(`Title: ${e.title}`),console.log(`Made: ${s.length?s.join(", "):"nothing but the title"}${e.files.length?` (${j(e.files.length,"file")} in ${b(x.join(t,"assets"))})`:""}`),e.notes?.length){console.log(`Not brought as the file has it (${e.notes.length}):`);for(let a of e.notes)console.log(` ${a.line?`line ${a.line}: `:""}${a.text}`)}if(o.length){console.log(`Text the preview leaves read-only (${o.length}), by doc.html's lines as gallery check gives them:`);for(let a of o)console.log(` ${a}`)}}else{console.log(`Created ${j(m.length,"document")} from ${r} (each nested as in the file):`);for(let{slug:l,depth:s,page:o,htmlFile:a,made:k}of m)console.log(`${" ".repeat(s+1)}${l} ${o.title} ${b(a)}`),console.log(`${" ".repeat(s+2)}Made: ${k.length?k.join(", "):"nothing but the title"}${o.files.length?` (${j(o.files.length,"file")} in its assets/)`:""}`);let e=m.flatMap(({slug:l,page:s})=>(s.notes??[]).map(o=>` ${l}: ${o.line?`line ${o.line}: `:""}${o.text}`));e.length&&console.log(`Not brought as the file has it (${e.length}):
3
- ${e.join(`
4
- `)}`);let t=m.flatMap(({slug:l,readOnly:s})=>s.map(o=>` ${l}: ${o}`));t.length&&console.log(`Text the preview leaves read-only (${t.length}), by doc.html's lines as gallery check gives them:
5
- ${t.join(`
6
- `)}`)}u.length&&console.log(`Not taken from ${r} (${u.length}): ${u.join(", ")}`);for(let e of await J())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 G(L.slug,{skipped:B(p),command:`gallery import ${r}`});console.log(_(N,R)),console.log(`Hand in: gallery export ${y.join(" ")}, then gallery qa ${y.join(" ")}`);let D=await z(N,p);D&&console.log(D);for(let i of N)console.log(i)}export{Se as run};
@@ -1,2 +0,0 @@
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 R}from"./chunk-6Y3HYOBM.mjs";import{b as I,c as B}from"./chunk-342HXE3Q.mjs";import{a as f,b as F,c as L,d as M}from"./chunk-T4Y2ZSVX.mjs";import{a as S,b as k,g as $}from"./chunk-5GK7HS62.mjs";import{a as N}from"./chunk-DR73Y2UJ.mjs";import{k as b}from"./chunk-ZLS2FRS6.mjs";import"./chunk-S3SX3COT.mjs";import{b as D}from"./chunk-ALZ6ZENZ.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import{b as v}from"./chunk-VRPVVMRB.mjs";import{j as d}from"./chunk-4OZWXZE5.mjs";import{k as w,q as h,t as g,u as y,v as x}from"./chunk-BX5AKINW.mjs";import"./chunk-HX4DLE3J.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-FJLM7YE7.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import O from"node:fs/promises";import{reportsDirectory as P}from"../browser/shared/paths.mjs";import{documentDirectory as U,documentFiles as q,layoutOf as z}from"../browser/shared/workspace.mjs";function C(s=P){let n=D({root:s,read:async a=>{let o=await O.readFile(q(U(a,s)).html,"utf8").catch(()=>null);return o===null?null:{source:o,text:v(o).text}},activity:N({file:z(s).activity})});return a=>n.snapshot(a)}async function te(s){let{slugs:t,options:n}=await d({options:["--allow-failures"],argv:s});t.length===0&&(console.error(R()),process.exit(1));let a=await b(t),o=await w(t,{prepare:f({say:!1})}),r=await S(t.filter(e=>!o.has(e)));await k(t.filter(e=>o.has(e)||r.failures.has(e))),await L(t),await M(t);let m=t.filter(e=>!o.has(e)&&!r.failures.has(e)),{built:l,exported:p,failures:c}=m.length>0?await h(m,{prepare:f({say:!1}),workspace:C()}):{built:[],exported:[],failures:new Map};for(let[e,i]of[...o,...r.failures])c.set(e,i);await y(c,{exportNote:!0}),await a.keep(p.map(({slug:e})=>e));let A=new Map(l.map(({report:e,removed:i})=>[e.slug,i]));for(let{slug:e,bytes:i,sha256:j}of p){let u=A.get(e),E=u.length>0?`; shared scripts and styles left out (unused): ${u.join(", ")}`:"";console.log(`Exported ${I(e)} (${i.toLocaleString("en-US")} bytes, sha256 ${j})${E}`)}g(l.map(({report:e})=>e)),F(l.map(({report:e})=>e));for(let e of r.lines)console.log(e);r.written.length>0&&console.log($(r.written));for(let{slug:e}of p)console.log(B(e));x(c,{above:!0,allow:n.has("--allow-failures")})}export{te as run};
@@ -1,2 +0,0 @@
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-6Y3HYOBM.mjs";import"./chunk-T4Y2ZSVX.mjs";import"./chunk-5GK7HS62.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-BX5AKINW.mjs";import"./chunk-HX4DLE3J.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-FJLM7YE7.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as noDocuments,b as run};
@@ -1,2 +0,0 @@
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-PKVK6WFC.mjs";import"./chunk-NMF3IPYA.mjs";import"./chunk-LJLVCU6W.mjs";import"./chunk-XBNFXWAW.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-T4Y2ZSVX.mjs";import"./chunk-XZV72SQ4.mjs";import"./chunk-V4ZHRALW.mjs";import"./chunk-5GK7HS62.mjs";import"./chunk-SQ3FQCCN.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-M4NRDYI5.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-6QWQXHAV.mjs";import"./chunk-ZLS2FRS6.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-7UZUQQ7Q.mjs";import"./chunk-4B2TB5K2.mjs";import"./chunk-KLQP46Y3.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-BX5AKINW.mjs";import"./chunk-HX4DLE3J.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-FJLM7YE7.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{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 +0,0 @@
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 f,d as g,e as h,f as $,g as v,i as y,j as r,k as x}from"./chunk-GMJD7ID3.mjs";import{b as c,f as p}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{descendantsIn as A}from"../browser/shared/outline.mjs";async function N(L){let{positional:u,options:I,values:T}=p({options:["--top","--first"],values:["--under","--after"],argv:L});if(u.length!==1)throw new c("Name the document to move, one.");let e=x(T,I);if(e.under===void 0&&!e.top&&e.after===void 0&&!e.first)throw new c("Say where it goes: --under <document> or --top, and --after <document> or --first.");let s=await f(),a=async(b,k)=>{let d=await $(b,k,s);return d.refused&&(console.error(d.refused),process.exit(1)),d.slug},t=await a(u[0],"the document to move"),l=e.under!==void 0?await a(e.under,"--under"):e.top?"":void 0,m=e.after!==void 0?await a(e.after,"--after"):null,o=await y(t,{parent:l,after:m,first:e.first});o.ok||(console.error(v(s,t,o.reason,{parent:l,after:m,message:o.message})),process.exit(1));let n=await f(),i=A(n.children,t).length,w=`${g(n,t)}${i?` with the ${i} document${i===1?"":"s"} under it`:""}`;o.moved?console.log(`Moved ${w}: now ${r(n,o)}; it was ${r(s,o.from)}.`):console.log(`${w} is there already: ${r(n,o)}.`),console.log(h(n,t))}export{N as run};
@@ -1,2 +0,0 @@
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 S}from"./chunk-4OZWXZE5.mjs";import{workspaceBase as _}from"../browser/shared/service-location.mjs";import I from"node:fs/promises";import{listExtensions as C}from"../browser/shared/extensions.mjs";import{ancestorsIn as M,moveDocument as P,outlineAndFile as A}from"../browser/shared/outline.mjs";import{DOCS as k,groupOfTop as B,isForeign as b,isTop as G,topIn as J,topOf as U}from"../browser/shared/outline-shape.mjs";import{draftFacts as q,draftOf as z,registeredIds as K,workspaceNames as R}from"../browser/shared/drafts.mjs";import{reportsDirectory as u}from"../browser/shared/paths.mjs";import{findPreviewServer as W}from"../browser/shared/preview-server.mjs";import{roleOf as X}from"../browser/shared/reports.mjs";import{nameStops as H,workspaceName as Q}from"../browser/shared/workspace-name.mjs";import{workspaceKey as w}from"../browser/shared/workspace-registry.mjs";import{defaultWorkspace as V,documentDirectory as y,documentFiles as Y,pageSlug as Z,readLink as ee}from"../browser/shared/workspace.mjs";async function ge(e=u,{others:t=w(e)===w(u)}={}){let{outline:{children:n,groups:o,links:s,shown:i},others:c}=await A(e,{others:t}),m=te(e,o,i),a=new Set(i.map(({id:r})=>r)),p=o.map(r=>({...r,name:m.get(r.id)??null,...t&&r.workspace&&!a.has(r.workspace)?{away:!0}:{}})),$=p.filter(r=>!r.extension),F=await C(e),x=Object.values(n).flat(),N=r=>typeof r=="string"?r.replace(/\s+/g," ").trim():"",j=x.some(b)?K():null,E=new Map(await Promise.all(x.map(async r=>{if(b(r)){let d=z(r),O=c.find(({id:L})=>L===d?.ws)?.facts.get(d.slug),f=O?{...O,missing:null}:await q(r,j);return[r,{slug:r,title:f.title,description:f.description,icon:f.icon,...f.url?{url:f.url}:{},draft:{path:f.path,missing:f.missing,ws:d?.ws??null}}]}if(s.includes(r)){let d=await ee(y(r,e));return[r,{slug:r,title:d?.title??r,description:"",icon:d?.icon??null,url:d?.url??""}]}let h=await I.readFile(Y(y(r,e)).json,"utf8").then(JSON.parse).catch(()=>({}));return[r,{slug:r,title:N(h?.title)||r,description:N(h?.description),icon:typeof h?.icon=="string"?h.icon:null}]})));return{children:n,groups:$,columns:p,extensions:F,documents:E}}function te(e,t,n=[]){let o=w(V()),s=new Set(t.map(({workspace:a})=>a).filter(Boolean)),i=H(),c=s.size?R(s,{stops:i}):new Map,m=new Map;for(let a of t)if(a.id===k)m.set(a.id,w(e)===o?"\u9ED8\u8BA4\u6587\u6863":Q(e,{stops:i}).name);else if(a.workspace){let p=n.find(({id:$})=>$===a.workspace);m.set(a.id,p?.isDefault?"\u9ED8\u8BA4\u6587\u6863":c.get(a.workspace)?.name??a.workspace)}else a.role==="links"&&m.set(a.id,"\u94FE\u63A5");return m}var v=e=>e?.title??e?.name??(e?.id===k?"\u6587\u6863":e?.role==="links"?"\u94FE\u63A5":e?"\u672A\u547D\u540D\u680F":"\u6587\u6863"),T=(e,t)=>e.groups?.find(({id:n})=>n===B(t));function ye(e,t){let n=e.documents.get(t);if(!n||n.url!==void 0)return null;let o=D(e,t),s=n.draft?.ws??null,i=s?e.groups.find(c=>c.workspace===s):e.groups.find(c=>c.id===k);return i&&U(i.id)===o?null:i?i.hidden?i.name??s:v(i):s}var l=({documents:e},t)=>`${t} (${e.get(t)?.title??t})`,D=(e,t)=>J(e.children,t)??"";function ke(e,t){let n=M(e.children,t).map(i=>l(e,i)),o=D(e,t),s=[...o===""?[]:[`${v(T(e,o))}\u680F`],...n];return`\u4F4D\u7F6E\uFF1A${s.length?s.join(" \u203A "):"\u9876\u5C42"}`}async function ve(e,t,n){let{slug:o}=await S(e);if(o===await Z(u))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=y(o,u);return{refused:await X(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 ne={"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 ${l(e,t)} under: gallery list --tree shows them.`,after:(e,t,{after:n})=>`No document "${n}" to put ${l(e,t)} after: gallery list --tree shows them.`,level:(e,t,{parent:n,after:o})=>`${l(e,o)} is not under ${n?l(e,n):"the top level"}: --after names a document at the level it goes to.`,itself:(e,t)=>`${l(e,t)} cannot go after itself.`,inside:(e,t,{parent:n,after:o})=>n===void 0&&o?`${l(e,t)} cannot go after ${l(e,o)}, which is under it.`:`${l(e,t)} cannot go under ${n===t?"itself":`${l(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."},xe=(e,t,n,o={})=>(ne[n]??((s,i,{message:c})=>`Not moved: ${c??n}.`))(e,t,o);async function oe(e,t,n="move"){let o=`127.0.0.1:${e.port}`;try{let i=await(await fetch(`http://${o}${_(u)}/__gallery/workspace/${n}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${o}`,"X-Gallery-Token":e.token},body:JSON.stringify({...t,workspace:u}),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 Ne(e,{parent:t=void 0,after:n=null,first:o=!1}={}){let s=await W(),i={slug:e,...t!==void 0?{parent:t}:{},after:n,first:o},c=s?await oe(s,i):null;return c||P(u,e,{parent:t,after:n,first:o})}function Oe(e,{parent:t,index:n}){let o=e.children[t]??[],s=t===""?"at the top level":G(t)?`at the top of the ${v(T(e,t))} column`:`under ${l(e,t)}`;return o.length===1?`${s}, the only ${o.some(i=>e.documents.get(i)?.url!==void 0)?"entry":"document"} there`:n===0?`${s}, first`:`${s}, right after ${l(e,o[n-1])}${n===o.length-1?", last":""}`}function Se(e,t,{top:n=!0}={}){let o=e.get("--under"),s=e.get("--after");if(o!==void 0&&t.has("--top"))throw new g("--under and --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"),after:s,first:t.has("--first")}}export{ge as a,v as b,ye as c,l as d,ke as e,ve as f,xe as g,oe as h,Ne as i,Oe as j,Se as k};
@@ -1,2 +0,0 @@
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-2HS7ZBPU.mjs";import"./chunk-SQ3FQCCN.mjs";import"./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-PAREWQGB.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as DEFAULT_DESCRIPTION,c as run,b as slugRefused};
@@ -1,10 +0,0 @@
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 i,l as C}from"./chunk-FJLM7YE7.mjs";import{a as g,c as w}from"./chunk-HYMEEXKN.mjs";import{g as j,o as A,p as S}from"./chunk-TKWEX4FD.mjs";import f from"node:path";import{attr as P,hasClass as z,walk as D}from"../browser/shared/html-tree.mjs";import{projectRoot as F,sdkDirectory as O,typeRoots as Y}from"../browser/shared/paths.mjs";var H=new Set(["application/ecmascript","application/javascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript"]);function y(t,{diffs:s=!1,tree:r=g(t)}={}){let n=[];return D(r,a=>{if(a.tagName!=="script"||P(a,"src")!==void 0)return;let o=(P(a,"type")||"").trim().toLowerCase(),l=s&&o==="application/json"&&a.parentNode?.tagName?a.parentNode:null,e=l&&z(l,"doc-diff")?"__declaredDiff(":void 0;if(!e&&o&&o!=="module"&&!H.has(o))return;let{startTag:c,endTag:p}=a.sourceCodeLocation??{};c&&n.push({start:c.endOffset,end:p?.startOffset??t.length,module:o==="module",...e?{call:e}:{}})},{inTemplates:!1}),n}function L(t,s,r=[]){let n=[],a=0,o="",l=e=>e.replace(/[^\r\n]/g," ");for(let{start:e,end:c,call:p}of s){let u=o+l(t.slice(a+o.length,e));if(p){let h=V(u,p,o.length);if(h===null){r.push(e);continue}u=h}n.push(u,t.slice(e,c)),a=c,o=p?");":""}return n.push(o+l(t.slice(a+o.length)),`
3
- export {};
4
- `),n.join("")}function V(t,s,r){let n=t.length;for(;;){let a=Math.max(t.lastIndexOf(`
5
- `,n-1)+1,r),o=t[n-1]==="\r"?n-1:n;if(o-a>=s.length)return t.slice(0,o-s.length)+s+t.slice(o);if(a<=r)return null;n=a-1}}function Pt(t,s=g(t)){return L(t,y(t,{tree:s}))}var q=new Set(["href","src","action","formaction"]),X=t=>{try{return decodeURIComponent(t)}catch{return t}};function Z(t,s){let r=y(t,{tree:s}).map(({start:n,end:a})=>({code:t.slice(n,a),start:n,where:"the document's script"}));return D(s,n=>{for(let{name:a,value:o}of n.attrs){let l=n.sourceCodeLocation?.attrs?.[a]?.startLine??n.sourceCodeLocation?.startLine,e=q.has(a)?o.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""):"";/^on[a-z]+$/.test(a)?r.push({code:o,line:l,where:`the ${a} attribute of <${n.tagName}>`}):/^javascript:/i.test(e)&&r.push({code:X(e.slice(11)),line:l,where:`the javascript: address of <${n.tagName} ${a}>`})}},{inTemplates:!1}),r}var R=new Set(["fetch","XMLHttpRequest","WebSocket","EventSource","sendBeacon","import"]),E=new Set(["window","globalThis","self"]),Q=t=>i.isIdentifier(t)?t.text==="navigator":i.isPropertyAccessExpression(t)&&t.name.text==="navigator"&&i.isIdentifier(t.expression)&&E.has(t.expression.text);function I(t){let{initializer:s}=i.walkUpBindingElementsAndPatterns(t);return!!s&&i.isIdentifier(s)&&E.has(s.text)}function tt(t){let s=t.parent;return i.isPropertyAccessExpression(s)&&s.name===t?i.isIdentifier(s.expression)&&E.has(s.expression.text):i.isBindingElement(s)&&s.propertyName===t?I(s):!((i.isPropertyAssignment(s)||i.isMethodDeclaration(s)||i.isPropertyDeclaration(s)||i.isGetAccessorDeclaration(s)||i.isSetAccessorDeclaration(s))&&s.name===t)}function et(t,s){return i.isIdentifier(t)&&s.has(t.text)&&tt(t)?{name:t.text,reference:i.isPropertyAccessExpression(t.parent)&&t.parent.name===t?t.parent:t}:i.isElementAccessExpression(t)&&i.isIdentifier(t.expression)&&E.has(t.expression.text)&&i.isStringLiteralLike(t.argumentExpression)&&s.has(t.argumentExpression.text)?{name:t.argumentExpression.text,reference:t}:i.isPropertyAccessExpression(t)&&s.has(t.name.text)&&t.name.text==="sendBeacon"&&Q(t.expression)?{name:"sendBeacon",reference:t}:s.has("import")&&i.isCallExpression(t)&&t.expression.kind===i.SyntaxKind.ImportKeyword?{name:"import",reference:t.expression}:null}function st(t,s){let r=new Map,n=(e,c)=>{let p=e.parent;for(;p&&!c(p);)p=p.parent;return p??t},a=e=>i.isFunctionLike(e)||i.isBlock(e)||i.isCaseBlock(e)||i.isForStatement(e)||i.isForInStatement(e)||i.isForOfStatement(e),o=e=>i.isFunctionExpression(e)||i.isClassExpression(e)?e:i.isFunctionDeclaration(e)||i.isClassDeclaration(e)?n(e,a):i.isCatchClause(e.parent)?e.parent:n(e,i.getCombinedNodeFlags(e)&i.NodeFlags.BlockScoped?a:i.isFunctionLike),l=e=>{(i.isParameter(e)||i.isVariableDeclaration(e)||i.isBindingElement(e)||i.isFunctionDeclaration(e)||i.isClassDeclaration(e)||i.isFunctionExpression(e)||i.isClassExpression(e))&&e.name&&i.isIdentifier(e.name)&&s.has(e.name.text)&&!(i.isBindingElement(e)&&I(e))&&r.set(e.name.text,[...r.get(e.name.text)??[],o(e)]),i.forEachChild(e,l)};return l(t),r}function rt(t,s=[]){for(let r=t;r;r=r.parent)if(s.includes(r))return!0;return!1}function Nt(t,s,{tree:r=g(t)}={}){let n=[];for(let{code:a,start:o,line:l,where:e}of Z(t,r))for(let{name:c,how:p,at:u}of k(a,s))n.push({name:c,how:p,line:l??w(t,o+u),where:e});return n.sort((a,o)=>a.line-o.line)}function k(t,s){if(![...s].some(l=>t.includes(l)))return[];let r=[],n=i.createSourceFile("code.js",t,i.ScriptTarget.Latest,!0,i.ScriptKind.JS),a=st(n,s),o=l=>{let e=et(l,s),c=e?.reference.parent;if(e&&!i.isTypeOfExpression(c)&&!(i.isIdentifier(e.reference)&&rt(l,a.get(e.name)))){let p=(i.isCallExpression(c)||i.isNewExpression(c))&&c.expression===e.reference?i.isNewExpression(c)?"new":"call":"use";r.push({name:e.name,how:p,at:l.getStart(n)})}i.forEachChild(l,o)};return o(n),r}var nt=new Set([2304,2552]),it=new Set([2300,2451,2448,2449,2450]),M=t=>nt.has(t)||it.has(t)||t>=1e3&&t<2e3;function at(t,s,r){if(!t.file||r.has(t)||M(t.code))return!1;let n=t.start??-1;return s.some(a=>!a.call&&a.start<=n&&n<a.end)}var ot=(t,s)=>/\bNumberValue\b/.test(t)||/\bd3\.(?:min|max|extent)\(/.test(s)?"; here d3 reads values of no type as strings: give the data its shape once with JSDoc, /** @type {Array<{ label: string, value: number }>} */ const rows = data;, and d3.min or d3.max may give undefined (?? 0)":"";function B(t){let s={allowJs:!0,checkJs:!0,noEmit:!0,allowUmdGlobalAccess:!0,strict:!0,noImplicitAny:!1,target:i.ScriptTarget.ES2022,module:i.ModuleKind.ESNext,moduleResolution:i.ModuleResolutionKind.Bundler,lib:["lib.es2022.d.ts","lib.dom.d.ts","lib.dom.iterable.d.ts"],types:["d3"],typeRoots:Y,skipLibCheck:!1},r=i.createCompilerHost(s),n=r.readFile.bind(r),a=r.fileExists.bind(r);return r.readFile=o=>t.get(f.resolve(o))??n(o),r.fileExists=o=>t.has(f.resolve(o))||a(o),i.createProgram([f.join(O,"index.d.ts"),...t.keys()],s,r)}var ct=/\bDoc[A-Z]\w*/,lt=(t,s)=>ct.test(s)||(t.relatedInformation??[]).some(({file:r})=>r&&f.resolve(r.fileName).startsWith(O+f.sep)),N={katex:"katex","katex-auto-render":"renderMathInElement"};function Dt(t,{assets:s=[]}={}){let r=f.join(F,"reports","__package__","kit.js"),n=t.replace(/^([ \t]*)(?:<!--|-->)/gm,"$1//"),a=s.filter(c=>Object.hasOwn(N,c)).map(c=>`declare const ${N[c]}: any;
6
- `),o=B(new Map([[r,`${n}
7
- export {};
8
- `],...a.length?[[f.join(f.dirname(r),"assets.d.ts"),a.join("")]]:[]])),l=new Set(o.getSyntacticDiagnostics()),e=new Map;for(let c of i.getPreEmitDiagnostics(o)){if(!c.file||f.resolve(c.file.fileName)!==r)continue;let{line:p}=c.file.getLineAndCharacterOfPosition(c.start??0),u=i.flattenDiagnosticMessageText(c.messageText," "),h=`${p} ${u}`;e.has(h)||e.set(h,{line:p+1,code:c.code,message:u,refused:l.has(c)||M(c.code)||lt(c,u)})}return[...e.values()]}function Ft(t){let s=new Map,r=new Map,n=new Map,a=[];for(let e of t){let c=y(e.html,{diffs:!0}),p=[c.filter(m=>!m.module),...c.filter(m=>m.module).map(m=>[m])],u=f.join(F,"reports",f.basename(f.dirname(e.htmlPath)),f.basename(e.htmlPath)),h=[];p.forEach((m,x)=>{let d=`${u}.${x}.js`;s.set(d,L(e.html,m,h)),r.set(d,f.resolve(e.htmlPath)),n.set(d,m)});for(let m of h){let x=e.html.slice(0,m).split(`
9
- `),d=f.resolve(e.htmlPath);a.push({htmlPath:f.resolve(e.htmlPath),text:`${d}:${x.length}:${x.at(-1).length+1} a declared diff's options could not be checked: write its <script type="application/json"> tag on a line of its own`})}}let o=B(s),l=new Set(o.getSyntacticDiagnostics());return[...a,...i.getPreEmitDiagnostics(o).map(e=>{let c=e.file?.getLineAndCharacterOfPosition(e.start||0),p=e.file?r.get(f.resolve(e.file.fileName))??null:null,u=p||e.file?.fileName,h=u?f.resolve(u):"SDK",m=i.flattenDiagnosticMessageText(e.messageText," "),x=p!==null&&at(e,n.get(f.resolve(e.file.fileName))??[],l);return{htmlPath:p,text:`${h}${c?`:${c.line+1}:${c.character+1}`:""} TS${e.code}: ${m}`,typeOnly:x,...x?{note:`line ${c.line+1}: TS${e.code} in the document's script (column ${c.character+1}): ${m} (strict TypeScript's word on a type: a note, not a failure; the browser runs the script as written: guard the value where it can really be null or of another type${ot(m,e.file.text.split(`
10
- `)[c.line]??"")})`}:{}}})]}import{readFileSync as _}from"node:fs";import{BODY as pt,isInstance as ft}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as K,PACKAGE_MARK as $}from"../browser/shared/components/installed.mjs";import{cssReferences as G,cssWithAddresses as ut}from"../browser/shared/css-references.mjs";import{packageScript as mt,scriptText as ht,styleText as xt}from"../browser/shared/export-wrap.mjs";import{attr as b,walk as U}from"../browser/shared/html-tree.mjs";import{mediaTypeOf as gt}from"../browser/shared/media.mjs";var dt=new RegExp(K,"i");function zt(t,{packages:s}=j(),r=null){if(!dt.test(t))return[];let n=new Set;return U(r??g(t),a=>{ft(a)&&n.add(b(a,K))},pt),[...n].map(a=>s.get(a)).filter(Boolean)}function Yt(t,s){if(s.length===0)return t;let r=s.map(A);return C(t,{styles:r.flatMap(({styles:n})=>n),scripts:r.flatMap(({scripts:n})=>n)})}function T(t,s){try{return _(S(t,s)).toString("utf8").replace(/^\uFEFF/,"")}catch{return null}}var W=/^(?:data:|#|$)/i,wt=/^(?:[a-z][a-z0-9+.-]*:|\/)/i,J=t=>t.replace(/^\.\//,"").replace(/[?#].*$/,""),Et=(t,s)=>ut(s,G(s),({value:r,kind:n})=>{let a=J(r);if(n==="import"||W.test(r)||!t.files.includes(a))return null;let o=S(t,a);return o&&`data:${gt(a)};base64,${_(o).toString("base64")}`}),v=new Set(["eval","Function"]),St=new Set([...R,...v]),yt={call:t=>`calls ${t}(\u2026)`,new:t=>`creates new ${t}(\u2026)`,use:t=>`uses ${t}`};function kt(t){if(!t.files.includes("style.css"))return[];let s=T(t,"style.css")??"";return G(s).flatMap(({value:r,kind:n,index:a})=>{let o=n==="import"?"has an @import, which an export cannot hold: write what it imports into style.css":W.test(r)?null:wt.test(r)?`loads ${r}: external resources are not portable`:t.files.includes(J(r))?null:`names ${r}, which an export cannot hold: put the file in the package and name it in its assets`;return o?[{line:w(s,a),what:o}]:[]})}function $t(t){if(!t.files.includes("kit.js"))return[];let s=T(t,"kit.js")??"";return k(s,St).filter(({name:r,how:n})=>n!=="use"||!v.has(r)).map(({name:r,how:n,at:a})=>({line:w(s,a),what:`${yt[n](r)}: ${v.has(r)?"an export runs no code made from words":"the export blocks the network; put its data in the instance"}`}))}var Ht=t=>t.flatMap(s=>[...kt(s).map(({what:r})=>`${s.id}: its style.css ${r}`),...$t(s).map(({line:r,what:n})=>`${s.id}: line ${r} of its kit.js ${n}`)]);function bt(t,s){let r=`${$}="${t.id}"`,n=T(t,s);return n===null?null:s==="kit.js"?`<script ${r}>${ht(mt(n))}</script>`:`<style ${r}>${xt(Et(t,n))}</style>`}function Vt(t,{packages:s}){if(!t.includes($))return t;let r=[];U(g(t),o=>{let l=s.get(b(o,$)),e=o.tagName==="link"?"style.css":o.tagName==="script"&&b(o,"src")!==void 0?"kit.js":null,c=o.sourceCodeLocation,p=l&&e&&c?bt(l,e):null;p&&r.push({start:c.startOffset,end:c.endOffset,copy:p})},{inTemplates:!1});let n="",a=0;for(let{start:o,end:l,copy:e}of r)n+=t.slice(a,o)+e,a=l;return n+t.slice(a)}export{Pt as a,R as b,Nt as c,k as d,Dt as e,Ft as f,zt as g,Yt as h,T as i,kt as j,$t as k,Ht as l,Vt as m};