delete corrupted files and start recovering sitegen.tsx

This commit is contained in:
chloe caruso 2025-06-07 01:24:32 -07:00
parent af60d1172f
commit a0d9b18b81
104 changed files with 3411 additions and 11272 deletions

View file

@ -1,10 +1,25 @@
// default
function isScope(node, parent) {
if ((0, _index.isBlockStatement)(node) && ((0, _index.isFunction)(parent) || (0, _index.isCatchClause)(parent))) {
return false;
}
if ((0, _index.isPattern)(node) && ((0, _index.isFunction)(parent) || (0, _index.isCatchClause)(parent))) {
return true;
}
return (0, _index.isScopable)(node);
// File System APIs
import { readFileSync, writeFileSync, readdirSync, statSync, existsSync, mkdirSync as nodeMkdirSync, rmSync } from 'node:fs';
import { readFile, writeFile, readdir, stat, mkdir as nodeMkdir, rm } from 'node:fs/promises';
// Re-export a mix of built-in Node.js sync+promise fs methods.
export {
readFileSync, writeFileSync, readdirSync, statSync, existsSync, rmSync ,
readFile, writeFile, readdir, stat, mkdir, rm
}
export function mkdir(dir: string) {
return nodeMkdir(dir, { recursive: true });
}
export function mkdirSync(dir: string) {
return nodeMkdirSync(dir, { recursive: true });
}
export async function writeMkdir(file: string, contents: Buffer | string) {
await mkdir(path.dirname(file));
return writeFile(file, contents);
}
import * as path from 'node:path';

View file

@ -1,8 +0,0 @@
.css text/css
.html text/html; charset=utf8
.jpeg image/jpeg
.jpg image/jpeg
.js text/javascript
.json application/json
.png image/png
.txt text/plain

View file

@ -1,11 +1,222 @@
// default
class Hub {
getCode() {}
getScope() {}
addHelper() {
throw new Error("Helpers are not supported by the default hub.");
}
buildError(node, msg, Error = TypeError) {
return new Error(msg);
}
// Sitegen! Clover's static site generator, built with love.
function main() {
return withSpinner({
text: "Recovering State",
successText: ({ elapsed }) =>
"sitegen! update in " + elapsed.toFixed(1) + "s",
failureText: () => "sitegen FAIL",
}, sitegen);
}
async function sitegen(status) {
const startTime = performance.now();
let root = path.resolve(import_meta.dirname, "../src");
const join = (...sub) => path.join(root, ...sub);
const incr = new Incremental();
const sections: Section[] =
require(path.join(root, "sections.ts")).siteSections;
const views = [];
const staticFiles = [];
let pages = [];
let scripts = [];
const backendFiles = [];
status.text = "Scanning Project";
for (const section of sections) {
const { root: sectionRoot } = section;
const sectionPath = (...sub) => path.join(sectionRoot, ...sub);
const rootPrefix = root === sectionRoot
? ""
: path.relative(root, sectionRoot) + "/";
const kinds = [
{
dir: sectionPath("pages"),
list: pages,
prefix: "/",
exclude: [".css", ".client.ts", ".client.tsx"],
},
{ dir: sectionPath("static"), list: staticFiles, prefix: "/", ext: true },
{ dir: sectionPath("scripts"), list: scripts, prefix: rootPrefix },
{ dir: sectionPath("views"), list: views, prefix: rootPrefix },
];
for (const { dir, list, prefix, exclude = [], ext = false } of kinds) {
const pages2 = fs.readDirRecOptional(dir);
page: for (const page of pages2) {
if (page.isDirectory()) continue;
for (const ext2 of exclude) {
if (page.name.endsWith(ext2)) continue page;
}
const file = path.relative(dir, page.parentPath + "/" + page.name);
const trim = ext
? file
: file.slice(0, -path.extname(file).length).replaceAll(".", "/");
let id = prefix + trim.replaceAll("\\", "/");
if (prefix === "/" && id.endsWith("/index")) {
id = id.slice(0, -"/index".length) || "/";
}
list.push({ id, file: path.join(page.parentPath, page.name) });
}
}
let backendFile = [
sectionPath("backend.ts"),
sectionPath("backend.tsx"),
].find((file) => fs.existsSync(file));
if (backendFile) backendFiles.push(backendFile);
}
scripts = scripts.filter(({ file }) => !file.match(/\.client\.[tj]sx?/));
const globalCssPath = join("global.css");
status.text = "Building";
const cssOnce = new OnceMap();
const cssQueue = new Queue({
name: "Bundle",
fn: ([, files, theme]) => css.bundleCssFiles(files, theme),
passive: true,
getItemText: ([id]) => id,
maxJobs: 2,
});
const ssrResults = [];
function loadSsrModule(page) {
require(page.file);
}
async function doSsrPage(page) {
const module2 = require(page.file);
const Page = module2.default;
if (!Page) {
throw new Error("Page is missing a 'default' export.");
}
const metadata = module2.meta;
if (!metadata) {
throw new Error("Page is missing 'meta' attribute with a title.");
}
const theme = {
bg: "#fff",
fg: "#050505",
primary: "#2e7dab",
...module2.theme,
};
const renderedMetaPromise = Promise.resolve(
typeof metadata === "function" ? metadata({ ssr: true }) : metadata,
).then((m) => meta.resolveAndRenderMetadata(m));
const cssImports = [globalCssPath, ...hot.getCssImports(page.file)];
const cssPromise = cssOnce.get(
cssImports.join(":") + JSON.stringify(theme),
() => cssQueue.add([page.id, cssImports, theme]),
);
const sitegenApi = sg.initRender();
const body = await (0, import_ssr.ssrAsync)(
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Page, {}),
{
sitegen: sitegenApi,
},
);
const inlineCss = await cssPromise;
const renderedMeta = await renderedMetaPromise;
if (!renderedMeta.includes("<title>")) {
throw new Error(
"Page is missing 'meta.title'. All pages need a title tag.",
);
}
ssrResults.push({
body,
head: renderedMeta,
inlineCss,
scriptFiles: Array.from(sitegenApi.scripts),
page,
});
}
const spinnerFormat = status.format;
status.format = () => "";
const moduleLoadQueue = new import_queue.Queue({
name: "Load Render Module",
fn: loadSSRModule,
getItemText,
maxJobs: 1,
});
moduleLoadQueue.addMany(pages);
await moduleLoadQueue.done({ method: "stop" });
const pageQueue = new import_queue.Queue({
name: "Render",
fn: doSsrPage,
getItemText,
maxJobs: 2,
});
pageQueue.addMany(pages);
await pageQueue.done({ method: "stop" });
status.format = spinnerFormat;
const referencedScripts = Array.from(
new Set(ssrResults.flatMap((r) => r.scriptFiles)),
);
const extraPublicScripts = scripts.map((entry) => entry.file);
const uniqueCount = new Set([
...referencedScripts,
...extraPublicScripts,
]).size;
status.text = `Bundle ${uniqueCount} Scripts`;
await bundle.bundleClientJavaScript(
referencedScripts,
extraPublicScripts,
incr,
);
async function doStaticFile(page) {
const body = await fs.readFile(page.file);
incr.putAsset({
srcId: "static:" + page.file,
key: page.id,
body,
});
}
const staticQueue = new import_queue.Queue({
name: "Load Static",
fn: doStaticFile,
getItemText,
maxJobs: 16,
});
status.format = () => "";
staticQueue.addMany(staticFiles);
await staticQueue.done({ method: "stop" });
status.format = spinnerFormat;
status.text = `Concat ${ssrResults.length} Pages`;
await Promise.all(
ssrResults.map(async ({ page, body, head, inlineCss, scriptFiles }) => {
const doc = wrapDocument({
body,
head,
inlineCss,
scripts: scriptFiles.map(
(id) =>
UNWRAP(
incr.out.script.get(
path.basename(id).replace(/\.client\.[jt]sx?$/, ""),
),
),
).map((x) => `{${x}}`).join(""),
});
incr.putAsset({
srcId: "page:" + page.file,
key: page.id,
body: doc,
headers: {
"Content-Type": "text/html",
},
});
}),
);
status.format = () => "";
status.text = ``;
await incr.wait();
status.format = spinnerFormat;
status.text = `Incremental Flush`;
incr.flush();
incr.serializeToDisk();
return { elapsed: (performance.now() - startTime) / 1e3 };
}
import type { Section } from "./sitegen-lib.ts";
import { OnceMap, Queue } from "./queue.ts";
import { Incremental } from "./incremental.ts";
import * as bundle from "./bundle.ts";
import * as css from "./css.ts";
import * as fs from './fs.ts';
import { withSpinner, Spinner } from "@paperclover/console/Spinner";

3174
package-lock.json generated

File diff suppressed because it is too large Load diff

12
repl.js
View file

@ -1,11 +1 @@
// default
(node, parent, grandparent) => {
switch (parent.type) {
case "MarkoTag":
return parent.var !== node;
case "MarkoTagBody":
return false;
default:
return originalIsReferenced(node, parent, grandparent);
}
}
// RIP

View file

@ -1,29 +0,0 @@
// default
function transpileNamespace(path, allowNamespaces) {
if (path.node.declare || path.node.id.type === "StringLiteral") {
path.remove();
return;
}
if (!allowNamespaces) {
throw path.get("id").buildCodeFrameError("Namespace not marked type-only declare." + " Non-declarative namespaces are only supported experimentally in Babel." + " To enable and review caveats see:" + " https://babeljs.io/docs/en/babel-plugin-transform-typescript");
}
const name = getFirstIdentifier(path.node.id).name;
const value = handleNested(path, path.node);
if (value === null) {
const program = path.findParent(p => p.isProgram());
(0, _globalTypes.registerGlobalType)(program.scope, name);
path.remove();
} else if (path.scope.hasOwnBinding(name)) {
path.replaceWith(value);
} else {
path.scope.registerDeclaration(path.replaceWithMultiple([getDeclaration(name), value])[0]);
}
}
// getFirstIdentifier
function getFirstIdentifier(node) {
if (_core.types.isIdentifier(node)) {
return node;
}
return getFirstIdentifier(node.left);
}

View file

@ -1,36 +0,0 @@
// beginHiddenCallStack
function beginHiddenCallStack(fn) {
if (!SUPPORTED) return fn;
return Object.defineProperty(function (...args) {
setupPrepareStackTrace();
return fn(...args);
}, "name", {
value: STOP_HIDING
});
}
// endHiddenCallStack
function endHiddenCallStack(fn) {
if (!SUPPORTED) return fn;
return Object.defineProperty(function (...args) {
return fn(...args);
}, "name", {
value: START_HIDING
});
}
// expectedError
function expectedError(error) {
if (!SUPPORTED) return;
expectedErrors.add(error);
return error;
}
// injectVirtualStackFrame
function injectVirtualStackFrame(error, filename) {
if (!SUPPORTED) return;
let frames = virtualFrames.get(error);
if (!frames) virtualFrames.set(error, frames = []);
frames.push(CallSite(filename));
return error;
}

View file

@ -1,91 +0,0 @@
// default
function* loadPrivatePartialConfig(inputOpts) {
if (inputOpts != null && (typeof inputOpts !== "object" || Array.isArray(inputOpts))) {
throw new Error("Babel options must be an object, null, or undefined");
}
const args = inputOpts ? (0, _options.validate)("arguments", inputOpts) : {};
const {
envName = (0, _environment.getEnv)(),
cwd = ".",
root: rootDir = ".",
rootMode = "root",
caller,
cloneInputAst = true
} = args;
const absoluteCwd = _path().resolve(cwd);
const absoluteRootDir = resolveRootMode(_path().resolve(absoluteCwd, rootDir), rootMode);
const filename = typeof args.filename === "string" ? _path().resolve(cwd, args.filename) : undefined;
const showConfigPath = yield* (0, _index.resolveShowConfigPath)(absoluteCwd);
const context = {
filename,
cwd: absoluteCwd,
root: absoluteRootDir,
envName,
caller,
showConfig: showConfigPath === filename
};
const configChain = yield* (0, _configChain.buildRootChain)(args, context);
if (!configChain) return null;
const merged = {
assumptions: {}
};
configChain.options.forEach(opts => {
(0, _util.mergeOptions)(merged, opts);
});
const options = Object.assign({}, merged, {
targets: (0, _resolveTargets.resolveTargets)(merged, absoluteRootDir),
cloneInputAst,
babelrc: false,
configFile: false,
browserslistConfigFile: false,
passPerPreset: false,
envName: context.envName,
cwd: context.cwd,
root: context.root,
rootMode: "root",
filename: typeof context.filename === "string" ? context.filename : undefined,
plugins: configChain.plugins.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)),
presets: configChain.presets.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor))
});
return {
options,
context,
fileHandling: configChain.fileHandling,
ignore: configChain.ignore,
babelrc: configChain.babelrc,
config: configChain.config,
files: configChain.files
};
}
// loadPartialConfig
function* loadPartialConfig(opts) {
let showIgnoredFiles = false;
if (typeof opts === "object" && opts !== null && !Array.isArray(opts)) {
var _opts = opts;
({
showIgnoredFiles
} = _opts);
opts = _objectWithoutPropertiesLoose(_opts, _excluded);
_opts;
}
const result = yield* loadPrivatePartialConfig(opts);
if (!result) return null;
const {
options,
babelrc,
ignore,
config,
fileHandling,
files
} = result;
if (fileHandling === "ignored" && !showIgnoredFiles) {
return null;
}
(options.plugins || []).forEach(item => {
if (item.value instanceof _plugin.default) {
throw new Error("Passing cached plugin instances is not supported in " + "babel.loadPartialConfig()");
}
});
return new PartialConfig(options, babelrc ? babelrc.filepath : undefined, ignore ? ignore.filepath : undefined, config ? config.filepath : undefined, fileHandling, files);
}

View file

@ -1,291 +0,0 @@
export function Speedbump() {
return (
<div class="panel last">
<div className="header">
an interlude
</div>
<div className="content file-view file-view-text speedbump">
<canvas
style="linear-gradient(45deg, #111318, #181f20)"
data-canvas="cotyledon"
>
</canvas>
<header>
<h1>cotyledon</h1>
</header>
<div id="captcha" style="display: none;">
<p style="max-width:480px">
please prove you're not a robot by selecting all of the images with
four-leaf clovers, until there are only regular clovers.
<noscript>
this will require javascript enabled on your computer to verify
the mouse clicks.
</noscript>
</p>
<div className="enter-container">
<div className="image-grid">
<button>
<img src="/captcha/image/1.jpeg" alt="a four-leaf clover" />
</button>
<button>
<img src="/captcha/image/2.jpeg" alt="a four-leaf clover" />
</button>
<button>
<img src="/captcha/image/3.jpeg" alt="a four-leaf clover" />
</button>
<button>
<img src="/captcha/image/4.jpeg" alt="a four-leaf clover" />
</button>
<button>
<img src="/captcha/image/5.jpeg" alt="a four-leaf clover" />
</button>
<button>
<img src="/captcha/image/6.jpeg" alt="a four-leaf clover" />
</button>
<button>
<img src="/captcha/image/7.jpeg" alt="a four-leaf clover" />
</button>
<button>
<img src="/captcha/image/8.jpeg" alt="a four-leaf clover" />
</button>
<button>
<img src="/captcha/image/9.jpeg" alt="a four-leaf clover" />
</button>
</div>
</div>
<div class="enter-container">
<button id="enter2">all done</button>
</div>
</div>
<div id="first">
<p>
this place is sacred, but dangerous. i have to keep visitors to an
absolute minimum; you'll get dust on all the artifacts.
</p>
<p>
by entering our museum, you agree not to use your camera. flash off
isn't enough; the bits and bytes are alergic even to a camera's
sensor
</p>
<p style="font-size:0.9rem;">
(in english: please do not store downloads after you're done viewing
them)
</p>
<div class="enter-container">
<button id="enter">break my boundaries</button>
</div>
</div>
</div>
</div>
);
}
export function Readme() {
return (
<div class="panel last">
<div className="header">
cotyledon
</div>
<div className="content file-view file-view-text">
<div style="max-width: 71ch;padding:3rem;font-family:rmo,monospace">
<p style="margin-top:0">
welcome to the archive. if this is your first time here, i recommend
starting in '<a href="/file/2017">2017</a>' and going
chronologically from there. however, there is truly no wrong way to
explore.
</p>
<p>
note that there is a blanket trigger warning for everything in this
archive: while there is nothing visually offensive, some portions of
the text and emotions conveyed through this may hit extremely hard.
you are warned.
</p>
<p>
all file dates are real. at least as real as i could figure out.
when i moved data across drives over my years, i accidentally had a
few points where i stamped over all the dates with the day that
moved the files. even fucked it up a final time in february 2025,
while in the process of unfucking things.
</p>
<p>
thankfully, my past self knew i'd want to assemble this kind of
site, and because of that they were crazy about storing the dates of
things inside of html, json/yaml files, and even in fucking
databases. i'm glad it was all stored though, but jeez what a nerd.
</p>
<p>
a few files were touched up for privacy, or otherwise re-encoded.
some of them i added extra metadata.
</p>
<p>
from the bottom of my heart: i hope you enjoy. it has been a
nightmare putting this all together. technically and emotionally
speaking. i'm glad we can put this all behind us, mark it as
completed, and get started with the good shit.
</p>
<p>
love,<br />clo
</p>
<br />
<p>
start here -&gt; <a href="/file/2017">2017</a>
</p>
</div>
</div>
</div>
);
}
export function ForEveryone() {
// deno-fmt-ignore
return <><div class="for_everyone">
<p>today is my 21st birthday. april 30th, 2025.</p>
<p>it's been nearly six months starting hormones.</p>
<p>sometimes i feel great,</p>
<p>sometimes i get dysphoria.</p>
<p>with the walls around me gone</p>
<p>that shit hits way harder than it did before.</p>
<p>ugh..</p>
<p>i'm glad the pain i felt is now explained,</p>
<p>but now rendered in high definition.</p>
<p>the smallest strands of hair on my face and belly act</p>
<p>as sharpened nails to pierce my soul.</p>
<p></p>
<p>it's all a pathway to better days; the sun had risen.</p>
<p>one little step at a time for both of us.</p>
<p>today i quit my job. free falling, it feels so weird.</p>
<p>like sky diving.</p>
<p>the only thing i feel is cold wind.</p>
<p>the only thing i see is everything,</p>
<p>and it's beautiful.</p>
<p>i have a month of falling before the parachute activates,</p>
<p>gonna spend as much time of it on art as i can.</p>
<p>that was, after all, my life plan:</p>
<p>i wanted to make art, all the time,</p>
<p>for everyone.</p>
<p></p>
<p>then you see what happened</p>
<p>to the world and the internet.</p>
<p>i never really got to live through that golden age,</p>
<p>it probably sucked back then too.</p>
<p>but now the big sites definitely stopped being fun.</p>
<p>they slide their cold hands up my body</p>
<p>and feel me around. it's unwelcoming, and</p>
<p>inconsiderate to how sensitive my skin is.</p>
<p>i'm so fucking glad i broke up with YouTube</p>
<p>and their devilish friends.</p>
<p>my NAS is at 5 / 24 TB</p>
<p>and probably wont fill for the next decade.</p>
<p></p>
<p>it took 2 months for me to notice my body changed.</p>
<p>that day was really nice, but it hurt a lot.</p>
<p>a sharp, satisfying pain in my chest gave me life.</p>
<p>learned new instincts for my arms</p>
<p>so they'd stop poking my new shape.</p>
<p>when i look at my face</p>
<p>it's like a different person.</p>
<p>she was the same as before, but completely new.</p>
<p>something changed</p>
<p>or i'm now used to seeing what makes me smile.</p>
<p>regardless, whatever i see in the mirror, i smile.</p>
<p>and, i don't hear that old name much anymore</p>
<p>aside from nightmares. and you'll never repeat it, ok?</p>
<p>okay.</p>
<p></p>
<p>been playing 'new canaan' by 'bill wurtz' on loop</p>
<p>in the background.</p>
<p>it kinda just feels right.</p>
<p>especially when that verse near the end comes on.</p>
<p></p>
<p>more people have been allowed to visit me.</p>
<p>my apartment used to be just for me,</p>
<p>but the more i felt like a person</p>
<p>the more i felt like having others over.</p>
<p>still have to decorate and clean it a little,</p>
<p>but it isn't a job to do alone.</p>
<p>we dragged a giant a rug across the city one day,</p>
<p>and it felt was like anything was possible.</p>
<p>sometimes i have ten people visit in a day,</p>
<p>or sometimes i focus my little eyes on just one.</p>
<p>i never really know what i want to do</p>
<p>until the time actually comes.</p>
<p></p>
{/* FILIP */}
<p>i think about the times i was by the water with you.</p>
<p>the sun setting warmly, icy air fell on our shoulders.</p>
{/* NATALIE */}
<p>and how we walked up to the top of that hill,</p>
<p>you picked up and disposed a nail on the ground,</p>
<p>walking the city thru places i've never been.</p>
{/* BEN */}
<p>or hiking through the park talking about compilers,</p>
<p>tiring me out until i'd fall asleep in your arms.</p>
{/* ELENA */}
<p>and the way you held on to my hand as i woke up,</p>
<p>noticing how i was trying to hide nightmare's tears.</p>
<p></p>
{/* HIGH SCHOOL */}
<p>i remember we were yelling lyrics loudly,</p>
<p>out of key yet cheered on because it was fun.</p>
{/* ADVAITH/NATALIE */}
<p>and when we all toured the big corporate office,</p>
{/* AYU/HARRIS */}
<p>then snuck in to some startup's office after hours;</p>
<p>i don't remember what movie we watched.</p>
{/* COLLEGE, DAY 1 IN EV's ROOM */}
<p>i remember laying on the bunk bed,</p>
<p>while the rest played a card game.</p>
{/* MEGHAN/MORE */}
<p>with us all laying on the rug, staring at the TV</p>
<p>as the ending twist to that show was revealed.</p>
<p></p>
<p>all the moments i cherish,</p>
<p>i love because it was always me.</p>
<p>i didn't have to pretend,</p>
<p>even if i didn't know who i was at the time.</p>
<p>you all were there. for me.</p>
<p></p>
<p>i don't want to pretend any more</p>
<p>i want to be myself. for everyone.</p>
<p></p>
<p>oh, the song ended. i thought it was on loop?</p>
<p>it's late... can hear the crickets...</p>
<p>and i can almost see the moon... mmmm...</p>
<p>...nah, too much light pollution.</p>
<p></p>
<p>one day. one day.</p>
<p></p>
<p class="normal">before i go, i want to show the uncensored version of "journal about a girl", because i can trust you at least. keep in mind, i think you're one of the first people to ever see this.</p>
</div>
<div class="for_everyone" style="max-width:80ch;">
<blockquote>
<p>journal - 2024-09-14</p>
<p>been at HackMIT today on behalf of the company. it's fun. me and zack were running around looking for people that might be good hires. he had this magic arbitrary criteria to tell "oh this person is probably cracked let's talk to them" and we go to the first one. they were a nerd, perfect. they seemed to be extremely talented with some extreme software projects.<br/>
okay.. oof... its still clouding my mind<br/>
i cant shake that feeling away</p>
<p>hold on...</p>
<p>at some point they open one of their profiles to navigate to some code, and it displays for a couple of seconds: "pronouns: she/they". i don't actually know anything about this person, but it was my perception that she is trans. their appearance, physique, and age felt similar to me, which tends makes people think you are male.</p>
<p>but... she was having fun being herself. being a legend of identity and of her skill in computer science. winning the physics major. making cool shit at the hackathon, and probably in life. my perception of her was the exact essence of who i myself wanted to be. i was jealous of her life.</p>
<p>i tried hard to avoid a breakdown. success. but i was feeling distant. the next hour or so was disorienting, trying not to think about it too hard. i think there was one possibly interesting person we talked to. i don't remember any of the other conversations. they were not important. but i couldn't think through them regardless.</p>
<p>later, i decided to read some of her code. i either have a huge dislike towards the Rust programming language and/or it was not high quality code. welp, so just is a person studying. my perception was just a perception, inaccurate but impacting. i know i need to become myself, whoever that is. otherwise, i'm just going to feel this shit at higher doses. i think about this every day, and the amount of time i feel being consumed by these problems only grows.</p>
<p>getting through it all is a lonely feeling. not because no one is around, but because i am isolated emotionally. i know other people hit these feelings, but we all are too afraid to speak up, and it's all lonely.</p>
<p>waiting on a reply from someone from healthcare. it'll be slow, but it will be okay.</p>
</blockquote>
</div>
<div class="for_everyone">
<p class="normal">
i've learned that even when i feel alone, it doesn't have to feel lonely. i know it's hard, dear. i know it's scary. but i promise it's possible. we're all in this together. struggling together. sacrificing together. we dedicate our lives to each you, and our art for everyone.
</p>
<p class="normal" style="font-size:2rem;color:#9C91FF;font-family:times,serif;font-style:italic">
and then we knew,<br/>
just like paper airplanes: that we could fly...
</p>
<br />
<p class="normal">
<a href="/" style='text-decoration:underline;text-underline-offset:0.2em;'>fin.</a>
</p>
</div>
</>
}
ForEveryone.class = "text";

View file

@ -1,40 +0,0 @@
// run
function* run(config, code, ast) {
const file = yield* (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code, ast);
const opts = file.opts;
try {
yield* transformFile(file, config.passes);
} catch (e) {
var _opts$filename;
e.message = `${(_opts$filename = opts.filename) != null ? _opts$filename : "unknown file"}: ${e.message}`;
if (!e.code) {
e.code = "BABEL_TRANSFORM_ERROR";
}
throw e;
}
let outputCode, outputMap;
try {
if (opts.code !== false) {
({
outputCode,
outputMap
} = (0, _generate.default)(config.passes, file));
}
} catch (e) {
var _opts$filename2;
e.message = `${(_opts$filename2 = opts.filename) != null ? _opts$filename2 : "unknown file"}: ${e.message}`;
if (!e.code) {
e.code = "BABEL_GENERATE_ERROR";
}
throw e;
}
return {
metadata: file.metadata,
options: opts,
ast: opts.ast === true ? file.ast : null,
code: outputCode === undefined ? null : outputCode,
map: outputMap === undefined ? null : outputMap,
sourceType: file.ast.program.sourceType,
externalDependencies: (0, _deepArray.flattenToSet)(config.externalDependencies)
};
}

View file

@ -1,44 +0,0 @@
// default
function normalizeOptions(config) {
const {
filename,
cwd,
filenameRelative = typeof filename === "string" ? _path().relative(cwd, filename) : "unknown",
sourceType = "module",
inputSourceMap,
sourceMaps = !!inputSourceMap,
sourceRoot = config.options.moduleRoot,
sourceFileName = _path().basename(filenameRelative),
comments = true,
compact = "auto"
} = config.options;
const opts = config.options;
const options = Object.assign({}, opts, {
parserOpts: Object.assign({
sourceType: _path().extname(filenameRelative) === ".mjs" ? "module" : sourceType,
sourceFileName: filename,
plugins: []
}, opts.parserOpts),
generatorOpts: Object.assign({
filename,
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
retainLines: opts.retainLines,
comments,
shouldPrintComment: opts.shouldPrintComment,
compact,
minified: opts.minified,
sourceMaps,
sourceRoot,
sourceFileName
}, opts.generatorOpts)
});
for (const plugins of config.passes) {
for (const plugin of plugins) {
if (plugin.manipulateOptions) {
plugin.manipulateOptions(options, options.parserOpts);
}
}
}
return options;
}

View file

@ -1,53 +0,0 @@
// default
function* normalizeFile(pluginPasses, options, code, ast) {
code = `${code || ""}`;
if (ast) {
if (ast.type === "Program") {
ast = file(ast, [], []);
} else if (ast.type !== "File") {
throw new Error("AST root must be a Program or File node");
}
if (options.cloneInputAst) {
ast = (0, _cloneDeep.default)(ast);
}
} else {
ast = yield* (0, _index.default)(pluginPasses, options, code);
}
let inputMap = null;
if (options.inputSourceMap !== false) {
if (typeof options.inputSourceMap === "object") {
inputMap = _convertSourceMap().fromObject(options.inputSourceMap);
}
if (!inputMap) {
const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);
if (lastComment) {
try {
inputMap = _convertSourceMap().fromComment("//" + lastComment);
} catch (err) {
{
debug("discarding unknown inline input sourcemap");
}
}
}
}
if (!inputMap) {
const lastComment = extractComments(EXTERNAL_SOURCEMAP_REGEX, ast);
if (typeof options.filename === "string" && lastComment) {
try {
const match = EXTERNAL_SOURCEMAP_REGEX.exec(lastComment);
const inputMapContent = _fs().readFileSync(_path().resolve(_path().dirname(options.filename), match[1]), "utf8");
inputMap = _convertSourceMap().fromJSON(inputMapContent);
} catch (err) {
debug("discarding unknown file input sourcemap", err);
}
} else if (lastComment) {
debug("discarding un-loadable file input sourcemap");
}
}
}
return new _file.default(options, {
code,
ast: ast,
inputMap
});
}

View file

