Skip to content

Commit 90b32db

Browse files
Merge pull request #33 from tubededentifrice/codex/add-customization-options-for-price-display
Add ticker display formatting and chart customization options
2 parents b7a8b22 + 310c807 commit 90b32db

43 files changed

Lines changed: 353 additions & 106 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#DistributionToolWindows/
22
node_modules/
33
.DS_Store
4+
com.courcelle.cryptoticker.sdPlugin/

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
[submodule "com.courcelle.cryptoticker.sdPlugin/libs"]
3-
path = com.courcelle.cryptoticker.sdPlugin/libs
2+
[submodule "com.courcelle.cryptoticker-dev.sdPlugin/libs"]
3+
path = com.courcelle.cryptoticker-dev.sdPlugin/libs
44
url = https://github.com/elgatosf/streamdeck-javascript-sdk

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Repository Guidelines
2+
This project is a Stream Deck plugin; The docs for the SDK are located at https://docs.elgato.com/streamdeck/sdk/introduction/getting-started/ (and it's sub pages).
23

34
## Project Structure & Module Organization
4-
- Source: `com.courcelle.cryptoticker.sdPlugin/` (plugin bundle).
5+
- Source: `com.courcelle.cryptoticker-dev.sdPlugin/` (plugin bundle).
56
- Core files: `manifest.json`, `index.html`, `js/ticker.js` (plugin logic), `js/pi.js` (property inspector), `css/`, `images/`.
67
- Dev preview: `dev/preview.html` and `dev/preview.js` served by the local preview server.
78
- Tests: `__tests__/` (e.g., `__tests__/ticker.test.js`).

CODEBASE_ANALYSIS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ Communication between the plugin and the Stream Deck software happens via a WebS
2121

2222
## Key Files
2323

24-
- `com.courcelle.cryptoticker.sdPlugin/manifest.json`: The plugin's manifest file. It defines the plugin's properties, actions, and entry points (`index.html` for the ticker, `index_pi.html` for the PI).
24+
- `com.courcelle.cryptoticker-dev.sdPlugin/manifest.json`: The plugin's manifest file. It defines the plugin's properties, actions, and entry points (`index.html` for the ticker, `index_pi.html` for the PI).
2525

26-
- `com.courcelle.cryptoticker.sdPlugin/js/ticker.js`: The core logic for the ticker display.
26+
- `com.courcelle.cryptoticker-dev.sdPlugin/js/ticker.js`: The core logic for the ticker display.
2727
- It connects to the data proxy using SignalR for real-time updates.
2828
- It uses an HTML5 `<canvas>` to draw the ticker/chart, which is then sent as an image to the Stream Deck hardware.
2929
- It handles user interactions (key presses) to switch between ticker and candle chart modes.
3030

31-
- `com.courcelle.cryptoticker.sdPlugin/js/pi.js`: The logic for the Property Inspector.
31+
- `com.courcelle.cryptoticker-dev.sdPlugin/js/pi.js`: The logic for the Property Inspector.
3232
- It dynamically fetches the list of available exchanges and trading pairs from the backend proxy.
3333
- It provides a form for users to configure settings like the pair, colors, fonts, and alert rules.
3434
- It sends the updated settings to the core plugin logic (`ticker.js`).

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,37 @@
1818
<img src="https://github.com/tubededentifrice/streamdeck-crypto/raw/master/screenshot2.png" width="354" />
1919

