@rosettadash/web-components 0.1.0
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/LICENSE +21 -0
- package/README.md +103 -0
- package/browser/media.js +484 -0
- package/browser/media.js.map +7 -0
- package/package.json +125 -0
- package/src/catalog/_shared/catalog-variant.d.ts +5 -0
- package/src/catalog/_shared/catalog-variant.js +19 -0
- package/src/catalog/_shared/catalog-variant.js.map +1 -0
- package/src/catalog/_shared/markup-shared.d.ts +6 -0
- package/src/catalog/_shared/markup-shared.js +21 -0
- package/src/catalog/_shared/markup-shared.js.map +1 -0
- package/src/catalog/component-attribute/index.d.ts +2 -0
- package/src/catalog/component-attribute/index.js +2 -0
- package/src/catalog/component-attribute/index.js.map +1 -0
- package/src/catalog/component-attribute/rd-attribute.d.ts +20 -0
- package/src/catalog/component-attribute/rd-attribute.js +27 -0
- package/src/catalog/component-attribute/rd-attribute.js.map +1 -0
- package/src/catalog/component-name/index.d.ts +2 -0
- package/src/catalog/component-name/index.js +2 -0
- package/src/catalog/component-name/index.js.map +1 -0
- package/src/catalog/component-name/rd-component-name.d.ts +40 -0
- package/src/catalog/component-name/rd-component-name.js +219 -0
- package/src/catalog/component-name/rd-component-name.js.map +1 -0
- package/src/catalog/component-option/index.d.ts +2 -0
- package/src/catalog/component-option/index.js +2 -0
- package/src/catalog/component-option/index.js.map +1 -0
- package/src/catalog/component-option/rd-component-option.d.ts +25 -0
- package/src/catalog/component-option/rd-component-option.js +104 -0
- package/src/catalog/component-option/rd-component-option.js.map +1 -0
- package/src/catalog/component-port/index.d.ts +2 -0
- package/src/catalog/component-port/index.js +2 -0
- package/src/catalog/component-port/index.js.map +1 -0
- package/src/catalog/component-port/rd-component-port.d.ts +26 -0
- package/src/catalog/component-port/rd-component-port.js +109 -0
- package/src/catalog/component-port/rd-component-port.js.map +1 -0
- package/src/catalog/component-requirement/index.d.ts +2 -0
- package/src/catalog/component-requirement/index.js +2 -0
- package/src/catalog/component-requirement/index.js.map +1 -0
- package/src/catalog/component-requirement/rd-component-requirement.d.ts +17 -0
- package/src/catalog/component-requirement/rd-component-requirement.js +76 -0
- package/src/catalog/component-requirement/rd-component-requirement.js.map +1 -0
- package/src/catalog/component-spec/index.d.ts +2 -0
- package/src/catalog/component-spec/index.js +2 -0
- package/src/catalog/component-spec/index.js.map +1 -0
- package/src/catalog/component-spec/rd-component-spec.d.ts +40 -0
- package/src/catalog/component-spec/rd-component-spec.js +367 -0
- package/src/catalog/component-spec/rd-component-spec.js.map +1 -0
- package/src/catalog/index.d.ts +23 -0
- package/src/catalog/index.js +37 -0
- package/src/catalog/index.js.map +1 -0
- package/src/catalog/palette-catalog/index.d.ts +2 -0
- package/src/catalog/palette-catalog/index.js +2 -0
- package/src/catalog/palette-catalog/index.js.map +1 -0
- package/src/catalog/palette-catalog/rd-palette-catalog.d.ts +29 -0
- package/src/catalog/palette-catalog/rd-palette-catalog.js +114 -0
- package/src/catalog/palette-catalog/rd-palette-catalog.js.map +1 -0
- package/src/catalog/palette-group/index.d.ts +2 -0
- package/src/catalog/palette-group/index.js +2 -0
- package/src/catalog/palette-group/index.js.map +1 -0
- package/src/catalog/palette-group/rd-palette-group.d.ts +33 -0
- package/src/catalog/palette-group/rd-palette-group.js +179 -0
- package/src/catalog/palette-group/rd-palette-group.js.map +1 -0
- package/src/catalog/subcomponent-name/index.d.ts +1 -0
- package/src/catalog/subcomponent-name/index.js +2 -0
- package/src/catalog/subcomponent-name/index.js.map +1 -0
- package/src/catalog/subcomponent-name/rd-subcomponent-name.d.ts +12 -0
- package/src/catalog/subcomponent-name/rd-subcomponent-name.js +29 -0
- package/src/catalog/subcomponent-name/rd-subcomponent-name.js.map +1 -0
- package/src/index.d.ts +9 -0
- package/src/index.js +23 -0
- package/src/index.js.map +1 -0
- package/src/layout/accordion/index.d.ts +4 -0
- package/src/layout/accordion/index.js +7 -0
- package/src/layout/accordion/index.js.map +1 -0
- package/src/layout/accordion/rd-accordion.d.ts +26 -0
- package/src/layout/accordion/rd-accordion.js +94 -0
- package/src/layout/accordion/rd-accordion.js.map +1 -0
- package/src/layout/accordion-link-list/index.d.ts +4 -0
- package/src/layout/accordion-link-list/index.js +7 -0
- package/src/layout/accordion-link-list/index.js.map +1 -0
- package/src/layout/accordion-link-list/rd-accordion-link-list.d.ts +36 -0
- package/src/layout/accordion-link-list/rd-accordion-link-list.js +139 -0
- package/src/layout/accordion-link-list/rd-accordion-link-list.js.map +1 -0
- package/src/lib/element-utils.d.ts +8 -0
- package/src/lib/element-utils.js +46 -0
- package/src/lib/element-utils.js.map +1 -0
- package/src/lib/parse-link-items.d.ts +6 -0
- package/src/lib/parse-link-items.js +37 -0
- package/src/lib/parse-link-items.js.map +1 -0
- package/src/lib/shadow-base.d.ts +20 -0
- package/src/lib/shadow-base.js +81 -0
- package/src/lib/shadow-base.js.map +1 -0
- package/src/lib/shadow-resources.d.ts +10 -0
- package/src/lib/shadow-resources.js +38 -0
- package/src/lib/shadow-resources.js.map +1 -0
- package/src/register-shadow-bases.browser.d.ts +1 -0
- package/src/register-shadow-bases.browser.js +5 -0
- package/src/register-shadow-bases.browser.js.map +1 -0
- package/src/visual/link-list/index.d.ts +4 -0
- package/src/visual/link-list/index.js +7 -0
- package/src/visual/link-list/index.js.map +1 -0
- package/src/visual/link-list/rd-link-list.d.ts +26 -0
- package/src/visual/link-list/rd-link-list.js +68 -0
- package/src/visual/link-list/rd-link-list.js.map +1 -0
- package/src/visual/media/equirect-viewport/index.d.ts +1 -0
- package/src/visual/media/equirect-viewport/index.js +2 -0
- package/src/visual/media/equirect-viewport/index.js.map +1 -0
- package/src/visual/media/equirect-viewport/rd-equirect-viewport.d.ts +30 -0
- package/src/visual/media/equirect-viewport/rd-equirect-viewport.js +199 -0
- package/src/visual/media/equirect-viewport/rd-equirect-viewport.js.map +1 -0
- package/src/visual/media/index.d.ts +3 -0
- package/src/visual/media/index.js +9 -0
- package/src/visual/media/index.js.map +1 -0
- package/src/visual/media/video-source/index.d.ts +1 -0
- package/src/visual/media/video-source/index.js +2 -0
- package/src/visual/media/video-source/index.js.map +1 -0
- package/src/visual/media/video-source/rd-video-source.d.ts +19 -0
- package/src/visual/media/video-source/rd-video-source.js +105 -0
- package/src/visual/media/video-source/rd-video-source.js.map +1 -0
- package/src/wasm/index.d.ts +2 -0
- package/src/wasm/index.js +6 -0
- package/src/wasm/index.js.map +1 -0
- package/src/wasm/wasm-media/index.d.ts +1 -0
- package/src/wasm/wasm-media/index.js +2 -0
- package/src/wasm/wasm-media/index.js.map +1 -0
- package/src/wasm/wasm-media/rd-wasm-media.d.ts +30 -0
- package/src/wasm/wasm-media/rd-wasm-media.js +269 -0
- package/src/wasm/wasm-media/rd-wasm-media.js.map +1 -0
- package/styles/catalog.css +69 -0
- package/styles/styles.css +76 -0
- package/styles/tokens.css +19 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kevin Ready <kevin@planetkevin.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# `@rosettadash/web-components`
|
|
2
|
+
|
|
3
|
+
Default RosettaDash UI runtime (Web Components).
|
|
4
|
+
|
|
5
|
+
**Author:** Kevin Ready \<kevin@planetkevin.com\>
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @rosettadash/web-components
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> Unscoped [`rosettadash`](https://www.npmjs.com/package/rosettadash) is the **product monorepo**, not this package. See [consumer install](../../docs/39-npm-consumer-install.md).
|
|
14
|
+
|
|
15
|
+
## Import shape
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
registerRdAccordion,
|
|
20
|
+
type AccordionProps,
|
|
21
|
+
} from '@rosettadash/web-components/layout/accordion';
|
|
22
|
+
|
|
23
|
+
registerRdAccordion();
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<rd-accordion title="Resources"></rd-accordion>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Recipes (DAS-94)
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { registerRdLinkList } from '@rosettadash/web-components/visual/link-list';
|
|
34
|
+
import {
|
|
35
|
+
registerRdAccordionLinkList,
|
|
36
|
+
AccordionLinkList,
|
|
37
|
+
} from '@rosettadash/web-components/layout/accordion-link-list';
|
|
38
|
+
|
|
39
|
+
registerRdLinkList();
|
|
40
|
+
registerRdAccordionLinkList();
|
|
41
|
+
|
|
42
|
+
AccordionLinkList({
|
|
43
|
+
title: 'Resources',
|
|
44
|
+
items: [{ label: 'Docs', href: '/docs' }],
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<!-- Composition -->
|
|
50
|
+
<rd-accordion title="Resources">
|
|
51
|
+
<rd-link-list items='[{"label":"Docs","href":"/docs"}]'></rd-link-list>
|
|
52
|
+
</rd-accordion>
|
|
53
|
+
|
|
54
|
+
<!-- Or the recipe helper element -->
|
|
55
|
+
<rd-accordion-link-list
|
|
56
|
+
title="Resources"
|
|
57
|
+
items='[{"label":"Docs","href":"/docs"}]'
|
|
58
|
+
></rd-accordion-link-list>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Media (ffmp3Console / DAS-83)
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { registerRosettaDashMediaElements } from '@rosettadash/web-components/media';
|
|
65
|
+
|
|
66
|
+
registerRosettaDashMediaElements();
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<rd-video-source></rd-video-source>
|
|
71
|
+
<rd-equirect-viewport preview-mode="rectilinear" yaw="0" pitch="0" horizontal-fov="90"></rd-equirect-viewport>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Events: `video-file`, `crop-region`. Filter math: `@rosettadash/core` (`buildEquirectExtractFilter`).
|
|
75
|
+
|
|
76
|
+
Same `<group>/…/<component>` paths are used on `@rosettadash/react`, `@rosettadash/angular`, `@rosettadash/vue`, and `@rosettadash/svelte`.
|
|
77
|
+
|
|
78
|
+
## Styles (opt-in)
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import '@rosettadash/web-components/tokens.css';
|
|
82
|
+
import '@rosettadash/web-components/styles.css';
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Tokens use the `--rd-*` prefix. Components work without these imports (minimal defaults in shadow CSS).
|
|
86
|
+
|
|
87
|
+
## Storybook
|
|
88
|
+
|
|
89
|
+
Interactive component catalogs ship with the **RosettaDash GitHub repo** (not this npm tarball). Clone [KevinEverywhere/rosettadash](https://github.com/KevinEverywhere/rosettadash), then:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm install
|
|
93
|
+
npm run storybook:web-components # port 6006 — primary catalog
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Sidebar: **Getting Started** (Start here, Component count, Styling modes) · **Catalog / Components** · **Catalog / Meta components**. Framework catalogs on ports 6007–6010 (`npm run storybook:react`, etc.). Details: [Storybook component catalog](https://github.com/KevinEverywhere/rosettadash/blob/development/docs/38-storybook-component-catalog.md).
|
|
97
|
+
|
|
98
|
+
## Build / pack
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
nx build web-components
|
|
102
|
+
npm pack ./dist/packages/web-components --dry-run
|
|
103
|
+
```
|
package/browser/media.js
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
// packages/core/src/lib/media/equirect-filter.ts
|
|
2
|
+
function buildEquirectFlatCropFilter(options) {
|
|
3
|
+
const cropX = Math.max(0, Math.round(options.cropX));
|
|
4
|
+
const cropY = Math.max(0, Math.round(options.cropY));
|
|
5
|
+
const cropWidth = Math.max(2, Math.round(options.cropWidth));
|
|
6
|
+
const cropHeight = Math.max(2, Math.round(options.cropHeight));
|
|
7
|
+
const outputWidth = Math.max(2, Math.round(options.outputWidth));
|
|
8
|
+
const outputHeight = Math.max(2, Math.round(options.outputHeight));
|
|
9
|
+
return `crop=${cropWidth}:${cropHeight}:${cropX}:${cropY},scale=${outputWidth}:${outputHeight}`;
|
|
10
|
+
}
|
|
11
|
+
function buildEquirectRectilinearFilter(options) {
|
|
12
|
+
const yaw = Number(options.yaw) || 0;
|
|
13
|
+
const pitch = Number(options.pitch) || 0;
|
|
14
|
+
const roll = Number(options.roll ?? 0) || 0;
|
|
15
|
+
const horizontalFov = Math.max(1, Number(options.horizontalFov) || 90);
|
|
16
|
+
const outputWidth = Math.max(2, Math.round(options.outputWidth));
|
|
17
|
+
const outputHeight = Math.max(2, Math.round(options.outputHeight));
|
|
18
|
+
return [
|
|
19
|
+
`v360=input=equirect:output=rectilinear:yaw=${yaw}:pitch=${pitch}:roll=${roll}:d_fov=${horizontalFov}`,
|
|
20
|
+
`scale=${outputWidth}:${outputHeight}`
|
|
21
|
+
].join(",");
|
|
22
|
+
}
|
|
23
|
+
function buildEquirectExtractFilter(mode, options) {
|
|
24
|
+
if (mode === "rectilinear") {
|
|
25
|
+
return buildEquirectRectilinearFilter({
|
|
26
|
+
yaw: options.yaw ?? 0,
|
|
27
|
+
pitch: options.pitch ?? 0,
|
|
28
|
+
roll: options.roll ?? 0,
|
|
29
|
+
horizontalFov: options.horizontalFov ?? 90,
|
|
30
|
+
outputWidth: options.outputWidth,
|
|
31
|
+
outputHeight: options.outputHeight
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return buildEquirectFlatCropFilter(options);
|
|
35
|
+
}
|
|
36
|
+
var DEFAULT_EQUIRECT_SOURCE = { width: 4096, height: 2048 };
|
|
37
|
+
var DEFAULT_EQUIRECT_FLAT_CROP = {
|
|
38
|
+
cropX: Math.floor((DEFAULT_EQUIRECT_SOURCE.width - 1080) / 2),
|
|
39
|
+
cropY: Math.floor((DEFAULT_EQUIRECT_SOURCE.height - 720) / 2),
|
|
40
|
+
cropWidth: 1080,
|
|
41
|
+
cropHeight: 720,
|
|
42
|
+
outputWidth: 720,
|
|
43
|
+
outputHeight: 480
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// packages/web-components/src/lib/element-utils.ts
|
|
47
|
+
function defineRosettaElement(tagName, ctor, options) {
|
|
48
|
+
if (customElements.get(tagName)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (options?.extends) {
|
|
52
|
+
customElements.define(tagName, ctor, { extends: options.extends });
|
|
53
|
+
} else {
|
|
54
|
+
customElements.define(tagName, ctor);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function readNumber(value, fallback) {
|
|
58
|
+
const next = Number(value);
|
|
59
|
+
return Number.isFinite(next) ? next : fallback;
|
|
60
|
+
}
|
|
61
|
+
function readString(value, fallback) {
|
|
62
|
+
return typeof value === "string" ? value : fallback;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// packages/web-components/src/lib/shadow-resources.ts
|
|
66
|
+
var textCache = /* @__PURE__ */ new Map();
|
|
67
|
+
function loadTextResource(relativePath, baseUrl) {
|
|
68
|
+
const url = new URL(relativePath, baseUrl);
|
|
69
|
+
const cacheKey = url.href;
|
|
70
|
+
const cached = textCache.get(cacheKey);
|
|
71
|
+
if (cached) {
|
|
72
|
+
return cached;
|
|
73
|
+
}
|
|
74
|
+
const promise = (async () => {
|
|
75
|
+
const response = await fetch(url);
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new Error(`Failed to load ${url.href}: ${response.status}`);
|
|
78
|
+
}
|
|
79
|
+
return response.text();
|
|
80
|
+
})();
|
|
81
|
+
textCache.set(cacheKey, promise);
|
|
82
|
+
return promise;
|
|
83
|
+
}
|
|
84
|
+
function applyShadowMount(root, options) {
|
|
85
|
+
root.innerHTML = "";
|
|
86
|
+
const style = document.createElement("style");
|
|
87
|
+
style.textContent = options.css;
|
|
88
|
+
root.appendChild(style);
|
|
89
|
+
const template = document.createElement("template");
|
|
90
|
+
template.innerHTML = options.html;
|
|
91
|
+
root.appendChild(template.content.cloneNode(true));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// packages/web-components/src/lib/shadow-base.ts
|
|
95
|
+
var SHADOW_ELEMENT_DIRS = {
|
|
96
|
+
"rd-accordion": "layout/accordion",
|
|
97
|
+
"rd-accordion-link-list": "layout/accordion-link-list",
|
|
98
|
+
"rd-link-list": "visual/link-list",
|
|
99
|
+
"rd-video-source": "visual/media/video-source",
|
|
100
|
+
"rd-equirect-viewport": "visual/media/equirect-viewport",
|
|
101
|
+
"rd-wasm-media": "wasm/wasm-media",
|
|
102
|
+
"rd-component-name": "catalog/component-name"
|
|
103
|
+
};
|
|
104
|
+
var tagToBaseUrl = /* @__PURE__ */ new Map();
|
|
105
|
+
var packageSrcRoot = null;
|
|
106
|
+
function normalizeDirectoryUrl(urlString) {
|
|
107
|
+
const url = new URL(urlString);
|
|
108
|
+
const lastSegment = url.pathname.split("/").pop() ?? "";
|
|
109
|
+
if (/\.[a-z0-9]+$/i.test(lastSegment)) {
|
|
110
|
+
url.pathname = url.pathname.replace(/\/[^/]+$/, "/");
|
|
111
|
+
} else if (!url.pathname.endsWith("/")) {
|
|
112
|
+
url.pathname = `${url.pathname}/`;
|
|
113
|
+
}
|
|
114
|
+
return url.href.endsWith("/") ? url.href : `${url.href}/`;
|
|
115
|
+
}
|
|
116
|
+
function registerShadowBase(tag, baseUrl) {
|
|
117
|
+
tagToBaseUrl.set(tag, normalizeDirectoryUrl(baseUrl));
|
|
118
|
+
}
|
|
119
|
+
function ensureShadowBase(tag) {
|
|
120
|
+
if (tagToBaseUrl.has(tag)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (!packageSrcRoot) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
`Shadow base not registered for ${tag}. Import '@rosettadash/web-components' once in app code, or add the web-components Jest setup in test config.`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
const dir = SHADOW_ELEMENT_DIRS[tag];
|
|
129
|
+
if (!dir) {
|
|
130
|
+
throw new Error(`Unknown shadow element tag: ${tag}`);
|
|
131
|
+
}
|
|
132
|
+
registerShadowBase(tag, new URL(`./${dir}/`, packageSrcRoot).href);
|
|
133
|
+
}
|
|
134
|
+
function getShadowBase(tag) {
|
|
135
|
+
const base = tagToBaseUrl.get(tag);
|
|
136
|
+
if (!base) {
|
|
137
|
+
throw new Error(`Shadow base not registered for ${tag}`);
|
|
138
|
+
}
|
|
139
|
+
return base;
|
|
140
|
+
}
|
|
141
|
+
async function loadShadowPairForTag(tag, htmlFile, cssFile) {
|
|
142
|
+
ensureShadowBase(tag);
|
|
143
|
+
const base = getShadowBase(tag);
|
|
144
|
+
const [html, css] = await Promise.all([
|
|
145
|
+
loadTextResource(htmlFile, base),
|
|
146
|
+
loadTextResource(cssFile, base)
|
|
147
|
+
]);
|
|
148
|
+
return { html, css };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// packages/web-components/src/visual/media/video-source/rd-video-source.ts
|
|
152
|
+
var DB_VIDEO_SOURCE_TAG = "rd-video-source";
|
|
153
|
+
var RdVideoSourceElement = class extends HTMLElement {
|
|
154
|
+
constructor() {
|
|
155
|
+
super(...arguments);
|
|
156
|
+
this.inputEl = null;
|
|
157
|
+
this.resourcesReady = null;
|
|
158
|
+
this.changeListener = null;
|
|
159
|
+
}
|
|
160
|
+
connectedCallback() {
|
|
161
|
+
if (!this.shadowRoot) {
|
|
162
|
+
this.attachShadow({ mode: "open" });
|
|
163
|
+
}
|
|
164
|
+
this.resourcesReady = this.mountShadow();
|
|
165
|
+
void this.resourcesReady.then(() => this.paint());
|
|
166
|
+
}
|
|
167
|
+
disconnectedCallback() {
|
|
168
|
+
if (this.inputEl && this.changeListener) {
|
|
169
|
+
this.inputEl.removeEventListener("change", this.changeListener);
|
|
170
|
+
}
|
|
171
|
+
this.changeListener = null;
|
|
172
|
+
this.inputEl = null;
|
|
173
|
+
}
|
|
174
|
+
setProperty(name, value) {
|
|
175
|
+
this[name] = value;
|
|
176
|
+
if (this.resourcesReady) {
|
|
177
|
+
void this.resourcesReady.then(() => this.paint());
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
whenReady() {
|
|
181
|
+
return this.resourcesReady ?? Promise.resolve();
|
|
182
|
+
}
|
|
183
|
+
get label() {
|
|
184
|
+
return readString(this.getAttribute("label"), "Video source");
|
|
185
|
+
}
|
|
186
|
+
get accept() {
|
|
187
|
+
return readString(this.getAttribute("accept"), "video/*");
|
|
188
|
+
}
|
|
189
|
+
get sourceWidth() {
|
|
190
|
+
return readNumber(this.getAttribute("source-width"), DEFAULT_EQUIRECT_SOURCE.width);
|
|
191
|
+
}
|
|
192
|
+
get sourceHeight() {
|
|
193
|
+
return readNumber(this.getAttribute("source-height"), DEFAULT_EQUIRECT_SOURCE.height);
|
|
194
|
+
}
|
|
195
|
+
async mountShadow() {
|
|
196
|
+
const root = this.shadowRoot;
|
|
197
|
+
if (!root || root.querySelector(".video-source")) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const pair = await loadShadowPairForTag(
|
|
201
|
+
DB_VIDEO_SOURCE_TAG,
|
|
202
|
+
"./rd-video-source.html",
|
|
203
|
+
"./rd-video-source.css"
|
|
204
|
+
);
|
|
205
|
+
applyShadowMount(root, pair);
|
|
206
|
+
this.inputEl = root.querySelector('[data-ref="input"]');
|
|
207
|
+
this.changeListener = () => this.handleFileSelected();
|
|
208
|
+
this.inputEl?.addEventListener("change", this.changeListener);
|
|
209
|
+
}
|
|
210
|
+
paint() {
|
|
211
|
+
const root = this.shadowRoot;
|
|
212
|
+
if (!root) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const labelEl = root.querySelector('[data-ref="label"]');
|
|
216
|
+
const metaEl = root.querySelector('[data-ref="meta"]');
|
|
217
|
+
if (labelEl) {
|
|
218
|
+
labelEl.textContent = this.label;
|
|
219
|
+
}
|
|
220
|
+
if (metaEl) {
|
|
221
|
+
metaEl.textContent = `${this.sourceWidth}\xD7${this.sourceHeight}`;
|
|
222
|
+
}
|
|
223
|
+
const input = root.querySelector('[data-ref="input"]');
|
|
224
|
+
if (input) {
|
|
225
|
+
input.accept = this.accept;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
handleFileSelected() {
|
|
229
|
+
const file = this.inputEl?.files?.[0];
|
|
230
|
+
if (!file) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const nameEl = this.shadowRoot?.querySelector('[data-ref="file-name"]');
|
|
234
|
+
if (nameEl) {
|
|
235
|
+
nameEl.textContent = file.name;
|
|
236
|
+
}
|
|
237
|
+
const metadata = {
|
|
238
|
+
name: file.name,
|
|
239
|
+
sourceWidth: this.sourceWidth,
|
|
240
|
+
sourceHeight: this.sourceHeight,
|
|
241
|
+
size: file.size
|
|
242
|
+
};
|
|
243
|
+
this.dispatchEvent(
|
|
244
|
+
new CustomEvent("video-file", {
|
|
245
|
+
detail: { file, metadata },
|
|
246
|
+
bubbles: true,
|
|
247
|
+
composed: true
|
|
248
|
+
})
|
|
249
|
+
);
|
|
250
|
+
this.dispatchEvent(
|
|
251
|
+
new CustomEvent("metadata", {
|
|
252
|
+
detail: metadata,
|
|
253
|
+
bubbles: true,
|
|
254
|
+
composed: true
|
|
255
|
+
})
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
RdVideoSourceElement.tagName = DB_VIDEO_SOURCE_TAG;
|
|
260
|
+
function registerRdVideoSource() {
|
|
261
|
+
ensureShadowBase(DB_VIDEO_SOURCE_TAG);
|
|
262
|
+
defineRosettaElement(RdVideoSourceElement.tagName, RdVideoSourceElement);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// packages/web-components/src/visual/media/equirect-viewport/rd-equirect-viewport.ts
|
|
266
|
+
var DB_EQUIRECT_VIEWPORT_TAG = "rd-equirect-viewport";
|
|
267
|
+
var RdEquirectViewportElement = class extends HTMLElement {
|
|
268
|
+
constructor() {
|
|
269
|
+
super(...arguments);
|
|
270
|
+
this.resourcesReady = null;
|
|
271
|
+
}
|
|
272
|
+
static get observedAttributes() {
|
|
273
|
+
return [
|
|
274
|
+
"label",
|
|
275
|
+
"preview-mode",
|
|
276
|
+
"source-width",
|
|
277
|
+
"source-height",
|
|
278
|
+
"crop-x",
|
|
279
|
+
"crop-y",
|
|
280
|
+
"crop-width",
|
|
281
|
+
"crop-height",
|
|
282
|
+
"output-width",
|
|
283
|
+
"output-height",
|
|
284
|
+
"yaw",
|
|
285
|
+
"pitch",
|
|
286
|
+
"horizontal-fov"
|
|
287
|
+
];
|
|
288
|
+
}
|
|
289
|
+
connectedCallback() {
|
|
290
|
+
if (!this.shadowRoot) {
|
|
291
|
+
this.attachShadow({ mode: "open" });
|
|
292
|
+
}
|
|
293
|
+
this.resourcesReady = this.mountShadow();
|
|
294
|
+
void this.resourcesReady.then(() => {
|
|
295
|
+
this.paint();
|
|
296
|
+
this.emitCropRegion();
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
attributeChangedCallback() {
|
|
300
|
+
if (this.shadowRoot && this.resourcesReady) {
|
|
301
|
+
void this.resourcesReady.then(() => {
|
|
302
|
+
this.paint();
|
|
303
|
+
this.emitCropRegion();
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
whenReady() {
|
|
308
|
+
return this.resourcesReady ?? Promise.resolve();
|
|
309
|
+
}
|
|
310
|
+
setProperty(name, value) {
|
|
311
|
+
const attrMap = {
|
|
312
|
+
previewMode: "preview-mode",
|
|
313
|
+
sourceWidth: "source-width",
|
|
314
|
+
sourceHeight: "source-height",
|
|
315
|
+
cropX: "crop-x",
|
|
316
|
+
cropY: "crop-y",
|
|
317
|
+
cropWidth: "crop-width",
|
|
318
|
+
cropHeight: "crop-height",
|
|
319
|
+
outputWidth: "output-width",
|
|
320
|
+
outputHeight: "output-height",
|
|
321
|
+
horizontalFov: "horizontal-fov"
|
|
322
|
+
};
|
|
323
|
+
const attr = attrMap[name] ?? name;
|
|
324
|
+
if (value === null || value === void 0) {
|
|
325
|
+
this.removeAttribute(attr);
|
|
326
|
+
} else {
|
|
327
|
+
this.setAttribute(attr, String(value));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
get previewMode() {
|
|
331
|
+
const mode = readString(this.getAttribute("preview-mode"), "flat-crop");
|
|
332
|
+
return mode === "rectilinear" ? "rectilinear" : "flat-crop";
|
|
333
|
+
}
|
|
334
|
+
get label() {
|
|
335
|
+
return readString(this.getAttribute("label"), "Equirect viewport");
|
|
336
|
+
}
|
|
337
|
+
get cropRegion() {
|
|
338
|
+
return {
|
|
339
|
+
cropX: this.cropX,
|
|
340
|
+
cropY: this.cropY,
|
|
341
|
+
cropWidth: this.cropWidth,
|
|
342
|
+
cropHeight: this.cropHeight,
|
|
343
|
+
outputWidth: this.outputWidth,
|
|
344
|
+
outputHeight: this.outputHeight,
|
|
345
|
+
yaw: this.yaw,
|
|
346
|
+
pitch: this.pitch,
|
|
347
|
+
horizontalFov: this.horizontalFov,
|
|
348
|
+
previewMode: this.previewMode,
|
|
349
|
+
filter: buildEquirectExtractFilter(this.previewMode, {
|
|
350
|
+
cropX: this.cropX,
|
|
351
|
+
cropY: this.cropY,
|
|
352
|
+
cropWidth: this.cropWidth,
|
|
353
|
+
cropHeight: this.cropHeight,
|
|
354
|
+
outputWidth: this.outputWidth,
|
|
355
|
+
outputHeight: this.outputHeight,
|
|
356
|
+
yaw: this.yaw,
|
|
357
|
+
pitch: this.pitch,
|
|
358
|
+
horizontalFov: this.horizontalFov
|
|
359
|
+
})
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
get sourceWidth() {
|
|
363
|
+
return readNumber(this.getAttribute("source-width"), DEFAULT_EQUIRECT_SOURCE.width);
|
|
364
|
+
}
|
|
365
|
+
get sourceHeight() {
|
|
366
|
+
return readNumber(this.getAttribute("source-height"), DEFAULT_EQUIRECT_SOURCE.height);
|
|
367
|
+
}
|
|
368
|
+
get cropX() {
|
|
369
|
+
return readNumber(this.getAttribute("crop-x"), DEFAULT_EQUIRECT_FLAT_CROP.cropX);
|
|
370
|
+
}
|
|
371
|
+
get cropY() {
|
|
372
|
+
return readNumber(this.getAttribute("crop-y"), DEFAULT_EQUIRECT_FLAT_CROP.cropY);
|
|
373
|
+
}
|
|
374
|
+
get cropWidth() {
|
|
375
|
+
return readNumber(this.getAttribute("crop-width"), DEFAULT_EQUIRECT_FLAT_CROP.cropWidth);
|
|
376
|
+
}
|
|
377
|
+
get cropHeight() {
|
|
378
|
+
return readNumber(this.getAttribute("crop-height"), DEFAULT_EQUIRECT_FLAT_CROP.cropHeight);
|
|
379
|
+
}
|
|
380
|
+
get outputWidth() {
|
|
381
|
+
return readNumber(this.getAttribute("output-width"), DEFAULT_EQUIRECT_FLAT_CROP.outputWidth);
|
|
382
|
+
}
|
|
383
|
+
get outputHeight() {
|
|
384
|
+
return readNumber(this.getAttribute("output-height"), DEFAULT_EQUIRECT_FLAT_CROP.outputHeight);
|
|
385
|
+
}
|
|
386
|
+
get yaw() {
|
|
387
|
+
return readNumber(this.getAttribute("yaw"), 0);
|
|
388
|
+
}
|
|
389
|
+
get pitch() {
|
|
390
|
+
return readNumber(this.getAttribute("pitch"), 0);
|
|
391
|
+
}
|
|
392
|
+
get horizontalFov() {
|
|
393
|
+
return readNumber(this.getAttribute("horizontal-fov"), 90);
|
|
394
|
+
}
|
|
395
|
+
async mountShadow() {
|
|
396
|
+
const root = this.shadowRoot;
|
|
397
|
+
if (!root || root.querySelector('[data-ref="root"]')) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const pair = await loadShadowPairForTag(
|
|
401
|
+
DB_EQUIRECT_VIEWPORT_TAG,
|
|
402
|
+
"./rd-equirect-viewport.html",
|
|
403
|
+
"./rd-equirect-viewport.css"
|
|
404
|
+
);
|
|
405
|
+
const panelCss = await loadTextResource("../../../lib/panel.css", getShadowBase(DB_EQUIRECT_VIEWPORT_TAG));
|
|
406
|
+
applyShadowMount(root, { html: pair.html, css: `${panelCss}
|
|
407
|
+
${pair.css}` });
|
|
408
|
+
}
|
|
409
|
+
paint() {
|
|
410
|
+
const root = this.shadowRoot;
|
|
411
|
+
if (!root) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
const cropLeftPct = this.cropX / this.sourceWidth * 100;
|
|
415
|
+
const cropTopPct = this.cropY / this.sourceHeight * 100;
|
|
416
|
+
const cropWidthPct = this.cropWidth / this.sourceWidth * 100;
|
|
417
|
+
const cropHeightPct = this.cropHeight / this.sourceHeight * 100;
|
|
418
|
+
const flatPreview = `
|
|
419
|
+
<div class="equirect-frame" style="aspect-ratio: ${this.sourceWidth} / ${this.sourceHeight}">
|
|
420
|
+
<div class="equirect-frame__crop" style="left:${cropLeftPct}%;top:${cropTopPct}%;width:${cropWidthPct}%;height:${cropHeightPct}%"></div>
|
|
421
|
+
</div>
|
|
422
|
+
`;
|
|
423
|
+
const rectilinearPreview = `
|
|
424
|
+
<div class="rectilinear-preview">
|
|
425
|
+
<div class="rectilinear-preview__cone" style="transform: rotateY(${this.yaw}deg) rotateX(${-this.pitch}deg)"></div>
|
|
426
|
+
<dl class="rectilinear-preview__meta">
|
|
427
|
+
<div><dt>Yaw</dt><dd>${this.yaw}\xB0</dd></div>
|
|
428
|
+
<div><dt>Pitch</dt><dd>${this.pitch}\xB0</dd></div>
|
|
429
|
+
<div><dt>FOV</dt><dd>${this.horizontalFov}\xB0</dd></div>
|
|
430
|
+
</dl>
|
|
431
|
+
</div>
|
|
432
|
+
`;
|
|
433
|
+
const labelEl = root.querySelector('[data-ref="label"]');
|
|
434
|
+
const modeEl = root.querySelector('[data-ref="mode"]');
|
|
435
|
+
if (labelEl) {
|
|
436
|
+
labelEl.textContent = this.label;
|
|
437
|
+
}
|
|
438
|
+
if (modeEl) {
|
|
439
|
+
modeEl.textContent = this.previewMode === "flat-crop" ? "Flat crop" : "Rectilinear";
|
|
440
|
+
}
|
|
441
|
+
const preview = root.querySelector('[data-ref="preview"]');
|
|
442
|
+
if (preview) {
|
|
443
|
+
preview.innerHTML = this.previewMode === "flat-crop" ? flatPreview : rectilinearPreview;
|
|
444
|
+
}
|
|
445
|
+
const filterEl = root.querySelector('[data-ref="filter"]');
|
|
446
|
+
if (filterEl) {
|
|
447
|
+
filterEl.textContent = String(this.cropRegion["filter"]);
|
|
448
|
+
}
|
|
449
|
+
const outputEl = root.querySelector('[data-ref="output"]');
|
|
450
|
+
if (outputEl) {
|
|
451
|
+
outputEl.textContent = `Output ${this.outputWidth}\xD7${this.outputHeight}`;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
emitCropRegion() {
|
|
455
|
+
this.dispatchEvent(
|
|
456
|
+
new CustomEvent("crop-region", {
|
|
457
|
+
detail: this.cropRegion,
|
|
458
|
+
bubbles: true,
|
|
459
|
+
composed: true
|
|
460
|
+
})
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
RdEquirectViewportElement.tagName = DB_EQUIRECT_VIEWPORT_TAG;
|
|
465
|
+
function registerRdEquirectViewport() {
|
|
466
|
+
ensureShadowBase(DB_EQUIRECT_VIEWPORT_TAG);
|
|
467
|
+
defineRosettaElement(RdEquirectViewportElement.tagName, RdEquirectViewportElement);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// packages/web-components/src/visual/media/index.ts
|
|
471
|
+
function registerRosettaDashMediaElements() {
|
|
472
|
+
registerRdVideoSource();
|
|
473
|
+
registerRdEquirectViewport();
|
|
474
|
+
}
|
|
475
|
+
export {
|
|
476
|
+
DB_EQUIRECT_VIEWPORT_TAG,
|
|
477
|
+
DB_VIDEO_SOURCE_TAG,
|
|
478
|
+
RdEquirectViewportElement,
|
|
479
|
+
RdVideoSourceElement,
|
|
480
|
+
registerRdEquirectViewport,
|
|
481
|
+
registerRdVideoSource,
|
|
482
|
+
registerRosettaDashMediaElements
|
|
483
|
+
};
|
|
484
|
+
//# sourceMappingURL=media.js.map
|