@ -1,56 +0,0 @@
// default
function* parser(pluginPasses, {
parserOpts,
highlightCode = true,
filename = "unknown"
}, code) {
try {
const results = [];
for (const plugins of pluginPasses) {
for (const plugin of plugins) {
const {
parserOverride
} = plugin;
if (parserOverride) {
const ast = parserOverride(code, parserOpts, _parser().parse);
if (ast !== undefined) results.push(ast);
}
}
}
if (results.length === 0) {
return (0, _parser().parse)(code, parserOpts);
} else if (results.length === 1) {
yield* [];
if (typeof results[0].then === "function") {
throw new Error(`You appear to be using an async parser plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
}
return results[0];
}
throw new Error("More than one plugin attempted to override parsing.");
} catch (err) {
if (err.code === "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED") {
err.message += "\nConsider renaming the file to '.mjs', or setting sourceType:module " + "or sourceType:unambiguous in your Babel config for this file.";
}
const {
loc,
missingPlugin
} = err;
if (loc) {
const codeFrame = (0, _codeFrame().codeFrameColumns)(code, {
start: {
line: loc.line,
column: loc.column + 1
}
}, {
highlightCode
});
if (missingPlugin) {
err.message = `${filename}: ` + (0, _missingPluginHelper.default)(missingPlugin[0], loc, codeFrame, filename);
} else {
err.message = `${filename}: ${err.message}\n\n` + codeFrame;
}
err.code = "BABEL_PARSE_ERROR";
}
throw err;
}
}

View file

@ -1,33 +0,0 @@
// default
function generateMissingPluginMessage(missingPluginName, loc, codeFrame, filename) {
let helpMessage = `Support for the experimental syntax '${missingPluginName}' isn't currently enabled ` + `(${loc.line}:${loc.column + 1}):\n\n` + codeFrame;
const pluginInfo = pluginNameMap[missingPluginName];
if (pluginInfo) {
const {
syntax: syntaxPlugin,
transform: transformPlugin
} = pluginInfo;
if (syntaxPlugin) {
const syntaxPluginInfo = getNameURLCombination(syntaxPlugin);
if (transformPlugin) {
const transformPluginInfo = getNameURLCombination(transformPlugin);
const sectionType = transformPlugin.name.startsWith("@babel/plugin") ? "plugins" : "presets";
helpMessage += `\n\nAdd ${transformPluginInfo} to the '${sectionType}' section of your Babel config to enable transformation.
If you want to leave it as-is, add ${syntaxPluginInfo} to the 'plugins' section to enable parsing.`;
} else {
helpMessage += `\n\nAdd ${syntaxPluginInfo} to the 'plugins' section of your Babel config ` + `to enable parsing.`;
}
}
}
const msgFilename = filename === "unknown" ? "<name of the input file>" : filename;
helpMessage += `
If you already added the plugin for this syntax to your config, it's possible that your config \
isn't being loaded.
You can re-run Babel with the BABEL_SHOW_CONFIG_FOR environment variable to show the loaded \
configuration:
\tnpx cross-env BABEL_SHOW_CONFIG_FOR=${msgFilename} <your build command>
See https://babeljs.io/docs/configuration#print-effective-configs for more info.
`;
return helpMessage;
}

View file

@ -1,11 +0,0 @@
// default
function _default(value) {
if (typeof value !== "object") return value;
{
try {
return deepClone(value, new Map(), true);
} catch (_) {
return structuredClone(value);
}
}
}

View file

@ -1,61 +0,0 @@
// default
function generateCode(pluginPasses, file) {
const {
opts,
ast,
code,
inputMap
} = file;
const {
generatorOpts
} = opts;
generatorOpts.inputSourceMap = inputMap == null ? void 0 : inputMap.toObject();
const results = [];
for (const plugins of pluginPasses) {
for (const plugin of plugins) {
const {
generatorOverride
} = plugin;
if (generatorOverride) {
const result = generatorOverride(ast, generatorOpts, code, _generator().default);
if (result !== undefined) results.push(result);
}
}
}
let result;
if (results.length === 0) {
result = (0, _generator().default)(ast, generatorOpts, code);
} else if (results.length === 1) {
result = results[0];
if (typeof result.then === "function") {
throw new Error(`You appear to be using an async codegen plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`);
}
} else {
throw new Error("More than one plugin attempted to override codegen.");
}
let {
code: outputCode,
decodedMap: outputMap = result.map
} = result;
if (result.__mergedMap) {
outputMap = Object.assign({}, result.map);
} else {
if (outputMap) {
if (inputMap) {
outputMap = (0, _mergeMap.default)(inputMap.toObject(), outputMap, generatorOpts.sourceFileName);
} else {
outputMap = result.map;
}
}
}
if (opts.sourceMaps === "inline" || opts.sourceMaps === "both") {
outputCode += "\n" + _convertSourceMap().fromObject(outputMap).toComment();
}
if (opts.sourceMaps === "inline") {
outputMap = null;
}
return {
outputCode,
outputMap
};
}

View file

@ -1,17 +0,0 @@
// default
function mergeSourceMap(inputMap, map, sourceFileName) {
const source = sourceFileName.replace(/\\/g, "/");
let found = false;
const result = _remapping()(rootless(map), (s, ctx) => {
if (s === source && !found) {
found = true;
ctx.source = "";
return rootless(inputMap);
}
return null;
});
if (typeof inputMap.sourceRoot === "string") {
result.sourceRoot = inputMap.sourceRoot;
}
return Object.assign({}, result);
}

File diff suppressed because one or more lines are too long

View file

@ -1,33 +0,0 @@
// loadPlugin
function* loadPlugin(name, dirname) {
const {
filepath,
loader
} = resolvePlugin(name, dirname, yield* (0, _async.isAsync)());
const value = yield* requireModule("plugin", loader, filepath);
debug("Loaded plugin %o from %o.", name, dirname);
return {
filepath,
value
};
}
// loadPreset
function* loadPreset(name, dirname) {
const {
filepath,
loader
} = resolvePreset(name, dirname, yield* (0, _async.isAsync)());
const value = yield* requireModule("preset", loader, filepath);
debug("Loaded preset %o from %o.", name, dirname);
return {
filepath,
value
};
}
// resolvePlugin
function () { [native code] }
// resolvePreset
function () { [native code] }

View file

@ -1,52 +0,0 @@
// moduleResolve
function moduleResolve(specifier, base, conditions, preserveSymlinks) {
const protocol = base.protocol;
const isData = protocol === 'data:';
const isRemote = isData || protocol === 'http:' || protocol === 'https:';
let resolved;
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
try {
resolved = new (_url().URL)(specifier, base);
} catch (error_) {
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
error.cause = error_;
throw error;
}
} else if (protocol === 'file:' && specifier[0] === '#') {
resolved = packageImportsResolve(specifier, base, conditions);
} else {
try {
resolved = new (_url().URL)(specifier);
} catch (error_) {
if (isRemote && !_module().builtinModules.includes(specifier)) {
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
error.cause = error_;
throw error;
}
resolved = packageResolve(specifier, base, conditions);
}
}
_assert()(resolved !== undefined, 'expected to be defined');
if (resolved.protocol !== 'file:') {
return resolved;
}
return finalizeResolution(resolved, base, preserveSymlinks);
}
// resolve
function resolve(specifier, parent) {
if (!parent) {
throw new Error('Please pass `parent`: `import-meta-resolve` cannot ponyfill that');
}
try {
return defaultResolve(specifier, {
parentURL: parent
}).url;
} catch (error) {
const exception = error;
if ((exception.code === 'ERR_UNSUPPORTED_DIR_IMPORT' || exception.code === 'ERR_MODULE_NOT_FOUND') && typeof exception.url === 'string') {
return exception.url;
}
throw error;
}
}

View file

@ -1,28 +0,0 @@
// transform
function transform(code, optsOrCallback, maybeCallback) {
let opts;
let callback;
if (typeof optsOrCallback === "function") {
callback = optsOrCallback;
opts = undefined;
} else {
opts = optsOrCallback;
callback = maybeCallback;
}
if (callback === undefined) {
{
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.sync)(code, opts);
}
}
(0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.errback)(code, opts, callback);
}
// transformAsync
function transformAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.async)(...args);
}
// transformSync
function transformSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.sync)(...args);
}

View file

@ -1,28 +0,0 @@
// transformFromAst
function transformFromAst(ast, code, optsOrCallback, maybeCallback) {
let opts;
let callback;
if (typeof optsOrCallback === "function") {
callback = optsOrCallback;
opts = undefined;
} else {
opts = optsOrCallback;
callback = maybeCallback;
}
if (callback === undefined) {
{
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.sync)(ast, code, opts);
}
}
(0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.errback)(ast, code, opts, callback);
}
// transformFromAstAsync
function transformFromAstAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.async)(...args);
}
// transformFromAstSync
function transformFromAstSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.sync)(...args);
}

View file

@ -1,23 +0,0 @@
// parse
function parse(code, opts, callback) {
if (typeof opts === "function") {
callback = opts;
opts = undefined;
}
if (callback === undefined) {
{
return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.sync)(code, opts);
}
}
(0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.errback)(code, opts, callback);
}
// parseAsync
function parseAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.async)(...args);
}
// parseSync
function parseSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.sync)(...args);
}

View file

@ -1,10 +0,0 @@
// default
(api, options, dirname) => {
let clonedApi;
for (const name of Object.keys(apiPolyfills)) {
if (api[name]) continue;
clonedApi != null ? clonedApi : clonedApi = copyApiObject(api);
clonedApi[name] = apiPolyfills[name](clonedApi);
}
return builder(clonedApi != null ? clonedApi : api, options || {}, dirname);
}

View file

@ -1,25 +0,0 @@
// declare
function declare(builder) {
return (api, options, dirname) => {
let clonedApi;
for (const name of Object.keys(apiPolyfills)) {
if (api[name]) continue;
clonedApi != null ? clonedApi : clonedApi = copyApiObject(api);
clonedApi[name] = apiPolyfills[name](clonedApi);
}
return builder(clonedApi != null ? clonedApi : api, options || {}, dirname);
};
}
// declarePreset
function declare(builder) {
return (api, options, dirname) => {
let clonedApi;
for (const name of Object.keys(apiPolyfills)) {
if (api[name]) continue;
clonedApi != null ? clonedApi : clonedApi = copyApiObject(api);
clonedApi[name] = apiPolyfills[name](clonedApi);
}
return builder(clonedApi != null ? clonedApi : api, options || {}, dirname);
};
}

View file

@ -1,17 +0,0 @@
// default
(api, options, dirname) => {
let clonedApi;
for (const name of Object.keys(apiPolyfills)) {
if (api[name]) continue;
clonedApi != null ? clonedApi : clonedApi = copyApiObject(api);
clonedApi[name] = apiPolyfills[name](clonedApi);
}
return builder(clonedApi != null ? clonedApi : api, options || {}, dirname);
}
// defineCommonJSHook
function defineCommonJSHook(file, hook) {
let hooks = file.get(commonJSHooksKey);
if (!hooks) file.set(commonJSHooksKey, hooks = []);
hooks.push(hook);
}

View file

@ -1,200 +0,0 @@
// buildDynamicImport
function buildDynamicImport(node, deferToThen, wrapWithPromise, builder) {
const specifier = _core.types.isCallExpression(node) ? node.arguments[0] : node.source;
if (_core.types.isStringLiteral(specifier) || _core.types.isTemplateLiteral(specifier) && specifier.quasis.length === 0) {
if (deferToThen) {
return _core.template.expression.ast`
Promise.resolve().then(() => ${builder(specifier)})
`;
} else return builder(specifier);
}
const specifierToString = _core.types.isTemplateLiteral(specifier) ? _core.types.identifier("specifier") : _core.types.templateLiteral([_core.types.templateElement({
raw: ""
}), _core.types.templateElement({
raw: ""
})], [_core.types.identifier("specifier")]);
if (deferToThen) {
return _core.template.expression.ast`
(specifier =>
new Promise(r => r(${specifierToString}))
.then(s => ${builder(_core.types.identifier("s"))})
)(${specifier})
`;
} else if (wrapWithPromise) {
return _core.template.expression.ast`
(specifier =>
new Promise(r => r(${builder(specifierToString)}))
)(${specifier})
`;
} else {
return _core.template.expression.ast`
(specifier => ${builder(specifierToString)})(${specifier})
`;
}
}
// buildNamespaceInitStatements
function buildNamespaceInitStatements(metadata, sourceMetadata, constantReexports = false, wrapReference = Lazy.wrapReference) {
var _wrapReference;
const statements = [];
const srcNamespaceId = _core.types.identifier(sourceMetadata.name);
for (const localName of sourceMetadata.importsNamespace) {
if (localName === sourceMetadata.name) continue;
statements.push(_core.template.statement`var NAME = SOURCE;`({
NAME: localName,
SOURCE: _core.types.cloneNode(srcNamespaceId)
}));
}
const srcNamespace = (_wrapReference = wrapReference(srcNamespaceId, sourceMetadata.wrap)) != null ? _wrapReference : srcNamespaceId;
if (constantReexports) {
statements.push(...buildReexportsFromMeta(metadata, sourceMetadata, true, wrapReference));
}
for (const exportName of sourceMetadata.reexportNamespace) {
statements.push((!_core.types.isIdentifier(srcNamespace) ? _core.template.statement`
Object.defineProperty(EXPORTS, "NAME", {
enumerable: true,
get: function() {
return NAMESPACE;
}
});
` : _core.template.statement`EXPORTS.NAME = NAMESPACE;`)({
EXPORTS: metadata.exportName,
NAME: exportName,
NAMESPACE: _core.types.cloneNode(srcNamespace)
}));
}
if (sourceMetadata.reexportAll) {
const statement = buildNamespaceReexport(metadata, _core.types.cloneNode(srcNamespace), constantReexports);
statement.loc = sourceMetadata.reexportAll.loc;
statements.push(statement);
}
return statements;
}
// ensureStatementsHoisted
function ensureStatementsHoisted(statements) {
statements.forEach(header => {
header._blockHoist = 3;
});
}
// getModuleName
function getModuleName(rootOpts, pluginOpts) {
var _pluginOpts$moduleId, _pluginOpts$moduleIds, _pluginOpts$getModule, _pluginOpts$moduleRoo;
return originalGetModuleName(rootOpts, {
moduleId: (_pluginOpts$moduleId = pluginOpts.moduleId) != null ? _pluginOpts$moduleId : rootOpts.moduleId,
moduleIds: (_pluginOpts$moduleIds = pluginOpts.moduleIds) != null ? _pluginOpts$moduleIds : rootOpts.moduleIds,
getModuleId: (_pluginOpts$getModule = pluginOpts.getModuleId) != null ? _pluginOpts$getModule : rootOpts.getModuleId,
moduleRoot: (_pluginOpts$moduleRoo = pluginOpts.moduleRoot) != null ? _pluginOpts$moduleRoo : rootOpts.moduleRoot
});
}
// hasExports
function hasExports(metadata) {
return metadata.hasExports;
}
// isModule
function isModule(path) {
return path.node.sourceType === "module";
}
// isSideEffectImport
function isSideEffectImport(source) {
return source.imports.size === 0 && source.importsNamespace.size === 0 && source.reexports.size === 0 && source.reexportNamespace.size === 0 && !source.reexportAll;
}
// rewriteModuleStatementsAndPrepareHeader
function rewriteModuleStatementsAndPrepareHeader(path, {
exportName,
strict,
allowTopLevelThis,
strictMode,
noInterop,
importInterop = noInterop ? "none" : "babel",
lazy,
getWrapperPayload = Lazy.toGetWrapperPayload(lazy != null ? lazy : false),
wrapReference = Lazy.wrapReference,
esNamespaceOnly,
filename,
constantReexports = arguments[1].loose,
enumerableModuleMeta = arguments[1].loose,
noIncompleteNsImportDetection
}) {
(0, _normalizeAndLoadMetadata.validateImportInteropOption)(importInterop);
_assert((0, _helperModuleImports.isModule)(path), "Cannot process module statements in a script");
path.node.sourceType = "script";
const meta = (0, _normalizeAndLoadMetadata.default)(path, exportName, {
importInterop,
initializeReexports: constantReexports,
getWrapperPayload,
esNamespaceOnly,
filename
});
if (!allowTopLevelThis) {
(0, _rewriteThis.default)(path);
}
(0, _rewriteLiveReferences.default)(path, meta, wrapReference);
if (strictMode !== false) {
const hasStrict = path.node.directives.some(directive => {
return directive.value.value === "use strict";
});
if (!hasStrict) {
path.unshiftContainer("directives", _core.types.directive(_core.types.directiveLiteral("use strict")));
}
}
const headers = [];
if ((0, _normalizeAndLoadMetadata.hasExports)(meta) && !strict) {
headers.push(buildESModuleHeader(meta, enumerableModuleMeta));
}
const nameList = buildExportNameListDeclaration(path, meta);
if (nameList) {
meta.exportNameListName = nameList.name;
headers.push(nameList.statement);
}
headers.push(...buildExportInitializationStatements(path, meta, wrapReference, constantReexports, noIncompleteNsImportDetection));
return {
meta,
headers
};
}
// rewriteThis
function rewriteThis(programPath) {
if (!rewriteThisVisitor) {
rewriteThisVisitor = _traverse.visitors.environmentVisitor({
ThisExpression(path) {
path.replaceWith(_core.types.unaryExpression("void", _core.types.numericLiteral(0), true));
}
});
rewriteThisVisitor.noScope = true;
}
(0, _traverse.default)(programPath.node, rewriteThisVisitor);
}
// wrapInterop
function wrapInterop(programPath, expr, type) {
if (type === "none") {
return null;
}
if (type === "node-namespace") {
return _core.types.callExpression(programPath.hub.addHelper("interopRequireWildcard"), [expr, _core.types.booleanLiteral(true)]);
} else if (type === "node-default") {
return null;
}
let helper;
if (type === "default") {
helper = "interopRequireDefault";
} else if (type === "namespace") {
helper = "interopRequireWildcard";
} else {
throw new Error(`Unknown interop: ${type}`);
}
return _core.types.callExpression(programPath.hub.addHelper(helper), [expr]);
}
// getDynamicImportSource
function getDynamicImportSource(node) {
const [source] = node.arguments;
return _core.types.isStringLiteral(source) || _core.types.isTemplateLiteral(source) ? source : _core.template.expression.ast`\`\${${source}}\``;
}

View file

@ -1,463 +0,0 @@
".aac": "audio/x-aac",
".aif": "audio/x-aiff",
".aifc": "audio/x-aiff",
".aiff": "audio/x-aiff",
".apk": "application/vnd.android.package-archive",
".asm": "text/x-asm",
".bat": "application/x-msdownload",
".bmp": "image/bmp",
".c": "text/x-c",
".cc": "text/x-c",
".class": "application/java-vm",
".com": "application/x-msdownload",
".conf": "text/plain",
".cpp": "text/x-c",
".css": "text/css",
".cxx": "text/x-c",
".def": "text/plain",
".diff": "text/plain",
".dll": "application/x-msdownload",
".doc": "application/msword",
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
".epub": "application/epub+zip",
".exe": "application/x-msdownload",
".gif": "image/gif",
".gz": "application/x-gzip",
".h": "text/x-c",
".hh": "text/x-c",
".htm": "text/html;charset=utf-8",
".html": "text/html;charset=utf-8",
".ico": "image/x-icon",
".ics": "text/calendar",
".ifb": "text/calendar",
".iso": "application/octet-stream",
".jar": "application/java-archive",
".java": "text/x-java-source",
".jpe": "image/jpeg",
".jpeg": "image/jpeg",
".jpg": "image/jpeg",
".jpgv": "video/jpeg",
".js": "application/javascript",
".json": "application/json",
".latex": "application/x-latex",
".list": "text/plain",
".log": "text/plain",
".chat": "text/plain",
".m4a": "audio/mp4",
".mid": "audio/midi",
".midi": "audio/midi",
".mov": "video/quicktime",
".mp3": "audio/mpeg",
".mp4": "video/mp4",
".mp4a": "audio/mp4",
".mp4v": "video/mp4",
".mpa": "video/mpeg",
".mpe": "video/mpeg",
".mpeg": "video/mpeg",
".mpg": "video/mpeg",
".mpg4": "video/mp4",
".mpga": "audio/mpeg",
".mpkg": "application/vnd.apple.installer+xml",
".msi": "application/x-msdownload",
".nb": "application/mathematica",
".nc": "application/x-netcdf",
".ncx": "application/x-dtbncx+xml",
".ngdat": "application/vnd.nokia.n-gage.data",
".nlu": "application/vnd.neurolanguage.nlu",
".nml": "application/vnd.enliven",
".nnd": "application/vnd.noblenet-directory",
".nns": "application/vnd.noblenet-sealer",
".nnw": "application/vnd.noblenet-web",
".npx": "image/vnd.net-fpx",
".nsf": "application/vnd.lotus-notes",
".nws": "message/rfc822",
".o": "application/octet-stream",
".oa2": "application/vnd.fujitsu.oasys2",
".oa3": "application/vnd.fujitsu.oasys3",
".oas": "application/vnd.fujitsu.oasys",
".obd": "application/x-msbinder",
".obj": "application/octet-stream",
".oda": "application/oda",
".odb": "application/vnd.oasis.opendocument.database",
".odc": "application/vnd.oasis.opendocument.chart",
".odf": "application/vnd.oasis.opendocument.formula",
".odft": "application/vnd.oasis.opendocument.formula-template",
".odg": "application/vnd.oasis.opendocument.graphics",
".odi": "application/vnd.oasis.opendocument.image",
".odp": "application/vnd.oasis.opendocument.presentation",
".ods": "application/vnd.oasis.opendocument.spreadsheet",
".odt": "application/vnd.oasis.opendocument.text",
".oga": "audio/ogg",
".ogg": "audio/ogg",
".ogv": "video/ogg",
".ogx": "application/ogg",
".onepkg": "application/onenote",
".onetmp": "application/onenote",
".onetoc": "application/onenote",
".onetoc2": "application/onenote",
".opf": "application/oebps-package+xml",
".oprc": "application/vnd.palm",
".org": "application/vnd.lotus-organizer",
".osf": "application/vnd.yamaha.openscoreformat",
".osfpvg": "application/vnd.yamaha.openscoreformat.osfpvg+xml",
".otc": "application/vnd.oasis.opendocument.chart-template",
".otf": "application/x-font-otf",
".otg": "application/vnd.oasis.opendocument.graphics-template",
".oth": "application/vnd.oasis.opendocument.text-web",
".oti": "application/vnd.oasis.opendocument.image-template",
".otm": "application/vnd.oasis.opendocument.text-master",
".otp": "application/vnd.oasis.opendocument.presentation-template",
".ots": "application/vnd.oasis.opendocument.spreadsheet-template",
".ott": "application/vnd.oasis.opendocument.text-template",
".oxt": "application/vnd.openofficeorg.extension",
".p": "text/x-pascal",
".p10": "application/pkcs10",
".p12": "application/x-pkcs12",
".p7b": "application/x-pkcs7-certificates",
".p7c": "application/pkcs7-mime",
".p7m": "application/pkcs7-mime",
".p7r": "application/x-pkcs7-certreqresp",
".p7s": "application/pkcs7-signature",
".pas": "text/x-pascal",
".pbd": "application/vnd.powerbuilder6",
".pbm": "image/x-portable-bitmap",
".pcf": "application/x-font-pcf",
".pcl": "application/vnd.hp-pcl",
".pclxl": "application/vnd.hp-pclxl",
".pct": "image/x-pict",
".pcurl": "application/vnd.curl.pcurl",
".pcx": "image/x-pcx",
".pdb": "application/vnd.palm",
".pdf": "application/pdf",
".pfa": "application/x-font-type1",
".pfb": "application/x-font-type1",
".pfm": "application/x-font-type1",
".pfr": "application/font-tdpfr",
".pfx": "application/x-pkcs12",
".pgm": "image/x-portable-graymap",
".pgn": "application/x-chess-pgn",
".pgp": "application/pgp-encrypted",
".pic": "image/x-pict",
".pkg": "application/octet-stream",
".pki": "application/pkixcmp",
".pkipath": "application/pkix-pkipath",
".pl": "text/plain",
".plb": "application/vnd.3gpp.pic-bw-large",
".plc": "application/vnd.mobius.plc",
".plf": "application/vnd.pocketlearn",
".pls": "application/pls+xml",
".pml": "application/vnd.ctc-posml",
".png": "image/png",
".pnm": "image/x-portable-anymap",
".portpkg": "application/vnd.macports.portpkg",
".pot": "application/vnd.ms-powerpoint",
".potm": "application/vnd.ms-powerpoint.template.macroenabled.12",
".potx": "application/vnd.openxmlformats-officedocument.presentationml.template",
".ppa": "application/vnd.ms-powerpoint",
".ppam": "application/vnd.ms-powerpoint.addin.macroenabled.12",
".ppd": "application/vnd.cups-ppd",
".ppm": "image/x-portable-pixmap",
".pps": "application/vnd.ms-powerpoint",
".ppsm": "application/vnd.ms-powerpoint.slideshow.macroenabled.12",
".ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
".ppt": "application/vnd.ms-powerpoint",
".pptm": "application/vnd.ms-powerpoint.presentation.macroenabled.12",
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
".pqa": "application/vnd.palm",
".prc": "application/x-mobipocket-ebook",
".pre": "application/vnd.lotus-freelance",
".prf": "application/pics-rules",
".ps": "application/postscript",
".psb": "application/vnd.3gpp.pic-bw-small",
".psd": "image/vnd.adobe.photoshop",
".psf": "application/x-font-linux-psf",
".ptid": "application/vnd.pvi.ptid1",
".pub": "application/x-mspublisher",
".pvb": "application/vnd.3gpp.pic-bw-var",
".pwn": "application/vnd.3m.post-it-notes",
".pwz": "application/vnd.ms-powerpoint",
".py": "text/x-python",
".pya": "audio/vnd.ms-playready.media.pya",
".pyc": "application/x-python-code",
".pyo": "application/x-python-code",
".pyv": "video/vnd.ms-playready.media.pyv",
".qam": "application/vnd.epson.quickanime",
".qbo": "application/vnd.intu.qbo",
".qfx": "application/vnd.intu.qfx",
".qps": "application/vnd.publishare-delta-tree",
".qt": "video/quicktime",
".qwd": "application/vnd.quark.quarkxpress",
".qwt": "application/vnd.quark.quarkxpress",
".qxb": "application/vnd.quark.quarkxpress",
".qxd": "application/vnd.quark.quarkxpress",
".qxl": "application/vnd.quark.quarkxpress",
".qxt": "application/vnd.quark.quarkxpress",
".ra": "audio/x-pn-realaudio",
".ram": "audio/x-pn-realaudio",
".rar": "application/x-rar-compressed",
".ras": "image/x-cmu-raster",
".rcprofile": "application/vnd.ipunplugged.rcprofile",
".rdf": "application/rdf+xml",
".rdz": "application/vnd.data-vision.rdz",
".rep": "application/vnd.businessobjects",
".res": "application/x-dtbresource+xml",
".rgb": "image/x-rgb",
".rif": "application/reginfo+xml",
".rl": "application/resource-lists+xml",
".rlc": "image/vnd.fujixerox.edmics-rlc",
".rld": "application/resource-lists-diff+xml",
".rm": "application/vnd.rn-realmedia",
".rmi": "audio/midi",
".rmp": "audio/x-pn-realaudio-plugin",
".rms": "application/vnd.jcp.javame.midlet-rms",
".rnc": "application/relax-ng-compact-syntax",
".roff": "text/troff",
".rpm": "application/x-rpm",
".rpss": "application/vnd.nokia.radio-presets",
".rpst": "application/vnd.nokia.radio-preset",
".rq": "application/sparql-query",
".rs": "application/rls-services+xml",
".rsd": "application/rsd+xml",
".rss": "application/rss+xml",
".rtf": "application/rtf",
".rtx": "text/richtext",
".s": "text/x-asm",
".saf": "application/vnd.yamaha.smaf-audio",
".sbml": "application/sbml+xml",
".sc": "application/vnd.ibm.secure-container",
".scd": "application/x-msschedule",
".scm": "application/vnd.lotus-screencam",
".scq": "application/scvp-cv-request",
".scs": "application/scvp-cv-response",
".scurl": "text/vnd.curl.scurl",
".sda": "application/vnd.stardivision.draw",
".sdc": "application/vnd.stardivision.calc",
".sdd": "application/vnd.stardivision.impress",
".sdkd": "application/vnd.solent.sdkm+xml",
".sdkm": "application/vnd.solent.sdkm+xml",
".sdp": "application/sdp",
".sdw": "application/vnd.stardivision.writer",
".see": "application/vnd.seemail",
".seed": "application/vnd.fdsn.seed",
".sema": "application/vnd.sema",
".semd": "application/vnd.semd",
".semf": "application/vnd.semf",
".ser": "application/java-serialized-object",
".setpay": "application/set-payment-initiation",
".setreg": "application/set-registration-initiation",
".sfd-hdstx": "application/vnd.hydrostatix.sof-data",
".sfs": "application/vnd.spotfire.sfs",
".sgl": "application/vnd.stardivision.writer-global",
".sgm": "text/sgml",
".sgml": "text/sgml",
".sh": "application/x-sh",
".shar": "application/x-shar",
".shf": "application/shf+xml",
".si": "text/vnd.wap.si",
".sic": "application/vnd.wap.sic",
".sig": "application/pgp-signature",
".silo": "model/mesh",
".sis": "application/vnd.symbian.install",
".sisx": "application/vnd.symbian.install",
".sit": "application/x-stuffit",
".sitx": "application/x-stuffitx",
".skd": "application/vnd.koan",
".skm": "application/vnd.koan",
".skp": "application/vnd.koan",
".skt": "application/vnd.koan",
".sl": "text/vnd.wap.sl",
".slc": "application/vnd.wap.slc",
".sldm": "application/vnd.ms-powerpoint.slide.macroenabled.12",
".sldx": "application/vnd.openxmlformats-officedocument.presentationml.slide",
".slt": "application/vnd.epson.salt",
".smf": "application/vnd.stardivision.math",
".smi": "application/smil+xml",
".smil": "application/smil+xml",
".snd": "audio/basic",
".snf": "application/x-font-snf",
".so": "application/octet-stream",
".spc": "application/x-pkcs7-certificates",
".spf": "application/vnd.yamaha.smaf-phrase",
".spl": "application/x-futuresplash",
".spot": "text/vnd.in3d.spot",
".spp": "application/scvp-vp-response",
".spq": "application/scvp-vp-request",
".spx": "audio/ogg",
".src": "application/x-wais-source",
".srx": "application/sparql-results+xml",
".sse": "application/vnd.kodak-descriptor",
".ssf": "application/vnd.epson.ssf",
".ssml": "application/ssml+xml",
".stc": "application/vnd.sun.xml.calc.template",
".std": "application/vnd.sun.xml.draw.template",
".stf": "application/vnd.wt.stf",
".sti": "application/vnd.sun.xml.impress.template",
".stk": "application/hyperstudio",
".stl": "application/vnd.ms-pki.stl",
".str": "application/vnd.pg.format",
".stw": "application/vnd.sun.xml.writer.template",
".sus": "application/vnd.sus-calendar",
".susp": "application/vnd.sus-calendar",
".sv4cpio": "application/x-sv4cpio",
".sv4crc": "application/x-sv4crc",
".svd": "application/vnd.svd",
".svg": "image/svg+xml",
".svgz": "image/svg+xml",
".swa": "application/x-director",
".swf": "application/x-shockwave-flash",
".swi": "application/vnd.arastra.swi",
".sxc": "application/vnd.sun.xml.calc",
".sxd": "application/vnd.sun.xml.draw",
".sxg": "application/vnd.sun.xml.writer.global",
".sxi": "application/vnd.sun.xml.impress",
".sxm": "application/vnd.sun.xml.math",
".sxw": "application/vnd.sun.xml.writer",
".t": "text/troff",
".tao": "application/vnd.tao.intent-module-archive",
".tar": "application/x-tar",
".tcap": "application/vnd.3gpp2.tcap",
".tcl": "application/x-tcl",
".teacher": "application/vnd.smart.teacher",
".tex": "application/x-tex",
".texi": "application/x-texinfo",
".texinfo": "application/x-texinfo",
".text": "text/plain",
".tfm": "application/x-tex-tfm",
".tgz": "application/x-gzip",
".tif": "image/tiff",
".tiff": "image/tiff",
".tmo": "application/vnd.tmobile-livetv",
".torrent": "application/x-bittorrent",
".tpl": "application/vnd.groove-tool-template",
".tpt": "application/vnd.trid.tpt",
".tr": "text/troff",
".tra": "application/vnd.trueapp",
".trm": "application/x-msterminal",
".tsv": "text/tab-separated-values",
".ttc": "application/x-font-ttf",
".ttf": "application/x-font-ttf",
".twd": "application/vnd.simtech-mindmapper",
".twds": "application/vnd.simtech-mindmapper",
".txd": "application/vnd.genomatix.tuxedo",
".txf": "application/vnd.mobius.txf",
".txt": "text/plain",
".u32": "application/x-authorware-bin",
".udeb": "application/x-debian-package",
".ufd": "application/vnd.ufdl",
".ufdl": "application/vnd.ufdl",
".umj": "application/vnd.umajin",
".unityweb": "application/vnd.unity",
".uoml": "application/vnd.uoml+xml",
".uri": "text/uri-list",
".uris": "text/uri-list",
".urls": "text/uri-list",
".ustar": "application/x-ustar",
".utz": "application/vnd.uiq.theme",
".uu": "text/x-uuencode",
".vcd": "application/x-cdlink",
".vcf": "text/x-vcard",
".vcg": "application/vnd.groove-vcard",
".vcs": "text/x-vcalendar",
".vcx": "application/vnd.vcx",
".vis": "application/vnd.visionary",
".viv": "video/vnd.vivo",
".vor": "application/vnd.stardivision.writer",
".vox": "application/x-authorware-bin",
".vrml": "model/vrml",
".vsd": "application/vnd.visio",
".vsf": "application/vnd.vsf",
".vss": "application/vnd.visio",
".vst": "application/vnd.visio",
".vsw": "application/vnd.visio",
".vtu": "model/vnd.vtu",
".vxml": "application/voicexml+xml",
".w3d": "application/x-director",
".wad": "application/x-doom",
".wav": "audio/x-wav",
".wax": "audio/x-ms-wax",
".wbmp": "image/vnd.wap.wbmp",
".wbs": "application/vnd.criticaltools.wbs+xml",
".wbxml": "application/vnd.wap.wbxml",
".wcm": "application/vnd.ms-works",
".wdb": "application/vnd.ms-works",
".wiz": "application/msword",
".wks": "application/vnd.ms-works",
".wm": "video/x-ms-wm",
".wma": "audio/x-ms-wma",
".wmd": "application/x-ms-wmd",
".wmf": "application/x-msmetafile",
".wml": "text/vnd.wap.wml",
".wmlc": "application/vnd.wap.wmlc",
".wmls": "text/vnd.wap.wmlscript",
".wmlsc": "application/vnd.wap.wmlscriptc",
".wmv": "video/x-ms-wmv",
".wmx": "video/x-ms-wmx",
".wmz": "application/x-ms-wmz",
".wpd": "application/vnd.wordperfect",
".wpl": "application/vnd.ms-wpl",
".wps": "application/vnd.ms-works",
".wqd": "application/vnd.wqd",
".wri": "application/x-mswrite",
".wrl": "model/vrml",
".wsdl": "application/wsdl+xml",
".wspolicy": "application/wspolicy+xml",
".wtb": "application/vnd.webturbo",
".wvx": "video/x-ms-wvx",
".x32": "application/x-authorware-bin",
".x3d": "application/vnd.hzn-3d-crossword",
".xap": "application/x-silverlight-app",
".xar": "application/vnd.xara",
".xbap": "application/x-ms-xbap",
".xbd": "application/vnd.fujixerox.docuworks.binder",
".xbm": "image/x-xbitmap",
".xdm": "application/vnd.syncml.dm+xml",
".xdp": "application/vnd.adobe.xdp+xml",
".xdw": "application/vnd.fujixerox.docuworks",
".xenc": "application/xenc+xml",
".xer": "application/patch-ops-error+xml",
".xfdf": "application/vnd.adobe.xfdf",
".xfdl": "application/vnd.xfdl",
".xht": "application/xhtml+xml",
".xhtml": "application/xhtml+xml",
".xhvml": "application/xv+xml",
".xif": "image/vnd.xiff",
".xla": "application/vnd.ms-excel",
".xlam": "application/vnd.ms-excel.addin.macroenabled.12",
".xlb": "application/vnd.ms-excel",
".xlc": "application/vnd.ms-excel",
".xlm": "application/vnd.ms-excel",
".xls": "application/vnd.ms-excel",
".xlsb": "application/vnd.ms-excel.sheet.binary.macroenabled.12",
".xlsm": "application/vnd.ms-excel.sheet.macroenabled.12",
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
".xlt": "application/vnd.ms-excel",
".xltm": "application/vnd.ms-excel.template.macroenabled.12",
".xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
".xlw": "application/vnd.ms-excel",
".xml": "application/xml",
".xo": "application/vnd.olpc-sugar",
".xop": "application/xop+xml",
".xpdl": "application/xml",
".xpi": "application/x-xpinstall",
".xpm": "image/x-xpixmap",
".xpr": "application/vnd.is-xpr",
".xps": "application/vnd.ms-xpsdocument",
".xpw": "application/vnd.intercon.formnet",
".xpx": "application/vnd.intercon.formnet",
".xsl": "application/xml",
".xslt": "application/xslt+xml",
".xsm": "application/vnd.syncml+xml",
".xspf": "application/xspf+xml",
".xul": "application/vnd.mozilla.xul+xml",
".xvm": "application/xv+xml",
".xvml": "application/xv+xml",
".xwd": "image/x-xwindowdump",
".xyz": "chemical/x-xyz",
".zaz": "application/vnd.zzazz.deck+xml",
".zip": "application/zip",
".zir": "application/vnd.zul",
".zirz": "application/vnd.zul",
".zmm": "application/vnd.handheld-entertainment+xml"
}

