solid-panes 3.6.2 → 3.6.3-c7f6db53

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.
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <coverage generated="1738750340295" clover="3.2.0">
3
- <project timestamp="1738750340295" name="All files">
2
+ <coverage generated="1739473574993" clover="3.2.0">
3
+ <project timestamp="1739473574994" name="All files">
4
4
  <metrics statements="125" coveredstatements="125" conditionals="6" coveredconditionals="4" methods="13" coveredmethods="13" elements="144" coveredelements="142" complexity="0" loc="125" ncloc="125" packages="2" files="5" classes="5"/>
5
5
  <package name="outline">
6
6
  <metrics statements="112" coveredstatements="112" conditionals="6" coveredconditionals="4" methods="7" coveredmethods="7"/>
@@ -116,7 +116,7 @@
116
116
  <div class='footer quiet pad2 space-top1 center small'>
117
117
  Code coverage generated by
118
118
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
119
- at 2025-02-05T10:12:20.286Z
119
+ at 2025-02-13T19:06:14.984Z
120
120
  </div>
121
121
  <script src="prettify.js"></script>
122
122
  <script>
@@ -146,7 +146,7 @@
146
146
  <div class='footer quiet pad2 space-top1 center small'>
147
147
  Code coverage generated by
148
148
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
149
- at 2025-02-05T10:12:20.286Z
149
+ at 2025-02-13T19:06:14.984Z
150
150
  </div>
151
151
  <script src="../prettify.js"></script>
152
152
  <script>
