@infinite-table/infinite-react 3.0.12 → 3.0.14

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/index.d.ts CHANGED
@@ -511,7 +511,7 @@ declare type InfiniteTableComputedColumn<T> = InfiniteTableColumn<T> & InfiniteT
511
511
  declare type InfiniteTableComputedPivotFinalColumn<T> = InfiniteTableComputedColumn<T> & InfiniteTablePivotFinalColumn<T>;
512
512
 
513
513
  interface LogFn {
514
- (...args: any[]): LogFn;
514
+ (...args: any[]): void;
515
515
  extend: (channelName: string) => LogFn;
516
516
  }
517
517
  declare class Logger {
@@ -3007,7 +3007,21 @@ declare type InterceptedMapFns<K, V> = {
3007
3007
  */
3008
3008
  declare function interceptMap<K, V>(map: Map<K, V>, fns: InterceptedMapFns<K, V>): () => void;
3009
3009
 
3010
- declare function debug(channelName: string): any;
3010
+ declare type DebugLogger = {
3011
+ (...args: any[]): void;
3012
+ extend: (channelName: string) => DebugLogger;
3013
+ enabled: boolean;
3014
+ channel: string;
3015
+ destroy: () => void;
3016
+ log: (...args: any[]) => void;
3017
+ };
3018
+ declare const debug: {
3019
+ (channelName: string): DebugLogger;
3020
+ colors: string[];
3021
+ enable: string;
3022
+ diffenable: string | boolean;
3023
+ log: DebugLogger['log'];
3024
+ };
3011
3025
 
3012
3026
  declare function useEffectWithChanges<T>(fn: (changes: Record<keyof T, any>, prevValues: Record<string, any>) => void | (() => void), deps: Record<keyof T, any>): void;
3013
3027
 
package/index.dev.js CHANGED
@@ -631,7 +631,7 @@ function getGlobal() {
631
631
  }
632
632
 
633
633
  // src/utils/debugPackage.ts
634
- var colors = [
634
+ var COLORS = [
635
635
  "#0000CC",
636
636
  "#0000FF",
637
637
  "#0033CC",
@@ -709,64 +709,114 @@ var colors = [
709
709
  "#FFCC00",
710
710
  "#FFCC33"
711
711
  ];
712
- var usedColors = colors.map((_) => 0);
713
- var getNextColor = () => {
712
+ var USED_COLORS_MAP = /* @__PURE__ */ new WeakMap();
713
+ USED_COLORS_MAP.set(
714
+ COLORS,
715
+ COLORS.map((_) => 0)
716
+ );
717
+ var getNextColor = (colors = COLORS) => {
718
+ var _a, _b;
719
+ let usedColors = [];
720
+ if (USED_COLORS_MAP.has(colors)) {
721
+ usedColors = USED_COLORS_MAP.get(colors);
722
+ } else {
723
+ usedColors = colors.map((_) => 0);
724
+ USED_COLORS_MAP.set(colors, usedColors);
725
+ }
714
726
  const index = usedColors.reduce(
715
727
  (iMin, x, i, arr) => x < arr[iMin] ? i : iMin,
716
728
  0
717
729
  );
718
- usedColors[index]++;
719
- return colors[index];
730
+ if (usedColors[index] != void 0) {
731
+ usedColors[index]++;
732
+ }
733
+ return (_b = (_a = colors[index]) != null ? _a : colors[0]) != null ? _b : COLORS[0];
720
734
  };
721
735
  var CHANNEL_SEPARATOR = ":";
722
736
  var CHANNEL_WILDCARD = "*";
737
+ var CHANNEL_NEGATION_CHAR = "-";
723
738
  var STORAGE_SEPARATOR = ",";
724
739
  var STORAGE_KEY = "debug";
725
740
  var STORAGE_DIFF_KEY = "diffdebug";
726
741
  var DEFAULT_LOG_DIFF = false;
727
- function debug(channelName) {
728
- const loggers = new DeepMap();
729
- const defaultLogger = console.log.bind(console);
730
- const getStorageKeyValue = () => {
731
- var _a, _b;
732
- return (_b = getGlobal() && ((_a = getGlobal().localStorage) == null ? void 0 : _a.getItem(STORAGE_KEY))) != null ? _b : "";
733
- };
734
- const getDiffStorageKeyValue = () => {
735
- var _a, _b;
736
- return (_b = getGlobal() && ((_a = getGlobal().localStorage) == null ? void 0 : _a.getItem(STORAGE_DIFF_KEY))) != null ? _b : `${DEFAULT_LOG_DIFF}`;
737
- };
738
- let storageKeyValue = "";
739
- let logDiffs = DEFAULT_LOG_DIFF;
740
- function updateStorageKeyValue(value) {
741
- logDiffs = getDiffStorageKeyValue() === "true";
742
- if (storageKeyValue === value) {
743
- return;
742
+ var loggers = new DeepMap();
743
+ var enabledChannelsCache = /* @__PURE__ */ new Map();
744
+ function isChannelTargeted(channel, permissionToken) {
745
+ const parts = channel.split(CHANNEL_SEPARATOR);
746
+ const partsMap = new DeepMap();
747
+ partsMap.set(parts, true);
748
+ const tokenParts = permissionToken.split(CHANNEL_SEPARATOR);
749
+ const hasWildcard = new Set(tokenParts).has(CHANNEL_WILDCARD);
750
+ const storagePartsWithoutWildcard = hasWildcard ? tokenParts.slice(0, tokenParts.indexOf(CHANNEL_WILDCARD)) : tokenParts;
751
+ if (partsMap.getKeysStartingWith(storagePartsWithoutWildcard, hasWildcard).length > 0) {
752
+ return true;
753
+ }
754
+ return void 0;
755
+ }
756
+ function isLoggingEnabled(channel, permissions) {
757
+ const cacheKey = `channel=${channel}_permissions=${permissions}`;
758
+ if (enabledChannelsCache.has(cacheKey)) {
759
+ return enabledChannelsCache.get(cacheKey);
760
+ }
761
+ const permissionTokens = permissions.split(STORAGE_SEPARATOR);
762
+ function done(result) {
763
+ enabledChannelsCache.set(cacheKey, result);
764
+ return result;
765
+ }
766
+ const exactTokens = [];
767
+ const wildcardTokens = [];
768
+ permissionTokens.forEach((permissionToken) => {
769
+ if (permissionToken.includes(CHANNEL_WILDCARD)) {
770
+ wildcardTokens.push(permissionToken);
771
+ } else {
772
+ exactTokens.push(permissionToken);
773
+ }
774
+ });
775
+ for (let i = 0; i < exactTokens.length; i++) {
776
+ let exactToken = exactTokens[i];
777
+ const negative = exactToken.startsWith(CHANNEL_NEGATION_CHAR);
778
+ if (negative) {
779
+ exactToken = exactToken.substring(CHANNEL_NEGATION_CHAR.length);
780
+ }
781
+ if (isChannelTargeted(channel, exactToken)) {
782
+ return done(negative ? false : true);
744
783
  }
745
- storageKeyValue = value;
746
784
  }
785
+ for (let i = 0; i < wildcardTokens.length; i++) {
786
+ let permissionToken = wildcardTokens[i];
787
+ const negated = permissionToken.startsWith("-");
788
+ if (negated) {
789
+ permissionToken = permissionToken.substring(1);
790
+ }
791
+ if (isChannelTargeted(channel, permissionToken)) {
792
+ return done(negated ? false : true);
793
+ }
794
+ }
795
+ return done(false);
796
+ }
797
+ var getStorageKeyValue = () => {
798
+ var _a, _b, _c;
799
+ return (_c = (_b = debug.enable) != null ? _b : getGlobal() && ((_a = getGlobal().localStorage) == null ? void 0 : _a.getItem(STORAGE_KEY))) != null ? _c : "";
800
+ };
801
+ var getDiffStorageKeyValue = () => {
802
+ var _a, _b, _c;
803
+ return (_c = (_b = debug.diffenable) != null ? _b : getGlobal() && ((_a = getGlobal().localStorage) == null ? void 0 : _a.getItem(STORAGE_DIFF_KEY))) != null ? _c : `${DEFAULT_LOG_DIFF}`;
804
+ };
805
+ var storageKeyValue = "";
806
+ var logDiffs = DEFAULT_LOG_DIFF;
807
+ function updateStorageKeyValue(value) {
808
+ logDiffs = `${getDiffStorageKeyValue()}` == "true";
809
+ if (storageKeyValue === value) {
810
+ return;
811
+ }
812
+ storageKeyValue = value;
813
+ enabledChannelsCache.clear();
814
+ }
815
+ function debugPackage(channelName) {
747
816
  updateStorageKeyValue(getStorageKeyValue());
748
817
  typeof getGlobal() !== "undefined" && getGlobal().addEventListener && getGlobal().addEventListener("storage", function() {
749
818
  updateStorageKeyValue(getStorageKeyValue());
750
819
  });
751
- function isLoggingEnabled(channel) {
752
- const parts = channel.split(CHANNEL_SEPARATOR);
753
- const partsMap = new DeepMap();
754
- partsMap.set(parts, true);
755
- const multipleStorageValues = storageKeyValue.split(STORAGE_SEPARATOR);
756
- for (let i = 0; i < multipleStorageValues.length; i++) {
757
- const storageValue = multipleStorageValues[i];
758
- const storageValueParts = storageValue.split(CHANNEL_SEPARATOR);
759
- const hasWildcard = new Set(storageValueParts).has(CHANNEL_WILDCARD);
760
- const storagePartsWithoutWildcard = hasWildcard ? storageValueParts.slice(
761
- 0,
762
- storageValueParts.indexOf(CHANNEL_WILDCARD)
763
- ) : storageValueParts;
764
- if (partsMap.getKeysStartingWith(storagePartsWithoutWildcard, hasWildcard).length > 0) {
765
- return true;
766
- }
767
- }
768
- return false;
769
- }
770
820
  function debugFactory(channelName2, parentChannel) {
771
821
  const channel = parentChannel ? `${parentChannel}${CHANNEL_SEPARATOR}${channelName2}` : channelName2;
772
822
  const channelParts = channel.split(CHANNEL_SEPARATOR);
@@ -774,18 +824,18 @@ function debug(channelName) {
774
824
  return loggers.get(channelParts);
775
825
  }
776
826
  const parentLogger = loggers.get(channelParts.slice(0, -1));
777
- let logFn = parentLogger ? parentLogger.log : defaultLogger;
827
+ let logFn = parentLogger ? parentLogger.log : debug.log;
778
828
  let enabled;
779
829
  let lastMessageTimestamp = 0;
780
- const isEnabled = () => enabled != null ? enabled : isLoggingEnabled(channel);
781
- const color = getNextColor();
830
+ const isEnabled = () => enabled != null ? enabled : isLoggingEnabled(channel, storageKeyValue);
831
+ const color = getNextColor(debug.colors);
782
832
  const logger = Object.defineProperties(
783
833
  (...args) => {
784
- if (isLoggingEnabled(channel)) {
834
+ if (isLoggingEnabled(channel, storageKeyValue)) {
785
835
  const now = Date.now();
786
836
  if (lastMessageTimestamp && logDiffs) {
787
837
  const diff = now - lastMessageTimestamp;
788
- logFn(`%c+${diff}ms:`, `color: ${color}`);
838
+ logFn(`%c[${channel}]`, `color: ${color}`, `+${diff}ms:`);
789
839
  }
790
840
  lastMessageTimestamp = now;
791
841
  logFn(`%c[${channel}]`, `color: ${color}`, ...args);
@@ -808,6 +858,11 @@ function debug(channelName) {
808
858
  set: (fn) => {
809
859
  logFn = fn;
810
860
  }
861
+ },
862
+ destroy: {
863
+ value: () => {
864
+ loggers.delete(channelParts);
865
+ }
811
866
  }
812
867
  }
813
868
  );
@@ -816,6 +871,18 @@ function debug(channelName) {
816
871
  }
817
872
  return debugFactory(channelName);
818
873
  }
874
+ var defaultLogger = console.log.bind(console);
875
+ var GLOBAL_ENABLE = void 0;
876
+ Object.defineProperty(debugPackage, "enable", {
877
+ get: () => GLOBAL_ENABLE,
878
+ set: (value) => {
879
+ GLOBAL_ENABLE = value;
880
+ updateStorageKeyValue(getStorageKeyValue());
881
+ }
882
+ });
883
+ var debug = debugPackage;
884
+ debug.colors = COLORS;
885
+ debug.log = defaultLogger;
819
886
 
820
887
  // src/utils/debug.ts
821
888
  var debugTable = debug(`InfiniteTable`);
@@ -17150,7 +17217,7 @@ var useLicense = (licenseKey = "") => {
17150
17217
  const valid = (0, import_react50.useMemo)(() => {
17151
17218
  let valid2 = isValidLicense(licenseKey, {
17152
17219
  publishedAt: 1624970570587,
17153
- version: "3.0.12"
17220
+ version: "3.0.14"
17154
17221
  });
17155
17222
  if (!licenseKey && !valid2 && isInsidePlayground) {
17156
17223
  return true;
package/index.dev.mjs CHANGED
@@ -589,7 +589,7 @@ function getGlobal() {
589
589
  }
590
590
 
591
591
  // src/utils/debugPackage.ts
592
- var colors = [
592
+ var COLORS = [
593
593
  "#0000CC",
594
594
  "#0000FF",
595
595
  "#0033CC",
@@ -667,64 +667,114 @@ var colors = [
667
667
  "#FFCC00",
668
668
  "#FFCC33"
669
669
  ];
670
- var usedColors = colors.map((_) => 0);
671
- var getNextColor = () => {
670
+ var USED_COLORS_MAP = /* @__PURE__ */ new WeakMap();
671
+ USED_COLORS_MAP.set(
672
+ COLORS,
673
+ COLORS.map((_) => 0)
674
+ );
675
+ var getNextColor = (colors = COLORS) => {
676
+ var _a, _b;
677
+ let usedColors = [];
678
+ if (USED_COLORS_MAP.has(colors)) {
679
+ usedColors = USED_COLORS_MAP.get(colors);
680
+ } else {
681
+ usedColors = colors.map((_) => 0);
682
+ USED_COLORS_MAP.set(colors, usedColors);
683
+ }
672
684
  const index = usedColors.reduce(
673
685
  (iMin, x, i, arr) => x < arr[iMin] ? i : iMin,
674
686
  0
675
687
  );
676
- usedColors[index]++;
677
- return colors[index];
688
+ if (usedColors[index] != void 0) {
689
+ usedColors[index]++;
690
+ }
691
+ return (_b = (_a = colors[index]) != null ? _a : colors[0]) != null ? _b : COLORS[0];
678
692
  };
679
693
  var CHANNEL_SEPARATOR = ":";
680
694
  var CHANNEL_WILDCARD = "*";
695
+ var CHANNEL_NEGATION_CHAR = "-";
681
696
  var STORAGE_SEPARATOR = ",";
682
697
  var STORAGE_KEY = "debug";
683
698
  var STORAGE_DIFF_KEY = "diffdebug";
684
699
  var DEFAULT_LOG_DIFF = false;
685
- function debug(channelName) {
686
- const loggers = new DeepMap();
687
- const defaultLogger = console.log.bind(console);
688
- const getStorageKeyValue = () => {
689
- var _a, _b;
690
- return (_b = getGlobal() && ((_a = getGlobal().localStorage) == null ? void 0 : _a.getItem(STORAGE_KEY))) != null ? _b : "";
691
- };
692
- const getDiffStorageKeyValue = () => {
693
- var _a, _b;
694
- return (_b = getGlobal() && ((_a = getGlobal().localStorage) == null ? void 0 : _a.getItem(STORAGE_DIFF_KEY))) != null ? _b : `${DEFAULT_LOG_DIFF}`;
695
- };
696
- let storageKeyValue = "";
697
- let logDiffs = DEFAULT_LOG_DIFF;
698
- function updateStorageKeyValue(value) {
699
- logDiffs = getDiffStorageKeyValue() === "true";
700
- if (storageKeyValue === value) {
701
- return;
700
+ var loggers = new DeepMap();
701
+ var enabledChannelsCache = /* @__PURE__ */ new Map();
702
+ function isChannelTargeted(channel, permissionToken) {
703
+ const parts = channel.split(CHANNEL_SEPARATOR);
704
+ const partsMap = new DeepMap();
705
+ partsMap.set(parts, true);
706
+ const tokenParts = permissionToken.split(CHANNEL_SEPARATOR);
707
+ const hasWildcard = new Set(tokenParts).has(CHANNEL_WILDCARD);
708
+ const storagePartsWithoutWildcard = hasWildcard ? tokenParts.slice(0, tokenParts.indexOf(CHANNEL_WILDCARD)) : tokenParts;
709
+ if (partsMap.getKeysStartingWith(storagePartsWithoutWildcard, hasWildcard).length > 0) {
710
+ return true;
711
+ }
712
+ return void 0;
713
+ }
714
+ function isLoggingEnabled(channel, permissions) {
715
+ const cacheKey = `channel=${channel}_permissions=${permissions}`;
716
+ if (enabledChannelsCache.has(cacheKey)) {
717
+ return enabledChannelsCache.get(cacheKey);
718
+ }
719
+ const permissionTokens = permissions.split(STORAGE_SEPARATOR);
720
+ function done(result) {
721
+ enabledChannelsCache.set(cacheKey, result);
722
+ return result;
723
+ }
724
+ const exactTokens = [];
725
+ const wildcardTokens = [];
726
+ permissionTokens.forEach((permissionToken) => {
727
+ if (permissionToken.includes(CHANNEL_WILDCARD)) {
728
+ wildcardTokens.push(permissionToken);
729
+ } else {
730
+ exactTokens.push(permissionToken);
731
+ }
732
+ });
733
+ for (let i = 0; i < exactTokens.length; i++) {
734
+ let exactToken = exactTokens[i];
735
+ const negative = exactToken.startsWith(CHANNEL_NEGATION_CHAR);
736
+ if (negative) {
737
+ exactToken = exactToken.substring(CHANNEL_NEGATION_CHAR.length);
738
+ }
739
+ if (isChannelTargeted(channel, exactToken)) {
740
+ return done(negative ? false : true);
702
741
  }
703
- storageKeyValue = value;
704
742
  }
743
+ for (let i = 0; i < wildcardTokens.length; i++) {
744
+ let permissionToken = wildcardTokens[i];
745
+ const negated = permissionToken.startsWith("-");
746
+ if (negated) {
747
+ permissionToken = permissionToken.substring(1);
748
+ }
749
+ if (isChannelTargeted(channel, permissionToken)) {
750
+ return done(negated ? false : true);
751
+ }
752
+ }
753
+ return done(false);
754
+ }
755
+ var getStorageKeyValue = () => {
756
+ var _a, _b, _c;
757
+ return (_c = (_b = debug.enable) != null ? _b : getGlobal() && ((_a = getGlobal().localStorage) == null ? void 0 : _a.getItem(STORAGE_KEY))) != null ? _c : "";
758
+ };
759
+ var getDiffStorageKeyValue = () => {
760
+ var _a, _b, _c;
761
+ return (_c = (_b = debug.diffenable) != null ? _b : getGlobal() && ((_a = getGlobal().localStorage) == null ? void 0 : _a.getItem(STORAGE_DIFF_KEY))) != null ? _c : `${DEFAULT_LOG_DIFF}`;
762
+ };
763
+ var storageKeyValue = "";
764
+ var logDiffs = DEFAULT_LOG_DIFF;
765
+ function updateStorageKeyValue(value) {
766
+ logDiffs = `${getDiffStorageKeyValue()}` == "true";
767
+ if (storageKeyValue === value) {
768
+ return;
769
+ }
770
+ storageKeyValue = value;
771
+ enabledChannelsCache.clear();
772
+ }
773
+ function debugPackage(channelName) {
705
774
  updateStorageKeyValue(getStorageKeyValue());
706
775
  typeof getGlobal() !== "undefined" && getGlobal().addEventListener && getGlobal().addEventListener("storage", function() {
707
776
  updateStorageKeyValue(getStorageKeyValue());
708
777
  });
709
- function isLoggingEnabled(channel) {
710
- const parts = channel.split(CHANNEL_SEPARATOR);
711
- const partsMap = new DeepMap();
712
- partsMap.set(parts, true);
713
- const multipleStorageValues = storageKeyValue.split(STORAGE_SEPARATOR);
714
- for (let i = 0; i < multipleStorageValues.length; i++) {
715
- const storageValue = multipleStorageValues[i];
716
- const storageValueParts = storageValue.split(CHANNEL_SEPARATOR);
717
- const hasWildcard = new Set(storageValueParts).has(CHANNEL_WILDCARD);
718
- const storagePartsWithoutWildcard = hasWildcard ? storageValueParts.slice(
719
- 0,
720
- storageValueParts.indexOf(CHANNEL_WILDCARD)
721
- ) : storageValueParts;
722
- if (partsMap.getKeysStartingWith(storagePartsWithoutWildcard, hasWildcard).length > 0) {
723
- return true;
724
- }
725
- }
726
- return false;
727
- }
728
778
  function debugFactory(channelName2, parentChannel) {
729
779
  const channel = parentChannel ? `${parentChannel}${CHANNEL_SEPARATOR}${channelName2}` : channelName2;
730
780
  const channelParts = channel.split(CHANNEL_SEPARATOR);
@@ -732,18 +782,18 @@ function debug(channelName) {
732
782
  return loggers.get(channelParts);
733
783
  }
734
784
  const parentLogger = loggers.get(channelParts.slice(0, -1));
735
- let logFn = parentLogger ? parentLogger.log : defaultLogger;
785
+ let logFn = parentLogger ? parentLogger.log : debug.log;
736
786
  let enabled;
737
787
  let lastMessageTimestamp = 0;
738
- const isEnabled = () => enabled != null ? enabled : isLoggingEnabled(channel);
739
- const color = getNextColor();
788
+ const isEnabled = () => enabled != null ? enabled : isLoggingEnabled(channel, storageKeyValue);
789
+ const color = getNextColor(debug.colors);
740
790
  const logger = Object.defineProperties(
741
791
  (...args) => {
742
- if (isLoggingEnabled(channel)) {
792
+ if (isLoggingEnabled(channel, storageKeyValue)) {
743
793
  const now = Date.now();
744
794
  if (lastMessageTimestamp && logDiffs) {
745
795
  const diff = now - lastMessageTimestamp;
746
- logFn(`%c+${diff}ms:`, `color: ${color}`);
796
+ logFn(`%c[${channel}]`, `color: ${color}`, `+${diff}ms:`);
747
797
  }
748
798
  lastMessageTimestamp = now;
749
799
  logFn(`%c[${channel}]`, `color: ${color}`, ...args);
@@ -766,6 +816,11 @@ function debug(channelName) {
766
816
  set: (fn) => {
767
817
  logFn = fn;
768
818
  }
819
+ },
820
+ destroy: {
821
+ value: () => {
822
+ loggers.delete(channelParts);
823
+ }
769
824
  }
770
825
  }
771
826
  );
@@ -774,6 +829,18 @@ function debug(channelName) {
774
829
  }
775
830
  return debugFactory(channelName);
776
831
  }
832
+ var defaultLogger = console.log.bind(console);
833
+ var GLOBAL_ENABLE = void 0;
834
+ Object.defineProperty(debugPackage, "enable", {
835
+ get: () => GLOBAL_ENABLE,
836
+ set: (value) => {
837
+ GLOBAL_ENABLE = value;
838
+ updateStorageKeyValue(getStorageKeyValue());
839
+ }
840
+ });
841
+ var debug = debugPackage;
842
+ debug.colors = COLORS;
843
+ debug.log = defaultLogger;
777
844
 
778
845
  // src/utils/debug.ts
779
846
  var debugTable = debug(`InfiniteTable`);
@@ -17131,7 +17198,7 @@ var useLicense = (licenseKey = "") => {
17131
17198
  const valid = useMemo11(() => {
17132
17199
  let valid2 = isValidLicense(licenseKey, {
17133
17200
  publishedAt: 1624970570587,
17134
- version: "3.0.12"
17201
+ version: "3.0.14"
17135
17202
  });
17136
17203
  if (!licenseKey && !valid2 && isInsidePlayground) {
17137
17204
  return true;