@a9n-shoji/rvw 0.4.1 → 0.4.2
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/CHANGELOG.md +17 -0
- package/dist/cli.mjs +526 -147
- package/dist/cli.mjs.map +3 -3
- package/dist/web/assets/DocumentViewer-CWTnSlpG.js +1420 -0
- package/dist/web/assets/{FileIcon-AhP8Ezk9.js → FileIcon-wDKKQgGv.js} +94 -94
- package/dist/web/assets/{MarkdownTable-Clfr8wUw.js → MarkdownTable-IiPLNTUX.js} +1 -1
- package/dist/web/assets/{MermaidExpandedView-BjmXfluL.js → MermaidExpandedView-BT6F4F2R.js} +2 -2
- package/dist/web/assets/{MermaidSurface-B2Z3pJme.js → MermaidSurface-CKiZv7R8.js} +1 -1
- package/dist/web/assets/{StructureViewer-B0fkdcLj.js → StructureViewer-u7de1S8C.js} +2 -2
- package/dist/web/assets/{WalkthroughPanel-BGgWu0bA.js → WalkthroughPanel-D2KqSIf9.js} +20 -20
- package/dist/web/assets/WalkthroughViewer-BDb-99Qk.js +43 -0
- package/dist/web/assets/{index-B3zKWMdE.css → index-B0xRoLW2.css} +1 -1
- package/dist/web/assets/index-DUZmOKYW.js +11 -0
- package/dist/web/index.html +5 -5
- package/migrations/017_domain_revisions.sql +14 -0
- package/package.json +1 -1
- package/dist/web/assets/DocumentViewer-cnnF6CLV.js +0 -1420
- package/dist/web/assets/WalkthroughViewer-DdPfdT2-.js +0 -43
- package/dist/web/assets/index-qmzlYGCz.js +0 -11
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t,r as n,t as r}from"./MermaidSurface-CKiZv7R8.js";import{C as i,D as a,E as o,N as s,O as c,S as l,T as u,_ as d,a as f,at as p,b as m,c as h,et as g,i as ee,it as _,k as v,l as y,ot as b,p as x,r as S,rt as C,s as te,st as ne,tt as w,u as T,w as E,x as D,y as re}from"./WalkthroughPanel-D2KqSIf9.js";import{c as O,i as ie,l as k,o as A,s as j}from"./FileIcon-wDKKQgGv.js";import{t as M}from"./lib-p2IERBh0.js";import{a as ae,i as N,n as oe,o as P,r as F,t as I}from"./MarkdownTable-IiPLNTUX.js";var L={abandonedHeadElementChild:{reason:`Unexpected metadata element after head`,description:"Unexpected element after head. Expected the element before `</head>`",url:!1},abruptClosingOfEmptyComment:{reason:`Unexpected abruptly closed empty comment`,description:"Unexpected `>` or `->`. Expected `-->` to close comments"},abruptDoctypePublicIdentifier:{reason:`Unexpected abruptly closed public identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the public identifier"},abruptDoctypeSystemIdentifier:{reason:`Unexpected abruptly closed system identifier`,description:"Unexpected `>`. Expected a closing `\"` or `'` after the identifier identifier"},absenceOfDigitsInNumericCharacterReference:{reason:`Unexpected non-digit at start of numeric character reference`,description:"Unexpected `%c`. Expected `[0-9]` for decimal references or `[0-9a-fA-F]` for hexadecimal references"},cdataInHtmlContent:{reason:`Unexpected CDATA section in HTML`,description:"Unexpected `<![CDATA[` in HTML. Remove it, use a comment, or encode special characters instead"},characterReferenceOutsideUnicodeRange:{reason:`Unexpected too big numeric character reference`,description:`Unexpectedly high character reference. Expected character references to be at most hexadecimal 10ffff (or decimal 1114111)`},closingOfElementWithOpenChildElements:{reason:`Unexpected closing tag with open child elements`,description:`Unexpectedly closing tag. Expected other tags to be closed first`,url:!1},controlCharacterInInputStream:{reason:`Unexpected control character`,description:"Unexpected control character `%x`. Expected a non-control code point, 0x00, or ASCII whitespace"},controlCharacterReference:{reason:`Unexpected control character reference`,description:`Unexpectedly control character in reference. Expected a non-control code point, 0x00, or ASCII whitespace`},disallowedContentInNoscriptInHead:{reason:"Disallowed content inside `<noscript>` in `<head>`",description:"Unexpected text character `%c`. Only use text in `<noscript>`s in `<body>`",url:!1},duplicateAttribute:{reason:`Unexpected duplicate attribute`,description:`Unexpectedly double attribute. Expected attributes to occur only once`},endTagWithAttributes:{reason:`Unexpected attribute on closing tag`,description:"Unexpected attribute. Expected `>` instead"},endTagWithTrailingSolidus:{reason:`Unexpected slash at end of closing tag`,description:"Unexpected `%c-1`. Expected `>` instead"},endTagWithoutMatchingOpenElement:{reason:`Unexpected unopened end tag`,description:`Unexpected end tag. Expected no end tag or another end tag`,url:!1},eofBeforeTagName:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected tag name instead`},eofInCdata:{reason:`Unexpected end of file in CDATA`,description:"Unexpected end of file. Expected `]]>` to close the CDATA"},eofInComment:{reason:`Unexpected end of file in comment`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInDoctype:{reason:`Unexpected end of file in doctype`,description:"Unexpected end of file. Expected a valid doctype (such as `<!doctype html>`)"},eofInElementThatCanContainOnlyText:{reason:`Unexpected end of file in element that can only contain text`,description:`Unexpected end of file. Expected text or a closing tag`,url:!1},eofInScriptHtmlCommentLikeText:{reason:`Unexpected end of file in comment inside script`,description:"Unexpected end of file. Expected `-->` to close the comment"},eofInTag:{reason:`Unexpected end of file in tag`,description:"Unexpected end of file. Expected `>` to close the tag"},incorrectlyClosedComment:{reason:`Incorrectly closed comment`,description:"Unexpected `%c-1`. Expected `-->` to close the comment"},incorrectlyOpenedComment:{reason:`Incorrectly opened comment`,description:"Unexpected `%c`. Expected `<!--` to open the comment"},invalidCharacterSequenceAfterDoctypeName:{reason:`Invalid sequence after doctype name`,description:"Unexpected sequence at `%c`. Expected `public` or `system`"},invalidFirstCharacterOfTagName:{reason:`Invalid first character in tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},misplacedDoctype:{reason:`Misplaced doctype`,description:`Unexpected doctype. Expected doctype before head`,url:!1},misplacedStartTagForHeadElement:{reason:"Misplaced `<head>` start tag",description:"Unexpected start tag `<head>`. Expected `<head>` directly after doctype",url:!1},missingAttributeValue:{reason:`Missing attribute value`,description:"Unexpected `%c-1`. Expected an attribute value or no `%c-1` instead"},missingDoctype:{reason:`Missing doctype before other content`,description:"Expected a `<!doctype html>` before anything else",url:!1},missingDoctypeName:{reason:`Missing doctype name`,description:"Unexpected doctype end at `%c`. Expected `html` instead"},missingDoctypePublicIdentifier:{reason:`Missing public identifier in doctype`,description:"Unexpected `%c`. Expected identifier for `public` instead"},missingDoctypeSystemIdentifier:{reason:`Missing system identifier in doctype`,description:'Unexpected `%c`. Expected identifier for `system` instead (suggested: `"about:legacy-compat"`)'},missingEndTagName:{reason:`Missing name in end tag`,description:"Unexpected `%c`. Expected an ASCII letter instead"},missingQuoteBeforeDoctypePublicIdentifier:{reason:`Missing quote before public identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingQuoteBeforeDoctypeSystemIdentifier:{reason:`Missing quote before system identifier in doctype`,description:"Unexpected `%c`. Expected `\"` or `'` instead"},missingSemicolonAfterCharacterReference:{reason:`Missing semicolon after character reference`,description:"Unexpected `%c`. Expected `;` instead"},missingWhitespaceAfterDoctypePublicKeyword:{reason:`Missing whitespace after public identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceAfterDoctypeSystemKeyword:{reason:`Missing whitespace after system identifier in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBeforeDoctypeName:{reason:`Missing whitespace before doctype name`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenAttributes:{reason:`Missing whitespace between attributes`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:{reason:`Missing whitespace between public and system identifiers in doctype`,description:"Unexpected `%c`. Expected ASCII whitespace instead"},nestedComment:{reason:`Unexpected nested comment`,description:"Unexpected `<!--`. Expected `-->`"},nestedNoscriptInHead:{reason:"Unexpected nested `<noscript>` in `<head>`",description:"Unexpected `<noscript>`. Expected a closing tag or a meta element",url:!1},nonConformingDoctype:{reason:`Unexpected non-conforming doctype declaration`,description:'Expected `<!doctype html>` or `<!doctype html system "about:legacy-compat">`',url:!1},nonVoidHtmlElementStartTagWithTrailingSolidus:{reason:`Unexpected trailing slash on start tag of non-void element`,description:"Unexpected `/`. Expected `>` instead"},noncharacterCharacterReference:{reason:`Unexpected noncharacter code point referenced by character reference`,description:`Unexpected code point. Do not use noncharacters in HTML`},noncharacterInInputStream:{reason:`Unexpected noncharacter character`,description:"Unexpected code point `%x`. Do not use noncharacters in HTML"},nullCharacterReference:{reason:`Unexpected NULL character referenced by character reference`,description:`Unexpected code point. Do not use NULL characters in HTML`},openElementsLeftAfterEof:{reason:`Unexpected end of file`,description:`Unexpected end of file. Expected closing tag instead`,url:!1},surrogateCharacterReference:{reason:`Unexpected surrogate character referenced by character reference`,description:`Unexpected code point. Do not use lone surrogate characters in HTML`},surrogateInInputStream:{reason:`Unexpected surrogate character`,description:"Unexpected code point `%x`. Do not use lone surrogate characters in HTML"},unexpectedCharacterAfterDoctypeSystemIdentifier:{reason:`Invalid character after system identifier in doctype`,description:"Unexpected character at `%c`. Expected `>`"},unexpectedCharacterInAttributeName:{reason:`Unexpected character in attribute name`,description:"Unexpected `%c`. Expected whitespace, `/`, `>`, `=`, or probably an ASCII letter"},unexpectedCharacterInUnquotedAttributeValue:{reason:`Unexpected character in unquoted attribute value`,description:"Unexpected `%c`. Quote the attribute value to include it"},unexpectedEqualsSignBeforeAttributeName:{reason:`Unexpected equals sign before attribute name`,description:"Unexpected `%c`. Add an attribute name before it"},unexpectedNullCharacter:{reason:`Unexpected NULL character`,description:"Unexpected code point `%x`. Do not use NULL characters in HTML"},unexpectedQuestionMarkInsteadOfTagName:{reason:`Unexpected question mark instead of tag name`,description:"Unexpected `%c`. Expected an ASCII letter instead"},unexpectedSolidusInTag:{reason:`Unexpected slash in tag`,description:"Unexpected `%c-1`. Expected it followed by `>` or in a quoted attribute value"},unknownNamedCharacterReference:{reason:`Unexpected unknown named character reference`,description:`Unexpected character reference. Expected known named character references`}},se=`https://html.spec.whatwg.org/multipage/parsing.html#parse-error-`,R=/-[a-z]/g,z=/%c(?:([-+])(\d+))?/g,B=/%x/g,V={2:!0,1:!1,0:null},H={};function ce(e,t){let n=t||H,r=n.onerror,o=e instanceof a?e:new a(e),s=n.fragment?i:l,c=String(o),u=s(c,{sourceCodeLocationInfo:!0,onParseError:n.onerror?d:null,scriptingEnabled:!1});return E(u,{file:o,space:n.space,verbose:n.verbose});function d(e){let t=e.code,i=le(t),a=n[i]??!0,s=typeof a==`number`?a:+!!a;if(s){let n=L[i],a=new v(l(n.reason),{place:{start:{line:e.startLine,column:e.startCol,offset:e.startOffset},end:{line:e.endLine,column:e.endCol,offset:e.endOffset}},ruleId:t,source:`hast-util-from-html`});o.path&&(a.file=o.path,a.name=o.path+`:`+a.name),a.fatal=V[s],a.note=l(n.description),a.url=n.url===!1?void 0:se+t,r(a)}function l(t){return t.replace(z,n).replace(B,r);function n(t,n,r){let i=(r?Number.parseInt(r,10):0)*(n===`-`?-1:1);return de(c.charAt(e.startOffset+i))}function r(){return fe(c.charCodeAt(e.startOffset))}}}}function le(e){return e.replace(R,ue)}function ue(e){return e.charAt(1).toUpperCase()}function de(e){return e==="`"?"` ` `":e}function fe(e){return`0x`+e.toString(16).toUpperCase()}var U=e(k(),1),pe=class extends Error{code;suggestions;status;details;constructor(e,t,n={}){super(t,n.cause===void 0?void 0:{cause:n.cause}),this.name=`RvwError`,this.code=e,this.suggestions=n.suggestions??[],this.status=n.status??400,this.details=n.details}toJSON(){return{code:this.code,message:this.message,suggestions:this.suggestions,...this.details===void 0?{}:{details:this.details}}}},me=`rvw-ref:`,W=`rvw-source:`,he=/^[A-Za-z][A-Za-z\d+.-]*:/u,ge=/^data:image\/(?:png|jpeg|gif|webp|avif);base64,[A-Za-z\d+/=\s]+$/u,_e=/<\s*\/?\s*(?:html|head|body)(?:\s|>)/iu,G=new Set(`a.article.aside.b.blockquote.br.button.caption.code.col.colgroup.dd.details.div.dl.dt.em.figcaption.figure.footer.h1.h2.h3.h4.h5.h6.header.hr.i.img.input.kbd.label.li.main.mark.nav.ol.option.p.pre.section.select.small.span.strong.style.sub.summary.sup.table.tbody.td.textarea.tfoot.th.thead.tr.ul`.split(`.`)),ve=new Set([`circle`,`clipPath`,`defs`,`desc`,`ellipse`,`g`,`line`,`linearGradient`,`marker`,`mask`,`path`,`polygon`,`polyline`,`radialGradient`,`rect`,`stop`,`svg`,`symbol`,`text`,`title`,`tspan`,`use`]),ye=new Set([`audio`,`base`,`canvas`,`embed`,`frame`,`iframe`,`link`,`meta`,`object`,`script`,`video`,`foreignobject`]),K=new Set([`article`,`aside`,`details`,`figure`,`img`,`section`,`svg`,`table`]),q=new Set([`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`,`className`,`dir`,`hidden`,`id`,`lang`,`role`,`style`,`tabIndex`,`title`]),be=new Map([[`a`,new Set([`href`,`hrefLang`])],[`blockquote`,new Set([`cite`])],[`button`,new Set([`disabled`,`name`,`type`,`value`])],[`col`,new Set([`span`,`width`])],[`details`,new Set([`open`])],[`img`,new Set([`alt`,`decoding`,`height`,`loading`,`src`,`width`])],[`input`,new Set([`accept`,`autoComplete`,`checked`,`disabled`,`max`,`maxLength`,`min`,`minLength`,`multiple`,`name`,`placeholder`,`readOnly`,`required`,`size`,`step`,`type`,`value`])],[`label`,new Set([`htmlFor`])],[`li`,new Set([`value`])],[`ol`,new Set([`reversed`,`start`,`type`])],[`option`,new Set([`disabled`,`label`,`selected`,`value`])],[`select`,new Set([`disabled`,`multiple`,`name`,`required`,`size`])],[`td`,new Set([`colSpan`,`headers`,`rowSpan`])],[`textarea`,new Set([`cols`,`disabled`,`maxLength`,`minLength`,`name`,`placeholder`,`readOnly`,`required`,`rows`,`wrap`])],[`th`,new Set([`abbr`,`colSpan`,`headers`,`rowSpan`,`scope`])]]),xe=new Set(`alignmentBaseline.clipPath.clipPathUnits.cx.cy.d.dominantBaseline.dx.dy.fill.fillOpacity.fillRule.fontFamily.fontSize.fontStyle.fontWeight.gradientTransform.gradientUnits.height.href.lengthAdjust.markerEnd.markerHeight.markerMid.markerStart.markerUnits.markerWidth.mask.maskContentUnits.maskUnits.offset.opacity.orient.pathLength.points.preserveAspectRatio.r.refX.refY.rx.ry.spreadMethod.stopColor.stopOpacity.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.textAnchor.textLength.transform.vectorEffect.viewBox.width.x.x1.x2.xmlns.y.y1.y2`.split(`.`)),Se=new Set([`clipPath`,`fill`,`markerEnd`,`markerMid`,`markerStart`,`mask`,`stroke`]);function Ce(e){let t=c(e),n=[],r=e=>{if(e.type===`code`&&e.lang===`html-preview`&&typeof e.value==`string`&&e.position){let t=e.position.start.line+1;n.push({startLine:t,endLine:t+Math.max(1,e.value.split(`
|
|
2
|
+
`).length)-1})}e.children?.forEach(r)};return r(t),n}function J(e,t){return t+(e?.start.line??1)}function Y(e,t){throw new pe(`INVALID_INPUT`,`html-preview L${e}: ${t}`)}function we(e){return e.replace(/\\([\da-f]{1,6}\s?|.)/giu,(e,t)=>{let n=t.trim();if(/^[\da-f]{1,6}$/iu.test(n)){let e=Number.parseInt(n,16);return e===0||e>1114111?`�`:String.fromCodePoint(e)}return t})}function Te(e,t){let n=we(e.replace(/\/\*[\s\S]*?\*\//gu,` `)).toLowerCase().replace(/url\s*\(\s*(["']?)#[a-z_][\w:.-]*\1\s*\)/giu,`internal-fragment`);(/@import\b|@font-face\b|(?:^|[^-])url\s*\(|image-set\s*\(|(?:^|[^-])image\s*\(|expression\s*\(|-moz-binding\s*:|behavior\s*:/u.test(n)||/(?:https?|file|blob|data):|\/\//u.test(n))&&Y(t,`network resourceを参照するCSSは使用できません。`)}function X(e){let t=e.trim();if(t.length===0||t.startsWith(`#`)||t.startsWith(`?`)||t.startsWith(`//`)||he.test(t))return null;let n=t.split(/[?#]/u,1)[0];if(!n)return null;let r;try{r=decodeURIComponent(n)}catch{return null}if(r.includes(`\\`)||r.includes(`\0`))return null;let i=[];for(let e of r.split(`/`))if(!(!e||e===`.`)){if(e===`..`){if(i.length===0)return null;i.pop();continue}i.push(e)}return i.length>0?i.join(`/`):null}function Ee(e,t,n){return q.has(t)||/^aria[A-Z]/u.test(t)||t===`dataRvwCommentable`||n&&xe.has(t)?!0:be.get(e)?.has(t)??!1}function Z(e,t){let n=e.properties?.[t];return typeof n==`string`?n:typeof n==`number`||typeof n==`boolean`||typeof n==`bigint`?String(n):Array.isArray(n)?n.filter(e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`).map(String).join(` `):null}function De(e,t,n,r){let i=e.trim();if(i.toLowerCase().startsWith(me)){n&&Y(t,`inline SVGのhrefはfragmentだけを使用できます。`),r.push(i.slice(8));return}i.startsWith(`#`)||!n&&(/^https?:/iu.test(i)||X(i))||(/^javascript:/iu.test(i)&&Y(t,`javascript: URLは使用できません。`),Y(t,n?`inline SVGのexternal hrefは使用できません。`:`link ${i} は使用できません。`))}function Oe(e,t){let n=[],r=[],i=new Set,a=0,o=(e,s)=>{if(e.type===`comment`){e.value?.startsWith(W)&&Y(J(e.position,t),`内部source markerは指定できません。`);return}if(e.type===`doctype`&&Y(J(e.position,t),`doctypeはfragment内で使用できません。`),e.type!==`element`||!e.tagName){e.children?.forEach(e=>o(e,s));return}let c=e.tagName,l=c.toLowerCase(),u=J(e.position,t),d=s||l===`svg`;ye.has(l)&&Y(u,`<${c}> は使用できません。`),!G.has(c)&&!ve.has(c)&&Y(u,`<${c}> は使用できません。`);for(let t of Object.keys(e.properties??{}))/^on/iu.test(t)&&Y(u,`${t.toLowerCase()} attribute は使用できません。`),t===`srcDoc`&&Y(u,`srcdoc attribute は使用できません。`),(/^dataRvwSource/iu.test(t)||/^dataRvw(?:Node|Text|CommentSurface)/iu.test(t))&&Y(u,`内部data-rvw-source-* attributeは指定できません。`),Ee(c,t,d)||Y(u,`<${c}>の${t} attribute は使用できません。`),i.add(t);let f=Z(e,`style`);f!==null&&Te(f,u),c===`style`&&Te(e.children?.map(e=>e.value??``).join(``)??``,u);let p=Z(e,`href`);if(p!==null&&De(p,u,d,n),d)for(let t of Se){let n=Z(e,t);n!==null&&Te(n,u)}if(c===`img`){a+=1;let t=Z(e,`src`);if(t||Y(u,`<img>にはsrcが必要です。`),t.startsWith(`data:`))ge.test(t)||Y(u,`inline imageは対応するbase64 data:imageだけを使用できます。`);else{let e=X(t);e||Y(u,`外部画像 ${t} は使用できません。`),r.push(e)}}e.children?.forEach(e=>o(e,d))};return o(e,!1),a>32&&Y(t,`画像はWalkthrough全体で32件以下にしてください。`),{referenceIds:n,repositoryImages:r,propertyNames:i,imageCount:a}}function ke(e){return{allowComments:!0,allowDoctypes:!1,ancestors:{},attributes:{"*":[...e]},clobber:[],protocols:{href:[`http`,`https`,`rvw-ref`],src:[`data`]},required:{},strip:[...ye],tagNames:[...G,...ve]}}function Ae(e,t){return e.position?{startLine:t+e.position.start.line,endLine:t+e.position.end.line}:null}function je(e,t){let n=Z(e,`alt`)?.trim(),r=Z(e,`title`)?.trim();e.tagName=`span`,e.properties={className:[`rvw-html-image-placeholder`],dataRvwImagePath:t,role:`img`,ariaLabel:n||r||`Missing image: ${t}`,...r?{title:r}:{}},e.children=[{type:`text`,value:n||r||`Image unavailable: ${t}`}]}function Me(e,t,n){let r=(e,i=!1)=>{if(e.type!==`element`||!e.tagName){if(e.children){let n=[];for(let a of e.children){let e=!i&&a.type===`text`?Ae(a,t):null;e&&a.value?.trim()&&n.push({type:`comment`,value:`${W}${e.startLine}:${e.endLine}`}),r(a,i),n.push(a)}e.children=n}return}let a=Ae(e,t);if(e.properties??={},a&&(e.properties.dataRvwSourceStartLine=a.startLine,e.properties.dataRvwSourceEndLine=a.endLine),(K.has(e.tagName)||Object.hasOwn(e.properties,`dataRvwCommentable`))&&(e.properties.dataRvwCommentSurface=`true`),e.tagName===`img`){let t=Z(e,`src`);if(t&&!t.startsWith(`data:`)){let r=X(t),i=r?n.get(r):null;r&&i?(e.properties.src=i,e.properties.dataRvwImagePath=r):r&&je(e,r)}}if(e.children){let n=[];for(let i of e.children){let a=e.tagName!==`style`&&i.type===`text`?Ae(i,t):null;a&&i.value?.trim()&&n.push({type:`comment`,value:`${W}${a.startLine}:${a.endLine}`}),r(i,e.tagName===`style`),n.push(i)}e.children=n}};r(e)}function Ne(e,t,n=new Map){_e.test(e)&&Y(t+1,`<html>、<head>、<body>はfragment内で使用できません。`);let r=ce(e,{fragment:!0}),i=Oe(r,t),a=m(r,ke(i.propertyNames));Me(a,t,n);let o=Math.max(1,e.split(`
|
|
3
|
+
`).length);return{startLine:t+1,endLine:t+o,imageCount:i.imageCount,referenceIds:i.referenceIds,repositoryImages:i.repositoryImages,html:M(a)}}function Pe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Fe(e,t,n,r){return[...r].sort((e,t)=>t.length-e.length).find(r=>{let i=`${t}${r}`;return n?RegExp(`${Pe(i)}-\\d+$`).test(e):e.endsWith(i)})??null}function Q(e,t,n,r,i=!0){return Array.from(e.querySelectorAll(t)).flatMap(e=>{let t=Fe(e.id,n,i,r);return t?[{bindingKey:t,element:e}]:[]})}var Ie={flowchart:{targets:(e,t)=>Q(e,`g.node[id]`,`-flowchart-`,t)},classDiagram:{targets:(e,t)=>Q(e,`g.node[id]`,`-classId-`,t)},sequenceDiagram:{targets:(e,t)=>{let n=new Set(t);return Array.from(e.querySelectorAll(`g[data-et="participant"][data-id]`)).flatMap(e=>{let t=e.dataset.id;return t&&n.has(t)?[{bindingKey:t,element:e}]:[]})}},"stateDiagram-v2":{targets:(e,t)=>Q(e,`g.statediagram-state[id]`,`-state-`,t)},erDiagram:{targets:(e,t)=>Q(e,`g.node[id]`,`-entity-`,t)},"architecture-beta":{targets:(e,t)=>Q(e,`g.architecture-service[id]`,`-service-`,t,!1)}};function Le(e){for(let t of e.split(`
|
|
4
|
+
`)){let e=t.trim();if(!e||e.startsWith(`%%`))continue;let n=e.match(/^(flowchart|graph|classDiagram|sequenceDiagram|stateDiagram-v2|erDiagram|architecture-beta)\b/)?.[1];return n===`graph`?`flowchart`:n??null}return null}function Re(e,t,n){let r=Le(e);return r?Ie[r].targets(t,n):[]}var $=O();function ze({action:e,markers:t,composer:n,composerAnchor:r,onComment:i,onActivateComment:a}){let o=(0,U.useRef)(null);return(0,U.useLayoutEffect)(()=>{if(!n)return;let e=window.requestAnimationFrame(()=>{o.current?.scrollIntoView({block:`nearest`,inline:`nearest`})});return()=>window.cancelAnimationFrame(e)},[n]),(0,$.jsxs)(`div`,{className:`walkthrough-html-overlay`,"aria-hidden":e===null&&t.length===0&&!n,children:[t.map(e=>(0,$.jsx)(`button`,{className:`walkthrough-html-marker${e.active?` is-active`:``}`,style:{left:e.left,top:e.top},"aria-label":e.label,title:e.label,onClick:()=>a(e.id),children:(0,$.jsx)(g,{})},e.id)),e&&(0,$.jsxs)(`button`,{className:`walkthrough-html-comment-action`,style:{left:e.left,top:e.top},"aria-label":e.label,title:e.label,onPointerDown:e=>e.preventDefault(),onClick:()=>i(e),children:[(0,$.jsx)(g,{}),`コメント`]}),n&&r&&(0,$.jsx)(`div`,{ref:o,className:`walkthrough-html-comment-composer`,style:{left:r.left,top:r.top},children:n})]})}var Be=240,Ve=2e4,He=/^rvw-source:(\d+):(\d+)$/u,Ue=new Set([`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/avif`,`image/svg+xml`]),We=[`default-src 'none'`,`script-src 'none'`,`style-src 'unsafe-inline'`,`img-src data:`,`font-src 'none'`,`connect-src 'none'`,`media-src 'none'`,`object-src 'none'`,`frame-src 'none'`,`worker-src 'none'`,`base-uri 'none'`,`form-action 'none'`].join(`; `);function Ge(e){let t=`
|
|
5
|
+
--rvw-bg: #161b22;
|
|
6
|
+
--rvw-fg: #e6edf3;
|
|
7
|
+
--rvw-muted: #8b949e;
|
|
8
|
+
--rvw-border: #30363d;
|
|
9
|
+
--rvw-accent: #58a6ff;
|
|
10
|
+
--rvw-panel: #21262d;
|
|
11
|
+
--rvw-highlight: #d29922;
|
|
12
|
+
color-scheme: dark;`,n=`
|
|
13
|
+
--rvw-bg: #ffffff;
|
|
14
|
+
--rvw-fg: #1f2328;
|
|
15
|
+
--rvw-muted: #57606a;
|
|
16
|
+
--rvw-border: #d8dee4;
|
|
17
|
+
--rvw-accent: #0969da;
|
|
18
|
+
--rvw-panel: #f6f8fa;
|
|
19
|
+
--rvw-highlight: #9a6700;
|
|
20
|
+
color-scheme: light;`;return e===`dark`?`:root {${t}}`:e===`light`?`:root {${n}}`:`:root {${n} color-scheme: light dark;} @media (prefers-color-scheme: dark) { :root {${t}} }`}function Ke(e){return`${Ge(e)}
|
|
21
|
+
*, *::before, *::after { box-sizing: border-box; }
|
|
22
|
+
html { background: transparent; }
|
|
23
|
+
body { margin: 0; overflow-x: auto; overflow-y: hidden; background: var(--rvw-bg); color: var(--rvw-fg); }
|
|
24
|
+
body, button, input, select, textarea { font: 14px/1.5 var(--rvw-font-sans, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif); }
|
|
25
|
+
code, kbd, pre { font-family: var(--rvw-font-mono, "SFMono-Regular", Consolas, monospace); }
|
|
26
|
+
img, svg { max-width: 100%; }
|
|
27
|
+
a { color: var(--rvw-accent); cursor: pointer; }
|
|
28
|
+
button, input, select, textarea { color: inherit; }
|
|
29
|
+
.rvw-preview-root { min-width: 0; padding: 16px; }
|
|
30
|
+
.rvw-html-image-placeholder { display: grid; min-height: 96px; place-items: center; padding: 16px; border: 1px dashed var(--rvw-border); border-radius: 6px; background: var(--rvw-panel); color: var(--rvw-muted); text-align: center; }
|
|
31
|
+
[data-rvw-comment-surface="true"] { cursor: default; }
|
|
32
|
+
::highlight(rvw-pane-find-left-match), ::highlight(rvw-pane-find-right-match) { background-color: light-dark(rgb(234 179 8 / 0.42), rgb(250 204 21 / 0.38)); }
|
|
33
|
+
::highlight(rvw-pane-find-left-current), ::highlight(rvw-pane-find-right-current) { background-color: light-dark(rgb(245 139 10 / 0.82), rgb(249 115 22 / 0.78)); color: light-dark(#17120a, #fff); }
|
|
34
|
+
`}var qe=`
|
|
35
|
+
.rvw-html-active-comment {
|
|
36
|
+
outline: 3px solid var(--rvw-highlight) !important;
|
|
37
|
+
outline-offset: 3px !important;
|
|
38
|
+
}
|
|
39
|
+
`;function Je(e,t){return`<meta http-equiv="Content-Security-Policy" content="${We}">
|
|
40
|
+
<meta name="color-scheme" content="light dark">
|
|
41
|
+
<style>${Ke(t)}</style>
|
|
42
|
+
<div class="rvw-preview-root" data-pane-find-text>${e}</div>
|
|
43
|
+
<style>${qe}</style>`}function Ye(e){if(!e)return null;let t=e,n=Number(t.dataset.rvwSourceStartLine),r=Number(t.dataset.rvwSourceEndLine);return!Number.isInteger(n)||!Number.isInteger(r)||n<1||r<1?null:{startLine:Math.min(n,r),endLine:Math.max(n,r)}}function Xe(e){return e&&typeof e==`object`&&`closest`in e?e:null}function Ze(e,t){return e.startLine<=t.endLine&&e.endLine>=t.startLine}function Qe(e){let t=0,n=e;for(;n;)t+=1,n=n.parentElement;return t}function $e(e,t){let n=[...e.querySelectorAll(`[data-rvw-source-start-line]`)].map(e=>({element:e,range:Ye(e)})).filter(e=>e.range!==null&&Ze(e.range,t));return n.sort((e,n)=>(e.range.startLine<=t.startLine&&e.range.endLine>=t.endLine?0:1)-(n.range.startLine<=t.startLine&&n.range.endLine>=t.endLine?0:1)||e.range.endLine-e.range.startLine-(n.range.endLine-n.range.startLine)||Qe(n.element)-Qe(e.element)),n[0]?.element??null}function et(e,t){let n=``,r=32768;for(let t=0;t<e.length;t+=r)n+=String.fromCharCode(...e.subarray(t,t+r));return`data:${t};base64,${window.btoa(n)}`}async function tt(e,t,n,r){let i=[...new Set(n)],a=new Map,o=0;for(let n of i){if(o>=20971520){a.set(n,null);continue}try{let i=await fetch(x(e,t,n),{signal:r}),s=i.headers.get(`content-type`)?.split(`;`,1)[0]?.toLowerCase(),c=Number(i.headers.get(`content-length`));if(!i.ok||!s||!Ue.has(s)||Number.isFinite(c)&&(c>5242880||o+c>20971520)){await i.body?.cancel(),a.set(n,null);continue}let l=new Uint8Array(await i.arrayBuffer());if(l.byteLength>5242880||o+l.byteLength>20971520){a.set(n,null);continue}o+=l.byteLength,a.set(n,et(l,s))}catch(e){if(r.aborted)throw e;a.set(n,null)}}return a}function nt({source:e,fenceRange:t,pullRequestId:n,sourceOid:r,references:i,placedComments:a,activeCommentId:o,navigationLine:s,themePreference:c,commentComposer:l,onOpenReference:u,onOpenRepositoryLink:d,onCommentRange:f,onActivateComment:p}){let m=(0,U.useRef)(null),h=(0,U.useRef)(null),g=(0,U.useRef)(null),ee=(0,U.useRef)(new WeakMap),[_,v]=(0,U.useState)(new Map),[y,b]=(0,U.useState)(Be),[x,S]=(0,U.useState)(null),[C,te]=(0,U.useState)(null),[ne,w]=(0,U.useState)([]),T=(0,U.useMemo)(()=>{try{return{value:Ne(e,t.startLine,_)}}catch(e){return{error:e instanceof Error?e.message:`HTML previewを表示できません。`}}},[t.startLine,_,e]),E=(0,U.useMemo)(()=>{try{return Ne(e,t.startLine).repositoryImages}catch{return[]}},[t.startLine,e]);(0,U.useEffect)(()=>{let e=new AbortController;return v(new Map),E.length>0&&tt(n,r,E,e.signal).then(t=>{e.signal.aborted||v(t)},()=>void 0),()=>e.abort()},[E,n,r]);let D=(0,U.useCallback)(()=>{let e=g.current,t=m.current,n=h.current,r=e?.contentDocument;if(!e||!t||!n||!r)return;let i=Math.max(r.documentElement.scrollHeight,r.body?.scrollHeight??0),s=Math.min(Ve,Math.max(Be,i));b(e=>Math.abs(e-s)<1?e:s),r.body&&(r.body.style.overflowY=i>Ve?`auto`:`hidden`);let c=e.getBoundingClientRect(),l=n.getBoundingClientRect();w(a.flatMap(({comment:e,placement:t})=>{if(t.outdated||!t.range)return[];let n=$e(r,t.range);if(!n)return[];let i=n.getBoundingClientRect();return[{id:e.id,left:c.left-l.left+i.right,top:c.top-l.top+i.top,active:e.id===o,label:`${e.id}のコメントを開く`}]}))},[o,a]);return(0,U.useLayoutEffect)(()=>{D()},[y,D]),(0,U.useEffect)(()=>{let e=g.current,t=m.current,n=h.current;if(!e||!t||!n||!T.value)return;let a=()=>void 0,o=()=>{a();let o=e.contentDocument;if(!o)return;let s=new WeakMap,c=o.createTreeWalker(o,NodeFilter.SHOW_COMMENT),l=c.nextNode();for(;l;){let e=He.exec(l.nodeValue??``),t=l.nextSibling;e&&t?.nodeType===Node.TEXT_NODE&&s.set(t,{startLine:Number(e[1]),endLine:Number(e[2])}),l=c.nextNode()}ee.current=s;let f=e=>Math.max(48,Math.min(n.clientWidth-48,e)),p=()=>{let e=o.getSelection();if(!e||e.rangeCount===0||e.isCollapsed||!e.toString().trim())return null;let t=e.getRangeAt(0),n=o.createTreeWalker(o,NodeFilter.SHOW_TEXT),r=[],i=n.nextNode();for(;i;){if(t.intersectsNode(i)){let e=s.get(i);e&&r.push(e)}i=n.nextNode()}if(r.length===0){let e=Ye((t.commonAncestorContainer.nodeType===Node.ELEMENT_NODE?t.commonAncestorContainer:t.commonAncestorContainer.parentElement)?.closest(`[data-rvw-source-start-line]`)??null);e&&r.push(e)}return r.length===0?null:{range:{startLine:Math.min(...r.map(e=>e.startLine)),endLine:Math.max(...r.map(e=>e.endLine))},rect:t.getBoundingClientRect()}},m=()=>{let t=p();if(!t){S(null);return}let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();S({range:t.range,left:f(r.left-i.left+t.rect.left+t.rect.width/2),top:r.top-i.top+t.rect.bottom+8,label:`選択したテキストへコメント`})},h=t=>{if(o.getSelection()?.toString().trim())return;let r=Xe(t.target)?.closest(`[data-rvw-comment-surface='true']`)??null,i=Ye(r);if(!r||!i){S(null);return}let a=r.getBoundingClientRect(),s=e.getBoundingClientRect(),c=n.getBoundingClientRect();S({range:i,left:f(s.left-c.left+a.right),top:s.top-c.top+a.top,label:`このvisualへコメント`})},g=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return;let t=e.key.toLowerCase(),n=t===`f`&&!e.shiftKey,r=t===`p`&&!e.shiftKey,i=t===`f`&&e.shiftKey;if(!n&&!r&&!i)return;let a=new KeyboardEvent(`keydown`,{key:e.key,code:e.code,location:e.location,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,repeat:e.repeat,bubbles:!0,cancelable:!0});window.document.dispatchEvent(a)||e.preventDefault()},_=e=>{let t=Xe(e.target)?.closest(`a[href]`);if(!t)return;e.preventDefault(),e.stopPropagation();let n=t.getAttribute(`href`)?.trim()??``,a=e.metaKey||e.ctrlKey;if(n.startsWith(`rvw-ref:`)){let e=i.get(n.slice(8));e&&u(e,a);return}if(n.startsWith(`#`)){o.getElementById(n.slice(1))?.scrollIntoView({block:`center`});return}if(/^https?:/iu.test(n)){window.open(n,`_blank`,`noopener,noreferrer`);return}let s=X(n);s&&d(s,r,a)};o.addEventListener(`selectionchange`,m),o.addEventListener(`pointerup`,m),o.addEventListener(`pointermove`,h),o.addEventListener(`keydown`,g),o.addEventListener(`click`,_,!0),o.addEventListener(`toggle`,D,!0);let v=null,y=()=>{v===null&&(v=window.requestAnimationFrame(()=>{v=null,D()}))};o.addEventListener(`scroll`,y,!0);let b=[...o.images];for(let e of b)e.addEventListener(`load`,D),e.addEventListener(`error`,D);let x=new ResizeObserver(D);x.observe(o.documentElement),o.body&&x.observe(o.body);let C=new ResizeObserver(D);C.observe(t),D(),a=()=>{o.removeEventListener(`selectionchange`,m),o.removeEventListener(`pointerup`,m),o.removeEventListener(`pointermove`,h),o.removeEventListener(`keydown`,g),o.removeEventListener(`click`,_,!0),o.removeEventListener(`toggle`,D,!0),o.removeEventListener(`scroll`,y,!0),v!==null&&window.cancelAnimationFrame(v);for(let e of b)e.removeEventListener(`load`,D),e.removeEventListener(`error`,D);x.disconnect(),C.disconnect()}};return e.addEventListener(`load`,o),e.contentDocument?.readyState===`complete`&&o(),()=>{e.removeEventListener(`load`,o),a()}},[u,d,i,T.value,r,D]),(0,U.useEffect)(()=>{let e=g.current?.contentDocument;if(!e)return;for(let t of e.querySelectorAll(`.rvw-html-active-comment`))t.classList.remove(`rvw-html-active-comment`);let t=a.find(({comment:e,placement:t})=>e.id===o&&!t.outdated&&t.range)?.placement;if(!t?.range)return;let n=$e(e,t.range);n&&(n.classList.add(`rvw-html-active-comment`),m.current?.scrollIntoView({block:`nearest`,inline:`nearest`}),n.scrollIntoView({block:`center`,inline:`nearest`}),D())},[o,a,D]),(0,U.useEffect)(()=>{if(s===null)return;let e=g.current?.contentDocument;if(!e)return;let t=$e(e,{startLine:s,endLine:s});t&&(m.current?.scrollIntoView({block:`center`,inline:`nearest`}),t.scrollIntoView({block:`center`,inline:`nearest`}))},[s,T.value]),T.error?(0,$.jsx)(`div`,{className:`walkthrough-html-preview-error`,role:`alert`,children:T.error}):(0,$.jsxs)(`div`,{className:`walkthrough-html-preview-shell`,ref:m,"data-rvw-navigation-start-line":t.startLine,"data-rvw-navigation-end-line":t.endLine,children:[(0,$.jsxs)(`div`,{className:`walkthrough-html-preview-toolbar`,"data-pane-find-ignore":!0,children:[(0,$.jsx)(`span`,{children:`HTML preview`}),(0,$.jsx)(`span`,{children:`textまたはvisualを選択してコメント`})]}),(0,$.jsxs)(`div`,{className:`walkthrough-html-preview-frame-shell`,ref:h,onPointerLeave:()=>S(null),children:[(0,$.jsx)(`iframe`,{ref:g,title:`Walkthrough HTML preview L${t.startLine}`,"data-pane-find-child-document":!0,sandbox:`allow-same-origin`,srcDoc:Je(T.value?.html??``,c),style:{height:y}}),(0,$.jsx)(ze,{action:x,markers:ne,composer:C?l(C.label):null,composerAnchor:C,onComment:e=>{g.current?.contentDocument?.getSelection()?.removeAllRanges(),S(null);let t=m.current?.clientWidth??0,n=Math.min(420,Math.max(0,t-24))/2,r=t>0?Math.max(12+n,Math.min(t-12-n,e.left)):e.left;te({...e,left:r}),f(e.range)},onActivateComment:p})]})]})}var rt=2400;function it(e){return U.Children.toArray(e).map(e=>typeof e==`string`||typeof e==`number`?String(e):(0,U.isValidElement)(e)?it(e.props.children):``).join(``)}function at(e,t){return!!(e&&t&&e.startLine===t.startLine&&e.endLine===t.endLine)}function ot(){return(0,$.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,width:`16`,height:`16`,children:(0,$.jsx)(`path`,{fill:`currentColor`,d:`M5.5 1.75A1.75 1.75 0 0 1 7.25 0h1.5a1.75 1.75 0 0 1 1.75 1.75V2h3a.75.75 0 0 1 0 1.5h-.64l-.68 10.03A2.5 2.5 0 0 1 9.69 16H6.31a2.5 2.5 0 0 1-2.49-2.47L3.14 3.5H2.5a.75.75 0 0 1 0-1.5h3v-.25Zm1.5 0V2h2v-.25a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25ZM4.65 3.5l.67 9.96c.02.58.46 1.04.99 1.04h3.38c.53 0 .97-.46.99-1.04l.67-9.96h-6.7Z`})})}function st({source:e,sourceRange:t,commented:n,bindings:i,references:a,themePreference:o,onOpenReference:s,onCommentRange:c,commentComposer:l,reviewContext:u}){let d=(0,U.useRef)(null),p=!!l,[m,h]=(0,U.useState)(!1),[_,v]=(0,U.useState)(``);(0,U.useLayoutEffect)(()=>{if(!p)return;let e=window.requestAnimationFrame(()=>{d.current?.scrollIntoView({block:`nearest`,inline:`nearest`})});return()=>window.cancelAnimationFrame(e)},[p]);let y=(0,U.useCallback)(e=>{if(!(e instanceof Element))return;let t=e.closest(`[data-walkthrough-reference-id]`)?.dataset.walkthroughReferenceId;return t?a.get(t):void 0},[a]),b=(0,U.useCallback)(t=>{for(let{bindingKey:n,element:r}of Re(e,t,Object.keys(i))){let e=i[n],t=e?a.get(e):void 0;t&&(r.classList.add(`walkthrough-diagram-node--linked`),r.setAttribute(`role`,`button`),r.setAttribute(`tabindex`,`0`),r.setAttribute(`aria-label`,`${t.label}をコードで開く`),r.dataset.walkthroughReferenceId=t.id)}},[i,a,e]),x=t?u.placedComments.filter(({placement:e})=>at(e.range,t)):[],S=t?{pullRequestId:u.pullRequestId,commentCount:x.length,onOpenCodeReference:u.onOpenCommentCodeReference,diagramReferenceBindings:{sourceOid:u.sourceOid,onRendered:b,referenceFromTarget:y,resolveForPeek:u.onResolveReferenceForPeek,onOpenInReview:s},renderComments:e=>(0,$.jsxs)(`div`,{className:`mermaid-diagram-comments`,children:[x.length===0&&!m&&(0,$.jsx)(`p`,{className:`mermaid-comments-empty`,children:`この diagram へのコメントはありません。`}),x.map(({comment:n,placement:r})=>(0,$.jsx)(ee,{comment:n,variant:`sidebar`,draftScope:`${u.draftScope}:mermaid:${t.startLine}-${t.endLine}`,placement:r,markdownSourceOid:u.sourceOid,themePreference:o,cancelDraftOnEscape:!0,onActiveChange:u.onCommentActiveChange,onOpenCodeReference:e,onOpenRepositoryLink:u.onOpenRepositoryLink},n.id)),m?(0,$.jsx)(w,{body:_,label:`Comment on diagram`,pending:u.diagramCommentPending,error:u.diagramCommentError,validationError:void 0,placement:`line`,onBodyChange:v,onCancel:()=>{h(!1),v(``),u.onCancelDiagramComment()},onSubmit:()=>{u.onCreateExpandedDiagramComment(t,_).then(()=>{h(!1),v(``)}).catch(()=>void 0)}}):(0,$.jsxs)(`button`,{className:`mermaid-comment-action`,onClick:()=>{u.onCancelDiagramComment(),h(!0)},children:[(0,$.jsx)(g,{}),`Comment on diagram`]})]})}:void 0;return(0,$.jsx)(f,{source:e,themePreference:o,renderIdPrefix:`rvwWalkthrough`,review:S,renderInline:i=>(0,$.jsxs)(`div`,{className:`walkthrough-diagram-shell${n?` has-comment`:``}`,...t?{"data-rvw-navigation-start-line":t.startLine,"data-rvw-navigation-end-line":t.endLine}:{},children:[(0,$.jsxs)(`div`,{className:`walkthrough-diagram-toolbar`,children:[(0,$.jsx)(`span`,{children:`Mermaid diagram`}),(0,$.jsx)(`span`,{children:`強調された要素を選択してコードを開く · Cmd/Ctrlで反対のペイン`}),t&&(0,$.jsxs)(`button`,{className:`button--quiet walkthrough-diagram-comment`,onPointerDown:e=>{e.button===0&&(e.preventDefault(),c(t))},onClick:e=>{e.detail===0&&c(t)},children:[(0,$.jsx)(g,{}),`図全体へコメント`]}),i]}),(0,$.jsx)(r,{className:`walkthrough-diagram`,source:e,themePreference:o,renderIdPrefix:`rvwWalkthrough`,errorClassName:`walkthrough-diagram-error`,onRendered:b,onPointerDown:e=>{let t=y(e.target);t&&(e.preventDefault(),e.stopPropagation(),s(t,e.metaKey||e.ctrlKey))},onKeyDown:e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=y(e.target);t&&(e.preventDefault(),s(t,!1))}}),l&&(0,$.jsx)(`div`,{className:`walkthrough-diagram-comment-composer`,ref:d,children:l})]})})}var ct=(0,U.createContext)(null);function lt({range:e,label:t,pending:n,error:r,onCancel:i,onSubmit:a}){let[o,s]=(0,U.useState)(``),c=t??(e.startLine===e.endLine?`L${e.startLine}へコメント`:`L${e.startLine}–${e.endLine}へコメント`);return(0,$.jsx)(w,{body:o,label:c,pending:n,error:r,validationError:void 0,placement:`line`,onBodyChange:s,onCancel:i,onSubmit:()=>a(o)})}var ut=({children:e,node:t,...n})=>{let r=(0,U.useContext)(ct),i=U.Children.count(e)===1?U.Children.only(e):null;if(!r||!(0,U.isValidElement)(i))return(0,$.jsx)(`pre`,{...n,children:e});let a=N(t);if(i.props.className===`language-html-preview`&&a){let e=r.diagramCommentRange&&r.diagramCommentRange.startLine>=a.startLine&&r.diagramCommentRange.endLine<=a.endLine?r.diagramCommentRange:null;return(0,$.jsx)(nt,{source:it(i.props.children).replace(/\n$/u,``),fenceRange:a,pullRequestId:r.pullRequestId,sourceOid:r.sourceOid,references:r.references,placedComments:r.placedComments,activeCommentId:r.activeCommentId,navigationLine:r.navigationLine,themePreference:r.themePreference,onOpenReference:r.onOpenReference,onOpenRepositoryLink:r.onOpenRepositoryLink,onCommentRange:r.onCommentRange,onActivateComment:r.onActivateComment,commentComposer:t=>e?(0,$.jsx)(lt,{range:e,label:t,pending:r.diagramCommentPending,error:r.diagramCommentError,onCancel:r.onCancelDiagramComment,onSubmit:t=>r.onSubmitDiagramComment(e,t)},`${e.startLine}:${e.endLine}`):null})}return i.props.className===`language-mermaid`?(0,$.jsx)(st,{source:it(i.props.children).trim(),sourceRange:a,commented:!!(a&&r.activeCommentId&&r.placedComments.some(({comment:e,placement:t})=>e.id===r.activeCommentId&&t.range&&t.range.startLine<=a.endLine&&t.range.endLine>=a.startLine)),bindings:r.diagramBindings,references:r.references,themePreference:r.themePreference,onOpenReference:r.onOpenReference,onCommentRange:r.onCommentRange,commentComposer:a&&at(a,r.diagramCommentRange)?(0,$.jsx)(lt,{range:a,pending:r.diagramCommentPending,error:r.diagramCommentError,onCancel:r.onCancelDiagramComment,onSubmit:e=>r.onSubmitDiagramComment(a,e)},`${a.startLine}:${a.endLine}`):null,reviewContext:r}):(0,$.jsx)(`pre`,{...n,children:e})},dt=(0,U.memo)(function({pullRequestId:e,body:t,diagramBindings:n,references:r,placedComments:i,activeCommentId:a,navigationLine:s,selectedRange:c,selectionComposerOpen:l,diagramCommentRange:f,markdownSourceOid:p,draftScope:m,themePreference:g,onOpenReference:_,onResolveReferenceForPeek:v,onOpenCommentCodeReference:b,onOpenRepositoryLink:x,onCommentActiveChange:S,onActivateComment:C,onCommentRange:ne,diagramCommentPending:w,diagramCommentError:E,onCancelDiagramComment:O,onSubmitDiagramComment:ie,onCreateExpandedDiagramComment:k}){let A=(0,U.useMemo)(()=>Ce(t),[t]),j=(0,U.useMemo)(()=>i.filter(({placement:e})=>{let t=e.range;return!(t&&A.some(e=>t.startLine>=e.startLine&&t.endLine<=e.endLine))}),[A,i]),M=(0,U.useMemo)(()=>j.map(({comment:e,placement:t})=>({id:e.id,range:t.range})),[j]),N=(0,U.useMemo)(()=>new Map(j.map(({comment:e,placement:t})=>[e.id,{comment:e,placement:t}])),[j]),oe=(0,U.useCallback)(({node:e,children:t,...n})=>{let r=F(e);return r.length===0?(0,$.jsx)(`div`,{...n,children:t}):(0,$.jsx)(`div`,{className:`markdown-inline-comments`,children:r.map(e=>{let t=N.get(e);return t?(0,$.jsx)(ee,{comment:t.comment,variant:`inline`,draftScope:m,placement:t.placement,markdownSourceOid:p,themePreference:g,onActiveChange:S,onOpenCodeReference:b,onOpenRepositoryLink:x},e):null})})},[N,m,p,S,b,x,g]);return(0,$.jsx)(ct.Provider,{value:{pullRequestId:e,sourceOid:p,diagramBindings:n,references:r,placedComments:i,activeCommentId:a,navigationLine:s,diagramCommentRange:f,themePreference:g,onOpenReference:_,onResolveReferenceForPeek:v,onOpenCommentCodeReference:b,onOpenRepositoryLink:x,onCommentActiveChange:S,onActivateComment:C,onCommentRange:ne,diagramCommentPending:w,diagramCommentError:E,onCancelDiagramComment:O,onSubmitDiagramComment:ie,onCreateExpandedDiagramComment:k,draftScope:m},children:(0,$.jsx)(`article`,{className:`walkthrough-markdown`,children:(0,$.jsx)(u,{rehypePlugins:[D,[re,T],[P,{annotations:M,activeCommentId:a,selectedRange:c,composerOpen:l}]],remarkPlugins:[d],urlTransform:e=>e.startsWith(`rvw-ref:`)?e:o(e),components:{div:oe,table:I,a:({href:e,children:t,node:n,...i})=>{let a=y(e),o=a?r.get(a):void 0;return o?(0,$.jsx)(h,{reference:o,className:`walkthrough-inline-reference`,onOpen:_,children:t}):(0,$.jsx)(`a`,{...ae(n),...i,href:e,children:t})},img:({alt:e,title:t,node:n})=>(0,$.jsx)(te,{alt:e,title:t,sourceAttributes:ae(n)}),pre:ut},children:t})})})});function ft({walkthrough:e,paneId:r,comments:i,activeCommentId:a,navigationTarget:o,onNavigationApplied:c,themePreference:l,onCommentActiveChange:u,onActivateComment:d,onOpenReference:f,onResolveReferenceForPeek:m,onOpenCommentCodeReference:h,onOpenRepositoryLink:v,onDeleted:y}){let x=t(),te=s(r,{kind:`walkthrough`,id:e.id,title:e.title,sourceOid:e.sourceOid}),T=(0,U.useRef)(null),E=(0,U.useRef)(null),D=(0,U.useRef)(c);D.current=c;let[re,O]=(0,U.useState)(!1),[k,M]=(0,U.useState)(null),[ae,N]=(0,U.useState)(null),[P,F]=(0,U.useState)(null),[I,L]=(0,U.useState)(``),[se,R]=(0,U.useState)(null),z=(0,U.useRef)(0),B=(0,U.useRef)(null),V=(0,U.useRef)(e);V.current=e;let H=(0,U.useRef)({onOpenReference:f,onResolveReferenceForPeek:m,onOpenCommentCodeReference:h,onOpenRepositoryLink:v,onCommentActiveChange:u,onActivateComment:d});H.current={onOpenReference:f,onResolveReferenceForPeek:m,onOpenCommentCodeReference:h,onOpenRepositoryLink:v,onCommentActiveChange:u,onActivateComment:d};let ce=(0,U.useMemo)(()=>new Map(e.references.map(e=>[e.id,e])),[e.references]);(0,U.useLayoutEffect)(()=>{if(!o||E.current===o.requestId)return;let e=o.requestId,t=window.requestAnimationFrame(()=>{let t=T.current;if(!t)return;if(o.line===null){t.scrollIntoView({behavior:`auto`,block:`start`,inline:`nearest`}),E.current=e,D.current(e);return}let n=String(o.line),r=t.querySelector(`[data-rvw-navigation-start-line="${n}"]`)??t.querySelector(`[data-rvw-source-start-line="${n}"]`)??[...t.querySelectorAll(`[data-rvw-navigation-start-line]`)].find(e=>{let t=Number(e.dataset.rvwNavigationStartLine),n=Number(e.dataset.rvwNavigationEndLine);return t<=o.line&&n>=o.line}),i=r?.closest(`details:not([open])`);i&&(i.open=!0),r&&(r.scrollIntoView({behavior:`auto`,block:`center`,inline:`nearest`}),E.current=e,D.current(e))});return()=>window.cancelAnimationFrame(t)},[o]);let le=(0,U.useCallback)((e,t)=>{z.current+=1;let n=z.current;B.current!==null&&(window.clearTimeout(B.current),B.current=null),R(null),H.current.onOpenReference(V.current,e,t).then(e=>{n!==z.current||!e||(R(e),B.current=window.setTimeout(()=>{R(null),B.current=null},rt))})},[]),ue=(0,U.useCallback)((e,t)=>H.current.onResolveReferenceForPeek(V.current,e,t),[]),de=(0,U.useCallback)((e,t,n)=>H.current.onOpenCommentCodeReference(e,t,n),[]),fe=(0,U.useCallback)((e,t,n)=>H.current.onOpenRepositoryLink(e,t,n),[]),pe=(0,U.useCallback)((e,t)=>H.current.onCommentActiveChange(e,t),[]),me=(0,U.useCallback)(e=>H.current.onActivateComment(e),[]);(0,U.useEffect)(()=>()=>{z.current+=1,B.current!==null&&window.clearTimeout(B.current)},[]);let W=(0,U.useMemo)(()=>i.filter(t=>t.target.kind===`walkthrough`&&t.target.walkthroughId===e.id),[i,e.id]),he=W.reduce((e,t)=>e+t.posts.length,0),ge=(0,U.useMemo)(()=>[...W].sort((e,t)=>e.id.localeCompare(t.id)),[W]),_e=n({queryKey:[`walkthrough-comment-placements`,e.id,e.body,ge.map(e=>[e.id,e.target])],queryFn:async({signal:t})=>await j(e.pullRequestId,ge.map(({id:e})=>e),[{kind:`walkthrough`,walkthroughId:e.id}],t),enabled:ge.length>0,staleTime:1/0}),G=(0,U.useMemo)(()=>{let e=new Map(_e.data?.comments.map(({commentId:e,placements:t})=>[e,t[0]?.placement])??[]);return W.flatMap(t=>{let n=e.get(t.id);return n?[{comment:t,placement:n}]:[]})},[_e.data,W]),ve=(0,U.useMemo)(()=>G.filter(({placement:e})=>!e.outdated&&e.range!==null),[G]),ye=(0,U.useMemo)(()=>G.filter(({comment:e,placement:t})=>e.target.kind===`walkthrough`&&e.target.startLine===null||t.outdated),[G]),K=ne({mutationFn:async({range:t,body:n})=>await ie(`/api/comments`,A({pullRequestId:e.pullRequestId,target:{kind:`walkthrough`,walkthroughId:e.id,startLine:t?.startLine??null,endLine:t?.endLine??null},body:n,authorLabel:`You`})),onMutate:async()=>await C(x,e.pullRequestId),onError:()=>_(x,e.pullRequestId),onSuccess:({comment:t})=>{window.getSelection()?.removeAllRanges(),L(``),O(!1),M(null),N(null),F(null),p(x,e.pullRequestId,t)}}),q=(0,U.useRef)(K);q.current=K;let be=ne({mutationFn:async()=>await ie(`/api/pull-requests/${e.pullRequestId}/walkthroughs/${e.id}`,{...A({}),method:`DELETE`}),onSuccess:async()=>{y(e),await Promise.all([x.invalidateQueries({queryKey:[`walkthroughs`]}),x.invalidateQueries({queryKey:[`walkthrough`]}),x.invalidateQueries({queryKey:[`comments`]}),x.invalidateQueries({queryKey:[`change-sequence`]})])}}),xe=W.filter(e=>e.resolvedAt===null).length,Se=()=>{let e=W.length===0?`紐づくコメントはありません。`:`紐づくコメント ${W.length}件と投稿 ${he}件も削除されます。`;window.confirm(`このウォークスルーを削除します。\n${e}\nコピー済みの参照は無効になります。\n\nこの操作は元に戻せません。`)&&be.mutate()},Ce=k?k.startLine===k.endLine?`L${k.startLine}`:`L${k.startLine}–${k.endLine}`:null,J=(0,U.useCallback)(()=>{window.getSelection()?.removeAllRanges(),q.current.reset(),L(``),M(null),N(null),F(null)},[]),Y=(0,U.useCallback)(e=>{q.current.reset(),L(``),O(!1),M(null),N(e),F(`diagram`)},[]),we=(0,U.useCallback)((e,t)=>{q.current.mutate({range:e,body:t})},[]),Te=(0,U.useCallback)(async(e,t)=>{await q.current.mutateAsync({range:e,body:t})},[]),X=k?(0,$.jsx)(w,{body:I,label:`${Ce??`選択範囲`}へコメント`,pending:K.isPending,error:K.error,validationError:void 0,placement:`line`,onBodyChange:L,onCancel:J,onSubmit:()=>K.mutate({range:k,body:I})}):null,Ee=(0,$.jsx)(dt,{pullRequestId:e.pullRequestId,body:e.body,diagramBindings:e.diagramBindings,references:ce,placedComments:ve,activeCommentId:a,navigationLine:o?.line??null,selectedRange:P===`selection`?k:null,selectionComposerOpen:P===`selection`,diagramCommentRange:ae,markdownSourceOid:e.sourceOid,draftScope:te,themePreference:l,onOpenReference:le,onResolveReferenceForPeek:ue,onOpenCommentCodeReference:de,onOpenRepositoryLink:fe,onCommentActiveChange:pe,onActivateComment:me,onCommentRange:Y,diagramCommentPending:K.isPending,diagramCommentError:K.error,onCancelDiagramComment:J,onSubmitDiagramComment:we,onCreateExpandedDiagramComment:Te});return(0,$.jsxs)(`div`,{className:`walkthrough-viewer`,ref:T,children:[(0,$.jsxs)(`header`,{className:`walkthrough-viewer-header`,children:[(0,$.jsxs)(`div`,{className:`walkthrough-viewer-title`,children:[(0,$.jsx)(`span`,{className:`walkthrough-viewer-icon`,children:(0,$.jsx)(S,{})}),(0,$.jsxs)(`div`,{className:`walkthrough-viewer-heading-copy`,children:[(0,$.jsx)(`span`,{className:`walkthrough-kicker`,children:`Agent-provided walkthrough`}),(0,$.jsx)(`h2`,{title:e.title,children:e.title})]})]}),(0,$.jsxs)(`div`,{className:`walkthrough-viewer-actions`,children:[(0,$.jsxs)(`button`,{className:`comment-icon-button walkthrough-comment-button`,"aria-label":`ウォークスルー全体へコメント`,title:`ウォークスルー全体へコメント`,"aria-pressed":re,onClick:()=>{K.reset(),L(``),M(null),N(null),F(null),O(e=>!e)},children:[(0,$.jsx)(g,{}),xe>0&&(0,$.jsx)(`span`,{children:xe})]}),(0,$.jsx)(`button`,{className:`comment-icon-button walkthrough-delete-button`,"aria-label":`ウォークスルーを削除`,title:`ウォークスルーを削除`,disabled:be.isPending,onClick:Se,children:(0,$.jsx)(ot,{})})]}),se&&(0,$.jsx)(`div`,{className:`code-reference-notice walkthrough-reference-notice`,role:`status`,"aria-live":`polite`,children:se})]}),(0,$.jsx)(b,{error:be.error}),(0,$.jsx)(b,{error:_e.error}),(re||ye.length>0)&&(0,$.jsxs)(`div`,{className:`walkthrough-comment-area`,children:[re&&(0,$.jsx)(w,{body:I,label:`ウォークスルー全体へコメント`,pending:K.isPending,error:K.error,validationError:void 0,placement:`file`,onBodyChange:L,onCancel:()=>{K.reset(),L(``),O(!1)},onSubmit:()=>K.mutate({range:null,body:I})}),ye.map(({comment:t,placement:n})=>(0,$.jsx)(ee,{comment:t,variant:`inline`,draftScope:te,placement:n,markdownSourceOid:e.sourceOid,themePreference:l,onActiveChange:u,onOpenCodeReference:h,onOpenRepositoryLink:v},t.id))]}),(0,$.jsx)(oe,{className:`walkthrough-markdown-surface`,selectedRange:k,composerOpen:P===`selection`,onSelection:e=>{if(!e){M(null),F(e=>e===`selection`?null:e);return}K.reset(),L(``),O(!1),M(e),N(null),F(null)},onOpenComposer:()=>F(`selection`),composer:X,children:(0,$.jsx)(`div`,{"data-pane-find-surface":!0,"data-pane-find-text":!0,children:Ee})})]})}export{ft as WalkthroughViewer};
|