@placeos/ts-client 4.2.1 → 4.2.3

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/dist/index.es.js CHANGED
@@ -41,15 +41,15 @@ function Wr(t, e, n, r) {
41
41
  function u(_) {
42
42
  try {
43
43
  l(r.next(_));
44
- } catch (b) {
45
- s(b);
44
+ } catch (v) {
45
+ s(v);
46
46
  }
47
47
  }
48
48
  function c(_) {
49
49
  try {
50
50
  l(r.throw(_));
51
- } catch (b) {
52
- s(b);
51
+ } catch (v) {
52
+ s(v);
53
53
  }
54
54
  }
55
55
  function l(_) {
@@ -161,7 +161,7 @@ function Hr(t, e, n) {
161
161
  }, i;
162
162
  function s(a) {
163
163
  return function(h) {
164
- return Promise.resolve(h).then(a, b);
164
+ return Promise.resolve(h).then(a, v);
165
165
  };
166
166
  }
167
167
  function u(a, h) {
@@ -179,12 +179,12 @@ function Hr(t, e, n) {
179
179
  }
180
180
  }
181
181
  function l(a) {
182
- a.value instanceof Ae ? Promise.resolve(a.value.v).then(_, b) : p(o[0][2], a);
182
+ a.value instanceof Ae ? Promise.resolve(a.value.v).then(_, v) : p(o[0][2], a);
183
183
  }
184
184
  function _(a) {
185
185
  c("next", a);
186
186
  }
187
- function b(a) {
187
+ function v(a) {
188
188
  c("throw", a);
189
189
  }
190
190
  function p(a, h) {
@@ -268,11 +268,11 @@ var ge = function() {
268
268
  } catch (f) {
269
269
  o = f instanceof Yt ? f.errors : [f];
270
270
  }
271
- var b = this._finalizers;
272
- if (b) {
271
+ var v = this._finalizers;
272
+ if (v) {
273
273
  this._finalizers = null;
274
274
  try {
275
- for (var p = Oe(b), a = p.next(); !a.done; a = p.next()) {
275
+ for (var p = Oe(v), a = p.next(); !a.done; a = p.next()) {
276
276
  var h = a.value;
277
277
  try {
278
278
  Sn(h);
@@ -1037,7 +1037,7 @@ function yi(t, e) {
1037
1037
  function gi(t, e) {
1038
1038
  return ie(t).pipe(ur(e), sr(e));
1039
1039
  }
1040
- function vi(t, e) {
1040
+ function bi(t, e) {
1041
1041
  return new q(function(n) {
1042
1042
  var r = 0;
1043
1043
  return e.schedule(function() {
@@ -1045,7 +1045,7 @@ function vi(t, e) {
1045
1045
  });
1046
1046
  });
1047
1047
  }
1048
- function bi(t, e) {
1048
+ function vi(t, e) {
1049
1049
  return new q(function(n) {
1050
1050
  var r;
1051
1051
  return _e(n, e, function() {
@@ -1086,13 +1086,13 @@ function ki(t, e) {
1086
1086
  if (Gn(t))
1087
1087
  return yi(t, e);
1088
1088
  if (Kn(t))
1089
- return vi(t, e);
1089
+ return bi(t, e);
1090
1090
  if (Zn(t))
1091
1091
  return gi(t, e);
1092
1092
  if (Xn(t))
1093
1093
  return cr(t, e);
1094
1094
  if (nr(t))
1095
- return bi(t, e);
1095
+ return vi(t, e);
1096
1096
  if (ir(t))
1097
1097
  return Si(t, e);
1098
1098
  }
@@ -1127,8 +1127,8 @@ function I(t, e) {
1127
1127
  });
1128
1128
  }
1129
1129
  function $i(t, e, n, r, i, o, s, u) {
1130
- var c = [], l = 0, _ = 0, b = !1, p = function() {
1131
- b && !c.length && !l && e.complete();
1130
+ var c = [], l = 0, _ = 0, v = !1, p = function() {
1131
+ v && !c.length && !l && e.complete();
1132
1132
  }, a = function(f) {
1133
1133
  return l < r ? h(f) : c.push(f);
1134
1134
  }, h = function(f) {
@@ -1154,7 +1154,7 @@ function $i(t, e, n, r, i, o, s, u) {
1154
1154
  }));
1155
1155
  };
1156
1156
  return t.subscribe(J(e, a, function() {
1157
- b = !0, p();
1157
+ v = !0, p();
1158
1158
  })), function() {
1159
1159
  };
1160
1160
  }
@@ -1246,8 +1246,8 @@ function En(t, e) {
1246
1246
  n.subscribe(J(r, function(c) {
1247
1247
  i?.unsubscribe();
1248
1248
  var l = 0, _ = o++;
1249
- ie(t(c, _)).subscribe(i = J(r, function(b) {
1250
- return r.next(e ? e(c, b, _, l++) : b);
1249
+ ie(t(c, _)).subscribe(i = J(r, function(v) {
1250
+ return r.next(e ? e(c, v, _, l++) : v);
1251
1251
  }, function() {
1252
1252
  i = null, u();
1253
1253
  }));
@@ -1272,14 +1272,14 @@ function cn(t, e) {
1272
1272
  return c.removeEventListener("abort", l);
1273
1273
  });
1274
1274
  }
1275
- var _ = ze(ze({}, r), { signal: s }), b = function(p) {
1275
+ var _ = ze(ze({}, r), { signal: s }), v = function(p) {
1276
1276
  u = !1, i.error(p);
1277
1277
  };
1278
1278
  return fetch(t, _).then(function(p) {
1279
1279
  n ? ie(n(p)).subscribe(J(i, void 0, function() {
1280
1280
  u = !1, i.complete();
1281
- }, b)) : (u = !1, i.next(p), i.complete());
1282
- }).catch(b), function() {
1281
+ }, v)) : (u = !1, i.next(p), i.complete());
1282
+ }).catch(v), function() {
1283
1283
  u && o.abort();
1284
1284
  };
1285
1285
  });
@@ -1704,7 +1704,7 @@ function qi() {
1704
1704
  return k.clean(), x.fill(0), S.fill(0), R;
1705
1705
  }
1706
1706
  e.hkdf = _;
1707
- function b(p, a, h, f) {
1707
+ function v(p, a, h, f) {
1708
1708
  for (var S = new o(p), y = S.digestLength, k = new Uint8Array(4), x = new Uint8Array(y), W = new Uint8Array(y), R = new Uint8Array(f), O = 0; O * y < f; O++) {
1709
1709
  var G = O + 1;
1710
1710
  k[0] = G >>> 24 & 255, k[1] = G >>> 16 & 255, k[2] = G >>> 8 & 255, k[3] = G >>> 0 & 255, S.reset(), S.update(a), S.update(k), S.finish(W);
@@ -1724,7 +1724,7 @@ function qi() {
1724
1724
  k[O] = 0;
1725
1725
  return S.clean(), R;
1726
1726
  }
1727
- e.pbkdf2 = b;
1727
+ e.pbkdf2 = v;
1728
1728
  });
1729
1729
  }(ft)), ft.exports;
1730
1730
  }
@@ -2044,7 +2044,7 @@ function z(t) {
2044
2044
  const me = {}, Fe = {}, ue = {};
2045
2045
  function Gi() {
2046
2046
  for (const t in me)
2047
- me.hasOwnProperty(t) && ve(t);
2047
+ me.hasOwnProperty(t) && be(t);
2048
2048
  for (const t in Fe)
2049
2049
  Fe.hasOwnProperty(t) && Xi(t);
2050
2050
  for (const t in ue)
@@ -2052,7 +2052,7 @@ function Gi() {
2052
2052
  }
2053
2053
  function ne(t, e, n = 300) {
2054
2054
  if (t && e && e instanceof Function)
2055
- ve(t), me[t] = setTimeout(() => {
2055
+ be(t), me[t] = setTimeout(() => {
2056
2056
  e(), delete me[t];
2057
2057
  }, n);
2058
2058
  else
@@ -2060,7 +2060,7 @@ function ne(t, e, n = 300) {
2060
2060
  t ? "Cannot create named timeout without a name" : "Cannot create a timeout without a callback"
2061
2061
  );
2062
2062
  }
2063
- function ve(t) {
2063
+ function be(t) {
2064
2064
  me[t] && (clearTimeout(me[t]), delete me[t]);
2065
2065
  }
2066
2066
  function Xi(t) {
@@ -2082,13 +2082,13 @@ const to = {
2082
2082
  version: "2.0.0"
2083
2083
  };
2084
2084
  let g = {}, A, F;
2085
- const v = {};
2085
+ const b = {};
2086
2086
  let w = "", ye = "";
2087
2087
  const Ee = new le(""), wt = new le("");
2088
2088
  let an = "/api/engine/v2";
2089
2089
  const ce = new le(!1), no = ce.asObservable();
2090
2090
  let gt = 0;
2091
- function be() {
2091
+ function ve() {
2092
2092
  return `${`${g.secure || window.location?.protocol.indexOf("https") >= 0 ? "https:" : "http:"}//${g.host || window.location?.host}`}${pr()}`;
2093
2093
  }
2094
2094
  function pr() {
@@ -2107,7 +2107,7 @@ function gs(t, e = !0) {
2107
2107
  A.setItem(`${w}_x-api-key`, `${t}`), A.setItem("trusted", `${e}`), oo("x-api-key", Wi(/* @__PURE__ */ new Date(), 5).valueOf());
2108
2108
  }
2109
2109
  function Ot() {
2110
- return bt("x-api-key", !1) || "";
2110
+ return vt("x-api-key", !1) || "";
2111
2111
  }
2112
2112
  function oo(t, e = zi(/* @__PURE__ */ new Date(), 2).valueOf()) {
2113
2113
  g.ignore_api_key && t === "x-api-key" || (A.setItem(`${w}_expires_at`, `${e}`), A.setItem(`${w}_access_token`, t));
@@ -2117,7 +2117,7 @@ function Y(t = !0) {
2117
2117
  if (!A) return "";
2118
2118
  if (Ot() && !g.ignore_api_key) return "x-api-key";
2119
2119
  const e = A.getItem(`${w}_expires_at`) || "", n = Ee.getValue();
2120
- return Hi(+e, /* @__PURE__ */ new Date()) && (d("Auth", "Token expired. Requesting new token..."), hn(), v.load_authority || (gt += 1, ne(
2120
+ return Hi(+e, /* @__PURE__ */ new Date()) && (d("Auth", "Token expired. Requesting new token..."), hn(), b.load_authority || (gt += 1, ne(
2121
2121
  "re-authorise",
2122
2122
  () => yr().catch(
2123
2123
  (r) => d("Auth", `Failed to get token: ${r}`)
@@ -2137,10 +2137,10 @@ function so() {
2137
2137
  function uo() {
2138
2138
  return Ee.pipe(I((t) => !!so()));
2139
2139
  }
2140
- function vt() {
2140
+ function bt() {
2141
2141
  return F;
2142
2142
  }
2143
- function vs() {
2143
+ function bs() {
2144
2144
  return ce.getValue();
2145
2145
  }
2146
2146
  function ln() {
@@ -2149,16 +2149,16 @@ function ln() {
2149
2149
  function co() {
2150
2150
  return !!g.secure;
2151
2151
  }
2152
- function bs() {
2152
+ function vs() {
2153
2153
  return no;
2154
2154
  }
2155
2155
  function fn() {
2156
- return bt("trust") === "true" || bt("trusted") === "true";
2156
+ return vt("trust") === "true" || vt("trusted") === "true";
2157
2157
  }
2158
2158
  function _r() {
2159
- return !!Ot() && !g.ignore_api_key || bt("fixed_device") === "true";
2159
+ return !!Ot() && !g.ignore_api_key || vt("fixed_device") === "true";
2160
2160
  }
2161
- function bt(t, e = !0) {
2161
+ function vt(t, e = !0) {
2162
2162
  let r = dr()[t];
2163
2163
  if (A) {
2164
2164
  const i = `${io()}_${t}`;
@@ -2171,8 +2171,8 @@ function Ss(t) {
2171
2171
  }
2172
2172
  function ks() {
2173
2173
  g = {}, F = void 0, Ee.next(""), wt.next(""), ce.next(!1), w = "", ye = "", an = "/api/engine/v2";
2174
- for (const t in v)
2175
- t in v && delete v[t];
2174
+ for (const t in b)
2175
+ t in b && delete b[t];
2176
2176
  Gi();
2177
2177
  }
2178
2178
  function mr() {
@@ -2182,20 +2182,20 @@ function hn() {
2182
2182
  d("Auth", "Invalidating tokens."), A.removeItem(`${w}_access_token`), A.removeItem(`${w}_expires_at`), Ee.getValue() && Ee.next("");
2183
2183
  }
2184
2184
  function yr(t, e = F) {
2185
- return v.authorise || (v.authorise = new Promise((n, r) => {
2185
+ return b.authorise || (b.authorise = new Promise((n, r) => {
2186
2186
  if (!e)
2187
- return delete v.authorise, r("Authority is not loaded");
2187
+ return delete b.authorise, r("Authority is not loaded");
2188
2188
  d("Auth", "Authorising user...");
2189
2189
  const i = () => {
2190
2190
  if (Y(!1))
2191
- d("Auth", "Valid token found."), delete v.authorise, n(Y());
2191
+ d("Auth", "Valid token found."), delete b.authorise, n(Y());
2192
2192
  else {
2193
2193
  const o = [
2194
2194
  () => {
2195
- d("Auth", "Successfully generated token."), n(Y()), delete v.authorise;
2195
+ d("Auth", "Successfully generated token."), n(Y()), delete b.authorise;
2196
2196
  },
2197
2197
  () => {
2198
- d("Auth", "Failed to generate token."), r("Failed to generate token"), setTimeout(() => delete v.authorise, 200);
2198
+ d("Auth", "Failed to generate token."), r("Failed to generate token"), setTimeout(() => delete b.authorise, 200);
2199
2199
  }
2200
2200
  ];
2201
2201
  g && g.auth_type === "password" ? (d("Auth", "Logging in with credentials."), go(g).then(
@@ -2203,14 +2203,14 @@ function yr(t, e = F) {
2203
2203
  ), gt = 0) : ye || nn() ? (d(
2204
2204
  "Auth",
2205
2205
  `Generating token with ${ye ? "code" : "refresh token"}`
2206
- ), vr().then(...o), gt = 0) : e.session ? (d(
2206
+ ), br().then(...o), gt = 0) : e.session ? (d(
2207
2207
  "Auth",
2208
2208
  "Users has session. Authorising application..."
2209
- ), ao(t).then(...o)) : (d("Auth", "No user session"), gr(e), r("No user session"), setTimeout(() => delete v.authorise, 200));
2209
+ ), ao(t).then(...o)) : (d("Auth", "No user session"), gr(e), r("No user session"), setTimeout(() => delete b.authorise, 200));
2210
2210
  }
2211
2211
  };
2212
2212
  fo().then(i, i);
2213
- })), v.authorise;
2213
+ })), b.authorise;
2214
2214
  }
2215
2215
  function xs() {
2216
2216
  const t = F ? F.logout_url : "/logout";
@@ -2230,7 +2230,7 @@ function xs() {
2230
2230
  });
2231
2231
  }
2232
2232
  function dn(t = 0) {
2233
- return v.load_authority || (v.load_authority = new Promise((e) => {
2233
+ return b.load_authority || (b.load_authority = new Promise((e) => {
2234
2234
  if (ce.next(!1), g.mock) {
2235
2235
  F = to, d("Auth", "System in mock mode"), ce.next(!0), e();
2236
2236
  return;
@@ -2240,7 +2240,7 @@ function dn(t = 0) {
2240
2240
  d("Auth", `Failed to load authority(${i})`), ce.next(!1), ne(
2241
2241
  "load_authority",
2242
2242
  () => {
2243
- delete v.load_authority, dn(t).then((o) => e());
2243
+ delete b.load_authority, dn(t).then((o) => e());
2244
2244
  },
2245
2245
  300 * Math.min(20, ++t)
2246
2246
  );
@@ -2262,9 +2262,9 @@ function dn(t = 0) {
2262
2262
  const o = () => {
2263
2263
  ce.next(!0), d("Auth", "Application set online."), e();
2264
2264
  };
2265
- delete v.load_authority, yr("").then(o, o);
2265
+ delete b.load_authority, yr("").then(o, o);
2266
2266
  }, r);
2267
- })), v.load_authority;
2267
+ })), b.load_authority;
2268
2268
  }
2269
2269
  async function ao(t) {
2270
2270
  const e = po(t);
@@ -2273,19 +2273,19 @@ async function ao(t) {
2273
2273
  window.location?.assign(e);
2274
2274
  }
2275
2275
  function lo(t) {
2276
- return v.iframe_auth || (v.iframe_auth = new Promise((e, n) => {
2276
+ return b.iframe_auth || (b.iframe_auth = new Promise((e, n) => {
2277
2277
  d("Auth", "Authorizing in an iFrame...");
2278
2278
  const r = document.createElement("iframe");
2279
2279
  r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.height = "1px", r.style.width = "1px", r.style.zIndex = "-1", r.id = "place-authorize", r.src = `${t}`;
2280
2280
  const i = (o) => {
2281
2281
  if (o.origin === window.location?.origin && o.data.type === "place-os") {
2282
2282
  const s = o.data;
2283
- if (d("Auth", "Received credentials from iFrame..."), document.body.removeChild(r), ve("iframe_auth"), window.removeEventListener("message", i), delete v.iframe_auth, s.token)
2283
+ if (d("Auth", "Received credentials from iFrame..."), document.body.removeChild(r), be("iframe_auth"), window.removeEventListener("message", i), delete b.iframe_auth, s.token)
2284
2284
  return e(), pn({
2285
2285
  access_token: s.token,
2286
2286
  ...s
2287
2287
  });
2288
- ye = s.code || "", vr().then(
2288
+ ye = s.code || "", br().then(
2289
2289
  (u) => e(u),
2290
2290
  (u) => n(u)
2291
2291
  );
@@ -2298,9 +2298,9 @@ function lo(t) {
2298
2298
  },
2299
2299
  15 * 1e3
2300
2300
  ), window.addEventListener("message", i), r.onerror = (o) => {
2301
- d("Auth", "iFrame error.", o), delete v.iframe_auth, n();
2301
+ d("Auth", "iFrame error.", o), delete b.iframe_auth, n();
2302
2302
  }, document.body.appendChild(r);
2303
- })), v.iframe_auth;
2303
+ })), b.iframe_auth;
2304
2304
  }
2305
2305
  let Dn = !1;
2306
2306
  function gr(t) {
@@ -2313,15 +2313,15 @@ function gr(t) {
2313
2313
  throw setTimeout(() => window.location?.assign(e), 300), Dn = !0, new Error("Redirecting to login page...");
2314
2314
  } else
2315
2315
  d("Auth", "Login being handled locally.");
2316
- delete v.authorise;
2316
+ delete b.authorise;
2317
2317
  }
2318
2318
  function fo() {
2319
- return v.check_token || (v.check_token = new Promise(async (t, e) => {
2320
- Y() ? (d("Auth", "Valid token found."), t(Y())) : (d("Auth", "No token. Checking URL for auth credentials..."), await ho() ? t(!0) : e()), delete v.check_token;
2321
- })), v.check_token;
2319
+ return b.check_token || (b.check_token = new Promise(async (t, e) => {
2320
+ Y() ? (d("Auth", "Valid token found."), t(Y())) : (d("Auth", "No token. Checking URL for auth credentials..."), await ho() ? t(!0) : e()), delete b.check_token;
2321
+ })), b.check_token;
2322
2322
  }
2323
2323
  function ho() {
2324
- return v.check_params || (v.check_params = new Promise((t) => {
2324
+ return b.check_params || (b.check_params = new Promise((t) => {
2325
2325
  d("Auth", "Checking for auth parameters...");
2326
2326
  let e = dr();
2327
2327
  if ((!e || Object.keys(e).length <= 0) && sessionStorage && (e = JSON.parse(
@@ -2339,13 +2339,13 @@ function ho() {
2339
2339
  t(!1);
2340
2340
  ne(
2341
2341
  "check_params_promise",
2342
- () => delete v.check_params,
2342
+ () => delete b.check_params,
2343
2343
  50
2344
2344
  );
2345
- })), v.check_params;
2345
+ })), b.check_params;
2346
2346
  }
2347
2347
  function po(t) {
2348
- const e = vo();
2348
+ const e = bo();
2349
2349
  t = t ? `${e};${t}` : e;
2350
2350
  const n = g ? (g.auth_uri || "").indexOf("?") >= 0 : !1, r = (g ? g.auth_uri : null) || "/auth/oauth/authorize", i = fn() || g.auth_type === "auth_code" ? "code" : "token";
2351
2351
  let o = `${r}${n ? "&" : "?"}response_type=${encodeURIComponent(i)}&client_id=${encodeURIComponent(w)}&state=${encodeURIComponent(t)}&redirect_uri=${encodeURIComponent(g.redirect_uri)}&scope=${encodeURIComponent(g.scope)}`;
@@ -2388,17 +2388,17 @@ function yo(t) {
2388
2388
  });
2389
2389
  return `${e}?${n}`;
2390
2390
  }
2391
- function vr() {
2392
- return br(...mo());
2391
+ function br() {
2392
+ return vr(...mo());
2393
2393
  }
2394
2394
  function go(t) {
2395
- return br(yo(t));
2395
+ return vr(yo(t));
2396
2396
  }
2397
- function br(t, e = "") {
2398
- return v.generate_tokens || (v.generate_tokens = new Promise((n, r) => {
2397
+ function vr(t, e = "") {
2398
+ return b.generate_tokens || (b.generate_tokens = new Promise((n, r) => {
2399
2399
  d("Auth", "Generating new token...");
2400
2400
  const i = (o) => {
2401
- d("Auth", "Error generating new tokens.", o), A.removeItem(`${w}_refresh_token`), wt.next(""), r(), delete v.generate_tokens;
2401
+ d("Auth", "Error generating new tokens.", o), A.removeItem(`${w}_refresh_token`), wt.next(""), r(), delete b.generate_tokens;
2402
2402
  };
2403
2403
  cn(t, {
2404
2404
  method: "POST",
@@ -2409,9 +2409,9 @@ function br(t, e = "") {
2409
2409
  }).subscribe(async (o) => {
2410
2410
  if (!o.ok) return i(o);
2411
2411
  const s = await o.json();
2412
- pn(s), n(), delete v.generate_tokens;
2412
+ pn(s), n(), delete b.generate_tokens;
2413
2413
  }, i);
2414
- })), v.generate_tokens;
2414
+ })), b.generate_tokens;
2415
2415
  }
2416
2416
  function pn(t) {
2417
2417
  const e = Li(
@@ -2426,13 +2426,13 @@ function pn(t) {
2426
2426
  t.refresh_token
2427
2427
  ), de("refresh_token"))), t.expires_in && (A.setItem(`${w}_expires_at`, `${e.valueOf()}`), de("expires_in")), ce.next(!0), Ee.next(t.access_token || ""), wt.next(t.refresh_token || "");
2428
2428
  }
2429
- function vo() {
2429
+ function bo() {
2430
2430
  const t = Bi();
2431
2431
  return A.setItem(`${w}_nonce`, t), t;
2432
2432
  }
2433
2433
  const Et = {};
2434
2434
  function $s(t, e = Et) {
2435
- bo(t.method, t.path, e);
2435
+ vo(t.method, t.path, e);
2436
2436
  const n = `${t.method}|${t.path}`, r = t.path.replace(/(http|https):\/\/[a-zA-Z0-9.]*:?([0-9]*)?/g, "").replace(/^\//, "").split("/"), i = {
2437
2437
  ...t,
2438
2438
  path_parts: r,
@@ -2442,7 +2442,7 @@ function $s(t, e = Et) {
2442
2442
  };
2443
2443
  e[n] = i, d("HTTP(M)", `+ ${t.method} ${t.path}`);
2444
2444
  }
2445
- function bo(t, e, n = Et) {
2445
+ function vo(t, e, n = Et) {
2446
2446
  const r = `${t}|${e}`;
2447
2447
  n[r] && (delete n[r], d("HTTP(M)", `- ${t} ${e}`));
2448
2448
  }
@@ -2547,7 +2547,7 @@ function Be(t, e, n, r = ln, i = So, o = wo) {
2547
2547
  En((s) => s.ok ? o(s, n.response_type) : On(s)),
2548
2548
  Mi(
2549
2549
  (s) => s.pipe(
2550
- un((u, c) => u.status === 511 ? (gr(vt()), wn(u)) : c + 1 > 4 || u.status !== 401 ? On(u || {}) : (d("HTTP", "Auth error", u), kr(), wn(u)))
2550
+ un((u, c) => u.status === 511 ? (gr(bt()), wn(u)) : c + 1 > 4 || u.status !== 401 ? On(u || {}) : (d("HTTP", "Auth error", u), kr(), wn(u)))
2551
2551
  )
2552
2552
  )
2553
2553
  );
@@ -2602,7 +2602,7 @@ function ws(t) {
2602
2602
  let xr = {}, $r = {}, Cn = "";
2603
2603
  const Pt = (t) => t;
2604
2604
  function E(t) {
2605
- const { query_params: e, fn: n, path: r, endpoint: i } = t, o = z(e), s = `${i || be()}${r ? "/" + r : ""}${o ? "?" + o : ""}`;
2605
+ const { query_params: e, fn: n, path: r, endpoint: i } = t, o = z(e), s = `${i || ve()}${r ? "/" + r : ""}${o ? "?" + o : ""}`;
2606
2606
  return ee(s).pipe(
2607
2607
  I((u) => {
2608
2608
  const c = Eo(s, o, r);
@@ -2620,37 +2620,37 @@ function E(t) {
2620
2620
  );
2621
2621
  }
2622
2622
  function $(t) {
2623
- const { query_params: e, id: n, path: r, fn: i, options: o } = t, s = z(e), u = `${be()}/${r}/${n}${s ? "?" + s : ""}`;
2623
+ const { query_params: e, id: n, path: r, fn: i, options: o } = t, s = z(e), u = `${ve()}/${r}/${n}${s ? "?" + s : ""}`;
2624
2624
  return ee(u, o).pipe(I((c) => (i || Pt)(c)));
2625
2625
  }
2626
2626
  function C(t) {
2627
- const { query_params: e, form_data: n, path: r, fn: i } = t, o = z(e), s = `${be()}/${r}${o ? "?" + o : ""}`;
2627
+ const { query_params: e, form_data: n, path: r, fn: i } = t, o = z(e), s = `${ve()}/${r}${o ? "?" + o : ""}`;
2628
2628
  return Ie(s, n).pipe(
2629
2629
  I((c) => (i || Pt)(c))
2630
2630
  );
2631
2631
  }
2632
2632
  function m(t) {
2633
- const { id: e, task_name: n, form_data: r, method: i, path: o, callback: s } = t, u = z(r), c = `${be()}/${o}/${e}/${n}`;
2633
+ const { id: e, task_name: n, form_data: r, method: i, path: o, callback: s } = t, u = z(r), c = `${ve()}/${o}/${e}/${n}`;
2634
2634
  return (i === "post" || i === "put" || !i ? (i === "put" ? We : Ie)(c, r) : (i === "del" ? He : ee)(
2635
2635
  `${c}${u ? "?" + u : ""}`,
2636
2636
  {
2637
2637
  response_type: "json"
2638
2638
  }
2639
2639
  )).pipe(
2640
- I((_) => (s || ((b) => b))(_))
2640
+ I((_) => (s || ((v) => v))(_))
2641
2641
  );
2642
2642
  }
2643
2643
  function N(t) {
2644
2644
  const { id: e, query_params: n, form_data: r, method: i, path: o, fn: s } = t, u = z({
2645
2645
  ...n,
2646
2646
  version: r.version || 0
2647
- }), c = `${be()}/${o}/${e}${u ? "?" + u : ""}`;
2647
+ }), c = `${ve()}/${o}/${e}${u ? "?" + u : ""}`;
2648
2648
  return (i === "put" ? We : It)(c, r).pipe(
2649
2649
  I((l) => (s || Pt)(l))
2650
2650
  );
2651
2651
  }
2652
2652
  function T(t) {
2653
- const { id: e, query_params: n, path: r } = t, i = z(n), o = `${be()}/${r}/${e}${i ? "?" + i : ""}`;
2653
+ const { id: e, query_params: n, path: r } = t, i = z(n), o = `${ve()}/${r}/${e}${i ? "?" + i : ""}`;
2654
2654
  return He(o);
2655
2655
  }
2656
2656
  function Eo(t, e, n) {
@@ -3450,7 +3450,7 @@ function yu(t = {}) {
3450
3450
  function gu(t, e = {}) {
3451
3451
  return $({ id: t, query_params: e, fn: Ct, path: K });
3452
3452
  }
3453
- function vu(t, e, n = "patch") {
3453
+ function bu(t, e, n = "patch") {
3454
3454
  return N({
3455
3455
  id: t,
3456
3456
  form_data: e,
@@ -3460,7 +3460,7 @@ function vu(t, e, n = "patch") {
3460
3460
  path: K
3461
3461
  });
3462
3462
  }
3463
- function bu(t) {
3463
+ function vu(t) {
3464
3464
  return C({ form_data: t, query_params: {}, fn: Ct, path: K });
3465
3465
  }
3466
3466
  function Su(t, e = {}) {
@@ -3575,12 +3575,14 @@ class Fo extends B {
3575
3575
  username;
3576
3576
  /** Password to connect to repository with */
3577
3577
  password;
3578
+ /** Root path of the repository to serve at the `folder_name` path */
3579
+ root_path;
3578
3580
  /** Repository type */
3579
3581
  get type() {
3580
3582
  return this.repo_type;
3581
3583
  }
3582
3584
  constructor(e = {}) {
3583
- super(e), this.folder_name = e.folder_name || "", this.description = e.description || "", this.uri = e.uri || "", this.branch = e.branch || "", this.commit_hash = e.commit_hash || "", this.repo_type = e.repo_type || Ir.Driver, this.username = e.username || "", this.password = e.password || "";
3585
+ super(e), this.folder_name = e.folder_name || "", this.description = e.description || "", this.uri = e.uri || "", this.branch = e.branch || "", this.commit_hash = e.commit_hash || "", this.repo_type = e.repo_type || Ir.Driver, this.username = e.username || "", this.password = e.password || "", this.root_path = e.root_path || "";
3584
3586
  }
3585
3587
  }
3586
3588
  const V = "repositories";
@@ -3877,7 +3879,7 @@ function gc(t, e, n = 1, r) {
3877
3879
  path: M
3878
3880
  });
3879
3881
  }
3880
- function vc(t, e, n = 1) {
3882
+ function bc(t, e, n = 1) {
3881
3883
  return m({
3882
3884
  id: t,
3883
3885
  task_name: `functions/${e}_${n}`,
@@ -3885,7 +3887,7 @@ function vc(t, e, n = 1) {
3885
3887
  path: M
3886
3888
  });
3887
3889
  }
3888
- function bc(t) {
3890
+ function vc(t) {
3889
3891
  return E({
3890
3892
  query_params: {},
3891
3893
  fn: (e) => new mn(e),
@@ -4401,13 +4403,13 @@ class Qt {
4401
4403
  }
4402
4404
  }
4403
4405
  const it = "/api/staff/v1/surveys";
4404
- function va(t = {}) {
4406
+ function ba(t = {}) {
4405
4407
  const e = z(t);
4406
4408
  return ee(`${it}${e ? "?" + e : ""}`).pipe(
4407
4409
  I((n) => n.map((r) => new Qt(r)))
4408
4410
  );
4409
4411
  }
4410
- function ba(t, e = {}) {
4412
+ function va(t, e = {}) {
4411
4413
  const n = z(e);
4412
4414
  return ee(`${it}/${t}${n ? "?" + n : ""}`).pipe(
4413
4415
  I((r) => new Qt(r))
@@ -4495,21 +4497,21 @@ var Yo = {
4495
4497
  var n = this, r = this._config, i = r.WebSocketCtor, o = r.protocol, s = r.url, u = r.binaryType, c = this._output, l = null;
4496
4498
  try {
4497
4499
  l = o ? new i(s, o) : new i(s), this._socket = l, u && (this._socket.binaryType = u);
4498
- } catch (b) {
4499
- c.error(b);
4500
+ } catch (v) {
4501
+ c.error(v);
4500
4502
  return;
4501
4503
  }
4502
4504
  var _ = new ge(function() {
4503
4505
  n._socket = null, l && l.readyState === 1 && l.close();
4504
4506
  });
4505
- l.onopen = function(b) {
4507
+ l.onopen = function(v) {
4506
4508
  var p = n._socket;
4507
4509
  if (!p) {
4508
4510
  l.close(), n._resetState();
4509
4511
  return;
4510
4512
  }
4511
4513
  var a = n._config.openObserver;
4512
- a && a.next(b);
4514
+ a && a.next(v);
4513
4515
  var h = n.destination;
4514
4516
  n.destination = At.create(function(f) {
4515
4517
  if (l.readyState === 1)
@@ -4526,16 +4528,16 @@ var Yo = {
4526
4528
  var f = n._config.closingObserver;
4527
4529
  f && f.next(void 0), l.close(), n._resetState();
4528
4530
  }), h && h instanceof Jt && _.add(h.subscribe(n.destination));
4529
- }, l.onerror = function(b) {
4530
- n._resetState(), c.error(b);
4531
- }, l.onclose = function(b) {
4531
+ }, l.onerror = function(v) {
4532
+ n._resetState(), c.error(v);
4533
+ }, l.onclose = function(v) {
4532
4534
  l === n._socket && n._resetState();
4533
4535
  var p = n._config.closeObserver;
4534
- p && p.next(b), b.wasClean ? c.complete() : c.error(b);
4535
- }, l.onmessage = function(b) {
4536
+ p && p.next(v), v.wasClean ? c.complete() : c.error(v);
4537
+ }, l.onmessage = function(v) {
4536
4538
  try {
4537
4539
  var p = n._config.deserializer;
4538
- c.next(p(b));
4540
+ c.next(p(v));
4539
4541
  } catch (a) {
4540
4542
  c.error(a);
4541
4543
  }
@@ -4634,11 +4636,11 @@ const L = {}, gn = {}, $e = {}, ts = {}, pe = new le(!1);
4634
4636
  $e._place_os_status = pe.asObservable();
4635
4637
  const Cr = new le([0, 0]);
4636
4638
  $e._place_os_sync = Cr.asObservable();
4637
- let Nr = Date.now(), we, xt = 0, se = null, ht, vn = 0;
4639
+ let Nr = Date.now(), we, xt = 0, se = null, ht, bn = 0;
4638
4640
  const st = 10 * 1e3, jr = new ae();
4639
4641
  $e._place_os_debug_events = jr.asObservable();
4640
4642
  function Kt() {
4641
- return be().indexOf("/control/") >= 0 ? "/control/websocket" : `${pr()}/systems/control`;
4643
+ return ve().indexOf("/control/") >= 0 ? "/control/websocket" : `${pr()}/systems/control`;
4642
4644
  }
4643
4645
  function Fr() {
4644
4646
  return pe.getValue();
@@ -4725,7 +4727,7 @@ function qe(t, e = st, n = 0) {
4725
4727
  },
4726
4728
  e
4727
4729
  );
4728
- } else se ? setTimeout(() => u(), 1e3) : bn().then(() => u());
4730
+ } else se ? setTimeout(() => u(), 1e3) : vn().then(() => u());
4729
4731
  }), L[r] = i;
4730
4732
  }
4731
4733
  return L[r].promise;
@@ -4752,8 +4754,8 @@ function zr(t) {
4752
4754
  time: Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3)
4753
4755
  });
4754
4756
  } else t.type === "error" ? cs(t) : t.cmd || d("WS", "Invalid websocket message", t, "error");
4755
- ve(`${t.id}`);
4756
- } else t === "pong" && (vn = Date.now(), d("WS", "Pong!"));
4757
+ be(`${t.id}`);
4758
+ } else t === "pong" && (bn = Date.now(), d("WS", "Pong!"));
4757
4759
  }
4758
4760
  function us(t) {
4759
4761
  const e = Object.keys(L).map((n) => L[n]).find((n) => n?.id === t.id);
@@ -4791,7 +4793,7 @@ function cs(t) {
4791
4793
  "error"
4792
4794
  );
4793
4795
  const n = Object.keys(L).map((r) => L[r]).filter((r) => r).find((r) => r.id === t.id);
4794
- n && n.reject && (n.reject(t), ve(`${n.key}`), delete L[n.key]);
4796
+ n && n.reject && (n.reject(t), be(`${n.key}`), delete L[n.key]);
4795
4797
  }
4796
4798
  function as(t, e, n = gn, r = $e) {
4797
4799
  const i = `${t.sys}|${t.mod}_${t.index}|${t.name}`;
@@ -4803,11 +4805,11 @@ function as(t, e, n = gn, r = $e) {
4803
4805
  e
4804
4806
  ]), n[i].next(e);
4805
4807
  }
4806
- function bn(t = 0) {
4808
+ function vn(t = 0) {
4807
4809
  return se == null && (se = new Promise((e) => {
4808
4810
  if (t > 40)
4809
4811
  return location.reload();
4810
- xt++, Nr = Date.now(), Q = ln() ? hs() : ls(), Q ? (d("WS(Debug)", "Authority:", [vt()]), d("WS", "Connecting to websocket..."), Q.subscribe(
4812
+ xt++, Nr = Date.now(), Q = ln() ? hs() : ls(), Q ? (d("WS(Debug)", "Authority:", [bt()]), d("WS", "Connecting to websocket..."), Q.subscribe(
4811
4813
  (n) => {
4812
4814
  pe.getValue() || (d("WS", "Connection established."), e()), pe.next(!0), xt = 0, Zt(), zr(n);
4813
4815
  },
@@ -4817,7 +4819,7 @@ function bn(t = 0) {
4817
4819
  () => {
4818
4820
  Q = void 0, se = null, Fn(), d("WS", "Connection closed by browser."), pe.next(!1), $t();
4819
4821
  }
4820
- ), we && clearInterval(we), vn = Date.now(), jn(), we = setInterval(
4822
+ ), we && clearInterval(we), bn = Date.now(), jn(), we = setInterval(
4821
4823
  () => jn(),
4822
4824
  Dr * 1e3
4823
4825
  ), Zt(), qr += 1, ht = setTimeout(() => {
@@ -4825,7 +4827,7 @@ function bn(t = 0) {
4825
4827
  }, 30 * 1e3)) : (Q ? d(
4826
4828
  "WS",
4827
4829
  `Waiting on auth(${t}). Retrying in ${1e3 * Math.min(10, t + 1)}ms...`,
4828
- [!!Y(), !!vt()],
4830
+ [!!Y(), !!bt()],
4829
4831
  "info"
4830
4832
  ) : d(
4831
4833
  "WS",
@@ -4834,14 +4836,14 @@ function bn(t = 0) {
4834
4836
  "error"
4835
4837
  ), setTimeout(
4836
4838
  () => {
4837
- se = null, bn(t).then((n) => e(n));
4839
+ se = null, vn(t).then((n) => e(n));
4838
4840
  },
4839
4841
  1e3 * Math.min(10, ++t)
4840
4842
  ));
4841
4843
  })), se;
4842
4844
  }
4843
4845
  function ls() {
4844
- if (!vt() || !Y()) return null;
4846
+ if (!bt() || !Y()) return null;
4845
4847
  const t = co() || location.protocol.indexOf("https") >= 0;
4846
4848
  let e = `ws${t ? "s" : ""}://${rn()}${Kt()}${_r() ? "?fixed_device=true" : ""}`;
4847
4849
  const n = Y();
@@ -4872,12 +4874,12 @@ function $t() {
4872
4874
  )}ms...`
4873
4875
  ), ne(
4874
4876
  "reconnect",
4875
- () => bn(),
4877
+ () => vn(),
4876
4878
  Math.min(5e3, (xt + 1) * 300 || 1e3)
4877
4879
  );
4878
4880
  }
4879
4881
  function jn() {
4880
- if (Date.now() - vn > 4 * Dr * 1e3)
4882
+ if (Date.now() - bn > 4 * Dr * 1e3)
4881
4883
  return $t();
4882
4884
  Q?.next("ping");
4883
4885
  }
@@ -4913,7 +4915,7 @@ function ds(t, e, n) {
4913
4915
  });
4914
4916
  break;
4915
4917
  case "unbind":
4916
- n[r] && (n[r].unsubscribe(), delete n[r], ve(`${r}`));
4918
+ n[r] && (n[r].unsubscribe(), delete n[r], be(`${r}`));
4917
4919
  break;
4918
4920
  }
4919
4921
  ne(
@@ -4946,7 +4948,7 @@ function Fn() {
4946
4948
  class zn {
4947
4949
  constructor(e, n) {
4948
4950
  this._module = e, this.name = n, ns().pipe(Pi()).subscribe((r) => {
4949
- r && (this._stale_bindings || this._pending === 1) ? (d("VAR", "Re-binding to status variable", this.binding()), this.rebind()) : r || (ve(
4951
+ r && (this._stale_bindings || this._pending === 1) ? (d("VAR", "Re-binding to status variable", this.binding()), this.rebind()) : r || (be(
4950
4952
  `rebind:${JSON.stringify(this.binding())}`
4951
4953
  ), d(
4952
4954
  "VAR",
@@ -4985,6 +4987,14 @@ class zn {
4985
4987
  subscribe(e) {
4986
4988
  return this.listen().subscribe(e);
4987
4989
  }
4990
+ bindThenSubscribe(e) {
4991
+ const n = this.bind();
4992
+ return this.listen().subscribe({
4993
+ next: e,
4994
+ complete: () => n(),
4995
+ error: () => n()
4996
+ });
4997
+ }
4988
4998
  /**
4989
4999
  * Bind to the status variable's value
4990
5000
  */
@@ -5169,7 +5179,7 @@ export {
5169
5179
  ha as addInvitation,
5170
5180
  cu as addLDAPSource,
5171
5181
  pu as addMetadata,
5172
- bu as addModule,
5182
+ vu as addModule,
5173
5183
  Mu as addOAuthSource,
5174
5184
  ma as addQuestion,
5175
5185
  Cu as addRepository,
@@ -5184,11 +5194,11 @@ export {
5184
5194
  Ec as addTrigger,
5185
5195
  Dc as addUser,
5186
5196
  zc as addZone,
5187
- be as apiEndpoint,
5197
+ ve as apiEndpoint,
5188
5198
  Ot as apiKey,
5189
5199
  oa as approveSignagePlaylist,
5190
5200
  yr as authorise,
5191
- vt as authority,
5201
+ bt as authority,
5192
5202
  Nn as bind,
5193
5203
  Qi as cleanObject,
5194
5204
  ks as cleanupAuth,
@@ -5201,12 +5211,12 @@ export {
5201
5211
  Oa as debug,
5202
5212
  jr as debug_events,
5203
5213
  He as del,
5204
- bo as deregisterMockEndpoint,
5214
+ vo as deregisterMockEndpoint,
5205
5215
  Aa as deregisterSystem,
5206
5216
  ss as execute,
5207
5217
  mc as executeOnSystem,
5208
5218
  Hc as executeOnZone,
5209
- vc as functionList,
5219
+ bc as functionList,
5210
5220
  Bi as generateNonce,
5211
5221
  ee as get,
5212
5222
  dr as getFragments,
@@ -5223,7 +5233,7 @@ export {
5223
5233
  Yi as isMobileSafari,
5224
5234
  ln as isMock,
5225
5235
  Ji as isNestedFrame,
5226
- vs as isOnline,
5236
+ bs as isOnline,
5227
5237
  co as isSecure,
5228
5238
  fn as isTrusted,
5229
5239
  Fr as is_connected,
@@ -5243,7 +5253,7 @@ export {
5243
5253
  ra as listSignagePlaylistMedia,
5244
5254
  ia as listSignagePlaylistMediaRevisions,
5245
5255
  Sc as listSystemTriggers,
5246
- bc as listSystemZones,
5256
+ vc as listSystemZones,
5247
5257
  Pc as listTriggerInstances,
5248
5258
  Nc as listZoneTags,
5249
5259
  Wc as listZoneTriggers,
@@ -5258,7 +5268,7 @@ export {
5258
5268
  Eu as moduleRuntimeError,
5259
5269
  Ou as moduleSettings,
5260
5270
  $u as moduleState,
5261
- bs as onlineState,
5271
+ vs as onlineState,
5262
5272
  Vi as parseLinkHeader,
5263
5273
  It as patch,
5264
5274
  Ie as post,
@@ -5283,7 +5293,7 @@ export {
5283
5293
  ec as querySettings,
5284
5294
  Qc as querySignageMedia,
5285
5295
  Gc as querySignagePlaylists,
5286
- va as querySurveys,
5296
+ ba as querySurveys,
5287
5297
  sc as querySystems,
5288
5298
  uc as querySystemsWithEmails,
5289
5299
  Ac as queryTriggers,
@@ -5347,7 +5357,7 @@ export {
5347
5357
  Yc as showSignageMedia,
5348
5358
  Vc as showSignageMetrics,
5349
5359
  Xc as showSignagePlaylist,
5350
- ba as showSurvey,
5360
+ va as showSurvey,
5351
5361
  cc as showSystem,
5352
5362
  wc as showTrigger,
5353
5363
  Mc as showUser,
@@ -5372,7 +5382,7 @@ export {
5372
5382
  fa as updateInvitation,
5373
5383
  uu as updateLDAPSource,
5374
5384
  du as updateMetadata,
5375
- vu as updateModule,
5385
+ bu as updateModule,
5376
5386
  Tu as updateOAuthSource,
5377
5387
  ya as updateQuestion,
5378
5388
  qu as updateRepository,