switch to importable web types

This commit is contained in:
2026-02-09 07:29:26 -08:00
parent 4c587528fc
commit fad7c4600a
7 changed files with 2364 additions and 16 deletions
+1 -3
View File
@@ -5,6 +5,4 @@ dist
.env
*.tgz
docs
bin
deno.lock
package-lock.json
bin
-4
View File
@@ -1,4 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/denoland/deno/refs/heads/main/cli/schemas/config-file.v1.json",
"nodeModulesDir":"none"
}
+2334
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -41,10 +41,10 @@
"workerless": "^0.1.0"
},
"devDependencies": {
"@sugoidogo/node-web-globals": "^1.1.0",
"@sugoidogo/web-filesystem-types": "^2.0.0",
"@types/deno": "^2.5.0",
"@sugoidogo/importable-types-web": "^1.0.0",
"@types/md5": "^2.3.6",
"@types/node": "^25.2.2",
"@types/web": "^0.0.329",
"deno": "^2.6.8",
"typedoc": "^0.28.16",
"typescript": "^5.9.3",
+1 -1
View File
@@ -3,7 +3,7 @@
"target": "es2022",
"module": "es2022",
"moduleResolution": "node",
"lib": ["ESNext"],
"lib": ["ES2022"],
"rewriteRelativeImportExtensions": true,
"erasableSyntaxOnly": true,
"verbatimModuleSyntax": true,
+23
View File
@@ -312,6 +312,29 @@ import { CFV2Client } from 'curseforge-v2'
import { forAsync } from '@sugoidogo/js-util'
import * as modrinth from '@modrinth-ts/lib/dist/index'
import type {
Crypto,
FileSystemDirectoryHandle,
FileSystemGetDirectoryOptions,
FileSystemGetFileOptions,
TextDecoder,
TextEncoder,
Console
} from '@sugoidogo/importable-types-web'
declare var TextEncoder: {
prototype: TextEncoder;
new(): TextEncoder;
};
declare var TextDecoder: {
prototype: TextDecoder
new(): TextDecoder
}
declare var crypto: Crypto
declare var console: Console
export async function getHash(data: Uint8Array<ArrayBuffer> | string, format: HashFormat): Promise<string | number> {
if (typeof data === 'string') data = new TextEncoder().encode(data)
if (format.startsWith('sha')) { // copied from https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API/Non-cryptographic_uses_of_subtle_crypto#hashing_a_file
+2 -5
View File
@@ -3,15 +3,12 @@
"target": "es2022",
"module": "es2022",
"moduleResolution": "node",
"lib": ["ESNext"],
"lib": ["ES2022"],
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "../../dist",
"types": [
"@sugoidogo/node-web-globals",
"@sugoidogo/web-filesystem-types"
],
"types": [],
"rewriteRelativeImportExtensions": true,
"erasableSyntaxOnly": true,
"verbatimModuleSyntax": true