@bendyline/squisq 1.4.1 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/dist/{ContentContainer-DNx460y8.d.ts → ContentContainer-BXUlIf18.d.ts} +6 -2
- package/dist/{Doc-BeSeH2iX.d.ts → Doc-BBVGq1_9.d.ts} +922 -273
- package/dist/{ImageEditDoc-BTIvw0oq.d.ts → ImageEditDoc-FuyGtt6o.d.ts} +11 -4
- package/dist/{chunk-ZTX4PFFT.js → chunk-2OIBZYKP.js} +75 -2
- package/dist/chunk-2OIBZYKP.js.map +1 -0
- package/dist/chunk-2UQOHYE2.js +45 -0
- package/dist/chunk-2UQOHYE2.js.map +1 -0
- package/dist/chunk-6ATE2PSM.js +344 -0
- package/dist/chunk-6ATE2PSM.js.map +1 -0
- package/dist/{chunk-57CVQCFX.js → chunk-A4O7GIWE.js} +74 -23
- package/dist/chunk-A4O7GIWE.js.map +1 -0
- package/dist/{chunk-5WFRKURX.js → chunk-DLXZMS5K.js} +4 -2
- package/dist/chunk-DLXZMS5K.js.map +1 -0
- package/dist/chunk-ET53IIEP.js +1 -0
- package/dist/chunk-ET53IIEP.js.map +1 -0
- package/dist/chunk-HWVFJAAH.js +362 -0
- package/dist/chunk-HWVFJAAH.js.map +1 -0
- package/dist/{chunk-2TMAWB4Y.js → chunk-IMSCRLLV.js} +1 -1
- package/dist/chunk-IMSCRLLV.js.map +1 -0
- package/dist/{chunk-B4EEON3N.js → chunk-KKNUBQ6Y.js} +536 -103
- package/dist/chunk-KKNUBQ6Y.js.map +1 -0
- package/dist/chunk-LDQ2HJIX.js +596 -0
- package/dist/chunk-LDQ2HJIX.js.map +1 -0
- package/dist/chunk-LH7I6SH7.js +7208 -0
- package/dist/chunk-LH7I6SH7.js.map +1 -0
- package/dist/chunk-PGGGKYWG.js +1 -0
- package/dist/chunk-PGGGKYWG.js.map +1 -0
- package/dist/{chunk-7UDSRZKG.js → chunk-Q3ROPT5H.js} +35 -14
- package/dist/chunk-Q3ROPT5H.js.map +1 -0
- package/dist/chunk-QE7TWGVT.js +178 -0
- package/dist/chunk-QE7TWGVT.js.map +1 -0
- package/dist/chunk-RUDYOTA6.js +345 -0
- package/dist/chunk-RUDYOTA6.js.map +1 -0
- package/dist/{chunk-K32VJONL.js → chunk-T5UK6YOB.js} +41 -2
- package/dist/chunk-T5UK6YOB.js.map +1 -0
- package/dist/{chunk-3K5OG6KI.js → chunk-TEEEILMP.js} +412 -186
- package/dist/chunk-TEEEILMP.js.map +1 -0
- package/dist/{chunk-FR2RBTKO.js → chunk-TQWLI6S2.js} +93 -27
- package/dist/chunk-TQWLI6S2.js.map +1 -0
- package/dist/{chunk-WMOI7FN3.js → chunk-UY7KGQ5R.js} +12 -2
- package/dist/{chunk-WMOI7FN3.js.map → chunk-UY7KGQ5R.js.map} +1 -1
- package/dist/{chunk-3E5F2XMR.js → chunk-VWUFZ6ZG.js} +29 -2
- package/dist/chunk-VWUFZ6ZG.js.map +1 -0
- package/dist/chunk-ZLQKNOZQ.js +1 -0
- package/dist/chunk-ZLQKNOZQ.js.map +1 -0
- package/dist/doc/index.d.ts +5 -5
- package/dist/doc/index.js +135 -8
- package/dist/generate/index.d.ts +3 -74
- package/dist/generate/index.js +2 -7
- package/dist/icons/index.d.ts +3 -26
- package/dist/icons/index.js +13 -0
- package/dist/icons/inlineIconMarker.d.ts +1 -0
- package/dist/icons/inlineIconMarker.js +15 -0
- package/dist/icons/inlineIconMarker.js.map +1 -0
- package/dist/imageEdit/index.d.ts +12 -6
- package/dist/imageEdit/index.js +4 -1
- package/dist/index.d.ts +14 -11
- package/dist/index.js +265 -37
- package/dist/inlineIconMarker-CiE8Hlvz.d.ts +59 -0
- package/dist/jsonForm/index.d.ts +42 -1
- package/dist/jsonForm/index.js +9 -1
- package/dist/markdown/index.d.ts +228 -3
- package/dist/markdown/index.js +42 -7
- package/dist/recommend/index.d.ts +1 -1
- package/dist/recommend/index.js +3 -2
- package/dist/schemas/index.d.ts +28 -8
- package/dist/schemas/index.js +36 -8
- package/dist/spatial/index.d.ts +9 -4
- package/dist/spatial/index.js +1 -1
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.js +1 -1
- package/dist/story/index.d.ts +1021 -41
- package/dist/story/index.js +135 -8
- package/dist/{themeLibrary-BHjJ0Qx6.d.ts → themeLibrary-CehcJhzz.d.ts} +1 -1
- package/dist/timing/index.js +3 -5
- package/dist/transform/index.d.ts +48 -10
- package/dist/transform/index.js +17 -481
- package/dist/transform/index.js.map +1 -1
- package/dist/{types-BdZkdJ3z.d.ts → types-DlAZ7MW4.d.ts} +115 -1
- package/dist/versions/index.d.ts +1 -1
- package/package.json +6 -1
- package/src/__tests__/animationUtils.test.ts +40 -0
- package/src/__tests__/annotationCoercion.test.ts +243 -0
- package/src/__tests__/applyRenderStyle.test.ts +146 -0
- package/src/__tests__/atmosphereLayers.test.ts +108 -0
- package/src/__tests__/attrTokens.test.ts +162 -0
- package/src/__tests__/contentExtractor.test.ts +60 -0
- package/src/__tests__/coverBlock.test.ts +46 -1
- package/src/__tests__/customTemplateSample.test.ts +144 -0
- package/src/__tests__/customTemplatesFrontmatter.test.ts +236 -0
- package/src/__tests__/customThemesFrontmatter.test.ts +145 -0
- package/src/__tests__/diagramBlock.test.ts +122 -0
- package/src/__tests__/diagramLayout.test.ts +134 -0
- package/src/__tests__/drawing.test.ts +109 -0
- package/src/__tests__/drawingBlock.test.ts +124 -0
- package/src/__tests__/drawingLayout.test.ts +171 -0
- package/src/__tests__/geohash.test.ts +6 -5
- package/src/__tests__/getLayers.test.ts +6 -2
- package/src/__tests__/getLayersFallback.test.ts +103 -0
- package/src/__tests__/imageEditExportSvg.test.ts +70 -0
- package/src/__tests__/imageEditVersions.test.ts +72 -0
- package/src/__tests__/inlineIconMarker.test.ts +36 -0
- package/src/__tests__/inputDescriptors.test.ts +162 -0
- package/src/__tests__/jsonForm.tokens.test.ts +84 -0
- package/src/__tests__/layoutBlock.test.ts +83 -0
- package/src/__tests__/layoutLayout.test.ts +169 -0
- package/src/__tests__/markdown.test.ts +87 -0
- package/src/__tests__/markdownSanitize.test.ts +79 -0
- package/src/__tests__/markdownToDoc.test.ts +391 -2
- package/src/__tests__/mediaAnnotations.test.ts +91 -0
- package/src/__tests__/mediaSchedule.test.ts +118 -0
- package/src/__tests__/pandocAttrParse.test.ts +187 -0
- package/src/__tests__/resolveDocTheme.test.ts +55 -0
- package/src/__tests__/rootExports.test.ts +43 -0
- package/src/__tests__/shapeGeometry.test.ts +89 -0
- package/src/__tests__/shapeVocabulary.test.ts +133 -0
- package/src/__tests__/structuredData.test.ts +249 -0
- package/src/__tests__/templateAnnotationParse.test.ts +108 -0
- package/src/__tests__/templateMetadata.test.ts +31 -0
- package/src/__tests__/templates.test.ts +257 -4
- package/src/__tests__/themeCompile.test.ts +42 -0
- package/src/__tests__/themeValidator.test.ts +6 -0
- package/src/__tests__/transformV2.test.ts +137 -0
- package/src/__tests__/transitionNormalize.test.ts +61 -0
- package/src/__tests__/validateDoc.test.ts +260 -0
- package/src/doc/annotationBlocks.ts +117 -0
- package/src/doc/customTemplatesFrontmatter.ts +314 -0
- package/src/doc/customThemesFrontmatter.ts +95 -0
- package/src/doc/docToMarkdown.ts +104 -5
- package/src/doc/getLayers.ts +49 -17
- package/src/doc/index.ts +47 -1
- package/src/doc/markdownToDoc.ts +411 -13
- package/src/doc/mediaAnnotations.ts +100 -0
- package/src/doc/resolveDocTheme.ts +55 -0
- package/src/doc/standaloneAnnotation.ts +58 -0
- package/src/doc/structuredData.ts +301 -0
- package/src/doc/templateInputs.ts +240 -0
- package/src/doc/templates/__tests__/customTemplate.test.ts +170 -0
- package/src/doc/templates/__tests__/customTemplateRegistry.test.ts +110 -0
- package/src/doc/templates/accentImage.ts +30 -6
- package/src/doc/templates/captionUtils.ts +23 -0
- package/src/doc/templates/comparisonBar.ts +33 -18
- package/src/doc/templates/coverBlock.ts +35 -5
- package/src/doc/templates/customTemplate.ts +51 -0
- package/src/doc/templates/dataTable.ts +37 -19
- package/src/doc/templates/dateEvent.ts +41 -20
- package/src/doc/templates/definitionCard.ts +26 -18
- package/src/doc/templates/diagramBlock.ts +204 -0
- package/src/doc/templates/diagramLayout.ts +159 -0
- package/src/doc/templates/drawingBlock.ts +325 -0
- package/src/doc/templates/drawingLayout.ts +539 -0
- package/src/doc/templates/factCard.ts +54 -26
- package/src/doc/templates/fallbackBlock.ts +123 -0
- package/src/doc/templates/featureBlock.ts +20 -13
- package/src/doc/templates/fullBleedQuote.ts +18 -8
- package/src/doc/templates/imageWithCaption.ts +30 -15
- package/src/doc/templates/index.ts +225 -46
- package/src/doc/templates/inputDescriptors.ts +432 -0
- package/src/doc/templates/layoutBlock.ts +43 -0
- package/src/doc/templates/layoutLayout.ts +243 -0
- package/src/doc/templates/listBlock.ts +56 -30
- package/src/doc/templates/mapBlock.ts +15 -12
- package/src/doc/templates/metadata.ts +120 -0
- package/src/doc/templates/persistentLayers.ts +129 -11
- package/src/doc/templates/photoGrid.ts +22 -34
- package/src/doc/templates/pullQuote.ts +30 -12
- package/src/doc/templates/quoteBlock.ts +54 -29
- package/src/doc/templates/sectionHeader.ts +25 -11
- package/src/doc/templates/statHighlight.ts +39 -22
- package/src/doc/templates/titleBlock.ts +59 -21
- package/src/doc/templates/tokens/__tests__/resolveTokens.test.ts +487 -0
- package/src/doc/templates/tokens/resolveTokens.ts +453 -0
- package/src/doc/templates/twoColumn.ts +48 -30
- package/src/doc/templates/videoPullQuote.ts +22 -12
- package/src/doc/templates/videoWithCaption.ts +21 -15
- package/src/doc/utils/animationUtils.ts +267 -3
- package/src/doc/utils/applyRenderStyle.ts +113 -0
- package/src/doc/utils/imageTreatment.ts +70 -0
- package/src/doc/utils/nearest.ts +59 -0
- package/src/doc/utils/shapeGeometry.ts +464 -0
- package/src/doc/utils/themeUtils.ts +75 -1
- package/src/doc/validate.ts +575 -0
- package/src/generate/contentExtractor.ts +148 -35
- package/src/generate/index.ts +0 -3
- package/src/icons/index.ts +8 -0
- package/src/icons/inlineIconMarker.ts +73 -0
- package/src/imageEdit/export.ts +85 -2
- package/src/imageEdit/index.ts +1 -0
- package/src/imageEdit/persistence.ts +51 -0
- package/src/index.ts +2 -0
- package/src/jsonForm/index.ts +2 -0
- package/src/jsonForm/tokens.ts +78 -0
- package/src/markdown/annotationCoercion.ts +295 -0
- package/src/markdown/attrTokens.ts +241 -0
- package/src/markdown/convert.ts +229 -26
- package/src/markdown/index.ts +37 -0
- package/src/markdown/sanitize.ts +318 -0
- package/src/markdown/stringify.ts +96 -6
- package/src/markdown/types.ts +66 -0
- package/src/markdown/utils.ts +111 -2
- package/src/recommend/templates.ts +24 -0
- package/src/schemas/BlockTemplates.ts +133 -4
- package/src/schemas/CustomTemplates.ts +126 -0
- package/src/schemas/Doc.ts +387 -65
- package/src/schemas/ImageEditDoc.ts +11 -4
- package/src/schemas/Media.ts +169 -0
- package/src/schemas/Theme.ts +23 -1
- package/src/schemas/Transitions.ts +224 -0
- package/src/schemas/colorUtils.ts +33 -0
- package/src/schemas/fontStacks.ts +5 -2
- package/src/schemas/index.ts +3 -0
- package/src/schemas/themeCompile.ts +24 -5
- package/src/schemas/themeValidator.ts +49 -11
- package/src/schemas/themes/cinematic.json +69 -12
- package/src/schemas/themes/documentary.json +58 -11
- package/src/schemas/themes/gezellig.json +60 -11
- package/src/schemas/themes/magazine.json +54 -9
- package/src/schemas/themes/morning-light.json +52 -9
- package/src/schemas/themes/standard-dark.json +48 -13
- package/src/schemas/themes/standard.json +44 -12
- package/src/schemas/themes/tech-dark.json +65 -12
- package/src/spatial/Geohash.ts +52 -21
- package/src/storage/ContentContainer.ts +6 -2
- package/src/transform/applyTransform.ts +43 -4
- package/src/transform/index.ts +1 -0
- package/src/transform/registry.ts +44 -13
- package/src/transform/styles/dataDriven.ts +2 -1
- package/src/transform/styles/documentary.ts +2 -1
- package/src/transform/styles/magazine.ts +3 -1
- package/src/transform/styles/minimal.ts +2 -1
- package/src/transform/styles/narrative.ts +3 -1
- package/src/transform/templateSelector.ts +87 -11
- package/src/transform/types.ts +35 -2
- package/dist/chunk-2TMAWB4Y.js.map +0 -1
- package/dist/chunk-3E5F2XMR.js.map +0 -1
- package/dist/chunk-3K5OG6KI.js.map +0 -1
- package/dist/chunk-4X3JQXNM.js +0 -35
- package/dist/chunk-4X3JQXNM.js.map +0 -1
- package/dist/chunk-57CVQCFX.js.map +0 -1
- package/dist/chunk-5WFRKURX.js.map +0 -1
- package/dist/chunk-7UDSRZKG.js.map +0 -1
- package/dist/chunk-B4EEON3N.js.map +0 -1
- package/dist/chunk-FR2RBTKO.js.map +0 -1
- package/dist/chunk-H3AXU4MJ.js +0 -179
- package/dist/chunk-H3AXU4MJ.js.map +0 -1
- package/dist/chunk-K32VJONL.js.map +0 -1
- package/dist/chunk-KSWJR66U.js +0 -3706
- package/dist/chunk-KSWJR66U.js.map +0 -1
- package/dist/chunk-MYIH7FWD.js +0 -145
- package/dist/chunk-MYIH7FWD.js.map +0 -1
- package/dist/chunk-ZTX4PFFT.js.map +0 -1
- package/src/__tests__/slideshowGenerator.test.ts +0 -128
- package/src/generate/slideshowGenerator.ts +0 -273
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-PGGGKYWG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -38,9 +38,7 @@ function getNeighbors(hash) {
|
|
|
38
38
|
return ngeohash.neighbors(hash);
|
|
39
39
|
}
|
|
40
40
|
function getGeohash4Neighbors(geohash4) {
|
|
41
|
-
if (geohash4.length !== 4)
|
|
42
|
-
throw new Error(`getGeohash4Neighbors requires 4-char geohash, got: ${geohash4}`);
|
|
43
|
-
}
|
|
41
|
+
if (geohash4.length !== 4) return [];
|
|
44
42
|
const neighbors = getNeighbors(geohash4);
|
|
45
43
|
return [geohash4, ...neighbors];
|
|
46
44
|
}
|
|
@@ -48,9 +46,7 @@ function getGeohashPrefix(geohash, precision) {
|
|
|
48
46
|
return geohash.slice(0, precision);
|
|
49
47
|
}
|
|
50
48
|
function geohashToHierarchicalPath(geohash4) {
|
|
51
|
-
if (geohash4.length !== 4)
|
|
52
|
-
throw new Error(`geohashToHierarchicalPath requires 4-char geohash, got: ${geohash4}`);
|
|
53
|
-
}
|
|
49
|
+
if (geohash4.length !== 4) return "";
|
|
54
50
|
const [c1, c2, c3, c4] = geohash4.split("");
|
|
55
51
|
return `${c1}/${c2}/${c3}/${c4}`;
|
|
56
52
|
}
|
|
@@ -58,19 +54,44 @@ function getGeohashPath(from, to, precision = 4) {
|
|
|
58
54
|
if (from === to) return [];
|
|
59
55
|
const fromCenter = decodeGeohash(from);
|
|
60
56
|
const toCenter = decodeGeohash(to);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const steps = Math.max(2, Math.ceil(
|
|
57
|
+
const distKm = haversineDistance(
|
|
58
|
+
{ lat: fromCenter.lat, lng: fromCenter.lng },
|
|
59
|
+
{ lat: toCenter.lat, lng: toCenter.lng }
|
|
60
|
+
);
|
|
61
|
+
const steps = Math.max(2, Math.ceil(distKm / 15));
|
|
62
|
+
const \u03C61 = fromCenter.lat * Math.PI / 180;
|
|
63
|
+
const \u03BB1 = fromCenter.lng * Math.PI / 180;
|
|
64
|
+
const \u03C62 = toCenter.lat * Math.PI / 180;
|
|
65
|
+
const \u03BB2 = toCenter.lng * Math.PI / 180;
|
|
66
|
+
const x1 = Math.cos(\u03C61) * Math.cos(\u03BB1);
|
|
67
|
+
const y1 = Math.cos(\u03C61) * Math.sin(\u03BB1);
|
|
68
|
+
const z1 = Math.sin(\u03C61);
|
|
69
|
+
const x2 = Math.cos(\u03C62) * Math.cos(\u03BB2);
|
|
70
|
+
const y2 = Math.cos(\u03C62) * Math.sin(\u03BB2);
|
|
71
|
+
const z2 = Math.sin(\u03C62);
|
|
72
|
+
const dot = Math.max(-1, Math.min(1, x1 * x2 + y1 * y2 + z1 * z2));
|
|
73
|
+
const d = Math.acos(dot);
|
|
74
|
+
const useLinear = Math.abs(Math.sin(d)) < 1e-10;
|
|
66
75
|
const seen = /* @__PURE__ */ new Set();
|
|
67
76
|
seen.add(from);
|
|
68
77
|
seen.add(to);
|
|
69
78
|
const path = [];
|
|
70
79
|
for (let i = 1; i < steps; i++) {
|
|
71
80
|
const t = i / steps;
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
let lat;
|
|
82
|
+
let lng;
|
|
83
|
+
if (useLinear) {
|
|
84
|
+
lat = fromCenter.lat + t * (toCenter.lat - fromCenter.lat);
|
|
85
|
+
lng = fromCenter.lng + t * (toCenter.lng - fromCenter.lng);
|
|
86
|
+
} else {
|
|
87
|
+
const A = Math.sin((1 - t) * d) / Math.sin(d);
|
|
88
|
+
const B = Math.sin(t * d) / Math.sin(d);
|
|
89
|
+
const x = A * x1 + B * x2;
|
|
90
|
+
const y = A * y1 + B * y2;
|
|
91
|
+
const z = A * z1 + B * z2;
|
|
92
|
+
lat = Math.atan2(z, Math.sqrt(x * x + y * y)) * 180 / Math.PI;
|
|
93
|
+
lng = Math.atan2(y, x) * 180 / Math.PI;
|
|
94
|
+
}
|
|
74
95
|
const hash = encodeGeohash(lat, lng, precision);
|
|
75
96
|
if (!seen.has(hash)) {
|
|
76
97
|
seen.add(hash);
|
|
@@ -100,4 +121,4 @@ export {
|
|
|
100
121
|
getGeohashPath,
|
|
101
122
|
geohashOverlapsBounds
|
|
102
123
|
};
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-Q3ROPT5H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/spatial/Haversine.ts","../src/spatial/Geohash.ts"],"sourcesContent":["/**\n * Haversine Distance Calculation\n *\n * Provides accurate distance calculation between two geographic coordinates\n * using the Haversine formula, which accounts for Earth's curvature.\n */\n\nimport type { Coordinates } from '../schemas/Types.js';\n\n/**\n * Calculate distance between two coordinates using Haversine formula.\n *\n * @param from Start coordinates\n * @param to End coordinates\n * @returns Distance in kilometers\n */\nexport function haversineDistance(from: Coordinates, to: Coordinates): number {\n const R = 6371; // Earth's radius in kilometers\n\n const dLat = toRadians(to.lat - from.lat);\n const dLng = toRadians(to.lng - from.lng);\n\n const a =\n Math.sin(dLat / 2) * Math.sin(dLat / 2) +\n Math.cos(toRadians(from.lat)) *\n Math.cos(toRadians(to.lat)) *\n Math.sin(dLng / 2) *\n Math.sin(dLng / 2);\n\n const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n\n return R * c;\n}\n\n/**\n * Calculate bearing from one coordinate to another.\n *\n * @param from Start coordinates\n * @param to End coordinates\n * @returns Bearing in degrees (0-360, where 0 = north, 90 = east)\n */\nexport function calculateBearing(from: Coordinates, to: Coordinates): number {\n const dLng = toRadians(to.lng - from.lng);\n const lat1 = toRadians(from.lat);\n const lat2 = toRadians(to.lat);\n\n const x = Math.sin(dLng) * Math.cos(lat2);\n const y = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLng);\n\n const bearing = Math.atan2(x, y);\n return ((bearing * 180) / Math.PI + 360) % 360;\n}\n\n/**\n * Convert degrees to radians.\n */\nfunction toRadians(degrees: number): number {\n return (degrees * Math.PI) / 180;\n}\n","/**\n * Geohash Utilities\n *\n * Provides geohash encoding/decoding and spatial utilities using the standard\n * ngeohash library for core operations, plus custom utilities for overlap checking\n * and distance calculation.\n *\n * Geohashes are a hierarchical spatial indexing system that divides the world\n * into a grid of cells. Each additional character narrows the area by ~1/32.\n *\n * Precision guide:\n * - 4 chars: ~39km x 19km (used for tile indexing)\n * - 5 chars: ~5km x 5km\n * - 6 chars: ~1.2km x 0.6km\n */\n\nimport ngeohash from 'ngeohash';\nimport { haversineDistance } from './Haversine.js';\n\n/**\n * Encode latitude/longitude to a geohash string.\n * Uses the standard ngeohash library.\n */\nexport function encodeGeohash(lat: number, lng: number, precision = 9): string {\n return ngeohash.encode(lat, lng, precision);\n}\n\n/**\n * Decode a geohash to latitude/longitude center with error bounds.\n * Uses the standard ngeohash library.\n */\nexport function decodeGeohash(hash: string): {\n lat: number;\n lng: number;\n latErr: number;\n lngErr: number;\n} {\n const result = ngeohash.decode(hash);\n return {\n lat: result.latitude,\n lng: result.longitude,\n latErr: result.error.latitude,\n lngErr: result.error.longitude,\n };\n}\n\n/**\n * Get the 8 neighboring geohash cells.\n * Returns up to 8 neighbors (fewer at poles or antimeridian).\n * Uses the standard ngeohash library.\n */\nexport function getNeighbors(hash: string): string[] {\n return ngeohash.neighbors(hash);\n}\n\n/**\n * Get a 3x3 grid of geohash4 cells (center + 8 neighbors).\n * Used for landing bonus expansions in Fly mode.\n *\n * @param geohash4 - Center geohash4 cell\n * @returns Array of 9 geohash4 cells (center first, then neighbors)\n *\n * @example\n * getGeohash4Neighbors('c23n')\n * // => ['c23n', 'c23p', 'c23q', 'c23j', 'c23m', 'c23k', 'c23h', 'c23e', 'c23s']\n */\nexport function getGeohash4Neighbors(geohash4: string): string[] {\n if (geohash4.length !== 4) return [];\n const neighbors = getNeighbors(geohash4);\n return [geohash4, ...neighbors];\n}\n\n/**\n * Get the prefix of a geohash at a given precision.\n * Simple helper for extracting geohash prefixes for directory organization.\n */\nexport function getGeohashPrefix(geohash: string, precision: number): string {\n return geohash.slice(0, precision);\n}\n\n/**\n * Convert a geohash prefix to a hierarchical path.\n *\n * Examples:\n * \"9mud\" -> \"9/m/u/d\"\n * \"9q8y\" -> \"9/q/8/y\"\n * \"c24k\" -> \"c/2/4/k\"\n *\n * This is used for organizing files in hierarchical directories to avoid\n * thousands of folders in a single directory, which causes filesystem\n * performance issues.\n */\nexport function geohashToHierarchicalPath(geohash4: string): string {\n if (geohash4.length !== 4) return '';\n const [c1, c2, c3, c4] = geohash4.split('');\n return `${c1}/${c2}/${c3}/${c4}`;\n}\n\n/**\n * Compute all geohash cells along the great-circle path between two geohash cells.\n * Samples points along the spherical arc from `from` to `to`, encoding each to a\n * geohash at the given precision, and returns the deduplicated list of intermediate\n * cells (excluding `from` and `to`).\n *\n * Uses spherical linear interpolation (SLERP) via 3D unit vectors, which correctly\n * handles antimeridian crossings and polar paths — both of which flat lat/lng\n * interpolation gets wrong.\n */\nexport function getGeohashPath(from: string, to: string, precision = 4): string[] {\n if (from === to) return [];\n\n const fromCenter = decodeGeohash(from);\n const toCenter = decodeGeohash(to);\n\n // Use haversine for accurate great-circle distance (step sizing)\n const distKm = haversineDistance(\n { lat: fromCenter.lat, lng: fromCenter.lng },\n { lat: toCenter.lat, lng: toCenter.lng },\n );\n\n // Step every ~15km to avoid skipping any geohash4 cell (~39x19km)\n const steps = Math.max(2, Math.ceil(distKm / 15));\n\n // Convert endpoints to unit Cartesian vectors for SLERP\n const φ1 = (fromCenter.lat * Math.PI) / 180;\n const λ1 = (fromCenter.lng * Math.PI) / 180;\n const φ2 = (toCenter.lat * Math.PI) / 180;\n const λ2 = (toCenter.lng * Math.PI) / 180;\n\n const x1 = Math.cos(φ1) * Math.cos(λ1);\n const y1 = Math.cos(φ1) * Math.sin(λ1);\n const z1 = Math.sin(φ1);\n const x2 = Math.cos(φ2) * Math.cos(λ2);\n const y2 = Math.cos(φ2) * Math.sin(λ2);\n const z2 = Math.sin(φ2);\n\n // Central angle between the two points\n const dot = Math.max(-1, Math.min(1, x1 * x2 + y1 * y2 + z1 * z2));\n const d = Math.acos(dot);\n // Near-antipodal fallback: sin(d)≈0 means the great circle is undefined.\n // Extremely unlikely for geohash path use; fall back to linear lat/lng.\n const useLinear = Math.abs(Math.sin(d)) < 1e-10;\n\n const seen = new Set<string>();\n seen.add(from);\n seen.add(to);\n\n const path: string[] = [];\n for (let i = 1; i < steps; i++) {\n const t = i / steps;\n let lat: number;\n let lng: number;\n if (useLinear) {\n lat = fromCenter.lat + t * (toCenter.lat - fromCenter.lat);\n lng = fromCenter.lng + t * (toCenter.lng - fromCenter.lng);\n } else {\n const A = Math.sin((1 - t) * d) / Math.sin(d);\n const B = Math.sin(t * d) / Math.sin(d);\n const x = A * x1 + B * x2;\n const y = A * y1 + B * y2;\n const z = A * z1 + B * z2;\n lat = (Math.atan2(z, Math.sqrt(x * x + y * y)) * 180) / Math.PI;\n lng = (Math.atan2(y, x) * 180) / Math.PI;\n }\n const hash = encodeGeohash(lat, lng, precision);\n if (!seen.has(hash)) {\n seen.add(hash);\n path.push(hash);\n }\n }\n\n return path;\n}\n\n/**\n * Check if a geohash cell overlaps with a bounding box.\n * Custom implementation (not available in ngeohash).\n */\nexport function geohashOverlapsBounds(\n hash: string,\n bounds: { north: number; south: number; east: number; west: number },\n): boolean {\n const { lat, lng, latErr, lngErr } = decodeGeohash(hash);\n\n const hashNorth = lat + latErr;\n const hashSouth = lat - latErr;\n const hashEast = lng + lngErr;\n const hashWest = lng - lngErr;\n\n return !(\n hashNorth < bounds.south ||\n hashSouth > bounds.north ||\n hashEast < bounds.west ||\n hashWest > bounds.east\n );\n}\n\n// Re-export for backwards compatibility with existing imports.\nexport { haversineDistance };\n"],"mappings":";AAgBO,SAAS,kBAAkB,MAAmB,IAAyB;AAC5E,QAAM,IAAI;AAEV,QAAM,OAAO,UAAU,GAAG,MAAM,KAAK,GAAG;AACxC,QAAM,OAAO,UAAU,GAAG,MAAM,KAAK,GAAG;AAExC,QAAM,IACJ,KAAK,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,OAAO,CAAC,IACtC,KAAK,IAAI,UAAU,KAAK,GAAG,CAAC,IAC1B,KAAK,IAAI,UAAU,GAAG,GAAG,CAAC,IAC1B,KAAK,IAAI,OAAO,CAAC,IACjB,KAAK,IAAI,OAAO,CAAC;AAErB,QAAM,IAAI,IAAI,KAAK,MAAM,KAAK,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC;AAEvD,SAAO,IAAI;AACb;AASO,SAAS,iBAAiB,MAAmB,IAAyB;AAC3E,QAAM,OAAO,UAAU,GAAG,MAAM,KAAK,GAAG;A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YAAM,WAAW,MAAM,KAAK,SAAS,MAAM,WAAW;AACtD,YAAM,WAAW,MAAM,KAAK,SAAS,MAAM,WAAW;AAAA,IACxD,OAAO;AACL,YAAM,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAC5C,YAAM,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;AACtC,YAAM,IAAI,IAAI,KAAK,IAAI;AACvB,YAAM,IAAI,IAAI,KAAK,IAAI;AACvB,YAAM,IAAI,IAAI,KAAK,IAAI;AACvB,YAAO,KAAK,MAAM,GAAG,KAAK,KAAK,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,MAAO,KAAK;AAC7D,YAAO,KAAK,MAAM,GAAG,CAAC,IAAI,MAAO,KAAK;AAAA,IACxC;AACA,UAAM,OAAO,cAAc,KAAK,KAAK,SAAS;AAC9C,QAAI,CAAC,KAAK,IAAI,IAAI,GAAG;AACnB,WAAK,IAAI,IAAI;AACb,WAAK,KAAK,IAAI;AAAA,IAChB;AAAA,EACF;AAEA,SAAO;AACT;AAMO,SAAS,sBACd,MACA,QACS;AACT,QAAM,EAAE,KAAK,KAAK,QAAQ,OAAO,IAAI,cAAc,IAAI;AAEvD,QAAM,YAAY,MAAM;AACxB,QAAM,YAAY,MAAM;AACxB,QAAM,WAAW,MAAM;AACvB,QAAM,WAAW,MAAM;AAEvB,SAAO,EACL,YAAY,OAAO,SACnB,YAAY,OAAO,SACnB,WAAW,OAAO,QAClB,WAAW,OAAO;AAEtB;","names":[]}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// src/schemas/Transitions.ts
|
|
2
|
+
var DEFAULT_TRANSITION_DURATION_SECONDS = 0.7;
|
|
3
|
+
var TRANSITION_TYPES = [
|
|
4
|
+
// Existing / common transitions
|
|
5
|
+
"cut",
|
|
6
|
+
"fade",
|
|
7
|
+
"dissolve",
|
|
8
|
+
"push",
|
|
9
|
+
"wipe",
|
|
10
|
+
"split",
|
|
11
|
+
"reveal",
|
|
12
|
+
"randomBars",
|
|
13
|
+
"shape",
|
|
14
|
+
"uncover",
|
|
15
|
+
"cover",
|
|
16
|
+
"zoom",
|
|
17
|
+
"pan",
|
|
18
|
+
// PowerPoint subtle / exciting transitions
|
|
19
|
+
"flash",
|
|
20
|
+
"fallOver",
|
|
21
|
+
"drape",
|
|
22
|
+
"curtains",
|
|
23
|
+
"wind",
|
|
24
|
+
"prestige",
|
|
25
|
+
"fracture",
|
|
26
|
+
"crush",
|
|
27
|
+
"peelOff",
|
|
28
|
+
"pageCurl",
|
|
29
|
+
"airplane",
|
|
30
|
+
"origami",
|
|
31
|
+
"checkerboard",
|
|
32
|
+
"blinds",
|
|
33
|
+
"clock",
|
|
34
|
+
"ripple",
|
|
35
|
+
"honeycomb",
|
|
36
|
+
"glitter",
|
|
37
|
+
"vortex",
|
|
38
|
+
"shred",
|
|
39
|
+
"switch",
|
|
40
|
+
"flip",
|
|
41
|
+
"gallery",
|
|
42
|
+
"cube",
|
|
43
|
+
"doors",
|
|
44
|
+
"box",
|
|
45
|
+
"ferrisWheel",
|
|
46
|
+
"conveyor",
|
|
47
|
+
"rotate",
|
|
48
|
+
"window",
|
|
49
|
+
"orbit",
|
|
50
|
+
"flyThrough",
|
|
51
|
+
"morph",
|
|
52
|
+
// PresentationML/Open XML precise names and legacy aliases
|
|
53
|
+
"checker",
|
|
54
|
+
"circle",
|
|
55
|
+
"comb",
|
|
56
|
+
"diamond",
|
|
57
|
+
"newsflash",
|
|
58
|
+
"plus",
|
|
59
|
+
"pull",
|
|
60
|
+
"random",
|
|
61
|
+
"randomBar",
|
|
62
|
+
"strips",
|
|
63
|
+
"wedge",
|
|
64
|
+
"wheel",
|
|
65
|
+
"prism",
|
|
66
|
+
"warp",
|
|
67
|
+
"ferris",
|
|
68
|
+
"flythrough",
|
|
69
|
+
"wheelReverse",
|
|
70
|
+
"pageCurlDouble",
|
|
71
|
+
"pageCurlSingle",
|
|
72
|
+
"slideLeft",
|
|
73
|
+
"slideRight",
|
|
74
|
+
"slideUp",
|
|
75
|
+
"slideDown"
|
|
76
|
+
];
|
|
77
|
+
var TRANSITION_DIRECTIONS = [
|
|
78
|
+
"left",
|
|
79
|
+
"right",
|
|
80
|
+
"up",
|
|
81
|
+
"down",
|
|
82
|
+
"in",
|
|
83
|
+
"out",
|
|
84
|
+
"horizontal",
|
|
85
|
+
"vertical"
|
|
86
|
+
];
|
|
87
|
+
var TRANSITION_TYPE_SET = new Set(TRANSITION_TYPES);
|
|
88
|
+
var TRANSITION_TYPE_ALIASES = {
|
|
89
|
+
none: "cut",
|
|
90
|
+
randombars: "randomBars",
|
|
91
|
+
randombar: "randomBar",
|
|
92
|
+
// Self-referential spellings (`checkerboard`, `shape`, `uncover`) are
|
|
93
|
+
// intentionally absent: an exact valid type returns early from
|
|
94
|
+
// `normalizeTransitionType`, and any case variant resolves through
|
|
95
|
+
// `NORMALIZED_TRANSITION_TYPES`. Only the *plural* aliases need an entry.
|
|
96
|
+
checkerboards: "checkerboard",
|
|
97
|
+
shapes: "shape",
|
|
98
|
+
ferris: "ferrisWheel",
|
|
99
|
+
ferriswheel: "ferrisWheel",
|
|
100
|
+
flythrough: "flyThrough",
|
|
101
|
+
flythru: "flyThrough",
|
|
102
|
+
pagecurl: "pageCurl",
|
|
103
|
+
pagecurldouble: "pageCurlDouble",
|
|
104
|
+
pagecurlsingle: "pageCurlSingle",
|
|
105
|
+
wheelreverse: "wheelReverse",
|
|
106
|
+
slideleft: "slideLeft",
|
|
107
|
+
slideright: "slideRight",
|
|
108
|
+
slideup: "slideUp",
|
|
109
|
+
slidedown: "slideDown"
|
|
110
|
+
};
|
|
111
|
+
var NORMALIZED_TRANSITION_TYPES = new Map(
|
|
112
|
+
TRANSITION_TYPES.map((type) => [normalizeToken(type), type])
|
|
113
|
+
);
|
|
114
|
+
function isTransitionType(value) {
|
|
115
|
+
return TRANSITION_TYPE_SET.has(value);
|
|
116
|
+
}
|
|
117
|
+
function normalizeTransitionType(value) {
|
|
118
|
+
const trimmed = value.trim();
|
|
119
|
+
if (!trimmed) return null;
|
|
120
|
+
if (isTransitionType(trimmed)) return trimmed;
|
|
121
|
+
const normalized = normalizeToken(trimmed);
|
|
122
|
+
return TRANSITION_TYPE_ALIASES[normalized] ?? NORMALIZED_TRANSITION_TYPES.get(normalized) ?? null;
|
|
123
|
+
}
|
|
124
|
+
function normalizeTransitionDirection(value) {
|
|
125
|
+
const normalized = normalizeToken(value);
|
|
126
|
+
switch (normalized) {
|
|
127
|
+
case "left":
|
|
128
|
+
case "l":
|
|
129
|
+
return "left";
|
|
130
|
+
case "right":
|
|
131
|
+
case "r":
|
|
132
|
+
return "right";
|
|
133
|
+
case "up":
|
|
134
|
+
case "u":
|
|
135
|
+
return "up";
|
|
136
|
+
case "down":
|
|
137
|
+
case "d":
|
|
138
|
+
return "down";
|
|
139
|
+
case "in":
|
|
140
|
+
return "in";
|
|
141
|
+
case "out":
|
|
142
|
+
return "out";
|
|
143
|
+
case "horizontal":
|
|
144
|
+
case "horz":
|
|
145
|
+
case "h":
|
|
146
|
+
return "horizontal";
|
|
147
|
+
case "vertical":
|
|
148
|
+
case "vert":
|
|
149
|
+
case "v":
|
|
150
|
+
return "vertical";
|
|
151
|
+
default:
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function resolveTransitionDuration(transition, fallback = DEFAULT_TRANSITION_DURATION_SECONDS) {
|
|
156
|
+
const duration = transition?.duration;
|
|
157
|
+
return duration != null && Number.isFinite(duration) && duration > 0 ? duration : fallback;
|
|
158
|
+
}
|
|
159
|
+
function resolveBlockTransition(block, theme, blockIndex) {
|
|
160
|
+
if (block.transition) return block.transition;
|
|
161
|
+
if (blockIndex === 0) return void 0;
|
|
162
|
+
return theme.renderStyle.defaultTransition;
|
|
163
|
+
}
|
|
164
|
+
function normalizeToken(value) {
|
|
165
|
+
return value.toLowerCase().replace(/[\s_-]+/g, "");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
DEFAULT_TRANSITION_DURATION_SECONDS,
|
|
170
|
+
TRANSITION_TYPES,
|
|
171
|
+
TRANSITION_DIRECTIONS,
|
|
172
|
+
isTransitionType,
|
|
173
|
+
normalizeTransitionType,
|
|
174
|
+
normalizeTransitionDirection,
|
|
175
|
+
resolveTransitionDuration,
|
|
176
|
+
resolveBlockTransition
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=chunk-QE7TWGVT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/Transitions.ts"],"sourcesContent":["/**\n * Shared transition vocabulary for block-to-block slide changes.\n *\n * The canonical names are based on PowerPoint / PresentationML transition\n * names where possible, with a few legacy renderer aliases kept so older\n * Squisq documents continue to work.\n */\n\nexport const DEFAULT_TRANSITION_DURATION_SECONDS = 0.7;\n\nexport const TRANSITION_TYPES = [\n // Existing / common transitions\n 'cut',\n 'fade',\n 'dissolve',\n 'push',\n 'wipe',\n 'split',\n 'reveal',\n 'randomBars',\n 'shape',\n 'uncover',\n 'cover',\n 'zoom',\n 'pan',\n\n // PowerPoint subtle / exciting transitions\n 'flash',\n 'fallOver',\n 'drape',\n 'curtains',\n 'wind',\n 'prestige',\n 'fracture',\n 'crush',\n 'peelOff',\n 'pageCurl',\n 'airplane',\n 'origami',\n 'checkerboard',\n 'blinds',\n 'clock',\n 'ripple',\n 'honeycomb',\n 'glitter',\n 'vortex',\n 'shred',\n 'switch',\n 'flip',\n 'gallery',\n 'cube',\n 'doors',\n 'box',\n 'ferrisWheel',\n 'conveyor',\n 'rotate',\n 'window',\n 'orbit',\n 'flyThrough',\n 'morph',\n\n // PresentationML/Open XML precise names and legacy aliases\n 'checker',\n 'circle',\n 'comb',\n 'diamond',\n 'newsflash',\n 'plus',\n 'pull',\n 'random',\n 'randomBar',\n 'strips',\n 'wedge',\n 'wheel',\n 'prism',\n 'warp',\n 'ferris',\n 'flythrough',\n 'wheelReverse',\n 'pageCurlDouble',\n 'pageCurlSingle',\n 'slideLeft',\n 'slideRight',\n 'slideUp',\n 'slideDown',\n] as const;\n\nexport type TransitionType = (typeof TRANSITION_TYPES)[number];\n\nexport const TRANSITION_DIRECTIONS = [\n 'left',\n 'right',\n 'up',\n 'down',\n 'in',\n 'out',\n 'horizontal',\n 'vertical',\n] as const;\n\nexport type TransitionDirection = (typeof TRANSITION_DIRECTIONS)[number];\n\n/**\n * Transition between blocks.\n *\n * A block's transition is the lead-in from the previous block. The same\n * transition drives the entering block and the previous block's exit.\n */\nexport interface Transition {\n /** Transition type */\n type: TransitionType;\n /** Duration in seconds. Defaults to DEFAULT_TRANSITION_DURATION_SECONDS. */\n duration?: number;\n /** Optional direction/variant for directional transitions. */\n direction?: TransitionDirection;\n}\n\nconst TRANSITION_TYPE_SET = new Set<string>(TRANSITION_TYPES);\n\nconst TRANSITION_TYPE_ALIASES: Record<string, TransitionType> = {\n none: 'cut',\n randombars: 'randomBars',\n randombar: 'randomBar',\n // Self-referential spellings (`checkerboard`, `shape`, `uncover`) are\n // intentionally absent: an exact valid type returns early from\n // `normalizeTransitionType`, and any case variant resolves through\n // `NORMALIZED_TRANSITION_TYPES`. Only the *plural* aliases need an entry.\n checkerboards: 'checkerboard',\n shapes: 'shape',\n ferris: 'ferrisWheel',\n ferriswheel: 'ferrisWheel',\n flythrough: 'flyThrough',\n flythru: 'flyThrough',\n pagecurl: 'pageCurl',\n pagecurldouble: 'pageCurlDouble',\n pagecurlsingle: 'pageCurlSingle',\n wheelreverse: 'wheelReverse',\n slideleft: 'slideLeft',\n slideright: 'slideRight',\n slideup: 'slideUp',\n slidedown: 'slideDown',\n};\n\nconst NORMALIZED_TRANSITION_TYPES = new Map<string, TransitionType>(\n TRANSITION_TYPES.map((type) => [normalizeToken(type), type]),\n);\n\nexport function isTransitionType(value: string): value is TransitionType {\n return TRANSITION_TYPE_SET.has(value);\n}\n\nexport function normalizeTransitionType(value: string): TransitionType | null {\n const trimmed = value.trim();\n if (!trimmed) return null;\n if (isTransitionType(trimmed)) return trimmed;\n const normalized = normalizeToken(trimmed);\n return TRANSITION_TYPE_ALIASES[normalized] ?? NORMALIZED_TRANSITION_TYPES.get(normalized) ?? null;\n}\n\nexport function normalizeTransitionDirection(value: string): TransitionDirection | null {\n const normalized = normalizeToken(value);\n switch (normalized) {\n case 'left':\n case 'l':\n return 'left';\n case 'right':\n case 'r':\n return 'right';\n case 'up':\n case 'u':\n return 'up';\n case 'down':\n case 'd':\n return 'down';\n case 'in':\n return 'in';\n case 'out':\n return 'out';\n case 'horizontal':\n case 'horz':\n case 'h':\n return 'horizontal';\n case 'vertical':\n case 'vert':\n case 'v':\n return 'vertical';\n default:\n return null;\n }\n}\n\nexport function resolveTransitionDuration(\n transition: Transition | undefined,\n fallback: number = DEFAULT_TRANSITION_DURATION_SECONDS,\n): number {\n const duration = transition?.duration;\n return duration != null && Number.isFinite(duration) && duration > 0 ? duration : fallback;\n}\n\n/**\n * Resolve the effective transition for a block: the authored value wins\n * (markdown frontmatter and transform styles both write `block.transition`\n * upstream), then the theme's `renderStyle.defaultTransition`, then\n * `undefined` (the player's built-in default).\n *\n * Block 0 never gets a theme default — an entrance transition on the first\n * block would dim the opening frames of every exported video.\n *\n * The theme parameter is structural (not `Theme`) to avoid a schema import\n * cycle; pass any resolved theme.\n */\nexport function resolveBlockTransition(\n block: { transition?: Transition },\n theme: { renderStyle: { defaultTransition?: Transition } },\n blockIndex: number,\n): Transition | undefined {\n if (block.transition) return block.transition;\n if (blockIndex === 0) return undefined;\n return theme.renderStyle.defaultTransition;\n}\n\nfunction normalizeToken(value: string): string {\n return value.toLowerCase().replace(/[\\s_-]+/g, '');\n}\n"],"mappings":";AAQO,IAAM,sCAAsC;AAE5C,IAAM,mBAAmB;AAAA;AAAA,EAE9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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SHAPE_KINDS = /* @__PURE__ */ new Set([
|
|
3
|
+
"triangle",
|
|
4
|
+
"right-triangle",
|
|
5
|
+
"diamond",
|
|
6
|
+
"pentagon",
|
|
7
|
+
"hexagon",
|
|
8
|
+
"octagon",
|
|
9
|
+
"star",
|
|
10
|
+
"star4",
|
|
11
|
+
"star6",
|
|
12
|
+
"parallelogram",
|
|
13
|
+
"trapezoid",
|
|
14
|
+
"plus",
|
|
15
|
+
"chevron",
|
|
16
|
+
"arrow-right",
|
|
17
|
+
"arrow-left",
|
|
18
|
+
"arrow-up",
|
|
19
|
+
"arrow-down",
|
|
20
|
+
"double-arrow",
|
|
21
|
+
"callout",
|
|
22
|
+
"cylinder",
|
|
23
|
+
"cloud",
|
|
24
|
+
"heart",
|
|
25
|
+
"lightning"
|
|
26
|
+
]);
|
|
27
|
+
function r(n) {
|
|
28
|
+
return Math.round(n * 10) / 10;
|
|
29
|
+
}
|
|
30
|
+
function poly(points) {
|
|
31
|
+
if (points.length === 0) return "";
|
|
32
|
+
const [first, ...rest] = points;
|
|
33
|
+
const head = `M ${r(first[0])} ${r(first[1])}`;
|
|
34
|
+
const tail = rest.map(([x, y]) => `L ${r(x)} ${r(y)}`).join(" ");
|
|
35
|
+
return `${head} ${tail} Z`;
|
|
36
|
+
}
|
|
37
|
+
function regular(cx, cy, rx, ry, sides, rotation) {
|
|
38
|
+
const pts = [];
|
|
39
|
+
for (let i = 0; i < sides; i++) {
|
|
40
|
+
const a = rotation + i * 2 * Math.PI / sides;
|
|
41
|
+
pts.push([cx + rx * Math.cos(a), cy + ry * Math.sin(a)]);
|
|
42
|
+
}
|
|
43
|
+
return pts;
|
|
44
|
+
}
|
|
45
|
+
function star(cx, cy, rx, ry, spikes, innerRatio) {
|
|
46
|
+
const pts = [];
|
|
47
|
+
const rot = -Math.PI / 2;
|
|
48
|
+
for (let i = 0; i < spikes * 2; i++) {
|
|
49
|
+
const outer = i % 2 === 0;
|
|
50
|
+
const a = rot + i * Math.PI / spikes;
|
|
51
|
+
const fx = outer ? rx : rx * innerRatio;
|
|
52
|
+
const fy = outer ? ry : ry * innerRatio;
|
|
53
|
+
pts.push([cx + fx * Math.cos(a), cy + fy * Math.sin(a)]);
|
|
54
|
+
}
|
|
55
|
+
return pts;
|
|
56
|
+
}
|
|
57
|
+
function shapePath(kind, x, y, w, h) {
|
|
58
|
+
const cx = x + w / 2;
|
|
59
|
+
const cy = y + h / 2;
|
|
60
|
+
const rx = w / 2;
|
|
61
|
+
const ry = h / 2;
|
|
62
|
+
const right = x + w;
|
|
63
|
+
const bottom = y + h;
|
|
64
|
+
switch (kind) {
|
|
65
|
+
case "triangle":
|
|
66
|
+
return poly([
|
|
67
|
+
[cx, y],
|
|
68
|
+
[right, bottom],
|
|
69
|
+
[x, bottom]
|
|
70
|
+
]);
|
|
71
|
+
case "right-triangle":
|
|
72
|
+
return poly([
|
|
73
|
+
[x, y],
|
|
74
|
+
[x, bottom],
|
|
75
|
+
[right, bottom]
|
|
76
|
+
]);
|
|
77
|
+
case "diamond":
|
|
78
|
+
return poly([
|
|
79
|
+
[cx, y],
|
|
80
|
+
[right, cy],
|
|
81
|
+
[cx, bottom],
|
|
82
|
+
[x, cy]
|
|
83
|
+
]);
|
|
84
|
+
case "pentagon":
|
|
85
|
+
return poly(regular(cx, cy, rx, ry, 5, -Math.PI / 2));
|
|
86
|
+
case "hexagon": {
|
|
87
|
+
const inset = w * 0.25;
|
|
88
|
+
return poly([
|
|
89
|
+
[x + inset, y],
|
|
90
|
+
[right - inset, y],
|
|
91
|
+
[right, cy],
|
|
92
|
+
[right - inset, bottom],
|
|
93
|
+
[x + inset, bottom],
|
|
94
|
+
[x, cy]
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
case "octagon": {
|
|
98
|
+
const cut = Math.min(w, h) * 0.29;
|
|
99
|
+
return poly([
|
|
100
|
+
[x + cut, y],
|
|
101
|
+
[right - cut, y],
|
|
102
|
+
[right, y + cut],
|
|
103
|
+
[right, bottom - cut],
|
|
104
|
+
[right - cut, bottom],
|
|
105
|
+
[x + cut, bottom],
|
|
106
|
+
[x, bottom - cut],
|
|
107
|
+
[x, y + cut]
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
case "star":
|
|
111
|
+
return poly(star(cx, cy, rx, ry, 5, 0.4));
|
|
112
|
+
case "star4":
|
|
113
|
+
return poly(star(cx, cy, rx, ry, 4, 0.4));
|
|
114
|
+
case "star6":
|
|
115
|
+
return poly(star(cx, cy, rx, ry, 6, 0.5));
|
|
116
|
+
case "parallelogram": {
|
|
117
|
+
const off = w * 0.25;
|
|
118
|
+
return poly([
|
|
119
|
+
[x + off, y],
|
|
120
|
+
[right, y],
|
|
121
|
+
[right - off, bottom],
|
|
122
|
+
[x, bottom]
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
125
|
+
case "trapezoid": {
|
|
126
|
+
const off = w * 0.25;
|
|
127
|
+
return poly([
|
|
128
|
+
[x + off, y],
|
|
129
|
+
[right - off, y],
|
|
130
|
+
[right, bottom],
|
|
131
|
+
[x, bottom]
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
case "plus": {
|
|
135
|
+
const t = Math.min(w, h) / 3;
|
|
136
|
+
const lx = x + (w - t) / 2;
|
|
137
|
+
const rxp = lx + t;
|
|
138
|
+
const ty = y + (h - t) / 2;
|
|
139
|
+
const byp = ty + t;
|
|
140
|
+
return poly([
|
|
141
|
+
[lx, y],
|
|
142
|
+
[rxp, y],
|
|
143
|
+
[rxp, ty],
|
|
144
|
+
[right, ty],
|
|
145
|
+
[right, byp],
|
|
146
|
+
[rxp, byp],
|
|
147
|
+
[rxp, bottom],
|
|
148
|
+
[lx, bottom],
|
|
149
|
+
[lx, byp],
|
|
150
|
+
[x, byp],
|
|
151
|
+
[x, ty],
|
|
152
|
+
[lx, ty]
|
|
153
|
+
]);
|
|
154
|
+
}
|
|
155
|
+
case "chevron": {
|
|
156
|
+
const notch = w * 0.25;
|
|
157
|
+
return poly([
|
|
158
|
+
[x, y],
|
|
159
|
+
[right - notch, y],
|
|
160
|
+
[right, cy],
|
|
161
|
+
[right - notch, bottom],
|
|
162
|
+
[x, bottom],
|
|
163
|
+
[x + notch, cy]
|
|
164
|
+
]);
|
|
165
|
+
}
|
|
166
|
+
case "arrow-right":
|
|
167
|
+
return blockArrow(x, y, w, h, "right");
|
|
168
|
+
case "arrow-left":
|
|
169
|
+
return blockArrow(x, y, w, h, "left");
|
|
170
|
+
case "arrow-up":
|
|
171
|
+
return blockArrow(x, y, w, h, "up");
|
|
172
|
+
case "arrow-down":
|
|
173
|
+
return blockArrow(x, y, w, h, "down");
|
|
174
|
+
case "double-arrow": {
|
|
175
|
+
const head = w * 0.3;
|
|
176
|
+
const bodyT = h * 0.4;
|
|
177
|
+
const ty = cy - bodyT / 2;
|
|
178
|
+
const by = cy + bodyT / 2;
|
|
179
|
+
return poly([
|
|
180
|
+
[x, cy],
|
|
181
|
+
[x + head, y],
|
|
182
|
+
[x + head, ty],
|
|
183
|
+
[right - head, ty],
|
|
184
|
+
[right - head, y],
|
|
185
|
+
[right, cy],
|
|
186
|
+
[right - head, bottom],
|
|
187
|
+
[right - head, by],
|
|
188
|
+
[x + head, by],
|
|
189
|
+
[x + head, bottom]
|
|
190
|
+
]);
|
|
191
|
+
}
|
|
192
|
+
case "callout": {
|
|
193
|
+
const bodyH = h * 0.78;
|
|
194
|
+
const bb = y + bodyH;
|
|
195
|
+
const tailX = x + w * 0.25;
|
|
196
|
+
return `M ${r(x)} ${r(y)} L ${r(right)} ${r(y)} L ${r(right)} ${r(bb)} L ${r(tailX + w * 0.12)} ${r(bb)} L ${r(tailX)} ${r(bottom)} L ${r(tailX - w * 0.02)} ${r(bb)} L ${r(x)} ${r(bb)} Z`;
|
|
197
|
+
}
|
|
198
|
+
case "cylinder": {
|
|
199
|
+
const ell = h * 0.16;
|
|
200
|
+
return `M ${r(x)} ${r(y + ell)} A ${r(rx)} ${r(ell)} 0 0 1 ${r(right)} ${r(y + ell)} L ${r(right)} ${r(bottom - ell)} A ${r(rx)} ${r(ell)} 0 0 1 ${r(x)} ${r(bottom - ell)} Z M ${r(x)} ${r(y + ell)} A ${r(rx)} ${r(ell)} 0 0 0 ${r(right)} ${r(y + ell)}`;
|
|
201
|
+
}
|
|
202
|
+
case "cloud": {
|
|
203
|
+
const b = h * 0.5;
|
|
204
|
+
return `M ${r(x + w * 0.2)} ${r(bottom)} A ${r(w * 0.2)} ${r(b)} 0 0 1 ${r(x + w * 0.15)} ${r(cy)} A ${r(w * 0.2)} ${r(b)} 0 0 1 ${r(x + w * 0.45)} ${r(y + h * 0.2)} A ${r(w * 0.2)} ${r(b)} 0 0 1 ${r(x + w * 0.8)} ${r(y + h * 0.25)} A ${r(w * 0.18)} ${r(b)} 0 0 1 ${r(x + w * 0.85)} ${r(bottom)} Z`;
|
|
205
|
+
}
|
|
206
|
+
case "heart": {
|
|
207
|
+
const topY = y + h * 0.3;
|
|
208
|
+
return `M ${r(cx)} ${r(bottom)} C ${r(x - w * 0.1)} ${r(cy)} ${r(x)} ${r(y)} ${r(cx)} ${r(topY)} C ${r(right)} ${r(y)} ${r(right + w * 0.1)} ${r(cy)} ${r(cx)} ${r(bottom)} Z`;
|
|
209
|
+
}
|
|
210
|
+
case "lightning":
|
|
211
|
+
return poly([
|
|
212
|
+
[x + w * 0.55, y],
|
|
213
|
+
[x + w * 0.2, y + h * 0.55],
|
|
214
|
+
[x + w * 0.45, y + h * 0.55],
|
|
215
|
+
[x + w * 0.3, bottom],
|
|
216
|
+
[right, y + h * 0.4],
|
|
217
|
+
[x + w * 0.55, y + h * 0.4]
|
|
218
|
+
]);
|
|
219
|
+
default:
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function blockArrow(x, y, w, h, dir) {
|
|
224
|
+
const right = x + w;
|
|
225
|
+
const bottom = y + h;
|
|
226
|
+
const cx = x + w / 2;
|
|
227
|
+
const cy = y + h / 2;
|
|
228
|
+
if (dir === "right" || dir === "left") {
|
|
229
|
+
const head2 = w * 0.4;
|
|
230
|
+
const bodyT2 = h * 0.5;
|
|
231
|
+
const ty = cy - bodyT2 / 2;
|
|
232
|
+
const by = cy + bodyT2 / 2;
|
|
233
|
+
if (dir === "right") {
|
|
234
|
+
return poly([
|
|
235
|
+
[x, ty],
|
|
236
|
+
[right - head2, ty],
|
|
237
|
+
[right - head2, y],
|
|
238
|
+
[right, cy],
|
|
239
|
+
[right - head2, bottom],
|
|
240
|
+
[right - head2, by],
|
|
241
|
+
[x, by]
|
|
242
|
+
]);
|
|
243
|
+
}
|
|
244
|
+
return poly([
|
|
245
|
+
[right, ty],
|
|
246
|
+
[x + head2, ty],
|
|
247
|
+
[x + head2, y],
|
|
248
|
+
[x, cy],
|
|
249
|
+
[x + head2, bottom],
|
|
250
|
+
[x + head2, by],
|
|
251
|
+
[right, by]
|
|
252
|
+
]);
|
|
253
|
+
}
|
|
254
|
+
const head = h * 0.4;
|
|
255
|
+
const bodyT = w * 0.5;
|
|
256
|
+
const lx = cx - bodyT / 2;
|
|
257
|
+
const rxp = cx + bodyT / 2;
|
|
258
|
+
if (dir === "down") {
|
|
259
|
+
return poly([
|
|
260
|
+
[lx, y],
|
|
261
|
+
[rxp, y],
|
|
262
|
+
[rxp, bottom - head],
|
|
263
|
+
[right, bottom - head],
|
|
264
|
+
[cx, bottom],
|
|
265
|
+
[x, bottom - head],
|
|
266
|
+
[lx, bottom - head]
|
|
267
|
+
]);
|
|
268
|
+
}
|
|
269
|
+
return poly([
|
|
270
|
+
[lx, bottom],
|
|
271
|
+
[rxp, bottom],
|
|
272
|
+
[rxp, y + head],
|
|
273
|
+
[right, y + head],
|
|
274
|
+
[cx, y],
|
|
275
|
+
[x, y + head],
|
|
276
|
+
[lx, y + head]
|
|
277
|
+
]);
|
|
278
|
+
}
|
|
279
|
+
function markerPath(style, dir) {
|
|
280
|
+
const mirror = dir === "start";
|
|
281
|
+
const mx = (n) => mirror ? 10 - n : n;
|
|
282
|
+
const tri = (closed) => `M ${mx(0)} 0 L ${mx(10)} 5 L ${mx(0)} 10${closed ? " z" : ""}`;
|
|
283
|
+
switch (style) {
|
|
284
|
+
case "arrow":
|
|
285
|
+
return { d: tri(true), filled: true };
|
|
286
|
+
case "open":
|
|
287
|
+
return { d: tri(false), filled: false };
|
|
288
|
+
case "diamond":
|
|
289
|
+
return { d: "M 0 5 L 5 0 L 10 5 L 5 10 z", filled: true };
|
|
290
|
+
case "square":
|
|
291
|
+
return { d: "M 1 1 L 9 1 L 9 9 L 1 9 z", filled: true };
|
|
292
|
+
case "circle":
|
|
293
|
+
return { d: "M 0 5 A 5 5 0 1 0 10 5 A 5 5 0 1 0 0 5 z", filled: true };
|
|
294
|
+
case "none":
|
|
295
|
+
default:
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function clipPoint(from, to) {
|
|
300
|
+
const dx = to.cx - from.cx;
|
|
301
|
+
const dy = to.cy - from.cy;
|
|
302
|
+
if (dx === 0 && dy === 0) return { x: from.cx, y: from.cy };
|
|
303
|
+
const sx = Math.abs(dx) > 0 ? from.rx / Math.abs(dx) : Infinity;
|
|
304
|
+
const sy = Math.abs(dy) > 0 ? from.ry / Math.abs(dy) : Infinity;
|
|
305
|
+
const s = Math.min(sx, sy);
|
|
306
|
+
return { x: from.cx + dx * s, y: from.cy + dy * s };
|
|
307
|
+
}
|
|
308
|
+
function clipEndpoints(a, b) {
|
|
309
|
+
return { start: clipPoint(a, b), end: clipPoint(b, a) };
|
|
310
|
+
}
|
|
311
|
+
function connectorPath(routing, start, end) {
|
|
312
|
+
if (routing === "straight") {
|
|
313
|
+
return `M ${r(start.x)} ${r(start.y)} L ${r(end.x)} ${r(end.y)}`;
|
|
314
|
+
}
|
|
315
|
+
if (routing === "orthogonal") {
|
|
316
|
+
const midX = (start.x + end.x) / 2;
|
|
317
|
+
return `M ${r(start.x)} ${r(start.y)} L ${r(midX)} ${r(start.y)} L ${r(midX)} ${r(end.y)} L ${r(end.x)} ${r(end.y)}`;
|
|
318
|
+
}
|
|
319
|
+
const dx = Math.abs(end.x - start.x);
|
|
320
|
+
const cp = Math.max(40, dx / 2);
|
|
321
|
+
return `M ${r(start.x)} ${r(start.y)} C ${r(start.x + cp)} ${r(start.y)}, ${r(end.x - cp)} ${r(end.y)}, ${r(end.x)} ${r(end.y)}`;
|
|
322
|
+
}
|
|
323
|
+
function lineStyleDasharray(style) {
|
|
324
|
+
switch (style?.toLowerCase()) {
|
|
325
|
+
case "dashed":
|
|
326
|
+
case "dash":
|
|
327
|
+
return "8 6";
|
|
328
|
+
case "dotted":
|
|
329
|
+
case "dot":
|
|
330
|
+
return "2 6";
|
|
331
|
+
default:
|
|
332
|
+
return void 0;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export {
|
|
337
|
+
PATH_SHAPE_KINDS,
|
|
338
|
+
shapePath,
|
|
339
|
+
markerPath,
|
|
340
|
+
clipPoint,
|
|
341
|
+
clipEndpoints,
|
|
342
|
+
connectorPath,
|
|
343
|
+
lineStyleDasharray
|
|
344
|
+
};
|
|
345
|
+
//# sourceMappingURL=chunk-RUDYOTA6.js.map
|