mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-10-01 09:19:34 +05:30
fix(flowchart): expose pure modules as window globals for standalone window; v4.9.7
Each pure module's UMD wrapper assigned window.FlowchartXxx only in the else branch — when 'module' was undefined. But the renderer runs with nodeIntegration:true, so 'module' is always truthy and the else branch never ran. The standalone Flowchart Generator window then aborted with 'Flowchart pure modules not loaded'. Fix: append 'if (typeof window !== undefined) window.FlowchartXxx = exported;' after the CommonJS branch in all 4 pure modules (store, shapes, mermaid, canvas). Both branches can run now; the legacy sidebar panel still loads them via require() and the renderer unconditionally exposes the global. Regression guard: 4 new source-grep tests in tests/flowchart-controller.test.js assert each module's source contains the 'window.FlowchartXxx = exported' assignment. Attribution: Amit Haridas
This commit is contained in:
@@ -214,3 +214,23 @@ describe('flowchart-controller: renderer.js sidebar registration is disabled', (
|
||||
expect(liveMatch).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
// v4.9.7 regression — pure modules MUST expose themselves as window globals
|
||||
// so the standalone Flowchart Generator window can load them via <script>
|
||||
// tags. In Electron renderer with nodeIntegration:true, `module` is truthy,
|
||||
// which used to make the UMD wrapper skip its browser-global assignment;
|
||||
// this guard is now mandatory. We assert the source contains the
|
||||
// `window.FlowchartXxx = exported;` line so a future refactor can't silently
|
||||
// drop it again.
|
||||
describe('flowchart pure modules — UMD browser-global assignment (v4.9.7)', () => {
|
||||
const cases = [
|
||||
['flowchart/flowchart-store.js', 'FlowchartStore'],
|
||||
['flowchart/flowchart-shapes.js', 'FlowchartShapes'],
|
||||
['flowchart/flowchart-mermaid.js', 'FlowchartMermaid'],
|
||||
['flowchart/flowchart-canvas.js', 'FlowchartCanvas'],
|
||||
];
|
||||
test.each(cases)('%s assigns window.%s = exported', (rel, globalName) => {
|
||||
const src = fs.readFileSync(path.join(__dirname, '..', 'src', rel), 'utf-8');
|
||||
expect(src).toMatch(new RegExp(`window\\.${globalName}\\s*=\\s*exported`));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user