solid-panes 5.1.0-3 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RDFXMLPane.d.ts.map +1 -1
- package/dist/RDFXMLPane2.cjs.js +1 -1
- package/dist/RDFXMLPane2.cjs.js.map +1 -1
- package/dist/RDFXMLPane2.esm.js +3 -3
- package/dist/RDFXMLPane2.esm.js.map +1 -1
- package/dist/components/editor-card/EditorCard.cjs.js +2 -2
- package/dist/components/editor-card/EditorCard.cjs.js.map +1 -1
- package/dist/components/editor-card/EditorCard.d.ts +2 -0
- package/dist/components/editor-card/EditorCard.d.ts.map +1 -1
- package/dist/components/editor-card/EditorCard.esm.js +68 -43
- package/dist/components/editor-card/EditorCard.esm.js.map +1 -1
- package/dist/components/editor-card/EditorCard.styles.cjs.js.map +1 -1
- package/dist/components/editor-card/EditorCard.styles.esm.js.map +1 -1
- package/dist/components/header/Header.cjs.js.map +1 -1
- package/dist/components/header/Header.esm.js.map +1 -1
- package/dist/components/header/Header.styles.cjs.js.map +1 -1
- package/dist/components/header/Header.styles.esm.js.map +1 -1
- package/dist/components/navbar/Navbar.cjs.js.map +1 -1
- package/dist/components/navbar/Navbar.esm.js.map +1 -1
- package/dist/components/navbar/Navbar.styles.cjs.js.map +1 -1
- package/dist/components/navbar/Navbar.styles.esm.js.map +1 -1
- package/dist/components/profile-heading/ProfileHeading.cjs.js +4 -4
- package/dist/components/profile-heading/ProfileHeading.cjs.js.map +1 -1
- package/dist/components/profile-heading/ProfileHeading.d.ts +4 -0
- package/dist/components/profile-heading/ProfileHeading.d.ts.map +1 -1
- package/dist/components/profile-heading/ProfileHeading.esm.js +123 -107
- package/dist/components/profile-heading/ProfileHeading.esm.js.map +1 -1
- package/dist/components/profile-heading/ProfileHeading.styles.cjs.js.map +1 -1
- package/dist/components/profile-heading/ProfileHeading.styles.esm.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/heading/HeadingEditDialog.cjs.js +19 -19
- package/dist/components/profile-heading/editor/sections/heading/HeadingEditDialog.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/heading/HeadingEditDialog.esm.js +86 -86
- package/dist/components/profile-heading/editor/sections/heading/HeadingEditDialog.esm.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/heading/dateHelpers.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/heading/dateHelpers.esm.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/heading/imageHelpers.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/heading/imagePreview.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/heading/mutations.cjs.js +1 -1
- package/dist/components/profile-heading/editor/sections/heading/mutations.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/heading/mutations.esm.js +61 -61
- package/dist/components/profile-heading/editor/sections/shared/contactTypeUtils.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/shared/contactTypeUtils.esm.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/shared/idNodeFactory.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/shared/phoneCountries.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/shared/phoneCountries.esm.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/shared/rdfMutationHelpers.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/shared/rdfMutationHelpers.esm.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/shared/rowState.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/shared/rowState.esm.js.map +1 -1
- package/dist/components/profile-heading/editor/sections/shared/sanitizeUtils.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/textUtils.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/textUtils.esm.js.map +1 -1
- package/dist/components/profile-heading/editor/texts/dialogTexts.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/texts/dialogTexts.esm.js.map +1 -1
- package/dist/components/profile-heading/editor/texts/messageTexts.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/texts/messageTexts.esm.js.map +1 -1
- package/dist/components/profile-heading/editor/ui/dialog2.cjs.js +1 -1
- package/dist/components/profile-heading/editor/ui/dialog2.cjs.js.map +1 -1
- package/dist/components/profile-heading/editor/ui/dialog2.esm.js +1 -1
- package/dist/components/profile-heading/editor/ui/dialog2.esm.js.map +1 -1
- package/dist/components/profile-heading/friendActions.cjs.js +1 -1
- package/dist/components/profile-heading/friendActions.cjs.js.map +1 -1
- package/dist/components/profile-heading/friendActions.esm.js +5 -5
- package/dist/components/profile-heading/profileHeadingData.cjs.js.map +1 -1
- package/dist/components/resource-action-dialog/ResourceActionDialog.cjs.js +33 -0
- package/dist/components/resource-action-dialog/ResourceActionDialog.cjs.js.map +1 -0
- package/dist/components/resource-action-dialog/ResourceActionDialog.d.ts +16 -0
- package/dist/components/resource-action-dialog/ResourceActionDialog.d.ts.map +1 -0
- package/dist/components/resource-action-dialog/ResourceActionDialog.esm.js +309 -0
- package/dist/components/resource-action-dialog/ResourceActionDialog.esm.js.map +1 -0
- package/dist/components/resource-action-dialog/ResourceActionDialog.styles.cjs.js +2 -0
- package/dist/components/resource-action-dialog/ResourceActionDialog.styles.cjs.js.map +1 -0
- package/dist/components/resource-action-dialog/ResourceActionDialog.styles.esm.js +6 -0
- package/dist/components/resource-action-dialog/ResourceActionDialog.styles.esm.js.map +1 -0
- package/dist/dataContentPane.d.ts.map +1 -1
- package/dist/dataContentPane2.cjs.js +1 -1
- package/dist/dataContentPane2.cjs.js.map +1 -1
- package/dist/dataContentPane2.esm.js +90 -78
- package/dist/dataContentPane2.esm.js.map +1 -1
- package/dist/humanReadablePane.d.ts +1 -0
- package/dist/humanReadablePane.d.ts.map +1 -1
- package/dist/humanReadablePane2.cjs.js +147 -15
- package/dist/humanReadablePane2.cjs.js.map +1 -1
- package/dist/humanReadablePane2.esm.js +281 -114
- package/dist/humanReadablePane2.esm.js.map +1 -1
- package/dist/imagePane.d.ts.map +1 -1
- package/dist/imagePane2.cjs.js +1 -1
- package/dist/imagePane2.cjs.js.map +1 -1
- package/dist/imagePane2.esm.js +9 -7
- package/dist/imagePane2.esm.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +3 -3
- package/dist/internal/internalPane.d.ts.map +1 -1
- package/dist/internal/internalPane2.cjs.js +1 -1
- package/dist/internal/internalPane2.cjs.js.map +1 -1
- package/dist/internal/internalPane2.esm.js +55 -60
- package/dist/internal/internalPane2.esm.js.map +1 -1
- package/dist/mainPage/header.cjs.js +1 -1
- package/dist/mainPage/header.esm.js +2 -2
- package/dist/mainPage/index.cjs.js +1 -1
- package/dist/mainPage/index.cjs.js.map +1 -1
- package/dist/mainPage/index.d.ts.map +1 -1
- package/dist/mainPage/index.esm.js +35 -26
- package/dist/mainPage/index.esm.js.map +1 -1
- package/dist/mainPage/navbar.cjs.js +1 -1
- package/dist/mainPage/navbar.cjs.js.map +1 -1
- package/dist/mainPage/navbar.esm.js +15 -15
- package/dist/mainPage/navigation.cjs.js +1 -1
- package/dist/mainPage/navigation.cjs.js.map +1 -1
- package/dist/mainPage/navigation.esm.js +4 -4
- package/dist/mainPage/profileHeading.d.ts.map +1 -1
- package/dist/mainPage/profileHeading2.cjs.js +1 -1
- package/dist/mainPage/profileHeading2.cjs.js.map +1 -1
- package/dist/mainPage/profileHeading2.esm.js +14 -14
- package/dist/mainPage/profileHeading2.esm.js.map +1 -1
- package/dist/n3Pane.d.ts.map +1 -1
- package/dist/n3Pane2.cjs.js +1 -1
- package/dist/n3Pane2.cjs.js.map +1 -1
- package/dist/n3Pane2.esm.js +1 -1
- package/dist/n3Pane2.esm.js.map +1 -1
- package/dist/navigation/browserEvents.cjs.js +1 -1
- package/dist/navigation/browserEvents.cjs.js.map +1 -1
- package/dist/navigation/browserEvents.d.ts.map +1 -1
- package/dist/navigation/browserEvents.esm.js +17 -17
- package/dist/navigation/browserEvents.esm.js.map +1 -1
- package/dist/navigation/chrome.cjs.js +1 -1
- package/dist/navigation/chrome.cjs.js.map +1 -1
- package/dist/navigation/chrome.d.ts +2 -2
- package/dist/navigation/chrome.d.ts.map +1 -1
- package/dist/navigation/chrome.esm.js +2 -2
- package/dist/navigation/chrome.esm.js.map +1 -1
- package/dist/navigation/controller.cjs.js +1 -1
- package/dist/navigation/controller.cjs.js.map +1 -1
- package/dist/navigation/controller.esm.js +37 -37
- package/dist/navigation/podContext.cjs.js +1 -1
- package/dist/navigation/podContext.cjs.js.map +1 -1
- package/dist/navigation/podContext.esm.js +5 -5
- package/dist/navigation/state.cjs.js +1 -1
- package/dist/navigation/state.cjs.js.map +1 -1
- package/dist/navigation/state.d.ts +4 -0
- package/dist/navigation/state.d.ts.map +1 -1
- package/dist/navigation/state.esm.js +18 -5
- package/dist/navigation/state.esm.js.map +1 -1
- package/dist/outline/fileExplorerHelpers.cjs.js +1 -1
- package/dist/outline/fileExplorerHelpers.cjs.js.map +1 -1
- package/dist/outline/fileExplorerHelpers.d.ts +2 -5
- package/dist/outline/fileExplorerHelpers.d.ts.map +1 -1
- package/dist/outline/fileExplorerHelpers.esm.js +11 -13
- package/dist/outline/fileExplorerHelpers.esm.js.map +1 -1
- package/dist/outline/manager2.cjs.js +1 -1
- package/dist/outline/manager2.cjs.js.map +1 -1
- package/dist/outline/manager2.esm.js +355 -327
- package/dist/outline/manager2.esm.js.map +1 -1
- package/dist/registerPanes.cjs.js +1 -1
- package/dist/registerPanes.cjs.js.map +1 -1
- package/dist/registerPanes.esm.js +1 -1
- package/dist/registerPanes.esm.js.map +1 -1
- package/dist/slideshow/slideshowPane.cjs.js +1 -1
- package/dist/slideshow/slideshowPane.cjs.js.map +1 -1
- package/dist/slideshow/slideshowPane.esm.js +30 -30
- package/dist/slideshow/slideshowPane.esm.js.map +1 -1
- package/dist/social/socialPane2.cjs.js +1 -1
- package/dist/social/socialPane2.esm.js +1 -1
- package/dist/social/socialSections.cjs.js +1 -1
- package/dist/social/socialSections.esm.js +1 -1
- package/dist/utils/paneUtils.cjs.js +1 -1
- package/dist/utils/paneUtils.cjs.js.map +1 -1
- package/dist/utils/paneUtils.esm.js +15 -15
- package/dist/versionInfo.cjs.js +1 -1
- package/dist/versionInfo.cjs.js.map +1 -1
- package/dist/versionInfo.esm.js +9 -9
- package/dist/versionInfo.esm.js.map +1 -1
- package/package.json +12 -13
|
@@ -1,7 +1,40 @@
|
|
|
1
|
-
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`.human-readable-pane{box-sizing:border-box;flex-direction:column;width:100%;min-width:0;max-width:100%;margin:0;padding:0 40px;display:flex;overflow:
|
|
1
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`.human-readable-pane{box-sizing:border-box;flex-direction:column;flex:auto;width:100%;min-width:0;max-width:100%;height:100%;min-height:0;margin:0;padding:0 40px;display:flex;overflow:auto}.human-readable-pane__container{box-sizing:border-box;flex-direction:column;flex:auto;width:100%;min-width:0;max-width:100%;min-height:0;margin:0;padding:0;display:flex;overflow-x:hidden}.human-readable-pane__frame{border:1px solid var(--solid-ui-color-slate-200,#e2e8f0);height:var(--human-readable-pane-height,480px);box-sizing:border-box;resize:both;width:100%;min-width:0;max-width:100%;padding:1rem;display:block;overflow:auto}.human-readable-pane__frame--markdown,.human-readable-pane__frame--plain-text{resize:none;flex:auto;height:auto;min-height:100%;max-height:100%}.human-readable-pane__frame--iframe{box-sizing:border-box;background:var(--color-background,white);width:100%;max-width:100%;min-height:0;padding:0;display:block;overflow:hidden}.human-readable-pane--iframe,solid-ui-file-explorer-provider>.paneDiv.human-readable-pane--iframe{flex:1;height:100%;min-height:0;display:flex;overflow:visible}.human-readable-pane__container--iframe{flex-direction:column;flex:auto;min-height:0;display:flex}.human-readable-pane__container--iframe>.human-readable-pane__frame--iframe{resize:none;flex:auto;height:480px;min-height:288px}.human-readable-pane__frame--markdown,.human-readable-pane__frame--plain-text{max-height:none;overflow:visible}.human-readable-pane__frame--markdown{overflow-wrap:anywhere;word-break:break-word}.human-readable-pane__frame--plain-text{white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;margin:0;font-family:monospace}.human-readable-pane__frame--markdown>*{box-sizing:border-box;max-width:100%}.human-readable-pane__frame--markdown img,.human-readable-pane__frame--markdown video,.human-readable-pane__frame--markdown canvas,.human-readable-pane__frame--markdown iframe{max-width:100%;height:auto}.human-readable-pane__frame--markdown pre,.human-readable-pane__frame--markdown code{overflow-wrap:anywhere;word-break:break-word;max-width:100%}.human-readable-pane__frame--markdown pre{white-space:pre-wrap}.human-readable-pane__frame--markdown table{box-sizing:border-box;width:100%;max-width:100%;display:block;overflow-x:auto}.human-readable-pane__frame--markdown th,.human-readable-pane__frame--markdown td{white-space:normal;overflow-wrap:anywhere;word-break:break-word}.human-readable-pane[data-layout=mobile] .human-readable-pane__frame{resize:none;min-width:0;padding:.75rem}.human-readable-pane[data-layout=mobile] .human-readable-pane__frame--markdown,.human-readable-pane[data-layout=mobile] .human-readable-pane__frame--plain-text{min-height:100%;max-height:none}.human-readable-pane[data-layout=mobile]{padding:0}.human-readable-pane[data-layout=mobile] .human-readable-pane__frame--markdown,.human-readable-pane[data-layout=mobile] .human-readable-pane__frame--plain-text{overflow-wrap:anywhere;word-break:break-word}.human-readable-pane[data-layout=mobile] .human-readable-pane__frame--iframe{flex:none;width:100%;max-width:100%;height:100vh;min-height:100vh}@media (width<=576px){.human-readable-pane{padding:0}.human-readable-pane__frame{resize:none;min-width:0;padding:.75rem}.human-readable-pane__frame--markdown,.human-readable-pane__frame--plain-text{overflow-wrap:anywhere;word-break:break-word}.human-readable-pane__frame--iframe{flex:none;width:100%;max-width:100%;height:100vh;min-height:100vh}}`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();const e=require("./_virtual/_rolldown/runtime.cjs.js");;let t=require("solid-ui"),n=require("solid-logic"),r=require("rdflib"),i=require("marked"),a=require("dompurify");a=e.__toESM(a);function o(){try{return n.authn.currentUser()?.value??null}catch{return null}}var s=e=>{if(!e)return!1;let t=e.split(`?`)[0].split(`#`)[0];return/\.(md|markdown|mdown|mkd|mkdn)$/i.test(t)},c=e=>{if(!e)return!1;let t=e.split(`?`)[0].split(`#`)[0];return/\.json$/i.test(t)},l=new Map;function u(e,t,n){e.className=``,e.classList.add(`human-readable-pane__frame`),e.classList.add(`human-readable-pane__frame--${t}`),n!==void 0&&e.style.setProperty(`--human-readable-pane-height`,`${n*16}px`)}var d=`solidos-human-readable-preview`,f=`allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals`,p=e=>e.includes(`<script src="https://dokie.li/scripts/dokieli.js">`)||e.includes(`dokieli.css`);function m(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function h(e,t){let n=e.match(/<base(\s[^>]*)?>/i);if(n&&n.index!==void 0){let r=n[0].match(/\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i),i=r?.[1]??r?.[2]??r?.[3];if(!r||i===void 0||/^[a-z][a-z\d+.-]*:/i.test(i)||i.startsWith(`//`))return e;let a;try{a=new URL(i,t).href}catch{return e}let o=n[0].replace(r[0],`href="${m(a)}"`);return e.slice(0,n.index)+o+e.slice(n.index+n[0].length)}let r=`<base href="${m(t)}">`,i=e.match(/<head(\s[^>]*)?>/i);if(i&&i.index!==void 0){let t=i.index+i[0].length;return e.slice(0,t)+r+e.slice(t)}return r+e}function g(e){let t=`<script>
|
|
2
|
+
(() => {
|
|
3
|
+
const style = document.createElement('style')
|
|
4
|
+
style.textContent = 'html, body { height: auto !important; min-height: 0 !important; max-height: none !important; overflow: visible !important; }'
|
|
5
|
+
document.head?.appendChild(style)
|
|
6
|
+
const reportHeight = () => {
|
|
7
|
+
const elements = Array.from(document.querySelectorAll('*'))
|
|
8
|
+
const height = Math.max(
|
|
9
|
+
document.documentElement.scrollHeight,
|
|
10
|
+
document.body ? document.body.scrollHeight : 0,
|
|
11
|
+
...elements.map(element => Math.max(
|
|
12
|
+
element.scrollHeight,
|
|
13
|
+
Math.ceil(element.getBoundingClientRect().bottom + window.scrollY)
|
|
14
|
+
))
|
|
15
|
+
)
|
|
16
|
+
window.parent.postMessage({ type: 'solidos-preview-size', height }, '*')
|
|
17
|
+
}
|
|
18
|
+
window.addEventListener('load', reportHeight)
|
|
19
|
+
new ResizeObserver(reportHeight).observe(document.documentElement)
|
|
20
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
21
|
+
if (document.body) new ResizeObserver(reportHeight).observe(document.body)
|
|
22
|
+
new MutationObserver(reportHeight).observe(document.body || document.documentElement, {
|
|
23
|
+
childList: true,
|
|
24
|
+
subtree: true,
|
|
25
|
+
attributes: true
|
|
26
|
+
})
|
|
27
|
+
reportHeight()
|
|
28
|
+
})
|
|
29
|
+
window.setInterval(reportHeight, 500)
|
|
30
|
+
reportHeight()
|
|
31
|
+
})()
|
|
32
|
+
<\/script>`,n=e.replace(/<\/body\s*>/i,`${t}$&`);return n===e?`${e}${t}`:n}function _(e){let t=e.split(`/`).pop()||e;try{return decodeURIComponent(t)}catch{return t}}function v(e,t){let n=_(t);try{return new DOMParser().parseFromString(e,`text/html`).querySelector(`title`)?.textContent?.trim()||n}catch{return n}}var y=`solidos-preview-request`,b=`solidos-preview-response`,x=`data-solidos-preview-bridge`,S=new Set([`GET`,`HEAD`]),C=new Set([`PUT`,`PATCH`,`DELETE`]);function w(e){if(typeof e!=`string`||!e.includes(y))return e;let t=new DOMParser().parseFromString(e,`text/html`),n=!1;for(let e of t.querySelectorAll(`script`)){let t=e.textContent||``;(e.hasAttribute(x)||t.includes(y)&&t.includes(b)&&t.includes(`const pending = new Map()`))&&(e.remove(),n=!0)}if(!n)return e;let r=e.match(/<!doctype[^>]*>/i)?.[0];return`${r?`${r}\n`:``}${t.documentElement.outerHTML}`}function T(e){return e===`about:srcdoc`||/^file:\/\/srcdoc\/?(?:[?#].*)?$/i.test(e)}function E(e,t){let n=new URL(e,t).href;return T(n)?t:n}function D(e){if(e)try{let t=new URL(e);return t.hash=``,t.href}catch{return}}function O(e,t,n,r=null){let i,a;try{i=new URL(E(e,n)),a=new URL(n)}catch{return!1}if(i.origin!==a.origin)return!1;let o=t.toUpperCase(),s=new URL(i.href);s.hash=``;let c=new URL(a.href);c.hash=``;let l=s.href===c.href,u=i.href===a.href,d=i.pathname===`/profile/card`||s.href===D(r);return S.has(o)&&(l||d)||u&&C.has(o)}function k(e,t,n,r=null){let i=`<script ${x}="true">
|
|
2
33
|
(() => {
|
|
3
34
|
const documentUri = ${JSON.stringify(t)}
|
|
35
|
+
const documentOrigin = new URL(documentUri).origin
|
|
4
36
|
const nonce = ${JSON.stringify(n)}
|
|
37
|
+
const viewerWebId = ${JSON.stringify(r)}
|
|
5
38
|
const pending = new Map()
|
|
6
39
|
let requestId = 0
|
|
7
40
|
try {
|
|
@@ -57,19 +90,19 @@
|
|
|
57
90
|
})
|
|
58
91
|
return operation
|
|
59
92
|
}
|
|
60
|
-
|
|
61
|
-
get: key => run(store.get(key)),
|
|
62
|
-
getAll: () => run(Array.from(store.values())),
|
|
63
|
-
getAllKeys: () => run(Array.from(store.keys())),
|
|
64
|
-
count: () => run(store.size),
|
|
65
|
-
openKeyCursor () {
|
|
93
|
+
const openCursor = (withValue) => {
|
|
66
94
|
const keys = Array.from(store.keys())
|
|
67
95
|
const operation = request(null)
|
|
68
96
|
pending++
|
|
69
97
|
let index = 0
|
|
70
98
|
const emit = () => {
|
|
71
99
|
operation.result = index < keys.length
|
|
72
|
-
? {
|
|
100
|
+
? {
|
|
101
|
+
key: keys[index],
|
|
102
|
+
primaryKey: keys[index],
|
|
103
|
+
value: withValue ? store.get(keys[index]) : undefined,
|
|
104
|
+
continue: () => { index++; queueMicrotask(emit) }
|
|
105
|
+
}
|
|
73
106
|
: null
|
|
74
107
|
operation.onsuccess?.({ target: operation })
|
|
75
108
|
if (!operation.result) {
|
|
@@ -82,7 +115,15 @@
|
|
|
82
115
|
}
|
|
83
116
|
queueMicrotask(emit)
|
|
84
117
|
return operation
|
|
85
|
-
}
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
transaction,
|
|
121
|
+
get: key => run(store.get(key)),
|
|
122
|
+
getAll: () => run(Array.from(store.values())),
|
|
123
|
+
getAllKeys: () => run(Array.from(store.keys())),
|
|
124
|
+
count: () => run(store.size),
|
|
125
|
+
openCursor: () => openCursor(true),
|
|
126
|
+
openKeyCursor: () => openCursor(false),
|
|
86
127
|
put: (value, key) => run(undefined, () => store.set(key, value)),
|
|
87
128
|
add: (value, key) => run(undefined, () => store.set(key, value)),
|
|
88
129
|
delete: key => run(undefined, () => store.delete(key)),
|
|
@@ -110,6 +151,27 @@
|
|
|
110
151
|
}
|
|
111
152
|
Object.defineProperty(window, 'indexedDB', { configurable: true, value: isolatedIndexedDB })
|
|
112
153
|
}
|
|
154
|
+
const createMemoryStorage = () => {
|
|
155
|
+
const values = new Map()
|
|
156
|
+
return {
|
|
157
|
+
get length () { return values.size },
|
|
158
|
+
key: index => Array.from(values.keys())[index] ?? null,
|
|
159
|
+
getItem: key => values.get(String(key)) ?? null,
|
|
160
|
+
setItem: (key, value) => values.set(String(key), String(value)),
|
|
161
|
+
removeItem: key => values.delete(String(key)),
|
|
162
|
+
clear: () => values.clear()
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
for (const storageName of ['localStorage', 'sessionStorage']) {
|
|
166
|
+
try {
|
|
167
|
+
window[storageName].getItem('__solidos_probe__')
|
|
168
|
+
} catch {
|
|
169
|
+
Object.defineProperty(window, storageName, {
|
|
170
|
+
configurable: true,
|
|
171
|
+
value: createMemoryStorage()
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
}
|
|
113
175
|
const nativeFetch = window.fetch.bind(window)
|
|
114
176
|
|
|
115
177
|
function isSrcdocUrl (url) {
|
|
@@ -128,7 +190,7 @@
|
|
|
128
190
|
return new Promise((resolve, reject) => {
|
|
129
191
|
pending.set(id, { resolve, reject })
|
|
130
192
|
window.parent.postMessage({
|
|
131
|
-
type: ${JSON.stringify(
|
|
193
|
+
type: ${JSON.stringify(y)},
|
|
132
194
|
nonce,
|
|
133
195
|
id,
|
|
134
196
|
url,
|
|
@@ -141,7 +203,7 @@
|
|
|
141
203
|
|
|
142
204
|
window.addEventListener('message', event => {
|
|
143
205
|
const message = event.data
|
|
144
|
-
if (!message || message.type !== ${JSON.stringify(
|
|
206
|
+
if (!message || message.type !== ${JSON.stringify(b)} || message.nonce !== nonce) return
|
|
145
207
|
const entry = pending.get(message.id)
|
|
146
208
|
if (!entry) return
|
|
147
209
|
pending.delete(message.id)
|
|
@@ -156,11 +218,38 @@
|
|
|
156
218
|
}))
|
|
157
219
|
})
|
|
158
220
|
|
|
221
|
+
const reportHeight = () => {
|
|
222
|
+
const elements = Array.from(document.querySelectorAll('*'))
|
|
223
|
+
const height = Math.max(
|
|
224
|
+
document.documentElement.scrollHeight,
|
|
225
|
+
document.body ? document.body.scrollHeight : 0,
|
|
226
|
+
...elements.map(element => Math.max(
|
|
227
|
+
element.scrollHeight,
|
|
228
|
+
Math.ceil(element.getBoundingClientRect().bottom + window.scrollY)
|
|
229
|
+
))
|
|
230
|
+
)
|
|
231
|
+
window.parent.postMessage({ type: 'solidos-preview-size', height }, '*')
|
|
232
|
+
}
|
|
233
|
+
window.addEventListener('load', reportHeight)
|
|
234
|
+
new ResizeObserver(reportHeight).observe(document.documentElement)
|
|
235
|
+
if (document.body) new ResizeObserver(reportHeight).observe(document.body)
|
|
236
|
+
new MutationObserver(reportHeight).observe(document.body || document.documentElement, {
|
|
237
|
+
childList: true,
|
|
238
|
+
subtree: true,
|
|
239
|
+
attributes: true
|
|
240
|
+
})
|
|
241
|
+
window.setInterval(reportHeight, 500)
|
|
242
|
+
reportHeight()
|
|
243
|
+
|
|
159
244
|
window.fetch = async (input, init = {}) => {
|
|
160
245
|
const request = input instanceof Request ? input : null
|
|
161
246
|
const url = documentRequestUrl(request ? request.url : input)
|
|
162
247
|
const method = (init.method || (request && request.method) || 'GET').toUpperCase()
|
|
163
|
-
|
|
248
|
+
const sameOrigin = new URL(url).origin === documentOrigin
|
|
249
|
+
const allowed = sameOrigin &&
|
|
250
|
+
(${JSON.stringify(Array.from(S))}.includes(method) ||
|
|
251
|
+
(url === documentUri && ${JSON.stringify(Array.from(C))}.includes(method)))
|
|
252
|
+
if (!allowed) {
|
|
164
253
|
return nativeFetch(input, init)
|
|
165
254
|
}
|
|
166
255
|
const headers = new Headers(request ? request.headers : undefined)
|
|
@@ -204,8 +293,10 @@
|
|
|
204
293
|
const resolvedUrl = documentRequestUrl(url)
|
|
205
294
|
this._method = String(method || 'GET').toUpperCase()
|
|
206
295
|
this._url = resolvedUrl
|
|
207
|
-
|
|
208
|
-
|
|
296
|
+
const sameOrigin = new URL(resolvedUrl).origin === documentOrigin
|
|
297
|
+
this._intercepted = sameOrigin &&
|
|
298
|
+
(${JSON.stringify(Array.from(S))}.includes(this._method) ||
|
|
299
|
+
(resolvedUrl === documentUri && ${JSON.stringify(Array.from(C))}.includes(this._method)))
|
|
209
300
|
if (!this._intercepted) {
|
|
210
301
|
this._native.open(method, url, async, user, password)
|
|
211
302
|
for (const type of ['abort', 'error', 'load', 'loadend', 'progress', 'readystatechange', 'timeout']) {
|
|
@@ -272,6 +363,47 @@
|
|
|
272
363
|
: ''
|
|
273
364
|
}
|
|
274
365
|
}
|
|
366
|
+
|
|
367
|
+
// Dokieli's own OIDC session cannot be restored in an opaque-origin
|
|
368
|
+
// sandbox, so it would always show "Sign in". Give it the SolidOS viewer
|
|
369
|
+
// through the same session shape Dokieli uses for its WebExtension mode;
|
|
370
|
+
// requests still go through the restricted bridge above.
|
|
371
|
+
const bridgedSession = viewerWebId
|
|
372
|
+
? {
|
|
373
|
+
isActive: true,
|
|
374
|
+
webId: viewerWebId,
|
|
375
|
+
authFetch: (input, init) => window.fetch(input, init),
|
|
376
|
+
handleRedirectFromLogin: async () => {},
|
|
377
|
+
restore: async () => {},
|
|
378
|
+
login: async () => {},
|
|
379
|
+
logout: async () => {
|
|
380
|
+
bridgedSession.isActive = false
|
|
381
|
+
bridgedSession.webId = undefined
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
: null
|
|
385
|
+
let dokieliHooksInstalled = false
|
|
386
|
+
const installDokieliHooks = () => {
|
|
387
|
+
const config = window.DO && window.DO.C
|
|
388
|
+
if (!config || dokieliHooksInstalled) return
|
|
389
|
+
dokieliHooksInstalled = true
|
|
390
|
+
if (bridgedSession) config.Session = bridgedSession
|
|
391
|
+
// Dokieli skips requests for file: URLs, which is how srcdoc reports
|
|
392
|
+
// its location, so keep its document URL pointing at the resource.
|
|
393
|
+
let documentUrl = config.DocumentURL
|
|
394
|
+
Object.defineProperty(config, 'DocumentURL', {
|
|
395
|
+
configurable: true,
|
|
396
|
+
enumerable: true,
|
|
397
|
+
get: () => documentUrl,
|
|
398
|
+
set: value => {
|
|
399
|
+
documentUrl = typeof value === 'string' && isSrcdocUrl(value) ? documentUri : value
|
|
400
|
+
}
|
|
401
|
+
})
|
|
402
|
+
config.DocumentURL = documentUrl
|
|
403
|
+
}
|
|
404
|
+
// Registered before dokieli.js runs, so this precedes Dokieli's init.
|
|
405
|
+
document.addEventListener('DOMContentLoaded', installDokieliHooks)
|
|
406
|
+
window.addEventListener('load', installDokieliHooks)
|
|
275
407
|
})()
|
|
276
|
-
<\/script>`;return
|
|
408
|
+
<\/script>`;return h(w(e)??e,t).replace(/<head(\s[^>]*)?>/i,e=>`${e}${i}`)}function A(e,t,n,r,i=null){let a=e.ownerDocument.defaultView;if(!a)return;let o=new Uint32Array(4);a.crypto.getRandomValues(o);let s=Array.from(o,e=>e.toString(16)).join(`-`),c=new URL(t).href;a.addEventListener(`message`,t=>{let n=t.data;if(t.source!==e.contentWindow||!n||n.type!==y||n.nonce!==s)return;let a=t=>{e.contentWindow?.postMessage(t,`*`)};O(n.url,n.method,c,i)?r(E(n.url,c),{method:n.method,headers:n.headers,body:S.has(n.method)?void 0:w(n.body)}).then(async e=>{a({type:b,nonce:s,id:n.id,ok:e.ok,status:e.status,headers:Array.from(e.headers.entries()),body:await e.text()})}).catch(e=>{a({type:b,nonce:s,id:n.id,ok:!1,status:0,headers:[],body:``,error:e instanceof Error?e.message:String(e)})}):a({type:b,nonce:s,id:n.id,ok:!1,status:403,headers:[],body:``,error:`Request not permitted by the SolidOS preview`})}),e.setAttribute(`sandbox`,f),e.srcdoc=k(n,c,s,i)}function j(e,t){let n=t=>{let n=t.data;t.source===e.contentWindow&&n?.type===`solidos-preview-size`&&typeof n.height==`number`&&Number.isFinite(n.height)&&(e.style.height=`${Math.max(1,Math.ceil(n.height))}px`,e.style.flexShrink=`0`)};return t.addEventListener(`message`,n),()=>t.removeEventListener(`message`,n)}var M={icon:function(e,n){if(e&&s(e.uri))return t.icons.iconBase+`markdown.svg`;if(e){let r=n.session.store,i=l.get(e.uri);if(i===`dokieli`)return t.icons.iconBase+`dokieli-logo.png`;if(i===`html`)return t.icons.originalIconBase+`tango/22-text-x-generic.png`;let a=r.fetcher.getHeader(e.doc(),`content`);if(a&&a.length>0){let n=a[0],r=n.includes(`<script src="https://dokie.li/scripts/dokieli.js">`)||n.includes(`dokieli.css`);return l.set(e.uri,r?`dokieli`:`html`),r?t.icons.iconBase+`dokieli-logo.png`:t.icons.originalIconBase+`tango/22-text-x-generic.png`}let o=r.fetcher.getHeader(e.doc(),`content-type`);if((o?o[0].split(`;`,1)[0].trim():null)===`text/html`)return r.fetcher._fetch(e.uri).then(e=>e.text()).then(n=>{let r=n.includes(`<script src="https://dokie.li/scripts/dokieli.js">`)||n.includes(`dokieli.css`);return l.set(e.uri,r?`dokieli`:`html`),r?t.icons.iconBase+`dokieli-logo.png`:t.icons.originalIconBase+`tango/22-text-x-generic.png`}).catch(()=>(l.set(e.uri,`html`),t.icons.originalIconBase+`tango/22-text-x-generic.png`))}return t.icons.originalIconBase+`tango/22-text-x-generic.png`},name:`humanReadable`,label:function(e,n){let i=n.session.store,a=[`text/plain`,`text/html`,`text/markdown`,`application/json`,`application/xhtml+xml`,`application/pdf`,`video/mp4`],o=function(e,t,n){let r=e.fetcher.getHeader(t,`content-type`);if(r){for(let e=0;e<r.length;e++)for(let t=0;t<n.length;t++)if(r[e].indexOf(n[t])>=0)return!0}return!1},c=function(e,t,n){let i=e.findTypeURIs(t);for(let e=0;e<n.length;e++)if(r.Util.mediaTypeClass(n[e]).uri in i)return!0;return!1};if(!e.uri)return null;if(i.findTypeURIs(e)[t.ns.link(`WebPage`).uri])return`Webpage`;if(s(e.uri))return`View`;if(o(i,e,a)||c(i,e,a)){let t=i.fetcher.getHeader(e.doc(),`content-type`);return(t?t[0].split(`;`,1)[0].trim():null)===`text/html`&&!l.has(e.uri)&&i.fetcher._fetch(e.uri).then(e=>e.text()).then(t=>{let n=t.includes(`<script src="https://dokie.li/scripts/dokieli.js">`)||t.includes(`dokieli.css`);l.set(e.uri,n?`dokieli`:`html`)}).catch(()=>{l.set(e.uri,`html`)}),`View`}return null},render:function(e,t){let n=t.dom,r=n.createElement(`div`),y=t.session.store;function b(e){let n=t.environment??{};e.dataset.layout=n.layout??`desktop`}let x=y.fetcher.getHeader(e.doc(),`content-type`),S=x?x[0].split(`;`,1)[0].trim():null,C=S===`text/markdown`||s(e.uri),w=S===`text/plain`||S===`application/json`||!S&&c(e.uri);S||console.log(`humanReadablePane: unknown content-type?`),r.classList.add(`human-readable-pane`),b(r);let T=function(t){y.fetcher.webOperation(`GET`,e.uri).then(e=>{let n=e.responseText??``,r=Math.min(30,n.split(/\n/).length+5),o=i.marked.parse(n,{async:!1});t.innerHTML=a.default.sanitize(o),u(t,`markdown`,r)}).catch(e=>{console.error(`Error fetching markdown content:`,e),t.innerHTML=`<p>Error loading content</p>`})},E=function(t){y.fetcher.webOperation(`GET`,e.uri).then(e=>{let n=e.responseText??``,r=Math.min(30,n.split(/\n/).length+5);t.textContent=n,u(t,`plain-text`,r)}).catch(e=>{console.error(`Error fetching plain text content:`,e),t.textContent=`Error loading content`})};if(C){let e=n.createElement(`div`);T(e);let t=n.createElement(`div`);t.classList.add(`human-readable-pane__container`),t.appendChild(e),r.appendChild(t)}else if(w){let e=n.createElement(`pre`);E(e);let t=n.createElement(`div`);t.classList.add(`human-readable-pane__container`),t.appendChild(e),r.appendChild(t)}else{let t=n.createElement(`iframe`);t.name=d,t.title=_(e.uri),u(t,`iframe`);let i=n.defaultView,a=i?j(t,i):()=>{},s=S===`text/html`||S===`application/xhtml+xml`,c=null,b=!1,x=!1,C=typeof MutationObserver>`u`?null:new MutationObserver(e=>{let t=e.some(e=>Array.from(e.addedNodes).some(e=>e===r||e.nodeType===Node.ELEMENT_NODE&&e.contains(r)));r.isConnected?x=!0:(x||t)&&(b=!0,c&&=(URL.revokeObjectURL(c),null),a(),C?.disconnect())});C?.observe(n,{childList:!0,subtree:!0});let w=e=>{t.removeAttribute(`src`),t.setAttribute(`sandbox`,``),t.srcdoc=`<p style="font-family: sans-serif">${m(e)}</p>`};s?y.fetcher.webOperation(`GET`,e.uri).then(n=>{let r=n.responseText??``;t.title=v(r,e.uri);let i=p(r);l.set(e.uri,i?`dokieli`:`html`),i?A(t,e.uri,r,(e,t)=>y.fetcher._fetch(e,t),o()):(t.setAttribute(`sandbox`,f),t.srcdoc=g(h(r,e.uri)))}).catch(e=>{console.error(`Error fetching HTML content:`,e),w(`Error loading content`)}):y.fetcher._fetch(e.uri).then(async n=>{if(!n.ok)throw Error(`HTTP ${n.status}`);let r=n.headers.get(`content-type`)?.split(`;`,1)[0].trim().toLowerCase();if(r===`text/html`||r===`application/xhtml+xml`){let r=await n.text();t.title=v(r,e.uri);let i=p(r);l.set(e.uri,i?`dokieli`:`html`),i?A(t,e.uri,r,(e,t)=>y.fetcher._fetch(e,t),o()):(t.setAttribute(`sandbox`,f),t.srcdoc=g(h(r,e.uri)));return}r!==`application/pdf`&&t.setAttribute(`sandbox`,f);let i=URL.createObjectURL(await n.blob());b?URL.revokeObjectURL(i):(c=i,t.src=i)}).catch(e=>{console.error(`Error fetching content:`,e),w(`Error loading content`)});let T=n.createElement(`div`);T.classList.add(`human-readable-pane__container`),T.classList.add(`human-readable-pane__container--iframe`),T.appendChild(t),r.appendChild(T),r.classList.add(`human-readable-pane--iframe`)}return r}};exports.HUMAN_READABLE_PREVIEW_FRAME_NAME=d,exports.default=M,exports.isAllowedPreviewRequest=O,exports.previewRequestUrl=E,exports.withBaseHref=h;
|
|
277
409
|
//# sourceMappingURL=humanReadablePane2.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"humanReadablePane2.cjs.js","names":["icons","Util","ns","DOMPurify","require_runtime","solid_ui","rdflib","marked","dompurify","isMarkdownFile","uri","path","dokieliCache","applyFrameClasses","frame","modifier","lines","HUMAN_READABLE_PREVIEW_FRAME_NAME","HTML_PREVIEW_SANDBOX","isDokieliHtml","text","escapeAttribute","value","withBaseHref","existingBase","html","href","existingHref","resolvedHref","baseUri","resolvedBase","base","headMatch","insertAt","resourceFilename","encodedFilename","documentTitle","fallback","PREVIEW_REQUEST_TYPE","PREVIEW_RESPONSE_TYPE","PREVIEW_METHODS","isSrcdocUrl","url","previewRequestUrl","resolvedUrl","documentUri","createPreviewBridge","bridge","nonce","match","mountDokieliBridge","ownerWindow","randomValues","expectedUri","request","event","respond","response","authenticatedFetch","error","humanReadablePane","subject","kb","context","cachedResult","responseText","isDokieli","cts","allowed","hasContentTypeIn","x","j","k","displayables","hasContentTypeIn2","t","myDocument","div","applyEnvironmentAttributes","environment","ct","isMarkdown","isPlainText","renderMarkdownContent","markdownText","res","renderPlainTextContent","plainText","frameContainer","isHtml","previewUrl","disposed","wasConnected","mutationObserver","wasAdded","records","record","node","showError","message","init","responseContentType","objectUrl"],"sources":["../src/humanReadablePane.ts"],"sourcesContent":["/* Human-readable Pane\n **\n ** This outline pane contains the document contents for an HTML document\n ** This is for peeking at a page, because the user might not want to leave the data browser.\n */\nimport { icons, ns } from 'solid-ui'\nimport { Util } from 'rdflib'\nimport { marked } from 'marked'\nimport DOMPurify from 'dompurify'\nimport type { DataBrowserContext, RenderEnvironment } from 'pane-registry'\nimport type { NamedNode } from 'rdflib'\nimport './humanReadablePane.css'\n\n// Helper function to check if a URI has a markdown file extension\ntype DokieliCacheValue = 'dokieli' | 'html'\n\ntype HumanReadableIcon = string | Promise<string>\n\ntype HumanReadablePaneDefinition = {\n icon: (subject: NamedNode, context: DataBrowserContext) => HumanReadableIcon\n name: string\n label: (subject: NamedNode, context: DataBrowserContext) => 'Webpage' | 'View' | null\n render: (subject: NamedNode, context: DataBrowserContext) => HTMLDivElement\n}\n\nconst isMarkdownFile = (uri?: string | null): boolean => {\n if (!uri) return false\n const path = uri.split('?')[0].split('#')[0] // Remove query string and fragment\n return /\\.(md|markdown|mdown|mkd|mkdn)$/i.test(path)\n}\n\n// Cache for dokieli detection results (keyed by subject URI)\nconst dokieliCache = new Map<string, DokieliCacheValue>()\n\nfunction applyFrameClasses (\n frame: HTMLElement,\n modifier: 'markdown' | 'plain-text' | 'iframe',\n lines?: number\n): void {\n frame.className = ''\n frame.classList.add('human-readable-pane__frame')\n frame.classList.add(`human-readable-pane__frame--${modifier}`)\n if (lines !== undefined) {\n frame.style.setProperty('--human-readable-pane-height', `${lines}em`)\n }\n}\n\n// window.name of preview iframes; initMainPage refuses to boot SolidOS inside such a frame.\nexport const HUMAN_READABLE_PREVIEW_FRAME_NAME = 'solidos-human-readable-preview'\n\n// Scripts may run but get an opaque origin, so previewed pages cannot reach the SolidOS session.\nconst HTML_PREVIEW_SANDBOX = 'allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals'\n\nconst isDokieliHtml = (text: string): boolean =>\n text.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') || text.includes('dokieli.css')\n\nfunction escapeAttribute (value: string): string {\n return value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>')\n}\n\n// srcdoc documents resolve relative URLs against about:srcdoc, so point them back at the resource.\nexport function withBaseHref (html: string, baseUri: string): string {\n const existingBase = html.match(/<base(\\s[^>]*)?>/i)\n if (existingBase && existingBase.index !== undefined) {\n const href = existingBase[0].match(/\\bhref\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/i)\n const existingHref = href?.[1] ?? href?.[2] ?? href?.[3]\n if (!href || existingHref === undefined) return html\n if (/^[a-z][a-z\\d+.-]*:/i.test(existingHref) || existingHref.startsWith('//')) return html\n let resolvedHref: string\n try {\n resolvedHref = new URL(existingHref, baseUri).href\n } catch {\n return html\n }\n const resolvedBase = existingBase[0].replace(href[0], `href=\"${escapeAttribute(resolvedHref)}\"`)\n return html.slice(0, existingBase.index) + resolvedBase + html.slice(existingBase.index + existingBase[0].length)\n }\n const base = `<base href=\"${escapeAttribute(baseUri)}\">`\n const headMatch = html.match(/<head(\\s[^>]*)?>/i)\n if (headMatch && headMatch.index !== undefined) {\n const insertAt = headMatch.index + headMatch[0].length\n return html.slice(0, insertAt) + base + html.slice(insertAt)\n }\n return base + html\n}\n\nfunction resourceFilename (uri: string): string {\n const encodedFilename = uri.split('/').pop() || uri\n try {\n return decodeURIComponent(encodedFilename)\n } catch {\n return encodedFilename\n }\n}\n\nfunction documentTitle (html: string, uri: string): string {\n const fallback = resourceFilename(uri)\n try {\n const title = new DOMParser().parseFromString(html, 'text/html').querySelector('title')?.textContent?.trim()\n return title || fallback\n } catch {\n return fallback\n }\n}\n\ntype PreviewRequest = {\n type: 'solidos-preview-request'\n nonce: string\n id: string\n url: string\n method: string\n headers?: Record<string, string>\n body?: string\n}\n\ntype PreviewResponse = {\n type: 'solidos-preview-response'\n nonce: string\n id: string\n ok: boolean\n status: number\n headers: Array<[string, string]>\n body: string\n error?: string\n}\n\nconst PREVIEW_REQUEST_TYPE = 'solidos-preview-request'\nconst PREVIEW_RESPONSE_TYPE = 'solidos-preview-response'\nconst PREVIEW_METHODS = new Set(['GET', 'PUT', 'PATCH', 'DELETE'])\n\nfunction isSrcdocUrl (url: string): boolean {\n return url === 'about:srcdoc' || /^file:\\/\\/srcdoc\\/?(?:[?#].*)?$/i.test(url)\n}\n\nexport function previewRequestUrl (url: string, documentUri: string): string {\n const resolvedUrl = new URL(url, documentUri).href\n return isSrcdocUrl(resolvedUrl) ? documentUri : resolvedUrl\n}\n\nfunction createPreviewBridge (html: string, uri: string, nonce: string): string {\n const bridge = `<script>\n(() => {\n const documentUri = ${JSON.stringify(uri)}\n const nonce = ${JSON.stringify(nonce)}\n const pending = new Map()\n let requestId = 0\n try {\n history.replaceState(null, '', documentUri)\n } catch {\n // Sandboxed documents may reject cross-origin history URLs.\n }\n // Opaque sandbox origins cannot use IndexedDB. Dokieli uses it for local\n // preferences and history, so provide an in-memory implementation without\n // granting the preview a persistent storage capability.\n try {\n window.indexedDB.open('__solidos_probe__')\n } catch {\n const databases = new Map()\n const request = (result) => ({ result, error: null, onsuccess: null, onerror: null, onupgradeneeded: null })\n const isolatedIndexedDB = {\n open (name) {\n const stores = databases.get(name) || new Map()\n databases.set(name, stores)\n const database = {\n objectStoreNames: { contains: storeName => stores.has(storeName) },\n createObjectStore (storeName) {\n if (!stores.has(storeName)) stores.set(storeName, new Map())\n return database.transaction(storeName, 'readwrite').objectStore(storeName)\n },\n transaction (storeName, mode = 'readonly') {\n const store = stores.get(storeName) || new Map()\n stores.set(storeName, store)\n let pending = 0\n let completed = false\n const transaction = {\n oncomplete: null,\n onerror: null,\n onabort: null,\n objectStore: () => {\n const run = (result, change) => {\n const operation = request(result)\n pending++\n queueMicrotask(() => {\n try {\n change?.()\n operation.onsuccess?.({ target: operation })\n } catch (error) {\n operation.error = error\n operation.onerror?.({ target: operation })\n } finally {\n pending--\n if (!pending && !completed) {\n completed = true\n transaction.oncomplete?.({ target: transaction })\n }\n }\n })\n return operation\n }\n return {\n get: key => run(store.get(key)),\n getAll: () => run(Array.from(store.values())),\n getAllKeys: () => run(Array.from(store.keys())),\n count: () => run(store.size),\n openKeyCursor () {\n const keys = Array.from(store.keys())\n const operation = request(null)\n pending++\n let index = 0\n const emit = () => {\n operation.result = index < keys.length\n ? { key: keys[index], continue: () => { index++; queueMicrotask(emit) } }\n : null\n operation.onsuccess?.({ target: operation })\n if (!operation.result) {\n pending--\n if (!pending && !completed) {\n completed = true\n transaction.oncomplete?.({ target: transaction })\n }\n }\n }\n queueMicrotask(emit)\n return operation\n },\n put: (value, key) => run(undefined, () => store.set(key, value)),\n add: (value, key) => run(undefined, () => store.set(key, value)),\n delete: key => run(undefined, () => store.delete(key)),\n clear: () => run(undefined, () => store.clear())\n }\n }\n }\n return transaction\n },\n close () {}\n }\n const operation = request(database)\n queueMicrotask(() => {\n operation.onupgradeneeded?.({ target: operation })\n operation.onsuccess?.({ target: operation })\n })\n return operation\n },\n deleteDatabase (name) {\n databases.delete(name)\n const operation = request(undefined)\n queueMicrotask(() => operation.onsuccess?.({ target: operation }))\n return operation\n }\n }\n Object.defineProperty(window, 'indexedDB', { configurable: true, value: isolatedIndexedDB })\n }\n const nativeFetch = window.fetch.bind(window)\n\n function isSrcdocUrl (url) {\n return url === 'about:srcdoc' || /^file:\\\\/\\\\/srcdoc\\\\/?(?:[?#].*)?$/i.test(url)\n }\n\n function documentRequestUrl (url) {\n const resolvedUrl = new URL(url, documentUri).href\n // srcdoc keeps this URL even when history.replaceState is unavailable in\n // an opaque sandbox. Dokieli saves via document.location.href.\n return isSrcdocUrl(resolvedUrl) ? documentUri : resolvedUrl\n }\n\n function requestParent (url, init) {\n const id = String(++requestId)\n return new Promise((resolve, reject) => {\n pending.set(id, { resolve, reject })\n window.parent.postMessage({\n type: ${JSON.stringify(PREVIEW_REQUEST_TYPE)},\n nonce,\n id,\n url,\n method: init.method,\n headers: init.headers,\n body: init.body\n }, '*')\n })\n }\n\n window.addEventListener('message', event => {\n const message = event.data\n if (!message || message.type !== ${JSON.stringify(PREVIEW_RESPONSE_TYPE)} || message.nonce !== nonce) return\n const entry = pending.get(message.id)\n if (!entry) return\n pending.delete(message.id)\n if (!message.ok) {\n entry.reject(new Error(message.error || 'Preview request failed'))\n return\n }\n const responseBody = [204, 205, 304].includes(message.status) ? null : message.body\n entry.resolve(new Response(responseBody, {\n status: message.status,\n headers: message.headers\n }))\n })\n\n window.fetch = async (input, init = {}) => {\n const request = input instanceof Request ? input : null\n const url = documentRequestUrl(request ? request.url : input)\n const method = (init.method || (request && request.method) || 'GET').toUpperCase()\n if (url !== documentUri || !${JSON.stringify(Array.from(PREVIEW_METHODS))}.includes(method)) {\n return nativeFetch(input, init)\n }\n const headers = new Headers(request ? request.headers : undefined)\n for (const [key, value] of new Headers(init.headers || {}).entries()) headers.set(key, value)\n const body = method === 'GET' || method === 'HEAD'\n ? undefined\n : (init.body || (request ? await request.clone().text() : undefined))\n return requestParent(url, {\n method,\n headers: Object.fromEntries(headers.entries()),\n body\n })\n }\n\n const NativeXMLHttpRequest = window.XMLHttpRequest\n window.XMLHttpRequest = class PreviewXMLHttpRequest {\n constructor () {\n this._native = new NativeXMLHttpRequest()\n this._headers = {}\n this._listeners = {}\n this._intercepted = false\n this.readyState = 0\n this.status = 0\n this.statusText = ''\n this.response = null\n this.responseText = ''\n }\n\n addEventListener (type, listener) {\n this._listeners[type] = this._listeners[type] || []\n this._listeners[type].push(listener)\n }\n\n _emit (type) {\n const event = { target: this, currentTarget: this, type }\n if (typeof this['on' + type] === 'function') this['on' + type](event)\n for (const listener of this._listeners[type] || []) listener.call(this, event)\n }\n\n open (method, url, async = true, user, password) {\n const resolvedUrl = documentRequestUrl(url)\n this._method = String(method || 'GET').toUpperCase()\n this._url = resolvedUrl\n this._intercepted = resolvedUrl === documentUri &&\n ${JSON.stringify(Array.from(PREVIEW_METHODS))}.includes(this._method)\n if (!this._intercepted) {\n this._native.open(method, url, async, user, password)\n for (const type of ['abort', 'error', 'load', 'loadend', 'progress', 'readystatechange', 'timeout']) {\n this._native.addEventListener(type, event => this._emitNative(type, event))\n }\n }\n this.readyState = 1\n this._emit('readystatechange')\n }\n\n _emitNative (type, event) {\n this.readyState = this._native.readyState\n this.status = this._native.status\n this.statusText = this._native.statusText\n this.response = this._native.response\n this.responseText = this._native.responseText\n this._emit(type)\n }\n\n setRequestHeader (name, value) {\n if (this._intercepted) this._headers[name] = value\n else this._native.setRequestHeader(name, value)\n }\n\n send (body) {\n if (!this._intercepted) {\n this._native.send(body)\n return\n }\n requestParent(this._url, {\n method: this._method,\n headers: this._headers,\n body: this._method === 'GET' || this._method === 'HEAD' ? undefined : body\n }).then(async response => {\n this.status = response.status\n this.statusText = response.statusText\n this._responseHeaders = response.headers\n this.responseText = await response.text()\n this.response = this.responseText\n this.readyState = 4\n this._emit('readystatechange')\n this._emit(response.ok ? 'load' : 'error')\n this._emit('loadend')\n }).catch(() => {\n this.readyState = 4\n this._emit('readystatechange')\n this._emit('error')\n this._emit('loadend')\n })\n }\n\n abort () {\n if (!this._intercepted) this._native.abort()\n this._emit('abort')\n }\n\n getResponseHeader (name) {\n return this._responseHeaders?.get(name) || null\n }\n\n getAllResponseHeaders () {\n return this._responseHeaders\n ? Array.from(this._responseHeaders.entries()).map(([key, value]) => key + ': ' + value).join('\\\\r\\\\n')\n : ''\n }\n }\n})()\n</script>`\n return withBaseHref(html, uri).replace(/<head(\\s[^>]*)?>/i, match => `${match}${bridge}`)\n}\n\nfunction mountDokieliBridge (\n frame: HTMLIFrameElement,\n uri: string,\n html: string,\n authenticatedFetch: (url: string, init?: RequestInit) => Promise<Response>\n): void {\n const ownerWindow = frame.ownerDocument.defaultView\n if (!ownerWindow) return\n\n const randomValues = new Uint32Array(4)\n ownerWindow.crypto.getRandomValues(randomValues)\n const nonce = Array.from(randomValues, value => value.toString(16)).join('-')\n const expectedUri = new URL(uri).href\n const listener = (event: MessageEvent<PreviewRequest>) => {\n const request = event.data\n if (\n event.source !== frame.contentWindow ||\n !request ||\n request.type !== PREVIEW_REQUEST_TYPE ||\n request.nonce !== nonce ||\n previewRequestUrl(request.url, expectedUri) !== expectedUri ||\n !PREVIEW_METHODS.has(request.method)\n ) return\n\n const respond = (response: PreviewResponse) => {\n frame.contentWindow?.postMessage(response, '*')\n }\n\n authenticatedFetch(expectedUri, {\n method: request.method,\n headers: request.headers,\n body: request.method === 'GET' ? undefined : request.body\n }).then(async response => {\n respond({\n type: PREVIEW_RESPONSE_TYPE,\n nonce,\n id: request.id,\n ok: response.ok,\n status: response.status,\n headers: Array.from(response.headers.entries()),\n body: await response.text()\n })\n }).catch(error => {\n respond({\n type: PREVIEW_RESPONSE_TYPE,\n nonce,\n id: request.id,\n ok: false,\n status: 0,\n headers: [],\n body: '',\n error: error instanceof Error ? error.message : String(error)\n })\n })\n }\n\n ownerWindow.addEventListener('message', listener)\n frame.setAttribute('sandbox', HTML_PREVIEW_SANDBOX)\n frame.srcdoc = createPreviewBridge(html, expectedUri, nonce)\n}\n\nconst humanReadablePane: HumanReadablePaneDefinition = {\n icon: function (subject: NamedNode, context: DataBrowserContext): HumanReadableIcon {\n // Markdown files detected by extension\n if (subject && isMarkdownFile(subject.uri)) {\n return icons.iconBase + 'markdown.svg'\n }\n\n // Dokieli files detected by content check\n if (subject) {\n const kb = context.session.store\n\n // Check cache from previous detection\n const cachedResult = dokieliCache.get(subject.uri)\n if (cachedResult === 'dokieli') {\n return icons.iconBase + 'dokieli-logo.png'\n } else if (cachedResult === 'html') {\n return icons.originalIconBase + 'tango/22-text-x-generic.png'\n }\n\n // Check if content already fetched (synchronous)\n const responseText = kb.fetcher.getHeader(subject.doc(), 'content')\n if (responseText && responseText.length > 0) {\n const text = responseText[0]\n const isDokieli = text.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ||\n text.includes('dokieli.css')\n dokieliCache.set(subject.uri, isDokieli ? 'dokieli' : 'html')\n return isDokieli\n ? icons.iconBase + 'dokieli-logo.png'\n : icons.originalIconBase + 'tango/22-text-x-generic.png'\n }\n\n // Content not yet fetched - return a promise (async detection)\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0].split(';', 1)[0].trim() : null\n\n if (ct === 'text/html') {\n return kb.fetcher._fetch(subject.uri)\n .then(response => response.text())\n .then(text => {\n const isDokieli = text.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ||\n text.includes('dokieli.css')\n dokieliCache.set(subject.uri, isDokieli ? 'dokieli' : 'html')\n return isDokieli\n ? icons.iconBase + 'dokieli-logo.png'\n : icons.originalIconBase + 'tango/22-text-x-generic.png'\n })\n .catch(() => {\n dokieliCache.set(subject.uri, 'html')\n return icons.originalIconBase + 'tango/22-text-x-generic.png'\n })\n }\n }\n\n // Default for all other human-readable content\n return icons.originalIconBase + 'tango/22-text-x-generic.png'\n },\n\n name: 'humanReadable',\n\n label: function (\n subject: NamedNode,\n context: DataBrowserContext\n ): 'Webpage' | 'View' | null {\n const kb = context.session.store\n\n // See also the source pane, which has lower precedence.\n\n const allowed = [\n 'text/plain',\n 'text/html',\n 'text/markdown',\n 'application/xhtml+xml',\n 'application/pdf',\n 'video/mp4'\n ]\n\n const hasContentTypeIn = function (\n kb: typeof context.session.store,\n x: NamedNode,\n displayables: string[]\n ): boolean {\n const cts = kb.fetcher.getHeader(x, 'content-type')\n if (cts) {\n for (let j = 0; j < cts.length; j++) {\n for (let k = 0; k < displayables.length; k++) {\n if (cts[j].indexOf(displayables[k]) >= 0) {\n return true\n }\n }\n }\n }\n return false\n }\n\n // This data could come from a fetch OR from ldp container\n const hasContentTypeIn2 = function (\n kb: typeof context.session.store,\n x: NamedNode,\n displayables: string[]\n ): boolean {\n const t = kb.findTypeURIs(x)\n for (let k = 0; k < displayables.length; k++) {\n if (Util.mediaTypeClass(displayables[k]).uri in t) {\n return true\n }\n }\n return false\n }\n\n if (!subject.uri) return null // no bnodes\n\n const t = kb.findTypeURIs(subject)\n if (t[ns.link('WebPage').uri]) return 'Webpage'\n\n // Check file extension for markdown files\n if (isMarkdownFile(subject.uri)) {\n return 'View'\n }\n\n if (\n hasContentTypeIn(kb, subject, allowed) ||\n hasContentTypeIn2(kb, subject, allowed)\n ) {\n // For HTML files, check if it's dokieli (async check, store result for later)\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0].split(';', 1)[0].trim() : null\n\n if (ct === 'text/html' && !dokieliCache.has(subject.uri)) {\n // Async check for dokieli, don't wait for result\n kb.fetcher._fetch(subject.uri)\n .then(response => response.text())\n .then(text => {\n const isDokieli = text.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ||\n text.includes('dokieli.css')\n dokieliCache.set(subject.uri, isDokieli ? 'dokieli' : 'html')\n })\n .catch(() => {\n dokieliCache.set(subject.uri, 'html')\n })\n }\n\n return 'View'\n }\n\n return null\n },\n\n render: function (\n subject: NamedNode,\n context: DataBrowserContext\n ): HTMLDivElement {\n const myDocument = context.dom\n const div = myDocument.createElement('div')\n const kb = context.session.store\n\n function applyEnvironmentAttributes (element: HTMLDivElement): void {\n const environment = (context.environment ?? {}) as Partial<RenderEnvironment>\n element.dataset.layout = environment.layout ?? 'desktop'\n }\n\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0].split(';', 1)[0].trim() : null // remove content-type parameters\n\n // Fallback: detect markdown by file extension if content-type is not text/markdown\n const isMarkdown = ct === 'text/markdown' || isMarkdownFile(subject.uri)\n const isPlainText = ct === 'text/plain'\n\n if (ct) {\n // console.log('humanReadablePane: c-t:' + ct)\n } else {\n console.log('humanReadablePane: unknown content-type?')\n }\n\n // @@ When we can, use CSP to turn off scripts within the iframe\n div.classList.add('human-readable-pane')\n applyEnvironmentAttributes(div)\n\n // render markdown to html in a DIV element\n const renderMarkdownContent = function (frame: HTMLDivElement) {\n kb.fetcher.webOperation('GET', subject.uri).then(response => {\n const markdownText = response.responseText ?? ''\n const lines = Math.min(30, markdownText.split(/\\n/).length + 5)\n const res = marked.parse(markdownText, { async: false })\n const clean = DOMPurify.sanitize(res)\n frame.innerHTML = clean\n applyFrameClasses(frame, 'markdown', lines)\n }).catch(error => {\n console.error('Error fetching markdown content:', error)\n frame.innerHTML = '<p>Error loading content</p>'\n })\n }\n\n // render plain text in a PRE element\n const renderPlainTextContent = function (frame: HTMLPreElement) {\n kb.fetcher.webOperation('GET', subject.uri).then(response => {\n const plainText = response.responseText ?? ''\n const lines = Math.min(30, plainText.split(/\\n/).length + 5)\n frame.textContent = plainText\n applyFrameClasses(frame, 'plain-text', lines)\n }).catch(error => {\n console.error('Error fetching plain text content:', error)\n frame.textContent = 'Error loading content'\n })\n }\n\n if (isMarkdown) {\n // For markdown, use a DIV element and render the content\n const frame = myDocument.createElement('div')\n renderMarkdownContent(frame)\n const frameContainer = myDocument.createElement('div')\n frameContainer.classList.add('human-readable-pane__container')\n frameContainer.appendChild(frame)\n div.appendChild(frameContainer)\n } else if (isPlainText) {\n // For plain text, use a PRE element and render the content\n const frame = myDocument.createElement('pre')\n renderPlainTextContent(frame)\n const frameContainer = myDocument.createElement('div')\n frameContainer.classList.add('human-readable-pane__container')\n frameContainer.appendChild(frame)\n div.appendChild(frameContainer)\n } else {\n // For other content types, use IFRAME.\n // The iframe's own request would be anonymous (Solid auth is not cookie based), so the\n // content is fetched with the authenticated fetcher and handed to the frame directly.\n const frame = myDocument.createElement('iframe')\n frame.name = HUMAN_READABLE_PREVIEW_FRAME_NAME\n frame.title = resourceFilename(subject.uri)\n applyFrameClasses(frame, 'iframe')\n const isHtml = ct === 'text/html' || ct === 'application/xhtml+xml'\n let previewUrl: string | null = null\n let disposed = false\n let wasConnected = false\n const mutationObserver = typeof MutationObserver === 'undefined'\n ? null\n : new MutationObserver(records => {\n const wasAdded = records.some(record =>\n Array.from(record.addedNodes).some(node =>\n node === div || (node.nodeType === Node.ELEMENT_NODE && (node as Element).contains(div))\n )\n )\n if (div.isConnected) {\n wasConnected = true\n } else if (wasConnected || wasAdded) {\n disposed = true\n if (previewUrl) {\n URL.revokeObjectURL(previewUrl)\n previewUrl = null\n }\n mutationObserver?.disconnect()\n }\n })\n mutationObserver?.observe(myDocument, { childList: true, subtree: true })\n\n const showError = (message: string) => {\n frame.removeAttribute('src')\n frame.setAttribute('sandbox', '')\n frame.srcdoc = `<p style=\"font-family: sans-serif\">${escapeAttribute(message)}</p>`\n }\n\n if (isHtml) {\n kb.fetcher.webOperation('GET', subject.uri).then(response => {\n const html = response.responseText ?? ''\n frame.title = documentTitle(html, subject.uri)\n const isDokieli = isDokieliHtml(html)\n dokieliCache.set(subject.uri, isDokieli ? 'dokieli' : 'html')\n if (isDokieli) {\n mountDokieliBridge(frame, subject.uri, html, (url, init) => kb.fetcher._fetch(url, init))\n } else {\n frame.setAttribute('sandbox', HTML_PREVIEW_SANDBOX)\n frame.srcdoc = withBaseHref(html, subject.uri)\n }\n }).catch(error => {\n console.error('Error fetching HTML content:', error)\n showError('Error loading content')\n })\n } else {\n kb.fetcher._fetch(subject.uri).then(async response => {\n if (!response.ok) throw new Error(`HTTP ${response.status}`)\n const responseContentType = response.headers.get('content-type')?.split(';', 1)[0].trim().toLowerCase()\n if (responseContentType === 'text/html' || responseContentType === 'application/xhtml+xml') {\n const html = await response.text()\n frame.title = documentTitle(html, subject.uri)\n const isDokieli = isDokieliHtml(html)\n dokieliCache.set(subject.uri, isDokieli ? 'dokieli' : 'html')\n if (isDokieli) {\n mountDokieliBridge(frame, subject.uri, html, (url, init) => kb.fetcher._fetch(url, init))\n } else {\n frame.setAttribute('sandbox', HTML_PREVIEW_SANDBOX)\n frame.srcdoc = withBaseHref(html, subject.uri)\n }\n return\n }\n frame.setAttribute('sandbox', HTML_PREVIEW_SANDBOX)\n const objectUrl = URL.createObjectURL(await response.blob())\n if (disposed) {\n URL.revokeObjectURL(objectUrl)\n return\n }\n previewUrl = objectUrl\n frame.src = objectUrl\n }).catch(error => {\n console.error('Error fetching content:', error)\n showError('Error loading content')\n })\n }\n\n const frameContainer = myDocument.createElement('div')\n frameContainer.classList.add('human-readable-pane__container')\n frameContainer.classList.add('human-readable-pane__container--iframe')\n frameContainer.appendChild(frame)\n div.appendChild(frameContainer)\n div.classList.add('human-readable-pane--iframe')\n }\n\n return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A/C,EAAM,aAAa,UAAWI,CAAoB,EAClD,IAAMoF,EAAY,IAAI,gBAAgB,MAAM7C,EAAS,KAAK,CAAC,EACvDkC,EACF,IAAI,gBAAgBW,CAAS,GAG/B,EAAaA,EACb,EAAM,IAAMA,EACd,CAAC,CAAC,CAAC,MAAM,GAAS,CAChB,QAAQ,MAAM,0BAA2B3C,CAAK,EAC9CuC,EAAU,uBAAuB,CACnC,CAAC,EAGH,IAAMV,EAAiBZ,EAAW,cAAc,KAAK,EACrDY,EAAe,UAAU,IAAI,gCAAgC,EAC7DA,EAAe,UAAU,IAAI,wCAAwC,EACrEA,EAAe,YAAY1E,CAAK,EAChC+D,EAAI,YAAYW,CAAc,EAC9BX,EAAI,UAAU,IAAI,6BAA6B,CACjD,CAEA,OAAOA,CACT,CACF,E"}
|
|
1
|
+
{"version":3,"file":"humanReadablePane2.cjs.js","names":["authn","icons","Util","ns","DOMPurify","require_runtime","solid_ui","solid_logic","rdflib","marked","dompurify","viewerWebId","isMarkdownFile","uri","path","isJsonFile","dokieliCache","applyFrameClasses","frame","modifier","lines","HUMAN_READABLE_PREVIEW_FRAME_NAME","HTML_PREVIEW_SANDBOX","isDokieliHtml","text","escapeAttribute","value","withBaseHref","existingBase","html","href","existingHref","resolvedHref","baseUri","resolvedBase","base","headMatch","insertAt","withPreviewResizeScript","script","withScript","resourceFilename","encodedFilename","documentTitle","fallback","PREVIEW_REQUEST_TYPE","PREVIEW_RESPONSE_TYPE","PREVIEW_BRIDGE_ATTRIBUTE","PREVIEW_READ_METHODS","PREVIEW_WRITE_METHODS","stripPreviewBridgeScripts","parsed","removed","source","doctype","isSrcdocUrl","url","previewRequestUrl","resolvedUrl","documentUri","profileDocumentUrl","webId","isAllowedPreviewRequest","expectedUrl","normalizedMethod","method","requestedDocument","expectedDocument","isPreviewDocument","isExactPreviewDocument","isApprovedProfileResource","createPreviewBridge","bridge","nonce","match","mountDokieliBridge","ownerWindow","randomValues","expectedUri","request","event","respond","response","authenticatedFetch","error","installPreviewAutoSize","onMessage","message","humanReadablePane","subject","kb","context","cachedResult","responseText","isDokieli","cts","allowed","hasContentTypeIn","x","j","k","displayables","hasContentTypeIn2","t","myDocument","div","applyEnvironmentAttributes","environment","ct","isMarkdown","isPlainText","renderMarkdownContent","markdownText","res","renderPlainTextContent","plainText","frameContainer","removePreviewAutoSize","isHtml","previewUrl","disposed","wasConnected","mutationObserver","wasAdded","records","record","node","showError","init","responseContentType","objectUrl"],"sources":["../src/humanReadablePane.ts"],"sourcesContent":["/* Human-readable Pane\n **\n ** This outline pane contains the document contents for an HTML document\n ** This is for peeking at a page, because the user might not want to leave the data browser.\n */\nimport { icons, ns } from 'solid-ui'\nimport { Util } from 'rdflib'\nimport { authn } from 'solid-logic'\nimport { marked } from 'marked'\nimport DOMPurify from 'dompurify'\nimport type { DataBrowserContext, RenderEnvironment } from 'pane-registry'\nimport type { NamedNode } from 'rdflib'\nimport './humanReadablePane.css'\n\nfunction viewerWebId (): string | null {\n try {\n return authn.currentUser()?.value ?? null\n } catch {\n return null\n }\n}\n\n// Helper function to check if a URI has a markdown file extension\ntype DokieliCacheValue = 'dokieli' | 'html'\n\ntype HumanReadableIcon = string | Promise<string>\n\ntype HumanReadablePaneDefinition = {\n icon: (subject: NamedNode, context: DataBrowserContext) => HumanReadableIcon\n name: string\n label: (subject: NamedNode, context: DataBrowserContext) => 'Webpage' | 'View' | null\n render: (subject: NamedNode, context: DataBrowserContext) => HTMLDivElement\n}\n\nconst isMarkdownFile = (uri?: string | null): boolean => {\n if (!uri) return false\n const path = uri.split('?')[0].split('#')[0] // Remove query string and fragment\n return /\\.(md|markdown|mdown|mkd|mkdn)$/i.test(path)\n}\n\nconst isJsonFile = (uri?: string | null): boolean => {\n if (!uri) return false\n const path = uri.split('?')[0].split('#')[0]\n return /\\.json$/i.test(path)\n}\n\n// Cache for dokieli detection results (keyed by subject URI)\nconst dokieliCache = new Map<string, DokieliCacheValue>()\n\nfunction applyFrameClasses (\n frame: HTMLElement,\n modifier: 'markdown' | 'plain-text' | 'iframe',\n lines?: number\n): void {\n frame.className = ''\n frame.classList.add('human-readable-pane__frame')\n frame.classList.add(`human-readable-pane__frame--${modifier}`)\n if (lines !== undefined) {\n frame.style.setProperty('--human-readable-pane-height', `${lines * 16}px`)\n }\n}\n\n// window.name of preview iframes; initMainPage refuses to boot SolidOS inside such a frame.\nexport const HUMAN_READABLE_PREVIEW_FRAME_NAME = 'solidos-human-readable-preview'\n\n// Scripts may run but get an opaque origin, so previewed pages cannot reach the SolidOS session.\nconst HTML_PREVIEW_SANDBOX = 'allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals'\n\nconst isDokieliHtml = (text: string): boolean =>\n text.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') || text.includes('dokieli.css')\n\nfunction escapeAttribute (value: string): string {\n return value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>')\n}\n\n// srcdoc documents resolve relative URLs against about:srcdoc, so point them back at the resource.\nexport function withBaseHref (html: string, baseUri: string): string {\n const existingBase = html.match(/<base(\\s[^>]*)?>/i)\n if (existingBase && existingBase.index !== undefined) {\n const href = existingBase[0].match(/\\bhref\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/i)\n const existingHref = href?.[1] ?? href?.[2] ?? href?.[3]\n if (!href || existingHref === undefined) return html\n if (/^[a-z][a-z\\d+.-]*:/i.test(existingHref) || existingHref.startsWith('//')) return html\n let resolvedHref: string\n try {\n resolvedHref = new URL(existingHref, baseUri).href\n } catch {\n return html\n }\n const resolvedBase = existingBase[0].replace(href[0], `href=\"${escapeAttribute(resolvedHref)}\"`)\n return html.slice(0, existingBase.index) + resolvedBase + html.slice(existingBase.index + existingBase[0].length)\n }\n const base = `<base href=\"${escapeAttribute(baseUri)}\">`\n const headMatch = html.match(/<head(\\s[^>]*)?>/i)\n if (headMatch && headMatch.index !== undefined) {\n const insertAt = headMatch.index + headMatch[0].length\n return html.slice(0, insertAt) + base + html.slice(insertAt)\n }\n return base + html\n}\n\nfunction withPreviewResizeScript (html: string): string {\n const script = `<script>\n(() => {\n const style = document.createElement('style')\n style.textContent = 'html, body { height: auto !important; min-height: 0 !important; max-height: none !important; overflow: visible !important; }'\n document.head?.appendChild(style)\n const reportHeight = () => {\n const elements = Array.from(document.querySelectorAll('*'))\n const height = Math.max(\n document.documentElement.scrollHeight,\n document.body ? document.body.scrollHeight : 0,\n ...elements.map(element => Math.max(\n element.scrollHeight,\n Math.ceil(element.getBoundingClientRect().bottom + window.scrollY)\n ))\n )\n window.parent.postMessage({ type: 'solidos-preview-size', height }, '*')\n }\n window.addEventListener('load', reportHeight)\n new ResizeObserver(reportHeight).observe(document.documentElement)\n document.addEventListener('DOMContentLoaded', () => {\n if (document.body) new ResizeObserver(reportHeight).observe(document.body)\n new MutationObserver(reportHeight).observe(document.body || document.documentElement, {\n childList: true,\n subtree: true,\n attributes: true\n })\n reportHeight()\n })\n window.setInterval(reportHeight, 500)\n reportHeight()\n})()\n</script>`\n const withScript = html.replace(/<\\/body\\s*>/i, `${script}$&`)\n return withScript === html ? `${html}${script}` : withScript\n}\n\nfunction resourceFilename (uri: string): string {\n const encodedFilename = uri.split('/').pop() || uri\n try {\n return decodeURIComponent(encodedFilename)\n } catch {\n return encodedFilename\n }\n}\n\nfunction documentTitle (html: string, uri: string): string {\n const fallback = resourceFilename(uri)\n try {\n const title = new DOMParser().parseFromString(html, 'text/html').querySelector('title')?.textContent?.trim()\n return title || fallback\n } catch {\n return fallback\n }\n}\n\ntype PreviewRequest = {\n type: 'solidos-preview-request'\n nonce: string\n id: string\n url: string\n method: string\n headers?: Record<string, string>\n body?: string\n}\n\ntype PreviewResponse = {\n type: 'solidos-preview-response'\n nonce: string\n id: string\n ok: boolean\n status: number\n headers: Array<[string, string]>\n body: string\n error?: string\n}\n\nconst PREVIEW_REQUEST_TYPE = 'solidos-preview-request'\nconst PREVIEW_RESPONSE_TYPE = 'solidos-preview-response'\nconst PREVIEW_BRIDGE_ATTRIBUTE = 'data-solidos-preview-bridge'\nconst PREVIEW_READ_METHODS = new Set(['GET', 'HEAD'])\nconst PREVIEW_WRITE_METHODS = new Set(['PUT', 'PATCH', 'DELETE'])\n\nfunction stripPreviewBridgeScripts (html: string | undefined): string | undefined {\n if (typeof html !== 'string' || !html.includes(PREVIEW_REQUEST_TYPE)) return html\n\n const parsed = new DOMParser().parseFromString(html, 'text/html')\n let removed = false\n for (const script of parsed.querySelectorAll('script')) {\n const source = script.textContent || ''\n const isPreviewBridge = script.hasAttribute(PREVIEW_BRIDGE_ATTRIBUTE) ||\n (\n source.includes(PREVIEW_REQUEST_TYPE) &&\n source.includes(PREVIEW_RESPONSE_TYPE) &&\n source.includes('const pending = new Map()')\n )\n if (isPreviewBridge) {\n script.remove()\n removed = true\n }\n }\n if (!removed) return html\n\n const doctype = html.match(/<!doctype[^>]*>/i)?.[0]\n return `${doctype ? `${doctype}\\n` : ''}${parsed.documentElement.outerHTML}`\n}\n\nfunction isSrcdocUrl (url: string): boolean {\n return url === 'about:srcdoc' || /^file:\\/\\/srcdoc\\/?(?:[?#].*)?$/i.test(url)\n}\n\nexport function previewRequestUrl (url: string, documentUri: string): string {\n const resolvedUrl = new URL(url, documentUri).href\n return isSrcdocUrl(resolvedUrl) ? documentUri : resolvedUrl\n}\n\nfunction profileDocumentUrl (webId: string | null | undefined): string | undefined {\n if (!webId) return undefined\n try {\n const url = new URL(webId)\n url.hash = ''\n return url.href\n } catch {\n return undefined\n }\n}\n\nexport function isAllowedPreviewRequest (\n url: string,\n method: string,\n documentUri: string,\n webId: string | null = null\n): boolean {\n let resolvedUrl: URL\n let expectedUrl: URL\n try {\n resolvedUrl = new URL(previewRequestUrl(url, documentUri))\n expectedUrl = new URL(documentUri)\n } catch {\n return false\n }\n\n if (resolvedUrl.origin !== expectedUrl.origin) {\n return false\n }\n\n const normalizedMethod = method.toUpperCase()\n const requestedDocument = new URL(resolvedUrl.href)\n requestedDocument.hash = ''\n const expectedDocument = new URL(expectedUrl.href)\n expectedDocument.hash = ''\n const isPreviewDocument = requestedDocument.href === expectedDocument.href\n const isExactPreviewDocument = resolvedUrl.href === expectedUrl.href\n // Path-based pods keep the viewer profile below the pod path, e.g. /alice/profile/card.\n const isApprovedProfileResource = resolvedUrl.pathname === '/profile/card' ||\n requestedDocument.href === profileDocumentUrl(webId)\n return (\n PREVIEW_READ_METHODS.has(normalizedMethod) &&\n (isPreviewDocument || isApprovedProfileResource)\n ) || (isExactPreviewDocument && PREVIEW_WRITE_METHODS.has(normalizedMethod))\n}\n\nfunction createPreviewBridge (html: string, uri: string, nonce: string, webId: string | null = null): string {\n const bridge = `<script ${PREVIEW_BRIDGE_ATTRIBUTE}=\"true\">\n(() => {\n const documentUri = ${JSON.stringify(uri)}\n const documentOrigin = new URL(documentUri).origin\n const nonce = ${JSON.stringify(nonce)}\n const viewerWebId = ${JSON.stringify(webId)}\n const pending = new Map()\n let requestId = 0\n try {\n history.replaceState(null, '', documentUri)\n } catch {\n // Sandboxed documents may reject cross-origin history URLs.\n }\n // Opaque sandbox origins cannot use IndexedDB. Dokieli uses it for local\n // preferences and history, so provide an in-memory implementation without\n // granting the preview a persistent storage capability.\n try {\n window.indexedDB.open('__solidos_probe__')\n } catch {\n const databases = new Map()\n const request = (result) => ({ result, error: null, onsuccess: null, onerror: null, onupgradeneeded: null })\n const isolatedIndexedDB = {\n open (name) {\n const stores = databases.get(name) || new Map()\n databases.set(name, stores)\n const database = {\n objectStoreNames: { contains: storeName => stores.has(storeName) },\n createObjectStore (storeName) {\n if (!stores.has(storeName)) stores.set(storeName, new Map())\n return database.transaction(storeName, 'readwrite').objectStore(storeName)\n },\n transaction (storeName, mode = 'readonly') {\n const store = stores.get(storeName) || new Map()\n stores.set(storeName, store)\n let pending = 0\n let completed = false\n const transaction = {\n oncomplete: null,\n onerror: null,\n onabort: null,\n objectStore: () => {\n const run = (result, change) => {\n const operation = request(result)\n pending++\n queueMicrotask(() => {\n try {\n change?.()\n operation.onsuccess?.({ target: operation })\n } catch (error) {\n operation.error = error\n operation.onerror?.({ target: operation })\n } finally {\n pending--\n if (!pending && !completed) {\n completed = true\n transaction.oncomplete?.({ target: transaction })\n }\n }\n })\n return operation\n }\n const openCursor = (withValue) => {\n const keys = Array.from(store.keys())\n const operation = request(null)\n pending++\n let index = 0\n const emit = () => {\n operation.result = index < keys.length\n ? {\n key: keys[index],\n primaryKey: keys[index],\n value: withValue ? store.get(keys[index]) : undefined,\n continue: () => { index++; queueMicrotask(emit) }\n }\n : null\n operation.onsuccess?.({ target: operation })\n if (!operation.result) {\n pending--\n if (!pending && !completed) {\n completed = true\n transaction.oncomplete?.({ target: transaction })\n }\n }\n }\n queueMicrotask(emit)\n return operation\n }\n return {\n transaction,\n get: key => run(store.get(key)),\n getAll: () => run(Array.from(store.values())),\n getAllKeys: () => run(Array.from(store.keys())),\n count: () => run(store.size),\n openCursor: () => openCursor(true),\n openKeyCursor: () => openCursor(false),\n put: (value, key) => run(undefined, () => store.set(key, value)),\n add: (value, key) => run(undefined, () => store.set(key, value)),\n delete: key => run(undefined, () => store.delete(key)),\n clear: () => run(undefined, () => store.clear())\n }\n }\n }\n return transaction\n },\n close () {}\n }\n const operation = request(database)\n queueMicrotask(() => {\n operation.onupgradeneeded?.({ target: operation })\n operation.onsuccess?.({ target: operation })\n })\n return operation\n },\n deleteDatabase (name) {\n databases.delete(name)\n const operation = request(undefined)\n queueMicrotask(() => operation.onsuccess?.({ target: operation }))\n return operation\n }\n }\n Object.defineProperty(window, 'indexedDB', { configurable: true, value: isolatedIndexedDB })\n }\n const createMemoryStorage = () => {\n const values = new Map()\n return {\n get length () { return values.size },\n key: index => Array.from(values.keys())[index] ?? null,\n getItem: key => values.get(String(key)) ?? null,\n setItem: (key, value) => values.set(String(key), String(value)),\n removeItem: key => values.delete(String(key)),\n clear: () => values.clear()\n }\n }\n for (const storageName of ['localStorage', 'sessionStorage']) {\n try {\n window[storageName].getItem('__solidos_probe__')\n } catch {\n Object.defineProperty(window, storageName, {\n configurable: true,\n value: createMemoryStorage()\n })\n }\n }\n const nativeFetch = window.fetch.bind(window)\n\n function isSrcdocUrl (url) {\n return url === 'about:srcdoc' || /^file:\\\\/\\\\/srcdoc\\\\/?(?:[?#].*)?$/i.test(url)\n }\n\n function documentRequestUrl (url) {\n const resolvedUrl = new URL(url, documentUri).href\n // srcdoc keeps this URL even when history.replaceState is unavailable in\n // an opaque sandbox. Dokieli saves via document.location.href.\n return isSrcdocUrl(resolvedUrl) ? documentUri : resolvedUrl\n }\n\n function requestParent (url, init) {\n const id = String(++requestId)\n return new Promise((resolve, reject) => {\n pending.set(id, { resolve, reject })\n window.parent.postMessage({\n type: ${JSON.stringify(PREVIEW_REQUEST_TYPE)},\n nonce,\n id,\n url,\n method: init.method,\n headers: init.headers,\n body: init.body\n }, '*')\n })\n }\n\n window.addEventListener('message', event => {\n const message = event.data\n if (!message || message.type !== ${JSON.stringify(PREVIEW_RESPONSE_TYPE)} || message.nonce !== nonce) return\n const entry = pending.get(message.id)\n if (!entry) return\n pending.delete(message.id)\n if (!message.ok) {\n entry.reject(new Error(message.error || 'Preview request failed'))\n return\n }\n const responseBody = [204, 205, 304].includes(message.status) ? null : message.body\n entry.resolve(new Response(responseBody, {\n status: message.status,\n headers: message.headers\n }))\n })\n\n const reportHeight = () => {\n const elements = Array.from(document.querySelectorAll('*'))\n const height = Math.max(\n document.documentElement.scrollHeight,\n document.body ? document.body.scrollHeight : 0,\n ...elements.map(element => Math.max(\n element.scrollHeight,\n Math.ceil(element.getBoundingClientRect().bottom + window.scrollY)\n ))\n )\n window.parent.postMessage({ type: 'solidos-preview-size', height }, '*')\n }\n window.addEventListener('load', reportHeight)\n new ResizeObserver(reportHeight).observe(document.documentElement)\n if (document.body) new ResizeObserver(reportHeight).observe(document.body)\n new MutationObserver(reportHeight).observe(document.body || document.documentElement, {\n childList: true,\n subtree: true,\n attributes: true\n })\n window.setInterval(reportHeight, 500)\n reportHeight()\n\n window.fetch = async (input, init = {}) => {\n const request = input instanceof Request ? input : null\n const url = documentRequestUrl(request ? request.url : input)\n const method = (init.method || (request && request.method) || 'GET').toUpperCase()\n const sameOrigin = new URL(url).origin === documentOrigin\n const allowed = sameOrigin &&\n (${JSON.stringify(Array.from(PREVIEW_READ_METHODS))}.includes(method) ||\n (url === documentUri && ${JSON.stringify(Array.from(PREVIEW_WRITE_METHODS))}.includes(method)))\n if (!allowed) {\n return nativeFetch(input, init)\n }\n const headers = new Headers(request ? request.headers : undefined)\n for (const [key, value] of new Headers(init.headers || {}).entries()) headers.set(key, value)\n const body = method === 'GET' || method === 'HEAD'\n ? undefined\n : (init.body || (request ? await request.clone().text() : undefined))\n return requestParent(url, {\n method,\n headers: Object.fromEntries(headers.entries()),\n body\n })\n }\n\n const NativeXMLHttpRequest = window.XMLHttpRequest\n window.XMLHttpRequest = class PreviewXMLHttpRequest {\n constructor () {\n this._native = new NativeXMLHttpRequest()\n this._headers = {}\n this._listeners = {}\n this._intercepted = false\n this.readyState = 0\n this.status = 0\n this.statusText = ''\n this.response = null\n this.responseText = ''\n }\n\n addEventListener (type, listener) {\n this._listeners[type] = this._listeners[type] || []\n this._listeners[type].push(listener)\n }\n\n _emit (type) {\n const event = { target: this, currentTarget: this, type }\n if (typeof this['on' + type] === 'function') this['on' + type](event)\n for (const listener of this._listeners[type] || []) listener.call(this, event)\n }\n\n open (method, url, async = true, user, password) {\n const resolvedUrl = documentRequestUrl(url)\n this._method = String(method || 'GET').toUpperCase()\n this._url = resolvedUrl\n const sameOrigin = new URL(resolvedUrl).origin === documentOrigin\n this._intercepted = sameOrigin &&\n (${JSON.stringify(Array.from(PREVIEW_READ_METHODS))}.includes(this._method) ||\n (resolvedUrl === documentUri && ${JSON.stringify(Array.from(PREVIEW_WRITE_METHODS))}.includes(this._method)))\n if (!this._intercepted) {\n this._native.open(method, url, async, user, password)\n for (const type of ['abort', 'error', 'load', 'loadend', 'progress', 'readystatechange', 'timeout']) {\n this._native.addEventListener(type, event => this._emitNative(type, event))\n }\n }\n this.readyState = 1\n this._emit('readystatechange')\n }\n\n _emitNative (type, event) {\n this.readyState = this._native.readyState\n this.status = this._native.status\n this.statusText = this._native.statusText\n this.response = this._native.response\n this.responseText = this._native.responseText\n this._emit(type)\n }\n\n setRequestHeader (name, value) {\n if (this._intercepted) this._headers[name] = value\n else this._native.setRequestHeader(name, value)\n }\n\n send (body) {\n if (!this._intercepted) {\n this._native.send(body)\n return\n }\n requestParent(this._url, {\n method: this._method,\n headers: this._headers,\n body: this._method === 'GET' || this._method === 'HEAD' ? undefined : body\n }).then(async response => {\n this.status = response.status\n this.statusText = response.statusText\n this._responseHeaders = response.headers\n this.responseText = await response.text()\n this.response = this.responseText\n this.readyState = 4\n this._emit('readystatechange')\n this._emit(response.ok ? 'load' : 'error')\n this._emit('loadend')\n }).catch(() => {\n this.readyState = 4\n this._emit('readystatechange')\n this._emit('error')\n this._emit('loadend')\n })\n }\n\n abort () {\n if (!this._intercepted) this._native.abort()\n this._emit('abort')\n }\n\n getResponseHeader (name) {\n return this._responseHeaders?.get(name) || null\n }\n\n getAllResponseHeaders () {\n return this._responseHeaders\n ? Array.from(this._responseHeaders.entries()).map(([key, value]) => key + ': ' + value).join('\\\\r\\\\n')\n : ''\n }\n }\n\n // Dokieli's own OIDC session cannot be restored in an opaque-origin\n // sandbox, so it would always show \"Sign in\". Give it the SolidOS viewer\n // through the same session shape Dokieli uses for its WebExtension mode;\n // requests still go through the restricted bridge above.\n const bridgedSession = viewerWebId\n ? {\n isActive: true,\n webId: viewerWebId,\n authFetch: (input, init) => window.fetch(input, init),\n handleRedirectFromLogin: async () => {},\n restore: async () => {},\n login: async () => {},\n logout: async () => {\n bridgedSession.isActive = false\n bridgedSession.webId = undefined\n }\n }\n : null\n let dokieliHooksInstalled = false\n const installDokieliHooks = () => {\n const config = window.DO && window.DO.C\n if (!config || dokieliHooksInstalled) return\n dokieliHooksInstalled = true\n if (bridgedSession) config.Session = bridgedSession\n // Dokieli skips requests for file: URLs, which is how srcdoc reports\n // its location, so keep its document URL pointing at the resource.\n let documentUrl = config.DocumentURL\n Object.defineProperty(config, 'DocumentURL', {\n configurable: true,\n enumerable: true,\n get: () => documentUrl,\n set: value => {\n documentUrl = typeof value === 'string' && isSrcdocUrl(value) ? documentUri : value\n }\n })\n config.DocumentURL = documentUrl\n }\n // Registered before dokieli.js runs, so this precedes Dokieli's init.\n document.addEventListener('DOMContentLoaded', installDokieliHooks)\n window.addEventListener('load', installDokieliHooks)\n})()\n</script>`\n const cleanHtml = stripPreviewBridgeScripts(html) ?? html\n return withBaseHref(cleanHtml, uri).replace(/<head(\\s[^>]*)?>/i, match => `${match}${bridge}`)\n}\n\nfunction mountDokieliBridge (\n frame: HTMLIFrameElement,\n uri: string,\n html: string,\n authenticatedFetch: (url: string, init?: RequestInit) => Promise<Response>,\n webId: string | null = null\n): void {\n const ownerWindow = frame.ownerDocument.defaultView\n if (!ownerWindow) return\n\n const randomValues = new Uint32Array(4)\n ownerWindow.crypto.getRandomValues(randomValues)\n const nonce = Array.from(randomValues, value => value.toString(16)).join('-')\n const expectedUri = new URL(uri).href\n const listener = (event: MessageEvent<PreviewRequest>) => {\n const request = event.data\n if (\n event.source !== frame.contentWindow ||\n !request ||\n request.type !== PREVIEW_REQUEST_TYPE ||\n request.nonce !== nonce\n ) return\n\n const respond = (response: PreviewResponse) => {\n frame.contentWindow?.postMessage(response, '*')\n }\n\n // Always settle authenticated bridge requests. Dropping a denied request\n // leaves the preview awaiting it forever (Dokieli then never leaves Loading…).\n if (!isAllowedPreviewRequest(request.url, request.method, expectedUri, webId)) {\n respond({\n type: PREVIEW_RESPONSE_TYPE,\n nonce,\n id: request.id,\n ok: false,\n status: 403,\n headers: [],\n body: '',\n error: 'Request not permitted by the SolidOS preview'\n })\n return\n }\n const requestUrl = previewRequestUrl(request.url, expectedUri)\n\n authenticatedFetch(requestUrl, {\n method: request.method,\n headers: request.headers,\n body: PREVIEW_READ_METHODS.has(request.method)\n ? undefined\n : stripPreviewBridgeScripts(request.body)\n }).then(async response => {\n respond({\n type: PREVIEW_RESPONSE_TYPE,\n nonce,\n id: request.id,\n ok: response.ok,\n status: response.status,\n headers: Array.from(response.headers.entries()),\n body: await response.text()\n })\n }).catch(error => {\n respond({\n type: PREVIEW_RESPONSE_TYPE,\n nonce,\n id: request.id,\n ok: false,\n status: 0,\n headers: [],\n body: '',\n error: error instanceof Error ? error.message : String(error)\n })\n })\n }\n\n ownerWindow.addEventListener('message', listener)\n frame.setAttribute('sandbox', HTML_PREVIEW_SANDBOX)\n frame.srcdoc = createPreviewBridge(html, expectedUri, nonce, webId)\n}\n\nfunction installPreviewAutoSize (\n frame: HTMLIFrameElement,\n ownerWindow: Window\n): () => void {\n const onMessage = (event: MessageEvent<{ type?: string, height?: number }>) => {\n const message = event.data\n if (\n event.source !== frame.contentWindow ||\n message?.type !== 'solidos-preview-size' ||\n typeof message.height !== 'number' ||\n !Number.isFinite(message.height)\n ) return\n frame.style.height = `${Math.max(1, Math.ceil(message.height))}px`\n frame.style.flexShrink = '0'\n }\n ownerWindow.addEventListener('message', onMessage)\n return () => ownerWindow.removeEventListener('message', onMessage)\n}\n\nconst humanReadablePane: HumanReadablePaneDefinition = {\n icon: function (subject: NamedNode, context: DataBrowserContext): HumanReadableIcon {\n // Markdown files detected by extension\n if (subject && isMarkdownFile(subject.uri)) {\n return icons.iconBase + 'markdown.svg'\n }\n\n // Dokieli files detected by content check\n if (subject) {\n const kb = context.session.store\n\n // Check cache from previous detection\n const cachedResult = dokieliCache.get(subject.uri)\n if (cachedResult === 'dokieli') {\n return icons.iconBase + 'dokieli-logo.png'\n } else if (cachedResult === 'html') {\n return icons.originalIconBase + 'tango/22-text-x-generic.png'\n }\n\n // Check if content already fetched (synchronous)\n const responseText = kb.fetcher.getHeader(subject.doc(), 'content')\n if (responseText && responseText.length > 0) {\n const text = responseText[0]\n const isDokieli = text.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ||\n text.includes('dokieli.css')\n dokieliCache.set(subject.uri, isDokieli ? 'dokieli' : 'html')\n return isDokieli\n ? icons.iconBase + 'dokieli-logo.png'\n : icons.originalIconBase + 'tango/22-text-x-generic.png'\n }\n\n // Content not yet fetched - return a promise (async detection)\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0].split(';', 1)[0].trim() : null\n\n if (ct === 'text/html') {\n return kb.fetcher._fetch(subject.uri)\n .then(response => response.text())\n .then(text => {\n const isDokieli = text.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ||\n text.includes('dokieli.css')\n dokieliCache.set(subject.uri, isDokieli ? 'dokieli' : 'html')\n return isDokieli\n ? icons.iconBase + 'dokieli-logo.png'\n : icons.originalIconBase + 'tango/22-text-x-generic.png'\n })\n .catch(() => {\n dokieliCache.set(subject.uri, 'html')\n return icons.originalIconBase + 'tango/22-text-x-generic.png'\n })\n }\n }\n\n // Default for all other human-readable content\n return icons.originalIconBase + 'tango/22-text-x-generic.png'\n },\n\n name: 'humanReadable',\n\n label: function (\n subject: NamedNode,\n context: DataBrowserContext\n ): 'Webpage' | 'View' | null {\n const kb = context.session.store\n\n // See also the source pane, which has lower precedence.\n\n const allowed = [\n 'text/plain',\n 'text/html',\n 'text/markdown',\n 'application/json',\n 'application/xhtml+xml',\n 'application/pdf',\n 'video/mp4'\n ]\n\n const hasContentTypeIn = function (\n kb: typeof context.session.store,\n x: NamedNode,\n displayables: string[]\n ): boolean {\n const cts = kb.fetcher.getHeader(x, 'content-type')\n if (cts) {\n for (let j = 0; j < cts.length; j++) {\n for (let k = 0; k < displayables.length; k++) {\n if (cts[j].indexOf(displayables[k]) >= 0) {\n return true\n }\n }\n }\n }\n return false\n }\n\n // This data could come from a fetch OR from ldp container\n const hasContentTypeIn2 = function (\n kb: typeof context.session.store,\n x: NamedNode,\n displayables: string[]\n ): boolean {\n const t = kb.findTypeURIs(x)\n for (let k = 0; k < displayables.length; k++) {\n if (Util.mediaTypeClass(displayables[k]).uri in t) {\n return true\n }\n }\n return false\n }\n\n if (!subject.uri) return null // no bnodes\n\n const t = kb.findTypeURIs(subject)\n if (t[ns.link('WebPage').uri]) return 'Webpage'\n\n // Check file extension for markdown files\n if (isMarkdownFile(subject.uri)) {\n return 'View'\n }\n\n if (\n hasContentTypeIn(kb, subject, allowed) ||\n hasContentTypeIn2(kb, subject, allowed)\n ) {\n // For HTML files, check if it's dokieli (async check, store result for later)\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0].split(';', 1)[0].trim() : null\n\n if (ct === 'text/html' && !dokieliCache.has(subject.uri)) {\n // Async check for dokieli, don't wait for result\n kb.fetcher._fetch(subject.uri)\n .then(response => response.text())\n .then(text => {\n const isDokieli = text.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ||\n text.includes('dokieli.css')\n dokieliCache.set(subject.uri, isDokieli ? 'dokieli' : 'html')\n })\n .catch(() => {\n dokieliCache.set(subject.uri, 'html')\n })\n }\n\n return 'View'\n }\n\n return null\n },\n\n render: function (\n subject: NamedNode,\n context: DataBrowserContext\n ): HTMLDivElement {\n const myDocument = context.dom\n const div = myDocument.createElement('div')\n const kb = context.session.store\n\n function applyEnvironmentAttributes (element: HTMLDivElement): void {\n const environment = (context.environment ?? {}) as Partial<RenderEnvironment>\n element.dataset.layout = environment.layout ?? 'desktop'\n }\n\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0].split(';', 1)[0].trim() : null // remove content-type parameters\n\n // Fallback: detect markdown by file extension if content-type is not text/markdown\n const isMarkdown = ct === 'text/markdown' || isMarkdownFile(subject.uri)\n const isPlainText = ct === 'text/plain' || ct === 'application/json' || (!ct && isJsonFile(subject.uri))\n\n if (ct) {\n // console.log('humanReadablePane: c-t:' + ct)\n } else {\n console.log('humanReadablePane: unknown content-type?')\n }\n\n // @@ When we can, use CSP to turn off scripts within the iframe\n div.classList.add('human-readable-pane')\n applyEnvironmentAttributes(div)\n\n // render markdown to html in a DIV element\n const renderMarkdownContent = function (frame: HTMLDivElement) {\n kb.fetcher.webOperation('GET', subject.uri).then(response => {\n const markdownText = response.responseText ?? ''\n const lines = Math.min(30, markdownText.split(/\\n/).length + 5)\n const res = marked.parse(markdownText, { async: false })\n const clean = DOMPurify.sanitize(res)\n frame.innerHTML = clean\n applyFrameClasses(frame, 'markdown', lines)\n }).catch(error => {\n console.error('Error fetching markdown content:', error)\n frame.innerHTML = '<p>Error loading content</p>'\n })\n }\n\n // render plain text in a PRE element\n const renderPlainTextContent = function (frame: HTMLPreElement) {\n kb.fetcher.webOperation('GET', subject.uri).then(response => {\n const plainText = response.responseText ?? ''\n const lines = Math.min(30, plainText.split(/\\n/).length + 5)\n frame.textContent = plainText\n applyFrameClasses(frame, 'plain-text', lines)\n }).catch(error => {\n console.error('Error fetching plain text content:', error)\n frame.textContent = 'Error loading content'\n })\n }\n\n if (isMarkdown) {\n // For markdown, use a DIV element and render the content\n const frame = myDocument.createElement('div')\n renderMarkdownContent(frame)\n const frameContainer = myDocument.createElement('div')\n frameContainer.classList.add('human-readable-pane__container')\n frameContainer.appendChild(frame)\n div.appendChild(frameContainer)\n } else if (isPlainText) {\n // For plain text, use a PRE element and render the content\n const frame = myDocument.createElement('pre')\n renderPlainTextContent(frame)\n const frameContainer = myDocument.createElement('div')\n frameContainer.classList.add('human-readable-pane__container')\n frameContainer.appendChild(frame)\n div.appendChild(frameContainer)\n } else {\n // For other content types, use IFRAME.\n // The iframe's own request would be anonymous (Solid auth is not cookie based), so the\n // content is fetched with the authenticated fetcher and handed to the frame directly.\n const frame = myDocument.createElement('iframe')\n frame.name = HUMAN_READABLE_PREVIEW_FRAME_NAME\n frame.title = resourceFilename(subject.uri)\n applyFrameClasses(frame, 'iframe')\n const ownerWindow = myDocument.defaultView\n const removePreviewAutoSize = ownerWindow\n ? installPreviewAutoSize(frame, ownerWindow)\n : () => {}\n const isHtml = ct === 'text/html' || ct === 'application/xhtml+xml'\n let previewUrl: string | null = null\n let disposed = false\n let wasConnected = false\n const mutationObserver = typeof MutationObserver === 'undefined'\n ? null\n : new MutationObserver(records => {\n const wasAdded = records.some(record =>\n Array.from(record.addedNodes).some(node =>\n node === div || (node.nodeType === Node.ELEMENT_NODE && (node as Element).contains(div))\n )\n )\n if (div.isConnected) {\n wasConnected = true\n } else if (wasConnected || wasAdded) {\n disposed = true\n if (previewUrl) {\n URL.revokeObjectURL(previewUrl)\n previewUrl = null\n }\n removePreviewAutoSize()\n mutationObserver?.disconnect()\n }\n })\n mutationObserver?.observe(myDocument, { childList: true, subtree: true })\n\n const showError = (message: string) => {\n frame.removeAttribute('src')\n frame.setAttribute('sandbox', '')\n frame.srcdoc = `<p style=\"font-family: sans-serif\">${escapeAttribute(message)}</p>`\n }\n\n if (isHtml) {\n kb.fetcher.webOperation('GET', subject.uri).then(response => {\n const html = response.responseText ?? ''\n frame.title = documentTitle(html, subject.uri)\n const isDokieli = isDokieliHtml(html)\n dokieliCache.set(subject.uri, isDokieli ? 'dokieli' : 'html')\n if (isDokieli) {\n mountDokieliBridge(frame, subject.uri, html, (url, init) => kb.fetcher._fetch(url, init), viewerWebId())\n } else {\n frame.setAttribute('sandbox', HTML_PREVIEW_SANDBOX)\n frame.srcdoc = withPreviewResizeScript(withBaseHref(html, subject.uri))\n }\n }).catch(error => {\n console.error('Error fetching HTML content:', error)\n showError('Error loading content')\n })\n } else {\n kb.fetcher._fetch(subject.uri).then(async response => {\n if (!response.ok) throw new Error(`HTTP ${response.status}`)\n const responseContentType = response.headers.get('content-type')?.split(';', 1)[0].trim().toLowerCase()\n if (responseContentType === 'text/html' || responseContentType === 'application/xhtml+xml') {\n const html = await response.text()\n frame.title = documentTitle(html, subject.uri)\n const isDokieli = isDokieliHtml(html)\n dokieliCache.set(subject.uri, isDokieli ? 'dokieli' : 'html')\n if (isDokieli) {\n mountDokieliBridge(frame, subject.uri, html, (url, init) => kb.fetcher._fetch(url, init), viewerWebId())\n } else {\n frame.setAttribute('sandbox', HTML_PREVIEW_SANDBOX)\n frame.srcdoc = withPreviewResizeScript(withBaseHref(html, subject.uri))\n }\n return\n }\n if (responseContentType !== 'application/pdf') {\n frame.setAttribute('sandbox', HTML_PREVIEW_SANDBOX)\n }\n const objectUrl = URL.createObjectURL(await response.blob())\n if (disposed) {\n URL.revokeObjectURL(objectUrl)\n return\n }\n previewUrl = objectUrl\n frame.src = objectUrl\n }).catch(error => {\n console.error('Error fetching content:', error)\n showError('Error loading content')\n })\n }\n\n const frameContainer = myDocument.createElement('div')\n frameContainer.classList.add('human-readable-pane__container')\n frameContainer.classList.add('human-readable-pane__container--iframe')\n frameContainer.appendChild(frame)\n div.appendChild(frameContainer)\n div.classList.add('human-readable-pane--iframe')\n }\n\n return div\n }\n}\n\nexport default humanReadablePane\n// ends\n"],"mappings":"A,8NAcA,SAASW,GAA8B,CACrC,GAAI,CACF,OAAOX,EAAAA,MAAM,YAAY,CAAC,EAAE,OAAS,IACvC,MAAQ,CACN,OAAO,IACT,CACF,CAcA,IAAMY,EAAkB,GAAiC,CACvD,GAAI,CAACC,EAAK,MAAO,GACjB,IAAMC,EAAOD,EAAI,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAC1C,MAAO,mCAAmC,KAAKC,CAAI,CACrD,EAEMC,EAAc,GAAiC,CACnD,GAAI,CAACF,EAAK,MAAO,GACjB,IAAMC,EAAOD,EAAI,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAC1C,MAAO,WAAW,KAAKC,CAAI,CAC7B,EAGME,EAAe,IAAI,IAEzB,SAASC,EACP,EACA,EACA,EACM,CACN,EAAM,UAAY,GAClBC,EAAM,UAAU,IAAI,4BAA4B,EAChDA,EAAM,UAAU,IAAI,+BAA+BC,GAAU,EACzDC,IAAU,IAAA,IACZF,EAAM,MAAM,YAAY,+BAAgC,GAAGE,EAAQ,GAAG,GAAG,CAE7E,CAGA,IAAaC,EAAoC,iCAG3CC,EAAuB,qFAE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