Skip to content

Commit cba90f5

Browse files
committed
Initial commit
0 parents  commit cba90f5

12 files changed

Lines changed: 1329 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: "Validate & Build"
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
Sanity:
8+
name: Build
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Install pnpm 📥
15+
uses: pnpm/action-setup@v4
16+
with:
17+
version: latest
18+
19+
- name: Install Node.js 📥
20+
uses: actions/setup-node@v4
21+
with:
22+
cache: pnpm
23+
node-version: latest
24+
25+
- name: Install dependencies 📥
26+
run: pnpm install
27+
28+
- name: Build
29+
run: pnpm run build
30+
31+
- name: Upload Build Artifacts
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: luna-artifacts
35+
path: ./dist
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "[master] Release"
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- "**/*.md"
7+
- ".vscode/**"
8+
9+
jobs:
10+
Build:
11+
uses: ./.github/workflows/build.yml
12+
13+
Release:
14+
name: Release latest on GitHub
15+
needs: Build
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Download All Artifacts
20+
uses: actions/download-artifact@v4
21+
with:
22+
name: luna-artifacts
23+
path: ./dist/
24+
25+
- name: Publish latest release on GitHub
26+
uses: marvinpinto/action-automatic-releases@latest
27+
with:
28+
repo_token: ${{ secrets.GITHUB_TOKEN }}
29+
automatic_release_tag: latest
30+
prerelease: false
31+
title: Latest Release
32+
files: ./dist/**

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Luna Plugins
2+
3+
This is a template & example of how to develop **[Tidal Luna](https://github.com/Inrixia/TidaLuna)** plugins.
4+
5+
## Getting Started
6+
7+
Follow these steps to create your own Luna plugin using this template:
8+
9+
### 1. Clone the Repository
10+
11+
```sh
12+
git clone https://github.com/Inrixia/luna-template.git luna-plugins
13+
cd luna-plugins
14+
```
15+
16+
### 2. Install Node.js (if missing)
17+
18+
If you don't have Node.js installed, use [nvm](https://github.com/nvm-sh/nvm):
19+
20+
```sh
21+
nvm install node
22+
nvm use node
23+
```
24+
25+
> This will install and use the latest Node.js version.
26+
27+
### 3. Enable pnpm via Corepack
28+
29+
[Corepack](https://nodejs.org/api/corepack.html) is included with Node.js 16.10+.
30+
31+
```sh
32+
corepack enable
33+
corepack prepare pnpm@latest --activate
34+
```
35+
36+
### 4. Install Dependencies
37+
38+
```sh
39+
pnpm install
40+
```
41+
42+
### 5. Start Developing
43+
44+
- Edit files in the `plugins/Example` directory to build your plugin.
45+
- Use `pnpm run watch` to build and serve with hot reload.
46+
47+
> While developing, you can install your local plugin into Tidal Luna using a local URL.
48+
> For example, if your plugin is `@luna/example` and you are running the dev server, use:
49+
> `http://127.0.0.1:3000/luna.example` as the install URL in Tidal Luna.
50+
51+
### 6. Update the README
52+
53+
Replace this README with information about your plugin:
54+
55+
- What it does
56+
- How to use it
57+
- Any configuration or setup steps
58+
59+
### 7. GitHub Actions: Workflow Permissions
60+
61+
If you want to use the included GitHub Action in (`.github`) to automatically create releases, you must set your repository workflow permissions to **Read and write permissions**:
62+
63+
1. Go to your repository's settings: `Settings > Actions > General` https://github.com/.../.../settings/actions
64+
1. Under **Workflow permissions**, select **Read and write permissions**.
65+
1. Click **Save**.
66+
67+
This allows the GitHub Action to create releases on your behalf.
68+
69+
---
70+
71+
For more details, see the [Tidal Luna documentation](https://github.com/Inrixia/TidaLuna).

esbuild.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "luna/buildPlugins";

package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "@luna/template",
3+
"description": "Template repo for making your own luna plugins",
4+
"type": "module",
5+
"scripts": {
6+
"watch": "concurrently \"pnpm:build --watch\" pnpm:serve",
7+
"build": "rimraf ./dist && tsx esbuild.config.ts",
8+
"serve": "http-server ./dist -p 3000 -s --cors -c-1"
9+
},
10+
"devDependencies": {
11+
"@types/node": "^22.14.1",
12+
"@types/react": "^19.1.2",
13+
"@types/react-dom": "^19.1.2",
14+
"concurrently": "^9.1.2",
15+
"http-server": "^14.1.1",
16+
"luna": "link:../TidaLuna",
17+
"oby": "^15.1.2",
18+
"rimraf": "^6.0.1",
19+
"tsx": "^4.19.3",
20+
"typescript": "^5.8.3"
21+
}
22+
}

plugins/Example/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@luna/example",
3+
"description": "A blank canvas",
4+
"author": {
5+
"name": "Inrixia",
6+
"url": "https://github.com/Inrixia",
7+
"avatarUrl": "https://2.gravatar.com/avatar/eeaffef9eb9b436dccc58c6c44c9fe8c3528e83e3bf64e1c736a68dbe8c097d3"
8+
},
9+
"main": "./src/index.ts",
10+
"type": "module"
11+
}

plugins/Example/src/Settings.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
3+
import { InfoMessage } from "@luna/lib";
4+
import { LunaSwitchSetting } from "@luna/ui";
5+
6+
export const Settings = () => {
7+
const onChange = React.useCallback((_: React.ChangeEvent<HTMLInputElement>, checked?: boolean) => {
8+
InfoMessage(`Example switch is now ${checked ? "on" : "off"}`);
9+
}, []);
10+
return <LunaSwitchSetting title="Example Switch" desc="This is an example switch" onChange={onChange} />;
11+
};

plugins/Example/src/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { InfoMessage, redux, Signal, type LunaUnload } from "@luna/lib";
2+
import { intercept } from "plugins/lib/src/redux";
3+
4+
InfoMessage(`Hello ${redux.store.getState().user.meta.profileName} from the Example plugin!`);
5+
6+
// Example plugin settings
7+
export { Settings } from "./Settings";
8+
9+
// Functions in unloads are called when plugin is unloaded.
10+
// Used to clean up resources, even listener dispose etc should be added here
11+
export const unloads = new Set<LunaUnload>();
12+
13+
// Log to console whenever changing page
14+
intercept("page/SET_PAGE_ID", unloads, console.log);
15+
16+
// Error signal allowing us to show error messages in the UI
17+
export const errSignal = new Signal<string | undefined>(undefined);
18+
19+
errSignal._ = "Example plugin error signal";

0 commit comments

Comments
 (0)