qstd 0.2.0 → 0.2.2
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/CHANGELOG.md +20 -0
- package/dist/client/index.cjs +24 -1
- package/dist/client/index.d.cts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +24 -2
- package/dist/{random-DMErOOdk.d.cts → log-DPBPow2d.d.cts} +14 -1
- package/dist/{random-DMErOOdk.d.ts → log-DPBPow2d.d.ts} +14 -1
- package/dist/react/index.cjs +87 -0
- package/dist/react/index.d.cts +18 -1
- package/dist/react/index.d.ts +18 -1
- package/dist/react/index.js +87 -1
- package/dist/server/index.cjs +23 -0
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +23 -1
- package/package.json +19 -18
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.2] - 2025-11-24
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Added `useTheme` hook for managing light/dark theme
|
|
15
|
+
- Syncs with localStorage and across components using events
|
|
16
|
+
- Provides `theme`, `isManual` state and `toggleTheme`, `update` functions
|
|
17
|
+
- Available in `qstd/react`
|
|
18
|
+
|
|
19
|
+
## [0.2.1] - 2025-11-24
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- Added `Log` utility module with logging functions
|
|
24
|
+
- `log()` - Pretty print values with JSON.stringify
|
|
25
|
+
- `info()` - Log with [info] prefix
|
|
26
|
+
- `warn()` - Log with [warn] prefix
|
|
27
|
+
- `error()` - Log with [error] prefix
|
|
28
|
+
- Available in both `qstd/client` and `qstd/server`
|
|
29
|
+
|
|
10
30
|
## [0.2.0] - 2025-11-22
|
|
11
31
|
|
|
12
32
|
### Added
|
package/dist/client/index.cjs
CHANGED
|
@@ -516,6 +516,28 @@ var hexColor = () => {
|
|
|
516
516
|
return hex;
|
|
517
517
|
};
|
|
518
518
|
|
|
519
|
+
// src/shared/log.ts
|
|
520
|
+
var log_exports = {};
|
|
521
|
+
__export(log_exports, {
|
|
522
|
+
error: () => error,
|
|
523
|
+
info: () => info,
|
|
524
|
+
log: () => log,
|
|
525
|
+
warn: () => warn
|
|
526
|
+
});
|
|
527
|
+
var stringify = (value) => JSON.stringify(value, null, 2);
|
|
528
|
+
var log = (...values) => {
|
|
529
|
+
console.log(...values.map(stringify));
|
|
530
|
+
};
|
|
531
|
+
var info = (...values) => {
|
|
532
|
+
console.log("[info]", ...values.map(stringify));
|
|
533
|
+
};
|
|
534
|
+
var warn = (...values) => {
|
|
535
|
+
console.log("[warn]", ...values.map(stringify));
|
|
536
|
+
};
|
|
537
|
+
var error = (...values) => {
|
|
538
|
+
console.log("[error]", ...values.map(stringify));
|
|
539
|
+
};
|
|
540
|
+
|
|
519
541
|
// src/client/dom.ts
|
|
520
542
|
var dom_exports = {};
|
|
521
543
|
__export(dom_exports, {
|
|
@@ -560,7 +582,7 @@ var scrollIntoView = (el, options) => {
|
|
|
560
582
|
var copy = async (text) => {
|
|
561
583
|
try {
|
|
562
584
|
await navigator.clipboard.writeText(text);
|
|
563
|
-
} catch (
|
|
585
|
+
} catch (error2) {
|
|
564
586
|
const textArea = document.createElement("textarea");
|
|
565
587
|
textArea.value = text;
|
|
566
588
|
textArea.style.position = "fixed";
|
|
@@ -581,6 +603,7 @@ exports.Dom = dom_exports;
|
|
|
581
603
|
exports.Flow = flow_exports;
|
|
582
604
|
exports.Int = int_exports;
|
|
583
605
|
exports.List = list_exports;
|
|
606
|
+
exports.Log = log_exports;
|
|
584
607
|
exports.Money = money_exports;
|
|
585
608
|
exports.Random = random_exports;
|
|
586
609
|
exports.Str = str_exports;
|
package/dist/client/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as Dict, f as Flow, i as Int, l as List, m as Money, r as Random, s as Str, t as Time } from '../
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-DPBPow2d.cjs';
|
|
2
2
|
import 'date-fns';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as Dict, f as Flow, i as Int, l as List, m as Money, r as Random, s as Str, t as Time } from '../
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-DPBPow2d.js';
|
|
2
2
|
import 'date-fns';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/client/index.js
CHANGED
|
@@ -514,6 +514,28 @@ var hexColor = () => {
|
|
|
514
514
|
return hex;
|
|
515
515
|
};
|
|
516
516
|
|
|
517
|
+
// src/shared/log.ts
|
|
518
|
+
var log_exports = {};
|
|
519
|
+
__export(log_exports, {
|
|
520
|
+
error: () => error,
|
|
521
|
+
info: () => info,
|
|
522
|
+
log: () => log,
|
|
523
|
+
warn: () => warn
|
|
524
|
+
});
|
|
525
|
+
var stringify = (value) => JSON.stringify(value, null, 2);
|
|
526
|
+
var log = (...values) => {
|
|
527
|
+
console.log(...values.map(stringify));
|
|
528
|
+
};
|
|
529
|
+
var info = (...values) => {
|
|
530
|
+
console.log("[info]", ...values.map(stringify));
|
|
531
|
+
};
|
|
532
|
+
var warn = (...values) => {
|
|
533
|
+
console.log("[warn]", ...values.map(stringify));
|
|
534
|
+
};
|
|
535
|
+
var error = (...values) => {
|
|
536
|
+
console.log("[error]", ...values.map(stringify));
|
|
537
|
+
};
|
|
538
|
+
|
|
517
539
|
// src/client/dom.ts
|
|
518
540
|
var dom_exports = {};
|
|
519
541
|
__export(dom_exports, {
|
|
@@ -558,7 +580,7 @@ var scrollIntoView = (el, options) => {
|
|
|
558
580
|
var copy = async (text) => {
|
|
559
581
|
try {
|
|
560
582
|
await navigator.clipboard.writeText(text);
|
|
561
|
-
} catch (
|
|
583
|
+
} catch (error2) {
|
|
562
584
|
const textArea = document.createElement("textarea");
|
|
563
585
|
textArea.value = text;
|
|
564
586
|
textArea.style.position = "fixed";
|
|
@@ -574,4 +596,4 @@ var copy = async (text) => {
|
|
|
574
596
|
}
|
|
575
597
|
};
|
|
576
598
|
|
|
577
|
-
export { dict_exports as Dict, dom_exports as Dom, flow_exports as Flow, int_exports as Int, list_exports as List, money_exports as Money, random_exports as Random, str_exports as Str, time_exports as Time };
|
|
599
|
+
export { dict_exports as Dict, dom_exports as Dom, flow_exports as Flow, int_exports as Int, list_exports as List, log_exports as Log, money_exports as Money, random_exports as Random, str_exports as Str, time_exports as Time };
|
|
@@ -444,4 +444,17 @@ declare namespace random {
|
|
|
444
444
|
export { random_coinFlip as coinFlip, random_date as date, random_hexColor as hexColor, random_item as item, random_num as num, random_shuffle as shuffle };
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
|
|
447
|
+
declare const log: (...values: unknown[]) => void;
|
|
448
|
+
declare const info: (...values: unknown[]) => void;
|
|
449
|
+
declare const warn: (...values: unknown[]) => void;
|
|
450
|
+
declare const error: (...values: unknown[]) => void;
|
|
451
|
+
|
|
452
|
+
declare const log$1_error: typeof error;
|
|
453
|
+
declare const log$1_info: typeof info;
|
|
454
|
+
declare const log$1_log: typeof log;
|
|
455
|
+
declare const log$1_warn: typeof warn;
|
|
456
|
+
declare namespace log$1 {
|
|
457
|
+
export { log$1_error as error, log$1_info as info, log$1_log as log, log$1_warn as warn };
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export { log$1 as a, dict as d, flow as f, int as i, list as l, money as m, random as r, str as s, time as t };
|
|
@@ -444,4 +444,17 @@ declare namespace random {
|
|
|
444
444
|
export { random_coinFlip as coinFlip, random_date as date, random_hexColor as hexColor, random_item as item, random_num as num, random_shuffle as shuffle };
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
-
|
|
447
|
+
declare const log: (...values: unknown[]) => void;
|
|
448
|
+
declare const info: (...values: unknown[]) => void;
|
|
449
|
+
declare const warn: (...values: unknown[]) => void;
|
|
450
|
+
declare const error: (...values: unknown[]) => void;
|
|
451
|
+
|
|
452
|
+
declare const log$1_error: typeof error;
|
|
453
|
+
declare const log$1_info: typeof info;
|
|
454
|
+
declare const log$1_log: typeof log;
|
|
455
|
+
declare const log$1_warn: typeof warn;
|
|
456
|
+
declare namespace log$1 {
|
|
457
|
+
export { log$1_error as error, log$1_info as info, log$1_log as log, log$1_warn as warn };
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export { log$1 as a, dict as d, flow as f, int as i, list as l, money as m, random as r, str as s, time as t };
|
package/dist/react/index.cjs
CHANGED
|
@@ -3547,6 +3547,92 @@ var CompoundBlock = Object.assign(Block, {
|
|
|
3547
3547
|
});
|
|
3548
3548
|
var block_default = CompoundBlock;
|
|
3549
3549
|
|
|
3550
|
+
// src/react/use-theme/literals.ts
|
|
3551
|
+
var THEME_STORAGE_KEY = "theme";
|
|
3552
|
+
var THEME_STORE_STORAGE_KEY = "themeStore";
|
|
3553
|
+
var THEME_CHANGE_EVENT = "qstd:theme-change";
|
|
3554
|
+
|
|
3555
|
+
// src/react/use-theme/fns.ts
|
|
3556
|
+
var getInitialTheme = () => {
|
|
3557
|
+
if (typeof window === "undefined") return "light";
|
|
3558
|
+
const stored = localStorage.getItem(THEME_STORAGE_KEY);
|
|
3559
|
+
return stored === "light" || stored === "dark" ? stored : "light";
|
|
3560
|
+
};
|
|
3561
|
+
var getInitialStore = () => {
|
|
3562
|
+
if (typeof window === "undefined") {
|
|
3563
|
+
return { theme: "light", isManual: false };
|
|
3564
|
+
}
|
|
3565
|
+
try {
|
|
3566
|
+
const stored = localStorage.getItem(THEME_STORE_STORAGE_KEY);
|
|
3567
|
+
if (stored) {
|
|
3568
|
+
const parsed = JSON.parse(stored);
|
|
3569
|
+
return {
|
|
3570
|
+
theme: parsed.theme ?? getInitialTheme(),
|
|
3571
|
+
isManual: parsed.isManual ?? false
|
|
3572
|
+
};
|
|
3573
|
+
}
|
|
3574
|
+
} catch {
|
|
3575
|
+
}
|
|
3576
|
+
return {
|
|
3577
|
+
theme: getInitialTheme(),
|
|
3578
|
+
isManual: false
|
|
3579
|
+
};
|
|
3580
|
+
};
|
|
3581
|
+
var saveStore = (store) => {
|
|
3582
|
+
if (typeof window === "undefined") return;
|
|
3583
|
+
try {
|
|
3584
|
+
localStorage.setItem(THEME_STORAGE_KEY, store.theme);
|
|
3585
|
+
localStorage.setItem(THEME_STORE_STORAGE_KEY, JSON.stringify(store));
|
|
3586
|
+
window.dispatchEvent(
|
|
3587
|
+
new CustomEvent(THEME_CHANGE_EVENT, { detail: store })
|
|
3588
|
+
);
|
|
3589
|
+
} catch {
|
|
3590
|
+
}
|
|
3591
|
+
};
|
|
3592
|
+
|
|
3593
|
+
// src/react/use-theme/index.ts
|
|
3594
|
+
function useTheme() {
|
|
3595
|
+
const [store, setStore] = React11__namespace.default.useState(getInitialStore);
|
|
3596
|
+
React11__namespace.default.useEffect(() => {
|
|
3597
|
+
if (typeof window === "undefined") return;
|
|
3598
|
+
const handleStorageChange = (e) => {
|
|
3599
|
+
if (e.key === THEME_STORAGE_KEY || e.key === THEME_STORE_STORAGE_KEY) {
|
|
3600
|
+
setStore(getInitialStore());
|
|
3601
|
+
}
|
|
3602
|
+
};
|
|
3603
|
+
const handleThemeChange = (e) => {
|
|
3604
|
+
const customEvent = e;
|
|
3605
|
+
if (customEvent.detail) {
|
|
3606
|
+
setStore(customEvent.detail);
|
|
3607
|
+
}
|
|
3608
|
+
};
|
|
3609
|
+
window.addEventListener("storage", handleStorageChange);
|
|
3610
|
+
window.addEventListener(THEME_CHANGE_EVENT, handleThemeChange);
|
|
3611
|
+
return () => {
|
|
3612
|
+
window.removeEventListener("storage", handleStorageChange);
|
|
3613
|
+
window.removeEventListener(THEME_CHANGE_EVENT, handleThemeChange);
|
|
3614
|
+
};
|
|
3615
|
+
}, []);
|
|
3616
|
+
const update = (updates) => {
|
|
3617
|
+
setStore((prev) => {
|
|
3618
|
+
const next = { ...prev, ...updates };
|
|
3619
|
+
saveStore(next);
|
|
3620
|
+
return next;
|
|
3621
|
+
});
|
|
3622
|
+
};
|
|
3623
|
+
const toggleTheme = (theme) => {
|
|
3624
|
+
setStore((prev) => {
|
|
3625
|
+
const next = {
|
|
3626
|
+
theme: theme ?? (prev.theme === "light" ? "dark" : "light"),
|
|
3627
|
+
isManual: true
|
|
3628
|
+
};
|
|
3629
|
+
saveStore(next);
|
|
3630
|
+
return next;
|
|
3631
|
+
});
|
|
3632
|
+
};
|
|
3633
|
+
return { ...store, update, toggleTheme };
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3550
3636
|
// src/react/index.ts
|
|
3551
3637
|
function useDebounce(value, delay = 500) {
|
|
3552
3638
|
const [debouncedValue, setDebouncedValue] = React11__namespace.default.useState(value);
|
|
@@ -3607,4 +3693,5 @@ function useMatchMedia2(queries, defaultValues = []) {
|
|
|
3607
3693
|
exports.default = block_default;
|
|
3608
3694
|
exports.useDebounce = useDebounce;
|
|
3609
3695
|
exports.useMatchMedia = useMatchMedia2;
|
|
3696
|
+
exports.useTheme = useTheme;
|
|
3610
3697
|
exports.useThrottle = useThrottle;
|
package/dist/react/index.d.cts
CHANGED
|
@@ -20991,6 +20991,23 @@ type BlockComponent = typeof Block & {
|
|
|
20991
20991
|
};
|
|
20992
20992
|
declare const CompoundBlock: BlockComponent;
|
|
20993
20993
|
|
|
20994
|
+
type Theme = "light" | "dark";
|
|
20995
|
+
type ThemeStore = {
|
|
20996
|
+
theme: Theme;
|
|
20997
|
+
isManual: boolean;
|
|
20998
|
+
};
|
|
20999
|
+
|
|
21000
|
+
/**
|
|
21001
|
+
* Hook to manage light/dark theme
|
|
21002
|
+
* Syncs with localStorage and across components using events
|
|
21003
|
+
*/
|
|
21004
|
+
declare function useTheme(): {
|
|
21005
|
+
update: (updates: Partial<ThemeStore>) => void;
|
|
21006
|
+
toggleTheme: (theme?: "light" | "dark") => void;
|
|
21007
|
+
theme: Theme;
|
|
21008
|
+
isManual: boolean;
|
|
21009
|
+
};
|
|
21010
|
+
|
|
20994
21011
|
/**
|
|
20995
21012
|
* React module - Block component, hooks, and types
|
|
20996
21013
|
*
|
|
@@ -21033,4 +21050,4 @@ declare function useThrottle(value: string, interval?: number): string;
|
|
|
21033
21050
|
*/
|
|
21034
21051
|
declare function useMatchMedia(queries: MediaQuery, defaultValues?: MatchedMedia): MatchedMedia;
|
|
21035
21052
|
|
|
21036
|
-
export { type MatchedMedia, type MediaQuery, type RadioOption, CompoundBlock as default, useDebounce, useMatchMedia, useThrottle };
|
|
21053
|
+
export { type MatchedMedia, type MediaQuery, type RadioOption, type Theme, type ThemeStore, CompoundBlock as default, useDebounce, useMatchMedia, useTheme, useThrottle };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -20991,6 +20991,23 @@ type BlockComponent = typeof Block & {
|
|
|
20991
20991
|
};
|
|
20992
20992
|
declare const CompoundBlock: BlockComponent;
|
|
20993
20993
|
|
|
20994
|
+
type Theme = "light" | "dark";
|
|
20995
|
+
type ThemeStore = {
|
|
20996
|
+
theme: Theme;
|
|
20997
|
+
isManual: boolean;
|
|
20998
|
+
};
|
|
20999
|
+
|
|
21000
|
+
/**
|
|
21001
|
+
* Hook to manage light/dark theme
|
|
21002
|
+
* Syncs with localStorage and across components using events
|
|
21003
|
+
*/
|
|
21004
|
+
declare function useTheme(): {
|
|
21005
|
+
update: (updates: Partial<ThemeStore>) => void;
|
|
21006
|
+
toggleTheme: (theme?: "light" | "dark") => void;
|
|
21007
|
+
theme: Theme;
|
|
21008
|
+
isManual: boolean;
|
|
21009
|
+
};
|
|
21010
|
+
|
|
20994
21011
|
/**
|
|
20995
21012
|
* React module - Block component, hooks, and types
|
|
20996
21013
|
*
|
|
@@ -21033,4 +21050,4 @@ declare function useThrottle(value: string, interval?: number): string;
|
|
|
21033
21050
|
*/
|
|
21034
21051
|
declare function useMatchMedia(queries: MediaQuery, defaultValues?: MatchedMedia): MatchedMedia;
|
|
21035
21052
|
|
|
21036
|
-
export { type MatchedMedia, type MediaQuery, type RadioOption, CompoundBlock as default, useDebounce, useMatchMedia, useThrottle };
|
|
21053
|
+
export { type MatchedMedia, type MediaQuery, type RadioOption, type Theme, type ThemeStore, CompoundBlock as default, useDebounce, useMatchMedia, useTheme, useThrottle };
|
package/dist/react/index.js
CHANGED
|
@@ -3524,6 +3524,92 @@ var CompoundBlock = Object.assign(Block, {
|
|
|
3524
3524
|
});
|
|
3525
3525
|
var block_default = CompoundBlock;
|
|
3526
3526
|
|
|
3527
|
+
// src/react/use-theme/literals.ts
|
|
3528
|
+
var THEME_STORAGE_KEY = "theme";
|
|
3529
|
+
var THEME_STORE_STORAGE_KEY = "themeStore";
|
|
3530
|
+
var THEME_CHANGE_EVENT = "qstd:theme-change";
|
|
3531
|
+
|
|
3532
|
+
// src/react/use-theme/fns.ts
|
|
3533
|
+
var getInitialTheme = () => {
|
|
3534
|
+
if (typeof window === "undefined") return "light";
|
|
3535
|
+
const stored = localStorage.getItem(THEME_STORAGE_KEY);
|
|
3536
|
+
return stored === "light" || stored === "dark" ? stored : "light";
|
|
3537
|
+
};
|
|
3538
|
+
var getInitialStore = () => {
|
|
3539
|
+
if (typeof window === "undefined") {
|
|
3540
|
+
return { theme: "light", isManual: false };
|
|
3541
|
+
}
|
|
3542
|
+
try {
|
|
3543
|
+
const stored = localStorage.getItem(THEME_STORE_STORAGE_KEY);
|
|
3544
|
+
if (stored) {
|
|
3545
|
+
const parsed = JSON.parse(stored);
|
|
3546
|
+
return {
|
|
3547
|
+
theme: parsed.theme ?? getInitialTheme(),
|
|
3548
|
+
isManual: parsed.isManual ?? false
|
|
3549
|
+
};
|
|
3550
|
+
}
|
|
3551
|
+
} catch {
|
|
3552
|
+
}
|
|
3553
|
+
return {
|
|
3554
|
+
theme: getInitialTheme(),
|
|
3555
|
+
isManual: false
|
|
3556
|
+
};
|
|
3557
|
+
};
|
|
3558
|
+
var saveStore = (store) => {
|
|
3559
|
+
if (typeof window === "undefined") return;
|
|
3560
|
+
try {
|
|
3561
|
+
localStorage.setItem(THEME_STORAGE_KEY, store.theme);
|
|
3562
|
+
localStorage.setItem(THEME_STORE_STORAGE_KEY, JSON.stringify(store));
|
|
3563
|
+
window.dispatchEvent(
|
|
3564
|
+
new CustomEvent(THEME_CHANGE_EVENT, { detail: store })
|
|
3565
|
+
);
|
|
3566
|
+
} catch {
|
|
3567
|
+
}
|
|
3568
|
+
};
|
|
3569
|
+
|
|
3570
|
+
// src/react/use-theme/index.ts
|
|
3571
|
+
function useTheme() {
|
|
3572
|
+
const [store, setStore] = React11__default.useState(getInitialStore);
|
|
3573
|
+
React11__default.useEffect(() => {
|
|
3574
|
+
if (typeof window === "undefined") return;
|
|
3575
|
+
const handleStorageChange = (e) => {
|
|
3576
|
+
if (e.key === THEME_STORAGE_KEY || e.key === THEME_STORE_STORAGE_KEY) {
|
|
3577
|
+
setStore(getInitialStore());
|
|
3578
|
+
}
|
|
3579
|
+
};
|
|
3580
|
+
const handleThemeChange = (e) => {
|
|
3581
|
+
const customEvent = e;
|
|
3582
|
+
if (customEvent.detail) {
|
|
3583
|
+
setStore(customEvent.detail);
|
|
3584
|
+
}
|
|
3585
|
+
};
|
|
3586
|
+
window.addEventListener("storage", handleStorageChange);
|
|
3587
|
+
window.addEventListener(THEME_CHANGE_EVENT, handleThemeChange);
|
|
3588
|
+
return () => {
|
|
3589
|
+
window.removeEventListener("storage", handleStorageChange);
|
|
3590
|
+
window.removeEventListener(THEME_CHANGE_EVENT, handleThemeChange);
|
|
3591
|
+
};
|
|
3592
|
+
}, []);
|
|
3593
|
+
const update = (updates) => {
|
|
3594
|
+
setStore((prev) => {
|
|
3595
|
+
const next = { ...prev, ...updates };
|
|
3596
|
+
saveStore(next);
|
|
3597
|
+
return next;
|
|
3598
|
+
});
|
|
3599
|
+
};
|
|
3600
|
+
const toggleTheme = (theme) => {
|
|
3601
|
+
setStore((prev) => {
|
|
3602
|
+
const next = {
|
|
3603
|
+
theme: theme ?? (prev.theme === "light" ? "dark" : "light"),
|
|
3604
|
+
isManual: true
|
|
3605
|
+
};
|
|
3606
|
+
saveStore(next);
|
|
3607
|
+
return next;
|
|
3608
|
+
});
|
|
3609
|
+
};
|
|
3610
|
+
return { ...store, update, toggleTheme };
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3527
3613
|
// src/react/index.ts
|
|
3528
3614
|
function useDebounce(value, delay = 500) {
|
|
3529
3615
|
const [debouncedValue, setDebouncedValue] = React11__default.useState(value);
|
|
@@ -3581,4 +3667,4 @@ function useMatchMedia2(queries, defaultValues = []) {
|
|
|
3581
3667
|
return value;
|
|
3582
3668
|
}
|
|
3583
3669
|
|
|
3584
|
-
export { block_default as default, useDebounce, useMatchMedia2 as useMatchMedia, useThrottle };
|
|
3670
|
+
export { block_default as default, useDebounce, useMatchMedia2 as useMatchMedia, useTheme, useThrottle };
|
package/dist/server/index.cjs
CHANGED
|
@@ -521,6 +521,28 @@ var hexColor = () => {
|
|
|
521
521
|
return hex;
|
|
522
522
|
};
|
|
523
523
|
|
|
524
|
+
// src/shared/log.ts
|
|
525
|
+
var log_exports = {};
|
|
526
|
+
__export(log_exports, {
|
|
527
|
+
error: () => error,
|
|
528
|
+
info: () => info,
|
|
529
|
+
log: () => log,
|
|
530
|
+
warn: () => warn
|
|
531
|
+
});
|
|
532
|
+
var stringify = (value) => JSON.stringify(value, null, 2);
|
|
533
|
+
var log = (...values) => {
|
|
534
|
+
console.log(...values.map(stringify));
|
|
535
|
+
};
|
|
536
|
+
var info = (...values) => {
|
|
537
|
+
console.log("[info]", ...values.map(stringify));
|
|
538
|
+
};
|
|
539
|
+
var warn = (...values) => {
|
|
540
|
+
console.log("[warn]", ...values.map(stringify));
|
|
541
|
+
};
|
|
542
|
+
var error = (...values) => {
|
|
543
|
+
console.log("[error]", ...values.map(stringify));
|
|
544
|
+
};
|
|
545
|
+
|
|
524
546
|
// src/server/file.ts
|
|
525
547
|
var file_exports = {};
|
|
526
548
|
__export(file_exports, {
|
|
@@ -535,6 +557,7 @@ exports.File = file_exports;
|
|
|
535
557
|
exports.Flow = flow_exports;
|
|
536
558
|
exports.Int = int_exports;
|
|
537
559
|
exports.List = list_exports;
|
|
560
|
+
exports.Log = log_exports;
|
|
538
561
|
exports.Money = money_exports;
|
|
539
562
|
exports.Random = random_exports;
|
|
540
563
|
exports.Str = str_exports;
|
package/dist/server/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as Dict, f as Flow, i as Int, l as List, m as Money, r as Random, s as Str, t as Time } from '../
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-DPBPow2d.cjs';
|
|
2
2
|
import 'date-fns';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { d as Dict, f as Flow, i as Int, l as List, m as Money, r as Random, s as Str, t as Time } from '../
|
|
1
|
+
export { d as Dict, f as Flow, i as Int, l as List, a as Log, m as Money, r as Random, s as Str, t as Time } from '../log-DPBPow2d.js';
|
|
2
2
|
import 'date-fns';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/server/index.js
CHANGED
|
@@ -515,6 +515,28 @@ var hexColor = () => {
|
|
|
515
515
|
return hex;
|
|
516
516
|
};
|
|
517
517
|
|
|
518
|
+
// src/shared/log.ts
|
|
519
|
+
var log_exports = {};
|
|
520
|
+
__export(log_exports, {
|
|
521
|
+
error: () => error,
|
|
522
|
+
info: () => info,
|
|
523
|
+
log: () => log,
|
|
524
|
+
warn: () => warn
|
|
525
|
+
});
|
|
526
|
+
var stringify = (value) => JSON.stringify(value, null, 2);
|
|
527
|
+
var log = (...values) => {
|
|
528
|
+
console.log(...values.map(stringify));
|
|
529
|
+
};
|
|
530
|
+
var info = (...values) => {
|
|
531
|
+
console.log("[info]", ...values.map(stringify));
|
|
532
|
+
};
|
|
533
|
+
var warn = (...values) => {
|
|
534
|
+
console.log("[warn]", ...values.map(stringify));
|
|
535
|
+
};
|
|
536
|
+
var error = (...values) => {
|
|
537
|
+
console.log("[error]", ...values.map(stringify));
|
|
538
|
+
};
|
|
539
|
+
|
|
518
540
|
// src/server/file.ts
|
|
519
541
|
var file_exports = {};
|
|
520
542
|
__export(file_exports, {
|
|
@@ -524,4 +546,4 @@ var readFile = (filePath, encoding = "utf-8") => {
|
|
|
524
546
|
return fs.readFileSync(filePath, encoding);
|
|
525
547
|
};
|
|
526
548
|
|
|
527
|
-
export { dict_exports as Dict, file_exports as File, flow_exports as Flow, int_exports as Int, list_exports as List, money_exports as Money, random_exports as Random, str_exports as Str, time_exports as Time };
|
|
549
|
+
export { dict_exports as Dict, file_exports as File, flow_exports as Flow, int_exports as Int, list_exports as List, log_exports as Log, money_exports as Money, random_exports as Random, str_exports as Str, time_exports as Time };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qstd",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Standard Block component and utilities library with Panda CSS",
|
|
5
5
|
"author": "malin1",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,6 +41,22 @@
|
|
|
41
41
|
"sideEffects": [
|
|
42
42
|
"dist/react/index.css"
|
|
43
43
|
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "panda codegen && panda cssgen && tsup && node scripts/inject-css-import.js",
|
|
46
|
+
"dev": "tsup --watch",
|
|
47
|
+
"prepublishOnly": "pnpm build",
|
|
48
|
+
"prepare:local": "pnpm build && cd playground && pnpm prepare",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"test:watch": "vitest",
|
|
51
|
+
"test:all": "pnpx tsx tests/test-all.ts",
|
|
52
|
+
"test:block": "node tests/test-block.tsx",
|
|
53
|
+
"test:playground": "node tests/playground-e2e.mjs",
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"typecheck:perf": "tsc --noEmit --extendedDiagnostics",
|
|
56
|
+
"typecheck:trace": "tsc --noEmit --generateTrace ./performance/ts-trace",
|
|
57
|
+
"analyze:tsserver": "bash performance/analyze-tsserver.sh",
|
|
58
|
+
"lint": "eslint src --ext ts,tsx"
|
|
59
|
+
},
|
|
44
60
|
"peerDependencies": {
|
|
45
61
|
"react": "^18.0.0 || ^19.0.0",
|
|
46
62
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
@@ -93,20 +109,5 @@
|
|
|
93
109
|
"bugs": {
|
|
94
110
|
"url": "https://github.com/55cancri/qstd/issues"
|
|
95
111
|
},
|
|
96
|
-
"homepage": "https://github.com/55cancri/qstd#readme"
|
|
97
|
-
|
|
98
|
-
"build": "panda codegen && panda cssgen && tsup && node scripts/inject-css-import.js",
|
|
99
|
-
"dev": "tsup --watch",
|
|
100
|
-
"prepare:local": "pnpm build && cd playground && pnpm prepare",
|
|
101
|
-
"test": "vitest run",
|
|
102
|
-
"test:watch": "vitest",
|
|
103
|
-
"test:all": "pnpx tsx tests/test-all.ts",
|
|
104
|
-
"test:block": "node tests/test-block.tsx",
|
|
105
|
-
"test:playground": "node tests/playground-e2e.mjs",
|
|
106
|
-
"typecheck": "tsc --noEmit",
|
|
107
|
-
"typecheck:perf": "tsc --noEmit --extendedDiagnostics",
|
|
108
|
-
"typecheck:trace": "tsc --noEmit --generateTrace ./performance/ts-trace",
|
|
109
|
-
"analyze:tsserver": "bash performance/analyze-tsserver.sh",
|
|
110
|
-
"lint": "eslint src --ext ts,tsx"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
112
|
+
"homepage": "https://github.com/55cancri/qstd#readme"
|
|
113
|
+
}
|