@aomex/pretty-json 3.30.6 → 3.30.8-alpha.62.sha-92b25bb

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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.30.7](https://github.com/aomex/aomex/compare/v3.30.6...v3.30.7) (2026-11-01)
7
+
8
+ **Note:** Version bump only for package @aomex/pretty-json
9
+
10
+
11
+
12
+
13
+
6
14
  ## [3.30.6](https://github.com/aomex/aomex/compare/v3.30.5...v3.30.6) (2026-10-19)
7
15
 
8
16
  **Note:** Version bump only for package @aomex/pretty-json
package/dist/index.d.ts CHANGED
@@ -1,26 +1,23 @@
1
- import { WebMiddleware } from '@aomex/web';
2
-
3
- interface PrettyJsonOptions {
4
- /**
5
- * 是否启用中间件。默认值:`true`
6
- */
7
- enable?: boolean;
8
- /**
9
- * 在查询字符串找到指定的key时,强制启用中间件
10
- * - example.com?pretty
11
- */
12
- query?: string;
13
- /**
14
- * 每行缩进空格数量。默认值:`2`
15
- * ```typescript
16
- * JSON.stringify({}, null, spaces)
17
- * ```
18
- */
19
- spaces?: number;
1
+ import { WebMiddleware } from "@aomex/web";
2
+ export interface PrettyJsonOptions {
3
+ /**
4
+ * 是否启用中间件。默认值:`true`
5
+ */
6
+ enable?: boolean;
7
+ /**
8
+ * 在查询字符串找到指定的key时,强制启用中间件
9
+ * - example.com?pretty
10
+ */
11
+ query?: string;
12
+ /**
13
+ * 每行缩进空格数量。默认值:`2`
14
+ * ```typescript
15
+ * JSON.stringify({}, null, spaces)
16
+ * ```
17
+ */
18
+ spaces?: number;
20
19
  }
21
20
  /**
22
21
  * 美化输出的JSON数据
23
22
  */
24
- declare const prettyJson: (options?: PrettyJsonOptions) => WebMiddleware;
25
-
26
- export { type PrettyJsonOptions, prettyJson };
23
+ export declare const prettyJson: (options?: PrettyJsonOptions) => WebMiddleware;
package/dist/index.js CHANGED
@@ -1,25 +1,26 @@
1
- // src/index.ts
2
1
  import { middleware } from "@aomex/common";
3
- import { Readable } from "stream";
2
+ import { Readable } from "node:stream";
4
3
  import StreamStringify from "streaming-json-stringify";
5
- var prettyJson = (options = {}) => {
6
- const { enable = true, spaces = 2, query } = options;
7
- return middleware.web(async (ctx, next) => {
8
- await next();
9
- const { request, response } = ctx;
10
- const { body } = response;
11
- const prettify = enable || query && Object.hasOwn(request.query, query);
12
- if (!prettify) return;
13
- if (body instanceof Readable && body.readableObjectMode) {
14
- response.contentType = "json";
15
- response.body = body.pipe(StreamStringify({ space: spaces }));
16
- } else if (response.isJSON(body)) {
17
- response.contentType = "json";
18
- response.body = JSON.stringify(body, null, spaces);
19
- }
20
- });
21
- };
22
- export {
23
- prettyJson
4
+ // src/index.ts
5
+ /**
6
+ * 美化输出的JSON数据
7
+ */
8
+ const prettyJson = (options = {}) => {
9
+ const { enable = true, spaces = 2, query } = options;
10
+ return middleware.web(async (ctx, next) => {
11
+ await next();
12
+ const { request, response } = ctx;
13
+ const { body } = response;
14
+ if (!(enable || query && Object.hasOwn(request.query, query))) return;
15
+ if (body instanceof Readable && body.readableObjectMode) {
16
+ response.contentType = "json";
17
+ response.body = body.pipe(StreamStringify({ space: spaces }));
18
+ } else if (response.isJSON(body)) {
19
+ response.contentType = "json";
20
+ response.body = JSON.stringify(body, null, spaces);
21
+ }
22
+ });
24
23
  };
24
+ export { prettyJson };
25
+
25
26
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { middleware } from '@aomex/common';\nimport type { WebMiddleware } from '@aomex/web';\nimport { Readable } from 'node:stream';\nimport StreamStringify from 'streaming-json-stringify';\n\nexport interface PrettyJsonOptions {\n /**\n * 是否启用中间件。默认值:`true`\n */\n enable?: boolean;\n /**\n * 在查询字符串找到指定的key时,强制启用中间件\n * - example.com?pretty\n */\n query?: string;\n /**\n * 每行缩进空格数量。默认值:`2`\n * ```typescript\n * JSON.stringify({}, null, spaces)\n * ```\n */\n spaces?: number;\n}\n\n/**\n * 美化输出的JSON数据\n */\nexport const prettyJson = (options: PrettyJsonOptions = {}): WebMiddleware => {\n const { enable = true, spaces = 2, query } = options;\n\n return middleware.web(async (ctx, next) => {\n await next();\n\n const { request, response } = ctx;\n const { body } = response;\n const prettify = enable || (query && Object.hasOwn(request.query, query));\n\n if (!prettify) return;\n\n if (body instanceof Readable && body.readableObjectMode) {\n response.contentType = 'json';\n response.body = body.pipe(StreamStringify({ space: spaces }));\n } else if (response.isJSON(body)) {\n response.contentType = 'json';\n response.body = JSON.stringify(body, null, spaces);\n }\n });\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB;AACzB,OAAO,qBAAqB;AAwBrB,IAAM,aAAa,CAAC,UAA6B,CAAC,MAAqB;AAC5E,QAAM,EAAE,SAAS,MAAM,SAAS,GAAG,MAAM,IAAI;AAE7C,SAAO,WAAW,IAAI,OAAO,KAAK,SAAS;AACzC,UAAM,KAAK;AAEX,UAAM,EAAE,SAAS,SAAS,IAAI;AAC9B,UAAM,EAAE,KAAK,IAAI;AACjB,UAAM,WAAW,UAAW,SAAS,OAAO,OAAO,QAAQ,OAAO,KAAK;AAEvE,QAAI,CAAC,SAAU;AAEf,QAAI,gBAAgB,YAAY,KAAK,oBAAoB;AACvD,eAAS,cAAc;AACvB,eAAS,OAAO,KAAK,KAAK,gBAAgB,EAAE,OAAO,OAAO,CAAC,CAAC;AAAA,IAC9D,WAAW,SAAS,OAAO,IAAI,GAAG;AAChC,eAAS,cAAc;AACvB,eAAS,OAAO,KAAK,UAAU,MAAM,MAAM,MAAM;AAAA,IACnD;AAAA,EACF,CAAC;AACH;","names":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { middleware } from '@aomex/common';\nimport type { WebMiddleware } from '@aomex/web';\nimport { Readable } from 'node:stream';\nimport StreamStringify from 'streaming-json-stringify';\n\nexport interface PrettyJsonOptions {\n /**\n * 是否启用中间件。默认值:`true`\n */\n enable?: boolean;\n /**\n * 在查询字符串找到指定的key时,强制启用中间件\n * - example.com?pretty\n */\n query?: string;\n /**\n * 每行缩进空格数量。默认值:`2`\n * ```typescript\n * JSON.stringify({}, null, spaces)\n * ```\n */\n spaces?: number;\n}\n\n/**\n * 美化输出的JSON数据\n */\nexport const prettyJson = (options: PrettyJsonOptions = {}): WebMiddleware => {\n const { enable = true, spaces = 2, query } = options;\n\n return middleware.web(async (ctx, next) => {\n await next();\n\n const { request, response } = ctx;\n const { body } = response;\n const prettify = enable || (query && Object.hasOwn(request.query, query));\n\n if (!prettify) return;\n\n if (body instanceof Readable && body.readableObjectMode) {\n response.contentType = 'json';\n response.body = body.pipe(StreamStringify({ space: spaces }));\n } else if (response.isJSON(body)) {\n response.contentType = 'json';\n response.body = JSON.stringify(body, null, spaces);\n }\n });\n};\n"],"mappings":";;;;;;;AA2BA,MAAa,cAAc,UAA6B,CAAC,MAAqB;CAC5E,MAAM,EAAE,SAAS,MAAM,SAAS,GAAG,UAAU;CAE7C,OAAO,WAAW,IAAI,OAAO,KAAK,SAAS;EACzC,MAAM,KAAK;EAEX,MAAM,EAAE,SAAS,aAAa;EAC9B,MAAM,EAAE,SAAS;EAGjB,IAAI,EAFa,UAAW,SAAS,OAAO,OAAO,QAAQ,OAAO,KAAK,IAExD;EAEf,IAAI,gBAAgB,YAAY,KAAK,oBAAoB;GACvD,SAAS,cAAc;GACvB,SAAS,OAAO,KAAK,KAAK,gBAAgB,EAAE,OAAO,OAAO,CAAC,CAAC;EAC9D,OAAO,IAAI,SAAS,OAAO,IAAI,GAAG;GAChC,SAAS,cAAc;GACvB,SAAS,OAAO,KAAK,UAAU,MAAM,MAAM,MAAM;EACnD;CACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,27 +1,21 @@
1
1
  {
2
2
  "name": "@aomex/pretty-json",
3
- "version": "3.30.6",
3
+ "version": "3.30.8-alpha.62.sha-92b25bb",
4
4
  "description": "格式化JSON数据",
5
5
  "keywords": [
6
6
  "pretty",
7
7
  "json"
8
8
  ],
9
- "repository": {
10
- "type": "git",
11
- "url": "git@github.com:aomex/aomex.git"
12
- },
9
+ "repository": "git@github.com:aomex/aomex.git",
13
10
  "homepage": "https://aomex.js.org",
14
11
  "license": "MIT",
15
12
  "type": "module",
16
13
  "sideEffects": false,
17
- "types": "dist/index.d.ts",
18
- "exports": {
19
- ".": {
20
- "types": "./dist/index.d.ts",
21
- "import": "./dist/index.js"
22
- },
23
- "./package.json": "./package.json"
14
+ "scripts": {
15
+ "prepublishOnly": "tsdown"
24
16
  },
17
+ "types": "src/index.ts",
18
+ "exports": "./src/index.ts",
25
19
  "files": [
26
20
  "dist",
27
21
  "LICENSE",
@@ -30,19 +24,27 @@
30
24
  "CHANGELOG.md"
31
25
  ],
32
26
  "publishConfig": {
27
+ "types": "dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
33
35
  "access": "public"
34
36
  },
35
37
  "peerDependencies": {
36
- "@aomex/common": "^3.0.0",
37
- "@aomex/web": "^3.0.0"
38
+ "@aomex/common": "^4.0.0",
39
+ "@aomex/web": "^4.0.0"
38
40
  },
39
41
  "dependencies": {
40
42
  "streaming-json-stringify": "^3.1.0"
41
43
  },
42
44
  "devDependencies": {
43
- "@aomex/common": "3.30.6",
44
- "@aomex/web": "3.30.6",
45
- "@types/streaming-json-stringify": "^3.1.1"
45
+ "@aomex/common": "3.30.8-alpha.62.sha-92b25bb",
46
+ "@aomex/web": "3.30.8-alpha.62.sha-92b25bb",
47
+ "@types/streaming-json-stringify": "^3.1.5"
46
48
  },
47
- "scripts": {}
48
- }
49
+ "gitHead": "92b25bbcd6c3ae28160316117a74c88619b5bc8d"
50
+ }