@segnavia/format 0.9.0 → 0.10.0
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/board-geometry.d.ts +34 -0
- package/dist/board-geometry.js +184 -0
- package/dist/board.d.ts +79 -0
- package/dist/board.js +75 -0
- package/dist/book.js +1 -1
- package/dist/deck.d.ts +1 -0
- package/dist/direction.d.ts +5 -1
- package/dist/direction.js +2 -1
- package/dist/index.d.ts +43 -2
- package/dist/index.js +9 -6
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Board, BoardItem } from "./board.js";
|
|
2
|
+
import { Box, Point, Size } from "./deck.js";
|
|
3
|
+
//#region src/board-geometry.d.ts
|
|
4
|
+
export interface BoardShapes {
|
|
5
|
+
items: Record<string, Size>;
|
|
6
|
+
labels: Record<string, Size>;
|
|
7
|
+
}
|
|
8
|
+
export interface BoardView {
|
|
9
|
+
zoom: number;
|
|
10
|
+
pan: Point;
|
|
11
|
+
viewport: Size;
|
|
12
|
+
}
|
|
13
|
+
export interface ZoomBounds {
|
|
14
|
+
minZoom?: number;
|
|
15
|
+
maxZoom?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ArrangeOptions {
|
|
18
|
+
layout: 'grid' | 'row';
|
|
19
|
+
gap: number;
|
|
20
|
+
columns?: number;
|
|
21
|
+
sectionPadding?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const MIN_BOARD_ZOOM = 0.05;
|
|
24
|
+
export declare const MAX_BOARD_ZOOM = 8;
|
|
25
|
+
export declare function itemHeight(item: BoardItem, shape: Size): number;
|
|
26
|
+
export declare function boardBounds(board: Board, shapes: BoardShapes): Box;
|
|
27
|
+
export declare function boardToScreen(view: BoardView, point: Point): Point;
|
|
28
|
+
export declare function screenToBoard(view: BoardView, point: Point): Point;
|
|
29
|
+
export declare function zoomToFit(bounds: Box, viewport: Size, padding: number): BoardView;
|
|
30
|
+
export declare function zoomAt(view: BoardView, point: Point, factor: number, options?: ZoomBounds): BoardView;
|
|
31
|
+
export declare function visibleItems(board: Board, shapes: BoardShapes, view: BoardView, margin: number): BoardItem[];
|
|
32
|
+
export declare function itemAt(board: Board, shapes: BoardShapes, point: Point): BoardItem | undefined;
|
|
33
|
+
export declare function arrange(board: Board, shapes: BoardShapes, options: ArrangeOptions): Board;
|
|
34
|
+
//#endregion
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
//#region src/board-geometry.ts
|
|
2
|
+
const MIN_BOARD_ZOOM = .05;
|
|
3
|
+
const MAX_BOARD_ZOOM = 8;
|
|
4
|
+
function requireShape(shapes, kind, id) {
|
|
5
|
+
if (!Object.hasOwn(shapes[kind], id)) throw new Error(`${kind === "items" ? "item" : "label"} "${id}" has no supplied shape; supply shapes.${kind}["${id}"]`);
|
|
6
|
+
const shape = shapes[kind][id];
|
|
7
|
+
if (!shape) throw new Error(`${kind === "items" ? "item" : "label"} "${id}" has no supplied shape; supply shapes.${kind}["${id}"]`);
|
|
8
|
+
return shape;
|
|
9
|
+
}
|
|
10
|
+
function requireView(view) {
|
|
11
|
+
if (!(view.zoom > 0)) throw new Error(`board view zoom is ${view.zoom}; provide a zoom greater than zero`);
|
|
12
|
+
}
|
|
13
|
+
function itemHeight(item, shape) {
|
|
14
|
+
return item.width * shape.height / shape.width;
|
|
15
|
+
}
|
|
16
|
+
function itemRectangle(item, shapes) {
|
|
17
|
+
const shape = requireShape(shapes, "items", item.id);
|
|
18
|
+
return {
|
|
19
|
+
x: item.x,
|
|
20
|
+
y: item.y,
|
|
21
|
+
width: item.width,
|
|
22
|
+
height: itemHeight(item, shape)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function union(rectangles) {
|
|
26
|
+
if (rectangles.length === 0) return {
|
|
27
|
+
x: 0,
|
|
28
|
+
y: 0,
|
|
29
|
+
width: 0,
|
|
30
|
+
height: 0
|
|
31
|
+
};
|
|
32
|
+
const left = Math.min(...rectangles.map((rectangle) => rectangle.x));
|
|
33
|
+
const top = Math.min(...rectangles.map((rectangle) => rectangle.y));
|
|
34
|
+
const right = Math.max(...rectangles.map((rectangle) => rectangle.x + rectangle.width));
|
|
35
|
+
const bottom = Math.max(...rectangles.map((rectangle) => rectangle.y + rectangle.height));
|
|
36
|
+
return {
|
|
37
|
+
x: left,
|
|
38
|
+
y: top,
|
|
39
|
+
width: right - left,
|
|
40
|
+
height: bottom - top
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function boardBounds(board, shapes) {
|
|
44
|
+
return union([
|
|
45
|
+
...board.items.map((item) => itemRectangle(item, shapes)),
|
|
46
|
+
...board.labels.map((label) => {
|
|
47
|
+
const shape = requireShape(shapes, "labels", label.id);
|
|
48
|
+
return {
|
|
49
|
+
x: label.x,
|
|
50
|
+
y: label.y,
|
|
51
|
+
width: shape.width,
|
|
52
|
+
height: shape.height
|
|
53
|
+
};
|
|
54
|
+
}),
|
|
55
|
+
...board.sections.map((section) => section.rectangle)
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
58
|
+
function boardToScreen(view, point) {
|
|
59
|
+
requireView(view);
|
|
60
|
+
return {
|
|
61
|
+
x: point.x * view.zoom + view.pan.x,
|
|
62
|
+
y: point.y * view.zoom + view.pan.y
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function screenToBoard(view, point) {
|
|
66
|
+
requireView(view);
|
|
67
|
+
return {
|
|
68
|
+
x: (point.x - view.pan.x) / view.zoom,
|
|
69
|
+
y: (point.y - view.pan.y) / view.zoom
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function zoomToFit(bounds, viewport, padding) {
|
|
73
|
+
const availableWidth = viewport.width - padding * 2;
|
|
74
|
+
const availableHeight = viewport.height - padding * 2;
|
|
75
|
+
if (!(availableWidth > 0 && availableHeight > 0 && bounds.width > 0 && bounds.height > 0)) throw new Error("zoom to fit needs positive bounds and a viewport larger than twice its padding; provide non-empty bounds and usable space");
|
|
76
|
+
const zoom = Math.min(availableWidth / bounds.width, availableHeight / bounds.height);
|
|
77
|
+
return {
|
|
78
|
+
zoom,
|
|
79
|
+
pan: {
|
|
80
|
+
x: (viewport.width - bounds.width * zoom) / 2 - bounds.x * zoom,
|
|
81
|
+
y: (viewport.height - bounds.height * zoom) / 2 - bounds.y * zoom
|
|
82
|
+
},
|
|
83
|
+
viewport
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function zoomAt(view, point, factor, options = {}) {
|
|
87
|
+
requireView(view);
|
|
88
|
+
if (!(factor > 0)) throw new Error(`zoom factor is ${factor}; provide a factor greater than zero`);
|
|
89
|
+
const minZoom = options.minZoom ?? .05;
|
|
90
|
+
const maxZoom = options.maxZoom ?? 8;
|
|
91
|
+
if (!(minZoom > 0 && maxZoom >= minZoom)) throw new Error("zoom bounds are invalid; provide a positive minZoom no greater than maxZoom");
|
|
92
|
+
const zoom = Math.min(maxZoom, Math.max(minZoom, view.zoom * factor));
|
|
93
|
+
const boardPoint = screenToBoard(view, point);
|
|
94
|
+
return {
|
|
95
|
+
...view,
|
|
96
|
+
zoom,
|
|
97
|
+
pan: {
|
|
98
|
+
x: point.x - boardPoint.x * zoom,
|
|
99
|
+
y: point.y - boardPoint.y * zoom
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function intersects(a, b) {
|
|
104
|
+
return a.x <= b.x + b.width && a.x + a.width >= b.x && a.y <= b.y + b.height && a.y + a.height >= b.y;
|
|
105
|
+
}
|
|
106
|
+
function visibleItems(board, shapes, view, margin) {
|
|
107
|
+
requireView(view);
|
|
108
|
+
const viewport = {
|
|
109
|
+
x: -margin,
|
|
110
|
+
y: -margin,
|
|
111
|
+
width: view.viewport.width + margin * 2,
|
|
112
|
+
height: view.viewport.height + margin * 2
|
|
113
|
+
};
|
|
114
|
+
return board.items.filter((item) => {
|
|
115
|
+
const rectangle = itemRectangle(item, shapes);
|
|
116
|
+
const screen = boardToScreen(view, {
|
|
117
|
+
x: rectangle.x,
|
|
118
|
+
y: rectangle.y
|
|
119
|
+
});
|
|
120
|
+
return intersects({
|
|
121
|
+
x: screen.x,
|
|
122
|
+
y: screen.y,
|
|
123
|
+
width: rectangle.width * view.zoom,
|
|
124
|
+
height: rectangle.height * view.zoom
|
|
125
|
+
}, viewport);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function itemAt(board, shapes, point) {
|
|
129
|
+
for (let index = board.items.length - 1; index >= 0; index -= 1) {
|
|
130
|
+
const item = board.items[index];
|
|
131
|
+
if (!item) continue;
|
|
132
|
+
const rectangle = itemRectangle(item, shapes);
|
|
133
|
+
if (point.x >= rectangle.x && point.x <= rectangle.x + rectangle.width && point.y >= rectangle.y && point.y <= rectangle.y + rectangle.height) return item;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function arrangedItems(board, shapes, options) {
|
|
137
|
+
if (options.layout === "grid" && options.columns !== void 0 && (!Number.isFinite(options.columns) || !Number.isInteger(options.columns) || options.columns <= 0)) throw new Error(`grid columns is ${options.columns}; provide a positive integer`);
|
|
138
|
+
const columns = options.layout === "row" ? Math.max(1, board.items.length) : Math.max(1, options.columns ?? Math.ceil(Math.sqrt(board.items.length)));
|
|
139
|
+
const columnWidths = Array.from({ length: columns }, () => 0);
|
|
140
|
+
const rowHeights = Array.from({ length: Math.ceil(board.items.length / columns) }, () => 0);
|
|
141
|
+
board.items.forEach((item, index) => {
|
|
142
|
+
const column = index % columns;
|
|
143
|
+
const row = Math.floor(index / columns);
|
|
144
|
+
columnWidths[column] = Math.max(columnWidths[column] ?? 0, item.width);
|
|
145
|
+
rowHeights[row] = Math.max(rowHeights[row] ?? 0, itemHeight(item, requireShape(shapes, "items", item.id)));
|
|
146
|
+
});
|
|
147
|
+
const offsets = (sizes) => sizes.map((_, index) => sizes.slice(0, index).reduce((total, size) => total + size, 0) + index * options.gap);
|
|
148
|
+
const xOffsets = offsets(columnWidths);
|
|
149
|
+
const yOffsets = offsets(rowHeights);
|
|
150
|
+
return board.items.map((item, index) => {
|
|
151
|
+
const column = index % columns;
|
|
152
|
+
const x = xOffsets[column] ?? 0;
|
|
153
|
+
return {
|
|
154
|
+
...item,
|
|
155
|
+
x: board.direction === "rtl" ? -x - item.width : x,
|
|
156
|
+
y: yOffsets[Math.floor(index / columns)] ?? 0
|
|
157
|
+
};
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function arrange(board, shapes, options) {
|
|
161
|
+
const items = arrangedItems(board, shapes, options);
|
|
162
|
+
const byId = new Map(items.map((item) => [item.id, item]));
|
|
163
|
+
const padding = options.sectionPadding ?? options.gap;
|
|
164
|
+
const sections = board.sections.map((section) => {
|
|
165
|
+
if (section.items.length === 0) return section;
|
|
166
|
+
const rectangle = union(section.items.map((id) => itemRectangle(byId.get(id), shapes)));
|
|
167
|
+
return {
|
|
168
|
+
...section,
|
|
169
|
+
rectangle: {
|
|
170
|
+
x: rectangle.x - padding,
|
|
171
|
+
y: rectangle.y - padding,
|
|
172
|
+
width: rectangle.width + padding * 2,
|
|
173
|
+
height: rectangle.height + padding * 2
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
...board,
|
|
179
|
+
items,
|
|
180
|
+
sections
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
export { MAX_BOARD_ZOOM, MIN_BOARD_ZOOM, arrange, boardBounds, boardToScreen, itemAt, itemHeight, screenToBoard, visibleItems, zoomAt, zoomToFit };
|
package/dist/board.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/board.d.ts
|
|
3
|
+
export declare const BoardItem: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
kind: z.ZodEnum<{
|
|
6
|
+
paper: "paper";
|
|
7
|
+
page: "page";
|
|
8
|
+
book: "book";
|
|
9
|
+
shot: "shot";
|
|
10
|
+
image: "image";
|
|
11
|
+
deck: "deck";
|
|
12
|
+
}>;
|
|
13
|
+
address: z.ZodString;
|
|
14
|
+
x: z.ZodNumber;
|
|
15
|
+
y: z.ZodNumber;
|
|
16
|
+
width: z.ZodNumber;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
export type BoardItem = z.infer<typeof BoardItem>;
|
|
19
|
+
export declare const BoardLabel: z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
text: z.ZodString;
|
|
22
|
+
x: z.ZodNumber;
|
|
23
|
+
y: z.ZodNumber;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type BoardLabel = z.infer<typeof BoardLabel>;
|
|
26
|
+
export declare const BoardSection: z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
title: z.ZodString;
|
|
29
|
+
rectangle: z.ZodObject<{
|
|
30
|
+
x: z.ZodNumber;
|
|
31
|
+
y: z.ZodNumber;
|
|
32
|
+
width: z.ZodNumber;
|
|
33
|
+
height: z.ZodNumber;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
items: z.ZodArray<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export type BoardSection = z.infer<typeof BoardSection>;
|
|
38
|
+
export declare const Board: z.ZodObject<{
|
|
39
|
+
title: z.ZodString;
|
|
40
|
+
direction: z.ZodEnum<{
|
|
41
|
+
ltr: "ltr";
|
|
42
|
+
rtl: "rtl";
|
|
43
|
+
}>;
|
|
44
|
+
items: z.ZodArray<z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
kind: z.ZodEnum<{
|
|
47
|
+
paper: "paper";
|
|
48
|
+
page: "page";
|
|
49
|
+
book: "book";
|
|
50
|
+
shot: "shot";
|
|
51
|
+
image: "image";
|
|
52
|
+
deck: "deck";
|
|
53
|
+
}>;
|
|
54
|
+
address: z.ZodString;
|
|
55
|
+
x: z.ZodNumber;
|
|
56
|
+
y: z.ZodNumber;
|
|
57
|
+
width: z.ZodNumber;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
labels: z.ZodArray<z.ZodObject<{
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
text: z.ZodString;
|
|
62
|
+
x: z.ZodNumber;
|
|
63
|
+
y: z.ZodNumber;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
sections: z.ZodArray<z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
title: z.ZodString;
|
|
68
|
+
rectangle: z.ZodObject<{
|
|
69
|
+
x: z.ZodNumber;
|
|
70
|
+
y: z.ZodNumber;
|
|
71
|
+
width: z.ZodNumber;
|
|
72
|
+
height: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
items: z.ZodArray<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
export type Board = z.infer<typeof Board>;
|
|
78
|
+
export type BoardInput = z.input<typeof Board>;
|
|
79
|
+
//#endregion
|
package/dist/board.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { TextDirection } from "./direction.js";
|
|
2
|
+
import { Box } from "./deck.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/board.ts
|
|
5
|
+
const BoardKind = z.enum([
|
|
6
|
+
"deck",
|
|
7
|
+
"page",
|
|
8
|
+
"paper",
|
|
9
|
+
"book",
|
|
10
|
+
"image",
|
|
11
|
+
"shot"
|
|
12
|
+
], { error: "item kind is unknown; use deck, page, paper, book, image or shot" });
|
|
13
|
+
const BoardItem = z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
kind: BoardKind,
|
|
16
|
+
address: z.string().min(1, "item address is empty; provide a non-empty address"),
|
|
17
|
+
x: z.number(),
|
|
18
|
+
y: z.number(),
|
|
19
|
+
width: z.number().positive("item width is not positive; provide a width greater than zero")
|
|
20
|
+
});
|
|
21
|
+
const BoardLabel = z.object({
|
|
22
|
+
id: z.string(),
|
|
23
|
+
text: z.string(),
|
|
24
|
+
x: z.number(),
|
|
25
|
+
y: z.number()
|
|
26
|
+
});
|
|
27
|
+
const BoardSection = z.object({
|
|
28
|
+
id: z.string(),
|
|
29
|
+
title: z.string(),
|
|
30
|
+
rectangle: Box,
|
|
31
|
+
items: z.array(z.string())
|
|
32
|
+
});
|
|
33
|
+
const Board = z.object({
|
|
34
|
+
title: z.string(),
|
|
35
|
+
direction: TextDirection,
|
|
36
|
+
items: z.array(BoardItem),
|
|
37
|
+
labels: z.array(BoardLabel),
|
|
38
|
+
sections: z.array(BoardSection)
|
|
39
|
+
}).superRefine((board, ctx) => {
|
|
40
|
+
const ids = /* @__PURE__ */ new Set();
|
|
41
|
+
const checkIds = (entries, listName) => {
|
|
42
|
+
entries.forEach((entry, index) => {
|
|
43
|
+
if (ids.has(entry.id)) ctx.addIssue({
|
|
44
|
+
code: "custom",
|
|
45
|
+
path: [
|
|
46
|
+
listName,
|
|
47
|
+
index,
|
|
48
|
+
"id"
|
|
49
|
+
],
|
|
50
|
+
message: `id "${entry.id}" is duplicated across board items, labels and sections; use a unique id`
|
|
51
|
+
});
|
|
52
|
+
ids.add(entry.id);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
checkIds(board.items, "items");
|
|
56
|
+
checkIds(board.labels, "labels");
|
|
57
|
+
checkIds(board.sections, "sections");
|
|
58
|
+
const itemIds = new Set(board.items.map((item) => item.id));
|
|
59
|
+
board.sections.forEach((section, sectionIndex) => {
|
|
60
|
+
section.items.forEach((id, itemIndex) => {
|
|
61
|
+
if (!itemIds.has(id)) ctx.addIssue({
|
|
62
|
+
code: "custom",
|
|
63
|
+
path: [
|
|
64
|
+
"sections",
|
|
65
|
+
sectionIndex,
|
|
66
|
+
"items",
|
|
67
|
+
itemIndex
|
|
68
|
+
],
|
|
69
|
+
message: `section member "${id}" is not a board item id; use the id of an existing item`
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
//#endregion
|
|
75
|
+
export { Board, BoardItem, BoardLabel, BoardSection };
|
package/dist/book.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Direction } from "./direction.js";
|
|
2
|
+
import { Scripts } from "./scripts.js";
|
|
2
3
|
import { NoteMarker, NumberSystem } from "./numbering.js";
|
|
3
4
|
import { Paper, sheetMm } from "./paper.js";
|
|
4
|
-
import { Scripts } from "./scripts.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
//#region src/book.ts
|
|
7
7
|
const BookMode = z.enum(["continuous", "paginated"]);
|
package/dist/deck.d.ts
CHANGED
package/dist/direction.d.ts
CHANGED
|
@@ -5,7 +5,11 @@ export declare const Direction: z.ZodEnum<{
|
|
|
5
5
|
rtl: "rtl";
|
|
6
6
|
auto: "auto";
|
|
7
7
|
}>;
|
|
8
|
-
export
|
|
8
|
+
export declare const TextDirection: z.ZodEnum<{
|
|
9
|
+
ltr: "ltr";
|
|
10
|
+
rtl: "rtl";
|
|
11
|
+
}>;
|
|
12
|
+
export type TextDirection = z.infer<typeof TextDirection>;
|
|
9
13
|
export declare function firstStrongDirection(text: string): TextDirection | null;
|
|
10
14
|
export declare function languageDirection(lang: string | undefined): TextDirection | null;
|
|
11
15
|
export declare function resolveDirection(dir: 'ltr' | 'rtl' | 'auto' | undefined, lang: string | undefined, sample: string): TextDirection;
|
package/dist/direction.js
CHANGED
|
@@ -5,6 +5,7 @@ const Direction = z.enum([
|
|
|
5
5
|
"rtl",
|
|
6
6
|
"auto"
|
|
7
7
|
]);
|
|
8
|
+
const TextDirection = z.enum(["ltr", "rtl"]);
|
|
8
9
|
const RTL_LETTER = /[\p{Script=Hebrew}\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Samaritan}\p{Script=Mandaic}\p{Script=Adlam}\p{Script=Hanifi_Rohingya}\p{Script=Mende_Kikakui}\p{Script=Old_Hungarian}\p{Script=Imperial_Aramaic}\p{Script=Phoenician}]/u;
|
|
9
10
|
const LETTER = /\p{L}/u;
|
|
10
11
|
const RTL_LANGUAGES = /* @__PURE__ */ new Set([
|
|
@@ -42,4 +43,4 @@ function resolveDirection(dir, lang, sample) {
|
|
|
42
43
|
return languageDirection(lang) ?? firstStrongDirection(sample) ?? "ltr";
|
|
43
44
|
}
|
|
44
45
|
//#endregion
|
|
45
|
-
export { Direction, firstStrongDirection, languageDirection, resolveDirection };
|
|
46
|
+
export { Direction, TextDirection, firstStrongDirection, languageDirection, resolveDirection };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Board, BoardInput, BoardItem, BoardLabel, BoardSection } from "./board.js";
|
|
2
2
|
import { Annotation, Box, Cue, DECK_SIZE, Deck, DeckInput, DeckLimits, ImageFit, Manifest, Narration, Point, PublishedShot, SHOT_KEY, Shot, Size, Slide, SlideContent, Word, annotationCueIssues, exceedsLimits } from "./deck.js";
|
|
3
|
+
import { ArrangeOptions, BoardShapes, BoardView, MAX_BOARD_ZOOM, MIN_BOARD_ZOOM, ZoomBounds, arrange, boardBounds, boardToScreen, itemAt, itemHeight, screenToBoard, visibleItems, zoomAt, zoomToFit } from "./board-geometry.js";
|
|
4
|
+
import { Book, BookContents, BookFrontMatterEntry, BookInput, BookMode, BookPage, BookSection, BookView, BookViewInput, Chapter, isBookContents, isHebrew, noteMarkerIssues } from "./book.js";
|
|
3
5
|
import { DeckFromSlidesOptions, SlideRow, deckFromSlides } from "./deck-from-slides.js";
|
|
4
6
|
import { Direction, TextDirection, firstStrongDirection, languageDirection, resolveDirection } from "./direction.js";
|
|
5
7
|
import { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, NAMED_PAPERS, PAPER_MM, PX_PER_MM, Paper, PaperBox, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
|
|
@@ -676,6 +678,45 @@ export declare function jsonSchemas(): {
|
|
|
676
678
|
meta: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
677
679
|
}, z.core.$strip>;
|
|
678
680
|
}, z.core.$strip>>;
|
|
681
|
+
board: z.core.ZodStandardJSONSchemaPayload<z.ZodObject<{
|
|
682
|
+
title: z.ZodString;
|
|
683
|
+
direction: z.ZodEnum<{
|
|
684
|
+
ltr: "ltr";
|
|
685
|
+
rtl: "rtl";
|
|
686
|
+
}>;
|
|
687
|
+
items: z.ZodArray<z.ZodObject<{
|
|
688
|
+
id: z.ZodString;
|
|
689
|
+
kind: z.ZodEnum<{
|
|
690
|
+
paper: "paper";
|
|
691
|
+
page: "page";
|
|
692
|
+
book: "book";
|
|
693
|
+
shot: "shot";
|
|
694
|
+
image: "image";
|
|
695
|
+
deck: "deck";
|
|
696
|
+
}>;
|
|
697
|
+
address: z.ZodString;
|
|
698
|
+
x: z.ZodNumber;
|
|
699
|
+
y: z.ZodNumber;
|
|
700
|
+
width: z.ZodNumber;
|
|
701
|
+
}, z.core.$strip>>;
|
|
702
|
+
labels: z.ZodArray<z.ZodObject<{
|
|
703
|
+
id: z.ZodString;
|
|
704
|
+
text: z.ZodString;
|
|
705
|
+
x: z.ZodNumber;
|
|
706
|
+
y: z.ZodNumber;
|
|
707
|
+
}, z.core.$strip>>;
|
|
708
|
+
sections: z.ZodArray<z.ZodObject<{
|
|
709
|
+
id: z.ZodString;
|
|
710
|
+
title: z.ZodString;
|
|
711
|
+
rectangle: z.ZodObject<{
|
|
712
|
+
x: z.ZodNumber;
|
|
713
|
+
y: z.ZodNumber;
|
|
714
|
+
width: z.ZodNumber;
|
|
715
|
+
height: z.ZodNumber;
|
|
716
|
+
}, z.core.$strip>;
|
|
717
|
+
items: z.ZodArray<z.ZodString>;
|
|
718
|
+
}, z.core.$strip>>;
|
|
719
|
+
}, z.core.$strip>>;
|
|
679
720
|
};
|
|
680
721
|
//#endregion
|
|
681
|
-
export { Annotation, Book, BookContents, BookFrontMatterEntry, type BookInput, BookMode, BookPage, BookSection, BookView, type BookViewInput, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, type DeckFromSlidesOptions, type DeckInput, type DeckLimits, Direction, ImageFit, type Imposed, Lexicon, MARK_GAP_MM, MARK_LENGTH_MM, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, type MillimeterEdges, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PX_PER_MM, type PageFit, type PagePlacementKind, type PagePlacementLayout, Paper, type PaperBox, type Placement, Point, PronunciationEntry, PublishedShot, SHOT_KEY, Scripts, Shot, type ShotUse, Size, Slide, SlideContent, type SlideRow,
|
|
722
|
+
export { Annotation, type ArrangeOptions, Board, type BoardInput, BoardItem, BoardLabel, BoardSection, type BoardShapes, type BoardView, Book, BookContents, BookFrontMatterEntry, type BookInput, BookMode, BookPage, BookSection, BookView, type BookViewInput, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, type DeckFromSlidesOptions, type DeckInput, type DeckLimits, Direction, ImageFit, type Imposed, Lexicon, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_BOARD_ZOOM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, type MillimeterEdges, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PX_PER_MM, type PageFit, type PagePlacementKind, type PagePlacementLayout, Paper, type PaperBox, type Placement, Point, PronunciationEntry, PublishedShot, SHOT_KEY, Scripts, Shot, type ShotUse, Size, Slide, SlideContent, type SlideRow, TextDirection, Transition, TransitionInput, Word, type ZoomBounds, annotationCueIssues, arrange, boardBounds, boardToScreen, deckFromSlides, exceedsLimits, firstStrongDirection, fitPage, formatNumber, impose, isBookContents, isHebrew, itemAt, itemHeight, languageDirection, lexiconVersion, mirrorPlacement, noteMarker, noteMarkerIssues, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, screenToBoard, sheetMm, shotsUsed, toMillimeters, visibleItems, zoomAt, zoomToFit };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { Direction, firstStrongDirection, languageDirection, resolveDirection } from "./direction.js";
|
|
2
|
-
import { NoteMarker, NumberSystem, formatNumber, noteMarker } from "./numbering.js";
|
|
3
|
-
import { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, NAMED_PAPERS, PAPER_MM, PX_PER_MM, Paper, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
|
|
1
|
+
import { Direction, TextDirection, firstStrongDirection, languageDirection, resolveDirection } from "./direction.js";
|
|
4
2
|
import { Scripts } from "./scripts.js";
|
|
5
|
-
import { Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookShape, BookView, Chapter, isBookContents, isHebrew, noteMarkerIssues } from "./book.js";
|
|
6
3
|
import { MAX_SLIDE_TIMING_MS } from "./timing.js";
|
|
7
4
|
import { DEFAULT_TRANSITION_DURATION_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, Transition } from "./transition.js";
|
|
8
5
|
import { Annotation, Box, Cue, DECK_SIZE, Deck, DeckShape, ImageFit, Manifest, Narration, Point, PublishedShot, SHOT_KEY, Shot, Size, Slide, SlideContent, Word, annotationCueIssues, exceedsLimits } from "./deck.js";
|
|
6
|
+
import { Board, BoardItem, BoardLabel, BoardSection } from "./board.js";
|
|
7
|
+
import { NoteMarker, NumberSystem, formatNumber, noteMarker } from "./numbering.js";
|
|
8
|
+
import { MARK_GAP_MM, MARK_LENGTH_MM, MM_PER_PT, NAMED_PAPERS, PAPER_MM, PX_PER_MM, Paper, printBoxes, printPadding, printProperties, roundMillimeters, sheetMm, toMillimeters } from "./paper.js";
|
|
9
|
+
import { Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookShape, BookView, Chapter, isBookContents, isHebrew, noteMarkerIssues } from "./book.js";
|
|
9
10
|
import { Lexicon, PronunciationEntry, lexiconVersion } from "./lexicon.js";
|
|
11
|
+
import { MAX_BOARD_ZOOM, MIN_BOARD_ZOOM, arrange, boardBounds, boardToScreen, itemAt, itemHeight, screenToBoard, visibleItems, zoomAt, zoomToFit } from "./board-geometry.js";
|
|
10
12
|
import { deckFromSlides } from "./deck-from-slides.js";
|
|
11
13
|
import { fitPage, impose, mirrorPlacement, pagePlacementLayout } from "./imposition.js";
|
|
12
14
|
import { shotsUsed } from "./shots-used.js";
|
|
@@ -147,8 +149,9 @@ function jsonSchemas() {
|
|
|
147
149
|
imposition: z.toJSONSchema(Imposition, { io: "input" }),
|
|
148
150
|
deck: z.toJSONSchema(DeckShape, { io: "input" }),
|
|
149
151
|
manifest: z.toJSONSchema(Manifest, { io: "input" }),
|
|
150
|
-
publishedShot: z.toJSONSchema(PublishedShot, { io: "input" })
|
|
152
|
+
publishedShot: z.toJSONSchema(PublishedShot, { io: "input" }),
|
|
153
|
+
board: z.toJSONSchema(Board, { io: "input" })
|
|
151
154
|
};
|
|
152
155
|
}
|
|
153
156
|
//#endregion
|
|
154
|
-
export { Annotation, Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookView, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, Direction, ImageFit, Imposition, Lexicon, MARK_GAP_MM, MARK_LENGTH_MM, MAX_IMPOSITION_CELLS, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, Margin, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PX_PER_MM, Page, PageSize, Paper, Point, Print, PronunciationEntry, PublishedShot, SHOT_KEY, Scripts, Shot, Size, Slide, SlideContent, Transition, Word, annotationCueIssues, deckFromSlides, exceedsLimits, firstStrongDirection, fitPage, formatNumber, impose, isBookContents, isHebrew, jsonSchemas, languageDirection, lexiconVersion, mirrorPlacement, noteMarker, noteMarkerIssues, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, sheetMm, shotsUsed, toMillimeters };
|
|
157
|
+
export { Annotation, Board, BoardItem, BoardLabel, BoardSection, Book, BookContents, BookFrontMatterEntry, BookMode, BookPage, BookSection, BookView, Box, Chapter, Cue, DECK_SIZE, DEFAULT_TRANSITION_DURATION_MS, Deck, Direction, ImageFit, Imposition, Lexicon, MARK_GAP_MM, MARK_LENGTH_MM, MAX_BOARD_ZOOM, MAX_IMPOSITION_CELLS, MAX_SLIDE_TIMING_MS, MAX_TRANSITION_DURATION_MS, MIN_BOARD_ZOOM, MIN_TRANSITION_DURATION_MS, MM_PER_PT, Manifest, Margin, NAMED_PAPERS, Narration, NoteMarker, NumberSystem, PAPER_MM, PX_PER_MM, Page, PageSize, Paper, Point, Print, PronunciationEntry, PublishedShot, SHOT_KEY, Scripts, Shot, Size, Slide, SlideContent, TextDirection, Transition, Word, annotationCueIssues, arrange, boardBounds, boardToScreen, deckFromSlides, exceedsLimits, firstStrongDirection, fitPage, formatNumber, impose, isBookContents, isHebrew, itemAt, itemHeight, jsonSchemas, languageDirection, lexiconVersion, mirrorPlacement, noteMarker, noteMarkerIssues, pagePlacementLayout, printBoxes, printPadding, printProperties, resolveDirection, roundMillimeters, screenToBoard, sheetMm, shotsUsed, toMillimeters, visibleItems, zoomAt, zoomToFit };
|