@bbn/bbn 2.0.237 → 2.0.239

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 (86) hide show
  1. package/dist/$.js +1 -1
  2. package/dist/bbn.js +3 -3
  3. package/dist/bbn.js.map +1 -1
  4. package/dist/bbn.sw.js +3 -3
  5. package/dist/bbn.sw.js.map +1 -1
  6. package/dist/com.js +13 -21
  7. package/dist/{vars.d.ts → data.d.ts} +1 -0
  8. package/dist/{vars.js → data.js} +1 -0
  9. package/dist/db/classes/Center.d.ts +10 -0
  10. package/dist/db/classes/Center.js +88 -0
  11. package/dist/db/classes/Object.d.ts +3 -0
  12. package/dist/db/classes/Object.js +469 -0
  13. package/dist/db/classes/ObjectProxy.d.ts +18 -0
  14. package/dist/db/classes/ObjectProxy.js +79 -0
  15. package/dist/db/classes/Proxy.d.ts +10 -0
  16. package/dist/db/classes/Proxy.js +52 -0
  17. package/dist/db/functions/fieldsFromFilter.d.ts +1 -0
  18. package/dist/db/functions/fieldsFromFilter.js +33 -0
  19. package/dist/db/functions/getPrimaryKey.d.ts +2 -0
  20. package/dist/db/functions/getPrimaryKey.js +8 -0
  21. package/dist/db/functions/requestToPromise.d.ts +1 -0
  22. package/dist/db/functions/requestToPromise.js +6 -0
  23. package/dist/db/functions/transactionDone.d.ts +1 -0
  24. package/dist/db/functions/transactionDone.js +7 -0
  25. package/dist/db/functions/transformResult.d.ts +1 -0
  26. package/dist/db/functions/transformResult.js +16 -0
  27. package/dist/db/types.d.ts +56 -0
  28. package/dist/db/types.js +1 -0
  29. package/dist/db.d.ts +3 -66
  30. package/dist/db.js +3 -558
  31. package/dist/dt/classes/{date.d.ts → Date.d.ts} +1 -1
  32. package/dist/dt/classes/{date.js → Date.js} +8 -3
  33. package/dist/dt/classes/{dateTime.d.ts → DateTime.d.ts} +1 -1
  34. package/dist/dt/classes/{dateTime.js → DateTime.js} +9 -3
  35. package/dist/dt/classes/{dt.d.ts → Dt.d.ts} +1 -1
  36. package/dist/dt/classes/{dt.js → Dt.js} +36 -48
  37. package/dist/dt/classes/Duration.js +193 -0
  38. package/dist/dt/classes/{monthDay.d.ts → MonthDay.d.ts} +1 -1
  39. package/dist/dt/classes/{monthDay.js → MonthDay.js} +2 -2
  40. package/dist/dt/classes/{time.d.ts → Time.d.ts} +1 -1
  41. package/dist/dt/classes/{time.js → Time.js} +2 -2
  42. package/dist/dt/classes/{yearMonth.d.ts → YearMonth.d.ts} +1 -1
  43. package/dist/dt/classes/{yearMonth.js → YearMonth.js} +2 -2
  44. package/dist/dt/classes/{zoned.d.ts → Zoned.d.ts} +1 -1
  45. package/dist/dt/classes/{zoned.js → Zoned.js} +9 -3
  46. package/dist/dt/functions/buildLocaleFromIntl.js +1 -1
  47. package/dist/dt/functions/guessFormat.js +1 -1
  48. package/dist/dt/functions/intl-weekinfo-polyfill.js +11 -4
  49. package/dist/dt/functions/parse.js +20 -22
  50. package/dist/dt/functions/setupIntl.js +33 -44
  51. package/dist/dt.d.ts +1 -1
  52. package/dist/dt.js +9 -8
  53. package/dist/env.d.ts +1 -1
  54. package/dist/env.js +6 -7
  55. package/dist/fn/ajax/abort.js +1 -1
  56. package/dist/fn/ajax/ajax.d.ts +1 -1
  57. package/dist/fn/ajax/ajax.js +2 -2
  58. package/dist/fn/ajax/download.js +1 -1
  59. package/dist/fn/ajax/getFileContent.js +2 -3
  60. package/dist/fn/ajax/link.js +2 -2
  61. package/dist/fn/ajax/stream.js +5 -4
  62. package/dist/fn/browser/executeSlowly.js +11 -22
  63. package/dist/fn/browser/log.js +5 -3
  64. package/dist/fn/browser/yieldToBrowser.js +7 -19
  65. package/dist/fn/html/makeReactive.js +2 -2
  66. package/dist/fn/init.d.ts +1 -1
  67. package/dist/fn/init.js +4 -5
  68. package/dist/fn/object/_filter.js +3 -2
  69. package/dist/fn/object/filter.js +2 -1
  70. package/dist/fn/phone/fphone.js +1 -2
  71. package/dist/fn/string/cast.js +1 -2
  72. package/dist/fn/string/shorten.js +1 -1
  73. package/dist/fn/string/treatForHash.js +1 -1
  74. package/dist/fn/style/addColors.d.ts +1 -1
  75. package/dist/fn/style/addColors.js +4 -4
  76. package/dist/fn/type/checkType.js +1 -2
  77. package/dist/fn/type/isCp.js +1 -2
  78. package/dist/fn/type/isHostname.js +1 -1
  79. package/dist/fn/type/isIP.js +1 -1
  80. package/dist/fn/type/isSame.js +2 -2
  81. package/dist/fn/type/isURL.js +1 -1
  82. package/dist/index-no-dep.js +11 -4
  83. package/dist/index.js +13 -4
  84. package/package.json +1 -1
  85. package/dist/dt/classes/duration.js +0 -199
  86. /package/dist/dt/classes/{duration.d.ts → Duration.d.ts} +0 -0
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  // setup-intl.ts
11
2
  import { ensureIntlWeekInfoPolyfill } from './intl-weekinfo-polyfill.js';
