Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -213,8 +213,13 @@ jobs:
file: api/Dockerfile
push: true
tags: ${{ env.API_IMAGE_ID_BASE }}:${{ github.sha }}
cache-from: type=gha,scope=docker-api
cache-to: type=gha,mode=max,scope=docker-api
# Use a registry cache (not type=gha): GHA caches are branch-scoped,
# and merge_group runs execute on transient refs, so a gha cache
# written there is never readable by later runs. A registry cache is
# shared across all refs. image-manifest/oci-mediatypes are required
# for Artifact Registry to accept the cache manifest.
cache-from: type=registry,ref=${{ env.API_IMAGE_ID_BASE }}:buildcache
cache-to: type=registry,ref=${{ env.API_IMAGE_ID_BASE }}:buildcache,mode=max,image-manifest=true,oci-mediatypes=true

- name: Set api_image_id output
id: api_image_id
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/Cargo.toml
Original file line numberDiff line numberDiff line change
Expand Up@@ -95,10 +95,10 @@ flate2 = "1"
thiserror = "2"
async-tar = "0.4.2"
async-compression = { version = "0.4", features = ["futures-io", "gzip"] }
deno_graph = "=0.110.2"
deno_graph = "=0.111.0"
deno_ast = { version = "0.53.0", features = ["view"] }
# sync with frontend/deno.json
deno_doc = { version = "=0.206.0", features = ["comrak"] }
deno_doc = { version = "=0.207.0", features = ["comrak"] }
deno_error = "0.7.0"
comrak = { version = "0.29.0", default-features = false }
ammonia = "4.0.0"
Expand Down
2 changes: 0 additions & 2 deletions api/src/analysis.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -164,7 +164,6 @@ async fn analyze_package_inner(
skip_dynamic_deps: false,
module_info_cacher: Default::default(),
unstable_bytes_imports: false,
unstable_text_imports: false,
jsr_metadata_store: None,
unstable_css_imports: false,
unstable_config_imports: false,
Expand DownExpand Up@@ -710,7 +709,6 @@ async fn rebuild_npm_tarball_inner(
skip_dynamic_deps: false,
module_info_cacher: Default::default(),
unstable_bytes_imports: false,
unstable_text_imports: false,
jsr_metadata_store: None,
unstable_css_imports: false,
unstable_config_imports: false,
Expand Down
1 change: 0 additions & 1 deletion api/src/api/package.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -2624,7 +2624,6 @@ async fn analyze_deps_tree(
skip_dynamic_deps: false,
module_info_cacher: Default::default(),
unstable_bytes_imports: false,
unstable_text_imports: false,
jsr_metadata_store: None,

unstable_css_imports: false,
Expand Down
57 changes: 26 additions & 31 deletions frontend/routes/package/(_islands)/LocalSymbolSearch.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,11 +14,7 @@ import {
import { Highlight, type Position } from "@orama/highlight";
import { api, path } from "../../../utils/api.ts";
import { useMacLike } from "../../../utils/os.ts";
import type {
AllSymbolsCtx,
AllSymbolsItemCtx,
SectionContentNamespaceSectionCtx,
} from "@deno/doc/html-types";
import type { AllSymbolsCtx, AllSymbolsItemCtx } from "@deno/doc/html-types";
import { renderToString } from "preact-render-to-string";
import { AllSymbols } from "../../../components/doc/AllSymbols.tsx";

Expand DownExpand Up@@ -113,11 +109,8 @@ export function LocalSymbolSearch(

for (const entrypoint of searchContent.value!.entrypoints) {
for (const kindGroup of entrypoint.module_doc.sections.sections) {
for (
const symbol
of (kindGroup.content as SectionContentNamespaceSectionCtx)
.content
) {
if (kindGroup.content.kind !== "namespace_section") continue;
for (const symbol of kindGroup.content.content) {
searchItems.push({
name: symbol.name,
symbolName: symbol.name,
Expand DownExpand Up@@ -202,32 +195,34 @@ export function LocalSymbolSearch(
.map((entrypoint) => {
const filteredSections = entrypoint.module_doc.sections.sections
.map((kindGroup) => {
const filteredContent =
(kindGroup.content as SectionContentNamespaceSectionCtx).content
.map((symbol) => {
const symbolMatches = hitNames.has(symbol.name);
const matchingSubitems = symbol.subitems.filter((subitem) =>
hitNames.has(subitem.title)
);

if (!symbolMatches && matchingSubitems.length === 0) {
return null;
}

return {
...symbol,
subitems: symbolMatches
? symbol.subitems
: matchingSubitems,
};
})
.filter(Boolean);
const content = kindGroup.content;
if (content.kind !== "namespace_section") return null;

const filteredContent = content.content
.map((symbol) => {
const symbolMatches = hitNames.has(symbol.name);
const matchingSubitems = symbol.subitems.filter((subitem) =>
hitNames.has(subitem.title)
);

if (!symbolMatches && matchingSubitems.length === 0) {
return null;
}

return {
...symbol,
subitems: symbolMatches
? symbol.subitems
: matchingSubitems,
};
})
.filter(Boolean);

if (filteredContent.length === 0) return null;

return {
...kindGroup,
content: { ...kindGroup.content, content: filteredContent },
content: { ...content, content: filteredContent },
};
})
.filter(Boolean);
Expand Down
13 changes: 13 additions & 0 deletions frontend/routes/package/index.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,6 +44,19 @@ export default define.page<typeof handler>(function PackagePage(
showProvenanceBadge
/>
)
: data.selectedVersion
? (
<div class="mt-8 text-tertiary text-center">
Documentation is only available for the{" "}
<a
class="link"
href={`/@${data.package.scope}/${data.package.name}`}
>
latest version
</a>{" "}
of a package.
</div>
)
: (
<div class="mt-8 text-tertiary text-center">
This package has not published{" "}
Expand Down
37 changes: 29 additions & 8 deletions frontend/utils/data.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -127,14 +127,35 @@ export async function packageDataWithDocs(
if (pkgDocsResp.code === "scopeNotFound") return null;
if (pkgDocsResp.code === "packageNotFound") return null;
if (pkgDocsResp.code === "docsOnlyForLatestVersion") {
// Docs are only served for the latest version; redirect to the
// canonical (versionless) docs URL for the latest version.
return new Response(null, {
status: 302,
headers: {
Location: `/@${scope}/${pkg}/doc${compileDocsRequestPath(docs)}`,
},
});
if ("entrypoint" in docs || "all_symbols" in docs) {
// Docs are only served for the latest version; redirect to the
// canonical (versionless) docs URL for the latest version.
return new Response(null, {
status: 302,
headers: {
Location: `/@${scope}/${pkg}/doc${compileDocsRequestPath(docs)}`,
},
});
}

// The package overview page of a non-latest version: render it
// without docs instead of redirecting away from the version.
const pkgVersionResp = await state.api.get<PackageVersionWithUser>(
path`/scopes/${scope}/packages/${pkg}/versions/${version!}`,
);
if (!pkgVersionResp.ok) {
if (pkgVersionResp.code === "packageVersionNotFound") return null;
if (pkgVersionResp.code === "scopeNotFound") return null;
if (pkgVersionResp.code === "packageNotFound") return null;
assertOk(pkgVersionResp);
}
return {
...data,
kind: "content",
selectedVersion: pkgVersionResp.data,
selectedVersionIsLatestUnyanked: false,
docs: null,
};
}
if (pkgDocsResp.code === "entrypointOrSymbolNotFound") {
// redirect to all symbols page if there is no default entrypoint
Expand Down
Loading