@seatmap-fyi/map-domain 0.0.0-stage → 0.1.0-alpha.2
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/case-fold-data.d.ts +1 -0
- package/dist/case-fold-data.js +4 -0
- package/dist/catalog.d.ts +15 -0
- package/dist/catalog.js +35 -0
- package/dist/geometry/boundary.d.ts +22 -0
- package/dist/geometry/boundary.js +69 -0
- package/dist/geometry/curve-warnings.d.ts +15 -0
- package/dist/geometry/curve-warnings.js +46 -0
- package/dist/geometry/ellipse.d.ts +5 -0
- package/dist/geometry/ellipse.js +74 -0
- package/dist/geometry/geometry.d.ts +37 -0
- package/dist/geometry/geometry.js +219 -0
- package/dist/geometry/primitives.d.ts +12 -0
- package/dist/geometry/primitives.js +35 -0
- package/dist/geometry/seating-layout.d.ts +43 -0
- package/dist/geometry/seating-layout.js +132 -0
- package/dist/geometry/venue-outline.d.ts +21 -0
- package/dist/geometry/venue-outline.js +120 -0
- package/dist/identity.d.ts +5 -0
- package/dist/identity.js +61 -0
- package/dist/issues.d.ts +46 -0
- package/dist/issues.js +55 -0
- package/dist/labels.d.ts +3 -0
- package/dist/labels.js +45 -0
- package/dist/preview.d.ts +15 -0
- package/dist/preview.js +158 -0
- package/dist/reference.d.ts +29 -0
- package/dist/reference.js +51 -0
- package/dist/schema.d.ts +1629 -0
- package/dist/schema.js +560 -0
- package/dist/types.d.ts +313 -0
- package/dist/types.js +91 -0
- package/dist/validation.d.ts +27 -0
- package/dist/validation.js +267 -0
- package/package.json +88 -4
- package/src/unicode-license.txt +39 -0
- package/README.md +0 -3
package/dist/preview.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { footprint, generateGroup, project, worldMatrices, } from "./geometry/geometry.js";
|
|
2
|
+
import { emptyBounds, extend } from "./geometry/primitives.js";
|
|
3
|
+
import { DecorationKind, SeatingKind, ShapeKind } from "./types.js";
|
|
4
|
+
export const ThumbnailPolicy = {
|
|
5
|
+
MaximumSvgLength: 128000,
|
|
6
|
+
MaximumContentLength: 120000,
|
|
7
|
+
MaximumRingPoints: 64,
|
|
8
|
+
MaximumSeatGlyphs: 512,
|
|
9
|
+
Width: 480,
|
|
10
|
+
Height: 300,
|
|
11
|
+
};
|
|
12
|
+
/** Produces bounded, external-resource-free geometry for recovery and private map previews. */
|
|
13
|
+
export function projectMapPreview(document) {
|
|
14
|
+
const bounds = emptyBounds();
|
|
15
|
+
const matrices = worldMatrices(document);
|
|
16
|
+
const sections = new Map(document.sections.map((section) => [section.id, section]));
|
|
17
|
+
const foreground = parseInt(document.background.color.slice(1, 3), 16) +
|
|
18
|
+
parseInt(document.background.color.slice(3, 5), 16) +
|
|
19
|
+
parseInt(document.background.color.slice(5, 7), 16) >
|
|
20
|
+
382
|
|
21
|
+
? "#000000"
|
|
22
|
+
: "#ffffff";
|
|
23
|
+
const paint = (value, fallback = foreground) => `fill="${value?.color ?? fallback}" fill-opacity="${value?.opacity ?? 0.45}"`;
|
|
24
|
+
const number = (value) => value.toFixed(3);
|
|
25
|
+
let content = "";
|
|
26
|
+
let glyphs = 0;
|
|
27
|
+
let empty = true;
|
|
28
|
+
const append = (markup) => {
|
|
29
|
+
if (content.length + markup.length <= ThumbnailPolicy.MaximumContentLength)
|
|
30
|
+
content += markup;
|
|
31
|
+
};
|
|
32
|
+
const point = (value, matrix) => {
|
|
33
|
+
const result = matrix ? project(matrix, value) : value;
|
|
34
|
+
extend(bounds, result);
|
|
35
|
+
return `${number(result.x)},${number(result.y)}`;
|
|
36
|
+
};
|
|
37
|
+
const polygon = (value, matrix) => [value.outer, ...value.holes]
|
|
38
|
+
.map((ring) => {
|
|
39
|
+
for (const entry of ring)
|
|
40
|
+
point(entry, matrix);
|
|
41
|
+
const length = Math.min(ring.length, ThumbnailPolicy.MaximumRingPoints);
|
|
42
|
+
return `M${Array.from({ length }, (_, index) => point(ring[Math.floor((index * ring.length) / length)], matrix)).join("L")}Z`;
|
|
43
|
+
})
|
|
44
|
+
.join("");
|
|
45
|
+
const rectangle = (width, height, matrix) => polygon({
|
|
46
|
+
outer: [
|
|
47
|
+
{ x: -width / 2, y: -height / 2 },
|
|
48
|
+
{ x: width / 2, y: -height / 2 },
|
|
49
|
+
{ x: width / 2, y: height / 2 },
|
|
50
|
+
{ x: -width / 2, y: height / 2 },
|
|
51
|
+
],
|
|
52
|
+
holes: [],
|
|
53
|
+
}, matrix);
|
|
54
|
+
for (const section of document.sections) {
|
|
55
|
+
if (!section.outline)
|
|
56
|
+
continue;
|
|
57
|
+
empty = false;
|
|
58
|
+
append(`<path d="${polygon(section.outline)}" ${paint(section.style?.fill)} fill-rule="evenodd"/>`);
|
|
59
|
+
}
|
|
60
|
+
for (const group of document.seatingGroups) {
|
|
61
|
+
empty = false;
|
|
62
|
+
const matrix = matrices.get(group.id);
|
|
63
|
+
const colour = sections.get(group.sectionId ?? "")?.style?.fill?.color ?? foreground;
|
|
64
|
+
if (group.boundary)
|
|
65
|
+
append(`<path d="${polygon(group.boundary, matrix)}" fill="${colour}" fill-opacity=".3" fill-rule="evenodd"/>`);
|
|
66
|
+
if (group.kind === SeatingKind.Rectangular)
|
|
67
|
+
append(`<path d="${rectangle(group.recipe.widthM, group.recipe.depthM, matrix)}" fill="${colour}" fill-opacity=".55"/>`);
|
|
68
|
+
if (group.kind === SeatingKind.Round) {
|
|
69
|
+
const ring = Array.from({ length: 32 }, (_, index) => ({
|
|
70
|
+
x: (Math.cos((index * Math.PI) / 16) * group.recipe.diameterM) / 2,
|
|
71
|
+
y: (Math.sin((index * Math.PI) / 16) * group.recipe.diameterM) / 2,
|
|
72
|
+
}));
|
|
73
|
+
append(`<path d="${polygon({ outer: ring, holes: [] }, matrix)}" fill="${colour}" fill-opacity=".55"/>`);
|
|
74
|
+
}
|
|
75
|
+
const rows = new Map();
|
|
76
|
+
const rowCounts = new Map("rows" in group
|
|
77
|
+
? group.rows.map((row) => [row.id, row.seats.length])
|
|
78
|
+
: []);
|
|
79
|
+
let index = 0;
|
|
80
|
+
const rowIndices = new Map();
|
|
81
|
+
for (const seat of generateGroup(group)) {
|
|
82
|
+
const position = project(matrix, seat.position);
|
|
83
|
+
const radius = Math.max(seat.size.width, seat.size.height) / 2;
|
|
84
|
+
for (const corner of footprint(seat, matrix))
|
|
85
|
+
extend(bounds, corner);
|
|
86
|
+
if (seat.rowId !== null) {
|
|
87
|
+
const row = rows.get(seat.rowId) ?? [];
|
|
88
|
+
const count = rowCounts.get(seat.rowId) ?? 1;
|
|
89
|
+
const slot = rowIndices.get(seat.rowId) ?? 0;
|
|
90
|
+
rowIndices.set(seat.rowId, slot + 1);
|
|
91
|
+
if (slot % Math.max(1, Math.ceil(count / 24)) === 0 ||
|
|
92
|
+
slot === count - 1)
|
|
93
|
+
row.push(`${number(position.x)},${number(position.y)}`);
|
|
94
|
+
rows.set(seat.rowId, row);
|
|
95
|
+
}
|
|
96
|
+
if (glyphs < ThumbnailPolicy.MaximumSeatGlyphs && index % 8 === 0) {
|
|
97
|
+
append(`<circle cx="${number(position.x)}" cy="${number(position.y)}" r="${number(radius)}" fill="${colour}" fill-opacity=".8"/>`);
|
|
98
|
+
glyphs++;
|
|
99
|
+
}
|
|
100
|
+
index++;
|
|
101
|
+
}
|
|
102
|
+
if (!group.boundary) {
|
|
103
|
+
for (const points of rows.values())
|
|
104
|
+
append(`<polyline points="${points.join(" ")}" fill="none" stroke="${colour}" stroke-width="${number(group.seatSizeM.height)}" stroke-opacity=".6" stroke-linecap="round"/>`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
for (const area of document.areas) {
|
|
108
|
+
empty = false;
|
|
109
|
+
const matrix = matrices.get(area.id);
|
|
110
|
+
const path = area.shape.kind === ShapeKind.Polygon
|
|
111
|
+
? polygon(area.shape.boundary, matrix)
|
|
112
|
+
: rectangle(area.shape.widthM, area.shape.heightM, matrix);
|
|
113
|
+
append(`<path d="${path}" ${paint(sections.get(area.sectionId ?? "")?.style?.fill)} fill-rule="evenodd"/>`);
|
|
114
|
+
}
|
|
115
|
+
for (const art of [...document.decorations].sort((left, right) => left.zIndex - right.zIndex)) {
|
|
116
|
+
empty = false;
|
|
117
|
+
const matrix = matrices.get(art.id);
|
|
118
|
+
let path;
|
|
119
|
+
if (art.kind === DecorationKind.Polygon)
|
|
120
|
+
path = polygon(art.boundary, matrix);
|
|
121
|
+
else if (art.kind === DecorationKind.Line)
|
|
122
|
+
path = `M${art.pointsM.map((value) => point(value, matrix)).join("L")}`;
|
|
123
|
+
else if (art.kind === DecorationKind.Circle)
|
|
124
|
+
path = polygon({
|
|
125
|
+
outer: Array.from({ length: 32 }, (_, index) => ({
|
|
126
|
+
x: Math.cos((index * Math.PI) / 16) * art.radiusM,
|
|
127
|
+
y: Math.sin((index * Math.PI) / 16) * art.radiusM,
|
|
128
|
+
})),
|
|
129
|
+
holes: [],
|
|
130
|
+
}, matrix);
|
|
131
|
+
else if (art.kind === DecorationKind.Text)
|
|
132
|
+
path = rectangle(Math.max(art.fontSizeM, Array.from(art.text).length * art.fontSizeM * 0.65), art.fontSizeM, matrix);
|
|
133
|
+
else
|
|
134
|
+
path = rectangle(art.sizeM.width, art.sizeM.height, matrix);
|
|
135
|
+
const outline = art.kind === DecorationKind.Image ||
|
|
136
|
+
art.kind === DecorationKind.Line ||
|
|
137
|
+
art.kind === DecorationKind.Text;
|
|
138
|
+
append(`<path d="${path}" ${outline ? 'fill="none"' : paint(art.style?.fill)} stroke="${art.style?.stroke?.color ?? foreground}" stroke-opacity="${art.style?.stroke?.opacity ?? 0.5}" stroke-width="${art.style?.strokeWidthM ?? 0.08}" fill-rule="evenodd"/>`);
|
|
139
|
+
}
|
|
140
|
+
const width = Number.isFinite(bounds.minX)
|
|
141
|
+
? Math.max(1, bounds.maxX - bounds.minX)
|
|
142
|
+
: 1;
|
|
143
|
+
const height = Number.isFinite(bounds.minY)
|
|
144
|
+
? Math.max(1, bounds.maxY - bounds.minY)
|
|
145
|
+
: 1;
|
|
146
|
+
const padding = Math.max(width, height) * 0.08;
|
|
147
|
+
const x = Number.isFinite(bounds.minX) ? bounds.minX - padding : -padding;
|
|
148
|
+
const y = Number.isFinite(bounds.minY) ? bounds.minY - padding : -padding;
|
|
149
|
+
const viewWidth = width + padding * 2;
|
|
150
|
+
const viewHeight = height + padding * 2;
|
|
151
|
+
return {
|
|
152
|
+
empty,
|
|
153
|
+
svg: `<svg xmlns="http://www.w3.org/2000/svg" width="480" height="300" viewBox="${x} ${y} ${viewWidth} ${viewHeight}"><rect x="${x}" y="${y}" width="${viewWidth}" height="${viewHeight}" ${paint(document.background)}/>${content}</svg>`,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export function thumbnailSvg(document) {
|
|
157
|
+
return projectMapPreview(document).svg;
|
|
158
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare enum PreviewSeatState {
|
|
3
|
+
Unverified = "unverified",
|
|
4
|
+
Available = "available",
|
|
5
|
+
Unavailable = "unavailable"
|
|
6
|
+
}
|
|
7
|
+
export declare enum PreviewOffer {
|
|
8
|
+
Standard = "standard",
|
|
9
|
+
Resale = "resale",
|
|
10
|
+
VIP = "vip"
|
|
11
|
+
}
|
|
12
|
+
export declare const referencePresentationSchema: z.ZodObject<{
|
|
13
|
+
version: z.ZodLiteral<1>;
|
|
14
|
+
mapId: z.ZodString;
|
|
15
|
+
source: z.ZodString;
|
|
16
|
+
capturedAt: z.ZodISODateTime;
|
|
17
|
+
standingSectionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
+
overviewMemberships: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
19
|
+
sectionId: z.ZodString;
|
|
20
|
+
inventorySectionIds: z.ZodArray<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>>>;
|
|
22
|
+
seats: z.ZodArray<z.ZodObject<{
|
|
23
|
+
id: z.ZodString;
|
|
24
|
+
state: z.ZodEnum<typeof PreviewSeatState>;
|
|
25
|
+
offer: z.ZodEnum<typeof PreviewOffer>;
|
|
26
|
+
matchesFilter: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
}, z.core.$strict>>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
export type ReferencePresentation = z.infer<typeof referencePresentationSchema>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DocumentLimits } from "./types.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { uuidSchema } from "./schema.js";
|
|
4
|
+
// Reference presentation is a dated observation, never authoritative inventory.
|
|
5
|
+
export var PreviewSeatState;
|
|
6
|
+
(function (PreviewSeatState) {
|
|
7
|
+
PreviewSeatState["Unverified"] = "unverified";
|
|
8
|
+
PreviewSeatState["Available"] = "available";
|
|
9
|
+
PreviewSeatState["Unavailable"] = "unavailable";
|
|
10
|
+
})(PreviewSeatState || (PreviewSeatState = {}));
|
|
11
|
+
export var PreviewOffer;
|
|
12
|
+
(function (PreviewOffer) {
|
|
13
|
+
PreviewOffer["Standard"] = "standard";
|
|
14
|
+
PreviewOffer["Resale"] = "resale";
|
|
15
|
+
PreviewOffer["VIP"] = "vip";
|
|
16
|
+
})(PreviewOffer || (PreviewOffer = {}));
|
|
17
|
+
export const referencePresentationSchema = z
|
|
18
|
+
.strictObject({
|
|
19
|
+
version: z.literal(1),
|
|
20
|
+
mapId: uuidSchema,
|
|
21
|
+
source: z.string().trim().min(1).max(200),
|
|
22
|
+
capturedAt: z.iso.datetime(),
|
|
23
|
+
standingSectionIds: z.array(uuidSchema).max(1024).optional(),
|
|
24
|
+
overviewMemberships: z
|
|
25
|
+
.array(z.strictObject({
|
|
26
|
+
sectionId: uuidSchema,
|
|
27
|
+
inventorySectionIds: z.array(uuidSchema).max(1024),
|
|
28
|
+
}))
|
|
29
|
+
.max(1024)
|
|
30
|
+
.optional(),
|
|
31
|
+
seats: z
|
|
32
|
+
.array(z.strictObject({
|
|
33
|
+
id: uuidSchema,
|
|
34
|
+
state: z.enum(PreviewSeatState),
|
|
35
|
+
offer: z.enum(PreviewOffer),
|
|
36
|
+
matchesFilter: z.boolean().optional(),
|
|
37
|
+
}))
|
|
38
|
+
.max(DocumentLimits.PhysicalSeats),
|
|
39
|
+
})
|
|
40
|
+
.superRefine((value, context) => {
|
|
41
|
+
const ids = new Set();
|
|
42
|
+
for (const [index, seat] of value.seats.entries()) {
|
|
43
|
+
if (ids.has(seat.id))
|
|
44
|
+
context.addIssue({
|
|
45
|
+
code: "custom",
|
|
46
|
+
path: ["seats", index, "id"],
|
|
47
|
+
message: "Duplicate presentation seat ID.",
|
|
48
|
+
});
|
|
49
|
+
ids.add(seat.id);
|
|
50
|
+
}
|
|
51
|
+
});
|