├── .github └── CODEOWNERS ├── .prettierrc.json ├── readme.md ├── .prettierignore ├── package.json ├── .gitignore ├── .vscode └── settings.json ├── yarn.lock └── index.js /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @james-gates-0212 2 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "arrowParens": "always", 4 | "printWidth": 60, 5 | "trailingComma": "all" 6 | } 7 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Convert for zoom 2 | 3 | ![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fconvert4zoom%2Fhit-counter) 4 | 5 | ## Run 6 | 7 | ```bash 8 | yarn 9 | node index.js 10 | ``` 11 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Ignore artifacts 2 | .DS_Store 3 | .env 4 | .gitignore 5 | .prettierignore 6 | build 7 | dist 8 | frontend 9 | node_modules 10 | 11 | # Ignore files 12 | *.gif 13 | *.ico 14 | *.jpeg 15 | *.jpg 16 | *.lock 17 | *.png 18 | *.svg 19 | *.txt 20 | *.woff 21 | *.woff2 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "convert4zoom", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "fs": "^0.0.1-security", 13 | "path": "^0.12.7" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | node_modules/ 6 | node_modules/ 7 | /data 8 | dist/ 9 | 10 | *.sh 11 | 12 | # testing 13 | /coverage 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | .env.local 21 | .env.development.local 22 | .env.test.local 23 | .env.production.local 24 | 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "workbench.colorCustomizations": { 3 | "titleBar.activeForeground": "#000", 4 | "titleBar.inactiveForeground": "#000000CC", 5 | "titleBar.activeBackground": "#2568eb", 6 | "titleBar.inactiveBackground": "#6825ebCC" 7 | }, 8 | "editor.defaultFormatter": "esbenp.prettier-vscode", 9 | "editor.formatOnSave": true, 10 | "[typescript]": { 11 | "editor.defaultFormatter": "esbenp.prettier-vscode", 12 | "editor.formatOnSave": true 13 | }, 14 | "[json]": { 15 | "editor.defaultFormatter": "esbenp.prettier-vscode", 16 | "editor.formatOnSave": true 17 | }, 18 | "editor.tabSize": 2 19 | } 20 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | fs@^0.0.1-security: 6 | version "0.0.1-security" 7 | resolved "https://registry.yarnpkg.com/fs/-/fs-0.0.1-security.tgz#8a7bd37186b6dddf3813f23858b57ecaaf5e41d4" 8 | integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w== 9 | 10 | inherits@2.0.3: 11 | version "2.0.3" 12 | resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" 13 | integrity sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw== 14 | 15 | path@^0.12.7: 16 | version "0.12.7" 17 | resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f" 18 | integrity sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q== 19 | dependencies: 20 | process "^0.11.1" 21 | util "^0.10.3" 22 | 23 | process@^0.11.1: 24 | version "0.11.10" 25 | resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" 26 | integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== 27 | 28 | util@^0.10.3: 29 | version "0.10.4" 30 | resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901" 31 | integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A== 32 | dependencies: 33 | inherits "2.0.3" 34 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | 4 | const patterns = [ 5 | { 6 | pattern: /pxToRem\(([\d]+[\.]?[\d]*)\)/, 7 | replace1: (val) => `pxToRemTEMP(${val})`, 8 | replace2: /pxToRemTEMP/g, 9 | replace3: 'pxToRem', 10 | }, 11 | { 12 | pattern: /([\d]+[\.]?[\d]*)rem/, 13 | replace1: (val) => `${val}TEMPrem`, 14 | replace2: /TEMPrem/g, 15 | replace3: 'rem', 16 | }, 17 | { 18 | pattern: / m=\{([\d]+[\.]?[\d]*)\}/, 19 | replace1: (val) => ` mTEMP={${val}}`, 20 | replace2: / mTEMP=/g, 21 | replace3: ' m=', 22 | }, 23 | { 24 | pattern: /mx=\{([\d]+[\.]?[\d]*)\}/, 25 | replace1: (val) => `mxTEMP={${val}}`, 26 | replace2: /mxTEMP=/g, 27 | replace3: 'mx=', 28 | }, 29 | { 30 | pattern: /my=\{([\d]+[\.]?[\d]*)\}/, 31 | replace1: (val) => `myTEMP={${val}}`, 32 | replace2: /myTEMP=/g, 33 | replace3: 'my=', 34 | }, 35 | { 36 | pattern: /mt=\{([\d]+[\.]?[\d]*)\}/, 37 | replace1: (val) => `mtTEMP={${val}}`, 38 | replace2: /mtTEMP=/g, 39 | replace3: 'mt=', 40 | }, 41 | { 42 | pattern: /mb=\{([\d]+[\.]?[\d]*)\}/, 43 | replace1: (val) => `mbTEMP={${val}}`, 44 | replace2: /mbTEMP=/g, 45 | replace3: 'mb=', 46 | }, 47 | { 48 | pattern: /ml=\{([\d]+[\.]?[\d]*)\}/, 49 | replace1: (val) => `mlTEMP={${val}}`, 50 | replace2: /mlTEMP=/g, 51 | replace3: 'ml=', 52 | }, 53 | { 54 | pattern: /mr=\{([\d]+[\.]?[\d]*)\}/, 55 | replace1: (val) => `mrTEMP={${val}}`, 56 | replace2: /mrTEMP=/g, 57 | replace3: 'mr=', 58 | }, 59 | { 60 | pattern: / p=\{([\d]+[\.]?[\d]*)\}/, 61 | replace1: (val) => ` pTEMP={${val}}`, 62 | replace2: / pTEMP=/g, 63 | replace3: ' p=', 64 | }, 65 | { 66 | pattern: /px=\{([\d]+[\.]?[\d]*)\}/, 67 | replace1: (val) => `pxTEMP={${val}}`, 68 | replace2: /pxTEMP=/g, 69 | replace3: 'px=', 70 | }, 71 | { 72 | pattern: /py=\{([\d]+[\.]?[\d]*)\}/, 73 | replace1: (val) => `pyTEMP={${val}}`, 74 | replace2: /pyTEMP=/g, 75 | replace3: 'py=', 76 | }, 77 | { 78 | pattern: /pt=\{([\d]+[\.]?[\d]*)\}/, 79 | replace1: (val) => `ptTEMP={${val}}`, 80 | replace2: /ptTEMP=/g, 81 | replace3: 'pt=', 82 | }, 83 | { 84 | pattern: /pb=\{([\d]+[\.]?[\d]*)\}/, 85 | replace1: (val) => `pbTEMP={${val}}`, 86 | replace2: /pbTEMP=/g, 87 | replace3: 'pb=', 88 | }, 89 | { 90 | pattern: /pl=\{([\d]+[\.]?[\d]*)\}/, 91 | replace1: (val) => `plTEMP={${val}}`, 92 | replace2: /plTEMP=/g, 93 | replace3: 'pl=', 94 | }, 95 | { 96 | pattern: /pr=\{([\d]+[\.]?[\d]*)\}/, 97 | replace1: (val) => `prTEMP={${val}}`, 98 | replace2: /prTEMP=/g, 99 | replace3: 'pr=', 100 | }, 101 | { 102 | pattern: /([\d]+[\.]?[\d]*)px/, 103 | replace1: (val) => `${val}TEMPpx`, 104 | replace2: /TEMPpx/g, 105 | replace3: 'px', 106 | }, 107 | ]; 108 | 109 | const zoom = 0.8; 110 | 111 | function fromDir(startPath, filter) { 112 | if (!fs.existsSync(startPath)) { 113 | console.log('no dir ', startPath); 114 | return; 115 | } 116 | 117 | var files = fs.readdirSync(startPath); 118 | for (var i = 0; i < files.length; i++) { 119 | var filename = path.join(startPath, files[i]); 120 | var stat = fs.lstatSync(filename); 121 | if (stat.isDirectory()) { 122 | fromDir(filename, filter); 123 | } else if (filename.endsWith(filter)) { 124 | var buffer = fs.readFileSync(filename); 125 | var content = buffer.toString(); 126 | var replaced = 0; 127 | for (const pattern of patterns) { 128 | while (pattern.pattern.test(content)) { 129 | var size = Number( 130 | pattern.pattern.exec(content)[1], 131 | ); 132 | content = content.replace( 133 | pattern.pattern, 134 | pattern.replace1( 135 | Number((size * zoom).toFixed(2)), 136 | ), 137 | ); 138 | replaced++; 139 | } 140 | content = content.replace( 141 | pattern.replace2, 142 | pattern.replace3, 143 | ); 144 | } 145 | fs.writeFileSync(filename, content); 146 | if (replaced) { 147 | console.log('-- found: ', filename); 148 | console.log(`>>>`, replaced, `replaced.`); 149 | } 150 | } 151 | } 152 | } 153 | 154 | const exts = ['.tsx', '.ts']; 155 | const paths = [ 156 | '../main/frontend/src/mui/', 157 | '../main/frontend/src/view/', 158 | ]; 159 | 160 | for (const path of paths) { 161 | for (const ext of exts) { 162 | fromDir(path, ext); 163 | } 164 | } 165 | --------------------------------------------------------------------------------