libey-ng-component-library 0.0.41 → 0.0.42

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.
@@ -2520,9 +2520,9 @@
2520
2520
  };
2521
2521
  }
2522
2522
 
2523
- var DEFAULT_TTL_MS$1 = 8 * 60 * 60 * 1000; // 8 horas - red de seguridad para maestros
2523
+ var DEFAULT_TTL_MS$2 = 8 * 60 * 60 * 1000; // 8 horas - red de seguridad para maestros
2524
2524
  function getOrFetch(key, fetchFn, ttlMs) {
2525
- if (ttlMs === void 0) { ttlMs = DEFAULT_TTL_MS$1; }
2525
+ if (ttlMs === void 0) { ttlMs = DEFAULT_TTL_MS$2; }
2526
2526
  var cached = getItem(key);
2527
2527
  if (cached)
2528
2528
  return rxjs.of(cached);
@@ -3037,9 +3037,9 @@
3037
3037
  __rewriteRelativeImportExtension: __rewriteRelativeImportExtension,
3038
3038
  };
3039
3039
 
3040
- var DEFAULT_TTL_MS = 8 * 60 * 60 * 1000; // 8 horas - red de seguridad para maestros
3040
+ var DEFAULT_TTL_MS$1 = 8 * 60 * 60 * 1000; // 8 horas - red de seguridad para maestros
3041
3041
  function Cacheable(key, ttlMs) {
3042
- if (ttlMs === void 0) { ttlMs = DEFAULT_TTL_MS; }
3042
+ if (ttlMs === void 0) { ttlMs = DEFAULT_TTL_MS$1; }
3043
3043
  return function (target, propertyKey, descriptor) {
3044
3044
  var originalMethod = descriptor.value;
3045
3045
  descriptor.value = function () {
@@ -3067,6 +3067,82 @@
3067
3067
  getOrFetch: getOrFetch,
3068
3068
  };
3069
3069
 
3070
+ var NAVIGATION_STATE_VERSION = 1;
3071
+ var KEY_PREFIX = 'libey:nav:';
3072
+ var DEFAULT_TTL_MS = 60 * 1000;
3073
+ function buildKey(name) {
3074
+ if (!name)
3075
+ throw new Error('navigationState: el nombre no puede estar vacio');
3076
+ return KEY_PREFIX + name;
3077
+ }
3078
+ function read(key) {
3079
+ var raw;
3080
+ try {
3081
+ raw = sessionStorage.getItem(key);
3082
+ }
3083
+ catch (_a) {
3084
+ return null;
3085
+ }
3086
+ if (!raw)
3087
+ return null;
3088
+ try {
3089
+ var entry = JSON.parse(raw);
3090
+ var isOldVersion = entry.version !== NAVIGATION_STATE_VERSION;
3091
+ var isExpired = Date.now() > entry.expiresAt;
3092
+ if (isOldVersion || isExpired) {
3093
+ sessionStorage.removeItem(key);
3094
+ return null;
3095
+ }
3096
+ return entry.data;
3097
+ }
3098
+ catch (_b) {
3099
+ sessionStorage.removeItem(key);
3100
+ return null;
3101
+ }
3102
+ }
3103
+ function set(name, data, ttlMs) {
3104
+ if (ttlMs === void 0) { ttlMs = DEFAULT_TTL_MS; }
3105
+ var entry = {
3106
+ version: NAVIGATION_STATE_VERSION,
3107
+ data: data,
3108
+ expiresAt: Date.now() + ttlMs,
3109
+ };
3110
+ try {
3111
+ sessionStorage.setItem(buildKey(name), JSON.stringify(entry));
3112
+ }
3113
+ catch (error) {
3114
+ console.error("navigationState: no se pudo guardar \"" + name + "\":", error);
3115
+ }
3116
+ }
3117
+ function consume(name) {
3118
+ var key = buildKey(name);
3119
+ var data = read(key);
3120
+ try {
3121
+ sessionStorage.removeItem(key);
3122
+ }
3123
+ catch (_a) {
3124
+ // sessionStorage no disponible - no hay nada que borrar
3125
+ }
3126
+ return data;
3127
+ }
3128
+ function peek(name) {
3129
+ return read(buildKey(name));
3130
+ }
3131
+ function remove(name) {
3132
+ try {
3133
+ sessionStorage.removeItem(buildKey(name));
3134
+ }
3135
+ catch (_a) {
3136
+ // sessionStorage no disponible - no hay nada que borrar
3137
+ }
3138
+ }
3139
+ var navigationState = {
3140
+ set: set,
3141
+ consume: consume,
3142
+ peek: peek,
3143
+ remove: remove,
3144
+ };
3145
+
3070
3146
  /*
3071
3147
  * Public API Surface of libey-ng-component-library
3072
3148
  */
@@ -3108,6 +3184,7 @@
3108
3184
  exports.SigWebTablet = SigWebTablet;
3109
3185
  exports.ZONE_COLORS = ZONE_COLORS;
3110
3186
  exports.cache = cache;
3187
+ exports.navigationState = navigationState;
3111
3188
  Object.keys(core).forEach(function (k) {
3112
3189
  if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
3113
3190
  enumerable: true,