Skip to content

Commit 245cdc7

Browse files
committed
fix(Result): avoid rerenders on firefox (sandbox v9)
1 parent 397cfda commit 245cdc7

6 files changed

Lines changed: 8 additions & 3 deletions

File tree

server/src/sandbox.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import cors from 'cors';
33
import express from 'express';
44
import fs from 'node:fs';
55
import path from 'node:path';
6+
import { sandboxVersion } from '../../src/livecodes/html/sandbox/index.ts';
67
import { dirname } from './utils.ts';
78

89
export const sandbox = ({ hostname, port }: { hostname: string; port: number }) => {
@@ -12,7 +13,7 @@ export const sandbox = ({ hostname, port }: { hostname: string; port: number })
1213
app.disable('x-powered-by');
1314

1415
const sandboxDir = path.resolve(dirname, 'sandbox');
15-
let sandboxVersionDir = path.resolve(sandboxDir, 'v8');
16+
let sandboxVersionDir = path.resolve(sandboxDir, sandboxVersion);
1617
fs.readdirSync(sandboxDir).forEach((v) => {
1718
if (fs.statSync(path.resolve(sandboxDir, v)).isDirectory()) {
1819
sandboxVersionDir = path.resolve(sandboxDir, v);

src/livecodes/html/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { predefinedValues } from '../utils/utils';
44

55
// @ts-ignore
6-
import resultTemplateRaw from './sandbox/v8/index.html?raw';
6+
import resultTemplateRaw from './sandbox/v9/index.html?raw';
77
// @ts-ignore
88
import appHTMLRaw from './app.html?raw';
99
// @ts-ignore
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const sandboxVersion = 'v9';
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
window.addEventListener('message', function (event) {
66
var html = event.data.result || event.data.html;
77
if (html) {
8+
document.open();
89
document.write(html);
910
document.close();
1011
}

src/livecodes/services/sandbox.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { sandboxVersion } from '../html/sandbox/index';
2+
13
const cfPagesBaseUrl = 'https://livecodes-sandbox.pages.dev';
24
const ghPagesBaseUrl = 'https://live-codes.github.io/livecodes-sandbox/dist';
35
const selfHostedBaseUrl = `https://${process.env.SANDBOX_HOST_NAME}:${process.env.SANDBOX_PORT}`;
@@ -8,7 +10,7 @@ const serviceBaseUrl =
810
: process.env.CI === 'true'
911
? ghPagesBaseUrl
1012
: cfPagesBaseUrl;
11-
const version = 'v8';
13+
const version = sandboxVersion;
1214

1315
export const sandboxService = {
1416
getResultUrl: () => `${serviceBaseUrl}/${version}/`,

0 commit comments

Comments
 (0)