12
3
  // ------------------------------
@@ -29,7 +20,7 @@ function needsDateTimeStylePolyfill() {
29
20
  new Intl.DateTimeFormat('en', { dateStyle: 'medium' });
30
21
  return false;
31
22
  }
32
- catch (_a) {
23
+ catch {
33
24
  // Old Safari, old Firefox, old Chrome, etc.
34
25
  return true;
35
26
  }
@@ -44,38 +35,36 @@ function needsDateTimeStylePolyfill() {
44
35
  * import { setupIntl } from './setup-intl';
45
36
  * await setupIntl();
46
37
  */
47
- export default function setupIntl() {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const tasks = [];
50
- // Polyfill RelativeTimeFormat only if missing (old Safari, old Firefox, etc.)
51
- if (needsRelativeTimeFormatPolyfill()) {
52
- tasks.push((() => __awaiter(this, void 0, void 0, function* () {
53
- const rtModule = yield import('@formatjs/intl-relativetimeformat/polyfill.js');
54
- // Ensure module is evaluated (rtModule is unused but import side-effect matters)
55
- void rtModule;
56
- // Add the locales you actually use:
57
- yield import('@formatjs/intl-relativetimeformat/locale-data/en.js');
58
- // await import('@formatjs/intl-relativetimeformat/locale-data/it');
59
- // ...more locales if needed
60
- }))());
61
- }
62
- // Polyfill DateTimeFormat only when style formats are not supported
63
- if (needsDateTimeStylePolyfill()) {
64
- tasks.push((() => __awaiter(this, void 0, void 0, function* () {
65
- const dtModule = yield import('@formatjs/intl-datetimeformat/polyfill.js');
66
- void dtModule;
67
- // Optional but common: locale data
68
- yield import('@formatjs/intl-datetimeformat/locale-data/en.js');
69
- // await import('@formatjs/intl-datetimeformat/locale-data/it');
70
- // If you need full timezone data (heavy!):
71
- // await import('@formatjs/intl-datetimeformat/add-all-tz');
72
- }))());
73
- }
74
- // Wait for all FormatJS polyfills that are actually needed
75
- if (tasks.length > 0) {
76
- yield Promise.all(tasks);
77
- }
78
- // Finally, always patch weekInfo (Intl.Locale) – Firefox, Chrome, etc.
79
- ensureIntlWeekInfoPolyfill();
80
- });
38
+ export default async function setupIntl() {
39
+ const tasks = [];
40
+ // Polyfill RelativeTimeFormat only if missing (old Safari, old Firefox, etc.)
41
+ if (needsRelativeTimeFormatPolyfill()) {
42
+ tasks.push((async () => {
43
+ const rtModule = await import('@formatjs/intl-relativetimeformat/polyfill.js');
44
+ // Ensure module is evaluated (rtModule is unused but import side-effect matters)
45
+ void rtModule;
46
+ // Add the locales you actually use:
47
+ await import('@formatjs/intl-relativetimeformat/locale-data/en.js');
48
+ // await import('@formatjs/intl-relativetimeformat/locale-data/it');
49
+ // ...more locales if needed
50
+ })());
51
+ }
52
+ // Polyfill DateTimeFormat only when style formats are not supported
53
+ if (needsDateTimeStylePolyfill()) {
54
+ tasks.push((async () => {
55
+ const dtModule = await import('@formatjs/intl-datetimeformat/polyfill.js');
56
+ void dtModule;
57
+ // Optional but common: locale data
58
+ await import('@formatjs/intl-datetimeformat/locale-data/en.js');
59
+ // await import('@formatjs/intl-datetimeformat/locale-data/it');
60
+ // If you need full timezone data (heavy!):
61
+ // await import('@formatjs/intl-datetimeformat/add-all-tz');
62
+ })());
63
+ }
64
+ // Wait for all FormatJS polyfills that are actually needed
65
+ if (tasks.length > 0) {
66
+ await Promise.all(tasks);
67
+ }
68
+ // Finally, always patch weekInfo (Intl.Locale) – Firefox, Chrome, etc.
69
+ ensureIntlWeekInfoPolyfill();
81
70
  }
package/dist/dt.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import bbnDtDuration from './dt/classes/duration.js';
1
+ import bbnDtDuration from './dt/classes/Duration.js';
2
2
  import parse from './dt/functions/parse.js';
3
3
  import guessFormat from './dt/functions/guessFormat.js';
4
4
  declare const dt: {
package/dist/dt.js CHANGED
@@ -1,14 +1,15 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
- import bbnDtDateTime from './dt/classes/dateTime.js';
3
- import bbnDtDate from './dt/classes/date.js';
4
- import bbnDtTime from './dt/classes/zoned.js';
5
- import bbnDtYearMonth from './dt/classes/yearMonth.js';
6
- import bbnDtMonthDay from './dt/classes/monthDay.js';
7
- import bbnDtZoned from './dt/classes/zoned.js';
8
- import bbnDtDuration from './dt/classes/duration.js';
2
+ import bbnDtDateTime from './dt/classes/DateTime.js';
3
+ import bbnDtDate from './dt/classes/Date.js';
4
+ import bbnDtTime from './dt/classes/Zoned.js';
5
+ import bbnDtYearMonth from './dt/classes/YearMonth.js';
6
+ import bbnDtMonthDay from './dt/classes/MonthDay.js';
7
+ import bbnDtZoned from './dt/classes/Zoned.js';
8
+ import bbnDtDuration from './dt/classes/Duration.js';
9
9
  import _ from './_.js';
10
10
  import parse from './dt/functions/parse.js';
11
11
  import guessFormat from './dt/functions/guessFormat.js';
12
+ import log from './fn/browser/log.js';
12
13
  const patterns = [
13
14
  // MariaDB DATETIME "YYYY-MM-DD HH:MM:SS"
14
15
  {
@@ -226,7 +227,7 @@ const dt = (value, inputFormat = null, cls = 'auto') => {
226
227
  return new bbnDtDuration(value);
227
228
  }
228
229
  else {
229
- bbn.fn.log('Invalid date value', value);
230
+ log('Invalid date value', value);
230
231
  throw new Error(_('Invalid date value'));
231
232
  }
232
233
  //throw new Error(_('Invalid date value: %s', value));
package/dist/env.d.ts CHANGED
@@ -5,7 +5,7 @@ declare const _default: {
5
5
  lang: string;
6
6
  host: string;
7
7
  url: string;
8
- old_path: any;
8
+ root: string;
9
9
  getParameters: {};
10
10
  loading: boolean;
11
11
  _enumerated: any[];
package/dist/env.js CHANGED
@@ -1,15 +1,14 @@
1
- var _a, _b, _c, _d, _e, _f;
2
1
  export default {
3
- siteTitle: (_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.title,
2
+ siteTitle: globalThis.document?.title,
4
3
  /* This variable should be set to true in debugging mode only */
5
4
  logging: false,
6
5
  /* Address of the CDN (where this file should be hosted) */
7
6
  cdn: '',
8
7
  /* Default language */
9
8
  lang: 'en',
10
- host: ((_b = globalThis.location) === null || _b === void 0 ? void 0 : _b.protocol) + '//' + ((_c = globalThis.location) === null || _c === void 0 ? void 0 : _c.hostname),
11
- url: (_d = globalThis.location) === null || _d === void 0 ? void 0 : _d.href,
12
- old_path: null,
9
+ host: globalThis.location?.protocol + '//' + globalThis.location?.hostname,
10
+ url: globalThis.location?.href,
11
+ root: '',
13
12
  getParameters: {},
14
13
  /* True when non asynchronous Ajax loads */
15
14
  loading: false,
@@ -41,11 +40,11 @@ export default {
41
40
  params: [],
42
41
  isInit: false,
43
42
  isFocused: false,
44
- isVisible: !((_e = globalThis.document) === null || _e === void 0 ? void 0 : _e.hidden),
43
+ isVisible: !globalThis.document?.hidden,
45
44
  timeoff: Math.round((new Date()).getTime() / 1000),
46
45
  loggingLevel: 5,
47
46
  ignoreUnload: false,
48
47
  historyDisabled: false,
49
48
  nav: 'ajax',
50
- online: (_f = globalThis.navigator) === null || _f === void 0 ? void 0 : _f.onLine
49
+ online: globalThis.navigator?.onLine
51
50
  };
@@ -23,7 +23,7 @@ import getLoader from './getLoader.js';
23
23
  */
24
24
  export default function abort(requestId) {
25
25
  let loader = getLoader(requestId);
26
- if (loader === null || loader === void 0 ? void 0 : loader.aborter) {
26
+ if (loader?.aborter) {
27
27
  loader.aborter.abort('Operation canceled by the user.');
28
28
  }
29
29
  /*
@@ -54,4 +54,4 @@
54
54
  *
55
55
  * @returns {Promise} The Promise created by the generated XHR.
56
56
  */
57
- export default function ajax(url: any, datatype?: any, data?: any, success?: any, failure?: any, abort?: any): any;
57
+ export default function ajax(url: any, datatype?: string, data?: any, success?: Function, failure?: Function, abort?: Function): any;
@@ -64,7 +64,7 @@ import com from '../../com.js';
64
64
  *
65
65
  * @returns {Promise} The Promise created by the generated XHR.
66
66
  */
67
- export default function ajax(url, datatype = null, data = null, success = null, failure = null, abort = null) {
67
+ export default function ajax(url, datatype, data, success, failure, abort) {
68
68
  if ((datatype === null) && url && (typeof url === "object") && url.url) {
69
69
  if (url.abort) {
70
70
  abort = url.abort;
@@ -96,7 +96,7 @@ export default function ajax(url, datatype = null, data = null, success = null,
96
96
  }
97
97
  let requestId = getRequestId(url, data, datatype);
98
98
  let loaderObj = getLoader(requestId);
99
- if (loaderObj === null || loaderObj === void 0 ? void 0 : loaderObj.loader) {
99
+ if (loaderObj?.loader) {
100
100
  return loaderObj.loader;
101
101
  }
102
102
  if (bbn.env.token) {
@@ -42,7 +42,7 @@ export default function download(url, filename = '', params = null) {
42
42
  if (!filename) {
43
43
  let prop = "content-disposition";
44
44
  let cd = "attachment; filename=";
45
- if ((headers === null || headers === void 0 ? void 0 : headers[prop]) && headers[prop].indexOf(cd) === 0) {
45
+ if (headers?.[prop] && headers[prop].indexOf(cd) === 0) {
46
46
  filename = substr(headers[prop], cd.length + 1, headers[prop].length - cd.length - 2);
47
47
  }
48
48
  else {
@@ -44,8 +44,7 @@ export default function getFileContent() {
44
44
  input.setAttribute("accept", type);
45
45
  }
46
46
  input.onchange = function (event) {
47
- var _a;
48
- const file = (_a = input.files) === null || _a === void 0 ? void 0 : _a[0];
47
+ const file = input.files?.[0];
49
48
  if (!file)
50
49
  return;
51
50
  const reader = new FileReader();
@@ -57,7 +56,7 @@ export default function getFileContent() {
57
56
  }
58
57
  reader.onload = function ({ target }) {
59
58
  if (success) {
60
- success(target === null || target === void 0 ? void 0 : target.result);
59
+ success(target?.result);
61
60
  }
62
61
  };
63
62
  reader.onerror = function () {
@@ -97,7 +97,7 @@ export default function link(...args) {
97
97
  }
98
98
  /** todo Do we keep obj in the unique string or do we make that only one concurrent connection to the same address can occur at the same time? */
99
99
  let errSt = bbn._('The Ajax call to') + ' ' + cfg.url + ' ';
100
- return ajax(cfg.url, cfg.datatype, cfg.obj, res => {
100
+ return ajax(cfg.url, cfg.datatype, cfg.obj, (res) => {
101
101
  if (!res) {
102
102
  log(errSt + bbn._('returned no answer'));
103
103
  }
@@ -116,7 +116,7 @@ export default function link(...args) {
116
116
  }
117
117
  if (callback(cfg.url, res, cfg.successFn, null, cfg.ele) && res.noNav === undefined) {
118
118
  // This solution is not very clean (we can't shorten a URL)
119
- if (bbn.env.path.indexOf(cfg.url) !== 0) {
119
+ if ((bbn.env?.path || '').indexOf(cfg.url) !== 0) {
120
120
  setNavigationVars(cfg.url, (res.title ? res.title + ' - ' : '') + bbn.env.siteTitle);
121
121
  }
122
122
  }
@@ -3,6 +3,7 @@ import getLoader from './getLoader.js';
3
3
  import _deleteLoader from './_deleteLoader.js';
4
4
  import isFunction from '../type/isFunction.js';
5
5
  import _addLoader from './_addLoader.js';
6
+ import log from '../browser/log.js';
6
7
  import defaultStartLoadingFunction from '../default/defaultStartLoadingFunction.js';
7
8
  import defaultEndLoadingFunction from '../default/defaultEndLoadingFunction.js';
8
9
  import defaultAjaxAbortFunction from '../default/defaultAjaxAbortFunction.js';
@@ -30,7 +31,7 @@ export default function stream(url, success, data, failure, abort, finished) {
30
31
  const requestId = getRequestId(url, data, 'json');
31
32
  const loaderObj = getLoader(requestId);
32
33
  //log("IN AJAX", loaderObj? loaderObj.loader : "NO LOADER")
33
- if (loaderObj === null || loaderObj === void 0 ? void 0 : loaderObj.loader) {
34
+ if (loaderObj?.loader) {
34
35
  return loaderObj.loader;
35
36
  }
36
37
  if (!data) {
@@ -52,7 +53,7 @@ export default function stream(url, success, data, failure, abort, finished) {
52
53
  for (let i in json) {
53
54
  try {
54
55
  const parsed = JSON.parse(json[i]);
55
- if (!(parsed === null || parsed === void 0 ? void 0 : parsed.__bbn_stream_ping__)) {
56
+ if (!parsed?.__bbn_stream_ping__) {
56
57
  success(parsed);
57
58
  }
58
59
  }
@@ -94,7 +95,7 @@ export default function stream(url, success, data, failure, abort, finished) {
94
95
  }
95
96
  if (isFn) {
96
97
  json += arrayBuffer2String(value).trim();
97
- bbn.fn.log(["STREAM RESULT", json.length, json]);
98
+ log(["STREAM RESULT", json.length, json]);
98
99
  if (json) {
99
100
  try {
100
101
  treatJSON(json);
@@ -107,7 +108,7 @@ export default function stream(url, success, data, failure, abort, finished) {
107
108
  }
108
109
  }
109
110
  else {
110
- bbn.fn.log(["STREAM SUCCESS IS FN? " + isFn]);
111
+ log(["STREAM SUCCESS IS FN? " + isFn]);
111
112
  }
112
113
  // Read some more, and call this function again
113
114
  return reader.read().then(pump);
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import yieldToBrowser from './yieldToBrowser.js';
11
2
  /**
12
3
  * Executes a function on each element of an array slowly, yielding to the browser in between.
@@ -14,18 +5,16 @@ import yieldToBrowser from './yieldToBrowser.js';
14
5
  * @param fn The function to execute on each element. If the function returns false, the iteration stops.
15
6
  * @returns A promise that resolves to true if the iteration completed, or false if it was stopped early.
16
7
  */
17
- export default function executeSlowly(arr, fn) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- for (let i = 0; i < arr.length; i++) {
20
- yield yieldToBrowser();
21
- let res = fn(arr[i], i);
22
- if (res instanceof Promise) {
23
- res = yield res;
24
- }
25
- if (res === false) {
26
- return false;
27
- }
8
+ export default async function executeSlowly(arr, fn) {
9
+ for (let i = 0; i < arr.length; i++) {
10
+ await yieldToBrowser();
11
+ let res = fn(arr[i], i);
12
+ if (res instanceof Promise) {
13
+ res = await res;
28
14
  }
29
- return true;
30
- });
15
+ if (res === false) {
16
+ return false;
17
+ }
18
+ }
19
+ return true;
31
20
  }
@@ -13,8 +13,7 @@ import isFunction from '../type/isFunction.js';
13
13
  * @returns
14
14
  */
15
15
  export default function log(...args) {
16
- var _a, _b, _c, _d;
17
- if (((_b = (_a = globalThis.bbn) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b.logging) && (globalThis.console !== undefined)) {
16
+ if (globalThis.bbn?.env?.logging && (globalThis.console !== undefined)) {
18
17
  let cfg;
19
18
  let level = 5;
20
19
  let fn = 'log';
@@ -29,12 +28,15 @@ export default function log(...args) {
29
28
  args.shift();
30
29
  }
31
30
  const exec = globalThis.console[fn];
32
- if (((_d = (_c = globalThis.bbn) === null || _c === void 0 ? void 0 : _c.env) === null || _d === void 0 ? void 0 : _d.loggingLevel) >= level) {
31
+ if (globalThis.bbn?.env?.loggingLevel >= level) {
33
32
  let i = 0;
34
33
  while (i < args.length) {
35
34
  let t = typeof args[i];
36
35
  let consoleArguments = [args[i]];
37
36
  if (t === 'string' || t === 'number') {
37
+ if (!globalThis.document) {
38
+ consoleArguments[0] = `[SW] ${consoleArguments[0]}`;
39
+ }
38
40
  consoleArguments.unshift('%c %s ', cfg);
39
41
  }
40
42
  exec.apply(globalThis.console, consoleArguments);
@@ -1,12 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  /**
11
2
  * Yields execution to the browser to allow it to process pending UI updates.
12
3
  * Uses `window.scheduler.yield()` if available, otherwise falls back to `requestAnimationFrame`.
@@ -19,15 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
10
  * @memberof bbn.fn
20
11
  * @returns {Promise}
21
12
  */
22
- export default function yieldToBrowser() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- var _a;
25
- if ((_a = window.scheduler) === null || _a === void 0 ? void 0 : _a.yield) {
26
- yield window.scheduler.yield(); // cooperative yield
27
- }
28
- else {
29
- yield new Promise(requestAnimationFrame);
30
- }
31
- });
13
+ export default async function yieldToBrowser() {
14
+ if (window.scheduler?.yield) {
15
+ await window.scheduler.yield(); // cooperative yield
16
+ }
17
+ else {
18
+ await new Promise(requestAnimationFrame);
19
+ }
32
20
  }
33
21
  ;
@@ -7,7 +7,7 @@ import warning from '../browser/warning.js';
7
7
  import isFunction from '../type/isFunction.js';
8
8
  import isSame from '../type/isSame.js';
9
9
  export default function makeReactive(obj, onSet, parent, parentProp) {
10
- const parentString = (parent === null || parent === void 0 ? void 0 : parent.$cid) || '';
10
+ const parentString = parent?.$cid || '';
11
11
  const prefix = '__bbn_' + (parentString ? parentString + '_' : '');
12
12
  if (obj && typeof obj === 'object' && [undefined, Object, Array].includes(obj.constructor)) {
13
13
  if (obj.__bbnIsProxy && obj.__bbnParent === parent) {
@@ -48,7 +48,7 @@ export default function makeReactive(obj, onSet, parent, parentProp) {
48
48
  }
49
49
  if (key === '__bbnRoot') {
50
50
  let root = obj;
51
- while (root && (root === null || root === void 0 ? void 0 : root.__bbnTarget)) {
51
+ while (root && root?.__bbnTarget) {
52
52
  root = root.__bbnTarget;
53
53
  }
54
54
  return root;
package/dist/fn/init.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Initializes the library bbn basing on the given configuration object.
3
3
  * - Gives to the environment the dimension of the window.innerWidth and window.innerHeight
4
4
  * - Defines the server's path (difference between the host and the current dir)
5
- * - Adds the colors contained in bbn.var.colors to define the css classes for background and colors.
5
+ * - Adds the colors contained in bbn.data.colors to define the css classes for background and colors.
6
6
  * - Adds the event listener to the document
7
7
  * - Activates the history
8
8
  * @method init
package/dist/fn/init.js CHANGED
@@ -45,7 +45,7 @@ const onActivity = (e) => {
45
45
  * Initializes the library bbn basing on the given configuration object.
46
46
  * - Gives to the environment the dimension of the window.innerWidth and window.innerHeight
47
47
  * - Defines the server's path (difference between the host and the current dir)
48
- * - Adds the colors contained in bbn.var.colors to define the css classes for background and colors.
48
+ * - Adds the colors contained in bbn.data.colors to define the css classes for background and colors.
49
49
  * - Adds the event listener to the document
50
50
  * - Activates the history
51
51
  * @method init
@@ -55,9 +55,8 @@ const onActivity = (e) => {
55
55
  * @returns
56
56
  */
57
57
  export default function init(cfg, force) {
58
- var _a, _b;
59
58
  if (!bbn.env.isInit) {
60
- bbn.env.root = ((_b = (_a = globalThis.document) === null || _a === void 0 ? void 0 : _a.baseURI) === null || _b === void 0 ? void 0 : _b.length) ? globalThis.document.baseURI : bbn.env.host;
59
+ bbn.env.root = globalThis.document?.baseURI?.length ? globalThis.document.baseURI : bbn.env.host;
61
60
  if (bbn.env.root.length && substr(bbn.env.root, -1) !== "/") {
62
61
  bbn.env.root += "/";
63
62
  }
@@ -77,8 +76,8 @@ export default function init(cfg, force) {
77
76
  bbn.env.params = bbn.env.path.split('/').filter(v => v !== '');
78
77
  setupIntl();
79
78
  if (globalThis.document) {
80
- if (bbn.var.colors) {
81
- addColors(bbn.var.colors);
79
+ if (bbn.data.colors) {
80
+ addColors(bbn.data.colors);
82
81
  }
83
82
  document.addEventListener("visibilitychange", () => {
84
83
  if (document.hidden) {
@@ -1,5 +1,6 @@
1
1
  import isArray from '../type/isArray.js';
2
2
  import compareConditions from './compareConditions.js';
3
+ import log from '../browser/log.js';
3
4
  /**
4
5
  * Returns a new array with only the data matching the given filter.
5
6
  *
@@ -52,8 +53,8 @@ export default function _filter(arr, prop, val = null, operator = '=', limit = 0
52
53
  try {
53
54
  arr = Array.from(arr);
54
55
  }
55
- catch (_a) {
56
- bbn.fn.log("NOT ARRAY", arr);
56
+ catch {
57
+ log("NOT ARRAY", arr);
57
58
  throw new Error('Error in filter: The first argument must be an array');
58
59
  }
59
60
  }
@@ -1,6 +1,7 @@
1
1
  import isArray from '../type/isArray.js';
2
2
  import { filterToConditions } from './filterToConditions.js';
3
3
  import compareConditions from './compareConditions.js';
4
+ import log from '../browser/log.js';
4
5
  /**
5
6
  * Returns a new array with only the data matching the given filter.
6
7
  *
@@ -50,7 +51,7 @@ import compareConditions from './compareConditions.js';
50
51
  */
51
52
  export default function filter(arr, prop, val = null, operator = '=') {
52
53
  if (!isArray(arr)) {
53
- bbn.fn.log("NOT ARRAY", arr);
54
+ log("NOT ARRAY", arr);
54
55
  throw new Error('Error in filter: The first argument must be an array');
55
56
  }
56
57
  let cfg = {};
@@ -2,12 +2,11 @@ import isNumber from '../type/isNumber.js';
2
2
  import isString from '../type/isString.js';
3
3
  import each from '../loop/each.js';
4
4
  export default function fphone(st) {
5
- var _a;
6
5
  if (isNumber(st)) {
7
6
  st = st.toString();
8
7
  }
9
8
  if (isString(st)) {
10
- const phoneCodes = ((_a = bbn.var) === null || _a === void 0 ? void 0 : _a.phoneCodes) || [];
9
+ const phoneCodes = bbn.data?.phoneCodes || [];
11
10
  let res = '';
12
11
  let prefix = '';
13
12
  let mask = '';
@@ -14,7 +14,6 @@
14
14
  * @returns {String}
15
15
  */
16
16
  export default function cast(st) {
17
- var _a;
18
17
  if (!st) {
19
18
  return '';
20
19
  }
@@ -22,7 +21,7 @@ export default function cast(st) {
22
21
  if (bbn.fn.isArray(st)) {
23
22
  return 'Array (' + st.length + ')';
24
23
  }
25
- return ((_a = st.constructor) === null || _a === void 0 ? void 0 : _a.name) || '{}';
24
+ return st.constructor?.name || '{}';
26
25
  }
27
26
  if (st.toString) {
28
27
  return st.toString();
@@ -28,7 +28,7 @@ import substr from './substr.js';
28
28
  export default function shorten(st, len, adj) {
29
29
  if (typeof st.toLowerCase() === "string") {
30
30
  if (!len) {
31
- len = bbn.var.shortenLen;
31
+ len = bbn.data.shortenLen;
32
32
  }
33
33
  if (adj === undefined || !isString(adj)) {
34
34
  adj = "...";
@@ -38,7 +38,7 @@ export default function treatForHash(value, depth = null, level = 0, visited = n
38
38
  else if (typeof value === 'boolean') {
39
39
  value = "__BBN_BOOLEAN__" + value.toString();
40
40
  }
41
- else if (![undefined, Object, Array, null].includes(value === null || value === void 0 ? void 0 : value.constructor)) {
41
+ else if (![undefined, Object, Array, null].includes(value?.constructor)) {
42
42
  if (isDom(value)) {
43
43
  if (isCp(value)) {
44
44
  value = "__BBN_CP__" + value.$cid;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Adds the given color to the object bbn.var.colors in order to be able to use
2
+ * Adds the given color to the object bbn.data.colors in order to be able to use
3
3
  * the css classes bbn-bg-myColor for the background and bbn-myColor for the text color.
4
4
  *
5
5
  * @method addColors
@@ -1,7 +1,7 @@
1
1
  import numProperties from '../object/numProperties.js';
2
2
  import iterate from '../loop/iterate.js';
3
3
  /**
4
- * Adds the given color to the object bbn.var.colors in order to be able to use
4
+ * Adds the given color to the object bbn.data.colors in order to be able to use
5
5
  * the css classes bbn-bg-myColor for the background and bbn-myColor for the text color.
6
6
  *
7
7
  * @method addColors
@@ -17,8 +17,8 @@ import iterate from '../loop/iterate.js';
17
17
  */
18
18
  export default function addColors(colors) {
19
19
  if (numProperties(colors)) {
20
- if (!bbn.var.colors) {
21
- bbn.var.colors = {};
20
+ if (!bbn.data.colors) {
21
+ bbn.data.colors = {};
22
22
  }
23
23
  let element = document.createElement("style");
24
24
  document.head.appendChild(element);
@@ -26,7 +26,7 @@ export default function addColors(colors) {
26
26
  // Append style element to head
27
27
  let i = 0;
28
28
  iterate(colors, (v, n) => {
29
- bbn.var.colors[n] = v;
29
+ bbn.data.colors[n] = v;
30
30
  sheet.insertRule(".bbn-" +
31
31
  n +
32
32
  ", .bbn-color-text-" +
@@ -12,7 +12,6 @@ export default function checkType(value, type, msg, ...logs) {
12
12
  }
13
13
  const typesList = [];
14
14
  each(type, (t) => {
15
- var _a;
16
15
  if (t === String) {
17
16
  t = 'string';
18
17
  }
@@ -32,7 +31,7 @@ export default function checkType(value, type, msg, ...logs) {
32
31
  t = 'function';
33
32
  }
34
33
  if (isFunction(t)) {
35
- typesList.push(t.name || ((_a = t.constructor) === null || _a === void 0 ? void 0 : _a.name) || t.toString());
34
+ typesList.push(t.name || t.constructor?.name || t.toString());
36
35
  if (value instanceof t) {
37
36
  ok = true;
38
37
  return false;
@@ -1,6 +1,5 @@
1
1
  import isDom from './isDom.js';
2
2
  export default function isCp(...args) {
3
- var _a;
4
3
  if (!args.length) {
5
4
  return false;
6
5
  }
@@ -9,7 +8,7 @@ export default function isCp(...args) {
9
8
  }
10
9
  for (let a of args) {
11
10
  let res = bbn.cp.isComponent(a);
12
- if (!res || isDom(a) || !((_a = a.$el) === null || _a === void 0 ? void 0 : _a.bbnCid)) {
11
+ if (!res || isDom(a) || !a.$el?.bbnCid) {
13
12
  return false;
14
13
  }
15
14
  }