Improve loading#827
Conversation
✅ Deploy Preview for livecodes ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
This is reverted and is still backward-compatible. |
|
Hi Dr.@hatemhosny //core.ts:5410
...
const sdkConfig = importCompressedCode(params.config ?? '');
const initialConfig = { ...codeImportConfig, ...appConfig, ...sdkConfig };// <== includes sdkConfig
...
setConfig(buildConfig({ ...getConfig(), ...userConfig, ...initialConfig })); // <== includes initialConfig
...
importExternalContent({
config: getConfig(), // <== this should have the fields in initialConfig so we shouldn't really need sdkConfig
sdkConfig,
configUrl: params.config,
template: params.template,
importUrl: Object.keys(codeImportConfig).length > 0 ? '' : params.x, // do not re-import compressed code
}).then(async (contentImported) => {so I think the props in (P.S. I am still looking at the failing tests) |
Deploying livecodes with
|
| Latest commit: |
77854e8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://782d9676.livecodes.pages.dev |
| Branch Preview URL: | https://improve-loading-config.livecodes.pages.dev |
|
Thank you @BassemHalim for the review.
Yes, await loadConfig(
buildConfig({
...config,
...templateConfig,
...importUrlConfig,
...configUrlConfig,
...sdkConfig,
...contentUrlConfig,
}),
parent.location.href,
false,
);We cannot use Example: const options: EmbedOptions = {
template: 'react',
config: {
activeEditor: 'markup',
markup: {
language: 'html',
content: '<p>Hello World (from config)</p>',
},
},
params: {
console: 'open',
},
};demo: https://livecodes.io/?x=id/i8628qhyin6
These were related to a feature to use hash as import url (now replaced by This PR still needs some tests for different scenarios and different sources. |
|
oh ok I see what you mean. |
|
Thank you @BassemHalim Yes, this is indeed the intended behaviour. Also this allows just adding query params to a share URL to modify some behaviours. e.g. |
|
|
added e2e tests for SDK options. I think this is ready now to merge. |



What type of PR is this? (check all applicable)
Description
This PR improves loading new projects.
A project config can be generated from a variety of sources. Some of the sources are already available when loading (e.g. SDK config, params, compressed code in
xparam, etc), while others need to be imported (e.g. template, import URL, config content URL, etc)These sources were mixed in
importExternalContent. So,initializePlaygroundstarted loading the UI then followed by a flash of changing content whenimportExternalContentruns.In addition, a notification of "Loading Content" appeared even when the content was already available.
This PR now handles all already available sources in the initial load and keeps only remote content to
importExternalContent.@BassemHalim whould you please review this, which is very much related to your PR #819