@rsdoctor/components 0.3.9 → 0.3.10-beta.1

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.
@@ -2,6 +2,7 @@
2
2
  import { Manifest, Rule, SDK } from '@rsdoctor/types';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import './i18n';
5
+ export declare function decompressText(input: string): string;
5
6
  export declare const useI18n: typeof useTranslation;
6
7
  export declare function useRuleIndexNavigate(code: string, link?: string | undefined): () => void;
7
8
  export declare function useUrlQuery(): Record<string, string | undefined>;
@@ -8,6 +8,20 @@ import parse from "url-parse";
8
8
  import "./i18n";
9
9
  import { setLocaleToStorage } from "./storage";
10
10
  const route = Client.RsdoctorClientRoutes.RuleIndex;
11
+ function decompressText(input) {
12
+ try {
13
+ if (!window.lz4)
14
+ return "";
15
+ const compressedBlock = Buffer.from(input);
16
+ let uncompressedBlock = Buffer.alloc(input.length * 10);
17
+ const n = window.lz4.decodeBlock(compressedBlock, uncompressedBlock);
18
+ uncompressedBlock = uncompressedBlock.slice(0, n);
19
+ return uncompressedBlock.toString("utf-8");
20
+ } catch (e) {
21
+ console.log(e);
22
+ return "";
23
+ }
24
+ }
11
25
  const useI18n = () => {
12
26
  const { i18n, ...rest } = useTranslation();
13
27
  return {
@@ -31,7 +45,9 @@ function useRuleIndexNavigate(code, link) {
31
45
  return () => window.open(link, "__blank");
32
46
  }
33
47
  return () => {
34
- navigate(`${route}?${Rule.RsdoctorRuleClientConstant.UrlQueryForErrorCode}=${code}`);
48
+ navigate(
49
+ `${route}?${Rule.RsdoctorRuleClientConstant.UrlQueryForErrorCode}=${code}`
50
+ );
35
51
  };
36
52
  }
37
53
  function useUrlQuery() {
@@ -76,9 +92,15 @@ function ensurePlainObject(value, dfts) {
76
92
  function useChunkGraphByManifest(manifest) {
77
93
  const prev = manifest.data.chunkGraph;
78
94
  if (typeof prev === "string") {
79
- manifest.data.chunkGraph = JSON.parse(Algorithm.decompressText(prev));
95
+ manifest.data.chunkGraph = JSON.parse(
96
+ Algorithm.decompressText(prev)
97
+ );
80
98
  }
81
- return ensurePlainObject(manifest.data.chunkGraph, { assets: [], chunks: [], entrypoints: [] });
99
+ return ensurePlainObject(manifest.data.chunkGraph, {
100
+ assets: [],
101
+ chunks: [],
102
+ entrypoints: []
103
+ });
82
104
  }
83
105
  function useConfigOutputFileNameByManifest(manifest) {
84
106
  if (typeof manifest.data.configs?.[0]?.config?.output?.filename === "string") {
@@ -89,7 +111,9 @@ function useConfigOutputFileNameByManifest(manifest) {
89
111
  function useModuleGraphByManifest(manifest) {
90
112
  const prev = manifest.data.moduleGraph;
91
113
  if (typeof prev === "string") {
92
- manifest.data.moduleGraph = JSON.parse(Algorithm.decompressText(prev));
114
+ manifest.data.moduleGraph = JSON.parse(
115
+ Algorithm.decompressText(prev)
116
+ );
93
117
  }
94
118
  return ensurePlainObject(manifest.data.moduleGraph, {
95
119
  dependencies: [],
@@ -117,7 +141,9 @@ function useModuleGraph(moduleGraph) {
117
141
  function usePackageGraphByManifest(manifest) {
118
142
  const prev = manifest.data.packageGraph;
119
143
  if (typeof prev === "string") {
120
- manifest.data.packageGraph = JSON.parse(Algorithm.decompressText(prev));
144
+ manifest.data.packageGraph = JSON.parse(
145
+ Algorithm.decompressText(prev)
146
+ );
121
147
  }
122
148
  return ensurePlainObject(manifest.data.packageGraph, {
123
149
  packages: [],
@@ -190,6 +216,7 @@ function useWindowWidth() {
190
216
  return windowWidth;
191
217
  }
192
218
  export {
219
+ decompressText,
193
220
  useBundleAlertsByErrors,
194
221
  useBundleAlertsByManifest,
195
222
  useChunkGraphByManifest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/components",
3
- "version": "0.3.9",
3
+ "version": "0.3.10-beta.1",
4
4
  "main": "./dist/index.js",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -75,9 +75,9 @@
75
75
  "terser": "^5.26.0",
76
76
  "typescript": "^5.2.2",
77
77
  "url-parse": "1.5.10",
78
- "@rsdoctor/graph": "0.3.9",
79
- "@rsdoctor/types": "0.3.9",
80
- "@rsdoctor/utils": "0.3.9"
78
+ "@rsdoctor/graph": "0.3.10-beta.1",
79
+ "@rsdoctor/types": "0.3.10-beta.1",
80
+ "@rsdoctor/utils": "0.3.10-beta.1"
81
81
  },
82
82
  "publishConfig": {
83
83
  "access": "public",