@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 +69 -86
- package/dist/index.cjs +718 -1010
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +5 -20
- package/dist/index.js +800 -0
- package/dist/index.js.map +1 -0
- package/package.json +18 -23
- package/LICENSE +0 -21
- package/dist/index.d.mts +0 -23
- package/dist/index.mjs +0 -1103
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,132 +1,115 @@
|
|
|
1
|
-
#
|
|
1
|
+
# KNOT Seatmap SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Embed a KNOT seatmap in a cross-origin iframe and control it through a typed chart handle.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
12
|
-
prerelease channel explicitly:
|
|
15
|
+
React:
|
|
13
16
|
|
|
14
17
|
```bash
|
|
15
|
-
npm install @knot-technologies/seatmap
|
|
18
|
+
npm install @knot-technologies/seatmap-react
|
|
16
19
|
```
|
|
17
20
|
|
|
18
|
-
##
|
|
21
|
+
## Mounting a seatmap
|
|
19
22
|
|
|
20
23
|
```ts
|
|
21
24
|
import { mountSeatmap } from '@knot-technologies/seatmap';
|
|
22
25
|
|
|
23
|
-
const container = document.
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
`
|
|
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
|
-
##
|
|
43
|
+
## Methods
|
|
65
44
|
|
|
66
|
-
|
|
45
|
+
The v0.1 chart handle implements these ten methods:
|
|
67
46
|
|
|
68
|
-
|
|
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
|
-
|
|
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
|
-
|
|
60
|
+
Subscribe with `chart.on(event, handler)` and unsubscribe with `chart.off(event, handler)`:
|
|
78
61
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
62
|
+
- `chartRendered`
|
|
63
|
+
- `chartRenderingFailed`
|
|
64
|
+
- `objectClicked`
|
|
65
|
+
- `objectSelected`
|
|
66
|
+
- `objectDeselected`
|
|
67
|
+
- `selectionChanged`
|
|
68
|
+
- `objectMouseOver`
|
|
69
|
+
- `objectMouseOut`
|
|
82
70
|
|
|
83
|
-
##
|
|
71
|
+
## Deferred methods
|
|
84
72
|
|
|
85
|
-
The
|
|
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
|
-
- `
|
|
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
|
-
|
|
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
|
-
|
|
86
|
+
## Content Security Policy
|
|
101
87
|
|
|
102
|
-
|
|
88
|
+
The SDK loads the engine from the KNOT development CDN. Permit that origin in `frame-src`:
|
|
103
89
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
90
|
+
```http
|
|
91
|
+
Content-Security-Policy: frame-src 'self' https://dev-seatmap.knottech.ai;
|
|
92
|
+
```
|
|
107
93
|
|
|
108
|
-
|
|
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
|
-
##
|
|
96
|
+
## Next.js
|
|
111
97
|
|
|
112
|
-
|
|
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
|
-
|
|
100
|
+
```tsx
|
|
101
|
+
'use client';
|
|
119
102
|
|
|
120
|
-
|
|
103
|
+
import { KnotSeatmap } from '@knot-technologies/seatmap-react';
|
|
121
104
|
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
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.
|