Skip to content

Commit 2f79d2e

Browse files
committed
Set up JSR entrypoint support
1 parent 76aa85c commit 2f79d2e

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

feat/dependencies-of/public.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ <h3>
7171
<span style="grid-area: label">Module URL:</span>
7272
<input type="url" name="url" class="url" style="grid-area: url"
7373
required value="{{ module_url }}"
74-
placeholder="https://deno.land/x/..." pattern="https://.+" />
74+
placeholder="https://deno.land/x/..." pattern="https://.+|jsr:.+" />
7575
<div class="options" style="grid-area: options;">
7676
<select name="rankdir">
7777
<option value="TB">Top-down</option>

lib/module-registries.ts

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export function determineModuleBase(fullUrl: string, opts: RegistryOpts): string
1717
case 'cdn.deno.land':
1818
if (parts[3] === 'std' && opts.isolateStd) return parts.slice(0, 8).join('/');
1919
return parts.slice(0, 6).join('/');
20+
case 'jsr.io':
21+
return `${parts.slice(0, 5).join('/')}@${parts[5]}`;
2022
case 'crux.land':
2123
if (parts.length == 4) return `${url.origin}/${parts[3]}`;
2224
return `${url.origin}/${parts[5].split('.')[0]}`;
@@ -107,6 +109,8 @@ export function determineModuleLabel(module: CodeModule, opts: RegistryOpts): st
107109
if (parts[3] !== 'std') modName = `/x${modName}`;
108110
return [[modName, ...parts.slice(7)].join('/'), `from ${parts[2]}`, ...extra];
109111
}
112+
case 'jsr.io':
113+
return [`jsr:${parts[3]}/${parts[4]}`];
110114
case 'crux.land':
111115
return [module.base.split('//')[1]];
112116
case 'esm.sh':
@@ -169,6 +173,7 @@ export function determineModuleLabel(module: CodeModule, opts: RegistryOpts): st
169173
export const ModuleColors = {
170174
"deno.land/std": "lightgreen",
171175
"deno.land/x": "lightskyblue",
176+
"jsr.io": "gold",
172177
"crux.land": "greenyellow",
173178
"cdn.esm.sh": "blanchedalmond",
174179
"esm.sh": "burlywood",
@@ -202,6 +207,8 @@ export function determineModuleAttrs(module: CodeModule): Record<string,string>
202207
return { fillcolor: ModuleColors["deno.land/std"], href: module.base };
203208
}
204209
return { fillcolor: ModuleColors["deno.land/x"], href: module.base };
210+
case 'jsr.io':
211+
return { fillcolor: ModuleColors["jsr.io"], href: module.base };
205212
case 'crux.land':
206213
return { fillcolor: ModuleColors["crux.land"], href: module.base };
207214
case 'aws-api.deno.dev':

lib/resolve.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// URL -> slug
22
export async function findModuleSlug(modUrl: string) {
3+
if (modUrl.startsWith('jsr:')) {
4+
return 'jsr/'+modUrl.slice(4);
5+
}
36
if (!modUrl.includes('://')) throw new Error(`That doesn't look like an absolute URL!`);
47
const url = new URL(modUrl);
58
if (url.protocol !== 'https:') throw new Error(`Only https:// URLs are supported at this time`);
@@ -26,6 +29,9 @@ export async function resolveModuleUrl(modSlug: string) {
2629
} else if (modSlug.startsWith('x/')) {
2730
return `https://deno.land/x/${modSlug.slice(2)}`;
2831

32+
} else if (modSlug.startsWith('jsr/')) {
33+
return `jsr:${modSlug.slice(4)}`;
34+
2935
} else if (modSlug.startsWith('https/')) {
3036
return `https://${modSlug.slice(6)}`;
3137

public/index.html

+9-4
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ <h1>Deno Module Visualizer</h1>
99
<section>
1010
<h2>Changelog</h2>
1111
<p>
12-
<strong>18 May 2024</strong>:
13-
Upgraded service to Deno 1.43, improving support for `jsr:*` and `node:*` imports.
12+
<strong>17 April 2025</strong>:
13+
Upgraded service to Deno 2.2. Accept <code>jsr:@...</code> imports in 'Module URL' textbox.
1414
</p>
1515
<p>
16-
<strong>15 March 2023</strong>:
17-
Upgraded service to Deno 1.31. Updated homepage examples.
16+
<strong>18 May 2024</strong>:
17+
Upgraded service to Deno 1.43, improving support for `jsr:*` and `node:*` imports.
1818
</p>
1919
<details>
2020
<summary>Older releases</summary>
21+
<p>
22+
<strong>15 March 2023</strong>:
23+
Upgraded service to Deno 1.31. Updated homepage examples.
24+
</p>
2125
<p>
2226
<strong>12 Febuary 2023</strong>:
2327
Upgraded service to Deno 1.30.
@@ -70,6 +74,7 @@ <h2>
7074

7175
<p>Just browsing? Here's a few interesting modules:</p>
7276
<ul>
77+
<li><a href="/dependencies-of/jsr:@astral/astral">jsr:@astral/astral</a> (a JSR package)</li>
7378
<li><a href="/dependencies-of/https/raw.githubusercontent.com/cloudydeno/module-visualizer/main/server.ts?rankdir=LR">raw.githubusercontent.com/cloudydeno/module-visualizer/main/server.ts</a> (this website!)</li>
7479
<li><a href="/dependencies-of/x/[email protected]/mod.ts?rankdir=LR">deno.land/x/[email protected]/mod.ts</a> (minimal)</li>
7580
<li><a href="/dependencies-of/x/[email protected]/mod.ts">deno.land/x/[email protected]/mod.ts</a> (uses NPM packages via esm.sh)</li>

0 commit comments

Comments
 (0)