structured-render 0.0.0 → 0.0.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/LICENSE-CC0 +121 -0
- package/LICENSE-MIT +21 -0
- package/README.md +13 -0
- package/dist/augments/shadow-styles.d.ts +7 -0
- package/dist/augments/shadow-styles.js +17 -0
- package/dist/elements/vir-markdown.element.d.ts +16 -0
- package/dist/elements/vir-markdown.element.js +73 -0
- package/dist/elements/vir-source.element.d.ts +24 -0
- package/dist/elements/vir-source.element.js +158 -0
- package/dist/elements/vir-structured-render.element.d.ts +19 -0
- package/dist/elements/vir-structured-render.element.js +346 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/dist/render/browser-rendering.d.ts +90 -0
- package/dist/render/browser-rendering.js +233 -0
- package/dist/render/html-to-pdf.d.ts +50 -0
- package/dist/render/html-to-pdf.js +7 -0
- package/dist/render/render-html.d.ts +38 -0
- package/dist/render/render-html.js +504 -0
- package/dist/render/render-image.d.ts +24 -0
- package/dist/render/render-image.js +35 -0
- package/dist/render/render-markdown-styles.d.ts +62 -0
- package/dist/render/render-markdown-styles.js +242 -0
- package/dist/render/render-markdown.d.ts +8 -0
- package/dist/render/render-markdown.js +169 -0
- package/dist/render/render-pdf.d.ts +35 -0
- package/dist/render/render-pdf.js +65 -0
- package/dist/render/render-types.d.ts +134 -0
- package/dist/render/render-types.js +41 -0
- package/dist/structured-render-data/create-section.d.ts +23 -0
- package/dist/structured-render-data/create-section.js +16 -0
- package/dist/structured-render-data/sections/code-block.section.d.ts +30 -0
- package/dist/structured-render-data/sections/code-block.section.js +11 -0
- package/dist/structured-render-data/sections/empty.section.d.ts +14 -0
- package/dist/structured-render-data/sections/empty.section.js +9 -0
- package/dist/structured-render-data/sections/icon.section.d.ts +25 -0
- package/dist/structured-render-data/sections/icon.section.js +40 -0
- package/dist/structured-render-data/sections/inline-code.section.d.ts +29 -0
- package/dist/structured-render-data/sections/inline-code.section.js +9 -0
- package/dist/structured-render-data/sections/list.section.d.ts +169 -0
- package/dist/structured-render-data/sections/list.section.js +29 -0
- package/dist/structured-render-data/sections/markdown.section.d.ts +29 -0
- package/dist/structured-render-data/sections/markdown.section.js +9 -0
- package/dist/structured-render-data/sections/processing.section.d.ts +14 -0
- package/dist/structured-render-data/sections/processing.section.js +9 -0
- package/dist/structured-render-data/sections/source.section.d.ts +59 -0
- package/dist/structured-render-data/sections/source.section.js +47 -0
- package/dist/structured-render-data/sections/table.section.d.ts +939 -0
- package/dist/structured-render-data/sections/table.section.js +99 -0
- package/dist/structured-render-data/sections/tag.section.d.ts +39 -0
- package/dist/structured-render-data/sections/tag.section.js +20 -0
- package/dist/structured-render-data/sections/text.section.d.ts +48 -0
- package/dist/structured-render-data/sections/text.section.js +25 -0
- package/dist/structured-render-data/structured-render-card.d.ts +918 -0
- package/dist/structured-render-data/structured-render-card.js +11 -0
- package/dist/structured-render-data/structured-render-data.d.ts +919 -0
- package/dist/structured-render-data/structured-render-data.js +8 -0
- package/dist/structured-render-data/structured-render-section.d.ts +1857 -0
- package/dist/structured-render-data/structured-render-section.js +115 -0
- package/package.json +75 -11
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { enumShape, nullableShape, recordShape, unionShape } from 'object-shape-tester';
|
|
2
|
+
import { createStructuredRenderSection } from '../create-section.js';
|
|
3
|
+
import { structuredRenderEmptyShape } from './empty.section.js';
|
|
4
|
+
import { structuredRenderInlineCodeShape } from './inline-code.section.js';
|
|
5
|
+
import { structuredRenderListShape } from './list.section.js';
|
|
6
|
+
import { renderDataMarkdownShape } from './markdown.section.js';
|
|
7
|
+
import { structuredRenderProcessingShape } from './processing.section.js';
|
|
8
|
+
import { structuredRenderSourceShape } from './source.section.js';
|
|
9
|
+
import { structuredRenderTagShape } from './tag.section.js';
|
|
10
|
+
import { structuredRenderTextShape } from './text.section.js';
|
|
11
|
+
/**
|
|
12
|
+
* Footer alignment options for {@link StructuredRenderTable}.
|
|
13
|
+
*
|
|
14
|
+
* @category Options
|
|
15
|
+
* @default StructuredRenderTableFooterAlignment.Left
|
|
16
|
+
*/
|
|
17
|
+
export var StructuredRenderTableFooterAlignment;
|
|
18
|
+
(function (StructuredRenderTableFooterAlignment) {
|
|
19
|
+
/** @default */
|
|
20
|
+
StructuredRenderTableFooterAlignment["Left"] = "left";
|
|
21
|
+
StructuredRenderTableFooterAlignment["Right"] = "right";
|
|
22
|
+
})(StructuredRenderTableFooterAlignment || (StructuredRenderTableFooterAlignment = {}));
|
|
23
|
+
/**
|
|
24
|
+
* Controls which direction cells render for {@link StructuredRenderTable}.
|
|
25
|
+
*
|
|
26
|
+
* @category Options
|
|
27
|
+
*/
|
|
28
|
+
export var StructuredRenderCellDirection;
|
|
29
|
+
(function (StructuredRenderCellDirection) {
|
|
30
|
+
/**
|
|
31
|
+
* Each cell in a table entry is rendered to the _right_ of the previous one; the cells run
|
|
32
|
+
* horizontally and increase the table's _width_. Headers run along the first row. Each table
|
|
33
|
+
* entry creates a new _row_.
|
|
34
|
+
*/
|
|
35
|
+
StructuredRenderCellDirection["Horizontal"] = "horizontal";
|
|
36
|
+
/**
|
|
37
|
+
* Each cell in a table entry is rendered _below_ the previous one; the cells run vertically and
|
|
38
|
+
* increase the table's _height_. Headers run down the first column. Each table entry creates a
|
|
39
|
+
* new _column_.
|
|
40
|
+
*/
|
|
41
|
+
StructuredRenderCellDirection["Vertical"] = "vertical";
|
|
42
|
+
})(StructuredRenderCellDirection || (StructuredRenderCellDirection = {}));
|
|
43
|
+
/**
|
|
44
|
+
* All section shapes allowed inside {@link StructuredRenderTable} cells.
|
|
45
|
+
*
|
|
46
|
+
* @category Internal
|
|
47
|
+
*/
|
|
48
|
+
export const structuredRenderShapesAllowedInTableShape = unionShape(structuredRenderTextShape, structuredRenderInlineCodeShape, renderDataMarkdownShape, structuredRenderTagShape, structuredRenderListShape, structuredRenderEmptyShape, structuredRenderProcessingShape);
|
|
49
|
+
/**
|
|
50
|
+
* Shape definition for {@link StructuredRenderTable}.
|
|
51
|
+
*
|
|
52
|
+
* @category Internal
|
|
53
|
+
*/
|
|
54
|
+
export const structuredRenderTableShape = createStructuredRenderSection('table', {
|
|
55
|
+
direction: enumShape(StructuredRenderCellDirection),
|
|
56
|
+
headers: [
|
|
57
|
+
{
|
|
58
|
+
key: '',
|
|
59
|
+
text: nullableShape(structuredRenderTextShape),
|
|
60
|
+
/**
|
|
61
|
+
* If `true`, all data associated with this header (the column / row) is not rendered at
|
|
62
|
+
* all.
|
|
63
|
+
*/
|
|
64
|
+
hidden: nullableShape(false),
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
entries: [
|
|
68
|
+
{
|
|
69
|
+
data: recordShape({
|
|
70
|
+
keys: '',
|
|
71
|
+
values: unionShape(nullableShape(structuredRenderShapesAllowedInTableShape), [
|
|
72
|
+
nullableShape(structuredRenderShapesAllowedInTableShape),
|
|
73
|
+
]),
|
|
74
|
+
}),
|
|
75
|
+
sources: nullableShape([nullableShape(structuredRenderSourceShape)]),
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
footerRows: nullableShape([
|
|
79
|
+
{
|
|
80
|
+
/** @default StructuredRenderTableFooterAlignment.Left */
|
|
81
|
+
alignment: nullableShape(enumShape(StructuredRenderTableFooterAlignment)),
|
|
82
|
+
cells: unionShape(nullableShape(structuredRenderShapesAllowedInTableShape), [
|
|
83
|
+
nullableShape(structuredRenderShapesAllowedInTableShape),
|
|
84
|
+
]),
|
|
85
|
+
},
|
|
86
|
+
]),
|
|
87
|
+
});
|
|
88
|
+
/**
|
|
89
|
+
* A helper for defining a {@link StructuredRenderTable} instance.
|
|
90
|
+
*
|
|
91
|
+
* @category Util
|
|
92
|
+
*/
|
|
93
|
+
export function createRenderDataTable(headers, entries, footerRows) {
|
|
94
|
+
return {
|
|
95
|
+
headers,
|
|
96
|
+
entries,
|
|
97
|
+
footerRows,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ViraColorVariant } from 'vira';
|
|
2
|
+
/**
|
|
3
|
+
* Shape definition for {@link StructuredRenderTag}.
|
|
4
|
+
*
|
|
5
|
+
* @category Internal
|
|
6
|
+
*/
|
|
7
|
+
export declare const structuredRenderTagShape: import("object-shape-tester").Shape<{
|
|
8
|
+
type: import("object-shape-tester").Shape<import("@sinclair/typebox").TUnsafe<"tag">>;
|
|
9
|
+
sectionTitle: import("object-shape-tester").Shape<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>>;
|
|
10
|
+
sources: import("object-shape-tester").Shape<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TArray<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TObject<{
|
|
11
|
+
type: import("@sinclair/typebox").TUnsafe<"source">;
|
|
12
|
+
pageNumbers: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TArray<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNumber | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>>)[]>>;
|
|
13
|
+
fileName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>;
|
|
14
|
+
fileBoundingBoxes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TArray<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TObject<{
|
|
15
|
+
x1: import("@sinclair/typebox").TNumber;
|
|
16
|
+
y1: import("@sinclair/typebox").TNumber;
|
|
17
|
+
x2: import("@sinclair/typebox").TNumber;
|
|
18
|
+
y2: import("@sinclair/typebox").TNumber;
|
|
19
|
+
}>)[]>>>)[]>>;
|
|
20
|
+
quote: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>;
|
|
21
|
+
}>)[]>>>)[]>>>;
|
|
22
|
+
} & {
|
|
23
|
+
text: import("object-shape-tester").Shape<import("type-fest").Primitive>;
|
|
24
|
+
useBigTag: import("object-shape-tester").Shape<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TBoolean | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>>;
|
|
25
|
+
color: import("object-shape-tester").Shape<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TObject<{
|
|
26
|
+
custom: import("@sinclair/typebox").TObject<{
|
|
27
|
+
backgroundColor: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>;
|
|
28
|
+
foregroundColor: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>;
|
|
29
|
+
}>;
|
|
30
|
+
}> | import("@sinclair/typebox").TObject<{
|
|
31
|
+
variant: import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TLiteral<ViraColorVariant.Accent> | import("@sinclair/typebox").TLiteral<ViraColorVariant.Plain> | import("@sinclair/typebox").TLiteral<ViraColorVariant.Neutral> | import("@sinclair/typebox").TLiteral<ViraColorVariant.Danger> | import("@sinclair/typebox").TLiteral<ViraColorVariant.Warning> | import("@sinclair/typebox").TLiteral<ViraColorVariant.Positive> | import("@sinclair/typebox").TLiteral<ViraColorVariant.None>)[]>;
|
|
32
|
+
}>)[]>)[]>>>;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* A section that renders a tag.
|
|
36
|
+
*
|
|
37
|
+
* @category Section
|
|
38
|
+
*/
|
|
39
|
+
export type StructuredRenderTag = typeof structuredRenderTagShape.runtimeType;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { enumShape, nullableShape, partialShape, primitiveShape, unionShape, } from 'object-shape-tester';
|
|
2
|
+
import { ViraColorVariant } from 'vira';
|
|
3
|
+
import { createStructuredRenderSection } from '../create-section.js';
|
|
4
|
+
/**
|
|
5
|
+
* Shape definition for {@link StructuredRenderTag}.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
9
|
+
export const structuredRenderTagShape = createStructuredRenderSection('tag', {
|
|
10
|
+
text: primitiveShape(''),
|
|
11
|
+
useBigTag: nullableShape(false),
|
|
12
|
+
color: nullableShape(unionShape({
|
|
13
|
+
custom: partialShape({
|
|
14
|
+
backgroundColor: nullableShape(''),
|
|
15
|
+
foregroundColor: nullableShape(''),
|
|
16
|
+
}),
|
|
17
|
+
}, {
|
|
18
|
+
variant: enumShape(ViraColorVariant),
|
|
19
|
+
})),
|
|
20
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style options for {@link StructuredRenderText}.
|
|
3
|
+
*
|
|
4
|
+
* @category Options
|
|
5
|
+
*/
|
|
6
|
+
export declare enum StructuredRenderTextStyle {
|
|
7
|
+
Faint = "faint",
|
|
8
|
+
Small = "small",
|
|
9
|
+
Bold = "bold"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Shape definition for {@link StructuredRenderText}.
|
|
13
|
+
*
|
|
14
|
+
* @category Internal
|
|
15
|
+
*/
|
|
16
|
+
export declare const structuredRenderTextShape: import("object-shape-tester").Shape<{
|
|
17
|
+
type: import("object-shape-tester").Shape<import("@sinclair/typebox").TUnsafe<"text">>;
|
|
18
|
+
sectionTitle: import("object-shape-tester").Shape<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>>;
|
|
19
|
+
sources: import("object-shape-tester").Shape<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TArray<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TObject<{
|
|
20
|
+
type: import("@sinclair/typebox").TUnsafe<"source">;
|
|
21
|
+
pageNumbers: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TArray<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNumber | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>>)[]>>;
|
|
22
|
+
fileName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>;
|
|
23
|
+
fileBoundingBoxes: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TArray<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TObject<{
|
|
24
|
+
x1: import("@sinclair/typebox").TNumber;
|
|
25
|
+
y1: import("@sinclair/typebox").TNumber;
|
|
26
|
+
x2: import("@sinclair/typebox").TNumber;
|
|
27
|
+
y2: import("@sinclair/typebox").TNumber;
|
|
28
|
+
}>)[]>>>)[]>>;
|
|
29
|
+
quote: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>;
|
|
30
|
+
}>)[]>>>)[]>>>;
|
|
31
|
+
} & {
|
|
32
|
+
text: import("object-shape-tester").Shape<import("type-fest").Primitive>;
|
|
33
|
+
style: import("object-shape-tester").Shape<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TLiteral<StructuredRenderTextStyle.Faint> | import("@sinclair/typebox").TLiteral<StructuredRenderTextStyle.Small> | import("@sinclair/typebox").TLiteral<StructuredRenderTextStyle.Bold>)[]>)[]>>>;
|
|
34
|
+
/** Rendered before the text. */
|
|
35
|
+
icon: import("object-shape-tester").Shape<import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TObject<{
|
|
36
|
+
type: import("@sinclair/typebox").TUnsafe<"icon">;
|
|
37
|
+
iconKey: import("@sinclair/typebox").TString;
|
|
38
|
+
strokeColor: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>;
|
|
39
|
+
fillColor: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined)[]>>;
|
|
40
|
+
strokeWidth: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TNull | import("@sinclair/typebox").TUndefined | import("@sinclair/typebox").TUnion<(import("@sinclair/typebox").TString | import("@sinclair/typebox").TNumber)[]>)[]>>;
|
|
41
|
+
}>)[]>>>;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* A section that renders text.
|
|
45
|
+
*
|
|
46
|
+
* @category Section
|
|
47
|
+
*/
|
|
48
|
+
export type StructuredRenderText = typeof structuredRenderTextShape.runtimeType;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { enumShape, nullableShape, primitiveShape } from 'object-shape-tester';
|
|
2
|
+
import { createStructuredRenderSection } from '../create-section.js';
|
|
3
|
+
import { structuredRenderIconShape } from './icon.section.js';
|
|
4
|
+
/**
|
|
5
|
+
* Style options for {@link StructuredRenderText}.
|
|
6
|
+
*
|
|
7
|
+
* @category Options
|
|
8
|
+
*/
|
|
9
|
+
export var StructuredRenderTextStyle;
|
|
10
|
+
(function (StructuredRenderTextStyle) {
|
|
11
|
+
StructuredRenderTextStyle["Faint"] = "faint";
|
|
12
|
+
StructuredRenderTextStyle["Small"] = "small";
|
|
13
|
+
StructuredRenderTextStyle["Bold"] = "bold";
|
|
14
|
+
})(StructuredRenderTextStyle || (StructuredRenderTextStyle = {}));
|
|
15
|
+
/**
|
|
16
|
+
* Shape definition for {@link StructuredRenderText}.
|
|
17
|
+
*
|
|
18
|
+
* @category Internal
|
|
19
|
+
*/
|
|
20
|
+
export const structuredRenderTextShape = createStructuredRenderSection('text', {
|
|
21
|
+
text: primitiveShape(''),
|
|
22
|
+
style: nullableShape(enumShape(StructuredRenderTextStyle)),
|
|
23
|
+
/** Rendered before the text. */
|
|
24
|
+
icon: nullableShape(structuredRenderIconShape),
|
|
25
|
+
});
|