Skip to content

Commit

Permalink
Merge pull request #465 from live-codes/fix-autoupdate
Browse files Browse the repository at this point in the history
fix autoupdate
  • Loading branch information
hatemhosny authored Oct 31, 2023
2 parents 868d5f3 + e2daf79 commit 118416b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/livecodes/UI/icons.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export const run =
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><title>Play</title><path d="M112 111v290c0 17.44 17 28.52 31 20.16l247.9-148.37c12.12-7.25 12.12-26.33 0-33.58L143 90.84c-14-8.36-31 2.72-31 20.16z" fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32"/></svg>';
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M112 111v290c0 17.44 17 28.52 31 20.16l247.9-148.37c12.12-7.25 12.12-26.33 0-33.58L143 90.84c-14-8.36-31 2.72-31 20.16z" fill="none" stroke="currentColor" stroke-miterlimit="10" stroke-width="32"/></svg>';

export const checked =
'<svg xmlns="http://www.w3.org/2000/svg" class="checked" viewBox="0 0 512 512"><title>Checkbox</title><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M352 176L217.6 336 160 272"/><rect x="64" y="64" width="384" height="384" rx="48" ry="48" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/></svg>';
'<svg xmlns="http://www.w3.org/2000/svg" class="checked" viewBox="0 0 512 512"><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M352 176L217.6 336 160 272"/><rect x="64" y="64" width="384" height="384" rx="48" ry="48" fill="none" stroke="currentColor" stroke-linejoin="round" stroke-width="32"/></svg>';

export const unchecked =
'<svg xmlns="http://www.w3.org/2000/svg" class="unchecked" viewBox="0 0 512 512"><title>Square</title><path d="M416 448H96a32.09 32.09 0 01-32-32V96a32.09 32.09 0 0132-32h320a32.09 32.09 0 0132 32v320a32.09 32.09 0 01-32 32z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/></svg>';
'<svg xmlns="http://www.w3.org/2000/svg" class="unchecked" viewBox="0 0 512 512"><path d="M416 448H96a32.09 32.09 0 01-32-32V96a32.09 32.09 0 0132-32h320a32.09 32.09 0 0132 32v320a32.09 32.09 0 01-32 32z" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/></svg>';

export const reset =
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><title>Refresh</title><path d="M320 146s24.36-12-64-12a160 160 0 10160 160" fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M256 58l80 80-80 80"/></svg>';
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M320 146s24.36-12-64-12a160 160 0 10160 160" fill="none" stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M256 58l80 80-80 80"/></svg>';

export const edit =
'<svg fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"></path></svg>';

export const copy = `
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 210.107 210.107" style="enable-background:new 0 0 210.107 210.107;" xml:space="preserve">
<g>
<path d="M168.506,0H80.235C67.413,0,56.981,10.432,56.981,23.254v2.854h-15.38
Expand Down
16 changes: 7 additions & 9 deletions src/livecodes/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,10 +1040,12 @@ const setExternalResourcesMark = () => {
}
};

const run = async (editorId?: EditorId, runTests = false) => {
const run = async (editorId?: EditorId, runTests?: boolean) => {
setLoading(true);
toolsPane?.console?.clear(/* silent= */ true);
const result = await getResultPage({ sourceEditor: editorId, runTests });
const config = getConfig();
const shouldRunTests = runTests ?? (config.autotest && Boolean(config.tests?.content?.trim()));
const result = await getResultPage({ sourceEditor: editorId, runTests: shouldRunTests });
await createIframe(UI.getResultElement(), result);
updateCompiledCode();
};
Expand Down Expand Up @@ -1991,9 +1993,8 @@ const handleChangeContent = () => {
const config = getConfig();
addConsoleInputCodeCompletion();

const shouldRunTests = Boolean(config.autotest && config.tests?.content);
if ((config.autoupdate || shouldRunTests) && !loading) {
await run(editorId, shouldRunTests);
if (config.autoupdate && !loading) {
await run(editorId);
}

if (config.markup.content !== getCache().markup.content) {
Expand Down Expand Up @@ -4190,10 +4191,7 @@ const createApi = (): API => {
};

const apiSetConfig = async (newConfig: Partial<Config>): Promise<Config> => {
const newAppConfig: Config = {
...getConfig(),
...buildConfig(newConfig),
};
const newAppConfig = buildConfig({ ...getConfig(), ...newConfig });
setConfig(newAppConfig);
await applyConfig(newConfig);
const content = getContentConfig(newConfig as Config);
Expand Down
1 change: 1 addition & 0 deletions src/livecodes/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const livecodes = (container: string, config: Partial<Config> = {}): Prom
if (isEmbed) {
const registerSDKEvent = (sdkEvent: CustomEvents[keyof CustomEvents], hasData = false) => {
window.addEventListener(sdkEvent, (e: CustomEventInit) => {
if (hasData && e.detail == null) return;
parent.postMessage(
{ type: sdkEvent, ...(hasData ? { payload: e.detail } : {}) },
anyOrigin,
Expand Down
2 changes: 1 addition & 1 deletion src/livecodes/vendors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export const vueSfcLoaderCdnBaseUrl = /* @__PURE__ */ getUrl('vue3-sfc-loader@0.

export const wabtjsUrl = /* @__PURE__ */ getUrl('[email protected]/index.js');

export const wasmoonUrl = /* @__PURE__ */ getUrl('[email protected].0/dist/index.js');
export const wasmoonUrl = /* @__PURE__ */ getUrl('[email protected].1/dist/index.js');

export const waveDromBaseUrl = /* @__PURE__ */ getUrl('[email protected]/');

Expand Down

0 comments on commit 118416b

Please sign in to comment.