@rotorjs/dashboard 0.5.2 → 0.7.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.
@@ -11,16 +11,14 @@ export type DashboardStateReducerMap<Engine extends DashboardEngine = DashboardE
11
11
  [type: string]: DashboardStateReducerConfig<Engine>;
12
12
  };
13
13
  export type DashboardEngineInit = {
14
- vars?: {
15
- [name: string]: DashboardVar;
16
- };
17
- facts?: {
18
- [name: string]: DashboardFact;
19
- };
14
+ vars?: [name: string, value: DashboardVar][];
15
+ facts?: [name: string, value: DashboardFact][];
20
16
  };
21
17
  export declare class DashboardEngine extends StateEngine<DashboardStateDescriptor, DashboardState, DashboardAction, DashboardEventTarget> {
22
18
  #private;
23
19
  constructor(target: DashboardEventTarget, reducerInit: DashboardStateReducerMap, init?: DashboardEngineInit);
20
+ get vars(): readonly [name: string, value: DashboardVar][];
21
+ get facts(): readonly [name: string, value: DashboardFact][];
24
22
  hasVar(name: string): boolean;
25
23
  getVar(name: string): DashboardVar | undefined;
26
24
  hasFact(name: string): boolean;
@@ -3,12 +3,8 @@ import { DashboardEventTarget } from './DashboardEventTarget';
3
3
  import { DashboardFact } from './DashboardFact';
4
4
  import { DashboardVar } from './DashboardVar';
5
5
  export type DashboardEnvironmentInit = {
6
- vars?: {
7
- [name: string]: DashboardVar;
8
- };
9
- facts?: {
10
- [name: string]: DashboardFact;
11
- };
6
+ vars?: [name: string, value: DashboardVar][];
7
+ facts?: [name: string, value: DashboardFact][];
12
8
  };
13
9
  export declare class DashboardEnvironment extends TypedEventTarget<{
14
10
  var: VarEvent;
@@ -19,12 +15,12 @@ export declare class DashboardEnvironment extends TypedEventTarget<{
19
15
  get target(): DashboardEventTarget;
20
16
  get id(): string;
21
17
  get signal(): AbortSignal;
18
+ get vars(): readonly [name: string, value: DashboardVar][];
19
+ get facts(): readonly [name: string, value: DashboardFact][];
22
20
  hasVar(name: string): boolean;
23
21
  getVar(name: string): DashboardVar | undefined;
24
- getVars(): [name: string, value: DashboardVar][];
25
22
  hasFact(name: string): boolean;
26
23
  getFact(name: string): DashboardFact | undefined;
27
- getFacts(): [name: string, value: DashboardFact][];
28
24
  stop(): void;
29
25
  }
30
26
  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(n?.vars?.map(([e, t]) => [e, Object.freeze(t)]) ?? []), this.#i = Object.fromEntries(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;
@@ -133,6 +135,12 @@ var p = class extends n {
133
135
  this.#t.stop();
134
136
  });
135
137
  }
138
+ get vars() {
139
+ return this.#t.vars;
140
+ }
141
+ get facts() {
142
+ return this.#t.facts;
143
+ }
136
144
  hasVar(e) {
137
145
  return this.#t.hasVar(e);
138
146
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rotorjs/dashboard",
3
- "version": "0.5.2",
3
+ "version": "0.7.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
  },