File tree Expand file tree Collapse file tree 8 files changed +85
-7
lines changed
Expand file tree Collapse file tree 8 files changed +85
-7
lines changed Original file line number Diff line number Diff line change 11/** @file This needs to be in a separate file so it can bee tree-shaken before being published, while still being importable by tests */
22
3- const testableUrls = new Map < string , string [ ] > ( ) ;
3+ export const testableUrls = new Map < string , string [ ] > ( ) ;
44
55export function addTests ( test : string , urls : string [ ] ) : void {
66 // @ts -expect-error KISS for Vite
Original file line number Diff line number Diff line change 1+ <script >
2+ import * as urlDetection from ' ../index' ;
3+ import { getTests } from ' ../collector' ;
4+ </script >
5+
6+ <style >
7+ pre , code {
8+ white-space : nowrap ;
9+ }
10+ pre a {
11+ color : inherit ;
12+ }
13+ </style >
14+ {#each Object .keys (urlDetection ) as name }
15+ {#if ! name .startsWith (' _' ) && name !== ' utils' }
16+ <h2 id ={name }><a href ="# {name }" >{name }</a ></h2 >
17+ {@const urls = getTests (name )}
18+ {#if urls [0 ] === ' combinedTestOnly' }
19+ <p ><em >Demo URLs missing</em ></p >
20+ {:else if urls .length === 0 }
21+ <p ><em >Undeterminable via URL</em ></p >
22+ {:else }
23+ <pre ><code >
24+ {#each urls as url }
25+ <a href ="/?url= {encodeURIComponent (url )}" >{url }</a ><br >
26+ {/each }
27+ </code ></pre >
28+ {/if }
29+ {/if }
30+ {/each }
Original file line number Diff line number Diff line change 11<script >
2-
32 import parseUrl from ' ./parse-url.js' ;
43 import * as urlDetection from ' ../index' ;
5- import { getAllUrls } from ' ../collector' ;
4+ import { getAllUrls , testableUrls } from ' ../collector' ;
65
76 const defaultUrl = ' https://github.com/refined-github/github-url-detection' ;
87 const urlParameter = new URLSearchParams (location .search );
7574 .undefined {
7675 color : gray ;
7776 }
77+
78+ pre a {
79+ color : inherit ;
80+ }
7881 </style >
7982
8083<label >
99102 {#each detections as {name, detect, result} (name )}
100103 {#if detect }
101104 <div class ={String (result )}>
102- {name }(url) // <span >{String (result )}</span ></div >
105+ < a href = "/detections.html# {name }" >{ name }</ a > (url) // <span >{String (result )}</span ></div >
103106 {:else }
104107 <div class =" undefined" >
105108 {name }() // undeterminable via URL</div >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="utf-8 " />
5+ < link
6+ rel ="stylesheet "
7+ href ="
https://unpkg.com/[email protected] /dist/chota.min.css "
8+ />
9+ < meta name ="viewport " content ="width=device-width,initial-scale=1 " />
10+
11+ < title > `github-url-detection` detections</ title >
12+
13+ < link rel ="stylesheet " href ="global.css " />
14+ < script defer type ="module " src ="detections.js "> </ script >
15+ </ head >
16+
17+ < body >
18+ < h1 >
19+ < a href ="https://github.com/refined-github/github-url-detection ">
20+ refined-github/github-url-detection
21+ </ a >
22+ </ h1 >
23+ < main class ="container ">
24+ </ main >
25+ </ body >
26+ </ html >
Original file line number Diff line number Diff line change 1+ import Detections from './Detections.svelte' ;
2+
3+ const app = new Detections ( {
4+ target : document . querySelector ( 'main' ) ,
5+ } ) ;
6+
7+ export default app ;
Original file line number Diff line number Diff line change 1111 < title > `github-url-detection` npm module testing ground</ title >
1212
1313 < link rel ="stylesheet " href ="global.css " />
14- < script defer type ="module " src ="main .js "> </ script >
14+ < script defer type ="module " src ="index .js "> </ script >
1515 </ head >
1616
1717 < body >
Original file line number Diff line number Diff line change 1- import App from './App .svelte' ;
1+ import Index from './Index .svelte' ;
22
3- const app = new App ( {
3+ const app = new Index ( {
44 target : document . querySelector ( 'main' ) ,
55} ) ;
66
Original file line number Diff line number Diff line change 1+ import { resolve } from 'node:path' ;
2+ import * as url from 'node:url' ;
13import { defineConfig } from 'vite' ;
24import { svelte } from '@sveltejs/vite-plugin-svelte' ;
35
6+ const __dirname = url . fileURLToPath ( new URL ( '.' , import . meta. url ) ) ;
7+
48export default defineConfig ( {
59 base : '' ,
610 plugins : [ svelte ( ) ] ,
11+ build : {
12+ rollupOptions : {
13+ input : {
14+ main : resolve ( __dirname , 'index.html' ) ,
15+ nested : resolve ( __dirname , 'detections.html' ) ,
16+ } ,
17+ } ,
18+ } ,
719} ) ;
You can’t perform that action at this time.
0 commit comments