Skip to content

Commit ea55359

Browse files
format (#315)
Co-authored-by: Taromati2 <taromati2@outlook.com>
1 parent d0dfb0d commit ea55359

229 files changed

Lines changed: 434 additions & 465 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/pages/base.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ if (!is_hidden_page) {
185185
*/
186186
export function setPreRender(hostUrl = urlParams.get('hostUrl') ?? localStorage.getItem('fountHostUrl') ?? 'http://localhost:8931') {
187187
const host = new URL(hostUrl.includes('://') ? hostUrl : `http://${hostUrl}`)
188-
const href = new URL('/parts/shells/home' + host.search + host.hash, host).href
188+
const { href } = new URL('/parts/shells/home' + host.search + host.hash, host)
189189
if (HTMLScriptElement.supports?.('speculationrules')) {
190190
const specScript = document.createElement('script')
191191
specScript.type = 'speculationrules'

.github/pages/test/frontend/fixtures.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ export function createPagesFixtures(options = {}) {
8383

8484
const fixtures = createPagesFixtures()
8585
/** 默认 Pages E2E 用例(`createPagesFixtures()` 产物)。 */
86-
export const test = fixtures.test
86+
export const { test } = fixtures
8787
/** 重导出 Playwright `expect` 断言。 */
8888
export { expect }

.github/pages/test/frontend/smoke.spec.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ test.describe('GitHub Pages smoke', () => {
8989
})
9090
})
9191

92-
const EULA_MD = /EULA\.[^/?#]+\.md/
92+
const EULA_MD = /EULA\.[^#/?]+\.md/
9393
const RELEASE_DOWNLOAD = /github\.com\/steve02081504\/fount\/releases\/latest\/download\/(fount\.exe|fount\.sh)/
9494

9595
/**
@@ -99,7 +99,7 @@ const RELEASE_DOWNLOAD = /github\.com\/steve02081504\/fount\/releases\/latest\/d
9999
*/
100100
async function fulfillEulaFromRepo(route) {
101101
expect(route.request().url()).not.toContain('__FOUNT_')
102-
const match = /EULA\.([^/?#]+)\.md/.exec(route.request().url())
102+
const match = /EULA\.([^#/?]+)\.md/.exec(route.request().url())
103103
const locale = match[1]
104104
const body = await readFile(join(REPO_ROOT, 'docs/EULA', `EULA.${locale}.md`), 'utf8')
105105
await route.fulfill({ status: 200, contentType: 'text/markdown; charset=utf-8', body })

deno.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,23 @@
5151
"exclude": [
5252
"src/public/pages/",
5353
".github/pages/",
54-
"src/public/parts/shells/*/public/**"
54+
"src/public/parts/shells/*/public/**",
55+
"**/test/frontend/**"
5556
],
5657
"rules": {
5758
"exclude": [
5859
"no-unversioned-import",
5960
"no-import-prefix",
60-
"no-debugger"
61+
"no-debugger",
62+
"require-await",
63+
"no-unused-vars",
64+
"no-inner-declarations",
65+
"no-explicit-any",
66+
"no-cond-assign",
67+
"no-control-regex",
68+
"no-dupe-else-if",
69+
"no-empty",
70+
"no-empty-pattern"
6171
]
6272
}
6373
}

imgs/icon_anime/fluid/boundary.mjs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const collectEdgeCells = (world, edge, out) => {
6565
*/
6666
const accumulateExposure = (world, roles) => {
6767
const { gravity, boundary } = world
68-
const exposure = boundary.exposure
68+
const { exposure } = boundary
6969
for (let e = 0; e < 4; e++) {
7070
const delta = roles[e].nx * gravity.gx + roles[e].ny * gravity.gy
7171
exposure[e] = Math.max(0, exposure[e] + delta)
@@ -84,8 +84,7 @@ const stepEdgeExchange = (world, roles) => {
8484
const cells = []
8585

8686
for (let e = 0; e < 4; e++) {
87-
const sink = roles[e].sink
88-
const source = roles[e].source
87+
const { sink, source } = roles[e]
8988
if (sink < 0.05 && source < 0.05) continue
9089
collectEdgeCells(world, e, cells)
9190

@@ -124,7 +123,7 @@ const stepEdgeExchange = (world, roles) => {
124123
}
125124

126125
if (source > 0.15 && !boundary.regurgitating)
127-
for (const cell of cells)
126+
for (const cell of cells)
128127
if (melt[cell] > 0.02) {
129128
const take = melt[cell] * source
130129
boundary.absorbedUnits += take
@@ -139,7 +138,6 @@ const stepEdgeExchange = (world, roles) => {
139138
}
140139
markAirIfMeltDrawCrossed(world, before, melt[cell])
141140
}
142-
143141
}
144142
}
145143

imgs/icon_anime/fluid/components.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const takeStats = (pool, id) => {
3636
/** `labelComponents` 返回壳。 */
3737
const LABEL_OUT = {
3838
/** @type {(ComponentStats | undefined)[]} */
39-
components: /** @type {(ComponentStats | undefined)[]} */ [],
39+
components: /** @type {(ComponentStats | undefined)[]} */[],
4040
nextId: 1,
4141
seedComponentId: 0,
4242
}
@@ -63,9 +63,7 @@ const LABEL_OUT = {
6363
*/
6464
export const labelComponents = (world, opts) => {
6565
const { worldW: W, worldH: H } = world
66-
const accept = opts.accept
67-
const labels = opts.labels
68-
const onCell = opts.onCell
66+
const { accept, labels, onCell } = opts
6967
const poolKey = opts.poolKey ?? 'componentPool'
7068
const pool = /** @type {ComponentStats[]} */ world.scratch[poolKey] ??= []
7169
const listKey = `${poolKey}List`

imgs/icon_anime/fluid/edges.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export const neighborCoord = (world, x, y, dx, dy, discretePickSalt) => {
176176
return NEIGHBOR
177177
}
178178

179-
const wrap = roles[crossed].wrap
179+
const { wrap } = roles[crossed]
180180
const outFrac = 1 - wrap
181181

182182
if (discretePickSalt !== undefined) {

imgs/icon_anime/fluid/gas/velocity.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ export const stepGas = (world, opts) => {
208208

209209
const { worldW: W, worldH: H, regionId, regions, gravity } = world
210210
const n = W * H
211-
const gasUx = world.gasUx
212-
const gasUy = world.gasUy
211+
const { gasUx, gasUy } = world
213212
const nextUx = scratch(world, 'gasNextUx', n, Float32Array)
214213
const nextUy = scratch(world, 'gasNextUy', n, Float32Array)
215214
const blocked = scratch(world, 'gasBlocked', n, Uint8Array)

imgs/icon_anime/fluid/liquid/hydraulic.mjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const bindSurfScratch = (world, surf) => {
6666
* @param {SurfSoa} surf 自由面 SoA
6767
*/
6868
const pushSurface = (world, x, y, component, pressure, phi, surf) => {
69-
const n = surf.n
69+
const { n } = surf
7070
if (n >= surf.x.length) {
7171
const { prefix } = surf
7272
surf.x = growScratch(world, `${prefix}X`, n + 1, Int32Array)
@@ -138,7 +138,7 @@ const onLiquidCell = (world, cell, x, y, id) => {
138138
if (!isLiquidFreeSurface(world, x, y, upW)) return
139139
const up = /** @type {{ dx: number, dy: number, w: number }} */ ctx.up
140140
const depth = /** @type {Float32Array} */ ctx.depth
141-
const W = ctx.W
141+
const { W } = ctx
142142
let airP = pressureAt(world, x, y)
143143
if (up.w > 0) {
144144
const ax = x + up.dx
@@ -180,7 +180,7 @@ const acceptMeltCell = (world, cell) =>
180180
const onMeltCell = (world, cell, x, y, id) => {
181181
const ctx = MELT_LABEL_CTX
182182
const upW = /** @type {{ dx: number[], dy: number[], w: number[], n: number }} */ ctx.upW
183-
const W = ctx.W
183+
const { W } = ctx
184184
let free = true
185185
for (let i = 0; i < upW.n; i++) {
186186
const ax = x + upW.dx[i]
@@ -195,15 +195,14 @@ const onMeltCell = (world, cell, x, y, id) => {
195195
if (!free) return
196196
const up = /** @type {{ dx: number, dy: number, w: number }} */ ctx.up
197197
const depth = /** @type {Float32Array} */ ctx.depth
198-
const surf = ctx.surf
199198
let airP = pressureAt(world, x, y)
200199
if (up.w > 0) {
201200
const ax = x + up.dx
202201
const ay = y + up.dy
203202
if (inWorld(world, ax, ay) && !isLiquidBarrier(world.mat[ay * W + ax]))
204203
airP = pressureAt(world, ax, ay)
205204
}
206-
pushSurface(world, x, y, id, airP, hydraulicPhi(airP, depth[cell]), surf)
205+
pushSurface(world, x, y, id, airP, hydraulicPhi(airP, depth[cell]), ctx.surf)
207206
}
208207

209208
/**

imgs/icon_anime/fluid/liquid/transport.mjs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const sinkOut = (mass, flowX, flowY, cell, dx, dy, amount, world) => {
109109
*/
110110
const transferNeighbor = (world, phase, flowX, flowY, W, cell, x, y, dx, dy, move, nbX, nbY, wrappedFrac, outFrac) => {
111111
if (move <= 1e-8) return
112-
const mass = phase.mass
112+
const { mass } = phase
113113
const crossed = wrappedFrac > 0 || outFrac > 0
114114
if (!crossed) {
115115
transferToCell(world, phase, flowX, flowY, mass, W, cell, x, y, nbX, nbY, move)
@@ -131,7 +131,7 @@ const transferNeighbor = (world, phase, flowX, flowY, W, cell, x, y, dx, dy, mov
131131
export const stepPhaseTransport = (world, phase, opts) => {
132132
const { worldW: W, worldH: H } = world
133133
const n = W * H
134-
const mass = phase.mass
134+
const { mass } = phase
135135
const flowX = scratch(world, phase.flowScratchX, n, Float32Array)
136136
const flowY = scratch(world, phase.flowScratchY, n, Float32Array)
137137
flowX.fill(0)
@@ -146,8 +146,7 @@ export const stepPhaseTransport = (world, phase, opts) => {
146146
const { pAt, markDirty } = pressure
147147

148148
const viscBuf = scratch(world, 'phaseVisc', n, Float32Array)
149-
const vx = phase.vx
150-
const vy = phase.vy
149+
const { vx, vy } = phase
151150

152151
// --- Settle along gravity-weighted down neighbors ---
153152
for (let si = 0; si < n; si++) {
@@ -173,8 +172,7 @@ export const stepPhaseTransport = (world, phase, opts) => {
173172
const nb = neighborCoord(world, x, y, dx, dy)
174173
const nbX = nb.x
175174
const nbY = nb.y
176-
const wrappedFrac = nb.wrappedFrac
177-
const outFrac = nb.outFrac
175+
const { wrappedFrac, outFrac } = nb
178176
const crossed = wrappedFrac > 0 || outFrac > 0
179177
let dstMass = 0
180178
let room = LIQ_FULL
@@ -233,8 +231,7 @@ export const stepPhaseTransport = (world, phase, opts) => {
233231
const nb = neighborCoord(world, x, y, dx, dy)
234232
const nbX = nb.x
235233
const nbY = nb.y
236-
const wrappedFrac = nb.wrappedFrac
237-
const outFrac = nb.outFrac
234+
const { wrappedFrac, outFrac } = nb
238235
const crossed = wrappedFrac > 0 || outFrac > 0
239236
if (!crossed) {
240237
const target = nbY * W + nbX

0 commit comments

Comments
 (0)