Skip to content

Commit 93b2306

Browse files
authored
Support v2 playgrounds in visual tests (#1560)
All new playgrounds are serialized in the v2 format, so this is bare minimum to support that.
1 parent deec210 commit 93b2306

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Apps/Playground/Scripts/validation_native.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,22 @@
179179
try {
180180
xmlHttp.onreadystatechange = null;
181181
const snippet = JSON.parse(xmlHttp.responseText);
182-
let code = JSON.parse(snippet.jsonPayload).code.toString()
182+
let code = JSON.parse(snippet.jsonPayload).code.toString();
183+
184+
// Check if this is a v2 manifest and extract the entry file's code
185+
// TODO: Handle multi-file playgrounds
186+
try {
187+
const manifestPayload = JSON.parse(code);
188+
if (manifestPayload.v === 2) {
189+
code = manifestPayload.files[manifestPayload.entry]
190+
.replace(/export +default +/g, "")
191+
.replace(/export +/g, "");
192+
}
193+
} catch (e) {
194+
// Not a manifest, proceed as usual
195+
}
196+
197+
code = code
183198
.replace(/"\/textures\//g, '"' + pgRoot + "/textures/")
184199
.replace(/"textures\//g, '"' + pgRoot + "/textures/")
185200
.replace(/\/scenes\//g, pgRoot + "/scenes/")

0 commit comments

Comments
 (0)