-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replace deprecated methods and use importMaps for Deno
- Loading branch information
Showing
3 changed files
with
12 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
"dev": "deno fmt && deno lint && deno task test && deno task check", | ||
"coverage": "rm -rf ./test/cov_profile && deno task test --coverage=./test/cov_profile && deno coverage --lcov --output=./coverage.lcov ./test/cov_profile", | ||
"report": "genhtml ./coverage.lcov --output-directory ./test/coverage/ && echo 'Point your browser to test/coverage/index.html to see the test coverage report.'", | ||
"bundle": "cd bundling && ./bundle-all.sh", | ||
"bundle-web": "mkdir -p out deno_cache && cd bundling && DENO_DIR=$PWD/../deno_cache deno run --unstable --quiet --allow-net --allow-read --allow-env=DENO_DIR,XDG_CACHE_HOME,HOME,DENO_AUTH_TOKENS --allow-write=../out,$PWD/../deno_cache bundle-web.ts dev ../src/mod.ts", | ||
"contribs": "deno run --allow-env --allow-read --allow-write=. --allow-net=api.github.com --allow-sys npm:all-contributors-cli" | ||
}, | ||
|
@@ -31,5 +30,10 @@ | |
"./package-lock.json", | ||
"./bundling/bundles" | ||
] | ||
}, | ||
"imports": { | ||
"@std/path": "jsr:@std/path@^0.221.0", | ||
"grammy_types": "https://deno.land/x/[email protected]/mod.ts", | ||
"debug": "https://cdn.skypack.dev/[email protected]" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
// === Needed imports | ||
import { basename } from "https://deno.land/[email protected]/path/basename.ts"; | ||
import { iterateReader } from "https://deno.land/[email protected]/streams/iterate_reader.ts"; | ||
import { basename } from "@std/path"; | ||
import { | ||
type ApiMethods as ApiMethodsF, | ||
type InputMedia as InputMediaF, | ||
|
@@ -11,13 +10,13 @@ import { | |
type InputMediaVideo as InputMediaVideoF, | ||
type InputSticker as InputStickerF, | ||
type Opts as OptsF, | ||
} from "https://deno.land/x/grammy_types@v3.6.2/mod.ts"; | ||
} from "grammy_types"; | ||
import { debug as d, isDeno } from "./platform.deno.ts"; | ||
|
||
const debug = d("grammy:warn"); | ||
|
||
// === Export all API types | ||
export * from "https://deno.land/x/grammy_types@v3.6.2/mod.ts"; | ||
export * from "grammy_types"; | ||
|
||
/** A value, or a potentially async function supplying that value */ | ||
type MaybeSupplier<T> = T | (() => T | Promise<T>); | ||
|
@@ -114,11 +113,11 @@ export class InputFile { | |
"Reading files by path requires a Deno environment", | ||
); | ||
} | ||
const file = await Deno.open(data); | ||
return iterateReader(file); | ||
using file = await Deno.open(data); | ||
return file.readable; | ||
} | ||
if (data instanceof Blob) return data.stream(); | ||
if (isDenoFile(data)) return iterateReader(data); | ||
if (isDenoFile(data)) return data.readable; | ||
// Handle Response objects | ||
if (data instanceof Response) { | ||
if (data.body === null) throw new Error(`No response body!`); | ||
|