@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/web/index.html
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Gallery</title>
|
|
7
7
|
<link rel="icon" href="data:," />
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-UW0RyFFt.js"></script>
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Bh74DfsV.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body class="preload">
|
|
12
12
|
<div id="root"></div>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { addStyle } from "../../page/ui.mjs";
|
|
2
|
-
|
|
3
|
-
// Its fill keeps the kit's square corners while it is edited (the light blue of it selected lies
|
|
4
|
-
// 6px past them, round: the kit's --doc-box-reach, overlay-layer.mjs reachOf).
|
|
5
|
-
const STYLE = `
|
|
6
|
-
[data-ge-editing] .doc-callout[contenteditable="true"] { --ge-text-radius: 0px; }
|
|
7
|
-
`;
|
|
8
|
-
|
|
9
|
-
/** A callout on the page: its look while edited. */
|
|
10
|
-
export function create() {
|
|
11
|
-
addStyle(STYLE);
|
|
12
|
-
return {};
|
|
13
|
-
}
|
package/dist/chunk-2PBALTR3.mjs
DELETED
|
@@ -1,57 +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 w}from"./chunk-TX6JH7TR.mjs";import{c as N}from"./chunk-ZBIM6ARY.mjs";import{a as k,b as d,f as O}from"./chunk-NSKUTQ5J.mjs";import{i as S}from"./chunk-HQQMJCQJ.mjs";import{c as u,g as x,o as A,p as C,r as b}from"./chunk-W63L7367.mjs";import $ from"node:fs";import v from"node:path";import{blocksHidden as D}from"../browser/editor/components/registry.mjs";import{PACKAGE_ID as K}from"../browser/shared/components/installed.mjs";import{DEVICE_NAMES as R,layoutOf as F,PACKAGE_MANIFEST as U,shallowPackages as T}from"../browser/shared/workspace.mjs";var W=(e,t,o)=>`{
|
|
3
|
-
"id": "${e}",
|
|
4
|
-
"apiVersion": 1,
|
|
5
|
-
"version": "0.1.0",
|
|
6
|
-
"name": { "zh": "${t}", "en": "${t}" },
|
|
7
|
-
"description": { "zh": "\u4E00\u4E2A\u53EF\u4EE5\u53CD\u590D\u4F7F\u7528\u7684\u5757", "en": "A block to use again" },
|
|
8
|
-
"words": "${t}",
|
|
9
|
-
"parts": {
|
|
10
|
-
"title": { "at": ":scope > h3", "edit": "text" },
|
|
11
|
-
"text": { "at": ":scope > p", "edit": "text", "optional": true }
|
|
12
|
-
},${o?`
|
|
13
|
-
"runtime": { "generated": [".component-drawn"] },`:""}
|
|
14
|
-
"markdown": "parts"
|
|
15
|
-
}
|
|
16
|
-
`,P=(e,t,o)=>`<div data-doc-component="${e}">
|
|
17
|
-
<h3>${t}</h3>
|
|
18
|
-
<p>${o}</p>
|
|
19
|
-
</div>
|
|
20
|
-
`,G=e=>`/* Every selector starts at the instance, so that nothing here reaches the rest of the page. */
|
|
21
|
-
[data-doc-component="${e}"] { padding: 12px 16px; border: 1px solid var(--doc-border); border-radius: 8px; }
|
|
22
|
-
[data-doc-component="${e}"] > h3 { margin-top: 0; }
|
|
23
|
-
`,M=(e,t,o)=>`# ${t}
|
|
24
|
-
|
|
25
|
-
What this block is for, and when a document uses it rather than a block of Gallery's own.
|
|
26
|
-
|
|
27
|
-
## How to write it
|
|
28
|
-
|
|
29
|
-
Write the element as example.html does: \`gallery component show ${e}\` prints it. Each part, and what goes in it:
|
|
30
|
-
|
|
31
|
-
- the title, its \`h3\`: required.
|
|
32
|
-
- the text, its \`p\`: optional.
|
|
33
|
-
|
|
34
|
-
## How it looks
|
|
35
|
-
|
|
36
|
-
What a reader sees of it, and what it shows while it is empty.
|
|
37
|
-
${o?`
|
|
38
|
-
## Its script
|
|
39
|
-
|
|
40
|
-
kit.js runs with the rights of a document's own script. What it draws, it draws in what the manifest's \`runtime\` names.
|
|
41
|
-
`:""}`,_=e=>`// Starts each instance from what the file says, and draws in a node the manifest's runtime names:
|
|
42
|
-
// the kit takes that off an instance before it starts one again, as an undo may put one back.
|
|
43
|
-
DocKit.component({
|
|
44
|
-
id: "${e}",
|
|
45
|
-
on: ["source"],
|
|
46
|
-
mount(host, context) {
|
|
47
|
-
const drawn = document.createElement("div");
|
|
48
|
-
drawn.className = "component-drawn";
|
|
49
|
-
host.append(drawn);
|
|
50
|
-
const draw = () => { drawn.textContent = context.part("title")?.textContent ?? ""; };
|
|
51
|
-
draw();
|
|
52
|
-
return { update: draw };
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
`;function I(e,{script:t=!1}={}){let o=e.split("/")[1];return{"component.json":W(e,o,t),"template.html":P(e,"\u6807\u9898","\u5199\u5728\u8FD9\u91CC\u3002"),"example.html":P(e,"\u4E00\u4E2A\u4F8B\u5B50","\u8FD9\u91CC\u5199\u8FD9\u4E2A\u5757\u5728\u4E00\u4EFD\u6587\u6863\u91CC\u7684\u6837\u5B50\u3002"),"writing.md":M(e,o,t),"style.css":G(e),...t?{"kit.js":_(e)}:{}}}var j="local";function B(e){let t=e.includes("/")?e:`${j}/${e}`;if(!K.test(t))throw new d(`Not a component's id: ${e} (<scope>/<name>, each in lowercase letters, digits and hyphens; a <name> alone is ${j}/<name>).`);let o=t.split("/").find(n=>R.has(n));if(o)throw new d(`Not a component's id: ${e} (Windows keeps ${o} for a device).`);return t}var V=(e,t)=>v.join(F(e).components,...t.split("/")),H=({name:e,file:t})=>`${w(t)} is one level too shallow, and no catalog reads it: a package is components/<scope>/<name>/, so move it to components/${j}/${e}/`;function Y(e,t){let o=T(e).find(({name:n})=>n===t.split("/")[1]);return o?H(o):`No component ${t} in ${w(F(e).components)}: gallery component list says which there are.`}function q(e,t,{script:o}){let n=V(e,t);if($.existsSync(n)||u(e).problems.has(t)){let s=!$.existsSync(v.join(n,U));console.error(s?`A folder is there with no component.json: ${w(n)}: move it, or give this component another name.`:`Component already exists: ${w(n)}: gallery component show ${t} says what it is; give a new one another name.`),process.exit(1)}let a=I(t,{script:o});try{$.mkdirSync(n,{recursive:!0});for(let[s,r]of Object.entries(a).reverse())$.writeFileSync(v.join(n,s),r)}catch(s){if(!s.code)throw s;console.error(`Cannot write ${w(n)} (${s.code}).`),process.exit(1)}console.log(`Created ${w(n)}: ${Object.keys(a).join(", ")}`),console.log(`Next: say in component.json what it is (its name, description and parts), write template.html, what "/" puts in a document, and example.html, an instance as a writer would fill it, then writing.md and style.css${o?" and kit.js":""} (references/building-components.md has every field and the rules), and run gallery component check ${t}, which passes as it stands now.`)}var g=({zh:e,en:t})=>e===t?e:`${e} / ${t}`;function z(e){if(C(e))return null;let t=A(e);return t?x("en",t):"it has no template.html"}var J={disabled:"disabled: its instances show as they stand, no script and no style",hidden:"hidden: the menus do not offer it, and the instances there go on running"};function L(e){let t=u(e),o=b(t),n=o.filter(({reason:i})=>i),a=o.filter(({reason:i})=>!i),s=a.filter(({state:i})=>i==="normal"),r=T(e),c=D(t.settings.hidden),p=()=>{c.length&&console.log(`Hidden by the user, not to write unless asked for: ${c.join(", ")}`)};if(console.log(`\u5DE5\u4F5C\u533A\uFF1A${w(e)}`),a.length+n.length+r.length===0){console.log("No component packages yet. A document is written with Gallery's blocks and whole blocks; gallery component new <id> starts a package when the user wants a block to use again."),p();return}console.log(s.length?`${s.length} component${s.length===1?"":"s"} to write with (gallery component show <id> says how):`:"No component to write with now.");for(let{id:i,name:l,version:m,description:y}of s){console.log(`${i} ${g(l)}`),console.log(` \u7248\u672C\uFF1A${m}\uFF08available\uFF09`),console.log(` \u8BF4\u660E\uFF1A${g(y)}`);let E=z(t.packages.get(i));E&&console.log(` \u6A21\u677F\uFF1Athe menus cannot insert it, and a document can still write it: ${E}`)}let h=a.filter(({state:i})=>i!=="normal");h.length+n.length+r.length>0&&console.log("Not to write with now:");for(let{id:i,name:l,version:m,state:y}of h)console.log(`${i} ${g(l)} ${m} ${J[y]}`);for(let{id:i,reason:l,version:m}of n)console.log(`${i}${m?` ${m}`:""} does not load: ${l.en}`);for(let i of r)console.log(H(i));p()}var Q=(e,{at:t,edit:o,optional:n,min:a,max:s})=>{let r=[n?"optional":"",a!==void 0?`at least ${a}`:"",s!==void 0?`at most ${s}`:""].filter(Boolean);return` ${e} ${t} ${o}${r.length?` (${r.join(", ")})`:""}`};function X(e,t){let o=u(e),n=o.problems.get(t),a=o.packages.get(t)??(n?.off?n:void 0);if(!a){let h=n?.problem;console.error(h?`${t} does not load: ${x("en",h)}`:Y(e,t)),process.exit(1)}let{state:s}=b(o).find(h=>h.id===t);console.log(`${t} ${g(a.name)}`),console.log(` \u7248\u672C\uFF1A${a.version}\uFF08${s==="normal"?"available":s}\uFF09`),console.log(` \u8BF4\u660E\uFF1A${g(a.description)}`),console.log(` ${w(a.folder)}`);let r=Object.entries(a.parts);console.log(r.length?"Parts (edit text: the user types there; none, or data: the component's):":"No parts.");for(let[h,i]of r)console.log(Q(h,i));let c=S(a,"writing.md")?.trimEnd();console.log(c?`How to write it (writing.md):
|
|
56
|
-
${c}`:"How to write it: the package has no writing.md.");let p=S(a,"example.html")?.trimEnd();console.log(p?`The example (example.html):
|
|
57
|
-
${p}`:"The example: the package has no example.html."),console.log("In a document: write the element as the example does, straight in the page or a section, with no data-block-id, which the export gives it.")}var f={new:(e,t,o)=>q(e,t,{script:o}),list:L,show:X,check:async(e,t)=>(await import("./chunk-YL2DPWVS.mjs")).checkCommand(e,t),try:async(e,t)=>(await import("./chunk-GPF4YWWB.mjs")).tryCommand(e,t)},Z=["--press","--drag","--to","--key"];function ee(e){let t=e.indexOf("--"),o=(t===-1?e:e.slice(0,t)).findIndex(s=>s==="--key"||s.startsWith("--key="));if(o===-1)return{argv:e,key:null};let n=o+(e[o].includes("=")?1:2),a=e[n];if(a===void 0||n===t||k(a))throw new d("--key takes a selector and a key: --key <selector> <key> (Enter, Space, ArrowRight, a letter, Shift+Tab).");return{argv:e.filter((s,r)=>r!==n),key:a}}async function we(e,{workspace:t}){try{return await te(e,t)}catch(o){throw o instanceof d&&e.find(n=>!k(n))==="try"&&(o.synopsis=N),o}}async function te(e,t){let{argv:o,key:n}=ee(e),{positional:a,options:s,values:r}=O({options:["--script","--keep"],values:Z,argv:o}),[c,p,...h]=a,i=Object.keys(f).join(", ");if(!c)throw new d(`Say what to do: ${i}.`);if(!Object.hasOwn(f,c))throw new d(`No such component command: ${c} (${i}).`);let l=f[c];if(s.has("--script")&&l!==f.new)throw new d(`--script goes with new, not ${c}.`);let m=[...r.keys(),...s.has("--keep")?["--keep"]:[]];if(l===f.try)return l(t,{named:a.slice(1),values:r,key:n,keep:s.has("--keep")});if(m.length)throw new d(`${m[0]} goes with try, not ${c}.`);if(l===f.list){if(p!==void 0)throw new d(`gallery component ${c} takes nothing else.`);return l(t)}if(p===void 0||h.length>0)throw new d(`gallery component ${c} takes one id.`);return l(t,B(p),s.has("--script"))}export{B as a,V as b,H as c,Y as d,ee as e,we as f};
|
package/dist/chunk-3LA3EMDE.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{a as Ee}from"./chunk-TX6JH7TR.mjs";import{a as Se,b as Ne,c as Oe,d as Ae,e as Le,f as Me}from"./chunk-LC7YNQFG.mjs";import{c as Te}from"./chunk-ITNLYXXV.mjs";import{o as ve}from"./chunk-QMQUXTU4.mjs";import{a as de}from"./chunk-HYMEEXKN.mjs";import{b as je}from"./chunk-5FRMCDPY.mjs";import{l as xe}from"./chunk-W63L7367.mjs";import A from"node:fs/promises";import De from"node:os";import E from"node:path";import{pathToFileURL as Ie}from"node:url";import{instancesOf as Fe}from"../browser/shared/components/index.mjs";import{FALLBACK as Ke,INSTANCE as pe}from"../browser/shared/components/installed.mjs";import{layoutOf as Ye,PACKAGE_MANIFEST as ze}from"../browser/shared/workspace.mjs";var Xe="in a browser, under the export's policy",X="component-check",Q=[360,736,1024],he=["light","dark"],Qe=[1024,360],Pe=1e4,Ze=6e4,we=3e4,_e=2e3,et=3e3,tt=60,nt=2,at=8,ot=we/2,st=/^(?:wasm-)?eval$/,it=new Set(["TargetCloseError","ConnectionClosedError"]),ue=e=>String(e?.message??e).split(`
|
|
3
|
-
`)[0],rt=(e,n)=>`<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${e}</title></head><body><main class="doc-page" data-doc-id="${e}">${n}
|
|
4
|
-
</main></body></html>
|
|
5
|
-
`,lt=({example:e,template:n})=>`<p>example.html</p>${e}
|
|
6
|
-
<hr><p>template.html</p>${n}`,He=(e,n)=>Fe(de(e),n).map(({sourceCodeLocation:{startLine:s,startOffset:i,endOffset:t}})=>({line:s,markup:e.slice(i,t)}));async function ct(e,n){let s=E.join(n,"components",...e.id.split("/"));for(let i of[ze,"template.html",...e.files]){let t=xe(e,i);if(!t)continue;let o=await A.readFile(t);await A.mkdir(E.dirname(E.join(s,i)),{recursive:!0}),await A.writeFile(E.join(s,i),i==="kit.js"?`${o}
|
|
7
|
-
//# sourceURL=kit.js
|
|
8
|
-
`:o)}}async function dt(e,{example:n,template:s},i){await ct(e,i);let t=E.join(i,X);await A.mkdir(t);let o=`${n}
|
|
9
|
-
`,p=je(rt(X,lt({example:n,template:s}))).text;await A.writeFile(E.join(t,"doc.html"),p),await A.writeFile(E.join(t,"doc.json"),JSON.stringify({title:X,description:X,type:"component"}));let u=await(await ve({directory:i}))(X),l=E.join(i,"export.html");await A.writeFile(l,u);let f=o.split(`
|
|
10
|
-
`).length-1,g=He(p,e).map(({line:c})=>c>f?{file:"template.html",line:c-f}:{file:"example.html",line:c});return{html:u,file:l,places:g,source:p}}async function ht({match:e,instance:n,fallback:s,parts:i,at:t,source:o,still:p,step:h,times:u,typed:l,typing:f}){let g=()=>[...document.querySelectorAll(e)].filter(a=>!a.parentElement.closest(n)),c=a=>new Promise(r=>setTimeout(r,a)),d=()=>new Promise(a=>{requestAnimationFrame(a),setTimeout(a,100)}),b=async a=>{await d(),await d();let r=a.outerHTML;for(let k=0,T=Date.now()+p;k<3;){if(Date.now()>T)return null;await c(h);let v=a.outerHTML;k=v===r?k+1:0,r=v}return r},w=a=>{let r=document.createElement("template");return r.innerHTML=a,r.content.firstElementChild},y=a=>`<${a.localName}${a.classList.length?` class="${a.getAttribute("class")}"`:""}>`,m=a=>a.nodeType===1?y(a):`the words "${a.data.trim().slice(0,40)}"`,$=a=>[...a.childNodes].filter(r=>r.nodeType===1||r.nodeType===3&&r.data.trim()),L=(a,r)=>["style","class"].includes(r)&&!a.getAttribute(r)?.trim()?null:a.getAttribute(r),P=(a,r)=>{for(let v of new Set([...a.getAttributeNames(),...r.getAttributeNames()]))if(L(a,v)!==L(r,v))return`${v} on ${y(r)}, ${JSON.stringify(L(a,v))} then ${JSON.stringify(L(r,v))}`;let[k,T]=[$(a),$(r)];for(let v=0;v<Math.max(k.length,T.length);v++){let[S,I]=[k[v],T[v]];if(!S||!I)return`${y(r)} ${S?`without ${m(S)}`:`with ${m(I)} more`}`;if(S.nodeType!==I.nodeType||S.localName!==I.localName||S.nodeType===3&&S.data.trim()!==I.data.trim())return`in ${y(r)}, ${m(S)} then ${m(I)}`;let _=S.nodeType===1?P(S,I):null;if(_)return _}return null},R=a=>{let r=new Map;for(let k of a)r.set(y(k),(r.get(y(k))??0)+1);return r},fe=()=>[...document.querySelectorAll("*")].filter(a=>!a.closest(n)),me=a=>[...a.at(-1).keys()].filter(r=>a.length>2&&a.every((k,T)=>T===0||(k.get(r)??0)>(a[T-1].get(r)??0))),ne=(a,r=()=>!0)=>Object.entries(i).filter(([,{edit:k}])=>r(k)).flatMap(([k,T])=>[...a.querySelectorAll(T.at)].map(v=>({name:k,node:v}))),Y=a=>ne(a,r=>r==="text"),U=a=>Object.entries(i).filter(([,{edit:r}])=>r==="data").map(([r,k])=>({name:r,node:a.querySelector(k.at)})).filter(({node:r})=>r),C=[],V=g()[t];if(!V)return[{kind:"gone"}];if(V.hasAttribute(s))return[{kind:"fallback"}];let ae=await b(V);if(ae===null)return[{kind:"moving"}];let Z=w(o),oe=Y(Z);Y(V).forEach(({name:a,node:r},k)=>{oe[k]&&oe[k].node.innerHTML!==r.innerHTML&&C.push({kind:"redrawn",part:a,how:`the file says ${JSON.stringify(oe[k].node.textContent.trim())}, the page ${JSON.stringify(r.textContent.trim())}`})});let ee=DocKit.dehydrate(V.cloneNode(!0)),se=P(Z,ee);if(se){let a=ne(ee),r=ne(Z).find(({node:k},T)=>a[T]&&P(k,a[T].node))?.name;C.push({kind:"left",what:se,...r?{part:r}:{}})}let qe=U(ee);for(let[a,{name:r,node:k}]of U(Z).entries())!se&&qe[a]?.node.innerHTML!==k.innerHTML&&C.push({kind:"data",part:r});let J=[],ie=new MutationObserver(a=>J.push(...a));ie.observe(document.documentElement,{subtree:!0,childList:!0,characterData:!0});let ge=new Set,ke=a=>{J.push(...ie.takeRecords());for(let{name:r,node:k}of a)(!k.isConnected||J.some(({target:T})=>k.contains(T)))&&ge.add(r);J.length=0},re=[ae],le=[R(fe())],ye=a=>{re.push(a),le.push(R(fe()))},x=ee,ce=Y(x);J.length=0,V.replaceWith(x);let H=await b(x);if(ke(ce),H!==null){ye(H);for(let a=0;a<u&&H!==null;a++){let r=x.cloneNode(!0);ce=Y(r),J.length=0,x.replaceWith(r),x=r,H=await b(x),ke(ce),H!==null&&ye(H)}}ie.disconnect(),H===null&&C.push({kind:"moving"});for(let a of ge)C.push({kind:"redrawn",part:a,how:"a mount changes it"});let be=re.map(a=>R(w(a).querySelectorAll("*"))),$e=me(be);for(let a of $e)C.push({kind:"piles",what:a,counts:be.map(r=>r.get(a)??0)});for(let a of me(le))C.push({kind:"piles",what:a,outside:!0,counts:le.map(r=>r.get(a)??0)});if(!$e.length){let a=re.slice(1).map(r=>P(w(ae),w(r))).find(Boolean);a&&C.push({kind:"changed",what:a})}let te=H===null?[]:Y(x).filter(({node:a})=>a.textContent.trim()),Ge=[...new Set([...new Map(te.map(a=>[a.name,a])).values(),...te])].slice(0,l),Ue=Date.now()+f;for(let{node:a}of Ge){if(Date.now()>Ue)break;let r=document.createTreeWalker(a,NodeFilter.SHOW_TEXT).nextNode(),k=r.data;r.data=`${k}\u2026`;let T=te.map(({node:S})=>S.textContent);await b(x);let v=te.find(({node:S},I)=>!S.isConnected||S.textContent!==T[I]);if(v){C.push({kind:"redrawn",part:v.name,how:"a change of its words does not stand"});break}r.data=k,await b(x)}return H!==null&&U(x).length>0&&C.push(...await Ve()),C;async function Ve(){let a=[],r=null,k=!1,T="as it hears that it can write (the editable signal)",v=[],S=_=>{if(_.target!==x)return;let{parts:F,run:z}=_.detail,M=F.map(({part:j})=>j.innerHTML),K=F.map(({part:j})=>j.cloneNode(!0)),q=z(Object.fromEntries(F.map(({name:j},O)=>[j,K[O]]))),W=F.find(({part:j},O)=>j.innerHTML!==M[O]),B=F.find(({part:j},O)=>K[O].cloneNode(!1).outerHTML!==j.cloneNode(!1).outerHTML);if(W&&F.forEach(({part:j},O)=>{j.innerHTML=M[O]}),!k){let j=W??B??F.find((O,D)=>K[D].innerHTML!==M[D]);j&&!v.some(O=>O.when===T)?v.push({kind:"unasked",part:j.name,when:T}):q&&!j&&_.preventDefault();return}W?r??=`it writes the part ${W.name} on the page, not the draft context.edit hands it, so the editor refuses the edit`:q&&B&&(r??=`it changes the part ${B.name}'s own tag or attributes, which are the file's: a change writes what a part holds, so the editor refuses the edit`),!(W||!q||B)&&(F.forEach(({part:j},O)=>{a.push({part:j,before:M[O]}),j.replaceChildren(...K[O].childNodes)}),_.preventDefault())};document.addEventListener("doc-component-edit",S);try{return[...await I(),...v]}finally{document.removeEventListener("doc-component-edit",S)}async function I(){dispatchEvent(new Event("doc-editable")),await b(x),T="as it mounts";let _=x.cloneNode(!0);x.replaceWith(_),x=_;let F=await b(x);T="as it hears its part changed (the source signal)";let z=DocKit.dehydrate(x.cloneNode(!0)),M=[];k=!0;try{if(!DocKit.example(x))return[{kind:"no-example"}]}catch(D){return[{kind:"example",what:`it throws: ${D?.message??D}`}]}finally{k=!1}let K=await b(x),q=DocKit.dehydrate(x.cloneNode(!0)),W=Object.fromEntries(U(q).map(({name:D,node:G},Je)=>[D,G.innerHTML,U(z)[Je]?.node.innerHTML]).filter(([,D,G])=>D!==G));r?M.push({kind:"example",what:r}):a.length===0?M.push({kind:"example",what:"context.edit was not taken: it was not called, or it answered false, and the console says why"}):Object.keys(W).length===0?M.push({kind:"example",what:"it changes nothing a part holds"}):M.push({kind:"wrote",parts:W});for(let D of[z,q])for(let{node:G}of U(D))G.textContent="";let B=P(z,q);B&&M.push({kind:"example",what:`it changes what is no data part: ${B}`});for(let{part:D,before:G}of a.reverse())D.innerHTML=G;let j=await b(x),O=F!==null&&j!==null?P(w(F),w(j)):null;return K===null||j===null?M.push({kind:"moving"}):O&&!B&&M.push({kind:"undo",what:O}),M}}}var pt=e=>e.map(({name:n,removed:s,added:i,lines:t})=>`${n} (-${s} +${i} of its ${t} line${t===1?"":"s"})`).join(" and "),ut="a write changes the lines it means and no others, a row moved with the blank before it, JSON written back by jsonIn and laid out in template.html and example.html as jsonIn writes it (building-components.md, Two examples)";function wt({kind:e,what:n,part:s,how:i,when:t,counts:o,outside:p,parts:h,back:u,line:l},f,{script:g}){let c=b=>({...f,what:b}),d=b=>({...f,what:b,note:!0});switch(e){case"wrote":return{...f,told:!0,what:`its example wrote ${pt(h)}; the server took it${u?"; put back as an undo does, it shows what it showed":""}`};case"laid":return d(`its example's write lays the part ${s} out anew (${i}): ${ut}`);case"drops":return{...d(`${n} listens for dragover and not for dragenter: a drop goes where both are cancelled, and the move that enters it asks dragenter alone, so that a release then (on a card's words, its padding) drops nothing: cancel dragenter as dragover is cancelled (preventDefault)`),file:"kit.js",line:l};case"gone":return c("the page does not hold this instance");case"fallback":return c(g?"its component failed or never started: the instance shows what it holds, read-only":"the instance shows as one of no package");case"moving":return d("what it shows never holds still (an animation?), so its mounts could not be compared");case"redrawn":return c(`the component redraws its text part ${s}: ${i}. A text part is the file's, what the user types in: read it, and draw in what is the component's`);case"left":return c(`dehydrate does not leave it as the file has it, so a copy of the view would hold what the kit made of it: ${n}. ${s?`That stands in its part ${s}, which is the file's: read a part, and draw in what is the component's`:"Name what it draws in the manifest's runtime, or take it off in dehydrate"}`);case"data":return c(`a mount changes its data part ${s}, so that a page would write what the component left there, with nothing edited: read a data part, and change it by context.edit alone`);case"no-example":return d("it has a data part and its component offers no example of an edit, so nothing has tried the way back to the file: give DocKit.component an example(host, context) that makes a small context.edit");case"example":return c(`its example: ${n}`);case"refused":return c("what its example wrote cannot go in the file: a script, a handler, an address of code, data-block-id or data-ge-*, what does not read back as itself, or what is no JSON in a script of data");case"undo":return c(`with what its example wrote put back, as an undo does, it does not show what it showed: ${n}: draw from the part, and on the source signal`);case"unasked":return c(`it writes its data part ${s} with no reader's gesture, ${t}, once the page takes edits: a page would write it each time it opened. Call context.edit on a gesture alone, a press, a drop or a key, and draw what the part holds as it is`);case"piles":return c(p?`${n} piles up outside the instance on each put-back (${o.join(", then ")} of them), so an undo adds another: a component draws in its instance, and what it has to put elsewhere it takes away again in destroy`:`${n} piles up on each put-back (${o.join(", then ")} of them): it is declared in neither the manifest's runtime nor dehydrate, so an undo adds another`);default:return c(`a mount does not give the same DOM again: ${n}`)}}var ft=e=>[...new Map(e.toReversed().map(n=>[`${n.finding.kind}|${n.finding.part??""}|${["piles","example"].includes(n.finding.kind)?n.finding.what:""}|${n.finding.when??""}|${n.finding.line??""}`,n])).values()].toReversed(),mt=4e6;function We(e,n,s=(i,t)=>i===t){let[i,t]=[e.split(`
|
|
11
|
-
`),n.split(`
|
|
12
|
-
`)],o=0;for(;o<i.length&&o<t.length&&s(i[o],t[o]);)o++;let p=0;for(;p<i.length-o&&p<t.length-o&&s(i[i.length-1-p],t[t.length-1-p]);)p++;let[h,u]=[i.slice(o,i.length-p),t.slice(o,t.length-p)];if(h.length===0&&u.length===0)return[];if(h.length*u.length>mt)return[{removed:h,added:u}];let l=Array.from({length:h.length+1},()=>new Uint32Array(u.length+1));for(let c=h.length-1;c>=0;c--)for(let d=u.length-1;d>=0;d--)l[c][d]=s(h[c],u[d])?l[c+1][d+1]+1:Math.max(l[c+1][d],l[c][d+1]);let f=[],g=null;for(let c=0,d=0;c<h.length||d<u.length;)c<h.length&&d<u.length&&s(h[c],u[d])?(g=null,c++,d++):(g||f.push(g={removed:[],added:[]}),d<u.length&&(c===h.length||l[c][d+1]>=l[c+1][d])?g.added.push(u[d++]):g.removed.push(h[c++]));return f}function gt(e,n){let s=t=>t.filter(o=>o.trim()).length,i=We(e,n);return{removed:i.reduce((t,o)=>t+s(o.removed),0),added:i.reduce((t,o)=>t+s(o.added),0),lines:s(e.split(`
|
|
13
|
-
`))}}function Re(e,n){let s=0,i=0;for(let[t,o]of e.entries())if(t>0&&s>0&&s<n&&i++,s+=o.replace(/\s+/g,"").length,s>=n)break;return i}function kt(e,n){let s=i=>i.filter(t=>!t.trim()).length;for(let{removed:i,added:t}of We(e,n,(o,p)=>o.trim()===p.trim())){if(s(t)>s(i))return"a line left blank";let[o,p]=[i.join("").replace(/\s+/g,""),t.join("").replace(/\s+/g,"")],h=0;for(;h<o.length&&h<p.length&&o[h]===p[h];)h++;let u=0;for(;u<o.length-h&&u<p.length-h&&o[o.length-1-u]===p[p.length-1-u];)u++;for(let[l,f,g]of[[h,i,t],[u,i.toReversed(),t.toReversed()]]){let[c,d]=[Re(f,l)+1,Re(g,l)+1];if(c!==d)return`${c} line${c===1?"":"s"} became ${d}`}}return null}function yt(e,{source:n,found:s,at:i,findings:t}){let o=Te(n,Fe(de(n),s)[i],e.parts,new Map([[s.id,s]]));if(!o)return[{kind:"refused"}];let p=Object.keys(e.parts),h=o.map(({start:l,end:f,text:g},c)=>({name:p[c],before:n.slice(l,f),after:g}));return[{kind:"wrote",back:!t.some(({kind:l})=>l==="undo"||l==="moving"),parts:h.map(({name:l,before:f,after:g})=>({name:l,...gt(f,g)}))},...h.flatMap(({name:l,before:f,after:g})=>{let c=kt(f,g);return c?[{kind:"laid",part:l,how:c}]:[]})]}var bt=2e3;function $t({match:e,instance:n,at:s,most:i}){let t=[...document.querySelectorAll(e)].filter(o=>!o.parentElement.closest(n))[s];return t?[window,document,t,...t.querySelectorAll("*")].slice(0,i):[]}function xt(e){return e.map((n,s)=>s<2?{parent:s-1,named:""}:{parent:s===2?1:e.indexOf(n.parentElement),named:`<${n.localName}${n.classList.length?` class="${n.getAttribute("class")}"`:""}>`})}function vt(){let e=new DragEvent("dragenter",{bubbles:!0,cancelable:!0,composed:!0,dataTransfer:new DataTransfer});return this.dispatchEvent(e),e.defaultPrevented}async function jt(e,{match:n,at:s}){let i=new Map,t=({scriptId:o,url:p})=>i.set(o,p);e.on("Debugger.scriptParsed",t);try{await e.send("Debugger.enable"),await e.send("Debugger.setSkipAllPauses",{skip:!0});let{result:o}=await e.send("Runtime.evaluate",{expression:`(${$t})(${JSON.stringify({match:n,instance:pe,at:s,most:bt})})`,objectGroup:"drops"}),{result:p}=await e.send("Runtime.callFunctionOn",{objectId:o.objectId,functionDeclaration:String(xt),arguments:[{objectId:o.objectId}],returnByValue:!0}),{result:h}=await e.send("Runtime.getProperties",{objectId:o.objectId,ownProperties:!0}),u=h.filter(({name:c,value:d})=>/^\d+$/.test(c)&&d?.objectId).sort((c,d)=>Number(c.name)-Number(d.name)),l=[];for(let{value:c}of u)l.push((await e.send("DOMDebugger.getEventListeners",{objectId:c.objectId})).listeners);let f=(c,d)=>l[c]?.some(b=>b.type===d),g=[];for(let c=2;c<l.length;c++){let d=l[c].find(w=>w.type==="dragover"&&i.get(w.scriptId)==="kit.js");if(!d)continue;let b=!1;for(let w=c;w>=2&&!b;w=p.value[w].parent)b=f(w,"dragenter");if(!b&&(f(0,"dragenter")||f(1,"dragenter"))){let{result:w}=await e.send("Runtime.callFunctionOn",{objectId:u[c].value.objectId,functionDeclaration:String(vt),returnByValue:!0});b=w.value===!0}b||g.push({kind:"drops",what:p.value[c].named,line:d.lineNumber+1})}return g}finally{e.off("Debugger.scriptParsed",t),await e.send("Runtime.releaseObjectGroup",{objectGroup:"drops"}).catch(()=>{}),await e.send("Debugger.disable").catch(()=>{})}}function Tt(e,n){let s={errors:new Map,notes:new Set,failed:new Set,dialogs:new Set,windows:0,opened:[],asked:1,pending:[]},i=t=>{let[o]=t.split(`
|
|
14
|
-
`);s.errors.has(o)||s.errors.set(o,Number(/\bkit\.js:(\d+)/.exec(t)?.[1])||null)};return e.on("pageerror",t=>i(t.stack??t.message)),e.on("console",t=>{let o=t.type();!["error","warn","warning"].includes(o)||!Oe(t,n,["kit.js"])||s.pending.push(Promise.all(t.args().map(p=>p.evaluate(h=>h instanceof Error?h.stack:String(h)).catch(()=>""))).then(p=>{let h=p.join(" ")||t.text();o==="error"?i(h):s.notes.add(h.split(`
|
|
15
|
-
`)[0])}))}),e.on("requestfailed",t=>{t.frame()===e.mainFrame()&&!t.isNavigationRequest()&&s.failed.add(t.url())}),e.on("request",t=>{t.isNavigationRequest()&&t.frame()===e.mainFrame()&&s.opened.push(t.url())}),s}async function Et(e,n){let s=await e.createCDPSession();return await s.send("Page.enable"),s.on("Page.javascriptDialogOpening",({type:i})=>{n.add(i),s.send("Page.handleJavaScriptDialog",{accept:!1}).catch(()=>{})}),s}function N(e,n,s=we){let i=0,t=()=>Object.assign(new Error(n),{stuck:!0,doing:n}),o=new Promise((h,u)=>{i=setTimeout(()=>u(t()),s)}),p=e.catch(h=>{throw it.has(h.name)?t():Object.assign(h,{doing:n})});return Promise.race([p,o]).finally(()=>clearTimeout(i))}var Be=e=>new Promise(n=>{if(!e.connected)return n(!0);e.once("disconnected",()=>n(!0)),setTimeout(()=>n(!1),_e)});function St({match:e,instance:n}){let{clientWidth:s,scrollWidth:i}=document.documentElement;if(i<=s+1)return null;let t=[...document.querySelectorAll(e)].filter(o=>!o.parentElement.closest(n));return{wide:i,at:t.findIndex(o=>[o,...o.querySelectorAll("*")].some(p=>p.getBoundingClientRect().right>s+1))}}var Ce=16,Nt="#8f8f8f";async function Ot(e,n,s){let i=await Promise.all(n.map(async t=>`data:image/png;base64,${(await A.readFile(t)).toString("base64")}`));await e.setViewport({width:Q.reduce((t,o)=>t+o,0)+Ce*(Q.length-1),height:900}),await e.setContent(`<!doctype html><body style="margin: 0; display: flex; align-items: flex-start; gap: ${Ce}px; background: ${Nt}">${i.map((t,o)=>`<img src="${t}" width="${Q[o]}" alt="" style="display: block">`).join("")}</body>`,{waitUntil:"load"}),await e.screenshot({path:s,fullPage:!0})}async function At(e,{file:n,html:s,source:i,places:t,found:o,out:p,loading:h}){let u=await e.createBrowserContext(),l=await u.newPage(),f=Ie(n).href,g=Tt(l,f),c=await Et(l,g.dialogs);u.on("targetcreated",w=>{w.type()==="page"&&(g.windows+=1,w.page().then(y=>y?.close()).then(()=>l.bringToFront()).catch(()=>{}))});let d={heard:g,blocked:[],late:[],taken:[],overviews:[],edited:[],asExport:[],answers:[],wide:[],stuck:null,stopped:null,gone:null},b=async w=>d.late.push(...await N(Me(l,{timeout:Pe}),w,3*Pe+we));await Ae(l),await l.setViewport({width:736,height:900}),await l.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]);try{await N(l.goto(f,{waitUntil:"load",timeout:0}),"the page opened",h),await b("the page opened");for(let m of he){await N(l.emulateMediaFeatures([{name:"prefers-color-scheme",value:m}]),`the ${m} theme came`);for(let $ of Q){if(await N(l.setViewport({width:$,height:900}),`the window went to ${$}px`),await b(`it was drawn at ${$}px`),m===he[0]){let P=await N(l.evaluate(St,{match:o.match,instance:pe}),`it was measured at ${$}px`);P&&d.wide.push({width:$,...P})}let L=E.join(p,`${$}-${m}.png`);await N(l.screenshot({path:L,fullPage:!0}),`it was pictured at ${$}px`),d.taken.push(L)}}await N(l.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]),"the light theme came"),await N(l.setViewport({width:736,height:900}),"the window went to 736px");let w=He(s,o),y=o.files.includes("kit.js")&&Object.values(o.parts).some(({edit:m})=>m==="data");for(let m=0;m<w.length;m++){let $=await N(l.evaluate(ht,{match:o.match,instance:pe,fallback:Ke,parts:o.parts,at:m,source:w[m].markup,still:et,step:tt,times:nt,typed:at,typing:ot}),"an instance was put back"),L=$.find(({kind:R})=>R==="wrote"),P=[...$.filter(R=>R!==L),...L?yt(L,{source:i,found:o,at:m,findings:$}):[]];y&&!$.some(({kind:R})=>R==="gone"||R==="fallback")&&P.push(...await N(jt(c,{match:o.match,at:m}),"the page was asked what an instance listens to")),d.answers.push(...P.map(R=>({finding:R,place:t[m]})))}d.blocked=await N(l.evaluate(()=>globalThis.__qaViolations),"the page was asked what it blocked"),g.asked+=1,await N(l.goto(f,{waitUntil:"load",timeout:0}),"the page opened again",h),await b("the page opened again"),await N(l.evaluate(()=>dispatchEvent(new Event("doc-editable"))),"the page was told it takes edits"),await b("it was drawn as the editing page draws it");for(let m of Qe){await N(l.setViewport({width:m,height:900}),`the window went to ${m}px`),await b(`it was drawn at ${m}px as the editing page draws it`);let $=E.join(p,`edit-${m}-light.png`);await N(l.screenshot({path:$,fullPage:!0}),`it was pictured at ${m}px as the editing page draws it`),d.edited.push($),(await A.readFile($)).equals(await A.readFile(E.join(p,`${m}-light.png`)))&&d.asExport.push($)}d.blocked.push(...await N(l.evaluate(()=>globalThis.__qaViolations),"the page was asked what it blocked"));for(let m of he){let $=E.join(p,`overview-${m}.png`);await N(Ot(l,Q.map(L=>E.join(p,`${L}-${m}.png`)),$),`the ${m} pictures were put side by side`),d.overviews.push($)}}catch(w){if(w.syscall)throw w;await Be(e)?d.gone=w.doing??"the page answered":w.stuck?d.stuck=w.doing:d.stopped=ue(w)}return await Promise.race([Promise.all(g.pending),new Promise(w=>setTimeout(w,_e).unref())]),d}var Lt=(e,n)=>e.startsWith(n)?e.slice(n.length):e;function Mt(e,n,s){let i=new Map;for(let{url:t,directive:o,source:p,line:h}of e){if(st.test(t)){let l=!p&&h>0;i.set(`${t}|${p}|${h}`,{file:l?"kit.js":"the page",...l?{line:h}:{},what:"the export's policy blocks code made from words (eval, new Function, a string given to setTimeout): an export runs none"});continue}let u=/^[a-z][a-z0-9+.-]*$/.test(t)?n.filter(l=>l.startsWith(`${t}:`)):[];for(let l of u.length?u:[t])i.set(`${l}|${o}`,{file:"the page",what:`the export's policy blocks ${Lt(l,s)||"something"} (${o}): ${o==="img-src"?"a picture of an instance is a data: address, or a file its style names":"an export holds all it needs"}`})}return[...i.values()]}function Dt({heard:e,blocked:n,late:s,answers:i,wide:t,stuck:o,stopped:p},{places:h,script:u,folder:l}){let f=ft(i).map(({finding:y,place:m})=>wt(y,m,{script:u})),g=[...e.failed],c=g.filter(y=>!n.some(m=>m.url&&y.startsWith(m.url))),d=e.opened.length>e.asked?"it loads itself again (location.reload(), a new location.href), so a reader's page would not stay":o?`it stopped answering while waiting until ${o}${u?": a script that never ends, or a component that changes what it hears (a text part, on its source signal)":""}`:p&&`the look at it stopped: ${p}`,b=t.map(({width:y,wide:m})=>`${m}px wide in a ${y}px window`).join(", "),w=h[t.find(({at:y})=>y>=0)?.at]??{file:"the page"};return{problems:[...[...e.errors].map(([y,m])=>({file:m?"kit.js":"the page",line:m,what:`the console says ${y}`})),...Mt(n,g,l),...c.map(y=>({file:"the page",what:`it could not load ${y.slice(0,120)}`})),...[...e.dialogs].map(y=>({file:"the page",what:`it opens a dialog (${y}), which stops a reader's page until it is answered: show what it says in the instance`})),...e.windows?[{file:"the page",what:"it opens a window, which takes a reader away from the page: show it in the instance, or link to it"}]:[],...d?[{file:"the page",what:d}]:[],...t.length?[{...w,what:`the page is ${b}: a reader scrolls the whole page sideways, and gallery qa fails it: let it fit the window (max-width: 100%), or put what is wider in a frame of its own that scrolls`}]:[],...f.filter(({note:y,told:m})=>!y&&!m)],notes:[...[...e.notes].map(y=>({file:"the page",what:`the console says ${y}`})),...f.filter(({note:y})=>y),...s.map(y=>({file:"the page",what:`waited for ${y}`}))],told:f.filter(({told:y})=>y)}}async function Jt(e,n,{example:s,template:i},{find:t=Se,start:o=Le,loading:p=Ze}={}){let h=Xe,u=null,l=null;try{u=await A.mkdtemp(E.join(De.tmpdir(),"gallery-component-check-"));let f=await dt(n,{example:s,template:i},u),g=t();if(!g)return{title:h,unverified:"no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one)"};try{l=await o({executablePath:g,args:Ne()})}catch(w){return{title:h,unverified:`the browser ${g} did not start, twice, each time with a fresh profile (${ue(w)}; GALLERY_BROWSER=<its executable> picks another)`}}let c=E.join(Ye(e).qa,"components",...n.id.split("/"));await A.rm(c,{recursive:!0,force:!0}),await A.mkdir(c,{recursive:!0});let d=await At(l.browser,{...f,found:n,out:c,loading:p}),b=Dt(d,{places:f.places,script:n.files.includes("kit.js"),folder:Ie(`${u}${E.sep}`).href});return d.gone?{title:h,...b,unverified:`the browser went while waiting until ${d.gone}, so it says nothing of the package`}:{title:h,...b,...d.taken.length?{pictures:{folder:c,overviews:d.overviews.map(w=>E.basename(w)),each:d.taken.map(w=>E.basename(w)),edited:d.edited.map(w=>E.basename(w)),asExport:d.asExport.map(w=>E.basename(w))}}:{}}}catch(f){return f.reason==="check"?{title:h,problems:f.failures.map(g=>({file:"the export",what:g}))}:f.syscall?{title:h,unverified:`cannot write ${Ee(f.syscall==="mkdtemp"?De.tmpdir():f.path)} (${f.code})`}:l&&await Be(l.browser)?{title:h,unverified:"the browser went before the page opened"}:{title:h,problems:[{file:"the page",what:`the look at it stopped: ${ue(f)}`}]}}finally{await l?.close(),u&&await A.rm(u,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{})}}export{Xe as a,Ze as b,et as c,tt as d,ue as e,rt as f,pt as g,ut as h,gt as i,kt as j,Et as k,N as l,Be as m,Jt as n};
|
package/dist/chunk-5FRMCDPY.mjs
DELETED
|
@@ -1,16 +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 Ge}from"./chunk-E7VYDG2X.mjs";import{A as Ut,C as Ue,F as zt,H as ze,K as qe,L as Je,M as Ve,N as qt,c as at,d as Ke,l as Pt,m as We,t as He,u as gt,w as Pe}from"./chunk-NFIBI4IP.mjs";import{b as ht,e as Ys}from"./chunk-A55HN5OK.mjs";Ys();import tn from"node:path";import{attr as w,curlyQuoted as en}from"../browser/shared/html-tree.mjs";import{FOLDED_LINES as Xe,LINE_START as Ze,NOWRAP as Jt,lineStart as sn,validFolded as nn}from"../browser/shared/code-lines.mjs";import{COLORS as on}from"../browser/shared/colors.mjs";import{FLOWS as an,isInstance as it,matchesNode as $t}from"../browser/shared/components/index.mjs";import{HEADED as ft}from"../browser/shared/components/dialog.mjs";import{pageLanguage as cn}from"../browser/shared/components/page.mjs";import{SHEETS_LABEL as Qe,shortSheets as rn}from"../browser/shared/components/sheets.mjs";import{iconValueOf as ln}from"../browser/shared/emoji/icon-value.mjs";import{escapeText as pt}from"../browser/shared/escape.mjs";import{COLUMN_GAP as fn,READING_WIDTH as St,SPAN as Ye,SPAN_SIZE as dt}from"../browser/shared/media.mjs";import{kitNamespace as ls}from"../browser/shared/old-names.mjs";import{CHART_DATA as fs,CHART_SOURCE as tt,nextChartKey as dn}from"../browser/shared/table-chart.mjs";import{BLOCK_COLORS as se}from"../browser/editor/components/colors.mjs";import{DETAILS as un,DIALOG as Xt,PAGE as mn,SECTION as hn,SHEETS as gn}from"../browser/editor/components/kit.mjs";import{DIALOG_TRIGGER as pn}from"../browser/editor/components/dialog/index.mjs";import{CHECKED as ne,FLOW as ut,TODO as Zt}from"../browser/editor/components/list/index.mjs";import{texSource as Nn}from"../browser/editor/components/math/index.mjs";import{BOX_CLASSES as On,HOSTS as $n,UNIT_KINDS as wn}from"../browser/editor/components/registry.mjs";import{HEADER_LOOK as ts}from"../browser/editor/components/table/index.mjs";import{backgroundColor as bn,parseColor as kn,textColor as Ln}from"../browser/editor/page/clipboard/import/colors.mjs";var oe=new Set(["script","style","template","textarea","noscript","code","svg","math","select","option","button","iframe","video","audio","canvas","object","picture"]),It=["doc-figure","doc-code","doc-diff","doc-math-inline","doc-math-block","doc-link-mention","doc-sheet-tabs","doc-state-fields","doc-filter-row","doc-image","doc-file","doc-bookmark","doc-embed","doc-icon","doc-title","doc-table-meta"],ae=new Set(["p","h1","h2","h3","h4","h5","h6","li","td","th","dt","dd","blockquote","figcaption","caption","summary"]),xt=new Set(["main","section","div","article","aside","blockquote","li","details","dialog"]),yn=new Set(on.map(({name:s})=>s)),C=s=>(w(s,"class")??"").split(/\s+/).filter(Boolean),es=s=>C(s).every(n=>se.includes(n)),vn=se.filter(s=>s.startsWith("doc-highlight-")),ct=s=>C(s).some(n=>!ls(n)),D=s=>s.nodeName==="#text",At=/^[\s\u200b-\u200d\u2060\ufeff]*$/,J=s=>D(s)&&At.test(s.value),L=s=>(s.childNodes??[]).filter(n=>n.tagName),Z=s=>(s.attrs??[]).map(n=>n.name),K=(s,n)=>Z(s).every(d=>n.includes(d)),Cn=[hn.match,un.match,Xt.match,gn.match,"table.doc-table"].join(", ");function ds(s){let n=C(s);return n.some(d=>It.includes(d))||Ke(s)||$t(s,Cn)||On.some(([d])=>n.includes(d))||wn.some(d=>d.class&&n.includes(d.class)&&(!d.tag||[d.tag].flat().includes(s.tagName)))}var Sn=s=>{for(let n=s.parentNode;n?.tagName&&n.tagName!=="main";n=n.parentNode)if(n.tagName==="figure")return!0;return!1},us=new Set(["thead","tbody","tfoot","tr","colgroup","col"]),ie=s=>ct(s)&&s.tagName!=="figure"&&!ae.has(s.tagName)&&!us.has(s.tagName)&&!ds(s),ms=new Set([...at].filter(s=>!["header","main","dialog","form","fieldset","caption","dd","dt","figcaption","summary","li","td","th",...us].includes(s))),xn=/\\\(([\s\S]*?)\\\)/g,Nt=s=>Nn(s)&&/\S/.test(s);function Tn(s,n=!0){let d=n?s:/^\s*(?:\\\[[\s\S]*?\\\]|\$\$[\s\S]*?\$\$)/.exec(s)?.[0]??"";return/[<>]/.test(d)&&Nt(d.replace(/</g,"\\lt ").replace(/>/g,"\\gt "))}var Qt=new Set(["br","wbr","img","input"]),hs=new Set([...at,"script","style","template","noscript","link","meta"]),gs=new Set(["input","select","textarea","button","label","option"]),En=new Set([...at,"hgroup","search","center","dir","listing","xmp","plaintext"]),Yt=s=>L(s).some(n=>En.has(n.tagName)||Yt(n)),ps=new Set(["main","section","div","article","aside","blockquote"]),In=an.join(", "),An=s=>ps.has(s.tagName)&&!ct(s)&&(C(s).length===0||$t(s,In)),et=s=>D(s)?!At.test(s.value):(s.childNodes??[]).some(et),Ns=s=>s.childNodes.some(n=>D(n)&&!At.test(n.value))&&L(s).some(n=>at.has(n.tagName)),_n=/^[ \t\n\r\f]*/;function Vt(s){let n=[],d=[];for(let u of s)u.tagName&&hs.has(u.tagName)?(n.push(d),d=[]):d.push(u);n.push(d);let p=u=>!u.tagName&&!et(u),N=u=>(D(u)||u.tagName&&!gs.has(u.tagName))&&et(u);return n.map(u=>{let O=u.findIndex(h=>!p(h));return O<0?[]:u.slice(O,u.findLastIndex(h=>!p(h))+1)}).filter(u=>u.some(N))}function jn(s){let n=[],d=p=>{for(let N of p.childNodes??[])N.tagName==="style"?n.push(N.childNodes.map(u=>u.value??"").join("")):N.tagName&&N.tagName!=="template"&&d(N)};return d(s),n.flatMap(p=>[...p.replace(/\/\*[\s\S]*?(?:\*\/|$)/g," ").matchAll(/([^{};]*)\{/g)].map(([,N])=>N))}var Bn=(s,{tags:n=[],classes:d=[]})=>{let p=[...n.map(u=>`(?<![\\w.#-])${u}`),...d.map(u=>`\\.${u}`)],N=p.length?new RegExp(`(?:${p.join("|")})(?![\\w-])`,"i"):null;return!!N&&s.some(u=>N.test(u))};function Mn(s){let n=[],d=p=>{for(let N of p.childNodes??[])N.tagName==="script"?n.push(N.childNodes.map(u=>u.value??"").join("")):N.tagName&&N.tagName!=="template"&&d(N)};return d(s),n.join(`
|
|
3
|
-
`)}var ce=["contains-task-list","task-list-item"],re=["task-list-item"],Os=["task-list-item-checkbox"],le=(s,n)=>C(s).every(d=>n.includes(d));function $s(s){let n=s.childNodes.find(d=>!J(d));return n?.tagName==="input"&&K(n,["type","checked","disabled","class"])&&w(n,"type")?.toLowerCase()==="checkbox"&&le(n,Os)&&n.sourceCodeLocation?.startTag?n:null}var ws=s=>s.tagName==="li"&&le(s,re)&&w(s,ne)===void 0&&s.sourceCodeLocation?.startTag&&$s(s),Rn=s=>s.tagName==="ul"&&le(s,ce)&&L(s).length>0&&s.childNodes.every(n=>n.tagName==="li"||J(n))&&L(s).every(ws),Dn={classes:[...new Set([...ce,...re,...Os])]},Fn=/checkbox|task-list/i,te=s=>s.tagName==="ol"&&(w(s,"data-doc-chart")==="flow"||w(s,"data-flow")!==void 0&&w(s,"data-doc-chart")===void 0),Gn=s=>s?.tagName==="ol"&&!ct(s)&&(C(s).includes(ut)||te(s)),Kn=s=>s.tagName==="li"&&Gn(s.parentNode),Et="doc-icon",Wn=s=>s.some(n=>n.tagName==="strong"||n.tagName==="b")&&s.every(n=>n.tagName==="strong"||n.tagName==="b"||D(n)&&At.test(n.value)||n.nodeName==="#comment"),Hn=/^(?:inherit|unset|currentcolor|none)$/i,Pn=/^(?:inherit|initial|unset|revert|revert-layer|transparent|none)$/i,z=s=>s.replace(/\s+/g," ").trim(),ss=/^\s*--doc-(?:table-height|span)\s*:/i;function ee(s){let n=s.replace(/\/\*[\s\S]*?(?:\*\/|$)/g," "),d=[],p="",N=0,u=0;for(let O=0;O<=n.length;O++){let h=n[O];p?h==="\\"?O++:h===p&&(p=""):h==='"'||h==="'"?p=h:h==="("?N++:h===")"?N=Math.max(0,N-1):(h===";"&&N===0||O===n.length)&&(d.push(n.slice(u,O)),u=O+1)}return d.filter(O=>O.trim())}function bs(s){let n=new Map;for(let l of ee(s)){let $=l.indexOf(":"),i=z($<0?l:l.slice(0,$)).toLowerCase();n.set(i==="background-color"?"background":i,$<0?"":z(l.slice($+1).replace(/!\s*important\s*$/i,"")))}let d=[],p=[],N,u,O=new Set,h=(l,$,i)=>{if((l==="color"?Hn:Pn).test($))return;let f=kn($);if(!f||f.a===0&&l==="color"){d.push(l);return}if(f.a===0)return;let g=i($,{nearest:!0})?.replace(/_background$/,"");if(!g||!yn.has(g)){p.push(`${l} ${$} left out: the ${l==="color"?"text's":"page's"} own is the nearest`);return}return i($)?.replace(/_background$/,"")!==g&&p.push(`${l} ${$} written as the kit's ${g}${l==="color"?"":" highlight"}`),g};for(let[l,$]of n)l==="color"?N=h(l,$,Ln):l==="background"?u=h(l,$,bn):l==="font-weight"&&/^(?:bold|bolder|[6-9]\d\d)$/i.test($)?O.add("strong"):l==="font-style"&&/^(?:italic|oblique)\b/i.test($)?O.add("em"):(l==="text-decoration"||l==="text-decoration-line")&&/^(?:(?:underline|line-through|solid)\s*)+$/i.test($)&&/underline|line-through/i.test($)?(/underline/i.test($)&&O.add("u"),/line-through/i.test($)&&O.add("s")):d.push(l);if(d.length)return{foreign:[...new Set(d)]};let y=[];N&&y.push([`<span class="doc-text-${N}">`,"</span>"]),u&&y.push([`<span class="doc-highlight-${u}">`,"</span>"]);for(let l of["strong","em","u","s"])O.has(l)&&y.push([`<${l}>`,`</${l}>`]);return{open:y.map(([l])=>l).join(""),close:y.map(([,l])=>l).reverse().join(""),notes:p}}var ns=/^(?:language|lang)-([\w#+.-]+)$/,Un=new Set(["data-language","data-lang","data-block-id"]),zn=[{name:Ze,names:[Ze,"data-start"],value:s=>sn(s)?.toString()??null,says:"the number of its first line is a whole number from 1"},{name:"data-line-numbers",names:["data-line-numbers"],value:s=>/^\s*(?:true|false)\s*$/i.test(s)?s.trim().toLowerCase():null,says:"false hides its line numbers, true shows them"},{name:Xe,names:[Xe],value:s=>nn(z(s))?z(s):null,says:"its folded lines are their numbers from 1, spaces between"}],os="data-title",as="data-wrap",qn=s=>L(s).length===1&&L(s)[0].tagName==="code"&&s.childNodes.every(n=>n.tagName||J(n))?L(s)[0]:null,Jn=new Set(["a","abbr","b","bdi","bdo","cite","code","data","del","dfn","em","font","i","ins","kbd","mark","q","s","samp","small","span","strike","strong","sub","sup","time","tt","u","var","br","wbr"]),Vn=new Set(["code","kbd","samp","tt","var"]);function ks(s){for(let n of s.childNodes){if(D(n))continue;if(!n.tagName)return"a comment in its <figcaption>";if(["img","picture","svg"].includes(n.tagName))return"a picture in its <figcaption>";if(!Jn.has(n.tagName))return`a <${n.tagName}> in its <figcaption>`;if(!n.sourceCodeLocation?.startTag||!(n.sourceCodeLocation.endTag||Qt.has(n.tagName)))return`a <${n.tagName}> not closed in its <figcaption>`;let d=ks(n);if(d)return d}return""}function is(s){let n=L(s),d=n.filter(y=>y.tagName==="pre"),p=n.filter(y=>y.tagName==="figcaption");if(!d.length)return null;let[N]=d,[u=null]=p,O=s.childNodes.find(y=>!y.tagName&&!J(y)),h=d.length>1||p.length>1||n.length>d.length+p.length?"more than the pre and one <figcaption> in its <figure>":O?D(O)?"words in its <figure> outside its caption":"a comment in its <figure>":u?Z(u).length?`its <figcaption> has an attribute of its own (${Z(u).join(", ")})`:u.sourceCodeLocation?.endTag?ks(u):"its <figcaption> is not closed in the file":"";return h?{pre:N,caption:u,why:h}:{pre:N,caption:u}}function Tt(s){let n=(s.attrs??[]).filter(({value:p})=>p.trim()),d=s.tagName==="abbr";return n.map(p=>`${p.name} ${JSON.stringify(z(p.value))} dropped: ${d&&p.name==="title"?"write the full name in the text":"write it in the text if the reader needs it"}`)}var q=s=>s.replace(/&/g,"&").replace(/"/g,""");function Xn(s){let n=new Set,d=p=>{for(let N of p.childNodes??[])if(N.tagName){for(let u of[tt,fs])w(N,u)!==void 0&&n.add(w(N,u));d(N.tagName==="template"?N.content:N)}};return d(s),n}function Zn(s){let n=new Map,d=p=>{for(let N of p.childNodes??[]){if(!N.tagName)continue;let u=w(N,"id");u!==void 0&&n.set(u,(n.get(u)??0)+1),d(N.tagName==="template"?N.content:N)}};return d(s),n}var Qn=/^[A-Za-z][\w-]{0,63}$/;function Yn(s){let n=Ge(s),d=ht(n,{sourceCodeLocationInfo:!0}),p=jt(d);if(!p)return{text:n,changes:[]};let N=[],u=[],O=t=>n.slice(0,t).split(`
|
|
4
|
-
`).length,h=(t,e,o=[],a={})=>{let c=O(t.sourceCodeLocation.startOffset);o.length||u.push({line:c,rule:e,...a});for(let r of o)u.push({line:c,rule:e,note:r,...a})},y=0,l=(t,e,o,{opens:a=null,closes:c=null,move:r=null,leaves:m=!1}={})=>N.push({start:t,end:e,text:o,order:y++,opens:a,closes:c,move:r,leaves:m}),$=(t,e,o,a)=>{l(t,t,o,{opens:e}),l(e,e,a,{closes:t})},i=t=>t.sourceCodeLocation?.startTag,f=t=>t.sourceCodeLocation?.endTag,g=(t,e,{drop:o=[]}={})=>{let a=C(t).filter(m=>!o.includes(m)),c=[...a,...e.filter(m=>!a.includes(m))],r=t.sourceCodeLocation.attrs?.class;if(c.join(" ")!==C(t).join(" "))if(r&&c.length)l(r.startOffset,r.endOffset,`class="${q(c.join(" "))}"`);else if(r)S(t,"class");else{let m=i(t).startOffset+1+t.tagName.length;l(m,m,` class="${q(c.join(" "))}"`)}},S=(t,e)=>{let o=t.sourceCodeLocation.attrs[e],a=o.startOffset;for(;/[ \t\n\r\f]/.test(n[a-1]??"");)a--;l(a,o.endOffset,"")},M=(t,e,{classes:o=[],drop:a=[]}={})=>{let c=t.sourceCodeLocation,r=Object.entries(c.attrs??{}).filter(([v])=>v!=="class"&&!a.includes(v)).map(([,v])=>` ${n.slice(v.startOffset,v.endOffset)}`).join(""),m=[...o,...C(t).filter(v=>!o.includes(v))];return`<${e}${m.length?` class="${q(m.join(" "))}"`:""}${r}>`},_,F=t=>Bn(_??=jn(d),t),Q,rt=t=>t.test(Q??=Mn(d)),W=(t,e,o)=>{l(i(t).startOffset,i(t).endOffset,e),f(t)&&l(f(t).startOffset,f(t).endOffset,o)},Bt=t=>W(t,"",""),H=t=>!!(i(t)&&(f(t)||t.tagName==="img")),de,ue=t=>{let e=w(t,"id");if(t.tagName!=="dialog"||!K(t,["id"])||!Qn.test(e??"")||!H(t))return!1;let o=L(t);return!(o.length?ms.has(o[0].tagName)&&H(o[0]):t.childNodes.some(c=>!J(c)&&c.nodeName!=="#comment"))||o.some(c=>c.tagName==="form")?!1:(de??=Zn(d),de.get(e)===1)},xs=t=>{let e=L(t)[0];return!$t(e,Xt.short)||Z(e).length?null:t.childNodes.slice(0,t.childNodes.indexOf(e)).every(J)?e:null},me=t=>t.tagName==="dialog"&&(C(t).includes("doc-dialog")||ue(t)),he=(t,e=[])=>{for(let o of t.childNodes??[])o===p||it(o)||(me(o)&&H(o)?e.push(o):he(o,e));return e},Mt=f(p)?he(d):[],ge,Ts=t=>(ge??=new Set((function e(o,a=[]){for(let c of o.childNodes??[])!c.tagName||it(c)||(me(c)&&a.push(w(c,"id")),e(c,a));return a})({childNodes:[p,...Mt]})),/^#./.test(t??"")&&ge.has(t.slice(1))),Es=t=>{let[e,...o]=L(t);if(!e||o.length||!C(e).includes("doc-dialog-panel"))return null;let[a,c,...r]=L(e);if(r.length||!a||!c||!C(a).includes(ft.header)||!C(c).includes("doc-dialog-content"))return null;let m=x=>x.childNodes.some(A=>!A.tagName&&!J(A)&&A.nodeName!=="#comment");if(m(e)||m(a)||!H(a)||!i(c))return null;let v=L(a),k=v.filter(x=>C(x).includes(ft.title)),E=v.filter(x=>!k.includes(x)),I=x=>(C(x).includes(ft.close)||w(x,ft.closeAttribute)!==void 0)&&H(x);return k.length!==1||!H(k[0])||E.length>1||!E.every(I)?null:{header:a,title:k[0],close:E[0]??null,content:c}},mt,pe=(t,e=[])=>{for(let o of t.childNodes??[])if(o.tagName){for(let{name:a,value:c}of o.attrs)a!=="id"&&a!=="class"&&e.push(c);(o.tagName==="script"||o.tagName==="style")&&e.push(o.childNodes.map(a=>a.value??"").join("")),pe(o,e)}return e},Is=(t,e)=>{mt??=pe(d).join(`
|
|
5
|
-
`);let o=0;for(let a=mt.indexOf(t);a>=0;a=mt.indexOf(t,a+t.length))!/[\w-]/.test(mt[a-1]??"")&&!/[\w-]/.test(mt[a+t.length]??"")&&o++;return o>(e?1:0)};function As(t){let e=Es(t);if(!e)return;let{header:o,title:a,close:c,content:r}=e,m=w(a,"id"),v=!!m&&w(t,"aria-labelledby")?.trim()===m;v&&S(t,"aria-labelledby"),l(i(o).startOffset,i(o).endOffset,n.slice(i(r).startOffset,i(r).endOffset));let k=i(a).startOffset+1;l(k,k+a.tagName.length,"h3"),g(a,[],{drop:[ft.title]}),m!==void 0&&!(m&&Is(m,v))&&S(a,"id"),l(f(a).startOffset,f(a).endOffset,"</h3>"),c&&l(c.sourceCodeLocation.startOffset,c.sourceCodeLocation.endOffset,""),l(f(o).startOffset,f(o).endOffset,""),l(i(r).startOffset,i(r).endOffset,"")}let Ne=t=>{for(let e of t.childNodes??[])it(e)||(e.tagName&&$t(e,Xt.match)&&As(e),Ne(e))},Rt=new Set;function Oe(t){let e=t.tagName;if(!H(t))return!1;let o=[];if(e==="mark"&&K(t,[]))W(t,'<span class="doc-highlight-yellow">',"</span>");else if((e==="del"||e==="strike")&&K(t,["cite","datetime"]))W(t,"<s>","</s>"),o=Tt(t);else if(e==="ins"&&K(t,["cite","datetime"]))W(t,"<u>","</u>"),o=Tt(t);else{if(["kbd","samp","tt","var"].includes(e)&&K(t,[]))return W(t,"<code>","</code>"),Rt.add(t),h(t,e),!0;if(e==="a"&&K(t,["href"])&&Ts(w(t,"href")))return g(t,[pn]),h(t,"dialog link"),!1;if(e==="small"&&K(t,[]))W(t,'<span class="doc-text-gray">',"</span>");else if(e==="q"&&K(t,["cite"]))W(t,"\u201C","\u201D"),o=Tt(t);else if(["abbr","cite","dfn","time","bdi","data"].includes(e)&&K(t,["title","datetime","value"]))Bt(t),o=Tt(t);else if(e==="span"&&K(t,[])||e==="font"&&K(t,["color"])&&!w(t,"color")?.trim())Bt(t);else if(e==="span"&&K(t,["style"])||e==="font"&&K(t,["color"])){let a=bs(e==="span"?w(t,"style")??"":`color: ${w(t,"color")}`);if(a.foreign)return!1;W(t,a.open,a.close),o=a.notes}else return!1}return Rt.add(t),h(t,e,o),!1}function _s(t){let{startOffset:e,endOffset:o}=t.sourceCodeLocation,a=n.slice(e,o);for(let c of a.matchAll(xn))$(e+c.index,e+c.index+c[0].length,'<span class="doc-math-inline">',"</span>"),u.push({line:O(e+c.index),rule:"formula"})}let $e=t=>L(t).every(e=>Rt.has(e)?$e(e):Ue(e));function js(t,e){let o=Ut(e);if(!o||t.tagName!==$n[o].takes||!H(e)||!H(t)||Z(t).length>0||!e.childNodes.every(r=>r===t||J(r))||!$e(t))return;let a=n.slice(i(e).endOffset,i(t).startOffset)+n.slice(f(t).endOffset,f(e).startOffset);l(i(e).endOffset,i(t).endOffset,""),l(f(t).startOffset,f(e).startOffset,"");let c=a.split(`
|
|
6
|
-
`).length-1;c>0&&l(f(e).endOffset,f(e).endOffset,lt.repeat(c)),h(e,o)}let Dt=new Set,we=new Set;function wt(t,e=()=>!1){for(let o of Vt(t)){if(!o.every(k=>k.tagName?i(k)&&(f(k)||Qt.has(k.tagName))&&!Yt(k):k.sourceCodeLocation))continue;let a=o[0].sourceCodeLocation.startOffset,c=o.at(-1).sourceCodeLocation.endOffset,r=n.slice(a,c),m=a+_n.exec(r)[0].length,v=c-/[ \t\n\r\f]*$/.exec(r)[0].length;if(o.every(D)&&Nt(n.slice(m,v)))$(m,v,'<div class="doc-math-block">',"</div>"),u.push({line:O(m),rule:"display formula"}),o.forEach(k=>we.add(k));else if(e(o)){let k=Wn(o);$(m,v,k?"<p>":"<p><strong>",k?"</p>":"</strong></p>"),u.push({line:O(m),rule:"step title",...ke(o[0].parentNode)}),o.forEach(E=>Dt.add(E))}else $(m,v,"<p>","</p>"),u.push({line:O(m),rule:"loose words"}),o.forEach(k=>Dt.add(k))}}let Bs=t=>t[0].parentNode.childNodes.slice(0,t[0].parentNode.childNodes.indexOf(t[0])).every(e=>!e.tagName||C(e).includes(Et)),be=new Set,ke=t=>be.has(t.parentNode)?{}:(be.add(t.parentNode),{note:"a step's own words written as its title, the first block of its node: <li><p><strong>\u2026</strong></p> then its content (a paragraph, a list\u2026)</li>"}),Ms=t=>{if(wt(t.childNodes,Bs),t.childNodes.filter(c=>c.tagName&&!C(c).includes(Et)).length>0||Vt(t.childNodes).length>0||!i(t)||!f(t))return;let a=t.childNodes.filter(c=>c.tagName).at(-1)?.sourceCodeLocation?.endOffset??i(t).endOffset;l(a,a,"<p></p>"),u.push({line:O(a),rule:"step title",...ke(t)})},Ft,Le=()=>{Ft??=Xn(d);let t=dn(Ft);return Ft.add(t),t},Rs=(t,e)=>`<div data-doc-chart="${q(w(t,"data-doc-chart"))}" ${fs}="${q(e)}"></div>`,lt=n.includes(`\r
|
|
7
|
-
`)?`\r
|
|
8
|
-
`:`
|
|
9
|
-
`,ye=t=>/^[ \t]*/.exec(n.slice(n.lastIndexOf(`
|
|
10
|
-
`,t-1)+1))[0];function ve(t,e,o,a=null){let c=Ce(t),r=c?gt(n,c.sourceCodeLocation.startOffset,c.sourceCodeLocation.endOffset):null,m=!!r&&(r.start!==c.sourceCodeLocation.startOffset||r.end!==c.sourceCodeLocation.endOffset),v=c?{from:i(c).endOffset,to:f(c).startOffset}:null,k=A=>`<figure class="doc-figure">${A?`<h3>${A}</h3>`:""}${Rs(t,o)}</figure>`,E=A=>v?A:A(""),I=m?`${lt}${ye(i(e).startOffset)}`:"",x=!!(a??f(e));if(x){let A=a?f(t).endOffset:f(e).endOffset;l(A,A,E(G=>`${a??""}${I}${k(G)}`),{closes:i(e).startOffset,move:v}),u.push({line:O(A),rule:"chart",key:o})}else l(i(e).startOffset,i(e).startOffset,E(A=>`${k(A)}${I}`),{opens:i(e).endOffset,move:v}),u.push({line:O(i(e).startOffset),rule:"chart",key:o});return r&&l(r.start,r.end,""),x&&!!a}let[Ds]=ts,Ce=t=>{let e=t.childNodes.find(o=>!J(o));return e?.tagName!=="caption"||!H(e)||Z(e).length>0||!et(e)||!e.childNodes.every(o=>D(o)||o.tagName&&!hs.has(o.tagName)&&!gs.has(o.tagName)&&!Yt(o))||e.childNodes.every(D)&&Nt(n.slice(i(e).endOffset,f(e).startOffset))||F({tags:["caption"]})?null:e},Fs=t=>{let e=w(t,"rowspan");return e===void 0||/^\s*\d+\s*$/.test(e)&&Number(e)===1};function Gs(t){let e=L(t).filter(m=>["thead","tbody","tfoot"].includes(m.tagName)),o=e.flatMap(m=>L(m)).flatMap(m=>L(m)).filter(m=>m.tagName==="th"&&i(m)),a=!F({tags:["th","thead"]});if(a)for(let m of o)g(m,se.some(v=>C(m).includes(v))?[Ds]:ts);let c=a||!o.length?[]:["its th as written (no header look, no thead): the document's own <style> styles th"],r=m=>m.length>0&&m.every(v=>v.tagName==="tr"&&H(v));for(let m of e){let v=L(m);if(m.tagName!=="tbody"||!r(v))continue;let[k,...E]=v,I=a&&e.length===1&&E.length>0&&L(k).length>0&&L(k).every(G=>G.tagName==="th"&&Fs(G)),x=i(m);if(x){if(!I||!f(m))continue;l(x.startOffset,x.endOffset,"<thead>"),l(k.sourceCodeLocation.endOffset,k.sourceCodeLocation.endOffset,`</thead>${n.slice(x.startOffset,x.endOffset)}`),h(k,"header row");continue}I&&($(k.sourceCodeLocation.startOffset,k.sourceCodeLocation.endOffset,"<thead>","</thead>"),h(k,"header row"));let A=I?E:v;$(A[0].sourceCodeLocation.startOffset,A.at(-1).sourceCodeLocation.endOffset,"<tbody>","</tbody>")}return c}let Gt,Ks=()=>{Gt??=(function e(o,a=new Set){for(let c of o.childNodes??[])c.tagName&&(w(c,"data-doc-sheets")!==void 0&&a.add(w(c,"data-doc-sheets")),e(c.tagName==="template"?c.content:c,a));return a})(d);let t=1;for(;Gt.has(`tabs-${t}`);)t++;return Gt.add(`tabs-${t}`),`tabs-${t}`},Se=new Set,Ws=t=>{let e=[],o=c=>c.childNodes.map(r=>D(r)?r.sourceCodeLocation?n.slice(r.sourceCodeLocation.startOffset,r.sourceCodeLocation.endOffset):r.value:r.tagName?(i(r)&&e.push(z(n.slice(i(r).startOffset,i(r).endOffset))),r.tagName==="br"?" ":o(r)):"").join(""),a=c=>c.childNodes.map(r=>D(r)?r.value:r.tagName==="br"?" ":r.tagName?a(r):"").join("");return{raw:z(o(t)),plain:z(a(t)),left:[...new Set(e)]}},Hs=(t,e,o)=>{let a=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").slice(0,48).replace(/-+$/,"")||`tab-${e+1}`,c=a;for(let r=2;o.has(c);r++)c=`${a}-${r}`;return o.add(c),c};function Ps(t,e){let o=cn(n),a=Qe[o]??Qe.zh,c=w(t,"data-doc-sheets")?.trim()?null:Ks(),r=new Set,m=[],v=e.map(({section:E,heading:I},x)=>{let{raw:A,plain:G,left:Y}=Ws(I),st=Hs(G,x,r);Z(I).length&&m.push(`${Z(I).join(", ")} of the heading "${G}" left out: a tab is its name alone`);for(let nt of Y)m.push(`${nt} in the heading "${G}" left out: a tab's name is plain text`);W(E,`<div data-doc-sheet="${st}">`,"</div>"),Se.add(I);let{startOffset:V,endOffset:X}=I.sourceCodeLocation,U=gt(n,V,X);return l(U.start,U.end,lt.repeat(n.slice(U.start,U.end).split(`
|
|
11
|
-
`).length-1)),Pe({sheet:st,title:A})}),k=M(t,t.tagName,{classes:["doc-sheet-shell"],drop:c?["data-doc-sheets"]:[]});c&&(k=k.replace(/>$/,` data-doc-sheets="${c}">`)),w(t,"aria-label")===void 0&&(k=k.replace(/>$/,` aria-label="${a}">`)),l(i(t).startOffset,i(t).endOffset,`${k}<div class="doc-sheet-tabs" aria-label="${a}">${v.join("")}</div>`),h(t,"sheets",m)}let Us=t=>{let e=L(t)[0];return L(t).length===1&&e.tagName==="a"&&C(e).join(" ")==="doc-bookmark"&&K(e,["class","href","title","target","rel"])&&!!w(e,"href")?.trim()&&H(e)&&e.childNodes.every(D)&&t.childNodes.every(o=>o===e||J(o))};function zs(t){let e=L(t)[0],o=w(e,"href").trim(),a=z(w(e,"title")??""),c=o;try{c=new URL(o).hostname||o}catch{}let r=[],m=w(e,"target");m!==void 0&&m.trim()!=="_blank"&&r.push(`target ${JSON.stringify(z(m))} left out: a bookmark opens its page in a new tab`);let v=w(e,"rel");v!==void 0&&v.split(/\s+/).some(I=>I&&!["noopener","noreferrer"].includes(I.toLowerCase()))&&r.push(`rel ${JSON.stringify(z(v))} left out: a bookmark's link is rel="noopener noreferrer"`),l(i(t).startOffset,i(t).endOffset,M(t,"figure",{classes:["doc-bookmark"]}));let k=et(e)?"":pt(c);l(i(e).startOffset,i(e).endOffset,`<a class="doc-bookmark-card" href="${q(o)}" target="_blank" rel="noopener noreferrer"><span class="doc-bookmark-text"><span class="doc-bookmark-title">${k}`);let E=a?`<span class="doc-bookmark-description">${pt(a)}</span>`:"";l(f(e).startOffset,f(e).endOffset,`</span>${E}<span class="doc-bookmark-url"><span class="doc-bookmark-href">${pt(o)}</span></span></span></a>`),l(f(t).startOffset,f(t).endOffset,"<figcaption></figcaption></figure>"),h(t,"bookmark",r)}let qs=t=>{let e=t?.parentNode;if(!t?.tagName||!C(t).includes("doc-column")||!e?.tagName||!C(e).includes("doc-columns"))return null;let o=r=>Number(/--doc-column-ratio\s*:\s*(\d*\.?\d+)/i.exec(w(r,"style")??"")?.[1]??1)||1,a=L(e).filter(r=>C(r).includes("doc-column")),c=a.reduce((r,m)=>r+o(m),0);return(St-fn*(a.length-1))/St*(o(t)/c)},Kt=(t,e,o)=>{let a=w(t,"width"),c=/^\s*(\d+(?:\.\d+)?)\s*(px|%)?\s*$/i.exec(a??""),r=(e?w(e,"style")??"":"").trim().replace(/;\s*$/,""),m=t.sourceCodeLocation.attrs?.width;if(!c||!m||/--doc-span\s*:/i.test(r))return null;let v=c[2]==="%",k=v?qs(o):null,E=v?Number(c[1])/100*(k??1):Number(c[1])/St,I=Math.round(Math.min(dt.max,Math.max(dt.min,E))*1e3)/1e3,x=m.startOffset;for(;/[ \t\n\r\f]/.test(n[x-1]??"");)x--;l(x,m.endOffset,"");let A=E<dt.min||E>dt.max?`, within ${dt.min} to ${dt.max}`:"",G=v?k===null?"a share of the width it stands in":`a share of the width it stands in, its column ${Math.round(k*1e3)/1e3} of the reading width`:`${Number(c[1])}px of the ${St}px reading width`;return{attribute:` style="${q(`${r?`${r}; `:""}${Ye}: ${I}`)}"`,note:`width="${a}" written as ${Ye}: ${I} on its figure (${G}${A}; at most the width it stands in)`}},Wt=(t,e)=>{let o=t?M(t,"figure",{classes:["doc-image"],drop:e?.attribute?["style"]:[]}):'<figure class="doc-image">';return e?.attribute?`${o.slice(0,-1)}${e.attribute}>`:o},Js=t=>L(t).filter(e=>e.tagName==="img").length===1&&L(t).every(e=>e.tagName==="img"||e.tagName==="figcaption")&&t.childNodes.every(e=>e.tagName||J(e)),Vs=t=>L(t).length===1&&L(t)[0].tagName==="img"&&t.childNodes.every(e=>e.tagName||J(e)),Xs=t=>t.childNodes.length>0&&t.childNodes.every(D)&&Nt(n.slice(i(t).endOffset,f(t).startOffset)),xe=new Set,Te=()=>F(Dn)||rt(Fn),Ee=t=>Rn(t)&&!Te();function Ie(t,e=null,o=null,a=[]){let c=qn(t),r=[t,c].filter(Boolean),m=[e,...r].filter(Boolean),v=r.flatMap(C).map(b=>ns.exec(b)?.[1]).find(Boolean)??m.map(b=>w(b,"data-language")??w(b,"data-lang")).find(Boolean),k=b=>m.find(T=>T.sourceCodeLocation.attrs?.[b]),E=(b,T)=>{let B=b?.sourceCodeLocation.attrs[T];return B?` ${n.slice(B.startOffset,B.endOffset)}`:""},I=k("id"),x=[...a],A=new Map(m.map(b=>[b,new Set])),G=b=>b.flatMap(T=>m.filter(B=>w(B,T)!==void 0).map(B=>(A.get(B).add(T),{element:B,name:T,value:w(B,T)}))),Y=(b,T)=>x.push(`${b.name} ${JSON.stringify(z(b.value))} left out (its <${b.element.tagName}>'s): ${T}`),st=zn.flatMap(({name:b,names:T,value:B,says:P})=>{let ot=G(T),R=ot.find(j=>B(j.value)!==null);for(let j of ot)j!==R&&Y(j,B(j.value)===null?P:`the block takes its <${R.element.tagName}>'s ${R.name}`);return R?[` ${b}="${q(B(R.value))}"`]:[]}),V=G([as]),X=V.find(b=>/^\s*(?:true|false)\s*$/i.test(b.value));for(let b of V)b!==X&&Y(b,X?`the block takes its <${X.element.tagName}>'s ${as}`:"false keeps its long lines on one line (they scroll), true wraps them");let U=X?X.value.trim().toLowerCase()==="false":r.some(b=>C(b).includes(Jt)),nt=r.flatMap(C).find(b=>vn.includes(b)),je=G([os]),Lt=o?null:je[0],Be=Lt?pt(z(Lt.value)):"";for(let b of je)b!==Lt&&Y(b,o?"its caption is its title":`the block takes its <${Lt.element.tagName}>'s ${os}`);let Me=b=>Object.keys(b.sourceCodeLocation.attrs??{}).filter(T=>T!=="class"&&!Un.has(T)&&!(T==="id"&&b===I)&&!A.get(b).has(T)),Re=b=>{let T=C(b).filter(j=>!ns.test(j)&&j!==Jt&&j!==nt),B=Me(b),ot=(b.attrs.find(j=>j.name==="style")?.value??"").split(";").map(j=>j.trim()).filter(Boolean).every(j=>/^--doc-code-height\s*:/i.test(j)),R=[...T.length?[`class ${JSON.stringify(T.join(" "))}`]:[],...B.filter(j=>!(j==="style"&&ot))];return R.length&&x.push(`${R.join(", ")} kept on its <${b.tagName}>`),`<${b.tagName}${T.length?` class="${q(T.join(" "))}"`:""}${B.map(j=>E(b,j)).join("")}>`},Ht=e?Me(e):[],De=`<div class="doc-code${U?` ${Jt}`:""}${nt?` ${nt}`:""}"${E(I,"id")}${E(k("data-block-id"),"data-block-id")}${v?` data-language="${q(v.toLowerCase())}"`:""}${st.join("")}${Ht.map(b=>E(e,b)).join("")}>`;Ht.length&&x.push(`${Ht.join(", ")} kept on the block (its <figure>'s)`);let Fe=Re(t),yt=b=>c?`${b}${Fe}`:`${b}${Fe}<code>`,vt=c&&H(c)?"</pre>":"</code></pre>",Ct=b=>`<div class="doc-code-title">${b}</div>`;if(!e)W(t,yt(`${De}${Ct(Be)}`),`${vt}</div>`);else if(W(e,De,"</div>"),!o)W(t,yt(Ct(Be)),vt);else{let{startOffset:b,endOffset:T}=o.sourceCodeLocation,B={from:i(o).endOffset,to:f(o).startOffset},P=R=>R.replace(/[ \t\n\r\f]+/g," ").trim(),ot=(R,j)=>n.slice(R,j).split(`
|
|
12
|
-
`).length-1;if(b<t.sourceCodeLocation.startOffset)l(b,T,R=>`${Ct(P(R))}${lt.repeat(ot(b,T))}`,{move:B}),W(t,yt(""),vt);else{let R=gt(n,b,T),j=ot(R.start,R.end),Zs=j?`${lt.repeat(j)}${ye(i(t).startOffset)}`:"";l(i(t).startOffset,i(t).endOffset,Qs=>yt(`${Ct(P(Qs))}${Zs}`),{move:B}),l(R.start,R.end,""),f(t)&&l(f(t).startOffset,f(t).endOffset,vt)}}if(c&&Z(c).length&&l(i(c).startOffset,i(c).endOffset,Re(c)),o){let b=new Set,T=B=>{for(let P of L(B))(!Vn.has(P.tagName)||Z(P).length)&&b.add(z(n.slice(i(P).startOffset,i(P).endOffset))),Qt.has(P.tagName)?l(i(P).startOffset,i(P).endOffset,P.tagName==="br"?" ":""):(Bt(P),T(P))};T(o);for(let B of b)x.push(`${B} in its caption left out: a code block's title is plain text`)}h(e??t,"code",x)}function Ae(t,e){let o=t.tagName;if(!H(t))return!1;if((o==="p"||o==="div"&&C(t).length===0)&&Xs(t))return W(t,M(t,"div",{classes:["doc-math-block"]}),"</div>"),h(t,"display formula"),!0;if(o==="figure"&&C(t).length===0&&Js(t)){let r=Kt(L(t).find(m=>m.tagName==="img"),t,e);return l(i(t).startOffset,i(t).endOffset,Wt(t,r)),L(t).some(m=>m.tagName==="figcaption")||l(f(t).startOffset,f(t).startOffset,"<figcaption></figcaption>"),h(t,"figure",r?[r.note]:[]),!0}if(o==="img"&&xt.has(e?.tagName)){let r=Kt(t,null,e);return $(i(t).startOffset,i(t).endOffset,Wt(null,r),"<figcaption></figcaption></figure>"),h(t,"picture",r?[r.note]:[]),!0}if(o==="p"&&xt.has(e?.tagName)&&Us(t))return zs(t),!0;if(w(t,"data-doc-sheets")!==void 0){let r=rn(t)?.tabs;return r&&Ps(t,r),!1}if(o==="p"&&Vs(t)){let r=Kt(L(t)[0],t,e);return W(t,Wt(t,r),"<figcaption></figcaption></figure>"),h(t,"picture",r?[r.note]:[]),!0}let a=o==="figure"&&C(t).length===0?is(t):null;if(a&&!a.why&&H(a.pre))return Ie(a.pre,t,a.caption),!0;if(o==="pre"&&!C(e??{}).includes("doc-code")){let m=e?.tagName==="figure"&&C(e).length===0&&L(e).some(k=>k.tagName==="figcaption")?is(e):null,v=m?.pre===t?m.why:"";return Ie(t,null,null,v?[`its <figure>'s caption stays a caption beside it: ${v}; a <figure> holding the pre and one <figcaption> of words alone makes them its title`]:[]),!0}if(o==="figure")return!xt.has(e?.tagName)||Sn(t)?!0:(g(t,["doc-figure"]),h(t,"figure"),ct(t));let c=o==="table"&&C(e??{}).includes("doc-table-wrap");if(o==="table"&&w(t,"data-doc-chart")!==void 0&&!xt.has((c?e.parentNode:e)?.tagName))return!1;if(o==="table"&&w(t,"data-doc-chart")!==void 0&&c&&i(e)){let r=w(e,tt)??Le();if(ve(t,e,r),w(e,tt)===void 0){let m=i(e).endOffset-1;l(m,m,` ${tt}="${q(r)}"`)}return l(i(t).startOffset,i(t).endOffset,M(t,"table",{drop:["data-doc-chart"]})),!1}if(o==="table"&&(!ct(t)||ds(t))&&!C(e??{}).includes("doc-table-wrap")){let r=t.sourceCodeLocation.attrs?.["data-block-id"],m=w(t,"data-doc-chart")!==void 0,k=(w(t,tt)?.trim()||null)??(m?Le():null),E=w(t,"style"),I=E===void 0?[]:ee(E).filter(U=>ss.test(U)),x=I.length?ee(E).filter(U=>!ss.test(U)):[],A=U=>` style="${q(U.map(nt=>nt.trim()).join("; "))}"`,G=`<div class="doc-table-wrap"${r?` ${n.slice(r.startOffset,r.endOffset)}`:""}${k?` ${tt}="${q(k)}"`:""}${I.length?A(I):""}>`,Y=M(t,"table",{classes:["doc-table"],drop:["data-block-id",...w(t,tt)!==void 0?[tt]:[],...m?["data-doc-chart"]:[],...I.length?["style"]:[]]}),st=x.length?`${Y.slice(0,-1)}${A(x)}>`:Y,V=m?null:Ce(t),X=!1;if(m&&(X=ve(t,t,k,"</div>")),V){let U=n.slice(i(t).endOffset,V.sourceCodeLocation.startOffset);l(i(t).startOffset,i(V).endOffset,'<p class="doc-note">'),l(f(V).startOffset,f(V).endOffset,`</p>${U}${G}${st}`),h(V,"caption")}else l(i(t).startOffset,i(t).startOffset,G,{opens:f(t).endOffset}),l(i(t).startOffset,i(t).endOffset,st);return X||l(f(t).endOffset,f(t).endOffset,"</div>",{closes:i(t).startOffset}),h(t,"table",Gs(t)),!1}if(o==="details"&&es(t)){let r=L(t)[0]?.tagName==="summary"?L(t)[0]:null;return!r||!H(r)||(l(i(t).startOffset,i(t).endOffset,M(t,"details",{classes:["doc-details"]})),L(r).some(m=>C(m).includes("doc-details-summary-label"))||$(i(r).endOffset,f(r).startOffset,'<span class="doc-details-summary-label">',"</span>"),$(f(r).endOffset,f(t).startOffset,'<div class="doc-details-content">',"</div>"),wt(t.childNodes.slice(t.childNodes.indexOf(r)+1)),h(t,"details")),!1}if(o==="dialog"&&ue(t)){let r=xs(t);return l(i(t).startOffset,i(t).endOffset,M(t,"dialog",{classes:["doc-dialog"]})),$(i(t).endOffset,f(t).startOffset,'<div class="doc-dialog-panel"><div class="doc-dialog-content">',"</div></div>"),r&&W(r,"<h3>","</h3>"),wt(t.childNodes.slice(r?t.childNodes.indexOf(r)+1:0)),h(t,"dialog"),!1}if(o==="aside"&&es(t)&&!F({tags:["aside"]}))return g(t,["doc-panel"]),xe.add(t),h(t,"aside"),!1;if(o==="ul"&&Ee(t)){g(t,[Zt],{drop:ce});for(let r of L(t))_e(r);return h(t,"task list"),!1}if(te(t)&&!ct(t))return l(i(t).startOffset,i(t).endOffset,M(t,"ol",{classes:[ut],drop:["data-doc-chart","data-flow"]})),h(t,"flowchart"),!1;if(o==="ul"&&C(t).includes(Zt)&&!ct(t)){let r=L(t).filter(ws);if(r.length&&!Te()){for(let m of r)_e(m);h(t,"task list")}return!1}return!1}function _e(t){let e=$s(t);if(g(t,[],{drop:re}),w(e,"checked")!==void 0){let c=i(t).startOffset+1+t.tagName.length;l(c,c,` ${ne}`)}let{startOffset:o,endOffset:a}=e.sourceCodeLocation;l(o,a+(n[a]===" "?1:0),"")}function bt(t,e=null,o=!1){An(t)&&(Ns(t)||xe.has(t)&&Vt(t.childNodes).length>0)?wt(t.childNodes):Kn(t)&&i(t)&&Ms(t);for(let a of t.childNodes??[]){if(D(a)){a.sourceCodeLocation&&a.value.includes("\\(")&&!we.has(a)&&_s(a);continue}if(!(!a.tagName||oe.has(a.tagName)||Se.has(a)||it(a))&&!(w(a,"data-doc-chart")!==void 0&&a.tagName!=="table"&&!te(a)||w(a,"contenteditable")!==void 0)&&!C(a).some(c=>It.includes(c))){if(a.tagName==="pre"){Ae(a,t);continue}if(!(ie(a)&&!Ee(a))){if(Dt.has(a)){Oe(a)||bt(a,a,!0);continue}Ae(a,t)||o&&Oe(a)||(bt(a,a,o||ae.has(a.tagName)),js(a,t))}}}}bt(p,p),bt({childNodes:Mt}),n.includes(ft.header)&&Ne(d);for(let t of Mt){let{startOffset:e,endOffset:o}=t.sourceCodeLocation,a=gt(n,e,o),c=f(p).startOffset,r=a.end>o?He(n,c):null;l(c,c,m=>r===null?m:`${m}${lt}${r}`,{move:{from:e,to:o}}),l(a.start,a.end,"",{leaves:!0}),h(t,"card outside main")}if(!N.length)return{text:n,changes:[]};let kt=N;for(let t of N.filter(e=>e.move)){let{from:e,to:o}=t.move,a=kt.filter(c=>!c.move&&!c.leaves&&c.start>=e&&c.end<=o);kt=kt.filter(c=>!a.includes(c)),t.text=t.text(cs(n.slice(e,o),a,e)),t.move=null}return{text:cs(n,kt),changes:u.sort((t,e)=>t.line-e.line)}}function cs(s,n,d=0){let p=h=>h.closes!==null?0:h.opens!==null?2:1,N=(h,y)=>p(h)-p(y)||(h.closes!==null?y.closes-h.closes||y.order-h.order:0)||(h.opens!==null?y.opens-h.opens:0)||h.order-y.order,u=[...n].sort((h,y)=>y.start-h.start||y.end-h.end||(h.start===h.end?N(y,h):y.order-h.order)),O=s;for(let{start:h,end:y,text:l}of u)O=O.slice(0,h-d)+l+O.slice(y-d);return O}function Ls(s,{finish:n=d=>d}={}){let{text:d,changes:p}=Yn(s);return{text:p.length?n(d):d,changes:p}}function jo(s,{finish:n,next:d,metadata:p=null}={}){let N=qt(s);if(N.length)return{text:s,changes:[],added:0,given:[],repeated:N,title:null,icon:null};let u=Ls(s,{finish:n}),{text:O,added:h,given:y}=qe(u.text,d),l=to(O,p);return{...l,changes:u.changes,added:h,given:Ve(l.text,y),repeated:N}}function Bo(s){return qt(s).length?[]:Je(Ls(s).text)}function to(s,n=null){let d=ht(s,{sourceCodeLocationInfo:!0}),p=jt(d),N=p&&Ot(p,l=>$t(l,mn.title)),u=N?.sourceCodeLocation?.endTag?Pt(s.slice(N.sourceCodeLocation.startTag.endOffset,N.sourceCodeLocation.endTag.startOffset)):"",O=s,h=null;if(u){let l=Ot(d,S=>S.tagName==="head"),i=(l&&Ot(l,S=>S.tagName==="title"))?.sourceCodeLocation,f=typeof n?.title=="string"?n.title:null,g=!1;if(i?.startTag&&i.endTag){let S=Pt(s.slice(i.startTag.endOffset,i.endTag.startOffset));if(!(f&&f!==u&&f.includes(u)?S.split(f).join("\0").includes(u):S.includes(u))){let _=f&&f!==u&&We(s,{from:f,to:u})||{start:i.startTag.endOffset,end:i.endTag.startOffset,text:pt(u)};O=s.slice(0,_.start)+_.text+s.slice(_.end),g=!0}}(g||f!==null&&f!==u)&&(h={from:f,to:u,page:g})}let y=null;if(p&&n&&typeof n=="object"){let l=ze(s),$=l.units.find(g=>g.kind==="icon"&&l.boxes[g.box]?.kind==="header"),i=$?ln(s.slice($.start,$.end)):null,f=n.icon??null;$?i!==null&&i!==f&&(y={from:f,to:i}):y=f===null?null:{from:f,to:f,missing:!0}}return{text:O,title:h,icon:y}}function Mo(s,n,{dryRun:d=!1,pending:p=!1,reread:N=!d&&!p}={}){let u=new Map;for(let{rule:y,line:l}of n)u.set(y,[...new Set([...u.get(y)??[],l])]);let O=[...u].map(([y,l])=>`${y} (line${l.length>1?"s":""} ${l.join(", ")})`).join(", "),h=tn.resolve(s);return[p?`natural ${h}: ${O} not rewritten yet: the export rewrites them in this file as the kit's markup (nothing to fix)`:`natural ${h}: ${O}${d?" would be":""} rewritten in this file as the kit's markup (nothing to fix)`,...n.filter(y=>y.note).map(({line:y,rule:l,note:$})=>` line ${y}, ${l}: ${$}`),...N?[" re-read the file before editing it"]:[]]}var rs="strong, em, b, i, u, s, code, a, sub, sup and br, the kit's colors (doc-text-*, doc-highlight-*) and formulas",fe=`write a to-do list as ul.${Zt} \u203A li, li[${ne}] for a checked item (a GFM task list, every item starting with its box, is made one unless the document's own style or script uses GFM's classes or the boxes)`,ys=s=>C(s).every(ls),vs=s=>L(s).flatMap(n=>[...n.tagName==="span"&&!(K(n,["class"])&&ys(n))?[n]:[],...vs(n)]),Cs=s=>L(s).some(n=>n.tagName==="img"||Cs(n)),Ss=s=>L(s).some(n=>n.tagName==="svg"||n.tagName==="canvas"||Ss(n)),_t=s=>L(s).some(n=>n.tagName==="input"&&w(n,"type")?.toLowerCase()==="checkbox"||_t(n)),eo=(s,n)=>{if(s==="tag:img")return"a picture amid the words: give it a paragraph of its own";if(s==="tag:span"){let d=vs(n).filter(p=>K(p,["style","class"])&&w(p,"style")!==void 0&&ys(p)).map(p=>bs(w(p,"style")).foreign).find(Boolean);return d?`a span with a style the kit has no format for (${d.join(", ")}): left as written`:`a <span> with a class or attribute of the document's own (the preview edits ${rs})`}return s==="tag:input"&&_t(n)?`a checkbox amid the words: ${fe}`:s.startsWith("tag:")&&at.has(s.slice(4))?`a block (<${s.slice(4)}>) amid the words: give the words a paragraph of their own`:s.startsWith("tag:")?`<${s.slice(4)}> amid the words (the preview edits ${rs})`:s==="comment"?"an HTML comment amid the words":s==="markup"?"an element not closed in the file (the parser closed it)":s==="mention"?'a page block written another way: the preview edits only <a class="doc-link-mention" href="../<slug>/doc.html"><span class="doc-link-mention-icon"></span>title</a>, its title plain words, no other attribute':s==="link"?"a javascript: or data: link":s},so=new Set([...ps,"details"]);function Ro(s){let n=ht(s,{sourceCodeLocationInfo:!0}),d=jt(n);if(!d)return[];let p=$=>s.slice(0,$).split(`
|
|
13
|
-
`).length,N=new Map,u=[],O=$=>{so.has($.tagName)&&$.sourceCodeLocation?.startTag&&Ns($)&&u.push({line:p($.sourceCodeLocation.startOffset),text:`<${$.tagName}>: words straight in it, outside any paragraph: give them a <p> (the preview cannot reach them, nor move its blocks one by one)`})},h=$=>{for(let i of L($)){let f=i.sourceCodeLocation?.startTag;f&&N.set(f.endOffset-1,i),h(i)}},y=$=>{for(let i of $.childNodes??[]){if(!i.tagName||oe.has(i.tagName))continue;if(it(i)){h(i);continue}if(w(i,"data-doc-chart")!==void 0||C(i).some(S=>It.includes(S))||ie(i))continue;let f=i.sourceCodeLocation?.startTag;f&&N.set(f.endOffset-1,i);let g=i.sourceCodeLocation?.endTag;if(ae.has(i.tagName)&&f&&i.childNodes.some(S=>D(S)&&/\\\[|\$\$/.test(S.value))&&!(g&&i.childNodes.every(D)&&Nt(s.slice(f.endOffset,g.startOffset)))){let S=Tn(s.slice(f.endOffset,g?g.startOffset:i.sourceCodeLocation.endOffset),!!g);u.push({line:p(f.startOffset),text:S?`<${i.tagName}>: the formula holds a bare < or >: write \\lt / \\gt (or < / >)`:`<${i.tagName}>: a display formula (\\[\u2026\\] or $$\u2026$$) amid the words: give it a paragraph of its own`})}i.tagName==="caption"&&f&&(et(i)||L(i).length>0)&&u.push({line:p(f.startOffset),text:'<caption>: the preview cannot edit a table caption; write the line above the table as <p class="doc-note">'}),O(i),y(i)}};O(d),y(d);let l=new Set;for(let{at:$,reason:i}of zt(s).locks){let f=N.get($);if(!f)continue;let g=i==="tag:input"&&f.tagName==="li"&&_t(f)&&f.parentNode?.sourceCodeLocation?.startTag?f.parentNode:null;g&&l.has(g)||(g&&l.add(g),g?u.push({line:p(g.sourceCodeLocation.startOffset),text:`<${g.tagName}>: checkboxes in its items: ${fe}`}):u.push({line:p(f.sourceCodeLocation.startOffset),text:`<${f.tagName}>: ${eo(i,f)}`}))}return u.sort(($,i)=>$.line-i.line).map(({line:$,text:i})=>`line ${$}: ${i}`)}function Do(s){let n=ht(s,{sourceCodeLocationInfo:!0}),d=jt(n);if(!d)return[];let p=f=>s.slice(0,f).split(`
|
|
14
|
-
`).length,N=[],u=[],O=f=>{for(let g of f.childNodes??[])g.tagName==="style"?u.push((g.childNodes??[]).map(S=>S.value??"").join("")):O(g)};O(n);let h=u.join(`
|
|
15
|
-
`).replace(/\/\*[\s\S]*?\*\//g,""),y=f=>new RegExp(`\\.${f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w-])`).test(h),l=f=>{for(let g of L(f).filter(S=>S.tagName==="colgroup"&&w(S,"data-doc-columns")===void 0)){let S=[g,...L(g)].filter(_=>w(_,"width")!==void 0||/(?:^|;)\s*(?:min-|max-)?width\s*:/i.test(w(_,"style")??"")),M=(g.sourceCodeLocation?g:L(g)[0])?.sourceCodeLocation;S.length&&M&&N.push({line:p(M.startOffset),text:`<${g.sourceCodeLocation?"colgroup":"col"}> widths: the kit sizes columns itself; a merged table uses yours`})}},$=f=>{for(let g of f.childNodes??[]){if(!g.tagName||oe.has(g.tagName)||it(g)||w(g,"data-doc-chart")!==void 0||C(g).some(_=>It.includes(_)))continue;if(ie(g)){let _=g.sourceCodeLocation,F=en(s,g).some(({name:Q})=>Q==="class");if(ms.has(g.tagName)&&_?.startTag&&!F&&(et(g)||Cs(g))&&!Ss(g)&&!C(g).some(y)){let Q=(g.tagName==="ul"||g.tagName==="ol")&&_t(g)?`; for its checkboxes, ${fe}`:"";N.push({line:p(_.startOffset),text:`<${g.tagName} class="${w(g,"class").trim()}"> is a whole block (\u6574\u4F53\u5757): the reader moves it whole and edits its words in place; right for a layout of yours that is no figure (a figure, a diagram or a timeline, goes in <figure class="doc-figure">); drop its class only if its contents were meant as ordinary blocks${Q}`})}continue}g.tagName==="table"&&l(g);let S=Ut(g)?L(g).filter(_=>at.has(_.tagName)):[];S.length>0&&g.sourceCodeLocation&&N.push({line:p(g.sourceCodeLocation.startOffset),text:`<${g.tagName} class="${w(g,"class").trim()}"> holds ${[...new Set(S.map(_=>`<${_.tagName}>`))].join(", ")}: it is one text block, its words straight in it (<br> starts a line) or in one plain <p>, and blocks set apart on a fill go in an <aside>`});let M=g.tagName==="ol"&&C(g).includes(ut)?L(g).find(_=>_.tagName!=="li"&&_.sourceCodeLocation):null;if(M&&N.push({line:p(M.sourceCodeLocation.startOffset),text:`<ol class="${ut}"> holds a <${M.tagName}> outside its items: a flowchart's steps are its <li>s (what one holds after its words, a paragraph or a list, is that step's content)`}),g.tagName==="ol"&&C(g).includes(ut))for(let _ of L(g).filter(F=>F.tagName==="li")){let F=L(_).find(rt=>!C(rt).includes(Et)),Q=F?_.childNodes.slice(0,_.childNodes.indexOf(F)):[];F&&F.tagName!=="p"&&F.sourceCodeLocation&&!Q.some(rt=>!C(rt).includes(Et)&&et(rt))&&N.push({line:p(F.sourceCodeLocation.startOffset),text:`a step of <ol class="${ut}"> begins with a <${F.tagName}>: a step's first block is its title, a paragraph (<p><strong>\u2026</strong></p>), the blocks after it its content`})}$(g)}};return $(d),i(d,(f,g)=>N.push({line:f,text:`a ${no[g]} in the text: the page shows it as a break or an empty line, not as a character (a tool that decodes \\u2028 or \\u2029 escapes writes one); write the break the text means (<br>, a new paragraph, a new line in code) or take it out`})),N.sort((f,g)=>f.line-g.line).map(({line:f,text:g})=>`line ${f}: ${g}`);function i(f,g){for(let S of f.childNodes??[])if(!(S.tagName==="script"||S.tagName==="style"||it(S))){if(D(S)&&S.sourceCodeLocation&&/[\u2028\u2029]/.test(S.value)){let{startOffset:M,endOffset:_}=S.sourceCodeLocation,Q=s.slice(M,_).search(/[\u2028\u2029]/);g(p(M+Math.max(Q,0)),S.value.match(/[\u2028\u2029]/)[0])}i(S,g)}}}function Fo(s){let n=O=>s.slice(0,O).split(`
|
|
16
|
-
`).length,d=O=>D(O)?O.value:(O.childNodes??[]).map(d).join(""),p=O=>d(O).replace(/\s+/g," ").trim(),N=O=>L(O).find(h=>/^h[1-6]$/.test(h.tagName)),u=[];for(let O of zt(s).units){if(O.keep?.reason!=="script"||!O.keep.own)continue;let h=O.node.parentNode;for(;h&&h.tagName!=="section";)h=h.parentNode;let y=O.tag==="section"&&N(O.node)?` ${p(N(O.node))}`:"",l=h?.tagName&&N(h)?` in ${p(N(h))}`:"";u.push({line:n(O.elStart),text:`<${O.tag}>${y}${l} kept by the script: ${O.keep.names.join(", ")} (the reader cannot delete or convert it; rename any of these the script does not select it by)`})}return u.sort((O,h)=>O.line-h.line).map(({line:O,text:h})=>`line ${O}: ${h}`)}var no={"\u2028":"line separator (U+2028)","\u2029":"paragraph separator (U+2029)"};function jt(s){return Ot(s,n=>n.tagName==="main")}function Ot(s,n){if(s.tagName&&n(s))return s;for(let d of s.childNodes??[]){let p=Ot(d,n);if(p)return p}return null}export{Yn as a,Ls as b,jo as c,Bo as d,to as e,Mo as f,Ro as g,Do as h,Fo as i};
|
package/dist/chunk-5LEK2CBS.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}from"./chunk-GYQV7Y4J.mjs";import"./chunk-7GHT2UCA.mjs";import"./chunk-UNUEWH4S.mjs";import"./chunk-G7TOXONE.mjs";import"./chunk-LC7YNQFG.mjs";import"./chunk-6U2SLSDN.mjs";import"./chunk-W7CXPCRV.mjs";import"./chunk-LAE5NQ4B.mjs";import"./chunk-P2CAZPDP.mjs";import"./chunk-ITNLYXXV.mjs";import"./chunk-QMQUXTU4.mjs";import"./chunk-HQQMJCQJ.mjs";import"./chunk-QYKCJ7FG.mjs";import"./chunk-YZ5Z6H4W.mjs";import"./chunk-VACRB2NE.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-TDQP3DKQ.mjs";import"./chunk-5FRMCDPY.mjs";import"./chunk-E7VYDG2X.mjs";import"./chunk-NFIBI4IP.mjs";import"./chunk-W63L7367.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as startProductionServer};
|
package/dist/chunk-5OFN5AHC.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 as k}from"./chunk-V4CPWKMZ.mjs";import{b as B,c as I}from"./chunk-342HXE3Q.mjs";import{a as y,b,c as v,d as l,e as x,f as S,g as $}from"./chunk-XINNG4F2.mjs";import"./chunk-7GHT2UCA.mjs";import"./chunk-G7TOXONE.mjs";import{k as h}from"./chunk-6U2SLSDN.mjs";import"./chunk-P2CAZPDP.mjs";import"./chunk-ITNLYXXV.mjs";import{j as u}from"./chunk-NSKUTQ5J.mjs";import{j as c,p as m,s as d,t as w,u as g}from"./chunk-QMQUXTU4.mjs";import"./chunk-HQQMJCQJ.mjs";import"./chunk-QYKCJ7FG.mjs";import"./chunk-YZ5Z6H4W.mjs";import"./chunk-VACRB2NE.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-TDQP3DKQ.mjs";import"./chunk-5FRMCDPY.mjs";import"./chunk-E7VYDG2X.mjs";import"./chunk-NFIBI4IP.mjs";import"./chunk-W63L7367.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";async function C(L){let{slugs:o,options:M}=await u({options:["--allow-failures"],argv:L});o.length===0&&(console.error(k()),process.exit(1));let N=await h(o),s=await c(o,{prepare:l({say:!1})}),t=await y(o.filter(e=>!s.has(e)));await b(o.filter(e=>s.has(e)||t.failures.has(e))),await S(o),await $(o);let p=o.filter(e=>!s.has(e)&&!t.failures.has(e)),{built:a,exported:i,failures:n}=p.length>0?await m(p,{prepare:l({say:!1})}):{built:[],exported:[],failures:new Map};for(let[e,r]of[...s,...t.failures])n.set(e,r);await w(n,{exportNote:!0}),await N.keep(i.map(({slug:e})=>e));let R=new Map(a.map(({report:e,removed:r})=>[e.slug,r]));for(let{slug:e,bytes:r,sha256:D}of i){let f=R.get(e),j=f.length>0?`; shared scripts and styles left out (unused): ${f.join(", ")}`:"";console.log(`Exported ${B(e)} (${r.toLocaleString("en-US")} bytes, sha256 ${D})${j}`)}d(a.map(({report:e})=>e)),x(a.map(({report:e})=>e));for(let e of t.lines)console.log(e);t.written.length>0&&console.log(v(t.written));for(let{slug:e}of i)console.log(I(e));g(n,{above:!0,allow:M.has("--allow-failures")})}export{C as run};
|
package/dist/chunk-5SIYS5HN.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{b as l,g as a,h as c}from"./chunk-YXAUQPVK.mjs";import{b as s,f as t,i}from"./chunk-NSKUTQ5J.mjs";import"./chunk-5L7RYZCL.mjs";import{reportsDirectory as w}from"../browser/shared/paths.mjs";async function h(m){let{positional:o,options:p}=t({options:["--no-browser"],argv:m});if(o.length>1)throw new s("Name one document at most.");let{slug:e=null,block:u=null}=o.length?await i(o[0]):{};console.log(`\u5DE5\u4F5C\u533A\uFF1A${w}`);let n=await a({slug:e,baseline:e!==null});n.ok||(console.error(n.message),process.exit(1));let r=await c(e,n,u);for(let g of r)console.log(g);console.log(await l(r,p))}export{h as run};
|
package/dist/chunk-5TEK3RAD.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{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n,t as o,u as p,v as q}from"./chunk-QMQUXTU4.mjs";import"./chunk-HQQMJCQJ.mjs";import"./chunk-QYKCJ7FG.mjs";import"./chunk-YZ5Z6H4W.mjs";import"./chunk-VACRB2NE.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-E7VYDG2X.mjs";import"./chunk-W63L7367.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{h as buildReports,d as checkReports,f as checkSelectedReports,b as exportFailures,k as exportReports,p as failureSummary,e as handInBlockers,l as notesByKind,m as notesOf,j as offlineReports,o as printFailures,c as quickFailures,a as repeatedIdFailures,q as reportFailures,n as reportNotes,i as withExportPolicy,g as writeSharedAssets};
|
package/dist/chunk-7GHT2UCA.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{d as re,e as oe}from"./chunk-G7TOXONE.mjs";import{d as ne}from"./chunk-P2CAZPDP.mjs";import{a as zt}from"./chunk-ITNLYXXV.mjs";import{a as Kt,b as Qt,c as Vt,d as Xt,e as qt}from"./chunk-TDQP3DKQ.mjs";import{b as te,c as ee,f as bt}from"./chunk-5FRMCDPY.mjs";import{a as Zt}from"./chunk-E7VYDG2X.mjs";import{G as Gt,H as Ht,a as Z}from"./chunk-NFIBI4IP.mjs";import{d as Wt,q as Ct}from"./chunk-W63L7367.mjs";import{randomBytes as Je}from"node:crypto";import X from"node:fs/promises";import nt from"node:path";import{FILE as Le,readItems as _e}from"../browser/shared/annotations.mjs";import{writeAtomic as Ue}from"../browser/shared/files.mjs";import{documentDirectory as Be}from"../browser/shared/workspace.mjs";var Ye=20,ie=/^\d{8}T\d{6}Z-[a-f0-9]{8}\.json$/,se=80,ce=({stateDirectory:i,slug:s})=>nt.join(i,"dropped-annotations",s),le=i=>({id:i.id,text:i.text,quote:i.anchor?.quote??"",kind:i.anchor?.kind??"text"});async function fe({stateDirectory:i,reportsDirectory:s,slug:p,time:m,items:h}){let d=ce({stateDirectory:i,reportsDirectory:s,slug:p});await X.mkdir(d,{recursive:!0});let k=m.replace(/[-:]/g,"").replace(/\.\d+Z$/,"Z");await Ue(nt.join(d,`${k}-${Je(4).toString("hex")}.json`),JSON.stringify({time:m,items:h}));let l=(await X.readdir(d)).filter(w=>ie.test(w)).sort();await Promise.all(l.slice(0,Math.max(0,l.length-Ye)).map(w=>X.rm(nt.join(d,w),{force:!0})))}async function _n({stateDirectory:i,reportsDirectory:s,slug:p}){let m=ce({stateDirectory:i,reportsDirectory:s,slug:p}),h=(await X.readdir(m).catch(()=>[])).filter(l=>ie.test(l)).sort();if(h.length===0)return[];let d=new Set(_e(await X.readFile(nt.join(Be(p,s),Le),"utf8").catch(()=>"")).map(l=>l.id)),k=[];for(let l of h){let w=nt.join(m,l);try{let T=JSON.parse(await X.readFile(w,"utf8")),E=Array.isArray(T?.items)?T.items.filter(F=>typeof F?.id=="string"&&!d.has(F.id)):[];typeof T?.time=="string"&&E.length&&k.push({time:T.time,items:E})}catch{}await X.rm(w,{force:!0}).catch(()=>{})}return k}var Ze=(i,s=new Date)=>{let p=new Date(i),m=d=>String(d).padStart(2,"0"),h=`${m(p.getHours())}:${m(p.getMinutes())}`;return p.toDateString()===s.toDateString()?h:`${p.getFullYear()}-${m(p.getMonth()+1)}-${m(p.getDate())} ${h}`},ae=i=>{let s=String(i??"").replace(/\s+/g," ").trim();return JSON.stringify(s.length>se?`${s.slice(0,se-1)}\u2026`:s)};function At(i,{time:s=null,items:p},{today:m=new Date}={}){let h=nt.resolve(i),d=`${p.length} \u6279\u6CE8 (annotation${p.length===1?"":"s"})`;return[`annotations ${h}: ${s?`at ${Ze(s,m)}, `:""}Gallery deleted ${d} whose words are gone from the document (rewritten or deleted):`,...p.map(({id:k,text:l,quote:w,kind:T})=>` ${k} ${ae(l)} on ${T==="blocks"?"the blocks ":""}${ae(w)}`)]}function Un(i,s,{today:p=new Date}={}){return s.length?[...s.flatMap(m=>At(i,m,{today:p}))," they were the reader's: say in your hand-off which your edit carried out and which you left, and never write them back"]:[]}import{randomBytes as We}from"node:crypto";import rt from"node:fs/promises";import dt from"node:path";import{writeAtomic as Ce}from"../browser/shared/files.mjs";var Ge=20,de=/^\d{8}T\d{6}Z-[a-f0-9]{8}\.json$/,ue=({stateDirectory:i,slug:s})=>dt.join(i,"rewrites",s);async function me({stateDirectory:i,reportsDirectory:s,slug:p,time:m,changes:h}){let d=ue({stateDirectory:i,reportsDirectory:s,slug:p});await rt.mkdir(d,{recursive:!0});let k=m.replace(/[-:]/g,"").replace(/\.\d+Z$/,"Z");await Ce(dt.join(d,`${k}-${We(4).toString("hex")}.json`),JSON.stringify({time:m,changes:h}));let l=(await rt.readdir(d)).filter(w=>de.test(w)).sort();await Promise.all(l.slice(0,Math.max(0,l.length-Ge)).map(w=>rt.rm(dt.join(d,w),{force:!0})))}async function pe({stateDirectory:i,reportsDirectory:s,slug:p}){let m=ue({stateDirectory:i,reportsDirectory:s,slug:p}),h=(await rt.readdir(m).catch(()=>[])).filter(k=>de.test(k)).sort(),d=[];for(let k of h){let l=dt.join(m,k);try{let w=JSON.parse(await rt.readFile(l,"utf8"));typeof w?.time=="string"&&Array.isArray(w.changes)&&d.push(w)}catch{}await rt.rm(l,{force:!0}).catch(()=>{})}return d}var He=(i,s=new Date)=>{let p=new Date(i),m=d=>String(d).padStart(2,"0"),h=`${m(p.getHours())}:${m(p.getMinutes())}`;return p.toDateString()===s.toDateString()?h:`${p.getFullYear()}-${m(p.getMonth()+1)}-${m(p.getDate())} ${h}`};function Gn(i,s,{today:p=new Date}={}){if(!s.length)return[];let m=dt.resolve(i),h=[];for(let{time:d,changes:k}of s){let l=[];for(let{line:w,rule:T,key:E}of[...k].sort((F,R)=>F.line-R.line)){let F=`line ${w} ${T}${E?` ${E}`:""}`;l.includes(F)||l.push(F)}h.push(`preview ${m}: at ${He(d,p)}, when the reader edited the page, the preview wrote your natural HTML as the kit's markup: ${l.join(", ")}`),h.push(...k.filter(w=>w.note).map(({line:w,rule:T,note:E})=>` line ${w}, ${T}: ${E}`))}return h.push(" re-read the file before editing it (those lines are the file's as you had left it)"),h}import{createHmac as sn,randomBytes as $e}from"node:crypto";import{existsSync as an,mkdirSync as cn,readFileSync as ln,writeFileSync as fn}from"node:fs";import D from"node:fs/promises";import A from"node:path";import{FILE as dn}from"../browser/shared/annotations.mjs";import{escapeTyped as un}from"../browser/shared/escape.mjs";import{writeAtomic as wt}from"../browser/shared/files.mjs";import{sendJson as U}from"../browser/shared/http.mjs";import{REQUEST_ID as Nt}from"../browser/shared/ids.mjs";import{UPLOAD_REQUEST_LIMIT as mn}from"../browser/shared/media.mjs";import{reportsDirectory as pn}from"../browser/shared/paths.mjs";import{sameDirectory as hn}from"../browser/shared/preview-server.mjs";import{slugPattern as q}from"../browser/shared/reports.mjs";import{documentDirectory as wn,documentFiles as gt,isDocumentSource as gn}from"../browser/shared/workspace.mjs";import Et from"node:fs/promises";import he from"node:path";import{checkAnnotations as ze,cleanAnchor as Ke,cleanItem as we,FILE as Qe,itemsText as Ve,readItems as Xe,treeText as ge}from"../browser/shared/annotations.mjs";import{writeAtomic as qe}from"../browser/shared/files.mjs";import{slugPattern as tn}from"../browser/shared/reports.mjs";import{documentDirectory as ye,documentFiles as en}from"../browser/shared/workspace.mjs";var nn=600*1e3,rn=600*1e3;function on(i){let{units:s,boxes:p}=Ht(i),m=[...s].sort((l,w)=>l.elStart-w.elStart),h=new Map(m.map((l,w)=>[l.id,w])),d=new Map(m.map(l=>[l.id,ge(l.node)])),k={h2:null,h3:null,h4:null};return m.map(l=>{let w=[];for(let R=l;R;R=R.parent===null?null:s[R.parent]){let N=p[R.box];if(N?.kind==="panel"&&N.key!==null){let v=s.find(I=>I.kind==="tab"&&I.parent===N.unit&&I.key===N.key);v&&w.unshift({tab:d.get(v.id)})}let B=N?.unit===null||N?.unit===void 0?null:s[N.unit];if(B?.tag==="details"&&N.kind==="details"){let v=B.node.childNodes.find(I=>I.tagName==="summary");v&&w.push({details:ge(v)})}}let T=w.find(R=>R.tab)?.tab,E=w.find(R=>R.details)?.details,F=[T,k.h2,k.h3,k.h4,E].filter(Boolean);return l.tag==="h2"?Object.assign(k,{h2:d.get(l.id),h3:null,h4:null}):l.tag==="h3"?Object.assign(k,{h3:d.get(l.id),h4:null}):l.tag==="h4"&&(k.h4=d.get(l.id)),{id:l.blockId,text:d.get(l.id),parent:l.parent===null?null:h.get(l.parent)??null,where:F,heading:/^h[2-4]$/.test(l.tag)}})}function ke({reportsDirectory:i,read:s,write:p=qe,dropped:m=()=>{},now:h=Date.now}){let d=new Map,k=new Map,l=new Map,w=(o,c)=>{let S=l.get(o);if(S?.text===c)return S.units;let y=on(c);return l.set(o,{text:c,units:y}),y},T=o=>he.join(ye(o,i),Qe),E=o=>typeof o=="string"&&tn.test(o);async function F(o){let c=await Et.readFile(T(o),"utf8").catch(()=>null);return{text:c,items:c===null?[]:Xe(c)}}async function R(o,c,S){let y=Ve(c);return y===S||(y===null?await Et.rm(T(o),{force:!0}):await p(T(o),y)),N(y)}let N=o=>o===null?"":Z(o),B=o=>{let c=d.get(o)??new Map;for(let[S,y]of c)h()-y>nn&&c.delete(S);return[...c.keys()]},v=(o,c)=>c.forEach(S=>d.get(o)?.delete(S)),I=o=>{let c=k.get(o)??k.set(o,new Map).get(o);for(let[S,y]of c)h()-y>rn&&c.delete(S);return c};async function W(o,{keep:c=null,items:S=null,before:y=void 0}={}){let J=S?{items:S,text:y}:await F(o),Y=await s(o).catch(()=>null);if(!Y)return{items:J.items,units:[],places:new Map,version:N(J.text),missing:!0};let L=w(o,Y.text),M=I(o),j=ze(J.items,L,{keep:new Set([...M.keys(),c])});for(let g of M.keys())j.waiting.has(g)||M.delete(g);if(j.dropped.length>0){let g=d.get(o)??d.set(o,new Map).get(o);for(let K of j.dropped)g.set(K.id,h())}let x=j.changed||S?await R(o,j.items,J.text):N(J.text);return j.dropped.length>0&&m(o,j.dropped),{items:j.items,units:L,places:j.places,version:x,missing:!1}}let ot=(o,{items:c,version:S})=>({ok:!0,version:S,items:c,dropped:B(o)});async function H(o){if(!E(o))return[400,{ok:!1,reason:"body"}];let c=await W(o);return c.missing?[404,{ok:!1,reason:"missing"}]:[200,ot(o,c)]}async function z(o){if(!E(o))return[400,{ok:!1,reason:"body"}];let c=await W(o);if(c.missing)return[404,{ok:!1,reason:"missing"}];let S=null,y=en(ye(o,i));try{S=JSON.parse(await Et.readFile(y.json,"utf8"))}catch{}let J=await s(o).catch(()=>null),Y=/<h1\b[^>]*>([\s\S]*?)<\/h1>/i.exec(J?.text??"")?.[1]?.replace(/<[^>]*>/g,"").trim(),L=typeof S?.title=="string"&&S.title.trim()?S.title.trim():Y||o,M=c.units.some(x=>x.heading),j=c.items.map(x=>{let g=c.units[c.places.get(x.id)?.at],K=g?.where?.length?g.where:g?.heading?[g.text]:[];return{where:K,top:M&&K.length===0,blocks:x.anchor.blocks.filter(kt=>c.units.some($t=>$t.id===kt)),whole:x.anchor.kind==="blocks",quote:x.anchor.quote,text:x.text}});return[200,{ok:!0,title:L,path:he.resolve(y.html),items:j}]}async function ut(o){let{slug:c}=o??{};if(!E(c))return[400,{ok:!1,reason:"body"}];if(!await s(c).catch(()=>null))return[404,{ok:!1,reason:"missing"}];let S=await F(c);if(o.anchors&&typeof o.anchors=="object"&&!Array.isArray(o.anchors)){let M=S.items.map(x=>{let g=Object.hasOwn(o.anchors,x.id)?Ke(o.anchors[x.id]):null;return g&&g.kind===x.anchor.kind?{...x,anchor:g}:x}),j=await R(c,M,S.text);return[200,ot(c,{items:M,version:j})]}let y=S.items,J=null,Y=null;if(o.put!==void 0){let M=y.find(x=>x.id===o.put?.id),j=we({...o.put,created:M?.created??o.put?.created});if(!j)return[400,{ok:!1,reason:"item"}];y=M?y.map(x=>x.id===j.id?j:x):[...y,j],J=j.id,M||I(c).set(j.id,h()),v(c,[j.id])}else if(typeof o.remove=="string")y=y.filter(M=>M.id!==o.remove);else if(o.clear===!0)Y=y,y=[];else if(Array.isArray(o.restore)){let M=new Map(y.map(g=>[g.id,g])),j=o.restore.map(g=>we(g,g?.updated)).filter(g=>g&&!(M.get(g.id)?.updated>g.updated)),x=new Set(j.map(g=>g.id));for(let g of x)M.has(g)||I(c).set(g,h());y=[...y.filter(g=>!x.has(g.id)),...j],v(c,[...x])}else return[400,{ok:!1,reason:"body"}];let L=await W(c,{keep:J,items:y,before:S.text});return[200,{...ot(c,L),...Y?{removed:Y}:{}}]}async function yt(o){if(!E(o))return;let{text:c}=await F(o);c!==null&&await W(o)}return{list:H,copy:z,change:ut,afterWrite:yt}}import{EMPTY_STYLE as yn,emptyWordsScript as kn,showEmpty as $n}from"../browser/editor/components/placeholder.mjs";import{TOKENS as xn}from"../browser/editor/page/look.mjs";import{MARGIN_STYLE as Sn,earlyMarginScript as jn}from"../browser/editor/page/margin.mjs";var Tt=/^[a-f0-9]{16}$/,Ft=2*1024*1024,On=mn,xe=50,Se=/^\d{8}T\d{6}Z-[a-f0-9]{16}\.html$/,vn=30,je=3,Oe=200,Mt="\u6587\u4EF6\u4E00\u518D\u88AB\u4FEE\u6539\uFF08\u4F8B\u5982 AI \u6B63\u5728\u5199\u5165\uFF09\uFF0C\u7A0D\u540E\u518D\u540C\u6B65",bn="\u8FD9\u6B21\u7684\u4FEE\u6539\u592A\u5927\uFF0C\u4E00\u6B21\u5B58\u4E0D\u4E0B",An=250,Rt=Symbol("again"),En="/__gallery/edit/src/editor/page/editor.mjs",Nn=i=>new Promise(s=>setTimeout(s,i));function Tn(i,s=Ft){return new Promise((p,m)=>{let h=[],d=0;i.on("data",k=>{d+=k.length,d>s?h.length=0:h.push(k)}),i.on("end",()=>d>s?m(new Error("too-large")):p(Buffer.concat(h).toString("utf8"))),i.on("error",m)})}function Mn(i){if(!i)return $e(16).toString("hex");let s=A.join(i,"token");try{let m=ln(s,"utf8").trim();if(/^[a-f0-9]{32}$/.test(m))return m}catch{}let p=$e(16).toString("hex");try{cn(i,{recursive:!0,mode:448}),fn(s,p,{mode:384})}catch{}return p}function Ar({reportsDirectory:i=pn,stateDirectory:s=null,write:p=wt,ids:m=!0,finish:h=l=>l,log:d=null,settling:k={}}={}){let l=Mn(s),w=oe(k),T=k.wait??re,E=async(t,n,e)=>{let r=await p(t,n,e);return r!==!1&&gn(A.basename(t))&&w.wrote(A.basename(A.dirname(t)),n),r},F=t=>wn(t,i),R=t=>gt(F(t)).html,N=new Map,B=s&&A.join(s,"snapshots"),v=Promise.resolve(),I=Promise.resolve(),W=async(t,n,e,{by:r="time"}={})=>{let a=(await D.readdir(t)).filter(f=>n.test(f));if(a.length<=e)return;let u=r==="name"?a.sort():(await Promise.all(a.map(async f=>({name:f,time:(await D.stat(A.join(t,f))).mtimeMs})))).sort((f,$)=>f.time-$.time).map(({name:f})=>f);await Promise.all(u.slice(0,u.length-e).map(f=>D.rm(A.join(t,f),{force:!0})))},ot=(t,n)=>{B&&(v=v.then(async()=>{let e=A.join(B,`${t}.html`),r=new Date;try{await D.utimes(e,r,r);return}catch{}await D.mkdir(B,{recursive:!0}),await wt(e,n),await W(B,/^[a-f0-9]{16}\.html$/,xe)}).catch(()=>{}))},H=(t,n)=>{s&&(v=v.then(async()=>{let e=A.join(s,"history",t),r=Z(n);if(await D.mkdir(e,{recursive:!0}),(await D.readdir(e)).filter(f=>Se.test(f)).sort().at(-1)?.endsWith(`-${r}.html`))return;let u=new Date().toISOString().replace(/[-:]/g,"").replace(/\.\d+Z$/,"Z");await wt(A.join(e,`${u}-${r}.html`),n),await W(e,Se,vn,{by:"name"})}).catch(()=>{}))},z=new Map,ut=t=>s&&A.join(s,"receipts",t),yt=(t,n,e,r)=>{for(z.set(`${t} ${n}`,{digest:e,answer:r});z.size>Oe*4;)z.delete(z.keys().next().value);let a=ut(t);a&&(v=v.then(async()=>{await D.mkdir(a,{recursive:!0}),await wt(A.join(a,`${n}.json`),JSON.stringify({digest:e,answer:r})),await W(a,{test:u=>u.endsWith(".json")&&Nt.test(u.slice(0,-5))},Oe)}).catch(()=>{}))},o=async(t,n)=>{let e=z.get(`${t} ${n}`);if(e)return e;let r=ut(t);if(!r)return null;await v;try{let a=JSON.parse(await D.readFile(A.join(r,`${n}.json`),"utf8"));return typeof a?.digest=="string"&&a.answer?.ok?a:null}catch{return null}},c=new Map,S=(t,n)=>{let e=new Date().toISOString();if(!s)return void c.set(t,[...c.get(t)??[],{time:e,changes:n}].slice(-20));v=v.then(()=>me({stateDirectory:s,reportsDirectory:i,slug:t,time:e,changes:n})).catch(()=>{})},y=async t=>{if(!s){let n=c.get(t)??[];return c.delete(t),n}return await v,pe({stateDirectory:s,reportsDirectory:i,slug:t})},J=(t,n)=>{for(N.delete(t),N.set(t,n);N.size>xe;)N.delete(N.keys().next().value);ot(t,n)},Y=async t=>{if(N.has(t))return N.get(t);if(!B||!Tt.test(t))return null;await v;let n=await D.readFile(A.join(B,`${t}.html`),"utf8").catch(()=>null);return n===null||Z(n)!==t?null:(J(t,n),n)},L=new Map,M=t=>{let n=L.get(t);if(n)return n;let e=te(t,{finish:h});for(L.set(t,e);L.size>8;)L.delete(L.keys().next().value);return e};async function j(t,n=void 0){if(typeof t!="string"||!q.test(t))return null;let e=R(t),r=n!==void 0?n:await D.readFile(e,"utf8").catch(()=>null);if(r===null)return null;let{text:a,changes:u}=M(r);return{file:e,source:r,text:a,version:Z(a),changes:u}}async function x(t){if(typeof t!="string"||!q.test(t))return{source:null,held:!1,signs:[],wait:0,own:!1};let n=R(t),e=await D.readFile(n,"utf8").catch(()=>null),r=(await D.stat(n).catch(()=>null))?.mtimeMs??0;return{source:e,...w.judge(t,{source:e,mtime:r})}}async function g(t,n=Date.now()+T){for(;;){let e=await x(t);if(!e.held||Date.now()>=n)return e;await Nn(Math.max(0,Math.min(An,n-Date.now())))}}async function K(t,{wait:n=T}={}){let e=await g(t,Date.now()+n);return j(t,e.held&&e.taken!==void 0?e.taken:e.source)}function kt(t,n,{editor:e=En,kitTags:r=()=>[]}={}){let{html:a,map:u}=zt(n);J(u.version,n);let f=Wt(i),$=Ct(f).map(({assets:_,...C})=>({...C,kit:r(_)})),O=`<script type="application/json" id="doc-edit-map" data-doc-dev>${JSON.stringify({slug:t,token:l,...u,components:$,hidden:f.settings.hidden}).replace(/</g,"\\u003c")}</script>
|
|
3
|
-
<script data-doc-dev>document.currentScript.remove(); import(${JSON.stringify(e)});</script>`,P=`<style data-doc-dev>.doc-display { display: none; }</style>
|
|
4
|
-
<style data-doc-dev data-ge-palette>${xn}</style>
|
|
5
|
-
<style data-doc-dev>${yn}</style>
|
|
6
|
-
<script data-doc-dev>${kn()}</script>
|
|
7
|
-
<script data-doc-dev>document.currentScript.remove(); document.documentElement.setAttribute("data-ge-order", "file");</script>
|
|
8
|
-
<style data-doc-dev data-ge-margin-style>${Sn}</style>
|
|
9
|
-
<script data-doc-dev>document.currentScript.remove(); ${jn(t,{notes:an(A.join(F(t),dn))})}</script>`;return{html:$n(a),snippet:O,head:P}}let $t=t=>J(Z(t),t);async function st(t,n=Ft){if(t.method!=="POST")return{error:[405,{ok:!1,reason:"method"}]};let e=t.headers.host??"",r=t.socket.localPort;if(e!==`127.0.0.1:${r}`&&e!==`localhost:${r}`)return{error:[403,{ok:!1,reason:"host"}]};if(t.headers.origin!==`http://${e}`)return{error:[403,{ok:!1,reason:"origin"}]};if(t.headers["x-gallery-token"]!==l)return{error:[403,{ok:!1,reason:"token"}]};if(!/^application\/json\b/i.test(t.headers["content-type"]??""))return{error:[415,{ok:!1,reason:"type"}]};try{return{body:JSON.parse(await Tn(t,n))}}catch(a){return{error:a.message==="too-large"?[413,{ok:!1,reason:"body",message:bn}]:[400,{ok:!1,reason:"body"}]}}}async function ve(t,n){let{slug:e,opening:r,known:a=null,texts:u=[],units:f=[],touch:$=[],pageIds:b=null,request:O=null}=t;if(typeof e!="string"||!q.test(e)||![u,f,$].every(Array.isArray))return[400,{ok:!1,reason:"body"}];if(O!==null&&(typeof O!="string"||!Nt.test(O)))return[400,{ok:!1,reason:"body"}];let P=O===null?null:Z(JSON.stringify([r??null,u,f,$])),_=await It(t);if(_)return _;let C=V=>(O!==null&&yt(e,O,P,V),[200,V]),G=R(e),Q=typeof r=="string"&&Tt.test(r)?await Y(r):null,et=V=>sn("sha256",l).update(`${e}
|
|
10
|
-
${V}`).digest("hex").slice(0,32);for(let V=1;;V++){let{source:pt,held:De}=await x(e);if(pt===null)return[404,{ok:!1,reason:"missing"}];if(De)return Date.now()<n?Rt:[409,{ok:!1,reason:"busy",message:Mt}];let{text:lt,changes:vt}=M(pt),ht=Qt({current:lt,opening:Q,texts:u,units:f,touch:$,ids:m,seal:et,pageIds:b}),{title:_t,icon:Ut,...Bt}=ht,ft=ht.text===lt?lt:h(ht.text);ft!==ht.text&&(Bt.version=Z(ft));let Yt={...Bt,foreign:typeof a=="string"&&Z(lt)!==a};if(ft===lt)return C({ok:!0,...Yt,wrote:!1,notes:[]});if(H(e,pt),!await E(G,ft,{expect:pt})){if(V===je)return[409,{ok:!1,reason:"busy",message:Mt}];continue}H(e,ft),vt.length&&(d&&d(bt(G,vt).join(`
|
|
11
|
-
`)),S(e,vt));let Pe=[..._t?await xt(A.dirname(G),_t):[],...Ut!==void 0?await Dt(A.dirname(G),Ut):[]];return C({ok:!0,...Yt,wrote:!0,notes:Pe})}}async function It({slug:t,opening:n,texts:e=[],units:r=[],touch:a=[],request:u=null}){if(typeof t!="string"||!q.test(t)||typeof u!="string"||!Nt.test(u)||![e,r,a].every(Array.isArray))return null;let f=await o(t,u);return f?f.digest===Z(JSON.stringify([n??null,e,r,a]))?[200,{...f.answer,again:!0}]:[409,{ok:!1,reason:"request",message:"\u540C\u4E00\u6B21\u4FDD\u5B58\u7684\u5185\u5BB9\u4E0D\u4E00\u81F4"}]:null}async function be(t,n){let{slug:e,opening:r,texts:a=[],units:u=[],instances:f=[],pageIds:$=null}=t;if(typeof e!="string"||!q.test(e)||!Array.isArray(a)||!Array.isArray(u)||!Array.isArray(f))return[400,{ok:!1,reason:"body"}];let{source:b,held:O}=await x(e);if(O)return Date.now()<n?Rt:[409,{ok:!1,reason:"busy",message:Mt}];let P=await j(e,b);if(P===null)return[404,{ok:!1,reason:"missing"}];let{text:_,version:C}=P,G=typeof r=="string"&&Tt.test(r)?await Y(r):null;return[200,{ok:!0,version:C,reverted:qt({current:_,opening:G,texts:a,pageIds:$}),units:Vt({current:_,units:u}),parts:Xt({current:_,instances:f,pageIds:$})}]}async function xt(t,{from:n,to:e,synced:r}){let a=["\u6807\u9898\u5DF2\u66F4\u65B0",...r?[]:["\u5355\u72EC\u6253\u5F00\u6216\u5BFC\u51FA\u65F6\u7684\u9875\u9762\u540D\u79F0\u539F\u672C\u5C31\u548C\u6807\u9898\u4E0D\u540C\uFF0C\u6CA1\u6709\u8DDF\u7740\u6539"]],u=gt(t).json,f=await D.readFile(u,"utf8").catch(()=>""),$=null;try{$=JSON.parse(f)}catch{}if($?.title!==n)return[...a,"\u641C\u7D22\u548C\u4FA7\u680F\u91CC\uFF08\u6CA1\u6253\u5F00\u8FD9\u4EFD\u6587\u6863\u65F6\uFF09\u7684\u6587\u6863\u540D\u539F\u672C\u5C31\u548C\u6807\u9898\u4E0D\u540C\uFF0C\u6CA1\u6709\u8DDF\u7740\u6539"];let b=new RegExp(`("title"\\s*:\\s*)${JSON.stringify(n).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`),O=b.test(f)?f.replace(b,(P,_)=>_+JSON.stringify(e)):`${JSON.stringify({...$,title:e},null,2)}
|
|
12
|
-
`;try{await E(u,O)}catch(P){return d?.(`${A.basename(u)}'s title was not written (${P.code??P.message}): ${u}`),[...a,"\u641C\u7D22\u548C\u4FA7\u680F\u91CC\uFF08\u6CA1\u6253\u5F00\u8FD9\u4EFD\u6587\u6863\u65F6\uFF09\u7684\u6587\u6863\u540D\u6CA1\u80FD\u8DDF\u7740\u6539"]}return a}async function Dt(t,n){let e=gt(t).json,r=null;try{r=JSON.parse(await D.readFile(e,"utf8"))}catch{}if(!r||typeof r!="object")return d?.(`${A.basename(e)} could not be read, so its icon was not written: ${e}`),["\u9875\u9762\u56FE\u6807\u5DF2\u66F4\u6362\uFF0C\u4F46\u641C\u7D22\u548C\u4FA7\u680F\u91CC\uFF08\u6CA1\u6253\u5F00\u8FD9\u4EFD\u6587\u6863\u65F6\uFF09\u7684\u56FE\u6807\u6CA1\u80FD\u8DDF\u7740\u6362"];if((r.icon??null)===n)return[];let{icon:a,...u}=r,f=n===null?u:{...u,icon:n};try{await E(e,`${JSON.stringify(f,null,2)}
|
|
13
|
-
`)}catch($){return d?.(`${A.basename(e)}'s icon was not written (${$.code??$.message}): ${e}`),["\u9875\u9762\u56FE\u6807\u5DF2\u66F4\u6362\uFF0C\u4F46\u641C\u7D22\u548C\u4FA7\u680F\u91CC\uFF08\u6CA1\u6253\u5F00\u8FD9\u4EFD\u6587\u6863\u65F6\uFF09\u7684\u56FE\u6807\u6CA1\u80FD\u8DDF\u7740\u6362"]}return[]}async function Ae(t,n){let e=typeof n=="string"?n.replace(/\s+/g," ").trim():"";if(!e)return{ok:!1,reason:"title",message:"\u6807\u9898\u4E0D\u80FD\u4E3A\u7A7A"};let r=R(t),a=await D.readFile(r,"utf8").catch(()=>null);if(a===null)return{ok:!1,reason:"missing"};let u=Zt(a),f=Gt(u).find(O=>O.kind==="title");if(!f)return{ok:!1,reason:"no-title",message:"\u8FD9\u4EFD\u6587\u6863\u6CA1\u6709\u6807\u9898"};let $=un(e),b=Kt({current:u,edits:[{id:f.id,parts:[{keep:!0,html:$}]}],ids:m});return b.ok?b.text!==a&&!await E(r,b.text,{expect:a})?{ok:!1,reason:"changed-again"}:{ok:!0,title:e,notes:b.title?await xt(A.dirname(r),b.title):[]}:{ok:!1,reason:"conflict"}}let at=t=>(n,e)=>{let r=I.then(()=>t(n));return I=r.catch(()=>{}),r.then(([a,u])=>U(e,a,u),a=>U(e,500,{ok:!1,reason:"write",message:a.message}))},Pt=(t,{early:n=null}={})=>async(e,r)=>{let a=await st(e);if(a.error)return U(r,...a.error);let u=a.body??{},f=Date.now()+T;try{let $=n&&await n(u);if($)return U(r,...$);for(;;){await g(u.slug,f);let b=I.then(()=>t(u,f));I=b.catch(()=>{});let O=await b;if(O!==Rt)return U(r,...O)}}catch($){return U(r,500,{ok:!1,reason:"write",message:$.message})}};async function St(t,{reader:n=!1}={}){if(typeof t!="string"||!q.test(t))return{ok:!1,reason:"missing",message:"\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"};let e=F(t),{html:r,json:a}=gt(e);for(let u=1;;u++){let{source:f,held:$}=n?await x(t):{source:await D.readFile(r,"utf8").catch(()=>null),held:!1};if(f===null)return{ok:!1,reason:"missing",message:"\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"};if($)return{ok:!1,reason:"busy",message:"\u6587\u4EF6\u4E00\u518D\u88AB\u4FEE\u6539\uFF08\u4F8B\u5982 AI \u6B63\u5728\u5199\u5165\uFF09\uFF0C\u6CA1\u6709\u5199\u5165"};let b=null;try{b=JSON.parse(await D.readFile(a,"utf8"))}catch{}let{text:O,changes:P,added:_,given:C,repeated:G,title:Q,icon:et}=ee(f,{finish:h,next:typeof m=="function"?m:void 0,metadata:b});if(O!==f){if(H(t,f),!await E(r,O,{expect:f})){if(u===je)return{ok:!1,reason:"busy",message:"\u6587\u4EF6\u4E00\u518D\u88AB\u4FEE\u6539\uFF08\u4F8B\u5982 AI \u6B63\u5728\u5199\u5165\uFF09\uFF0C\u6CA1\u6709\u5199\u5165"};continue}H(t,O),n&&P.length&&(d&&d(bt(r,P).join(`
|
|
14
|
-
`)),S(t,P))}return Q&&typeof b?.title=="string"&&b.title!==Q.to&&await xt(e,{from:b.title,to:Q.to,synced:Q.page}),et&&!et.missing&&await Dt(e,et.to),{ok:!0,changes:O===f?[]:P,added:O===f?0:_,given:O===f?[]:C,repeated:G,written:O!==f,title:Q,icon:et}}}let Ee=async(t,{reader:n=!1}={})=>{n&&await g(t);let e=I.then(()=>St(t,{reader:n}));return I=e.catch(()=>{}),e};async function Jt(t){let n=await st(t);if(n.error)return{refused:n.error};let{slug:e,workspace:r}=n.body??{};return typeof e!="string"||!q.test(e)||typeof r!="string"?{refused:[400,{ok:!1,reason:"body"}]}:hn(r,i)?{slug:e}:{refused:[409,{ok:!1,reason:"elsewhere",message:"\u8FD9\u4E2A\u9884\u89C8\u670D\u52A1\u5668\u7BA1\u7684\u662F\u53E6\u4E00\u4E2A\u76EE\u5F55\u7684\u6587\u6863"}]}}async function Ne(t,n){try{let e=I.then(async()=>{let{slug:u,refused:f}=await Jt(t);if(f)return{answer:f};let $=await St(u);return{slug:$.ok?u:null,answer:[$.ok?200:$.reason==="missing"?404:409,$]}});I=e.catch(()=>{});let{slug:r,answer:a}=await e;return r&&await Ot(r),U(n,...a)}catch(e){return U(n,500,{ok:!1,reason:"write",message:e.message})}}async function Te(t){let{slug:n,refused:e}=await Jt(t);return e||(await Ot(n),[200,{ok:!0}])}let tt=ne({reportsDirectory:i}),it=ke({reportsDirectory:i,read:t=>K(t,{wait:0}),write:E,dropped:(t,n)=>{let e=n.map(le);d&&d(At(A.join(F(t),"annotations.json"),{items:e}).join(`
|
|
15
|
-
`)),s&&(v=v.then(()=>fe({stateDirectory:s,reportsDirectory:i,slug:t,time:new Date().toISOString(),items:e})).catch(()=>{}))}}),Lt=Promise.resolve(),jt=t=>{let n=Lt.then(t);return Lt=n.catch(()=>{}),n},Me=t=>(n,e)=>jt(()=>t(n)).then(([r,a])=>U(e,r,a),r=>U(e,500,{ok:!1,reason:"write",message:r.message})),Re=300,ct=new Map;async function Ot(t){let n=ct.get(t);n&&(clearTimeout(n.timer),ct.delete(t));let e=jt(()=>it.afterWrite(t));n&&e.then(n.resolve,n.reject),await e.catch(r=>d?.(`${t}: annotations not checked: ${r.message}`)),await v}let Fe=t=>{let n=t.headers.host??"",e=t.socket.localPort;return n!==`127.0.0.1:${e}`&&n!==`localhost:${e}`?[403,{ok:!1,reason:"host"}]:t.headers["x-gallery-token"]!==l?[403,{ok:!1,reason:"token"}]:null};async function Ie(t){if(t.method==="GET"){let e=Fe(t);if(e)return e;let r=new URL(t.url??"/","http://localhost").searchParams;return r.get("as")==="copy"?it.copy(r.get("slug")):it.list(r.get("slug"))}let n=await st(t);return n.error??it.change(n.body)}let mt=(t,n=Ft)=>async e=>{let r=await st(e,n);return r.error??t(r.body)};return{token:l,preview:kt,opened:$t,check:st,upload:at(mt(tt.upload,On)),addEmoji:at(mt(tt.addEmoji)),unfurl:at(mt(tt.unfurl)),annotations:Me(Ie),checkAnnotations(t){let n=ct.get(t);return n||(n={timer:0},n.done=new Promise((e,r)=>Object.assign(n,{resolve:e,reject:r})),ct.set(t,n)),clearTimeout(n.timer),n.timer=setTimeout(()=>{ct.delete(t),jt(()=>it.afterWrite(t)).then(n.resolve,n.reject)},Re),n.done},frameable:at(mt(tt.frameable)),listEmojis:tt.listEmojis,readEmoji:tt.readEmoji,respond:at,keepVersion:H,renameReport:Ae,read:j,settled:x,whenTaken:g,readTaken:K,takeRewrites:y,handIn:Ee,handInReport:St,handInRequest:Ne,settleRequest:(t,n)=>Te(t).then(([e,r])=>U(n,e,r),e=>U(n,500,{ok:!1,reason:"write",message:e.message})),settleNotes:Ot,commit:Pt(ve,{early:It}),reverted:Pt(be),stored:()=>v}}export{_n as a,Un as b,pe as c,Gn as d,Ar as e};
|
package/dist/chunk-ATCJYAR4.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}from"./chunk-5FRMCDPY.mjs";import"./chunk-E7VYDG2X.mjs";import"./chunk-NFIBI4IP.mjs";import"./chunk-W63L7367.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{f as changeLines,c as handedInSource,e as inStep,a as naturalize,d as pendingBlockIds,g as readOnlyTexts,i as scriptKept,b as shownSource,h as writingNotes};
|
package/dist/chunk-C7HWOBIF.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}from"./chunk-FQGQH4KM.mjs";import"./chunk-TX6JH7TR.mjs";import"./chunk-YXAUQPVK.mjs";import"./chunk-NSKUTQ5J.mjs";import"./chunk-YZ5Z6H4W.mjs";import"./chunk-E7VYDG2X.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as DEFAULT_DESCRIPTION,c as run,b as slugRefused};
|
package/dist/chunk-E7VYDG2X.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{b as d,e as L}from"./chunk-A55HN5OK.mjs";L();import{isInstance as x}from"../browser/shared/components/index.mjs";import{mayHoldOldNames as A,newAttributeName as I,newAttributeValue as b,newScriptNames as N,newStyleNames as j}from"../browser/shared/old-names.mjs";var S=/^data-(?:report|doc)-(?:kit|vendor)$/;function q(o){if(typeof o!="string"||!A(o))return o;let O=d(o,{sourceCodeLocationInfo:!0}),c=[],u=(t,e,s)=>{o.slice(t,e)!==s&&c.push({start:t,end:e,text:s})};function g(t){let e=t.sourceCodeLocation?.attrs??{};for(let{name:n,value:y}of t.attrs){let r=e[n];if(!r)continue;let i=o.slice(r.startOffset,r.endOffset),f=i.indexOf("="),v=f<0?i:i.slice(0,f),m=f<0?"":i.slice(f),C=/^on/i.test(n)||/^\s*javascript:/i.test(y)?N(m):b(n,m,t.tagName);u(r.startOffset,r.endOffset,I(v)+C)}if(t.attrs.some(({name:n})=>S.test(n))||!["style","script"].includes(t.tagName))return;let s=t.childNodes?.[0]?.sourceCodeLocation;if(!s)return;let w=(t.attrs.find(({name:n})=>n==="type")?.value??"").trim().toLowerCase();if(t.tagName==="script"&&/json/.test(w))return;let p=o.slice(s.startOffset,s.endOffset);u(s.startOffset,s.endOffset,t.tagName==="style"?j(p):N(p))}let l=t=>{for(let e of t.childNodes??[])x(e)||(e.tagName&&g(e),l(e.tagName==="template"&&e.content?e.content:e))};if(l(O),!c.length)return o;c.sort((t,e)=>e.start-t.start);let a=o;for(let{start:t,end:e,text:s}of c)a=a.slice(0,t)+s+a.slice(e);return a}export{q as a};
|
package/dist/chunk-FQGQH4KM.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 as i,b as k}from"./chunk-TX6JH7TR.mjs";import{a as g,b as y,c as x,i as $}from"./chunk-YXAUQPVK.mjs";import{b as f,f as w,g as u}from"./chunk-NSKUTQ5J.mjs";import{b as d}from"./chunk-YZ5Z6H4W.mjs";import{existsSync as j}from"node:fs";import n from"node:path";import{reportsDirectory as c}from"../browser/shared/paths.mjs";import{keptName as D,layoutOf as E,listTrash as L}from"../browser/shared/workspace.mjs";var T="\u65B0\u6587\u6863";async function S(o,t=c){return D(o)?`"${o}" is a name the workspace keeps for itself: choose another slug.`:j(n.join(E(t).pages,o))?`"${o}" is the \u5199\u4F5C\u504F\u597D page's slug: choose another slug.`:j(n.join(t,o))?`Document already exists: ${i(n.join(t,o))}`:(await L(t)).some(s=>s.slug===o)?`"${o}" is a document's in the trash: choose another slug.`:null}async function C(o){let{positional:t,options:s}=w({options:["--no-preview","--no-browser"],argv:o}),[e,l,h=T]=t;if(t.length<2||t.length>3||!e||!l?.trim()||!h.trim())throw new f("Name the slug and the title (then a description, if you choose one), each quoted when it has spaces.");u(e);let p=await S(e);p&&(console.error(p),process.exit(1));try{await d(e,l,h)}catch(r){if(r.code!=="EEXIST")throw r;console.error(await S(e)??`Document already exists: ${i(n.join(c,e))}`),process.exit(1)}console.log(`Created ${i(n.join(c,e,"doc.html"))} and doc.json`);for(let r of await k())console.log(r);let a=await $(e,{skipped:x(s),command:`gallery new ${e}`});console.log(g(a,"replace the starter section with the document's skeleton (each section's heading) as soon as you can outline it, then write it a section at a time, as ordinary HTML, so that the user watches it grow (gallery check fails while the starter section remains).")),console.log(`Hand in: gallery export ${e}, then gallery qa ${e}`);let m=await y(a,s);m&&console.log(m);for(let r of a)console.log(r)}export{T as a,S as b,C as c};
|
package/dist/chunk-GPF4YWWB.mjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{b as we,c as pe,d as ge,e as J,g as R,h as me,i as X,j as $e,k as ye,l as $,m as ke}from"./chunk-3LA3EMDE.mjs";import{a as H}from"./chunk-TX6JH7TR.mjs";import{d as ce,g as de}from"./chunk-YXAUQPVK.mjs";import{a as U}from"./chunk-UNUEWH4S.mjs";import{a as Q,c as F}from"./chunk-G7TOXONE.mjs";import{a as he,b as fe,e as ue}from"./chunk-LC7YNQFG.mjs";import"./chunk-ITNLYXXV.mjs";import{b as v,i as ie}from"./chunk-NSKUTQ5J.mjs";import"./chunk-QMQUXTU4.mjs";import"./chunk-HQQMJCQJ.mjs";import"./chunk-QYKCJ7FG.mjs";import"./chunk-YZ5Z6H4W.mjs";import"./chunk-VACRB2NE.mjs";import{a as re}from"./chunk-HYMEEXKN.mjs";import"./chunk-TDQP3DKQ.mjs";import{b as z}from"./chunk-5FRMCDPY.mjs";import"./chunk-E7VYDG2X.mjs";import"./chunk-NFIBI4IP.mjs";import{c as Y,g as le}from"./chunk-W63L7367.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import C from"node:fs/promises";import P from"node:path";import{isInstance as K,partOf as Fe}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as ae,FALLBACK as Re,FIELDS as _e,INSTANCE as Se,PACKAGE_ID as je}from"../browser/shared/components/installed.mjs";import{attr as ee,walk as Pe}from"../browser/shared/html-tree.mjs";import{documentDirectory as Be,documentFiles as He,layoutOf as se,packageFolders as Ue}from"../browser/shared/workspace.mjs";var be=10,te=6,qe=3,Ge=100,Le=1024,Ie=900,Ve=4e3,V=3e4,Ke=1500,ne=3e4,oe=500,We=5e3,Ze=200,B=e=>new Promise(t=>setTimeout(t,e));async function Ye(e){let{_keyDefinitions:t}=await import("./chunk-43B75J5T.mjs"),n=Object.hasOwn(t,e)?[e]:e.split("+"),a=new Set(["Control","Shift","Alt","Meta"]);if(n.some(o=>!Object.hasOwn(t,o))||n.slice(0,-1).some(o=>!a.has(o)))throw new v(`Not a key: ${e} (a key as a browser names it, Enter, Space, Escape, Tab, ArrowRight, a letter or a digit, after modifiers joined by "+": Shift+Tab, Control+Enter).`);return n}async function ze(e,t){let n=["--press","--drag","--key"].filter(a=>e.has(a));if(n.length!==1)throw new v(n.length?`One gesture at a time: ${n.join(" or ")}.`:"Say the gesture: --press <selector>, --drag <selector> --to <selector> or --key <selector> <key>.");if(e.has("--to")&&!e.has("--drag"))throw new v("--to goes with --drag: --drag <selector> --to <selector>.");if(e.has("--drag")&&!e.has("--to"))throw new v("--drag takes --to: --drag <selector> --to <selector>, where it is dropped.");return e.has("--press")?{kind:"press",at:e.get("--press")}:e.has("--drag")?{kind:"drag",at:e.get("--drag"),to:e.get("--to")}:{kind:"key",at:e.get("--key"),keys:await Ye(t),key:t}}var Qe=e=>{let t=e.parentNode;for(;t&&!K(t);)t=t.parentNode;return t??null};function Ne(e){let t=[];return Pe(re(e),n=>{K(n)&&t.push({element:n,id:ee(n,ae),blockId:ee(n,"data-block-id")??null,line:n.sourceCodeLocation?.startLine})},{stop:K}),t}var Je=(e,{id:t,blockId:n})=>n??(e.filter(a=>a.id===t).length===1?t:null);function Xe(e,t,{slug:n,name:a}){let o=()=>e.map(i=>` ${Je(e,i)??"(no id yet: gallery export gives it one)"} ${i.id} at ${a}:${i.line}`).join(`
|
|
3
|
-
`);if(t===null){if(e.length===1)return 0;throw new v(`${n} holds ${e.length} instances: name one, gallery component try ${n} <instance id> \u2026
|
|
4
|
-
${o()}`)}let r=e.findIndex(({blockId:i})=>i===t);if(r>=0)return r;let l=t.includes("/")?t:`local/${t}`,s=je.test(l)?e.flatMap((i,c)=>i.id===l?[c]:[]):[];if(s.length===1)return s[0];throw new v(s.length?`${n} holds ${s.length} instances of ${l}: name one by its id
|
|
5
|
-
${o()}`:`${n} holds no instance ${t}:
|
|
6
|
-
${o()}`)}var et=e=>e.replace(/\s+data-block-id="[^"]*"/g,""),ve=e=>et(z(e).text);function xe(e,t,n){let a=Ne(e)[t]?.element;if(!a||ee(a,ae)!==n.id)return null;let o=[],r=Object.entries(n.parts).map(([c,{at:u}])=>{let p=Fe(a,u).filter(h=>h.sourceCodeLocation?.endTag&&!K(h)&&Qe(h)===a).map(({sourceCodeLocation:{startTag:h,endTag:d}})=>({start:h.endOffset,end:d.startOffset}));return o.push(...p),{name:c,text:p.map(({start:h,end:d})=>e.slice(h,d)).join(`
|
|
7
|
-
`)}}),l=o.sort((c,u)=>c.start-u.start||u.end-c.end).filter((c,u)=>!o.slice(0,u).some(p=>p.start<=c.start&&c.end<=p.end)),s="",i=0;for(let{start:c,end:u}of l)s+=e.slice(i,c),i=u;return{parts:r,outside:s+e.slice(i)}}function tt(e,t,n,a){let[o,r]=[xe(e,n,a),xe(t,n,a)];return!o||!r?{parts:[],outside:null,gone:!0}:{parts:o.parts.flatMap(({name:s,text:i},c)=>i===r.parts[c].text?[]:[{name:s,...X(i,r.parts[c].text),how:$e(i,r.parts[c].text)}]),outside:o.outside===r.outside?null:X(o.outside,r.outside),gone:!1}}async function nt(e,t){let{components:n,marker:a}=se(e);return await Oe([t,a,n])+U+F+oe}async function Oe(e){let t=[...e];for(let a of e)for(let o of await C.readdir(a,{recursive:!0,withFileTypes:!0}).catch(()=>[]))t.push(P.join(o.parentPath,o.name));let n=await Promise.all(t.map(a=>C.stat(a).then(({mtimeMs:o})=>o,()=>0)));return Math.max(...n)}var ot=e=>fetch(`${e}/__gallery/workspace/components`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?t.json():null).then(t=>Array.isArray(t?.packages)?t.packages:null,()=>null);async function at(e,t,n){let{components:a,marker:o}=se(e),r=Ue(e).find(k=>k.id.toLowerCase()===t)?.folder??P.join(a,...t.split("/")),[l,s]=await Promise.all([Oe([o,r]),ot(n)]),{packages:i,problems:c,settings:u}=Y(e),p=s?.find(k=>k.id===t)??null,h=s?p?.state??"none":null,d=h==="normal"||h==="hidden",f=u.disabled.includes(t),m=c.get(t),y=m&&!f&&d?le("en",m.problem):null,S=s!==null&&i.has(t)&&!d;return{by:l+(y?Q:U+F),held:y,behind:S,off:f,stamp:(i.get(t)??m)?.stamp??null,state:h,reason:p?.reason?.en??null}}var Ce=({state:e,reason:t})=>e==="none"?"no such package":t?`it as not loading (${t})`:"it turned off";function st(e,{said:t,unparsed:n=null,off:a,behind:o=!1,state:r,reason:l}){let s="the instance shows what it holds, read-only, so a reader can do nothing with it";return n?`${s}: its kit.js did not parse, so no component of it started, and the console says ${n}`:t.length?`${s}: its component failed as the page started it, and the console says ${t.join("; ")}`:a?`${s}: ${e} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6`:o?`${s}: the server has not taken ${e} as components/ holds it, where it loads: its catalog in use has ${Ce({state:r,reason:l})}`:r==="disabled"&&!l?`${s}: ${e} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6`:r==="broken"||r==="disabled"?`${s}: the server has ${e} as not loading (${l}): gallery component check ${e} says why`:r==="none"?`${s}: the server has not taken ${e} as components/ holds it (its catalog in use has no such package)`:r?`${s}: the page was served before the server took ${e} as components/ holds it, and did not load itself again with it`:`${s}: its component failed or never started, and the console said nothing of it`}var it=(e,t,n)=>t.held?`${e} does not load as components/ holds it (${t.held}), and the server keeps it as it was until components/ has not changed for ${Q/1e3}s, as it keeps a package written file by file`:t.behind?`components/ holds ${e} as loading, and the server's catalog in use still has ${Ce(t)}: it takes what components/ holds once that has not changed for ${F/1e3}s`:n?`${e} or gallery.json changed a moment ago, and the server takes the change once components/ has not changed for ${F/1e3}s, the page served before loading itself again for it`:`the server took ${e} as components/ holds it, and the page served before is to load itself again with it`,rt=(e,t,n)=>t.held?`the server still keeps ${e} as it was`:t.behind?`the server has still not taken ${e} as components/ holds it`:`the server took ${e} as components/ holds it, and the page did not load itself again with it in ${n/1e3}s`;async function lt({root:e,id:t,origin:n,loadedAt:a,loaded:o,told:r=We,say:l=s=>console.log(s)}){let s=Date.now(),i,c=0,u=0,p=!1;for(;;await B(Ze)){let h=await at(e,t,n),d=Date.now();i!==void 0&&h.stamp!==i&&(c=d),i=h.stamp,h.behind&&!u&&(u=d);let f=Math.max(h.by,...[c,u].filter(Boolean).map(y=>y+U+F)),m=o()?"the page loaded itself again":h.off?`gallery.json turns ${t} off now`:a>=f?`the page was asked for after the server took ${t} as components/ holds it`:d>f+r?rt(t,h,r):null;if(m)return p&&l(`Waited ${((d-s)/1e3).toFixed(1)}s: ${m}`),h;p||f-d<=oe&&d-s<=oe||(p=!0,l(`Waiting: ${it(t,h,f>d)}, ${Math.ceil((f+r-d)/1e3)}s more at most`))}}function ct({instance:e,at:t}){return[...document.querySelectorAll(e)].filter(n=>!n.parentElement?.closest(e))[t]??null}function dt(e,t){let n=d=>`<${d.localName}${d.classList.length?` class="${d.getAttribute("class")}"`:""}>`,a;try{a=e.querySelector(t)}catch{return{invalid:!0}}if(!a)return{none:!0,held:[...new Set([...e.querySelectorAll("[class]")].filter(d=>d.getClientRects().length>0).flatMap(d=>[...d.classList].map(f=>`.${f}`)))].slice(0,16)};let o=((a instanceof HTMLElement?a.innerText:a.textContent)??"").replace(/\s+/g," ").trim(),r={named:n(a),words:o.length>40?`${o.slice(0,40)}\u2026`:o},l=[...a.getClientRects()].filter(({width:d,height:f})=>d>0&&f>0);if(!l.length)return{...r,hidden:!0};let{left:s,top:i,right:c,bottom:u,width:p,height:h}=l.reduce((d,f)=>d.width*d.height>=f.width*f.height?d:f);return{...r,box:{left:s,top:i,right:c,bottom:u,x:s+p/2,y:i+h/2}}}function ht(e,{selector:t,x:n,y:a}){let o=e.querySelector(t),r=document.elementFromPoint(n,a);return!r||o.contains(r)?null:`<${r.localName}${r.classList.length?` class="${r.getAttribute("class")}"`:""}>`}function ft(e,{at:t,to:n}){let[a,o]=[e.querySelector(t),e.querySelector(n)];return a===o?"same":a.contains(o)?"inside":null}function ut(e){let t=a=>a instanceof Element?`<${a.localName}${a.classList.length?` class="${a.getAttribute("class")}"`:""}>`:"the page",n={edits:[],states:[],started:null,dropped:null,effect:null};addEventListener("doc-component-edit",a=>{a.target===e&&n.edits.push({taken:a.defaultPrevented,parts:(a.detail?.parts??[]).map(({name:o})=>o)})}),new MutationObserver(a=>{for(let{oldValue:o}of a)n.states.push(o);n.states.push(document.documentElement.getAttribute("data-ge-save"))}).observe(document.documentElement,{attributes:!0,attributeFilter:["data-ge-save"],attributeOldValue:!0}),document.addEventListener("dragstart",a=>{n.started=t(a.target)},!0),document.addEventListener("drop",a=>{n.dropped=t(a.target)},!0),document.addEventListener("dragend",a=>{n.effect=a.dataTransfer?.dropEffect??null},!0),globalThis.__galleryTry=n}async function wt(e,{still:t,step:n}){let a=()=>new Promise(r=>{requestAnimationFrame(r),setTimeout(r,100)});await a(),await a();let o=e.outerHTML;for(let r=0,l=Date.now()+t;r<3;){if(Date.now()>l)return null;await new Promise(i=>setTimeout(i,n));let s=e.outerHTML;r=s===o?r+1:0,o=s}return o}function pt(e,t,{left:n,top:a,right:o,bottom:r}){let l=0;for(let[s,i,c,u]of[[e.x,t.x,n,o],[e.y,t.y,a,r]]){if(i===s)continue;let[p,h]=[(c-s)/(i-s),(u-s)/(i-s)];l=Math.max(l,Math.min(p,h))}return l*Math.hypot(t.x-e.x,t.y-e.y)}function gt(e,t){let n=Math.hypot(t.x-e.x,t.y-e.y),a=i=>n===0?{x:e.x,y:e.y}:{x:e.x+(t.x-e.x)*i/n,y:e.y+(t.y-e.y)*i/n},o=Math.min(te,n),r=pt(e,t,t)-qe,l=r>o?r:n,s=[a(o/2),a(o)];for(let i=1;i<=be;i++)s.push(a(o+(l-o)*i/be));return l!==n&&s.push({x:t.x,y:t.y}),s}var W={press:"press",drag:"drag",key:"key"},q=(e,{named:t,words:n})=>`${e} (${t}${n?` "${n}"`:""})`,Ee=e=>Object.assign(new v(e),{unfound:!0});async function mt(e,t,n){let a=async i=>{let c=await $(t.evaluate(dt,i),"the page was asked what the selector finds");if(c.invalid)throw new v(`Not a selector: ${i}.`);if(c.none)throw Ee(`Nothing in the instance is ${i}${c.held.length?`: what it shows has ${c.held.join(", ")}`:": it shows nothing with a class"}.`);if(c.hidden)throw Ee(`${i} finds ${c.named} in the instance, which is not shown (it has no box on the page), so a reader cannot reach it: name what it shows.`);return c},o=await a(n.at);if(n.kind==="press"){let{x:i,y:c}=o.box,u=await $(t.evaluate(ht,{selector:n.at,x:i,y:c}),"the page was asked what stands at the press");return await e.mouse.move(i,c),await e.mouse.down(),await e.mouse.up(),{said:`a press on ${q(n.at,o)}, with the pointer at its middle`,over:u}}if(n.kind==="drag"){let i=await a(n.to),c=await $(t.evaluate(ft,{at:n.at,to:n.to}),"the page was asked where the drag ends");if(c)throw new v(`${c==="same"?`--drag and --to find the same element, ${o.named}`:`--to ${n.to} finds ${i.named}, which stands in what --drag ${n.at} finds, ${o.named}`}: a drag ends where it is dropped, on another element of the instance (another column, another row), which --to names.`);if(Math.hypot(i.box.x-o.box.x,i.box.y-o.box.y)<te)throw new v(`The middles of what --drag ${n.at} and --to ${n.to} find stand less than ${te}px apart, too near for a drag to start: name with --to where it is dropped, further off.`);let u=gt(o.box,i.box);await e.mouse.move(o.box.x,o.box.y),await e.mouse.down();for(let{x:p,y:h}of u)await e.mouse.move(p,h);return await B(Ge),await e.mouse.up(),{said:`a drag of ${q(n.at,o)} to ${q(n.to,i)}, with the pointer in ${u.length} moves, released as it comes onto it`}}let r=await t.$(n.at);await $(r.focus(),"the focus went to the element");let l=await $(e.evaluate(i=>document.activeElement===i||i.contains(document.activeElement)?null:`<${document.activeElement?.localName??"body"}>`,r),"the page was asked where the focus is"),s=n.keys.slice(0,-1);for(let i of s)await e.keyboard.down(i);await e.keyboard.press(n.keys.at(-1));for(let i of s.toReversed())await e.keyboard.up(i);return{said:`${n.key} pressed with the focus given to ${q(n.at,o)}, as Tab gives it`,unfocused:l}}var $t=e=>fetch(`${e}/__gallery/workspace/info`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok,()=>!1);async function Te(e,t,n){let a=Date.now();for(let o=0,r=0;;await B(100)){let{seen:l,now:s}=await $(e.evaluate(c=>({seen:globalThis.__galleryTry.states.slice(c),now:document.documentElement.getAttribute("data-ge-save")}),t),"the page was asked where saving stands"),i=s!=="saved"||l.some(c=>c!=="saved");if(i&&s==="saved")return"saved";if(s==="stopped"||s==="reloading")return s;if(o=s==="held"?o+1:0,o>=3)return"held";if(r=s==="offline"?r+1:0,r>0&&r%10===0&&!await $t(n))return"offline";if(!i&&Date.now()-a>Ke)return"unchanged";if(Date.now()-a>ne)return s}}var _=e=>({held:"a card waits for a reader: someone else changed the part meanwhile, and the page held its write for the reader there, which closing the page dropped",offline:"the page could not reach the server (offline)",stopped:"the page stopped saving (stopped): the server refused its write",reloading:"the page loaded itself again (doc.html or a package it holds changed meanwhile)",waiting:`it waited ${ne/1e3}s to be saved and never was`,syncing:`its save took more than ${ne/1e3}s`})[e];function yt(e,{parts:t,outside:n,gone:a},{gesture:o,name:r,held:l=!1,keep:s=!1}){let i=n?`; outside the instance's parts -${n.removed} +${n.added} lines someone else wrote meanwhile, which stay`:"";return a?{unverified:`${e}, and ${r} holds the instance no more where it stood: someone else wrote the file meanwhile`}:t.length===0?{unverified:`${e}: ${r} is as it was${n?" in the instance's parts":""} (data-block-id aside)${i}`}:l?{unverified:`${e}: what ${r} holds of ${R(t)} is someone else's, which stays${i}`}:s?{unverified:`${e}: ${r} holds what the ${o} wrote, ${R(t)}, kept (--keep)${i}`}:{problem:`${e}, and ${r} holds what the ${o} wrote, ${R(t)}${i}: put that back yourself, ${r} read again first${n?", keeping what someone else wrote":""}`}}function kt(e,t,{over:n,unfocused:a,refusals:o,name:r}){let l=[];return n&&l.push(`the press landed on ${n}, which stands over it there`),a&&l.push(`the element takes no focus (a button, a field or a tabindex), so the key went to ${a}`),t.started&&!t.dropped?l.push(`an HTML5 drag started (dragstart on ${t.started}) and nothing took its drop where it was released (dragend's dropEffect ${t.effect??"none"}): a list a card is dropped on cancels dragenter as well as dragover (preventDefault), or a release as the pointer comes onto it drops nothing`):t.dropped&&t.edits.length===0&&l.push(`it was dropped on ${t.dropped}, and no context.edit came of it`),t.edits.some(({taken:s})=>s)?l.push("context.edit was taken, and its change left what the parts hold as it was"):t.edits.length?l.push(`context.edit was called and the page refused it${o.length?`: the console says ${o.join("; ")}`:""}`):t.started||l.push(`no context.edit came of it: the component answers no ${e} there, or asked while context.canEdit() was false`),`the ${W[e]} wrote nothing to ${r}: ${l.join("; ")}`}async function bt(e,t){let n={own:new Map,others:new Map,dialogs:new Map,pending:[],page:0,from:0},a=new RegExp(`/__gallery/components/${t}/kit\\.js[^:\\s)]*:(\\d+)`),o=(l,s,{at:i="",unparsed:c=!1}={})=>{if(s<n.from)return;let u=l.split(`
|
|
8
|
-
`)[0],p=a.exec(l)??a.exec(i);l.includes(t)||p?n.own.set(u,{line:Number(p?.[1])||null,page:s,unparsed:c&&a.test(i)}):n.others.set(u,{page:s})};e.on("request",l=>{l.isNavigationRequest()&&l.frame()===e.mainFrame()&&(n.page+=1)}),e.on("console",l=>{if(!["error","warn","warning"].includes(l.type())||/^Failed to load resource/.test(l.text()))return;let{page:s}=n;n.pending.push(Promise.all(l.args().map(i=>i.evaluate(c=>c instanceof Error?c.stack:String(c)).catch(()=>""))).then(i=>o(i.join(" ")||l.text(),s)))});let r=await ye(e,{add:l=>n.dialogs.set(l,{page:n.page})});return r.on("Runtime.exceptionThrown",({exceptionDetails:{exception:l,text:s,url:i,lineNumber:c,stackTrace:u}})=>{o(l?.description??String(l?.value??s),n.page,{at:i?`${i}:${c+1}`:"",unparsed:!u&&l?.className==="SyntaxError"})}),await r.send("Runtime.enable"),n}function vt(e){e.from=e.page;for(let t of[e.own,e.others,e.dialogs])for(let[n,{page:a}]of t)a<e.from&&t.delete(n)}var G=e=>Promise.race([Promise.all(e.pending),B(2e3)]);async function xt(e){let t=n=>e.waitForSelector(n,{timeout:V}).catch(a=>{if(a.name==="TimeoutError")throw a;return e.waitForSelector(n,{timeout:V})});try{return await t("[data-doc-ready]"),await t("html[data-ge-editing][data-ge-save]"),await e.waitForFunction(()=>globalThis.__galleryTryEditable===!0&&document.documentElement.getAttribute("data-ge-save")==="saved",{timeout:V}),!0}catch(n){if(n.name!=="TimeoutError")throw n;return!1}}async function Et(e,{at:t,id:n}){let a=await $(e.evaluateHandle(ct,{instance:Se,at:t}),"the page was asked for the instance"),o=await $(a.evaluate((r,{fallback:l,id:s})=>!(r instanceof Element)||r.getAttribute("data-doc-component")!==s?null:(DocKit.reveal?.(r),{fallback:r.hasAttribute(l),height:r.getBoundingClientRect().height}),{fallback:Re,id:n}),"the page was asked for the instance");return o?(await e.setViewport({width:Le,height:Math.min(Ve,Math.max(Ie,Math.ceil(o.height)+240))}),await $(a.evaluate(r=>r.scrollIntoView({block:"center",behavior:"instant"})),"the instance was brought into view"),await $(a.evaluate(wt,{still:pe,step:ge}),"the instance held still"),{host:a,fallback:o.fallback}):null}async function Tt(e){await $(e.evaluate(({instance:t,fields:n})=>{let a=document.activeElement;a instanceof HTMLElement&&a.closest(t)&&a.matches(n)&&a.blur()},{instance:Se,fields:_e}),"the focus left the instance's field"),await e.keyboard.down("Control"),await e.keyboard.press("z"),await e.keyboard.up("Control")}var At=3;async function St(e,{root:t,address:n,at:a,gesture:o,keep:r,file:l,name:s,line:i,found:c,out:u}){let p=await e.createBrowserContext(),h=await p.newPage(),d=await bt(h,c.id),f={problems:[],notes:[]},m=(w,b=`${s}:${i}`)=>f.problems.push({where:b,what:w}),y=W[o.kind],S=new URL(n).origin,k=0,M=0;h.on("request",w=>{!w.isNavigationRequest()||w.frame()!==h.mainFrame()||(k+=1,M=Date.now())});let L=null,N=null,T=async()=>tt(ve(N),ve(await C.readFile(l,"utf8").catch(()=>"")),a,c),A=(w,b,I=!1)=>{let D=yt(w,b,{gesture:y,name:s,held:I,keep:r});return D.problem&&m(D.problem),{...f,unverified:D.unverified}};await h.evaluateOnNewDocument(()=>addEventListener("doc-editable",()=>{globalThis.__galleryTryEditable=!0})),await h.setViewport({width:Le,height:Ie}),await h.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]);try{await $(h.goto(n,{waitUntil:"load",timeout:0}),"the page opened",we);let w=null,b=null;for(let x=1;!w;x++){let g=k;try{if(!await xt(h))return{...f,unverified:`the page did not come to edit in ${V/1e3}s, so nothing was tried`};if(w=await Et(h,{at:a,id:c.id}),!w)return{...f,unverified:`the page does not hold the instance where ${s} has it (${s} changed meanwhile?), so nothing was tried`};if(await B(Math.max(0,await nt(t,l)-Date.now())),w.fallback&&(b=await lt({root:t,id:c.id,origin:S,loadedAt:M,loaded:()=>k!==g})),k!==g)throw new Error("the page loaded itself again");if(w.fallback)break;if(N=await C.readFile(l,"utf8"),await $(w.host.evaluate(ut),"the page was asked to listen"),k!==g)throw new Error("the page loaded itself again")}catch(E){if(k===g||x===At)throw E;w=null,vt(d)}}let{host:I}=w;if(w.fallback){await G(d);let x=[...d.own].map(([g,{line:E,unparsed:De}])=>({words:`${g}${E?` (kit.js:${E})`:""}`,unparsed:De}));return d.own.clear(),m(st(c.id,{said:x.map(({words:g})=>g),unparsed:x.find(({unparsed:g})=>g)?.words??null,...b})),await Ae(I,f,u)}L=k;let D=await mt(h,I,o);f.gesture=D.said;let Z=await Te(h,0,S),Me=await $(h.evaluate(()=>globalThis.__galleryTry),"the page was asked what it heard");await Ae(I,f,u);let O=await T();if(_(Z))return A(`after the ${y}, ${_(Z)}`,O,Z==="held");if(O.gone)return A(`after the ${y}`,O);if(f.others=O.outside,O.parts.length===0){await G(d);let x=[...d.own.keys()].filter(g=>g.includes("context.edit"));for(let g of x)d.own.delete(g);return m(kt(o.kind,Me,{...D,refusals:x,name:s})),f}f.wrote={parts:O.parts,plain:z(N).changes.length>0};for(let{name:x,how:g}of O.parts)g&&f.notes.push({where:`${s}:${i}`,what:`the ${y}'s write lays the part ${x} out anew (${g}): ${me}`});if(!r){let x=await $(h.evaluate(()=>globalThis.__galleryTry.states.length),"the page was asked where saving stands");await Tt(h);let g=await Te(h,x,S),E=await T();if(k>L)return A(`after the ${y}, ${_("reloading")}`,E);if(_(g))return A(`after one Ctrl+Z, ${_(g)}`,E,g==="held");if(E.gone)return A("after one Ctrl+Z",E);g==="unchanged"?m(`one Ctrl+Z wrote nothing, so ${s} keeps what the ${y} wrote: put the part back yourself, ${s} read again first`):E.parts.length?m(`after one Ctrl+Z ${s} is not as it was, ${R(E.parts)} still differing: put that back yourself, ${s} read again first`):f.undone=!0,f.others=E.outside??f.others}return f.others&&(f.unverified=`someone else wrote ${s} meanwhile, outside the instance's parts (the user's page, an Agent), which stays${r?"":": try it again once the file holds still"}`),f}catch(w){if(w instanceof v){if(!w.unfound||(await G(d),d.own.size===0&&d.dialogs.size===0))throw w;return m(`${w.message[0].toLowerCase()}${w.message.slice(1).replace(/\.$/,"")}; its component did not draw it, and the console says why`),f}let b=L===null?null:await T();if(b&&k>L)return A(`after the ${y}, ${_("reloading")}`,b);if(await ke(e)){let I=`the browser went while waiting until ${w.doing??"the page answered"}`;return b?A(I,b):{...f,unverified:`${I}, so nothing was tried`}}return w.stuck?m(`the page stopped answering while waiting until ${w.doing}: a script that never ends, or a component that changes what it hears`,"the page"):m(`the trial stopped: ${J(w)}`,"the page"),b?A(`after the ${y} the trial stopped`,b):f}finally{await G(d);for(let[w,{line:b}]of d.own)f.problems.push({where:b?`kit.js:${b}`:"the page",what:`the console says ${w}`});for(let w of d.others.keys())f.notes.push({where:"the page",what:`the console says ${w}`});for(let w of d.dialogs.keys())f.problems.push({where:"the page",what:`it opened a dialog (${w}), which stops a reader's page until it is answered: show what it says in the instance`});await p.close().catch(()=>{})}}async function Ae(e,t,n){let a=P.join(n,"after.png");try{await $(e.screenshot({path:a}),"the instance was pictured"),t.picture=a}catch(o){if(o.stuck)throw o}return t}var j={gesture:"Gesture: ",wrote:"Wrote: ",undone:"Undone: ",kept:"Kept (--keep): ",picture:"Picture of the instance after the "},Lt="nothing outside the instance changed (data-block-id aside)";function It({slug:e,name:t,gesture:{kind:n},keep:a},o){let r=[];o.gesture&&r.push(`${j.gesture}${o.gesture}`);for(let{where:s,what:i}of o.problems)r.push(` FAIL ${s}: ${i}`);for(let{where:s,what:i}of o.notes)r.push(` note ${s}: ${i}`);if(o.wrote){let s=o.wrote.plain?"; and the page wrote the document's plain HTML as the kit's markup, as its first save of an edit does (gallery check and gallery export say what, by line, once), which stays":"",i=o.others?`; outside the instance's parts -${o.others.removed} +${o.others.added} lines someone else wrote meanwhile (the user's page, an Agent), which stay`:`; ${Lt}`;r.push(`${j.wrote}${R(o.wrote.parts)}${i}${s}`),a?r.push(`${j.kept}${t} holds what it wrote`):o.undone&&r.push(`${j.undone}one Ctrl+Z, and ${o.others?`the instance's parts in ${t} are as they were`:`${t} is as it was`} (data-block-id aside${o.wrote.plain?", its plain HTML the kit's markup":""})`)}o.picture&&r.push(`${j.picture}${W[n]}: ${H(o.picture)}`);let l=o.problems.length;return l?{lines:[...r,`FAIL ${e}: ${l} problem${l===1?"":"s"}`],code:1}:o.unverified?{lines:[...r,`UNVERIFIED ${e}: ${o.unverified}`],code:3}:{lines:[...r,`OK ${e}: the ${W[n]} wrote ${o.wrote.parts.map(({name:s})=>s).join(" and ")}${a?", kept (--keep)":", and one Ctrl+Z took it back"}`],code:0}}async function Kt(e,{named:t,values:n,key:a,keep:o}){let r=await ze(n,a);if(t.length===0)throw new v("Name the document: gallery component try <slug> [<instance id>] and the gesture.");if(t.length>2)throw new v("gallery component try takes a document and an instance's id at most.");let{slug:l,block:s}=await ie(t[0]),i=He(Be(l,e)).html,c=await C.readFile(i,"utf8").catch(()=>null);c===null&&(console.error(`No document "${l}": ${H(i)} does not exist (gallery list lists those there are).`),process.exit(1));let u=Ne(c);u.length===0&&(console.error(`${l} holds no instance of a component package (an element with ${ae}): gallery component list says which there are, and gallery component show <id> how to write one.`),process.exit(1));let p=P.basename(i),h=Xe(u,t[1]??s,{slug:l,name:p}),{id:d,line:f}=u[h],m=Y(e),y=m.packages.get(d);if(!y){let T=m.problems.get(d);console.error(T?.off?`${d} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6: its instances show what they hold, read-only, so a reader can do nothing with them.`:T?`${d} does not load, so its instances show what they hold, read-only: gallery component check ${d} says why.`:`No component ${d} in this workspace, so its instance shows what it holds, read-only: gallery component list says which there are.`),process.exit(1)}console.log(`${d} in ${l}, ${p}:${f}: ${H(i)}`);let S=await de({slug:l,command:`gallery component try ${l}`});if(!S.ok){console.log(`UNVERIFIED ${l}: ${S.message}`),process.exitCode=3;return}let k=ce(S.port,l);console.log(`Page: ${k} (the document's page alone, editable: the Agent's own; the server runs on after this command)`);let M=he();if(!M){console.log(`UNVERIFIED ${l}: no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one), so nothing was tried`),process.exitCode=3;return}let L;try{L=await ue({executablePath:M,args:fe()})}catch(T){console.log(`UNVERIFIED ${l}: the browser ${M} did not start, twice, each time with a fresh profile (${J(T)}; GALLERY_BROWSER=<its executable> picks another), so nothing was tried`),process.exitCode=3;return}let N=P.join(se(e).qa,l,"try");try{await C.rm(N,{recursive:!0,force:!0}),await C.mkdir(N,{recursive:!0});let{lines:T,code:A}=It({slug:l,name:p,gesture:r,keep:o},await St(L.browser,{root:e,address:k,at:h,gesture:r,keep:o,file:i,name:p,line:f,found:y,out:N}));console.log(T.join(`
|
|
9
|
-
`)),process.exitCode=A}finally{await L.close()}}export{Lt as INSIDE_ALONE,j as TRY_LINES,ve as asShown,tt as changesOf,Xe as chosenInstance,yt as cutOffSaid,gt as dragPath,st as fallbackSaid,ze as gestureOf,Ne as instancesIn,Ye as keysOf,bt as listen,kt as nothingSaid,vt as takenAgain,at as takenBy,nt as toldBy,It as trialSaid,Kt as tryCommand,lt as untilTaken,et as withoutIds};
|