View file

@ -1,55 +0,0 @@
const db = getDb("cache.sqlite");
db.table(
"blob_assets",
/* SQL */ `
create table blob_assets (
hash text primary key,
refs integer not null default 0
);
`,
);
/**
* Uncompressed files are read directly from the media store root. Compressed
* files are stored as `<compress store>/<first 2 chars of hash>/<hash>` Since
* multiple files can share the same hash, the number of references is tracked
* so that when a file is deleted, the compressed data is only removed when all
* references are gone.
*/
export class BlobAsset {
/** sha1 of the contents */
hash!: string;
refs!: number;
}
export namespace BlobAsset {
const getQuery = cache.prepare(/* SQL */ `
SELECT * FROM blob_assets WHERE hash = ?;
`).as(BlobAsset);
export function get(hash: string) {
return getQuery.get(hash);
}
const putOrIncrementQuery = cache.prepare(/* SQL */ `
INSERT INTO blob_assets (hash, refs) VALUES (?, 1)
ON CONFLICT(hash) DO UPDATE SET refs = refs + 1;
`);
export function putOrIncrement(hash: string) {
assert(hash.length === 40);
putOrIncrementQuery.get(hash);
return get(hash)!;
}
const decrementQuery = cache.prepare(/* SQL */ `
UPDATE blob_assets SET refs = refs - 1 WHERE hash = ? AND refs > 0;
`);
const deleteQuery = cache.prepare(/* SQL */ `
DELETE FROM blob_assets WHERE hash = ? AND refs <= 0;
`);
export function decrementOrDelete(hash: string) {
assert(hash.length === 40);
decrementQuery.run(hash);
return deleteQuery.run(hash).changes > 0;
}
}
import { getDb } from "#sqlite";

View file

@ -1,51 +0,0 @@
import { getDb } from "#database";
const db = getDb("cache.sqlite");
db.table(/* SQL */ `
CREATE TABLE IF NOT EXISTS permissions (
prefix TEXT PRIMARY KEY,
allow INTEGER NOT NULL
);
`);
export class FilePermissions {
prefix!: string;
/** Currently set to 1 always */
allow!: number;
// -- static ops --
static getByPrefix(filePath: string): number {
return (getByPrefixQuery.get(filePath))?.allow ?? 0;
}
static getExact(filePath: string): number {
return (getExactQuery.get(filePath))?.allow ?? 0;
}
static setPermissions(dirPath: string, level: number) {
if (level) {
insertQuery.run(dirPath, level);
} else {
deleteQuery.run(dirPath);
}
}
}
const getByPrefixQuery = db.prepare(/* SQL */ `
SELECT allow
FROM permissions
WHERE ? GLOB prefix || '*'
ORDER BY LENGTH(prefix) DESC
LIMIT 1;
`).type<FilePermissions>();
const getExactQuery = db.prepare(/* SQL */ `
SELECT allow FROM permissions WHERE ? == prefix
`).type<FilePermissions>();
const insertQuery = db.prepare(/* SQL */ `
REPLACE INTO permissions(prefix, allow) VALUES(?, ?);
`);
const deleteQuery = db.prepare(/* SQL */ `
DELETE FROM permissions WHERE prefix = ?;
`);

View file

@ -1,27 +0,0 @@
import { MediaFile } from "../db";
import { useInlineScript } from "../framework/page-resources";
import { Readme } from "../media/cotyledon";
import { MediaPanel } from "../pages-dynamic/file_viewer";
import "../media/files.css";
export const theme = {
bg: "#312652",
fg: "#f0f0ff",
primary: "#fabe32",
};
export default function CotyledonPage() {
useInlineScript("canvas_cotyledon");
useInlineScript("file_viewer");
return (
<div class="files ctld ctld-et">
<MediaPanel
file={MediaFile.getByPath("/")!}
isLast={false}
activeFilename={null}
hasCotyledonCookie
/>
<Readme />
</div>
);
}

View file

@ -1,43 +0,0 @@
// relativeImportPath
function relativeImportPath(from, to) {
let i = 0;
let sepPos = -1;
let prevSepPos = -1;
let prevPrevSepPos = -1;
const fromLen = from.length;
const commonLen = Math.min(to.length, fromLen);
for (; i < commonLen; i++) {
const curChar = to[i];
if (curChar !== from[i])
break;
if (curChar === import_path.sep) {
prevPrevSepPos = prevSepPos;
prevSepPos = sepPos;
sepPos = i;
}
}
if (sepPos !== -1) {
if (hasNms(to, sepPos)) {
return toPosix(stripNms(to, sepPos));
}
if (prevSepPos !== -1) {
if (prevPrevSepPos !== -1 && to[prevSepPos + 1] === "@") {
prevSepPos = prevPrevSepPos;
}
if (hasNms(to, prevSepPos)) {
return toPosix(stripNms(to, prevSepPos));
}
}
}
if (sepPos <= 0)
return toPosix(to);
let back = 0;
for (; i < fromLen; i++)
if (from[i] === import_path.sep)
back++;
if (back) {
return backSep.repeat(back) + toPosix(to.slice(sepPos + 1));
} else {
return `.${toPosix(to.slice(sepPos))}`;
}
}

View file

@ -1,284 +0,0 @@
// ImportInjector
class ImportInjector {
constructor(path, importedSource, opts) {
this._defaultOpts = {
importedSource: null,
importedType: "commonjs",
importedInterop: "babel",
importingInterop: "babel",
ensureLiveReference: false,
ensureNoContext: false,
importPosition: "before"
};
const programPath = path.find(p => p.isProgram());
this._programPath = programPath;
this._programScope = programPath.scope;
this._hub = programPath.hub;
this._defaultOpts = this._applyDefaults(importedSource, opts, true);
}
addDefault(importedSourceIn, opts) {
return this.addNamed("default", importedSourceIn, opts);
}
addNamed(importName, importedSourceIn, opts) {
_assert(typeof importName === "string");
return this._generateImport(this._applyDefaults(importedSourceIn, opts), importName);
}
addNamespace(importedSourceIn, opts) {
return this._generateImport(this._applyDefaults(importedSourceIn, opts), null);
}
addSideEffect(importedSourceIn, opts) {
return this._generateImport(this._applyDefaults(importedSourceIn, opts), void 0);
}
_applyDefaults(importedSource, opts, isInit = false) {
let newOpts;
if (typeof importedSource === "string") {
newOpts = Object.assign({}, this._defaultOpts, {
importedSource
}, opts);
} else {
_assert(!opts, "Unexpected secondary arguments.");
newOpts = Object.assign({}, this._defaultOpts, importedSource);
}
if (!isInit && opts) {
if (opts.nameHint !== undefined) newOpts.nameHint = opts.nameHint;
if (opts.blockHoist !== undefined) newOpts.blockHoist = opts.blockHoist;
}
return newOpts;
}
_generateImport(opts, importName) {
const isDefault = importName === "default";
const isNamed = !!importName && !isDefault;
const isNamespace = importName === null;
const {
importedSource,
importedType,
importedInterop,
importingInterop,
ensureLiveReference,
ensureNoContext,
nameHint,
importPosition,
blockHoist
} = opts;
let name = nameHint || importName;
const isMod = (0, _isModule.default)(this._programPath);
const isModuleForNode = isMod && importingInterop === "node";
const isModuleForBabel = isMod && importingInterop === "babel";
if (importPosition === "after" && !isMod) {
throw new Error(`"importPosition": "after" is only supported in modules`);
}
const builder = new _importBuilder.default(importedSource, this._programScope, this._hub);
if (importedType === "es6") {
if (!isModuleForNode && !isModuleForBabel) {
throw new Error("Cannot import an ES6 module from CommonJS");
}
builder.import();
if (isNamespace) {
builder.namespace(nameHint || importedSource);
} else if (isDefault || isNamed) {
builder.named(name, importName);
}
} else if (importedType !== "commonjs") {
throw new Error(`Unexpected interopType "${importedType}"`);
} else if (importedInterop === "babel") {
if (isModuleForNode) {
name = name !== "default" ? name : importedSource;
const es6Default = `${importedSource}$es6Default`;
builder.import();
if (isNamespace) {
builder.default(es6Default).var(name || importedSource).wildcardInterop();
} else if (isDefault) {
if (ensureLiveReference) {
builder.default(es6Default).var(name || importedSource).defaultInterop().read("default");
} else {
builder.default(es6Default).var(name).defaultInterop().prop(importName);
}
} else if (isNamed) {
builder.default(es6Default).read(importName);
}
} else if (isModuleForBabel) {
builder.import();
if (isNamespace) {
builder.namespace(name || importedSource);
} else if (isDefault || isNamed) {
builder.named(name, importName);
}
} else {
builder.require();
if (isNamespace) {
builder.var(name || importedSource).wildcardInterop();
} else if ((isDefault || isNamed) && ensureLiveReference) {
if (isDefault) {
name = name !== "default" ? name : importedSource;
builder.var(name).read(importName);
builder.defaultInterop();
} else {
builder.var(importedSource).read(importName);
}
} else if (isDefault) {
builder.var(name).defaultInterop().prop(importName);
} else if (isNamed) {
builder.var(name).prop(importName);
}
}
} else if (importedInterop === "compiled") {
if (isModuleForNode) {
builder.import();
if (isNamespace) {
builder.default(name || importedSource);
} else if (isDefault || isNamed) {
builder.default(importedSource).read(name);
}
} else if (isModuleForBabel) {
builder.import();
if (isNamespace) {
builder.namespace(name || importedSource);
} else if (isDefault || isNamed) {
builder.named(name, importName);
}
} else {
builder.require();
if (isNamespace) {
builder.var(name || importedSource);
} else if (isDefault || isNamed) {
if (ensureLiveReference) {
builder.var(importedSource).read(name);
} else {
builder.prop(importName).var(name);
}
}
}
} else if (importedInterop === "uncompiled") {
if (isDefault && ensureLiveReference) {
throw new Error("No live reference for commonjs default");
}
if (isModuleForNode) {
builder.import();
if (isNamespace) {
builder.default(name || importedSource);
} else if (isDefault) {
builder.default(name);
} else if (isNamed) {
builder.default(importedSource).read(name);
}
} else if (isModuleForBabel) {
builder.import();
if (isNamespace) {
builder.default(name || importedSource);
} else if (isDefault) {
builder.default(name);
} else if (isNamed) {
builder.named(name, importName);
}
} else {
builder.require();
if (isNamespace) {
builder.var(name || importedSource);
} else if (isDefault) {
builder.var(name);
} else if (isNamed) {
if (ensureLiveReference) {
builder.var(importedSource).read(name);
} else {
builder.var(name).prop(importName);
}
}
}
} else {
throw new Error(`Unknown importedInterop "${importedInterop}".`);
}
const {
statements,
resultName
} = builder.done();
this._insertStatements(statements, importPosition, blockHoist);
if ((isDefault || isNamed) && ensureNoContext && resultName.type !== "Identifier") {
return sequenceExpression([numericLiteral(0), resultName]);
}
return resultName;
}
_insertStatements(statements, importPosition = "before", blockHoist = 3) {
if (importPosition === "after") {
if (this._insertStatementsAfter(statements)) return;
} else {
if (this._insertStatementsBefore(statements, blockHoist)) return;
}
this._programPath.unshiftContainer("body", statements);
}
_insertStatementsBefore(statements, blockHoist) {
if (statements.length === 1 && isImportDeclaration(statements[0]) && isValueImport(statements[0])) {
const firstImportDecl = this._programPath.get("body").find(p => {
return p.isImportDeclaration() && isValueImport(p.node);
});
if ((firstImportDecl == null ? void 0 : firstImportDecl.node.source.value) === statements[0].source.value && maybeAppendImportSpecifiers(firstImportDecl.node, statements[0])) {
return true;
}
}
statements.forEach(node => {
node._blockHoist = blockHoist;
});
const targetPath = this._programPath.get("body").find(p => {
const val = p.node._blockHoist;
return Number.isFinite(val) && val < 4;
});
if (targetPath) {
targetPath.insertBefore(statements);
return true;
}
return false;
}
_insertStatementsAfter(statements) {
const statementsSet = new Set(statements);
const importDeclarations = new Map();
for (const statement of statements) {
if (isImportDeclaration(statement) && isValueImport(statement)) {
const source = statement.source.value;
if (!importDeclarations.has(source)) importDeclarations.set(source, []);
importDeclarations.get(source).push(statement);
}
}
let lastImportPath = null;
for (const bodyStmt of this._programPath.get("body")) {
if (bodyStmt.isImportDeclaration() && isValueImport(bodyStmt.node)) {
lastImportPath = bodyStmt;
const source = bodyStmt.node.source.value;
const newImports = importDeclarations.get(source);
if (!newImports) continue;
for (const decl of newImports) {
if (!statementsSet.has(decl)) continue;
if (maybeAppendImportSpecifiers(bodyStmt.node, decl)) {
statementsSet.delete(decl);
}
}
}
}
if (statementsSet.size === 0) return true;
if (lastImportPath) lastImportPath.insertAfter(Array.from(statementsSet));
return !!lastImportPath;
}
}
// addDefault
function addDefault(path, importedSource, opts) {
return new _importInjector.default(path).addDefault(importedSource, opts);
}
// addNamed
function addNamed(path, name, importedSource, opts) {
return new _importInjector.default(path).addNamed(name, importedSource, opts);
}
// addNamespace
function addNamespace(path, importedSource, opts) {
return new _importInjector.default(path).addNamespace(importedSource, opts);
}
// addSideEffect
function addSideEffect(path, importedSource, opts) {
return new _importInjector.default(path).addSideEffect(importedSource, opts);
}
// isModule
function isModule(path) {
return path.node.sourceType === "module";
}

File diff suppressed because it is too large Load diff

View file

@ -1,233 +0,0 @@
// Vibe coded with AI
(globalThis as any).canvas_2017 = function (canvas: HTMLCanvasElement) {
const isStandalone = canvas.getAttribute("data-standalone") === "true";
// Configuration interface for the checkerboard effect
interface CheckerboardConfig {
fps: number; // frames per second
color1: string; // first checkerboard color
color2: string; // second checkerboard color
opacity: number; // opacity of each checkerboard (0-1)
speedX1: number; // horizontal speed of first checkerboard (pixels per second)
speedY1: number; // vertical speed of first checkerboard (pixels per second)
speedX2: number; // horizontal speed of second checkerboard (pixels per second)
speedY2: number; // vertical speed of second checkerboard (pixels per second)
baseTileSize: number; // base size of checkerboard tiles
sizeVariation: number; // maximum variation in tile size (pixels)
sineFrequency1: number; // frequency of first sine wave for size variation
sineFrequency2: number; // frequency of second sine wave for size variation
sineOffset: number; // offset between the two sine waves (radians)
rotation: number; // rotation in degrees for the entire pattern
rotation2: number; // rotation in degrees for the entire pattern
}
// Default configuration
const config: CheckerboardConfig = {
fps: 30,
color1: "#1A1C17",
color2: "#1A1C17",
opacity: 0.3,
speedX1: -0.02, // moving left slowly
speedY1: -0.01, // moving up slowly
speedX2: -0.015, // moving left (slightly slower)
speedY2: 0.012, // moving down slowly
baseTileSize: 200,
sizeVariation: 1.5,
sineFrequency1: 0.0005,
sineFrequency2: 0.0008,
sineOffset: Math.PI / 2, // 90 degrees offset
rotation: 2, // 5 degree rotation
rotation2: -2, // 5 degree rotation
};
// Get the canvas context
const ctx = canvas.getContext("2d");
if (!ctx) {
console.error("Could not get canvas context");
return () => {};
}
// Make canvas transparent
if (isStandalone) {
canvas.style.backgroundColor = "#737D60";
} else {
canvas.style.backgroundColor = "transparent";
}
// Variables to track position and animation
let width = canvas.width;
let height = canvas.height;
let animationFrameId: number;
let lastFrameTime = 0;
const frameInterval = 1000 / config.fps;
// Position offsets for the two checkerboards (centered)
let offset1X = 0;
let offset1Y = 0;
let offset2X = 0;
let offset2Y = 0;
// Time variable for sine wave calculation
let time = 0;
// Convert rotation to radians
const rotationRad = (config.rotation * Math.PI) / 180;
const rotationRad2 = (config.rotation2 * Math.PI) / 180;
// Update canvas dimensions when resized
const updateDimensions = () => {
width = canvas.width = canvas.clientWidth;
height = canvas.height = canvas.clientHeight;
};
// Calculate the diagonal length of the canvas (to ensure rotation covers corners)
const calculateDiagonal = () => {
return Math.sqrt(width * width + height * height);
};
// Draw a single checkerboard pattern scaled from center with rotation
const drawCheckerboard = (
offsetX: number,
offsetY: number,
tileSize: number,
color1: string,
color2: string,
opacity: number,
rotationRad: number,
) => {
ctx.globalAlpha = opacity;
// Get the center of the viewport
const centerX = width / 2;
const centerY = height / 2;
// Save the current transformation state
ctx.save();
// Move to the center of the canvas, rotate, then move back
ctx.translate(centerX, centerY);
ctx.rotate(rotationRad);
// Calculate the number of tiles needed to cover the rotated canvas
// We need to use the diagonal length to ensure we cover the corners when rotated
const diagonal = calculateDiagonal();
const tilesX = Math.ceil(diagonal / tileSize) + 6; // Added extra tiles for rotation
const tilesY = Math.ceil(diagonal / tileSize) + 6;
// Calculate how many tiles fit from center to edge (in each direction)
const halfTilesX = Math.ceil(tilesX / 2);
const halfTilesY = Math.ceil(tilesY / 2);
// Adjust the offset to be relative to the center
// The modulo ensures the pattern repeats smoothly even with scaling
const adjustedOffsetX = offsetX % (tileSize * 2);
const adjustedOffsetY = offsetY % (tileSize * 2);
// Draw the checker pattern, centered on the viewport
for (let y = -halfTilesY; y <= halfTilesY; y++) {
for (let x = -halfTilesX; x <= halfTilesX; x++) {
// Determine if this tile should be colored (creating checker pattern)
// We add a large number to ensure (x+y) is always positive for the modulo
if ((x + y + 1000) % 2 === 0) {
ctx.fillStyle = color1;
} else {
ctx.fillStyle = color2;
}
// Calculate the position of this tile relative to the center
// The adjusted offset creates the movement effect
const posX = (x * tileSize) + adjustedOffsetX;
const posY = (y * tileSize) + adjustedOffsetY;
// Draw the tile
ctx.fillRect(
posX - tileSize / 2,
posY - tileSize / 2,
tileSize,
tileSize,
);
}
}
// Restore the transformation state
ctx.restore();
};
// Animation loop
const animate = (currentTime: number) => {
animationFrameId = requestAnimationFrame(animate);
// Control frame rate
if (currentTime - lastFrameTime < frameInterval) {
return;
}
// Calculate the time elapsed since the last frame
const dt = currentTime - lastFrameTime;
lastFrameTime = currentTime;
// Increment time for sine wave calculation
time += dt;
// Update the position offsets based on speed and elapsed time
offset1X += config.speedX1 * dt;
offset1Y += config.speedY1 * dt;
offset2X += config.speedX2 * dt;
offset2Y += config.speedY2 * dt;
// Calculate the tile sizes using sine waves
const tileSize1 = config.baseTileSize +
Math.sin(time * config.sineFrequency1) * config.sizeVariation;
const tileSize2 = config.baseTileSize +
Math.sin(time * config.sineFrequency2 + config.sineOffset) *
config.sizeVariation;
// Clear canvas
ctx.clearRect(0, 0, width, height);
// Draw the two checkerboards
drawCheckerboard(
offset1X,
offset1Y,
tileSize1,
config.color1,
"transparent",
config.opacity,
rotationRad,
);
drawCheckerboard(
offset2X,
offset2Y,
tileSize2,
config.color2,
"transparent",
config.opacity,
rotationRad2,
);
// Reset global alpha
ctx.globalAlpha = 1.0;
};
// Initialize the animation
const init = () => {
// Set up resize handler
globalThis.addEventListener("resize", updateDimensions);
// Initial setup
updateDimensions();
// Start animation
lastFrameTime = performance.now();
animationFrameId = requestAnimationFrame(animate);
};
// Start the animation
init();
// Return cleanup function
return () => {
globalThis.removeEventListener("resize", updateDimensions);
cancelAnimationFrame(animationFrameId);
};
};

View file

