@next-core/react-runtime 1.11.0 → 1.11.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.
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.useMessage = useMessage;
8
+ var _react = _interopRequireDefault(require("react"));
7
9
  var _runtime = require("@next-core/runtime");
8
10
  /**
9
11
  * 获取 message 对象的 React hooks,用于显示通知消息。
10
12
  *
13
+ * **注意**: 使用 useMemo 确保返回的 message 对象引用稳定,
14
+ * 避免不必要的组件重渲染。这在对象被用于依赖数组或传递给记忆化组件时尤为重要。
15
+ *
11
16
  * @example
12
17
  *
13
18
  * ```tsx
@@ -31,7 +36,7 @@ var _runtime = require("@next-core/runtime");
31
36
  * @returns message 对象,包含 success、error、info、warn 四个方法。
32
37
  */
33
38
  function useMessage() {
34
- return {
39
+ return _react.default.useMemo(() => ({
35
40
  success: message => {
36
41
  _runtime.Notification.show({
37
42
  type: "success",
@@ -56,6 +61,6 @@ function useMessage() {
56
61
  message
57
62
  });
58
63
  }
59
- };
64
+ }), []);
60
65
  }
61
66
  //# sourceMappingURL=useMessage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMessage.js","names":["_runtime","require","useMessage","success","message","Notification","show","type","error","info","warn"],"sources":["../../src/useMessage.ts"],"sourcesContent":["import { Notification } from \"@next-core/runtime\";\n\nexport interface Message {\n /**\n * 显示成功消息。\n * @param message - 要显示的消息内容\n */\n success: (message: string) => void;\n\n /**\n * 显示错误消息。\n * @param message - 要显示的消息内容\n */\n error: (message: string) => void;\n\n /**\n * 显示信息消息。\n * @param message - 要显示的消息内容\n */\n info: (message: string) => void;\n\n /**\n * 显示警告消息。\n * @param message - 要显示的消息内容\n */\n warn: (message: string) => void;\n}\n\n/**\n * 获取 message 对象的 React hooks,用于显示通知消息。\n *\n * @example\n *\n * ```tsx\n * function MyReactComponent() {\n * const message = useMessage();\n * const handleSuccess = () => {\n * message.success(\"操作成功!\");\n * };\n * const handleError = () => {\n * message.error(\"操作失败!\");\n * };\n * return (\n * <div>\n * <button onClick={handleSuccess}>成功</button>\n * <button onClick={handleError}>失败</button>\n * </div>\n * );\n * }\n * ```\n *\n * @returns message 对象,包含 success、error、info、warn 四个方法。\n */\nexport function useMessage(): Message {\n return {\n success: (message: string) => {\n Notification.show({ type: \"success\", message });\n },\n error: (message: string) => {\n Notification.show({ type: \"error\", message });\n },\n info: (message: string) => {\n Notification.show({ type: \"info\", message });\n },\n warn: (message: string) => {\n Notification.show({ type: \"warn\", message });\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAAA,EAAY;EACpC,OAAO;IACLC,OAAO,EAAGC,OAAe,IAAK;MAC5BC,qBAAY,CAACC,IAAI,CAAC;QAAEC,IAAI,EAAE,SAAS;QAAEH;MAAQ,CAAC,CAAC;IACjD,CAAC;IACDI,KAAK,EAAGJ,OAAe,IAAK;MAC1BC,qBAAY,CAACC,IAAI,CAAC;QAAEC,IAAI,EAAE,OAAO;QAAEH;MAAQ,CAAC,CAAC;IAC/C,CAAC;IACDK,IAAI,EAAGL,OAAe,IAAK;MACzBC,qBAAY,CAACC,IAAI,CAAC;QAAEC,IAAI,EAAE,MAAM;QAAEH;MAAQ,CAAC,CAAC;IAC9C,CAAC;IACDM,IAAI,EAAGN,OAAe,IAAK;MACzBC,qBAAY,CAACC,IAAI,CAAC;QAAEC,IAAI,EAAE,MAAM;QAAEH;MAAQ,CAAC,CAAC;IAC9C;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useMessage.js","names":["_react","_interopRequireDefault","require","_runtime","useMessage","React","useMemo","success","message","Notification","show","type","error","info","warn"],"sources":["../../src/useMessage.ts"],"sourcesContent":["import React from \"react\";\nimport { Notification } from \"@next-core/runtime\";\n\nexport interface Message {\n /**\n * 显示成功消息。\n * @param message - 要显示的消息内容\n */\n success: (message: string) => void;\n\n /**\n * 显示错误消息。\n * @param message - 要显示的消息内容\n */\n error: (message: string) => void;\n\n /**\n * 显示信息消息。\n * @param message - 要显示的消息内容\n */\n info: (message: string) => void;\n\n /**\n * 显示警告消息。\n * @param message - 要显示的消息内容\n */\n warn: (message: string) => void;\n}\n\n/**\n * 获取 message 对象的 React hooks,用于显示通知消息。\n *\n * **注意**: 使用 useMemo 确保返回的 message 对象引用稳定,\n * 避免不必要的组件重渲染。这在对象被用于依赖数组或传递给记忆化组件时尤为重要。\n *\n * @example\n *\n * ```tsx\n * function MyReactComponent() {\n * const message = useMessage();\n * const handleSuccess = () => {\n * message.success(\"操作成功!\");\n * };\n * const handleError = () => {\n * message.error(\"操作失败!\");\n * };\n * return (\n * <div>\n * <button onClick={handleSuccess}>成功</button>\n * <button onClick={handleError}>失败</button>\n * </div>\n * );\n * }\n * ```\n *\n * @returns message 对象,包含 success、error、info、warn 四个方法。\n */\nexport function useMessage(): Message {\n return React.useMemo(\n () => ({\n success: (message: string) => {\n Notification.show({ type: \"success\", message });\n },\n error: (message: string) => {\n Notification.show({ type: \"error\", message });\n },\n info: (message: string) => {\n Notification.show({ type: \"info\", message });\n },\n warn: (message: string) => {\n Notification.show({ type: \"warn\", message });\n },\n }),\n []\n );\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,UAAUA,CAAA,EAAY;EACpC,OAAOC,cAAK,CAACC,OAAO,CAClB,OAAO;IACLC,OAAO,EAAGC,OAAe,IAAK;MAC5BC,qBAAY,CAACC,IAAI,CAAC;QAAEC,IAAI,EAAE,SAAS;QAAEH;MAAQ,CAAC,CAAC;IACjD,CAAC;IACDI,KAAK,EAAGJ,OAAe,IAAK;MAC1BC,qBAAY,CAACC,IAAI,CAAC;QAAEC,IAAI,EAAE,OAAO;QAAEH;MAAQ,CAAC,CAAC;IAC/C,CAAC;IACDK,IAAI,EAAGL,OAAe,IAAK;MACzBC,qBAAY,CAACC,IAAI,CAAC;QAAEC,IAAI,EAAE,MAAM;QAAEH;MAAQ,CAAC,CAAC;IAC9C,CAAC;IACDM,IAAI,EAAGN,OAAe,IAAK;MACzBC,qBAAY,CAACC,IAAI,CAAC;QAAEC,IAAI,EAAE,MAAM;QAAEH;MAAQ,CAAC,CAAC;IAC9C;EACF,CAAC,CAAC,EACF,EACF,CAAC;AACH","ignoreList":[]}
@@ -1,7 +1,11 @@
1
+ import React from "react";
1
2
  import { Notification } from "@next-core/runtime";
2
3
  /**
3
4
  * 获取 message 对象的 React hooks,用于显示通知消息。
4
5
  *
6
+ * **注意**: 使用 useMemo 确保返回的 message 对象引用稳定,
7
+ * 避免不必要的组件重渲染。这在对象被用于依赖数组或传递给记忆化组件时尤为重要。
8
+ *
5
9
  * @example
6
10
  *
7
11
  * ```tsx
@@ -25,7 +29,7 @@ import { Notification } from "@next-core/runtime";
25
29
  * @returns message 对象,包含 success、error、info、warn 四个方法。
26
30
  */
27
31
  export function useMessage() {
28
- return {
32
+ return React.useMemo(() => ({
29
33
  success: message => {
30
34
  Notification.show({
31
35
  type: "success",
@@ -50,6 +54,6 @@ export function useMessage() {
50
54
  message
51
55
  });
52
56
  }
53
- };
57
+ }), []);
54
58
  }
55
59
  //# sourceMappingURL=useMessage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMessage.js","names":["Notification","useMessage","success","message","show","type","error","info","warn"],"sources":["../../src/useMessage.ts"],"sourcesContent":["import { Notification } from \"@next-core/runtime\";\n\nexport interface Message {\n /**\n * 显示成功消息。\n * @param message - 要显示的消息内容\n */\n success: (message: string) => void;\n\n /**\n * 显示错误消息。\n * @param message - 要显示的消息内容\n */\n error: (message: string) => void;\n\n /**\n * 显示信息消息。\n * @param message - 要显示的消息内容\n */\n info: (message: string) => void;\n\n /**\n * 显示警告消息。\n * @param message - 要显示的消息内容\n */\n warn: (message: string) => void;\n}\n\n/**\n * 获取 message 对象的 React hooks,用于显示通知消息。\n *\n * @example\n *\n * ```tsx\n * function MyReactComponent() {\n * const message = useMessage();\n * const handleSuccess = () => {\n * message.success(\"操作成功!\");\n * };\n * const handleError = () => {\n * message.error(\"操作失败!\");\n * };\n * return (\n * <div>\n * <button onClick={handleSuccess}>成功</button>\n * <button onClick={handleError}>失败</button>\n * </div>\n * );\n * }\n * ```\n *\n * @returns message 对象,包含 success、error、info、warn 四个方法。\n */\nexport function useMessage(): Message {\n return {\n success: (message: string) => {\n Notification.show({ type: \"success\", message });\n },\n error: (message: string) => {\n Notification.show({ type: \"error\", message });\n },\n info: (message: string) => {\n Notification.show({ type: \"info\", message });\n },\n warn: (message: string) => {\n Notification.show({ type: \"warn\", message });\n },\n };\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,oBAAoB;AA4BjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAAA,EAAY;EACpC,OAAO;IACLC,OAAO,EAAGC,OAAe,IAAK;MAC5BH,YAAY,CAACI,IAAI,CAAC;QAAEC,IAAI,EAAE,SAAS;QAAEF;MAAQ,CAAC,CAAC;IACjD,CAAC;IACDG,KAAK,EAAGH,OAAe,IAAK;MAC1BH,YAAY,CAACI,IAAI,CAAC;QAAEC,IAAI,EAAE,OAAO;QAAEF;MAAQ,CAAC,CAAC;IAC/C,CAAC;IACDI,IAAI,EAAGJ,OAAe,IAAK;MACzBH,YAAY,CAACI,IAAI,CAAC;QAAEC,IAAI,EAAE,MAAM;QAAEF;MAAQ,CAAC,CAAC;IAC9C,CAAC;IACDK,IAAI,EAAGL,OAAe,IAAK;MACzBH,YAAY,CAACI,IAAI,CAAC;QAAEC,IAAI,EAAE,MAAM;QAAEF;MAAQ,CAAC,CAAC;IAC9C;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useMessage.js","names":["React","Notification","useMessage","useMemo","success","message","show","type","error","info","warn"],"sources":["../../src/useMessage.ts"],"sourcesContent":["import React from \"react\";\nimport { Notification } from \"@next-core/runtime\";\n\nexport interface Message {\n /**\n * 显示成功消息。\n * @param message - 要显示的消息内容\n */\n success: (message: string) => void;\n\n /**\n * 显示错误消息。\n * @param message - 要显示的消息内容\n */\n error: (message: string) => void;\n\n /**\n * 显示信息消息。\n * @param message - 要显示的消息内容\n */\n info: (message: string) => void;\n\n /**\n * 显示警告消息。\n * @param message - 要显示的消息内容\n */\n warn: (message: string) => void;\n}\n\n/**\n * 获取 message 对象的 React hooks,用于显示通知消息。\n *\n * **注意**: 使用 useMemo 确保返回的 message 对象引用稳定,\n * 避免不必要的组件重渲染。这在对象被用于依赖数组或传递给记忆化组件时尤为重要。\n *\n * @example\n *\n * ```tsx\n * function MyReactComponent() {\n * const message = useMessage();\n * const handleSuccess = () => {\n * message.success(\"操作成功!\");\n * };\n * const handleError = () => {\n * message.error(\"操作失败!\");\n * };\n * return (\n * <div>\n * <button onClick={handleSuccess}>成功</button>\n * <button onClick={handleError}>失败</button>\n * </div>\n * );\n * }\n * ```\n *\n * @returns message 对象,包含 success、error、info、warn 四个方法。\n */\nexport function useMessage(): Message {\n return React.useMemo(\n () => ({\n success: (message: string) => {\n Notification.show({ type: \"success\", message });\n },\n error: (message: string) => {\n Notification.show({ type: \"error\", message });\n },\n info: (message: string) => {\n Notification.show({ type: \"info\", message });\n },\n warn: (message: string) => {\n Notification.show({ type: \"warn\", message });\n },\n }),\n []\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,oBAAoB;AA4BjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAAA,EAAY;EACpC,OAAOF,KAAK,CAACG,OAAO,CAClB,OAAO;IACLC,OAAO,EAAGC,OAAe,IAAK;MAC5BJ,YAAY,CAACK,IAAI,CAAC;QAAEC,IAAI,EAAE,SAAS;QAAEF;MAAQ,CAAC,CAAC;IACjD,CAAC;IACDG,KAAK,EAAGH,OAAe,IAAK;MAC1BJ,YAAY,CAACK,IAAI,CAAC;QAAEC,IAAI,EAAE,OAAO;QAAEF;MAAQ,CAAC,CAAC;IAC/C,CAAC;IACDI,IAAI,EAAGJ,OAAe,IAAK;MACzBJ,YAAY,CAACK,IAAI,CAAC;QAAEC,IAAI,EAAE,MAAM;QAAEF;MAAQ,CAAC,CAAC;IAC9C,CAAC;IACDK,IAAI,EAAGL,OAAe,IAAK;MACzBJ,YAAY,CAACK,IAAI,CAAC;QAAEC,IAAI,EAAE,MAAM;QAAEF;MAAQ,CAAC,CAAC;IAC9C;EACF,CAAC,CAAC,EACF,EACF,CAAC;AACH","ignoreList":[]}
@@ -23,6 +23,9 @@ export interface Message {
23
23
  /**
24
24
  * 获取 message 对象的 React hooks,用于显示通知消息。
25
25
  *
26
+ * **注意**: 使用 useMemo 确保返回的 message 对象引用稳定,
27
+ * 避免不必要的组件重渲染。这在对象被用于依赖数组或传递给记忆化组件时尤为重要。
28
+ *
26
29
  * @example
27
30
  *
28
31
  * ```tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/react-runtime",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
4
4
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/react-runtime",
5
5
  "license": "GPL-3.0",
6
6
  "repository": {
@@ -38,9 +38,9 @@
38
38
  "test:ci": "cross-env NODE_ENV='test' CI=true test-next"
39
39
  },
40
40
  "dependencies": {
41
- "@next-core/easyops-runtime": "^0.15.32",
41
+ "@next-core/easyops-runtime": "^0.15.33",
42
42
  "@next-core/react-element": "^1.0.40",
43
- "@next-core/runtime": "^1.72.7",
43
+ "@next-core/runtime": "^1.72.8",
44
44
  "@next-core/types": "^1.19.0",
45
45
  "react": "0.0.0-experimental-ee8509801-20230117",
46
46
  "react-dom": "0.0.0-experimental-ee8509801-20230117"
@@ -50,5 +50,5 @@
50
50
  "@next-core/test-next": "^2.0.1",
51
51
  "jest-fetch-mock": "^3.0.3"
52
52
  },
53
- "gitHead": "c4f008e94f469718c38b7b933f562db06d646691"
53
+ "gitHead": "6f770693e9786f976e05509b9cba8e993a5f97f1"
54
54
  }