Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/windows-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
release_version:
description: "Version to publish (for example 1.0.3; do not include the v prefix)"
required: true
default: "1.0.3"
default: "1.0.5"
type: string

permissions:
Expand Down Expand Up @@ -41,7 +41,13 @@ jobs:
} elseif ($env:GITHUB_REF -like "refs/tags/v*") {
$version = $env:REF_NAME -replace '^v', ''
} else {
$version = "1.0.3"
# Keep PR/push installer artifacts aligned with the version declared
# by the installer script instead of maintaining a second version.
$iss = Get-Content "installer/GLB-Viewer.iss" -Raw
if ($iss -notmatch '(?m)^\s*#define\s+AppVersion\s+"(\d+\.\d+\.\d+)"') {
throw "Could not resolve AppVersion from installer/GLB-Viewer.iss"
}
$version = $Matches[1]
}
if ($version -notmatch '^\d+\.\d+\.\d+$') {
throw "Version must use the format X.Y.Z (received: $version)"
Expand Down
2 changes: 1 addition & 1 deletion installer/GLB-Viewer.iss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define AppName "GLB Viewer"
#ifndef AppVersion
#define AppVersion "1.0.4"
#define AppVersion "1.0.5"
#endif
#define AppPublisher "VeloraTech"

Expand Down
9 changes: 8 additions & 1 deletion scripts/update-viewer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ try {

$assets = @(
'viewer.html',
'src/editor/ViewerShell.js',
'src/editor/EditorStateStore.js',
'src/editor/ToolRegistry.js',
'src/editor/WorkspaceManager.js',
Expand All @@ -34,6 +35,12 @@ try {
'src/editor/OrbitPreview.js',
'src/editor/ViewportWorkspace.js',
'src/editor/MultiObjectTransform.js',
'three/examples/jsm/controls/OrbitControls.js',
'three/examples/jsm/controls/TransformControls.js',
'three/examples/jsm/environments/RoomEnvironment.js',
'three/examples/jsm/loaders/GLTFLoader.js',
'three/examples/jsm/utils/BufferGeometryUtils.js',
'three/examples/jsm/exporters/GLTFExporter.js',
'src/core/ResourceDisposer.js',
'src/core/PerformanceMonitor.js',
'src/core/HardwareProviders.js',
Expand All @@ -58,7 +65,7 @@ try {
if ($asset -eq 'viewer.html' -and ($content -notmatch '<!DOCTYPE html>' -or $content -notmatch 'GLB Viewer')) {
throw 'Downloaded viewer.html failed its content check.'
}
if ($asset.EndsWith('.js') -and $content -notmatch 'export ') { throw "Downloaded module failed its content check: $asset" }
if ($asset.EndsWith('.js') -and $asset -ne 'src/editor/ViewerShell.js' -and $content -notmatch 'export ') { throw "Downloaded module failed its content check: $asset" }
}

# Install as an immutable per-user version. The launcher reads the active
Expand Down
63 changes: 63 additions & 0 deletions src/editor/ViewerShell.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* Independent viewer shell: this file intentionally has no ES-module dependencies. */
(() => {
const state = { failed: false };
function showBootstrapFailure(message) {
if (window.__GLB_VIEWER_BOOTED__ || state.failed) return;
state.failed = true;
const loading = document.getElementById('loading');
if (loading) {
loading.classList.add('hidden');
loading.style.display = 'none';
}
const error = document.getElementById('error');
if (error) {
error.style.display = 'none';
error.style.pointerEvents = 'none';
}
let notice = document.getElementById('viewer-bootstrap-error');
if (!notice) {
notice = document.createElement('div');
notice.id = 'viewer-bootstrap-error';
notice.setAttribute('role', 'alert');
notice.style.cssText = 'position:fixed;left:12px;top:58px;z-index:200;max-width:min(560px,calc(100vw - 24px));padding:12px 14px;border:1px solid rgba(255,120,120,.45);border-radius:8px;background:#282326;color:#fff;font:13px/1.5 system-ui,sans-serif;box-shadow:0 8px 28px rgba(0,0,0,.35);pointer-events:auto';
document.body.appendChild(notice);
}
notice.textContent = 'Viewer tools could not finish initializing. Your workspace navigation is still available. ' + message;
console.error('[GLB Viewer bootstrap]', message);
}
window.addEventListener('error', event => {
const target = event.target;
if (target && (target.tagName === 'SCRIPT' || target.tagName === 'LINK')) {
const assetUrl = target.src || target.href || '';
// Third-party icon CDN failures must never disable the local application.
if (assetUrl && new URL(assetUrl, window.location.href).origin !== window.location.origin) return;
if (assetUrl) showBootstrapFailure('A required local application file failed to load: ' + assetUrl);
return;
}
if (event.error) showBootstrapFailure(event.error.message || 'An application startup error occurred.');
}, true);
window.addEventListener('unhandledrejection', event => {
showBootstrapFailure(event.reason?.message || 'An application startup task failed.');
});
document.addEventListener('click', event => {
if (window.__GLB_VIEWER_BOOTED__) return;
const button = event.target.closest?.('[data-workspace]');
if (!button) return;
const name = button.dataset.workspace;
const shell = document.getElementById('workspace-main');
const content = document.getElementById('workspace-content');
if (!shell || !content) return;
const views = [...content.querySelectorAll('.workspace-view')];
const selected = views.find(view => view.dataset.view === name);
if (!selected) return;
shell.hidden = false;
shell.style.display = 'flex';
views.forEach(view => { view.hidden = view !== selected; });
const heading = shell.querySelector('#workspace-header h2');
if (heading) heading.textContent = name[0].toUpperCase() + name.slice(1);
button.classList.add('active');
document.querySelectorAll('[data-workspace]').forEach(item => {
if (item !== button) item.classList.remove('active');
});
});
})();
32 changes: 32 additions & 0 deletions tests/viewer-resilience.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { existsSync } from 'node:fs';

const viewer = await readFile(new URL('../viewer.html', import.meta.url), 'utf8');
const updater = await readFile(new URL('../scripts/update-viewer.ps1', import.meta.url), 'utf8');
const shell = await readFile(new URL('../src/editor/ViewerShell.js', import.meta.url), 'utf8');

test('every local Three.js addon statically imported by the viewer is bundled', () => {
const imports = [...viewer.matchAll(/from\s+['"]three\/addons\/([^'"]+)['"]/g)].map(match => match[1]);
assert.ok(imports.length > 0, 'expected local Three.js addon imports');
for (const path of imports) {
assert.ok(existsSync(new URL('../three/examples/jsm/' + path, import.meta.url)), 'missing bundled addon: ' + path);
assert.ok(updater.includes("'three/examples/jsm/" + path + "'"), 'updater does not deliver addon: ' + path);
}
});

test('independent shell loads before the application module', () => {
const shellPosition = viewer.indexOf('<script src="./src/editor/ViewerShell.js"></script>');
const modulePosition = viewer.indexOf('<script type="module">');
assert.ok(shellPosition >= 0 && modulePosition > shellPosition);
assert.ok(updater.includes("'src/editor/ViewerShell.js'"));
});

test('startup failure releases the blocking loader and preserves workspace navigation', () => {
assert.match(shell, /classList\.add\('hidden'\)/);
assert.match(shell, /loading\.style\.display = 'none'/);
assert.match(shell, /\[data-workspace\]/);
assert.match(shell, /window\.__GLB_VIEWER_BOOTED__/);
assert.match(viewer, /window\.__GLB_VIEWER_BOOTED__ = true/);
});
Loading
Loading