@seatmap-fyi/map-domain 0.1.0-alpha.3 → 0.1.0-alpha.4
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/catalog.d.ts +6 -1
- package/dist/catalog.js +44 -2
- package/dist/categories.d.ts +25 -0
- package/dist/categories.js +138 -0
- package/dist/editor-state.js +8 -1
- package/dist/geometry/geometry.d.ts +7 -1
- package/dist/geometry/geometry.js +16 -5
- package/dist/geometry/seat-shape.d.ts +24 -0
- package/dist/geometry/seat-shape.js +101 -0
- package/dist/geometry/seating-layout.d.ts +12 -3
- package/dist/geometry/seating-layout.js +94 -9
- package/dist/identity.js +9 -1
- package/dist/labels.d.ts +6 -0
- package/dist/labels.js +71 -8
- package/dist/preview.js +40 -5
- package/dist/row-segments.d.ts +26 -0
- package/dist/row-segments.js +112 -0
- package/dist/schema.d.ts +994 -61
- package/dist/schema.js +271 -38
- package/dist/selling.d.ts +34 -0
- package/dist/selling.js +163 -0
- package/dist/table-layout.d.ts +30 -0
- package/dist/table-layout.js +142 -0
- package/dist/types.d.ts +193 -27
- package/dist/types.js +71 -0
- package/dist/validation.js +20 -7
- package/package.json +21 -1
package/dist/identity.js
CHANGED
|
@@ -44,7 +44,15 @@ export function* remapDocumentSteps(source, name) {
|
|
|
44
44
|
return result;
|
|
45
45
|
}
|
|
46
46
|
if (typeof value === "string" &&
|
|
47
|
-
[
|
|
47
|
+
[
|
|
48
|
+
"id",
|
|
49
|
+
"parentId",
|
|
50
|
+
"sectionId",
|
|
51
|
+
"companionForSeatId",
|
|
52
|
+
"assetId",
|
|
53
|
+
"categoryId",
|
|
54
|
+
"rowId",
|
|
55
|
+
].includes(key))
|
|
48
56
|
return ids.get(value) ?? value;
|
|
49
57
|
return value;
|
|
50
58
|
}
|
package/dist/labels.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { type LabelSequence } from "./types.js";
|
|
2
2
|
export declare function labelKey(value: string): string;
|
|
3
|
+
/** Position in the buyer's sequence, independent of authored inventory identity. */
|
|
4
|
+
export declare function sequenceOrdinal(sequence: LabelSequence, index: number, count: number): number;
|
|
5
|
+
export declare function sequenceStep(sequence: LabelSequence): number;
|
|
6
|
+
/** Combined patterns own their order; the stored anchor remains available when switching back. */
|
|
7
|
+
export declare function sequenceOwnsOrder(scheme: string): boolean;
|
|
8
|
+
export declare function sequenceStart(sequence: LabelSequence, count: number): number;
|
|
3
9
|
export declare function sequenceLabel(sequence: LabelSequence, index: number, count: number): string;
|
package/dist/labels.js
CHANGED
|
@@ -24,22 +24,85 @@ export function labelKey(value) {
|
|
|
24
24
|
.join("")
|
|
25
25
|
.normalize("NFC");
|
|
26
26
|
}
|
|
27
|
+
/** Position in the buyer's sequence, independent of authored inventory identity. */
|
|
28
|
+
export function sequenceOrdinal(sequence, index, count) {
|
|
29
|
+
const middle = Math.ceil(count / 2);
|
|
30
|
+
if (sequence.scheme === NumberingScheme.OutsideIn)
|
|
31
|
+
return index < middle ? index * 2 : (count - 1 - index) * 2 + 1;
|
|
32
|
+
if (sequence.scheme === NumberingScheme.InsideOut)
|
|
33
|
+
return index < middle ? (middle - 1 - index) * 2 : (index - middle) * 2 + 1;
|
|
34
|
+
if (sequence.direction === LabelDirection.Centre) {
|
|
35
|
+
const centre = Math.floor((count - 1) / 2);
|
|
36
|
+
if (index === centre)
|
|
37
|
+
return 0;
|
|
38
|
+
if (index < centre)
|
|
39
|
+
return (centre - index) * 2 - (count % 2);
|
|
40
|
+
return (index - centre) * 2 - (count % 2 === 0 ? 1 : 0);
|
|
41
|
+
}
|
|
42
|
+
return sequence.direction === LabelDirection.Reverse
|
|
43
|
+
? count - 1 - index
|
|
44
|
+
: index;
|
|
45
|
+
}
|
|
46
|
+
export function sequenceStep(sequence) {
|
|
47
|
+
return sequence.scheme === NumberingScheme.Odd ||
|
|
48
|
+
sequence.scheme === NumberingScheme.Even
|
|
49
|
+
? 2
|
|
50
|
+
: 1;
|
|
51
|
+
}
|
|
52
|
+
/** Combined patterns own their order; the stored anchor remains available when switching back. */
|
|
53
|
+
export function sequenceOwnsOrder(scheme) {
|
|
54
|
+
return (scheme === NumberingScheme.OutsideIn || scheme === NumberingScheme.InsideOut);
|
|
55
|
+
}
|
|
56
|
+
export function sequenceStart(sequence, count) {
|
|
57
|
+
let start = !sequenceOwnsOrder(sequence.scheme) &&
|
|
58
|
+
sequence.numberFrom === "last" &&
|
|
59
|
+
sequence.lastAt !== undefined
|
|
60
|
+
? Math.max(0, sequence.lastAt - Math.max(0, count - 1) * sequenceStep(sequence))
|
|
61
|
+
: sequence.startAt;
|
|
62
|
+
if (sequence.scheme === NumberingScheme.Odd && start % 2 === 0)
|
|
63
|
+
start++;
|
|
64
|
+
if (sequence.scheme === NumberingScheme.Even && start % 2 === 1)
|
|
65
|
+
start++;
|
|
66
|
+
return start;
|
|
67
|
+
}
|
|
68
|
+
const romanParts = [
|
|
69
|
+
[1000, "M"],
|
|
70
|
+
[900, "CM"],
|
|
71
|
+
[500, "D"],
|
|
72
|
+
[400, "CD"],
|
|
73
|
+
[100, "C"],
|
|
74
|
+
[90, "XC"],
|
|
75
|
+
[50, "L"],
|
|
76
|
+
[40, "XL"],
|
|
77
|
+
[10, "X"],
|
|
78
|
+
[9, "IX"],
|
|
79
|
+
[5, "V"],
|
|
80
|
+
[4, "IV"],
|
|
81
|
+
[1, "I"],
|
|
82
|
+
];
|
|
27
83
|
export function sequenceLabel(sequence, index, count) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
ordinal *
|
|
31
|
-
(sequence.scheme === NumberingScheme.Odd ||
|
|
32
|
-
sequence.scheme === NumberingScheme.Even
|
|
33
|
-
? 2
|
|
34
|
-
: 1);
|
|
84
|
+
let n = sequenceStart(sequence, count) +
|
|
85
|
+
sequenceOrdinal(sequence, index, count) * sequenceStep(sequence);
|
|
35
86
|
let label = String(n);
|
|
36
|
-
if (sequence.scheme === NumberingScheme.Alphabetic
|
|
87
|
+
if (sequence.scheme === NumberingScheme.Alphabetic ||
|
|
88
|
+
sequence.scheme === NumberingScheme.LowerAlphabetic) {
|
|
89
|
+
n = Math.max(1, n);
|
|
37
90
|
label = "";
|
|
38
91
|
while (n > 0) {
|
|
39
92
|
n--;
|
|
40
93
|
label = String.fromCharCode(65 + (n % 26)) + label;
|
|
41
94
|
n = Math.floor(n / 26);
|
|
42
95
|
}
|
|
96
|
+
if (sequence.scheme === NumberingScheme.LowerAlphabetic)
|
|
97
|
+
label = label.toLowerCase();
|
|
98
|
+
}
|
|
99
|
+
else if (sequence.scheme === NumberingScheme.Roman && n > 0) {
|
|
100
|
+
label = "";
|
|
101
|
+
for (const [value, glyph] of romanParts) {
|
|
102
|
+
const repeats = Math.floor(n / value);
|
|
103
|
+
label += glyph.repeat(repeats);
|
|
104
|
+
n %= value;
|
|
105
|
+
}
|
|
43
106
|
}
|
|
44
107
|
return (sequence.prefix ?? "") + label + (sequence.suffix ?? "");
|
|
45
108
|
}
|
package/dist/preview.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { documentGroupSeats } from "./catalog.js";
|
|
2
|
+
import { footprint, project, worldMatrices, multiply, transformMatrix, } from "./geometry/geometry.js";
|
|
2
3
|
import { emptyBounds, extend } from "./geometry/primitives.js";
|
|
3
|
-
import {
|
|
4
|
+
import { categoryCatalog, categorySeatShape } from "./categories.js";
|
|
5
|
+
import { seatShapeParts, SeatShapePartKind } from "./geometry/seat-shape.js";
|
|
6
|
+
import { DecorationKind, SeatingKind, ShapeKind, SeatShape } from "./types.js";
|
|
4
7
|
export const ThumbnailPolicy = {
|
|
5
8
|
MaximumSvgLength: 128000,
|
|
6
9
|
MaximumContentLength: 120000,
|
|
@@ -13,6 +16,7 @@ export const ThumbnailPolicy = {
|
|
|
13
16
|
export function projectMapPreview(document) {
|
|
14
17
|
const bounds = emptyBounds();
|
|
15
18
|
const matrices = worldMatrices(document);
|
|
19
|
+
const categories = categoryCatalog(document);
|
|
16
20
|
const sections = new Map(document.sections.map((section) => [section.id, section]));
|
|
17
21
|
const foreground = parseInt(document.background.color.slice(1, 3), 16) +
|
|
18
22
|
parseInt(document.background.color.slice(3, 5), 16) +
|
|
@@ -78,7 +82,11 @@ export function projectMapPreview(document) {
|
|
|
78
82
|
: []);
|
|
79
83
|
let index = 0;
|
|
80
84
|
const rowIndices = new Map();
|
|
81
|
-
for (const seat of
|
|
85
|
+
for (const seat of documentGroupSeats(document, group)) {
|
|
86
|
+
if (seat.slot.gap) {
|
|
87
|
+
index++;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
82
90
|
const position = project(matrix, seat.position);
|
|
83
91
|
const radius = Math.max(seat.size.width, seat.size.height) / 2;
|
|
84
92
|
for (const corner of footprint(seat, matrix))
|
|
@@ -94,7 +102,31 @@ export function projectMapPreview(document) {
|
|
|
94
102
|
rows.set(seat.rowId, row);
|
|
95
103
|
}
|
|
96
104
|
if (glyphs < ThumbnailPolicy.MaximumSeatGlyphs && index % 8 === 0) {
|
|
97
|
-
|
|
105
|
+
const category = seat.categoryId
|
|
106
|
+
? categories.get(seat.categoryId)
|
|
107
|
+
: undefined;
|
|
108
|
+
const shape = categorySeatShape(category, seat.slot);
|
|
109
|
+
const seatColour = category?.color ?? colour;
|
|
110
|
+
if (shape === SeatShape.Circle) {
|
|
111
|
+
append(`<circle cx="${number(position.x)}" cy="${number(position.y)}" r="${number(radius)}" fill="${seatColour}" fill-opacity=".8"/>`);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const transform = multiply(matrix, transformMatrix({
|
|
115
|
+
positionM: seat.position,
|
|
116
|
+
rotationDeg: seat.rotationDeg,
|
|
117
|
+
}));
|
|
118
|
+
const shapeMarkup = seatShapeParts(shape)
|
|
119
|
+
.map((part) => {
|
|
120
|
+
if (part.kind === SeatShapePartKind.Rectangle)
|
|
121
|
+
return `<rect x="${number(part.x * seat.size.width)}" y="${number(part.y * seat.size.height)}" width="${number(part.width * seat.size.width)}" height="${number(part.height * seat.size.height)}" rx="${number(part.radius * Math.min(seat.size.width, seat.size.height))}"/>`;
|
|
122
|
+
const points = [];
|
|
123
|
+
for (let index = 0; index < part.points.length; index += 2)
|
|
124
|
+
points.push(`${number(part.points[index] * seat.size.width)},${number(part.points[index + 1] * seat.size.height)}`);
|
|
125
|
+
return `<polygon points="${points.join(" ")}"/>`;
|
|
126
|
+
})
|
|
127
|
+
.join("");
|
|
128
|
+
append(`<g transform="matrix(${transform.a} ${transform.b} ${transform.c} ${transform.d} ${transform.tx} ${transform.ty})" fill="${seatColour}" fill-opacity=".8">${shapeMarkup}</g>`);
|
|
129
|
+
}
|
|
98
130
|
glyphs++;
|
|
99
131
|
}
|
|
100
132
|
index++;
|
|
@@ -110,7 +142,10 @@ export function projectMapPreview(document) {
|
|
|
110
142
|
const path = area.shape.kind === ShapeKind.Polygon
|
|
111
143
|
? polygon(area.shape.boundary, matrix)
|
|
112
144
|
: rectangle(area.shape.widthM, area.shape.heightM, matrix);
|
|
113
|
-
|
|
145
|
+
const category = area.categoryId
|
|
146
|
+
? categories.get(area.categoryId)
|
|
147
|
+
: undefined;
|
|
148
|
+
append(`<path d="${path}" ${paint(category ? { color: category.color, opacity: 1 } : sections.get(area.sectionId ?? "")?.style?.fill)} fill-rule="evenodd"/>`);
|
|
114
149
|
}
|
|
115
150
|
for (const art of [...document.decorations].sort((left, right) => left.zIndex - right.zIndex)) {
|
|
116
151
|
empty = false;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RowEnds, type PhysicalDocumentV1, type SeatingGroup, type RowInventory, type RowSlot, type SegmentedRow, type UUID, type PointM } from "./types.js";
|
|
2
|
+
export type RowSegment = {
|
|
3
|
+
row: SegmentedRow;
|
|
4
|
+
group: RowInventory;
|
|
5
|
+
part: RowSlot;
|
|
6
|
+
partIndex: number;
|
|
7
|
+
firstIndex: number;
|
|
8
|
+
totalSeats: number;
|
|
9
|
+
};
|
|
10
|
+
export type SegmentedRowEntry = {
|
|
11
|
+
row: SegmentedRow;
|
|
12
|
+
parts: readonly RowSegment[];
|
|
13
|
+
};
|
|
14
|
+
export declare function isRowInventory(group: SeatingGroup): group is RowInventory;
|
|
15
|
+
/** Logical rows associate independent physical parts without moving them between rendering banks. */
|
|
16
|
+
export declare function rowSegments(document: PhysicalDocumentV1): ReadonlyMap<UUID, RowSegment>;
|
|
17
|
+
export declare function changedSegmentGroups(before: PhysicalDocumentV1, after: PhysicalDocumentV1): ReadonlySet<UUID>;
|
|
18
|
+
export declare function suggestedRowEnds(document: PhysicalDocumentV1, rowId: UUID): RowEnds;
|
|
19
|
+
export type RowAisleGap = {
|
|
20
|
+
nextPartIndex: number;
|
|
21
|
+
distanceM: number;
|
|
22
|
+
requiredM: number;
|
|
23
|
+
deltaM: PointM;
|
|
24
|
+
};
|
|
25
|
+
/** A marked aisle leaves one seat of space between the adjacent seat centres. */
|
|
26
|
+
export declare function rowAisleGaps(document: PhysicalDocumentV1, rowId: UUID): RowAisleGap[];
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { generateGroup, project, worldMatrices } from "./geometry/geometry.js";
|
|
2
|
+
import { SeatingKind, RowEnds, RowJoin, } from "./types.js";
|
|
3
|
+
const segments = new WeakMap();
|
|
4
|
+
export function isRowInventory(group) {
|
|
5
|
+
return (group.kind === SeatingKind.Straight || group.kind === SeatingKind.Curved);
|
|
6
|
+
}
|
|
7
|
+
/** Logical rows associate independent physical parts without moving them between rendering banks. */
|
|
8
|
+
export function rowSegments(document) {
|
|
9
|
+
const cached = segments.get(document);
|
|
10
|
+
if (cached)
|
|
11
|
+
return cached;
|
|
12
|
+
const owners = new Map(document.seatingGroups.flatMap((group) => isRowInventory(group)
|
|
13
|
+
? group.rows.map((part) => [part.id, { group, part }])
|
|
14
|
+
: []));
|
|
15
|
+
const result = new Map();
|
|
16
|
+
for (const row of document.segmentedRows ?? []) {
|
|
17
|
+
const parts = row.parts.map((part) => owners.get(part.rowId));
|
|
18
|
+
const totalSeats = parts.reduce((sum, item) => sum + item.part.seats.length, 0);
|
|
19
|
+
let firstIndex = 0;
|
|
20
|
+
parts.forEach((item, partIndex) => {
|
|
21
|
+
result.set(item.part.id, {
|
|
22
|
+
row,
|
|
23
|
+
...item,
|
|
24
|
+
partIndex,
|
|
25
|
+
firstIndex,
|
|
26
|
+
totalSeats,
|
|
27
|
+
});
|
|
28
|
+
firstIndex += item.part.seats.length;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
segments.set(document, result);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
export function changedSegmentGroups(before, after) {
|
|
35
|
+
const groups = new Set();
|
|
36
|
+
if (before.segmentedRows === after.segmentedRows &&
|
|
37
|
+
before.seatingGroups === after.seatingGroups)
|
|
38
|
+
return groups;
|
|
39
|
+
const previous = new Map((before.segmentedRows ?? []).map((row) => [row.id, row]));
|
|
40
|
+
const next = new Map((after.segmentedRows ?? []).map((row) => [row.id, row]));
|
|
41
|
+
for (const id of new Set([...previous.keys(), ...next.keys()])) {
|
|
42
|
+
const previousRow = previous.get(id), nextRow = next.get(id);
|
|
43
|
+
if (previousRow === nextRow &&
|
|
44
|
+
previousRow?.parts.every((part) => rowSegments(before).get(part.rowId).part.seats.length ===
|
|
45
|
+
rowSegments(after).get(part.rowId).part.seats.length))
|
|
46
|
+
continue;
|
|
47
|
+
for (const part of previous.get(id)?.parts ?? [])
|
|
48
|
+
groups.add(rowSegments(before).get(part.rowId).group.id);
|
|
49
|
+
for (const part of next.get(id)?.parts ?? [])
|
|
50
|
+
groups.add(rowSegments(after).get(part.rowId).group.id);
|
|
51
|
+
}
|
|
52
|
+
return groups;
|
|
53
|
+
}
|
|
54
|
+
export function suggestedRowEnds(document, rowId) {
|
|
55
|
+
const segment = rowSegments(document).get(rowId);
|
|
56
|
+
if (!segment)
|
|
57
|
+
return RowEnds.Both;
|
|
58
|
+
const first = segment.partIndex === 0 ||
|
|
59
|
+
segment.row.parts[segment.partIndex].joinBefore === RowJoin.Aisle;
|
|
60
|
+
const last = segment.partIndex === segment.row.parts.length - 1 ||
|
|
61
|
+
segment.row.parts[segment.partIndex + 1].joinBefore === RowJoin.Aisle;
|
|
62
|
+
if (first && last)
|
|
63
|
+
return RowEnds.Both;
|
|
64
|
+
if (first)
|
|
65
|
+
return RowEnds.Start;
|
|
66
|
+
return last ? RowEnds.End : RowEnds.None;
|
|
67
|
+
}
|
|
68
|
+
/** A marked aisle leaves one seat of space between the adjacent seat centres. */
|
|
69
|
+
export function rowAisleGaps(document, rowId) {
|
|
70
|
+
const row = document.segmentedRows.find((row) => row.id === rowId);
|
|
71
|
+
const segments = rowSegments(document);
|
|
72
|
+
const matrices = worldMatrices(document);
|
|
73
|
+
const seats = new Map();
|
|
74
|
+
const edges = row.parts.map((part) => {
|
|
75
|
+
const segment = segments.get(part.rowId);
|
|
76
|
+
let generated = seats.get(segment.group.id);
|
|
77
|
+
if (!generated) {
|
|
78
|
+
generated = [...generateGroup(segment.group)];
|
|
79
|
+
seats.set(segment.group.id, generated);
|
|
80
|
+
}
|
|
81
|
+
const physical = generated.filter((seat) => seat.rowId === part.rowId);
|
|
82
|
+
const matrix = matrices.get(segment.group.id);
|
|
83
|
+
return {
|
|
84
|
+
first: project(matrix, physical[0].position),
|
|
85
|
+
last: project(matrix, physical.at(-1).position),
|
|
86
|
+
pitchM: segment.part.layout.seatPitchM,
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
return row.parts.flatMap((part, index) => {
|
|
90
|
+
if (!index || part.joinBefore !== RowJoin.Aisle)
|
|
91
|
+
return [];
|
|
92
|
+
const previous = edges[index - 1], next = edges[index];
|
|
93
|
+
const dx = next.first.x - previous.last.x;
|
|
94
|
+
const dy = next.first.y - previous.last.y;
|
|
95
|
+
const distanceM = Math.hypot(dx, dy);
|
|
96
|
+
const requiredM = previous.pitchM + next.pitchM;
|
|
97
|
+
if (distanceM >= requiredM - 1e-9)
|
|
98
|
+
return [];
|
|
99
|
+
const angle = Math.atan2(dy, dx);
|
|
100
|
+
return [
|
|
101
|
+
{
|
|
102
|
+
nextPartIndex: index,
|
|
103
|
+
distanceM,
|
|
104
|
+
requiredM,
|
|
105
|
+
deltaM: {
|
|
106
|
+
x: Math.cos(angle) * (requiredM - distanceM),
|
|
107
|
+
y: Math.sin(angle) * (requiredM - distanceM),
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
});
|
|
112
|
+
}
|