First commit

This commit is contained in:
Jonathan Staab
2023-03-25 10:08:17 -05:00
commit 39d001280c
12 changed files with 4962 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
node_modules
+1
View File
@@ -0,0 +1 @@
node_modules
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm run check
+8
View File
@@ -0,0 +1,8 @@
{
"semi": false,
"printWidth": 100,
"bracketSameLine": true,
"arrowParens": "avoid",
"bracketSpacing": false,
"pluginSearchDirs": false
}
+4
View File
@@ -0,0 +1,4 @@
const t = 1;
export {
t as stuff
};
+1
View File
@@ -0,0 +1 @@
(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.paravel={}))})(this,function(e){"use strict";e.stuff=1,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
+24
View File
@@ -0,0 +1,24 @@
export type EventBusListener = {
id: string
handler: (...args: any[]) => void
}
export class EventBus {
listeners: Record<string, Array<EventBusListener>> = {}
on(name, handler) {
const id = Math.random().toString().slice(2)
this.listeners[name] = this.listeners[name] || ([] as Array<EventBusListener>)
this.listeners[name].push({id, handler})
return id
}
off(name, id) {
this.listeners[name] = this.listeners[name].filter(l => l.id !== id)
}
handle(k, ...payload) {
for (const {handler} of this.listeners[k] || []) {
handler(...payload)
}
}
}
+1
View File
@@ -0,0 +1 @@
export * from './EventBus'
+4852
View File
File diff suppressed because it is too large Load Diff
+39
View File
@@ -0,0 +1,39 @@
{
"name": "paravel",
"version": "1.0.0",
"description": "Yet another toolkit for nostr",
"files": [
"dist"
],
"main": "./dist/paravel.umd.js",
"module": "./dist/paravel.es.js",
"exports": {
".": {
"import": "./dist/paravel.es.js",
"require": "./dist/paravel.umd.js"
}
},
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"check:ts": "tsc --lib esnext lib/*.ts --noEmit",
"check:fmt": "prettier --check lib/*",
"check": "run-p check:*",
"format": "prettier --write lib/*"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@tsconfig/recommended": "^1.0.2",
"prettier": "^2.8.7",
"vite": "^4.2.1",
"vite-plugin-eslint": "^1.8.1"
},
"dependencies": {
"husky": "^8.0.3",
"npm-run-all": "^4.1.5",
"typescript": "^5.0.2"
}
}
+12
View File
@@ -0,0 +1,12 @@
{
"extends": "@tsconfig/recommended/tsconfig.json"
"compilerOptions": {
"useDefineForClassFields": true,
"allowSyntheticDefaultImports": true,
"module": "esnext",
"resolveJsonModule": true,
"isolatedModules": false,
"importsNotUsedAsValues": "preserve"
},
"include": ["lib/**/*.d.ts", "lib/**/*.ts"]
}
+14
View File
@@ -0,0 +1,14 @@
import path from 'path'
import {defineConfig} from 'vite'
import eslint from 'vite-plugin-eslint'
export default defineConfig({
plugins: [eslint()],
build: {
lib: {
entry: path.resolve(__dirname, 'lib/main.ts'),
name: 'paravel',
fileName: (format) => `paravel.${format}.js`
}
}
})