openvibers/openvibe.network Commits
footer: define the global root it shares the chrome cache through; test that every browser bundle evaluates
Changes
@@@ -27,6 +27,7 @@})(typeof globalThis !== 'undefined' ? globalThis : this, function () {'use strict';++ const root = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : {});// ── Shared chrome data (https://openvibe.network/api/chrome) ─────────────────────────────// Sites ordered by real use, footer copy and per-site legal links. Cached per host for 30// minutes in localStorage and refreshed in the background, so pages paint from cache and the@@@ -16,3 +16,19 @@ assert.equal(icons.resolve('yt'), 'youtube');assert.equal(icons.resolve('<img onerror=1>'), 'ov', 'unknown names fall back to the mark');for (const f of ['../island.js', '../ui.js']) { const m = require(f); assert.equal(typeof (m.start || m.toast), 'function', `${f} loads without a DOM`); }console.log('shared modules: all checks passed');++++// The browser bundles must at least evaluate in a bare global (this caught a missing `root` once).++{++ const vm = require('vm'); const fs = require('fs'); const path = require('path');++ for (const f of ['footer.js', 'navbar.js', 'island.js', 'ui.js', 'ov-icons.js', 'history.js', 'sso-client.js']) {++ const ctx = vm.createContext({ console });++ ctx.globalThis = ctx; ctx.window = ctx; ctx.self = ctx;++ ctx.localStorage = { getItem: () => null, setItem() {} }; ctx.location = { hostname: 'openvibe.tools', href: 'https://openvibe.tools/' };++ assert.doesNotThrow(() => vm.runInContext(fs.readFileSync(path.join(__dirname, '..', f), 'utf8'), ctx), `${f} evaluates`);++ }++ const ctx = vm.createContext({ console }); ctx.globalThis = ctx; ctx.window = ctx; ctx.location = { hostname: 'openvibe.media', href: 'https://openvibe.media/' }; ctx.localStorage = { getItem: () => null, setItem() {} };++ vm.runInContext(fs.readFileSync(path.join(__dirname, '..', 'footer.js'), 'utf8'), ctx);++ const html = ctx.OpenVibeFooter.buildHTML({ service: 'media', variant: 'full' });++ assert.ok(html.includes('Legal') && html.includes('ovf-brand'), 'footer renders without chrome data');++ console.log('browser bundles evaluate: ok');++}
@@ -27,6 +27,7 @@
@@ -27,6 +27,7 @@
})(typeof globalThis !== 'undefined' ? globalThis : this, function () {
})(typeof globalThis !== 'undefined' ? globalThis : this, function () {
'use strict';
'use strict';
+ const root = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : {});
// ── Shared chrome data (https://openvibe.network/api/chrome) ─────────────────────────────
// ── Shared chrome data (https://openvibe.network/api/chrome) ─────────────────────────────
// Sites ordered by real use, footer copy and per-site legal links. Cached per host for 30
// Sites ordered by real use, footer copy and per-site legal links. Cached per host for 30
// minutes in localStorage and refreshed in the background, so pages paint from cache and the
// minutes in localStorage and refreshed in the background, so pages paint from cache and the
@@ -16,3 +16,19 @@ assert.equal(icons.resolve('yt'), 'youtube');
@@ -16,3 +16,19 @@ assert.equal(icons.resolve('yt'), 'youtube');
assert.equal(icons.resolve('<img onerror=1>'), 'ov', 'unknown names fall back to the mark');
assert.equal(icons.resolve('<img onerror=1>'), 'ov', 'unknown names fall back to the mark');
for (const f of ['../island.js', '../ui.js']) { const m = require(f); assert.equal(typeof (m.start || m.toast), 'function', `${f} loads without a DOM`); }
for (const f of ['../island.js', '../ui.js']) { const m = require(f); assert.equal(typeof (m.start || m.toast), 'function', `${f} loads without a DOM`); }
console.log('shared modules: all checks passed');
console.log('shared modules: all checks passed');
+
+// The browser bundles must at least evaluate in a bare global (this caught a missing `root` once).
+{
+ const vm = require('vm'); const fs = require('fs'); const path = require('path');
+ for (const f of ['footer.js', 'navbar.js', 'island.js', 'ui.js', 'ov-icons.js', 'history.js', 'sso-client.js']) {
+ const ctx = vm.createContext({ console });
+ ctx.globalThis = ctx; ctx.window = ctx; ctx.self = ctx;
+ ctx.localStorage = { getItem: () => null, setItem() {} }; ctx.location = { hostname: 'openvibe.tools', href: 'https://openvibe.tools/' };
+ assert.doesNotThrow(() => vm.runInContext(fs.readFileSync(path.join(__dirname, '..', f), 'utf8'), ctx), `${f} evaluates`);
+ }
+ const ctx = vm.createContext({ console }); ctx.globalThis = ctx; ctx.window = ctx; ctx.location = { hostname: 'openvibe.media', href: 'https://openvibe.media/' }; ctx.localStorage = { getItem: () => null, setItem() {} };
+ vm.runInContext(fs.readFileSync(path.join(__dirname, '..', 'footer.js'), 'utf8'), ctx);
+ const html = ctx.OpenVibeFooter.buildHTML({ service: 'media', variant: 'full' });
+ assert.ok(html.includes('Legal') && html.includes('ovf-brand'), 'footer renders without chrome data');
+ console.log('browser bundles evaluate: ok');
+}