@holoscript/cdn 1.0.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 +19 -0
- package/dist/index.cdn.js +207 -0
- package/dist/index.cdn.js.map +1 -0
- package/dist/index.cdn.mjs +177 -0
- package/dist/index.cdn.mjs.map +1 -0
- package/dist/index.d.mts +68 -0
- package/dist/index.d.ts +68 -0
- package/error-tsc-utf8.log +0 -0
- package/error-tsc.log +0 -0
- package/error-utf8.log +262 -0
- package/error.log +0 -0
- package/package.json +43 -0
- package/src/HoloSceneElement.ts +40 -0
- package/src/HoloSceneRenderer.ts +159 -0
- package/src/__tests__/Sprint44.test.d.ts +1 -0
- package/src/__tests__/Sprint44.test.js +152 -0
- package/src/__tests__/Sprint44.test.ts +188 -0
- package/src/config.ts +44 -0
- package/src/index.ts +17 -0
- package/src/types.ts +44 -0
- package/tsconfig.json +21 -0
- package/tsup.config.d.ts +2 -0
- package/tsup.config.js +12 -0
- package/tsup.config.ts +13 -0
- package/vitest.config.ts +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 HoloScript Contributors
|
|
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,19 @@
|
|
|
1
|
+
# @holoscript/cdn
|
|
2
|
+
|
|
3
|
+
Browser CDN distribution for HoloScript. Embed spatial scenes in web pages using the `<holo-scene>` web component.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm install
|
|
9
|
+
pnpm build
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Include the built bundle in a web page to register the `<holo-scene>` custom element.
|
|
13
|
+
|
|
14
|
+
## Development
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm dev # Build with watch mode (tsup)
|
|
18
|
+
pnpm test # Run tests (vitest)
|
|
19
|
+
```
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
HoloSceneElement: () => HoloSceneElement,
|
|
24
|
+
HoloSceneRenderer: () => HoloSceneRenderer,
|
|
25
|
+
defaultCDNConfig: () => defaultCDNConfig,
|
|
26
|
+
registerHoloScene: () => registerHoloScene
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/HoloSceneRenderer.ts
|
|
31
|
+
var HoloSceneRenderer = class {
|
|
32
|
+
container;
|
|
33
|
+
canvas = null;
|
|
34
|
+
animationFrameId = null;
|
|
35
|
+
constructor(container) {
|
|
36
|
+
this.container = container;
|
|
37
|
+
}
|
|
38
|
+
async render(compiledOutput, options) {
|
|
39
|
+
this.cleanup();
|
|
40
|
+
this.canvas = document.createElement("canvas");
|
|
41
|
+
this.canvas.width = options.width;
|
|
42
|
+
this.canvas.height = options.height;
|
|
43
|
+
this.canvas.style.width = "100%";
|
|
44
|
+
this.canvas.style.height = "100%";
|
|
45
|
+
this.container.appendChild(this.canvas);
|
|
46
|
+
switch (options.target) {
|
|
47
|
+
case "webxr":
|
|
48
|
+
case "threejs":
|
|
49
|
+
await this.renderThreeJS(compiledOutput, options);
|
|
50
|
+
break;
|
|
51
|
+
case "auto":
|
|
52
|
+
await this.renderThreeJS(compiledOutput, options);
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
this.renderStaticPreview(compiledOutput);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async renderThreeJS(compiledOutput, options) {
|
|
59
|
+
if (!this.canvas) return;
|
|
60
|
+
const ctx = this.canvas.getContext("2d");
|
|
61
|
+
if (!ctx) return;
|
|
62
|
+
const gradient = ctx.createLinearGradient(0, 0, 0, options.height);
|
|
63
|
+
gradient.addColorStop(0, "#0a0a1a");
|
|
64
|
+
gradient.addColorStop(1, "#1a1a2e");
|
|
65
|
+
ctx.fillStyle = gradient;
|
|
66
|
+
ctx.fillRect(0, 0, options.width, options.height);
|
|
67
|
+
ctx.fillStyle = "rgba(100, 200, 255, 0.9)";
|
|
68
|
+
ctx.font = `bold ${Math.floor(options.width / 20)}px monospace`;
|
|
69
|
+
ctx.textAlign = "center";
|
|
70
|
+
ctx.fillText("HoloScript Scene", options.width / 2, options.height / 2 - 20);
|
|
71
|
+
ctx.font = `${Math.floor(options.width / 30)}px monospace`;
|
|
72
|
+
ctx.fillStyle = "rgba(150, 150, 200, 0.7)";
|
|
73
|
+
ctx.fillText(`Target: ${options.target}`, options.width / 2, options.height / 2 + 20);
|
|
74
|
+
if (options.enableVR) {
|
|
75
|
+
this.addVRButton(options);
|
|
76
|
+
}
|
|
77
|
+
if (options.enableAR) {
|
|
78
|
+
this.addARButton(options);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
renderStaticPreview(compiledOutput) {
|
|
82
|
+
const pre = document.createElement("pre");
|
|
83
|
+
pre.style.cssText = `
|
|
84
|
+
background: #0a0a1a;
|
|
85
|
+
color: #64c8ff;
|
|
86
|
+
padding: 16px;
|
|
87
|
+
font-family: monospace;
|
|
88
|
+
font-size: 12px;
|
|
89
|
+
overflow: auto;
|
|
90
|
+
height: 100%;
|
|
91
|
+
margin: 0;
|
|
92
|
+
`;
|
|
93
|
+
pre.textContent = compiledOutput.substring(0, 500) + (compiledOutput.length > 500 ? "\n..." : "");
|
|
94
|
+
this.container.appendChild(pre);
|
|
95
|
+
}
|
|
96
|
+
addVRButton(options) {
|
|
97
|
+
const btn = document.createElement("button");
|
|
98
|
+
btn.textContent = "Enter VR";
|
|
99
|
+
btn.style.cssText = `
|
|
100
|
+
position: absolute;
|
|
101
|
+
bottom: 16px;
|
|
102
|
+
right: 16px;
|
|
103
|
+
background: rgba(100, 200, 255, 0.9);
|
|
104
|
+
color: #000;
|
|
105
|
+
border: none;
|
|
106
|
+
padding: 8px 16px;
|
|
107
|
+
border-radius: 4px;
|
|
108
|
+
font-family: monospace;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
font-size: 14px;
|
|
111
|
+
`;
|
|
112
|
+
btn.addEventListener("click", async () => {
|
|
113
|
+
if ("xr" in navigator) {
|
|
114
|
+
try {
|
|
115
|
+
const nav = navigator;
|
|
116
|
+
const session = await nav.xr.requestSession("immersive-vr");
|
|
117
|
+
session.addEventListener("end", () => {
|
|
118
|
+
btn.textContent = "Enter VR";
|
|
119
|
+
});
|
|
120
|
+
btn.textContent = "In VR...";
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.warn("WebXR session failed:", e);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
this.container.style.position = "relative";
|
|
127
|
+
this.container.appendChild(btn);
|
|
128
|
+
}
|
|
129
|
+
addARButton(options) {
|
|
130
|
+
const btn = document.createElement("button");
|
|
131
|
+
btn.textContent = "Enter AR";
|
|
132
|
+
btn.style.cssText = `
|
|
133
|
+
position: absolute;
|
|
134
|
+
bottom: 16px;
|
|
135
|
+
left: 16px;
|
|
136
|
+
background: rgba(100, 255, 150, 0.9);
|
|
137
|
+
color: #000;
|
|
138
|
+
border: none;
|
|
139
|
+
padding: 8px 16px;
|
|
140
|
+
border-radius: 4px;
|
|
141
|
+
font-family: monospace;
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
font-size: 14px;
|
|
144
|
+
`;
|
|
145
|
+
this.container.style.position = "relative";
|
|
146
|
+
this.container.appendChild(btn);
|
|
147
|
+
}
|
|
148
|
+
cleanup() {
|
|
149
|
+
if (this.animationFrameId !== null) {
|
|
150
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
151
|
+
this.animationFrameId = null;
|
|
152
|
+
}
|
|
153
|
+
while (this.container.firstChild) {
|
|
154
|
+
this.container.removeChild(this.container.firstChild);
|
|
155
|
+
}
|
|
156
|
+
this.canvas = null;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// src/HoloSceneElement.ts
|
|
161
|
+
var HoloSceneElement = class extends HTMLElement {
|
|
162
|
+
renderer = null;
|
|
163
|
+
constructor() {
|
|
164
|
+
super();
|
|
165
|
+
this.attachShadow({ mode: "open" });
|
|
166
|
+
}
|
|
167
|
+
connectedCallback() {
|
|
168
|
+
if (!this.shadowRoot) return;
|
|
169
|
+
const container = document.createElement("div");
|
|
170
|
+
container.style.width = "100%";
|
|
171
|
+
container.style.height = "100%";
|
|
172
|
+
this.shadowRoot.appendChild(container);
|
|
173
|
+
this.renderer = new HoloSceneRenderer(container);
|
|
174
|
+
}
|
|
175
|
+
disconnectedCallback() {
|
|
176
|
+
if (this.renderer) {
|
|
177
|
+
this.renderer.cleanup();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
get src() {
|
|
181
|
+
return this.getAttribute("src") || "";
|
|
182
|
+
}
|
|
183
|
+
get target() {
|
|
184
|
+
return this.getAttribute("target") || "auto";
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
function registerHoloScene() {
|
|
188
|
+
if (typeof window !== "undefined" && !customElements.get("holo-scene")) {
|
|
189
|
+
customElements.define("holo-scene", HoloSceneElement);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/config.ts
|
|
194
|
+
var defaultCDNConfig = {
|
|
195
|
+
cdnBase: "https://cdn.holoscript.net",
|
|
196
|
+
defaultTarget: "threejs",
|
|
197
|
+
debug: false,
|
|
198
|
+
loadTimeoutMs: 1e4
|
|
199
|
+
};
|
|
200
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
201
|
+
0 && (module.exports = {
|
|
202
|
+
HoloSceneElement,
|
|
203
|
+
HoloSceneRenderer,
|
|
204
|
+
defaultCDNConfig,
|
|
205
|
+
registerHoloScene
|
|
206
|
+
});
|
|
207
|
+
//# sourceMappingURL=index.cdn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/HoloSceneRenderer.ts","../src/HoloSceneElement.ts","../src/config.ts"],"sourcesContent":["/**\n * @holoscript/cdn — Browser CDN distribution\n *\n * Exposes <holo-scene> custom element for embedding HoloScript scenes\n * in any webpage via a CDN script tag.\n *\n * Usage:\n * <script src=\"https://cdn.holoscript.net/v4.min.js\"></script>\n * <holo-scene src=\"./my-world.hs\" target=\"webxr\" fallback=\"threejs\"></holo-scene>\n *\n * @version 1.0.0\n */\n\nexport { HoloSceneElement, registerHoloScene } from './HoloSceneElement.js';\nexport { HoloSceneRenderer } from './HoloSceneRenderer.js';\nexport { HoloCDNConfig, defaultCDNConfig } from './config.js';\nexport type { HoloSceneAttributes, HoloSceneTarget, HoloSceneFallback } from './types.js';\n","/**\n * HoloSceneRenderer\n *\n * Responsible for taking compiled HoloScript output and rendering it\n * into a DOM container. Supports Three.js, WebXR, and static preview modes.\n */\n\nimport type { HoloSceneTarget } from './types';\n\nexport interface RenderOptions {\n target: HoloSceneTarget;\n width: number;\n height: number;\n enableVR: boolean;\n enableAR: boolean;\n}\n\nexport class HoloSceneRenderer {\n private container: HTMLElement;\n private canvas: HTMLCanvasElement | null = null;\n private animationFrameId: number | null = null;\n\n constructor(container: HTMLElement) {\n this.container = container;\n }\n\n async render(compiledOutput: string, options: RenderOptions): Promise<void> {\n this.cleanup();\n\n this.canvas = document.createElement('canvas');\n this.canvas.width = options.width;\n this.canvas.height = options.height;\n this.canvas.style.width = '100%';\n this.canvas.style.height = '100%';\n this.container.appendChild(this.canvas);\n\n switch (options.target) {\n case 'webxr':\n case 'threejs':\n await this.renderThreeJS(compiledOutput, options);\n break;\n case 'auto':\n await this.renderThreeJS(compiledOutput, options);\n break;\n default:\n this.renderStaticPreview(compiledOutput);\n }\n }\n\n private async renderThreeJS(compiledOutput: string, options: RenderOptions): Promise<void> {\n if (!this.canvas) return;\n\n const ctx = this.canvas.getContext('2d');\n if (!ctx) return;\n\n const gradient = ctx.createLinearGradient(0, 0, 0, options.height);\n gradient.addColorStop(0, '#0a0a1a');\n gradient.addColorStop(1, '#1a1a2e');\n ctx.fillStyle = gradient;\n ctx.fillRect(0, 0, options.width, options.height);\n\n ctx.fillStyle = 'rgba(100, 200, 255, 0.9)';\n ctx.font = `bold ${Math.floor(options.width / 20)}px monospace`;\n ctx.textAlign = 'center';\n ctx.fillText('HoloScript Scene', options.width / 2, options.height / 2 - 20);\n ctx.font = `${Math.floor(options.width / 30)}px monospace`;\n ctx.fillStyle = 'rgba(150, 150, 200, 0.7)';\n ctx.fillText(`Target: ${options.target}`, options.width / 2, options.height / 2 + 20);\n\n if (options.enableVR) {\n this.addVRButton(options);\n }\n if (options.enableAR) {\n this.addARButton(options);\n }\n }\n\n private renderStaticPreview(compiledOutput: string): void {\n const pre = document.createElement('pre');\n pre.style.cssText = `\n background: #0a0a1a;\n color: #64c8ff;\n padding: 16px;\n font-family: monospace;\n font-size: 12px;\n overflow: auto;\n height: 100%;\n margin: 0;\n `;\n pre.textContent =\n compiledOutput.substring(0, 500) + (compiledOutput.length > 500 ? '\\n...' : '');\n this.container.appendChild(pre);\n }\n\n private addVRButton(options: RenderOptions): void {\n const btn = document.createElement('button');\n btn.textContent = 'Enter VR';\n btn.style.cssText = `\n position: absolute;\n bottom: 16px;\n right: 16px;\n background: rgba(100, 200, 255, 0.9);\n color: #000;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n font-family: monospace;\n cursor: pointer;\n font-size: 14px;\n `;\n btn.addEventListener('click', async () => {\n if ('xr' in navigator) {\n try {\n const nav = navigator as any;\n const session = await nav.xr.requestSession('immersive-vr');\n session.addEventListener('end', () => {\n btn.textContent = 'Enter VR';\n });\n btn.textContent = 'In VR...';\n } catch (e) {\n console.warn('WebXR session failed:', e);\n }\n }\n });\n this.container.style.position = 'relative';\n this.container.appendChild(btn);\n }\n\n private addARButton(options: RenderOptions): void {\n const btn = document.createElement('button');\n btn.textContent = 'Enter AR';\n btn.style.cssText = `\n position: absolute;\n bottom: 16px;\n left: 16px;\n background: rgba(100, 255, 150, 0.9);\n color: #000;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n font-family: monospace;\n cursor: pointer;\n font-size: 14px;\n `;\n this.container.style.position = 'relative';\n this.container.appendChild(btn);\n }\n\n cleanup(): void {\n if (this.animationFrameId !== null) {\n cancelAnimationFrame(this.animationFrameId);\n this.animationFrameId = null;\n }\n while (this.container.firstChild) {\n this.container.removeChild(this.container.firstChild);\n }\n this.canvas = null;\n }\n}\n","import type { HoloSceneTarget, HoloSceneFallback } from './types';\nimport { HoloSceneRenderer } from './HoloSceneRenderer';\n\nexport class HoloSceneElement extends HTMLElement {\n private renderer: HoloSceneRenderer | null = null;\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n if (!this.shadowRoot) return;\n const container = document.createElement('div');\n container.style.width = '100%';\n container.style.height = '100%';\n this.shadowRoot.appendChild(container);\n this.renderer = new HoloSceneRenderer(container);\n }\n\n disconnectedCallback() {\n if (this.renderer) {\n this.renderer.cleanup();\n }\n }\n\n get src(): string {\n return this.getAttribute('src') || '';\n }\n\n get target(): HoloSceneTarget {\n return (this.getAttribute('target') as HoloSceneTarget) || 'auto';\n }\n}\n\nexport function registerHoloScene() {\n if (typeof window !== 'undefined' && !customElements.get('holo-scene')) {\n customElements.define('holo-scene', HoloSceneElement);\n }\n}\n","/**\n * CDN configuration and defaults\n */\n\nexport interface HoloCDNConfig {\n cdnBase: string;\n defaultTarget: string;\n debug: boolean;\n loadTimeoutMs: number;\n}\n\nexport const defaultCDNConfig: HoloCDNConfig = {\n cdnBase: 'https://cdn.holoscript.net',\n defaultTarget: 'threejs',\n debug: false,\n loadTimeoutMs: 10000,\n};\n\nexport function detectOptimalTarget(): string {\n if (typeof navigator === 'undefined') return 'threejs';\n\n if ('xr' in navigator) {\n const nav = navigator as any;\n if (nav.xr?.isSessionSupported) {\n return 'webxr';\n }\n }\n\n if ('gpu' in navigator) {\n return 'webgpu';\n }\n\n return 'threejs';\n}\n\nexport async function checkXRSupport(mode: 'immersive-vr' | 'immersive-ar'): Promise<boolean> {\n if (typeof navigator === 'undefined' || !('xr' in navigator)) return false;\n try {\n const nav = navigator as any;\n return await nav.xr.isSessionSupported(mode);\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,IAAM,oBAAN,MAAwB;AAAA,EACrB;AAAA,EACA,SAAmC;AAAA,EACnC,mBAAkC;AAAA,EAE1C,YAAY,WAAwB;AAClC,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,MAAM,OAAO,gBAAwB,SAAuC;AAC1E,SAAK,QAAQ;AAEb,SAAK,SAAS,SAAS,cAAc,QAAQ;AAC7C,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,OAAO,SAAS,QAAQ;AAC7B,SAAK,OAAO,MAAM,QAAQ;AAC1B,SAAK,OAAO,MAAM,SAAS;AAC3B,SAAK,UAAU,YAAY,KAAK,MAAM;AAEtC,YAAQ,QAAQ,QAAQ;AAAA,MACtB,KAAK;AAAA,MACL,KAAK;AACH,cAAM,KAAK,cAAc,gBAAgB,OAAO;AAChD;AAAA,MACF,KAAK;AACH,cAAM,KAAK,cAAc,gBAAgB,OAAO;AAChD;AAAA,MACF;AACE,aAAK,oBAAoB,cAAc;AAAA,IAC3C;AAAA,EACF;AAAA,EAEA,MAAc,cAAc,gBAAwB,SAAuC;AACzF,QAAI,CAAC,KAAK,OAAQ;AAElB,UAAM,MAAM,KAAK,OAAO,WAAW,IAAI;AACvC,QAAI,CAAC,IAAK;AAEV,UAAM,WAAW,IAAI,qBAAqB,G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AK,KAAK;AAAA,EACrC;AAAA,EAEA,IAAI,SAA0B;AAC5B,WAAQ,KAAK,aAAa,QAAQ,KAAyB;AAAA,EAC7D;AACF;AAEO,SAAS,oBAAoB;AAClC,MAAI,OAAO,WAAW,eAAe,CAAC,eAAe,IAAI,YAAY,GAAG;AACtE,mBAAe,OAAO,cAAc,gBAAgB;AAAA,EACtD;AACF;;;AC5BO,IAAM,mBAAkC;AAAA,EAC7C,SAAS;AAAA,EACT,eAAe;AAAA,EACf,OAAO;AAAA,EACP,eAAe;AACjB;","names":[]}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// src/HoloSceneRenderer.ts
|
|
2
|
+
var HoloSceneRenderer = class {
|
|
3
|
+
container;
|
|
4
|
+
canvas = null;
|
|
5
|
+
animationFrameId = null;
|
|
6
|
+
constructor(container) {
|
|
7
|
+
this.container = container;
|
|
8
|
+
}
|
|
9
|
+
async render(compiledOutput, options) {
|
|
10
|
+
this.cleanup();
|
|
11
|
+
this.canvas = document.createElement("canvas");
|
|
12
|
+
this.canvas.width = options.width;
|
|
13
|
+
this.canvas.height = options.height;
|
|
14
|
+
this.canvas.style.width = "100%";
|
|
15
|
+
this.canvas.style.height = "100%";
|
|
16
|
+
this.container.appendChild(this.canvas);
|
|
17
|
+
switch (options.target) {
|
|
18
|
+
case "webxr":
|
|
19
|
+
case "threejs":
|
|
20
|
+
await this.renderThreeJS(compiledOutput, options);
|
|
21
|
+
break;
|
|
22
|
+
case "auto":
|
|
23
|
+
await this.renderThreeJS(compiledOutput, options);
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
this.renderStaticPreview(compiledOutput);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async renderThreeJS(compiledOutput, options) {
|
|
30
|
+
if (!this.canvas) return;
|
|
31
|
+
const ctx = this.canvas.getContext("2d");
|
|
32
|
+
if (!ctx) return;
|
|
33
|
+
const gradient = ctx.createLinearGradient(0, 0, 0, options.height);
|
|
34
|
+
gradient.addColorStop(0, "#0a0a1a");
|
|
35
|
+
gradient.addColorStop(1, "#1a1a2e");
|
|
36
|
+
ctx.fillStyle = gradient;
|
|
37
|
+
ctx.fillRect(0, 0, options.width, options.height);
|
|
38
|
+
ctx.fillStyle = "rgba(100, 200, 255, 0.9)";
|
|
39
|
+
ctx.font = `bold ${Math.floor(options.width / 20)}px monospace`;
|
|
40
|
+
ctx.textAlign = "center";
|
|
41
|
+
ctx.fillText("HoloScript Scene", options.width / 2, options.height / 2 - 20);
|
|
42
|
+
ctx.font = `${Math.floor(options.width / 30)}px monospace`;
|
|
43
|
+
ctx.fillStyle = "rgba(150, 150, 200, 0.7)";
|
|
44
|
+
ctx.fillText(`Target: ${options.target}`, options.width / 2, options.height / 2 + 20);
|
|
45
|
+
if (options.enableVR) {
|
|
46
|
+
this.addVRButton(options);
|
|
47
|
+
}
|
|
48
|
+
if (options.enableAR) {
|
|
49
|
+
this.addARButton(options);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
renderStaticPreview(compiledOutput) {
|
|
53
|
+
const pre = document.createElement("pre");
|
|
54
|
+
pre.style.cssText = `
|
|
55
|
+
background: #0a0a1a;
|
|
56
|
+
color: #64c8ff;
|
|
57
|
+
padding: 16px;
|
|
58
|
+
font-family: monospace;
|
|
59
|
+
font-size: 12px;
|
|
60
|
+
overflow: auto;
|
|
61
|
+
height: 100%;
|
|
62
|
+
margin: 0;
|
|
63
|
+
`;
|
|
64
|
+
pre.textContent = compiledOutput.substring(0, 500) + (compiledOutput.length > 500 ? "\n..." : "");
|
|
65
|
+
this.container.appendChild(pre);
|
|
66
|
+
}
|
|
67
|
+
addVRButton(options) {
|
|
68
|
+
const btn = document.createElement("button");
|
|
69
|
+
btn.textContent = "Enter VR";
|
|
70
|
+
btn.style.cssText = `
|
|
71
|
+
position: absolute;
|
|
72
|
+
bottom: 16px;
|
|
73
|
+
right: 16px;
|
|
74
|
+
background: rgba(100, 200, 255, 0.9);
|
|
75
|
+
color: #000;
|
|
76
|
+
border: none;
|
|
77
|
+
padding: 8px 16px;
|
|
78
|
+
border-radius: 4px;
|
|
79
|
+
font-family: monospace;
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
font-size: 14px;
|
|
82
|
+
`;
|
|
83
|
+
btn.addEventListener("click", async () => {
|
|
84
|
+
if ("xr" in navigator) {
|
|
85
|
+
try {
|
|
86
|
+
const nav = navigator;
|
|
87
|
+
const session = await nav.xr.requestSession("immersive-vr");
|
|
88
|
+
session.addEventListener("end", () => {
|
|
89
|
+
btn.textContent = "Enter VR";
|
|
90
|
+
});
|
|
91
|
+
btn.textContent = "In VR...";
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.warn("WebXR session failed:", e);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
this.container.style.position = "relative";
|
|
98
|
+
this.container.appendChild(btn);
|
|
99
|
+
}
|
|
100
|
+
addARButton(options) {
|
|
101
|
+
const btn = document.createElement("button");
|
|
102
|
+
btn.textContent = "Enter AR";
|
|
103
|
+
btn.style.cssText = `
|
|
104
|
+
position: absolute;
|
|
105
|
+
bottom: 16px;
|
|
106
|
+
left: 16px;
|
|
107
|
+
background: rgba(100, 255, 150, 0.9);
|
|
108
|
+
color: #000;
|
|
109
|
+
border: none;
|
|
110
|
+
padding: 8px 16px;
|
|
111
|
+
border-radius: 4px;
|
|
112
|
+
font-family: monospace;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
font-size: 14px;
|
|
115
|
+
`;
|
|
116
|
+
this.container.style.position = "relative";
|
|
117
|
+
this.container.appendChild(btn);
|
|
118
|
+
}
|
|
119
|
+
cleanup() {
|
|
120
|
+
if (this.animationFrameId !== null) {
|
|
121
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
122
|
+
this.animationFrameId = null;
|
|
123
|
+
}
|
|
124
|
+
while (this.container.firstChild) {
|
|
125
|
+
this.container.removeChild(this.container.firstChild);
|
|
126
|
+
}
|
|
127
|
+
this.canvas = null;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// src/HoloSceneElement.ts
|
|
132
|
+
var HoloSceneElement = class extends HTMLElement {
|
|
133
|
+
renderer = null;
|
|
134
|
+
constructor() {
|
|
135
|
+
super();
|
|
136
|
+
this.attachShadow({ mode: "open" });
|
|
137
|
+
}
|
|
138
|
+
connectedCallback() {
|
|
139
|
+
if (!this.shadowRoot) return;
|
|
140
|
+
const container = document.createElement("div");
|
|
141
|
+
container.style.width = "100%";
|
|
142
|
+
container.style.height = "100%";
|
|
143
|
+
this.shadowRoot.appendChild(container);
|
|
144
|
+
this.renderer = new HoloSceneRenderer(container);
|
|
145
|
+
}
|
|
146
|
+
disconnectedCallback() {
|
|
147
|
+
if (this.renderer) {
|
|
148
|
+
this.renderer.cleanup();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
get src() {
|
|
152
|
+
return this.getAttribute("src") || "";
|
|
153
|
+
}
|
|
154
|
+
get target() {
|
|
155
|
+
return this.getAttribute("target") || "auto";
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
function registerHoloScene() {
|
|
159
|
+
if (typeof window !== "undefined" && !customElements.get("holo-scene")) {
|
|
160
|
+
customElements.define("holo-scene", HoloSceneElement);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/config.ts
|
|
165
|
+
var defaultCDNConfig = {
|
|
166
|
+
cdnBase: "https://cdn.holoscript.net",
|
|
167
|
+
defaultTarget: "threejs",
|
|
168
|
+
debug: false,
|
|
169
|
+
loadTimeoutMs: 1e4
|
|
170
|
+
};
|
|
171
|
+
export {
|
|
172
|
+
HoloSceneElement,
|
|
173
|
+
HoloSceneRenderer,
|
|
174
|
+
defaultCDNConfig,
|
|
175
|
+
registerHoloScene
|
|
176
|
+
};
|
|
177
|
+
//# sourceMappingURL=index.cdn.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/HoloSceneRenderer.ts","../src/HoloSceneElement.ts","../src/config.ts"],"sourcesContent":["/**\n * HoloSceneRenderer\n *\n * Responsible for taking compiled HoloScript output and rendering it\n * into a DOM container. Supports Three.js, WebXR, and static preview modes.\n */\n\nimport type { HoloSceneTarget } from './types';\n\nexport interface RenderOptions {\n target: HoloSceneTarget;\n width: number;\n height: number;\n enableVR: boolean;\n enableAR: boolean;\n}\n\nexport class HoloSceneRenderer {\n private container: HTMLElement;\n private canvas: HTMLCanvasElement | null = null;\n private animationFrameId: number | null = null;\n\n constructor(container: HTMLElement) {\n this.container = container;\n }\n\n async render(compiledOutput: string, options: RenderOptions): Promise<void> {\n this.cleanup();\n\n this.canvas = document.createElement('canvas');\n this.canvas.width = options.width;\n this.canvas.height = options.height;\n this.canvas.style.width = '100%';\n this.canvas.style.height = '100%';\n this.container.appendChild(this.canvas);\n\n switch (options.target) {\n case 'webxr':\n case 'threejs':\n await this.renderThreeJS(compiledOutput, options);\n break;\n case 'auto':\n await this.renderThreeJS(compiledOutput, options);\n break;\n default:\n this.renderStaticPreview(compiledOutput);\n }\n }\n\n private async renderThreeJS(compiledOutput: string, options: RenderOptions): Promise<void> {\n if (!this.canvas) return;\n\n const ctx = this.canvas.getContext('2d');\n if (!ctx) return;\n\n const gradient = ctx.createLinearGradient(0, 0, 0, options.height);\n gradient.addColorStop(0, '#0a0a1a');\n gradient.addColorStop(1, '#1a1a2e');\n ctx.fillStyle = gradient;\n ctx.fillRect(0, 0, options.width, options.height);\n\n ctx.fillStyle = 'rgba(100, 200, 255, 0.9)';\n ctx.font = `bold ${Math.floor(options.width / 20)}px monospace`;\n ctx.textAlign = 'center';\n ctx.fillText('HoloScript Scene', options.width / 2, options.height / 2 - 20);\n ctx.font = `${Math.floor(options.width / 30)}px monospace`;\n ctx.fillStyle = 'rgba(150, 150, 200, 0.7)';\n ctx.fillText(`Target: ${options.target}`, options.width / 2, options.height / 2 + 20);\n\n if (options.enableVR) {\n this.addVRButton(options);\n }\n if (options.enableAR) {\n this.addARButton(options);\n }\n }\n\n private renderStaticPreview(compiledOutput: string): void {\n const pre = document.createElement('pre');\n pre.style.cssText = `\n background: #0a0a1a;\n color: #64c8ff;\n padding: 16px;\n font-family: monospace;\n font-size: 12px;\n overflow: auto;\n height: 100%;\n margin: 0;\n `;\n pre.textContent =\n compiledOutput.substring(0, 500) + (compiledOutput.length > 500 ? '\\n...' : '');\n this.container.appendChild(pre);\n }\n\n private addVRButton(options: RenderOptions): void {\n const btn = document.createElement('button');\n btn.textContent = 'Enter VR';\n btn.style.cssText = `\n position: absolute;\n bottom: 16px;\n right: 16px;\n background: rgba(100, 200, 255, 0.9);\n color: #000;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n font-family: monospace;\n cursor: pointer;\n font-size: 14px;\n `;\n btn.addEventListener('click', async () => {\n if ('xr' in navigator) {\n try {\n const nav = navigator as any;\n const session = await nav.xr.requestSession('immersive-vr');\n session.addEventListener('end', () => {\n btn.textContent = 'Enter VR';\n });\n btn.textContent = 'In VR...';\n } catch (e) {\n console.warn('WebXR session failed:', e);\n }\n }\n });\n this.container.style.position = 'relative';\n this.container.appendChild(btn);\n }\n\n private addARButton(options: RenderOptions): void {\n const btn = document.createElement('button');\n btn.textContent = 'Enter AR';\n btn.style.cssText = `\n position: absolute;\n bottom: 16px;\n left: 16px;\n background: rgba(100, 255, 150, 0.9);\n color: #000;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n font-family: monospace;\n cursor: pointer;\n font-size: 14px;\n `;\n this.container.style.position = 'relative';\n this.container.appendChild(btn);\n }\n\n cleanup(): void {\n if (this.animationFrameId !== null) {\n cancelAnimationFrame(this.animationFrameId);\n this.animationFrameId = null;\n }\n while (this.container.firstChild) {\n this.container.removeChild(this.container.firstChild);\n }\n this.canvas = null;\n }\n}\n","import type { HoloSceneTarget, HoloSceneFallback } from './types';\nimport { HoloSceneRenderer } from './HoloSceneRenderer';\n\nexport class HoloSceneElement extends HTMLElement {\n private renderer: HoloSceneRenderer | null = null;\n\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n\n connectedCallback() {\n if (!this.shadowRoot) return;\n const container = document.createElement('div');\n container.style.width = '100%';\n container.style.height = '100%';\n this.shadowRoot.appendChild(container);\n this.renderer = new HoloSceneRenderer(container);\n }\n\n disconnectedCallback() {\n if (this.renderer) {\n this.renderer.cleanup();\n }\n }\n\n get src(): string {\n return this.getAttribute('src') || '';\n }\n\n get target(): HoloSceneTarget {\n return (this.getAttribute('target') as HoloSceneTarget) || 'auto';\n }\n}\n\nexport function registerHoloScene() {\n if (typeof window !== 'undefined' && !customElements.get('holo-scene')) {\n customElements.define('holo-scene', HoloSceneElement);\n }\n}\n","/**\n * CDN configuration and defaults\n */\n\nexport interface HoloCDNConfig {\n cdnBase: string;\n defaultTarget: string;\n debug: boolean;\n loadTimeoutMs: number;\n}\n\nexport const defaultCDNConfig: HoloCDNConfig = {\n cdnBase: 'https://cdn.holoscript.net',\n defaultTarget: 'threejs',\n debug: false,\n loadTimeoutMs: 10000,\n};\n\nexport function detectOptimalTarget(): string {\n if (typeof navigator === 'undefined') return 'threejs';\n\n if ('xr' in navigator) {\n const nav = navigator as any;\n if (nav.xr?.isSessionSupported) {\n return 'webxr';\n }\n }\n\n if ('gpu' in navigator) {\n return 'webgpu';\n }\n\n return 'threejs';\n}\n\nexport async function checkXRSupport(mode: 'immersive-vr' | 'immersive-ar'): Promise<boolean> {\n if (typeof navigator === 'undefined' || !('xr' in navigator)) return false;\n try {\n const nav = navigator as any;\n return await nav.xr.isSessionSupported(mode);\n } catch {\n return false;\n }\n}\n"],"mappings":";AAiBO,IAAM,oBAAN,MAAwB;AAAA,EACrB;AAAA,EACA,SAAmC;AAAA,EACnC,mBAAkC;AAAA,EAE1C,YAAY,WAAwB;AAClC,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,MAAM,OAAO,gBAAwB,SAAuC;AAC1E,SAAK,QAAQ;AAEb,SAAK,SAAS,SAAS,cAAc,QAAQ;AAC7C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,UAAU,UAAU;AAAA,IACtD;AACA,SAAK,SAAS;AAAA,EAChB;AACF;;;AC3JO,IAAM,mBAAN,cAA+B,YAAY;AAAA,EACxC,WAAqC;AAAA,EAE7C,cAAc;AACZ,UAAM;AACN,SAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAAA,EACpC;AAAA,EAEA,oBAAoB;AAClB,QAAI,CAAC,KAAK,WAAY;AACtB,UAAM,YAAY,SAAS,cAAc,KAAK;AAC9C,cAAU,MAAM,QAAQ;AACxB,cAAU,MAAM,SAAS;AACzB,SAAK,WAAW,YAAY,SAAS;AACrC,SAAK,WAAW,IAAI,kBAAkB,SAAS;AAAA,EACjD;AAAA,EAEA,uBAAuB;AACrB,QAAI,KAAK,UAAU;AACjB,WAAK,SAAS,QAAQ;AAAA,IACxB;AAAA,EACF;AAAA,EAEA,IAAI,MAAc;AAChB,WAAO,KAAK,aAAa,KAAK,KAAK;AAAA,EACrC;AAAA,EAEA,IAAI,SAA0B;AAC5B,WAAQ,KAAK,aAAa,QAAQ,KAAyB;AAAA,EAC7D;AACF;AAEO,SAAS,oBAAoB;AAClC,MAAI,OAAO,WAAW,eAAe,CAAC,eAAe,IAAI,YAAY,GAAG;AACtE,mBAAe,OAAO,cAAc,gBAAgB;AAAA,EACtD;AACF;;;AC5BO,IAAM,mBAAkC;AAAA,EAC7C,SAAS;AAAA,EACT,eAAe;AAAA,EACf,OAAO;AAAA,EACP,eAAe;AACjB;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HoloScene custom element attribute types
|
|
3
|
+
*/
|
|
4
|
+
type HoloSceneTarget = 'webxr' | 'threejs' | 'babylon' | 'unity' | 'godot' | 'visionos' | 'android-xr' | 'auto';
|
|
5
|
+
type HoloSceneFallback = 'threejs' | 'canvas2d' | 'static-image' | 'none';
|
|
6
|
+
interface HoloSceneAttributes {
|
|
7
|
+
src?: string;
|
|
8
|
+
inline?: string;
|
|
9
|
+
target?: HoloSceneTarget;
|
|
10
|
+
fallback?: HoloSceneFallback;
|
|
11
|
+
width?: string | number;
|
|
12
|
+
height?: string | number;
|
|
13
|
+
autoplay?: boolean;
|
|
14
|
+
vr?: boolean;
|
|
15
|
+
ar?: boolean;
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class HoloSceneElement extends HTMLElement {
|
|
21
|
+
private renderer;
|
|
22
|
+
constructor();
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
disconnectedCallback(): void;
|
|
25
|
+
get src(): string;
|
|
26
|
+
get target(): HoloSceneTarget;
|
|
27
|
+
}
|
|
28
|
+
declare function registerHoloScene(): void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* HoloSceneRenderer
|
|
32
|
+
*
|
|
33
|
+
* Responsible for taking compiled HoloScript output and rendering it
|
|
34
|
+
* into a DOM container. Supports Three.js, WebXR, and static preview modes.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
interface RenderOptions {
|
|
38
|
+
target: HoloSceneTarget;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
enableVR: boolean;
|
|
42
|
+
enableAR: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare class HoloSceneRenderer {
|
|
45
|
+
private container;
|
|
46
|
+
private canvas;
|
|
47
|
+
private animationFrameId;
|
|
48
|
+
constructor(container: HTMLElement);
|
|
49
|
+
render(compiledOutput: string, options: RenderOptions): Promise<void>;
|
|
50
|
+
private renderThreeJS;
|
|
51
|
+
private renderStaticPreview;
|
|
52
|
+
private addVRButton;
|
|
53
|
+
private addARButton;
|
|
54
|
+
cleanup(): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* CDN configuration and defaults
|
|
59
|
+
*/
|
|
60
|
+
interface HoloCDNConfig {
|
|
61
|
+
cdnBase: string;
|
|
62
|
+
defaultTarget: string;
|
|
63
|
+
debug: boolean;
|
|
64
|
+
loadTimeoutMs: number;
|
|
65
|
+
}
|
|
66
|
+
declare const defaultCDNConfig: HoloCDNConfig;
|
|
67
|
+
|
|
68
|
+
export { type HoloCDNConfig, type HoloSceneAttributes, HoloSceneElement, type HoloSceneFallback, HoloSceneRenderer, type HoloSceneTarget, defaultCDNConfig, registerHoloScene };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HoloScene custom element attribute types
|
|
3
|
+
*/
|
|
4
|
+
type HoloSceneTarget = 'webxr' | 'threejs' | 'babylon' | 'unity' | 'godot' | 'visionos' | 'android-xr' | 'auto';
|
|
5
|
+
type HoloSceneFallback = 'threejs' | 'canvas2d' | 'static-image' | 'none';
|
|
6
|
+
interface HoloSceneAttributes {
|
|
7
|
+
src?: string;
|
|
8
|
+
inline?: string;
|
|
9
|
+
target?: HoloSceneTarget;
|
|
10
|
+
fallback?: HoloSceneFallback;
|
|
11
|
+
width?: string | number;
|
|
12
|
+
height?: string | number;
|
|
13
|
+
autoplay?: boolean;
|
|
14
|
+
vr?: boolean;
|
|
15
|
+
ar?: boolean;
|
|
16
|
+
loading?: boolean;
|
|
17
|
+
class?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class HoloSceneElement extends HTMLElement {
|
|
21
|
+
private renderer;
|
|
22
|
+
constructor();
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
disconnectedCallback(): void;
|
|
25
|
+
get src(): string;
|
|
26
|
+
get target(): HoloSceneTarget;
|
|
27
|
+
}
|
|
28
|
+
declare function registerHoloScene(): void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* HoloSceneRenderer
|
|
32
|
+
*
|
|
33
|
+
* Responsible for taking compiled HoloScript output and rendering it
|
|
34
|
+
* into a DOM container. Supports Three.js, WebXR, and static preview modes.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
interface RenderOptions {
|
|
38
|
+
target: HoloSceneTarget;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
enableVR: boolean;
|
|
42
|
+
enableAR: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare class HoloSceneRenderer {
|
|
45
|
+
private container;
|
|
46
|
+
private canvas;
|
|
47
|
+
private animationFrameId;
|
|
48
|
+
constructor(container: HTMLElement);
|
|
49
|
+
render(compiledOutput: string, options: RenderOptions): Promise<void>;
|
|
50
|
+
private renderThreeJS;
|
|
51
|
+
private renderStaticPreview;
|
|
52
|
+
private addVRButton;
|
|
53
|
+
private addARButton;
|
|
54
|
+
cleanup(): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* CDN configuration and defaults
|
|
59
|
+
*/
|
|
60
|
+
interface HoloCDNConfig {
|
|
61
|
+
cdnBase: string;
|
|
62
|
+
defaultTarget: string;
|
|
63
|
+
debug: boolean;
|
|
64
|
+
loadTimeoutMs: number;
|
|
65
|
+
}
|
|
66
|
+
declare const defaultCDNConfig: HoloCDNConfig;
|
|
67
|
+
|
|
68
|
+
export { type HoloCDNConfig, type HoloSceneAttributes, HoloSceneElement, type HoloSceneFallback, HoloSceneRenderer, type HoloSceneTarget, defaultCDNConfig, registerHoloScene };
|
|
File without changes
|
package/error-tsc.log
ADDED
|
File without changes
|