Created
March 30, 2023 09:23
-
-
Save fvsch/81c7301f8f2fa3d2ec8fc39f1e7354f9 to your computer and use it in GitHub Desktop.
Testing the StackBlitz SDK from a browser's console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void (async function () { | |
// set origin to the StackBlitz instance you want to test | |
const origin = 'https://stackblitz.com'; | |
const sdk = await import( | |
'https://unpkg.com/@stackblitz/sdk@1/bundles/sdk.m.js' | |
).then((module) => module.default); | |
const jsProject = { | |
title: 'JS Project', | |
template: 'javascript', | |
files: { 'index.js': '// JavaScript', 'index.html': '' }, | |
}; | |
const nodeProject = { | |
title: 'Node Project', | |
template: 'node', | |
files: { 'index.js': '// Node' }, | |
}; | |
const unknownTemplateProject = { | |
title: 'Unknown Template', | |
template: 'lolwhat', | |
files: { 'index.js': '// JavaScript', 'index.html': '' }, | |
}; | |
[jsProject, nodeProject, unknownTemplateProject].forEach((project, index) => { | |
setTimeout( | |
() => sdk.openProject(project, { newWindow: true, origin }), | |
index * 1_000 | |
); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment