polen 0.9.0 → 0.9.1-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.
- package/README.md +3 -3
- package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts.map +1 -1
- package/build/api/schema/data-sources/schema-directory/schema-directory.js +2 -1
- package/build/api/schema/data-sources/schema-directory/schema-directory.js.map +1 -1
- package/build/lib/vite-virtual/debug.d.ts +1 -1
- package/build/lib/vite-virtual/debug.d.ts.map +1 -1
- package/build/lib/vite-virtual/debug.js +1 -1
- package/build/lib/vite-virtual/debug.js.map +1 -1
- package/build/singletons/debug.d.ts +1 -1
- package/build/singletons/debug.d.ts.map +1 -1
- package/build/singletons/debug.js +1 -1
- package/build/singletons/debug.js.map +1 -1
- package/package.json +26 -20
- package/src/api/schema/data-sources/schema-directory/schema-directory.ts +2 -1
- package/src/lib/vite-virtual/debug.ts +1 -1
- package/src/singletons/debug.ts +1 -1
- package/build/lib/debug/debug.d.ts +0 -13
- package/build/lib/debug/debug.d.ts.map +0 -1
- package/build/lib/debug/debug.js +0 -86
- package/build/lib/debug/debug.js.map +0 -1
- package/build/lib/debug/environment-variable.d.ts +0 -6
- package/build/lib/debug/environment-variable.d.ts.map +0 -1
- package/build/lib/debug/environment-variable.js +0 -48
- package/build/lib/debug/environment-variable.js.map +0 -1
- package/build/lib/debug/index.d.ts +0 -2
- package/build/lib/debug/index.d.ts.map +0 -1
- package/build/lib/debug/index.js +0 -2
- package/build/lib/debug/index.js.map +0 -1
- package/src/lib/debug/debug.ts +0 -120
- package/src/lib/debug/environment-variable.ts +0 -56
- package/src/lib/debug/index.ts +0 -1
package/README.md
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"schema-directory.d.ts","sourceRoot":"","sources":["../../../../../src/api/schema/data-sources/schema-directory/schema-directory.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;
|
1
|
+
{"version":3,"file":"schema-directory.d.ts","sourceRoot":"","sources":["../../../../../src/api/schema/data-sources/schema-directory/schema-directory.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAU7C,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,eAAe,GAAI,aAAa,WAAW,KAAG,MAO1D,CAAA;AAED,eAAO,MAAM,WAAW,GAAU,aAAa,WAAW,KAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAgEjF,CAAA"}
|
@@ -4,7 +4,8 @@ import { debug as debugPolen } from '#singletons/debug';
|
|
4
4
|
import { Arr, Path } from '@wollybeard/kit';
|
5
5
|
import { glob } from 'tinyglobby';
|
6
6
|
import { FileNameExpression } from "./file-name-expression/index.js";
|
7
|
-
const debug = debugPolen.sub([`schema`, `data-source-schema-directory`])
|
7
|
+
// const debug = debugPolen.sub([`schema`, `data-source-schema-directory`])
|
8
|
+
const debug = debugPolen.sub(`schema:data-source-schema-directory`);
|
8
9
|
const defaultPaths = {
|
9
10
|
schemaDirectory: `./schema`,
|
10
11
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"schema-directory.js","sourceRoot":"","sources":["../../../../../src/api/schema/data-sources/schema-directory/schema-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAEpE,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,
|
1
|
+
{"version":3,"file":"schema-directory.js","sourceRoot":"","sources":["../../../../../src/api/schema/data-sources/schema-directory/schema-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AAEpE,2EAA2E;AAC3E,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAA;AAEnE,MAAM,YAAY,GAAG;IACnB,eAAe,EAAE,UAAU;CAC5B,CAAA;AAWD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,WAAwB,EAAU,EAAE;IAClE,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAA;IACvE,MAAM,MAAM,GAAW;QACrB,IAAI,EAAE,cAAc,CAAC,WAAW,CAAC,IAAI,IAAI,YAAY,CAAC,eAAe,CAAC;KACvE,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,WAAwB,EAA0B,EAAE;IACpF,MAAM,MAAM,GAAG,eAAe,CAAC,WAAW,CAAC,CAAA;IAE3C,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;IAC5B,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC;QAC3B,GAAG,EAAE,MAAM,CAAC,IAAI;QAChB,QAAQ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AQ,GAAG,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;QAEpC,MAAM,MAAM,GAAG,QAAQ,EAAE,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAA;QACvD,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAA;QAE5B,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,aAAa,CAAC;YAChD,MAAM;YACN,KAAK;SACN,CAAC,CAAA;QAEF,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,MAAM;YACN,KAAK;YACL,OAAO;SACR,CAAA;IACH,CAAC,CAAC,CACH,CAAA;IAED,UAAU,CAAC,OAAO,EAAE,CAAA;IAEpB,MAAM,MAAM,GAAW;QACrB,QAAQ,EAAE,UAAU;KACrB,CAAA;IAED,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAExB,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/lib/vite-virtual/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/lib/vite-virtual/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,eAAO,MAAM,KAAK,aAA+B,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/lib/vite-virtual/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/lib/vite-virtual/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/singletons/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/singletons/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,eAAO,MAAM,KAAK,aAAwB,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/singletons/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/singletons/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAEvC,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "polen",
|
3
|
-
"version": "0.9.
|
3
|
+
"version": "0.9.1-next.2",
|
4
4
|
"type": "module",
|
5
5
|
"description": "A framework for delightful GraphQL developer portals",
|
6
6
|
"author": {
|
@@ -77,15 +77,15 @@
|
|
77
77
|
"@mdx-js/rollup": "^3.1.0",
|
78
78
|
"@radix-ui/react-icons": "^1.3.2",
|
79
79
|
"@radix-ui/themes": "^3.2.1",
|
80
|
-
"@rolldown/pluginutils": "1.0.0-beta.
|
80
|
+
"@rolldown/pluginutils": "1.0.0-beta.16",
|
81
81
|
"@rollup/pluginutils": "^5.1.4",
|
82
82
|
"@shikijs/rehype": "^3.6.0",
|
83
83
|
"@shikijs/transformers": "^3.6.0",
|
84
84
|
"@shikijs/twoslash": "^3.6.0",
|
85
|
-
"@swc/core": "^1.
|
85
|
+
"@swc/core": "^1.12.1",
|
86
86
|
"@types/jsesc": "^3.0.3",
|
87
|
-
"@vitejs/plugin-react": "^4.5.
|
88
|
-
"@vitejs/plugin-react-oxc": "^0.2.
|
87
|
+
"@vitejs/plugin-react": "^4.5.2",
|
88
|
+
"@vitejs/plugin-react-oxc": "^0.2.3",
|
89
89
|
"@vue/reactivity": "^3.5.16",
|
90
90
|
"@wollybeard/kit": "^0.35.0",
|
91
91
|
"@wollybeard/projector": "^0.2.0",
|
@@ -110,17 +110,17 @@
|
|
110
110
|
"remark-parse": "^11.0.0",
|
111
111
|
"remark-rehype": "^11.1.2",
|
112
112
|
"resolve.imports": "^2.0.3",
|
113
|
-
"rolldown": "1.0.0-beta.
|
113
|
+
"rolldown": "1.0.0-beta.16",
|
114
114
|
"shiki": "^3.6.0",
|
115
115
|
"source-map": "^0.7.4",
|
116
116
|
"superjson": "^2.2.2",
|
117
117
|
"tinyglobby": "^0.2.14",
|
118
|
-
"tsx": "^4.
|
118
|
+
"tsx": "^4.20.3",
|
119
119
|
"typescript": "^5.8.3",
|
120
120
|
"unified": "^11.0.5",
|
121
121
|
"vfile": "^6.0.3",
|
122
|
-
"vite": "npm:rolldown-vite@~6.3.
|
123
|
-
"vite-plugin-inspect": "^11.
|
122
|
+
"vite": "npm:rolldown-vite@~6.3.21",
|
123
|
+
"vite-plugin-inspect": "^11.2.0",
|
124
124
|
"vite-plugin-restart": "^0.4.2",
|
125
125
|
"youch-core": "^0.3.2",
|
126
126
|
"zx": "8.5.5"
|
@@ -132,23 +132,24 @@
|
|
132
132
|
"@actions/glob": "^0.5.0",
|
133
133
|
"@actions/io": "^1.1.3",
|
134
134
|
"@changesets/cli": "^2.29.4",
|
135
|
-
"@eslint/js": "^9.
|
135
|
+
"@eslint/js": "^9.29.0",
|
136
136
|
"@molt/command": "^0.9.0",
|
137
137
|
"@octokit/core": "^7.0.2",
|
138
138
|
"@octokit/types": "^14.1.0",
|
139
|
-
"@playwright/browser-chromium": "^1.
|
139
|
+
"@playwright/browser-chromium": "^1.53.0",
|
140
140
|
"@stylistic/eslint-plugin": "^4.4.1",
|
141
141
|
"@tsconfig/node-lts": "^22.0.1",
|
142
142
|
"@tsconfig/node22": "^22.0.2",
|
143
143
|
"@tsconfig/strictest": "^2.0.5",
|
144
|
-
"@types/node": "^
|
145
|
-
"@types/react": "^19.1.
|
144
|
+
"@types/node": "^24.0.3",
|
145
|
+
"@types/react": "^19.1.8",
|
146
146
|
"@types/react-dom": "^19.1.6",
|
147
|
-
"@
|
148
|
-
"@typescript-eslint/
|
147
|
+
"@types/semver": "^7.7.0",
|
148
|
+
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
149
|
+
"@typescript-eslint/parser": "^8.34.0",
|
149
150
|
"dprint": "^0.50.0",
|
150
151
|
"dripip": "^0.10.0",
|
151
|
-
"eslint": "^9.
|
152
|
+
"eslint": "^9.29.0",
|
152
153
|
"eslint-plugin-deprecation": "^3.0.0",
|
153
154
|
"eslint-plugin-only-warn": "^1.1.0",
|
154
155
|
"eslint-plugin-react-hooks": "^5.2.0",
|
@@ -158,19 +159,23 @@
|
|
158
159
|
"fs-jetpack": "^5.1.0",
|
159
160
|
"get-port-please": "^3.1.2",
|
160
161
|
"globals": "^16.2.0",
|
161
|
-
"playwright": "1.53.0
|
162
|
+
"playwright": "1.53.0",
|
162
163
|
"publint": "^0.3.12",
|
163
164
|
"semver": "^7.7.2",
|
164
165
|
"strip-ansi": "^7.1.0",
|
165
166
|
"type-fest": "^4.41.0",
|
166
167
|
"typescript": "^5.8.3",
|
167
|
-
"typescript-eslint": "^8.
|
168
|
+
"typescript-eslint": "^8.34.0",
|
168
169
|
"vite-tsconfig-paths": "^5.1.4",
|
169
|
-
"vitest": "^3.2.
|
170
|
-
"zod": "^3.25.
|
170
|
+
"vitest": "^3.2.3",
|
171
|
+
"zod": "^3.25.64"
|
171
172
|
},
|
172
173
|
"packageManager": "pnpm@10.11.1",
|
173
174
|
"scripts": {
|
175
|
+
"gh:demos-rebuild": "gh workflow run demos-rebuild.yaml -f since_version=0.9.0-next.8",
|
176
|
+
"gh:demos-rebuild:list": "gh run list --workflow=demos-rebuild.yaml",
|
177
|
+
"gh:demos-rebuild:logs": "gh run view $(gh run list --workflow=demos-rebuild.yaml --limit=1 --json databaseId -q '.[0].databaseId') --log",
|
178
|
+
"gh:demos-rebuild:watch": "gh run watch $(gh run list --workflow=demos-rebuild.yaml --limit=1 --json databaseId -q '.[0].databaseId')",
|
174
179
|
"sandbox": "tsx src/sandbox",
|
175
180
|
"sandbox:watch": "tsx --watch src/sandbox",
|
176
181
|
"sb": "pnpm sandbox",
|
@@ -181,6 +186,7 @@
|
|
181
186
|
"test:unit": "vitest",
|
182
187
|
"dev": "pnpm build:watch:emit",
|
183
188
|
"dev:pokemon": "pnpm polen dev --project examples/pokemon",
|
189
|
+
"dev:demo-index": "node --no-warnings ./scripts/build-demos-index.ts --mode dev --serve",
|
184
190
|
"build:demos": "zx ./scripts/build-demos.mjs",
|
185
191
|
"build:clean": "pnpm tsc --build tsconfig.build.json --clean && rm -rf build",
|
186
192
|
"build": "tsc --build tsconfig.build.json",
|
@@ -7,7 +7,8 @@ import { glob } from 'tinyglobby'
|
|
7
7
|
import type { Schema } from '../../schema.ts'
|
8
8
|
import { FileNameExpression } from './file-name-expression/index.ts'
|
9
9
|
|
10
|
-
const debug = debugPolen.sub([`schema`, `data-source-schema-directory`])
|
10
|
+
// const debug = debugPolen.sub([`schema`, `data-source-schema-directory`])
|
11
|
+
const debug = debugPolen.sub(`schema:data-source-schema-directory`)
|
11
12
|
|
12
13
|
const defaultPaths = {
|
13
14
|
schemaDirectory: `./schema`,
|
package/src/singletons/debug.ts
CHANGED
@@ -1,13 +0,0 @@
|
|
1
|
-
type DebugParameters = [event: string, payload?: unknown];
|
2
|
-
export interface Debug {
|
3
|
-
(...args: DebugParameters): void;
|
4
|
-
toggle: (isEnabled: boolean) => void;
|
5
|
-
sub: (subNamespace: string | string[]) => Debug;
|
6
|
-
}
|
7
|
-
interface State {
|
8
|
-
isEnabled: boolean;
|
9
|
-
}
|
10
|
-
export declare const create: (namespaceInput?: string | string[], initialState?: State) => Debug;
|
11
|
-
export declare const debugGlobal: Debug;
|
12
|
-
export {};
|
13
|
-
//# sourceMappingURL=debug.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../../src/lib/debug/debug.ts"],"names":[],"mappings":"AAKA,KAAK,eAAe,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAA;AAEzD,MAAM,WAAW,KAAK;IACpB,CAAC,GAAG,IAAI,EAAE,eAAe,GAAG,IAAI,CAAA;IAChC,MAAM,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;IACpC,GAAG,EAAE,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,KAAK,CAAA;CAChD;AAED,UAAU,KAAK;IACb,SAAS,EAAE,OAAO,CAAA;CACnB;AAgCD,eAAO,MAAM,MAAM,GAAI,iBAAiB,MAAM,GAAG,MAAM,EAAE,EAAE,eAAe,KAAK,KAAG,KA0DjF,CAAA;AAcD,eAAO,MAAM,WAAW,OAAW,CAAA"}
|
package/build/lib/debug/debug.js
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
import { Arr, Str } from '@wollybeard/kit';
|
2
|
-
import { colorize } from 'consola/utils';
|
3
|
-
import { inspect } from 'node:util';
|
4
|
-
import { calcIsEnabledFromEnv } from "./environment-variable.js";
|
5
|
-
// todo:
|
6
|
-
// const Option = {
|
7
|
-
// else:
|
8
|
-
// <alternative>(alternative: alternative) => <value>(value: value): value extends undefined ? alternative : value => {
|
9
|
-
// if (value === undefined || value === null) {
|
10
|
-
// return alternative as any
|
11
|
-
// }
|
12
|
-
// return value as any
|
13
|
-
// },
|
14
|
-
// }
|
15
|
-
// const namespaceToString = (namespace: string[] = []): string => {
|
16
|
-
// return formatNamespaceSegment(namespace.join(`_`))
|
17
|
-
// // todo:
|
18
|
-
// // const x = Option.else([] as string[])
|
19
|
-
// // const y = x(namespace)
|
20
|
-
// // const z = Fn.pipe(
|
21
|
-
// // namespace,
|
22
|
-
// // x,
|
23
|
-
// // // Option.else([]),
|
24
|
-
// // // (_) => Array.is(_) ? _ : [],
|
25
|
-
// // // Str.joinWith(`_`),
|
26
|
-
// // // Str.Case.upper,
|
27
|
-
// // )
|
28
|
-
// }
|
29
|
-
const formatNamespaceSegment = (segment) => {
|
30
|
-
return Str.Case.snake(segment).toUpperCase();
|
31
|
-
};
|
32
|
-
export const create = (namespaceInput, initialState) => {
|
33
|
-
const namespace = Arr.sure(namespaceInput ?? []);
|
34
|
-
const isDebugEnabledFromEnv = calcIsEnabledFromEnv(process.env, namespace);
|
35
|
-
const state = initialState ?? {
|
36
|
-
isEnabled: isDebugEnabledFromEnv,
|
37
|
-
};
|
38
|
-
const debug = (...args) => {
|
39
|
-
const isPayloadPassed = args.length === 2;
|
40
|
-
const [event, payload] = args;
|
41
|
-
if (state.isEnabled) {
|
42
|
-
// If a payload is an array then default depth to 1 so that we see its _contents_
|
43
|
-
const isPayloadArray = Array.isArray(payload);
|
44
|
-
const depthBoost = isPayloadArray ? 1 : 0;
|
45
|
-
const defaultDepth = 3;
|
46
|
-
const debugDepth = parseNumberOr(process.env[`DEBUG_DEPTH`], defaultDepth) + depthBoost;
|
47
|
-
const isPayloadDisabled = debugDepth < 0;
|
48
|
-
const payloadRendered = isPayloadPassed && !isPayloadDisabled
|
49
|
-
? inspect(payload, {
|
50
|
-
colors: true,
|
51
|
-
depth: debugDepth,
|
52
|
-
// compact: true,
|
53
|
-
maxStringLength: 1000,
|
54
|
-
})
|
55
|
-
: ``;
|
56
|
-
const formatNamespaceSegmentAnsi = (segment) => {
|
57
|
-
return colorize(`bold`, colorize(`bgYellowBright`, ` ` + formatNamespaceSegment(segment) + ` `));
|
58
|
-
};
|
59
|
-
const namespaceRendered = namespace.map(formatNamespaceSegmentAnsi).join(` `);
|
60
|
-
const eventRendered = colorize(`bold`, colorize(`bgMagentaBright`, ` ` + formatNamespaceSegment(event) + ` `));
|
61
|
-
const prefixRendered = `${namespaceRendered} ${eventRendered}`;
|
62
|
-
console.debug(prefixRendered, payloadRendered);
|
63
|
-
}
|
64
|
-
};
|
65
|
-
debug.toggle = (isEnabled) => {
|
66
|
-
state.isEnabled = isEnabled;
|
67
|
-
};
|
68
|
-
debug.sub = (subNamespace) => {
|
69
|
-
const s = Arr.sure(subNamespace);
|
70
|
-
const stateCopy = structuredClone(state);
|
71
|
-
return create([...namespace, ...s], stateCopy);
|
72
|
-
};
|
73
|
-
return debug;
|
74
|
-
};
|
75
|
-
const parseNumberOr = (str, defaultValue) => {
|
76
|
-
if (str === ``)
|
77
|
-
return defaultValue;
|
78
|
-
const parsed = Number(str);
|
79
|
-
if (Number.isNaN(parsed)) {
|
80
|
-
return defaultValue;
|
81
|
-
}
|
82
|
-
return parsed;
|
83
|
-
};
|
84
|
-
// initialize root debug
|
85
|
-
export const debugGlobal = create();
|
86
|
-
//# sourceMappingURL=debug.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../../src/lib/debug/debug.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAchE,QAAQ;AACR,mBAAmB;AACnB,UAAU;AACV,2HAA2H;AAC3H,qDAAqD;AACrD,oCAAoC;AACpC,UAAU;AACV,4BAA4B;AAC5B,SAAS;AACT,IAAI;AAEJ,oEAAoE;AACpE,uDAAuD;AACvD,aAAa;AACb,6CAA6C;AAC7C,8BAA8B;AAC9B,0BAA0B;AAC1B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AAoB,EAAU,EAAE;IAC9E,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,YAAY,CAAA;IAEnC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;IAC1B,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,OAAO,YAAY,CAAA;IACrB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,wBAAwB;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,EAAE,CAAA"}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
export declare const enVarName = "DEBUG";
|
2
|
-
export declare const deliminator = ",";
|
3
|
-
export declare const wildcard = "*";
|
4
|
-
export declare const enVarEnabledValuesStatic: string[];
|
5
|
-
export declare const calcIsEnabledFromEnv: (enVars: Record<string, unknown>, namespace?: string[]) => boolean;
|
6
|
-
//# sourceMappingURL=environment-variable.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"environment-variable.d.ts","sourceRoot":"","sources":["../../../src/lib/debug/environment-variable.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,UAAU,CAAA;AAEhC,eAAO,MAAM,WAAW,MAAM,CAAA;AAC9B,eAAO,MAAM,QAAQ,MAAM,CAAA;AAC3B,eAAO,MAAM,wBAAwB,UAA0B,CAAA;AAE/D,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,YAAY,MAAM,EAAE,KACnB,OA4CF,CAAA"}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import { Arr, Language } from '@wollybeard/kit';
|
2
|
-
export const enVarName = `DEBUG`;
|
3
|
-
export const deliminator = `,`;
|
4
|
-
export const wildcard = `*`;
|
5
|
-
export const enVarEnabledValuesStatic = [`true`, wildcard, `1`];
|
6
|
-
export const calcIsEnabledFromEnv = (enVars, namespace) => {
|
7
|
-
const namespace_ = namespace?.map(_ => _.toLowerCase());
|
8
|
-
const includeFilters = typeof enVars[enVarName] === `string`
|
9
|
-
? enVars[enVarName]
|
10
|
-
.trim()
|
11
|
-
.toLowerCase()
|
12
|
-
.split(deliminator)
|
13
|
-
.map(patternExpression => {
|
14
|
-
return patternExpression
|
15
|
-
.trim()
|
16
|
-
.split(`:`)
|
17
|
-
.map(_ => _.trim());
|
18
|
-
})
|
19
|
-
: undefined;
|
20
|
-
if (!includeFilters)
|
21
|
-
return false;
|
22
|
-
if (includeFilters.length === 0)
|
23
|
-
return false;
|
24
|
-
// If any is like * then it means "enable everything"
|
25
|
-
if (includeFilters.some(includeFilter => {
|
26
|
-
if (includeFilter.length === 1 && enVarEnabledValuesStatic.includes(includeFilter[0]))
|
27
|
-
return true;
|
28
|
-
}))
|
29
|
-
return true;
|
30
|
-
// At this point, if there is no namespace (e.g. root), then we cannot match anything
|
31
|
-
if (!namespace_)
|
32
|
-
return false;
|
33
|
-
for (const includeFilter of includeFilters) {
|
34
|
-
if (Arr.getLast(includeFilter) !== wildcard) {
|
35
|
-
return includeFilter.join() === namespace_.join();
|
36
|
-
}
|
37
|
-
let i = 0;
|
38
|
-
for (const segment of includeFilter) {
|
39
|
-
if (segment === wildcard)
|
40
|
-
return true;
|
41
|
-
if (segment !== namespace_[i])
|
42
|
-
return false;
|
43
|
-
i++;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
Language.never();
|
47
|
-
};
|
48
|
-
//# sourceMappingURL=environment-variable.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"environment-variable.js","sourceRoot":"","sources":["../../../src/lib/debug/environment-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/C,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAA;AAEhC,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAA;AAC9B,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,CAAA;AA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AAO,aAAa,CAAC,IAAI,EAAE,KAAK,UAAU,CAAC,IAAI,EAAE,CAAA;QACnD,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,CAAA;QACT,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE,CAAC;YACpC,IAAI,OAAO,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAA;YACrC,IAAI,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAA;YAC3C,CAAC,EAAE,CAAA;QACL,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,KAAK,EAAE,CAAA;AAClB,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/debug/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA"}
|
package/build/lib/debug/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/debug/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA"}
|
package/src/lib/debug/debug.ts
DELETED
@@ -1,120 +0,0 @@
|
|
1
|
-
import { Arr, Str } from '@wollybeard/kit'
|
2
|
-
import { colorize } from 'consola/utils'
|
3
|
-
import { inspect } from 'node:util'
|
4
|
-
import { calcIsEnabledFromEnv } from './environment-variable.ts'
|
5
|
-
|
6
|
-
type DebugParameters = [event: string, payload?: unknown]
|
7
|
-
|
8
|
-
export interface Debug {
|
9
|
-
(...args: DebugParameters): void
|
10
|
-
toggle: (isEnabled: boolean) => void
|
11
|
-
sub: (subNamespace: string | string[]) => Debug
|
12
|
-
}
|
13
|
-
|
14
|
-
interface State {
|
15
|
-
isEnabled: boolean
|
16
|
-
}
|
17
|
-
|
18
|
-
// todo:
|
19
|
-
// const Option = {
|
20
|
-
// else:
|
21
|
-
// <alternative>(alternative: alternative) => <value>(value: value): value extends undefined ? alternative : value => {
|
22
|
-
// if (value === undefined || value === null) {
|
23
|
-
// return alternative as any
|
24
|
-
// }
|
25
|
-
// return value as any
|
26
|
-
// },
|
27
|
-
// }
|
28
|
-
|
29
|
-
// const namespaceToString = (namespace: string[] = []): string => {
|
30
|
-
// return formatNamespaceSegment(namespace.join(`_`))
|
31
|
-
// // todo:
|
32
|
-
// // const x = Option.else([] as string[])
|
33
|
-
// // const y = x(namespace)
|
34
|
-
// // const z = Fn.pipe(
|
35
|
-
// // namespace,
|
36
|
-
// // x,
|
37
|
-
// // // Option.else([]),
|
38
|
-
// // // (_) => Array.is(_) ? _ : [],
|
39
|
-
// // // Str.joinWith(`_`),
|
40
|
-
// // // Str.Case.upper,
|
41
|
-
// // )
|
42
|
-
// }
|
43
|
-
|
44
|
-
const formatNamespaceSegment = (segment: string): string => {
|
45
|
-
return Str.Case.snake(segment).toUpperCase()
|
46
|
-
}
|
47
|
-
|
48
|
-
export const create = (namespaceInput?: string | string[], initialState?: State): Debug => {
|
49
|
-
const namespace = Arr.sure(namespaceInput ?? [])
|
50
|
-
const isDebugEnabledFromEnv = calcIsEnabledFromEnv(process.env, namespace)
|
51
|
-
|
52
|
-
const state: State = initialState ?? {
|
53
|
-
isEnabled: isDebugEnabledFromEnv,
|
54
|
-
}
|
55
|
-
|
56
|
-
const debug: Debug = (...args) => {
|
57
|
-
const isPayloadPassed = args.length === 2
|
58
|
-
const [event, payload] = args
|
59
|
-
|
60
|
-
if (state.isEnabled) {
|
61
|
-
// If a payload is an array then default depth to 1 so that we see its _contents_
|
62
|
-
const isPayloadArray = Array.isArray(payload)
|
63
|
-
const depthBoost = isPayloadArray ? 1 : 0
|
64
|
-
const defaultDepth = 3
|
65
|
-
const debugDepth = parseNumberOr(process.env[`DEBUG_DEPTH`], defaultDepth) + depthBoost
|
66
|
-
const isPayloadDisabled = debugDepth < 0
|
67
|
-
|
68
|
-
const payloadRendered = isPayloadPassed && !isPayloadDisabled
|
69
|
-
? inspect(payload, {
|
70
|
-
colors: true,
|
71
|
-
depth: debugDepth,
|
72
|
-
// compact: true,
|
73
|
-
maxStringLength: 1000,
|
74
|
-
})
|
75
|
-
: ``
|
76
|
-
|
77
|
-
const formatNamespaceSegmentAnsi = (segment: string): string => {
|
78
|
-
return colorize(`bold`, colorize(`bgYellowBright`, ` ` + formatNamespaceSegment(segment) + ` `))
|
79
|
-
}
|
80
|
-
|
81
|
-
const namespaceRendered = namespace.map(formatNamespaceSegmentAnsi).join(` `)
|
82
|
-
const eventRendered = colorize(
|
83
|
-
`bold`,
|
84
|
-
colorize(
|
85
|
-
`bgMagentaBright`,
|
86
|
-
` ` + formatNamespaceSegment(event) + ` `,
|
87
|
-
),
|
88
|
-
)
|
89
|
-
const prefixRendered = `${namespaceRendered} ${eventRendered}`
|
90
|
-
|
91
|
-
console.debug(prefixRendered, payloadRendered)
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
debug.toggle = (isEnabled: boolean) => {
|
96
|
-
state.isEnabled = isEnabled
|
97
|
-
}
|
98
|
-
|
99
|
-
debug.sub = (subNamespace: string | string[]) => {
|
100
|
-
const s = Arr.sure(subNamespace)
|
101
|
-
const stateCopy = structuredClone(state)
|
102
|
-
return create([...namespace, ...s], stateCopy)
|
103
|
-
}
|
104
|
-
|
105
|
-
return debug
|
106
|
-
}
|
107
|
-
|
108
|
-
const parseNumberOr = (str: string | undefined, defaultValue: number): number => {
|
109
|
-
if (str === ``) return defaultValue
|
110
|
-
|
111
|
-
const parsed = Number(str)
|
112
|
-
if (Number.isNaN(parsed)) {
|
113
|
-
return defaultValue
|
114
|
-
}
|
115
|
-
return parsed
|
116
|
-
}
|
117
|
-
|
118
|
-
// initialize root debug
|
119
|
-
|
120
|
-
export const debugGlobal = create()
|
@@ -1,56 +0,0 @@
|
|
1
|
-
import { Arr, Language } from '@wollybeard/kit'
|
2
|
-
|
3
|
-
export const enVarName = `DEBUG`
|
4
|
-
|
5
|
-
export const deliminator = `,`
|
6
|
-
export const wildcard = `*`
|
7
|
-
export const enVarEnabledValuesStatic = [`true`, wildcard, `1`]
|
8
|
-
|
9
|
-
export const calcIsEnabledFromEnv = (
|
10
|
-
enVars: Record<string, unknown>,
|
11
|
-
namespace?: string[],
|
12
|
-
): boolean => {
|
13
|
-
const namespace_ = namespace?.map(_ => _.toLowerCase())
|
14
|
-
|
15
|
-
const includeFilters = typeof enVars[enVarName] === `string`
|
16
|
-
? enVars[enVarName]
|
17
|
-
.trim()
|
18
|
-
.toLowerCase()
|
19
|
-
.split(deliminator)
|
20
|
-
.map(patternExpression => {
|
21
|
-
return patternExpression
|
22
|
-
.trim()
|
23
|
-
.split(`:`)
|
24
|
-
.map(_ => _.trim())
|
25
|
-
})
|
26
|
-
: undefined
|
27
|
-
|
28
|
-
if (!includeFilters) return false
|
29
|
-
|
30
|
-
if (includeFilters.length === 0) return false
|
31
|
-
|
32
|
-
// If any is like * then it means "enable everything"
|
33
|
-
if (
|
34
|
-
includeFilters.some(includeFilter => {
|
35
|
-
if (includeFilter.length === 1 && enVarEnabledValuesStatic.includes(includeFilter[0]!)) return true
|
36
|
-
})
|
37
|
-
) return true
|
38
|
-
|
39
|
-
// At this point, if there is no namespace (e.g. root), then we cannot match anything
|
40
|
-
if (!namespace_) return false
|
41
|
-
|
42
|
-
for (const includeFilter of includeFilters) {
|
43
|
-
if (Arr.getLast(includeFilter) !== wildcard) {
|
44
|
-
return includeFilter.join() === namespace_.join()
|
45
|
-
}
|
46
|
-
|
47
|
-
let i = 0
|
48
|
-
for (const segment of includeFilter) {
|
49
|
-
if (segment === wildcard) return true
|
50
|
-
if (segment !== namespace_[i]) return false
|
51
|
-
i++
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
Language.never()
|
56
|
-
}
|
package/src/lib/debug/index.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * as Debug from './debug.ts'
|