@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.170 → 2.0.0-next.171

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.
Files changed (78) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +870 -441
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +1110 -383
  4. package/dist/ar/poi/poi-aton.d.ts +1 -0
  5. package/dist/ar/poi/poi-aton.d.ts.map +1 -1
  6. package/dist/ar/poi/poi-aton.js +1 -0
  7. package/dist/ar/poi/poi-aton.js.map +1 -1
  8. package/dist/ar/poi/poi-base.d.ts +39 -5
  9. package/dist/ar/poi/poi-base.d.ts.map +1 -1
  10. package/dist/ar/poi/poi-base.js +108 -37
  11. package/dist/ar/poi/poi-base.js.map +1 -1
  12. package/dist/ar/poi/poi-data.d.ts +1 -0
  13. package/dist/ar/poi/poi-data.d.ts.map +1 -1
  14. package/dist/ar/poi/poi-data.js +1 -0
  15. package/dist/ar/poi/poi-data.js.map +1 -1
  16. package/dist/ar/poi/poi-vessel.d.ts +1 -0
  17. package/dist/ar/poi/poi-vessel.d.ts.map +1 -1
  18. package/dist/ar/poi/poi-vessel.js +1 -0
  19. package/dist/ar/poi/poi-vessel.js.map +1 -1
  20. package/dist/ar/poi/poi.d.ts +4 -12
  21. package/dist/ar/poi/poi.d.ts.map +1 -1
  22. package/dist/ar/poi/poi.js +6 -72
  23. package/dist/ar/poi/poi.js.map +1 -1
  24. package/dist/ar/poi-button/poi-button.d.ts +6 -2
  25. package/dist/ar/poi-button/poi-button.d.ts.map +1 -1
  26. package/dist/ar/poi-button/poi-button.js +10 -1
  27. package/dist/ar/poi-button/poi-button.js.map +1 -1
  28. package/dist/ar/poi-card/poi-card.d.ts +12 -1
  29. package/dist/ar/poi-card/poi-card.d.ts.map +1 -1
  30. package/dist/ar/poi-card/poi-card.js +4 -1
  31. package/dist/ar/poi-card/poi-card.js.map +1 -1
  32. package/dist/ar/poi-controller/poi-controller.d.ts +45 -1
  33. package/dist/ar/poi-controller/poi-controller.d.ts.map +1 -1
  34. package/dist/ar/poi-controller/poi-controller.js +72 -14
  35. package/dist/ar/poi-controller/poi-controller.js.map +1 -1
  36. package/dist/ar/poi-group/poi-group.d.ts +28 -5
  37. package/dist/ar/poi-group/poi-group.d.ts.map +1 -1
  38. package/dist/ar/poi-group/poi-group.js +50 -7
  39. package/dist/ar/poi-group/poi-group.js.map +1 -1
  40. package/dist/ar/poi-layer/poi-layer.css.js +69 -18
  41. package/dist/ar/poi-layer/poi-layer.css.js.map +1 -1
  42. package/dist/ar/poi-layer/poi-layer.d.ts +64 -5
  43. package/dist/ar/poi-layer/poi-layer.d.ts.map +1 -1
  44. package/dist/ar/poi-layer/poi-layer.js +173 -39
  45. package/dist/ar/poi-layer/poi-layer.js.map +1 -1
  46. package/dist/ar/poi-layer-stack/poi-layer-stack.d.ts +82 -7
  47. package/dist/ar/poi-layer-stack/poi-layer-stack.d.ts.map +1 -1
  48. package/dist/ar/poi-layer-stack/poi-layer-stack.js +172 -100
  49. package/dist/ar/poi-layer-stack/poi-layer-stack.js.map +1 -1
  50. package/dist/ar/poi-projection/poi-projection.d.ts +88 -0
  51. package/dist/ar/poi-projection/poi-projection.d.ts.map +1 -0
  52. package/dist/ar/poi-projection/poi-projection.js +90 -0
  53. package/dist/ar/poi-projection/poi-projection.js.map +1 -0
  54. package/docs/MigrationGuide.mdx +61 -5
  55. package/docs/migration-guide/a11y-labels.md +8 -0
  56. package/docs/migration-guide/api-automation.md +1 -0
  57. package/package.json +2 -2
  58. package/src/ar/_test-utils.ts +18 -6
  59. package/src/ar/poi/poi-aton.ts +2 -0
  60. package/src/ar/poi/poi-base.ts +159 -70
  61. package/src/ar/poi/poi-data.ts +2 -0
  62. package/src/ar/poi/poi-dom-ownership.spec.ts +393 -0
  63. package/src/ar/poi/poi-vessel.ts +2 -0
  64. package/src/ar/poi/poi.ts +12 -113
  65. package/src/ar/poi-button/poi-button.ts +25 -3
  66. package/src/ar/poi-card/poi-card.ts +16 -2
  67. package/src/ar/poi-controller/poi-controller.spec.ts +54 -0
  68. package/src/ar/poi-controller/poi-controller.stories.ts +76 -24
  69. package/src/ar/poi-controller/poi-controller.ts +111 -41
  70. package/src/ar/poi-group/poi-group.stories.ts +18 -5
  71. package/src/ar/poi-group/poi-group.ts +87 -12
  72. package/src/ar/poi-layer/poi-layer.css +69 -18
  73. package/src/ar/poi-layer/poi-layer.stories.ts +30 -16
  74. package/src/ar/poi-layer/poi-layer.ts +289 -64
  75. package/src/ar/poi-layer-stack/poi-layer-stack.stories.ts +56 -23
  76. package/src/ar/poi-layer-stack/poi-layer-stack.ts +342 -247
  77. package/src/ar/poi-projection/poi-projection.stories.ts +100 -0
  78. package/src/ar/poi-projection/poi-projection.ts +147 -0
