hojas/node_modules/@marp-team/marp-cli/lib/marp-cli-qbOdG7H_.js

18 lines
533 KiB
JavaScript
Raw Permalink Normal View History

2026-05-14 10:56:04 +02:00
"use strict";var e=require("node:process"),t=require("node:os"),n=require("node:tty"),r=require("./binary-H3Un9BO3.js"),o=require("node:fs"),i=require("node:path"),s=require("node:fs/promises"),a=require("path"),u=require("node:child_process"),A=require("node:util"),c=require("fs"),D=require("os"),l=require("child_process"),p=require("process"),g=require("events"),f=require("puppeteer-core"),h=require("node:events"),d=require("node:util/types"),m=require("node:crypto"),w=require("assert"),C=require("util"),E=require("cosmiconfig"),F=require("node:url"),B=require("module"),b=require("node:assert"),v=require("node:module"),y=require("node:v8"),k=require("url"),P=require("node:stream/consumers"),I=require("node:timers/promises"),x=require("tmp"),Q=require("@marp-team/marpit"),M=require("chokidar"),S=require("net"),O=require("ws"),R=require("node:querystring"),H=require("serve-index"),L=require("@marp-team/marp-core/package.json"),T="undefined"!=typeof document?document.currentScript:null;function j(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var N=j(c),Y=j(F);const U=(e=0)=>t=>`[${t+e}m`,G=(e=0)=>t=>`[${38+e};5;${t}m`,z=(e=0)=>(t,n,r)=>`[${38+e};2;${t};${n};${r}m`,J={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(J.modifier),Object.keys(J.color),Object.keys(J.bgColor);const K=function(){const e=new Map;for(const[t,n]of Object.entries(J)){for(const[t,r]of Object.entries(n))J[t]={open:`[${r[0]}m`,close:`[${r[1]}m`},n[t]=J[t],e.set(r[0],r[1]);Object.defineProperty(J,t,{value:n,enumerable:!1})}return Object.defineProperty(J,"codes",{value:e,enumerable:!1}),J.color.close="",J.bgColor.close="",J.color.ansi=U(),J.color.ansi256=G(),J.color.ansi16m=z(),J.bgColor.ansi=U(10),J.bgColor.ansi256=G(10),J.bgColor.ansi16m=z(10),Object.defineProperties(J,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;3===n.length&&(n=[...n].map(e=>e+e).join(""));const r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},enumerable:!1},hexToAnsi256:{value:e=>J.rgbToAnsi256(...J.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let t,n,r;if(e>=232)t=(10*(e-232)+8)/255,n=t,r=t;else{const o=(e-=16)%36;t=Math.floor(e/36)/5,n=Math.floor(o/6)/5,r=o%6/5}const o=2*Math.max(t,n,r);if(0===o)return 30;let i=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return 2===o&&(i+=60),i},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>J.ansi256ToAnsi(J.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>J.ansi256ToAnsi(J.hexToAnsi256(e)),enumerable:!1}}),J}();function X(t,n=(globalThis.Deno?globalThis.Deno.args:e.argv)){const r=t.startsWith("-")?"":1===t.length?"-":"--",o=n.indexOf(r+t),i=n.indexOf("--");return-1!==o&&(-1===i||o<i)}const{env:Z}=e;let W;function q(n,r={}){return 0!==(o=function(n,{streamIsTTY:r,sniffFlags:o=!0}={}){const i=function(){if("FORCE_COLOR"in Z)return"true"===Z.FORCE_COLOR?1:"false"===Z.FORCE_COLOR?0:0===Z.FORCE_COLO
/**
* @license
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/const Dt="win32"===p.platform,lt=p.browser,pt={red:lt?"crimson":1,yellow:lt?"gold":3,cyan:lt?"darkturquoise":6,green:lt?"forestgreen":2,blue:lt?"steelblue":4,magenta:lt?"palevioletred":5};r.b.colors=[pt.cyan,pt.green,pt.blue,pt.magenta];class gt extends g.EventEmitter{constructor(e){super(e)}issueStatus(e,t){"status"!==e&&"statusEnd"!==e||this.emit(e,[e,...t])}issueWarning(e,t){this.emit("warning",[e,...t])}}const ft={};let ht;class dt{static _logToStdErr(e,t){dt.loggerfn(e)(...t)}static loggerfn(e){let t=ft[e=`LH:${e}`];return t||(t=r.b(e),ft[e]=t,e.endsWith("error")?t.color=pt.red:e.endsWith("warn")&&(t.color=pt.yellow)),t}static setLevel(e){switch(ht=e,e){case"silent":r.b.enable("-LH:*");break;case"verbose":r.b.enable("LH:*");break;case"warn":r.b.enable("-LH:*, LH:*:warn, LH:*:error");break;case"error":r.b.enable("-LH:*, LH:*:error");break;default:r.b.enable("LH:*, -LH:*:verbose")}}static formatProtocol(e,t,n){const r=!p||p.browser?1/0:p.stdout.columns,o=t.method||"?????",i=r-o.length-e.length-25,s=t.params&&"IO.read"!==o?JSON.stringify(t.params).substr(0,i):"";dt._logToStdErr(`${e}:${n||""}`,[o,s])}static isVerbose(){return"verbose"===ht}static time({msg:e,id:t,args:n=[]},r="log"){rt(t),dt[r]("status",e,...n)}static timeEnd({msg:e,id:t,args:n=[]},r="verbose"){dt[r]("statusEnd",e,...n),ot(t)}static log(e,...t){return dt.events.issueStatus(e,t),dt._logToStdErr(e,t)}static warn(e,...t){return dt.events.issueWarning(e,t),dt._logToStdErr(`${e}:warn`,t)}static error(e,...t){return dt._logToStdErr(`${e}:error`,t)}static verbose(e,...t){return dt.events.issueStatus(e,t),dt._logToStdErr(`${e}:verbose`,t)}static greenify(e){return`${dt.green}${e}${dt.reset}`}static redify(e){return`${dt.red}${e}${dt.reset}`}static get green(){return""}static get red(){return""}static get yellow(){return""}static get purple(){return""}static get reset(){return""}static get bold(){return""}static get dim(){return""}static get tick(){return Dt?"":""}static get cross(){return Dt?"×":""}static get whiteSmallSquare(){return Dt?"·":""}static get heavyHorizontal(){return Dt?"":""}static get heavyVertical(){return Dt?" ":" "}static get heavyUpAndRight(){return Dt?"":""}static get heavyVerticalAndRight(){return Dt?"":""}static get heavyDownAndHorizontal(){return Dt?"":""}static get doubleLightHorizontal(){return""}}dt.events=new gt,dt.takeTimeEntries=()=>{const e=it();return st(),e},dt.getTimeEntries=()=>it();var mt,wt,Ct,Et={exports:{}};!function(){if(Ct)return Et.exports;Ct=1;const e=D,t=c,n=function(){if(wt)return mt;wt=1;const e=c;let t;return mt=()=>(void 0===t&&(t=function(){try{return e.statSync("/.dockerenv"),!0}catch(e){return!1}}()||function(){try{return e.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch(e){return!1}}()),t)}(),r=()=>{if("linux"!==process.platform)return!1;if(e.release().toLowerCase().includes("microsoft"))return!n();try{return!!t.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")&&!n()}catch(e){return!1}};process.env.__IS_WSL_TEST__?Et.exports=r:Et.exports=r(),Et.exports}();
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
class Ft extends Error{constructor(e="Unexpected error",t){return super(),this.message=e,this.code=t,this.stack=(new Error).stack,this}}class Bt extends Ft{constructor(){super(...arguments),this.message="The CHROME_PATH environment variable must be set to a Chrome/Chromium executable no older than Chrome stable.",this.code="ERR_LAUNCHER_PATH_NOT_SET"}}function bt(e,t){try{return l.execFileSync("wslpath",["-u",e]).toString().trim()}catch{return t}}
/**
* @license Copyright 2016 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
const vt=/\r?\n/;function yt(){return It(process.env.CHROME_PATH)?process.env.CHROME_PATH:It(process.env.LIGHTHOUSE_CHROMIUM_PATH)?(dt.warn("ChromeLauncher","LIGHTHOUSE_CHROMIUM_PATH is deprecated, use CHROME_PATH env variable instead."),process.env.LIGHTHOUSE_CHROMIUM_PATH):void 0}function kt(){const e=[],t=[`${a.sep}Google${a.sep}Chrome SxS${a.sep}Application${a.sep}chrome.exe`,`${a.sep}Google${a.sep}Chrome${a.sep}Application${a.sep}chrome.exe`],n=[process.env.LOCALAPPDATA,process.env.PROGRAMFILES,process.env["PROGRAMFILES(X86)"]].filter(Boolean),r=yt();return r&&e.push(r),n.forEach(n=>t.forEach(t=>{const r=a.join(n,t);It(r)&&e.push(r)})),e}function Pt(e,t){return e.map(e=>{for(const n of t)if(n.regex.test(e))return{path:e,weight:n.weight};return{path:e,weight:10}}).sort((e,t)=>t.weight-e.weight).map(e=>e.path)}function It(e){if(!e)return!1;try{return c.accessSync(e),!0}catch(e){return!1}}let xt,Qt;function Mt(){return void 0===Qt&&(Qt=(()=>{try{return o.statSync("/run/.containerenv"),!0}catch{return!1}})()||(void 0===xt&&(xt=function(){try{return o.statSync("/.dockerenv"),!0}catch{return!1}}()||function(){try{return o.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}()),xt)),Qt}const St=()=>!!process.env.MARP_USER;let Ot,Rt,Ht;function Lt(e=21){var t;t=e|=0,!Ot||Ot.length<t?(Ot=Buffer.allocUnsafe(128*t),m.webcrypto.getRandomValues(Ot),Rt=0):Rt+t>Ot.length&&(m.webcrypto.getRandomValues(Ot),Rt=0),Rt+=t;let n="";for(let t=Rt-e;t<Rt;t++)n+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&Ot[t]];return n}const Tt=/^\/mnt\/[a-z]\//;class jt extends h.EventEmitter{static kind;static protocol;path;protocolTimeout;timeout;#e;_puppeteerDataDir=ye();_puppeteer=ye();constructor(e){super(),this.#e=`marp-cli-${Lt(10)}`,this.path=e.path,this.timeout=e.timeout??3e4,this.protocolTimeout=0===this.timeout?0:Math.max(18e4,this.timeout)}get kind(){return this.constructor.kind}get protocol(){return this.constructor.protocol}async launch(e={}){return this._puppeteer.init(async()=>{r.c("Launching browser via Puppeteer...");const t=await this.launchPuppeteer(e);return t.once("disconnected",()=>{this.emit("disconnect",t),this._puppeteer.value=void 0,r.c("Browser disconnected (Cleaned up puppeteer instance)")}),this.emit("launch",t),t})}async withPage(e){const t=Lt(8),n=await this.launch(),o=await n.newPage();r.c("Created a new page [%s]",t),o.setDefaultTimeout(this.timeout),o.setDefaultNavigationTimeout(this.timeout);try{return await e(o)}finally{await o.close(),r.c("Page closed [%s]",t)}}async close(){const e=await this._puppeteer.value;e&&(e.connected&&(await e.close(),this.emit("close",e)),this._puppeteer.value=void 0)}async[Symbol.asyncDispose](){await this.close()}async browserInWSLHost(){return!!await He()&&Tt.test((this._puppeteer.value&&!d.isPromise(this._puppeteer.value)?this._puppeteer.value.process()?.spawnfile:null)??this.path)}async resolveToFileURI(e){return await this.browserInWSLHost()?`file:${await Ie(e,!0)}`:`file://${e}`}async generateLaunchOptions(e={}){const t={browser:this.kind,executablePath:this.path,headless:!0,protocol:this.protocol,protocolTimeout:this.protocolTimeout,timeout:this.timeout,...e};return await this.browserInWSLHost()&&(t.env={}),t}async puppeteerDataDir(){return this._puppeteerDataDir.init(async()=>{let e=!1;const n=await(async()=>await this.browserInWSLHost()&&(void 0===Ht&&(Ht=await Qe("TMP")),void 0!==Ht)?(e=!0,i.win32.resolve(Ht,this.#e)):i.resolve(t.tmpdir(),this.#e))(),s=e?await xe(n):n;return await o.promises.mkdir(s,{recursive:!0}),r.c("Created data directory: %s",s),n})}}class Nt extends jt{static kind="chrome";static protocol="webDriverBiDi";async launchPuppeteer(e){const t=await this.generateLaunchOptions({enableExtensions:!!process.env.CHROME_ENABLE_EXTENSIONS,headless:this.puppeteerHeadless(),pipe:await this.puppeteerPipe(),...e,userDataDir:void 0,args:await this.puppeteerArgs(e.args??[])}),n=async(e={})=>{const r={...t,...e};try{return await f.launch(r)}catch(t){if(he(t)){if(r.pipe)return await n({...e,pipe:!1});/need to run as root or suid/