deckjsx 0.2.1 → 0.3.1
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 +3 -3
- package/dist/index.d.mts +26 -152
- package/dist/index.mjs +482 -98
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/{jsx-runtime-ru5t8S3z.d.mts → jsx-runtime-CJ9_d_0Q.d.mts} +217 -14
- package/dist/jsx-runtime.d.mts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,8 +38,8 @@ const deck = new Deck({
|
|
|
38
38
|
meta: { title: "Quarterly Review", author: "deckjsx" },
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
deck.add(({
|
|
42
|
-
<Slide name={`Slide ${slideIndex + 1}`} style={{ backgroundColor: "#F8FAFC" }}>
|
|
41
|
+
deck.add(({ composition }) => (
|
|
42
|
+
<Slide name={`Slide ${composition.slideIndex + 1}`} style={{ backgroundColor: "#F8FAFC" }}>
|
|
43
43
|
<main
|
|
44
44
|
style={{
|
|
45
45
|
x: 0.7,
|
|
@@ -71,7 +71,7 @@ deck.add(({ slideIndex, totalSlides }) => (
|
|
|
71
71
|
<p
|
|
72
72
|
style={{ width: "100%", height: 0.3, fontSize: 11, color: "#64748B", textAlign: "right" }}
|
|
73
73
|
>
|
|
74
|
-
{slideIndex + 1} / {totalSlides}
|
|
74
|
+
{composition.slideIndex + 1} / {composition.totalSlides}
|
|
75
75
|
</p>
|
|
76
76
|
</footer>
|
|
77
77
|
</main>
|
package/dist/index.d.mts
CHANGED
|
@@ -1,151 +1,5 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ImageCropAuthoring, $t as SemanticSlideNode, A as CssBoxSizing, At as ViewProps, B as CssGridTemplateAreas, Bt as AssetEntity, C as ClassNameValueArray, Ct as TextJsxChild, D as CssAlignItems, Dt as TextTabStopAuthoring, E as CssAlignContent, Et as TextTabStopAlignment, F as CssGridAutoFlow, Ft as CompositionSourceInternals, G as CssObjectPosition, Gt as SemanticContainerNode, H as CssGridTrack, Ht as BaseSemanticNode, I as CssGridLine, It as SlideFactory, J as CssVisibility, Jt as SemanticNode, K as CssOverflow, Kt as SemanticDocumentNode, L as CssGridPlacement, Lt as SlideFactoryInput, M as CssFlexBasis, Mt as COMPOSITION_SOURCE, N as CssFlexDirection, Nt as CompositionContext, O as CssAlignSelf, Ot as TextTabStopLength, P as CssFlexWrap, Pt as CompositionSource, Q as DeckPointLength, Qt as SemanticShapeNode, R as CssGridShorthand, Rt as SourceContextInput, S as ClassNameValue, St as TextFit, T as ContentJsxChild, Tt as TextStyle, U as CssJustifyContent, Ut as GraphNodeId, V as CssGridTemplateShorthand, Vt as AssetEntityId, W as CssJustifySelf, Wt as SemanticAuthorGraph, X as DeckLength, Xt as SemanticOrigin, Y as DeckJsxIntrinsicElements, Yt as SemanticNodeKind, Z as DeckOptions, Zt as SemanticRole, _ as AuthorNodeProps, _n as JsxKey, _t as StackAlignment, a as createElement, an as StyleEntity, at as IntrinsicImgProps, b as BorderStyle, bt as StrokeLineCap, c as isSlideNode, cn as DiagnosticLabel, ct as IntrinsicViewTag, d as Slide, dn as formatDiagnostic, dt as OutputConfig, en as SemanticTextNode, et as ImageCropValue, f as Text, fn as formatDiagnostics, ft as ShapeProps, g as AuthorNodeMap, gt as Spacing, h as AuthorNodeKind, hn as SemanticGraphDiagnosticError, ht as SlideStyle, i as Fragment, in as StyleClassRef, it as IntrinsicDivProps, j as CssDisplay, jt as ViewStyle, k as CssAspectRatio, kt as VerticalAlign, l as Image, ln as DiagnosticSeverity, lt as JsxNode, m as AuthorNode, mn as DeckDiagnosticError, mt as SlideProps, nn as SourceIdentity, nt as ImageStyle, o as isAuthorNode, on as StyleEntityId, ot as IntrinsicPProps, p as View, pn as CompositionDiagnosticError, pt as ShapeStyle, q as CssPosition, qt as SemanticImageNode, rn as SourceOrigin, rt as ImplementedBackendName, s as isContentNode, sn as Diagnostic, st as IntrinsicTextTag, tn as SemanticTextRunNode, tt as ImageProps, u as Shape, un as Diagnostics, ut as LayoutMode, v as AuthorNodePropsMap, vn as SourceSpan, vt as StackAxis, w as ContentAuthorNode, wt as TextProps, x as ClassNameObject, xt as StrokeLineJoin, y as BackendName, yt as StrokeDashType, z as CssGridTemplate, zt as SourceContextMapper } from "./jsx-runtime-CJ9_d_0Q.mjs";
|
|
2
2
|
|
|
3
|
-
//#region src/diagnostics/errors.d.ts
|
|
4
|
-
declare class DeckDiagnosticError extends Error {
|
|
5
|
-
readonly diagnostics: Diagnostics;
|
|
6
|
-
constructor(message: string, diagnostics: Diagnostics);
|
|
7
|
-
}
|
|
8
|
-
declare class SemanticGraphDiagnosticError extends DeckDiagnosticError {
|
|
9
|
-
constructor(diagnostics: Diagnostics);
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/diagnostics/format.d.ts
|
|
13
|
-
declare function formatDiagnostic(diagnostic: Diagnostic): string;
|
|
14
|
-
declare function formatDiagnostics(diagnostics: Diagnostics): string;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/diagnostics/index.d.ts
|
|
17
|
-
type DiagnosticSeverity = "error" | "warning";
|
|
18
|
-
type DiagnosticLabel = {
|
|
19
|
-
readonly message: string;
|
|
20
|
-
readonly path: string;
|
|
21
|
-
readonly sourceSpan?: SourceSpan;
|
|
22
|
-
readonly severity?: "primary" | "secondary";
|
|
23
|
-
};
|
|
24
|
-
type Diagnostic = {
|
|
25
|
-
readonly severity: DiagnosticSeverity;
|
|
26
|
-
readonly code: string;
|
|
27
|
-
readonly title: string;
|
|
28
|
-
readonly message?: string;
|
|
29
|
-
readonly labels: readonly DiagnosticLabel[];
|
|
30
|
-
readonly notes?: readonly string[];
|
|
31
|
-
readonly help?: readonly string[];
|
|
32
|
-
};
|
|
33
|
-
type Diagnostics = {
|
|
34
|
-
readonly items: readonly Diagnostic[];
|
|
35
|
-
readonly hasErrors: boolean;
|
|
36
|
-
readonly hasWarnings: boolean;
|
|
37
|
-
};
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/graph/types.d.ts
|
|
40
|
-
type Brand<T, B extends string> = T & {
|
|
41
|
-
readonly __brand: B;
|
|
42
|
-
};
|
|
43
|
-
type GraphNodeId = Brand<string, "GraphNodeId">;
|
|
44
|
-
type StyleEntityId = Brand<string, "StyleEntityId">;
|
|
45
|
-
type AssetEntityId = Brand<string, "AssetEntityId">;
|
|
46
|
-
type SemanticNodeKind = "container" | "document" | "image" | "shape" | "slide" | "text" | "textRun";
|
|
47
|
-
type SemanticRole = {
|
|
48
|
-
readonly kind: "document";
|
|
49
|
-
} | {
|
|
50
|
-
readonly kind: "slide";
|
|
51
|
-
} | {
|
|
52
|
-
readonly kind: "genericContainer";
|
|
53
|
-
} | {
|
|
54
|
-
readonly kind: "sectioning";
|
|
55
|
-
readonly tag: SectioningTag;
|
|
56
|
-
} | {
|
|
57
|
-
readonly kind: "figure";
|
|
58
|
-
} | {
|
|
59
|
-
readonly kind: "paragraph";
|
|
60
|
-
} | {
|
|
61
|
-
readonly kind: "heading";
|
|
62
|
-
readonly level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
63
|
-
} | {
|
|
64
|
-
readonly kind: "image";
|
|
65
|
-
} | {
|
|
66
|
-
readonly kind: "shape";
|
|
67
|
-
};
|
|
68
|
-
type SemanticOrigin = {
|
|
69
|
-
readonly kind: "authored" | "implicit";
|
|
70
|
-
readonly path: string;
|
|
71
|
-
readonly sourceSpan?: SourceSpan;
|
|
72
|
-
readonly reason?: "primitive-text-in-container";
|
|
73
|
-
};
|
|
74
|
-
type BaseSemanticNode = {
|
|
75
|
-
readonly id: GraphNodeId;
|
|
76
|
-
readonly kind: SemanticNodeKind;
|
|
77
|
-
readonly origin: SemanticOrigin;
|
|
78
|
-
readonly authoredTag?: AuthoredTag;
|
|
79
|
-
readonly authoredComponent?: AuthoredComponent;
|
|
80
|
-
readonly role?: SemanticRole;
|
|
81
|
-
readonly key?: JsxKey;
|
|
82
|
-
readonly styleRef?: StyleEntityId;
|
|
83
|
-
};
|
|
84
|
-
type SemanticDocumentNode = BaseSemanticNode & {
|
|
85
|
-
readonly kind: "document";
|
|
86
|
-
readonly children: readonly GraphNodeId[];
|
|
87
|
-
};
|
|
88
|
-
type SemanticSlideNode = BaseSemanticNode & {
|
|
89
|
-
readonly kind: "slide";
|
|
90
|
-
readonly name?: string;
|
|
91
|
-
readonly children: readonly GraphNodeId[];
|
|
92
|
-
};
|
|
93
|
-
type SemanticContainerNode = BaseSemanticNode & {
|
|
94
|
-
readonly kind: "container";
|
|
95
|
-
readonly children: readonly GraphNodeId[];
|
|
96
|
-
};
|
|
97
|
-
type SemanticTextNode = BaseSemanticNode & {
|
|
98
|
-
readonly kind: "text";
|
|
99
|
-
readonly inlineChildren: readonly GraphNodeId[];
|
|
100
|
-
readonly implicit?: boolean;
|
|
101
|
-
};
|
|
102
|
-
type SemanticTextRunNode = BaseSemanticNode & {
|
|
103
|
-
readonly kind: "textRun";
|
|
104
|
-
readonly text: string;
|
|
105
|
-
};
|
|
106
|
-
type SemanticImageNode = BaseSemanticNode & {
|
|
107
|
-
readonly kind: "image";
|
|
108
|
-
readonly assetRef?: AssetEntityId;
|
|
109
|
-
};
|
|
110
|
-
type SemanticShapeNode = BaseSemanticNode & {
|
|
111
|
-
readonly kind: "shape";
|
|
112
|
-
};
|
|
113
|
-
type SemanticNode = SemanticContainerNode | SemanticDocumentNode | SemanticImageNode | SemanticShapeNode | SemanticSlideNode | SemanticTextNode | SemanticTextRunNode;
|
|
114
|
-
type StyleEntity = {
|
|
115
|
-
readonly id: StyleEntityId;
|
|
116
|
-
readonly target: SemanticNodeKind;
|
|
117
|
-
readonly authored: {
|
|
118
|
-
readonly style?: unknown;
|
|
119
|
-
readonly direct?: unknown;
|
|
120
|
-
};
|
|
121
|
-
readonly resolved?: unknown;
|
|
122
|
-
};
|
|
123
|
-
type AssetEntity = {
|
|
124
|
-
readonly id: AssetEntityId;
|
|
125
|
-
readonly kind: "image";
|
|
126
|
-
readonly source: {
|
|
127
|
-
readonly kind: "path";
|
|
128
|
-
readonly path: string;
|
|
129
|
-
} | {
|
|
130
|
-
readonly kind: "data";
|
|
131
|
-
readonly data: string;
|
|
132
|
-
};
|
|
133
|
-
readonly metadata: {
|
|
134
|
-
readonly mediaType?: string;
|
|
135
|
-
readonly byteLength?: number;
|
|
136
|
-
readonly widthPx?: number;
|
|
137
|
-
readonly heightPx?: number;
|
|
138
|
-
readonly contentHash?: string;
|
|
139
|
-
};
|
|
140
|
-
readonly resolution: "failed" | "resolved" | "unresolved";
|
|
141
|
-
};
|
|
142
|
-
type SemanticAuthorGraph = {
|
|
143
|
-
readonly documentId: GraphNodeId;
|
|
144
|
-
readonly nodes: ReadonlyMap<GraphNodeId, SemanticNode>;
|
|
145
|
-
readonly styles: ReadonlyMap<StyleEntityId, StyleEntity>;
|
|
146
|
-
readonly assets: ReadonlyMap<AssetEntityId, AssetEntity>;
|
|
147
|
-
};
|
|
148
|
-
//#endregion
|
|
149
3
|
//#region src/ir/index.d.ts
|
|
150
4
|
type PresentationIR = {
|
|
151
5
|
version: "0.1";
|
|
@@ -394,11 +248,11 @@ type CompileInspectResult = {
|
|
|
394
248
|
readonly graph?: SemanticAuthorGraph;
|
|
395
249
|
readonly diagnostics: Diagnostics;
|
|
396
250
|
};
|
|
397
|
-
|
|
251
|
+
type WithSource<TSourceContext> = [TSourceContext] extends [void] ? never : (sourceContext: TSourceContext) => BoundSource<TSourceContext>;
|
|
252
|
+
declare class BoundSource<TSourceContext = void> implements CompositionSource<TSourceContext> {
|
|
398
253
|
#private;
|
|
399
|
-
constructor(
|
|
400
|
-
|
|
401
|
-
render(): PresentationIR;
|
|
254
|
+
constructor(source: Deck<TSourceContext>, sourceContext: TSourceContext);
|
|
255
|
+
[COMPOSITION_SOURCE](): CompositionSourceInternals<TSourceContext>;
|
|
402
256
|
compile(): SemanticAuthorGraph;
|
|
403
257
|
compile(config: {
|
|
404
258
|
mode?: "strict";
|
|
@@ -406,8 +260,28 @@ declare class Deck {
|
|
|
406
260
|
compile(config: {
|
|
407
261
|
mode: "inspect";
|
|
408
262
|
}): CompileInspectResult;
|
|
263
|
+
render(): PresentationIR;
|
|
409
264
|
output(config: OutputConfig): Promise<void>;
|
|
410
265
|
}
|
|
266
|
+
declare class Deck<TSourceContext = void> implements CompositionSource<TSourceContext> {
|
|
267
|
+
#private;
|
|
268
|
+
readonly withSource: WithSource<TSourceContext>;
|
|
269
|
+
constructor(options: DeckOptions);
|
|
270
|
+
get options(): DeckOptions;
|
|
271
|
+
[COMPOSITION_SOURCE](): CompositionSourceInternals<TSourceContext>;
|
|
272
|
+
add(slide: SlideFactory<TSourceContext>): this;
|
|
273
|
+
mount<TChildContext>(sourceKey: string, child: Deck<TChildContext>, ...context: [TChildContext] extends [void] ? [] : [sourceContext: SourceContextInput<TSourceContext, TChildContext>]): this;
|
|
274
|
+
mount<TChildContext>(sourceKey: string, child: BoundSource<TChildContext>): this;
|
|
275
|
+
render(this: Deck<void>): PresentationIR;
|
|
276
|
+
compile(this: Deck<void>): SemanticAuthorGraph;
|
|
277
|
+
compile(this: Deck<void>, config: {
|
|
278
|
+
mode?: "strict";
|
|
279
|
+
}): SemanticAuthorGraph;
|
|
280
|
+
compile(this: Deck<void>, config: {
|
|
281
|
+
mode: "inspect";
|
|
282
|
+
}): CompileInspectResult;
|
|
283
|
+
output(this: Deck<void>, config: OutputConfig): Promise<void>;
|
|
284
|
+
}
|
|
411
285
|
//#endregion
|
|
412
286
|
//#region src/backends/pptxgenjs.d.ts
|
|
413
287
|
declare function pptxgenjsBackend(): CompileBackend;
|
|
@@ -430,4 +304,4 @@ declare global {
|
|
|
430
304
|
}
|
|
431
305
|
}
|
|
432
306
|
//#endregion
|
|
433
|
-
export { type AssetEntity, type AssetEntityId, type AuthorNode, type AuthorNodeKind, type AuthorNodeMap, type AuthorNodeProps, type AuthorNodePropsMap, type BackendArtifact, type BackendName, type BackgroundImageLayerIR, type BackgroundLayerIR, type BaseNodeIR, type BaseSemanticNode, type BorderStyle, type CompileBackend, type CompileInspectResult, type CompileMode, type ContentAuthorNode, type ContentJsxChild, type CssAlignContent, type CssAlignItems, type CssAlignSelf, type CssAspectRatio, type CssBoxSizing, type CssDisplay, type CssFlexBasis, type CssFlexDirection, type CssFlexWrap, type CssGridAutoFlow, type CssGridLine, type CssGridPlacement, type CssGridShorthand, type CssGridTemplate, type CssGridTemplateAreas, type CssGridTemplateShorthand, type CssGridTrack, type CssJustifyContent, type CssJustifySelf, type CssObjectPosition, type CssOverflow, type CssPosition, type CssVisibility, Deck, DeckDiagnosticError, type DeckJsxIntrinsicElements, type DeckLength, type DeckOptions, type DeckPointLength, type Diagnostic, type DiagnosticLabel, type DiagnosticSeverity, type Diagnostics, EMU_PER_INCH, type EdgeStrokeIR, type FillIR, Fragment, type FrameIR, type GraphNodeId, type GroupIR, type HyperlinkIR, Image, type ImageCropAuthoring, type ImageCropIR, type ImageCropValue, type ImageIR, type ImageProps, type ImageSourceIR, type ImageStyle, type ImplementedBackendName, type IntrinsicDivProps, type IntrinsicImgProps, type IntrinsicPProps, type IntrinsicTextTag, type IntrinsicViewTag, type JsxKey, type JsxNode, type LayoutMode, type LinearGradientFillIR, type LinearGradientStopIR, type NodeIR, type ObjectPositionIR, type OutputConfig, POINTS_PER_INCH, type PresentationIR, type RadialGradientFillIR, type SemanticAuthorGraph, type SemanticContainerNode, type SemanticDocumentNode, SemanticGraphDiagnosticError, type SemanticImageNode, type SemanticNode, type SemanticNodeKind, type SemanticOrigin, type SemanticRole, type SemanticShapeNode, type SemanticSlideNode, type SemanticTextNode, type SemanticTextRunNode, type ShadowIR, Shape, type ShapeIR, type ShapeProps, type ShapeStyle, type SizeIR, Slide, type
|
|
307
|
+
export { type AssetEntity, type AssetEntityId, type AuthorNode, type AuthorNodeKind, type AuthorNodeMap, type AuthorNodeProps, type AuthorNodePropsMap, type BackendArtifact, type BackendName, type BackgroundImageLayerIR, type BackgroundLayerIR, type BaseNodeIR, type BaseSemanticNode, type BorderStyle, type BoundSource, type ClassNameObject, type ClassNameValue, type ClassNameValueArray, type CompileBackend, type CompileInspectResult, type CompileMode, type CompositionContext, CompositionDiagnosticError, type ContentAuthorNode, type ContentJsxChild, type CssAlignContent, type CssAlignItems, type CssAlignSelf, type CssAspectRatio, type CssBoxSizing, type CssDisplay, type CssFlexBasis, type CssFlexDirection, type CssFlexWrap, type CssGridAutoFlow, type CssGridLine, type CssGridPlacement, type CssGridShorthand, type CssGridTemplate, type CssGridTemplateAreas, type CssGridTemplateShorthand, type CssGridTrack, type CssJustifyContent, type CssJustifySelf, type CssObjectPosition, type CssOverflow, type CssPosition, type CssVisibility, Deck, DeckDiagnosticError, type DeckJsxIntrinsicElements, type DeckLength, type DeckOptions, type DeckPointLength, type Diagnostic, type DiagnosticLabel, type DiagnosticSeverity, type Diagnostics, EMU_PER_INCH, type EdgeStrokeIR, type FillIR, Fragment, type FrameIR, type GraphNodeId, type GroupIR, type HyperlinkIR, Image, type ImageCropAuthoring, type ImageCropIR, type ImageCropValue, type ImageIR, type ImageProps, type ImageSourceIR, type ImageStyle, type ImplementedBackendName, type IntrinsicDivProps, type IntrinsicImgProps, type IntrinsicPProps, type IntrinsicTextTag, type IntrinsicViewTag, type JsxKey, type JsxNode, type LayoutMode, type LinearGradientFillIR, type LinearGradientStopIR, type NodeIR, type ObjectPositionIR, type OutputConfig, POINTS_PER_INCH, type PresentationIR, type RadialGradientFillIR, type SemanticAuthorGraph, type SemanticContainerNode, type SemanticDocumentNode, SemanticGraphDiagnosticError, type SemanticImageNode, type SemanticNode, type SemanticNodeKind, type SemanticOrigin, type SemanticRole, type SemanticShapeNode, type SemanticSlideNode, type SemanticTextNode, type SemanticTextRunNode, type ShadowIR, Shape, type ShapeIR, type ShapeProps, type ShapeStyle, type SizeIR, Slide, type SlideFactory, type SlideFactoryInput, type SlideIR, type SlideProps, type SlideStyle, type SolidFillIR, type SourceContextMapper, type SourceIdentity, type SourceOrigin, type SourceSpan, type Spacing, type StackAlignment, type StackAxis, type StrokeDashType, type StrokeIR, type StrokeLineCap, type StrokeLineJoin, type StyleClassRef, type StyleEntity, type StyleEntityId, Text, type TextBulletListIR, type TextContentIR, type TextFit, type TextIR, type TextJsxChild, type TextListIR, type TextNoListIR, type TextNumberListIR, type TextProps, type TextRunIR, type TextStyle, type TextStyleIR, type TextTabStopAlignment, type TextTabStopAuthoring, type TextTabStopIR, type TextTabStopLength, type VerticalAlign, View, type ViewProps, type ViewStyle, createElement, formatDiagnostic, formatDiagnostics, isAuthorNode, isContentNode, isSlideNode, pptxgenjsBackend };
|
package/dist/index.mjs
CHANGED
|
@@ -4139,17 +4139,12 @@ function renderPresentation(options, slides) {
|
|
|
4139
4139
|
meta: options.meta,
|
|
4140
4140
|
size: slideSize,
|
|
4141
4141
|
slides: slides.map((factory, slideIndex) => {
|
|
4142
|
-
return compileSlide(toLegacyJsxNode(factory({
|
|
4142
|
+
return compileSlide(toLegacyJsxNode(factory({ composition: {
|
|
4143
4143
|
slideIndex,
|
|
4144
4144
|
totalSlides: slides.length,
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
}
|
|
4149
|
-
})), {
|
|
4150
|
-
slideIndex,
|
|
4151
|
-
totalSlides: slides.length
|
|
4152
|
-
}, slideFrame, idGenerator, lengthContext);
|
|
4145
|
+
deckSlideIndex: slideIndex,
|
|
4146
|
+
deckTotalSlides: slides.length
|
|
4147
|
+
} })), { slideIndex }, slideFrame, idGenerator, lengthContext);
|
|
4153
4148
|
})
|
|
4154
4149
|
};
|
|
4155
4150
|
}
|
|
@@ -4188,6 +4183,12 @@ var SemanticGraphDiagnosticError = class extends DeckDiagnosticError {
|
|
|
4188
4183
|
this.name = "SemanticGraphDiagnosticError";
|
|
4189
4184
|
}
|
|
4190
4185
|
};
|
|
4186
|
+
var CompositionDiagnosticError = class extends DeckDiagnosticError {
|
|
4187
|
+
constructor(diagnostics) {
|
|
4188
|
+
super(formatDiagnostics(diagnostics), diagnostics);
|
|
4189
|
+
this.name = "CompositionDiagnosticError";
|
|
4190
|
+
}
|
|
4191
|
+
};
|
|
4191
4192
|
//#endregion
|
|
4192
4193
|
//#region src/diagnostics/index.ts
|
|
4193
4194
|
function createDiagnostics(items = []) {
|
|
@@ -4201,6 +4202,276 @@ function diagnostic(input) {
|
|
|
4201
4202
|
return input;
|
|
4202
4203
|
}
|
|
4203
4204
|
//#endregion
|
|
4205
|
+
//#region src/composition/types.ts
|
|
4206
|
+
const COMPOSITION_SOURCE = Symbol("deckjsx.compositionSource");
|
|
4207
|
+
function sourceIdentity(value) {
|
|
4208
|
+
return value;
|
|
4209
|
+
}
|
|
4210
|
+
//#endregion
|
|
4211
|
+
//#region src/composition/resolve.ts
|
|
4212
|
+
const MAX_COMPOSITION_DEPTH = 64;
|
|
4213
|
+
const ROOT_SOURCE = { kind: "root" };
|
|
4214
|
+
function addDiagnostic$1(context, item) {
|
|
4215
|
+
context.diagnostics.push(item);
|
|
4216
|
+
}
|
|
4217
|
+
function compositionDiagnostic(input) {
|
|
4218
|
+
return diagnostic({
|
|
4219
|
+
severity: "error",
|
|
4220
|
+
code: input.code,
|
|
4221
|
+
title: input.title,
|
|
4222
|
+
message: input.message,
|
|
4223
|
+
labels: [{
|
|
4224
|
+
path: input.path,
|
|
4225
|
+
message: input.message
|
|
4226
|
+
}],
|
|
4227
|
+
...input.help ? { help: input.help } : {}
|
|
4228
|
+
});
|
|
4229
|
+
}
|
|
4230
|
+
function sourcePathFor(parentPath, sourceKey) {
|
|
4231
|
+
return parentPath === "root" ? sourceKey : `${parentPath}/${sourceKey}`;
|
|
4232
|
+
}
|
|
4233
|
+
function sourceOriginFor(parent, sourceKey) {
|
|
4234
|
+
return {
|
|
4235
|
+
kind: "mounted",
|
|
4236
|
+
sourceKey,
|
|
4237
|
+
sourceIdentity: sourceIdentity(`${parent.kind === "root" ? "" : `${parent.sourceIdentity}/`}${sourceKey}`)
|
|
4238
|
+
};
|
|
4239
|
+
}
|
|
4240
|
+
function sourceMaterialFor(source) {
|
|
4241
|
+
return source.kind === "root" ? ["source", "root"] : ["source", source.sourceIdentity];
|
|
4242
|
+
}
|
|
4243
|
+
function validateSourceKey(sourceKey) {
|
|
4244
|
+
if (sourceKey.trim().length === 0) return "Source Key must not be empty.";
|
|
4245
|
+
if (sourceKey === "." || sourceKey === "..") return "Source Key must not be dot or dot-dot.";
|
|
4246
|
+
if (sourceKey.includes("/")) return "Source Key must not contain /.";
|
|
4247
|
+
}
|
|
4248
|
+
function describeInvalidRoot(value) {
|
|
4249
|
+
if (isLegacyAuthorNode(value)) return "Slide factory returned a legacy author node.";
|
|
4250
|
+
if (isAuthorTreeNode(value)) return "Slide factory returned an author tree node that is not a <Slide /> root.";
|
|
4251
|
+
if (value === null) return "Slide factory returned null.";
|
|
4252
|
+
return `Slide factory returned ${typeof value}.`;
|
|
4253
|
+
}
|
|
4254
|
+
function isSlideRoot(value) {
|
|
4255
|
+
return value.kind === "element" && value.source.kind === "component" && value.source.component === "Slide";
|
|
4256
|
+
}
|
|
4257
|
+
function isPromiseLike(value) {
|
|
4258
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
4259
|
+
}
|
|
4260
|
+
function mapSlotOrigins(value, origin, targets, seen) {
|
|
4261
|
+
if (isAuthorTreeNode(value)) {
|
|
4262
|
+
targets.set(value, origin);
|
|
4263
|
+
return;
|
|
4264
|
+
}
|
|
4265
|
+
if (!Array.isArray(value)) return;
|
|
4266
|
+
if (seen.has(value)) return;
|
|
4267
|
+
seen.add(value);
|
|
4268
|
+
value.forEach((item) => mapSlotOrigins(item, origin, targets, seen));
|
|
4269
|
+
}
|
|
4270
|
+
function collectSourceSlots(context, parent) {
|
|
4271
|
+
const origins = /* @__PURE__ */ new WeakMap();
|
|
4272
|
+
if (!context.present || typeof context.value !== "object" || context.value === null) return origins;
|
|
4273
|
+
Object.entries(context.value).forEach(([field, value]) => {
|
|
4274
|
+
mapSlotOrigins(value, {
|
|
4275
|
+
source: parent.slotOwnerSource,
|
|
4276
|
+
field,
|
|
4277
|
+
identityMaterial: [...parent.slotOwnerMaterial, `slot:${field}`]
|
|
4278
|
+
}, origins, /* @__PURE__ */ new WeakSet());
|
|
4279
|
+
});
|
|
4280
|
+
return origins;
|
|
4281
|
+
}
|
|
4282
|
+
function childContextFor(entry, context, path) {
|
|
4283
|
+
if (entry.invalidExtraContext) {
|
|
4284
|
+
addDiagnostic$1(context, compositionDiagnostic({
|
|
4285
|
+
code: "E_COMPOSITION_INVALID_MOUNT",
|
|
4286
|
+
title: "mount received invalid source context",
|
|
4287
|
+
path,
|
|
4288
|
+
message: "A Bound Source cannot receive additional Source Context."
|
|
4289
|
+
}));
|
|
4290
|
+
return;
|
|
4291
|
+
}
|
|
4292
|
+
if (entry.contextProvider === void 0) return { present: false };
|
|
4293
|
+
if (typeof entry.contextProvider !== "function") return {
|
|
4294
|
+
present: true,
|
|
4295
|
+
value: entry.contextProvider
|
|
4296
|
+
};
|
|
4297
|
+
try {
|
|
4298
|
+
const value = context.context.present ? entry.contextProvider(context.context.value) : entry.contextProvider();
|
|
4299
|
+
if (isPromiseLike(value)) {
|
|
4300
|
+
addDiagnostic$1(context, compositionDiagnostic({
|
|
4301
|
+
code: "E_COMPOSITION_CONTEXT_MAPPER_ASYNC",
|
|
4302
|
+
title: "source context mapper returned a Promise",
|
|
4303
|
+
path,
|
|
4304
|
+
message: "Source Context Mappers must be synchronous in v0.3."
|
|
4305
|
+
}));
|
|
4306
|
+
return;
|
|
4307
|
+
}
|
|
4308
|
+
return {
|
|
4309
|
+
present: true,
|
|
4310
|
+
value
|
|
4311
|
+
};
|
|
4312
|
+
} catch (error) {
|
|
4313
|
+
addDiagnostic$1(context, compositionDiagnostic({
|
|
4314
|
+
code: "E_COMPOSITION_CONTEXT_MAPPER_FAILED",
|
|
4315
|
+
title: "source context mapper failed",
|
|
4316
|
+
path,
|
|
4317
|
+
message: error instanceof Error ? error.message : "Source Context Mapper threw."
|
|
4318
|
+
}));
|
|
4319
|
+
return;
|
|
4320
|
+
}
|
|
4321
|
+
}
|
|
4322
|
+
function resolveSource(source, context) {
|
|
4323
|
+
const sourceState = source[COMPOSITION_SOURCE]();
|
|
4324
|
+
const effectiveContext = context.context.present ? context.context : sourceState.boundContext;
|
|
4325
|
+
if (context.depth > MAX_COMPOSITION_DEPTH) {
|
|
4326
|
+
addDiagnostic$1(context, compositionDiagnostic({
|
|
4327
|
+
code: "E_COMPOSITION_DEPTH_EXCEEDED",
|
|
4328
|
+
title: "composition depth exceeded",
|
|
4329
|
+
path: context.sourcePath,
|
|
4330
|
+
message: `Composition depth exceeded ${MAX_COMPOSITION_DEPTH}.`
|
|
4331
|
+
}));
|
|
4332
|
+
return;
|
|
4333
|
+
}
|
|
4334
|
+
if (context.stack.indexOf(sourceState.cycleId) !== -1) {
|
|
4335
|
+
addDiagnostic$1(context, compositionDiagnostic({
|
|
4336
|
+
code: "E_COMPOSITION_CYCLE",
|
|
4337
|
+
title: "composition cycle detected",
|
|
4338
|
+
path: context.sourcePath,
|
|
4339
|
+
message: "A Deck cannot mount itself through its descendant sources."
|
|
4340
|
+
}));
|
|
4341
|
+
return;
|
|
4342
|
+
}
|
|
4343
|
+
const entries = [];
|
|
4344
|
+
let slideCount = 0;
|
|
4345
|
+
const sourceKeys = /* @__PURE__ */ new Set();
|
|
4346
|
+
const slotOrigins = collectSourceSlots(effectiveContext, context);
|
|
4347
|
+
const nextContextBase = {
|
|
4348
|
+
diagnostics: context.diagnostics,
|
|
4349
|
+
stack: [...context.stack, sourceState.cycleId],
|
|
4350
|
+
depth: context.depth + 1
|
|
4351
|
+
};
|
|
4352
|
+
sourceState.entries.forEach((entry, index) => {
|
|
4353
|
+
if (entry.kind === "slide") {
|
|
4354
|
+
entries.push({
|
|
4355
|
+
kind: "slide",
|
|
4356
|
+
factory: entry.factory,
|
|
4357
|
+
path: `${context.sourcePath} > slideFactory[${index}]`
|
|
4358
|
+
});
|
|
4359
|
+
slideCount += 1;
|
|
4360
|
+
return;
|
|
4361
|
+
}
|
|
4362
|
+
const mountPath = `${context.sourcePath} > mount[${entry.sourceKey}]`;
|
|
4363
|
+
const invalidKey = validateSourceKey(entry.sourceKey);
|
|
4364
|
+
if (invalidKey) {
|
|
4365
|
+
addDiagnostic$1(context, compositionDiagnostic({
|
|
4366
|
+
code: "E_COMPOSITION_INVALID_SOURCE_KEY",
|
|
4367
|
+
title: "invalid source key",
|
|
4368
|
+
path: mountPath,
|
|
4369
|
+
message: invalidKey
|
|
4370
|
+
}));
|
|
4371
|
+
return;
|
|
4372
|
+
}
|
|
4373
|
+
if (sourceKeys.has(entry.sourceKey)) {
|
|
4374
|
+
addDiagnostic$1(context, compositionDiagnostic({
|
|
4375
|
+
code: "E_COMPOSITION_DUPLICATE_SOURCE_KEY",
|
|
4376
|
+
title: "duplicate source key",
|
|
4377
|
+
path: mountPath,
|
|
4378
|
+
message: `Source Key "${entry.sourceKey}" is already used in this parent source.`
|
|
4379
|
+
}));
|
|
4380
|
+
return;
|
|
4381
|
+
}
|
|
4382
|
+
sourceKeys.add(entry.sourceKey);
|
|
4383
|
+
const childContext = childContextFor(entry, context, mountPath);
|
|
4384
|
+
if (!childContext) return;
|
|
4385
|
+
const childSource = sourceOriginFor(context.source, entry.sourceKey);
|
|
4386
|
+
const childPlan = resolveSource(entry.source, {
|
|
4387
|
+
...nextContextBase,
|
|
4388
|
+
source: childSource,
|
|
4389
|
+
sourceIdentityMaterial: sourceMaterialFor(childSource),
|
|
4390
|
+
sourcePath: sourcePathFor(context.sourcePath, entry.sourceKey),
|
|
4391
|
+
context: childContext,
|
|
4392
|
+
slotOwnerSource: context.source,
|
|
4393
|
+
slotOwnerMaterial: context.sourceIdentityMaterial
|
|
4394
|
+
});
|
|
4395
|
+
if (!childPlan) return;
|
|
4396
|
+
entries.push({
|
|
4397
|
+
kind: "source",
|
|
4398
|
+
source: childPlan
|
|
4399
|
+
});
|
|
4400
|
+
slideCount += childPlan.slideCount;
|
|
4401
|
+
});
|
|
4402
|
+
return {
|
|
4403
|
+
source: context.source,
|
|
4404
|
+
sourceIdentityMaterial: context.sourceIdentityMaterial,
|
|
4405
|
+
context: effectiveContext,
|
|
4406
|
+
entries,
|
|
4407
|
+
slideCount,
|
|
4408
|
+
slotOrigins
|
|
4409
|
+
};
|
|
4410
|
+
}
|
|
4411
|
+
function flattenPlan(plan, deckTotalSlides, deckSlideIndex, roots, diagnostics) {
|
|
4412
|
+
let sourceSlideIndex = 0;
|
|
4413
|
+
let nextDeckSlideIndex = deckSlideIndex;
|
|
4414
|
+
for (const entry of plan.entries) {
|
|
4415
|
+
if (entry.kind === "source") {
|
|
4416
|
+
nextDeckSlideIndex = flattenPlan(entry.source, deckTotalSlides, nextDeckSlideIndex, roots, diagnostics);
|
|
4417
|
+
sourceSlideIndex += entry.source.slideCount;
|
|
4418
|
+
continue;
|
|
4419
|
+
}
|
|
4420
|
+
const composition = {
|
|
4421
|
+
...plan.source.kind === "mounted" ? { sourceKey: plan.source.sourceKey } : {},
|
|
4422
|
+
slideIndex: sourceSlideIndex,
|
|
4423
|
+
totalSlides: plan.slideCount,
|
|
4424
|
+
deckSlideIndex: nextDeckSlideIndex,
|
|
4425
|
+
deckTotalSlides
|
|
4426
|
+
};
|
|
4427
|
+
const input = plan.context.present ? {
|
|
4428
|
+
context: plan.context.value,
|
|
4429
|
+
composition
|
|
4430
|
+
} : { composition };
|
|
4431
|
+
const root = entry.factory(input);
|
|
4432
|
+
if (!isAuthorTreeNode(root) || !isSlideRoot(root)) diagnostics.push(compositionDiagnostic({
|
|
4433
|
+
code: "E_COMPOSITION_INVALID_ROOT",
|
|
4434
|
+
title: "slide factory must return a <Slide /> root",
|
|
4435
|
+
path: entry.path,
|
|
4436
|
+
message: describeInvalidRoot(root),
|
|
4437
|
+
help: ["Return <Slide>...</Slide> from the slide factory passed to deck.add()."]
|
|
4438
|
+
}));
|
|
4439
|
+
else roots.push({
|
|
4440
|
+
root,
|
|
4441
|
+
source: plan.source,
|
|
4442
|
+
sourceIdentityMaterial: plan.sourceIdentityMaterial,
|
|
4443
|
+
path: entry.path,
|
|
4444
|
+
composition,
|
|
4445
|
+
slotOrigins: plan.slotOrigins
|
|
4446
|
+
});
|
|
4447
|
+
sourceSlideIndex += 1;
|
|
4448
|
+
nextDeckSlideIndex += 1;
|
|
4449
|
+
}
|
|
4450
|
+
return nextDeckSlideIndex;
|
|
4451
|
+
}
|
|
4452
|
+
function resolveComposition(source) {
|
|
4453
|
+
const diagnostics = [];
|
|
4454
|
+
const rootPlan = resolveSource(source, {
|
|
4455
|
+
diagnostics,
|
|
4456
|
+
stack: [],
|
|
4457
|
+
depth: 0,
|
|
4458
|
+
source: ROOT_SOURCE,
|
|
4459
|
+
sourceIdentityMaterial: sourceMaterialFor(ROOT_SOURCE),
|
|
4460
|
+
sourcePath: "root",
|
|
4461
|
+
context: { present: false },
|
|
4462
|
+
slotOwnerSource: ROOT_SOURCE,
|
|
4463
|
+
slotOwnerMaterial: sourceMaterialFor(ROOT_SOURCE)
|
|
4464
|
+
});
|
|
4465
|
+
if (!rootPlan) return { diagnostics: createDiagnostics(diagnostics) };
|
|
4466
|
+
const roots = [];
|
|
4467
|
+
flattenPlan(rootPlan, rootPlan.slideCount, 0, roots, diagnostics);
|
|
4468
|
+
const resolvedDiagnostics = createDiagnostics(diagnostics);
|
|
4469
|
+
return {
|
|
4470
|
+
...resolvedDiagnostics.hasErrors ? {} : { roots },
|
|
4471
|
+
diagnostics: resolvedDiagnostics
|
|
4472
|
+
};
|
|
4473
|
+
}
|
|
4474
|
+
//#endregion
|
|
4204
4475
|
//#region src/graph/identity.ts
|
|
4205
4476
|
function slug(value) {
|
|
4206
4477
|
return value.replace(/[^a-zA-Z0-9:_-]+/g, "_");
|
|
@@ -4281,35 +4552,74 @@ function nodeSemanticKind(node) {
|
|
|
4281
4552
|
function nodeRole(node) {
|
|
4282
4553
|
return node.source.kind === "tag" ? semanticRoleForTag(node.source.tag) : semanticRoleForComponent(node.source.component);
|
|
4283
4554
|
}
|
|
4284
|
-
function
|
|
4555
|
+
function sourceFor(context) {
|
|
4556
|
+
return context.activeSlot?.source ?? context.source;
|
|
4557
|
+
}
|
|
4558
|
+
function contextForNode(node, context) {
|
|
4559
|
+
const slot = context.slotOrigins.get(node);
|
|
4560
|
+
if (!slot) return context;
|
|
4561
|
+
return {
|
|
4562
|
+
...context,
|
|
4563
|
+
activeSlot: slot,
|
|
4564
|
+
parentMaterial: [...context.parentMaterial, ...slot.identityMaterial],
|
|
4565
|
+
path: `${context.path} > slot[${slot.field}]`
|
|
4566
|
+
};
|
|
4567
|
+
}
|
|
4568
|
+
function originFor(node, path, context) {
|
|
4285
4569
|
return {
|
|
4286
4570
|
kind: "authored",
|
|
4287
4571
|
path,
|
|
4572
|
+
source: sourceFor(context),
|
|
4288
4573
|
...node.sourceSpan ? { sourceSpan: node.sourceSpan } : {}
|
|
4289
4574
|
};
|
|
4290
4575
|
}
|
|
4291
|
-
function textOriginFor(node, path) {
|
|
4576
|
+
function textOriginFor(node, path, context) {
|
|
4292
4577
|
return {
|
|
4293
4578
|
kind: "authored",
|
|
4294
4579
|
path,
|
|
4580
|
+
source: sourceFor(context),
|
|
4295
4581
|
...node.sourceSpan ? { sourceSpan: node.sourceSpan } : {}
|
|
4296
4582
|
};
|
|
4297
4583
|
}
|
|
4298
4584
|
function propsWithoutStyle(props) {
|
|
4299
|
-
const { style: _style, children: _children, ...direct } = props;
|
|
4585
|
+
const { style: _style, children: _children, className: _className, ...direct } = props;
|
|
4300
4586
|
return Object.keys(direct).length === 0 ? void 0 : direct;
|
|
4301
4587
|
}
|
|
4588
|
+
function collectClassNames(value, names) {
|
|
4589
|
+
if (value === false || value === null || value === void 0) return;
|
|
4590
|
+
if (typeof value === "string") {
|
|
4591
|
+
names.push(...value.trim().split(/\s+/).filter(Boolean));
|
|
4592
|
+
return;
|
|
4593
|
+
}
|
|
4594
|
+
if (Array.isArray(value)) {
|
|
4595
|
+
value.forEach((item) => collectClassNames(item, names));
|
|
4596
|
+
return;
|
|
4597
|
+
}
|
|
4598
|
+
if (typeof value === "object") Object.entries(value).forEach(([name, enabled]) => {
|
|
4599
|
+
if (enabled === true) collectClassNames(name, names);
|
|
4600
|
+
});
|
|
4601
|
+
}
|
|
4602
|
+
function classRefsFor(value) {
|
|
4603
|
+
const names = [];
|
|
4604
|
+
collectClassNames(value, names);
|
|
4605
|
+
return names.length === 0 ? void 0 : names.map((name, index) => ({
|
|
4606
|
+
name,
|
|
4607
|
+
index
|
|
4608
|
+
}));
|
|
4609
|
+
}
|
|
4302
4610
|
function styleRefFor(state, idMaterial, target, props) {
|
|
4303
4611
|
const style = props.style;
|
|
4304
4612
|
const direct = propsWithoutStyle(props);
|
|
4305
|
-
|
|
4613
|
+
const classRefs = classRefsFor(props.className);
|
|
4614
|
+
if (style === void 0 && direct === void 0 && classRefs === void 0) return;
|
|
4306
4615
|
const id = styleEntityId(idMaterial);
|
|
4307
4616
|
state.styles.set(id, {
|
|
4308
4617
|
id,
|
|
4309
4618
|
target,
|
|
4310
4619
|
authored: {
|
|
4311
4620
|
...style !== void 0 ? { style } : {},
|
|
4312
|
-
...direct !== void 0 ? { direct } : {}
|
|
4621
|
+
...direct !== void 0 ? { direct } : {},
|
|
4622
|
+
...classRefs !== void 0 ? { classRefs } : {}
|
|
4313
4623
|
}
|
|
4314
4624
|
});
|
|
4315
4625
|
return id;
|
|
@@ -4352,12 +4662,12 @@ function assetForImage(state, idMaterial, props, path) {
|
|
|
4352
4662
|
state.assets.set(id, entity);
|
|
4353
4663
|
return id;
|
|
4354
4664
|
}
|
|
4355
|
-
function semanticBase(state, node, id, kind, path, material) {
|
|
4665
|
+
function semanticBase(state, node, id, kind, path, material, context) {
|
|
4356
4666
|
const styleRef = styleRefFor(state, material, kind, node.props);
|
|
4357
4667
|
return {
|
|
4358
4668
|
id,
|
|
4359
4669
|
kind,
|
|
4360
|
-
origin: originFor(node, path),
|
|
4670
|
+
origin: originFor(node, path, context),
|
|
4361
4671
|
...node.source.kind === "tag" ? { authoredTag: node.source.tag } : {},
|
|
4362
4672
|
...node.source.kind === "component" ? { authoredComponent: node.source.component } : {},
|
|
4363
4673
|
...node.key !== void 0 ? { key: node.key } : {},
|
|
@@ -4374,7 +4684,7 @@ function buildTextRunFromLeaf(state, leaf, context, index) {
|
|
|
4374
4684
|
state.nodes.set(id, {
|
|
4375
4685
|
id,
|
|
4376
4686
|
kind: "textRun",
|
|
4377
|
-
origin: textOriginFor(leaf, path),
|
|
4687
|
+
origin: textOriginFor(leaf, path, context),
|
|
4378
4688
|
text
|
|
4379
4689
|
});
|
|
4380
4690
|
return {
|
|
@@ -4396,6 +4706,7 @@ function buildImplicitTextNode(state, leaf, context, index) {
|
|
|
4396
4706
|
origin: {
|
|
4397
4707
|
kind: "implicit",
|
|
4398
4708
|
path: `${context.path} > implicitText[${index}]`,
|
|
4709
|
+
source: sourceFor(context),
|
|
4399
4710
|
...leaf.sourceSpan ? { sourceSpan: leaf.sourceSpan } : {},
|
|
4400
4711
|
reason: "primitive-text-in-container"
|
|
4401
4712
|
},
|
|
@@ -4411,11 +4722,12 @@ function buildChildren(state, children, context) {
|
|
|
4411
4722
|
const ids = [];
|
|
4412
4723
|
children.forEach((child, index) => {
|
|
4413
4724
|
if (child.kind === "fragment") {
|
|
4725
|
+
const childContext = contextForNode(child, context);
|
|
4414
4726
|
const segment = `fragment:${keySegment(child.key, index)}`;
|
|
4415
4727
|
ids.push(...buildChildren(state, child.children, {
|
|
4416
|
-
...
|
|
4417
|
-
parentMaterial: [...
|
|
4418
|
-
path: `${
|
|
4728
|
+
...childContext,
|
|
4729
|
+
parentMaterial: [...childContext.parentMaterial, segment],
|
|
4730
|
+
path: `${childContext.path} > fragment[${keySegment(child.key, index)}]`
|
|
4419
4731
|
}));
|
|
4420
4732
|
return;
|
|
4421
4733
|
}
|
|
@@ -4424,11 +4736,12 @@ function buildChildren(state, children, context) {
|
|
|
4424
4736
|
});
|
|
4425
4737
|
return ids;
|
|
4426
4738
|
}
|
|
4427
|
-
function buildTextLikeNode(state, node, id, path, material) {
|
|
4739
|
+
function buildTextLikeNode(state, node, id, path, material, context) {
|
|
4428
4740
|
const inlineChildren = [];
|
|
4429
4741
|
node.children.forEach((child, index) => {
|
|
4430
4742
|
if (child.kind === "text") {
|
|
4431
4743
|
const run = buildTextRunFromLeaf(state, child, {
|
|
4744
|
+
...context,
|
|
4432
4745
|
parentId: id,
|
|
4433
4746
|
parentMaterial: material,
|
|
4434
4747
|
path,
|
|
@@ -4438,16 +4751,24 @@ function buildTextLikeNode(state, node, id, path, material) {
|
|
|
4438
4751
|
return;
|
|
4439
4752
|
}
|
|
4440
4753
|
if (child.kind === "fragment") {
|
|
4441
|
-
|
|
4754
|
+
const childContext = contextForNode(child, {
|
|
4755
|
+
...context,
|
|
4442
4756
|
parentId: id,
|
|
4443
|
-
parentMaterial:
|
|
4444
|
-
path
|
|
4757
|
+
parentMaterial: material,
|
|
4758
|
+
path,
|
|
4445
4759
|
inline: true
|
|
4760
|
+
});
|
|
4761
|
+
const segment = `fragment:${keySegment(child.key, index)}`;
|
|
4762
|
+
inlineChildren.push(...buildChildren(state, child.children, {
|
|
4763
|
+
...childContext,
|
|
4764
|
+
parentMaterial: [...childContext.parentMaterial, segment],
|
|
4765
|
+
path: `${childContext.path} > fragment[${keySegment(child.key, index)}]`
|
|
4446
4766
|
}));
|
|
4447
4767
|
return;
|
|
4448
4768
|
}
|
|
4449
4769
|
if (child.source.kind === "tag" && child.source.tag === "span") {
|
|
4450
4770
|
const built = buildNode(state, child, {
|
|
4771
|
+
...context,
|
|
4451
4772
|
parentId: id,
|
|
4452
4773
|
parentMaterial: material,
|
|
4453
4774
|
path,
|
|
@@ -4459,7 +4780,7 @@ function buildTextLikeNode(state, node, id, path, material) {
|
|
|
4459
4780
|
addDiagnostic(state, invalidStructure(`${path} > ${sourceName(child)}[${index}]`, "block content cannot appear inside text", "Text-like elements accept primitive text and inline spans only."));
|
|
4460
4781
|
});
|
|
4461
4782
|
state.nodes.set(id, {
|
|
4462
|
-
...semanticBase(state, node, id, "text", path, material),
|
|
4783
|
+
...semanticBase(state, node, id, "text", path, material, context),
|
|
4463
4784
|
kind: "text",
|
|
4464
4785
|
inlineChildren
|
|
4465
4786
|
});
|
|
@@ -4488,13 +4809,14 @@ function collectInlineText(state, children, path) {
|
|
|
4488
4809
|
return text;
|
|
4489
4810
|
}
|
|
4490
4811
|
function buildNode(state, node, context, index) {
|
|
4812
|
+
const nodeContext = contextForNode(node, context);
|
|
4491
4813
|
if (node.kind === "fragment") return;
|
|
4492
|
-
if (node.kind === "text") return
|
|
4814
|
+
if (node.kind === "text") return nodeContext.inline ? buildTextRunFromLeaf(state, node, nodeContext, index) : buildImplicitTextNode(state, node, nodeContext, index);
|
|
4493
4815
|
const kind = nodeSemanticKind(node);
|
|
4494
4816
|
const segment = `${sourceName(node)}:${keySegment(node.key, index)}`;
|
|
4495
|
-
const material = [...
|
|
4817
|
+
const material = [...nodeContext.parentMaterial, segment];
|
|
4496
4818
|
const id = graphNodeId(material);
|
|
4497
|
-
const path = `${
|
|
4819
|
+
const path = `${nodeContext.path} > ${sourceName(node)}[${keySegment(node.key, index)}]`;
|
|
4498
4820
|
if (kind === "textRun") {
|
|
4499
4821
|
if (!context.inline) {
|
|
4500
4822
|
addDiagnostic(state, invalidStructure(path, "span cannot appear here", "span must be inside a text-like element.", ["Wrap the span in <p>...</p> or move it inside an existing text element."]));
|
|
@@ -4502,7 +4824,7 @@ function buildNode(state, node, context, index) {
|
|
|
4502
4824
|
}
|
|
4503
4825
|
const text = collectInlineText(state, node.children, path);
|
|
4504
4826
|
state.nodes.set(id, {
|
|
4505
|
-
...semanticBase(state, node, id, "textRun", path, material),
|
|
4827
|
+
...semanticBase(state, node, id, "textRun", path, material, nodeContext),
|
|
4506
4828
|
kind: "textRun",
|
|
4507
4829
|
text
|
|
4508
4830
|
});
|
|
@@ -4511,12 +4833,12 @@ function buildNode(state, node, context, index) {
|
|
|
4511
4833
|
kind: "textRun"
|
|
4512
4834
|
};
|
|
4513
4835
|
}
|
|
4514
|
-
if (kind === "text") return buildTextLikeNode(state, node, id, path, material);
|
|
4836
|
+
if (kind === "text") return buildTextLikeNode(state, node, id, path, material, nodeContext);
|
|
4515
4837
|
if (kind === "image") {
|
|
4516
4838
|
if (node.children.length > 0) addDiagnostic(state, invalidStructure(path, "image cannot have children", "Image nodes are leaf nodes."));
|
|
4517
4839
|
const assetRef = assetForImage(state, material, node.props, path);
|
|
4518
4840
|
state.nodes.set(id, {
|
|
4519
|
-
...semanticBase(state, node, id, "image", path, material),
|
|
4841
|
+
...semanticBase(state, node, id, "image", path, material, nodeContext),
|
|
4520
4842
|
kind: "image",
|
|
4521
4843
|
...assetRef ? { assetRef } : {}
|
|
4522
4844
|
});
|
|
@@ -4529,10 +4851,13 @@ function buildNode(state, node, context, index) {
|
|
|
4529
4851
|
parentId: id,
|
|
4530
4852
|
parentMaterial: material,
|
|
4531
4853
|
path,
|
|
4532
|
-
inline: false
|
|
4854
|
+
inline: false,
|
|
4855
|
+
source: sourceFor(nodeContext),
|
|
4856
|
+
slotOrigins: nodeContext.slotOrigins,
|
|
4857
|
+
activeSlot: nodeContext.activeSlot
|
|
4533
4858
|
});
|
|
4534
4859
|
state.nodes.set(id, {
|
|
4535
|
-
...semanticBase(state, node, id, kind, path, material),
|
|
4860
|
+
...semanticBase(state, node, id, kind, path, material, nodeContext),
|
|
4536
4861
|
kind,
|
|
4537
4862
|
children: childIds
|
|
4538
4863
|
});
|
|
@@ -4541,6 +4866,25 @@ function buildNode(state, node, context, index) {
|
|
|
4541
4866
|
kind
|
|
4542
4867
|
};
|
|
4543
4868
|
}
|
|
4869
|
+
function rootSource() {
|
|
4870
|
+
return { kind: "root" };
|
|
4871
|
+
}
|
|
4872
|
+
function asComposedRoot(root, index) {
|
|
4873
|
+
if (root.kind !== "element") throw new Error("Semantic graph roots must be element nodes.");
|
|
4874
|
+
return {
|
|
4875
|
+
root,
|
|
4876
|
+
source: rootSource(),
|
|
4877
|
+
sourceIdentityMaterial: ["source", "root"],
|
|
4878
|
+
path: `document > slideFactory[${index}]`,
|
|
4879
|
+
composition: {
|
|
4880
|
+
slideIndex: index,
|
|
4881
|
+
totalSlides: 0,
|
|
4882
|
+
deckSlideIndex: index,
|
|
4883
|
+
deckTotalSlides: 0
|
|
4884
|
+
},
|
|
4885
|
+
slotOrigins: /* @__PURE__ */ new WeakMap()
|
|
4886
|
+
};
|
|
4887
|
+
}
|
|
4544
4888
|
function buildSemanticAuthorGraph(roots) {
|
|
4545
4889
|
const documentId = graphNodeId(["document", "root"]);
|
|
4546
4890
|
const state = {
|
|
@@ -4549,20 +4893,33 @@ function buildSemanticAuthorGraph(roots) {
|
|
|
4549
4893
|
assets: /* @__PURE__ */ new Map(),
|
|
4550
4894
|
diagnostics: []
|
|
4551
4895
|
};
|
|
4896
|
+
const slideIds = [];
|
|
4897
|
+
roots.forEach((root, index) => {
|
|
4898
|
+
const composed = "root" in root ? root : asComposedRoot(root, index);
|
|
4899
|
+
const built = buildNode(state, composed.root, {
|
|
4900
|
+
parentId: documentId,
|
|
4901
|
+
parentMaterial: [
|
|
4902
|
+
"document",
|
|
4903
|
+
"root",
|
|
4904
|
+
...composed.sourceIdentityMaterial
|
|
4905
|
+
],
|
|
4906
|
+
path: composed.path,
|
|
4907
|
+
inline: false,
|
|
4908
|
+
source: composed.source,
|
|
4909
|
+
slotOrigins: composed.slotOrigins
|
|
4910
|
+
}, composed.composition.slideIndex);
|
|
4911
|
+
if (built) slideIds.push(built.id);
|
|
4912
|
+
});
|
|
4552
4913
|
const documentNode = {
|
|
4553
4914
|
id: documentId,
|
|
4554
4915
|
kind: "document",
|
|
4555
4916
|
origin: {
|
|
4556
4917
|
kind: "implicit",
|
|
4557
|
-
path: "document"
|
|
4918
|
+
path: "document",
|
|
4919
|
+
source: rootSource()
|
|
4558
4920
|
},
|
|
4559
4921
|
role: { kind: "document" },
|
|
4560
|
-
children:
|
|
4561
|
-
parentId: documentId,
|
|
4562
|
-
parentMaterial: ["document", "root"],
|
|
4563
|
-
path: "document",
|
|
4564
|
-
inline: false
|
|
4565
|
-
})
|
|
4922
|
+
children: slideIds
|
|
4566
4923
|
};
|
|
4567
4924
|
state.nodes.set(documentId, documentNode);
|
|
4568
4925
|
const diagnostics = createDiagnostics(state.diagnostics);
|
|
@@ -15702,78 +16059,105 @@ async function outputPresentation(presentation, config) {
|
|
|
15702
16059
|
}
|
|
15703
16060
|
//#endregion
|
|
15704
16061
|
//#region src/deck.ts
|
|
15705
|
-
function
|
|
15706
|
-
return
|
|
15707
|
-
}
|
|
15708
|
-
function
|
|
15709
|
-
|
|
15710
|
-
|
|
15711
|
-
|
|
15712
|
-
return
|
|
15713
|
-
}
|
|
15714
|
-
function
|
|
15715
|
-
|
|
15716
|
-
|
|
15717
|
-
|
|
15718
|
-
|
|
15719
|
-
|
|
15720
|
-
|
|
15721
|
-
|
|
15722
|
-
|
|
15723
|
-
|
|
15724
|
-
|
|
15725
|
-
|
|
15726
|
-
|
|
15727
|
-
|
|
15728
|
-
|
|
15729
|
-
|
|
15730
|
-
|
|
15731
|
-
|
|
16062
|
+
function hasMountedSources(entries) {
|
|
16063
|
+
return entries.some((entry) => entry.kind === "mount");
|
|
16064
|
+
}
|
|
16065
|
+
function directSlideFactories(entries) {
|
|
16066
|
+
return entries.flatMap((entry) => entry.kind === "slide" ? [entry.factory] : []);
|
|
16067
|
+
}
|
|
16068
|
+
function mountedSourceError() {
|
|
16069
|
+
return /* @__PURE__ */ new Error("Mounted sources are supported by compile() only until the output pipeline supports graph composition.");
|
|
16070
|
+
}
|
|
16071
|
+
function compileSource(source, config = {}) {
|
|
16072
|
+
const composition = resolveComposition(source);
|
|
16073
|
+
if (composition.diagnostics.hasErrors) {
|
|
16074
|
+
if (config.mode === "inspect") return { diagnostics: composition.diagnostics };
|
|
16075
|
+
throw new CompositionDiagnosticError(composition.diagnostics);
|
|
16076
|
+
}
|
|
16077
|
+
const result = buildSemanticAuthorGraph(composition.roots ?? []);
|
|
16078
|
+
if (config.mode === "inspect") return result;
|
|
16079
|
+
if (result.diagnostics.hasErrors) throw new SemanticGraphDiagnosticError(result.diagnostics);
|
|
16080
|
+
if (!result.graph) throw new SemanticGraphDiagnosticError(result.diagnostics);
|
|
16081
|
+
return result.graph;
|
|
16082
|
+
}
|
|
16083
|
+
var BoundSource = class {
|
|
16084
|
+
#source;
|
|
16085
|
+
#sourceContext;
|
|
16086
|
+
constructor(source, sourceContext) {
|
|
16087
|
+
this.#source = source;
|
|
16088
|
+
this.#sourceContext = sourceContext;
|
|
16089
|
+
}
|
|
16090
|
+
[COMPOSITION_SOURCE]() {
|
|
16091
|
+
const source = this.#source[COMPOSITION_SOURCE]();
|
|
16092
|
+
return {
|
|
16093
|
+
entries: source.entries,
|
|
16094
|
+
cycleId: source.cycleId,
|
|
16095
|
+
boundContext: {
|
|
16096
|
+
present: true,
|
|
16097
|
+
value: this.#sourceContext
|
|
16098
|
+
}
|
|
16099
|
+
};
|
|
16100
|
+
}
|
|
16101
|
+
compile(config = {}) {
|
|
16102
|
+
return compileSource(this, config);
|
|
16103
|
+
}
|
|
16104
|
+
render() {
|
|
16105
|
+
const source = this.#source[COMPOSITION_SOURCE]();
|
|
16106
|
+
if (hasMountedSources(source.entries)) throw mountedSourceError();
|
|
16107
|
+
return renderPresentation(this.#source.options, directSlideFactories(source.entries).map((factory) => (input) => factory({
|
|
16108
|
+
...input,
|
|
16109
|
+
context: this.#sourceContext
|
|
16110
|
+
})));
|
|
16111
|
+
}
|
|
16112
|
+
async output(config) {
|
|
16113
|
+
await outputPresentation(this.render(), config);
|
|
16114
|
+
}
|
|
16115
|
+
};
|
|
15732
16116
|
var Deck = class {
|
|
15733
16117
|
#options;
|
|
15734
|
-
#
|
|
16118
|
+
#entries = [];
|
|
16119
|
+
withSource;
|
|
15735
16120
|
constructor(options) {
|
|
15736
16121
|
this.#options = options;
|
|
16122
|
+
this.withSource = ((sourceContext) => new BoundSource(this, sourceContext));
|
|
16123
|
+
}
|
|
16124
|
+
get options() {
|
|
16125
|
+
return this.#options;
|
|
16126
|
+
}
|
|
16127
|
+
[COMPOSITION_SOURCE]() {
|
|
16128
|
+
return {
|
|
16129
|
+
entries: this.#entries,
|
|
16130
|
+
cycleId: this,
|
|
16131
|
+
boundContext: { present: false }
|
|
16132
|
+
};
|
|
15737
16133
|
}
|
|
15738
16134
|
add(slide) {
|
|
15739
|
-
this.#
|
|
16135
|
+
this.#entries.push({
|
|
16136
|
+
kind: "slide",
|
|
16137
|
+
factory: slide
|
|
16138
|
+
});
|
|
16139
|
+
return this;
|
|
16140
|
+
}
|
|
16141
|
+
mount(sourceKey, child, ...context) {
|
|
16142
|
+
this.#entries.push({
|
|
16143
|
+
kind: "mount",
|
|
16144
|
+
sourceKey,
|
|
16145
|
+
source: child,
|
|
16146
|
+
...context.length > 0 ? { contextProvider: context[0] } : {},
|
|
16147
|
+
...child instanceof BoundSource && context.length > 0 ? { invalidExtraContext: true } : {}
|
|
16148
|
+
});
|
|
15740
16149
|
return this;
|
|
15741
16150
|
}
|
|
15742
16151
|
render() {
|
|
15743
|
-
|
|
16152
|
+
if (hasMountedSources(this.#entries)) throw mountedSourceError();
|
|
16153
|
+
return renderPresentation(this.#options, directSlideFactories(this.#entries));
|
|
15744
16154
|
}
|
|
15745
16155
|
compile(config = {}) {
|
|
15746
|
-
|
|
15747
|
-
const diagnostics = [];
|
|
15748
|
-
this.#slides.forEach((factory, slideIndex) => {
|
|
15749
|
-
const root = factory({
|
|
15750
|
-
slideIndex,
|
|
15751
|
-
totalSlides: this.#slides.length,
|
|
15752
|
-
context: {
|
|
15753
|
-
slideIndex,
|
|
15754
|
-
totalSlides: this.#slides.length
|
|
15755
|
-
}
|
|
15756
|
-
});
|
|
15757
|
-
if (!isAuthorTreeNode(root) || !isSlideRoot(root)) {
|
|
15758
|
-
diagnostics.push(invalidRootDiagnostic(root, slideIndex));
|
|
15759
|
-
return;
|
|
15760
|
-
}
|
|
15761
|
-
roots.push(root);
|
|
15762
|
-
});
|
|
15763
|
-
if (diagnostics.length > 0) {
|
|
15764
|
-
const result = { diagnostics: createDiagnostics(diagnostics) };
|
|
15765
|
-
if (config.mode === "inspect") return result;
|
|
15766
|
-
throw new SemanticGraphDiagnosticError(result.diagnostics);
|
|
15767
|
-
}
|
|
15768
|
-
const result = buildSemanticAuthorGraph(roots);
|
|
15769
|
-
if (config.mode === "inspect") return result;
|
|
15770
|
-
if (result.diagnostics.hasErrors) throw new SemanticGraphDiagnosticError(result.diagnostics);
|
|
15771
|
-
if (!result.graph) throw new SemanticGraphDiagnosticError(result.diagnostics);
|
|
15772
|
-
return result.graph;
|
|
16156
|
+
return compileSource(this, config);
|
|
15773
16157
|
}
|
|
15774
16158
|
async output(config) {
|
|
15775
16159
|
await outputPresentation(this.render(), config);
|
|
15776
16160
|
}
|
|
15777
16161
|
};
|
|
15778
16162
|
//#endregion
|
|
15779
|
-
export { Deck, DeckDiagnosticError, EMU_PER_INCH, Fragment, Image, POINTS_PER_INCH, SemanticGraphDiagnosticError, Shape, Slide, Text, View, createElement, formatDiagnostic, formatDiagnostics, isAuthorNode, isContentNode, isSlideNode, pptxgenjsBackend };
|
|
16163
|
+
export { CompositionDiagnosticError, Deck, DeckDiagnosticError, EMU_PER_INCH, Fragment, Image, POINTS_PER_INCH, SemanticGraphDiagnosticError, Shape, Slide, Text, View, createElement, formatDiagnostic, formatDiagnostics, isAuthorNode, isContentNode, isSlideNode, pptxgenjsBackend };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _n as JsxKey, gn as AuthorTreeNode, i as Fragment, n as jsx, r as jsxs, t as JSX } from "./jsx-runtime-CJ9_d_0Q.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/jsx-dev-runtime.d.ts
|
|
4
4
|
declare function jsxDEV(type: unknown, props: unknown, key?: JsxKey, _isStaticChildren?: boolean, source?: unknown): AuthorTreeNode;
|
|
@@ -44,6 +44,211 @@ type AuthorTextLeaf = {
|
|
|
44
44
|
type AuthorTreeNode = AuthorElementNode | AuthorFragmentNode | AuthorTextLeaf;
|
|
45
45
|
type AuthorTreeChild = AuthorTreeNode | string | number | boolean | null | undefined | readonly AuthorTreeChild[];
|
|
46
46
|
//#endregion
|
|
47
|
+
//#region src/diagnostics/errors.d.ts
|
|
48
|
+
declare class DeckDiagnosticError extends Error {
|
|
49
|
+
readonly diagnostics: Diagnostics;
|
|
50
|
+
constructor(message: string, diagnostics: Diagnostics);
|
|
51
|
+
}
|
|
52
|
+
declare class SemanticGraphDiagnosticError extends DeckDiagnosticError {
|
|
53
|
+
constructor(diagnostics: Diagnostics);
|
|
54
|
+
}
|
|
55
|
+
declare class CompositionDiagnosticError extends DeckDiagnosticError {
|
|
56
|
+
constructor(diagnostics: Diagnostics);
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/diagnostics/format.d.ts
|
|
60
|
+
declare function formatDiagnostic(diagnostic: Diagnostic): string;
|
|
61
|
+
declare function formatDiagnostics(diagnostics: Diagnostics): string;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/diagnostics/index.d.ts
|
|
64
|
+
type DiagnosticSeverity = "error" | "warning";
|
|
65
|
+
type DiagnosticLabel = {
|
|
66
|
+
readonly message: string;
|
|
67
|
+
readonly path: string;
|
|
68
|
+
readonly sourceSpan?: SourceSpan;
|
|
69
|
+
readonly severity?: "primary" | "secondary";
|
|
70
|
+
};
|
|
71
|
+
type Diagnostic = {
|
|
72
|
+
readonly severity: DiagnosticSeverity;
|
|
73
|
+
readonly code: string;
|
|
74
|
+
readonly title: string;
|
|
75
|
+
readonly message?: string;
|
|
76
|
+
readonly labels: readonly DiagnosticLabel[];
|
|
77
|
+
readonly notes?: readonly string[];
|
|
78
|
+
readonly help?: readonly string[];
|
|
79
|
+
};
|
|
80
|
+
type Diagnostics = {
|
|
81
|
+
readonly items: readonly Diagnostic[];
|
|
82
|
+
readonly hasErrors: boolean;
|
|
83
|
+
readonly hasWarnings: boolean;
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/graph/types.d.ts
|
|
87
|
+
type Brand<T, B extends string> = T & {
|
|
88
|
+
readonly __brand: B;
|
|
89
|
+
};
|
|
90
|
+
type GraphNodeId = Brand<string, "GraphNodeId">;
|
|
91
|
+
type StyleEntityId = Brand<string, "StyleEntityId">;
|
|
92
|
+
type AssetEntityId = Brand<string, "AssetEntityId">;
|
|
93
|
+
type SourceIdentity = Brand<string, "SourceIdentity">;
|
|
94
|
+
type SemanticNodeKind = "container" | "document" | "image" | "shape" | "slide" | "text" | "textRun";
|
|
95
|
+
type SemanticRole = {
|
|
96
|
+
readonly kind: "document";
|
|
97
|
+
} | {
|
|
98
|
+
readonly kind: "slide";
|
|
99
|
+
} | {
|
|
100
|
+
readonly kind: "genericContainer";
|
|
101
|
+
} | {
|
|
102
|
+
readonly kind: "sectioning";
|
|
103
|
+
readonly tag: SectioningTag;
|
|
104
|
+
} | {
|
|
105
|
+
readonly kind: "figure";
|
|
106
|
+
} | {
|
|
107
|
+
readonly kind: "paragraph";
|
|
108
|
+
} | {
|
|
109
|
+
readonly kind: "heading";
|
|
110
|
+
readonly level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
111
|
+
} | {
|
|
112
|
+
readonly kind: "image";
|
|
113
|
+
} | {
|
|
114
|
+
readonly kind: "shape";
|
|
115
|
+
};
|
|
116
|
+
type SourceOrigin = {
|
|
117
|
+
readonly kind: "root";
|
|
118
|
+
} | {
|
|
119
|
+
readonly kind: "mounted";
|
|
120
|
+
readonly sourceKey: string;
|
|
121
|
+
readonly sourceIdentity: SourceIdentity;
|
|
122
|
+
};
|
|
123
|
+
type SemanticOrigin = {
|
|
124
|
+
readonly kind: "authored" | "implicit";
|
|
125
|
+
readonly path: string;
|
|
126
|
+
readonly source?: SourceOrigin;
|
|
127
|
+
readonly sourceSpan?: SourceSpan;
|
|
128
|
+
readonly reason?: "primitive-text-in-container";
|
|
129
|
+
};
|
|
130
|
+
type BaseSemanticNode = {
|
|
131
|
+
readonly id: GraphNodeId;
|
|
132
|
+
readonly kind: SemanticNodeKind;
|
|
133
|
+
readonly origin: SemanticOrigin;
|
|
134
|
+
readonly authoredTag?: AuthoredTag;
|
|
135
|
+
readonly authoredComponent?: AuthoredComponent;
|
|
136
|
+
readonly role?: SemanticRole;
|
|
137
|
+
readonly key?: JsxKey;
|
|
138
|
+
readonly styleRef?: StyleEntityId;
|
|
139
|
+
};
|
|
140
|
+
type SemanticDocumentNode = BaseSemanticNode & {
|
|
141
|
+
readonly kind: "document";
|
|
142
|
+
readonly children: readonly GraphNodeId[];
|
|
143
|
+
};
|
|
144
|
+
type SemanticSlideNode = BaseSemanticNode & {
|
|
145
|
+
readonly kind: "slide";
|
|
146
|
+
readonly name?: string;
|
|
147
|
+
readonly children: readonly GraphNodeId[];
|
|
148
|
+
};
|
|
149
|
+
type SemanticContainerNode = BaseSemanticNode & {
|
|
150
|
+
readonly kind: "container";
|
|
151
|
+
readonly children: readonly GraphNodeId[];
|
|
152
|
+
};
|
|
153
|
+
type SemanticTextNode = BaseSemanticNode & {
|
|
154
|
+
readonly kind: "text";
|
|
155
|
+
readonly inlineChildren: readonly GraphNodeId[];
|
|
156
|
+
readonly implicit?: boolean;
|
|
157
|
+
};
|
|
158
|
+
type SemanticTextRunNode = BaseSemanticNode & {
|
|
159
|
+
readonly kind: "textRun";
|
|
160
|
+
readonly text: string;
|
|
161
|
+
};
|
|
162
|
+
type SemanticImageNode = BaseSemanticNode & {
|
|
163
|
+
readonly kind: "image";
|
|
164
|
+
readonly assetRef?: AssetEntityId;
|
|
165
|
+
};
|
|
166
|
+
type SemanticShapeNode = BaseSemanticNode & {
|
|
167
|
+
readonly kind: "shape";
|
|
168
|
+
};
|
|
169
|
+
type SemanticNode = SemanticContainerNode | SemanticDocumentNode | SemanticImageNode | SemanticShapeNode | SemanticSlideNode | SemanticTextNode | SemanticTextRunNode;
|
|
170
|
+
type StyleClassRef = {
|
|
171
|
+
readonly name: string;
|
|
172
|
+
readonly index: number;
|
|
173
|
+
};
|
|
174
|
+
type StyleEntity = {
|
|
175
|
+
readonly id: StyleEntityId;
|
|
176
|
+
readonly target: SemanticNodeKind;
|
|
177
|
+
readonly authored: {
|
|
178
|
+
readonly style?: unknown;
|
|
179
|
+
readonly direct?: unknown;
|
|
180
|
+
readonly classRefs?: readonly StyleClassRef[];
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
type AssetEntity = {
|
|
184
|
+
readonly id: AssetEntityId;
|
|
185
|
+
readonly kind: "image";
|
|
186
|
+
readonly source: {
|
|
187
|
+
readonly kind: "path";
|
|
188
|
+
readonly path: string;
|
|
189
|
+
} | {
|
|
190
|
+
readonly kind: "data";
|
|
191
|
+
readonly data: string;
|
|
192
|
+
};
|
|
193
|
+
readonly metadata: {
|
|
194
|
+
readonly mediaType?: string;
|
|
195
|
+
readonly byteLength?: number;
|
|
196
|
+
readonly widthPx?: number;
|
|
197
|
+
readonly heightPx?: number;
|
|
198
|
+
readonly contentHash?: string;
|
|
199
|
+
};
|
|
200
|
+
readonly resolution: "failed" | "resolved" | "unresolved";
|
|
201
|
+
};
|
|
202
|
+
type SemanticAuthorGraph = {
|
|
203
|
+
readonly documentId: GraphNodeId;
|
|
204
|
+
readonly nodes: ReadonlyMap<GraphNodeId, SemanticNode>;
|
|
205
|
+
readonly styles: ReadonlyMap<StyleEntityId, StyleEntity>;
|
|
206
|
+
readonly assets: ReadonlyMap<AssetEntityId, AssetEntity>;
|
|
207
|
+
};
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/composition/types.d.ts
|
|
210
|
+
declare const COMPOSITION_SOURCE: unique symbol;
|
|
211
|
+
type CompositionContext = {
|
|
212
|
+
readonly sourceKey?: string;
|
|
213
|
+
readonly slideIndex: number;
|
|
214
|
+
readonly totalSlides: number;
|
|
215
|
+
readonly deckSlideIndex: number;
|
|
216
|
+
readonly deckTotalSlides: number;
|
|
217
|
+
};
|
|
218
|
+
type SlideFactoryInput<TSourceContext = void> = [TSourceContext] extends [void] ? {
|
|
219
|
+
readonly composition: CompositionContext;
|
|
220
|
+
} : {
|
|
221
|
+
readonly context: TSourceContext;
|
|
222
|
+
readonly composition: CompositionContext;
|
|
223
|
+
};
|
|
224
|
+
type SlideFactory<TSourceContext = void> = (input: SlideFactoryInput<TSourceContext>) => JsxNode;
|
|
225
|
+
type SourceContextMapper<TParentContext, TChildContext> = [TParentContext] extends [void] ? () => TChildContext : (context: TParentContext) => TChildContext;
|
|
226
|
+
type SourceContextInput<TParentContext, TChildContext> = TChildContext | SourceContextMapper<TParentContext, TChildContext>;
|
|
227
|
+
type SourceContextBinding<TSourceContext = unknown> = {
|
|
228
|
+
readonly present: false;
|
|
229
|
+
} | {
|
|
230
|
+
readonly present: true;
|
|
231
|
+
readonly value: TSourceContext;
|
|
232
|
+
};
|
|
233
|
+
type CompositionEntry<TSourceContext = unknown> = {
|
|
234
|
+
readonly kind: "slide";
|
|
235
|
+
readonly factory: SlideFactory<TSourceContext>;
|
|
236
|
+
} | {
|
|
237
|
+
readonly kind: "mount";
|
|
238
|
+
readonly sourceKey: string;
|
|
239
|
+
readonly source: CompositionSource<unknown>;
|
|
240
|
+
readonly contextProvider?: SourceContextInput<TSourceContext, unknown>;
|
|
241
|
+
readonly invalidExtraContext?: boolean;
|
|
242
|
+
};
|
|
243
|
+
type CompositionSourceInternals<TSourceContext = unknown> = {
|
|
244
|
+
readonly entries: readonly CompositionEntry<TSourceContext>[];
|
|
245
|
+
readonly cycleId: object;
|
|
246
|
+
readonly boundContext: SourceContextBinding<TSourceContext>;
|
|
247
|
+
};
|
|
248
|
+
type CompositionSource<TSourceContext = unknown> = {
|
|
249
|
+
readonly [COMPOSITION_SOURCE]: () => CompositionSourceInternals<TSourceContext>;
|
|
250
|
+
};
|
|
251
|
+
//#endregion
|
|
47
252
|
//#region src/authoring/index.d.ts
|
|
48
253
|
type DeckLength = number | `${number}${"in" | "pt" | "px" | "%" | "em" | "rem" | "vh" | "vw" | "ch"}`;
|
|
49
254
|
type DeckPointLength = number | `${number}${"pt" | "in" | "px" | "em" | "rem" | "vh" | "vw" | "ch"}`;
|
|
@@ -104,6 +309,12 @@ interface ViewIntrinsicJsxChildArray extends ReadonlyArray<ViewIntrinsicJsxChild
|
|
|
104
309
|
type ViewIntrinsicJsxChild = ContentJsxChild | string | number | ViewIntrinsicJsxChildArray;
|
|
105
310
|
interface JsxNodeArray extends ReadonlyArray<JsxNode> {}
|
|
106
311
|
type JsxNode = AuthorNode | AuthorTreeNode | string | number | boolean | null | undefined | JsxNodeArray;
|
|
312
|
+
interface ClassNameValueArray extends ReadonlyArray<ClassNameValue> {}
|
|
313
|
+
type ClassNameObject = Readonly<Record<string, boolean | null | undefined>>;
|
|
314
|
+
type ClassNameValue = string | false | null | undefined | ClassNameValueArray | ClassNameObject;
|
|
315
|
+
type ClassNameAuthorProps = {
|
|
316
|
+
className?: ClassNameValue;
|
|
317
|
+
};
|
|
107
318
|
type BaseAuthorProps = {
|
|
108
319
|
opacity?: number;
|
|
109
320
|
rotation?: number;
|
|
@@ -319,21 +530,13 @@ type DeckOptions = {
|
|
|
319
530
|
subject?: string;
|
|
320
531
|
};
|
|
321
532
|
};
|
|
322
|
-
type SlideContext = {
|
|
323
|
-
slideIndex: number;
|
|
324
|
-
totalSlides: number;
|
|
325
|
-
context?: {
|
|
326
|
-
slideIndex: number;
|
|
327
|
-
totalSlides: number;
|
|
328
|
-
};
|
|
329
|
-
};
|
|
330
|
-
type SlideFactory = (context: SlideContext) => JsxNode;
|
|
331
533
|
type OutputConfig = {
|
|
332
534
|
backend: ImplementedBackendName;
|
|
333
535
|
output: string;
|
|
334
536
|
};
|
|
335
537
|
type SlideNodeProps = {
|
|
336
538
|
name?: string;
|
|
539
|
+
className?: ClassNameValue;
|
|
337
540
|
style?: SlideStyle;
|
|
338
541
|
background?: string;
|
|
339
542
|
backgroundImage?: string;
|
|
@@ -350,19 +553,19 @@ type SlideProps = SlideNodeProps & {
|
|
|
350
553
|
};
|
|
351
554
|
type ViewNodeProps = {
|
|
352
555
|
style?: ViewStyle;
|
|
353
|
-
} & ViewStyle;
|
|
556
|
+
} & ClassNameAuthorProps & ViewStyle;
|
|
354
557
|
type ViewProps = ViewNodeProps & {
|
|
355
558
|
children?: ContentJsxChild;
|
|
356
559
|
};
|
|
357
560
|
type TextNodeProps = {
|
|
358
561
|
style?: TextStyle;
|
|
359
|
-
} & TextStyle;
|
|
562
|
+
} & ClassNameAuthorProps & TextStyle;
|
|
360
563
|
type TextProps = TextNodeProps & {
|
|
361
564
|
children?: TextJsxChild;
|
|
362
565
|
};
|
|
363
566
|
type ImageNodeProps = {
|
|
364
567
|
style?: ImageStyle;
|
|
365
|
-
} & ImageStyle & ({
|
|
568
|
+
} & ClassNameAuthorProps & ImageStyle & ({
|
|
366
569
|
src: string;
|
|
367
570
|
data?: string;
|
|
368
571
|
} | {
|
|
@@ -375,7 +578,7 @@ type ImageProps = ImageNodeProps & {
|
|
|
375
578
|
type ShapeNodeProps = {
|
|
376
579
|
style?: ShapeStyle;
|
|
377
580
|
shape: "rect" | "ellipse" | "line";
|
|
378
|
-
} & ShapeStyle;
|
|
581
|
+
} & ClassNameAuthorProps & ShapeStyle;
|
|
379
582
|
type ShapeProps = ShapeNodeProps & {
|
|
380
583
|
children?: never;
|
|
381
584
|
};
|
|
@@ -485,4 +688,4 @@ declare namespace JSX {
|
|
|
485
688
|
}
|
|
486
689
|
}
|
|
487
690
|
//#endregion
|
|
488
|
-
export {
|
|
691
|
+
export { ImageCropAuthoring as $, SemanticSlideNode as $t, CssBoxSizing as A, ViewProps as At, CssGridTemplateAreas as B, AssetEntity as Bt, ClassNameValueArray as C, TextJsxChild as Ct, CssAlignItems as D, TextTabStopAuthoring as Dt, CssAlignContent as E, TextTabStopAlignment as Et, CssGridAutoFlow as F, CompositionSourceInternals as Ft, CssObjectPosition as G, SemanticContainerNode as Gt, CssGridTrack as H, BaseSemanticNode as Ht, CssGridLine as I, SlideFactory as It, CssVisibility as J, SemanticNode as Jt, CssOverflow as K, SemanticDocumentNode as Kt, CssGridPlacement as L, SlideFactoryInput as Lt, CssFlexBasis as M, COMPOSITION_SOURCE as Mt, CssFlexDirection as N, CompositionContext as Nt, CssAlignSelf as O, TextTabStopLength as Ot, CssFlexWrap as P, CompositionSource as Pt, DeckPointLength as Q, SemanticShapeNode as Qt, CssGridShorthand as R, SourceContextInput as Rt, ClassNameValue as S, TextFit as St, ContentJsxChild as T, TextStyle as Tt, CssJustifyContent as U, GraphNodeId as Ut, CssGridTemplateShorthand as V, AssetEntityId as Vt, CssJustifySelf as W, SemanticAuthorGraph as Wt, DeckLength as X, SemanticOrigin as Xt, DeckJsxIntrinsicElements as Y, SemanticNodeKind as Yt, DeckOptions as Z, SemanticRole as Zt, AuthorNodeProps as _, JsxKey as _n, StackAlignment as _t, createElement as a, StyleEntity as an, IntrinsicImgProps as at, BorderStyle as b, StrokeLineCap as bt, isSlideNode as c, DiagnosticLabel as cn, IntrinsicViewTag as ct, Slide as d, formatDiagnostic as dn, OutputConfig as dt, SemanticTextNode as en, ImageCropValue as et, Text as f, formatDiagnostics as fn, ShapeProps as ft, AuthorNodeMap as g, AuthorTreeNode as gn, Spacing as gt, AuthorNodeKind as h, SemanticGraphDiagnosticError as hn, SlideStyle as ht, Fragment as i, StyleClassRef as in, IntrinsicDivProps as it, CssDisplay as j, ViewStyle as jt, CssAspectRatio as k, VerticalAlign as kt, Image as l, DiagnosticSeverity as ln, JsxNode as lt, AuthorNode as m, DeckDiagnosticError as mn, SlideProps as mt, jsx as n, SourceIdentity as nn, ImageStyle as nt, isAuthorNode as o, StyleEntityId as on, IntrinsicPProps as ot, View as p, CompositionDiagnosticError as pn, ShapeStyle as pt, CssPosition as q, SemanticImageNode as qt, jsxs as r, SourceOrigin as rn, ImplementedBackendName as rt, isContentNode as s, Diagnostic as sn, IntrinsicTextTag as st, JSX as t, SemanticTextRunNode as tn, ImageProps as tt, Shape as u, Diagnostics as un, LayoutMode as ut, AuthorNodePropsMap as v, SourceSpan as vn, StackAxis as vt, ContentAuthorNode as w, TextProps as wt, ClassNameObject as x, StrokeLineJoin as xt, BackendName as y, StrokeDashType as yt, CssGridTemplate as z, SourceContextMapper as zt };
|
package/dist/jsx-runtime.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _n as JsxKey, i as Fragment, n as jsx, r as jsxs, t as JSX } from "./jsx-runtime-CJ9_d_0Q.mjs";
|
|
2
2
|
export { Fragment, JSX, JsxKey, jsx, jsxs };
|