From a6c4a7864e66d8f33763777f80ef9f5435d78fa6 Mon Sep 17 00:00:00 2001 From: crowlkats Date: Tue, 17 Dec 2024 05:40:42 +0100 Subject: [PATCH] add missing snapshots --- .../html_test__html_doc_files_rewrite-54.snap | 124 +++++ .../html_test__html_doc_files_rewrite-55.snap | 480 ++++++++++++++++++ .../html_test__html_doc_files_rewrite-56.snap | 353 +++++++++++++ .../html_test__html_doc_files_rewrite-57.snap | 277 ++++++++++ .../html_test__html_doc_files_rewrite-58.snap | 67 +++ .../html_test__html_doc_files_rewrite-59.snap | 178 +++++++ .../html_test__html_doc_files_rewrite-60.snap | 127 +++++ .../html_test__html_doc_files_rewrite-61.snap | 186 +++++++ .../html_test__html_doc_files_rewrite-62.snap | 127 +++++ .../html_test__html_doc_files_rewrite-63.snap | 186 +++++++ .../html_test__html_doc_files_rewrite-64.snap | 159 ++++++ .../html_test__html_doc_files_rewrite-65.snap | 109 ++++ .../html_test__html_doc_files_rewrite-66.snap | 186 +++++++ .../html_test__html_doc_files_rewrite-67.snap | 15 + .../html_test__html_doc_files_rewrite-68.snap | 39 ++ .../html_test__html_doc_files_rewrite-69.snap | 145 ++++++ .../html_test__html_doc_files_rewrite-70.snap | 7 + 17 files changed, 2765 insertions(+) create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-54.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-55.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-56.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-57.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-58.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-59.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-60.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-61.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-62.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-63.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-64.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-65.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-66.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-67.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-68.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-69.snap create mode 100644 tests/snapshots/html_test__html_doc_files_rewrite-70.snap diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-54.snap b/tests/snapshots/html_test__html_doc_files_rewrite-54.snap new file mode 100644 index 00000000..6add1e4e --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-54.snap @@ -0,0 +1,124 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + c - documentation + + + + + + + + + + +
+
+
+
+
+

Usage

import { c } from ".";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-55.snap b/tests/snapshots/html_test__html_doc_files_rewrite-55.snap new file mode 100644 index 00000000..308e0759 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-55.snap @@ -0,0 +1,480 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + d - documentation + + + + + + + + + + +
+
+
+
+
+
+ function d +
+ + + + + + + + + + + +d<T = string>(
foo?: number,
bar?: string,
baz?: { hello?: string; },
qaz: T,
...strings: string[],
): string
+
+
+ + + + + + + + + + +

test

+

+
d();
+
+
+
+
+ + + + + + + + + + +

Example 2

+

+
d();
+
+
+
+
+
+
+

+ + + + + + + + + + +Type Parameters

+ +
+
+ + + + + + + + + + +T = string + +
+
+
+
+

+ + + + + + + + + + +Parameters

+ +
+
optional
+
+ + + + + + + + + + +foo: number = 1 + +

{number} some parameter

+
+
+ +
+
optional
+
+ + + + + + + + + + +bar: string = bar + +
+
+ +
+
optional
+
+ + + + + + + + + + +baz: { hello?: string; } + +
+
+ +
+
+
+ +
+
+ + + + + + + + + + +...strings: string[] + +
+
+
+
+

+ + + + + + + + + + +Return Type

+ +
+
string + +

a new string

+
+
+
+
+ +
+
Foo + +

bar

+
+
+
+
+
+
+
+
+

Usage

import { d } from ".";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-56.snap b/tests/snapshots/html_test__html_doc_files_rewrite-56.snap new file mode 100644 index 00000000..fc363a77 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-56.snap @@ -0,0 +1,353 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + functionWithOptionalParameters - documentation + + + + + + + + + + +
+
+
+
+
+
+ function functionWithOptionalParameters +
+ + + + + + + + + + + +functionWithOptionalParameters(
foo?: number,
bar?: number,
baz?: [number],
unnamed 3?: string[],
unnamed 4?: { qux: number; },
): void
+
+
+

