@heycys/gallery 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/assets/preview/runtime.js +156 -0
- package/assets/preview/shell.html +107 -0
- package/assets/writing-preferences.md +1 -1
- package/browser/editor/components/divider/index.mjs +1 -1
- package/browser/editor/page/annotate/card.mjs +6 -0
- package/browser/editor/page/annotate/index.mjs +22 -2
- package/browser/editor/page/columns/index.mjs +1 -1
- package/browser/editor/page/conflicts.mjs +1 -1
- package/browser/editor/page/drag/index.mjs +1 -1
- package/browser/editor/page/editor.mjs +43 -5
- package/browser/editor/page/focus.mjs +104 -0
- package/browser/editor/page/handle/index.mjs +14 -2
- package/browser/editor/page/links/index.mjs +2 -2
- package/browser/editor/page/quiet.mjs +3 -3
- package/browser/editor/page/resize/index.mjs +1 -1
- package/browser/editor/page/session.mjs +4 -1
- package/browser/editor/page/ui.mjs +1 -1
- package/browser/shared/annotations.mjs +22 -3
- package/browser/shared/block-packs.mjs +13 -4
- package/browser/shared/document-look.mjs +14 -0
- package/browser/shared/drafts.mjs +1 -1
- package/browser/shared/extension-manifest.mjs +40 -12
- package/browser/shared/favorite-merge.mjs +17 -0
- package/browser/shared/favorites.mjs +77 -0
- package/browser/shared/i18n/en.mjs +123 -24
- package/browser/shared/outline-ops.mjs +109 -0
- package/browser/shared/outline.mjs +6 -0
- package/browser/shared/pages.mjs +20 -8
- package/browser/shared/paths.mjs +5 -2
- package/browser/shared/preference-documents.mjs +137 -0
- package/browser/shared/presence.mjs +94 -0
- package/browser/shared/preview-server.mjs +8 -5
- package/browser/shared/qa-levels.mjs +9 -1
- package/browser/shared/session.mjs +4 -0
- package/browser/shared/shipped-blocks.mjs +22 -4
- package/browser/shared/startup.mjs +101 -0
- package/browser/shared/workspace-address.mjs +3 -0
- package/browser/shared/workspace-columns.mjs +1 -1
- package/browser/shared/workspace-look.mjs +21 -8
- package/browser/shared/workspace-registry.mjs +6 -3
- package/browser/shared/workspace.mjs +37 -10
- package/browser/shared/writing-preferences.mjs +2 -42
- package/dist/chunk-25LYSMAE.mjs +2 -0
- package/dist/chunk-2I6ZVC5O.mjs +2 -0
- package/dist/{chunk-M4NRDYI5.mjs → chunk-2MYTOOP6.mjs} +1 -1
- package/dist/chunk-2VNENLER.mjs +2 -0
- package/dist/chunk-3FERXZF5.mjs +4 -0
- package/dist/chunk-3M6SBBGU.mjs +2 -0
- package/dist/chunk-3VCAAF34.mjs +2 -0
- package/dist/{chunk-JXXHAXYH.mjs → chunk-3ZTRLGSA.mjs} +1 -1
- package/dist/chunk-4FRA5AUE.mjs +2 -0
- package/dist/chunk-4LR2QEC2.mjs +4 -0
- package/dist/chunk-56SVJENP.mjs +966 -0
- package/dist/chunk-5CQISL2G.mjs +4 -0
- package/dist/{chunk-RRKJMHNX.mjs → chunk-5I5ZDDWC.mjs} +5 -5
- package/dist/chunk-5IHDLEB4.mjs +10 -0
- package/dist/chunk-5LRDMV7O.mjs +2 -0
- package/dist/chunk-5MVUYRKG.mjs +5 -0
- package/dist/chunk-5TLLIZT7.mjs +2 -0
- package/dist/chunk-6ILJWFYW.mjs +4 -0
- package/dist/chunk-6N25CJ6Y.mjs +3 -0
- package/dist/{chunk-SQ6Y2ZMA.mjs → chunk-7DTINW6U.mjs} +2 -2
- package/dist/chunk-7KWAGKIK.mjs +2 -0
- package/dist/chunk-7WNUOAFK.mjs +2 -0
- package/dist/chunk-7XCRW5RC.mjs +2 -0
- package/dist/{chunk-ERE2BXYV.mjs → chunk-7XSDTILF.mjs} +1 -1
- package/dist/chunk-ABKYFOVR.mjs +2 -0
- package/dist/chunk-AMUF7PUN.mjs +2 -0
- package/dist/{chunk-PLB7L22J.mjs → chunk-B2EIMERT.mjs} +2 -2
- package/dist/{chunk-QNECWMGR.mjs → chunk-B45IAAU6.mjs} +1 -1
- package/dist/chunk-B6RAGF4R.mjs +2 -0
- package/dist/chunk-BSJKFE7I.mjs +4 -0
- package/dist/chunk-C72EEVLK.mjs +2 -0
- package/dist/chunk-CRAUKZ23.mjs +4 -0
- package/dist/chunk-F4CT35KL.mjs +2 -0
- package/dist/chunk-F63BNJLG.mjs +2 -0
- package/dist/chunk-FBKUPS44.mjs +2 -0
- package/dist/chunk-FL52ZL5Z.mjs +15 -0
- package/dist/chunk-FOZCU4VW.mjs +2 -0
- package/dist/chunk-G5HV7BC3.mjs +2 -0
- package/dist/{chunk-ERLAIBOA.mjs → chunk-GB5SOYQJ.mjs} +2 -2
- package/dist/chunk-GN3SG3IF.mjs +2 -0
- package/dist/{chunk-6QWQXHAV.mjs → chunk-HFTBVEZK.mjs} +1 -1
- package/dist/chunk-IOW5HLRK.mjs +2 -0
- package/dist/chunk-IQ3GJNTI.mjs +6 -0
- package/dist/chunk-K6SPFBUJ.mjs +2 -0
- package/dist/chunk-K7Y7SPTS.mjs +2 -0
- package/dist/chunk-L2IJCEUH.mjs +2 -0
- package/dist/{chunk-GPIWQ4X4.mjs → chunk-L3VT6LM4.mjs} +1 -1
- package/dist/chunk-L4WLQYFC.mjs +5 -0
- package/dist/{chunk-FFV733MA.mjs → chunk-LAMCAGK6.mjs} +1 -1
- package/dist/chunk-LHGKPMTI.mjs +2 -0
- package/dist/chunk-LJZIYVNA.mjs +3 -0
- package/dist/chunk-LSVCTLS2.mjs +2 -0
- package/dist/chunk-LZY74XTP.mjs +2 -0
- package/dist/chunk-MC4LRSVH.mjs +2 -0
- package/dist/chunk-MCEXN4G5.mjs +2 -0
- package/dist/chunk-MTLAOCFF.mjs +181 -0
- package/dist/chunk-MZ66LN3B.mjs +2 -0
- package/dist/chunk-N5QWJRRI.mjs +2 -0
- package/dist/chunk-NF4MMOUB.mjs +2 -0
- package/dist/chunk-NHJYAJ73.mjs +3 -0
- package/dist/chunk-NRSD7SVY.mjs +2 -0
- package/dist/chunk-NT23I4XW.mjs +2 -0
- package/dist/chunk-NUALABIS.mjs +3 -0
- package/dist/chunk-NW6LAU22.mjs +2 -0
- package/dist/chunk-NWWHDGKF.mjs +5 -0
- package/dist/chunk-OFRCVMSJ.mjs +2 -0
- package/dist/chunk-OKVQQ3CX.mjs +4 -0
- package/dist/chunk-OM24O4KR.mjs +8 -0
- package/dist/{chunk-4B2TB5K2.mjs → chunk-PBMOC7KA.mjs} +2 -2
- package/dist/chunk-PVTCP43W.mjs +2 -0
- package/dist/chunk-Q62HZAJS.mjs +2 -0
- package/dist/chunk-QBJWIR3Q.mjs +2 -0
- package/dist/chunk-QDSEZX7Z.mjs +6 -0
- package/dist/chunk-QR4V4A2Z.mjs +15 -0
- package/dist/{chunk-QVGOPHOF.mjs → chunk-QRLVVZ3R.mjs} +1 -1
- package/dist/chunk-QW3QG67J.mjs +2 -0
- package/dist/chunk-R2T2EVWY.mjs +8 -0
- package/dist/{chunk-GJJRBGMY.mjs → chunk-R5RERE6G.mjs} +1 -1
- package/dist/chunk-RFHEWT3Y.mjs +5 -0
- package/dist/chunk-RS2Z2JQP.mjs +2 -0
- package/dist/chunk-S6YEC4GE.mjs +16 -0
- package/dist/chunk-SHZLMGGW.mjs +2 -0
- package/dist/chunk-TALJQM2O.mjs +2 -0
- package/dist/chunk-TLNJWEFY.mjs +22 -0
- package/dist/{chunk-6Q7ASAXJ.mjs → chunk-TQZU7D7C.mjs} +1 -1
- package/dist/chunk-UTKNWYBA.mjs +2 -0
- package/dist/chunk-V3TM3TEN.mjs +2 -0
- package/dist/chunk-V3XROSP5.mjs +7 -0
- package/dist/{chunk-6QBHU4DF.mjs → chunk-V5JTW2LH.mjs} +1 -1
- package/dist/chunk-VAXLSISW.mjs +4 -0
- package/dist/chunk-VBHI3RG6.mjs +2 -0
- package/dist/{chunk-6L6V7YR2.mjs → chunk-VKZJRGDR.mjs} +1 -1
- package/dist/chunk-VZXZM7NS.mjs +2 -0
- package/dist/chunk-WDS6HEPE.mjs +2 -0
- package/dist/chunk-WHGANNEY.mjs +13 -0
- package/dist/chunk-WMJWC4QY.mjs +56 -0
- package/dist/{chunk-VZ2RQ3AM.mjs → chunk-WWONJJQS.mjs} +1 -1
- package/dist/chunk-X4WNLFIK.mjs +2 -0
- package/dist/chunk-XNNCQROX.mjs +11 -0
- package/dist/chunk-XRYECF23.mjs +170 -0
- package/dist/{chunk-K3JKPFL5.mjs → chunk-Z4NEXXFK.mjs} +1 -1
- package/dist/{chunk-236JJXWY.mjs → chunk-ZFVF2YPV.mjs} +2 -2
- package/dist/chunk-ZM2IX3R2.mjs +2 -0
- package/dist/chunk-ZNGGDUZI.mjs +2 -0
- package/dist/chunk-ZOEJQOKT.mjs +2 -0
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/update-fetch.mjs +1 -1
- package/dist/worker.mjs +1 -1
- package/kit/runtime.js +1 -0
- package/package.json +1 -1
- package/release.json +4 -4
- package/skill/SKILL.md +54 -148
- package/skill/references/building-blocks.md +4 -4
- package/skill/references/charts-and-figures.md +73 -0
- package/skill/references/extensions.md +47 -4
- package/skill/references/pages-and-data.md +22 -3
- package/skill/references/preference-files.md +7 -0
- package/skill/references/previews.md +17 -0
- package/skill/references/writing-html.md +21 -82
- package/web/assets/index-B4uUluLM.js +15 -0
- package/web/assets/index-C3vHT8sH.css +1 -0
- package/web/index.html +2 -2
- package/dist/chunk-2KAVXMKG.mjs +0 -4
- package/dist/chunk-2T4PZQEP.mjs +0 -2
- package/dist/chunk-3SKOU6OZ.mjs +0 -10
- package/dist/chunk-3XZOA7AH.mjs +0 -170
- package/dist/chunk-4KUO7R2M.mjs +0 -16
- package/dist/chunk-4OZWXZE5.mjs +0 -5
- package/dist/chunk-4SNV4HA5.mjs +0 -2
- package/dist/chunk-53XDTHTG.mjs +0 -4
- package/dist/chunk-5XV3YYLG.mjs +0 -2
- package/dist/chunk-65NTKF4N.mjs +0 -6
- package/dist/chunk-6GV3CBB2.mjs +0 -2
- package/dist/chunk-6NLXUKAY.mjs +0 -4
- package/dist/chunk-6XD6U3QA.mjs +0 -5
- package/dist/chunk-7EFHNQ5B.mjs +0 -3
- package/dist/chunk-7ISBBDJR.mjs +0 -2
- package/dist/chunk-7M2BQQGZ.mjs +0 -2
- package/dist/chunk-7UZUQQ7Q.mjs +0 -554
- package/dist/chunk-ALZ6ZENZ.mjs +0 -3
- package/dist/chunk-BLNQUR5R.mjs +0 -168
- package/dist/chunk-BMX3VUHY.mjs +0 -2
- package/dist/chunk-BN7M3IN7.mjs +0 -8
- package/dist/chunk-C257H6IA.mjs +0 -2
- package/dist/chunk-CHQU37CA.mjs +0 -2
- package/dist/chunk-DR73Y2UJ.mjs +0 -3
- package/dist/chunk-E4IHAIJ7.mjs +0 -2
- package/dist/chunk-EURLTOTZ.mjs +0 -4
- package/dist/chunk-F4ZA6JRZ.mjs +0 -3
- package/dist/chunk-GKOBB6DH.mjs +0 -2
- package/dist/chunk-GMJD7ID3.mjs +0 -2
- package/dist/chunk-IA2SIEJQ.mjs +0 -2
- package/dist/chunk-JEUK3ZO7.mjs +0 -2
- package/dist/chunk-JPG2LBQM.mjs +0 -11
- package/dist/chunk-KLQP46Y3.mjs +0 -4
- package/dist/chunk-LMUZQK5O.mjs +0 -2
- package/dist/chunk-MKIBJTJZ.mjs +0 -6
- package/dist/chunk-MNWJ4EZY.mjs +0 -2
- package/dist/chunk-NHP66IWR.mjs +0 -5
- package/dist/chunk-OEIJLMPI.mjs +0 -2
- package/dist/chunk-PDZR3L3C.mjs +0 -2
- package/dist/chunk-PUOQ65NC.mjs +0 -2
- package/dist/chunk-Q4MS6OFC.mjs +0 -2
- package/dist/chunk-Q7P3Q5YX.mjs +0 -13
- package/dist/chunk-QP7BOHE4.mjs +0 -2
- package/dist/chunk-S3SX3COT.mjs +0 -20
- package/dist/chunk-TANZRINB.mjs +0 -2
- package/dist/chunk-UGWMMEJ5.mjs +0 -15
- package/dist/chunk-ULXSPX5H.mjs +0 -5
- package/dist/chunk-USIHBCSW.mjs +0 -15
- package/dist/chunk-VPMRP2TL.mjs +0 -2
- package/dist/chunk-WFGPMCTZ.mjs +0 -4
- package/dist/chunk-XZCFPKGO.mjs +0 -2
- package/dist/chunk-ZFGMJVJC.mjs +0 -2
- package/web/assets/index-FLb9jCfl.css +0 -1
- package/web/assets/index-czjrXVjf.js +0 -15
- /package/dist/{chunk-PAREWQGB.mjs → chunk-NOGQX56R.mjs} +0 -0
package/dist/chunk-6GV3CBB2.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{d as v}from"./chunk-2OHANJ6Q.mjs";import t from"node:fs/promises";import a from"node:path";import{randomBytes as F}from"node:crypto";import{defaultWorkspace as k,layoutOf as M}from"../browser/shared/workspace.mjs";import{withOutlineLock as L}from"../browser/shared/outline.mjs";import{extensionDirectory as P,extensionPath as x,forgetExtensionGrant as z,readManifest as O}from"../browser/shared/extension-manifest.mjs";import{findPreviewServer as T}from"../browser/shared/preview-server.mjs";var b=100*1024*1024,B=1e4;async function I(e,p){let c=await T({answering:!0});if(!c)return null;let n=`http://127.0.0.1:${c.port}`,o=await fetch(`${n}/__gallery/extensions/${e}`,{method:"POST",headers:{Origin:n,"Content-Type":"application/json","X-Gallery-Token":c.token},body:JSON.stringify(p)}),y=await o.json();if(!o.ok)throw new Error(y.message??"\u6269\u5C55\u64CD\u4F5C\u5931\u8D25");return y}async function N(e,{inService:p=!1,beforeReplace:c=async()=>{}}={}){if(e=a.resolve(e),!p){let s=await I("install",{path:e});if(s)return s.installed}let n=M(k()).extensions;if(await t.mkdir(n,{recursive:!0}),(await t.lstat(n)).isSymbolicLink())throw new Error("\u6269\u5C55\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");let o=await t.mkdtemp(a.join(n,".install-")),y=0,Z=0,d=s=>{if(y+=s,++Z>B||y>b)throw new Error("\u6269\u5C55\u8D85\u8FC7 100MB \u6216 10000 \u4E2A\u6587\u4EF6")};try{let s=await t.lstat(e);if(s.isSymbolicLink())throw new Error("\u5B89\u88C5\u6E90\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");if(s.isDirectory()){let r=async(f,u)=>{for(let w of await t.readdir(f,{withFileTypes:!0})){x(w.name);let i=a.join(f,w.name),m=a.join(u,w.name);if(w.isDirectory())d(0),await t.mkdir(m),await r(i,m);else if(w.isFile())d((await t.stat(i)).size),await t.copyFile(i,m);else throw new Error("\u6269\u5C55\u53EA\u80FD\u5305\u542B\u666E\u901A\u6587\u4EF6\u548C\u6587\u4EF6\u5939")}};await r(e,o)}else if(s.isFile()&&e.toLowerCase().endsWith(".zip")){if(s.size>b)throw new Error("\u6269\u5C55 ZIP \u8D85\u8FC7 100MB");let r=v(e);try{let f=new Set,u=r.entries.find(i=>i.name==="extension.json")??r.entries.find(i=>/^[^/]+\/extension.json$/.test(i.name));if(!u)throw new Error("ZIP \u4E2D\u6CA1\u6709 extension.json");let w=u.name.slice(0,-14);for(let i of r.entries){if(x(i.name),!i.name.startsWith(w))throw new Error("ZIP \u7684\u6587\u4EF6\u5FC5\u987B\u5728\u540C\u4E00\u4E2A\u6269\u5C55\u6587\u4EF6\u5939\u5185");let m=i.name.slice(w.length),$=x(m),S=m.toLowerCase();if(f.has(S))throw new Error("ZIP \u4E2D\u5B58\u5728\u91CD\u540D\u6587\u4EF6");f.add(S),d(i.size);let j=a.join(o,...$);await t.mkdir(a.dirname(j),{recursive:!0}),await r.extract(i,j)}}finally{r.close()}}else throw new Error("\u8BF7\u9009\u62E9\u6269\u5C55\u6587\u4EF6\u5939\u6216 ZIP");let E=await O(o),h=E.id??a.basename(e).replace(/\.zip$/i,""),l=P(h),g=a.join(n,`.old-${F(8).toString("hex")}`);return await c(h),await L(k(),async()=>{let r=await t.lstat(l).catch(()=>null);if(r?.isSymbolicLink())throw new Error("\u5DF2\u5B89\u88C5\u7684\u6269\u5C55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");await z(h),r&&await t.rename(l,g);try{await t.rename(o,l)}catch(f){throw r&&await t.rename(g,l),f}r&&await t.rm(g,{recursive:!0,force:!0})}),{id:h,folder:l,agent:E.agent?a.join(l,E.agent):null}}finally{await t.rm(o,{recursive:!0,force:!0})}}async function Y(e,{inService:p=!1,beforeReplace:c=async()=>{}}={}){if(!p&&await I("remove",{id:e}))return;let n=P(e);if((await t.lstat(a.dirname(n))).isSymbolicLink())throw new Error("\u6269\u5C55\u76EE\u5F55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");await c(e),await L(k(),async()=>{if((await t.lstat(n)).isSymbolicLink())throw new Error("\u6269\u5C55\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");await z(e),await t.rm(n,{recursive:!0})})}export{N as a,Y as b};
|
package/dist/chunk-6NLXUKAY.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 U,b as Z,c as ot,d as q}from"./chunk-W5NPH5UA.mjs";import{e as L}from"./chunk-ECZBLQKK.mjs";import{D as nt,a as _,b as V,l as tt,m as D,o as et}from"./chunk-E7656LR7.mjs";import{b as J,c as P,e as Q}from"./chunk-A55HN5OK.mjs";import{IDENTITY as Ne}from"../browser/editor/components/registry.mjs";function gt(e){let{blocks:a,locks:r,units:n,boxes:c}=L(e),l=wt(e,[...a.map(t=>({at:t.innerStart-1,text:` data-ge-block="${t.id}"`})),...r.map(t=>({at:t.at,text:` data-ge-lock="${t.reason}"`})),...n.map(t=>({at:t.at,text:` data-ge-unit="${t.id}"${t.grid?" data-ge-grid":""}${t.keep?` data-ge-keep="${t.keep.reason}"${t.keep.own?" data-ge-keep-own":""}`:""}`})),...n.filter(t=>t.lead!==null).map(t=>({at:t.lead,text:` data-ge-lead="${t.id}"`})),...c.map(t=>({at:t.at,text:` data-ge-box="${t.id}"${t.pure?" data-ge-pure":""}`}))]),p={version:_(e),blocks:a.map(t=>({id:t.id,tag:t.tag,kind:t.kind,caps:Object.keys(t.caps),inner:e.slice(t.innerStart,t.innerEnd),atoms:t.atoms,unit:t.unit,...t.path?{path:t.path}:{},...t.self!==null?{self:!0}:{}})),units:n.map(t=>({id:t.id,kind:t.kind,parent:t.parent,hash:D(e,t),...t.blockId?{blockId:t.blockId}:{},...t.keep?{keep:t.keep}:{},...t.grid?{grid:!0}:{},...t.parts?{parts:t.parts}:{}})),boxes:c.map(t=>({id:t.id,kind:t.kind,unit:t.unit,...t.key!==null?{key:t.key}:{}}))};return{html:l,map:p}}function wt(e,a,r=!0){let n=[],c=0;for(let l of[...a].sort((p,t)=>p.at-t.at)){if(e[l.at]!==">"){if(r)throw new Error(`Unexpected start tag before offset ${l.at}.`);continue}let p=et(e,l.at);n.push(e.slice(c,p),l.text),c=p}return n.push(e.slice(c)),n.join("")}Q();import{COMPONENTS as kt,instancesOf as xt,partOf as st}from"../browser/shared/components/index.mjs";import{attr as rt}from"../browser/shared/html-tree.mjs";var at=new Set(["main","section","article","aside","nav","header","footer","div","details","dialog","figure","blockquote","table","ul","ol","dl"]),Nt=new Set(["script","style","template","textarea","title","xmp","iframe","noembed","noframes","noscript","plaintext","pre","code","kbd","samp","var","svg","math"]),It=kt.filter(e=>e.match&&e.pairs);function Ot(e){let a=e.replace(/^/," "),r=J(a,{sourceCodeLocationInfo:!0}),n=f=>a.slice(0,f).split(`
|
|
3
|
-
`).length,c=[],l=(f,d,s)=>c.push({key:f,tag:a.slice(d,s).replace(/\s+/g," "),line:n(d),offset:d});V(r,"main")||l("no <main> in the file",0,0);let p=[],t=new Set,k=f=>{for(let d of f.childNodes??[]){let s=d.sourceCodeLocation;if(d.nodeName==="#comment"){s&&p.push([s.startOffset,s.endOffset]);continue}if(d.tagName){if(s?.startTag&&p.push([s.startTag.startOffset,s.startTag.endOffset]),Nt.has(d.tagName)){s&&p.push([s.startOffset,s.endOffset??a.length]);continue}s?.endTag&&t.add(s.endTag.startOffset),at.has(d.tagName)&&s?.startTag&&!s.endTag&&l(`<${d.tagName}> not closed`,s.startTag.startOffset,s.startTag.endOffset),k(d)}}};k(r),p.sort((f,d)=>f[0]-d[0]);let N="",h=0;for(let[f,d]of p)d<=h||(N+=a.slice(h,Math.max(h,f))+" ".repeat(d-Math.max(h,f)),h=d);N+=a.slice(h);for(let f of N.matchAll(/<\/([A-Za-z][A-Za-z0-9]*)[^<>]*>?/g)){let d=f[1].toLowerCase();at.has(d)&&!t.has(f.index)&&l(`</${d}> closes nothing`,f.index,f.index+f[0].length)}for(let f of It)for(let d of xt(r,f))for(let{a:s,attrA:g,b:x,attrB:A}of f.pairs){let o=st(d,f.parts[s].at).map(M=>rt(M,g)),u=st(d,f.parts[x].at).map(M=>rt(M,A)),j=M=>new Set(M).size===M.length,I=j(o)&&j(u)&&o.length===u.length&&o.every(M=>u.includes(M)),b=d.sourceCodeLocation;!I&&b&&l(`${f.id}: ${s} and ${x} do not pair`,b.startOffset,b.startTag?.endOffset??b.startOffset)}return c.sort((f,d)=>f.offset-d.offset).map(({key:f,tag:d,line:s})=>({key:f,tag:d,line:s,text:`${f} (line ${s})`}))}Q();import{treeText as z}from"../browser/shared/annotations.mjs";import{attr as F}from"../browser/shared/html-tree.mjs";var it=2e3*2e3,G=2e3,ct=50,lt=1500;function ft(e,a,r,n){let c="",l=a;for(let p of n)p.end<=l||p.start>=r||(p.start>l&&(c+=e.slice(l,p.start)),l=Math.max(l,p.end));return c+e.slice(l,r)}var dt=e=>e.replace(/\s+/g," ").trim(),bt=e=>/\S/.test(e.replace(/<!--[^]*?-->/g,"").replace(/<[^>]*>/g,"").replace(/\u0000/g,"")),pt=e=>e.companion?[{start:e.start,end:e.end},{start:e.companion.start,end:e.companion.end}]:[{start:e.start,end:e.end}];function H(e){let a=L(e),{units:r,blocks:n}=a,c=r[0]?.node??n[0]?.node??null;for(;c?.parentNode;)c=c.parentNode;let l=c?tt(e,[c]):[],p=[...r].sort((o,u)=>o.start-u.start||u.end-o.end),t=new Map,k=[];for(let o of p){for(;k.length&&k.at(-1).end<=o.start;)k.pop();t.set(o,k.at(-1)??null),k.push(o)}for(let o of r.filter(u=>u.companion)){let{start:u,end:j}=o.companion;for(let I of r){if(I===o||I.start<u||I.end>j)continue;let b=t.get(I);(!b||b.start<u)&&t.set(I,o)}}let N=new Map;for(let o of r){let u=t.get(o);u&&N.set(u,[...N.get(u)??[],o])}let h=n.find(o=>o.kind==="title")??null,f=[...r.map(o=>({unit:o,at:o.elStart})),...h?[{unit:null,at:h.start}]:[]].sort((o,u)=>o.at-u.at),d=new Map(f.map((o,u)=>[o.unit,u])),s=new Map;for(let o of r)o.blockId&&s.set(o.blockId,(s.get(o.blockId)??0)+1);let g=f.map(({unit:o})=>{if(!o){let $=dt(ft(e,h.start,h.end,l));return{unit:null,title:!0,kind:"title",key:`title\0${$}`,own:$,counts:1,parent:null,blockId:null,text:z(h.node).slice(0,G)}}let u=N.get(o)??[],j=[...u.flatMap(pt),...l].sort(($,R)=>$.start-R.start),I=dt(pt(o).map(({start:$,end:R})=>ft(e,$,R,j)).join("\0")),b=u.length>0&&!bt(I),M=t.get(o);return{unit:o,kind:o.kind,key:`${o.kind}\0${I}`,own:I,counts:b?0:1,parent:M?d.get(M):null,blockId:o.blockId,text:z(o.node).slice(0,G)}}),x=null;return{rows:g,scanned:a,ref:o=>o.title?{title:!0}:o.blockId&&s.get(o.blockId)===1?{id:o.blockId}:(x??=(()=>{let u=new Map,j=new Map;for(let{unit:I}of f){if(!I)continue;let b=D(e,I);j.set(I,{hash:b,nth:u.get(b)??0}),u.set(b,(u.get(b)??0)+1)}return j})(),x.get(o.unit))}}function St(e,a){if(e.length*a.length<=it)return Z(e,a);let r=s=>s.reduce((g,x)=>g.set(x,(g.get(x)??0)+1),new Map),[n,c]=[r(e),r(a)],l=new Map;a.forEach((s,g)=>{c.get(s)===1&&n.get(s)===1&&l.set(s,g)});let p=[];e.forEach((s,g)=>{l.has(s)&&p.push([g,l.get(s)])});let t=[],k=[];p.forEach(([,s],g)=>{let x=0,A=t.length;for(;x<A;){let o=x+A>>1;p[t[o]][1]<s?x=o+1:A=o}k[g]=x>0?t[x-1]:-1,t[x]=g});let N=[];for(let s=t.at(-1)??-1;s>=0;s=k[s])N.unshift(p[s]);let h=[],[f,d]=[0,0];for(let[s,g]of[...N,[e.length,a.length]]){if((s-f)*(g-d)<=it)for(let[x,A]of Z(e.slice(f,s),a.slice(d,g)))h.push([f+x,d+A]);s<e.length&&h.push([s,g]),[f,d]=[s+1,g+1]}return h}var ut=(e,a)=>a.nested?z(P(e.slice(a.innerStart,a.innerEnd))):z(a.node),mt=e=>e.match(/[A-Za-z0-9]+|\s+|[^A-Za-z0-9\s]/gu)?.length??0,ht=({scanned:e},a)=>(a.title?e.blocks.filter(r=>r.kind==="title"):e.blocks.filter(r=>r.unit===a.unit.id)).sort((r,n)=>r.innerStart-n.innerStart);function yt(e){let a=[],r=n=>{for(let c of n.childNodes??[])c.tagName==="tr"?a.push((c.childNodes??[]).filter(l=>l.tagName==="td"||l.tagName==="th").map(l=>z(l).replace(/\s+/g," ")).join(" \xB7 ")):c.tagName&&r(c.tagName==="template"?c.content:c)};return r(e),a.length?a.join(`
|
|
4
|
-
`):z(e)}function Mt(e,a,r){let n=e[a],c=0;for(let N=n.parent;N!==null;N=e[N].parent)r(N)&&(c+=1);let l=n.title?"h1":n.unit.node.tagName,p=n.title?n.text:yt(P(n.own.replace(/\u0000/g," "))).slice(0,G),t={kind:n.kind,tag:l,depth:c,text:p},k=l==="li"?n.unit.node.parentNode:null;if((k?.tagName==="ul"||k?.tagName==="ol")&&(t.marker=k.tagName,k.tagName==="ol")){let N=(k.childNodes??[]).filter(h=>h.tagName==="li");t.number=(Number.parseInt(F(k,"start")??"1",10)||1)+N.indexOf(n.unit.node)}return t}function $t(e,a){if(e===a)return null;let r=H(e),n=H(a),[c,l]=[r.rows.map(i=>i.key),n.rows.map(i=>i.key)],p=St(c,l);if(p.length===c.length&&p.length===l.length)return null;let t=i=>{let w=new Map;for(let S of i)S.blockId&&w.set(S.blockId,(w.get(S.blockId)??0)+1);return S=>!!S.blockId&&w.get(S.blockId)===1},[k,N]=[t(r.rows),t(n.rows)],h=[],[f,d]=[0,0];for(let[i,w]of[...p,[c.length,l.length]]){let S=new Map;for(let m=d;m<w;m++)N(n.rows[m])&&S.set(n.rows[m].blockId,m);let T=[],v=d-1;for(let m=f;m<i;m++){let O=k(r.rows[m])?S.get(r.rows[m].blockId):void 0;O!==void 0&&O>v&&(T.push([m,O]),v=O)}let B=[],[y,E]=[f,d];for(let[m,O]of[...T,[i,w]]){for(;y<m;y++){let C=r.rows[y];for(let W=E;W<O;W++){let Y=n.rows[W];if(Y.kind===C.kind&&(C.title||ot(C.own,Y.own))){B.push([y,W]),E=W+1;break}}}m<i&&B.push([m,O]),[y,E]=[m+1,O+1]}B.sort((m,O)=>m[0]-O[0]),[y,E]=[f,d];for(let[m,O]of[...B,[i,w]]){for(;y<m;y++)h.push({type:"del",i:y});for(;E<O;E++)h.push({type:"ins",j:E});m<i&&h.push({type:"chg",i:m,j:O}),[y,E]=[m+1,O+1]}i<c.length&&h.push({type:"same",i,j:w}),[f,d]=[i+1,w+1]}let s=new Set(h.filter(i=>i.type==="ins").map(i=>i.j)),g=new Set(h.filter(i=>i.type==="del").map(i=>i.i)),x=(i,w)=>{let S=new Set;for(let T of w)if(i[T].counts)for(let v=i[T].parent;v!==null;v=i[v].parent)S.add(v);return T=>i[T].counts||(S.has(T)?0:1)},[A,o]=[x(n.rows,s),x(r.rows,g)],u={added:0,changed:0,removed:0},j=[],I=[],b=[],M,$=null,R=null,K=i=>{if(!$)return;let w=Math.max(0,$.rows.length-ct);b.push({...i!==null?{before:n.ref(n.rows[i])}:R!==null?{after:n.ref(n.rows[R])}:{into:"main"},count:$.count,rows:$.rows.slice(0,ct),...w?{more:w}:{}}),$=null},X=i=>g.has(i)&&r.rows[i].counts>0;for(let i of h){if(i.type==="del"){$??={count:0,rows:[]},$.count+=o(i.i),u.removed+=o(i.i),X(i.i)&&$.rows.push(Mt(r.rows,i.i,X));continue}if(K(i.j),R=i.j,i.type==="ins"){let w=n.rows[i.j];u.added+=A(i.j),(w.parent===null||!s.has(w.parent))&&j.push({ref:n.ref(w)})}else if(i.type==="chg"){let[w,S]=[r.rows[i.i],n.rows[i.j]];u.changed+=1;let T=ht(r,w),v=ht(n,S),B=[],y=T.length!==v.length||T.length===0||T.some((E,m)=>E.tag!==v[m].tag);y||(T.forEach((E,m)=>{let[O,C]=[ut(e,E),ut(a,v[m])];mt(O)>lt||mt(C)>lt?y=!0:O!==C&&B.push({nth:m,base:O})}),B.length===0&&(y=!0)),y&&(B=[]),I.push({ref:n.ref(S),...y?{whole:!0}:{texts:B}}),S.title&&(M={base:w.text})}}return K(null),{counts:u,added:j,changed:I,...M?{title:M}:{},removed:b}}function Tt(e){let{units:a}=L(e),r=c=>{for(let l=c;l;l=l.parentNode)if(l.tagName&&(F(l,"data-doc-placeholder")!==void 0||l.tagName==="header"||(F(l,"class")??"").split(/\s+/).includes("doc-header")))return!1;return!0},n=c=>/^(img|picture|svg|canvas|video|audio|iframe|object|embed)$/.test(c.tagName??"")||(c.childNodes??[]).some(n);return!a.some(c=>r(c.node)&&(z(c.node)!==""||n(c.node)))}function jt(e,a){try{return q({current:e,ids:!0,...a}).text}catch{return e}}function Et(e,a){try{let r=L(e).blocks.find(c=>c.kind==="title");if(!r)return e;let n=U({current:e,edits:[{id:r.id,parts:[{keep:!0,html:a}]}],ids:!1});return n.ok?n.text:e}catch{return e}}var we=(e,a,r,n)=>nt.installed.rewrite(e,a,r,{packages:n});export{gt as a,Ot as b,$t as c,Tt as d,jt as e,Et as f,we as g};
|
package/dist/chunk-6XD6U3QA.mjs
DELETED
|
@@ -1,5 +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 $,b as u}from"./chunk-6GV3CBB2.mjs";import"./chunk-2OHANJ6Q.mjs";import{b as r,f as c}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{listCapabilities as k,readManifest as v}from"../browser/shared/extension-manifest.mjs";import x from"node:path";import d from"node:fs/promises";import{SIDEBAR_FILE as w,readSidebarText as E}from"../browser/shared/extension-sidebar.mjs";import{extensionSource as N,listExtensions as S,readExtension as I}from"../browser/shared/extensions.mjs";import{isExtensionId as y}from"../browser/shared/outline-shape.mjs";import{withOutlineLock as A}from"../browser/shared/outline.mjs";import{reportsDirectory as f}from"../browser/shared/paths.mjs";import{defaultWorkspace as p,ensureWorkspace as O,layoutOf as g}from"../browser/shared/workspace.mjs";var h=s=>`${s} ${s===1?"entry":"entries"}`;async function L(s){if(s.length>0)throw new r("list takes nothing: gallery extension check <id> reads one.");let o=await k();return S(f,{all:!0}).then(t=>{if(console.log(`Public columns: ${g(p()).extensions} (gallery extension new <id> "<title>").`),t.length===0){console.log(`No extensions visible from ${f}. Use gallery extension new <id> "<title>" (references/extensions.md says how to fill its entries).`);return}console.log(`${t.length} extension${t.length===1?"":"s"} visible from ${f}:`);for(let e of t){let n=e.missing?`no ${w}: it gives the sidebar no column`:e.error?`\u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.error.message}`:`${e.title}, ${h(e.count)}${e.notes.length?`, ${e.notes.length} note${e.notes.length===1?"":"s"}`:""}`;console.log(` ${e.id} ${n}`),console.log(` ${e.file}`);let i=o.find(a=>a.id===e.id);i?.manifest&&console.log(` Script: ${!!i.manifest.workbench?.script}; backend: ${!!i.manifest.server}; enabled: ${i.enabled}`),i?.agent&&console.log(` Agent instructions: ${i.agent}`)}console.log("gallery extension check <id> prints what the sidebar shows of one.")})}function b(s,o,t=[]){for(let e of s){let n=e.url?e.url:"(no address: a click opens and closes what is under it)";t.push(`${" ".repeat(o)}${e.id} ${e.icon?`${e.icon} `:""}${e.title} ${n}`),b(e.children??[],o+1,t)}return t}async function F(s){if(s.length!==1)throw new r("Name one extension: gallery extension check <id>.");let[o]=s;if(!y(o))throw new r(`Not an extension's id: ${o} (its folder's name under extensions/: lowercase letters, digits and dashes, 48 at most).`);let t=await N(f,o);t||(console.error(`No extension "${o}" visible from ${f}: gallery extension list shows them.`),process.exit(1));let e=await I(t.root,o),n=t.file;if(e.missing){if(await v(t.folder).catch(()=>null)){console.log(`OK ${o}: extension.json (${t.folder})`);return}console.error(`FAIL ${n}: there is no ${w}; the folder gives the sidebar no column until it has one (references/extensions.md says how it is written).`),process.exit(1)}e.error&&(console.error(`FAIL ${n}: ${e.error.message}`),console.error(`The sidebar shows the column "${e.title}" with one row: \u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A${e.error.message}`),process.exit(1)),console.log(`The sidebar shows the column ${e.title}${e.icon?` (${e.icon})`:""}, ${h(e.count)}, in the order the file gives (an entry with an address opens it beside the sidebar, one without opens and closes what is under it):`),console.log(e.title);for(let i of b(e.entries,1))console.log(i);for(let i of e.notes)console.log(`note: ${i.message}`);console.log(`OK ${o}: ${h(e.count)} (${n})`)}async function T(s){if(s.length!==2||!y(s[0]))throw new r('Use gallery extension new <id> "<title>".');let[o,t]=s,e=E(JSON.stringify({title:t,entries:[]}));if(e.error)throw new r(e.error.message);let n=p();if(!(await O(n)).ours)throw new r(`Not a Gallery workspace: ${n}`);let i=x.join(g(n).extensions,o),a=x.join(i,w);await A(n,async()=>{for(let l of[g(n).extensions,i]){await d.mkdir(l,{recursive:!0});let m=await d.lstat(l);if(!m.isDirectory()||m.isSymbolicLink())throw new r(`Not an ordinary directory: ${l}`)}try{await d.writeFile(a,JSON.stringify({title:e.sidebar.title,entries:[]},null,2)+`
|
|
3
|
-
`,{flag:"wx"})}catch(l){throw l.code==="EEXIST"?new r(`Already exists: ${a}. Read and edit this file instead.`):l}}),console.log(`Created public extension ${o}
|
|
4
|
-
${a}`)}async function M(s){let[o,...t]=s;if(o==="new"){let{positional:e}=c({argv:t});return T(e)}if(o==="install"||o==="remove"){let{positional:e}=c({argv:t});if(e.length!==1)throw new r(`gallery extension ${o} <${o==="install"?"folder | zip":"id"}>`);if(o==="remove")await u(e[0]),console.log(`Removed extension ${e[0]}`);else{let n=await $(e[0]);console.log(`Installed ${n.id}: ${n.folder}
|
|
5
|
-
Next: enable it in Gallery Settings > Extensions. Its backend starts on first use after enabling.`),n.agent&&console.log(`Agent instructions: ${n.agent}`)}return}if(o==="list"){let{positional:e}=c({argv:t});return L(e)}if(o==="check"){let{positional:e}=c({argv:t});return F(e)}throw new r(o?`No such action: extension ${o} (new, list, check, install, remove).`:"Say what to do: gallery extension new <id> <title>, list or check <id>.")}export{M as run};
|
package/dist/chunk-7EFHNQ5B.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a}from"./chunk-JEUK3ZO7.mjs";import"./chunk-6NLXUKAY.mjs";import{f as D}from"./chunk-VRPVVMRB.mjs";import{b as d,f as J,i as k}from"./chunk-4OZWXZE5.mjs";import{c as F}from"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import{a as A}from"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{existsSync as E}from"node:fs";import R from"node:fs/promises";import m from"node:path";import{iconKind as q}from"../browser/shared/emoji/icon-value.mjs";import{writeAtomic as z}from"../browser/shared/files.mjs";import{reportsDirectory as C}from"../browser/shared/paths.mjs";import{roleOf as M}from"../browser/shared/reports.mjs";import{documentDirectory as P,documentFiles as T,pageSlug as U}from"../browser/shared/workspace.mjs";var K=o=>o.replace(/\s+/g," ").trim(),_=o=>o.replace(/^[a-z]:\/(?:[^/]+\/)*?(?=icons\/(?:tabler\/)?[^/]+$)/i,"/"),h=o=>o===null?"none":JSON.stringify(o);async function ie(o){let{positional:u,values:c}=J({values:["--title","--icon","--description"],argv:o});if(u.length!==1)throw new d("Name one document, then what to set: --title, --icon, --description.");if(!["--title","--icon","--description"].some(e=>c.has(e)))throw new d('Say what to set: --title "<title>", --icon <emoji|none|\u2026>, --description "<text>".');let n=c.has("--title")?K(c.get("--title")):void 0,p=c.has("--description")?K(c.get("--description")):void 0;if(n==="")throw new d("--title takes the words of the title: a document's title is never empty.");if(p==="")throw new d("--description takes words: a document's description is never empty.");let t;if(c.has("--icon")){let e=_(c.get("--icon").trim()),f=e==="none"?"none":q(e);if(!f||/["<>&]/.test(e))throw new d(`Not a page icon: ${e} (an emoji, none, an icon of the \u56FE\u6807 tab as /icons/<name>_<color>.svg, or a picture of the document's assets/).`);if(f==="glyph"&&!F(e))throw new d(`No such icon of the \u56FE\u6807 tab: ${e}.`);t=f==="none"?null:e}let{slug:w}=await k(u[0]),$=P(w,C);(w===await U(C)||await M($)==="instructions")&&(console.error(`${u[0]} is the \u5199\u4F5C\u504F\u597D page: only the user changes it.`),process.exit(1));let{html:r,json:s}=T($);E(r)||(console.error(`No document "${u[0]}": ${a(r)} does not exist (gallery list lists those there are).`),process.exit(1)),t&&q(t)==="image"&&!E(m.join($,...t.split("/")))&&(console.error(`No picture ${t} in ${a($)}: put it in its assets/ first.`),process.exit(1));let i;try{if(i=JSON.parse(await R.readFile(s,"utf8")),!i||typeof i!="object"||Array.isArray(i))throw new Error("not an object")}catch(e){console.error(`${a(s)} does not read (${e.code??e.message}): mend it first.`),process.exit(1)}let b=null,N=!1;for(let e=1;n!==void 0||t!==void 0;e++){let f=await R.readFile(r,"utf8"),v=A(f),y=D(v,{title:n,icon:t});if(y.missing&&(console.error(`${a(r)} has no title to ${n!==void 0?"set":"put the icon before"}: write it as an h1.doc-title in the page's header (writing-html.md, "The page").`),process.exit(1)),b=y.before,y.text===v)break;if(await z(r,y.text,{expect:f})){N=!0;break}e===3&&(console.error(`${a(r)} kept changing while it was being written (the page saving, or an Agent writing it?): nothing written. Run gallery set again.`),process.exit(1))}let l={...i};n!==void 0&&(l.title=n),p!==void 0&&(l.description=p),t===null?delete l.icon:t!==void 0&&(l.icon=t);let x=JSON.stringify(l)!==JSON.stringify(i);x&&await z(s,`${JSON.stringify(l,null,2)}
|
|
3
|
-
`);let S=m.basename(r),g=[];n!==void 0&&g.push(` title: ${h(b.title)} \u2192 ${h(n)} (${S}'s h1 and <title>, ${m.basename(s)})`),t!==void 0&&g.push(` icon: ${h(b.icon)} \u2192 ${h(t)} (${S}'s header, ${m.basename(s)})`),p!==void 0&&g.push(` description: ${h(typeof i.description=="string"?i.description:null)} \u2192 ${h(p)} (${m.basename(s)})`);let j=[...N?[a(r)]:[],...x?[a(s)]:[]];if(j.length===0){console.log(`Nothing to change: ${w} has ${g.length===1?"that already":"those already"}.`);return}console.log(`Set ${w}:`);for(let e of g)console.log(e);let O=j.length===1;console.log(`Re-read ${j.join(", ")} before editing ${O?"it":"them"}: gallery set wrote ${O?"it":"them"} (${[...N?[`${S}: its header`]:[],...x?[`${m.basename(s)}: ${["title","icon","description"].filter(e=>JSON.stringify(l[e])!==JSON.stringify(i[e])).join(", ")}`]:[]].join("; ")}).`)}export{ie as run};
|
package/dist/chunk-7ISBBDJR.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-Q7P3Q5YX.mjs";import"./chunk-4KUO7R2M.mjs";import"./chunk-MKIBJTJZ.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-2KAVXMKG.mjs";import"./chunk-XZCFPKGO.mjs";import"./chunk-BN7M3IN7.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-M4NRDYI5.mjs";import"./chunk-PUOQ65NC.mjs";import"./chunk-6Q7ASAXJ.mjs";import"./chunk-S3SX3COT.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-6NLXUKAY.mjs";import"./chunk-VRPVVMRB.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-USIHBCSW.mjs";import"./chunk-3SKOU6OZ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-PLB7L22J.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-W5NPH5UA.mjs";import"./chunk-ECZBLQKK.mjs";import"./chunk-E7656LR7.mjs";import"./chunk-TKWEX4FD.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{b as BEGIN,e as GESTURES,M as INSIDE_ALONE,N as OPEN_IT,a as READY,c as SAVING,L as TRY_LINES,m as asShown,o as changesOf,k as chosenInstance,z as cutOffSaid,D as documentHost,y as dragPath,x as drawn,s as dropScratch,t as dropStale,v as fallbackSaid,g as gestureOf,i as instancesIn,d as keysOf,B as listen,P as madeSaid,A as nothingSaid,n as partsOf,j as placeSaid,r as scratchCopy,f as stepOf,E as stepsCalled,h as stepsOf,K as stoppedTrial,C as takenAgain,u as takenBy,q as toldBy,J as trial,O as trialSaid,Q as tryCommand,w as untilTaken,l as withoutIds,F as wordsDiffer,G as wordsIn,p as writtenLines,I as writtenOtherwise,H as writtenWords};
|
package/dist/chunk-7M2BQQGZ.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{refusal as ct,said as at}from"../browser/shared/i18n/index.mjs";import{SITE_ICON_BYTES as it,SITE_ICON_TYPES as lt,loginTitle as ut}from"../browser/shared/web-links.mjs";import $ from"node:http";import z from"node:https";import Y from"node:net";import S from"node:tls";import P from"node:zlib";import{Readable as B}from"node:stream";import{execFile as j}from"node:child_process";import{promisify as M}from"node:util";var A=M(j),X=/^(localhost|127\.|10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|\[?::1\]?$|0\.0\.0\.0)/i;function K(t,e){let n=t.toLowerCase();for(let r of e){let o=r.trim().toLowerCase();if(!o)continue;if(o==="*")return!0;if(o==="<local>"){if(!n.includes("."))return!0;continue}if(o.includes("*")){if(new RegExp(`^${o.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")}$`).test(n))return!0;continue}let s=o.replace(/^\./,"").replace(/:\d+$/,"");if(n===s||n.endsWith(`.${s}`))return!0}return!1}var N=t=>/^[a-z]+:\/\//i.test(t)?t:`http://${t}`;function V(t=process.env){let e=t.HTTPS_PROXY||t.https_proxy||t.HTTP_PROXY||t.http_proxy||t.ALL_PROXY||t.all_proxy;return e?{url:N(e),bypass:(t.NO_PROXY||t.no_proxy||"").split(",")}:null}async function J(){let{stdout:t}=await A("reg",["query","HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"],{windowsHide:!0,timeout:3e3}),e=o=>new RegExp(`^\\s*${o}\\s+REG_\\w+\\s+(.*)$`,"mi").exec(t)?.[1]?.trim();if(Number.parseInt(e("ProxyEnable")||"0",16)!==1)return null;let n=e("ProxyServer");if(!n)return null;let r=n;if(n.includes("=")){let o=Object.fromEntries(n.split(";").map(s=>s.split("=").map(c=>c.trim())));if(r=o.https||o.http,!r)return null}return{url:N(r),bypass:(e("ProxyOverride")||"").split(";")}}async function Q(){let{stdout:t}=await A("scutil",["--proxy"],{timeout:3e3}),e=r=>new RegExp(`\\b${r}\\s*:\\s*(\\S+)`).exec(t)?.[1];if(e("HTTPSEnable")!=="1"||!e("HTTPSProxy"))return null;let n=[...t.matchAll(/^\s*\d+\s*:\s*(\S+)\s*$/gm)].map(r=>r[1]);return{url:`http://${e("HTTPSProxy")}:${e("HTTPSPort")||80}`,bypass:n}}var C=null,I=0;async function Z(){let t=V();if(t)return t;if(C!==null&&Date.now()-I<3e4)return C||null;let e=null;try{process.platform==="win32"?e=await J():process.platform==="darwin"&&(e=await Q())}catch{e=null}return C=e||!1,I=Date.now(),e}async function tt(t){let e;try{e=new URL(t).hostname}catch{return null}if(X.test(e))return null;let n=await Z();return n&&!K(e,n.bypass)&&/^http:/i.test(n.url)?n.url:null}var R=t=>t.username?{"proxy-authorization":`Basic ${Buffer.from(`${decodeURIComponent(t.username)}:${decodeURIComponent(t.password)}`).toString("base64")}`}:{};function _(t,e,n,r){return new Promise((o,s)=>{let c=$.request({host:t.hostname,port:t.port||80,method:"CONNECT",path:`${e}:${n}`,headers:{host:`${e}:${n}`,...R(t)},signal:r});c.once("connect",(a,l)=>{a.statusCode===200?o(l):(l.destroy(),s(Object.assign(new Error(`the proxy answered ${a.statusCode}`),{proxyAnswered:a.statusCode})))}),c.once("error",s),c.end()})}function et(t,{method:e,headers:n,signal:r},o){let s=new URL(t),c=new URL(o),a={"accept-encoding":"gzip, deflate, br",...n};return new Promise((l,i)=>{let u=f=>{f.once("response",l),f.once("error",i),f.end()};if(s.protocol==="http:"){u($.request({host:c.hostname,port:c.port||80,method:e,path:s.href,headers:{...a,host:s.host,...R(c)},signal:r}));return}_(c,s.hostname,s.port||443,r).then(f=>{u(z.request(s,{method:e,headers:{...a,host:s.host},defaultPort:443,signal:r,createConnection:()=>S.connect({socket:f,servername:s.hostname,ALPNProtocols:["http/1.1"]})}))},i)})}function T(t,e){let n=new Headers;for(let[l,i]of Object.entries(t.headers))n.set(l,Array.isArray(i)?i.join(", "):String(i));let r=(t.headers["content-encoding"]||"").toLowerCase(),o={gzip:P.createGunzip,"x-gzip":P.createGunzip,deflate:P.createInflate,br:P.createBrotliDecompress}[r],s=o?t.pipe(o()):t;o&&(t.on("error",l=>s.destroy(l)),n.delete("content-encoding"),n.delete("content-length"));let c=[101,204,205,304].includes(t.statusCode);c&&t.resume();let a=new Response(c?null:B.toWeb(s),{status:t.statusCode,statusText:t.statusMessage,headers:n});return Object.defineProperty(a,"url",{value:e}),a}async function nt(t,{method:e="GET",headers:n={},signal:r}={},o){for(let s=0;;s++){let c=await et(t,{method:e,headers:n,signal:r},o),a=c.headers.location;if([301,302,303,307,308].includes(c.statusCode)&&a&&s<10){c.resume(),t=new URL(a,t).href,c.statusCode===303&&(e="GET");continue}return T(c,t)}}var v=t=>t.includes(":")?`[${t}]`:t,ot=t=>/^[\d.]+$/.test(t)||t.includes(":");function Pt(t,{address:e,proxy:n=null,headers:r={},signal:o,connect:s=(a,l)=>Y.connect({host:a,port:l}),ca:c=null}){let a=Number(t.port)||(t.protocol==="https:"?443:80),l=e===null;if(l&&!(n&&t.protocol==="https:"))return Promise.reject(new Error("fetchPinned: only an https address is handed to a proxy by its name"));let i=ot(t.hostname)?void 0:t.hostname,u={"accept-encoding":"gzip, deflate, br",...r,host:t.host},f=`${t.pathname}${t.search}`,L=l||c?[...S.rootCertificates,...c?[c]:[]]:null,b=d=>S.connect({socket:d,servername:i,ALPNProtocols:["http/1.1"],...L?{ca:L}:{},...l?{rejectUnauthorized:!0}:{}}),F=d=>new Promise((x,m)=>{if(o?.aborted)return d.destroy(),m(o.reason);let h=b(d),g=()=>h.destroy(o.reason);o?.addEventListener("abort",g,{once:!0}),h.on("error",p=>{o?.removeEventListener("abort",g),m(p)}),h.once("close",()=>m(new Error("the connection closed before TLS was done"))),h.once("secureConnect",()=>{if(o?.removeEventListener("abort",g),l&&!h.authorized){let p=Object.assign(new Error(`the certificate failed (${h.authorizationError})`),{code:String(h.authorizationError)});return h.destroy(),m(p)}x(h)})});return new Promise((d,x)=>{let m=p=>{let w=(t.protocol==="https:"?z:$).request({method:"GET",signal:o,...p});w.once("response",D=>d(T(D,t.href))),w.once("error",x),w.end()};if(!n){m({host:e,port:a,path:f,headers:u,createConnection:()=>t.protocol==="https:"?b(s(e,a)):s(e,a)});return}let h=new URL(n),g=p=>x(p?.proxyAnswered||o?.aborted?p:Object.assign(p??new Error("the proxy was not reached"),{proxyFailed:!0}));if(t.protocol==="http:"){let p=$.request({host:h.hostname,port:h.port||80,method:"GET",path:`http://${v(e)}:${a}${f}`,headers:{...u,...R(h)},agent:!1,signal:o});p.once("response",w=>d(T(w,t.href))),p.once("error",g),p.end();return}_(h,l?t.hostname:v(e),a,o).then(p=>F(p).then(w=>m({host:l?t.hostname:e,port:a,path:f,headers:u,createConnection:()=>w}),x),g)})}async function rt(t,e={}){let n=await tt(t);if(n)try{return await nt(t,e,n)}catch(r){if(e.signal?.aborted)throw r}return fetch(t,e)}var st="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0 Safari/537.36";async function y(t,{timeout:e=1e4,accept:n="*/*",headers:r={},unreachable:o="\u6253\u4E0D\u5F00\u8FD9\u4E2A\u7F51\u9875",protocols:s=["http:","https:"]}={}){let c;try{c=new URL(t)}catch{throw Object.assign(new Error("\u4E0D\u662F\u7F51\u5740"),{reason:"url"})}if(!s.includes(c.protocol))throw Object.assign(new Error("\u53EA\u652F\u6301 http(s) \u7F51\u5740"),{reason:"url"});return rt(c,{redirect:"follow",signal:AbortSignal.timeout(e),headers:{"user-agent":st,accept:n,...r}}).catch(()=>{throw Object.assign(new Error(o),{reason:"download"})})}async function E(t,e){let n=t.body.getReader(),r=[],o=0;for(;;){let{done:s,value:c}=await n.read();if(s)break;if(r.push(Buffer.from(c)),o+=c.length,o>=e){n.cancel().catch(()=>{});break}}return Buffer.concat(r)}async function O(t,e){let n=await E(t,e+1);return n.length<=e?n:null}var ft={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},H=t=>t.replace(/&(#x[0-9a-f]+|#\d+|\w+);/gi,(e,n)=>{if(n[0]==="#"){let r=n[1]==="x"||n[1]==="X"?parseInt(n.slice(2),16):Number(n.slice(1));return Number.isFinite(r)&&r>0&&r<=1114111?String.fromCodePoint(r):e}return ft[n.toLowerCase()]??e}),U=t=>H(String(t??"")).replace(/\s+/g," ").trim();function pt(t){let e={};for(let n of t.matchAll(/([\w:-]+)\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+))/g))e[n[1].toLowerCase()]=n[3]??n[4]??n[5]??"";return e}function k(t,e){let n=/charset=([\w-]+)/i.exec(e??"")?.[1];n||(n=/<meta[^>]+charset=["']?([\w-]+)/i.exec(t.subarray(0,4096).toString("latin1"))?.[1]);try{return new TextDecoder(n||"utf-8").decode(t)}catch{return new TextDecoder("utf-8").decode(t)}}function q(t,e){let n=t.search(/<\/head>/i),r=n>0?t.slice(0,n):t.slice(0,3e5),o={},s=[];for(let[i]of r.matchAll(/<(meta|link)\b[^>]*>/gi)){let u=pt(i);if(/^<meta/i.test(i)){let f=(u.property||u.name||u.itemprop||"").toLowerCase();f&&u.content!==void 0&&!(f in o)&&(o[f]=u.content)}else u.rel&&u.href&&/(^|\s)(icon|shortcut icon|apple-touch-icon)(\s|$)/i.test(u.rel)&&s.push({rel:u.rel.toLowerCase(),href:u.href})}let c=i=>{try{return i?new URL(H(i),e).href:null}catch{return null}},a=/<title[^>]*>([\s\S]*?)<\/title>/i.exec(r)?.[1],l=s.find(i=>/(^|\s)icon(\s|$)/.test(i.rel))??s.find(i=>i.rel.includes("icon"));return{title:U(o["og:title"]||o["twitter:title"]||a||"").slice(0,300),description:U(o["og:description"]||o["twitter:description"]||o.description||"").slice(0,600),icon:c(l?.href)||c("/favicon.ico"),cover:c(o["og:image"]||o["og:image:url"]||o["og:image:secure_url"]||o["twitter:image"]||o["twitter:image:src"])}}async function ht(t){if(!t)return null;try{let e=await y(t,{timeout:8e3,accept:"image/*,*/*;q=0.5",protocols:["http:","https:","data:"]}),n=(e.headers.get("content-type")??"").split(";")[0].trim();if(!e.ok||!/^image\//.test(n))return null;let r=await O(e,5*1024*1024);return r?.length?r:null}catch{return null}}async function Rt(t){try{let e=await y(t,{timeout:8e3,accept:"text/html,*/*;q=0.8"});if(e.body?.cancel().catch(()=>{}),[401,403].includes(e.status)||W(e.url))return{frameable:!0,reason:"auth"};if(!e.ok)return{frameable:!0,reason:"unknown"};let n=(e.headers.get("x-frame-options")??"").toLowerCase(),r=(e.headers.get("content-security-policy")??"").split(",").map(o=>/(?:^|;)\s*frame-ancestors\s+([^;]*)/i.exec(o)?.[1]?.trim().toLowerCase()).filter(o=>o!==void 0);return r.length?r.some(o=>o==="'none'"||o==="'self'")?{frameable:!1,reason:"frame-ancestors"}:{frameable:!0,...r.every(o=>o==="*")?{}:{reason:"unknown"}}:n.split(",").some(o=>/^(deny|sameorigin)$/.test(o.trim()))?{frameable:!1,reason:"x-frame-options"}:{frameable:!0}}catch(e){return e.reason==="url"?{frameable:!1,reason:"url"}:{frameable:!0,reason:"unknown"}}}function W(t){try{let e=new URL(t);return/^(?:login|signin|passport|sso)\./i.test(e.hostname)||/\/(?:login|signin|sign-in|oauth2\/challenge)(?:[/.]|$)/i.test(e.pathname)}catch{return!1}}async function Ot(t){try{let e=await y(t,{accept:"text/html,application/xhtml+xml;q=0.9,*/*;q=0.8",headers:{"accept-language":"zh-CN,zh;q=0.9,en;q=0.8"}});if([401,403].includes(e.status)||W(e.url))return e.body?.cancel().catch(()=>{}),{title:"",reason:"auth"};let n=e.headers.get("content-type")??"";if(!e.ok||!/html|xml/i.test(n))return e.body?.cancel().catch(()=>{}),{title:"",reason:"unknown"};let r=q(k(await E(e,1.5*1024*1024),n),e.url||t).title;return ut(r)?{title:"",reason:"auth"}:{title:r.slice(0,200)}}catch{return{title:"",reason:"unknown"}}}function dt(t){let e=t.subarray(0,16);return e[0]===137&&e.toString("latin1",1,4)==="PNG"?"image/png":e[0]===0&&e[1]===0&&e[2]===1&&e[3]===0?"image/x-icon":e.toString("latin1",0,3)==="GIF"?"image/gif":e[0]===255&&e[1]===216&&e[2]===255?"image/jpeg":e.toString("latin1",0,4)==="RIFF"&&e.toString("latin1",8,12)==="WEBP"?"image/webp":/^\s*(<\?xml[^>]*>\s*)?<svg[\s>]/i.test(t.subarray(0,512).toString("utf8"))?"image/svg+xml":null}async function G(t,e){if(!t||e<=0)return null;try{let n=await y(t,{timeout:e,accept:"image/*,*/*;q=0.5",protocols:["http:","https:","data:"]});if(!n.ok)return n.body?.cancel().catch(()=>{}),null;let r=(n.headers.get("content-type")??"").split(";")[0].trim().toLowerCase(),o=await O(n,it);if(!o?.length)return null;let s=lt.includes(r)?r:dt(o);return s?`data:${s};base64,${o.toString("base64")}`:null}catch{return null}}async function kt(t,{timeout:e=4e3,env:n=process.env}={}){if(n.GALLERY_SITE_ICON==="off")return null;if(n.GALLERY_SITE_ICON==="local"){let i="";try{i=new URL(t).hostname.replace(/^\[|\]$/g,"")}catch{}if(!/^(127\.\d+\.\d+\.\d+|localhost|::1)$/i.test(i))return null}let r=Date.now()+e,o=()=>r-Date.now(),s=t,c=null;try{let i=await y(t,{timeout:o(),accept:"text/html,application/xhtml+xml;q=0.9,*/*;q=0.8"});s=i.url||t;let u=i.headers.get("content-type")??"";i.ok&&/html|xml/i.test(u)?c=q(k(await E(i,512*1024),u),s).icon:i.body?.cancel().catch(()=>{})}catch{return null}let a=null;try{a=new URL("/favicon.ico",s).href}catch{}return await G(c,o())??(c!==a?G(a,o()):null)}async function qt(t,e,{icon:n=!0,cover:r=!0}={}){let o=await y(t,{accept:"text/html,application/xhtml+xml;q=0.9,*/*;q=0.8",headers:{"accept-language":"zh-CN,zh;q=0.9,en;q=0.8"}}),s=o.url||new URL(t).href,c=o.headers.get("content-type")??"";if(!o.ok)throw ct(at("\u7F51\u9875\u8FD4\u56DE {0}",o.status),{reason:"download"});if(!/html|xml/i.test(c))return o.body?.cancel().catch(()=>{}),{url:s,title:"",description:"",icon:null,cover:null};let a=q(k(await E(o,1.5*1024*1024),c),s),l=async(f,L)=>{let b=await ht(f);try{return b?await e(b,L):null}catch{return null}},[i,u]=await Promise.all([n?l(a.icon,"bookmark-icon"):null,r?l(a.cover,"bookmark-cover"):null]);return{url:s,title:a.title,description:a.description,icon:i,cover:u}}export{tt as a,Pt as b,y as c,O as d,Rt as e,Ot as f,kt as g,qt as h};
|