From 5893a72e969725b5c618d3c48ab712c98ff9b942 Mon Sep 17 00:00:00 2001 From: Dmitry Vasilev Date: Thu, 6 Jul 2023 23:51:22 +0300 Subject: [PATCH] fix self-hosted dev --- src/record_io.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/record_io.js b/src/record_io.js index 68d2b04..ca3144c 100644 --- a/src/record_io.js +++ b/src/record_io.js @@ -3,11 +3,21 @@ import {set_record_call} from './runtime.js' // Current context for current execution of code let cxt +const label = Symbol('io_patches_applied') + export const set_current_context = _cxt => { cxt = _cxt - if(!cxt.window.__is_io_pached) { + // When we develop leporello.js inside itself, patches may be applied twice, + // once for host leporello, and another for leporello under development. This + // module would be loaded twice, once from host window, another time from + // run_window. Every module will have its own 'label', so we can apply + // patches twice + if(cxt.window.__io_patched_by == null) { + cxt.window.__io_patched_by = new Set() + } + if(!cxt.window.__io_patched_by.has(label)) { apply_io_patches() - cxt.window.__is_io_pached = true + cxt.window.__io_patched_by.add(label) } }