2020
## Installation
21-
- Run `cp -f ./com.courcelle.cryptoticker.sdPlugin/manifest.dev.json ./com.courcelle.cryptoticker.sdPlugin/manifest.json` to use the dev version
22-
- Run `mv com.courcelle.cryptoticker.sdPlugin com.courcelle.cryptoticker-dev.sdPlugin` to use the dev version
23-
- Run `streamdeck link ./com.courcelle.cryptoticker.sdPlugin` after having installed the [Elgato's CLI](https://docs.elgato.com/streamdeck/sdk/introduction/getting-started)
24-
- Run `mv com.courcelle.cryptoticker-dev.sdPlugin com.courcelle.cryptoticker.sdPlugin` to use the dev version
25-
- Once finished with testing, run `cp -f ./com.courcelle.cryptoticker.sdPlugin/manifest.pub.json ./com.courcelle.cryptoticker.sdPlugin/manifest.json` to go back to public manifest
21+
- Run the following to be able to use the `dev` version in the Stream Deck (you need to have the [Elgato's CLI](https://docs.elgato.com/streamdeck/sdk/introduction/getting-started) installed):
22+
```
23+
streamdeck dev
24+
streamdeck link ./com.courcelle.cryptoticker-dev.sdPlugin
25+
open "http://localhost:23654/"
26+
npm run watch
27+
# You should have the "dev" plugin listed in your Stream Deck UI, if not quit it entirely and restart it
28+
```
29+
30+
- Once finished testing, revert back to normal (optional):
31+
```
32+
streamdeck unlink com.courcelle.cryptoticker-dev
33+
```
2634

2735
## Packaging
28-
- Bump the version in `src/com.courcelle.cryptoticker.sdPlugin/manifest.json`.
29-
- Run `streamdeck pack com.courcelle.cryptoticker.sdPlugin`
36+
- Bump the version in `src/com.courcelle.cryptoticker-dev.sdPlugin/manifest.pub.json`.
37+
38+
Run the following to create the "published" version of the plugin:
39+
```
40+
mkdir -p com.courcelle.cryptoticker.sdPlugin # Make sure to never edit this, and only make changes to the -dev directory
41+
rsync -avh --delete ./com.courcelle.cryptoticker-dev.sdPlugin/ ./com.courcelle.cryptoticker.sdPlugin/
42+
cp -f ./com.courcelle.cryptoticker.sdPlugin/manifest.pub.json ./com.courcelle.cryptoticker.sdPlugin/manifest.json
43+
rm -f com.courcelle.cryptoticker.streamDeckPlugin
44+
streamdeck pack com.courcelle.cryptoticker.sdPlugin
45+
```
46+
3047

3148
## Development
3249

3350
Use the following npm scripts during development:
3451

3552
- `npm test` – run the Jest unit tests
53+
- `npm run watch` – watch for changes in the code and notify the Stream Deck UI to reload it whenever needed
3654
- `npm run preview` – start a lightweight server on port 34115 and open the preview page in the default browser

__tests__/ticker.test.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const ticker = require("../com.courcelle.cryptoticker.sdPlugin/js/ticker.js");
1+
const ticker = require("../com.courcelle.cryptoticker-dev.sdPlugin/js/ticker.js");
22

33
test("subscription key builds with conversion", () => {
44
const key = ticker.getSubscriptionContextKey("BITFINEX", "BTCUSD", "USD", "EUR");
@@ -28,3 +28,29 @@ test("rounded value adjusts for large numbers", () => {
2828
test("normalize value", () => {
2929
expect(ticker.normalizeValue(5, 0, 10)).toBeCloseTo(0.5);
3030
});
31+
32+
test("prepareCandlesForDisplay keeps latest entries ordered", () => {
33+
const candles = [
34+
{ ts: 100, open: 1, close: 1, high: 2, low: 0, volumeQuote: 10 },
35+
{ ts: 300, open: 3, close: 4, high: 5, low: 3, volumeQuote: 30 },
36+
{ ts: 200, open: 2, close: 2, high: 3, low: 1, volumeQuote: 20 }
37+
];
38+
39+
const prepared = ticker.prepareCandlesForDisplay(candles, 2);
40+
41+
expect(prepared).toHaveLength(2);
42+
expect(prepared[0].ts).toBe(200);
43+
expect(prepared[1].ts).toBe(300);
44+
});
45+
46+
test("getCandlesNormalized spans full width for prepared candles", () => {
47+
const candles = ticker.prepareCandlesForDisplay([
48+
{ ts: 100, open: 1, close: 1.5, high: 2, low: 1, volumeQuote: 10 },
49+
{ ts: 200, open: 1.5, close: 2, high: 2.5, low: 1.5, volumeQuote: 15 }
50+
], 2);
51+
52+
const normalized = ticker.getCandlesNormalized(candles);
53+
54+
expect(normalized[0].timePercent).toBeCloseTo(0);
55+
expect(normalized[normalized.length - 1].timePercent).toBeCloseTo(1);
56+
});
File renamed without changes.
File renamed without changes.

com.courcelle.cryptoticker.sdPlugin/css/elg_calendar_inv.svg renamed to com.courcelle.cryptoticker-dev.sdPlugin/css/elg_calendar_inv.svg

File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)