Skip to content

Commit

Permalink
Add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Staab committed Jul 7, 2023
0 parents commit c5e830c
Show file tree
Hide file tree
Showing 17 changed files with 629 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .ackrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--ignore-dir=node_modules
--ignore-dir=dist
--ignore-file=match:package-lock.json

2 changes: 2 additions & 0 deletions .fdignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
android
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
20 changes: 20 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.cache/
.idea/
.vs/
.vscode/
docs/
node_modules/
lib/
src/

.gitignore
.npmrc
.prettierrc
favicon.svg
index.html
nodemon.json
package-lock.json
tsconfig.json
vite.config.js
yarn-error.log
yarn.lock
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"jsxSingleQuote": false,
"printWidth": 80,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Jon Staab

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# OstrichScript

OstrichScript is a convention for extending nostr clients with user-defined functionality.
Extensions are written in lua so that they are easy to write, and easy to sandbox in any client.

The basic idea is that a script can export any number of functions which can then be called from
javascript to augment a client's functionality with highly customized user scripts.

You can learn lua by following along with [programming in lua](https://www.lua.org/pil/contents.html).

You can write, edit, publish, and delete extensions using [Ostrich Editor]().

# Interface

A script may export any of the following functions:

```
filterEvent(event: NostrEvent): boolean
```

Functions are expected to be synchronous, but are awaited by this library.

# Implementations

Currently OstricScript is implemented in the following clients:

(none yet)


15 changes: 15 additions & 0 deletions favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>vite-library-template</title>

<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;300;400;600;700&display=swap"
rel="stylesheet"
/>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const testFunction = (name: string) => {
console.log(`Hello, ${name}!`);
};
43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "vite-library-template",
"version": "0.0.1",
"description": "A template for JavaScript/TypeScript library projects using Vite as a bundler.",
"repository": {
"type": "git",
"url": "git+https://github.com/yuigoto/vite-library-template.git"
},
"bugs": {
"url": "https://github.com/yuigoto/vite-library-template/issues"
},
"homepage": "https://github.com/yuigoto/vite-library-template/tree/main#readme",
"keywords": [
"javascript",
"typescript"
],
"files": [
"dist"
],
"author": "Fabio Y. Goto <[email protected]>",
"license": "MIT",
"main": "./dist/index.umd.js",
"module": "./dist/index.es.js",
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js",
"default": "./dist/index.es.js"
}
},
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"devDependencies": {
"@rollup/plugin-typescript": "^8.3.0",
"sass": "^1.45.1",
"tslib": "^2.3.1",
"typescript": "^4.4.4",
"vite": "^2.7.2"
}
}
8 changes: 8 additions & 0 deletions src/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
10 changes: 10 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { testFunction } from "lib";
import "./main.scss";

testFunction("Fabio");

const app = document.querySelector<HTMLDivElement>('#app')!;

app.innerHTML = `
<h1>Vite Library Template!</h1>
`
1 change: 1 addition & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
45 changes: 45 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": ["src/*"],
"lib/*": ["lib/*"]
},
"allowJs": true,
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationDir": "dist",
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"lib": [
"ES5",
"ES6",
"ES7",
"ESNext",
"DOM",
"DOM.Iterable",
"ES2015.Core"
],
"isolatedModules": false,
"module": "ESNext",
"moduleResolution": "Node",
"noEmit": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": false,
"resolveJsonModule": true,
"rootDir": "./lib",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "ES2020",
"traceResolution": false,
"useDefineForClassFields": true
},
"include": ["lib/**/*.ts"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
30 changes: 30 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const path = require("path");
const { defineConfig } = require("vite");
const typescript = require("@rollup/plugin-typescript");

module.exports = defineConfig({
server: {
fs: {
allow: [".."],
},
},
build: {
lib: {
entry: path.resolve(__dirname, "lib/index.ts"),
fileName: (format) => `index.${format}.js`,
name: "@yuigoto/vite-library-template",
},
rollupOptions: {
plugins: [
typescript({
sourceMap: true,
}),
],
},
},
resolve: {
alias: {
lib: path.resolve(__dirname, "lib"),
},
},
});
Loading

0 comments on commit c5e830c

Please sign in to comment.