Skip to content

Commit

Permalink
curl module
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-782 committed Dec 24, 2023
1 parent a31df64 commit ee775ce
Show file tree
Hide file tree
Showing 7 changed files with 840 additions and 6 deletions.
640 changes: 640 additions & 0 deletions includes/curl.d.ts

Large diffs are not rendered by default.

161 changes: 158 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"bundle": "esbuild ./src/index.ts --bundle --outfile=build/esbuild/bootstrap.js --format=esm --external:unsafe --target=es2017 --alias:@war3js/unsafe=unsafe",
"bundle-polyfill": "esbuild ./src/polyfill.ts --bundle --outfile=build/esbuild/polyfill.js --format=esm --external:unsafe --target=es2020 --alias:@war3js/unsafe=unsafe",
"bundle-bootstrap": "esbuild ./src/index.ts --bundle --outfile=build/esbuild/bootstrap.js --format=esm --external:unsafe --target=es2020 --alias:@war3js/unsafe=unsafe",
"bundle": "npm run bundle-polyfill && npm run bundle-bootstrap",
"start": "ts-node-esm ./src/test.ts",
"lint": "eslint ./src/ --ext .ts --rulesdir ./eslint/rules/",
"typesgen": "tsc && dts-bundle-generator build/tsc/types/index.d.ts -o build/dts-bundle/out.d.ts --export-referenced-types=false --external-inlines=@war3js/events --external-imports=@war3js/unsafe --inline-declare-global=true && ts-node-esm ./src/typesAppener.ts && node ./utils/tsconfigPrepare.js && tsc -p ./build/fullTypes/tsconfig.json && node ./utils/tsconfigRemove.js",
"typesgen": "tsc && dts-bundle-generator build/tsc/types/index.d.ts -o build/dts-bundle/out.d.ts --export-referenced-types=false --external-inlines=readable-stream --external-inlines=@war3js/events --external-imports=@war3js/unsafe --inline-declare-global=true && ts-node-esm ./src/typesAppener.ts && node ./utils/tsconfigPrepare.js && tsc -p ./build/fullTypes/tsconfig.json && node ./utils/tsconfigRemove.js",
"docgen": "node ./utils/tsconfigPrepare.js && typedoc && node ./utils/tsconfigRemove.js",
"clean": "node ./utils/clean.js",
"build": "npm run bundle && npm run typesgen && npm run docgen"
Expand All @@ -28,11 +30,15 @@
"eslint": "^8.53.0",
"jass-to-ast": "^2.0.2",
"prettier": "3.0.3",
"readable-stream": "^4.5.1",
"text-decoding": "^1.0.0",
"ts-morph": "^20.0.0",
"ts-node": "^10.9.1",
"typed-emitter": "^2.1.0",
"typedoc": "^0.25.3",
"typescript": "^5.2.2"
},
"dependencies": {
"@types/readable-stream": "^4.0.10"
}
}
21 changes: 21 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,27 @@ import { Destructable } from "./handles/Destructable.js";
import { Item } from "./handles/Item.js";
import { HandleWrapper } from "./services/HandleWrapper.js";

import { Readable, Writable, Transform, Duplex, pipeline, finished } from "readable-stream";

export const stream: any = {
Readable,
Writable,
Transform,
Duplex,
pipeline,
finished,
};

Object.freeze(stream);

import * as _Buffer from "buffer";

export const buffer: any = {
..._Buffer,
};

Object.freeze(buffer);

export const isUjApi = !!getNativeByName("GetUjAPIVersion");
export const console = new Console();

Expand Down
1 change: 1 addition & 0 deletions src/polyfill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "abort-controller/polyfill";
11 changes: 11 additions & 0 deletions src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ import { __getDatabaseGlobalType, getNativeByName } from "@war3js/unsafe";
import { Player, Unit } from "./index.js";
import { TriggerUnitEvent } from "./triggerEvents/unit/TriggerUnitEvent.js";
import { isNode } from "./utils/runtime.js";
import { Readable } from "stream";

import { curl_easy_init, constants, curl_easy_setopt, curl_easy_perform } from "curl";

const curl = curl_easy_init();

curl_easy_setopt(curl, constants.CURLOPT_URL, "wss://test");

curl_easy_perform(curl, () => {
// Ready
});

const hpal = new Unit(Player.getById(0), 1215324524, 0, 0, 0);
//const hpalI = Unit.createIllusionFromUnit(hpal);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"esModuleInterop": true,
"declarationDir": "build/tsc/types",
"baseUrl": "./src",
"types": ["@war3js/text-decoding-types", "@types/node"]
"types": ["@war3js/text-decoding-types", "./includes/curl"]
},
"include": ["src/**/*"],
"exclude": ["../typesAppenderConfig.d.ts"]
Expand Down

0 comments on commit ee775ce

Please sign in to comment.