docusaurus-theme-openapi-docs 0.0.0-976 → 0.0.0-978

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/lib/index.js CHANGED
@@ -11,7 +11,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.default = docusaurusThemeOpenAPI;
13
13
  const path_1 = __importDefault(require("path"));
14
- const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
15
14
  function docusaurusThemeOpenAPI() {
16
15
  return {
17
16
  name: "docusaurus-theme-openapi",
@@ -36,7 +35,11 @@ function docusaurusThemeOpenAPI() {
36
35
  // Avoid conflicts with docusaurus-plugin-sass
37
36
  if (sassLoaderRule.length === 0) {
38
37
  return {
39
- plugins: [new NodePolyfillPlugin()],
38
+ plugins: [
39
+ new utils.currentBundler.instance.ProvidePlugin({
40
+ process: require.resolve("process/browser"),
41
+ })
42
+ ],
40
43
  module: {
41
44
  rules: [
42
45
  {
@@ -55,7 +58,11 @@ function docusaurusThemeOpenAPI() {
55
58
  };
56
59
  }
57
60
  return {
58
- plugins: [new NodePolyfillPlugin()],
61
+ plugins: [
62
+ new utils.currentBundler.instance.ProvidePlugin({
63
+ process: require.resolve("process/browser"),
64
+ })
65
+ ],
59
66
  };
60
67
  },
61
68
  };
@@ -12,7 +12,6 @@ var __importDefault =
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.default = ApiItem;
15
- const zlib_1 = __importDefault(require("zlib"));
16
15
  const react_1 = __importDefault(require("react"));
17
16
  const BrowserOnly_1 = __importDefault(require("@docusaurus/BrowserOnly"));
18
17
  const ExecutionEnvironment_1 = __importDefault(
@@ -31,12 +30,22 @@ const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
31
30
  const Metadata_1 = __importDefault(require("@theme/DocItem/Metadata"));
32
31
  const SkeletonLoader_1 = __importDefault(require("@theme/SkeletonLoader"));
33
32
  const clsx_1 = __importDefault(require("clsx"));
33
+ const pako_1 = require("pako");
34
34
  const react_redux_1 = require("react-redux");
35
35
  const store_1 = require("./store");
36
36
  let ApiExplorer = (_) => react_1.default.createElement("div", null);
37
37
  if (ExecutionEnvironment_1.default.canUseDOM) {
38
38
  ApiExplorer = require("@theme/ApiExplorer").default;
39
39
  }
40
+ function base64ToUint8Array(base64) {
41
+ const binary = atob(base64);
42
+ const len = binary.length;
43
+ const bytes = new Uint8Array(len);
44
+ for (let i = 0; i < len; i++) {
45
+ bytes[i] = binary.charCodeAt(i);
46
+ }
47
+ return bytes;
48
+ }
40
49
  // @ts-ignore
41
50
  function ApiItem(props) {
42
51
  const docHtmlClassName = `docs-doc-id-${props.content.metadata.id}`;
@@ -50,7 +59,7 @@ function ApiItem(props) {
50
59
  if (api) {
51
60
  try {
52
61
  api = JSON.parse(
53
- zlib_1.default.inflateSync(Buffer.from(api, "base64")).toString()
62
+ new TextDecoder().decode((0, pako_1.ungzip)(base64ToUint8Array(api)))
54
63
  );
55
64
  } catch {}
56
65
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docusaurus-theme-openapi-docs",
3
3
  "description": "OpenAPI theme for Docusaurus.",
4
- "version": "0.0.0-976",
4
+ "version": "0.0.0-978",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -33,8 +33,9 @@
33
33
  "@types/crypto-js": "^4.1.0",
34
34
  "@types/file-saver": "^2.0.5",
35
35
  "@types/lodash": "^4.14.176",
36
+ "@types/pako": "^2.0.3",
36
37
  "concurrently": "^5.2.0",
37
- "docusaurus-plugin-openapi-docs": "0.0.0-976",
38
+ "docusaurus-plugin-openapi-docs": "0.0.0-978",
38
39
  "docusaurus-plugin-sass": "^0.2.3",
39
40
  "eslint-plugin-prettier": "^5.0.1"
40
41
  },
@@ -47,10 +48,11 @@
47
48
  "crypto-js": "^4.1.1",
48
49
  "file-saver": "^2.0.5",
49
50
  "lodash": "^4.17.20",
50
- "node-polyfill-webpack-plugin": "^3.0.0",
51
+ "pako": "^2.1.0",
51
52
  "postman-code-generators": "^1.10.1",
52
53
  "postman-collection": "^4.4.0",
53
54
  "prism-react-renderer": "^2.3.0",
55
+ "process": "^0.11.10",
54
56
  "react-hook-form": "^7.43.8",
55
57
  "react-live": "^4.0.0",
56
58
  "react-magic-dropzone": "^1.0.1",
@@ -62,7 +64,6 @@
62
64
  "sass": "^1.80.4",
63
65
  "sass-loader": "^16.0.2",
64
66
  "unist-util-visit": "^5.0.0",
65
- "webpack": "^5.61.0",
66
67
  "xml-formatter": "^2.6.1"
67
68
  },
68
69
  "peerDependencies": {
@@ -75,5 +76,5 @@
75
76
  "engines": {
76
77
  "node": ">=14"
77
78
  },
78
- "gitHead": "58ca0bfe422e57a6399052fb9dd9120f2559b187"
79
+ "gitHead": "27ea72abde7faf35da09a0ecc72cde6a0a0a52d6"
79
80
  }
package/src/index.ts CHANGED
@@ -9,8 +9,6 @@ import path from "path";
9
9
 
10
10
  import type { Plugin } from "@docusaurus/types";
11
11
 
12
- const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
13
-
14
12
  export default function docusaurusThemeOpenAPI(): Plugin<void> {
15
13
  return {
16
14
  name: "docusaurus-theme-openapi",
@@ -41,7 +39,11 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
41
39
  // Avoid conflicts with docusaurus-plugin-sass
42
40
  if (sassLoaderRule.length === 0) {
43
41
  return {
44
- plugins: [new NodePolyfillPlugin()],
42
+ plugins: [
43
+ new utils.currentBundler.instance.ProvidePlugin({
44
+ process: require.resolve("process/browser"),
45
+ })
46
+ ],
45
47
  module: {
46
48
  rules: [
47
49
  {
@@ -60,7 +62,11 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
60
62
  };
61
63
  }
62
64
  return {
63
- plugins: [new NodePolyfillPlugin()],
65
+ plugins: [
66
+ new utils.currentBundler.instance.ProvidePlugin({
67
+ process: require.resolve("process/browser"),
68
+ })
69
+ ],
64
70
  };
65
71
  },
66
72
  };
@@ -5,8 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
 
8
- import zlib from "zlib";
9
-
10
8
  import React from "react";
11
9
 
12
10
  import BrowserOnly from "@docusaurus/BrowserOnly";
@@ -23,13 +21,16 @@ import type { Props } from "@theme/DocItem";
23
21
  import DocItemMetadata from "@theme/DocItem/Metadata";
24
22
  import SkeletonLoader from "@theme/SkeletonLoader";
25
23
  import clsx from "clsx";
26
- import { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
27
- import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
24
+ import {
25
+ ParameterObject,
26
+ ServerObject,
27
+ } from "docusaurus-plugin-openapi-docs/src/openapi/types";
28
28
  import type { ApiItem as ApiItemType } from "docusaurus-plugin-openapi-docs/src/types";
29
29
  import type {
30
30
  DocFrontMatter,
31
31
  ThemeConfig,
32
32
  } from "docusaurus-theme-openapi-docs/src/types";
33
+ import { ungzip } from "pako";
33
34
  import { Provider } from "react-redux";
34
35
 
35
36
  import { createStoreWithoutState, createStoreWithState } from "./store";
@@ -52,6 +53,16 @@ interface SampleFrontMatter extends DocFrontMatter {
52
53
  readonly sample?: any;
53
54
  }
54
55
 
56
+ function base64ToUint8Array(base64: string) {
57
+ const binary = atob(base64);
58
+ const len = binary.length;
59
+ const bytes = new Uint8Array(len);
60
+ for (let i = 0; i < len; i++) {
61
+ bytes[i] = binary.charCodeAt(i);
62
+ }
63
+ return bytes;
64
+ }
65
+
55
66
  // @ts-ignore
56
67
  export default function ApiItem(props: Props): JSX.Element {
57
68
  const docHtmlClassName = `docs-doc-id-${props.content.metadata.id}`;
@@ -65,7 +76,7 @@ export default function ApiItem(props: Props): JSX.Element {
65
76
  if (api) {
66
77
  try {
67
78
  api = JSON.parse(
68
- zlib.inflateSync(Buffer.from(api as any, "base64") as any).toString()
79
+ new TextDecoder().decode(ungzip(base64ToUint8Array(api as any)))
69
80
  );
70
81
  } catch {}
71
82
  }