+ + + + + + + + + + +Parameters

+ +
+
optional
+
+ + + + + + + + + + +foo: number = 1 + +
+
+ +
+
optional
+
+ + + + + + + + + + +bar: number + +
+
+ +
+
optional
+
+ + + + + + + + + + +baz: [number] + +
+
+ +
+
optional
+
+ + + + + + + + + + +unnamed 3: string[] + +
+
+ +
+
optional
+
+ + + + + + + + + + +unnamed 4: { qux: number; } + +
+
+
+
+

+ + + + + + + + + + +Return Type

+ +
+
void + +
+
+
+
+ +
+
+ +

bar

+
+
+
+ +
+
+
+
+
+
+
+

Usage

import { functionWithOptionalParameters } from ".";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-57.snap b/tests/snapshots/html_test__html_doc_files_rewrite-57.snap new file mode 100644 index 00000000..fd485338 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-57.snap @@ -0,0 +1,277 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + qaz - documentation + + + + + + + + + + +
+
+
+
+
+

Usage

import { qaz } from ".";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-58.snap b/tests/snapshots/html_test__html_doc_files_rewrite-58.snap new file mode 100644 index 00000000..78f462d8 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-58.snap @@ -0,0 +1,67 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + someVariable - documentation + + + + + + + + + + +
+
+
+
+
+
+ variable someVariable +
+
+
+
+
+

Usage

import { someVariable } from ".";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-59.snap b/tests/snapshots/html_test__html_doc_files_rewrite-59.snap new file mode 100644 index 00000000..60770f81 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-59.snap @@ -0,0 +1,178 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + x - documentation + + + + + + + + + + +
+
+
+
+
+

Usage

import { x } from ".";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-60.snap b/tests/snapshots/html_test__html_doc_files_rewrite-60.snap new file mode 100644 index 00000000..1b6b48a7 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-60.snap @@ -0,0 +1,127 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + c - documentation + + + + + + + + + + +
+
+
+
+
+
f
+
+ x + +
No documentation available
+
+
+
+
+
+
+
+

Usage

import * as c from "c";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-61.snap b/tests/snapshots/html_test__html_doc_files_rewrite-61.snap new file mode 100644 index 00000000..248833ad --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-61.snap @@ -0,0 +1,186 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + x - c - documentation + + + + + + + + + + +
+
+
+
+
+

Usage

import { x } from "c";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-62.snap b/tests/snapshots/html_test__html_doc_files_rewrite-62.snap new file mode 100644 index 00000000..6b95dacc --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-62.snap @@ -0,0 +1,127 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + d - documentation + + + + + + + + + + +
+
+
+
+
+
f
+
+ externalFunction + +
No documentation available
+
+
+
+
+
+
+
+

Usage

import * as mod from "d";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-63.snap b/tests/snapshots/html_test__html_doc_files_rewrite-63.snap new file mode 100644 index 00000000..9fc08737 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-63.snap @@ -0,0 +1,186 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + externalFunction - d - documentation + + + + + + + + + + +
+
+
+
+
+

Usage

import { externalFunction } from "d";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-64.snap b/tests/snapshots/html_test__html_doc_files_rewrite-64.snap new file mode 100644 index 00000000..e4eeac79 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-64.snap @@ -0,0 +1,159 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + foo - documentation + + + + + + + + + + +
+
+
+
+
+
f
+
+ x + +
No documentation available
+
+
+
+
v
+
+ default + +

The default export item.

+
+
+
+
+
+
+
+
+

Usage

import * as bar from "foo";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-65.snap b/tests/snapshots/html_test__html_doc_files_rewrite-65.snap new file mode 100644 index 00000000..17abc251 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-65.snap @@ -0,0 +1,109 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + default - foo - documentation + + + + + + + + + + +
+
+
+
+
+

Usage

import bar from "foo";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-66.snap b/tests/snapshots/html_test__html_doc_files_rewrite-66.snap new file mode 100644 index 00000000..c5f81334 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-66.snap @@ -0,0 +1,186 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- + + + + x - foo - documentation + + + + + + + + + + +
+
+
+
+
+