@ -1,431 +0,0 @@
// This canvas is based on the maze generation algo in Tanks. This was
// originally written in C++ as a single function in 2018, and was ported to TS
// by Chloe in 2025 for the cotyledon canvas.
//
// The main difference is that this version is a visualization, rather than the
// practical function. Instead of taking a millisecond, only 5 steps are
// performed per second, visualizing the whole ordeal. It also isn't a playable
// game, obviously.
//
// Ported with love because I care about my old self
// She deserves the world, but instead gave it to me.
(globalThis as any).canvas_2018 = function (canvas: HTMLCanvasElement) {
const isStandalone = canvas.getAttribute("data-standalone") === "true";
if (isStandalone) {
canvas.style.backgroundColor = "#27201E";
}
interface Cell {
down: boolean;
right: boolean;
visited: boolean;
cell_flash: number;
down_flash: number;
right_flash: number;
}
interface Pos {
x: number;
y: number;
/** Where the wall is relative to x, y. */
dir: "left" | "right" | "up" | "down";
}
interface Maze {
grid: Grid;
cursor: { x: number; y: number };
lastTick: number;
/* Pixels */
transform: number;
newCellsToVisit: Pos[];
randomWallBag: Cell[];
randomWallTarget: number;
renderOffset: { x: number; y: number };
done: boolean;
}
const hex = (color: number[]) =>
"#" + color.map((c) => c.toString(16).padStart(2, "0")).join("");
let cellSize: number;
let borderThickness: number;
const cellFlashModifier = isStandalone ? 0.4 : 0.2;
const color = isStandalone ? "#170d0b" : "#231C1A";
const bg = [0x27, 0x20, 0x1E];
const wallFlashColor = [0xFF, 0xA8, 0x7A];
const cellFlashColor = "#FFA87A";
const updateTime = 1000 / 7;
const randomWallBreakInterval = [6, 12]; // every 10 to 18 walls.
function randomBetween(min: number, max: number) {
return Math.round(
Math.random() * (max - min),
) + min;
}
function randomOf<T>(array: T[]): T {
return array[randomBetween(0, array.length - 1)];
}
function randomWallTarget() {
return randomBetween(
randomWallBreakInterval[0],
randomWallBreakInterval[1],
);
}
// Originally, this used a 2-dimensional array. However, I wanted to make sure
// that the grid could be infinitely sized. This grid constructs new cells on
// demand, as needed.
class Grid {
cells = new Map<number, Cell>();
cell({ x, y }: { x: number; y: number }) {
const k = ((x | 0) << 16) + (y | 0);
const { cells } = this;
let existing = this.cells.get(k);
if (!existing) {
existing = {
cell_flash: 0,
down: true,
down_flash: 0,
right: true,
right_flash: 0,
visited: false,
};
cells.set(k, existing);
}
return existing;
}
forAll(
renderOffset: { x: number; y: number },
width: number,
height: number,
cb: (cell: Cell, pos: { x: number; y: number }) => void,
) {
const { x: offsetX, y: offsetY } = renderOffset;
const startX = Math.floor(-offsetX / cellSize);
const startY = Math.floor(-offsetY / cellSize);
const endX = Math.ceil((width - offsetX) / cellSize);
const endY = Math.ceil((height - offsetY) / cellSize);
for (let x = startX; x <= endX; x++) {
for (let y = startY; y <= endY; y++) {
const cellX = offsetX + x * cellSize;
const cellY = offsetY + y * cellSize;
cb(this.cell({ x, y }), { x: cellX, y: cellY });
}
}
}
}
const ctx = canvas.getContext("2d")!;
if (!ctx) {
console.error("Could not get canvas context");
return () => {};
}
let width: number, height: number;
const updateDimensions = () => {
width = canvas.width = canvas.offsetWidth;
height = canvas.height = canvas.offsetHeight;
cellSize = 100;
borderThickness = 8;
};
updateDimensions();
setTimeout(() => {
updateDimensions();
}, 10);
let maze = initMaze();
let nextMaze: Maze | null = null;
let completeFade = 0;
function initMaze(): Maze {
return {
grid: new Grid(),
transform: 0,
cursor: {
x: randomBetween(0, Math.ceil(width / cellSize)),
y: randomBetween(0, Math.ceil(height / cellSize)),
},
lastTick: performance.now(),
randomWallBag: [],
randomWallTarget: randomWallTarget(),
newCellsToVisit: [],
renderOffset: { x: 0, y: 0 },
done: false,
};
}
function isOnScreen(maze: Maze, x: number, y: number) {
const { x: offsetX, y: offsetY } = maze.renderOffset;
const cellX = offsetX + x * cellSize;
const cellY = offsetY + y * cellSize;
return (
cellX + cellSize > 0 &&
cellX < width &&
cellY + cellSize > 0 &&
cellY < height
);
}
function tick(maze: Maze, other?: Maze) {
if (maze.done) return;
// The original maze algorithm broke down 4%-8% of random right facing
// walls, and 4%-8% of down facing walls. It did this at the end.
// To make this visual more interesting, two random walls will be broken
// down every 12-25 cell visits. This way, the main trail is always running.
if (maze.randomWallBag.length > maze.randomWallTarget) {
const down: Cell = randomOf(maze.randomWallBag);
const right: Cell = randomOf(maze.randomWallBag);
maze.randomWallBag.forEach((cell) =>
cell.cell_flash = Math.min(cell.cell_flash + 0.2, 1)
);
down.cell_flash = 1;
down.down = false;
down.down_flash = 1;
right.cell_flash = 1;
right.right = false;
right.right_flash = 1;
maze.randomWallBag = [];
maze.randomWallTarget = randomWallTarget();
return;
}
// The main algorithm was simple: Have a cursor position, and move it in a
// random direction that it had not seen before. Once it had run out of
// options, branch off of a previous location. Only visit each cell once.
//
// In this visualization, cells that are too far offscreen are softly
// treated as "visited", which is how the simulation always stays in frame.
const current = maze.grid.cell(maze.cursor);
current.visited = true;
current.cell_flash = 1;
maze.randomWallBag.push(current);
const adjacent = ([
{ x: maze.cursor.x + 1, y: maze.cursor.y, dir: "left" },
{ x: maze.cursor.x - 1, y: maze.cursor.y, dir: "right" },
{ x: maze.cursor.x, y: maze.cursor.y + 1, dir: "up" },
{ x: maze.cursor.x, y: maze.cursor.y - 1, dir: "down" },
] as Pos[]).filter((pos) =>
isOnScreen(maze, pos.x, pos.y) &&
maze.grid.cell(pos).visited === false
);
if (adjacent.length === 0) {
// move cursor to a random cell that has not been visited.
const cells = maze.newCellsToVisit.filter((pos) =>
isOnScreen(maze, pos.x, pos.y) &&
maze.grid.cell(pos).visited === false
);
if (cells.length === 0) {
maze.done = true;
return;
}
const continuePos = randomOf(cells);
breakWall(maze, continuePos, other);
maze.cursor = { x: continuePos.x, y: continuePos.y };
return;
}
// break a random wall
const toBreak = randomOf(adjacent);
breakWall(maze, toBreak, other);
maze.cursor = { x: toBreak.x, y: toBreak.y };
// add the other directions to the new cells to visit.
maze.newCellsToVisit.push(
...adjacent.filter((pos) => pos.dir !== toBreak.dir),
);
}
function breakWall(maze: Maze, pos: Pos, other?: Maze) {
if (pos.dir === "right") {
const cell = maze.grid.cell(pos);
cell.right = false;
cell.right_flash = 1;
if (other) cell.right = false;
} else if (pos.dir === "down") {
const cell = maze.grid.cell(pos);
cell.down = false;
cell.down_flash = 1;
if (other) cell.down = false;
} else if (pos.dir === "left") {
const cell = maze.grid.cell({ x: pos.x - 1, y: pos.y });
cell.right = false;
cell.right_flash = 1;
if (other) cell.right = false;
} else if (pos.dir === "up") {
const cell = maze.grid.cell({ x: pos.x, y: pos.y - 1 });
cell.down = false;
cell.down_flash = 1;
if (other) cell.down = false;
}
}
function renderOffset(maze: Maze) {
return { x: maze.transform, y: maze.transform };
}
let animationFrameId: number;
let last = performance.now();
let dt: number = 0;
function renderMazeBorders(maze: Maze, opacity: number) {
ctx.globalAlpha = opacity;
maze.grid.forAll(
maze.renderOffset,
width,
height,
(cell, { x: cellX, y: cellY }) => {
// Walls
if (cell.right) {
ctx.fillStyle = color;
ctx.fillRect(
cellX + cellSize - borderThickness / 2,
cellY - borderThickness / 2,
borderThickness,
cellSize + borderThickness,
);
}
if (cell.down) {
ctx.fillStyle = color;
ctx.fillRect(
cellX - borderThickness / 2,
cellY + cellSize - borderThickness / 2,
cellSize + borderThickness,
borderThickness,
);
}
},
);
ctx.globalAlpha = 1;
}
function renderCellFlash(maze: Maze) {
maze.grid.forAll(
maze.renderOffset,
width,
height,
(cell, { x: cellX, y: cellY }) => {
// Cell flash to show visiting path.
if (cell.cell_flash > 0) {
cell.cell_flash = Math.max(0, cell.cell_flash - dt / 1000);
ctx.fillStyle = cellFlashColor;
ctx.globalAlpha = cell.cell_flash * cellFlashModifier;
ctx.fillRect(cellX, cellY, cellSize, cellSize);
ctx.globalAlpha = 1;
}
},
);
}
function renderBorderFlash(maze: Maze) {
maze.grid.forAll(
maze.renderOffset,
width,
height,
(cell, { x: cellX, y: cellY }) => {
if (cell.right_flash == 0 && cell.down_flash == 0) {
return;
}
// Walls
const cellFlash = cell.cell_flash * cellFlashModifier;
if (cell.right_flash > 0) {
cell.right_flash = Math.max(0, cell.right_flash - dt / 500);
ctx.fillStyle = interpolateColor(
bg,
wallFlashColor,
Math.max(cell.right_flash, cellFlash),
);
if (cellFlash > cell.right_flash) {
ctx.globalAlpha = cell.right_flash / cellFlash;
}
ctx.fillRect(
cellX + cellSize - borderThickness / 2,
cellY + borderThickness / 2,
borderThickness,
cellSize - borderThickness,
);
ctx.globalAlpha = 1;
}
if (cell.down_flash > 0) {
if (cellFlash > cell.down_flash) {
ctx.globalAlpha = cell.down_flash / cellFlash;
}
cell.down_flash = Math.max(0, cell.down_flash - dt / 500);
ctx.fillStyle = interpolateColor(
bg,
wallFlashColor,
Math.max(cell.down_flash, cellFlash),
);
ctx.fillRect(
cellX + borderThickness / 2,
cellY + cellSize - borderThickness / 2,
cellSize - borderThickness,
borderThickness,
);
ctx.globalAlpha = 1;
}
},
);
}
function render() {
const now = performance.now();
dt = now - last;
maze.transform += dt * 0.005;
maze.renderOffset = renderOffset(maze);
if (!maze.done) {
if (now - maze.lastTick >= updateTime) {
tick(maze);
maze.lastTick = now;
if (maze.done) {
nextMaze = initMaze();
nextMaze.transform = (maze.transform % cellSize) - dt * 0.005;
nextMaze.lastTick = now;
completeFade = 0;
}
}
}
if (nextMaze) {
nextMaze.transform += dt * 0.005;
nextMaze.renderOffset = renderOffset(nextMaze);
if (!nextMaze.done && now - nextMaze.lastTick >= updateTime) {
tick(nextMaze, maze);
nextMaze.lastTick = now;
}
}
last = now;
ctx.clearRect(0, 0, width, height);
renderCellFlash(maze);
if (nextMaze) renderCellFlash(nextMaze);
renderMazeBorders(maze, 1);
if (nextMaze) {
renderMazeBorders(nextMaze, completeFade);
completeFade += dt / 3000;
if (completeFade >= 1) {
maze = nextMaze;
nextMaze = null;
}
}
renderBorderFlash(maze);
if (nextMaze) {
renderCellFlash(nextMaze);
renderBorderFlash(nextMaze);
}
animationFrameId = requestAnimationFrame(render);
}
function interpolateColor(start: number[], end: number[], t: number) {
return hex(start.map((s, i) => Math.round(s + (end[i] - s) * t)));
}
globalThis.addEventListener("resize", updateDimensions);
animationFrameId = requestAnimationFrame(render);
// cleanup function
return () => {
globalThis.removeEventListener("resize", updateDimensions);
cancelAnimationFrame(animationFrameId);
};
};

View file

@ -1,109 +0,0 @@
// __esModule
true
// assertAllowedAttributes
function assertAllowedAttributes(path, allowed) {
let i = 0;
for (const attr of path.node.attributes) {
if (attr.type === "MarkoSpreadAttribute") {
throw path.hub.buildError(
attr,
`Tag does not support spread attributes.`
);
} else if (!allowed.includes(attr.name)) {
throw path.hub.buildError(
attr,
`Tag does not support the \`${attr.name}\` attribute.`
);
}
i++;
}
}
// assertAttributesOrArgs
function assertAttributesOrArgs(path) {
const { node } = path;
const args = node.arguments;
if (args && args.length && (node.attributes.length > 0 || node.body.length)) {
const start = args[0].loc.start;
const end = args[args.length - 1].loc.end;
throw path.hub.buildError(
{ loc: { start, end } },
"Tag does not support arguments when attributes or body present."
);
}
}
// assertAttributesOrSingleArg
function assertAttributesOrSingleArg(path) {
assertAttributesOrArgs(path);
const args = path.node.arguments;
if (args && args.length > 1) {
const start = args[1].loc.start;
const end = args[args.length - 1].loc.end;
throw path.hub.buildError(
{ loc: { start, end } },
"Tag does not support multiple arguments."
);
}
}
// assertNoArgs
function assertNoArgs(path) {
const args = path.node.arguments;
if (args && args.length) {
const start = args[0].loc.start;
const end = args[args.length - 1].loc.end;
throw path.hub.buildError(
{ loc: { start, end } },
"Tag does not support arguments."
);
}
}
// assertNoAttributeTags
function assertNoAttributeTags(path) {
if (path.node.attributeTags.length) {
throw path.hub.buildError(
path.node.attributeTags[0],
"Tag not support nested attribute tags."
);
}
}
// assertNoAttributes
function assertNoAttributes(path) {
const { attributes } = path.node;
if (attributes.length) {
const start = attributes[0].loc.start;
const end = attributes[attributes.length - 1].loc.end;
throw path.hub.buildError(
{ loc: { start, end } },
"Tag does not support attributes."
);
}
}
// assertNoParams
function assertNoParams(path) {
const { params } = path.node.body;
if (params.length) {
const start = params[0].loc.start;
const end = params[params.length - 1].loc.end;
throw path.hub.buildError(
{ loc: { start, end } },
"Tag does not support parameters."
);
}
}
// assertNoVar
function assertNoVar(path) {
if (path.node.var) {
throw path.hub.buildError(
path.node.var,
"Tag does not support a variable."
);
}
}

View file

@ -1,197 +0,0 @@
// Vibe coded with AI
(globalThis as any).canvas_2020 = function (canvas: HTMLCanvasElement) {
const isStandalone = canvas.getAttribute("data-standalone") === "true";
// Rain effect with slanted lines
// Configuration interface for the rain effect
interface RainConfig {
fps: number; // frames per second
color: string; // color of rain particles
angle: number; // angle in degrees
particleDensity: number; // particles per 10000 pixels of canvas area
speed: number; // speed of particles (pixels per frame)
lineWidth: number; // thickness of rain lines
lineLength: number; // length of rain lines
}
// Rain particle interface
interface RainParticle {
x: number; // x position
y: number; // y position
}
// Default configuration
const config: RainConfig = {
fps: 16,
color: isStandalone ? "#00FEFB99" : "#081F24",
angle: -18,
particleDensity: 1,
speed: 400,
lineWidth: 8,
lineLength: 100,
};
// Get the canvas context
const ctx = canvas.getContext("2d");
if (!ctx) {
console.error("Could not get canvas context");
return () => {};
}
// Make canvas transparent
if (isStandalone) {
canvas.style.backgroundColor = "#0F252B";
} else {
canvas.style.backgroundColor = "transparent";
}
// Calculate canvas dimensions and update when resized
let width = canvas.width;
let height = canvas.height;
let particles: RainParticle[] = [];
let animationFrameId: number;
let lastFrameTime = 0;
const frameInterval = 1000 / config.fps;
// Calculate angle in radians
const angleRad = (config.angle * Math.PI) / 180;
// Update canvas dimensions and particle count when resized
const updateDimensions = () => {
width = canvas.width = canvas.offsetWidth;
height = canvas.height = canvas.offsetHeight;
// Calculate the canvas area in pixels
const canvasArea = width * height;
// Calculate target number of particles based on canvas area
const targetParticleCount = Math.floor(
(canvasArea / 10000) * config.particleDensity,
);
// Calculate buffer for horizontal offset due to slanted angle
const buffer = Math.abs(height * Math.tan(angleRad)) + config.lineLength;
// Adjust the particles array
if (particles.length < targetParticleCount) {
// Add more particles if needed
for (let i = particles.length; i < targetParticleCount; i++) {
particles.push(createParticle(true, buffer));
}
} else if (particles.length > targetParticleCount) {
// Remove excess particles
particles = particles.slice(0, targetParticleCount);
}
};
// Create a new particle
// Added initialDistribution parameter to distribute particles across the entire canvas at startup
const createParticle = (
initialDistribution = false,
buffer: number,
): RainParticle => {
// For initial distribution, place particles throughout the canvas
// Otherwise start them above the canvas
let x = Math.random() * (width + buffer * 2) - buffer;
let y;
if (initialDistribution) {
// Distribute across the entire canvas height for initial setup
y = Math.random() * (height + config.lineLength * 2) - config.lineLength;
} else {
// Start new particles from above the canvas with some randomization
y = -config.lineLength - (Math.random() * config.lineLength * 20);
}
return {
x,
y,
};
};
// Update particle positions
const updateParticles = () => {
// Calculate buffer for horizontal offset due to slanted angle
const buffer = Math.abs(height * Math.tan(angleRad)) + config.lineLength;
for (let i = 0; i < particles.length; i++) {
const p = particles[i];
// Update position based on speed and angle
p.x += Math.sin(angleRad) * config.speed;
p.y += Math.cos(angleRad) * config.speed;
// Reset particles that go offscreen - only determined by position
// Add extra buffer to ensure particles fully exit the visible area before resetting
if (
p.y > height + config.lineLength ||
p.x < -buffer ||
p.x > width + buffer
) {
particles[i] = createParticle(false, buffer);
}
}
};
// Draw particles
const drawParticles = () => {
// Clear canvas
ctx.clearRect(0, 0, width, height);
// Set drawing properties
ctx.strokeStyle = config.color;
ctx.lineWidth = config.lineWidth;
ctx.lineCap = "square";
// Draw each rain line
ctx.beginPath();
for (const p of particles) {
// Only draw particles that are either on screen or within a reasonable buffer
// This is for performance reasons - we don't need to draw particles far offscreen
if (p.y >= -config.lineLength * 2 && p.y <= height + config.lineLength) {
const endX = p.x + Math.sin(angleRad) * config.lineLength;
const endY = p.y + Math.cos(angleRad) * config.lineLength;
ctx.moveTo(p.x, p.y);
ctx.lineTo(endX, endY);
}
}
ctx.stroke();
};
// Animation loop
const animate = (currentTime: number) => {
animationFrameId = requestAnimationFrame(animate);
// Control frame rate
if (currentTime - lastFrameTime < frameInterval) {
return;
}
lastFrameTime = currentTime;
updateParticles();
drawParticles();
};
// Initialize the animation
const init = () => {
// Set up resize handler
globalThis.addEventListener("resize", updateDimensions);
// Initial setup
updateDimensions();
// Start animation
lastFrameTime = performance.now();
animationFrameId = requestAnimationFrame(animate);
};
// Start the animation
init();
// Return cleanup function
return () => {
globalThis.removeEventListener("resize", updateDimensions);
cancelAnimationFrame(animationFrameId);
};
};

View file

@ -1,783 +0,0 @@
// Vibe coded.
(globalThis as any).canvas_2021 = function (canvas: HTMLCanvasElement) {
const isStandalone = canvas.getAttribute("data-standalone") === "true";
// Constants for simulation
const PARTICLE_RADIUS = 4.5;
const PARTICLE_DENSITY = 0.004; // Particles per pixel
const MIN_SPEED = 0.05;
const MAX_SPEED = 6.0;
const FRICTION = 0.96;
const REPULSION_STRENGTH = 0.1;
const REPULSION_RADIUS = 50;
const FORCE_RADIUS = 400; // Increased radius
const FORCE_STRENGTH = 0.25;
const FORCE_FALLOFF_EXPONENT = 3; // Higher value = sharper falloff
const FORCE_SPACING = 10; // Pixels between force points
const MIN_FORCE_STRENGTH = 0.05; // Minimum force strength for very slow movements
const MAX_FORCE_STRENGTH = 0.4; // Maximum force strength for fast movements
const MIN_SPEED_THRESHOLD = 1; // Movement speed (px/frame) that produces minimum force
const MAX_SPEED_THRESHOLD = 20; // Movement speed that produces maximum force
const OVERSCAN_PIXELS = 250;
const CELL_SIZE = REPULSION_RADIUS; // For spatial hashing
let globalOpacity = 0;
if (isStandalone) {
canvas.style.backgroundColor = "#301D02";
} else {
canvas.style.backgroundColor = "transparent";
}
// Interfaces
interface Particle {
x: number;
y: number;
vx: number;
vy: number;
charge: number; // 0 to 1, affecting color
}
interface Force {
x: number;
y: number;
dx: number;
dy: number;
strength: number;
radius: number;
createdAt: number;
}
interface SpatialHash {
[key: string]: Particle[];
}
// State
let first = true;
let particles: Particle[] = [];
let forces: Force[] = [];
let width = canvas.width;
let height = canvas.height;
let targetParticleCount = 0;
let spatialHash: SpatialHash = {};
let ctx: CanvasRenderingContext2D | null = null;
let animationId: number | null = null;
let isRunning = false;
// Mouse tracking
let lastMousePosition: { x: number; y: number } | null = null;
// Track position of the last created force
let lastForcePosition: { x: number; y: number } | null = null;
// Keep track of previous canvas dimensions for resize logic
let previousWidth = 0;
let previousHeight = 0;
// Initialize and cleanup
function init(): void {
ctx = canvas.getContext("2d");
if (!ctx) return;
// Set canvas to full size
resizeCanvas();
// Event listeners
globalThis.addEventListener("resize", resizeCanvas);
document.addEventListener("mousemove", handleMouseMove);
// Start animation immediately
start();
}
function cleanup(): void {
// Stop the animation
stop();
// Remove event listeners
globalThis.removeEventListener("resize", resizeCanvas);
document.removeEventListener("mousemove", handleMouseMove);
// Clear arrays
particles = [];
forces = [];
spatialHash = {};
lastMousePosition = null;
lastForcePosition = null;
}
// Resize canvas and adjust particle count
function resizeCanvas(): void {
// Store previous dimensions
previousWidth = width;
previousHeight = height;
// Update to new dimensions
width = globalThis.innerWidth;
height = globalThis.innerHeight;
canvas.width = width;
canvas.height = height;
const oldTargetCount = targetParticleCount;
targetParticleCount = Math.floor(width * height * PARTICLE_DENSITY);
// Adjust particle count
if (targetParticleCount > oldTargetCount) {
// Add more particles if needed, but only in newly available space
addParticles(targetParticleCount - oldTargetCount, !first);
first = false;
}
// Note: Removal of excess particles happens naturally during update
}
// Handle mouse movement
function handleMouseMove(e: MouseEvent): void {
const rect = canvas.getBoundingClientRect();
const currentX = e.clientX - rect.left;
const currentY = e.clientY - rect.top;
// Initialize positions if this is the first movement
if (!lastMousePosition || !lastForcePosition) {
lastMousePosition = { x: currentX, y: currentY };
lastForcePosition = { x: currentX, y: currentY };
return;
}
// Store current mouse position
const mouseX = currentX;
const mouseY = currentY;
// Calculate vector from last mouse position to current
const dx = mouseX - lastMousePosition.x;
const dy = mouseY - lastMousePosition.y;
const distMoved = Math.sqrt(dx * dx + dy * dy);
// Skip if essentially no movement (avoids numerical issues)
if (distMoved < 0.1) {
return;
}
// Get the vector from the last force to the current mouse position
const forceDx = mouseX - lastForcePosition.x;
const forceDy = mouseY - lastForcePosition.y;
const forceDistance = Math.sqrt(forceDx * forceDx + forceDy * forceDy);
// Only create forces if we've moved far enough from the last force
if (forceDistance >= FORCE_SPACING) {
// Calculate the direction vector from last force to current mouse
let dirX = forceDx / forceDistance;
let dirY = forceDy / forceDistance;
// Calculate how many force points to create
const numPoints = Math.floor(forceDistance / FORCE_SPACING);
// Calculate movement speed based on the recent movement
const movementSpeed = distMoved; // Simple approximation of speed
// Scale force strength based on movement speed
let speedFactor;
if (movementSpeed <= MIN_SPEED_THRESHOLD) {
speedFactor = MIN_FORCE_STRENGTH;
} else if (movementSpeed >= MAX_SPEED_THRESHOLD) {
speedFactor = MAX_FORCE_STRENGTH;
} else {
// Linear interpolation between min and max
const t = (movementSpeed - MIN_SPEED_THRESHOLD) /
(MAX_SPEED_THRESHOLD - MIN_SPEED_THRESHOLD);
speedFactor = MIN_FORCE_STRENGTH +
t * (MAX_FORCE_STRENGTH - MIN_FORCE_STRENGTH);
}
// Store current force position to update incrementally
let currentForceX = lastForcePosition.x;
let currentForceY = lastForcePosition.y;
// Create evenly spaced force points along the path from last force to current mouse
for (let i = 0; i < numPoints; i++) {
// Calculate position for this force point
const t = (i + 1) / numPoints;
const fx = lastForcePosition.x + forceDx * t;
const fy = lastForcePosition.y + forceDy * t;
// Create force at this position with the direction vector
createForce(fx, fy, dirX, dirY, speedFactor);
// Update the last force position to this new force
currentForceX = fx;
currentForceY = fy;
}
// Update the last force position
lastForcePosition = { x: currentForceX, y: currentForceY };
}
// Always update the last mouse position
lastMousePosition = { x: mouseX, y: mouseY };
}
// Create a new force
function createForce(
x: number,
y: number,
dx: number,
dy: number,
strength = FORCE_STRENGTH,
): void {
forces.push({
x,
y,
dx,
dy,
strength,
radius: 1,
createdAt: Date.now(),
});
}
// Improved particle addition with fill strategy options
function addParticles(count: number, inNewAreaOnly: boolean = false): void {
// Determine available space
const minX = -OVERSCAN_PIXELS;
const maxX = width + OVERSCAN_PIXELS;
const minY = -OVERSCAN_PIXELS;
const maxY = height + OVERSCAN_PIXELS;
// Use a grid system that guarantees uniform spacing of particles
const gridSpacing = REPULSION_RADIUS * 0.8; // Slightly less than repulsion radius
const gridWidth = Math.ceil((maxX - minX) / gridSpacing);
const gridHeight = Math.ceil((maxY - minY) / gridSpacing);
// Track which grid cells are already occupied
const occupiedCells: Set<string> = new Set();
// Mark cells occupied by existing particles
for (const particle of particles) {
const cellX = Math.floor((particle.x - minX) / gridSpacing);
const cellY = Math.floor((particle.y - minY) / gridSpacing);
// Ensure cell coordinates are within valid range
if (cellX >= 0 && cellX < gridWidth && cellY >= 0 && cellY < gridHeight) {
occupiedCells.add(`${cellX},${cellY}`);
}
}
// Create arrays of all cells and filter by placement strategy
const allGridCells: { x: number; y: number }[] = [];
for (let cellY = 0; cellY < gridHeight; cellY++) {
for (let cellX = 0; cellX < gridWidth; cellX++) {
const cellKey = `${cellX},${cellY}`;
if (!occupiedCells.has(cellKey)) {
const posX = minX + (cellX + 0.5) * gridSpacing;
const posY = minY + (cellY + 0.5) * gridSpacing;
// For new area only placement, filter to expanded areas
if (inNewAreaOnly && previousWidth > 0 && previousHeight > 0) {
const expandedRight = width > previousWidth;
const expandedBottom = height > previousHeight;
const inNewRightArea = expandedRight && posX >= previousWidth &&
posX <= width;
const inNewBottomArea = expandedBottom && posY >= previousHeight &&
posY <= height;
if (inNewRightArea || inNewBottomArea) {
allGridCells.push({ x: cellX, y: cellY });
}
} else if (!inNewAreaOnly) {
// Standard placement - add all valid cells
allGridCells.push({ x: cellX, y: cellY });
}
}
}
}
if (allGridCells.length == 0) {
throw new Error("No cells available to place particles");
}
// We now have all grid cells that match our placement criteria
// If we need more particles than we have available cells, we need to adjust
// gridSpacing to fit more cells into the same space
if (count > allGridCells.length) {
// Retry with a smaller grid spacing
// Proportionally reduce the grid spacing to fit the required number of particles
const scaleFactor = Math.sqrt(allGridCells.length / count);
const newGridSpacing = gridSpacing * scaleFactor;
// Clear particles and try again with new spacing
// This is a recursive call, but with adjusted parameters that will fit
return addParticlesWithCustomSpacing(
count,
inNewAreaOnly,
newGridSpacing,
);
}
// Shuffle the available cells for random selection
shuffleArray(allGridCells);
// Take the number of cells we need
const cellsToUse = Math.min(count, allGridCells.length);
const selectedCells = allGridCells.slice(0, cellsToUse);
// Create particles in selected cells
for (const cell of selectedCells) {
// Add jitter within the cell for natural look
const jitterX = (Math.random() - 0.5) * gridSpacing * 0.8;
const jitterY = (Math.random() - 0.5) * gridSpacing * 0.8;
// Calculate final position
const x = minX + (cell.x + 0.5) * gridSpacing + jitterX;
const y = minY + (cell.y + 0.5) * gridSpacing + jitterY;
// Create a particle at this position
particles.push(createParticle(x, y));
}
}
// Helper function to add particles with custom grid spacing
function addParticlesWithCustomSpacing(
count: number,
inNewAreaOnly: boolean,
gridSpacing: number,
): void {
if (gridSpacing == 0) throw new Error("Grid spacing is 0");
// Determine available space
const minX = -OVERSCAN_PIXELS;
const maxX = width + OVERSCAN_PIXELS;
const minY = -OVERSCAN_PIXELS;
const maxY = height + OVERSCAN_PIXELS;
// Create grid using the custom spacing
const gridWidth = Math.ceil((maxX - minX) / gridSpacing);
const gridHeight = Math.ceil((maxY - minY) / gridSpacing);
// Track which grid cells are already occupied
const occupiedCells: Set<string> = new Set();
// Mark cells occupied by existing particles
for (const particle of particles) {
const cellX = Math.floor((particle.x - minX) / gridSpacing);
const cellY = Math.floor((particle.y - minY) / gridSpacing);
// Ensure cell coordinates are within valid range
if (cellX >= 0 && cellX < gridWidth && cellY >= 0 && cellY < gridHeight) {
occupiedCells.add(`${cellX},${cellY}`);
}
}
// Create arrays of all cells and filter by placement strategy
const allGridCells: { x: number; y: number }[] = [];
for (let cellY = 0; cellY < gridHeight; cellY++) {
for (let cellX = 0; cellX < gridWidth; cellX++) {
const cellKey = `${cellX},${cellY}`;
if (!occupiedCells.has(cellKey)) {
const posX = minX + (cellX + 0.5) * gridSpacing;
const posY = minY + (cellY + 0.5) * gridSpacing;
// For new area only placement, filter to expanded areas
if (inNewAreaOnly && previousWidth > 0 && previousHeight > 0) {
const expandedRight = width > previousWidth;
const expandedBottom = height > previousHeight;
const inNewRightArea = expandedRight && posX >= previousWidth &&
posX <= width;
const inNewBottomArea = expandedBottom && posY >= previousHeight &&
posY <= height;
if (inNewRightArea || inNewBottomArea) {
allGridCells.push({ x: cellX, y: cellY });
}
} else if (!inNewAreaOnly) {
// Standard placement - add all valid cells
allGridCells.push({ x: cellX, y: cellY });
}
}
}
}
// Shuffle the available cells for random distribution
shuffleArray(allGridCells);
// Take the number of cells we need (or all if we have fewer)
const cellsToUse = Math.min(count, allGridCells.length);
// Create particles in selected cells
for (let i = 0; i < cellsToUse; i++) {
const cell = allGridCells[i];
// Add jitter within the cell
const jitterX = (Math.random() - 0.5) * gridSpacing * 0.8;
const jitterY = (Math.random() - 0.5) * gridSpacing * 0.8;
// Calculate final position
const x = minX + (cell.x + 0.5) * gridSpacing + jitterX;
const y = minY + (cell.y + 0.5) * gridSpacing + jitterY;
// Create a particle at this position
particles.push(createParticle(x, y));
}
}
// Utility to shuffle an array (Fisher-Yates algorithm)
function shuffleArray<T>(array: T[]): void {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
// Simplified createParticle function that just places at a specific position
function createParticle(x: number, y: number): Particle {
return {
x: x + (Math.random() * 4 - 2),
y: y + (Math.random() * 4 - 2),
vx: 0,
vy: 0,
charge: 0,
};
}
// Function to create a particle on one of the edges
function createParticleOnEdge(): Particle {
// Overscan bounds with fixed pixel size
const minX = -OVERSCAN_PIXELS;
const maxX = width + OVERSCAN_PIXELS;
const minY = -OVERSCAN_PIXELS;
const maxY = height + OVERSCAN_PIXELS;
let x: number, y: number;
// Place on one of the edges
const edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0: // Top
x = minX + Math.random() * (maxX - minX);
y = minY;
break;
case 1: // Right
x = maxX;
y = minY + Math.random() * (maxY - minY);
break;
case 2: // Bottom
x = minX + Math.random() * (maxX - minX);
y = maxY;
break;
case 3: // Left
x = minX;
y = minY + Math.random() * (maxY - minY);
break;
default:
x = minX + Math.random() * (maxX - minX);
y = minY + Math.random() * (maxY - minY);
}
return createParticle(x, y);
}
// Spatial hashing functions
function getHashKey(x: number, y: number): string {
const cellX = Math.floor(x / CELL_SIZE);
const cellY = Math.floor(y / CELL_SIZE);
return `${cellX},${cellY}`;
}
function addToSpatialHash(particle: Particle): void {
const key = getHashKey(particle.x, particle.y);
if (!spatialHash[key]) {
spatialHash[key] = [];
}
spatialHash[key].push(particle);
}
function updateSpatialHash(): void {
// Clear previous hash
spatialHash = {};
// Add all particles to hash
for (const particle of particles) {
addToSpatialHash(particle);
}
}
function getNearbyParticles(
x: number,
y: number,
radius: number,
): Particle[] {
const result: Particle[] = [];
const cellRadius = Math.ceil(radius / CELL_SIZE);
const centerCellX = Math.floor(x / CELL_SIZE);
const centerCellY = Math.floor(y / CELL_SIZE);
for (
let cellX = centerCellX - cellRadius;
cellX <= centerCellX + cellRadius;
cellX++
) {
for (
let cellY = centerCellY - cellRadius;
cellY <= centerCellY + cellRadius;
cellY++
) {
const key = `${cellX},${cellY}`;
const cell = spatialHash[key];
if (cell) {
result.push(...cell);
}
}
}
return result;
}
// Main update function
function update(): void {
const now = Date.now();
// Fixed pixel overscan
const minX = -OVERSCAN_PIXELS;
const maxX = width + OVERSCAN_PIXELS;
const minY = -OVERSCAN_PIXELS;
const maxY = height + OVERSCAN_PIXELS;
// Update spatial hash
updateSpatialHash();
// Update forces and remove expired ones
if (forces.length > 40) {
forces = forces.slice(-40);
}
forces = forces.filter((force) => {
force.strength *= 0.95;
force.radius *= 0.95;
return force.strength > 0.001;
});
// Update particles
const newParticles: Particle[] = [];
for (const particle of particles) {
// Apply forces
for (const force of forces) {
const dx = particle.x - force.x;
const dy = particle.y - force.y;
const distSq = dx * dx + dy * dy;
const radius = force.radius * FORCE_RADIUS;
if (distSq < radius * radius) {
const dist = Math.sqrt(distSq);
// Exponential falloff - much more concentrated at center
// (1 - x/R)^n where n controls how sharp the falloff is
const normalizedDist = dist / radius;
const factor = Math.pow(1 - normalizedDist, FORCE_FALLOFF_EXPONENT);
// Calculate force line projection for directional effect
// This makes particles along the force's path experience stronger effect
const dotProduct = (dx * -force.dx) + (dy * -force.dy);
const projectionFactor = Math.max(0, dotProduct / dist);
// Apply the combined factors - stronger directional bias
const finalFactor = factor * force.strength *
(0.1 + 0.9 * projectionFactor);
particle.vx += force.dx * finalFactor;
particle.vy += force.dy * finalFactor;
// charge for the first 100ms
if ((now - force.createdAt) < 100) {
particle.charge = Math.min(
1,
particle.charge + (finalFactor * finalFactor) * 0.2,
);
}
}
}
// Apply repulsion from nearby particles
const nearby = getNearbyParticles(
particle.x,
particle.y,
REPULSION_RADIUS,
);
for (const other of nearby) {
if (other === particle) continue;
const dx = particle.x - other.x;
const dy = particle.y - other.y;
const distSq = dx * dx + dy * dy;
if (distSq < REPULSION_RADIUS * REPULSION_RADIUS && distSq > 0) {
const dist = Math.sqrt(distSq);
const factor = REPULSION_STRENGTH * (1 - dist / REPULSION_RADIUS);
const fx = dx / dist * factor;
const fy = dy / dist * factor;
particle.vx += fx;
particle.vy += fy;
}
}
// Apply friction
particle.vx *= FRICTION;
particle.vy *= FRICTION;
// Ensure minimum speed
const speed = Math.sqrt(
particle.vx * particle.vx + particle.vy * particle.vy,
);
if (speed < MIN_SPEED && speed > 0) {
const scale = MIN_SPEED / speed;
particle.vx *= scale;
particle.vy *= scale;
}
// Cap at maximum speed
if (speed > MAX_SPEED) {
const scale = MAX_SPEED / speed;
particle.vx *= scale;
particle.vy *= scale;
}
// Update position
particle.x += particle.vx;
particle.y += particle.vy;
// Decrease charge
particle.charge *= 0.99;
// Check if particle is within extended bounds
if (
particle.x >= minX && particle.x <= maxX &&
particle.y >= minY && particle.y <= maxY
) {
// If outside screen but within overscan, keep it if we need more particles
if (
(particle.x < 0 || particle.x > width ||
particle.y < 0 || particle.y > height) &&
newParticles.length >= targetParticleCount
) {
continue;
}
newParticles.push(particle);
} else {
// Out of bounds, respawn if needed
if (newParticles.length < targetParticleCount) {
newParticles.push(createParticleOnEdge());
}
}
}
// Add more particles if needed
while (newParticles.length < targetParticleCount) {
newParticles.push(createParticleOnEdge());
}
particles = newParticles;
}
// Render function
const mul = isStandalone ? 0.9 : 0.5;
const add = isStandalone ? 0.1 : 0.03;
function render(): void {
if (!ctx) return;
// Clear canvas
ctx.clearRect(0, 0, width, height);
// Draw particles
for (const particle of particles) {
// Only draw if within canvas bounds (plus a small margin)
if (
particle.x >= -PARTICLE_RADIUS &&
particle.x <= width + PARTICLE_RADIUS &&
particle.y >= -PARTICLE_RADIUS && particle.y <= height + PARTICLE_RADIUS
) {
ctx.beginPath();
ctx.arc(particle.x, particle.y, PARTICLE_RADIUS, 0, Math.PI * 2);
// Color based on charge
ctx.fillStyle = "#FFCB1F";
ctx.globalAlpha = (particle.charge * mul + add) * globalOpacity;
ctx.fill();
}
}
// // Debug: Draw forces and falloff visualization
// if (ctx) {
// for (const force of forces) {
// const R = force.radius * FORCE_RADIUS;
// // Draw force point
// ctx.beginPath();
// ctx.arc(force.x, force.y, 5, 0, Math.PI * 2);
// ctx.fillStyle = 'rgba(255, 0, 0, 0.5)';
// ctx.fill();
// // Draw force direction
// ctx.beginPath();
// ctx.moveTo(force.x, force.y);
// ctx.lineTo(force.x + force.dx * 20, force.y + force.dy * 20);
// ctx.strokeStyle = 'red';
// ctx.stroke();
// // Visualize the falloff curve with rings
// for (let i = 0; i <= 10; i++) {
// const radius = (R * i) / 10;
// const normalizedDist = radius / R;
// const intensity = Math.pow(1 - normalizedDist, FORCE_FALLOFF_EXPONENT);
// ctx.beginPath();
// ctx.arc(force.x, force.y, radius, 0, Math.PI * 2);
// ctx.strokeStyle = `rgba(255, 0, 0, ${intensity * 0.2})`;
// ctx.stroke();
// }
// }
// }
}
// Animation loop
let r = Math.random();
function animate(): void {
globalOpacity = Math.min(1, globalOpacity + 0.03);
update();
render();
if (isRunning) {
animationId = requestAnimationFrame(animate);
}
}
// Start/stop functions
function start(): void {
if (isRunning) return;
// Calculate target particle count based on canvas size
targetParticleCount = Math.floor(width * height * PARTICLE_DENSITY);
// Clear any existing particles and create new ones with proper spacing
particles = [];
addParticles(targetParticleCount);
isRunning = true;
animate();
}
function stop(): void {
isRunning = false;
if (animationId !== null) {
cancelAnimationFrame(animationId);
animationId = null;
}
}
init();
return cleanup;
};