@@ -0,0 +1,100 @@
1
+ import type {Meta, StoryObj} from '@storybook/web-components-vite';
2
+ import {html} from 'lit';
3
+ import {
4
+ MediaFit,
5
+ computeMediaProjection,
6
+ projectPoint,
7
+ } from './poi-projection.js';
8
+ import {moduleDocs} from '../../../.storybook/manifest-docs.js';
9
+
10
+ type PoiProjectionArgs = {
11
+ mediaWidth: number;
12
+ mediaHeight: number;
13
+ renderWidth: number;
14
+ renderHeight: number;
15
+ fit: MediaFit;
16
+ pointX: number;
17
+ pointY: number;
18
+ };
19
+
20
+ const meta: Meta<PoiProjectionArgs> = {
21
+ title: 'AR/POI Projection',
22
+ tags: ['autodocs', '6.1'],
23
+ parameters: {
24
+ docs: {
25
+ description: {
26
+ component: moduleDocs('ar/poi-projection/poi-projection.ts'),
27
+ },
28
+ },
29
+ },
30
+ args: {
31
+ mediaWidth: 1920,
32
+ mediaHeight: 1080,
33
+ renderWidth: 480,
34
+ renderHeight: 360,
35
+ fit: MediaFit.Contain,
36
+ pointX: 960,
37
+ pointY: 540,
38
+ },
39
+ argTypes: {
40
+ mediaWidth: {control: {type: 'number'}},
41
+ mediaHeight: {control: {type: 'number'}},
42
+ renderWidth: {control: {type: 'number'}},
43
+ renderHeight: {control: {type: 'number'}},
44
+ fit: {control: {type: 'select'}, options: Object.values(MediaFit)},
45
+ pointX: {control: {type: 'number'}},
46
+ pointY: {control: {type: 'number'}},
47
+ },
48
+ } satisfies Meta<PoiProjectionArgs>;
49
+
50
+ export default meta;
51
+ type Story = StoryObj<PoiProjectionArgs>;
52
+
53
+ const renderDemo = (args: PoiProjectionArgs) => {
54
+ const projection = computeMediaProjection({
55
+ mediaWidth: args.mediaWidth,
56
+ mediaHeight: args.mediaHeight,
57
+ renderWidth: args.renderWidth,
58
+ renderHeight: args.renderHeight,
59
+ fit: args.fit,
60
+ });
61
+ const point = projection
62
+ ? projectPoint(projection, args.pointX, args.pointY)
63
+ : null;
64
+
65
+ return html`
66
+ <div
67
+ style="position: relative; width: ${args.renderWidth}px; height: ${args.renderHeight}px; border: 1px solid var(--instrument-frame-primary-color, #888); overflow: hidden;"
68
+ >
69
+ ${
70
+ projection
71
+ ? html`
72
+ <div
73
+ style="position: absolute; left: ${projection.offsetX}px; top: ${projection.offsetY}px; width: ${projection.contentWidth}px; height: ${projection.contentHeight}px; background: var(--container-backdrop-color, rgb(0 0 0 / 8%));"
74
+ ></div>
75
+ `
76
+ : null
77
+ }
78
+ ${
79
+ point
80
+ ? html`
81
+ <div
82
+ style="position: absolute; left: ${point.x - 4}px; top: ${
83
+ point.y - 4
84
+ }px; width: 8px; height: 8px; border-radius: 50%; background: var(--instrument-enhanced-primary-color, #2a6);"
85
+ ></div>
86
+ `
87
+ : null
88
+ }
89
+ </div>
90
+ `;
91
+ };
92
+
93
+ export const Contain: Story = {
94
+ render: renderDemo,
95
+ };
96
+
97
+ export const Cover: Story = {
98
+ args: {fit: MediaFit.Cover},
99
+ render: renderDemo,
100
+ };
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @module POI Projection
3
+ *
4
+ * Media-projection helpers for POI overlays.
5
+ *
6
+ * Maps points from media pixel space (video/image natural resolution) to
7
+ * rendered screen space, accounting for `cover`/`contain` letterboxing.
8
+ * This is the same math `obc-poi-controller` applies to its
9
+ * detections-driven targets, exported as pure functions so applications
10
+ * that manage their own POI elements can project coordinates without
11
+ * re-implementing the transform.
12
+ *
13
+ * ### Usage Guidelines
14
+ * - Build a {@link MediaProjection} once per resize/metadata change via
15
+ * {@link computeMediaProjection}; reuse it for every point in a frame.
16
+ * - `renderWidth`/`renderHeight` come from the media element's
17
+ * `getBoundingClientRect()`; `mediaWidth`/`mediaHeight` from
18
+ * `videoWidth`/`videoHeight` (video) or `naturalWidth`/`naturalHeight`
19
+ * (image).
20
+ * - {@link projectPointToLayer} additionally converts a projected
21
+ * point into `obc-poi-data` layer coordinates (`x` center px,
22
+ * `y` line length from the layer's bottom anchor), given the layer's
23
+ * bottom offset inside the projection container.
24
+ *
25
+ * ### Fit modes
26
+ * - `cover`: media fills the container; overflow is cropped.
27
+ * - `contain`: media letterboxes inside the container.
28
+ *
29
+ * The Storybook demo draws the rendered container (outer box), the scaled
30
+ * media content region (shaded), and a marker at the projected point.
31
+ */
32
+
33
+ /** Fit behavior matching `obc-poi-controller`'s `PoiFitMode` values. */
34
+ export enum MediaFit {
35
+ Cover = 'cover',
36
+ Contain = 'contain',
37
+ }
38
+
39
+ /** Natural and rendered media dimensions plus the fit mode. */
40
+ export interface MediaProjectionInput {
41
+ /** Media natural width in px (`videoWidth`/`naturalWidth`). */
42
+ mediaWidth: number;
43
+ /** Media natural height in px (`videoHeight`/`naturalHeight`). */
44
+ mediaHeight: number;
45
+ /** Rendered element width in px. */
46
+ renderWidth: number;
47
+ /** Rendered element height in px. */
48
+ renderHeight: number;
49
+ fit: MediaFit;
50
+ }
51
+
52
+ /** Resolved projection: uniform scale plus letterbox offsets. */
53
+ export interface MediaProjection {
54
+ scale: number;
55
+ /** Horizontal letterbox offset in rendered px (negative when cropped). */
56
+ offsetX: number;
57
+ /** Vertical letterbox offset in rendered px (negative when cropped). */
58
+ offsetY: number;
59
+ /** Scaled media content width in rendered px. */
60
+ contentWidth: number;
61
+ /** Scaled media content height in rendered px. */
62
+ contentHeight: number;
63
+ }
64
+
65
+ /**
66
+ * Compute the projection for the given dimensions, or `null` when any
67
+ * dimension is non-finite or zero (media not measured yet).
68
+ */
69
+ export function computeMediaProjection(
70
+ input: MediaProjectionInput
71
+ ): MediaProjection | null {
72
+ const {mediaWidth, mediaHeight, renderWidth, renderHeight, fit} = input;
73
+ if (
74
+ !Number.isFinite(mediaWidth) ||
75
+ !Number.isFinite(mediaHeight) ||
76
+ !Number.isFinite(renderWidth) ||
77
+ !Number.isFinite(renderHeight) ||
78
+ mediaWidth === 0 ||
79
+ mediaHeight === 0 ||
80
+ renderWidth === 0 ||
81
+ renderHeight === 0
82
+ ) {
83
+ return null;
84
+ }
85
+
86
+ const scale =
87
+ fit === MediaFit.Cover
88
+ ? Math.max(renderWidth / mediaWidth, renderHeight / mediaHeight)
89
+ : Math.min(renderWidth / mediaWidth, renderHeight / mediaHeight);
90
+
91
+ const contentWidth = mediaWidth * scale;
92
+ const contentHeight = mediaHeight * scale;
93
+ return {
94
+ scale,
95
+ offsetX: (renderWidth - contentWidth) / 2,
96
+ offsetY: (renderHeight - contentHeight) / 2,
97
+ contentWidth,
98
+ contentHeight,
99
+ };
100
+ }
101
+
102
+ /** Project a point from media pixel space into rendered space. */
103
+ export function projectPoint(
104
+ projection: MediaProjection,
105
+ x: number,
106
+ y: number
107
+ ): {x: number; y: number} {
108
+ return {
109
+ x: projection.offsetX + x * projection.scale,
110
+ y: projection.offsetY + y * projection.scale,
111
+ };
112
+ }
113
+
114
+ /**
115
+ * Project a media-space anchor point into `obc-poi-data` layer
116
+ * coordinates.
117
+ *
118
+ * `layerBottom` is the POI layer's bottom edge measured in the same
119
+ * rendered coordinate space as the projection container (e.g.
120
+ * `layerRect.bottom - containerRect.top`). The returned `y` is the
121
+ * connector line length extending downward from the layer to the
122
+ * target point, clamped to `0` (matches how `obc-poi-controller`
123
+ * positions its detection targets).
124
+ */
125
+ export function projectPointToLayer(
126
+ projection: MediaProjection,
127
+ x: number,
128
+ y: number,
129
+ layerBottom: number
130
+ ): {x: number; y: number} {
131
+ const projected = projectPoint(projection, x, y);
132
+ return {
133
+ x: projected.x,
134
+ y: Math.max(0, projected.y - layerBottom),
135
+ };
136
+ }
137
+
138
+ /** Scale a media-space box dimension into rendered px, or `null`. */
139
+ export function projectBoxSize(
140
+ projection: MediaProjection,
141
+ size: number | null | undefined
142
+ ): number | null {
143
+ if (typeof size !== 'number' || !Number.isFinite(size)) {
144
+ return null;
145
+ }
146
+ return size * projection.scale;
147
+ }