Usage

import { x } from "foo";
+
+
+
+
+
+ + diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-67.snap b/tests/snapshots/html_test__html_doc_files_rewrite-67.snap new file mode 100644 index 00000000..4778501f --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-67.snap @@ -0,0 +1,15 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- +// deno-fmt-ignore-file +// deno-lint-ignore-file +/** + * Fuse.js v7.0.0 - Lightweight fuzzy-search (http://fusejs.io) + * + * Copyright (c) 2023 Kiro Risk (http://kiro.me) + * All Rights Reserved. Apache Software License 2.0 + * + * http://www.apache.org/licenses/LICENSE-2.0 + */ +var e,t;e=this,t=function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:{},n=t.getFn,i=void 0===n?$.getFn:n,o=t.fieldNormWeight,c=void 0===o?$.fieldNormWeight:o;r(this,e),this.norm=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=new Map,r=Math.pow(10,t);return{get:function(t){var i=t.match(F).length;if(n.has(i))return n.get(i);var o=1/Math.pow(i,.5*e),c=parseFloat(Math.round(o*r)/r);return n.set(i,c),c},clear:function(){n.clear()}}}(c,3),this.getFn=i,this.isCreated=!1,this.setIndexRecords()}return o(e,[{key:"setSources",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.docs=e}},{key:"setIndexRecords",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.records=e}},{key:"setKeys",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.keys=t,this._keysMap={},t.forEach((function(t,n){e._keysMap[t.id]=n}))}},{key:"create",value:function(){var e=this;!this.isCreated&&this.docs.length&&(this.isCreated=!0,m(this.docs[0])?this.docs.forEach((function(t,n){e._addString(t,n)})):this.docs.forEach((function(t,n){e._addObject(t,n)})),this.norm.clear())}},{key:"add",value:function(e){var t=this.size();m(e)?this._addString(e,t):this._addObject(e,t)}},{key:"removeAt",value:function(e){this.records.splice(e,1);for(var t=e,n=this.size();t2&&void 0!==arguments[2]?arguments[2]:{},r=n.getFn,i=void 0===r?$.getFn:r,o=n.fieldNormWeight,c=void 0===o?$.fieldNormWeight:o,a=new R({getFn:i,fieldNormWeight:c});return a.setKeys(e.map(A)),a.setSources(t),a.create(),a}function N(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.errors,r=void 0===n?0:n,i=t.currentLocation,o=void 0===i?0:i,c=t.expectedLocation,a=void 0===c?0:c,s=t.distance,u=void 0===s?$.distance:s,h=t.ignoreLocation,l=void 0===h?$.ignoreLocation:h,f=r/e.length;if(l)return f;var d=Math.abs(a-o);return u?f+d/u:d?1:f}var W=32;function T(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=r.location,o=void 0===i?$.location:i,c=r.distance,a=void 0===c?$.distance:c,s=r.threshold,u=void 0===s?$.threshold:s,h=r.findAllMatches,l=void 0===h?$.findAllMatches:h,f=r.minMatchCharLength,d=void 0===f?$.minMatchCharLength:f,v=r.includeMatches,g=void 0===v?$.includeMatches:v,y=r.ignoreLocation,p=void 0===y?$.ignoreLocation:y;if(t.length>W)throw new Error("Pattern length exceeds max of ".concat(W,"."));for(var m,k=t.length,M=e.length,b=Math.max(0,Math.min(o,M)),x=u,w=b,S=d>1||g,L=S?Array(M):[];(m=e.indexOf(t,w))>-1;){var _=N(t,{currentLocation:m,expectedLocation:b,distance:a,ignoreLocation:p});if(x=Math.min(_,x),w=m+k,S)for(var O=0;O=P;D-=1){var K=D-1,q=n[e.charAt(K)];if(S&&(L[K]=+!!q),z[D]=(z[D+1]<<1|1)&q,E&&(z[D]|=(j[D+1]|j[D])<<1|1|j[D+1]),z[D]&C&&(A=N(t,{errors:E,currentLocation:K,expectedLocation:b,distance:a,ignoreLocation:p}))<=x){if(x=A,(w=K)<=b)break;P=Math.max(1,2*b-w)}}if(N(t,{errors:E+1,currentLocation:b,expectedLocation:b,distance:a,ignoreLocation:p})>x)break;j=z}var B={isMatch:w>=0,score:Math.max(.001,A)};if(S){var J=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$.minMatchCharLength,n=[],r=-1,i=-1,o=0,c=e.length;o=t&&n.push([r,i]),r=-1)}return e[o-1]&&o-r>=t&&n.push([r,o-1]),n}(L,d);J.length?g&&(B.indices=J):B.isMatch=!1}return B}function z(e){for(var t={},n=0,r=e.length;n1&&void 0!==arguments[1]?arguments[1]:{},o=i.location,c=void 0===o?$.location:o,a=i.threshold,s=void 0===a?$.threshold:a,u=i.distance,h=void 0===u?$.distance:u,l=i.includeMatches,f=void 0===l?$.includeMatches:l,d=i.findAllMatches,v=void 0===d?$.findAllMatches:d,g=i.minMatchCharLength,y=void 0===g?$.minMatchCharLength:g,p=i.isCaseSensitive,m=void 0===p?$.isCaseSensitive:p,k=i.ignoreLocation,M=void 0===k?$.ignoreLocation:k;if(r(this,e),this.options={location:c,threshold:s,distance:h,includeMatches:f,findAllMatches:v,minMatchCharLength:y,isCaseSensitive:m,ignoreLocation:M},this.pattern=m?t:t.toLowerCase(),this.chunks=[],this.pattern.length){var b=function(e,t){n.chunks.push({pattern:e,alphabet:z(e),startIndex:t})},x=this.pattern.length;if(x>W){for(var w=0,S=x%W,L=x-S;w1&&void 0!==arguments[1]?arguments[1]:{},c=o.location,a=void 0===c?$.location:c,s=o.threshold,u=void 0===s?$.threshold:s,h=o.distance,l=void 0===h?$.distance:h,f=o.includeMatches,d=void 0===f?$.includeMatches:f,v=o.findAllMatches,g=void 0===v?$.findAllMatches:v,y=o.minMatchCharLength,p=void 0===y?$.minMatchCharLength:y,m=o.isCaseSensitive,k=void 0===m?$.isCaseSensitive:m,M=o.ignoreLocation,b=void 0===M?$.ignoreLocation:M;return r(this,n),(i=t.call(this,e))._bitapSearch=new D(e,{location:a,threshold:u,distance:l,includeMatches:d,findAllMatches:g,minMatchCharLength:p,isCaseSensitive:k,ignoreLocation:b}),i}return o(n,[{key:"search",value:function(e){return this._bitapSearch.searchIn(e)}}],[{key:"type",get:function(){return"fuzzy"}},{key:"multiRegex",get:function(){return/^"(.*)"$/}},{key:"singleRegex",get:function(){return/^(.*)$/}}]),n}(K),X=function(e){a(n,e);var t=l(n);function n(e){return r(this,n),t.call(this,e)}return o(n,[{key:"search",value:function(e){for(var t,n=0,r=[],i=this.pattern.length;(t=e.indexOf(this.pattern,n))>-1;)n=t+i,r.push([t,n-1]);var o=!!r.length;return{isMatch:o,score:o?0:1,indices:r}}}],[{key:"type",get:function(){return"include"}},{key:"multiRegex",get:function(){return/^'"(.*)"$/}},{key:"singleRegex",get:function(){return/^'(.*)$/}}]),n}(K),Y=[B,X,U,V,H,G,J,Q],Z=Y.length,ee=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,te=new Set([Q.type,X.type]),ne=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.isCaseSensitive,o=void 0===i?$.isCaseSensitive:i,c=n.includeMatches,a=void 0===c?$.includeMatches:c,s=n.minMatchCharLength,u=void 0===s?$.minMatchCharLength:s,h=n.ignoreLocation,l=void 0===h?$.ignoreLocation:h,f=n.findAllMatches,d=void 0===f?$.findAllMatches:f,v=n.location,g=void 0===v?$.location:v,y=n.threshold,p=void 0===y?$.threshold:y,m=n.distance,k=void 0===m?$.distance:m;r(this,e),this.query=null,this.options={isCaseSensitive:o,includeMatches:a,minMatchCharLength:u,findAllMatches:d,ignoreLocation:l,location:g,threshold:p,distance:k},this.pattern=o?t:t.toLowerCase(),this.query=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.split("|").map((function(e){for(var n=e.trim().split(ee).filter((function(e){return e&&!!e.trim()})),r=[],i=0,o=n.length;i2&&void 0!==arguments[2]?arguments[2]:{}).auto,r=void 0===n||n;return ue(e)||(e=he(e)),function e(n){var i=Object.keys(n),o=function(e){return!!e[ae]}(n);if(!o&&i.length>1&&!ue(n))return e(he(n));if(function(e){return!g(e)&&b(e)&&!ue(e)}(n)){var c=o?n[ae]:i[0],a=o?n[se]:n[c];if(!m(a))throw new Error(function(e){return"Invalid value for key ".concat(e)}(c));var s={keyId:C(c),pattern:a};return r&&(s.searcher=ie(a,t)),s}var u={children:[],operator:i[0]};return i.forEach((function(t){var r=n[t];g(r)&&r.forEach((function(t){u.children.push(e(t))}))})),u}(e)}function fe(e,t){var n=e.matches;t.matches=[],x(n)&&n.forEach((function(e){if(x(e.indices)&&e.indices.length){var n={indices:e.indices,value:e.value};e.key&&(n.key=e.key.src),e.idx>-1&&(n.refIndex=e.idx),t.matches.push(n)}}))}function de(e,t){t.score=e.score}var ve=function(){function e(n){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;r(this,e),this.options=t(t({},$),i),this.options.useExtendedSearch,this._keyStore=new j(this.options.keys),this.setCollection(n,o)}return o(e,[{key:"setCollection",value:function(e,t){if(this._docs=e,t&&!(t instanceof R))throw new Error("Incorrect 'index' type");this._myIndex=t||P(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}},{key:"add",value:function(e){x(e)&&(this._docs.push(e),this._myIndex.add(e))}},{key:"remove",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(){return!1},t=[],n=0,r=this._docs.length;n1&&void 0!==arguments[1]?arguments[1]:{}).limit,n=void 0===t?-1:t,r=this.options,i=r.includeMatches,o=r.includeScore,c=r.shouldSort,a=r.sortFn,s=r.ignoreFieldNorm,u=m(e)?m(this._docs[0])?this._searchStringList(e):this._searchObjectList(e):this._searchLogical(e);return function(e,t){var n=t.ignoreFieldNorm,r=void 0===n?$.ignoreFieldNorm:n;e.forEach((function(e){var t=1;e.matches.forEach((function(e){var n=e.key,i=e.norm,o=e.score,c=n?n.weight:null;t*=Math.pow(0===o&&c?Number.EPSILON:o,(c||1)*(r?1:i))})),e.score=t}))}(u,{ignoreFieldNorm:s}),c&&u.sort(a),k(n)&&n>-1&&(u=u.slice(0,n)),function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.includeMatches,i=void 0===r?$.includeMatches:r,o=n.includeScore,c=void 0===o?$.includeScore:o,a=[];return i&&a.push(fe),c&&a.push(de),e.map((function(e){var n=e.idx,r={item:t[n],refIndex:n};return a.length&&a.forEach((function(t){t(e,r)})),r}))}(u,this._docs,{includeMatches:i,includeScore:o})}},{key:"_searchStringList",value:function(e){var t=ie(e,this.options),n=this._myIndex.records,r=[];return n.forEach((function(e){var n=e.v,i=e.i,o=e.n;if(x(n)){var c=t.searchIn(n),a=c.isMatch,s=c.score,u=c.indices;a&&r.push({item:n,idx:i,matches:[{score:s,value:n,norm:o,indices:u}]})}})),r}},{key:"_searchLogical",value:function(e){var t=this,n=le(e,this.options),r=function e(n,r,i){if(!n.children){var o=n.keyId,c=n.searcher,a=t._findMatches({key:t._keyStore.get(o),value:t._myIndex.getValueForItemAtKeyId(r,o),searcher:c});return a&&a.length?[{idx:i,item:r,matches:a}]:[]}for(var s=[],u=0,h=n.children.length;u1&&void 0!==arguments[1]?arguments[1]:{},n=t.getFn,r=void 0===n?$.getFn:n,i=t.fieldNormWeight,o=void 0===i?$.fieldNormWeight:i,c=e.keys,a=e.records,s=new R({getFn:r,fieldNormWeight:o});return s.setKeys(c),s.setIndexRecords(a),s},ve.config=$,function(){re.push.apply(re,arguments)}(ne),ve},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Fuse=t(); diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-68.snap b/tests/snapshots/html_test__html_doc_files_rewrite-68.snap new file mode 100644 index 00000000..e67d0c9c --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-68.snap @@ -0,0 +1,39 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- +function findParent(el, find) { + do { + if (find(el)) { + return el; + } + } while (el = el.parentElement); +} + +document.addEventListener("click", (e) => { + const target = findParent( + e.target, + (el) => el instanceof HTMLButtonElement && el.dataset["copy"], + ); + if (target) { + navigator?.clipboard?.writeText(target.dataset["copy"]); + target.classList.add("copied"); + setTimeout(() => target.classList.remove("copied"), 1000); + } +}); + +window.addEventListener("load", () => { + const usageSelector = document.getElementById("usageSelector"); + + document.addEventListener("mouseup", (e) => { + if ( + findParent( + e.target, + (el) => + el.parentElement === usageSelector && el instanceof HTMLDivElement, + ) + ) { + usageSelector.open = false; + } + }); +}); diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-69.snap b/tests/snapshots/html_test__html_doc_files_rewrite-69.snap new file mode 100644 index 00000000..33d6c4a7 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-69.snap @@ -0,0 +1,145 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- +const Fuse = window.Fuse; + +const searchInput = document.querySelector("#searchbar"); +const contentDiv = document.querySelector("#content"); +const searchResultsDiv = document.querySelector("#searchResults"); +const currentFile = + document.querySelector("meta[name='doc-current-file']").attributes + .getNamedItem("content").value; +const pathToRoot = "../".repeat( + currentFile ? (currentFile.split("/").length + 1) : 0, +); +searchInput.removeAttribute("style"); + +const SEARCH_INDEX = window.DENO_DOC_SEARCH_INDEX; + +const fuse = new Fuse(SEARCH_INDEX.nodes, { + keys: [{ + name: "name", + weight: 2, + }], + isCaseSensitive: false, + minMatchCharLength: 2, + threshold: 0.4, +}); + +const loadedUrl = new URL(window.location.href); +const val = loadedUrl.searchParams.get("q"); +if (val) { + searchInput.value = val; + doSearch(val); +} + +window.addEventListener("load", function () { + document.addEventListener("keydown", function (event) { + if (event.key.toLowerCase() === "s") { + if (event.target !== searchInput) { + searchInput.focus(); + event.preventDefault(); + } + } + }); + + const emptyPlaceholder = "Click or press 'S' to search..."; + searchInput.placeholder = emptyPlaceholder; + + searchInput.addEventListener("focus", function () { + searchInput.placeholder = "Type your query here..."; + }); + + searchInput.addEventListener("blur", function () { + searchInput.placeholder = emptyPlaceholder; + }); +}); + +function debounce(func, delay) { + let timerId; + + return function () { + const context = this; + const args = arguments; + + clearTimeout(timerId); + + timerId = setTimeout(function () { + func.apply(context, args); + }, delay); + }; +} + +const debouncedSearch = debounce(doSearch, 250); + +searchInput.addEventListener("input", (e) => { + const val = e.target.value; + debouncedSearch(val); +}); + +function doSearch(val) { + if (!val) { + updateCurrentLocation(val); + showPage(); + } else { + const results = searchInIndex(val); + // console.log("results", results); + updateCurrentLocation(val); + renderResults(results); + showSearchResults(); + } +} + +function updateCurrentLocation(val) { + const url = new URL(window.location.href); + if (val) { + url.searchParams.set("q", val); + } else { + url.searchParams.delete("q"); + } + window.history.replaceState({}, "", url.href); +} + +function showPage() { + contentDiv.style.display = "flex"; + searchResultsDiv.style.display = "none"; +} + +function showSearchResults() { + contentDiv.style.display = "none"; + searchResultsDiv.style.display = "block"; +} + +function renderResults(results) { + if (results.length === 0) { + searchResultsDiv.innerHTML = `No result`; + return; + } + + let html = `
    `; + + for (const result of results) { + const kind = result.kind.map((kind) => { + return `
    ${kind.char}
    `; + }).join(""); + + html += `
  • + +
    +
    + ${kind} +
    + ${result.name} +
    +
    +
  • `; + } + + html += `
