@bbn/bbn 1.0.86 → 1.0.88

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/bundle.d.ts CHANGED
@@ -1591,6 +1591,14 @@ declare module "fn/ajax/ajax" {
1591
1591
  export { ajax };
1592
1592
  }
1593
1593
  declare module "fn/misc/analyzeFunction" {
1594
+ /**
1595
+ * Analyzes the given function and extracts details about its structure.
1596
+ *
1597
+ * @function analyzeFunction
1598
+ * @param {Function} fn - The function to analyze.
1599
+ * @returns {Object} An object containing details about the function.
1600
+ * @throws {Error} When unexpected syntax is encountered while parsing.
1601
+ */
1594
1602
  const analyzeFunction: (fn: any) => {
1595
1603
  body: any;
1596
1604
  args: any[];
package/dist/bundle.js CHANGED
@@ -3212,9 +3212,19 @@
3212
3212
  "use strict";
3213
3213
  Object.defineProperty(exports, "__esModule", { value: true });
3214
3214
  exports.analyzeFunction = void 0;
3215
+ /**
3216
+ * Analyzes the given function and extracts details about its structure.
3217
+ *
3218
+ * @function analyzeFunction
3219
+ * @param {Function} fn - The function to analyze.
3220
+ * @returns {Object} An object containing details about the function.
3221
+ * @throws {Error} When unexpected syntax is encountered while parsing.
3222
+ */
3215
3223
  const analyzeFunction = function (fn) {
3216
- const functionString = fn.toString();
3217
- let all = functionString.split('');
3224
+ const all = typeof fn === 'function' ? fn.toString() : fn;
3225
+ if (typeof all !== 'string') {
3226
+ throw Error('Unexpected type ' + typeof fn + ' while parsing function');
3227
+ }
3218
3228
  let exp = '';
3219
3229
  let isArrow = false;
3220
3230
  let isAsync = false;
@@ -3229,12 +3239,33 @@
3229
3239
  let escapable = ['"', "'", '`'];
3230
3240
  let isEscaped = false;
3231
3241
  let settingDefault = false;
3242
+ let isComment = false;
3243
+ let isCommentLine = false;
3232
3244
  for (let i = 0; i < all.length; i++) {
3233
- if (all[i] === currentQuote && !isEscaped && currentQuote) {
3245
+ // Handle string literals
3246
+ if (!isComment && all[i] === '/' && all[i + 1] === '*') {
3247
+ isComment = true;
3248
+ exp = '';
3249
+ }
3250
+ else if (all[i] === '*' && all[i + 1] === '/') {
3251
+ isComment = false;
3252
+ }
3253
+ else if (!isCommentLine && all[i] === '/' && all[i + 1] === '/') {
3254
+ isCommentLine = true;
3255
+ exp = '';
3256
+ }
3257
+ else if (all[i] === '\n') {
3258
+ isCommentLine = false;
3259
+ }
3260
+ else if (isComment || isCommentLine) {
3261
+ continue;
3262
+ }
3263
+ else if (all[i] === currentQuote && !isEscaped && currentQuote) {
3234
3264
  currentQuote = '';
3235
3265
  exp += all[i];
3236
3266
  }
3237
3267
  else if (currentQuote) {
3268
+ isEscaped = all[i] === '\\' && !isEscaped;
3238
3269
  exp += all[i];
3239
3270
  }
3240
3271
  else if (escapable.includes(all[i]) && !isEscaped) {
@@ -3256,13 +3287,13 @@
3256
3287
  else if (all[i] === ')') {
3257
3288
  if (parOpened === parClosed + 1) {
3258
3289
  if (settingDefault) {
3259
- currentArg.default = exp.trim();
3290
+ currentArg['default'] = exp.trim();
3260
3291
  settingDefault = false;
3261
3292
  }
3262
3293
  else if (exp) {
3263
- currentArg.name = exp.trim();
3294
+ currentArg['name'] = exp.trim();
3264
3295
  }
3265
- if (currentArg.name || currentArg.default) {
3296
+ if (currentArg['name'] || currentArg['default']) {
3266
3297
  args.push(currentArg);
3267
3298
  currentArg = {};
3268
3299
  }
@@ -3270,37 +3301,32 @@
3270
3301
  }
3271
3302
  parClosed++;
3272
3303
  }
3273
- else if (all[i] === '=') {
3274
- if (functionString.substr(i, 2) === '=>') {
3275
- if (exp.trim() !== '' && parOpened === parClosed) {
3276
- currentArg.name = exp.trim();
3277
- args.push(currentArg);
3278
- currentArg = {};
3279
- exp = '';
3280
- }
3281
- isArrow = true;
3282
- i++;
3283
- continue;
3284
- }
3285
- else if (parOpened > parClosed && !settingDefault) {
3286
- currentArg.name = exp.trim();
3304
+ else if (all[i] === '=' && all[i + 1] === '>') {
3305
+ if (exp.trim() !== '' && parOpened === parClosed) {
3306
+ currentArg['name'] = exp.trim();
3307
+ args.push(currentArg);
3308
+ currentArg = {};
3287
3309
  exp = '';
3288
- settingDefault = true;
3289
- }
3290
- else {
3291
- exp += all[i];
3292
3310
  }
3311
+ isArrow = true;
3312
+ i++;
3313
+ continue;
3314
+ }
3315
+ else if (all[i] === '=' && parOpened > parClosed && !settingDefault) {
3316
+ currentArg['name'] = exp.trim();
3317
+ exp = '';
3318
+ settingDefault = true;
3293
3319
  }
3294
3320
  else if (all[i] === ',') {
3295
3321
  if (parOpened > parClosed) {
3296
3322
  if (settingDefault) {
3297
- currentArg.default = exp.trim();
3323
+ currentArg['default'] = exp.trim();
3298
3324
  settingDefault = false;
3299
3325
  }
3300
3326
  else if (exp) {
3301
- currentArg.name = exp.trim();
3327
+ currentArg['name'] = exp.trim();
3302
3328
  }
3303
- if (currentArg.name || currentArg.default) {
3329
+ if (currentArg['name'] || currentArg['default']) {
3304
3330
  args.push(currentArg);
3305
3331
  currentArg = {};
3306
3332
  }
@@ -3311,11 +3337,11 @@
3311
3337
  }
3312
3338
  }
3313
3339
  else if (all[i] === '{' || all[i] === '}') {
3314
- body = functionString.substring(i).trim();
3340
+ body = all.substring(i).trim();
3315
3341
  break;
3316
3342
  }
3317
3343
  else if (isArrow) {
3318
- body = functionString.substring(functionString.indexOf('=>') + 2).trim();
3344
+ body = all.substring(all.indexOf('=>') + 2).trim();
3319
3345
  break;
3320
3346
  }
3321
3347
  else if (all[i] === ' ') {
@@ -5948,7 +5974,7 @@
5948
5974
  };
5949
5975
  exports.getHTMLOfSelection = getHTMLOfSelection;
5950
5976
  });
5951
- define("fn/browser/getEventData", ["require", "exports", "fn/html/getHTMLOfSelection", "fn/loop/each", "fn/default/defaultErrorFunction"], function (require, exports, getHTMLOfSelection_1, each_15, defaultErrorFunction_1) {
5977
+ define("fn/browser/getEventData", ["require", "exports", "fn/html/getHTMLOfSelection", "fn/loop/each"], function (require, exports, getHTMLOfSelection_1, each_15) {
5952
5978
  "use strict";
5953
5979
  Object.defineProperty(exports, "__esModule", { value: true });
5954
5980
  exports.getEventData = void 0;
@@ -6032,7 +6058,7 @@
6032
6058
  }
6033
6059
  }
6034
6060
  else {
6035
- (0, defaultErrorFunction_1.defaultErrorFunction)(bbn._('Impossible to read the file') + ' ' + name);
6061
+ bbn.fn.defaultErrorFunction(bbn._('Impossible to read the file') + ' ' + name);
6036
6062
  }
6037
6063
  }
6038
6064
  else {
@@ -6899,7 +6925,7 @@
6899
6925
  };
6900
6926
  exports.submit = submit;
6901
6927
  });
6902
- define("fn/style/resize", ["require", "exports", "fn/style/getCssVar", "fn/loop/each", "fn/default/defaultResizeFunction"], function (require, exports, getCssVar_1, each_17, defaultResizeFunction_1) {
6928
+ define("fn/style/resize", ["require", "exports", "fn/style/getCssVar", "fn/loop/each"], function (require, exports, getCssVar_1, each_17) {
6903
6929
  "use strict";
6904
6930
  Object.defineProperty(exports, "__esModule", { value: true });
6905
6931
  exports.resize = void 0;
@@ -6934,8 +6960,8 @@
6934
6960
  if (!done) {
6935
6961
  classes.push(newCls);
6936
6962
  }
6963
+ bbn.fn.defaultResizeFunction();
6937
6964
  document.body.className = classes.join(' ');
6938
- (0, defaultResizeFunction_1.defaultResizeFunction)();
6939
6965
  }
6940
6966
  };
6941
6967
  exports.resize = resize;
@@ -6991,7 +7017,7 @@
6991
7017
  };
6992
7018
  exports.isMobile = isMobile;
6993
7019
  });
6994
- define("fn/init", ["require", "exports", "fn/string/substr", "fn/loop/each", "fn/object/extend", "fn/style/addColors", "fn/ajax/link", "fn/form/submit", "fn/style/resize", "fn/browser/isMobile", "fn/browser/isTabletDevice", "fn/default/defaultHistoryFunction", "fn/type/isFunction", "fn/browser/log"], function (require, exports, substr_11, each_18, extend_7, addColors_1, link_1, submit_1, resize_1, isMobile_1, isTabletDevice_2, defaultHistoryFunction_1, isFunction_9, log_18) {
7020
+ define("fn/init", ["require", "exports", "fn/string/substr", "fn/loop/each", "fn/object/extend", "fn/style/addColors", "fn/ajax/link", "fn/form/submit", "fn/style/resize", "fn/browser/isMobile", "fn/browser/isTabletDevice", "fn/type/isFunction", "fn/browser/log"], function (require, exports, substr_11, each_18, extend_7, addColors_1, link_1, submit_1, resize_1, isMobile_1, isTabletDevice_2, isFunction_9, log_18) {
6995
7021
  "use strict";
6996
7022
  Object.defineProperty(exports, "__esModule", { value: true });
6997
7023
  exports.init = void 0;
@@ -7011,61 +7037,62 @@
7011
7037
  const init = function (cfg, force) {
7012
7038
  let parts;
7013
7039
  if (!bbn.env.isInit || force) {
7014
- bbn.env.root = document.baseURI.length > 0 ? document.baseURI : bbn.env.host;
7015
- if (bbn.env.root.length && (0, substr_11.substr)(bbn.env.root, -1) !== '/') {
7016
- bbn.env.root += '/';
7040
+ bbn.env.root =
7041
+ document.baseURI.length > 0 ? document.baseURI : bbn.env.host;
7042
+ if (bbn.env.root.length && (0, substr_11.substr)(bbn.env.root, -1) !== "/") {
7043
+ bbn.env.root += "/";
7017
7044
  }
7018
- if (!bbn.env.isInit && typeof dayjs !== 'undefined') {
7045
+ if (!bbn.env.isInit && typeof dayjs !== "undefined") {
7019
7046
  (0, each_18.each)([
7020
- 'advancedFormat',
7021
- 'arraySupport',
7022
- 'badMutable',
7023
- 'buddhistEra',
7024
- 'calendar',
7025
- 'customParseFormat',
7026
- 'dayOfYear',
7027
- 'devHelper',
7028
- 'duration',
7029
- 'isBetween',
7030
- 'isLeapYear',
7031
- 'isSameOrAfter',
7032
- 'isSameOrBefore',
7033
- 'isToday',
7034
- 'isTomorrow',
7035
- 'isYesterday',
7036
- 'isoWeek',
7037
- 'isoWeeksInYear',
7038
- 'localeData',
7039
- 'localizedFormat',
7040
- 'minMax',
7041
- 'objectSupport',
7042
- 'pluralGetSet',
7043
- 'quarterOfYear',
7044
- 'relativeTime',
7045
- 'timezone',
7046
- 'toArray',
7047
- 'toObject',
7048
- 'updateLocale',
7049
- 'utc',
7050
- 'weekOfYear',
7051
- 'weekYear',
7052
- 'weekday',
7047
+ "advancedFormat",
7048
+ "arraySupport",
7049
+ "badMutable",
7050
+ "buddhistEra",
7051
+ "calendar",
7052
+ "customParseFormat",
7053
+ "dayOfYear",
7054
+ "devHelper",
7055
+ "duration",
7056
+ "isBetween",
7057
+ "isLeapYear",
7058
+ "isSameOrAfter",
7059
+ "isSameOrBefore",
7060
+ "isToday",
7061
+ "isTomorrow",
7062
+ "isYesterday",
7063
+ "isoWeek",
7064
+ "isoWeeksInYear",
7065
+ "localeData",
7066
+ "localizedFormat",
7067
+ "minMax",
7068
+ "objectSupport",
7069
+ "pluralGetSet",
7070
+ "quarterOfYear",
7071
+ "relativeTime",
7072
+ "timezone",
7073
+ "toArray",
7074
+ "toObject",
7075
+ "updateLocale",
7076
+ "utc",
7077
+ "weekOfYear",
7078
+ "weekYear",
7079
+ "weekday",
7053
7080
  ], (plugin) => {
7054
- if (window['dayjs_plugin_' + plugin]) {
7055
- dayjs.extend(window['dayjs_plugin_' + plugin]);
7081
+ if (window["dayjs_plugin_" + plugin]) {
7082
+ dayjs.extend(window["dayjs_plugin_" + plugin]);
7056
7083
  }
7057
7084
  });
7058
7085
  }
7059
7086
  /* The server's path (difference between the host and the current dir */
7060
- if (typeof cfg === 'object') {
7087
+ if (typeof cfg === "object") {
7061
7088
  (0, extend_7.extend)(true, bbn, cfg);
7062
7089
  }
7063
7090
  bbn.env.path = (0, substr_11.substr)(bbn.env.url, bbn.env.root.length);
7064
- parts = bbn.env.path.split('/');
7091
+ parts = bbn.env.path.split("/");
7065
7092
  //$.each(parts, function(i, v){
7066
7093
  (0, each_18.each)(parts, (v, i) => {
7067
7094
  v = decodeURI(v.trim());
7068
- if (v !== '') {
7095
+ if (v !== "") {
7069
7096
  bbn.env.params.push(v);
7070
7097
  }
7071
7098
  });
@@ -7082,59 +7109,63 @@
7082
7109
  bbn.env.isFocused = false;
7083
7110
  bbn.env.timeoff = Math.round(new Date().getTime() / 1000);
7084
7111
  };
7085
- document.addEventListener('focusin', (e) => {
7086
- if (e.target instanceof HTMLElement && !e.target.classList.contains('bbn-no')) {
7112
+ document.addEventListener("focusin", (e) => {
7113
+ if (e.target instanceof HTMLElement &&
7114
+ !e.target.classList.contains("bbn-no")) {
7087
7115
  bbn.env.focused = e.target;
7088
7116
  }
7089
7117
  bbn.env.last_focus = new Date().getTime();
7090
7118
  });
7091
- document.addEventListener('click', (e) => {
7119
+ document.addEventListener("click", (e) => {
7092
7120
  bbn.env.last_focus = new Date().getTime();
7093
- if (bbn.env.nav !== 'ajax') {
7121
+ if (bbn.env.nav !== "ajax") {
7094
7122
  return;
7095
7123
  }
7096
7124
  let target = e.target;
7097
- if (target instanceof HTMLElement && (target.tagName !== 'A')) {
7125
+ if (target instanceof HTMLElement && target.tagName !== "A") {
7098
7126
  let p = target;
7099
- while (p && p.tagName !== 'A') {
7100
- if (p.tagName === 'BODY') {
7127
+ while (p && p.tagName !== "A") {
7128
+ if (p.tagName === "BODY") {
7101
7129
  break;
7102
7130
  }
7103
7131
  p = p.parentElement;
7104
7132
  }
7105
- if (p && p.tagName === 'A') {
7133
+ if (p && p.tagName === "A") {
7106
7134
  target = p;
7107
7135
  }
7108
7136
  else {
7109
7137
  target = null;
7110
7138
  }
7111
7139
  }
7112
- if (target instanceof HTMLElement && target.hasAttribute('href') && !target.hasAttribute('target') && !target.classList.contains('bbn-no')) {
7140
+ if (target instanceof HTMLElement &&
7141
+ target.hasAttribute("href") &&
7142
+ !target.hasAttribute("target") &&
7143
+ !target.classList.contains("bbn-no")) {
7113
7144
  e.preventDefault();
7114
7145
  e.stopPropagation();
7115
- (0, link_1.link)(target.getAttribute('href'));
7146
+ (0, link_1.link)(target.getAttribute("href"));
7116
7147
  return false;
7117
7148
  }
7118
7149
  });
7119
- (0, each_18.each)(document.querySelectorAll('form:not(.bbn-no), form:not(.bbn-form)'), (ele) => {
7120
- ele.addEventListener('submit', (e) => {
7150
+ (0, each_18.each)(document.querySelectorAll("form:not(.bbn-no), form:not(.bbn-form)"), (ele) => {
7151
+ ele.addEventListener("submit", (e) => {
7121
7152
  (0, submit_1.submit)(ele, e);
7122
7153
  });
7123
7154
  });
7124
- window.addEventListener('hashchange', () => {
7155
+ window.addEventListener("hashchange", () => {
7125
7156
  bbn.env.hashChanged = new Date().getTime();
7126
7157
  }, false);
7127
- window.addEventListener('resize', () => {
7158
+ window.addEventListener("resize", () => {
7128
7159
  (0, resize_1.resize)();
7129
7160
  });
7130
- window.addEventListener('orientationchange', () => {
7161
+ window.addEventListener("orientationchange", () => {
7131
7162
  (0, resize_1.resize)();
7132
7163
  });
7133
7164
  (0, resize_1.resize)();
7134
7165
  if ((0, isMobile_1.isMobile)()) {
7135
- document.body.classList.add('bbn-mobile');
7166
+ document.body.classList.add("bbn-mobile");
7136
7167
  if ((0, isTabletDevice_2.isTabletDevice)()) {
7137
- document.body.classList.add('bbn-tablet');
7168
+ document.body.classList.add("bbn-tablet");
7138
7169
  }
7139
7170
  }
7140
7171
  if (window.history) {
@@ -7142,9 +7173,9 @@
7142
7173
  let h = window.history;
7143
7174
  if (!bbn.env.historyDisabled && h) {
7144
7175
  //e.preventDefault();
7145
- let state = h.state;
7146
- if (state) {
7147
- if ((0, defaultHistoryFunction_1.defaultHistoryFunction)(state)) {
7176
+ if (bbn.fn.defaultHistoryFunction(h.state)) {
7177
+ let state = h.state;
7178
+ if (state) {
7148
7179
  //link(substr(state.url, bbn.env.root.length), $.extend({title: state.title}, state.data));
7149
7180
  (0, link_1.link)(state.url, (0, extend_7.extend)({ title: state.title || bbn.env.siteTitle }, state.data || {}));
7150
7181
  }
@@ -7156,9 +7187,9 @@
7156
7187
  };
7157
7188
  }
7158
7189
  bbn.env.isInit = true;
7159
- document.dispatchEvent(new Event('bbninit'));
7190
+ document.dispatchEvent(new Event("bbninit"));
7160
7191
  if (bbn.env.logging) {
7161
- (0, log_18.log)('Logging in bbn is enabled');
7192
+ (0, log_18.log)("Logging in bbn is enabled");
7162
7193
  }
7163
7194
  }
7164
7195
  };
@@ -9769,7 +9800,7 @@
9769
9800
  };
9770
9801
  exports.upload = upload;
9771
9802
  });
9772
- define("fn", ["require", "exports", "fn/ajax/_addLoader", "fn/object/_compareValues", "fn/ajax/_deleteLoader", "fn/ajax/abort", "fn/ajax/abortURL", "fn/style/addColors", "fn/form/addInputs", "fn/style/addStyle", "fn/html/adjustHeight", "fn/html/adjustSize", "fn/html/adjustWidth", "fn/ajax/ajax", "fn/misc/analyzeFunction", "fn/style/animateCss", "fn/convert/arrayBuffer2String", "fn/object/arrayFromProp", "fn/object/autoExtend", "fn/string/baseName", "fn/string/br2nl", "fn/datetime/calendar", "fn/ajax/callback", "fn/string/camelize", "fn/string/camelToCss", "fn/convert/canvasToImage", "fn/style/center", "fn/object/checkProps", "fn/object/checkPropsDetails", "fn/object/checkPropsOrDie", "fn/type/checkType", "fn/object/circularReplacer", "fn/object/clone", "fn/convert/colorToHex", "fn/object/compare", "fn/object/compareConditions", "fn/browser/copy", "fn/string/correctCase", "fn/object/count", "fn/string/crc32", "fn/object/createObject", "fn/style/cssExists", "fn/datetime/date", "fn/datetime/dateSQL", "fn/datetime/daysInMonth", "fn/object/deepPath", "fn/default/defaultAjaxAbortFunction", "fn/default/defaultAjaxErrorFunction", "fn/default/defaultAlertFunction", "fn/default/defaultConfirmFunction", "fn/default/defaultEndLoadingFunction", "fn/default/defaultErrorFunction", "fn/default/defaultHistoryFunction", "fn/default/defaultLinkFunction", "fn/default/defaultPostLinkFunction", "fn/default/defaultPreLinkFunction", "fn/default/defaultResizeFunction", "fn/default/defaultStartLoadingFunction", "fn/object/deleteProp", "fn/object/diffObj", "fn/string/dirName", "fn/ajax/download", "fn/ajax/downloadContent", "fn/loop/each", "fn/browser/eraseCookie", "fn/browser/error", "fn/string/escapeDquotes", "fn/string/escapeRegExp", "fn/string/escapeSquotes", "fn/string/escapeTicks", "fn/string/escapeUrl", "fn/object/extend", "fn/object/extendOut", "fn/datetime/fdate", "fn/datetime/fdatetime", "fn/form/fieldValue", "fn/string/fileExt", "fn/object/filter", "fn/object/filterToConditions", "fn/object/findAll", "fn/loop/fori", "fn/loop/forir", "fn/string/format", "fn/string/formatBytes", "fn/datetime/formatDate", "fn/string/formatSize", "fn/form/formdata", "fn/convert/fromXml", "fn/datetime/ftime", "fn/html/getAllTags", "fn/html/getAncestors", "fn/html/getAttributes", "fn/browser/getBrowserName", "fn/browser/getBrowserVersion", "fn/browser/getCookie", "fn/style/getCssVar", "fn/datetime/getDay", "fn/browser/getDeviceType", "fn/browser/getEventData", "fn/object/getField", "fn/object/getFieldValues", "fn/html/getHtml", "fn/html/getHTMLOfSelection", "fn/ajax/getLoader", "fn/html/getPath", "fn/object/getProp", "fn/object/getProperty", "fn/ajax/getRequestId", "fn/object/getRow", "fn/style/getScrollBarSize", "fn/html/getText", "fn/misc/getTimeoff", "fn/browser/happy", "fn/string/hash", "fn/convert/hex2rgb", "fn/browser/history", "fn/html/html2text", "fn/convert/imageToCanvas", "fn/convert/imgToBase64", "fn/browser/info", "fn/init", "fn/browser/isActiveInterface", "fn/type/isArray", "fn/type/isBlob", "fn/type/isBoolean", "fn/type/isCanvas", "fn/type/isColor", "fn/type/isComment", "fn/type/isCp", "fn/type/isDate", "fn/browser/isDesktopDevice", "fn/type/isDimension", "fn/type/isDom", "fn/type/isEmail", "fn/type/isEmpty", "fn/type/isEvent", "fn/browser/isFocused", "fn/type/isFunction", "fn/type/isHostname", "fn/html/isInside", "fn/type/isInt", "fn/type/isIP", "fn/type/isIterable", "fn/browser/isMobile", "fn/browser/isMobileDevice", "fn/type/isNull", "fn/type/isNumber", "fn/type/isObject", "fn/type/isPercent", "fn/type/isPrimitive", "fn/type/isPromise", "fn/type/isPropSize", "fn/type/isSame", "fn/type/isSQLDate", "fn/type/isString", "fn/type/isSymbol", "fn/browser/isTabletDevice", "fn/type/isURL", "fn/type/isValidDimension", "fn/type/isValidName", "fn/type/isValue", "fn/type/isVue", "fn/loop/iterate", "fn/style/lightenDarkenHex", "fn/ajax/link", "fn/browser/log", "fn/html/makeReactive", "fn/object/map", "fn/string/md5", "fn/misc/money", "fn/object/move", "fn/object/multiorder", "fn/string/nl2br", "fn/object/numProperties", "fn/form/objectToFormData", "fn/object/order", "fn/style/outerHeight", "fn/style/outerWidth", "fn/misc/percent", "fn/object/pickValue", "fn/ajax/post", "fn/ajax/postOut", "fn/string/printf", "fn/string/quotes2html", "fn/misc/randomInt", "fn/string/randomString", "fn/string/removeAccents", "fn/object/removeEmpty", "fn/string/removeExtraSpaces", "fn/string/removeHtmlComments", "fn/object/removePrivateProp", "fn/string/removeTrailingChars", "fn/string/repeat", "fn/string/replaceAll", "fn/browser/replaceSelection", "fn/style/resize", "fn/convert/rgb2hex", "fn/loop/riterate", "fn/misc/roundDecimal", "fn/string/sanitize", "fn/object/search", "fn/browser/selectElementText", "fn/html/selector", "fn/browser/setCookie", "fn/style/setCssVar", "fn/ajax/setNavigationVars", "fn/object/setProp", "fn/object/setProperty", "fn/string/shorten", "fn/object/shortenObj", "fn/object/shuffle", "fn/string/simpleHash", "fn/string/simpleHash1", "fn/string/simpleHash2", "fn/datetime/chrono", "fn/convert/string2ArrayBuffer", "fn/form/submit", "fn/string/substr", "fn/object/sum", "fn/datetime/timestamp", "fn/convert/toCSV", "fn/browser/toggleFullScreen", "fn/misc/translate", "fn/ajax/treatAjaxArguments", "fn/string/trim", "fn/string/uniqString", "fn/object/unique", "fn/ajax/upload", "fn/browser/warning"], function (require, exports, _addLoader_2, _compareValues_3, _deleteLoader_2, abort_1, abortURL_1, addColors_2, addInputs_2, addStyle_1, adjustHeight_1, adjustSize_3, adjustWidth_1, ajax_4, analyzeFunction_1, animateCss_1, arrayBuffer2String_1, arrayFromProp_1, autoExtend_1, baseName_3, br2nl_1, calendar_1, callback_3, camelize_1, camelToCss_1, canvasToImage_1, center_1, checkProps_1, checkPropsDetails_3, checkPropsOrDie_1, checkType_6, circularReplacer_2, clone_2, colorToHex_1, compare_2, compareConditions_3, copy_1, correctCase_2, count_1, crc32_1, createObject_4, cssExists_1, date_8, dateSQL_1, daysInMonth_1, deepPath_1, defaultAjaxAbortFunction_1, defaultAjaxErrorFunction_1, defaultAlertFunction_1, defaultConfirmFunction_1, defaultEndLoadingFunction_1, defaultErrorFunction_2, defaultHistoryFunction_2, defaultLinkFunction_1, defaultPostLinkFunction_1, defaultPreLinkFunction_1, defaultResizeFunction_2, defaultStartLoadingFunction_1, deleteProp_1, diffObj_1, dirName_2, download_1, downloadContent_2, each_28, eraseCookie_1, error_4, escapeDquotes_1, escapeRegExp_3, escapeSquotes_1, escapeTicks_1, escapeUrl_1, extend_8, extendOut_1, fdate_2, fdatetime_2, fieldValue_2, fileExt_2, filter_6, filterToConditions_3, findAll_1, fori_1, forir_1, format_1, formatBytes_1, formatDate_1, formatSize_1, formdata_2, fromXml_1, ftime_1, getAllTags_1, getAncestors_2, getAttributes_1, getBrowserName_1, getBrowserVersion_1, getCookie_1, getCssVar_2, getDay_1, getDeviceType_4, getEventData_1, getField_1, getFieldValues_1, getHtml_1, getHTMLOfSelection_2, getLoader_4, getPath_1, getProp_1, getProperty_4, getRequestId_2, getRow_3, getScrollBarSize_1, getText_1, getTimeoff_1, happy_1, hash_2, hex2rgb_1, history_1, html2text_2, imageToCanvas_2, imgToBase64_1, info_1, init_1, isActiveInterface_1, isArray_19, isBlob_2, isBoolean_1, isCanvas_2, isColor_1, isComment_1, isCp_3, isDate_8, isDesktopDevice_1, isDimension_1, isDom_5, isEmail_1, isEmpty_2, isEvent_1, isFocused_1, isFunction_11, isHostname_1, isInside_1, isInt_2, isIP_2, isIterable_5, isMobile_2, isMobileDevice_2, isNull_4, isNumber_10, isObject_18, isPercent_1, isPrimitive_1, isPromise_1, isPropSize_1, isSame_3, isSQLDate_1, isString_27, isSymbol_2, isTabletDevice_3, isURL_1, isValidDimension_2, isValidName_1, isValue_2, isVue_1, iterate_12, lightenDarkenHex_1, link_2, log_22, makeReactive_1, map_1, md5_4, money_1, move_1, multiorder_1, nl2br_1, numProperties_8, objectToFormData_2, order_1, outerHeight_1, outerWidth_1, percent_1, pickValue_1, post_2, postOut_1, printf_1, quotes2html_1, randomInt_2, randomString_1, removeAccents_4, removeEmpty_1, removeExtraSpaces_1, removeHtmlComments_2, removePrivateProp_2, removeTrailingChars_1, repeat_1, replaceAll_8, replaceSelection_1, resize_3, rgb2hex_1, riterate_1, roundDecimal_1, sanitize_1, search_6, selectElementText_1, selector_3, setCookie_1, setCssVar_1, setNavigationVars_2, setProp_1, setProperty_2, shorten_2, shortenObj_1, shuffle_1, simpleHash_2, simpleHash1_2, simpleHash2_2, chrono_1, string2ArrayBuffer_1, submit_2, substr_16, sum_1, timestamp_1, toCSV_1, toggleFullScreen_1, translate_1, treatAjaxArguments_3, trim_2, uniqString_1, unique_2, upload_1, warning_2) {
9803
+ define("fn", ["require", "exports", "fn/ajax/_addLoader", "fn/object/_compareValues", "fn/ajax/_deleteLoader", "fn/ajax/abort", "fn/ajax/abortURL", "fn/style/addColors", "fn/form/addInputs", "fn/style/addStyle", "fn/html/adjustHeight", "fn/html/adjustSize", "fn/html/adjustWidth", "fn/ajax/ajax", "fn/misc/analyzeFunction", "fn/style/animateCss", "fn/convert/arrayBuffer2String", "fn/object/arrayFromProp", "fn/object/autoExtend", "fn/string/baseName", "fn/string/br2nl", "fn/datetime/calendar", "fn/ajax/callback", "fn/string/camelize", "fn/string/camelToCss", "fn/convert/canvasToImage", "fn/style/center", "fn/object/checkProps", "fn/object/checkPropsDetails", "fn/object/checkPropsOrDie", "fn/type/checkType", "fn/object/circularReplacer", "fn/object/clone", "fn/convert/colorToHex", "fn/object/compare", "fn/object/compareConditions", "fn/browser/copy", "fn/string/correctCase", "fn/object/count", "fn/string/crc32", "fn/object/createObject", "fn/style/cssExists", "fn/datetime/date", "fn/datetime/dateSQL", "fn/datetime/daysInMonth", "fn/object/deepPath", "fn/default/defaultAjaxAbortFunction", "fn/default/defaultAjaxErrorFunction", "fn/default/defaultAlertFunction", "fn/default/defaultConfirmFunction", "fn/default/defaultEndLoadingFunction", "fn/default/defaultErrorFunction", "fn/default/defaultHistoryFunction", "fn/default/defaultLinkFunction", "fn/default/defaultPostLinkFunction", "fn/default/defaultPreLinkFunction", "fn/default/defaultResizeFunction", "fn/default/defaultStartLoadingFunction", "fn/object/deleteProp", "fn/object/diffObj", "fn/string/dirName", "fn/ajax/download", "fn/ajax/downloadContent", "fn/loop/each", "fn/browser/eraseCookie", "fn/browser/error", "fn/string/escapeDquotes", "fn/string/escapeRegExp", "fn/string/escapeSquotes", "fn/string/escapeTicks", "fn/string/escapeUrl", "fn/object/extend", "fn/object/extendOut", "fn/datetime/fdate", "fn/datetime/fdatetime", "fn/form/fieldValue", "fn/string/fileExt", "fn/object/filter", "fn/object/filterToConditions", "fn/object/findAll", "fn/loop/fori", "fn/loop/forir", "fn/string/format", "fn/string/formatBytes", "fn/datetime/formatDate", "fn/string/formatSize", "fn/form/formdata", "fn/convert/fromXml", "fn/datetime/ftime", "fn/html/getAllTags", "fn/html/getAncestors", "fn/html/getAttributes", "fn/browser/getBrowserName", "fn/browser/getBrowserVersion", "fn/browser/getCookie", "fn/style/getCssVar", "fn/datetime/getDay", "fn/browser/getDeviceType", "fn/browser/getEventData", "fn/object/getField", "fn/object/getFieldValues", "fn/html/getHtml", "fn/html/getHTMLOfSelection", "fn/ajax/getLoader", "fn/html/getPath", "fn/object/getProp", "fn/object/getProperty", "fn/ajax/getRequestId", "fn/object/getRow", "fn/style/getScrollBarSize", "fn/html/getText", "fn/misc/getTimeoff", "fn/browser/happy", "fn/string/hash", "fn/convert/hex2rgb", "fn/browser/history", "fn/html/html2text", "fn/convert/imageToCanvas", "fn/convert/imgToBase64", "fn/browser/info", "fn/init", "fn/browser/isActiveInterface", "fn/type/isArray", "fn/type/isBlob", "fn/type/isBoolean", "fn/type/isCanvas", "fn/type/isColor", "fn/type/isComment", "fn/type/isCp", "fn/type/isDate", "fn/browser/isDesktopDevice", "fn/type/isDimension", "fn/type/isDom", "fn/type/isEmail", "fn/type/isEmpty", "fn/type/isEvent", "fn/browser/isFocused", "fn/type/isFunction", "fn/type/isHostname", "fn/html/isInside", "fn/type/isInt", "fn/type/isIP", "fn/type/isIterable", "fn/browser/isMobile", "fn/browser/isMobileDevice", "fn/type/isNull", "fn/type/isNumber", "fn/type/isObject", "fn/type/isPercent", "fn/type/isPrimitive", "fn/type/isPromise", "fn/type/isPropSize", "fn/type/isSame", "fn/type/isSQLDate", "fn/type/isString", "fn/type/isSymbol", "fn/browser/isTabletDevice", "fn/type/isURL", "fn/type/isValidDimension", "fn/type/isValidName", "fn/type/isValue", "fn/type/isVue", "fn/loop/iterate", "fn/style/lightenDarkenHex", "fn/ajax/link", "fn/browser/log", "fn/html/makeReactive", "fn/object/map", "fn/string/md5", "fn/misc/money", "fn/object/move", "fn/object/multiorder", "fn/string/nl2br", "fn/object/numProperties", "fn/form/objectToFormData", "fn/object/order", "fn/style/outerHeight", "fn/style/outerWidth", "fn/misc/percent", "fn/object/pickValue", "fn/ajax/post", "fn/ajax/postOut", "fn/string/printf", "fn/string/quotes2html", "fn/misc/randomInt", "fn/string/randomString", "fn/string/removeAccents", "fn/object/removeEmpty", "fn/string/removeExtraSpaces", "fn/string/removeHtmlComments", "fn/object/removePrivateProp", "fn/string/removeTrailingChars", "fn/string/repeat", "fn/string/replaceAll", "fn/browser/replaceSelection", "fn/style/resize", "fn/convert/rgb2hex", "fn/loop/riterate", "fn/misc/roundDecimal", "fn/string/sanitize", "fn/object/search", "fn/browser/selectElementText", "fn/html/selector", "fn/browser/setCookie", "fn/style/setCssVar", "fn/ajax/setNavigationVars", "fn/object/setProp", "fn/object/setProperty", "fn/string/shorten", "fn/object/shortenObj", "fn/object/shuffle", "fn/string/simpleHash", "fn/string/simpleHash1", "fn/string/simpleHash2", "fn/datetime/chrono", "fn/convert/string2ArrayBuffer", "fn/form/submit", "fn/string/substr", "fn/object/sum", "fn/datetime/timestamp", "fn/convert/toCSV", "fn/browser/toggleFullScreen", "fn/misc/translate", "fn/ajax/treatAjaxArguments", "fn/string/trim", "fn/string/uniqString", "fn/object/unique", "fn/ajax/upload", "fn/browser/warning"], function (require, exports, _addLoader_2, _compareValues_3, _deleteLoader_2, abort_1, abortURL_1, addColors_2, addInputs_2, addStyle_1, adjustHeight_1, adjustSize_3, adjustWidth_1, ajax_4, analyzeFunction_1, animateCss_1, arrayBuffer2String_1, arrayFromProp_1, autoExtend_1, baseName_3, br2nl_1, calendar_1, callback_3, camelize_1, camelToCss_1, canvasToImage_1, center_1, checkProps_1, checkPropsDetails_3, checkPropsOrDie_1, checkType_6, circularReplacer_2, clone_2, colorToHex_1, compare_2, compareConditions_3, copy_1, correctCase_2, count_1, crc32_1, createObject_4, cssExists_1, date_8, dateSQL_1, daysInMonth_1, deepPath_1, defaultAjaxAbortFunction_1, defaultAjaxErrorFunction_1, defaultAlertFunction_1, defaultConfirmFunction_1, defaultEndLoadingFunction_1, defaultErrorFunction_1, defaultHistoryFunction_1, defaultLinkFunction_1, defaultPostLinkFunction_1, defaultPreLinkFunction_1, defaultResizeFunction_1, defaultStartLoadingFunction_1, deleteProp_1, diffObj_1, dirName_2, download_1, downloadContent_2, each_28, eraseCookie_1, error_4, escapeDquotes_1, escapeRegExp_3, escapeSquotes_1, escapeTicks_1, escapeUrl_1, extend_8, extendOut_1, fdate_2, fdatetime_2, fieldValue_2, fileExt_2, filter_6, filterToConditions_3, findAll_1, fori_1, forir_1, format_1, formatBytes_1, formatDate_1, formatSize_1, formdata_2, fromXml_1, ftime_1, getAllTags_1, getAncestors_2, getAttributes_1, getBrowserName_1, getBrowserVersion_1, getCookie_1, getCssVar_2, getDay_1, getDeviceType_4, getEventData_1, getField_1, getFieldValues_1, getHtml_1, getHTMLOfSelection_2, getLoader_4, getPath_1, getProp_1, getProperty_4, getRequestId_2, getRow_3, getScrollBarSize_1, getText_1, getTimeoff_1, happy_1, hash_2, hex2rgb_1, history_1, html2text_2, imageToCanvas_2, imgToBase64_1, info_1, init_1, isActiveInterface_1, isArray_19, isBlob_2, isBoolean_1, isCanvas_2, isColor_1, isComment_1, isCp_3, isDate_8, isDesktopDevice_1, isDimension_1, isDom_5, isEmail_1, isEmpty_2, isEvent_1, isFocused_1, isFunction_11, isHostname_1, isInside_1, isInt_2, isIP_2, isIterable_5, isMobile_2, isMobileDevice_2, isNull_4, isNumber_10, isObject_18, isPercent_1, isPrimitive_1, isPromise_1, isPropSize_1, isSame_3, isSQLDate_1, isString_27, isSymbol_2, isTabletDevice_3, isURL_1, isValidDimension_2, isValidName_1, isValue_2, isVue_1, iterate_12, lightenDarkenHex_1, link_2, log_22, makeReactive_1, map_1, md5_4, money_1, move_1, multiorder_1, nl2br_1, numProperties_8, objectToFormData_2, order_1, outerHeight_1, outerWidth_1, percent_1, pickValue_1, post_2, postOut_1, printf_1, quotes2html_1, randomInt_2, randomString_1, removeAccents_4, removeEmpty_1, removeExtraSpaces_1, removeHtmlComments_2, removePrivateProp_2, removeTrailingChars_1, repeat_1, replaceAll_8, replaceSelection_1, resize_3, rgb2hex_1, riterate_1, roundDecimal_1, sanitize_1, search_6, selectElementText_1, selector_3, setCookie_1, setCssVar_1, setNavigationVars_2, setProp_1, setProperty_2, shorten_2, shortenObj_1, shuffle_1, simpleHash_2, simpleHash1_2, simpleHash2_2, chrono_1, string2ArrayBuffer_1, submit_2, substr_16, sum_1, timestamp_1, toCSV_1, toggleFullScreen_1, translate_1, treatAjaxArguments_3, trim_2, uniqString_1, unique_2, upload_1, warning_2) {
9773
9804
  "use strict";
9774
9805
  Object.defineProperty(exports, "__esModule", { value: true });
9775
9806
  exports.fn = void 0;
@@ -9823,12 +9854,12 @@
9823
9854
  defaultAlertFunction: defaultAlertFunction_1.defaultAlertFunction,
9824
9855
  defaultConfirmFunction: defaultConfirmFunction_1.defaultConfirmFunction,
9825
9856
  defaultEndLoadingFunction: defaultEndLoadingFunction_1.defaultEndLoadingFunction,
9826
- defaultErrorFunction: defaultErrorFunction_2.defaultErrorFunction,
9827
- defaultHistoryFunction: defaultHistoryFunction_2.defaultHistoryFunction,
9857
+ defaultErrorFunction: defaultErrorFunction_1.defaultErrorFunction,
9858
+ defaultHistoryFunction: defaultHistoryFunction_1.defaultHistoryFunction,
9828
9859
  defaultLinkFunction: defaultLinkFunction_1.defaultLinkFunction,
9829
9860
  defaultPostLinkFunction: defaultPostLinkFunction_1.defaultPostLinkFunction,
9830
9861
  defaultPreLinkFunction: defaultPreLinkFunction_1.defaultPreLinkFunction,
9831
- defaultResizeFunction: defaultResizeFunction_2.defaultResizeFunction,
9862
+ defaultResizeFunction: defaultResizeFunction_1.defaultResizeFunction,
9832
9863
  defaultStartLoadingFunction: defaultStartLoadingFunction_1.defaultStartLoadingFunction,
9833
9864
  deleteProp: deleteProp_1.deleteProp,
9834
9865
  diffObj: diffObj_1.diffObj,
@@ -1,6 +1,5 @@
1
1
  import { getHTMLOfSelection } from '../html/getHTMLOfSelection';
2
2
  import { each } from '../loop/each';
3
- import { defaultErrorFunction } from '../default/defaultErrorFunction';
4
3
  /**
5
4
  * Returns a promise having the event's data as argument.
6
5
  * @method getEventData
@@ -81,7 +80,7 @@ const getEventData = function (e) {
81
80
  }
82
81
  }
83
82
  else {
84
- defaultErrorFunction(bbn._('Impossible to read the file') + ' ' + name);
83
+ bbn.fn.defaultErrorFunction(bbn._('Impossible to read the file') + ' ' + name);
85
84
  }
86
85
  }
87
86
  else {
package/dist/fn/init.js CHANGED
@@ -1,15 +1,14 @@
1
- import { substr } from './string/substr';
2
- import { each } from './loop/each';
3
- import { extend } from './object/extend';
4
- import { addColors } from './style/addColors';
5
- import { link } from './ajax/link';
6
- import { submit } from './form/submit';
7
- import { resize } from './style/resize';
8
- import { isMobile } from './browser/isMobile';
9
- import { isTabletDevice } from './browser/isTabletDevice';
10
- import { defaultHistoryFunction } from './default/defaultHistoryFunction';
11
- import { isFunction } from './type/isFunction';
12
- import { log } from './browser/log';
1
+ import { substr } from "./string/substr";
2
+ import { each } from "./loop/each";
3
+ import { extend } from "./object/extend";
4
+ import { addColors } from "./style/addColors";
5
+ import { link } from "./ajax/link";
6
+ import { submit } from "./form/submit";
7
+ import { resize } from "./style/resize";
8
+ import { isMobile } from "./browser/isMobile";
9
+ import { isTabletDevice } from "./browser/isTabletDevice";
10
+ import { isFunction } from "./type/isFunction";
11
+ import { log } from "./browser/log";
13
12
  /**
14
13
  * Initializes the library bbn basing on the given configuration object.
15
14
  * - Gives to the environment the dimension of the window.innerWidth and window.innerHeight
@@ -26,61 +25,62 @@ import { log } from './browser/log';
26
25
  const init = function (cfg, force) {
27
26
  let parts;
28
27
  if (!bbn.env.isInit || force) {
29
- bbn.env.root = document.baseURI.length > 0 ? document.baseURI : bbn.env.host;
30
- if (bbn.env.root.length && substr(bbn.env.root, -1) !== '/') {
31
- bbn.env.root += '/';
28
+ bbn.env.root =
29
+ document.baseURI.length > 0 ? document.baseURI : bbn.env.host;
30
+ if (bbn.env.root.length && substr(bbn.env.root, -1) !== "/") {
31
+ bbn.env.root += "/";
32
32
  }
33
- if (!bbn.env.isInit && typeof dayjs !== 'undefined') {
33
+ if (!bbn.env.isInit && typeof dayjs !== "undefined") {
34
34
  each([
35
- 'advancedFormat',
36
- 'arraySupport',
37
- 'badMutable',
38
- 'buddhistEra',
39
- 'calendar',
40
- 'customParseFormat',
41
- 'dayOfYear',
42
- 'devHelper',
43
- 'duration',
44
- 'isBetween',
45
- 'isLeapYear',
46
- 'isSameOrAfter',
47
- 'isSameOrBefore',
48
- 'isToday',
49
- 'isTomorrow',
50
- 'isYesterday',
51
- 'isoWeek',
52
- 'isoWeeksInYear',
53
- 'localeData',
54
- 'localizedFormat',
55
- 'minMax',
56
- 'objectSupport',
57
- 'pluralGetSet',
58
- 'quarterOfYear',
59
- 'relativeTime',
60
- 'timezone',
61
- 'toArray',
62
- 'toObject',
63
- 'updateLocale',
64
- 'utc',
65
- 'weekOfYear',
66
- 'weekYear',
67
- 'weekday',
35
+ "advancedFormat",
36
+ "arraySupport",
37
+ "badMutable",
38
+ "buddhistEra",
39
+ "calendar",
40
+ "customParseFormat",
41
+ "dayOfYear",
42
+ "devHelper",
43
+ "duration",
44
+ "isBetween",
45
+ "isLeapYear",
46
+ "isSameOrAfter",
47
+ "isSameOrBefore",
48
+ "isToday",
49
+ "isTomorrow",
50
+ "isYesterday",
51
+ "isoWeek",
52
+ "isoWeeksInYear",
53
+ "localeData",
54
+ "localizedFormat",
55
+ "minMax",
56
+ "objectSupport",
57
+ "pluralGetSet",
58
+ "quarterOfYear",
59
+ "relativeTime",
60
+ "timezone",
61
+ "toArray",
62
+ "toObject",
63
+ "updateLocale",
64
+ "utc",
65
+ "weekOfYear",
66
+ "weekYear",
67
+ "weekday",
68
68
  ], (plugin) => {
69
- if (window['dayjs_plugin_' + plugin]) {
70
- dayjs.extend(window['dayjs_plugin_' + plugin]);
69
+ if (window["dayjs_plugin_" + plugin]) {
70
+ dayjs.extend(window["dayjs_plugin_" + plugin]);
71
71
  }
72
72
  });
73
73
  }
74
74
  /* The server's path (difference between the host and the current dir */
75
- if (typeof cfg === 'object') {
75
+ if (typeof cfg === "object") {
76
76
  extend(true, bbn, cfg);
77
77
  }
78
78
  bbn.env.path = substr(bbn.env.url, bbn.env.root.length);
79
- parts = bbn.env.path.split('/');
79
+ parts = bbn.env.path.split("/");
80
80
  //$.each(parts, function(i, v){
81
81
  each(parts, (v, i) => {
82
82
  v = decodeURI(v.trim());
83
- if (v !== '') {
83
+ if (v !== "") {
84
84
  bbn.env.params.push(v);
85
85
  }
86
86
  });
@@ -97,59 +97,63 @@ const init = function (cfg, force) {
97
97
  bbn.env.isFocused = false;
98
98
  bbn.env.timeoff = Math.round(new Date().getTime() / 1000);
99
99
  };
100
- document.addEventListener('focusin', (e) => {
101
- if (e.target instanceof HTMLElement && !e.target.classList.contains('bbn-no')) {
100
+ document.addEventListener("focusin", (e) => {
101
+ if (e.target instanceof HTMLElement &&
102
+ !e.target.classList.contains("bbn-no")) {
102
103
  bbn.env.focused = e.target;
103
104
  }
104
105
  bbn.env.last_focus = new Date().getTime();
105
106
  });
106
- document.addEventListener('click', (e) => {
107
+ document.addEventListener("click", (e) => {
107
108
  bbn.env.last_focus = new Date().getTime();
108
- if (bbn.env.nav !== 'ajax') {
109
+ if (bbn.env.nav !== "ajax") {
109
110
  return;
110
111
  }
111
112
  let target = e.target;
112
- if (target instanceof HTMLElement && (target.tagName !== 'A')) {
113
+ if (target instanceof HTMLElement && target.tagName !== "A") {
113
114
  let p = target;
114
- while (p && p.tagName !== 'A') {
115
- if (p.tagName === 'BODY') {
115
+ while (p && p.tagName !== "A") {
116
+ if (p.tagName === "BODY") {
116
117
  break;
117
118
  }
118
119
  p = p.parentElement;
119
120
  }
120
- if (p && p.tagName === 'A') {
121
+ if (p && p.tagName === "A") {
121
122
  target = p;
122
123
  }
123
124
  else {
124
125
  target = null;
125
126
  }
126
127
  }
127
- if (target instanceof HTMLElement && target.hasAttribute('href') && !target.hasAttribute('target') && !target.classList.contains('bbn-no')) {
128
+ if (target instanceof HTMLElement &&
129
+ target.hasAttribute("href") &&
130
+ !target.hasAttribute("target") &&
131
+ !target.classList.contains("bbn-no")) {
128
132
  e.preventDefault();
129
133
  e.stopPropagation();
130
- link(target.getAttribute('href'));
134
+ link(target.getAttribute("href"));
131
135
  return false;
132
136
  }
133
137
  });
134
- each(document.querySelectorAll('form:not(.bbn-no), form:not(.bbn-form)'), (ele) => {
135
- ele.addEventListener('submit', (e) => {
138
+ each(document.querySelectorAll("form:not(.bbn-no), form:not(.bbn-form)"), (ele) => {
139
+ ele.addEventListener("submit", (e) => {
136
140
  submit(ele, e);
137
141
  });
138
142
  });
139
- window.addEventListener('hashchange', () => {
143
+ window.addEventListener("hashchange", () => {
140
144
  bbn.env.hashChanged = new Date().getTime();
141
145
  }, false);
142
- window.addEventListener('resize', () => {
146
+ window.addEventListener("resize", () => {
143
147
  resize();
144
148
  });
145
- window.addEventListener('orientationchange', () => {
149
+ window.addEventListener("orientationchange", () => {
146
150
  resize();
147
151
  });
148
152
  resize();
149
153
  if (isMobile()) {
150
- document.body.classList.add('bbn-mobile');
154
+ document.body.classList.add("bbn-mobile");
151
155
  if (isTabletDevice()) {
152
- document.body.classList.add('bbn-tablet');
156
+ document.body.classList.add("bbn-tablet");
153
157
  }
154
158
  }
155
159
  if (window.history) {
@@ -157,9 +161,9 @@ const init = function (cfg, force) {
157
161
  let h = window.history;
158
162
  if (!bbn.env.historyDisabled && h) {
159
163
  //e.preventDefault();
160
- let state = h.state;
161
- if (state) {
162
- if (defaultHistoryFunction(state)) {
164
+ if (bbn.fn.defaultHistoryFunction(h.state)) {
165
+ let state = h.state;
166
+ if (state) {
163
167
  //link(substr(state.url, bbn.env.root.length), $.extend({title: state.title}, state.data));
164
168
  link(state.url, extend({ title: state.title || bbn.env.siteTitle }, state.data || {}));
165
169
  }
@@ -171,9 +175,9 @@ const init = function (cfg, force) {
171
175
  };
172
176
  }
173
177
  bbn.env.isInit = true;
174
- document.dispatchEvent(new Event('bbninit'));
178
+ document.dispatchEvent(new Event("bbninit"));
175
179
  if (bbn.env.logging) {
176
- log('Logging in bbn is enabled');
180
+ log("Logging in bbn is enabled");
177
181
  }
178
182
  }
179
183
  };
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Analyzes the given function and extracts details about its structure.
3
+ *
4
+ * @function analyzeFunction
5
+ * @param {Function} fn - The function to analyze.
6
+ * @returns {Object} An object containing details about the function.
7
+ * @throws {Error} When unexpected syntax is encountered while parsing.
8
+ */
1
9
  declare const analyzeFunction: (fn: any) => {
2
10
  body: any;
3
11
  args: any[];
@@ -1,7 +1,17 @@
1
1
  import { md5 } from '../string/md5';
2
+ /**
3
+ * Analyzes the given function and extracts details about its structure.
4
+ *
5
+ * @function analyzeFunction
6
+ * @param {Function} fn - The function to analyze.
7
+ * @returns {Object} An object containing details about the function.
8
+ * @throws {Error} When unexpected syntax is encountered while parsing.
9
+ */
2
10
  const analyzeFunction = function (fn) {
3
- const functionString = fn.toString();
4
- let all = functionString.split('');
11
+ const all = typeof fn === 'function' ? fn.toString() : fn;
12
+ if (typeof all !== 'string') {
13
+ throw Error('Unexpected type ' + typeof fn + ' while parsing function');
14
+ }
5
15
  let exp = '';
6
16
  let isArrow = false;
7
17
  let isAsync = false;
@@ -16,12 +26,33 @@ const analyzeFunction = function (fn) {
16
26
  let escapable = ['"', "'", '`'];
17
27
  let isEscaped = false;
18
28
  let settingDefault = false;
29
+ let isComment = false;
30
+ let isCommentLine = false;
19
31
  for (let i = 0; i < all.length; i++) {
20
- if (all[i] === currentQuote && !isEscaped && currentQuote) {
32
+ // Handle string literals
33
+ if (!isComment && all[i] === '/' && all[i + 1] === '*') {
34
+ isComment = true;
35
+ exp = '';
36
+ }
37
+ else if (all[i] === '*' && all[i + 1] === '/') {
38
+ isComment = false;
39
+ }
40
+ else if (!isCommentLine && all[i] === '/' && all[i + 1] === '/') {
41
+ isCommentLine = true;
42
+ exp = '';
43
+ }
44
+ else if (all[i] === '\n') {
45
+ isCommentLine = false;
46
+ }
47
+ else if (isComment || isCommentLine) {
48
+ continue;
49
+ }
50
+ else if (all[i] === currentQuote && !isEscaped && currentQuote) {
21
51
  currentQuote = '';
22
52
  exp += all[i];
23
53
  }
24
54
  else if (currentQuote) {
55
+ isEscaped = all[i] === '\\' && !isEscaped;
25
56
  exp += all[i];
26
57
  }
27
58
  else if (escapable.includes(all[i]) && !isEscaped) {
@@ -43,13 +74,13 @@ const analyzeFunction = function (fn) {
43
74
  else if (all[i] === ')') {
44
75
  if (parOpened === parClosed + 1) {
45
76
  if (settingDefault) {
46
- currentArg.default = exp.trim();
77
+ currentArg['default'] = exp.trim();
47
78
  settingDefault = false;
48
79
  }
49
80
  else if (exp) {
50
- currentArg.name = exp.trim();
81
+ currentArg['name'] = exp.trim();
51
82
  }
52
- if (currentArg.name || currentArg.default) {
83
+ if (currentArg['name'] || currentArg['default']) {
53
84
  args.push(currentArg);
54
85
  currentArg = {};
55
86
  }
@@ -57,37 +88,32 @@ const analyzeFunction = function (fn) {
57
88
  }
58
89
  parClosed++;
59
90
  }
60
- else if (all[i] === '=') {
61
- if (functionString.substr(i, 2) === '=>') {
62
- if (exp.trim() !== '' && parOpened === parClosed) {
63
- currentArg.name = exp.trim();
64
- args.push(currentArg);
65
- currentArg = {};
66
- exp = '';
67
- }
68
- isArrow = true;
69
- i++;
70
- continue;
71
- }
72
- else if (parOpened > parClosed && !settingDefault) {
73
- currentArg.name = exp.trim();
91
+ else if (all[i] === '=' && all[i + 1] === '>') {
92
+ if (exp.trim() !== '' && parOpened === parClosed) {
93
+ currentArg['name'] = exp.trim();
94
+ args.push(currentArg);
95
+ currentArg = {};
74
96
  exp = '';
75
- settingDefault = true;
76
- }
77
- else {
78
- exp += all[i];
79
97
  }
98
+ isArrow = true;
99
+ i++;
100
+ continue;
101
+ }
102
+ else if (all[i] === '=' && parOpened > parClosed && !settingDefault) {
103
+ currentArg['name'] = exp.trim();
104
+ exp = '';
105
+ settingDefault = true;
80
106
  }
81
107
  else if (all[i] === ',') {
82
108
  if (parOpened > parClosed) {
83
109
  if (settingDefault) {
84
- currentArg.default = exp.trim();
110
+ currentArg['default'] = exp.trim();
85
111
  settingDefault = false;
86
112
  }
87
113
  else if (exp) {
88
- currentArg.name = exp.trim();
114
+ currentArg['name'] = exp.trim();
89
115
  }
90
- if (currentArg.name || currentArg.default) {
116
+ if (currentArg['name'] || currentArg['default']) {
91
117
  args.push(currentArg);
92
118
  currentArg = {};
93
119
  }
@@ -98,11 +124,11 @@ const analyzeFunction = function (fn) {
98
124
  }
99
125
  }
100
126
  else if (all[i] === '{' || all[i] === '}') {
101
- body = functionString.substring(i).trim();
127
+ body = all.substring(i).trim();
102
128
  break;
103
129
  }
104
130
  else if (isArrow) {
105
- body = functionString.substring(functionString.indexOf('=>') + 2).trim();
131
+ body = all.substring(all.indexOf('=>') + 2).trim();
106
132
  break;
107
133
  }
108
134
  else if (all[i] === ' ') {
@@ -1,6 +1,5 @@
1
1
  import { getCssVar } from './getCssVar';
2
2
  import { each } from '../loop/each';
3
- import { defaultResizeFunction } from '../default/defaultResizeFunction';
4
3
  const resize = function () {
5
4
  let diffW = bbn.env.width !== window.innerWidth;
6
5
  let diffH = bbn.env.height !== window.innerHeight;
@@ -32,8 +31,8 @@ const resize = function () {
32
31
  if (!done) {
33
32
  classes.push(newCls);
34
33
  }
34
+ bbn.fn.defaultResizeFunction();
35
35
  document.body.className = classes.join(' ');
36
- defaultResizeFunction();
37
36
  }
38
37
  };
39
38
  export { resize };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.86",
3
+ "version": "1.0.88",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,6 +18,7 @@
18
18
  "author": "Thomas Nabet <thomas.nabet@gmail.com>",
19
19
  "license": "MIT",
20
20
  "devDependencies": {
21
+ "mocha": "^10.2.0",
21
22
  "typescript": "^5.2.2"
22
23
  },
23
24
  "bugs": {
@@ -26,7 +27,9 @@
26
27
  "homepage": "https://github.com/nabab/bbn-js#readme",
27
28
  "dependencies": {
28
29
  "axios": "^1.5.1",
30
+ "chai": "^4.3.10",
29
31
  "dayjs": "^1.11.10",
32
+ "jsdom-global": "^3.0.2",
30
33
  "typescript-bundle": "^1.0.18"
31
34
  },
32
35
  "directories": {