polen 0.2.0-next.1 → 0.2.0-next.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.
@@ -1,4 +1,8 @@
1
- type DebugParameters = [event: string, payload?: unknown];
2
- export declare const create: (namespace?: string) => (...args: DebugParameters) => void;
3
- export declare const debug: (event: string, payload?: unknown) => void;
4
- export {};
1
+ export declare const create: (namespace?: string) => {
2
+ (event: string, payload?: unknown): void;
3
+ toggle(isEnabled: boolean): void;
4
+ };
5
+ export declare const debug: {
6
+ (event: string, payload?: unknown): void;
7
+ toggle(isEnabled: boolean): void;
8
+ };
@@ -2,12 +2,15 @@ import { inspect } from 'node:util';
2
2
  import { colorize } from 'consola/utils';
3
3
  import { snakeCase } from 'es-toolkit';
4
4
  export const create = (namespace) => {
5
- return (...args) => {
6
- const isDebug = process.env[`DEBUG`] === `true` || process.env[`DEBUG`] === `*` ||
7
- process.env[`DEBUG`] === `1`;
5
+ const isDebugEnabled = process.env[`DEBUG`] === `true` || process.env[`DEBUG`] === `*` ||
6
+ process.env[`DEBUG`] === `1`;
7
+ const state = {
8
+ isEnabled: isDebugEnabled,
9
+ };
10
+ const debug = (...args) => {
8
11
  const isPayloadPassed = args.length === 2;
9
12
  const [event, payload] = args;
10
- if (isDebug) {
13
+ if (state.isEnabled) {
11
14
  const debugDepth = parseNumberOr(process.env[`DEBUG_DEPTH`], 0);
12
15
  const isPayloadDisabled = debugDepth < 0;
13
16
  const payloadRendered = isPayloadPassed && !isPayloadDisabled
@@ -26,6 +29,10 @@ export const create = (namespace) => {
26
29
  console.debug(prefixRendered, payloadRendered);
27
30
  }
28
31
  };
32
+ debug.toggle = (isEnabled) => {
33
+ state.isEnabled = isEnabled;
34
+ };
35
+ return debug;
29
36
  };
30
37
  export const debug = create();
31
38
  const parseNumberOr = (str, defaultValue) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polen",
3
- "version": "0.2.0-next.1",
3
+ "version": "0.2.0-next.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "examples:unlink": "rm -rf examples/{basic,github}/pnpm-workspace.yaml && git checkout examples/*/pnpm-lock.yaml",
@@ -20,7 +20,8 @@
20
20
  "check:types": "tsc --noEmit",
21
21
  "check:package": "publint run --strict",
22
22
  "release:version": "changeset version && git commit -am \"chore: release\" && git push",
23
- "prepublishOnly": "pnpm build"
23
+ "prepublishOnly": "pnpm build",
24
+ "project:example-controller": "tsx ./scripts/example-controller.ts"
24
25
  },
25
26
  "repository": {
26
27
  "type": "git",
@@ -54,6 +55,7 @@
54
55
  "devDependencies": {
55
56
  "@changesets/cli": "^2.28.1",
56
57
  "@eslint/js": "^9.24.0",
58
+ "@molt/command": "^0.9.0",
57
59
  "@playwright/browser-chromium": "^1.51.1",
58
60
  "@stylistic/eslint-plugin": "^4.2.0",
59
61
  "@tsconfig/strictest": "^2.0.5",
@@ -70,15 +72,18 @@
70
72
  "eslint-plugin-react-refresh": "^0.4.19",
71
73
  "eslint-plugin-tsdoc": "^0.4.0",
72
74
  "eslint-plugin-unused-imports": "^4.1.4",
75
+ "fs-jetpack": "^5.1.0",
73
76
  "globals": "^16.0.0",
74
77
  "playwright": "^1.51.1",
75
78
  "publint": "^0.3.11",
76
79
  "strip-ansi": "^7.1.0",
77
80
  "tsx": "^4.19.3",
81
+ "type-fest": "^4.39.1",
78
82
  "typescript": "^5.8.3",
79
83
  "typescript-eslint": "^8.29.1",
80
84
  "vite": "^6.2.6",
81
85
  "vite-tsconfig-paths": "^5.1.4",
86
+ "zod": "^3.24.2",
82
87
  "zx": "^8.5.2"
83
88
  },
84
89
  "packageManager": "pnpm@10.8.0",