@heycys/gallery 0.2.0 → 0.2.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 +1 -1
- package/browser/editor/components/icon/page.mjs +6 -4
- package/browser/editor/components/icons.mjs +2 -2
- package/browser/editor/page/clipboard/import/read.mjs +20 -2
- package/browser/shared/document-copy.mjs +43 -0
- package/browser/shared/drafts.mjs +10 -3
- package/browser/shared/emoji/icon-value.mjs +2 -2
- package/browser/shared/extensions.mjs +83 -7
- package/browser/shared/i18n/en.mjs +10 -0
- package/browser/shared/outline-shape.mjs +6 -0
- package/browser/shared/outline.mjs +135 -10
- package/browser/shared/workspace-columns.mjs +11 -7
- package/dist/{chunk-QE5RG76S.mjs → chunk-2GKGEVMR.mjs} +11 -7
- package/dist/{chunk-HYMEEXKN.mjs → chunk-2RKIHJI2.mjs} +1 -1
- package/dist/{chunk-742D2WWJ.mjs → chunk-36FIRJIF.mjs} +2 -2
- package/dist/{chunk-EAIFITAV.mjs → chunk-3A5I2GJK.mjs} +1 -1
- package/dist/{chunk-7JDX4E65.mjs → chunk-3OFXMN6N.mjs} +1 -1
- package/dist/chunk-46ACXOU5.mjs +2 -0
- package/dist/{chunk-PUOQ65NC.mjs → chunk-4AMTKWDO.mjs} +1 -1
- package/dist/{chunk-HPOI4ZX7.mjs → chunk-4DNHHJSL.mjs} +1 -1
- package/dist/chunk-5DPABPBI.mjs +2 -0
- package/dist/{chunk-ALZ6ZENZ.mjs → chunk-5IIH335D.mjs} +1 -1
- package/dist/{chunk-EP25HDAJ.mjs → chunk-5L26JUYA.mjs} +1 -1
- package/dist/{chunk-FDMAXMQA.mjs → chunk-5MEXZ2UF.mjs} +1 -1
- package/dist/{chunk-ZHEHPMBK.mjs → chunk-6MPKCH3P.mjs} +1 -1
- package/dist/{chunk-C564NU2H.mjs → chunk-74RPP2M2.mjs} +1 -1
- package/dist/{chunk-YNAWBAYN.mjs → chunk-7M7UPWU6.mjs} +1 -1
- package/dist/{chunk-YROX2O22.mjs → chunk-7N2LPG33.mjs} +1 -1
- package/dist/{chunk-VS7JIGJW.mjs → chunk-7XDYK3UC.mjs} +1 -1
- package/dist/chunk-AEMVZYZQ.mjs +166 -0
- package/dist/{chunk-TR7TWGHB.mjs → chunk-AFGUR7SY.mjs} +1 -1
- package/dist/{chunk-K5XATEOO.mjs → chunk-AMDGVDNV.mjs} +1 -1
- package/dist/{chunk-JA7G53PC.mjs → chunk-ASAXY2DJ.mjs} +1 -1
- package/dist/{chunk-W7665ZEC.mjs → chunk-BYSF5UMM.mjs} +2 -2
- package/dist/{chunk-U3SSPL4K.mjs → chunk-CCSGFCLZ.mjs} +1 -1
- package/dist/{chunk-JLTZF4LA.mjs → chunk-CG3UHDKH.mjs} +1 -1
- package/dist/{chunk-YLPSMDIS.mjs → chunk-CPS4SRPF.mjs} +2 -2
- package/dist/{chunk-AHN3NFKJ.mjs → chunk-CZ5KJSGK.mjs} +1 -1
- package/dist/chunk-DAMVDXR3.mjs +2 -0
- package/dist/{chunk-WQDQWCX5.mjs → chunk-DH6GMDNN.mjs} +1 -1
- package/dist/{chunk-U5XL7D6A.mjs → chunk-DHB7UZ7F.mjs} +1 -1
- package/dist/{chunk-OEXWRJME.mjs → chunk-DKR7LFIY.mjs} +1 -1
- package/dist/chunk-DLFZJJEE.mjs +2 -0
- package/dist/{chunk-DJISHPUL.mjs → chunk-FCK6NXON.mjs} +1 -1
- package/dist/{chunk-IV64FFI4.mjs → chunk-FX42XU6J.mjs} +1 -1
- package/dist/{chunk-FETSREUN.mjs → chunk-FXQBADMN.mjs} +1 -1
- package/dist/{chunk-BFJGHSQN.mjs → chunk-G4YP7GVC.mjs} +1 -1
- package/dist/{chunk-V6XZ4VIR.mjs → chunk-GWOYMENX.mjs} +1 -1
- package/dist/chunk-HATA2W7X.mjs +2 -0
- package/dist/{chunk-YI43RG4P.mjs → chunk-HBAUKKQH.mjs} +1 -1
- package/dist/{chunk-MAFIGVXY.mjs → chunk-HM4E43VM.mjs} +1 -1
- package/dist/{chunk-OFHXGWOX.mjs → chunk-JI6T3A4Y.mjs} +1 -1
- package/dist/{chunk-5XA2ZBAE.mjs → chunk-JJNRIFND.mjs} +2 -2
- package/dist/chunk-JL6R4FG4.mjs +4 -0
- package/dist/{chunk-UMHUSOPJ.mjs → chunk-JXLSHVJ2.mjs} +1 -1
- package/dist/{chunk-VFX2KNHP.mjs → chunk-KFZBYDIS.mjs} +1 -1
- package/dist/{chunk-ZTHICSSF.mjs → chunk-KH24LWAT.mjs} +1 -1
- package/dist/{chunk-GHOYKMQ3.mjs → chunk-KUILYI7H.mjs} +1 -1
- package/dist/{chunk-5K44HLTZ.mjs → chunk-L7W624FD.mjs} +1 -1
- package/dist/{chunk-J5PUIV3Y.mjs → chunk-LE44MD3O.mjs} +1 -1
- package/dist/{chunk-4K5KC6V2.mjs → chunk-LV24RY2E.mjs} +1 -1
- package/dist/{chunk-43B75J5T.mjs → chunk-MKTX5PGV.mjs} +1 -1
- package/dist/{chunk-LKX55H76.mjs → chunk-NAGMRVW4.mjs} +1 -1
- package/dist/{chunk-DAZL73VK.mjs → chunk-NFABH3QW.mjs} +2 -2
- package/dist/{chunk-U7NZI6N4.mjs → chunk-NIW7F7LU.mjs} +2 -2
- package/dist/{chunk-PAREWQGB.mjs → chunk-NWRZXELO.mjs} +1 -1
- package/dist/{chunk-ZWWC4KLF.mjs → chunk-OU3S466R.mjs} +1 -1
- package/dist/{chunk-MN7BZL4R.mjs → chunk-PAFSFVYB.mjs} +1 -1
- package/dist/chunk-QCEATQC4.mjs +2 -0
- package/dist/{chunk-Y34NR5JL.mjs → chunk-QJ3TFJLQ.mjs} +1 -1
- package/dist/{chunk-IA4PSIMD.mjs → chunk-QK3VISCA.mjs} +1 -1
- package/dist/{chunk-7OG26PGF.mjs → chunk-QXVNUASA.mjs} +1 -1
- package/dist/{chunk-GRAXKKG4.mjs → chunk-QZ35UAB4.mjs} +1 -1
- package/dist/{chunk-AR5D57ZD.mjs → chunk-S2Y7VI4H.mjs} +2 -2
- package/dist/{chunk-HXG7EOPJ.mjs → chunk-SAHS56QM.mjs} +1 -1
- package/dist/{chunk-3MBRL2PM.mjs → chunk-SOD23RGL.mjs} +1 -1
- package/dist/chunk-TDWJKOLN.mjs +2 -0
- package/dist/{chunk-ITOH5EGO.mjs → chunk-TOE6DPLH.mjs} +1 -1
- package/dist/chunk-UGO5N3EI.mjs +15 -0
- package/dist/{chunk-4OKWZY5E.mjs → chunk-V5JRSGZF.mjs} +1 -1
- package/dist/{chunk-BZ5RAF7L.mjs → chunk-VA3KAQZD.mjs} +1 -1
- package/dist/{chunk-HDWTZ763.mjs → chunk-VG5JEIUQ.mjs} +1 -1
- package/dist/{chunk-POTA2FV4.mjs → chunk-VGTMLQWZ.mjs} +1 -1
- package/dist/{chunk-UYVCQK3H.mjs → chunk-VKSRM7EY.mjs} +1 -1
- package/dist/{chunk-ZDLPUOAG.mjs → chunk-VNUWREXU.mjs} +1 -1
- package/dist/{chunk-AGDILNWB.mjs → chunk-VPVOAJ7X.mjs} +1 -1
- package/dist/{chunk-CMA72MAG.mjs → chunk-WCWYNFDF.mjs} +1 -1
- package/dist/{chunk-ZQS6H473.mjs → chunk-WTEGUPFG.mjs} +1 -1
- package/dist/{chunk-R2ZDLJYT.mjs → chunk-XKOHV4H6.mjs} +1 -1
- package/dist/{chunk-MXUBKDRO.mjs → chunk-XMKHCUI6.mjs} +1 -1
- package/dist/{chunk-67N2QJYT.mjs → chunk-XQRUG4G3.mjs} +1 -1
- package/dist/{chunk-PGDE24N5.mjs → chunk-YBB5LWZK.mjs} +1 -1
- package/dist/{chunk-6N3PX4XX.mjs → chunk-YFJU3O7G.mjs} +1 -1
- package/dist/chunk-YPPJVDQI.mjs +2 -0
- package/dist/chunk-ZANMKAWS.mjs +2 -0
- package/dist/{chunk-6QBHU4DF.mjs → chunk-ZCP7BTOZ.mjs} +1 -1
- package/dist/{chunk-ERLAIBOA.mjs → chunk-ZEY2RLBT.mjs} +2 -2
- package/dist/{chunk-SQ6Y2ZMA.mjs → chunk-ZO7SFB2E.mjs} +2 -2
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/worker.mjs +1 -1
- package/kit/math.js +1 -1
- package/kit/report.css +3 -3
- package/package.json +1 -1
- package/release.json +5 -5
- package/skill/SKILL.md +8 -7
- package/skill/references/extensions.md +11 -7
- package/web/assets/index-BHC5ZOMh.js +15 -0
- package/web/assets/index-xP0uw3a0.css +1 -0
- package/web/index.html +2 -2
- package/dist/chunk-6KBYRA2C.mjs +0 -2
- package/dist/chunk-F6HVDZR4.mjs +0 -2
- package/dist/chunk-J43Z6LSS.mjs +0 -2
- package/dist/chunk-JZT7I2OJ.mjs +0 -2
- package/dist/chunk-L2SUIS5S.mjs +0 -2
- package/dist/chunk-L7UP52JO.mjs +0 -2
- package/dist/chunk-LM4XFQHZ.mjs +0 -2
- package/dist/chunk-MTYYHM2G.mjs +0 -15
- package/dist/chunk-NAMN3RAF.mjs +0 -2
- package/dist/chunk-ORID3AE7.mjs +0 -166
- package/dist/chunk-SWUTTZCN.mjs +0 -2
- package/dist/chunk-UJQJKNGK.mjs +0 -2
- package/web/assets/index-BM_K-Auu.css +0 -1
- package/web/assets/index-DRslOBiv.js +0 -15
- /package/dist/{chunk-YEY3RSFQ.mjs → chunk-5MMN3N5J.mjs} +0 -0
- /package/dist/{chunk-UH4SIXTR.mjs → chunk-74UW7QSL.mjs} +0 -0
- /package/dist/{chunk-W7XHE4CT.mjs → chunk-EKGYYOSP.mjs} +0 -0
- /package/dist/{chunk-QAIHRH3I.mjs → chunk-KNZJT4ET.mjs} +0 -0
- /package/dist/{chunk-A55HN5OK.mjs → chunk-N3DSBH5S.mjs} +0 -0
- /package/dist/{chunk-QR6A54KJ.mjs → chunk-ZW2A6GBW.mjs} +0 -0
|
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { iconKind } from "./emoji/icon-value.mjs";
|
|
4
4
|
import { isWorkspace, readRegistry, workspaceId, workspaceKey } from "./workspace-registry.mjs";
|
|
5
|
-
import { defaultWorkspace, documentFiles, isSlugName } from "./workspace.mjs";
|
|
5
|
+
import { defaultWorkspace, documentFiles, isSlugName, readLink } from "./workspace.mjs";
|
|
6
6
|
|
|
7
7
|
// The other workspaces a workspace's sidebar shows a column of (notes/plans/workspaces-links-plan-2026-11-08.md
|
|
8
8
|
// §7.2; docs/workbench.md "Columns"): every workspace of the machine's registry (./workspace-registry.mjs) but
|
|
@@ -13,8 +13,8 @@ import { defaultWorkspace, documentFiles, isSlugName } from "./workspace.mjs";
|
|
|
13
13
|
// as its own sidebar has them) and the place of its documents no column holds; the user's order of the
|
|
14
14
|
// columns is the outline's after that.
|
|
15
15
|
//
|
|
16
|
-
// What a workspace's sidebar is read with (snapshotOf): its documents in its
|
|
17
|
-
//
|
|
16
|
+
// What a workspace's sidebar is read with (snapshotOf): its documents and links in its former local order,
|
|
17
|
+
// their same-workspace parents, and what their doc.json or link.json
|
|
18
18
|
// says (title, description, an icon of the emoji or 图标 kind: no picture of another workspace's folder). It is
|
|
19
19
|
// read from its files, never written, and kept SNAPSHOT_KEPT ms at most, so that the reads of a burst (a
|
|
20
20
|
// command and the workbench's read after it, the list of 添加其他 Gallery 项目…) read each folder once while a
|
|
@@ -90,19 +90,19 @@ async function read(root, readOwn) {
|
|
|
90
90
|
const documents = new Set();
|
|
91
91
|
const order = [];
|
|
92
92
|
const parentOf = new Map();
|
|
93
|
-
//
|
|
94
|
-
const
|
|
93
|
+
// Own documents and links; another workspace's reference is not a second file here.
|
|
94
|
+
const isEntry = (key) => !key.startsWith("~") && isSlugName(key);
|
|
95
95
|
const parentIn = (child) => {
|
|
96
96
|
for (const [key, list] of Object.entries(own.children)) if (list.includes(child)) return key;
|
|
97
97
|
return null;
|
|
98
98
|
};
|
|
99
99
|
const above = (slug) => {
|
|
100
100
|
let up = parentIn(slug);
|
|
101
|
-
while (up !== null && !(up === "" || up.startsWith(":")) && !
|
|
101
|
+
while (up !== null && !(up === "" || up.startsWith(":")) && !isEntry(up)) up = parentIn(up);
|
|
102
102
|
return up === null || up === "" || up.startsWith(":") ? null : up;
|
|
103
103
|
};
|
|
104
104
|
const walk = (key) => (own.children[key] ?? []).forEach((slug) => {
|
|
105
|
-
if (
|
|
105
|
+
if (isEntry(slug) && !documents.has(slug)) {
|
|
106
106
|
documents.add(slug);
|
|
107
107
|
order.push(slug);
|
|
108
108
|
parentOf.set(slug, above(slug));
|
|
@@ -111,6 +111,10 @@ async function read(root, readOwn) {
|
|
|
111
111
|
});
|
|
112
112
|
for (const { id } of own.groups) walk(id === "docs" ? "" : `:${id}`);
|
|
113
113
|
const facts = new Map(await Promise.all(order.map(async (slug) => {
|
|
114
|
+
if (own.links.includes(slug)) {
|
|
115
|
+
const link = await readLink(path.join(root, slug));
|
|
116
|
+
return [slug, { ...link, kind: "link", title: link?.title ?? slug, description: "", path: path.join(root, slug, "link.json") }];
|
|
117
|
+
}
|
|
114
118
|
const files = documentFiles(path.join(root, slug));
|
|
115
119
|
const metadata = await fs.readFile(files.json, "utf8").then((text) => JSON.parse(text.replace(/^/, "")), () => null);
|
|
116
120
|
const value = metadata && typeof metadata === "object" && !Array.isArray(metadata) ? metadata : {};
|
|
@@ -204,19 +204,23 @@ remove moves it to the trash, which the workbench's \u8BBE\u7F6E \u203A \u56DE\u
|
|
|
204
204
|
Each is written through the workspace's running server when there is one (an open workbench shows it
|
|
205
205
|
at once), else here.
|
|
206
206
|
Exits 1 when a link, a column or an entry named is not there or the server refuses it; 2 for an
|
|
207
|
-
address that is not http or https, an empty name, or two places at once.`,extension:`Usage: gallery extension
|
|
207
|
+
address that is not http or https, an empty name, or two places at once.`,extension:`Usage: gallery extension new <id> "<title>" [--local]
|
|
208
|
+
gallery extension list
|
|
208
209
|
gallery extension check <id>
|
|
209
210
|
An extension (\u6269\u5C55) gives the sidebar a column of entries of its own, beside \u6587\u6863: a folder
|
|
210
211
|
<workspace>/extensions/<id>/ whose sidebar.json lists them (a title, an optional icon, and entries each with
|
|
211
212
|
an id, a title, an optional address (http or https), an optional icon and optional children). The workbench
|
|
212
213
|
reads the file again within a second of every change; a click on an entry with an address opens that page beside
|
|
213
214
|
the sidebar (as a web link's), one without opens and closes what is under it. The user may drag the column to
|
|
214
|
-
another place
|
|
215
|
-
shows the column with one row, \u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A<why>.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
another place, rename it and reorder its root entries; title/order edits write back to sidebar.json.
|
|
216
|
+
A file that does not read shows the column with one row, \u6761\u76EE\u8BFB\u4E0D\u51FA\u6765\uFF1A<why>.
|
|
217
|
+
new creates an empty sidebar.json in the DEFAULT workspace, shared by every project's sidebar. Add --local
|
|
218
|
+
to create it only in the selected workspace (--workspace still selects the project). Existing files are never
|
|
219
|
+
overwritten. Read the printed file and fill its entries (references/extensions.md in the skill says how).
|
|
220
|
+
Every sidebar reads the default workspace's extensions plus its own. A project sidebar.json with the same id
|
|
221
|
+
takes precedence in that project; an empty folder does not. No files are copied or moved automatically.
|
|
222
|
+
list prints the visible extensions, their source paths, titles and entry counts, or why they show none.
|
|
223
|
+
check <id> resolves the same public/project source as the sidebar and prints what the sidebar will show:
|
|
220
224
|
the column, then each entry with its id, title and address, one under another indented; notes (an icon that
|
|
221
225
|
is no emoji and no icon of the \u56FE\u6807 tab, which is left out) follow. Writes nothing.
|
|
222
226
|
Exits 0 when the file reads; 1 when the extension is not there, has no sidebar.json or its file does not
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{b as n,e as c}from"./chunk-
|
|
2
|
+
import{b as n,e as c}from"./chunk-N3DSBH5S.mjs";c();var f=e=>n(e.replace(/^\uFEFF/," "),{sourceCodeLocationInfo:!0}),i=(e,o)=>e.slice(o.sourceCodeLocation.startOffset,o.sourceCodeLocation.endOffset);function a(e,o){let r=1;for(let t=e.indexOf(`
|
|
3
3
|
`);t!==-1&&t<o;t=e.indexOf(`
|
|
4
4
|
`,t+1))r++;return r}export{f as a,i as b,a as c};
|
|
@@ -10,10 +10,10 @@ Error cause: ${lt(e)?e.stack:e}`)}this.#w()}#x(e){let r=Qt.createInterface(e),o=
|
|
|
10
10
|
`)))};this.#t.on("exit",i),this.#t.on("error",i);let n=r>0?setTimeout(c,r):void 0;this.#h.on("line",d);let l=()=>{clearTimeout(n),this.#h.off("line",d),this.#t.off("exit",i),this.#t.off("error",i)};function c(){l(),a(new te(`Timed out after ${r} ms while waiting for the WS endpoint URL to appear in stdout!`))}for(let f of this.#n)d(f);function d(f){let p=f.match(e);p&&(l(),o(p[1]))}})}},rr=`Puppeteer was unable to kill the process which ran the browser binary.
|
|
11
11
|
This means that, on future Puppeteer launches, Puppeteer might not be able to launch the browser.
|
|
12
12
|
Please check your open processes and ensure that the browser processes that Puppeteer launched have been killed.
|
|
13
|
-
If you think this is a bug, please report it on the Puppeteer issue tracker.`;function or(t){try{return process.kill(t,0)}catch(e){if(ar(e)&&e.code&&e.code==="ESRCH")return!1;throw e}}function lt(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function ar(t){return lt(t)&&("errno"in t||"code"in t||"path"in t||"syscall"in t)}var te=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor)}};import gr from"node:assert";import{spawnSync as Ne}from"node:child_process";import{existsSync as A,readFileSync as Cr}from"node:fs";import{mkdir as mt,unlink as Rr}from"node:fs/promises";import L from"node:os";import H from"node:path";var S=class{#e;constructor(e){this.#e=e}supports(e){return!0}getDownloadUrl(e){return this.#r(e.browser,e.platform,e.buildId)}#r(e,r,o){return new URL(K[e](r,o,this.#e))}getExecutablePath(e){return U[e.browser](e.platform,e.buildId)}getName(){return"DefaultProvider"}};import{spawnSync as sr,spawn as ir,execFile as nr}from"node:child_process";import{constants as lr,createReadStream as cr,createWriteStream as ur}from"node:fs";import{mkdir as oe,readdir as hr,symlink as dr}from"node:fs/promises";import*as v from"node:path";import{Stream as fr,Writable as mr}from"node:stream";import{pipeline as ct}from"node:stream/promises";import{promisify as De}from"node:util";var M=De(nr);async function ht(t,e,r){if(v.isAbsolute(e)||(e=v.resolve(process.cwd(),e)),t.endsWith(".zip"))await oe(e,{recursive:!0}),await xr(t,e,r);else if(t.endsWith(".tar.bz2"))await ut(t,e,"bzip2",r);else if(t.endsWith(".dmg"))await oe(e),await br(t,e);else if(t.endsWith(".exe")){let o=sr(t,[`/ExtractDir=${e}`],{env:{__compat_layer:"RunAsInvoker"}});if(o.status!==0)throw new Error(`Failed to extract ${t} to ${e}: ${o.output}`)}else if(t.endsWith(".tar.xz"))await ut(t,e,"xz");else throw new Error(`Unsupported archive format: ${t}`)}function pr(t){let e=new fr.Transform({transform(r,o,a){t.stdin.write(r,o)?a():t.stdin.once("drain",a)},flush(r){t.stdout.destroyed?r():(t.stdin.end(),t.stdout.on("close",r))}});return t.stdin.on("error",r=>{"code"in r&&r.code==="EPIPE"?e.emit("end"):e.destroy(r)}),t.stdout.on("data",r=>e.push(r)).on("error",r=>e.destroy(r)),t.once("close",()=>e.end()),e}var wr={xz:"xz",bzip2:"bzip2"};async function ut(t,e,r,o){let{unpackTar:a}=await import("./chunk-
|
|
13
|
+
If you think this is a bug, please report it on the Puppeteer issue tracker.`;function or(t){try{return process.kill(t,0)}catch(e){if(ar(e)&&e.code&&e.code==="ESRCH")return!1;throw e}}function lt(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function ar(t){return lt(t)&&("errno"in t||"code"in t||"path"in t||"syscall"in t)}var te=class extends Error{constructor(e){super(e),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor)}};import gr from"node:assert";import{spawnSync as Ne}from"node:child_process";import{existsSync as A,readFileSync as Cr}from"node:fs";import{mkdir as mt,unlink as Rr}from"node:fs/promises";import L from"node:os";import H from"node:path";var S=class{#e;constructor(e){this.#e=e}supports(e){return!0}getDownloadUrl(e){return this.#r(e.browser,e.platform,e.buildId)}#r(e,r,o){return new URL(K[e](r,o,this.#e))}getExecutablePath(e){return U[e.browser](e.platform,e.buildId)}getName(){return"DefaultProvider"}};import{spawnSync as sr,spawn as ir,execFile as nr}from"node:child_process";import{constants as lr,createReadStream as cr,createWriteStream as ur}from"node:fs";import{mkdir as oe,readdir as hr,symlink as dr}from"node:fs/promises";import*as v from"node:path";import{Stream as fr,Writable as mr}from"node:stream";import{pipeline as ct}from"node:stream/promises";import{promisify as De}from"node:util";var M=De(nr);async function ht(t,e,r){if(v.isAbsolute(e)||(e=v.resolve(process.cwd(),e)),t.endsWith(".zip"))await oe(e,{recursive:!0}),await xr(t,e,r);else if(t.endsWith(".tar.bz2"))await ut(t,e,"bzip2",r);else if(t.endsWith(".dmg"))await oe(e),await br(t,e);else if(t.endsWith(".exe")){let o=sr(t,[`/ExtractDir=${e}`],{env:{__compat_layer:"RunAsInvoker"}});if(o.status!==0)throw new Error(`Failed to extract ${t} to ${e}: ${o.output}`)}else if(t.endsWith(".tar.xz"))await ut(t,e,"xz");else throw new Error(`Unsupported archive format: ${t}`)}function pr(t){let e=new fr.Transform({transform(r,o,a){t.stdin.write(r,o)?a():t.stdin.once("drain",a)},flush(r){t.stdout.destroyed?r():(t.stdin.end(),t.stdout.on("close",r))}});return t.stdin.on("error",r=>{"code"in r&&r.code==="EPIPE"?e.emit("end"):e.destroy(r)}),t.stdout.on("data",r=>e.push(r)).on("error",r=>e.destroy(r)),t.once("close",()=>e.end()),e}var wr={xz:"xz",bzip2:"bzip2"};async function ut(t,e,r,o){let{unpackTar:a}=await import("./chunk-ZW2A6GBW.mjs");return await new Promise((i,n)=>{function l(f){return p=>{"code"in p&&p.code==="ENOENT"&&(p=new Error(`\`${f}\` utility is required to unpack this archive`,{cause:p})),n(p)}}let c=ir(wr[r],["-d"],{stdio:["pipe","pipe","inherit"]}).once("error",l(r)).once("exit",f=>{o?.(b.fileUtil)?.(`${r} exited, code=${f}`)}),d=a(e);d.once("error",l("tar")),d.once("finish",i),cr(t).pipe(pr(c)).pipe(d)})}async function br(t,e){let{stdout:r}=await M("hdiutil",["attach","-nobrowse","-noautoopen",t]),o=r.match(/\/Volumes\/(.*)/m);if(!o)throw new Error(`Could not find volume path in ${r}`);let a=o[0];try{let n=(await hr(a)).find(c=>typeof c=="string"&&c.endsWith(".app"));if(!n)throw new Error(`Cannot find app in ${a}`);let l=v.join(a,n);await M("cp",["-R",l,e])}finally{await M("hdiutil",["detach",a,"-quiet"])}}var j=class extends Error{};async function xr(t,e,r){for(let o of[Ir,Er])try{await o(t,e,r);return}catch(a){if(!(a instanceof j))throw a}throw new Error("Extraction failed: no zip archiver is available. Install `unzip` (or `tar.exe`/Powershell on Windows), or add the optional `yauzl` dependency.")}async function Er(t,e,r){let{default:o}=await import("yauzl").catch(()=>{throw new j("Extraction failed: The optional `yauzl` dependency is not installed.")}),a=De(o.open);try{let i=await a(t,{lazyEntries:!0});await new Promise((n,l)=>{i.on("error",l).on("end",n).on("entry",c=>{yr(i,c,e).then(()=>{i.readEntry()},l)}).readEntry()})}catch(i){throw new Error(`Extraction failed: ${t}`,{cause:i})}}async function Ir(t,e,r){try{if(process.platform==="win32"){let o=process.env.SystemRoot??process.env.SYSTEMROOT??"C:\\Windows";try{let a=`${o}\\System32\\tar.exe`;await M(a,["-xf",t,"-C",e]);return}catch(a){r?.(b.fileUtil)?.(`tar.exe extraction failed: ${a}`)}try{await M("powershell.exe",["-NoProfile","-NonInteractive","-Command","& { Expand-Archive -LiteralPath $args[0] -DestinationPath $args[1] -Force }",t,e]);return}catch(a){r?.(b.fileUtil)?.(`powershell.exe extraction failed: ${a}`)}await M("pwsh.exe",["-NoProfile","-NonInteractive","-Command","& { Expand-Archive -LiteralPath $args[0] -DestinationPath $args[1] -Force }",t,e])}else await M("unzip",["-o",t,"-d",e])}catch(o){throw o?.code==="ENOENT"?new j("Extraction failed: Required native binary ('tar.exe', 'powershell.exe', 'pwsh.exe' or 'unzip') was not found in the system PATH."):new Error(`Extraction failed: ${o?.stderr?.toString()||o?.message}`)}}function vr(t,e){let r=v.resolve(t),o=v.resolve(e);return o===r||o.startsWith(r+v.sep)}async function yr(t,e,r){let{S_IFMT:o,S_IFDIR:a,S_IFLNK:i}=lr,n=e.externalFileAttributes>>>16,l=(n&o)===a||e.fileName.endsWith("/")||e.versionMadeBy>>8===0&&e.externalFileAttributes===16,c=(n&o)===i,d=n===0?l?493:420:n&511,f=v.join(r,e.fileName);if(l){await oe(f,{recursive:!0,mode:d});return}await oe(v.dirname(f),{recursive:!0});let p=await De(t.openReadStream.bind(t))(e);if(c){let E=[];await ct(p,new mr({write(Te,Wr,It){Te instanceof Buffer&&E.push(Te),It()}}));let P=Buffer.concat(E).toString(),Et=v.resolve(v.dirname(f),P);if(!vr(r,Et))throw new Error(`Zip symlink "${e.fileName}" would point outside of the target directory.`);await dr(P,f);return}await ct(p,ur(f,{mode:d}))}var V=null,ae=class t{#e;#r=0;#o=0;#t=[];#s=!1;#a=0;#i=!1;constructor(e){this.#e=e}static createBarTicker(e,r,o=process.stderr){return(!V||V.#e!==o)&&(V=new t(o)),V.#n(e,r)}#c(){let e=this.#r++;return e>0&&this.#e.isTTY&&this.#e.write(`
|
|
14
14
|
`),e}#n(e,r){let o=this.#c();this.#t.push({title:e,total:r,downloaded:0,startTime:0,lastRendered:""});let a=!1;return i=>{let n=this.#t[o];n.startTime===0&&(n.startTime=Date.now()),n.downloaded+=i;let l=n.downloaded>=n.total;(l||Date.now()-this.#a>=100)&&this.#u(),l&&!a&&(a=!0,this.#l())}}#u(){this.#s||(this.#s=!0,queueMicrotask(()=>{this.#s=!1,this.#a=Date.now(),this.#d()}))}#h(e){let r=this.#t[e],o=Math.min(1,Math.max(0,r.downloaded/r.total)),a=Math.round(o*100),i=r.startTime>0?Date.now()-r.startTime:0,n=i>0?r.downloaded/i:0,l=n>0?(r.total-r.downloaded)/n/1e3:0,c=20,d=Math.round(c*o),f="=".repeat(d)+" ".repeat(c-d),p=o>=1?"unpacking":`${a}% ${l.toFixed(1)}s`;return`${r.title} [${f}] ${p} `}#d(){if(!this.#e.isTTY)return;let e=this.#r;if(e!==0){e>1&&this.#e.moveCursor(0,-(e-1));for(let r=0;r<e;r++){let o=this.#h(r);o!==this.#t[r].lastRendered&&(this.#e.cursorTo(0),this.#e.write(o),this.#e.clearLine(1),this.#t[r].lastRendered=o),r<e-1&&this.#e.moveCursor(0,1)}this.#e.cursorTo(0),this.#i&&(V=null,this.#e.write(`
|
|
15
15
|
`))}}#l(){this.#o++,this.#o>=this.#r&&this.#r>0&&(this.#i=!0)}};var pt=new Map;function se(t){pt.set(t,process.hrtime())}function ie(t,e){let r=process.hrtime(),o=pt.get(t);if(!o)return;let a=r[0]*1e3+r[1]/1e6-(o[0]*1e3+o[1]/1e6);e?.(b.install)?.(`Duration for ${t}: ${a}ms`)}var B=class extends Error{};async function Sr(t){if(!t.platform)throw new Error("Platform must be defined");let e=t.logger,o=new C(t.cacheDir,t.logger).browserRoot(t.browser),a=[...t.providers||[]];t.baseUrl&&a.push(new S(t.baseUrl)),(!t.baseUrl||t.forceFallbackForTesting)&&a.push(new S);let i={browser:t.browser,platform:t.platform,buildId:t.buildId,progressCallback:t.downloadProgressCallback==="default"?await wt(t.browser,t.buildIdAlias??t.buildId):t.downloadProgressCallback},n=[];for(let d of a)try{if(!await d.supports(i)){e?.(b.install)?.(`Provider ${d.getName()} does not support ${t.browser} on ${t.platform}`);continue}d instanceof S||(e?.(b.install)?.(`\u26A0\uFE0F Using custom downloader: ${d.getName()}`),e?.(b.install)?.("\u26A0\uFE0F Puppeteer does not guarantee compatibility with non-default providers")),e?.(b.install)?.(`Trying provider: ${d.getName()} for ${t.browser} ${t.buildId}`);let f=await d.getDownloadUrl(i);if(!f){e?.(b.install)?.(`Provider ${d.getName()} returned no URL for ${t.browser} ${t.buildId}`);continue}return e?.(b.install)?.(`Successfully got URL from ${d.getName()}: ${f}`),A(o)||await mt(o,{recursive:!0}),await Ar(f,t,d,e)}catch(f){e?.(b.install)?.(`Provider ${d.getName()} failed: ${f.message}`),n.push({providerName:d.getName(),error:f})}let l=n.map(d=>` - ${d.providerName}: ${d.error.message}`).join(`
|
|
16
16
|
`),c=`All providers failed for ${t.browser} ${t.buildId}:
|
|
17
17
|
${l}`;throw n.length>0&&n.every(d=>d.error instanceof B)?new B(c):new Error(c)}async function Le(t){if(t.platform??=y(),t.unpack??=!0,t.logger??=J,!t.platform)throw new Error(`Cannot download a binary for the provided platform: ${L.platform()} (${L.arch()})`);return t.providers??=[],await Sr(t)}async function dt(t,e){if(process.platform!=="linux"||t.platform!==s.LINUX&&t.platform!==s.LINUX_ARM)return;let r=H.join(H.dirname(t.executablePath),"deb.deps");if(!A(r)){e?.(b.install)?.(`deb.deps file was not found at ${r}`);return}let o=Cr(r,"utf-8").split(`
|
|
18
|
-
`).join(",");if(process.getuid?.()!==0)throw new Error("Installing system dependencies requires root privileges");let a=Ne("apt-get",["-v"]);if(a.status!==0)throw new Error("Failed to install system dependencies: apt-get does not seem to be available");if(e?.(b.install)?.(`Trying to install dependencies: ${o}`),a=Ne("apt-get",["satisfy","-y",o,"--no-install-recommends"]),a.status!==0)throw new Error(`Failed to install system dependencies: status=${a.status},error=${a.error},stdout=${a.stdout.toString("utf8")},stderr=${a.stderr.toString("utf8")}`);e?.(b.install)?.(`Installed system dependencies ${o}`)}async function Ar(t,e,r,o){if(!r)throw new Error("Provider is required for installation");if(e.platform??=y(),!e.platform)throw new Error(`Cannot download a binary for the provided platform: ${L.platform()} (${L.arch()})`);let a=e.downloadProgressCallback;a==="default"&&(a=await wt(e.browser,e.buildIdAlias??e.buildId));let i=decodeURIComponent(t.toString()).split("/").pop();gr(i,`A malformed download URL was found: ${t}.`);let n=new C(e.cacheDir,e.logger),l=n.browserRoot(e.browser),c=H.join(l,`${e.buildId}-${i}`);if(A(l)||await mt(l,{recursive:!0}),e.expectedHash&&o?.(b.install)?.(`Using provided checksum for ${i}: ${e.expectedHash}`),!e.unpack)return A(c)||(o?.(b.install)?.(`Downloading binary from ${t}`),se("download"),await le(t,c,a,e.expectedHash),ie("download",o)),c;let d=n.installationDir(e.browser,e.platform,e.buildId),f=await r.getExecutablePath({browser:e.browser,buildId:e.buildId,platform:e.platform});o?.(b.install)?.(`Using executable path from provider: ${f}`);let p=new _(n,e.browser,e.buildId,e.platform);r instanceof S||n.writeExecutablePath(e.browser,e.platform,e.buildId,f);try{if(A(d)){if(!A(p.executablePath))throw new B(`The browser folder (${d}) exists but the executable (${p.executablePath}) is missing. An earlier install of this build probably did not finish. Delete ${d} and install the browser again.`);return await ft(p,o),e.installDeps&&await dt(p,o),p}if(A(c))o?.(b.install)?.(`Using existing archive at ${c}`);else{o?.(b.install)?.(`Downloading binary from ${t}`);try{se("download"),await le(t,c,a,e.expectedHash)}finally{ie("download",o)}}o?.(b.install)?.(`Installing ${c} to ${d}`);try{se("extract"),await ht(c,d,e.logger)}finally{ie("extract",o)}if(e.buildIdAlias){let E=p.readMetadata();E.aliases[e.buildIdAlias]=e.buildId,p.writeMetadata(E)}return await ft(p,o),e.installDeps&&await dt(p,o),p}finally{A(c)&&await Rr(c)}}async function ft(t,e){if((t.platform===s.WIN32||t.platform===s.WIN64)&&t.browser===u.CHROME&&t.platform===y())try{se("permissions");let r=H.dirname(t.executablePath),o=H.join(r,"setup.exe");if(!A(o))return;Ne(H.join(r,"setup.exe"),["--configure-browser-in-directory="+r],{shell:!1})}finally{ie("permissions",e)}}async function $r(t){if(t.platform??=y(),!t.platform)throw new Error(`Cannot detect the browser platform for: ${L.platform()} (${L.arch()})`);new C(t.cacheDir).uninstall(t.browser,t.platform,t.buildId)}async function Dr(t){return new C(t.cacheDir).getInstalledBrowsers()}async function Nr(t){if(t.platform??=y(),!t.platform)throw new Error(`Cannot download a binary for the provided platform: ${L.platform()} (${L.arch()})`);let e=[...t.providers||[],new S(t.baseUrl)],r={browser:t.browser,platform:t.platform,buildId:t.buildId};for(let o of e){if(!await o.supports(r))continue;let a=await o.getDownloadUrl(r);if(a&&await Oe(a))return!0}return!1}function Lr(t,e,r,o){return new URL(K[t](e,r,o))}async function wt(t,e){let r,o=0;return(a,i)=>{r||(r=ae.createBarTicker(`Downloading ${t} ${e} - ${Pr(i)}`,i));let n=a-o;o=a,r(n)}}function Pr(t){let e=t/1e3/1e3;return`${Math.round(e*10)/10} MB`}import{spawn as Tr}from"node:child_process";import bt from"node:fs";import Mr from"node:os";import Br from"node:path";import{stdin as Or,stdout as Ur}from"node:process";import*as xt from"node:readline";function _r(t){return Object.values(u).includes(t)}function Hr(t){return Object.values(s).includes(t)}var Fr="3.2.3",Pe=class{#e;#r;#o;#t;#s;#a;#i;constructor(e,r){e||(e={}),typeof e=="string"&&(e={cachePath:e}),this.#e=e.cachePath??process.cwd(),this.#r=r,this.#o=e.scriptName??"@puppeteer/browsers",this.#t=e.version??Fr,this.#s=e.allowCachePathOverride??!0,this.#a=e.pinnedBrowsers,this.#i=e.prefixCommand}#c(e,r){return e.positional("browser",{description:"Which browser to install <browser>[@<buildId|latest>]. `latest` will try to find the latest available build. `buildId` is a browser-specific identifier such as a version or a revision.",type:"string",coerce:o=>{let a={name:this.#d(o),buildId:this.#l(o)};if(!_r(a.name))throw new Error(`Unsupported browser '${a.name}'`);return a},demandOption:r})}#n(e){return e.option("platform",{type:"string",desc:"Platform that the binary needs to be compatible with.",choices:Object.values(s),default:y(),coerce:r=>{if(!Hr(r))throw new Error(`Unsupported platform '${r}'`);return r},defaultDescription:"Auto-detected"})}#u(e,r=!1){return this.#s?e.option("path",{type:"string",desc:"Path to the root folder for the browser downloads and installation. If a relative path is provided, it will be resolved relative to the current working directory. The installation folder structure is compatible with the cache structure used by Puppeteer.",defaultDescription:"Current working directory",...r?{}:{default:process.cwd()},demandOption:r}):e}async run(e){let{default:r}=await import("./chunk-C564NU2H.mjs"),{hideBin:o}=await import("./chunk-4K5KC6V2.mjs"),a=r(o(e)),i=a.scriptName(this.#o).version(this.#t);this.#i?i=i.command(this.#i.cmd,this.#i.description,n=>this.#h(n)):i=this.#h(i),await i.demandCommand(1).help().wrap(Math.min(120,a.terminalWidth())).parseAsync()}#h(e){let r=this.#a?"pinned":"latest",o=this.#a?"[browser]":"<browser>";return e.command(`install ${o}`,"Download and install the specified browser. If successful, the command outputs the actual browser buildId that was installed and the absolute path to the browser executable (see --format).",a=>{this.#a&&a.example("$0 install","Install all pinned browsers"),a.example("$0 install chrome",`Install the ${r} available build of the Chrome browser.`).example("$0 install chrome@latest","Install the latest available build for the Chrome browser.").example("$0 install chrome@stable","Install the latest available build for the Chrome browser from the stable channel.").example("$0 install chrome@beta","Install the latest available build for the Chrome browser from the beta channel.").example("$0 install chrome@dev","Install the latest available build for the Chrome browser from the dev channel.").example("$0 install chrome@canary","Install the latest available build for the Chrome Canary browser.").example("$0 install chrome@115","Install the latest available build for Chrome 115.").example("$0 install chromedriver@canary","Install the latest available build for ChromeDriver Canary.").example("$0 install chromedriver@115","Install the latest available build for ChromeDriver 115.").example("$0 install chromedriver@115.0.5790","Install the latest available patch (115.0.5790.X) build for ChromeDriver.").example("$0 install chrome-headless-shell","Install the latest available chrome-headless-shell build.").example("$0 install chrome-headless-shell@beta","Install the latest available chrome-headless-shell build corresponding to the Beta channel.").example("$0 install chrome-headless-shell@118","Install the latest available chrome-headless-shell 118 build.").example("$0 install chromium@1083080","Install the revision 1083080 of the Chromium browser.").example("$0 install firefox","Install the latest nightly available build of the Firefox browser.").example("$0 install firefox@stable","Install the latest stable build of the Firefox browser.").example("$0 install firefox@beta","Install the latest beta build of the Firefox browser.").example("$0 install firefox@devedition","Install the latest devedition build of the Firefox browser.").example("$0 install firefox@esr","Install the latest ESR build of the Firefox browser.").example("$0 install firefox@nightly","Install the latest nightly build of the Firefox browser.").example("$0 install firefox@stable_111.0.1","Install a specific version of the Firefox browser.").example("$0 install firefox --platform mac","Install the latest Mac (Intel) build of the Firefox browser."),this.#s&&a.example("$0 install firefox --path /tmp/my-browser-cache","Install to the specified cache directory.");let i=this.#c(a,!this.#a),n=this.#n(i);return this.#u(n,!1).option("base-url",{type:"string",desc:"Base URL to download from"}).option("install-deps",{type:"boolean",desc:"Whether to attempt installing system dependencies (only supported on Linux, requires root privileges).",default:!1}).option("format",{type:"string",desc:"Format to use for the output. Supported placeholders: {{browser}}, {{buildId}}, {{path}}, {{platform}}",default:"{{browser}}@{{buildId}} {{path}}"})},async a=>{if(this.#a&&!a.browser){let i=await Promise.allSettled(Object.entries(this.#a).map(async([n,l])=>{l.skipDownload||await this.#p({...a,browser:{name:n,buildId:l.buildId}})}));for(let n of i)if(n.status==="rejected")throw n.reason}else await this.#p(a)}).command("launch <browser>","Launch the specified browser",a=>{a.example("$0 launch chrome@115.0.5790.170","Launch Chrome 115.0.5790.170").example("$0 launch firefox@112.0a1","Launch the Firefox browser identified by the milestone 112.0a1.").example("$0 launch chrome@115.0.5790.170 --detached","Launch the browser but detach the sub-processes.").example("$0 launch chrome@canary --system","Try to locate the Canary build of Chrome installed on the system and launch it.").example("$0 launch chrome@115.0.5790.170 -- --version","Launch Chrome 115.0.5790.170 and pass custom argument to the binary.");let i=a.parserConfiguration({"populate--":!0}),n=this.#c(i,!0),l=this.#n(n);return this.#u(l).option("detached",{type:"boolean",desc:"Detach the child process.",default:!1}).option("system",{type:"boolean",desc:"Search for a browser installed on the system instead of the cache folder.",default:!1}).option("dumpio",{type:"boolean",desc:"Forwards the browser's process stdout and stderr",default:!1})},async a=>{let i=a["--"]?.filter(l=>typeof l=="string");a.browser.buildId=this.#m(a.browser.buildId,a.browser.name);let n=a.system?Ae({browser:a.browser.name,channel:ue(a.browser.buildId),platform:a.platform}):re({browser:a.browser.name,buildId:a.browser.buildId,cacheDir:a.path??this.#e,platform:a.platform});$e({args:i,executablePath:n,dumpio:a.dumpio,detached:a.detached})}).command("clear",this.#s?"Removes all installed browsers from the specified cache directory":`Removes all installed browsers from ${this.#e}`,a=>this.#u(a,!0),async a=>{let i=a.path??this.#e,n=this.#r??xt.createInterface({input:Or,output:Ur});n.question(`Do you want to permanently and recursively delete the content of ${i} (yes/No)? `,l=>{if(n.close(),!["y","yes"].includes(l.toLowerCase().trim())){console.log("Cancelled.");return}new C(i).clear(),console.log(`${i} cleared.`)})}).command("list","List all installed browsers in the cache directory",a=>(a.example("$0 list","List all installed browsers in the cache directory"),this.#s&&a.example("$0 list --path /tmp/my-browser-cache","List browsers installed in the specified cache directory"),this.#u(a)),async a=>{let i=a.path??this.#e,l=new C(i).getInstalledBrowsers();for(let c of l)console.log(`${c.browser}@${c.buildId} (${c.platform}) ${c.executablePath}`)}).command("bisect <path>","(experimental) Bisect Chrome for Testing using the specified script. Downloads https://chromium.googlesource.com/chromium/src.git/+/main/tools/bisect-builds.py to ~/bisect-builds.py if needed.",a=>a.positional("path",{type:"string",description:"Path to a script or test name to bisect.",demandOption:!0}).option("good",{type:"string",alias:"g",demandOption:!0,desc:"Last known good version"}).option("bad",{type:"string",alias:"b",demandOption:!0,desc:"First known bad version"}).option("cft",{type:"boolean",desc:"Use -cft",default:!0}),async a=>{let n=a.path.endsWith(".mjs")||a.path.endsWith(".cjs")||a.path.endsWith(".js")?`PUPPETEER_EXECUTABLE_PATH=%p node ${a.path}`:`BINARY=%p npm run ${a.path}`,l=Br.join(Mr.homedir(),"bisect-builds.py");if(!bt.existsSync(l)){console.log("Downloading bisect-builds.py...");let f=await fetch("https://chromium.googlesource.com/chromium/src.git/+/main/tools/bisect-builds.py?format=TEXT");if(!f.ok)throw new Error(`Failed to download bisect-builds.py: ${f.statusText}`);let p=await f.text(),E=Buffer.from(p,"base64").toString("utf-8");bt.writeFileSync(l,E,{mode:493}),console.log(`Saved bisect-builds.py to ${l}`)}let c="python3",d=[l,"-g",a.good,"-b",a.bad,a.cft?"-cft":"-s","-v","--verify-range","--not-interactive","-c",n];await new Promise((f,p)=>{let E=Tr(c,d,{stdio:"inherit"});E.on("error",P=>{p(P)}),E.on("exit",P=>{P!==0?p(new Error(`Process exited with code ${P}`)):f()})})}).demandCommand(1).help()}#d(e){return e.split("@").shift()}#l(e){let r=e.split("@");return r.length===2?r[1]:this.#a?"pinned":"latest"}#m(e,r){if(e==="pinned"){let o=this.#a?.[r];if(!o||!o.buildId)throw new Error(`No pinned version found for ${r}`);return o.buildId}return e}async#p(e){if(!e.browser)throw new Error("No browser arg provided");if(!e.platform)throw new Error("Could not resolve the current platform");e.browser.buildId=this.#m(e.browser.buildId,e.browser.name);let r=e.browser.buildId;e.browser.buildId=await Ce(e.browser.name,e.platform,e.browser.buildId);try{await Le({browser:e.browser.name,buildId:e.browser.buildId,platform:e.platform,cacheDir:e.path??this.#e,downloadProgressCallback:"default",baseUrl:e.baseUrl,buildIdAlias:r!==e.browser.buildId?r:void 0,installDeps:e.installDeps})}catch(a){if(!(a instanceof B))throw a;let i=this.#i?`${this.#o} ${this.#i.cmd}`:this.#o;throw new Error(`${a.message}
|
|
18
|
+
`).join(",");if(process.getuid?.()!==0)throw new Error("Installing system dependencies requires root privileges");let a=Ne("apt-get",["-v"]);if(a.status!==0)throw new Error("Failed to install system dependencies: apt-get does not seem to be available");if(e?.(b.install)?.(`Trying to install dependencies: ${o}`),a=Ne("apt-get",["satisfy","-y",o,"--no-install-recommends"]),a.status!==0)throw new Error(`Failed to install system dependencies: status=${a.status},error=${a.error},stdout=${a.stdout.toString("utf8")},stderr=${a.stderr.toString("utf8")}`);e?.(b.install)?.(`Installed system dependencies ${o}`)}async function Ar(t,e,r,o){if(!r)throw new Error("Provider is required for installation");if(e.platform??=y(),!e.platform)throw new Error(`Cannot download a binary for the provided platform: ${L.platform()} (${L.arch()})`);let a=e.downloadProgressCallback;a==="default"&&(a=await wt(e.browser,e.buildIdAlias??e.buildId));let i=decodeURIComponent(t.toString()).split("/").pop();gr(i,`A malformed download URL was found: ${t}.`);let n=new C(e.cacheDir,e.logger),l=n.browserRoot(e.browser),c=H.join(l,`${e.buildId}-${i}`);if(A(l)||await mt(l,{recursive:!0}),e.expectedHash&&o?.(b.install)?.(`Using provided checksum for ${i}: ${e.expectedHash}`),!e.unpack)return A(c)||(o?.(b.install)?.(`Downloading binary from ${t}`),se("download"),await le(t,c,a,e.expectedHash),ie("download",o)),c;let d=n.installationDir(e.browser,e.platform,e.buildId),f=await r.getExecutablePath({browser:e.browser,buildId:e.buildId,platform:e.platform});o?.(b.install)?.(`Using executable path from provider: ${f}`);let p=new _(n,e.browser,e.buildId,e.platform);r instanceof S||n.writeExecutablePath(e.browser,e.platform,e.buildId,f);try{if(A(d)){if(!A(p.executablePath))throw new B(`The browser folder (${d}) exists but the executable (${p.executablePath}) is missing. An earlier install of this build probably did not finish. Delete ${d} and install the browser again.`);return await ft(p,o),e.installDeps&&await dt(p,o),p}if(A(c))o?.(b.install)?.(`Using existing archive at ${c}`);else{o?.(b.install)?.(`Downloading binary from ${t}`);try{se("download"),await le(t,c,a,e.expectedHash)}finally{ie("download",o)}}o?.(b.install)?.(`Installing ${c} to ${d}`);try{se("extract"),await ht(c,d,e.logger)}finally{ie("extract",o)}if(e.buildIdAlias){let E=p.readMetadata();E.aliases[e.buildIdAlias]=e.buildId,p.writeMetadata(E)}return await ft(p,o),e.installDeps&&await dt(p,o),p}finally{A(c)&&await Rr(c)}}async function ft(t,e){if((t.platform===s.WIN32||t.platform===s.WIN64)&&t.browser===u.CHROME&&t.platform===y())try{se("permissions");let r=H.dirname(t.executablePath),o=H.join(r,"setup.exe");if(!A(o))return;Ne(H.join(r,"setup.exe"),["--configure-browser-in-directory="+r],{shell:!1})}finally{ie("permissions",e)}}async function $r(t){if(t.platform??=y(),!t.platform)throw new Error(`Cannot detect the browser platform for: ${L.platform()} (${L.arch()})`);new C(t.cacheDir).uninstall(t.browser,t.platform,t.buildId)}async function Dr(t){return new C(t.cacheDir).getInstalledBrowsers()}async function Nr(t){if(t.platform??=y(),!t.platform)throw new Error(`Cannot download a binary for the provided platform: ${L.platform()} (${L.arch()})`);let e=[...t.providers||[],new S(t.baseUrl)],r={browser:t.browser,platform:t.platform,buildId:t.buildId};for(let o of e){if(!await o.supports(r))continue;let a=await o.getDownloadUrl(r);if(a&&await Oe(a))return!0}return!1}function Lr(t,e,r,o){return new URL(K[t](e,r,o))}async function wt(t,e){let r,o=0;return(a,i)=>{r||(r=ae.createBarTicker(`Downloading ${t} ${e} - ${Pr(i)}`,i));let n=a-o;o=a,r(n)}}function Pr(t){let e=t/1e3/1e3;return`${Math.round(e*10)/10} MB`}import{spawn as Tr}from"node:child_process";import bt from"node:fs";import Mr from"node:os";import Br from"node:path";import{stdin as Or,stdout as Ur}from"node:process";import*as xt from"node:readline";function _r(t){return Object.values(u).includes(t)}function Hr(t){return Object.values(s).includes(t)}var Fr="3.2.3",Pe=class{#e;#r;#o;#t;#s;#a;#i;constructor(e,r){e||(e={}),typeof e=="string"&&(e={cachePath:e}),this.#e=e.cachePath??process.cwd(),this.#r=r,this.#o=e.scriptName??"@puppeteer/browsers",this.#t=e.version??Fr,this.#s=e.allowCachePathOverride??!0,this.#a=e.pinnedBrowsers,this.#i=e.prefixCommand}#c(e,r){return e.positional("browser",{description:"Which browser to install <browser>[@<buildId|latest>]. `latest` will try to find the latest available build. `buildId` is a browser-specific identifier such as a version or a revision.",type:"string",coerce:o=>{let a={name:this.#d(o),buildId:this.#l(o)};if(!_r(a.name))throw new Error(`Unsupported browser '${a.name}'`);return a},demandOption:r})}#n(e){return e.option("platform",{type:"string",desc:"Platform that the binary needs to be compatible with.",choices:Object.values(s),default:y(),coerce:r=>{if(!Hr(r))throw new Error(`Unsupported platform '${r}'`);return r},defaultDescription:"Auto-detected"})}#u(e,r=!1){return this.#s?e.option("path",{type:"string",desc:"Path to the root folder for the browser downloads and installation. If a relative path is provided, it will be resolved relative to the current working directory. The installation folder structure is compatible with the cache structure used by Puppeteer.",defaultDescription:"Current working directory",...r?{}:{default:process.cwd()},demandOption:r}):e}async run(e){let{default:r}=await import("./chunk-74RPP2M2.mjs"),{hideBin:o}=await import("./chunk-LV24RY2E.mjs"),a=r(o(e)),i=a.scriptName(this.#o).version(this.#t);this.#i?i=i.command(this.#i.cmd,this.#i.description,n=>this.#h(n)):i=this.#h(i),await i.demandCommand(1).help().wrap(Math.min(120,a.terminalWidth())).parseAsync()}#h(e){let r=this.#a?"pinned":"latest",o=this.#a?"[browser]":"<browser>";return e.command(`install ${o}`,"Download and install the specified browser. If successful, the command outputs the actual browser buildId that was installed and the absolute path to the browser executable (see --format).",a=>{this.#a&&a.example("$0 install","Install all pinned browsers"),a.example("$0 install chrome",`Install the ${r} available build of the Chrome browser.`).example("$0 install chrome@latest","Install the latest available build for the Chrome browser.").example("$0 install chrome@stable","Install the latest available build for the Chrome browser from the stable channel.").example("$0 install chrome@beta","Install the latest available build for the Chrome browser from the beta channel.").example("$0 install chrome@dev","Install the latest available build for the Chrome browser from the dev channel.").example("$0 install chrome@canary","Install the latest available build for the Chrome Canary browser.").example("$0 install chrome@115","Install the latest available build for Chrome 115.").example("$0 install chromedriver@canary","Install the latest available build for ChromeDriver Canary.").example("$0 install chromedriver@115","Install the latest available build for ChromeDriver 115.").example("$0 install chromedriver@115.0.5790","Install the latest available patch (115.0.5790.X) build for ChromeDriver.").example("$0 install chrome-headless-shell","Install the latest available chrome-headless-shell build.").example("$0 install chrome-headless-shell@beta","Install the latest available chrome-headless-shell build corresponding to the Beta channel.").example("$0 install chrome-headless-shell@118","Install the latest available chrome-headless-shell 118 build.").example("$0 install chromium@1083080","Install the revision 1083080 of the Chromium browser.").example("$0 install firefox","Install the latest nightly available build of the Firefox browser.").example("$0 install firefox@stable","Install the latest stable build of the Firefox browser.").example("$0 install firefox@beta","Install the latest beta build of the Firefox browser.").example("$0 install firefox@devedition","Install the latest devedition build of the Firefox browser.").example("$0 install firefox@esr","Install the latest ESR build of the Firefox browser.").example("$0 install firefox@nightly","Install the latest nightly build of the Firefox browser.").example("$0 install firefox@stable_111.0.1","Install a specific version of the Firefox browser.").example("$0 install firefox --platform mac","Install the latest Mac (Intel) build of the Firefox browser."),this.#s&&a.example("$0 install firefox --path /tmp/my-browser-cache","Install to the specified cache directory.");let i=this.#c(a,!this.#a),n=this.#n(i);return this.#u(n,!1).option("base-url",{type:"string",desc:"Base URL to download from"}).option("install-deps",{type:"boolean",desc:"Whether to attempt installing system dependencies (only supported on Linux, requires root privileges).",default:!1}).option("format",{type:"string",desc:"Format to use for the output. Supported placeholders: {{browser}}, {{buildId}}, {{path}}, {{platform}}",default:"{{browser}}@{{buildId}} {{path}}"})},async a=>{if(this.#a&&!a.browser){let i=await Promise.allSettled(Object.entries(this.#a).map(async([n,l])=>{l.skipDownload||await this.#p({...a,browser:{name:n,buildId:l.buildId}})}));for(let n of i)if(n.status==="rejected")throw n.reason}else await this.#p(a)}).command("launch <browser>","Launch the specified browser",a=>{a.example("$0 launch chrome@115.0.5790.170","Launch Chrome 115.0.5790.170").example("$0 launch firefox@112.0a1","Launch the Firefox browser identified by the milestone 112.0a1.").example("$0 launch chrome@115.0.5790.170 --detached","Launch the browser but detach the sub-processes.").example("$0 launch chrome@canary --system","Try to locate the Canary build of Chrome installed on the system and launch it.").example("$0 launch chrome@115.0.5790.170 -- --version","Launch Chrome 115.0.5790.170 and pass custom argument to the binary.");let i=a.parserConfiguration({"populate--":!0}),n=this.#c(i,!0),l=this.#n(n);return this.#u(l).option("detached",{type:"boolean",desc:"Detach the child process.",default:!1}).option("system",{type:"boolean",desc:"Search for a browser installed on the system instead of the cache folder.",default:!1}).option("dumpio",{type:"boolean",desc:"Forwards the browser's process stdout and stderr",default:!1})},async a=>{let i=a["--"]?.filter(l=>typeof l=="string");a.browser.buildId=this.#m(a.browser.buildId,a.browser.name);let n=a.system?Ae({browser:a.browser.name,channel:ue(a.browser.buildId),platform:a.platform}):re({browser:a.browser.name,buildId:a.browser.buildId,cacheDir:a.path??this.#e,platform:a.platform});$e({args:i,executablePath:n,dumpio:a.dumpio,detached:a.detached})}).command("clear",this.#s?"Removes all installed browsers from the specified cache directory":`Removes all installed browsers from ${this.#e}`,a=>this.#u(a,!0),async a=>{let i=a.path??this.#e,n=this.#r??xt.createInterface({input:Or,output:Ur});n.question(`Do you want to permanently and recursively delete the content of ${i} (yes/No)? `,l=>{if(n.close(),!["y","yes"].includes(l.toLowerCase().trim())){console.log("Cancelled.");return}new C(i).clear(),console.log(`${i} cleared.`)})}).command("list","List all installed browsers in the cache directory",a=>(a.example("$0 list","List all installed browsers in the cache directory"),this.#s&&a.example("$0 list --path /tmp/my-browser-cache","List browsers installed in the specified cache directory"),this.#u(a)),async a=>{let i=a.path??this.#e,l=new C(i).getInstalledBrowsers();for(let c of l)console.log(`${c.browser}@${c.buildId} (${c.platform}) ${c.executablePath}`)}).command("bisect <path>","(experimental) Bisect Chrome for Testing using the specified script. Downloads https://chromium.googlesource.com/chromium/src.git/+/main/tools/bisect-builds.py to ~/bisect-builds.py if needed.",a=>a.positional("path",{type:"string",description:"Path to a script or test name to bisect.",demandOption:!0}).option("good",{type:"string",alias:"g",demandOption:!0,desc:"Last known good version"}).option("bad",{type:"string",alias:"b",demandOption:!0,desc:"First known bad version"}).option("cft",{type:"boolean",desc:"Use -cft",default:!0}),async a=>{let n=a.path.endsWith(".mjs")||a.path.endsWith(".cjs")||a.path.endsWith(".js")?`PUPPETEER_EXECUTABLE_PATH=%p node ${a.path}`:`BINARY=%p npm run ${a.path}`,l=Br.join(Mr.homedir(),"bisect-builds.py");if(!bt.existsSync(l)){console.log("Downloading bisect-builds.py...");let f=await fetch("https://chromium.googlesource.com/chromium/src.git/+/main/tools/bisect-builds.py?format=TEXT");if(!f.ok)throw new Error(`Failed to download bisect-builds.py: ${f.statusText}`);let p=await f.text(),E=Buffer.from(p,"base64").toString("utf-8");bt.writeFileSync(l,E,{mode:493}),console.log(`Saved bisect-builds.py to ${l}`)}let c="python3",d=[l,"-g",a.good,"-b",a.bad,a.cft?"-cft":"-s","-v","--verify-range","--not-interactive","-c",n];await new Promise((f,p)=>{let E=Tr(c,d,{stdio:"inherit"});E.on("error",P=>{p(P)}),E.on("exit",P=>{P!==0?p(new Error(`Process exited with code ${P}`)):f()})})}).demandCommand(1).help()}#d(e){return e.split("@").shift()}#l(e){let r=e.split("@");return r.length===2?r[1]:this.#a?"pinned":"latest"}#m(e,r){if(e==="pinned"){let o=this.#a?.[r];if(!o||!o.buildId)throw new Error(`No pinned version found for ${r}`);return o.buildId}return e}async#p(e){if(!e.browser)throw new Error("No browser arg provided");if(!e.platform)throw new Error("Could not resolve the current platform");e.browser.buildId=this.#m(e.browser.buildId,e.browser.name);let r=e.browser.buildId;e.browser.buildId=await Ce(e.browser.name,e.platform,e.browser.buildId);try{await Le({browser:e.browser.name,buildId:e.browser.buildId,platform:e.platform,cacheDir:e.path??this.#e,downloadProgressCallback:"default",baseUrl:e.baseUrl,buildIdAlias:r!==e.browser.buildId?r:void 0,installDeps:e.installDeps})}catch(a){if(!(a instanceof B))throw a;let i=this.#i?`${this.#o} ${this.#i.cmd}`:this.#o;throw new Error(`${a.message}
|
|
19
19
|
You can also empty the whole browser cache with \`npx ${i} clear\` and then run \`npx ${i} install\` again.`,{cause:a})}let o=re({browser:e.browser.name,buildId:e.browser.buildId,cacheDir:e.path??this.#e,platform:e.platform});console.log(e.format.replace(/{{browser}}/g,e.browser.name).replace(/{{buildId}}/g,e.browser.buildId).replace(/{{path}}/g,o).replace(/{{platform}}/g,e.platform))}};function kr(t,e,r,o="zip"){return`${t}-${e}-${r}.${o}`}export{u as a,s as b,h as c,m as d,Ce as e,Xt as f,Yt as g,Re as h,y as i,_ as j,C as k,re as l,Ae as m,$e as n,er as o,tr as p,ee as q,te as r,S as s,Le as t,$r as u,Dr as v,Nr as w,Lr as x,Pe as y,kr as z};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{e as D,f as x}from"./chunk-
|
|
2
|
+
import{e as D,f as x}from"./chunk-XQRUG4G3.mjs";import{a as d,b as u,c as w,d as y}from"./chunk-OU3S466R.mjs";import{b as c,d as f,e as m,g as p,h as g,i as a,j as h}from"./chunk-WTEGUPFG.mjs";import{k as l}from"./chunk-YFJU3O7G.mjs";import{a as s}from"./chunk-JXLSHVJ2.mjs";import S from"node:path";import{FILE as j}from"../browser/shared/annotations.mjs";import{editStateDirectory as L,reportsDirectory as i}from"../browser/shared/paths.mjs";import{documentDirectory as $,documentFiles as k}from"../browser/shared/workspace.mjs";function O({say:e=!0}={}){return o=>{let{text:t,changes:n}=c(o.html,{finish:l});if(e&&n.length&&console.log(p(o.htmlPath,n,{pending:!0}).join(`
|
|
3
3
|
`)),e){let r=f(o.html);r.length&&console.log(D(o.htmlPath,r,r.length,{pending:!0}).join(`
|
|
4
4
|
`));for(let N of x(o.htmlPath,m(s(o.html),o.metadata),{pending:!0}))console.log(N)}return t}}function b(e){for(let o of e){for(let t of g(o.html))console.log(`note ${o.slug}: ${t} (read-only in the preview)`);for(let t of a(o.html))console.log(`note ${o.slug}: ${t}`);for(let t of h(o.html))console.log(`note ${o.slug}: ${t}`)}}async function q(e){for(let o of e){let t=await w({stateDirectory:L,reportsDirectory:i,slug:o});for(let n of y(k($(o,i)).html,t))console.log(n)}}async function z(e){for(let o of e){let t=await d({stateDirectory:L,reportsDirectory:i,slug:o});for(let n of u(S.join($(o,i),j),t))console.log(n)}}export{O as a,b,q as c,z as d};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{c as Oe,f as we,g as ge,h as $e,i as We,j as ne,l as Y,m as Ge,n as Ae,o as Ke,p as Ve,q as ze,r as g,t as Qe,u as Ye}from"./chunk-
|
|
2
|
+
import{c as Oe,f as we,g as ge,h as $e,i as We,j as ne,l as Y,m as Ge,n as Ae,o as Ke,p as Ve,q as ze,r as g,t as Qe,u as Ye}from"./chunk-SOD23RGL.mjs";import{M as Xe}from"./chunk-4DNHHJSL.mjs";import{f as Te,i as Je}from"./chunk-JJNRIFND.mjs";import{a as K}from"./chunk-JEUK3ZO7.mjs";import{a as me}from"./chunk-CG3UHDKH.mjs";import{a as Ue,b as Ze,f as pe,g as qe}from"./chunk-4AMTKWDO.mjs";import{e as Ne,g as te}from"./chunk-OU3S466R.mjs";import{b as Se}from"./chunk-WTEGUPFG.mjs";import{b as T,i as Pe}from"./chunk-4OZWXZE5.mjs";import{a as Be}from"./chunk-2RKIHJI2.mjs";import{f as Ee,j as He}from"./chunk-VG5JEIUQ.mjs";import{randomBytes as Ct}from"node:crypto";import{existsSync as It}from"node:fs";import N from"node:fs/promises";import A from"node:path";import{isInstance as Re,isSlot as jt,partOf as Mt}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as ke,FALLBACK as Rt,FIELDS as Dt,INSTANCE as ft,PACKAGE_ID as _t,SLOT as Ft}from"../browser/shared/components/installed.mjs";import{attr as ce,walk as Ht}from"../browser/shared/html-tree.mjs";import{documentDirectory as Pt,documentFiles as Bt,layoutOf as se,packageFolders as Jt,slugTaken as Ut}from"../browser/shared/workspace.mjs";var et=10,Ce=6,Zt=3,qt=100,De=1024,_e=900,Wt=4e3,le=3e4,Gt=1500,Ie=3e4,je=500,Kt=5e3,Vt=200,tt=20,nt=160,ye=12,zt=3600*1e3,Qt=["p","pi","pin"],he=e=>new Promise(t=>setTimeout(t,e));async function at(e){let{_keyDefinitions:t}=await import("./chunk-MKTX5PGV.mjs"),n=Object.hasOwn(t,e)?[e]:e.split("+"),a=new Set(["Control","Shift","Alt","Meta"]);if(n.some(s=>!Object.hasOwn(t,s))||n.slice(0,-1).some(s=>!a.has(s)))throw new T(`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}var ie={press:"<selector>",drag:'<selector>, with "to": <selector>',key:"[<selector>, <key>]",type:"[<selector>, <words>]",select:"[<selector>, <value>]"};async function ut(e,t=null){let n=d=>new T(t?`${t[0].toUpperCase()}${t.slice(1)}: ${d}`:`${d[0].toUpperCase()}${d.slice(1)}`);if(!e||typeof e!="object"||Array.isArray(e))throw n(`a step is an object naming one gesture: ${Object.entries(ie).map(([d,h])=>`"${d}": ${h}`).join(", ")}, and "then": <key> after it.`);let a=Object.keys(e).filter(d=>!Object.hasOwn(ie,d)&&!["to","then","replace"].includes(d));if(a.length)throw n(`no such field: ${a.join(", ")} (a step names one of ${Object.keys(ie).join(", ")}, "to" with a drag, "replace": true with typing and "then" after any).`);let s=Object.keys(ie).filter(d=>e[d]!==void 0),o=d=>t?`"${d}"`:`--${d}`;if(s.length!==1)throw n(s.length?`one gesture at a time: ${s.map(o).join(" or ")}.`:t?`name the gesture: ${Object.keys(ie).map(o).join(", ")}.`:"Say the gesture: --press <selector>, --drag <selector> --to <selector>, --key <selector> <key>, --type <selector> <words> or --select <selector> <value>; or --steps <file>.");let[i]=s;if(e.to!==void 0&&i!=="drag")throw n(`${o("to")} goes with ${o("drag")}: ${t?'"drag": <selector>, "to": <selector>':"--drag <selector> --to <selector>"}.`);if(i==="drag"&&e.to===void 0)throw n(`${o("drag")} takes ${o("to")}: ${t?'"drag": <selector>, "to": <selector>':"--drag <selector> --to <selector>"}, where it is dropped.`);if(e.replace!==void 0&&i!=="type")throw n(`${o("replace")} goes with ${o("type")}: it selects what the field holds before the words go in.`);if(e.replace!==void 0&&e.replace!==!0)throw n(`${o("replace")} is true: ${t?'"replace": true':"--replace"} selects what the field holds before the words go in.`);let l=(d,h)=>{if(typeof d!="string"||!d)throw n(`${h} is words: ${JSON.stringify(d)}.`);return d},c=(d,h)=>{if(!Array.isArray(d)||d.length!==2)throw n(`${o(i)} takes ${t?`[<selector>, ${h}]`:`<selector> ${h}`}.`);return[l(d[0],"a selector"),l(d[1],h)]},r={kind:i};if(i==="press"&&(r.at=l(e.press,"a selector")),i==="drag"&&Object.assign(r,{at:l(e.drag,"a selector"),to:l(e.to,"a selector")}),i==="key"){let[d,h]=c(e.key,"<key>");Object.assign(r,{at:d,key:h,keys:await at(h)})}return i==="type"&&([r.at,r.text]=c(e.type,"<words>"),e.replace&&(r.replace=!0)),i==="select"&&([r.at,r.value]=c(e.select,"<value>")),e.then!==void 0&&(r.then={key:l(e.then,"a key"),keys:await at(l(e.then,"a key"))}),r}async function Yt(e,t={},n=!1){if(n&&e.has("--steps"))throw new T('--steps <file> holds every gesture: --replace goes in a step of it, as { "type": [".name", "\u65B0\u540D\u5B57"], "replace": true }, not beside it.');if(e.has("--steps")){let s=["--press","--drag","--to","--key","--type","--select","--then"].filter(o=>e.has(o));if(s.length)throw new T(`--steps <file> holds every gesture: ${s.join(", ")} goes in it, not beside it.`);return null}let a={};for(let s of["press","drag","to","then"])e.has(`--${s}`)&&(a[s]=e.get(`--${s}`));for(let s of["key","type","select"])e.has(`--${s}`)&&(a[s]=[e.get(`--${s}`),t[`--${s}`]]);return n&&(a.replace=!0),ut(a)}async function Xt(e){let t=A.basename(e),n;try{n=await N.readFile(e,"utf8")}catch(o){throw new T(`No steps file: ${K(e)} (${o.code??ne(o)}).`)}let a;try{a=JSON.parse(n.replace(/^/,""))}catch(o){throw new T(`${t} is no JSON: ${ne(o)}. A steps file is a list of steps, as [{ "press": ".add" }, { "type": [".name", "\u65B0\u540D\u5B57"], "then": "Enter" }].`)}if(!Array.isArray(a)||a.length===0)throw new T(`${t} holds no list of steps: write [{ "press": ".add" }, { "type": [".name", "\u65B0\u540D\u5B57"], "then": "Enter" }].`);if(a.length>tt)throw new T(`${t} holds ${a.length} steps, and a trial makes ${tt} at most: try fewer at a time.`);let s=[];for(let[o,i]of a.entries())s.push(await ut(i,`step ${o+1} of ${t}`));return s}var pt=e=>{let t=e.parentNode;for(;t&&!Re(t);)t=t.parentNode;return t??null},en=(e,t)=>{for(let n=e.parentNode;n&&n!==t;n=n.parentNode)if(jt(n))return ce(n,Ft);return null};function wt(e){let t=[];return Ht(Be(e),n=>{if(!Re(n))return;let a=pt(n);t.push({element:n,id:ce(n,ke),blockId:ce(n,"data-block-id")??null,line:n.sourceCodeLocation?.startLine,in:a?{id:ce(a,ke),line:a.sourceCodeLocation?.startLine,slot:en(n,a)}:null})},{inTemplates:!1}),t}var gt=({line:e,in:t},n)=>`${n}:${e}${t?`, in ${t.slot?`the slot ${t.slot} of `:""}${t.id} at ${n}:${t.line}`:""}`,tn=(e,{id:t,blockId:n})=>n??(e.filter(a=>a.id===t).length===1?t:null);function nn(e,t,{slug:n,name:a}){let s=()=>e.map(c=>` ${tn(e,c)??"(no id yet: gallery export gives it one)"} ${c.id} at ${gt(c,a)}`).join(`
|
|
3
3
|
`);if(t===null){if(e.length===1)return 0;throw new T(`${n} holds ${e.length} instances: name one, gallery block try ${n} <instance id> \u2026
|
|
4
4
|
${s()}`)}let o=e.findIndex(({blockId:c})=>c===t);if(o>=0)return o;let i=t.includes("/")?t:`local/${t}`,l=_t.test(i)?e.flatMap((c,r)=>c.id===i?[r]:[]):[];if(l.length===1)return l[0];throw new T(l.length?`${n} holds ${l.length} instances of ${i}: name one by its id
|
|
5
5
|
${s()}`:`${n} holds no instance ${t}:
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
+
import{a,b}from"./chunk-FX42XU6J.mjs";import"./chunk-KUILYI7H.mjs";import"./chunk-2GKGEVMR.mjs";import"./chunk-VKSRM7EY.mjs";import"./chunk-LE44MD3O.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";export{a as copiedLines,b as run};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
|
|
2
|
-
import{spawn as O}from"node:child_process";import{existsSync as I}from"node:fs";import C from"node:fs/promises";import _ from"node:os";import q from"node:path";import{APART as S}from"../browser/editor/components/registry.mjs";var N=6e4,x=600,B=["A4","A3","Letter","Legal","Tabloid"];function F(){if(process.env.GALLERY_BROWSER)return process.env.GALLERY_BROWSER;let{PROGRAMFILES:o="","PROGRAMFILES(X86)":e="",LOCALAPPDATA:r="",HOME:i=""}=process.env;return({win32:[`${o}\\Google\\Chrome\\Application\\chrome.exe`,`${e}\\Google\\Chrome\\Application\\chrome.exe`,`${r}\\Google\\Chrome\\Application\\chrome.exe`,`${e}\\Microsoft\\Edge\\Application\\msedge.exe`,`${o}\\Microsoft\\Edge\\Application\\msedge.exe`],darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Chromium.app/Contents/MacOS/Chromium",...i?[`${i}/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,`${i}/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge`,`${i}/Applications/Chromium.app/Contents/MacOS/Chromium`]:[]],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/opt/google/chrome/chrome","/usr/bin/microsoft-edge","/usr/bin/microsoft-edge-stable","/opt/microsoft/msedge/msedge","/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"]}[process.platform]??[]).find(s=>s&&I(s))??null}var $=()=>process.getuid?.()===0?["--no-sandbox"]:[],te=()=>["--no-first-run","--no-default-browser-check","--disable-extensions","--hide-scrollbars","--lang=zh-CN",...$()];function oe(o,e,r=[]){let i=o.location()?.url??"";return!/^Failed to load resource|^Refused to |Content Security Policy/.test(o.text())&&(!i||i.startsWith(e)||r.includes(i))}var re=o=>o.evaluateOnNewDocument(()=>{globalThis.__qaViolations=[],document.addEventListener("securitypolicyviolation",e=>{globalThis.__qaViolations.push({url:e.blockedURI,directive:e.effectiveDirective||e.violatedDirective,source:e.sourceFile,line:e.lineNumber})})}),V=3e4,W=5e3;function ie(o,e=W){let r=0,i=new Promise(c=>{r=setTimeout(c,e)});return Promise.race([Promise.resolve(o).catch(()=>{}),i]).finally(()=>clearTimeout(r))}var E=o=>new Promise(e=>setTimeout(e,o).unref()),D=o=>String(o??"").replace(/\s+/g," ").trim(),M=o=>{let e=o.split(/\r?\n/).map(D).filter(Boolean).at(-1);return e?`: ${e.slice(0,200)}`:""};async function se({executablePath:o,args:e=[],attempts:r=2,start:i=H}){let c=[];for(let s=0;s<r;s+=1){let n=await C.mkdtemp(q.join(_.tmpdir(),"gallery-browser-")),t=()=>C.rm(n,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{});try{let{browser:a,stop:l}=await i({executablePath:o,args:e,profile:n});return{browser:a,failures:c,close:async()=>{await l().catch(()=>{}),await t()}}}catch(a){c.push(D(a?.message??a)),await t()}}throw Object.assign(new Error(c.at(-1)??"the browser did not start"),{failures:c})}async function H({executablePath:o,args:e,profile:r,starting:i=V}){let{default:c}=await import("./chunk-
|
|
2
|
+
import{spawn as O}from"node:child_process";import{existsSync as I}from"node:fs";import C from"node:fs/promises";import _ from"node:os";import q from"node:path";import{APART as S}from"../browser/editor/components/registry.mjs";var N=6e4,x=600,B=["A4","A3","Letter","Legal","Tabloid"];function F(){if(process.env.GALLERY_BROWSER)return process.env.GALLERY_BROWSER;let{PROGRAMFILES:o="","PROGRAMFILES(X86)":e="",LOCALAPPDATA:r="",HOME:i=""}=process.env;return({win32:[`${o}\\Google\\Chrome\\Application\\chrome.exe`,`${e}\\Google\\Chrome\\Application\\chrome.exe`,`${r}\\Google\\Chrome\\Application\\chrome.exe`,`${e}\\Microsoft\\Edge\\Application\\msedge.exe`,`${o}\\Microsoft\\Edge\\Application\\msedge.exe`],darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Chromium.app/Contents/MacOS/Chromium",...i?[`${i}/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,`${i}/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge`,`${i}/Applications/Chromium.app/Contents/MacOS/Chromium`]:[]],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/opt/google/chrome/chrome","/usr/bin/microsoft-edge","/usr/bin/microsoft-edge-stable","/opt/microsoft/msedge/msedge","/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"]}[process.platform]??[]).find(s=>s&&I(s))??null}var $=()=>process.getuid?.()===0?["--no-sandbox"]:[],te=()=>["--no-first-run","--no-default-browser-check","--disable-extensions","--hide-scrollbars","--lang=zh-CN",...$()];function oe(o,e,r=[]){let i=o.location()?.url??"";return!/^Failed to load resource|^Refused to |Content Security Policy/.test(o.text())&&(!i||i.startsWith(e)||r.includes(i))}var re=o=>o.evaluateOnNewDocument(()=>{globalThis.__qaViolations=[],document.addEventListener("securitypolicyviolation",e=>{globalThis.__qaViolations.push({url:e.blockedURI,directive:e.effectiveDirective||e.violatedDirective,source:e.sourceFile,line:e.lineNumber})})}),V=3e4,W=5e3;function ie(o,e=W){let r=0,i=new Promise(c=>{r=setTimeout(c,e)});return Promise.race([Promise.resolve(o).catch(()=>{}),i]).finally(()=>clearTimeout(r))}var E=o=>new Promise(e=>setTimeout(e,o).unref()),D=o=>String(o??"").replace(/\s+/g," ").trim(),M=o=>{let e=o.split(/\r?\n/).map(D).filter(Boolean).at(-1);return e?`: ${e.slice(0,200)}`:""};async function se({executablePath:o,args:e=[],attempts:r=2,start:i=H}){let c=[];for(let s=0;s<r;s+=1){let n=await C.mkdtemp(q.join(_.tmpdir(),"gallery-browser-")),t=()=>C.rm(n,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{});try{let{browser:a,stop:l}=await i({executablePath:o,args:e,profile:n});return{browser:a,failures:c,close:async()=>{await l().catch(()=>{}),await t()}}}catch(a){c.push(D(a?.message??a)),await t()}}throw Object.assign(new Error(c.at(-1)??"the browser did not start"),{failures:c})}async function H({executablePath:o,args:e,profile:r,starting:i=V}){let{default:c}=await import("./chunk-ZEY2RLBT.mjs"),s=await c.defaultArgs({headless:!0,userDataDir:r,args:[...e,"--remote-debugging-port=0"]}),n=process.platform!=="win32",t=O(o,s,{stdio:["ignore","ignore","pipe"],windowsHide:!0,detached:n}),a=!1;t.on("error",()=>a||=t.pid===void 0);let l=()=>a||t.exitCode!==null||t.signalCode!==null,u=new Promise(f=>t.once("exit",f)),m=()=>{if(!l())try{n?process.kill(-t.pid,"SIGKILL"):t.kill()}catch{try{t.kill("SIGKILL")}catch{}}};process.once("exit",m);let p="",d=new Promise((f,w)=>{let g=setTimeout(()=>w(new Error(`it said nothing of its DevTools port in ${i/1e3}s${M(p)}`)),i);t.stderr.setEncoding("utf8"),t.stderr.on("data",h=>{p=`${p}${h}`.slice(-4e3);let y=/DevTools listening on (ws:\/\/\S+)/.exec(p);y&&(clearTimeout(g),f(y[1]))}),t.once("error",h=>(clearTimeout(g),w(h))),t.once("exit",(h,y)=>(clearTimeout(g),w(new Error(`it stopped (${y??`exit ${h}`}) before it opened its DevTools port${M(p)}`))))}),A=async()=>{try{l()||await Promise.race([u,E(5e3)]),m(),l()||await Promise.race([u,E(3e3)])}finally{process.off("exit",m)}},v;try{let f=await d,w=0,g=new Promise((y,G)=>{w=setTimeout(()=>G(new Error(`it opened its DevTools port and did not answer in ${i/1e3}s`)),i)}),h=c.connect({browserWSEndpoint:f,defaultViewport:{width:800,height:600}});h.catch(()=>{}),v=await Promise.race([h,g]).finally(()=>clearTimeout(w))}catch(f){throw m(),await A(),f}return{browser:v,stop:async()=>{await Promise.race([v.close().catch(()=>{}),E(5e3)]),await A()}}}var b=null,L=0,T=0;async function K(){let o=F();if(!o)throw Object.assign(new Error("\u6CA1\u6709\u627E\u5230 Chrome \u6216 Edge\uFF1A\u5BFC\u51FA PDF \u9700\u8981\u7535\u8111\u4E0A\u88C5\u6709\u5176\u4E2D\u4E00\u4E2A\u6D4F\u89C8\u5668"),{reason:"browser"});let{default:e}=await import("./chunk-ZEY2RLBT.mjs");return e.launch({executablePath:o,headless:!0,args:["--no-first-run","--no-default-browser-check","--disable-extensions",...$()]})}async function R(o,e){clearTimeout(L),T+=1,b??=K().catch(i=>{throw b=null,i});let r=await(await b).newPage();try{return await r.emulateMediaFeatures([{name:"prefers-reduced-motion",value:"reduce"},{name:"prefers-color-scheme",value:"light"}]),await r.setViewport({width:1200,height:900}),await r.setContent(o,{waitUntil:"load",timeout:6e4}),await P(r,{changing:x}),await e(r)}finally{await r.close().catch(()=>{}),T-=1,T===0&&(L=setTimeout(async()=>{let i=b;b=null,(await i?.catch(()=>null))?.close().catch(()=>{})},N))}}async function P(o,{timeout:e=15e3,changing:r=e}={}){let i=[],c=(n,t,a=e)=>{t!==!0&&i.push(`${n} (${t===!1?`not in ${a/1e3}s`:t})`)},s=(n,t=e)=>o.evaluate(n,t).catch(a=>a.message);return c("the fonts loaded",await s(n=>Promise.race([Promise.resolve(document.fonts?.ready).then(()=>!0),new Promise(t=>setTimeout(()=>t(!1),n))]))),c("the kit's first drawing done (data-doc-drawn)",await s(n=>new Promise(t=>{let a=Date.now(),l=()=>{!globalThis.DocKit||document.documentElement.hasAttribute("data-doc-drawn")?(globalThis.DocCode?.colorAll?.(),t(!0)):Date.now()-a>n?t(!1):setTimeout(l,50)};l()}))),c("the page done changing",await s(n=>new Promise(t=>{let a=()=>[document.documentElement.scrollHeight,...[...document.querySelectorAll("[style]")].map(d=>d.getAttribute("style")),...[...document.adoptedStyleSheets??[]].flatMap(d=>[...d.cssRules].map(A=>A.cssText)),...[...document.querySelectorAll("svg, canvas")].map(d=>d.outerHTML.length),[...document.images].filter(d=>d.complete).length].join("|"),l=Date.now(),u=a(),m=0,p=()=>{let d=a();m=d===u?m+1:0,u=d,m>=3?t(!0):Date.now()-l>n?t(!1):setTimeout(p,100)};setTimeout(p,100)}),r),r),i}async function k(o){await o.evaluate(()=>{document.documentElement.setAttribute("data-doc-theme","light");for(let e of document.querySelectorAll("[data-doc-sheets]")){let r=e.querySelector(":scope > .doc-sheet-tabs");if(r){for(let i of r.querySelectorAll(":scope > .doc-sheet-tab")){let c=i.getAttribute("data-sheet-tab"),s=[...e.querySelectorAll(":scope > [data-doc-sheet]")].find(a=>a.getAttribute("data-doc-sheet")===c);if(!s)continue;s.hidden=!1,s.removeAttribute("aria-hidden"),s.style.setProperty("display","block","important");let n=r.cloneNode(!1);n.removeAttribute("id"),n.removeAttribute("role"),n.style.setProperty("break-after","avoid");let t=i.cloneNode(!0);t.removeAttribute("id"),t.setAttribute("aria-selected","true"),t.classList.add("is-active"),n.append(t),s.before(n)}r.style.setProperty("display","none","important")}}for(let e of document.querySelectorAll("details"))e.open=!0;window.dispatchEvent(new Event("resize"))}),await P(o,{changing:x})}var j={A4:793.7,A3:1122.5,Letter:816,Legal:816,Tabloid:1056},z=96;async function U(o,e){await o.emulateMediaType("print");let r=await o.evaluate(()=>Math.max(0,innerWidth-document.documentElement.clientWidth));await o.setViewport({width:Math.floor(e)+r,height:900}),await P(o,{changing:x})}function ne(o,{paper:e="A4",scale:r=1}={}){let i=B.includes(e)?e:"A4",c=Math.min(2,Math.max(.1,r));return R(o,async s=>(await k(s),await U(s,(j[i]-2*z)/c),Buffer.from(await s.pdf({format:i,scale:c,printBackground:!0,margin:{top:"1in",right:"1in",bottom:"1in",left:"1in"}}))))}function ae(o){return R(o,async e=>{await k(e);let r=e.viewport(),i=await e.$$("main figure.doc-figure"),c=[];for(let s of i){let n=0;try{n=await s.evaluate(async(t,a)=>{let l=[];for(let u=t.closest(a);u;u=u.parentElement.closest(a))l.unshift(u);for(let u of l)u.style.setProperty("height","auto"),u.style.setProperty("max-height","calc(100dvh - (2 * var(--doc-dialog-margin)))"),u.showModal();return await new Promise(u=>requestAnimationFrame(()=>requestAnimationFrame(u))),l.length?Math.ceil(t.getBoundingClientRect().height):0},S),n&&(await e.setViewport({...r,height:r.height+n}),await P(e,{changing:x})),await s.evaluate(t=>t.scrollIntoView({block:"center"})),c.push(Buffer.from(await s.screenshot({type:"png"})))}catch{c.push(null)}await s.evaluate((t,a)=>{for(let l=t.closest(a);l;l=l.parentElement.closest(a))l.close(),l.style.removeProperty("height"),l.style.removeProperty("max-height"),l.getAttribute("style")||l.removeAttribute("style")},S).catch(()=>{}),n&&await e.setViewport(r).catch(()=>{})}return c})}export{F as a,te as b,oe as c,re as d,W as e,ie as f,se as g,P as h,ne as i,ae as j};
|