@lark-apaas/client-toolkit 1.2.17-alpha.1 → 1.2.17-alpha.3

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.
Files changed (71) hide show
  1. package/lib/antd-table.d.ts +2 -2
  2. package/lib/apis/aily-chat.d.ts +2 -0
  3. package/lib/apis/aily-chat.js +2 -0
  4. package/lib/apis/components/ActiveLink.d.ts +26 -0
  5. package/lib/apis/components/ActiveLink.js +66 -0
  6. package/lib/apis/hooks/useScrollReveal.d.ts +1 -0
  7. package/lib/apis/hooks/useScrollReveal.js +1 -0
  8. package/lib/apis/utils/getEnv.d.ts +1 -0
  9. package/lib/apis/utils/getEnv.js +2 -0
  10. package/lib/apis/utils/scopedStorage.d.ts +1 -0
  11. package/lib/apis/utils/scopedStorage.js +2 -0
  12. package/lib/auth.d.ts +1 -0
  13. package/lib/auth.js +2 -0
  14. package/lib/components/AppContainer/IframeBridge.d.ts +0 -1
  15. package/lib/components/AppContainer/IframeBridge.js +1 -20
  16. package/lib/components/AppContainer/api-proxy/core.js +2 -1
  17. package/lib/components/AppContainer/index.d.ts +9 -2
  18. package/lib/components/AppContainer/index.js +14 -70
  19. package/lib/components/AppContainer/utils/childApi.js +1 -0
  20. package/lib/components/AppContainer/utils/tea.js +1 -1
  21. package/lib/components/ErrorRender/index.js +5 -11
  22. package/lib/components/User/UserSelect.js +1 -13
  23. package/lib/components/theme/index.d.ts +0 -1
  24. package/lib/components/theme/index.js +0 -1
  25. package/lib/components/theme/util.d.ts +0 -2
  26. package/lib/components/theme/util.js +0 -108
  27. package/lib/components/ui/toast.d.ts +2 -0
  28. package/lib/components/ui/toast.js +53 -0
  29. package/lib/hooks/index.d.ts +1 -0
  30. package/lib/hooks/index.js +1 -0
  31. package/lib/hooks/useScrollReveal.d.ts +61 -0
  32. package/lib/hooks/useScrollReveal.js +37 -0
  33. package/lib/index.js +5 -1
  34. package/lib/integrations/dataloom.js +4 -2
  35. package/lib/integrations/services/types.d.ts +1 -0
  36. package/lib/logger/batch-logger.js +3 -2
  37. package/lib/logger/intercept-global-error.js +16 -14
  38. package/lib/logger/log-types.d.ts +4 -4
  39. package/lib/logger/log-types.js +1 -1
  40. package/lib/logger/selected-logs.js +1 -2
  41. package/lib/runtime/axios.d.ts +5 -0
  42. package/lib/runtime/axios.js +2 -0
  43. package/lib/runtime/dayjs.d.ts +5 -0
  44. package/lib/runtime/dayjs.js +2 -0
  45. package/lib/runtime/iframe-bridge.d.ts +11 -0
  46. package/lib/runtime/iframe-bridge.js +29 -0
  47. package/lib/runtime/index.d.ts +24 -0
  48. package/lib/runtime/index.js +17 -0
  49. package/lib/runtime/observable.d.ts +5 -0
  50. package/lib/runtime/observable.js +2 -0
  51. package/lib/runtime/react-devtools-hook.d.ts +19 -0
  52. package/lib/runtime/react-devtools-hook.js +20 -0
  53. package/lib/runtime/server-log.d.ts +5 -0
  54. package/lib/runtime/server-log.js +41 -0
  55. package/lib/runtime/styles.d.ts +5 -0
  56. package/lib/runtime/styles.js +1 -0
  57. package/lib/theme-layer.css +2 -1
  58. package/lib/utils/axiosConfig.js +25 -3
  59. package/lib/utils/getParentOrigin.js +12 -2
  60. package/lib/utils/hmr-api.d.ts +39 -0
  61. package/lib/utils/hmr-api.js +36 -0
  62. package/lib/utils/module-hot.d.ts +9 -5
  63. package/lib/utils/module-hot.js +9 -10
  64. package/lib/utils/requestManager.js +1 -3
  65. package/lib/utils/scopedStorage.d.ts +5 -0
  66. package/lib/utils/scopedStorage.js +46 -0
  67. package/package.json +2 -2
  68. package/lib/components/AppContainer/utils/listenHot.d.ts +0 -1
  69. package/lib/components/AppContainer/utils/listenHot.js +0 -57
  70. package/lib/components/theme/ui-config.d.ts +0 -1
  71. package/lib/components/theme/ui-config.js +0 -2
