@ai-markdown/core 3.0.0-beta.1 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -15
- package/dist/index.d.ts +25 -15
- package/dist/index.dev.cjs +5 -0
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +5 -0
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/package.json +13 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import * as hast from 'hast';
|
|
2
1
|
import { Element, RootContent, Root as Root$1, Nodes } from 'hast';
|
|
3
|
-
import * as mdast from 'mdast';
|
|
4
2
|
import { Root } from 'mdast';
|
|
5
3
|
import { Registry, ChunkData, PipelineOptions, AdvanceOptions } from '@ai-markdown/engine';
|
|
6
4
|
export { isFootnoteSection } from '@ai-markdown/engine';
|
|
@@ -228,6 +226,7 @@ declare function buildBlocks(mdast: Root, hast: Root$1, source: string, options?
|
|
|
228
226
|
*/
|
|
229
227
|
declare function computeBlockFingerprint(taintLabels: NonNullable<BlockInfo['taintLabels']>, registry: Registry, thisChunkSym: symbol, clobberPrefix: string): string;
|
|
230
228
|
|
|
229
|
+
type BlockPlanner = (mdast: Root, hast: Root$1, source: string, options?: BuildBlocksOptions) => BuildBlocksResult;
|
|
231
230
|
/** Reuse the engine's retained prefix plans, including reference blocks.
|
|
232
231
|
* Reference prefixes require full-document context when planning the tail.
|
|
233
232
|
* Raw HTML and definition regions retain complete planning: their ownership
|
|
@@ -235,7 +234,7 @@ declare function computeBlockFingerprint(taintLabels: NonNullable<BlockInfo['tai
|
|
|
235
234
|
* guesses, establish which trees the incremental engine actually retained.
|
|
236
235
|
* Top-level traversal remains O(blocks); reference context still visits the
|
|
237
236
|
* full mdast when needed, while per-block HAST planning is tail-only. */
|
|
238
|
-
declare function createBlockPlanner():
|
|
237
|
+
declare function createBlockPlanner(): BlockPlanner;
|
|
239
238
|
|
|
240
239
|
/** Minimal write capability; registration and cleanup remain with the adapter. */
|
|
241
240
|
interface ContributionRegistry {
|
|
@@ -261,14 +260,15 @@ interface ContributionOptions {
|
|
|
261
260
|
* validate definition bodies after a plugin or schema change. */
|
|
262
261
|
chain: readonly unknown[];
|
|
263
262
|
}
|
|
263
|
+
interface ContributionSession {
|
|
264
|
+
commit(options: ContributionOptions): void;
|
|
265
|
+
}
|
|
264
266
|
/** Create one contribution publisher per mounted chunk.
|
|
265
267
|
* Call commit only in the host's commit/effect phase, after registration.
|
|
266
268
|
* Constructing a session does not register or publish anything. A discarded
|
|
267
269
|
* render must never call commit. The host owns registration and cleanup.
|
|
268
270
|
*/
|
|
269
|
-
declare function createContributionSession():
|
|
270
|
-
commit({ pipeline, ownLabels, registry, targetPhantoms, sym, clobberPrefix, chain }: ContributionOptions): void;
|
|
271
|
-
};
|
|
271
|
+
declare function createContributionSession(): ContributionSession;
|
|
272
272
|
|
|
273
273
|
/**
|
|
274
274
|
* Turn-taking coordinator for smooth-streaming chunks that share a
|
|
@@ -426,7 +426,7 @@ declare function buildAggregateTree(registry: Registry, clobberPrefix: string, p
|
|
|
426
426
|
* Copies exactly what the render-time mutators touch — every node object,
|
|
427
427
|
* its `children` array (the allow/disallow filters splice it), and its
|
|
428
428
|
* `properties` object (`urlTransform` overwrites `href`/`src`) — while
|
|
429
|
-
* SHARING `position`,
|
|
429
|
+
* SHARING `position`, arbitrary nested plugin data, string values, and individual property values
|
|
430
430
|
* by reference. This is both cheaper than a JSON round-trip (no string
|
|
431
431
|
* intermediate; `position` objects, typically over half of a serialized
|
|
432
432
|
* hast, are never materialized) and exact for any tree the pipeline
|
|
@@ -438,6 +438,22 @@ declare function buildAggregateTree(registry: Registry, clobberPrefix: string, p
|
|
|
438
438
|
/** See module docs. Safe for any hast node union member. */
|
|
439
439
|
declare function cloneHastForRender<T extends Nodes>(node: T): T;
|
|
440
440
|
|
|
441
|
+
/** Per-consumer parse state and full/incremental fallback policy.
|
|
442
|
+
* The host decides whether a next frame is expected (false for SSR), owns
|
|
443
|
+
* this session, and resets it when render policy invalidates retained trees.
|
|
444
|
+
* Parsing does not register chunks or publish document contributions.
|
|
445
|
+
*/
|
|
446
|
+
|
|
447
|
+
interface PipelineTrees {
|
|
448
|
+
mdast: Root;
|
|
449
|
+
hast: Root$1;
|
|
450
|
+
}
|
|
451
|
+
interface PipelineSession {
|
|
452
|
+
/** Drop retained incremental state. Does not dispose host subscriptions. */
|
|
453
|
+
reset(): void;
|
|
454
|
+
/** Read-only borrowed trees: clone before destructive rendering. */
|
|
455
|
+
parse(options: PipelineFrameOptions): PipelineTrees;
|
|
456
|
+
}
|
|
441
457
|
type RemarkRehypeOptions = NonNullable<PipelineOptions['remarkRehypeOptions']>;
|
|
442
458
|
interface PipelineFrameOptions {
|
|
443
459
|
content: string;
|
|
@@ -457,13 +473,7 @@ interface PipelineFrameOptions {
|
|
|
457
473
|
defListEnabled: boolean;
|
|
458
474
|
measure?: AdvanceOptions['measure'];
|
|
459
475
|
}
|
|
460
|
-
declare function createPipelineSession():
|
|
461
|
-
reset(): void;
|
|
462
|
-
parse({ content, targetPhantoms, remarkPlugins, rehypePlugins, remarkRehypeOptions, handlers, preserveForBodyHarvest, documentId, provenance, incrementalParse, defListEnabled, measure: measureHere, }: PipelineFrameOptions): {
|
|
463
|
-
mdast: mdast.Root;
|
|
464
|
-
hast: hast.Root;
|
|
465
|
-
};
|
|
466
|
-
};
|
|
476
|
+
declare function createPipelineSession(): PipelineSession;
|
|
467
477
|
|
|
468
478
|
interface DefinitionLabels {
|
|
469
479
|
footnoteLabels: ReadonlySet<string>;
|
|
@@ -494,4 +504,4 @@ type ContributionPolicyInputs = Pick<PipelineFrameOptions, 'remarkPlugins' | 're
|
|
|
494
504
|
*/
|
|
495
505
|
declare function buildContributionChain(inputs: ContributionPolicyInputs): readonly unknown[];
|
|
496
506
|
|
|
497
|
-
export { type BlockInfo, type BuildBlocksOptions, type BuildBlocksResult, type ContributionOptions, type ContributionPolicyInputs, type ContributionRegistry, type CoordinationPolicy, type DefinitionLabels, type GateWarnVerdict, type PhantomTargets, type PipelineFrameOptions, type RenderItem, type SmoothCoordinator, type TailSignal, buildAggregateTree, buildBlocks, buildContributionChain, cloneHastForRender, computeBlockFingerprint, computeHtmlBlockDigest, computeHtmlBlockDigestWithExtent, createBlockPlanner, createContributionSession, createPipelineSession, createSmoothCoordinator, deriveCoordinationPolicy, derivePhantomTargets, deriveTailSignal, evaluateGateWarn, hasMdastSource };
|
|
507
|
+
export { type BlockInfo, type BlockPlanner, type BuildBlocksOptions, type BuildBlocksResult, type ContributionOptions, type ContributionPolicyInputs, type ContributionRegistry, type ContributionSession, type CoordinationPolicy, type DefinitionLabels, type GateWarnVerdict, type PhantomTargets, type PipelineFrameOptions, type PipelineSession, type PipelineTrees, type RenderItem, type SmoothCoordinator, type TailSignal, buildAggregateTree, buildBlocks, buildContributionChain, cloneHastForRender, computeBlockFingerprint, computeHtmlBlockDigest, computeHtmlBlockDigestWithExtent, createBlockPlanner, createContributionSession, createPipelineSession, createSmoothCoordinator, deriveCoordinationPolicy, derivePhantomTargets, deriveTailSignal, evaluateGateWarn, hasMdastSource };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import * as hast from 'hast';
|
|
2
1
|
import { Element, RootContent, Root as Root$1, Nodes } from 'hast';
|
|
3
|
-
import * as mdast from 'mdast';
|
|
4
2
|
import { Root } from 'mdast';
|
|
5
3
|
import { Registry, ChunkData, PipelineOptions, AdvanceOptions } from '@ai-markdown/engine';
|
|
6
4
|
export { isFootnoteSection } from '@ai-markdown/engine';
|
|
@@ -228,6 +226,7 @@ declare function buildBlocks(mdast: Root, hast: Root$1, source: string, options?
|
|
|
228
226
|
*/
|
|
229
227
|
declare function computeBlockFingerprint(taintLabels: NonNullable<BlockInfo['taintLabels']>, registry: Registry, thisChunkSym: symbol, clobberPrefix: string): string;
|
|
230
228
|
|
|
229
|
+
type BlockPlanner = (mdast: Root, hast: Root$1, source: string, options?: BuildBlocksOptions) => BuildBlocksResult;
|
|
231
230
|
/** Reuse the engine's retained prefix plans, including reference blocks.
|
|
232
231
|
* Reference prefixes require full-document context when planning the tail.
|
|
233
232
|
* Raw HTML and definition regions retain complete planning: their ownership
|
|
@@ -235,7 +234,7 @@ declare function computeBlockFingerprint(taintLabels: NonNullable<BlockInfo['tai
|
|
|
235
234
|
* guesses, establish which trees the incremental engine actually retained.
|
|
236
235
|
* Top-level traversal remains O(blocks); reference context still visits the
|
|
237
236
|
* full mdast when needed, while per-block HAST planning is tail-only. */
|
|
238
|
-
declare function createBlockPlanner():
|
|
237
|
+
declare function createBlockPlanner(): BlockPlanner;
|
|
239
238
|
|
|
240
239
|
/** Minimal write capability; registration and cleanup remain with the adapter. */
|
|
241
240
|
interface ContributionRegistry {
|
|
@@ -261,14 +260,15 @@ interface ContributionOptions {
|
|
|
261
260
|
* validate definition bodies after a plugin or schema change. */
|
|
262
261
|
chain: readonly unknown[];
|
|
263
262
|
}
|
|
263
|
+
interface ContributionSession {
|
|
264
|
+
commit(options: ContributionOptions): void;
|
|
265
|
+
}
|
|
264
266
|
/** Create one contribution publisher per mounted chunk.
|
|
265
267
|
* Call commit only in the host's commit/effect phase, after registration.
|
|
266
268
|
* Constructing a session does not register or publish anything. A discarded
|
|
267
269
|
* render must never call commit. The host owns registration and cleanup.
|
|
268
270
|
*/
|
|
269
|
-
declare function createContributionSession():
|
|
270
|
-
commit({ pipeline, ownLabels, registry, targetPhantoms, sym, clobberPrefix, chain }: ContributionOptions): void;
|
|
271
|
-
};
|
|
271
|
+
declare function createContributionSession(): ContributionSession;
|
|
272
272
|
|
|
273
273
|
/**
|
|
274
274
|
* Turn-taking coordinator for smooth-streaming chunks that share a
|
|
@@ -426,7 +426,7 @@ declare function buildAggregateTree(registry: Registry, clobberPrefix: string, p
|
|
|
426
426
|
* Copies exactly what the render-time mutators touch — every node object,
|
|
427
427
|
* its `children` array (the allow/disallow filters splice it), and its
|
|
428
428
|
* `properties` object (`urlTransform` overwrites `href`/`src`) — while
|
|
429
|
-
* SHARING `position`,
|
|
429
|
+
* SHARING `position`, arbitrary nested plugin data, string values, and individual property values
|
|
430
430
|
* by reference. This is both cheaper than a JSON round-trip (no string
|
|
431
431
|
* intermediate; `position` objects, typically over half of a serialized
|
|
432
432
|
* hast, are never materialized) and exact for any tree the pipeline
|
|
@@ -438,6 +438,22 @@ declare function buildAggregateTree(registry: Registry, clobberPrefix: string, p
|
|
|
438
438
|
/** See module docs. Safe for any hast node union member. */
|
|
439
439
|
declare function cloneHastForRender<T extends Nodes>(node: T): T;
|
|
440
440
|
|
|
441
|
+
/** Per-consumer parse state and full/incremental fallback policy.
|
|
442
|
+
* The host decides whether a next frame is expected (false for SSR), owns
|
|
443
|
+
* this session, and resets it when render policy invalidates retained trees.
|
|
444
|
+
* Parsing does not register chunks or publish document contributions.
|
|
445
|
+
*/
|
|
446
|
+
|
|
447
|
+
interface PipelineTrees {
|
|
448
|
+
mdast: Root;
|
|
449
|
+
hast: Root$1;
|
|
450
|
+
}
|
|
451
|
+
interface PipelineSession {
|
|
452
|
+
/** Drop retained incremental state. Does not dispose host subscriptions. */
|
|
453
|
+
reset(): void;
|
|
454
|
+
/** Read-only borrowed trees: clone before destructive rendering. */
|
|
455
|
+
parse(options: PipelineFrameOptions): PipelineTrees;
|
|
456
|
+
}
|
|
441
457
|
type RemarkRehypeOptions = NonNullable<PipelineOptions['remarkRehypeOptions']>;
|
|
442
458
|
interface PipelineFrameOptions {
|
|
443
459
|
content: string;
|
|
@@ -457,13 +473,7 @@ interface PipelineFrameOptions {
|
|
|
457
473
|
defListEnabled: boolean;
|
|
458
474
|
measure?: AdvanceOptions['measure'];
|
|
459
475
|
}
|
|
460
|
-
declare function createPipelineSession():
|
|
461
|
-
reset(): void;
|
|
462
|
-
parse({ content, targetPhantoms, remarkPlugins, rehypePlugins, remarkRehypeOptions, handlers, preserveForBodyHarvest, documentId, provenance, incrementalParse, defListEnabled, measure: measureHere, }: PipelineFrameOptions): {
|
|
463
|
-
mdast: mdast.Root;
|
|
464
|
-
hast: hast.Root;
|
|
465
|
-
};
|
|
466
|
-
};
|
|
476
|
+
declare function createPipelineSession(): PipelineSession;
|
|
467
477
|
|
|
468
478
|
interface DefinitionLabels {
|
|
469
479
|
footnoteLabels: ReadonlySet<string>;
|
|
@@ -494,4 +504,4 @@ type ContributionPolicyInputs = Pick<PipelineFrameOptions, 'remarkPlugins' | 're
|
|
|
494
504
|
*/
|
|
495
505
|
declare function buildContributionChain(inputs: ContributionPolicyInputs): readonly unknown[];
|
|
496
506
|
|
|
497
|
-
export { type BlockInfo, type BuildBlocksOptions, type BuildBlocksResult, type ContributionOptions, type ContributionPolicyInputs, type ContributionRegistry, type CoordinationPolicy, type DefinitionLabels, type GateWarnVerdict, type PhantomTargets, type PipelineFrameOptions, type RenderItem, type SmoothCoordinator, type TailSignal, buildAggregateTree, buildBlocks, buildContributionChain, cloneHastForRender, computeBlockFingerprint, computeHtmlBlockDigest, computeHtmlBlockDigestWithExtent, createBlockPlanner, createContributionSession, createPipelineSession, createSmoothCoordinator, deriveCoordinationPolicy, derivePhantomTargets, deriveTailSignal, evaluateGateWarn, hasMdastSource };
|
|
507
|
+
export { type BlockInfo, type BlockPlanner, type BuildBlocksOptions, type BuildBlocksResult, type ContributionOptions, type ContributionPolicyInputs, type ContributionRegistry, type ContributionSession, type CoordinationPolicy, type DefinitionLabels, type GateWarnVerdict, type PhantomTargets, type PipelineFrameOptions, type PipelineSession, type PipelineTrees, type RenderItem, type SmoothCoordinator, type TailSignal, buildAggregateTree, buildBlocks, buildContributionChain, cloneHastForRender, computeBlockFingerprint, computeHtmlBlockDigest, computeHtmlBlockDigestWithExtent, createBlockPlanner, createContributionSession, createPipelineSession, createSmoothCoordinator, deriveCoordinationPolicy, derivePhantomTargets, deriveTailSignal, evaluateGateWarn, hasMdastSource };
|
package/dist/index.dev.cjs
CHANGED
|
@@ -633,6 +633,11 @@ function cloneHastForRender(node) {
|
|
|
633
633
|
if (withProperties.properties) {
|
|
634
634
|
withProperties.properties = { ...withProperties.properties };
|
|
635
635
|
}
|
|
636
|
+
if (copy.data) {
|
|
637
|
+
copy.data = { ...copy.data };
|
|
638
|
+
const data = copy.data;
|
|
639
|
+
if (data.originalUrls) data.originalUrls = { ...data.originalUrls };
|
|
640
|
+
}
|
|
636
641
|
return copy;
|
|
637
642
|
}
|
|
638
643
|
|