From 267a659dfbae873480b49edc312a408811789743 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Thu, 11 Nov 2021 12:41:29 +0100 Subject: [PATCH] Script to update web-ifc. --- package.json | 3 ++- tools/updatelibs.py | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 9190798..d167515 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "fflate": "0.7.1", "jquery": "3.5.1", "rhino3dm": "7.7.0", - "three": "0.134.0" + "three": "0.134.0", + "web-ifc": "0.0.28" }, "eslintConfig": { "env": { diff --git a/tools/updatelibs.py b/tools/updatelibs.py index 4b0415b..70bc384 100644 --- a/tools/updatelibs.py +++ b/tools/updatelibs.py @@ -1,10 +1,7 @@ import os import sys -import json +import re import shutil -import zipfile -import urllib -import urllib.request from lib import tools_lib as Tools @@ -44,6 +41,11 @@ fflateFileMap = [ [os.path.join ('fflate', 'umd', 'index.js'), os.path.join ('loaders', 'fflate.min.js')], ] +webIfcFileMap = [ + [os.path.join ('web-ifc', 'web-ifc-api.js'), os.path.join ('loaders', 'web-ifc-api.js')], + [os.path.join ('web-ifc', 'web-ifc.wasm'), os.path.join ('loaders', 'web-ifc.wasm')], +] + def PrintInfo (message): print ('INFO: ' + message) @@ -57,6 +59,11 @@ def UpdateModule (fileMap, moduleDir, libsDir): PrintInfo ('Copying file ' + os.path.split (src)[1]) shutil.copy2 (src, dst) +def FixWebIfcExport (libsDir): + apiFilePath = os.path.join (libsDir, 'loaders', 'web-ifc-api.js') + regex = re.compile (r'export \{.*\};', re.DOTALL) + Tools.ReplaceRegexInFile (apiFilePath, regex, '') + def Main (argv): toolsDir = os.path.dirname (os.path.abspath (__file__)) rootDir = os.path.dirname (toolsDir) @@ -71,6 +78,8 @@ def Main (argv): UpdateModule (dracoFileMap, nodeModulesDir, libsDir) UpdateModule (rhino3dmFileMap, nodeModulesDir, libsDir) UpdateModule (fflateFileMap, nodeModulesDir, libsDir) + UpdateModule (webIfcFileMap, nodeModulesDir, libsDir) + FixWebIfcExport (libsDir) return 0