@@ -0,0 +1,36 @@
1
+ function createWebpackHmrApi(hot) {
2
+ return {
3
+ onSuccess (callback) {
4
+ let lastStatus = null;
5
+ const handler = (status)=>{
6
+ if ('idle' === status && 'apply' === lastStatus) try {
7
+ callback();
8
+ } catch (e) {
9
+ console.error('[HMR] Success callback error:', e);
10
+ }
11
+ lastStatus = status;
12
+ };
13
+ hot.addStatusHandler(handler);
14
+ return ()=>hot.removeStatusHandler(handler);
15
+ },
16
+ onError (callback) {
17
+ const handler = (status)=>{
18
+ if ('fail' === status || 'abort' === status) try {
19
+ callback(new Error(`HMR ${status}`));
20
+ } catch (e) {
21
+ console.error('[HMR] Error callback error:', e);
22
+ }
23
+ };
24
+ hot.addStatusHandler(handler);
25
+ return ()=>hot.removeStatusHandler(handler);
26
+ }
27
+ };
28
+ }
29
+ function getHmrApi() {
30
+ if ('production' === process.env.NODE_ENV) return null;
31
+ if (import.meta.webpackHot) return createWebpackHmrApi(import.meta.webpackHot);
32
+ 'undefined' != typeof module && module.hot;
33
+ if (window.__VITE_HMR__) return window.__VITE_HMR__;
34
+ return null;
35
+ }
36
+ export { getHmrApi };
@@ -10,16 +10,20 @@
10
10
  * - abort: An update was aborted, but the system is still in its previous state
11
11
  * - fail: An update has thrown an exception and the system's state has been compromised
12
12
  */
