18 lines
911 B
Python
Executable file
18 lines
911 B
Python
Executable file
import re
|
|
|
|
with open('c:/ScriptoriumAI/scriptoriumai-ui/src/App.tsx', 'r', encoding='utf-8') as f:
|
|
text = f.read()
|
|
|
|
def wrap_in_suspense(match):
|
|
name = match.group(1)
|
|
tag = match.group(2)
|
|
return f'<Route {name} element={{<Suspense fallback={{<div className=\"h-full w-full grid place-items-center bg-gray-950 text-gray-300 text-sm\">Loading {tag}...</div>}}><{tag} /></Suspense>}} />'
|
|
|
|
text = re.sub(r'<Route (index) element=\{<Dashboard />\} />', r'<Route index element={<Suspense fallback={<div className=\"h-full w-full grid place-items-center bg-gray-950 text-gray-300 text-sm\">Loading workspace...</div>}><Dashboard /></Suspense>} />', text)
|
|
|
|
text = re.sub(r'<Route (path=\"(?:.*?)\") element=\{<([A-Za-z]+)\s*/>\} />', wrap_in_suspense, text)
|
|
|
|
with open('c:/ScriptoriumAI/scriptoriumai-ui/src/App.tsx', 'w', encoding='utf-8') as f:
|
|
f.write(text)
|
|
|
|
print('Done wrapping with Suspense')
|