@knot-technologies/seatmap 0.3.1-dev.0 → 0.4.0-dev.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 CHANGED
@@ -1,132 +1,115 @@
1
- # @knot-technologies/seatmap
1
+ # KNOT Seatmap SDK
2
2
 
3
- Framework-agnostic JavaScript SDK for embedding the KNOT Seatmap iframe engine.
3
+ Embed a KNOT seatmap in a cross-origin iframe and control it through a typed chart handle.
4
4
 
5
- ## Install
5
+ > **Selection is local-only in v0.1.** Selecting an object does not reserve or hold it on the server. The entire selection is lost when the page reloads.
6
+
7
+ ## Installation
8
+
9
+ Vanilla JavaScript or TypeScript:
6
10
 
7
11
  ```bash
8
12
  npm install @knot-technologies/seatmap
9
13
  ```
10
14
 
11
- Before the first production release, shared-dev integrations install the
12
- prerelease channel explicitly:
15
+ React:
13
16
 
14
17
  ```bash
15
- npm install @knot-technologies/seatmap@dev
18
+ npm install @knot-technologies/seatmap-react
16
19
  ```
17
20
 
18
- ## Usage
21
+ ## Mounting a seatmap
19
22
 
20
23
  ```ts
21
24
  import { mountSeatmap } from '@knot-technologies/seatmap';
22
25
 
23
- const container = document.getElementById('seatmap');
24
-
25
- if (!container) {
26
- throw new Error('Missing seatmap container');
26
+ const container = document.querySelector('#seatmap');
27
+ if (!(container instanceof HTMLElement)) {
28
+ throw new Error('Seatmap container not found');
27
29
  }
28
30
 
29
31
  const chart = await mountSeatmap(container, {
30
- session: 'sess_xxx',
31
- token: 'jwt_xxx',
32
- hold: 'seatmap',
33
- onSelectionChanged(change) {
34
- console.log(change.objects);
35
- },
36
- onChartRenderingFailed(error) {
37
- console.error(error);
38
- },
32
+ sessionId: 'session-id',
33
+ clientToken: 'client-token',
39
34
  });
40
35
 
41
- await chart.selectObjects(['A-1']);
42
- ```
43
-
44
- The `session` and `token` fields are required for the standard booking flow. The token must be minted by the KNOT API for the target session and browser origin. The SDK uses KNOT-managed API and live-update endpoints internally; integrator applications do not configure backend or SSE URLs.
45
-
46
- ### Environment profiles
47
-
48
- `production` is the default for stable releases. Integrations exercising the
49
- shared Seatmap dev deployment select `development` explicitly:
50
-
51
- ```ts
52
- await mountSeatmap(container, {
53
- session: 'sess_xxx',
54
- token: 'jwt_xxx',
55
- environment: 'development',
36
+ chart.on('selectionChanged', ({ selected }) => {
37
+ console.log(selected);
56
38
  });
57
39
  ```
58
40
 
59
- `development` has its own release-controlled API, SSE, and engine origins; it
60
- does not alias `predev` or `production`. Unknown or unconfigured profiles reject
61
- before network or iframe work. Profiles never accept raw API, SSE, engine, or
62
- CDN URL overrides from integrator code.
41
+ Call `await chart.destroy()` when the integration is removed. The chart handle is terminal after destruction.
63
42
 
64
- ## Config
43
+ ## Methods
65
44
 
66
- `mountSeatmap` accepts `SeatmapConfig` from `@knot-technologies/seatmap-types`.
45
+ The v0.1 chart handle implements these ten methods:
67
46
 
68
- Common options:
47
+ - `selectObjects(objects)`
48
+ - `deselectObjects(objects)`
49
+ - `clearSelection()`
50
+ - `listSelectedObjects()`
51
+ - `setObjectQuantity(object, quantity)`
52
+ - `highlightObjects(objects, color?)`
53
+ - `clearHighlights()`
54
+ - `setMetadata(metadata)`
55
+ - `setCategoryMetadata(metadata)`
56
+ - `destroy()`
69
57
 
70
- - `pricing`: category, object, and ticket-type pricing.
71
- - `environment`: `production`, `predev`, or `development`.
72
- - `hold`: `seatmap`, `external`, or `none`.
73
- - `fitTo`: `width` for auto-height or `widthAndHeight` for fixed container height.
74
- - `objectColor` and `tooltipText`: function hooks evaluated by the engine.
75
- - Callback fields such as `onChartRendered`, `onObjectSelected`, `onSelectionChanged`, `onHoldSucceeded`, and `onHoldFailed`.
58
+ ## Events
76
59
 
77
- Integrations that own their reservation lifecycle can disable SDK-managed holds:
60
+ Subscribe with `chart.on(event, handler)` and unsubscribe with `chart.off(event, handler)`:
78
61
 
