@rsdoctor/sdk 0.1.6-beta.0 → 0.1.6-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.
@@ -44,7 +44,7 @@ class RsdoctorWebpackSDK extends import_core.SDKCore {
44
44
  this._chunkGraph = new import_graph.ChunkGraph();
45
45
  this._rawSourceMapCache = /* @__PURE__ */ new Map();
46
46
  this._sourceMap = /* @__PURE__ */ new Map();
47
- this.server = options.noServer ? new import_fakeServer.RsdoctorFakeServer(this, void 0) : new import_server.RsdoctorServer(this, options.port, options.innerClientName);
47
+ this.server = options.noServer ? new import_fakeServer.RsdoctorFakeServer(this, void 0) : new import_server.RsdoctorServer(this, options.port, options.innerClientPath);
48
48
  this.type = options.type || import_types.SDK.ToDataType.Normal;
49
49
  this.extraConfig = options.config;
50
50
  }
@@ -46,16 +46,14 @@ var import_path = __toESM(require("path"));
46
46
  var import_build = require("@rsdoctor/utils/build");
47
47
  var import_base = require("./base");
48
48
  var import_router = require("../router");
49
- var import_common = require("@rsdoctor/utils/common");
50
49
  class RendererAPI extends import_base.BaseAPI {
51
50
  constructor() {
52
51
  super(...arguments);
53
52
  this.isClientServed = false;
54
53
  }
55
54
  async entryHtml() {
56
- const { server, res, req } = this.ctx;
57
- const name = req.url && req.url.match(/innerClientName=([\w-|\=]+)/)?.[1];
58
- const clientHtmlPath = name ? require.resolve(`${import_common.Algorithm.decompressText(name)}/react-client`) : require.resolve("@rsdoctor/client");
55
+ const { server, res } = this.ctx;
56
+ const clientHtmlPath = server.innerClientPath ? server.innerClientPath : require.resolve("@rsdoctor/client");
59
57
  if (!this.isClientServed) {
60
58
  this.isClientServed = true;
61
59
  const clientDistPath = import_path.default.resolve(clientHtmlPath, "..");
@@ -45,10 +45,9 @@ var import_router = require("./router");
45
45
  var APIs = __toESM(require("./apis"));
46
46
  var import_logger = require("@rsdoctor/utils/logger");
47
47
  var import_openBrowser = require("../utils/openBrowser");
48
- var import_common2 = require("@rsdoctor/utils/common");
49
48
  __reExport(server_exports, require("./utils"), module.exports);
50
49
  class RsdoctorServer {
51
- constructor(sdk, port = import_build.Server.defaultPort, innerClientName = "") {
50
+ constructor(sdk, port = import_build.Server.defaultPort, innerClientPath = "") {
52
51
  this.sdk = sdk;
53
52
  this.disposed = true;
54
53
  this.get = (route, cb) => {
@@ -75,7 +74,7 @@ class RsdoctorServer {
75
74
  (0, import_assert.default)(typeof port === "number");
76
75
  this.port = port;
77
76
  this._router = new import_router.Router({ sdk, server: this, apis: Object.values(APIs) });
78
- this.innerClientName = innerClientName;
77
+ this._innerClientPath = innerClientPath;
79
78
  }
80
79
  get app() {
81
80
  return this._server.app;
@@ -90,6 +89,9 @@ class RsdoctorServer {
90
89
  get socketUrl() {
91
90
  return `ws://localhost:${this.port}`;
92
91
  }
92
+ get innerClientPath() {
93
+ return this._innerClientPath;
94
+ }
93
95
  async bootstrap() {
94
96
  if (!this.disposed) {
95
97
  return;
@@ -158,12 +160,12 @@ class RsdoctorServer {
158
160
  });
159
161
  }
160
162
  getClientUrl(route = "homepage", ...args) {
161
- const relativeUrl = this.innerClientName ? `${import_types.SDK.ServerAPI.API.EntryHtml}?innerClientName=${import_common2.Algorithm.compressText(this.innerClientName)}` : import_types.SDK.ServerAPI.API.EntryHtml;
163
+ const relativeUrl = import_types.SDK.ServerAPI.API.EntryHtml;
162
164
  switch (route) {
163
165
  case import_types.Client.RsdoctorClientRoutes.BundleDiff: {
164
166
  const [baseline, current] = args;
165
167
  const qs = import_common.Bundle.getBundleDiffPageQueryString([baseline, current]);
166
- return this.innerClientName ? `${relativeUrl}${qs.replace("?", "&")}#${import_types.Client.RsdoctorClientRoutes.BundleDiff}` : `${relativeUrl}${qs}#${import_types.Client.RsdoctorClientRoutes.BundleDiff}`;
168
+ return `${relativeUrl}${qs}#${import_types.Client.RsdoctorClientRoutes.BundleDiff}`;
167
169
  }
168
170
  default:
169
171
  return relativeUrl;
@@ -21,7 +21,7 @@ class RsdoctorWebpackSDK extends SDKCore {
21
21
  this._chunkGraph = new ChunkGraph();
22
22
  this._rawSourceMapCache = /* @__PURE__ */ new Map();
23
23
  this._sourceMap = /* @__PURE__ */ new Map();
24
- this.server = options.noServer ? new RsdoctorFakeServer(this, void 0) : new RsdoctorServer(this, options.port, options.innerClientName);
24
+ this.server = options.noServer ? new RsdoctorFakeServer(this, void 0) : new RsdoctorServer(this, options.port, options.innerClientPath);
25
25
  this.type = options.type || SDK.ToDataType.Normal;
26
26
  this.extraConfig = options.config;
27
27
  }
@@ -15,16 +15,14 @@ import path from "path";
15
15
  import { File } from "@rsdoctor/utils/build";
16
16
  import { BaseAPI } from "./base";
17
17
  import { Router } from "../router";
18
- import { Algorithm } from "@rsdoctor/utils/common";
19
18
  class RendererAPI extends BaseAPI {
20
19
  constructor() {
21
20
  super(...arguments);
22
21
  this.isClientServed = false;
23
22
  }
24
23
  async entryHtml() {
25
- const { server, res, req } = this.ctx;
26
- const name = req.url && req.url.match(/innerClientName=([\w-|\=]+)/)?.[1];
27
- const clientHtmlPath = name ? require.resolve(`${Algorithm.decompressText(name)}/react-client`) : require.resolve("@rsdoctor/client");
24
+ const { server, res } = this.ctx;
25
+ const clientHtmlPath = server.innerClientPath ? server.innerClientPath : require.resolve("@rsdoctor/client");
28
26
  if (!this.isClientServed) {
29
27
  this.isClientServed = true;
30
28
  const clientDistPath = path.resolve(clientHtmlPath, "..");
@@ -11,10 +11,9 @@ import { Router } from "./router";
11
11
  import * as APIs from "./apis";
12
12
  import { chalk, logger } from "@rsdoctor/utils/logger";
13
13
  import { openBrowser } from "../utils/openBrowser";
14
- import { Algorithm } from "@rsdoctor/utils/common";
15
14
  export * from "./utils";
16
15
  class RsdoctorServer {
17
- constructor(sdk, port = Server.defaultPort, innerClientName = "") {
16
+ constructor(sdk, port = Server.defaultPort, innerClientPath = "") {
18
17
  this.sdk = sdk;
19
18
  this.disposed = true;
20
19
  this.get = (route, cb) => {
@@ -41,7 +40,7 @@ class RsdoctorServer {
41
40
  assert(typeof port === "number");
42
41
  this.port = port;
43
42
  this._router = new Router({ sdk, server: this, apis: Object.values(APIs) });
44
- this.innerClientName = innerClientName;
43
+ this._innerClientPath = innerClientPath;
45
44
  }
46
45
  get app() {
47
46
  return this._server.app;
@@ -56,6 +55,9 @@ class RsdoctorServer {
56
55
  get socketUrl() {
57
56
  return `ws://localhost:${this.port}`;
58
57
  }
58
+ get innerClientPath() {
59
+ return this._innerClientPath;
60
+ }
59
61
  async bootstrap() {
60
62
  if (!this.disposed) {
61
63
  return;
@@ -124,12 +126,12 @@ class RsdoctorServer {
124
126
  });
125
127
  }
126
128
  getClientUrl(route = "homepage", ...args) {
127
- const relativeUrl = this.innerClientName ? `${SDK.ServerAPI.API.EntryHtml}?innerClientName=${Algorithm.compressText(this.innerClientName)}` : SDK.ServerAPI.API.EntryHtml;
129
+ const relativeUrl = SDK.ServerAPI.API.EntryHtml;
128
130
  switch (route) {
129
131
  case Client.RsdoctorClientRoutes.BundleDiff: {
130
132
  const [baseline, current] = args;
131
133
  const qs = Bundle.getBundleDiffPageQueryString([baseline, current]);
132
- return this.innerClientName ? `${relativeUrl}${qs.replace("?", "&")}#${Client.RsdoctorClientRoutes.BundleDiff}` : `${relativeUrl}${qs}#${Client.RsdoctorClientRoutes.BundleDiff}`;
134
+ return `${relativeUrl}${qs}#${Client.RsdoctorClientRoutes.BundleDiff}`;
133
135
  }
134
136
  default:
135
137
  return relativeUrl;
@@ -23,7 +23,7 @@ export interface RsdoctorBuilderSDK extends RsdoctorSDKOptions {
23
23
  port?: number;
24
24
  noServer?: boolean;
25
25
  config?: SDK.SDKOptionsType;
26
- innerClientName?: string;
26
+ innerClientPath?: string;
27
27
  }
28
28
  export interface RsdoctorWebpackSDKOptions extends RsdoctorBuilderSDK {
29
29
  }
@@ -5,15 +5,16 @@ export declare class RsdoctorServer implements SDK.RsdoctorServerInstance {
5
5
  protected sdk: SDK.RsdoctorBuilderSDKInstance;
6
6
  private _server;
7
7
  port: number;
8
- innerClientName: string;
9
8
  private _socket?;
10
9
  private disposed;
11
10
  private _router;
12
- constructor(sdk: SDK.RsdoctorBuilderSDKInstance, port?: number, innerClientName?: string);
11
+ private _innerClientPath;
12
+ constructor(sdk: SDK.RsdoctorBuilderSDKInstance, port?: number, innerClientPath?: string);
13
13
  get app(): SDK.RsdoctorServerInstance['app'];
14
14
  get host(): string;
15
15
  get origin(): string;
16
16
  get socketUrl(): string;
17
+ get innerClientPath(): string;
17
18
  bootstrap(): Promise<void>;
18
19
  protected wrapNextHandleFunction(method: 'GET' | 'POST', cb: (...args: Parameters<Thirdparty.connect.NextHandleFunction>) => Common.PlainObject | string): Thirdparty.connect.NextHandleFunction;
19
20
  proxy(api: SDK.ServerAPI.API, method: 'GET' | 'POST', cb: (...args: Parameters<Thirdparty.connect.NextHandleFunction>) => Common.PlainObject | string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsdoctor/sdk",
3
- "version": "0.1.6-beta.0",
3
+ "version": "0.1.6-beta.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/web-infra-dev/rsdoctor",
@@ -25,10 +25,10 @@
25
25
  "socket.io": "4.7.2",
26
26
  "source-map": "^0.7.4",
27
27
  "tapable": "2.2.1",
28
- "@rsdoctor/client": "0.1.6-beta.0",
29
- "@rsdoctor/graph": "0.1.6-beta.0",
30
- "@rsdoctor/types": "0.1.6-beta.0",
31
- "@rsdoctor/utils": "0.1.6-beta.0"
28
+ "@rsdoctor/client": "0.1.6-beta.1",
29
+ "@rsdoctor/types": "0.1.6-beta.1",
30
+ "@rsdoctor/utils": "0.1.6-beta.1",
31
+ "@rsdoctor/graph": "0.1.6-beta.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/body-parser": "1.19.2",