@tony01/astroneum 0.4.1-beta.2 → 0.4.1-beta.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +280 -237
- package/LICENSE +21 -21
- package/README.md +250 -198
- package/dist/{Indicator-BBI3L_lx.d.ts → Indicator-BQQcVGGT.d.ts} +51 -227
- package/dist/astroneum.css +1 -1
- package/dist/chunk-47YGQEL5.js +399 -0
- package/dist/chunk-67XM5LOK.js +2 -0
- package/dist/{chunk-2YYGUSVX.js → chunk-DFJMDDL5.js} +1 -1
- package/dist/chunk-EFAS6F4C.js +59 -0
- package/dist/chunk-EHZN52CY.js +2 -0
- package/dist/chunk-HKLWNPMP.js +35 -0
- package/dist/chunk-ONPPQW65.js +2 -0
- package/dist/chunk-SCTHEM27.js +3 -0
- package/dist/chunk-UQXYMB6X.js +2 -0
- package/dist/chunk-WSIR5T2M.js +3 -0
- package/dist/entries/alerts.d.ts +36 -10
- package/dist/entries/alerts.js +1 -1
- package/dist/entries/datafeeds/crypto.d.ts +5 -1
- package/dist/entries/datafeeds/crypto.js +1 -1
- package/dist/entries/datafeeds/polygon.d.ts +3 -1
- package/dist/entries/datafeeds/polygon.js +1 -1
- package/dist/entries/headless.d.ts +78 -0
- package/dist/entries/headless.js +2 -0
- package/dist/entries/multichart.d.ts +12 -1
- package/dist/entries/multichart.js +1 -1
- package/dist/entries/replay.d.ts +3 -1
- package/dist/entries/script.d.ts +2 -68
- package/dist/entries/script.js +1 -1
- package/dist/entries/watchlist.d.ts +32 -2
- package/dist/entries/watchlist.js +1 -1
- package/dist/entries/workspace.d.ts +61 -0
- package/dist/entries/workspace.js +2 -0
- package/dist/index-BiXdqLA4.d.ts +45 -0
- package/dist/index-_JgHTy8X.d.ts +19 -0
- package/dist/index.d.ts +188 -27
- package/dist/index.js +1 -1
- package/dist/script-BU9StbN-.d.ts +120 -0
- package/dist/types-W6SIYQ9m.d.ts +232 -0
- package/dist/types-yETgeYsE.d.ts +28 -0
- package/dist/zh-CN-NDTUDZGZ.js +3 -0
- package/docs/MIRROR-PLAN-SYMBOL-SEARCH-WATCHLIST.md +255 -0
- package/docs/STRUCTURE.md +51 -37
- package/docs/TODO-DESIGN.md +111 -37
- package/docs/TODO.md +26 -16
- package/docs/WORKSTREAMS.md +55 -0
- package/docs/api.md +655 -528
- package/docs/datafeed-guide.md +329 -311
- package/docs/design-astroneum.md +204 -65
- package/docs/plugin-development.md +569 -565
- package/docs/tv-functions-skill.md +88 -64
- package/package.json +158 -147
- package/dist/chunk-4YOLQ5DC.js +0 -2
- package/dist/chunk-I4YQBP2M.js +0 -3
- package/dist/chunk-OOMZRONH.js +0 -35
- package/dist/chunk-PV2GAINM.js +0 -2
- package/dist/chunk-YW3STIPY.js +0 -653
- package/dist/zh-CN-Y2C6RSOI.js +0 -3
package/package.json
CHANGED
|
@@ -1,147 +1,158 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tony01/astroneum",
|
|
3
|
-
"version": "0.4.1-beta.
|
|
4
|
-
"packageManager": "pnpm@
|
|
5
|
-
"description": "Astroneum - Professional financial charting library, ready out of the box.",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"style": "./dist/astroneum.css",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/index.js",
|
|
14
|
-
"default": "./dist/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./
|
|
17
|
-
"types": "./dist/entries/
|
|
18
|
-
"import": "./dist/entries/
|
|
19
|
-
"default": "./dist/entries/
|
|
20
|
-
},
|
|
21
|
-
"./
|
|
22
|
-
"types": "./dist/entries/
|
|
23
|
-
"import": "./dist/entries/
|
|
24
|
-
"default": "./dist/entries/
|
|
25
|
-
},
|
|
26
|
-
"./
|
|
27
|
-
"types": "./dist/entries/
|
|
28
|
-
"import": "./dist/entries/
|
|
29
|
-
"default": "./dist/entries/
|
|
30
|
-
},
|
|
31
|
-
"./
|
|
32
|
-
"types": "./dist/entries/
|
|
33
|
-
"import": "./dist/entries/
|
|
34
|
-
"default": "./dist/entries/
|
|
35
|
-
},
|
|
36
|
-
"./
|
|
37
|
-
"types": "./dist/entries/
|
|
38
|
-
"import": "./dist/entries/
|
|
39
|
-
"default": "./dist/entries/
|
|
40
|
-
},
|
|
41
|
-
"./
|
|
42
|
-
"types": "./dist/entries/
|
|
43
|
-
"import": "./dist/entries/
|
|
44
|
-
"default": "./dist/entries/
|
|
45
|
-
},
|
|
46
|
-
"./
|
|
47
|
-
"types": "./dist/entries/
|
|
48
|
-
"import": "./dist/entries/
|
|
49
|
-
"default": "./dist/entries/
|
|
50
|
-
},
|
|
51
|
-
"./
|
|
52
|
-
"types": "./dist/entries/
|
|
53
|
-
"import": "./dist/entries/
|
|
54
|
-
"default": "./dist/entries/
|
|
55
|
-
},
|
|
56
|
-
"./
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
"
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"
|
|
136
|
-
"react
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
"
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@tony01/astroneum",
|
|
3
|
+
"version": "0.4.1-beta.24",
|
|
4
|
+
"packageManager": "pnpm@10.33.0",
|
|
5
|
+
"description": "Astroneum - Professional financial charting library, ready out of the box.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"style": "./dist/astroneum.css",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./headless": {
|
|
17
|
+
"types": "./dist/entries/headless.d.ts",
|
|
18
|
+
"import": "./dist/entries/headless.js",
|
|
19
|
+
"default": "./dist/entries/headless.js"
|
|
20
|
+
},
|
|
21
|
+
"./replay": {
|
|
22
|
+
"types": "./dist/entries/replay.d.ts",
|
|
23
|
+
"import": "./dist/entries/replay.js",
|
|
24
|
+
"default": "./dist/entries/replay.js"
|
|
25
|
+
},
|
|
26
|
+
"./multichart": {
|
|
27
|
+
"types": "./dist/entries/multichart.d.ts",
|
|
28
|
+
"import": "./dist/entries/multichart.js",
|
|
29
|
+
"default": "./dist/entries/multichart.js"
|
|
30
|
+
},
|
|
31
|
+
"./watchlist": {
|
|
32
|
+
"types": "./dist/entries/watchlist.d.ts",
|
|
33
|
+
"import": "./dist/entries/watchlist.js",
|
|
34
|
+
"default": "./dist/entries/watchlist.js"
|
|
35
|
+
},
|
|
36
|
+
"./workspace": {
|
|
37
|
+
"types": "./dist/entries/workspace.d.ts",
|
|
38
|
+
"import": "./dist/entries/workspace.js",
|
|
39
|
+
"default": "./dist/entries/workspace.js"
|
|
40
|
+
},
|
|
41
|
+
"./portfolio": {
|
|
42
|
+
"types": "./dist/entries/portfolio.d.ts",
|
|
43
|
+
"import": "./dist/entries/portfolio.js",
|
|
44
|
+
"default": "./dist/entries/portfolio.js"
|
|
45
|
+
},
|
|
46
|
+
"./alerts": {
|
|
47
|
+
"types": "./dist/entries/alerts.d.ts",
|
|
48
|
+
"import": "./dist/entries/alerts.js",
|
|
49
|
+
"default": "./dist/entries/alerts.js"
|
|
50
|
+
},
|
|
51
|
+
"./script": {
|
|
52
|
+
"types": "./dist/entries/script.d.ts",
|
|
53
|
+
"import": "./dist/entries/script.js",
|
|
54
|
+
"default": "./dist/entries/script.js"
|
|
55
|
+
},
|
|
56
|
+
"./datafeeds/polygon": {
|
|
57
|
+
"types": "./dist/entries/datafeeds/polygon.d.ts",
|
|
58
|
+
"import": "./dist/entries/datafeeds/polygon.js",
|
|
59
|
+
"default": "./dist/entries/datafeeds/polygon.js"
|
|
60
|
+
},
|
|
61
|
+
"./datafeeds/crypto": {
|
|
62
|
+
"types": "./dist/entries/datafeeds/crypto.d.ts",
|
|
63
|
+
"import": "./dist/entries/datafeeds/crypto.js",
|
|
64
|
+
"default": "./dist/entries/datafeeds/crypto.js"
|
|
65
|
+
},
|
|
66
|
+
"./style.css": "./dist/astroneum.css",
|
|
67
|
+
"./package.json": "./package.json"
|
|
68
|
+
},
|
|
69
|
+
"sideEffects": [
|
|
70
|
+
"./dist/astroneum.css"
|
|
71
|
+
],
|
|
72
|
+
"files": [
|
|
73
|
+
"LICENSE",
|
|
74
|
+
"README.md",
|
|
75
|
+
"CHANGELOG.md",
|
|
76
|
+
"docs",
|
|
77
|
+
"dist/**/*.js",
|
|
78
|
+
"dist/**/*.css",
|
|
79
|
+
"dist/**/*.d.ts"
|
|
80
|
+
],
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">=18"
|
|
83
|
+
},
|
|
84
|
+
"repository": {
|
|
85
|
+
"type": "git",
|
|
86
|
+
"url": "git+https://github.com/Tony1185/Astroneum.git"
|
|
87
|
+
},
|
|
88
|
+
"bugs": {
|
|
89
|
+
"url": "https://github.com/Tony1185/Astroneum/issues"
|
|
90
|
+
},
|
|
91
|
+
"homepage": "https://github.com/Tony1185/Astroneum#readme",
|
|
92
|
+
"keywords": [
|
|
93
|
+
"astroneum",
|
|
94
|
+
"candlestick",
|
|
95
|
+
"candlestick-chart",
|
|
96
|
+
"finance",
|
|
97
|
+
"financial-chart",
|
|
98
|
+
"stock",
|
|
99
|
+
"trading",
|
|
100
|
+
"technical-analysis",
|
|
101
|
+
"indicators",
|
|
102
|
+
"chart",
|
|
103
|
+
"canvas",
|
|
104
|
+
"webgl",
|
|
105
|
+
"react",
|
|
106
|
+
"typescript"
|
|
107
|
+
],
|
|
108
|
+
"author": "kowito",
|
|
109
|
+
"license": "MIT",
|
|
110
|
+
"private": false,
|
|
111
|
+
"publishConfig": {
|
|
112
|
+
"access": "public"
|
|
113
|
+
},
|
|
114
|
+
"scripts": {
|
|
115
|
+
"clean": "node -e \"const fs=require('node:fs');fs.rmSync('dist',{ recursive: true, force: true })\"",
|
|
116
|
+
"build:js": "tsup --config tsup.config.ts",
|
|
117
|
+
"build:css": "sass src/styles/index.scss src/styles/.tmp-astroneum.css --no-source-map && esbuild src/styles/.tmp-astroneum.css --bundle --minify --loader:.eot=dataurl --loader:.ttf=dataurl --loader:.woff=dataurl --loader:.svg=dataurl --outfile=dist/astroneum.css && node -e \"const fs=require('node:fs');fs.rmSync('src/styles/.tmp-astroneum.css',{ force: true })\"",
|
|
118
|
+
"build": "pnpm clean && pnpm build:js && pnpm build:css",
|
|
119
|
+
"typecheck": "tsc --noEmit",
|
|
120
|
+
"test": "tsx --test src/__tests__/*.test.ts",
|
|
121
|
+
"test:watch": "tsx --test --watch src/__tests__/*.test.ts",
|
|
122
|
+
"lint": "eslint src",
|
|
123
|
+
"size": "size-limit",
|
|
124
|
+
"package:check": "node scripts/verify-package.mjs",
|
|
125
|
+
"verify": "pnpm lint && pnpm typecheck && pnpm build && pnpm test",
|
|
126
|
+
"prepublishOnly": "pnpm verify"
|
|
127
|
+
},
|
|
128
|
+
"devDependencies": {
|
|
129
|
+
"@size-limit/preset-big-lib": "^12.1.0",
|
|
130
|
+
"@types/node": "^24.9.1",
|
|
131
|
+
"@types/react": "^19.2.2",
|
|
132
|
+
"@types/react-dom": "^19.2.2",
|
|
133
|
+
"@webgpu/types": "^0.1.69",
|
|
134
|
+
"esbuild": "^0.25.11",
|
|
135
|
+
"eslint": "^9.39.4",
|
|
136
|
+
"react": "^19.2.0",
|
|
137
|
+
"react-dom": "^19.2.0",
|
|
138
|
+
"sass": "^1.0.0",
|
|
139
|
+
"size-limit": "^12.1.0",
|
|
140
|
+
"tsup": "^8.5.1",
|
|
141
|
+
"tsx": "^4.20.6",
|
|
142
|
+
"typescript": "^5.8.3",
|
|
143
|
+
"typescript-eslint": "^8.59.0"
|
|
144
|
+
},
|
|
145
|
+
"peerDependencies": {
|
|
146
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
147
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
148
|
+
},
|
|
149
|
+
"pnpm": {
|
|
150
|
+
"overrides": {
|
|
151
|
+
"esbuild": ">=0.25.0"
|
|
152
|
+
},
|
|
153
|
+
"onlyBuiltDependencies": [
|
|
154
|
+
"@parcel/watcher",
|
|
155
|
+
"esbuild"
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
}
|
package/dist/chunk-4YOLQ5DC.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
function g(r){try{let t=new URL(r);if(t.protocol!=="http:"&&t.protocol!=="https:")return !1;let e=t.hostname.toLowerCase().replace(/^\[|\]$/g,"");return !(e==="localhost"||e==="127.0.0.1"||e==="::1"||/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|169\.254\.|127\.)/.test(e)||e.endsWith(".local")||e.endsWith(".internal"))}catch{return false}}var f="astroneum-alerts";function m(){try{let r=localStorage.getItem(f);if(!r)return [];let t=JSON.parse(r);return Array.isArray(t)?t.filter(e=>{if(e===null||typeof e!="object")return !1;let i=e;return typeof i.id=="string"&&typeof i.symbol=="string"&&typeof i.price=="number"&&typeof i.status=="string"&&typeof i.createdAt=="string"}):[]}catch{return []}}function d(r){try{localStorage.setItem(f,JSON.stringify(r));}catch{}}var b={Thin:880,Classic:660,Alert:1e3,Bell:523,Chime:784};function h(r="Thin",t="once"){try{let e=new AudioContext,i=b[r]??880,s=()=>{let n=e.createOscillator(),o=e.createGain();n.connect(o),o.connect(e.destination),n.frequency.value=i,o.gain.setValueAtTime(.3,e.currentTime),o.gain.exponentialRampToValueAtTime(.001,e.currentTime+.4),n.start(e.currentTime),n.stop(e.currentTime+.4),n.onended=()=>{t!=="repeating"&&e.close();};};if(s(),t==="repeating"){let n=setInterval(s,600);setTimeout(()=>{clearInterval(n),e.close();},5e3);}}catch{}}var c=null;function y(){return c&&document.body.contains(c)||(c=document.createElement("div"),c.id="astroneum-alert-toast-container",c.style.cssText="position:fixed;top:16px;right:16px;z-index:10000;display:flex;flex-direction:column;gap:8px;pointer-events:none",document.body.appendChild(c)),c}function A(r,t){try{let e=y(),i=document.createElement("div");i.style.cssText="pointer-events:auto;min-width:280px;max-width:400px;padding:12px 16px;border-radius:8px;background:#1d2026;border:1px solid #2962ff;color:#d1d4dc;font-family:-apple-system,sans-serif;font-size:14px;box-shadow:0 4px 16px rgba(0,0,0,0.4);cursor:pointer;transition:opacity 0.3s;animation:toast-in 0.2s ease-out";let s=document.createElement("div");s.textContent=r,s.style.cssText="font-weight:600;margin-bottom:4px;color:#2962ff";let n=document.createElement("div");n.textContent=t,n.style.cssText="color:#8a8f9c;font-size:13px",i.appendChild(s),i.appendChild(n),i.onclick=()=>{i.style.opacity="0",setTimeout(()=>i.remove(),300);},e.appendChild(i),setTimeout(()=>{i.parentNode&&(i.style.opacity="0",setTimeout(()=>i.remove(),300));},8e3);}catch{}}function v(r){if(!r||r.preset==="24/7")return true;let t=new Date,e=t.getDay(),i=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0"),n=`${i}:${s}`;if(r.preset==="weekdays")return e>=1&&e<=5;if(r.preset==="working_hours")return e>=1&&e<=5&&n>="09:00"&&n<="18:00";if(r.preset==="custom"){if(!(r.days??[0,1,2,3,4,5,6]).includes(e))return false;let a=r.from??"00:00",l=r.to??"23:59";return a<=l?n>=a&&n<=l:n>=a||n<=l}return true}async function p(r,t,e,i){try{await fetch("/astroneum/api/alerts/email",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r,subject:t,body:e,isPlainText:i})});}catch{}}async function S(r,t,e,i){try{i({webhookStatus:"pending",webhookStatusAt:new Date().toISOString()});let n=await(await fetch("/astroneum/api/alerts/webhook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({webhookUrl:r,message:t,payload:e})})).json();i({webhookStatus:n?.ok?"delivered":"failed",webhookStatusAt:new Date().toISOString(),webhookHttpStatus:typeof n?.status=="number"?n.status:void 0});}catch{i({webhookStatus:"failed",webhookStatusAt:new Date().toISOString()});}}var u=class r{static _instance=null;_alerts;_lastPrice=new Map;_listeners=[];_savePending=false;constructor(){this._alerts=m();}static getInstance(){return r._instance||(r._instance=new r),r._instance}add(t){let e={...t,id:`alert_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,status:"active",createdAt:new Date().toISOString(),frequency:t.frequency??"once",soundEnabled:t.soundEnabled??true,notificationEnabled:t.notificationEnabled??false};return this._alerts.push(e),d(this._alerts),e.id}update(t,e){let i=this._alerts.findIndex(s=>s.id===t);return i===-1?false:(this._alerts[i]={...this._alerts[i],...e},d(this._alerts),true)}delete(t){let e=this._alerts.length;return this._alerts=this._alerts.filter(i=>i.id!==t),this._alerts.length!==e?(d(this._alerts),true):false}dismiss(t){return this.update(t,{status:"dismissed"})}reactivate(t){return this.update(t,{status:"active",triggeredAt:void 0})}clear(t){this._alerts=t?this._alerts.filter(e=>e.symbol!==t):[],d(this._alerts);}getAll(){return this._alerts}getActive(){return this._alerts.filter(t=>t.status==="active")}getForSymbol(t){return this._alerts.filter(e=>e.symbol===t)}getActiveForSymbol(t){return this._alerts.filter(e=>e.symbol===t&&e.status==="active")}getHistory(){return this._alerts.filter(t=>t.status!=="active")}check(t){let{symbol:e,price:i,timestamp:s}=t,n=this._lastPrice.get(e);this._lastPrice.set(e,i);for(let o of this._alerts){if(o.symbol!==e||o.status!=="active")continue;if(o.expiration&&new Date(o.expiration).getTime()<s){o.status="expired";continue}let a=false;switch(o.condition){case "above":a=i>=o.price;break;case "below":a=i<=o.price;break;case "crosses_above":a=n!==void 0&&n<o.price&&i>=o.price;break;case "crosses_below":a=n!==void 0&&n>o.price&&i<=o.price;break;case "crossing":a=n!==void 0&&(n<o.price&&i>=o.price||n>o.price&&i<=o.price);break}if(!a)continue;let l=new Date(s).toISOString();o.triggeredAt=l,o.frequency==="once"&&(o.status="triggered"),this._fire(o,i);}this._schedulePersist();}_schedulePersist(){this._savePending||(this._savePending=true,setTimeout(()=>{this._savePending=false,d(this._alerts);},1e3));}_fire(t,e){let i=v(t.notificationSchedule),s=t.messageTemplate??t.note??`${t.symbol} ${t.condition} ${t.price}`,n=`${t.symbol} ${t.condition} ${t.price} \u2014 current: ${e}`;if(t.soundEnabled&&i&&h(t.soundTitle??"Thin",t.soundDuration??"once"),t.notificationEnabled&&i&&"Notification"in window&&(Notification.permission==="granted"?new Notification(`Alert: ${s}`,{body:`Current price: ${e}`,icon:"/favicon.ico"}):Notification.permission!=="denied"&&Notification.requestPermission().then(o=>{o==="granted"&&new Notification(`Alert: ${s}`,{body:`Current price: ${e}`});})),t.toastEnabled&&i&&A(`Alert: ${s}`,n),t.webhookUrl&&g(t.webhookUrl)&&i){let o=t.messageTemplate??n,a={id:t.id,symbol:t.symbol,condition:t.condition,price:t.price,triggeredPrice:e,triggeredAt:t.triggeredAt,note:t.note,message:o};S(t.webhookUrl,o,a,l=>{this.update(t.id,l);});}t.emailEnabled&&i&&p("",`Alert: ${s}`,n,false),t.plainTextEnabled&&t.plainTextEmail&&i&&p(t.plainTextEmail,`Alert: ${s}`,n,true);for(let o of this._listeners)try{o(t,e);}catch{}}onTriggered(t){return this._listeners.push(t),()=>{this._listeners=this._listeners.filter(e=>e!==t);}}async requestNotificationPermission(){return "Notification"in window?Notification.permission!=="default"?Notification.permission:Notification.requestPermission():"denied"}},w=u;export{w as a};
|
package/dist/chunk-I4YQBP2M.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import {b as b$1}from'./chunk-SDXH2WAI.js';var q=[{ticker:"BINANCE:BTCUSDT",name:"Bitcoin Perpetual / USDT",shortName:"BTC PERP",exchange:"BINANCE",market:"crypto",pricePrecision:2,volumePrecision:6,priceCurrency:"USDT",type:"crypto",venueSymbol:"BTCUSDT"},{ticker:"BINANCE:ETHUSDT",name:"Ethereum Perpetual / USDT",shortName:"ETH PERP",exchange:"BINANCE",market:"crypto",pricePrecision:2,volumePrecision:4,priceCurrency:"USDT",type:"crypto",venueSymbol:"ETHUSDT"},{ticker:"BINANCE:SOLUSDT",name:"Solana Perpetual / USDT",shortName:"SOL PERP",exchange:"BINANCE",market:"crypto",pricePrecision:3,volumePrecision:2,priceCurrency:"USDT",type:"crypto",venueSymbol:"SOLUSDT"},{ticker:"BITGET:BTCUSDT",name:"Bitcoin USDT Futures",shortName:"BTC PERP",exchange:"BITGET",market:"crypto",pricePrecision:2,volumePrecision:6,priceCurrency:"USDT",type:"crypto",venueSymbol:"BTCUSDT",productType:"USDT-FUTURES"},{ticker:"BITGET:ETHUSDT",name:"Ethereum USDT Futures",shortName:"ETH PERP",exchange:"BITGET",market:"crypto",pricePrecision:2,volumePrecision:4,priceCurrency:"USDT",type:"crypto",venueSymbol:"ETHUSDT",productType:"USDT-FUTURES"},{ticker:"OKX:BTC-USDT-SWAP",name:"Bitcoin USDT Swap",shortName:"BTC SWAP",exchange:"OKX",market:"crypto",pricePrecision:2,volumePrecision:6,priceCurrency:"USDT",type:"crypto",instId:"BTC-USDT-SWAP"},{ticker:"OKX:ETH-USDT-SWAP",name:"Ethereum USDT Swap",shortName:"ETH SWAP",exchange:"OKX",market:"crypto",pricePrecision:2,volumePrecision:4,priceCurrency:"USDT",type:"crypto",instId:"ETH-USDT-SWAP"}],X=q,G="astroneum:datafeed-error",j="wss://fstream.binance.com/market/ws",A="https://fapi.binance.com/fapi/v1",J="wss://ws.bitget.com/v2/ws/public",_="https://api.bitget.com/api/v2/mix/market",V="wss://ws.okx.com:8443/ws/v5/public",R="https://www.okx.com/api/v5/market",E=120;function $(e,t){return `${e.ticker}::${t.text}`}function z(e,t){if(!e)return true;let n=e.toLowerCase();return t.ticker.toLowerCase().includes(n)||(t.name??"").toLowerCase().includes(n)}function U(e){if(typeof e!="string")return null;try{return JSON.parse(e)}catch{return null}}function l(e){let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:null}function C(e){let t=true;for(let n=1;n<e.length;n++)if(e[n].timestamp<e[n-1].timestamp){t=false;break}return t?e:e.slice().sort((n,r)=>n.timestamp-r.timestamp)}function I(e,t,n){return e.filter(r=>r.timestamp>=t&&r.timestamp<=n)}function Y(e){return ({second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:2592e6,year:31536e6}[e.timespan]??6e4)*e.multiplier}function x(e,t,n){let r=Y(e),a=Math.floor(t/r)*r,o=Math.floor(n/r)*r;return o>=a?{from:a,to:o}:{from:a,to:a}}function N(e){return e.timespan==="minute"&&[1,3,5,15,30].includes(e.multiplier)?`${e.multiplier}m`:e.timespan==="hour"&&[1,2,4,6,8,12].includes(e.multiplier)?`${e.multiplier}h`:e.timespan==="day"&&[1,3].includes(e.multiplier)?`${e.multiplier}d`:e.timespan==="week"&&e.multiplier===1?"1w":e.timespan==="month"&&e.multiplier===1?"1M":null}function O(e){return e.timespan==="minute"&&[1,3,5,15,30].includes(e.multiplier)?`${e.multiplier}m`:e.timespan==="hour"&&[1,2,4,6,12].includes(e.multiplier)?`${e.multiplier}H`:e.timespan==="day"&&[1,3].includes(e.multiplier)?`${e.multiplier}D`:e.timespan==="week"&&e.multiplier===1?"1W":e.timespan==="month"&&e.multiplier===1?"1M":null}function W(e){return e.timespan==="minute"&&[1,3,5,15,30].includes(e.multiplier)?`${e.multiplier}m`:e.timespan==="hour"&&[1,2,4,6,12].includes(e.multiplier)?`${e.multiplier}H`:e.timespan==="day"&&[1,3].includes(e.multiplier)?`${e.multiplier}D`:e.timespan==="week"&&e.multiplier===1?"1W":e.timespan==="month"&&e.multiplier===1?"1M":null}function H(e){let t=e.indexOf(":");return t>=0?e.slice(t+1):e}function b(e){return (e.venueSymbol??H(e.ticker)).toUpperCase()}function F(e){return e.instId??H(e.ticker)}function Q(e){return (e.productType??"USDT-FUTURES").toUpperCase()}function Z(e){return (e.productType??"USDT-FUTURES").toLowerCase()}function K(e){if(typeof e.exchange=="string"&&e.exchange.trim())return e.exchange.toUpperCase();let t=e.ticker.split(":",1)[0]?.toUpperCase();return t&&t.length>0?t:null}function ee(e,t){return {...e,exchange:t}}async function g(e){try{let t=await fetch(e);return t.ok?await t.json():null}catch{return null}}var L=new Map;function te(e){return e&&typeof e=="object"&&"data"in e?e.data??e:e}function p(e,t,n,r){let a=`${e.ticker}::${t.text}::${n}`,o=Date.now(),c=L.get(a)??0;if(o-c<2500)return;L.set(a,o);let s={exchange:K(e)??void 0,ticker:e.ticker,period:t.text,type:n,message:r};console.error(`[astroneum:datafeed] ${s.ticker} ${s.period} - ${s.message}`),typeof window<"u"&&window.dispatchEvent(new CustomEvent(G,{detail:s}));}function M(e){if(!Array.isArray(e))return [];let t=[];for(let n of e){if(!Array.isArray(n))continue;let r=l(n[0]),a=l(n[1]),o=l(n[2]),c=l(n[3]),s=l(n[4]),i=l(n[5]),u=l(n[7]);r===null||a===null||o===null||c===null||s===null||i===null||t.push({timestamp:r,open:a,high:o,low:c,close:s,volume:i,turnover:u??i*s});}return C(t)}function P(e){if(!Array.isArray(e))return [];let t=[];for(let n of e){if(!Array.isArray(n))continue;let r=l(n[0]),a=l(n[1]),o=l(n[2]),c=l(n[3]),s=l(n[4]),i=l(n[5]),u=l(n[6]),f=l(n[7]);r===null||a===null||o===null||c===null||s===null||i===null||t.push({timestamp:r,open:a,high:o,low:c,close:s,volume:i,turnover:f??u??i*s});}return C(t)}function T(e){if(!Array.isArray(e))return [];let t=[];for(let n of e){if(!Array.isArray(n))continue;let r=l(n[0]),a=l(n[1]),o=l(n[2]),c=l(n[3]),s=l(n[4]),i=l(n[5]),u=l(n[7])??l(n[6]);r===null||a===null||o===null||c===null||s===null||i===null||t.push({timestamp:r,open:a,high:o,low:c,close:s,volume:i,turnover:u??i*s});}return C(t)}var ne={id:"BINANCE",async getHistoryBars(e,t,n,r){let a=N(t);if(a===null)return p(e,t,"unsupported-period",`Binance does not support period ${t.text}`),[];let o=x(t,n,r),c=b(e),s=new URL(`${A}/klines`);s.searchParams.set("symbol",c),s.searchParams.set("interval",a),s.searchParams.set("startTime",`${o.from}`),s.searchParams.set("endTime",`${o.to}`),s.searchParams.set("limit","1000");let i=new URL(`${A}/klines`);i.searchParams.set("symbol",c),i.searchParams.set("interval",a),i.searchParams.set("endTime",`${o.to}`),i.searchParams.set("limit","1000");let u=await g(s.toString());u===null&&p(e,t,"history-request-failed","Binance history request failed");let f=M(u),m=I(f,o.from,o.to);if(m.length<E){let d=await g(i.toString()),S=M(d).filter(y=>y.timestamp<=o.to);S.length>m.length&&(m=S);}return m.length===0&&p(e,t,"history-empty","Binance returned no candle data for this range"),m},getWebSocketUrl(e,t){let n=N(t);return n===null?"wss://invalid":`${j}/${b(e).toLowerCase()}@kline_${n}`},parseMessage(e){let t=te(U(e.data));if(!t||typeof t!="object")return null;let n=t;if(n.e!=="kline"||!n.k)return null;let r=l(n.k.t),a=l(n.k.o),o=l(n.k.h),c=l(n.k.l),s=l(n.k.c),i=l(n.k.v),u=l(n.k.q);return r===null||a===null||o===null||c===null||s===null||i===null?null:{timestamp:r,open:a,high:o,low:c,close:s,volume:i,turnover:u??i*s}}},re={id:"BITGET",async getHistoryBars(e,t,n,r){let a=O(t);if(a===null)return p(e,t,"unsupported-period",`Bitget does not support period ${t.text}`),[];let o=x(t,n,r),c=b(e),s=Z(e),i=new URL(`${_}/candles`);i.searchParams.set("symbol",c),i.searchParams.set("productType",s),i.searchParams.set("granularity",a),i.searchParams.set("startTime",`${o.from}`),i.searchParams.set("endTime",`${o.to}`),i.searchParams.set("limit","1000");let u=new URL(`${_}/candles`);u.searchParams.set("symbol",c),u.searchParams.set("productType",s),u.searchParams.set("granularity",a),u.searchParams.set("limit","1000");let f=await g(i.toString());f===null&&p(e,t,"history-request-failed","Bitget history request failed");let m=P(f?.data),d=I(m,o.from,o.to);if(d.length<E){let h=await g(u.toString()),y=P(h?.data).filter(k=>k.timestamp<=o.to);y.length>d.length&&(d=y);}return d.length===0&&p(e,t,"history-empty","Bitget returned no candle data for this range"),d},getWebSocketUrl(){return J},onOpen(e,t,n){let r=O(n);if(r===null){p(t,n,"unsupported-period",`Bitget does not support period ${n.text}`);return}let a=Q(t);e.send(JSON.stringify({op:"subscribe",args:[{instType:a,channel:`candle${r}`,instId:b(t)}]}));},parseMessage(e){let t=U(e.data);if(!t||typeof t!="object")return null;let n=t.data;if(!Array.isArray(n))return null;let r=P(n);return r.length>0?r[r.length-1]:null}},ae={id:"OKX",async getHistoryBars(e,t,n,r){let a=W(t);if(a===null)return p(e,t,"unsupported-period",`OKX does not support period ${t.text}`),[];let o=x(t,n,r),c=F(e),s=new URL(`${R}/candles`);s.searchParams.set("instId",c),s.searchParams.set("bar",a),s.searchParams.set("limit","300");let i=new URL(`${R}/history-candles`);i.searchParams.set("instId",c),i.searchParams.set("bar",a),i.searchParams.set("limit","300");let u=await g(s.toString());u===null&&p(e,t,"history-request-failed","OKX history request failed");let f=T(u?.data),m=I(f,o.from,o.to);if(m.length<E){let d=f.filter(h=>h.timestamp<=o.to);if(d.length>m.length)m=d;else {let h=await g(i.toString()),y=T(h?.data).filter(k=>k.timestamp<=o.to);y.length>m.length&&(m=y);}}return m.length===0&&p(e,t,"history-empty","OKX returned no candle data for this range"),m},getWebSocketUrl(){return V},onOpen(e,t,n){let r=W(n);if(r===null){p(t,n,"unsupported-period",`OKX does not support period ${n.text}`);return}e.send(JSON.stringify({op:"subscribe",args:[{channel:`candle${r}`,instId:F(t)}]}));},parseMessage(e){let t=U(e.data);if(!t||typeof t!="object")return null;let n=t.data;if(!Array.isArray(n))return null;let r=T(n);return r.length>0?r[r.length-1]:null}},oe=[ne,re,ae],v=class extends b$1{adapter;constructor(t,n){super({smoothingDuration:n}),this.adapter=t;}async getHistoryBars(t,n,r,a){return this.adapter.getHistoryBars(t,n,r,a)}subscribe(t,n,r){let a=this.adapter.getWebSocketUrl(t,n);if(!a||a==="wss://invalid"){p(t,n,"subscription-failed",`No WebSocket stream available for period ${n.text}`);return}super.subscribe(t,n,r);}getWebSocketUrl(t,n){return this.adapter.getWebSocketUrl(t,n)}parseMessage(t,n,r){return this.adapter.parseMessage(t,n,r)}onOpen(t,n,r){this.adapter.onOpen?.(t,n,r);}},w=class{searchSymbols(t=""){return Promise.resolve([])}getHistoryData(t,n,r,a){return p(t,n,"unsupported-symbol",`Unsupported symbol ${t.ticker}`),Promise.resolve([])}subscribe(t,n,r){p(t,n,"subscription-failed",`No live feed available for ${t.ticker}`);}unsubscribe(t,n){}},D=class{symbols;liveFeeds=new Map;supportedExchanges=new Set;noDataFeed=new w;activeFeedByKey=new Map;constructor(t={}){this.symbols=t.symbols??X;let n=Math.max(0,t.smoothingDuration??220),r=t.adapters&&t.adapters.length>0?t.adapters:oe;for(let a of r){let o=a.id.toUpperCase();this.supportedExchanges.add(o),this.liveFeeds.set(o,new v({...a,id:o},n));}}searchSymbols(t=""){return Promise.resolve(this.symbols.filter(n=>z(t,n)))}async getHistoryData(t,n,r,a){return this.resolveFeed(t).getHistoryData(t,n,r,a)}subscribe(t,n,r){let a=$(t,n);this.unsubscribe(t,n);let o=this.resolveFeed(t);this.activeFeedByKey.set(a,o),o.subscribe(this.normalizeSymbol(t),n,r);}unsubscribe(t,n){let r=$(t,n);(this.activeFeedByKey.get(r)??this.resolveFeed(t)).unsubscribe(this.normalizeSymbol(t),n),this.activeFeedByKey.delete(r);}normalizeSymbol(t){let n=this.resolveExchange(t);return n?ee(t,n):t}resolveFeed(t){let n=this.resolveExchange(t);if(n!==null){let r=this.liveFeeds.get(n);if(r)return r}return this.noDataFeed}resolveExchange(t){let n=K(t);return n&&this.supportedExchanges.has(n)?n:null}};function ie(e={}){return new D(e)}
|
|
3
|
-
export{X as a,G as b,ne as c,re as d,ae as e,D as f,ie as g};
|