@luminix/support 0.4.1 → 0.4.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/support.js CHANGED
@@ -4191,81 +4191,6 @@ function Zp(e, t, r) {
4191
4191
  function Xp(e, t) {
4192
4192
  return e == null ? !0 : Oi(e, t);
4193
4193
  }
4194
- function Re(e) {
4195
- return class extends e {
4196
- constructor(...r) {
4197
- super(...r);
4198
- j(this, "_macros", {});
4199
- return new Proxy(this, {
4200
- get(n, s, i) {
4201
- return Reflect.has(n, s) ? Reflect.get(n, s, i) : typeof s == "string" && n.hasMacro(s) ? n._macros[s].bind(n) : Reflect.get(n, s, i);
4202
- }
4203
- });
4204
- }
4205
- macro(r, n) {
4206
- if (typeof n != "function")
4207
- throw new TypeError("Macro must be a function");
4208
- this._macros[r] = n;
4209
- }
4210
- hasMacro(r) {
4211
- return r in this._macros && typeof this._macros[r] == "function";
4212
- }
4213
- flushMacros() {
4214
- this._macros = {};
4215
- }
4216
- };
4217
- }
4218
- class Qp {
4219
- fromQuery(t) {
4220
- const r = {};
4221
- for (const [n, s] of t.entries())
4222
- this.set(r, n, s);
4223
- return r;
4224
- }
4225
- fromFormData(t) {
4226
- return this.fromQuery(t);
4227
- }
4228
- get(t, r, n) {
4229
- return cc(t, r, n);
4230
- }
4231
- has(t, r) {
4232
- return Xd(t, r);
4233
- }
4234
- isEmpty(t) {
4235
- return sp(t);
4236
- }
4237
- isEqual(t, r) {
4238
- return ip(t, r);
4239
- }
4240
- merge(t, ...r) {
4241
- let n;
4242
- try {
4243
- n = structuredClone(t);
4244
- } catch {
4245
- n = sd(t);
4246
- }
4247
- return Ri(n, ...r), n;
4248
- }
4249
- omit(t, ...r) {
4250
- return hp(t, ...r);
4251
- }
4252
- pick(t, ...r) {
4253
- return jp(t, ...r);
4254
- }
4255
- set(t, r, n) {
4256
- Bp(t, r, n);
4257
- }
4258
- toQuery(t) {
4259
- return Qr(t, new URLSearchParams());
4260
- }
4261
- toFormData(t) {
4262
- return Qr(t, new FormData());
4263
- }
4264
- unset(t, r) {
4265
- Xp(t, r);
4266
- }
4267
- }
4268
- const O = new (Re(Qp))();
4269
4194
  class Sm extends yr {
4270
4195
  constructor(r = []) {
4271
4196
  super();
@@ -4286,7 +4211,7 @@ class Sm extends yr {
4286
4211
  loadConfiguration() {
4287
4212
  if (document.getElementById("luminix-data::config")) {
4288
4213
  const r = Lu("config");
4289
- r && typeof r == "object" && (this._configuration = O.merge({}, r));
4214
+ r && typeof r == "object" && this.withConfiguration(r);
4290
4215
  }
4291
4216
  }
4292
4217
  bind(r, n) {
@@ -4316,7 +4241,7 @@ class Sm extends yr {
4316
4241
  }
4317
4242
  create() {
4318
4243
  if (this.services.length > 0) {
4319
- this.make("log").warning(
4244
+ console.warn(
4320
4245
  "[Luminix] Application already created. Skipping double invocation of `create()`. If you want to re-create the application, please flush it first."
4321
4246
  );
4322
4247
  return;
@@ -4351,6 +4276,81 @@ class Sm extends yr {
4351
4276
  }
4352
4277
  }
4353
4278
  }
4279
+ function Re(e) {
4280
+ return class extends e {
4281
+ constructor(...r) {
4282
+ super(...r);
4283
+ j(this, "_macros", {});
4284
+ return new Proxy(this, {
4285
+ get(n, s, i) {
4286
+ return Reflect.has(n, s) ? Reflect.get(n, s, i) : typeof s == "string" && n.hasMacro(s) ? n._macros[s].bind(n) : Reflect.get(n, s, i);
4287
+ }
4288
+ });
4289
+ }
4290
+ macro(r, n) {
4291
+ if (typeof n != "function")
4292
+ throw new TypeError("Macro must be a function");
4293
+ this._macros[r] = n;
4294
+ }
4295
+ hasMacro(r) {
4296
+ return r in this._macros && typeof this._macros[r] == "function";
4297
+ }
4298
+ flushMacros() {
4299
+ this._macros = {};
4300
+ }
4301
+ };
4302
+ }
4303
+ class Qp {
4304
+ fromQuery(t) {
4305
+ const r = {};
4306
+ for (const [n, s] of t.entries())
4307
+ this.set(r, n, s);
4308
+ return r;
4309
+ }
4310
+ fromFormData(t) {
4311
+ return this.fromQuery(t);
4312
+ }
4313
+ get(t, r, n) {
4314
+ return cc(t, r, n);
4315
+ }
4316
+ has(t, r) {
4317
+ return Xd(t, r);
4318
+ }
4319
+ isEmpty(t) {
4320
+ return sp(t);
4321
+ }
4322
+ isEqual(t, r) {
4323
+ return ip(t, r);
4324
+ }
4325
+ merge(t, ...r) {
4326
+ let n;
4327
+ try {
4328
+ n = structuredClone(t);
4329
+ } catch {
4330
+ n = sd(t);
4331
+ }
4332
+ return Ri(n, ...r), n;
4333
+ }
4334
+ omit(t, ...r) {
4335
+ return hp(t, ...r);
4336
+ }
4337
+ pick(t, ...r) {
4338
+ return jp(t, ...r);
4339
+ }
4340
+ set(t, r, n) {
4341
+ Bp(t, r, n);
4342
+ }
4343
+ toQuery(t) {
4344
+ return Qr(t, new URLSearchParams());
4345
+ }
4346
+ toFormData(t) {
4347
+ return Qr(t, new FormData());
4348
+ }
4349
+ unset(t, r) {
4350
+ Xp(t, r);
4351
+ }
4352
+ }
4353
+ const O = new (Re(Qp))();
4354
4354
  let lr = class {
4355
4355
  constructor(t, r) {
4356
4356
  this._response = t, this._error = r;
@@ -4517,10 +4517,19 @@ class xm {
4517
4517
  return this.options = t, this;
4518
4518
  }
4519
4519
  withQueryParameters(t) {
4520
- return O.set(this.options, "params", O.merge(this.options.params, t)), this;
4520
+ const r = typeof t == "string" ? O.fromQuery(new URLSearchParams(t)) : t instanceof URLSearchParams ? O.fromQuery(t) : t;
4521
+ return O.set(
4522
+ this.options,
4523
+ "params",
4524
+ O.merge(this.options.params || {}, r)
4525
+ ), this;
4521
4526
  }
4522
4527
  replaceQueryParameters(t) {
4523
- return O.set(this.options, "params", t), this;
4528
+ return O.set(
4529
+ this.options,
4530
+ "params",
4531
+ typeof t == "string" ? O.fromQuery(new URLSearchParams(t)) : t instanceof URLSearchParams ? O.fromQuery(t) : t
4532
+ ), this;
4524
4533
  }
4525
4534
  withData(t) {
4526
4535
  const r = O.get(this.options, "data", {}), n = r instanceof FormData ? O.fromFormData(r) : r;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luminix/support",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "module": "dist/support.js",
5
5
  "types": "types/index.d.ts",
6
6
  "type": "module",
@@ -13,8 +13,8 @@ export default class Client {
13
13
  replaceHeaders(headers: Record<string, string>): this;
14
14
  withOptions(options: RequestOptions): this;
15
15
  replaceOptions(options: RequestOptions): this;
16
- withQueryParameters(params: string | object): this;
17
- replaceQueryParameters(params: string | object): this;
16
+ withQueryParameters(params: URLSearchParams | string | object): this;
17
+ replaceQueryParameters(params: URLSearchParams | string | object): this;
18
18
  withData(data: object): this;
19
19
  replaceData(data: object): this;
20
20
  withBasicAuth(username: string, password: string): this;