@heycys/gallery 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/browser/editor/components/align.mjs +58 -0
- package/browser/editor/components/code/index.mjs +1 -1
- package/browser/editor/components/embed/page.mjs +1 -1
- package/browser/editor/components/file/page.mjs +4 -4
- package/browser/editor/components/heading/index.mjs +7 -6
- package/browser/editor/components/icons.mjs +3 -0
- package/browser/editor/components/image/index.mjs +2 -0
- package/browser/editor/components/image/page.mjs +172 -90
- package/browser/editor/components/installed/index.mjs +6 -2
- package/browser/editor/components/installed/page.mjs +80 -13
- package/browser/editor/components/media/icons.mjs +13 -8
- package/browser/editor/components/media/page.mjs +5 -3
- package/browser/editor/components/media/toolbar.mjs +12 -3
- package/browser/editor/components/paragraph/index.mjs +4 -3
- package/browser/editor/components/registry.mjs +17 -5
- package/browser/editor/components/table/index.mjs +4 -2
- package/browser/editor/page/after/index.mjs +288 -0
- package/browser/editor/page/align.mjs +91 -0
- package/browser/editor/page/beside.mjs +5 -6
- package/browser/editor/page/block-menu/index.mjs +6 -3
- package/browser/editor/page/blocks.mjs +3 -1
- package/browser/editor/page/board/hint.mjs +64 -27
- package/browser/editor/page/board/index.mjs +160 -71
- package/browser/editor/page/board/motion.mjs +177 -0
- package/browser/editor/page/board/settings.mjs +4 -3
- package/browser/editor/page/clipboard/index.mjs +10 -3
- package/browser/editor/page/clipboard/own/blocks.mjs +3 -4
- package/browser/editor/page/clipboard/own/describe.mjs +6 -2
- package/browser/editor/page/commit.mjs +2 -2
- package/browser/editor/page/core.mjs +3 -1
- package/browser/editor/page/custom-page.mjs +15 -11
- package/browser/editor/page/editor.mjs +31 -14
- package/browser/editor/page/history.mjs +19 -4
- package/browser/editor/page/insert/index.mjs +20 -22
- package/browser/editor/page/menu.mjs +15 -7
- package/browser/editor/page/page-objects.mjs +3 -7
- package/browser/editor/page/present-links.mjs +5 -4
- package/browser/editor/page/present-shell.mjs +63 -0
- package/browser/editor/page/selection/index.mjs +10 -2
- package/browser/editor/page/table/binding.mjs +87 -0
- package/browser/editor/page/table/icons.mjs +0 -2
- package/browser/editor/page/table/index.mjs +10 -14
- package/browser/editor/page/table/views.mjs +5 -52
- package/browser/editor/page/table/widths.mjs +82 -10
- package/browser/editor/page/typing/index.mjs +44 -12
- package/browser/editor/page/typing/leave.mjs +19 -5
- package/browser/shared/block-packs.mjs +23 -8
- package/browser/shared/component-catalog.mjs +15 -8
- package/browser/shared/component-source.mjs +3 -1
- package/browser/shared/components/heading.mjs +2 -1
- package/browser/shared/components/installed.mjs +1 -1
- package/browser/shared/components/page.mjs +2 -0
- package/browser/shared/components/paragraph.mjs +8 -1
- package/browser/shared/components/table.mjs +1 -0
- package/browser/shared/emoji/line-icons.mjs +37 -0
- package/browser/shared/http.mjs +9 -0
- package/browser/shared/i18n/en.mjs +40 -17
- package/browser/shared/outline.mjs +30 -2
- package/browser/shared/pack-manifest.mjs +12 -1
- package/browser/shared/pages.mjs +169 -57
- package/browser/shared/pinyin.mjs +92 -0
- package/browser/shared/present-step.mjs +17 -0
- package/browser/shared/sidebar-head.mjs +70 -0
- package/browser/shared/web-links.mjs +5 -0
- package/dist/chunk-2OHANJ6Q.mjs +2 -0
- package/dist/{chunk-QOUEFUCH.mjs → chunk-3MBRL2PM.mjs} +1 -1
- package/dist/{chunk-NWR2LT5B.mjs → chunk-4OKWZY5E.mjs} +1 -1
- package/dist/{chunk-RMECZA2K.mjs → chunk-5K44HLTZ.mjs} +1 -1
- package/dist/{chunk-NFMCP2HI.mjs → chunk-5XA2ZBAE.mjs} +2 -2
- package/dist/{chunk-OUUP3WKT.mjs → chunk-67N2QJYT.mjs} +1 -1
- package/dist/chunk-6KBYRA2C.mjs +2 -0
- package/dist/{chunk-SX4LJYT6.mjs → chunk-6N3PX4XX.mjs} +1 -1
- package/dist/{chunk-RFDZXFJF.mjs → chunk-7JDX4E65.mjs} +1 -1
- package/dist/chunk-7M2BQQGZ.mjs +2 -0
- package/dist/{chunk-ZUNVAXLH.mjs → chunk-7OG26PGF.mjs} +1 -1
- package/dist/{chunk-B4P2CM2J.mjs → chunk-AHN3NFKJ.mjs} +1 -1
- package/dist/chunk-ALZ6ZENZ.mjs +3 -0
- package/dist/{chunk-UGWYKHBL.mjs → chunk-AR5D57ZD.mjs} +2 -2
- package/dist/{chunk-W3BGBJQW.mjs → chunk-BFJGHSQN.mjs} +1 -1
- package/dist/{chunk-HLYV7RIH.mjs → chunk-CMA72MAG.mjs} +1 -1
- package/dist/{chunk-D4CKRD3V.mjs → chunk-DAZL73VK.mjs} +2 -2
- package/dist/{chunk-6VTU6KEO.mjs → chunk-DJISHPUL.mjs} +1 -1
- package/dist/{chunk-BPL64HGA.mjs → chunk-EAIFITAV.mjs} +1 -1
- package/dist/chunk-EP25HDAJ.mjs +2 -0
- package/dist/{chunk-6EZ7FNIK.mjs → chunk-F4ZA6JRZ.mjs} +1 -1
- package/dist/{chunk-3KJHLHUO.mjs → chunk-F6HVDZR4.mjs} +1 -1
- package/dist/{chunk-3NJACR4W.mjs → chunk-FDMAXMQA.mjs} +1 -1
- package/dist/chunk-FETSREUN.mjs +5 -0
- package/dist/{chunk-RKPWLGZ3.mjs → chunk-GHOYKMQ3.mjs} +1 -1
- package/dist/chunk-HDWTZ763.mjs +12 -0
- package/dist/{chunk-VTKNEYT3.mjs → chunk-HPOI4ZX7.mjs} +1 -1
- package/dist/{chunk-OW5NWPOJ.mjs → chunk-HXG7EOPJ.mjs} +1 -1
- package/dist/{chunk-V6RIYQZZ.mjs → chunk-ITOH5EGO.mjs} +1 -1
- package/dist/{chunk-ZWPMCK7P.mjs → chunk-IV64FFI4.mjs} +1 -1
- package/dist/chunk-J43Z6LSS.mjs +2 -0
- package/dist/chunk-J5PUIV3Y.mjs +4 -0
- package/dist/{chunk-KTKHRC6H.mjs → chunk-JA7G53PC.mjs} +1 -1
- package/dist/{chunk-NWFBE2YA.mjs → chunk-JLTZF4LA.mjs} +1 -1
- package/dist/{chunk-GY3FAUVM.mjs → chunk-JZT7I2OJ.mjs} +1 -1
- package/dist/{chunk-QKXMPUXC.mjs → chunk-K5XATEOO.mjs} +1 -1
- package/dist/chunk-L2SUIS5S.mjs +2 -0
- package/dist/{chunk-TEZAWDSQ.mjs → chunk-LM4XFQHZ.mjs} +1 -1
- package/dist/{chunk-5ZJA7CXT.mjs → chunk-MN7BZL4R.mjs} +1 -1
- package/dist/chunk-MTYYHM2G.mjs +15 -0
- package/dist/{chunk-HMYTM3GT.mjs → chunk-MXUBKDRO.mjs} +1 -1
- package/dist/{chunk-MHW7ZKOU.mjs → chunk-OEXWRJME.mjs} +1 -1
- package/dist/{chunk-CRJEG7MT.mjs → chunk-OFHXGWOX.mjs} +1 -1
- package/dist/chunk-ORID3AE7.mjs +166 -0
- package/dist/{chunk-32ZUEFZ7.mjs → chunk-PGDE24N5.mjs} +1 -1
- package/dist/{chunk-UNOYVIYR.mjs → chunk-POTA2FV4.mjs} +1 -1
- package/dist/{chunk-N7AZZLGT.mjs → chunk-QE5RG76S.mjs} +18 -17
- package/dist/{chunk-N76HWBA3.mjs → chunk-R2ZDLJYT.mjs} +1 -1
- package/dist/chunk-SWUTTZCN.mjs +2 -0
- package/dist/{chunk-POQSE4C2.mjs → chunk-TR7TWGHB.mjs} +1 -1
- package/dist/chunk-U5XL7D6A.mjs +3 -0
- package/dist/{chunk-PVER7LSC.mjs → chunk-U7NZI6N4.mjs} +2 -2
- package/dist/{chunk-Q47PLKIJ.mjs → chunk-UGWMMEJ5.mjs} +1 -1
- package/dist/chunk-UJQJKNGK.mjs +2 -0
- package/dist/chunk-UYVCQK3H.mjs +22 -0
- package/dist/{chunk-FJYN7RTH.mjs → chunk-VFX2KNHP.mjs} +1 -1
- package/dist/{chunk-UBBRTJ2R.mjs → chunk-VS7JIGJW.mjs} +1 -1
- package/dist/{chunk-NVRNLK25.mjs → chunk-W7665ZEC.mjs} +2 -2
- package/dist/{chunk-NG375ILQ.mjs → chunk-WQDQWCX5.mjs} +1 -1
- package/dist/chunk-YLPSMDIS.mjs +5 -0
- package/dist/{chunk-VXACTLO3.mjs → chunk-YNAWBAYN.mjs} +1 -1
- package/dist/{chunk-ZB4H7ZN4.mjs → chunk-YROX2O22.mjs} +1 -1
- package/dist/{chunk-YQGT4AB2.mjs → chunk-ZDLPUOAG.mjs} +1 -1
- package/dist/chunk-ZQS6H473.mjs +16 -0
- package/dist/{chunk-OJKMINIU.mjs → chunk-ZWWC4KLF.mjs} +15 -15
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/worker.mjs +1 -1
- package/kit/board.css +5 -5
- package/kit/code.js +15 -15
- package/kit/report.css +120 -41
- package/kit/runtime.js +45 -7
- package/kit/tables.js +2 -0
- package/kit/ui.js +2 -0
- package/package.json +1 -1
- package/packs/gallery/chart-view/kit.js +3 -3
- package/packs/gallery/chart-view/writing.md +1 -1
- package/packs/gallery/countdown/component.json +1 -1
- package/packs/gallery/countdown/kit.js +89 -29
- package/packs/gallery/countdown/preview.svg +1 -1
- package/packs/gallery/countdown/style.css +88 -100
- package/packs/gallery/countdown/writing.md +2 -2
- package/packs/gallery/habit/component.json +3 -3
- package/packs/gallery/habit/kit.js +114 -75
- package/packs/gallery/habit/preview.svg +1 -1
- package/packs/gallery/habit/style.css +133 -205
- package/packs/gallery/habit/writing.md +2 -2
- package/packs/gallery/heatmap/component.json +2 -2
- package/packs/gallery/heatmap/kit.js +335 -173
- package/packs/gallery/heatmap/preview.svg +1 -1
- package/packs/gallery/heatmap/style.css +158 -170
- package/packs/gallery/heatmap/writing.md +2 -2
- package/packs/gallery/kanban/kit.js +3 -3
- package/packs/gallery/kanban/writing.md +1 -1
- package/packs/gallery/metric/kit.js +3 -3
- package/packs/gallery/metric/writing.md +1 -1
- package/packs/gallery/note/component.json +3 -3
- package/packs/gallery/note/kit.js +40 -13
- package/packs/gallery/note/preview.svg +1 -1
- package/packs/gallery/note/style.css +51 -30
- package/packs/gallery/note/writing.md +2 -2
- package/packs/gallery/recent/component.json +2 -2
- package/packs/gallery/recent/kit.js +141 -86
- package/packs/gallery/recent/preview.svg +1 -1
- package/packs/gallery/recent/style.css +53 -126
- package/packs/gallery/recent/writing.md +2 -2
- package/packs/gallery/static/component.json +2 -2
- package/packs/gallery/static/preview.svg +1 -1
- package/packs/gallery/static/style.css +99 -66
- package/packs/gallery/static/writing.md +2 -2
- package/packs/gallery/stats/component.json +3 -3
- package/packs/gallery/stats/kit.js +253 -72
- package/packs/gallery/stats/preview.svg +1 -1
- package/packs/gallery/stats/style.css +64 -142
- package/packs/gallery/stats/writing.md +2 -2
- package/packs/gallery/today/component.json +2 -2
- package/packs/gallery/today/kit.js +62 -27
- package/packs/gallery/today/preview.svg +1 -1
- package/packs/gallery/today/style.css +101 -72
- package/packs/gallery/today/writing.md +2 -2
- package/packs/gallery/todos/component.json +1 -1
- package/packs/gallery/todos/kit.js +218 -71
- package/packs/gallery/todos/preview.svg +1 -1
- package/packs/gallery/todos/style.css +170 -223
- package/packs/gallery/todos/writing.md +1 -1
- package/packs/gallery/weather/component.json +2 -2
- package/packs/gallery/weather/kit.js +165 -90
- package/packs/gallery/weather/preview.svg +1 -1
- package/packs/gallery/weather/style.css +100 -218
- package/packs/gallery/weather/writing.md +1 -1
- package/packs/gallery-soft/countdown/component.json +18 -0
- package/packs/gallery-soft/countdown/example.html +3 -0
- package/packs/gallery-soft/countdown/kit.js +206 -0
- package/packs/gallery-soft/countdown/preview.svg +1 -0
- package/packs/gallery-soft/countdown/style.css +211 -0
- package/packs/gallery-soft/countdown/template.html +3 -0
- package/packs/gallery-soft/countdown/writing.md +24 -0
- package/packs/gallery-soft/habit/component.json +14 -0
- package/packs/gallery-soft/habit/example.html +3 -0
- package/packs/gallery-soft/habit/kit.js +366 -0
- package/packs/gallery-soft/habit/preview.svg +1 -0
- package/packs/gallery-soft/habit/style.css +251 -0
- package/packs/gallery-soft/habit/template.html +3 -0
- package/packs/gallery-soft/habit/writing.md +23 -0
- package/packs/gallery-soft/heatmap/component.json +18 -0
- package/packs/gallery-soft/heatmap/example.html +3 -0
- package/packs/gallery-soft/heatmap/kit.js +498 -0
- package/packs/gallery-soft/heatmap/preview.svg +1 -0
- package/packs/gallery-soft/heatmap/style.css +181 -0
- package/packs/gallery-soft/heatmap/template.html +3 -0
- package/packs/gallery-soft/heatmap/writing.md +23 -0
- package/packs/gallery-soft/note/component.json +14 -0
- package/packs/gallery-soft/note/example.html +3 -0
- package/packs/gallery-soft/note/kit.js +162 -0
- package/packs/gallery-soft/note/preview.svg +1 -0
- package/packs/gallery-soft/note/style.css +148 -0
- package/packs/gallery-soft/note/template.html +3 -0
- package/packs/gallery-soft/note/writing.md +20 -0
- package/packs/gallery-soft/recent/component.json +13 -0
- package/packs/gallery-soft/recent/example.html +1 -0
- package/packs/gallery-soft/recent/kit.js +335 -0
- package/packs/gallery-soft/recent/preview.svg +1 -0
- package/packs/gallery-soft/recent/style.css +160 -0
- package/packs/gallery-soft/recent/template.html +1 -0
- package/packs/gallery-soft/recent/writing.md +17 -0
- package/packs/gallery-soft/static/component.json +13 -0
- package/packs/gallery-soft/static/example.html +12 -0
- package/packs/gallery-soft/static/preview.svg +1 -0
- package/packs/gallery-soft/static/style.css +186 -0
- package/packs/gallery-soft/static/template.html +1 -0
- package/packs/gallery-soft/static/writing.md +20 -0
- package/packs/gallery-soft/stats/component.json +13 -0
- package/packs/gallery-soft/stats/example.html +1 -0
- package/packs/gallery-soft/stats/kit.js +341 -0
- package/packs/gallery-soft/stats/preview.svg +1 -0
- package/packs/gallery-soft/stats/style.css +119 -0
- package/packs/gallery-soft/stats/template.html +1 -0
- package/packs/gallery-soft/stats/writing.md +13 -0
- package/packs/gallery-soft/today/component.json +12 -0
- package/packs/gallery-soft/today/example.html +1 -0
- package/packs/gallery-soft/today/kit.js +222 -0
- package/packs/gallery-soft/today/preview.svg +1 -0
- package/packs/gallery-soft/today/style.css +178 -0
- package/packs/gallery-soft/today/template.html +1 -0
- package/packs/gallery-soft/today/writing.md +16 -0
- package/packs/gallery-soft/todos/component.json +19 -0
- package/packs/gallery-soft/todos/example.html +3 -0
- package/packs/gallery-soft/todos/kit.js +527 -0
- package/packs/gallery-soft/todos/preview.svg +1 -0
- package/packs/gallery-soft/todos/style.css +212 -0
- package/packs/gallery-soft/todos/template.html +3 -0
- package/packs/gallery-soft/todos/writing.md +32 -0
- package/packs/gallery-soft/weather/component.json +19 -0
- package/packs/gallery-soft/weather/example.html +3 -0
- package/packs/gallery-soft/weather/kit.js +411 -0
- package/packs/gallery-soft/weather/preview.svg +1 -0
- package/packs/gallery-soft/weather/style.css +185 -0
- package/packs/gallery-soft/weather/template.html +3 -0
- package/packs/gallery-soft/weather/writing.md +28 -0
- package/release.json +9 -9
- package/skill/SKILL.md +12 -12
- package/skill/references/building-blocks.md +4 -4
- package/skill/references/pages-and-data.md +13 -9
- package/skill/references/writing-html.md +2 -0
- package/web/assets/index-BM_K-Auu.css +1 -0
- package/web/assets/index-DRslOBiv.js +15 -0
- package/web/index.html +2 -2
- package/dist/chunk-2NRBY6AJ.mjs +0 -2
- package/dist/chunk-35NQ4PLQ.mjs +0 -2
- package/dist/chunk-4AV456RQ.mjs +0 -2
- package/dist/chunk-5XYHDBJ5.mjs +0 -2
- package/dist/chunk-6A53MZYZ.mjs +0 -2
- package/dist/chunk-6EXH3ORZ.mjs +0 -166
- package/dist/chunk-BVEFGE4B.mjs +0 -2
- package/dist/chunk-D4EURAX4.mjs +0 -4
- package/dist/chunk-DQCE7TJY.mjs +0 -5
- package/dist/chunk-FWNRPMCJ.mjs +0 -12
- package/dist/chunk-FWW4CSAZ.mjs +0 -2
- package/dist/chunk-JVHHHGEA.mjs +0 -3
- package/dist/chunk-PZDLJJTJ.mjs +0 -3
- package/dist/chunk-SXHBYZST.mjs +0 -16
- package/dist/chunk-UFNYFFKO.mjs +0 -20
- package/dist/chunk-UKSHDZZ6.mjs +0 -2
- package/dist/chunk-VJPFVNNW.mjs +0 -15
- package/dist/chunk-VS3ZMVGX.mjs +0 -5
- package/web/assets/index-BK2e_07w.js +0 -13
- package/web/assets/index-CWFI83mF.css +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-AR5D57ZD.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-7OG26PGF.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-QE5RG76S.mjs";import"./chunk-J5PUIV3Y.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{g as GESTURES,d as addName,b as blockNamed,i as keyOf,f as missingSaid,c as packageFolder,a as packageNamed,h as pairsOf,j as run,e as shallowSaid};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as y,b as C}from"./chunk-Q4UEPUWF.mjs";import{a as A}from"./chunk-
|
|
2
|
+
import{a as y,b as C}from"./chunk-Q4UEPUWF.mjs";import{a as A}from"./chunk-IV64FFI4.mjs";import{c as P,d as W}from"./chunk-GHOYKMQ3.mjs";import"./chunk-QE5RG76S.mjs";import"./chunk-UYVCQK3H.mjs";import"./chunk-J5PUIV3Y.mjs";import{b as j,f as M}from"./chunk-4OZWXZE5.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{randomBytes as R}from"node:crypto";import{existsSync as X,readdirSync as G,readFileSync as Y,statSync as _}from"node:fs";import c from"node:fs/promises";import q from"node:os";import i from"node:path";import{release as J,reportsDirectory as V,skillDirectory as H}from"../browser/shared/paths.mjs";import{copyOldDocuments as Q,ensureWorkspace as Z,layoutOf as z,oldStateOf as K}from"../browser/shared/workspace.mjs";var S=o=>_(o,{throwIfNoEntry:!1})?.isDirectory()??!1;function ee({agent:o=null,project:e=!1,dir:r=null,cwd:t=process.cwd(),env:s=process.env}={}){if(r)return[{agent:null,target:i.resolve(t,r),skills:null}];let a=o?[o]:Object.keys(y),u=d=>e?i.join(i.resolve(t),y[d].project):i.resolve(y[d].home(s)),p=a.filter(d=>S(u(d)));return(o||p.length?o?a:p:["claude"]).map(d=>{let h=i.join(u(d),"skills");return{agent:d,target:i.join(h,"gallery"),skills:h}})}function te(o){try{return C(Y(i.join(o,"SKILL.md"),"utf8"))}catch{return null}}function T(o){let e=_(o,{throwIfNoEntry:!1});if(!e)return{kind:"absent"};if(!e.isDirectory())return{kind:"other",why:"it is a file"};let r=G(o);if(r.length===0)return{kind:"absent"};if(r.includes(".git"))return{kind:"other",why:"it is a git checkout"};let t=te(o),s=u=>r.includes(u);return(s("package.json")&&s("src")||s("reports"))&&(t==="gallery"||t==="html-report-studio")?{kind:"fat",name:t}:t==="gallery"&&!s("package.json")&&!s("src")&&!s("reports")?{kind:"thin"}:{kind:"other",why:t?`its SKILL.md is the skill "${t}"`:"it holds no Gallery skill"}}function oe(o){return S(o)?G(o,{withFileTypes:!0}).filter(e=>e.isDirectory()&&!e.name.startsWith(".")).map(e=>i.join(o,e.name)).filter(e=>T(e).kind==="fat"):[]}function re(o){let e=i.join(K(o),"servers");return S(e)?G(e).filter(r=>r.endsWith(".json")).flatMap(r=>{try{let{pid:t,port:s}=JSON.parse(Y(i.join(e,r),"utf8"));return!Number.isInteger(t)||t<=0||t===process.pid?[]:(process.kill(t,0),[{pid:t,port:s}])}catch(t){return t.code==="EPERM"?[{pid:Number.NaN,port:null}]:[]}}):[]}async function O(o){let e=0,r=0,t=async s=>{for(let a of await c.readdir(s,{withFileTypes:!0})){let u=i.join(s,a.name);a.isDirectory()?await t(u):(e++,r+=(await c.lstat(u)).size)}};return await t(o).catch(()=>{}),{files:e,bytes:r}}var B=o=>`${(o/1024/1024).toFixed(1)} MB`,se=(o,e)=>`${o} ${e}${o===1?"":"s"}`;async function v(o,e){for(let r=0;;r++)try{return await c.rename(o,e)}catch(t){if(process.platform!=="win32"||r>=10||!["EPERM","EBUSY","EACCES"].includes(t.code))throw t;await new Promise(s=>setTimeout(s,100*(r+1)))}}function ne(o,e=new Date){let r=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,t=i.join(z(o).gallery,`old-skill-${r}`);for(let s=1;;s++){let a=s===1?t:`${t}-${s}`;if(!X(a))return a}}async function ie(o,e){await c.mkdir(i.dirname(e),{recursive:!0});try{return await v(o,e),null}catch(s){if(s.code!=="EXDEV")return`${s.code??s.message}`}let r=await O(o);await c.cp(o,e,{recursive:!0,preserveTimestamps:!0,verbatimSymlinks:!0,errorOnExist:!0,force:!1});let t=await O(e);return t.files!==r.files||t.bytes!==r.bytes?`the copy holds ${t.files} files, ${t.bytes} bytes, of ${r.files}, ${r.bytes}: the old folder was left as it was`:(await c.rm(o,{recursive:!0,force:!0}),null)}async function U(o){let e=[],r=async t=>{for(let s of await c.readdir(t,{withFileTypes:!0})){let a=i.join(t,s.name);s.isDirectory()?await r(a):e.push([i.relative(o,a).split(i.sep).join("/"),await c.readFile(a)])}};return await r(o),e.sort(([t],[s])=>t<s?-1:t>s?1:0)}var le=(o,e)=>o.length===e.length&&o.every(([r,t],s)=>r===e[s][0]&&t.equals(e[s][1]));async function ae(o,e,r){if(r==="thin"&&le(await U(o),await U(e)))return"same";let t=i.dirname(e);await c.mkdir(t,{recursive:!0});let s=R(4).toString("hex"),a=i.join(t,`.gallery-skill-new-${s}`);if(await c.cp(o,a,{recursive:!0}),r==="absent")return X(e)&&await c.rmdir(e),await v(a,e),"new";let u=i.join(t,`.gallery-skill-old-${s}`);await v(e,u);try{await v(a,e)}catch(p){throw await v(u,e).catch(()=>{}),await c.rm(a,{recursive:!0,force:!0}),p}return await c.rm(u,{recursive:!0,force:!0}),"updated"}async function $e(o,{version:e}){let{positional:r,options:t,values:s}=M({options:["--project"],values:["--agent","--dir"],argv:o});if(r[0]!=="install")throw new j(r.length?`No such skill command: ${r[0]} (install).`:"Say what to do: gallery skill install.");if(r.length>1)throw new j(`gallery skill install takes no other argument: ${r[1]}`);let a=s.get("--agent")??null;if(a!==null&&!Object.hasOwn(y,a))throw new j(`--agent is claude or codex, not ${a}.`);let u=s.get("--dir")??null;if(u!==null&&(a!==null||t.has("--project")))throw new j("--dir names the skill's folder itself: not with --agent or --project.");let p=ee({agent:a,project:t.has("--project"),dir:u}),d=[],h=p.map(n=>({...n,...T(n.target)}));for(let{target:n,kind:l,why:f}of h)l==="other"&&d.push(`${n} holds something that is not a Gallery skill (${f}): move it away, or pass --dir <another folder>.`);let N=[...new Set(h.flatMap(({target:n,kind:l,skills:f})=>[...l==="fat"?[n]:[],...f?oe(f):[]]))];for(let n of N)for(let{pid:l,port:f}of re(n))d.push(Number.isNaN(l)?`The older Gallery skill ${n} has a preview server running that this user cannot see: stop it first.`:`The older Gallery skill ${n} has its preview server running (pid ${l}${f?`, port ${f}`:""}): stop it first (close the window that runs it, or end process ${l}), then run gallery skill install again.`);if(d.length){for(let n of d)console.error(n);console.error("Nothing was changed."),process.exit(1)}if(N.length){let n=V;try{let{ours:l,reads:f}=await Z(n);l||(console.error(W(n,f)),process.exit(1))}catch(l){if(!l.code)throw l;console.error(P(n,l.code)),process.exit(1)}console.log(`\u5DE5\u4F5C\u533A\uFF1A${n}`);for(let l of N){console.log(`An older Gallery skill (the whole tools) is in ${l}: its documents go into the workspace, then it moves out of the skills folder.`);let f=i.join(l,"reports");if(S(f)){let m=await Q({from:f,to:n,state:K(l)});for(let w of A(m,f,n))console.log(` ${w}`)}else console.log(" It holds no documents (no reports/ folder).");let g=i.join(l,"exports");if(S(g)){let m=z(n).exports;await c.mkdir(m,{recursive:!0});let w=[],I=[];for(let E of(await c.readdir(g)).filter(x=>x.endsWith(".html")).sort())try{await c.copyFile(i.join(g,E),i.join(m,E),c.constants.COPYFILE_EXCL),w.push(E)}catch(x){if(x.code!=="EEXIST")throw x;I.push(E)}w.length&&console.log(` Exports: copied ${se(w.length,"file")} into ${m}: ${w.join(", ")}`),I.length&&console.log(` Exports not copied (the name is taken in ${m}; they stay in the moved folder's exports/): ${I.join(", ")}`)}let{bytes:k}=await O(l),$=await O(i.join(l,"node_modules")),D=ne(n),L=await ie(l,D);L&&(console.error(`Could not move ${l} to ${D} (${L}). Its documents are copied; move the folder out of the skills folder yourself (it is never needed in it again), then run gallery skill install again.`),process.exit(1)),console.log(` Moved the old skill to ${D} (${B(k)}${$.files?`; its node_modules/, ${B($.bytes)}, may be deleted: nothing reads it any more`:""}).`)}}let F=H,b=null;if(!J){let{buildSkill:n}=await import("./chunk-UGWMMEJ5.mjs");b=await c.mkdtemp(i.join(q.tmpdir(),"gallery-skill-")),F=i.join(b,"gallery"),n(F,{version:e})}try{let n=!1;for(let{agent:l,target:f}of h){let g=T(f).kind,k=await ae(F,f,g),$=l?` for ${y[l].name}`:"";console.log(k==="same"?`The Gallery skill ${e}${$} is installed already, unchanged: ${f}`:`${k==="updated"?"Updated":"Installed"} the Gallery skill ${e}${$}: ${f}`),n||=k!=="same"}n&&console.log("Open a new Agent session to use it.")}finally{b&&await c.rm(b,{recursive:!0,force:!0})}}export{y as AGENTS,T as kindOf,$e as run,ee as targetsOf};
|
|
@@ -394,22 +394,23 @@ Exits 2 for a host no block's needs can name, or a key that is empty or more tha
|
|
|
394
394
|
gallery page try <slug> <card id> --select <selector> <value> [--then <key>] [--keep]
|
|
395
395
|
gallery page try <slug> <card id> --steps <file> [--keep]
|
|
396
396
|
gallery page check <slug>
|
|
397
|
-
A custom page (\u81EA\u5B9A\u4E49\u9875) is a
|
|
398
|
-
|
|
399
|
-
and page.json ({ "title", "icon" }).
|
|
397
|
+
A custom page (\u81EA\u5B9A\u4E49\u9875) is a page the workbench lists in its sidebar with \u65B0\u5EFA and \u641C\u7D22, kept in the
|
|
398
|
+
workspace: pages/<slug>/, page.html (free HTML: its look, its own scripts, and boards of cards, each card
|
|
399
|
+
one custom block's instance, where it has them) and page.json ({ "title", "icon" }). An Agent writes them
|
|
400
|
+
(the user may make a blank one for an Agent to write); the user orders, renames and trashes them.
|
|
400
401
|
Documents and custom pages share one set of slugs: neither takes the other's, nor pages (the folder).
|
|
401
|
-
The home page (\u9996\u9875) is pages/home,
|
|
402
|
+
The home page (\u9996\u9875) is pages/home, a page as any.
|
|
402
403
|
new makes one: page.html with its title (in <title>: a page draws no big title) and one empty board (data-board-id="main"), and
|
|
403
|
-
page.json with the title
|
|
404
|
-
blocks its cards hold. Says where it wrote and what to write next, and with the workspace's server
|
|
404
|
+
page.json with the title; it goes last in the sidebar's head. The server puts in the scripts and styles
|
|
405
|
+
of the blocks its cards hold. Says where it wrote and what to write next, and with the workspace's server
|
|
405
406
|
running ends with the \u4EA4\u7ED9\u7528\u6237 line gallery open has: the page's whole address, to send the user at once
|
|
406
407
|
(without one, gallery page open <slug> --no-browser gives it).
|
|
407
408
|
Exits 1 when the slug is taken (a document's, a page's, the trash's) or kept (exports, components, pages,
|
|
408
|
-
assets, materials\u2026)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
list says the workspace's custom pages in the sidebar's order (
|
|
412
|
-
pages.order, then by title): each one's slug, icon and title, its address (\u5730\u5740\uFF1A, the whole address with
|
|
409
|
+
assets, materials\u2026). Before the server's first start in the workspace makes the default home page (with
|
|
410
|
+
its own cards; gallery open --no-browser starts one), gallery page open, add, try and check of home say
|
|
411
|
+
so in place of "no such page".
|
|
412
|
+
list says the workspace's custom pages in the sidebar's order (the order the user dragged them to, then
|
|
413
|
+
gallery.json's pages.order, then by title): each one's slug, icon and title, its address (\u5730\u5740\uFF1A, the whole address with
|
|
413
414
|
the workspace's server running, else /#@<slug>, after the port of a server) and where its page.html is;
|
|
414
415
|
in a workspace with no page whose home page is not made yet, only that the home page waits for the server.
|
|
415
416
|
open starts this workspace's Gallery server (or uses the one running), as gallery open does, and opens
|
|
@@ -466,17 +467,17 @@ document's alone; 2 a mistake in the command line (a card the page has not, a se
|
|
|
466
467
|
nothing in the instance, a steps file that does not read); 3 when the trial was not seen through
|
|
467
468
|
(UNVERIFIED: no server or browser, a page that loaded itself again).
|
|
468
469
|
check says what is wrong with the page, each problem a FAIL line with its line in page.html, and what
|
|
469
|
-
changed in it. Its structure
|
|
470
|
-
|
|
470
|
+
changed in it. Its structure (a page's own scripts, frames and stylesheets are none of its problems):
|
|
471
|
+
where it has boards or cards, its boards in <main class="gallery-page">, each board's data-board-id and each
|
|
471
472
|
card's data-card-id there, of lowercase letters, digits and hyphens, and once in the page, each card a
|
|
472
473
|
board's child holding one instance, its data-x, data-y, data-w and data-h whole numbers on the board
|
|
473
474
|
(0 <= x, 1 <= w <= 12, x + w <= 12, 0 <= y, 1 <= h <= 24) and sharing a cell with no other card of its
|
|
474
475
|
board, its block in the workspace, loading, not turned off and with page in its places; and each file of
|
|
475
476
|
the page's own named (assets/<file>: the folder pages/<slug>/assets/, which the server serves at
|
|
476
|
-
/pages/<slug>/assets/<file>) there, and
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
477
|
+
/pages/<slug>/assets/<file>) there, and no frame's but a picture's (the server serves a page's own
|
|
478
|
+
pictures by their type, its stylesheets and scripts as such, and any other file as bytes for saving: a
|
|
479
|
+
frame of a file there downloads it, while a link, a font, a video or audio uses the bytes), a picture,
|
|
480
|
+
stylesheet or script written relative any other way being one nothing serves. Then the cards with their ids and cells, and the changes since the page as
|
|
480
481
|
the last check that found nothing saw it (or, before any, since the version the page service kept before
|
|
481
482
|
its last write): cards added, removed, moved (to another board too), resized, their data parts changed
|
|
482
483
|
(with the lines), a card's own markup, the page's own HTML; each change the page wrote since, a gesture
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as Je,b as Qe,c as ge,e as At,h as Xe,i as tn}from"./chunk-
|
|
2
|
+
import{a as Je,b as Qe,c as ge,e as At,h as Xe,i as tn}from"./chunk-VFX2KNHP.mjs";import{A as Ye,B as We,C as Te,D as Q,E as Ze,a as me,g as Oe,h as He,j as Ne,l as Fe,m as wt,n as ke,o as $e,p as ne,q as Ft,r as De,s as Ve,t as vt,u as Le,v as Ge,w as Me,x as kt,y as G,z as je}from"./chunk-VS7JIGJW.mjs";import{g as Ct}from"./chunk-HDWTZ763.mjs";import{b as pe,c as he,e as Ee}from"./chunk-A55HN5OK.mjs";import{BLOCK_TYPES as Ie,COPIED_AS_ITSELF as Kn,IDENTITY as gn}from"../browser/editor/components/registry.mjs";import{copyKeys as Un}from"../browser/editor/components/figure/index.mjs";import{accepts as xe,attributeValue as An,BLOCK_TYPES as Dt,boxRole as we,CHAPTER as En,holdsStraight as On,IDENTITY as Ke,isLead as rn,SIZES as Nn,sizeValue as ln,TOGGLES as an}from"../browser/editor/components/registry.mjs";import{iconMarkup as $n,iconValueOf as Ln,validIcon as Mn}from"../browser/editor/components/icon/index.mjs";Ee();import{attributeValue as bn,BLOCK_TYPES as en,HOSTS as xn,TOGGLES as wn}from"../browser/editor/components/registry.mjs";import{texSource as nn}from"../browser/editor/components/math/index.mjs";var Ce=new Set(Object.entries(en).filter(([,s])=>!s.box&&!s.bare).map(([s])=>s)),se=(s,m,I="")=>{let k=Q[m.type]?.leaf;if(k)return k(s,m,I);let g=[s.className,...m.classes??[]].filter(Boolean).join(" ");return`<${s.tag}${g?` class="${g}"`:""}${ke(m.attributes)}${I}>${m.html}</${s.tag}>`},Be=(s,m)=>s===void 0||!!s&&typeof s=="object"&&!Array.isArray(s)&&Object.entries(s).every(([I,k])=>typeof k=="string"&&bn(m,I,k)),qe=s=>s?.empty===!0,Pe=(s,m)=>s===void 0?null:I=>s.includes(m.slice(I.startOffset,I.endOffset));function ye(s,m,{empty:I=!1,file:k}={}){if(typeof m!="string"||!m.trim()&&!(I&&m===""))return!1;if(m==="")return!0;if(s.tex&&!nn(m))return!1;let g=s.inside??s.tag,$=`<${g}>${m}</${g}>`,[w,...u]=he($,{sourceCodeLocationInfo:!0}).childNodes;return u.length===0&&w?.tagName===g&&ge(w,[],s.inside!==void 0,{cell:g==="td"||g==="th",known:Pe(k,$)})===null}var vn=new Set(Object.values(en).filter(s=>s.text&&s.className).map(s=>s.kind));function ze(s,m){if(s.keep?.reason==="script")return null;if(s.kind==="list")return m.some(k=>k.unit===s.id&&k.kind==="list")?"list":null;let I=Q[s.kind];return I?.written?I.written(s)?"written":null:s.text===void 0||s.nested?null:["p","h1","h2","h3","h4","li"].includes(s.tag)||vn.has(s.kind)?"text":null}function be(s,m,I){if(!Array.isArray(m)||!m.every(g=>Sn(s,g,I)))return"invalid";let k=m.filter(g=>g.keep);return k.length>1?"invalid":m.length>k.length&&!s.caps.split||k.length===0&&!s.caps.remove||m.length===0&&s.nested?"fixed":k.length===1&&k[0].html.trim()===""&&!s.caps.empty?"empty":null}function sn(s,m,I){let k=`<table><tbody><tr><${s}>${m}</${s}></tr></tbody></table>`,[g,...$]=he(k,{sourceCodeLocationInfo:!0}).childNodes,w=$.length===0&&g?.tagName==="table"&&g.childNodes.length===1?g.childNodes[0]:null,u=w?.childNodes.length===1?w.childNodes[0]:null,h=u?.childNodes.length===1?u.childNodes[0]:null;return h?.tagName===s&&ge(h,[],!1,{cell:!0,known:Pe(I,k)})===null}var on={p:"paragraph",h1:"heading",h2:"heading",h3:"heading",h4:"heading",li:"item"},In=(s,m)=>s.classes===void 0||!s.keep&&Array.isArray(s.classes)&&new Set(s.classes).size===s.classes.length&&s.classes.every(I=>(wn[on[m]]??[]).includes(I));function Sn(s,m,I){if(!m||typeof m.html!="string"||xn[s.kind]?.tex&&!nn(m.html))return!1;let k=m.keep?s.tag:m.tag;if(!m.keep&&Je[s.tag]!==k||!In(m,k)||m.attributes!==void 0&&(m.keep||!Be(m.attributes,on[k])))return!1;let g=k==="td"||k==="th",$=g?`<table><tbody><tr><${k}>${m.html}</${k}></tr></tbody></table>`:`<${k}>${m.html}</${k}>`,[w,...u]=he($,{sourceCodeLocationInfo:!0}).childNodes;if(u.length>0||!w)return!1;let h=w;if(g){let p=w.tagName==="table"&&w.childNodes.length===1?w.childNodes[0]:null,f=p?.childNodes.length===1?p.childNodes[0]:null;h=f?.childNodes.length===1?f.childNodes[0]:null}return h?.tagName===k&&ge(h,[],Qe(s.kind,s.tag,s.caps),{cell:g,known:Pe(I,$)})===null}import{attr as cn}from"../browser/shared/html-tree.mjs";import{pageLanguage as jn}from"../browser/shared/components/page.mjs";import{SHEETS as Tn}from"../browser/editor/components/kit.mjs";import{BLOCK_ID as Cn}from"../browser/shared/ids.mjs";function fn({current:s,edits:m,units:I=[],partial:k=!1,ids:g=!1,touch:$=[],proposals:w=null}){let u=At(s),h=u.blocks,p=s.includes(`\r
|
|
3
3
|
`)?`\r
|
|
4
4
|
`:`
|
|
5
5
|
`,f=[],O=[],j=[],K=new Map,q=null,X,xt=!1,tt=(t,n)=>f.push({unit:t.id,reason:n}),et=t=>{let o=Ft(t).replace(/[0-9.]/g,l=>String.fromCharCode(l.charCodeAt(0)-65248)).replace(/[\s,,]/g,"").replace(/[−–]/g,"-").match(/-?\d+(?:\.\d+)?/)?.[0];return o===void 0?null:Number(o)},ht=(t,n,o)=>{if(t.kind!=="cell")return;let l=s.slice(t.start,t.innerStart),a=/\sdata-sort-value(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/.exec(l);if(!a)return;let d=(a[1]??a[2]??a[3]??"").trim(),x=/^-?\d+(\.\d+)?(e[-+]?\d+)?$/i.test(d)?Number(d):null,[S,c]=[et(s.slice(t.innerStart,t.innerEnd)),et(n)],b="";x!==null&&c!==null?b=` data-sort-value="${Number((c*(S?x/S:1)).toPrecision(12))}"`:x!==null&&S===null&&(b=a[0]),b!==a[0]&&O.push({start:t.start+a.index,end:t.start+a.index+a[0].length,text:b,of:[{id:o}]})},Vt=t=>{t.keep&&ee(t)?tt(t,"referenced"):j.push({start:t.start,end:t.end},...t.companion?[t.companion]:[])},oe=(t,n)=>{let o=t.classAttr,l=o?o.value.split(/\s+/).filter(Boolean):[],a=l;for(let[x,S]of n)a=S?a.includes(x)?a:[...a,x]:a.filter(c=>c!==x);if(a.join(" ")===l.join(" "))return;if(ut(t),!o){let x=/^<[A-Za-z][\w-]*/.exec(s.slice(t.elStart,t.elStart+40));if(!x)return tt(t,"unknown");let S=t.elStart+x[0].length;O.push({start:S,end:S,text:` class="${a.join(" ")}"`});return}if(a.length===0){O.push({...ne(s,o.start,o.end),text:""});return}let d=/=\s*'/.test(s.slice(o.start,o.end))?"'":'"';O.push({start:o.start,end:o.end,text:`class=${d}${a.join(" ")}${d}`})},It=typeof g=="function"?g:g?Xe:null,ct=new Set([...s.matchAll(tn)].map(t=>t[1]??t[2])),qt=()=>{for(;;){let t=It();if(!ct.has(t))return ct.add(t)&&t}},re=[],Pt=[],Gt=t=>t?` ${Ke}="${t}"`:"",le=t=>typeof t=="string"&&Cn.test(t)&&!ct.has(t),ft=(t,n)=>{let o=It?le(n)?(ct.add(n),n):qt():null;return o&&t!==void 0&&Pt.push({key:t,id:o}),Gt(o)},ot=new Set,zt=t=>{ot.add(t.at);let n=w?.get(t.id),o=It?le(n)?(ct.add(n),n):qt():null;return o&&re.push({at:t.at,id:o}),Gt(o)},ut=t=>{if(!It||!t||t.blockId||t.at===void 0||ot.has(t.at))return;let n=$e(s,t.at);O.push({start:n,end:n,text:zt(t)})},St=t=>{let{element:n,source:o}=vt(t.restore),l=n.sourceCodeLocation,a=cn(n,Ke);if(a&&!ct.has(a))return ct.add(a),t.key!==void 0&&Pt.push({key:t.key,id:a}),o;let d=o,x=l.startTag.endOffset-1;if(a){let S=l.attrs[Ke],c=ne(d,S.startOffset,S.endOffset);d=d.slice(0,c.start)+d.slice(c.end),x-=c.end-c.start}return x=$e(d,x),d.slice(0,x)+ft(t.key,t.blockId)+d.slice(x)},gt=t=>{let n=null;for(let o of u.units)o.elStart<=t.start&&t.start<o.end&&(!n||o.elStart>n.elStart)&&(n=o);return n},_=new Set;for(let t of m){let{id:n,parts:o}=t??{},l=Number.isInteger(n)?h[n]:void 0;if(!l){f.push({id:n,reason:"unknown"});continue}if(Array.isArray(o)&&o.length===0&&l.self!==null&&u.units[l.self].keep){f.push({id:n,reason:"referenced"});continue}let a=be(l,o,s);if(a){f.push({id:n,reason:a});continue}if(o.length===0){let N={...je(s,l.start,l.end),of:[{id:n}]};O.push(N),K.set(n,N),l.self!==null&&_.add(l.self);continue}let d=G(s,l.start),x=d===null?"":p+d,S=N=>`<${N.tag}${N.classes?` class="${N.classes.join(" ")}"`:""}${ke(N.attributes)}${ft(N.key,N.blockId)}>${N.html}</${N.tag}>`,c=o.findIndex(N=>N.keep),b=gt(l),v=b&&b.at===l.innerStart-1;if((!v||l.tag==="li")&&ut(b),l.tag==="li"&&c>=0){let N=o.slice(0,c),z=o.slice(c+1),C=b?{start:b.start,end:b.end}:null;O.push({start:l.innerStart,end:l.innerEnd,text:o[c].html,of:[{id:n}]}),N.length>0&&O.push({start:l.start,end:l.start,seq:1/0,text:N.map(S).join(x)+x,edge:C,of:[{id:n}]}),z.length>0&&O.push({start:l.end,end:l.end,text:x+z.map(S).join(x),edge:C,of:[{id:n}]})}else{let N=s.slice(l.start,l.innerStart);if(v&&It&&!b.blockId&&!ot.has(b.at)&&(N=`${N.slice(0,-1)}${zt(b)}>`),o.length===1&&c===0&&N===s.slice(l.start,l.innerStart)){O.push({start:l.innerStart,end:l.innerEnd,text:o[0].html,of:[{id:n}]}),ht(l,o[0].html,n),l.kind==="title"&&(q={from:Ft(s.slice(l.innerStart,l.innerEnd)),to:Ft(o[0].html)});continue}let z=o.map(C=>C.keep?N+C.html+s.slice(l.innerEnd,l.end):S(C)).join(x);O.push({start:l.start,end:l.end,text:z,of:[{id:n}]})}l.kind==="title"&&(q={from:Ft(s.slice(l.innerStart,l.innerEnd)),to:Ft(o[0].html)})}let Y=(t,n,o)=>{let l=u.units.filter(c=>c.box===t),a=[];for(let c=1;c<l.length;c++){let b=s.slice(l[c-1].end,l[c].start);b.trim()||a.push({pair:[l[c-1],l[c]],gap:b})}let d=a.find(({pair:c})=>c.includes(n))??a[0];if(d)return d.gap.replace(/\r?\n/g,p);let x=G(s,o.start),S=we(u.boxes[t]?.kind)==="root"?p:"";return x===null?"":S+p+x},Yt=t=>{if(t.kind!=="nest"||G(s,t.innerEnd)!==null)return null;let n=u.units[t.unit];return n?G(s,n.elStart):null},Wt=(t,n)=>{let o=s.slice(t.at+1,t.innerEnd).match(/\n([ \t]*)\S/);return o?o[1]:`${n??""} `},Kt=(t,n)=>n!==null&&we(t.kind)==="root",mt=[],Zt=(t,n,o,l)=>{let a=Number.isInteger(n?.into)?u.boxes[n.into]:null,d=Number.isInteger(n?.after),x=a?null:u.units[d?n.after:n?.before],S=a??(x?u.boxes[x.box]:null),c=z=>z>=t.start&&z<t.end;if(!S||!(xe(S.kind,te(t))||l===S.kind)||t.kind==="tab"&&S.id!==t.box||x&&(x===t||!o.has(x.id)||c(x.elStart))||a&&c(S.at))return tt(t,"position");let b=G(s,t.start);if(ut(t),a){if(a.innerEnd===null)return tt(t,"missing");let z=Yt(a);if(z!==null){mt.push({start:t.start,end:t.end,at:a.innerEnd,seq:lt++,from:b,to:z+nt,wrap:R=>p+z+nt+R+p+z});return}let C=G(s,a.innerEnd),W=Wt(a,C),T=C!==null&&W.startsWith(C)?W.slice(C.length):" ",P=Kt(a,C);mt.push({start:t.start,end:t.end,at:P?a.innerEnd-C.length:a.innerEnd,seq:lt++,from:b,to:W,wrap:R=>C===null?R:P?C+T+R+p:T+R+p+C});return}let v=Y(x.box,x,x),N=d?v.includes(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
+
import{a,b,c,d,e,f,g}from"./chunk-67N2QJYT.mjs";import"./chunk-ZWWC4KLF.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-ITOH5EGO.mjs";import"./chunk-ZQS6H473.mjs";import"./chunk-MXUBKDRO.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-R2ZDLJYT.mjs";import"./chunk-VFX2KNHP.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as handInReports,e as idLines,f as inStepLines,d as noteNew,b as previewSettled,g as rereadLine,c as roundBegins};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{$ 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-
|
|
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-HPOI4ZX7.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-EAIFITAV.mjs";import"./chunk-67N2QJYT.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-DJISHPUL.mjs";import"./chunk-ZWWC4KLF.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-ITOH5EGO.mjs";import"./chunk-ZQS6H473.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-MXUBKDRO.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-R2ZDLJYT.mjs";import"./chunk-VFX2KNHP.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{_ 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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
+
import{a as v,b as j}from"./chunk-HYMEEXKN.mjs";import l from"node:fs";import p from"node:path";import V from"node:zlib";import{escapeAttribute as $,escapeMarkup as _}from"../browser/shared/escape.mjs";import{componentOf as b,instancesOf as L,partOf as O}from"../browser/shared/components/index.mjs";import{ICON_COLOR_VALUES as I,TAB_ICON as N,glyphOf as B,iconKind as u,iconUrl as T,iconValueOf as S,tabIconValue as R}from"../browser/shared/emoji/icon-value.mjs";import{lineIconSvg as z}from"../browser/shared/emoji/line-icons.mjs";import{mediaTypeOf as A,mediaUrl as J}from"../browser/shared/media.mjs";import{emojiDataDirectory as P,reportsDirectory as E}from"../browser/shared/paths.mjs";import{slugPattern as G}from"../browser/shared/reports.mjs";import{documentDirectory as D}from"../browser/shared/workspace.mjs";var g=P,k=String.fromCodePoint(65039),C=null,x=null;function H(){return C??={positions:JSON.parse(l.readFileSync(p.join(g,"positions.json"),"utf8")),index:JSON.parse(l.readFileSync(p.join(g,"twemoji-index.json"),"utf8")),svg:V.gunzipSync(l.readFileSync(p.join(g,"twemoji-svg.bin")))},C}function F(e){let{positions:t,index:r,svg:o}=H(),n=[e,e.replaceAll(k,""),`${e}${k}`].find(c=>t[c]),i=n&&r[t[n][0]];return i?o.subarray(i[0],i[0]+i[1]):null}function U(e){let t=F(e);return t?`data:image/svg+xml;base64,${t.toString("base64")}`:null}function ue(e){return d(""),[...x.keys()].filter(t=>t.startsWith(`${e}/`)).map(t=>t.slice(e.length+1))}function d(e,t="currentColor"){x??=new Map(JSON.parse(l.readFileSync(p.join(g,"icons.json"),"utf8")).icons.flatMap(([,n,i,c,a])=>[[`mingcute/${n}`,c],[`tabler/${i}`,a]].filter(([,s])=>s)));let r=B(e),o=r&&x.get(`${r.set}/${r.name}`);return o?o.split("#COLOR").join(t).replace("<svg ",'<svg aria-hidden="true" '):null}function K(e){let[t,r]=I[B(e)?.color]??I.gray,o=d(e);return o&&o.replace(/<svg\b[^>]*>/,n=>`${n.replace(/ aria-hidden="true"/,"").replace(/^<svg /,'<svg xmlns="http://www.w3.org/2000/svg" ').replace(/ xmlns="http:\/\/www\.w3\.org\/2000\/svg"(?=.* xmlns=)/,"")}<style>svg{color:${t}}@media (prefers-color-scheme:dark){svg{color:${r}}}</style>`)}var W=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><text x="18" y="18" text-anchor="middle" dominant-baseline="central" font-size="30" font-family="'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif">${_(e)}</text></svg>`;function q({value:e,slug:t=null,tab:r=!1,reportsDirectory:o=E}){let n=z(e,{color:"#000",tab:r});if(n)return{type:"image/svg+xml",body:Buffer.from(n)};let i=u(e);if(i==="emoji")return{type:"image/svg+xml",body:F(e)??Buffer.from(W(e))};if(i==="glyph"){let a=r?K(e):d(e,"#000");return a&&{type:"image/svg+xml",body:Buffer.from(a)}}if(i!=="image"||!t||!G.test(t))return null;let c=p.join(D(t,o),e);return l.existsSync(c)?{type:A(e),body:l.readFileSync(c)}:null}var M=/(<div\b[^>]*\bclass="doc-icon"[^>]*>)([\s\S]*?)(<\/div>)/g;function de(e,{slug:t,mode:r="export",reportsDirectory:o=E}){return te(X(e,{mode:r}).replace(M,(n,i,c,a)=>{let s=S(n),y=u(s);if(!y)return n;let f=null;if(y==="emoji"){let m=U(s);f=m&&`<img alt="${$(s)}" src="${m}">`}else if(y==="glyph")f=d(s);else if(r==="preview")f=`<img src="${J("asset",t,s)}" alt="">`;else{let m=p.join(D(t,o),s),w=l.existsSync(m)?l.readFileSync(m):null;f=w&&`<img src="data:${A(s)};base64,${w.toString("base64")}" alt="">`}let h=r==="preview"?i.replace(/>$/,` data-ge-icon="${$(s)}">`):i;return f?`${h}${f}${a}`:`${h}${c}${a}`}),ee(Z(e),{slug:t,mode:r,reportsDirectory:o}))}var ye=e=>[...e.matchAll(M)].flatMap(t=>{let r=u(S(t[0]))==="image"?/<img\b[^>]*\bsrc="/.exec(t[2]):null;return r?[t.index+t[1].length+r.index]:[]}),Q=/<button\b[^>]*\bdata-tab-icon="([^"]*)"[^>]*>/g;function X(e,{mode:t="export"}={}){return e.replace(Q,(r,o)=>{if(u(o)!=="emoji"||r.includes(N))return r;let n=t==="preview"?T(o):U(o);if(!n)return r;let i=`${N}: ${R(n)}`;return/\sstyle="/.test(r)?r.replace(/\sstyle="([^"]*)"/,(c,a)=>` style="${a.replace(/;?\s*$/,"; ")}${i}"`):r.replace(/>$/,` style="${i}">`)})}function Y(e){let t=O(e,b("page").header)[0];return{all:L(e,b("icon")),own:t?O(t,b("icon").match):[]}}function Z(e){let[t]=Y(v(e)).own;return t?S(j(e,t)):null}function ee(e,{slug:t,mode:r,reportsDirectory:o}){if(!e)return null;if(r==="preview")return T(e,t,{tab:!0});let n=q({value:e,slug:t,tab:!0,reportsDirectory:o});return n&&`data:${n.type};base64,${Buffer.from(n.body).toString("base64")}`}var te=(e,t)=>t&&/<\/head>/i.test(e)&&!e.includes("data-doc-tab-icon")?e.replace(/<\/head>/i,()=>` <link rel="icon" href="${$(t)}" data-doc-tab-icon>
|
|
3
|
+
</head>`):e;export{U as a,ue as b,d as c,q as d,de as e,ye as f,Y as g,Z as h};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{g as n,h as g}from"./chunk-
|
|
3
|
-
`).catch(()=>{}),console.log(`Gallery serves ${t} at ${n(r)} (Chrome or Edge). Ctrl+C stops it.`);return}let{writeSharedAssets:y}=await import("./chunk-
|
|
2
|
+
import{g as n,h as g}from"./chunk-5XA2ZBAE.mjs";import{b as m,f as d}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{spawn as P}from"node:child_process";import h from"node:fs/promises";import R from"node:path";import{projectRoot as v,release as k,reportsDirectory as t}from"../browser/shared/paths.mjs";import{answerOf as S,findPreviewServer as x,portIsFree as E,readAnnouncement as G}from"../browser/shared/preview-server.mjs";import{layoutOf as $}from"../browser/shared/workspace.mjs";var b=a=>new Promise(s=>setTimeout(s,a));async function O(a){let{positional:s,values:l}=d({values:["--port"],argv:a});if(s.length>0)throw new m(`gallery serve takes no arguments: ${s[0]}`);let o=l.has("--port")?Number(l.get("--port")):null;if(o!==null&&!(Number.isInteger(o)&&o>0&&o<65536))throw new m(`--port takes a port number: ${l.get("--port")}`);let i=await G({reportsDirectory:t}),f=i?await S(i,t,1e4):"no";f!=="no"&&(console.error(`This workspace's Gallery server runs already: ${n(i.port)} (pid ${i.pid}${f==="busy"?", not answering now":""}). gallery stop stops it; one server serves a workspace.`),process.exit(1));let r=null;if(o!==null)await E(o)||(console.error(`Port ${o} is taken: name another (--port), or leave it out for the first free one.`),process.exit(1)),r=o;else{for(let e of await g())if(await E(e)){r=e;break}r===null&&(console.error("No port from 4317 is free: name one (--port <n>)."),process.exit(1))}if(k){process.env.GALLERY_SERVER_KIND="cli";let{startProductionServer:e}=await import("./chunk-L2SUIS5S.mjs");await e({port:r,kind:"cli"}),await h.writeFile($(t).lastPortFile,`${r}
|
|
3
|
+
`).catch(()=>{}),console.log(`Gallery serves ${t} at ${n(r)} (Chrome or Edge). Ctrl+C stops it.`);return}let{writeSharedAssets:y}=await import("./chunk-WQDQWCX5.mjs");await y();let c=P(process.execPath,[R.join(v,"node_modules","vite","bin","vite.js"),"--host","127.0.0.1","--port",String(r),"--strictPort"],{cwd:v,env:{...process.env,GALLERY_WORKSPACE:t,GALLERY_SERVER_KIND:"cli"},stdio:"inherit"});for(let e of["SIGINT","SIGTERM"])process.on(e,()=>c.kill(e));let w=new Promise(e=>c.once("exit",(u,p)=>e(u??(p?1:0))));for(;;){let e=await Promise.race([w.then(p=>({code:p})),b(300).then(()=>null)]);if(e&&process.exit(e.code),(await x({reportsDirectory:t,answering:!0,timeout:2e3}))?.pid===c.pid)break}await h.writeFile($(t).lastPortFile,`${r}
|
|
4
4
|
`).catch(()=>{}),console.log(`Gallery serves ${t} at ${n(r)} (Chrome or Edge). Ctrl+C stops it.`),process.exit(await w)}export{O as run};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-2OHANJ6Q.mjs";import{c as L,d as F}from"./chunk-Q4UEPUWF.mjs";import{c as x,d as j,k as w}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import l from"node:fs";import c from"node:path";import{pathToFileURL as K}from"node:url";import{projectRoot as p}from"../browser/shared/paths.mjs";import{sha256 as A}from"../browser/shared/files.mjs";var g=["SKILL.md","references/writing-html.md","references/building-blocks.md","references/block-script.md","references/pages-and-data.md","references/extensions.md","references/example-report.html","sdk","agents/openai.yaml"],u="## Before anything: the gallery command";function T(n){let[t,s]=n.split(/[.+-]/).map(Number);return{range:`^${n}`,takes:`${n} or a later ${t===0?`0.${s}`:t}.x`}}function N(n,t){let s=n.indexOf(`
|
|
3
3
|
${u}
|
|
4
4
|
`);if(s<0)throw new Error(`SKILL.md has no section "${u}" (the version range of the command stands there)`);let e=n.indexOf(`
|
|
5
5
|
## `,s+u.length+1),i=e<0?n.length:e,{range:r,takes:o}=T(t),a=n.slice(s,i).replace(new RegExp(L.source,"g"),F(t)).replace(/\^\d+\.\d+\.\d+(?:-[\w.]+)?/g,r).replace(/\b\d+\.\d+\.\d+(?:-[\w.]+)? or a later \d+(?:\.\d+)?\.x\b/g,o);return n.slice(0,s)+a+n.slice(i)}function y(n=p){let t=g.filter(r=>!l.existsSync(c.join(n,r)));if(t.length)return t.map(r=>`the skill takes ${r}, which is not there`);let s=E(g,n),e=r=>l.readFileSync(c.join(n,r),"utf8"),i=P(s,e).map(r=>`${r}, which the skill does not hold: link only what it holds`);for(let r of s.filter(o=>o.startsWith("sdk/")&&o.endsWith(".ts")))for(let[,o]of e(r).matchAll(/\bfrom\s+["']([^"']+)["']|\bimport\(\s*["']([^"']+)["']\s*\)/g))o&&(!o.startsWith("./")||o.includes("/../"))&&i.push(`${r} imports ${o}, outside sdk/: write the types it needs in sdk/`);return i}function R(n,{root:t=p,version:s=JSON.parse(l.readFileSync(c.join(t,"package.json"),"utf8")).version}={}){let e=y(t);if(e.length)throw new Error(`The skill cannot be made:
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-EP25HDAJ.mjs";import"./chunk-AR5D57ZD.mjs";import"./chunk-5XA2ZBAE.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-7OG26PGF.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-QE5RG76S.mjs";import"./chunk-UYVCQK3H.mjs";import"./chunk-J5PUIV3Y.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{c as HOME_NOT_MADE,g as emptyRequiredOf,d as missingPageSaid,a as pageAddressOf,b as pageAloneOf,h as run,e as setsOf,f as settingsGiven};
|
|
@@ -0,0 +1,22 @@
|
|
|
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 Ee,d as X,f as ae,h as ie,i as Ne,l as oe,p as ve}from"./chunk-J5PUIV3Y.mjs";import{D as ce}from"./chunk-VS7JIGJW.mjs";import{a as Q,f as Ce,g as Ie,n as je,t as Ae}from"./chunk-HDWTZ763.mjs";import{b as ye,e as mt}from"./chunk-A55HN5OK.mjs";mt();import{createHash as ht}from"node:crypto";import{cellsOf as gt}from"../browser/shared/card-size.mjs";import{escapeAttribute as de}from"../browser/shared/escape.mjs";import{attr as N,elementsOf as le,hasClass as _e,walk as Te}from"../browser/shared/html-tree.mjs";import{ATTRIBUTE as He}from"../browser/shared/components/installed.mjs";var q=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,sr=Object.freeze(["data-board-id","data-card-id","data-x","data-y","data-w","data-h"]),De="gallery-board",Fe="gallery-card",Le=e=>(e.tagName==="div"||e.tagName==="section")&&N(e,He)!==void 0,wt=e=>ht("sha256").update(e.replace(/\r\n?/g,`
|
|
3
|
+
`)).digest("hex").slice(0,16),kt=e=>ye(e.replace(/^/," "),{sourceCodeLocationInfo:!0});function I(e){let n=[];return Te(kt(e),r=>{if(!_e(r,De))return;let i=le(r).filter(s=>_e(s,Fe)&&s.sourceCodeLocation).map(s=>{let a=le(s).find(Le)??null;a||Te(s,O=>{a??=Le(O)?O:null});let h=s.sourceCodeLocation,g={x:N(s,"data-x"),y:N(s,"data-y"),w:N(s,"data-w"),h:N(s,"data-h")};return{id:N(s,"data-card-id")??null,node:s,board:N(r,"data-board-id")??null,...gt({dataset:g}),instance:a,block:a?N(a,He):null,start:h.startOffset,end:h.endOffset,closed:!!h.endTag}});n.push({id:N(r,"data-board-id")??null,node:r,cards:i})},{inTemplates:!1}),{boards:n,cards:n.flatMap(r=>r.cards)}}function Ot(e){let n=new Set(e.map(({id:s})=>s).filter(s=>typeof s=="string"&&q.test(s))),r=new Set,i=1;return e.map(({id:s})=>{if(typeof s=="string"&&q.test(s)&&!r.has(s))return r.add(s),s;for(;n.has(`c${i}`)||r.has(`c${i}`);)i++;let a=`c${i}`;return r.add(a),a})}function fe(e){let n=new Set(e),r=1;for(;n.has(`c${r}`);)r++;return`c${r}`}function ee(e,n,r){let{startTag:i}=n.sourceCodeLocation,s=i.attrs??{},a=[],h=[];for(let[g,O]of Object.entries(r)){let S=s[g];S?(a.push({start:S.startOffset,end:S.endOffset,text:O===null?"":`${g}="${de(String(O))}"`}),O===null&&e[S.startOffset-1]===" "&&(a.at(-1).start-=1)):O!==null&&h.push(` ${g}="${de(String(O))}"`)}if(h.length){let g=s.class?.endOffset??i.startOffset+1+n.tagName.length;a.push({start:g,end:g,text:h.join("")})}return a}function te(e,n){return[...n].sort((r,i)=>i.start-r.start||i.end-r.end).reduce((r,{start:i,end:s,text:a})=>r.slice(0,i)+a+r.slice(s),e)}function W(e){let{cards:n}=I(e),r=Ot(n),i=n.flatMap((s,a)=>s.id===r[a]?[]:ee(e,s.node,{"data-card-id":r[a]}));return{text:i.length?te(e,i):e,filled:n.flatMap((s,a)=>s.id===r[a]?[]:[r[a]])}}var V=(e,n)=>wt(e.slice(n.start,n.end));function Re(e){let n=W(e).text;return I(n).cards.map(r=>({id:r.id,board:r.board,x:r.x,y:r.y,w:r.w,h:r.h,base:V(n,r),block:r.block}))}var Pe=e=>[e.board,...["x","y","w","h"].map(n=>N(e.node,`data-${n}`))].join(",");function Me(e,n){let r=n.node.sourceCodeLocation.startTag.endOffset;return e.slice(n.start,r).replace(/\s+data-[xywh]="[^"]*"/g,"")+e.slice(r,n.end)}function Je(e,n){let[r,i]=[W(e).text,W(n).text],[s,a]=[I(r).cards,I(i).cards],h={};for(let g of s)a.some(O=>O.id===g.id)||(h[g.id]=["removed"]);for(let g of a){let O=s.find(v=>v.id===g.id);if(!O){h[g.id]=["added"];continue}let S=[...Pe(O)!==Pe(g)?["cells"]:[],...Me(r,O)!==Me(i,g)?["content"]:[]];S.length&&(h[g.id]=S)}return h}function Y(e,n){let{cards:r}=I(e),i=r.flatMap(s=>{let a=n.get(s.id);if(!a)return[];let h={};for(let g of["x","y","w","h"])a[g]!==void 0&&N(s.node,`data-${g}`)!==String(a[g])&&(h[`data-${g}`]=a[g]);return Object.keys(h).length?ee(e,s.node,h):[]});return i.length?te(e,i):e}function xt(e,n,r){let i=e.lastIndexOf(`
|
|
4
|
+
`,n-1)+1,s=e.indexOf(`
|
|
5
|
+
`,r),a=s===-1?e.slice(r):e.slice(r,s);return!/^[ \t]*$/.test(e.slice(i,n))||!/^[ \t\r]*$/.test(a)?{from:n,to:r}:{from:i,to:s===-1?e.length:s+1}}function Be(e,n){let r=I(e).cards.find(a=>a.id===n);if(!r)return null;let{from:i,to:s}=xt(e,r.start,r.end);return{text:e.slice(0,i)+e.slice(s),html:e.slice(r.start,r.end)}}var ze=(e,n)=>/^[ \t]*/.exec(e.slice(e.lastIndexOf(`
|
|
6
|
+
`,n-1)+1))[0],$t=(e,n)=>e.replace(/\r?\n/g,r=>`${r}${n}`);function We({id:e,x:n,y:r,w:i,h:s},a,h="",g=`
|
|
7
|
+
`){return`${`<section class="${Fe}" data-card-id="${de(e)}" data-x="${n}" data-y="${r}" data-w="${i}" data-h="${s}">`}${g}${h} ${$t(a.trim().replace(/\r?\n/g,g),`${h} `)}${g}${h}</section>`}function ue(e,n,r){let i=I(e).boards.find(j=>j.id===n);if(!i)return null;let{node:s}=i,a=s.sourceCodeLocation,h=e.includes(`\r
|
|
8
|
+
`)?`\r
|
|
9
|
+
`:`
|
|
10
|
+
`,g=i.cards.at(-1),O=g?ze(e,g.start):`${ze(e,a.startOffset)} `,S=r.match(/\n([ \t]*)<\/[a-z]+>\s*$/)?.[1]??"",v=r.trim().replace(/\r?\n/g,`
|
|
11
|
+
`).split(`
|
|
12
|
+
`).map((j,_)=>_===0||S===O?j:j.startsWith(S)?`${O}${j.slice(S.length)}`:j).join(h);if(a.endTag){let j=a.endTag.startOffset,_=e.lastIndexOf(`
|
|
13
|
+
`,j-1)+1,F=/^[ \t]*$/.test(e.slice(_,j)),T=F?_:j,R=`${F?"":h}${O}${v}${h}`;return{text:e.slice(0,T)+R+e.slice(T),start:T+R.indexOf(v)}}let E=a.endOffset,D=`${h}${O}${v}`;return{text:e.slice(0,E)+D+e.slice(E),start:E+D.indexOf(v)}}function ar(e,{blockOf:n=()=>null}={}){let r=W(e).text,i=[];for(let s of I(r).cards){let a=s.block?n(s.block):null,h={"data-ge-base":V(r,s)};a?.fit==="content"&&(h["data-ge-fit"]="content"),a?.bare&&(h["data-ge-bare"]="");let g=s.block===null?null:a?.state??"missing";if(g&&g!=="page"&&(h["data-ge-state"]=g),i.push(...ee(r,s.node,h)),s.instance&&a&&g!=="page"&&g!=="missing"){let{startOffset:O,endOffset:S}=s.instance.sourceCodeLocation;i.push({start:O,end:O,text:"<template data-ge-held>"},{start:S,end:S,text:"</template>"})}}return te(r,i)}function Ue(e){let n=`<!doctype html><html><head></head><body><div class="${De}">`,r=`${n}${e}</div></body></html>`,[i]=I(r).boards;return{text:r,board:i,from:n.length,to:n.length+e.length}}function Ge(e){let{board:n}=Ue(e);if(!n||n.cards.length!==1)return null;let r=le(n.node).length!==1||n.node.childNodes.some(s=>s.nodeName==="#text"&&s.value.trim()),[i]=n.cards;return r||!i.closed||!i.instance||i.instance.parentNode!==i.node?null:i}function Ke(e,{id:n,x:r,y:i,w:s,h:a}){let{text:h,board:g,from:O,to:S}=Ue(e),v={"data-card-id":n,"data-x":r,"data-y":i,"data-w":s,"data-h":a},E=ee(h,g.cards[0].node,v),D=E.reduce((j,{start:_,end:F,text:T})=>j+T.length-(F-_),0);return te(h,E).slice(O,S+D)}import{readFileSync as pe}from"node:fs";import z from"node:fs/promises";import H from"node:path";import{refusedInCopy as Ve}from"../browser/shared/components/installed.mjs";import{writeAtomic as Ye}from"../browser/shared/files.mjs";import{sendJson as re}from"../browser/shared/http.mjs";import{jsonIn as bt}from"../browser/shared/json-layout.mjs";import{defaultSize as me,freeSpot as St,onBoard as he,pushDown as ge,settle as yt,sizeFor as Ze}from"../browser/shared/board-places.mjs";import{FIRST_BOARD as Qe,HOME_CARDS as Ct,HOME_SIZES as It,pageExists as we,pageFiles as jt,pageVersion as Xe,tellHomeCards as qe}from"../browser/shared/pages.mjs";import{OWN_SCOPE as At,PACK_FILE as Et,readPackManifest as Nt}from"../browser/shared/pack-manifest.mjs";import{packsDirectory as vt}from"../browser/shared/paths.mjs";import{sameDirectory as _t}from"../browser/shared/preview-server.mjs";import{walk as Tt}from"../browser/shared/html-tree.mjs";import{closePageHint as Lt,pageDefaults as Pt}from"../browser/shared/pages.mjs";var Mt=20,ke="writes.jsonl",zt=200;async function Ar(e,n,r){return(await z.readFile(H.join(e,"pages",n,ke),"utf8").catch(()=>"")).split(`
|
|
14
|
+
`).flatMap(s=>{try{let a=JSON.parse(s);return a&&typeof a.at=="number"&&a.at>=r&&a.cards&&typeof a.cards=="object"?[a]:[]}catch{return[]}})}var Ht=["place","arrange","add","remove","edit","settings","restore-defaults"],U=e=>Number.isInteger(e)&&e>=0,ne=e=>Number.isInteger(e)&&e>=1,Dt=/^\d{4}-\d{2}-\d{2}$/,x=(e,n,r)=>[e,{ok:!1,reason:n,...r?{message:r}:{}}];function Ft(e,n){return typeof e=="string"?e.replace(new RegExp(`(^|[\\s"'(,=])/pages/${n}/assets/`,"g"),"$1assets/"):e}var et=e=>[409,{ok:!1,refused:e}];function Er(e,n){let r=e.packages.get(n);return r?{state:r.places.includes("page")?"page":"document",card:r.card,settings:r.settings,places:r.places,fit:r.card.fit,bare:r.card.bare,name:r.name,parts:Object.fromEntries(Object.entries(r.parts).filter(([,i])=>i.edit==="data").map(([i,s])=>[i,s.at]))}:e.settings.disabled.includes(n)&&e.problems.has(n)?{state:"disabled",card:null,settings:[],places:[],fit:"fixed",bare:!1,name:null,parts:{}}:null}function Rt(e,{type:n,options:r}){return n==="text"||n==="document"?typeof e=="string"&&e.length<=1e4:n==="number"?typeof e=="number"&&Number.isFinite(e)||e===null:n==="select"?r.includes(e):n==="date"?e===""||typeof e=="string"&&Dt.test(e):n==="switch"?typeof e=="boolean":!1}function tt(e,{x:n,y:r,w:i,h:s}){let a={x:e.x??n,y:e.y??r,w:e.w??i,h:e.h??s};return U(a.x)&&U(a.y)&&ne(a.w)&&ne(a.h)?a:null}function rt({root:e,edits:n,stateDirectory:r,catalog:i=()=>Ie(e),catalogTaken:s=()=>{},shipped:a=void 0,log:h=()=>{},shown:g=O=>O}){let O=0;async function S(f,t){let o=H.join(r,"pages",f);await z.mkdir(o,{recursive:!0}),O=(O+1)%1e4,await z.writeFile(H.join(o,`${String(Date.now()).padStart(15,"0")}-${String(O).padStart(4,"0")}.html`),t);let d=(await z.readdir(o)).filter(p=>/^\d{15}-\d{4}\.html$/.test(p)).sort();for(let p of d.slice(0,Math.max(0,d.length-Mt)))await z.rm(H.join(o,p),{force:!0})}async function v(f,t){let o=H.join(r,"pages",f,ke);try{let d=(await z.readFile(o,"utf8").catch(()=>"")).split(`
|
|
15
|
+
`).filter(Boolean);d.push(JSON.stringify({at:Date.now(),...t})),await Ye(o,`${d.slice(-zt).join(`
|
|
16
|
+
`)}
|
|
17
|
+
`)}catch(d){h(`the write of ${f}'s page.html could not be told in ${ke}: ${d.message}`)}}function E(f,t){if(typeof t.card!="string")return{error:x(400,"card")};let o=I(f).cards.find(d=>d.id===t.card);return o?typeof t.base!="string"||V(f,o)!==t.base?{error:et("changed")}:{card:o}:{error:et("gone")}}let D=(f,t)=>I(f).cards.filter(o=>o.board===t).map(({id:o,x:d,y:p,w:l,h:u})=>({id:o,x:d,y:p,w:l,h:u})),j=(f,t)=>new Map(t.filter(o=>{let d=f.find(p=>p.id===o.id);return!d||d.x!==o.x||d.y!==o.y||d.w!==o.w||d.h!==o.h}).map(o=>[o.id,o])),_=(f,t,o)=>ce.installed.dataOf(f,t.instance,o)??{};function F(f,t,o,d){if(!t.instance||!d.has(t.block))return{error:x(409,"block")};let p=_(f,t,d),l=ce.installed.rewrite(f,t.instance,o,{packages:d});if(!l)return{error:x(400,"part")};let u=[...l].sort((m,k)=>k.start-m.start).reduce((m,{start:k,end:$,text:c})=>m.slice(0,k)+c+m.slice($),f),w=_(u,I(u).cards.find(m=>m.id===t.id),d);return{text:u,parts:Object.fromEntries(Object.keys(o).map(m=>[m,{was:p[m]??"",now:w[m]??""}]))}}function T(f,t){return Object.fromEntries(Object.entries(f).map(([o,{was:d,now:p}])=>[o,{was:g(d,t),now:g(p,t)}]))}let R={place(f,t,{packages:o}){let{card:d,error:p}=E(f,t);if(p)return{error:p};let l=tt(t,d);if(!l)return{error:x(400,"cells")};let u=o.get(d.block);if(l.w!==d.w||l.h!==d.h){let m=u&&!u.card.sizes&&u.card.h===null&&l.w===d.w;if(u&&!u.card.resize&&!m)return{error:x(409,"resize")};u&&!m&&(l={...l,...Ze(u.card,l)})}let w=D(f,d.board);return{text:Y(f,j(w,ge(w,{id:d.id,...l})))}},arrange(f,t){if(!Array.isArray(t.cards)||t.cards.length===0)return{error:x(400,"cards")};let o=[];for(let p of t.cards){let{card:l,error:u}=E(f,p??{});if(u)return{error:u};let w=tt(p,l);if(!w)return{error:x(400,"cells")};o.push({card:l,cells:he(w)})}let d=f;for(let p of new Set(o.map(({card:l})=>l.board))){let l=D(d,p),u=o.filter(({card:m})=>m.board===p),w=l.map(m=>({...m,...u.find(({card:k})=>k.id===m.id)?.cells??{}}));d=Y(d,j(l,yt(w,u.map(({card:m})=>m.id))))}return{text:d}},async add(f,t,o){let{boards:d,cards:p}=I(f);if(t.html!==void 0)return ct(f,t,{boards:d,cards:p});if(typeof t.block!="string")return{error:x(400,"block")};let l=typeof t.board=="string"?d.find(y=>y.id===t.board):d.find(y=>y.id===Qe)??d[0];if(!l)return{error:x(409,"board")};ae(t.block,a)&&oe(e,{ids:[t.block],directory:a,log:h}).updated.length>0&&(s(),o.refresh());let u=o.packages.get(t.block),w=o.catalog.settings.disabled.includes(t.block);if(!u&&!w&&!o.catalog.problems.has(t.block)&&ae(t.block,a)){let y=X(a).find(({id:K})=>K===t.block);y&&y.places.includes("page")&&!ie(e,y).added&&(Ne(e,y),h(`${t.block} added to the workspace for a card of a custom page`),s(),o.refresh(),u=o.packages.get(t.block))}if(!u)return{error:x(409,o.catalog.settings.disabled.includes(t.block)?"disabled":"missing")};if(!u.places.includes("page"))return{error:x(409,"places")};let m=Ae(u);if(!m)return{error:x(409,"template")};if(t.w!==void 0&&!ne(t.w)||t.h!==void 0&&!ne(t.h))return{error:x(400,"cells")};let k=me(u.card),$=t.w!==void 0||t.h!==void 0?Ze(u.card,{w:t.w??k.w,h:t.h??k.h}):k,c=l.cards.map(({id:y,x:K,y:ft,w:ut,h:pt})=>({id:y,x:K,y:ft,w:ut,h:pt})),b=t.x!==void 0||t.y!==void 0?{x:t.x??0,y:t.y??0}:St(c,$);if(!U(b.x)||!U(b.y))return{error:x(400,"cells")};let C=fe(p.map(y=>y.id)),L=he({...b,w:$.w,h:$.h}),J=f.includes(`\r
|
|
18
|
+
`)?`\r
|
|
19
|
+
`:`
|
|
20
|
+
`,A=We({id:C,...L},m,"",J),G=ue(f,l.id,A),Z=j(c,ge(c,{id:C,...L}).filter(y=>y.id!==C)),P=Y(G.text,Z),B=I(P).cards.find(y=>y.id===C);if(t.settings!==void 0){let y=R.settings(P,{card:C,base:V(P,B),values:t.settings},o);if(y.error)return y;P=y.text,B=I(P).cards.find(K=>K.id===C)}return{text:P,extra:{card:C,html:P.slice(B.start,B.end),measure:k.measured&&t.h===void 0,pushed:[...Z.keys()]}}},remove(f,t){let{card:o,error:d}=E(f,t);if(d)return{error:d};let{text:p,html:l}=Be(f,o.id);return{text:p,extra:{removed:{id:o.id,board:o.board,html:l}}}},edit(f,t,{packages:o,slug:d}){let{card:p,error:l}=E(f,t);if(l)return{error:l};let u=t.parts!==void 0?t.parts:typeof t.part=="string"?{[t.part]:t.html}:null;if(!u||typeof u!="object"||Array.isArray(u)||Object.keys(u).length===0)return{error:x(400,"part")};let w=Object.fromEntries(Object.entries(u).map(([k,$])=>[k,Ft($,d)])),m=F(f,p,w,o);return m.error?m:{text:m.text,extra:{parts:T(m.parts,d)}}},settings(f,t,{packages:o,slug:d}){let{card:p,error:l}=E(f,t);if(l)return{error:l};let u=o.get(p.block),w=u?.settings??[];if(!u||w.length===0)return{error:x(409,"settings")};let m=t.values;if(!m||typeof m!="object"||Array.isArray(m))return{error:x(400,"values")};for(let[L,J]of Object.entries(m)){let A=w.find(G=>G.key===L);if(!A||!Rt(J,A))return{error:x(400,"values",L)}}let k=_(f,p,o)[Q];if(k===void 0)return{error:x(409,"settings")};let $={};try{$=k.trim()?JSON.parse(k):{}}catch{$={}}(!$||typeof $!="object"||Array.isArray($))&&($={});let c={...$,...m};if(JSON.stringify(c)===JSON.stringify($))return{text:f,extra:{parts:T({[Q]:{was:k,now:k}},d)}};let b=k.trim()?bt(k,c):JSON.stringify(c),C=F(f,p,{[Q]:b},o);return C.error?C:{text:C.text,extra:{parts:T(C.parts,d)}}},async"restore-defaults"(f,t,o){if(!Pt(o.slug,e))return{error:x(409,"defaults")};let d=new Set(I(f).cards.map(w=>w.block)),p=f,l=[],u=[];for(let w of Ct){if(d.has(w))continue;let[m,k]=It[w]??[],$=await R.add(p,{op:"add",block:w,...m?{w:m,h:k}:{}},o),c=o.packages.get(w)?.name??X(a).find(({id:b})=>b===w)?.title??null;if($.error){u.push({block:w,reason:$.error[1].reason,name:c});continue}p=$.text,l.push({card:$.extra.card,block:w,html:$.extra.html,name:c})}return{text:p,extra:{added:l,skipped:u}}}};function ct(f,t,{boards:o,cards:d}){if(typeof t.html!="string"||t.html.length>11e5)return{error:x(400,"html")};let p=t.html.trim(),l=Ge(p);if(!l)return{error:x(400,"html")};let u=Ve(l.node.tagName,l.node.attrs??[]);if(Tt(l.node,A=>{u||=Ve(A.tagName,A.attrs??[])}),u)return{error:x(400,"html")};let w=o.find(A=>A.id===(typeof t.board=="string"?t.board:Qe))??o[0];if(!w)return{error:x(409,"board")};if(t.x!==void 0&&!U(t.x)||t.y!==void 0&&!U(t.y))return{error:x(400,"cells")};let m=d.map(A=>A.id),k=l.id&&!m.includes(l.id)&&q.test(l.id)?l.id:fe(m),$=he({x:t.x??l.x,y:t.y??l.y,w:l.w,h:l.h}),c=w.cards.map(({id:A,x:G,y:Z,w:P,h:B})=>({id:A,x:G,y:Z,w:P,h:B})),b=ue(f,w.id,Ke(p,{id:k,...$})),C=j(c,ge(c,{id:k,...$}).filter(A=>A.id!==k)),L=Y(b.text,C),J=I(L).cards.find(A=>A.id===k);return{text:L,extra:{card:k,html:L.slice(J.start,J.end),pushed:[...C.keys()]}}}async function be(f,t,{by:o}={}){if(!t||typeof t!="object"||!Ht.includes(t.op))return x(400,"op");if(t.workspace!==void 0&&(typeof t.workspace!="string"||!_t(t.workspace,e)))return x(409,"elsewhere","\u8FD9\u4E2A\u9884\u89C8\u670D\u52A1\u5668\u7BA1\u7684\u662F\u53E6\u4E00\u4E2A\u76EE\u5F55\u7684\u6587\u6863");if(!we(f,e))return x(404,"missing");let d=jt(f,e);for(let p=0;p<3;p++){let[l,u]=await Promise.all([z.readFile(d.html,"utf8").catch(()=>null),z.readFile(d.json,"utf8").catch(()=>"")]);if(l===null)return x(404,"missing");if(Buffer.byteLength(l)>1e6)return x(413,"size");let w=Xe(l,u),m=W(l).text,k=i(),$={slug:f,get catalog(){return k},get packages(){return k.packages},refresh:()=>{k=i()}},c=await R[t.op](m,t,$);if(c.error)return c.error;let b=c.text;if(Buffer.byteLength(b)>1e6)return x(413,"size");if(b!==l){if(await S(f,l),!await Ye(d.html,b,{expect:l}))continue;await v(f,{op:t.op,by:o==="gallery"?"gallery":t.agent===!0?"agent":"page",cards:Je(l,b)})}return t.op==="restore-defaults"&&await qe(e).catch(()=>{}),[200,{ok:!0,version:Xe(b,u),before:w,cards:Re(b),...c.extra??{}}]}return x(409,"busy")}function Se(f="zh"){oe(e,{directory:a,log:h}).updated.length>0&&s();let t=i(),o=[...t.settings.packsOff??[],...ve(e,t.settings.packs)],d=c=>c.split("/")[0],p=c=>!t.settings.unlisted.includes(c)&&!o.includes(d(c)),l=c=>t.packs?.get(d(c))??u(d(c)),u=c=>{try{return Nt(pe(H.join(a??vt,c,Et),"utf8")).name}catch{return null}},w=[...t.packages.values()].filter(c=>c.places.includes("page")&&p(c.id)).map(c=>({id:c.id,name:c.name,description:c.description,preview:c.files.includes("preview.svg")?je(c,"preview.svg"):null,size:me(c.card),installed:!0,settings:c.settings.length>0,pack:{id:d(c.id),name:l(c.id)}}));for(let c of X(a)){if(!c.places.includes("page")||t.packages.has(c.id)||t.problems.has(c.id)||t.settings.disabled.includes(c.id)||!p(c.id)||ie(e,c).added)continue;let b=null;try{b=`data:image/svg+xml;base64,${pe(H.join(c.folder,"preview.svg")).toString("base64")}`}catch{}let C=null;try{C=JSON.parse(pe(H.join(c.folder,"component.json"),"utf8")).card??null}catch{}w.push({id:c.id,name:c.title,description:c.description,preview:b,size:me(C),installed:!1,settings:!1,pack:{id:c.pack,name:l(c.id)}})}let m=c=>c.name?.[f]??c.name?.zh??c.id,k=Ee(a),$=({pack:c})=>c.id===At?-1:k.includes(c.id)?k.indexOf(c.id):k.length;return w.sort((c,b)=>$(c)-$(b)||(c.pack.id===b.pack.id?0:c.pack.id<b.pack.id?-1:1)||m(c).localeCompare(m(b),"zh-CN")||(c.id<b.id?-1:1))}async function dt(f,t){return we(f,e)?(t?.cards===!0?await qe(e):await Lt(e,f),[200,{ok:!0}]):x(404,"missing")}function lt(f,t,o,d){if((d==="cards"||d==="hint")&&f.method==="POST")return n.respond(async l=>{let u=await n.check(l);return u.error?u.error:d==="hint"?dt(o,u.body):be(o,u.body)})(f,t);if(d==="library"&&f.method==="GET"){let l=f.headers.host??"",u=f.socket.localPort;if(l!==`127.0.0.1:${u}`&&l!==`localhost:${u}`)return re(t,403,{ok:!1,reason:"host"});if(!we(o,e))return re(t,404,{ok:!1,reason:"missing"});let w=new URL(f.url??"/","http://localhost").searchParams.get("language")==="en"?"en":"zh";return re(t,200,{ok:!0,blocks:Se(w)})}let p=["cards","library","hint"].includes(d);return re(t,p?405:404,{ok:!1,reason:p?"method":"unknown"})}return{handle:lt,apply:be,library:Se}}import{readFileSync as ot}from"node:fs";import{writeAtomic as nt}from"../browser/shared/files.mjs";import{HOME as M,HOME_TITLE as Jt,createPage as Bt,hintOf as st,markHomeMade as at,pageExists as Oe,pageFiles as xe,pageSlugRefused as Wt,pagesSettings as Ut,writeHints as se}from"../browser/shared/pages.mjs";import{layoutOf as it,markerOf as Gt}from"../browser/shared/workspace.mjs";import{lineIconValue as Kt}from"../browser/shared/emoji/line-icons.mjs";var Vt="GALLERY_NO_DEFAULT_HOME",$e=Kt("house"),Yt="/icons/home-1_lightgray.svg",Zt=(e=process.env)=>!["","0","false",void 0].includes(e[Vt]);async function Hr(e,{shipped:n=void 0,stateDirectory:r=it(e).state,env:i=process.env}={}){if(Zt(i))return{did:"off"};let s={ours:!1};try{s=Gt(ot(it(e).marker,"utf8"))}catch{}if(!s.ours)return{did:"unread"};if(Ut(e).homeMade)return await Qt(e).catch(()=>{}),{did:"done"};let a="mark";try{if(Oe(M,e))return await at(e),await se(e,{homeAdopted:!0,homeLineIcon:!0}).catch(()=>{}),{did:"kept"};a="page";let h=await Wt(M,e);if(h)return{did:"taken",why:h};await Bt(M,Jt,{root:e,icon:$e,defaultCards:!0,hint:!0}),a="cards";let g=rt({root:e,edits:null,stateDirectory:r,catalog:()=>Ce(e),shipped:n}),[,O]=await g.apply(M,{op:"restore-defaults"},{by:"gallery"});return a="mark",await at(e),await se(e,{homeAdopted:!0,homeLineIcon:!0}).catch(()=>{}),{did:"made",file:xe(M,e).html,cards:(O.added??[]).map(({card:S})=>S),skipped:O.skipped??[]}}catch(h){return{did:"failed",stage:a,file:Oe(M,e)?xe(M,e).html:null,why:h?.message??String(h)}}}async function Qt(e){let n=!1,r=()=>{if(!Oe(M,e))return null;let{json:i}=xe(M,e);try{let s=ot(i,"utf8"),a=JSON.parse(s.replace(/^/,""));return a&&typeof a=="object"&&!Array.isArray(a)?{json:i,text:s,value:a}:null}catch{return null}};if(st(e,"homeAdopted")!==!0){let i=r();if(i&&!("defaultCards"in i.value)&&!("hint"in i.value)){let s={...i.value,...i.value.icon?{}:{icon:$e},defaultCards:!0,hint:!0};n=await nt(i.json,`${JSON.stringify(s,null,2)}
|
|
21
|
+
`,{expect:i.text})}await se(e,{homeAdopted:!0})}if(st(e,"homeLineIcon")!==!0){let i=r();i?.value.icon===Yt&&(n=await nt(i.json,`${JSON.stringify({...i.value,icon:$e},null,2)}
|
|
22
|
+
`,{expect:i.text})||n),await se(e,{homeLineIcon:!0})}return n}function Dr({stage:e,file:n,why:r}){return e==="mark"?`The default home page ${n} is there, but gallery.json could not say it was made (${r}); a later start tries again.`:e==="cards"?`The default home page ${n} was made without its cards (${r}): \u6062\u590D\u9ED8\u8BA4\u5361\u7247 in its menu in the sidebar puts them on.`:`The default home page was not made (${r}); a later start tries again.`}export{q as a,I as b,W as c,Me as d,ar as e,Ar as f,Er as g,rt as h,Zt as i,Hr as j,Dr as k};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{D as $,a as H,c as y,d as v,e as q,f as K,g as Y,i as V,k as X,o as z}from"./chunk-UBBRTJ2R.mjs";import{g as P}from"./chunk-FWNRPMCJ.mjs";import{b as S,e as U}from"./chunk-A55HN5OK.mjs";U();import{HOSTS as A,IDENTITY as dt}from"../browser/editor/components/registry.mjs";import{CODE as ut,MATH as tt,MEDIA as mt,PAGE as pt,TABLE as gt}from"../browser/editor/components/kit.mjs";import{TAB as ht}from"../browser/editor/components/paragraph/index.mjs";import{componentOf as Nt,isInstance as w,matchesNode as x,partOf as bt}from"../browser/shared/components/index.mjs";import{texSource as It}from"../browser/editor/components/math/index.mjs";import{MENTION as M,MENTION_ICON as J,MENTION_PAGE as Q}from"../browser/shared/components/mention.mjs";import{imageFile as et}from"../browser/shared/media.mjs";import{isFileLink as kt}from"../browser/shared/page-address.mjs";import{isInkClass as xt}from"../browser/editor/page/marks.mjs";import{ownInline as Tt}from"../browser/editor/page/own.mjs";import{attr as h,hasClass as Ot}from"../browser/shared/html-tree.mjs";var Lt=new Set(["h1","h2","h3","h4","p","li"]),Ct=new Set(["h3","h4","p","figcaption"]),Et=Object.entries(A).flatMap(([t,e])=>(e.parts??[]).map(([r,a])=>{let c=Nt(r);if(c?.parts?.[a]?.edit!=="text")throw new Error(`Host ${t}: ${r} has no part ${a} edited as text`);return{kind:t,match:c.match,at:c.parts[a].at}})),St=t=>Et.filter(({match:e})=>x(t,e)).flatMap(({kind:e,at:r})=>bt(t,r).map(a=>({kind:e,part:a}))),vt=t=>t.sort((e,r)=>e.part.sourceCodeLocation.startOffset-r.part.sourceCodeLocation.startOffset),$t=new Set(["strong","em","b","i","u","s","code","a","br","sup","sub"]),wt=new Set(["ul","ol","blockquote"]),_=new Set(["pre","summary","button","label","select","textarea","form","template","script","style","svg","math","iframe","object","noscript","canvas","video","audio"]),le={p:"p",h1:"p",h2:"p",h3:"p",h4:"p",li:"li"};function At(t,e,r){let a=A[t];if(!a)throw new Error(`Unknown block kind ${t}`);return a.caps({bound:r,blockLevel:y.has(e)})}var st=t=>t.tagName==="span"&&x(t,tt.inline),Bt=t=>t.tagName==="a"&&Ot(t,M),Pt=/^https?:\/\/[^\s"<>]+$/i,C=t=>t.attrs.map(e=>e.name).sort().join(),yt=t=>h(t,"class")===M&&t.childNodes.length===0&&(C(t)==="class"||C(t)===`class,${Q}`&&h(t,Q)==="");function _t(t){if(yt(t))return null;if(C(t)!=="class,href"||h(t,"class")!==M||!(Pt.test(h(t,"href"))||kt(h(t,"href"))))return"mention";let[e,...r]=t.childNodes;return(e?.tagName==="img"?C(e)==="alt,class,src"&&h(e,"class")===J&&h(e,"alt")===""&&et(h(e,"src")):e?.tagName==="span"&&C(e)==="class"&&h(e,"class")===J&&e.childNodes.length===0)&&r.length>0&&r.every(c=>c.nodeName==="#text")&&r.some(c=>c.value.trim())?null:"mention"}var Mt=t=>t.tagName==="span"&&t.attrs.length===1&&t.attrs[0].name==="class"&&t.attrs[0].value.trim().split(/\s+/).every(xt),jt=t=>t.tagName==="span"&&t.attrs.length===1&&t.attrs[0].name==="class"&&t.attrs[0].value===ht,ot=t=>$t.has(t.tagName)||Mt(t)||jt(t),B=t=>(t.childNodes??[]).some(e=>e.nodeName==="#text"?e.value.trim()!=="":B(e)),at=t=>Tt(t.tagName,t.attrs,B(t)),Z=t=>t.attrs.some(e=>e.name==="id"||e.name.startsWith("data-")&&e.name!==dt),Wt=t=>/^(javascript|vbscript|data):/i.test(t.replace(/[\u0000- ]/g,"")),Dt=(t,e,r={})=>t==="text"?y.has(e)?!1:"atoms":t==="title"||t==="code"||t==="codeTitle"||t==="tex"||!!r.plain;function j(t,e,r=!1,{cell:a=!1,pictures:c=a,known:l=null}={}){for(let n of t.childNodes){if(n.nodeName==="#text")continue;if(!n.tagName)return"comment";if(r===!0)return`tag:${n.tagName}`;if(n.attrs.some(m=>/^on/i.test(m.name)))return"markup";if(r==="atoms"){if(!n.sourceCodeLocation?.endTag&&n.tagName!=="br")return"markup";if(l&&!l(n.sourceCodeLocation))return`tag:${n.tagName}`;e.push(n.sourceCodeLocation);continue}if(a&&(n.tagName==="ul"||n.tagName==="ol")){let m=Ut(n,e,l);if(m)return m;continue}if(c&&n.tagName==="img"){if(Ft(n))return"picture";continue}if(st(n)){if(n.childNodes.some(m=>m.nodeName!=="#text"))return"markup";e.push(n.sourceCodeLocation);continue}if(Bt(n)){let m=_t(n);if(m)return m;e.push(n.sourceCodeLocation);continue}if(at(n)){if(!n.sourceCodeLocation?.endTag)return"markup";if(l&&!l(n.sourceCodeLocation))return`tag:${n.tagName}`;e.push(n.sourceCodeLocation);continue}if(!ot(n))return`tag:${n.tagName}`;if(n.tagName!=="br"&&!n.sourceCodeLocation?.endTag)return"markup";if(n.tagName==="a"&&Wt(h(n,"href")??""))return"link";let N=j(n,e,!1,{known:l,pictures:c});if(N)return N}return null}var Gt=["src","alt","width"],Rt=/^[1-9]\d{0,3}$/;function Ft(t){let r=t.attrs.map(l=>l.name).find(l=>!Gt.includes(l));if(r)return`the attribute ${r}`;let a=h(t,"src");if(!et(a))return`its src (${a===void 0?"none":a.slice(0,80)}): no picture of the document's assets/ folder`;let c=h(t,"width");return c===void 0||Rt.test(c)?null:`its width (${c}): a whole number of pixels`}function Ut(t,e,r){if(t.attrs.length>0||!t.sourceCodeLocation?.endTag)return"markup";for(let a of t.childNodes){if(a.nodeName==="#text"&&!a.value.trim())continue;if(a.tagName!=="li")return`tag:${a.tagName??"text"}`;if(a.attrs.length>0||!a.sourceCodeLocation?.endTag)return"markup";let c=j(a,e,!1,{known:r,pictures:!0});if(c)return c}return null}function T(t){let e=[],r=[],a=new Map,c=null,l=(o,s,i=null)=>{let u=o.sourceCodeLocation;if(!A[s]||!u?.startTag||h(o,"contenteditable")!==void 0)return!1;let k=[],f=Dt(s,o.tagName),p=i?{childNodes:o.childNodes.slice(0,o.childNodes.indexOf(i))}:o,G=u.endTag?j(p,k,f,{cell:s==="cell"}):"markup";if(G)return r.push({at:u.startTag.endOffset-1,reason:G}),!1;let L=u.startTag.endOffset,ft=i?L+t.slice(L,i.sourceCodeLocation.startOffset).replace(/[ \t\r\n\f]+$/,"").length:u.endTag.startOffset,R={id:e.length,tag:o.tagName,kind:s,bound:!1,caps:{},start:u.startOffset,end:u.endOffset,innerStart:L,innerEnd:ft,atoms:k.map(F=>[F.startOffset-L,F.endOffset-L]),wrapper:null,nested:!!i,node:o};return e.push(R),a.set(o,R),!0},n=o=>(o.childNodes??[]).filter(s=>s.tagName),N=o=>{let s=o.sourceCodeLocation;return s?.startTag&&s.endTag?t.slice(s.startTag.endOffset,s.endTag.startOffset):null},m=o=>o.tagName!=="a"&&!Z(o)&&B(o)&&n(o).every(s=>at(s)?!B(s):ot(s)||st(s)),I=o=>{for(let s of n(o))s.tagName==="td"||s.tagName==="th"?l(s,"cell"):["thead","tbody","tfoot","tr"].includes(s.tagName)&&I(s)},d=o=>{for(let s of n(o))s.tagName==="table"?I(s):!_.has(s.tagName)&&!w(s)&&d(s)},b=o=>{let s=n(o);s.length===1&&s[0].tagName==="code"&&o.childNodes.every(i=>i.tagName||!i.value?.trim())?l(s[0],"code"):s.length===0?l(o,"code"):o.sourceCodeLocation?.startTag&&r.push({at:o.sourceCodeLocation.startTag.endOffset-1,reason:"markup"})},g=(o,s=!0)=>{for(let i of n(o)){let u=i.tagName,k=w(i);for(let{kind:f,part:p}of vt(k?$[V(i)].textParts(i,c??=P().packages):St(i)))l(p,f);if(k){for(let{element:f}of Y(i))g(f,s);continue}if(u==="div"&&x(i,ut.match)){for(let f of n(i))f.tagName==="pre"&&h(f,"contenteditable")===void 0&&b(f);continue}if(!(_.has(u)||h(i,"contenteditable")!==void 0))if(u==="table")I(i);else if(u==="figure"){let f=x(i,mt);for(let p of n(i))if(!(f&&p.tagName==="figcaption"))if(Ct.has(p.tagName))l(p,"field");else if(p.tagName==="table")I(p);else{if(_.has(p.tagName))continue;w(p)?g({childNodes:[p]},s):f||v(p)||Z(p)?d(p):g({childNodes:[p]},s)}}else if(u==="details")for(let f of n(i))w(f)?g({childNodes:[f]},s):f.tagName!=="summary"&&g(f,s);else if(u==="h1"&&(o.tagName==="header"||x(i,pt.title)))l(i,"title");else if(u==="li"&&K(i))g({childNodes:n(i)},s);else if(Lt.has(u)){let f=u==="li"?q(i):[];f?.length>0?(l(i,"flow",f[0]),g({childNodes:f},s)):l(i,"flow")||g(i,!1)}else if(u==="div"&&x(i,tt.block)&&n(i).length===0&&It(N(i)))l(i,"tex");else if(u==="div"&&x(i,gt.lead))for(let f of n(i))f.tagName==="span"&&l(f,"field");else s&&!v(i)&&m(i)?l(i,"text"):(g(i,s&&!v(i)),wt.has(u)&&it(i))}},it=o=>{let s=o.sourceCodeLocation,i=n(o).map(f=>a.get(f));if(!(i.length>0&&i.every(Boolean)&&o.childNodes.every(f=>f.tagName||f.nodeName==="#text"&&!f.value.trim()))||!s?.endTag)return;let k={start:s.startOffset,end:s.endOffset,ids:i.map(f=>f.id)};i.forEach(f=>f.wrapper=k)},W=o=>{for(let s of n(o))(s.tagName==="main"?g:W)(s)},D=S(t,{sourceCodeLocationInfo:!0});W(D);let{units:E,boxes:ct,referenced:lt}=X(D,t);for(let o of E)o.grid=!!$[o.kind]?.plain?.(o.node);for(let o of E){let s=$[o.kind]?.dataOf?.(t,o.node,c??=P().packages);s&&(o.parts=Object.fromEntries(Object.entries(s).map(([i,u])=>[i,H(u)])))}for(let o of e){let s=null;for(let i of E)i.start<=o.start&&o.start<i.end&&(!s||i.start>s.start)&&(s=i);o.unit=s?.id??null,o.self=s&&s.at===o.innerStart-1?s.id:null,o.self!==null&&(s.text=o.id),o.path=s&&o.self===null?Ht(s,o.node):null,A.text&&o.kind==="flow"&&o.self===null&&(s?.kind==="block"||s?.kind==="figure")&&(o.kind="text"),o.bound=lt(o.node)!==null,o.caps=Object.fromEntries(At(o.kind,o.tag,o.bound).map(i=>[i,!0]))}return{blocks:e,locks:r,units:E,boxes:ct}}function Ht(t,e){let r=[],a=e;for(;a&&!t.nodes.includes(a);a=a.parentNode){let c=(a.parentNode?.childNodes??[]).filter(l=>l.tagName===a.tagName);r.unshift([a.tagName,c.indexOf(a),c.length])}return a?[a===t.node?"unit":a===t.nodes[0]&&t.lead!==null?"lead":"panel",...r]:null}var fe=t=>T(t).blocks;function de(t){let{units:e,boxes:r}=T(t);return{units:e,boxes:r}}U();import{randomBlockId as qt}from"../browser/shared/ids.mjs";import{IDENTITY as O}from"../browser/editor/components/registry.mjs";var Kt=/\sdata-block-id\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;function be(t,e=qt){let{units:r}=T(t),a=new Set([...t.matchAll(Kt)].map(d=>d[1]??d[2])),c=()=>{for(;;){let d=e();if(!a.has(d))return a.add(d)&&d}},l=new Set,n=[],N=[],m=[];for(let d of r)if(d.blockId)l.has(d.blockId)&&d.blockIdAttr?(N.push(d.blockId),n.push({start:d.blockIdAttr.start,end:d.blockIdAttr.end,text:`${O}="${c()}"`})):l.add(d.blockId);else{let b=c();if(d.blockIdAttr)n.push({start:d.blockIdAttr.start,end:d.blockIdAttr.end,text:`${O}="${b}"`});else{let g=z(t,d.at);n.push({start:g,end:g,text:` ${O}="${b}"`})}m.push({id:b,tag:rt(d.tag,d.attrs),at:d.elStart})}let I=t;for(let d of n.sort((b,g)=>g.start-b.start))I=I.slice(0,d.start)+d.text+I.slice(d.end);return m.sort((d,b)=>d.at-b.at),{text:I,added:m.length,renamed:N,given:m.map(({id:d,tag:b})=>({id:d,tag:b}))}}function Ie(t){let e=nt(t);return T(t).units.filter(r=>!r.blockId).sort((r,a)=>r.elStart-a.elStart).map(r=>({line:e(r.elStart),tag:rt(r.tag,r.attrs)}))}function ke(t,e){let r=new Map(e.map(c=>[c.id,c])),a=nt(t);return T(t).units.filter(c=>r.has(c.blockId)).sort((c,l)=>c.elStart-l.elStart).map(c=>({...r.get(c.blockId),line:a(c.elStart)}))}function nt(t){let e=[0];for(let r=t.indexOf(`
|
|
2
|
+
import{D as $,a as H,c as y,d as v,e as q,f as K,g as Y,i as V,k as X,o as z}from"./chunk-VS7JIGJW.mjs";import{g as P}from"./chunk-HDWTZ763.mjs";import{b as S,e as U}from"./chunk-A55HN5OK.mjs";U();import{HOSTS as A,IDENTITY as dt}from"../browser/editor/components/registry.mjs";import{CODE as ut,MATH as tt,MEDIA as mt,PAGE as pt,TABLE as gt}from"../browser/editor/components/kit.mjs";import{TAB as ht}from"../browser/editor/components/paragraph/index.mjs";import{componentOf as Nt,isInstance as w,matchesNode as x,partOf as bt}from"../browser/shared/components/index.mjs";import{texSource as It}from"../browser/editor/components/math/index.mjs";import{MENTION as M,MENTION_ICON as J,MENTION_PAGE as Q}from"../browser/shared/components/mention.mjs";import{imageFile as et}from"../browser/shared/media.mjs";import{isFileLink as kt}from"../browser/shared/page-address.mjs";import{isInkClass as xt}from"../browser/editor/page/marks.mjs";import{ownInline as Tt}from"../browser/editor/page/own.mjs";import{attr as h,hasClass as Ot}from"../browser/shared/html-tree.mjs";var Lt=new Set(["h1","h2","h3","h4","p","li"]),Ct=new Set(["h3","h4","p","figcaption"]),Et=Object.entries(A).flatMap(([t,e])=>(e.parts??[]).map(([r,a])=>{let c=Nt(r);if(c?.parts?.[a]?.edit!=="text")throw new Error(`Host ${t}: ${r} has no part ${a} edited as text`);return{kind:t,match:c.match,at:c.parts[a].at}})),St=t=>Et.filter(({match:e})=>x(t,e)).flatMap(({kind:e,at:r})=>bt(t,r).map(a=>({kind:e,part:a}))),vt=t=>t.sort((e,r)=>e.part.sourceCodeLocation.startOffset-r.part.sourceCodeLocation.startOffset),$t=new Set(["strong","em","b","i","u","s","code","a","br","sup","sub"]),wt=new Set(["ul","ol","blockquote"]),_=new Set(["pre","summary","button","label","select","textarea","form","template","script","style","svg","math","iframe","object","noscript","canvas","video","audio"]),le={p:"p",h1:"p",h2:"p",h3:"p",h4:"p",li:"li"};function At(t,e,r){let a=A[t];if(!a)throw new Error(`Unknown block kind ${t}`);return a.caps({bound:r,blockLevel:y.has(e)})}var st=t=>t.tagName==="span"&&x(t,tt.inline),Bt=t=>t.tagName==="a"&&Ot(t,M),Pt=/^https?:\/\/[^\s"<>]+$/i,C=t=>t.attrs.map(e=>e.name).sort().join(),yt=t=>h(t,"class")===M&&t.childNodes.length===0&&(C(t)==="class"||C(t)===`class,${Q}`&&h(t,Q)==="");function _t(t){if(yt(t))return null;if(C(t)!=="class,href"||h(t,"class")!==M||!(Pt.test(h(t,"href"))||kt(h(t,"href"))))return"mention";let[e,...r]=t.childNodes;return(e?.tagName==="img"?C(e)==="alt,class,src"&&h(e,"class")===J&&h(e,"alt")===""&&et(h(e,"src")):e?.tagName==="span"&&C(e)==="class"&&h(e,"class")===J&&e.childNodes.length===0)&&r.length>0&&r.every(c=>c.nodeName==="#text")&&r.some(c=>c.value.trim())?null:"mention"}var Mt=t=>t.tagName==="span"&&t.attrs.length===1&&t.attrs[0].name==="class"&&t.attrs[0].value.trim().split(/\s+/).every(xt),jt=t=>t.tagName==="span"&&t.attrs.length===1&&t.attrs[0].name==="class"&&t.attrs[0].value===ht,ot=t=>$t.has(t.tagName)||Mt(t)||jt(t),B=t=>(t.childNodes??[]).some(e=>e.nodeName==="#text"?e.value.trim()!=="":B(e)),at=t=>Tt(t.tagName,t.attrs,B(t)),Z=t=>t.attrs.some(e=>e.name==="id"||e.name.startsWith("data-")&&e.name!==dt),Wt=t=>/^(javascript|vbscript|data):/i.test(t.replace(/[\u0000- ]/g,"")),Dt=(t,e,r={})=>t==="text"?y.has(e)?!1:"atoms":t==="title"||t==="code"||t==="codeTitle"||t==="tex"||!!r.plain;function j(t,e,r=!1,{cell:a=!1,pictures:c=a,known:l=null}={}){for(let n of t.childNodes){if(n.nodeName==="#text")continue;if(!n.tagName)return"comment";if(r===!0)return`tag:${n.tagName}`;if(n.attrs.some(m=>/^on/i.test(m.name)))return"markup";if(r==="atoms"){if(!n.sourceCodeLocation?.endTag&&n.tagName!=="br")return"markup";if(l&&!l(n.sourceCodeLocation))return`tag:${n.tagName}`;e.push(n.sourceCodeLocation);continue}if(a&&(n.tagName==="ul"||n.tagName==="ol")){let m=Ut(n,e,l);if(m)return m;continue}if(c&&n.tagName==="img"){if(Ft(n))return"picture";continue}if(st(n)){if(n.childNodes.some(m=>m.nodeName!=="#text"))return"markup";e.push(n.sourceCodeLocation);continue}if(Bt(n)){let m=_t(n);if(m)return m;e.push(n.sourceCodeLocation);continue}if(at(n)){if(!n.sourceCodeLocation?.endTag)return"markup";if(l&&!l(n.sourceCodeLocation))return`tag:${n.tagName}`;e.push(n.sourceCodeLocation);continue}if(!ot(n))return`tag:${n.tagName}`;if(n.tagName!=="br"&&!n.sourceCodeLocation?.endTag)return"markup";if(n.tagName==="a"&&Wt(h(n,"href")??""))return"link";let N=j(n,e,!1,{known:l,pictures:c});if(N)return N}return null}var Gt=["src","alt","width"],Rt=/^[1-9]\d{0,3}$/;function Ft(t){let r=t.attrs.map(l=>l.name).find(l=>!Gt.includes(l));if(r)return`the attribute ${r}`;let a=h(t,"src");if(!et(a))return`its src (${a===void 0?"none":a.slice(0,80)}): no picture of the document's assets/ folder`;let c=h(t,"width");return c===void 0||Rt.test(c)?null:`its width (${c}): a whole number of pixels`}function Ut(t,e,r){if(t.attrs.length>0||!t.sourceCodeLocation?.endTag)return"markup";for(let a of t.childNodes){if(a.nodeName==="#text"&&!a.value.trim())continue;if(a.tagName!=="li")return`tag:${a.tagName??"text"}`;if(a.attrs.length>0||!a.sourceCodeLocation?.endTag)return"markup";let c=j(a,e,!1,{known:r,pictures:!0});if(c)return c}return null}function T(t){let e=[],r=[],a=new Map,c=null,l=(o,s,i=null)=>{let u=o.sourceCodeLocation;if(!A[s]||!u?.startTag||h(o,"contenteditable")!==void 0)return!1;let k=[],f=Dt(s,o.tagName),p=i?{childNodes:o.childNodes.slice(0,o.childNodes.indexOf(i))}:o,G=u.endTag?j(p,k,f,{cell:s==="cell"}):"markup";if(G)return r.push({at:u.startTag.endOffset-1,reason:G}),!1;let L=u.startTag.endOffset,ft=i?L+t.slice(L,i.sourceCodeLocation.startOffset).replace(/[ \t\r\n\f]+$/,"").length:u.endTag.startOffset,R={id:e.length,tag:o.tagName,kind:s,bound:!1,caps:{},start:u.startOffset,end:u.endOffset,innerStart:L,innerEnd:ft,atoms:k.map(F=>[F.startOffset-L,F.endOffset-L]),wrapper:null,nested:!!i,node:o};return e.push(R),a.set(o,R),!0},n=o=>(o.childNodes??[]).filter(s=>s.tagName),N=o=>{let s=o.sourceCodeLocation;return s?.startTag&&s.endTag?t.slice(s.startTag.endOffset,s.endTag.startOffset):null},m=o=>o.tagName!=="a"&&!Z(o)&&B(o)&&n(o).every(s=>at(s)?!B(s):ot(s)||st(s)),I=o=>{for(let s of n(o))s.tagName==="td"||s.tagName==="th"?l(s,"cell"):["thead","tbody","tfoot","tr"].includes(s.tagName)&&I(s)},d=o=>{for(let s of n(o))s.tagName==="table"?I(s):!_.has(s.tagName)&&!w(s)&&d(s)},b=o=>{let s=n(o);s.length===1&&s[0].tagName==="code"&&o.childNodes.every(i=>i.tagName||!i.value?.trim())?l(s[0],"code"):s.length===0?l(o,"code"):o.sourceCodeLocation?.startTag&&r.push({at:o.sourceCodeLocation.startTag.endOffset-1,reason:"markup"})},g=(o,s=!0)=>{for(let i of n(o)){let u=i.tagName,k=w(i);for(let{kind:f,part:p}of vt(k?$[V(i)].textParts(i,c??=P().packages):St(i)))l(p,f);if(k){for(let{element:f}of Y(i))g(f,s);continue}if(u==="div"&&x(i,ut.match)){for(let f of n(i))f.tagName==="pre"&&h(f,"contenteditable")===void 0&&b(f);continue}if(!(_.has(u)||h(i,"contenteditable")!==void 0))if(u==="table")I(i);else if(u==="figure"){let f=x(i,mt);for(let p of n(i))if(!(f&&p.tagName==="figcaption"))if(Ct.has(p.tagName))l(p,"field");else if(p.tagName==="table")I(p);else{if(_.has(p.tagName))continue;w(p)?g({childNodes:[p]},s):f||v(p)||Z(p)?d(p):g({childNodes:[p]},s)}}else if(u==="details")for(let f of n(i))w(f)?g({childNodes:[f]},s):f.tagName!=="summary"&&g(f,s);else if(u==="h1"&&(o.tagName==="header"||x(i,pt.title)))l(i,"title");else if(u==="li"&&K(i))g({childNodes:n(i)},s);else if(Lt.has(u)){let f=u==="li"?q(i):[];f?.length>0?(l(i,"flow",f[0]),g({childNodes:f},s)):l(i,"flow")||g(i,!1)}else if(u==="div"&&x(i,tt.block)&&n(i).length===0&&It(N(i)))l(i,"tex");else if(u==="div"&&x(i,gt.lead))for(let f of n(i))f.tagName==="span"&&l(f,"field");else s&&!v(i)&&m(i)?l(i,"text"):(g(i,s&&!v(i)),wt.has(u)&&it(i))}},it=o=>{let s=o.sourceCodeLocation,i=n(o).map(f=>a.get(f));if(!(i.length>0&&i.every(Boolean)&&o.childNodes.every(f=>f.tagName||f.nodeName==="#text"&&!f.value.trim()))||!s?.endTag)return;let k={start:s.startOffset,end:s.endOffset,ids:i.map(f=>f.id)};i.forEach(f=>f.wrapper=k)},W=o=>{for(let s of n(o))(s.tagName==="main"?g:W)(s)},D=S(t,{sourceCodeLocationInfo:!0});W(D);let{units:E,boxes:ct,referenced:lt}=X(D,t);for(let o of E)o.grid=!!$[o.kind]?.plain?.(o.node);for(let o of E){let s=$[o.kind]?.dataOf?.(t,o.node,c??=P().packages);s&&(o.parts=Object.fromEntries(Object.entries(s).map(([i,u])=>[i,H(u)])))}for(let o of e){let s=null;for(let i of E)i.start<=o.start&&o.start<i.end&&(!s||i.start>s.start)&&(s=i);o.unit=s?.id??null,o.self=s&&s.at===o.innerStart-1?s.id:null,o.self!==null&&(s.text=o.id),o.path=s&&o.self===null?Ht(s,o.node):null,A.text&&o.kind==="flow"&&o.self===null&&(s?.kind==="block"||s?.kind==="figure")&&(o.kind="text"),o.bound=lt(o.node)!==null,o.caps=Object.fromEntries(At(o.kind,o.tag,o.bound).map(i=>[i,!0]))}return{blocks:e,locks:r,units:E,boxes:ct}}function Ht(t,e){let r=[],a=e;for(;a&&!t.nodes.includes(a);a=a.parentNode){let c=(a.parentNode?.childNodes??[]).filter(l=>l.tagName===a.tagName);r.unshift([a.tagName,c.indexOf(a),c.length])}return a?[a===t.node?"unit":a===t.nodes[0]&&t.lead!==null?"lead":"panel",...r]:null}var fe=t=>T(t).blocks;function de(t){let{units:e,boxes:r}=T(t);return{units:e,boxes:r}}U();import{randomBlockId as qt}from"../browser/shared/ids.mjs";import{IDENTITY as O}from"../browser/editor/components/registry.mjs";var Kt=/\sdata-block-id\s*=\s*(?:"([^"]*)"|'([^']*)')/gi;function be(t,e=qt){let{units:r}=T(t),a=new Set([...t.matchAll(Kt)].map(d=>d[1]??d[2])),c=()=>{for(;;){let d=e();if(!a.has(d))return a.add(d)&&d}},l=new Set,n=[],N=[],m=[];for(let d of r)if(d.blockId)l.has(d.blockId)&&d.blockIdAttr?(N.push(d.blockId),n.push({start:d.blockIdAttr.start,end:d.blockIdAttr.end,text:`${O}="${c()}"`})):l.add(d.blockId);else{let b=c();if(d.blockIdAttr)n.push({start:d.blockIdAttr.start,end:d.blockIdAttr.end,text:`${O}="${b}"`});else{let g=z(t,d.at);n.push({start:g,end:g,text:` ${O}="${b}"`})}m.push({id:b,tag:rt(d.tag,d.attrs),at:d.elStart})}let I=t;for(let d of n.sort((b,g)=>g.start-b.start))I=I.slice(0,d.start)+d.text+I.slice(d.end);return m.sort((d,b)=>d.at-b.at),{text:I,added:m.length,renamed:N,given:m.map(({id:d,tag:b})=>({id:d,tag:b}))}}function Ie(t){let e=nt(t);return T(t).units.filter(r=>!r.blockId).sort((r,a)=>r.elStart-a.elStart).map(r=>({line:e(r.elStart),tag:rt(r.tag,r.attrs)}))}function ke(t,e){let r=new Map(e.map(c=>[c.id,c])),a=nt(t);return T(t).units.filter(c=>r.has(c.blockId)).sort((c,l)=>c.elStart-l.elStart).map(c=>({...r.get(c.blockId),line:a(c.elStart)}))}function nt(t){let e=[0];for(let r=t.indexOf(`
|
|
3
3
|
`);r!==-1;r=t.indexOf(`
|
|
4
4
|
`,r+1))e.push(r+1);return r=>{let[a,c]=[0,e.length-1];for(;a<c;){let l=a+c+1>>1;e[l]<=r?a=l:c=l-1}return a+1}}function rt(t,e=[]){let r=e.filter(({name:l})=>l!==O&&l!=="style"),a=l=>{let n=l.replace(/\s+/g," "),N=n.length>32?`${n.slice(0,31)}\u2026`:n;return N===""?"":/[\s"'=<>`]/.test(N)?`="${N.replaceAll('"',""")}"`:`=${N}`},c=r.slice(0,3).map(({name:l,value:n})=>`${l}${a(n)}`);return`<${[t,...c,...r.length>3?["\u2026"]:[]].join(" ")}>`}function xe(t){let e=new Map,r=a=>{let c=a.attrs?.find(n=>n.name===O)?.value,l=a.sourceCodeLocation?.attrs?.[O]??a.sourceCodeLocation;c!==void 0&&e.set(c,[...e.get(c)??[],l]);for(let n of a.content?.childNodes??a.childNodes??[])r(n)};return r(S(t,{sourceCodeLocationInfo:!0})),[...e].filter(([,a])=>a.length>1).map(([a,c])=>({id:a,lines:c.map(l=>l?.startLine),columns:c.map(l=>l?.startCol)}))}export{le as a,Dt as b,j as c,Ft as d,T as e,fe as f,de as g,qt as h,Kt as i,be as j,Ie as k,ke as l,xe as m};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{g as St,r as nt,t as Ct}from"./chunk-FWNRPMCJ.mjs";import{a as Lt,b as st,c as z,e as vt}from"./chunk-A55HN5OK.mjs";import{createHash as Ee}from"node:crypto";import{BLOCK_LEVEL as ot}from"../browser/shared/html-tree.mjs";var wt=t=>Ee("sha256").update(t).digest("hex").slice(0,16),M=t=>t.nodeName==="#text"&&!t.value.trim();function at(t,e){for(let s of t.childNodes??[]){if(s.tagName===e)return s;let o=s.tagName&&at(s,e);if(o)return o}return null}import{ATTRIBUTES as an,BOX_CLASSES as on,COMPONENT_ATTRIBUTES as rn,COMPONENT_CLASSES as cn,GROUPING as ln,IDENTITY as R,TOGGLES as fn,UNIT_KINDS as dn}from"../browser/editor/components/registry.mjs";import{attr as I,hasClass as kt}from"../browser/shared/html-tree.mjs";import{idsNamed as un}from"../browser/shared/copy-ids.mjs";import{DIALOG as pn,PAGE as mn,SECTION as gn,SHEETS as K,TABLE as Le}from"../browser/editor/components/kit.mjs";import{matchesNode as q,partOf as bt}from"../browser/shared/components/index.mjs";import{escapeMarkup as V}from"../browser/shared/escape.mjs";import{imageFile as Ae}from"../browser/shared/media.mjs";import{emptyFigure as Ie}from"../browser/editor/components/media/write.mjs";var _e=t=>typeof t=="string"&&t.length<=2e3&&/^https?:\/\/[^\s"<>]+$/.test(t),Et=(t,e)=>typeof t=="string"&&t.length<=e&&!/[\u0000-\u001f]/.test(t),At=t=>t.href===""&&!t.title&&!t.description&&!t.icon&&!t.cover&&t.caption==="",It=t=>t==null||Ae(t),_t={bookmark:{check:(t,{validLeaf:e})=>At(t)||_e(t.href)&&Et(t.title,300)&&Et(t.description??"",600)&&It(t.icon)&&It(t.cover)&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(At(t))return Ie("bookmark",e);let s=t.title.trim()||new URL(t.href).hostname,o=[`<span class="doc-bookmark-title">${V(s)}</span>`,t.description?`<span class="doc-bookmark-description">${V(t.description)}</span>`:"",`<span class="doc-bookmark-url">${t.icon?`<img class="doc-bookmark-icon" src="${t.icon}" alt="">`:""}<span class="doc-bookmark-href">${V(t.href)}</span></span>`].join(""),n=t.cover?`<span class="doc-bookmark-cover"><img src="${t.cover}" alt=""></span>`:"",a=`<a class="doc-bookmark-card" href="${V(t.href)}" target="_blank" rel="noopener noreferrer"><span class="doc-bookmark-text">${o}</span>${n}</a>`;return e.block(`<figure class="doc-bookmark"${e.id}>`,[a,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{BLOCK_TYPES as Be,sizeValue as Me}from"../browser/editor/components/registry.mjs";import{LINE_START as Mt,lineStart as je}from"../browser/shared/code-lines.mjs";import{hasClass as Bt}from"../browser/shared/html-tree.mjs";import{CODE_HEIGHT as rt,FOLDED_LINES as jt,validFolded as Re,validLanguage as De}from"../browser/editor/components/code/index.mjs";var ze=(t,e,s,o,n="",a="",r="",i="")=>`<div class="${t.className}"${s?` data-language="${s}"`:""}${i?` ${Mt}="${i}"`:""}${r?` ${jt}="${r}"`:""}${o?` style="${rt}: ${o}"`:""}${n}><div class="doc-code-title">${a}</div><pre><code>${e}</code></pre></div>`,Ue=(t,e)=>t==="data-language"||t===jt||t===Mt||t==="style"&&new RegExp(`^\\s*${rt}\\s*:[^;]*;?\\s*$`).test(e??""),We=t=>typeof t=="string"&&t.length<=200&&!/[<>\n]|&(?!(amp|lt|gt|quot|#39);)/.test(t),Fe=t=>(t.language===void 0||De(t.language))&&(t.folded===void 0||Re(t.folded))&&(t.height===void 0||Me("code",rt,t.height)===t.height)&&(t.title===void 0||We(t.title))&&(t.lineStart===void 0||typeof t.lineStart=="string"&&String(je(t.lineStart))===t.lineStart);function Ke(t){let{node:e}=t;if(t.tag!=="div"||t.nested||!Bt(e,Be.code.className))return!1;let s=(n,a)=>{let r=n.childNodes??[],i=r.filter(f=>f.tagName);return i.length===a.length&&i.every((f,l)=>f.tagName===a[l])&&r.every(f=>f.tagName||!(f.value??"").trim())?i:null},o=s(e,["div","pre"]);return!!o&&Bt(o[0],"doc-code-title")&&!!s(o[1],["code"])}var Rt={code:{fields:["language","folded","height","title","lineStart"],check:Fe,leaf:(t,e,s)=>ze(t,e.html,e.language,e.height,s,e.title,e.folded,e.lineStart),written:Ke,attribute:Ue}};import{sizeValue as He}from"../browser/editor/components/registry.mjs";import{MIN_COLUMNS as Pe,RATIO as Dt}from"../browser/editor/components/columns/index.mjs";var zt={columns:{check:t=>t.children.length>=Pe&&t.children.every(e=>e.type==="column")},column:{check:t=>t.ratio===void 0||He("column",Dt,t.ratio)===t.ratio,write(t,e){let s=t.ratio===void 0?"":` style="${Dt}: ${t.ratio}"`;return e.block(`<div class="doc-column"${s}${e.id}>`,e.children(e.inner),"</div>")}}};var Ut={details:{empty:!0,check:(t,{validLeaf:e})=>t.title===""||e({tag:"span"},t.title),write(t,e){let s=e.inner===null?null:e.inner+e.step,o=e.block('<div class="doc-details-content">',e.children(s),"</div>",e.inner,s),n=t.classes?.length?` ${t.classes.join(" ")}`:"";return e.block(`<details class="doc-details${n}"${e.id}>`,[`<summary><span class="doc-details-summary-label">${t.title}</span></summary>`,t.children.length>0?o:'<div class="doc-details-content"></div>'],"</details>")}}};var Wt={dialog:{empty:!0,check(t,{usedIds:e}){return typeof t.id!="string"||!/^[A-Za-z][\w-]{0,63}$/.test(t.id)||e.has(t.id)?!1:(e.add(t.id),!0)},write(t,e){let s=t.children.length>0?e.block('<div class="doc-dialog-content">',e.children(e.deep(3)),"</div>",e.deep(2),e.deep(3)):'<div class="doc-dialog-content"></div>',o=e.block('<div class="doc-dialog-panel">',[s],"</div>",e.deep(1),e.deep(2));return e.block(`<dialog class="doc-dialog" id="${t.id}">`,[o],"</dialog>")}}};import{escapeAttribute as Ge}from"../browser/shared/escape.mjs";import{embedFile as Ft}from"../browser/shared/media.mjs";import{emptyFigure as qe}from"../browser/editor/components/media/write.mjs";import{FILE_SANDBOX as Ve,WEB_SANDBOX as Xe}from"../browser/editor/components/embed/index.mjs";var Ye=t=>typeof t=="string"&&t.length<=2e3&&/^https:\/\/[^\s"<>]+$/.test(t),Kt=t=>t.src===""&&t.height===void 0&&t.caption==="",Ht={embed:{check:(t,{validLeaf:e})=>Kt(t)||(Ye(t.src)||Ft(t.src))&&(t.height===void 0||/^\d{2,4}px$/.test(t.height))&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(Kt(t))return qe("embed",e);let s=Ft(t.src),o=s?/\.pdf$/i.test(t.src)?"":` sandbox="${Ve}"`:` sandbox="${Xe}" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen`,n=`<iframe class="doc-embed-frame" src="${Ge(t.src)}"${o} loading="lazy"></iframe>`,a=t.height?` style="--doc-embed-height: ${t.height}"`:"";return e.block(`<figure class="doc-embed${s?" doc-embed--file":""}"${a}${e.id}>`,[n,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{escapeMarkup as Pt}from"../browser/shared/escape.mjs";import{assetFile as Ze}from"../browser/shared/media.mjs";import{emptyFigure as Je}from"../browser/editor/components/media/write.mjs";var Gt=t=>t.href===""&&t.name===""&&t.size===void 0&&t.caption==="",Qe=t=>typeof t=="string"&&t.trim()!==""&&t.length<=120&&!/[\u0000-\u001f<>:"/\\|?*]/.test(t),qt={file:{check:(t,{validLeaf:e})=>Gt(t)||Ze(t.href)&&Qe(t.name)&&(t.size===void 0||/^\d+(\.\d)? (B|KiB|MiB|GiB)$/.test(t.size))&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(Gt(t))return Je("file",e);let s=t.size?`<span class="doc-file-size">${t.size}</span>`:"",o=`<a class="doc-file-link" href="${t.href}" download="${Pt(t.name)}"><span class="doc-file-name">${Pt(t.name)}</span>${s}</a>`;return e.block(`<figure class="doc-file"${e.id}>`,[o,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{FLOW as ts,FLOW_DIRECTION as Vt,FLOW_RATIO as Xt}from"../browser/editor/components/flowchart/index.mjs";import{START as es,validDirection as Yt,validStart as ss}from"../browser/editor/components/list/index.mjs";import{sizeValue as ns,TOGGLES as as}from"../browser/editor/components/registry.mjs";var Zt={flowchart:{check:t=>(t.start===void 0||ss(t.start))&&(t.direction===void 0||Yt(t.direction))&&t.children.length>0,write:(t,e)=>e.block(`<ol class="${ts}"${t.start?` ${es}="${t.start}"`:""}${t.direction?` ${Vt}="${t.direction}"`:""}${e.id}>`,e.children(e.inner),"</ol>")},step:{check:t=>(t.classes===void 0||Array.isArray(t.classes)&&new Set(t.classes).size===t.classes.length&&t.classes.every(e=>(as.step??[]).includes(e)))&&(t.ratio===void 0||ns("step",Xt,t.ratio)===t.ratio)&&(t.direction===void 0||Yt(t.direction))&&t.children.length>0,write(t,e){let s=t.classes?.length?` class="${t.classes.join(" ")}"`:"",o=t.direction?` ${Vt}="${t.direction}"`:"",n=t.ratio===void 0?"":` style="${Xt}: ${t.ratio}"`;return e.block(`<li${s}${o}${n}${e.id}>`,e.children(e.inner),"</li>")}}};import{SPAN as os,SPAN_SIZE as Jt,imageFile as Qt}from"../browser/shared/media.mjs";import{emptyFigure as rs}from"../browser/editor/components/media/write.mjs";var is=/^\d{1,3}(\.\d{1,3})?( \d{1,3}(\.\d{1,3})?){3}$/,te=t=>t.src===""&&t.caption===""&&t.span===void 0&&t.original===void 0&&t.classes===void 0,cs=t=>typeof t=="number"&&Number.isFinite(t)&&t>=Jt.min&&t<=Jt.max,ee={image:{check:(t,{validLeaf:e})=>te(t)||Qt(t.src)&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption))&&(t.span===void 0||cs(t.span))&&(t.original===void 0||Qt(t.original)&&typeof t.crop=="string"&&is.test(t.crop)),write(t,e){if(te(t))return rs("image",e);let s=["doc-image",...t.classes??[]].join(" "),o=t.span===void 0?"":` style="${os}: ${Math.round(t.span*1e3)/1e3}"`,n=t.original===void 0?"":` data-original="${t.original}" data-crop="${t.crop}"`;return e.block(`<figure class="${s}"${o}${e.id}>`,[`<img src="${t.src}" alt=""${n}>`,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};vt();import{heldByNode as ls,instanceSlots as fs,isInstance as lt,isSlot as ds,ownSlots as us,partOf as ft}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as G,DATA_MOST as ps,NO_TEXT as ms,PACKAGE_ID as se,SCHEMA as ne,SLOT as ae,fitsDataScript as gs,isDataScript as hs,noDataPart as $s,refusedInCopy as Ns,refusedInData as Os,schemaAhead as oe}from"../browser/shared/components/installed.mjs";import{attr as B,walk as re}from"../browser/shared/html-tree.mjs";import{CHART_KEY as bs,VIEW_FROM as it}from"../browser/shared/table-chart.mjs";var P=(t,e)=>{for(let s=t.parentNode;s;s=s.parentNode)if(s===e)return!0;return!1},xs=t=>{let e=t.parentNode;for(;e&&!lt(e);)e=e.parentNode;return e??null},dt=(t,e)=>xs(t)===e&&ls(t)===e&&!ds(t);function ct(t,e){let o=Object.entries(e.get(B(t,G))?.parts??{}).filter(([,{edit:n}])=>n==="data").map(([n,{at:a}])=>[n,ft(t,a).find(r=>r.sourceCodeLocation&&!lt(r)&&dt(r,t))]).filter(([,n])=>n);return o.filter(([,n],a)=>!o.some(([,r],i)=>P(n,r)||r===n&&i<a))}var ys=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),ks="http://www.w3.org/1999/xhtml",Ts=t=>(t.content??t).childNodes;function ie(t,e,s,o){let n=s;for(let a of Ts(t)){let r=a.sourceCodeLocation;if(r?.startOffset!==n)return!1;if(a.tagName){let{startTag:i,endTag:f}=r,l=ys.has(a.tagName)||a.namespaceURI!==ks&&e.startsWith("/>",r.endOffset-2);if(f?!ie(a,e,i.endOffset,f.startOffset):!l)return!1}n=r.endOffset}return n===o}function Ls(t,e,s){if(e.tagName==="script")return hs(e.tagName,e.attrs)&&gs(s);if($s(e.tagName))return!1;let{startTag:o,endTag:n}=e.sourceCodeLocation,a=t.slice(o.startOffset,o.endOffset),r=`${a}${s}${t.slice(n.startOffset,n.endOffset)}`,[i,...f]=z(e.parentNode,r,{sourceCodeLocationInfo:!0}).childNodes;if(f.length>0||i?.tagName!==e.tagName||i.sourceCodeLocation?.endOffset!==r.length||!i.sourceCodeLocation.endTag||!ie(i,r,a.length,a.length+s.length))return!1;let l=!1;return re(i,m=>{l||=Os(m.tagName,m.attrs)}),!l}var vs=(t,e)=>Object.values(e.get(B(t,G))?.parts??{}).filter(({edit:s})=>s==="text"||s==="data").flatMap(({at:s})=>ft(t,s).filter(o=>dt(o,t))),ce={installed:{slots(t,e){let s=vs(t,e);return fs(t).filter(o=>!s.some(n=>P(o,n)))},boxes(t,e){return this.slots(t,e).map(s=>({element:s,kind:"slot",key:B(s,ae)}))},textParts(t,e){let s=e.get(B(t,G));if(oe(B(t,ne),s?.schema))return[];let o=Object.values(s?.parts??{}).filter(({edit:r})=>r==="text"),n=ct(t,e).map(([,r])=>r),a=[...new Set(o.flatMap(({at:r})=>ft(t,r)))].filter(r=>r.sourceCodeLocation&&!lt(r)&&!ms.has(r.tagName)&&dt(r,t)).filter(r=>!n.some(i=>i===r||P(r,i)||P(i,r)));return a.filter(r=>!a.some(i=>P(r,i))).map(r=>({kind:"installed",part:r}))},source({package:t,html:e,children:s,boxKeys:o,from:n},{packages:a,written:r}){if(typeof t!="string"||!se.test(t))return null;let i=s!==void 0;if(i&&!(Array.isArray(s)&&Array.isArray(o)&&o.length===s.length)||n!=null&&(typeof n!="string"||!bs.test(n)))return null;let f=e===void 0?a.has(t)?Ct(a.get(t)):null:e,l=typeof f=="string"?nt(f,t):null;if(l&&(typeof n=="string"||n===null&&B(l.root,it)!==void 0)&&(l.root.attrs=[...l.root.attrs.filter(({name:L})=>L!==it),...n===null?[]:[{name:it,value:n}]],l=nt(Lt(l.root),t)),!l)return null;let m=us(l.root),u=L=>!L.childNodes.every(N=>N.nodeName==="#text"&&!N.value.trim());if((e!==void 0||!i)&&m.some(u)||i&&!o.every(L=>m.some(N=>B(N,ae)===L)))return null;if(e!==void 0){let L=!1;if(re({childNodes:[l.root]},N=>{L||=Ns(N.tagName,N.attrs)}),L)return null}let v=m.map(L=>L.sourceCodeLocation).sort((L,N)=>N.startOffset-L.startOffset).reduce((L,{startTag:N,endTag:b})=>L.slice(0,N.endOffset)+L.slice(b.startOffset),l.markup);return r(i?v:l.markup)},unwritten:({package:t,html:e},{packages:s})=>e===void 0&&se.test(t)&&!s.has(t)?"no-package":"invalid",definition:(t,e)=>e.get(B(t,G))?.definition,dataOf(t,e,s){let o=ct(e,s).filter(([,n])=>n.sourceCodeLocation.endTag);return o.length>0?Object.fromEntries(o.map(([n,a])=>[n,t.slice(a.sourceCodeLocation.startTag.endOffset,a.sourceCodeLocation.endTag.startOffset)])):null},rewrite(t,e,s,{packages:o}){let n=new Map(ct(e,o)),a=Object.keys(s),r=a.map(f=>s[f]);if(oe(B(e,ne),o.get(B(e,G))?.schema)||a.length===0||!r.every(f=>typeof f=="string")||!a.every(f=>n.has(f))||r.reduce((f,l)=>f+Buffer.byteLength(l),0)>ps||!a.every(f=>n.get(f).sourceCodeLocation.endTag&&Ls(t,n.get(f),s[f])))return null;let i=t.includes(`\r
|
|
2
|
+
import{g as St,r as nt,t as Ct}from"./chunk-HDWTZ763.mjs";import{a as Lt,b as st,c as z,e as vt}from"./chunk-A55HN5OK.mjs";import{createHash as Ee}from"node:crypto";import{BLOCK_LEVEL as ot}from"../browser/shared/html-tree.mjs";var wt=t=>Ee("sha256").update(t).digest("hex").slice(0,16),M=t=>t.nodeName==="#text"&&!t.value.trim();function at(t,e){for(let s of t.childNodes??[]){if(s.tagName===e)return s;let o=s.tagName&&at(s,e);if(o)return o}return null}import{ATTRIBUTES as an,BOX_CLASSES as on,COMPONENT_ATTRIBUTES as rn,COMPONENT_CLASSES as cn,GROUPING as ln,IDENTITY as R,TOGGLES as fn,UNIT_KINDS as dn}from"../browser/editor/components/registry.mjs";import{attr as I,hasClass as kt}from"../browser/shared/html-tree.mjs";import{idsNamed as un}from"../browser/shared/copy-ids.mjs";import{DIALOG as pn,PAGE as mn,SECTION as gn,SHEETS as K,TABLE as Le}from"../browser/editor/components/kit.mjs";import{matchesNode as q,partOf as bt}from"../browser/shared/components/index.mjs";import{escapeMarkup as V}from"../browser/shared/escape.mjs";import{imageFile as Ae}from"../browser/shared/media.mjs";import{emptyFigure as Ie}from"../browser/editor/components/media/write.mjs";var _e=t=>typeof t=="string"&&t.length<=2e3&&/^https?:\/\/[^\s"<>]+$/.test(t),Et=(t,e)=>typeof t=="string"&&t.length<=e&&!/[\u0000-\u001f]/.test(t),At=t=>t.href===""&&!t.title&&!t.description&&!t.icon&&!t.cover&&t.caption==="",It=t=>t==null||Ae(t),_t={bookmark:{check:(t,{validLeaf:e})=>At(t)||_e(t.href)&&Et(t.title,300)&&Et(t.description??"",600)&&It(t.icon)&&It(t.cover)&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(At(t))return Ie("bookmark",e);let s=t.title.trim()||new URL(t.href).hostname,o=[`<span class="doc-bookmark-title">${V(s)}</span>`,t.description?`<span class="doc-bookmark-description">${V(t.description)}</span>`:"",`<span class="doc-bookmark-url">${t.icon?`<img class="doc-bookmark-icon" src="${t.icon}" alt="">`:""}<span class="doc-bookmark-href">${V(t.href)}</span></span>`].join(""),n=t.cover?`<span class="doc-bookmark-cover"><img src="${t.cover}" alt=""></span>`:"",a=`<a class="doc-bookmark-card" href="${V(t.href)}" target="_blank" rel="noopener noreferrer"><span class="doc-bookmark-text">${o}</span>${n}</a>`;return e.block(`<figure class="doc-bookmark"${e.id}>`,[a,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{BLOCK_TYPES as Be,sizeValue as Me}from"../browser/editor/components/registry.mjs";import{LINE_START as Mt,lineStart as je}from"../browser/shared/code-lines.mjs";import{hasClass as Bt}from"../browser/shared/html-tree.mjs";import{CODE_HEIGHT as rt,FOLDED_LINES as jt,validFolded as Re,validLanguage as De}from"../browser/editor/components/code/index.mjs";var ze=(t,e,s,o,n="",a="",r="",i="")=>`<div class="${t.className}"${s?` data-language="${s}"`:""}${i?` ${Mt}="${i}"`:""}${r?` ${jt}="${r}"`:""}${o?` style="${rt}: ${o}"`:""}${n}><div class="doc-code-title">${a}</div><pre><code>${e}</code></pre></div>`,Ue=(t,e)=>t==="data-language"||t===jt||t===Mt||t==="style"&&new RegExp(`^\\s*${rt}\\s*:[^;]*;?\\s*$`).test(e??""),We=t=>typeof t=="string"&&t.length<=200&&!/[<>\n]|&(?!(amp|lt|gt|quot|#39);)/.test(t),Fe=t=>(t.language===void 0||De(t.language))&&(t.folded===void 0||Re(t.folded))&&(t.height===void 0||Me("code",rt,t.height)===t.height)&&(t.title===void 0||We(t.title))&&(t.lineStart===void 0||typeof t.lineStart=="string"&&String(je(t.lineStart))===t.lineStart);function Ke(t){let{node:e}=t;if(t.tag!=="div"||t.nested||!Bt(e,Be.code.className))return!1;let s=(n,a)=>{let r=n.childNodes??[],i=r.filter(f=>f.tagName);return i.length===a.length&&i.every((f,l)=>f.tagName===a[l])&&r.every(f=>f.tagName||!(f.value??"").trim())?i:null},o=s(e,["div","pre"]);return!!o&&Bt(o[0],"doc-code-title")&&!!s(o[1],["code"])}var Rt={code:{fields:["language","folded","height","title","lineStart"],check:Fe,leaf:(t,e,s)=>ze(t,e.html,e.language,e.height,s,e.title,e.folded,e.lineStart),written:Ke,attribute:Ue}};import{sizeValue as He}from"../browser/editor/components/registry.mjs";import{MIN_COLUMNS as Pe,RATIO as Dt}from"../browser/editor/components/columns/index.mjs";var zt={columns:{check:t=>t.children.length>=Pe&&t.children.every(e=>e.type==="column")},column:{check:t=>t.ratio===void 0||He("column",Dt,t.ratio)===t.ratio,write(t,e){let s=t.ratio===void 0?"":` style="${Dt}: ${t.ratio}"`;return e.block(`<div class="doc-column"${s}${e.id}>`,e.children(e.inner),"</div>")}}};var Ut={details:{empty:!0,check:(t,{validLeaf:e})=>t.title===""||e({tag:"span"},t.title),write(t,e){let s=e.inner===null?null:e.inner+e.step,o=e.block('<div class="doc-details-content">',e.children(s),"</div>",e.inner,s),n=t.classes?.length?` ${t.classes.join(" ")}`:"";return e.block(`<details class="doc-details${n}"${e.id}>`,[`<summary><span class="doc-details-summary-label">${t.title}</span></summary>`,t.children.length>0?o:'<div class="doc-details-content"></div>'],"</details>")}}};var Wt={dialog:{empty:!0,check(t,{usedIds:e}){return typeof t.id!="string"||!/^[A-Za-z][\w-]{0,63}$/.test(t.id)||e.has(t.id)?!1:(e.add(t.id),!0)},write(t,e){let s=t.children.length>0?e.block('<div class="doc-dialog-content">',e.children(e.deep(3)),"</div>",e.deep(2),e.deep(3)):'<div class="doc-dialog-content"></div>',o=e.block('<div class="doc-dialog-panel">',[s],"</div>",e.deep(1),e.deep(2));return e.block(`<dialog class="doc-dialog" id="${t.id}">`,[o],"</dialog>")}}};import{escapeAttribute as Ge}from"../browser/shared/escape.mjs";import{embedFile as Ft}from"../browser/shared/media.mjs";import{emptyFigure as qe}from"../browser/editor/components/media/write.mjs";import{FILE_SANDBOX as Ve,WEB_SANDBOX as Xe}from"../browser/editor/components/embed/index.mjs";var Ye=t=>typeof t=="string"&&t.length<=2e3&&/^https:\/\/[^\s"<>]+$/.test(t),Kt=t=>t.src===""&&t.height===void 0&&t.caption==="",Ht={embed:{check:(t,{validLeaf:e})=>Kt(t)||(Ye(t.src)||Ft(t.src))&&(t.height===void 0||/^\d{2,4}px$/.test(t.height))&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(Kt(t))return qe("embed",e);let s=Ft(t.src),o=s?/\.pdf$/i.test(t.src)?"":` sandbox="${Ve}"`:` sandbox="${Xe}" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen`,n=`<iframe class="doc-embed-frame" src="${Ge(t.src)}"${o} loading="lazy"></iframe>`,a=t.height?` style="--doc-embed-height: ${t.height}"`:"";return e.block(`<figure class="doc-embed${s?" doc-embed--file":""}"${a}${e.id}>`,[n,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{escapeMarkup as Pt}from"../browser/shared/escape.mjs";import{assetFile as Ze}from"../browser/shared/media.mjs";import{emptyFigure as Je}from"../browser/editor/components/media/write.mjs";var Gt=t=>t.href===""&&t.name===""&&t.size===void 0&&t.caption==="",Qe=t=>typeof t=="string"&&t.trim()!==""&&t.length<=120&&!/[\u0000-\u001f<>:"/\\|?*]/.test(t),qt={file:{check:(t,{validLeaf:e})=>Gt(t)||Ze(t.href)&&Qe(t.name)&&(t.size===void 0||/^\d+(\.\d)? (B|KiB|MiB|GiB)$/.test(t.size))&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption)),write(t,e){if(Gt(t))return Je("file",e);let s=t.size?`<span class="doc-file-size">${t.size}</span>`:"",o=`<a class="doc-file-link" href="${t.href}" download="${Pt(t.name)}"><span class="doc-file-name">${Pt(t.name)}</span>${s}</a>`;return e.block(`<figure class="doc-file"${e.id}>`,[o,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};import{FLOW as ts,FLOW_DIRECTION as Vt,FLOW_RATIO as Xt}from"../browser/editor/components/flowchart/index.mjs";import{START as es,validDirection as Yt,validStart as ss}from"../browser/editor/components/list/index.mjs";import{sizeValue as ns,TOGGLES as as}from"../browser/editor/components/registry.mjs";var Zt={flowchart:{check:t=>(t.start===void 0||ss(t.start))&&(t.direction===void 0||Yt(t.direction))&&t.children.length>0,write:(t,e)=>e.block(`<ol class="${ts}"${t.start?` ${es}="${t.start}"`:""}${t.direction?` ${Vt}="${t.direction}"`:""}${e.id}>`,e.children(e.inner),"</ol>")},step:{check:t=>(t.classes===void 0||Array.isArray(t.classes)&&new Set(t.classes).size===t.classes.length&&t.classes.every(e=>(as.step??[]).includes(e)))&&(t.ratio===void 0||ns("step",Xt,t.ratio)===t.ratio)&&(t.direction===void 0||Yt(t.direction))&&t.children.length>0,write(t,e){let s=t.classes?.length?` class="${t.classes.join(" ")}"`:"",o=t.direction?` ${Vt}="${t.direction}"`:"",n=t.ratio===void 0?"":` style="${Xt}: ${t.ratio}"`;return e.block(`<li${s}${o}${n}${e.id}>`,e.children(e.inner),"</li>")}}};import{SPAN as os,SPAN_SIZE as Jt,imageFile as Qt}from"../browser/shared/media.mjs";import{emptyFigure as rs}from"../browser/editor/components/media/write.mjs";var is=/^\d{1,3}(\.\d{1,3})?( \d{1,3}(\.\d{1,3})?){3}$/,te=t=>t.src===""&&t.caption===""&&t.span===void 0&&t.original===void 0&&t.classes===void 0,cs=t=>typeof t=="number"&&Number.isFinite(t)&&t>=Jt.min&&t<=Jt.max,ee={image:{check:(t,{validLeaf:e})=>te(t)||Qt(t.src)&&typeof t.caption=="string"&&(t.caption===""||e({tag:"figcaption"},t.caption))&&(t.span===void 0||cs(t.span))&&(t.original===void 0||Qt(t.original)&&typeof t.crop=="string"&&is.test(t.crop)),write(t,e){if(te(t))return rs("image",e);let s=["doc-image",...t.classes??[]].join(" "),o=t.span===void 0?"":` style="${os}: ${Math.round(t.span*1e3)/1e3}"`,n=t.original===void 0?"":` data-original="${t.original}" data-crop="${t.crop}"`;return e.block(`<figure class="${s}"${o}${e.id}>`,[`<img src="${t.src}" alt=""${n}>`,`<figcaption>${t.caption}</figcaption>`],"</figure>")}}};vt();import{heldByNode as ls,instanceSlots as fs,isInstance as lt,isSlot as ds,ownSlots as us,partOf as ft}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as G,DATA_MOST as ps,NO_TEXT as ms,PACKAGE_ID as se,SCHEMA as ne,SLOT as ae,fitsDataScript as gs,isDataScript as hs,noDataPart as $s,refusedInCopy as Ns,refusedInData as Os,schemaAhead as oe}from"../browser/shared/components/installed.mjs";import{attr as B,walk as re}from"../browser/shared/html-tree.mjs";import{CHART_KEY as bs,VIEW_FROM as it}from"../browser/shared/table-chart.mjs";var P=(t,e)=>{for(let s=t.parentNode;s;s=s.parentNode)if(s===e)return!0;return!1},xs=t=>{let e=t.parentNode;for(;e&&!lt(e);)e=e.parentNode;return e??null},dt=(t,e)=>xs(t)===e&&ls(t)===e&&!ds(t);function ct(t,e){let o=Object.entries(e.get(B(t,G))?.parts??{}).filter(([,{edit:n}])=>n==="data").map(([n,{at:a}])=>[n,ft(t,a).find(r=>r.sourceCodeLocation&&!lt(r)&&dt(r,t))]).filter(([,n])=>n);return o.filter(([,n],a)=>!o.some(([,r],i)=>P(n,r)||r===n&&i<a))}var ys=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),ks="http://www.w3.org/1999/xhtml",Ts=t=>(t.content??t).childNodes;function ie(t,e,s,o){let n=s;for(let a of Ts(t)){let r=a.sourceCodeLocation;if(r?.startOffset!==n)return!1;if(a.tagName){let{startTag:i,endTag:f}=r,l=ys.has(a.tagName)||a.namespaceURI!==ks&&e.startsWith("/>",r.endOffset-2);if(f?!ie(a,e,i.endOffset,f.startOffset):!l)return!1}n=r.endOffset}return n===o}function Ls(t,e,s){if(e.tagName==="script")return hs(e.tagName,e.attrs)&&gs(s);if($s(e.tagName))return!1;let{startTag:o,endTag:n}=e.sourceCodeLocation,a=t.slice(o.startOffset,o.endOffset),r=`${a}${s}${t.slice(n.startOffset,n.endOffset)}`,[i,...f]=z(e.parentNode,r,{sourceCodeLocationInfo:!0}).childNodes;if(f.length>0||i?.tagName!==e.tagName||i.sourceCodeLocation?.endOffset!==r.length||!i.sourceCodeLocation.endTag||!ie(i,r,a.length,a.length+s.length))return!1;let l=!1;return re(i,m=>{l||=Os(m.tagName,m.attrs)}),!l}var vs=(t,e)=>Object.values(e.get(B(t,G))?.parts??{}).filter(({edit:s})=>s==="text"||s==="data").flatMap(({at:s})=>ft(t,s).filter(o=>dt(o,t))),ce={installed:{slots(t,e){let s=vs(t,e);return fs(t).filter(o=>!s.some(n=>P(o,n)))},boxes(t,e){return this.slots(t,e).map(s=>({element:s,kind:"slot",key:B(s,ae)}))},textParts(t,e){let s=e.get(B(t,G));if(oe(B(t,ne),s?.schema))return[];let o=Object.values(s?.parts??{}).filter(({edit:r})=>r==="text"),n=ct(t,e).map(([,r])=>r),a=[...new Set(o.flatMap(({at:r})=>ft(t,r)))].filter(r=>r.sourceCodeLocation&&!lt(r)&&!ms.has(r.tagName)&&dt(r,t)).filter(r=>!n.some(i=>i===r||P(r,i)||P(i,r)));return a.filter(r=>!a.some(i=>P(r,i))).map(r=>({kind:"installed",part:r}))},source({package:t,html:e,children:s,boxKeys:o,from:n},{packages:a,written:r}){if(typeof t!="string"||!se.test(t))return null;let i=s!==void 0;if(i&&!(Array.isArray(s)&&Array.isArray(o)&&o.length===s.length)||n!=null&&(typeof n!="string"||!bs.test(n)))return null;let f=e===void 0?a.has(t)?Ct(a.get(t)):null:e,l=typeof f=="string"?nt(f,t):null;if(l&&(typeof n=="string"||n===null&&B(l.root,it)!==void 0)&&(l.root.attrs=[...l.root.attrs.filter(({name:L})=>L!==it),...n===null?[]:[{name:it,value:n}]],l=nt(Lt(l.root),t)),!l)return null;let m=us(l.root),u=L=>!L.childNodes.every(N=>N.nodeName==="#text"&&!N.value.trim());if((e!==void 0||!i)&&m.some(u)||i&&!o.every(L=>m.some(N=>B(N,ae)===L)))return null;if(e!==void 0){let L=!1;if(re({childNodes:[l.root]},N=>{L||=Ns(N.tagName,N.attrs)}),L)return null}let v=m.map(L=>L.sourceCodeLocation).sort((L,N)=>N.startOffset-L.startOffset).reduce((L,{startTag:N,endTag:b})=>L.slice(0,N.endOffset)+L.slice(b.startOffset),l.markup);return r(i?v:l.markup)},unwritten:({package:t,html:e},{packages:s})=>e===void 0&&se.test(t)&&!s.has(t)?"no-package":"invalid",definition:(t,e)=>e.get(B(t,G))?.definition,dataOf(t,e,s){let o=ct(e,s).filter(([,n])=>n.sourceCodeLocation.endTag);return o.length>0?Object.fromEntries(o.map(([n,a])=>[n,t.slice(a.sourceCodeLocation.startTag.endOffset,a.sourceCodeLocation.endTag.startOffset)])):null},rewrite(t,e,s,{packages:o}){let n=new Map(ct(e,o)),a=Object.keys(s),r=a.map(f=>s[f]);if(oe(B(e,ne),o.get(B(e,G))?.schema)||a.length===0||!r.every(f=>typeof f=="string")||!a.every(f=>n.has(f))||r.reduce((f,l)=>f+Buffer.byteLength(l),0)>ps||!a.every(f=>n.get(f).sourceCodeLocation.endTag&&Ls(t,n.get(f),s[f])))return null;let i=t.includes(`\r
|
|
3
3
|
`)?`\r
|
|
4
4
|
`:`
|
|
5
5
|
`;return a.map(f=>{let{startTag:l,endTag:m}=n.get(f).sourceCodeLocation;return{start:l.endOffset,end:m.startOffset,text:s[f].replace(/\r?\n/g,i)}})}}};vt();import{IDENTITY as Ss}from"../browser/editor/components/registry.mjs";import{SHEETS as X,TABLE as le}from"../browser/editor/components/kit.mjs";import{escapeAttribute as Y,escapeText as ut}from"../browser/shared/escape.mjs";import{isInstance as Cs,matchesNode as pt}from"../browser/shared/components/index.mjs";import{attr as j}from"../browser/shared/html-tree.mjs";import{CHART_SOURCE as fe,TABLE_READERS as ws}from"../browser/shared/table-chart.mjs";import{freshPrefix as Es,referencedIds as As,rewrite as Is}from"../browser/shared/copy-ids.mjs";var de=(t={})=>Object.entries(t).map(([e,s])=>s===""?` ${e}`:` ${e}="${Y(String(s))}"`).join(""),ue=(t,e)=>t[e-1]==="/"?e-1:e;function Z(t,e,s){let o=e;for(;o>0&&/\s/.test(t[o-1]);)o--;return{start:o,end:s}}function Sa(t){let e=s=>s.nodeName==="#text"?s.value:(s.childNodes??[]).map(e).join("");return e(z(t)).replace(/\s+/g," ").trim()}function Ca(t,{from:e,to:s}){let n=pe(st(t,{sourceCodeLocationInfo:!0}))?.sourceCodeLocation;if(!n?.endTag)return null;let a=t.slice(n.startTag.endOffset,n.endTag.startOffset);if(!e)return a.trim()===""?{start:n.startTag.endOffset,end:n.endTag.startOffset,text:ut(s)}:null;let r=ut(e),i=a.indexOf(r);if(i<0||a.indexOf(r,i+1)>=0)return null;let f=n.startTag.endOffset+i;return{start:f,end:f+r.length,text:ut(s)}}function pe(t){for(let e of t.childNodes??[]){if(e.tagName==="title")return e;if(e.tagName==="body")continue;let s=e.tagName&&pe(e);if(s)return s}return null}function _s(t){let e=[],s=0,o=null,n=0;for(let a=0;a<t.length;a++){let r=t[a];if(r==="&"){let i=/^&(#\d+|#x[\da-f]+|[a-z]\w*);/i.exec(t.slice(a));i&&(a+=i[0].length-1)}else o?r===o?o=null:r==="\\"&&a++:r==='"'||r==="'"?o=r:r==="("?s++:r===")"?s=Math.max(0,s-1):r===";"&&s===0&&(e.push(t.slice(n,a)),n=a+1)}return e.push(t.slice(n)),e.map(a=>a.trim()).filter(Boolean)}function ht(t,e){let s=_s(t);for(let[o,n]of e){let a=s.findIndex(r=>r.slice(0,r.indexOf(":")).trim()===o);n===null?a>=0&&s.splice(a,1):a>=0?s[a]=`${o}: ${n}`:s.push(`${o}: ${n}`)}return s.join("; ")}var Bs=new Set(["pre","textarea","script","style"]);function wa(t){if(typeof t!="string"||!t.trim())return null;let s=z(t,{sourceCodeLocationInfo:!0}).childNodes.filter(f=>f.nodeName!=="#comment"&&!(f.nodeName==="#text"&&!f.value.trim())),[o,n]=s;if(s.length===2&&o.tagName==="button"&&pt(o,X.tab)&&n.tagName&&n.sourceCodeLocation?.endTag&&j(o,X.tabKey)&&j(n,X.panelKey)===j(o,X.tabKey)){let f=o.sourceCodeLocation.endOffset;return{element:o,source:t.slice(0,f),panel:t.slice(f).replace(/^\s+/,""),kind:"tab"}}let a=s.at(-1),r=s.length===2?s[0]:null;if(!a?.tagName||!a.sourceCodeLocation?.startTag||s.length>2||r&&!(r.tagName&&pt(r,le.lead)&&pt(a,le.frame)))return null;let i=W(a);return{element:a,source:t,kind:i}}function Ms(t){let e=[],s=o=>{for(let n of o.childNodes??[]){if(!n.tagName)continue;let a=j(n,"id");a&&e.push(a),s(n.tagName==="template"?n.content:n)}};return s(st(t)),e}var Ea=(t,e)=>`${mt(t.slice(e.start,e.end),U(t,e.start),"")}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{E as re,J as ae,K as ne,O as ie,P as ce,a as C,b as Q,c as F,g as X,h as Z,n as D,o as ee,r as te,s as se,t as oe}from"./chunk-
|
|
2
|
+
import{E as re,J as ae,K as ne,O as ie,P as ce,a as C,b as Q,c as F,g as X,h as Z,n as D,o as ee,r as te,s as se,t as oe}from"./chunk-7JDX4E65.mjs";import{j as K}from"./chunk-3MBRL2PM.mjs";import{d as le}from"./chunk-EP25HDAJ.mjs";import{i as q}from"./chunk-5XA2ZBAE.mjs";import{a as L}from"./chunk-JEUK3ZO7.mjs";import{a as M,b as z,g as J}from"./chunk-PUOQ65NC.mjs";import{b as x,c as T}from"./chunk-UYVCQK3H.mjs";import{b as E}from"./chunk-4OZWXZE5.mjs";import{f as H,j as Y}from"./chunk-HDWTZ763.mjs";import{b as V,e as pe}from"./chunk-A55HN5OK.mjs";pe();import N from"node:fs/promises";import P from"node:path";import{isInstance as ge}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as me}from"../browser/shared/components/installed.mjs";import{attr as we,walk as $e}from"../browser/shared/html-tree.mjs";import{pageExists as ye,pageFiles as be}from"../browser/shared/pages.mjs";import{layoutOf as Ee}from"../browser/shared/workspace.mjs";var xe="card ids aside",ke="nothing else in page.html changed (card ids aside)",Se=e=>new Promise(s=>setTimeout(s,e)),Te=/^\/__gallery\/pages\/[a-z0-9-]+\/cards$/,de=e=>{let s=null;return $e(V(e,{sourceCodeLocationInfo:!0}),n=>{s??=ge(n)?n:null},{inTemplates:!1}),s},fe=(e,s)=>{let n=s.node.sourceCodeLocation.startTag.endOffset;return{frame:e.slice(s.start,n).replace(/\s+data-[xywh]="[^"]*"/g,""),rest:e.slice(n,s.end)}};function Ce(e,s,n,a){let[o,d]=[x(e).cards,x(s).cards],c=[],t=r=>`card ${r.id}${r.block?` (${r.block})`:""}`,l=r=>["x","y","w","h"].map(i=>`${i} ${we(r.node,`data-${i}`)??"-"}`).join(", ");for(let r of o){let i=d.find(g=>g.id===r.id);if(!i){c.push(`${t(r)} taken out`);continue}let m=r.board!==i.board;(m||l(r)!==l(i))&&c.push(`${t(r)}'s place, ${l(r)}${m?` on ${r.board}`:""} then ${l(i)}${m?` on ${i.board}`:""}`);let[h,p]=[fe(e,r),fe(s,i)];if(h.frame===p.frame&&h.rest===p.rest)continue;if(r.id!==n){c.push(t(r));continue}h.frame!==p.frame&&c.push(`${t(r)}'s own frame (an attribute of its <section> but its place)`);let[f,$]=[D(h.rest,de,a),D(p.rest,de,a)];!f||!$?c.push(`${t(r)}'s instance`):f.outside!==$.outside&&c.push(`${t(r)} itself, outside its data parts (a part edited as text or none, or what its instance holds besides its parts)`)}for(let r of d)o.some(i=>i.id===r.id)||c.push(`a ${t(r)} put in`);let w=(r,i)=>{let m="",h=0;for(let p of[...i].sort((f,$)=>f.start-$.start))m+=r.slice(h,p.start),h=p.end;return(m+r.slice(h)).replace(/\s+/g," ")};return(w(e,o)!==w(s,d)||!c.length)&&c.push("the page's own HTML outside its cards (its head, its style, its header)"),c.join("; ")}function Ie(e,s,{card:n,found:a}){let[o,d]=[T(e).text,T(s).text],t=ee(o,d,l=>x(l).cards.find(w=>w.id===n)?.instance??null,a);return t.outside&&(t.outside={...t.outside,what:Ce(o,d,n,a)}),t}async function Oe(e){try{return await e.waitForSelector("[data-doc-ready]",{timeout:C}).catch(s=>{if(s.name==="TimeoutError")throw s;return e.waitForSelector("[data-doc-ready]",{timeout:C})}),await e.waitForFunction(()=>globalThis.__galleryTryEditable===!0&&!!document.querySelector("script[data-ge-page]"),{timeout:C}),!0}catch(s){if(s.name!=="TimeoutError")throw s;return!1}}function ve(e){return e?.startsWith("stopped")?`the page service refused the board's write (${e.slice(7).trim()||"no reason given"}), and the page showed itself again as the file holds it`:{refused:"the page service refused the board's write: the card was changed or taken out meanwhile (someone else's write of page.html), and the page showed itself again as the file holds it",offline:"the page could not reach the server (offline)",reloading:"the page loaded itself again (page.html or a custom block it holds changed meanwhile, or the page service refused a write)",syncing:`its write took more than ${F/1e3}s to be answered`}[e]}function Ae(e){let s=[],n=new Map;return e.on("request",a=>{if(a.method()!=="POST"||!Te.test(new URL(a.url()).pathname))return;let o={done:!1,status:null,answer:null,failed:null};s.push(o),n.set(a,o)}),e.on("response",a=>{let o=n.get(a.request());o&&(o.status=a.status(),o.done=!0,o.status!==200&&a.json().then(d=>{o.answer=d},()=>{}))}),e.on("requestfailed",a=>{let o=n.get(a);o&&(o.failed=a.failure()?.errorText??"failed",o.done=!0)}),{mark:async()=>s.length,async until(a){let o=Date.now();for(let d=0;;await Se(100)){let c=s.slice(a);if(c.length===0){if(Date.now()-o>Q)return"unchanged";continue}if(c.some(l=>!l.done)){if(d=0,Date.now()-o>F)return"syncing";continue}if(++d<4)continue;if(c.some(l=>l.failed))return"offline";let t=c.find(l=>l.status!==200);return t?t.answer?.refused||t.status===409&&!t.answer?"refused":`stopped ${t.answer?.reason??`HTTP ${t.status}`}`:"saved"}}}}function Re({card:e,found:s}){let n={...s,parts:Object.fromEntries(Object.entries(s.parts).filter(([,a])=>a.edit==="data"))};return{where:{card:e},ready:Oe,saves:Ae,changes:(a,o)=>Ie(a,o,{card:e,found:n}),plain:()=>!1,stayed:ve,outside:"problem",outsideSaid:a=>`card ${e}'s data parts: ${a.what}, where a reader's gesture on the card is to change its data parts alone`,aside:xe,inside:ke,framed:a=>a.closest(".gallery-card")??a}}var Le=e=>` ${e.id} ${e.block??"(no instance)"} x ${e.x}, y ${e.y}, w ${e.w}, h ${e.h}${e.board?` on board ${e.board}`:""}`;async function Ke(e,{named:s,values:n,seconds:a={},keep:o,replace:d=!1}){if(s.length===0)throw new E("Name the page and the card: gallery page try <slug> <card id> and the gesture.");if(s.length===1)throw new E(`Name the card of ${s[0]} to try: gallery page try ${s[0]} <card id> and the gesture (its data-card-id; gallery page check ${s[0]} lists the cards).`);if(s.length>2)throw new E("gallery page try takes a page's slug and a card's id.");let c=await X(n,a,d),[t,l]=s,w=n.has("--steps")?P.resolve(n.get("--steps")):null,r=c?[c]:await Z(w),i=be(t,e);ye(t,e)||(console.error(await le(t,e)),process.exit(1));let m=await N.readFile(i.html,"utf8"),{cards:h}=x(T(m).text),p=h.find(u=>u.id===l);if(!p)throw new E(h.length?`${t} has no card ${l}: its cards are
|
|
3
3
|
${h.map(Le).join(`
|
|
4
|
-
`)}`:`${t} has no card yet: gallery page add ${t} <block> puts one on it.`);let f=P.basename(i.html),$=p.node.sourceCodeLocation?.startLine??null;p.instance||(console.error(`Card ${l} of ${t} (${f}:${$}) holds no instance of a custom block (an element with ${me}): there is nothing on it to try.`),process.exit(1));let g=p.block,_=H(e),k=_.packages.get(g);if(!k){let u=_.problems.get(g);console.error(u?.off?`${g} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868: its card says so on the page and runs nothing.`:u?`${g} does not load (${Y("en",u.problem)}), so its card runs nothing: gallery block check ${g} says why.`:`No custom block ${g} in this workspace, so its card runs nothing: gallery block list says which there are${g.startsWith("gallery/")?`, and gallery block add ${g.slice(8)} puts one of Gallery's own in`:""}.`),process.exit(1)}k.places.includes("page")||(console.error(`${g} is a block of documents (its manifest's places has no "page"): on a custom page its card says so and runs nothing, so there is nothing to try there (gallery block try tries it in a document).`),process.exit(1)),console.log(`${g} in card ${l} of ${t}, at ${f}:${$}: ${L(i.html)}`),w&&console.log(`Steps: ${r.length} from ${L(w)}, made one after another in one page`);let S=await q({command:`gallery page try ${t}`});if(!S.ok){console.log(`UNVERIFIED ${t}: ${S.message}`),process.exitCode=3;return}let{pageAloneOf:j}=await import("./chunk-
|
|
4
|
+
`)}`:`${t} has no card yet: gallery page add ${t} <block> puts one on it.`);let f=P.basename(i.html),$=p.node.sourceCodeLocation?.startLine??null;p.instance||(console.error(`Card ${l} of ${t} (${f}:${$}) holds no instance of a custom block (an element with ${me}): there is nothing on it to try.`),process.exit(1));let g=p.block,_=H(e),k=_.packages.get(g);if(!k){let u=_.problems.get(g);console.error(u?.off?`${g} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868: its card says so on the page and runs nothing.`:u?`${g} does not load (${Y("en",u.problem)}), so its card runs nothing: gallery block check ${g} says why.`:`No custom block ${g} in this workspace, so its card runs nothing: gallery block list says which there are${g.startsWith("gallery/")?`, and gallery block add ${g.slice(8)} puts one of Gallery's own in`:""}.`),process.exit(1)}k.places.includes("page")||(console.error(`${g} is a block of documents (its manifest's places has no "page"): on a custom page its card says so and runs nothing, so there is nothing to try there (gallery block try tries it in a document).`),process.exit(1)),console.log(`${g} in card ${l} of ${t}, at ${f}:${$}: ${L(i.html)}`),w&&console.log(`Steps: ${r.length} from ${L(w)}, made one after another in one page`);let S=await q({command:`gallery page try ${t}`});if(!S.ok){console.log(`UNVERIFIED ${t}: ${S.message}`),process.exitCode=3;return}let{pageAloneOf:j}=await import("./chunk-UJQJKNGK.mjs");await oe(e);let B=[],G=async u=>{let b=await te(e,{directory:i.folder,files:i,text:u});return B.push(b.slug),b},I=Re({card:l,found:k});try{let u=o?{slug:t,file:i.html}:await G(m),b=j(S.port,u.slug);console.log(o?`Page: ${b} (the custom page alone, editable: the Agent's own; --keep: what ${re(r)} write stays in ${f}, and every page open on it shows it, the user's too; the server runs on after this command)`:`Page: ${b} (a scratch copy of ${t}, its page alone, editable, made for this trial and gone at its end: ${f} is not written, and no page of the user's shows the trial; the server runs on after this command)`);let O=M();if(!O){console.log(`UNVERIFIED ${t}: no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one), so nothing was tried`),process.exitCode=3;return}let v;try{v=await J({executablePath:O,args:z()})}catch(R){console.log(`UNVERIFIED ${t}: the browser ${O} did not start, twice, each time with a fresh profile (${K(R)}; GALLERY_BROWSER=<its executable> picks another), so nothing was tried`),process.exitCode=3;return}let A=P.join(Ee(e).qa,t,"try");try{await N.rm(A,{recursive:!0,force:!0}),await N.mkdir(A,{recursive:!0});let R=async y=>{if(o)return{address:b,file:u.file};let W=await G(y);return{address:j(S.port,W.slug),file:W.file}},U;try{U=await ae(v.browser,{root:e,address:b,fresh:R,steps:r,keep:o,file:u.file,name:f,line:$,found:k,out:A,host:I})}catch(y){if(y instanceof E&&y.made&&console.log(ce({name:f,steps:r,keep:o,host:I},y.made).join(`
|
|
5
5
|
`)),y.stuck)return ne(t,y,f,o);throw y}let{lines:ue,code:he}=ie({slug:t,name:f,steps:r,keep:o,host:I},U);console.log(ue.join(`
|
|
6
6
|
`)),process.exitCode=he}finally{await v.close()}}finally{for(let u of B)await se(e,u)}}export{xe as a,ke as b,de as c,Ce as d,Ie as e,Ae as f,Re as g,Ke as h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q}from"./chunk-
|
|
2
|
+
import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q}from"./chunk-MXUBKDRO.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{h as buildReports,d as checkReports,f as checkSelectedReports,b as exportFailures,k as exportReports,p as failureSummary,e as handInBlockers,l as notesByKind,m as notesOf,j as offlineReports,o as printFailures,c as quickFailures,a as repeatedIdFailures,q as reportFailures,n as reportNotes,i as withExportPolicy,g as writeSharedAssets};
|