`; + searchResultsDiv.innerHTML = html; +} + +function searchInIndex(val) { + return fuse.search(val).map((result) => result.item); +} diff --git a/tests/snapshots/html_test__html_doc_files_rewrite-70.snap b/tests/snapshots/html_test__html_doc_files_rewrite-70.snap new file mode 100644 index 00000000..74fd2618 --- /dev/null +++ b/tests/snapshots/html_test__html_doc_files_rewrite-70.snap @@ -0,0 +1,7 @@ +--- +source: tests/html_test.rs +expression: files.get(file_name).unwrap() +--- +(function () { + window.DENO_DOC_SEARCH_INDEX = {"nodes":[{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"A","file":".","doc":"","url":"././~/A.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"AbstractClass","file":".","doc":"","url":"././~/AbstractClass.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"AbstractClass.prototype.method","file":".","doc":"","url":"././~/AbstractClass.prototype.method.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"AbstractClass.prototype.getter","file":".","doc":"","url":"././~/AbstractClass.prototype.getter.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"AbstractClass.prototype.foo","file":".","doc":"","url":"././~/AbstractClass.prototype.foo.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"B","file":".","doc":"","url":"././~/B.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Bar","file":".","doc":"> Some quote in bar docs\n> This quote part is ignored\n> when getting the title of this doc\n\nBar docs","url":"././~/Bar.html","deprecated":false},{"kind":[{"char":"T","kind":"TypeAlias","title":"Type Alias"}],"name":"Baz","file":".","doc":"","url":"././~/Baz.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Baz.bar","file":".","doc":"","url":"././~/Baz.bar.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Baz.foo","file":".","doc":"","url":"././~/Baz.foo.html","deprecated":false},{"kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"EmptyInterface","file":".","doc":"","url":"././~/EmptyInterface.html","deprecated":false},{"kind":[{"char":"E","kind":"Enum","title":"Enum"}],"name":"Enum","file":".","doc":"","url":"././~/Enum.html","deprecated":false},{"kind":[{"char":"E","kind":"Enum","title":"Enum"}],"name":"Enum2","file":".","doc":"","url":"././~/Enum2.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foo","file":".","doc":"some Foo docs {@linkcode Bar}\n","url":"././~/Foo.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.[Symbol.iterator]","file":".","doc":"","url":"././~/Foo.prototype.[Symbol.iterator].html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.getter","file":".","doc":"","url":"././~/Foo.prototype.getter.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.setter","file":".","doc":"","url":"././~/Foo.prototype.setter.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.getterAndSetter","file":".","doc":"","url":"././~/Foo.prototype.getterAndSetter.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.getterAndSetter","file":".","doc":"","url":"././~/Foo.prototype.getterAndSetter.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.staticSetter","file":".","doc":"","url":"././~/Foo.staticSetter.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.test","file":".","doc":"","url":"././~/Foo.prototype.test.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.staticMethod","file":".","doc":"","url":"././~/Foo.staticMethod.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.methodWithOverloads","file":".","doc":"","url":"././~/Foo.prototype.methodWithOverloads.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.methodWithOverloads","file":".","doc":"","url":"././~/Foo.prototype.methodWithOverloads.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Foo.prototype.methodWithOverloads","file":".","doc":"","url":"././~/Foo.prototype.methodWithOverloads.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.bar","file":".","doc":"","url":"././~/Foo.bar.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.protectedProperty","file":".","doc":"","url":"././~/Foo.prototype.protectedProperty.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.readonlyProperty","file":".","doc":"","url":"././~/Foo.prototype.readonlyProperty.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.foo","file":".","doc":"","url":"././~/Foo.prototype.foo.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Foo.prototype.\"><img src=x onerror=alert(1)>","file":".","doc":"","url":"././~/Foo.prototype.\">.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"}],"name":"Foobar","file":".","doc":"```ts\n// This code block is ignored when getting the title of this doc\nconst foobar = new Foobar();\n```\n\nFoobar docs\n\n# heading\n\ncontent\n\n## sub heading\n","url":"././~/Foobar.html","deprecated":false},{"kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"Hello","file":".","doc":"","url":"././~/Hello.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Hello.optionalMethod","file":".","doc":"","url":"././~/Hello.optionalMethod.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"Hello.computedMethod","file":".","doc":"","url":"././~/Hello.computedMethod.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.world","file":".","doc":"","url":"././~/Hello.world.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.test","file":".","doc":"Some docs","url":"././~/Hello.test.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.ab","file":".","doc":"","url":"././~/Hello.ab.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"Hello.x","file":".","doc":"","url":"././~/Hello.x.html","deprecated":false},{"kind":[{"char":"I","kind":"Interface","title":"Interface"}],"name":"InterfaceWithIndexSignature","file":".","doc":"","url":"././~/InterfaceWithIndexSignature.html","deprecated":false},{"kind":[{"char":"c","kind":"Class","title":"Class"},{"char":"N","kind":"Namespace","title":"Namespace"}],"name":"Testing","file":".","doc":"","url":"././~/Testing.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"Testing.t","file":".","doc":"","url":"././~/Testing.t.html","deprecated":false},{"kind":[{"char":"T","kind":"TypeAlias","title":"Type Alias"}],"name":"TypeAlias","file":".","doc":"","url":"././~/TypeAlias.html","deprecated":false},{"kind":[{"char":"v","kind":"Variable","title":"Variable"}],"name":"anotherVariable","file":".","doc":"","url":"././~/anotherVariable.html","deprecated":false},{"kind":[{"char":"m","kind":"Method","title":"Method"}],"name":"anotherVariable.bar","file":".","doc":"","url":"././~/anotherVariable.bar.html","deprecated":false},{"kind":[{"char":"p","kind":"Property","title":"Property"}],"name":"anotherVariable.foo","file":".","doc":"","url":"././~/anotherVariable.foo.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"c","file":".","doc":"","url":"././~/c.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"d","file":".","doc":"","url":"././~/d.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"functionWithOptionalParameters","file":".","doc":"","url":"././~/functionWithOptionalParameters.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"}],"name":"qaz","file":".","doc":"content\n","url":"././~/qaz.html","deprecated":false},{"kind":[{"char":"v","kind":"Variable","title":"Variable"}],"name":"someVariable","file":".","doc":"","url":"././~/someVariable.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"Testing.x","file":"c","doc":"","url":"./c/~/Testing.x.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"},{"char":"f","kind":"Function","title":"Function"}],"name":"x","file":"c","doc":"","url":"./c/~/x.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"Testing.externalFunction","file":"d","doc":"","url":"./d/~/Testing.externalFunction.html","deprecated":false},{"kind":[{"char":"f","kind":"Function","title":"Function"}],"name":"externalFunction","file":"d","doc":"","url":"./d/~/externalFunction.html","deprecated":false},{"kind":[{"char":"v","kind":"Variable","title":"Variable"}],"name":"default","file":"foo","doc":"The default export item.\n\nThis item reproduces the issue reported in {@link https://github.com/jsr-io/jsr/issues/459}","url":"./foo/~/default.html","deprecated":false}]}; +})()