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
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ import { resolveStoryRuntime } from '../../document-api-adapters/story-runtime/r
import { BODY_STORY_KEY, buildStoryKey, parseStoryKey } from '../../document-api-adapters/story-runtime/story-key.js';
import { createStoryEditor } from '../story-editor-factory.js';
import { buildEndnoteBlocks } from './layout/EndnotesBuilder.js';
import { toFlowBlocks, ConverterContext, FlowBlockCache } from '@superdoc/pm-adapter';
import { toFlowBlocks, FlowBlockCache } from '@superdoc/pm-adapter';
import type { ConverterContext } from '@superdoc/pm-adapter/converter-context.js';
import { readSettingsRoot, readDefaultTableStyle } from '../../document-api-adapters/document-settings.js';
import {
incrementalLayout,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { EditorState } from 'prosemirror-state';
import type { FlowBlock, Run as LayoutRun, TextRun } from '@superdoc/contracts';
import { toFlowBlocks, type ConverterContext } from '@superdoc/pm-adapter';
import { toFlowBlocks } from '@superdoc/pm-adapter';
import type { ConverterContext } from '@superdoc/pm-adapter/converter-context.js';
import { SUBSCRIPT_SUPERSCRIPT_SCALE } from '@superdoc/pm-adapter/constants.js';

import type { ProseMirrorJSON } from '../../types/EditorTypes.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

import type { EditorState } from 'prosemirror-state';
import type { FlowBlock } from '@superdoc/contracts';
import { toFlowBlocks, type ConverterContext } from '@superdoc/pm-adapter';
import { toFlowBlocks } from '@superdoc/pm-adapter';
import type { ConverterContext } from '@superdoc/pm-adapter/converter-context.js';
import { SUBSCRIPT_SUPERSCRIPT_SCALE } from '@superdoc/pm-adapter/constants.js';

import type { ProseMirrorJSON } from '../../types/EditorTypes.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect, vi } from 'vitest';
import type { EditorState } from 'prosemirror-state';
import { buildFootnotesInput, type ConverterLike } from '../layout/FootnotesBuilder.js';
import type { ConverterContext } from '@superdoc/pm-adapter';
import type { ConverterContext } from '@superdoc/pm-adapter/converter-context.js';
import { SUBSCRIPT_SUPERSCRIPT_SCALE } from '@superdoc/pm-adapter/constants.js';
import { toFlowBlocks } from '@superdoc/pm-adapter';

Expand Down
2 changes: 2 additions & 0 deletions packages/superdoc/scripts/audit-declarations.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ if (!fs.existsSync(distRoot)) {
const RELOCATED_PACKAGES = [
'@superdoc/document-api',
'@superdoc/contracts',
'@superdoc/dom-contract',
'@superdoc/layout-bridge',
'@superdoc/painter-dom',
'@superdoc/pm-adapter',
];

// Specifiers that may appear as bare imports in published d.ts files even
Expand Down
11 changes: 11 additions & 0 deletions packages/superdoc/scripts/ensure-types.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,21 @@ function rewriteDocApiPaths(fileContent, filePath) {
// their declarations into superdoc's dist (via vite-plugin-dts include)
// and redirect bare specifiers in emitted .d.ts files to relative
// paths the consumer can resolve.
//
// SD-2893 note for pm-adapter: only specific type subpaths are
// relocated (see vite.config.js include list). A bare `@superdoc/pm-adapter`
// specifier would rewrite to a relative path that does not exist in dist.
// The audit gate (RELOCATED_PACKAGES in audit-declarations.cjs) rejects
// any unrewritten bare specifier at build time, so this is a build-time
// failure rather than a silent consumer break. If a future public type
// genuinely needs the pm-adapter barrel, widen the vite include and the
// shim drain in lockstep.
const RELOCATION_RULES = [
{ pkg: '@superdoc/contracts', distEntry: 'layout-engine/contracts/src/index.d.ts' },
{ pkg: '@superdoc/dom-contract', distEntry: 'layout-engine/dom-contract/src/index.d.ts' },
{ pkg: '@superdoc/layout-bridge', distEntry: 'layout-engine/layout-bridge/src/index.d.ts' },
{ pkg: '@superdoc/painter-dom', distEntry: 'layout-engine/painters/dom/src/index.d.ts' },
{ pkg: '@superdoc/pm-adapter', distEntry: 'layout-engine/pm-adapter/src/index.d.ts' },
];

function makeRelocationRewriter({ pkg, distEntry }) {
Expand Down
5 changes: 4 additions & 1 deletion packages/superdoc/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"../super-editor/src",
"../document-api/src",
"../layout-engine/contracts/src",
"../layout-engine/dom-contract/src",
"../layout-engine/layout-bridge/src",
"../layout-engine/painters/dom/src"
"../layout-engine/painters/dom/src",
"../layout-engine/pm-adapter/src/converter-context.ts",
"../layout-engine/pm-adapter/src/sections/types.ts"
]
}
7 changes: 7 additions & 0 deletions packages/superdoc/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,15 @@ export default defineConfig(({ mode, command }) => {
// rewrite step in ensure-types can redirect bare specifiers to
// local relative paths. Same pattern as @superdoc/document-api.
'../layout-engine/contracts/src/**/*',
'../layout-engine/dom-contract/src/**/*',
'../layout-engine/layout-bridge/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
// internal packages that would re-expand the shim list. Only the
// type subpaths reachable from the public surface are relocated.
'../layout-engine/pm-adapter/src/converter-context.ts',
'../layout-engine/pm-adapter/src/sections/types.ts',
],
outDir: 'dist',
// vite-plugin-dts still gathers diagnostics for this mixed JS/Vue source
Expand Down
Loading