@bereasoftware/time-guard 2.7.2 → 2.8.0
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/README.en.md +5 -1
- package/README.md +5 -1
- package/dist/angular/index.cjs +1 -148
- package/dist/angular/index.es.js +60 -112
- package/dist/calendars/index.cjs +1 -357
- package/dist/calendars/index.es.js +66 -99
- package/dist/chunk-C6qsp3rV.cjs +1 -0
- package/dist/core-Dxn1aRFk.js +1186 -0
- package/dist/core-TqmHKXY1.cjs +1 -0
- package/dist/core.d.ts +27 -1
- package/dist/index.d.ts +4 -2
- package/dist/locales/index.cjs +1 -7
- package/dist/locales/index.d.ts +11 -0
- package/dist/locales/index.es.js +3 -3
- package/dist/{locales-CGdn0DJN.cjs → locales-3Mw99lQ-.js} +201 -82
- package/dist/locales-bc-5kDuZ.cjs +1 -0
- package/dist/native/index.cjs +1 -48
- package/dist/native/index.es.js +8 -18
- package/dist/plugins/advanced-format.cjs +1 -105
- package/dist/plugins/advanced-format.es.js +43 -63
- package/dist/plugins/duration.cjs +1 -258
- package/dist/plugins/duration.es.js +59 -165
- package/dist/plugins/relative-time.cjs +1 -166
- package/dist/plugins/relative-time.es.js +36 -74
- package/dist/qwik/index.cjs +1 -104
- package/dist/qwik/index.es.js +33 -94
- package/dist/react/index.cjs +1 -112
- package/dist/react/index.es.js +57 -91
- package/dist/solid/index.cjs +1 -127
- package/dist/solid/index.es.js +34 -116
- package/dist/svelte/index.cjs +1 -398
- package/dist/svelte/index.es.js +85 -344
- package/dist/time-guard.cjs +3 -7359
- package/dist/time-guard.es.js +3412 -3625
- package/dist/time-guard.iife.js +3 -13549
- package/dist/time-guard.umd.js +3 -13550
- package/dist/vue/index.cjs +1 -143
- package/dist/vue/index.es.js +62 -116
- package/package.json +2 -3
- package/dist/chunk-S8Y6Ng9i.cjs +0 -36
- package/dist/core-BIDjudpO.cjs +0 -1892
- package/dist/core-DWPXk3rz.js +0 -1809
- package/dist/locales-BUE_aq8K.js +0 -3514
package/dist/svelte/index.es.js
CHANGED
|
@@ -1,393 +1,134 @@
|
|
|
1
|
-
/*! time-guard v2.
|
|
2
|
-
import {
|
|
3
|
-
Array.isArray;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Array.prototype;
|
|
8
|
-
var noop = () => {};
|
|
9
|
-
/** @param {Array<() => void>} arr */
|
|
10
|
-
function run_all(arr) {
|
|
11
|
-
for (var i = 0; i < arr.length; i++) arr[i]();
|
|
1
|
+
/*! time-guard v2.8.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
|
|
2
|
+
import { i as e, o as t, s as n } from "../core-Dxn1aRFk.js";
|
|
3
|
+
Array.isArray, Array.prototype.indexOf, Array.prototype.includes, Array.from, Array.prototype;
|
|
4
|
+
var r = () => {};
|
|
5
|
+
function i(e) {
|
|
6
|
+
for (var t = 0; t < e.length; t++) e[t]();
|
|
12
7
|
}
|
|
13
8
|
//#endregion
|
|
14
9
|
//#region node_modules/.pnpm/svelte@5.55.9_@typescript-eslint+types@8.59.4/node_modules/svelte/src/internal/client/constants.js
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
var MAYBE_DIRTY = 4096;
|
|
18
|
-
/**
|
|
19
|
-
* 'Transparent' effects do not create a transition boundary.
|
|
20
|
-
* This is on a block effect 99% of the time but may also be on a branch effect if its parent block effect was pruned
|
|
21
|
-
*/
|
|
22
|
-
var EFFECT_TRANSPARENT = 65536;
|
|
23
|
-
var EFFECT_PRESERVED = 1 << 19;
|
|
24
|
-
new class StaleReactionError extends Error {
|
|
10
|
+
var a = 1024, o = 2048, s = 4096, c = 65536, l = 1 << 19;
|
|
11
|
+
new class extends Error {
|
|
25
12
|
name = "StaleReactionError";
|
|
26
13
|
message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
|
|
27
|
-
}();
|
|
28
|
-
globalThis.document?.contentType;
|
|
14
|
+
}(), globalThis.document?.contentType;
|
|
29
15
|
//#endregion
|
|
30
16
|
//#region node_modules/.pnpm/svelte@5.55.9_@typescript-eslint+types@8.59.4/node_modules/svelte/src/internal/client/reactivity/equality.js
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* @param {unknown} b
|
|
34
|
-
* @returns {boolean}
|
|
35
|
-
*/
|
|
36
|
-
function safe_not_equal(a, b) {
|
|
37
|
-
return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function";
|
|
17
|
+
function u(e, t) {
|
|
18
|
+
return e == e ? e !== t || typeof e == "object" && !!e || typeof e == "function" : t == t;
|
|
38
19
|
}
|
|
39
|
-
~(
|
|
20
|
+
~(o | s | a);
|
|
40
21
|
//#endregion
|
|
41
22
|
//#region node_modules/.pnpm/svelte@5.55.9_@typescript-eslint+types@8.59.4/node_modules/svelte/src/store/utils.js
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* @param {(value: T) => void} run
|
|
47
|
-
* @param {(value: T) => void} [invalidate]
|
|
48
|
-
* @returns {() => void}
|
|
49
|
-
*/
|
|
50
|
-
function subscribe_to_store(store, run, invalidate) {
|
|
51
|
-
if (store == null) {
|
|
52
|
-
run(void 0);
|
|
53
|
-
if (invalidate) invalidate(void 0);
|
|
54
|
-
return noop;
|
|
55
|
-
}
|
|
56
|
-
const unsub = untrack(() => store.subscribe(run, invalidate));
|
|
57
|
-
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
|
|
23
|
+
function d(e, t, n) {
|
|
24
|
+
if (e == null) return t(void 0), n && n(void 0), r;
|
|
25
|
+
let i = _(() => e.subscribe(t, n));
|
|
26
|
+
return i.unsubscribe ? () => i.unsubscribe() : i;
|
|
58
27
|
}
|
|
59
28
|
//#endregion
|
|
60
29
|
//#region node_modules/.pnpm/svelte@5.55.9_@typescript-eslint+types@8.59.4/node_modules/svelte/src/store/shared/index.js
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* @type {Array<SubscribeInvalidateTuple<any> | any>}
|
|
65
|
-
*/
|
|
66
|
-
var subscriber_queue = [];
|
|
67
|
-
/**
|
|
68
|
-
* Creates a `Readable` store that allows reading by subscription.
|
|
69
|
-
*
|
|
70
|
-
* @template T
|
|
71
|
-
* @param {T} [value] initial value
|
|
72
|
-
* @param {StartStopNotifier<T>} [start]
|
|
73
|
-
* @returns {Readable<T>}
|
|
74
|
-
*/
|
|
75
|
-
function readable(value, start) {
|
|
76
|
-
return { subscribe: writable(value, start).subscribe };
|
|
30
|
+
var f = [];
|
|
31
|
+
function p(e, t) {
|
|
32
|
+
return { subscribe: m(e, t).subscribe };
|
|
77
33
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/** @type {Unsubscriber | null} */
|
|
88
|
-
let stop = null;
|
|
89
|
-
/** @type {Set<SubscribeInvalidateTuple<T>>} */
|
|
90
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
91
|
-
/**
|
|
92
|
-
* @param {T} new_value
|
|
93
|
-
* @returns {void}
|
|
94
|
-
*/
|
|
95
|
-
function set(new_value) {
|
|
96
|
-
if (safe_not_equal(value, new_value)) {
|
|
97
|
-
value = new_value;
|
|
98
|
-
if (stop) {
|
|
99
|
-
const run_queue = !subscriber_queue.length;
|
|
100
|
-
for (const subscriber of subscribers) {
|
|
101
|
-
subscriber[1]();
|
|
102
|
-
subscriber_queue.push(subscriber, value);
|
|
103
|
-
}
|
|
104
|
-
if (run_queue) {
|
|
105
|
-
for (let i = 0; i < subscriber_queue.length; i += 2) subscriber_queue[i][0](subscriber_queue[i + 1]);
|
|
106
|
-
subscriber_queue.length = 0;
|
|
107
|
-
}
|
|
34
|
+
function m(e, t = r) {
|
|
35
|
+
let n = null, i = /* @__PURE__ */ new Set();
|
|
36
|
+
function a(t) {
|
|
37
|
+
if (u(e, t) && (e = t, n)) {
|
|
38
|
+
let t = !f.length;
|
|
39
|
+
for (let t of i) t[1](), f.push(t, e);
|
|
40
|
+
if (t) {
|
|
41
|
+
for (let e = 0; e < f.length; e += 2) f[e][0](f[e + 1]);
|
|
42
|
+
f.length = 0;
|
|
108
43
|
}
|
|
109
44
|
}
|
|
110
45
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* @returns {void}
|
|
114
|
-
*/
|
|
115
|
-
function update(fn) {
|
|
116
|
-
set(fn(value));
|
|
46
|
+
function o(t) {
|
|
47
|
+
a(t(e));
|
|
117
48
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*/
|
|
123
|
-
function subscribe(run, invalidate = noop) {
|
|
124
|
-
/** @type {SubscribeInvalidateTuple<T>} */
|
|
125
|
-
const subscriber = [run, invalidate];
|
|
126
|
-
subscribers.add(subscriber);
|
|
127
|
-
if (subscribers.size === 1) stop = start(set, update) || noop;
|
|
128
|
-
run(value);
|
|
129
|
-
return () => {
|
|
130
|
-
subscribers.delete(subscriber);
|
|
131
|
-
if (subscribers.size === 0 && stop) {
|
|
132
|
-
stop();
|
|
133
|
-
stop = null;
|
|
134
|
-
}
|
|
49
|
+
function s(s, c = r) {
|
|
50
|
+
let l = [s, c];
|
|
51
|
+
return i.add(l), i.size === 1 && (n = t(a, o) || r), s(e), () => {
|
|
52
|
+
i.delete(l), i.size === 0 && n && (n(), n = null);
|
|
135
53
|
};
|
|
136
54
|
}
|
|
137
55
|
return {
|
|
138
|
-
set,
|
|
139
|
-
update,
|
|
140
|
-
subscribe
|
|
56
|
+
set: a,
|
|
57
|
+
update: o,
|
|
58
|
+
subscribe: s
|
|
141
59
|
};
|
|
142
60
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Derived value store by synchronizing one or more readable stores and
|
|
157
|
-
* applying an aggregation function over its input values.
|
|
158
|
-
*
|
|
159
|
-
* @template {Stores} S
|
|
160
|
-
* @template T
|
|
161
|
-
* @overload
|
|
162
|
-
* @param {S} stores
|
|
163
|
-
* @param {(values: StoresValues<S>) => T} fn
|
|
164
|
-
* @param {T} [initial_value]
|
|
165
|
-
* @returns {Readable<T>}
|
|
166
|
-
*/
|
|
167
|
-
/**
|
|
168
|
-
* @template {Stores} S
|
|
169
|
-
* @template T
|
|
170
|
-
* @param {S} stores
|
|
171
|
-
* @param {Function} fn
|
|
172
|
-
* @param {T} [initial_value]
|
|
173
|
-
* @returns {Readable<T>}
|
|
174
|
-
*/
|
|
175
|
-
function derived(stores, fn, initial_value) {
|
|
176
|
-
const single = !Array.isArray(stores);
|
|
177
|
-
/** @type {Array<Readable<any>>} */
|
|
178
|
-
const stores_array = single ? [stores] : stores;
|
|
179
|
-
if (!stores_array.every(Boolean)) throw new Error("derived() expects stores as input, got a falsy value");
|
|
180
|
-
const auto = fn.length < 2;
|
|
181
|
-
return readable(initial_value, (set, update) => {
|
|
182
|
-
let started = false;
|
|
183
|
-
/** @type {T[]} */
|
|
184
|
-
const values = [];
|
|
185
|
-
let pending = 0;
|
|
186
|
-
let cleanup = noop;
|
|
187
|
-
const sync = () => {
|
|
188
|
-
if (pending) return;
|
|
189
|
-
cleanup();
|
|
190
|
-
const result = fn(single ? values[0] : values, set, update);
|
|
191
|
-
if (auto) set(result);
|
|
192
|
-
else cleanup = typeof result === "function" ? result : noop;
|
|
193
|
-
};
|
|
194
|
-
const unsubscribers = stores_array.map((store, i) => subscribe_to_store(store, (value) => {
|
|
195
|
-
values[i] = value;
|
|
196
|
-
pending &= ~(1 << i);
|
|
197
|
-
if (started) sync();
|
|
61
|
+
function h(e, t, n) {
|
|
62
|
+
let a = !Array.isArray(e), o = a ? [e] : e;
|
|
63
|
+
if (!o.every(Boolean)) throw Error("derived() expects stores as input, got a falsy value");
|
|
64
|
+
let s = t.length < 2;
|
|
65
|
+
return p(n, (e, n) => {
|
|
66
|
+
let c = !1, l = [], u = 0, f = r, p = () => {
|
|
67
|
+
if (u) return;
|
|
68
|
+
f();
|
|
69
|
+
let i = t(a ? l[0] : l, e, n);
|
|
70
|
+
s ? e(i) : f = typeof i == "function" ? i : r;
|
|
71
|
+
}, m = o.map((e, t) => d(e, (e) => {
|
|
72
|
+
l[t] = e, u &= ~(1 << t), c && p();
|
|
198
73
|
}, () => {
|
|
199
|
-
|
|
74
|
+
u |= 1 << t;
|
|
200
75
|
}));
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return function stop() {
|
|
204
|
-
run_all(unsubscribers);
|
|
205
|
-
cleanup();
|
|
206
|
-
started = false;
|
|
76
|
+
return c = !0, p(), function() {
|
|
77
|
+
i(m), f(), c = !1;
|
|
207
78
|
};
|
|
208
79
|
});
|
|
209
80
|
}
|
|
210
|
-
|
|
81
|
+
c | l;
|
|
211
82
|
//#endregion
|
|
212
83
|
//#region node_modules/.pnpm/svelte@5.55.9_@typescript-eslint+types@8.59.4/node_modules/svelte/src/internal/client/runtime.js
|
|
213
|
-
var
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* any state read inside `fn` will not be treated as a dependency.
|
|
217
|
-
*
|
|
218
|
-
* ```ts
|
|
219
|
-
* $effect(() => {
|
|
220
|
-
* // this will run when `data` changes, but not when `time` changes
|
|
221
|
-
* save(data, {
|
|
222
|
-
* timestamp: untrack(() => time)
|
|
223
|
-
* });
|
|
224
|
-
* });
|
|
225
|
-
* ```
|
|
226
|
-
* @template T
|
|
227
|
-
* @param {() => T} fn
|
|
228
|
-
* @returns {T}
|
|
229
|
-
*/
|
|
230
|
-
function untrack(fn) {
|
|
231
|
-
var previous_untracking = untracking;
|
|
84
|
+
var g = !1;
|
|
85
|
+
function _(e) {
|
|
86
|
+
var t = g;
|
|
232
87
|
try {
|
|
233
|
-
|
|
234
|
-
return fn();
|
|
88
|
+
return g = !0, e();
|
|
235
89
|
} finally {
|
|
236
|
-
|
|
90
|
+
g = t;
|
|
237
91
|
}
|
|
238
92
|
}
|
|
239
93
|
//#endregion
|
|
240
94
|
//#region src/svelte.ts
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
*
|
|
244
|
-
* Provides reactive stores and lifecycle-managed wrappers for TimeGuard.
|
|
245
|
-
* Compatible with both Svelte 4 (`$store` auto-subscription) and
|
|
246
|
-
* Svelte 5 (`$state` + `get()` from stores).
|
|
247
|
-
*
|
|
248
|
-
* @example
|
|
249
|
-
* ```svelte
|
|
250
|
-
* <script lang="ts">
|
|
251
|
-
* import { useCurrentTime, useRelativeTime } from '@bereasoftware/time-guard/svelte';
|
|
252
|
-
*
|
|
253
|
-
* const now = useCurrentTime({ interval: 1000 });
|
|
254
|
-
* const relative = useRelativeTime('2026-05-20T08:00:00');
|
|
255
|
-
* <\/script>
|
|
256
|
-
*
|
|
257
|
-
* <h1>{$now.format('HH:mm:ss')}</h1>
|
|
258
|
-
* <p>Published: {$relative}</p>
|
|
259
|
-
* ```
|
|
260
|
-
*/
|
|
261
|
-
/**
|
|
262
|
-
* Duck-type check: is this a Svelte store (has `subscribe`)?
|
|
263
|
-
*/
|
|
264
|
-
function isStore(val) {
|
|
265
|
-
return typeof val === "object" && val !== null && "subscribe" in val && typeof val.subscribe === "function";
|
|
95
|
+
function v(e) {
|
|
96
|
+
return typeof e == "object" && !!e && "subscribe" in e && typeof e.subscribe == "function";
|
|
266
97
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
*/
|
|
270
|
-
function toStore(val) {
|
|
271
|
-
return isStore(val) ? val : readable(val);
|
|
98
|
+
function y(e) {
|
|
99
|
+
return v(e) ? e : p(e);
|
|
272
100
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
*/
|
|
277
|
-
var TimeGuardConfigKey = Symbol("TimeGuardConfig");
|
|
278
|
-
/**
|
|
279
|
-
* Creates a reactive readable store of a TimeGuard instance.
|
|
280
|
-
* Automatically updates when `input` changes (supports both plain values
|
|
281
|
-
* and Svelte stores as input — pass a `Readable` for full reactivity).
|
|
282
|
-
* Integrates global config from `getContext(TimeGuardConfigKey)` as fallback.
|
|
283
|
-
*
|
|
284
|
-
* ```svelte
|
|
285
|
-
* <script>
|
|
286
|
-
* import { writable } from 'svelte/store';
|
|
287
|
-
* import { useTimeGuard } from '@bereasoftware/time-guard/svelte';
|
|
288
|
-
* import { TimeGuard } from '@bereasoftware/time-guard';
|
|
289
|
-
*
|
|
290
|
-
* // Static input — no reactivity needed
|
|
291
|
-
* const tg = useTimeGuard('2026-05-20');
|
|
292
|
-
*
|
|
293
|
-
* // Reactive input — pass a store
|
|
294
|
-
* const dateStore = writable('2026-05-20');
|
|
295
|
-
* const tg2 = useTimeGuard(dateStore);
|
|
296
|
-
* <\/script>
|
|
297
|
-
*
|
|
298
|
-
* <p>{$tg.format('dddd, DD MMMM YYYY')}</p>
|
|
299
|
-
* <p>{$tg2.format('dddd, DD MMMM YYYY')}</p>
|
|
300
|
-
* ```
|
|
301
|
-
*/
|
|
302
|
-
function useTimeGuard(input, config) {
|
|
303
|
-
if (isStore(input)) return derived(input, ($val) => TimeGuard.from($val, config));
|
|
304
|
-
return readable(TimeGuard.from(input, config));
|
|
101
|
+
var b = Symbol("TimeGuardConfig");
|
|
102
|
+
function x(t, n) {
|
|
103
|
+
return v(t) ? h(t, (t) => e.from(t, n)) : p(e.from(t, n));
|
|
305
104
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
* ```svelte
|
|
312
|
-
* <script>
|
|
313
|
-
* import { useCurrentTime } from '@bereasoftware/time-guard/svelte';
|
|
314
|
-
* const now = useCurrentTime({ interval: 1000 });
|
|
315
|
-
* <\/script>
|
|
316
|
-
* <p>{$now.format('HH:mm:ss')}</p>
|
|
317
|
-
* ```
|
|
318
|
-
*/
|
|
319
|
-
function useCurrentTime(options) {
|
|
320
|
-
const interval = options?.interval ?? 1e3;
|
|
321
|
-
const config = options?.config;
|
|
322
|
-
const store = writable(TimeGuard.now(config), () => {
|
|
323
|
-
const timer = setInterval(() => {
|
|
324
|
-
store.set(TimeGuard.now(config));
|
|
325
|
-
}, interval);
|
|
105
|
+
function S(t) {
|
|
106
|
+
let n = t?.interval ?? 1e3, r = t?.config, i = m(e.now(r), () => {
|
|
107
|
+
let t = setInterval(() => {
|
|
108
|
+
i.set(e.now(r));
|
|
109
|
+
}, n);
|
|
326
110
|
return () => {
|
|
327
|
-
clearInterval(
|
|
111
|
+
clearInterval(t);
|
|
328
112
|
};
|
|
329
113
|
});
|
|
330
|
-
return { subscribe:
|
|
114
|
+
return { subscribe: i.subscribe };
|
|
331
115
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
* <\/script>
|
|
341
|
-
* <p>{$relative}</p>
|
|
342
|
-
* ```
|
|
343
|
-
*/
|
|
344
|
-
function useRelativeTime(date, options) {
|
|
345
|
-
const interval = options?.interval ?? 6e4;
|
|
346
|
-
const locale = options?.locale;
|
|
347
|
-
const numeric = options?.numeric;
|
|
348
|
-
const compute = () => {
|
|
349
|
-
const tgDate = TimeGuard.from(date);
|
|
350
|
-
const now = TimeGuard.now();
|
|
351
|
-
return tgDate.since(now).humanize({
|
|
352
|
-
locale,
|
|
353
|
-
numeric
|
|
354
|
-
});
|
|
355
|
-
};
|
|
356
|
-
const store = writable(compute(), () => {
|
|
357
|
-
const timer = setInterval(() => {
|
|
358
|
-
store.set(compute());
|
|
359
|
-
}, interval);
|
|
116
|
+
function C(e, n) {
|
|
117
|
+
let r = n?.interval ?? 6e4, i = n?.locale, a = n?.numeric, o = () => t(e, {
|
|
118
|
+
locale: i,
|
|
119
|
+
numeric: a
|
|
120
|
+
}), s = m(o(), () => {
|
|
121
|
+
let e = setInterval(() => {
|
|
122
|
+
s.set(o());
|
|
123
|
+
}, r);
|
|
360
124
|
return () => {
|
|
361
|
-
clearInterval(
|
|
125
|
+
clearInterval(e);
|
|
362
126
|
};
|
|
363
127
|
});
|
|
364
|
-
return { subscribe:
|
|
128
|
+
return { subscribe: s.subscribe };
|
|
365
129
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
* Recalculates reactively when `start` or `end` change (supports both
|
|
369
|
-
* plain values and Svelte stores).
|
|
370
|
-
*
|
|
371
|
-
* ```svelte
|
|
372
|
-
* <script>
|
|
373
|
-
* import { writable } from 'svelte/store';
|
|
374
|
-
* import { useTimeRange } from '@bereasoftware/time-guard/svelte';
|
|
375
|
-
*
|
|
376
|
-
* // Static range
|
|
377
|
-
* const range = useTimeRange('2026-05-20', '2026-06-01');
|
|
378
|
-
*
|
|
379
|
-
* // Reactive range
|
|
380
|
-
* const start = writable('2026-05-20');
|
|
381
|
-
* const end = writable('2026-06-01');
|
|
382
|
-
* const range2 = useTimeRange(start, end);
|
|
383
|
-
* <\/script>
|
|
384
|
-
*
|
|
385
|
-
* <p>Duration: {$range.toDuration().humanize()}</p>
|
|
386
|
-
*/
|
|
387
|
-
function useTimeRange(start, end, config) {
|
|
388
|
-
return derived([toStore(start), toStore(end)], ([$start, $end]) => {
|
|
389
|
-
return new TimeRange(TimeGuard.from($start, config), TimeGuard.from($end, config));
|
|
390
|
-
});
|
|
130
|
+
function w(e, t, r) {
|
|
131
|
+
return h([y(e), y(t)], ([e, t]) => n(e, t, r));
|
|
391
132
|
}
|
|
392
133
|
//#endregion
|
|
393
|
-
export { TimeGuardConfigKey, useCurrentTime, useRelativeTime, useTimeGuard, useTimeRange };
|
|
134
|
+
export { b as TimeGuardConfigKey, S as useCurrentTime, C as useRelativeTime, x as useTimeGuard, w as useTimeRange };
|