@rotorjs/dashboard 0.5.1 → 0.6.0

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.
@@ -19,12 +19,12 @@ export declare class DashboardEnvironment extends TypedEventTarget<{
19
19
  get target(): DashboardEventTarget;
20
20
  get id(): string;
21
21
  get signal(): AbortSignal;
22
+ get vars(): readonly [name: string, value: DashboardVar][];
23
+ get facts(): readonly [name: string, value: DashboardFact][];
22
24
  hasVar(name: string): boolean;
23
25
  getVar(name: string): DashboardVar | undefined;
24
- getVars(): [name: string, value: DashboardVar][];
25
26
  hasFact(name: string): boolean;
26
27
  getFact(name: string): DashboardFact | undefined;
27
- getFacts(): [name: string, value: DashboardFact][];
28
28
  stop(): void;
29
29
  }
30
30
  export declare class VarEvent extends Event {
package/dist/main.js CHANGED
@@ -7,9 +7,11 @@ var c = class extends a {
7
7
  #t = s();
8
8
  #n;
9
9
  #r;
10
- #i = new AbortController();
10
+ #i;
11
+ #a;
12
+ #o = new AbortController();
11
13
  constructor(t, n) {
12
- super(), this.#e = t, this.#n = Object.fromEntries(Object.entries(n?.vars ?? {}).map(([e, t]) => [e, Object.freeze(t)])), this.#r = Object.fromEntries(Object.entries(n?.facts ?? {}).map(([e, t]) => [e, Object.freeze(t)]));
14
+ super(), this.#e = t, this.#n = Object.fromEntries(Object.entries(n?.vars ?? {}).map(([e, t]) => [e, Object.freeze(t)])), this.#i = Object.fromEntries(Object.entries(n?.facts ?? {}).map(([e, t]) => [e, Object.freeze(t)]));
13
15
  let r = this.signal;
14
16
  this.target.addEventListener("action", (t) => {
15
17
  if (t.emitter === this.#t) return;
@@ -20,15 +22,15 @@ var c = class extends a {
20
22
  value: n.value,
21
23
  exposed: n.exposed ?? !1
22
24
  });
23
- o(e, t) || (this.#n[n.name] = t, this.dispatchEvent(new l(n.name, t.value, t.exposed)));
25
+ o(e, t) || (this.#n[n.name] = t, this.#r = void 0, this.dispatchEvent(new l(n.name, t.value, t.exposed)));
24
26
  return;
25
27
  }
26
28
  case "fact": {
27
- let e = this.#r[n.name], t = Object.freeze({ value: n.value });
28
- o(e, t) || (this.#r[n.name] = t, this.dispatchEvent(new u(n.name, t.value)));
29
+ let e = this.#i[n.name], t = Object.freeze({ value: n.value });
30
+ o(e, t) || (this.#i[n.name] = t, this.#a = void 0, this.dispatchEvent(new u(n.name, t.value)));
29
31
  return;
30
32
  }
31
- case "sync": Object.entries(this.#n).forEach(([t, { value: n, exposed: r }]) => {
33
+ case "sync": this.vars.forEach(([t, { value: n, exposed: r }]) => {
32
34
  let i = new e({
33
35
  type: "var",
34
36
  name: t,
@@ -36,7 +38,7 @@ var c = class extends a {
36
38
  exposed: r
37
39
  });
38
40
  i.emitter = this.#t, this.target.dispatchEvent(i);
39
- }), Object.entries(this.#r).forEach(([t, { value: n }]) => {
41
+ }), this.facts.forEach(([t, { value: n }]) => {
40
42
  let r = new e({
41
43
  type: "fact",
42
44
  name: t,
@@ -54,7 +56,13 @@ var c = class extends a {
54
56
  return this.#t;
55
57
  }
56
58
  get signal() {
57
- return this.#i.signal;
59
+ return this.#o.signal;
60
+ }
61
+ get vars() {
62
+ return this.#r ||= Object.freeze(Object.entries(this.#n)), this.#r;
63
+ }
64
+ get facts() {
65
+ return this.#a ||= Object.freeze(Object.entries(this.#i)), this.#a;
58
66
  }
59
67
  hasVar(e) {
60
68
  return Object.hasOwn(this.#n, e);
@@ -62,20 +70,14 @@ var c = class extends a {
62
70
  getVar(e) {
63
71
  return this.#n[e];
64
72
  }
65
- getVars() {
66
- return Object.entries(this.#n);
67
- }
68
73
  hasFact(e) {
69
- return Object.hasOwn(this.#r, e);
74
+ return Object.hasOwn(this.#i, e);
70
75
  }
71
76
  getFact(e) {
72
- return this.#r[e];
73
- }
74
- getFacts() {
75
- return Object.entries(this.#r);
77
+ return this.#i[e];
76
78
  }
77
79
  stop() {
78
- this.#i.abort();
80
+ this.#o.abort();
79
81
  }
80
82
  }, l = class extends Event {
81
83
  #e;
@@ -206,8 +208,9 @@ var p = class extends n {
206
208
  getLocale(e) {
207
209
  if (e?.locale) return e.locale;
208
210
  if (this.#e?.locale) return this.#e.locale;
211
+ this.#e?.reducer?.addInterest(f(_));
209
212
  let t = this.#e?.reducer?.engine.getFact(_)?.value;
210
- return this.#e?.reducer?.addInterest(f(_)), typeof t == "string" ? t : void 0;
213
+ return typeof t == "string" && t ? t : void 0;
211
214
  }
212
215
  getFormat(e) {
213
216
  return new Intl.NumberFormat(this.getLocale(e));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rotorjs/dashboard",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Rotor",
5
5
  "author": {
6
6
  "name": "Aaron Burmeister"
@@ -46,19 +46,19 @@
46
46
  "@types/react": "^19.2.17",
47
47
  "@types/react-dom": "^19.1.9",
48
48
  "@vitejs/plugin-react": "^6.0.2",
49
- "eslint": "^10.4.1",
49
+ "eslint": "^10.5.0",
50
50
  "eslint-config-prettier": "^10.1.8",
51
51
  "eslint-import-resolver-typescript": "^4.4.5",
52
52
  "eslint-plugin-import-x": "^4.16.2",
53
53
  "eslint-plugin-prettier": "^5.5.6",
54
54
  "eslint-plugin-react-hooks": "^7.1.1",
55
- "eslint-plugin-react-refresh": "^0.5.2",
55
+ "eslint-plugin-react-refresh": "^0.5.3",
56
56
  "globals": "^17.6.0",
57
57
  "prettier": "^3.8.4",
58
58
  "react": "^19.2.7",
59
59
  "react-dom": "^19.2.7",
60
60
  "typescript": "^6.0.3",
61
- "typescript-eslint": "^8.61.0",
61
+ "typescript-eslint": "^8.61.1",
62
62
  "unplugin-dts": "^1.0.2",
63
63
  "vite": "^8.0.16"
64
64
  },