Skip to content

Commit 000af3e

Browse files
authored
ci(superdoc): enroll use-password-prompt.js under checkJs gate (SD-2866) (#3050)
Third file under the SD-2863 ratchet. Closes 8 errors that the probe surfaced: - The internal queue's element type lacked the `originalException` field that handleEncryptionError pushes onto each entry. Real drift: the JSDoc said `{ doc, errorCode }` but the runtime stored `{ doc, errorCode, originalException }` and the value was read again in onUnhandled. Promoted to a named QueueEntry typedef with the field properly declared. - queue.shift() returns undefined when empty; added a fast-path early return after the shift so the rest of the function can rely on a defined entry. - The lazy import of PasswordPromptSurface.vue now goes through the *.vue ambient shim added in SD-2865 and casts the default export to object before passing to markRaw(). Stacks on caio/SD-2865-checkjs-find-replace because SD-2865 introduced the *.vue shim.
1 parent cad5ff4 commit 000af3e

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

packages/superdoc/scripts/check-jsdoc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const { spawnSync } = require('child_process');
4141
const CHECKED_FILES = [
4242
'src/helpers/schema-introspection.js',
4343
'src/composables/use-find-replace.js',
44+
'src/composables/use-password-prompt.js',
4445
];
4546

4647
const packageDir = path.resolve(__dirname, '..');

packages/superdoc/src/composables/use-password-prompt.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-check
12
import { shallowRef, markRaw } from 'vue';
23

34
/** @typedef {import('../core/types').PasswordPromptConfig} PasswordPromptConfig */
@@ -41,7 +42,16 @@ const DEFAULT_TEXTS = {
4142
export function usePasswordPrompt({ getSurfaceManager, getPasswordPromptConfig, onUnhandled }) {
4243
// ---- internal state -------------------------------------------------------
4344

44-
/** @type {Array<{ doc: any, errorCode: string }>} */
45+
/**
46+
* Pending password-prompt request waiting for a free `activePrompt` slot.
47+
* `originalException` is preserved so `onUnhandled` can re-emit the host's
48+
* original exception payload verbatim if the prompt cannot render.
49+
* @typedef {Object} QueueEntry
50+
* @property {any} doc
51+
* @property {string} errorCode
52+
* @property {{ error?: Error, editor?: any }} [originalException]
53+
*/
54+
/** @type {QueueEntry[]} */
4555
const queue = [];
4656

4757
/** @type {import('vue').ShallowRef<{ doc: any, surfaceHandle: any } | null>} */
@@ -128,6 +138,7 @@ export function usePasswordPrompt({ getSurfaceManager, getPasswordPromptConfig,
128138
if (queue.length === 0) return;
129139

130140
const entry = queue.shift();
141+
if (!entry) return;
131142
showPrompt(entry).catch((err) => {
132143
// Surface errors (e.g. from a consumer's resolver or invalid config)
133144
// as console errors rather than letting them become unhandled rejections.
@@ -233,8 +244,11 @@ export function usePasswordPrompt({ getSurfaceManager, getPasswordPromptConfig,
233244
} else {
234245
// Built-in component — use ariaLabelledBy pointing to the component's
235246
// reactive heading, so the accessible name updates after a bad password
236-
// (e.g. "Password Required" → "Incorrect Password").
237-
const { default: PasswordPromptSurface } = await import('../components/surfaces/PasswordPromptSurface.vue');
247+
// (e.g. "Password Required" → "Incorrect Password"). The `.vue` shim
248+
// types the default export as `unknown`; narrow to `object` for
249+
// `markRaw()`.
250+
const mod = await import('../components/surfaces/PasswordPromptSurface.vue');
251+
const PasswordPromptSurface = /** @type {object} */ (mod.default);
238252
const surfaceId = `password-prompt-${doc.id}`;
239253
handle = manager.open({
240254
id: surfaceId,

0 commit comments

Comments
 (0)