This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createCanvas, ImageData } = require("@napi-rs/canvas"); | |
const { writeFileSync } = require("fs"); | |
/** | |
* @typedef {Object} PortalOptions | |
* @property {Number} width | |
* @property {Number} height | |
* @property {Number} [frameCount] | |
* @property {Number} [spiralCount] | |
* @property {Number} [noise] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from importlib.util import spec_from_file_location, module_from_spec | |
def require(path: str): | |
""" | |
JavaScript styled require with relative paths and JSON support. | |
""" | |
if (path.endswith(".json")): | |
from json import loads | |
with open(path, "r") as f: | |
return loads(f.read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { loadImage, createCanvas } = require("@napi-rs/canvas"); | |
const { writeFileSync } = require("fs"); | |
const { readFile } = require("fs/promises"); | |
/** | |
* @typedef TileSheetOptions | |
* @property {string | URL | Buffer | ArrayBufferLike | Uint8Array | import("@napi-rs/canvas").Image | import("stream").Readable} src - What to load | |
* @property {number} [duplicate] - How many duplicates to create (default 2) | |
* @property {boolean} [pingPong] - Whether to ping-pong the animation or not (default false) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { readdirSync, statSync, readFileSync, mkdirSync, existsSync, writeFileSync } from "fs"; | |
import { sep } from "path"; | |
const INPUT_JS_PATH = "./pages"; | |
const EMITTED_VUE_PATH = "./vue"; | |
function walkSync(dir: string, filelist: string[] = []) { | |
// add trailing slash if not present | |
if (!dir.endsWith(sep)) dir += sep; | |
for (const file of readdirSync(dir)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { loadImage, createCanvas } = require("@napi-rs/canvas"); | |
const { readdirSync, writeFileSync, existsSync, mkdirSync } = require("fs"); | |
const { join } = require("path"); | |
/** @typedef {string | URL | Buffer | ArrayBufferLike | Uint8Array | import("@napi-rs/canvas").Image | import("stream").Readable} ImageSource */ | |
/** @typedef {[number, number, number, number]} ColorTuple - [r, g, b, a] array of colors */ | |
/** | |
* @typedef ReplacementData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { copyFile, mkdir } = require("fs/promises"); | |
// why is there no async exists function | |
const { existsSync } = require("fs"); | |
const DEBUG = false; | |
if (!Object.groupBy || typeof Object.groupBy !== "function") { | |
console.error(`You need a newer version of Node.js to run this program! (>=21.0)`); | |
process.exit(1); | |
} |