@heycys/gallery 0.1.0 → 0.1.1
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 +51 -1
- package/browser/editor/components/callout/index.mjs +40 -15
- package/browser/editor/components/columns/page.mjs +41 -28
- package/browser/editor/components/details/index.mjs +2 -1
- package/browser/editor/components/dialog/index.mjs +2 -1
- package/browser/editor/components/dialog/page.mjs +0 -18
- package/browser/editor/components/divider/index.mjs +1 -1
- package/browser/editor/components/figure/page.mjs +10 -1
- package/browser/editor/components/file/page.mjs +2 -2
- package/browser/editor/components/flowchart/add.mjs +2 -2
- package/browser/editor/components/heading/index.mjs +2 -0
- package/browser/editor/components/heading/page.mjs +6 -0
- package/browser/editor/components/highlight/index.mjs +4 -20
- package/browser/editor/components/icons.mjs +5 -2
- package/browser/editor/components/image/page.mjs +2 -2
- package/browser/editor/components/installed/index.mjs +71 -25
- package/browser/editor/components/installed/page.mjs +122 -21
- package/browser/editor/components/kit.mjs +3 -0
- package/browser/editor/components/media/page.mjs +44 -14
- package/browser/editor/components/pages.mjs +2 -2
- package/browser/editor/components/registry.mjs +56 -30
- package/browser/editor/components/section/index.mjs +2 -1
- package/browser/editor/components/set-apart.mjs +24 -0
- package/browser/editor/components/table/index.mjs +5 -3
- package/browser/editor/components/table/page.mjs +29 -18
- package/browser/editor/page/annotate/anchors.mjs +4 -3
- package/browser/editor/page/annotate/index.mjs +61 -34
- package/browser/editor/page/autosave.mjs +50 -4
- package/browser/editor/page/beside.mjs +5 -5
- package/browser/editor/page/block-menu/colors.mjs +3 -1
- package/browser/editor/page/block-menu/index.mjs +8 -6
- package/browser/editor/page/blocks.mjs +16 -7
- package/browser/editor/page/caret.mjs +4 -1
- package/browser/editor/page/changes/bar.mjs +102 -0
- package/browser/editor/page/changes/ghost.mjs +206 -0
- package/browser/editor/page/changes/gone-words.mjs +94 -0
- package/browser/editor/page/changes/index.mjs +447 -0
- package/browser/editor/page/changes/words.mjs +27 -0
- package/browser/editor/page/clipboard/import/colors.mjs +3 -3
- package/browser/editor/page/clipboard/index.mjs +32 -13
- package/browser/editor/page/clipboard/own/blocks.mjs +14 -5
- package/browser/editor/page/clipboard/own/describe.mjs +16 -7
- package/browser/editor/page/clipboard/own/export.mjs +6 -6
- package/browser/editor/page/clipboard/own/selection.mjs +2 -2
- package/browser/editor/page/clipboard/own/writers.mjs +0 -11
- package/browser/editor/page/columns/index.mjs +1 -1
- package/browser/editor/page/commit.mjs +19 -4
- package/browser/editor/page/conflicts.mjs +6 -26
- package/browser/editor/page/convert.mjs +8 -7
- package/browser/editor/page/core.mjs +55 -17
- package/browser/editor/page/drag/index.mjs +40 -24
- package/browser/editor/page/drag/preview.mjs +9 -4
- package/browser/editor/page/editor.mjs +70 -15
- package/browser/editor/page/emoji-picker/emoji-tab.mjs +22 -13
- package/browser/editor/page/emoji-picker/grid.mjs +7 -5
- package/browser/editor/page/emoji-picker/icon-tab.mjs +4 -4
- package/browser/editor/page/emoji-picker/icons.mjs +0 -1
- package/browser/editor/page/emoji-picker/index.mjs +11 -9
- package/browser/editor/page/emoji-picker/styles.mjs +161 -2
- package/browser/editor/page/emoji-picker/support.mjs +6 -4
- package/browser/editor/page/emoji-picker/upload.mjs +12 -11
- package/browser/editor/page/fills.mjs +5 -3
- package/browser/editor/page/fold/index.mjs +348 -0
- package/browser/editor/page/fold/rule.mjs +125 -0
- package/browser/editor/page/folded.mjs +23 -0
- package/browser/editor/page/format-bar/bar.mjs +2 -1
- package/browser/editor/page/format-bar/index.mjs +1 -1
- package/browser/editor/page/geometry.mjs +8 -6
- package/browser/editor/page/handle/index.mjs +17 -6
- package/browser/editor/page/hints/index.mjs +1 -1
- package/browser/editor/page/insert/index.mjs +30 -17
- package/browser/editor/page/long-runs.mjs +75 -0
- package/browser/editor/page/look.mjs +15 -3
- package/browser/editor/page/margin.mjs +45 -24
- package/browser/editor/page/menu.mjs +69 -25
- package/browser/editor/page/merge.mjs +24 -0
- package/browser/editor/page/notices.mjs +1 -1
- package/browser/editor/page/offered.mjs +1 -1
- package/browser/editor/page/outline/folds.mjs +11 -10
- package/browser/editor/page/outline/index.mjs +131 -45
- package/browser/editor/page/outline/list.mjs +23 -11
- package/browser/editor/page/outline/read.mjs +1 -1
- package/browser/editor/page/outline/strip.mjs +7 -1
- package/browser/editor/page/panel.mjs +5 -4
- package/browser/editor/page/resize/index.mjs +1 -1
- package/browser/editor/page/selection/delete.mjs +8 -6
- package/browser/editor/page/selection/index.mjs +10 -3
- package/browser/editor/page/session.mjs +54 -3
- package/browser/editor/page/table/cell-bar.mjs +4 -1
- package/browser/editor/page/table/cells.mjs +1 -1
- package/browser/editor/page/table/icons.mjs +1 -1
- package/browser/editor/page/table/index.mjs +13 -8
- package/browser/editor/page/table/widths.mjs +9 -4
- package/browser/editor/page/text-select/index.mjs +18 -3
- package/browser/editor/page/tooltip.mjs +1 -1
- package/browser/editor/page/type-grid.mjs +4 -3
- package/browser/editor/page/typing/code-edges.mjs +63 -17
- package/browser/editor/page/typing/index.mjs +12 -6
- package/browser/editor/page/typing/leave.mjs +1 -1
- package/browser/shared/annotations.mjs +8 -10
- package/browser/shared/code-folds.mjs +5 -1
- package/browser/shared/colors.mjs +15 -13
- package/browser/shared/component-catalog.mjs +24 -10
- package/browser/shared/components/callout.mjs +4 -2
- package/browser/shared/components/index.mjs +61 -7
- package/browser/shared/components/installed.mjs +75 -5
- package/browser/shared/components/page.mjs +10 -1
- package/browser/shared/components/table.mjs +1 -1
- package/browser/shared/components/text.mjs +2 -2
- package/browser/shared/document-look.mjs +178 -0
- package/browser/shared/emoji/data/LICENSE-lucide.txt +43 -0
- package/browser/shared/emoji/data/README.md +4 -2
- package/browser/shared/emoji/data/categories.json +1 -1
- package/browser/shared/emoji/data/keywords-en.json +1 -1
- package/browser/shared/emoji/data/keywords-zh.json +1 -1
- package/browser/shared/emoji/data/names.json +1 -1
- package/browser/shared/emoji/data/positions.json +1 -1
- package/browser/shared/emoji/data/twemoji-index.json +1 -1
- package/browser/shared/emoji/data/twemoji-svg.bin +0 -0
- package/browser/shared/emoji/data.mjs +10 -12
- package/browser/shared/emoji/emoji.mjs +8 -7
- package/browser/shared/emoji/icon-value.mjs +4 -3
- package/browser/shared/html-tree.mjs +11 -5
- package/browser/shared/i18n/en.mjs +67 -8
- package/browser/shared/long-runs.mjs +39 -0
- package/browser/shared/new-names.mjs +5 -2
- package/browser/shared/outline.mjs +194 -0
- package/browser/shared/preferences.mjs +10 -4
- package/browser/shared/session.mjs +5 -4
- package/browser/shared/workspace-look.mjs +91 -0
- package/browser/shared/zoom.mjs +5 -5
- package/dist/chunk-3HIRPVLU.mjs +2 -0
- package/dist/chunk-4FS7Z7WR.mjs +2 -0
- package/dist/{chunk-LHTFLRB6.mjs → chunk-5MHMDLZD.mjs} +2 -2
- package/dist/{chunk-YXAUQPVK.mjs → chunk-5ZKJ3H4P.mjs} +3 -3
- package/dist/{chunk-ZBIM6ARY.mjs → chunk-64K7IPLO.mjs} +55 -16
- package/dist/{chunk-QYKCJ7FG.mjs → chunk-6QXGZM36.mjs} +1 -1
- package/dist/chunk-6RGJOMJP.mjs +16 -0
- package/dist/{chunk-EUX7IC5J.mjs → chunk-7DTINW6U.mjs} +2 -2
- package/dist/{chunk-6CYG3Z4V.mjs → chunk-AJ73XJF3.mjs} +1 -1
- package/dist/chunk-AUZGSZJH.mjs +13 -0
- package/dist/{chunk-7QQBR7PB.mjs → chunk-BFE45AKL.mjs} +1 -1
- package/dist/chunk-BGGDRNYQ.mjs +10 -0
- package/dist/{chunk-L4DVONOG.mjs → chunk-BXO2ZY5P.mjs} +1 -1
- package/dist/chunk-CEH4MRCC.mjs +2 -0
- package/dist/chunk-CY2FNNAB.mjs +16 -0
- package/dist/{chunk-LC7YNQFG.mjs → chunk-DFUDV4LX.mjs} +1 -1
- package/dist/chunk-DKXG4XDG.mjs +2 -0
- package/dist/chunk-E7LWZRXY.mjs +4 -0
- package/dist/chunk-EZQ34M3F.mjs +124 -0
- package/dist/chunk-FDLXYYG4.mjs +4 -0
- package/dist/chunk-FUKQNOQS.mjs +9 -0
- package/dist/{chunk-DB4WKGYF.mjs → chunk-GB5SOYQJ.mjs} +2 -2
- package/dist/{chunk-ACOPDCNB.mjs → chunk-IVDLMMBD.mjs} +1 -1
- package/dist/chunk-JPOSLGOC.mjs +6 -0
- package/dist/chunk-JVHHHGEA.mjs +3 -0
- package/dist/chunk-L3QKH4OK.mjs +26 -0
- package/dist/{chunk-B3VTYBYR.mjs → chunk-LCTHTZIL.mjs} +2 -2
- package/dist/chunk-LEF6DRCK.mjs +59 -0
- package/dist/chunk-LS4F7JUM.mjs +2 -0
- package/dist/chunk-NO5NJCHO.mjs +2 -0
- package/dist/{chunk-UNUEWH4S.mjs → chunk-NQPVAU63.mjs} +1 -1
- package/dist/chunk-O35FIXRB.mjs +2 -0
- package/dist/chunk-PL6GHLGD.mjs +15 -0
- package/dist/{chunk-G7TOXONE.mjs → chunk-QJIR2BLP.mjs} +1 -1
- package/dist/chunk-QUPLVPB2.mjs +7 -0
- package/dist/chunk-R7BNENLY.mjs +4 -0
- package/dist/chunk-S6O4UHLC.mjs +2 -0
- package/dist/{chunk-HMHK3EQ6.mjs → chunk-SGJWQKEI.mjs} +1 -1
- package/dist/chunk-SYGN7GLU.mjs +2 -0
- package/dist/chunk-TYK6VNAB.mjs +10 -0
- package/dist/{chunk-EVJ3BX3M.mjs → chunk-U6KNPJPR.mjs} +1 -1
- package/dist/{chunk-YZ5Z6H4W.mjs → chunk-UALRNVSE.mjs} +1 -1
- package/dist/chunk-UMHUSOPJ.mjs +2 -0
- package/dist/chunk-V3HXVQEM.mjs +2 -0
- package/dist/{chunk-UXUK4PMC.mjs → chunk-V5JTW2LH.mjs} +1 -1
- package/dist/chunk-V5VXUJKG.mjs +2 -0
- package/dist/chunk-VBXMADMP.mjs +2 -0
- package/dist/chunk-VNV55RUA.mjs +2 -0
- package/dist/chunk-VPD2PS35.mjs +2 -0
- package/dist/chunk-W3BGBJQW.mjs +2 -0
- package/dist/chunk-W4VKN3GF.mjs +7 -0
- package/dist/chunk-W5BXXPDJ.mjs +3 -0
- package/dist/{chunk-Z52HTUW7.mjs → chunk-XNROSH2T.mjs} +2 -2
- package/dist/chunk-XUNHRCOG.mjs +6 -0
- package/dist/{chunk-6U2SLSDN.mjs → chunk-Y6RLRPG3.mjs} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/worker.mjs +1 -1
- package/kit/math.js +18 -2
- package/kit/report.css +248 -137
- package/kit/runtime.js +126 -51
- package/kit/tables.js +51 -1
- package/kit/ui.js +97 -0
- package/package.json +1 -1
- package/release.json +8 -8
- package/sdk/doc-kit.d.ts +9 -3
- package/skill/SKILL.md +22 -10
- package/skill/references/building-components.md +46 -6
- package/skill/references/example-report.html +1 -1
- package/skill/references/writing-html.md +4 -4
- package/skill/sdk/doc-kit.d.ts +9 -3
- package/web/assets/index-Bh74DfsV.css +1 -0
- package/web/assets/index-UW0RyFFt.js +13 -0
- package/web/index.html +2 -2
- package/browser/editor/components/callout/page.mjs +0 -13
- package/dist/chunk-2PBALTR3.mjs +0 -57
- package/dist/chunk-3LA3EMDE.mjs +0 -15
- package/dist/chunk-5FRMCDPY.mjs +0 -16
- package/dist/chunk-5LEK2CBS.mjs +0 -2
- package/dist/chunk-5OFN5AHC.mjs +0 -2
- package/dist/chunk-5SIYS5HN.mjs +0 -2
- package/dist/chunk-5TEK3RAD.mjs +0 -2
- package/dist/chunk-7GHT2UCA.mjs +0 -15
- package/dist/chunk-ATCJYAR4.mjs +0 -2
- package/dist/chunk-C7HWOBIF.mjs +0 -2
- package/dist/chunk-E7VYDG2X.mjs +0 -2
- package/dist/chunk-FQGQH4KM.mjs +0 -2
- package/dist/chunk-GPF4YWWB.mjs +0 -9
- package/dist/chunk-GYQV7Y4J.mjs +0 -120
- package/dist/chunk-HQQMJCQJ.mjs +0 -10
- package/dist/chunk-IERUOGC3.mjs +0 -6
- package/dist/chunk-ITNLYXXV.mjs +0 -3
- package/dist/chunk-NFIBI4IP.mjs +0 -26
- package/dist/chunk-O52JMOCZ.mjs +0 -2
- package/dist/chunk-QMQUXTU4.mjs +0 -12
- package/dist/chunk-QVWVFC5K.mjs +0 -6
- package/dist/chunk-QZY6Q64C.mjs +0 -2
- package/dist/chunk-TDQP3DKQ.mjs +0 -10
- package/dist/chunk-V4CPWKMZ.mjs +0 -2
- package/dist/chunk-VACRB2NE.mjs +0 -3
- package/dist/chunk-W63L7367.mjs +0 -7
- package/dist/chunk-W7CXPCRV.mjs +0 -6
- package/dist/chunk-XINNG4F2.mjs +0 -4
- package/dist/chunk-YL2DPWVS.mjs +0 -4
- package/web/assets/index-B6Ai3wsa.js +0 -13
- package/web/assets/index-SYPC3EZy.css +0 -1
package/dist/chunk-W63L7367.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as P,c as C,e as at}from"./chunk-A55HN5OK.mjs";at();import{isUtf8 as ct}from"node:buffer";import{createHash as lt}from"node:crypto";import{lstatSync as pt,readFileSync as A,realpathSync as F,statSync as mt}from"node:fs";import dt from"node:fs/promises";import y from"node:path";import{isInstance as ft,parseCompound as ut,parsePart as gt,parseSelector as ht,partOf as yt}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as B,NO_TEXT as bt,PACKAGE_ID as J,PACKAGE_MARK as wt,instanceMatch as kt,refusedInCopy as Et,settingState as Ot}from"../browser/shared/components/installed.mjs";import{writeAtomic as St}from"../browser/shared/files.mjs";import{attr as At,walk as vt}from"../browser/shared/html-tree.mjs";import{inLanguage as $t,refusal as Z,said as o,saying as xt,told as Nt}from"../browser/shared/i18n/index.mjs";import{DEVICE_NAMES as Tt,PACKAGE_MANIFEST as w,WORKSPACE_MARK as It,findWorkspace as jt,layoutOf as H,markerOf as _t,packageFolders as Mt}from"../browser/shared/workspace.mjs";var z=1,L=new Set(["code","state","sheets","tokens","dialogs","katex-styles","katex","katex-auto-render","math","d3","charts","tables"]),Pt=["id","apiVersion","version","name","description","words","parts","runtime","assets","markdown","schema"],Ct=["at","edit","optional","min","max"],Ft=["generated","attrs"],zt=["text","data","none"],Lt=["parts","text"],Y=["kit.js","style.css","preview.svg"],E="template.html",Rt=[w,E,...Y],v=t=>[...new Set([...Rt,...t])].sort(),Dt=/^(?:[A-Za-z0-9_-][A-Za-z0-9._-]*\/)*[A-Za-z0-9_-][A-Za-z0-9._-]*\.[A-Za-z0-9]+$/,Vt=/^(?:doc-|data-doc-|data-ge-)|^data-block-id$/i,R=256*1024,u=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),f=t=>typeof t=="string"&&t.trim()!=="",$=(t,n)=>t.id<n.id?-1:1,i=t=>{throw Z(t)},g=t=>{let n=lt("sha256");return t(n),n.digest("hex").slice(0,16)};function b(t,n){let s=y.join(t,n);try{let e=pt(s,{throwIfNoEntry:!1});if(!e)return null;if(!e.isSymbolicLink()&&!n.includes("/"))return s;let r=F.native(s);return r.startsWith(F.native(t)+y.sep)?r:null}catch{return null}}function q(t,n){try{let s=b(t,n);return s&&A(s)}catch{return null}}var D=new Map,Kt=2e3;function Wt(t){let{size:n,mtimeMs:s}=mt(t),e=D.get(t);if(e?.size===n&&e.time===s)return e.digest;let r=g(c=>c.update(A(t)));return Date.now()-s>Kt&&D.set(t,{size:n,time:s,digest:r}),r}var x=(t,n)=>g(s=>{for(let e of n){let r=b(t,e),c="none";try{r&&(c=Wt(r))}catch{}s.update(`${e}\0${c}
|
|
3
|
-
`)}}),X=t=>t.toString("utf8").replace(/^\uFEFF/,""),Q=(t,n)=>{t.length>R&&i(o("{0} \u6709 {1} KB\uFF0C\u800C\u6BCF\u4E00\u9875\u90FD\u5E26\u7740\u5B83\uFF0C\u6700\u591A {2} KB",n,Math.ceil(t.length/1024),R/1024))},N=(t,n,s="")=>{for(let e of Object.keys(t))n.includes(e)||i(o("{0} \u4E0D\u662F\u7EC4\u4EF6\u5305\u80FD\u5199\u7684\u5B57\u6BB5",`${s}${e}`))},V=(t,n)=>{for(let s of n)t[s]===void 0&&i(o("\u7F3A\u5C11 {0}",s))},K=(t,n)=>{(!u(t)||!f(t.zh)||!f(t.en)||Object.keys(t).length!==2)&&i(o("{0} \u8981\u5199\u6210 { zh, en } \u4E24\u79CD\u8BED\u8A00\u7684\u6587\u5B57",n))},Gt=t=>t.split(",").map(n=>n.split(">").at(-1).trim()).filter(n=>n!=="*").map(n=>ut(n).tag);function Ut(t,n){let s=`parts.${t}`;u(n)||i(o("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868",s)),N(n,Ct,`${s}.`),f(n.at)||i(o("\u7F3A\u5C11 {0}",`${s}.at`));try{gt(n.at)}catch(e){i(o("{0} \u5199\u9519\u4E86\uFF1A{1}",`${s}.at`,e.message))}zt.includes(n.edit)||i(o("{0} \u7684 edit \u53EA\u80FD\u662F text\u3001data \u6216 none",s)),n.optional!==void 0&&typeof n.optional!="boolean"&&i(o("{0} \u8981\u5199\u6210 true \u6216 false",`${s}.optional`));for(let e of["min","max"])n[e]!==void 0&&!(Number.isInteger(n[e])&&n[e]>=0)&&i(o("{0} \u8981\u5199\u6210\u4E0D\u5C0F\u4E8E 0 \u7684\u6574\u6570",`${s}.${e}`));if(n.min>n.max&&i(o("{0} \u7684 min \u6BD4 max \u5927\uFF0C\u6CA1\u6709\u5B9E\u4F8B\u80FD\u6EE1\u8DB3",s)),n.edit==="text")for(let e of Gt(n.at))bt.has(e)&&i(o("{0} \u4E0D\u80FD\u6309\u6587\u5B57\u7F16\u8F91\uFF1A<{1}> \u4E0D\u662F\u80FD\u6253\u5B57\u7684\u6587\u5B57",s,e))}var Bt=t=>t.split(",").some(n=>n.split(">").every(s=>[":scope","*"].includes(s.trim())));function Jt(t,n){if(t===void 0)return null;u(t)||i(o("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","runtime")),N(t,Ft,"runtime.");let s=`[${B}="${n}"]`,e=(l,p)=>{try{if(!f(l))throw new Error("no selector");ht(l)}catch(m){i(o("{0} \u5199\u9519\u4E86\uFF1A{1}",p,m.message))}return l.split(",").map(m=>m.trim().startsWith(":scope")?m.trim().replace(":scope",s):`${s} ${m.trim()}`).join(", ")},{generated:r=[],attrs:c={}}=t;Array.isArray(r)||i(o("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","runtime.generated")),u(c)||i(o("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","runtime.attrs"));for(let l of Object.values(c)){(!Array.isArray(l)||!l.every(f))&&i(o("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","runtime.attrs"));for(let p of l)Vt.test(p)&&i(o("{0} \u662F Gallery \u81EA\u5DF1\u7684\u540D\u5B57\uFF0C\u7EC4\u4EF6\u5305\u4E0D\u80FD\u7528",p))}let a=l=>{let p=e(l,"runtime.generated");return Bt(l)&&i(o("{0} \u7684 {1} \u662F\u6574\u4E2A\u5B9E\u4F8B\uFF0C\u800C\u8FD9\u91CC\u53EA\u5199\u5B83\u751F\u6210\u7684\u8282\u70B9","runtime.generated",l)),p};return{generated:r.map(a),attrs:Object.fromEntries(Object.entries(c).map(([l,p])=>[e(l,"runtime.attrs"),p]))}}function Zt(t,n){if(t===void 0)return{kit:[],own:[]};(!Array.isArray(t)||!t.every(f))&&i(o("{0} \u8981\u5199\u6210\u4E00\u4E32\u6587\u5B57","assets"));let s=t.filter(e=>!L.has(e));for(let e of s)Dt.test(e)||i(o("assets \u91CC\u7684 {0} \u65E2\u4E0D\u662F\u5957\u4EF6\u7684\u8D44\u6E90\uFF0C\u4E5F\u4E0D\u662F\u5305\u91CC\u7684\u6587\u4EF6",e)),b(n,e)||i(o("assets \u5199\u4E86 {0}\uFF0C\u5305\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6587\u4EF6",e));return{kit:t.filter(e=>L.has(e)),own:s}}function Ht(t,n,s){let e;try{e=JSON.parse(s)}catch(p){i(o("component.json \u4E0D\u662F JSON\uFF1A{0}",p.message))}u(e)||i(o("component.json \u5199\u7684\u4E0D\u662F\u4E00\u4E2A\u5BF9\u8C61")),J.test(t)||i(o("{0} \u4E0D\u80FD\u505A\u7EC4\u4EF6\u5305\u7684 id\uFF1A\u8303\u56F4\u548C\u540D\u5B57\u90FD\u53EA\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26",t));for(let p of t.split("/"))Tt.has(p)&&i(o("{0} \u4E0D\u80FD\u505A\u7EC4\u4EF6\u5305\u7684 id\uFF1A{1} \u662F Windows \u7559\u7ED9\u8BBE\u5907\u7684\u540D\u5B57",t,p));if(e.id!==t&&i(o("\u6E05\u5355\u7684 id \u662F {0}\uFF0C\u548C\u5B83\u7684\u6587\u4EF6\u5939 {1} \u4E0D\u4E00\u6837",String(e.id),t)),V(e,["apiVersion"]),(!Number.isInteger(e.apiVersion)||e.apiVersion<1)&&i(o("apiVersion \u8981\u5199\u6210\u4E00\u4E2A\u6B63\u6574\u6570")),e.apiVersion!==z)throw Z(o("\u8FD9\u4E2A\u7EC4\u4EF6\u5305\u8981 apiVersion {0}\uFF0C\u8FD9\u4E00\u7248 Gallery \u53EA\u652F\u6301 {1}",e.apiVersion,z),{disabled:!0,version:f(e.version)?e.version:null});N(e,Pt),V(e,["version","name","description","parts"]),f(e.version)||i(o("{0} \u8981\u5199\u6210\u6587\u5B57","version")),K(e.name,"name"),K(e.description,"description"),e.words!==void 0&&typeof e.words!="string"&&i(o("{0} \u8981\u5199\u6210\u6587\u5B57","words")),u(e.parts)||i(o("{0} \u8981\u5199\u6210\u4E00\u5F20\u8868","parts"));for(let[p,m]of Object.entries(e.parts))Ut(p,m);let r=Jt(e.runtime,t),{kit:c,own:a}=Zt(e.assets,n);e.markdown!==void 0&&!Lt.includes(e.markdown)&&i(o("markdown \u53EA\u80FD\u662F parts \u6216 text")),e.schema!==void 0&&!(Number.isInteger(e.schema)&&e.schema>=1)&&i(o("schema \u8981\u5199\u6210\u4E00\u4E2A\u6B63\u6574\u6570"));let l=q(n,E);return l&&Q(l,E),{id:t,match:kt(t),parts:e.parts,...r?{runtime:r}:{},...e.schema!==void 0?{schema:e.schema}:{},apiVersion:e.apiVersion,version:e.version,name:e.name,description:e.description,words:e.words??"",assets:c,markdown:e.markdown??"parts",files:[...new Set([...Y.filter(p=>b(n,p)),...a])],template:l&&X(l),folder:n,definition:g(p=>p.update(s)),stamp:x(n,v(a))}}function Yt(t,n){try{let s=q(n,w);return s||i(o("\u8BFB\u4E0D\u51FA component.json")),ct(s)||i(o("{0} \u4E0D\u662F UTF-8 \u7F16\u7801\uFF1A\u8BF7\u5B58\u6210 UTF-8",w)),Q(s,w),Ht(t,n,X(s))}catch(s){let e=xt(s),r=g(c=>c.update(`${x(n,v([]))} ${JSON.stringify(e)}`));return{id:t.toLowerCase(),stamp:r,problem:e,disabled:s.disabled===!0,version:s.version??null}}}var T=()=>jt().root,qt=/^[a-z0-9][a-z0-9-]*(?:\/[a-z0-9][a-z0-9-]*)?$/,W=(t,n)=>[...new Set(Array.isArray(t)?t.filter(s=>typeof s=="string"&&n.test(s)):[])],I=t=>({hidden:W(t?.components?.hidden,qt),disabled:W(t?.components?.disabled,J)}),j=o("gallery.json \u8BFB\u4E0D\u51FA\u6765\uFF1A\u6539\u597D\u8FD9\u4E2A\u6587\u4EF6\u540E\u518D\u8BD5"),Xt=o("gallery.json \u4E0D\u662F Gallery \u7684\u6587\u4EF6");function O(t){if(t===null)return{value:null};let{value:n,ours:s,reads:e}=_t(t);return s?{value:n}:{problem:e?Xt:j}}function Qt(t){try{return O(A(H(t).marker,"utf8"))}catch(n){return n.code==="ENOENT"?O(null):{problem:j}}}var te=["EPERM","EACCES","EBUSY","EROFS"];async function Ee(t,{id:n,hidden:s,disabled:e}){let r=H(t).marker,c=await dt.readFile(r,"utf8").catch(d=>{if(d.code==="ENOENT")return null;i(j)}),{value:a,problem:l}=O(c);l&&i(l);let p=(d,M)=>M===void 0?d:M?[...new Set([...d,n])]:d.filter(it=>it!==n),{hidden:m,disabled:ot}=I(a),rt={...u(a?.components)?a.components:{},hidden:p(m,s),disabled:p(ot,e)};await St(r,`${JSON.stringify({...a??It,components:rt},null,2)}
|
|
4
|
-
`,{expect:c}).catch(d=>{throw te.includes(d.code)&&i(o("gallery.json \u5199\u4E0D\u8FDB\u53BB\uFF1A\u53EF\u80FD\u662F\u53EA\u8BFB\u7684\uFF0C\u6216\u88AB\u522B\u7684\u7A0B\u5E8F\u5360\u7740")),d})||i(o("gallery.json \u521A\u521A\u88AB\u6539\u8FC7\uFF1A\u518D\u8BD5\u4E00\u6B21"))}var ee=t=>({...t,off:!0,disabled:!0,problem:o("\u5728\u8BBE\u7F6E\u91CC\u505C\u7528\u4E86"),stamp:g(n=>n.update(`${t.stamp} off`))}),k=I(null),ne=({packages:t,problems:n,settings:s=k})=>g(e=>{for(let{id:r,stamp:c}of[...t.values(),...n.values()].sort($))e.update(`${r} ${c}
|
|
5
|
-
`);e.update(`hidden ${[...s.hidden].sort().join(" ")}
|
|
6
|
-
`),e.update(`settings ${s.problem?.message??""}
|
|
7
|
-
`)});function se(t,n){let{value:s,problem:e}=Qt(t);return e?{hidden:n.hidden,disabled:n.disabled,problem:e}:I(s)}function oe(t=T(),n=k,{on:s=null}={}){let e=se(t,n),r=new Map,c=new Map;for(let{id:a,folder:l}of Mt(t)){let p=Yt(a,l);(p.problem?c:r).set(p.id,p)}for(let a of r.keys())c.delete(a);for(let a of e.disabled)!r.has(a)||a===s||(c.set(a,ee(r.get(a))),r.delete(a));return{packages:r,problems:c,settings:e,stamp:ne({packages:r,problems:c,settings:e})}}var h=new Map;function Oe(t=T()){let n=y.resolve(t);return h.has(n)||h.set(n,oe(n)),h.get(n)}var Se=(t,n)=>{h.set(y.resolve(t),n)},Ae=(t=T())=>{h.delete(y.resolve(t))},G=(t,n)=>$t(t,()=>Nt(n)),_=t=>({zh:G("zh",t),en:G("en",t)}),ve=({settings:t})=>t.problem?_(t.problem):null,tt=(t,n)=>t.problem?t.disabled?"disabled":"broken":Ot(t.id,n),et=({id:t,match:n,parts:s,runtime:e,schema:r})=>({id:t,match:n,parts:s,...e?{runtime:e}:{},...r!==void 0?{schema:r}:{}}),$e=({packages:t,problems:n})=>[...[...t.values()].map(et),...[...n.values()].map(({id:s,problem:e})=>({id:s,problem:_(e)}))],re=t=>`DocKit.describe(${JSON.stringify(t)});`.replace(/</g,"\\u003c"),S=({id:t,stamp:n},s)=>`/__gallery/components/${t}/${s}?v=${n}`;function ie(t){let n=`${wt}="${t.id}"`,s=e=>t.files.includes(e);return{styles:s("style.css")?[`<link rel="stylesheet" href="${S(t,"style.css")}" ${n}>`]:[],scripts:[`<script ${n}>${re({...et(t),...s("kit.js")?{script:!0}:{}})}</script>`,...s("kit.js")?[`<script src="${S(t,"kit.js")}" ${n}></script>`]:[]]}}var xe=({folder:t},n)=>b(t,n),Ne=({folder:t,files:n})=>x(t,v(n));function U(t,n){let s=C(t,{sourceCodeLocationInfo:!0}).childNodes.filter(r=>r.tagName||r.nodeName==="#text"&&r.value.trim()),[e]=s;return s.length===1&&e.tagName&&ft(e)&&At(e,B)===n&&e.sourceCodeLocation.endTag?e:null}function ae(t,n){let s=U(t,n),e=s&&P(s),r=e&&U(e,n);return r?{markup:e,root:r}:null}function nt({id:t,template:n,parts:s}){if(!n)return{};let e=ae(n,t);if(!e)return{problem:o("template.html \u8981\u662F\u8FD9\u4E2A\u7EC4\u4EF6\u5305\u7684\u4E00\u4E2A\u5B9E\u4F8B\uFF0C\u6709\u81EA\u5DF1\u7684\u7ED3\u675F\u6807\u7B7E\uFF0C\u6B64\u5916\u4EC0\u4E48\u90FD\u6CA1\u6709")};let r=[];if(vt({childNodes:[e.root]},a=>{Et(a.tagName,a.attrs)&&r.push(a.tagName)}),r.length>0)return{problem:o("template.html \u91CC\u7684 <{0}> \u8FDB\u4E0D\u4E86\u65B0\u5EFA\u7684\u5757\uFF1A\u811A\u672C\u3001\u4E8B\u4EF6\u3001\u6837\u5F0F\u548C Gallery \u81EA\u5DF1\u7684\u6807\u8BB0\u90FD\u4E0D\u5199\u5728\u6A21\u677F\u91CC",r[0])};let c=Object.entries(s).find(([,a])=>{let l=yt(e.root,a.at).length;return l<(a.optional?0:a.min??1)||l>(a.max??1/0)});return c?{problem:o("template.html \u7684 {0} \u548C\u6E05\u5355\u5199\u7684\u6570\u76EE\u4E0D\u7B26",c[0])}:{markup:e.markup}}var Te=t=>nt(t).problem??null,st=t=>nt(t).markup??null,Ie=({packages:t,settings:n=k})=>[...t.values()].sort($).map(s=>({id:s.id,version:s.version,name:s.name,description:s.description,words:s.words,definition:s.definition,stamp:s.stamp,template:st(s),preview:s.files.includes("preview.svg")?S(s,"preview.svg"):null,state:tt(s,n),markdown:s.markdown,assets:s.assets,tags:ie(s)})),je=({packages:t,problems:n,settings:s=k})=>[...t.values(),...n.values()].sort($).map(e=>({id:e.id,version:e.version??null,name:e.name??null,description:e.description??null,state:tt(e,s),reason:e.problem&&!e.off?_(e.problem):null,template:!!st(e),hidden:s.hidden.includes(e.id),disabled:s.disabled.includes(e.id)})),_e=({hidden:t,disabled:n})=>`settings ${t.join(",")} ${n.join(",")}`;export{Ee as a,ne as b,oe as c,Oe as d,Se as e,Ae as f,G as g,ve as h,$e as i,re as j,ie as k,xe as l,Ne as m,ae as n,Te as o,st as p,Ie as q,je as r,_e as s};
|
package/dist/chunk-W7CXPCRV.mjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{k as et}from"./chunk-QYKCJ7FG.mjs";import{a as nt}from"./chunk-E7VYDG2X.mjs";import L from"node:fs/promises";import rt from"node:path";import{writeAtomic as it}from"../browser/shared/files.mjs";import{documentFiles as wt}from"../browser/shared/workspace.mjs";var mt=s=>L.access(s).then(()=>!0,()=>!1);async function Ct(s,{create:d,slugOf:l,folderOf:p,fill:P,place:O,under:A="",said:c="\u5BFC\u5165\u81EA {0}",lang:M=null}){let E=[],v=[];async function h(f,F,C){let S=await l(f,C);await d(S,f.title,c.replace("{0}",()=>f.from),{lang:M});let R=p(S),{html:J,json:y}=wt(R),$=await L.readFile(J,"utf8");await it(J,et(await P({source:$,nodes:f.nodes,icon:f.icon,own:f.own,raws:f.raws,lang:f.lang}))),f.files.length&&await L.mkdir(rt.join(R,"assets"),{recursive:!0});for(let{from:N,name:T}of f.files){let x=rt.join(R,"assets",T);await mt(x)||await L.copyFile(N,x)}if(f.icon){let N=JSON.parse(await L.readFile(y,"utf8"));await it(y,`${JSON.stringify({...N,icon:f.icon},null,2)}
|
|
3
|
-
`)}await O(S,F),E.push(S);for(let N of f.children??[])await h(N,S,null);return S}for(let[f,F]of s.entries())v.push(await h(F,A,f));return{made:E,top:v}}import{randomBytes as dt}from"node:crypto";import w from"node:fs/promises";import u from"node:path";import{writeAtomic as _}from"../browser/shared/files.mjs";import{sendJson as W}from"../browser/shared/http.mjs";import{said as D,saying as ht}from"../browser/shared/i18n/index.mjs";import{reportsDirectory as pt}from"../browser/shared/paths.mjs";import{listReportSlugs as yt,slugPattern as g}from"../browser/shared/reports.mjs";import{COMPONENTS_FOLDER as Q,DOCUMENT_FOLDERS as kt,PAGE_SLUG as Ot,documentDirectory as jt,documentFiles as Y,layoutOf as gt,listTrash as vt,packageFolders as St,pageSlug as xt,slugTaken as bt,trashIdPattern as at}from"../browser/shared/workspace.mjs";import{MENTION as Et}from"../browser/shared/components/mention.mjs";import{findIn as Nt,reportLines as Pt,tidyQuery as Ft}from"../browser/shared/search.mjs";import{countWords as $t}from"../browser/shared/words.mjs";var Tt=([s,d,l,...p])=>p.length?D("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}\uFF1B{2} \u7B49 {3} \u6761",s,d,l,p.length+3):l!==void 0?D("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}\uFF1B{2}",s,d,l):d!==void 0?D("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}\uFF1B{1}",s,d):D("\u68C0\u67E5\u6CA1\u6709\u901A\u8FC7\uFF1A{0}",s),ot=s=>s==="en"?"en":null;async function H(s,d){for(let l=0;;l++)try{return await w.rename(s,d)}catch(p){if(!["EPERM","EBUSY","EACCES"].includes(p.code))throw p;if(l>=5)break;await new Promise(P=>setTimeout(P,60*(l+1)))}await w.cp(s,d,{recursive:!0,errorOnExist:!0,force:!1}),await w.rm(s,{recursive:!0,force:!0,maxRetries:5})}var At=s=>u.resolve(s);function qt({edits:s,reports:d,reportsDirectory:l=pt,server:p={kind:"dev",version:null,stop:null},components:P=null}){let{trash:O,outline:A}=gt(l),c=(t,n,e)=>[t,{ok:!1,reason:n,...ht(e)}],M=t=>w.readFile(t,"utf8").then(JSON.parse).catch(()=>null),E=t=>jt(t,l),v=t=>Y(E(t)),h=t=>u.join(l,t),f=t=>T(Y(h(t)).html),F=async t=>{let n=await w.readdir(h(t),{withFileTypes:!0});if(t!==Q)return n.map(({name:r})=>r);let e=new Set(St(l).map(({id:r})=>r.split("/")[0]));return n.filter(r=>r.isFile()||kt.includes(r.name)&&!e.has(r.name)).map(({name:r})=>r)},C=async(t,n,e)=>{await w.mkdir(e,{recursive:!0});let r=[];try{for(let i of t)await H(u.join(n,i),u.join(e,i)),r.push(i)}catch(i){for(let a of r)await H(u.join(e,a),u.join(n,a));throw i}},S=async(t,n)=>{if(t!==Q)return H(h(t),n);await C(await F(t),h(t),n),await w.rmdir(h(t)).catch(()=>{})},R=async(t,n)=>t===Q&&!await f(t)&&(await Promise.all((await w.readdir(n)).map(e=>T(u.join(h(t),e))))).every(e=>!e),J=async t=>await M(Y(t).json)??{},y=async t=>{let{title:n=t,description:e="",type:r,instructions:i,icon:a}=await J(E(t));return{slug:t,title:n,description:e,...r?{type:r}:{},...typeof a=="string"&&a?{icon:a}:{},...i===!0?{instructions:!0}:{}}},$=()=>xt(l),N=async(t,n)=>{let e=await J(E(t));await _(v(t).json,`${JSON.stringify({...e,[n]:!0},null,2)}
|
|
4
|
-
`)},T=t=>w.access(t).then(()=>!0,()=>!1),x=async(t,{own:n=null}={})=>{let e=new Set((await B()).map(({slug:r})=>r));e.delete(n);for(let r=1;;r++){let i=r===1?t:`${t}-${r}`;if(!bt(i,l)&&!e.has(i))return i}},z=async(t,n)=>{let e=v(t).html,r=await w.readFile(e,"utf8"),i=nt(r).replace(`data-doc-id="${n}"`,`data-doc-id="${t}"`);i!==r&&await _(e,i)};async function b(){let t=await $(),n=(await yt(l)).filter(o=>o!==t),e=await M(A),r={"":[]},i=new Set,a=o=>{for(let k of e?.children?.[o]??[])!n.includes(k)||i.has(k)||(i.add(k),(r[o]??=[]).push(k),a(k))};a("");for(let o of n)i.has(o)||r[""].push(o);return{version:1,children:r}}function st(t){let n=t?.children;if(!n||typeof n!="object"||Array.isArray(n))return!1;let e=new Set;for(let[r,i]of Object.entries(n)){if(r!==""&&!g.test(r)||!Array.isArray(i))return!1;for(let a of i){if(typeof a!="string"||!g.test(a)||e.has(a)||a===r)return!1;e.add(a)}}return!0}let G=async t=>(await w.mkdir(u.dirname(A),{recursive:!0}),_(A,`${JSON.stringify({version:1,children:t.children},null,2)}
|
|
5
|
-
`));async function U(t,n="",e=1/0){let r=await b();for(let o of Object.values(r.children))o.includes(t)&&o.splice(o.indexOf(t),1);let i=n!==t&&(n===""||Object.values(r.children).some(o=>o.includes(n))),a=r.children[i?n:""]??=[];a.splice(Math.max(0,Math.min(e,a.length)),0,t),await G(r)}async function ct(t){let n=await b();for(let[e,r]of Object.entries(n.children)){let i=r.indexOf(t);if(!(i<0))return r.splice(i,1,...n.children[t]??[]),delete n.children[t],await G(n),{parent:e,index:i}}return{parent:"",index:1/0}}let V=new Map;async function ut(t,n){let e=v(t).html,r=await w.stat(e).catch(()=>null);if(!r)return null;let i=V.get(t);if(i?.at===r.mtimeMs&&(i.titles===null||i.titles===n))return i.lines;let a=(await s.read(t))?.text??"",o=Pt(d.words(a,t));return V.set(t,{at:r.mtimeMs,titles:a.includes(Et)?n:null,lines:o}),o}let X=t=>M(u.join(O,t,"entry.json")),B=()=>vt(l),Z={info:async()=>[200,{ok:!0,version:1,gallery:p.version,token:s.token,commands:[...Object.keys(K)],server:{pid:process.pid,workspace:u.resolve(l),kind:p.kind}}],async outline(){let t=await b(),n=await $(),e=[...Object.values(t.children).flat(),...n?[n]:[]],r=async i=>[i,await y(i)];return[200,{ok:!0,outline:t,instructions:n,reports:Object.fromEntries(await Promise.all(e.map(r))),trash:await B()}]},trash:async()=>[200,{ok:!0,entries:await B()}],async stats(t){let n=t.get("slug")??"",e=g.test(n)?v(n).html:"",[r,i]=g.test(n)?await Promise.all([w.stat(e),s.read(n)]).catch(()=>[]):[];return!r||!i?c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"):[200,{ok:!0,edited:Math.round(r.mtimeMs),words:$t(i.text)}]},components:async()=>[200,{ok:!0,...P.read()}],async source(t){let n=t.get("slug")??"";if(!g.test(n))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let e=u.resolve(v(n).html);return await T(e)?[200,{ok:!0,path:e}]:c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863")},async search(t){let n=Ft(t.get("q")??"");if(!n)return[200,{ok:!0,results:[]}];let{children:e}=await b(),r=[],i=m=>(e[m]??[]).forEach(j=>{r.push(j),i(j)});i("");let a=n.toLowerCase(),o=new Map(await Promise.all(r.map(async m=>[m,await y(m)]))),k=JSON.stringify([...o].map(([m,{title:j}])=>[m,j])),I=(await Promise.all(r.map(async m=>{let j=await ut(m,k);if(!j)return null;let q=String(o.get(m).title).toLowerCase().includes(a),{count:tt,hits:ft}=Nt(j,n);return q||tt?{slug:m,title:q,count:tt,hits:ft}:null}))).filter(Boolean);return I.sort((m,j)=>Number(j.title)-Number(m.title)||j.count-m.count),[200,{ok:!0,results:I.slice(0,50)}]}},K={async outline({outline:t}){return st(t)?(await G(t),[200,{ok:!0,outline:await b()}]):c(400,"outline","\u6587\u6863\u76EE\u5F55\u7684\u7ED3\u6784\u4E0D\u5BF9\uFF1A\u6BCF\u4EFD\u6587\u6863\u53EA\u80FD\u51FA\u73B0\u4E00\u6B21")},async create({title:t,description:n,parent:e="",language:r}){let i=typeof t=="string"&&t.trim()?t.trim():"\u672A\u547D\u540D\u6587\u6863",a=await x("doc");return await d.create(a,i,typeof n=="string"&&n.trim()?n.trim():"\u65B0\u6587\u6863",{lang:ot(r)}),await U(a,typeof e=="string"?e:""),[200,{ok:!0,report:await y(a)}]},async instructions({title:t,description:n,language:e}){let r=await $();if(r)return[200,{ok:!0,report:await y(r)}];let i=await x(Ot),a=(o,k)=>typeof o=="string"&&o.trim()?o.trim().slice(0,200):k;return await d.create(i,a(t,"\u5199\u4F5C\u504F\u597D"),a(n,"Agent \u6BCF\u6B21\u5199\u62A5\u544A\u524D\u90FD\u4F1A\u5148\u8BFB\u7684\u5199\u4F5C\u504F\u597D"),{lang:ot(e),page:!0}),await N(i,"instructions"),[200,{ok:!0,report:await y(i)}]},async components({id:t,hidden:n,disabled:e}){try{return[200,{ok:!0,...await P.write({id:t,hidden:n,disabled:e})}]}catch(r){return c(409,"components",r)}},async duplicate({slug:t,suffix:n}){if(typeof t!="string"||!g.test(t)||!await f(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let e=await x(`${t}-copy`),r=new Set(["",...await F(t)]);await w.cp(h(t),h(e),{recursive:!0,errorOnExist:!0,filter:m=>r.has(u.relative(h(t),m).split(u.sep)[0])}),await z(e,t);let{title:i}=await y(t),a=await s.renameReport(e,`${i}${typeof n=="string"&&n.length>0&&n.length<=20?n:"\uFF08\u526F\u672C\uFF09"}`),o=await b(),[k,I]=Object.entries(o.children).find(([,m])=>m.includes(t))??["",null];return await U(e,k,I?I.indexOf(t)+1:1/0),[200,{ok:!0,report:await y(e),notes:a.notes??[]}]},async rename({slug:t,title:n}){if(typeof t!="string"||!g.test(t))return c(400,"slug","\u6587\u6863\u540D\u4E0D\u5BF9");let e=await s.renameReport(t,n);return e.ok?[200,{ok:!0,report:await y(t),notes:e.notes}]:c({title:400,missing:404}[e.reason]??409,e.reason,e.message??"\u6539\u540D\u6CA1\u6709\u6210\u529F")},async trash({slug:t}){if(typeof t!="string"||!g.test(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");if(t===await $())return c(409,"instructions","\u5199\u4F5C\u504F\u597D\u4E0D\u80FD\u79FB\u5230\u56DE\u6536\u533A");if(!await f(t))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let{title:n}=await y(t),e=`${Date.now().toString(36)}-${dt(3).toString("hex")}`,r=await b(),{parent:i,index:a}=await ct(t);try{await w.mkdir(u.join(O,e),{recursive:!0}),await S(t,u.join(O,e,"report"))}catch(k){throw await G(r),await w.rm(u.join(O,e),{recursive:!0,force:!0}).catch(()=>{}),k}let o={id:e,slug:t,title:n,at:Date.now(),parent:i,index:Number.isFinite(a)?a:-1};return await _(u.join(O,e,"entry.json"),`${JSON.stringify(o,null,2)}
|
|
6
|
-
`),[200,{ok:!0,entry:o}]},async restore({id:t}){let n=typeof t=="string"&&at.test(t)?await X(t):null;if(!n)return c(404,"missing","\u56DE\u6536\u533A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879");let e=u.join(O,t,"report"),r=await R(n.slug,e),i=r?n.slug:await x(n.slug,{own:n.slug});return r?await C(await w.readdir(e),e,h(i)):await H(e,h(i)),i!==n.slug&&await z(i,n.slug),await w.rm(u.join(O,t),{recursive:!0,force:!0}),await U(i,n.parent,n.index<0?1/0:n.index),[200,{ok:!0,report:await y(i),entry:{...n,slug:i}}]},async destroy({id:t}){return typeof t!="string"||!at.test(t)||!await X(t)?c(404,"missing","\u56DE\u6536\u533A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879"):(await w.rm(u.join(O,t),{recursive:!0,force:!0}),[200,{ok:!0}])},async export({slug:t}){if(typeof t!="string"||!g.test(t)||!await T(E(t)))return c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863");let{problems:n=[],file:e,refused:r}=await d.export(t);return r?c(r.reason==="missing"?404:409,r.reason,r.message):n.length?c(422,"check",Tt(n)):[200,{ok:!0,path:At(e)}]}};function lt(t,n,e){if(t.method==="GET"&&Object.hasOwn(Z,e)){let r=t.headers.host??"",i=t.socket.localPort;return r!==`127.0.0.1:${i}`&&r!==`localhost:${i}`?W(n,403,{ok:!1,reason:"host"}):Z[e](new URL(t.url??"/","http://localhost").searchParams).then(([a,o])=>W(n,a,o),a=>W(n,...c(500,"read",a)))}return t.method==="POST"&&e==="stop"?s.respond(async r=>{let i=await s.check(r);return i.error?i.error:p.kind!=="cli"||typeof p.stop!="function"?c(409,"dev","\u8FD9\u662F npm run dev \u7684\u670D\u52A1\u5668\uFF1A\u5728\u8FD0\u884C\u5B83\u7684\u5730\u65B9\u505C\u6B62\u5B83"):(n.once("finish",()=>p.stop()),[200,{ok:!0,pid:process.pid}])})(t,n):t.method==="POST"&&Object.hasOwn(K,e)?s.respond(async r=>{let i=await s.check(r);return i.error?i.error:K[e](i.body&&typeof i.body=="object"?i.body:{})})(t,n):W(n,404,{ok:!1,reason:"unknown"})}return{handle:lt,outline:b,trashEntries:B,place:U,freeSlug:x}}export{Ct as a,qt as b};
|
package/dist/chunk-XINNG4F2.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as L,b as N,c as O,d as T,e as I}from"./chunk-7GHT2UCA.mjs";import{f as k}from"./chunk-QMQUXTU4.mjs";import{k as p}from"./chunk-QYKCJ7FG.mjs";import{b as x,d as S,e as b,f as d,g as v,h as D,i as j}from"./chunk-5FRMCDPY.mjs";import{a as y}from"./chunk-E7VYDG2X.mjs";import f from"node:path";import{editStateDirectory as M,reportsDirectory as h}from"../browser/shared/paths.mjs";import{findPreviewServer as P}from"../browser/shared/preview-server.mjs";import{documentDirectory as A,documentFiles as E,isDocumentSource as B}from"../browser/shared/workspace.mjs";var m=t=>f.resolve(t),G=t=>f.basename(E(f.dirname(t)).json),_={busy:"it kept changing while it was being written (an Agent writing it?); nothing written. Run the export again.",timeout:"the workspace's Gallery server did not answer in 30s; nothing written. Run the export again."};async function F(t,e,n="hand-in"){let a=`127.0.0.1:${t.port}`,o;try{o=await fetch(`http://${a}/__gallery/edit/${n}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${a}`,"X-Gallery-Token":t.token},body:JSON.stringify({slug:e,workspace:h}),signal:AbortSignal.timeout(3e4)})}catch(s){return s.name==="TimeoutError"?{ok:!1,reason:"timeout"}:null}let i=await o.json().catch(()=>null);return typeof i?.ok!="boolean"||["elsewhere","token","host","origin"].includes(i.reason)?null:i}async function te(t){let e=await P({reportsDirectory:h}),n=null,a=[],o=new Map,i=[];for(let s of t){let{html:l,json:c}=E(A(s,h)),r=e?await F(e,s):null;if(r===null&&(n??=I({reportsDirectory:h,stateDirectory:M,finish:p}),r=await n.handIn(s),r.ok&&await n.settleNotes(s)),!r.ok){r.reason!=="missing"&&o.set(s,[`${m(l)} was not handed in: ${_[r.reason]??r.message??r.reason}`]);continue}if(r.repeated?.length){o.set(s,k(r.repeated));continue}i.push(...$(l,r)),r.written&&(r.changes.length&&i.push(...d(l,r.changes,{reread:!1})),r.added&&i.push(...g(l,r.given,r.added)),a.push(m(l))),C(r)&&a.push(m(c))}return{written:a,failures:o,lines:i}}async function ne(t){let e=await P({reportsDirectory:h});if(e){for(let n of t)if(await F(e,n,"settle")===null)return}}var C=({title:t=null,icon:e=null})=>!!(t&&typeof t.from=="string"&&t.from!==t.to||e&&!e.missing),R=10;function g(t,e,n=e?.length??0,{pending:a=!1}={}){let o=`${n} block${n===1?"":"s"}`;if(a){let s=[`ids ${m(t)}: ${o} without an id yet: the export gives ${n===1?"it":"each"} one`];return n>R?s:[...s,...e.map(({line:l,tag:c})=>` line ${l} ${c}`)]}let i=[`ids ${m(t)}: ${o} given an id`];return!e||n>R?i:[...i,...e.map(({line:s,tag:l,id:c})=>` line ${s} ${l} \u2192 ${c}`)]}function $(t,{title:e=null,icon:n=null}={},{pending:a=!1}={}){let o=m(f.dirname(t)),i=G(t),s=(c,r,w)=>a?`${c} not ${r} yet (${w}): the export writes ${c.includes(" and ")?"them":"it"}`:`${c} written ${r}: ${w}`,l=[];if(e){let c=[...e.page?["<title>"]:[],...typeof e.from=="string"&&e.from!==e.to?[`${i}'s title`]:[]];c.length&&l.push(`title ${o}: ${s(c.join(" and "),"as its h1 says it",JSON.stringify(e.to))}`)}return n?.missing?l.push(`icon ${o}: ${i} has the icon ${JSON.stringify(n.from)} and the page's header none: write it there (<div class="doc-icon">\u2026</div> before the h1) or take "icon" out of ${i} (the export leaves ${i}'s as it is)`):n&&l.push(`icon ${o}: ${s(`${i}'s icon`,"as its header has it",n.to===null?"none":JSON.stringify(n.to))}`),l}function oe(t,{by:e="this export"}={}){let n=t.length===1,a=[...t.filter(o=>B(f.basename(o))).map(o=>f.basename(o)).filter((o,i,s)=>s.indexOf(o)===i).map(o=>`${o}: the kit's markup, block ids`),...t.filter(o=>/^(doc|report)\.json$/.test(f.basename(o))).map(o=>f.basename(o)).filter((o,i,s)=>s.indexOf(o)===i).map(o=>`${o}: the title or icon said above`)];return`Re-read ${t.join(", ")} before editing ${n?"it":"them"}: ${e} wrote ${n?"it":"them"} (${a.join("; ")}).`}import H from"node:path";import{FILE as W}from"../browser/shared/annotations.mjs";import{editStateDirectory as J,reportsDirectory as u}from"../browser/shared/paths.mjs";import{documentDirectory as K,documentFiles as X}from"../browser/shared/workspace.mjs";function ue({say:t=!0}={}){return e=>{let{text:n,changes:a}=x(e.html,{finish:p});if(t&&a.length&&console.log(d(e.htmlPath,a,{pending:!0}).join(`
|
|
3
|
-
`)),t){let o=S(e.html);o.length&&console.log(g(e.htmlPath,o,o.length,{pending:!0}).join(`
|
|
4
|
-
`));for(let i of $(e.htmlPath,b(y(e.html),e.metadata),{pending:!0}))console.log(i)}return n}}function ge(t){for(let e of t){for(let n of v(e.html))console.log(`note ${e.slug}: ${n} (read-only in the preview)`);for(let n of D(e.html))console.log(`note ${e.slug}: ${n}`);for(let n of j(e.html))console.log(`note ${e.slug}: ${n}`)}}async function $e(t){for(let e of t){let n=await O({stateDirectory:J,reportsDirectory:u,slug:e});for(let a of T(X(K(e,u)).html,n))console.log(a)}}async function we(t){for(let e of t){let n=await L({stateDirectory:J,reportsDirectory:u,slug:e});for(let a of N(H.join(K(e,u),W),n))console.log(a)}}export{te as a,ne as b,oe as c,ue as d,ge as e,$e as f,we as g};
|
package/dist/chunk-YL2DPWVS.mjs
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as te,f as ne,n as se}from"./chunk-3LA3EMDE.mjs";import{b as A,d as oe}from"./chunk-2PBALTR3.mjs";import{a as N}from"./chunk-TX6JH7TR.mjs";import"./chunk-LC7YNQFG.mjs";import"./chunk-ITNLYXXV.mjs";import"./chunk-ZBIM6ARY.mjs";import"./chunk-NSKUTQ5J.mjs";import{a as J,i as X,r as Z}from"./chunk-QMQUXTU4.mjs";import{d as Y,e as q,i as j,j as V,k as W}from"./chunk-HQQMJCQJ.mjs";import{a as $}from"./chunk-QYKCJ7FG.mjs";import"./chunk-YZ5Z6H4W.mjs";import"./chunk-VACRB2NE.mjs";import{a as D,c as x}from"./chunk-HYMEEXKN.mjs";import"./chunk-TDQP3DKQ.mjs";import{b as ee,g as R}from"./chunk-5FRMCDPY.mjs";import"./chunk-E7VYDG2X.mjs";import{c as Q}from"./chunk-NFIBI4IP.mjs";import{c as K,e as G,g as P,o as H}from"./chunk-W63L7367.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{isUtf8 as ke}from"node:buffer";import ue from"node:fs";import E from"node:path";import{instancesOf as _,isInstance as Le,partOf as fe}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as y,refusedInCopy as Se}from"../browser/shared/components/installed.mjs";import{attr as T,elementsOf as de,walk as I}from"../browser/shared/html-tree.mjs";import{blankedCss as v}from"../browser/shared/css-references.mjs";import{ATTRIBUTE as ce}from"../browser/shared/components/installed.mjs";var $e=new Set(["media","supports","container","layer","starting-style"]);function F(t,e){let n=0,s="";for(let o=0;o<t.length;o++){let i=t[o];i==="\\"?o++:s?s=i===s?"":s:i==='"'||i==="'"?s=i:i===")"||i==="]"?n--:(n===0&&e(i,o),(i==="("||i==="[")&&n++)}}function be(t){let e=v(t),n=v(t,{strings:!0}),s={children:[]},o=[s],i=0,a=0;for(let r=0;r<e.length;r++){let c=e[r];if(c==="\\")r++;else if(c==="("||c==="[")a++;else if(c===")"||c==="]")a=Math.max(0,a-1);else{if(a>0)continue;if(c==="{"){let l={prelude:n.slice(i,r),start:i,children:[]};o.at(-1).children.push(l),o.push(l),i=r+1}else c==="}"?(o.length>1&&o.pop(),i=r+1):c===";"&&(i=r+1)}}return s.children}function ie(t){let e=[],n=0;return F(t,(s,o)=>{s===","&&(e.push({text:t.slice(n,o),start:n}),n=o+1)}),e.push({text:t.slice(n),start:n}),e.filter(({text:s})=>s.trim())}function he(t){let e=[],n=t.trim(),s="",o=0,i=0,a=r=>{(i||r)>o&&e.push({combinator:s,compound:n.slice(o,i||r)}),i=0};return F(n,(r,c)=>{/\s/.test(r)?c===o?o=c+1:i||=c:">+~".includes(r)?(a(c),s=r,o=c+1):i&&(a(c),s=" ",o=c)}),a(n.length),e}function re(t){let e=[],n=-1,s=0,o="";for(let a=0;a<t.length;a++){let r=t[a];r==="\\"?a++:o?o=r===o?"":o:r==='"'||r==="'"?o=r:r==="("?s++:r===")"?s--:r==="["&&s===0?n=a:r==="]"&&s===0&&n>=0&&(e.push(t.slice(n,a+1)),n=-1)}let i=!1;return F(t,a=>{i||=a==="&"}),{attributes:e,nesting:i,scope:/(?:^|[^\w-]):scope\b/.test(t)}}var ye=t=>new RegExp(`^\\[\\s*${ce}\\s*=\\s*(["'])${t.replace(/[/-]/g,"\\$&")}\\1\\s*i?\\s*\\]$`,"i"),xe=t=>v(t).replace(/\\.|\[[^\]]*\]/g,"").includes("&");function ae(t,e,n){let s=he(t),o=({compound:l})=>re(l).attributes.some(h=>e.test(h)),i=({compound:l})=>{let{nesting:h,scope:u}=re(l);return!!n&&(h||u)},a=l=>["+","~"].includes(l?.combinator),r=s.findLastIndex(l=>o(l)||i(l));if(r<0)return!n||xe(t)?{why:"outside"}:{why:n==="instance"&&a(s[0])?"beside":null,subject:"inside"};let c=o(s[r])||n==="instance";return{why:c&&a(s[r+1])?"beside":null,subject:c&&r===s.length-1?"instance":"inside"}}var le=t=>t.some(({subject:e})=>e==="instance")?"instance":"inside";function pe(t,e){let n=ye(e),s=`[${ce}="${e}"]`,o=[],i=(r,c,l)=>{let h=c.replace(/\s+/g," ").trim();o.push({line:x(t,r),what:l==="beside"?`${h} reaches what stands beside the instance: what it styles has to stand in it`:`${h} reaches outside the instance: start it at ${s}`})},a=(r,c)=>{for(let l of r){let h=l.prelude.length-l.prelude.trimStart().length,u=l.start+h,p=/^@([\w-]+)\s*/.exec(l.prelude.trim());if(p){let f=p[1].toLowerCase();if($e.has(f))a(l.children,c);else if(f==="page")o.push({line:x(t,u),what:"@page reaches the paper of the whole document: an instance has no page of its own"});else if(f==="scope"){let d=/^@scope\s*\(([^)]*)\)/i.exec(l.prelude.trim())?.[1]??"",g=ie(d).map(({text:w})=>({...ae(w,n,c),steps:he(w).length}));d&&g.every(({why:w,steps:S})=>!w&&S===1)?a(l.children,le(g)):i(u,l.prelude,"outside")}continue}let m=ie(l.prelude).map(({text:f,start:d})=>{let g=ae(f,n,c);return g.why&&i(l.start+d+f.length-f.trimStart().length,f,g.why),g});m.some(({why:f})=>f)||a(l.children,le(m))}};return a(be(t),null),o}var b="template.html",k="example.html",C="component.json",Ee=new Set(["localStorage","sessionStorage"]),Oe=/^\S+: (?:line \d+ of )?its (?:kit\.js|style\.css) /,je=/(?: (?:names a file that )?is not in the document's folder|: it is (?:no file of|not in) the document's .*)$|^external resources are not portable: .*$/,Ne=": an example stands in no document: write a picture as a data: address, or draw it from style.css with a file the manifest's assets name",Ae=t=>t.replace(je,e=>(e.startsWith("external")?e:"")+Ne),L=(t,e)=>j({folder:t},e);function O(t,e){let n=null;try{n=ue.readFileSync(E.join(t,e))}catch{return null}return ke(n)?null:{file:e,what:"it is not UTF-8: save it as UTF-8 (PowerShell's > writes UTF-16; Set-Content -Encoding utf8 does not)"}}function z(t,e){let n=/^line (\d+): | \(line (\d+)\)/.exec(e);return n?{file:t,line:Number(n[1]??n[2]),what:e.replace(n[0],"")}:{file:t,what:e}}function U(t,e){let n=$.parseJsonText(C,t),s=n.statements[0]?.expression,o=null;for(let i of e.split(".")){let a=s?.properties?.find(({name:r})=>r?.text===i);if(!a)break;o=n.getLineAndCharacterOfPosition(a.getStart(n)).line+1,s=a.initializer}return o}function Te(t,{message:e,text:n="",values:s=[]}){let o=/at position (\d+)/.exec(e)?.[1];if(o)return x(t,Number(o));for(let i of[...s.map(String),...n.match(/[a-zA-Z][\w.]*/g)??[]]){let a=U(t,i);if(a)return a}return null}var Ce=t=>R(t).map(e=>/^line (\d+): <([^>]+)>: ([\s\S]*)$/.exec(e)).filter(Boolean).map(([,e,n,s])=>({line:Number(e),tag:n,why:s}));function Ie(t,{file:e,tree:n,html:s}){let o=[],i=Ce(s),a=Object.entries(t.parts).filter(([,l])=>l.edit==="text"),r=Object.entries(t.parts).filter(([,l])=>l.edit==="data"),c=(l,h)=>{let u=!1;return I(l,p=>{u||=p===h}),u};for(let l of _(n,t))for(let[h,u]of a)for(let p of fe(l,u.at)){let m=p.sourceCodeLocation?.startLine,f=de(p).find(w=>Q.has(w.tagName)),d=i.find(w=>w.line===m&&w.tag===p.tagName),g=r.find(([,w])=>fe(l,w.at).some(S=>S===p||c(S,p)||c(p,S)))?.[0];g?o.push({file:e,line:m,what:`the part ${h} (${u.at}) is edited as text, and stands in the part ${g}, edited as data, or around it, which is the component's: the editor leaves it read-only: name elements apart`}):f?o.push({file:e,line:m,what:`the part ${h} (${u.at}) is edited as text and holds a block, its <${f.tagName}> at line ${f.sourceCodeLocation?.startLine}: a text part holds words and marks alone, and the editor would leave this one read-only: write its \`at\` as what holds the words (${u.at} > ${f.tagName}), or give each block a part of its own`}):d&&o.push({file:e,line:m,what:`the part ${h} (${u.at}) is edited as text, and the editor would leave it read-only for what it holds: ${d.why}. A text part holds words and marks alone`})}return o}var ge="(?:(?:[zcs]h|[bpmfdtnlgkhjqxrzcsyw])?(?:[iuv]?(?:a(?:i|o|ng?)?|e(?:i|r|ng?)?|o(?:u|ng)?)|i(?:u|ng?)?|u(?:i|n)?|vn?))",Pe=new RegExp(`^${ge}$`,"i"),Re=new RegExp(`^${ge}{1,8}$`,"i"),M=new RegExp("\\p{Script=Han}","u"),ve=6,we=t=>[...t].filter(e=>M.test(e)).length;function Fe(t){let e=t.replaceAll("'",""),n=[0,...Array(e.length).fill(1/0)];for(let s=1;s<=e.length;s++)for(let o=Math.max(0,s-ve);o<s;o++)n[o]+1<n[s]&&Pe.test(e.slice(o,s))&&(n[s]=n[o]+1);return e&&Number.isFinite(n[e.length])?n[e.length]:null}function ze({name:t,words:e}){let n=we(t.zh),s=e.split(/\s+/).filter(Boolean);return n===0?M.test(e)&&!s.some(o=>Re.test(o)):!s.some(o=>Fe(o.toLowerCase())===n)}function Be({id:t,folder:e,catalog:n,off:s,parts:o}){let i=n.packages.get(t),a=n.problems.get(t)?.problem,r=L(e,C)??"",c=[];a&&c.push({file:C,line:Te(r,a),what:P("en",a)}),i?.template===null&&c.push({file:b,what:`there is none, and it is what "/" puts in a document: with none, no menu offers the block: write one <div ${y}="${t}"> with what a new instance holds`}),c.push(...o);let l=O(e,"writing.md");l&&c.push(l);let h=l||L(e,"writing.md")?.trim()?[]:[{file:"writing.md",what:"there is none, so gallery component show has nothing to say of how to write it"}];return i&&ze(i)&&h.push({file:C,line:U(r,"words")??U(r,"name.zh"),what:M.test(i.name.zh)?`no word of words spells its whole name ${i.name.zh} in pinyin as an input method composes it, its ${we(i.name.zh)} Chinese characters a syllable each in one word (as \u65B9\u6848\u6253\u5206 is fangandafen): "/" finds it while those letters are being composed only by such a word. What is counted is how many syllables a word reads as, not which characters they spell`:'its words are Chinese and none of them is pinyin: "/" goes by the letters an input method is composing, so write the pinyin there (\u770B\u677F kanban)'}),s&&h.push({file:"gallery.json",what:"the user turned it off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6, which is theirs to change and says nothing of the package: it is checked as if it were on, and the instances of a document show what they hold, read-only, until it is on"}),{title:"manifest",problems:c,notes:h}}function Ue(t){let e=$.createSourceFile("kit.js",t,$.ScriptTarget.Latest,!0,$.ScriptKind.JS),n=[],s=o=>{let i=$.isCallExpression(o)&&$.isPropertyAccessExpression(o.expression)?o.expression:null;if(i?.name.text==="component"&&/\bDocKit$/.test(i.expression.getText(e))){let[a]=o.arguments,r=a&&$.isObjectLiteralExpression(a)?a.properties.find(l=>l.name?.getText(e)==="id"):null,c=r&&$.isPropertyAssignment(r)&&$.isStringLiteralLike(r.initializer)?r.initializer.text:null;n.push({id:c,at:o.getStart(e)})}$.forEachChild(o,s)};return s(e),n}function _e(t){let e="kit.js";if(!t.files.includes("kit.js"))return{title:e,none:"none: a static block"};let n=O(t.folder,e);if(n)return{title:e,stops:!0,problems:[n]};let s=j(t,"kit.js")??"",o=J(s);if(o)return{title:e,stops:!0,problems:[{file:e,line:o.line,what:`a browser refuses it: ${o.message}`}]};let i=W(t).map(({line:l,what:h})=>({file:e,line:l,what:h})),a=i.length>0;for(let{name:l,at:h}of Y(s,Ee))i.push({file:e,line:x(s,h),what:`uses ${l}: an instance keeps what a reader chose with context.state`});let r=Ue(s);for(let{id:l,at:h}of r)l!==null&&l!==t.id&&i.push({file:e,line:x(s,h),what:`it registers ${l}, and this package is ${t.id}`});let c=r.length?[]:[{file:e,what:`no DocKit.component({ id: "${t.id}", mount(host, context) { \u2026 } }) is to be read in it, and a script may make that call in ways reading does not tell: running it says whether it starts one`}];for(let{line:l,code:h,message:u,refused:p}of q(s,{assets:t.assets}))(p?i:c).push({file:e,line:l,what:`TS${h}: ${u}`});return{title:e,stops:a,problems:i.sort((l,h)=>(l.line??0)-(h.line??0)),notes:c}}function Me(t){let e="style.css";if(!t.files.includes("style.css"))return{title:e,none:"none"};let n=O(t.folder,e);if(n)return{title:e,stops:!0,problems:[n]};let s=j(t,"style.css")??"",o=V(t),i=[...pe(s,t.id),...o].map(({line:a,what:r})=>({file:e,line:a,what:r}));return{title:e,stops:o.length>0,problems:i.sort((a,r)=>a.line-r.line)}}function De(t,{tree:e}){let n=null;I(e,r=>{n??=r.tagName==="main"?r:null});let s=de(n??{}),o=(n?.childNodes??[]).some(r=>r.nodeName==="#text"&&r.value.trim()),[i]=s;if(s.length!==1||o||!Le(i)||T(i,y)!==t)return[{file:b,line:i?.sourceCodeLocation?.startLine,what:`a template is one element, a <div ${y}="${t}"> or a <section>, and it holds ${s.length===1&&!o?`<${i.tagName}${T(i,y)?` ${y}="${T(i,y)}"`:""}>`:`${s.length} element${s.length===1?"":"s"}${o?" and words":""}`}`}];let a=[];return I({childNodes:[i]},r=>{T(r,"data-block-id")!==void 0&&a.push({file:b,line:r.sourceCodeLocation?.startLine,what:"it writes a data-block-id, which every instance made of it would repeat: leave it out, Gallery gives a block its id"})}),a}function Ke(t,{tree:e}){let n=H(t);if(!n)return[];let[s]=_(e,t),o=null;return s&&I({childNodes:[s]},i=>{Se(i.tagName,i.attrs)&&(o??=i)}),[{file:b,line:(o??s)?.sourceCodeLocation?.startLine,what:P("en",n)}]}function Ge(t){return[[b,"component-template"],[k,"component-example"]].flatMap(([e,n])=>{let s=L(t,e);if(s===null||!s.trim()||O(t,e))return[];let o=ne(n,s),{text:i}=ee(o);return[{file:e,slug:n,written:o,html:i,tree:D(i)}]})}function He({id:t,folder:e,found:n,pages:s,parts:o}){let i="template.html and example.html",a=[],r=[];for(let p of[b,k]){let m=O(e,p);m?a.push(m):p===b&&!L(e,p)?.trim()&&n.template!==null?a.push({file:p,what:"it is empty"}):p===k&&!s.some(f=>f.file===p)&&a.push({file:p,what:`there is none or it is empty: write an instance as a writer would fill it, a <div ${y}="${t}">; it is what this check runs`})}let c=s.find(p=>p.file===b);c&&a.push(...De(t,c));let l=s.find(p=>p.file===k);l&&_(l.tree,n).length===0&&a.push({file:k,what:`it holds no instance of ${t}: a <div ${y}="${t}">`});let h=s.map(({slug:p,written:m,html:f,file:d})=>({file:d,slug:p,written:m,html:f,directory:E.join(e,p),htmlPath:E.join(e,p,"doc.html"),metadata:{title:p,description:p,type:"component"}})),u=X(h);for(let p of h){for(let m of u.get(p.slug)??[])Oe.test(m)||a.push(z(p.file,Ae(m)));for(let m of Z(p))r.push(z(p.file,m));for(let m of R(p.html)){let f=z(p.file,`${m} (read-only in the preview)`);o.some(({file:d,line:g})=>d===f.file&&g===f.line)||r.push(f)}}return c&&!a.some(({file:p})=>p===b)&&a.push(...Ke(n,c)),{title:i,problems:a,notes:r}}function Ye(t,e){let n=K(t,void 0,{on:e}),s=A(t,e);if(!n.packages.has(e)&&!n.problems.has(e))return null;G(t,n);let o=n.packages.has(e)&&n.settings.disabled.includes(e),i=n.packages.get(e)??{id:e,folder:s,files:["kit.js","style.css"].filter(l=>ue.existsSync(E.join(s,l)))},a=Ge(s),r=n.packages.has(e)?null:"its manifest does not load",c=r?[]:a.flatMap(l=>Ie(i,l));return{found:n.packages.get(e)??null,pages:a,sections:[Be({id:e,folder:s,catalog:n,off:o,parts:c}),_e(i),Me(i),r?{title:"template.html and example.html",skipped:r}:He({id:e,folder:s,found:i,pages:a,parts:c})]}}var B=({file:t,line:e})=>e?`${t}:${e}`:t;function me({title:t,problems:e=[],notes:n=[],told:s=[],none:o,skipped:i,unverified:a,pictures:r},c){let l=a?`UNVERIFIED ${a}`:i?`not run: ${i}`:o??(e.length?`${e.length} problem${e.length===1?"":"s"}`:`ok${n.length?`, ${n.length} note${n.length===1?"":"s"}`:""}`);return[`${c}. ${t}: ${l}`,...e.map(h=>` FAIL ${B(h)}: ${h.what}`),...n.map(h=>` note ${B(h)}: ${h.what}`),...s.map(h=>` way back ${B(h)}: ${h.what}`),...r?[qe(r)]:[]]}function qe({folder:t,overviews:e,each:n,edited:s=[],asExport:o=[]}){let i=e.length?`${N(E.join(t,e[0]))}${e.slice(1).map(c=>` and ${c}`).join("")}, the three widths of each theme side by side; then each at full size: `:`${N(t)}: `,a=o.length===0?"":o.length===s.length?", each the same picture as the export's at its width: the block draws nothing more where a reader can edit":`, ${o.join(" and ")} the same picture as the export's at its width`,r=s.length?`; and ${s.join(" and ")}, as the editing page draws it (context.canEdit() true)${a}`:"";return` Pictures (none looked at for you; example.html above the line, template.html below it, each under its name): ${i}${n.join(", ")}${r}`}function Ve([t,e,n,s]){return t.problems.length?"the manifest":e.stops?"kit.js":n.stops?"style.css":s.skipped||s.problems.length?"template.html and example.html":null}async function $t(t,e){let n=Ye(t,e);n||(console.error(oe(t,e)),process.exit(1)),console.log(`${e}: ${N(A(t,e))}`),n.sections.forEach((r,c)=>console.log(me(r,c+1).join(`
|
|
3
|
-
`)));let s=Ve(n.sections),o=A(t,e),i=s?{title:te,skipped:`${s} first`}:await se(t,n.found,{example:L(o,k),template:L(o,b)});console.log(me(i,5).join(`
|
|
4
|
-
`));let a=[...n.sections,i].reduce((r,{problems:c=[]})=>r+c.length,0);a?(console.log(`FAIL ${e}: ${a} problem${a===1?"":"s"}`),process.exitCode=1):i.unverified?(console.log(`UNVERIFIED ${e}: the rest passed, and no browser ran it: export a document that holds it and open that in Chrome or Edge.`),process.exitCode=3):console.log(`OK ${e}`)}export{$t as checkCommand,Fe as fewestSyllables,Ye as readSections,me as sectionLines,ze as wantsPinyin};
|