@seatmap-fyi/map-domain 0.1.0-alpha.48 → 0.1.0-alpha.51
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/arc-fan-rebuild.d.ts +9 -5
- package/dist/arc-fan-rebuild.js +78 -14
- package/dist/arc-fan-section-layout.d.ts +11 -0
- package/dist/arc-fan-section-layout.js +54 -0
- package/dist/arc-fan.interface.d.ts +18 -1
- package/dist/categories.d.ts +11 -2
- package/dist/categories.js +42 -10
- package/dist/editor-state.d.ts +2 -0
- package/dist/editor-state.js +3 -0
- package/dist/floors.d.ts +1 -1
- package/dist/floors.js +4 -9
- package/dist/geometry/decoration-bounds.d.ts +6 -1
- package/dist/geometry/decoration-bounds.js +23 -1
- package/dist/geometry/geometry.d.ts +4 -0
- package/dist/geometry/geometry.js +37 -10
- package/dist/geometry/inventory-outline.d.ts +8 -0
- package/dist/geometry/inventory-outline.js +46 -0
- package/dist/geometry/seat-shape.js +4 -4
- package/dist/geometry/seating-layout.d.ts +1 -0
- package/dist/geometry/seating-layout.js +7 -0
- package/dist/geometry/three-point-arc.d.ts +10 -0
- package/dist/geometry/three-point-arc.js +32 -0
- package/dist/geometry/venue-outline.js +44 -9
- package/dist/issues.d.ts +2 -0
- package/dist/issues.js +2 -0
- package/dist/layers.js +20 -4
- package/dist/media.d.ts +16 -2
- package/dist/media.js +19 -0
- package/dist/physical-document.interface.d.ts +77 -7
- package/dist/physical-document.interface.js +19 -0
- package/dist/schema.d.ts +174 -5
- package/dist/schema.js +82 -16
- package/dist/section-growth.d.ts +3 -3
- package/dist/section-growth.interface.d.ts +10 -2
- package/dist/section-growth.js +83 -36
- package/dist/section-layout.d.ts +9 -3
- package/dist/section-layout.js +2 -0
- package/dist/table-layout.d.ts +2 -1
- package/dist/table-layout.js +21 -13
- package/dist/validation.d.ts +1 -0
- package/dist/validation.js +13 -16
- package/package.json +9 -1
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { ArcFanRebuildIssue, type ArcFanInput, type ArcFanPart, type ArcFanPlan, type ArcFanRows, type ArcFanRebuildSource, type ArcFanRebuildPlacement } from "./arc-fan.interface.js";
|
|
2
|
-
import type { PhysicalDocumentV1, RowSlot } from "./physical-document.interface.js";
|
|
1
|
+
import { ArcFanRebuildIssue, type ArcFanInput, type ArcFanPart, type ArcFanPlan, type ArcFanRows, type ArcFanRebuildSource, type ArcFanRebuildSettings, type ArcFanRebuildPlacement } from "./arc-fan.interface.js";
|
|
2
|
+
import type { PhysicalDocumentV1, PointM, RowSlot, UUID } from "./physical-document.interface.js";
|
|
3
3
|
export declare const arcFanRebuildMessages: Record<ArcFanRebuildIssue, string>;
|
|
4
4
|
export declare const arcFanGeometryEntryMessage = "This fan has manually edited geometry. Edit its rows individually to keep those changes.";
|
|
5
5
|
export declare function arcFanParts(plan: ArcFanPlan): ArcFanPart[];
|
|
6
|
-
/**
|
|
7
|
-
export declare function
|
|
6
|
+
/** Capture the phase of the source grid relative to the bank, so a copy can move the whole outline. */
|
|
7
|
+
export declare function arcFanOutlineGridOrigin(center: PointM): PointM;
|
|
8
|
+
/** A generated section and its rows share provenance; authored boundary changes stop regeneration. */
|
|
9
|
+
export declare function arcFanRebuildSource(document: PhysicalDocumentV1, group: ArcFanRows): ArcFanRebuildSource | null;
|
|
8
10
|
export declare function arcFanSequenceCustomized(row: RowSlot, part: ArcFanPart): boolean;
|
|
9
|
-
|
|
11
|
+
/** The first physical row owns the generator's category default; seat overrides remain individual. */
|
|
12
|
+
export declare function arcFanRebuildCategory(group: ArcFanRows): UUID | null;
|
|
13
|
+
export declare function reviewArcFanRebuild(document: PhysicalDocumentV1, group: ArcFanRows, plan: ArcFanPlan, { categoryId, positionM, editorState }: ArcFanRebuildSettings): ArcFanRebuildIssue | null;
|
|
10
14
|
/** Show the same authored fan in world coordinates, including inherited rotation and reflection. */
|
|
11
15
|
export declare function arcFanWorldInput(document: PhysicalDocumentV1, group: ArcFanRows): ArcFanInput;
|
|
12
16
|
/** Convert the form's world draft back into the bank's single local geometry owner. */
|
package/dist/arc-fan-rebuild.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { planArcFan } from "./arc-fan.js";
|
|
2
|
-
import { ArcFanRebuildIssue, } from "./arc-fan.interface.js";
|
|
1
|
+
import { arcFanSeats, planArcFan } from "./arc-fan.js";
|
|
2
|
+
import { ArcFanRebuildIssue, ArcFanSectionOrigin, } from "./arc-fan.interface.js";
|
|
3
3
|
import { NumberingScheme, LabelDirection, RowEnds } from "./physical-document.interface.js";
|
|
4
4
|
import { worldMatrices, inverse, project, normalizeAngle } from "./geometry/geometry.js";
|
|
5
5
|
import { resolveRowLayout, rowPlacementOffset } from "./geometry/seating-layout.js";
|
|
6
|
+
import { matchesPaddedSectionOutline } from "./geometry/inventory-outline.js";
|
|
7
|
+
import { LayoutUnitM } from "./geometry/units.js";
|
|
6
8
|
import { seatHasOwnSettings } from "./selling.js";
|
|
9
|
+
import { mapEditorPolicy } from "./editor-state.js";
|
|
7
10
|
const coordinateToleranceM = 1e-7;
|
|
8
11
|
const angleToleranceDeg = 1e-7;
|
|
12
|
+
const outlineSeatGridM = LayoutUnitM / 1_000_000;
|
|
13
|
+
const outlineRoundoffM = outlineSeatGridM / 1_000;
|
|
9
14
|
const degrees = 180 / Math.PI;
|
|
15
|
+
const rowSources = new WeakMap();
|
|
10
16
|
const sources = new WeakMap();
|
|
11
17
|
const generatedRowFields = new Set([
|
|
12
18
|
"zIndex",
|
|
@@ -59,9 +65,9 @@ function sameLayout(a, b) {
|
|
|
59
65
|
sameAngle(a.seatRotationOffsetDeg ?? 0, b.seatRotationOffsetDeg ?? 0));
|
|
60
66
|
}
|
|
61
67
|
/** Compare current physical rows with generation provenance; seat customizations remain independent. */
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
return
|
|
68
|
+
function rowSource(group) {
|
|
69
|
+
if (rowSources.has(group))
|
|
70
|
+
return rowSources.get(group);
|
|
65
71
|
const generation = group.arcFan;
|
|
66
72
|
const plan = generation ? planArcFan({ ...generation.recipe, center: { x: 0, y: 0 } }) : null;
|
|
67
73
|
let source = null;
|
|
@@ -82,7 +88,53 @@ export function arcFanRebuildSource(group) {
|
|
|
82
88
|
source = { parts, members: generation.members, rows: group.rows };
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
|
-
|
|
91
|
+
rowSources.set(group, source);
|
|
92
|
+
return source;
|
|
93
|
+
}
|
|
94
|
+
function snapOutlineCoordinate(coordinate, gridOrigin = 0) {
|
|
95
|
+
return gridOrigin + Math.round((coordinate - gridOrigin) / outlineSeatGridM) * outlineSeatGridM;
|
|
96
|
+
}
|
|
97
|
+
/** Capture the phase of the source grid relative to the bank, so a copy can move the whole outline. */
|
|
98
|
+
export function arcFanOutlineGridOrigin(center) {
|
|
99
|
+
return {
|
|
100
|
+
x: snapOutlineCoordinate(center.x) - center.x,
|
|
101
|
+
y: snapOutlineCoordinate(center.y) - center.y,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** A generated section and its rows share provenance; authored boundary changes stop regeneration. */
|
|
105
|
+
export function arcFanRebuildSource(document, group) {
|
|
106
|
+
let cached = sources.get(document);
|
|
107
|
+
if (!cached) {
|
|
108
|
+
cached = new WeakMap();
|
|
109
|
+
sources.set(document, cached);
|
|
110
|
+
}
|
|
111
|
+
if (cached.has(group))
|
|
112
|
+
return cached.get(group);
|
|
113
|
+
let source = rowSource(group);
|
|
114
|
+
const generation = group.arcFan;
|
|
115
|
+
if (source && generation?.sectionOrigin === ArcFanSectionOrigin.Generated && generation.sectionId) {
|
|
116
|
+
const section = document.sections.find((section) => section.id === generation.sectionId);
|
|
117
|
+
const gridOrigin = generation.sectionOutlineGridOriginM;
|
|
118
|
+
if (gridOrigin) {
|
|
119
|
+
const plan = planArcFan({ ...generation.recipe, center: { x: 0, y: 0 } });
|
|
120
|
+
const seats = arcFanSeats(plan).map(({ x, y }) => ({
|
|
121
|
+
x: snapOutlineCoordinate(x, gridOrigin.x),
|
|
122
|
+
y: snapOutlineCoordinate(y, gridOrigin.y),
|
|
123
|
+
}));
|
|
124
|
+
const matrix = worldMatrices(document).get(group.id);
|
|
125
|
+
if (!matchesPaddedSectionOutline(seats, section?.outline, {
|
|
126
|
+
toWorld: (point) => project(matrix, point),
|
|
127
|
+
toleranceM: outlineRoundoffM,
|
|
128
|
+
}))
|
|
129
|
+
source = null;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const plan = planArcFan(arcFanWorldInput(document, group));
|
|
133
|
+
if (!matchesPaddedSectionOutline(arcFanSeats(plan), section?.outline))
|
|
134
|
+
source = null;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
cached.set(group, source);
|
|
86
138
|
return source;
|
|
87
139
|
}
|
|
88
140
|
export function arcFanSequenceCustomized(row, part) {
|
|
@@ -106,24 +158,35 @@ function rowCustomized(source, index) {
|
|
|
106
158
|
function retainsSeatLayout(before, after) {
|
|
107
159
|
return sameLayout(before.layout, after.layout);
|
|
108
160
|
}
|
|
109
|
-
|
|
110
|
-
|
|
161
|
+
/** The first physical row owns the generator's category default; seat overrides remain individual. */
|
|
162
|
+
export function arcFanRebuildCategory(group) {
|
|
163
|
+
const category = group.rows[0]?.categoryId;
|
|
164
|
+
return category === undefined ? (group.categoryId ?? null) : category;
|
|
165
|
+
}
|
|
166
|
+
export function reviewArcFanRebuild(document, group, plan, { categoryId, positionM, editorState }) {
|
|
167
|
+
const source = arcFanRebuildSource(document, group);
|
|
111
168
|
if (!source)
|
|
112
169
|
return ArcFanRebuildIssue.Geometry;
|
|
170
|
+
const categoryChanged = categoryId !== arcFanRebuildCategory(group);
|
|
171
|
+
const moved = positionM.x !== group.transform.positionM.x || positionM.y !== group.transform.positionM.y;
|
|
172
|
+
const policy = mapEditorPolicy(document, editorState);
|
|
113
173
|
const nextParts = arcFanParts(plan);
|
|
114
174
|
const next = new Map(nextParts.map((part) => [part.rowIndex + ":" + part.partIndex, part]));
|
|
115
175
|
for (let index = 0; index < source.rows.length; index++) {
|
|
116
176
|
const row = source.rows[index], part = source.parts[index];
|
|
117
177
|
const after = next.get(part.rowIndex + ":" + part.partIndex);
|
|
118
|
-
const
|
|
178
|
+
const locked = policy.lockOwner(row.id);
|
|
179
|
+
const custom = locked || rowCustomized(source, index) || row.seats.some(seatHasOwnSettings);
|
|
119
180
|
if (!after) {
|
|
120
181
|
if (custom)
|
|
121
182
|
return ArcFanRebuildIssue.RemoveCustomizedRow;
|
|
122
183
|
continue;
|
|
123
184
|
}
|
|
185
|
+
if (locked && (moved || after.seats !== row.seats.length))
|
|
186
|
+
return ArcFanRebuildIssue.CustomizedShape;
|
|
124
187
|
if (row.seats.slice(after.seats).some(seatHasOwnSettings))
|
|
125
188
|
return ArcFanRebuildIssue.CustomizedShape;
|
|
126
|
-
if (custom && !retainsSeatLayout(part, after))
|
|
189
|
+
if (custom && (categoryChanged || !retainsSeatLayout(part, after)))
|
|
127
190
|
return ArcFanRebuildIssue.CustomizedShape;
|
|
128
191
|
}
|
|
129
192
|
return null;
|
|
@@ -147,6 +210,10 @@ export function arcFanRebuildPlacement(document, group, input) {
|
|
|
147
210
|
const matrices = worldMatrices(document), matrix = matrices.get(group.id);
|
|
148
211
|
const direction = matrix.a * matrix.d - matrix.b * matrix.c < 0 ? -1 : 1;
|
|
149
212
|
const angle = Math.atan2(matrix.c, matrix.d) * degrees;
|
|
213
|
+
let positionM = group.transform.positionM;
|
|
214
|
+
if (input.center.x !== matrix.tx || input.center.y !== matrix.ty) {
|
|
215
|
+
positionM = group.parentId ? project(inverse(matrices.get(group.parentId)), input.center) : input.center;
|
|
216
|
+
}
|
|
150
217
|
return {
|
|
151
218
|
input: {
|
|
152
219
|
...input,
|
|
@@ -155,9 +222,6 @@ export function arcFanRebuildPlacement(document, group, input) {
|
|
|
155
222
|
endAngleDeg: direction * (input.endAngleDeg - angle),
|
|
156
223
|
skewDeg: direction * input.skewDeg,
|
|
157
224
|
},
|
|
158
|
-
transform: {
|
|
159
|
-
...group.transform,
|
|
160
|
-
positionM: group.parentId ? project(inverse(matrices.get(group.parentId)), input.center) : input.center,
|
|
161
|
-
},
|
|
225
|
+
transform: { ...group.transform, positionM },
|
|
162
226
|
};
|
|
163
227
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { MapEditorState } from "./editor-state.js";
|
|
3
|
+
import { type ArcFanSectionLayout } from "./arc-fan.interface.js";
|
|
4
|
+
import type { PhysicalDocumentV1, UUID } from "./physical-document.interface.js";
|
|
5
|
+
export declare const arcFanSectionRebuildInputSchema: z.ZodObject<{
|
|
6
|
+
arcFanGroupId: z.ZodString;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
/** Prove the generated section transition independently of the submitted outline or protection metadata. */
|
|
9
|
+
export declare function rebuiltArcFanSection(before: PhysicalDocumentV1, after: PhysicalDocumentV1, groupId: UUID, editorState: MapEditorState): ArcFanSectionLayout | null;
|
|
10
|
+
/** Normalize only the proved generated section before checking all remaining position locks. */
|
|
11
|
+
export declare function projectArcFanSectionLayout(document: PhysicalDocumentV1, layout: ArcFanSectionLayout): PhysicalDocumentV1;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { uuidSchema } from "./schema.js";
|
|
3
|
+
import { documentCatalog } from "./catalog.js";
|
|
4
|
+
import { arcFanSeats, planArcFan } from "./arc-fan.js";
|
|
5
|
+
import { arcFanRebuildCategory, arcFanRebuildSource, arcFanWorldInput, reviewArcFanRebuild, } from "./arc-fan-rebuild.js";
|
|
6
|
+
import { ArcFanSectionOrigin } from "./arc-fan.interface.js";
|
|
7
|
+
import { paddedSectionOutline } from "./geometry/inventory-outline.js";
|
|
8
|
+
export const arcFanSectionRebuildInputSchema = z.strictObject({ arcFanGroupId: uuidSchema });
|
|
9
|
+
/** Prove the generated section transition independently of the submitted outline or protection metadata. */
|
|
10
|
+
export function rebuiltArcFanSection(before, after, groupId, editorState) {
|
|
11
|
+
const previous = documentCatalog(before).groups.get(groupId);
|
|
12
|
+
const next = documentCatalog(after).groups.get(groupId);
|
|
13
|
+
if (!previous || !("rows" in previous) || !next || !("rows" in next))
|
|
14
|
+
return null;
|
|
15
|
+
const original = previous.arcFan;
|
|
16
|
+
const generation = next.arcFan;
|
|
17
|
+
if (original?.sectionOrigin !== ArcFanSectionOrigin.Generated ||
|
|
18
|
+
!original.sectionId ||
|
|
19
|
+
generation?.sectionOrigin !== ArcFanSectionOrigin.Generated ||
|
|
20
|
+
!arcFanRebuildSource(before, previous))
|
|
21
|
+
return null;
|
|
22
|
+
const index = before.sections.findIndex((section) => section.id === original.sectionId);
|
|
23
|
+
const section = before.sections[index];
|
|
24
|
+
const local = planArcFan({ ...generation.recipe, center: { x: 0, y: 0 } });
|
|
25
|
+
if (!local ||
|
|
26
|
+
reviewArcFanRebuild(before, previous, local, {
|
|
27
|
+
categoryId: arcFanRebuildCategory(next),
|
|
28
|
+
positionM: next.transform.positionM,
|
|
29
|
+
editorState,
|
|
30
|
+
}) ||
|
|
31
|
+
!arcFanRebuildSource(after, next))
|
|
32
|
+
return null;
|
|
33
|
+
const outline = paddedSectionOutline(arcFanSeats(planArcFan(arcFanWorldInput(after, next))));
|
|
34
|
+
if (outline) {
|
|
35
|
+
const verifiedOutline = after.sections.find((item) => item.id === section.id)?.outline;
|
|
36
|
+
if (generation.sectionId !== section.id || !verifiedOutline)
|
|
37
|
+
return null;
|
|
38
|
+
// Rebuild provenance already proved this outline. Retain its exact coordinates across JS runtimes.
|
|
39
|
+
return { before: section, after: { ...section, outline: verifiedOutline }, index };
|
|
40
|
+
}
|
|
41
|
+
if (generation.sectionId !== null ||
|
|
42
|
+
after.sections.some((item) => item.id === section.id) ||
|
|
43
|
+
next.sectionId === section.id ||
|
|
44
|
+
next.rows.some((row) => row.fillOrigin?.sectionId === section.id))
|
|
45
|
+
return null;
|
|
46
|
+
return { before: section, after: null, index };
|
|
47
|
+
}
|
|
48
|
+
/** Normalize only the proved generated section before checking all remaining position locks. */
|
|
49
|
+
export function projectArcFanSectionLayout(document, layout) {
|
|
50
|
+
const sections = document.sections.filter((section) => section.id !== layout.before.id);
|
|
51
|
+
if (layout.after)
|
|
52
|
+
sections.splice(layout.index, 0, layout.after);
|
|
53
|
+
return { ...document, sections };
|
|
54
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { MapEditorState } from "./editor-state.js";
|
|
3
|
+
import type { arcFanSectionRebuildInputSchema } from "./arc-fan-section-layout.js";
|
|
4
|
+
import type { PointM, UUID, RowLayout, RowSlot, StraightRows, CurvedRows, LabelSequence, RowEnds, Transform, Section } from "./physical-document.interface.js";
|
|
2
5
|
import type { SectionFillPlan } from "./section-fill.interface.js";
|
|
3
6
|
export declare enum ArcFanFit {
|
|
4
7
|
Spacing = "spacing",
|
|
@@ -32,6 +35,11 @@ export type ArcFanMember = {
|
|
|
32
35
|
labelOverride?: string;
|
|
33
36
|
};
|
|
34
37
|
export type ArcFanRows = StraightRows | CurvedRows;
|
|
38
|
+
export type ArcFanRebuildSettings = {
|
|
39
|
+
categoryId: UUID | null;
|
|
40
|
+
positionM: PointM;
|
|
41
|
+
editorState: MapEditorState;
|
|
42
|
+
};
|
|
35
43
|
export type ArcFanPart = {
|
|
36
44
|
rowIndex: number;
|
|
37
45
|
partIndex: number;
|
|
@@ -72,6 +80,8 @@ export type ArcFanGeneration = {
|
|
|
72
80
|
recipe: ArcFanRecipe;
|
|
73
81
|
sectionId: UUID | null;
|
|
74
82
|
sectionOrigin: ArcFanSectionOrigin;
|
|
83
|
+
/** Local origin of the layout-microunit grid used to generate an imported section outline. */
|
|
84
|
+
sectionOutlineGridOriginM?: PointM;
|
|
75
85
|
members: ArcFanMember[];
|
|
76
86
|
};
|
|
77
87
|
export type ArcFanPlan = Pick<SectionFillPlan, "rows" | "recipe"> & {
|
|
@@ -81,3 +91,10 @@ export type ArcFanPlan = Pick<SectionFillPlan, "rows" | "recipe"> & {
|
|
|
81
91
|
maximumPitchM: number;
|
|
82
92
|
aisles: number;
|
|
83
93
|
};
|
|
94
|
+
export type ArcFanSectionRebuildInput = z.infer<typeof arcFanSectionRebuildInputSchema>;
|
|
95
|
+
/** Canonically derived section geometry, including removal when no polygon can be outlined. */
|
|
96
|
+
export interface ArcFanSectionLayout {
|
|
97
|
+
before: Section;
|
|
98
|
+
after: Section | null;
|
|
99
|
+
index: number;
|
|
100
|
+
}
|
package/dist/categories.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MapCategory, PhysicalDocumentV1, RowSlot, SeatingGroup, SeatSlot, UUID } from "./physical-document.interface.js";
|
|
2
|
-
import { SeatShape } from "./physical-document.interface.js";
|
|
1
|
+
import type { InventoryArea, MapCategory, PhysicalDocumentV1, RowSlot, SeatingGroup, SeatSlot, UUID } from "./physical-document.interface.js";
|
|
2
|
+
import { SeatShape, SeatingKind } from "./physical-document.interface.js";
|
|
3
3
|
import { type DomainIssue } from "./issues.js";
|
|
4
4
|
export declare function categoryCatalog(document: PhysicalDocumentV1): ReadonlyMap<UUID, MapCategory>;
|
|
5
5
|
/** Absence inherits; explicit null records an unassigned child. */
|
|
@@ -13,7 +13,16 @@ export declare function missingCategoryLabel(places: number): string;
|
|
|
13
13
|
export declare function categoryIssues(document: PhysicalDocumentV1): readonly DomainIssue[];
|
|
14
14
|
/** Fragment paste reuses catalogue identity; whole-map copy remaps it with the map. */
|
|
15
15
|
export declare function remapGroupCategories(group: SeatingGroup, ids: ReadonlyMap<UUID, UUID>): SeatingGroup;
|
|
16
|
+
export declare enum InventoryKind {
|
|
17
|
+
Rows = "rows",
|
|
18
|
+
Tables = "tables",
|
|
19
|
+
Standing = "standing",
|
|
20
|
+
Booths = "booths"
|
|
21
|
+
}
|
|
22
|
+
export declare function groupInventoryKind(kind: SeatingKind): InventoryKind;
|
|
23
|
+
export declare function areaInventoryKind(kind: InventoryArea["kind"]): InventoryKind;
|
|
16
24
|
export declare function categoryUsage(document: PhysicalDocumentV1): ReadonlyMap<UUID, number>;
|
|
25
|
+
export declare function categoryInventoryKinds(document: PhysicalDocumentV1, categoryId: UUID): ReadonlySet<InventoryKind>;
|
|
17
26
|
export declare function ticketOptionNameKey(name: string): string;
|
|
18
27
|
export type CategoryPricing = {
|
|
19
28
|
onSale: boolean;
|
package/dist/categories.js
CHANGED
|
@@ -125,6 +125,10 @@ export function categoryIssues(document) {
|
|
|
125
125
|
}
|
|
126
126
|
const uses = categoryUsage(document);
|
|
127
127
|
for (const category of document.categories ?? []) {
|
|
128
|
+
if (categoryInventoryKinds(document, category.id).size > 1) {
|
|
129
|
+
const message = `Category “${category.name}” spans incompatible inventory types`;
|
|
130
|
+
findings.push(issue(IssueCode.MixedCategoryInventory, message, [category.id]));
|
|
131
|
+
}
|
|
128
132
|
if (!uses.get(category.id) || !categoryPricing(category).missing)
|
|
129
133
|
continue;
|
|
130
134
|
const message = `Category "${category.name}" has no default price. Each event sets its price before it goes on sale`;
|
|
@@ -164,34 +168,62 @@ export function remapGroupCategories(group, ids) {
|
|
|
164
168
|
},
|
|
165
169
|
};
|
|
166
170
|
}
|
|
171
|
+
export var InventoryKind;
|
|
172
|
+
(function (InventoryKind) {
|
|
173
|
+
InventoryKind["Rows"] = "rows";
|
|
174
|
+
InventoryKind["Tables"] = "tables";
|
|
175
|
+
InventoryKind["Standing"] = "standing";
|
|
176
|
+
InventoryKind["Booths"] = "booths";
|
|
177
|
+
})(InventoryKind || (InventoryKind = {}));
|
|
178
|
+
export function groupInventoryKind(kind) {
|
|
179
|
+
return kind === SeatingKind.Straight || kind === SeatingKind.Curved ? InventoryKind.Rows : InventoryKind.Tables;
|
|
180
|
+
}
|
|
181
|
+
export function areaInventoryKind(kind) {
|
|
182
|
+
return kind === AreaKind.Booth ? InventoryKind.Booths : InventoryKind.Standing;
|
|
183
|
+
}
|
|
167
184
|
const usage = new WeakMap();
|
|
168
|
-
|
|
185
|
+
const noInventoryKinds = new Set();
|
|
186
|
+
function categoryInventory(document) {
|
|
169
187
|
const cached = usage.get(document);
|
|
170
188
|
if (cached)
|
|
171
189
|
return cached;
|
|
172
190
|
const counts = new Map();
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
191
|
+
const kinds = new Map();
|
|
192
|
+
const count = (id, kind, quantity) => {
|
|
193
|
+
if (!id)
|
|
194
|
+
return;
|
|
195
|
+
counts.set(id, (counts.get(id) ?? 0) + quantity);
|
|
196
|
+
const used = kinds.get(id) ?? new Set();
|
|
197
|
+
used.add(kind);
|
|
198
|
+
kinds.set(id, used);
|
|
176
199
|
};
|
|
177
200
|
for (const group of document.seatingGroups) {
|
|
201
|
+
const kind = groupInventoryKind(group.kind);
|
|
178
202
|
if (group.kind === SeatingKind.Straight || group.kind === SeatingKind.Curved) {
|
|
179
203
|
for (const row of group.rows)
|
|
180
204
|
for (const slot of row.seats)
|
|
181
205
|
if (!slot.gap)
|
|
182
|
-
count(seatCategoryId(group, slot, row));
|
|
206
|
+
count(seatCategoryId(group, slot, row), kind, 1);
|
|
183
207
|
}
|
|
184
208
|
else {
|
|
185
209
|
const slots = group.kind === SeatingKind.Round ? group.chairs : Object.values(group.chairsBySide).flat();
|
|
186
210
|
for (const slot of slots)
|
|
187
211
|
if (!slot.gap)
|
|
188
|
-
count(seatCategoryId(group, slot));
|
|
212
|
+
count(seatCategoryId(group, slot), kind, 1);
|
|
189
213
|
}
|
|
190
214
|
}
|
|
191
|
-
for (const area of document.areas)
|
|
192
|
-
count(area.categoryId ?? null, area.kind === AreaKind.Booth ? 1 : area.capacity);
|
|
193
|
-
|
|
194
|
-
|
|
215
|
+
for (const area of document.areas) {
|
|
216
|
+
count(area.categoryId ?? null, areaInventoryKind(area.kind), area.kind === AreaKind.Booth ? 1 : area.capacity);
|
|
217
|
+
}
|
|
218
|
+
const result = { counts, kinds };
|
|
219
|
+
usage.set(document, result);
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
export function categoryUsage(document) {
|
|
223
|
+
return categoryInventory(document).counts;
|
|
224
|
+
}
|
|
225
|
+
export function categoryInventoryKinds(document, categoryId) {
|
|
226
|
+
return categoryInventory(document).kinds.get(categoryId) ?? noInventoryKinds;
|
|
195
227
|
}
|
|
196
228
|
export function ticketOptionNameKey(name) {
|
|
197
229
|
return name.trim().toLowerCase();
|
package/dist/editor-state.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type PhysicalDocumentV1, type UUID } from "./physical-document.interface.js";
|
|
3
|
+
export declare const editorHistoryEntryLimit = 100;
|
|
4
|
+
export declare const editorUndoRevisionsSchema: z.ZodArray<z.ZodNumber>;
|
|
3
5
|
export declare const mapEditorStateSchema: z.ZodObject<{
|
|
4
6
|
version: z.ZodLiteral<1>;
|
|
5
7
|
lockedIds: z.ZodArray<z.ZodString>;
|
package/dist/editor-state.js
CHANGED
|
@@ -4,6 +4,9 @@ import { documentCatalog } from "./catalog.js";
|
|
|
4
4
|
import { worldMatrices } from "./geometry/geometry.js";
|
|
5
5
|
import { uuidSchema } from "./schema.js";
|
|
6
6
|
import { DecorationKind } from "./physical-document.interface.js";
|
|
7
|
+
// The editor bounds the combined Undo and Redo stacks to this many commands.
|
|
8
|
+
export const editorHistoryEntryLimit = 100;
|
|
9
|
+
export const editorUndoRevisionsSchema = z.array(z.number().int().positive()).max(editorHistoryEntryLimit);
|
|
7
10
|
export const mapEditorStateSchema = z.strictObject({
|
|
8
11
|
version: z.literal(1),
|
|
9
12
|
lockedIds: z.array(uuidSchema).max(100_000),
|
package/dist/floors.d.ts
CHANGED
package/dist/floors.js
CHANGED
|
@@ -11,9 +11,9 @@ export function floorCatalog(document) {
|
|
|
11
11
|
const entries = new Map();
|
|
12
12
|
const owners = new Map();
|
|
13
13
|
for (const floor of document.floors ?? [])
|
|
14
|
-
entries.set(floor.id, { floor, members: [], capacity: { physicalSeats: 0, gaQuantity: 0 },
|
|
14
|
+
entries.set(floor.id, { floor, members: [], capacity: { physicalSeats: 0, gaQuantity: 0 }, rowGapCount: 0 });
|
|
15
15
|
if (!document.floors)
|
|
16
|
-
entries.set(null, { floor: null, members: [], capacity: { physicalSeats: 0, gaQuantity: 0 },
|
|
16
|
+
entries.set(null, { floor: null, members: [], capacity: { physicalSeats: 0, gaQuantity: 0 }, rowGapCount: 0 });
|
|
17
17
|
for (const member of [
|
|
18
18
|
...document.sections,
|
|
19
19
|
...document.collections,
|
|
@@ -29,20 +29,15 @@ export function floorCatalog(document) {
|
|
|
29
29
|
const id = group.floorId ?? null;
|
|
30
30
|
const entry = entries.get(id);
|
|
31
31
|
const inventoryCount = groupInventoryCount(group);
|
|
32
|
-
let slotCount = 0;
|
|
33
32
|
if ("rows" in group) {
|
|
33
|
+
let slotCount = 0;
|
|
34
34
|
for (const row of group.rows) {
|
|
35
35
|
owners.set(row.id, id);
|
|
36
36
|
slotCount += row.seats.length;
|
|
37
37
|
}
|
|
38
|
+
entry.rowGapCount += slotCount - inventoryCount;
|
|
38
39
|
}
|
|
39
|
-
else if ("chairs" in group)
|
|
40
|
-
slotCount = group.chairs.length;
|
|
41
|
-
else
|
|
42
|
-
for (const side of Object.values(group.chairsBySide))
|
|
43
|
-
slotCount += side.length;
|
|
44
40
|
entry.capacity.physicalSeats += inventoryCount;
|
|
45
|
-
entry.gapCount += slotCount - inventoryCount;
|
|
46
41
|
}
|
|
47
42
|
for (const area of document.areas) {
|
|
48
43
|
const count = entries.get(area.floorId ?? null).capacity;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { type Decoration } from "../physical-document.interface.js";
|
|
1
|
+
import { DecorationKind, type Decoration, type ReferencePlanCrop } from "../physical-document.interface.js";
|
|
2
2
|
import { type Bounds, type Matrix } from "./geometry.js";
|
|
3
|
+
export declare const FullReferenceCrop: Readonly<ReferencePlanCrop>;
|
|
4
|
+
/** Both the render mask and hit bounds use the full image's original centre as their origin. */
|
|
5
|
+
export declare function imageLocalBounds(image: Extract<Decoration, {
|
|
6
|
+
kind: DecorationKind.Image;
|
|
7
|
+
}>): Bounds;
|
|
3
8
|
/** World bounds of the physical artwork, independent of editor selection and section ownership. */
|
|
4
9
|
export declare function decorationBounds(decoration: Decoration, matrix: Matrix): Bounds;
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { polygonContour } from "./polygon-curves.js";
|
|
2
|
-
import { DecorationKind, LabelAlignment } from "../physical-document.interface.js";
|
|
2
|
+
import { DecorationKind, LabelAlignment, } from "../physical-document.interface.js";
|
|
3
3
|
import { pointsBounds, project } from "./geometry.js";
|
|
4
|
+
export const FullReferenceCrop = { left: 0, top: 0, width: 1, height: 1 };
|
|
5
|
+
/** Both the render mask and hit bounds use the full image's original centre as their origin. */
|
|
6
|
+
export function imageLocalBounds(image) {
|
|
7
|
+
const { width, height } = image.sizeM;
|
|
8
|
+
const crop = image.referenceCrop ?? FullReferenceCrop;
|
|
9
|
+
return {
|
|
10
|
+
minX: (crop.left - 0.5) * width,
|
|
11
|
+
minY: (crop.top - 0.5) * height,
|
|
12
|
+
maxX: (Math.min(1, crop.left + crop.width) - 0.5) * width,
|
|
13
|
+
maxY: (Math.min(1, crop.top + crop.height) - 0.5) * height,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
4
16
|
/** World bounds of the physical artwork, independent of editor selection and section ownership. */
|
|
5
17
|
export function decorationBounds(decoration, matrix) {
|
|
6
18
|
let points;
|
|
@@ -27,6 +39,16 @@ export function decorationBounds(decoration, matrix) {
|
|
|
27
39
|
case DecorationKind.Circle:
|
|
28
40
|
points = rectanglePoints(decoration.radiusM * 2, decoration.radiusM * 2);
|
|
29
41
|
break;
|
|
42
|
+
case DecorationKind.Image: {
|
|
43
|
+
const { minX, minY, maxX, maxY } = imageLocalBounds(decoration);
|
|
44
|
+
points = [
|
|
45
|
+
{ x: minX, y: minY },
|
|
46
|
+
{ x: maxX, y: minY },
|
|
47
|
+
{ x: maxX, y: maxY },
|
|
48
|
+
{ x: minX, y: maxY },
|
|
49
|
+
];
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
30
52
|
default:
|
|
31
53
|
points = rectanglePoints(decoration.sizeM.width, decoration.sizeM.height);
|
|
32
54
|
}
|
|
@@ -16,6 +16,9 @@ export type GeneratedSeat = {
|
|
|
16
16
|
label: string;
|
|
17
17
|
/** Canonical sequence label, independent of an authored display override. */
|
|
18
18
|
bookingLabel: string;
|
|
19
|
+
/** A table chair’s display number without its optional table name. */
|
|
20
|
+
chairNumber?: string;
|
|
21
|
+
buyerNoun?: string;
|
|
19
22
|
ownerLabel: string;
|
|
20
23
|
addressRowLabel?: string;
|
|
21
24
|
logicalRowLabel?: string;
|
|
@@ -44,3 +47,4 @@ export declare function generateGroup(group: SeatingGroup): Generator<GeneratedS
|
|
|
44
47
|
export declare function footprint(seat: GeneratedSeat, world?: Matrix): PointM[];
|
|
45
48
|
export declare function footprintInside(points: PointM[], polygon: PolygonM): boolean;
|
|
46
49
|
export declare function invalidPolygon(polygon: PolygonM): boolean;
|
|
50
|
+
export { arcThroughPoints } from "./three-point-arc.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { polygonContour } from "./polygon-curves.js";
|
|
2
|
-
import { rowPlacementOffset, rowSeatGeometry, roundChairGeometry, rectangularChairGeometry,
|
|
3
|
-
import {
|
|
2
|
+
import { rowPlacementOffset, rowSeatGeometry, roundChairGeometry, rectangularChairGeometry, rectangularChairOrder, } from "./seating-layout.js";
|
|
3
|
+
import { NumberingScheme, TableChairNumberFormat, SeatingKind, RowEnds, } from "../physical-document.interface.js";
|
|
4
4
|
import { inventoryName, sequenceLabel, rowDisplayLabel } from "../labels.js";
|
|
5
5
|
import { seatCategoryId } from "../categories.js";
|
|
6
6
|
import { containsPoint, intersects, pointsBounds } from "./primitives.js";
|
|
@@ -119,33 +119,59 @@ export function* generateGroup(group) {
|
|
|
119
119
|
const row = group.rows[r];
|
|
120
120
|
const owner = rowDisplayLabel(group, r);
|
|
121
121
|
const offset = rowPlacementOffset(group, r, row.offsetM);
|
|
122
|
+
const firstAisleIndex = row.aisleSeats === RowEnds.Start || row.aisleSeats === RowEnds.Both
|
|
123
|
+
? row.seats.findIndex((seat) => !seat.gap)
|
|
124
|
+
: -1;
|
|
125
|
+
let lastAisleIndex = -1;
|
|
126
|
+
if (row.aisleSeats === RowEnds.End || row.aisleSeats === RowEnds.Both) {
|
|
127
|
+
lastAisleIndex = row.seats.length - 1;
|
|
128
|
+
while (lastAisleIndex >= 0 && row.seats[lastAisleIndex].gap)
|
|
129
|
+
lastAisleIndex--;
|
|
130
|
+
}
|
|
122
131
|
for (let i = 0; i < row.seats.length; i++) {
|
|
123
132
|
const geometry = rowSeatGeometry(group, r, i, row.seats.length, longestRow, row.layout);
|
|
124
133
|
const p = { x: geometry.position.x + offset.x, y: geometry.position.y + offset.y };
|
|
125
134
|
const rotation = geometry.rotationDeg;
|
|
126
|
-
const seat = emit(row.seats[i], p, rotation, sequenceLabel(row.seatSequenceOverride ?? group.labels.seats, i, row.seats.length), owner, row.id,
|
|
127
|
-
(i === row.seats.length - 1 && (row.aisleSeats === RowEnds.End || row.aisleSeats === RowEnds.Both)), seatCategoryId(group, row.seats[i], row));
|
|
135
|
+
const seat = emit(row.seats[i], p, rotation, sequenceLabel(row.seatSequenceOverride ?? group.labels.seats, i, row.seats.length), owner, row.id, i === firstAisleIndex || i === lastAisleIndex, seatCategoryId(group, row.seats[i], row));
|
|
128
136
|
yield seat;
|
|
129
137
|
}
|
|
130
138
|
}
|
|
139
|
+
return;
|
|
131
140
|
}
|
|
132
|
-
|
|
141
|
+
const { labels } = group;
|
|
142
|
+
const ownerLabel = inventoryName(labels);
|
|
143
|
+
const numbering = labels.chairNumbering;
|
|
144
|
+
const letters = numbering?.format === TableChairNumberFormat.Letter;
|
|
145
|
+
const displaySequence = numbering && {
|
|
146
|
+
scheme: letters ? NumberingScheme.Alphabetic : NumberingScheme.Numeric,
|
|
147
|
+
startAt: letters ? Math.max(1, numbering.startAt) : numbering.startAt,
|
|
148
|
+
direction: numbering.direction,
|
|
149
|
+
};
|
|
150
|
+
const emitChair = (slot, position, rotation, index, count) => {
|
|
151
|
+
const seat = emit(slot, position, rotation, sequenceLabel(labels.chairs, index, count), ownerLabel, null);
|
|
152
|
+
if (labels.buyerNoun !== undefined)
|
|
153
|
+
seat.buyerNoun = labels.buyerNoun;
|
|
154
|
+
if (!numbering || !displaySequence)
|
|
155
|
+
return seat;
|
|
156
|
+
const chairNumber = sequenceLabel(displaySequence, index, count);
|
|
157
|
+
const label = numbering.format === TableChairNumberFormat.Prefixed ? `${ownerLabel}-${chairNumber}` : chairNumber;
|
|
158
|
+
return { ...seat, label: slot.labelOverride ?? label, chairNumber };
|
|
159
|
+
};
|
|
160
|
+
if (group.kind === SeatingKind.Round) {
|
|
133
161
|
for (let i = 0; i < group.chairs.length; i++) {
|
|
134
162
|
const geometry = roundChairGeometry(group.recipe, group.seatSizeM.height, i, group.chairs.length);
|
|
135
|
-
yield
|
|
163
|
+
yield emitChair(group.chairs[i], geometry.position, geometry.rotationDeg, i, group.chairs.length);
|
|
136
164
|
}
|
|
137
165
|
}
|
|
138
166
|
else {
|
|
139
|
-
const sides = group.recipe
|
|
140
|
-
? [TableSide.Top, TableSide.Bottom, TableSide.Left, TableSide.Right]
|
|
141
|
-
: Object.values(TableSide);
|
|
167
|
+
const sides = rectangularChairOrder(group.recipe);
|
|
142
168
|
const total = sides.reduce((n, s) => n + group.chairsBySide[s].length, 0);
|
|
143
169
|
let ordinal = 0;
|
|
144
170
|
for (const side of sides) {
|
|
145
171
|
const list = group.chairsBySide[side];
|
|
146
172
|
for (let i = 0; i < list.length; i++) {
|
|
147
173
|
const geometry = rectangularChairGeometry(group.recipe, group.seatSizeM.height, side, i, list.length);
|
|
148
|
-
yield
|
|
174
|
+
yield emitChair(list[i], geometry.position, geometry.rotationDeg, ordinal++, total);
|
|
149
175
|
}
|
|
150
176
|
}
|
|
151
177
|
}
|
|
@@ -226,3 +252,4 @@ function calculateInvalidPolygon(polygon) {
|
|
|
226
252
|
return true;
|
|
227
253
|
return false;
|
|
228
254
|
}
|
|
255
|
+
export { arcThroughPoints } from "./three-point-arc.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PointM, PolygonM } from "../physical-document.interface.js";
|
|
2
|
+
/** The editable inventory envelope uses 22 layout units of radial padding. */
|
|
3
|
+
export declare function paddedSectionOutline(points: readonly PointM[]): PolygonM | null;
|
|
4
|
+
/** Confirm an exact generated envelope and retain its authored coordinates for history. */
|
|
5
|
+
export declare function matchesPaddedSectionOutline(points: readonly PointM[], actual: PolygonM | undefined, { toWorld, toleranceM }?: {
|
|
6
|
+
toWorld?: (point: PointM) => PointM;
|
|
7
|
+
toleranceM?: number;
|
|
8
|
+
}): boolean;
|