@synnaxlabs/x 0.26.7 → 0.28.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.
Files changed (92) hide show
  1. package/.turbo/turbo-build.log +20 -18
  2. package/dist/compare.cjs +1 -1
  3. package/dist/compare.js +1 -1
  4. package/dist/deep.cjs +1 -1
  5. package/dist/deep.js +39 -39
  6. package/dist/{index-DCwgKLH_.js → index-DPWtMAJa.js} +12 -8
  7. package/dist/index-DYgqYo6X.cjs +1 -0
  8. package/dist/index.cjs +2 -2
  9. package/dist/index.js +172 -158
  10. package/dist/kv.cjs +1 -1
  11. package/dist/kv.js +2 -4
  12. package/dist/observe.cjs +1 -1
  13. package/dist/observe.js +26 -16
  14. package/dist/path-577Fmn5N.cjs +1 -0
  15. package/dist/path-B-1-i3qC.js +72 -0
  16. package/dist/{series-CaeAWaDJ.js → series-DIZdmPCa.js} +65 -50
  17. package/dist/{series-CNcMldp_.cjs → series-DMsaUp_n.cjs} +7 -7
  18. package/dist/src/binary/encoder.d.ts +0 -1
  19. package/dist/src/change/change.d.ts +0 -1
  20. package/dist/src/clamp/clamp.d.ts +0 -1
  21. package/dist/src/compare/compare.d.ts +5 -1
  22. package/dist/src/compare/compare.d.ts.map +1 -1
  23. package/dist/src/control/control.d.ts +0 -1
  24. package/dist/src/control/index.d.ts.map +1 -1
  25. package/dist/src/deep/delete.d.ts +0 -1
  26. package/dist/src/deep/equal.d.ts +0 -1
  27. package/dist/src/deep/merge.d.ts +0 -1
  28. package/dist/src/deep/path.d.ts +78 -3
  29. package/dist/src/deep/path.d.ts.map +1 -1
  30. package/dist/src/errors/errors.d.ts.map +1 -1
  31. package/dist/src/errors/index.d.ts.map +1 -1
  32. package/dist/src/id/id.d.ts +0 -1
  33. package/dist/src/identity.d.ts +0 -1
  34. package/dist/src/kv/types.d.ts +16 -0
  35. package/dist/src/kv/types.d.ts.map +1 -1
  36. package/dist/src/migrate/migrate.d.ts +34 -5
  37. package/dist/src/migrate/migrate.d.ts.map +1 -1
  38. package/dist/src/mock/MockGLBufferController.d.ts +5 -6
  39. package/dist/src/mock/MockGLBufferController.d.ts.map +1 -1
  40. package/dist/src/numeric/index.d.ts.map +1 -1
  41. package/dist/src/numeric/numeric.d.ts.map +1 -1
  42. package/dist/src/observe/observe.d.ts +24 -2
  43. package/dist/src/observe/observe.d.ts.map +1 -1
  44. package/dist/src/primitive.d.ts +1 -2
  45. package/dist/src/primitive.d.ts.map +1 -1
  46. package/dist/src/record.d.ts +0 -1
  47. package/dist/src/renderable.d.ts +0 -1
  48. package/dist/src/runtime/os.d.ts +0 -1
  49. package/dist/src/search.d.ts +0 -1
  50. package/dist/src/spatial/base.d.ts +0 -1
  51. package/dist/src/spatial/bounds/bounds.d.ts +0 -1
  52. package/dist/src/spatial/box/box.d.ts +0 -1
  53. package/dist/src/spatial/dimensions/dimensions.d.ts +0 -1
  54. package/dist/src/spatial/direction/direction.d.ts +0 -1
  55. package/dist/src/spatial/location/location.d.ts +0 -1
  56. package/dist/src/spatial/position/position.d.ts +0 -1
  57. package/dist/src/spatial/scale/scale.d.ts +0 -1
  58. package/dist/src/spatial/xy/xy.d.ts +0 -1
  59. package/dist/src/telem/generate.d.ts +0 -1
  60. package/dist/src/telem/series.d.ts +0 -1
  61. package/dist/src/telem/telem.d.ts +19 -1
  62. package/dist/src/telem/telem.d.ts.map +1 -1
  63. package/dist/src/zodutil/zodutil.d.ts +0 -1
  64. package/dist/telem.cjs +1 -1
  65. package/dist/telem.js +1 -1
  66. package/dist/types-BpAJW2TM.js +11 -0
  67. package/dist/types-zRwnQ1hc.cjs +1 -0
  68. package/dist/zodutil.cjs +1 -1
  69. package/dist/zodutil.js +1 -1
  70. package/package.json +3 -3
  71. package/src/caseconv/caseconv.spec.ts +9 -0
  72. package/src/compare/compare.ts +6 -0
  73. package/src/control/index.ts +9 -0
  74. package/src/deep/path.spec.ts +29 -0
  75. package/src/deep/path.ts +102 -10
  76. package/src/errors/errors.ts +9 -0
  77. package/src/errors/index.ts +9 -0
  78. package/src/kv/types.ts +13 -0
  79. package/src/migrate/migrate.spec.ts +78 -0
  80. package/src/migrate/migrate.ts +69 -9
  81. package/src/mock/MockGLBufferController.ts +7 -7
  82. package/src/numeric/index.ts +9 -0
  83. package/src/numeric/numeric.ts +9 -0
  84. package/src/observe/observe.ts +30 -1
  85. package/src/primitive.ts +1 -1
  86. package/src/telem/series.spec.ts +14 -0
  87. package/src/telem/series.ts +1 -1
  88. package/src/telem/telem.ts +26 -0
  89. package/tsconfig.tsbuildinfo +1 -1
  90. package/dist/index-CvHP07Bs.cjs +0 -1
  91. package/dist/path-Coj1BKMh.cjs +0 -1
  92. package/dist/path-DH9iaDDf.js +0 -58
