mirror of
https://github.com/rust-windowing/winit.git
synced 2026-06-27 15:13:13 -04:00
Move Web backend to winit-web
This commit is contained in:
committed by
Kirill Chibisov
parent
2d4b9938f0
commit
e542a78deb
19
winit-web/src/script/.swcrc
Normal file
19
winit-web/src/script/.swcrc
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"module": {
|
||||
"type": "es6"
|
||||
},
|
||||
"isModule": true,
|
||||
"minify": true,
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
},
|
||||
"target": "es2022",
|
||||
"minify": {
|
||||
"compress": {
|
||||
"unused": true
|
||||
},
|
||||
"mangle": true
|
||||
}
|
||||
}
|
||||
}
|
||||
32
winit-web/src/script/eslint.config.mjs
Normal file
32
winit-web/src/script/eslint.config.mjs
Normal file
@@ -0,0 +1,32 @@
|
||||
import eslint from '@eslint/js'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import globals from 'globals'
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: ['**/*.min.js', 'eslint.config.mjs'],
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.strictTypeChecked,
|
||||
...tseslint.configs.stylisticTypeChecked,
|
||||
{
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
project: ['tsconfig.json'],
|
||||
sourceType: 'module',
|
||||
},
|
||||
globals: {
|
||||
...globals.browser,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-confusing-void-expression': [
|
||||
'error',
|
||||
{
|
||||
ignoreArrowShorthand: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
)
|
||||
8
winit-web/src/script/package.json
Normal file
8
winit-web/src/script/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9",
|
||||
"eslint": "^9",
|
||||
"typescript": "^5",
|
||||
"typescript-eslint": "^8"
|
||||
}
|
||||
}
|
||||
12
winit-web/src/script/scheduler.d.ts
vendored
Normal file
12
winit-web/src/script/scheduler.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
declare global {
|
||||
// eslint-disable-next-line no-var
|
||||
var scheduler: Scheduler
|
||||
}
|
||||
|
||||
export interface Scheduler {
|
||||
postTask<T>(callback: () => T | PromiseLike<T>, options?: SchedulerPostTaskOptions): Promise<T>
|
||||
}
|
||||
|
||||
export interface SchedulerPostTaskOptions {
|
||||
delay?: number
|
||||
}
|
||||
14
winit-web/src/script/tsconfig.json
Normal file
14
winit-web/src/script/tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"allowUnreachableCode": false,
|
||||
"allowUnusedLabels": false,
|
||||
"exactOptionalPropertyTypes": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"strict": true,
|
||||
}
|
||||
}
|
||||
1
winit-web/src/script/worker.min.js
vendored
Normal file
1
winit-web/src/script/worker.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
onmessage=e=>{let[s,a]=e.data,l=()=>s.postMessage(void 0);"scheduler"in globalThis?globalThis.scheduler.postTask(l,{delay:a}):setTimeout(l,a)};
|
||||
10
winit-web/src/script/worker.ts
Normal file
10
winit-web/src/script/worker.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
onmessage = (event) => {
|
||||
const [port, timeout] = event.data as [MessagePort, number]
|
||||
const f = () => port.postMessage(undefined)
|
||||
|
||||
if ('scheduler' in globalThis) {
|
||||
void globalThis.scheduler.postTask(f, { delay: timeout })
|
||||
} else {
|
||||
setTimeout(f, timeout)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user