79
- ```ts
80
- hold: 'external';
81
- ```
62
+ - `chartRendered`
63
+ - `chartRenderingFailed`
64
+ - `objectClicked`
65
+ - `objectSelected`
66
+ - `objectDeselected`
67
+ - `selectionChanged`
68
+ - `objectMouseOver`
69
+ - `objectMouseOut`
82
70
 
83
- ## Chart API
71
+ ## Deferred methods
84
72
 
85
- The resolved `SeatmapChart` exposes selection, view, metadata, category, hold, and styling methods:
73
+ The public contract reserves these method names for later releases:
86
74
 
87
- - `selectObjects`, `deselectObjects`, `clearSelection`, `listSelectedObjects`
88
- - `highlightObjects`, `clearHighlights`, `pulse`, `unpulse`, `spotlight`, `clearSpotlight`
89
- - `disableObjects`, `enableObjects`
90
- - `setMetadata`, `setCategoryMetadata`
91
- - `selectCategories`, `deselectCategories`, `listCategories`
92
- - `findObject`
93
75
  - `holdBestAvailable`
94
- - `resetView`, `zoomToObjects`, `zoomToSelectedObjects`, `zoomToSection`
76
+ - `pulse` and `unpulse`
77
+ - `spotlight` and `clearSpotlight`
78
+ - `disableObjects` and `enableObjects`
79
+ - `selectCategories`, `deselectCategories`, and `listCategories`
80
+ - `findObject`
81
+ - `zoomToObjects`, `zoomToSection`, and `resetView`
95
82
  - `changeConfig`
96
- - `destroy`
97
83
 
98
- ### View semantics
84
+ Calling a deferred method rejects with a typed error whose code is `METHOD_NOT_IMPLEMENTED` and whose message names the method. Deferred methods never silently succeed.
99
85
 
100
- `resetView()` returns to **Fit**, which is always reported as `100%` regardless of the chart's world-space dimensions. Zoom values are normalized relative to that Fit transform; they are not raw renderer scales.
86
+ ## Content Security Policy
101
87
 
102
- Buyer interaction authority is binary: `overview` or `seat`. `zoomToSection()` fits the camera to contextual geometry without creating a public section mode, focus toggle, or back-stack entry; `zoomToObjects()` and `zoomToSelectedObjects()` follow the same continuous-camera model. Programmatic navigation cancels residual pan momentum before moving. Small layouts may begin with seat authority at Fit when their projected seats are already actionable.
88
+ The SDK loads the engine from the KNOT development CDN. Permit that origin in `frame-src`:
103
89
 
104
- Rendered seats stop growing at a `30px` representative target with a `32px` hard ceiling for the largest seat. The read-only minimap appears as an orientation aid at seat authority, mirrors the live viewport, and never intercepts pointer input.
105
-
106
- ### Browser requirements
90
+ ```http
91
+ Content-Security-Policy: frame-src 'self' https://dev-seatmap.knottech.ai;
92
+ ```
107
93
 
108
- The booking map requires WebGL2. There is no Canvas, SVG, or compatibility renderer flag. A temporary context loss pauses drawing and picking while the complete GPU runtime is restored; camera, selection, and availability state remain in CPU memory. If WebGL2 is unavailable or restoration is exhausted, the iframe shows the seatmap-unavailable state instead of switching renderers. Integrations should always provide `onChartRenderingFailed` for chart-level bootstrap and rendering errors.
94
+ If a site uses `child-src` for older browser compatibility, permit the same origin there as well. A blocked engine rejects the mount instead of falling back to a same-origin bundle.
109
95
 
110
- ## Engine source
96
+ ## Next.js
111
97
 
112
- Published builds load the matching verified engine from the CDN assigned to the
113
- selected environment. Stable versions use a `major.minor` channel. Prereleases
114
- use an isolated channel such as `dev/0.3.1-dev.0`, so dev validation cannot move
115
- the stable engine pointer. The origins are fixed at publication time and cannot
116
- be overridden by consumer configuration.
98
+ The seatmap needs browser APIs and must mount only on the client. Put the component that imports the SDK behind a client boundary:
117
99
 
118
- ## Types
100
+ ```tsx
101
+ 'use client';
119
102
 
120
- This package re-exports the public types from `@knot-technologies/seatmap-types`.
103
+ import { KnotSeatmap } from '@knot-technologies/seatmap-react';
121
104
 
122
- ```ts
123
- import type { SeatmapChart, SeatmapConfig } from '@knot-technologies/seatmap';
105
+ export function Seatmap({ sessionId, clientToken }) {
106
+ return (
107
+ <KnotSeatmap
108
+ config={{ sessionId, clientToken }}
109
+ style={{ minHeight: 600 }}
110
+ />
111
+ );
112
+ }
124
113
  ```
125
114
 
126
- ## Versioning
127
-
128
- Semver. Major = breaking public API. Minor = added features. Patch = fixes.
129
-
130
- ## License
131
-
132
- MIT
115
+ Do not call `mountSeatmap` during server rendering. The React package itself is safe to import during SSR; mounting starts from its client-side effect.