Skip to content

Commit d77e8a0

Browse files
committed
Merge branch 'v1'
2 parents 39c2bd4 + 885c26e commit d77e8a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1326
-1475
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
- run: yarn
3535
- name: Build
3636
run: yarn build:pkg
37+
- name: Copy Origin Bundle to Dist
38+
run: cp dist/xcpc-tools.js /tmp/xcpc-tools-bundle.js
3739
- name: Create Zip for Windows
3840
run: zip -r /tmp/xcpc-tools-win.zip dist/pkg/xcpc-tools-win.exe
3941
- name: Create Tar for MacOS
@@ -50,6 +52,7 @@ jobs:
5052
with:
5153
tag_name: ${{ steps.tag.outputs.version }}-${{ steps.tag.outputs.sha_short }}
5254
files: |
55+
/tmp/xcpc-tools-bundle.js
5356
/tmp/xcpc-tools-win.zip
5457
/tmp/xcpc-tools-macos.tar.gz
5558
/tmp/xcpc-tools-linux.tar.gz

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ config.*.json
1717
data/
1818
yarn.lock
1919
pnpm-lock.yaml
20-
tsconfig.json
21-
tsconfig.*.json
2220

2321
.yarn/cache
2422
.yarn/build-state.yml

build.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
/* eslint-disable import/no-dynamic-require */
22
import path from 'path';
3+
import zlib from 'zlib';
4+
import { encode } from 'base16384';
35
import esbuild from 'esbuild';
6+
import { chunk } from 'lodash';
47
import { fs, Logger } from '@hydrooj/utils';
58

69
const logger = new Logger('build');
710
logger.info('Building...');
11+
12+
function encodeBinary(a: Buffer) {
13+
const file = zlib.gzipSync(a);
14+
return chunk([...encode(file)], 1000).map((i) => String.fromCodePoint(...i)).join('');
15+
}
16+
17+
const nopMap = '//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIiJdLCJtYXBwaW5ncyI6IkEifQ==';
18+
819
(async () => {
920
fs.ensureDirSync(path.resolve(process.cwd(), 'dist'));
1021
const res = await esbuild.build({
@@ -13,12 +24,30 @@ logger.info('Building...');
1324
outdir: path.join(process.cwd(), 'dist'),
1425
splitting: false,
1526
write: false,
27+
tsconfig: path.resolve(process.cwd(), 'tsconfig.json'),
1628
minify: true,
17-
entryPoints: [path.resolve(process.cwd(), 'entry.ts')],
18-
loader: {
19-
'.frontend': 'base64',
20-
'.ttf': 'base64',
21-
'.wasm': 'base64',
29+
entryPoints: [path.resolve(process.cwd(), 'packages/server/index.ts')],
30+
charset: 'utf8',
31+
sourcemap: 'inline',
32+
plugins: [{
33+
name: 'base16384',
34+
setup(b) {
35+
b.onLoad({ filter: /\.(frontend|ttf|wasm)$/, namespace: 'file' }, (t) => {
36+
const file = fs.readFileSync(path.join(t.path));
37+
return {
38+
contents: `module.exports = "${encodeBinary(file)}";\n${nopMap}`,
39+
loader: 'tsx',
40+
};
41+
});
42+
b.onLoad({ filter: /node_modules\/.+\.js$/ }, (t) => ({
43+
contents: `${fs.readFileSync(t.path, 'utf8')}\n${nopMap}`,
44+
loader: 'default',
45+
}));
46+
},
47+
}],
48+
alias: {
49+
ws: `${path.dirname(require.resolve('ws/package.json'))}/index.js`,
50+
saslprep: path.resolve(__dirname, 'saslprep.js'),
2251
},
2352
});
2453
if (res.errors.length) console.error(res.errors);

entry.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@
66
"packages/*"
77
],
88
"scripts": {
9-
"start:client": "node -r ./register.js packages/client/index.ts",
10-
"start:server": "node -r ./register.js packages/server/index.ts",
9+
"start:client": "node -r ./register.js packages/server/index.ts --client --debug",
10+
"start:server": "node -r ./register.js packages/server/index.ts --debug",
11+
"lint": "eslint packages --ext js,ts,tsx,jsx",
1112
"build": "yarn build:ui:prod && node -r ./register.js build.ts",
13+
"build:server": "node -r ./register.js build.ts",
1214
"build:pkg": "yarn build:ui:prod && node -r ./register.js build.ts && pkg dist/xcpc-tools.js --targets linux,macos,win --out-path dist/pkg"
1315
},
1416
"devDependencies": {
1517
"@expo-google-fonts/noto-color-emoji": "^0.2.3",
1618
"@expo-google-fonts/noto-sans-sc": "^0.2.3",
17-
"@hydrooj/eslint-config": "^1.0.7",
18-
"@hydrooj/utils": "^1.4.17",
19-
"@types/node": "^20.10.5",
19+
"@hydrooj/eslint-config": "^1.0.10",
20+
"@hydrooj/register": "^1.0.1",
21+
"@hydrooj/utils": "^1.4.24",
22+
"@types/node": "^20.14.2",
23+
"@yao-pkg/pkg": "^5.12.0",
2024
"dejavu-fonts-ttf": "^2.37.3",
21-
"eslint": "^8.56.0",
25+
"eslint": "^8.57.0",
2226
"eslint-import-resolver-typescript": "^3.6.1",
23-
"pkg": "^5.8.1",
2427
"typescript": "^5.3.3"
2528
},
2629
"resolutions": {

packages/client/assets.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

packages/client/balloon.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/client/fetcher.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

packages/client/index.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)