Skip to content

docs(GltfLoader): document Promise requirement, rejection propagation, and add @param/@returns to resolveUri#408

Merged
ormidales merged 2 commits into
1.1.17from
copilot/update-gltfloader-jsdoc-for-resolveuri
Apr 2, 2026
Merged

docs(GltfLoader): document Promise requirement, rejection propagation, and add @param/@returns to resolveUri#408
ormidales merged 2 commits into
1.1.17from
copilot/update-gltfloader-jsdoc-for-resolveuri

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

The resolveUri JSDoc was silent on the async contract: it didn't state the callback must return a Promise, didn't document that rejections propagate out of loadGltf, and had no @param or @returns tags.

src/core/GltfLoader.ts

  • Added explicit statement that the callback must return a Promise
  • Documented that rejections propagate directly from loadGltf
  • Added @param uri — incorporates the previously orphaned percent-decoding failure note
  • Added @returnsPromise<ArrayBuffer> resolving to raw buffer bytes
  • Reorganized body for logical flow: security warning → description → contract → param/returns
/**
 * @security Never perform additional URI decoding or resolution inside this callback.
 * The loader has already validated and best-effort percent-decoded the URI;
 * re-decoding may re-introduce path-traversal or SSRF vulnerabilities.
 *
 * Optional async callback invoked to resolve external buffer URIs referenced by the
 * glTF asset (non-`data:` references found in `buffers[].uri`).
 * Required when loading plain `.gltf` files that reference external `.bin` files.
 *
 * The callback **must** return a `Promise` that resolves to the raw bytes of the
 * referenced buffer. Rejections propagate directly from `loadGltf`.
 *
 * @param uri The raw URI string extracted from the glTF JSON, already validated
 *   against the loader's URI whitelist and best-effort percent-decoded. If
 *   percent-decoding fails due to invalid percent-encoding, the original URI string
 *   (with invalid sequences preserved) may be passed instead. Do **not** perform
 *   additional URI resolution or decoding inside this callback.
 * @returns A `Promise` resolving to the buffer's raw bytes as an `ArrayBuffer`.
 */
resolveUri?: (uri: string) => Promise<ArrayBuffer>;

tests/gltf.test.ts

Four new JSDoc-contract tests added to the existing GltfLoaderOptions JSDoc describe block, asserting that the source contains the Promise requirement, rejection propagation statement, @param uri, and @returns tags.

…opagation, @param and @returns tags

Agent-Logs-Url: https://github.com/ormidales/microgl/sessions/f9487d93-c163-439a-b9f4-0e3dcc65f76f

Co-authored-by: ormidales <46538211+ormidales@users.noreply.github.com>
Copilot AI changed the title [WIP] Update JSDoc for resolveUri to document async/Promise requirement docs(GltfLoader): document Promise requirement, rejection propagation, and add @param/@returns to resolveUri Apr 2, 2026
Copilot AI requested a review from ormidales April 2, 2026 13:11
@ormidales ormidales added this to the v1.1.17 milestone Apr 2, 2026
@ormidales ormidales marked this pull request as ready for review April 2, 2026 13:23
Copilot AI review requested due to automatic review settings April 2, 2026 13:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves the GltfLoaderOptions.resolveUri documentation to clearly specify its async Promise contract, how failures propagate, and to add explicit @param/@returns tags; adds tests to lock in those documentation requirements.

Changes:

  • Expanded resolveUri JSDoc to require a Promise<ArrayBuffer>, document rejection propagation, and add @param uri / @returns.
  • Reorganized the JSDoc block for clearer security → contract → tags flow.
  • Added tests asserting the presence of the new JSDoc contract statements and tags in the source.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/core/GltfLoader.ts Updates resolveUri JSDoc contract (Promise requirement, rejection propagation, param/returns).
tests/gltf.test.ts Adds JSDoc “contract” tests that assert the updated documentation content is present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/core/GltfLoader.ts
@ormidales ormidales merged commit 41ea5aa into 1.1.17 Apr 2, 2026
6 checks passed
@ormidales ormidales deleted the copilot/update-gltfloader-jsdoc-for-resolveuri branch April 2, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PATCH] GltfLoader.resolveUri callback JSDoc does not document the async/Promise requirement

3 participants