View file

@ -1,160 +0,0 @@
(globalThis as any).canvas_2022 = function (canvas: HTMLCanvasElement) {
const isStandalone = canvas.getAttribute("data-standalone") === "true";
// Configuration for the grid of rotating squares
const config = {
gridRotation: 20, // Overall grid rotation in degrees
squareSize: 20, // Size of each square
spacing: 100, // Distance between square centers
moveSpeedX: 0.01, // Horizontal movement speed (pixels per second)
moveSpeedY: 0.01, // Vertical movement speed (pixels per second)
squareColor: "#00220A", // Color of the squares
squareOpacity: 1, // Opacity of the squares
// Function to determine square rotation based on its coordinates and time
// Can be adjusted for different patterns
rotationFunction: (x: number, y: number, time: number): number => {
// Combination of spatial wave and time-based rotation
return Math.sin(x * 0.05) * Math.cos(y * 0.05) * 180;
},
};
// Convert grid rotation to radians
const gridRotationRad = (config.gridRotation * Math.PI) / 180;
// Get the canvas context
const ctx = canvas.getContext("2d");
if (!ctx) {
console.error("Could not get canvas context");
return () => {};
}
// Make canvas transparent
if (isStandalone) {
canvas.style.backgroundColor = "#154226";
} else {
canvas.style.backgroundColor = "transparent";
}
// Animation variables
let width = canvas.width;
let height = canvas.height;
let offsetX = 0;
let offsetY = 0;
let time = 0;
let animationFrameId: number;
let lastTime = 0;
// Update canvas dimensions when resized
const updateDimensions = () => {
width = canvas.width = canvas.clientWidth;
height = canvas.height = canvas.clientHeight;
};
// Calculate the diagonal length of the canvas (to ensure rotation covers corners)
const calculateDiagonal = () => {
return Math.sqrt(width * width + height * height);
};
// Draw a single square with rotation
const drawSquare = (x: number, y: number, size: number, rotation: number) => {
ctx.save();
// Move to the center of the square position, rotate, then draw
ctx.translate(x, y);
ctx.rotate((rotation * Math.PI) / 180); // Convert rotation degrees to radians
// Draw square centered at position
ctx.fillRect(-size / 2, -size / 2, size, size);
ctx.restore();
};
// Draw the entire grid of squares
const drawGrid = () => {
ctx.clearRect(0, 0, width, height);
// Set drawing properties
ctx.fillStyle = config.squareColor;
ctx.globalAlpha = config.squareOpacity;
// Save the current transformation state
ctx.save();
// Move to the center of the canvas, rotate the grid, then move back
const centerX = width / 2;
const centerY = height / 2;
ctx.translate(centerX, centerY);
ctx.rotate(gridRotationRad);
// Calculate how much of the grid to draw based on canvas size
const diagonal = calculateDiagonal();
const gridSize = Math.ceil(diagonal / config.spacing) + 2;
// Adjust for offset to create movement
const adjustedOffsetX = offsetX % config.spacing;
const adjustedOffsetY = offsetY % config.spacing;
// Draw grid with enough squares to cover the rotated canvas
const halfGrid = Math.ceil(gridSize / 2);
for (let y = -halfGrid; y <= halfGrid; y++) {
for (let x = -halfGrid; x <= halfGrid; x++) {
// Calculate actual position with offset
const posX = x * config.spacing + adjustedOffsetX;
const posY = y * config.spacing + adjustedOffsetY;
// Calculate square rotation based on its position and time
const squareRotation = config.rotationFunction(posX, posY, time);
// Draw the square
drawSquare(posX, posY, config.squareSize, squareRotation);
}
}
// Restore the transformation state
ctx.restore();
// Reset global alpha
ctx.globalAlpha = 1.0;
};
// Animation loop
const animate = (currentTime: number) => {
animationFrameId = requestAnimationFrame(animate);
// Calculate time elapsed since last frame
const elapsed = currentTime - lastTime;
lastTime = currentTime;
// Update time variable for rotation function
time += elapsed;
// Update position offsets for movement
offsetX += config.moveSpeedX * elapsed;
offsetY += config.moveSpeedY * elapsed;
// Draw the grid
drawGrid();
};
// Initialize the animation
const init = () => {
// Set up resize handler
globalThis.addEventListener("resize", updateDimensions);
// Initial setup
updateDimensions();
// Start animation
animationFrameId = requestAnimationFrame(animate);
};
// Start the animation
init();
// Return cleanup function
return () => {
globalThis.removeEventListener("resize", updateDimensions);
cancelAnimationFrame(animationFrameId);
};
};

View file

@ -1,197 +0,0 @@
(globalThis as any).canvas_2023 = function (canvas: HTMLCanvasElement) {
const isStandalone = canvas.getAttribute("data-standalone") === "true";
const config = {
heartBaseSize: 50,
heartMaxSize: 100,
spacing: 150,
rowSpeed: 0.1,
heartColor: "#FF90D9",
heartOpacity: isStandalone ? 0.5 : 0.04,
mouseInfluenceRadius: 1000,
heartScaleFunction: (distance: number, radius: number): number => {
if (distance > radius) return 1;
const normalizedDistance = distance / radius;
const scaleFactor = 1 +
(1 - normalizedDistance) *
(config.heartMaxSize / config.heartBaseSize - 1);
return 1 + (scaleFactor - 1) * Math.pow(1 - normalizedDistance, 2);
},
};
const heart = new Path2D(
"M23.9451 45.3973L20.8672 42.6493C16.9551 39.0174 13.7054 35.8927 11.1181 33.275C8.53056 30.6574 6.46731 28.286 4.92839 26.1608C3.38946 24.0356 2.31772 22.1028 1.71314 20.3624C1.10856 18.6219 0.806274 16.8705 0.806274 15.1081C0.806274 11.4718 2.03118 8.42016 4.481 5.95312C6.93118 3.48608 9.93831 2.25256 13.5024 2.25256C15.5649 2.25256 17.482 2.70142 19.2536 3.59912C21.0255 4.49682 22.5893 5.80674 23.9451 7.52887C25.484 5.73346 27.1059 4.40522 28.8108 3.54416C30.5161 2.6831 32.3751 2.25256 34.3877 2.25256C38.0141 2.25256 41.0551 3.48663 43.5108 5.95477C45.9661 8.42291 47.1938 11.4758 47.1938 15.1136C47.1938 16.8712 46.8823 18.6115 46.2594 20.3343C45.6365 22.0568 44.5648 23.9807 43.0442 26.1059C41.5236 28.231 39.4721 30.6136 36.8896 33.2536C34.3068 35.8936 31.0362 39.0255 27.0779 42.6493L23.9451 45.3973ZM23.9176 38.802C27.6088 35.431 30.6339 32.5547 32.9928 30.173C35.3518 27.7913 37.2091 25.7211 38.5648 23.9624C39.9205 22.2036 40.864 20.6137 41.3953 19.1928C41.9266 17.7715 42.1923 16.4101 42.1923 15.1086C42.1923 12.8768 41.4529 11.0098 39.974 9.50748C38.4952 8.0052 36.6461 7.25406 34.4268 7.25406C32.631 7.25406 30.9572 7.6811 29.4055 8.87193C27.8537 10.0628 25.5389 13.0434 25.5389 13.0434L23.9451 15.3299L22.3512 13.0434C22.3512 13.0434 20.0643 10.2311 18.4638 9.04031C16.8634 7.84948 15.2194 7.25406 13.4991 7.25406C11.2929 7.25406 9.46857 7.98816 8.02602 9.45637C6.58383 10.9246 5.86273 12.8162 5.86273 15.1311C5.86273 16.4784 6.13644 17.8679 6.68386 19.2994C7.23127 20.731 8.18394 22.3333 9.54185 24.1064C10.8998 25.879 12.7329 27.9562 15.0413 30.3379C17.3497 32.7196 20.3084 35.5409 23.9176 38.802Z",
);
const ctx = canvas.getContext("2d");
if (!ctx) {
console.error("Could not get canvas context");
return () => {};
}
if (isStandalone) {
canvas.style.backgroundColor = "#2F1C21";
} else {
canvas.style.backgroundColor = "transparent";
}
let width = canvas.width;
let height = canvas.height;
let animationFrameId: number;
let lastFrameTime = 0;
let mouseX = width / 2;
let mouseY = height / 2;
let offset = config.spacing / 2;
const updateDimensions = () => {
width = canvas.width = canvas.clientWidth;
height = canvas.height = canvas.clientHeight;
mouseX = width / 2;
mouseY = height / 2;
};
const drawHeart = (x: number, y: number, size: number) => {
const scale = size / 30;
ctx.save();
ctx.translate(x, y);
ctx.scale(scale, scale);
ctx.fillStyle = config.heartColor;
ctx.fill(heart);
ctx.restore();
};
const c = 400;
const h = 40;
const k = solveForK(c, h);
const drawHeartGrid = () => {
ctx.clearRect(0, 0, width, height);
ctx.globalAlpha = config.heartOpacity;
const numRows = Math.ceil(height / config.spacing) + 1;
for (let row = 0; row < numRows; row++) {
const direction = row % 2 === 0 ? 1 : -1;
const rowOffset = (offset * direction) % config.spacing;
const posYInit = row * config.spacing + config.spacing / 2;
for (
let posXInit = -config.spacing + rowOffset;
posXInit < width + config.spacing;
posXInit += config.spacing
) {
const dx = (posXInit + config.heartBaseSize / 2) - mouseX;
const dy = (posYInit + config.heartBaseSize / 2) - mouseY;
const distance = Math.sqrt(dx * dx + dy * dy);
const pushIntensity = asymmetricBump(distance, h, c, k, 0.00002);
const pushAngle = Math.atan2(dy, dx);
const pushDistanceX = pushIntensity * Math.cos(pushAngle);
const pushDistanceY = pushIntensity * Math.sin(pushAngle);
const posX = posXInit + pushDistanceX * 1;
const posY = posYInit + pushDistanceY * 2;
const scaleFactor = config.heartScaleFunction(
distance,
config.mouseInfluenceRadius,
);
const heartSize = config.heartBaseSize * scaleFactor;
if (
posX > -config.heartMaxSize &&
posX < width + config.heartMaxSize &&
posY > -config.heartMaxSize &&
posY < height + config.heartMaxSize
) {
drawHeart(posX - heartSize / 2, posY - heartSize / 2, heartSize);
}
}
}
ctx.globalAlpha = 1.0;
};
function solveForK(c: number, k: number) {
// input -> f(x)=h*e^{(-k*(x-c)^{2})}
// desired result is (0, 0.45). (0, 0) is unsolvable but 0.45px will round down to 0.
//
// solution: -\frac{\ln\left(\frac{0.45}{h}\right)}{c^{2}}
return -Math.log(0.45 / h) / (c * c);
}
function asymmetricBump(
x: number,
h: number,
c: number,
leftK: number,
rightK: number,
) {
const k = (x <= c) ? leftK : rightK;
return h * Math.exp(-k * Math.pow(x - c, 2));
}
const updateOffset = (elapsed: number) => {
offset += config.rowSpeed * elapsed;
if (offset > 1000000) {
offset -= 1000000;
}
};
const animate = (currentTime: number) => {
animationFrameId = requestAnimationFrame(animate);
const elapsed = currentTime - lastFrameTime;
lastFrameTime = currentTime;
updateOffset(elapsed * 0.05);
drawHeartGrid();
};
const handleMouseMove = (event: MouseEvent) => {
const rect = canvas.getBoundingClientRect();
mouseX = event.clientX - rect.left;
mouseY = event.clientY - rect.top;
};
const handleTouchMove = (event: TouchEvent) => {
if (event.touches.length > 0) {
event.preventDefault();
const rect = canvas.getBoundingClientRect();
mouseX = event.touches[0].clientX - rect.left;
mouseY = event.touches[0].clientY - rect.top;
}
};
const init = () => {
globalThis.addEventListener("resize", updateDimensions);
document.addEventListener("mousemove", handleMouseMove);
document.addEventListener("touchmove", handleTouchMove, { passive: false });
updateDimensions();
lastFrameTime = performance.now();
animationFrameId = requestAnimationFrame(animate);
};
init();
return () => {
globalThis.removeEventListener("resize", updateDimensions);
document.removeEventListener("mousemove", handleMouseMove);
document.removeEventListener("touchmove", handleTouchMove);
cancelAnimationFrame(animationFrameId);
};
};

View file

@ -1,251 +0,0 @@
// Vibe coded with AI
(globalThis as any).canvas_2024 = function (canvas: HTMLCanvasElement) {
const isStandalone = canvas.getAttribute("data-standalone") === "true";
if (isStandalone) {
canvas.parentElement!.style.backgroundColor = "black";
}
const gl = canvas.getContext("webgl", {
alpha: true,
premultipliedAlpha: false,
});
if (!gl) {
console.error("WebGL not supported");
return () => {};
}
canvas.style.imageRendering = "pixelated";
canvas.style.opacity = isStandalone ? "0.3" : "0.15";
// Resize canvas to match display size
const resize = () => {
const displayWidth = Math.floor(
(canvas.clientWidth || globalThis.innerWidth) / 3,
);
const displayHeight = Math.floor(
(canvas.clientHeight || globalThis.innerHeight) / 3,
);
if (canvas.width !== displayWidth || canvas.height !== displayHeight) {
canvas.width = displayWidth;
canvas.height = displayHeight;
gl.viewport(0, 0, canvas.width, canvas.height);
}
};
resize();
// Vertex shader (just passes coordinates)
const vertexShaderSource = `
attribute vec2 a_position;
void main() {
gl_Position = vec4(a_position, 0.0, 1.0);
}
`;
// Fragment shader creates random noise with higher opacity to ensure visibility
const fragmentShaderSource = `
precision mediump float;
uniform float u_time;
float noise1(float seed1,float seed2){
return(
fract(seed1+12.34567*
fract(100.*(abs(seed1*0.91)+seed2+94.68)*
fract((abs(seed2*0.41)+45.46)*
fract((abs(seed2)+757.21)*
fract(seed1*0.0171))))))
* 1.0038 - 0.00185;
}
float n(float seed1, float seed2, float seed3){
float buff1 = abs(seed1+100.81) + 1000.3;
float buff2 = abs(seed2+100.45) + 1000.2;
float buff3 = abs(noise1(seed1, seed2)+seed3) + 1000.1;
buff1 = (buff3*fract(buff2*fract(buff1*fract(buff2*0.146))));
buff2 = (buff2*fract(buff2*fract(buff1+buff2*fract(buff3*0.52))));
buff1 = noise1(buff1, buff2);
return(buff1);
}
void main() {
float noise = n(gl_FragCoord.x, gl_FragCoord.y, u_time);
gl_FragColor = vec4(1.0, 0.7, 0.7, 0.8*noise);
}
`;
// Create and compile shaders
const vertexShader = createShader(gl, gl.VERTEX_SHADER, vertexShaderSource);
const fragmentShader = createShader(
gl,
gl.FRAGMENT_SHADER,
fragmentShaderSource,
);
// Check if shader creation failed
if (!vertexShader || !fragmentShader) {
console.error("Failed to create shaders");
return () => {};
}
// Create program and link shaders
const program = createProgram(gl, vertexShader, fragmentShader);
// Check if program creation failed
if (!program) {
console.error("Failed to create program");
return () => {};
}
// Get attribute and uniform locations
const positionAttributeLocation = gl.getAttribLocation(program, "a_position");
const timeUniformLocation = gl.getUniformLocation(program, "u_time");
// Create a position buffer for a rectangle covering the entire canvas
const positionBuffer = gl.createBuffer();
if (!positionBuffer) {
console.error("Failed to create position buffer");
return () => {};
}
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
// Rectangle that covers the entire clip space
const positions = [
-1.0,
-1.0, // bottom left
1.0,
-1.0, // bottom right
-1.0,
1.0, // top left
1.0,
1.0, // top right
];
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(positions), gl.STATIC_DRAW);
// Set up blending
gl.enable(gl.BLEND);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
// Fixed 24 FPS timing
const FPS = 24;
const FRAME_TIME = 1000 / FPS; // ms per frame
// Handle animation
let animationTimerId: number;
let startTime = Date.now();
let lastFrameTime = 0;
const render = () => {
// Get current time
const currentTime = Date.now();
const deltaTime = currentTime - lastFrameTime;
// Skip frame if it's too early (maintain 24 FPS)
if (deltaTime < FRAME_TIME) {
animationTimerId = globalThis.setTimeout(render, 0); // Check again ASAP but yield to browser
return;
}
// Update last frame time, accounting for any drift
lastFrameTime = currentTime - (deltaTime % FRAME_TIME);
// Resize canvas if needed
resize();
// Calculate elapsed time in seconds for animation
const elapsedTime = (currentTime - startTime) / 1000;
// Clear the canvas with transparent black
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
// Use our shader program
gl.useProgram(program);
// Set up the position attribute
gl.enableVertexAttribArray(positionAttributeLocation);
gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
gl.vertexAttribPointer(
positionAttributeLocation,
2, // 2 components per vertex
gl.FLOAT, // data type
false, // normalize
0, // stride (0 = compute from size and type)
0, // offset
);
// Update time uniform for animation
gl.uniform1f(timeUniformLocation, elapsedTime);
// Draw the rectangle (2 triangles)
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
// Schedule next frame (aiming for 24 FPS)
const timeToNextFrame = Math.max(
0,
FRAME_TIME - (Date.now() - currentTime),
);
animationTimerId = globalThis.setTimeout(render, timeToNextFrame);
};
// Helper function to create shaders
function createShader(
gl: WebGLRenderingContext,
type: number,
source: string,
): WebGLShader | null {
const shader = gl.createShader(type);
if (!shader) {
console.error("Failed to create shader object");
return null;
}
gl.shaderSource(shader, source);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
console.error("Shader compilation error:", gl.getShaderInfoLog(shader));
gl.deleteShader(shader);
return null;
}
return shader;
}
// Helper function to create program and link shaders
function createProgram(
gl: WebGLRenderingContext,
vertexShader: WebGLShader,
fragmentShader: WebGLShader,
): WebGLProgram | null {
const program = gl.createProgram();
if (!program) {
console.error("Failed to create program object");
return null;
}
gl.attachShader(program, vertexShader);
gl.attachShader(program, fragmentShader);
gl.linkProgram(program);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
console.error("Program linking error:", gl.getProgramInfoLog(program));
return null;
}
return program;
}
// Start the rendering with initial timestamp
lastFrameTime = Date.now();
render();
// Return cleanup function
return () => {
clearTimeout(animationTimerId);
if (program) gl.deleteProgram(program);
if (vertexShader) gl.deleteShader(vertexShader);
if (fragmentShader) gl.deleteShader(fragmentShader);
if (positionBuffer) gl.deleteBuffer(positionBuffer);
};
};

View file

@ -1,197 +0,0 @@
// __esModule
true
// computeNode
function computeNode(node) {
switch (node.type) {
case "StringLiteral":
case "NumericLiteral":
case "BooleanLiteral":
return { value: node.value };
case "RegExpLiteral":
return { value: new RegExp(node.pattern, node.flags) };
case "NullLiteral":
return { value: null };
case "Identifier":
switch (node.name) {
case "undefined":
return { value: undefined };
case "NaN":
return { value: NaN };
case "Infinity":
return { value: Infinity };
default:
return;
}
case "BigIntLiteral":
return { value: BigInt(node.value) };
case "ParenthesizedExpression":
return computeNode(node.expression);
case "BinaryExpression":{
const left = computeNode(node.left);
if (!left) return;
const right = computeNode(node.right);
if (!right) return;
switch (node.operator) {
case "+":
return { value: left.value + right.value };
case "-":
return { value: left.value - right.value };
case "*":
return { value: left.value * right.value };
case "/":
return { value: left.value / right.value };
case "%":
return { value: left.value % right.value };
case "**":
return { value: left.value ** right.value };
case "|":
return { value: left.value | right.value };
case "&":
return { value: left.value & right.value };
case "^":
return { value: left.value ^ right.value };
case "<<":
return { value: left.value << right.value };
case ">>":
return { value: left.value >> right.value };
case ">>>":
return { value: left.value >>> right.value };
case "==":
return { value: left.value == right.value };
case "!=":
return { value: left.value != right.value };
case "===":
return { value: left.value === right.value };
case "!==":
return { value: left.value !== right.value };
case "<":
return { value: left.value < right.value };
case "<=":
return { value: left.value <= right.value };
case ">":
return { value: left.value > right.value };
case ">=":
return { value: left.value >= right.value };
default:
return;
}
}
case "UnaryExpression":{
const arg = computeNode(node.argument);
if (!arg) return;
switch (node.operator) {
case "+":
return { value: +arg.value };
case "-":
return { value: -arg.value };
case "~":
return { value: ~arg.value };
case "!":
return { value: !arg.value };
case "typeof":
return { value: typeof arg.value };
case "void":
return { value: void arg.value };
default:
return;
}
}
case "LogicalExpression":{
const left = computeNode(node.left);
if (!left) return;
const right = computeNode(node.right);
if (!right) return;
switch (node.operator) {
case "&&":
return { value: left.value && right.value };
case "||":
return { value: left.value || right.value };
case "??":
return { value: left.value ?? right.value };
default:
return;
}
}
case "ConditionalExpression":{
const test = computeNode(node.test);
if (!test) return;
const consequent = computeNode(node.consequent);
if (!consequent) return;
const alternate = computeNode(node.alternate);
if (!alternate) return;
return { value: test.value ? consequent.value : alternate.value };
}
case "TemplateLiteral":{
let value = node.quasis[0].value.cooked;
for (let i = 0; i < node.expressions.length; i++) {
const expr = computeNode(node.expressions[i]);
if (!expr) return;
value += expr.value + node.quasis[i + 1].value.cooked;
}
return { value };
}
case "ObjectExpression":{
const value = {};
for (const prop of node.properties) {
if (prop.decorators) return;
switch (prop.type) {
case "ObjectProperty":{
let key;
if (prop.computed) {
const keyNode = computeNode(prop.key);
if (!keyNode) return;
key = keyNode.value + "";
} else {
switch (prop.key.type) {
case "Identifier":
key = prop.key.name;
break;
case "StringLiteral":
key = prop.key.value;
break;
default:
return;
}
}
const propValue = computeNode(prop.value);
if (!propValue) return;
value[key] = propValue.value;
break;
}
case "SpreadElement":{
const arg = computeNode(prop.argument);
if (!arg) return;
Object.assign(value, arg.value);
break;
}
}
}
return { value };
}
case "ArrayExpression":{
const value = [];
for (const elem of node.elements) {
if (elem) {
if (elem.type === "SpreadElement") {
const arg = computeNode(elem.argument);
if (typeof arg?.value?.[Symbol.iterator] !== "function") return;
for (const item of arg.value) {
value.push(item);
}
} else {
const elemValue = computeNode(elem);
if (!elemValue) return;
value.push(elemValue.value);
}
} else {
value.length++;
}
}
return { value };
}
}
}

