Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
FieryFlames committed Mar 4, 2023
0 parents commit bb65139
Show file tree
Hide file tree
Showing 12 changed files with 1,609 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
.DS_Store
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Typing Avatars
Replaces the typing indicator with the avatars of those who are typing.
58 changes: 58 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { readFile, writeFile } from "fs/promises";
import { createHash } from "crypto";

import { rollup } from "rollup";
import { swc } from "rollup-plugin-swc3";
import esbuild from "rollup-plugin-esbuild";
import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";

const manifest = JSON.parse(await readFile(`./manifest.json`));
const outPath = `./dist/index.js`;

try {
const bundle = await rollup({
input: `./${manifest.main}`,
onwarn: () => { },
plugins: [
nodeResolve(),
commonjs(),
esbuild({ minify: true }),
swc({
env: {
targets: "defaults",
include: [
"transform-classes",
"transform-arrow-functions",
],
},
}),
],
});

await bundle.write({
file: outPath,
globals(id) {
if (id.startsWith("@vendetta")) return id.substring(1).replace(/\//g, ".");
const map = {
react: "window.React",
};

return map[id] || null;
},
format: "iife",
compact: true,
exports: "named",
});
await bundle.close();

const toHash = await readFile(outPath);
manifest.hash = createHash("sha256").update(toHash).digest("hex");
manifest.main = "index.js";
await writeFile(`./dist/manifest.json`, JSON.stringify(manifest));

console.log(`Successfully built ${manifest.name}!`);
} catch (e) {
console.error("Failed to build plugin...", e);
process.exit(1);
}
14 changes: 14 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Typing Avatars",
"description": "Replaces the typing indicator with the avatars of those who are typing.",
"authors": [
{
"name": "Fiery",
"id": "890228870559698955"
}
],
"main": "src/index.tsx",
"vendetta": {
"icon": "ic_feedback"
}
}
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"private": true,
"scripts": {
"build": "node build.mjs"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@swc/core": "^1.3.35",
"esbuild": "^0.16.14",
"rollup": "^3.9.1",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-swc3": "^0.8.0",
"vendetta-types": "latest"
},
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [
"react",
"react-native"
]
}
}
}
Loading

0 comments on commit bb65139

Please sign in to comment.