introduce prettierrc formatting
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
*.ice
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
*.min.js
|
||||||
|
*.wasm
|
||||||
|
*.data
|
||||||
|
|
||||||
|
archive/
|
||||||
|
tutorials/
|
||||||
|
projects/game_of_life.html
|
||||||
|
projects/oscillations_in_3d.html
|
||||||
|
|
||||||
|
thin_ice/fs
|
||||||
|
thin_ice/obj
|
||||||
|
flocking/pkg
|
||||||
|
cellular_automata/static
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"semi": true,
|
||||||
|
"trailingComma": "es5"
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.nf-code {
|
.nf-code {
|
||||||
font-family: "Fraunces", serif;
|
font-family: 'Fraunces', serif;
|
||||||
font-size: clamp(7rem, 22vw, 16rem);
|
font-size: clamp(7rem, 22vw, 16rem);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
@@ -44,7 +44,7 @@ body {
|
|||||||
|
|
||||||
.nf-eyebrow::before,
|
.nf-eyebrow::before,
|
||||||
.nf-eyebrow::after {
|
.nf-eyebrow::after {
|
||||||
content: "";
|
content: '';
|
||||||
display: block;
|
display: block;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
width: 3rem;
|
width: 3rem;
|
||||||
@@ -53,7 +53,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.nf-heading {
|
.nf-heading {
|
||||||
font-family: "Fraunces", serif;
|
font-family: 'Fraunces', serif;
|
||||||
font-size: clamp(1.6rem, 4vw, 2.8rem);
|
font-size: clamp(1.6rem, 4vw, 2.8rem);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
const responseEl = document.getElementById('nf-response');
|
const responseEl = document.getElementById('nf-response');
|
||||||
const hintEl = document.getElementById('nf-hint');
|
const hintEl = document.getElementById('nf-hint');
|
||||||
const href = globalThis.location.href;
|
const href = globalThis.location.href;
|
||||||
const path = (href.length >= 45) ? href.substring(0, 45) : href;
|
const path = href.length >= 45 ? href.substring(0, 45) : href;
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
|
|||||||
+73
-44
@@ -1,21 +1,21 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Havox</title>
|
<title>Havox</title>
|
||||||
<meta name="description" content="John Gatward's portfolio"/>
|
<meta name="description" content="John Gatward's portfolio" />
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com"/>
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link
|
<link
|
||||||
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,700;1,400&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,600;1,9..144,300&display=swap"
|
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,700;1,400&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,600;1,9..144,300&display=swap"
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
/>
|
/>
|
||||||
<link rel="stylesheet" href="style.css"/>
|
<link rel="stylesheet" href="style.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<!-- ─── Nav ─────────────────────────────────────────────────── -->
|
<!-- ─── Nav ─────────────────────────────────────────────────── -->
|
||||||
<nav>
|
<nav>
|
||||||
<a href="#hero" class="nav-logo">havox</a>
|
<a href="#hero" class="nav-logo">havox</a>
|
||||||
<ul class="nav-links">
|
<ul class="nav-links">
|
||||||
<li><a href="#about">about</a></li>
|
<li><a href="#about">about</a></li>
|
||||||
@@ -23,10 +23,10 @@
|
|||||||
<li><a href="#projects">projects</a></li>
|
<li><a href="#projects">projects</a></li>
|
||||||
<li><a href="#contact">contact</a></li>
|
<li><a href="#contact">contact</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<!-- ─── Hero ─────────────────────────────────────────────────── -->
|
<!-- ─── Hero ─────────────────────────────────────────────────── -->
|
||||||
<section id="hero">
|
<section id="hero">
|
||||||
<p class="hero-eyebrow">// havox.org - v4</p>
|
<p class="hero-eyebrow">// havox.org - v4</p>
|
||||||
<h1 class="hero-name">John <em>Gatward</em></h1>
|
<h1 class="hero-name">John <em>Gatward</em></h1>
|
||||||
<p class="hero-subtitle">Software Engineer</p>
|
<p class="hero-subtitle">Software Engineer</p>
|
||||||
@@ -48,12 +48,12 @@
|
|||||||
<a href="#projects" class="btn btn-primary">View projects</a>
|
<a href="#projects" class="btn btn-primary">View projects</a>
|
||||||
<a href="#contact" class="btn btn-ghost">Contact me</a>
|
<a href="#contact" class="btn btn-ghost">Contact me</a>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
||||||
<!-- ─── About ─────────────────────────────────────────────────── -->
|
<!-- ─── About ─────────────────────────────────────────────────── -->
|
||||||
<section id="about" class="about-section">
|
<section id="about" class="about-section">
|
||||||
<div class="reveal">
|
<div class="reveal">
|
||||||
<p class="section-label">about</p>
|
<p class="section-label">about</p>
|
||||||
<h2 class="section-heading">Havox & <em>me</em></h2>
|
<h2 class="section-heading">Havox & <em>me</em></h2>
|
||||||
@@ -167,12 +167,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
||||||
<!-- ─── Skills ─────────────────────────────────────────────────── -->
|
<!-- ─── Skills ─────────────────────────────────────────────────── -->
|
||||||
<section id="skills">
|
<section id="skills">
|
||||||
<p class="section-label reveal">skills</p>
|
<p class="section-label reveal">skills</p>
|
||||||
<h2 class="section-heading reveal" style="transition-delay: 0.05s">
|
<h2 class="section-heading reveal" style="transition-delay: 0.05s">
|
||||||
What I <em>know</em>
|
What I <em>know</em>
|
||||||
@@ -265,12 +265,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
||||||
<!-- ─── Projects ──────────────────────────────────────────────── -->
|
<!-- ─── Projects ──────────────────────────────────────────────── -->
|
||||||
<section id="projects">
|
<section id="projects">
|
||||||
<p class="section-label reveal">projects</p>
|
<p class="section-label reveal">projects</p>
|
||||||
<h2 class="section-heading reveal" style="transition-delay: 0.05s">
|
<h2 class="section-heading reveal" style="transition-delay: 0.05s">
|
||||||
Things I <em>built</em>
|
Things I <em>built</em>
|
||||||
@@ -289,9 +289,14 @@
|
|||||||
class="card-grid card-grid--featured reveal"
|
class="card-grid card-grid--featured reveal"
|
||||||
style="transition-delay: 0.14s"
|
style="transition-delay: 0.14s"
|
||||||
>
|
>
|
||||||
<article class="card card-link" data-href="https://wordlesolver.umbra.mom">
|
<article
|
||||||
|
class="card card-link"
|
||||||
|
data-href="https://wordlesolver.umbra.mom"
|
||||||
|
>
|
||||||
<span class="card-date">9 Feb 2025</span>
|
<span class="card-date">9 Feb 2025</span>
|
||||||
<span class="project-status project-status--active">Active development</span>
|
<span class="project-status project-status--active"
|
||||||
|
>Active development</span
|
||||||
|
>
|
||||||
<span class="card-title">Wordle Solver</span>
|
<span class="card-title">Wordle Solver</span>
|
||||||
<span class="card-desc"
|
<span class="card-desc"
|
||||||
>Built after one too many missed 3-guess games. Now it plays
|
>Built after one too many missed 3-guess games. Now it plays
|
||||||
@@ -300,9 +305,19 @@
|
|||||||
>
|
>
|
||||||
<span class="card-source">
|
<span class="card-source">
|
||||||
Source code:
|
Source code:
|
||||||
<a href="https://github.com/jayo60013/wordle-solver-api" target="_blank" rel="noopener noreferrer">API</a>
|
<a
|
||||||
|
href="https://github.com/jayo60013/wordle-solver-api"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>API</a
|
||||||
|
>
|
||||||
·
|
·
|
||||||
<a href="https://github.com/jayo60013/wordle-solver-frontend" target="_blank" rel="noopener noreferrer">Frontend</a>
|
<a
|
||||||
|
href="https://github.com/jayo60013/wordle-solver-frontend"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>Frontend</a
|
||||||
|
>
|
||||||
</span>
|
</span>
|
||||||
<span class="tag-row">
|
<span class="tag-row">
|
||||||
<span class="tag tag-yellow">Rust</span>
|
<span class="tag tag-yellow">Rust</span>
|
||||||
@@ -310,9 +325,14 @@
|
|||||||
<span class="tag tag-peach">TypeScript</span>
|
<span class="tag tag-peach">TypeScript</span>
|
||||||
</span>
|
</span>
|
||||||
</article>
|
</article>
|
||||||
<article class="card card-link" data-href="https://crackthequote.umbra.mom">
|
<article
|
||||||
|
class="card card-link"
|
||||||
|
data-href="https://crackthequote.umbra.mom"
|
||||||
|
>
|
||||||
<span class="card-date">13 Apr 2024</span>
|
<span class="card-date">13 Apr 2024</span>
|
||||||
<span class="project-status project-status--active">Active development</span>
|
<span class="project-status project-status--active"
|
||||||
|
>Active development</span
|
||||||
|
>
|
||||||
<span class="card-title">Crack the Quote</span>
|
<span class="card-title">Crack the Quote</span>
|
||||||
<span class="card-desc"
|
<span class="card-desc"
|
||||||
>A substitution-cipher puzzle game with a daily challenge. Built for
|
>A substitution-cipher puzzle game with a daily challenge. Built for
|
||||||
@@ -320,7 +340,12 @@
|
|||||||
>
|
>
|
||||||
<span class="card-source">
|
<span class="card-source">
|
||||||
Source code:
|
Source code:
|
||||||
<a href="https://github.com/jayo60013/crack-the-quote-api" target="_blank" rel="noopener noreferrer">API</a>
|
<a
|
||||||
|
href="https://github.com/jayo60013/crack-the-quote-api"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>API</a
|
||||||
|
>
|
||||||
</span>
|
</span>
|
||||||
<span class="tag-row">
|
<span class="tag-row">
|
||||||
<span class="tag tag-yellow">Rust</span>
|
<span class="tag tag-yellow">Rust</span>
|
||||||
@@ -377,7 +402,9 @@
|
|||||||
data-href="https://pubquiz.umbra.mom"
|
data-href="https://pubquiz.umbra.mom"
|
||||||
>
|
>
|
||||||
<span class="card-date">03 Apr 2025</span>
|
<span class="card-date">03 Apr 2025</span>
|
||||||
<span class="project-status project-status--active">Active development</span>
|
<span class="project-status project-status--active"
|
||||||
|
>Active development</span
|
||||||
|
>
|
||||||
<span class="card-title">Pub Quiz Dashboard</span>
|
<span class="card-title">Pub Quiz Dashboard</span>
|
||||||
<span class="card-desc"
|
<span class="card-desc"
|
||||||
>A Python dashboard to track our local pub quiz performances.</span
|
>A Python dashboard to track our local pub quiz performances.</span
|
||||||
@@ -444,7 +471,9 @@
|
|||||||
data-href="https://samstoreymusic.com"
|
data-href="https://samstoreymusic.com"
|
||||||
>
|
>
|
||||||
<span class="card-date">1 Nov 2023</span>
|
<span class="card-date">1 Nov 2023</span>
|
||||||
<span class="project-status project-status--active">Active development</span>
|
<span class="project-status project-status--active"
|
||||||
|
>Active development</span
|
||||||
|
>
|
||||||
<span class="card-title">samstoreymusic.com</span>
|
<span class="card-title">samstoreymusic.com</span>
|
||||||
<span class="card-desc"
|
<span class="card-desc"
|
||||||
>A website design and build for a friend working in music. Saving
|
>A website design and build for a friend working in music. Saving
|
||||||
@@ -645,12 +674,12 @@
|
|||||||
See more
|
See more
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
|
|
||||||
<!-- ─── Contact ───────────────────────────────────────────────── -->
|
<!-- ─── Contact ───────────────────────────────────────────────── -->
|
||||||
<section id="contact">
|
<section id="contact">
|
||||||
<p class="section-label reveal">contact</p>
|
<p class="section-label reveal">contact</p>
|
||||||
<div class="contact-inner reveal" style="transition-delay: 0.1s">
|
<div class="contact-inner reveal" style="transition-delay: 0.1s">
|
||||||
<div>
|
<div>
|
||||||
@@ -691,17 +720,17 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<!-- ─── Footer ─────────────────────────────────────────────────── -->
|
<!-- ─── Footer ─────────────────────────────────────────────────── -->
|
||||||
<footer>
|
<footer>
|
||||||
<span>umbra.mom - John Gatward</span>
|
<span>umbra.mom - John Gatward</span>
|
||||||
<span>
|
<span>
|
||||||
Source code (self‑hosted):
|
Source code (self‑hosted):
|
||||||
<a href="https://gitea.umbra.mom/jay/havox">repository</a>
|
<a href="https://gitea.umbra.mom/jay/havox">repository</a>
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
../prettier/bin/prettier.cjs
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "havox",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/prettier": {
|
||||||
|
"version": "3.8.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz",
|
||||||
|
"integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"prettier": "bin/prettier.cjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
Copyright © James Long and contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
+104
@@ -0,0 +1,104 @@
|
|||||||
|
[](https://prettier.io)
|
||||||
|
|
||||||
|
<h2 align="center">Opinionated Code Formatter</h2>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<em>
|
||||||
|
JavaScript
|
||||||
|
· TypeScript
|
||||||
|
· Flow
|
||||||
|
· JSX
|
||||||
|
· JSON
|
||||||
|
</em>
|
||||||
|
<br />
|
||||||
|
<em>
|
||||||
|
CSS
|
||||||
|
· SCSS
|
||||||
|
· Less
|
||||||
|
</em>
|
||||||
|
<br />
|
||||||
|
<em>
|
||||||
|
HTML
|
||||||
|
· Vue
|
||||||
|
· Angular
|
||||||
|
</em>
|
||||||
|
<br />
|
||||||
|
<em>
|
||||||
|
GraphQL
|
||||||
|
· Markdown
|
||||||
|
· YAML
|
||||||
|
</em>
|
||||||
|
<br />
|
||||||
|
<em>
|
||||||
|
<a href="https://prettier.io/docs/plugins">
|
||||||
|
Your favorite language?
|
||||||
|
</a>
|
||||||
|
</em>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://github.com/prettier/prettier/actions?query=branch%3Amain">
|
||||||
|
<img alt="CI Status" src="https://img.shields.io/github/check-runs/prettier/prettier/main?style=flat-square&label=CI"></a>
|
||||||
|
<a href="https://codecov.io/gh/prettier/prettier">
|
||||||
|
<img alt="Coverage Status" src="https://img.shields.io/codecov/c/github/prettier/prettier.svg?style=flat-square"></a>
|
||||||
|
<a href="https://x.com/acdlite/status/974390255393505280">
|
||||||
|
<img alt="Blazing Fast" src="https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg?style=flat-square"></a>
|
||||||
|
<br/>
|
||||||
|
<a href="https://www.npmjs.com/package/prettier">
|
||||||
|
<img alt="npm version" src="https://img.shields.io/npm/v/prettier.svg?style=flat-square"></a>
|
||||||
|
<a href="https://www.npmjs.com/package/prettier">
|
||||||
|
<img alt="weekly downloads from npm" src="https://img.shields.io/npm/dw/prettier.svg?style=flat-square"></a>
|
||||||
|
<a href="https://github.com/prettier/prettier#badge">
|
||||||
|
<img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"></a>
|
||||||
|
<a href="https://x.com/intent/follow?screen_name=PrettierCode">
|
||||||
|
<img alt="Follow Prettier on X" src="https://img.shields.io/badge/%40PrettierCode-9f9f9f?style=flat-square&logo=x&labelColor=555"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Intro
|
||||||
|
|
||||||
|
Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
|
||||||
|
|
||||||
|
### Input
|
||||||
|
|
||||||
|
<!-- prettier-ignore -->
|
||||||
|
```js
|
||||||
|
foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());
|
||||||
|
```
|
||||||
|
|
||||||
|
### Output
|
||||||
|
|
||||||
|
```js
|
||||||
|
foo(
|
||||||
|
reallyLongArg(),
|
||||||
|
omgSoManyParameters(),
|
||||||
|
IShouldRefactorThis(),
|
||||||
|
isThereSeriouslyAnotherOne(),
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
Prettier can be run [in your editor](https://prettier.io/docs/editors) on-save, in a [pre-commit hook](https://prettier.io/docs/precommit), or in [CI environments](https://prettier.io/docs/cli#list-different) to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**[Documentation](https://prettier.io/docs/)**
|
||||||
|
|
||||||
|
[Install](https://prettier.io/docs/install) ·
|
||||||
|
[Options](https://prettier.io/docs/options) ·
|
||||||
|
[CLI](https://prettier.io/docs/cli) ·
|
||||||
|
[API](https://prettier.io/docs/api)
|
||||||
|
|
||||||
|
**[Playground](https://prettier.io/playground/)**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Badge
|
||||||
|
|
||||||
|
Show the world you're using _Prettier_ → [](https://github.com/prettier/prettier)
|
||||||
|
|
||||||
|
```md
|
||||||
|
[](https://github.com/prettier/prettier)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||||
+6059
File diff suppressed because it is too large
Load Diff
+80
@@ -0,0 +1,80 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||||
|
var __commonJS = function(cb, mod) {
|
||||||
|
return function __require() {
|
||||||
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// node_modules/semver-compare/index.js
|
||||||
|
var require_semver_compare = __commonJS({
|
||||||
|
"node_modules/semver-compare/index.js": function(exports2, module2) {
|
||||||
|
module2.exports = function cmp(a, b) {
|
||||||
|
var pa = a.split(".");
|
||||||
|
var pb = b.split(".");
|
||||||
|
for (var i = 0; i < 3; i++) {
|
||||||
|
var na = Number(pa[i]);
|
||||||
|
var nb = Number(pb[i]);
|
||||||
|
if (na > nb) return 1;
|
||||||
|
if (nb > na) return -1;
|
||||||
|
if (!isNaN(na) && isNaN(nb)) return 1;
|
||||||
|
if (isNaN(na) && !isNaN(nb)) return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// node_modules/please-upgrade-node/index.js
|
||||||
|
var require_please_upgrade_node = __commonJS({
|
||||||
|
"node_modules/please-upgrade-node/index.js": function(exports2, module2) {
|
||||||
|
var semverCompare = require_semver_compare();
|
||||||
|
module2.exports = function pleaseUpgradeNode2(pkg, opts) {
|
||||||
|
var opts = opts || {};
|
||||||
|
var requiredVersion = pkg.engines.node.replace(">=", "");
|
||||||
|
var currentVersion = process.version.replace("v", "");
|
||||||
|
if (semverCompare(currentVersion, requiredVersion) === -1) {
|
||||||
|
if (opts.message) {
|
||||||
|
console.error(opts.message(requiredVersion));
|
||||||
|
} else {
|
||||||
|
console.error(
|
||||||
|
pkg.name + " requires at least version " + requiredVersion + " of Node, please upgrade"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (opts.hasOwnProperty("exitCode")) {
|
||||||
|
process.exit(opts.exitCode);
|
||||||
|
} else {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// bin/prettier.cjs
|
||||||
|
var nodeModule = require("module");
|
||||||
|
if (typeof nodeModule.enableCompileCache === "function") {
|
||||||
|
nodeModule.enableCompileCache();
|
||||||
|
}
|
||||||
|
var pleaseUpgradeNode = require_please_upgrade_node();
|
||||||
|
var packageJson = require("../package.json");
|
||||||
|
pleaseUpgradeNode(packageJson);
|
||||||
|
var dynamicImport = new Function("module", "return import(module)");
|
||||||
|
var promise;
|
||||||
|
var index = process.argv.indexOf("--experimental-cli");
|
||||||
|
if (process.env.PRETTIER_EXPERIMENTAL_CLI || index !== -1) {
|
||||||
|
if (index !== -1) {
|
||||||
|
process.argv.splice(index, 1);
|
||||||
|
}
|
||||||
|
promise = dynamicImport("../internal/experimental-cli.mjs").then(
|
||||||
|
function(cli) {
|
||||||
|
return cli.__promise;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
promise = dynamicImport("../internal/legacy-cli.mjs").then(function runCli(cli) {
|
||||||
|
return cli.run();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
module.exports.__promise = promise;
|
||||||
+254
@@ -0,0 +1,254 @@
|
|||||||
|
// https://github.com/prettier/prettier/blob/next/src/document/public.js
|
||||||
|
export namespace builders {
|
||||||
|
type DocCommand =
|
||||||
|
| Align
|
||||||
|
| BreakParent
|
||||||
|
| Cursor
|
||||||
|
| Fill
|
||||||
|
| Group
|
||||||
|
| IfBreak
|
||||||
|
| Indent
|
||||||
|
| IndentIfBreak
|
||||||
|
| Label
|
||||||
|
| Line
|
||||||
|
| LineSuffix
|
||||||
|
| LineSuffixBoundary
|
||||||
|
| Trim;
|
||||||
|
type Doc = string | Doc[] | DocCommand;
|
||||||
|
|
||||||
|
interface Align {
|
||||||
|
type: "align";
|
||||||
|
contents: Doc;
|
||||||
|
n: number | string | { type: "root" };
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BreakParent {
|
||||||
|
type: "break-parent";
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Cursor {
|
||||||
|
type: "cursor";
|
||||||
|
placeholder: symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Fill {
|
||||||
|
type: "fill";
|
||||||
|
parts: Doc[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Group {
|
||||||
|
type: "group";
|
||||||
|
id?: symbol;
|
||||||
|
contents: Doc;
|
||||||
|
break: boolean;
|
||||||
|
expandedStates: Doc[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface HardlineWithoutBreakParent extends Line {
|
||||||
|
hard: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IfBreak {
|
||||||
|
type: "if-break";
|
||||||
|
breakContents: Doc;
|
||||||
|
flatContents: Doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Indent {
|
||||||
|
type: "indent";
|
||||||
|
contents: Doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IndentIfBreak {
|
||||||
|
type: "indent-if-break";
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Label {
|
||||||
|
type: "label";
|
||||||
|
label: any;
|
||||||
|
contents: Doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Line {
|
||||||
|
type: "line";
|
||||||
|
soft?: boolean | undefined;
|
||||||
|
hard?: boolean | undefined;
|
||||||
|
literal?: boolean | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LineSuffix {
|
||||||
|
type: "line-suffix";
|
||||||
|
contents: Doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LineSuffixBoundary {
|
||||||
|
type: "line-suffix-boundary";
|
||||||
|
}
|
||||||
|
|
||||||
|
interface LiterallineWithoutBreakParent extends Line {
|
||||||
|
hard: true;
|
||||||
|
literal: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
type LiteralLine = [LiterallineWithoutBreakParent, BreakParent];
|
||||||
|
|
||||||
|
interface Softline extends Line {
|
||||||
|
soft: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Hardline = [HardlineWithoutBreakParent, BreakParent];
|
||||||
|
|
||||||
|
interface Trim {
|
||||||
|
type: "trim";
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GroupOptions {
|
||||||
|
shouldBreak?: boolean | undefined;
|
||||||
|
id?: symbol | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addAlignmentToDoc(doc: Doc, size: number, tabWidth: number): Doc;
|
||||||
|
|
||||||
|
/** @see [align](https://github.com/prettier/prettier/blob/main/commands.md#align) */
|
||||||
|
function align(widthOrString: Align["n"], doc: Doc): Align;
|
||||||
|
|
||||||
|
/** @see [breakParent](https://github.com/prettier/prettier/blob/main/commands.md#breakparent) */
|
||||||
|
const breakParent: BreakParent;
|
||||||
|
|
||||||
|
/** @see [conditionalGroup](https://github.com/prettier/prettier/blob/main/commands.md#conditionalgroup) */
|
||||||
|
function conditionalGroup(alternatives: Doc[], options?: GroupOptions): Group;
|
||||||
|
|
||||||
|
/** @see [dedent](https://github.com/prettier/prettier/blob/main/commands.md#dedent) */
|
||||||
|
function dedent(doc: Doc): Align;
|
||||||
|
|
||||||
|
/** @see [dedentToRoot](https://github.com/prettier/prettier/blob/main/commands.md#dedenttoroot) */
|
||||||
|
function dedentToRoot(doc: Doc): Align;
|
||||||
|
|
||||||
|
/** @see [fill](https://github.com/prettier/prettier/blob/main/commands.md#fill) */
|
||||||
|
function fill(docs: Doc[]): Fill;
|
||||||
|
|
||||||
|
/** @see [group](https://github.com/prettier/prettier/blob/main/commands.md#group) */
|
||||||
|
function group(doc: Doc, opts?: GroupOptions): Group;
|
||||||
|
|
||||||
|
/** @see [hardline](https://github.com/prettier/prettier/blob/main/commands.md#hardline) */
|
||||||
|
const hardline: Hardline;
|
||||||
|
|
||||||
|
/** @see [hardlineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
|
||||||
|
const hardlineWithoutBreakParent: HardlineWithoutBreakParent;
|
||||||
|
|
||||||
|
/** @see [ifBreak](https://github.com/prettier/prettier/blob/main/commands.md#ifbreak) */
|
||||||
|
function ifBreak(
|
||||||
|
ifBreak: Doc,
|
||||||
|
noBreak?: Doc,
|
||||||
|
options?: { groupId?: symbol | undefined },
|
||||||
|
): IfBreak;
|
||||||
|
|
||||||
|
/** @see [indent](https://github.com/prettier/prettier/blob/main/commands.md#indent) */
|
||||||
|
function indent(doc: Doc): Indent;
|
||||||
|
|
||||||
|
/** @see [indentIfBreak](https://github.com/prettier/prettier/blob/main/commands.md#indentifbreak) */
|
||||||
|
function indentIfBreak(
|
||||||
|
doc: Doc,
|
||||||
|
opts: { groupId: symbol; negate?: boolean | undefined },
|
||||||
|
): IndentIfBreak;
|
||||||
|
|
||||||
|
/** @see [join](https://github.com/prettier/prettier/blob/main/commands.md#join) */
|
||||||
|
function join(sep: Doc, docs: Doc[]): Doc[];
|
||||||
|
|
||||||
|
/** @see [label](https://github.com/prettier/prettier/blob/main/commands.md#label) */
|
||||||
|
function label(label: any | undefined, contents: Doc): Doc;
|
||||||
|
|
||||||
|
/** @see [line](https://github.com/prettier/prettier/blob/main/commands.md#line) */
|
||||||
|
const line: Line;
|
||||||
|
|
||||||
|
/** @see [lineSuffix](https://github.com/prettier/prettier/blob/main/commands.md#linesuffix) */
|
||||||
|
function lineSuffix(suffix: Doc): LineSuffix;
|
||||||
|
|
||||||
|
/** @see [lineSuffixBoundary](https://github.com/prettier/prettier/blob/main/commands.md#linesuffixboundary) */
|
||||||
|
const lineSuffixBoundary: LineSuffixBoundary;
|
||||||
|
|
||||||
|
/** @see [literalline](https://github.com/prettier/prettier/blob/main/commands.md#literalline) */
|
||||||
|
const literalline: LiteralLine;
|
||||||
|
|
||||||
|
/** @see [literallineWithoutBreakParent](https://github.com/prettier/prettier/blob/main/commands.md#hardlinewithoutbreakparent-and-literallinewithoutbreakparent) */
|
||||||
|
const literallineWithoutBreakParent: LiterallineWithoutBreakParent;
|
||||||
|
|
||||||
|
/** @see [markAsRoot](https://github.com/prettier/prettier/blob/main/commands.md#markasroot) */
|
||||||
|
function markAsRoot(doc: Doc): Align;
|
||||||
|
|
||||||
|
/** @see [softline](https://github.com/prettier/prettier/blob/main/commands.md#softline) */
|
||||||
|
const softline: Softline;
|
||||||
|
|
||||||
|
/** @see [trim](https://github.com/prettier/prettier/blob/main/commands.md#trim) */
|
||||||
|
const trim: Trim;
|
||||||
|
|
||||||
|
/** @see [cursor](https://github.com/prettier/prettier/blob/main/commands.md#cursor) */
|
||||||
|
const cursor: Cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace printer {
|
||||||
|
function printDocToString(
|
||||||
|
doc: builders.Doc,
|
||||||
|
options: Options,
|
||||||
|
): {
|
||||||
|
formatted: string;
|
||||||
|
/**
|
||||||
|
* This property is a misnomer, and has been since the changes in
|
||||||
|
* https://github.com/prettier/prettier/pull/15709.
|
||||||
|
* The region of the document indicated by `cursorNodeStart` and `cursorNodeText` will
|
||||||
|
* sometimes actually be what lies BETWEEN a pair of leaf nodes in the AST, rather than a node.
|
||||||
|
*/
|
||||||
|
cursorNodeStart?: number | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note that, like cursorNodeStart, this is a misnomer and may actually be the text between two
|
||||||
|
* leaf nodes in the AST instead of the text of a node.
|
||||||
|
*/
|
||||||
|
cursorNodeText?: string | undefined;
|
||||||
|
};
|
||||||
|
interface Options {
|
||||||
|
/**
|
||||||
|
* Specify the line length that the printer will wrap on.
|
||||||
|
* @default 80
|
||||||
|
*/
|
||||||
|
printWidth: number;
|
||||||
|
/**
|
||||||
|
* Specify the number of spaces per indentation-level.
|
||||||
|
* @default 2
|
||||||
|
*/
|
||||||
|
tabWidth: number;
|
||||||
|
/**
|
||||||
|
* Indent lines with tabs instead of spaces
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
useTabs?: boolean;
|
||||||
|
parentParser?: string | undefined;
|
||||||
|
__embeddedInHtml?: boolean | undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace utils {
|
||||||
|
function willBreak(doc: builders.Doc): boolean;
|
||||||
|
function traverseDoc(
|
||||||
|
doc: builders.Doc,
|
||||||
|
onEnter?: (doc: builders.Doc) => void | boolean,
|
||||||
|
onExit?: (doc: builders.Doc) => void,
|
||||||
|
shouldTraverseConditionalGroups?: boolean,
|
||||||
|
): void;
|
||||||
|
function findInDoc<T = builders.Doc>(
|
||||||
|
doc: builders.Doc,
|
||||||
|
callback: (doc: builders.Doc) => T,
|
||||||
|
defaultValue: T,
|
||||||
|
): T;
|
||||||
|
function mapDoc<T = builders.Doc>(
|
||||||
|
doc: builders.Doc,
|
||||||
|
callback: (doc: builders.Doc) => T,
|
||||||
|
): T;
|
||||||
|
function removeLines(doc: builders.Doc): builders.Doc;
|
||||||
|
function stripTrailingHardline(doc: builders.Doc): builders.Doc;
|
||||||
|
function replaceEndOfLine(
|
||||||
|
doc: builders.Doc,
|
||||||
|
replacement?: builders.Doc,
|
||||||
|
): builders.Doc;
|
||||||
|
function canBreak(doc: builders.Doc): boolean;
|
||||||
|
}
|
||||||
+1511
File diff suppressed because one or more lines are too long
+1480
File diff suppressed because one or more lines are too long
+720
File diff suppressed because one or more lines are too long
+968
@@ -0,0 +1,968 @@
|
|||||||
|
// Copied from `@types/prettier`
|
||||||
|
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/5bb07fc4b087cb7ee91084afa6fe750551a7bbb1/types/prettier/index.d.ts
|
||||||
|
|
||||||
|
// Minimum TypeScript Version: 4.2
|
||||||
|
|
||||||
|
// Add `export {}` here to shut off automatic exporting from index.d.ts. There
|
||||||
|
// are quite a few utility types here that don't need to be shipped with the
|
||||||
|
// exported module.
|
||||||
|
export {};
|
||||||
|
|
||||||
|
import { builders, printer, utils } from "./doc.js";
|
||||||
|
|
||||||
|
export namespace doc {
|
||||||
|
export { builders, printer, utils };
|
||||||
|
}
|
||||||
|
|
||||||
|
// This utility is here to handle the case where you have an explicit union
|
||||||
|
// between string literals and the generic string type. It would normally
|
||||||
|
// resolve out to just the string type, but this generic LiteralUnion maintains
|
||||||
|
// the intellisense of the original union.
|
||||||
|
//
|
||||||
|
// It comes from this issue: microsoft/TypeScript#29729:
|
||||||
|
// https://github.com/microsoft/TypeScript/issues/29729#issuecomment-700527227
|
||||||
|
export type LiteralUnion<T extends U, U = string> =
|
||||||
|
| T
|
||||||
|
| (Pick<U, never> & { _?: never | undefined });
|
||||||
|
|
||||||
|
export type AST = any;
|
||||||
|
export type Doc = doc.builders.Doc;
|
||||||
|
|
||||||
|
// The type of elements that make up the given array T.
|
||||||
|
type ArrayElement<T> = T extends Array<infer E> ? E : never;
|
||||||
|
|
||||||
|
// A union of the properties of the given object that are arrays.
|
||||||
|
type ArrayProperties<T> = {
|
||||||
|
[K in keyof T]: NonNullable<T[K]> extends readonly any[] ? K : never;
|
||||||
|
}[keyof T];
|
||||||
|
|
||||||
|
// A union of the properties of the given array T that can be used to index it.
|
||||||
|
// If the array is a tuple, then that's going to be the explicit indices of the
|
||||||
|
// array, otherwise it's going to just be number.
|
||||||
|
type IndexProperties<T extends { length: number }> =
|
||||||
|
IsTuple<T> extends true ? Exclude<Partial<T>["length"], T["length"]> : number;
|
||||||
|
|
||||||
|
// Effectively performing T[P], except that it's telling TypeScript that it's
|
||||||
|
// safe to do this for tuples, arrays, or objects.
|
||||||
|
type IndexValue<T, P> = T extends any[]
|
||||||
|
? P extends number
|
||||||
|
? T[P]
|
||||||
|
: never
|
||||||
|
: P extends keyof T
|
||||||
|
? T[P]
|
||||||
|
: never;
|
||||||
|
|
||||||
|
// Determines if an object T is an array like string[] (in which case this
|
||||||
|
// evaluates to false) or a tuple like [string] (in which case this evaluates to
|
||||||
|
// true).
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
type IsTuple<T> = T extends []
|
||||||
|
? true
|
||||||
|
: T extends [infer First, ...infer Remain]
|
||||||
|
? IsTuple<Remain>
|
||||||
|
: false;
|
||||||
|
|
||||||
|
type CallProperties<T> = T extends any[] ? IndexProperties<T> : keyof T;
|
||||||
|
type IterProperties<T> = T extends any[]
|
||||||
|
? IndexProperties<T>
|
||||||
|
: ArrayProperties<T>;
|
||||||
|
|
||||||
|
type CallCallback<T, U> = (path: AstPath<T>, index: number, value: any) => U;
|
||||||
|
type EachCallback<T> = (
|
||||||
|
path: AstPath<ArrayElement<T>>,
|
||||||
|
index: number,
|
||||||
|
value: any,
|
||||||
|
) => void;
|
||||||
|
type MapCallback<T, U> = (
|
||||||
|
path: AstPath<ArrayElement<T>>,
|
||||||
|
index: number,
|
||||||
|
value: any,
|
||||||
|
) => U;
|
||||||
|
|
||||||
|
// https://github.com/prettier/prettier/blob/next/src/common/ast-path.js
|
||||||
|
export class AstPath<T = any> {
|
||||||
|
constructor(value: T);
|
||||||
|
|
||||||
|
get key(): string | null;
|
||||||
|
get index(): number | null;
|
||||||
|
get node(): T;
|
||||||
|
get parent(): T | null;
|
||||||
|
get grandparent(): T | null;
|
||||||
|
get isInArray(): boolean;
|
||||||
|
get siblings(): T[] | null;
|
||||||
|
get next(): T | null;
|
||||||
|
get previous(): T | null;
|
||||||
|
get isFirst(): boolean;
|
||||||
|
get isLast(): boolean;
|
||||||
|
get isRoot(): boolean;
|
||||||
|
get root(): T;
|
||||||
|
get ancestors(): T[];
|
||||||
|
|
||||||
|
stack: T[];
|
||||||
|
|
||||||
|
callParent<U>(callback: (path: this) => U, count?: number): U;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use `AstPath#key` or `AstPath#index`
|
||||||
|
*/
|
||||||
|
getName(): PropertyKey | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Please use `AstPath#node` or `AstPath#siblings`
|
||||||
|
*/
|
||||||
|
getValue(): T;
|
||||||
|
|
||||||
|
getNode(count?: number): T | null;
|
||||||
|
|
||||||
|
getParentNode(count?: number): T | null;
|
||||||
|
|
||||||
|
match(
|
||||||
|
...predicates: Array<
|
||||||
|
(node: any, name: string | null, number: number | null) => boolean
|
||||||
|
>
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
// For each of the tree walk functions (call, each, and map) this provides 5
|
||||||
|
// strict type signatures, along with a fallback at the end if you end up
|
||||||
|
// calling more than 5 properties deep. This helps a lot with typing because
|
||||||
|
// for the majority of cases you're calling fewer than 5 properties, so the
|
||||||
|
// tree walk functions have a clearer understanding of what you're doing.
|
||||||
|
//
|
||||||
|
// Note that resolving these types is somewhat complicated, and it wasn't
|
||||||
|
// even supported until TypeScript 4.2 (before it would just say that the
|
||||||
|
// type instantiation was excessively deep and possibly infinite).
|
||||||
|
|
||||||
|
call<U>(callback: CallCallback<T, U>): U;
|
||||||
|
call<U, P1 extends CallProperties<T>>(
|
||||||
|
callback: CallCallback<IndexValue<T, P1>, U>,
|
||||||
|
prop1: P1,
|
||||||
|
): U;
|
||||||
|
call<U, P1 extends keyof T, P2 extends CallProperties<T[P1]>>(
|
||||||
|
callback: CallCallback<IndexValue<IndexValue<T, P1>, P2>, U>,
|
||||||
|
prop1: P1,
|
||||||
|
prop2: P2,
|
||||||
|
): U;
|
||||||
|
call<
|
||||||
|
U,
|
||||||
|
P1 extends keyof T,
|
||||||
|
P2 extends CallProperties<T[P1]>,
|
||||||
|
P3 extends CallProperties<IndexValue<T[P1], P2>>,
|
||||||
|
>(
|
||||||
|
callback: CallCallback<
|
||||||
|
IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>,
|
||||||
|
U
|
||||||
|
>,
|
||||||
|
prop1: P1,
|
||||||
|
prop2: P2,
|
||||||
|
prop3: P3,
|
||||||
|
): U;
|
||||||
|
call<
|
||||||
|
U,
|
||||||
|
P1 extends keyof T,
|
||||||
|
P2 extends CallProperties<T[P1]>,
|
||||||
|
P3 extends CallProperties<IndexValue<T[P1], P2>>,
|
||||||
|
P4 extends CallProperties<IndexValue<IndexValue<T[P1], P2>, P3>>,
|
||||||
|
>(
|
||||||
|
callback: CallCallback<
|
||||||
|
IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>,
|
||||||
|
U
|
||||||
|
>,
|
||||||
|
prop1: P1,
|
||||||
|
prop2: P2,
|
||||||
|
prop3: P3,
|
||||||
|
prop4: P4,
|
||||||
|
): U;
|
||||||
|
call<U, P extends PropertyKey>(
|
||||||
|
callback: CallCallback<any, U>,
|
||||||
|
prop1: P,
|
||||||
|
prop2: P,
|
||||||
|
prop3: P,
|
||||||
|
prop4: P,
|
||||||
|
...props: P[]
|
||||||
|
): U;
|
||||||
|
|
||||||
|
each(callback: EachCallback<T>): void;
|
||||||
|
each<P1 extends IterProperties<T>>(
|
||||||
|
callback: EachCallback<IndexValue<T, P1>>,
|
||||||
|
prop1: P1,
|
||||||
|
): void;
|
||||||
|
each<P1 extends keyof T, P2 extends IterProperties<T[P1]>>(
|
||||||
|
callback: EachCallback<IndexValue<IndexValue<T, P1>, P2>>,
|
||||||
|
prop1: P1,
|
||||||
|
prop2: P2,
|
||||||
|
): void;
|
||||||
|
each<
|
||||||
|
P1 extends keyof T,
|
||||||
|
P2 extends IterProperties<T[P1]>,
|
||||||
|
P3 extends IterProperties<IndexValue<T[P1], P2>>,
|
||||||
|
>(
|
||||||
|
callback: EachCallback<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>>,
|
||||||
|
prop1: P1,
|
||||||
|
prop2: P2,
|
||||||
|
prop3: P3,
|
||||||
|
): void;
|
||||||
|
each<
|
||||||
|
P1 extends keyof T,
|
||||||
|
P2 extends IterProperties<T[P1]>,
|
||||||
|
P3 extends IterProperties<IndexValue<T[P1], P2>>,
|
||||||
|
P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3>>,
|
||||||
|
>(
|
||||||
|
callback: EachCallback<
|
||||||
|
IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>
|
||||||
|
>,
|
||||||
|
prop1: P1,
|
||||||
|
prop2: P2,
|
||||||
|
prop3: P3,
|
||||||
|
prop4: P4,
|
||||||
|
): void;
|
||||||
|
each(
|
||||||
|
callback: EachCallback<any[]>,
|
||||||
|
prop1: PropertyKey,
|
||||||
|
prop2: PropertyKey,
|
||||||
|
prop3: PropertyKey,
|
||||||
|
prop4: PropertyKey,
|
||||||
|
...props: PropertyKey[]
|
||||||
|
): void;
|
||||||
|
|
||||||
|
map<U>(callback: MapCallback<T, U>): U[];
|
||||||
|
map<U, P1 extends IterProperties<T>>(
|
||||||
|
callback: MapCallback<IndexValue<T, P1>, U>,
|
||||||
|
prop1: P1,
|
||||||
|
): U[];
|
||||||
|
map<U, P1 extends keyof T, P2 extends IterProperties<T[P1]>>(
|
||||||
|
callback: MapCallback<IndexValue<IndexValue<T, P1>, P2>, U>,
|
||||||
|
prop1: P1,
|
||||||
|
prop2: P2,
|
||||||
|
): U[];
|
||||||
|
map<
|
||||||
|
U,
|
||||||
|
P1 extends keyof T,
|
||||||
|
P2 extends IterProperties<T[P1]>,
|
||||||
|
P3 extends IterProperties<IndexValue<T[P1], P2>>,
|
||||||
|
>(
|
||||||
|
callback: MapCallback<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, U>,
|
||||||
|
prop1: P1,
|
||||||
|
prop2: P2,
|
||||||
|
prop3: P3,
|
||||||
|
): U[];
|
||||||
|
map<
|
||||||
|
U,
|
||||||
|
P1 extends keyof T,
|
||||||
|
P2 extends IterProperties<T[P1]>,
|
||||||
|
P3 extends IterProperties<IndexValue<T[P1], P2>>,
|
||||||
|
P4 extends IterProperties<IndexValue<IndexValue<T[P1], P2>, P3>>,
|
||||||
|
>(
|
||||||
|
callback: MapCallback<
|
||||||
|
IndexValue<IndexValue<IndexValue<IndexValue<T, P1>, P2>, P3>, P4>,
|
||||||
|
U
|
||||||
|
>,
|
||||||
|
prop1: P1,
|
||||||
|
prop2: P2,
|
||||||
|
prop3: P3,
|
||||||
|
prop4: P4,
|
||||||
|
): U[];
|
||||||
|
map<U>(
|
||||||
|
callback: MapCallback<any[], U>,
|
||||||
|
prop1: PropertyKey,
|
||||||
|
prop2: PropertyKey,
|
||||||
|
prop3: PropertyKey,
|
||||||
|
prop4: PropertyKey,
|
||||||
|
...props: PropertyKey[]
|
||||||
|
): U[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated `FastPath` was renamed to `AstPath` */
|
||||||
|
export type FastPath<T = any> = AstPath<T>;
|
||||||
|
|
||||||
|
export type BuiltInParser = (text: string, options?: any) => AST;
|
||||||
|
export type BuiltInParserName =
|
||||||
|
| "acorn"
|
||||||
|
| "angular"
|
||||||
|
| "babel-flow"
|
||||||
|
| "babel-ts"
|
||||||
|
| "babel"
|
||||||
|
| "css"
|
||||||
|
| "espree"
|
||||||
|
| "flow"
|
||||||
|
| "glimmer"
|
||||||
|
| "graphql"
|
||||||
|
| "html"
|
||||||
|
| "json-stringify"
|
||||||
|
| "json"
|
||||||
|
| "json5"
|
||||||
|
| "jsonc"
|
||||||
|
| "less"
|
||||||
|
| "lwc"
|
||||||
|
| "markdown"
|
||||||
|
| "mdx"
|
||||||
|
| "meriyah"
|
||||||
|
| "mjml"
|
||||||
|
| "scss"
|
||||||
|
| "typescript"
|
||||||
|
| "vue"
|
||||||
|
| "yaml";
|
||||||
|
export type BuiltInParsers = Record<BuiltInParserName, BuiltInParser>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For use in `.prettierrc.js`, `.prettierrc.ts`, `.prettierrc.cjs`, `.prettierrc.cts`, `prettierrc.mjs`, `prettierrc.mts`, `prettier.config.js`, `prettier.config.ts`, `prettier.config.cjs`, `prettier.config.cts`, `prettier.config.mjs`, `prettier.config.mts`
|
||||||
|
*/
|
||||||
|
export interface Config extends Options {
|
||||||
|
overrides?: Array<{
|
||||||
|
files: string | string[];
|
||||||
|
excludeFiles?: string | string[];
|
||||||
|
options?: Options;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Options extends Partial<RequiredOptions> {}
|
||||||
|
|
||||||
|
export interface RequiredOptions extends doc.printer.Options {
|
||||||
|
/**
|
||||||
|
* Print semicolons at the ends of statements.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
semi: boolean;
|
||||||
|
/**
|
||||||
|
* Use single quotes instead of double quotes.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
singleQuote: boolean;
|
||||||
|
/**
|
||||||
|
* Use single quotes in JSX.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
jsxSingleQuote: boolean;
|
||||||
|
/**
|
||||||
|
* Print trailing commas wherever possible.
|
||||||
|
* @default "all"
|
||||||
|
*/
|
||||||
|
trailingComma: "none" | "es5" | "all";
|
||||||
|
/**
|
||||||
|
* Print spaces between brackets in object literals.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
|
bracketSpacing: boolean;
|
||||||
|
/**
|
||||||
|
* How to wrap object literals.
|
||||||
|
* @default "preserve"
|
||||||
|
*/
|
||||||
|
objectWrap: "preserve" | "collapse";
|
||||||
|
/**
|
||||||
|
* Put the `>` of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being
|
||||||
|
* alone on the next line (does not apply to self closing elements).
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
bracketSameLine: boolean;
|
||||||
|
/**
|
||||||
|
* Format only a segment of a file.
|
||||||
|
* @default 0
|
||||||
|
*/
|
||||||
|
rangeStart: number;
|
||||||
|
/**
|
||||||
|
* Format only a segment of a file.
|
||||||
|
* @default Number.POSITIVE_INFINITY
|
||||||
|
*/
|
||||||
|
rangeEnd: number;
|
||||||
|
/**
|
||||||
|
* Specify which parser to use.
|
||||||
|
*/
|
||||||
|
parser: LiteralUnion<BuiltInParserName>;
|
||||||
|
/**
|
||||||
|
* Specify the input filepath. This will be used to do parser inference.
|
||||||
|
*/
|
||||||
|
filepath: string;
|
||||||
|
/**
|
||||||
|
* Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file.
|
||||||
|
* This is very useful when gradually transitioning large, unformatted codebases to prettier.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
requirePragma: boolean;
|
||||||
|
/**
|
||||||
|
* Prettier can insert a special @format marker at the top of files specifying that
|
||||||
|
* the file has been formatted with prettier. This works well when used in tandem with
|
||||||
|
* the --require-pragma option. If there is already a docblock at the top of
|
||||||
|
* the file then this option will add a newline to it with the @format marker.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
insertPragma: boolean;
|
||||||
|
/**
|
||||||
|
* Prettier can allow individual files to opt out of formatting if they contain a special comment, called a pragma, at the top of the file.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
checkIgnorePragma: boolean;
|
||||||
|
/**
|
||||||
|
* By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
|
||||||
|
* In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
|
||||||
|
* @default "preserve"
|
||||||
|
*/
|
||||||
|
proseWrap: "always" | "never" | "preserve";
|
||||||
|
/**
|
||||||
|
* Include parentheses around a sole arrow function parameter.
|
||||||
|
* @default "always"
|
||||||
|
*/
|
||||||
|
arrowParens: "avoid" | "always";
|
||||||
|
/**
|
||||||
|
* Provide ability to support new languages to prettier.
|
||||||
|
*/
|
||||||
|
plugins: Array<string | URL | Plugin>;
|
||||||
|
/**
|
||||||
|
* How to handle whitespaces in HTML.
|
||||||
|
* @default "css"
|
||||||
|
*/
|
||||||
|
htmlWhitespaceSensitivity: "css" | "strict" | "ignore";
|
||||||
|
/**
|
||||||
|
* Which end of line characters to apply.
|
||||||
|
* @default "lf"
|
||||||
|
*/
|
||||||
|
endOfLine: "auto" | "lf" | "crlf" | "cr";
|
||||||
|
/**
|
||||||
|
* Change when properties in objects are quoted.
|
||||||
|
* @default "as-needed"
|
||||||
|
*/
|
||||||
|
quoteProps: "as-needed" | "consistent" | "preserve";
|
||||||
|
/**
|
||||||
|
* Whether or not to indent the code inside <script> and <style> tags in Vue files.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
vueIndentScriptAndStyle: boolean;
|
||||||
|
/**
|
||||||
|
* Control whether Prettier formats quoted code embedded in the file.
|
||||||
|
* @default "auto"
|
||||||
|
*/
|
||||||
|
embeddedLanguageFormatting: "auto" | "off";
|
||||||
|
/**
|
||||||
|
* Enforce single attribute per line in HTML, Vue and JSX.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
singleAttributePerLine: boolean;
|
||||||
|
/**
|
||||||
|
* Where to print operators when binary expressions wrap lines.
|
||||||
|
* @default "end"
|
||||||
|
*/
|
||||||
|
experimentalOperatorPosition: "start" | "end";
|
||||||
|
/**
|
||||||
|
* Use curious ternaries, with the question mark after the condition, instead
|
||||||
|
* of on the same line as the consequent.
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
experimentalTernaries: boolean;
|
||||||
|
/**
|
||||||
|
* Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
|
||||||
|
* @default false
|
||||||
|
* @deprecated use bracketSameLine instead
|
||||||
|
*/
|
||||||
|
jsxBracketSameLine?: boolean;
|
||||||
|
/**
|
||||||
|
* Arbitrary additional values on an options object are always allowed.
|
||||||
|
*/
|
||||||
|
[_: string]: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ParserOptions<T = any> extends RequiredOptions {
|
||||||
|
locStart: (node: T) => number;
|
||||||
|
locEnd: (node: T) => number;
|
||||||
|
originalText: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Plugin<T = any> {
|
||||||
|
languages?: SupportLanguage[] | undefined;
|
||||||
|
parsers?: { [parserName: string]: Parser<T> } | undefined;
|
||||||
|
printers?: { [astFormat: string]: Printer<T> } | undefined;
|
||||||
|
options?: SupportOptions | undefined;
|
||||||
|
defaultOptions?: Partial<RequiredOptions> | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Parser<T = any> {
|
||||||
|
parse: (text: string, options: ParserOptions<T>) => T | Promise<T>;
|
||||||
|
astFormat: string;
|
||||||
|
hasPragma?: ((text: string) => boolean) | undefined;
|
||||||
|
hasIgnorePragma?: ((text: string) => boolean) | undefined;
|
||||||
|
locStart: (node: T) => number;
|
||||||
|
locEnd: (node: T) => number;
|
||||||
|
preprocess?:
|
||||||
|
| ((text: string, options: ParserOptions<T>) => string | Promise<string>)
|
||||||
|
| undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Printer<T = any> {
|
||||||
|
print(
|
||||||
|
path: AstPath<T>,
|
||||||
|
options: ParserOptions<T>,
|
||||||
|
print: (path: AstPath<T>) => Doc,
|
||||||
|
args?: unknown,
|
||||||
|
): Doc;
|
||||||
|
printPrettierIgnored?(
|
||||||
|
path: AstPath<T>,
|
||||||
|
options: ParserOptions<T>,
|
||||||
|
print: (path: AstPath<T>) => Doc,
|
||||||
|
args?: unknown,
|
||||||
|
): Doc;
|
||||||
|
embed?:
|
||||||
|
| ((
|
||||||
|
path: AstPath,
|
||||||
|
options: Options,
|
||||||
|
) =>
|
||||||
|
| ((
|
||||||
|
textToDoc: (text: string, options: Options) => Promise<Doc>,
|
||||||
|
print: (
|
||||||
|
selector?: string | number | Array<string | number> | AstPath,
|
||||||
|
) => Doc,
|
||||||
|
path: AstPath,
|
||||||
|
options: Options,
|
||||||
|
) => Promise<Doc | undefined> | Doc | undefined)
|
||||||
|
| Doc
|
||||||
|
| null)
|
||||||
|
| undefined;
|
||||||
|
preprocess?:
|
||||||
|
| ((ast: T, options: ParserOptions<T>) => T | Promise<T>)
|
||||||
|
| undefined;
|
||||||
|
insertPragma?: (text: string) => string;
|
||||||
|
/**
|
||||||
|
* @returns `null` if you want to remove this node
|
||||||
|
* @returns `void` if you want to use modified `cloned`
|
||||||
|
* @returns anything if you want to replace the node with it
|
||||||
|
*/
|
||||||
|
massageAstNode?:
|
||||||
|
| ((original: any, cloned: any, parent: any) => any)
|
||||||
|
| undefined;
|
||||||
|
hasPrettierIgnore?: ((path: AstPath<T>) => boolean) | undefined;
|
||||||
|
canAttachComment?: ((node: T, ancestors: T[]) => boolean) | undefined;
|
||||||
|
isBlockComment?: ((node: T) => boolean) | undefined;
|
||||||
|
willPrintOwnComments?: ((path: AstPath<T>) => boolean) | undefined;
|
||||||
|
printComment?:
|
||||||
|
| ((commentPath: AstPath<T>, options: ParserOptions<T>) => Doc)
|
||||||
|
| undefined;
|
||||||
|
/**
|
||||||
|
* By default, Prettier searches all object properties (except for a few predefined ones) of each node recursively.
|
||||||
|
* This function can be provided to override that behavior.
|
||||||
|
* @param node The node whose children should be returned.
|
||||||
|
* @param options Current options.
|
||||||
|
* @returns `[]` if the node has no children or `undefined` to fall back on the default behavior.
|
||||||
|
*/
|
||||||
|
getCommentChildNodes?:
|
||||||
|
| ((node: T, options: ParserOptions<T>) => T[] | undefined)
|
||||||
|
| undefined;
|
||||||
|
handleComments?:
|
||||||
|
| {
|
||||||
|
ownLine?:
|
||||||
|
| ((
|
||||||
|
commentNode: any,
|
||||||
|
text: string,
|
||||||
|
options: ParserOptions<T>,
|
||||||
|
ast: T,
|
||||||
|
isLastComment: boolean,
|
||||||
|
) => boolean)
|
||||||
|
| undefined;
|
||||||
|
endOfLine?:
|
||||||
|
| ((
|
||||||
|
commentNode: any,
|
||||||
|
text: string,
|
||||||
|
options: ParserOptions<T>,
|
||||||
|
ast: T,
|
||||||
|
isLastComment: boolean,
|
||||||
|
) => boolean)
|
||||||
|
| undefined;
|
||||||
|
remaining?:
|
||||||
|
| ((
|
||||||
|
commentNode: any,
|
||||||
|
text: string,
|
||||||
|
options: ParserOptions<T>,
|
||||||
|
ast: T,
|
||||||
|
isLastComment: boolean,
|
||||||
|
) => boolean)
|
||||||
|
| undefined;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
|
getVisitorKeys?:
|
||||||
|
| ((node: T, nonTraversableKeys: Set<string>) => string[])
|
||||||
|
| undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CursorOptions extends Options {
|
||||||
|
/**
|
||||||
|
* Specify where the cursor is.
|
||||||
|
*/
|
||||||
|
cursorOffset: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CursorResult {
|
||||||
|
formatted: string;
|
||||||
|
cursorOffset: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `format` is used to format text using Prettier. [Options](https://prettier.io/docs/options) may be provided to override the defaults.
|
||||||
|
*/
|
||||||
|
export function format(source: string, options?: Options): Promise<string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`.
|
||||||
|
* This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios.
|
||||||
|
*/
|
||||||
|
export function check(source: string, options?: Options): Promise<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `formatWithCursor` both formats the code, and translates a cursor position from unformatted code to formatted code.
|
||||||
|
* This is useful for editor integrations, to prevent the cursor from moving when code is formatted.
|
||||||
|
*
|
||||||
|
* The `cursorOffset` option should be provided, to specify where the cursor is.
|
||||||
|
*/
|
||||||
|
export function formatWithCursor(
|
||||||
|
source: string,
|
||||||
|
options: CursorOptions,
|
||||||
|
): Promise<CursorResult>;
|
||||||
|
|
||||||
|
export interface ResolveConfigOptions {
|
||||||
|
/**
|
||||||
|
* If set to `false`, all caching will be bypassed.
|
||||||
|
*/
|
||||||
|
useCache?: boolean | undefined;
|
||||||
|
/**
|
||||||
|
* Pass directly the path of the config file if you don't wish to search for it.
|
||||||
|
*/
|
||||||
|
config?: string | URL | undefined;
|
||||||
|
/**
|
||||||
|
* If set to `true` and an `.editorconfig` file is in your project,
|
||||||
|
* Prettier will parse it and convert its properties to the corresponding prettier configuration.
|
||||||
|
* This configuration will be overridden by `.prettierrc`, etc. Currently,
|
||||||
|
* the following EditorConfig properties are supported:
|
||||||
|
* - indent_style
|
||||||
|
* - indent_size/tab_width
|
||||||
|
* - max_line_length
|
||||||
|
*/
|
||||||
|
editorconfig?: boolean | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `resolveConfig` can be used to resolve configuration for a given source file,
|
||||||
|
* passing its path or url as the first argument. The config search will start at
|
||||||
|
* the directory of the file location and continue to search up the directory.
|
||||||
|
*
|
||||||
|
* A promise is returned which will resolve to:
|
||||||
|
*
|
||||||
|
* - An options object, providing a [config file](https://prettier.io/docs/configuration) was found.
|
||||||
|
* - `null`, if no file was found.
|
||||||
|
*
|
||||||
|
* The promise will be rejected if there was an error parsing the configuration file.
|
||||||
|
*/
|
||||||
|
export function resolveConfig(
|
||||||
|
fileUrlOrPath: string | URL,
|
||||||
|
options?: ResolveConfigOptions,
|
||||||
|
): Promise<Options | null>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `resolveConfigFile` can be used to find the path of the Prettier configuration file,
|
||||||
|
* that will be used when resolving the config (i.e. when calling `resolveConfig`).
|
||||||
|
*
|
||||||
|
* A promise is returned which will resolve to:
|
||||||
|
*
|
||||||
|
* - The path of the configuration file.
|
||||||
|
* - `null`, if no file was found.
|
||||||
|
*
|
||||||
|
* The promise will be rejected if there was an error parsing the configuration file.
|
||||||
|
*/
|
||||||
|
export function resolveConfigFile(
|
||||||
|
fileUrlOrPath?: string | URL,
|
||||||
|
): Promise<string | null>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* As you repeatedly call `resolveConfig`, the file system structure will be cached for performance. This function will clear the cache.
|
||||||
|
* Generally this is only needed for editor integrations that know that the file system has changed since the last format took place.
|
||||||
|
*/
|
||||||
|
export function clearConfigCache(): Promise<void>;
|
||||||
|
|
||||||
|
export interface SupportLanguage {
|
||||||
|
name: string;
|
||||||
|
parsers: BuiltInParserName[] | string[];
|
||||||
|
group?: string | undefined;
|
||||||
|
tmScope?: string | undefined;
|
||||||
|
aceMode?: string | undefined;
|
||||||
|
codemirrorMode?: string | undefined;
|
||||||
|
codemirrorMimeType?: string | undefined;
|
||||||
|
aliases?: string[] | undefined;
|
||||||
|
extensions?: string[] | undefined;
|
||||||
|
filenames?: string[] | undefined;
|
||||||
|
linguistLanguageId?: number | undefined;
|
||||||
|
vscodeLanguageIds?: string[] | undefined;
|
||||||
|
interpreters?: string[] | undefined;
|
||||||
|
isSupported?: ((options: { filepath: string }) => boolean) | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SupportOptionRange {
|
||||||
|
start: number;
|
||||||
|
end: number;
|
||||||
|
step: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SupportOptionType =
|
||||||
|
| "int"
|
||||||
|
| "string"
|
||||||
|
| "boolean"
|
||||||
|
| "choice"
|
||||||
|
| "path";
|
||||||
|
|
||||||
|
export type CoreCategoryType =
|
||||||
|
| "Config"
|
||||||
|
| "Editor"
|
||||||
|
| "Format"
|
||||||
|
| "Other"
|
||||||
|
| "Output"
|
||||||
|
| "Global"
|
||||||
|
| "Special";
|
||||||
|
|
||||||
|
export interface BaseSupportOption<Type extends SupportOptionType> {
|
||||||
|
readonly name?: string | undefined;
|
||||||
|
/**
|
||||||
|
* Usually you can use {@link CoreCategoryType}
|
||||||
|
*/
|
||||||
|
category: string;
|
||||||
|
/**
|
||||||
|
* The type of the option.
|
||||||
|
*
|
||||||
|
* When passing a type other than the ones listed below, the option is
|
||||||
|
* treated as taking any string as argument, and `--option <${type}>` will
|
||||||
|
* be displayed in --help.
|
||||||
|
*/
|
||||||
|
type: Type;
|
||||||
|
/**
|
||||||
|
* Indicate that the option is deprecated.
|
||||||
|
*
|
||||||
|
* Use a string to add an extra message to --help for the option,
|
||||||
|
* for example to suggest a replacement option.
|
||||||
|
*/
|
||||||
|
deprecated?: true | string | undefined;
|
||||||
|
/**
|
||||||
|
* Description to be displayed in --help. If omitted, the option won't be
|
||||||
|
* shown at all in --help.
|
||||||
|
*/
|
||||||
|
description?: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntSupportOption extends BaseSupportOption<"int"> {
|
||||||
|
default?: number | undefined;
|
||||||
|
array?: false | undefined;
|
||||||
|
range?: SupportOptionRange | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IntArraySupportOption extends BaseSupportOption<"int"> {
|
||||||
|
default?: Array<{ value: number[] }> | undefined;
|
||||||
|
array: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StringSupportOption extends BaseSupportOption<"string"> {
|
||||||
|
default?: string | undefined;
|
||||||
|
array?: false | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StringArraySupportOption extends BaseSupportOption<"string"> {
|
||||||
|
default?: Array<{ value: string[] }> | undefined;
|
||||||
|
array: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BooleanSupportOption extends BaseSupportOption<"boolean"> {
|
||||||
|
default?: boolean | undefined;
|
||||||
|
array?: false | undefined;
|
||||||
|
description: string;
|
||||||
|
oppositeDescription?: string | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BooleanArraySupportOption extends BaseSupportOption<"boolean"> {
|
||||||
|
default?: Array<{ value: boolean[] }> | undefined;
|
||||||
|
array: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChoiceSupportOption<
|
||||||
|
Value = any,
|
||||||
|
> extends BaseSupportOption<"choice"> {
|
||||||
|
default?: Value | Array<{ value: Value }> | undefined;
|
||||||
|
description: string;
|
||||||
|
choices: Array<{
|
||||||
|
value: Value;
|
||||||
|
description: string;
|
||||||
|
}>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PathSupportOption extends BaseSupportOption<"path"> {
|
||||||
|
default?: string | undefined;
|
||||||
|
array?: false | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PathArraySupportOption extends BaseSupportOption<"path"> {
|
||||||
|
default?: Array<{ value: string[] }> | undefined;
|
||||||
|
array: true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SupportOption =
|
||||||
|
| IntSupportOption
|
||||||
|
| IntArraySupportOption
|
||||||
|
| StringSupportOption
|
||||||
|
| StringArraySupportOption
|
||||||
|
| BooleanSupportOption
|
||||||
|
| BooleanArraySupportOption
|
||||||
|
| ChoiceSupportOption
|
||||||
|
| PathSupportOption
|
||||||
|
| PathArraySupportOption;
|
||||||
|
|
||||||
|
export interface SupportOptions extends Record<string, SupportOption> {}
|
||||||
|
|
||||||
|
export interface SupportInfo {
|
||||||
|
languages: SupportLanguage[];
|
||||||
|
options: SupportOption[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FileInfoOptions {
|
||||||
|
ignorePath?: string | URL | (string | URL)[] | undefined;
|
||||||
|
withNodeModules?: boolean | undefined;
|
||||||
|
plugins?: Array<string | URL | Plugin> | undefined;
|
||||||
|
resolveConfig?: boolean | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FileInfoResult {
|
||||||
|
ignored: boolean;
|
||||||
|
inferredParser: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getFileInfo(
|
||||||
|
file: string | URL,
|
||||||
|
options?: FileInfoOptions,
|
||||||
|
): Promise<FileInfoResult>;
|
||||||
|
|
||||||
|
export interface SupportInfoOptions {
|
||||||
|
plugins?: Array<string | URL | Plugin> | undefined;
|
||||||
|
showDeprecated?: boolean | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object representing the parsers, languages and file types Prettier supports for the current version.
|
||||||
|
*/
|
||||||
|
export function getSupportInfo(
|
||||||
|
options?: SupportInfoOptions,
|
||||||
|
): Promise<SupportInfo>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `version` field in `package.json`
|
||||||
|
*/
|
||||||
|
export const version: string;
|
||||||
|
|
||||||
|
// https://github.com/prettier/prettier/blob/main/src/utilities/public.js
|
||||||
|
export namespace util {
|
||||||
|
interface SkipOptions {
|
||||||
|
backwards?: boolean | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Quote = "'" | '"';
|
||||||
|
|
||||||
|
function getMaxContinuousCount(text: string, searchString: string): number;
|
||||||
|
|
||||||
|
function getStringWidth(text: string): number;
|
||||||
|
|
||||||
|
function getAlignmentSize(
|
||||||
|
text: string,
|
||||||
|
tabWidth: number,
|
||||||
|
startIndex?: number | undefined,
|
||||||
|
): number;
|
||||||
|
|
||||||
|
function getIndentSize(value: string, tabWidth: number): number;
|
||||||
|
|
||||||
|
function skipNewline(
|
||||||
|
text: string,
|
||||||
|
startIndex: number | false,
|
||||||
|
options?: SkipOptions | undefined,
|
||||||
|
): number | false;
|
||||||
|
|
||||||
|
function skipInlineComment(
|
||||||
|
text: string,
|
||||||
|
startIndex: number | false,
|
||||||
|
): number | false;
|
||||||
|
|
||||||
|
function skipTrailingComment(
|
||||||
|
text: string,
|
||||||
|
startIndex: number | false,
|
||||||
|
): number | false;
|
||||||
|
|
||||||
|
function skipTrailingComment(
|
||||||
|
text: string,
|
||||||
|
startIndex: number | false,
|
||||||
|
): number | false;
|
||||||
|
|
||||||
|
function hasNewline(
|
||||||
|
text: string,
|
||||||
|
startIndex: number,
|
||||||
|
options?: SkipOptions | undefined,
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
function hasNewlineInRange(
|
||||||
|
text: string,
|
||||||
|
startIndex: number,
|
||||||
|
endIndex: number,
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
function hasSpaces(
|
||||||
|
text: string,
|
||||||
|
startIndex: number,
|
||||||
|
options?: SkipOptions | undefined,
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
function getNextNonSpaceNonCommentCharacterIndex(
|
||||||
|
text: string,
|
||||||
|
startIndex: number,
|
||||||
|
): number | false;
|
||||||
|
|
||||||
|
function getNextNonSpaceNonCommentCharacter(
|
||||||
|
text: string,
|
||||||
|
startIndex: number,
|
||||||
|
): string;
|
||||||
|
|
||||||
|
function isNextLineEmpty(text: string, startIndex: number): boolean;
|
||||||
|
|
||||||
|
function isPreviousLineEmpty(text: string, startIndex: number): boolean;
|
||||||
|
|
||||||
|
function makeString(
|
||||||
|
rawText: string,
|
||||||
|
enclosingQuote: Quote,
|
||||||
|
unescapeUnnecessaryEscapes?: boolean | undefined,
|
||||||
|
): string;
|
||||||
|
|
||||||
|
function skip(
|
||||||
|
characters: string | RegExp,
|
||||||
|
): (
|
||||||
|
text: string,
|
||||||
|
startIndex: number | false,
|
||||||
|
options?: SkipOptions,
|
||||||
|
) => number | false;
|
||||||
|
|
||||||
|
const skipWhitespace: (
|
||||||
|
text: string,
|
||||||
|
startIndex: number | false,
|
||||||
|
options?: SkipOptions,
|
||||||
|
) => number | false;
|
||||||
|
|
||||||
|
const skipSpaces: (
|
||||||
|
text: string,
|
||||||
|
startIndex: number | false,
|
||||||
|
options?: SkipOptions,
|
||||||
|
) => number | false;
|
||||||
|
|
||||||
|
const skipToLineEnd: (
|
||||||
|
text: string,
|
||||||
|
startIndex: number | false,
|
||||||
|
options?: SkipOptions,
|
||||||
|
) => number | false;
|
||||||
|
|
||||||
|
const skipEverythingButNewLine: (
|
||||||
|
text: string,
|
||||||
|
startIndex: number | false,
|
||||||
|
options?: SkipOptions,
|
||||||
|
) => number | false;
|
||||||
|
|
||||||
|
function addLeadingComment(node: any, comment: any): void;
|
||||||
|
|
||||||
|
function addDanglingComment(node: any, comment: any, marker: any): void;
|
||||||
|
|
||||||
|
function addTrailingComment(node: any, comment: any): void;
|
||||||
|
|
||||||
|
function getPreferredQuote(
|
||||||
|
text: string,
|
||||||
|
preferredQuoteOrPreferSingleQuote: Quote | boolean,
|
||||||
|
): Quote;
|
||||||
|
}
|
||||||
+18793
File diff suppressed because one or more lines are too long
+2841
File diff suppressed because it is too large
Load Diff
+12790
File diff suppressed because one or more lines are too long
+6229
File diff suppressed because it is too large
Load Diff
+203
@@ -0,0 +1,203 @@
|
|||||||
|
{
|
||||||
|
"name": "prettier",
|
||||||
|
"version": "3.8.1",
|
||||||
|
"description": "Prettier is an opinionated code formatter",
|
||||||
|
"bin": "./bin/prettier.cjs",
|
||||||
|
"repository": "prettier/prettier",
|
||||||
|
"funding": "https://github.com/prettier/prettier?sponsor=1",
|
||||||
|
"homepage": "https://prettier.io",
|
||||||
|
"author": "James Long",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "./index.cjs",
|
||||||
|
"browser": "./standalone.js",
|
||||||
|
"unpkg": "./standalone.js",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./index.d.ts",
|
||||||
|
"require": "./index.cjs",
|
||||||
|
"browser": {
|
||||||
|
"import": "./standalone.mjs",
|
||||||
|
"default": "./standalone.js"
|
||||||
|
},
|
||||||
|
"default": "./index.mjs"
|
||||||
|
},
|
||||||
|
"./*": "./*",
|
||||||
|
"./doc": {
|
||||||
|
"types": "./doc.d.ts",
|
||||||
|
"require": "./doc.js",
|
||||||
|
"default": "./doc.mjs"
|
||||||
|
},
|
||||||
|
"./standalone": {
|
||||||
|
"types": "./standalone.d.ts",
|
||||||
|
"require": "./standalone.js",
|
||||||
|
"default": "./standalone.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/estree": {
|
||||||
|
"types": "./plugins/estree.d.ts",
|
||||||
|
"require": "./plugins/estree.js",
|
||||||
|
"default": "./plugins/estree.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/babel": {
|
||||||
|
"types": "./plugins/babel.d.ts",
|
||||||
|
"require": "./plugins/babel.js",
|
||||||
|
"default": "./plugins/babel.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/flow": {
|
||||||
|
"types": "./plugins/flow.d.ts",
|
||||||
|
"require": "./plugins/flow.js",
|
||||||
|
"default": "./plugins/flow.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/typescript": {
|
||||||
|
"types": "./plugins/typescript.d.ts",
|
||||||
|
"require": "./plugins/typescript.js",
|
||||||
|
"default": "./plugins/typescript.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/acorn": {
|
||||||
|
"types": "./plugins/acorn.d.ts",
|
||||||
|
"require": "./plugins/acorn.js",
|
||||||
|
"default": "./plugins/acorn.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/meriyah": {
|
||||||
|
"types": "./plugins/meriyah.d.ts",
|
||||||
|
"require": "./plugins/meriyah.js",
|
||||||
|
"default": "./plugins/meriyah.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/angular": {
|
||||||
|
"types": "./plugins/angular.d.ts",
|
||||||
|
"require": "./plugins/angular.js",
|
||||||
|
"default": "./plugins/angular.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/postcss": {
|
||||||
|
"types": "./plugins/postcss.d.ts",
|
||||||
|
"require": "./plugins/postcss.js",
|
||||||
|
"default": "./plugins/postcss.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/graphql": {
|
||||||
|
"types": "./plugins/graphql.d.ts",
|
||||||
|
"require": "./plugins/graphql.js",
|
||||||
|
"default": "./plugins/graphql.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/markdown": {
|
||||||
|
"types": "./plugins/markdown.d.ts",
|
||||||
|
"require": "./plugins/markdown.js",
|
||||||
|
"default": "./plugins/markdown.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/glimmer": {
|
||||||
|
"types": "./plugins/glimmer.d.ts",
|
||||||
|
"require": "./plugins/glimmer.js",
|
||||||
|
"default": "./plugins/glimmer.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/html": {
|
||||||
|
"types": "./plugins/html.d.ts",
|
||||||
|
"require": "./plugins/html.js",
|
||||||
|
"default": "./plugins/html.mjs"
|
||||||
|
},
|
||||||
|
"./plugins/yaml": {
|
||||||
|
"types": "./plugins/yaml.d.ts",
|
||||||
|
"require": "./plugins/yaml.js",
|
||||||
|
"default": "./plugins/yaml.mjs"
|
||||||
|
},
|
||||||
|
"./esm/standalone.mjs": "./standalone.mjs",
|
||||||
|
"./parser-babel": "./plugins/babel.js",
|
||||||
|
"./parser-babel.js": "./plugins/babel.js",
|
||||||
|
"./esm/parser-babel.mjs": "./plugins/babel.mjs",
|
||||||
|
"./parser-flow": "./plugins/flow.js",
|
||||||
|
"./parser-flow.js": "./plugins/flow.js",
|
||||||
|
"./esm/parser-flow.mjs": "./plugins/flow.mjs",
|
||||||
|
"./parser-typescript": "./plugins/typescript.js",
|
||||||
|
"./parser-typescript.js": "./plugins/typescript.js",
|
||||||
|
"./esm/parser-typescript.mjs": "./plugins/typescript.mjs",
|
||||||
|
"./parser-espree": "./plugins/acorn.js",
|
||||||
|
"./parser-espree.js": "./plugins/acorn.js",
|
||||||
|
"./esm/parser-espree.mjs": "./plugins/acorn.mjs",
|
||||||
|
"./parser-meriyah": "./plugins/meriyah.js",
|
||||||
|
"./parser-meriyah.js": "./plugins/meriyah.js",
|
||||||
|
"./esm/parser-meriyah.mjs": "./plugins/meriyah.mjs",
|
||||||
|
"./parser-angular": "./plugins/angular.js",
|
||||||
|
"./parser-angular.js": "./plugins/angular.js",
|
||||||
|
"./esm/parser-angular.mjs": "./plugins/angular.mjs",
|
||||||
|
"./parser-postcss": "./plugins/postcss.js",
|
||||||
|
"./parser-postcss.js": "./plugins/postcss.js",
|
||||||
|
"./esm/parser-postcss.mjs": "./plugins/postcss.mjs",
|
||||||
|
"./parser-graphql": "./plugins/graphql.js",
|
||||||
|
"./parser-graphql.js": "./plugins/graphql.js",
|
||||||
|
"./esm/parser-graphql.mjs": "./plugins/graphql.mjs",
|
||||||
|
"./parser-markdown": "./plugins/markdown.js",
|
||||||
|
"./parser-markdown.js": "./plugins/markdown.js",
|
||||||
|
"./esm/parser-markdown.mjs": "./plugins/markdown.mjs",
|
||||||
|
"./parser-glimmer": "./plugins/glimmer.js",
|
||||||
|
"./parser-glimmer.js": "./plugins/glimmer.js",
|
||||||
|
"./esm/parser-glimmer.mjs": "./plugins/glimmer.mjs",
|
||||||
|
"./parser-html": "./plugins/html.js",
|
||||||
|
"./parser-html.js": "./plugins/html.js",
|
||||||
|
"./esm/parser-html.mjs": "./plugins/html.mjs",
|
||||||
|
"./parser-yaml": "./plugins/yaml.js",
|
||||||
|
"./parser-yaml.js": "./plugins/yaml.js",
|
||||||
|
"./esm/parser-yaml.mjs": "./plugins/yaml.mjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"LICENSE",
|
||||||
|
"README.md",
|
||||||
|
"THIRD-PARTY-NOTICES.md",
|
||||||
|
"bin/prettier.cjs",
|
||||||
|
"doc.d.ts",
|
||||||
|
"doc.js",
|
||||||
|
"doc.mjs",
|
||||||
|
"index.cjs",
|
||||||
|
"index.d.ts",
|
||||||
|
"index.d.ts",
|
||||||
|
"index.mjs",
|
||||||
|
"internal/experimental-cli-worker.mjs",
|
||||||
|
"internal/experimental-cli.mjs",
|
||||||
|
"internal/legacy-cli.mjs",
|
||||||
|
"package.json",
|
||||||
|
"plugins/acorn.d.ts",
|
||||||
|
"plugins/acorn.js",
|
||||||
|
"plugins/acorn.mjs",
|
||||||
|
"plugins/angular.d.ts",
|
||||||
|
"plugins/angular.js",
|
||||||
|
"plugins/angular.mjs",
|
||||||
|
"plugins/babel.d.ts",
|
||||||
|
"plugins/babel.js",
|
||||||
|
"plugins/babel.mjs",
|
||||||
|
"plugins/estree.d.ts",
|
||||||
|
"plugins/estree.js",
|
||||||
|
"plugins/estree.mjs",
|
||||||
|
"plugins/flow.d.ts",
|
||||||
|
"plugins/flow.js",
|
||||||
|
"plugins/flow.mjs",
|
||||||
|
"plugins/glimmer.d.ts",
|
||||||
|
"plugins/glimmer.js",
|
||||||
|
"plugins/glimmer.mjs",
|
||||||
|
"plugins/graphql.d.ts",
|
||||||
|
"plugins/graphql.js",
|
||||||
|
"plugins/graphql.mjs",
|
||||||
|
"plugins/html.d.ts",
|
||||||
|
"plugins/html.js",
|
||||||
|
"plugins/html.mjs",
|
||||||
|
"plugins/markdown.d.ts",
|
||||||
|
"plugins/markdown.js",
|
||||||
|
"plugins/markdown.mjs",
|
||||||
|
"plugins/meriyah.d.ts",
|
||||||
|
"plugins/meriyah.js",
|
||||||
|
"plugins/meriyah.mjs",
|
||||||
|
"plugins/postcss.d.ts",
|
||||||
|
"plugins/postcss.js",
|
||||||
|
"plugins/postcss.mjs",
|
||||||
|
"plugins/typescript.d.ts",
|
||||||
|
"plugins/typescript.js",
|
||||||
|
"plugins/typescript.mjs",
|
||||||
|
"plugins/yaml.d.ts",
|
||||||
|
"plugins/yaml.js",
|
||||||
|
"plugins/yaml.mjs",
|
||||||
|
"standalone.d.ts",
|
||||||
|
"standalone.js",
|
||||||
|
"standalone.mjs"
|
||||||
|
],
|
||||||
|
"preferUnplugged": true,
|
||||||
|
"sideEffects": false,
|
||||||
|
"type": "commonjs"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
import { Parser } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
acorn: Parser;
|
||||||
|
espree: Parser;
|
||||||
|
};
|
||||||
+16
File diff suppressed because one or more lines are too long
+16
File diff suppressed because one or more lines are too long
+8
@@ -0,0 +1,8 @@
|
|||||||
|
import { Parser } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
__ng_action: Parser;
|
||||||
|
__ng_binding: Parser;
|
||||||
|
__ng_directive: Parser;
|
||||||
|
__ng_interpolation: Parser;
|
||||||
|
};
|
||||||
+4
File diff suppressed because one or more lines are too long
+4
File diff suppressed because one or more lines are too long
+18
@@ -0,0 +1,18 @@
|
|||||||
|
import { Parser } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
__babel_estree: Parser;
|
||||||
|
__js_expression: Parser;
|
||||||
|
__ts_expression: Parser;
|
||||||
|
__vue_event_binding: Parser;
|
||||||
|
__vue_expression: Parser;
|
||||||
|
__vue_ts_event_binding: Parser;
|
||||||
|
__vue_ts_expression: Parser;
|
||||||
|
babel: Parser;
|
||||||
|
"babel-flow": Parser;
|
||||||
|
"babel-ts": Parser;
|
||||||
|
json: Parser;
|
||||||
|
"json-stringify": Parser;
|
||||||
|
json5: Parser;
|
||||||
|
jsonc: Parser;
|
||||||
|
};
|
||||||
+15
File diff suppressed because one or more lines are too long
+15
File diff suppressed because one or more lines are too long
+6
@@ -0,0 +1,6 @@
|
|||||||
|
import { Printer } from "../index.js";
|
||||||
|
|
||||||
|
export declare const printers: {
|
||||||
|
estree: Printer;
|
||||||
|
"estree-json": Printer;
|
||||||
|
};
|
||||||
+44
File diff suppressed because one or more lines are too long
+44
File diff suppressed because one or more lines are too long
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import { Parser } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
flow: Parser;
|
||||||
|
};
|
||||||
+20
File diff suppressed because one or more lines are too long
+20
File diff suppressed because one or more lines are too long
+9
@@ -0,0 +1,9 @@
|
|||||||
|
import { Parser, Printer } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
glimmer: Parser;
|
||||||
|
};
|
||||||
|
|
||||||
|
export declare const printers: {
|
||||||
|
glimmer: Printer;
|
||||||
|
};
|
||||||
+37
File diff suppressed because one or more lines are too long
+37
File diff suppressed because one or more lines are too long
+9
@@ -0,0 +1,9 @@
|
|||||||
|
import { Parser, Printer } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
graphql: Parser;
|
||||||
|
};
|
||||||
|
|
||||||
|
export declare const printers: {
|
||||||
|
graphql: Printer;
|
||||||
|
};
|
||||||
+28
File diff suppressed because one or more lines are too long
+28
File diff suppressed because one or more lines are too long
+13
@@ -0,0 +1,13 @@
|
|||||||
|
import { Parser, Printer } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
angular: Parser;
|
||||||
|
html: Parser;
|
||||||
|
lwc: Parser;
|
||||||
|
mjml: Parser;
|
||||||
|
vue: Parser;
|
||||||
|
};
|
||||||
|
|
||||||
|
export declare const printers: {
|
||||||
|
html: Printer;
|
||||||
|
};
|
||||||
+24
File diff suppressed because one or more lines are too long
+24
File diff suppressed because one or more lines are too long
+11
@@ -0,0 +1,11 @@
|
|||||||
|
import { Parser, Printer } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
markdown: Parser;
|
||||||
|
mdx: Parser;
|
||||||
|
remark: Parser;
|
||||||
|
};
|
||||||
|
|
||||||
|
export declare const printers: {
|
||||||
|
mdast: Printer;
|
||||||
|
};
|
||||||
+62
File diff suppressed because one or more lines are too long
+62
File diff suppressed because one or more lines are too long
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import { Parser } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
meriyah: Parser;
|
||||||
|
};
|
||||||
+5
File diff suppressed because one or more lines are too long
+5
File diff suppressed because one or more lines are too long
+11
@@ -0,0 +1,11 @@
|
|||||||
|
import { Parser, Printer } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
css: Parser;
|
||||||
|
less: Parser;
|
||||||
|
scss: Parser;
|
||||||
|
};
|
||||||
|
|
||||||
|
export declare const printers: {
|
||||||
|
postcss: Printer;
|
||||||
|
};
|
||||||
+61
File diff suppressed because one or more lines are too long
+61
File diff suppressed because one or more lines are too long
+5
@@ -0,0 +1,5 @@
|
|||||||
|
import { Parser } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
typescript: Parser;
|
||||||
|
};
|
||||||
+21
File diff suppressed because one or more lines are too long
+21
File diff suppressed because one or more lines are too long
+9
@@ -0,0 +1,9 @@
|
|||||||
|
import { Parser, Printer } from "../index.js";
|
||||||
|
|
||||||
|
export declare const parsers: {
|
||||||
|
yaml: Parser;
|
||||||
|
};
|
||||||
|
|
||||||
|
export declare const printers: {
|
||||||
|
yaml: Printer;
|
||||||
|
};
|
||||||
+159
File diff suppressed because one or more lines are too long
+159
File diff suppressed because one or more lines are too long
+33
@@ -0,0 +1,33 @@
|
|||||||
|
import { CursorOptions, CursorResult, Options, SupportInfo } from "./index.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* formatWithCursor both formats the code, and translates a cursor position from unformatted code to formatted code.
|
||||||
|
* This is useful for editor integrations, to prevent the cursor from moving when code is formatted
|
||||||
|
*
|
||||||
|
* The cursorOffset option should be provided, to specify where the cursor is.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* await prettier.formatWithCursor(" 1", { cursorOffset: 2, parser: "babel" });
|
||||||
|
* ```
|
||||||
|
* `-> { formatted: "1;\n", cursorOffset: 1 }`
|
||||||
|
*/
|
||||||
|
export function formatWithCursor(
|
||||||
|
source: string,
|
||||||
|
options: CursorOptions,
|
||||||
|
): Promise<CursorResult>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `format` is used to format text using Prettier. [Options](https://prettier.io/docs/options) may be provided to override the defaults.
|
||||||
|
*/
|
||||||
|
export function format(source: string, options?: Options): Promise<string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `check` checks to see if the file has been formatted with Prettier given those options and returns a `Boolean`.
|
||||||
|
* This is similar to the `--list-different` parameter in the CLI and is useful for running Prettier in CI scenarios.
|
||||||
|
*/
|
||||||
|
export function check(source: string, options?: Options): Promise<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object representing the parsers, languages and file types Prettier supports for the current version.
|
||||||
|
*/
|
||||||
|
export function getSupportInfo(): Promise<SupportInfo>;
|
||||||
+29
File diff suppressed because one or more lines are too long
+29
File diff suppressed because one or more lines are too long
Generated
+32
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "havox",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "havox",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "^3.8.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/prettier": {
|
||||||
|
"version": "3.8.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.1.tgz",
|
||||||
|
"integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"prettier": "bin/prettier.cjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "havox",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "404.js",
|
||||||
|
"scripts": {
|
||||||
|
"format": "prettier --write ."
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@git.umbra.mom:jay/havox.git"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"type": "commonjs",
|
||||||
|
"devDependencies": {
|
||||||
|
"prettier": "^3.8.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,8 +6,5 @@
|
|||||||
"main.5cae1eb5.css.map": "/projects/cellular_automata/static/css/main.5cae1eb5.css.map",
|
"main.5cae1eb5.css.map": "/projects/cellular_automata/static/css/main.5cae1eb5.css.map",
|
||||||
"main.608a23ae.js.map": "/projects/cellular_automata/static/js/main.608a23ae.js.map"
|
"main.608a23ae.js.map": "/projects/cellular_automata/static/js/main.608a23ae.js.map"
|
||||||
},
|
},
|
||||||
"entrypoints": [
|
"entrypoints": ["static/css/main.5cae1eb5.css", "static/js/main.608a23ae.js"]
|
||||||
"static/css/main.5cae1eb5.css",
|
|
||||||
"static/js/main.608a23ae.js"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@@ -1 +1,31 @@
|
|||||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/projects/cellular_automata/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/projects/cellular_automata/logo192.png"/><link rel="manifest" href="/projects/cellular_automata/manifest.json"/><title>React App</title><script defer="defer" src="/projects/cellular_automata/static/js/main.608a23ae.js"></script><link href="/projects/cellular_automata/static/css/main.5cae1eb5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="icon" href="/projects/cellular_automata/favicon.ico" />
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
|
<meta name="theme-color" content="#000000" />
|
||||||
|
<meta
|
||||||
|
name="description"
|
||||||
|
content="Web site created using create-react-app"
|
||||||
|
/>
|
||||||
|
<link
|
||||||
|
rel="apple-touch-icon"
|
||||||
|
href="/projects/cellular_automata/logo192.png"
|
||||||
|
/>
|
||||||
|
<link rel="manifest" href="/projects/cellular_automata/manifest.json" />
|
||||||
|
<title>React App</title>
|
||||||
|
<script
|
||||||
|
defer="defer"
|
||||||
|
src="/projects/cellular_automata/static/js/main.608a23ae.js"
|
||||||
|
></script>
|
||||||
|
<link
|
||||||
|
href="/projects/cellular_automata/static/css/main.5cae1eb5.css"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||||
|
<div id="root"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
# https://www.robotstxt.org/robotstxt.html
|
|
||||||
User-agent: *
|
|
||||||
Disallow:
|
|
||||||
@@ -1,2 +1,173 @@
|
|||||||
#root,body,html{margin:0;min-height:100%}body{background:radial-gradient(circle at top,#eef4ff 0,#f8fbff 55%,#eef2f7 100%);color:#0f172a;font-family:Segoe UI,sans-serif}.cell{border:1px solid #1f2937;box-sizing:border-box;margin:0;padding:0}.dead{background:#000}.alive{background:#fff}.board{border:1px solid #94a3b8;cursor:crosshair;display:inline-block;-webkit-user-select:none;user-select:none}.row{display:flex}.horizontal-slider{margin:auto;width:100%}.example-thumb{background:#fff;border:5px solid #3774ff;border-radius:100%;box-shadow:0 0 2px 0 #00000070;cursor:pointer;display:block;position:absolute;z-index:100}.example-thumb.active{background-color:grey}.example-track{background:#ddd;position:relative}.example-track.example-track-0{background:#83a9ff}.horizontal-slider .example-track{height:4px;top:20px}.horizontal-slider .example-thumb{height:10px;line-height:38px;outline:none;top:12px;width:10px}.radioGroup{grid-gap:.45rem;display:grid;gap:.45rem}.radioOption{align-items:center;color:#1e293b;cursor:pointer;display:flex;font-size:.92rem;gap:.5rem}.radioOption input{accent-color:#2f7df6;margin:0}.title{margin:2rem 0 1.25rem;text-align:center}.title h1{color:#0f172a;font-size:2.2rem;letter-spacing:.03em;margin:0}.title p{color:#475569;font-size:.95rem;margin:.35rem 0 0}.body{align-items:flex-start;display:flex;gap:1.25rem;justify-content:center;margin:0 auto 1.75rem;max-width:980px;padding:0 1rem}.gameBoard{padding:.6rem}.controlPanel,.gameBoard{background:#fff;border:1px solid #d5deea;border-radius:12px;box-shadow:0 12px 28px #0f172a1a}.controlPanel{color:#1e293b;padding:1rem;width:270px}.panelSection{margin-bottom:1rem}.panelSection h3{color:#334155;font-size:.95rem;margin:0 0 .5rem}.buttonRow{grid-gap:.5rem;display:grid;gap:.5rem;grid-template-columns:repeat(3,1fr);margin-bottom:1.1rem}.controlButton{background:#f8fafc;border:1px solid #cbd5e1;border-radius:8px;color:#1e293b;cursor:pointer;font-weight:500;padding:.45rem .35rem}.controlButton:hover{background:#eef2f8}.sliderContainer{grid-gap:.25rem;display:grid;gap:.25rem}.sliderContainer span{color:#334155;font-size:.95rem}.fpsValue{color:#64748b;font-size:.85rem;margin:.3rem 0 0}
|
#root,
|
||||||
|
body,
|
||||||
|
html {
|
||||||
|
margin: 0;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background: radial-gradient(
|
||||||
|
circle at top,
|
||||||
|
#eef4ff 0,
|
||||||
|
#f8fbff 55%,
|
||||||
|
#eef2f7 100%
|
||||||
|
);
|
||||||
|
color: #0f172a;
|
||||||
|
font-family:
|
||||||
|
Segoe UI,
|
||||||
|
sans-serif;
|
||||||
|
}
|
||||||
|
.cell {
|
||||||
|
border: 1px solid #1f2937;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.dead {
|
||||||
|
background: #000;
|
||||||
|
}
|
||||||
|
.alive {
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
.board {
|
||||||
|
border: 1px solid #94a3b8;
|
||||||
|
cursor: crosshair;
|
||||||
|
display: inline-block;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.horizontal-slider {
|
||||||
|
margin: auto;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.example-thumb {
|
||||||
|
background: #fff;
|
||||||
|
border: 5px solid #3774ff;
|
||||||
|
border-radius: 100%;
|
||||||
|
box-shadow: 0 0 2px 0 #00000070;
|
||||||
|
cursor: pointer;
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
.example-thumb.active {
|
||||||
|
background-color: grey;
|
||||||
|
}
|
||||||
|
.example-track {
|
||||||
|
background: #ddd;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.example-track.example-track-0 {
|
||||||
|
background: #83a9ff;
|
||||||
|
}
|
||||||
|
.horizontal-slider .example-track {
|
||||||
|
height: 4px;
|
||||||
|
top: 20px;
|
||||||
|
}
|
||||||
|
.horizontal-slider .example-thumb {
|
||||||
|
height: 10px;
|
||||||
|
line-height: 38px;
|
||||||
|
outline: none;
|
||||||
|
top: 12px;
|
||||||
|
width: 10px;
|
||||||
|
}
|
||||||
|
.radioGroup {
|
||||||
|
grid-gap: 0.45rem;
|
||||||
|
display: grid;
|
||||||
|
gap: 0.45rem;
|
||||||
|
}
|
||||||
|
.radioOption {
|
||||||
|
align-items: center;
|
||||||
|
color: #1e293b;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
font-size: 0.92rem;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
.radioOption input {
|
||||||
|
accent-color: #2f7df6;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
margin: 2rem 0 1.25rem;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.title h1 {
|
||||||
|
color: #0f172a;
|
||||||
|
font-size: 2.2rem;
|
||||||
|
letter-spacing: 0.03em;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.title p {
|
||||||
|
color: #475569;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
margin: 0.35rem 0 0;
|
||||||
|
}
|
||||||
|
.body {
|
||||||
|
align-items: flex-start;
|
||||||
|
display: flex;
|
||||||
|
gap: 1.25rem;
|
||||||
|
justify-content: center;
|
||||||
|
margin: 0 auto 1.75rem;
|
||||||
|
max-width: 980px;
|
||||||
|
padding: 0 1rem;
|
||||||
|
}
|
||||||
|
.gameBoard {
|
||||||
|
padding: 0.6rem;
|
||||||
|
}
|
||||||
|
.controlPanel,
|
||||||
|
.gameBoard {
|
||||||
|
background: #fff;
|
||||||
|
border: 1px solid #d5deea;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 12px 28px #0f172a1a;
|
||||||
|
}
|
||||||
|
.controlPanel {
|
||||||
|
color: #1e293b;
|
||||||
|
padding: 1rem;
|
||||||
|
width: 270px;
|
||||||
|
}
|
||||||
|
.panelSection {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
.panelSection h3 {
|
||||||
|
color: #334155;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
margin: 0 0 0.5rem;
|
||||||
|
}
|
||||||
|
.buttonRow {
|
||||||
|
grid-gap: 0.5rem;
|
||||||
|
display: grid;
|
||||||
|
gap: 0.5rem;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
margin-bottom: 1.1rem;
|
||||||
|
}
|
||||||
|
.controlButton {
|
||||||
|
background: #f8fafc;
|
||||||
|
border: 1px solid #cbd5e1;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: #1e293b;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 0.45rem 0.35rem;
|
||||||
|
}
|
||||||
|
.controlButton:hover {
|
||||||
|
background: #eef2f8;
|
||||||
|
}
|
||||||
|
.sliderContainer {
|
||||||
|
grid-gap: 0.25rem;
|
||||||
|
display: grid;
|
||||||
|
gap: 0.25rem;
|
||||||
|
}
|
||||||
|
.sliderContainer span {
|
||||||
|
color: #334155;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
.fpsValue {
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
margin: 0.3rem 0 0;
|
||||||
|
}
|
||||||
/*# sourceMappingURL=main.5cae1eb5.css.map*/
|
/*# sourceMappingURL=main.5cae1eb5.css.map*/
|
||||||
File diff suppressed because one or more lines are too long
@@ -5,10 +5,18 @@ class cPoint {
|
|||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
this.r = 9;
|
this.r = 9;
|
||||||
}
|
}
|
||||||
set changeX(nx) { this.x = nx; }
|
set changeX(nx) {
|
||||||
set changeY(ny) { this.y = ny; }
|
this.x = nx;
|
||||||
get changeX() { return this.x; }
|
}
|
||||||
get changeY() { return this.y; }
|
set changeY(ny) {
|
||||||
|
this.y = ny;
|
||||||
|
}
|
||||||
|
get changeX() {
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
get changeY() {
|
||||||
|
return this.y;
|
||||||
|
}
|
||||||
|
|
||||||
isHit(mx, my, r = HIT_R) {
|
isHit(mx, my, r = HIT_R) {
|
||||||
return dist(mx, my, this.x, this.y) <= r;
|
return dist(mx, my, this.x, this.y) <= r;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
let p = [], v = [];
|
let p = [],
|
||||||
|
v = [];
|
||||||
let lines = [];
|
let lines = [];
|
||||||
let theta = (3 / 2) * Math.PI, t = 0;
|
let theta = (3 / 2) * Math.PI,
|
||||||
|
t = 0;
|
||||||
let paused = false;
|
let paused = false;
|
||||||
let showLabels = false;
|
let showLabels = false;
|
||||||
let showInterPoints = true;
|
let showInterPoints = true;
|
||||||
@@ -68,8 +70,8 @@ function drawPointsAndLabels() {
|
|||||||
pop();
|
pop();
|
||||||
|
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
const hovered = (i === hoverIndex);
|
const hovered = i === hoverIndex;
|
||||||
const selected = (i === selectedIndex);
|
const selected = i === selectedIndex;
|
||||||
p[i].drawPoint(hovered, selected);
|
p[i].drawPoint(hovered, selected);
|
||||||
if (showLabels) {
|
if (showLabels) {
|
||||||
noStroke();
|
noStroke();
|
||||||
@@ -81,21 +83,25 @@ function drawPointsAndLabels() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (showLabels) {
|
if (showLabels) {
|
||||||
noStroke(); fill(220);
|
noStroke();
|
||||||
textSize(12); textAlign(LEFT, BOTTOM);
|
fill(220);
|
||||||
|
textSize(12);
|
||||||
|
textAlign(LEFT, BOTTOM);
|
||||||
text(`P4`, p[4].x + 8, p[4].y - 8);
|
text(`P4`, p[4].x + 8, p[4].y - 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showInterPoints) {
|
if (showInterPoints) {
|
||||||
const styleMid = {
|
const styleMid = {
|
||||||
stroke: [80, 180, 255, 100],
|
stroke: [80, 180, 255, 100],
|
||||||
fill: [80, 180, 255, 50]
|
fill: [80, 180, 255, 50],
|
||||||
};
|
};
|
||||||
for (let i = 4; i <= 8; i++) {
|
for (let i = 4; i <= 8; i++) {
|
||||||
p[i].drawPoint(false, false, styleMid);
|
p[i].drawPoint(false, false, styleMid);
|
||||||
if (showLabels) {
|
if (showLabels) {
|
||||||
noStroke(); fill(200);
|
noStroke();
|
||||||
textSize(12); textAlign(LEFT, BOTTOM);
|
fill(200);
|
||||||
|
textSize(12);
|
||||||
|
textAlign(LEFT, BOTTOM);
|
||||||
text(`P${i}`, p[i].x + 8, p[i].y - 8);
|
text(`P${i}`, p[i].x + 8, p[i].y - 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +117,7 @@ function drawHUD() {
|
|||||||
`t = ${t.toFixed(3)}`,
|
`t = ${t.toFixed(3)}`,
|
||||||
`Space = ${paused ? 'Resume' : 'Pause'}`,
|
`Space = ${paused ? 'Resume' : 'Pause'}`,
|
||||||
`H = Toggle points 5..8 | L = Toggle labels | R = Reset`,
|
`H = Toggle points 5..8 | L = Toggle labels | R = Reset`,
|
||||||
`Drag a handle (P0..P3). Hold Shift to move the entire curve.`
|
`Drag a handle (P0..P3). Hold Shift to move the entire curve.`,
|
||||||
];
|
];
|
||||||
for (let i = 0; i < hud.length; i++) {
|
for (let i = 0; i < hud.length; i++) {
|
||||||
text(hud[i], 12, 12 + i * 18);
|
text(hud[i], 12, 12 + i * 18);
|
||||||
@@ -127,12 +133,17 @@ function initCubicCurve(resetPositions = true) {
|
|||||||
|
|
||||||
if (resetPositions) {
|
if (resetPositions) {
|
||||||
p[0] = new cPoint(width * 0.15, height * 0.75, 'end');
|
p[0] = new cPoint(width * 0.15, height * 0.75, 'end');
|
||||||
p[1] = new cPoint(width * 0.35, height * 0.20, 'control');
|
p[1] = new cPoint(width * 0.35, height * 0.2, 'control');
|
||||||
p[2] = new cPoint(width * 0.65, height * 0.20, 'control');
|
p[2] = new cPoint(width * 0.65, height * 0.2, 'control');
|
||||||
p[3] = new cPoint(width * 0.85, height * 0.75, 'end');
|
p[3] = new cPoint(width * 0.85, height * 0.75, 'end');
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
if (!p[i]) p[i] = new cPoint(width * (0.15 + i * 0.2), height / 2, i === 0 || i === 3 ? 'end' : 'control');
|
if (!p[i])
|
||||||
|
p[i] = new cPoint(
|
||||||
|
width * (0.15 + i * 0.2),
|
||||||
|
height / 2,
|
||||||
|
i === 0 || i === 3 ? 'end' : 'control'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+15
-3
@@ -21,7 +21,12 @@ export class SimulationWasm {
|
|||||||
step(): void;
|
step(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
export type InitInput =
|
||||||
|
| RequestInfo
|
||||||
|
| URL
|
||||||
|
| Response
|
||||||
|
| BufferSource
|
||||||
|
| WebAssembly.Module;
|
||||||
|
|
||||||
export interface InitOutput {
|
export interface InitOutput {
|
||||||
readonly memory: WebAssembly.Memory;
|
readonly memory: WebAssembly.Memory;
|
||||||
@@ -54,7 +59,9 @@ export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|||||||
*
|
*
|
||||||
* @returns {InitOutput}
|
* @returns {InitOutput}
|
||||||
*/
|
*/
|
||||||
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
export function initSync(
|
||||||
|
module: { module: SyncInitInput } | SyncInitInput
|
||||||
|
): InitOutput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
||||||
@@ -64,4 +71,9 @@ export function initSync(module: { module: SyncInitInput } | SyncInitInput): Ini
|
|||||||
*
|
*
|
||||||
* @returns {Promise<InitOutput>}
|
* @returns {Promise<InitOutput>}
|
||||||
*/
|
*/
|
||||||
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
export default function __wbg_init(
|
||||||
|
module_or_path?:
|
||||||
|
| { module_or_path: InitInput | Promise<InitInput> }
|
||||||
|
| InitInput
|
||||||
|
| Promise<InitInput>
|
||||||
|
): Promise<InitOutput>;
|
||||||
|
|||||||
@@ -106,123 +106,138 @@ export class SimulationWasm {
|
|||||||
wasm.simulationwasm_step(this.__wbg_ptr);
|
wasm.simulationwasm_step(this.__wbg_ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Symbol.dispose) SimulationWasm.prototype[Symbol.dispose] = SimulationWasm.prototype.free;
|
if (Symbol.dispose)
|
||||||
|
SimulationWasm.prototype[Symbol.dispose] = SimulationWasm.prototype.free;
|
||||||
|
|
||||||
function __wbg_get_imports() {
|
function __wbg_get_imports() {
|
||||||
const import0 = {
|
const import0 = {
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
__wbg___wbindgen_is_function_3c846841762788c1: function(arg0) {
|
__wbg___wbindgen_is_function_3c846841762788c1: function (arg0) {
|
||||||
const ret = typeof(getObject(arg0)) === 'function';
|
const ret = typeof getObject(arg0) === 'function';
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
__wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
|
__wbg___wbindgen_is_object_781bc9f159099513: function (arg0) {
|
||||||
const val = getObject(arg0);
|
const val = getObject(arg0);
|
||||||
const ret = typeof(val) === 'object' && val !== null;
|
const ret = typeof val === 'object' && val !== null;
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
__wbg___wbindgen_is_string_7ef6b97b02428fae: function(arg0) {
|
__wbg___wbindgen_is_string_7ef6b97b02428fae: function (arg0) {
|
||||||
const ret = typeof(getObject(arg0)) === 'string';
|
const ret = typeof getObject(arg0) === 'string';
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
|
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function (arg0) {
|
||||||
const ret = getObject(arg0) === undefined;
|
const ret = getObject(arg0) === undefined;
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
__wbg___wbindgen_throw_6ddd609b62940d55: function (arg0, arg1) {
|
||||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||||
},
|
},
|
||||||
__wbg_call_2d781c1f4d5c0ef8: function() { return handleError(function (arg0, arg1, arg2) {
|
__wbg_call_2d781c1f4d5c0ef8: function () {
|
||||||
|
return handleError(function (arg0, arg1, arg2) {
|
||||||
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
}, arguments); },
|
}, arguments);
|
||||||
__wbg_crypto_38df2bab126b63dc: function(arg0) {
|
},
|
||||||
|
__wbg_crypto_38df2bab126b63dc: function (arg0) {
|
||||||
const ret = getObject(arg0).crypto;
|
const ret = getObject(arg0).crypto;
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
|
__wbg_getRandomValues_c44a50d8cfdaebeb: function () {
|
||||||
|
return handleError(function (arg0, arg1) {
|
||||||
getObject(arg0).getRandomValues(getObject(arg1));
|
getObject(arg0).getRandomValues(getObject(arg1));
|
||||||
}, arguments); },
|
}, arguments);
|
||||||
__wbg_length_ea16607d7b61445b: function(arg0) {
|
},
|
||||||
|
__wbg_length_ea16607d7b61445b: function (arg0) {
|
||||||
const ret = getObject(arg0).length;
|
const ret = getObject(arg0).length;
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
__wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
|
__wbg_msCrypto_bd5a034af96bcba6: function (arg0) {
|
||||||
const ret = getObject(arg0).msCrypto;
|
const ret = getObject(arg0).msCrypto;
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbg_new_with_length_825018a1616e9e55: function(arg0) {
|
__wbg_new_with_length_825018a1616e9e55: function (arg0) {
|
||||||
const ret = new Uint8Array(arg0 >>> 0);
|
const ret = new Uint8Array(arg0 >>> 0);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbg_node_84ea875411254db1: function(arg0) {
|
__wbg_node_84ea875411254db1: function (arg0) {
|
||||||
const ret = getObject(arg0).node;
|
const ret = getObject(arg0).node;
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbg_process_44c7a14e11e9f69e: function(arg0) {
|
__wbg_process_44c7a14e11e9f69e: function (arg0) {
|
||||||
const ret = getObject(arg0).process;
|
const ret = getObject(arg0).process;
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
|
__wbg_prototypesetcall_d62e5099504357e6: function (arg0, arg1, arg2) {
|
||||||
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
Uint8Array.prototype.set.call(
|
||||||
|
getArrayU8FromWasm0(arg0, arg1),
|
||||||
|
getObject(arg2)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
__wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
|
__wbg_randomFillSync_6c25eac9869eb53c: function () {
|
||||||
|
return handleError(function (arg0, arg1) {
|
||||||
getObject(arg0).randomFillSync(takeObject(arg1));
|
getObject(arg0).randomFillSync(takeObject(arg1));
|
||||||
}, arguments); },
|
}, arguments);
|
||||||
__wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
|
},
|
||||||
|
__wbg_require_b4edbdcf3e2a1ef0: function () {
|
||||||
|
return handleError(function () {
|
||||||
const ret = module.require;
|
const ret = module.require;
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
}, arguments); },
|
}, arguments);
|
||||||
__wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function() {
|
},
|
||||||
|
__wbg_static_accessor_GLOBAL_8adb955bd33fac2f: function () {
|
||||||
const ret = typeof global === 'undefined' ? null : global;
|
const ret = typeof global === 'undefined' ? null : global;
|
||||||
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function() {
|
__wbg_static_accessor_GLOBAL_THIS_ad356e0db91c7913: function () {
|
||||||
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
||||||
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbg_static_accessor_SELF_f207c857566db248: function() {
|
__wbg_static_accessor_SELF_f207c857566db248: function () {
|
||||||
const ret = typeof self === 'undefined' ? null : self;
|
const ret = typeof self === 'undefined' ? null : self;
|
||||||
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function() {
|
__wbg_static_accessor_WINDOW_bb9f1ba69d61b386: function () {
|
||||||
const ret = typeof window === 'undefined' ? null : window;
|
const ret = typeof window === 'undefined' ? null : window;
|
||||||
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbg_subarray_a068d24e39478a8a: function(arg0, arg1, arg2) {
|
__wbg_subarray_a068d24e39478a8a: function (arg0, arg1, arg2) {
|
||||||
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbg_versions_276b2795b1c6a219: function(arg0) {
|
__wbg_versions_276b2795b1c6a219: function (arg0) {
|
||||||
const ret = getObject(arg0).versions;
|
const ret = getObject(arg0).versions;
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
__wbindgen_cast_0000000000000001: function (arg0, arg1) {
|
||||||
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
||||||
const ret = getArrayU8FromWasm0(arg0, arg1);
|
const ret = getArrayU8FromWasm0(arg0, arg1);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
__wbindgen_cast_0000000000000002: function (arg0, arg1) {
|
||||||
// Cast intrinsic for `Ref(String) -> Externref`.
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
||||||
const ret = getStringFromWasm0(arg0, arg1);
|
const ret = getStringFromWasm0(arg0, arg1);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbindgen_object_clone_ref: function(arg0) {
|
__wbindgen_object_clone_ref: function (arg0) {
|
||||||
const ret = getObject(arg0);
|
const ret = getObject(arg0);
|
||||||
return addHeapObject(ret);
|
return addHeapObject(ret);
|
||||||
},
|
},
|
||||||
__wbindgen_object_drop_ref: function(arg0) {
|
__wbindgen_object_drop_ref: function (arg0) {
|
||||||
takeObject(arg0);
|
takeObject(arg0);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
"./flocking_bg.js": import0,
|
'./flocking_bg.js': import0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const SimulationWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
const SimulationWasmFinalization =
|
||||||
|
typeof FinalizationRegistry === 'undefined'
|
||||||
? { register: () => {}, unregister: () => {} }
|
? { register: () => {}, unregister: () => {} }
|
||||||
: new FinalizationRegistry(ptr => wasm.__wbg_simulationwasm_free(ptr >>> 0, 1));
|
: new FinalizationRegistry((ptr) =>
|
||||||
|
wasm.__wbg_simulationwasm_free(ptr >>> 0, 1)
|
||||||
|
);
|
||||||
|
|
||||||
function addHeapObject(obj) {
|
function addHeapObject(obj) {
|
||||||
if (heap_next === heap.length) heap.push(heap.length + 1);
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
||||||
@@ -251,13 +266,18 @@ function getStringFromWasm0(ptr, len) {
|
|||||||
|
|
||||||
let cachedUint8ArrayMemory0 = null;
|
let cachedUint8ArrayMemory0 = null;
|
||||||
function getUint8ArrayMemory0() {
|
function getUint8ArrayMemory0() {
|
||||||
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
if (
|
||||||
|
cachedUint8ArrayMemory0 === null ||
|
||||||
|
cachedUint8ArrayMemory0.byteLength === 0
|
||||||
|
) {
|
||||||
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
||||||
}
|
}
|
||||||
return cachedUint8ArrayMemory0;
|
return cachedUint8ArrayMemory0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getObject(idx) { return heap[idx]; }
|
function getObject(idx) {
|
||||||
|
return heap[idx];
|
||||||
|
}
|
||||||
|
|
||||||
function handleError(f, args) {
|
function handleError(f, args) {
|
||||||
try {
|
try {
|
||||||
@@ -282,18 +302,26 @@ function takeObject(idx) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
let cachedTextDecoder = new TextDecoder('utf-8', {
|
||||||
|
ignoreBOM: true,
|
||||||
|
fatal: true,
|
||||||
|
});
|
||||||
cachedTextDecoder.decode();
|
cachedTextDecoder.decode();
|
||||||
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
||||||
let numBytesDecoded = 0;
|
let numBytesDecoded = 0;
|
||||||
function decodeText(ptr, len) {
|
function decodeText(ptr, len) {
|
||||||
numBytesDecoded += len;
|
numBytesDecoded += len;
|
||||||
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
||||||
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
cachedTextDecoder = new TextDecoder('utf-8', {
|
||||||
|
ignoreBOM: true,
|
||||||
|
fatal: true,
|
||||||
|
});
|
||||||
cachedTextDecoder.decode();
|
cachedTextDecoder.decode();
|
||||||
numBytesDecoded = len;
|
numBytesDecoded = len;
|
||||||
}
|
}
|
||||||
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
return cachedTextDecoder.decode(
|
||||||
|
getUint8ArrayMemory0().subarray(ptr, ptr + len)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let wasmModule, wasm;
|
let wasmModule, wasm;
|
||||||
@@ -312,10 +340,17 @@ async function __wbg_load(module, imports) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
const validResponse = module.ok && expectedResponseType(module.type);
|
const validResponse = module.ok && expectedResponseType(module.type);
|
||||||
|
|
||||||
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
if (
|
||||||
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
validResponse &&
|
||||||
|
module.headers.get('Content-Type') !== 'application/wasm'
|
||||||
} else { throw e; }
|
) {
|
||||||
|
console.warn(
|
||||||
|
'`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n',
|
||||||
|
e
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,7 +368,10 @@ async function __wbg_load(module, imports) {
|
|||||||
|
|
||||||
function expectedResponseType(type) {
|
function expectedResponseType(type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'basic': case 'cors': case 'default': return true;
|
case 'basic':
|
||||||
|
case 'cors':
|
||||||
|
case 'default':
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -342,12 +380,13 @@ async function __wbg_load(module, imports) {
|
|||||||
function initSync(module) {
|
function initSync(module) {
|
||||||
if (wasm !== undefined) return wasm;
|
if (wasm !== undefined) return wasm;
|
||||||
|
|
||||||
|
|
||||||
if (module !== undefined) {
|
if (module !== undefined) {
|
||||||
if (Object.getPrototypeOf(module) === Object.prototype) {
|
if (Object.getPrototypeOf(module) === Object.prototype) {
|
||||||
({module} = module)
|
({ module } = module);
|
||||||
} else {
|
} else {
|
||||||
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
console.warn(
|
||||||
|
'using deprecated parameters for `initSync()`; pass a single object instead'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,12 +401,13 @@ function initSync(module) {
|
|||||||
async function __wbg_init(module_or_path) {
|
async function __wbg_init(module_or_path) {
|
||||||
if (wasm !== undefined) return wasm;
|
if (wasm !== undefined) return wasm;
|
||||||
|
|
||||||
|
|
||||||
if (module_or_path !== undefined) {
|
if (module_or_path !== undefined) {
|
||||||
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
||||||
({module_or_path} = module_or_path)
|
({ module_or_path } = module_or_path);
|
||||||
} else {
|
} else {
|
||||||
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
console.warn(
|
||||||
|
'using deprecated parameters for the initialization function; pass a single object instead'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,7 +416,11 @@ async function __wbg_init(module_or_path) {
|
|||||||
}
|
}
|
||||||
const imports = __wbg_get_imports();
|
const imports = __wbg_get_imports();
|
||||||
|
|
||||||
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
if (
|
||||||
|
typeof module_or_path === 'string' ||
|
||||||
|
(typeof Request === 'function' && module_or_path instanceof Request) ||
|
||||||
|
(typeof URL === 'function' && module_or_path instanceof URL)
|
||||||
|
) {
|
||||||
module_or_path = fetch(module_or_path);
|
module_or_path = fetch(module_or_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,10 @@ function updateControlsCollapsedState(isCollapsed) {
|
|||||||
controls.classList.toggle('collapsed', isCollapsed);
|
controls.classList.toggle('collapsed', isCollapsed);
|
||||||
controls.setAttribute('aria-expanded', String(!isCollapsed));
|
controls.setAttribute('aria-expanded', String(!isCollapsed));
|
||||||
controlsToggle.setAttribute('aria-expanded', String(!isCollapsed));
|
controlsToggle.setAttribute('aria-expanded', String(!isCollapsed));
|
||||||
controlsToggle.setAttribute('aria-label', isCollapsed ? 'Expand controls' : 'Collapse controls');
|
controlsToggle.setAttribute(
|
||||||
|
'aria-label',
|
||||||
|
isCollapsed ? 'Expand controls' : 'Collapse controls'
|
||||||
|
);
|
||||||
controlsToggle.textContent = isCollapsed ? '‹' : '›';
|
controlsToggle.textContent = isCollapsed ? '‹' : '›';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +76,8 @@ function sizeCanvasToViewport() {
|
|||||||
displayWidth = nextDisplayWidth;
|
displayWidth = nextDisplayWidth;
|
||||||
displayHeight = nextDisplayHeight;
|
displayHeight = nextDisplayHeight;
|
||||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||||
document.getElementById('canvasSize').textContent = `${displayWidth}x${displayHeight}`;
|
document.getElementById('canvasSize').textContent =
|
||||||
|
`${displayWidth}x${displayHeight}`;
|
||||||
|
|
||||||
return { width: displayWidth, height: displayHeight };
|
return { width: displayWidth, height: displayHeight };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,16 @@
|
|||||||
--panel-transition: 180ms ease;
|
--panel-transition: 180ms ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
html, body {
|
html,
|
||||||
|
body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
font-family:
|
||||||
|
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
|
||||||
|
Cantarell, sans-serif;
|
||||||
background: #121212;
|
background: #121212;
|
||||||
color: #d9d9d9;
|
color: #d9d9d9;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@@ -43,7 +46,9 @@ body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
transition: width var(--panel-transition), min-width var(--panel-transition);
|
transition:
|
||||||
|
width var(--panel-transition),
|
||||||
|
min-width var(--panel-transition);
|
||||||
min-width: var(--panel-width);
|
min-width: var(--panel-width);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +126,7 @@ label {
|
|||||||
color: #a0a0a0;
|
color: #a0a0a0;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"] {
|
input[type='range'] {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 6px;
|
height: 6px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
@@ -131,7 +136,7 @@ input[type="range"] {
|
|||||||
appearance: none;
|
appearance: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"]::-webkit-slider-thumb {
|
input[type='range']::-webkit-slider-thumb {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
width: 16px;
|
width: 16px;
|
||||||
@@ -142,11 +147,11 @@ input[type="range"]::-webkit-slider-thumb {
|
|||||||
transition: background 0.2s;
|
transition: background 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"]::-webkit-slider-thumb:hover {
|
input[type='range']::-webkit-slider-thumb:hover {
|
||||||
background: #2196f3;
|
background: #2196f3;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"]::-moz-range-thumb {
|
input[type='range']::-moz-range-thumb {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
@@ -156,7 +161,7 @@ input[type="range"]::-moz-range-thumb {
|
|||||||
transition: background 0.2s;
|
transition: background 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"]::-moz-range-thumb:hover {
|
input[type='range']::-moz-range-thumb:hover {
|
||||||
background: #2196f3;
|
background: #2196f3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="range"] {
|
input[type='range'] {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 10px auto 0;
|
margin: 10px auto 0;
|
||||||
width: 260px;
|
width: 260px;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@
|
|||||||
field[i],
|
field[i],
|
||||||
field[i + 1],
|
field[i + 1],
|
||||||
field[i + cols + 1],
|
field[i + cols + 1],
|
||||||
field[i + cols],
|
field[i + cols]
|
||||||
);
|
);
|
||||||
noStroke();
|
noStroke();
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ function Cell(i, j) {
|
|||||||
this.walls = [true, true, true, true];
|
this.walls = [true, true, true, true];
|
||||||
this.visited = false;
|
this.visited = false;
|
||||||
|
|
||||||
this.checkNeighbors = function() {
|
this.checkNeighbors = function () {
|
||||||
var neighbors = [];
|
var neighbors = [];
|
||||||
|
|
||||||
var top = grid[index(i, j -1)];
|
var top = grid[index(i, j - 1)];
|
||||||
var right = grid[index(i+1, j)];
|
var right = grid[index(i + 1, j)];
|
||||||
var bottom = grid[index(i, j+1)];
|
var bottom = grid[index(i, j + 1)];
|
||||||
var left = grid[index(i-1, j)];
|
var left = grid[index(i - 1, j)];
|
||||||
|
|
||||||
if (top && !top.visited) {
|
if (top && !top.visited) {
|
||||||
neighbors.push(top);
|
neighbors.push(top);
|
||||||
@@ -31,32 +31,30 @@ function Cell(i, j) {
|
|||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
this.highlight = function () {
|
||||||
}
|
var x = this.i * w;
|
||||||
this.highlight = function() {
|
var y = this.j * w;
|
||||||
var x = this.i*w;
|
|
||||||
var y = this.j*w;
|
|
||||||
noStroke();
|
noStroke();
|
||||||
fill(252, 106, 2, 100);
|
fill(252, 106, 2, 100);
|
||||||
rect(x, y, w, w);
|
rect(x, y, w, w);
|
||||||
}
|
};
|
||||||
|
|
||||||
this.show = function() {
|
this.show = function () {
|
||||||
var x = this.i*w;
|
var x = this.i * w;
|
||||||
var y = this.j*w;
|
var y = this.j * w;
|
||||||
stroke(0);
|
stroke(0);
|
||||||
if (this.walls[0]) {
|
if (this.walls[0]) {
|
||||||
line(x , y , x + w, y);
|
line(x, y, x + w, y);
|
||||||
}
|
}
|
||||||
if (this.walls[1]) {
|
if (this.walls[1]) {
|
||||||
line(x + w, y , x + w, y + w);
|
line(x + w, y, x + w, y + w);
|
||||||
}
|
}
|
||||||
if (this.walls[2]) {
|
if (this.walls[2]) {
|
||||||
line(x + w, y + w, x , y + w);
|
line(x + w, y + w, x, y + w);
|
||||||
}
|
}
|
||||||
if (this.walls[3]) {
|
if (this.walls[3]) {
|
||||||
line(x , y + w, x , y);
|
line(x, y + w, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.visited) {
|
if (this.visited) {
|
||||||
@@ -64,5 +62,5 @@ function Cell(i, j) {
|
|||||||
fill(242, 255, 28, 125);
|
fill(242, 255, 28, 125);
|
||||||
rect(x, y, w, w);
|
rect(x, y, w, w);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,26 +4,25 @@ var grid = [];
|
|||||||
var current;
|
var current;
|
||||||
var stack = [];
|
var stack = [];
|
||||||
|
|
||||||
function setup(){
|
function setup() {
|
||||||
createCanvas(800, 800);
|
createCanvas(800, 800);
|
||||||
cols = floor(width/w)
|
cols = floor(width / w);
|
||||||
rows = floor(height/w)
|
rows = floor(height / w);
|
||||||
//frameRate(6);
|
//frameRate(6);
|
||||||
|
|
||||||
for (var j = 0; j < rows; j++){
|
for (var j = 0; j < rows; j++) {
|
||||||
for (var i = 0; i < cols; i++){
|
for (var i = 0; i < cols; i++) {
|
||||||
var cell = new Cell(i,j);
|
var cell = new Cell(i, j);
|
||||||
grid.push(cell);
|
grid.push(cell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current = grid[0];
|
current = grid[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw(){
|
function draw() {
|
||||||
background(150);
|
background(150);
|
||||||
for (var i = 0; i < grid.length; i++){
|
for (var i = 0; i < grid.length; i++) {
|
||||||
grid[i].show();
|
grid[i].show();
|
||||||
|
|
||||||
}
|
}
|
||||||
current.visited = true;
|
current.visited = true;
|
||||||
current.highlight();
|
current.highlight();
|
||||||
@@ -35,103 +34,99 @@ function draw(){
|
|||||||
removeWalls(current, next);
|
removeWalls(current, next);
|
||||||
|
|
||||||
current = next;
|
current = next;
|
||||||
} else if (stack.length > 0){
|
} else if (stack.length > 0) {
|
||||||
current = stack.pop();
|
current = stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function index(i, j) {
|
||||||
function index(i, j){
|
if (i < 0 || j < 0 || i > cols - 1 || j > rows - 1) {
|
||||||
if(i < 0 || j < 0 || i > cols-1 || j > rows-1){
|
return -1;
|
||||||
return -1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return i + j * cols;
|
return i + j * cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cell(i, j){
|
function cell(i, j) {
|
||||||
this.i = i;
|
this.i = i;
|
||||||
this.j = j;
|
this.j = j;
|
||||||
this.walls = [true, true, true, true];
|
this.walls = [true, true, true, true];
|
||||||
this.visited = false;
|
this.visited = false;
|
||||||
|
|
||||||
this.checkNeighbors = function(){
|
this.checkNeighbors = function () {
|
||||||
var neighbors = [];
|
var neighbors = [];
|
||||||
|
|
||||||
var top = grid[index(i, j-1)];
|
var top = grid[index(i, j - 1)];
|
||||||
var right = grid[index(i+1, j)];
|
var right = grid[index(i + 1, j)];
|
||||||
var bottom = grid[index(i, j + 1)];
|
var bottom = grid[index(i, j + 1)];
|
||||||
var left = grid[index(i-1, j)];
|
var left = grid[index(i - 1, j)];
|
||||||
|
|
||||||
if (top && !top.visited){
|
if (top && !top.visited) {
|
||||||
neighbors.push(top);
|
neighbors.push(top);
|
||||||
}
|
}
|
||||||
if (right && !right.visited){
|
if (right && !right.visited) {
|
||||||
neighbors.push(right);
|
neighbors.push(right);
|
||||||
}
|
}
|
||||||
if (bottom && !bottom.visited){
|
if (bottom && !bottom.visited) {
|
||||||
neighbors.push(bottom);
|
neighbors.push(bottom);
|
||||||
}
|
}
|
||||||
if (left && !left.visited){
|
if (left && !left.visited) {
|
||||||
neighbors.push(left);
|
neighbors.push(left);
|
||||||
}
|
}
|
||||||
if (neighbors.length > 0){
|
if (neighbors.length > 0) {
|
||||||
var r = floor(random(0, neighbors.length));
|
var r = floor(random(0, neighbors.length));
|
||||||
return neighbor[r];
|
return neighbor[r];
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
this.highlight = function(){
|
this.highlight = function () {
|
||||||
var x = this.i*w;
|
var x = this.i * w;
|
||||||
var y = this.j*w;
|
var y = this.j * w;
|
||||||
noStroke();
|
noStroke();
|
||||||
fill(0, 0, 255, 125);
|
fill(0, 0, 255, 125);
|
||||||
rect(x,y,w,w);
|
rect(x, y, w, w);
|
||||||
}
|
};
|
||||||
|
};
|
||||||
|
|
||||||
}
|
this.show = function () {
|
||||||
|
var x = this.i * w;
|
||||||
this.show = function(){
|
var y = this.j * w;
|
||||||
var x = this.i*w;
|
|
||||||
var y = this.j*w;
|
|
||||||
stroke(255);
|
stroke(255);
|
||||||
if (this.walls[0]){
|
if (this.walls[0]) {
|
||||||
line(x,y,x+w,y);
|
line(x, y, x + w, y);
|
||||||
}
|
}
|
||||||
if (this.walls[1]){
|
if (this.walls[1]) {
|
||||||
line(x+w,y,x+w,y+w);
|
line(x + w, y, x + w, y + w);
|
||||||
}
|
}
|
||||||
if (this.walls[2]){
|
if (this.walls[2]) {
|
||||||
line(x+w,y+w,x,y+w);
|
line(x + w, y + w, x, y + w);
|
||||||
}
|
}
|
||||||
if (this.walls[3]){
|
if (this.walls[3]) {
|
||||||
line(x,y+w,x,y);
|
line(x, y + w, x, y);
|
||||||
}
|
}
|
||||||
if (this.visited){
|
if (this.visited) {
|
||||||
fill(255, 0, 255, 125);
|
fill(255, 0, 255, 125);
|
||||||
rect(x,y,w,w);
|
rect(x, y, w, w);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeWalls(a, b){
|
function removeWalls(a, b) {
|
||||||
var x = a.i - b.i;
|
var x = a.i - b.i;
|
||||||
if (x === 1){
|
if (x === 1) {
|
||||||
a.walls[3] = false;
|
a.walls[3] = false;
|
||||||
b.walls[1] = false;
|
b.walls[1] = false;
|
||||||
} else if (x === -1){
|
} else if (x === -1) {
|
||||||
a.walls[1] = false;
|
a.walls[1] = false;
|
||||||
b.walls[3] = false;
|
b.walls[3] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var y = a.j - b.j;
|
var y = a.j - b.j;
|
||||||
if (y === 1){
|
if (y === 1) {
|
||||||
a.walls[0] = false;
|
a.walls[0] = false;
|
||||||
b.walls[2] = false;
|
b.walls[2] = false;
|
||||||
} else if (y === -1){
|
} else if (y === -1) {
|
||||||
a.walls[2] = false;
|
a.walls[2] = false;
|
||||||
b.walls[0] = false;
|
b.walls[0] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3794
-2369
File diff suppressed because it is too large
Load Diff
@@ -6,10 +6,14 @@ const fullscreenButton = document.getElementById('fullscreenButton');
|
|||||||
|
|
||||||
outputElement.value = '';
|
outputElement.value = '';
|
||||||
|
|
||||||
canvasElement.addEventListener('webglcontextlost', (event) => {
|
canvasElement.addEventListener(
|
||||||
|
'webglcontextlost',
|
||||||
|
(event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setStatus('WebGL context lost. Reload the page to restart the simulation.');
|
setStatus('WebGL context lost. Reload the page to restart the simulation.');
|
||||||
}, false);
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
function setStatus(text) {
|
function setStatus(text) {
|
||||||
if (!setStatus.last) {
|
if (!setStatus.last) {
|
||||||
@@ -60,11 +64,15 @@ var Module = {
|
|||||||
totalDependencies: 0,
|
totalDependencies: 0,
|
||||||
monitorRunDependencies(left) {
|
monitorRunDependencies(left) {
|
||||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||||
setStatus(left ? `Preparing... (${this.totalDependencies - left}/${this.totalDependencies})` : 'Running...');
|
setStatus(
|
||||||
|
left
|
||||||
|
? `Preparing... (${this.totalDependencies - left}/${this.totalDependencies})`
|
||||||
|
: 'Running...'
|
||||||
|
);
|
||||||
if (!left) {
|
if (!left) {
|
||||||
setTimeout(() => setStatus(''), 250);
|
setTimeout(() => setStatus(''), 250);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
fullscreenButton.addEventListener('click', () => {
|
fullscreenButton.addEventListener('click', () => {
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ textarea {
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
font-family: "Courier New", monospace;
|
font-family: 'Courier New', monospace;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
background: white;
|
background: white;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
var circleCount, total;
|
var circleCount, total;
|
||||||
var x, y;
|
var x, y;
|
||||||
var calcPI;
|
var calcPI;
|
||||||
var DisplayPI = "a";
|
var DisplayPI = 'a';
|
||||||
const PI = 3.1415926535;
|
const PI = 3.1415926535;
|
||||||
var BestPI = 50;
|
var BestPI = 50;
|
||||||
|
|
||||||
@@ -84,15 +84,15 @@
|
|||||||
DisplayPI = calcPI;
|
DisplayPI = calcPI;
|
||||||
BestPI = calcPI;
|
BestPI = calcPI;
|
||||||
|
|
||||||
var PIDisplay = document.getElementById("PIbox");
|
var PIDisplay = document.getElementById('PIbox');
|
||||||
PIDisplay.innerHTML = DisplayPI;
|
PIDisplay.innerHTML = DisplayPI;
|
||||||
|
|
||||||
var ErrorDisplay = document.getElementById("percentage");
|
var ErrorDisplay = document.getElementById('percentage');
|
||||||
var DisplayError = "a";
|
var DisplayError = 'a';
|
||||||
var Perror = (calcPI - PI) / PI;
|
var Perror = (calcPI - PI) / PI;
|
||||||
Perror *= 100;
|
Perror *= 100;
|
||||||
DisplayError = nfc(Perror, 10);
|
DisplayError = nfc(Perror, 10);
|
||||||
ErrorDisplay.innerHTML = DisplayError + "%";
|
ErrorDisplay.innerHTML = DisplayError + '%';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -10,10 +10,14 @@ if (outputElement) {
|
|||||||
outputElement.value = '';
|
outputElement.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
canvasElement.addEventListener('webglcontextlost', (event) => {
|
canvasElement.addEventListener(
|
||||||
|
'webglcontextlost',
|
||||||
|
(event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setStatus('WebGL context lost. Reload the page to restart the game.');
|
setStatus('WebGL context lost. Reload the page to restart the game.');
|
||||||
}, false);
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
function setStatus(text) {
|
function setStatus(text) {
|
||||||
if (!setStatus.last) {
|
if (!setStatus.last) {
|
||||||
@@ -70,7 +74,11 @@ globalThis.Module.setStatus = setStatus;
|
|||||||
globalThis.Module.totalDependencies = 0;
|
globalThis.Module.totalDependencies = 0;
|
||||||
globalThis.Module.monitorRunDependencies = function (left) {
|
globalThis.Module.monitorRunDependencies = function (left) {
|
||||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||||
setStatus(left ? `Preparing... (${this.totalDependencies - left}/${this.totalDependencies})` : 'Running...');
|
setStatus(
|
||||||
|
left
|
||||||
|
? `Preparing... (${this.totalDependencies - left}/${this.totalDependencies})`
|
||||||
|
: 'Running...'
|
||||||
|
);
|
||||||
if (!left) {
|
if (!left) {
|
||||||
setTimeout(() => setStatus(''), 250);
|
setTimeout(() => setStatus(''), 250);
|
||||||
}
|
}
|
||||||
@@ -78,7 +86,10 @@ globalThis.Module.monitorRunDependencies = function (left) {
|
|||||||
|
|
||||||
fullscreenButton.addEventListener('click', () => {
|
fullscreenButton.addEventListener('click', () => {
|
||||||
if (typeof globalThis.Module.requestFullscreen === 'function') {
|
if (typeof globalThis.Module.requestFullscreen === 'function') {
|
||||||
globalThis.Module.requestFullscreen(pointerLockCheckbox.checked, resizeCheckbox.checked);
|
globalThis.Module.requestFullscreen(
|
||||||
|
pointerLockCheckbox.checked,
|
||||||
|
resizeCheckbox.checked
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ h3,
|
|||||||
button,
|
button,
|
||||||
summary,
|
summary,
|
||||||
.back-button {
|
.back-button {
|
||||||
font-family: "Arial Black", Arial, Helvetica, sans-serif;
|
font-family: 'Arial Black', Arial, Helvetica, sans-serif;
|
||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
letter-spacing: 0.02em;
|
letter-spacing: 0.02em;
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,7 @@ textarea {
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border: 3px solid var(--border);
|
border: 3px solid var(--border);
|
||||||
font-family: "Courier New", monospace;
|
font-family: 'Courier New', monospace;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
resize: vertical;
|
resize: vertical;
|
||||||
background: white;
|
background: white;
|
||||||
|
|||||||
+8710
-1
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@ export function setupCanvas(gl, canvas) {
|
|||||||
return {
|
return {
|
||||||
canvas,
|
canvas,
|
||||||
gl,
|
gl,
|
||||||
aspectRatio: canvas.width / canvas.height
|
aspectRatio: canvas.width / canvas.height,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,5 +15,9 @@ export function resizeCanvas(gl, canvas, program) {
|
|||||||
canvas.height = canvas.clientHeight * window.devicePixelRatio;
|
canvas.height = canvas.clientHeight * window.devicePixelRatio;
|
||||||
gl.viewport(0, 0, canvas.width, canvas.height);
|
gl.viewport(0, 0, canvas.width, canvas.height);
|
||||||
gl.useProgram(program);
|
gl.useProgram(program);
|
||||||
gl.uniform2f(gl.getUniformLocation(program, "u_resolution"), canvas.width, canvas.height);
|
gl.uniform2f(
|
||||||
|
gl.getUniformLocation(program, 'u_resolution'),
|
||||||
|
canvas.width,
|
||||||
|
canvas.height
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+68
-41
@@ -1,8 +1,8 @@
|
|||||||
import { initWasm } from "./wasm.js";
|
import { initWasm } from './wasm.js';
|
||||||
import { setupCanvas, resizeCanvas } from "./canvas.js";
|
import { setupCanvas, resizeCanvas } from './canvas.js';
|
||||||
import { createShaderProgram } from "./shaders.js";
|
import { createShaderProgram } from './shaders.js';
|
||||||
import { draw } from "./tsp-gl.js";
|
import { draw } from './tsp-gl.js';
|
||||||
import { initPoints } from "./utils.js";
|
import { initPoints } from './utils.js';
|
||||||
|
|
||||||
const DEFAULT_POINT_COUNT = 36;
|
const DEFAULT_POINT_COUNT = 36;
|
||||||
const MIN_POINTS = 4;
|
const MIN_POINTS = 4;
|
||||||
@@ -57,28 +57,31 @@ function createLineFragmentShader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const canvas = document.getElementById("tsp-canvas");
|
const canvas = document.getElementById('tsp-canvas');
|
||||||
const pointCountInput = document.getElementById("pointCountInput");
|
const pointCountInput = document.getElementById('pointCountInput');
|
||||||
const applyPointCountButton = document.getElementById("applyPointCountButton");
|
const applyPointCountButton = document.getElementById(
|
||||||
const pointCountStatus = document.getElementById("pointCountStatus");
|
'applyPointCountButton'
|
||||||
|
);
|
||||||
|
const pointCountStatus = document.getElementById('pointCountStatus');
|
||||||
|
|
||||||
if (!canvas || !pointCountInput || !applyPointCountButton || !pointCountStatus) {
|
if (
|
||||||
|
!canvas ||
|
||||||
|
!pointCountInput ||
|
||||||
|
!applyPointCountButton ||
|
||||||
|
!pointCountStatus
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gl = canvas.getContext("webgl2");
|
const gl = canvas.getContext('webgl2');
|
||||||
if (!gl) {
|
if (!gl) {
|
||||||
pointCountStatus.textContent = "WebGL2 unavailable in this browser.";
|
pointCountStatus.textContent = 'WebGL2 unavailable in this browser.';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl.clearColor(0.1, 0.1, 0.1, 1);
|
gl.clearColor(0.1, 0.1, 0.1, 1);
|
||||||
|
|
||||||
const {
|
const { initialisePoints, getPointOrder, memory } = await initWasm();
|
||||||
initialisePoints,
|
|
||||||
getPointOrder,
|
|
||||||
memory
|
|
||||||
} = await initWasm();
|
|
||||||
|
|
||||||
const vertexCode = `
|
const vertexCode = `
|
||||||
attribute vec2 a_position;
|
attribute vec2 a_position;
|
||||||
@@ -93,7 +96,7 @@ async function run() {
|
|||||||
const lineBuffer = gl.createBuffer();
|
const lineBuffer = gl.createBuffer();
|
||||||
|
|
||||||
if (!positionBuffer || !lineBuffer) {
|
if (!positionBuffer || !lineBuffer) {
|
||||||
pointCountStatus.textContent = "Unable to initialise WebGL buffers.";
|
pointCountStatus.textContent = 'Unable to initialise WebGL buffers.';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,20 +106,26 @@ async function run() {
|
|||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
scene: null,
|
scene: null,
|
||||||
draggingIndex: -1
|
draggingIndex: -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
function updateStatus(pointCount) {
|
function updateStatus(pointCount) {
|
||||||
pointCountStatus.textContent = `${pointCount} point${pointCount === 1 ? "" : "s"}`;
|
pointCountStatus.textContent = `${pointCount} point${pointCount === 1 ? '' : 's'}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function recalculateRoute(scene) {
|
function recalculateRoute(scene) {
|
||||||
const pointOrderPtr = getPointOrder(scene.pointsPtr, scene.pointCount);
|
const pointOrderPtr = getPointOrder(scene.pointsPtr, scene.pointCount);
|
||||||
scene.pointOrder = Array.from(new Uint32Array(memory.buffer, pointOrderPtr, scene.pointCount));
|
scene.pointOrder = Array.from(
|
||||||
|
new Uint32Array(memory.buffer, pointOrderPtr, scene.pointCount)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncPointsToMemory(scene) {
|
function syncPointsToMemory(scene) {
|
||||||
scene.pointArray = new Float32Array(memory.buffer, scene.pointsPtr, scene.pointCount * 2);
|
scene.pointArray = new Float32Array(
|
||||||
|
memory.buffer,
|
||||||
|
scene.pointsPtr,
|
||||||
|
scene.pointCount * 2
|
||||||
|
);
|
||||||
|
|
||||||
for (let i = 0; i < scene.points.length; i++) {
|
for (let i = 0; i < scene.points.length; i++) {
|
||||||
scene.pointArray[i * 2] = scene.points[i].cx;
|
scene.pointArray[i * 2] = scene.points[i].cx;
|
||||||
@@ -133,10 +142,22 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const pointsPtr = initialisePoints(pointCount, Date.now());
|
const pointsPtr = initialisePoints(pointCount, Date.now());
|
||||||
const pointArray = new Float32Array(memory.buffer, pointsPtr, pointCount * 2);
|
const pointArray = new Float32Array(
|
||||||
|
memory.buffer,
|
||||||
|
pointsPtr,
|
||||||
|
pointCount * 2
|
||||||
|
);
|
||||||
const points = initPoints(pointArray);
|
const points = initPoints(pointArray);
|
||||||
const program = createShaderProgram(gl, vertexCode, createPointFragmentShader(pointCount));
|
const program = createShaderProgram(
|
||||||
const lineProgram = createShaderProgram(gl, vertexCode, createLineFragmentShader());
|
gl,
|
||||||
|
vertexCode,
|
||||||
|
createPointFragmentShader(pointCount)
|
||||||
|
);
|
||||||
|
const lineProgram = createShaderProgram(
|
||||||
|
gl,
|
||||||
|
vertexCode,
|
||||||
|
createLineFragmentShader()
|
||||||
|
);
|
||||||
|
|
||||||
state.scene = {
|
state.scene = {
|
||||||
pointCount,
|
pointCount,
|
||||||
@@ -145,7 +166,7 @@ async function run() {
|
|||||||
points,
|
points,
|
||||||
pointOrder: [],
|
pointOrder: [],
|
||||||
program,
|
program,
|
||||||
lineProgram
|
lineProgram,
|
||||||
};
|
};
|
||||||
|
|
||||||
recalculateRoute(state.scene);
|
recalculateRoute(state.scene);
|
||||||
@@ -154,7 +175,7 @@ async function run() {
|
|||||||
pointCountInput.value = String(pointCount);
|
pointCountInput.value = String(pointCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.addEventListener("mousedown", (e) => {
|
canvas.addEventListener('mousedown', (e) => {
|
||||||
if (!state.scene) {
|
if (!state.scene) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -165,8 +186,8 @@ async function run() {
|
|||||||
|
|
||||||
for (let i = 0; i < state.scene.points.length; i++) {
|
for (let i = 0; i < state.scene.points.length; i++) {
|
||||||
const point = state.scene.points[i];
|
const point = state.scene.points[i];
|
||||||
const dx = (0.5 * x + 0.5) - point.cx;
|
const dx = 0.5 * x + 0.5 - point.cx;
|
||||||
const dy = (0.5 * y + 0.5) - point.cy;
|
const dy = 0.5 * y + 0.5 - point.cy;
|
||||||
const distance = Math.hypot(dx, dy);
|
const distance = Math.hypot(dx, dy);
|
||||||
|
|
||||||
if (distance <= RADIUS_SIZE) {
|
if (distance <= RADIUS_SIZE) {
|
||||||
@@ -176,14 +197,16 @@ async function run() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
canvas.addEventListener("mousemove", (e) => {
|
canvas.addEventListener('mousemove', (e) => {
|
||||||
if (!state.scene || state.draggingIndex === -1) {
|
if (!state.scene || state.draggingIndex === -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rect = canvas.getBoundingClientRect();
|
const rect = canvas.getBoundingClientRect();
|
||||||
state.scene.points[state.draggingIndex].cx = (e.clientX - rect.left) / rect.width;
|
state.scene.points[state.draggingIndex].cx =
|
||||||
state.scene.points[state.draggingIndex].cy = 1 - (e.clientY - rect.top) / rect.height;
|
(e.clientX - rect.left) / rect.width;
|
||||||
|
state.scene.points[state.draggingIndex].cy =
|
||||||
|
1 - (e.clientY - rect.top) / rect.height;
|
||||||
|
|
||||||
syncPointsToMemory(state.scene);
|
syncPointsToMemory(state.scene);
|
||||||
recalculateRoute(state.scene);
|
recalculateRoute(state.scene);
|
||||||
@@ -193,26 +216,30 @@ async function run() {
|
|||||||
state.draggingIndex = -1;
|
state.draggingIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.addEventListener("mouseup", stopDragging);
|
canvas.addEventListener('mouseup', stopDragging);
|
||||||
canvas.addEventListener("mouseleave", stopDragging);
|
canvas.addEventListener('mouseleave', stopDragging);
|
||||||
|
|
||||||
function applyPointCount() {
|
function applyPointCount() {
|
||||||
const nextPointCount = clampPointCount(Number.parseInt(pointCountInput.value, 10));
|
const nextPointCount = clampPointCount(
|
||||||
|
Number.parseInt(pointCountInput.value, 10)
|
||||||
|
);
|
||||||
initialiseScene(nextPointCount);
|
initialiseScene(nextPointCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
applyPointCountButton.addEventListener("click", applyPointCount);
|
applyPointCountButton.addEventListener('click', applyPointCount);
|
||||||
pointCountInput.addEventListener("keydown", (event) => {
|
pointCountInput.addEventListener('keydown', (event) => {
|
||||||
if (event.key === "Enter") {
|
if (event.key === 'Enter') {
|
||||||
applyPointCount();
|
applyPointCount();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
pointCountInput.addEventListener("blur", () => {
|
pointCountInput.addEventListener('blur', () => {
|
||||||
pointCountInput.value = String(clampPointCount(Number.parseInt(pointCountInput.value, 10)));
|
pointCountInput.value = String(
|
||||||
|
clampPointCount(Number.parseInt(pointCountInput.value, 10))
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("resize", () => {
|
window.addEventListener('resize', () => {
|
||||||
if (!state.scene) {
|
if (!state.scene) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,3 @@ export function createShaderProgram(gl, vertexCode, fragCode) {
|
|||||||
|
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-5
@@ -1,7 +1,16 @@
|
|||||||
// tsp-gl.js
|
// tsp-gl.js
|
||||||
import { updateLines } from "./utils.js";
|
import { updateLines } from './utils.js';
|
||||||
|
|
||||||
export function draw(gl, points, program, lineProgram, positionBuffer, lineBuffer, pointOrder, aspectRatio) {
|
export function draw(
|
||||||
|
gl,
|
||||||
|
points,
|
||||||
|
program,
|
||||||
|
lineProgram,
|
||||||
|
positionBuffer,
|
||||||
|
lineBuffer,
|
||||||
|
pointOrder,
|
||||||
|
aspectRatio
|
||||||
|
) {
|
||||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
// Draw Circles
|
// Draw Circles
|
||||||
@@ -22,10 +31,10 @@ function updateCircleUniforms(gl, points, program, positionBuffer) {
|
|||||||
|
|
||||||
gl.useProgram(program);
|
gl.useProgram(program);
|
||||||
|
|
||||||
gl.uniform2fv(gl.getUniformLocation(program, "u_centers"), centerArray);
|
gl.uniform2fv(gl.getUniformLocation(program, 'u_centers'), centerArray);
|
||||||
|
|
||||||
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
|
||||||
const positionAttribLoc = gl.getAttribLocation(program, "a_position");
|
const positionAttribLoc = gl.getAttribLocation(program, 'a_position');
|
||||||
gl.enableVertexAttribArray(positionAttribLoc);
|
gl.enableVertexAttribArray(positionAttribLoc);
|
||||||
gl.vertexAttribPointer(positionAttribLoc, 2, gl.FLOAT, false, 0, 0);
|
gl.vertexAttribPointer(positionAttribLoc, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
|
||||||
@@ -38,7 +47,7 @@ function drawLines(gl, program, buffer, lineVertices) {
|
|||||||
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
|
||||||
gl.bufferData(gl.ARRAY_BUFFER, lineVertices, gl.DYNAMIC_DRAW);
|
gl.bufferData(gl.ARRAY_BUFFER, lineVertices, gl.DYNAMIC_DRAW);
|
||||||
|
|
||||||
const positionAttribLoc = gl.getAttribLocation(program, "a_position");
|
const positionAttribLoc = gl.getAttribLocation(program, 'a_position');
|
||||||
gl.enableVertexAttribArray(positionAttribLoc);
|
gl.enableVertexAttribArray(positionAttribLoc);
|
||||||
gl.vertexAttribPointer(positionAttribLoc, 2, gl.FLOAT, false, 0, 0);
|
gl.vertexAttribPointer(positionAttribLoc, 2, gl.FLOAT, false, 0, 0);
|
||||||
|
|
||||||
|
|||||||
+11
-8
@@ -1,24 +1,27 @@
|
|||||||
export async function initWasm() {
|
export async function initWasm() {
|
||||||
|
|
||||||
let wasmMemory = new WebAssembly.Memory({
|
let wasmMemory = new WebAssembly.Memory({
|
||||||
initial: 256,
|
initial: 256,
|
||||||
maximum: 256
|
maximum: 256,
|
||||||
});
|
});
|
||||||
|
|
||||||
let importObject = {
|
let importObject = {
|
||||||
env: {
|
env: {
|
||||||
memory: wasmMemory,
|
memory: wasmMemory,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await fetch("./main.wasm");
|
const response = await fetch('./main.wasm');
|
||||||
const wasmModule = await WebAssembly.instantiateStreaming(response, importObject);
|
const wasmModule = await WebAssembly.instantiateStreaming(
|
||||||
const { initialisePoints, getPointOrder, memory } = wasmModule.instance.exports;
|
response,
|
||||||
|
importObject
|
||||||
|
);
|
||||||
|
const { initialisePoints, getPointOrder, memory } =
|
||||||
|
wasmModule.instance.exports;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
initialisePoints,
|
initialisePoints,
|
||||||
getPointOrder,
|
getPointOrder,
|
||||||
memory,
|
memory,
|
||||||
wasmMemory
|
wasmMemory,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@
|
|||||||
function draw() {
|
function draw() {
|
||||||
background(43);
|
background(43);
|
||||||
angleMode(DEGREES);
|
angleMode(DEGREES);
|
||||||
lineNum = document.getElementById("myRange").value;
|
lineNum = document.getElementById('myRange').value;
|
||||||
|
|
||||||
drawLine(hMargin, lineNum + 1);
|
drawLine(hMargin, lineNum + 1);
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
width / 2,
|
width / 2,
|
||||||
(j * height) / vm,
|
(j * height) / vm,
|
||||||
((hm - 1) * width) / hm,
|
((hm - 1) * width) / hm,
|
||||||
(j * height) / vm,
|
(j * height) / vm
|
||||||
); //blue line
|
); //blue line
|
||||||
|
|
||||||
stroke(255);
|
stroke(255);
|
||||||
@@ -177,39 +177,39 @@
|
|||||||
width / hm,
|
width / hm,
|
||||||
(j * height) / vm,
|
(j * height) / vm,
|
||||||
width / hm + changex,
|
width / hm + changex,
|
||||||
(j * height) / vm - arrowHeight,
|
(j * height) / vm - arrowHeight
|
||||||
); //left top
|
); //left top
|
||||||
line(
|
line(
|
||||||
width / hm + changex,
|
width / hm + changex,
|
||||||
(j * height) / vm + arrowHeight,
|
(j * height) / vm + arrowHeight,
|
||||||
width / hm,
|
width / hm,
|
||||||
(j * height) / vm,
|
(j * height) / vm
|
||||||
); //left bottom
|
); //left bottom
|
||||||
|
|
||||||
line(
|
line(
|
||||||
((hm - 1) * width) / hm + changex,
|
((hm - 1) * width) / hm + changex,
|
||||||
(j * height) / vm + arrowHeight,
|
(j * height) / vm + arrowHeight,
|
||||||
((hm - 1) * width) / hm,
|
((hm - 1) * width) / hm,
|
||||||
(j * height) / vm,
|
(j * height) / vm
|
||||||
); //right bottom
|
); //right bottom
|
||||||
line(
|
line(
|
||||||
width / 2 - changex,
|
width / 2 - changex,
|
||||||
(j * height) / vm + arrowHeight,
|
(j * height) / vm + arrowHeight,
|
||||||
width / 2,
|
width / 2,
|
||||||
(j * height) / vm,
|
(j * height) / vm
|
||||||
); //center bottom
|
); //center bottom
|
||||||
|
|
||||||
line(
|
line(
|
||||||
((hm - 1) * width) / hm,
|
((hm - 1) * width) / hm,
|
||||||
(j * height) / vm,
|
(j * height) / vm,
|
||||||
((hm - 1) * width) / hm + changex,
|
((hm - 1) * width) / hm + changex,
|
||||||
(j * height) / vm - arrowHeight,
|
(j * height) / vm - arrowHeight
|
||||||
); //right bottom
|
); //right bottom
|
||||||
line(
|
line(
|
||||||
width / 2,
|
width / 2,
|
||||||
(j * height) / vm,
|
(j * height) / vm,
|
||||||
width / 2 - changex,
|
width / 2 - changex,
|
||||||
(j * height) / vm - arrowHeight,
|
(j * height) / vm - arrowHeight
|
||||||
); //center top
|
); //center top
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const NAV_OFFSET = 120;
|
const NAV_OFFSET = 120;
|
||||||
const DEFAULT_VISIBLE_PROJECTS = 9;
|
const DEFAULT_VISIBLE_PROJECTS = 9;
|
||||||
const INTERACTIVE_SELECTOR = 'a, button, input, textarea, select, summary, [role="button"]';
|
const INTERACTIVE_SELECTOR =
|
||||||
|
'a, button, input, textarea, select, summary, [role="button"]';
|
||||||
|
|
||||||
initRevealOnScroll();
|
initRevealOnScroll();
|
||||||
initActiveNavLink();
|
initActiveNavLink();
|
||||||
@@ -13,7 +14,8 @@ function initRevealOnScroll() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const observer = new IntersectionObserver((entries, currentObserver) => {
|
const observer = new IntersectionObserver(
|
||||||
|
(entries, currentObserver) => {
|
||||||
entries.forEach((entry) => {
|
entries.forEach((entry) => {
|
||||||
if (!entry.isIntersecting) {
|
if (!entry.isIntersecting) {
|
||||||
return;
|
return;
|
||||||
@@ -22,7 +24,9 @@ function initRevealOnScroll() {
|
|||||||
entry.target.classList.add('visible');
|
entry.target.classList.add('visible');
|
||||||
currentObserver.unobserve(entry.target);
|
currentObserver.unobserve(entry.target);
|
||||||
});
|
});
|
||||||
}, {threshold: 0.1, rootMargin: '0px 0px -40px 0px'});
|
},
|
||||||
|
{ threshold: 0.1, rootMargin: '0px 0px -40px 0px' }
|
||||||
|
);
|
||||||
|
|
||||||
revealTargets.forEach((target) => observer.observe(target));
|
revealTargets.forEach((target) => observer.observe(target));
|
||||||
}
|
}
|
||||||
@@ -44,11 +48,14 @@ function initActiveNavLink() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
navLinks.forEach((link) => {
|
navLinks.forEach((link) => {
|
||||||
link.classList.toggle('is-active', link.getAttribute('href') === `#${currentSectionId}`);
|
link.classList.toggle(
|
||||||
|
'is-active',
|
||||||
|
link.getAttribute('href') === `#${currentSectionId}`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener('scroll', updateActiveNavLink, {passive: true});
|
window.addEventListener('scroll', updateActiveNavLink, { passive: true });
|
||||||
updateActiveNavLink();
|
updateActiveNavLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,14 +117,19 @@ function navigateToCard(card, event) {
|
|||||||
|
|
||||||
function initProjectFilters() {
|
function initProjectFilters() {
|
||||||
const filterChips = Array.from(document.querySelectorAll('.filter-chip'));
|
const filterChips = Array.from(document.querySelectorAll('.filter-chip'));
|
||||||
const projectCards = Array.from(document.querySelectorAll('#project-grid .project-card'));
|
const projectCards = Array.from(
|
||||||
|
document.querySelectorAll('#project-grid .project-card')
|
||||||
|
);
|
||||||
if (filterChips.length === 0 || projectCards.length === 0) {
|
if (filterChips.length === 0 || projectCards.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const seeMoreButton = document.querySelector('#projects-see-more');
|
const seeMoreButton = document.querySelector('#projects-see-more');
|
||||||
const techByCard = new Map(
|
const techByCard = new Map(
|
||||||
projectCards.map((card) => [card, (card.dataset.tech || '').split(/\s+/).filter(Boolean)]),
|
projectCards.map((card) => [
|
||||||
|
card,
|
||||||
|
(card.dataset.tech || '').split(/\s+/).filter(Boolean),
|
||||||
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
let selectedFilter = 'all';
|
let selectedFilter = 'all';
|
||||||
@@ -128,7 +140,8 @@ function initProjectFilters() {
|
|||||||
|
|
||||||
projectCards.forEach((card) => {
|
projectCards.forEach((card) => {
|
||||||
const tech = techByCard.get(card) || [];
|
const tech = techByCard.get(card) || [];
|
||||||
const matchesFilter = selectedFilter === 'all' || tech.includes(selectedFilter);
|
const matchesFilter =
|
||||||
|
selectedFilter === 'all' || tech.includes(selectedFilter);
|
||||||
|
|
||||||
card.classList.toggle('is-hidden', !matchesFilter);
|
card.classList.toggle('is-hidden', !matchesFilter);
|
||||||
if (!matchesFilter) {
|
if (!matchesFilter) {
|
||||||
@@ -136,7 +149,8 @@ function initProjectFilters() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isCollapsed = !isExpanded && visibleCount >= DEFAULT_VISIBLE_PROJECTS;
|
const isCollapsed =
|
||||||
|
!isExpanded && visibleCount >= DEFAULT_VISIBLE_PROJECTS;
|
||||||
card.classList.toggle('is-collapsed', isCollapsed);
|
card.classList.toggle('is-collapsed', isCollapsed);
|
||||||
visibleCount += 1;
|
visibleCount += 1;
|
||||||
});
|
});
|
||||||
@@ -147,7 +161,10 @@ function initProjectFilters() {
|
|||||||
|
|
||||||
const canExpand = visibleCount > DEFAULT_VISIBLE_PROJECTS;
|
const canExpand = visibleCount > DEFAULT_VISIBLE_PROJECTS;
|
||||||
seeMoreButton.hidden = !canExpand;
|
seeMoreButton.hidden = !canExpand;
|
||||||
seeMoreButton.setAttribute('aria-expanded', canExpand && isExpanded ? 'true' : 'false');
|
seeMoreButton.setAttribute(
|
||||||
|
'aria-expanded',
|
||||||
|
canExpand && isExpanded ? 'true' : 'false'
|
||||||
|
);
|
||||||
seeMoreButton.textContent = isExpanded ? 'See less' : 'See more';
|
seeMoreButton.textContent = isExpanded ? 'See less' : 'See more';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ html {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: radial-gradient(rgba(205, 214, 244, 0.028) 0.5px, transparent 0.6px),
|
background:
|
||||||
|
radial-gradient(rgba(205, 214, 244, 0.028) 0.5px, transparent 0.6px),
|
||||||
radial-gradient(rgba(17, 17, 27, 0.032) 0.5px, transparent 0.6px),
|
radial-gradient(rgba(17, 17, 27, 0.032) 0.5px, transparent 0.6px),
|
||||||
radial-gradient(
|
radial-gradient(
|
||||||
1200px 800px at 12% 8%,
|
1200px 800px at 12% 8%,
|
||||||
@@ -54,18 +55,20 @@ body {
|
|||||||
transparent 64%
|
transparent 64%
|
||||||
),
|
),
|
||||||
linear-gradient(180deg, #1e1e2e 0%, #1b1b2b 55%, #1a1a29 100%);
|
linear-gradient(180deg, #1e1e2e 0%, #1b1b2b 55%, #1a1a29 100%);
|
||||||
background-size: 3px 3px,
|
background-size:
|
||||||
|
3px 3px,
|
||||||
3px 3px,
|
3px 3px,
|
||||||
auto,
|
auto,
|
||||||
auto,
|
auto,
|
||||||
auto;
|
auto;
|
||||||
background-position: 0 0,
|
background-position:
|
||||||
|
0 0,
|
||||||
1px 1px,
|
1px 1px,
|
||||||
0 0,
|
0 0,
|
||||||
0 0,
|
0 0,
|
||||||
0 0;
|
0 0;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
font-family: "JetBrains Mono", "Apple Color Emoji", monospace;
|
font-family: 'JetBrains Mono', 'Apple Color Emoji', monospace;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
line-height: 1.7;
|
line-height: 1.7;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
@@ -74,7 +77,7 @@ body {
|
|||||||
|
|
||||||
body::before,
|
body::before,
|
||||||
body::after {
|
body::after {
|
||||||
content: "";
|
content: '';
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 52rem;
|
width: 52rem;
|
||||||
height: 42rem;
|
height: 42rem;
|
||||||
@@ -148,7 +151,7 @@ nav {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.nav-logo {
|
.nav-logo {
|
||||||
font-family: "Fraunces", serif;
|
font-family: 'Fraunces', serif;
|
||||||
font-size: 1.3rem;
|
font-size: 1.3rem;
|
||||||
color: var(--mauve);
|
color: var(--mauve);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@@ -172,7 +175,7 @@ nav {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.nav-links a::after {
|
.nav-links a::after {
|
||||||
content: "";
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: -3px;
|
bottom: -3px;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -223,7 +226,7 @@ section.full-width {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.section-label::after {
|
.section-label::after {
|
||||||
content: "";
|
content: '';
|
||||||
display: block;
|
display: block;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
width: 3rem;
|
width: 3rem;
|
||||||
@@ -252,7 +255,7 @@ section.full-width {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.hero-name {
|
.hero-name {
|
||||||
font-family: "Fraunces", serif;
|
font-family: 'Fraunces', serif;
|
||||||
font-size: clamp(3.5rem, 9vw, 7.5rem);
|
font-size: clamp(3.5rem, 9vw, 7.5rem);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
@@ -268,7 +271,7 @@ section.full-width {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.hero-subtitle {
|
.hero-subtitle {
|
||||||
font-family: "Fraunces", serif;
|
font-family: 'Fraunces', serif;
|
||||||
font-size: clamp(1.2rem, 3vw, 2.2rem);
|
font-size: clamp(1.2rem, 3vw, 2.2rem);
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
color: var(--subtext1);
|
color: var(--subtext1);
|
||||||
@@ -300,7 +303,7 @@ section.full-width {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.hero-by-role {
|
.hero-by-role {
|
||||||
font-family: "Fraunces", serif;
|
font-family: 'Fraunces', serif;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
color: var(--mauve);
|
color: var(--mauve);
|
||||||
@@ -321,7 +324,7 @@ section.full-width {
|
|||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
padding: 0.6rem 1.4rem;
|
padding: 0.6rem 1.4rem;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-family: "JetBrains Mono", monospace;
|
font-family: 'JetBrains Mono', monospace;
|
||||||
font-size: 0.78rem;
|
font-size: 0.78rem;
|
||||||
letter-spacing: 0.05em;
|
letter-spacing: 0.05em;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
@@ -333,7 +336,8 @@ section.full-width {
|
|||||||
.btn-primary {
|
.btn-primary {
|
||||||
background: var(--mauve);
|
background: var(--mauve);
|
||||||
color: var(--crust);
|
color: var(--crust);
|
||||||
box-shadow: 0 0 0 1px rgba(203, 166, 247, 0.25),
|
box-shadow:
|
||||||
|
0 0 0 1px rgba(203, 166, 247, 0.25),
|
||||||
0 10px 26px rgba(17, 17, 27, 0.4);
|
0 10px 26px rgba(17, 17, 27, 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,10 +360,11 @@ section.full-width {
|
|||||||
|
|
||||||
/* Decorative grid bg */
|
/* Decorative grid bg */
|
||||||
#hero::before {
|
#hero::before {
|
||||||
content: "";
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
background-image: linear-gradient(var(--surface0) 1px, transparent 1px),
|
background-image:
|
||||||
|
linear-gradient(var(--surface0) 1px, transparent 1px),
|
||||||
linear-gradient(90deg, var(--surface0) 1px, transparent 1px);
|
linear-gradient(90deg, var(--surface0) 1px, transparent 1px);
|
||||||
background-size: 60px 60px;
|
background-size: 60px 60px;
|
||||||
opacity: 0.18;
|
opacity: 0.18;
|
||||||
@@ -450,7 +455,7 @@ section.full-width {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.version-timeline::before {
|
.version-timeline::before {
|
||||||
content: "";
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0.65rem;
|
left: 0.65rem;
|
||||||
top: 0.5rem;
|
top: 0.5rem;
|
||||||
@@ -474,7 +479,8 @@ section.full-width {
|
|||||||
border: 2px solid var(--surface1);
|
border: 2px solid var(--surface1);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin-top: 0.15rem;
|
margin-top: 0.15rem;
|
||||||
transition: border-color 0.2s,
|
transition:
|
||||||
|
border-color 0.2s,
|
||||||
background 0.2s;
|
background 0.2s;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
@@ -524,7 +530,8 @@ section.full-width {
|
|||||||
font-size: 0.7rem;
|
font-size: 0.7rem;
|
||||||
color: var(--overlay1);
|
color: var(--overlay1);
|
||||||
margin-left: 0.3rem;
|
margin-left: 0.3rem;
|
||||||
transition: color 0.2s,
|
transition:
|
||||||
|
color 0.2s,
|
||||||
transform 0.2s;
|
transform 0.2s;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
@@ -554,7 +561,7 @@ section.full-width {
|
|||||||
|
|
||||||
/* ─── Skills ───────────────────────────────────────────── */
|
/* ─── Skills ───────────────────────────────────────────── */
|
||||||
#skills h2 {
|
#skills h2 {
|
||||||
font-family: "Fraunces", serif;
|
font-family: 'Fraunces', serif;
|
||||||
font-size: 2.8rem;
|
font-size: 2.8rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
@@ -676,7 +683,7 @@ section.full-width {
|
|||||||
|
|
||||||
/* ─── Tutorials / Projects shared ─────────────────────── */
|
/* ─── Tutorials / Projects shared ─────────────────────── */
|
||||||
.section-heading {
|
.section-heading {
|
||||||
font-family: "Fraunces", serif;
|
font-family: 'Fraunces', serif;
|
||||||
font-size: 2.8rem;
|
font-size: 2.8rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
@@ -742,7 +749,7 @@ section.full-width {
|
|||||||
font-size: 0.68rem;
|
font-size: 0.68rem;
|
||||||
letter-spacing: 0.04em;
|
letter-spacing: 0.04em;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-family: "JetBrains Mono", monospace;
|
font-family: 'JetBrains Mono', monospace;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
}
|
}
|
||||||
@@ -781,7 +788,7 @@ section.full-width {
|
|||||||
font-size: 0.72rem;
|
font-size: 0.72rem;
|
||||||
letter-spacing: 0.06em;
|
letter-spacing: 0.06em;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
font-family: "JetBrains Mono", monospace;
|
font-family: 'JetBrains Mono', monospace;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
}
|
}
|
||||||
@@ -810,7 +817,10 @@ section.full-width {
|
|||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
|
transition:
|
||||||
|
background 0.2s,
|
||||||
|
transform 0.2s,
|
||||||
|
box-shadow 0.2s;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
@@ -830,7 +840,7 @@ section.full-width {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.card::before {
|
.card::before {
|
||||||
content: "";
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -931,7 +941,6 @@ section.full-width {
|
|||||||
color: var(--mauve);
|
color: var(--mauve);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ─── Contact ──────────────────────────────────────────── */
|
/* ─── Contact ──────────────────────────────────────────── */
|
||||||
#contact {
|
#contact {
|
||||||
min-height: auto;
|
min-height: auto;
|
||||||
@@ -950,7 +959,7 @@ section.full-width {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.contact-inner h2 {
|
.contact-inner h2 {
|
||||||
font-family: "Fraunces", serif;
|
font-family: 'Fraunces', serif;
|
||||||
font-size: 2.4rem;
|
font-size: 2.4rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
@@ -1009,13 +1018,13 @@ section.full-width {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.contact-link-icon--github {
|
.contact-link-icon--github {
|
||||||
-webkit-mask-image: url("icons/github.svg");
|
-webkit-mask-image: url('icons/github.svg');
|
||||||
mask-image: url("icons/github.svg");
|
mask-image: url('icons/github.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-link-icon--linkedin {
|
.contact-link-icon--linkedin {
|
||||||
-webkit-mask-image: url("icons/linkedin.svg");
|
-webkit-mask-image: url('icons/linkedin.svg');
|
||||||
mask-image: url("icons/linkedin.svg");
|
mask-image: url('icons/linkedin.svg');
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-link-label {
|
.contact-link-label {
|
||||||
@@ -1062,7 +1071,8 @@ footer a:hover {
|
|||||||
.reveal {
|
.reveal {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: translateY(24px);
|
transform: translateY(24px);
|
||||||
transition: opacity 0.6s ease,
|
transition:
|
||||||
|
opacity 0.6s ease,
|
||||||
transform 0.6s ease;
|
transform 0.6s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user