chore: Started adding typescript to zen, b=(no-bug), c=scripts, workspaces

This commit is contained in:
Mr. M 2025-04-21 00:02:19 +02:00
parent 5dfc6a663f
commit a7846a64d0
No known key found for this signature in database
GPG key ID: 6292C4C8F8652B18
20 changed files with 46424 additions and 14 deletions

View file

@ -0,0 +1,41 @@
import os
FILES = [
"index.d.ts",
"lib.gecko.darwin.d.ts",
"lib.gecko.dom.d.ts",
"lib.gecko.glean.d.ts",
"lib.gecko.linux.d.ts",
"lib.gecko.modules.d.ts",
"lib.gecko.nsresult.d.ts",
"lib.gecko.services.d.ts",
"lib.gecko.tweaks.d.ts",
"lib.gecko.win32.d.ts",
"lib.gecko.xpcom.d.ts",
"lib.gecko.xpidl.d.ts",
]
ENGINE_PATH = os.path.join("engine", "tools", "@types")
SRC_PATH = os.path.join("src", "zen", "@types")
def update_ts_types():
os.system("cd engine && ./mach ts build && ./mach ts update")
# copy the files from engine/tools/@types to src/@types
for file in FILES:
src_file = os.path.join(ENGINE_PATH, file)
dest_file = os.path.join(SRC_PATH, file)
if os.path.exists(src_file):
os.system(f"cp {src_file} {dest_file}")
else:
print(f"File {src_file} does not exist.")
# add zen.d.ts to the end of index.d.ts
with open(os.path.join(SRC_PATH, "index.d.ts"), "a") as f:
f.write("\n")
f.write('/// <reference types="./zen.d.ts" />\n')
f.write('\n')
if __name__ == "__main__":
update_ts_types()
print("Updated TypeScript types.")