Repository navigation
feat(api): expose resolved asset declarations to post-build hooks - #231
Merged
Merged
Conversation
Member
|
Nice catch on the reading time calculation. Thanks for the fix and contribution! |
Member
|
Hey @justinTM, your commits landed with an email which isn't linked to your GitHub account, so you're not showing up in the repo contributors list – though we absolutely recognise your contribution. If you'd like your profile to show up on docmd's repo page and website, just add that email under GitHub email settings. No rush! |
mgks
added a commit
that referenced
this pull request
Sep 22, 2026
feat(api): expose resolved asset declarations to post-build hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #230.
Why
Post-build integrations can inspect
outputDir, but a directory walk cannotrecover external URLs, page conditions, injection position, load priority, or
which template/plugin declared an asset.
DocMD also resolved plugin assets once for copying and again while rendering.
A stateful or asynchronous
getAssets()hook could therefore describe onefile to the copier and another to the generated page.
The first consumer is a Google Apps Script packager, but the same seam is
useful for offline archives, embedded viewers, and other non-directory hosts.
What changed
onConfigResolved.readonly ResolvedAsset[]for copying, page tags, andPostBuildContext.resolvedAssets.src/dest/locationdefaults and precedence while makingthe documented
path/url/positionform work consistently in both copyand render stages.
getAssets()type to its existing async runtime support.On full builds, the one resolution still happens after core/theme/user asset
preparation—the same boundary as the existing first copy-stage call.
flowchart TB subgraph CHANGE["The change"] direction TB subgraph RESOLUTION["Resolve once"] direction LR DECL["Template and plugin declarations"]:::context BUILD["buildSite()"]:::modified RESOLVE(["resolveBuildAssets()"]) ARRAY(["One frozen declaration catalog — not an output manifest"]) REPEAT["Repeated per-stage resolution"]:::removed DECL --> RESOLVE BUILD -->|"once, after onConfigResolved"| RESOLVE RESOLVE -->|"returns frozen"| ARRAY RESOLVE -. "replaces" .-> REPEAT end subgraph USES["Reuse the same array"] direction LR COPY["Copy local files"]:::modified TAGS["Emit page tags"]:::modified POST["Expose to post-build hooks"]:::modified COPY ~~~ TAGS ~~~ POST ARRAY -->|"copy files"| COPY ARRAY -->|"emit page tags"| TAGS ARRAY -->|"same array"| POST end subgraph API["Public API"] direction LR TYPES["types.ts"]:::modified ENTRY["ResolvedAsset"] CONTEXT["PostBuildContext.resolvedAssets"] TYPES -->|"defines"| ENTRY TYPES -->|"exposes"| CONTEXT end ENTRY -. "describes each item" .-> ARRAY end subgraph LEGEND["Change key"] direction LR L_CONTEXT["= Context"]:::context L_MODIFIED["~ Modified"]:::modified L_NEW["+ New"]:::new L_REMOVED["- Removed"]:::removed L_CONTEXT ~~~ L_MODIFIED ~~~ L_NEW ~~~ L_REMOVED end CHANGE ~~~ LEGEND class RESOLVE,ARRAY,ENTRY,CONTEXT new classDef context fill:#F1F5F9,stroke:#64748B,color:#172033,stroke-width:2px classDef modified fill:#FFF4D6,stroke:#9A6700,color:#3D2B00,stroke-width:2px classDef new fill:#E6F4EA,stroke:#1E7A3E,color:#103A20,stroke-width:3px classDef removed fill:#FDE8E8,stroke:#B42318,color:#4A1712,stroke-width:2px,stroke-dasharray:6 3 style CHANGE fill:#F8FAFC,stroke:#94A3B8,stroke-width:1px style RESOLUTION fill:#FFFFFF,stroke:#CBD5E1,stroke-width:1px style USES fill:#FFFFFF,stroke:#CBD5E1,stroke-width:1px style API fill:#FFFFFF,stroke:#CBD5E1,stroke-width:1px style LEGEND fill:#FFFFFF,stroke:#CBD5E1,stroke-width:1pxContract boundary
resolvedAssetsdescribes the plugin and template declarations the currentasset pipeline understands. File entries identify the source and generated-site
path; URL entries identify an uncopied URL/path reference. Both include
effective rendering metadata and declaration provenance.
It is deliberately not a complete output manifest. Core UI, theme, and user
asset directories are copied separately, and post-build hooks can create more
files after this value is assembled. Existing reserved
Asset.inlineandAsset.hashfields remain outside the current pipeline and this new view.Declaration order and duplicates are preserved; consumers must not infer final
tag order or unique output paths from the array.
Integrations should read emitted bytes from
outputDir/outputPath, since DocMDmay transform a source while copying it.
Legacy local-file declarations retain their existing defaults and precedence.
The shared resolver also fixes two inconsistencies in the typed contract:
canonical
path/url/positiondeclarations now reach both stages, andlocation: "none"suppresses URL-only tags as it already did for local assets.Verification
pnpm -r run buildDOCMD_TEST_CACHE_OFF=1 node tests/runner.js --only=plugin-assets-pipeline— 27 passed, 0 failed
env -u NO_COLOR DOCMD_TEST_CACHE_OFF=1 pnpm verify --skip-setuppnpm lintnon-merge proof at
c494325e,pinned to feature commit
53dd43f7— all three jobs passed