View file

@ -1,98 +0,0 @@
// default
class ImportBuilder {
constructor(importedSource, scope, hub) {
this._statements = [];
this._resultName = null;
this._importedSource = void 0;
this._scope = scope;
this._hub = hub;
this._importedSource = importedSource;
}
done() {
return {
statements: this._statements,
resultName: this._resultName
};
}
import() {
this._statements.push(importDeclaration([], stringLiteral(this._importedSource)));
return this;
}
require() {
this._statements.push(expressionStatement(callExpression(identifier("require"), [stringLiteral(this._importedSource)])));
return this;
}
namespace(name = "namespace") {
const local = this._scope.generateUidIdentifier(name);
const statement = this._statements[this._statements.length - 1];
_assert(statement.type === "ImportDeclaration");
_assert(statement.specifiers.length === 0);
statement.specifiers = [importNamespaceSpecifier(local)];
this._resultName = cloneNode(local);
return this;
}
default(name) {
const id = this._scope.generateUidIdentifier(name);
const statement = this._statements[this._statements.length - 1];
_assert(statement.type === "ImportDeclaration");
_assert(statement.specifiers.length === 0);
statement.specifiers = [importDefaultSpecifier(id)];
this._resultName = cloneNode(id);
return this;
}
named(name, importName) {
if (importName === "default") return this.default(name);
const id = this._scope.generateUidIdentifier(name);
const statement = this._statements[this._statements.length - 1];
_assert(statement.type === "ImportDeclaration");
_assert(statement.specifiers.length === 0);
statement.specifiers = [importSpecifier(id, identifier(importName))];
this._resultName = cloneNode(id);
return this;
}
var(name) {
const id = this._scope.generateUidIdentifier(name);
let statement = this._statements[this._statements.length - 1];
if (statement.type !== "ExpressionStatement") {
_assert(this._resultName);
statement = expressionStatement(this._resultName);
this._statements.push(statement);
}
this._statements[this._statements.length - 1] = variableDeclaration("var", [variableDeclarator(id, statement.expression)]);
this._resultName = cloneNode(id);
return this;
}
defaultInterop() {
return this._interop(this._hub.addHelper("interopRequireDefault"));
}
wildcardInterop() {
return this._interop(this._hub.addHelper("interopRequireWildcard"));
}
_interop(callee) {
const statement = this._statements[this._statements.length - 1];
if (statement.type === "ExpressionStatement") {
statement.expression = callExpression(callee, [statement.expression]);
} else if (statement.type === "VariableDeclaration") {
_assert(statement.declarations.length === 1);
statement.declarations[0].init = callExpression(callee, [statement.declarations[0].init]);
} else {
_assert.fail("Unexpected type.");
}
return this;
}
prop(name) {
const statement = this._statements[this._statements.length - 1];
if (statement.type === "ExpressionStatement") {
statement.expression = memberExpression(statement.expression, identifier(name));
} else if (statement.type === "VariableDeclaration") {
_assert(statement.declarations.length === 1);
statement.declarations[0].init = memberExpression(statement.declarations[0].init, identifier(name));
} else {
_assert.fail("Unexpected type:" + statement.type);
}
return this;
}
read(name) {
this._resultName = memberExpression(this._resultName, identifier(name));
}
}

View file

@ -1,4 +0,0 @@
// default
function isModule(path) {
return path.node.sourceType === "module";
}

View file

@ -1,12 +0,0 @@
// default
function rewriteThis(programPath) {
if (!rewriteThisVisitor) {
rewriteThisVisitor = _traverse.visitors.environmentVisitor({
ThisExpression(path) {
path.replaceWith(_core.types.unaryExpression("void", _core.types.numericLiteral(0), true));
}
});
rewriteThisVisitor.noScope = true;
}
(0, _traverse.default)(programPath.node, rewriteThisVisitor);
}

View file

@ -1,61 +0,0 @@
// default
function rewriteLiveReferences(programPath, metadata, wrapReference) {
const imported = new Map();
const exported = new Map();
const requeueInParent = path => {
programPath.requeue(path);
};
for (const [source, data] of metadata.source) {
for (const [localName, importName] of data.imports) {
imported.set(localName, [source, importName, null]);
}
for (const localName of data.importsNamespace) {
imported.set(localName, [source, null, localName]);
}
}
for (const [local, data] of metadata.local) {
let exportMeta = exported.get(local);
if (!exportMeta) {
exportMeta = [];
exported.set(local, exportMeta);
}
exportMeta.push(...data.names);
}
const rewriteBindingInitVisitorState = {
metadata,
requeueInParent,
scope: programPath.scope,
exported
};
programPath.traverse(rewriteBindingInitVisitor, rewriteBindingInitVisitorState);
const rewriteReferencesVisitorState = {
seen: new WeakSet(),
metadata,
requeueInParent,
scope: programPath.scope,
imported,
exported,
buildImportReference([source, importName, localName], identNode) {
const meta = metadata.source.get(source);
meta.referenced = true;
if (localName) {
if (meta.wrap) {
var _wrapReference;
identNode = (_wrapReference = wrapReference(identNode, meta.wrap)) != null ? _wrapReference : identNode;
}
return identNode;
}
let namespace = _core.types.identifier(meta.name);
if (meta.wrap) {
var _wrapReference2;
namespace = (_wrapReference2 = wrapReference(namespace, meta.wrap)) != null ? _wrapReference2 : namespace;
}
if (importName === "default" && meta.interop === "node-default") {
return namespace;
}
const computed = metadata.stringSpecifiers.has(importName);
return _core.types.memberExpression(namespace, computed ? _core.types.stringLiteral(importName) : _core.types.identifier(importName), computed);
}
};
programPath.traverse(rewriteReferencesVisitor, rewriteReferencesVisitorState);
}

View file

@ -1,69 +0,0 @@
// default
function normalizeModuleAndLoadMetadata(programPath, exportName, {
importInterop,
initializeReexports = false,
getWrapperPayload,
esNamespaceOnly = false,
filename
}) {
if (!exportName) {
exportName = programPath.scope.generateUidIdentifier("exports").name;
}
const stringSpecifiers = new Set();
nameAnonymousExports(programPath);
const {
local,
sources,
hasExports
} = getModuleMetadata(programPath, {
initializeReexports,
getWrapperPayload
}, stringSpecifiers);
removeImportExportDeclarations(programPath);
for (const [source, metadata] of sources) {
const {
importsNamespace,
imports
} = metadata;
if (importsNamespace.size > 0 && imports.size === 0) {
const [nameOfnamespace] = importsNamespace;
metadata.name = nameOfnamespace;
}
const resolvedInterop = resolveImportInterop(importInterop, source, filename);
if (resolvedInterop === "none") {
metadata.interop = "none";
} else if (resolvedInterop === "node" && metadata.interop === "namespace") {
metadata.interop = "node-namespace";
} else if (resolvedInterop === "node" && metadata.interop === "default") {
metadata.interop = "node-default";
} else if (esNamespaceOnly && metadata.interop === "namespace") {
metadata.interop = "default";
}
}
return {
exportName,
exportNameListName: null,
hasExports,
local,
source: sources,
stringSpecifiers
};
}
// hasExports
function hasExports(metadata) {
return metadata.hasExports;
}
// isSideEffectImport
function isSideEffectImport(source) {
return source.imports.size === 0 && source.importsNamespace.size === 0 && source.reexports.size === 0 && source.reexportNamespace.size === 0 && !source.reexportAll;
}
// validateImportInteropOption
function validateImportInteropOption(importInterop) {
if (typeof importInterop !== "function" && importInterop !== "none" && importInterop !== "babel" && importInterop !== "node") {
throw new Error(`.importInterop must be one of "none", "babel", "node", or a function returning one of those values (received ${importInterop}).`);
}
return importInterop;
}

View file

@ -1,23 +0,0 @@
// toGetWrapperPayload
function toGetWrapperPayload(lazy) {
return (source, metadata) => {
if (lazy === false) return null;
if ((0, _normalizeAndLoadMetadata.isSideEffectImport)(metadata) || metadata.reexportAll) return null;
if (lazy === true) {
return source.includes(".") ? null : "lazy";
}
if (Array.isArray(lazy)) {
return !lazy.includes(source) ? null : "lazy";
}
if (typeof lazy === "function") {
return lazy(source) ? "lazy" : null;
}
throw new Error(`.lazy must be a boolean, string array, or function`);
};
}
// wrapReference
function wrapReference(ref, payload) {
if (payload === "lazy") return _core.types.callExpression(ref, []);
return null;
}

View file

@ -1,40 +0,0 @@
// buildDynamicImport
function buildDynamicImport(node, deferToThen, wrapWithPromise, builder) {
const specifier = _core.types.isCallExpression(node) ? node.arguments[0] : node.source;
if (_core.types.isStringLiteral(specifier) || _core.types.isTemplateLiteral(specifier) && specifier.quasis.length === 0) {
if (deferToThen) {
return _core.template.expression.ast`
Promise.resolve().then(() => ${builder(specifier)})
`;
} else return builder(specifier);
}
const specifierToString = _core.types.isTemplateLiteral(specifier) ? _core.types.identifier("specifier") : _core.types.templateLiteral([_core.types.templateElement({
raw: ""
}), _core.types.templateElement({
raw: ""
})], [_core.types.identifier("specifier")]);
if (deferToThen) {
return _core.template.expression.ast`
(specifier =>
new Promise(r => r(${specifierToString}))
.then(s => ${builder(_core.types.identifier("s"))})
)(${specifier})
`;
} else if (wrapWithPromise) {
return _core.template.expression.ast`
(specifier =>
new Promise(r => r(${builder(specifierToString)}))
)(${specifier})
`;
} else {
return _core.template.expression.ast`
(specifier => ${builder(specifierToString)})(${specifier})
`;
}
}
// getDynamicImportSource
function getDynamicImportSource(node) {
const [source] = node.arguments;
return _core.types.isStringLiteral(source) || _core.types.isTemplateLiteral(source) ? source : _core.template.expression.ast`\`\${${source}}\``;
}

View file

@ -1,10 +0,0 @@
// default
function getModuleName(rootOpts, pluginOpts) {
var _pluginOpts$moduleId, _pluginOpts$moduleIds, _pluginOpts$getModule, _pluginOpts$moduleRoo;
return originalGetModuleName(rootOpts, {
moduleId: (_pluginOpts$moduleId = pluginOpts.moduleId) != null ? _pluginOpts$moduleId : rootOpts.moduleId,
moduleIds: (_pluginOpts$moduleIds = pluginOpts.moduleIds) != null ? _pluginOpts$moduleIds : rootOpts.moduleIds,
getModuleId: (_pluginOpts$getModule = pluginOpts.getModuleId) != null ? _pluginOpts$getModule : rootOpts.getModuleId,
moduleRoot: (_pluginOpts$moduleRoo = pluginOpts.moduleRoot) != null ? _pluginOpts$moduleRoo : rootOpts.moduleRoot
});
}

View file

@ -1,5 +0,0 @@
// transformDynamicImport
function transformDynamicImport(path, noInterop, file) {
const buildRequire = noInterop ? requireNoInterop : requireInterop;
path.replaceWith((0, _helperModuleTransforms.buildDynamicImport)(path.node, true, false, specifier => buildRequire(specifier, file)));
}

View file

@ -1,34 +0,0 @@
// lazyImportsHook
lazy => ({
name: `${"@babel/plugin-transform-modules-commonjs"}/lazy`,
version: "7.27.1",
getWrapperPayload(source, metadata) {
if ((0, _helperModuleTransforms.isSideEffectImport)(metadata) || metadata.reexportAll) {
return null;
}
if (lazy === true) {
return source.includes(".") ? null : "lazy/function";
}
if (Array.isArray(lazy)) {
return !lazy.includes(source) ? null : "lazy/function";
}
if (typeof lazy === "function") {
return lazy(source) ? "lazy/function" : null;
}
},
buildRequireWrapper(name, init, payload, referenced) {
if (payload === "lazy/function") {
if (!referenced) return false;
return _core.template.statement.ast`
function ${name}() {
const data = ${init};
${name} = function(){ return data; };
return data;
}
`;
}
},
wrapReference(ref, payload) {
if (payload === "lazy/function") return _core.types.callExpression(ref, []);
}
})

View file

@ -1,22 +0,0 @@
// defineCommonJSHook
function defineCommonJSHook(file, hook) {
let hooks = file.get(commonJSHooksKey);
if (!hooks) file.set(commonJSHooksKey, hooks = []);
hooks.push(hook);
}
// makeInvokers
function makeInvokers(file) {
const hooks = file.get(commonJSHooksKey);
return {
getWrapperPayload(...args) {
return findMap(hooks, hook => hook.getWrapperPayload == null ? void 0 : hook.getWrapperPayload(...args));
},
wrapReference(...args) {
return findMap(hooks, hook => hook.wrapReference == null ? void 0 : hook.wrapReference(...args));
},
buildRequireWrapper(...args) {
return findMap(hooks, hook => hook.buildRequireWrapper == null ? void 0 : hook.buildRequireWrapper(...args));
}
};
}

View file

@ -1,10 +0,0 @@
// default
(api, options, dirname) => {
let clonedApi;
for (const name of Object.keys(apiPolyfills)) {
if (api[name]) continue;
clonedApi != null ? clonedApi : clonedApi = copyApiObject(api);
clonedApi[name] = apiPolyfills[name](clonedApi);
}
return builder(clonedApi != null ? clonedApi : api, options || {}, dirname);
}

View file

@ -1,298 +0,0 @@
// FEATURES
[object Object]
// buildCheckInRHS
function buildCheckInRHS(rhs, file, inRHSIsObject) {
if (inRHSIsObject || !(file.availableHelper != null && file.availableHelper("checkInRHS"))) return rhs;
return _core.types.callExpression(file.addHelper("checkInRHS"), [rhs]);
}
// createClassFeaturePlugin
function createClassFeaturePlugin({
name,
feature,
loose,
manipulateOptions,
api,
inherits,
decoratorVersion
}) {
var _api$assumption;
if (feature & _features.FEATURES.decorators) {
{
if (decoratorVersion === "2023-11" || decoratorVersion === "2023-05" || decoratorVersion === "2023-01" || decoratorVersion === "2022-03" || decoratorVersion === "2021-12") {
return (0, _decorators.default)(api, {
loose
}, decoratorVersion, inherits);
}
}
}
{
api != null ? api : api = {
assumption: () => void 0
};
}
const setPublicClassFields = api.assumption("setPublicClassFields");
const privateFieldsAsSymbols = api.assumption("privateFieldsAsSymbols");
const privateFieldsAsProperties = api.assumption("privateFieldsAsProperties");
const noUninitializedPrivateFieldAccess = (_api$assumption = api.assumption("noUninitializedPrivateFieldAccess")) != null ? _api$assumption : false;
const constantSuper = api.assumption("constantSuper");
const noDocumentAll = api.assumption("noDocumentAll");
if (privateFieldsAsProperties && privateFieldsAsSymbols) {
throw new Error(`Cannot enable both the "privateFieldsAsProperties" and ` + `"privateFieldsAsSymbols" assumptions as the same time.`);
}
const privateFieldsAsSymbolsOrProperties = privateFieldsAsProperties || privateFieldsAsSymbols;
if (loose === true) {
const explicit = [];
if (setPublicClassFields !== undefined) {
explicit.push(`"setPublicClassFields"`);
}
if (privateFieldsAsProperties !== undefined) {
explicit.push(`"privateFieldsAsProperties"`);
}
if (privateFieldsAsSymbols !== undefined) {
explicit.push(`"privateFieldsAsSymbols"`);
}
if (explicit.length !== 0) {
console.warn(`[${name}]: You are using the "loose: true" option and you are` + ` explicitly setting a value for the ${explicit.join(" and ")}` + ` assumption${explicit.length > 1 ? "s" : ""}. The "loose" option` + ` can cause incompatibilities with the other class features` + ` plugins, so it's recommended that you replace it with the` + ` following top-level option:\n` + `\t"assumptions": {\n` + `\t\t"setPublicClassFields": true,\n` + `\t\t"privateFieldsAsSymbols": true\n` + `\t}`);
}
}
return {
name,
manipulateOptions,
inherits,
pre(file) {
(0, _features.enableFeature)(file, feature, loose);
{
if (typeof file.get(versionKey) === "number") {
file.set(versionKey, "7.27.1");
return;
}
}
if (!file.get(versionKey) || _semver.lt(file.get(versionKey), "7.27.1")) {
file.set(versionKey, "7.27.1");
}
},
visitor: {
Class(path, {
file
}) {
if (file.get(versionKey) !== "7.27.1") return;
if (!(0, _features.shouldTransform)(path, file)) return;
const pathIsClassDeclaration = path.isClassDeclaration();
if (pathIsClassDeclaration) (0, _typescript.assertFieldTransformed)(path);
const loose = (0, _features.isLoose)(file, feature);
let constructor;
const isDecorated = (0, _decorators.hasDecorators)(path.node);
const props = [];
const elements = [];
const computedPaths = [];
const privateNames = new Set();
const body = path.get("body");
for (const path of body.get("body")) {
if ((path.isClassProperty() || path.isClassMethod()) && path.node.computed) {
computedPaths.push(path);
}
if (path.isPrivate()) {
const {
name
} = path.node.key.id;
const getName = `get ${name}`;
const setName = `set ${name}`;
if (path.isClassPrivateMethod()) {
if (path.node.kind === "get") {
if (privateNames.has(getName) || privateNames.has(name) && !privateNames.has(setName)) {
throw path.buildCodeFrameError("Duplicate private field");
}
privateNames.add(getName).add(name);
} else if (path.node.kind === "set") {
if (privateNames.has(setName) || privateNames.has(name) && !privateNames.has(getName)) {
throw path.buildCodeFrameError("Duplicate private field");
}
privateNames.add(setName).add(name);
}
} else {
if (privateNames.has(name) && !privateNames.has(getName) && !privateNames.has(setName) || privateNames.has(name) && (privateNames.has(getName) || privateNames.has(setName))) {
throw path.buildCodeFrameError("Duplicate private field");
}
privateNames.add(name);
}
}
if (path.isClassMethod({
kind: "constructor"
})) {
constructor = path;
} else {
elements.push(path);
if (path.isProperty() || path.isPrivate() || path.isStaticBlock != null && path.isStaticBlock()) {
props.push(path);
}
}
}
{
if (!props.length && !isDecorated) return;
}
const innerBinding = path.node.id;
let ref;
if (!innerBinding || !pathIsClassDeclaration) {
{
var _path$ensureFunctionN;
(_path$ensureFunctionN = path.ensureFunctionName) != null ? _path$ensureFunctionN : path.ensureFunctionName = require("@babel/traverse").NodePath.prototype.ensureFunctionName;
}
path.ensureFunctionName(false);
ref = path.scope.generateUidIdentifier((innerBinding == null ? void 0 : innerBinding.name) || "Class");
}
const classRefForDefine = ref != null ? ref : _core.types.cloneNode(innerBinding);
const privateNamesMap = (0, _fields.buildPrivateNamesMap)(classRefForDefine.name, privateFieldsAsSymbolsOrProperties != null ? privateFieldsAsSymbolsOrProperties : loose, props, file);
const privateNamesNodes = (0, _fields.buildPrivateNamesNodes)(privateNamesMap, privateFieldsAsProperties != null ? privateFieldsAsProperties : loose, privateFieldsAsSymbols != null ? privateFieldsAsSymbols : false, file);
(0, _fields.transformPrivateNamesUsage)(classRefForDefine, path, privateNamesMap, {
privateFieldsAsProperties: privateFieldsAsSymbolsOrProperties != null ? privateFieldsAsSymbolsOrProperties : loose,
noUninitializedPrivateFieldAccess,
noDocumentAll,
innerBinding
}, file);
let keysNodes, staticNodes, instanceNodes, lastInstanceNodeReturnsThis, pureStaticNodes, classBindingNode, wrapClass;
{
if (isDecorated) {
staticNodes = pureStaticNodes = keysNodes = [];
({
instanceNodes,
wrapClass
} = (0, _decorators2.buildDecoratedClass)(classRefForDefine, path, elements, file));
} else {
keysNodes = (0, _misc.extractComputedKeys)(path, computedPaths, file);
({
staticNodes,
pureStaticNodes,
instanceNodes,
lastInstanceNodeReturnsThis,
classBindingNode,
wrapClass
} = (0, _fields.buildFieldsInitNodes)(ref, path.node.superClass, props, privateNamesMap, file, setPublicClassFields != null ? setPublicClassFields : loose, privateFieldsAsSymbolsOrProperties != null ? privateFieldsAsSymbolsOrProperties : loose, noUninitializedPrivateFieldAccess, constantSuper != null ? constantSuper : loose, innerBinding));
}
}
if (instanceNodes.length > 0) {
(0, _misc.injectInitialization)(path, constructor, instanceNodes, (referenceVisitor, state) => {
{
if (isDecorated) return;
}
for (const prop of props) {
if (_core.types.isStaticBlock != null && _core.types.isStaticBlock(prop.node) || prop.node.static) continue;
prop.traverse(referenceVisitor, state);
}
}, lastInstanceNodeReturnsThis);
}
const wrappedPath = wrapClass(path);
wrappedPath.insertBefore([...privateNamesNodes, ...keysNodes]);
if (staticNodes.length > 0) {
wrappedPath.insertAfter(staticNodes);
}
if (pureStaticNodes.length > 0) {
wrappedPath.find(parent => parent.isStatement() || parent.isDeclaration()).insertAfter(pureStaticNodes);
}
if (classBindingNode != null && pathIsClassDeclaration) {
wrappedPath.insertAfter(classBindingNode);
}
},
ExportDefaultDeclaration(path, {
file
}) {
{
if (file.get(versionKey) !== "7.27.1") return;
const decl = path.get("declaration");
if (decl.isClassDeclaration() && (0, _decorators.hasDecorators)(decl.node)) {
if (decl.node.id) {
{
var _path$splitExportDecl;
(_path$splitExportDecl = path.splitExportDeclaration) != null ? _path$splitExportDecl : path.splitExportDeclaration = require("@babel/traverse").NodePath.prototype.splitExportDeclaration;
}
path.splitExportDeclaration();
} else {
decl.node.type = "ClassExpression";
}
}
}
}
}
};
}
// enableFeature
function enableFeature(file, feature, loose) {
if (!hasFeature(file, feature) || canIgnoreLoose(file, feature)) {
file.set(featuresKey, file.get(featuresKey) | feature);
if (loose === "#__internal__@babel/preset-env__prefer-true-but-false-is-ok-if-it-prevents-an-error") {
setLoose(file, feature, true);
file.set(looseLowPriorityKey, file.get(looseLowPriorityKey) | feature);
} else if (loose === "#__internal__@babel/preset-env__prefer-false-but-true-is-ok-if-it-prevents-an-error") {
setLoose(file, feature, false);
file.set(looseLowPriorityKey, file.get(looseLowPriorityKey) | feature);
} else {
setLoose(file, feature, loose);
}
}
let resolvedLoose;
for (const [mask, name] of featuresSameLoose) {
if (!hasFeature(file, mask)) continue;
{
if (canIgnoreLoose(file, mask)) continue;
}
const loose = isLoose(file, mask);
if (resolvedLoose === !loose) {
throw new Error("'loose' mode configuration must be the same for @babel/plugin-transform-class-properties, " + "@babel/plugin-transform-private-methods and " + "@babel/plugin-transform-private-property-in-object (when they are enabled)." + "\n\n" + getBabelShowConfigForHint(file));
} else {
resolvedLoose = loose;
{
var higherPriorityPluginName = name;
}
}
}
if (resolvedLoose !== undefined) {
for (const [mask, name] of featuresSameLoose) {
if (hasFeature(file, mask) && isLoose(file, mask) !== resolvedLoose) {
setLoose(file, mask, resolvedLoose);
console.warn(`Though the "loose" option was set to "${!resolvedLoose}" in your @babel/preset-env ` + `config, it will not be used for ${name} since the "loose" mode option was set to ` + `"${resolvedLoose}" for ${higherPriorityPluginName}.\nThe "loose" option must be the ` + `same for @babel/plugin-transform-class-properties, @babel/plugin-transform-private-methods ` + `and @babel/plugin-transform-private-property-in-object (when they are enabled): you can ` + `silence this warning by explicitly adding\n` + `\t["${name}", { "loose": ${resolvedLoose} }]\n` + `to the "plugins" section of your Babel config.` + "\n\n" + getBabelShowConfigForHint(file));
}
}
}
}
// injectInitialization
function injectInitialization(path, constructor, nodes, renamer, lastReturnsThis) {
if (!nodes.length) return;
const isDerived = !!path.node.superClass;
if (!constructor) {
const newConstructor = _core.types.classMethod("constructor", _core.types.identifier("constructor"), [], _core.types.blockStatement([]));
if (isDerived) {
newConstructor.params = [_core.types.restElement(_core.types.identifier("args"))];
newConstructor.body.body.push(_core.template.statement.ast`super(...args)`);
}
[constructor] = path.get("body").unshiftContainer("body", newConstructor);
}
if (renamer) {
renamer(referenceVisitor, {
scope: constructor.scope
});
}
if (isDerived) {
const bareSupers = [];
constructor.traverse(findBareSupers, bareSupers);
let isFirst = true;
for (const bareSuper of bareSupers) {
if (isFirst) {
isFirst = false;
} else {
nodes = nodes.map(n => _core.types.cloneNode(n));
}
if (!bareSuper.parentPath.isExpressionStatement()) {
const allNodes = [bareSuper.node, ...nodes.map(n => _core.types.toExpression(n))];
if (!lastReturnsThis) allNodes.push(_core.types.thisExpression());
bareSuper.replaceWith(_core.types.sequenceExpression(allNodes));
} else {
bareSuper.insertAfter(nodes);
}
}
} else {
constructor.get("body").unshiftContainer("body", nodes);
}
}

View file

