openpetswithchatandmcp/website/apply_suspense.py
OpenPets Dev 65ac83849e Add 'website/' from commit '966aea480ffe1c340553aa878def30131d2af827'
git-subtree-dir: website
git-subtree-mainline: 8d3849caea
git-subtree-split: 966aea480f
2026-06-17 20:48:39 +00:00

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')