From 10e7ab0a8e6eed61822dd201d79c3d6ccb2193b3 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Mon, 4 May 2026 21:23:14 -0300 Subject: [PATCH 1/2] fix(types): drain shims for layout-engine and useUiFontFamily (SD-2893) Two cheap-win follow-ups to the D1 relocation. Shim count: 6 to 4. useUiFontFamily: the bare @superdoc/composables/useUiFontFamily.js specifier only appeared inside a JSDoc @example block. The example was also misleading; this composable is not exported from any public entry, so a consumer cannot use the shown import. Removing the example clears the shim without changing public API. @superdoc/layout-engine: relocate via the same D1 pattern as contracts and layout-bridge. layout-engine only imports from @superdoc/contracts (already relocated), so a full src/**/* glob is safe and does not pull additional internal packages into the declaration graph. Remaining shims: @superdoc/common, common/components/BasicUpload.vue, common/list-marker-utils, style-engine/ooxml. Each needs more evaluation than a cheap-win slice. --- .../superdoc/scripts/audit-declarations.cjs | 1 + packages/superdoc/scripts/ensure-types.cjs | 2 ++ .../superdoc/src/composables/useUiFontFamily.js | 17 ----------------- packages/superdoc/tsconfig.json | 1 + packages/superdoc/vite.config.js | 1 + 5 files changed, 5 insertions(+), 17 deletions(-) diff --git a/packages/superdoc/scripts/audit-declarations.cjs b/packages/superdoc/scripts/audit-declarations.cjs index 592a314614..93980302f1 100644 --- a/packages/superdoc/scripts/audit-declarations.cjs +++ b/packages/superdoc/scripts/audit-declarations.cjs @@ -69,6 +69,7 @@ const RELOCATION_GUARD_PACKAGES = [ '@superdoc/contracts', '@superdoc/dom-contract', '@superdoc/layout-bridge', + '@superdoc/layout-engine', '@superdoc/painter-dom', '@superdoc/pm-adapter', ]; diff --git a/packages/superdoc/scripts/ensure-types.cjs b/packages/superdoc/scripts/ensure-types.cjs index 1f5ede147d..7b0e79c828 100644 --- a/packages/superdoc/scripts/ensure-types.cjs +++ b/packages/superdoc/scripts/ensure-types.cjs @@ -219,6 +219,7 @@ const RELOCATION_RULES = [ { pkg: '@superdoc/contracts', distEntry: 'layout-engine/contracts/src/index.d.ts', matchSubpaths: true }, { pkg: '@superdoc/dom-contract', distEntry: 'layout-engine/dom-contract/src/index.d.ts', matchSubpaths: true }, { pkg: '@superdoc/layout-bridge', distEntry: 'layout-engine/layout-bridge/src/index.d.ts', matchSubpaths: true }, + { pkg: '@superdoc/layout-engine', distEntry: 'layout-engine/layout-engine/src/index.d.ts', matchSubpaths: true }, { pkg: '@superdoc/painter-dom', distEntry: 'layout-engine/painters/dom/src/index.d.ts', matchSubpaths: true }, { pkg: '@superdoc/pm-adapter/converter-context.js', @@ -241,6 +242,7 @@ const RELOCATION_GUARD_PACKAGES = [ '@superdoc/contracts', '@superdoc/dom-contract', '@superdoc/layout-bridge', + '@superdoc/layout-engine', '@superdoc/painter-dom', '@superdoc/pm-adapter', ]; diff --git a/packages/superdoc/src/composables/useUiFontFamily.js b/packages/superdoc/src/composables/useUiFontFamily.js index 824a2a95c4..76f75cdbad 100644 --- a/packages/superdoc/src/composables/useUiFontFamily.js +++ b/packages/superdoc/src/composables/useUiFontFamily.js @@ -21,23 +21,6 @@ export const DEFAULT_UI_FONT_FAMILY = 'Arial, Helvetica, sans-serif'; * * @returns {{ uiFontFamily: import('vue').ComputedRef }} An object containing: * - uiFontFamily: A computed reference to the UI font-family string - * - * @example - * // In a Vue component - * import { useUiFontFamily } from '@superdoc/composables/useUiFontFamily.js'; - * - * export default { - * setup() { - * const { uiFontFamily } = useUiFontFamily(); - * - * // Use in template or computed styles - * return { uiFontFamily }; - * } - * } - * - * @example - * // In a template - * */ export function useUiFontFamily() { const instance = getCurrentInstance(); diff --git a/packages/superdoc/tsconfig.json b/packages/superdoc/tsconfig.json index 28953bb9a9..00ea821601 100644 --- a/packages/superdoc/tsconfig.json +++ b/packages/superdoc/tsconfig.json @@ -29,6 +29,7 @@ "../layout-engine/contracts/src", "../layout-engine/dom-contract/src", "../layout-engine/layout-bridge/src", + "../layout-engine/layout-engine/src", "../layout-engine/painters/dom/src", "../layout-engine/pm-adapter/src/converter-context.ts", "../layout-engine/pm-adapter/src/sections/types.ts" diff --git a/packages/superdoc/vite.config.js b/packages/superdoc/vite.config.js index 74e572d256..f45fe8f863 100644 --- a/packages/superdoc/vite.config.js +++ b/packages/superdoc/vite.config.js @@ -132,6 +132,7 @@ export default defineConfig(({ mode, command }) => { '../layout-engine/contracts/src/**/*', '../layout-engine/dom-contract/src/**/*', '../layout-engine/layout-bridge/src/**/*', + '../layout-engine/layout-engine/src/**/*', '../layout-engine/painters/dom/src/**/*', // SD-2893: pm-adapter is included file-by-file (not via `src/**/*`) // because the full barrel pulls in @superdoc/style-engine and other From 6ceead087828522723b33ba8cfdb758b4177fa94 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Tue, 5 May 2026 08:07:00 -0300 Subject: [PATCH 2/2] fix(types): drain @superdoc/common/list-marker-utils shim (SD-2893) list-marker-utils is the only @superdoc/common subpath publicly reachable today (via painter-dom/src/utils/marker-helpers). Adding shared/common to vite-plugin-dts's include shifts the common ancestor to the repo root and reorganises the entire dist tree, so emit declarations directly via tsc in the postbuild step instead. Adds the file plus its sibling layout-constants dependency to dist/shared/common, registers an exact relocation rule, and guards the subpath against a future shim regression. The bare @superdoc/common package and other subpaths stay shimmed until separately drained. Shim count: 4 to 3. Remaining: @superdoc/common, @superdoc/common/components/BasicUpload.vue, @superdoc/style-engine/ooxml. Verified: build:es clean, declaration audit clean (8 guarded), consumer matrix 47/0/0, runtime smoke 4/4, negative test confirms the painter-dom consumer rewrites to dist/shared/common/list-marker-utils.d.ts. --- .../superdoc/scripts/audit-declarations.cjs | 1 + packages/superdoc/scripts/ensure-types.cjs | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/packages/superdoc/scripts/audit-declarations.cjs b/packages/superdoc/scripts/audit-declarations.cjs index 93980302f1..86c7326397 100644 --- a/packages/superdoc/scripts/audit-declarations.cjs +++ b/packages/superdoc/scripts/audit-declarations.cjs @@ -72,6 +72,7 @@ const RELOCATION_GUARD_PACKAGES = [ '@superdoc/layout-engine', '@superdoc/painter-dom', '@superdoc/pm-adapter', + '@superdoc/common/list-marker-utils', ]; // Specifiers that may appear as bare imports in published d.ts files even diff --git a/packages/superdoc/scripts/ensure-types.cjs b/packages/superdoc/scripts/ensure-types.cjs index 7b0e79c828..e483a21733 100644 --- a/packages/superdoc/scripts/ensure-types.cjs +++ b/packages/superdoc/scripts/ensure-types.cjs @@ -62,6 +62,41 @@ if (handwrittenCopiedSuperEditor > 0) { console.log(`[ensure-types] ✓ Copied ${handwrittenCopiedSuperEditor} hand-written .d.ts files from super-editor/src`); } +// SD-2893: emit declarations for the shared/common subpaths reachable from the +// public surface. Adding shared/ to vite-plugin-dts's `include` would shift the +// common-ancestor of all source files to the repo root and reorganise the +// entire dist tree, so we run tsc directly for just the files we relocate. +// Today: list-marker-utils plus its sibling layout-constants. Add new entries +// here in lockstep with `RELOCATION_RULES` below. +const SHARED_COMMON_DTS_TARGETS = ['list-marker-utils.ts', 'layout-constants.ts']; +{ + const { spawnSync: _spawnSync } = require('node:child_process'); + const tscBin = path.join(repoRoot, 'node_modules', '.bin', 'tsc'); + const sharedCommonDistDir = path.join(distRoot, 'shared/common'); + fs.mkdirSync(sharedCommonDistDir, { recursive: true }); + const sources = SHARED_COMMON_DTS_TARGETS.map((f) => path.join(repoRoot, 'shared/common', f)); + const tscResult = _spawnSync( + tscBin, + [ + '--declaration', + '--emitDeclarationOnly', + '--skipLibCheck', + '--target', 'ES2022', + '--module', 'ESNext', + '--moduleResolution', 'bundler', + '--outDir', sharedCommonDistDir, + '--rootDir', path.join(repoRoot, 'shared/common'), + ...sources, + ], + { stdio: 'inherit' }, + ); + if (tscResult.status !== 0) { + console.error('[ensure-types] tsc failed emitting shared/common declarations'); + process.exit(1); + } + console.log(`[ensure-types] ✓ Emitted ${SHARED_COMMON_DTS_TARGETS.length} shared/common declarations`); +} + const requiredEntryPoints = [ 'superdoc/src/index.d.ts', 'superdoc/src/super-editor.d.ts', @@ -231,6 +266,15 @@ const RELOCATION_RULES = [ distEntry: 'layout-engine/pm-adapter/src/sections/types.d.ts', matchSubpaths: false, }, + // SD-2893: list-marker-utils is the only @superdoc/common subpath publicly + // reachable today (via painter-dom). Relocate just this file so the bare + // @superdoc/common shim does not capture it; the parent @superdoc/common + // package and other subpaths stay shimmed until separately drained. + { + pkg: '@superdoc/common/list-marker-utils', + distEntry: 'shared/common/list-marker-utils.d.ts', + matchSubpaths: false, + }, ]; // Guard packages that must never fall back to `_internal-shims.d.ts`. @@ -245,6 +289,7 @@ const RELOCATION_GUARD_PACKAGES = [ '@superdoc/layout-engine', '@superdoc/painter-dom', '@superdoc/pm-adapter', + '@superdoc/common/list-marker-utils', ]; function isRelocatedSpecifier(mod) {