13
- type ModuleHotType = 'idle' | 'check' | 'prepare' | 'ready' | 'dispose' | 'apply' | 'abort' | 'fail';
14
- interface ModuleHotInstance {
13
+ export type ModuleHotType = 'idle' | 'check' | 'prepare' | 'ready' | 'dispose' | 'apply' | 'abort' | 'fail';
14
+ export interface ModuleHotInstance {
15
15
  addStatusHandler: (handler: (status: ModuleHotType) => void) => void;
16
16
  removeStatusHandler: (handler: (status: ModuleHotType) => void) => void;
17
17
  }
18
+ /**
19
+ * 获取 Webpack HMR 实例
20
+ * 仅支持 Webpack/Rspack 的 HMR API
21
+ */
18
22
  export declare function getModuleHot(): ModuleHotInstance | null;
19
23
  /**
20
24
  * 创建模块热更成功处理函数
21
- * 监听模块热更状态,当状态为apply时,调用回调函数并传入true
22
- * @param callback 热更成功回调函数,参数为是否成功
25
+ * 监听模块热更状态,检测 apply -> idle 转换表示热更成功
26
+ *
27
+ * @param callback 热更回调函数,参数为是否成功和当前状态
23
28
  */
24
29
  export declare function createApplyHandle(callback: (success: boolean, status: ModuleHotType) => void): (status: ModuleHotType) => void;
25
- export {};
@@ -1,22 +1,21 @@
1
1
  function getModuleHot() {
2
2
  if ('production' === process.env.NODE_ENV) return null;
3
- return import.meta.webpackHot || module.hot;
3
+ if (import.meta.webpackHot) return import.meta.webpackHot;
4
+ 'undefined' != typeof module && module.hot;
5
+ return null;
4
6
  }
5
7
  function createApplyHandle(callback) {
6
- let hasApply = false;
8
+ let lastStatus = null;
7
9
  return (status)=>{
8
10
  if ('fail' === status || 'abort' === status) {
9
- hasApply = false;
11
+ lastStatus = status;
10
12
  return callback(false, status);
11
13
  }
12
- if (hasApply) {
13
- if ('idle' === status) {
14
- hasApply = false;
15
- callback(true, status);
16
- }
17
- return;
14
+ if ('idle' === status && 'apply' === lastStatus) {
15
+ lastStatus = status;
16
+ return callback(true, status);
18
17
  }
19
- hasApply = 'apply' === status;
18
+ lastStatus = status;
20
19
  };
21
20
  }
22
21
  export { createApplyHandle, getModuleHot };
@@ -4,9 +4,7 @@ async function fetchUserProfilesByIds(ids) {
4
4
  try {
5
5
  const dataloom = await getDataloom();
6
6
  if (!dataloom) throw new Error('Dataloom client is unavailable');
7
- const numericIds = ids.map(Number).filter(Number.isFinite);
8
- if (0 === numericIds.length) return [];
9
- const response = await dataloom.service.user.getByIds(numericIds);
7
+ const response = await dataloom.service.user.getByIds(ids);
10
8
  return Array.isArray(response?.data) ? response.data : response?.data?.user_list || [];
11
9
  } catch (error) {
12
10
  console.error(`Failed to fetch profiles for user IDs ${ids.join(', ')}:`, error);
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 按 appId 隔离的 localStorage 封装
3
+ * API 与原生 localStorage 保持一致
4
+ */
5
+ export declare const scopedStorage: Storage;
@@ -0,0 +1,46 @@
1
+ import { getAppId } from "./getAppId.js";
2
+ function getPrefix() {
3
+ const appId = getAppId(window.location.pathname);
4
+ const namespace = appId || '__global__';
5
+ return `__miaoda_${namespace}__:`;
6
+ }
7
+ function getScopedKeys() {
8
+ const prefix = getPrefix();
9
+ const keys = [];
10
+ for(let i = 0; i < localStorage.length; i++){
11
+ const key = localStorage.key(i);
12
+ if (key && key.startsWith(prefix)) keys.push(key.substring(prefix.length));
13
+ }
14
+ return keys;
15
+ }
16
+ const scopedStorage = {
17
+ getItem (key) {
18
+ const prefixedKey = getPrefix() + key;
19
+ return localStorage.getItem(prefixedKey);
20
+ },
21
+ setItem (key, value) {
22
+ const prefixedKey = getPrefix() + key;
23
+ localStorage.setItem(prefixedKey, value);
24
+ },
25
+ removeItem (key) {
26
+ const prefixedKey = getPrefix() + key;
27
+ localStorage.removeItem(prefixedKey);
28
+ },
29
+ clear () {
30
+ const prefix = getPrefix();
31
+ const keysToRemove = [];
32
+ for(let i = 0; i < localStorage.length; i++){
33
+ const key = localStorage.key(i);
34
+ if (key && key.startsWith(prefix)) keysToRemove.push(key);
35
+ }
36
+ keysToRemove.forEach((key)=>localStorage.removeItem(key));
37
+ },
38
+ key (index) {
39
+ const keys = getScopedKeys();
40
+ return keys[index] || null;
41
+ },
42
+ get length () {
43
+ return getScopedKeys().length;
44
+ }
45
+ };
46
+ export { scopedStorage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.2.17-alpha.1",
3
+ "version": "1.2.17-alpha.3",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -103,7 +103,7 @@
103
103
  "@lark-apaas/auth-sdk": "^0.1.0",
104
104
  "@lark-apaas/client-capability": "^0.1.4",
105
105
  "@lark-apaas/miaoda-inspector": "^1.0.16",
106
- "@lark-apaas/observable-web": "^1.0.2-alpha.2",
106
+ "@lark-apaas/observable-web": "1.0.2-alpha.4",
107
107
  "@radix-ui/react-avatar": "^1.1.10",
108
108
  "@radix-ui/react-popover": "^1.1.15",
109
109
  "@radix-ui/react-slot": "^1.2.3",
@@ -1 +0,0 @@
1
- export declare function connectDevServer(): WebSocket;
@@ -1,57 +0,0 @@
1
- import sockjs_client from "sockjs-client";
2
- import { submitPostMessage, submitSlardarEvent } from "../../../utils/postMessage.js";
3
- import { getWsPath } from "../../../utils/utils.js";
4
- let hotInited = false;
5
- function handleDevServerMessage(msg) {
6
- if ('hash' === msg.type) {
7
- if (!hotInited) {
8
- hotInited = true;
9
- return;
10
- }
11
- submitPostMessage({
12
- type: 'HmrMessage',
13
- msg: {
14
- type: 'hot'
15
- },
16
- data: null
17
- });
18
- } else if ('errors' === msg.type) submitPostMessage({
19
- type: 'HmrMessage',
20
- msg: {
21
- type: 'errors',
22
- data: JSON.stringify(msg.data)
23
- },
24
- data: null
25
- });
26
- else if ('hmr-timing' === msg.type) {
27
- const { duration, fileCount, fileTotalSize } = msg.data;
28
- submitSlardarEvent({
29
- name: 'runTiming',
30
- metrics: {
31
- duration
32
- },
33
- categories: {
34
- type: 'sandbox-hmr-timing',
35
- fileCount,
36
- fileTotalSize
37
- }
38
- });
39
- }
40
- }
41
- function connectDevServer() {
42
- const sockUrl = getWsPath();
43
- const sock = new sockjs_client(sockUrl);
44
- sock.onopen = ()=>console.log('✅ connect DevServer SockJS');
45
- sock.onmessage = (event)=>{
46
- try {
47
- const msg = JSON.parse(event.data);
48
- console.log('hmr 消息:', msg);
49
- handleDevServerMessage(msg);
50
- } catch (err) {
51
- console.error('解析 hmr 消息失败:', event.data);
52
- }
53
- };
54
- return sock;
55
- }
56
- 'production' !== process.env.NODE_ENV && connectDevServer();
57
- export { connectDevServer };
@@ -1 +0,0 @@
1
- export { defaultUIConfig, type UIComponentConfig, } from '@lark-apaas/miaoda-inspector';
@@ -1,2 +0,0 @@
1
- import { defaultUIConfig } from "@lark-apaas/miaoda-inspector";
2
- export { defaultUIConfig };