@ -1,323 +0,0 @@
// buildCheckInRHS
function buildCheckInRHS(rhs, file, inRHSIsObject) {
if (inRHSIsObject || !(file.availableHelper != null && file.availableHelper("checkInRHS"))) return rhs;
return _core.types.callExpression(file.addHelper("checkInRHS"), [rhs]);
}
// buildFieldsInitNodes
function buildFieldsInitNodes(ref, superRef, props, privateNamesMap, file, setPublicClassFields, privateFieldsAsSymbolsOrProperties, noUninitializedPrivateFieldAccess, constantSuper, innerBindingRef) {
let classRefFlags = 0;
let injectSuperRef;
const staticNodes = [];
const instanceNodes = [];
let lastInstanceNodeReturnsThis = false;
const pureStaticNodes = [];
let classBindingNode = null;
const getSuperRef = _core.types.isIdentifier(superRef) ? () => superRef : () => {
injectSuperRef != null ? injectSuperRef : injectSuperRef = props[0].scope.generateUidIdentifierBasedOnNode(superRef);
return injectSuperRef;
};
const classRefForInnerBinding = ref != null ? ref : props[0].scope.generateUidIdentifier((innerBindingRef == null ? void 0 : innerBindingRef.name) || "Class");
ref != null ? ref : ref = _core.types.cloneNode(innerBindingRef);
for (const prop of props) {
if (prop.isClassProperty()) {
ts.assertFieldTransformed(prop);
}
const isStatic = !(_core.types.isStaticBlock != null && _core.types.isStaticBlock(prop.node)) && prop.node.static;
const isInstance = !isStatic;
const isPrivate = prop.isPrivate();
const isPublic = !isPrivate;
const isField = prop.isProperty();
const isMethod = !isField;
const isStaticBlock = prop.isStaticBlock == null ? void 0 : prop.isStaticBlock();
if (isStatic) classRefFlags |= 1;
if (isStatic || isMethod && isPrivate || isStaticBlock) {
new _helperReplaceSupers.default({
methodPath: prop,
constantSuper,
file: file,
refToPreserve: innerBindingRef,
getSuperRef,
getObjectRef() {
classRefFlags |= 2;
if (isStatic || isStaticBlock) {
return classRefForInnerBinding;
} else {
return _core.types.memberExpression(classRefForInnerBinding, _core.types.identifier("prototype"));
}
}
}).replace();
const replaced = replaceThisContext(prop, classRefForInnerBinding, innerBindingRef);
if (replaced) {
classRefFlags |= 2;
}
}
lastInstanceNodeReturnsThis = false;
switch (true) {
case isStaticBlock:
{
const blockBody = prop.node.body;
if (blockBody.length === 1 && _core.types.isExpressionStatement(blockBody[0])) {
staticNodes.push(inheritPropComments(blockBody[0], prop));
} else {
staticNodes.push(_core.types.inheritsComments(_core.template.statement.ast`(() => { ${blockBody} })()`, prop.node));
}
break;
}
case isStatic && isPrivate && isField && privateFieldsAsSymbolsOrProperties:
staticNodes.push(buildPrivateFieldInitLoose(_core.types.cloneNode(ref), prop, privateNamesMap));
break;
case isStatic && isPrivate && isField && !privateFieldsAsSymbolsOrProperties:
if (!newHelpers(file)) {
staticNodes.push(buildPrivateStaticFieldInitSpecOld(prop, privateNamesMap));
} else {
staticNodes.push(buildPrivateStaticFieldInitSpec(prop, privateNamesMap, noUninitializedPrivateFieldAccess));
}
break;
case isStatic && isPublic && isField && setPublicClassFields:
if (!isNameOrLength(prop.node)) {
staticNodes.push(buildPublicFieldInitLoose(_core.types.cloneNode(ref), prop));
break;
}
case isStatic && isPublic && isField && !setPublicClassFields:
staticNodes.push(buildPublicFieldInitSpec(_core.types.cloneNode(ref), prop, file));
break;
case isInstance && isPrivate && isField && privateFieldsAsSymbolsOrProperties:
instanceNodes.push(buildPrivateFieldInitLoose(_core.types.thisExpression(), prop, privateNamesMap));
break;
case isInstance && isPrivate && isField && !privateFieldsAsSymbolsOrProperties:
instanceNodes.push(buildPrivateInstanceFieldInitSpec(_core.types.thisExpression(), prop, privateNamesMap, file));
break;
case isInstance && isPrivate && isMethod && privateFieldsAsSymbolsOrProperties:
instanceNodes.unshift(buildPrivateMethodInitLoose(_core.types.thisExpression(), prop, privateNamesMap));
pureStaticNodes.push(buildPrivateMethodDeclaration(file, prop, privateNamesMap, privateFieldsAsSymbolsOrProperties));
break;
case isInstance && isPrivate && isMethod && !privateFieldsAsSymbolsOrProperties:
instanceNodes.unshift(buildPrivateInstanceMethodInitSpec(_core.types.thisExpression(), prop, privateNamesMap, file));
pureStaticNodes.push(buildPrivateMethodDeclaration(file, prop, privateNamesMap, privateFieldsAsSymbolsOrProperties));
break;
case isStatic && isPrivate && isMethod && !privateFieldsAsSymbolsOrProperties:
if (!newHelpers(file)) {
staticNodes.unshift(buildPrivateStaticFieldInitSpecOld(prop, privateNamesMap));
}
pureStaticNodes.push(buildPrivateMethodDeclaration(file, prop, privateNamesMap, privateFieldsAsSymbolsOrProperties));
break;
case isStatic && isPrivate && isMethod && privateFieldsAsSymbolsOrProperties:
staticNodes.unshift(buildPrivateStaticMethodInitLoose(_core.types.cloneNode(ref), prop, file, privateNamesMap));
pureStaticNodes.push(buildPrivateMethodDeclaration(file, prop, privateNamesMap, privateFieldsAsSymbolsOrProperties));
break;
case isInstance && isPublic && isField && setPublicClassFields:
instanceNodes.push(buildPublicFieldInitLoose(_core.types.thisExpression(), prop));
break;
case isInstance && isPublic && isField && !setPublicClassFields:
lastInstanceNodeReturnsThis = true;
instanceNodes.push(buildPublicFieldInitSpec(_core.types.thisExpression(), prop, file));
break;
default:
throw new Error("Unreachable.");
}
}
if (classRefFlags & 2 && innerBindingRef != null) {
classBindingNode = _core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.cloneNode(classRefForInnerBinding), _core.types.cloneNode(innerBindingRef)));
}
return {
staticNodes: staticNodes.filter(Boolean),
instanceNodes: instanceNodes.filter(Boolean),
lastInstanceNodeReturnsThis,
pureStaticNodes: pureStaticNodes.filter(Boolean),
classBindingNode,
wrapClass(path) {
for (const prop of props) {
prop.node.leadingComments = null;
prop.remove();
}
if (injectSuperRef) {
path.scope.push({
id: _core.types.cloneNode(injectSuperRef)
});
path.set("superClass", _core.types.assignmentExpression("=", injectSuperRef, path.node.superClass));
}
if (classRefFlags !== 0) {
if (path.isClassExpression()) {
path.scope.push({
id: ref
});
path.replaceWith(_core.types.assignmentExpression("=", _core.types.cloneNode(ref), path.node));
} else {
if (innerBindingRef == null) {
path.node.id = ref;
}
if (classBindingNode != null) {
path.scope.push({
id: classRefForInnerBinding
});
}
}
}
return path;
}
};
}
// buildPrivateNamesMap
function buildPrivateNamesMap(className, privateFieldsAsSymbolsOrProperties, props, file) {
const privateNamesMap = new Map();
let classBrandId;
for (const prop of props) {
if (prop.isPrivate()) {
const {
name
} = prop.node.key.id;
let update = privateNamesMap.get(name);
if (!update) {
const isMethod = !prop.isProperty();
const isStatic = prop.node.static;
let initAdded = false;
let id;
if (!privateFieldsAsSymbolsOrProperties && newHelpers(file) && isMethod && !isStatic) {
initAdded = !!classBrandId;
classBrandId != null ? classBrandId : classBrandId = prop.scope.generateUidIdentifier(`${className}_brand`);
id = classBrandId;
} else {
id = prop.scope.generateUidIdentifier(name);
}
update = {
id,
static: isStatic,
method: isMethod,
initAdded
};
privateNamesMap.set(name, update);
}
if (prop.isClassPrivateMethod()) {
if (prop.node.kind === "get") {
const {
body
} = prop.node.body;
let $;
if (body.length === 1 && _core.types.isReturnStatement($ = body[0]) && _core.types.isCallExpression($ = $.argument) && $.arguments.length === 1 && _core.types.isThisExpression($.arguments[0]) && _core.types.isIdentifier($ = $.callee)) {
update.getId = _core.types.cloneNode($);
update.getterDeclared = true;
} else {
update.getId = prop.scope.generateUidIdentifier(`get_${name}`);
}
} else if (prop.node.kind === "set") {
const {
params
} = prop.node;
const {
body
} = prop.node.body;
let $;
if (body.length === 1 && _core.types.isExpressionStatement($ = body[0]) && _core.types.isCallExpression($ = $.expression) && $.arguments.length === 2 && _core.types.isThisExpression($.arguments[0]) && _core.types.isIdentifier($.arguments[1], {
name: params[0].name
}) && _core.types.isIdentifier($ = $.callee)) {
update.setId = _core.types.cloneNode($);
update.setterDeclared = true;
} else {
update.setId = prop.scope.generateUidIdentifier(`set_${name}`);
}
} else if (prop.node.kind === "method") {
update.methodId = prop.scope.generateUidIdentifier(name);
}
}
privateNamesMap.set(name, update);
}
}
return privateNamesMap;
}
// buildPrivateNamesNodes
function buildPrivateNamesNodes(privateNamesMap, privateFieldsAsProperties, privateFieldsAsSymbols, state) {
const initNodes = [];
const injectedIds = new Set();
for (const [name, value] of privateNamesMap) {
const {
static: isStatic,
method: isMethod,
getId,
setId
} = value;
const isGetterOrSetter = getId || setId;
const id = _core.types.cloneNode(value.id);
let init;
if (privateFieldsAsProperties) {
init = _core.types.callExpression(state.addHelper("classPrivateFieldLooseKey"), [_core.types.stringLiteral(name)]);
} else if (privateFieldsAsSymbols) {
init = _core.types.callExpression(_core.types.identifier("Symbol"), [_core.types.stringLiteral(name)]);
} else if (!isStatic) {
if (injectedIds.has(id.name)) continue;
injectedIds.add(id.name);
init = _core.types.newExpression(_core.types.identifier(isMethod && (!isGetterOrSetter || newHelpers(state)) ? "WeakSet" : "WeakMap"), []);
}
if (init) {
if (!privateFieldsAsSymbols) {
(0, _helperAnnotateAsPure.default)(init);
}
initNodes.push(_core.template.statement.ast`var ${id} = ${init}`);
}
}
return initNodes;
}
// privateNameVisitorFactory
function privateNameVisitorFactory(visitor) {
const nestedVisitor = _traverse.visitors.environmentVisitor(Object.assign({}, visitor));
const privateNameVisitor = Object.assign({}, visitor, {
Class(path) {
const {
privateNamesMap
} = this;
const body = path.get("body.body");
const visiblePrivateNames = new Map(privateNamesMap);
const redeclared = [];
for (const prop of body) {
if (!prop.isPrivate()) continue;
const {
name
} = prop.node.key.id;
visiblePrivateNames.delete(name);
redeclared.push(name);
}
if (!redeclared.length) {
return;
}
path.get("body").traverse(nestedVisitor, Object.assign({}, this, {
redeclared
}));
path.traverse(privateNameVisitor, Object.assign({}, this, {
privateNamesMap: visiblePrivateNames
}));
path.skipKey("body");
}
});
return privateNameVisitor;
}
// transformPrivateNamesUsage
function transformPrivateNamesUsage(ref, path, privateNamesMap, {
privateFieldsAsProperties,
noUninitializedPrivateFieldAccess,
noDocumentAll,
innerBinding
}, state) {
if (!privateNamesMap.size) return;
const body = path.get("body");
const handler = privateFieldsAsProperties ? privateNameHandlerLoose : privateNameHandlerSpec;
(0, _helperMemberExpressionToFunctions.default)(body, privateNameVisitor, Object.assign({
privateNamesMap,
classRef: ref,
file: state
}, handler, {
noDocumentAll,
noUninitializedPrivateFieldAccess,
innerBinding
}));
body.traverse(privateInVisitor, {
privateNamesMap,
classRef: ref,
file: state,
privateFieldsAsProperties,
innerBinding
});
}

View file

@ -1,6 +0,0 @@
// default
function memberExpressionToFunctions(path, visitor, state) {
path.traverse(visitor, Object.assign({}, handle, state, {
memoiser: new AssignmentMemoiser()
}));
}

View file

@ -1,16 +0,0 @@
// default
function optimiseCallExpression(callee, thisNode, args, optional) {
if (args.length === 1 && isSpreadElement(args[0]) && isIdentifier(args[0].argument, {
name: "arguments"
})) {
if (optional) {
return optionalCallExpression(optionalMemberExpression(callee, identifier("apply"), false, true), [thisNode, args[0].argument], false);
}
return callExpression(memberExpression(callee, identifier("apply")), [thisNode, args[0].argument]);
} else {
if (optional) {
return optionalCallExpression(optionalMemberExpression(callee, identifier("call"), false, true), [thisNode, ...args], false);
}
return callExpression(memberExpression(callee, identifier("call")), [thisNode, ...args]);
}
}

View file

@ -1,8 +0,0 @@
// default
function annotateAsPure(pathOrNode) {
const node = pathOrNode.node || pathOrNode;
if (isPureAnnotated(node)) {
return;
}
addComment(node, "leading", PURE_ANNOTATION);
}

View file

@ -1,20 +0,0 @@
// isTransparentExprWrapper
function isTransparentExprWrapper(node) {
return isTSAsExpression(node) || isTSSatisfiesExpression(node) || isTSTypeAssertion(node) || isTSNonNullExpression(node) || isTypeCastExpression(node) || isParenthesizedExpression(node);
}
// skipTransparentExprWrapperNodes
function skipTransparentExprWrapperNodes(node) {
while (isTransparentExprWrapper(node)) {
node = node.expression;
}
return node;
}
// skipTransparentExprWrappers
function skipTransparentExprWrappers(path) {
while (isTransparentExprWrapper(path.node)) {
path = path.get("expression");
}
return path;
}

View file

@ -1,6 +0,0 @@
// assertFieldTransformed
function assertFieldTransformed(path) {
if (path.node.declare || false) {
throw path.buildCodeFrameError(`TypeScript 'declare' fields must first be transformed by ` + `@babel/plugin-transform-typescript.\n` + `If you have already enabled that plugin (or '@babel/preset-typescript'), make sure ` + `that it runs before any plugin related to additional class features:\n` + ` - @babel/plugin-transform-class-properties\n` + ` - @babel/plugin-transform-private-methods\n` + ` - @babel/plugin-proposal-decorators`);
}
}

View file

@ -1,84 +0,0 @@
// default
function _default({
assertVersion,
assumption
}, {
loose
}, version, inherits) {
var _assumption, _assumption2;
{
if (version === "2023-11" || version === "2023-05" || version === "2023-01") {
assertVersion("^7.21.0");
} else if (version === "2021-12") {
assertVersion("^7.16.0");
} else {
assertVersion("^7.19.0");
}
}
const VISITED = new WeakSet();
const constantSuper = (_assumption = assumption("constantSuper")) != null ? _assumption : loose;
const ignoreFunctionLength = (_assumption2 = assumption("ignoreFunctionLength")) != null ? _assumption2 : loose;
const namedEvaluationVisitor = NamedEvaluationVisitoryFactory(isDecoratedAnonymousClassExpression, visitClass);
function visitClass(path, state, className) {
var _node$id;
if (VISITED.has(path)) return;
const {
node
} = path;
className != null ? className : className = (_node$id = node.id) == null ? void 0 : _node$id.name;
const newPath = transformClass(path, state, constantSuper, ignoreFunctionLength, className, namedEvaluationVisitor, version);
if (newPath) {
VISITED.add(newPath);
return;
}
VISITED.add(path);
}
return {
name: "proposal-decorators",
inherits: inherits,
visitor: Object.assign({
ExportDefaultDeclaration(path, state) {
const {
declaration
} = path.node;
if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && isDecorated(declaration)) {
const isAnonymous = !declaration.id;
{
var _path$splitExportDecl;
(_path$splitExportDecl = path.splitExportDeclaration) != null ? _path$splitExportDecl : path.splitExportDeclaration = require("@babel/traverse").NodePath.prototype.splitExportDeclaration;
}
const updatedVarDeclarationPath = path.splitExportDeclaration();
if (isAnonymous) {
visitClass(updatedVarDeclarationPath, state, _core.types.stringLiteral("default"));
}
}
},
ExportNamedDeclaration(path) {
const {
declaration
} = path.node;
if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && isDecorated(declaration)) {
{
var _path$splitExportDecl2;
(_path$splitExportDecl2 = path.splitExportDeclaration) != null ? _path$splitExportDecl2 : path.splitExportDeclaration = require("@babel/traverse").NodePath.prototype.splitExportDeclaration;
}
path.splitExportDeclaration();
}
},
Class(path, state) {
visitClass(path, state, undefined);
}
}, namedEvaluationVisitor)
};
}
// hasDecorators
function hasDecorators(node) {
return hasOwnDecorators(node) || node.body.body.some(hasOwnDecorators);
}
// hasOwnDecorators
function hasOwnDecorators(node) {
var _node$decorators;
return !!((_node$decorators = node.decorators) != null && _node$decorators.length);
}

View file

@ -1,89 +0,0 @@
// extractComputedKeys
function extractComputedKeys(path, computedPaths, file) {
const {
scope
} = path;
const declarations = [];
const state = {
classBinding: path.node.id && scope.getBinding(path.node.id.name),
file
};
for (const computedPath of computedPaths) {
const computedKey = computedPath.get("key");
if (computedKey.isReferencedIdentifier()) {
handleClassTDZ(computedKey, state);
} else {
computedKey.traverse(classFieldDefinitionEvaluationTDZVisitor, state);
}
const computedNode = computedPath.node;
if (!computedKey.isConstantExpression()) {
const assignment = memoiseComputedKey(computedKey.node, scope, scope.generateUidBasedOnNode(computedKey.node));
if (assignment) {
declarations.push(_core.types.expressionStatement(assignment));
computedNode.key = _core.types.cloneNode(assignment.left);
}
}
}
return declarations;
}
// injectInitialization
function injectInitialization(path, constructor, nodes, renamer, lastReturnsThis) {
if (!nodes.length) return;
const isDerived = !!path.node.superClass;
if (!constructor) {
const newConstructor = _core.types.classMethod("constructor", _core.types.identifier("constructor"), [], _core.types.blockStatement([]));
if (isDerived) {
newConstructor.params = [_core.types.restElement(_core.types.identifier("args"))];
newConstructor.body.body.push(_core.template.statement.ast`super(...args)`);
}
[constructor] = path.get("body").unshiftContainer("body", newConstructor);
}
if (renamer) {
renamer(referenceVisitor, {
scope: constructor.scope
});
}
if (isDerived) {
const bareSupers = [];
constructor.traverse(findBareSupers, bareSupers);
let isFirst = true;
for (const bareSuper of bareSupers) {
if (isFirst) {
isFirst = false;
} else {
nodes = nodes.map(n => _core.types.cloneNode(n));
}
if (!bareSuper.parentPath.isExpressionStatement()) {
const allNodes = [bareSuper.node, ...nodes.map(n => _core.types.toExpression(n))];
if (!lastReturnsThis) allNodes.push(_core.types.thisExpression());
bareSuper.replaceWith(_core.types.sequenceExpression(allNodes));
} else {
bareSuper.insertAfter(nodes);
}
}
} else {
constructor.get("body").unshiftContainer("body", nodes);
}
}
// memoiseComputedKey
function memoiseComputedKey(keyNode, scope, hint) {
const isUidReference = _core.types.isIdentifier(keyNode) && scope.hasUid(keyNode.name);
if (isUidReference) {
return;
}
const isMemoiseAssignment = _core.types.isAssignmentExpression(keyNode, {
operator: "="
}) && _core.types.isIdentifier(keyNode.left) && scope.hasUid(keyNode.left.name);
if (isMemoiseAssignment) {
return _core.types.cloneNode(keyNode);
} else {
const ident = _core.types.identifier(hint);
scope.push({
id: ident,
kind: "let"
});
return _core.types.assignmentExpression("=", _core.types.cloneNode(ident), keyNode);
}
}

View file

@ -1,101 +0,0 @@
// FEATURES
[object Object]
// enableFeature
function enableFeature(file, feature, loose) {
if (!hasFeature(file, feature) || canIgnoreLoose(file, feature)) {
file.set(featuresKey, file.get(featuresKey) | feature);
if (loose === "#__internal__@babel/preset-env__prefer-true-but-false-is-ok-if-it-prevents-an-error") {
setLoose(file, feature, true);
file.set(looseLowPriorityKey, file.get(looseLowPriorityKey) | feature);
} else if (loose === "#__internal__@babel/preset-env__prefer-false-but-true-is-ok-if-it-prevents-an-error") {
setLoose(file, feature, false);
file.set(looseLowPriorityKey, file.get(looseLowPriorityKey) | feature);
} else {
setLoose(file, feature, loose);
}
}
let resolvedLoose;
for (const [mask, name] of featuresSameLoose) {
if (!hasFeature(file, mask)) continue;
{
if (canIgnoreLoose(file, mask)) continue;
}
const loose = isLoose(file, mask);
if (resolvedLoose === !loose) {
throw new Error("'loose' mode configuration must be the same for @babel/plugin-transform-class-properties, " + "@babel/plugin-transform-private-methods and " + "@babel/plugin-transform-private-property-in-object (when they are enabled)." + "\n\n" + getBabelShowConfigForHint(file));
} else {
resolvedLoose = loose;
{
var higherPriorityPluginName = name;
}
}
}
if (resolvedLoose !== undefined) {
for (const [mask, name] of featuresSameLoose) {
if (hasFeature(file, mask) && isLoose(file, mask) !== resolvedLoose) {
setLoose(file, mask, resolvedLoose);
console.warn(`Though the "loose" option was set to "${!resolvedLoose}" in your @babel/preset-env ` + `config, it will not be used for ${name} since the "loose" mode option was set to ` + `"${resolvedLoose}" for ${higherPriorityPluginName}.\nThe "loose" option must be the ` + `same for @babel/plugin-transform-class-properties, @babel/plugin-transform-private-methods ` + `and @babel/plugin-transform-private-property-in-object (when they are enabled): you can ` + `silence this warning by explicitly adding\n` + `\t["${name}", { "loose": ${resolvedLoose} }]\n` + `to the "plugins" section of your Babel config.` + "\n\n" + getBabelShowConfigForHint(file));
}
}
}
}
// isLoose
function isLoose(file, feature) {
return !!(file.get(looseKey) & feature);
}
// shouldTransform
function shouldTransform(path, file) {
let decoratorPath = null;
let publicFieldPath = null;
let privateFieldPath = null;
let privateMethodPath = null;
let staticBlockPath = null;
if ((0, _decorators.hasOwnDecorators)(path.node)) {
decoratorPath = path.get("decorators.0");
}
for (const el of path.get("body.body")) {
if (!decoratorPath && (0, _decorators.hasOwnDecorators)(el.node)) {
decoratorPath = el.get("decorators.0");
}
if (!publicFieldPath && el.isClassProperty()) {
publicFieldPath = el;
}
if (!privateFieldPath && el.isClassPrivateProperty()) {
privateFieldPath = el;
}
if (!privateMethodPath && el.isClassPrivateMethod != null && el.isClassPrivateMethod()) {
privateMethodPath = el;
}
if (!staticBlockPath && el.isStaticBlock != null && el.isStaticBlock()) {
staticBlockPath = el;
}
}
if (decoratorPath && privateFieldPath) {
throw privateFieldPath.buildCodeFrameError("Private fields in decorated classes are not supported yet.");
}
if (decoratorPath && privateMethodPath) {
throw privateMethodPath.buildCodeFrameError("Private methods in decorated classes are not supported yet.");
}
if (decoratorPath && !hasFeature(file, FEATURES.decorators)) {
throw path.buildCodeFrameError("Decorators are not enabled." + "\nIf you are using " + '["@babel/plugin-proposal-decorators", { "version": "legacy" }], ' + 'make sure it comes *before* "@babel/plugin-transform-class-properties" ' + "and enable loose mode, like so:\n" + '\t["@babel/plugin-proposal-decorators", { "version": "legacy" }]\n' + '\t["@babel/plugin-transform-class-properties", { "loose": true }]');
}
if (privateMethodPath && !hasFeature(file, FEATURES.privateMethods)) {
throw privateMethodPath.buildCodeFrameError("Class private methods are not enabled. " + "Please add `@babel/plugin-transform-private-methods` to your configuration.");
}
if ((publicFieldPath || privateFieldPath) && !hasFeature(file, FEATURES.fields) && !hasFeature(file, FEATURES.privateMethods)) {
throw path.buildCodeFrameError("Class fields are not enabled. " + "Please add `@babel/plugin-transform-class-properties` to your configuration.");
}
if (staticBlockPath && !hasFeature(file, FEATURES.staticBlocks)) {
throw path.buildCodeFrameError("Static class blocks are not enabled. " + "Please add `@babel/plugin-transform-class-static-block` to your configuration.");
}
if (decoratorPath || privateMethodPath || staticBlockPath) {
return true;
}
if ((publicFieldPath || privateFieldPath) && hasFeature(file, FEATURES.fields)) {
return true;
}
return false;
}

View file

@ -1,53 +0,0 @@
// EXPORTED_CONST_ENUMS_IN_NAMESPACE
[object WeakSet]
// default
function transpileConstEnum(path, t) {
const {
name
} = path.node.id;
const parentIsExport = path.parentPath.isExportNamedDeclaration();
let isExported = parentIsExport;
if (!isExported && t.isProgram(path.parent)) {
isExported = path.parent.body.some(stmt => t.isExportNamedDeclaration(stmt) && stmt.exportKind !== "type" && !stmt.source && stmt.specifiers.some(spec => t.isExportSpecifier(spec) && spec.exportKind !== "type" && spec.local.name === name));
}
const {
enumValues: entries
} = (0, _enum.translateEnumValues)(path, t);
if (isExported || EXPORTED_CONST_ENUMS_IN_NAMESPACE.has(path.node)) {
const obj = t.objectExpression(entries.map(([name, value]) => t.objectProperty(t.isValidIdentifier(name) ? t.identifier(name) : t.stringLiteral(name), value)));
if (path.scope.hasOwnBinding(name)) {
(parentIsExport ? path.parentPath : path).replaceWith(t.expressionStatement(t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("assign")), [path.node.id, obj])));
} else {
path.replaceWith(t.variableDeclaration("var", [t.variableDeclarator(path.node.id, obj)]));
path.scope.registerDeclaration(path);
}
return;
}
const entriesMap = new Map(entries);
path.scope.path.traverse({
Scope(path) {
if (path.scope.hasOwnBinding(name)) path.skip();
},
MemberExpression(path) {
if (!t.isIdentifier(path.node.object, {
name
})) return;
let key;
if (path.node.computed) {
if (t.isStringLiteral(path.node.property)) {
key = path.node.property.value;
} else {
return;
}
} else if (t.isIdentifier(path.node.property)) {
key = path.node.property.name;
} else {
return;
}
if (!entriesMap.has(key)) return;
path.replaceWith(t.cloneNode(entriesMap.get(key)));
}
});
path.remove();
}

View file

@ -1,138 +0,0 @@
// default
function transpileEnum(path, t) {
const {
node,
parentPath
} = path;
if (node.declare) {
path.remove();
return;
}
const name = node.id.name;
const {
fill,
data,
isPure
} = enumFill(path, t, node.id);
switch (parentPath.type) {
case "BlockStatement":
case "ExportNamedDeclaration":
case "Program":
{
const isGlobal = t.isProgram(path.parent);
const isSeen = seen(parentPath);
let init = t.objectExpression([]);
if (isSeen || isGlobal) {
init = t.logicalExpression("||", t.cloneNode(fill.ID), init);
}
const enumIIFE = buildEnumWrapper(Object.assign({}, fill, {
INIT: init
}));
if (isPure) (0, _helperAnnotateAsPure.default)(enumIIFE);
if (isSeen) {
const toReplace = parentPath.isExportDeclaration() ? parentPath : path;
toReplace.replaceWith(t.expressionStatement(t.assignmentExpression("=", t.cloneNode(node.id), enumIIFE)));
} else {
path.scope.registerDeclaration(path.replaceWith(t.variableDeclaration(isGlobal ? "var" : "let", [t.variableDeclarator(node.id, enumIIFE)]))[0]);
}
ENUMS.set(path.scope.getBindingIdentifier(name), data);
break;
}
default:
throw new Error(`Unexpected enum parent '${path.parent.type}`);
}
function seen(parentPath) {
if (parentPath.isExportDeclaration()) {
return seen(parentPath.parentPath);
}
if (parentPath.getData(name)) {
return true;
} else {
parentPath.setData(name, true);
return false;
}
}
}
// isSyntacticallyString
function isSyntacticallyString(expr) {
expr = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrapperNodes)(expr);
switch (expr.type) {
case "BinaryExpression":
{
const left = expr.left;
const right = expr.right;
return expr.operator === "+" && (isSyntacticallyString(left) || isSyntacticallyString(right));
}
case "TemplateLiteral":
case "StringLiteral":
return true;
}
return false;
}
// translateEnumValues
function translateEnumValues(path, t) {
var _ENUMS$get;
const bindingIdentifier = path.scope.getBindingIdentifier(path.node.id.name);
const seen = (_ENUMS$get = ENUMS.get(bindingIdentifier)) != null ? _ENUMS$get : new Map();
let constValue = -1;
let lastName;
let isPure = true;
const enumMembers = path.get("members");
const enumValues = enumMembers.map(memberPath => {
const member = memberPath.node;
const name = t.isIdentifier(member.id) ? member.id.name : member.id.value;
const initializerPath = memberPath.get("initializer");
const initializer = member.initializer;
let value;
if (initializer) {
constValue = computeConstantValue(initializerPath, seen);
if (constValue !== undefined) {
seen.set(name, constValue);
_assert(typeof constValue === "number" || typeof constValue === "string");
if (constValue === Infinity || Number.isNaN(constValue)) {
value = t.identifier(String(constValue));
} else if (constValue === -Infinity) {
value = t.unaryExpression("-", t.identifier("Infinity"));
} else {
value = t.valueToNode(constValue);
}
} else {
isPure && (isPure = initializerPath.isPure());
if (initializerPath.isReferencedIdentifier()) {
ReferencedIdentifier(initializerPath, {
t,
seen,
path
});
} else {
initializerPath.traverse(enumSelfReferenceVisitor, {
t,
seen,
path
});
}
value = initializerPath.node;
seen.set(name, undefined);
}
} else if (typeof constValue === "number") {
constValue += 1;
value = t.numericLiteral(constValue);
seen.set(name, constValue);
} else if (typeof constValue === "string") {
throw path.buildCodeFrameError("Enum member must have initializer.");
} else {
const lastRef = t.memberExpression(t.cloneNode(path.node.id), t.stringLiteral(lastName), true);
value = t.binaryExpression("+", t.numericLiteral(1), lastRef);
seen.set(name, undefined);
}
lastName = name;
return [name, value];
});
return {
isPure,
data: seen,
enumValues
};
}

View file

@ -1,17 +0,0 @@
// GLOBAL_TYPES
[object WeakMap]
// isGlobalType
function isGlobalType({
scope
}, name) {
if (scope.hasBinding(name)) return false;
if (GLOBAL_TYPES.get(scope).has(name)) return true;
console.warn(`The exported identifier "${name}" is not declared in Babel's scope tracker\n` + `as a JavaScript value binding, and "@babel/plugin-transform-typescript"\n` + `never encountered it as a TypeScript type declaration.\n` + `It will be treated as a JavaScript value.\n\n` + `This problem is likely caused by another plugin injecting\n` + `"${name}" without registering it in the scope tracker. If you are the author\n` + ` of that plugin, please use "scope.registerDeclaration(declarationPath)".`);
return false;
}
// registerGlobalType
function registerGlobalType(programScope, name) {
GLOBAL_TYPES.get(programScope).add(name);
}

View file

@ -1,44 +0,0 @@
// makeConfigAPI
function makeConfigAPI(cache) {
const env = value => cache.using(data => {
if (value === undefined) return data.envName;
if (typeof value === "function") {
return (0, _caching.assertSimpleType)(value(data.envName));
}
return (Array.isArray(value) ? value : [value]).some(entry => {
if (typeof entry !== "string") {
throw new Error("Unexpected non-string value");
}
return entry === data.envName;
});
});
const caller = cb => cache.using(data => (0, _caching.assertSimpleType)(cb(data.caller)));
return {
version: _index.version,
cache: cache.simple(),
env,
async: () => false,
caller,
assertVersion
};
}
// makePluginAPI
function makePluginAPI(cache, externalDependencies) {
const assumption = name => cache.using(data => data.assumptions[name]);
return Object.assign({}, makePresetAPI(cache, externalDependencies), {
assumption
});
}
// makePresetAPI
function makePresetAPI(cache, externalDependencies) {
const targets = () => JSON.parse(cache.using(data => JSON.stringify(data.targets)));
const addExternalDependency = ref => {
externalDependencies.push(ref);
};
return Object.assign({}, makeConfigAPI(cache), {
targets,
addExternalDependency
});
}

View file