package/dist/index.js CHANGED
@@ -1,196 +1,210 @@
1
- var $ = Object.defineProperty;
2
- var M = (e, r, t) => r in e ? $(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var m = (e, r, t) => M(e, typeof r != "symbol" ? r + "" : r, t);
4
- import { e as _ } from "./index-CzjnpuXF.js";
5
- import { a as I } from "./index-C9i674Sf.js";
6
- import { c as Q } from "./change-DLl6DccR.js";
7
- import { c as F, s as H } from "./scale-BgCpxgAk.js";
8
- import { i as w, a as E } from "./index-DCwgKLH_.js";
9
- import { c as X, b as Y, p as ee } from "./index-DCwgKLH_.js";
1
+ var T = Object.defineProperty;
2
+ var $ = (r, o, e) => o in r ? T(r, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[o] = e;
3
+ var m = (r, o, e) => $(r, typeof o != "symbol" ? o + "" : o, e);
4
+ import { e as I } from "./index-CzjnpuXF.js";
5
+ import { a as F } from "./index-C9i674Sf.js";
6
+ import { c as X } from "./change-DLl6DccR.js";
7
+ import { c as rr, s as er } from "./scale-BgCpxgAk.js";
8
+ import { L as b, G as y, E as k, i as w, a as j, b as A } from "./index-DPWtMAJa.js";
9
+ import { c as tr, d as nr, p as sr } from "./index-DPWtMAJa.js";
10
10
  import { z as i } from "zod";
11
- import { debounce as oe, throttle as te } from "./debounce.js";
12
- import { deep as ne } from "./deep.js";
13
- import { d as ae, D as ce, M as le, R as fe, S as me, e as pe, c as ue, b as ge, T as de, a as xe, g as be, h as ye, i as Se, f as ve, t as he } from "./series-CaeAWaDJ.js";
14
- import { isObject as Me } from "./identity.js";
15
- import { kv as Ee } from "./kv.js";
16
- import { b as je, m as ke } from "./bounds-CpboA0q6.js";
17
- import { observe as Ae } from "./observe.js";
18
- import { getEntries as ze, unknownRecordZ as Ve } from "./record.js";
19
- import { e as Ne } from "./external-CO221aaF.js";
20
- import { Search as Ge } from "./search.js";
21
- import { b as Le } from "./box-B5SaODGu.js";
22
- import { d as We } from "./dimensions-D-1PnJVI.js";
23
- import { d as _e } from "./direction-CScbfCdT.js";
24
- import { l as Ie } from "./location-C6sCnzhU.js";
25
- import { p as Qe } from "./position-BY9oBMZB.js";
26
- import { s as Fe } from "./spatial-DozyssiN.js";
27
- import { x as Je } from "./xy-CrgPnICw.js";
28
- import { nullToArr as Ye, toArray as er } from "./toArray.js";
29
- import { unique as or } from "./unique.js";
30
- import { URL as sr, buildQueryString as nr } from "./url.js";
31
- import { RoutedWorker as ar, TypedWorker as cr, createMockWorkers as lr } from "./worker.js";
11
+ import { debounce as ar, throttle as cr } from "./debounce.js";
12
+ import { deep as fr } from "./deep.js";
13
+ import { d as mr, D as pr, M as gr, R as dr, S as xr, e as br, c as yr, b as Sr, T as hr, a as vr, g as Er, h as Mr, i as Tr, f as $r, t as kr } from "./series-DIZdmPCa.js";
14
+ import { isObject as jr } from "./identity.js";
15
+ import { t as Or } from "./types-BpAJW2TM.js";
16
+ import { b as Nr, m as zr } from "./bounds-CpboA0q6.js";
17
+ import { observe as Lr } from "./observe.js";
18
+ import { getEntries as Vr, unknownRecordZ as Dr } from "./record.js";
19
+ import { e as _r } from "./external-CO221aaF.js";
20
+ import { Search as Cr } from "./search.js";
21
+ import { b as Br } from "./box-B5SaODGu.js";
22
+ import { d as Qr } from "./dimensions-D-1PnJVI.js";
23
+ import { d as Ir } from "./direction-CScbfCdT.js";
24
+ import { l as Fr } from "./location-C6sCnzhU.js";
25
+ import { p as Xr } from "./position-BY9oBMZB.js";
26
+ import { s as re } from "./spatial-DozyssiN.js";
27
+ import { x as oe } from "./xy-CrgPnICw.js";
28
+ import { nullToArr as ne, toArray as se } from "./toArray.js";
29
+ import { unique as ae } from "./unique.js";
30
+ import { URL as le, buildQueryString as fe } from "./url.js";
31
+ import { RoutedWorker as me, TypedWorker as pe, createMockWorkers as ge } from "./worker.js";
32
32
  const a = class a extends Number {
33
33
  };
34
34
  m(a, "Absolute", 255), m(a, "Default", 1), m(a, "z", i.union([
35
35
  i.instanceof(a),
36
- i.number().int().min(0).max(255).transform((r) => new a(r)),
37
- i.instanceof(Number).transform((r) => new a(r))
36
+ i.number().int().min(0).max(255).transform((o) => new a(o)),
37
+ i.instanceof(Number).transform((o) => new a(o))
38
38
  ]));
39
- let g = a;
40
- const y = i.object({
39
+ let x = a;
40
+ const v = i.object({
41
41
  name: i.string(),
42
42
  key: i.string()
43
- }), T = (e) => i.object({
44
- subject: y,
45
- resource: e,
46
- authority: g.z
47
- }), j = (...e) => (r) => r.filter((t) => {
48
- let o = !1;
49
- return t.to != null && (o = e.includes(t.to.resource)), t.from != null && !o && (o = e.includes(t.from.resource)), o;
50
- }), N = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
43
+ }), O = (r) => i.object({
44
+ subject: v,
45
+ resource: r,
46
+ authority: x.z
47
+ }), R = (...r) => (o) => o.filter((e) => {
48
+ let t = !1;
49
+ return e.to != null && (t = r.includes(e.to.resource)), e.from != null && !t && (t = r.includes(e.from.resource)), t;
50
+ }), _ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
51
51
  __proto__: null,
52
- Authority: g,
53
- filterTransfersByChannelKey: j,
54
- stateZ: T,
55
- subjectZ: y
52
+ Authority: x,
53
+ filterTransfersByChannelKey: R,
54
+ stateZ: O,
55
+ subjectZ: v
56
56
  }, Symbol.toStringTag, { value: "Module" })), c = class c extends Error {
57
57
  constructor() {
58
58
  super(c.MESSAGE);
59
59
  }
60
60
  /** Returns true if the error or message is a cancellation error" */
61
- matches(r) {
62
- return typeof r == "string" ? r.includes(c.MESSAGE) : r instanceof c || r.message.includes(c.MESSAGE);
61
+ matches(o) {
62
+ return typeof o == "string" ? o.includes(c.MESSAGE) : o instanceof c || o.message.includes(c.MESSAGE);
63
63
  }
64
64
  };
65
65
  m(c, "MESSAGE", "canceled");
66
- let x = c;
67
- const k = new x(), Z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
66
+ let S = c;
67
+ const N = new S(), q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
68
68
  __proto__: null,
69
- CANCELED: k
70
- }, Symbol.toStringTag, { value: "Module" })), G = (e) => e ? -1 : 1, b = i.string().regex(/^\d+\.\d+\.\d+$/), d = (e, r) => {
71
- const t = b.parse(e), o = b.parse(r), [l, p, u] = t.split(".").map(Number), [f, s, n] = o.split(".").map(Number);
72
- return l !== f ? l - f : p !== s ? p - s : u - n;
73
- }, S = (e, r) => w(d(e, r)), O = (e, r) => E(d(e, r)), A = ({
74
- name: e,
75
- migrate: r
76
- }) => (t) => {
69
+ CANCELED: N
70
+ }, Symbol.toStringTag, { value: "Module" })), C = (r) => r ? -1 : 1, h = i.string().regex(/^\d+\.\d+\.\d+$/), p = (r, o, e = {}) => {
71
+ e.checkMajor ?? (e.checkMajor = !0), e.checkMinor ?? (e.checkMinor = !0), e.checkPatch ?? (e.checkPatch = !0);
72
+ const t = h.parse(r), l = h.parse(o), [g, f, u] = t.split(".").map(Number), [n, s, d] = l.split(".").map(Number);
73
+ if (e.checkMajor) {
74
+ if (g < n) return b;
75
+ if (g > n) return y;
76
+ }
77
+ if (e.checkMinor) {
78
+ if (f < s) return b;
79
+ if (f > s) return y;
80
+ }
81
+ if (e.checkPatch) {
82
+ if (u < d) return b;
83
+ if (u > d) return y;
84
+ }
85
+ return k;
86
+ }, z = (r, o, e = {}) => w(p(r, o, e)), E = (r, o, e = {}) => j(p(r, o, e)), G = (r, o, e = {}) => A(p(r, o, e)), L = ({
87
+ name: r,
88
+ migrate: o
89
+ }) => (e) => {
77
90
  try {
78
- const o = r(t);
79
- return console.log(`${e} migrated: ${t.version} -> ${o.version}`), o;
80
- } catch (o) {
81
- throw console.log(`${e} failed to migrate from ${t.version}`), console.error(o), o;
91
+ const t = o(e);
92
+ return console.log(`${r} migrated: ${e.version} -> ${t.version}`), t;
93
+ } catch (t) {
94
+ throw console.log(`${r} failed to migrate from ${e.version}`), console.error(t), t;
82
95
  }
83
- }, R = ({
84
- name: e,
85
- migrations: r,
86
- targetSchema: t,
87
- def: o
96
+ }, P = ({
97
+ name: r,
98
+ migrations: o,
99
+ targetSchema: e,
100
+ def: t
88
101
  }) => {
89
- const l = Object.keys(r).sort(d).pop();
102
+ const l = Object.keys(o).sort(p).pop();
90
103
  if (l == null)
91
- return (s) => {
92
- if (s.version !== o.version)
104
+ return (n) => {
105
+ if (n.version !== t.version)
93
106
  return console.log(
94
- `${e} version ${s.version} is newer than latest version of ${o.version}.
107
+ `${r} version ${n.version} is newer than latest version of ${t.version}.
95
108
  Returning default instead.
96
109
  `
97
- ), o;
110
+ ), t;
98
111
  try {
99
- return t != null ? t.parse(s) : s;
100
- } catch (n) {
101
- return console.log(`${e} failed to parse default. Exiting with default`), console.error(n), o;
112
+ return e != null ? e.parse(n) : n;
113
+ } catch (s) {
114
+ return console.log(`${r} failed to parse default. Exiting with default`), console.error(s), t;
102
115
  }
103
116
  };
104
- const p = Object.keys(r).length;
105
- let u = !1;
106
- const f = (s) => {
117
+ const g = Object.keys(o).length;
118
+ let f = !1;
119
+ const u = (n) => {
107
120
  try {
108
- if (p === 0 || S(s.version, l))
109
- return console.log(u ? `${e} ${s.version} now up to date` : `${e} version ${s.version} is up to date with target version ${o.version}`), s;
110
- const n = s.version, v = r[n], h = v(s);
111
- return u = !0, f(h);
112
- } catch (n) {
121
+ if (g === 0 || E(n.version, l))
122
+ return console.log(f ? `${r} ${n.version} now up to date` : `${r} version ${n.version} is up to date with target version ${t.version}`), n;
123
+ const s = n.version, d = o[s], M = d(n);
124
+ return f = !0, u(M);
125
+ } catch (s) {
113
126
  return console.log(
114
- `${e} failed to migrate from ${s.version} to ${l}`
115
- ), console.error(n), o;
127
+ `${r} failed to migrate from ${n.version} to ${l}`
128
+ ), console.error(s), t;
116
129
  }
117
130
  };
118
- return (s) => {
131
+ return (n) => {
119
132
  try {
120
- return f(s);
121
- } catch (n) {
122
- return console.log(`${e} failed to parse final result. Exiting with default`), console.error(n), o;
133
+ return u(n);
134
+ } catch (s) {
135
+ return console.log(`${r} failed to parse final result. Exiting with default`), console.error(s), t;
123
136
  }
124
137
  };
125
- }, P = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
138
+ }, W = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
126
139
  __proto__: null,
127
- compareSemVer: d,
128
- createMigration: A,
129
- migrator: R,
130
- semVerNewer: S,
131
- semVerOlder: O,
132
- semVerZ: b
133
- }, Symbol.toStringTag, { value: "Module" })), L = (e) => {
134
- if (e === void 0 || typeof e == "string" || typeof e == "number")
135
- return e;
136
- if (e.toString === void 0) throw new Error("invalid renderer");
137
- return e.toString();
138
- }, C = (e) => Array.isArray(e) ? [...e] : typeof e == "object" && e !== null ? { ...e } : e;
140
+ compareSemVer: p,
141
+ createMigration: L,
142
+ migrator: P,
143
+ semVerNewer: E,
144
+ semVerOlder: G,
145
+ semVerZ: h,
146
+ versionsEqual: z
147
+ }, Symbol.toStringTag, { value: "Module" })), B = (r) => {
148
+ if (r === void 0 || typeof r == "string" || typeof r == "number")
149
+ return r;
150
+ if (r.toString === void 0) throw new Error("invalid renderer");
151
+ return r.toString();
152
+ }, H = (r) => Array.isArray(r) ? [...r] : typeof r == "object" && r !== null ? { ...r } : r;
139
153
  export {
140
- ae as DataType,
141
- ce as Density,
142
- le as MultiSeries,
143
- fe as Rate,
144
- ar as RoutedWorker,
145
- Ge as Search,
146
- me as Series,
147
- pe as Size,
148
- ue as TimeRange,
149
- ge as TimeSpan,
150
- de as TimeStamp,
151
- cr as TypedWorker,
152
- sr as URL,
153
- xe as addSamples,
154
- _ as binary,
155
- je as bounds,
156
- Le as box,
157
- nr as buildQueryString,
158
- I as caseconv,
159
- Q as change,
160
- F as clamp,
161
- X as compare,
162
- N as control,
163
- be as convertDataType,
164
- L as convertRenderV,
165
- lr as createMockWorkers,
166
- oe as debounce,
167
- ne as deep,
168
- We as dimensions,
169
- _e as direction,
170
- Z as errors,
171
- ze as getEntries,
172
- ye as id,
173
- G as invert,
174
- Se as isCrudeSeries,
175
- Me as isObject,
176
- Y as isStringer,
177
- ve as isTelemValue,
178
- Ee as kv,
179
- Ie as location,
180
- ke as math,
181
- P as migrate,
182
- Ye as nullToArr,
183
- Ae as observe,
184
- Qe as position,
185
- ee as primitiveIsZero,
186
- Ne as runtime,
187
- H as scale,
188
- C as shallowCopy,
189
- Fe as spatial,
190
- te as throttle,
191
- er as toArray,
192
- he as typedArrayZ,
193
- or as unique,
194
- Ve as unknownRecordZ,
195
- Je as xy
154
+ mr as DataType,
155
+ pr as Density,
156
+ gr as MultiSeries,
157
+ dr as Rate,
158
+ me as RoutedWorker,
159
+ Cr as Search,
160
+ xr as Series,
161
+ br as Size,
162
+ yr as TimeRange,
163
+ Sr as TimeSpan,
164
+ hr as TimeStamp,
165
+ pe as TypedWorker,
166
+ le as URL,
167
+ vr as addSamples,
168
+ I as binary,
169
+ Nr as bounds,
170
+ Br as box,
171
+ fe as buildQueryString,
172
+ F as caseconv,
173
+ X as change,
174
+ rr as clamp,
175
+ tr as compare,
176
+ _ as control,
177
+ Er as convertDataType,
178
+ B as convertRenderV,
179
+ ge as createMockWorkers,
180
+ ar as debounce,
181
+ fr as deep,
182
+ Qr as dimensions,
183
+ Ir as direction,
184
+ q as errors,
185
+ Vr as getEntries,
186
+ Mr as id,
187
+ C as invert,
188
+ Tr as isCrudeSeries,
189
+ jr as isObject,
190
+ nr as isStringer,
191
+ $r as isTelemValue,
192
+ Or as kv,
193
+ Fr as location,
194
+ zr as math,
195
+ W as migrate,
196
+ ne as nullToArr,
197
+ Lr as observe,
198
+ Xr as position,
199
+ sr as primitiveIsZero,
200
+ _r as runtime,
201
+ er as scale,
202
+ H as shallowCopy,
203
+ re as spatial,
204
+ cr as throttle,
205
+ se as toArray,
206
+ kr as typedArrayZ,
207
+ ae as unique,
208
+ Dr as unknownRecordZ,
209
+ oe as xy
196
210
  };
package/dist/kv.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.kv=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./types-zRwnQ1hc.cjs");exports.kv=e.types;
package/dist/kv.js CHANGED
@@ -1,6 +1,4 @@
1
- const e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2
- __proto__: null
3
- }, Symbol.toStringTag, { value: "Module" }));
1
+ import { t } from "./types-BpAJW2TM.js";
4
2
  export {
5
- e as kv
3
+ t as kv
6
4
  };
package/dist/observe.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var l=Object.defineProperty;var a=(t,e,r)=>e in t?l(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>a(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class h{constructor(e,r){n(this,"handlers");n(this,"transform");this.transform=e,this.handlers=r??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let r=e;if(this.transform!=null){const[s,o]=this.transform(e);if(!o)return;r=s}this.handlers.forEach((s,o)=>o(r))}}class i{constructor(e){n(this,"handlers");this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((r,s)=>s(e))}}const c=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:i,Observer:h},Symbol.toStringTag,{value:"Module"}));exports.observe=c;
1
+ "use strict";var l=Object.defineProperty;var a=(r,e,s)=>e in r?l(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s;var t=(r,e,s)=>a(r,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class h{constructor(e,s){t(this,"handlers");t(this,"transform");t(this,"closer");this.transform=e,this.handlers=s??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){let s=e;if(this.transform!=null){const[n,o]=this.transform(e);if(!o)return;s=n}this.handlers.forEach((n,o)=>o(s))}setCloser(e){this.closer=e}async close(){var e;return await((e=this.closer)==null?void 0:e.call(this))}}class i{constructor(e){t(this,"handlers");this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((s,n)=>n(e))}}const c=Object.freeze(Object.defineProperty({__proto__:null,BaseObserver:i,Observer:h},Symbol.toStringTag,{value:"Module"}));exports.observe=c;
package/dist/observe.js CHANGED
@@ -1,41 +1,51 @@
1
- var h = Object.defineProperty;
2
- var l = (s, e, r) => e in s ? h(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
3
- var n = (s, e, r) => l(s, typeof e != "symbol" ? e + "" : e, r);
4
- class o {
5
- constructor(e, r) {
6
- n(this, "handlers");
7
- n(this, "transform");
8
- this.transform = e, this.handlers = r ?? /* @__PURE__ */ new Map();
1
+ var o = Object.defineProperty;
2
+ var a = (r, e, s) => e in r ? o(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
+ var t = (r, e, s) => a(r, typeof e != "symbol" ? e + "" : e, s);
4
+ class h {
5
+ constructor(e, s) {
6
+ t(this, "handlers");
7
+ t(this, "transform");
8
+ t(this, "closer");
9
+ this.transform = e, this.handlers = s ?? /* @__PURE__ */ new Map();
9
10
  }
11
+ /** Implements the observable interface. */
10
12
  onChange(e) {
11
13
  return this.handlers.set(e, null), () => this.handlers.delete(e);
12
14
  }
15
+ /** Notifies all handlers that the value of the observable has changed. */
13
16
  notify(e) {
14
- let r = e;
17
+ let s = e;
15
18
  if (this.transform != null) {
16
- const [t, a] = this.transform(e);
17
- if (!a) return;
18
- r = t;
19
+ const [n, l] = this.transform(e);
20
+ if (!l) return;
21
+ s = n;
19
22
  }
20
- this.handlers.forEach((t, a) => a(r));
23
+ this.handlers.forEach((n, l) => l(s));
24
+ }
25
+ setCloser(e) {
26
+ this.closer = e;
27
+ }
28
+ async close() {
29
+ var e;
30
+ return await ((e = this.closer) == null ? void 0 : e.call(this));
21
31
  }
22
32
  }
23
33
  class i {
24
34
  constructor(e) {
25
- n(this, "handlers");
35
+ t(this, "handlers");
26
36
  this.handlers = e ?? /* @__PURE__ */ new Map();
27
37
  }
28
38
  onChange(e) {
29
39
  return this.handlers.set(e, null), () => this.handlers.delete(e);
30
40
  }
31
41
  notify(e) {
32
- this.handlers.forEach((r, t) => t(e));
42
+ this.handlers.forEach((s, n) => n(e));
33
43
  }
34
44
  }
35
45
  const d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
36
46
  __proto__: null,
37
47
  BaseObserver: i,
38
- Observer: o
48
+ Observer: h
39
49
  }, Symbol.toStringTag, { value: "Module" }));
40
50
  export {
41
51
  d as observe
@@ -0,0 +1 @@
1
+ "use strict";const c=(l,n,t=".")=>{const r=l.split(t);return r.map((s,o)=>{const i=n(s,o,r);return i==null?null:typeof i=="string"?i:i.join(t)}).filter(s=>s!=null).join(t)},a=(l,n,t={optional:!1,separator:"."})=>{t.separator??(t.separator=".");const{optional:r,getter:e=(i,u)=>i[u]}=t,s=n.split(t.separator);if(s.length===1&&s[0]==="")return l;let o=l;for(const i of s){const u=e(o,i);if(u==null){if(r)return null;throw new Error(`Path ${n} does not exist. ${i} is null`)}o=u}return o},f=(l,n,t)=>{const r=n.split(".");let e=l;for(let s=0;s<r.length-1;s++){const o=r[s];e[o]==null&&(e[o]={}),e=e[o]}e[r[r.length-1]]=t},h=(l,n)=>{const t=n.split(".");let r=l;for(let e=0;e<t.length-1;e++){const s=t[e];if(r[s]==null)return;r=r[s]}if(Array.isArray(r)){const e=parseInt(t[t.length-1],10);if(isNaN(e))return;r.splice(e,1);return}delete r[t[t.length-1]]},p=(l,n)=>{const t=l.split(".");return n<0?t[t.length+n]:t[n]},g=(l,n)=>{try{return a(l,n),!0}catch{return!1}},m=(l,n)=>{if(n.length===0)return!0;const t=l.split("."),r=n.split(".");if(r.length>t.length)return!1;for(let e=0;e<r.length;e++){const s=t[e],o=r[e];if(o!=="*"&&s!==o)return!1}return!0};exports.element=p;exports.get=a;exports.has=g;exports.pathsMatch=m;exports.remove=h;exports.set=f;exports.transformPath=c;
@@ -0,0 +1,72 @@
1
+ const c = (l, e, t = ".") => {
2
+ const r = l.split(t);
3
+ return r.map((s, o) => {
4
+ const a = e(s, o, r);
5
+ return a == null ? null : typeof a == "string" ? a : a.join(t);
6
+ }).filter((s) => s != null).join(t);
7
+ }, u = (l, e, t = { optional: !1, separator: "." }) => {
8
+ t.separator ?? (t.separator = ".");
9
+ const { optional: r, getter: n = (a, i) => a[i] } = t, s = e.split(t.separator);
10
+ if (s.length === 1 && s[0] === "") return l;
11
+ let o = l;
12
+ for (const a of s) {
13
+ const i = n(o, a);
14
+ if (i == null) {
15
+ if (r) return null;
16
+ throw new Error(`Path ${e} does not exist. ${a} is null`);
17
+ }
18
+ o = i;
19
+ }
20
+ return o;
21
+ }, f = (l, e, t) => {
22
+ const r = e.split(".");
23
+ let n = l;
24
+ for (let s = 0; s < r.length - 1; s++) {
25
+ const o = r[s];
26
+ n[o] == null && (n[o] = {}), n = n[o];
27
+ }
28
+ n[r[r.length - 1]] = t;
29
+ }, p = (l, e) => {
30
+ const t = e.split(".");
31
+ let r = l;
32
+ for (let n = 0; n < t.length - 1; n++) {
33
+ const s = t[n];
34
+ if (r[s] == null) return;
35
+ r = r[s];
36
+ }
37
+ if (Array.isArray(r)) {
38
+ const n = parseInt(t[t.length - 1], 10);
39
+ if (isNaN(n)) return;
40
+ r.splice(n, 1);
41
+ return;
42
+ }
43
+ delete r[t[t.length - 1]];
44
+ }, h = (l, e) => {
45
+ const t = l.split(".");
46
+ return e < 0 ? t[t.length + e] : t[e];
47
+ }, g = (l, e) => {
48
+ try {
49
+ return u(l, e), !0;
50
+ } catch {
51
+ return !1;
52
+ }
53
+ }, m = (l, e) => {
54
+ if (e.length === 0) return !0;
55
+ const t = l.split("."), r = e.split(".");
56
+ if (r.length > t.length) return !1;
57
+ for (let n = 0; n < r.length; n++) {
58
+ const s = t[n], o = r[n];
59
+ if (o !== "*" && s !== o)
60
+ return !1;
61
+ }
62
+ return !0;
63
+ };
64
+ export {
65
+ h as e,
66
+ u as g,
67
+ g as h,
68
+ m as p,
69
+ p as r,
70
+ f as s,
71
+ c as t
72
+ };