@xfe-repo/web-register 1.2.1 → 1.3.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/dist/index.d.ts CHANGED
@@ -15,9 +15,10 @@ type CreateOptions<ExtendConfig = null, ExtendContext = null, P = any> = {
15
15
  LoadFullback?: ComponentType<any> | null;
16
16
  ErrorFullback?: ComponentType<any> | null;
17
17
  renderTitle?: (name: string, context: RegisterContext<ExtendContext, P>) => string;
18
+ getQuery?: (context: RegisterContext<ExtendContext, P>) => string | Partial<Record<string, string>>;
18
19
  };
19
20
  type ORegisterConfig = {
20
- name: string;
21
+ name?: string;
21
22
  onLoad?: (context: RegisterContext) => Promise<any>;
22
23
  onLeave?: (context: ORegisterContext) => Promise<boolean>;
23
24
  };
package/dist/index.js CHANGED
@@ -341,9 +341,11 @@ var createRegisterComponent = function(config, getContext, WrappedComponent) {
341
341
  var RegisterComponent = (0, import_react.memo)(function(props) {
342
342
  var context = getContext();
343
343
  var isPreload = context.isPreload;
344
- var name = config.name, ErrorFullback = config.ErrorFullback, LoadFullback = config.LoadFullback, renderTitle = config.renderTitle;
344
+ var name = config.name, ErrorFullback = config.ErrorFullback, LoadFullback = config.LoadFullback, renderTitle = config.renderTitle, getQuery = config.getQuery;
345
345
  var query = (0, import_react.useMemo)(function() {
346
- return import_query_string.default.parse(location.search, {
346
+ var query2 = (getQuery === null || getQuery === void 0 ? void 0 : getQuery(context)) || "";
347
+ var isParsed = typeof query2 === "object";
348
+ return isParsed ? query2 : import_query_string.default.parse(query2, {
347
349
  parseBooleans: true,
348
350
  parseNumbers: true
349
351
  });
@@ -397,10 +399,8 @@ var createRegisterComponent = function(config, getContext, WrappedComponent) {
397
399
  if (needLoad && LoadFullback) content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadFullback, {});
398
400
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, {
399
401
  children: [
400
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_helmet.Helmet, {
401
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
402
- children: (renderTitle === null || renderTitle === void 0 ? void 0 : renderTitle(name, context)) || name
403
- })
402
+ renderTitle && name && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_helmet.Helmet, {
403
+ title: renderTitle(name, context)
404
404
  }),
405
405
  content
406
406
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-register",
3
- "version": "1.2.1",
3
+ "version": "1.3.2",
4
4
  "sideEffects": false,
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,6 +20,9 @@
20
20
  "@xfe-repo/eslint-config": "0.0.5",
21
21
  "@xfe-repo/typescript-config": "0.0.6"
22
22
  },
23
+ "publishConfig": {
24
+ "registry": "https://registry.npmjs.org/"
25
+ },
23
26
  "scripts": {
24
27
  "build": "tsup",
25
28
  "dev": "tsup --watch",