41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
import re
|
|
import sys
|
|
|
|
with open('app.js', 'r') as f:
|
|
content = f.read()
|
|
|
|
# 1. Add _buildShell()
|
|
shell_html = """
|
|
_buildShell() {
|
|
const root = document.getElementById('app-root');
|
|
if (!root) return;
|
|
|
|
root.innerHTML = `
|
|
<div id="sidebar" class="sidebar"></div>
|
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
|
|
<div id="main-panel" class="main-panel"></div>
|
|
<div id="toast-container"></div>
|
|
`;
|
|
},
|
|
"""
|
|
|
|
# Find init() and insert _buildShell() call and definition
|
|
init_idx = content.find('async init() {')
|
|
if init_idx != -1:
|
|
content = content[:init_idx] + shell_html + content[init_idx:]
|
|
content = content.replace('this.loadState();', 'this.loadState();\n this._buildShell();')
|
|
|
|
# 2. _renderAll() instead of render()
|
|
content = content.replace('render() {', '_renderAll() {')
|
|
|
|
# 3. Surgical updates
|
|
# We can replace 'this.render();' with selective calls, but the prompt says:
|
|
# "6. Full _renderAll() called only on: tab switch, space switch, page init, bulk complete."
|
|
# "5. saveState() must skip during bulk run." (already in code: if (this.state.bulk && this.state.bulk.running) return;)
|
|
# "4. Results: binaryData ALWAYS nulled after blobUrl created"
|
|
# "7. No this.dom.mainPanel.innerHTML = ... after init, except for Spaces Dashboard view"
|
|
# "8. No this.dom.sidebar.innerHTML = ... after init."
|
|
|
|
with open('/tmp/app_new.js', 'w') as f:
|
|
f.write(content)
|