@ -1,47 +0,0 @@
// default
function* loadCodeDefault(filepath, loader, esmError, tlaError) {
let async;
const ext = _path().extname(filepath);
const isTS = ext === ".ts" || ext === ".cts" || ext === ".mts";
const type = SUPPORTED_EXTENSIONS[hasOwnProperty.call(SUPPORTED_EXTENSIONS, ext) ? ext : ".js"];
const pattern = `${loader} ${type}`;
switch (pattern) {
case "require cjs":
case "auto cjs":
if (isTS) {
return ensureTsSupport(filepath, ext, () => loadCjsDefault(filepath));
} else {
return loadCjsDefault(filepath, arguments[2]);
}
case "auto unknown":
case "require unknown":
case "require esm":
try {
if (isTS) {
return ensureTsSupport(filepath, ext, () => loadCjsDefault(filepath));
} else {
return loadCjsDefault(filepath, arguments[2]);
}
} catch (e) {
if (e.code === "ERR_REQUIRE_ASYNC_MODULE" || e.code === "ERR_REQUIRE_CYCLE_MODULE" && asyncModules.has(filepath)) {
asyncModules.add(filepath);
if (!(async != null ? async : async = yield* (0, _async.isAsync)())) {
throw new _configError.default(tlaError, filepath);
}
} else if (e.code === "ERR_REQUIRE_ESM" || type === "esm") {} else {
throw e;
}
}
case "auto esm":
if (async != null ? async : async = yield* (0, _async.isAsync)()) {
const promise = isTS ? ensureTsSupport(filepath, ext, () => loadMjsFromPath(filepath)) : loadMjsFromPath(filepath);
return (yield* (0, _async.waitFor)(promise)).default;
}
throw new _configError.default(esmError, filepath);
default:
throw new Error("Internal Babel error: unreachable code.");
}
}
// supportsESM
true

View file

@ -1,14 +0,0 @@
// transformFile
function transformFile(...args) {
transformFileRunner.errback(...args);
}
// transformFileAsync
function transformFileAsync(...args) {
return transformFileRunner.async(...args);
}
// transformFileSync
function transformFileSync(...args) {
return transformFileRunner.sync(...args);
}

View file

@ -1,73 +0,0 @@
// createConfigItem
function createConfigItem(target, options, callback) {
if (callback !== undefined) {
(0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.errback)(target, options, callback);
} else if (typeof options === "function") {
(0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.errback)(target, undefined, callback);
} else {
{
return createConfigItemSync(target, options);
}
}
}
// createConfigItemAsync
function createConfigItemAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.async)(...args);
}
// createConfigItemSync
function createConfigItemSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.sync)(...args);
}
// default
function(...args) {
return genFn.apply(this, args);
}
// loadOptions
function loadOptions(opts, callback) {
if (callback !== undefined) {
(0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.errback)(opts, callback);
} else if (typeof opts === "function") {
(0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.errback)(undefined, opts);
} else {
{
return loadOptionsSync(opts);
}
}
}
// loadOptionsAsync
function loadOptionsAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.async)(...args);
}
// loadOptionsSync
function loadOptionsSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.sync)(...args);
}
// loadPartialConfig
function loadPartialConfig(opts, callback) {
if (callback !== undefined) {
(0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.errback)(opts, callback);
} else if (typeof opts === "function") {
(0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.errback)(undefined, opts);
} else {
{
return loadPartialConfigSync(opts);
}
}
}
// loadPartialConfigAsync
function loadPartialConfigAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.async)(...args);
}
// loadPartialConfigSync
function loadPartialConfigSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.sync)(...args);
}

View file

@ -1,4 +0,0 @@
// default
function(...args) {
return genFn.apply(this, args);
}

View file

@ -1,23 +0,0 @@
// default
class Plugin {
constructor(plugin, options, key, externalDependencies = (0, _deepArray.finalize)([])) {
this.key = void 0;
this.manipulateOptions = void 0;
this.post = void 0;
this.pre = void 0;
this.visitor = void 0;
this.parserOverride = void 0;
this.generatorOverride = void 0;
this.options = void 0;
this.externalDependencies = void 0;
this.key = plugin.name || key;
this.manipulateOptions = plugin.manipulateOptions;
this.post = plugin.post;
this.pre = plugin.pre;
this.visitor = plugin.visitor || {};
this.parserOverride = plugin.parserOverride;
this.generatorOverride = plugin.generatorOverride;
this.options = options;
this.externalDependencies = externalDependencies;
}
}

View file

@ -1,16 +0,0 @@
// finalize
function finalize(deepArr) {
return Object.freeze(deepArr);
}
// flattenToSet
function flattenToSet(arr) {
const result = new Set();
const stack = [arr];
while (stack.length > 0) {
for (const el of stack.pop()) {
if (Array.isArray(el)) stack.push(el);else result.add(el);
}
}
return result;
}

View file

@ -1,24 +0,0 @@
// createConfigItem
function* createConfigItem(value, {
dirname = ".",
type
} = {}) {
const descriptor = yield* (0, _configDescriptors.createDescriptor)(value, _path().resolve(dirname), {
type,
alias: "programmatic item"
});
return createItemFromDescriptor(descriptor);
}
// createItemFromDescriptor
function createItemFromDescriptor(desc) {
return new ConfigItem(desc);
}
// getItemDescriptor
function getItemDescriptor(item) {
if (item != null && item[CONFIG_ITEM_BRAND]) {
return item._descriptor;
}
return undefined;
}

View file

@ -1,86 +0,0 @@
// createCachedDescriptors
function createCachedDescriptors(dirname, options, alias) {
const {
plugins,
presets,
passPerPreset
} = options;
return {
options: optionsWithResolvedBrowserslistConfigFile(options, dirname),
plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => handlerOf([]),
presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => handlerOf([])
};
}
// createDescriptor
function* createDescriptor(pair, dirname, {
type,
alias,
ownPass
}) {
const desc = (0, _item.getItemDescriptor)(pair);
if (desc) {
return desc;
}
let name;
let options;
let value = pair;
if (Array.isArray(value)) {
if (value.length === 3) {
[value, options, name] = value;
} else {
[value, options] = value;
}
}
let file = undefined;
let filepath = null;
if (typeof value === "string") {
if (typeof type !== "string") {
throw new Error("To resolve a string-based item, the type of item must be given");
}
const resolver = type === "plugin" ? _index.loadPlugin : _index.loadPreset;
const request = value;
({
filepath,
value
} = yield* resolver(value, dirname));
file = {
request,
resolved: filepath
};
}
if (!value) {
throw new Error(`Unexpected falsy value: ${String(value)}`);
}
if (typeof value === "object" && value.__esModule) {
if (value.default) {
value = value.default;
} else {
throw new Error("Must export a default export when using ES6 modules.");
}
}
if (typeof value !== "object" && typeof value !== "function") {
throw new Error(`Unsupported format: ${typeof value}. Expected an object or a function.`);
}
if (filepath !== null && typeof value === "object" && value) {
throw new Error(`Plugin/Preset files are not allowed to export objects, only functions. In ${filepath}`);
}
return {
name,
alias: filepath || alias,
value,
options,
dirname,
ownPass,
file
};
}
// createUncachedDescriptors
function createUncachedDescriptors(dirname, options, alias) {
return {
options: optionsWithResolvedBrowserslistConfigFile(options, dirname),
plugins: (0, _functional.once)(() => createPluginDescriptors(options.plugins || [], dirname, alias)),
presets: (0, _functional.once)(() => createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset))
};
}

View file

@ -1,49 +0,0 @@
// once
function once(fn) {
let result;
let resultP;
let promiseReferenced = false;
return function* () {
if (!result) {
if (resultP) {
promiseReferenced = true;
return yield* (0, _async.waitFor)(resultP);
}
if (!(yield* (0, _async.isAsync)())) {
try {
result = {
ok: true,
value: yield* fn()
};
} catch (error) {
result = {
ok: false,
value: error
};
}
} else {
let resolve, reject;
resultP = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
try {
result = {
ok: true,
value: yield* fn()
};
resultP = null;
if (promiseReferenced) resolve(result.value);
} catch (error) {
result = {
ok: false,
value: error
};
resultP = null;
if (promiseReferenced) reject(error);
}
}
}
if (result.ok) return result.value;else throw result.value;
};
}

View file

@ -1,39 +0,0 @@
// resolveBrowserslistConfigFile
function resolveBrowserslistConfigFile(browserslistConfigFile, configFileDir) {
return _path().resolve(configFileDir, browserslistConfigFile);
}
// resolveTargets
function resolveTargets(options, root) {
const optTargets = options.targets;
let targets;
if (typeof optTargets === "string" || Array.isArray(optTargets)) {
targets = {
browsers: optTargets
};
} else if (optTargets) {
if ("esmodules" in optTargets) {
targets = Object.assign({}, optTargets, {
esmodules: "intersect"
});
} else {
targets = optTargets;
}
}
const {
browserslistConfigFile
} = options;
let configFile;
let ignoreBrowserslistConfig = false;
if (typeof browserslistConfigFile === "string") {
configFile = browserslistConfigFile;
} else {
ignoreBrowserslistConfig = browserslistConfigFile === false;
}
return (0, _helperCompilationTargets().default)(targets, {
ignoreBrowserslistConfig,
configFile,
configPath: root,
browserslistEnv: options.browserslistEnv
});
}

View file

@ -1,162 +0,0 @@
// buildPresetChain
function* buildPresetChain(arg, context) {
const chain = yield* buildPresetChainWalker(arg, context);
if (!chain) return null;
return {
plugins: dedupDescriptors(chain.plugins),
presets: dedupDescriptors(chain.presets),
options: chain.options.map(o => normalizeOptions(o)),
files: new Set()
};
}
// buildPresetChainWalker
function* chainWalker(input, context, files = new Set(), baseLogger) {
const {
dirname
} = input;
const flattenedConfigs = [];
const rootOpts = root(input);
if (configIsApplicable(rootOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: rootOpts,
envName: undefined,
index: undefined
});
const envOpts = env(input, context.envName);
if (envOpts && configIsApplicable(envOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: envOpts,
envName: context.envName,
index: undefined
});
}
(rootOpts.options.overrides || []).forEach((_, index) => {
const overrideOps = overrides(input, index);
if (configIsApplicable(overrideOps, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: overrideOps,
index,
envName: undefined
});
const overrideEnvOpts = overridesEnv(input, index, context.envName);
if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: overrideEnvOpts,
index,
envName: context.envName
});
}
}
});
}
if (flattenedConfigs.some(({
config: {
options: {
ignore,
only
}
}
}) => shouldIgnore(context, ignore, only, dirname))) {
return null;
}
const chain = emptyChain();
const logger = createLogger(input, context, baseLogger);
for (const {
config,
index,
envName
} of flattenedConfigs) {
if (!(yield* mergeExtendsChain(chain, config.options, dirname, context, files, baseLogger))) {
return null;
}
logger(config, index, envName);
yield* mergeChainOpts(chain, config);
}
return chain;
}
// buildRootChain
function* buildRootChain(opts, context) {
let configReport, babelRcReport;
const programmaticLogger = new _printer.ConfigPrinter();
const programmaticChain = yield* loadProgrammaticChain({
options: opts,
dirname: context.cwd
}, context, undefined, programmaticLogger);
if (!programmaticChain) return null;
const programmaticReport = yield* programmaticLogger.output();
let configFile;
if (typeof opts.configFile === "string") {
configFile = yield* (0, _index.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller);
} else if (opts.configFile !== false) {
configFile = yield* (0, _index.findRootConfig)(context.root, context.envName, context.caller);
}
let {
babelrc,
babelrcRoots
} = opts;
let babelrcRootsDirectory = context.cwd;
const configFileChain = emptyChain();
const configFileLogger = new _printer.ConfigPrinter();
if (configFile) {
const validatedFile = validateConfigFile(configFile);
const result = yield* loadFileChain(validatedFile, context, undefined, configFileLogger);
if (!result) return null;
configReport = yield* configFileLogger.output();
if (babelrc === undefined) {
babelrc = validatedFile.options.babelrc;
}
if (babelrcRoots === undefined) {
babelrcRootsDirectory = validatedFile.dirname;
babelrcRoots = validatedFile.options.babelrcRoots;
}
mergeChain(configFileChain, result);
}
let ignoreFile, babelrcFile;
let isIgnored = false;
const fileChain = emptyChain();
if ((babelrc === true || babelrc === undefined) && typeof context.filename === "string") {
const pkgData = yield* (0, _index.findPackageData)(context.filename);
if (pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)) {
({
ignore: ignoreFile,
config: babelrcFile
} = yield* (0, _index.findRelativeConfig)(pkgData, context.envName, context.caller));
if (ignoreFile) {
fileChain.files.add(ignoreFile.filepath);
}
if (ignoreFile && shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)) {
isIgnored = true;
}
if (babelrcFile && !isIgnored) {
const validatedFile = validateBabelrcFile(babelrcFile);
const babelrcLogger = new _printer.ConfigPrinter();
const result = yield* loadFileChain(validatedFile, context, undefined, babelrcLogger);
if (!result) {
isIgnored = true;
} else {
babelRcReport = yield* babelrcLogger.output();
mergeChain(fileChain, result);
}
}
if (babelrcFile && isIgnored) {
fileChain.files.add(babelrcFile.filepath);
}
}
}
if (context.showConfig) {
console.log(`Babel configs on "${context.filename}" (ascending priority):\n` + [configReport, babelRcReport, programmaticReport].filter(x => !!x).join("\n\n") + "\n-----End Babel configs-----");
}
const chain = mergeChain(mergeChain(mergeChain(emptyChain(), configFileChain), fileChain), programmaticChain);
return {
plugins: isIgnored ? [] : dedupDescriptors(chain.plugins),
presets: isIgnored ? [] : dedupDescriptors(chain.presets),
options: isIgnored ? [] : chain.options.map(o => normalizeOptions(o)),
fileHandling: isIgnored ? "ignored" : "transpile",
ignore: ignoreFile || undefined,
babelrc: babelrcFile || undefined,
config: configFile || undefined,
files: chain.files
};
}

View file

@ -1,26 +0,0 @@
// assumptionsNames
[object Set]
// checkNoUnwrappedItemOptionPairs
function checkNoUnwrappedItemOptionPairs(items, index, type, e) {
if (index === 0) return;
const lastItem = items[index - 1];
const thisItem = items[index];
if (lastItem.file && lastItem.options === undefined && typeof thisItem.value === "object") {
e.message += `\n- Maybe you meant to use\n` + `"${type}s": [\n ["${lastItem.file.request}", ${JSON.stringify(thisItem.value, undefined, 2)}]\n]\n` + `To be a valid ${type}, its name and options should be wrapped in a pair of brackets`;
}
}
// validate
function validate(type, opts, filename) {
try {
return validateNested({
type: "root",
source: type
}, opts);
} catch (error) {
const configError = new _configError.default(error.message, filename);
if (error.code) configError.code = error.code;
throw configError;
}
}

View file

@ -1,2 +0,0 @@
// default
[object Object]

View file

@ -1,229 +0,0 @@
// access
function access(loc, name) {
return {
type: "access",
name,
parent: loc
};
}
// assertArray
function assertArray(loc, value) {
if (value != null && !Array.isArray(value)) {
throw new Error(`${msg(loc)} must be an array, or undefined`);
}
return value;
}
// assertAssumptions
function assertAssumptions(loc, value) {
if (value === undefined) return;
if (typeof value !== "object" || value === null) {
throw new Error(`${msg(loc)} must be an object or undefined.`);
}
let root = loc;
do {
root = root.parent;
} while (root.type !== "root");
const inPreset = root.source === "preset";
for (const name of Object.keys(value)) {
const subLoc = access(loc, name);
if (!_options.assumptionsNames.has(name)) {
throw new Error(`${msg(subLoc)} is not a supported assumption.`);
}
if (typeof value[name] !== "boolean") {
throw new Error(`${msg(subLoc)} must be a boolean.`);
}
if (inPreset && value[name] === false) {
throw new Error(`${msg(subLoc)} cannot be set to 'false' inside presets.`);
}
}
return value;
}
// assertBabelrcSearch
function assertBabelrcSearch(loc, value) {
if (value === undefined || typeof value === "boolean") {
return value;
}
if (Array.isArray(value)) {
value.forEach((item, i) => {
if (!checkValidTest(item)) {
throw new Error(`${msg(access(loc, i))} must be a string/Function/RegExp.`);
}
});
} else if (!checkValidTest(value)) {
throw new Error(`${msg(loc)} must be a undefined, a boolean, a string/Function/RegExp ` + `or an array of those, got ${JSON.stringify(value)}`);
}
return value;
}
// assertBoolean
function assertBoolean(loc, value) {
if (value !== undefined && typeof value !== "boolean") {
throw new Error(`${msg(loc)} must be a boolean, or undefined`);
}
return value;
}
// assertCallerMetadata
function assertCallerMetadata(loc, value) {
const obj = assertObject(loc, value);
if (obj) {
if (typeof obj.name !== "string") {
throw new Error(`${msg(loc)} set but does not contain "name" property string`);
}
for (const prop of Object.keys(obj)) {
const propLoc = access(loc, prop);
const value = obj[prop];
if (value != null && typeof value !== "boolean" && typeof value !== "string" && typeof value !== "number") {
throw new Error(`${msg(propLoc)} must be null, undefined, a boolean, a string, or a number.`);
}
}
}
return value;
}
// assertCompact
function assertCompact(loc, value) {
if (value !== undefined && typeof value !== "boolean" && value !== "auto") {
throw new Error(`${msg(loc)} must be a boolean, "auto", or undefined`);
}
return value;
}
// assertConfigApplicableTest
function assertConfigApplicableTest(loc, value) {
if (value === undefined) {
return value;
}
if (Array.isArray(value)) {
value.forEach((item, i) => {
if (!checkValidTest(item)) {
throw new Error(`${msg(access(loc, i))} must be a string/Function/RegExp.`);
}
});
} else if (!checkValidTest(value)) {
throw new Error(`${msg(loc)} must be a string/Function/RegExp, or an array of those`);
}
return value;
}
// assertConfigFileSearch
function assertConfigFileSearch(loc, value) {
if (value !== undefined && typeof value !== "boolean" && typeof value !== "string") {
throw new Error(`${msg(loc)} must be a undefined, a boolean, a string, ` + `got ${JSON.stringify(value)}`);
}
return value;
}
// assertFunction
function assertFunction(loc, value) {
if (value !== undefined && typeof value !== "function") {
throw new Error(`${msg(loc)} must be a function, or undefined`);
}
return value;
}
// assertIgnoreList
function assertIgnoreList(loc, value) {
const arr = assertArray(loc, value);
arr == null || arr.forEach((item, i) => assertIgnoreItem(access(loc, i), item));
return arr;
}
// assertInputSourceMap
function assertInputSourceMap(loc, value) {
if (value !== undefined && typeof value !== "boolean" && (typeof value !== "object" || !value)) {
throw new Error(`${msg(loc)} must be a boolean, object, or undefined`);
}
return value;
}
// assertObject
function assertObject(loc, value) {
if (value !== undefined && (typeof value !== "object" || Array.isArray(value) || !value)) {
throw new Error(`${msg(loc)} must be an object, or undefined`);
}
return value;
}
// assertPluginList
function assertPluginList(loc, value) {
const arr = assertArray(loc, value);
if (arr) {
arr.forEach((item, i) => assertPluginItem(access(loc, i), item));
}
return arr;
}
// assertRootMode
function assertRootMode(loc, value) {
if (value !== undefined && value !== "root" && value !== "upward" && value !== "upward-optional") {
throw new Error(`${msg(loc)} must be a "root", "upward", "upward-optional" or undefined`);
}
return value;
}
// assertSourceMaps
function assertSourceMaps(loc, value) {
if (value !== undefined && typeof value !== "boolean" && value !== "inline" && value !== "both") {
throw new Error(`${msg(loc)} must be a boolean, "inline", "both", or undefined`);
}
return value;
}
// assertSourceType
function assertSourceType(loc, value) {
if (value !== undefined && value !== "module" && value !== "script" && value !== "unambiguous") {
throw new Error(`${msg(loc)} must be "module", "script", "unambiguous", or undefined`);
}
return value;
}
// assertString
function assertString(loc, value) {
if (value !== undefined && typeof value !== "string") {
throw new Error(`${msg(loc)} must be a string, or undefined`);
}
return value;
}
// assertTargets
function assertTargets(loc, value) {
if ((0, _helperCompilationTargets().isBrowsersQueryValid)(value)) return value;
if (typeof value !== "object" || !value || Array.isArray(value)) {
throw new Error(`${msg(loc)} must be a string, an array of strings or an object`);
}
const browsersLoc = access(loc, "browsers");
const esmodulesLoc = access(loc, "esmodules");
assertBrowsersList(browsersLoc, value.browsers);
assertBoolean(esmodulesLoc, value.esmodules);
for (const key of Object.keys(value)) {
const val = value[key];
const subLoc = access(loc, key);
if (key === "esmodules") assertBoolean(subLoc, val);else if (key === "browsers") assertBrowsersList(subLoc, val);else if (!hasOwnProperty.call(_helperCompilationTargets().TargetNames, key)) {
const validTargets = Object.keys(_helperCompilationTargets().TargetNames).join(", ");
throw new Error(`${msg(subLoc)} is not a valid target. Supported targets are ${validTargets}`);
} else assertBrowserVersion(subLoc, val);
}
return value;
}
// msg
function msg(loc) {
switch (loc.type) {
case "root":
return ``;
case "env":
return `${msg(loc.parent)}.env["${loc.name}"]`;
case "overrides":
return `${msg(loc.parent)}.overrides[${loc.index}]`;
case "option":
return `${msg(loc.parent)}.${loc.name}`;
case "access":
return `${msg(loc.parent)}[${JSON.stringify(loc.name)}]`;
default:
throw new Error(`Assertion failure: Unknown type ${loc.type}`);
}
}

View file

@ -1,13 +0,0 @@
// default
function pathToPattern(pattern, dirname) {
const parts = _path().resolve(dirname, pattern).split(_path().sep);
return new RegExp(["^", ...parts.map((part, i) => {
const last = i === parts.length - 1;
if (part === "**") return last ? starStarPatLast : starStarPat;
if (part === "*") return last ? starPatLast : starPat;
if (part.indexOf("*.") === 0) {
return substitution + escapeRegExp(part.slice(1)) + (last ? endSep : sep);
}
return escapeRegExp(part) + (last ? endSep : sep);
})].join(""));
}

View file

@ -1,37 +0,0 @@
// ChainFormatter
[object Object]
// ConfigPrinter
class ConfigPrinter {
constructor() {
this._stack = [];
}
configure(enabled, type, {
callerName,
filepath
}) {
if (!enabled) return () => {};
return (content, index, envName) => {
this._stack.push({
type,
callerName,
filepath,
content,
index,
envName
});
};
}
static *format(config) {
let title = Formatter.title(config.type, config.callerName, config.filepath);
const loc = Formatter.loc(config.index, config.envName);
if (loc) title += ` ${loc}`;
const content = yield* Formatter.optionsAndDescriptors(config.content);
return `${title}\n${content}`;
}
*output() {
if (this._stack.length === 0) return "";
const configs = yield* _gensync().all(this._stack.map(s => ConfigPrinter.format(s)));
return configs.join("\n\n");
}
}

View file

@ -1,23 +0,0 @@
// validatePluginObject
function validatePluginObject(obj) {
const rootPath = {
type: "root",
source: "plugin"
};
Object.keys(obj).forEach(key => {
const validator = VALIDATORS[key];
if (validator) {
const optLoc = {
type: "option",
name: key,
parent: rootPath
};
validator(optLoc, obj[key]);
} else {
const invalidPluginPropertyError = new Error(`.${key} is not a valid Plugin property`);
invalidPluginPropertyError.code = "BABEL_UNKNOWN_PLUGIN_PROPERTY";
throw invalidPluginPropertyError;
}
});
return obj;
}

View file

@ -1,4 +0,0 @@
// getEnv
function getEnv(defaultValue = "development") {
return process.env.BABEL_ENV || process.env.NODE_ENV || defaultValue;
}

File diff suppressed because it is too large Load diff

View file

@ -1,30 +0,0 @@
// __esModule
true
// getFile
function getFile() {
if (currentFile) {
return currentFile;
}
throw new Error("Unable to access Marko File outside of a compilation");
}
// getFileInternal
function getFileInternal() {
return currentFile;
}
// getProgram
function getProgram() {
if (currentFile) {
return currentFile.path;
}
throw new Error("Unable to access Marko Program outside of a compilation");
}
// setFileInternal
function setFileInternal(file) {
return currentFile = file;
}

View file

@ -1,13 +0,0 @@
import { Script } from "#sitegen";
export interface Input {
script: string;
}
<Script src="./canvas.client.ts" />;
<canvas#canvas
data-canvas=script
data-standalone="true"
style="position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;"
/>

View file

@ -1,25 +0,0 @@
// __esModule
true
// DiagnosticType
[object Object]
// diagnosticDeprecate
function diagnosticDeprecate(path, options) {
add(DiagnosticType.Deprecation, path, options);
}
// diagnosticError
function diagnosticError(path, options) {
add(DiagnosticType.Error, path, options);
}
// diagnosticSuggest
function diagnosticSuggest(path, options) {
add(DiagnosticType.Suggestion, path, options);
}
// diagnosticWarn
function diagnosticWarn(path, options) {
add(DiagnosticType.Warning, path, options);
}

View file

@ -1,33 +0,0 @@
// default
class PluginPass {
constructor(file, key, options, isAsync) {
this._map = new Map();
this.key = void 0;
this.file = void 0;
this.opts = void 0;
this.cwd = void 0;
this.filename = void 0;
this.isAsync = void 0;
this.key = key;
this.file = file;
this.opts = options || {};
this.cwd = file.opts.cwd;
this.filename = file.opts.filename;
this.isAsync = isAsync;
}
set(key, val) {
this._map.set(key, val);
}
get(key) {
return this._map.get(key);
}
availableHelper(name, versionRange) {
return this.file.availableHelper(name, versionRange);
}
addHelper(name) {
return this.file.addHelper(name);
}
buildCodeFrameError(node, msg, _Error) {
return this.file.buildCodeFrameError(node, msg, _Error);
}
}

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -1,8 +0,0 @@
// default
class ConfigError extends Error {
constructor(message, filename) {
super(message);
(0, _rewriteStackTrace.expectedError)(this);
if (filename) (0, _rewriteStackTrace.injectVirtualStackFrame)(this, filename);
}
}

Binary file not shown.

Binary file not shown.

View file

@ -1,126 +1,57 @@
// __esModule
true
// importDefault
function importDefault(file, request, nameHint) {
const imports = getImports(file);
request = resolveRelativePath(file, request);
let importDeclaration = imports.get(request);
if (!importDeclaration) {
imports.set(
request,
importDeclaration = file.path.pushContainer(
"body",
_compiler.types.importDeclaration([], _compiler.types.stringLiteral(request))
)[0]
);
async function qaDate(el: HTMLAnchorElement) {
if (el.hasAttribute("data-copy-state")) return;
const time = el.children[0] as HTMLTimeElement;
const prevText = time.textContent;
const url = `${window.location.origin}/q+a/${
time.dateTime.replace(/[^\d]/g, "").slice(2, 12)
}`;
el.setAttribute("data-copy-state", "1");
try {
await navigator.clipboard.writeText(url);
time.textContent = "copied permalink to question";
time.classList.add("winner");
} catch (error) {
time.textContent = "failed to copy :(";
}
if (!nameHint) {
return;
}
const specifiers = importDeclaration.get("specifiers");
const specifier = specifiers.find((specifier) =>
specifier.isImportDefaultSpecifier()
setTimeout(() => {
el.removeAttribute("data-copy-state");
time.textContent = prevText;
time.classList.remove("winner");
}, 1500);
}
requestAnimationFrame(() => {
// Make every link clickable
document.querySelectorAll("e-").forEach((questionRoot) =>
(questionRoot.querySelector("a:not([href])") as HTMLAnchorElement).href =
"#"
);
if (!specifier) {
const identifier = file.scope.generateUidIdentifier(nameHint);
importDeclaration.pushContainer(
"specifiers",
_compiler.types.importDefaultSpecifier(identifier)
);
return identifier;
}
return _compiler.types.identifier(specifier.node.local.name);
}
// importNamed
function importNamed(file, request, name, nameHint = name) {
request = resolveRelativePath(file, request);
const imports = getImports(file);
let importDeclaration = imports.get(request);
if (!importDeclaration) {
imports.set(
request,
importDeclaration = file.path.pushContainer(
"body",
_compiler.types.importDeclaration([], _compiler.types.stringLiteral(request))
)[0]
);
}
const specifiers = importDeclaration.get("specifiers");
const specifier = specifiers.find(
(specifier) =>
specifier.isImportSpecifier() && specifier.node.imported.name === name
// Avoid attaching 1500+ event listeners
document.querySelector("main")!.addEventListener(
"click",
(event, element = event.target as HTMLAnchorElement) => {
if (
!(event.button ||
event.which != 1 ||
event.metaKey ||
event.ctrlKey ||
event.shiftKey ||
event.altKey ||
event.defaultPrevented)
) {
while (element && element !== document.body) {
if (
element.nodeName.toUpperCase() === "A" &&
element.getAttribute("href") === "#" &&
element.parentElement?.tagName === "E-"
) {
event.preventDefault();
qaDate(element);
return;
}
element =
(element.assignedSlot ?? element.parentNode) as HTMLAnchorElement;
}
}
},
);
if (!specifier) {
const identifier = file.scope.generateUidIdentifier(nameHint);
importDeclaration.pushContainer(
"specifiers",
_compiler.types.importSpecifier(identifier, _compiler.types.identifier(name))
);
return identifier;
}
return _compiler.types.identifier(specifier.node.local.name);
}
// importStar
function importStar(file, request, nameHint) {
const imports = getImports(file);
request = resolveRelativePath(file, request);
let importDeclaration = imports.get(request);
if (!importDeclaration) {
imports.set(
request,
importDeclaration = file.path.pushContainer(
"body",
_compiler.types.importDeclaration([], _compiler.types.stringLiteral(request))
)[0]
);
}
if (!nameHint) {
return;
}
const specifiers = importDeclaration.get("specifiers");
const specifier = specifiers.find((specifier) =>
specifier.isImportNamespaceSpecifier()
);
if (!specifier) {
const identifier = file.scope.generateUidIdentifier(nameHint);
importDeclaration.pushContainer(
"specifiers",
_compiler.types.importNamespaceSpecifier(identifier)
);
return identifier;
}
return _compiler.types.identifier(specifier.node.local.name);
}
// resolveRelativePath
function resolveRelativePath(file, request) {
if (request.startsWith(FS_START)) {
request = (0, _relativeImportPath.relativeImportPath)(file.opts.filename, request);
}
if (file.markoOpts.optimize) {
request = request.replace(
/(^|\/node-modules\/)marko\/src\//,
"$1marko/dist/"
);
}
return request;
}
});

Some files were not shown because too many files have changed in this diff Show more