deckjsx 0.3.1 → 0.4.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/dist/index.d.mts +34 -2
- package/dist/index.mjs +523 -12
- package/dist/{jsx-Crlbye9V.mjs → jsx-B9HB9_cS.mjs} +1 -1
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-dev-runtime.mjs +1 -1
- package/dist/{jsx-runtime-CJ9_d_0Q.d.mts → jsx-runtime-BMKEs7aG.d.mts} +24 -3
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
|
-
import { $ as ImageCropAuthoring, $t as
|
|
1
|
+
import { $ as ImageCropAuthoring, $t as SemanticDocumentNode, A as CssBoxSizing, At as TextRunStyle, B as CssGridTemplateAreas, Bt as CompositionContext, C as ClassNameValueArray, Cn as StyleDiagnosticError, Ct as StyleClassStyle, D as CssAlignItems, Dt as TextJsxChild, E as CssAlignContent, En as SourceSpan, Et as TextFit, F as CssGridAutoFlow, Ft as VerticalAlign, G as CssObjectPosition, Gt as SourceContextInput, H as CssGridTrack, Ht as CompositionSourceInternals, I as CssGridLine, It as ViewProps, J as CssVisibility, Jt as AssetEntityId, K as CssOverflow, Kt as SourceContextMapper, L as CssGridPlacement, Lt as ViewStyle, M as CssFlexBasis, Mt as TextTabStopAlignment, N as CssFlexDirection, Nt as TextTabStopAuthoring, O as CssAlignSelf, Ot as TextProps, P as CssFlexWrap, Pt as TextTabStopLength, Q as DeckPointLength, Qt as SemanticContainerNode, R as CssGridShorthand, Rt as defineStyles, S as ClassNameValue, Sn as SemanticGraphDiagnosticError, St as StyleClassDefinition, T as ContentJsxChild, Tn as JsxKey, Tt as StyleTargetSelector, U as CssJustifyContent, Ut as SlideFactory, V as CssGridTemplateShorthand, Vt as CompositionSource, W as CssJustifySelf, Wt as SlideFactoryInput, X as DeckLength, Xt as GraphNodeId, Y as DeckJsxIntrinsicElements, Yt as BaseSemanticNode, Z as DeckOptions, Zt as SemanticAuthorGraph, _ as AuthorNodeProps, _n as Diagnostics, _t as StackAlignment, a as createElement, an as SemanticShapeNode, at as IntrinsicImgProps, b as BorderStyle, bn as CompositionDiagnosticError, bt as StrokeLineCap, c as isSlideNode, cn as SemanticTextRunNode, ct as IntrinsicViewTag, d as Slide, dn as StyleClassRef, dt as OutputConfig, en as SemanticImageNode, et as ImageCropValue, f as Text, fn as StyleEntity, ft as ShapeProps, g as AuthorNodeMap, gn as DiagnosticSeverity, gt as Spacing, h as AuthorNodeKind, hn as DiagnosticLabel, ht as SlideStyle, i as Fragment, in as SemanticRole, it as IntrinsicDivProps, j as CssDisplay, jt as TextStyle, k as CssAspectRatio, kt as TextRunNodeProps, l as Image, ln as SourceIdentity, lt as JsxNode, m as AuthorNode, mn as Diagnostic, mt as SlideProps, nn as SemanticNodeKind, nt as ImageStyle, o as isAuthorNode, on as SemanticSlideNode, ot as IntrinsicPProps, p as View, pn as StyleEntityId, pt as ShapeStyle, q as CssPosition, qt as AssetEntity, rn as SemanticOrigin, rt as ImplementedBackendName, s as isContentNode, sn as SemanticTextNode, st as IntrinsicTextTag, tn as SemanticNode, tt as ImageProps, u as Shape, un as SourceOrigin, ut as LayoutMode, v as AuthorNodePropsMap, vn as formatDiagnostic, vt as StackAxis, w as ContentAuthorNode, wt as StyleSheet, x as ClassNameObject, xn as DeckDiagnosticError, xt as StrokeLineJoin, y as BackendName, yn as formatDiagnostics, yt as StrokeDashType, z as CssGridTemplate, zt as COMPOSITION_SOURCE } from "./jsx-runtime-BMKEs7aG.mjs";
|
|
2
2
|
|
|
3
|
+
//#region src/style/resolve.d.ts
|
|
4
|
+
type ResolvedStyleLayer = "default" | "theme" | "class" | "style";
|
|
5
|
+
type ResolvedStyleSource = {
|
|
6
|
+
readonly layer: "default";
|
|
7
|
+
} | {
|
|
8
|
+
readonly layer: "theme";
|
|
9
|
+
} | {
|
|
10
|
+
readonly layer: "class";
|
|
11
|
+
readonly className: string;
|
|
12
|
+
readonly stylesheetIndex: number;
|
|
13
|
+
readonly ruleIndex: number;
|
|
14
|
+
readonly selector: string;
|
|
15
|
+
} | {
|
|
16
|
+
readonly layer: "style";
|
|
17
|
+
};
|
|
18
|
+
type ResolvedStyleProperty = {
|
|
19
|
+
readonly value: unknown;
|
|
20
|
+
readonly source: ResolvedStyleSource;
|
|
21
|
+
};
|
|
22
|
+
type ResolvedStyle = {
|
|
23
|
+
readonly style: Readonly<Record<string, unknown>>;
|
|
24
|
+
readonly properties: Readonly<Record<string, ResolvedStyleProperty>>;
|
|
25
|
+
readonly appliedClasses: readonly ResolvedStyleSource[];
|
|
26
|
+
};
|
|
27
|
+
type ResolvedStyleMap = ReadonlyMap<StyleEntityId, ResolvedStyle>;
|
|
28
|
+
type StyleResolutionResult = {
|
|
29
|
+
readonly resolvedStyles: ResolvedStyleMap;
|
|
30
|
+
readonly diagnostics: Diagnostics;
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
3
33
|
//#region src/ir/index.d.ts
|
|
4
34
|
type PresentationIR = {
|
|
5
35
|
version: "0.1";
|
|
@@ -247,6 +277,7 @@ type CompileMode = "inspect" | "strict";
|
|
|
247
277
|
type CompileInspectResult = {
|
|
248
278
|
readonly graph?: SemanticAuthorGraph;
|
|
249
279
|
readonly diagnostics: Diagnostics;
|
|
280
|
+
readonly resolvedStyles?: ResolvedStyleMap;
|
|
250
281
|
};
|
|
251
282
|
type WithSource<TSourceContext> = [TSourceContext] extends [void] ? never : (sourceContext: TSourceContext) => BoundSource<TSourceContext>;
|
|
252
283
|
declare class BoundSource<TSourceContext = void> implements CompositionSource<TSourceContext> {
|
|
@@ -269,6 +300,7 @@ declare class Deck<TSourceContext = void> implements CompositionSource<TSourceCo
|
|
|
269
300
|
constructor(options: DeckOptions);
|
|
270
301
|
get options(): DeckOptions;
|
|
271
302
|
[COMPOSITION_SOURCE](): CompositionSourceInternals<TSourceContext>;
|
|
303
|
+
useStyles(stylesheet: StyleSheet): this;
|
|
272
304
|
add(slide: SlideFactory<TSourceContext>): this;
|
|
273
305
|
mount<TChildContext>(sourceKey: string, child: Deck<TChildContext>, ...context: [TChildContext] extends [void] ? [] : [sourceContext: SourceContextInput<TSourceContext, TChildContext>]): this;
|
|
274
306
|
mount<TChildContext>(sourceKey: string, child: BoundSource<TChildContext>): this;
|
|
@@ -304,4 +336,4 @@ declare global {
|
|
|
304
336
|
}
|
|
305
337
|
}
|
|
306
338
|
//#endregion
|
|
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 };
|
|
339
|
+
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 ResolvedStyle, type ResolvedStyleLayer, type ResolvedStyleMap, type ResolvedStyleProperty, type ResolvedStyleSource, 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 StyleClassDefinition, type StyleClassRef, type StyleClassStyle, StyleDiagnosticError, type StyleEntity, type StyleEntityId, type StyleResolutionResult, type StyleSheet, type StyleTargetSelector, Text, type TextBulletListIR, type TextContentIR, type TextFit, type TextIR, type TextJsxChild, type TextListIR, type TextNoListIR, type TextNumberListIR, type TextProps, type TextRunIR, type TextRunNodeProps, type TextRunStyle, type TextStyle, type TextStyleIR, type TextTabStopAlignment, type TextTabStopAuthoring, type TextTabStopIR, type TextTabStopLength, type VerticalAlign, View, type ViewProps, type ViewStyle, createElement, defineStyles, formatDiagnostic, formatDiagnostics, isAuthorNode, isContentNode, isSlideNode, pptxgenjsBackend };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isContentNode, c as toLegacyJsxNode, d as
|
|
1
|
+
import { a as isContentNode, c as toLegacyJsxNode, d as Shape, f as Slide, h as isAuthorTreeNode, i as isAuthorNode, l as isAuthoredTag, m as View, n as createElement, o as isSlideNode, p as Text, s as isLegacyAuthorNode, t as Fragment, u as Image } from "./jsx-B9HB9_cS.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
4
4
|
import { dirname } from "node:path";
|
|
@@ -28,6 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
}) : target, mod));
|
|
29
29
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
30
|
//#endregion
|
|
31
|
+
//#region src/authoring/index.ts
|
|
32
|
+
function defineStyles(stylesheet) {
|
|
33
|
+
return stylesheet;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
31
36
|
//#region src/types.ts
|
|
32
37
|
const EMU_PER_INCH = 914400;
|
|
33
38
|
const POINTS_PER_INCH = 72;
|
|
@@ -4189,6 +4194,12 @@ var CompositionDiagnosticError = class extends DeckDiagnosticError {
|
|
|
4189
4194
|
this.name = "CompositionDiagnosticError";
|
|
4190
4195
|
}
|
|
4191
4196
|
};
|
|
4197
|
+
var StyleDiagnosticError = class extends DeckDiagnosticError {
|
|
4198
|
+
constructor(diagnostics) {
|
|
4199
|
+
super(formatDiagnostics(diagnostics), diagnostics);
|
|
4200
|
+
this.name = "StyleDiagnosticError";
|
|
4201
|
+
}
|
|
4202
|
+
};
|
|
4192
4203
|
//#endregion
|
|
4193
4204
|
//#region src/diagnostics/index.ts
|
|
4194
4205
|
function createDiagnostics(items = []) {
|
|
@@ -4402,6 +4413,7 @@ function resolveSource(source, context) {
|
|
|
4402
4413
|
return {
|
|
4403
4414
|
source: context.source,
|
|
4404
4415
|
sourceIdentityMaterial: context.sourceIdentityMaterial,
|
|
4416
|
+
stylesheets: sourceState.stylesheets,
|
|
4405
4417
|
context: effectiveContext,
|
|
4406
4418
|
entries,
|
|
4407
4419
|
slideCount,
|
|
@@ -4440,6 +4452,7 @@ function flattenPlan(plan, deckTotalSlides, deckSlideIndex, roots, diagnostics)
|
|
|
4440
4452
|
root,
|
|
4441
4453
|
source: plan.source,
|
|
4442
4454
|
sourceIdentityMaterial: plan.sourceIdentityMaterial,
|
|
4455
|
+
stylesheets: plan.stylesheets,
|
|
4443
4456
|
path: entry.path,
|
|
4444
4457
|
composition,
|
|
4445
4458
|
slotOrigins: plan.slotOrigins
|
|
@@ -4489,7 +4502,7 @@ function assetEntityId(material) {
|
|
|
4489
4502
|
//#region src/graph/roles.ts
|
|
4490
4503
|
function semanticKindForTag(tag) {
|
|
4491
4504
|
if (tag === "img") return "image";
|
|
4492
|
-
if (tag === "p" || tag
|
|
4505
|
+
if (tag === "p" || /^h[1-6]$/.test(tag) || tag === "span") return tag === "span" ? "textRun" : "text";
|
|
4493
4506
|
return "container";
|
|
4494
4507
|
}
|
|
4495
4508
|
function semanticKindForComponent(component) {
|
|
@@ -4581,10 +4594,6 @@ function textOriginFor(node, path, context) {
|
|
|
4581
4594
|
...node.sourceSpan ? { sourceSpan: node.sourceSpan } : {}
|
|
4582
4595
|
};
|
|
4583
4596
|
}
|
|
4584
|
-
function propsWithoutStyle(props) {
|
|
4585
|
-
const { style: _style, children: _children, className: _className, ...direct } = props;
|
|
4586
|
-
return Object.keys(direct).length === 0 ? void 0 : direct;
|
|
4587
|
-
}
|
|
4588
4597
|
function collectClassNames(value, names) {
|
|
4589
4598
|
if (value === false || value === null || value === void 0) return;
|
|
4590
4599
|
if (typeof value === "string") {
|
|
@@ -4607,18 +4616,30 @@ function classRefsFor(value) {
|
|
|
4607
4616
|
index
|
|
4608
4617
|
}));
|
|
4609
4618
|
}
|
|
4619
|
+
function directStyleProps(props) {
|
|
4620
|
+
const { children: _children, className: _className, data: _data, name: _name, shape: _shape, src: _src, style: _style, ...directStyle } = props;
|
|
4621
|
+
return Object.keys(directStyle).length === 0 ? void 0 : directStyle;
|
|
4622
|
+
}
|
|
4623
|
+
function mergedAuthoredStyle(props) {
|
|
4624
|
+
const directStyle = directStyleProps(props);
|
|
4625
|
+
const inlineStyle = props.style;
|
|
4626
|
+
if (directStyle === void 0) return inlineStyle;
|
|
4627
|
+
if (inlineStyle !== void 0 && (typeof inlineStyle !== "object" || inlineStyle === null || Array.isArray(inlineStyle))) return inlineStyle;
|
|
4628
|
+
return {
|
|
4629
|
+
...directStyle,
|
|
4630
|
+
...inlineStyle
|
|
4631
|
+
};
|
|
4632
|
+
}
|
|
4610
4633
|
function styleRefFor(state, idMaterial, target, props) {
|
|
4611
|
-
const style = props
|
|
4612
|
-
const direct = propsWithoutStyle(props);
|
|
4634
|
+
const style = mergedAuthoredStyle(props);
|
|
4613
4635
|
const classRefs = classRefsFor(props.className);
|
|
4614
|
-
if (style === void 0 &&
|
|
4636
|
+
if (style === void 0 && classRefs === void 0) return;
|
|
4615
4637
|
const id = styleEntityId(idMaterial);
|
|
4616
4638
|
state.styles.set(id, {
|
|
4617
4639
|
id,
|
|
4618
4640
|
target,
|
|
4619
4641
|
authored: {
|
|
4620
4642
|
...style !== void 0 ? { style } : {},
|
|
4621
|
-
...direct !== void 0 ? { direct } : {},
|
|
4622
4643
|
...classRefs !== void 0 ? { classRefs } : {}
|
|
4623
4644
|
}
|
|
4624
4645
|
});
|
|
@@ -4875,6 +4896,7 @@ function asComposedRoot(root, index) {
|
|
|
4875
4896
|
root,
|
|
4876
4897
|
source: rootSource(),
|
|
4877
4898
|
sourceIdentityMaterial: ["source", "root"],
|
|
4899
|
+
stylesheets: [],
|
|
4878
4900
|
path: `document > slideFactory[${index}]`,
|
|
4879
4901
|
composition: {
|
|
4880
4902
|
slideIndex: index,
|
|
@@ -4934,6 +4956,478 @@ function buildSemanticAuthorGraph(roots) {
|
|
|
4934
4956
|
};
|
|
4935
4957
|
}
|
|
4936
4958
|
//#endregion
|
|
4959
|
+
//#region src/style/resolve.ts
|
|
4960
|
+
const EMPTY_CLASS_NAMES = /* @__PURE__ */ new Set();
|
|
4961
|
+
function sourceKeyFor(source) {
|
|
4962
|
+
return !source || source.kind === "root" ? "root" : source.sourceIdentity;
|
|
4963
|
+
}
|
|
4964
|
+
function classesBySource(roots) {
|
|
4965
|
+
const stylesheets = /* @__PURE__ */ new Map();
|
|
4966
|
+
roots.forEach((root) => {
|
|
4967
|
+
const key = sourceKeyFor(root.source);
|
|
4968
|
+
if (!stylesheets.has(key)) stylesheets.set(key, root.stylesheets);
|
|
4969
|
+
});
|
|
4970
|
+
return stylesheets;
|
|
4971
|
+
}
|
|
4972
|
+
function isTargetedDefinition(definition) {
|
|
4973
|
+
return typeof definition === "object" && definition !== null && "style" in definition && typeof definition.style === "object" && definition.style !== null;
|
|
4974
|
+
}
|
|
4975
|
+
function styleObjectFor(definition) {
|
|
4976
|
+
return isTargetedDefinition(definition) ? definition.style : definition;
|
|
4977
|
+
}
|
|
4978
|
+
function targetsFor(definition) {
|
|
4979
|
+
if (!isTargetedDefinition(definition) || definition.target === void 0) return;
|
|
4980
|
+
return typeof definition.target === "string" ? [definition.target] : definition.target;
|
|
4981
|
+
}
|
|
4982
|
+
function invalidClassNameReason(name) {
|
|
4983
|
+
if (name.trim().length === 0) return "Style Class names must not be empty.";
|
|
4984
|
+
if (/\s/.test(name)) return "Style Class names must not contain whitespace.";
|
|
4985
|
+
}
|
|
4986
|
+
function styleDiagnostic(input) {
|
|
4987
|
+
return diagnostic({
|
|
4988
|
+
severity: input.severity ?? "error",
|
|
4989
|
+
code: input.code,
|
|
4990
|
+
title: input.title,
|
|
4991
|
+
message: input.message,
|
|
4992
|
+
labels: [{
|
|
4993
|
+
path: input.path,
|
|
4994
|
+
message: input.message
|
|
4995
|
+
}],
|
|
4996
|
+
...input.help ? { help: input.help } : {}
|
|
4997
|
+
});
|
|
4998
|
+
}
|
|
4999
|
+
function compareSpecificity(left, right) {
|
|
5000
|
+
return left[0] - right[0] || left[1] - right[1] || left[2] - right[2];
|
|
5001
|
+
}
|
|
5002
|
+
function addSpecificity(left, right) {
|
|
5003
|
+
return [
|
|
5004
|
+
left[0] + right[0],
|
|
5005
|
+
left[1] + right[1],
|
|
5006
|
+
left[2] + right[2]
|
|
5007
|
+
];
|
|
5008
|
+
}
|
|
5009
|
+
function isHexDigit(value) {
|
|
5010
|
+
return value !== void 0 && /^[0-9a-fA-F]$/.test(value);
|
|
5011
|
+
}
|
|
5012
|
+
function isSelectorDelimiter(value) {
|
|
5013
|
+
return value === void 0 || /[\s.#:[\]>+~*,/]/.test(value);
|
|
5014
|
+
}
|
|
5015
|
+
function decodeEscape(input, start) {
|
|
5016
|
+
const next = input[start + 1];
|
|
5017
|
+
if (next === void 0 || next === "\n" || next === "\r" || next === "\f") return;
|
|
5018
|
+
if (!isHexDigit(next)) return {
|
|
5019
|
+
value: next,
|
|
5020
|
+
next: start + 2
|
|
5021
|
+
};
|
|
5022
|
+
let index = start + 1;
|
|
5023
|
+
let hex = "";
|
|
5024
|
+
while (index < input.length && hex.length < 6 && isHexDigit(input[index])) {
|
|
5025
|
+
hex += input[index];
|
|
5026
|
+
index += 1;
|
|
5027
|
+
}
|
|
5028
|
+
if (/\s/.test(input[index] ?? "")) index += 1;
|
|
5029
|
+
const codePoint = Number.parseInt(hex, 16);
|
|
5030
|
+
if (codePoint === 0 || codePoint > 1114111) return {
|
|
5031
|
+
value: "�",
|
|
5032
|
+
next: index
|
|
5033
|
+
};
|
|
5034
|
+
return {
|
|
5035
|
+
value: String.fromCodePoint(codePoint),
|
|
5036
|
+
next: index
|
|
5037
|
+
};
|
|
5038
|
+
}
|
|
5039
|
+
function parseClassIdentifier(input, start) {
|
|
5040
|
+
let index = start;
|
|
5041
|
+
let value = "";
|
|
5042
|
+
while (index < input.length && !isSelectorDelimiter(input[index])) {
|
|
5043
|
+
if (input[index] === "\\") {
|
|
5044
|
+
const escaped = decodeEscape(input, index);
|
|
5045
|
+
if (!escaped) return;
|
|
5046
|
+
value += escaped.value;
|
|
5047
|
+
index = escaped.next;
|
|
5048
|
+
continue;
|
|
5049
|
+
}
|
|
5050
|
+
value += input[index];
|
|
5051
|
+
index += 1;
|
|
5052
|
+
}
|
|
5053
|
+
return value.length === 0 ? void 0 : {
|
|
5054
|
+
value,
|
|
5055
|
+
next: index
|
|
5056
|
+
};
|
|
5057
|
+
}
|
|
5058
|
+
function cssEscapeIdentifier(value) {
|
|
5059
|
+
let escaped = "";
|
|
5060
|
+
const firstCodePoint = value.codePointAt(0);
|
|
5061
|
+
let position = 0;
|
|
5062
|
+
for (const char of value) {
|
|
5063
|
+
const codePoint = char.codePointAt(0);
|
|
5064
|
+
if (codePoint === void 0) continue;
|
|
5065
|
+
if (codePoint === 0) {
|
|
5066
|
+
escaped += "�";
|
|
5067
|
+
position += 1;
|
|
5068
|
+
continue;
|
|
5069
|
+
}
|
|
5070
|
+
if (codePoint >= 1 && codePoint <= 31 || codePoint === 127 || position === 0 && codePoint >= 48 && codePoint <= 57 || position === 1 && codePoint >= 48 && codePoint <= 57 && firstCodePoint === 45) {
|
|
5071
|
+
escaped += `\\${codePoint.toString(16)} `;
|
|
5072
|
+
position += 1;
|
|
5073
|
+
continue;
|
|
5074
|
+
}
|
|
5075
|
+
if (position === 0 && value === "-" && codePoint === 45) {
|
|
5076
|
+
escaped += `\\${char}`;
|
|
5077
|
+
position += 1;
|
|
5078
|
+
continue;
|
|
5079
|
+
}
|
|
5080
|
+
if (codePoint >= 128 || codePoint === 45 || codePoint === 95 || codePoint >= 48 && codePoint <= 57 || codePoint >= 65 && codePoint <= 90 || codePoint >= 97 && codePoint <= 122) {
|
|
5081
|
+
escaped += char;
|
|
5082
|
+
position += 1;
|
|
5083
|
+
continue;
|
|
5084
|
+
}
|
|
5085
|
+
escaped += `\\${char}`;
|
|
5086
|
+
position += 1;
|
|
5087
|
+
}
|
|
5088
|
+
return escaped;
|
|
5089
|
+
}
|
|
5090
|
+
function parseSelectorPart(value) {
|
|
5091
|
+
if (value.length === 0) return;
|
|
5092
|
+
const tag = value.match(/^[a-z][a-z0-9-]*/)?.[0];
|
|
5093
|
+
if (tag !== void 0 && !isAuthoredTag(tag)) return;
|
|
5094
|
+
const rest = tag ? value.slice(tag.length) : value;
|
|
5095
|
+
if (rest.length === 0) return {
|
|
5096
|
+
part: {
|
|
5097
|
+
...tag ? { tag } : {},
|
|
5098
|
+
classes: []
|
|
5099
|
+
},
|
|
5100
|
+
specificity: [
|
|
5101
|
+
0,
|
|
5102
|
+
0,
|
|
5103
|
+
tag ? 1 : 0
|
|
5104
|
+
]
|
|
5105
|
+
};
|
|
5106
|
+
const classes = [];
|
|
5107
|
+
let index = 0;
|
|
5108
|
+
while (index < rest.length) {
|
|
5109
|
+
if (rest[index] !== ".") return;
|
|
5110
|
+
const parsedClass = parseClassIdentifier(rest, index + 1);
|
|
5111
|
+
if (!parsedClass) return;
|
|
5112
|
+
classes.push(parsedClass.value);
|
|
5113
|
+
index = parsedClass.next;
|
|
5114
|
+
}
|
|
5115
|
+
return {
|
|
5116
|
+
part: {
|
|
5117
|
+
...tag ? { tag } : {},
|
|
5118
|
+
classes
|
|
5119
|
+
},
|
|
5120
|
+
specificity: [
|
|
5121
|
+
0,
|
|
5122
|
+
classes.length,
|
|
5123
|
+
tag ? 1 : 0
|
|
5124
|
+
]
|
|
5125
|
+
};
|
|
5126
|
+
}
|
|
5127
|
+
function parseSelector(selector) {
|
|
5128
|
+
const value = selector.trim();
|
|
5129
|
+
if (value.length === 0) return;
|
|
5130
|
+
const parsedParts = splitSelectorParts(value).map(parseSelectorPart);
|
|
5131
|
+
const parts = [];
|
|
5132
|
+
let specificity = [
|
|
5133
|
+
0,
|
|
5134
|
+
0,
|
|
5135
|
+
0
|
|
5136
|
+
];
|
|
5137
|
+
for (const parsedPart of parsedParts) {
|
|
5138
|
+
if (parsedPart === void 0) return;
|
|
5139
|
+
parts.push(parsedPart.part);
|
|
5140
|
+
specificity = addSpecificity(specificity, parsedPart.specificity);
|
|
5141
|
+
}
|
|
5142
|
+
if (parts.length === 0) return;
|
|
5143
|
+
return {
|
|
5144
|
+
parts,
|
|
5145
|
+
specificity
|
|
5146
|
+
};
|
|
5147
|
+
}
|
|
5148
|
+
function splitSelectorParts(value) {
|
|
5149
|
+
const parts = [];
|
|
5150
|
+
let current = "";
|
|
5151
|
+
let index = 0;
|
|
5152
|
+
while (index < value.length) {
|
|
5153
|
+
const char = value[index];
|
|
5154
|
+
if (/\s/.test(char)) {
|
|
5155
|
+
if (current.length > 0) {
|
|
5156
|
+
parts.push(current);
|
|
5157
|
+
current = "";
|
|
5158
|
+
}
|
|
5159
|
+
index += 1;
|
|
5160
|
+
continue;
|
|
5161
|
+
}
|
|
5162
|
+
if (char !== "\\") {
|
|
5163
|
+
current += char;
|
|
5164
|
+
index += 1;
|
|
5165
|
+
continue;
|
|
5166
|
+
}
|
|
5167
|
+
const next = value[index + 1];
|
|
5168
|
+
current += char;
|
|
5169
|
+
if (isHexDigit(next)) {
|
|
5170
|
+
let hexIndex = index + 1;
|
|
5171
|
+
let hexLength = 0;
|
|
5172
|
+
while (hexIndex < value.length && hexLength < 6 && isHexDigit(value[hexIndex])) {
|
|
5173
|
+
current += value[hexIndex];
|
|
5174
|
+
hexIndex += 1;
|
|
5175
|
+
hexLength += 1;
|
|
5176
|
+
}
|
|
5177
|
+
if (/\s/.test(value[hexIndex] ?? "")) {
|
|
5178
|
+
current += value[hexIndex];
|
|
5179
|
+
hexIndex += 1;
|
|
5180
|
+
}
|
|
5181
|
+
index = hexIndex;
|
|
5182
|
+
continue;
|
|
5183
|
+
}
|
|
5184
|
+
if (next !== void 0) {
|
|
5185
|
+
current += next;
|
|
5186
|
+
index += 2;
|
|
5187
|
+
continue;
|
|
5188
|
+
}
|
|
5189
|
+
index += 1;
|
|
5190
|
+
}
|
|
5191
|
+
if (current.length > 0) parts.push(current);
|
|
5192
|
+
return parts;
|
|
5193
|
+
}
|
|
5194
|
+
function selectorFor(className, target) {
|
|
5195
|
+
if (target === void 0) return `.${cssEscapeIdentifier(className)}`;
|
|
5196
|
+
return target;
|
|
5197
|
+
}
|
|
5198
|
+
function rightmostSelectorHasClass(selector, className) {
|
|
5199
|
+
return selector.parts.at(-1)?.classes.includes(className) ?? false;
|
|
5200
|
+
}
|
|
5201
|
+
function collectSelectorConditionClassNames(className, selector) {
|
|
5202
|
+
return selector.parts.flatMap((part, index) => index === selector.parts.length - 1 ? part.classes.filter((name) => name !== className) : part.classes);
|
|
5203
|
+
}
|
|
5204
|
+
function classNamesFor(node, context) {
|
|
5205
|
+
return context.classNamesByNodeId.get(node.id) ?? EMPTY_CLASS_NAMES;
|
|
5206
|
+
}
|
|
5207
|
+
function selectorPartMatches(part, node, context) {
|
|
5208
|
+
if (part.tag !== void 0 && node.authoredTag !== part.tag) return false;
|
|
5209
|
+
const activeClassNames = classNamesFor(node, context);
|
|
5210
|
+
return part.classes.every((name) => activeClassNames.has(name));
|
|
5211
|
+
}
|
|
5212
|
+
function ancestorMatches(parts, node, context) {
|
|
5213
|
+
let parentId = context.parentById.get(node.id);
|
|
5214
|
+
for (let index = parts.length - 1; index >= 0; index -= 1) {
|
|
5215
|
+
const part = parts[index];
|
|
5216
|
+
let matched = false;
|
|
5217
|
+
while (parentId !== void 0) {
|
|
5218
|
+
const parent = context.graph.nodes.get(parentId);
|
|
5219
|
+
parentId = context.parentById.get(parentId);
|
|
5220
|
+
if (!parent) continue;
|
|
5221
|
+
if (selectorPartMatches(part, parent, context)) {
|
|
5222
|
+
matched = true;
|
|
5223
|
+
break;
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
if (!matched) return false;
|
|
5227
|
+
}
|
|
5228
|
+
return true;
|
|
5229
|
+
}
|
|
5230
|
+
function selectorMatches(className, selector, node, activeClassNames, context) {
|
|
5231
|
+
if (!activeClassNames.has(className)) return false;
|
|
5232
|
+
const targetPart = selector.parts.at(-1);
|
|
5233
|
+
if (!targetPart || !selectorPartMatches(targetPart, node, context)) return false;
|
|
5234
|
+
return ancestorMatches(selector.parts.slice(0, -1), node, context);
|
|
5235
|
+
}
|
|
5236
|
+
function registerStylesheets(sourceKey, stylesheets, diagnostics) {
|
|
5237
|
+
const classes = /* @__PURE__ */ new Map();
|
|
5238
|
+
const selectorConditionClassNames = /* @__PURE__ */ new Set();
|
|
5239
|
+
let ruleIndex = 0;
|
|
5240
|
+
stylesheets?.forEach((stylesheet, stylesheetIndex) => {
|
|
5241
|
+
Object.entries(stylesheet.classes).forEach(([className, definition]) => {
|
|
5242
|
+
const path = `source:${sourceKey} > stylesheet[${stylesheetIndex}].classes.${className}`;
|
|
5243
|
+
const invalidReason = invalidClassNameReason(className);
|
|
5244
|
+
if (invalidReason) {
|
|
5245
|
+
diagnostics.push(styleDiagnostic({
|
|
5246
|
+
code: "E_STYLE_INVALID_CLASS_NAME",
|
|
5247
|
+
title: "invalid style class name",
|
|
5248
|
+
path,
|
|
5249
|
+
message: invalidReason
|
|
5250
|
+
}));
|
|
5251
|
+
return;
|
|
5252
|
+
}
|
|
5253
|
+
const targets = targetsFor(definition);
|
|
5254
|
+
const selectorTexts = targets === void 0 ? [selectorFor(className, void 0)] : targets;
|
|
5255
|
+
let hasTargetDiagnostics = false;
|
|
5256
|
+
const selectors = [];
|
|
5257
|
+
selectorTexts.forEach((selectorText) => {
|
|
5258
|
+
const selector = parseSelector(selectorText);
|
|
5259
|
+
if (!selector) {
|
|
5260
|
+
hasTargetDiagnostics = true;
|
|
5261
|
+
diagnostics.push(styleDiagnostic({
|
|
5262
|
+
code: "E_STYLE_UNSUPPORTED_SELECTOR",
|
|
5263
|
+
title: "unsupported stylesheet selector",
|
|
5264
|
+
path,
|
|
5265
|
+
message: `Selector "${selectorText}" is not supported in v0.4.1.`,
|
|
5266
|
+
help: ["Use class, tag, compound tag/class, or descendant selectors such as .title, p.title, or .card .caption."]
|
|
5267
|
+
}));
|
|
5268
|
+
return;
|
|
5269
|
+
}
|
|
5270
|
+
if (!rightmostSelectorHasClass(selector, className)) {
|
|
5271
|
+
hasTargetDiagnostics = true;
|
|
5272
|
+
diagnostics.push(styleDiagnostic({
|
|
5273
|
+
code: "E_STYLE_INVALID_CLASS_TARGET",
|
|
5274
|
+
title: "style class target must include its class selector",
|
|
5275
|
+
path,
|
|
5276
|
+
message: `Style Class "${className}" target must include .${cssEscapeIdentifier(className)} in the rightmost selector.`,
|
|
5277
|
+
help: ["Write the target as a CSS selector such as p.title or .card .title."]
|
|
5278
|
+
}));
|
|
5279
|
+
return;
|
|
5280
|
+
}
|
|
5281
|
+
collectSelectorConditionClassNames(className, selector).forEach((name) => selectorConditionClassNames.add(name));
|
|
5282
|
+
selectors.push({
|
|
5283
|
+
text: selectorText,
|
|
5284
|
+
selector
|
|
5285
|
+
});
|
|
5286
|
+
});
|
|
5287
|
+
const list = classes.get(className) ?? [];
|
|
5288
|
+
classes.set(className, [...list, {
|
|
5289
|
+
className,
|
|
5290
|
+
definition,
|
|
5291
|
+
stylesheetIndex,
|
|
5292
|
+
ruleIndex: ruleIndex++,
|
|
5293
|
+
path,
|
|
5294
|
+
selectors,
|
|
5295
|
+
hasTargetDiagnostics
|
|
5296
|
+
}]);
|
|
5297
|
+
});
|
|
5298
|
+
});
|
|
5299
|
+
return {
|
|
5300
|
+
classes,
|
|
5301
|
+
selectorConditionClassNames
|
|
5302
|
+
};
|
|
5303
|
+
}
|
|
5304
|
+
function resolveClassMatches(node, entity, registry, context, diagnostics) {
|
|
5305
|
+
const classRefs = entity.authored.classRefs ?? [];
|
|
5306
|
+
const activeClassNames = new Set(classRefs.map((ref) => ref.name));
|
|
5307
|
+
const matched = [];
|
|
5308
|
+
[...activeClassNames].forEach((className) => {
|
|
5309
|
+
const registrations = registry.classes.get(className);
|
|
5310
|
+
if (!registrations || registrations.length === 0) {
|
|
5311
|
+
if (!registry.selectorConditionClassNames.has(className)) diagnostics.push(styleDiagnostic({
|
|
5312
|
+
severity: "warning",
|
|
5313
|
+
code: "E_STYLE_UNKNOWN_CLASS",
|
|
5314
|
+
title: "unknown style class",
|
|
5315
|
+
path: node.origin.path,
|
|
5316
|
+
message: `Style Class "${className}" is referenced but is not defined in this source.`,
|
|
5317
|
+
help: ["Register a stylesheet with deck.useStyles() on the same Deck source."]
|
|
5318
|
+
}));
|
|
5319
|
+
return;
|
|
5320
|
+
}
|
|
5321
|
+
const before = matched.length;
|
|
5322
|
+
let hasTargetDiagnostics = false;
|
|
5323
|
+
registrations.forEach((registration) => {
|
|
5324
|
+
hasTargetDiagnostics ||= registration.hasTargetDiagnostics;
|
|
5325
|
+
registration.selectors.forEach(({ selector, text }) => {
|
|
5326
|
+
if (!selectorMatches(className, selector, node, activeClassNames, context)) return;
|
|
5327
|
+
matched.push({
|
|
5328
|
+
registration,
|
|
5329
|
+
selector: text,
|
|
5330
|
+
specificity: selector.specificity,
|
|
5331
|
+
style: styleObjectFor(registration.definition)
|
|
5332
|
+
});
|
|
5333
|
+
});
|
|
5334
|
+
});
|
|
5335
|
+
if (matched.length === before && !hasTargetDiagnostics) diagnostics.push(styleDiagnostic({
|
|
5336
|
+
code: "E_STYLE_TARGET_MISMATCH",
|
|
5337
|
+
title: "style class target does not match element",
|
|
5338
|
+
path: node.origin.path,
|
|
5339
|
+
message: `Style Class "${className}" is defined but no target matches this element.`,
|
|
5340
|
+
help: ["Adjust the class target selector or move the className to a matching element."]
|
|
5341
|
+
}));
|
|
5342
|
+
});
|
|
5343
|
+
return matched.sort((left, right) => {
|
|
5344
|
+
return compareSpecificity(left.specificity, right.specificity) || left.registration.ruleIndex - right.registration.ruleIndex;
|
|
5345
|
+
});
|
|
5346
|
+
}
|
|
5347
|
+
function applyProperties(style, source, properties) {
|
|
5348
|
+
Object.entries(style).forEach(([key, value]) => {
|
|
5349
|
+
properties[key] = {
|
|
5350
|
+
value,
|
|
5351
|
+
source
|
|
5352
|
+
};
|
|
5353
|
+
});
|
|
5354
|
+
}
|
|
5355
|
+
function resolvedStyleFor(node, entity, registry, context, diagnostics) {
|
|
5356
|
+
const properties = {};
|
|
5357
|
+
const appliedClasses = [];
|
|
5358
|
+
resolveClassMatches(node, entity, registry, context, diagnostics).forEach((match) => {
|
|
5359
|
+
const source = {
|
|
5360
|
+
layer: "class",
|
|
5361
|
+
className: match.registration.className,
|
|
5362
|
+
stylesheetIndex: match.registration.stylesheetIndex,
|
|
5363
|
+
ruleIndex: match.registration.ruleIndex,
|
|
5364
|
+
selector: match.selector
|
|
5365
|
+
};
|
|
5366
|
+
appliedClasses.push(source);
|
|
5367
|
+
applyProperties(match.style, source, properties);
|
|
5368
|
+
});
|
|
5369
|
+
if (typeof entity.authored.style === "object" && entity.authored.style !== null) applyProperties(entity.authored.style, { layer: "style" }, properties);
|
|
5370
|
+
return {
|
|
5371
|
+
style: Object.fromEntries(Object.entries(properties).map(([key, property]) => [key, property.value])),
|
|
5372
|
+
properties,
|
|
5373
|
+
appliedClasses
|
|
5374
|
+
};
|
|
5375
|
+
}
|
|
5376
|
+
function nodeByStyleRef(graph) {
|
|
5377
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
5378
|
+
graph.nodes.forEach((node) => {
|
|
5379
|
+
if (node.styleRef) nodes.set(node.styleRef, node);
|
|
5380
|
+
});
|
|
5381
|
+
return nodes;
|
|
5382
|
+
}
|
|
5383
|
+
function parentMapFor(graph) {
|
|
5384
|
+
const parentById = /* @__PURE__ */ new Map();
|
|
5385
|
+
graph.nodes.forEach((node) => {
|
|
5386
|
+
("children" in node ? node.children : "inlineChildren" in node ? node.inlineChildren : []).forEach((childId) => {
|
|
5387
|
+
parentById.set(childId, node.id);
|
|
5388
|
+
});
|
|
5389
|
+
});
|
|
5390
|
+
return parentById;
|
|
5391
|
+
}
|
|
5392
|
+
function classNamesByNodeIdFor(graph) {
|
|
5393
|
+
const classNamesByNodeId = /* @__PURE__ */ new Map();
|
|
5394
|
+
graph.nodes.forEach((node) => {
|
|
5395
|
+
const classRefs = node.styleRef ? graph.styles.get(node.styleRef)?.authored.classRefs : void 0;
|
|
5396
|
+
classNamesByNodeId.set(node.id, new Set(classRefs?.map((ref) => ref.name) ?? []));
|
|
5397
|
+
});
|
|
5398
|
+
return classNamesByNodeId;
|
|
5399
|
+
}
|
|
5400
|
+
function resolveStyles(graph, roots) {
|
|
5401
|
+
const diagnostics = [];
|
|
5402
|
+
const stylesheets = classesBySource(roots);
|
|
5403
|
+
const registries = /* @__PURE__ */ new Map();
|
|
5404
|
+
const nodes = nodeByStyleRef(graph);
|
|
5405
|
+
const selectorContext = {
|
|
5406
|
+
graph,
|
|
5407
|
+
parentById: parentMapFor(graph),
|
|
5408
|
+
classNamesByNodeId: classNamesByNodeIdFor(graph)
|
|
5409
|
+
};
|
|
5410
|
+
const resolvedStyles = /* @__PURE__ */ new Map();
|
|
5411
|
+
stylesheets.forEach((sourceStylesheets, sourceKey) => {
|
|
5412
|
+
registries.set(sourceKey, registerStylesheets(sourceKey, sourceStylesheets, diagnostics));
|
|
5413
|
+
});
|
|
5414
|
+
graph.styles.forEach((entity, id) => {
|
|
5415
|
+
const node = nodes.get(id);
|
|
5416
|
+
if (!node) return;
|
|
5417
|
+
const sourceKey = sourceKeyFor(node.origin.source);
|
|
5418
|
+
let registry = registries.get(sourceKey);
|
|
5419
|
+
if (!registry) {
|
|
5420
|
+
registry = registerStylesheets(sourceKey, stylesheets.get(sourceKey), diagnostics);
|
|
5421
|
+
registries.set(sourceKey, registry);
|
|
5422
|
+
}
|
|
5423
|
+
resolvedStyles.set(id, resolvedStyleFor(node, entity, registry, selectorContext, diagnostics));
|
|
5424
|
+
});
|
|
5425
|
+
return {
|
|
5426
|
+
resolvedStyles,
|
|
5427
|
+
diagnostics: createDiagnostics(diagnostics)
|
|
5428
|
+
};
|
|
5429
|
+
}
|
|
5430
|
+
//#endregion
|
|
4937
5431
|
//#region node_modules/inherits/inherits_browser.js
|
|
4938
5432
|
var require_inherits_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4939
5433
|
if (typeof Object.create === "function") module.exports = function inherits(ctor, superCtor) {
|
|
@@ -16068,6 +16562,9 @@ function directSlideFactories(entries) {
|
|
|
16068
16562
|
function mountedSourceError() {
|
|
16069
16563
|
return /* @__PURE__ */ new Error("Mounted sources are supported by compile() only until the output pipeline supports graph composition.");
|
|
16070
16564
|
}
|
|
16565
|
+
function combineDiagnostics(...diagnostics) {
|
|
16566
|
+
return createDiagnostics(diagnostics.flatMap((item) => item.items));
|
|
16567
|
+
}
|
|
16071
16568
|
function compileSource(source, config = {}) {
|
|
16072
16569
|
const composition = resolveComposition(source);
|
|
16073
16570
|
if (composition.diagnostics.hasErrors) {
|
|
@@ -16075,8 +16572,15 @@ function compileSource(source, config = {}) {
|
|
|
16075
16572
|
throw new CompositionDiagnosticError(composition.diagnostics);
|
|
16076
16573
|
}
|
|
16077
16574
|
const result = buildSemanticAuthorGraph(composition.roots ?? []);
|
|
16078
|
-
|
|
16575
|
+
const styleResult = result.graph ? resolveStyles(result.graph, composition.roots ?? []) : void 0;
|
|
16576
|
+
const diagnostics = styleResult ? combineDiagnostics(result.diagnostics, styleResult.diagnostics) : result.diagnostics;
|
|
16577
|
+
if (config.mode === "inspect") return {
|
|
16578
|
+
...result.graph ? { graph: result.graph } : {},
|
|
16579
|
+
diagnostics,
|
|
16580
|
+
...styleResult ? { resolvedStyles: styleResult.resolvedStyles } : {}
|
|
16581
|
+
};
|
|
16079
16582
|
if (result.diagnostics.hasErrors) throw new SemanticGraphDiagnosticError(result.diagnostics);
|
|
16583
|
+
if (styleResult?.diagnostics.hasErrors) throw new StyleDiagnosticError(styleResult.diagnostics);
|
|
16080
16584
|
if (!result.graph) throw new SemanticGraphDiagnosticError(result.diagnostics);
|
|
16081
16585
|
return result.graph;
|
|
16082
16586
|
}
|
|
@@ -16091,6 +16595,7 @@ var BoundSource = class {
|
|
|
16091
16595
|
const source = this.#source[COMPOSITION_SOURCE]();
|
|
16092
16596
|
return {
|
|
16093
16597
|
entries: source.entries,
|
|
16598
|
+
stylesheets: source.stylesheets,
|
|
16094
16599
|
cycleId: source.cycleId,
|
|
16095
16600
|
boundContext: {
|
|
16096
16601
|
present: true,
|
|
@@ -16116,6 +16621,7 @@ var BoundSource = class {
|
|
|
16116
16621
|
var Deck = class {
|
|
16117
16622
|
#options;
|
|
16118
16623
|
#entries = [];
|
|
16624
|
+
#stylesheets = [];
|
|
16119
16625
|
withSource;
|
|
16120
16626
|
constructor(options) {
|
|
16121
16627
|
this.#options = options;
|
|
@@ -16127,10 +16633,15 @@ var Deck = class {
|
|
|
16127
16633
|
[COMPOSITION_SOURCE]() {
|
|
16128
16634
|
return {
|
|
16129
16635
|
entries: this.#entries,
|
|
16636
|
+
stylesheets: this.#stylesheets,
|
|
16130
16637
|
cycleId: this,
|
|
16131
16638
|
boundContext: { present: false }
|
|
16132
16639
|
};
|
|
16133
16640
|
}
|
|
16641
|
+
useStyles(stylesheet) {
|
|
16642
|
+
this.#stylesheets.push(stylesheet);
|
|
16643
|
+
return this;
|
|
16644
|
+
}
|
|
16134
16645
|
add(slide) {
|
|
16135
16646
|
this.#entries.push({
|
|
16136
16647
|
kind: "slide",
|
|
@@ -16160,4 +16671,4 @@ var Deck = class {
|
|
|
16160
16671
|
}
|
|
16161
16672
|
};
|
|
16162
16673
|
//#endregion
|
|
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 };
|
|
16674
|
+
export { CompositionDiagnosticError, Deck, DeckDiagnosticError, EMU_PER_INCH, Fragment, Image, POINTS_PER_INCH, SemanticGraphDiagnosticError, Shape, Slide, StyleDiagnosticError, Text, View, createElement, defineStyles, formatDiagnostic, formatDiagnostics, isAuthorNode, isContentNode, isSlideNode, pptxgenjsBackend };
|
|
@@ -287,4 +287,4 @@ function isContentNode(value) {
|
|
|
287
287
|
return isAuthorNode(value) && value.kind !== "slide";
|
|
288
288
|
}
|
|
289
289
|
//#endregion
|
|
290
|
-
export { isContentNode as a, toLegacyJsxNode as c,
|
|
290
|
+
export { isContentNode as a, toLegacyJsxNode as c, Shape as d, Slide as f, isAuthorTreeNode as h, isAuthorNode as i, isAuthoredTag as l, View as m, createElement as n, isSlideNode as o, Text as p, createElementWithMetadata as r, isLegacyAuthorNode as s, Fragment as t, Image as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tn as JsxKey, i as Fragment, n as jsx, r as jsxs, t as JSX, wn as AuthorTreeNode } from "./jsx-runtime-BMKEs7aG.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;
|
package/dist/jsx-dev-runtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as createElementWithMetadata, t as Fragment } from "./jsx-
|
|
1
|
+
import { r as createElementWithMetadata, t as Fragment } from "./jsx-B9HB9_cS.mjs";
|
|
2
2
|
import { jsx, jsxs } from "./jsx-runtime.mjs";
|
|
3
3
|
//#region src/jsx-dev-runtime.ts
|
|
4
4
|
function sourceSpanFromDevSource(source) {
|
|
@@ -55,6 +55,9 @@ declare class SemanticGraphDiagnosticError extends DeckDiagnosticError {
|
|
|
55
55
|
declare class CompositionDiagnosticError extends DeckDiagnosticError {
|
|
56
56
|
constructor(diagnostics: Diagnostics);
|
|
57
57
|
}
|
|
58
|
+
declare class StyleDiagnosticError extends DeckDiagnosticError {
|
|
59
|
+
constructor(diagnostics: Diagnostics);
|
|
60
|
+
}
|
|
58
61
|
//#endregion
|
|
59
62
|
//#region src/diagnostics/format.d.ts
|
|
60
63
|
declare function formatDiagnostic(diagnostic: Diagnostic): string;
|
|
@@ -176,7 +179,6 @@ type StyleEntity = {
|
|
|
176
179
|
readonly target: SemanticNodeKind;
|
|
177
180
|
readonly authored: {
|
|
178
181
|
readonly style?: unknown;
|
|
179
|
-
readonly direct?: unknown;
|
|
180
182
|
readonly classRefs?: readonly StyleClassRef[];
|
|
181
183
|
};
|
|
182
184
|
};
|
|
@@ -242,6 +244,7 @@ type CompositionEntry<TSourceContext = unknown> = {
|
|
|
242
244
|
};
|
|
243
245
|
type CompositionSourceInternals<TSourceContext = unknown> = {
|
|
244
246
|
readonly entries: readonly CompositionEntry<TSourceContext>[];
|
|
247
|
+
readonly stylesheets: readonly StyleSheet[];
|
|
245
248
|
readonly cycleId: object;
|
|
246
249
|
readonly boundContext: SourceContextBinding<TSourceContext>;
|
|
247
250
|
};
|
|
@@ -518,6 +521,18 @@ type ShapeStyle = FrameAuthorProps & Omit<BoxStyleAuthorProps, "backgroundColor"
|
|
|
518
521
|
borderRadius?: DeckLength;
|
|
519
522
|
radius?: DeckLength;
|
|
520
523
|
};
|
|
524
|
+
type TextRunStyle = Pick<TextStyle, "fontFamily" | "fontSize" | "fontWeight" | "italic" | "fontStyle" | "underline" | "strike" | "textDecoration" | "textDecorationLine" | "textDecorationStyle" | "textDecorationColor" | "textTransform" | "direction" | "writingMode" | "color" | "verticalAlign" | "charSpacing" | "letterSpacing" | "href" | "tooltip" | "superscript" | "subscript" | "textShadow">;
|
|
525
|
+
type StyleTargetSelector = string;
|
|
526
|
+
type StyleClassStyle = SlideStyle | ViewStyle | TextStyle | TextRunStyle | ImageStyle | ShapeStyle;
|
|
527
|
+
type TargetedStyleClassDefinition<TStyle extends StyleClassStyle = StyleClassStyle> = {
|
|
528
|
+
readonly target?: StyleTargetSelector | readonly StyleTargetSelector[];
|
|
529
|
+
readonly style: TStyle;
|
|
530
|
+
};
|
|
531
|
+
type StyleClassDefinition<TStyle extends StyleClassStyle = StyleClassStyle> = TStyle | TargetedStyleClassDefinition<TStyle>;
|
|
532
|
+
type StyleSheet<TClasses extends Readonly<Record<string, StyleClassDefinition>> = Readonly<Record<string, StyleClassDefinition>>> = {
|
|
533
|
+
readonly classes: TClasses;
|
|
534
|
+
};
|
|
535
|
+
declare function defineStyles<const TStyleSheet extends StyleSheet>(stylesheet: TStyleSheet): TStyleSheet;
|
|
521
536
|
type DeckOptions = {
|
|
522
537
|
layout: {
|
|
523
538
|
width: number;
|
|
@@ -563,6 +578,9 @@ type TextNodeProps = {
|
|
|
563
578
|
type TextProps = TextNodeProps & {
|
|
564
579
|
children?: TextJsxChild;
|
|
565
580
|
};
|
|
581
|
+
type TextRunNodeProps = {
|
|
582
|
+
style?: TextRunStyle;
|
|
583
|
+
} & ClassNameAuthorProps & TextRunStyle;
|
|
566
584
|
type ImageNodeProps = {
|
|
567
585
|
style?: ImageStyle;
|
|
568
586
|
} & ClassNameAuthorProps & ImageStyle & ({
|
|
@@ -623,12 +641,15 @@ type IntrinsicDivProps = ViewNodeProps & {
|
|
|
623
641
|
type IntrinsicPProps = TextNodeProps & {
|
|
624
642
|
children?: TextJsxChild;
|
|
625
643
|
};
|
|
644
|
+
type IntrinsicSpanProps = TextRunNodeProps & {
|
|
645
|
+
children?: TextJsxChild;
|
|
646
|
+
};
|
|
626
647
|
type IntrinsicImgProps = ImageProps;
|
|
627
648
|
type IntrinsicViewTag = "article" | "aside" | "div" | "figure" | "footer" | "header" | "main" | "nav" | "section";
|
|
628
649
|
type IntrinsicTextTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p";
|
|
629
650
|
type DeckJsxIntrinsicElements = {
|
|
630
651
|
img: IntrinsicImgProps;
|
|
631
|
-
span:
|
|
652
|
+
span: IntrinsicSpanProps;
|
|
632
653
|
} & { [Tag in IntrinsicViewTag]: IntrinsicDivProps } & { [Tag in IntrinsicTextTag]: IntrinsicPProps };
|
|
633
654
|
//#endregion
|
|
634
655
|
//#region src/authoring/components.d.ts
|
|
@@ -688,4 +709,4 @@ declare namespace JSX {
|
|
|
688
709
|
}
|
|
689
710
|
}
|
|
690
711
|
//#endregion
|
|
691
|
-
export { ImageCropAuthoring as $,
|
|
712
|
+
export { ImageCropAuthoring as $, SemanticDocumentNode as $t, CssBoxSizing as A, TextRunStyle as At, CssGridTemplateAreas as B, CompositionContext as Bt, ClassNameValueArray as C, StyleDiagnosticError as Cn, StyleClassStyle as Ct, CssAlignItems as D, TextJsxChild as Dt, CssAlignContent as E, SourceSpan as En, TextFit as Et, CssGridAutoFlow as F, VerticalAlign as Ft, CssObjectPosition as G, SourceContextInput as Gt, CssGridTrack as H, CompositionSourceInternals as Ht, CssGridLine as I, ViewProps as It, CssVisibility as J, AssetEntityId as Jt, CssOverflow as K, SourceContextMapper as Kt, CssGridPlacement as L, ViewStyle as Lt, CssFlexBasis as M, TextTabStopAlignment as Mt, CssFlexDirection as N, TextTabStopAuthoring as Nt, CssAlignSelf as O, TextProps as Ot, CssFlexWrap as P, TextTabStopLength as Pt, DeckPointLength as Q, SemanticContainerNode as Qt, CssGridShorthand as R, defineStyles as Rt, ClassNameValue as S, SemanticGraphDiagnosticError as Sn, StyleClassDefinition as St, ContentJsxChild as T, JsxKey as Tn, StyleTargetSelector as Tt, CssJustifyContent as U, SlideFactory as Ut, CssGridTemplateShorthand as V, CompositionSource as Vt, CssJustifySelf as W, SlideFactoryInput as Wt, DeckLength as X, GraphNodeId as Xt, DeckJsxIntrinsicElements as Y, BaseSemanticNode as Yt, DeckOptions as Z, SemanticAuthorGraph as Zt, AuthorNodeProps as _, Diagnostics as _n, StackAlignment as _t, createElement as a, SemanticShapeNode as an, IntrinsicImgProps as at, BorderStyle as b, CompositionDiagnosticError as bn, StrokeLineCap as bt, isSlideNode as c, SemanticTextRunNode as cn, IntrinsicViewTag as ct, Slide as d, StyleClassRef as dn, OutputConfig as dt, SemanticImageNode as en, ImageCropValue as et, Text as f, StyleEntity as fn, ShapeProps as ft, AuthorNodeMap as g, DiagnosticSeverity as gn, Spacing as gt, AuthorNodeKind as h, DiagnosticLabel as hn, SlideStyle as ht, Fragment as i, SemanticRole as in, IntrinsicDivProps as it, CssDisplay as j, TextStyle as jt, CssAspectRatio as k, TextRunNodeProps as kt, Image as l, SourceIdentity as ln, JsxNode as lt, AuthorNode as m, Diagnostic as mn, SlideProps as mt, jsx as n, SemanticNodeKind as nn, ImageStyle as nt, isAuthorNode as o, SemanticSlideNode as on, IntrinsicPProps as ot, View as p, StyleEntityId as pn, ShapeStyle as pt, CssPosition as q, AssetEntity as qt, jsxs as r, SemanticOrigin as rn, ImplementedBackendName as rt, isContentNode as s, SemanticTextNode as sn, IntrinsicTextTag as st, JSX as t, SemanticNode as tn, ImageProps as tt, Shape as u, SourceOrigin as un, LayoutMode as ut, AuthorNodePropsMap as v, formatDiagnostic as vn, StackAxis as vt, ContentAuthorNode as w, AuthorTreeNode as wn, StyleSheet as wt, ClassNameObject as x, DeckDiagnosticError as xn, StrokeLineJoin as xt, BackendName as y, formatDiagnostics as yn, StrokeDashType as yt, CssGridTemplate as z, COMPOSITION_SOURCE as zt };
|
package/dist/jsx-runtime.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tn as JsxKey, i as Fragment, n as jsx, r as jsxs, t as JSX } from "./jsx-runtime-BMKEs7aG.mjs";
|
|
2
2
|
export { Fragment, JSX, JsxKey, jsx, jsxs };
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as createElementWithMetadata, t as Fragment } from "./jsx-
|
|
1
|
+
import { r as createElementWithMetadata, t as Fragment } from "./jsx-B9HB9_cS.mjs";
|
|
2
2
|
//#region src/jsx-runtime.ts
|
|
3
3
|
function jsx(type, props, key) {
|
|
4
4
|
return createElementWithMetadata(type, props, key);
|