Skip to content

Commit 58dea1c

Browse files
TC999Copilotxmcp
authored
修复编译报错 && CI 编译 (#314)
* Create node.js.yml * Update node.js.yml * Update node.js.yml * Update node.js.yml * 去掉报错 * 修复编译命令 * Initial plan * Fix TypeScript compilation errors for ArrayBufferLike compatibility Co-authored-by: TC999 <[email protected]> * 测试 * also build edg package --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: xmcp <[email protected]>
1 parent a7cd106 commit 58dea1c

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

.github/workflows/node.js.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ "master" ]
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
matrix:
18+
node-version: [lts/*]
19+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
#cache: 'npm'
28+
- run: npm install
29+
- run: npm install -g grunt-cli
30+
- run: npm run build:chrome
31+
- run: npm run build:firefox
32+
- run: npm run build:edg
33+
- name: Upload a Build Artifact
34+
uses: actions/[email protected]
35+
with:
36+
name: extension
37+
path: dist/*.zip

pakkujs/background/compressor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ let base85 = (function () {
126126
// borrowed from https://evanhahn.com/javascript-compression-streams-api-with-strings/
127127

128128
async function concat_u8_array(arrays: Uint8Array[]): Promise<Uint8Array> {
129-
let ab = await new Blob(arrays).arrayBuffer();
129+
let ab = await new Blob(arrays as BlobPart[]).arrayBuffer();
130130
return new Uint8Array(ab);
131131
}
132132

pakkujs/content_script/xhr_hook.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type MutableXMLHttpRequest = Mutable<XMLHttpRequest>;
5454

5555
function uint8array_to_arraybuffer(array: Uint8Array) {
5656
// https://stackoverflow.com/questions/37228285/uint8array-to-arraybuffer
57-
return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset);
57+
return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset) as ArrayBuffer;
5858
}
5959

6060
function str_to_arraybuffer(str: string) {
@@ -281,7 +281,7 @@ type MutableXMLHttpRequest = Mutable<XMLHttpRequest>;
281281

282282
let resp_data;
283283
if(resp.data instanceof Uint8Array)
284-
resp_data = resp.data;
284+
resp_data = uint8array_to_arraybuffer(resp.data);
285285
else if(typeof resp.data === 'object')
286286
resp_data = byte_object_to_arraybuffer(resp.data);
287287
else // str

pakkujs/core/scheduler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function perform_throttle(fn: ()=>void) {
5353

5454
// https://stackoverflow.com/questions/37228285/uint8array-to-arraybuffer
5555
function u8array_to_arraybuffer(array: Uint8Array): ArrayBuffer {
56-
return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset)
56+
return array.buffer.slice(array.byteOffset, array.byteLength + array.byteOffset) as ArrayBuffer
5757
}
5858

5959
class Scheduler {

0 commit comments

Comments
 (0)