@bendyline/squisq 2.11.5 → 2.11.7

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.
@@ -1,214 +0,0 @@
1
- // src/schemas/Viewport.ts
2
- var VIEWPORT_PRESETS = {
3
- /** 16:9 landscape (default, 1080p) */
4
- landscape: { width: 1920, height: 1080, name: "16:9 Landscape" },
5
- /** 9:16 portrait (vertical video, stories) */
6
- portrait: { width: 1080, height: 1920, name: "9:16 Portrait" },
7
- /** 1:1 square (social media) */
8
- square: { width: 1080, height: 1080, name: "1:1 Square" },
9
- /** 4:3 standard */
10
- standard: { width: 1440, height: 1080, name: "4:3 Standard" }
11
- };
12
- function getViewport(viewport) {
13
- if (typeof viewport === "string") {
14
- return VIEWPORT_PRESETS[viewport];
15
- }
16
- return viewport;
17
- }
18
- var REFERENCE_DIAGONAL = Math.sqrt(1920 * 1920 + 1080 * 1080);
19
- function calculateFontScale(viewport) {
20
- const currentDiagonal = Math.sqrt(
21
- viewport.width * viewport.width + viewport.height * viewport.height
22
- );
23
- return currentDiagonal / REFERENCE_DIAGONAL;
24
- }
25
- function getViewportOrientation(viewport) {
26
- const ratio = viewport.width / viewport.height;
27
- if (Math.abs(ratio - 1) < 0.05) return "square";
28
- return ratio > 1 ? "landscape" : "portrait";
29
- }
30
- function getAspectRatioString(viewport) {
31
- const gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
32
- const divisor = gcd(viewport.width, viewport.height);
33
- return `${viewport.width / divisor}:${viewport.height / divisor}`;
34
- }
35
-
36
- // src/schemas/LayoutStrategy.ts
37
- var LAYOUT_CONFIGS = {
38
- landscape: {
39
- primaryY: "35%",
40
- secondaryY: "55%",
41
- tertiaryY: "75%",
42
- titleScale: 1,
43
- bodyScale: 1,
44
- columnLeftX: "25%",
45
- columnRightX: "75%",
46
- columnTopY: "35%",
47
- columnBottomY: "65%",
48
- stackColumns: false,
49
- maxTextWidth: "80%",
50
- horizontalPadding: "10%",
51
- captionY: "85%",
52
- captionScale: 1
53
- },
54
- portrait: {
55
- // Content positioned higher for thumb-reach zone on mobile
56
- primaryY: "25%",
57
- secondaryY: "42%",
58
- tertiaryY: "58%",
59
- // Titles scale down for narrower width; body text scales up to fill vertical space
60
- titleScale: 0.7,
61
- bodyScale: 1.5,
62
- // Stacked columns instead of side-by-side
63
- columnLeftX: "50%",
64
- columnRightX: "50%",
65
- columnTopY: "30%",
66
- columnBottomY: "55%",
67
- stackColumns: true,
68
- // Wider relative to viewport to use available space
69
- maxTextWidth: "90%",
70
- horizontalPadding: "5%",
71
- captionY: "75%",
72
- captionScale: 0.85
73
- },
74
- square: {
75
- primaryY: "30%",
76
- secondaryY: "50%",
77
- tertiaryY: "70%",
78
- titleScale: 0.85,
79
- bodyScale: 0.9,
80
- columnLeftX: "25%",
81
- columnRightX: "75%",
82
- columnTopY: "35%",
83
- columnBottomY: "65%",
84
- stackColumns: false,
85
- maxTextWidth: "85%",
86
- horizontalPadding: "7.5%",
87
- captionY: "82%",
88
- captionScale: 0.9
89
- }
90
- };
91
- function getLayoutHints(orientation) {
92
- return LAYOUT_CONFIGS[orientation];
93
- }
94
- function scaledFontSize(basePx, viewport, orientation, isTitle = false) {
95
- const fontScale = calculateFontScale(viewport);
96
- const layout = getLayoutHints(orientation);
97
- const typeScale = isTitle ? layout.titleScale : layout.bodyScale;
98
- return Math.round(basePx * fontScale * typeScale);
99
- }
100
- function getTwoColumnPositions(orientation) {
101
- const layout = getLayoutHints(orientation);
102
- if (layout.stackColumns) {
103
- return {
104
- left: { x: "50%", y: layout.columnTopY },
105
- right: { x: "50%", y: layout.columnBottomY }
106
- };
107
- }
108
- return {
109
- left: { x: layout.columnLeftX, y: "50%" },
110
- right: { x: layout.columnRightX, y: "50%" }
111
- };
112
- }
113
- function getSafeTextBounds(orientation) {
114
- const layout = getLayoutHints(orientation);
115
- return {
116
- left: layout.horizontalPadding,
117
- right: layout.horizontalPadding,
118
- top: "10%",
119
- bottom: "10%"
120
- };
121
- }
122
-
123
- // src/schemas/BlockTemplates.ts
124
- var DEFAULT_DOC_FONT = 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';
125
- var DEFAULT_TITLE_FONT = 'Georgia, "Times New Roman", serif';
126
- function isTemplateBlock(block) {
127
- return "template" in block && typeof block.template === "string";
128
- }
129
- function createTemplateContext(theme, blockIndex, totalBlocks, viewport = VIEWPORT_PRESETS.landscape) {
130
- const orientation = getViewportOrientation(viewport);
131
- const overrides = theme.renderStyle.layoutOverrides;
132
- const baseLayout = getLayoutHints(orientation);
133
- return {
134
- theme,
135
- blockIndex,
136
- totalBlocks,
137
- viewport,
138
- fontScale: calculateFontScale(viewport),
139
- orientation,
140
- layout: overrides ? { ...baseLayout, ...overrides } : baseLayout
141
- };
142
- }
143
- function scaledFontSize2(basePx, context, isTitle = false) {
144
- return scaledFontSize(basePx, context.viewport, context.orientation, isTitle);
145
- }
146
- function isPersistentLayerTemplate(layer) {
147
- return "template" in layer && typeof layer.template === "string";
148
- }
149
-
150
- // src/internal/immutable.ts
151
- function cloneData(value, seen = /* @__PURE__ */ new WeakMap()) {
152
- if (value === null || typeof value !== "object") return value;
153
- const existing = seen.get(value);
154
- if (existing !== void 0) return existing;
155
- const tag = Object.prototype.toString.call(value);
156
- if (tag === "[object ArrayBuffer]") {
157
- const source2 = new Uint8Array(value);
158
- const copy2 = new Uint8Array(source2.byteLength);
159
- copy2.set(source2);
160
- return copy2.buffer;
161
- }
162
- if (tag === "[object Date]") {
163
- return new Date(Date.prototype.getTime.call(value));
164
- }
165
- if (Array.isArray(value)) {
166
- const copy2 = [];
167
- seen.set(value, copy2);
168
- for (const item of value) copy2.push(cloneData(item, seen));
169
- return copy2;
170
- }
171
- const source = value;
172
- const copy = {};
173
- seen.set(value, copy);
174
- for (const key of Object.keys(source)) {
175
- Object.defineProperty(copy, key, {
176
- value: cloneData(source[key], seen),
177
- enumerable: true,
178
- configurable: true,
179
- writable: true
180
- });
181
- }
182
- return copy;
183
- }
184
- function deepFreezeData(value, seen = /* @__PURE__ */ new WeakSet()) {
185
- if (value === null || typeof value !== "object" || seen.has(value)) return value;
186
- seen.add(value);
187
- for (const key of Object.keys(value)) {
188
- deepFreezeData(value[key], seen);
189
- }
190
- return Object.freeze(value);
191
- }
192
- function cloneAndFreezeData(value) {
193
- return deepFreezeData(cloneData(value));
194
- }
195
-
196
- export {
197
- VIEWPORT_PRESETS,
198
- getViewport,
199
- calculateFontScale,
200
- getViewportOrientation,
201
- getAspectRatioString,
202
- getLayoutHints,
203
- scaledFontSize,
204
- getTwoColumnPositions,
205
- getSafeTextBounds,
206
- DEFAULT_DOC_FONT,
207
- DEFAULT_TITLE_FONT,
208
- isTemplateBlock,
209
- createTemplateContext,
210
- scaledFontSize2,
211
- isPersistentLayerTemplate,
212
- cloneData,
213
- cloneAndFreezeData
214
- };
@@ -1,34 +0,0 @@
1
- import {
2
- DEFAULT_WORDS_PER_SECOND,
3
- countSpokenWords
4
- } from "./chunk-67L6WRJN.js";
5
-
6
- // src/timing/readingTime.ts
7
- var DEFAULT_READING_WPM = 200;
8
- function estimateReadingTime(text, options) {
9
- const configuredWpm = options?.wordsPerMinute;
10
- const wpm = typeof configuredWpm === "number" && configuredWpm > 0 ? configuredWpm : DEFAULT_READING_WPM;
11
- const words = text.split(/\s+/).filter((w) => w.length > 0).length;
12
- const minutes = words / wpm;
13
- return {
14
- words,
15
- minutes,
16
- seconds: Math.round(minutes * 60)
17
- };
18
- }
19
- function estimateNarrationTime(text, options) {
20
- const providedWps = options?.wordsPerSecond;
21
- const wps = typeof providedWps === "number" && providedWps > 0 ? providedWps : DEFAULT_WORDS_PER_SECOND;
22
- const spokenWords = countSpokenWords(text);
23
- const totalSeconds = spokenWords / wps;
24
- return {
25
- spokenWords,
26
- minutes: totalSeconds / 60,
27
- seconds: Math.round(totalSeconds)
28
- };
29
- }
30
-
31
- export {
32
- estimateReadingTime,
33
- estimateNarrationTime
34
- };