@@ -550,7 +550,7 @@ outlineIcons.termWidgets.addTri = new outlineIcons.OutlinerIcon(
550
550
  <div class='footer quiet pad2 space-top1 center small'>
551
551
  Code coverage generated by
552
552
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
553
- at 2025-02-05T10:12:20.286Z
553
+ at 2025-02-13T19:06:14.984Z
554
554
  </div>
555
555
  <script src="../prettify.js"></script>
556
556
  <script>
@@ -181,7 +181,7 @@ export function viewsAddPropertyView (views, property, pviewfunc, isDefault) {
181
181
  <div class='footer quiet pad2 space-top1 center small'>
182
182
  Code coverage generated by
183
183
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
184
- at 2025-02-05T10:12:20.286Z
184
+ at 2025-02-13T19:06:14.984Z
185
185
  </div>
186
186
  <script src="../prettify.js"></script>
187
187
  <script>
@@ -106,7 +106,7 @@ export default (dom) =&gt; function viewAsImage (obj) {
106
106
  <div class='footer quiet pad2 space-top1 center small'>
107
107
  Code coverage generated by
108
108
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
109
- at 2025-02-05T10:12:20.286Z
109
+ at 2025-02-13T19:06:14.984Z
110
110
  </div>
111
111
  <script src="../prettify.js"></script>
112
112
  <script>
@@ -112,7 +112,7 @@
112
112
  <div class='footer quiet pad2 space-top1 center small'>
113
113
  Code coverage generated by
114
114
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
115
- at 2025-02-05T10:12:20.286Z
115
+ at 2025-02-13T19:06:14.984Z
116
116
  </div>
117
117
  <script src="../prettify.js"></script>
118
118
  <script>
@@ -101,7 +101,7 @@
101
101
  <div class='footer quiet pad2 space-top1 center small'>
102
102
  Code coverage generated by
103
103
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
104
- at 2025-02-05T10:12:20.286Z
104
+ at 2025-02-13T19:06:14.984Z
105
105
  </div>
106
106
  <script src="../prettify.js"></script>
107
107
  <script>
@@ -223,7 +223,7 @@ export function generateRandomString () {
223
223
  <div class='footer quiet pad2 space-top1 center small'>
224
224
  Code coverage generated by
225
225
  <a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
226
- at 2025-02-05T10:12:20.286Z
226
+ at 2025-02-13T19:06:14.984Z
227
227
  </div>
228
228
  <script src="../prettify.js"></script>
229
229
  <script>
@@ -0,0 +1,34 @@
1
+ import typescriptEslint from "@typescript-eslint/eslint-plugin";
2
+ import globals from "globals";
3
+ import tsParser from "@typescript-eslint/parser";
4
+
5
+ export default [{
6
+ ignores: ["**/dist", "**/lib", "typings/rdflib"],
7
+ }, {
8
+ plugins: {
9
+ "@typescript-eslint": typescriptEslint,
10
+ },
11
+
12
+ languageOptions: {
13
+ globals: {
14
+ ...globals.browser,
15
+ ...globals.node,
16
+ Atomics: "readonly",
17
+ SharedArrayBuffer: "readonly",
18
+ },
19
+
20
+ parser: tsParser,
21
+ },
22
+ files: ["src/**/*.js", "src/**/*.ts", "src/**/*.cjs", "src/**/*.mjs"],
23
+ rules: {
24
+ "no-unused-vars": ["warn", {
25
+ argsIgnorePattern: "^_",
26
+ varsIgnorePattern: "^_",
27
+ }],
28
+
29
+ "@typescript-eslint/no-unused-vars": ["warn", {
30
+ argsIgnorePattern: "^_",
31
+ varsIgnorePattern: "^_",
32
+ }],
33
+ },
34
+ }];
@@ -53,7 +53,7 @@ var _default = exports["default"] = {
53
53
 
54
54
  // This data coul d come from a fetch OR from ldp comtaimner
55
55
  var hasContentTypeIn2 = function hasContentTypeIn2(kb, x, displayables) {
56
- var t = kb.findTypeURIs(subject);
56
+ var t = kb.findTypeURIs(x);
57
57
  for (var k = 0; k < displayables.length; k++) {
58
58
  if ($rdf.Util.mediaTypeClass(displayables[k]).uri in t) {
59
59
  return true;
@@ -119,38 +119,52 @@ var _default = exports["default"] = {
119
119
  div.setAttribute('class', 'docView');
120
120
  var iframe = myDocument.createElement('IFRAME');
121
121
 
122
- // get with authenticated fetch
123
- kb.fetcher._fetch(subject.uri).then(function (response) {
124
- return response.blob();
125
- }).then(function (blob) {
122
+ // Function to set iframe attributes
123
+ var setIframeAttributes = function setIframeAttributes(iframe, blob, lines) {
126
124
  var objectURL = URL.createObjectURL(blob);
127
- iframe.setAttribute('src', objectURL); // w640 h480 //
125
+ iframe.setAttribute('src', objectURL);
128
126
  iframe.setAttribute('type', blob.type);
129
127
  iframe.setAttribute('class', 'doc');
130
- return blob.text();
131
- }).then(function (blobText) {
128
+ iframe.setAttribute('style', "border: 1px solid; padding: 1em; height:".concat(lines, "em; width:800px; resize: both; overflow: auto;"));
129
+
130
+ // Apply sandbox attribute only for HTML files
131
+ // @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
132
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
133
+ // You can;'t have any sandbox and allow plugins.
134
+ // We could sandbox only HTML files I suppose.
135
+ // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
136
+ if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {
137
+ iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
138
+ }
139
+ };
140
+
141
+ // Fetch and process the blob
142
+ kb.fetcher._fetch(subject.uri).then(function (response) {
143
+ return response.blob();
144
+ }).then(function (blob) {
145
+ var blobTextPromise = blob.type.startsWith('text') ? blob.text() : Promise.resolve('');
146
+ return blobTextPromise.then(function (blobText) {
147
+ return {
148
+ blob: blob,
149
+ blobText: blobText
150
+ };
151
+ });
152
+ }).then(function (_ref) {
153
+ var blob = _ref.blob,
154
+ blobText = _ref.blobText;
132
155
  var newLines = blobText.includes('<script src="https://dokie.li/scripts/dokieli.js">') ? -10 : 5;
133
156
  var lines = Math.min(30, blobText.split(/\n/).length + newLines);
134
- iframe.setAttribute('style', "border: 1px solid; padding: 1em; height:".concat(lines, "em; width:800px; resize: both; overflow: auto;"));
157
+ setIframeAttributes(iframe, blob, lines);
135
158
  })["catch"](function (err) {
136
- console.log(err);
159
+ console.log('Error fetching or processing blob:', err);
137
160
  });
138
161
  var cts = kb.fetcher.getHeader(subject.doc(), 'content-type');
139
- var ct = cts ? cts[0] : null;
162
+ var ct = cts ? cts[0].split(';', 1)[0].trim() : null;
140
163
  if (ct) {
141
164
  console.log('dokieliPane: c-t:' + ct);
142
165
  } else {
143
166
  console.log('dokieliPane: unknown content-type?');
144
167
  }
145
-
146
- // @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
147
- // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
148
- // You can;'t have any sandbox and allow plugins.
149
- // We could sandbox only HTML files I suppose.
150
- // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
151
-
152
- // iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static
153
-
154
168
  var tr = myDocument.createElement('tr');
155
169
  tr.appendChild(iframe);
156
170
  div.appendChild(tr);
@@ -1 +1 @@
1
- {"version":3,"file":"dokieliPane.js","names":["UI","_interopRequireWildcard","require","$rdf","mime","_new","_interopRequireDefault","e","__esModule","_getRequireWildcardCache","WeakMap","r","t","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_default","exports","icon","icons","iconBase","name","mintClass","ns","solid","label","subject","context","kb","session","store","allowed","hasContentTypeIn","x","displayables","cts","fetcher","getHeader","j","length","k","indexOf","hasContentTypeIn2","findTypeURIs","Util","mediaTypeClass","uri","link","mintNew","newPaneOptions","newInstance","newBase","endsWith","slice","sym","contentType","lookup","includes","htmlContents","DOKIELI_TEMPLATE","filename","split","decodeURIComponent","encodedTitle","replace","Promise","resolve","webOperation","data","then","console","log","err","render","myDocument","dom","div","createElement","setAttribute","iframe","_fetch","response","blob","objectURL","URL","createObjectURL","type","text","blobText","newLines","lines","Math","min","concat","doc","ct","tr","appendChild"],"sources":["../../src/dokieli/dokieliPane.js"],"sourcesContent":["/* Human-readable editable \"Dokieli\" Pane\n **\n ** This outline pane contains the document contents for a Dokieli document\n ** The dokeili system allows the user to edit a document including anotations\n ** review. It does not use turtle, but RDF/a\n */\n\nimport * as UI from 'solid-ui'\nimport * as $rdf from 'rdflib'\nimport * as mime from 'mime-types'\n\n// const DOKIELI_TEMPLATE_URI = 'https://dokie.li/new' // Copy to make new dok\n\nimport DOKIELI_TEMPLATE from './new.js' // Distributed with this library\n\nexport default {\n icon: UI.icons.iconBase + 'dokieli-logo.png', // @@ improve? more like doccument?\n\n name: 'Dokieli',\n\n mintClass: UI.ns.solid('DokieliDocument'), // @@ A better class?\n\n label: function (subject, context) {\n const kb = context.session.store\n const ns = UI.ns\n const allowed = [\n // 'text/plain',\n 'text/html',\n 'application/xhtml+xml'\n // 'image/png', 'image/jpeg', 'application/pdf',\n // 'video/mp4'\n ]\n\n const hasContentTypeIn = function (kb, x, displayables) {\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 coul d come from a fetch OR from ldp comtaimner\n const hasContentTypeIn2 = function (kb, x, displayables) {\n const t = kb.findTypeURIs(subject)\n for (let k = 0; k < displayables.length; k++) {\n if ($rdf.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 'view'\n\n if (\n hasContentTypeIn(kb, subject, allowed) ||\n hasContentTypeIn2(kb, subject, allowed)\n ) {\n return 'Dok'\n }\n\n return null\n },\n\n // Create a new folder in a Solid system, with a dokieli editable document in it\n mintNew: function (context, newPaneOptions) {\n const kb = context.session.store\n let newInstance = newPaneOptions.newInstance\n if (!newInstance) {\n let uri = newPaneOptions.newBase\n if (uri.endsWith('/')) {\n uri = uri.slice(0, -1)\n newPaneOptions.newBase = uri\n }\n newInstance = kb.sym(uri)\n }\n\n const contentType = mime.lookup(newInstance.uri)\n if (!contentType || !contentType.includes('html')) {\n newInstance = $rdf.sym(newInstance.uri + '.html')\n }\n newPaneOptions.newInstance = newInstance // Save for creation system\n\n // console.log('New dokieli will make: ' + newInstance)\n\n let htmlContents = DOKIELI_TEMPLATE\n let filename = newInstance.uri.split('/').slice(-1)[0]\n filename = decodeURIComponent(filename.split('.')[0])\n const encodedTitle = filename\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n htmlContents = htmlContents.replace('<title>', '<title>' + encodedTitle)\n htmlContents = htmlContents.replace(\n '</article>',\n '<h1>' + encodedTitle + '</h1></article>'\n )\n // console.log('@@ New HTML for Dok:' + htmlContents)\n return new Promise(function (resolve) {\n kb.fetcher\n .webOperation('PUT', newInstance.uri, {\n data: htmlContents,\n contentType: 'text/html'\n })\n .then(function () {\n console.log(\n 'new Dokieli document created at ' + newPaneOptions.newInstance\n )\n resolve(newPaneOptions)\n })\n .catch(function (err) {\n console.log(\n 'Error creating dokieli doc at ' +\n newPaneOptions.newInstance +\n ': ' +\n err\n )\n })\n })\n },\n\n // Derived from: humanReadablePane .. share code?\n render: function (subject, context) {\n const myDocument = context.dom\n const div = myDocument.createElement('div')\n const kb = context.session.store\n\n // @@ When we can, use CSP to turn off scripts within the iframe\n div.setAttribute('class', 'docView')\n const iframe = myDocument.createElement('IFRAME')\n\n // get with authenticated fetch\n kb.fetcher._fetch(subject.uri)\n .then(function(response) {\n return response.blob()\n })\n .then(function(blob) {\n const objectURL = URL.createObjectURL(blob)\n iframe.setAttribute('src', objectURL) // w640 h480 //\n iframe.setAttribute('type', blob.type)\n iframe.setAttribute('class', 'doc')\n return blob.text()\n })\n .then(function(blobText) {\n const newLines = blobText.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ? -10 : 5\n const lines = Math.min(30, blobText.split(/\\n/).length + newLines)\n iframe.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)\n })\n .catch(err => { console.log(err) })\n\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0] : null\n if (ct) {\n console.log('dokieliPane: c-t:' + ct)\n } else {\n console.log('dokieliPane: unknown content-type?')\n }\n\n // @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n // You can;'t have any sandbox and allow plugins.\n // We could sandbox only HTML files I suppose.\n // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html\n\n // iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static\n\n const tr = myDocument.createElement('tr')\n tr.appendChild(iframe)\n div.appendChild(tr)\n return div\n }\n}\n// ends\n"],"mappings":";;;;;;;AAOA,IAAAA,EAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,uBAAA,CAAAC,OAAA;AAIA,IAAAG,IAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAuC,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAAA,SAAAE,yBAAAF,CAAA,6BAAAG,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,yBAAAF,CAAA,WAAAA,CAAA,GAAAK,CAAA,GAAAD,CAAA,KAAAJ,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAI,CAAA,SAAAA,CAAA,IAAAJ,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,gBAAAM,OAAA,CAAAN,CAAA,0BAAAA,CAAA,sBAAAA,CAAA,QAAAK,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAE,GAAA,CAAAP,CAAA,UAAAK,CAAA,CAAAG,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA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C;IACnB,OAAOpB,GAAG;EACZ;AACF,CAAC,EACD","ignoreList":[]}
1
+ {"version":3,"file":"dokieliPane.js","names":["UI","_interopRequireWildcard","require","$rdf","mime","_new","_interopRequireDefault","e","__esModule","_getRequireWildcardCache","WeakMap","r","t","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_default","exports","icon","icons","iconBase","name","mintClass","ns","solid","label","subject","context","kb","session","store","allowed","hasContentTypeIn","x","displayables","cts","fetcher","getHeader","j","length","k","indexOf","hasContentTypeIn2","findTypeURIs","Util","mediaTypeClass","uri","link","mintNew","newPaneOptions","newInstance","newBase","endsWith","slice","sym","contentType","lookup","includes","htmlContents","DOKIELI_TEMPLATE","filename","split","decodeURIComponent","encodedTitle","replace","Promise","resolve","webOperation","data","then","console","log","err","render","myDocument","dom","div","createElement","setAttribute","iframe","setIframeAttributes","blob","lines","objectURL","URL","createObjectURL","type","concat","_fetch","response","blobTextPromise","startsWith","text","blobText","_ref","newLines","Math","min","doc","ct","trim","tr","appendChild"],"sources":["../../src/dokieli/dokieliPane.js"],"sourcesContent":["/* Human-readable editable \"Dokieli\" Pane\n **\n ** This outline pane contains the document contents for a Dokieli document\n ** The dokeili system allows the user to edit a document including anotations\n ** review. It does not use turtle, but RDF/a\n */\n\nimport * as UI from 'solid-ui'\nimport * as $rdf from 'rdflib'\nimport * as mime from 'mime-types'\n\n// const DOKIELI_TEMPLATE_URI = 'https://dokie.li/new' // Copy to make new dok\n\nimport DOKIELI_TEMPLATE from './new.js' // Distributed with this library\n\nexport default {\n icon: UI.icons.iconBase + 'dokieli-logo.png', // @@ improve? more like doccument?\n\n name: 'Dokieli',\n\n mintClass: UI.ns.solid('DokieliDocument'), // @@ A better class?\n\n label: function (subject, context) {\n const kb = context.session.store\n const ns = UI.ns\n const allowed = [\n // 'text/plain',\n 'text/html',\n 'application/xhtml+xml'\n // 'image/png', 'image/jpeg', 'application/pdf',\n // 'video/mp4'\n ]\n\n const hasContentTypeIn = function (kb, x, displayables) {\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 coul d come from a fetch OR from ldp comtaimner\n const hasContentTypeIn2 = function (kb, x, displayables) {\n const t = kb.findTypeURIs(x)\n for (let k = 0; k < displayables.length; k++) {\n if ($rdf.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 'view'\n\n if (\n hasContentTypeIn(kb, subject, allowed) ||\n hasContentTypeIn2(kb, subject, allowed)\n ) {\n return 'Dok'\n }\n\n return null\n },\n\n // Create a new folder in a Solid system, with a dokieli editable document in it\n mintNew: function (context, newPaneOptions) {\n const kb = context.session.store\n let newInstance = newPaneOptions.newInstance\n if (!newInstance) {\n let uri = newPaneOptions.newBase\n if (uri.endsWith('/')) {\n uri = uri.slice(0, -1)\n newPaneOptions.newBase = uri\n }\n newInstance = kb.sym(uri)\n }\n\n const contentType = mime.lookup(newInstance.uri)\n if (!contentType || !contentType.includes('html')) {\n newInstance = $rdf.sym(newInstance.uri + '.html')\n }\n newPaneOptions.newInstance = newInstance // Save for creation system\n\n // console.log('New dokieli will make: ' + newInstance)\n\n let htmlContents = DOKIELI_TEMPLATE\n let filename = newInstance.uri.split('/').slice(-1)[0]\n filename = decodeURIComponent(filename.split('.')[0])\n const encodedTitle = filename\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n htmlContents = htmlContents.replace('<title>', '<title>' + encodedTitle)\n htmlContents = htmlContents.replace(\n '</article>',\n '<h1>' + encodedTitle + '</h1></article>'\n )\n // console.log('@@ New HTML for Dok:' + htmlContents)\n return new Promise(function (resolve) {\n kb.fetcher\n .webOperation('PUT', newInstance.uri, {\n data: htmlContents,\n contentType: 'text/html'\n })\n .then(function () {\n console.log(\n 'new Dokieli document created at ' + newPaneOptions.newInstance\n )\n resolve(newPaneOptions)\n })\n .catch(function (err) {\n console.log(\n 'Error creating dokieli doc at ' +\n newPaneOptions.newInstance +\n ': ' +\n err\n )\n })\n })\n },\n\n // Derived from: humanReadablePane .. share code?\n render: function (subject, context) {\n const myDocument = context.dom\n const div = myDocument.createElement('div')\n const kb = context.session.store\n\n // @@ When we can, use CSP to turn off scripts within the iframe\n div.setAttribute('class', 'docView')\n const iframe = myDocument.createElement('IFRAME')\n\n // Function to set iframe attributes\n const setIframeAttributes = (iframe, blob, lines) => {\n const objectURL = URL.createObjectURL(blob)\n iframe.setAttribute('src', objectURL)\n iframe.setAttribute('type', blob.type)\n iframe.setAttribute('class', 'doc')\n iframe.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)\n\n // Apply sandbox attribute only for HTML files\n // @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n // You can;'t have any sandbox and allow plugins.\n // We could sandbox only HTML files I suppose.\n // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html\n if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {\n iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin')\n }\n }\n\n // Fetch and process the blob\n kb.fetcher._fetch(subject.uri)\n .then(response => response.blob())\n .then(blob => {\n const blobTextPromise = blob.type.startsWith('text') ? blob.text() : Promise.resolve('')\n return blobTextPromise.then(blobText => ({ blob, blobText }))\n })\n .then(({ blob, blobText }) => {\n const newLines = blobText.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ? -10 : 5\n const lines = Math.min(30, blobText.split(/\\n/).length + newLines)\n setIframeAttributes(iframe, blob, lines)\n })\n .catch(err => {\n console.log('Error fetching or processing blob:', err)\n })\n\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0].split(';', 1)[0].trim() : null\n if (ct) {\n console.log('dokieliPane: c-t:' + ct)\n } else {\n console.log('dokieliPane: unknown content-type?')\n }\n\n const tr = myDocument.createElement('tr')\n tr.appendChild(iframe)\n div.appendChild(tr)\n return div\n }\n}\n// ends\n"],"mappings":";;;;;;;AAOA,IAAAA,EAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,uBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,uBAAA,CAAAC,OAAA;AAIA,IAAAG,IAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAuC,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AAAA,SAAAE,yBAAAF,CAAA,6BAAAG,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,yBAAAF,CAAA,WAAAA,CAAA,GAAAK,CAAA,GAAAD,CAAA,KAAAJ,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAI,CAAA,SAAAA,CAAA,IAAAJ,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,gBAAAM,OAAA,CAAAN,CAAA,0BAAAA,CAAA,sBAAAA,CAAA,QAAAK,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAE,GAAA,CAAAP,CAAA,UAAAK,CAAA,CAAAG,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAe,CAAA,SAAAG,CAAA,GA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AAC;IAC1C,CAAC,CAAC,SACI,CAAC,UAAAV,GAAG,EAAI;MACZF,OAAO,CAACC,GAAG,CAAC,oCAAoC,EAAEC,GAAG,CAAC;IACxD,CAAC,CAAC;IAEJ,IAAMrC,GAAG,GAAGP,EAAE,CAACQ,OAAO,CAACC,SAAS,CAACX,OAAO,CAACwE,GAAG,CAAC,CAAC,EAAE,cAAc,CAAC;IAC/D,IAAMC,EAAE,GAAGhE,GAAG,GAAGA,GAAG,CAAC,CAAC,CAAC,CAAC0B,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAACuC,IAAI,CAAC,CAAC,GAAG,IAAI;IACtD,IAAID,EAAE,EAAE;MACN7B,OAAO,CAACC,GAAG,CAAC,mBAAmB,GAAG4B,EAAE,CAAC;IACvC,CAAC,MAAM;MACL7B,OAAO,CAACC,GAAG,CAAC,oCAAoC,CAAC;IACnD;IAED,IAAM8B,EAAE,GAAG3B,UAAU,CAACG,aAAa,CAAC,IAAI,CAAC;IACxCwB,EAAE,CAACC,WAAW,CAACvB,MAAM,CAAC;IACtBH,GAAG,CAAC0B,WAAW,CAACD,EAAE,CAAC;IACnB,OAAOzB,GAAG;EACZ;AACF,CAAC,EACD","ignoreList":[]}
@@ -40,7 +40,7 @@ var humanReadablePane = {
40
40
 
41
41
  // This data could come from a fetch OR from ldp container
42
42
  var hasContentTypeIn2 = function hasContentTypeIn2(kb, x, displayables) {
43
- var t = kb.findTypeURIs(subject);
43
+ var t = kb.findTypeURIs(x);
44
44
  for (var k = 0; k < displayables.length; k++) {
45
45
  if (_rdflib.Util.mediaTypeClass(displayables[k]).uri in t) {
46
46
  return true;
@@ -62,7 +62,7 @@ var humanReadablePane = {
62
62
  var div = myDocument.createElement('div');
63
63
  var kb = context.session.store;
64
64
  var cts = kb.fetcher.getHeader(subject.doc(), 'content-type');
65
- var ct = cts ? cts[0] : null;
65
+ var ct = cts ? cts[0].split(';', 1)[0].trim() : null; // remove content-type parameters
66
66
  if (ct) {
67
67
  // console.log('humanReadablePane: c-t:' + ct)
68
68
  } else {
@@ -73,6 +73,21 @@ var humanReadablePane = {
73
73
  div.setAttribute('class', 'docView');
74
74
  var element = ct === 'text/markdown' ? 'DIV' : 'IFRAME';
75
75
  var frame = myDocument.createElement(element);
76
+ var setIframeAttributes = function setIframeAttributes(frame, blob, lines) {
77
+ frame.setAttribute('src', URL.createObjectURL(blob));
78
+ frame.setAttribute('type', blob.type);
79
+ frame.setAttribute('class', 'doc');
80
+ frame.setAttribute('style', "border: 1px solid; padding: 1em; height: ".concat(lines, "em; width: 800px; resize: both; overflow: auto;"));
81
+
82
+ // Apply sandbox attribute only for HTML files
83
+ // @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
84
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
85
+ // You can't have any sandbox and allow plugins.
86
+ // We could sandbox only HTML files I suppose.
87
+ if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {
88
+ frame.setAttribute('sandbox', 'allow-scripts allow-same-origin');
89
+ }
90
+ };
76
91
 
77
92
  // render markdown to html
78
93
  var markdownHtml = function markdownHtml() {
@@ -84,35 +99,35 @@ var humanReadablePane = {
84
99
  frame.innerHTML = clean;
85
100
  frame.setAttribute('class', 'doc');
86
101
  frame.setAttribute('style', "border: 1px solid; padding: 1em; height: ".concat(lines, "em; width: 800px; resize: both; overflow: auto;"));
102
+ })["catch"](function (error) {
103
+ console.error('Error fetching markdown content:', error);
104
+ frame.innerHTML = '<p>Error loading content</p>';
87
105
  });
88
106
  };
89
107
  if (ct === 'text/markdown') {
90
108
  markdownHtml();
91
109
  } else {
92
- // get with authenticated fetch
110
+ // Fetch and process the blob
93
111
  kb.fetcher._fetch(subject.uri).then(function (response) {
94
112
  return response.blob();
95
113
  }).then(function (blob) {
96
- var objectURL = URL.createObjectURL(blob);
97
- frame.setAttribute('src', objectURL);
98
- frame.setAttribute('type', blob.type);
99
- frame.setAttribute('class', 'doc');
100
- return blob.type.startsWith('text') ? blob.text() : '';
101
- }).then(function (blobText) {
114
+ var blobTextPromise = blob.type.startsWith('text') ? blob.text() : Promise.resolve('');
115
+ return blobTextPromise.then(function (blobText) {
116
+ return {
117
+ blob: blob,
118
+ blobText: blobText
119
+ };
120
+ });
121
+ }).then(function (_ref) {
122
+ var blob = _ref.blob,
123
+ blobText = _ref.blobText;
102
124
  var newLines = blobText.includes('<script src="https://dokie.li/scripts/dokieli.js">') ? -10 : 5;
103
125
  var lines = Math.min(30, blobText.split(/\n/).length + newLines);
104
- frame.setAttribute('style', "border: 1px solid; padding: 1em; height:".concat(lines, "em; width:800px; resize: both; overflow: auto;"));
126
+ setIframeAttributes(frame, blob, lines);
127
+ })["catch"](function (err) {
128
+ console.log('Error fetching or processing blob:', err);
105
129
  });
106
130
  }
107
-
108
- // @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
109
- // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
110
- // You can't have any sandbox and allow plugins.
111
- // We could sandbox only HTML files I suppose.
112
- // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
113
-
114
- // iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static
115
-
116
131
  var tr = myDocument.createElement('TR');
117
132
  tr.appendChild(frame);
118
133
  div.appendChild(tr);
@@ -1 +1 @@
1
- {"version":3,"file":"humanReadablePane.js","names":["_solidUi","require","_rdflib","_marked","_dompurify","_interopRequireDefault","e","__esModule","humanReadablePane","icon","icons","originalIconBase","name","label","subject","context","kb","session","store","allowed","hasContentTypeIn","x","displayables","cts","fetcher","getHeader","j","length","k","indexOf","hasContentTypeIn2","t","findTypeURIs","Util","mediaTypeClass","uri","ns","link","render","myDocument","dom","div","createElement","doc","ct","console","log","setAttribute","element","frame","markdownHtml","webOperation","then","response","markdownText","responseText","lines","Math","min","split","res","marked","parse","clean","DOMPurify","sanitize","innerHTML","concat","_fetch","blob","objectURL","URL","createObjectURL","type","startsWith","text","blobText","newLines","includes","tr","appendChild","_default","exports"],"sources":["../src/humanReadablePane.js"],"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';\n\nconst humanReadablePane = {\n icon: icons.originalIconBase + 'tango/22-text-x-generic.png',\n\n name: 'humanReadable',\n\n label: function (subject, context) {\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 'image/png',\n 'image/jpeg',\n 'application/pdf',\n 'video/mp4'\n ]\n\n const hasContentTypeIn = function (kb, x, displayables) {\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 (kb, x, displayables) {\n const t = kb.findTypeURIs(subject)\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 'view'\n\n if (\n hasContentTypeIn(kb, subject, allowed) ||\n hasContentTypeIn2(kb, subject, allowed)\n ) {\n return 'View'\n }\n\n return null\n },\n\n render: function (subject, context) {\n const myDocument = context.dom\n const div = myDocument.createElement('div')\n const kb = context.session.store\n\n const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')\n const ct = cts ? cts[0] : null\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.setAttribute('class', 'docView')\n const element = ct === 'text/markdown' ? 'DIV' : 'IFRAME'\n const frame = myDocument.createElement(element)\n\n // render markdown to html\n const markdownHtml = function () {\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)\n const clean = DOMPurify.sanitize(res)\n frame.innerHTML = clean\n frame.setAttribute('class', 'doc')\n frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 800px; resize: both; overflow: auto;`)\n })\n }\n\n if (ct === 'text/markdown') {\n markdownHtml()\n } else {\n // get with authenticated fetch\n kb.fetcher._fetch(subject.uri)\n .then(function(response) {\n return response.blob()\n })\n .then(function(blob) {\n const objectURL = URL.createObjectURL(blob)\n frame.setAttribute('src', objectURL)\n frame.setAttribute('type', blob.type)\n frame.setAttribute('class', 'doc')\n return blob.type.startsWith('text') ? blob.text() : ''\n })\n .then(function(blobText) {\n const newLines = blobText.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ? -10 : 5\n const lines = Math.min(30, blobText.split(/\\n/).length + newLines)\n frame.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)\n })\n }\n\n // @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n // You can't have any sandbox and allow plugins.\n // We could sandbox only HTML files I suppose.\n // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html\n\n // iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static\n\n const tr = myDocument.createElement('TR')\n tr.appendChild(frame)\n div.appendChild(tr)\n return div\n }\n}\n\nexport default humanReadablePane\n// ends\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA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AAMC,SAAS,GAAGC,GAAG,CAACC,eAAe,CAACH,IAAI,CAAC;QAC3CpB,KAAK,CAACF,YAAY,CAAC,KAAK,EAAEuB,SAAS,CAAC;QACpCrB,KAAK,CAACF,YAAY,CAAC,MAAM,EAAEsB,IAAI,CAACI,IAAI,CAAC;QACrCxB,KAAK,CAACF,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC;QAClC,OAAOsB,IAAI,CAACI,IAAI,CAACC,UAAU,CAAC,MAAM,CAAC,GAAGL,IAAI,CAACM,IAAI,CAAC,CAAC,GAAG,EAAE;MACxD,CAAC,CAAC,CACDvB,IAAI,CAAC,UAASwB,QAAQ,EAAE;QACvB,IAAMC,QAAQ,GAAGD,QAAQ,CAACE,QAAQ,CAAC,oDAAoD,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;QAClG,IAAMtB,KAAK,GAAGC,IAAI,CAACC,GAAG,CAAC,EAAE,EAAEkB,QAAQ,CAACjB,KAAK,CAAC,IAAI,CAAC,CAAChC,MAAM,GAAGkD,QAAQ,CAAC;QAClE5B,KAAK,CAACF,YAAY,CAAC,OAAO,6CAAAoB,MAAA,CAA6CX,KAAK,mDAAgD,CAAC;MAC/H,CAAC,CAAC;IACN;;IAEA;IACA;IACA;IACA;IACA;;IAEA;;IAEA,IAAMuB,EAAE,GAAGxC,UAAU,CAACG,aAAa,CAAC,IAAI,CAAC;IACzCqC,EAAE,CAACC,WAAW,CAAC/B,KAAK,CAAC;IACrBR,GAAG,CAACuC,WAAW,CAACD,EAAE,CAAC;IACnB,OAAOtC,GAAG;EACZ;AACF,CAAC;AAAA,IAAAwC,QAAA,GAAAC,OAAA,cAEc1E,iBAAiB,EAChC","ignoreList":[]}
1
+ {"version":3,"file":"humanReadablePane.js","names":["_solidUi","require","_rdflib","_marked","_dompurify","_interopRequireDefault","e","__esModule","humanReadablePane","icon","icons","originalIconBase","name","label","subject","context","kb","session","store","allowed","hasContentTypeIn","x","displayables","cts","fetcher","getHeader","j","length","k","indexOf","hasContentTypeIn2","t","findTypeURIs","Util","mediaTypeClass","uri","ns","link","render","myDocument","dom","div","createElement","doc","ct","split","trim","console","log","setAttribute","element","frame","setIframeAttributes","blob","lines","URL","createObjectURL","type","concat","markdownHtml","webOperation","then","response","markdownText","responseText","Math","min","res","marked","parse","clean","DOMPurify","sanitize","innerHTML","error","_fetch","blobTextPromise","startsWith","text","Promise","resolve","blobText","_ref","newLines","includes","err","tr","appendChild","_default","exports"],"sources":["../src/humanReadablePane.js"],"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';\n\nconst humanReadablePane = {\n icon: icons.originalIconBase + 'tango/22-text-x-generic.png',\n\n name: 'humanReadable',\n\n label: function (subject, context) {\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 'image/png',\n 'image/jpeg',\n 'application/pdf',\n 'video/mp4'\n ]\n\n const hasContentTypeIn = function (kb, x, displayables) {\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 (kb, x, displayables) {\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 'view'\n\n if (\n hasContentTypeIn(kb, subject, allowed) ||\n hasContentTypeIn2(kb, subject, allowed)\n ) {\n return 'View'\n }\n\n return null\n },\n\n render: function (subject, context) {\n const myDocument = context.dom\n const div = myDocument.createElement('div')\n const kb = context.session.store\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 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.setAttribute('class', 'docView')\n const element = ct === 'text/markdown' ? 'DIV' : 'IFRAME'\n const frame = myDocument.createElement(element)\n\n const setIframeAttributes = (frame, blob, lines) => {\n frame.setAttribute('src', URL.createObjectURL(blob));\n frame.setAttribute('type', blob.type);\n frame.setAttribute('class', 'doc');\n frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 800px; resize: both; overflow: auto;`);\n\n // Apply sandbox attribute only for HTML files\n // @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe\n // You can't have any sandbox and allow plugins.\n // We could sandbox only HTML files I suppose.\n if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {\n frame.setAttribute('sandbox', 'allow-scripts allow-same-origin');\n }\n };\n\n // render markdown to html\n const markdownHtml = function () {\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)\n const clean = DOMPurify.sanitize(res)\n frame.innerHTML = clean\n frame.setAttribute('class', 'doc')\n frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 800px; resize: both; overflow: auto;`)\n }).catch(error => {\n console.error('Error fetching markdown content:', error)\n frame.innerHTML = '<p>Error loading content</p>'\n })\n }\n\n if (ct === 'text/markdown') {\n markdownHtml()\n } else {\n // Fetch and process the blob\n kb.fetcher._fetch(subject.uri)\n .then(response => response.blob())\n .then(blob => {\n const blobTextPromise = blob.type.startsWith('text') ? blob.text() : Promise.resolve('')\n return blobTextPromise.then(blobText => ({ blob, blobText }))\n })\n .then(({ blob, blobText }) => {\n const newLines = blobText.includes('<script src=\"https://dokie.li/scripts/dokieli.js\">') ? -10 : 5\n const lines = Math.min(30, blobText.split(/\\n/).length + newLines)\n setIframeAttributes(frame, blob, lines)\n })\n .catch(err => {\n console.log('Error fetching or processing blob:', err)\n })\n }\n\n const tr = myDocument.createElement('TR')\n tr.appendChild(frame)\n div.appendChild(tr)\n return div\n }\n}\n\nexport default humanReadablePane\n// ends\n"],"mappings":";;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAAkC,SAAAI,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,gBAAAA,CAAA;AARlC;AACA;AACA;AACA;AACA;;AAMA,IAAME,iBAAiB,GAAG;EACxBC,IAAI,EAAEC,cAAK,CAACC,gBAAgB,GAAG,6BAA6B;EAE5DC,IAAI,EAAE,eAAe;EAErBC,KAAK,EAAE,SAAPA,KAAKA,CAAYC,OAAO,EAAEC,OAAO,EAAE;IACjC,IAAMC,EAAE,GAAGD,OAAO,CAACE,OAAO,CAACC,KAAK;;IAEhC;;IAEA,IAAMC,OAAO,GAAG,CACd,YAAY,EACZ,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,WAAW,CACZ;IAED,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAaJ,EAAE,EAAEK,CAAC,EAAEC,YAAY,EAAE;MACtD,IAAMC,GAAG,GAAGP,EAAE,CAACQ,OAAO,CAACC,SAAS,CAACJ,CAAC,EAAE,cAAc,CAAC;MACnD,IAAIE,GAAG,EAAE;QACP,KAAK,IAAIG,CAAC,GAAG,CAAC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
8
- v8: string;
9
- uv: string;
10
- zlib: string;
11
- brotli: string;
8
+ acorn: string;
9
+ ada: string;
12
10
  ares: string;
11
+ base64: string;
12
+ brotli: string;
13
+ cjs_module_lexer: string;
14
+ cldr: string;
15
+ icu: string;
16
+ llhttp: string;
13
17
  modules: string;
14
- nghttp2: string;
15
18
  napi: string;
16
- llhttp: string;
19
+ nghttp2: string;
20
+ nghttp3: string;
21
+ ngtcp2: string;
17
22
  openssl: string;
18
- cldr: string;
19
- icu: string;
23
+ simdutf: string;
20
24
  tz: string;
25
+ undici: string;
21
26
  unicode: string;
22
- ngtcp2: string;
23
- nghttp3: string;
27
+ uv: string;
28
+ uvwasi: string;
29
+ v8: string;
30
+ zlib: string;
24
31
  };
25
32
  };
26
33
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"versionInfo.d.ts","sourceRoot":"","sources":["../src/versionInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAyBE"}
1
+ {"version":3,"file":"versionInfo.d.ts","sourceRoot":"","sources":["../src/versionInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAgCE"}
@@ -5,28 +5,35 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports["default"] = void 0;
7
7
  var _default = exports["default"] = {
8
- buildTime: "2025-02-05T10:12:21Z",
9
- commit: "65d80a4a704e8b79647cd2bc4b9985e9659a326e",
8
+ buildTime: "2025-02-13T19:06:15Z",
9
+ commit: "c7f6db53b895a4500f6b448ca9f4cb9545b5336e",
10
10
  npmInfo: {
11
- 'solid-panes': '3.6.2',
11
+ 'solid-panes': '3.6.3',
12
12
  npm: '8.19.4',
13
- node: '16.20.2',
14
- v8: '9.4.146.26-node.26',
15
- uv: '1.43.0',
16
- zlib: '1.2.11',
17
- brotli: '1.0.9',
18
- ares: '1.19.1',
19
- modules: '93',
20
- nghttp2: '1.47.0',
21
- napi: '8',
22
- llhttp: '6.0.11',
23
- openssl: '1.1.1v+quic',
24
- cldr: '41.0',
25
- icu: '71.1',
26
- tz: '2022f',
27
- unicode: '14.0',
28
- ngtcp2: '0.8.1',
29
- nghttp3: '0.7.0'
13
+ node: '18.20.6',
14
+ acorn: '8.13.0',
15
+ ada: '2.8.0',
16
+ ares: '1.29.0',
17
+ base64: '0.5.2',
18
+ brotli: '1.1.0',
19
+ cjs_module_lexer: '1.2.2',
20
+ cldr: '44.1',
21
+ icu: '74.2',
22
+ llhttp: '6.1.1',
23
+ modules: '108',
24
+ napi: '9',
25
+ nghttp2: '1.61.0',
26
+ nghttp3: '0.7.0',
27
+ ngtcp2: '1.3.0',
28
+ openssl: '3.0.15+quic',
29
+ simdutf: '5.6.0',
30
+ tz: '2024a',
31
+ undici: '5.28.5',
32
+ unicode: '15.1',
33
+ uv: '1.44.2',
34
+ uvwasi: '0.0.19',
35
+ v8: '10.2.154.26-node.37',
36
+ zlib: '1.3.0.1-motley'
30
37
  }
31
38
  };
32
39
  //# sourceMappingURL=versionInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"versionInfo.js","names":["buildTime","commit","npmInfo","npm","node","v8","uv","zlib","brotli","ares","modules","nghttp2","napi","llhttp","openssl","cldr","icu","tz","unicode","ngtcp2","nghttp3"],"sources":["../src/versionInfo.ts"],"sourcesContent":["export default {\nbuildTime: \"2025-02-05T10:12:21Z\",\ncommit: \"65d80a4a704e8b79647cd2bc4b9985e9659a326e\",\nnpmInfo:\n{\n 'solid-panes': '3.6.2',\n npm: '8.19.4',\n node: '16.20.2',\n v8: '9.4.146.26-node.26',\n uv: '1.43.0',\n zlib: '1.2.11',\n brotli: '1.0.9',\n ares: '1.19.1',\n modules: '93',\n nghttp2: '1.47.0',\n napi: '8',\n llhttp: '6.0.11',\n openssl: '1.1.1v+quic',\n cldr: '41.0',\n icu: '71.1',\n tz: '2022f',\n unicode: '14.0',\n ngtcp2: '0.8.1',\n nghttp3: '0.7.0'\n}\n};\n"],"mappings":";;;;;;oCAAe;EACfA,SAAS,EAAE,sBAAsB;EACjCC,MAAM,EAAE,0CAA0C;EAClDC,OAAO,EACP;IACE,aAAa,EAAE,OAAO;IACtBC,GAAG,EAAE,QAAQ;IACbC,IAAI,EAAE,SAAS;IACfC,EAAE,EAAE,oBAAoB;IACxBC,EAAE,EAAE,QAAQ;IACZC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE,OAAO;IACfC,IAAI,EAAE,QAAQ;IACdC,OAAO,EAAE,IAAI;IACbC,OAAO,EAAE,QAAQ;IACjBC,IAAI,EAAE,GAAG;IACTC,MAAM,EAAE,QAAQ;IAChBC,OAAO,EAAE,aAAa;IACtBC,IAAI,EAAE,MAAM;IACZC,GAAG,EAAE,MAAM;IACXC,EAAE,EAAE,OAAO;IACXC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,OAAO;IACfC,OAAO,EAAE;EACX;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"versionInfo.js","names":["buildTime","commit","npmInfo","npm","node","acorn","ada","ares","base64","brotli","cjs_module_lexer","cldr","icu","llhttp","modules","napi","nghttp2","nghttp3","ngtcp2","openssl","simdutf","tz","undici","unicode","uv","uvwasi","v8","zlib"],"sources":["../src/versionInfo.ts"],"sourcesContent":["export default {\nbuildTime: \"2025-02-13T19:06:15Z\",\ncommit: \"c7f6db53b895a4500f6b448ca9f4cb9545b5336e\",\nnpmInfo:\n{\n 'solid-panes': '3.6.3',\n npm: '8.19.4',\n node: '18.20.6',\n acorn: '8.13.0',\n ada: '2.8.0',\n ares: '1.29.0',\n base64: '0.5.2',\n brotli: '1.1.0',\n cjs_module_lexer: '1.2.2',\n cldr: '44.1',\n icu: '74.2',\n llhttp: '6.1.1',\n modules: '108',\n napi: '9',\n nghttp2: '1.61.0',\n nghttp3: '0.7.0',\n ngtcp2: '1.3.0',\n openssl: '3.0.15+quic',\n simdutf: '5.6.0',\n tz: '2024a',\n undici: '5.28.5',\n unicode: '15.1',\n uv: '1.44.2',\n uvwasi: '0.0.19',\n v8: '10.2.154.26-node.37',\n zlib: '1.3.0.1-motley'\n}\n};\n"],"mappings":";;;;;;oCAAe;EACfA,SAAS,EAAE,sBAAsB;EACjCC,MAAM,EAAE,0CAA0C;EAClDC,OAAO,EACP;IACE,aAAa,EAAE,OAAO;IACtBC,GAAG,EAAE,QAAQ;IACbC,IAAI,EAAE,SAAS;IACfC,KAAK,EAAE,QAAQ;IACfC,GAAG,EAAE,OAAO;IACZC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE,OAAO;IACfC,MAAM,EAAE,OAAO;IACfC,gBAAgB,EAAE,OAAO;IACzBC,IAAI,EAAE,MAAM;IACZC,GAAG,EAAE,MAAM;IACXC,MAAM,EAAE,OAAO;IACfC,OAAO,EAAE,KAAK;IACdC,IAAI,EAAE,GAAG;IACTC,OAAO,EAAE,QAAQ;IACjBC,OAAO,EAAE,OAAO;IAChBC,MAAM,EAAE,OAAO;IACfC,OAAO,EAAE,aAAa;IACtBC,OAAO,EAAE,OAAO;IAChBC,EAAE,EAAE,OAAO;IACXC,MAAM,EAAE,QAAQ;IAChBC,OAAO,EAAE,MAAM;IACfC,EAAE,EAAE,QAAQ;IACZC,MAAM,EAAE,QAAQ;IAChBC,EAAE,EAAE,qBAAqB;IACzBC,IAAI,EAAE;EACR;AACA,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-panes",
3
- "version": "3.6.2",
3
+ "version": "3.6.3-c7f6db53",
4
4
  "description": "Solid-compatible Panes: applets and views for the mashlib and databrowser",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -51,6 +51,7 @@
51
51
  "chat-pane": "^2.4.27",
52
52
  "contacts-pane": "^2.6.13",
53
53
  "dompurify": "^3.2.4",
54
+ "eslint": "^9.20.1",
54
55
  "folder-pane": "^2.4.28",
55
56
  "issue-pane": "^2.4.20",
56
57
  "marked": "^11.2.0",
@@ -70,12 +71,12 @@
70
71
  "@testing-library/dom": "^9.3.4",
71
72
  "@testing-library/jest-dom": "^6.6.3",
72
73
  "@types/webpack-env": "^1.18.8",
73
- "@typescript-eslint/eslint-plugin": "^6.21.0",
74
- "@typescript-eslint/parser": "^6.21.0",
74
+ "@typescript-eslint/eslint-plugin": "^8.24.0",
75
+ "@typescript-eslint/parser": "^8.24.0",
75
76
  "babel-loader": "^9.2.1",
76
77
  "babel-plugin-inline-import": "^3.0.0",
77
78
  "buffer": "^6.0.3",
78
- "eslint": "^8.57.1",
79
+ "globals": "^15.15.0",
79
80
  "html-webpack-plugin": "^5.6.3",
80
81
  "husky": "^8.0.3",
81
82
  "jest": "^29.7.0",
@@ -47,7 +47,7 @@ export default {
47
47
 
48
48
  // This data coul d come from a fetch OR from ldp comtaimner
49
49
  const hasContentTypeIn2 = function (kb, x, displayables) {
50
- const t = kb.findTypeURIs(subject)
50
+ const t = kb.findTypeURIs(x)
51
51
  for (let k = 0; k < displayables.length; k++) {
52
52
  if ($rdf.Util.mediaTypeClass(displayables[k]).uri in t) {
53
53
  return true
@@ -138,41 +138,49 @@ export default {
138
138
  div.setAttribute('class', 'docView')
139
139
  const iframe = myDocument.createElement('IFRAME')
140
140
 
141
- // get with authenticated fetch
141
+ // Function to set iframe attributes
142
+ const setIframeAttributes = (iframe, blob, lines) => {
143
+ const objectURL = URL.createObjectURL(blob)
144
+ iframe.setAttribute('src', objectURL)
145
+ iframe.setAttribute('type', blob.type)
146
+ iframe.setAttribute('class', 'doc')
147
+ iframe.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)
148
+
149
+ // Apply sandbox attribute only for HTML files
150
+ // @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
151
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
152
+ // You can;'t have any sandbox and allow plugins.
153
+ // We could sandbox only HTML files I suppose.
154
+ // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
155
+ if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {
156
+ iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin')
157
+ }
158
+ }
159
+
160
+ // Fetch and process the blob
142
161
  kb.fetcher._fetch(subject.uri)
143
- .then(function(response) {
144
- return response.blob()
162
+ .then(response => response.blob())
163
+ .then(blob => {
164
+ const blobTextPromise = blob.type.startsWith('text') ? blob.text() : Promise.resolve('')
165
+ return blobTextPromise.then(blobText => ({ blob, blobText }))
145
166
  })
146
- .then(function(blob) {
147
- const objectURL = URL.createObjectURL(blob)
148
- iframe.setAttribute('src', objectURL) // w640 h480 //
149
- iframe.setAttribute('type', blob.type)
150
- iframe.setAttribute('class', 'doc')
151
- return blob.text()
152
- })
153
- .then(function(blobText) {
167
+ .then(({ blob, blobText }) => {
154
168
  const newLines = blobText.includes('<script src="https://dokie.li/scripts/dokieli.js">') ? -10 : 5
155
169
  const lines = Math.min(30, blobText.split(/\n/).length + newLines)
156
- iframe.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)
157
- })
158
- .catch(err => { console.log(err) })
170
+ setIframeAttributes(iframe, blob, lines)
171
+ })
172
+ .catch(err => {
173
+ console.log('Error fetching or processing blob:', err)
174
+ })
159
175
 
160
176
  const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')
161
- const ct = cts ? cts[0] : null
177
+ const ct = cts ? cts[0].split(';', 1)[0].trim() : null
162
178
  if (ct) {
163
179
  console.log('dokieliPane: c-t:' + ct)
164
180
  } else {
165
181
  console.log('dokieliPane: unknown content-type?')
166
182
  }
167
183
 
168
- // @@ NOte beflow - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
169
- // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
170
- // You can;'t have any sandbox and allow plugins.
171
- // We could sandbox only HTML files I suppose.
172
- // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
173
-
174
- // iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static
175
-
176
184
  const tr = myDocument.createElement('tr')
177
185
  tr.appendChild(iframe)
178
186
  div.appendChild(tr)
@@ -45,7 +45,7 @@ const humanReadablePane = {
45
45
 
46
46
  // This data could come from a fetch OR from ldp container
47
47
  const hasContentTypeIn2 = function (kb, x, displayables) {
48
- const t = kb.findTypeURIs(subject)
48
+ const t = kb.findTypeURIs(x)
49
49
  for (let k = 0; k < displayables.length; k++) {
50
50
  if (Util.mediaTypeClass(displayables[k]).uri in t) {
51
51
  return true
@@ -75,7 +75,7 @@ const humanReadablePane = {
75
75
  const kb = context.session.store
76
76
 
77
77
  const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')
78
- const ct = cts ? cts[0] : null
78
+ const ct = cts ? cts[0].split(';', 1)[0].trim() : null // remove content-type parameters
79
79
  if (ct) {
80
80
  // console.log('humanReadablePane: c-t:' + ct)
81
81
  } else {
@@ -87,6 +87,22 @@ const humanReadablePane = {
87
87
  const element = ct === 'text/markdown' ? 'DIV' : 'IFRAME'
88
88
  const frame = myDocument.createElement(element)
89
89
 
90
+ const setIframeAttributes = (frame, blob, lines) => {
91
+ frame.setAttribute('src', URL.createObjectURL(blob));
92
+ frame.setAttribute('type', blob.type);
93
+ frame.setAttribute('class', 'doc');
94
+ frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 800px; resize: both; overflow: auto;`);
95
+
96
+ // Apply sandbox attribute only for HTML files
97
+ // @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
98
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
99
+ // You can't have any sandbox and allow plugins.
100
+ // We could sandbox only HTML files I suppose.
101
+ if (blob.type === 'text/html' || blob.type === 'application/xhtml+xml') {
102
+ frame.setAttribute('sandbox', 'allow-scripts allow-same-origin');
103
+ }
104
+ };
105
+
90
106
  // render markdown to html
91
107
  const markdownHtml = function () {
92
108
  kb.fetcher.webOperation('GET', subject.uri).then(response => {
@@ -97,39 +113,32 @@ const humanReadablePane = {
97
113
  frame.innerHTML = clean
98
114
  frame.setAttribute('class', 'doc')
99
115
  frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 800px; resize: both; overflow: auto;`)
116
+ }).catch(error => {
117
+ console.error('Error fetching markdown content:', error)
118
+ frame.innerHTML = '<p>Error loading content</p>'
100
119
  })
101
120
  }
102
121
 
103
122
  if (ct === 'text/markdown') {
104
123
  markdownHtml()
105
124
  } else {
106
- // get with authenticated fetch
107
- kb.fetcher._fetch(subject.uri)
108
- .then(function(response) {
109
- return response.blob()
110
- })
111
- .then(function(blob) {
112
- const objectURL = URL.createObjectURL(blob)
113
- frame.setAttribute('src', objectURL)
114
- frame.setAttribute('type', blob.type)
115
- frame.setAttribute('class', 'doc')
116
- return blob.type.startsWith('text') ? blob.text() : ''
117
- })
118
- .then(function(blobText) {
119
- const newLines = blobText.includes('<script src="https://dokie.li/scripts/dokieli.js">') ? -10 : 5
120
- const lines = Math.min(30, blobText.split(/\n/).length + newLines)
121
- frame.setAttribute('style', `border: 1px solid; padding: 1em; height:${lines}em; width:800px; resize: both; overflow: auto;`)
122
- })
125
+ // Fetch and process the blob
126
+ kb.fetcher._fetch(subject.uri)
127
+ .then(response => response.blob())
128
+ .then(blob => {
129
+ const blobTextPromise = blob.type.startsWith('text') ? blob.text() : Promise.resolve('')
130
+ return blobTextPromise.then(blobText => ({ blob, blobText }))
131
+ })
132
+ .then(({ blob, blobText }) => {
133
+ const newLines = blobText.includes('<script src="https://dokie.li/scripts/dokieli.js">') ? -10 : 5
134
+ const lines = Math.min(30, blobText.split(/\n/).length + newLines)
135
+ setIframeAttributes(frame, blob, lines)
136
+ })
137
+ .catch(err => {
138
+ console.log('Error fetching or processing blob:', err)
139
+ })
123
140
  }
124
141
 
125
- // @@ Note below - if we set ANY sandbox, then Chrome and Safari won't display it if it is PDF.
126
- // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
127
- // You can't have any sandbox and allow plugins.
128
- // We could sandbox only HTML files I suppose.
129
- // HTML5 bug: https://lists.w3.org/Archives/Public/public-html/2011Jun/0330.html
130
-
131
- // iframe.setAttribute('sandbox', 'allow-same-origin allow-forms'); // allow-scripts ?? no documents should be static
132
-
133
142
  const tr = myDocument.createElement('TR')
134
143
  tr.appendChild(frame)
135
144
  div.appendChild(tr)
@@ -1,26 +1,33 @@
1
1
  export default {
2
- buildTime: "2025-02-05T10:12:21Z",
3
- commit: "65d80a4a704e8b79647cd2bc4b9985e9659a326e",
2
+ buildTime: "2025-02-13T19:06:15Z",
3
+ commit: "c7f6db53b895a4500f6b448ca9f4cb9545b5336e",
4
4
  npmInfo:
5
5
  {
6
- 'solid-panes': '3.6.2',
6
+ 'solid-panes': '3.6.3',
7
7
  npm: '8.19.4',
8
- node: '16.20.2',
9
- v8: '9.4.146.26-node.26',
10
- uv: '1.43.0',
11
- zlib: '1.2.11',
12
- brotli: '1.0.9',
13
- ares: '1.19.1',
14
- modules: '93',
15
- nghttp2: '1.47.0',
16
- napi: '8',
17
- llhttp: '6.0.11',
18
- openssl: '1.1.1v+quic',
19
- cldr: '41.0',
20
- icu: '71.1',
21
- tz: '2022f',
22
- unicode: '14.0',
23
- ngtcp2: '0.8.1',
24
- nghttp3: '0.7.0'
8
+ node: '18.20.6',
9
+ acorn: '8.13.0',
10
+ ada: '2.8.0',
11
+ ares: '1.29.0',
12
+ base64: '0.5.2',
13
+ brotli: '1.1.0',
14
+ cjs_module_lexer: '1.2.2',
15
+ cldr: '44.1',
16
+ icu: '74.2',
17
+ llhttp: '6.1.1',
18
+ modules: '108',
19
+ napi: '9',
20
+ nghttp2: '1.61.0',
21
+ nghttp3: '0.7.0',
22
+ ngtcp2: '1.3.0',
23
+ openssl: '3.0.15+quic',
24
+ simdutf: '5.6.0',
25
+ tz: '2024a',
26
+ undici: '5.28.5',
27
+ unicode: '15.1',
28
+ uv: '1.44.2',
29
+ uvwasi: '0.0.19',
30
+ v8: '10.2.154.26-node.37',
31
+ zlib: '1.3.0.1-motley'
25
32
  }
26
33
  };